@techlabi/kycrazy-ui-kit 0.36.0 → 0.37.0
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/CHANGELOG.md +6 -0
- package/dist/index.es.js +3 -0
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -3926,7 +3926,7 @@ Manifest JSON has weights with names: `+u.join(", ")+".");return l=a.reduce(func
|
|
|
3926
3926
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3927
3927
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3928
3928
|
PERFORMANCE OF THIS SOFTWARE.
|
|
3929
|
-
***************************************************************************** */var Wh=function(n,t){return Wh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o])},Wh(n,t)};function De(n,t){Wh(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var dn=function(){return dn=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},dn.apply(this,arguments)};function $e(n,t,e,r){function o(a){return a instanceof e?a:new e(function(i){i(a)})}return new(e||(e=Promise))(function(a,i){function s(l){try{c(r.next(l))}catch(d){i(d)}}function u(l){try{c(r.throw(l))}catch(d){i(d)}}function c(l){l.done?a(l.value):o(l.value).then(s,u)}c((r=r.apply(n,[])).next())})}function ke(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,o,a,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,o&&(a=c[0]&2?o.return:c[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;switch(o=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,o=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){e.label=c[1];break}if(c[0]===6&&e.label<a[1]){e.label=a[1],a=c;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(c);break}a[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(l){c=[6,l],o=0}finally{r=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function eu(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var r=Array(n),o=0,t=0;t<e;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)r[o]=a[i];return r}var Fi=function(){function n(t,e){if(!La(t)||!La(e))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:t,height:e}));this._width=t,this._height=e}return Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),n.prototype.reverse=function(){return new n(1/this.width,1/this.height)},n}();function fl(n,t){return n instanceof bt&&n.shape.length===t}function l5(n){return fl(n,2)}function hl(n){return fl(n,3)}function jo(n){return fl(n,4)}function d5(n){return n%1!==0}function Bb(n){return n%2===0}function f5(n,t){t===void 0&&(t=2);var e=Math.pow(10,t);return Math.floor(n*e)/e}function Wb(n){return n&&n.width&&n.height}function h5(n,t){var e=n.width,r=n.height,o=t/Math.max(r,e);return new Fi(Math.round(e*o),Math.round(r*o))}function Vh(n){return n.reduce(function(t,e){return t.add(e)},new ot(0,0)).div(new ot(n.length,n.length))}function tu(n,t,e){return Array(n).fill(0).map(function(r,o){return t+o*e})}function La(n){return!!n&&n!==1/0&&n!==-1/0&&!isNaN(n)||n===0}function Vb(n){return La(n)&&0<=n&&n<=1}var ot=function(){function n(t,e){this._x=t,this._y=e}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.prototype.sub=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.mul=function(t){return new n(this.x*t.x,this.y*t.y)},n.prototype.div=function(t){return new n(this.x/t.x,this.y/t.y)},n.prototype.abs=function(){return new n(Math.abs(this.x),Math.abs(this.y))},n.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},n.prototype.floor=function(){return new n(Math.floor(this.x),Math.floor(this.y))},n}(),Uo=function(){function n(t,e){e===void 0&&(e=!0);var r=t||{},o=[r.left,r.top,r.right,r.bottom].every(La),a=[r.x,r.y,r.width,r.height].every(La);if(!a&&!o)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var i=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=i[0],u=i[1],c=i[2],l=i[3];n.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",e),this._x=s,this._y=u,this._width=c,this._height=l}return n.isRect=function(t){return!!t&&[t.x,t.y,t.width,t.height].every(La)},n.assertIsValidBox=function(t,e,r){if(r===void 0&&(r=!1),!n.isRect(t))throw new Error(e+" - invalid box: "+JSON.stringify(t)+", expected object with properties x, y, width, height");if(!r&&(t.width<0||t.height<0))throw new Error(e+" - width ("+t.width+") and height ("+t.height+") must be positive numbers")},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topLeft",{get:function(){return new ot(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topRight",{get:function(){return new ot(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomLeft",{get:function(){return new ot(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomRight",{get:function(){return new ot(this.right,this.bottom)},enumerable:!0,configurable:!0}),n.prototype.round=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.round(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.floor=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.floor(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.toSquare=function(){var t=this,e=t.x,r=t.y,o=t.width,a=t.height,i=Math.abs(o-a);return o<a&&(e-=i/2,o+=i),a<o&&(r-=i/2,a+=i),new n({x:e,y:r,width:o,height:a})},n.prototype.rescale=function(t){var e=Wb(t)?t.width:t,r=Wb(t)?t.height:t;return new n({x:this.x*e,y:this.y*r,width:this.width*e,height:this.height*r})},n.prototype.pad=function(t,e){var r=[this.x-t/2,this.y-e/2,this.width+t,this.height+e],o=r[0],a=r[1],i=r[2],s=r[3];return new n({x:o,y:a,width:i,height:s})},n.prototype.clipAtImageBorders=function(t,e){var r=this,o=r.x,a=r.y,i=r.right,s=r.bottom,u=Math.max(o,0),c=Math.max(a,0),l=i-u,d=s-c,f=Math.min(l,t-u),h=Math.min(d,e-c);return new n({x:u,y:c,width:f,height:h}).floor()},n.prototype.shift=function(t,e){var r=this,o=r.width,a=r.height,i=this.x+t,s=this.y+e;return new n({x:i,y:s,width:o,height:a})},n.prototype.padAtBorders=function(t,e){var r=this.width+1,o=this.height+1,a=1,i=1,s=r,u=o,c=this.left,l=this.top,d=this.right,f=this.bottom;return d>e&&(s=-d+e+r,d=e),f>t&&(u=-f+t+o,f=t),c<1&&(u=2-c,c=1),l<1&&(u=2-l,l=1),{dy:i,edy:u,dx:a,edx:s,y:l,ey:f,x:c,ex:d,w:r,h:o}},n.prototype.calibrate=function(t){return new n({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()},n}(),pl=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{left:e,top:r,right:o,bottom:a},i)||this}return t}(Uo),jb=function(){function n(t,e,r,o,a){this._imageDims=new Fi(a.width,a.height),this._score=t,this._classScore=e,this._className=r,this._box=new Uo(o).rescale(this._imageDims)}return Object.defineProperty(n.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativeBox",{get:function(){return new Uo(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new n(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:e})},n}(),Wr=function(n){De(t,n);function t(e,r,o){return n.call(this,e,e,"",r,o)||this}return t.prototype.forSize=function(e,r){var o=n.prototype.forSize.call(this,e,r),a=o.score,i=o.relativeBox,s=o.imageDims;return new t(a,i,s)},t}(jb);function p5(n,t,e){e===void 0&&(e=!0);var r=Math.max(0,Math.min(n.right,t.right)-Math.max(n.left,t.left)),o=Math.max(0,Math.min(n.bottom,t.bottom)-Math.max(n.top,t.top)),a=r*o;return e?a/(n.area+t.area-a):a/Math.min(n.area,t.area)}function v5(n){var t=n.map(function(s){return s.x}),e=n.map(function(s){return s.y}),r=t.reduce(function(s,u){return u<s?u:s},1/0),o=e.reduce(function(s,u){return u<s?u:s},1/0),a=t.reduce(function(s,u){return s<u?u:s},0),i=e.reduce(function(s,u){return s<u?u:s},0);return new pl(r,o,a,i)}function nu(n,t,e,r){r===void 0&&(r=!0);for(var o=t.map(function(s,u){return{score:s,boxIndex:u}}).sort(function(s,u){return s.score-u.score}).map(function(s){return s.boxIndex}),a=[],i=function(){var s=o.pop();a.push(s);for(var u=o,c=[],l=0;l<u.length;l++){var d=u[l],f=n[s],h=n[d];c.push(p5(f,h,r))}o=o.filter(function(m,p){return c[p]<=e})};o.length>0;)i();return a}function ru(n,t){return xe(function(){var e=t[0],r=t[1],o=t[2],a=Lr(eu(n.shape.slice(0,3),[1]),e),i=Lr(eu(n.shape.slice(0,3),[1]),r),s=Lr(eu(n.shape.slice(0,3),[1]),o),u=Vt([a,i,s],3);return zt(n,u)})}function m5(n,t){return t===void 0&&(t=!1),xe(function(){var e=n.shape.slice(1),r=e[0],o=e[1];if(r===o)return n;var a=Math.abs(r-o),i=Math.round(a*(t?.5:1)),s=r>o?2:1,u=function(h){var m=n.shape.slice();return m[s]=h,Lr(m,0)},c=u(i),l=a-c.shape[s],d=t&&l?u(l):null,f=[d,n,c].filter(function(h){return!!h}).map(function(h){return h.toFloat()});return Vt(f,s)})}function jh(n){return 1/(1+Math.exp(-n))}var Uh=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{x:e,y:r,width:o,height:a},i)||this}return t}(Uo),g5=.5,y5=.43,b5=.45,vl=function(){function n(t,e,r){r===void 0&&(r=new ot(0,0));var o=e.width,a=e.height;this._imgDims=new Fi(o,a),this._shift=r,this._positions=t.map(function(i){return i.mul(new ot(o,a)).add(r)})}return Object.defineProperty(n.prototype,"shift",{get:function(){return new ot(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativePositions",{get:function(){var t=this;return this._positions.map(function(e){return e.sub(t._shift).div(new ot(t.imageWidth,t.imageHeight))})},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new this.constructor(this.relativePositions,{width:t,height:e})},n.prototype.shiftBy=function(t,e){return new this.constructor(this.relativePositions,this._imgDims,new ot(t,e))},n.prototype.shiftByPoint=function(t){return this.shiftBy(t.x,t.y)},n.prototype.align=function(t,e){if(e===void 0&&(e={}),t){var r=t instanceof Wr?t.box.floor():new Uo(t);return this.shiftBy(r.x,r.y).align(null,e)}var o=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},e),a=o.useDlibAlignment,i=o.minBoxPadding;return a?this.alignDlib():this.alignMinBbox(i)},n.prototype.alignDlib=function(){var t=this.getRefPointsForAlignment(),e=t[0],r=t[1],o=t[2],a=function(d){return o.sub(d).magnitude()},i=(a(e)+a(r))/2,s=Math.floor(i/b5),u=Vh(t),c=Math.floor(Math.max(0,u.x-g5*s)),l=Math.floor(Math.max(0,u.y-y5*s));return new Uh(c,l,Math.min(s,this.imageWidth+c),Math.min(s,this.imageHeight+l))},n.prototype.alignMinBbox=function(t){var e=v5(this.positions);return e.pad(e.width*t,e.height*t)},n.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},n}(),x5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getRefPointsForAlignment=function(){var e=this.positions;return[e[0],e[1],Vh([e[3],e[4]])]},t}(vl),w5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getJawOutline=function(){return this.positions.slice(0,17)},t.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},t.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},t.prototype.getNose=function(){return this.positions.slice(27,36)},t.prototype.getLeftEye=function(){return this.positions.slice(36,42)},t.prototype.getRightEye=function(){return this.positions.slice(42,48)},t.prototype.getMouth=function(){return this.positions.slice(48,68)},t.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Vh)},t}(vl),Ub=function(){function n(t,e){this._label=t,this._distance=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),n.prototype.toString=function(t){return t===void 0&&(t=!0),""+this.label+(t?" ("+f5(this.distance)+")":"")},n}(),zb=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._label=r,o}return t.assertIsValidLabeledBox=function(e,r){if(Uo.assertIsValidBox(e,r),!La(e.label))throw new Error(r+" - expected property label ("+e.label+") to be a number")},Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),t}(Uo),ml=function(){function n(t,e){if(typeof t!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(e)||e.some(function(r){return!(r instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),n.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(t){return Array.from(t)})}},n.fromJSON=function(t){var e=t.descriptors.map(function(r){return new Float32Array(r)});return new n(t.label,e)},n}();(function(n){De(t,n);function t(e,r,o,a){var i=n.call(this,e,r)||this;return i._score=o,i._classScore=a,i}return t.assertIsValidPredictedBox=function(e,r){if(zb.assertIsValidLabeledBox(e,r),!Vb(e.score)||!Vb(e.classScore))throw new Error(r+" - expected properties score ("+e.score+") and ("+e.classScore+") to be a number between [0, 1]")},Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),t})(zb);function C5(n){return n.detection instanceof Wr}function zh(n,t){var e={detection:t};return Object.assign({},n,e)}function Hb(){var n=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},t=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:n,readFile:t}}function Gb(n){var t="";if(!n)try{n=require("fs")}catch(r){t=r.toString()}var e=n?function(r){return new Promise(function(o,a){n.readFile(r,function(i,s){return i?a(i):o(s)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+t)};return{readFile:e}}function qb(){var n=global.Canvas||global.HTMLCanvasElement,t=global.Image||global.HTMLImageElement,e=function(){if(n)return new n;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},r=function(){if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},o=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},a=Gb();return dn({Canvas:n||function(){function i(){}return i}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function i(){}return i}(),Image:t||function(){function i(){}return i}(),ImageData:global.ImageData||function(){function i(){}return i}(),Video:global.HTMLVideoElement||function(){function i(){}return i}(),createCanvasElement:e,createImageElement:r,fetch:o},a)}function Kb(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function Yb(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var Ht;function _5(){if(!Ht)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return Ht}function Hh(n){Ht=n}function Gh(){Kb()&&Hh(Hb()),Yb()&&Hh(qb())}function E5(n){if(Ht||Gh(),!Ht)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var t=n.Canvas,e=t===void 0?Ht.Canvas:t,r=n.Image,o=r===void 0?Ht.Image:r;Ht.Canvas=e,Ht.Image=o,Ht.createCanvasElement=n.createCanvasElement||function(){return new e},Ht.createImageElement=n.createImageElement||function(){return new o},Ht.ImageData=n.ImageData||Ht.ImageData,Ht.Video=n.Video||Ht.Video,Ht.fetch=n.fetch||Ht.fetch,Ht.readFile=n.readFile||Ht.readFile}var rn={getEnv:_5,setEnv:Hh,initialize:Gh,createBrowserEnv:Hb,createFileSystem:Gb,createNodejsEnv:qb,monkeyPatch:E5,isBrowser:Kb,isNodejs:Yb};Gh();function Xb(n){return!rn.isNodejs()&&typeof n=="string"?document.getElementById(n):n}function Ba(n){var t=rn.getEnv(),e=t.Canvas,r=t.CanvasRenderingContext2D;if(n instanceof r)return n;var o=Xb(n);if(!(o instanceof e))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var a=o.getContext("2d");if(!a)throw new Error("resolveContext2d - canvas 2d context is null");return a}var Zb;(function(n){n.TOP_LEFT="TOP_LEFT",n.TOP_RIGHT="TOP_RIGHT",n.BOTTOM_LEFT="BOTTOM_LEFT",n.BOTTOM_RIGHT="BOTTOM_RIGHT"})(Zb||(Zb={}));function Qb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e&&n.complete||n instanceof r&&n.readyState>=3}function S5(n){return new Promise(function(t,e){if(n instanceof rn.getEnv().Canvas||Qb(n))return t();function r(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),t(a))}function o(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),e(a))}n.addEventListener("load",r),n.addEventListener("error",o)})}function Jb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e?new Fi(n.naturalWidth,n.naturalHeight):n instanceof r?new Fi(n.videoWidth,n.videoHeight):new Fi(n.width,n.height)}function gl(n){var t=n.width,e=n.height,r=rn.getEnv().createCanvasElement,o=r();return o.width=t,o.height=e,o}function qh(n,t){var e=rn.getEnv().ImageData;if(!(n instanceof e)&&!Qb(n))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=Jb(n),o=r.width,a=r.height,i=gl({width:o,height:a});return n instanceof e?Ba(i).putImageData(n,0,0):Ba(i).drawImage(n,0,0,o,a),i}function N5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return e=rn.getEnv().createCanvasElement(),r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=xe(function(){return n.as3D(o,a,i).toInt()}),[4,Bh.toPixels(s,e)];case 1:return u.sent(),s.dispose(),[2,e]}})})}function e2(n){var t=rn.getEnv(),e=t.Image,r=t.Canvas,o=t.Video;return n instanceof e||n instanceof r||n instanceof o}function $5(n,t,e){e===void 0&&(e=!1);var r=rn.getEnv(),o=r.Image,a=r.Canvas;if(!(n instanceof o||n instanceof a))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var i=Jb(n),s=t/Math.max(i.height,i.width),u=s*i.width,c=s*i.height,l=gl({width:t,height:t}),d=n instanceof a?n:qh(n),f=Math.abs(u-c)/2,h=e&&u<c?f:0,m=e&&c<u?f:0;return Ba(l).drawImage(d,h,m,u,c),l}var yl=function(){function n(t,e){var r=this;if(e===void 0&&(e=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(t))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+t);this._treatAsBatchInput=e,this._batchSize=t.length,t.forEach(function(o,a){if(hl(o)){r._imageTensors[a]=o,r._inputDimensions[a]=o.shape;return}if(jo(o)){var i=o.shape[0];if(i!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+i+" passed, but not supported in input array");r._imageTensors[a]=o,r._inputDimensions[a]=o.shape.slice(1);return}var s=o instanceof rn.getEnv().Canvas?o:qh(o);r._canvases[a]=s,r._inputDimensions[a]=[s.height,s.width,3]})}return Object.defineProperty(n.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"reshapedInputDimensions",{get:function(){var t=this;return tu(this.batchSize,0,1).map(function(e,r){return t.getReshapedInputDimensions(r)})},enumerable:!0,configurable:!0}),n.prototype.getInput=function(t){return this.canvases[t]||this.imageTensors[t]},n.prototype.getInputDimensions=function(t){return this._inputDimensions[t]},n.prototype.getInputHeight=function(t){return this._inputDimensions[t][0]},n.prototype.getInputWidth=function(t){return this._inputDimensions[t][1]},n.prototype.getReshapedInputDimensions=function(t){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var e=this.getInputWidth(t),r=this.getInputHeight(t);return h5({width:e,height:r},this.inputSize)},n.prototype.toBatchTensor=function(t,e){var r=this;return e===void 0&&(e=!0),this._inputSize=t,xe(function(){var o=tu(r.batchSize,0,1).map(function(i){var s=r.getInput(i);if(s instanceof bt){var u=jo(s)?s:s.expandDims();return u=m5(u,e),(u.shape[1]!==t||u.shape[2]!==t)&&(u=wh.resizeBilinear(u,[t,t])),u.as3D(t,t,3)}if(s instanceof rn.getEnv().Canvas)return Bh.fromPixels($5(s,t,e));throw new Error("toBatchTensor - at batchIdx "+i+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+s)}),a=Bn(o.map(function(i){return i.toFloat()})).as4D(r.batchSize,t,t,3);return a})},n}();function Yt(n){return $e(this,void 0,void 0,function(){var t,e,r;return ke(this,function(o){switch(o.label){case 0:if(n instanceof yl)return[2,n];if(t=Array.isArray(n)?n:[n],!t.length)throw new Error("toNetInput - empty array passed as input");return e=function(a){return Array.isArray(n)?" at input index "+a+":":""},r=t.map(Xb),r.forEach(function(a,i){if(!e2(a)&&!hl(a)&&!jo(a))throw typeof t[i]=="string"?new Error("toNetInput -"+e(i)+" string passed, but could not resolve HTMLElement for element id "+t[i]):new Error("toNetInput -"+e(i)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(jo(a)){var s=a.shape[0];if(s!==1)throw new Error("toNetInput -"+e(i)+" tf.Tensor4D with batchSize "+s+" passed, but not supported in input array")}}),[4,Promise.all(r.map(function(a){return e2(a)&&S5(a)}))];case 1:return o.sent(),[2,new yl(r,Array.isArray(n))]}})})}function Kh(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u;return ke(this,function(c){switch(c.label){case 0:return e=rn.getEnv().Canvas,r=n,n instanceof e?[3,5]:[4,Yt(n)];case 1:if(o=c.sent(),o.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return a=o.getInput(0),a instanceof e?(i=a,[3,4]):[3,2];case 2:return[4,N5(a)];case 3:i=c.sent(),c.label=4;case 4:r=i,c.label=5;case 5:return s=Ba(r),u=t.map(function(l){return l instanceof Wr?l.forSize(r.width,r.height).box.floor():l}).map(function(l){return l.clipAtImageBorders(r.width,r.height)}),[2,u.map(function(l){var d=l.x,f=l.y,h=l.width,m=l.height,p=gl({width:h,height:m});return Ba(p).putImageData(s.getImageData(d,f,h,m),0,0),p})]}})})}function Yh(n,t){return $e(this,void 0,void 0,function(){return ke(this,function(e){if(!hl(n)&&!jo(n))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jo(n)&&n.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,xe(function(){var r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=t.map(function(c){return c instanceof Wr?c.forSize(a,o).box:c}).map(function(c){return c.clipAtImageBorders(a,o)}),u=s.map(function(c){var l=c.x,d=c.y,f=c.width,h=c.height;return sb(n.as3D(o,a,i),[d,l,0],[h,f,i])});return u})]})})}function k5(n,t){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return e=rn.getEnv().fetch,[4,e(n,t)];case 1:if(r=o.sent(),!(r.status<400))throw new Error("failed to fetch: ("+r.status+") "+r.statusText+", from url: "+r.url);return[2,r]}})})}function P5(n){return $e(this,void 0,void 0,function(){return ke(this,function(t){switch(t.label){case 0:return[4,k5(n)];case 1:return[2,t.sent().json()]}})})}function t2(n,t){var e=t+"-weights_manifest.json";if(!n)return{modelBaseUri:"",manifestUri:e};if(n==="/")return{modelBaseUri:"/",manifestUri:"/"+e};var r=n.startsWith("http://")?"http://":n.startsWith("https://")?"https://":"";n=n.replace(r,"");var o=n.split("/").filter(function(s){return s}),a=n.endsWith(".json")?o[o.length-1]:e,i=r+(n.endsWith(".json")?o.slice(0,o.length-1):o).join("/");return i=n.startsWith("/")?"/"+i:i,{modelBaseUri:i,manifestUri:i==="/"?"/"+a:i+"/"+a}}function I5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=t2(n,t),r=e.manifestUri,o=e.modelBaseUri,[4,P5(r)];case 1:return a=i.sent(),[2,Rb.loadWeights(a,o)]}})})}var uo=function(){function n(t){this._name=t,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(n.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),n.prototype.getParamFromPath=function(t){var e=this.traversePropertyPath(t),r=e.obj,o=e.objProp;return r[o]},n.prototype.reassignParamFromPath=function(t,e){var r=this.traversePropertyPath(t),o=r.obj,a=r.objProp;o[a].dispose(),o[a]=e},n.prototype.getParamList=function(){var t=this;return this._paramMappings.map(function(e){var r=e.paramPath;return{path:r,tensor:t.getParamFromPath(r)}})},n.prototype.getTrainableParams=function(){return this.getParamList().filter(function(t){return t.tensor instanceof xi})},n.prototype.getFrozenParams=function(){return this.getParamList().filter(function(t){return!(t.tensor instanceof xi)})},n.prototype.variable=function(){var t=this;this.getFrozenParams().forEach(function(e){var r=e.path,o=e.tensor;t.reassignParamFromPath(r,o.variable())})},n.prototype.freeze=function(){var t=this;this.getTrainableParams().forEach(function(e){var r=e.path,o=e.tensor,a=nn(o.dataSync());o.dispose(),t.reassignParamFromPath(r,a)})},n.prototype.dispose=function(t){t===void 0&&(t=!0),this.getParamList().forEach(function(e){if(t&&e.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+e.path);e.tensor.dispose()}),this._params=void 0},n.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(t){var e=t.tensor;return Array.from(e.dataSync())}).reduce(function(t,e){return t.concat(e)}))},n.prototype.load=function(t){return $e(this,void 0,void 0,function(){return ke(this,function(e){switch(e.label){case 0:return t instanceof Float32Array?(this.extractWeights(t),[2]):[4,this.loadFromUri(t)];case 1:return e.sent(),[2]}})})},n.prototype.loadFromUri=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,I5(t,this.getDefaultModelName())];case 1:return e=r.sent(),this.loadFromWeightMap(e),[2]}})})},n.prototype.loadFromDisk=function(t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u,c,l,d;return ke(this,function(f){switch(f.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return e=rn.getEnv().readFile,r=t2(t,this.getDefaultModelName()),o=r.manifestUri,a=r.modelBaseUri,i=function(h){return Promise.all(h.map(function(m){return e(m).then(function(p){return p.buffer})}))},s=Rb.weightsLoaderFactory(i),l=(c=JSON).parse,[4,e(o)];case 1:return u=l.apply(c,[f.sent().toString()]),[4,s(u,a)];case 2:return d=f.sent(),this.loadFromWeightMap(d),[2]}})})},n.prototype.loadFromWeightMap=function(t){var e=this.extractParamsFromWeigthMap(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.extractWeights=function(t){var e=this.extractParams(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.traversePropertyPath=function(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var e=t.split("/").reduce(function(a,i){if(!a.nextObj.hasOwnProperty(i))throw new Error("traversePropertyPath - object does not have property "+i+", for path "+t);return{obj:a.nextObj,objProp:i,nextObj:a.nextObj[i]}},{nextObj:this.params}),r=e.obj,o=e.objProp;if(!r||!o||!(r[o]instanceof bt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+t);return{obj:r,objProp:o}},n}();function Vn(n,t,e){return xe(function(){var r=mh(n,t.depthwise_filter,t.pointwise_filter,e,"same");return r=qe(r,t.bias),r})}function Xh(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=wt(e?qe(Zn(n,t.conv0.filters,[2,2],"same"),t.conv0.bias):Vn(n,t.conv0,[2,2])),o=Vn(r,t.conv1,[1,1]),a=wt(qe(r,o)),i=Vn(a,t.conv2,[1,1]);return wt(qe(r,qe(o,i)))})}function bl(n,t,e,r){return e===void 0&&(e=!1),r===void 0&&(r=!0),xe(function(){var o=wt(e?qe(Zn(n,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):Vn(n,t.conv0,r?[2,2]:[1,1])),a=Vn(o,t.conv1,[1,1]),i=wt(qe(o,a)),s=Vn(i,t.conv2,[1,1]),u=wt(qe(o,qe(a,s))),c=Vn(u,t.conv3,[1,1]);return wt(qe(o,qe(a,qe(s,c))))})}function cr(n,t,e,r){return e===void 0&&(e="same"),r===void 0&&(r=!1),xe(function(){var o=qe(Zn(n,t.filters,[1,1],e),t.bias);return r?wt(o):o})}function co(n,t){Object.keys(n).forEach(function(e){t.some(function(r){return r.originalPath===e})||n[e].dispose()})}function xl(n,t){return function(e,r,o,a){var i=Sn(n(e*r*o*o),[o,o,e,r]),s=Ot(n(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}}function Zh(n,t){return function(e,r,o){var a=Ro(n(e*r),[e,r]),i=Ot(n(r));return t.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:a,bias:i}}}var n2=function(){function n(t,e,r){this.depthwise_filter=t,this.pointwise_filter=e,this.bias=r}return n}();function Qh(n,t){return function(e,r,o){var a=Sn(n(9*e),[3,3,e,1]),i=Sn(n(e*r),[1,1,e,r]),s=Ot(n(r));return t.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new n2(a,i,s)}}function Jh(n){return function(t){var e=n(t+"/depthwise_filter",4),r=n(t+"/pointwise_filter",4),o=n(t+"/bias",1);return new n2(e,r,o)}}function zo(n,t){return function(e,r,o){var a=n[e];if(!fl(a,r))throw new Error("expected weightMap["+e+"] to be a Tensor"+r+"D, instead have "+a);return t.push({originalPath:e,paramPath:o||e}),a}}function lo(n){var t=n;function e(o){var a=t.slice(0,o);return t=t.slice(o),a}function r(){return t}return{extractWeights:e,getRemainingWeights:r}}function r2(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u,c){c===void 0&&(c=!1);var l=c?e(i,s,3,u+"/conv0"):r(i,s,u+"/conv0"),d=r(s,s,u+"/conv1"),f=r(s,s,u+"/conv2");return{conv0:l,conv1:d,conv2:f}}function a(i,s,u,c){c===void 0&&(c=!1);var l=o(i,s,u,c),d=l.conv0,f=l.conv1,h=l.conv2,m=r(s,s,u+"/conv3");return{conv0:d,conv1:f,conv2:h,conv3:m}}return{extractDenseBlock3Params:o,extractDenseBlock4Params:a}}function A5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock4Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2"),c=a(128,256,"dense3");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u,dense3:c}}}function o2(n){return function(t){var e=n(t+"/filters",4),r=n(t+"/bias",1);return{filters:e,bias:r}}}function a2(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2");return{conv0:c,conv1:l,conv2:d}}function i(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2"),f=o(s+"/conv3");return{conv0:c,conv1:l,conv2:d,conv3:f}}return{extractDenseBlock3Params:a,extractDenseBlock4Params:i}}function T5(n){var t=[],e=a2(n,t).extractDenseBlock4Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2"),dense3:e("dense3")};return co(n,t),{params:r,paramMappings:t}}var i2=function(n){De(t,n);function t(){return n.call(this,"FaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=bl(i,r.dense0,!0);return s=bl(s,r.dense1),s=bl(s,r.dense2),s=bl(s,r.dense3),s=Qs(s,[7,7],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},t.prototype.extractParamsFromWeigthMap=function(e){return T5(e)},t.prototype.extractParams=function(e){return A5(e)},t}(uo);function Vr(n,t){return xe(function(){return qe(il(n,t.weights),t.bias)})}function O5(n,t,e){var r=[],o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=Zh(a,r),u=s(t,e,"fc");if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{paramMappings:r,params:{fc:u}}}function D5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:r("fc")};return co(n,t),{params:o,paramMappings:t}}function s2(n){var t={},e={};return Object.keys(n).forEach(function(r){var o=r.startsWith("fc")?e:t;o[r]=n[r]}),{featureExtractorMap:t,classifierMap:e}}var u2=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._faceFeatureExtractor=r,o}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e;return Vr(a.as2D(a.shape[0],-1),o.fc)})},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return O5(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),D5(a)},t.prototype.extractParams=function(e){var r=this.getClassifierChannelsIn(),o=this.getClassifierChannelsOut(),a=o*r+o,i=e.slice(0,e.length-a),s=e.slice(e.length-a);return this.faceFeatureExtractor.extractWeights(i),this.extractClassifierParams(s)},t}(uo),c2=["neutral","happy","sad","angry","fearful","disgusted","surprised"],M5=function(){function n(t){var e=this;if(t.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+t.length);c2.forEach(function(r,o){e[r]=t[o]})}return n.prototype.asSortedArray=function(){var t=this;return c2.map(function(e){return{expression:e,probability:t[e]}}).sort(function(e,r){return r.probability-e.probability})},n}(),F5=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceExpressionNet",e)||this}return t.prototype.forwardInput=function(e){var r=this;return xe(function(){return oo(r.runNet(e))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictExpressions=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,Yt(e)];case 1:return r=u.sent(),[4,this.forwardInput(r)];case 2:return o=u.sent(),[4,Promise.all(jt(o).map(function(c){return $e(s,void 0,void 0,function(){var l;return ke(this,function(d){switch(d.label){case 0:return[4,c.data()];case 1:return l=d.sent(),c.dispose(),[2,l]}})})}))];case 3:return a=u.sent(),o.dispose(),i=a.map(function(c){return new M5(c)}),[2,r.isBatchInput?i:i[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_expression_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t.prototype.getClassifierChannelsOut=function(){return 7},t}(u2);function l2(n,t){var e={expressions:t};return Object.assign({},n,e)}function R5(n){return C5(n)&&n.landmarks instanceof vl&&n.unshiftedLandmarks instanceof vl&&n.alignedRect instanceof Wr}function ep(n,t){var e=n.detection.box,r=t.shiftBy(e.x,e.y),o=r.align(),a=n.detection.imageDims,i=new Wr(n.detection.score,o.rescale(a.reverse()),a),s={landmarks:r,unshiftedLandmarks:t,alignedRect:i};return Object.assign({},n,s)}function L5(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u){var c=r(i,s,u+"/separable_conv0"),l=r(s,s,u+"/separable_conv1"),d=e(i,s,1,u+"/expansion_conv");return{separable_conv0:c,separable_conv1:l,expansion_conv:d}}function a(i,s){var u=r(i,i,s+"/separable_conv0"),c=r(i,i,s+"/separable_conv1"),l=r(i,i,s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:e,extractSeparableConvParams:r,extractReductionBlockParams:o,extractMainBlockParams:a}}function B5(n,t){var e=[],r=lo(n),o=r.extractWeights,a=r.getRemainingWeights,i=L5(o,e),s=i.extractConvParams,u=i.extractSeparableConvParams,c=i.extractReductionBlockParams,l=i.extractMainBlockParams,d=s(3,32,3,"entry_flow/conv_in"),f=c(32,64,"entry_flow/reduction_block_0"),h=c(64,128,"entry_flow/reduction_block_1"),m={conv_in:d,reduction_block_0:f,reduction_block_1:h},p={};tu(t,0,1).forEach(function(w){p["main_block_"+w]=l(128,"middle_flow/main_block_"+w)});var v=c(128,256,"exit_flow/reduction_block"),g=u(256,512,"exit_flow/separable_conv"),y={reduction_block:v,separable_conv:g};if(a().length!==0)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:e,params:{entry_flow:m,middle_flow:p,exit_flow:y}}}function W5(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=r(s+"/expansion_conv");return{separable_conv0:u,separable_conv1:c,expansion_conv:l}}function i(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=o(s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:r,extractSeparableConvParams:o,extractReductionBlockParams:a,extractMainBlockParams:i}}function V5(n,t){var e=[],r=W5(n,e),o=r.extractConvParams,a=r.extractSeparableConvParams,i=r.extractReductionBlockParams,s=r.extractMainBlockParams,u=o("entry_flow/conv_in"),c=i("entry_flow/reduction_block_0"),l=i("entry_flow/reduction_block_1"),d={conv_in:u,reduction_block_0:c,reduction_block_1:l},f={};tu(t,0,1).forEach(function(v){f["main_block_"+v]=s("middle_flow/main_block_"+v)});var h=i("exit_flow/reduction_block"),m=a("exit_flow/separable_conv"),p={reduction_block:h,separable_conv:m};return co(n,e),{params:{entry_flow:d,middle_flow:f,exit_flow:p},paramMappings:e}}function d2(n,t,e){return qe(Zn(n,t.filters,e,"same"),t.bias)}function tp(n,t,e){e===void 0&&(e=!0);var r=e?wt(n):n;return r=Vn(r,t.separable_conv0,[1,1]),r=Vn(wt(r),t.separable_conv1,[1,1]),r=Kt(r,[3,3],[2,2],"same"),r=qe(r,d2(n,t.expansion_conv,[2,2])),r}function j5(n,t){var e=Vn(wt(n),t.separable_conv0,[1,1]);return e=Vn(wt(e),t.separable_conv1,[1,1]),e=Vn(wt(e),t.separable_conv2,[1,1]),e=qe(e,n),e}var U5=function(n){De(t,n);function t(e){var r=n.call(this,"TinyXception")||this;return r._numMainBlocks=e,r}return t.prototype.forwardInput=function(e){var r=this,o=this.params;if(!o)throw new Error("TinyXception - load model before inference");return xe(function(){var a=e.toBatchTensor(112,!0),i=[122.782,117.001,104.298],s=ru(a,i).div(ve(256)),u=wt(d2(s,o.entry_flow.conv_in,[2,2]));return u=tp(u,o.entry_flow.reduction_block_0,!1),u=tp(u,o.entry_flow.reduction_block_1),tu(r._numMainBlocks,0,1).forEach(function(c){u=j5(u,o.middle_flow["main_block_"+c])}),u=tp(u,o.exit_flow.reduction_block),u=wt(Vn(u,o.exit_flow.separable_conv,[1,1])),u})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"tiny_xception_model"},t.prototype.extractParamsFromWeigthMap=function(e){return V5(e,this._numMainBlocks)},t.prototype.extractParams=function(e){return B5(e,this._numMainBlocks)},t}(uo);function z5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=Zh(r,t),i=a(512,1,"fc/age"),s=a(512,2,"fc/gender");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{fc:{age:i,gender:s}}}}function H5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:{age:r("fc/age"),gender:r("fc/gender")}};return co(n,t),{params:o,paramMappings:t}}var wl;(function(n){n.FEMALE="female",n.MALE="male"})(wl||(wl={}));var G5=function(n){De(t,n);function t(e){e===void 0&&(e=new U5(2));var r=n.call(this,"AgeGenderNet")||this;return r._faceFeatureExtractor=e,r}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e,i=Qs(a,[7,7],[2,2],"valid").as2D(a.shape[0],-1),s=Vr(i,o.fc.age).as1D(),u=Vr(i,o.fc.gender);return{age:s,gender:u}})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e),a=o.age,i=o.gender;return{age:a,gender:oo(i)}})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictAgeAndGender=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s,u,c=this;return ke(this,function(l){switch(l.label){case 0:return[4,Yt(e)];case 1:return r=l.sent(),[4,this.forwardInput(r)];case 2:return o=l.sent(),a=jt(o.age),i=jt(o.gender),s=a.map(function(d,f){return{ageTensor:d,genderTensor:i[f]}}),[4,Promise.all(s.map(function(d){var f=d.ageTensor,h=d.genderTensor;return $e(c,void 0,void 0,function(){var m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return[4,f.data()];case 1:return m=w.sent()[0],[4,h.data()];case 2:return p=w.sent()[0],v=p>.5,g=v?wl.MALE:wl.FEMALE,y=v?p:1-p,f.dispose(),h.dispose(),[2,{age:m,gender:g,genderProbability:y}]}})})}))];case 3:return u=l.sent(),o.age.dispose(),o.gender.dispose(),[2,r.isBatchInput?u:u[0]]}})})},t.prototype.getDefaultModelName=function(){return"age_gender_model"},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return z5(e)},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),H5(a)},t.prototype.extractParams=function(e){var r=1539,o=e.slice(0,e.length-r),a=e.slice(e.length-r);return this.faceFeatureExtractor.extractWeights(o),this.extractClassifierParams(a)},t}(uo),f2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.postProcess=function(e,r,o){var a=o.map(function(s){var u=s.width,c=s.height,l=r/Math.max(c,u);return{width:u*l,height:c*l}}),i=a.length;return xe(function(){var s=function(f,h){return Bn([Lr([68],f),Lr([68],h)],1).as2D(1,136).as1D()},u=function(f,h){var m=a[f],p=m.width,v=m.height;return h(p,v)?Math.abs(p-v)/2:0},c=function(f){return u(f,function(h,m){return h<m})},l=function(f){return u(f,function(h,m){return m<h})},d=e.mul(Lr([i,136],r)).sub(Bn(Array.from(Array(i),function(f,h){return s(c(h),l(h))}))).div(Bn(Array.from(Array(i),function(f,h){return s(a[h].width,a[h].height)})));return d})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e);return r.postProcess(o,e.inputSize,e.inputDimensions.map(function(a){var i=a[0],s=a[1];return{height:i,width:s}}))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.detectLandmarks=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u,c){return $e(i,void 0,void 0,function(){var l,d,f,h,m;return ke(this,function(p){switch(p.label){case 0:return f=(d=Array).from,[4,u.data()];case 1:return l=f.apply(d,[p.sent()]),h=l.filter(function(v,g){return Bb(g)}),m=l.filter(function(v,g){return!Bb(g)}),[2,new w5(Array(68).fill(0).map(function(v,g){return new ot(h[g],m[g])}),{height:r.getInputHeight(c),width:r.getInputWidth(c)})]}})})}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getClassifierChannelsOut=function(){return 136},t}(u2),h2=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceLandmark68Net",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t}(f2);function q5(n){var t=[],e=a2(n,t).extractDenseBlock3Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2")};return co(n,t),{params:r,paramMappings:t}}function K5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock3Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u}}}var Y5=function(n){De(t,n);function t(){return n.call(this,"TinyFaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("TinyFaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=Xh(i,r.dense0,!0);return s=Xh(s,r.dense1),s=Xh(s,r.dense2),s=Qs(s,[14,14],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},t.prototype.extractParamsFromWeigthMap=function(e){return q5(e)},t.prototype.extractParams=function(e){return K5(e)},t}(uo),X5=function(n){De(t,n);function t(e){return e===void 0&&(e=new Y5),n.call(this,"FaceLandmark68TinyNet",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},t.prototype.getClassifierChannelsIn=function(){return 128},t}(f2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(h2);function Z5(n,t){return qe(cn(n,t.weights),t.biases)}function np(n,t,e,r,o){o===void 0&&(o="same");var a=t.conv,i=a.filters,s=a.bias,u=Zn(n,i,e,o);return u=qe(u,s),u=Z5(u,t.scale),r?wt(u):u}function Q5(n,t){return np(n,t,[1,1],!0)}function p2(n,t){return np(n,t,[1,1],!1)}function v2(n,t){return np(n,t,[2,2],!0,"valid")}function J5(n,t){function e(s,u,c){var l=n(s),d=l.length/(u*c*c);if(d5(d))throw new Error("depth has to be an integer: "+d+", weights.length: "+l.length+", numFilters: "+u+", filterSize: "+c);return xe(function(){return Bo(Sn(l,[u,d,c,c]),[2,3,1,0])})}function r(s,u,c,l){var d=e(s,u,c),f=Ot(n(u));return t.push({paramPath:l+"/filters"},{paramPath:l+"/bias"}),{filters:d,bias:f}}function o(s,u){var c=Ot(n(s)),l=Ot(n(s));return t.push({paramPath:u+"/weights"},{paramPath:u+"/biases"}),{weights:c,biases:l}}function a(s,u,c,l){var d=r(s,u,c,l+"/conv"),f=o(u,l+"/scale");return{conv:d,scale:f}}function i(s,u,c,l,d){d===void 0&&(d=!1);var f=a((d?.5:1)*s,u,c,l+"/conv1"),h=a(s,u,c,l+"/conv2");return{conv1:f,conv2:h}}return{extractConvLayerParams:a,extractResidualLayerParams:i}}function e9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=J5(e,o),i=a.extractConvLayerParams,s=a.extractResidualLayerParams,u=i(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),d=s(9216,32,3,"conv32_3"),f=s(36864,64,3,"conv64_down",!0),h=s(36864,64,3,"conv64_1"),m=s(36864,64,3,"conv64_2"),p=s(36864,64,3,"conv64_3"),v=s(147456,128,3,"conv128_down",!0),g=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),w=s(589824,256,3,"conv256_down",!0),x=s(589824,256,3,"conv256_1"),C=s(589824,256,3,"conv256_2"),_=s(589824,256,3,"conv256_down_out"),E=xe(function(){return Bo(Ro(e(256*128),[128,256]),[1,0])});if(o.push({paramPath:"fc"}),r().length!==0)throw new Error("weights remaing after extract: "+r().length);var S={conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:d,conv64_down:f,conv64_1:h,conv64_2:m,conv64_3:p,conv128_down:v,conv128_1:g,conv128_2:y,conv256_down:w,conv256_1:x,conv256_2:C,conv256_down_out:_,fc:E};return{params:S,paramMappings:o}}function t9(n,t){var e=zo(n,t);function r(i){var s=e(i+"/scale/weights",1),u=e(i+"/scale/biases",1);return{weights:s,biases:u}}function o(i){var s=e(i+"/conv/filters",4),u=e(i+"/conv/bias",1),c=r(i);return{conv:{filters:s,bias:u},scale:c}}function a(i){return{conv1:o(i+"/conv1"),conv2:o(i+"/conv2")}}return{extractConvLayerParams:o,extractResidualLayerParams:a}}function n9(n){var t=[],e=t9(n,t),r=e.extractConvLayerParams,o=e.extractResidualLayerParams,a=r("conv32_down"),i=o("conv32_1"),s=o("conv32_2"),u=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),d=o("conv64_2"),f=o("conv64_3"),h=o("conv128_down"),m=o("conv128_1"),p=o("conv128_2"),v=o("conv256_down"),g=o("conv256_1"),y=o("conv256_2"),w=o("conv256_down_out"),x=n.fc;if(t.push({originalPath:"fc",paramPath:"fc"}),!l5(x))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+x);var C={conv32_down:a,conv32_1:i,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:d,conv64_3:f,conv128_down:h,conv128_1:m,conv128_2:p,conv256_down:v,conv256_1:g,conv256_2:y,conv256_down_out:w,fc:x};return co(n,t),{params:C,paramMappings:t}}function jr(n,t){var e=Q5(n,t.conv1);return e=p2(e,t.conv2),e=qe(e,n),e=wt(e),e}function Cl(n,t){var e=v2(n,t.conv1);e=p2(e,t.conv2);var r=Qs(n,2,2,"valid"),o=vt(r.shape),a=r.shape[3]!==e.shape[3],i=r.shape[1]!==e.shape[1]||r.shape[2]!==e.shape[2];if(i){var s=eu(e.shape);s[1]=1;var u=vt(s);e=Vt([e,u],1);var c=eu(e.shape);c[2]=1;var l=vt(c);e=Vt([e,l],2)}return r=a?Vt([r,o],3):r,e=qe(r,e),e=wt(e),e}var r9=function(n){De(t,n);function t(){return n.call(this,"FaceRecognitionNet")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceRecognitionNet - load model before inference");return xe(function(){var o=e.toBatchTensor(150,!0).toFloat(),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(256)),s=v2(i,r.conv32_down);s=Kt(s,3,2,"valid"),s=jr(s,r.conv32_1),s=jr(s,r.conv32_2),s=jr(s,r.conv32_3),s=Cl(s,r.conv64_down),s=jr(s,r.conv64_1),s=jr(s,r.conv64_2),s=jr(s,r.conv64_3),s=Cl(s,r.conv128_down),s=jr(s,r.conv128_1),s=jr(s,r.conv128_2),s=Cl(s,r.conv256_down),s=jr(s,r.conv256_1),s=jr(s,r.conv256_2),s=Cl(s,r.conv256_down_out);var u=s.mean([1,2]),c=il(u,r.fc);return c})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.computeFaceDescriptor=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u){return u.data()}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_recognition_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n9(e)},t.prototype.extractParams=function(e){return e9(e)},t}(uo);function m2(n,t){var e={descriptor:t};return Object.assign({},n,e)}function g2(n,t){var e={age:t};return Object.assign({},n,e)}function y2(n,t,e){var r={gender:t,genderProbability:e};return Object.assign({},n,r)}var b2=function(){function n(t){var e=t===void 0?{}:t,r=e.minFaceSize,o=e.scaleFactor,a=e.maxNumScales,i=e.scoreThresholds,s=e.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=r||20,this._scaleFactor=o||.709,this._maxNumScales=a||10,this._scoreThresholds=i||[.6,.7,.7],this._scaleSteps=s,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(u){return typeof u!="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(u){return typeof u!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(n.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),n}();function o9(n,t){function e(u,c){var l=Sn(n(9*u),[3,3,u,1]),d=Ot(n(u)),f=Ot(n(u)),h=Ot(n(u)),m=Ot(n(u));return t.push({paramPath:c+"/filters"},{paramPath:c+"/batch_norm_scale"},{paramPath:c+"/batch_norm_offset"},{paramPath:c+"/batch_norm_mean"},{paramPath:c+"/batch_norm_variance"}),{filters:l,batch_norm_scale:d,batch_norm_offset:f,batch_norm_mean:h,batch_norm_variance:m}}function r(u,c,l,d,f){var h=Sn(n(u*c*l*l),[l,l,u,c]),m=Ot(n(c));return t.push({paramPath:d+"/filters"},{paramPath:d+"/"+(f?"batch_norm_offset":"bias")}),{filters:h,bias:m}}function o(u,c,l,d){var f=r(u,c,l,d,!0),h=f.filters,m=f.bias;return{filters:h,batch_norm_offset:m}}function a(u,c,l){var d=e(u,l+"/depthwise_conv"),f=o(u,c,1,l+"/pointwise_conv");return{depthwise_conv:d,pointwise_conv:f}}function i(){var u=o(3,32,3,"mobilenetv1/conv_0"),c=a(32,64,"mobilenetv1/conv_1"),l=a(64,128,"mobilenetv1/conv_2"),d=a(128,128,"mobilenetv1/conv_3"),f=a(128,256,"mobilenetv1/conv_4"),h=a(256,256,"mobilenetv1/conv_5"),m=a(256,512,"mobilenetv1/conv_6"),p=a(512,512,"mobilenetv1/conv_7"),v=a(512,512,"mobilenetv1/conv_8"),g=a(512,512,"mobilenetv1/conv_9"),y=a(512,512,"mobilenetv1/conv_10"),w=a(512,512,"mobilenetv1/conv_11"),x=a(512,1024,"mobilenetv1/conv_12"),C=a(1024,1024,"mobilenetv1/conv_13");return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,conv_8:v,conv_9:g,conv_10:y,conv_11:w,conv_12:x,conv_13:C}}function s(){var u=o(1024,256,1,"prediction_layer/conv_0"),c=o(256,512,3,"prediction_layer/conv_1"),l=o(512,128,1,"prediction_layer/conv_2"),d=o(128,256,3,"prediction_layer/conv_3"),f=o(256,128,1,"prediction_layer/conv_4"),h=o(128,256,3,"prediction_layer/conv_5"),m=o(256,64,1,"prediction_layer/conv_6"),p=o(64,128,3,"prediction_layer/conv_7"),v=r(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),g=r(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),y=r(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),w=r(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),x=r(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),C=r(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),_=r(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),E=r(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),S=r(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),N=r(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),$=r(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),A=r(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),P={box_encoding_predictor:v,class_predictor:g},j={box_encoding_predictor:y,class_predictor:w},B={box_encoding_predictor:x,class_predictor:C},z={box_encoding_predictor:_,class_predictor:E},H={box_encoding_predictor:S,class_predictor:N},F={box_encoding_predictor:$,class_predictor:A};return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,box_predictor_0:P,box_predictor_1:j,box_predictor_2:B,box_predictor_3:z,box_predictor_4:H,box_predictor_5:F}}return{extractMobilenetV1Params:i,extractPredictionLayerParams:s}}function a9(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=o9(r,t),i=a.extractMobilenetV1Params,s=a.extractPredictionLayerParams,u=i(),c=s(),l=jf(r(5118*4),[1,5118,4]),d={extra_dim:l};if(t.push({paramPath:"output_layer/extra_dim"}),o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:u,prediction_layer:c,output_layer:d},paramMappings:t}}function i9(n,t){var e=zo(n,t);function r(c,l,d){var f=e(c+"/Conv2d_"+l+"_pointwise/weights",4,d+"/filters"),h=e(c+"/Conv2d_"+l+"_pointwise/convolution_bn_offset",1,d+"/batch_norm_offset");return{filters:f,batch_norm_offset:h}}function o(c){var l="mobilenetv1/conv_"+c,d="MobilenetV1/Conv2d_"+c+"_depthwise",f=l+"/depthwise_conv",h=l+"/pointwise_conv",m=e(d+"/depthwise_weights",4,f+"/filters"),p=e(d+"/BatchNorm/gamma",1,f+"/batch_norm_scale"),v=e(d+"/BatchNorm/beta",1,f+"/batch_norm_offset"),g=e(d+"/BatchNorm/moving_mean",1,f+"/batch_norm_mean"),y=e(d+"/BatchNorm/moving_variance",1,f+"/batch_norm_variance");return{depthwise_conv:{filters:m,batch_norm_scale:p,batch_norm_offset:v,batch_norm_mean:g,batch_norm_variance:y},pointwise_conv:r("MobilenetV1",c,h)}}function a(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:o(1),conv_2:o(2),conv_3:o(3),conv_4:o(4),conv_5:o(5),conv_6:o(6),conv_7:o(7),conv_8:o(8),conv_9:o(9),conv_10:o(10),conv_11:o(11),conv_12:o(12),conv_13:o(13)}}function i(c,l){var d=e(c+"/weights",4,l+"/filters"),f=e(c+"/biases",1,l+"/bias");return{filters:d,bias:f}}function s(c){var l=i("Prediction/BoxPredictor_"+c+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+c+"/box_encoding_predictor"),d=i("Prediction/BoxPredictor_"+c+"/ClassPredictor","prediction_layer/box_predictor_"+c+"/class_predictor");return{box_encoding_predictor:l,class_predictor:d}}function u(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:s(0),box_predictor_1:s(1),box_predictor_2:s(2),box_predictor_3:s(3),box_predictor_4:s(4),box_predictor_5:s(5)}}return{extractMobilenetV1Params:a,extractPredictionLayerParams:u}}function s9(n){var t=[],e=i9(n,t),r=e.extractMobilenetV1Params,o=e.extractPredictionLayerParams,a=n["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!hl(a))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+a);var i={mobilenetv1:r(),prediction_layer:o(),output_layer:{extra_dim:a}};return co(n,t),{params:i,paramMappings:t}}function Ur(n,t,e){return xe(function(){var r=Zn(n,t.filters,e,"same");return r=qe(r,t.batch_norm_offset),lh(r,0,6)})}var u9=.0010000000474974513;function c9(n,t,e){return xe(function(){var r=al(n,t.filters,e,"same");return r=z1(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,u9),lh(r,0,6)})}function l9(n){return[2,4,6,12].some(function(t){return t===n})?[2,2]:[1,1]}function d9(n,t){return xe(function(){var e=null,r=Ur(n,t.conv_0,[2,2]),o=[t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13];if(o.forEach(function(a,i){var s=i+1,u=l9(s);r=c9(r,a.depthwise_conv,u),r=Ur(r,a.pointwise_conv,[1,1]),s===11&&(e=r)}),e===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:e}})}function f9(n,t,e,r,o){var a=n.shape[0],i=Math.min(e,a),s=t.map(function(l,d){return{score:l,boxIndex:d}}).filter(function(l){return l.score>o}).sort(function(l,d){return d.score-l.score}),u=function(l){return l<=r?1:0},c=[];return s.forEach(function(l){if(!(c.length>=i)){for(var d=l.score,f=c.length-1;f>=0;--f){var h=h9(n,l.boxIndex,c[f]);if(h!==0&&(l.score*=u(h),l.score<=o))break}d===l.score&&c.push(l.boxIndex)}}),c}function h9(n,t,e){var r=n.arraySync(),o=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),i=Math.max(r[t][0],r[t][2]),s=Math.max(r[t][1],r[t][3]),u=Math.min(r[e][0],r[e][2]),c=Math.min(r[e][1],r[e][3]),l=Math.max(r[e][0],r[e][2]),d=Math.max(r[e][1],r[e][3]),f=(i-o)*(s-a),h=(l-u)*(d-c);if(f<=0||h<=0)return 0;var m=Math.max(o,u),p=Math.max(a,c),v=Math.min(i,l),g=Math.min(s,d),y=Math.max(v-m,0)*Math.max(g-p,0);return y/(f+h-y)}function p9(n){var t=jt(Bo(n,[1,0])),e=[zt(t[2],t[0]),zt(t[3],t[1])],r=[qe(t[0],ur(e[0],ve(2))),qe(t[1],ur(e[1],ve(2)))];return{sizes:e,centers:r}}function v9(n,t){var e=p9(n),r=e.sizes,o=e.centers,a=jt(Bo(t,[1,0])),i=ur(cn(dh(ur(a[2],ve(5))),r[0]),ve(2)),s=qe(cn(ur(a[0],ve(10)),r[0]),o[0]),u=ur(cn(dh(ur(a[3],ve(5))),r[1]),ve(2)),c=qe(cn(ur(a[1],ve(10)),r[1]),o[1]);return Bo(Bn([zt(s,i),zt(c,u),qe(s,i),qe(c,u)]),[1,0])}function m9(n,t,e){return xe(function(){var r=n.shape[0],o=v9(ir(_i(e.extra_dim,[r,1,1]),[-1,4]),ir(n,[-1,4]));o=ir(o,[r,o.shape[0]/r,4]);var a=W1(Br(t,[0,0,1],[-1,-1,-1])),i=Br(a,[0,0,0],[-1,-1,1]);i=ir(i,[r,i.shape[1]]);var s=jt(o),u=jt(i);return{boxes:s,scores:u}})}function Ri(n,t){return xe(function(){var e=n.shape[0],r=ir(cr(n,t.box_encoding_predictor),[e,-1,1,4]),o=ir(cr(n,t.class_predictor),[e,-1,3]);return{boxPredictionEncoding:r,classPrediction:o}})}function g9(n,t,e){return xe(function(){var r=Ur(n,e.conv_0,[1,1]),o=Ur(r,e.conv_1,[2,2]),a=Ur(o,e.conv_2,[1,1]),i=Ur(a,e.conv_3,[2,2]),s=Ur(i,e.conv_4,[1,1]),u=Ur(s,e.conv_5,[2,2]),c=Ur(u,e.conv_6,[1,1]),l=Ur(c,e.conv_7,[2,2]),d=Ri(t,e.box_predictor_0),f=Ri(n,e.box_predictor_1),h=Ri(o,e.box_predictor_2),m=Ri(i,e.box_predictor_3),p=Ri(u,e.box_predictor_4),v=Ri(l,e.box_predictor_5),g=Vt([d.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding,m.boxPredictionEncoding,p.boxPredictionEncoding,v.boxPredictionEncoding],1),y=Vt([d.classPrediction,f.classPrediction,h.classPrediction,m.classPrediction,p.classPrediction,v.classPrediction],1);return{boxPredictions:g,classPredictions:y}})}var ou=function(){function n(t){var e=t===void 0?{}:t,r=e.minConfidence,o=e.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=r||.5,this._maxResults=o||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(n.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),n}(),x2=function(n){De(t,n);function t(){return n.call(this,"SsdMobilenetv1")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("SsdMobilenetv1 - load model before inference");return xe(function(){var o=e.toBatchTensor(512,!1).toFloat(),a=zt(cn(o,ve(.007843137718737125)),ve(1)),i=d9(a,r.mobilenetv1),s=g9(i.out,i.conv11,r.prediction_layer),u=s.boxPredictions,c=s.classPredictions;return m9(u,c,r.output_layer)})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.locateFaces=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:return o=new ou(r),a=o.maxResults,i=o.minConfidence,[4,Yt(e)];case 1:for(s=N.sent(),u=this.forwardInput(s),c=u.boxes,l=u.scores,d=c[0],f=l[0],h=1;h<c.length;h++)c[h].dispose(),l[h].dispose();return v=(p=Array).from,[4,f.data()];case 2:return m=v.apply(p,[N.sent()]),g=.5,y=f9(d,m,a,g,i),w=s.getReshapedInputDimensions(0),x=s.inputSize,C=x/w.width,_=x/w.height,E=d.arraySync(),S=y.map(function($){var A=[Math.max(0,E[$][0]),Math.min(1,E[$][2])].map(function(F){return F*_}),P=A[0],j=A[1],B=[Math.max(0,E[$][1]),Math.min(1,E[$][3])].map(function(F){return F*C}),z=B[0],H=B[1];return new Wr(m[$],new Uh(z,P,H-z,j-P),{height:s.getInputHeight(0),width:s.getInputWidth(0)})}),d.dispose(),f.dispose(),[2,S]}})})},t.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},t.prototype.extractParamsFromWeigthMap=function(e){return s9(e)},t.prototype.extractParams=function(e){return a9(e)},t}(uo);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(x2);var y9=.4,b9=[new ot(.738768,.874946),new ot(2.42204,2.65704),new ot(4.30971,7.04493),new ot(10.246,4.59428),new ot(12.6868,11.8741)],x9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],w9=[117.001,114.697,97.404],C9="tiny_yolov2_model",_9="tiny_yolov2_separable_conv_model",_l=function(n){return typeof n=="number"};function E9(n){if(!n)throw new Error("invalid config: "+n);if(typeof n.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+n.withSeparableConvs);if(!_l(n.iouThreshold)||n.iouThreshold<0||n.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+n.iouThreshold);if(!Array.isArray(n.classes)||!n.classes.length||!n.classes.every(function(t){return typeof t=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(n.classes));if(!Array.isArray(n.anchors)||!n.anchors.length||!n.anchors.map(function(t){return t||{}}).every(function(t){return _l(t.x)&&_l(t.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(n.anchors));if(n.meanRgb&&(!Array.isArray(n.meanRgb)||n.meanRgb.length!==3||!n.meanRgb.every(_l)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(n.meanRgb))}function rp(n){return xe(function(){var t=cn(n,ve(.10000000149011612));return qe(wt(zt(n,t)),t)})}function Ho(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=Zn(e,t.conv.filters,[1,1],"valid"),e=zt(e,t.bn.sub),e=cn(e,t.bn.truediv),e=qe(e,t.conv.bias),rp(e)})}function Go(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=mh(e,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),e=qe(e,t.bias),rp(e)})}function S9(n,t){var e=xl(n,t);function r(i,s){var u=Ot(n(i)),c=Ot(n(i));return t.push({paramPath:s+"/sub"},{paramPath:s+"/truediv"}),{sub:u,truediv:c}}function o(i,s,u){var c=e(i,s,3,u+"/conv"),l=r(s,u+"/bn");return{conv:c,bn:l}}var a=Qh(n,t);return{extractConvParams:e,extractConvWithBatchNormParams:o,extractSeparableConvParams:a}}function N9(n,t,e,r){var o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=[],u=S9(a,s),c=u.extractConvParams,l=u.extractConvWithBatchNormParams,d=u.extractSeparableConvParams,f;if(t.withSeparableConvs){var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=t.isFirstLayerConv2d?c(h,m,3,"conv0"):d(h,m,"conv0"),E=d(m,p,"conv1"),S=d(p,v,"conv2"),N=d(v,g,"conv3"),$=d(g,y,"conv4"),A=d(y,w,"conv5"),P=x?d(w,x,"conv6"):void 0,j=C?d(x,C,"conv7"):void 0,B=c(C||x||w,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}else{var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=l(h,m,"conv0"),E=l(m,p,"conv1"),S=l(p,v,"conv2"),N=l(v,g,"conv3"),$=l(g,y,"conv4"),A=l(y,w,"conv5"),P=l(w,x,"conv6"),j=l(x,C,"conv7"),B=c(C,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{params:f,paramMappings:s}}function $9(n,t){var e=zo(n,t);function r(s){var u=e(s+"/sub",1),c=e(s+"/truediv",1);return{sub:u,truediv:c}}function o(s){var u=e(s+"/filters",4),c=e(s+"/bias",1);return{filters:u,bias:c}}function a(s){var u=o(s+"/conv"),c=r(s+"/bn");return{conv:u,bn:c}}var i=Jh(e);return{extractConvParams:o,extractConvWithBatchNormParams:a,extractSeparableConvParams:i}}function k9(n,t){var e=[],r=$9(n,e),o=r.extractConvParams,a=r.extractConvWithBatchNormParams,i=r.extractSeparableConvParams,s;if(t.withSeparableConvs){var u=t.filterSizes&&t.filterSizes.length||9;s={conv0:t.isFirstLayerConv2d?o("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:u>7?i("conv6"):void 0,conv7:u>8?i("conv7"):void 0,conv8:o("conv8")}}else s={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:o("conv8")};return co(n,e),{params:s,paramMappings:e}}var w2;(function(n){n[n.XS=224]="XS",n[n.SM=320]="SM",n[n.MD=416]="MD",n[n.LG=608]="LG"})(w2||(w2={}));var op=function(){function n(t){var e=t===void 0?{}:t,r=e.inputSize,o=e.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=r||416,this._scoreThreshold=o||.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(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),n}(),C2=function(n){De(t,n);function t(e){var r=n.call(this,"TinyYolov2")||this;return E9(e),r._config=e,r}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),t.prototype.runTinyYolov2=function(e,r){var o=Ho(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=Ho(o,r.conv6),o=Ho(o,r.conv7),cr(o,r.conv8,"valid",!1)},t.prototype.runMobilenet=function(e,r){var o=this.config.isFirstLayerConv2d?rp(cr(e,r.conv0,"valid",!1)):Go(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=r.conv6?Go(o,r.conv6):o,o=r.conv7?Go(o,r.conv7):o,cr(o,r.conv8,"valid",!1)},t.prototype.forwardInput=function(e,r){var o=this,a=this.params;if(!a)throw new Error("TinyYolov2 - load model before inference");return xe(function(){var i=e.toBatchTensor(r,!1).toFloat();return i=o.config.meanRgb?ru(i,o.config.meanRgb):i,i=i.div(ve(256)),o.config.withSeparableConvs?o.runMobilenet(i,a):o.runTinyYolov2(i,a)})},t.prototype.forward=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent()]}})})},t.prototype.detect=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y=this;return ke(this,function(w){switch(w.label){case 0:return o=new op(r),a=o.inputSize,i=o.scoreThreshold,[4,Yt(e)];case 1:return s=w.sent(),[4,this.forwardInput(s,a)];case 2:return u=w.sent(),c=xe(function(){return jt(u)[0].expandDims()}),l={width:s.getInputWidth(0),height:s.getInputHeight(0)},[4,this.extractBoxes(c,s.getReshapedInputDimensions(0),i)];case 3:return d=w.sent(),u.dispose(),c.dispose(),f=d.map(function(x){return x.box}),h=d.map(function(x){return x.score}),m=d.map(function(x){return x.classScore}),p=d.map(function(x){return y.config.classes[x.label]}),v=nu(f.map(function(x){return x.rescale(a)}),h,this.config.iouThreshold,!0),g=v.map(function(x){return new jb(h[x],m[x],p[x],f[x],l)}),[2,g]}})})},t.prototype.getDefaultModelName=function(){return""},t.prototype.extractParamsFromWeigthMap=function(e){return k9(e,this.config)},t.prototype.extractParams=function(e){var r=this.config.filterSizes||t.DEFAULT_FILTER_SIZES,o=r?r.length:void 0;if(o!==7&&o!==8&&o!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+o+" filterSizes in config");return N9(e,this.config,this.boxEncodingSize,r)},t.prototype.extractBoxes=function(e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S,N,$,A,P,j,B,z,H,F,M=this;return ke(this,function(O){switch(O.label){case 0:return a=r.width,i=r.height,s=Math.max(a,i),u=s/a,c=s/i,l=e.shape[1],d=this.config.anchors.length,f=xe(function(){var I=e.reshape([l,l,d,M.boxEncodingSize]),L=I.slice([0,0,0,0],[l,l,d,4]),K=I.slice([0,0,0,4],[l,l,d,1]),q=M.withClassScores?oo(I.slice([0,0,0,5],[l,l,d,M.config.classes.length]),3):ve(0);return[L,K,q]}),h=f[0],m=f[1],p=f[2],v=[],[4,m.array()];case 1:return g=O.sent(),[4,h.array()];case 2:y=O.sent(),w=0,O.label=3;case 3:if(!(w<l))return[3,12];x=0,O.label=4;case 4:if(!(x<l))return[3,11];C=0,O.label=5;case 5:return C<d?(_=jh(g[w][x][C][0]),!o||_>o?(E=(x+jh(y[w][x][C][0]))/l*u,S=(w+jh(y[w][x][C][1]))/l*c,N=Math.exp(y[w][x][C][2])*this.config.anchors[C].x/l*u,$=Math.exp(y[w][x][C][3])*this.config.anchors[C].y/l*c,A=E-N/2,P=S-$/2,j={row:w,col:x,anchor:C},this.withClassScores?[4,this.extractPredictedClass(p,j)]:[3,7]):[3,9]):[3,10];case 6:return F=O.sent(),[3,8];case 7:F={classScore:1,label:0},O.label=8;case 8:B=F,z=B.classScore,H=B.label,v.push(dn({box:new pl(A,P,A+N,P+$),score:_,classScore:_*z,label:H},j)),O.label=9;case 9:return C++,[3,5];case 10:return x++,[3,4];case 11:return w++,[3,3];case 12:return h.dispose(),m.dispose(),p.dispose(),[2,v]}})})},t.prototype.extractPredictedClass=function(e,r){return $e(this,void 0,void 0,function(){var o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return o=r.row,a=r.col,i=r.anchor,[4,e.array()];case 1:return s=u.sent(),[2,Array(this.config.classes.length).fill(0).map(function(c,l){return s[o][a][i][l]}).map(function(c,l){return{classScore:c,label:l}}).reduce(function(c,l){return c.classScore>l.classScore?c:l})]}})})},t.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],t}(uo),P9=function(n){De(t,n);function t(e){e===void 0&&(e=!0);var r=this,o=Object.assign({},{withSeparableConvs:e,iouThreshold:y9,classes:["face"]},e?{anchors:x9,meanRgb:w9}:{anchors:b9,withClassScores:!0});return r=n.call(this,o)||this,r}return Object.defineProperty(t.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return this.withSeparableConvs?_9:C9},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),I9=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name="TinyFaceDetectorOptions",e}return t}(op),au=function(){function n(){}return n.prototype.then=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:return e=t,[4,this.run()];case 1:return[2,e.apply(void 0,[r.sent()])]}})})},n.prototype.run=function(){return $e(this,void 0,void 0,function(){return ke(this,function(t){throw new Error("ComposableTask - run is not implemented")})})},n}();function El(n,t,e,r,o){return o===void 0&&(o=function(a){var i=a.alignedRect;return i}),$e(this,void 0,void 0,function(){var a,i,s,u,c;return ke(this,function(l){switch(l.label){case 0:return a=n.map(function(d){return R5(d)?o(d):d.detection}),s=r,s?[3,5]:t instanceof bt?[4,Yh(t,a)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,Kh(t,a)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return i=s,[4,e(i)];case 6:return c=l.sent(),i.forEach(function(d){return d instanceof bt&&d.dispose()}),[2,c]}})})}function ap(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a=this;return ke(this,function(i){return[2,El([n],t,function(s){return $e(a,void 0,void 0,function(){return ke(this,function(u){return[2,e(s[0])]})})},r,o)]})})}function A9(n){return xe(function(){return Bn(jt(n,3).reverse(),3)})}var Sl=2,Nl=12;function T9(n,t){var e=xl(n,t),r=Zh(n,t);function o(c,l){var d=Ot(n(c));return t.push({paramPath:l}),d}function a(c,l,d){d===void 0&&(d=!1);var f=e(c[0],c[1],3,l+"/conv1"),h=o(c[1],l+"/prelu1_alpha"),m=e(c[1],c[2],3,l+"/conv2"),p=o(c[2],l+"/prelu2_alpha"),v=e(c[2],c[3],d?2:3,l+"/conv3"),g=o(c[3],l+"/prelu3_alpha");return{conv1:f,prelu1_alpha:h,conv2:m,prelu2_alpha:p,conv3:v,prelu3_alpha:g}}function i(){var c=a([3,10,16,32],"pnet"),l=e(32,2,1,"pnet/conv4_1"),d=e(32,4,1,"pnet/conv4_2");return dn(dn({},c),{conv4_1:l,conv4_2:d})}function s(){var c=a([3,28,48,64],"rnet",!0),l=r(576,128,"rnet/fc1"),d=o(128,"rnet/prelu4_alpha"),f=r(128,2,"rnet/fc2_1"),h=r(128,4,"rnet/fc2_2");return dn(dn({},c),{fc1:l,prelu4_alpha:d,fc2_1:f,fc2_2:h})}function u(){var c=a([3,32,64,64],"onet"),l=e(64,128,2,"onet/conv4"),d=o(128,"onet/prelu4_alpha"),f=r(1152,256,"onet/fc1"),h=o(256,"onet/prelu5_alpha"),m=r(256,2,"onet/fc2_1"),p=r(256,4,"onet/fc2_2"),v=r(256,10,"onet/fc2_3");return dn(dn({},c),{conv4:l,prelu4_alpha:d,fc1:f,prelu5_alpha:h,fc2_1:m,fc2_2:p,fc2_3:v})}return{extractPNetParams:i,extractRNetParams:s,extractONetParams:u}}function O9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=T9(e,o),i=a.extractPNetParams,s=a.extractRNetParams,u=a.extractONetParams,c=i(),l=s(),d=u();if(r().length!==0)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:c,rnet:l,onet:d},paramMappings:o}}function D9(n,t){var e=zo(n,t);function r(l){var d=e(l+"/weights",4,l+"/filters"),f=e(l+"/bias",1);return{filters:d,bias:f}}function o(l){var d=e(l+"/weights",2),f=e(l+"/bias",1);return{weights:d,bias:f}}function a(l){return e(l,1)}function i(l){var d=r(l+"/conv1"),f=a(l+"/prelu1_alpha"),h=r(l+"/conv2"),m=a(l+"/prelu2_alpha"),p=r(l+"/conv3"),v=a(l+"/prelu3_alpha");return{conv1:d,prelu1_alpha:f,conv2:h,prelu2_alpha:m,conv3:p,prelu3_alpha:v}}function s(){var l=i("pnet"),d=r("pnet/conv4_1"),f=r("pnet/conv4_2");return dn(dn({},l),{conv4_1:d,conv4_2:f})}function u(){var l=i("rnet"),d=o("rnet/fc1"),f=a("rnet/prelu4_alpha"),h=o("rnet/fc2_1"),m=o("rnet/fc2_2");return dn(dn({},l),{fc1:d,prelu4_alpha:f,fc2_1:h,fc2_2:m})}function c(){var l=i("onet"),d=r("onet/conv4"),f=a("onet/prelu4_alpha"),h=o("onet/fc1"),m=a("onet/prelu5_alpha"),p=o("onet/fc2_1"),v=o("onet/fc2_2"),g=o("onet/fc2_3");return dn(dn({},l),{conv4:d,prelu4_alpha:f,fc1:h,prelu5_alpha:m,fc2_1:p,fc2_2:v,fc2_3:g})}return{extractPNetParams:s,extractRNetParams:u,extractONetParams:c}}function M9(n){var t=[],e=D9(n,t),r=e.extractPNetParams,o=e.extractRNetParams,a=e.extractONetParams,i=r(),s=o(),u=a();return co(n,t),{params:{pnet:i,rnet:s,onet:u},paramMappings:t}}function ip(n,t){var e=t[0],r=t[1];return{height:Math.floor(e*n),width:Math.floor(r*n)}}function F9(n,t,e){for(var r=e[0],o=e[1],a=Nl/n,i=[],s=Math.min(r,o)*a,u=0;s>=12;)i.push(a*Math.pow(t,u)),s=s*t,u+=1;return i}var sp=function(n){De(t,n);function t(e,r,o,a){return n.call(this,{left:e,top:r,right:o,bottom:a},!0)||this}return t}(Uo);function _2(n){return xe(function(){return cn(zt(n,ve(127.5)),ve(.0078125))})}function Li(n,t){return xe(function(){return qe(wt(n),cn(t,el(wt(el(n)))))})}function up(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=cr(n,t.conv1,"valid");return r=Li(r,t.prelu1_alpha),r=Kt(r,e?[2,2]:[3,3],[2,2],"same"),r=cr(r,t.conv2,"valid"),r=Li(r,t.prelu2_alpha),r=e?r:Kt(r,[3,3],[2,2],"valid"),r=cr(r,t.conv3,"valid"),r=Li(r,t.prelu3_alpha),r})}function R9(n,t){return xe(function(){var e=up(n,t,!0),r=cr(e,t.conv4_1,"valid"),o=Xn(sl(r,3),3),a=oo(zt(r,o),3),i=cr(e,t.conv4_2,"valid");return{prob:a,regions:i}})}function L9(n,t){return xe(function(){var e=ip(t,n.shape.slice(1)),r=e.height,o=e.width,a=wh.resizeBilinear(n,[r,o]),i=_2(a);return Bo(i,[0,2,1,3])})}function B9(n,t,e,r){for(var o=[],a=n.arraySync(),i=0;i<n.shape[0];i++)for(var s=0;s<n.shape[1];s++)a[i][s]>=r&&o.push(new ot(s,i));var u=o.map(function(c){var l=new pl(Math.round((c.y*Sl+1)/e),Math.round((c.x*Sl+1)/e),Math.round((c.y*Sl+Nl)/e),Math.round((c.x*Sl+Nl)/e)),d=a[c.y][c.x],f=t.arraySync(),h=new sp(f[c.y][c.x][0],f[c.y][c.x][1],f[c.y][c.x][2],f[c.y][c.x][3]);return{cell:l,score:d,region:h}});return u}function W9(n,t,e,r,o){o.stage1=[];var a=t.map(function(f){return xe(function(){var h={scale:f},m=L9(n,f),p=Date.now(),v=R9(m,r),g=v.prob,y=v.regions;h.pnet=Date.now()-p;var w=jt(jt(g,3)[1])[0],x=jt(y)[0];return{scoresTensor:w,regionsTensor:x,scale:f,statsForScale:h}})}),i=a.map(function(f){var h=f.scoresTensor,m=f.regionsTensor,p=f.scale,v=f.statsForScale,g=B9(h,m,p,e);if(h.dispose(),m.dispose(),!g.length)return o.stage1.push(v),[];var y=Date.now(),w=nu(g.map(function(x){return x.cell}),g.map(function(x){return x.score}),.5);return v.nms=Date.now()-y,v.numBoxes=w.length,o.stage1.push(v),w.map(function(x){return g[x]})}),s=i.reduce(function(f,h){return f.concat(h)},[]),u=[],c=[];if(s.length>0){var l=Date.now(),d=nu(s.map(function(f){return f.cell}),s.map(function(f){return f.score}),.7);o.stage1_nms=Date.now()-l,c=d.map(function(f){return s[f].score}),u=d.map(function(f){return s[f]}).map(function(f){var h=f.cell,m=f.region;return new pl(h.left+m.left*h.width,h.top+m.top*h.height,h.right+m.right*h.width,h.bottom+m.bottom*h.height).toSquare().round()})}return{boxes:u,scores:c}}function E2(n,t,e){var r=e.width,o=e.height;return $e(this,void 0,void 0,function(){var a,i,s,u=this;return ke(this,function(c){switch(c.label){case 0:return a=Ba(n),[4,Promise.all(t.map(function(l){return $e(u,void 0,void 0,function(){var d,f,h,m,p,v,g,y;return ke(this,function(w){return d=l.padAtBorders(n.height,n.width),f=d.y,h=d.ey,m=d.x,p=d.ex,v=m-1,g=f-1,y=a.getImageData(v,g,p-v,h-g),[2,rn.isNodejs()?qh(y):createImageBitmap(y)]})})}))];case 1:return i=c.sent(),s=[],i.forEach(function(l){var d=gl({width:r,height:o}),f=Ba(d);f.drawImage(l,0,0,r,o);for(var h=f.getImageData(0,0,r,o).data,m=[],p=0;p<h.length;p+=4)m.push(h[p+2]),m.push(h[p+1]),m.push(h[p]);s.push(m)}),[2,s.map(function(l){var d=xe(function(){var f=Bo(Sn(l,[1,r,o,3]),[0,2,1,3]).toFloat();return _2(f)});return d})]}})})}function V9(n,t){return xe(function(){var e=up(n,t),r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu4_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=jt(u,1)[1];return{scores:l,regions:c}})}function j9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return a=Date.now(),[4,E2(n,t,{width:24,height:24})];case 1:return i=w.sent(),o.stage2_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(x){var C=V9(x,r);return x.dispose(),C}),o.stage2_rnet=Date.now()-a,u=s.length>1?Vt(s.map(function(x){return x.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[w.sent()]),u.dispose(),f=c.map(function(x,C){return{score:x,idx:C}}).filter(function(x){return x.score>e}).map(function(x){var C=x.idx;return C}),h=f.map(function(x){return t[x]}),m=f.map(function(x){return c[x]}),p=[],v=[],h.length>0&&(a=Date.now(),g=nu(h,m,.7),o.stage2_nms=Date.now()-a,y=g.map(function(x){var C=s[f[x]].regions.arraySync();return new sp(C[0][0],C[0][1],C[0][2],C[0][3])}),v=g.map(function(x){return m[x]}),p=g.map(function(x,C){return h[x].calibrate(y[C])})),s.forEach(function(x){x.regions.dispose(),x.scores.dispose()}),[2,{boxes:p,scores:v}]}})})}function U9(n,t){return xe(function(){var e=up(n,t);e=Kt(e,[2,2],[2,2],"same"),e=cr(e,t.conv4,"valid"),e=Li(e,t.prelu4_alpha);var r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu5_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=Vr(a,t.fc2_3),d=jt(u,1)[1];return{scores:d,regions:c,points:l}})}function z9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w;return ke(this,function(x){switch(x.label){case 0:return a=Date.now(),[4,E2(n,t,{width:48,height:48})];case 1:return i=x.sent(),o.stage3_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(C){var _=U9(C,r);return C.dispose(),_}),o.stage3_onet=Date.now()-a,u=s.length>1?Vt(s.map(function(C){return C.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[x.sent()]),u.dispose(),f=c.map(function(C,_){return{score:C,idx:_}}).filter(function(C){return C.score>e}).map(function(C){var _=C.idx;return _}),h=f.map(function(C){var _=s[C].regions.arraySync();return new sp(_[0][0],_[0][1],_[0][2],_[0][3])}),m=f.map(function(C,_){return t[C].calibrate(h[_])}),p=f.map(function(C){return c[C]}),v=[],g=[],y=[],m.length>0&&(a=Date.now(),w=nu(m,p,.7,!1),o.stage3_nms=Date.now()-a,v=w.map(function(C){return m[C]}),g=w.map(function(C){return p[C]}),y=w.map(function(C,_){return Array(5).fill(0).map(function(E,S){var N=s[C].points.arraySync();return new ot(N[0][S]*(v[_].width+1)+v[_].left,N[0][S+5]*(v[_].height+1)+v[_].top)})})),s.forEach(function(C){C.regions.dispose(),C.scores.dispose(),C.points.dispose()}),[2,{boxes:v,scores:g,points:y}]}})})}var H9=function(n){De(t,n);function t(){return n.call(this,"Mtcnn")||this}return t.prototype.load=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.load.call(this,e)]})})},t.prototype.loadFromDisk=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.loadFromDisk.call(this,e)]})})},t.prototype.forwardInput=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:if(o=this.params,!o)throw new Error("Mtcnn - load model before inference");if(a=e.canvases[0],!a)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return i={},s=Date.now(),u=xe(function(){return A9(Xn(Bh.fromPixels(a)).toFloat())}),c=function($){return u.dispose(),i.total=Date.now()-s,$},l=u.shape.slice(1),d=l[0],f=l[1],h=new b2(r),m=h.minFaceSize,p=h.scaleFactor,v=h.maxNumScales,g=h.scoreThresholds,y=h.scaleSteps,w=(y||F9(m,p,[d,f])).filter(function($){var A=ip($,[d,f]);return Math.min(A.width,A.height)>Nl}).slice(0,v),i.scales=w,i.pyramid=w.map(function($){return ip($,[d,f])}),x=Date.now(),[4,W9(u,w,g[0],o.pnet,i)];case 1:return C=N.sent(),i.total_stage1=Date.now()-x,C.boxes.length?(i.stage2_numInputBoxes=C.boxes.length,x=Date.now(),[4,j9(a,C.boxes,g[1],o.rnet,i)]):[2,c({results:[],stats:i})];case 2:return _=N.sent(),i.total_stage2=Date.now()-x,_.boxes.length?(i.stage3_numInputBoxes=_.boxes.length,x=Date.now(),[4,z9(a,_.boxes,g[2],o.onet,i)]):[2,c({results:[],stats:i})];case 3:return E=N.sent(),i.total_stage3=Date.now()-x,S=E.boxes.map(function($,A){return ep(zh({},new Wr(E.scores[A],new Uh($.left/f,$.top/d,$.width/f,$.height/d),{height:d,width:f})),new x5(E.points[A].map(function(P){return P.sub(new ot($.left,$.top)).div(new ot($.width,$.height))}),{width:$.width,height:$.height}))}),[2,c({results:S,stats:i})]}})})},t.prototype.forward=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent().results]}})})},t.prototype.forwardWithStats=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[2,o.apply(this,[a.sent(),r])]}})})},t.prototype.getDefaultModelName=function(){return"mtcnn_model"},t.prototype.extractParamsFromWeigthMap=function(e){return M9(e)},t.prototype.extractParams=function(e){return O9(e)},t}(uo),G9=.4,q9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],K9=[117.001,114.697,97.404],Y9=function(n){De(t,n);function t(){var e=this,r={withSeparableConvs:!0,iouThreshold:G9,classes:["face"],anchors:q9,meanRgb:K9,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return e=n.call(this,r)||this,e}return Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),mn={ssdMobilenetv1:new x2,tinyFaceDetector:new Y9,tinyYolov2:new P9,mtcnn:new H9,faceLandmark68Net:new h2,faceLandmark68TinyNet:new X5,faceRecognitionNet:new r9,faceExpressionNet:new F5,ageGenderNet:new G5},S2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),cp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.faceExpressionNet.predictExpressions(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){return l2(i,r[s])})]}})})},t.prototype.withAgeAndGender=function(){return new hp(this,this.input)},t}(S2),lp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceExpressionNet.predictExpressions(a)},this.extractedFaces)]:[2];case 2:return r=o.sent(),[2,l2(e,r)]}})})},t.prototype.withAgeAndGender=function(){return new pp(this,this.input)},t}(S2),dp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(cp),fp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(lp),N2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),hp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.ageGenderNet.predictAgeAndGender(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){var u=r[s],c=u.age,l=u.gender,d=u.genderProbability;return g2(y2(i,l,d),c)})]}})})},t.prototype.withFaceExpressions=function(){return new cp(this,this.input)},t}(N2),pp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?[4,ap(e,this.input,function(u){return mn.ageGenderNet.predictAgeAndGender(u)},this.extractedFaces)]:[2];case 2:return r=s.sent(),o=r.age,a=r.gender,i=r.genderProbability,[2,g2(y2(e,a,i),o)]}})})},t.prototype.withFaceExpressions=function(){return new lp(this,this.input)},t}(N2),vp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(hp),mp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(pp),$2=function(n){De(t,n);function t(e,r){var o=n.call(this)||this;return o.parentTask=e,o.input=r,o}return t}(au),gp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),[4,El(e,this.input,function(a){return Promise.all(a.map(function(i){return mn.faceRecognitionNet.computeFaceDescriptor(i)}))},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return r=o.sent(),[2,r.map(function(a,i){return m2(e[i],a)})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t}($2),yp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceRecognitionNet.computeFaceDescriptor(a)},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return r=o.sent(),[2,m2(e,r)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t}($2),k2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.useTinyLandmarkNet=o,a}return Object.defineProperty(t.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?mn.faceLandmark68TinyNet:mn.faceLandmark68Net},enumerable:!0,configurable:!0}),t}(au),X9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,this.parentTask];case 1:return e=u.sent(),r=e.map(function(c){return c.detection}),this.input instanceof bt?[4,Yh(this.input,r)]:[3,3];case 2:return a=u.sent(),[3,5];case 3:return[4,Kh(this.input,r)];case 4:a=u.sent(),u.label=5;case 5:return o=a,[4,Promise.all(o.map(function(c){return s.landmarkNet.detectLandmarks(c)}))];case 6:return i=u.sent(),o.forEach(function(c){return c instanceof bt&&c.dispose()}),[2,e.map(function(c,l){return ep(c,i[l])})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(k2),Z9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?(r=e.detection,this.input instanceof bt?[4,Yh(this.input,[r])]:[3,3]):[2];case 2:return a=s.sent(),[3,5];case 3:return[4,Kh(this.input,[r])];case 4:a=s.sent(),s.label=5;case 5:return o=a,[4,this.landmarkNet.detectLandmarks(o[0])];case 6:return i=s.sent(),o.forEach(function(u){return u instanceof bt&&u.dispose()}),[2,ep(e,i)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(k2),P2=function(n){De(t,n);function t(e,r){r===void 0&&(r=new ou);var o=n.call(this)||this;return o.input=e,o.options=r,o}return t}(au),I2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=this,r=e.input,o=e.options,o instanceof b2?[4,mn.mtcnn.forward(r,o)]:[3,2];case 1:return[2,i.sent().map(function(s){return s.detection})];case 2:if(a=o instanceof I9?function(s){return mn.tinyFaceDetector.locateFaces(s,o)}:o instanceof ou?function(s){return mn.ssdMobilenetv1.locateFaces(s,o)}:o instanceof op?function(s){return mn.tinyYolov2.locateFaces(s,o)}:null,!a)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,a(r)]}})})},t.prototype.runAndExtendWithFaceDetections=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o.map(function(i){return zh({},i)}))]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new X9(this.runAndExtendWithFaceDetections(),this.input,e)},t.prototype.withFaceExpressions=function(){return new cp(this.runAndExtendWithFaceDetections(),this.input)},t.prototype.withAgeAndGender=function(){return new hp(this.runAndExtendWithFaceDetections(),this.input)},t}(P2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,new I2(this.input,this.options)];case 1:return e=o.sent(),r=e[0],e.forEach(function(a){a.score>r.score&&(r=a)}),[2,r]}})})},t.prototype.runAndExtendWithFaceDetection=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o?zh({},o):void 0)]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new Z9(this.runAndExtendWithFaceDetection(),this.input,e)},t.prototype.withFaceExpressions=function(){return new lp(this.runAndExtendWithFaceDetection(),this.input)},t.prototype.withAgeAndGender=function(){return new pp(this.runAndExtendWithFaceDetection(),this.input)},t})(P2);function Q9(n,t){return t===void 0&&(t=new ou),new I2(n,t)}function J9(n,t){if(n.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var e=Array.from(n),r=Array.from(t);return Math.sqrt(e.map(function(o,a){return o-r[a]}).reduce(function(o,a){return o+Math.pow(a,2)},0))}(function(){function n(t,e){e===void 0&&(e=.6),this._distanceThreshold=e;var r=Array.isArray(t)?t:[t];if(!r.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var o=1,a=function(){return"person "+o++};this._labeledDescriptors=r.map(function(i){if(i instanceof ml)return i;if(i instanceof Float32Array)return new ml(a(),[i]);if(i.descriptor&&i.descriptor instanceof Float32Array)return new ml(a(),[i.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(n.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),n.prototype.computeMeanDistance=function(t,e){return e.map(function(r){return J9(r,t)}).reduce(function(r,o){return r+o},0)/(e.length||1)},n.prototype.matchDescriptor=function(t){var e=this;return this.labeledDescriptors.map(function(r){var o=r.descriptors,a=r.label;return new Ub(a,e.computeMeanDistance(t,o))}).reduce(function(r,o){return r.distance<o.distance?r:o})},n.prototype.findBestMatch=function(t){var e=this.matchDescriptor(t);return e.distance<this.distanceThreshold?e:new Ub("unknown",e.distance)},n.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(t){return t.toJSON()})}},n.fromJSON=function(t){var e=t.labeledDescriptors.map(function(r){return ml.fromJSON(r)});return new n(e,t.distanceThreshold)},n})();function fo(n){return Array.isArray?Array.isArray(n):O2(n)==="[object Array]"}function eD(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function tD(n){return n==null?"":eD(n)}function zr(n){return typeof n=="string"}function A2(n){return typeof n=="number"}function nD(n){return n===!0||n===!1||rD(n)&&O2(n)=="[object Boolean]"}function T2(n){return typeof n=="object"}function rD(n){return T2(n)&&n!==null}function jn(n){return n!=null}function bp(n){return!n.trim().length}function O2(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const oD="Incorrect 'index' type",aD=n=>`Invalid value for key ${n}`,iD=n=>`Pattern length exceeds max of ${n}.`,sD=n=>`Missing ${n} property in key`,uD=n=>`Property 'weight' in key '${n}' must be a positive integer`,D2=Object.prototype.hasOwnProperty;class cD{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(r=>{let o=M2(r);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(r=>{r.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function M2(n){let t=null,e=null,r=null,o=1,a=null;if(zr(n)||fo(n))r=n,t=F2(n),e=xp(n);else{if(!D2.call(n,"name"))throw new Error(sD("name"));const i=n.name;if(r=i,D2.call(n,"weight")&&(o=n.weight,o<=0))throw new Error(uD(i));t=F2(i),e=xp(i),a=n.getFn}return{path:t,id:e,weight:o,src:r,getFn:a}}function F2(n){return fo(n)?n:n.split(".")}function xp(n){return fo(n)?n.join("."):n}function lD(n,t){let e=[],r=!1;const o=(a,i,s)=>{if(jn(a))if(!i[s])e.push(a);else{let u=i[s];const c=a[u];if(!jn(c))return;if(s===i.length-1&&(zr(c)||A2(c)||nD(c)))e.push(tD(c));else if(fo(c)){r=!0;for(let l=0,d=c.length;l<d;l+=1)o(c[l],i,s+1)}else i.length&&o(c,i,s+1)}};return o(n,zr(t)?t.split("."):t,0),r?e:e[0]}var Ae={...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:lD,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const dD=/[^ ]+/g;function fD(n=1,t=3){const e=new Map,r=Math.pow(10,t);return{get(o){const a=o.match(dD).length;if(e.has(a))return e.get(a);const i=1/Math.pow(a,.5*n),s=parseFloat(Math.round(i*r)/r);return e.set(a,s),s},clear(){e.clear()}}}class wp{constructor({getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){this.norm=fD(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,r)=>{this._keysMap[e.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,zr(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();zr(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,r=this.size();e<r;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!jn(t)||bp(t))return;let r={v:t,i:e,n:this.norm.get(t)};this.records.push(r)}_addObject(t,e){let r={i:e,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(jn(i)){if(fo(i)){let s=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:c,value:l}=u.pop();if(jn(l))if(zr(l)&&!bp(l)){let d={v:l,i:c,n:this.norm.get(l)};s.push(d)}else fo(l)&&l.forEach((d,f)=>{u.push({nestedArrIndex:f,value:d})})}r.$[a]=s}else if(zr(i)&&!bp(i)){let s={v:i,n:this.norm.get(i)};r.$[a]=s}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function R2(n,t,{getFn:e=Ae.getFn,fieldNormWeight:r=Ae.fieldNormWeight}={}){const o=new wp({getFn:e,fieldNormWeight:r});return o.setKeys(n.map(M2)),o.setSources(t),o.create(),o}function hD(n,{getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){const{keys:r,records:o}=n,a=new wp({getFn:t,fieldNormWeight:e});return a.setKeys(r),a.setIndexRecords(o),a}function $l(n,{errors:t=0,currentLocation:e=0,expectedLocation:r=0,distance:o=Ae.distance,ignoreLocation:a=Ae.ignoreLocation}={}){const i=t/n.length;if(a)return i;const s=Math.abs(r-e);return o?i+s/o:s?1:i}function pD(n=[],t=Ae.minMatchCharLength){let e=[],r=-1,o=-1,a=0;for(let i=n.length;a<i;a+=1){let s=n[a];s&&r===-1?r=a:!s&&r!==-1&&(o=a-1,o-r+1>=t&&e.push([r,o]),r=-1)}return n[a-1]&&a-r>=t&&e.push([r,a-1]),e}const Wa=32;function vD(n,t,e,{location:r=Ae.location,distance:o=Ae.distance,threshold:a=Ae.threshold,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,includeMatches:u=Ae.includeMatches,ignoreLocation:c=Ae.ignoreLocation}={}){if(t.length>Wa)throw new Error(iD(Wa));const l=t.length,d=n.length,f=Math.max(0,Math.min(r,d));let h=a,m=f;const p=s>1||u,v=p?Array(d):[];let g;for(;(g=n.indexOf(t,m))>-1;){let E=$l(t,{currentLocation:g,expectedLocation:f,distance:o,ignoreLocation:c});if(h=Math.min(E,h),m=g+l,p){let S=0;for(;S<l;)v[g+S]=1,S+=1}}m=-1;let y=[],w=1,x=l+d;const C=1<<l-1;for(let E=0;E<l;E+=1){let S=0,N=x;for(;S<N;)$l(t,{errors:E,currentLocation:f+N,expectedLocation:f,distance:o,ignoreLocation:c})<=h?S=N:x=N,N=Math.floor((x-S)/2+S);x=N;let $=Math.max(1,f-N+1),A=i?d:Math.min(f+N,d)+l,P=Array(A+2);P[A+1]=(1<<E)-1;for(let B=A;B>=$;B-=1){let z=B-1,H=e[n.charAt(z)];if(p&&(v[z]=+!!H),P[B]=(P[B+1]<<1|1)&H,E&&(P[B]|=(y[B+1]|y[B])<<1|1|y[B+1]),P[B]&C&&(w=$l(t,{errors:E,currentLocation:z,expectedLocation:f,distance:o,ignoreLocation:c}),w<=h)){if(h=w,m=z,m<=f)break;$=Math.max(1,2*f-m)}}if($l(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:o,ignoreLocation:c})>h)break;y=P}const _={isMatch:m>=0,score:Math.max(.001,w)};if(p){const E=pD(v,s);E.length?u&&(_.indices=E):_.isMatch=!1}return _}function mD(n){let t={};for(let e=0,r=n.length;e<r;e+=1){const o=n.charAt(e);t[o]=(t[o]||0)|1<<r-e-1}return t}const kl=String.prototype.normalize?n=>n.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):n=>n;class L2{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){if(this.options={location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l},t=u?t:t.toLowerCase(),t=c?kl(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const d=(h,m)=>{this.chunks.push({pattern:h,alphabet:mD(h),startIndex:m})},f=this.pattern.length;if(f>Wa){let h=0;const m=f%Wa,p=f-m;for(;h<p;)d(this.pattern.substr(h,Wa),h),h+=Wa;if(m){const v=f-Wa;d(this.pattern.substr(v),v)}}else d(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern===t){let p={isMatch:!0,score:0};return o&&(p.indices=[[0,t.length-1]]),p}const{location:a,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,ignoreLocation:l}=this.options;let d=[],f=0,h=!1;this.chunks.forEach(({pattern:p,alphabet:v,startIndex:g})=>{const{isMatch:y,score:w,indices:x}=vD(t,p,v,{location:a+g,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,includeMatches:o,ignoreLocation:l});y&&(h=!0),f+=w,y&&x&&(d=[...d,...x])});let m={isMatch:h,score:h?f/this.chunks.length:1};return h&&o&&(m.indices=d),m}}class qo{constructor(t){this.pattern=t}static isMultiMatch(t){return B2(t,this.multiRegex)}static isSingleMatch(t){return B2(t,this.singleRegex)}search(){}}function B2(n,t){const e=n.match(t);return e?e[1]:null}class gD extends qo{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class yD extends qo{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class bD extends qo{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class xD extends qo{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class wD extends qo{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class CD extends qo{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class W2 extends qo{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){super(t),this._bitapSearch=new L2(t,{location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class V2 extends qo{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,r;const o=[],a=this.pattern.length;for(;(r=t.indexOf(this.pattern,e))>-1;)e=r+a,o.push([r,e-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const Cp=[gD,V2,bD,xD,CD,wD,yD,W2],j2=Cp.length,_D=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ED="|";function SD(n,t={}){return n.split(ED).map(e=>{let r=e.trim().split(_D).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const s=r[a];let u=!1,c=-1;for(;!u&&++c<j2;){const l=Cp[c];let d=l.isMultiMatch(s);d&&(o.push(new l(d,t)),u=!0)}if(!u)for(c=-1;++c<j2;){const l=Cp[c];let d=l.isSingleMatch(s);if(d){o.push(new l(d,t));break}}}return o})}const ND=new Set([W2.type,V2.type]);class $D{constructor(t,{isCaseSensitive:e=Ae.isCaseSensitive,ignoreDiacritics:r=Ae.ignoreDiacritics,includeMatches:o=Ae.includeMatches,minMatchCharLength:a=Ae.minMatchCharLength,ignoreLocation:i=Ae.ignoreLocation,findAllMatches:s=Ae.findAllMatches,location:u=Ae.location,threshold:c=Ae.threshold,distance:l=Ae.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o,minMatchCharLength:a,findAllMatches:s,ignoreLocation:i,location:u,threshold:c,distance:l},t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern=t,this.query=SD(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?kl(t):t;let i=0,s=[],u=0;for(let c=0,l=e.length;c<l;c+=1){const d=e[c];s.length=0,i=0;for(let f=0,h=d.length;f<h;f+=1){const m=d[f],{isMatch:p,indices:v,score:g}=m.search(t);if(p){if(i+=1,u+=g,r){const y=m.constructor.type;ND.has(y)?s=[...s,...v]:s.push(v)}}else{u=0,i=0,s.length=0;break}}if(i){let f={isMatch:!0,score:u/i};return r&&(f.indices=s),f}}return{isMatch:!1,score:1}}}const _p=[];function kD(...n){_p.push(...n)}function Ep(n,t){for(let e=0,r=_p.length;e<r;e+=1){let o=_p[e];if(o.condition(n,t))return new o(n,t)}return new L2(n,t)}const Pl={AND:"$and",OR:"$or"},Sp={PATH:"$path",PATTERN:"$val"},Np=n=>!!(n[Pl.AND]||n[Pl.OR]),PD=n=>!!n[Sp.PATH],ID=n=>!fo(n)&&T2(n)&&!Np(n),U2=n=>({[Pl.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function z2(n,t,{auto:e=!0}={}){const r=o=>{let a=Object.keys(o);const i=PD(o);if(!i&&a.length>1&&!Np(o))return r(U2(o));if(ID(o)){const u=i?o[Sp.PATH]:a[0],c=i?o[Sp.PATTERN]:o[u];if(!zr(c))throw new Error(aD(u));const l={keyId:xp(u),pattern:c};return e&&(l.searcher=Ep(c,t)),l}let s={children:[],operator:a[0]};return a.forEach(u=>{const c=o[u];fo(c)&&c.forEach(l=>{s.children.push(r(l))})}),s};return Np(n)||(n=U2(n)),r(n)}function AD(n,{ignoreFieldNorm:t=Ae.ignoreFieldNorm}){n.forEach(e=>{let r=1;e.matches.forEach(({key:o,norm:a,score:i})=>{const s=o?o.weight:null;r*=Math.pow(i===0&&s?Number.EPSILON:i,(s||1)*(t?1:a))}),e.score=r})}function TD(n,t){const e=n.matches;t.matches=[],jn(e)&&e.forEach(r=>{if(!jn(r.indices)||!r.indices.length)return;const{indices:o,value:a}=r;let i={indices:o,value:a};r.key&&(i.key=r.key.src),r.idx>-1&&(i.refIndex=r.idx),t.matches.push(i)})}function OD(n,t){t.score=n.score}function DD(n,t,{includeMatches:e=Ae.includeMatches,includeScore:r=Ae.includeScore}={}){const o=[];return e&&o.push(TD),r&&o.push(OD),n.map(a=>{const{idx:i}=a,s={item:t[i],refIndex:i};return o.length&&o.forEach(u=>{u(a,s)}),s})}class Bi{constructor(t,e={},r){this.options={...Ae,...e},this.options.useExtendedSearch,this._keyStore=new cD(this.options.keys),this.setCollection(t,r)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof wp))throw new Error(oD);this._myIndex=e||R2(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){jn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let r=0,o=this._docs.length;r<o;r+=1){const a=this._docs[r];t(a,r)&&(this.removeAt(r),r-=1,o-=1,e.push(a))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:s}=this.options;let u=zr(t)?zr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return AD(u,{ignoreFieldNorm:s}),a&&u.sort(i),A2(e)&&e>-1&&(u=u.slice(0,e)),DD(u,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const e=Ep(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=e.searchIn(a);u&&o.push({item:a,idx:i,matches:[{score:c,value:a,norm:s,indices:l}]})}),o}_searchLogical(t){const e=z2(t,this.options),r=(s,u,c)=>{if(!s.children){const{keyId:d,searcher:f}=s,h=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:f});return h&&h.length?[{idx:c,item:u,matches:h}]:[]}const l=[];for(let d=0,f=s.children.length;d<f;d+=1){const h=s.children[d],m=r(h,u,c);if(m.length)l.push(...m);else if(s.operator===Pl.AND)return[]}return l},o=this._myIndex.records,a={},i=[];return o.forEach(({$:s,i:u})=>{if(jn(s)){let c=r(e,s,u);c.length&&(a[u]||(a[u]={idx:u,item:s,matches:[]},i.push(a[u])),c.forEach(({matches:l})=>{a[u].matches.push(...l)}))}}),i}_searchObjectList(t){const e=Ep(t,this.options),{keys:r,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:s})=>{if(!jn(i))return;let u=[];r.forEach((c,l)=>{u.push(...this._findMatches({key:c,value:i[l],searcher:e}))}),u.length&&a.push({idx:s,item:i,matches:u})}),a}_findMatches({key:t,value:e,searcher:r}){if(!jn(e))return[];let o=[];if(fo(e))e.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=r.searchIn(a);u&&o.push({score:c,key:t,value:a,idx:i,norm:s,indices:l})});else{const{v:a,n:i}=e,{isMatch:s,score:u,indices:c}=r.searchIn(a);s&&o.push({score:u,key:t,value:a,norm:i,indices:c})}return o}}Bi.version="7.1.0",Bi.createIndex=R2,Bi.parseIndex=hD,Bi.config=Ae,Bi.parseQuery=z2,kD($D);const MD=D.createContext(void 0);let $p;const FD=({apiEndpoint:n,children:t})=>(D.useEffect(()=>{$p=n},[n]),b.jsx(MD.Provider,{value:{apiEndpoint:n},children:t})),RD=()=>{if(!$p)throw new Error("ApiEndpoint not initialized. Make sure ApiProvider is mounted.");return $p};typeof window>"u"&&(async()=>{const{Canvas:n,Image:t,ImageData:e,loadImage:r}=await Promise.resolve().then(()=>dz);global.Image=t,global.HTMLImageElement=t,global.ImageData=e,global.HTMLCanvasElement=n,global.CanvasRenderingContext2D=n,global.loadImage=r,rn.monkeyPatch({Canvas:n,Image:t,ImageData:e,createCanvasElement:()=>new n(1,1),createImageElement:()=>new t})})();class LD{constructor(){km(this,"signalMap");km(this,"modelsLoaded",!1);this.signalMap={id:["date of birth","birth date","place of birth","id","identification","identity card","permit","valid until","expiration date","given name","surname","sex","gender","height","weight","address","issuing authority","issued by","card number","personal number","nationality"],passport:["passport","passport number","country code","issuing country","issuing state","place of issue","place of birth","date of issue","date of expiry","expiry date","valid until","authority","surname","given name","name","sex","nationality","type","holder","mrz","document","travel","abroad","citizen"],license:["license","driver","driver license","dl number","licence number","permit","valid until","date of birth","birth date","issue date","expiration date","holder's signature","authority","class","restrictions","endorsements","sex","eyes","hair","height","weight","organ donor","address"],voterId:["voter","voting","voter id","voter card","elector","elector's name","father's name","electoral roll","polling station","constituency","elector id","serial number","sex","age","dob","date of birth","part number","section","epic","identity card","address"],default:["name","id","date","dob","expiry","number","document","issued"]}}async toBase64(t){if(typeof window>"u")return(await(await Promise.resolve().then(()=>fz)).readFile(t)).toString("base64");if(t instanceof File)return new Promise((e,r)=>{const o=new FileReader;o.onload=()=>{const i=o.result.split(",")[1];e(i)},o.onerror=r,o.readAsDataURL(t)});throw new Error("Unsupported input type for base64 conversion")}async validateIdCard(t,e){let r=t;if(typeof t!="string"){const s=await this.toBase64(t);r=`data:${t.type||"image/jpeg"};base64,${s}`}const{data:{text:o}}=await Ak.recognize(r,"eng"),a=this.signalMap[e]||this.signalMap.default;console.log("OCR Result:",{text:o});let i=a.some(s=>{const u=o.toLowerCase().includes(s);return u&&console.log(`Found ${e} match:`,s),u});if(!i){const u=new Bi(a,{includeScore:!0,threshold:.6}).search(o.toLowerCase());i=u.length>0,i&&console.log("Found fuzzy match:",u[0].item,u[0].score,{found:u})}return{type:e,passed:i,textSnippet:o.slice(0,200),fullText:o}}async loadModels(){if(this.modelsLoaded)return;const e=`${RD()}/api/models`;await Promise.all([mn.ssdMobilenetv1.loadFromUri(e),mn.faceLandmark68Net.loadFromUri(e),mn.faceRecognitionNet.loadFromUri(e)]),this.modelsLoaded=!0}async validateFace(t){await this.loadModels();let e=t;if(typeof t!="string"){const i=await this.toBase64(t);e=`data:${t.type||"image/jpeg"};base64,${i}`}const r=await this.fileToImage(e),o=await Q9(r,new ou);return{type:"face",passed:o.length===1,facesDetected:o.length}}async fileToImage(t){return new Promise((e,r)=>{const o=new Image;if(o.onload=()=>e(o),o.onerror=r,typeof t=="string")o.src=t;else{const a=new FileReader;a.onload=()=>{o.src=a.result},a.onerror=r,a.readAsDataURL(t)}})}}const H2=new LD,BD=(n,t,e,r,o,a,i)=>{const[s,u]=D.useState(null),[c,l]=D.useState(null),[d,f]=D.useState({x:0,y:0,w:320,h:192}),h=D.useRef(`frameMask-${Math.random().toString(36).slice(2)}`),{toast:m}=Qu(),p=D.useMemo(()=>c?URL.createObjectURL(c):null,[c]),v=vi.find(x=>x.id===i);D.useEffect(()=>{e.current&&s&&(e.current.srcObject=s)},[s]),D.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]);const g=D.useCallback(async()=>{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:9999},height:{ideal:9999}}});u(x)}catch{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:1280},height:{ideal:720}}});u(x)}catch{m({title:"Camera Error",description:"Unable to access camera. Please check permissions.",variant:"destructive"})}}},[n,m]),y=D.useCallback(()=>{s&&(s.getTracks().forEach(x=>x.stop()),u(null))},[s]),w=D.useCallback(async()=>{if(!e.current||!r.current||!o.current)return;const x=e.current,C=r.current,_=C.getContext("2d");if(!_)return;const E=x.videoWidth,S=x.videoHeight;if(n==="selfie"){C.width=E,C.height=S,_.drawImage(x,0,0,E,S),C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{const q=document.createElement("canvas"),Z=q.getContext("2d");if(!Z)return;const oe=x.getBoundingClientRect(),ae=E/oe.width,X=S/oe.height,re=10,ce=(d.x-re)*ae,ue=(d.y-re)*X,se=(d.w+2*re)*ae,ee=(d.h+2*re)*X;q.width=se,q.height=ee,Z.drawImage(x,ce,ue,se,ee,0,0,se,ee);const _e=await new Promise(Ze=>q.toBlob(Ze,"image/jpeg",.8));if(!_e)return;const Me=new File([_e],`crop-${Date.now()}.jpg`,{type:"image/jpeg"});if(m({title:"Validating...",description:"Checking if the photo has a face..."}),!(await H2.validateFace(Me)).passed){m({title:"Validation Failed",description:"No face detected. Please retake your selfie.",variant:"destructive"});return}m({title:"Photo Captured",description:"Selfie captured successfully"}),l(K),y()}catch(q){console.error("Face validation error:",q),m({title:"Validation Error",description:"We couldn’t process the selfie. Please try again.",variant:"destructive"})}},"image/jpeg",.8);return}const N=x.getBoundingClientRect(),$=E/N.width,A=S/N.height,P=10,j=(d.x-P)*$,B=(d.y-P)*A,z=(d.w+2*P)*$,H=(d.h+2*P)*A,F=Math.max(0,Math.min(j,E-z)),M=Math.max(0,Math.min(B,S-H)),O=Math.min(z,E-F),I=Math.min(H,S-M);if(C.width=t==="circular"?Math.max(O,I):O,C.height=t==="circular"?Math.max(O,I):I,t==="circular"){const L=Math.min(O,I)/2;_.beginPath(),_.arc(C.width/2,C.height/2,L+P*$,0,Math.PI*2),_.clip(),_.drawImage(x,F-(C.width-O)/2,M-(C.height-I)/2,C.width,C.height,0,0,C.width,C.height)}else _.drawImage(x,F,M,O,I,0,0,C.width,C.height);C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{if(m({title:"Validating...",description:`Checking if the photo looks like ${v.title} ...`}),!(await H2.validateIdCard(K,i)).passed){m({title:"Validation Failed",description:`This doesn’t look like ${v.title} card. Try again.`,variant:"destructive"});return}l(K),y(),m({title:"Photo Captured",description:`${v.title} validated successfully`})}catch(q){console.error(q),m({title:"OCR Error",description:"We couldn’t process the photo. Please try again.",variant:"destructive"})}},"image/jpeg",.8)},[n,y,m,t,d,e,r,o]);return D.useEffect(()=>(!c&&!s&&g(),()=>{y()}),[c,s,g,y]),D.useEffect(()=>{if(!o.current||!a.current)return;const x=()=>{const _=o.current.getBoundingClientRect(),E=a.current.getBoundingClientRect();f({x:Math.round(E.left-_.left),y:Math.round(E.top-_.top),w:Math.round(E.width),h:Math.round(E.height)})};x();const C=new ResizeObserver(x);return C.observe(a.current),C.observe(o.current),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{C.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},[t,s,o,a]),{stream:s,photo:c,setPhoto:l,hole:d,maskId:h.current,photoUrl:p,capturePhoto:w}},kp=768;function WD(){const[n,t]=k.useState(void 0);return k.useEffect(()=>{const e=window.matchMedia(`(max-width: ${kp-1}px)`),r=()=>{t(window.innerWidth<kp)};return e.addEventListener("change",r),t(window.innerWidth<kp),()=>e.removeEventListener("change",r)},[]),!!n}const VD={"id-front":"ID Front","id-back":"ID Back",selfie:"Selfie"},Wi=({currentStep:n,onRetake:t,onConfirm:e,onBack:r,title:o,description:a,frameType:i,documentTypeId:s})=>{const u=D.useRef(null),c=D.useRef(null),l=D.useRef(null),d=D.useRef(null),f=WD(),{stream:h,photo:m,setPhoto:p,hole:v,maskId:g,photoUrl:y,capturePhoto:w}=BD(n,i,u,c,l,d,s),x=!!h,C=()=>{p(null),r()},_=()=>{p(null),t()},E=()=>{m&&e(m),m&&e(m),p(null)},S=v.x+v.w/2,N=v.y+v.h/2,$=Math.max(v.w,v.h)/2,A=()=>{const P=VD[n]||"Photo";return b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:`Review ${P}`,subTitle:"Make sure the information is seen clearly, with no blur or glare.",onBack:C}),b.jsx("div",{className:"mb-8",children:b.jsx("div",{className:"relative",children:y&&b.jsx("img",{src:y,alt:"Captured photo",className:`w-full h-64 object-cover ${n==="selfie"?"":i==="circular"?"rounded-full":"rounded-2xl"} bg-muted`})})}),b.jsxs("div",{className:"flex gap-4",children:[b.jsx(_t,{variant:"outline",onClick:_,className:"flex-1 text-md",children:"Take again"}),b.jsx(_t,{onClick:E,className:"flex-1 text-md",children:"Looks good"})]})]})})};return m?A():b.jsxs(hn,{className:"relative w-full max-w-md mx-auto bg-gray-900 border-gray-900 overflow-hidden",children:[x&&b.jsx("video",{ref:u,autoPlay:!0,playsInline:!0,muted:!0,loop:!0,className:`absolute inset-0 w-full h-full object-cover z-0 ${!f&&"scale-x-[-1]"}`}),b.jsx("div",{ref:l,className:"absolute inset-0 z-5 pointer-events-none","aria-hidden":!0,children:b.jsxs("svg",{className:"w-full h-full",children:[b.jsx("defs",{children:b.jsxs("mask",{id:g,children:[b.jsx("rect",{width:"100%",height:"100%",fill:"white"}),i==="circular"?b.jsx("circle",{cx:S,cy:N,r:$,fill:"black"}):b.jsx("rect",{x:v.x,y:v.y,width:v.w,height:v.h,fill:"black"})]})}),b.jsx("rect",{width:"100%",height:"100%",fill:"rgba(17,24,39,0.7)",mask:`url(#${g})`})]})}),b.jsx("canvas",{ref:c,className:"hidden"}),b.jsxs(pn,{className:"relative z-10 text-white flex flex-col h-full",children:[b.jsxs("div",{className:"flex items-center p-6",children:[b.jsx(_t,{variant:"ghost",size:"sm",onClick:C,className:"text-white hover:bg-gray-600",children:b.jsx(Cg,{className:"h-6 w-6"})}),b.jsx("h1",{className:"text-xl font-semibold ml-4",children:o})]}),b.jsx("div",{className:"px-6 mb-8",children:b.jsx("p",{className:"text-gray-300 text-center",children:a})}),b.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:[b.jsx("div",{className:"relative mb-16",children:x?b.jsxs("div",{ref:d,className:`relative z-20 ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:[b.jsx("div",{className:`absolute inset-0 opacity-0 ${i==="circular"?"rounded-full":""} z-10`}),i==="circular"?null:b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-l-4 border-white z-30",style:{top:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-r-4 border-white z-30",style:{top:"-4px",right:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-l-4 border-white z-30",style:{bottom:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-r-4 border-white z-30",style:{bottom:"-4px",right:"-4px"}})]})]}):b.jsx("div",{className:`bg-gray-700 flex items-center justify-center ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:b.jsx("p",{className:"text-gray-400",children:"Camera loading..."})})}),b.jsx(_t,{onClick:w,size:"lg",className:"w-16 h-16 rounded-full bg-white hover:bg-gray-100 border-4 border-gray-600 p-0",disabled:!x,children:b.jsx("div",{className:"w-8 h-8 rounded-full bg-white"})})]})]})]})},jD=({apiEndpoint:n,apiKey:t,onComplete:e,onDoneClick:r})=>{const[o,a]=D.useState("landing"),[i,s]=D.useState(""),[u,c]=D.useState(""),[l,d]=D.useState(null),[f,h]=D.useState(null),[m,p]=D.useState(null),{data:v}=HD(n,t),g=X0({mutationFn:UD}),{toast:y}=Qu(),w=D.useMemo(()=>[...v!=null&&v.hide_name_step?[]:["name"],...v!=null&&v.hide_document_selection_step?[]:["document-selection"],"selfie","pre-selfie","id-front","id-back","verify"],[v]),x=()=>v.hide_name_step?v.hide_document_selection_step?"id-front":"document-selection":"name",C=async()=>{if((v.hide_name_step||!!i)&&l&&f&&m){const N={full_name:i,selfie_photo:l,id_photo:f,id_photo_back:m},$=await g.mutateAsync({apiEndpoint:n,apiKey:t,data:N});e($.data.token,N),y({title:"KYC Complete",description:"Identity verification completed successfully"}),s(""),d(null),h(null),p(null),a("done")}},_=()=>b.jsx(b.Fragment,{children:o!=="landing"&&b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"flex space-x-2",children:w.map((S,N)=>b.jsx("div",{className:`w-3 h-3 rounded-full ${w.indexOf(o)>=N?"bg-primary":"bg-muted"}`},S))})})}),E=()=>{switch(console.log("currentStep",o),o){case"landing":return b.jsx(Z0,{onContinue:()=>a(x())});case"name":return b.jsx(G$,{fullName:i,onNameChange:s,onContinue:()=>a(v.hide_document_selection_step?"id-front":"document-selection"),renderProgress:_});case"document-selection":return b.jsx(ey,{selectedDocumentType:u,onDocumentTypeChange:c,onContinue:()=>a("id-front"),onBack:()=>a(v.hide_name_step?"landing":"name"),renderProgress:_});case"id-front":return b.jsx(Wi,{title:"Upload ID",description:"Place your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",currentStep:o,onRetake:()=>{h(null)},onConfirm:S=>{h(S),a(u==="passport"?"pre-selfie":"id-back")},onBack:()=>{h(null),a(v.hide_document_selection_step?v.hide_name_step?"landing":"name":"document-selection")}});case"id-back":return b.jsx(Wi,{title:"Upload ID Back",description:"Place the back of your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",currentStep:o,onRetake:()=>{p(null)},onConfirm:S=>{p(S),a("pre-selfie")},onBack:()=>{p(null),a("id-front")}});case"pre-selfie":return b.jsx(ty,{onContinue:()=>a("selfie"),onBack:()=>a("id-back")});case"selfie":return b.jsx(Wi,{title:"Selfie",description:"Place your face inside the frame and take a picture. Make sure it is clearly visible.",frameType:"circular",currentStep:o,onRetake:()=>{d(null)},onConfirm:S=>{d(S),a("verify")},onBack:()=>{d(null),a("id-back")}});case"verify":return b.jsx(q$,{fullName:i,onComplete:()=>a("processing"),onStartOver:()=>a("landing")});case"processing":return b.jsx(ny,{onComplete:C});case"done":return b.jsx(ry,{onDoneClick:r});default:return null}};return b.jsx("div",{className:"w-[430px]",children:E()})};async function UD({apiEndpoint:n,apiKey:t,data:e}){const r=new FormData;r.append("full_name",e.full_name),r.append("selfie_photo",e.selfie_photo,e.selfie_photo.name),r.append("id_photo",e.id_photo,e.id_photo.name),r.append("id_photo_back",e.id_photo_back,e.id_photo_back.name);const o=await fetch(`${n}/api/kyc`,{method:"POST",headers:{"X-API-Key":t},body:r});if(!o.ok)throw new Error("Network response was not ok");return o.json()}const zD=async(n,t)=>{const e=await fetch(`${n}/api/settings`,{method:"GET",headers:{"X-API-Key":t,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Network response was not ok");return(await e.json()).data},HD=(n,t)=>V$({queryKey:["settings",n,t],queryFn:()=>zD(n,t),enabled:!!n&&!!t});var iu=n=>n.type==="checkbox",Va=n=>n instanceof Date,gn=n=>n==null;const G2=n=>typeof n=="object";var Dt=n=>!gn(n)&&!Array.isArray(n)&&G2(n)&&!Va(n),q2=n=>Dt(n)&&n.target?iu(n.target)?n.target.checked:n.target.value:n,GD=n=>n.substring(0,n.search(/\.\d+(\.|$)/))||n,K2=(n,t)=>n.has(GD(t)),qD=n=>{const t=n.constructor&&n.constructor.prototype;return Dt(t)&&t.hasOwnProperty("isPrototypeOf")},Pp=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Gt(n){let t;const e=Array.isArray(n),r=typeof FileList<"u"?n instanceof FileList:!1;if(n instanceof Date)t=new Date(n);else if(!(Pp&&(n instanceof Blob||r))&&(e||Dt(n)))if(t=e?[]:Object.create(Object.getPrototypeOf(n)),!e&&!qD(n))t=n;else for(const o in n)n.hasOwnProperty(o)&&(t[o]=Gt(n[o]));else return n;return t}var Il=n=>/^\w*$/.test(n),At=n=>n===void 0,Ip=n=>Array.isArray(n)?n.filter(Boolean):[],Ap=n=>Ip(n.replace(/["|']|\]/g,"").split(/\.|\[/)),me=(n,t,e)=>{if(!t||!Dt(n))return e;const r=(Il(t)?[t]:Ap(t)).reduce((o,a)=>gn(o)?o:o[a],n);return At(r)||r===n?At(n[t])?e:n[t]:r},Un=n=>typeof n=="boolean",ct=(n,t,e)=>{let r=-1;const o=Il(t)?[t]:Ap(t),a=o.length,i=a-1;for(;++r<a;){const s=o[r];let u=e;if(r!==i){const c=n[s];u=Dt(c)||Array.isArray(c)?c:isNaN(+o[r+1])?{}:[]}if(s==="__proto__"||s==="constructor"||s==="prototype")return;n[s]=u,n=n[s]}};const Al={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},lr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ho={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Tp=D.createContext(null);Tp.displayName="HookFormContext";const Tl=()=>D.useContext(Tp),KD=n=>{const{children:t,...e}=n;return D.createElement(Tp.Provider,{value:e},t)};var Y2=(n,t,e,r=!0)=>{const o={defaultValues:t._defaultValues};for(const a in n)Object.defineProperty(o,a,{get:()=>{const i=a;return t._proxyFormState[i]!==lr.all&&(t._proxyFormState[i]=!r||lr.all),e&&(e[i]=!0),n[i]}});return o};const Op=typeof window<"u"?D.useLayoutEffect:D.useEffect;function YD(n){const t=Tl(),{control:e=t.control,disabled:r,name:o,exact:a}=n||{},[i,s]=D.useState(e._formState),u=D.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Op(()=>e._subscribe({name:o,formState:u.current,exact:a,callback:c=>{!r&&s({...e._formState,...c})}}),[o,r,a]),D.useEffect(()=>{u.current.isValid&&e._setValid(!0)},[e]),D.useMemo(()=>Y2(i,e,u.current,!1),[i,e])}var zn=n=>typeof n=="string",X2=(n,t,e,r,o)=>zn(n)?(r&&t.watch.add(n),me(e,n,o)):Array.isArray(n)?n.map(a=>(r&&t.watch.add(a),me(e,a))):(r&&(t.watchAll=!0),e),Dp=n=>gn(n)||!G2(n);function po(n,t,e=new WeakSet){if(Dp(n)||Dp(t))return n===t;if(Va(n)&&Va(t))return n.getTime()===t.getTime();const r=Object.keys(n),o=Object.keys(t);if(r.length!==o.length)return!1;if(e.has(n)||e.has(t))return!0;e.add(n),e.add(t);for(const a of r){const i=n[a];if(!o.includes(a))return!1;if(a!=="ref"){const s=t[a];if(Va(i)&&Va(s)||Dt(i)&&Dt(s)||Array.isArray(i)&&Array.isArray(s)?!po(i,s,e):i!==s)return!1}}return!0}function XD(n){const t=Tl(),{control:e=t.control,name:r,defaultValue:o,disabled:a,exact:i,compute:s}=n||{},u=D.useRef(o),c=D.useRef(s),l=D.useRef(void 0);c.current=s;const d=D.useMemo(()=>e._getWatch(r,u.current),[e,r]),[f,h]=D.useState(c.current?c.current(d):d);return Op(()=>e._subscribe({name:r,formState:{values:!0},exact:i,callback:m=>{if(!a){const p=X2(r,e._names,m.values||e._formValues,!1,u.current);if(c.current){const v=c.current(p);po(v,l.current)||(h(v),l.current=v)}else h(p)}}}),[e,a,r,i]),D.useEffect(()=>e._removeUnmounted()),f}function Z2(n){const t=Tl(),{name:e,disabled:r,control:o=t.control,shouldUnregister:a,defaultValue:i}=n,s=K2(o._names.array,e),u=D.useMemo(()=>me(o._formValues,e,me(o._defaultValues,e,i)),[o,e,i]),c=XD({control:o,name:e,defaultValue:u,exact:!0}),l=YD({control:o,name:e,exact:!0}),d=D.useRef(n),f=D.useRef(void 0),h=D.useRef(o.register(e,{...n.rules,value:c,...Un(n.disabled)?{disabled:n.disabled}:{}}));d.current=n;const m=D.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!me(l.errors,e)},isDirty:{enumerable:!0,get:()=>!!me(l.dirtyFields,e)},isTouched:{enumerable:!0,get:()=>!!me(l.touchedFields,e)},isValidating:{enumerable:!0,get:()=>!!me(l.validatingFields,e)},error:{enumerable:!0,get:()=>me(l.errors,e)}}),[l,e]),p=D.useCallback(w=>h.current.onChange({target:{value:q2(w),name:e},type:Al.CHANGE}),[e]),v=D.useCallback(()=>h.current.onBlur({target:{value:me(o._formValues,e),name:e},type:Al.BLUR}),[e,o._formValues]),g=D.useCallback(w=>{const x=me(o._fields,e);x&&w&&(x._f.ref={focus:()=>w.focus&&w.focus(),select:()=>w.select&&w.select(),setCustomValidity:C=>w.setCustomValidity(C),reportValidity:()=>w.reportValidity()})},[o._fields,e]),y=D.useMemo(()=>({name:e,value:c,...Un(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p,onBlur:v,ref:g}),[e,r,l.disabled,p,v,g,c]);return D.useEffect(()=>{const w=o._options.shouldUnregister||a,x=f.current;x&&x!==e&&!s&&o.unregister(x),o.register(e,{...d.current.rules,...Un(d.current.disabled)?{disabled:d.current.disabled}:{}});const C=(_,E)=>{const S=me(o._fields,_);S&&S._f&&(S._f.mount=E)};if(C(e,!0),w){const _=Gt(me(o._options.defaultValues,e));ct(o._defaultValues,e,_),At(me(o._formValues,e))&&ct(o._formValues,e,_)}return!s&&o.register(e),f.current=e,()=>{(s?w&&!o._state.action:w)?o.unregister(e):C(e,!1)}},[e,o,s,a]),D.useEffect(()=>{o._setDisabledField({disabled:r,name:e})},[r,e,o]),D.useMemo(()=>({field:y,formState:l,fieldState:m}),[y,l,m])}const ZD=n=>n.render(Z2(n));var Q2=(n,t,e,r,o)=>t?{...e[n],types:{...e[n]&&e[n].types?e[n].types:{},[r]:o||!0}}:{},su=n=>Array.isArray(n)?n:[n],J2=()=>{let n=[];return{get observers(){return n},next:o=>{for(const a of n)a.next&&a.next(o)},subscribe:o=>(n.push(o),{unsubscribe:()=>{n=n.filter(a=>a!==o)}}),unsubscribe:()=>{n=[]}}};function ex(n,t){const e={};for(const r in n)if(n.hasOwnProperty(r)){const o=n[r],a=t[r];if(o&&Dt(o)&&a){const i=ex(o,a);Dt(i)&&(e[r]=i)}else n[r]&&(e[r]=a)}return e}var kn=n=>Dt(n)&&!Object.keys(n).length,Mp=n=>n.type==="file",dr=n=>typeof n=="function",Ol=n=>{if(!Pp)return!1;const t=n?n.ownerDocument:0;return n instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},tx=n=>n.type==="select-multiple",Fp=n=>n.type==="radio",QD=n=>Fp(n)||iu(n),Rp=n=>Ol(n)&&n.isConnected;function JD(n,t){const e=t.slice(0,-1).length;let r=0;for(;r<e;)n=At(n)?r++:n[t[r++]];return n}function e8(n){for(const t in n)if(n.hasOwnProperty(t)&&!At(n[t]))return!1;return!0}function Mt(n,t){const e=Array.isArray(t)?t:Il(t)?[t]:Ap(t),r=e.length===1?n:JD(n,e),o=e.length-1,a=e[o];return r&&delete r[a],o!==0&&(Dt(r)&&kn(r)||Array.isArray(r)&&e8(r))&&Mt(n,e.slice(0,-1)),n}var t8=n=>{for(const t in n)if(dr(n[t]))return!0;return!1};function nx(n){return Array.isArray(n)||Dt(n)&&!t8(n)}function Lp(n,t={}){for(const e in n)nx(n[e])?(t[e]=Array.isArray(n[e])?[]:{},Lp(n[e],t[e])):gn(n[e])||(t[e]=!0);return t}function Vi(n,t,e){e||(e=Lp(t));for(const r in n)nx(n[r])?At(t)||Dp(e[r])?e[r]=Lp(n[r],Array.isArray(n[r])?[]:{}):Vi(n[r],gn(t)?{}:t[r],e[r]):e[r]=!po(n[r],t[r]);return e}const rx={value:!1,isValid:!1},ox={value:!0,isValid:!0};var ax=n=>{if(Array.isArray(n)){if(n.length>1){const t=n.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return n[0].checked&&!n[0].disabled?n[0].attributes&&!At(n[0].attributes.value)?At(n[0].value)||n[0].value===""?ox:{value:n[0].value,isValid:!0}:ox:rx}return rx},ix=(n,{valueAsNumber:t,valueAsDate:e,setValueAs:r})=>At(n)?n:t?n===""?NaN:n&&+n:e&&zn(n)?new Date(n):r?r(n):n;const sx={isValid:!1,value:null};var ux=n=>Array.isArray(n)?n.reduce((t,e)=>e&&e.checked&&!e.disabled?{isValid:!0,value:e.value}:t,sx):sx;function cx(n){const t=n.ref;return Mp(t)?t.files:Fp(t)?ux(n.refs).value:tx(t)?[...t.selectedOptions].map(({value:e})=>e):iu(t)?ax(n.refs).value:ix(At(t.value)?n.ref.value:t.value,n)}var n8=(n,t,e,r)=>{const o={};for(const a of n){const i=me(t,a);i&&ct(o,a,i._f)}return{criteriaMode:e,names:[...n],fields:o,shouldUseNativeValidation:r}},Dl=n=>n instanceof RegExp,uu=n=>At(n)?n:Dl(n)?n.source:Dt(n)?Dl(n.value)?n.value.source:n.value:n,lx=n=>({isOnSubmit:!n||n===lr.onSubmit,isOnBlur:n===lr.onBlur,isOnChange:n===lr.onChange,isOnAll:n===lr.all,isOnTouch:n===lr.onTouched});const dx="AsyncFunction";var r8=n=>!!n&&!!n.validate&&!!(dr(n.validate)&&n.validate.constructor.name===dx||Dt(n.validate)&&Object.values(n.validate).find(t=>t.constructor.name===dx)),o8=n=>n.mount&&(n.required||n.min||n.max||n.maxLength||n.minLength||n.pattern||n.validate),fx=(n,t,e)=>!e&&(t.watchAll||t.watch.has(n)||[...t.watch].some(r=>n.startsWith(r)&&/^\.\w+/.test(n.slice(r.length))));const cu=(n,t,e,r)=>{for(const o of e||Object.keys(n)){const a=me(n,o);if(a){const{_f:i,...s}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(cu(s,t))break}else if(Dt(s)&&cu(s,t))break}}};function hx(n,t,e){const r=me(n,e);if(r||Il(e))return{error:r,name:e};const o=e.split(".");for(;o.length;){const a=o.join("."),i=me(t,a),s=me(n,a);if(i&&!Array.isArray(i)&&e!==a)return{name:e};if(s&&s.type)return{name:a,error:s};if(s&&s.root&&s.root.type)return{name:`${a}.root`,error:s.root};o.pop()}return{name:e}}var a8=(n,t,e,r)=>{e(n);const{name:o,...a}=n;return kn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||lr.all))},i8=(n,t,e)=>!n||!t||n===t||su(n).some(r=>r&&(e?r===t:r.startsWith(t)||t.startsWith(r))),s8=(n,t,e,r,o)=>o.isOnAll?!1:!e&&o.isOnTouch?!(t||n):(e?r.isOnBlur:o.isOnBlur)?!n:(e?r.isOnChange:o.isOnChange)?n:!0,u8=(n,t)=>!Ip(me(n,t)).length&&Mt(n,t),c8=(n,t,e)=>{const r=su(me(n,e));return ct(r,"root",t[e]),ct(n,e,r),n};function px(n,t,e="validate"){if(zn(n)||Array.isArray(n)&&n.every(zn)||Un(n)&&!n)return{type:e,message:zn(n)?n:"",ref:t}}var ji=n=>Dt(n)&&!Dl(n)?n:{value:n,message:""},vx=async(n,t,e,r,o,a)=>{const{ref:i,refs:s,required:u,maxLength:c,minLength:l,min:d,max:f,pattern:h,validate:m,name:p,valueAsNumber:v,mount:g}=n._f,y=me(e,p);if(!g||t.has(p))return{};const w=s?s[0]:i,x=P=>{o&&w.reportValidity&&(w.setCustomValidity(Un(P)?"":P||""),w.reportValidity())},C={},_=Fp(i),E=iu(i),S=_||E,N=(v||Mp(i))&&At(i.value)&&At(y)||Ol(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,$=Q2.bind(null,p,r,C),A=(P,j,B,z=ho.maxLength,H=ho.minLength)=>{const F=P?j:B;C[p]={type:P?z:H,message:F,ref:i,...$(P?z:H,F)}};if(a?!Array.isArray(y)||!y.length:u&&(!S&&(N||gn(y))||Un(y)&&!y||E&&!ax(s).isValid||_&&!ux(s).isValid)){const{value:P,message:j}=zn(u)?{value:!!u,message:u}:ji(u);if(P&&(C[p]={type:ho.required,message:j,ref:w,...$(ho.required,j)},!r))return x(j),C}if(!N&&(!gn(d)||!gn(f))){let P,j;const B=ji(f),z=ji(d);if(!gn(y)&&!isNaN(y)){const H=i.valueAsNumber||y&&+y;gn(B.value)||(P=H>B.value),gn(z.value)||(j=H<z.value)}else{const H=i.valueAsDate||new Date(y),F=I=>new Date(new Date().toDateString()+" "+I),M=i.type=="time",O=i.type=="week";zn(B.value)&&y&&(P=M?F(y)>F(B.value):O?y>B.value:H>new Date(B.value)),zn(z.value)&&y&&(j=M?F(y)<F(z.value):O?y<z.value:H<new Date(z.value))}if((P||j)&&(A(!!P,B.message,z.message,ho.max,ho.min),!r))return x(C[p].message),C}if((c||l)&&!N&&(zn(y)||a&&Array.isArray(y))){const P=ji(c),j=ji(l),B=!gn(P.value)&&y.length>+P.value,z=!gn(j.value)&&y.length<+j.value;if((B||z)&&(A(B,P.message,j.message),!r))return x(C[p].message),C}if(h&&!N&&zn(y)){const{value:P,message:j}=ji(h);if(Dl(P)&&!y.match(P)&&(C[p]={type:ho.pattern,message:j,ref:i,...$(ho.pattern,j)},!r))return x(j),C}if(m){if(dr(m)){const P=await m(y,e),j=px(P,w);if(j&&(C[p]={...j,...$(ho.validate,j.message)},!r))return x(j.message),C}else if(Dt(m)){let P={};for(const j in m){if(!kn(P)&&!r)break;const B=px(await m[j](y,e),w,j);B&&(P={...B,...$(j,B.message)},x(B.message),r&&(C[p]=P))}if(!kn(P)&&(C[p]={ref:w,...P},!r))return C}}return x(!0),C};const l8={mode:lr.onSubmit,reValidateMode:lr.onChange,shouldFocusError:!0};function d8(n={}){let t={...l8,...n},e={submitCount:0,isDirty:!1,isReady:!1,isLoading:dr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=Dt(t.defaultValues)||Dt(t.values)?Gt(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Gt(o),i={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const l={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...l};const f={array:J2(),state:J2()},h=t.criteriaMode===lr.all,m=V=>Y=>{clearTimeout(c),c=setTimeout(V,Y)},p=async V=>{if(!t.disabled&&(l.isValid||d.isValid||V)){const Y=t.resolver?kn((await E()).errors):await N(r,!0);Y!==e.isValid&&f.state.next({isValid:Y})}},v=(V,Y)=>{!t.disabled&&(l.isValidating||l.validatingFields||d.isValidating||d.validatingFields)&&((V||Array.from(s.mount)).forEach(te=>{te&&(Y?ct(e.validatingFields,te,Y):Mt(e.validatingFields,te))}),f.state.next({validatingFields:e.validatingFields,isValidating:!kn(e.validatingFields)}))},g=(V,Y=[],te,he,pe=!0,le=!0)=>{if(he&&te&&!t.disabled){if(i.action=!0,le&&Array.isArray(me(r,V))){const ye=te(me(r,V),he.argA,he.argB);pe&&ct(r,V,ye)}if(le&&Array.isArray(me(e.errors,V))){const ye=te(me(e.errors,V),he.argA,he.argB);pe&&ct(e.errors,V,ye),u8(e.errors,V)}if((l.touchedFields||d.touchedFields)&&le&&Array.isArray(me(e.touchedFields,V))){const ye=te(me(e.touchedFields,V),he.argA,he.argB);pe&&ct(e.touchedFields,V,ye)}(l.dirtyFields||d.dirtyFields)&&(e.dirtyFields=Vi(o,a)),f.state.next({name:V,isDirty:A(V,Y),dirtyFields:e.dirtyFields,errors:e.errors,isValid:e.isValid})}else ct(a,V,Y)},y=(V,Y)=>{ct(e.errors,V,Y),f.state.next({errors:e.errors})},w=V=>{e.errors=V,f.state.next({errors:e.errors,isValid:!1})},x=(V,Y,te,he)=>{const pe=me(r,V);if(pe){const le=me(a,V,At(te)?me(o,V):te);At(le)||he&&he.defaultChecked||Y?ct(a,V,Y?le:cx(pe._f)):B(V,le),i.mount&&p()}},C=(V,Y,te,he,pe)=>{let le=!1,ye=!1;const We={name:V};if(!t.disabled){if(!te||he){(l.isDirty||d.isDirty)&&(ye=e.isDirty,e.isDirty=We.isDirty=A(),le=ye!==We.isDirty);const Ge=po(me(o,V),Y);ye=!!me(e.dirtyFields,V),Ge?Mt(e.dirtyFields,V):ct(e.dirtyFields,V,!0),We.dirtyFields=e.dirtyFields,le=le||(l.dirtyFields||d.dirtyFields)&&ye!==!Ge}if(te){const Ge=me(e.touchedFields,V);Ge||(ct(e.touchedFields,V,te),We.touchedFields=e.touchedFields,le=le||(l.touchedFields||d.touchedFields)&&Ge!==te)}le&&pe&&f.state.next(We)}return le?We:{}},_=(V,Y,te,he)=>{const pe=me(e.errors,V),le=(l.isValid||d.isValid)&&Un(Y)&&e.isValid!==Y;if(t.delayError&&te?(u=m(()=>y(V,te)),u(t.delayError)):(clearTimeout(c),u=null,te?ct(e.errors,V,te):Mt(e.errors,V)),(te?!po(pe,te):pe)||!kn(he)||le){const ye={...he,...le&&Un(Y)?{isValid:Y}:{},errors:e.errors,name:V};e={...e,...ye},f.state.next(ye)}},E=async V=>{v(V,!0);const Y=await t.resolver(a,t.context,n8(V||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(V),Y},S=async V=>{const{errors:Y}=await E(V);if(V)for(const te of V){const he=me(Y,te);he?ct(e.errors,te,he):Mt(e.errors,te)}else e.errors=Y;return Y},N=async(V,Y,te={valid:!0})=>{for(const he in V){const pe=V[he];if(pe){const{_f:le,...ye}=pe;if(le){const We=s.array.has(le.name),Ge=pe._f&&r8(pe._f);Ge&&l.validatingFields&&v([le.name],!0);const Qt=await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation&&!Y,We);if(Ge&&l.validatingFields&&v([le.name]),Qt[le.name]&&(te.valid=!1,Y))break;!Y&&(me(Qt,le.name)?We?c8(e.errors,Qt,le.name):ct(e.errors,le.name,Qt[le.name]):Mt(e.errors,le.name))}!kn(ye)&&await N(ye,Y,te)}}return te.valid},$=()=>{for(const V of s.unMount){const Y=me(r,V);Y&&(Y._f.refs?Y._f.refs.every(te=>!Rp(te)):!Rp(Y._f.ref))&&X(V)}s.unMount=new Set},A=(V,Y)=>!t.disabled&&(V&&Y&&ct(a,V,Y),!po(I(),o)),P=(V,Y,te)=>X2(V,s,{...i.mount?a:At(Y)?o:zn(V)?{[V]:Y}:Y},te,Y),j=V=>Ip(me(i.mount?a:o,V,t.shouldUnregister?me(o,V,[]):[])),B=(V,Y,te={})=>{const he=me(r,V);let pe=Y;if(he){const le=he._f;le&&(!le.disabled&&ct(a,V,ix(Y,le)),pe=Ol(le.ref)&&gn(Y)?"":Y,tx(le.ref)?[...le.ref.options].forEach(ye=>ye.selected=pe.includes(ye.value)):le.refs?iu(le.ref)?le.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(pe)?ye.checked=!!pe.find(We=>We===ye.value):ye.checked=pe===ye.value||!!pe)}):le.refs.forEach(ye=>ye.checked=ye.value===pe):Mp(le.ref)?le.ref.value="":(le.ref.value=pe,le.ref.type||f.state.next({name:V,values:Gt(a)})))}(te.shouldDirty||te.shouldTouch)&&C(V,pe,te.shouldTouch,te.shouldDirty,!0),te.shouldValidate&&O(V)},z=(V,Y,te)=>{for(const he in Y){if(!Y.hasOwnProperty(he))return;const pe=Y[he],le=V+"."+he,ye=me(r,le);(s.array.has(V)||Dt(pe)||ye&&!ye._f)&&!Va(pe)?z(le,pe,te):B(le,pe,te)}},H=(V,Y,te={})=>{const he=me(r,V),pe=s.array.has(V),le=Gt(Y);ct(a,V,le),pe?(f.array.next({name:V,values:Gt(a)}),(l.isDirty||l.dirtyFields||d.isDirty||d.dirtyFields)&&te.shouldDirty&&f.state.next({name:V,dirtyFields:Vi(o,a),isDirty:A(V,le)})):he&&!he._f&&!gn(le)?z(V,le,te):B(V,le,te),fx(V,s)&&f.state.next({...e,name:V}),f.state.next({name:i.mount?V:void 0,values:Gt(a)})},F=async V=>{i.mount=!0;const Y=V.target;let te=Y.name,he=!0;const pe=me(r,te),le=Ge=>{he=Number.isNaN(Ge)||Va(Ge)&&isNaN(Ge.getTime())||po(Ge,me(a,te,Ge))},ye=lx(t.mode),We=lx(t.reValidateMode);if(pe){let Ge,Qt;const xr=Y.type?cx(pe._f):q2(V),er=V.type===Al.BLUR||V.type===Al.FOCUS_OUT,_s=!o8(pe._f)&&!t.resolver&&!me(e.errors,te)&&!pe._f.deps||s8(er,me(e.touchedFields,te),e.isSubmitted,We,ye),wr=fx(te,s,er);ct(a,te,xr),er?(!Y||!Y.readOnly)&&(pe._f.onBlur&&pe._f.onBlur(V),u&&u(0)):pe._f.onChange&&pe._f.onChange(V);const On=C(te,xr,er),ha=!kn(On)||wr;if(!er&&f.state.next({name:te,type:V.type,values:Gt(a)}),_s)return(l.isValid||d.isValid)&&(t.mode==="onBlur"?er&&p():er||p()),ha&&f.state.next({name:te,...wr?{}:On});if(!er&&wr&&f.state.next({...e}),t.resolver){const{errors:No}=await E([te]);if(le(xr),he){const Nm=hx(e.errors,r,te),xd=hx(No,r,Nm.name||te);Ge=xd.error,te=xd.name,Qt=kn(No)}}else v([te],!0),Ge=(await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation))[te],v([te]),le(xr),he&&(Ge?Qt=!1:(l.isValid||d.isValid)&&(Qt=await N(r,!0)));he&&(pe._f.deps&&(!Array.isArray(pe._f.deps)||pe._f.deps.length>0)&&O(pe._f.deps),_(te,Qt,Ge,On))}},M=(V,Y)=>{if(me(e.errors,Y)&&V.focus)return V.focus(),1},O=async(V,Y={})=>{let te,he;const pe=su(V);if(t.resolver){const le=await S(At(V)?V:pe);te=kn(le),he=V?!pe.some(ye=>me(le,ye)):te}else V?(he=(await Promise.all(pe.map(async le=>{const ye=me(r,le);return await N(ye&&ye._f?{[le]:ye}:ye)}))).every(Boolean),!(!he&&!e.isValid)&&p()):he=te=await N(r);return f.state.next({...!zn(V)||(l.isValid||d.isValid)&&te!==e.isValid?{}:{name:V},...t.resolver||!V?{isValid:te}:{},errors:e.errors}),Y.shouldFocus&&!he&&cu(r,M,V?pe:s.mount),he},I=(V,Y)=>{let te={...i.mount?a:o};return Y&&(te=ex(Y.dirtyFields?e.dirtyFields:e.touchedFields,te)),At(V)?te:zn(V)?me(te,V):V.map(he=>me(te,he))},L=(V,Y)=>({invalid:!!me((Y||e).errors,V),isDirty:!!me((Y||e).dirtyFields,V),error:me((Y||e).errors,V),isValidating:!!me(e.validatingFields,V),isTouched:!!me((Y||e).touchedFields,V)}),K=V=>{V&&su(V).forEach(Y=>Mt(e.errors,Y)),f.state.next({errors:V?e.errors:{}})},q=(V,Y,te)=>{const he=(me(r,V,{_f:{}})._f||{}).ref,pe=me(e.errors,V)||{},{ref:le,message:ye,type:We,...Ge}=pe;ct(e.errors,V,{...Ge,...Y,ref:he}),f.state.next({name:V,errors:e.errors,isValid:!1}),te&&te.shouldFocus&&he&&he.focus&&he.focus()},Z=(V,Y)=>dr(V)?f.state.subscribe({next:te=>"values"in te&&V(P(void 0,Y),te)}):P(V,Y,!0),oe=V=>f.state.subscribe({next:Y=>{i8(V.name,Y.name,V.exact)&&a8(Y,V.formState||l,Lt,V.reRenderRoot)&&V.callback({values:{...a},...e,...Y,defaultValues:o})}}).unsubscribe,ae=V=>(i.mount=!0,d={...d,...V.formState},oe({...V,formState:d})),X=(V,Y={})=>{for(const te of V?su(V):s.mount)s.mount.delete(te),s.array.delete(te),Y.keepValue||(Mt(r,te),Mt(a,te)),!Y.keepError&&Mt(e.errors,te),!Y.keepDirty&&Mt(e.dirtyFields,te),!Y.keepTouched&&Mt(e.touchedFields,te),!Y.keepIsValidating&&Mt(e.validatingFields,te),!t.shouldUnregister&&!Y.keepDefaultValue&&Mt(o,te);f.state.next({values:Gt(a)}),f.state.next({...e,...Y.keepDirty?{isDirty:A()}:{}}),!Y.keepIsValid&&p()},re=({disabled:V,name:Y})=>{(Un(V)&&i.mount||V||s.disabled.has(Y))&&(V?s.disabled.add(Y):s.disabled.delete(Y))},ce=(V,Y={})=>{let te=me(r,V);const he=Un(Y.disabled)||Un(t.disabled);return ct(r,V,{...te||{},_f:{...te&&te._f?te._f:{ref:{name:V}},name:V,mount:!0,...Y}}),s.mount.add(V),te?re({disabled:Un(Y.disabled)?Y.disabled:t.disabled,name:V}):x(V,!0,Y.value),{...he?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:uu(Y.min),max:uu(Y.max),minLength:uu(Y.minLength),maxLength:uu(Y.maxLength),pattern:uu(Y.pattern)}:{},name:V,onChange:F,onBlur:F,ref:pe=>{if(pe){ce(V,Y),te=me(r,V);const le=At(pe.value)&&pe.querySelectorAll&&pe.querySelectorAll("input,select,textarea")[0]||pe,ye=QD(le),We=te._f.refs||[];if(ye?We.find(Ge=>Ge===le):le===te._f.ref)return;ct(r,V,{_f:{...te._f,...ye?{refs:[...We.filter(Rp),le,...Array.isArray(me(o,V))?[{}]:[]],ref:{type:le.type,name:V}}:{ref:le}}}),x(V,!1,void 0,le)}else te=me(r,V,{}),te._f&&(te._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(K2(s.array,V)&&i.action)&&s.unMount.add(V)}}},ue=()=>t.shouldFocusError&&cu(r,M,s.mount),se=V=>{Un(V)&&(f.state.next({disabled:V}),cu(r,(Y,te)=>{const he=me(r,te);he&&(Y.disabled=he._f.disabled||V,Array.isArray(he._f.refs)&&he._f.refs.forEach(pe=>{pe.disabled=he._f.disabled||V}))},0,!1))},ee=(V,Y)=>async te=>{let he;te&&(te.preventDefault&&te.preventDefault(),te.persist&&te.persist());let pe=Gt(a);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:le,values:ye}=await E();e.errors=le,pe=Gt(ye)}else await N(r);if(s.disabled.size)for(const le of s.disabled)Mt(pe,le);if(Mt(e.errors,"root"),kn(e.errors)){f.state.next({errors:{}});try{await V(pe,te)}catch(le){he=le}}else Y&&await Y({...e.errors},te),ue(),setTimeout(ue);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kn(e.errors)&&!he,submitCount:e.submitCount+1,errors:e.errors}),he)throw he},_e=(V,Y={})=>{me(r,V)&&(At(Y.defaultValue)?H(V,Gt(me(o,V))):(H(V,Y.defaultValue),ct(o,V,Gt(Y.defaultValue))),Y.keepTouched||Mt(e.touchedFields,V),Y.keepDirty||(Mt(e.dirtyFields,V),e.isDirty=Y.defaultValue?A(V,Gt(me(o,V))):A()),Y.keepError||(Mt(e.errors,V),l.isValid&&p()),f.state.next({...e}))},Me=(V,Y={})=>{const te=V?Gt(V):o,he=Gt(te),pe=kn(V),le=pe?o:he;if(Y.keepDefaultValues||(o=te),!Y.keepValues){if(Y.keepDirtyValues){const ye=new Set([...s.mount,...Object.keys(Vi(o,a))]);for(const We of Array.from(ye))me(e.dirtyFields,We)?ct(le,We,me(a,We)):H(We,me(le,We))}else{if(Pp&&At(V))for(const ye of s.mount){const We=me(r,ye);if(We&&We._f){const Ge=Array.isArray(We._f.refs)?We._f.refs[0]:We._f.ref;if(Ol(Ge)){const Qt=Ge.closest("form");if(Qt){Qt.reset();break}}}}if(Y.keepFieldsRef)for(const ye of s.mount)H(ye,me(le,ye));else r={}}a=t.shouldUnregister?Y.keepDefaultValues?Gt(o):{}:Gt(le),f.array.next({values:{...le}}),f.state.next({values:{...le}})}s={mount:Y.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!l.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues,i.watch=!!t.shouldUnregister,f.state.next({submitCount:Y.keepSubmitCount?e.submitCount:0,isDirty:pe?!1:Y.keepDirty?e.isDirty:!!(Y.keepDefaultValues&&!po(V,o)),isSubmitted:Y.keepIsSubmitted?e.isSubmitted:!1,dirtyFields:pe?{}:Y.keepDirtyValues?Y.keepDefaultValues&&a?Vi(o,a):e.dirtyFields:Y.keepDefaultValues&&V?Vi(o,V):Y.keepDirty?e.dirtyFields:{},touchedFields:Y.keepTouched?e.touchedFields:{},errors:Y.keepErrors?e.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?e.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},Ye=(V,Y)=>Me(dr(V)?V(a):V,Y),Ze=(V,Y={})=>{const te=me(r,V),he=te&&te._f;if(he){const pe=he.refs?he.refs[0]:he.ref;pe.focus&&(pe.focus(),Y.shouldSelect&&dr(pe.select)&&pe.select())}},Lt=V=>{e={...e,...V}},Ct={control:{register:ce,unregister:X,getFieldState:L,handleSubmit:ee,setError:q,_subscribe:oe,_runSchema:E,_focusError:ue,_getWatch:P,_getDirty:A,_setValid:p,_setFieldArray:g,_setDisabledField:re,_setErrors:w,_getFieldArray:j,_reset:Me,_resetDefaultValues:()=>dr(t.defaultValues)&&t.defaultValues().then(V=>{Ye(V,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:$,_disableForm:se,_subjects:f,_proxyFormState:l,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state(V){i=V},get _defaultValues(){return o},get _names(){return s},set _names(V){s=V},get _formState(){return e},get _options(){return t},set _options(V){t={...t,...V}}},subscribe:ae,trigger:O,register:ce,handleSubmit:ee,watch:Z,setValue:H,getValues:I,reset:Ye,resetField:_e,clearErrors:K,unregister:X,setError:q,setFocus:Ze,getFieldState:L};return{...Ct,formControl:Ct}}function lu(n={}){const t=D.useRef(void 0),e=D.useRef(void 0),[r,o]=D.useState({isDirty:!1,isValidating:!1,isLoading:dr(n.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1,isReady:!1,defaultValues:dr(n.defaultValues)?void 0:n.defaultValues});if(!t.current)if(n.formControl)t.current={...n.formControl,formState:r},n.defaultValues&&!dr(n.defaultValues)&&n.formControl.reset(n.defaultValues,n.resetOptions);else{const{formControl:i,...s}=d8(n);t.current={...s,formState:r}}const a=t.current.control;return a._options=n,Op(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>o({...a._formState}),reRenderRoot:!0});return o(s=>({...s,isReady:!0})),a._formState.isReady=!0,i},[a]),D.useEffect(()=>a._disableForm(n.disabled),[a,n.disabled]),D.useEffect(()=>{n.mode&&(a._options.mode=n.mode),n.reValidateMode&&(a._options.reValidateMode=n.reValidateMode)},[a,n.mode,n.reValidateMode]),D.useEffect(()=>{n.errors&&(a._setErrors(n.errors),a._focusError())},[a,n.errors]),D.useEffect(()=>{n.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,n.shouldUnregister]),D.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),D.useEffect(()=>{n.values&&!po(n.values,e.current)?(a._reset(n.values,{keepFieldsRef:!0,...a._options.resetOptions}),e.current=n.values,o(i=>({...i}))):a._resetDefaultValues()},[a,n.values]),D.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=Y2(r,a),t.current}const mx=(n,t,e)=>{if(n&&"reportValidity"in n){const r=me(e,t);n.setCustomValidity(r&&r.message||""),n.reportValidity()}},gx=(n,t)=>{for(const e in t.fields){const r=t.fields[e];r&&r.ref&&"reportValidity"in r.ref?mx(r.ref,e,n):r.refs&&r.refs.forEach(o=>mx(o,e,n))}},f8=(n,t)=>{t.shouldUseNativeValidation&&gx(n,t);const e={};for(const r in n){const o=me(t.fields,r),a=Object.assign(n[r]||{},{ref:o&&o.ref});if(h8(t.names||Object.keys(n),r)){const i=Object.assign({},me(e,r));ct(i,"root",a),ct(e,r,i)}else ct(e,r,a)}return e},h8=(n,t)=>n.some(e=>e.startsWith(t+"."));var p8=function(n,t){for(var e={};n.length;){var r=n[0],o=r.code,a=r.message,i=r.path.join(".");if(!e[i])if("unionErrors"in r){var s=r.unionErrors[0].errors[0];e[i]={message:s.message,type:s.code}}else e[i]={message:a,type:o};if("unionErrors"in r&&r.unionErrors.forEach(function(l){return l.errors.forEach(function(d){return n.push(d)})}),t){var u=e[i].types,c=u&&u[r.code];e[i]=Q2(i,t,e,o,c?[].concat(c,r.message):r.message)}n.shift()}return e},du=function(n,t,e){return e===void 0&&(e={}),function(r,o,a){try{return Promise.resolve(function(i,s){try{var u=Promise.resolve(n[e.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(c){return a.shouldUseNativeValidation&&gx({},a),{errors:{},values:e.raw?r:c}})}catch(c){return s(c)}return u&&u.then?u.then(void 0,s):u}(0,function(i){if(function(s){return Array.isArray(s==null?void 0:s.errors)}(i))return{values:{},errors:f8(p8(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},rt;(function(n){n.assertEqual=o=>{};function t(o){}n.assertIs=t;function e(o){throw new Error}n.assertNever=e,n.arrayToEnum=o=>{const a={};for(const i of o)a[i]=i;return a},n.getValidEnumValues=o=>{const a=n.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(const s of a)i[s]=o[s];return n.objectValues(i)},n.objectValues=o=>n.objectKeys(o).map(function(a){return o[a]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const a=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},n.find=(o,a)=>{for(const i of o)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(rt||(rt={}));var yx;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(yx||(yx={}));const Ee=rt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ko=n=>{switch(typeof n){case"undefined":return Ee.undefined;case"string":return Ee.string;case"number":return Number.isNaN(n)?Ee.nan:Ee.number;case"boolean":return Ee.boolean;case"function":return Ee.function;case"bigint":return Ee.bigint;case"symbol":return Ee.symbol;case"object":return Array.isArray(n)?Ee.array:n===null?Ee.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ee.promise:typeof Map<"u"&&n instanceof Map?Ee.map:typeof Set<"u"&&n instanceof Set?Ee.set:typeof Date<"u"&&n instanceof Date?Ee.date:Ee.object;default:return Ee.unknown}},fe=rt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class vo extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(a){return a.message},r={_errors:[]},o=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(e(i));else{let s=r,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(e(i))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return o(this),r}static assert(t){if(!(t instanceof vo))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,rt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const o of this.issues)if(o.path.length>0){const a=o.path[0];e[a]=e[a]||[],e[a].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}vo.create=n=>new vo(n);const Bp=(n,t)=>{let e;switch(n.code){case fe.invalid_type:n.received===Ee.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case fe.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,rt.jsonStringifyReplacer)}`;break;case fe.unrecognized_keys:e=`Unrecognized key(s) in object: ${rt.joinValues(n.keys,", ")}`;break;case fe.invalid_union:e="Invalid input";break;case fe.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${rt.joinValues(n.options)}`;break;case fe.invalid_enum_value:e=`Invalid enum value. Expected ${rt.joinValues(n.options)}, received '${n.received}'`;break;case fe.invalid_arguments:e="Invalid function arguments";break;case fe.invalid_return_type:e="Invalid function return type";break;case fe.invalid_date:e="Invalid date";break;case fe.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:rt.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case fe.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case fe.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case fe.custom:e="Invalid input";break;case fe.invalid_intersection_types:e="Intersection results could not be merged";break;case fe.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case fe.not_finite:e="Number must be finite";break;default:e=t.defaultError,rt.assertNever(n)}return{message:e}};let v8=Bp;function m8(){return v8}const g8=n=>{const{data:t,path:e,errorMaps:r,issueData:o}=n,a=[...e,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="";const u=r.filter(c=>!!c).slice().reverse();for(const c of u)s=c(i,{data:t,defaultError:s}).message;return{...o,path:a,message:s}};function be(n,t){const e=m8(),r=g8({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Bp?void 0:Bp].filter(o=>!!o)});n.common.issues.push(r)}class Hn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const o of e){if(o.status==="aborted")return Re;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const o of e){const a=await o.key,i=await o.value;r.push({key:a,value:i})}return Hn.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const o of e){const{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return Re;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[a.value]=i.value)}return{status:t.value,value:r}}}const Re=Object.freeze({status:"aborted"}),fu=n=>({status:"dirty",value:n}),Qn=n=>({status:"valid",value:n}),bx=n=>n.status==="aborted",xx=n=>n.status==="dirty",Ui=n=>n.status==="valid",Ml=n=>typeof Promise<"u"&&n instanceof Promise;var Pe;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Pe||(Pe={}));class Yo{constructor(t,e,r,o){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const wx=(n,t)=>{if(Ui(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new vo(n.common.issues);return this._error=e,this._error}}};function Ke(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:o}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(i,s)=>{const{message:u}=n;return i.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??r??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:u??e??s.defaultError}},description:o}}class tt{get description(){return this._def.description}_getType(t){return Ko(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Hn,ctx:{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Ml(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){const r={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parseSync({data:t,path:r.path,parent:r});return wx(r,o)}"~validate"(t){var r,o;const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:e});return Ui(a)?{value:a.value}:{issues:e.common.issues}}catch(a){(o=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(a=>Ui(a)?{value:a.value}:{issues:e.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parse({data:t,path:r.path,parent:r}),a=await(Ml(o)?o:Promise.resolve(o));return wx(r,a)}refine(t,e){const r=o=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(o):e;return this._refinement((o,a)=>{const i=t(o),s=()=>a.addIssue({code:fe.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,e){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof e=="function"?e(r,o):e),!1))}_refinement(t){return new Gi({schema:this,typeName:Le.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Qo.create(this,this._def)}nullable(){return qi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hr.create(this)}promise(){return Ll.create(this,this._def)}or(t){return Fl.create([this,t],this._def)}and(t){return Rl.create(this,t,this._def)}transform(t){return new Gi({...Ke(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Up({...Ke(this._def),innerType:this,defaultValue:e,typeName:Le.ZodDefault})}brand(){return new W8({typeName:Le.ZodBranded,type:this,...Ke(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new zp({...Ke(this._def),innerType:this,catchValue:e,typeName:Le.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Hp.create(this,t)}readonly(){return Gp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const y8=/^c[^\s-]{8,}$/i,b8=/^[0-9a-z]+$/,x8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,w8=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C8=/^[a-z0-9_-]{21}$/i,_8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E8=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,S8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wp;const $8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,k8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,P8=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,I8=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cx="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",O8=new RegExp(`^${Cx}$`);function _x(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);const e=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function D8(n){return new RegExp(`^${_x(n)}$`)}function M8(n){let t=`${Cx}T${_x(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function F8(n,t){return!!((t==="v4"||!t)&&$8.test(n)||(t==="v6"||!t)&&P8.test(n))}function R8(n,t){if(!_8.test(n))return!1;try{const[e]=n.split(".");if(!e)return!1;const r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function L8(n,t){return!!((t==="v4"||!t)&&k8.test(n)||(t==="v6"||!t)&&I8.test(n))}class Xo extends tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Ee.string){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.string,received:a.parsedType}),Re}const r=new Hn;let o;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(t,o),i?be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")S8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"email",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Wp||(Wp=new RegExp(N8,"u")),Wp.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"emoji",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")w8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"uuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")C8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"nanoid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")y8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")b8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid2",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")x8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ulid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),be(o,{validation:"url",code:fe.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"regex",code:fe.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?M8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?O8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?D8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?E8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"duration",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?F8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ip",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?R8(t.data,a.alg)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"jwt",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?L8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cidr",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?A8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?T8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64url",code:fe.invalid_string,message:a.message}),r.dirty()):rt.assertNever(a);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(o=>t.test(o),{validation:e,code:fe.invalid_string,...Pe.errToObj(r)})}_addCheck(t){return new Xo({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Pe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Pe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Pe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Pe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Pe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Pe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Pe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Pe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Pe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Pe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Pe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Pe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Pe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Pe.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Pe.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Pe.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Pe.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Pe.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Pe.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Pe.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Pe.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Pe.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Pe.errToObj(e)})}nonempty(t){return this.min(1,Pe.errToObj(t))}trim(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Xo.create=n=>new Xo({checks:[],typeName:Le.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});function B8(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=e>r?e:r,a=Number.parseInt(n.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return a%i/10**o}class hu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Ee.number){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.number,received:a.parsedType}),Re}let r;const o=new Hn;for(const a of this._def.checks)a.kind==="int"?rt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?B8(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_finite,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new hu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new hu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Pe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Pe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pe.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&rt.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}hu.create=n=>new hu({checks:[],typeName:Le.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class pu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Ee.bigint)return this._getInvalidInput(t);let r;const o=new Hn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.bigint,received:e.parsedType}),Re}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new pu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new pu({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}pu.create=n=>new pu({checks:[],typeName:Le.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});class Ex extends tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Ee.boolean){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.boolean,received:r.parsedType}),Re}return Qn(t.data)}}Ex.create=n=>new Ex({typeName:Le.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class vu extends tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Ee.date){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.date,received:a.parsedType}),Re}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_date}),Re}const r=new Hn;let o;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):rt.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new vu({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Pe.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Pe.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}vu.create=n=>new vu({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Le.ZodDate,...Ke(n)});class Sx extends tt{_parse(t){if(this._getType(t)!==Ee.symbol){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.symbol,received:r.parsedType}),Re}return Qn(t.data)}}Sx.create=n=>new Sx({typeName:Le.ZodSymbol,...Ke(n)});class Nx extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.undefined,received:r.parsedType}),Re}return Qn(t.data)}}Nx.create=n=>new Nx({typeName:Le.ZodUndefined,...Ke(n)});class $x extends tt{_parse(t){if(this._getType(t)!==Ee.null){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.null,received:r.parsedType}),Re}return Qn(t.data)}}$x.create=n=>new $x({typeName:Le.ZodNull,...Ke(n)});class mu extends tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Qn(t.data)}}mu.create=n=>new mu({typeName:Le.ZodAny,...Ke(n)});class kx extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qn(t.data)}}kx.create=n=>new kx({typeName:Le.ZodUnknown,...Ke(n)});class Zo extends tt{_parse(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.never,received:e.parsedType}),Re}}Zo.create=n=>new Zo({typeName:Le.ZodNever,...Ke(n)});class Px extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.void,received:r.parsedType}),Re}return Qn(t.data)}}Px.create=n=>new Px({typeName:Le.ZodVoid,...Ke(n)});class Hr extends tt{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),o=this._def;if(e.parsedType!==Ee.array)return be(e,{code:fe.invalid_type,expected:Ee.array,received:e.parsedType}),Re;if(o.exactLength!==null){const i=e.data.length>o.exactLength.value,s=e.data.length<o.exactLength.value;(i||s)&&(be(e,{code:i?fe.too_big:fe.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&e.data.length<o.minLength.value&&(be(e,{code:fe.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&e.data.length>o.maxLength.value&&(be(e,{code:fe.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((i,s)=>o.type._parseAsync(new Yo(e,i,e.path,s)))).then(i=>Hn.mergeArray(r,i));const a=[...e.data].map((i,s)=>o.type._parseSync(new Yo(e,i,e.path,s)));return Hn.mergeArray(r,a)}get element(){return this._def.type}min(t,e){return new Hr({...this._def,minLength:{value:t,message:Pe.toString(e)}})}max(t,e){return new Hr({...this._def,maxLength:{value:t,message:Pe.toString(e)}})}length(t,e){return new Hr({...this._def,exactLength:{value:t,message:Pe.toString(e)}})}nonempty(t){return this.min(1,t)}}Hr.create=(n,t)=>new Hr({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...Ke(t)});function zi(n){if(n instanceof Ft){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Qo.create(zi(r))}return new Ft({...n._def,shape:()=>t})}else return n instanceof Hr?new Hr({...n._def,type:zi(n.element)}):n instanceof Qo?Qo.create(zi(n.unwrap())):n instanceof qi?qi.create(zi(n.unwrap())):n instanceof ja?ja.create(n.items.map(t=>zi(t))):n}class Ft extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=rt.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==Ee.object){const c=this._getOrReturnCtx(t);return be(c,{code:fe.invalid_type,expected:Ee.object,received:c.parsedType}),Re}const{status:r,ctx:o}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Zo&&this._def.unknownKeys==="strip"))for(const c in o.data)i.includes(c)||s.push(c);const u=[];for(const c of i){const l=a[c],d=o.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Yo(o,d,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Zo){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of s)u.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(c==="strict")s.length>0&&(be(o,{code:fe.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of s){const d=o.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Yo(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of u){const d=await l.key,f=await l.value;c.push({key:d,value:f,alwaysSet:l.alwaysSet})}return c}).then(c=>Hn.mergeObjectSync(r,c)):Hn.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Pe.errToObj,new Ft({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var a,i;const o=((i=(a=this._def).errorMap)==null?void 0:i.call(a,e,r).message)??r.defaultError;return e.code==="unrecognized_keys"?{message:Pe.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new Ft({...this._def,unknownKeys:"strip"})}passthrough(){return new Ft({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ft({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ft({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Le.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new Ft({...this._def,catchall:t})}pick(t){const e={};for(const r of rt.objectKeys(t))t[r]&&this.shape[r]&&(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}omit(t){const e={};for(const r of rt.objectKeys(this.shape))t[r]||(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}deepPartial(){return zi(this)}partial(t){const e={};for(const r of rt.objectKeys(this.shape)){const o=this.shape[r];t&&!t[r]?e[r]=o:e[r]=o.optional()}return new Ft({...this._def,shape:()=>e})}required(t){const e={};for(const r of rt.objectKeys(this.shape))if(t&&!t[r])e[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Qo;)a=a._def.innerType;e[r]=a}return new Ft({...this._def,shape:()=>e})}keyof(){return Tx(rt.objectKeys(this.shape))}}Ft.create=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.strictCreate=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strict",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.lazycreate=(n,t)=>new Ft({shape:n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)});class Fl extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function o(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new vo(s.ctx.common.issues));return be(e,{code:fe.invalid_union,unionErrors:i}),Re}if(e.common.async)return Promise.all(r.map(async a=>{const i={...e,common:{...e.common,issues:[]},parent:null};return{result:await a._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(o);{let a;const i=[];for(const u of r){const c={...e,common:{...e.common,issues:[]},parent:null},l=u._parseSync({data:e.data,path:e.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return e.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(u=>new vo(u));return be(e,{code:fe.invalid_union,unionErrors:s}),Re}}get options(){return this._def.options}}Fl.create=(n,t)=>new Fl({options:n,typeName:Le.ZodUnion,...Ke(t)});function Vp(n,t){const e=Ko(n),r=Ko(t);if(n===t)return{valid:!0,data:n};if(e===Ee.object&&r===Ee.object){const o=rt.objectKeys(t),a=rt.objectKeys(n).filter(s=>o.indexOf(s)!==-1),i={...n,...t};for(const s of a){const u=Vp(n[s],t[s]);if(!u.valid)return{valid:!1};i[s]=u.data}return{valid:!0,data:i}}else if(e===Ee.array&&r===Ee.array){if(n.length!==t.length)return{valid:!1};const o=[];for(let a=0;a<n.length;a++){const i=n[a],s=t[a],u=Vp(i,s);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return e===Ee.date&&r===Ee.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class Rl extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=(a,i)=>{if(bx(a)||bx(i))return Re;const s=Vp(a.value,i.value);return s.valid?((xx(a)||xx(i))&&e.dirty(),{status:e.value,value:s.data}):(be(r,{code:fe.invalid_intersection_types}),Re)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Rl.create=(n,t,e)=>new Rl({left:n,right:t,typeName:Le.ZodIntersection,...Ke(e)});class ja extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.array)return be(r,{code:fe.invalid_type,expected:Ee.array,received:r.parsedType}),Re;if(r.data.length<this._def.items.length)return be(r,{code:fe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Re;!this._def.rest&&r.data.length>this._def.items.length&&(be(r,{code:fe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const a=[...r.data].map((i,s)=>{const u=this._def.items[s]||this._def.rest;return u?u._parse(new Yo(r,i,r.path,s)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>Hn.mergeArray(e,i)):Hn.mergeArray(e,a)}get items(){return this._def.items}rest(t){return new ja({...this._def,rest:t})}}ja.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ja({items:n,typeName:Le.ZodTuple,rest:null,...Ke(t)})};class Ix extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.map)return be(r,{code:fe.invalid_type,expected:Ee.map,received:r.parsedType}),Re;const o=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([s,u],c)=>({key:o._parse(new Yo(r,s,r.path,[c,"key"])),value:a._parse(new Yo(r,u,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}})}else{const s=new Map;for(const u of i){const c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}}}}Ix.create=(n,t,e)=>new Ix({valueType:t,keyType:n,typeName:Le.ZodMap,...Ke(e)});class gu extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.set)return be(r,{code:fe.invalid_type,expected:Ee.set,received:r.parsedType}),Re;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(be(r,{code:fe.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),e.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(be(r,{code:fe.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),e.dirty());const a=this._def.valueType;function i(u){const c=new Set;for(const l of u){if(l.status==="aborted")return Re;l.status==="dirty"&&e.dirty(),c.add(l.value)}return{status:e.value,value:c}}const s=[...r.data.values()].map((u,c)=>a._parse(new Yo(r,u,r.path,c)));return r.common.async?Promise.all(s).then(u=>i(u)):i(s)}min(t,e){return new gu({...this._def,minSize:{value:t,message:Pe.toString(e)}})}max(t,e){return new gu({...this._def,maxSize:{value:t,message:Pe.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}gu.create=(n,t)=>new gu({valueType:n,minSize:null,maxSize:null,typeName:Le.ZodSet,...Ke(t)});class Ax extends tt{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Ax.create=(n,t)=>new Ax({getter:n,typeName:Le.ZodLazy,...Ke(t)});class jp extends tt{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return be(e,{received:e.data,code:fe.invalid_literal,expected:this._def.value}),Re}return{status:"valid",value:t.data}}get value(){return this._def.value}}jp.create=(n,t)=>new jp({value:n,typeName:Le.ZodLiteral,...Ke(t)});function Tx(n,t){return new Hi({values:n,typeName:Le.ZodEnum,...Ke(t)})}class Hi extends tt{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{expected:rt.joinValues(r),received:e.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{received:e.data,code:fe.invalid_enum_value,options:r}),Re}return Qn(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Hi.create(t,{...this._def,...e})}exclude(t,e=this._def){return Hi.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Hi.create=Tx;class Ox extends tt{_parse(t){const e=rt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Ee.string&&r.parsedType!==Ee.number){const o=rt.objectValues(e);return be(r,{expected:rt.joinValues(o),received:r.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(rt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const o=rt.objectValues(e);return be(r,{received:r.data,code:fe.invalid_enum_value,options:o}),Re}return Qn(t.data)}get enum(){return this._def.values}}Ox.create=(n,t)=>new Ox({values:n,typeName:Le.ZodNativeEnum,...Ke(t)});class Ll extends tt{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Ee.promise&&e.common.async===!1)return be(e,{code:fe.invalid_type,expected:Ee.promise,received:e.parsedType}),Re;const r=e.parsedType===Ee.promise?e.data:Promise.resolve(e.data);return Qn(r.then(o=>this._def.type.parseAsync(o,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Ll.create=(n,t)=>new Ll({type:n,typeName:Le.ZodPromise,...Ke(t)});class Gi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=this._def.effect||null,a={addIssue:i=>{be(r,i),i.fatal?e.abort():e.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){const i=o.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async s=>{if(e.value==="aborted")return Re;const u=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return u.status==="aborted"?Re:u.status==="dirty"||e.value==="dirty"?fu(u.value):u});{if(e.value==="aborted")return Re;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?Re:s.status==="dirty"||e.value==="dirty"?fu(s.value):s}}if(o.type==="refinement"){const i=s=>{const u=o.refinement(s,a);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value).then(()=>({status:e.value,value:s.value}))))}if(o.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ui(i))return Re;const s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ui(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:e.value,value:s})):Re);rt.assertNever(o)}}Gi.create=(n,t,e)=>new Gi({schema:n,typeName:Le.ZodEffects,effect:t,...Ke(e)}),Gi.createWithPreprocess=(n,t,e)=>new Gi({schema:t,effect:{type:"preprocess",transform:n},typeName:Le.ZodEffects,...Ke(e)});class Qo extends tt{_parse(t){return this._getType(t)===Ee.undefined?Qn(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Qo.create=(n,t)=>new Qo({innerType:n,typeName:Le.ZodOptional,...Ke(t)});class qi extends tt{_parse(t){return this._getType(t)===Ee.null?Qn(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qi.create=(n,t)=>new qi({innerType:n,typeName:Le.ZodNullable,...Ke(t)});class Up extends tt{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===Ee.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Up.create=(n,t)=>new Up({innerType:n,typeName:Le.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});class zp extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ml(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}zp.create=(n,t)=>new zp({innerType:n,typeName:Le.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});class Dx extends tt{_parse(t){if(this._getType(t)!==Ee.nan){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.nan,received:r.parsedType}),Re}return{status:"valid",value:t.data}}}Dx.create=n=>new Dx({typeName:Le.ZodNaN,...Ke(n)});class W8 extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class Hp extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Re:a.status==="dirty"?(e.dirty(),fu(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Re:o.status==="dirty"?(e.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,e){return new Hp({in:t,out:e,typeName:Le.ZodPipeline})}}class Gp extends tt{_parse(t){const e=this._def.innerType._parse(t),r=o=>(Ui(o)&&(o.value=Object.freeze(o.value)),o);return Ml(e)?e.then(o=>r(o)):r(e)}unwrap(){return this._def.innerType}}Gp.create=(n,t)=>new Gp({innerType:n,typeName:Le.ZodReadonly,...Ke(t)});function Mx(n,t){const e=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof e=="string"?{message:e}:e}function V8(n,t={},e){return n?mu.create().superRefine((r,o)=>{const a=n(r);if(a instanceof Promise)return a.then(i=>{if(!i){const s=Mx(t,r),u=s.fatal??e??!0;o.addIssue({code:"custom",...s,fatal:u})}});if(!a){const i=Mx(t,r),s=i.fatal??e??!0;o.addIssue({code:"custom",...i,fatal:s})}}):mu.create()}var Le;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Le||(Le={}));const qp=(n,t={message:`Input not instance of ${n.name}`})=>V8(e=>e instanceof n,t),Xt=Xo.create,Fx=vu.create;mu.create,Zo.create,Hr.create;const yu=Ft.create;Fl.create,Rl.create,ja.create;const j8=jp.create;Hi.create,Ll.create,Qo.create,qi.create;const bu=KD,Rx=k.createContext({}),Tt=({...n})=>b.jsx(Rx.Provider,{value:{name:n.name},children:b.jsx(ZD,{...n})}),Bl=()=>{const n=k.useContext(Rx),t=k.useContext(Lx),{getFieldState:e,formState:r}=Tl(),o=e(n.name,r);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:n.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...o}},Lx=k.createContext({}),St=k.forwardRef(({className:n,...t},e)=>{const r=k.useId();return b.jsx(Lx.Provider,{value:{id:r},children:b.jsx("div",{ref:e,className:Be("space-y-2",n),...t})})});St.displayName="FormItem";const Nt=k.forwardRef(({className:n,...t},e)=>{const{error:r,formItemId:o}=Bl();return b.jsx(Ea,{ref:e,className:Be(r&&"text-destructive",n),htmlFor:o,...t})});Nt.displayName="FormLabel";const $t=k.forwardRef(({...n},t)=>{const{error:e,formItemId:r,formDescriptionId:o,formMessageId:a}=Bl();return b.jsx(Vm,{ref:t,id:r,"aria-describedby":e?`${o} ${a}`:`${o}`,"aria-invalid":!!e,...n})});$t.displayName="FormControl";const U8=k.forwardRef(({className:n,...t},e)=>{const{formDescriptionId:r}=Bl();return b.jsx("p",{ref:e,id:r,className:Be("text-sm text-muted-foreground",n),...t})});U8.displayName="FormDescription";const kt=k.forwardRef(({className:n,children:t,...e},r)=>{const{error:o,formMessageId:a}=Bl(),i=o?String(o==null?void 0:o.message):t;return i?b.jsx("p",{ref:r,id:a,className:Be("text-sm font-medium text-destructive",n),...e,children:i}):null});kt.displayName="FormMessage";const z8=yu({bank_statement:qp(File).optional().refine(n=>n!==void 0,"Bank statement is required"),company_structure:qp(File).optional().refine(n=>n!==void 0,"Company structure document is required"),certificate_of_registration:qp(File).optional().refine(n=>n!==void 0,"Certificate of registration is required")}),H8=({data:n,onDataChange:t,onContinue:e,onBack:r,renderProgress:o})=>{const a=D.useRef(null),i=D.useRef(null),s=D.useRef(null),u=lu({resolver:du(z8),defaultValues:{bank_statement:n.bank_statement||void 0,company_structure:n.company_structure||void 0,certificate_of_registration:n.certificate_of_registration||void 0}}),c=f=>{t(f),e()},l=(f,h)=>{u.setValue(f,h),t({[f]:h})},d=({field:f,label:h,description:m,inputRef:p})=>{const v=u.watch(f);return b.jsx(Tt,{control:u.control,name:f,render:()=>b.jsxs(St,{children:[b.jsx(Nt,{children:h}),b.jsx($t,{children:b.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-6",children:[b.jsx("input",{ref:p,type:"file",accept:".pdf,.jpg,.jpeg,.png,.doc,.docx",className:"hidden",onChange:g=>{var w;const y=((w=g.target.files)==null?void 0:w[0])||null;l(f,y)}}),v?b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(nE,{className:"w-5 h-5 text-primary"}),b.jsx("span",{className:"text-sm font-medium",children:v.name})]}),b.jsx(_t,{type:"button",variant:"ghost",size:"sm",onClick:()=>{l(f,null),p.current&&(p.current.value="")},children:b.jsx(Md,{className:"w-4 h-4"})})]}):b.jsxs("div",{className:"text-center cursor-pointer",onClick:()=>{var g;return(g=p.current)==null?void 0:g.click()},children:[b.jsx(oE,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground"}),b.jsx("p",{className:"font-medium",children:h}),b.jsx("p",{className:"text-sm text-muted-foreground",children:m}),b.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Supported: PDF, JPG, PNG, DOC, DOCX"})]})]})}),b.jsx(kt,{})]})})};return b.jsxs(hn,{className:"w-full max-w-2xl mx-auto",children:[b.jsx(Oo,{children:b.jsx(Do,{title:"Company Documents",subTitle:"Please upload the required company documents",onBack:r})}),b.jsxs(pn,{children:[b.jsx(bu,{...u,children:b.jsxs("form",{onSubmit:u.handleSubmit(c),className:"space-y-6",children:[b.jsx(d,{field:"bank_statement",label:"Bank Statement",description:"Upload your latest bank statement",inputRef:a}),b.jsx(d,{field:"company_structure",label:"Company Structure",description:"Upload document showing directors & legal representatives",inputRef:i}),b.jsx(d,{field:"certificate_of_registration",label:"Certificate of Registration",description:"Upload your company's certificate of registration",inputRef:s}),b.jsx(_t,{type:"submit",className:"w-full",children:"Complete Verification"})]})}),b.jsx("div",{className:"mt-6",children:o()})]})]})};function Bx(n,[t,e]){return Math.min(e,Math.max(t,n))}var G8=k.createContext(void 0);function q8(n){const t=k.useContext(G8);return n||t||"ltr"}var Kp=0;function Wx(){k.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??Vx()),document.body.insertAdjacentElement("beforeend",n[1]??Vx()),Kp++,()=>{Kp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Kp--}},[])}function Vx(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var Yp="focusScope.autoFocusOnMount",Xp="focusScope.autoFocusOnUnmount",jx={bubbles:!1,cancelable:!0},K8="FocusScope",Zp=k.forwardRef((n,t)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=n,[s,u]=k.useState(null),c=tr(o),l=tr(a),d=k.useRef(null),f=mt(t,p=>u(p)),h=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let p=function(w){if(h.paused||!s)return;const x=w.target;s.contains(x)?d.current=x:Jo(d.current,{select:!0})},v=function(w){if(h.paused||!s)return;const x=w.relatedTarget;x!==null&&(s.contains(x)||Jo(d.current,{select:!0}))},g=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Jo(s)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(g);return s&&y.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[r,s,h.paused]),k.useEffect(()=>{if(s){Hx.add(h);const p=document.activeElement;if(!s.contains(p)){const g=new CustomEvent(Yp,jx);s.addEventListener(Yp,c),s.dispatchEvent(g),g.defaultPrevented||(Y8(eM(Ux(s)),{select:!0}),document.activeElement===p&&Jo(s))}return()=>{s.removeEventListener(Yp,c),setTimeout(()=>{const g=new CustomEvent(Xp,jx);s.addEventListener(Xp,l),s.dispatchEvent(g),g.defaultPrevented||Jo(p??document.body,{select:!0}),s.removeEventListener(Xp,l),Hx.remove(h)},0)}}},[s,c,l,h]);const m=k.useCallback(p=>{if(!e&&!r||h.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,g=document.activeElement;if(v&&g){const y=p.currentTarget,[w,x]=X8(y);w&&x?!p.shiftKey&&g===x?(p.preventDefault(),e&&Jo(w,{select:!0})):p.shiftKey&&g===w&&(p.preventDefault(),e&&Jo(x,{select:!0})):g===y&&p.preventDefault()}},[e,r,h.paused]);return b.jsx(et.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Zp.displayName=K8;function Y8(n,{select:t=!1}={}){const e=document.activeElement;for(const r of n)if(Jo(r,{select:t}),document.activeElement!==e)return}function X8(n){const t=Ux(n),e=zx(t,n),r=zx(t.reverse(),n);return[e,r]}function Ux(n){const t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)t.push(e.currentNode);return t}function zx(n,t){for(const e of n)if(!Z8(e,{upTo:t}))return e}function Z8(n,{upTo:t}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(t!==void 0&&n===t)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function Q8(n){return n instanceof HTMLInputElement&&"select"in n}function Jo(n,{select:t=!1}={}){if(n&&n.focus){const e=document.activeElement;n.focus({preventScroll:!0}),n!==e&&Q8(n)&&t&&n.select()}}var Hx=J8();function J8(){let n=[];return{add(t){const e=n[0];t!==e&&(e==null||e.pause()),n=Gx(n,t),n.unshift(t)},remove(t){var e;n=Gx(n,t),(e=n[0])==null||e.resume()}}}function Gx(n,t){const e=[...n],r=e.indexOf(t);return r!==-1&&e.splice(r,1),e}function eM(n){return n.filter(t=>t.tagName!=="A")}function tM(n){const t=k.useRef({value:n,previous:n});return k.useMemo(()=>(t.current.value!==n&&(t.current.previous=t.current.value,t.current.value=n),t.current.previous),[n])}var nM=function(n){if(typeof document>"u")return null;var t=Array.isArray(n)?n[0]:n;return t.ownerDocument.body},Ki=new WeakMap,Wl=new WeakMap,Vl={},Qp=0,qx=function(n){return n&&(n.host||qx(n.parentNode))},rM=function(n,t){return t.map(function(e){if(n.contains(e))return e;var r=qx(e);return r&&n.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",n,". Doing nothing"),null)}).filter(function(e){return!!e})},oM=function(n,t,e,r){var o=rM(t,Array.isArray(n)?n:[n]);Vl[e]||(Vl[e]=new WeakMap);var a=Vl[e],i=[],s=new Set,u=new Set(o),c=function(d){!d||s.has(d)||(s.add(d),c(d.parentNode))};o.forEach(c);var l=function(d){!d||u.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))l(f);else try{var h=f.getAttribute(r),m=h!==null&&h!=="false",p=(Ki.get(f)||0)+1,v=(a.get(f)||0)+1;Ki.set(f,p),a.set(f,v),i.push(f),p===1&&m&&Wl.set(f,!0),v===1&&f.setAttribute(e,"true"),m||f.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",f,g)}})};return l(t),s.clear(),Qp++,function(){i.forEach(function(d){var f=Ki.get(d)-1,h=a.get(d)-1;Ki.set(d,f),a.set(d,h),f||(Wl.has(d)||d.removeAttribute(r),Wl.delete(d)),h||d.removeAttribute(e)}),Qp--,Qp||(Ki=new WeakMap,Ki=new WeakMap,Wl=new WeakMap,Vl={})}},Kx=function(n,t,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),o=nM(n);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),oM(r,o,e,"aria-hidden")):function(){return null}},Gr=function(){return Gr=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},Gr.apply(this,arguments)};function Yx(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(e[r[o]]=n[r[o]]);return e}function aM(n,t,e){if(e||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return n.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var jl="right-scroll-bar-position",Ul="width-before-scroll-bar",iM="with-scroll-bars-hidden",sM="--removed-body-scroll-bar-size";function Jp(n,t){return typeof n=="function"?n(t):n&&(n.current=t),n}function uM(n,t){var e=D.useState(function(){return{value:n,callback:t,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=t,e.facade}var cM=typeof window<"u"?k.useLayoutEffect:k.useEffect,Xx=new WeakMap;function lM(n,t){var e=uM(null,function(r){return n.forEach(function(o){return Jp(o,r)})});return cM(function(){var r=Xx.get(e);if(r){var o=new Set(r),a=new Set(n),i=e.current;o.forEach(function(s){a.has(s)||Jp(s,null)}),a.forEach(function(s){o.has(s)||Jp(s,i)})}Xx.set(e,n)},[n]),e}function dM(n){return n}function fM(n,t){t===void 0&&(t=dM);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:n},useMedium:function(a){var i=t(a,r);return e.push(i),function(){e=e.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;e.length;){var i=e;e=[],i.forEach(a)}e={push:function(s){return a(s)},filter:function(){return e}}},assignMedium:function(a){r=!0;var i=[];if(e.length){var s=e;e=[],s.forEach(a),i=e}var u=function(){var l=i;i=[],l.forEach(a)},c=function(){return Promise.resolve().then(u)};c(),e={push:function(l){i.push(l),c()},filter:function(l){return i=i.filter(l),e}}}};return o}function hM(n){n===void 0&&(n={});var t=fM(null);return t.options=Gr({async:!0,ssr:!1},n),t}var Zx=function(n){var t=n.sideCar,e=Yx(n,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return k.createElement(r,Gr({},e))};Zx.isSideCarExport=!0;function pM(n,t){return n.useMedium(t),Zx}var Qx=hM(),ev=function(){},zl=k.forwardRef(function(n,t){var e=k.useRef(null),r=k.useState({onScrollCapture:ev,onWheelCapture:ev,onTouchMoveCapture:ev}),o=r[0],a=r[1],i=n.forwardProps,s=n.children,u=n.className,c=n.removeScrollBar,l=n.enabled,d=n.shards,f=n.sideCar,h=n.noRelative,m=n.noIsolation,p=n.inert,v=n.allowPinchZoom,g=n.as,y=g===void 0?"div":g,w=n.gapMode,x=Yx(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=lM([e,t]),E=Gr(Gr({},x),o);return k.createElement(k.Fragment,null,l&&k.createElement(C,{sideCar:Qx,removeScrollBar:c,shards:d,noRelative:h,noIsolation:m,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:e,gapMode:w}),i?k.cloneElement(k.Children.only(s),Gr(Gr({},E),{ref:_})):k.createElement(y,Gr({},E,{className:u,ref:_}),s))});zl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zl.classNames={fullWidth:Ul,zeroRight:jl};var vM=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mM(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var t=vM();return t&&n.setAttribute("nonce",t),n}function gM(n,t){n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}function yM(n){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(n)}var bM=function(){var n=0,t=null;return{add:function(e){n==0&&(t=mM())&&(gM(t,e),yM(t)),n++},remove:function(){n--,!n&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xM=function(){var n=bM();return function(t,e){k.useEffect(function(){return n.add(t),function(){n.remove()}},[t&&e])}},Jx=function(){var n=xM(),t=function(e){var r=e.styles,o=e.dynamic;return n(r,o),null};return t},wM={left:0,top:0,right:0,gap:0},tv=function(n){return parseInt(n||"",10)||0},CM=function(n){var t=window.getComputedStyle(document.body),e=t[n==="padding"?"paddingLeft":"marginLeft"],r=t[n==="padding"?"paddingTop":"marginTop"],o=t[n==="padding"?"paddingRight":"marginRight"];return[tv(e),tv(r),tv(o)]},_M=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return wM;var t=CM(n),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-e+t[2]-t[0])}},EM=Jx(),Yi="data-scroll-locked",SM=function(n,t,e,r){var o=n.left,a=n.top,i=n.right,s=n.gap;return e===void 0&&(e="margin"),`
|
|
3929
|
+
***************************************************************************** */var Wh=function(n,t){return Wh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o])},Wh(n,t)};function De(n,t){Wh(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var dn=function(){return dn=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},dn.apply(this,arguments)};function $e(n,t,e,r){function o(a){return a instanceof e?a:new e(function(i){i(a)})}return new(e||(e=Promise))(function(a,i){function s(l){try{c(r.next(l))}catch(d){i(d)}}function u(l){try{c(r.throw(l))}catch(d){i(d)}}function c(l){l.done?a(l.value):o(l.value).then(s,u)}c((r=r.apply(n,[])).next())})}function ke(n,t){var e={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,o,a,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;e;)try{if(r=1,o&&(a=c[0]&2?o.return:c[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;switch(o=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,o=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(a=e.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){e.label=c[1];break}if(c[0]===6&&e.label<a[1]){e.label=a[1],a=c;break}if(a&&e.label<a[2]){e.label=a[2],e.ops.push(c);break}a[2]&&e.ops.pop(),e.trys.pop();continue}c=t.call(n,e)}catch(l){c=[6,l],o=0}finally{r=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function eu(){for(var n=0,t=0,e=arguments.length;t<e;t++)n+=arguments[t].length;for(var r=Array(n),o=0,t=0;t<e;t++)for(var a=arguments[t],i=0,s=a.length;i<s;i++,o++)r[o]=a[i];return r}var Fi=function(){function n(t,e){if(!La(t)||!La(e))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:t,height:e}));this._width=t,this._height=e}return Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),n.prototype.reverse=function(){return new n(1/this.width,1/this.height)},n}();function fl(n,t){return n instanceof bt&&n.shape.length===t}function l5(n){return fl(n,2)}function hl(n){return fl(n,3)}function jo(n){return fl(n,4)}function d5(n){return n%1!==0}function Bb(n){return n%2===0}function f5(n,t){t===void 0&&(t=2);var e=Math.pow(10,t);return Math.floor(n*e)/e}function Wb(n){return n&&n.width&&n.height}function h5(n,t){var e=n.width,r=n.height,o=t/Math.max(r,e);return new Fi(Math.round(e*o),Math.round(r*o))}function Vh(n){return n.reduce(function(t,e){return t.add(e)},new ot(0,0)).div(new ot(n.length,n.length))}function tu(n,t,e){return Array(n).fill(0).map(function(r,o){return t+o*e})}function La(n){return!!n&&n!==1/0&&n!==-1/0&&!isNaN(n)||n===0}function Vb(n){return La(n)&&0<=n&&n<=1}var ot=function(){function n(t,e){this._x=t,this._y=e}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.prototype.sub=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.mul=function(t){return new n(this.x*t.x,this.y*t.y)},n.prototype.div=function(t){return new n(this.x/t.x,this.y/t.y)},n.prototype.abs=function(){return new n(Math.abs(this.x),Math.abs(this.y))},n.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))},n.prototype.floor=function(){return new n(Math.floor(this.x),Math.floor(this.y))},n}(),Uo=function(){function n(t,e){e===void 0&&(e=!0);var r=t||{},o=[r.left,r.top,r.right,r.bottom].every(La),a=[r.x,r.y,r.width,r.height].every(La);if(!a&&!o)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var i=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=i[0],u=i[1],c=i[2],l=i[3];n.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",e),this._x=s,this._y=u,this._width=c,this._height=l}return n.isRect=function(t){return!!t&&[t.x,t.y,t.width,t.height].every(La)},n.assertIsValidBox=function(t,e,r){if(r===void 0&&(r=!1),!n.isRect(t))throw new Error(e+" - invalid box: "+JSON.stringify(t)+", expected object with properties x, y, width, height");if(!r&&(t.width<0||t.height<0))throw new Error(e+" - width ("+t.width+") and height ("+t.height+") must be positive numbers")},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"area",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topLeft",{get:function(){return new ot(this.left,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"topRight",{get:function(){return new ot(this.right,this.top)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomLeft",{get:function(){return new ot(this.left,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottomRight",{get:function(){return new ot(this.right,this.bottom)},enumerable:!0,configurable:!0}),n.prototype.round=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.round(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.floor=function(){var t=[this.x,this.y,this.width,this.height].map(function(i){return Math.floor(i)}),e=t[0],r=t[1],o=t[2],a=t[3];return new n({x:e,y:r,width:o,height:a})},n.prototype.toSquare=function(){var t=this,e=t.x,r=t.y,o=t.width,a=t.height,i=Math.abs(o-a);return o<a&&(e-=i/2,o+=i),a<o&&(r-=i/2,a+=i),new n({x:e,y:r,width:o,height:a})},n.prototype.rescale=function(t){var e=Wb(t)?t.width:t,r=Wb(t)?t.height:t;return new n({x:this.x*e,y:this.y*r,width:this.width*e,height:this.height*r})},n.prototype.pad=function(t,e){var r=[this.x-t/2,this.y-e/2,this.width+t,this.height+e],o=r[0],a=r[1],i=r[2],s=r[3];return new n({x:o,y:a,width:i,height:s})},n.prototype.clipAtImageBorders=function(t,e){var r=this,o=r.x,a=r.y,i=r.right,s=r.bottom,u=Math.max(o,0),c=Math.max(a,0),l=i-u,d=s-c,f=Math.min(l,t-u),h=Math.min(d,e-c);return new n({x:u,y:c,width:f,height:h}).floor()},n.prototype.shift=function(t,e){var r=this,o=r.width,a=r.height,i=this.x+t,s=this.y+e;return new n({x:i,y:s,width:o,height:a})},n.prototype.padAtBorders=function(t,e){var r=this.width+1,o=this.height+1,a=1,i=1,s=r,u=o,c=this.left,l=this.top,d=this.right,f=this.bottom;return d>e&&(s=-d+e+r,d=e),f>t&&(u=-f+t+o,f=t),c<1&&(u=2-c,c=1),l<1&&(u=2-l,l=1),{dy:i,edy:u,dx:a,edx:s,y:l,ey:f,x:c,ex:d,w:r,h:o}},n.prototype.calibrate=function(t){return new n({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()},n}(),pl=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{left:e,top:r,right:o,bottom:a},i)||this}return t}(Uo),jb=function(){function n(t,e,r,o,a){this._imageDims=new Fi(a.width,a.height),this._score=t,this._classScore=e,this._className=r,this._box=new Uo(o).rescale(this._imageDims)}return Object.defineProperty(n.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"className",{get:function(){return this._className},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"box",{get:function(){return this._box},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageDims",{get:function(){return this._imageDims},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this.imageDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this.imageDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativeBox",{get:function(){return new Uo(this._box).rescale(this.imageDims.reverse())},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new n(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:e})},n}(),Wr=function(n){De(t,n);function t(e,r,o){return n.call(this,e,e,"",r,o)||this}return t.prototype.forSize=function(e,r){var o=n.prototype.forSize.call(this,e,r),a=o.score,i=o.relativeBox,s=o.imageDims;return new t(a,i,s)},t}(jb);function p5(n,t,e){e===void 0&&(e=!0);var r=Math.max(0,Math.min(n.right,t.right)-Math.max(n.left,t.left)),o=Math.max(0,Math.min(n.bottom,t.bottom)-Math.max(n.top,t.top)),a=r*o;return e?a/(n.area+t.area-a):a/Math.min(n.area,t.area)}function v5(n){var t=n.map(function(s){return s.x}),e=n.map(function(s){return s.y}),r=t.reduce(function(s,u){return u<s?u:s},1/0),o=e.reduce(function(s,u){return u<s?u:s},1/0),a=t.reduce(function(s,u){return s<u?u:s},0),i=e.reduce(function(s,u){return s<u?u:s},0);return new pl(r,o,a,i)}function nu(n,t,e,r){r===void 0&&(r=!0);for(var o=t.map(function(s,u){return{score:s,boxIndex:u}}).sort(function(s,u){return s.score-u.score}).map(function(s){return s.boxIndex}),a=[],i=function(){var s=o.pop();a.push(s);for(var u=o,c=[],l=0;l<u.length;l++){var d=u[l],f=n[s],h=n[d];c.push(p5(f,h,r))}o=o.filter(function(m,p){return c[p]<=e})};o.length>0;)i();return a}function ru(n,t){return xe(function(){var e=t[0],r=t[1],o=t[2],a=Lr(eu(n.shape.slice(0,3),[1]),e),i=Lr(eu(n.shape.slice(0,3),[1]),r),s=Lr(eu(n.shape.slice(0,3),[1]),o),u=Vt([a,i,s],3);return zt(n,u)})}function m5(n,t){return t===void 0&&(t=!1),xe(function(){var e=n.shape.slice(1),r=e[0],o=e[1];if(r===o)return n;var a=Math.abs(r-o),i=Math.round(a*(t?.5:1)),s=r>o?2:1,u=function(h){var m=n.shape.slice();return m[s]=h,Lr(m,0)},c=u(i),l=a-c.shape[s],d=t&&l?u(l):null,f=[d,n,c].filter(function(h){return!!h}).map(function(h){return h.toFloat()});return Vt(f,s)})}function jh(n){return 1/(1+Math.exp(-n))}var Uh=function(n){De(t,n);function t(e,r,o,a,i){return i===void 0&&(i=!1),n.call(this,{x:e,y:r,width:o,height:a},i)||this}return t}(Uo),g5=.5,y5=.43,b5=.45,vl=function(){function n(t,e,r){r===void 0&&(r=new ot(0,0));var o=e.width,a=e.height;this._imgDims=new Fi(o,a),this._shift=r,this._positions=t.map(function(i){return i.mul(new ot(o,a)).add(r)})}return Object.defineProperty(n.prototype,"shift",{get:function(){return new ot(this._shift.x,this._shift.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageWidth",{get:function(){return this._imgDims.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageHeight",{get:function(){return this._imgDims.height},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"positions",{get:function(){return this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"relativePositions",{get:function(){var t=this;return this._positions.map(function(e){return e.sub(t._shift).div(new ot(t.imageWidth,t.imageHeight))})},enumerable:!0,configurable:!0}),n.prototype.forSize=function(t,e){return new this.constructor(this.relativePositions,{width:t,height:e})},n.prototype.shiftBy=function(t,e){return new this.constructor(this.relativePositions,this._imgDims,new ot(t,e))},n.prototype.shiftByPoint=function(t){return this.shiftBy(t.x,t.y)},n.prototype.align=function(t,e){if(e===void 0&&(e={}),t){var r=t instanceof Wr?t.box.floor():new Uo(t);return this.shiftBy(r.x,r.y).align(null,e)}var o=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},e),a=o.useDlibAlignment,i=o.minBoxPadding;return a?this.alignDlib():this.alignMinBbox(i)},n.prototype.alignDlib=function(){var t=this.getRefPointsForAlignment(),e=t[0],r=t[1],o=t[2],a=function(d){return o.sub(d).magnitude()},i=(a(e)+a(r))/2,s=Math.floor(i/b5),u=Vh(t),c=Math.floor(Math.max(0,u.x-g5*s)),l=Math.floor(Math.max(0,u.y-y5*s));return new Uh(c,l,Math.min(s,this.imageWidth+c),Math.min(s,this.imageHeight+l))},n.prototype.alignMinBbox=function(t){var e=v5(this.positions);return e.pad(e.width*t,e.height*t)},n.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class")},n}(),x5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getRefPointsForAlignment=function(){var e=this.positions;return[e[0],e[1],Vh([e[3],e[4]])]},t}(vl),w5=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.getJawOutline=function(){return this.positions.slice(0,17)},t.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22)},t.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27)},t.prototype.getNose=function(){return this.positions.slice(27,36)},t.prototype.getLeftEye=function(){return this.positions.slice(36,42)},t.prototype.getRightEye=function(){return this.positions.slice(42,48)},t.prototype.getMouth=function(){return this.positions.slice(48,68)},t.prototype.getRefPointsForAlignment=function(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Vh)},t}(vl),Ub=function(){function n(t,e){this._label=t,this._distance=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distance",{get:function(){return this._distance},enumerable:!0,configurable:!0}),n.prototype.toString=function(t){return t===void 0&&(t=!0),""+this.label+(t?" ("+f5(this.distance)+")":"")},n}(),zb=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._label=r,o}return t.assertIsValidLabeledBox=function(e,r){if(Uo.assertIsValidBox(e,r),!La(e.label))throw new Error(r+" - expected property label ("+e.label+") to be a number")},Object.defineProperty(t.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),t}(Uo),ml=function(){function n(t,e){if(typeof t!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(e)||e.some(function(r){return!(r instanceof Float32Array)}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=e}return Object.defineProperty(n.prototype,"label",{get:function(){return this._label},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"descriptors",{get:function(){return this._descriptors},enumerable:!0,configurable:!0}),n.prototype.toJSON=function(){return{label:this.label,descriptors:this.descriptors.map(function(t){return Array.from(t)})}},n.fromJSON=function(t){var e=t.descriptors.map(function(r){return new Float32Array(r)});return new n(t.label,e)},n}();(function(n){De(t,n);function t(e,r,o,a){var i=n.call(this,e,r)||this;return i._score=o,i._classScore=a,i}return t.assertIsValidPredictedBox=function(e,r){if(zb.assertIsValidLabeledBox(e,r),!Vb(e.score)||!Vb(e.classScore))throw new Error(r+" - expected properties score ("+e.score+") and ("+e.classScore+") to be a number between [0, 1]")},Object.defineProperty(t.prototype,"score",{get:function(){return this._score},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function(){return this._classScore},enumerable:!0,configurable:!0}),t})(zb);function C5(n){return n.detection instanceof Wr}function zh(n,t){var e={detection:t};return Object.assign({},n,e)}function Hb(){var n=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment")},t=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:n,readFile:t}}function Gb(n){var t="";if(!n)try{n=require("fs")}catch(r){t=r.toString()}var e=n?function(r){return new Promise(function(o,a){n.readFile(r,function(i,s){return i?a(i):o(s)})})}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+t)};return{readFile:e}}function qb(){var n=global.Canvas||global.HTMLCanvasElement,t=global.Image||global.HTMLImageElement,e=function(){if(n)return new n;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},r=function(){if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},o=global.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment")},a=Gb();return dn({Canvas:n||function(){function i(){}return i}(),CanvasRenderingContext2D:global.CanvasRenderingContext2D||function(){function i(){}return i}(),Image:t||function(){function i(){}return i}(),ImageData:global.ImageData||function(){function i(){}return i}(),Video:global.HTMLVideoElement||function(){function i(){}return i}(),createCanvasElement:e,createImageElement:r,fetch:o},a)}function Kb(){return typeof window=="object"&&typeof document<"u"&&typeof HTMLImageElement<"u"&&typeof HTMLCanvasElement<"u"&&typeof HTMLVideoElement<"u"&&typeof ImageData<"u"&&typeof CanvasRenderingContext2D<"u"}function Yb(){return typeof global=="object"&&typeof require=="function"&&typeof module<"u"&&typeof process<"u"&&!!process.version}var Ht;function _5(){if(!Ht)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return Ht}function Hh(n){Ht=n}function Gh(){Kb()&&Hh(Hb()),Yb()&&Hh(qb())}function E5(n){if(Ht||Gh(),!Ht)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var t=n.Canvas,e=t===void 0?Ht.Canvas:t,r=n.Image,o=r===void 0?Ht.Image:r;Ht.Canvas=e,Ht.Image=o,Ht.createCanvasElement=n.createCanvasElement||function(){return new e},Ht.createImageElement=n.createImageElement||function(){return new o},Ht.ImageData=n.ImageData||Ht.ImageData,Ht.Video=n.Video||Ht.Video,Ht.fetch=n.fetch||Ht.fetch,Ht.readFile=n.readFile||Ht.readFile}var rn={getEnv:_5,setEnv:Hh,initialize:Gh,createBrowserEnv:Hb,createFileSystem:Gb,createNodejsEnv:qb,monkeyPatch:E5,isBrowser:Kb,isNodejs:Yb};Gh();function Xb(n){return!rn.isNodejs()&&typeof n=="string"?document.getElementById(n):n}function Ba(n){var t=rn.getEnv(),e=t.Canvas,r=t.CanvasRenderingContext2D;if(n instanceof r)return n;var o=Xb(n);if(!(o instanceof e))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var a=o.getContext("2d");if(!a)throw new Error("resolveContext2d - canvas 2d context is null");return a}var Zb;(function(n){n.TOP_LEFT="TOP_LEFT",n.TOP_RIGHT="TOP_RIGHT",n.BOTTOM_LEFT="BOTTOM_LEFT",n.BOTTOM_RIGHT="BOTTOM_RIGHT"})(Zb||(Zb={}));function Qb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e&&n.complete||n instanceof r&&n.readyState>=3}function S5(n){return new Promise(function(t,e){if(n instanceof rn.getEnv().Canvas||Qb(n))return t();function r(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),t(a))}function o(a){a.currentTarget&&(a.currentTarget.removeEventListener("load",r),a.currentTarget.removeEventListener("error",o),e(a))}n.addEventListener("load",r),n.addEventListener("error",o)})}function Jb(n){var t=rn.getEnv(),e=t.Image,r=t.Video;return n instanceof e?new Fi(n.naturalWidth,n.naturalHeight):n instanceof r?new Fi(n.videoWidth,n.videoHeight):new Fi(n.width,n.height)}function gl(n){var t=n.width,e=n.height,r=rn.getEnv().createCanvasElement,o=r();return o.width=t,o.height=e,o}function qh(n,t){var e=rn.getEnv().ImageData;if(!(n instanceof e)&&!Qb(n))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=Jb(n),o=r.width,a=r.height,i=gl({width:o,height:a});return n instanceof e?Ba(i).putImageData(n,0,0):Ba(i).drawImage(n,0,0,o,a),i}function N5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return e=rn.getEnv().createCanvasElement(),r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=xe(function(){return n.as3D(o,a,i).toInt()}),[4,Bh.toPixels(s,e)];case 1:return u.sent(),s.dispose(),[2,e]}})})}function e2(n){var t=rn.getEnv(),e=t.Image,r=t.Canvas,o=t.Video;return n instanceof e||n instanceof r||n instanceof o}function $5(n,t,e){e===void 0&&(e=!1);var r=rn.getEnv(),o=r.Image,a=r.Canvas;if(!(n instanceof o||n instanceof a))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var i=Jb(n),s=t/Math.max(i.height,i.width),u=s*i.width,c=s*i.height,l=gl({width:t,height:t}),d=n instanceof a?n:qh(n),f=Math.abs(u-c)/2,h=e&&u<c?f:0,m=e&&c<u?f:0;return Ba(l).drawImage(d,h,m,u,c),l}var yl=function(){function n(t,e){var r=this;if(e===void 0&&(e=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(t))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+t);this._treatAsBatchInput=e,this._batchSize=t.length,t.forEach(function(o,a){if(hl(o)){r._imageTensors[a]=o,r._inputDimensions[a]=o.shape;return}if(jo(o)){var i=o.shape[0];if(i!==1)throw new Error("NetInput - tf.Tensor4D with batchSize "+i+" passed, but not supported in input array");r._imageTensors[a]=o,r._inputDimensions[a]=o.shape.slice(1);return}var s=o instanceof rn.getEnv().Canvas?o:qh(o);r._canvases[a]=s,r._inputDimensions[a]=[s.height,s.width,3]})}return Object.defineProperty(n.prototype,"imageTensors",{get:function(){return this._imageTensors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"canvases",{get:function(){return this._canvases},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isBatchInput",{get:function(){return this.batchSize>1||this._treatAsBatchInput},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"batchSize",{get:function(){return this._batchSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputDimensions",{get:function(){return this._inputDimensions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"reshapedInputDimensions",{get:function(){var t=this;return tu(this.batchSize,0,1).map(function(e,r){return t.getReshapedInputDimensions(r)})},enumerable:!0,configurable:!0}),n.prototype.getInput=function(t){return this.canvases[t]||this.imageTensors[t]},n.prototype.getInputDimensions=function(t){return this._inputDimensions[t]},n.prototype.getInputHeight=function(t){return this._inputDimensions[t][0]},n.prototype.getInputWidth=function(t){return this._inputDimensions[t][1]},n.prototype.getReshapedInputDimensions=function(t){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");var e=this.getInputWidth(t),r=this.getInputHeight(t);return h5({width:e,height:r},this.inputSize)},n.prototype.toBatchTensor=function(t,e){var r=this;return e===void 0&&(e=!0),this._inputSize=t,xe(function(){var o=tu(r.batchSize,0,1).map(function(i){var s=r.getInput(i);if(s instanceof bt){var u=jo(s)?s:s.expandDims();return u=m5(u,e),(u.shape[1]!==t||u.shape[2]!==t)&&(u=wh.resizeBilinear(u,[t,t])),u.as3D(t,t,3)}if(s instanceof rn.getEnv().Canvas)return Bh.fromPixels($5(s,t,e));throw new Error("toBatchTensor - at batchIdx "+i+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+s)}),a=Bn(o.map(function(i){return i.toFloat()})).as4D(r.batchSize,t,t,3);return a})},n}();function Yt(n){return $e(this,void 0,void 0,function(){var t,e,r;return ke(this,function(o){switch(o.label){case 0:if(n instanceof yl)return[2,n];if(t=Array.isArray(n)?n:[n],!t.length)throw new Error("toNetInput - empty array passed as input");return e=function(a){return Array.isArray(n)?" at input index "+a+":":""},r=t.map(Xb),r.forEach(function(a,i){if(!e2(a)&&!hl(a)&&!jo(a))throw typeof t[i]=="string"?new Error("toNetInput -"+e(i)+" string passed, but could not resolve HTMLElement for element id "+t[i]):new Error("toNetInput -"+e(i)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");if(jo(a)){var s=a.shape[0];if(s!==1)throw new Error("toNetInput -"+e(i)+" tf.Tensor4D with batchSize "+s+" passed, but not supported in input array")}}),[4,Promise.all(r.map(function(a){return e2(a)&&S5(a)}))];case 1:return o.sent(),[2,new yl(r,Array.isArray(n))]}})})}function Kh(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u;return ke(this,function(c){switch(c.label){case 0:return e=rn.getEnv().Canvas,r=n,n instanceof e?[3,5]:[4,Yt(n)];case 1:if(o=c.sent(),o.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return a=o.getInput(0),a instanceof e?(i=a,[3,4]):[3,2];case 2:return[4,N5(a)];case 3:i=c.sent(),c.label=4;case 4:r=i,c.label=5;case 5:return s=Ba(r),u=t.map(function(l){return l instanceof Wr?l.forSize(r.width,r.height).box.floor():l}).map(function(l){return l.clipAtImageBorders(r.width,r.height)}),[2,u.map(function(l){var d=l.x,f=l.y,h=l.width,m=l.height,p=gl({width:h,height:m});return Ba(p).putImageData(s.getImageData(d,f,h,m),0,0),p})]}})})}function Yh(n,t){return $e(this,void 0,void 0,function(){return ke(this,function(e){if(!hl(n)&&!jo(n))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(jo(n)&&n.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return[2,xe(function(){var r=n.shape.slice(jo(n)?1:0),o=r[0],a=r[1],i=r[2],s=t.map(function(c){return c instanceof Wr?c.forSize(a,o).box:c}).map(function(c){return c.clipAtImageBorders(a,o)}),u=s.map(function(c){var l=c.x,d=c.y,f=c.width,h=c.height;return sb(n.as3D(o,a,i),[d,l,0],[h,f,i])});return u})]})})}function k5(n,t){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return e=rn.getEnv().fetch,[4,e(n,t)];case 1:if(r=o.sent(),!(r.status<400))throw new Error("failed to fetch: ("+r.status+") "+r.statusText+", from url: "+r.url);return[2,r]}})})}function P5(n){return $e(this,void 0,void 0,function(){return ke(this,function(t){switch(t.label){case 0:return[4,k5(n)];case 1:return[2,t.sent().json()]}})})}function t2(n,t){var e=t+"-weights_manifest.json";if(!n)return{modelBaseUri:"",manifestUri:e};if(n==="/")return{modelBaseUri:"/",manifestUri:"/"+e};var r=n.startsWith("http://")?"http://":n.startsWith("https://")?"https://":"";n=n.replace(r,"");var o=n.split("/").filter(function(s){return s}),a=n.endsWith(".json")?o[o.length-1]:e,i=r+(n.endsWith(".json")?o.slice(0,o.length-1):o).join("/");return i=n.startsWith("/")?"/"+i:i,{modelBaseUri:i,manifestUri:i==="/"?"/"+a:i+"/"+a}}function I5(n,t){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=t2(n,t),r=e.manifestUri,o=e.modelBaseUri,[4,P5(r)];case 1:return a=i.sent(),[2,Rb.loadWeights(a,o)]}})})}var uo=function(){function n(t){this._name=t,this._params=void 0,this._paramMappings=[]}return Object.defineProperty(n.prototype,"params",{get:function(){return this._params},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"paramMappings",{get:function(){return this._paramMappings},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isLoaded",{get:function(){return!!this.params},enumerable:!0,configurable:!0}),n.prototype.getParamFromPath=function(t){var e=this.traversePropertyPath(t),r=e.obj,o=e.objProp;return r[o]},n.prototype.reassignParamFromPath=function(t,e){var r=this.traversePropertyPath(t),o=r.obj,a=r.objProp;o[a].dispose(),o[a]=e},n.prototype.getParamList=function(){var t=this;return this._paramMappings.map(function(e){var r=e.paramPath;return{path:r,tensor:t.getParamFromPath(r)}})},n.prototype.getTrainableParams=function(){return this.getParamList().filter(function(t){return t.tensor instanceof xi})},n.prototype.getFrozenParams=function(){return this.getParamList().filter(function(t){return!(t.tensor instanceof xi)})},n.prototype.variable=function(){var t=this;this.getFrozenParams().forEach(function(e){var r=e.path,o=e.tensor;t.reassignParamFromPath(r,o.variable())})},n.prototype.freeze=function(){var t=this;this.getTrainableParams().forEach(function(e){var r=e.path,o=e.tensor,a=nn(o.dataSync());o.dispose(),t.reassignParamFromPath(r,a)})},n.prototype.dispose=function(t){t===void 0&&(t=!0),this.getParamList().forEach(function(e){if(t&&e.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+e.path);e.tensor.dispose()}),this._params=void 0},n.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(t){var e=t.tensor;return Array.from(e.dataSync())}).reduce(function(t,e){return t.concat(e)}))},n.prototype.load=function(t){return $e(this,void 0,void 0,function(){return ke(this,function(e){switch(e.label){case 0:return t instanceof Float32Array?(this.extractWeights(t),[2]):[4,this.loadFromUri(t)];case 1:return e.sent(),[2]}})})},n.prototype.loadFromUri=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromUri - expected model uri");return[4,I5(t,this.getDefaultModelName())];case 1:return e=r.sent(),this.loadFromWeightMap(e),[2]}})})},n.prototype.loadFromDisk=function(t){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s,u,c,l,d;return ke(this,function(f){switch(f.label){case 0:if(t&&typeof t!="string")throw new Error(this._name+".loadFromDisk - expected model file path");return e=rn.getEnv().readFile,r=t2(t,this.getDefaultModelName()),o=r.manifestUri,a=r.modelBaseUri,i=function(h){return Promise.all(h.map(function(m){return e(m).then(function(p){return p.buffer})}))},s=Rb.weightsLoaderFactory(i),l=(c=JSON).parse,[4,e(o)];case 1:return u=l.apply(c,[f.sent().toString()]),[4,s(u,a)];case 2:return d=f.sent(),this.loadFromWeightMap(d),[2]}})})},n.prototype.loadFromWeightMap=function(t){var e=this.extractParamsFromWeigthMap(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.extractWeights=function(t){var e=this.extractParams(t),r=e.paramMappings,o=e.params;this._paramMappings=r,this._params=o},n.prototype.traversePropertyPath=function(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var e=t.split("/").reduce(function(a,i){if(!a.nextObj.hasOwnProperty(i))throw new Error("traversePropertyPath - object does not have property "+i+", for path "+t);return{obj:a.nextObj,objProp:i,nextObj:a.nextObj[i]}},{nextObj:this.params}),r=e.obj,o=e.objProp;if(!r||!o||!(r[o]instanceof bt))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+t);return{obj:r,objProp:o}},n}();function Vn(n,t,e){return xe(function(){var r=mh(n,t.depthwise_filter,t.pointwise_filter,e,"same");return r=qe(r,t.bias),r})}function Xh(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=wt(e?qe(Zn(n,t.conv0.filters,[2,2],"same"),t.conv0.bias):Vn(n,t.conv0,[2,2])),o=Vn(r,t.conv1,[1,1]),a=wt(qe(r,o)),i=Vn(a,t.conv2,[1,1]);return wt(qe(r,qe(o,i)))})}function bl(n,t,e,r){return e===void 0&&(e=!1),r===void 0&&(r=!0),xe(function(){var o=wt(e?qe(Zn(n,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):Vn(n,t.conv0,r?[2,2]:[1,1])),a=Vn(o,t.conv1,[1,1]),i=wt(qe(o,a)),s=Vn(i,t.conv2,[1,1]),u=wt(qe(o,qe(a,s))),c=Vn(u,t.conv3,[1,1]);return wt(qe(o,qe(a,qe(s,c))))})}function cr(n,t,e,r){return e===void 0&&(e="same"),r===void 0&&(r=!1),xe(function(){var o=qe(Zn(n,t.filters,[1,1],e),t.bias);return r?wt(o):o})}function co(n,t){Object.keys(n).forEach(function(e){t.some(function(r){return r.originalPath===e})||n[e].dispose()})}function xl(n,t){return function(e,r,o,a){var i=Sn(n(e*r*o*o),[o,o,e,r]),s=Ot(n(r));return t.push({paramPath:a+"/filters"},{paramPath:a+"/bias"}),{filters:i,bias:s}}}function Zh(n,t){return function(e,r,o){var a=Ro(n(e*r),[e,r]),i=Ot(n(r));return t.push({paramPath:o+"/weights"},{paramPath:o+"/bias"}),{weights:a,bias:i}}}var n2=function(){function n(t,e,r){this.depthwise_filter=t,this.pointwise_filter=e,this.bias=r}return n}();function Qh(n,t){return function(e,r,o){var a=Sn(n(9*e),[3,3,e,1]),i=Sn(n(e*r),[1,1,e,r]),s=Ot(n(r));return t.push({paramPath:o+"/depthwise_filter"},{paramPath:o+"/pointwise_filter"},{paramPath:o+"/bias"}),new n2(a,i,s)}}function Jh(n){return function(t){var e=n(t+"/depthwise_filter",4),r=n(t+"/pointwise_filter",4),o=n(t+"/bias",1);return new n2(e,r,o)}}function zo(n,t){return function(e,r,o){var a=n[e];if(!fl(a,r))throw new Error("expected weightMap["+e+"] to be a Tensor"+r+"D, instead have "+a);return t.push({originalPath:e,paramPath:o||e}),a}}function lo(n){var t=n;function e(o){var a=t.slice(0,o);return t=t.slice(o),a}function r(){return t}return{extractWeights:e,getRemainingWeights:r}}function r2(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u,c){c===void 0&&(c=!1);var l=c?e(i,s,3,u+"/conv0"):r(i,s,u+"/conv0"),d=r(s,s,u+"/conv1"),f=r(s,s,u+"/conv2");return{conv0:l,conv1:d,conv2:f}}function a(i,s,u,c){c===void 0&&(c=!1);var l=o(i,s,u,c),d=l.conv0,f=l.conv1,h=l.conv2,m=r(s,s,u+"/conv3");return{conv0:d,conv1:f,conv2:h,conv3:m}}return{extractDenseBlock3Params:o,extractDenseBlock4Params:a}}function A5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock4Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2"),c=a(128,256,"dense3");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u,dense3:c}}}function o2(n){return function(t){var e=n(t+"/filters",4),r=n(t+"/bias",1);return{filters:e,bias:r}}}function a2(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2");return{conv0:c,conv1:l,conv2:d}}function i(s,u){u===void 0&&(u=!1);var c=u?r(s+"/conv0"):o(s+"/conv0"),l=o(s+"/conv1"),d=o(s+"/conv2"),f=o(s+"/conv3");return{conv0:c,conv1:l,conv2:d,conv3:f}}return{extractDenseBlock3Params:a,extractDenseBlock4Params:i}}function T5(n){var t=[],e=a2(n,t).extractDenseBlock4Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2"),dense3:e("dense3")};return co(n,t),{params:r,paramMappings:t}}var i2=function(n){De(t,n);function t(){return n.call(this,"FaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=bl(i,r.dense0,!0);return s=bl(s,r.dense1),s=bl(s,r.dense2),s=bl(s,r.dense3),s=Qs(s,[7,7],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_model"},t.prototype.extractParamsFromWeigthMap=function(e){return T5(e)},t.prototype.extractParams=function(e){return A5(e)},t}(uo);function Vr(n,t){return xe(function(){return qe(il(n,t.weights),t.bias)})}function O5(n,t,e){var r=[],o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=Zh(a,r),u=s(t,e,"fc");if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{paramMappings:r,params:{fc:u}}}function D5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:r("fc")};return co(n,t),{params:o,paramMappings:t}}function s2(n){var t={},e={};return Object.keys(n).forEach(function(r){var o=r.startsWith("fc")?e:t;o[r]=n[r]}),{featureExtractorMap:t,classifierMap:e}}var u2=function(n){De(t,n);function t(e,r){var o=n.call(this,e)||this;return o._faceFeatureExtractor=r,o}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e;return Vr(a.as2D(a.shape[0],-1),o.fc)})},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return O5(e,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),D5(a)},t.prototype.extractParams=function(e){var r=this.getClassifierChannelsIn(),o=this.getClassifierChannelsOut(),a=o*r+o,i=e.slice(0,e.length-a),s=e.slice(e.length-a);return this.faceFeatureExtractor.extractWeights(i),this.extractClassifierParams(s)},t}(uo),c2=["neutral","happy","sad","angry","fearful","disgusted","surprised"],M5=function(){function n(t){var e=this;if(t.length!==7)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+t.length);c2.forEach(function(r,o){e[r]=t[o]})}return n.prototype.asSortedArray=function(){var t=this;return c2.map(function(e){return{expression:e,probability:t[e]}}).sort(function(e,r){return r.probability-e.probability})},n}(),F5=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceExpressionNet",e)||this}return t.prototype.forwardInput=function(e){var r=this;return xe(function(){return oo(r.runNet(e))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictExpressions=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,Yt(e)];case 1:return r=u.sent(),[4,this.forwardInput(r)];case 2:return o=u.sent(),[4,Promise.all(jt(o).map(function(c){return $e(s,void 0,void 0,function(){var l;return ke(this,function(d){switch(d.label){case 0:return[4,c.data()];case 1:return l=d.sent(),c.dispose(),[2,l]}})})}))];case 3:return a=u.sent(),o.dispose(),i=a.map(function(c){return new M5(c)}),[2,r.isBatchInput?i:i[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_expression_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t.prototype.getClassifierChannelsOut=function(){return 7},t}(u2);function l2(n,t){var e={expressions:t};return Object.assign({},n,e)}function R5(n){return C5(n)&&n.landmarks instanceof vl&&n.unshiftedLandmarks instanceof vl&&n.alignedRect instanceof Wr}function ep(n,t){var e=n.detection.box,r=t.shiftBy(e.x,e.y),o=r.align(),a=n.detection.imageDims,i=new Wr(n.detection.score,o.rescale(a.reverse()),a),s={landmarks:r,unshiftedLandmarks:t,alignedRect:i};return Object.assign({},n,s)}function L5(n,t){var e=xl(n,t),r=Qh(n,t);function o(i,s,u){var c=r(i,s,u+"/separable_conv0"),l=r(s,s,u+"/separable_conv1"),d=e(i,s,1,u+"/expansion_conv");return{separable_conv0:c,separable_conv1:l,expansion_conv:d}}function a(i,s){var u=r(i,i,s+"/separable_conv0"),c=r(i,i,s+"/separable_conv1"),l=r(i,i,s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:e,extractSeparableConvParams:r,extractReductionBlockParams:o,extractMainBlockParams:a}}function B5(n,t){var e=[],r=lo(n),o=r.extractWeights,a=r.getRemainingWeights,i=L5(o,e),s=i.extractConvParams,u=i.extractSeparableConvParams,c=i.extractReductionBlockParams,l=i.extractMainBlockParams,d=s(3,32,3,"entry_flow/conv_in"),f=c(32,64,"entry_flow/reduction_block_0"),h=c(64,128,"entry_flow/reduction_block_1"),m={conv_in:d,reduction_block_0:f,reduction_block_1:h},p={};tu(t,0,1).forEach(function(w){p["main_block_"+w]=l(128,"middle_flow/main_block_"+w)});var v=c(128,256,"exit_flow/reduction_block"),g=u(256,512,"exit_flow/separable_conv"),y={reduction_block:v,separable_conv:g};if(a().length!==0)throw new Error("weights remaing after extract: "+a().length);return{paramMappings:e,params:{entry_flow:m,middle_flow:p,exit_flow:y}}}function W5(n,t){var e=zo(n,t),r=o2(e),o=Jh(e);function a(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=r(s+"/expansion_conv");return{separable_conv0:u,separable_conv1:c,expansion_conv:l}}function i(s){var u=o(s+"/separable_conv0"),c=o(s+"/separable_conv1"),l=o(s+"/separable_conv2");return{separable_conv0:u,separable_conv1:c,separable_conv2:l}}return{extractConvParams:r,extractSeparableConvParams:o,extractReductionBlockParams:a,extractMainBlockParams:i}}function V5(n,t){var e=[],r=W5(n,e),o=r.extractConvParams,a=r.extractSeparableConvParams,i=r.extractReductionBlockParams,s=r.extractMainBlockParams,u=o("entry_flow/conv_in"),c=i("entry_flow/reduction_block_0"),l=i("entry_flow/reduction_block_1"),d={conv_in:u,reduction_block_0:c,reduction_block_1:l},f={};tu(t,0,1).forEach(function(v){f["main_block_"+v]=s("middle_flow/main_block_"+v)});var h=i("exit_flow/reduction_block"),m=a("exit_flow/separable_conv"),p={reduction_block:h,separable_conv:m};return co(n,e),{params:{entry_flow:d,middle_flow:f,exit_flow:p},paramMappings:e}}function d2(n,t,e){return qe(Zn(n,t.filters,e,"same"),t.bias)}function tp(n,t,e){e===void 0&&(e=!0);var r=e?wt(n):n;return r=Vn(r,t.separable_conv0,[1,1]),r=Vn(wt(r),t.separable_conv1,[1,1]),r=Kt(r,[3,3],[2,2],"same"),r=qe(r,d2(n,t.expansion_conv,[2,2])),r}function j5(n,t){var e=Vn(wt(n),t.separable_conv0,[1,1]);return e=Vn(wt(e),t.separable_conv1,[1,1]),e=Vn(wt(e),t.separable_conv2,[1,1]),e=qe(e,n),e}var U5=function(n){De(t,n);function t(e){var r=n.call(this,"TinyXception")||this;return r._numMainBlocks=e,r}return t.prototype.forwardInput=function(e){var r=this,o=this.params;if(!o)throw new Error("TinyXception - load model before inference");return xe(function(){var a=e.toBatchTensor(112,!0),i=[122.782,117.001,104.298],s=ru(a,i).div(ve(256)),u=wt(d2(s,o.entry_flow.conv_in,[2,2]));return u=tp(u,o.entry_flow.reduction_block_0,!1),u=tp(u,o.entry_flow.reduction_block_1),tu(r._numMainBlocks,0,1).forEach(function(c){u=j5(u,o.middle_flow["main_block_"+c])}),u=tp(u,o.exit_flow.reduction_block),u=wt(Vn(u,o.exit_flow.separable_conv,[1,1])),u})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"tiny_xception_model"},t.prototype.extractParamsFromWeigthMap=function(e){return V5(e,this._numMainBlocks)},t.prototype.extractParams=function(e){return B5(e,this._numMainBlocks)},t}(uo);function z5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=Zh(r,t),i=a(512,1,"fc/age"),s=a(512,2,"fc/gender");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{fc:{age:i,gender:s}}}}function H5(n){var t=[],e=zo(n,t);function r(a){var i=e(a+"/weights",2),s=e(a+"/bias",1);return{weights:i,bias:s}}var o={fc:{age:r("fc/age"),gender:r("fc/gender")}};return co(n,t),{params:o,paramMappings:t}}var wl;(function(n){n.FEMALE="female",n.MALE="male"})(wl||(wl={}));var G5=function(n){De(t,n);function t(e){e===void 0&&(e=new U5(2));var r=n.call(this,"AgeGenderNet")||this;return r._faceFeatureExtractor=e,r}return Object.defineProperty(t.prototype,"faceFeatureExtractor",{get:function(){return this._faceFeatureExtractor},enumerable:!0,configurable:!0}),t.prototype.runNet=function(e){var r=this,o=this.params;if(!o)throw new Error(this._name+" - load model before inference");return xe(function(){var a=e instanceof yl?r.faceFeatureExtractor.forwardInput(e):e,i=Qs(a,[7,7],[2,2],"valid").as2D(a.shape[0],-1),s=Vr(i,o.fc.age).as1D(),u=Vr(i,o.fc.gender);return{age:s,gender:u}})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e),a=o.age,i=o.gender;return{age:a,gender:oo(i)}})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.predictAgeAndGender=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i,s,u,c=this;return ke(this,function(l){switch(l.label){case 0:return[4,Yt(e)];case 1:return r=l.sent(),[4,this.forwardInput(r)];case 2:return o=l.sent(),a=jt(o.age),i=jt(o.gender),s=a.map(function(d,f){return{ageTensor:d,genderTensor:i[f]}}),[4,Promise.all(s.map(function(d){var f=d.ageTensor,h=d.genderTensor;return $e(c,void 0,void 0,function(){var m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return[4,f.data()];case 1:return m=w.sent()[0],[4,h.data()];case 2:return p=w.sent()[0],v=p>.5,g=v?wl.MALE:wl.FEMALE,y=v?p:1-p,f.dispose(),h.dispose(),[2,{age:m,gender:g,genderProbability:y}]}})})}))];case 3:return u=l.sent(),o.age.dispose(),o.gender.dispose(),[2,r.isBatchInput?u:u[0]]}})})},t.prototype.getDefaultModelName=function(){return"age_gender_model"},t.prototype.dispose=function(e){e===void 0&&(e=!0),this.faceFeatureExtractor.dispose(e),n.prototype.dispose.call(this,e)},t.prototype.loadClassifierParams=function(e){var r=this.extractClassifierParams(e),o=r.params,a=r.paramMappings;this._params=o,this._paramMappings=a},t.prototype.extractClassifierParams=function(e){return z5(e)},t.prototype.extractParamsFromWeigthMap=function(e){var r=s2(e),o=r.featureExtractorMap,a=r.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(o),H5(a)},t.prototype.extractParams=function(e){var r=1539,o=e.slice(0,e.length-r),a=e.slice(e.length-r);return this.faceFeatureExtractor.extractWeights(o),this.extractClassifierParams(a)},t}(uo),f2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.postProcess=function(e,r,o){var a=o.map(function(s){var u=s.width,c=s.height,l=r/Math.max(c,u);return{width:u*l,height:c*l}}),i=a.length;return xe(function(){var s=function(f,h){return Bn([Lr([68],f),Lr([68],h)],1).as2D(1,136).as1D()},u=function(f,h){var m=a[f],p=m.width,v=m.height;return h(p,v)?Math.abs(p-v)/2:0},c=function(f){return u(f,function(h,m){return h<m})},l=function(f){return u(f,function(h,m){return m<h})},d=e.mul(Lr([i,136],r)).sub(Bn(Array.from(Array(i),function(f,h){return s(c(h),l(h))}))).div(Bn(Array.from(Array(i),function(f,h){return s(a[h].width,a[h].height)})));return d})},t.prototype.forwardInput=function(e){var r=this;return xe(function(){var o=r.runNet(e);return r.postProcess(o,e.inputSize,e.inputDimensions.map(function(a){var i=a[0],s=a[1];return{height:i,width:s}}))})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.detectLandmarks=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u,c){return $e(i,void 0,void 0,function(){var l,d,f,h,m;return ke(this,function(p){switch(p.label){case 0:return f=(d=Array).from,[4,u.data()];case 1:return l=f.apply(d,[p.sent()]),h=l.filter(function(v,g){return Bb(g)}),m=l.filter(function(v,g){return!Bb(g)}),[2,new w5(Array(68).fill(0).map(function(v,g){return new ot(h[g],m[g])}),{height:r.getInputHeight(c),width:r.getInputWidth(c)})]}})})}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getClassifierChannelsOut=function(){return 136},t}(u2),h2=function(n){De(t,n);function t(e){return e===void 0&&(e=new i2),n.call(this,"FaceLandmark68Net",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_model"},t.prototype.getClassifierChannelsIn=function(){return 256},t}(f2);function q5(n){var t=[],e=a2(n,t).extractDenseBlock3Params,r={dense0:e("dense0",!0),dense1:e("dense1"),dense2:e("dense2")};return co(n,t),{params:r,paramMappings:t}}function K5(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=r2(r,t).extractDenseBlock3Params,i=a(3,32,"dense0",!0),s=a(32,64,"dense1"),u=a(64,128,"dense2");if(o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{paramMappings:t,params:{dense0:i,dense1:s,dense2:u}}}var Y5=function(n){De(t,n);function t(){return n.call(this,"TinyFaceFeatureExtractor")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("TinyFaceFeatureExtractor - load model before inference");return xe(function(){var o=e.toBatchTensor(112,!0),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(255)),s=Xh(i,r.dense0,!0);return s=Xh(s,r.dense1),s=Xh(s,r.dense2),s=Qs(s,[14,14],[2,2],"valid"),s})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.getDefaultModelName=function(){return"face_feature_extractor_tiny_model"},t.prototype.extractParamsFromWeigthMap=function(e){return q5(e)},t.prototype.extractParams=function(e){return K5(e)},t}(uo),X5=function(n){De(t,n);function t(e){return e===void 0&&(e=new Y5),n.call(this,"FaceLandmark68TinyNet",e)||this}return t.prototype.getDefaultModelName=function(){return"face_landmark_68_tiny_model"},t.prototype.getClassifierChannelsIn=function(){return 128},t}(f2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(h2);function Z5(n,t){return qe(cn(n,t.weights),t.biases)}function np(n,t,e,r,o){o===void 0&&(o="same");var a=t.conv,i=a.filters,s=a.bias,u=Zn(n,i,e,o);return u=qe(u,s),u=Z5(u,t.scale),r?wt(u):u}function Q5(n,t){return np(n,t,[1,1],!0)}function p2(n,t){return np(n,t,[1,1],!1)}function v2(n,t){return np(n,t,[2,2],!0,"valid")}function J5(n,t){function e(s,u,c){var l=n(s),d=l.length/(u*c*c);if(d5(d))throw new Error("depth has to be an integer: "+d+", weights.length: "+l.length+", numFilters: "+u+", filterSize: "+c);return xe(function(){return Bo(Sn(l,[u,d,c,c]),[2,3,1,0])})}function r(s,u,c,l){var d=e(s,u,c),f=Ot(n(u));return t.push({paramPath:l+"/filters"},{paramPath:l+"/bias"}),{filters:d,bias:f}}function o(s,u){var c=Ot(n(s)),l=Ot(n(s));return t.push({paramPath:u+"/weights"},{paramPath:u+"/biases"}),{weights:c,biases:l}}function a(s,u,c,l){var d=r(s,u,c,l+"/conv"),f=o(u,l+"/scale");return{conv:d,scale:f}}function i(s,u,c,l,d){d===void 0&&(d=!1);var f=a((d?.5:1)*s,u,c,l+"/conv1"),h=a(s,u,c,l+"/conv2");return{conv1:f,conv2:h}}return{extractConvLayerParams:a,extractResidualLayerParams:i}}function e9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=J5(e,o),i=a.extractConvLayerParams,s=a.extractResidualLayerParams,u=i(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),d=s(9216,32,3,"conv32_3"),f=s(36864,64,3,"conv64_down",!0),h=s(36864,64,3,"conv64_1"),m=s(36864,64,3,"conv64_2"),p=s(36864,64,3,"conv64_3"),v=s(147456,128,3,"conv128_down",!0),g=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),w=s(589824,256,3,"conv256_down",!0),x=s(589824,256,3,"conv256_1"),C=s(589824,256,3,"conv256_2"),_=s(589824,256,3,"conv256_down_out"),E=xe(function(){return Bo(Ro(e(256*128),[128,256]),[1,0])});if(o.push({paramPath:"fc"}),r().length!==0)throw new Error("weights remaing after extract: "+r().length);var S={conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:d,conv64_down:f,conv64_1:h,conv64_2:m,conv64_3:p,conv128_down:v,conv128_1:g,conv128_2:y,conv256_down:w,conv256_1:x,conv256_2:C,conv256_down_out:_,fc:E};return{params:S,paramMappings:o}}function t9(n,t){var e=zo(n,t);function r(i){var s=e(i+"/scale/weights",1),u=e(i+"/scale/biases",1);return{weights:s,biases:u}}function o(i){var s=e(i+"/conv/filters",4),u=e(i+"/conv/bias",1),c=r(i);return{conv:{filters:s,bias:u},scale:c}}function a(i){return{conv1:o(i+"/conv1"),conv2:o(i+"/conv2")}}return{extractConvLayerParams:o,extractResidualLayerParams:a}}function n9(n){var t=[],e=t9(n,t),r=e.extractConvLayerParams,o=e.extractResidualLayerParams,a=r("conv32_down"),i=o("conv32_1"),s=o("conv32_2"),u=o("conv32_3"),c=o("conv64_down"),l=o("conv64_1"),d=o("conv64_2"),f=o("conv64_3"),h=o("conv128_down"),m=o("conv128_1"),p=o("conv128_2"),v=o("conv256_down"),g=o("conv256_1"),y=o("conv256_2"),w=o("conv256_down_out"),x=n.fc;if(t.push({originalPath:"fc",paramPath:"fc"}),!l5(x))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+x);var C={conv32_down:a,conv32_1:i,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:d,conv64_3:f,conv128_down:h,conv128_1:m,conv128_2:p,conv256_down:v,conv256_1:g,conv256_2:y,conv256_down_out:w,fc:x};return co(n,t),{params:C,paramMappings:t}}function jr(n,t){var e=Q5(n,t.conv1);return e=p2(e,t.conv2),e=qe(e,n),e=wt(e),e}function Cl(n,t){var e=v2(n,t.conv1);e=p2(e,t.conv2);var r=Qs(n,2,2,"valid"),o=vt(r.shape),a=r.shape[3]!==e.shape[3],i=r.shape[1]!==e.shape[1]||r.shape[2]!==e.shape[2];if(i){var s=eu(e.shape);s[1]=1;var u=vt(s);e=Vt([e,u],1);var c=eu(e.shape);c[2]=1;var l=vt(c);e=Vt([e,l],2)}return r=a?Vt([r,o],3):r,e=qe(r,e),e=wt(e),e}var r9=function(n){De(t,n);function t(){return n.call(this,"FaceRecognitionNet")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("FaceRecognitionNet - load model before inference");return xe(function(){var o=e.toBatchTensor(150,!0).toFloat(),a=[122.782,117.001,104.298],i=ru(o,a).div(ve(256)),s=v2(i,r.conv32_down);s=Kt(s,3,2,"valid"),s=jr(s,r.conv32_1),s=jr(s,r.conv32_2),s=jr(s,r.conv32_3),s=Cl(s,r.conv64_down),s=jr(s,r.conv64_1),s=jr(s,r.conv64_2),s=jr(s,r.conv64_3),s=Cl(s,r.conv128_down),s=jr(s,r.conv128_1),s=jr(s,r.conv128_2),s=Cl(s,r.conv256_down),s=jr(s,r.conv256_1),s=jr(s,r.conv256_2),s=Cl(s,r.conv256_down_out);var u=s.mean([1,2]),c=il(u,r.fc);return c})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.computeFaceDescriptor=function(e){return $e(this,void 0,void 0,function(){var r,o,a,i=this;return ke(this,function(s){switch(s.label){case 0:return[4,Yt(e)];case 1:return r=s.sent(),o=xe(function(){return jt(i.forwardInput(r))}),[4,Promise.all(o.map(function(u){return u.data()}))];case 2:return a=s.sent(),o.forEach(function(u){return u.dispose()}),[2,r.isBatchInput?a:a[0]]}})})},t.prototype.getDefaultModelName=function(){return"face_recognition_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n9(e)},t.prototype.extractParams=function(e){return e9(e)},t}(uo);function m2(n,t){var e={descriptor:t};return Object.assign({},n,e)}function g2(n,t){var e={age:t};return Object.assign({},n,e)}function y2(n,t,e){var r={gender:t,genderProbability:e};return Object.assign({},n,r)}var b2=function(){function n(t){var e=t===void 0?{}:t,r=e.minFaceSize,o=e.scaleFactor,a=e.maxNumScales,i=e.scoreThresholds,s=e.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=r||20,this._scaleFactor=o||.709,this._maxNumScales=a||10,this._scoreThresholds=i||[.6,.7,.7],this._scaleSteps=s,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(u){return typeof u!="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(u){return typeof u!="number"})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers")}return Object.defineProperty(n.prototype,"minFaceSize",{get:function(){return this._minFaceSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleFactor",{get:function(){return this._scaleFactor},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxNumScales",{get:function(){return this._maxNumScales},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThresholds",{get:function(){return this._scoreThresholds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scaleSteps",{get:function(){return this._scaleSteps},enumerable:!0,configurable:!0}),n}();function o9(n,t){function e(u,c){var l=Sn(n(9*u),[3,3,u,1]),d=Ot(n(u)),f=Ot(n(u)),h=Ot(n(u)),m=Ot(n(u));return t.push({paramPath:c+"/filters"},{paramPath:c+"/batch_norm_scale"},{paramPath:c+"/batch_norm_offset"},{paramPath:c+"/batch_norm_mean"},{paramPath:c+"/batch_norm_variance"}),{filters:l,batch_norm_scale:d,batch_norm_offset:f,batch_norm_mean:h,batch_norm_variance:m}}function r(u,c,l,d,f){var h=Sn(n(u*c*l*l),[l,l,u,c]),m=Ot(n(c));return t.push({paramPath:d+"/filters"},{paramPath:d+"/"+(f?"batch_norm_offset":"bias")}),{filters:h,bias:m}}function o(u,c,l,d){var f=r(u,c,l,d,!0),h=f.filters,m=f.bias;return{filters:h,batch_norm_offset:m}}function a(u,c,l){var d=e(u,l+"/depthwise_conv"),f=o(u,c,1,l+"/pointwise_conv");return{depthwise_conv:d,pointwise_conv:f}}function i(){var u=o(3,32,3,"mobilenetv1/conv_0"),c=a(32,64,"mobilenetv1/conv_1"),l=a(64,128,"mobilenetv1/conv_2"),d=a(128,128,"mobilenetv1/conv_3"),f=a(128,256,"mobilenetv1/conv_4"),h=a(256,256,"mobilenetv1/conv_5"),m=a(256,512,"mobilenetv1/conv_6"),p=a(512,512,"mobilenetv1/conv_7"),v=a(512,512,"mobilenetv1/conv_8"),g=a(512,512,"mobilenetv1/conv_9"),y=a(512,512,"mobilenetv1/conv_10"),w=a(512,512,"mobilenetv1/conv_11"),x=a(512,1024,"mobilenetv1/conv_12"),C=a(1024,1024,"mobilenetv1/conv_13");return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,conv_8:v,conv_9:g,conv_10:y,conv_11:w,conv_12:x,conv_13:C}}function s(){var u=o(1024,256,1,"prediction_layer/conv_0"),c=o(256,512,3,"prediction_layer/conv_1"),l=o(512,128,1,"prediction_layer/conv_2"),d=o(128,256,3,"prediction_layer/conv_3"),f=o(256,128,1,"prediction_layer/conv_4"),h=o(128,256,3,"prediction_layer/conv_5"),m=o(256,64,1,"prediction_layer/conv_6"),p=o(64,128,3,"prediction_layer/conv_7"),v=r(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),g=r(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),y=r(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),w=r(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),x=r(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),C=r(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),_=r(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),E=r(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),S=r(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),N=r(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),$=r(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),A=r(128,18,1,"prediction_layer/box_predictor_5/class_predictor"),P={box_encoding_predictor:v,class_predictor:g},j={box_encoding_predictor:y,class_predictor:w},B={box_encoding_predictor:x,class_predictor:C},z={box_encoding_predictor:_,class_predictor:E},H={box_encoding_predictor:S,class_predictor:N},F={box_encoding_predictor:$,class_predictor:A};return{conv_0:u,conv_1:c,conv_2:l,conv_3:d,conv_4:f,conv_5:h,conv_6:m,conv_7:p,box_predictor_0:P,box_predictor_1:j,box_predictor_2:B,box_predictor_3:z,box_predictor_4:H,box_predictor_5:F}}return{extractMobilenetV1Params:i,extractPredictionLayerParams:s}}function a9(n){var t=[],e=lo(n),r=e.extractWeights,o=e.getRemainingWeights,a=o9(r,t),i=a.extractMobilenetV1Params,s=a.extractPredictionLayerParams,u=i(),c=s(),l=jf(r(5118*4),[1,5118,4]),d={extra_dim:l};if(t.push({paramPath:"output_layer/extra_dim"}),o().length!==0)throw new Error("weights remaing after extract: "+o().length);return{params:{mobilenetv1:u,prediction_layer:c,output_layer:d},paramMappings:t}}function i9(n,t){var e=zo(n,t);function r(c,l,d){var f=e(c+"/Conv2d_"+l+"_pointwise/weights",4,d+"/filters"),h=e(c+"/Conv2d_"+l+"_pointwise/convolution_bn_offset",1,d+"/batch_norm_offset");return{filters:f,batch_norm_offset:h}}function o(c){var l="mobilenetv1/conv_"+c,d="MobilenetV1/Conv2d_"+c+"_depthwise",f=l+"/depthwise_conv",h=l+"/pointwise_conv",m=e(d+"/depthwise_weights",4,f+"/filters"),p=e(d+"/BatchNorm/gamma",1,f+"/batch_norm_scale"),v=e(d+"/BatchNorm/beta",1,f+"/batch_norm_offset"),g=e(d+"/BatchNorm/moving_mean",1,f+"/batch_norm_mean"),y=e(d+"/BatchNorm/moving_variance",1,f+"/batch_norm_variance");return{depthwise_conv:{filters:m,batch_norm_scale:p,batch_norm_offset:v,batch_norm_mean:g,batch_norm_variance:y},pointwise_conv:r("MobilenetV1",c,h)}}function a(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:o(1),conv_2:o(2),conv_3:o(3),conv_4:o(4),conv_5:o(5),conv_6:o(6),conv_7:o(7),conv_8:o(8),conv_9:o(9),conv_10:o(10),conv_11:o(11),conv_12:o(12),conv_13:o(13)}}function i(c,l){var d=e(c+"/weights",4,l+"/filters"),f=e(c+"/biases",1,l+"/bias");return{filters:d,bias:f}}function s(c){var l=i("Prediction/BoxPredictor_"+c+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+c+"/box_encoding_predictor"),d=i("Prediction/BoxPredictor_"+c+"/ClassPredictor","prediction_layer/box_predictor_"+c+"/class_predictor");return{box_encoding_predictor:l,class_predictor:d}}function u(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:s(0),box_predictor_1:s(1),box_predictor_2:s(2),box_predictor_3:s(3),box_predictor_4:s(4),box_predictor_5:s(5)}}return{extractMobilenetV1Params:a,extractPredictionLayerParams:u}}function s9(n){var t=[],e=i9(n,t),r=e.extractMobilenetV1Params,o=e.extractPredictionLayerParams,a=n["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!hl(a))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+a);var i={mobilenetv1:r(),prediction_layer:o(),output_layer:{extra_dim:a}};return co(n,t),{params:i,paramMappings:t}}function Ur(n,t,e){return xe(function(){var r=Zn(n,t.filters,e,"same");return r=qe(r,t.batch_norm_offset),lh(r,0,6)})}var u9=.0010000000474974513;function c9(n,t,e){return xe(function(){var r=al(n,t.filters,e,"same");return r=z1(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,u9),lh(r,0,6)})}function l9(n){return[2,4,6,12].some(function(t){return t===n})?[2,2]:[1,1]}function d9(n,t){return xe(function(){var e=null,r=Ur(n,t.conv_0,[2,2]),o=[t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13];if(o.forEach(function(a,i){var s=i+1,u=l9(s);r=c9(r,a.depthwise_conv,u),r=Ur(r,a.pointwise_conv,[1,1]),s===11&&(e=r)}),e===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:e}})}function f9(n,t,e,r,o){var a=n.shape[0],i=Math.min(e,a),s=t.map(function(l,d){return{score:l,boxIndex:d}}).filter(function(l){return l.score>o}).sort(function(l,d){return d.score-l.score}),u=function(l){return l<=r?1:0},c=[];return s.forEach(function(l){if(!(c.length>=i)){for(var d=l.score,f=c.length-1;f>=0;--f){var h=h9(n,l.boxIndex,c[f]);if(h!==0&&(l.score*=u(h),l.score<=o))break}d===l.score&&c.push(l.boxIndex)}}),c}function h9(n,t,e){var r=n.arraySync(),o=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),i=Math.max(r[t][0],r[t][2]),s=Math.max(r[t][1],r[t][3]),u=Math.min(r[e][0],r[e][2]),c=Math.min(r[e][1],r[e][3]),l=Math.max(r[e][0],r[e][2]),d=Math.max(r[e][1],r[e][3]),f=(i-o)*(s-a),h=(l-u)*(d-c);if(f<=0||h<=0)return 0;var m=Math.max(o,u),p=Math.max(a,c),v=Math.min(i,l),g=Math.min(s,d),y=Math.max(v-m,0)*Math.max(g-p,0);return y/(f+h-y)}function p9(n){var t=jt(Bo(n,[1,0])),e=[zt(t[2],t[0]),zt(t[3],t[1])],r=[qe(t[0],ur(e[0],ve(2))),qe(t[1],ur(e[1],ve(2)))];return{sizes:e,centers:r}}function v9(n,t){var e=p9(n),r=e.sizes,o=e.centers,a=jt(Bo(t,[1,0])),i=ur(cn(dh(ur(a[2],ve(5))),r[0]),ve(2)),s=qe(cn(ur(a[0],ve(10)),r[0]),o[0]),u=ur(cn(dh(ur(a[3],ve(5))),r[1]),ve(2)),c=qe(cn(ur(a[1],ve(10)),r[1]),o[1]);return Bo(Bn([zt(s,i),zt(c,u),qe(s,i),qe(c,u)]),[1,0])}function m9(n,t,e){return xe(function(){var r=n.shape[0],o=v9(ir(_i(e.extra_dim,[r,1,1]),[-1,4]),ir(n,[-1,4]));o=ir(o,[r,o.shape[0]/r,4]);var a=W1(Br(t,[0,0,1],[-1,-1,-1])),i=Br(a,[0,0,0],[-1,-1,1]);i=ir(i,[r,i.shape[1]]);var s=jt(o),u=jt(i);return{boxes:s,scores:u}})}function Ri(n,t){return xe(function(){var e=n.shape[0],r=ir(cr(n,t.box_encoding_predictor),[e,-1,1,4]),o=ir(cr(n,t.class_predictor),[e,-1,3]);return{boxPredictionEncoding:r,classPrediction:o}})}function g9(n,t,e){return xe(function(){var r=Ur(n,e.conv_0,[1,1]),o=Ur(r,e.conv_1,[2,2]),a=Ur(o,e.conv_2,[1,1]),i=Ur(a,e.conv_3,[2,2]),s=Ur(i,e.conv_4,[1,1]),u=Ur(s,e.conv_5,[2,2]),c=Ur(u,e.conv_6,[1,1]),l=Ur(c,e.conv_7,[2,2]),d=Ri(t,e.box_predictor_0),f=Ri(n,e.box_predictor_1),h=Ri(o,e.box_predictor_2),m=Ri(i,e.box_predictor_3),p=Ri(u,e.box_predictor_4),v=Ri(l,e.box_predictor_5),g=Vt([d.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding,m.boxPredictionEncoding,p.boxPredictionEncoding,v.boxPredictionEncoding],1),y=Vt([d.classPrediction,f.classPrediction,h.classPrediction,m.classPrediction,p.classPrediction,v.classPrediction],1);return{boxPredictions:g,classPredictions:y}})}var ou=function(){function n(t){var e=t===void 0?{}:t,r=e.minConfidence,o=e.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=r||.5,this._maxResults=o||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(n.prototype,"minConfidence",{get:function(){return this._minConfidence},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxResults",{get:function(){return this._maxResults},enumerable:!0,configurable:!0}),n}(),x2=function(n){De(t,n);function t(){return n.call(this,"SsdMobilenetv1")||this}return t.prototype.forwardInput=function(e){var r=this.params;if(!r)throw new Error("SsdMobilenetv1 - load model before inference");return xe(function(){var o=e.toBatchTensor(512,!1).toFloat(),a=zt(cn(o,ve(.007843137718737125)),ve(1)),i=d9(a,r.mobilenetv1),s=g9(i.out,i.conv11,r.prediction_layer),u=s.boxPredictions,c=s.classPredictions;return m9(u,c,r.output_layer)})},t.prototype.forward=function(e){return $e(this,void 0,void 0,function(){var r;return ke(this,function(o){switch(o.label){case 0:return r=this.forwardInput,[4,Yt(e)];case 1:return[2,r.apply(this,[o.sent()])]}})})},t.prototype.locateFaces=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:return o=new ou(r),a=o.maxResults,i=o.minConfidence,[4,Yt(e)];case 1:for(s=N.sent(),u=this.forwardInput(s),c=u.boxes,l=u.scores,d=c[0],f=l[0],h=1;h<c.length;h++)c[h].dispose(),l[h].dispose();return v=(p=Array).from,[4,f.data()];case 2:return m=v.apply(p,[N.sent()]),g=.5,y=f9(d,m,a,g,i),w=s.getReshapedInputDimensions(0),x=s.inputSize,C=x/w.width,_=x/w.height,E=d.arraySync(),S=y.map(function($){var A=[Math.max(0,E[$][0]),Math.min(1,E[$][2])].map(function(F){return F*_}),P=A[0],j=A[1],B=[Math.max(0,E[$][1]),Math.min(1,E[$][3])].map(function(F){return F*C}),z=B[0],H=B[1];return new Wr(m[$],new Uh(z,P,H-z,j-P),{height:s.getInputHeight(0),width:s.getInputWidth(0)})}),d.dispose(),f.dispose(),[2,S]}})})},t.prototype.getDefaultModelName=function(){return"ssd_mobilenetv1_model"},t.prototype.extractParamsFromWeigthMap=function(e){return s9(e)},t.prototype.extractParams=function(e){return a9(e)},t}(uo);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(x2);var y9=.4,b9=[new ot(.738768,.874946),new ot(2.42204,2.65704),new ot(4.30971,7.04493),new ot(10.246,4.59428),new ot(12.6868,11.8741)],x9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],w9=[117.001,114.697,97.404],C9="tiny_yolov2_model",_9="tiny_yolov2_separable_conv_model",_l=function(n){return typeof n=="number"};function E9(n){if(!n)throw new Error("invalid config: "+n);if(typeof n.withSeparableConvs!="boolean")throw new Error("config.withSeparableConvs has to be a boolean, have: "+n.withSeparableConvs);if(!_l(n.iouThreshold)||n.iouThreshold<0||n.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+n.iouThreshold);if(!Array.isArray(n.classes)||!n.classes.length||!n.classes.every(function(t){return typeof t=="string"}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(n.classes));if(!Array.isArray(n.anchors)||!n.anchors.length||!n.anchors.map(function(t){return t||{}}).every(function(t){return _l(t.x)&&_l(t.y)}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(n.anchors));if(n.meanRgb&&(!Array.isArray(n.meanRgb)||n.meanRgb.length!==3||!n.meanRgb.every(_l)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(n.meanRgb))}function rp(n){return xe(function(){var t=cn(n,ve(.10000000149011612));return qe(wt(zt(n,t)),t)})}function Ho(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=Zn(e,t.conv.filters,[1,1],"valid"),e=zt(e,t.bn.sub),e=cn(e,t.bn.truediv),e=qe(e,t.conv.bias),rp(e)})}function Go(n,t){return xe(function(){var e=Ia(n,[[0,0],[1,1],[1,1],[0,0]]);return e=mh(e,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),e=qe(e,t.bias),rp(e)})}function S9(n,t){var e=xl(n,t);function r(i,s){var u=Ot(n(i)),c=Ot(n(i));return t.push({paramPath:s+"/sub"},{paramPath:s+"/truediv"}),{sub:u,truediv:c}}function o(i,s,u){var c=e(i,s,3,u+"/conv"),l=r(s,u+"/bn");return{conv:c,bn:l}}var a=Qh(n,t);return{extractConvParams:e,extractConvWithBatchNormParams:o,extractSeparableConvParams:a}}function N9(n,t,e,r){var o=lo(n),a=o.extractWeights,i=o.getRemainingWeights,s=[],u=S9(a,s),c=u.extractConvParams,l=u.extractConvWithBatchNormParams,d=u.extractSeparableConvParams,f;if(t.withSeparableConvs){var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=t.isFirstLayerConv2d?c(h,m,3,"conv0"):d(h,m,"conv0"),E=d(m,p,"conv1"),S=d(p,v,"conv2"),N=d(v,g,"conv3"),$=d(g,y,"conv4"),A=d(y,w,"conv5"),P=x?d(w,x,"conv6"):void 0,j=C?d(x,C,"conv7"):void 0,B=c(C||x||w,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}else{var h=r[0],m=r[1],p=r[2],v=r[3],g=r[4],y=r[5],w=r[6],x=r[7],C=r[8],_=l(h,m,"conv0"),E=l(m,p,"conv1"),S=l(p,v,"conv2"),N=l(v,g,"conv3"),$=l(g,y,"conv4"),A=l(y,w,"conv5"),P=l(w,x,"conv6"),j=l(x,C,"conv7"),B=c(C,5*e,1,"conv8");f={conv0:_,conv1:E,conv2:S,conv3:N,conv4:$,conv5:A,conv6:P,conv7:j,conv8:B}}if(i().length!==0)throw new Error("weights remaing after extract: "+i().length);return{params:f,paramMappings:s}}function $9(n,t){var e=zo(n,t);function r(s){var u=e(s+"/sub",1),c=e(s+"/truediv",1);return{sub:u,truediv:c}}function o(s){var u=e(s+"/filters",4),c=e(s+"/bias",1);return{filters:u,bias:c}}function a(s){var u=o(s+"/conv"),c=r(s+"/bn");return{conv:u,bn:c}}var i=Jh(e);return{extractConvParams:o,extractConvWithBatchNormParams:a,extractSeparableConvParams:i}}function k9(n,t){var e=[],r=$9(n,e),o=r.extractConvParams,a=r.extractConvWithBatchNormParams,i=r.extractSeparableConvParams,s;if(t.withSeparableConvs){var u=t.filterSizes&&t.filterSizes.length||9;s={conv0:t.isFirstLayerConv2d?o("conv0"):i("conv0"),conv1:i("conv1"),conv2:i("conv2"),conv3:i("conv3"),conv4:i("conv4"),conv5:i("conv5"),conv6:u>7?i("conv6"):void 0,conv7:u>8?i("conv7"):void 0,conv8:o("conv8")}}else s={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:o("conv8")};return co(n,e),{params:s,paramMappings:e}}var w2;(function(n){n[n.XS=224]="XS",n[n.SM=320]="SM",n[n.MD=416]="MD",n[n.LG=608]="LG"})(w2||(w2={}));var op=function(){function n(t){var e=t===void 0?{}:t,r=e.inputSize,o=e.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=r||416,this._scoreThreshold=o||.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(n.prototype,"inputSize",{get:function(){return this._inputSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scoreThreshold",{get:function(){return this._scoreThreshold},enumerable:!0,configurable:!0}),n}(),C2=function(n){De(t,n);function t(e){var r=n.call(this,"TinyYolov2")||this;return E9(e),r._config=e,r}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"withClassScores",{get:function(){return this.config.withClassScores||this.config.classes.length>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boxEncodingSize",{get:function(){return 5+(this.withClassScores?this.config.classes.length:0)},enumerable:!0,configurable:!0}),t.prototype.runTinyYolov2=function(e,r){var o=Ho(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Ho(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=Ho(o,r.conv6),o=Ho(o,r.conv7),cr(o,r.conv8,"valid",!1)},t.prototype.runMobilenet=function(e,r){var o=this.config.isFirstLayerConv2d?rp(cr(e,r.conv0,"valid",!1)):Go(e,r.conv0);return o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv1),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv2),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv3),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv4),o=Kt(o,[2,2],[2,2],"same"),o=Go(o,r.conv5),o=Kt(o,[2,2],[1,1],"same"),o=r.conv6?Go(o,r.conv6):o,o=r.conv7?Go(o,r.conv7):o,cr(o,r.conv8,"valid",!1)},t.prototype.forwardInput=function(e,r){var o=this,a=this.params;if(!a)throw new Error("TinyYolov2 - load model before inference");return xe(function(){var i=e.toBatchTensor(r,!1).toFloat();return i=o.config.meanRgb?ru(i,o.config.meanRgb):i,i=i.div(ve(256)),o.config.withSeparableConvs?o.runMobilenet(i,a):o.runTinyYolov2(i,a)})},t.prototype.forward=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent()]}})})},t.prototype.detect=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y=this;return ke(this,function(w){switch(w.label){case 0:return o=new op(r),a=o.inputSize,i=o.scoreThreshold,[4,Yt(e)];case 1:return s=w.sent(),[4,this.forwardInput(s,a)];case 2:return u=w.sent(),c=xe(function(){return jt(u)[0].expandDims()}),l={width:s.getInputWidth(0),height:s.getInputHeight(0)},[4,this.extractBoxes(c,s.getReshapedInputDimensions(0),i)];case 3:return d=w.sent(),u.dispose(),c.dispose(),f=d.map(function(x){return x.box}),h=d.map(function(x){return x.score}),m=d.map(function(x){return x.classScore}),p=d.map(function(x){return y.config.classes[x.label]}),v=nu(f.map(function(x){return x.rescale(a)}),h,this.config.iouThreshold,!0),g=v.map(function(x){return new jb(h[x],m[x],p[x],f[x],l)}),[2,g]}})})},t.prototype.getDefaultModelName=function(){return""},t.prototype.extractParamsFromWeigthMap=function(e){return k9(e,this.config)},t.prototype.extractParams=function(e){var r=this.config.filterSizes||t.DEFAULT_FILTER_SIZES,o=r?r.length:void 0;if(o!==7&&o!==8&&o!==9)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+o+" filterSizes in config");return N9(e,this.config,this.boxEncodingSize,r)},t.prototype.extractBoxes=function(e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S,N,$,A,P,j,B,z,H,F,M=this;return ke(this,function(O){switch(O.label){case 0:return a=r.width,i=r.height,s=Math.max(a,i),u=s/a,c=s/i,l=e.shape[1],d=this.config.anchors.length,f=xe(function(){var I=e.reshape([l,l,d,M.boxEncodingSize]),L=I.slice([0,0,0,0],[l,l,d,4]),K=I.slice([0,0,0,4],[l,l,d,1]),q=M.withClassScores?oo(I.slice([0,0,0,5],[l,l,d,M.config.classes.length]),3):ve(0);return[L,K,q]}),h=f[0],m=f[1],p=f[2],v=[],[4,m.array()];case 1:return g=O.sent(),[4,h.array()];case 2:y=O.sent(),w=0,O.label=3;case 3:if(!(w<l))return[3,12];x=0,O.label=4;case 4:if(!(x<l))return[3,11];C=0,O.label=5;case 5:return C<d?(_=jh(g[w][x][C][0]),!o||_>o?(E=(x+jh(y[w][x][C][0]))/l*u,S=(w+jh(y[w][x][C][1]))/l*c,N=Math.exp(y[w][x][C][2])*this.config.anchors[C].x/l*u,$=Math.exp(y[w][x][C][3])*this.config.anchors[C].y/l*c,A=E-N/2,P=S-$/2,j={row:w,col:x,anchor:C},this.withClassScores?[4,this.extractPredictedClass(p,j)]:[3,7]):[3,9]):[3,10];case 6:return F=O.sent(),[3,8];case 7:F={classScore:1,label:0},O.label=8;case 8:B=F,z=B.classScore,H=B.label,v.push(dn({box:new pl(A,P,A+N,P+$),score:_,classScore:_*z,label:H},j)),O.label=9;case 9:return C++,[3,5];case 10:return x++,[3,4];case 11:return w++,[3,3];case 12:return h.dispose(),m.dispose(),p.dispose(),[2,v]}})})},t.prototype.extractPredictedClass=function(e,r){return $e(this,void 0,void 0,function(){var o,a,i,s;return ke(this,function(u){switch(u.label){case 0:return o=r.row,a=r.col,i=r.anchor,[4,e.array()];case 1:return s=u.sent(),[2,Array(this.config.classes.length).fill(0).map(function(c,l){return s[o][a][i][l]}).map(function(c,l){return{classScore:c,label:l}}).reduce(function(c,l){return c.classScore>l.classScore?c:l})]}})})},t.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],t}(uo),P9=function(n){De(t,n);function t(e){e===void 0&&(e=!0);var r=this,o=Object.assign({},{withSeparableConvs:e,iouThreshold:y9,classes:["face"]},e?{anchors:x9,meanRgb:w9}:{anchors:b9,withClassScores:!0});return r=n.call(this,o)||this,r}return Object.defineProperty(t.prototype,"withSeparableConvs",{get:function(){return this.config.withSeparableConvs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return this.withSeparableConvs?_9:C9},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),I9=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e._name="TinyFaceDetectorOptions",e}return t}(op),au=function(){function n(){}return n.prototype.then=function(t){return $e(this,void 0,void 0,function(){var e;return ke(this,function(r){switch(r.label){case 0:return e=t,[4,this.run()];case 1:return[2,e.apply(void 0,[r.sent()])]}})})},n.prototype.run=function(){return $e(this,void 0,void 0,function(){return ke(this,function(t){throw new Error("ComposableTask - run is not implemented")})})},n}();function El(n,t,e,r,o){return o===void 0&&(o=function(a){var i=a.alignedRect;return i}),$e(this,void 0,void 0,function(){var a,i,s,u,c;return ke(this,function(l){switch(l.label){case 0:return a=n.map(function(d){return R5(d)?o(d):d.detection}),s=r,s?[3,5]:t instanceof bt?[4,Yh(t,a)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,Kh(t,a)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return i=s,[4,e(i)];case 6:return c=l.sent(),i.forEach(function(d){return d instanceof bt&&d.dispose()}),[2,c]}})})}function ap(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a=this;return ke(this,function(i){return[2,El([n],t,function(s){return $e(a,void 0,void 0,function(){return ke(this,function(u){return[2,e(s[0])]})})},r,o)]})})}function A9(n){return xe(function(){return Bn(jt(n,3).reverse(),3)})}var Sl=2,Nl=12;function T9(n,t){var e=xl(n,t),r=Zh(n,t);function o(c,l){var d=Ot(n(c));return t.push({paramPath:l}),d}function a(c,l,d){d===void 0&&(d=!1);var f=e(c[0],c[1],3,l+"/conv1"),h=o(c[1],l+"/prelu1_alpha"),m=e(c[1],c[2],3,l+"/conv2"),p=o(c[2],l+"/prelu2_alpha"),v=e(c[2],c[3],d?2:3,l+"/conv3"),g=o(c[3],l+"/prelu3_alpha");return{conv1:f,prelu1_alpha:h,conv2:m,prelu2_alpha:p,conv3:v,prelu3_alpha:g}}function i(){var c=a([3,10,16,32],"pnet"),l=e(32,2,1,"pnet/conv4_1"),d=e(32,4,1,"pnet/conv4_2");return dn(dn({},c),{conv4_1:l,conv4_2:d})}function s(){var c=a([3,28,48,64],"rnet",!0),l=r(576,128,"rnet/fc1"),d=o(128,"rnet/prelu4_alpha"),f=r(128,2,"rnet/fc2_1"),h=r(128,4,"rnet/fc2_2");return dn(dn({},c),{fc1:l,prelu4_alpha:d,fc2_1:f,fc2_2:h})}function u(){var c=a([3,32,64,64],"onet"),l=e(64,128,2,"onet/conv4"),d=o(128,"onet/prelu4_alpha"),f=r(1152,256,"onet/fc1"),h=o(256,"onet/prelu5_alpha"),m=r(256,2,"onet/fc2_1"),p=r(256,4,"onet/fc2_2"),v=r(256,10,"onet/fc2_3");return dn(dn({},c),{conv4:l,prelu4_alpha:d,fc1:f,prelu5_alpha:h,fc2_1:m,fc2_2:p,fc2_3:v})}return{extractPNetParams:i,extractRNetParams:s,extractONetParams:u}}function O9(n){var t=lo(n),e=t.extractWeights,r=t.getRemainingWeights,o=[],a=T9(e,o),i=a.extractPNetParams,s=a.extractRNetParams,u=a.extractONetParams,c=i(),l=s(),d=u();if(r().length!==0)throw new Error("weights remaing after extract: "+r().length);return{params:{pnet:c,rnet:l,onet:d},paramMappings:o}}function D9(n,t){var e=zo(n,t);function r(l){var d=e(l+"/weights",4,l+"/filters"),f=e(l+"/bias",1);return{filters:d,bias:f}}function o(l){var d=e(l+"/weights",2),f=e(l+"/bias",1);return{weights:d,bias:f}}function a(l){return e(l,1)}function i(l){var d=r(l+"/conv1"),f=a(l+"/prelu1_alpha"),h=r(l+"/conv2"),m=a(l+"/prelu2_alpha"),p=r(l+"/conv3"),v=a(l+"/prelu3_alpha");return{conv1:d,prelu1_alpha:f,conv2:h,prelu2_alpha:m,conv3:p,prelu3_alpha:v}}function s(){var l=i("pnet"),d=r("pnet/conv4_1"),f=r("pnet/conv4_2");return dn(dn({},l),{conv4_1:d,conv4_2:f})}function u(){var l=i("rnet"),d=o("rnet/fc1"),f=a("rnet/prelu4_alpha"),h=o("rnet/fc2_1"),m=o("rnet/fc2_2");return dn(dn({},l),{fc1:d,prelu4_alpha:f,fc2_1:h,fc2_2:m})}function c(){var l=i("onet"),d=r("onet/conv4"),f=a("onet/prelu4_alpha"),h=o("onet/fc1"),m=a("onet/prelu5_alpha"),p=o("onet/fc2_1"),v=o("onet/fc2_2"),g=o("onet/fc2_3");return dn(dn({},l),{conv4:d,prelu4_alpha:f,fc1:h,prelu5_alpha:m,fc2_1:p,fc2_2:v,fc2_3:g})}return{extractPNetParams:s,extractRNetParams:u,extractONetParams:c}}function M9(n){var t=[],e=D9(n,t),r=e.extractPNetParams,o=e.extractRNetParams,a=e.extractONetParams,i=r(),s=o(),u=a();return co(n,t),{params:{pnet:i,rnet:s,onet:u},paramMappings:t}}function ip(n,t){var e=t[0],r=t[1];return{height:Math.floor(e*n),width:Math.floor(r*n)}}function F9(n,t,e){for(var r=e[0],o=e[1],a=Nl/n,i=[],s=Math.min(r,o)*a,u=0;s>=12;)i.push(a*Math.pow(t,u)),s=s*t,u+=1;return i}var sp=function(n){De(t,n);function t(e,r,o,a){return n.call(this,{left:e,top:r,right:o,bottom:a},!0)||this}return t}(Uo);function _2(n){return xe(function(){return cn(zt(n,ve(127.5)),ve(.0078125))})}function Li(n,t){return xe(function(){return qe(wt(n),cn(t,el(wt(el(n)))))})}function up(n,t,e){return e===void 0&&(e=!1),xe(function(){var r=cr(n,t.conv1,"valid");return r=Li(r,t.prelu1_alpha),r=Kt(r,e?[2,2]:[3,3],[2,2],"same"),r=cr(r,t.conv2,"valid"),r=Li(r,t.prelu2_alpha),r=e?r:Kt(r,[3,3],[2,2],"valid"),r=cr(r,t.conv3,"valid"),r=Li(r,t.prelu3_alpha),r})}function R9(n,t){return xe(function(){var e=up(n,t,!0),r=cr(e,t.conv4_1,"valid"),o=Xn(sl(r,3),3),a=oo(zt(r,o),3),i=cr(e,t.conv4_2,"valid");return{prob:a,regions:i}})}function L9(n,t){return xe(function(){var e=ip(t,n.shape.slice(1)),r=e.height,o=e.width,a=wh.resizeBilinear(n,[r,o]),i=_2(a);return Bo(i,[0,2,1,3])})}function B9(n,t,e,r){for(var o=[],a=n.arraySync(),i=0;i<n.shape[0];i++)for(var s=0;s<n.shape[1];s++)a[i][s]>=r&&o.push(new ot(s,i));var u=o.map(function(c){var l=new pl(Math.round((c.y*Sl+1)/e),Math.round((c.x*Sl+1)/e),Math.round((c.y*Sl+Nl)/e),Math.round((c.x*Sl+Nl)/e)),d=a[c.y][c.x],f=t.arraySync(),h=new sp(f[c.y][c.x][0],f[c.y][c.x][1],f[c.y][c.x][2],f[c.y][c.x][3]);return{cell:l,score:d,region:h}});return u}function W9(n,t,e,r,o){o.stage1=[];var a=t.map(function(f){return xe(function(){var h={scale:f},m=L9(n,f),p=Date.now(),v=R9(m,r),g=v.prob,y=v.regions;h.pnet=Date.now()-p;var w=jt(jt(g,3)[1])[0],x=jt(y)[0];return{scoresTensor:w,regionsTensor:x,scale:f,statsForScale:h}})}),i=a.map(function(f){var h=f.scoresTensor,m=f.regionsTensor,p=f.scale,v=f.statsForScale,g=B9(h,m,p,e);if(h.dispose(),m.dispose(),!g.length)return o.stage1.push(v),[];var y=Date.now(),w=nu(g.map(function(x){return x.cell}),g.map(function(x){return x.score}),.5);return v.nms=Date.now()-y,v.numBoxes=w.length,o.stage1.push(v),w.map(function(x){return g[x]})}),s=i.reduce(function(f,h){return f.concat(h)},[]),u=[],c=[];if(s.length>0){var l=Date.now(),d=nu(s.map(function(f){return f.cell}),s.map(function(f){return f.score}),.7);o.stage1_nms=Date.now()-l,c=d.map(function(f){return s[f].score}),u=d.map(function(f){return s[f]}).map(function(f){var h=f.cell,m=f.region;return new pl(h.left+m.left*h.width,h.top+m.top*h.height,h.right+m.right*h.width,h.bottom+m.bottom*h.height).toSquare().round()})}return{boxes:u,scores:c}}function E2(n,t,e){var r=e.width,o=e.height;return $e(this,void 0,void 0,function(){var a,i,s,u=this;return ke(this,function(c){switch(c.label){case 0:return a=Ba(n),[4,Promise.all(t.map(function(l){return $e(u,void 0,void 0,function(){var d,f,h,m,p,v,g,y;return ke(this,function(w){return d=l.padAtBorders(n.height,n.width),f=d.y,h=d.ey,m=d.x,p=d.ex,v=m-1,g=f-1,y=a.getImageData(v,g,p-v,h-g),[2,rn.isNodejs()?qh(y):createImageBitmap(y)]})})}))];case 1:return i=c.sent(),s=[],i.forEach(function(l){var d=gl({width:r,height:o}),f=Ba(d);f.drawImage(l,0,0,r,o);for(var h=f.getImageData(0,0,r,o).data,m=[],p=0;p<h.length;p+=4)m.push(h[p+2]),m.push(h[p+1]),m.push(h[p]);s.push(m)}),[2,s.map(function(l){var d=xe(function(){var f=Bo(Sn(l,[1,r,o,3]),[0,2,1,3]).toFloat();return _2(f)});return d})]}})})}function V9(n,t){return xe(function(){var e=up(n,t),r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu4_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=jt(u,1)[1];return{scores:l,regions:c}})}function j9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y;return ke(this,function(w){switch(w.label){case 0:return a=Date.now(),[4,E2(n,t,{width:24,height:24})];case 1:return i=w.sent(),o.stage2_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(x){var C=V9(x,r);return x.dispose(),C}),o.stage2_rnet=Date.now()-a,u=s.length>1?Vt(s.map(function(x){return x.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[w.sent()]),u.dispose(),f=c.map(function(x,C){return{score:x,idx:C}}).filter(function(x){return x.score>e}).map(function(x){var C=x.idx;return C}),h=f.map(function(x){return t[x]}),m=f.map(function(x){return c[x]}),p=[],v=[],h.length>0&&(a=Date.now(),g=nu(h,m,.7),o.stage2_nms=Date.now()-a,y=g.map(function(x){var C=s[f[x]].regions.arraySync();return new sp(C[0][0],C[0][1],C[0][2],C[0][3])}),v=g.map(function(x){return m[x]}),p=g.map(function(x,C){return h[x].calibrate(y[C])})),s.forEach(function(x){x.regions.dispose(),x.scores.dispose()}),[2,{boxes:p,scores:v}]}})})}function U9(n,t){return xe(function(){var e=up(n,t);e=Kt(e,[2,2],[2,2],"same"),e=cr(e,t.conv4,"valid"),e=Li(e,t.prelu4_alpha);var r=ir(e,[e.shape[0],t.fc1.weights.shape[0]]),o=Vr(r,t.fc1),a=Li(o,t.prelu5_alpha),i=Vr(a,t.fc2_1),s=Xn(sl(i,1),1),u=oo(zt(i,s),1),c=Vr(a,t.fc2_2),l=Vr(a,t.fc2_3),d=jt(u,1)[1];return{scores:d,regions:c,points:l}})}function z9(n,t,e,r,o){return $e(this,void 0,void 0,function(){var a,i,s,u,c,l,d,f,h,m,p,v,g,y,w;return ke(this,function(x){switch(x.label){case 0:return a=Date.now(),[4,E2(n,t,{width:48,height:48})];case 1:return i=x.sent(),o.stage3_extractImagePatches=Date.now()-a,a=Date.now(),s=i.map(function(C){var _=U9(C,r);return C.dispose(),_}),o.stage3_onet=Date.now()-a,u=s.length>1?Vt(s.map(function(C){return C.scores})):s[0].scores,d=(l=Array).from,[4,u.data()];case 2:return c=d.apply(l,[x.sent()]),u.dispose(),f=c.map(function(C,_){return{score:C,idx:_}}).filter(function(C){return C.score>e}).map(function(C){var _=C.idx;return _}),h=f.map(function(C){var _=s[C].regions.arraySync();return new sp(_[0][0],_[0][1],_[0][2],_[0][3])}),m=f.map(function(C,_){return t[C].calibrate(h[_])}),p=f.map(function(C){return c[C]}),v=[],g=[],y=[],m.length>0&&(a=Date.now(),w=nu(m,p,.7,!1),o.stage3_nms=Date.now()-a,v=w.map(function(C){return m[C]}),g=w.map(function(C){return p[C]}),y=w.map(function(C,_){return Array(5).fill(0).map(function(E,S){var N=s[C].points.arraySync();return new ot(N[0][S]*(v[_].width+1)+v[_].left,N[0][S+5]*(v[_].height+1)+v[_].top)})})),s.forEach(function(C){C.regions.dispose(),C.scores.dispose(),C.points.dispose()}),[2,{boxes:v,scores:g,points:y}]}})})}var H9=function(n){De(t,n);function t(){return n.call(this,"Mtcnn")||this}return t.prototype.load=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.load.call(this,e)]})})},t.prototype.loadFromDisk=function(e){return $e(this,void 0,void 0,function(){return ke(this,function(r){return console.warn("mtcnn is deprecated and will be removed soon"),[2,n.prototype.loadFromDisk.call(this,e)]})})},t.prototype.forwardInput=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o,a,i,s,u,c,l,d,f,h,m,p,v,g,y,w,x,C,_,E,S;return ke(this,function(N){switch(N.label){case 0:if(o=this.params,!o)throw new Error("Mtcnn - load model before inference");if(a=e.canvases[0],!a)throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return i={},s=Date.now(),u=xe(function(){return A9(Xn(Bh.fromPixels(a)).toFloat())}),c=function($){return u.dispose(),i.total=Date.now()-s,$},l=u.shape.slice(1),d=l[0],f=l[1],h=new b2(r),m=h.minFaceSize,p=h.scaleFactor,v=h.maxNumScales,g=h.scoreThresholds,y=h.scaleSteps,w=(y||F9(m,p,[d,f])).filter(function($){var A=ip($,[d,f]);return Math.min(A.width,A.height)>Nl}).slice(0,v),i.scales=w,i.pyramid=w.map(function($){return ip($,[d,f])}),x=Date.now(),[4,W9(u,w,g[0],o.pnet,i)];case 1:return C=N.sent(),i.total_stage1=Date.now()-x,C.boxes.length?(i.stage2_numInputBoxes=C.boxes.length,x=Date.now(),[4,j9(a,C.boxes,g[1],o.rnet,i)]):[2,c({results:[],stats:i})];case 2:return _=N.sent(),i.total_stage2=Date.now()-x,_.boxes.length?(i.stage3_numInputBoxes=_.boxes.length,x=Date.now(),[4,z9(a,_.boxes,g[2],o.onet,i)]):[2,c({results:[],stats:i})];case 3:return E=N.sent(),i.total_stage3=Date.now()-x,S=E.boxes.map(function($,A){return ep(zh({},new Wr(E.scores[A],new Uh($.left/f,$.top/d,$.width/f,$.height/d),{height:d,width:f})),new x5(E.points[A].map(function(P){return P.sub(new ot($.left,$.top)).div(new ot($.width,$.height))}),{width:$.width,height:$.height}))}),[2,c({results:S,stats:i})]}})})},t.prototype.forward=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[4,o.apply(this,[a.sent(),r])];case 2:return[2,a.sent().results]}})})},t.prototype.forwardWithStats=function(e,r){return r===void 0&&(r={}),$e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return o=this.forwardInput,[4,Yt(e)];case 1:return[2,o.apply(this,[a.sent(),r])]}})})},t.prototype.getDefaultModelName=function(){return"mtcnn_model"},t.prototype.extractParamsFromWeigthMap=function(e){return M9(e)},t.prototype.extractParams=function(e){return O9(e)},t}(uo),G9=.4,q9=[new ot(1.603231,2.094468),new ot(6.041143,7.080126),new ot(2.882459,3.518061),new ot(4.266906,5.178857),new ot(9.041765,10.66308)],K9=[117.001,114.697,97.404],Y9=function(n){De(t,n);function t(){var e=this,r={withSeparableConvs:!0,iouThreshold:G9,classes:["face"],anchors:q9,meanRgb:K9,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return e=n.call(this,r)||this,e}return Object.defineProperty(t.prototype,"anchors",{get:function(){return this.config.anchors},enumerable:!0,configurable:!0}),t.prototype.locateFaces=function(e,r){return $e(this,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.detect(e,r)];case 1:return o=a.sent(),[2,o.map(function(i){return new Wr(i.score,i.relativeBox,{width:i.imageWidth,height:i.imageHeight})})]}})})},t.prototype.getDefaultModelName=function(){return"tiny_face_detector_model"},t.prototype.extractParamsFromWeigthMap=function(e){return n.prototype.extractParamsFromWeigthMap.call(this,e)},t}(C2),mn={ssdMobilenetv1:new x2,tinyFaceDetector:new Y9,tinyYolov2:new P9,mtcnn:new H9,faceLandmark68Net:new h2,faceLandmark68TinyNet:new X5,faceRecognitionNet:new r9,faceExpressionNet:new F5,ageGenderNet:new G5},S2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),cp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.faceExpressionNet.predictExpressions(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){return l2(i,r[s])})]}})})},t.prototype.withAgeAndGender=function(){return new hp(this,this.input)},t}(S2),lp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceExpressionNet.predictExpressions(a)},this.extractedFaces)]:[2];case 2:return r=o.sent(),[2,l2(e,r)]}})})},t.prototype.withAgeAndGender=function(){return new pp(this,this.input)},t}(S2),dp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(cp),fp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(lp),N2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.extractedFaces=o,a}return t}(au),hp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o=this;return ke(this,function(a){switch(a.label){case 0:return[4,this.parentTask];case 1:return e=a.sent(),[4,El(e,this.input,function(i){return $e(o,void 0,void 0,function(){return ke(this,function(s){switch(s.label){case 0:return[4,Promise.all(i.map(function(u){return mn.ageGenderNet.predictAgeAndGender(u)}))];case 1:return[2,s.sent()]}})})},this.extractedFaces)];case 2:return r=a.sent(),[2,e.map(function(i,s){var u=r[s],c=u.age,l=u.gender,d=u.genderProbability;return g2(y2(i,l,d),c)})]}})})},t.prototype.withFaceExpressions=function(){return new cp(this,this.input)},t}(N2),pp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?[4,ap(e,this.input,function(u){return mn.ageGenderNet.predictAgeAndGender(u)},this.extractedFaces)]:[2];case 2:return r=s.sent(),o=r.age,a=r.gender,i=r.genderProbability,[2,g2(y2(e,a,i),o)]}})})},t.prototype.withFaceExpressions=function(){return new lp(this,this.input)},t}(N2),vp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(hp),mp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(pp),$2=function(n){De(t,n);function t(e,r){var o=n.call(this)||this;return o.parentTask=e,o.input=r,o}return t}(au),gp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),[4,El(e,this.input,function(a){return Promise.all(a.map(function(i){return mn.faceRecognitionNet.computeFaceDescriptor(i)}))},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})];case 2:return r=o.sent(),[2,r.map(function(a,i){return m2(e[i],a)})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t}($2),yp=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,this.parentTask];case 1:return e=o.sent(),e?[4,ap(e,this.input,function(a){return mn.faceRecognitionNet.computeFaceDescriptor(a)},null,function(a){return a.landmarks.align(null,{useDlibAlignment:!0})})]:[2];case 2:return r=o.sent(),[2,m2(e,r)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t}($2),k2=function(n){De(t,n);function t(e,r,o){var a=n.call(this)||this;return a.parentTask=e,a.input=r,a.useTinyLandmarkNet=o,a}return Object.defineProperty(t.prototype,"landmarkNet",{get:function(){return this.useTinyLandmarkNet?mn.faceLandmark68TinyNet:mn.faceLandmark68Net},enumerable:!0,configurable:!0}),t}(au),X9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i,s=this;return ke(this,function(u){switch(u.label){case 0:return[4,this.parentTask];case 1:return e=u.sent(),r=e.map(function(c){return c.detection}),this.input instanceof bt?[4,Yh(this.input,r)]:[3,3];case 2:return a=u.sent(),[3,5];case 3:return[4,Kh(this.input,r)];case 4:a=u.sent(),u.label=5;case 5:return o=a,[4,Promise.all(o.map(function(c){return s.landmarkNet.detectLandmarks(c)}))];case 6:return i=u.sent(),o.forEach(function(c){return c instanceof bt&&c.dispose()}),[2,e.map(function(c,l){return ep(c,i[l])})]}})})},t.prototype.withFaceExpressions=function(){return new dp(this,this.input)},t.prototype.withAgeAndGender=function(){return new vp(this,this.input)},t.prototype.withFaceDescriptors=function(){return new gp(this,this.input)},t}(k2),Z9=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a,i;return ke(this,function(s){switch(s.label){case 0:return[4,this.parentTask];case 1:return e=s.sent(),e?(r=e.detection,this.input instanceof bt?[4,Yh(this.input,[r])]:[3,3]):[2];case 2:return a=s.sent(),[3,5];case 3:return[4,Kh(this.input,[r])];case 4:a=s.sent(),s.label=5;case 5:return o=a,[4,this.landmarkNet.detectLandmarks(o[0])];case 6:return i=s.sent(),o.forEach(function(u){return u instanceof bt&&u.dispose()}),[2,ep(e,i)]}})})},t.prototype.withFaceExpressions=function(){return new fp(this,this.input)},t.prototype.withAgeAndGender=function(){return new mp(this,this.input)},t.prototype.withFaceDescriptor=function(){return new yp(this,this.input)},t}(k2),P2=function(n){De(t,n);function t(e,r){r===void 0&&(r=new ou);var o=n.call(this)||this;return o.input=e,o.options=r,o}return t}(au),I2=function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r,o,a;return ke(this,function(i){switch(i.label){case 0:return e=this,r=e.input,o=e.options,o instanceof b2?[4,mn.mtcnn.forward(r,o)]:[3,2];case 1:return[2,i.sent().map(function(s){return s.detection})];case 2:if(a=o instanceof I9?function(s){return mn.tinyFaceDetector.locateFaces(s,o)}:o instanceof ou?function(s){return mn.ssdMobilenetv1.locateFaces(s,o)}:o instanceof op?function(s){return mn.tinyYolov2.locateFaces(s,o)}:null,!a)throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return[2,a(r)]}})})},t.prototype.runAndExtendWithFaceDetections=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o.map(function(i){return zh({},i)}))]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new X9(this.runAndExtendWithFaceDetections(),this.input,e)},t.prototype.withFaceExpressions=function(){return new cp(this.runAndExtendWithFaceDetections(),this.input)},t.prototype.withAgeAndGender=function(){return new hp(this.runAndExtendWithFaceDetections(),this.input)},t}(P2);(function(n){De(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.run=function(){return $e(this,void 0,void 0,function(){var e,r;return ke(this,function(o){switch(o.label){case 0:return[4,new I2(this.input,this.options)];case 1:return e=o.sent(),r=e[0],e.forEach(function(a){a.score>r.score&&(r=a)}),[2,r]}})})},t.prototype.runAndExtendWithFaceDetection=function(){var e=this;return new Promise(function(r){return $e(e,void 0,void 0,function(){var o;return ke(this,function(a){switch(a.label){case 0:return[4,this.run()];case 1:return o=a.sent(),[2,r(o?zh({},o):void 0)]}})})})},t.prototype.withFaceLandmarks=function(e){return e===void 0&&(e=!1),new Z9(this.runAndExtendWithFaceDetection(),this.input,e)},t.prototype.withFaceExpressions=function(){return new lp(this.runAndExtendWithFaceDetection(),this.input)},t.prototype.withAgeAndGender=function(){return new pp(this.runAndExtendWithFaceDetection(),this.input)},t})(P2);function Q9(n,t){return t===void 0&&(t=new ou),new I2(n,t)}function J9(n,t){if(n.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var e=Array.from(n),r=Array.from(t);return Math.sqrt(e.map(function(o,a){return o-r[a]}).reduce(function(o,a){return o+Math.pow(a,2)},0))}(function(){function n(t,e){e===void 0&&(e=.6),this._distanceThreshold=e;var r=Array.isArray(t)?t:[t];if(!r.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var o=1,a=function(){return"person "+o++};this._labeledDescriptors=r.map(function(i){if(i instanceof ml)return i;if(i instanceof Float32Array)return new ml(a(),[i]);if(i.descriptor&&i.descriptor instanceof Float32Array)return new ml(a(),[i.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>")})}return Object.defineProperty(n.prototype,"labeledDescriptors",{get:function(){return this._labeledDescriptors},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"distanceThreshold",{get:function(){return this._distanceThreshold},enumerable:!0,configurable:!0}),n.prototype.computeMeanDistance=function(t,e){return e.map(function(r){return J9(r,t)}).reduce(function(r,o){return r+o},0)/(e.length||1)},n.prototype.matchDescriptor=function(t){var e=this;return this.labeledDescriptors.map(function(r){var o=r.descriptors,a=r.label;return new Ub(a,e.computeMeanDistance(t,o))}).reduce(function(r,o){return r.distance<o.distance?r:o})},n.prototype.findBestMatch=function(t){var e=this.matchDescriptor(t);return e.distance<this.distanceThreshold?e:new Ub("unknown",e.distance)},n.prototype.toJSON=function(){return{distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(t){return t.toJSON()})}},n.fromJSON=function(t){var e=t.labeledDescriptors.map(function(r){return ml.fromJSON(r)});return new n(e,t.distanceThreshold)},n})();function fo(n){return Array.isArray?Array.isArray(n):O2(n)==="[object Array]"}function eD(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function tD(n){return n==null?"":eD(n)}function zr(n){return typeof n=="string"}function A2(n){return typeof n=="number"}function nD(n){return n===!0||n===!1||rD(n)&&O2(n)=="[object Boolean]"}function T2(n){return typeof n=="object"}function rD(n){return T2(n)&&n!==null}function jn(n){return n!=null}function bp(n){return!n.trim().length}function O2(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const oD="Incorrect 'index' type",aD=n=>`Invalid value for key ${n}`,iD=n=>`Pattern length exceeds max of ${n}.`,sD=n=>`Missing ${n} property in key`,uD=n=>`Property 'weight' in key '${n}' must be a positive integer`,D2=Object.prototype.hasOwnProperty;class cD{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(r=>{let o=M2(r);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(r=>{r.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function M2(n){let t=null,e=null,r=null,o=1,a=null;if(zr(n)||fo(n))r=n,t=F2(n),e=xp(n);else{if(!D2.call(n,"name"))throw new Error(sD("name"));const i=n.name;if(r=i,D2.call(n,"weight")&&(o=n.weight,o<=0))throw new Error(uD(i));t=F2(i),e=xp(i),a=n.getFn}return{path:t,id:e,weight:o,src:r,getFn:a}}function F2(n){return fo(n)?n:n.split(".")}function xp(n){return fo(n)?n.join("."):n}function lD(n,t){let e=[],r=!1;const o=(a,i,s)=>{if(jn(a))if(!i[s])e.push(a);else{let u=i[s];const c=a[u];if(!jn(c))return;if(s===i.length-1&&(zr(c)||A2(c)||nD(c)))e.push(tD(c));else if(fo(c)){r=!0;for(let l=0,d=c.length;l<d;l+=1)o(c[l],i,s+1)}else i.length&&o(c,i,s+1)}};return o(n,zr(t)?t.split("."):t,0),r?e:e[0]}var Ae={...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:lD,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const dD=/[^ ]+/g;function fD(n=1,t=3){const e=new Map,r=Math.pow(10,t);return{get(o){const a=o.match(dD).length;if(e.has(a))return e.get(a);const i=1/Math.pow(a,.5*n),s=parseFloat(Math.round(i*r)/r);return e.set(a,s),s},clear(){e.clear()}}}class wp{constructor({getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){this.norm=fD(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,r)=>{this._keysMap[e.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,zr(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();zr(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,r=this.size();e<r;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!jn(t)||bp(t))return;let r={v:t,i:e,n:this.norm.get(t)};this.records.push(r)}_addObject(t,e){let r={i:e,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(jn(i)){if(fo(i)){let s=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:c,value:l}=u.pop();if(jn(l))if(zr(l)&&!bp(l)){let d={v:l,i:c,n:this.norm.get(l)};s.push(d)}else fo(l)&&l.forEach((d,f)=>{u.push({nestedArrIndex:f,value:d})})}r.$[a]=s}else if(zr(i)&&!bp(i)){let s={v:i,n:this.norm.get(i)};r.$[a]=s}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function R2(n,t,{getFn:e=Ae.getFn,fieldNormWeight:r=Ae.fieldNormWeight}={}){const o=new wp({getFn:e,fieldNormWeight:r});return o.setKeys(n.map(M2)),o.setSources(t),o.create(),o}function hD(n,{getFn:t=Ae.getFn,fieldNormWeight:e=Ae.fieldNormWeight}={}){const{keys:r,records:o}=n,a=new wp({getFn:t,fieldNormWeight:e});return a.setKeys(r),a.setIndexRecords(o),a}function $l(n,{errors:t=0,currentLocation:e=0,expectedLocation:r=0,distance:o=Ae.distance,ignoreLocation:a=Ae.ignoreLocation}={}){const i=t/n.length;if(a)return i;const s=Math.abs(r-e);return o?i+s/o:s?1:i}function pD(n=[],t=Ae.minMatchCharLength){let e=[],r=-1,o=-1,a=0;for(let i=n.length;a<i;a+=1){let s=n[a];s&&r===-1?r=a:!s&&r!==-1&&(o=a-1,o-r+1>=t&&e.push([r,o]),r=-1)}return n[a-1]&&a-r>=t&&e.push([r,a-1]),e}const Wa=32;function vD(n,t,e,{location:r=Ae.location,distance:o=Ae.distance,threshold:a=Ae.threshold,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,includeMatches:u=Ae.includeMatches,ignoreLocation:c=Ae.ignoreLocation}={}){if(t.length>Wa)throw new Error(iD(Wa));const l=t.length,d=n.length,f=Math.max(0,Math.min(r,d));let h=a,m=f;const p=s>1||u,v=p?Array(d):[];let g;for(;(g=n.indexOf(t,m))>-1;){let E=$l(t,{currentLocation:g,expectedLocation:f,distance:o,ignoreLocation:c});if(h=Math.min(E,h),m=g+l,p){let S=0;for(;S<l;)v[g+S]=1,S+=1}}m=-1;let y=[],w=1,x=l+d;const C=1<<l-1;for(let E=0;E<l;E+=1){let S=0,N=x;for(;S<N;)$l(t,{errors:E,currentLocation:f+N,expectedLocation:f,distance:o,ignoreLocation:c})<=h?S=N:x=N,N=Math.floor((x-S)/2+S);x=N;let $=Math.max(1,f-N+1),A=i?d:Math.min(f+N,d)+l,P=Array(A+2);P[A+1]=(1<<E)-1;for(let B=A;B>=$;B-=1){let z=B-1,H=e[n.charAt(z)];if(p&&(v[z]=+!!H),P[B]=(P[B+1]<<1|1)&H,E&&(P[B]|=(y[B+1]|y[B])<<1|1|y[B+1]),P[B]&C&&(w=$l(t,{errors:E,currentLocation:z,expectedLocation:f,distance:o,ignoreLocation:c}),w<=h)){if(h=w,m=z,m<=f)break;$=Math.max(1,2*f-m)}}if($l(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:o,ignoreLocation:c})>h)break;y=P}const _={isMatch:m>=0,score:Math.max(.001,w)};if(p){const E=pD(v,s);E.length?u&&(_.indices=E):_.isMatch=!1}return _}function mD(n){let t={};for(let e=0,r=n.length;e<r;e+=1){const o=n.charAt(e);t[o]=(t[o]||0)|1<<r-e-1}return t}const kl=String.prototype.normalize?n=>n.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):n=>n;class L2{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){if(this.options={location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l},t=u?t:t.toLowerCase(),t=c?kl(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const d=(h,m)=>{this.chunks.push({pattern:h,alphabet:mD(h),startIndex:m})},f=this.pattern.length;if(f>Wa){let h=0;const m=f%Wa,p=f-m;for(;h<p;)d(this.pattern.substr(h,Wa),h),h+=Wa;if(m){const v=f-Wa;d(this.pattern.substr(v),v)}}else d(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern===t){let p={isMatch:!0,score:0};return o&&(p.indices=[[0,t.length-1]]),p}const{location:a,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,ignoreLocation:l}=this.options;let d=[],f=0,h=!1;this.chunks.forEach(({pattern:p,alphabet:v,startIndex:g})=>{const{isMatch:y,score:w,indices:x}=vD(t,p,v,{location:a+g,distance:i,threshold:s,findAllMatches:u,minMatchCharLength:c,includeMatches:o,ignoreLocation:l});y&&(h=!0),f+=w,y&&x&&(d=[...d,...x])});let m={isMatch:h,score:h?f/this.chunks.length:1};return h&&o&&(m.indices=d),m}}class qo{constructor(t){this.pattern=t}static isMultiMatch(t){return B2(t,this.multiRegex)}static isSingleMatch(t){return B2(t,this.singleRegex)}search(){}}function B2(n,t){const e=n.match(t);return e?e[1]:null}class gD extends qo{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class yD extends qo{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class bD extends qo{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class xD extends qo{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class wD extends qo{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class CD extends qo{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class W2 extends qo{constructor(t,{location:e=Ae.location,threshold:r=Ae.threshold,distance:o=Ae.distance,includeMatches:a=Ae.includeMatches,findAllMatches:i=Ae.findAllMatches,minMatchCharLength:s=Ae.minMatchCharLength,isCaseSensitive:u=Ae.isCaseSensitive,ignoreDiacritics:c=Ae.ignoreDiacritics,ignoreLocation:l=Ae.ignoreLocation}={}){super(t),this._bitapSearch=new L2(t,{location:e,threshold:r,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:s,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class V2 extends qo{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,r;const o=[],a=this.pattern.length;for(;(r=t.indexOf(this.pattern,e))>-1;)e=r+a,o.push([r,e-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const Cp=[gD,V2,bD,xD,CD,wD,yD,W2],j2=Cp.length,_D=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ED="|";function SD(n,t={}){return n.split(ED).map(e=>{let r=e.trim().split(_D).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const s=r[a];let u=!1,c=-1;for(;!u&&++c<j2;){const l=Cp[c];let d=l.isMultiMatch(s);d&&(o.push(new l(d,t)),u=!0)}if(!u)for(c=-1;++c<j2;){const l=Cp[c];let d=l.isSingleMatch(s);if(d){o.push(new l(d,t));break}}}return o})}const ND=new Set([W2.type,V2.type]);class $D{constructor(t,{isCaseSensitive:e=Ae.isCaseSensitive,ignoreDiacritics:r=Ae.ignoreDiacritics,includeMatches:o=Ae.includeMatches,minMatchCharLength:a=Ae.minMatchCharLength,ignoreLocation:i=Ae.ignoreLocation,findAllMatches:s=Ae.findAllMatches,location:u=Ae.location,threshold:c=Ae.threshold,distance:l=Ae.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:r,includeMatches:o,minMatchCharLength:a,findAllMatches:s,ignoreLocation:i,location:u,threshold:c,distance:l},t=e?t:t.toLowerCase(),t=r?kl(t):t,this.pattern=t,this.query=SD(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?kl(t):t;let i=0,s=[],u=0;for(let c=0,l=e.length;c<l;c+=1){const d=e[c];s.length=0,i=0;for(let f=0,h=d.length;f<h;f+=1){const m=d[f],{isMatch:p,indices:v,score:g}=m.search(t);if(p){if(i+=1,u+=g,r){const y=m.constructor.type;ND.has(y)?s=[...s,...v]:s.push(v)}}else{u=0,i=0,s.length=0;break}}if(i){let f={isMatch:!0,score:u/i};return r&&(f.indices=s),f}}return{isMatch:!1,score:1}}}const _p=[];function kD(...n){_p.push(...n)}function Ep(n,t){for(let e=0,r=_p.length;e<r;e+=1){let o=_p[e];if(o.condition(n,t))return new o(n,t)}return new L2(n,t)}const Pl={AND:"$and",OR:"$or"},Sp={PATH:"$path",PATTERN:"$val"},Np=n=>!!(n[Pl.AND]||n[Pl.OR]),PD=n=>!!n[Sp.PATH],ID=n=>!fo(n)&&T2(n)&&!Np(n),U2=n=>({[Pl.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function z2(n,t,{auto:e=!0}={}){const r=o=>{let a=Object.keys(o);const i=PD(o);if(!i&&a.length>1&&!Np(o))return r(U2(o));if(ID(o)){const u=i?o[Sp.PATH]:a[0],c=i?o[Sp.PATTERN]:o[u];if(!zr(c))throw new Error(aD(u));const l={keyId:xp(u),pattern:c};return e&&(l.searcher=Ep(c,t)),l}let s={children:[],operator:a[0]};return a.forEach(u=>{const c=o[u];fo(c)&&c.forEach(l=>{s.children.push(r(l))})}),s};return Np(n)||(n=U2(n)),r(n)}function AD(n,{ignoreFieldNorm:t=Ae.ignoreFieldNorm}){n.forEach(e=>{let r=1;e.matches.forEach(({key:o,norm:a,score:i})=>{const s=o?o.weight:null;r*=Math.pow(i===0&&s?Number.EPSILON:i,(s||1)*(t?1:a))}),e.score=r})}function TD(n,t){const e=n.matches;t.matches=[],jn(e)&&e.forEach(r=>{if(!jn(r.indices)||!r.indices.length)return;const{indices:o,value:a}=r;let i={indices:o,value:a};r.key&&(i.key=r.key.src),r.idx>-1&&(i.refIndex=r.idx),t.matches.push(i)})}function OD(n,t){t.score=n.score}function DD(n,t,{includeMatches:e=Ae.includeMatches,includeScore:r=Ae.includeScore}={}){const o=[];return e&&o.push(TD),r&&o.push(OD),n.map(a=>{const{idx:i}=a,s={item:t[i],refIndex:i};return o.length&&o.forEach(u=>{u(a,s)}),s})}class Bi{constructor(t,e={},r){this.options={...Ae,...e},this.options.useExtendedSearch,this._keyStore=new cD(this.options.keys),this.setCollection(t,r)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof wp))throw new Error(oD);this._myIndex=e||R2(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){jn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let r=0,o=this._docs.length;r<o;r+=1){const a=this._docs[r];t(a,r)&&(this.removeAt(r),r-=1,o-=1,e.push(a))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:s}=this.options;let u=zr(t)?zr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return AD(u,{ignoreFieldNorm:s}),a&&u.sort(i),A2(e)&&e>-1&&(u=u.slice(0,e)),DD(u,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const e=Ep(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=e.searchIn(a);u&&o.push({item:a,idx:i,matches:[{score:c,value:a,norm:s,indices:l}]})}),o}_searchLogical(t){const e=z2(t,this.options),r=(s,u,c)=>{if(!s.children){const{keyId:d,searcher:f}=s,h=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:f});return h&&h.length?[{idx:c,item:u,matches:h}]:[]}const l=[];for(let d=0,f=s.children.length;d<f;d+=1){const h=s.children[d],m=r(h,u,c);if(m.length)l.push(...m);else if(s.operator===Pl.AND)return[]}return l},o=this._myIndex.records,a={},i=[];return o.forEach(({$:s,i:u})=>{if(jn(s)){let c=r(e,s,u);c.length&&(a[u]||(a[u]={idx:u,item:s,matches:[]},i.push(a[u])),c.forEach(({matches:l})=>{a[u].matches.push(...l)}))}}),i}_searchObjectList(t){const e=Ep(t,this.options),{keys:r,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:s})=>{if(!jn(i))return;let u=[];r.forEach((c,l)=>{u.push(...this._findMatches({key:c,value:i[l],searcher:e}))}),u.length&&a.push({idx:s,item:i,matches:u})}),a}_findMatches({key:t,value:e,searcher:r}){if(!jn(e))return[];let o=[];if(fo(e))e.forEach(({v:a,i,n:s})=>{if(!jn(a))return;const{isMatch:u,score:c,indices:l}=r.searchIn(a);u&&o.push({score:c,key:t,value:a,idx:i,norm:s,indices:l})});else{const{v:a,n:i}=e,{isMatch:s,score:u,indices:c}=r.searchIn(a);s&&o.push({score:u,key:t,value:a,norm:i,indices:c})}return o}}Bi.version="7.1.0",Bi.createIndex=R2,Bi.parseIndex=hD,Bi.config=Ae,Bi.parseQuery=z2,kD($D);const MD=D.createContext(void 0);let $p;const FD=({apiEndpoint:n,children:t})=>(D.useEffect(()=>{$p=n},[n]),b.jsx(MD.Provider,{value:{apiEndpoint:n},children:t})),RD=()=>{if(!$p)throw new Error("ApiEndpoint not initialized. Make sure ApiProvider is mounted.");return $p};typeof window>"u"&&(async()=>{const{Canvas:n,Image:t,ImageData:e,loadImage:r}=await Promise.resolve().then(()=>dz);global.Image=t,global.HTMLImageElement=t,global.ImageData=e,global.HTMLCanvasElement=n,global.CanvasRenderingContext2D=n,global.loadImage=r,rn.monkeyPatch({Canvas:n,Image:t,ImageData:e,createCanvasElement:()=>new n(1,1),createImageElement:()=>new t})})();class LD{constructor(){km(this,"signalMap");km(this,"modelsLoaded",!1);this.signalMap={id:["date of birth","birth date","place of birth","id","identification","identity card","permit","valid until","expiration date","given name","surname","sex","gender","height","weight","address","issuing authority","issued by","card number","personal number","nationality"],passport:["passport","passport number","country code","issuing country","issuing state","place of issue","place of birth","date of issue","date of expiry","expiry date","valid until","authority","surname","given name","name","sex","nationality","type","holder","mrz","document","travel","abroad","citizen"],license:["license","driver","driver license","dl number","licence number","permit","valid until","date of birth","birth date","issue date","expiration date","holder's signature","authority","class","restrictions","endorsements","sex","eyes","hair","height","weight","organ donor","address"],voterId:["voter","voting","voter id","voter card","elector","elector's name","father's name","electoral roll","polling station","constituency","elector id","serial number","sex","age","dob","date of birth","part number","section","epic","identity card","address"],default:["name","id","date","dob","expiry","number","document","issued"]}}async toBase64(t){if(typeof window>"u")return(await(await Promise.resolve().then(()=>fz)).readFile(t)).toString("base64");if(t instanceof File)return new Promise((e,r)=>{const o=new FileReader;o.onload=()=>{const i=o.result.split(",")[1];e(i)},o.onerror=r,o.readAsDataURL(t)});throw new Error("Unsupported input type for base64 conversion")}async validateIdCard(t,e){let r=t;if(typeof t!="string"){const s=await this.toBase64(t);r=`data:${t.type||"image/jpeg"};base64,${s}`}const{data:{text:o}}=await Ak.recognize(r,"eng"),a=this.signalMap[e]||this.signalMap.default;console.log("OCR Result:",{text:o});let i=a.some(s=>{const u=o.toLowerCase().includes(s);return u&&console.log(`Found ${e} match:`,s),u});if(!i){const u=new Bi(a,{includeScore:!0,threshold:.6}).search(o.toLowerCase());i=u.length>0,i&&console.log("Found fuzzy match:",u[0].item,u[0].score,{found:u})}return{type:e,passed:i,textSnippet:o.slice(0,200),fullText:o}}async loadModels(){if(this.modelsLoaded)return;const e=`${RD()}/api/models`;await Promise.all([mn.ssdMobilenetv1.loadFromUri(e),mn.faceLandmark68Net.loadFromUri(e),mn.faceRecognitionNet.loadFromUri(e)]),this.modelsLoaded=!0}async validateFace(t){await this.loadModels();let e=t;if(typeof t!="string"){const i=await this.toBase64(t);e=`data:${t.type||"image/jpeg"};base64,${i}`}const r=await this.fileToImage(e),o=await Q9(r,new ou);return{type:"face",passed:o.length===1,facesDetected:o.length}}async fileToImage(t){return new Promise((e,r)=>{const o=new Image;if(o.onload=()=>e(o),o.onerror=r,typeof t=="string")o.src=t;else{const a=new FileReader;a.onload=()=>{o.src=a.result},a.onerror=r,a.readAsDataURL(t)}})}}const H2=new LD,BD=(n,t,e,r,o,a,i)=>{const[s,u]=D.useState(null),[c,l]=D.useState(null),[d,f]=D.useState({x:0,y:0,w:320,h:192}),h=D.useRef(`frameMask-${Math.random().toString(36).slice(2)}`),{toast:m}=Qu(),p=D.useMemo(()=>c?URL.createObjectURL(c):null,[c]),v=vi.find(x=>x.id===i);D.useEffect(()=>{e.current&&s&&(e.current.srcObject=s)},[s]),D.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]);const g=D.useCallback(async()=>{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:9999},height:{ideal:9999}}});u(x)}catch{try{const x=await navigator.mediaDevices.getUserMedia({video:{facingMode:n==="selfie"?"user":"environment",width:{ideal:1280},height:{ideal:720}}});u(x)}catch{m({title:"Camera Error",description:"Unable to access camera. Please check permissions.",variant:"destructive"})}}},[n,m]),y=D.useCallback(()=>{s&&(s.getTracks().forEach(x=>x.stop()),u(null))},[s]),w=D.useCallback(async()=>{if(!e.current||!r.current||!o.current)return;const x=e.current,C=r.current,_=C.getContext("2d");if(!_)return;const E=x.videoWidth,S=x.videoHeight;if(n==="selfie"){C.width=E,C.height=S,_.drawImage(x,0,0,E,S),C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{const q=document.createElement("canvas"),Z=q.getContext("2d");if(!Z)return;const oe=x.getBoundingClientRect(),ae=E/oe.width,X=S/oe.height,re=10,ce=(d.x-re)*ae,ue=(d.y-re)*X,se=(d.w+2*re)*ae,ee=(d.h+2*re)*X;q.width=se,q.height=ee,Z.drawImage(x,ce,ue,se,ee,0,0,se,ee);const _e=await new Promise(Ze=>q.toBlob(Ze,"image/jpeg",.8));if(!_e)return;const Me=new File([_e],`crop-${Date.now()}.jpg`,{type:"image/jpeg"});if(m({title:"Validating...",description:"Checking if the photo has a face..."}),!(await H2.validateFace(Me)).passed){m({title:"Validation Failed",description:"No face detected. Please retake your selfie.",variant:"destructive"});return}m({title:"Photo Captured",description:"Selfie captured successfully"}),l(K),y()}catch(q){console.error("Face validation error:",q),m({title:"Validation Error",description:"We couldn’t process the selfie. Please try again.",variant:"destructive"})}},"image/jpeg",.8);return}const N=x.getBoundingClientRect(),$=E/N.width,A=S/N.height,P=10,j=(d.x-P)*$,B=(d.y-P)*A,z=(d.w+2*P)*$,H=(d.h+2*P)*A,F=Math.max(0,Math.min(j,E-z)),M=Math.max(0,Math.min(B,S-H)),O=Math.min(z,E-F),I=Math.min(H,S-M);if(C.width=t==="circular"?Math.max(O,I):O,C.height=t==="circular"?Math.max(O,I):I,t==="circular"){const L=Math.min(O,I)/2;_.beginPath(),_.arc(C.width/2,C.height/2,L+P*$,0,Math.PI*2),_.clip(),_.drawImage(x,F-(C.width-O)/2,M-(C.height-I)/2,C.width,C.height,0,0,C.width,C.height)}else _.drawImage(x,F,M,O,I,0,0,C.width,C.height);C.toBlob(async L=>{if(!L)return;const K=new File([L],`${n}-${Date.now()}.jpg`,{type:"image/jpeg"});try{if(m({title:"Validating...",description:`Checking if the photo looks like ${v.title} ...`}),!(await H2.validateIdCard(K,i)).passed){m({title:"Validation Failed",description:`This doesn’t look like ${v.title} card. Try again.`,variant:"destructive"});return}l(K),y(),m({title:"Photo Captured",description:`${v.title} validated successfully`})}catch(q){console.error(q),m({title:"OCR Error",description:"We couldn’t process the photo. Please try again.",variant:"destructive"})}},"image/jpeg",.8)},[n,y,m,t,d,e,r,o]);return D.useEffect(()=>(!c&&!s&&g(),()=>{y()}),[c,s,g,y]),D.useEffect(()=>{if(!o.current||!a.current)return;const x=()=>{const _=o.current.getBoundingClientRect(),E=a.current.getBoundingClientRect();f({x:Math.round(E.left-_.left),y:Math.round(E.top-_.top),w:Math.round(E.width),h:Math.round(E.height)})};x();const C=new ResizeObserver(x);return C.observe(a.current),C.observe(o.current),window.addEventListener("resize",x),window.addEventListener("scroll",x,!0),()=>{C.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("scroll",x,!0)}},[t,s,o,a]),{stream:s,photo:c,setPhoto:l,hole:d,maskId:h.current,photoUrl:p,capturePhoto:w}},kp=768;function WD(){const[n,t]=k.useState(void 0);return k.useEffect(()=>{const e=window.matchMedia(`(max-width: ${kp-1}px)`),r=()=>{t(window.innerWidth<kp)};return e.addEventListener("change",r),t(window.innerWidth<kp),()=>e.removeEventListener("change",r)},[]),!!n}const VD={"id-front":"ID Front","id-back":"ID Back",selfie:"Selfie"},Wi=({currentStep:n,onRetake:t,onConfirm:e,onBack:r,title:o,description:a,frameType:i,documentTypeId:s})=>{const u=D.useRef(null),c=D.useRef(null),l=D.useRef(null),d=D.useRef(null),f=WD(),{stream:h,photo:m,setPhoto:p,hole:v,maskId:g,photoUrl:y,capturePhoto:w}=BD(n,i,u,c,l,d,s),x=!!h,C=()=>{p(null),r()},_=()=>{p(null),t()},E=()=>{m&&e(m),m&&e(m),p(null)},S=v.x+v.w/2,N=v.y+v.h/2,$=Math.max(v.w,v.h)/2,A=()=>{const P=VD[n]||"Photo";return b.jsx(hn,{className:"w-full max-w-md mx-auto",children:b.jsxs(pn,{className:"p-6",children:[b.jsx(Do,{title:`Review ${P}`,subTitle:"Make sure the information is seen clearly, with no blur or glare.",onBack:C}),b.jsx("div",{className:"mb-8",children:b.jsx("div",{className:"relative",children:y&&b.jsx("img",{src:y,alt:"Captured photo",className:`w-full h-64 object-cover ${n==="selfie"?"":i==="circular"?"rounded-full":"rounded-2xl"} bg-muted`})})}),b.jsxs("div",{className:"flex gap-4",children:[b.jsx(_t,{variant:"outline",onClick:_,className:"flex-1 text-md",children:"Take again"}),b.jsx(_t,{onClick:E,className:"flex-1 text-md",children:"Looks good"})]})]})})};return m?A():b.jsxs(hn,{className:"relative w-full max-w-md mx-auto bg-gray-900 border-gray-900 overflow-hidden",children:[x&&b.jsx("video",{ref:u,autoPlay:!0,playsInline:!0,muted:!0,loop:!0,className:`absolute inset-0 w-full h-full object-cover z-0 ${!f&&"scale-x-[-1]"}`}),b.jsx("div",{ref:l,className:"absolute inset-0 z-5 pointer-events-none","aria-hidden":!0,children:b.jsxs("svg",{className:"w-full h-full",children:[b.jsx("defs",{children:b.jsxs("mask",{id:g,children:[b.jsx("rect",{width:"100%",height:"100%",fill:"white"}),i==="circular"?b.jsx("circle",{cx:S,cy:N,r:$,fill:"black"}):b.jsx("rect",{x:v.x,y:v.y,width:v.w,height:v.h,fill:"black"})]})}),b.jsx("rect",{width:"100%",height:"100%",fill:"rgba(17,24,39,0.7)",mask:`url(#${g})`})]})}),b.jsx("canvas",{ref:c,className:"hidden"}),b.jsxs(pn,{className:"relative z-10 text-white flex flex-col h-full",children:[b.jsxs("div",{className:"flex items-center p-6",children:[b.jsx(_t,{variant:"ghost",size:"sm",onClick:C,className:"text-white hover:bg-gray-600",children:b.jsx(Cg,{className:"h-6 w-6"})}),b.jsx("h1",{className:"text-xl font-semibold ml-4",children:o})]}),b.jsx("div",{className:"px-6 mb-8",children:b.jsx("p",{className:"text-gray-300 text-center",children:a})}),b.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6",children:[b.jsx("div",{className:"relative mb-16",children:x?b.jsxs("div",{ref:d,className:`relative z-20 ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:[b.jsx("div",{className:`absolute inset-0 opacity-0 ${i==="circular"?"rounded-full":""} z-10`}),i==="circular"?null:b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-l-4 border-white z-30",style:{top:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-t-4 border-r-4 border-white z-30",style:{top:"-4px",right:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-l-4 border-white z-30",style:{bottom:"-4px",left:"-4px"}}),b.jsx("div",{className:"absolute w-6 h-6 border-b-4 border-r-4 border-white z-30",style:{bottom:"-4px",right:"-4px"}})]})]}):b.jsx("div",{className:`bg-gray-700 flex items-center justify-center ${i==="circular"?"w-80 h-80 rounded-full":s==="passport"?"w-80 h-[350px]":"w-80 h-48"}`,children:b.jsx("p",{className:"text-gray-400",children:"Camera loading..."})})}),b.jsx(_t,{onClick:w,size:"lg",className:"w-16 h-16 rounded-full bg-white hover:bg-gray-100 border-4 border-gray-600 p-0",disabled:!x,children:b.jsx("div",{className:"w-8 h-8 rounded-full bg-white"})})]})]})]})},jD=({apiEndpoint:n,apiKey:t,onComplete:e,onDoneClick:r})=>{const[o,a]=D.useState("landing"),[i,s]=D.useState(""),[u,c]=D.useState(""),[l,d]=D.useState(null),[f,h]=D.useState(null),[m,p]=D.useState(null),{data:v}=HD(n,t),g=X0({mutationFn:UD}),{toast:y}=Qu(),w=D.useMemo(()=>[...v!=null&&v.hide_name_step?[]:["name"],...v!=null&&v.hide_document_selection_step?[]:["document-selection"],"selfie","pre-selfie","id-front","id-back","verify"],[v]),x=()=>v.hide_name_step?v.hide_document_selection_step?"id-front":"document-selection":"name",C=async()=>{if((v.hide_name_step||!!i)&&l&&f&&m){const N={full_name:i,selfie_photo:l,id_photo:f,id_photo_back:m},$=await g.mutateAsync({apiEndpoint:n,apiKey:t,data:N});e($.data.token,N),y({title:"KYC Complete",description:"Identity verification completed successfully"}),s(""),d(null),h(null),p(null),a("done")}},_=()=>b.jsx(b.Fragment,{children:o!=="landing"&&b.jsx("div",{className:"flex justify-center",children:b.jsx("div",{className:"flex space-x-2",children:w.map((S,N)=>b.jsx("div",{className:`w-3 h-3 rounded-full ${w.indexOf(o)>=N?"bg-primary":"bg-muted"}`},S))})})}),E=()=>{switch(console.log("currentStep",o),o){case"landing":return b.jsx(Z0,{onContinue:()=>a(x())});case"name":return b.jsx(G$,{fullName:i,onNameChange:s,onContinue:()=>a(v.hide_document_selection_step?"id-front":"document-selection"),renderProgress:_});case"document-selection":return b.jsx(ey,{selectedDocumentType:u,onDocumentTypeChange:c,onContinue:()=>a("id-front"),onBack:()=>a(v.hide_name_step?"landing":"name"),renderProgress:_});case"id-front":return b.jsx(Wi,{title:"Upload ID",description:"Place your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",documentTypeId:u,currentStep:o,onRetake:()=>{h(null)},onConfirm:S=>{h(S),a(u==="passport"?"pre-selfie":"id-back")},onBack:()=>{h(null),a(v.hide_document_selection_step?v.hide_name_step?"landing":"name":"document-selection")}});case"id-back":return b.jsx(Wi,{title:"Upload ID Back",description:"Place the back of your ID inside the frame and take a picture. Make sure it is not cut or has any glare.",frameType:"rectangular",documentTypeId:u,currentStep:o,onRetake:()=>{p(null)},onConfirm:S=>{p(S),a("pre-selfie")},onBack:()=>{p(null),a("id-front")}});case"pre-selfie":return b.jsx(ty,{onContinue:()=>a("selfie"),onBack:()=>a("id-back")});case"selfie":return b.jsx(Wi,{title:"Selfie",description:"Place your face inside the frame and take a picture. Make sure it is clearly visible.",frameType:"circular",documentTypeId:u,currentStep:o,onRetake:()=>{d(null)},onConfirm:S=>{d(S),a("verify")},onBack:()=>{d(null),a("id-back")}});case"verify":return b.jsx(q$,{fullName:i,onComplete:()=>a("processing"),onStartOver:()=>a("landing")});case"processing":return b.jsx(ny,{onComplete:C});case"done":return b.jsx(ry,{onDoneClick:r});default:return null}};return b.jsx("div",{className:"w-[430px]",children:E()})};async function UD({apiEndpoint:n,apiKey:t,data:e}){const r=new FormData;r.append("full_name",e.full_name),r.append("selfie_photo",e.selfie_photo,e.selfie_photo.name),r.append("id_photo",e.id_photo,e.id_photo.name),r.append("id_photo_back",e.id_photo_back,e.id_photo_back.name);const o=await fetch(`${n}/api/kyc`,{method:"POST",headers:{"X-API-Key":t},body:r});if(!o.ok)throw new Error("Network response was not ok");return o.json()}const zD=async(n,t)=>{const e=await fetch(`${n}/api/settings`,{method:"GET",headers:{"X-API-Key":t,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Network response was not ok");return(await e.json()).data},HD=(n,t)=>V$({queryKey:["settings",n,t],queryFn:()=>zD(n,t),enabled:!!n&&!!t});var iu=n=>n.type==="checkbox",Va=n=>n instanceof Date,gn=n=>n==null;const G2=n=>typeof n=="object";var Dt=n=>!gn(n)&&!Array.isArray(n)&&G2(n)&&!Va(n),q2=n=>Dt(n)&&n.target?iu(n.target)?n.target.checked:n.target.value:n,GD=n=>n.substring(0,n.search(/\.\d+(\.|$)/))||n,K2=(n,t)=>n.has(GD(t)),qD=n=>{const t=n.constructor&&n.constructor.prototype;return Dt(t)&&t.hasOwnProperty("isPrototypeOf")},Pp=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Gt(n){let t;const e=Array.isArray(n),r=typeof FileList<"u"?n instanceof FileList:!1;if(n instanceof Date)t=new Date(n);else if(!(Pp&&(n instanceof Blob||r))&&(e||Dt(n)))if(t=e?[]:Object.create(Object.getPrototypeOf(n)),!e&&!qD(n))t=n;else for(const o in n)n.hasOwnProperty(o)&&(t[o]=Gt(n[o]));else return n;return t}var Il=n=>/^\w*$/.test(n),At=n=>n===void 0,Ip=n=>Array.isArray(n)?n.filter(Boolean):[],Ap=n=>Ip(n.replace(/["|']|\]/g,"").split(/\.|\[/)),me=(n,t,e)=>{if(!t||!Dt(n))return e;const r=(Il(t)?[t]:Ap(t)).reduce((o,a)=>gn(o)?o:o[a],n);return At(r)||r===n?At(n[t])?e:n[t]:r},Un=n=>typeof n=="boolean",ct=(n,t,e)=>{let r=-1;const o=Il(t)?[t]:Ap(t),a=o.length,i=a-1;for(;++r<a;){const s=o[r];let u=e;if(r!==i){const c=n[s];u=Dt(c)||Array.isArray(c)?c:isNaN(+o[r+1])?{}:[]}if(s==="__proto__"||s==="constructor"||s==="prototype")return;n[s]=u,n=n[s]}};const Al={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},lr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ho={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Tp=D.createContext(null);Tp.displayName="HookFormContext";const Tl=()=>D.useContext(Tp),KD=n=>{const{children:t,...e}=n;return D.createElement(Tp.Provider,{value:e},t)};var Y2=(n,t,e,r=!0)=>{const o={defaultValues:t._defaultValues};for(const a in n)Object.defineProperty(o,a,{get:()=>{const i=a;return t._proxyFormState[i]!==lr.all&&(t._proxyFormState[i]=!r||lr.all),e&&(e[i]=!0),n[i]}});return o};const Op=typeof window<"u"?D.useLayoutEffect:D.useEffect;function YD(n){const t=Tl(),{control:e=t.control,disabled:r,name:o,exact:a}=n||{},[i,s]=D.useState(e._formState),u=D.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Op(()=>e._subscribe({name:o,formState:u.current,exact:a,callback:c=>{!r&&s({...e._formState,...c})}}),[o,r,a]),D.useEffect(()=>{u.current.isValid&&e._setValid(!0)},[e]),D.useMemo(()=>Y2(i,e,u.current,!1),[i,e])}var zn=n=>typeof n=="string",X2=(n,t,e,r,o)=>zn(n)?(r&&t.watch.add(n),me(e,n,o)):Array.isArray(n)?n.map(a=>(r&&t.watch.add(a),me(e,a))):(r&&(t.watchAll=!0),e),Dp=n=>gn(n)||!G2(n);function po(n,t,e=new WeakSet){if(Dp(n)||Dp(t))return n===t;if(Va(n)&&Va(t))return n.getTime()===t.getTime();const r=Object.keys(n),o=Object.keys(t);if(r.length!==o.length)return!1;if(e.has(n)||e.has(t))return!0;e.add(n),e.add(t);for(const a of r){const i=n[a];if(!o.includes(a))return!1;if(a!=="ref"){const s=t[a];if(Va(i)&&Va(s)||Dt(i)&&Dt(s)||Array.isArray(i)&&Array.isArray(s)?!po(i,s,e):i!==s)return!1}}return!0}function XD(n){const t=Tl(),{control:e=t.control,name:r,defaultValue:o,disabled:a,exact:i,compute:s}=n||{},u=D.useRef(o),c=D.useRef(s),l=D.useRef(void 0);c.current=s;const d=D.useMemo(()=>e._getWatch(r,u.current),[e,r]),[f,h]=D.useState(c.current?c.current(d):d);return Op(()=>e._subscribe({name:r,formState:{values:!0},exact:i,callback:m=>{if(!a){const p=X2(r,e._names,m.values||e._formValues,!1,u.current);if(c.current){const v=c.current(p);po(v,l.current)||(h(v),l.current=v)}else h(p)}}}),[e,a,r,i]),D.useEffect(()=>e._removeUnmounted()),f}function Z2(n){const t=Tl(),{name:e,disabled:r,control:o=t.control,shouldUnregister:a,defaultValue:i}=n,s=K2(o._names.array,e),u=D.useMemo(()=>me(o._formValues,e,me(o._defaultValues,e,i)),[o,e,i]),c=XD({control:o,name:e,defaultValue:u,exact:!0}),l=YD({control:o,name:e,exact:!0}),d=D.useRef(n),f=D.useRef(void 0),h=D.useRef(o.register(e,{...n.rules,value:c,...Un(n.disabled)?{disabled:n.disabled}:{}}));d.current=n;const m=D.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!me(l.errors,e)},isDirty:{enumerable:!0,get:()=>!!me(l.dirtyFields,e)},isTouched:{enumerable:!0,get:()=>!!me(l.touchedFields,e)},isValidating:{enumerable:!0,get:()=>!!me(l.validatingFields,e)},error:{enumerable:!0,get:()=>me(l.errors,e)}}),[l,e]),p=D.useCallback(w=>h.current.onChange({target:{value:q2(w),name:e},type:Al.CHANGE}),[e]),v=D.useCallback(()=>h.current.onBlur({target:{value:me(o._formValues,e),name:e},type:Al.BLUR}),[e,o._formValues]),g=D.useCallback(w=>{const x=me(o._fields,e);x&&w&&(x._f.ref={focus:()=>w.focus&&w.focus(),select:()=>w.select&&w.select(),setCustomValidity:C=>w.setCustomValidity(C),reportValidity:()=>w.reportValidity()})},[o._fields,e]),y=D.useMemo(()=>({name:e,value:c,...Un(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:p,onBlur:v,ref:g}),[e,r,l.disabled,p,v,g,c]);return D.useEffect(()=>{const w=o._options.shouldUnregister||a,x=f.current;x&&x!==e&&!s&&o.unregister(x),o.register(e,{...d.current.rules,...Un(d.current.disabled)?{disabled:d.current.disabled}:{}});const C=(_,E)=>{const S=me(o._fields,_);S&&S._f&&(S._f.mount=E)};if(C(e,!0),w){const _=Gt(me(o._options.defaultValues,e));ct(o._defaultValues,e,_),At(me(o._formValues,e))&&ct(o._formValues,e,_)}return!s&&o.register(e),f.current=e,()=>{(s?w&&!o._state.action:w)?o.unregister(e):C(e,!1)}},[e,o,s,a]),D.useEffect(()=>{o._setDisabledField({disabled:r,name:e})},[r,e,o]),D.useMemo(()=>({field:y,formState:l,fieldState:m}),[y,l,m])}const ZD=n=>n.render(Z2(n));var Q2=(n,t,e,r,o)=>t?{...e[n],types:{...e[n]&&e[n].types?e[n].types:{},[r]:o||!0}}:{},su=n=>Array.isArray(n)?n:[n],J2=()=>{let n=[];return{get observers(){return n},next:o=>{for(const a of n)a.next&&a.next(o)},subscribe:o=>(n.push(o),{unsubscribe:()=>{n=n.filter(a=>a!==o)}}),unsubscribe:()=>{n=[]}}};function ex(n,t){const e={};for(const r in n)if(n.hasOwnProperty(r)){const o=n[r],a=t[r];if(o&&Dt(o)&&a){const i=ex(o,a);Dt(i)&&(e[r]=i)}else n[r]&&(e[r]=a)}return e}var kn=n=>Dt(n)&&!Object.keys(n).length,Mp=n=>n.type==="file",dr=n=>typeof n=="function",Ol=n=>{if(!Pp)return!1;const t=n?n.ownerDocument:0;return n instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},tx=n=>n.type==="select-multiple",Fp=n=>n.type==="radio",QD=n=>Fp(n)||iu(n),Rp=n=>Ol(n)&&n.isConnected;function JD(n,t){const e=t.slice(0,-1).length;let r=0;for(;r<e;)n=At(n)?r++:n[t[r++]];return n}function e8(n){for(const t in n)if(n.hasOwnProperty(t)&&!At(n[t]))return!1;return!0}function Mt(n,t){const e=Array.isArray(t)?t:Il(t)?[t]:Ap(t),r=e.length===1?n:JD(n,e),o=e.length-1,a=e[o];return r&&delete r[a],o!==0&&(Dt(r)&&kn(r)||Array.isArray(r)&&e8(r))&&Mt(n,e.slice(0,-1)),n}var t8=n=>{for(const t in n)if(dr(n[t]))return!0;return!1};function nx(n){return Array.isArray(n)||Dt(n)&&!t8(n)}function Lp(n,t={}){for(const e in n)nx(n[e])?(t[e]=Array.isArray(n[e])?[]:{},Lp(n[e],t[e])):gn(n[e])||(t[e]=!0);return t}function Vi(n,t,e){e||(e=Lp(t));for(const r in n)nx(n[r])?At(t)||Dp(e[r])?e[r]=Lp(n[r],Array.isArray(n[r])?[]:{}):Vi(n[r],gn(t)?{}:t[r],e[r]):e[r]=!po(n[r],t[r]);return e}const rx={value:!1,isValid:!1},ox={value:!0,isValid:!0};var ax=n=>{if(Array.isArray(n)){if(n.length>1){const t=n.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return n[0].checked&&!n[0].disabled?n[0].attributes&&!At(n[0].attributes.value)?At(n[0].value)||n[0].value===""?ox:{value:n[0].value,isValid:!0}:ox:rx}return rx},ix=(n,{valueAsNumber:t,valueAsDate:e,setValueAs:r})=>At(n)?n:t?n===""?NaN:n&&+n:e&&zn(n)?new Date(n):r?r(n):n;const sx={isValid:!1,value:null};var ux=n=>Array.isArray(n)?n.reduce((t,e)=>e&&e.checked&&!e.disabled?{isValid:!0,value:e.value}:t,sx):sx;function cx(n){const t=n.ref;return Mp(t)?t.files:Fp(t)?ux(n.refs).value:tx(t)?[...t.selectedOptions].map(({value:e})=>e):iu(t)?ax(n.refs).value:ix(At(t.value)?n.ref.value:t.value,n)}var n8=(n,t,e,r)=>{const o={};for(const a of n){const i=me(t,a);i&&ct(o,a,i._f)}return{criteriaMode:e,names:[...n],fields:o,shouldUseNativeValidation:r}},Dl=n=>n instanceof RegExp,uu=n=>At(n)?n:Dl(n)?n.source:Dt(n)?Dl(n.value)?n.value.source:n.value:n,lx=n=>({isOnSubmit:!n||n===lr.onSubmit,isOnBlur:n===lr.onBlur,isOnChange:n===lr.onChange,isOnAll:n===lr.all,isOnTouch:n===lr.onTouched});const dx="AsyncFunction";var r8=n=>!!n&&!!n.validate&&!!(dr(n.validate)&&n.validate.constructor.name===dx||Dt(n.validate)&&Object.values(n.validate).find(t=>t.constructor.name===dx)),o8=n=>n.mount&&(n.required||n.min||n.max||n.maxLength||n.minLength||n.pattern||n.validate),fx=(n,t,e)=>!e&&(t.watchAll||t.watch.has(n)||[...t.watch].some(r=>n.startsWith(r)&&/^\.\w+/.test(n.slice(r.length))));const cu=(n,t,e,r)=>{for(const o of e||Object.keys(n)){const a=me(n,o);if(a){const{_f:i,...s}=a;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(cu(s,t))break}else if(Dt(s)&&cu(s,t))break}}};function hx(n,t,e){const r=me(n,e);if(r||Il(e))return{error:r,name:e};const o=e.split(".");for(;o.length;){const a=o.join("."),i=me(t,a),s=me(n,a);if(i&&!Array.isArray(i)&&e!==a)return{name:e};if(s&&s.type)return{name:a,error:s};if(s&&s.root&&s.root.type)return{name:`${a}.root`,error:s.root};o.pop()}return{name:e}}var a8=(n,t,e,r)=>{e(n);const{name:o,...a}=n;return kn(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(i=>t[i]===(!r||lr.all))},i8=(n,t,e)=>!n||!t||n===t||su(n).some(r=>r&&(e?r===t:r.startsWith(t)||t.startsWith(r))),s8=(n,t,e,r,o)=>o.isOnAll?!1:!e&&o.isOnTouch?!(t||n):(e?r.isOnBlur:o.isOnBlur)?!n:(e?r.isOnChange:o.isOnChange)?n:!0,u8=(n,t)=>!Ip(me(n,t)).length&&Mt(n,t),c8=(n,t,e)=>{const r=su(me(n,e));return ct(r,"root",t[e]),ct(n,e,r),n};function px(n,t,e="validate"){if(zn(n)||Array.isArray(n)&&n.every(zn)||Un(n)&&!n)return{type:e,message:zn(n)?n:"",ref:t}}var ji=n=>Dt(n)&&!Dl(n)?n:{value:n,message:""},vx=async(n,t,e,r,o,a)=>{const{ref:i,refs:s,required:u,maxLength:c,minLength:l,min:d,max:f,pattern:h,validate:m,name:p,valueAsNumber:v,mount:g}=n._f,y=me(e,p);if(!g||t.has(p))return{};const w=s?s[0]:i,x=P=>{o&&w.reportValidity&&(w.setCustomValidity(Un(P)?"":P||""),w.reportValidity())},C={},_=Fp(i),E=iu(i),S=_||E,N=(v||Mp(i))&&At(i.value)&&At(y)||Ol(i)&&i.value===""||y===""||Array.isArray(y)&&!y.length,$=Q2.bind(null,p,r,C),A=(P,j,B,z=ho.maxLength,H=ho.minLength)=>{const F=P?j:B;C[p]={type:P?z:H,message:F,ref:i,...$(P?z:H,F)}};if(a?!Array.isArray(y)||!y.length:u&&(!S&&(N||gn(y))||Un(y)&&!y||E&&!ax(s).isValid||_&&!ux(s).isValid)){const{value:P,message:j}=zn(u)?{value:!!u,message:u}:ji(u);if(P&&(C[p]={type:ho.required,message:j,ref:w,...$(ho.required,j)},!r))return x(j),C}if(!N&&(!gn(d)||!gn(f))){let P,j;const B=ji(f),z=ji(d);if(!gn(y)&&!isNaN(y)){const H=i.valueAsNumber||y&&+y;gn(B.value)||(P=H>B.value),gn(z.value)||(j=H<z.value)}else{const H=i.valueAsDate||new Date(y),F=I=>new Date(new Date().toDateString()+" "+I),M=i.type=="time",O=i.type=="week";zn(B.value)&&y&&(P=M?F(y)>F(B.value):O?y>B.value:H>new Date(B.value)),zn(z.value)&&y&&(j=M?F(y)<F(z.value):O?y<z.value:H<new Date(z.value))}if((P||j)&&(A(!!P,B.message,z.message,ho.max,ho.min),!r))return x(C[p].message),C}if((c||l)&&!N&&(zn(y)||a&&Array.isArray(y))){const P=ji(c),j=ji(l),B=!gn(P.value)&&y.length>+P.value,z=!gn(j.value)&&y.length<+j.value;if((B||z)&&(A(B,P.message,j.message),!r))return x(C[p].message),C}if(h&&!N&&zn(y)){const{value:P,message:j}=ji(h);if(Dl(P)&&!y.match(P)&&(C[p]={type:ho.pattern,message:j,ref:i,...$(ho.pattern,j)},!r))return x(j),C}if(m){if(dr(m)){const P=await m(y,e),j=px(P,w);if(j&&(C[p]={...j,...$(ho.validate,j.message)},!r))return x(j.message),C}else if(Dt(m)){let P={};for(const j in m){if(!kn(P)&&!r)break;const B=px(await m[j](y,e),w,j);B&&(P={...B,...$(j,B.message)},x(B.message),r&&(C[p]=P))}if(!kn(P)&&(C[p]={ref:w,...P},!r))return C}}return x(!0),C};const l8={mode:lr.onSubmit,reValidateMode:lr.onChange,shouldFocusError:!0};function d8(n={}){let t={...l8,...n},e={submitCount:0,isDirty:!1,isReady:!1,isLoading:dr(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=Dt(t.defaultValues)||Dt(t.values)?Gt(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:Gt(o),i={action:!1,mount:!1,watch:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const l={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let d={...l};const f={array:J2(),state:J2()},h=t.criteriaMode===lr.all,m=V=>Y=>{clearTimeout(c),c=setTimeout(V,Y)},p=async V=>{if(!t.disabled&&(l.isValid||d.isValid||V)){const Y=t.resolver?kn((await E()).errors):await N(r,!0);Y!==e.isValid&&f.state.next({isValid:Y})}},v=(V,Y)=>{!t.disabled&&(l.isValidating||l.validatingFields||d.isValidating||d.validatingFields)&&((V||Array.from(s.mount)).forEach(te=>{te&&(Y?ct(e.validatingFields,te,Y):Mt(e.validatingFields,te))}),f.state.next({validatingFields:e.validatingFields,isValidating:!kn(e.validatingFields)}))},g=(V,Y=[],te,he,pe=!0,le=!0)=>{if(he&&te&&!t.disabled){if(i.action=!0,le&&Array.isArray(me(r,V))){const ye=te(me(r,V),he.argA,he.argB);pe&&ct(r,V,ye)}if(le&&Array.isArray(me(e.errors,V))){const ye=te(me(e.errors,V),he.argA,he.argB);pe&&ct(e.errors,V,ye),u8(e.errors,V)}if((l.touchedFields||d.touchedFields)&&le&&Array.isArray(me(e.touchedFields,V))){const ye=te(me(e.touchedFields,V),he.argA,he.argB);pe&&ct(e.touchedFields,V,ye)}(l.dirtyFields||d.dirtyFields)&&(e.dirtyFields=Vi(o,a)),f.state.next({name:V,isDirty:A(V,Y),dirtyFields:e.dirtyFields,errors:e.errors,isValid:e.isValid})}else ct(a,V,Y)},y=(V,Y)=>{ct(e.errors,V,Y),f.state.next({errors:e.errors})},w=V=>{e.errors=V,f.state.next({errors:e.errors,isValid:!1})},x=(V,Y,te,he)=>{const pe=me(r,V);if(pe){const le=me(a,V,At(te)?me(o,V):te);At(le)||he&&he.defaultChecked||Y?ct(a,V,Y?le:cx(pe._f)):B(V,le),i.mount&&p()}},C=(V,Y,te,he,pe)=>{let le=!1,ye=!1;const We={name:V};if(!t.disabled){if(!te||he){(l.isDirty||d.isDirty)&&(ye=e.isDirty,e.isDirty=We.isDirty=A(),le=ye!==We.isDirty);const Ge=po(me(o,V),Y);ye=!!me(e.dirtyFields,V),Ge?Mt(e.dirtyFields,V):ct(e.dirtyFields,V,!0),We.dirtyFields=e.dirtyFields,le=le||(l.dirtyFields||d.dirtyFields)&&ye!==!Ge}if(te){const Ge=me(e.touchedFields,V);Ge||(ct(e.touchedFields,V,te),We.touchedFields=e.touchedFields,le=le||(l.touchedFields||d.touchedFields)&&Ge!==te)}le&&pe&&f.state.next(We)}return le?We:{}},_=(V,Y,te,he)=>{const pe=me(e.errors,V),le=(l.isValid||d.isValid)&&Un(Y)&&e.isValid!==Y;if(t.delayError&&te?(u=m(()=>y(V,te)),u(t.delayError)):(clearTimeout(c),u=null,te?ct(e.errors,V,te):Mt(e.errors,V)),(te?!po(pe,te):pe)||!kn(he)||le){const ye={...he,...le&&Un(Y)?{isValid:Y}:{},errors:e.errors,name:V};e={...e,...ye},f.state.next(ye)}},E=async V=>{v(V,!0);const Y=await t.resolver(a,t.context,n8(V||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return v(V),Y},S=async V=>{const{errors:Y}=await E(V);if(V)for(const te of V){const he=me(Y,te);he?ct(e.errors,te,he):Mt(e.errors,te)}else e.errors=Y;return Y},N=async(V,Y,te={valid:!0})=>{for(const he in V){const pe=V[he];if(pe){const{_f:le,...ye}=pe;if(le){const We=s.array.has(le.name),Ge=pe._f&&r8(pe._f);Ge&&l.validatingFields&&v([le.name],!0);const Qt=await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation&&!Y,We);if(Ge&&l.validatingFields&&v([le.name]),Qt[le.name]&&(te.valid=!1,Y))break;!Y&&(me(Qt,le.name)?We?c8(e.errors,Qt,le.name):ct(e.errors,le.name,Qt[le.name]):Mt(e.errors,le.name))}!kn(ye)&&await N(ye,Y,te)}}return te.valid},$=()=>{for(const V of s.unMount){const Y=me(r,V);Y&&(Y._f.refs?Y._f.refs.every(te=>!Rp(te)):!Rp(Y._f.ref))&&X(V)}s.unMount=new Set},A=(V,Y)=>!t.disabled&&(V&&Y&&ct(a,V,Y),!po(I(),o)),P=(V,Y,te)=>X2(V,s,{...i.mount?a:At(Y)?o:zn(V)?{[V]:Y}:Y},te,Y),j=V=>Ip(me(i.mount?a:o,V,t.shouldUnregister?me(o,V,[]):[])),B=(V,Y,te={})=>{const he=me(r,V);let pe=Y;if(he){const le=he._f;le&&(!le.disabled&&ct(a,V,ix(Y,le)),pe=Ol(le.ref)&&gn(Y)?"":Y,tx(le.ref)?[...le.ref.options].forEach(ye=>ye.selected=pe.includes(ye.value)):le.refs?iu(le.ref)?le.refs.forEach(ye=>{(!ye.defaultChecked||!ye.disabled)&&(Array.isArray(pe)?ye.checked=!!pe.find(We=>We===ye.value):ye.checked=pe===ye.value||!!pe)}):le.refs.forEach(ye=>ye.checked=ye.value===pe):Mp(le.ref)?le.ref.value="":(le.ref.value=pe,le.ref.type||f.state.next({name:V,values:Gt(a)})))}(te.shouldDirty||te.shouldTouch)&&C(V,pe,te.shouldTouch,te.shouldDirty,!0),te.shouldValidate&&O(V)},z=(V,Y,te)=>{for(const he in Y){if(!Y.hasOwnProperty(he))return;const pe=Y[he],le=V+"."+he,ye=me(r,le);(s.array.has(V)||Dt(pe)||ye&&!ye._f)&&!Va(pe)?z(le,pe,te):B(le,pe,te)}},H=(V,Y,te={})=>{const he=me(r,V),pe=s.array.has(V),le=Gt(Y);ct(a,V,le),pe?(f.array.next({name:V,values:Gt(a)}),(l.isDirty||l.dirtyFields||d.isDirty||d.dirtyFields)&&te.shouldDirty&&f.state.next({name:V,dirtyFields:Vi(o,a),isDirty:A(V,le)})):he&&!he._f&&!gn(le)?z(V,le,te):B(V,le,te),fx(V,s)&&f.state.next({...e,name:V}),f.state.next({name:i.mount?V:void 0,values:Gt(a)})},F=async V=>{i.mount=!0;const Y=V.target;let te=Y.name,he=!0;const pe=me(r,te),le=Ge=>{he=Number.isNaN(Ge)||Va(Ge)&&isNaN(Ge.getTime())||po(Ge,me(a,te,Ge))},ye=lx(t.mode),We=lx(t.reValidateMode);if(pe){let Ge,Qt;const xr=Y.type?cx(pe._f):q2(V),er=V.type===Al.BLUR||V.type===Al.FOCUS_OUT,_s=!o8(pe._f)&&!t.resolver&&!me(e.errors,te)&&!pe._f.deps||s8(er,me(e.touchedFields,te),e.isSubmitted,We,ye),wr=fx(te,s,er);ct(a,te,xr),er?(!Y||!Y.readOnly)&&(pe._f.onBlur&&pe._f.onBlur(V),u&&u(0)):pe._f.onChange&&pe._f.onChange(V);const On=C(te,xr,er),ha=!kn(On)||wr;if(!er&&f.state.next({name:te,type:V.type,values:Gt(a)}),_s)return(l.isValid||d.isValid)&&(t.mode==="onBlur"?er&&p():er||p()),ha&&f.state.next({name:te,...wr?{}:On});if(!er&&wr&&f.state.next({...e}),t.resolver){const{errors:No}=await E([te]);if(le(xr),he){const Nm=hx(e.errors,r,te),xd=hx(No,r,Nm.name||te);Ge=xd.error,te=xd.name,Qt=kn(No)}}else v([te],!0),Ge=(await vx(pe,s.disabled,a,h,t.shouldUseNativeValidation))[te],v([te]),le(xr),he&&(Ge?Qt=!1:(l.isValid||d.isValid)&&(Qt=await N(r,!0)));he&&(pe._f.deps&&(!Array.isArray(pe._f.deps)||pe._f.deps.length>0)&&O(pe._f.deps),_(te,Qt,Ge,On))}},M=(V,Y)=>{if(me(e.errors,Y)&&V.focus)return V.focus(),1},O=async(V,Y={})=>{let te,he;const pe=su(V);if(t.resolver){const le=await S(At(V)?V:pe);te=kn(le),he=V?!pe.some(ye=>me(le,ye)):te}else V?(he=(await Promise.all(pe.map(async le=>{const ye=me(r,le);return await N(ye&&ye._f?{[le]:ye}:ye)}))).every(Boolean),!(!he&&!e.isValid)&&p()):he=te=await N(r);return f.state.next({...!zn(V)||(l.isValid||d.isValid)&&te!==e.isValid?{}:{name:V},...t.resolver||!V?{isValid:te}:{},errors:e.errors}),Y.shouldFocus&&!he&&cu(r,M,V?pe:s.mount),he},I=(V,Y)=>{let te={...i.mount?a:o};return Y&&(te=ex(Y.dirtyFields?e.dirtyFields:e.touchedFields,te)),At(V)?te:zn(V)?me(te,V):V.map(he=>me(te,he))},L=(V,Y)=>({invalid:!!me((Y||e).errors,V),isDirty:!!me((Y||e).dirtyFields,V),error:me((Y||e).errors,V),isValidating:!!me(e.validatingFields,V),isTouched:!!me((Y||e).touchedFields,V)}),K=V=>{V&&su(V).forEach(Y=>Mt(e.errors,Y)),f.state.next({errors:V?e.errors:{}})},q=(V,Y,te)=>{const he=(me(r,V,{_f:{}})._f||{}).ref,pe=me(e.errors,V)||{},{ref:le,message:ye,type:We,...Ge}=pe;ct(e.errors,V,{...Ge,...Y,ref:he}),f.state.next({name:V,errors:e.errors,isValid:!1}),te&&te.shouldFocus&&he&&he.focus&&he.focus()},Z=(V,Y)=>dr(V)?f.state.subscribe({next:te=>"values"in te&&V(P(void 0,Y),te)}):P(V,Y,!0),oe=V=>f.state.subscribe({next:Y=>{i8(V.name,Y.name,V.exact)&&a8(Y,V.formState||l,Lt,V.reRenderRoot)&&V.callback({values:{...a},...e,...Y,defaultValues:o})}}).unsubscribe,ae=V=>(i.mount=!0,d={...d,...V.formState},oe({...V,formState:d})),X=(V,Y={})=>{for(const te of V?su(V):s.mount)s.mount.delete(te),s.array.delete(te),Y.keepValue||(Mt(r,te),Mt(a,te)),!Y.keepError&&Mt(e.errors,te),!Y.keepDirty&&Mt(e.dirtyFields,te),!Y.keepTouched&&Mt(e.touchedFields,te),!Y.keepIsValidating&&Mt(e.validatingFields,te),!t.shouldUnregister&&!Y.keepDefaultValue&&Mt(o,te);f.state.next({values:Gt(a)}),f.state.next({...e,...Y.keepDirty?{isDirty:A()}:{}}),!Y.keepIsValid&&p()},re=({disabled:V,name:Y})=>{(Un(V)&&i.mount||V||s.disabled.has(Y))&&(V?s.disabled.add(Y):s.disabled.delete(Y))},ce=(V,Y={})=>{let te=me(r,V);const he=Un(Y.disabled)||Un(t.disabled);return ct(r,V,{...te||{},_f:{...te&&te._f?te._f:{ref:{name:V}},name:V,mount:!0,...Y}}),s.mount.add(V),te?re({disabled:Un(Y.disabled)?Y.disabled:t.disabled,name:V}):x(V,!0,Y.value),{...he?{disabled:Y.disabled||t.disabled}:{},...t.progressive?{required:!!Y.required,min:uu(Y.min),max:uu(Y.max),minLength:uu(Y.minLength),maxLength:uu(Y.maxLength),pattern:uu(Y.pattern)}:{},name:V,onChange:F,onBlur:F,ref:pe=>{if(pe){ce(V,Y),te=me(r,V);const le=At(pe.value)&&pe.querySelectorAll&&pe.querySelectorAll("input,select,textarea")[0]||pe,ye=QD(le),We=te._f.refs||[];if(ye?We.find(Ge=>Ge===le):le===te._f.ref)return;ct(r,V,{_f:{...te._f,...ye?{refs:[...We.filter(Rp),le,...Array.isArray(me(o,V))?[{}]:[]],ref:{type:le.type,name:V}}:{ref:le}}}),x(V,!1,void 0,le)}else te=me(r,V,{}),te._f&&(te._f.mount=!1),(t.shouldUnregister||Y.shouldUnregister)&&!(K2(s.array,V)&&i.action)&&s.unMount.add(V)}}},ue=()=>t.shouldFocusError&&cu(r,M,s.mount),se=V=>{Un(V)&&(f.state.next({disabled:V}),cu(r,(Y,te)=>{const he=me(r,te);he&&(Y.disabled=he._f.disabled||V,Array.isArray(he._f.refs)&&he._f.refs.forEach(pe=>{pe.disabled=he._f.disabled||V}))},0,!1))},ee=(V,Y)=>async te=>{let he;te&&(te.preventDefault&&te.preventDefault(),te.persist&&te.persist());let pe=Gt(a);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:le,values:ye}=await E();e.errors=le,pe=Gt(ye)}else await N(r);if(s.disabled.size)for(const le of s.disabled)Mt(pe,le);if(Mt(e.errors,"root"),kn(e.errors)){f.state.next({errors:{}});try{await V(pe,te)}catch(le){he=le}}else Y&&await Y({...e.errors},te),ue(),setTimeout(ue);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:kn(e.errors)&&!he,submitCount:e.submitCount+1,errors:e.errors}),he)throw he},_e=(V,Y={})=>{me(r,V)&&(At(Y.defaultValue)?H(V,Gt(me(o,V))):(H(V,Y.defaultValue),ct(o,V,Gt(Y.defaultValue))),Y.keepTouched||Mt(e.touchedFields,V),Y.keepDirty||(Mt(e.dirtyFields,V),e.isDirty=Y.defaultValue?A(V,Gt(me(o,V))):A()),Y.keepError||(Mt(e.errors,V),l.isValid&&p()),f.state.next({...e}))},Me=(V,Y={})=>{const te=V?Gt(V):o,he=Gt(te),pe=kn(V),le=pe?o:he;if(Y.keepDefaultValues||(o=te),!Y.keepValues){if(Y.keepDirtyValues){const ye=new Set([...s.mount,...Object.keys(Vi(o,a))]);for(const We of Array.from(ye))me(e.dirtyFields,We)?ct(le,We,me(a,We)):H(We,me(le,We))}else{if(Pp&&At(V))for(const ye of s.mount){const We=me(r,ye);if(We&&We._f){const Ge=Array.isArray(We._f.refs)?We._f.refs[0]:We._f.ref;if(Ol(Ge)){const Qt=Ge.closest("form");if(Qt){Qt.reset();break}}}}if(Y.keepFieldsRef)for(const ye of s.mount)H(ye,me(le,ye));else r={}}a=t.shouldUnregister?Y.keepDefaultValues?Gt(o):{}:Gt(le),f.array.next({values:{...le}}),f.state.next({values:{...le}})}s={mount:Y.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!l.isValid||!!Y.keepIsValid||!!Y.keepDirtyValues,i.watch=!!t.shouldUnregister,f.state.next({submitCount:Y.keepSubmitCount?e.submitCount:0,isDirty:pe?!1:Y.keepDirty?e.isDirty:!!(Y.keepDefaultValues&&!po(V,o)),isSubmitted:Y.keepIsSubmitted?e.isSubmitted:!1,dirtyFields:pe?{}:Y.keepDirtyValues?Y.keepDefaultValues&&a?Vi(o,a):e.dirtyFields:Y.keepDefaultValues&&V?Vi(o,V):Y.keepDirty?e.dirtyFields:{},touchedFields:Y.keepTouched?e.touchedFields:{},errors:Y.keepErrors?e.errors:{},isSubmitSuccessful:Y.keepIsSubmitSuccessful?e.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:o})},Ye=(V,Y)=>Me(dr(V)?V(a):V,Y),Ze=(V,Y={})=>{const te=me(r,V),he=te&&te._f;if(he){const pe=he.refs?he.refs[0]:he.ref;pe.focus&&(pe.focus(),Y.shouldSelect&&dr(pe.select)&&pe.select())}},Lt=V=>{e={...e,...V}},Ct={control:{register:ce,unregister:X,getFieldState:L,handleSubmit:ee,setError:q,_subscribe:oe,_runSchema:E,_focusError:ue,_getWatch:P,_getDirty:A,_setValid:p,_setFieldArray:g,_setDisabledField:re,_setErrors:w,_getFieldArray:j,_reset:Me,_resetDefaultValues:()=>dr(t.defaultValues)&&t.defaultValues().then(V=>{Ye(V,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:$,_disableForm:se,_subjects:f,_proxyFormState:l,get _fields(){return r},get _formValues(){return a},get _state(){return i},set _state(V){i=V},get _defaultValues(){return o},get _names(){return s},set _names(V){s=V},get _formState(){return e},get _options(){return t},set _options(V){t={...t,...V}}},subscribe:ae,trigger:O,register:ce,handleSubmit:ee,watch:Z,setValue:H,getValues:I,reset:Ye,resetField:_e,clearErrors:K,unregister:X,setError:q,setFocus:Ze,getFieldState:L};return{...Ct,formControl:Ct}}function lu(n={}){const t=D.useRef(void 0),e=D.useRef(void 0),[r,o]=D.useState({isDirty:!1,isValidating:!1,isLoading:dr(n.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1,isReady:!1,defaultValues:dr(n.defaultValues)?void 0:n.defaultValues});if(!t.current)if(n.formControl)t.current={...n.formControl,formState:r},n.defaultValues&&!dr(n.defaultValues)&&n.formControl.reset(n.defaultValues,n.resetOptions);else{const{formControl:i,...s}=d8(n);t.current={...s,formState:r}}const a=t.current.control;return a._options=n,Op(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>o({...a._formState}),reRenderRoot:!0});return o(s=>({...s,isReady:!0})),a._formState.isReady=!0,i},[a]),D.useEffect(()=>a._disableForm(n.disabled),[a,n.disabled]),D.useEffect(()=>{n.mode&&(a._options.mode=n.mode),n.reValidateMode&&(a._options.reValidateMode=n.reValidateMode)},[a,n.mode,n.reValidateMode]),D.useEffect(()=>{n.errors&&(a._setErrors(n.errors),a._focusError())},[a,n.errors]),D.useEffect(()=>{n.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,n.shouldUnregister]),D.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==r.isDirty&&a._subjects.state.next({isDirty:i})}},[a,r.isDirty]),D.useEffect(()=>{n.values&&!po(n.values,e.current)?(a._reset(n.values,{keepFieldsRef:!0,...a._options.resetOptions}),e.current=n.values,o(i=>({...i}))):a._resetDefaultValues()},[a,n.values]),D.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=Y2(r,a),t.current}const mx=(n,t,e)=>{if(n&&"reportValidity"in n){const r=me(e,t);n.setCustomValidity(r&&r.message||""),n.reportValidity()}},gx=(n,t)=>{for(const e in t.fields){const r=t.fields[e];r&&r.ref&&"reportValidity"in r.ref?mx(r.ref,e,n):r.refs&&r.refs.forEach(o=>mx(o,e,n))}},f8=(n,t)=>{t.shouldUseNativeValidation&&gx(n,t);const e={};for(const r in n){const o=me(t.fields,r),a=Object.assign(n[r]||{},{ref:o&&o.ref});if(h8(t.names||Object.keys(n),r)){const i=Object.assign({},me(e,r));ct(i,"root",a),ct(e,r,i)}else ct(e,r,a)}return e},h8=(n,t)=>n.some(e=>e.startsWith(t+"."));var p8=function(n,t){for(var e={};n.length;){var r=n[0],o=r.code,a=r.message,i=r.path.join(".");if(!e[i])if("unionErrors"in r){var s=r.unionErrors[0].errors[0];e[i]={message:s.message,type:s.code}}else e[i]={message:a,type:o};if("unionErrors"in r&&r.unionErrors.forEach(function(l){return l.errors.forEach(function(d){return n.push(d)})}),t){var u=e[i].types,c=u&&u[r.code];e[i]=Q2(i,t,e,o,c?[].concat(c,r.message):r.message)}n.shift()}return e},du=function(n,t,e){return e===void 0&&(e={}),function(r,o,a){try{return Promise.resolve(function(i,s){try{var u=Promise.resolve(n[e.mode==="sync"?"parse":"parseAsync"](r,t)).then(function(c){return a.shouldUseNativeValidation&&gx({},a),{errors:{},values:e.raw?r:c}})}catch(c){return s(c)}return u&&u.then?u.then(void 0,s):u}(0,function(i){if(function(s){return Array.isArray(s==null?void 0:s.errors)}(i))return{values:{},errors:f8(p8(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},rt;(function(n){n.assertEqual=o=>{};function t(o){}n.assertIs=t;function e(o){throw new Error}n.assertNever=e,n.arrayToEnum=o=>{const a={};for(const i of o)a[i]=i;return a},n.getValidEnumValues=o=>{const a=n.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(const s of a)i[s]=o[s];return n.objectValues(i)},n.objectValues=o=>n.objectKeys(o).map(function(a){return o[a]}),n.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const a=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},n.find=(o,a)=>{for(const i of o)if(a(i))return i},n.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(rt||(rt={}));var yx;(function(n){n.mergeShapes=(t,e)=>({...t,...e})})(yx||(yx={}));const Ee=rt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ko=n=>{switch(typeof n){case"undefined":return Ee.undefined;case"string":return Ee.string;case"number":return Number.isNaN(n)?Ee.nan:Ee.number;case"boolean":return Ee.boolean;case"function":return Ee.function;case"bigint":return Ee.bigint;case"symbol":return Ee.symbol;case"object":return Array.isArray(n)?Ee.array:n===null?Ee.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Ee.promise:typeof Map<"u"&&n instanceof Map?Ee.map:typeof Set<"u"&&n instanceof Set?Ee.set:typeof Date<"u"&&n instanceof Date?Ee.date:Ee.object;default:return Ee.unknown}},fe=rt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class vo extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(a){return a.message},r={_errors:[]},o=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(e(i));else{let s=r,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(e(i))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return o(this),r}static assert(t){if(!(t instanceof vo))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,rt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},r=[];for(const o of this.issues)if(o.path.length>0){const a=o.path[0];e[a]=e[a]||[],e[a].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:e}}get formErrors(){return this.flatten()}}vo.create=n=>new vo(n);const Bp=(n,t)=>{let e;switch(n.code){case fe.invalid_type:n.received===Ee.undefined?e="Required":e=`Expected ${n.expected}, received ${n.received}`;break;case fe.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(n.expected,rt.jsonStringifyReplacer)}`;break;case fe.unrecognized_keys:e=`Unrecognized key(s) in object: ${rt.joinValues(n.keys,", ")}`;break;case fe.invalid_union:e="Invalid input";break;case fe.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${rt.joinValues(n.options)}`;break;case fe.invalid_enum_value:e=`Invalid enum value. Expected ${rt.joinValues(n.options)}, received '${n.received}'`;break;case fe.invalid_arguments:e="Invalid function arguments";break;case fe.invalid_return_type:e="Invalid function return type";break;case fe.invalid_date:e="Invalid date";break;case fe.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(e=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?e=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?e=`Invalid input: must end with "${n.validation.endsWith}"`:rt.assertNever(n.validation):n.validation!=="regex"?e=`Invalid ${n.validation}`:e="Invalid";break;case fe.too_small:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?e=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:e="Invalid input";break;case fe.too_big:n.type==="array"?e=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?e=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?e=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?e=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?e=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:e="Invalid input";break;case fe.custom:e="Invalid input";break;case fe.invalid_intersection_types:e="Intersection results could not be merged";break;case fe.not_multiple_of:e=`Number must be a multiple of ${n.multipleOf}`;break;case fe.not_finite:e="Number must be finite";break;default:e=t.defaultError,rt.assertNever(n)}return{message:e}};let v8=Bp;function m8(){return v8}const g8=n=>{const{data:t,path:e,errorMaps:r,issueData:o}=n,a=[...e,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="";const u=r.filter(c=>!!c).slice().reverse();for(const c of u)s=c(i,{data:t,defaultError:s}).message;return{...o,path:a,message:s}};function be(n,t){const e=m8(),r=g8({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,e,e===Bp?void 0:Bp].filter(o=>!!o)});n.common.issues.push(r)}class Hn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const r=[];for(const o of e){if(o.status==="aborted")return Re;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,e){const r=[];for(const o of e){const a=await o.key,i=await o.value;r.push({key:a,value:i})}return Hn.mergeObjectSync(t,r)}static mergeObjectSync(t,e){const r={};for(const o of e){const{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return Re;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[a.value]=i.value)}return{status:t.value,value:r}}}const Re=Object.freeze({status:"aborted"}),fu=n=>({status:"dirty",value:n}),Qn=n=>({status:"valid",value:n}),bx=n=>n.status==="aborted",xx=n=>n.status==="dirty",Ui=n=>n.status==="valid",Ml=n=>typeof Promise<"u"&&n instanceof Promise;var Pe;(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Pe||(Pe={}));class Yo{constructor(t,e,r,o){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const wx=(n,t)=>{if(Ui(t))return{success:!0,data:t.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new vo(n.common.issues);return this._error=e,this._error}}};function Ke(n){if(!n)return{};const{errorMap:t,invalid_type_error:e,required_error:r,description:o}=n;if(t&&(e||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(i,s)=>{const{message:u}=n;return i.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??r??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:u??e??s.defaultError}},description:o}}class tt{get description(){return this._def.description}_getType(t){return Ko(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Hn,ctx:{common:t.parent.common,data:t.data,parsedType:Ko(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Ml(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){const r={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parseSync({data:t,path:r.path,parent:r});return wx(r,o)}"~validate"(t){var r,o;const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:e});return Ui(a)?{value:a.value}:{issues:e.common.issues}}catch(a){(o=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(a=>Ui(a)?{value:a.value}:{issues:e.common.issues})}async parseAsync(t,e){const r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){const r={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ko(t)},o=this._parse({data:t,path:r.path,parent:r}),a=await(Ml(o)?o:Promise.resolve(o));return wx(r,a)}refine(t,e){const r=o=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(o):e;return this._refinement((o,a)=>{const i=t(o),s=()=>a.addIssue({code:fe.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,e){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof e=="function"?e(r,o):e),!1))}_refinement(t){return new Gi({schema:this,typeName:Le.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Qo.create(this,this._def)}nullable(){return qi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Hr.create(this)}promise(){return Ll.create(this,this._def)}or(t){return Fl.create([this,t],this._def)}and(t){return Rl.create(this,t,this._def)}transform(t){return new Gi({...Ke(this._def),schema:this,typeName:Le.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Up({...Ke(this._def),innerType:this,defaultValue:e,typeName:Le.ZodDefault})}brand(){return new W8({typeName:Le.ZodBranded,type:this,...Ke(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new zp({...Ke(this._def),innerType:this,catchValue:e,typeName:Le.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Hp.create(this,t)}readonly(){return Gp.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const y8=/^c[^\s-]{8,}$/i,b8=/^[0-9a-z]+$/,x8=/^[0-9A-HJKMNP-TV-Z]{26}$/i,w8=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,C8=/^[a-z0-9_-]{21}$/i,_8=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E8=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,S8=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N8="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wp;const $8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,k8=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,P8=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,I8=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,A8=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T8=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Cx="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",O8=new RegExp(`^${Cx}$`);function _x(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);const e=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function D8(n){return new RegExp(`^${_x(n)}$`)}function M8(n){let t=`${Cx}T${_x(n)}`;const e=[];return e.push(n.local?"Z?":"Z"),n.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function F8(n,t){return!!((t==="v4"||!t)&&$8.test(n)||(t==="v6"||!t)&&P8.test(n))}function R8(n,t){if(!_8.test(n))return!1;try{const[e]=n.split(".");if(!e)return!1;const r=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&(o==null?void 0:o.typ)!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function L8(n,t){return!!((t==="v4"||!t)&&k8.test(n)||(t==="v6"||!t)&&I8.test(n))}class Xo extends tt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Ee.string){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.string,received:a.parsedType}),Re}const r=new Hn;let o;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(t,o),i?be(o,{code:fe.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&be(o,{code:fe.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")S8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"email",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Wp||(Wp=new RegExp(N8,"u")),Wp.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"emoji",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")w8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"uuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")C8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"nanoid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")y8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")b8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cuid2",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")x8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ulid",code:fe.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),be(o,{validation:"url",code:fe.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"regex",code:fe.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?M8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?O8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?D8(a).test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:fe.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?E8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"duration",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?F8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"ip",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?R8(t.data,a.alg)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"jwt",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?L8(t.data,a.version)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"cidr",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?A8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64",code:fe.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?T8.test(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{validation:"base64url",code:fe.invalid_string,message:a.message}),r.dirty()):rt.assertNever(a);return{status:r.value,value:t.data}}_regex(t,e,r){return this.refinement(o=>t.test(o),{validation:e,code:fe.invalid_string,...Pe.errToObj(r)})}_addCheck(t){return new Xo({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Pe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Pe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Pe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Pe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Pe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Pe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Pe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Pe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Pe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Pe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Pe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Pe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Pe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Pe.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Pe.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Pe.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...Pe.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...Pe.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...Pe.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...Pe.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...Pe.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...Pe.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...Pe.errToObj(e)})}nonempty(t){return this.min(1,Pe.errToObj(t))}trim(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Xo.create=n=>new Xo({checks:[],typeName:Le.ZodString,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});function B8(n,t){const e=(n.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=e>r?e:r,a=Number.parseInt(n.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return a%i/10**o}class hu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Ee.number){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.number,received:a.parsedType}),Re}let r;const o=new Hn;for(const a of this._def.checks)a.kind==="int"?rt.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?B8(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_finite,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new hu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new hu({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Pe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:Pe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pe.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&rt.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(e===null||r.value>e)&&(e=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(e)&&Number.isFinite(t)}}hu.create=n=>new hu({checks:[],typeName:Le.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class pu extends tt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Ee.bigint)return this._getInvalidInput(t);let r;const o=new Hn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),be(r,{code:fe.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):rt.assertNever(a);return{status:o.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.bigint,received:e.parsedType}),Re}gte(t,e){return this.setLimit("min",t,!0,Pe.toString(e))}gt(t,e){return this.setLimit("min",t,!1,Pe.toString(e))}lte(t,e){return this.setLimit("max",t,!0,Pe.toString(e))}lt(t,e){return this.setLimit("max",t,!1,Pe.toString(e))}setLimit(t,e,r,o){return new pu({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:r,message:Pe.toString(o)}]})}_addCheck(t){return new pu({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pe.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:Pe.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}pu.create=n=>new pu({checks:[],typeName:Le.ZodBigInt,coerce:(n==null?void 0:n.coerce)??!1,...Ke(n)});class Ex extends tt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Ee.boolean){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.boolean,received:r.parsedType}),Re}return Qn(t.data)}}Ex.create=n=>new Ex({typeName:Le.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...Ke(n)});class vu extends tt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Ee.date){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_type,expected:Ee.date,received:a.parsedType}),Re}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return be(a,{code:fe.invalid_date}),Re}const r=new Hn;let o;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(o=this._getOrReturnCtx(t,o),be(o,{code:fe.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):rt.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new vu({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:Pe.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:Pe.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}vu.create=n=>new vu({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:Le.ZodDate,...Ke(n)});class Sx extends tt{_parse(t){if(this._getType(t)!==Ee.symbol){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.symbol,received:r.parsedType}),Re}return Qn(t.data)}}Sx.create=n=>new Sx({typeName:Le.ZodSymbol,...Ke(n)});class Nx extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.undefined,received:r.parsedType}),Re}return Qn(t.data)}}Nx.create=n=>new Nx({typeName:Le.ZodUndefined,...Ke(n)});class $x extends tt{_parse(t){if(this._getType(t)!==Ee.null){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.null,received:r.parsedType}),Re}return Qn(t.data)}}$x.create=n=>new $x({typeName:Le.ZodNull,...Ke(n)});class mu extends tt{constructor(){super(...arguments),this._any=!0}_parse(t){return Qn(t.data)}}mu.create=n=>new mu({typeName:Le.ZodAny,...Ke(n)});class kx extends tt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qn(t.data)}}kx.create=n=>new kx({typeName:Le.ZodUnknown,...Ke(n)});class Zo extends tt{_parse(t){const e=this._getOrReturnCtx(t);return be(e,{code:fe.invalid_type,expected:Ee.never,received:e.parsedType}),Re}}Zo.create=n=>new Zo({typeName:Le.ZodNever,...Ke(n)});class Px extends tt{_parse(t){if(this._getType(t)!==Ee.undefined){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.void,received:r.parsedType}),Re}return Qn(t.data)}}Px.create=n=>new Px({typeName:Le.ZodVoid,...Ke(n)});class Hr extends tt{_parse(t){const{ctx:e,status:r}=this._processInputParams(t),o=this._def;if(e.parsedType!==Ee.array)return be(e,{code:fe.invalid_type,expected:Ee.array,received:e.parsedType}),Re;if(o.exactLength!==null){const i=e.data.length>o.exactLength.value,s=e.data.length<o.exactLength.value;(i||s)&&(be(e,{code:i?fe.too_big:fe.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&e.data.length<o.minLength.value&&(be(e,{code:fe.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&e.data.length>o.maxLength.value&&(be(e,{code:fe.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),e.common.async)return Promise.all([...e.data].map((i,s)=>o.type._parseAsync(new Yo(e,i,e.path,s)))).then(i=>Hn.mergeArray(r,i));const a=[...e.data].map((i,s)=>o.type._parseSync(new Yo(e,i,e.path,s)));return Hn.mergeArray(r,a)}get element(){return this._def.type}min(t,e){return new Hr({...this._def,minLength:{value:t,message:Pe.toString(e)}})}max(t,e){return new Hr({...this._def,maxLength:{value:t,message:Pe.toString(e)}})}length(t,e){return new Hr({...this._def,exactLength:{value:t,message:Pe.toString(e)}})}nonempty(t){return this.min(1,t)}}Hr.create=(n,t)=>new Hr({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Le.ZodArray,...Ke(t)});function zi(n){if(n instanceof Ft){const t={};for(const e in n.shape){const r=n.shape[e];t[e]=Qo.create(zi(r))}return new Ft({...n._def,shape:()=>t})}else return n instanceof Hr?new Hr({...n._def,type:zi(n.element)}):n instanceof Qo?Qo.create(zi(n.unwrap())):n instanceof qi?qi.create(zi(n.unwrap())):n instanceof ja?ja.create(n.items.map(t=>zi(t))):n}class Ft extends tt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=rt.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==Ee.object){const c=this._getOrReturnCtx(t);return be(c,{code:fe.invalid_type,expected:Ee.object,received:c.parsedType}),Re}const{status:r,ctx:o}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Zo&&this._def.unknownKeys==="strip"))for(const c in o.data)i.includes(c)||s.push(c);const u=[];for(const c of i){const l=a[c],d=o.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Yo(o,d,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Zo){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of s)u.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(c==="strict")s.length>0&&(be(o,{code:fe.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of s){const d=o.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Yo(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of u){const d=await l.key,f=await l.value;c.push({key:d,value:f,alwaysSet:l.alwaysSet})}return c}).then(c=>Hn.mergeObjectSync(r,c)):Hn.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return Pe.errToObj,new Ft({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,r)=>{var a,i;const o=((i=(a=this._def).errorMap)==null?void 0:i.call(a,e,r).message)??r.defaultError;return e.code==="unrecognized_keys"?{message:Pe.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new Ft({...this._def,unknownKeys:"strip"})}passthrough(){return new Ft({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ft({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ft({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Le.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new Ft({...this._def,catchall:t})}pick(t){const e={};for(const r of rt.objectKeys(t))t[r]&&this.shape[r]&&(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}omit(t){const e={};for(const r of rt.objectKeys(this.shape))t[r]||(e[r]=this.shape[r]);return new Ft({...this._def,shape:()=>e})}deepPartial(){return zi(this)}partial(t){const e={};for(const r of rt.objectKeys(this.shape)){const o=this.shape[r];t&&!t[r]?e[r]=o:e[r]=o.optional()}return new Ft({...this._def,shape:()=>e})}required(t){const e={};for(const r of rt.objectKeys(this.shape))if(t&&!t[r])e[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Qo;)a=a._def.innerType;e[r]=a}return new Ft({...this._def,shape:()=>e})}keyof(){return Tx(rt.objectKeys(this.shape))}}Ft.create=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.strictCreate=(n,t)=>new Ft({shape:()=>n,unknownKeys:"strict",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)}),Ft.lazycreate=(n,t)=>new Ft({shape:n,unknownKeys:"strip",catchall:Zo.create(),typeName:Le.ZodObject,...Ke(t)});class Fl extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=this._def.options;function o(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new vo(s.ctx.common.issues));return be(e,{code:fe.invalid_union,unionErrors:i}),Re}if(e.common.async)return Promise.all(r.map(async a=>{const i={...e,common:{...e.common,issues:[]},parent:null};return{result:await a._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(o);{let a;const i=[];for(const u of r){const c={...e,common:{...e.common,issues:[]},parent:null},l=u._parseSync({data:e.data,path:e.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return e.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(u=>new vo(u));return be(e,{code:fe.invalid_union,unionErrors:s}),Re}}get options(){return this._def.options}}Fl.create=(n,t)=>new Fl({options:n,typeName:Le.ZodUnion,...Ke(t)});function Vp(n,t){const e=Ko(n),r=Ko(t);if(n===t)return{valid:!0,data:n};if(e===Ee.object&&r===Ee.object){const o=rt.objectKeys(t),a=rt.objectKeys(n).filter(s=>o.indexOf(s)!==-1),i={...n,...t};for(const s of a){const u=Vp(n[s],t[s]);if(!u.valid)return{valid:!1};i[s]=u.data}return{valid:!0,data:i}}else if(e===Ee.array&&r===Ee.array){if(n.length!==t.length)return{valid:!1};const o=[];for(let a=0;a<n.length;a++){const i=n[a],s=t[a],u=Vp(i,s);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return e===Ee.date&&r===Ee.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}class Rl extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=(a,i)=>{if(bx(a)||bx(i))return Re;const s=Vp(a.value,i.value);return s.valid?((xx(a)||xx(i))&&e.dirty(),{status:e.value,value:s.data}):(be(r,{code:fe.invalid_intersection_types}),Re)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Rl.create=(n,t,e)=>new Rl({left:n,right:t,typeName:Le.ZodIntersection,...Ke(e)});class ja extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.array)return be(r,{code:fe.invalid_type,expected:Ee.array,received:r.parsedType}),Re;if(r.data.length<this._def.items.length)return be(r,{code:fe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Re;!this._def.rest&&r.data.length>this._def.items.length&&(be(r,{code:fe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const a=[...r.data].map((i,s)=>{const u=this._def.items[s]||this._def.rest;return u?u._parse(new Yo(r,i,r.path,s)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>Hn.mergeArray(e,i)):Hn.mergeArray(e,a)}get items(){return this._def.items}rest(t){return new ja({...this._def,rest:t})}}ja.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ja({items:n,typeName:Le.ZodTuple,rest:null,...Ke(t)})};class Ix extends tt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.map)return be(r,{code:fe.invalid_type,expected:Ee.map,received:r.parsedType}),Re;const o=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([s,u],c)=>({key:o._parse(new Yo(r,s,r.path,[c,"key"])),value:a._parse(new Yo(r,u,r.path,[c,"value"]))}));if(r.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}})}else{const s=new Map;for(const u of i){const c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return Re;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),s.set(c.value,l.value)}return{status:e.value,value:s}}}}Ix.create=(n,t,e)=>new Ix({valueType:t,keyType:n,typeName:Le.ZodMap,...Ke(e)});class gu extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==Ee.set)return be(r,{code:fe.invalid_type,expected:Ee.set,received:r.parsedType}),Re;const o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(be(r,{code:fe.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),e.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(be(r,{code:fe.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),e.dirty());const a=this._def.valueType;function i(u){const c=new Set;for(const l of u){if(l.status==="aborted")return Re;l.status==="dirty"&&e.dirty(),c.add(l.value)}return{status:e.value,value:c}}const s=[...r.data.values()].map((u,c)=>a._parse(new Yo(r,u,r.path,c)));return r.common.async?Promise.all(s).then(u=>i(u)):i(s)}min(t,e){return new gu({...this._def,minSize:{value:t,message:Pe.toString(e)}})}max(t,e){return new gu({...this._def,maxSize:{value:t,message:Pe.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}gu.create=(n,t)=>new gu({valueType:n,minSize:null,maxSize:null,typeName:Le.ZodSet,...Ke(t)});class Ax extends tt{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Ax.create=(n,t)=>new Ax({getter:n,typeName:Le.ZodLazy,...Ke(t)});class jp extends tt{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return be(e,{received:e.data,code:fe.invalid_literal,expected:this._def.value}),Re}return{status:"valid",value:t.data}}get value(){return this._def.value}}jp.create=(n,t)=>new jp({value:n,typeName:Le.ZodLiteral,...Ke(t)});function Tx(n,t){return new Hi({values:n,typeName:Le.ZodEnum,...Ke(t)})}class Hi extends tt{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{expected:rt.joinValues(r),received:e.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),r=this._def.values;return be(e,{received:e.data,code:fe.invalid_enum_value,options:r}),Re}return Qn(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Hi.create(t,{...this._def,...e})}exclude(t,e=this._def){return Hi.create(this.options.filter(r=>!t.includes(r)),{...this._def,...e})}}Hi.create=Tx;class Ox extends tt{_parse(t){const e=rt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Ee.string&&r.parsedType!==Ee.number){const o=rt.objectValues(e);return be(r,{expected:rt.joinValues(o),received:r.parsedType,code:fe.invalid_type}),Re}if(this._cache||(this._cache=new Set(rt.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const o=rt.objectValues(e);return be(r,{received:r.data,code:fe.invalid_enum_value,options:o}),Re}return Qn(t.data)}get enum(){return this._def.values}}Ox.create=(n,t)=>new Ox({values:n,typeName:Le.ZodNativeEnum,...Ke(t)});class Ll extends tt{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==Ee.promise&&e.common.async===!1)return be(e,{code:fe.invalid_type,expected:Ee.promise,received:e.parsedType}),Re;const r=e.parsedType===Ee.promise?e.data:Promise.resolve(e.data);return Qn(r.then(o=>this._def.type.parseAsync(o,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Ll.create=(n,t)=>new Ll({type:n,typeName:Le.ZodPromise,...Ke(t)});class Gi extends tt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Le.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:r}=this._processInputParams(t),o=this._def.effect||null,a={addIssue:i=>{be(r,i),i.fatal?e.abort():e.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){const i=o.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async s=>{if(e.value==="aborted")return Re;const u=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return u.status==="aborted"?Re:u.status==="dirty"||e.value==="dirty"?fu(u.value):u});{if(e.value==="aborted")return Re;const s=this._def.schema._parseSync({data:i,path:r.path,parent:r});return s.status==="aborted"?Re:s.status==="dirty"||e.value==="dirty"?fu(s.value):s}}if(o.type==="refinement"){const i=s=>{const u=o.refinement(s,a);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){const s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?Re:(s.status==="dirty"&&e.dirty(),i(s.value).then(()=>({status:e.value,value:s.value}))))}if(o.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ui(i))return Re;const s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Ui(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:e.value,value:s})):Re);rt.assertNever(o)}}Gi.create=(n,t,e)=>new Gi({schema:n,typeName:Le.ZodEffects,effect:t,...Ke(e)}),Gi.createWithPreprocess=(n,t,e)=>new Gi({schema:t,effect:{type:"preprocess",transform:n},typeName:Le.ZodEffects,...Ke(e)});class Qo extends tt{_parse(t){return this._getType(t)===Ee.undefined?Qn(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Qo.create=(n,t)=>new Qo({innerType:n,typeName:Le.ZodOptional,...Ke(t)});class qi extends tt{_parse(t){return this._getType(t)===Ee.null?Qn(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}qi.create=(n,t)=>new qi({innerType:n,typeName:Le.ZodNullable,...Ke(t)});class Up extends tt{_parse(t){const{ctx:e}=this._processInputParams(t);let r=e.data;return e.parsedType===Ee.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Up.create=(n,t)=>new Up({innerType:n,typeName:Le.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ke(t)});class zp extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ml(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vo(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}zp.create=(n,t)=>new zp({innerType:n,typeName:Le.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ke(t)});class Dx extends tt{_parse(t){if(this._getType(t)!==Ee.nan){const r=this._getOrReturnCtx(t);return be(r,{code:fe.invalid_type,expected:Ee.nan,received:r.parsedType}),Re}return{status:"valid",value:t.data}}}Dx.create=n=>new Dx({typeName:Le.ZodNaN,...Ke(n)});class W8 extends tt{_parse(t){const{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}}class Hp extends tt{_parse(t){const{status:e,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Re:a.status==="dirty"?(e.dirty(),fu(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Re:o.status==="dirty"?(e.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,e){return new Hp({in:t,out:e,typeName:Le.ZodPipeline})}}class Gp extends tt{_parse(t){const e=this._def.innerType._parse(t),r=o=>(Ui(o)&&(o.value=Object.freeze(o.value)),o);return Ml(e)?e.then(o=>r(o)):r(e)}unwrap(){return this._def.innerType}}Gp.create=(n,t)=>new Gp({innerType:n,typeName:Le.ZodReadonly,...Ke(t)});function Mx(n,t){const e=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof e=="string"?{message:e}:e}function V8(n,t={},e){return n?mu.create().superRefine((r,o)=>{const a=n(r);if(a instanceof Promise)return a.then(i=>{if(!i){const s=Mx(t,r),u=s.fatal??e??!0;o.addIssue({code:"custom",...s,fatal:u})}});if(!a){const i=Mx(t,r),s=i.fatal??e??!0;o.addIssue({code:"custom",...i,fatal:s})}}):mu.create()}var Le;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Le||(Le={}));const qp=(n,t={message:`Input not instance of ${n.name}`})=>V8(e=>e instanceof n,t),Xt=Xo.create,Fx=vu.create;mu.create,Zo.create,Hr.create;const yu=Ft.create;Fl.create,Rl.create,ja.create;const j8=jp.create;Hi.create,Ll.create,Qo.create,qi.create;const bu=KD,Rx=k.createContext({}),Tt=({...n})=>b.jsx(Rx.Provider,{value:{name:n.name},children:b.jsx(ZD,{...n})}),Bl=()=>{const n=k.useContext(Rx),t=k.useContext(Lx),{getFieldState:e,formState:r}=Tl(),o=e(n.name,r);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:n.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...o}},Lx=k.createContext({}),St=k.forwardRef(({className:n,...t},e)=>{const r=k.useId();return b.jsx(Lx.Provider,{value:{id:r},children:b.jsx("div",{ref:e,className:Be("space-y-2",n),...t})})});St.displayName="FormItem";const Nt=k.forwardRef(({className:n,...t},e)=>{const{error:r,formItemId:o}=Bl();return b.jsx(Ea,{ref:e,className:Be(r&&"text-destructive",n),htmlFor:o,...t})});Nt.displayName="FormLabel";const $t=k.forwardRef(({...n},t)=>{const{error:e,formItemId:r,formDescriptionId:o,formMessageId:a}=Bl();return b.jsx(Vm,{ref:t,id:r,"aria-describedby":e?`${o} ${a}`:`${o}`,"aria-invalid":!!e,...n})});$t.displayName="FormControl";const U8=k.forwardRef(({className:n,...t},e)=>{const{formDescriptionId:r}=Bl();return b.jsx("p",{ref:e,id:r,className:Be("text-sm text-muted-foreground",n),...t})});U8.displayName="FormDescription";const kt=k.forwardRef(({className:n,children:t,...e},r)=>{const{error:o,formMessageId:a}=Bl(),i=o?String(o==null?void 0:o.message):t;return i?b.jsx("p",{ref:r,id:a,className:Be("text-sm font-medium text-destructive",n),...e,children:i}):null});kt.displayName="FormMessage";const z8=yu({bank_statement:qp(File).optional().refine(n=>n!==void 0,"Bank statement is required"),company_structure:qp(File).optional().refine(n=>n!==void 0,"Company structure document is required"),certificate_of_registration:qp(File).optional().refine(n=>n!==void 0,"Certificate of registration is required")}),H8=({data:n,onDataChange:t,onContinue:e,onBack:r,renderProgress:o})=>{const a=D.useRef(null),i=D.useRef(null),s=D.useRef(null),u=lu({resolver:du(z8),defaultValues:{bank_statement:n.bank_statement||void 0,company_structure:n.company_structure||void 0,certificate_of_registration:n.certificate_of_registration||void 0}}),c=f=>{t(f),e()},l=(f,h)=>{u.setValue(f,h),t({[f]:h})},d=({field:f,label:h,description:m,inputRef:p})=>{const v=u.watch(f);return b.jsx(Tt,{control:u.control,name:f,render:()=>b.jsxs(St,{children:[b.jsx(Nt,{children:h}),b.jsx($t,{children:b.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-6",children:[b.jsx("input",{ref:p,type:"file",accept:".pdf,.jpg,.jpeg,.png,.doc,.docx",className:"hidden",onChange:g=>{var w;const y=((w=g.target.files)==null?void 0:w[0])||null;l(f,y)}}),v?b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(nE,{className:"w-5 h-5 text-primary"}),b.jsx("span",{className:"text-sm font-medium",children:v.name})]}),b.jsx(_t,{type:"button",variant:"ghost",size:"sm",onClick:()=>{l(f,null),p.current&&(p.current.value="")},children:b.jsx(Md,{className:"w-4 h-4"})})]}):b.jsxs("div",{className:"text-center cursor-pointer",onClick:()=>{var g;return(g=p.current)==null?void 0:g.click()},children:[b.jsx(oE,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground"}),b.jsx("p",{className:"font-medium",children:h}),b.jsx("p",{className:"text-sm text-muted-foreground",children:m}),b.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Supported: PDF, JPG, PNG, DOC, DOCX"})]})]})}),b.jsx(kt,{})]})})};return b.jsxs(hn,{className:"w-full max-w-2xl mx-auto",children:[b.jsx(Oo,{children:b.jsx(Do,{title:"Company Documents",subTitle:"Please upload the required company documents",onBack:r})}),b.jsxs(pn,{children:[b.jsx(bu,{...u,children:b.jsxs("form",{onSubmit:u.handleSubmit(c),className:"space-y-6",children:[b.jsx(d,{field:"bank_statement",label:"Bank Statement",description:"Upload your latest bank statement",inputRef:a}),b.jsx(d,{field:"company_structure",label:"Company Structure",description:"Upload document showing directors & legal representatives",inputRef:i}),b.jsx(d,{field:"certificate_of_registration",label:"Certificate of Registration",description:"Upload your company's certificate of registration",inputRef:s}),b.jsx(_t,{type:"submit",className:"w-full",children:"Complete Verification"})]})}),b.jsx("div",{className:"mt-6",children:o()})]})]})};function Bx(n,[t,e]){return Math.min(e,Math.max(t,n))}var G8=k.createContext(void 0);function q8(n){const t=k.useContext(G8);return n||t||"ltr"}var Kp=0;function Wx(){k.useEffect(()=>{const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",n[0]??Vx()),document.body.insertAdjacentElement("beforeend",n[1]??Vx()),Kp++,()=>{Kp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Kp--}},[])}function Vx(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.outline="none",n.style.opacity="0",n.style.position="fixed",n.style.pointerEvents="none",n}var Yp="focusScope.autoFocusOnMount",Xp="focusScope.autoFocusOnUnmount",jx={bubbles:!1,cancelable:!0},K8="FocusScope",Zp=k.forwardRef((n,t)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=n,[s,u]=k.useState(null),c=tr(o),l=tr(a),d=k.useRef(null),f=mt(t,p=>u(p)),h=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let p=function(w){if(h.paused||!s)return;const x=w.target;s.contains(x)?d.current=x:Jo(d.current,{select:!0})},v=function(w){if(h.paused||!s)return;const x=w.relatedTarget;x!==null&&(s.contains(x)||Jo(d.current,{select:!0}))},g=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Jo(s)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(g);return s&&y.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[r,s,h.paused]),k.useEffect(()=>{if(s){Hx.add(h);const p=document.activeElement;if(!s.contains(p)){const g=new CustomEvent(Yp,jx);s.addEventListener(Yp,c),s.dispatchEvent(g),g.defaultPrevented||(Y8(eM(Ux(s)),{select:!0}),document.activeElement===p&&Jo(s))}return()=>{s.removeEventListener(Yp,c),setTimeout(()=>{const g=new CustomEvent(Xp,jx);s.addEventListener(Xp,l),s.dispatchEvent(g),g.defaultPrevented||Jo(p??document.body,{select:!0}),s.removeEventListener(Xp,l),Hx.remove(h)},0)}}},[s,c,l,h]);const m=k.useCallback(p=>{if(!e&&!r||h.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,g=document.activeElement;if(v&&g){const y=p.currentTarget,[w,x]=X8(y);w&&x?!p.shiftKey&&g===x?(p.preventDefault(),e&&Jo(w,{select:!0})):p.shiftKey&&g===w&&(p.preventDefault(),e&&Jo(x,{select:!0})):g===y&&p.preventDefault()}},[e,r,h.paused]);return b.jsx(et.div,{tabIndex:-1,...i,ref:f,onKeyDown:m})});Zp.displayName=K8;function Y8(n,{select:t=!1}={}){const e=document.activeElement;for(const r of n)if(Jo(r,{select:t}),document.activeElement!==e)return}function X8(n){const t=Ux(n),e=zx(t,n),r=zx(t.reverse(),n);return[e,r]}function Ux(n){const t=[],e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)t.push(e.currentNode);return t}function zx(n,t){for(const e of n)if(!Z8(e,{upTo:t}))return e}function Z8(n,{upTo:t}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(t!==void 0&&n===t)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function Q8(n){return n instanceof HTMLInputElement&&"select"in n}function Jo(n,{select:t=!1}={}){if(n&&n.focus){const e=document.activeElement;n.focus({preventScroll:!0}),n!==e&&Q8(n)&&t&&n.select()}}var Hx=J8();function J8(){let n=[];return{add(t){const e=n[0];t!==e&&(e==null||e.pause()),n=Gx(n,t),n.unshift(t)},remove(t){var e;n=Gx(n,t),(e=n[0])==null||e.resume()}}}function Gx(n,t){const e=[...n],r=e.indexOf(t);return r!==-1&&e.splice(r,1),e}function eM(n){return n.filter(t=>t.tagName!=="A")}function tM(n){const t=k.useRef({value:n,previous:n});return k.useMemo(()=>(t.current.value!==n&&(t.current.previous=t.current.value,t.current.value=n),t.current.previous),[n])}var nM=function(n){if(typeof document>"u")return null;var t=Array.isArray(n)?n[0]:n;return t.ownerDocument.body},Ki=new WeakMap,Wl=new WeakMap,Vl={},Qp=0,qx=function(n){return n&&(n.host||qx(n.parentNode))},rM=function(n,t){return t.map(function(e){if(n.contains(e))return e;var r=qx(e);return r&&n.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",n,". Doing nothing"),null)}).filter(function(e){return!!e})},oM=function(n,t,e,r){var o=rM(t,Array.isArray(n)?n:[n]);Vl[e]||(Vl[e]=new WeakMap);var a=Vl[e],i=[],s=new Set,u=new Set(o),c=function(d){!d||s.has(d)||(s.add(d),c(d.parentNode))};o.forEach(c);var l=function(d){!d||u.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))l(f);else try{var h=f.getAttribute(r),m=h!==null&&h!=="false",p=(Ki.get(f)||0)+1,v=(a.get(f)||0)+1;Ki.set(f,p),a.set(f,v),i.push(f),p===1&&m&&Wl.set(f,!0),v===1&&f.setAttribute(e,"true"),m||f.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",f,g)}})};return l(t),s.clear(),Qp++,function(){i.forEach(function(d){var f=Ki.get(d)-1,h=a.get(d)-1;Ki.set(d,f),a.set(d,h),f||(Wl.has(d)||d.removeAttribute(r),Wl.delete(d)),h||d.removeAttribute(e)}),Qp--,Qp||(Ki=new WeakMap,Ki=new WeakMap,Wl=new WeakMap,Vl={})}},Kx=function(n,t,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),o=nM(n);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),oM(r,o,e,"aria-hidden")):function(){return null}},Gr=function(){return Gr=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},Gr.apply(this,arguments)};function Yx(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(n);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(n,r[o])&&(e[r[o]]=n[r[o]]);return e}function aM(n,t,e){if(e||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return n.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var jl="right-scroll-bar-position",Ul="width-before-scroll-bar",iM="with-scroll-bars-hidden",sM="--removed-body-scroll-bar-size";function Jp(n,t){return typeof n=="function"?n(t):n&&(n.current=t),n}function uM(n,t){var e=D.useState(function(){return{value:n,callback:t,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=t,e.facade}var cM=typeof window<"u"?k.useLayoutEffect:k.useEffect,Xx=new WeakMap;function lM(n,t){var e=uM(null,function(r){return n.forEach(function(o){return Jp(o,r)})});return cM(function(){var r=Xx.get(e);if(r){var o=new Set(r),a=new Set(n),i=e.current;o.forEach(function(s){a.has(s)||Jp(s,null)}),a.forEach(function(s){o.has(s)||Jp(s,i)})}Xx.set(e,n)},[n]),e}function dM(n){return n}function fM(n,t){t===void 0&&(t=dM);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:n},useMedium:function(a){var i=t(a,r);return e.push(i),function(){e=e.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;e.length;){var i=e;e=[],i.forEach(a)}e={push:function(s){return a(s)},filter:function(){return e}}},assignMedium:function(a){r=!0;var i=[];if(e.length){var s=e;e=[],s.forEach(a),i=e}var u=function(){var l=i;i=[],l.forEach(a)},c=function(){return Promise.resolve().then(u)};c(),e={push:function(l){i.push(l),c()},filter:function(l){return i=i.filter(l),e}}}};return o}function hM(n){n===void 0&&(n={});var t=fM(null);return t.options=Gr({async:!0,ssr:!1},n),t}var Zx=function(n){var t=n.sideCar,e=Yx(n,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return k.createElement(r,Gr({},e))};Zx.isSideCarExport=!0;function pM(n,t){return n.useMedium(t),Zx}var Qx=hM(),ev=function(){},zl=k.forwardRef(function(n,t){var e=k.useRef(null),r=k.useState({onScrollCapture:ev,onWheelCapture:ev,onTouchMoveCapture:ev}),o=r[0],a=r[1],i=n.forwardProps,s=n.children,u=n.className,c=n.removeScrollBar,l=n.enabled,d=n.shards,f=n.sideCar,h=n.noRelative,m=n.noIsolation,p=n.inert,v=n.allowPinchZoom,g=n.as,y=g===void 0?"div":g,w=n.gapMode,x=Yx(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=lM([e,t]),E=Gr(Gr({},x),o);return k.createElement(k.Fragment,null,l&&k.createElement(C,{sideCar:Qx,removeScrollBar:c,shards:d,noRelative:h,noIsolation:m,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:e,gapMode:w}),i?k.cloneElement(k.Children.only(s),Gr(Gr({},E),{ref:_})):k.createElement(y,Gr({},E,{className:u,ref:_}),s))});zl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zl.classNames={fullWidth:Ul,zeroRight:jl};var vM=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mM(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var t=vM();return t&&n.setAttribute("nonce",t),n}function gM(n,t){n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}function yM(n){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(n)}var bM=function(){var n=0,t=null;return{add:function(e){n==0&&(t=mM())&&(gM(t,e),yM(t)),n++},remove:function(){n--,!n&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xM=function(){var n=bM();return function(t,e){k.useEffect(function(){return n.add(t),function(){n.remove()}},[t&&e])}},Jx=function(){var n=xM(),t=function(e){var r=e.styles,o=e.dynamic;return n(r,o),null};return t},wM={left:0,top:0,right:0,gap:0},tv=function(n){return parseInt(n||"",10)||0},CM=function(n){var t=window.getComputedStyle(document.body),e=t[n==="padding"?"paddingLeft":"marginLeft"],r=t[n==="padding"?"paddingTop":"marginTop"],o=t[n==="padding"?"paddingRight":"marginRight"];return[tv(e),tv(r),tv(o)]},_M=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return wM;var t=CM(n),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-e+t[2]-t[0])}},EM=Jx(),Yi="data-scroll-locked",SM=function(n,t,e,r){var o=n.left,a=n.top,i=n.right,s=n.gap;return e===void 0&&(e="margin"),`
|
|
3930
3930
|
.`.concat(iM,` {
|
|
3931
3931
|
overflow: hidden `).concat(r,`;
|
|
3932
3932
|
padding-right: `).concat(s,"px ").concat(r,`;
|