mongoose
Version:
Mongoose MongoDB ODM
2 lines • 851 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(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}r(9906).set(r(6333));var s=r(4304);s.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=s(),e.model=function(t,r){var n=function(t){!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&&o(t,e)}(c,t);var e,n,s,u=(n=c,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=a(n);if(s){var r=a(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return 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)}(this,t)});function c(t,e){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),u.call(this,t,r,e)}return e=c,Object.defineProperty(e,"prototype",{writable:!1}),e}(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),u=o.ValidationError,c=r(8859),f=r(5721);function l(t,e,r,i,u){if(!(this instanceof l))return new l(t,e,r,i,u);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,u),c(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=u,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=Object.prototype.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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new 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),u=r(5251),c=r(9739),f=r(6495),l=r(9981),h=r(2392),p=r(7906),d=r(8751),y=r(5721),b=r(6584),m=r(6872),v=["Polygon","MultiPolygon"];function g(t,e,r){if(Array.isArray(t))t.forEach((function(n,i){if(Array.isArray(n)||y(n))return g(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)||y(a)?(g(a,e,r),t[o]=a):t[o]=e.castForQuery({val:a,context:r})}}function _(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,w){if(Array.isArray(r))throw new Error("Query filter must be an object, got an array ",d.inspect(r));if(null==r)return r;null!=e&&null!=e.discriminators&&null!=r[e.options.discriminatorKey]&&(e=h(e,r[e.options.discriminatorKey])||e);var S,O,E,A,j,$,x=Object.keys(r),P=x.length;for(i=i||{};P--;)if($=r[A=x[P]],"$or"===A||"$nor"===A||"$and"===A){if(!Array.isArray($))throw new a("Array",$,A);for(var M=0;M<$.length;++M){if(null==$[M]||"object"!==o($[M]))throw new a("Object",$[M],A+"."+M);$[M]=t(e,$[M],i,w)}}else{if("$where"===A){if("string"!==(j=o($))&&"function"!==j)throw new Error("Must have a string or function for $where");"function"===j&&(r[A]=$.toString());continue}if("$expr"===A){$=c($,e);continue}if("$elemMatch"===A)$=t(e,$,i,w);else if("$text"===A)$=f($,A);else{if(!e)continue;if(!(O=e.path(A)))for(var k=A.split("."),R=k.length;R--;){var T=k.slice(0,R).join("."),I=k.slice(R).join("."),B=e.path(T),N=B&&B.schema&&B.schema.options&&B.schema.options.discriminatorKey;if(null!=B&&null!=(B.schema&&B.schema.discriminators)&&null!=N&&I!==N){var D=l(r,T+"."+N),L=B.schema.discriminators;"string"==typeof D&&null!=L[D]?O=L[D].path(I):null!=D&&1===Object.keys(D).length&&Array.isArray(D.$in)&&1===D.$in.length&&"string"==typeof D.$in[0]&&null!=L[D.$in[0]]&&(O=L[D.$in[0]].path(I))}}if(O){if(null==$)continue;if(m.isPOJO($))if(Object.keys($).some(p))for(var C=Object.keys($),U=void 0,q=C.length;q--;)if(E=$[U=C[q]],"$not"===U){if(E&&O){if((S=Object.keys(E)).length&&p(S[0]))for(var F in E)E[F]=O.castForQuery(F,E[F],w);else $[U]=O.castForQuery(U,E,w);continue}}else $[U]=O.castForQuery(U,E,w);else r[A]=O.castForQuery(null,$,w);else if(Array.isArray($)&&-1===["Buffer","Array"].indexOf(O.instance)){var V,z=[],H=n($);try{for(H.s();!(V=H.n()).done;){var W=V.value;z.push(O.castForQuery(null,W,w))}}catch(t){H.e(t)}finally{H.f()}r[A]={$in:z}}else r[A]=O.castForQuery(null,$,w)}else{for(var K=A.split("."),J=K.length,G=void 0,Y=void 0,Q=void 0;J--&&(G=K.slice(0,J).join("."),!(O=e.path(G))););if(O){if(O.caster&&O.caster.schema){(Q={})[Y=K.slice(J).join(".")]=$;var X=t(O.caster.schema,Q,i,w)[Y];void 0===X?delete r[A]:r[A]=X}else r[A]=$;continue}if(y($)){var Z="";if($.$near?Z="$near":$.$nearSphere?Z="$nearSphere":$.$within?Z="$within":$.$geoIntersects?Z="$geoIntersects":$.$geoWithin&&(Z="$geoWithin"),Z){var tt=new u.Number("__QueryCasting__"),et=$[Z];if(null!=$.$maxDistance&&($.$maxDistance=tt.castForQuery(null,$.$maxDistance,w)),null!=$.$minDistance&&($.$minDistance=tt.castForQuery(null,$.$minDistance,w)),"$within"===Z){var rt=et.$center||et.$centerSphere||et.$box||et.$polygon;if(!rt)throw new Error("Bad $within parameter: "+JSON.stringify($));et=rt}else if("$near"===Z&&"string"==typeof et.type&&Array.isArray(et.coordinates))et=et.coordinates;else if(("$near"===Z||"$nearSphere"===Z||"$geoIntersects"===Z)&&et.$geometry&&"string"==typeof et.$geometry.type&&Array.isArray(et.$geometry.coordinates))null!=et.$maxDistance&&(et.$maxDistance=tt.castForQuery(null,et.$maxDistance,w)),null!=et.$minDistance&&(et.$minDistance=tt.castForQuery(null,et.$minDistance,w)),b(et.$geometry)&&(et.$geometry=et.$geometry.toObject({transform:!1,virtuals:!1})),et=et.$geometry.coordinates;else if("$geoWithin"===Z)if(et.$geometry){b(et.$geometry)&&(et.$geometry=et.$geometry.toObject({virtuals:!1}));var nt=et.$geometry.type;if(-1===v.indexOf(nt))throw new Error('Invalid geoJSON type for $geoWithin "'+nt+'", must be "Polygon" or "MultiPolygon"');et=et.$geometry.coordinates}else et=et.$box||et.$polygon||et.$center||et.$centerSphere,b(et)&&(et=et.toObject({virtuals:!1}));g(et,tt,w);continue}}if(e.nested[A])continue;var it="strict"in i?i.strict:e.options.strict,ot=_(i,e._userProvidedOptions,e.options,w);if(i.upsert&&it){if("throw"===it)throw new s(A);throw new s(A,'Path "'+A+'" is not in schema, strict mode is `true`, and upsert is `true`.')}if("throw"===ot)throw new s(A,'Path "'+A+"\" is not in schema and strictQuery is 'throw'.");ot&&delete r[A]}}}return r}},3087:(t,e,r)=>{"use strict";var n=r(9373);t.exports=function(t){return null==t?t:""===t?null:"bigint"==typeof t?t:"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";var n,i;function o(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 a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach((function(e){f(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function s(){s=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new R(n||[]);return i(a,"_invoke",{value:x(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var d="suspendedStart",y="suspendedYield",b="executing",m="completed",v={};function g(){}function _(){}function w(){}var S={};f(S,a,(function(){return this}));var O=Object.getPrototypeOf,E=O&&O(O(T([])));E&&E!==r&&n.call(E,a)&&(S=E);var A=w.prototype=g.prototype=Object.create(S);function j(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function $(t,e){function r(i,o,a,s){var u=h(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==p(f)&&n.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){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function x(e,r,n){var i=d;return function(o,a){if(i===b)throw new Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=P(s,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=b;var c=h(e,r,n);if("normal"===c.type){if(i=n.done?m:y,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=m,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=h(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function M(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(M,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(p(e)+" is not iterable")}return _.prototype=w,i(A,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:_,configurable:!0}),_.displayName=f(w,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,c,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},j($.prototype),f($.prototype,u,(function(){return this})),e.AsyncIterator=$,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new $(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(A),f(A,c,"Generator"),f(A,a,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},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),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function u(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){u(o,n,i,a,s,"next",t)}function s(t){u(o,n,i,a,s,"throw",t)}a(void 0)}))}}function f(t,e,r){return(e=function(t){var e=function(t,e){if("object"!==p(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===p(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(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 h(t,e);var r=Object.prototype.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)?h(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 h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function p(t){return p="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},p(t)}var d,y,b,m=r(9620).EventEmitter,v=r(6379),g=r(4888),_=r(3861),w=r(4107),S=r(900),O=r(7962),E=r(5506),A=r(3328),j=r(122),$=r(2037),x=r(7427),P=r(2874),M=r(4134),k=r(1973),R=r(8724).M,T=r(8724).c,I=r(2829).x,B=r(9981),N=r(111),D=r(37),L=r(9728),C=r(719),U=r(1490),q=r(2183),F=r(9098),V=r(8751).inspect,z=r(4962).h,H=r(5837),W=r(3564),K=r(2888),J=r(6872),G=r(5543),Y=J.deepEqual,Q=J.isMongooseObject,X=r(8770).arrayAtomicsBackupSymbol,Z=r(8770).arrayAtomicsSymbol,tt=r(8770).documentArrayParent,et=r(8770).documentIsModified,rt=r(8770).documentModifiedPaths,nt=r(8770).documentSchemaSymbol,it=r(8770).getSymbol,ot=r(8770).populateModelSymbol,at=r(8770).scopeSymbol,st=r(8107).schemaMixedSymbol,ut=r(251),ct=r(9585),ft=J.specialProperties;function lt(t,e,r,n){if("object"===p(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n),null==this.$__schema){var i=J.isObject(e)&&!e.instanceOfSchema?new E(e):e;this.$__setSchema(i),e=r,r=n,n=arguments[4]||{}}if(this.$__=new v,null!=n.isNew&&!0!==n.isNew&&(this.$isNew=n.isNew),null!=n.priorDoc&&(this.$__.priorDoc=n.priorDoc),r&&(this.$__.skipId=r),null!=t&&"object"!==p(t))throw new S(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,u=l(a.requiredPaths(!0));try{for(u.s();!(s=u.n()).done;){var c=s.value;this.$__.activePaths.require(c)}}catch(t){u.e(t)}finally{u.f()}var f=null;J.isPOJO(e)&&Object.keys(e).length>0&&(f=F(e),this.$__.selected=e,this.$__.exclude=f);var h=!1===f&&e?x(e):null;if(null==this._doc&&(this.$__buildDoc(t,e,r,f,h,!1),o&&P(this,e,f,h,!0,null)),t&&(this.$__original_set?this.$__original_set(t,void 0,!0,n):this.$set(t,void 0,!0,n),t instanceof lt&&(this.$isNew=t.$isNew)),n.willInit&&o?n.skipDefaults&&(this.$__.skipDefaults=n.skipDefaults):o&&P(this,e,f,h,!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("$")||T({prop:t,subprops:null,prototype:d})}))}!function(t){var e=t.$__schema&&t.$__schema.callQueue;if(e.length){var r,n=l(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 ht in lt.prototype.$isMongooseDocumentPrototype=!0,Object.defineProperty(lt.prototype,"isNew",{get:function(){return this.$isNew},set:function(t){this.$isNew=t}}),Object.defineProperty(lt.prototype,"errors",{get:function(){return this.$errors},set:function(t){this.$errors=t}}),lt.prototype.$isNew=!0,J.each(["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"],(function(t){lt.prototype[t]=function(){if(!this.$__.emitter){if("emit"===t)return;this.$__.emitter=new m,this.$__.emitter.setMaxListeners(0)}return this.$__.emitter[t].apply(this.$__.emitter,arguments)},lt.prototype["$".concat(t)]=lt.prototype[t]})),lt.prototype.constructor=lt,m.prototype)lt[ht]=m.prototype[ht];function pt(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="",u=n[a];if(u.startsWith(e+".")){var c=r.$__schema.paths[u],f=c.splitPath().slice(o.length),l=f.length;if(void 0!==c.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=c.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 dt(t,e,r,n,i){i=i||"",null!=e.$__&&(e=e._doc);for(var o,a,s,u=Object.keys(e),c=u.length,f=0,l=t.$__.strictMode,h=t.$__schema;f<c;)p(f++);function p(c){if("__proto__"!==(s=u[c])&&"constructor"!==s&&(a=i+s,o=h.path(a),!h.$isRootDiscriminator||t.$__isSelected(a)))if(!o&&J.isPOJO(e[s]))r[s]||(r[s]={},l||s in h.tree||s in h.methods||s in h.virtuals||(t[s]=r[s])),dt(t,e[s],r[s],n,a+".");else if(o){if(r.hasOwnProperty(s)&&void 0!==e[s]&&delete r[s],null===e[s])r[s]=o._castNullish(null);else if(void 0!==e[s]){var f=null==e[s].$__?null:e[s].$__.wasPopulated;if(o&&!f)try{n&&n.setters?r[s]=o.applySetters(e[s],t,!1):r[s]=o.cast(e[s],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]=e[s]}t.$isModified(a)||t.$__.activePaths.init(a)}else r[s]=e[s],l||i||(t[s]=e[s])}}function yt(t){if(null==t)return!0;if("object"!==p(t)||Array.isArray(t))return!1;for(var e=0,r=Object.keys(t);e<r.length;e++)if(!yt(t[r[e]]))return!1;return!0}function bt(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(),u=t.modifiedPaths(),c=l(s);try{for(c.s();!(a=c.n()).done;){var f=a.value;if(f.$basePath){var h,p=f.$__fullPathWithIndexes(),d=l(f.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,u)||t.isDirectModified(p)||t.$isDefault(p)||(i.add(p),null==t.$__.pathsToScopes&&(t.$__.pathsToScopes={}),t.$__.pathsToScopes[p]=f.$isDocumentArrayElement?f.__parentArray:f.$parent(),n[p]={skipSchemaValidators:!0},f.$isDocumentArrayElement&&null!=f.__index&&(n[p].index=f.__index))}}}catch(t){c.e(t)}finally{c.f()}var b,m=l(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=l(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,E=l(i);try{for(E.s();!(O=E.n()).done;){var A=O.value;t.$__schema.singleNestedPaths.hasOwnProperty(A)&&i.delete(A)}}catch(t){E.e(t)}finally{E.f()}Array.isArray(e)?i=function(t,e){var r,n=new Set(e),i=new Map([]),o=l(e);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(-1!==a.indexOf("."))for(var s=a.split("."),u=s[0],c=1;c<s.length;++c)i.set(u,a),u=u+"."+s[c]}}catch(t){o.e(t)}finally{o.f()}var f,h=new Set,p=l(t);try{for(p.s();!(f=p.n()).done;){var d=f.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 j,$=l(i);try{for($.s();!(j=$.n()).done;){var x=j.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(t)}finally{$.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,R={skipArrays:!0},T=l(i);try{for(T.s();!(k=T.n()).done;){var B=k.value;if(t.$__schema.nested[B]){var N=t.$__getValue(B);Q(N)&&(N=N.toObject({transform:!1}));var D=I(N,B,R,t.$__schema);Object.keys(D).forEach(o)}}}catch(t){T.e(t)}finally{T.f()}var L,C=l(i);try{for(C.s();!(L=C.n()).done;){var U=L.value,q=t.$__schema.path(U);if(q&&(q.$parentSchemaDocArray&&"string"==typeof q.$parentSchemaDocArray.path&&i.add(q.$parentSchemaDocArray.path),q.$isSchemaMap)){var F=t.$__getValue(U);if(null!=F){var V,z=l(F.keys());try{for(z.s();!(V=z.n()).done;){var H=V.value;i.add(U+"."+H)}}catch(t){z.e(t)}finally{z.f()}}}}}catch(t){C.e(t)}finally{C.f()}return[i=Array.from(i),n]}function mt(t){for(var e,r,n,i=Object.keys(t),o=i.length;o--;)n=t[r=i[o]],J.isPOJO(n)&&(t[r]=mt(n)),void 0!==t[r]?e=!0:delete t[r];return e?t:void 0}function vt(t,e,r,n){var i,o,a,s=t.$__schema,u=Object.keys(s.virtuals),c=u.length,f=c,l=t._doc,h="boolean"!=typeof(n&&n.aliases)||n.aliases,p=null;if(Array.isArray(r.virtuals))p=new Set(r.virtuals);else if(r.virtuals&&r.virtuals.pathsToSkip){p=new Set(u);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(r=r||{},c=0;c<f;++c)if(i=u[c],(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=k(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 gt(t,e){if(G(e))throw new Error("`transform` function must be synchronous, but the transform on path `"+t+"` returned a promise.")}lt.prototype.$__schema,lt.prototype.schema,Object.defineProperty(lt.prototype,"$locals",{configurable:!1,enumerable:!1,get:function(){return null==this.$__.locals&&(this.$__.locals={}),this.$__.locals},set:function(t){this.$__.locals=t}}),lt.prototype.isNew,Object.defineProperty(lt.prototype,"$where",{configurable:!1,enumerable:!1,writable:!0}),lt.prototype.id,lt.prototype.$errors,Object.defineProperty(lt.prototype,"$op",{get:function(){return this.$__.op||null},set:function(t){this.$__.op=t}}),lt.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,u=0;u<s;++u){var c=a[u];if("_id"===c){if(r)continue;if(t&&"_id"in t)continue}for(var f=this.$__schema.paths[c].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},lt.prototype.toBSON=function(){return this.toObject(z)},lt.prototype.init=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.$__init(t,e),r&&r(null,this),this},lt.prototype.$init=function(){return this.constructor.prototype.init.apply(this,arguments)},lt.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=l(e.populated);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.isVirtual?this.$populated(o.path,J.getValue(o.path,t),o):this.$populated(o.path,o._docs[n],o),null!=o._childDocs){var a,s=l(o._childDocs);try{for(s.s();!(a=s.n()).done;){var u=a.value;null!=u&&null!=u.$__&&(u.$__.parent=this)}}catch(t){s.e(t)}finally{s.f()}o._childDocs=[]}}}catch(t){i.e(t)}finally{i.f()}}dt(this,t,this._doc,e),H(this,e.populated),this.$emit("init",this),this.constructor.emit("init",this);var c=!1===this.$__.exclude&&this.$__.selected?x(this.$__.selected):null;return P(this,this.$__.selected,this.$__.exclude,c,!1,this.$__.skipDefaults),this},lt.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},lt.prototype.replaceOne=function(){var t=Array.prototype.slice.call(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},lt.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 g("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=l(this.$getAllSubdocs());try{for(r.s();!(e=r.n()).done;)e.value.$session(t)}catch(t){r.e(t)}finally{r.f()}}return t}},lt.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)},lt.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},lt.prototype.$set=function(t,e,r,n){var i=this;J.isPOJO(r)&&(n=r,r=void 0);var o,a,s,u,c=n&&n.merge,h=r&&!0!==r,d=!0===r,y=0,b=n&&"strict"in n,m=b?n.strict:this.$__.strictMode;if(h&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.$__schema.interpretAsType(t,r,this.$__schema.options)),null==t){var v=[e,t];t=v[0],e=v[1]}else if("string"!=typeof t){if(t instanceof lt&&(t=t.$__isNested?t.toObject():t._doc),null==t){var S=[e,t];t=S[0],e=S[1]}"_id"in t&&"id"in t&&delete t.id,u=e?e+".":"";var O=(o=D(this.$__schema,t)).length,E=n&&n._skipMinimizeTopLevel||!1;if(0===O&&E)return delete n._skipMinimizeTopLevel,e&&this.$set(e,{}),this;n=Object.assign({},n,{_skipMinimizeTopLevel:!1});for(var j=0;j<O;++j){s=o[j];var $=u?u+s:s;a=this.$__schema.pathType($);var x=t[s];if(!0!==r||u||null==x||"nested"!==a||null==this._doc[s]||delete this._doc[s],J.isNonBuiltinObject(x)&&"nested"===a)this.$set($,x,d,Object.assign({},n,{_skipMarkModified:!0})),pt(this.$get($),$,this);else if(m){if(d&&void 0===x&&void 0!==this.$get($))continue;if("adhocOrUndefined"===a&&(a=N(this,$,{typeOnly:!0})),"real"===a||"virtual"===a)this.$set($,x,d,n);else if("nested"===a&&x instanceof lt)this.$set($,x.toObject({transform:!1}),d,n);else if("throw"===m)throw"nested"===a?new w(s,x):new A(s)}else void 0!==x&&this.$set($,x,d,n)}for(var P={},k=Object.keys(this.$__schema.tree),R=0,T=k.length;R<T;++R)(s=k[R])&&this._doc.hasOwnProperty(s)&&(P[s]=void 0);return this._doc=Object.assign(P,this._doc),this}var I=this.$__schema.pathType(t),B=null;if("adhocOrUndefined"===I&&(B=-1===t.indexOf(".")?[t]:t.split("."),I=N(this,B,{typeOnly:!0})),"adhocOrUndefined"===I&&!b){null==B&&(B=-1===t.indexOf(".")?[t]:t.split("."));var U=L(this.$__schema,B);void 0!==U&&(m=U)}e=C(e);var q,F=null!=i.$__.priorDoc?i.$__.priorDoc.$__getValue(t):d?void 0:i.$__getValue(t);if("nested"===I&&e){if("object"===p(e)&&null!=e){if(null!=e.$__&&(e=e.toObject(z)),null==e)return this.invalidate(t,new g.CastError("Object",e,t)),this;var V=null!=this.$__.savedState&&this.$__.savedState.hasOwnProperty(t);if(null!=this.$__.savedState&&!this.$isNew&&!this.$__.savedState.hasOwnProperty(t)){var H=this.$__getValue(t);this.$__.savedState[t]=H;for(var K=0,G=Object.keys(H||{});K<G.length;K++){var Y=G[K];this.$__.savedState[t+"."+Y]=H[Y]}}if(c)return this.$set(e,t,d);this.$__setValue(t,null),M(this,t);var Q=D(this.$__schema,e,t);this.$__setValue(t,{});var X,Z=l(Q);try{for(Z.s();!(X=Z.n()).done;){var tt=X.value;this.$set(t+"."+tt,e[tt],d,n)}}catch(t){Z.e(t)}finally{Z.f()}return null!=F&&J.deepEqual(V?this.$__.savedState[t]:F,e)?this.unmarkModified(t):this.markModified(t),this}return this.invalidate(t,new g.CastError("Object",e,t)),this}if(null==B&&(B=-1===t.indexOf(".")?[t]:t.split(".")),"string"==typeof this.$__schema.aliases[B[0]]&&(B[0]=this.$__schema.aliases[B[0]]),"adhocOrUndefined"===I&&m){var et;for(y=0;y<B.length;++y){var rt=B.slice(0,y+1).join(".");if(y+1<B.length&&"virtual"===this.$__schema.pathType(rt))return W.set(t,e,this),this;if(null!=(q=this.$__schema.path(rt))){if(q instanceof _){et=!0;break}if(q.$isSchemaMap&&q.$__schemaType instanceof _&&y<B.length-1){et=!0,q=q.$__schemaType;break}}}if(null==q&&(q=N(this,t)),!et&&!q){if("throw"===m)throw new A(t);return this}}else{if("virtual"===I)return(q=this.$__schema.virtualpath(t)).applySetters(e,this),this;q=this.$__path(t)}var nt,it=this._doc,at="";for(y=0;y<B.length-1;++y)it=it[B[y]],at+=(0!==at.length?".":"")+B[y],it||(this.$set(at,{}),this.$__isSelected(at)||this.unmarkModified(at),it=this.$__getValue(at));if(B.length<=1)nt=t;else{var st=B.length;for(y=0;y<st;++y){var ut=B.slice(0,y+1).join(".");if(null===this.$get(ut,null,{getters:!1})){nt=ut;break}}nt||(nt=t)}if(!q)return this.$__set(nt,t,n,d,B,q,e,F),"nested"===I&&null==e&&M(this,t),this;if((q.$isSingleNested||q.$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&&c&&q.$isSingleNested){e instanceof lt&&(e=e.toObject({virtuals:!1,transform:!1}));for(var ft=0,ht=Object.keys(e);ft<ht.length;ft++){var dt=ht[ft];this.$set(t+"."+dt,e[dt],d,n)}return this}var yt=!0;try{var bt,mt=function(){if(null==q.options)return!1;if(!(e instanceof lt))return!1;var t=e.constructor,r=q.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=q.options.refPath;if(null==n)return!1;var i=e.get(n);return i===t.modelName||i===t.baseModelName}(),vt=!1;if(mt&&e instanceof lt&&(!e.$__.wasPopulated||J.deepEqual(e.$__.wasPopulated.value,e._id))){var gt=q&&q.$isSingleNested?q.cast(e,this):e._id;this.$populated(t,gt,f({},ot,e.constructor)),e.$__.wasPopulated={value:gt},vt=!0}var _t=this.$__schema.options.typeKey;if(q.options&&Array.isArray(q.options[_t])&&q.options[_t].length&&q.options[_t][0].ref&&function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=l(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof lt))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,q.options[_t][0].ref)){bt=f({},ot,e[0].constructor),this.$populated(t,e.map((function(t){return t._id})),bt);var wt,St=l(e);try{for(St.s();!(wt=St.n()).done;){var Ot=wt.value;Ot.$__.wasPopulated={value:Ot._id}}}catch(t){St.e(t)}finally{St.f()}vt=!0}if(!mt||!q.$isSingleNested||!e.$__){var Et=this;null!=this.$__schema.singleNestedPaths[t]&&B.length>1&&(Et=ct(this,B,this.schema)),e=null!=n&&n.overwriteImmutable?q.applySetters(e,Et,!1,F,{overwriteImmutable:!0}):q.applySetters(e,Et,!1,F)}if(Array.isArray(e)&&!Array.isArray(q)&&q.$isMongooseDocumentArray&&0!==e.length&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var At=Object.keys(e[0].$__.populated),jt=function(){var r=xt[$t];i.$populated(t+"."+r,e.map((function(t){return t.$populated(r)})),e[0].$__.populated[r].options)},$t=0,xt=At;$t<xt.length;$t++)jt();vt=!0}if(!vt&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var Pt=0;Pt<e.length;++Pt)e[Pt]instanceof lt&&e.set(Pt,e[Pt]._id,!0);delete this.$__.populated[t]}null!=e&&q.$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 u=null==r?void 0:r.$__getValue(a);s.$immutableSetter.call(t,u)}}}(e,q,F),this.$markValid(t)}catch(r){r instanceof g.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof g.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new g.CastError(q.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new g.CastError(q.instance,e,t,r)),yt=!1}if(yt){var Mt=null,kt=null;if(!d){var Rt=this.$isSubdocument?this.ownerDocument():this;Mt=Rt.$__.savedState,kt=this.$isSubdocument?this.$__.fullPath+"."+t:t,Rt.$__saveInitialState(kt)}this.$__set(nt,t,n,d,B,q,e,F),null!=Mt&&Mt.hasOwnProperty(kt)&&J.deepEqual(e,Mt[kt])&&this.unmarkModified(t)}return q.$isSingleNested&&(this.isDirectModified(t)||null==e)&&M(this,t),this},lt.prototype.set=lt.prototype.$set,lt.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 lt&&Y(a._id,s)||Y(a,void 0!==s?s:J.getValue(e,this))&&(n||null==a||!(e in this.$__.activePaths.getStatePaths("default"))||!Y(a,o.getDefault(this,n)))))},lt.prototype.$__set=function(t,e,n,i,o,a,s,u){b=b||r(1568),this.$__shouldModify(t,e,n,i,o,a,s,u)?(this.$__.primitiveAtomics&&this.$__.primitiveAtomics[e]&&(delete this.$__.primitiveAtomics[e],0===Object.keys(this.$__.primitiveAtomics).length&&delete this.$__.primitiveAtomics),this.markModified(t),y||(y=r(8268)),s&&J.isMongooseArray(s)&&(s._registerAtomic("$set",s),J.isMongooseDocumentArray(s)&&s.forEach((function(t){t&&t.__parentArray&&(t.__parentArray=s)})))):Array.isArray(s)&&Array.isArray(u)&&J.isMongooseArray(s)&&J.isMongooseArray(u)&&(s[Z]=u[Z],s[X]=u[X],J.isMongooseDocumentArray(s)&&s.forEach((function(t){t.isNew=!1})));for(var c=this._doc,f=0,l=o.length,h="";f<l;f++){var p=f+1===l;if(h+=h?"."+o[f]:o[f],ft.has(o[f]))return;if(p)c instanceof Map?c.set(o[f],s):c[o[f]]=s;else{var d=c instanceof Map,m=d?c.get(o[f]):c[o[f]];J.isPOJO(m)||m&&m instanceof b?c=m:m&&!Array.isArray(m)&&m.$isSingleNested?c=m._doc:m&&Array.isArray(m)?c=m:null==m?(m={},d?c.set(o[f],m):c[o[f]]=m,c=m):c=m}}},lt.prototype.$__getValue=function(t){return J.getValue(t,this._doc)},lt.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 A(t);if(!0===this.$__.strictMode)return this}else if("Number"!==n.instance)return this.invalidate(t,new g.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 g.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},lt.prototype.$__setValue=function(t,e){return J.setValue(t,e,this._doc),this},lt.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 u=-1!==t.indexOf("."),c=this._doc,f=u?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++)c&&c._doc&&(c=c._doc),c=null==c?void 0:c instanceof Map?c.get(f[l],{getters:!1}):l===h-1?J.getValue(f[l],c):c[f[l]];if(n&&(c=n.cast(c)),null!=o&&!1!==r.getters)c=o.applyGetters(c,this);else if(this.$__schema.nested[t]&&r.virtuals)return vt(this,k(c)||{},{path:t});return c},lt.prototype[it]=lt.prototype.get,lt.prototype.$get=lt.prototype.get,lt.prototype.$__path=function(t){var e=this.$__.adhocPaths;return(e&&e.hasOwnProperty(t)?e[t]:null)||this.$__schema.path(t)},lt.prototype.markModified=function(t,e){this.$__saveInitialState(t),this.$__.activePaths.modify(t),null==e||this.$isSubdocument||(this.$__.pathsToScopes=this.$__pathsToScopes||{},this.$__.pathsToScopes[t]=e)},lt.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]=k(this.$__getValue(i)))}},lt.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),null!=this.$__.pathsToScopes&&delete this.$__.pathsToScopes[t]},lt.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},lt.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.getStatePaths("modify"))},lt.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"===p(r)&&(J.isPOJO(r)?yt(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},lt.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=ut(a),u=s.length;for(i=0;i<u;++i)r.add(s[i]);if(t.includeChildren){var c=0,f=this.$get(a);if("object"===p(f)&&null!==f){f._doc&&(f=f._doc);var l=f.length;if(Array.isArray(f))for(c=0;c<l;++c){var h=a+"."+c;if(!r.has(h)&&(r.add(h),null!=f[c]&&f[c].$__)){var d=f[c].modifiedPaths(),y=0,b=d.length;for(y=0;y<b;++y)r.add(h+"."+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)},lt.prototype[rt]=lt.prototype.modifiedPaths,lt.prototype.isModified=function(t,e){if(t){var r=this.$__.activePaths.states.modify;if(null==r)return!1;"string"==typeof t&&(t=-1===t.indexOf(" ")?[t]:t.split(" "));var n,i=l(t);try{for(i.s();!(n=i.n()).done;)if(null!=r[n.value])return!0}catch(t){i.e(t)}finally{i.f()}var o=e||this[rt](),a=t.some((function(t){return!!~o.indexOf(t)})),s=Object.keys(r);return a||t.some((function(t){return s.some((function(e){return e===t||t.startsWith(e+".")}))}))}return this.$__.activePaths.some("modify")},lt.prototype.$isModified=lt.prototype.isModified,lt.prototype[et]=lt.prototype.isModified,lt.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)}))},lt.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},lt.prototype.isDirectModified=function(t){var e=this;if(null==t)return this.$__.activePaths.some("modify");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.getStatePaths("modify").hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.getStatePaths("modify").hasOwnProperty(t)}))},lt.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)}))},lt.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&&q(this.$__.selected[a])){n=!!this.$__.selected[a];break}}if(null===n)return!0;if(t in this.$__.selected)return n;for(var s=t+".",u=0,c=r;u<c.length;u++){var f=c[u];if("_id"!==f){if(f.startsWith(s))return n||f!==s;if(s.startsWith(f+"."))return n}}return!n},lt.prototype.$__isSelected=lt.prototype.isSelected,lt.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&&q(this.$__.selected[a])){n=!!this.$__.selected[a];break}}return null===n||(this.$__.selected.hasOwnProperty(t)?n:!n)},lt.prototype.validate=function(t,e){return(n=n||c(s().mark((function t(e,r){var n,i,o=this,a=arguments;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("function"!=typeof e&&"function"!=typeof r&&"function"!=typeof a[2]){t.next=2;break}throw new g("Document.prototype.validate() no longer accepts a callback");case 2:if(this.$op="validate",null!=this.$isSubdocument||(this.$__.validating?n=new O(this,{parentStack:r&&r.parentStack,conflictStack:this.$__.validating.stack}):this.$__.validating=new O(this,{parentStack:r&&r.parentStack})),1===a.length&&("object"!==p(a[0])||Array.isArray(a[0])||(r=a[0],e=null)),r&&"string"==typeof r.pathsToSkip&&(i=-1===r.pathsToSkip.indexOf(" "),r.pathsT