@hadesz/monitor
Version:
A complete server monitoring system with agents, server and dashboard
2 lines • 839 kB
JavaScript
/*! For license information please see browser.umd.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mongoose=e():t.mongoose=e()}("undefined"!=typeof self?self:this,(()=>(()=>{var t={5507:(t,e,r)=>{"use strict";t.exports=r(1735)},1735:(t,e,r)=>{"use strict";var n=r(365).Buffer;function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(o=function(){return!!t})()}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}r(9906).set(r(6333));var c=r(4304);c.setBrowser(!0),e.Error=r(4888),e.Schema=r(5506),e.Types=r(8941),e.VirtualType=r(459),e.SchemaType=r(4289),e.utils=r(6872),e.Document=c(),e.model=function(t,r){var n=function(t){function e(t,n){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,r){return e=a(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,o()?Reflect.construct(e,r||[],a(t).constructor):e.apply(t,r))}(this,e,[t,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(e.Document);return n.modelName=t,n},"undefined"!=typeof window&&(window.mongoose=t.exports,window.Buffer=n)},3434:(t,e,r)=>{"use strict";var n=r(8727),i=r(9620).EventEmitter,o=r(4888),a=r(5506),s=r(6079),c=o.ValidationError,u=r(8859),f=r(5721);function l(t,e,r,i,c){if(!(this instanceof l))return new l(t,e,r,i,c);if(f(e)&&!e.instanceOfSchema&&(e=new a(e)),e=this.schema||e,!this.schema&&e.options._id&&void 0===(t=t||{})._id&&(t._id=new s),!e)throw new o.MissingSchemaError;for(var h in this.$__setSchema(e),n.call(this,t,r,i,c),u(this,e,{decorateDoc:!0}),e.methods)this[h]=e.methods[h];for(var p in e.statics)this[p]=e.statics[p]}l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.events=new i,l.$emitter=new i,["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"].forEach((function(t){l[t]=function(){return l.$emitter[t].apply(l.$emitter,arguments)}})),l.ValidationError=c,t.exports=l},6787:(t,e,r)=>{"use strict";function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=r(1795),s=r(3328),c=r(5251),u=r(9739),f=r(2417),l=r(6495),h=r(9981),p=r(2392),d=r(7906),y=r(8751),b=r(5721),m=r(6584),v=r(6872),g=["Polygon","MultiPolygon"];function _(t,e,r){if(Array.isArray(t))t.forEach((function(n,i){if(Array.isArray(n)||b(n))return _(n,e,r);t[i]=e.castForQuery(null,n,r)}));else for(var n=Object.keys(t),i=n.length;i--;){var o=n[i],a=t[o];Array.isArray(a)||b(a)?(_(a,e,r),t[o]=a):t[o]=e.castForQuery({val:a,context:r})}}function w(t,e,r,n){if("strictQuery"in t)return t.strictQuery;if("strictQuery"in e)return e.strictQuery;var i=n&&n.mongooseCollection&&n.mongooseCollection.conn&&n.mongooseCollection.conn.base&&n.mongooseCollection.conn.base.options;return i&&"strictQuery"in i?i.strictQuery:r.strictQuery}t.exports=function t(e,r,i,S){if(Array.isArray(r))throw new Error("Query filter must be an object, got an array ",y.inspect(r));if(null==r)return r;null!=e&&null!=e.discriminators&&null!=r[e.options.discriminatorKey]&&(e=p(e,r[e.options.discriminatorKey])||e);var O,j,$,A,E,x,P=Object.keys(r),M=P.length;for(i=i||{};M--;)if(x=r[A=P[M]],"$or"===A||"$nor"===A||"$and"===A){if(!Array.isArray(x))throw new a("Array",x,A);for(var k=x.length-1;k>=0;k--){if(null==x[k]||"object"!==o(x[k]))throw new a("Object",x[k],A+"."+k);var B=Object.keys(x[k]).length,T=x[k][e.options.discriminatorKey];if(null==T)x[k]=t(e,x[k],i,S);else{var I=p(S.schema,T);x[k]=t(I||e,x[k],i,S)}0===Object.keys(x[k]).length&&0!==B&&x.splice(k,1)}0===x.length&&delete r[A]}else{if("$where"===A){if("string"!==(E=o(x))&&"function"!==E)throw new Error("Must have a string or function for $where");"function"===E&&(r[A]=x.toString());continue}if("$expr"===A){x=u(x,e);continue}if("$elemMatch"===A)x=t(e,x,i,S);else if("$text"===A)x=l(x,A);else if("$comment"!==A||e.paths.hasOwnProperty("$comment")){if(!e)continue;if(!(j=e.path(A)))for(var R=A.split("."),N=R.length;N--;){var D=R.slice(0,N).join("."),U=R.slice(N).join("."),C=e.path(D),L=C&&C.schema&&C.schema.options&&C.schema.options.discriminatorKey;if(null!=C&&null!=(C.schema&&C.schema.discriminators)&&null!=L&&U!==L){var q=h(r,D+"."+L),F=C.schema.discriminators;"string"==typeof q&&null!=F[q]?j=F[q].path(U):null!=q&&1===Object.keys(q).length&&Array.isArray(q.$in)&&1===q.$in.length&&"string"==typeof q.$in[0]&&null!=F[q.$in[0]]&&(j=F[q.$in[0]].path(U))}}if(j){if(null==x)continue;if(v.isPOJO(x))if(Object.keys(x).some(d))for(var V=Object.keys(x),z=void 0,K=V.length;K--;)if($=x[z=V[K]],"$elemMatch"===z)$&&null!=j&&null!=j.schema?t(j.schema,$,i,S):$&&null!=j&&j.$isMongooseArray&&(v.isPOJO($)&&null!=$.$not?t(e,$,i,S):x[z]=j.castForQuery(z,$,S));else if("$not"===z){if($&&j){if((O=Object.keys($)).length&&d(O[0]))for(var H in $)$[H]=j.castForQuery(H,$[H],S);else x[z]=j.castForQuery(z,$,S);continue}}else x[z]=j.castForQuery(z,$,S);else r[A]=j.castForQuery(null,x,S);else if(Array.isArray(x)&&-1===["Buffer","Array"].indexOf(j.instance)){var W,J=[],G=n(x);try{for(G.s();!(W=G.n()).done;){var Y=W.value;J.push(j.castForQuery(null,Y,S))}}catch(t){G.e(t)}finally{G.f()}r[A]={$in:J}}else r[A]=j.castForQuery(null,x,S)}else{for(var Q=A.split("."),X=Q.length,Z=void 0,tt=void 0,et=void 0;X--&&(Z=Q.slice(0,X).join("."),!(j=e.path(Z))););if(j){if(j.caster&&j.caster.schema){(et={})[tt=Q.slice(X).join(".")]=x;var rt=t(j.caster.schema,et,i,S)[tt];void 0===rt?delete r[A]:r[A]=rt}else r[A]=x;continue}if(b(x)){var nt="";if(x.$near?nt="$near":x.$nearSphere?nt="$nearSphere":x.$within?nt="$within":x.$geoIntersects?nt="$geoIntersects":x.$geoWithin&&(nt="$geoWithin"),nt){var it=new c.Number("__QueryCasting__"),ot=x[nt];if(null!=x.$maxDistance&&(x.$maxDistance=it.castForQuery(null,x.$maxDistance,S)),null!=x.$minDistance&&(x.$minDistance=it.castForQuery(null,x.$minDistance,S)),"$within"===nt){var at=ot.$center||ot.$centerSphere||ot.$box||ot.$polygon;if(!at)throw new Error("Bad $within parameter: "+JSON.stringify(x));ot=at}else if("$near"===nt&&"string"==typeof ot.type&&Array.isArray(ot.coordinates))ot=ot.coordinates;else if(("$near"===nt||"$nearSphere"===nt||"$geoIntersects"===nt)&&ot.$geometry&&"string"==typeof ot.$geometry.type&&Array.isArray(ot.$geometry.coordinates))null!=ot.$maxDistance&&(ot.$maxDistance=it.castForQuery(null,ot.$maxDistance,S)),null!=ot.$minDistance&&(ot.$minDistance=it.castForQuery(null,ot.$minDistance,S)),m(ot.$geometry)&&(ot.$geometry=ot.$geometry.toObject({transform:!1,virtuals:!1})),ot=ot.$geometry.coordinates;else if("$geoWithin"===nt)if(ot.$geometry){m(ot.$geometry)&&(ot.$geometry=ot.$geometry.toObject({virtuals:!1}));var st=ot.$geometry.type;if(-1===g.indexOf(st))throw new Error('Invalid geoJSON type for $geoWithin "'+st+'", must be "Polygon" or "MultiPolygon"');ot=ot.$geometry.coordinates}else ot=ot.$box||ot.$polygon||ot.$center||ot.$centerSphere,m(ot)&&(ot=ot.toObject({virtuals:!1}));_(ot,it,S);continue}}if(e.nested[A])continue;var ct="strict"in i?i.strict:e.options.strict,ut=w(i,e._userProvidedOptions,e.options,S);if(i.upsert&&ct){if("throw"===ct)throw new s(A);throw new s(A,'Path "'+A+'" is not in schema, strict mode is `true`, and upsert is `true`.')}if("throw"===ut)throw new s(A,'Path "'+A+"\" is not in schema and strictQuery is 'throw'.");ut&&delete r[A]}}else x=f(x,A),r[A]=x}return r}},3087:(t,e,r)=>{"use strict";var n=r(9373),i=r(4029).Long;t.exports=function(t){return null==t?t:""===t?null:"bigint"==typeof t?t:t instanceof i?t.toBigInt():"string"==typeof t||"number"==typeof t?BigInt(t):void n.ok(!1)}},6670:(t,e,r)=>{"use strict";var n=r(1795);t.exports=function(e,r){if(t.exports.convertToTrue.has(e))return!0;if(t.exports.convertToFalse.has(e))return!1;if(null==e)return e;throw new n("boolean",e,r)},t.exports.convertToTrue=new Set([!0,"true",1,"1","yes"]),t.exports.convertToFalse=new Set([!1,"false",0,"0","no"])},195:(t,e,r)=>{"use strict";var n=r(9373);t.exports=function(t){return null==t||""===t?null:t instanceof Date?(n.ok(!isNaN(t.valueOf())),t):(n.ok("boolean"!=typeof t),e=t instanceof Number||"number"==typeof t?new Date(t):"string"==typeof t&&!isNaN(Number(t))&&(Number(t)>=275761||Number(t)<-271820)?new Date(Number(t)):"function"==typeof t.valueOf?new Date(t.valueOf()):new Date(t),isNaN(e.valueOf())?void n.ok(!1):e);var e}},6209:(t,e,r)=>{"use strict";var n=r(365).Buffer;function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}var o=r(5003),a=r(9373);t.exports=function(t){return null==t?t:"object"===i(t)&&"string"==typeof t.$numberDecimal?o.fromString(t.$numberDecimal):t instanceof o?t:"string"==typeof t?o.fromString(t):"function"==typeof n&&n.isBuffer(t)||"function"==typeof Uint8Array&&t instanceof Uint8Array?new o(t):"number"==typeof t?o.fromString(String(t)):"function"==typeof t.valueOf&&"string"==typeof t.valueOf()?o.fromString(t.valueOf()):void a.ok(!1)}},3065:(t,e,r)=>{"use strict";var n=r(9373);t.exports=function(t){return null==t?t:""===t?null:("string"!=typeof t&&"boolean"!=typeof t||(t=Number(t)),n.ok(!isNaN(t)),t instanceof Number?t.valueOf():"number"==typeof t?t:Array.isArray(t)||"function"!=typeof t.valueOf?t.toString&&!Array.isArray(t)&&t.toString()==Number(t)?Number(t):void n.ok(!1):Number(t.valueOf()))}},4731:(t,e,r)=>{"use strict";var n=r(1563),i=r(6079);t.exports=function(t){if(null==t)return t;if(n(t,"ObjectId"))return t;if(t._id){if(n(t._id,"ObjectId"))return t._id;if(t._id.toString instanceof Function)return new i(t._id.toString())}return t.toString instanceof Function?new i(t.toString()):new i(t)}},2417:(t,e,r)=>{"use strict";var n=r(1795);t.exports=function(t,e){if(null==t)return t;if(t._id&&"string"==typeof t._id)return t._id;if(t.toString&&t.toString!==Object.prototype.toString&&!Array.isArray(t))return t.toString();throw new n("string",t,e)}},8727:(t,e,r)=>{"use strict";function n(){n=function(){return e};var t,e={},r=Object.prototype,i=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r,n){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function f(e,r,n,i){var o=r&&r.prototype instanceof d?r:d,a=Object.create(o.prototype);return u(a,"_invoke",function(e,r,n){var i=1;return function(o,a){if(3===i)throw Error("Generator is already running");if(4===i){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=O(s,n);if(c){if(c===p)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===i)throw i=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=3;var u=h(e,r,n);if("normal"===u.type){if(i=n.done?4:2,u.arg===p)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=4,n.method="throw",n.arg=u.arg)}}}(e,n,new A(i||[])),!0),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p={};function d(){}function y(){}function b(){}var m={};u(m,a,(function(){return this}));var v=Object.getPrototypeOf,g=v&&v(v(E([])));g&&g!==r&&i.call(g,a)&&(m=g);var _=b.prototype=d.prototype=Object.create(m);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(n,o,a,s){var c=h(t[n],t,o);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==l(f)&&i.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var n;u(this,"_invoke",(function(t,i){function o(){return new e((function(e,n){r(t,i,e,n)}))}return n=n?n.then(o,o):o()}),!0)}function O(e,r){var n=r.method,i=e.i[n];if(i===t)return r.delegate=null,"throw"===n&&e.i.return&&(r.method="return",r.arg=t,O(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),p;var o=h(i,e.i,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,p;var a=o.arg;return a?a.done?(r[e.r]=a.value,r.next=e.n,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,p):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function j(t){this.tryEntries.push(t)}function $(e){var r=e[4]||{};r.type="normal",r.arg=t,e[4]=r}function A(t){this.tryEntries=[[-1]],t.forEach(j,this),this.reset(!0)}function E(e){if(null!=e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function r(){for(;++n<e.length;)if(i.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(l(e)+" is not iterable")}return y.prototype=b,u(_,"constructor",b),u(b,"constructor",y),y.displayName=u(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u(t,c,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},w(S.prototype),u(S.prototype,s,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new S(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(_),u(_,c,"Generator"),u(_,a,(function(){return this})),u(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},e.values=E,A.prototype={constructor:A,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach($),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(t){a.type="throw",a.arg=e,r.next=t}for(var i=r.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o[4],s=this.prev,c=o[1],u=o[2];if(-1===o[0])return n("end"),!1;if(!c&&!u)throw Error("try statement without catch or finally");if(null!=o[0]&&o[0]<=s){if(s<c)return this.method="next",this.arg=t,n(c),!0;if(s<u)return n(u),!1}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var i=n;break}}i&&("break"===t||"continue"===t)&&i[0]<=e&&e<=i[2]&&(i=null);var o=i?i[4]:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i[2],p):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[2]===t)return this.complete(r[4],r[3]),$(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r[0]===t){var n=r[4];if("throw"===n.type){var i=n.arg;$(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={i:E(e),r,n},"next"===this.method&&(this.arg=t),p}},e}function i(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function s(t){i(a,n,o,s,c,"next",t)}function c(t){i(a,n,o,s,c,"throw",t)}s(void 0)}))}}function a(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?a(Object(r),!0).forEach((function(e){c(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function c(t,e,r){return(e=function(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return f(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}var h,p,d,y=r(9620).EventEmitter,b=r(6379),m=r(4888),v=r(3861),g=r(4107),_=r(900),w=r(7962),S=r(5506),O=r(3328),j=r(122),$=r(2037),A=r(7427),E=r(2874),x=r(4134),P=r(1973),M=r(8724).M,k=r(8724).c,B=r(2829).x,T=r(9981),I=r(111),R=r(37),N=r(9728),D=r(719),U=r(1490),C=r(2183),L=r(9098),q=r(8751).inspect,F=r(4962).h,V=r(5837),z=r(3564),K=r(2888),H=r(6872),W=r(5543),J=H.deepEqual,G=H.isMongooseObject,Y=r(8770).arrayAtomicsBackupSymbol,Q=r(8770).arrayAtomicsSymbol,X=r(8770).documentArrayParent,Z=r(8770).documentIsModified,tt=r(8770).documentModifiedPaths,et=r(8770).documentSchemaSymbol,rt=r(8770).getSymbol,nt=r(8770).populateModelSymbol,it=r(8770).scopeSymbol,ot=r(8107).schemaMixedSymbol,at=r(251),st=r(9585),ct=r(8770).sessionNewDocuments,ut=H.specialProperties;function ft(t,e,r,n){if("object"===l(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n),null==this.$__schema){var i=H.isObject(e)&&!e.instanceOfSchema?new S(e):e;this.$__setSchema(i),e=r,r=n,n=arguments[4]||{}}if(this.$__=new b,null!=n.isNew&&!0!==n.isNew&&(this.$isNew=n.isNew),null!=n.priorDoc&&(this.$__.priorDoc=n.priorDoc),r&&(this.$__.skipId=r),null!=t&&"object"!==l(t))throw new _(t,"obj","Document");var o=!0;void 0!==n.defaults&&(this.$__.defaults=n.defaults,o=n.defaults);var a=this.$__schema;"boolean"==typeof e||"throw"===e?(!0!==e&&(this.$__.strictMode=e),e=void 0):!0!==a.options.strict&&(this.$__.strictMode=a.options.strict);var s,c=u(a.requiredPaths(!0));try{for(c.s();!(s=c.n()).done;){var f=s.value;this.$__.activePaths.require(f)}}catch(t){c.e(t)}finally{c.f()}var h=null;H.isPOJO(e)&&Object.keys(e).length>0&&(h=L(e),this.$__.selected=e,this.$__.exclude=h);var p=!1===h&&e?A(e):null;if(null==this._doc&&(this.$__buildDoc(t,e,r,h,p,!1),o&&E(this,e,h,p,!0,null)),t&&(this.$__original_set?this.$__original_set(t,void 0,!0,n):this.$set(t,void 0,!0,n),t instanceof ft&&(this.$isNew=t.$isNew)),n.willInit&&o?n.skipDefaults&&(this.$__.skipDefaults=n.skipDefaults):o&&E(this,e,h,p,!1,n.skipDefaults),!this.$__.strictMode&&t){var d=this;Object.keys(this._doc).forEach((function(t){t in a.tree||t in a.methods||t in a.virtuals||t.startsWith("$")||k({prop:t,subprops:null,prototype:d})}))}!function(t){var e=t.$__schema&&t.$__schema.callQueue;if(e.length){var r,n=u(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;"pre"!==i[0]&&"post"!==i[0]&&"on"!==i[0]&&t[i[0]].apply(t,i[1])}}catch(t){n.e(t)}finally{n.f()}}}(this)}for(var lt in ft.prototype.$isMongooseDocumentPrototype=!0,Object.defineProperty(ft.prototype,"isNew",{get:function(){return this.$isNew},set:function(t){this.$isNew=t}}),Object.defineProperty(ft.prototype,"errors",{get:function(){return this.$errors},set:function(t){this.$errors=t}}),ft.prototype.$isNew=!0,H.each(["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"],(function(t){ft.prototype[t]=function(){if(!this.$__.emitter){if("emit"===t)return;this.$__.emitter=new y,this.$__.emitter.setMaxListeners(0)}return this.$__.emitter[t].apply(this.$__.emitter,arguments)},ft.prototype["$".concat(t)]=ft.prototype[t]})),ft.prototype.constructor=ft,y.prototype)ft[lt]=y.prototype[lt];function ht(t,e,r){if(null!=t)for(var n=Object.keys(r.$__schema.paths),i=n.length,o=-1===e.indexOf(".")?[e]:e.split("."),a=0;a<i;++a){var s="",c=n[a];if(c.startsWith(e+".")){var u=r.$__schema.paths[c],f=u.splitPath().slice(o.length),l=f.length;if(void 0!==u.defaultValue)for(var h=t,p=0;p<l&&null!=h;++p){var d=f[p];if(p===l-1){if(void 0!==h[d])break;try{var y=u.getDefault(r,!1);void 0!==y&&(h[d]=y)}catch(t){r.invalidate(e+"."+s,t);break}break}s+=(s.length?".":"")+d,h[d]=h[d]||{},h=h[d]}}}}function pt(t,e,r,n,i){i=i||"",null!=e.$__&&(e=e._doc);for(var o,a,s,c=Object.keys(e),u=c.length,f=0,l=t.$__.strictMode,h=t.$__schema;f<u;)p(f++);function p(u){if("__proto__"!==(s=c[u])&&"constructor"!==s&&(a=i?i+s:s,o=h.path(a),!h.$isRootDiscriminator||t.$__isSelected(a))){var f=e[s];if(!o&&H.isPOJO(f))r[s]||(r[s]={},l||s in h.tree||s in h.methods||s in h.virtuals||(t[s]=r[s])),pt(t,f,r[s],n,a+".");else if(o){if(r.hasOwnProperty(s)&&void 0!==f&&delete r[s],null===f)r[s]=o._castNullish(null);else if(void 0!==f){var p=null==f.$__?null:f.$__.wasPopulated;if(o&&!p)try{n&&n.setters?r[s]=o.applySetters(f,t,!1):r[s]=o.cast(f,t,!0)}catch(e){t.invalidate(e.path,new $({path:e.path,message:e.message,type:"cast",value:e.value,reason:e}))}else r[s]=f}t.$isModified(a)||t.$__.activePaths.init(a)}else r[s]=f,l||i||(t[s]=f)}}}function dt(t){if(null==t)return!0;if("object"!==l(t)||Array.isArray(t))return!1;for(var e=0,r=Object.keys(t);e<r.length;e++)if(!dt(t[r[e]]))return!1;return!0}function yt(t,e,r){var n={};!function(t){var e=Object.keys(t.$__.activePaths.getStatePaths("require")),r=0,n=e.length;for(r=0;r<n;++r){var i=e[r],o=t.$__schema.path(i);if(null!=o&&"function"==typeof o.originalRequiredValue){t.$__.cachedRequired=t.$__.cachedRequired||{};try{t.$__.cachedRequired[i]=o.originalRequiredValue.call(t,t)}catch(e){t.invalidate(i,e)}}}}(t);var i=new Set(Object.keys(t.$__.activePaths.getStatePaths("require")).filter((function(e){return!(!t.$__isSelected(e)&&!t.$isModified(e))&&(null==t.$__.cachedRequired||!(e in t.$__.cachedRequired)||t.$__.cachedRequired[e])})));function o(t){i.add(t)}Object.keys(t.$__.activePaths.getStatePaths("init")).forEach(o),Object.keys(t.$__.activePaths.getStatePaths("modify")).forEach(o),Object.keys(t.$__.activePaths.getStatePaths("default")).forEach(o);var a,s=t.$getAllSubdocs(),c=t.modifiedPaths(),f=u(s);try{for(f.s();!(a=f.n()).done;){var l=a.value;if(l.$basePath){var h,p=l.$isSingleNested?l.$__pathRelativeToParent():l.$__fullPathWithIndexes(),d=u(l.modifiedPaths());try{for(d.s();!(h=d.n()).done;){var y=h.value;i.delete(p+"."+y)}}catch(t){d.e(t)}finally{d.f()}!t.$isModified(p,null,c)||t.isDirectModified(p)||t.$isDefault(p)||(i.add(p),null==t.$__.pathsToScopes&&(t.$__.pathsToScopes={}),t.$__.pathsToScopes[p]=l.$isDocumentArrayElement?l.__parentArray:l.$parent(),n[p]={skipSchemaValidators:!0},l.$isDocumentArrayElement&&null!=l.__index&&(n[p].index=l.__index))}}}catch(t){f.e(t)}finally{f.f()}var b,m=u(i);try{for(m.s();!(b=m.n()).done;){var v=b.value,g=t.$__schema.path(v);if(g){if(g.$isMongooseDocumentArray){var _,w=u(i);try{for(w.s();!(_=w.n()).done;){var S=_.value;(null==S||S.startsWith(g.path+"."))&&i.delete(S)}}catch(t){w.e(t)}finally{w.f()}}(g.caster||0!==g.validators.length||g.$parentSchemaDocArray)&&(!g.$isMongooseArray||g.$isMongooseDocumentArray||g.$embeddedSchemaType.$isMongooseArray||0!==g.validators.length||0!==g.$embeddedSchemaType.validators.length)||i.delete(v)}}}catch(t){m.e(t)}finally{m.f()}var O,j=u(i);try{for(j.s();!(O=j.n()).done;){var $=O.value;t.$__schema.singleNestedPaths.hasOwnProperty($)&&i.delete($)}}catch(t){j.e(t)}finally{j.f()}Array.isArray(e)?i=function(t,e){var r,n=new Set(e),i=new Map([]),o=u(e);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(-1!==a.indexOf("."))for(var s=a.split("."),c=s[0],f=1;f<s.length;++f)i.set(c,a),c=c+"."+s[f]}}catch(t){o.e(t)}finally{o.f()}var l,h=new Set,p=u(t);try{for(p.s();!(l=p.n()).done;){var d=l.value;n.has(d)?h.add(d):i.has(d)&&h.add(i.get(d))}}catch(t){p.e(t)}finally{p.f()}return h}(i,e):Array.isArray(r)&&(i=function(t,e){return e=new Set(e),t=Array.from(t).filter((function(t){return!e.has(t)})),new Set(t)}(i,r));var A,E=u(i);try{for(E.s();!(A=E.n()).done;){var x=A.value,P=t.$__schema.path(x);P&&P.$isMongooseArray&&(Array.isArray(P)||!P.$isMongooseDocumentArray||P&&P.schemaOptions&&P.schemaOptions.required)&&(!P.$isMongooseArray||P.$isMongooseDocumentArray||P.$embeddedSchemaType.$isMongooseArray||0!==P.$embeddedSchemaType.validators.length)&&M(t.$__getValue(x),i,x)}}catch(t){E.e(t)}finally{E.f()}function M(t,e,r){if(null!=t)for(var n=t.length,i=0;i<n;++i)Array.isArray(t[i])?M(t[i],e,r+"."+i):e.add(r+"."+i)}var k,T={skipArrays:!0},I=u(i);try{for(I.s();!(k=I.n()).done;){var R=k.value;if(t.$__schema.nested[R]){var N=t.$__getValue(R);G(N)&&(N=N.toObject({transform:!1}));var D=B(N,R,T,t.$__schema);Object.keys(D).forEach(o)}}}catch(t){I.e(t)}finally{I.f()}var U,C=u(i);try{for(C.s();!(U=C.n()).done;){var L=U.value,q=t.$__schema.path(L);if(q&&(q.$parentSchemaDocArray&&"string"==typeof q.$parentSchemaDocArray.path&&i.add(q.$parentSchemaDocArray.path),q.$isSchemaMap)){var F=t.$__getValue(L);if(null!=F){var V,z=u(F.keys());try{for(z.s();!(V=z.n()).done;){var K=V.value;i.add(L+"."+K)}}catch(t){z.e(t)}finally{z.f()}}}}}catch(t){C.e(t)}finally{C.f()}return[i=Array.from(i),n]}function bt(t){for(var e,r,n,i=Object.keys(t),o=i.length;o--;)n=t[r=i[o]],H.isPOJO(n)&&(t[r]=bt(n)),void 0!==t[r]?e=!0:delete t[r];return e?t:void 0}function mt(t,e,r,n){var i,o,a,s=t.$__schema,c=Object.keys(s.virtuals),u=c.length,f=u,l=t._doc,h="boolean"!=typeof(n&&n.aliases)||n.aliases;r=r||{};var p=null;if(Array.isArray(r.virtuals))p=new Set(r.virtuals);else if(r.virtuals&&r.virtuals.pathsToSkip){p=new Set(c);for(var d=0;d<r.virtuals.pathsToSkip.length;d++)p.has(r.virtuals.pathsToSkip[d])&&p.delete(r.virtuals.pathsToSkip[d])}if(!l)return e;for(u=0;u<f;++u)if(i=c[u],(null==p||p.has(i))&&(h||!s.aliases.hasOwnProperty(i))){if(o=i,null!=r.path){if(!i.startsWith(r.path+"."))continue;o=i.substring(r.path.length+1)}var y=o.split(".");if(void 0!==(a=P(t.get(i),r))){var b=y.length;l=e;for(var m=0;m<b-1;++m)l[y[m]]=l[y[m]]||{},l=l[y[m]];l[y[b-1]]=a}}return e}function vt(t,e){if(W(e))throw new Error("`transform` function must be synchronous, but the transform on path `"+t+"` returned a promise.")}ft.prototype.$__schema,ft.prototype.schema,Object.defineProperty(ft.prototype,"$locals",{configurable:!1,enumerable:!1,get:function(){return null==this.$__.locals&&(this.$__.locals={}),this.$__.locals},set:function(t){this.$__.locals=t}}),ft.prototype.isNew,Object.defineProperty(ft.prototype,"$where",{configurable:!1,enumerable:!1,writable:!0}),ft.prototype.id,ft.prototype.$errors,Object.defineProperty(ft.prototype,"$op",{get:function(){return this.$__.op||null},set:function(t){this.$__.op=t}}),ft.prototype.$__buildDoc=function(t,e,r,n,i){for(var o={},a=Object.keys(this.$__schema.paths).filter((function(t){return!t.includes("$*")})),s=a.length,c=0;c<s;++c){var u=a[c];if("_id"===u){if(r)continue;if(t&&"_id"in t)continue}for(var f=this.$__schema.paths[u].splitPath(),l=f.length,h=l-1,p="",d=o,y=!1,b=0;b<l;++b){var m=f[b];if(p.length?p+="."+m:p=m,!0===n){if(p in e)break}else if(!1===n&&e&&!y)if(p in e)y=!0;else if(!i[p])break;b<h&&(d=d[m]||(d[m]={}))}}this._doc=o},ft.prototype.toBSON=function(){return this.toObject(F)},ft.prototype.init=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.$__init(t,e),r&&r(null,this),this},ft.prototype.$init=function(){return this.constructor.prototype.init.apply(this,arguments)},ft.prototype.$__init=function(t,e){if(this.$isNew=!1,e=e||{},null!=t._id&&e.populated&&e.populated.length){var r,n=String(t._id),i=u(e.populated);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.isVirtual?this.$populated(o.path,H.getValue(o.path,t),o):this.$populated(o.path,o._docs[n],o),null!=o._childDocs){var a,s=u(o._childDocs);try{for(s.s();!(a=s.n()).done;){var c=a.value;null!=c&&null!=c.$__&&(c.$__.parent=this)}}catch(t){s.e(t)}finally{s.f()}o._childDocs=[]}}}catch(t){i.e(t)}finally{i.f()}}pt(this,t,this._doc,e),V(this,e.populated),this.$emit("init",this),this.constructor.emit("init",this);var f=!1===this.$__.exclude&&this.$__.selected?A(this.$__.selected):null;return E(this,this.$__.selected,this.$__.exclude,f,!1,this.$__.skipDefaults),this},ft.prototype.updateOne=function(t,e,r){var n=this.constructor.updateOne({_id:this._id},t,e),i=this;return n.pre((function(t){i.constructor._middleware.execPre("updateOne",i,[i],t)})),n.post((function(t){i.constructor._middleware.execPost("updateOne",i,[i],{},t)})),null!=this.$session()&&("session"in n.options||(n.options.session=this.$session())),null!=r?n.exec(r):n},ft.prototype.replaceOne=function(){var t=Array.prototype.slice.call(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},ft.prototype.$session=function(t){if(0===arguments.length)return null!=this.$__.session&&this.$__.session.hasEnded?(this.$__.session=null,null):this.$__.session;if(null!=t&&t.hasEnded)throw new m("Cannot set a document's session to a session that has ended. Make sure you haven't called `endSession()` on the session you are passing to `$session()`.");if(null!=t||null!=this.$__.session){if(this.$__.session=t,!this.$isSubdocument){var e,r=u(this.$getAllSubdocs());try{for(r.s();!(e=r.n()).done;)e.value.$session(t)}catch(t){r.e(t)}finally{r.f()}}return t}},ft.prototype.$timestamps=function(t){return 0===arguments.length?null!=this.$__.timestamps?this.$__.timestamps:this.$__schema?this.$__schema.options.timestamps:void 0:(t!==this.$timestamps()&&(this.$__.timestamps=t),this)},ft.prototype.overwrite=function(t){for(var e=0,r=Array.from(new Set(Object.keys(this._doc).concat(Object.keys(t))));e<r.length;e++){var n=r[e];"_id"!==n&&(this.$__schema.options.versionKey&&n===this.$__schema.options.versionKey||this.$__schema.options.discriminatorKey&&n===this.$__schema.options.discriminatorKey||this.$set(n,t[n]))}return this},ft.prototype.$set=function(t,e,r,n){var i=this;H.isPOJO(r)&&(n=r,r=void 0);var o,a,f,h,p=n&&n.merge,d=r&&!0!==r,y=!0===r,b=0,_=n&&"strict"in n,w=_?n.strict:this.$__.strictMode;if(d&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.$__schema.interpretAsType(t,r,this.$__schema.options)),null==t){var S=[e,t];t=S[0],e=S[1]}else if("string"!=typeof t){if(t instanceof ft&&(t=t.$__isNested?t.toObject():t.$__schema===this.$__schema?mt(t,s({},t._doc)):t._doc),null==t){var j=[e,t];t=j[0],e=j[1]}h=e?e+".":"";var $=(o=R(this.$__schema,t)).length,A=n&&n._skipMinimizeTopLevel||!1;if(0===$&&A)return delete n._skipMinimizeTopLevel,e&&this.$set(e,{}),this;n=Object.assign({},n,{_skipMinimizeTopLevel:!1});for(var E=0;E<$;++E){f=o[E];var P=h?h+f:f;a=this.$__schema.pathType(P);var M=t[f];if(!0!==r||h||null==M||"nested"!==a||null==this._doc[f]||delete this._doc[f],H.isNonBuiltinObject(M)&&"nested"===a)this.$set(P,M,y,Object.assign({},n,{_skipMarkModified:!0})),ht(this.$get(P),P,this);else if(w){if(y&&void 0===M&&void 0!==this.$get(P))continue;if("adhocOrUndefined"===a&&(a=I(this,P,{typeOnly:!0})),"real"===a||"virtual"===a)this.$set(P,M,y,n);else if("nested"===a&&M instanceof ft)this.$set(P,M.toObject({transform:!1}),y,n);else{if("throw"===w)throw"nested"===a?new g(f,M):new O(f);"nested"===a&&null==M&&this.$set(P,M,y,n)}}else void 0!==M&&this.$set(P,M,y,n)}for(var k={},B=Object.keys(this.$__schema.tree),T=0,U=B.length;T<U;++T)(f=B[T])&&this._doc.hasOwnProperty(f)&&(k[f]=void 0);return this._doc=Object.assign(k,this._doc),this}var C=this.$__schema.pathType(t),L=null;if("adhocOrUndefined"===C&&(L=-1===t.indexOf(".")?[t]:t.split("."),C=I(this,L,{typeOnly:!0})),"adhocOrUndefined"===C&&!_){null==L&&(L=-1===t.indexOf(".")?[t]:t.split("."));var q=N(this.$__schema,L);void 0!==q&&(w=q)}e=D(e);var V,K=null!=i.$__.priorDoc?i.$__.priorDoc.$__getValue(t):y?void 0:i.$__getValue(t);if("nested"===C&&e){if("object"===l(e)&&null!=e){if(null!=e.$__&&(e=e.toObject(F)),null==e)return this.invalidate(t,new m.CastError("Object",e,t)),this;var W=this.$isModified(t),J=null!=this.$__.savedState&&this.$__.savedState.hasOwnProperty(t);if(null!=this.$__.savedState&&!this.$isNew&&!this.$__.savedState.hasOwnProperty(t)){var G=this.$__getValue(t);this.$__.savedState[t]=G;for(var Y=0,Q=Object.keys(G||{});Y<Q.length;Y++){var X=Q[Y];this.$__.savedState[t+"."+X]=G[X]}}if(p)return this.$set(e,t,y,n);this.$__setValue(t,null),x(this,t);var Z=R(this.$__schema,e,t);this.$__setValue(t,{});var tt,et=u(Z);try{for(et.s();!(tt=et.n()).done;){var rt=tt.value;this.$set(t+"."+rt,e[rt],y,s(s({},n),{},{_skipMarkModified:!0}))}}catch(t){et.e(t)}finally{et.f()}return null==K||W&&!J||!H.deepEqual(J?this.$__.savedState[t]:K,e)?this.markModified(t):this.unmarkModified(t),this}return this.invalidate(t,new m.CastError("Object",e,t)),this}if(null==L&&(L=-1===t.indexOf(".")?[t]:t.split(".")),"string"==typeof this.$__schema.aliases[L[0]]&&(L[0]=this.$__schema.aliases[L[0]]),"adhocOrUndefined"===C&&w){var it;for(b=0;b<L.length;++b){var ot=L.slice(0,b+1).join(".");if(b+1<L.length&&"virtual"===this.$__schema.pathType(ot))return z.set(t,e,this),this;if(null!=(V=this.$__schema.path(ot))){if(V instanceof v){it=!0;break}if(V.$isSchemaMap&&V.$__schemaType instanceof v&&b<L.length-1){it=!0,V=V.$__schemaType;break}}}if(null==V&&(V=I(this,t)),!it&&!V){if("throw"===w)throw new O(t);return this}}else{if("virtual"===C)return(V=this.$__schema.virtualpath(t)).applySetters(e,this),this;V=this.$__path(t)}var at,ut=this._doc,lt="";for(b=0;b<L.length-1;++b)ut=ut[L[b]],lt+=(0!==lt.length?".":"")+L[b],ut||(this.$set(lt,{}),this.$__isSelected(lt)||this.unmarkModified(lt),ut=this.$__getValue(lt));if(L.length<=1)at=t;else{var pt=L.length;for(b=0;b<pt;++b){var dt=L.slice(0,b+1).join(".");if(null===this.$get(dt,null,{getters:!1})){at=dt;break}}at||(at=t)}if(!V)return this.$__set(at,t,n,y,L,V,e,K),"nested"===C&&null==e&&x(this,t),this;if((V.$isSingleNested||V.$isMongooseArray)&&function(t,e){if(t.$__.validationError){for(var r=0,n=Object.keys(t.$__.validationError.errors);r<n.length;r++){var i=n[r];i.startsWith(e+".")&&delete t.$__.validationError.errors[i]}0===Object.keys(t.$__.validationError.errors).length&&(t.$__.validationError=null)}}(this,t),null!=e&&p&&V.$isSingleNested){e instanceof ft&&(e=e.toObject({virtuals:!1,transform:!1}));for(var yt=0,bt=Object.keys(e);yt<bt.length;yt++){var vt=bt[yt];this.$set(t+"."+vt,e[vt],y,n)}return this}var gt=!0;try{var _t,wt=function(){if(null==V.options)return!1;if(!(e instanceof ft))return!1;var t=e.constructor,r=V.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=V.options.refPath;if(null==n)return!1;var i=e.get(n);return i===t.modelName||i===t.baseModelName}(),St=!1;if(wt&&e instanceof ft&&(!e.$__.wasPopulated||H.deepEqual(e.$__.wasPopulated.value,e._id))){var Ot=V&&V.$isSingleNested?V.cast(e,this):e._id;this.$populated(t,Ot,c({},nt,e.constructor)),e.$__.wasPopulated={value:Ot},St=!0}var jt=this.$__schema.options.typeKey;if(V.options&&Array.isArray(V.options[jt])&&V.options[jt].length&&V.options[jt][0].ref&&function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=u(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof ft))return!1;if(null==i.constructor.modelName)return!1;if(i.constructor.modelName!=e&&i.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,V.options[jt][0].ref)){_t=c({},nt,e[0].constructor),this.$populated(t,e.map((function(t){return t._id})),_t);var $t,At=u(e);try{for(At.s();!($t=At.n()).done;){var Et=$t.value;Et.$__.wasPopulated={value:Et._id}}}catch(t){At.e(t)}finally{At.f()}St=!0}if(!wt||!V.$isSingleNested||!e.$__){var xt=this;null!=this.$__schema.singleNestedPaths[t]&&L.length>1&&(xt=st(this,L,this.schema)),e=null!=n&&n.overwriteImmutable?V.applySetters(e,xt,!1,K,{overwriteImmutable:!0}):V.applySetters(e,xt,!1,K)}if(Array.isArray(e)&&!Array.isArray(V)&&V.$isMongooseDocumentArray&&0!==e.length&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var Pt=Object.keys(e[0].$__.populated),Mt=function(){var r=Bt[kt];i.$populated(t+"."+r,e.map((function(t){return t.$populated(r)})),e[0].$__.populated[r].options)},kt=0,Bt=Pt;kt<Bt.length;kt++)Mt();St=!0}if(!St&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var Tt=0;Tt<e.length;++Tt)e[Tt]instanceof ft&&e.set(Tt,e[Tt]._id,!0);delete this.$__.populated[t]}null!=e&&V.$isSingleNested&&function(t,e,r){var n=e.schema;if(null!=n)for(var i=0,o=Object.keys(n.paths);i<o.length;i++){var a=o[i],s=n.paths[a];if(null!=s.$immutableSetter){var c=null==r?void 0:r.$__getValue(a);s.$immutableSetter.call(t,c)}}}(e,V,K),this.$markValid(t)}catch(r){r instanceof m.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof m.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new m.CastError(V.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new m.CastError(V.instance,e,t,r)),gt=!1}if(gt){var It,Rt=null,Nt=null;if(!y){var Dt=this.$isSubdocument?this.ownerDocument():this;Rt=Dt.$__.savedState,Nt=this.$isSubdocument?this.$__.fullPath+"."+t:t,Dt.$__saveInitialState(Nt)}this.$__set(at,t,n,y,L,V,e,K);var Ut=!(null===(It=this.$__.session)||void 0===It||!It.transaction),Ct=this.$__.session&&this.$__.session[ct]&&this.$__.session[ct].has(this)&&this.$__.session[ct].get(this).modifiedPaths&&!this.$__.session[ct].get(this).modifiedPaths.has(Nt);null!=Rt&&Rt.hasOwnProperty(Nt)&&(!Ut||Ct)&&H.deepEqual(e,Rt[Nt])&&this.unmarkModified(t)}return V.$isSingleNested&&(this.isDirectModified(t)||null==e)&&x(this,t),this},ft.prototype.set=ft.prototype.$set,ft.prototype.$__shouldModify=function(t,e,r,n,i,o,a,s){return!(r&&r._skipMarkModified||!this.$isNew&&!(e in this.$__.activePaths.getStatePaths("modify"))&&(void 0!==a||this.$__isSelected(e))&&(void 0===a&&e in this.$__.activePaths.getStatePaths("default")||this.$populated(e)&&a instanceof ft&&J(a._id,s)||J(a,void 0!==s?s:H.getValue(e,this))&&(n||null==a||!(e in this.$__.activePaths.getStatePaths("default"))||!J(a,o.getDefault(this,n)))))},ft.prototype.$__set=function(t,e,n,i,o,a,s,c){d=d||r(1568),this.$__shouldModify(t,e,n,i,o,a,s,c)?(this.$__.primitiveAtomics&&this.$__.primitiveAtomics[e]&&(delete this.$__.primitiveAtomics[e],0===Object.keys(this.$__.primitiveAtomics).length&&delete this.$__.primitiveAtomics),this.markModified(t),p||(p=r(1362)),s&&H.isMongooseArray(s)&&(s._registerAtomic("$set",s),H.isMongooseDocumentArray(s)&&s.forEach((function(t){t&&t.__parentArray&&(t.__parentArray=s)})))):Array.isArray(s)&&Array.isArray(c)&&H.isMongooseArray(s)&&H.isMongooseArray(c)&&(s[Q]=c[Q],s[Y]=c[Y],H.isMongooseDocumentArray(s)&&s.forEach((function(t){null!=t&&(t.$isNew=!1)})));for(var u=this._doc,f=0,l=o.length,h="";f<l;f++){var y=f+1===l;if(h+=h?"."+o[f]:o[f],ut.has(o[f]))return;if(y)u instanceof Map?u.set(o[f],s):u.$isSingleNested?(o[f]in u||(u[o[f]]=s),u._doc[o[f]]=s):u[o[f]]=s;else{var b=u instanceof Map,m=b?u.get(o[f]):u[o[f]];H.isPOJO(m)||m&&m instanceof d||m&&!Array.isArray(m)&&m.$isSingleNested||m&&Array.isArray(m)?u=m:null==m?(m={},b?u.set(o[f],m):u[o[f]]=m,u=m):u=m}}},ft.prototype.$__getValue=function(t){return H.getValue(t,this._doc)},ft.prototype.$inc=function(t,e){var r=this;if(null==e&&(e=1),Array.isArray(t))return t.forEach((function(t){return r.$inc(t,e)})),this;var n=this.$__path(t);if(null==n){if("throw"===this.$__.strictMode)throw new O(t);if(!0===this.$__.strictMode)return this}else if("Number"!==n.instance)return this.invalidate(t,new m.CastError(n.instance,e,t)),this;var i=this.$__getValue(t)||0,o=!1,a=null,s=e;try{e=n.cast(e),s=(a=n.applySetters(i+e,this))-i,o=!0}catch(r){this.invalidate(t,new m.CastError("number",e,t,r))}return o&&(this.$__.primitiveAtomics=this.$__.primitiveAtomics||{},null==this.$__.primitiveAtomics[t]?this.$__.primitiveAtomics[t]={$inc:s}:this.$__.primitiveAtomics[t].$inc+=s,this.markModified(t),this.$__setValue(t,a)),this},ft.prototype.$__setValue=function(t,e){return H.setValue(t,e,this._doc),this},ft.prototype.get=function(t,e,r){var n;null==r&&(r={}),e&&(n=this.$__schema.interpretAsType(t,e,this.$__schema.options));var i=r.noDottedPath,o=i?this.$__schema.paths[t]:this.$__path(t);if(null==o&&null!=(o=this.$__schema.virtualpath(t)))return o.applyGetters(void 0,this);if(i){var a=this._doc[t];return n&&(a=n.cast(a)),null!=o&&!1!==r.getters?o.applyGetters(a,this):a}if(null!=o&&"Mixed"===o.instance){var s=this.$__schema.virtualpath(t);null!=s&&(o=s)}var c=-1!==t.indexOf("."),u=this._doc,f=c?t.split("."):[t];"string"==typeof this.$__schema.aliases[f[0]]&&(f[0]=this.$__schema.aliases[f[0]]);for(var l=0,h=f.length;l<h;l++)u&&u._doc&&(u=u._doc),u=null==u?void 0:u instanceof Map?u.get(f[l],{getters:!1}):l===h-1?H.getValue(f[l],u):u[f[l]];if(n&&(u=n.cast(u)),null!=o&&!1!==r.getters)u=o.applyGetters(u,this);else if(this.$__schema.nested[t]&&r.virtuals)return mt(this,P(u)||{},{path:t});return u},ft.prototype[rt]=ft.prototype.get,ft.prototype.$get=ft.prototype.get,ft.prototype.$__path=function(t){var e=this.$__.adhocPaths;return(e&&e.hasOwnProperty(t)?e[t]:null)||this.$__schema.path(t)},ft.prototype.markModified=function(t,e){this.$__saveInitialState(t),this.$__.activePaths.modify(t),null==e||this.$isSubdocument||(this.$__.pathsToScopes=this.$__pathsToScopes||{},this.$__.pathsToScopes[t]=e)},ft.prototype.$__saveInitialState=function(t){var e=this.$__.savedState,r=t;if(null!=e){var n=r.indexOf("."),i=-1===n?r:r.slice(0,n);e.hasOwnProperty(i)||(e[i]=P(this.$__getValue(i)))}},ft.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),null!=this.$__.pathsToScopes&&delete this.$__.pathsToScopes[t]},ft.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},ft.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.getStatePaths("modify"))},ft.prototype.$isEmpty=function(t){var e={minimize:!0,virtuals:!1,getters:!1,transform:!1};if(0!==arguments.length){var r=this.$get(t);return null==r||"object"===l(r)&&(H.isPOJO(r)?dt(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},ft.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.getStatePaths("modify")),r=new Set,n=0,i=0,o=e.length;for(n=0;n<o;++n){var a=e[n],s=at(a),c=s.length;for(i=0;i<c;++i)r.add(s[i]);if(t.includeChildren){var u=0,f=this.$get(a);if("object"===l(f)&&null!==f){f._doc&&(f=f._doc);var h=f.length;if(Array.isArray(f))for(u=0;u<h;++u){var p=a+"."+u;if(!r.has(p)&&(r.add(p),null!=f[u]&&f[u].$__)){var d=f[u].modifiedPaths(),y=0,b=d.length;for(y=0;y<b;++y)r.add(p+"."+d[y])}}else{var m=Object.keys(f),v=0,g=m.length;for(v=0;v<g;++v)r.add(a+"."+m[v])}}}}return Array.from(r)},ft.prototype[tt]=ft.prototype.modifiedPaths,ft.prototype.isModified=function(t,e,r){var n=this;if(t){var i=e&&e.ignoreAtomics,o=this.$__.activePaths.states.modify;if(null==o)return!1;"string"==typeof t&&(t=-1===t.indexOf(" ")?[t]:t.split(" "));var a,s=u(t);try{for(s.s();!(a=s.n()).done;)if(null!=o[a.value])return!0}catch(t){s.e(t)}finally{s.f()}var c=r||this[tt](),f=t.some((function(t){return!!~c.indexOf(t)})),l=Object.keys(o);return i&&(l=l.filter((function(t){var e=n.$__getValue(t);return null==e||null==e[Q]||void 0!==e[Q].$set}))),f||t.some((function(t){return l.some((function(e){return e===t||t.startsWith(e+".")}))}))}return this.$__.activePaths.some("modify")},ft.prototype.$isModified=ft.prototype.isModified,ft.prototype[Z]=ft.prototype.isModified,ft.prototype.$isDefault=function(t){var e=this;if(null==t)return this.$__.activePaths.some("default");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.getStatePaths("default").hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.getStatePaths("default").hasOwnProperty(t)}))},ft.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},ft.prototype.isDirectModified=function(t){var e=this;if(null==t)return this.$__.activePaths.some("modify");if("string"==typeof t&&-1===t.indexOf(" ")){var r=this.$__.activePaths.getStatePaths("modify").hasOwnProperty(t);if(r||-1===t.indexOf("."))return r;for(var n=t.split("."),i=0;i<n.length-1;++i){var o=n.slice(0,i+1).join("."),a=this.$get(o);if(null!=a&&null!=a.$__&&a.isDirectModified(n.slice(i+1).join(".")))return!0}return!1}var s=t;return"string"==typeof s&&(s=s.split(" ")),s.some((function(t){return e.isDirectModified(t)}))},ft.prototype.isInit=function(t){var e=this;if(null==t)return this.$__.activePaths.some("init");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.getStatePaths("init").hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.getStatePaths("init").hasOwnProperty(t)}))},ft.prototype.isSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if(!t)return!1;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.$__isSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var i=0,o=r;i<o.length;i++){var a=o[i];if("_id"!==a&&C(this.$__.selected[a])){n=!!this.$__.selected[a];break}}if(null===n)return!0;if(t in this.$__.selected)return n;for(var s=t+".",c=0,u=r;c<u.length;c++){var f=u[c];if("_id"!==f){if(f.startsWith(s))return n||f!==s;if(s.startsWith(f+"."))return n}}return!n},ft.prototype.$__isSelected=ft.prototype.isSelected,ft.prototype.isDirectSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.isDirectSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var i=0,o=r;i<o.length;i++){var a=o[i];if("_id"!==a&&C(this.$__.selected[a])){n=!!this.$__.selected[a];break}}return null===n||(this.$__.selected.hasOwnProperty(t)?n:!n)},ft.prototype.validate=function(){var t=o(n().mark((function t(e,r){var i,o,a=this,s=arguments;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("function"!=typeof e&&"function"!=typeof r&&"function"!=typeof s[2]){t.next=2;break}throw new m("Document.prototype.validate() no longer accepts a callback")