PageSourceSearch

https://app.leadsbridge.com/static/js/vendors-mirage-esm-5d4afc1bb1e85402b5a4.js

js leadsbridge.com collected 2026-09-24 07:16:29 UTC 78,339 bytes, 2 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="968105a7-a1cd-48b1-bd9e-5f197695667c",e._sentryDebugIdIdentifier="sentry-dbid-968105a7-a1cd-48b1-bd9e-5f197695667c")}catch(e){}}();var _global="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};_global.SENTRY_RELEASE={id:"45d996ec00b3dbb0b82e39a0d08246fd329cbef0"},(self.webpackChunkleadsbridge=self.webpackChunkleadsbridge||[]).push([[139],{18655:(e,t,i)=>{i.d(t,{HM:()=>fe,n0:()=>ft});var n=i(52011),r=i.n(n),o=i(96491),s=i.n(o),a=i(6553),c=i.n(a),u=i(88975),l=i.n(u),h=i(2183),d=i.n(h),f=(i(71453),i(49770)),y=(i(90564),i(30174)),m=i(61446),p=i.n(m),v=i(32722),g=i.n(v),_=i(14676),k=i.n(_),b=i(38805),F=i.n(b),A=i(28717),w=i.n(A),N=i(78995),I=i.n(N),R=i(82207),M=i.n(R),C=i(82927),O=i.n(C),z=i(15828),P=i.n(z),S=i(44174),T=i.n(S),j=i(94446),E=i.n(j),q=i(28213),x=i.n(q),K=i(12008),D=i.n(K),Y=i(79373),H=i.n(Y),B=i(24671),L=i.n(B),G=i(8063),W=i.n(G);function J(e){return J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},J(e)}function Q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U(e,t){for(var i=0;t.length>i;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function $(e,t,i){return t&&U(e.prototype,t),i&&U(e,i),e}function Z(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function V(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ee(e,t)}function X(e){return X=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},X(e)}function ee(e,t){return ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ee(e,t)}function te(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function ie(e,t,i){return ie=te()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return i&&ee(r,i.prototype),r},ie.apply(null,arguments)}function ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?ne(e):t}function oe(e){var t=te();return function(){var i,n=X(e);if(t){var r=X(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return re(this,i)}}function se(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var i=[],n=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(i.push(s.value),!t||i.length!==t);n=!0);}catch(e){r=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return i}(e,t)||ce(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ae(e){return function(e){if(Array.isArray(e))return ue(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||ce(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ce(e,t){if(e){if("string"==typeof e)return ue(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?ue(e,t):void 0}}function ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);t>i;i++)n[i]=e[i];return n}var le=function e(){this.build=function(t){var i=this,n={},o=Object.assign({},this.attrs);
1delete o.afterCreate,Object.keys(o).forEach((function(t){e.isTrait.call(i,t)&&delete o[t]}));var a=function(e,t){var i,n=new function(){},r=[];return Object.keys(e).forEach((function(e){var t;Object.defineProperty(n.constructor.prototype,e,{get:function(){return r.push([i,e]),t},set:function(e){t=e},enumerable:!1,configurable:!0})})),Object.keys(e).forEach((function(t){var i=e[t];"function"!=typeof i&&(n[t]=i)})),Object.keys(e).forEach((function(o){var s=e[o];i=o,"function"==typeof s&&(n[o]=s.call(n,t)),r.push([o])})),function(e){for(var t=l()(d()(e)),i=t.length,n=new Array(i),r={},o=i,s=function o(s,a,c){if(c.indexOf(s)>=0)throw new Error("Cyclic dependency in properties ".concat(JSON.stringify(c)));if(!r[a]){r[a]=!0;var u=e.filter((function(e){return e&&e[0]===s}));if(a=u.length){var l=c.concat(s);do{var h=u[--a][1];h&&o(h,t.indexOf(h),l)}while(a)}n[--i]=s}};o--;)r[o]||s(t[o],o,[]);return n.reverse()}(r)}(o,t);return a.forEach((function(e){var i,a;i=function(e){return c()(e,a)},a=function(e){return Array.isArray(e)?e.map(a):r()(e)?i(e):s()(e)?e.call(o,t):e};var u=o[e];n[e]=s()(u)?u.call(n,t):a(u)})),n}};le.extend=function(e){var t=Object.assign({},this.attrs,e),i=function(){this.attrs=t,le.call(this)};return i.extend=le.extend,i.extractAfterCreateCallbacks=le.extractAfterCreateCallbacks,i.isTrait=le.isTrait,i.attrs=t,i},le.extractAfterCreateCallbacks=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.traits,n=[],r=this.attrs||{};return r.afterCreate&&n.push(r.afterCreate),(Array.isArray(i)?i:Object.keys(r)).filter((function(t){return e.isTrait(t)&&r[t].extension.afterCreate})).forEach((function(e){n.push(r[e].extension.afterCreate)})),n},le.isTrait=function(e){var t=this.attrs;return r()(t[e])&&!0===t[e].__isTrait__};var he=function(){function e(){Q(this,e),this._nextId=1,this._ids={}}return $(e,[{key:"get",value:function(){return this._nextId}},{key:"set",value:function(e){if(this._ids[e])throw new Error("Attempting to use the ID ".concat(e,", but it's already been used"));var t;(+(t=e)).toString()!==t.toString()||this._nextId>+e||(this._nextId=+e+1),this._ids[e]=!0}},{key:"inc",value:function(){var e=this.get()+1;return this._nextId=e,e}},{key:"fetch",value:function(){var e=this.get();return this._ids[e]=!0,this.inc(),e.toString()}},{key:"reset",value:function(){this._nextId=1,this._ids={}}}]),e}(),de=console.warn,fe=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;Q(this,e),this.code=t,this.headers=i,204===t?void 0!==n&&""!==n?de("Mirage: One of your route handlers is returning a custom\n          204 Response that has data, but this is a violation of the HTTP spec\n          and could lead to unexpected behavior. 204 responses should have no\n          content (an empty string) as their body."):this.data="":this.data=void 0!==n&&""!==n||Object.prototype.hasOwnProperty.call(this.headers,"Content-Type")?n:{},204===t||Object.prototype.hasOwnProperty.call(this.headers,"Content-Type")||(this.headers["Content-Type"]="application/json")}return $(e,[{key:"toRackResponse",value:function(){return[this.code,this.headers,this.data]}}]),e}(),ye={},me={},pe={},ve={};function ge(e){if("string"!=typeof ye[e]){var t=(0,y._A)(ke(e),!1).split("/").map(p()).join("/");ye[e]=t}return ye[e]}function _e(e){if("string"!=typeof me[e]){var t=(0,y.H0)(ke(e));me[e]=t}return me[e]}function ke(e){if("string"!=typeof pe[e]){var t=(0,y.It)(e);pe[e]=t}return pe[e]}function be(e){if("string"!=typeof ve[e]){var t=(0,y.kC)(e);ve[e]=t}return ve[e]}function Fe(e){return r()(e)&&!0===e.__isAssociation__}var Ae=["description","fileName","lineNumber","message","name","number","stack"];function we(e,t){if("string"==typeof e&&!t)throw new Ne(e);if(!e)throw new Ne(t.replace(/^ +/gm,"")||"Assertion failed")}function Ne(e,t){var i=Error(e);t&&(i.stack=t);for(var n=0;Ae.length>n;n++){var r=Ae[n];this[r]=["description","message","stack"].indexOf(r)>-1?"Mirage: ".concat(i[r]):i[r]}}Ne.prototype=Object.create(Error.prototype);var Ie=function(){function e(t,i){Q(this,e),this.modelName=void 0,"object"===J(t)?(this.modelName=void 0,this.opts=t):(this.modelName=t?_e(t):"",this.opts=i||{}),this.name="",this.ownerModelName=""}return $(e,[{key:"setSchema",value:function(e){this.schema=e}},{key:"isReflexive",value:function(){return!(this.modelName!==this.ownerModelName||!this.opts.inverse)||!(void 0!==this.opts.inverse||this.ownerModelName!==this.modelName)}},{key:"isPolymorphic",get:function(){return this.opts.polymorphic}},{key:"type",get:function(){throw new Error("Subclasses of Association must implement a getter for type")}},{key:"foreignKey",get:function(){return this.getForeignKey()}},{key:"identifier",get:function(){throw new Error("Subclasses of Association must implement a getter for identifier")}}]),e}(),Re={},Me=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"getForeignKeyArray",value:function(){return[ge(this.ownerModelName),this.getForeignKey()]}},{key:"getForeignKey",value:function(){if("string"!=typeof Re[this.name]){var e="".concat(ge(this.name),"Id");Re[this.name]=e}return Re[this.name]}},{key:"addMethodsToModelClass",value:function(e,t){var i=e.prototype,n=this,r=this.getForeignKey(),o=Z({},t,this);i.belongsToAssociations=Object.assign(i.belongsToAssociations,o),Object.keys(i.belongsToAssociations).forEac
1h((function(e){var t=i.belongsToAssociations[e];i.belongsToAssociationFks[t.getForeignKey()]=t})),this.schema.addDependentAssociation(this,this.modelName),i.associationKeys.add(t),i.associationIdKeys.add(r),Object.defineProperty(i,r,{get:function(){this._tempAssociations=this._tempAssociations||{};var e=this._tempAssociations[t];return null===e?null:n.isPolymorphic?e?{id:e.id,type:e.modelName}:this.attrs[r]:e?e.id:this.attrs[r]},set:function(e){var i;null===e?i=null:void 0!==e&&(n.isPolymorphic?(we("object"===J(e),"You're setting an ID on the polymorphic association '".concat(n.name,"' but you didn't pass in an object. Polymorphic IDs need to be in the form { type, id }.")),i=n.schema[n.schema.toCollectionName(e.type)].find(e.id)):we(i=n.schema[n.schema.toCollectionName(n.modelName)].find(e),"Couldn't find ".concat(n.modelName," with id = ").concat(e))),this[t]=i}}),Object.defineProperty(i,t,{get:function(){this._tempAssociations=this._tempAssociations||{};var e=this._tempAssociations[t],i=this[r],o=null;return e?o=e:null!==i&&(o=n.isPolymorphic?n.schema[n.schema.toCollectionName(i.type)].find(i.id):n.schema[n.schema.toCollectionName(n.modelName)].find(i)),o},set:function(e){if(this._tempAssociations=this._tempAssociations||{},this._tempAssociations[t]=e,e&&e.hasInverseFor(n)){var i=e.inverseFor(n);e.associate(this,i)}}}),i["new".concat(be(t))]=function(){var e,i;n.isPolymorphic?(e=arguments.length>0?arguments[0]:void 0,i=arguments.length>1?arguments[1]:void 0):(e=n.modelName,i=arguments.length>0?arguments[0]:void 0);var r=n.schema[n.schema.toCollectionName(e)].new(i);return this[t]=r,r},i["create".concat(be(t))]=function(){var e,i;n.isPolymorphic?(e=arguments.length>0?arguments[0]:void 0,i=arguments.length>1?arguments[1]:void 0):(e=n.modelName,i=arguments.length>0?arguments[0]:void 0);var r=n.schema[n.schema.toCollectionName(e)].create(i);return this[t]=r,this.save(),r.reload()}}},{key:"disassociateAllDependentsFromTarget",value:function(e){var t,i=this;t=this.isPolymorphic?{type:e.modelName,id:e.id}:e.id,this.schema[this.schema.toCollectionName(this.ownerModelName)].where((function(e){var n=e[i.getForeignKey()];return!!n&&("object"===J(n)?n.type===t.type&&n.id===t.id:n===t)})).models.forEach((function(t){t.disassociate(e,i),t.save()}))}},{key:"identifier",get:function(){if("string"!=typeof Re[this.name]){var e="".concat(ge(this.name),"Id");Re[this.name]=e}return Re[this.name]}},{key:"type",get:function(){return"belongsTo"}}]),i}(Ie);function Ce(e){return Array.isArray(e)?e.map(Ce):Object.assign({},e)}var Oe=function(){function e(t,i,n){Q(this,e),this.name=t,this._records=[],this.identityManager=new n,i&&this.insert(i)}return $(e,[{key:"all",value:function(){return Ce(this._records)}},{key:"insert",value:function(e){var t=this;return Array.isArray(e)?k()(e,(function(e){return t._insertRecord(e)})):this._insertRecord(e)}},{key:"find",value:function(e){if(Array.isArray(e))return this._findRecords(e).filter(Boolean).map(Ce);var t=this._findRecord(e);return t?Ce(t):null}},{key:"findBy",value:function(e){var t=this._findRecordBy(e);return t?Ce(t):null}},{key:"where",value:function(e){return this._findRecordsWhere(e).map(Ce)}},{key:"firstOrCreate",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.where(e),n=se(i,1),r=n[0];if(r)return r;var o=Object.assign(t,e),s=this.insert(o);return s}},{key:"update",value:function(e,t){var i,n=this;if(void 0===t){t=e;var r=[];return this._records.forEach((function(e){var i=Object.assign({},e);n._updateRecord(e,t),g()(i,e)||r.push(e)})),r}if("number"==typeof e||"string"==typeof e){var o=this._findRecord(e);return this._updateRecord(o,t),o}return Array.isArray(e)?((i=this._findRecords(e)).forEach((function(e){n._updateRecord(e,t)}
1)),i):"object"===J(e)?((i=this._findRecordsWhere(e)).forEach((function(e){n._updateRecord(e,t)})),i):void 0}},{key:"remove",value:function(e){var t=this;if(void 0===e)this._records=[],this.identityManager.reset();else if("number"==typeof e||"string"==typeof e){var i=this._findRecord(e),n=this._records.indexOf(i);this._records.splice(n,1)}else Array.isArray(e)?this._findRecords(e).forEach((function(e){var i=t._records.indexOf(e);t._records.splice(i,1)})):"object"===J(e)&&this._findRecordsWhere(e).forEach((function(e){var i=t._records.indexOf(e);t._records.splice(i,1)}))}},{key:"_findRecord",value:function(e){return e=e.toString(),this._records.find((function(t){return t.id===e}))}},{key:"_findRecordBy",value:function(e){return this._findRecordsWhere(e)[0]}},{key:"_findRecords",value:function(e){return e.map(this._findRecord,this)}},{key:"_findRecordsWhere",value:function(e){var t=this._records;var i="object"===J(e)?function(t){return Object.keys(e).every((function(i){return String(t[i])===String(e[i])}))}:e;return t.filter(i)}},{key:"_insertRecord",value:function(e){var t=Ce(e);return t&&null==t.id?t.id=this.identityManager.fetch(t):(t.id=t.id.toString(),this.identityManager.set(t.id)),this._records.push(t),Ce(t)}},{key:"_updateRecord",value:function(e,t){var i=t&&Object.prototype.hasOwnProperty.call(t,"id")?t.id.toString():null;if(i&&e.id!==i)throw new Error("Updating the ID of a record is not permitted");for(var n in t)"id"!==n&&(e[n]=t[n])}}]),e}(),ze=function(){function e(t,i){Q(this,e),this._collections=[],this.registerIdentityManagers(i),t&&this.loadData(t)}return $(e,[{key:"loadData",value:function(e){for(var t in e)this.createCollection(t,F()(e[t]))}},{key:"dump",value:function(){return this._collections.reduce((function(e,t){return e[t.name]=t.all(),e}),{})}},{key:"createCollection",value:function(e,t){if(this[e])t&&this[e].insert(t);else{var i=this.identityManagerFor(e),n=new Oe(e,t,i);Object.defineProperty(this,e,{get:function(){var e=n.all();return["insert","find","findBy","where","update","remove","firstOrCreate"].forEach((function(t){e[t]=function(){return n[t].apply(n,arguments)}})),e}}),Object.defineProperty(this,"_".concat(e),{get:function(){var e=[];return["insert","find","findBy","where","update","remove","firstOrCreate"].forEach((function(t){e[t]=function(){return n[t].apply(n,arguments)}})),e}}),this._collections.push(n)}return this}},{key:"createCollections",value:function(){for(var e=this,t=arguments.length,i=new Array(t),n=0;t>n;n++)i[n]=arguments[n];i.forEach((function(t){return e.createCollection(t)}))}},{key:"emptyData",value:function(){this._collections.forEach((function(e){return e.remove()}))}},{key:"identityManagerFor",value:function(e){return this._identityManagers[this._container.inflector.singularize(e)]||this._identityManagers.application||he}},{key:"registerIdentityManagers",value:function(e){this._identityManagers=e||{}}}]),e}(),Pe=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];Q(this,e),we(t&&"string"==typeof t,"You must pass a `modelName` into a Collection"),this.modelName=t,this.models=i}return $(e,[{key:"update",value:function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return w().apply(void 0,[this.models,"update"].concat(t)),this}},{key:"save",value:function(){return w()(this.models,"save"),this}},{key:"reload",value:function(){return w()(this.models,"reload"),this}},{key:"destroy",value:function(){return w()(this.models,"destroy"),this}},{key:"add",value:function(e){return this.models.push(e),this}},{key:"remove",value:function(e){var t=this.models.find((function(t){return t.toString()===e.toString()}));if(t){var i=this.models.indexOf(t);this.models.splice(i,1)}return this}},{key:"includes",value:function(e){return this.models.some((function(t){return t.toString()===e.toString()}))}},{key:"filter",value:function(t){var i=this.models.filter(t);return new e(this.modelName,i)}},{key:"sort",value:function(t){var i=this.models.concat().sort(t);return new e(this.modelName,i)}},{key:"slice",value:function(){var t,i=(t=this.models).slice.apply(t,arguments);return new e(this.modelName,i)}},{key:"mergeCollection",value:function(e){return this.models=this.models.concat(e.models),this}},{key:"toString",value:function(){return"collection:".concat(this.modelName,"(").concat(this.models.map((function(e){return e.id})).join(","),")")}},{key:"length",get:function(){return this.models.length}}]),e}(),Se=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];Q(this,e),this.models=t}return $(e,[{key:"update",value:function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return w().apply(void 0,[this.models,"update"].concat(t)),this}},{key:"destroy",value:function(){return w()(this.models,"destroy"),this}},{key:"save",value:function(){return w()(this.models,"save"),this}},{key:"reload",value:function(){return w()(this.models,"reload"),this}},{key:"add",value:function(e){return this.models.push(e),this}},{key:"remove",value:function(e){var t=this.models.find((function(t){return g()(t.attrs,e.attrs)}));if(t){var i=this.models.indexOf(t);this.models.splice(i,1)}return this}},{key:"includes",value:function(e){return this.models.some((function(t){return g()(t.attrs,e.attrs)}))}},{key:"filter",value:function(t){return new e(this.models.filter(t))}},{key:"sort",value:function(t){return new e(this.models.concat().sort(t))}},{key:"slice",value:function(){var t,i=(t=this.models).slice.apply(t,arguments);return new e(i)}},{key:"mergeCollection",value:function(e){return this.models=this.models.concat(e.models),this}},{key:"toString",value:function(){return"collection:".concat(this.modelName,"(").concat(this.models.map((function(e){return e.id})).join(","),")")}},{key:"length",get:function(){return this.models.length}}]),e}(),Te={},je=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"getForeignKeyArray",value:function(){return[ge(this.ownerModelName),this.getForeignKey()]}},{key:"getForeignKey",value:function(){if("string"!=typeof Te[this.name]){var e="".concat(this._container.inflector.singularize(ge(this.name)),"Ids");Te[this.name]=e}return Te[this.name]}},{key:"addMethodsToModelClass",value:function(e,t){var i=e.prototype,n=this,r=this.getForeignKey(),o=Z({},t,this);i.hasManyAssociations=Object.assign(i.hasManyAssociations,o),Object.keys(i.hasManyAssociations).forEac
1h((function(e){var t=i.hasManyAssociations[e];i.hasManyAssociationFks[t.getForeignKey()]=t})),this.schema.addDependentAssociation(this,this.modelName),i.associationKeys.add(t),i.associationIdKeys.add(r),Object.defineProperty(i,r,{get:function(){this._tempAssociations=this._tempAssociations||{};var e=this._tempAssociations[t];return e?e.models.map(n.isPolymorphic?function(e){return{type:e.modelName,id:e.id}}:function(e){return e.id}):this.attrs[r]||[]},set:function(e){var i;if(null===e)i=[];else if(void 0!==e)if(we(Array.isArray(e),"You must pass an array in when setting ".concat(r," on ").concat(this)),n.isPolymorphic){we(e.every((function(e){return"object"===J(e)&&void 0!==J(e.type)&&void 0!==J(e.id)})),"You must pass in an array of polymorphic identifiers (objects of shape { type, id }) when setting ".concat(r," on ").concat(this));var o=e.map((function(e){var t=e.id;return n.schema[n.schema.toCollectionName(e.type)].find(t)}));i=new Se(o)}else i=n.schema[n.schema.toCollectionName(n.modelName)].find(e);this[t]=i}}),Object.defineProperty(i,t,{get:function(){this._tempAssociations=this._tempAssociations||{};var e=null;if(this._tempAssociations[t])e=this._tempAssociations[t];else{if(n.isPolymorphic)if(this[r]){var i=this[r].map((function(e){var t=e.id;return n.schema[n.schema.toCollectionName(e.type)].find(t)}));e=new Se(i)}else e=new Se(n.modelName);else e=this[r]?n.schema[n.schema.toCollectionName(n.modelName)].find(this[r]):new Pe(n.modelName);this._tempAssociations[t]=e}return e},set:function(e){var i,r=this;(e instanceof Pe||e instanceof Se)&&(e=e.models),e=e?I()(e):[],this._tempAssociations=this._tempAssociations||{},i=n.isPolymorphic?new Se(e):new Pe(n.modelName,e),this._tempAssociations[t]=i,e.forEach((function(e){if(e.hasInverseFor(n)){var t=e.inverseFor(n);e.associate(r,t)}}))}}),i["new".concat(be(ge(this._container.inflector.singularize(n.name))))]=function(){var e,i;n.isPolymorphic?(e=arguments.length>0?arguments[0]:void 0,i=arguments.length>1?arguments[1]:void 0):(e=n.modelName,i=arguments.length>0?arguments[0]:void 0);var r=n.schema[n.schema.toCollectionName(e)].new(i),o=this[t].models;return o.push(r),this[t]=o,r},i["create".concat(be(ge(this._container.inflector.singularize(n.name))))]=function(){var e,i;n.isPolymorphic?(e=arguments.length>0?arguments[0]:void 0,i=arguments.length>1?arguments[1]:void 0):(e=n.modelName,i=arguments.length>0?arguments[0]:void 0);var r=n.schema[n.schema.toCollectionName(e)].create(i),o=this[t].models;return o.push(r),this[t]=o,this.save(),r.reload()}}},{key:"disassociateAllDependentsFromTarget",value:function(e){var t,i=this;t=this.isPolymorphic?{type:e.modelName,id:e.id}:e.id,this.schema[this.schema.toCollectionName(this.ownerModelName)].where((function(e){var n=e[i.getForeignKey()];return n&&n.find((function(e){return"object"===J(e)?e.type===t.type&&e.id===t.id:e===t}))})).models.forEach((function(t){t.disassociate(e,i),t.save()}))}},{key:"identifier",get:function(){if("string"!=typeof Te[this.name]){var e="".concat(ge(this._container.inflector.singularize(this.name)),"Ids");Te[this.name]=e}return Te[this.name]}},{key:"type",get:function(){return"hasMany"}}]),i}(Ie),Ee={},qe=function(){function e(){Q(this,e)}return $(e,[{key:"getModelClassFromPath",value:function(e){if(e){if("string"!=typeof Ee[e]){for(var t,i=e.split("/"),n=i.length-1;n>=0;n--){var r=i[n];if(r.length&&":"!==r[0]){t=r;break}}Ee[e]=_e(ge(this._container.inflector.singularize(t)))}return Ee[e]}}},{key:"_getIdForRequest",value:function(e,t){var i;return e&&e.params&&e.params.id?i=e.params.id:t&&t.data&&t.data.id&&(i=t.data.id),i}},{key:"_getJsonApiDocForRequest",value:function(e,t){var i;return e&&e.requestBody&&(i=JSON.parse(e.requestBody)),this.serializerOrRegistry.normalize(i,t)}},{key:"_getAttrsForRequest",value:function(e,t){var i=this,n=this._getJsonApiDocForRequest(e,t),r=this._getIdForRequest(e,n),o={};return we(n.data&&(n.data.attributes||n.data.type||n.data.relationships),"You're using a shorthand or #normalizedRequestAttrs, but your serializer's normalize function did not return a valid JSON:API document. Consult the docs for the normalize hook on the Serializer class."),n.data.attributes&&(o=Object.keys(n.data.attributes).reduce((function(e,t){return e[ge(t)]=n.data.attributes[t],e}),{})),n.data.relationships&&Object.keys(n.data.relationships).forEac
1h((function(r){var s,a=n.data.relationships[r],c=i.schema.modelClassFor(t).associationFor(ge(r));we(c,"You're passing the relationship '".concat(r,"' to the '").concat(t,"' model via a ").concat(e.method," to '").concat(e.url,"', but you did not define the '").concat(r,"' association on the '").concat(t,"' model.")),s=c.isPolymorphic?a.data:c instanceof je?a.data&&a.data.map((function(e){return e.id})):a.data&&a.data.id,o[c.identifier]=s}),{}),r&&(o.id=r),o}},{key:"_getAttrsForFormRequest",value:function(e){var t=e.requestBody;return we(t&&"string"==typeof t,"You're using the helper method #normalizedFormData, but the request body is empty or not a valid url encoded string."),t.split("&").reduce((function(e,t){var i=se(t.split("="),2);return e[i[0]]=decodeURIComponent(i[1].replace(/\+/g," ")),e}),{})}}]),e}(),xe=function(e){V(i,e);var t=oe(i);function i(e,n,r,o,s){var a;return Q(this,i),(a=t.call(this,s)).schema=e,a.serializerOrRegistry=n,a.userFunction=r,a.path=o,a}return $(i,[{key:"handle",value:function(e){return this.userFunction(this.schema,e)}},{key:"setRequest",value:function(e){this.request=e}},{key:"serialize",value:function(e,t){return(t?this.serializerOrRegistry.serializerFor(t,{explicit:!0}):this.serializerOrRegistry).serialize(e,this.request)}},{key:"normalizedRequestAttrs",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this.path,n=this.request,r=this.request.requestHeaders,o={};for(var s in r)o[s.toLowerCase()]=r[s];return/x-www-form-urlencoded/.test(o["content-type"])?e=this._getAttrsForFormRequest(n):(t?we(_e(t)===t,"You called normalizedRequestAttrs('".concat(t,"'), but normalizedRequestAttrs was intended to be used with the dasherized version of the model type. Please change this to normalizedRequestAttrs('").concat(_e(t),"').")):t=this.getModelClassFromPath(i),we(this.schema.hasModelForModelName(t),"You're using a shorthand or the #normalizedRequestAttrs helper but the detected model of '".concat(t,"' does not exist. You might need to pass in the correct modelName as the first argument to #normalizedRequestAttrs.")),e=this._getAttrsForRequest(n,t)),e}}]),i}(qe),Ke=function(){function e(t,i,n){Q(this,e),this.schema=t,this.serializerOrRegistry=i,this.object=n}return $(e,[{key:"handle",value:function(){return this.object}}]),e}(),De=function(e){V(i,e);var t=oe(i);function i(e,n,r,o){var s,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};Q(this,i),s=t.call(this),r=r||s.getModelClassFromPath(o),s.schema=e,s.serializerOrRegistry=n,s.shorthand=r,s.options=a;var c=Array.isArray(r)?"array":J(r);if("string"===c){var u=s.schema[s.schema.toCollectionName(r)];s.handle=function(e){return s.handleStringShorthand(e,u)}}else if("array"===c){var l=r.map((function(e){return s.schema[s.schema.toCollectionName(e)]}));s.handle=function(e){return s.handleArrayShorthand(e,l)}}return s}return i}(qe),Ye=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"handleStringShorthand",value:function(e,t){var i=ge(this.shorthand);we(t,"The route handler for ".concat(e.url," is trying to access the ").concat(i," model, but that model doesn't exist."));var n=this._getIdForRequest(e);if(n){var r=t.find(n);return r||new fe(404)}if(this.options.coalesce){var o=this.serializerOrRegistry.getCoalescedIds(e,i);if(o)return t.find(o)}return t.all()}},{key:"handleArrayShorthand",value:function(e,t){var i=this.shorthand;return we(!this._getIdForRequest(e)||this._container.inflector.singularize(i[0])!==i[0],"It looks like you're using the \"Single record with\n      related records\" version of the array shorthand, in addition to opting\n      in to the model layer. This shorthand was made when there was no\n      serializer layer. Now that you're using models, please ensure your\n      relationships are defined, and create a serializer for the parent\n      model, adding the relationships there."),t.map((function(e){return e.all()}))}}]),i}(De),He=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"handleStringShorthand",value:function(e,t){var i=ge(this.shorthand);we(t,"The route handler for ".concat(e.url," is trying to access the ").concat(i," model, but that model doesn't exist."));var n=this._getAttrsForRequest(e,t.camelizedModelName);return t.create(n)}}]),i}(De),Be=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"handleStringShorthand",value:function(e,t){var i=ge(this.shorthand);we(t,"The route handler for ".concat(e.url," is trying to access the ").concat(i," model, but that model doesn't exist."));var n=this._getIdForRequest(e),r=t.find(n);if(!r)return new fe(404);var o=this._getAttrsForRequest(e,t.camelizedModelName);return r.update(o)}}]),i}(De),Le=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"handleStringShorthand",value:function(e,t){var i=ge(this.shorthand);we(t,"The route handler for ".concat(e.url," is trying to access the ").concat(i," model, but that model doesn't exist."));var n=this._getIdForRequest(e),r=t.find(n);if(!r)return new fe(404);r.destroy()}},{key:"handleArrayShorthand",value:function(e,t){var i=this,n=this._getIdForRequest(e),r=t[0].find(n);t.slice(1).map((function(e){return i._container.inflector.pluralize(e.camelizedModelName)}
1)).forEach((function(e){return r[e].destroy()})),r.destroy()}}]),i}(De),Ge=function(e){V(i,e);var t=oe(i);function i(){return Q(this,i),t.apply(this,arguments)}return $(i,[{key:"handleStringShorthand",value:function(e,t){var i=ge(this.shorthand);we(t,"The route handler for ".concat(e.url," is trying to access the ").concat(i," model, but that model doesn't exist."));var n=this._getIdForRequest(e);if(n){var r=t.find(n);return new fe(r?204:404)}if(this.options.coalesce&&e.queryParams&&e.queryParams.ids){var o=t.find(e.queryParams.ids);return new fe(o?204:404)}return new fe(204)}}]),i}(De),We={get:200,put:204,post:201,delete:204};var Je=function(){function e(t){var i=t.schema,n=t.verb,r=t.rawHandler,o=t.customizedCode,s=t.options,a=t.path,c=t.serializerOrRegistry;Q(this,e),this.verb=n,this.customizedCode=o,this.serializerOrRegistry=c,this.handler=function(e){var t,i=e.verb,n=e.rawHandler,r=[e.schema,e.serializerOrRegistry,n,e.path,e.options],o=J(n);return"function"===o?t=ie(xe,r):"object"===o&&n?t=ie(Ke,r):"get"===i?t=ie(Ye,r):"post"===i?t=ie(He,r):"put"===i||"patch"===i?t=ie(Be,r):"delete"===i?t=ie(Le,r):"head"===i&&(t=ie(Ge,r)),t}({verb:n,schema:i,path:a,serializerOrRegistry:c,rawHandler:r,options:s})}return $(e,[{key:"handle",value:function(e){var t=this;return this._getMirageResponseForRequest(e).then((function(i){return t.serialize(i,e)})).then((function(e){return e.toRackResponse()}))}},{key:"_getMirageResponseForRequest",value:function(e){var t;try{this.handler instanceof xe&&this.handler.setRequest(e),t=this.handler.handle(e)}catch(i){if(i instanceof Ne)t=new fe(500,{},i);else t=new fe(500,{},{message:i.message||i,stack:"Mirage: Your ".concat(e.method," handler for the url ").concat(e.url," threw an error:\n\n").concat(i.stack||i)})}return this._toMirageResponse(t)}},{key:"_toMirageResponse",value:function(e){var t,i=this;return new Promise((function(n,r){Promise.resolve(e).then((function(r){if(r instanceof fe)t=e;else{var o=i._getCodeForResponse(r);t=new fe(o,{},r)}n(t)})).catch(r)}))}},{key:"_getCodeForResponse",value:function(e){var t;return this.customizedCode?t=this.customizedCode:204===(t=We[this.verb])&&void 0!==e&&""!==e&&(t=200),t}},{key:"serialize",value:function(e,t){return e.data=this.serializerOrRegistry.serialize(e.data,t),e}}]),e}();function Qe(e,t){var i=function(t){V(n,t);var i=oe(n);function n(){var t,r;Q(this,n);for(var o=arguments.length,s=new Array(o),a=0;o>a;a++)s[a]=arguments[a];(t=i.call.apply(i,[this].concat(s)),e&&M()(e,"constructor"))&&(r=e.constructor).call.apply(r,[ne(t)].concat(s));return t}return n}(this);return Object.assign(i,this,t),e&&Object.assign(i.prototype,e),i}var Ue=function(){function e(t,i,n,r){var o=this;return Q(this,e),we(t,"A model requires a schema"),we(i,"A model requires a modelName"),this._schema=t,this.modelName=i,this.fks=r||[],this.attrs={},n=n||{},this.fks.forEach((function(e){o.attrs[e]=void 0!==n[e]?n[e]:null})),Object.keys(n).forEach((function(e){var t=n[e];o._validateAttr(e,t),o._setupAttr(e,t),o._setupRelationship(e,t)})),this}return $(e,[{key:"save",value:function(){var e=this._schema.toInternalCollectionName(this.modelName);return this.isNew()?(this.attrs=this._schema.db[e].insert(this.attrs),this._definePlainAttribute("id")):(this._schema.isSaving[this.toString()]=!0,this._schema.db[e].update(this.attrs.id,this.attrs)),this._saveAssociations(),this._schema.isSaving[this.toString()]=!1,this}},{key:"update",value:function(e,t){var i;return null==e||("object"===J(e)?i=e:(i={}
1)[e]=t,Object.keys(i).forEach((function(e){this.associationKeys.has(e)||this.associationIdKeys.has(e)||this._definePlainAttribute(e),this[e]=i[e]}),this),this.save()),this}},{key:"destroy",value:function(){if(this.isSaved()){this._disassociateFromDependents();var e=this._schema.toInternalCollectionName(this.modelName);this._schema.db[e].remove(this.attrs.id)}}},{key:"isNew",value:function(){var e=!1;if(null!=this.attrs.id){var t=this._schema.toInternalCollectionName(this.modelName);this._schema.db[t].find(this.attrs.id)&&(e=!0)}return!e}},{key:"isSaved",value:function(){return!this.isNew()}},{key:"reload",value:function(){if(this.id){var e=this._schema.toInternalCollectionName(this.modelName),t=this._schema.db[e].find(this.id);Object.keys(t).filter((function(e){return"id"!==e})).forEach((function(e){this.attrs[e]=t[e]}),this)}return this._tempAssociations={},this}},{key:"toJSON",value:function(){return this.attrs}},{key:"associationFor",value:function(e){return this.associations[e]}},{key:"inverseFor",value:function(e){return this._explicitInverseFor(e)||this._implicitInverseFor(e)}},{key:"_explicitInverseFor",value:function(e){this._checkForMultipleExplicitInverses(e);var t=this._schema.associationsFor(this.modelName),i=e.opts.inverse,n=i?t[i]:null,r=n&&n.isPolymorphic,o=n&&n.modelName===e.ownerModelName;return n&&n.opts.inverse&&n.opts.inverse!==e.name&&we(!1,"You specified an inverse of ".concat(i," for ").concat(e.name,", but it does not match ").concat(n.modelName," ").concat(n.name,"'s inverse")),r||o?n:null}},{key:"_checkForMultipleExplicitInverses",value:function(e){var t=this._schema.associationsFor(this.modelName);we(1>=Object.keys(t).filter((function(i){var n=t[i];return e.ownerModelName===n.modelName&&e.name===n.opts.inverse})).length,"The ".concat(this.modelName," model has defined multiple explicit inverse associations for the ").concat(e.ownerModelName,".").concat(e.name," association."))}},{key:"_implicitInverseFor",value:function(e){var t=this,i=this._schema.associationsFor(this.modelName),n=e.ownerModelName;return O()(i).filter((function(e){return e.modelName===n})).reduce((function(i,n){var r=n.opts.inverse;return(void 0===r||r===e.name)&&(we(!i,"The ".concat(t.modelName," model has multiple possible inverse associations for the ").concat(e.ownerModelName,".").concat(e.name," association.")),i=n),i}),null)}},{key:"hasInverseFor",value:function(e){return!!this.inverseFor(e)}},{key:"alreadyAssociatedWith",value:function(t,i){var n=this[i.name];if(n&&t)return n instanceof e?n.isSaved()&&t.isSaved()?n.toString()===t.toString():n===t:n.includes(t)}},{key:"associate",value:function(e,t){if(!this.alreadyAssociatedWith(e,t)){var i=t.name;t instanceof je?this[i].includes(e)||this[i].add(e):this[i]=e}}},{key:"disassociate",value:function(e,t){var i=t.getForeignKey();if(t instanceof je){var n;if(t.isPolymorphic){var r=this[i].find((function(t){return t.type===e.modelName&&t.id===e.id}));n=r&&this[i].indexOf(r)}else n=this[i].map((function(e){return e.toString()})).indexOf(e.id.toString());n>-1&&this.attrs[i].splice(n,1)}else this.attrs[i]=null}},{key:"_setupAttr",value:function(e,t){this.associationKeys.has(e)||this.associationIdKeys.has(e)||(this.attrs[e]=t,this._definePlainAttribute(e))}},{key:"_definePlainAttribute",value:function(e){var t=Object.getOwnPropertyDescriptor(this,e);t&&t.get||(Object.prototype.hasOwnProperty.call(this.attrs,e)||(this.attrs[e]=null),Object.defineProperty(this,e,{get:function(){return this.attrs[e]},set:function(t){this.attrs[e]=t}}))}},{key:"_setupRelationship",value:function(e,t){var i=this.associationIdKeys.has(e)||this.fks.includes(e),n=this.associationKeys.has(e);i&&(null!=t&&this._validateForeignKeyExistsInDatabase(e,t),this.attrs[e]=t),n&&(this[e]=t)}},{key:"_validateAttr",value:function(t,i){if(this.associationKeys.has(t)){var n=this.associationFor(t),r=null===i;if(n instanceof je){var o=i instanceof Pe||i instanceof Se,s=Array.isArray(i)&&i.every((function(t){return t instanceof e}));we(o||s||r,"You're trying to create a ".concat(this.modelName,' model and you passed in "').concat(i,'" under the ').concat(t," key, but that key is a HasMany relationship. You must pass in a Collection, PolymorphicCollection, array of Models, or null."))}else n instanceof Me&&we(i instanceof e||r,"You're trying to create a ".concat(this.modelName,' model and 
1you passed in "').concat(i,'" under the ').concat(t," key, but that key is a BelongsTo relationship. You must pass in a Model or null."))}this.associationIdKeys.has(t)&&(t.endsWith("Ids")&&we(Array.isArray(i)||null===i,"You're trying to create a ".concat(this.modelName,' model and you passed in "').concat(i,'" under the ').concat(t," key, but that key is a foreign key for a HasMany relationship. You must pass in an array of ids or null.")));var a=i instanceof e||i instanceof Pe||i instanceof Se,c=Array.isArray(i)&&i.length&&i.every((function(t){return t instanceof e}));if(a||c){var u=i;we(this.associationKeys.has(t),"You're trying to create a ".concat(this.modelName," model and you passed in a ").concat(u.toString()," under the ").concat(t," key, but you haven't defined that key as an association on your model."))}}},{key:"_validateForeignKeyExistsInDatabase",value:function(e,t){var i=this;if(Array.isArray(t)){var n,r=this.hasManyAssociationFks[e];r.isPolymorphic?(n=t.map((function(e){var t=e.id;return i._schema.db[i._schema.toInternalCollectionName(e.type)].find(t)})),n=I()(n)):n=this._schema.db[this._schema.toInternalCollectionName(r.modelName)].find(t);var o=r.isPolymorphic?t.map((function(e){return"".concat(e.type,":").concat(e.id)})).join(","):t;we(n.length===t.length,"You're instantiating a ".concat(this.modelName," that has a ").concat(e," of ").concat(o,", but some of those records don't exist in the database."))}else{var s,a=this.belongsToAssociationFks[e];s=a.isPolymorphic?this._schema.db[this._schema.toInternalCollectionName(t.type)].find(t.id):this._schema.db[this._schema.toInternalCollectionName(a.modelName)].find(t);var c=a.isPolymorphic?"".concat(t.type,":").concat(t.id):t;we(s,"You're instantiating a ".concat(this.modelName," that has a ").concat(e," of ").concat(c,", but that record doesn't exist in the database."))}}},{key:"_saveAssociations",value:function(){this._saveBelongsToAssociations(),this._saveHasManyAssociations()}},{key:"_saveBelongsToAssociations",value:function(){var e=this;O()(this.belongsToAssociations).forEach((function(t){e._disassociateFromOldInverses(t),e._saveNewAssociates(t),e._associateWithNewInverses(t)}))}},{key:"_saveHasManyAssociations",value:function(){var e=this;O()(this.hasManyAssociations).forEach((function(t){e._disassociateFromOldInverses(t),e._saveNewAssociates(t),e._associateWithNewInverses(t)}))}},{key:"_disassociateFromOldInverses",value:function(e){e instanceof je?this._disassociateFromHasManyInverses(e):e instanceof Me&&this._disassociateFromBelongsToInverse(e)}},{key:"_disassociateFromHasManyInverses",value:function(e){var t=this,i=e.getForeignKey(),n=this._tempAssociations&&this._tempAssociations[e.name],r=this.attrs[i];n&&r&&(e.isPolymorphic?r.map((function(e){var i=e.id;return t._schema[t._schema.toCollectionName(e.type)].find(i)})):this._schema[this._schema.toCollectionName(e.modelName)].find(r||[]).models).filter((function(t){return!t.isSaving&&!n.includes(t)&&t.hasInverseFor(e)})).forEach((function(i){var n=i.inverseFor(e);i.disassociate(t,n),i.save()}))}},{key:"_disassociateFromBelongsToInverse",value:function(e){var t,i=e.getForeignKey(),n=this.attrs[i];if(void 0!==(this._tempAssociations&&this._tempAssociations[e.name])&&n&&(t=e.isPolymorphic?this._schema[this._schema.toCollectionName(n.type)].find(n.id):this._schema[this._schema.toCollectionName(e.modelName)].find(n)).hasInverseFor(e)){var r=t.inverseFor(e);t.disassociate(this,r),t._updateInDb(t.attrs)}}},{key:"_disassociateFromDependents",value:function(){var e=this;this._schema.dependentAssociationsFor(this.modelName).forEach((function(t){t.disassociateAllDependentsFromTarget(e)}))}},{key:"_saveNewAssociates",value:function(e){var t=e.getForeignKey(),i=this._tempAssociations&&this._tempAssociations[e.name];if(void 0!==i){if(this.__isSavingNewChildren=!0,delete this._tempAssociations[e.name],i instanceof Pe)i.models.filter((function(e){return!e.isSaving})).forEach((function(e){e.save()})),this._updateInDb(Z({},t,i.models.map((function(e){return e.id}))));else if(i instanceof Se)i.models.filter((function(e){return!e.isSaving}
1)).forEach((function(e){e.save()})),this._updateInDb(Z({},t,i.models.map((function(e){return{type:e.modelName,id:e.id}}))));else if(null===i)this._updateInDb(Z({},t,null));else if(this.equals(i))this._updateInDb(Z({},t,this.id));else if(!i.isSaving){i.save(),this._syncTempAssociations(i),this._updateInDb(Z({},t,e.isPolymorphic?{id:i.id,type:i.modelName}:i.id))}this.__isSavingNewChildren=!1}}},{key:"_associateWithNewInverses",value:function(t){var i=this;if(!this.__isSavingNewChildren){var n=this[t.name];n instanceof e?this._associateModelWithInverse(n,t):(n instanceof Pe||n instanceof Se)&&n.models.forEach((function(e){i._associateModelWithInverse(e,t)})),delete this._tempAssociations[t.name]}}},{key:"_associateModelWithInverse",value:function(e,t){var i=this;if(e.hasInverseFor(t)){var n=e.inverseFor(t),r=n.getForeignKey(),o=this.id;if(n instanceof Me){var s;s=n.isPolymorphic?{type:this.modelName,id:o}:o,this._schema.db[this._schema.toInternalCollectionName(e.modelName)].update(e.id,Z({},r,s))}else{var a,c,u=this._schema.db[this._schema.toInternalCollectionName(e.modelName)],l=u.find(e.id)[n.getForeignKey()]||[],h=Object.assign([],l);n.isPolymorphic?(a={type:this.modelName,id:o},c=h.some((function(e){return e.type==i.modelName&&e.id==o}))):(a=o,c=h.includes(o)),c||h.push(a),u.update(e.id,Z({},r,h))}}}},{key:"_updateInDb",value:function(e){this.attrs=this._schema.db[this._schema.toInternalCollectionName(this.modelName)].update(this.attrs.id,e)}},{key:"_syncTempAssociations",value:function(e){var t=this;Object.keys(this._tempAssociations).forEach((function(i){t._tempAssociations[i]&&t._tempAssociations[i].toString()===e.toString()&&(t._tempAssociations[i]=e)}))}},{key:"toString",value:function(){var e=this.id?"(".concat(this.id,")"):"";return"model:".concat(this.modelName).concat(e)}},{key:"equals",value:function(e){return this.toString()===e.toString()}},{key:"associations",get:function(){return this._schema.associationsFor(this.modelName)}},{key:"isSaving",get:function(){return this._schema.isSaving[this.toString()]}}]),e}();Ue.extend=Qe,Ue.findBelongsToAssociation=function(e){return this.prototype.belongsToAssociations[e]};var $e=function(){function e(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Q(this,e),this.registry=t,this.type=i,this.request=n,this.attrs=this.attrs||void 0,this.include=this.include||[],this.root=this.root||void 0,this.embed=this.embed||void 0,this.serializeIds=this.serializeIds||void 0}return $(e,[{key:"serialize",value:function(e){return this.primaryResource=e,this.buildPayload(e)}},{key:"normalize",value:function(e){return e}},{key:"buildPayload",value:function(e,t,i,n){if(!e&&P()(t))return n;if(e){var r=se(this.getHashForPrimaryResource(e),2),o=r[0],s=r[1],a=this.isCollection(e)?e.models:[e];return this.buildPayload(void 0,s,a,o)}var c=t.shift(),u=se(this.getHashForIncludedResource(c),2),l=u[0],h=u[1].filter((function(e){return!i.map((function(e){return e.toString()})).includes(e.toString())})).concat(t),d=(this.isCollection(c)?c.models:[c]).concat(i),f=this.mergePayloads(n,l);return this.buildPayload(void 0,h,d,f)}},{key:"getHashForPrimaryResource",value:function(e){var t,i=se(this.getHashForResource(e),2),n=i[0],r=i[1];this.root?(we(!(e instanceof Se),"The base Serializer class cannot serialize a top-level PolymorphicCollection when root is true, since PolymorphicCollections have no type."),t=Z({},this.serializerFor(e.modelName).keyForResource(e),n)):t=n;return[t,r]}},{key:"getHashForIncludedResource",value:function(e){var t,i;if(e instanceof Se)t={},i=e.models;else{var n=this.serializerFor(e.modelName),r=se(n.getHashForResource(e),2),o=r[0],s=r[1],a=n.keyForRelationship(e.modelName);t=Array.isArray(o)?Z({},a,o):Z({},a,[o]),i=s}return[t,i]}},{key:"getHashForResource",value:function(e){var t,i,n=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s||(i=this),s&&e.modelName&&(i=this.serializerFor(e.modelName)),t=this.isModel(e)?i._hashForModel(e,r,o):e.models.map((function(e){var t=i;return t||(t=n.serializerFor(e.modelName)),t._hashForModel(e,r,o)})),this.embed)return[t,[]];
1var a=E()(I()(d()(i.getKeysForIncluded().map((function(t){return n.isCollection(e)?e.models.map((function(e){return e[t]})):e[t]})))),(function(e){return e.toString()}));return[t,a]}},{key:"mergePayloads",value:function(e,t){var i,n=se(Object.keys(t),1)[0];return e[n]?(i=e)[n]=e[n].concat(t[n]):i=Object.assign(e,t),i}},{key:"keyForResource",value:function(e){var t=e.modelName;return this.isModel(e)?this.keyForModel(t):this.keyForCollection(t)}},{key:"keyForModel",value:function(e){return ge(e)}},{key:"keyForCollection",value:function(e){return this._container.inflector.pluralize(this.keyForModel(e))}},{key:"_hashForModel",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this._attrsForModel(e);if(t&&e.fks.forEach((function(e){delete r[e]})),this.embed){var o=Object.assign({},n);return o[e.modelName]=o[e.modelName]||{},o[e.modelName][e.id]=!0,this.getKeysForIncluded().forEach((function(t){var n=e[t];if(n&&!T()(o,"".concat(n.modelName,".").concat(n.id))){var s=se(i.getHashForResource(n,!0,o,!0),1)[0],a=i.keyForEmbeddedRelationship(t);if(r[a]=s,i.isModel(n)){var c="".concat(ge(t),"Id");delete r[c]}}})),r}return this._maybeAddAssociationIds(e,r)}},{key:"_attrsForModel",value:function(e){var t={};return t=this.attrs?this.attrs.reduce((function(t,i){return t[i]=e[i],t}),{}):Object.assign(t,e.attrs),e.fks.forEach((function(e){return delete t[e]})),this._formatAttributeKeys(t)}},{key:"_maybeAddAssociationIds",value:function(e,t){var i=this,n=Object.assign({},t);return"always"===this.serializeIds?e.associationKeys.forEach((function(t){var r=e[t],o=e.associationFor(t);if(i.isCollection(r)){var s=i.keyForRelationshipIds(t);n[s]=e["".concat(i._container.inflector.singularize(t),"Ids")]}else if(i.isModel(r)&&o.isPolymorphic){var a=i.keyForPolymorphicForeignKeyType(t),c=i.keyForPolymorphicForeignKeyId(t);n[a]=e["".concat(t,"Id")].type,n[c]=e["".concat(t,"Id")].id}else if(r){var u=i.keyForForeignKey(t);n[u]=e["".concat(t,"Id")]}})):"included"===this.serializeIds&&this.getKeysForIncluded().forEach((function(t){var r=e[t],o=e.associationFor(t);if(i.isCollection(r)){var s=i.keyForRelationshipIds(t);n[s]=e["".concat(i._container.inflector.singularize(t),"Ids")]}else if(i.isModel(r)&&o.isPolymorphic){var a=i.keyForPolymorphicForeignKeyType(t),c=i.keyForPolymorphicForeignKeyId(t);n[a]=e["".concat(t,"Id")].type,n[c]=e["".concat(t,"Id")].id}else if(i.isModel(r)){var u=i.keyForForeignKey(t);n[u]=e["".concat(t,"Id")]}})),n}},{key:"keyForAttribute",value:function(e){return e}},{key:"keyForRelationship",value:function(e){return ge(this._container.inflector.pluralize(e))}},{key:"keyForEmbeddedRelationship",value:function(e){return ge(e)}},{key:"keyForRelationshipIds",value:function(e){return"".concat(this._container.inflector.singularize(ge(e)),"Ids")}},{key:"keyForForeignKey",value:function(e){return"".concat(ge(e),"Id")}},{key:"keyForPolymorphicForeignKeyId",value:function(e){return"".concat(ge(e),"Id")}},{key:"keyForPolymorphicForeignKeyType",value:function(e){return"".concat(ge(e),"Type")}},{key:"isModel",value:function(e){return e instanceof Ue}},{key:"isCollection",value:function(e){return e instanceof Pe||e instanceof Se}},{key:"isModelOrCollection",value:function(e){return this.isModel(e)||this.isCollection(e)}},{key:"serializerFor",value:function(e){return this.registry.serializerFor(e)}},{key:"getKeysForIncluded",value:function(){return s()(this.include)?this.include(this.request,this.primaryResource):this.include}},{key:"_formatAttributeKeys",value:function(e){var t={};for(var i in e){t[this.keyForAttribute(i)]=e[i]}return t}},{key:"getCoalescedIds",value:function(){}},{key:"schema",get:function(){return this.registry.schema}}]),e}();$e.prototype.include=[],$e.prototype.root=!0,$e.prototype.embed=!1,$e.prototype.serializeIds="included",$e.extend=Qe;var Ze=function(e){V(i,e);var t=oe(i);function i(){var e;return Q(this,i),(e=t.apply(this,arguments)).alwaysIncludeLinkageData=e.alwaysIncludeLinkageData||void 0,e}return $(i,[{key:"keyForModel",value:function(e){return _e(e)}},{key:"keyForCollection",value:function(e){return _e(e)}},{key:"keyForAttribute",value:function(e){return _e(e)}},{key:"keyForRelationship",value:function(e){return _e(e)}},{key:"links",value:function(){}},{key:"getHashForPrimaryResource",value:function(e){return this._createRequestedIncludesGraph(e),[{data:this.getHashForResource(e)},this.getAddToIncludesForResource(e)]}},{key:"getHashForIncludedResource",value:function(e){var t=this.serializerFor(e.modelName).getHashForResource(e),i={included:this.isModel(e)?[t]:t},n=[];return this.hasQueryParamIncludes()||(n=this.getAddToIncludesForResource(e)),[i,n]}},{key:"getHashForResource",value:function(e){var t=this;return this.isModel(e)?this.getResourceObjectForModel(e):e.models.map((function(e){return t.getResourceObjectForModel(e)}))}},{key:"getAddToIncludesForResource",value:function(e){var t;this.hasQueryParamIncludes()?t=this.request.queryParams.include.split(","):t=this.serializerFor(e.modelName).getKeys
1ForIncluded();return this.getAddToIncludesForResourceAndPaths(e,t)}},{key:"getAddToIncludesForResourceAndPaths",value:function(e,t){var i=this,n=[];return t.forEach((function(t){var r=t.split("."),o=i.getIncludesForResourceAndPath.apply(i,[e].concat(ae(r)));n.push(o)})),E()(I()(d()(n)),(function(e){return e.toString()}))}},{key:"getIncludesForResourceAndPath",value:function(e){for(var t=this,i=arguments.length,n=new Array(i>1?i-1:0),r=1;i>r;r++)n[r-1]=arguments[r];var o=ge(n.shift()),s=[],a=[];if(this.isModel(e)){var c=e[o];this.isModel(c)?a=[c]:this.isCollection(c)&&(a=c.models)}else e.models.forEach((function(e){var i=e[o];t.isModel(i)?a.push(i):t.isCollection(i)&&(a=a.concat(i.models))}));return s=s.concat(a),n.length&&a.forEach((function(e){s=s.concat(t.getIncludesForResourceAndPath.apply(t,[e].concat(n)))})),s}},{key:"getResourceObjectForModel",value:function(e){var t=this._attrsForModel(e,!0);delete t.id;var i={type:this.typeKeyForModel(e),id:e.id,attributes:t};return this._maybeAddRelationshipsToResourceObjectForModel(i,e)}},{key:"_maybeAddRelationshipsToResourceObjectForModel",value:function(e,t){var i=this,n={};return t.associationKeys.forEach((function(e){var r=t[e],o=i.keyForRelationship(e),s={};if(i.hasLinksForRelationship(t,e)){var a=i.serializerFor(t.modelName).links(t);s.links=a[e]}if(i.alwaysIncludeLinkageData||i.shouldIncludeLinkageData(e,t)||i._relationshipIsIncludedForModel(e,t)){var c=null;i.isModel(r)?c={type:i.typeKeyForModel(r),id:r.id}:i.isCollection(r)&&(c=r.models.map((function(e){return{type:i.typeKeyForModel(e),id:e.id}}))),s.data=c}P()(s)||(n[o]=s)})),P()(n)||(e.relationships=n),e}},{key:"hasLinksForRelationship",value:function(e,t){var i=this.serializerFor(e.modelName),n=i.links&&i.links(e);return n&&null!=n[t]}},{key:"_relationshipIsIncludedForModel",value:function(e,t){if(this.hasQueryParamIncludes()){var i,n=this.request._includesGraph,r=this._graphKeyForModel(t);return n.data[r]?i=n.data[r]:n.included[this._container.inflector.pluralize(t.modelName)]&&(i=n.included[this._container.inflector.pluralize(t.modelName)][r]),i&&i.relationships&&Object.prototype.hasOwnProperty.call(i.relationships,_e(e))}return this.getKeysForIncluded().includes(e)}},{key:"_createRequestedIncludesGraph",value:function(e){var t=this,i={data:{}};if(this.isModel(e)){var n=this._graphKeyForModel(e);i.data[n]={},this._addPrimaryModelToRequestedIncludesGraph(i,e)}else this.isCollection(e)&&e.models.forEach((function(e){var n=t._graphKeyForModel(e);i.data[n]={},t._addPrimaryModelToRequestedIncludesGraph(i,e)}));this.request._includesGraph=i}},{key:"_addPrimaryModelToRequestedIncludesGraph",value:function(e,t){var i=this;if(this.hasQueryParamIncludes()){var n=this._graphKeyForModel(t);this.getQueryParamIncludes().split(",").filter((function(e){return!!e.trim()})).forEach((function(r){e.data[n].relationships=e.data[n].relationships||{};var o=r.split(".").map(_e),s=o[0],a=s,c=ge(s);we(t.associationKeys.has(c),'You tried to include "'.concat(s,'" with ').concat(t,' but no association named "').concat(c,'" is defined on the model.'));var u,l=t[c];u=i.isModel(l)?i._graphKeyForModel(l):i.isCollection(l)?l.models.map(i._graphKeyForModel):null,e.data[n].relationships[a]=u,l&&i._addResourceToRequestedIncludesGraph(e,l,o.slice(1))}))}}},{key:"_addResourceToRequestedIncludesGraph",value:function(e,t,i){var n=this;e.included=e.included||{},(this.isCollection(t)?t.models:[t]).forEach((function(t){var r=n._container.inflector.pluralize(t.modelName);e.included[r]=e.included[r]||{},n._addModelToRequestedIncludesGraph(e,t,i)}))}},{key:"_addModelToRequestedIncludesGraph",value:function(e,t,i){var n=this._container.inflector.pluralize(t.modelName),r=this._graphKeyForModel(t);e.included[n][r]=e.included[n][r]||{},i.length&&this._addResourceRelationshipsToRequestedIncludesGraph(e,n,r,t,i)}},{key:"_addResourceRelationshipsToRequestedIncludesGraph",value:function(e,t,i,n,r){e.included[t][i].relationships=e.included[t][i].relationships||{};var o,s=r[0],a=n[ge(s)];this.isModel(a)?o=this._graphKeyForModel(a):this.isCollection(a)&&(o=a.models.map(this._graphKeyForModel)),e.included[t][i].relationships[s]=o,a&&this._addResourceToRequestedIncludesGraph(e,a,r.slice(1))}},{key:"_graphKeyForModel",value:function(e){return"".concat(e.modelName,":").concat(e.id)}},{key:"getQueryParamIncludes",value:function(){return T()(this,"request.queryParams.include")}},{key:"hasQueryParamIncludes",value:function(){return!!this.getQueryParamIncludes()}},{key:"typeKeyForModel",value:function(e){return _e(this._container.inflector.pluralize(e.modelName))}}
1,{key:"getCoalescedIds",value:function(e){var t=e.queryParams&&e.queryParams["filter[id]"];return"string"==typeof t?t.split(","):t}},{key:"shouldIncludeLinkageData",value:function(e,t){return!1}}]),i}($e);Ze.prototype.alwaysIncludeLinkageData=!1;var Ve=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Q(this,e),this.schema=t,this._serializerMap=i}return $(e,[{key:"normalize",value:function(e,t){return this.serializerFor(t).normalize(e)}},{key:"serialize",value:function(e,t){var i=this;return this.request=t,this._isModelOrCollection(e)?this.serializerFor(e.modelName).serialize(e,t):Array.isArray(e)&&e.some(this._isCollection)?e.reduce((function(e,n){var r=i.serializerFor(n.modelName);return r.embed?e[i._container.inflector.pluralize(n.modelName)]=r.serialize(n,t):e=Object.assign(e,r.serialize(n,t)),e}),{}):e}},{key:"serializerFor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.explicit,n=void 0!==i&&i,r=e&&this._serializerMap&&this._serializerMap[ge(e)];return n?we(!!r,"You passed in ".concat(e," as an explicit serializer type but that serializer doesn't exist.")):we(!(r=r||this._serializerMap.application||$e)||r.prototype.embed||r.prototype.root||new r instanceof Ze,"You cannot have a serializer that sideloads (embed: false) and disables the root (root: false)."),new r(this,e,this.request)}},{key:"_isModel",value:function(e){return e instanceof Ue}},{key:"_isCollection",value:function(e){return e instanceof Pe||e instanceof Se}},{key:"_isModelOrCollection",value:function(e){return this._isModel(e)||this._isCollection(e)}},{key:"registerSerializers",value:function(e){this._serializerMap=Object.assign(this._serializerMap||{},e)}},{key:"getCoalescedIds",value:function(e,t){return this.serializerFor(t).getCoalescedIds(e)}}]),e}(),Xe={},et={},tt={},it=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Q(this,e),we(t,"A schema requires a db"),this.db=t,this._registry={},this._dependentAssociations={polymorphic:[]},this.registerModels(i),this.isSaving={}}return $(e,[{key:"registerModels",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};x()(t,(function(i,n){e.registerModel(n,t[n])}))}},{key:"registerModel",value:function(e,t){var i=this,n=ge(e),r=_e(n);t=t.extend(),this._registry[n]=this._registry[n]||{class:null,foreignKeys:[]},this._registry[n].class=t,t.prototype._schema=this,t.prototype.modelName=r,t.prototype.hasManyAssociations={},t.prototype.hasManyAssociationFks={},t.prototype.belongsToAssociations={},t.prototype.belongsToAssociationFks={},t.prototype.associationKeys=new Set,t.prototype.associationIdKeys=new Set,t.prototype.depen
1dentAssociations=[];var o={};for(var s in t.prototype)if(t.prototype[s]instanceof Ie){var a=t.prototype[s];a.name=s,a.modelName=a.modelName||this.toModelName(s),a.ownerModelName=r,a.setSchema(this);var c=se(a.getForeignKeyArray(),2),u=c[0],l=c[1];o[u]=o[u]||[],we(!o[u].includes(l),"Your '".concat(e,"' model definition has multiple possible inverse relationships of type '").concat(u,"'. Please use explicit inverses.")),o[u].push(l),this._addForeignKeyToRegistry(u,l),a.addMethodsToModelClass(t,s)}var h=this.toCollectionName(r);return this.db[h]||this.db.createCollection(h),this[h]={camelizedModelName:n,new:function(e){return i.new(n,e)},create:function(e){return i.create(n,e)},all:function(e){return i.all(n,e)},find:function(e){return i.find(n,e)},findBy:function(e){return i.findBy(n,e)},findOrCreateBy:function(e){return i.findOrCreateBy(n,e)},where:function(e){return i.where(n,e)},none:function(e){return i.none(n,e)},first:function(e){return i.first(n,e)}},this}},{key:"modelFor",value:function(e){return this._registry[e]}},{key:"new",value:function(e,t){return this._instantiateModel(_e(e),t)}},{key:"create",value:function(e,t){return this.new(e,t).save()}},{key:"all",value:function(e){var t=this.collectionForType(e);return this._hydrate(t,_e(e))}},{key:"none",value:function(e){return this._hydrate([],_e(e))}},{key:"find",value:function(e,t){var i=this.collectionForType(e).find(t);return Array.isArray(t)&&we(i.length===t.length,"Couldn't find all ".concat(this._container.inflector.pluralize(e)," with ids: (").concat(t.join(","),") (found ").concat(i.length," results, but was looking for ").concat(t.length,")")),this._hydrate(i,_e(e))}},{key:"findBy",value:function(e,t){var i=this.collectionForType(e).findBy(t);return this._hydrate(i,_e(e))}},{key:"findOrCreateBy",value:function(e,t){var i=this.collectionForType(e).findBy(t);return i?this._hydrate(i,_e(e)):this.create(e,t)}},{key:"where",value:function(e,t){var i=this.collectionForType(e).where(t);return this._hydrate(i,_e(e))}},{key:"first",value:function(e){var t=this.collectionForType(e);return this._hydrate(t[0],_e(e))}},{key:"modelClassFor",value:function(e){var t=this._registry[ge(e)];return we(t,"Model not registered: ".concat(e)),t.class.prototype}},{key:"addDependentAssociation",value:function(e,t){e.isPolymorphic?this._dependentAssociations.polymorphic.push(e):(this._dependentAssociations[t]=this._dependentAssociations[t]||[],this._dependentAssociations[t].push(e))}},{key:"dependentAssociationsFor",value:function(e){return(this._dependentAssociations[e]||[]).concat(this._dependentAssociations.polymorphic||[])}},{key:"associationsFor",value:function(e){var t=this.modelClassFor(e);return Object.assign({},t.belongsToAssociations,t.hasManyAssociations)}},{key:"hasModelForModelName",value:function(e){return this.modelFor(ge(e))}},{key:"collectionForType",value:function(e){var t=this.toCollectionName(e);return we(this.db[t],"You're trying to find model(s) of type ".concat(e," but this collection doesn't exist in the database.")),this.db[t]}},{key:"toCollectionName",value:function(e){if("string"!=typeof Xe[e]){var t=_e(e),i=ge(this._container.inflector.pluralize(t));Xe[e]=i}return Xe[e]}},{key:"toInternalCollectionName",value:function(e){if("string"!=typeof et[e]){var t="_".concat(this.toCollectionName(e));et[e]=t}return et[e]}},{key:"toModelName",value:function(e){if("string"!=typeof tt[e]){var t=_e(e),i=this._container.inflector.singularize(t);tt[e]=i}return tt[e]}},{key:"_addForeignKeyToRegistry",value:function(e,t){this._registry[e]=this._registry[e]||{class:null,foreignKeys:[]};var i=this._registry[e].foreignKeys;i.includes(t)||i.push(t)}},{key:"_instantiateModel",value:function(e,t){return new(this._modelFor(e))(this,e,t,this._foreignKeysFor(e))}},{key:"_modelFor",value:function(e){return this._registry[ge(e)].class}},{key:"_foreignKeysFor",value:function(e){return this._registry[ge(e)].foreignKeys}},{key:"_hydrate",value:function(e,t){if(Array.isArray(e)){var i=e.map((function(e){return this._instantiateModel(t,e)}),this);return new Pe(t,i)}return e?this._instantiateModel(t,e):null}}]),e}(),nt={Db:ze,Association:Ie,RouteHandler:Je,BaseRouteHandler:qe,Serializer:$e,SerializerRegistry:Ve,Schema:it},rt={singularize:y.C5,pluralize:y._6},ot=function(){function e(){Q(this,e),this.inflector=rt}return $(e,[{key:"register",value:function(e,t){this[e]=t}},{key:"create",value:function(e){var t=nt[e];t.prototype._container=this;for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;i>r;r++)n[r-1]=arguments[r];return ie(t,n)}}]),e}(),st=new ot;ze.prototype._container=st,Ie.prototype._container=st,qe.prototype._container=st,Je.prototype._container=st,$e.prototype._container=st,Ve.prototype._container=st,it.prototype._container=st;var at={};function ct(e){if("undefined"!=typeof window)return new f.Z((function(){this.passthroughRequest=function(t,i,n){e.shouldLog()},this.handledRequest=function(t,i,n){if(e.shouldLog()){var r=n.requestBody,o=n.responseText;try{JSON.parse(r)}catch(e){r}try{JSON.parse(o)}catch(e){o}}};var t=this.checkPassthrough;this.checkPassthrough=function(i){var n=e.passthroughChecks.some((function(e){return e(i)}));if(n){var r=i.url.includes("?")?i.url.substr(0,i.url.indexOf("?")):i.url;this[i.method.toLowerCase()](r,this.passthrough)}return t.apply(this,arguments)},this.unhandledRequest=function(e,t){t=decodeURI(t),we("Your app tried to ".concat(e," '").concat(t,"', but there was no route defined to handle this request. Define a route for this endpoint in y
1our routes() config. Did you forget to define a namespace?"))}}),{trackRequests:e.shouldTrackRequests()})}var ut={coalesce:!1,timing:void 0},lt={singularize:y.C5,pluralize:y._6},ht=["http://localhost:0/chromecheckurl","http://localhost:30820/socket.io",function(e){return/.+\.hot-update.json$/.test(e.url)}];function dt(e){var t=se(e.splice(-1),1)[0];!function(e){if(!e||"object"!==J(e))return!1;for(var t=Object.keys(ut),i=Object.keys(e),n=0;i.length>n;n++)if(t.indexOf(i[n])>-1)return!0;return!1}(t)?(e.push(t),t=ut):t=H()({},ut,t);for(var i=2-e.length;i-- >0;)e.push(void 0);return e.push(t),e}function ft(e){return new yt(e)}var yt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Q(this,e),this._container=new ot,this.config(t),this.db=this.db||void 0,this.schema=this.schema||void 0}return $(e,[{key:"config",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.passthroughChecks=this.passthroughChecks||[];var t=e.environment&&this.environment&&this.environment!==e.environment;we(!t,"You cannot modify Mirage's environment once the server is created"),this.environment=e.environment||this.environment||"development",e.routes&&(we(!e.baseConfig,"The routes option is an alias for the baseConfig option. You can't pass both options into your server definition."),e.baseConfig=e.routes),e.seeds&&(we(!e.scenarios,"The seeds option is an alias for the scenarios.default option. You can't pass both options into your server definition."),e.scenarios={default:e.seeds}),this._config=e,this.namespace=this.namespace||e.namespace||"",this.inflector=e.inflector||lt,this._container.register("inflector",this.inflector),this.urlPrefix=this.urlPrefix||e.urlPrefix||"",this.timing=this.timing||e.timing||400,this.logging=void 0!==this.logging?this.logging:void 0,this.testConfig=this.testConfig||void 0,this.trackRequests=e.trackRequests,this._defineRouteHandlerHelpers(),this.db?this.db.registerIdentityManagers(e.identityManagers):this.db=this._container.create("Db",void 0,e.identityManagers),this.schema?(this.schema.registerModels(e.models),this.serializerOrRegistry.registerSerializers(e.serializers||{})):(this.schema=this._container.create("Schema",this.db,e.models),this.serializerOrRegistry=this._container.create("SerializerRegistry",this.schema,e.serializers));var i=this._hasModulesOfType(e,"factories"),n=e.scenarios&&Object.prototype.hasOwnProperty.call(e.scenarios,"default"),r=void 0!==e.trackRequests&&this.pretender;we(!r,"You cannot modify Pretender's request tracking once the server is created"),this.pretender=this.pretender||e.pretender||ct(this),e.baseConfig&&this.loadConfig(e.baseConfig),this.isTest()&&(e.testConfig&&this.loadConfig(e.testConfig),"undefined"!=typeof window&&(window.server=this)),this.isTest()&&i?this.loadFactories(e.factories):!this.isTest()&&n?(this.loadFactories(e.factories),e.scenarios.default(this)):this.loadFixtures();var o=void 0===e.useDefaultPassthroughs||e.useDefaultPassthroughs;o&&this._configureDefaultPassthroughs()}},{key:"isTest",value:function(){return"test"===this.environment}},{key:"shouldLog",value:function(){return void 0!==this.logging?this.logging:!this.isTest()}},{key:"shouldTrackRequests",value:function(){return Boolean(this.trackRequests)}},{key:"loadConfig",value:function(e){e.call(this),this.timing=this.isTest()?0:this.timing||0}},{key:"passthrough",value:function(){for(var e=this,t=arguments.length,i=new Array(t),n=0;t>n;n++)i[n]=arguments[n];if("undefined"!=typeof window){var r=["get","post","put","delete","patch","options","head"],o=i[i.length-1];0===i.length?i=["/**","/"]:Array.isArray(o)&&(r=i.pop()),i.forEac
1h((function(t){"function"==typeof t?e.passthroughChecks.push(t):r.forEach((function(i){var n=e._getFullPath(t);e.pretender[i](n,e.pretender.passthrough)}))}))}}},{key:"loadFixtures",value:function(){for(var e=this._config.fixtures,t=arguments.length,i=new Array(t),n=0;t>n;n++)i[n]=arguments[n];if(i.length){var r=i.map(ge),o=r.filter((function(t){return!e[t]}));if(o.length)throw new Error("Fixtures not found: ".concat(o.join(", ")));e=D().apply(void 0,[e].concat(ae(r)))}this.db.loadData(e)}},{key:"loadFactories",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=this._factoryMap||{};this._factoryMap=H()(i,t),Object.keys(t).forEach((function(t){var i=e.schema.toCollectionName(t);e.db.createCollection(i)}))}},{key:"factoryFor",value:function(e){var t=ge(e);if(this._factoryMap&&this._factoryMap[t])return this._factoryMap[t]}},{key:"build",value:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;t>n;n++)i[n-1]=arguments[n];var o=i.filter((function(e){return e&&"string"==typeof e})),s=L()(i,(function(e){return r()(e)})),a=ge(e);this.factorySequences=this.factorySequences||{},this.factorySequences[a]=this.factorySequences[a]+1||0;var c=this.factoryFor(e);if(c){var u=(c=c.extend({})).attrs||{};this._validateTraits(o,c,e);var l=this._mergeExtensions(u,o,s);this._mapAssociationsFromAttributes(e,u,s),this._mapAssociationsFromAttributes(e,l);var h=c.extend(l),d=new h,f=this.factorySequences[a];return d.build(f)}return s}},{key:"buildList",value:function(e,t){we(W()(t),"second argument has to be an integer, you passed: ".concat(J(t)));for(var i=[],n=arguments.length,r=new Array(n>2?n-2:0),o=2;n>o;o++)r[o-2]=arguments[o];for(var s=[e].concat(r),a=0;t>a;a++)i.push(this.build.apply(this,s));return i}},{key:"create",value:function(e){var t=this;we(this._modelOrFactoryExistsForType(e),"You called server.create('".concat(e,"') but no model or factory was found. Make sure you're passing in the singularized version of the model or factory name."));for(var i=arguments.length,n=new Array(i>1?i-1:0),o=1;i>o;o++)n[o-1]=arguments[o];var s,a=n.filter((function(e){return e&&"string"==typeof e})),c=L()(n,(function(e){return r()(e)})),u=L()(n,(function(e){return e&&Array.isArray(e)})),l=this.build.apply(this,[e].concat(ae(a),[c]));if(this.schema&&this.schema[this.schema.toCollectionName(e)]){var h=this.schema[this.schema.toCollectionName(e)];s=h.create(l)}else{var d,f;u?d=u:(f=this.schema?this.schema.toInternalCollectionName(e):"_".concat(this.inflector.pluralize(e)),d=this.db[f]),we(d,"You called server.create('".concat(e,"') but no model or factory was found.")),s=d.insert(l)}var y=this.factoryFor(e);return y&&y.extractAfterCreateCallbacks({traits:a}).forEach((function(e){e(s,t)})),s}},{key:"createList",value:function(e,t){we(this._modelOrFactoryExistsForType(e),"You called server.createList('".concat(e,"') but no model or factory was found. Make sure you're passing in the singularized version of the model or factory name.")),we(W()(t),"second argument has to be an integer, you passed: ".concat(J(t)));for(var i=[],n=this.schema?this.schema.toInternalCollectionName(e):"_".concat(this.inflector.pluralize(e)),r=this.db[n],o=arguments.length,s=new Array(o>2?o-2:0),a=2;o>a;a++)s[a-2]=arguments[a];for(var c=[e].concat(s,[r]),u=0;t>u;u++)i.push(this.create.apply(this,c));return i}},{key:"shutdown",value:function(){"undefined"!=typeof window&&this.pretender.shutdown(),"undefined"!=typeof window&&"test"===this.environment&&(window.server=void 0)}},{key:"resource",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.only,r=i.except,o=i.path;if(e=this.inflector.pluralize(e),o=o||"/".concat(e),r=r||[],(n=n||[]).length>0&&r.length>0)throw"cannot use both :only and :except options";var s={index:{methods:["get"],path:"".concat(o)},show:{methods:["get"],path:"".concat(o,"/:id")},create:{methods:["post"],path:"".concat(o)},update:{methods:["put","patch"],path:"".concat(o,"/:id")},delete:{methods:["del"],path:"".concat(o,"/:id")}},a=Object.keys(s),c=n.length>0&&n||r.length>0&&a.filter((function(e){return-1===r.indexOf(e)}))||a;
1c.forEach((function(i){var n=s[i];n.methods.forEach((function(i){return o===e?t[i](n.path):t[i](n.path,e)}))}))}},{key:"_defineRouteHandlerHelpers",value:function(){var e=this;[["get"],["post"],["put"],["delete","del"],["patch"],["head"],["options"]].forEach((function(t){var i=se(t,2),n=i[0],r=i[1];e[n]=function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),o=1;i>o;o++)r[o-1]=arguments[o];var s=dt(r),a=se(s,3),c=a[0],u=a[1],l=a[2];return e._registerRouteHandler(n,t,c,u,l)},r&&(e[r]=e[n])}))}},{key:"_serialize",value:function(e){return"string"==typeof e?e:JSON.stringify(e)}},{key:"_registerRouteHandler",value:function(e,t,i,n,r){var o=this,s=this._container.create("RouteHandler",{schema:this.schema,verb:e,rawHandler:i,customizedCode:n,options:r,path:t,serializerOrRegistry:this.serializerOrRegistry}),a=this._getFullPath(t);if(this.pretender)return this.pretender[e](a,(function(e){return s.handle(e).then((function(e){var t=se(e,3);return[t[0],t[1],o._serialize(t[2])]}))}),void 0!==r.timing?r.timing:function(){return o.timing})}},{key:"_hasModulesOfType",value:function(e,t){var i=e[t];return!!i&&Object.keys(i).length>0}},{key:"_getFullPath",value:function(e){e="/"===e[0]?e.slice(1):e;var t="",i=this.urlPrefix?this.urlPrefix.trim():"",n="";if(this.urlPrefix&&this.namespace&&("/"===this.namespace[0]&&"/"===this.namespace[this.namespace.length-1]&&(n=this.namespace.substring(0,this.namespace.length-1).substring(1)),"/"===this.namespace[0]&&"/"!==this.namespace[this.namespace.length-1]&&(n=this.namespace.substring(1)),"/"!==this.namespace[0]&&"/"===this.namespace[this.namespace.length-1]&&(n=this.namespace.substring(0,this.namespace.length-1)),"/"!==this.namespace[0]&&"/"!==this.namespace[this.namespace.length-1]&&(n=this.namespace)),this.namespace&&!this.urlPrefix){if("/"===this.namespace[0]&&"/"===this.namespace[this.namespace.length-1]&&(n=this.namespace.substring(0,this.namespace.length-1)),"/"===this.namespace[0]&&"/"!==this.namespace[this.namespace.length-1]&&(n=this.namespace),"/"!==this.namespace[0]&&"/"===this.namespace[this.namespace.length-1]){var r=this.namespace.substring(0,this.namespace.length-1);n="/".concat(r)}"/"!==this.namespace[0]&&"/"!==this.namespace[this.namespace.length-1]&&(n="/".concat(this.namespace))}return this.namespace||(n=""),/^https?:\/\//.test(e)?t+=e:(i.length&&(t+="/"===i[i.length-1]?i:"".concat(i,"/")),"/"!==(t+=n)[t.length-1]&&(t+="/"),/^https?:\/\//.test(t+=e)||(t=(t="/".concat(t)).replace(/\/+/g,"/"))),t}},{key:"_configureDefaultPassthroughs",value:function(){var e=this;ht.forEach((function(t){e.passthrough(t)}))}},{key:"_typeIsPluralForModel",value:function(e){if("boolean"!=typeof at[e]){var t=this._modelOrFactoryExistsForTypeOrCollectionName(e),i=e===this.inflector.pluralize(e),n=this.inflector.singularize(e)===this.inflector.pluralize(e);at[e]=i&&!n&&t}return at[e]}},{key:"_modelOrFactoryExistsForType",value:function(e){var t=this.schema&&this.schema.modelFor(ge(e)),i=this.db[this.schema.toInternalCollectionName(e)];return(t||i)&&!this._typeIsPluralForModel(e)}},{key:"_modelOrFactoryExistsForTypeOrCollectionName",value:function(e){var t=this.schema&&this.schema.modelFor(ge(e)),i=this.db[this.schema.toInternalCollectionName(e)];return t||i}},{key:"_validateTraits",value:function(e,t,i){e.forEach((function(e){if(!t.isTrait(e))throw new Error("'".concat(e,"' trait is not registered in '").concat(i,"' factory"))}))}},{key:"_mergeExtensions",value:function(e,t,i){var n=t.map((function(t){return e[t].extension}));return n.push(i||{}),n.reduce((function(e,t){return H()(e,t)}),{})}},{key:"_mapAssociationsFromAttributes",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Object.keys(t||{}).filter((function(e){return Fe(t[e])})).forEach((function(r){var o=i.schema.modelClassFor(e).associationFor(r);we(o&&o instanceof Me,"You're using the `association` factory helper on the '".concat(r,"' attribute of your ").concat(e," factory, but that attribute is not a `belongsTo` association.")),we(!(o&&o instanceof Me&&o.modelName===e),"You're using the association() helper on your ".concat(e," factory for ").concat(r,", which is a belongsTo self-referential relationship. You can't do this as it will lead to infinite recursion. You can move the helper inside of a trait and use it selectively.")),we(!(o&&o.opts&&o.opts.polymorphic),"You're using the association() helper on your ".concat(e," factory for ").concat(r,", which is a polymorphic relationship. This is not currently supported."));var s=t[r],a="".concat(ge(r),"Id");n[r]||(t[a]=i.create.apply(i,[o.modelName].concat(ae(s.traitsAndOverrides))).id),delete t[r]}))}}]),e}();$e.extend({serializeIds:"always",normalizeIds:!0,keyForModel:function(e){return ke(e)},keyForAttribute:function(e){return ke(e)},keyForRelationship:function(e){return this._container.inflector.pluralize(ke(e))},keyForEmbeddedRelationship:function(e){return ke(e)},keyForRelationshipIds:function(e){return"".concat(ke(this._container.inflector.singularize(e)),"_ids")},keyForForeignKey:function(e){return"".concat(ke(e),"_id")},keyForPolymorphicForeignKeyId:function(e){return"".concat(ke(e),"_id")},keyForPolymorphicForeignKeyType:function(e){return"".concat(ke(e),"_type")},normalize:function(e){var t=this,i=Object.keys(e)[0],n=e[i],r=ge(i),o=this.schema.modelClassFor(r),s=o.belongsToAssociations,a=o.hasManyAssociations,c=Object.keys(s),u=Object.keys(a),l={data:{type:this._container.inflector.pluralize(i),attributes:{}}};n.id&&(l.data.id=n.id);var h={};
1return Object.keys(n).forEach((function(e){if("id"!==e)if(t.normalizeIds)if(c.includes(e)){var i=s[e].modelName;h[_e(e)]={data:{type:i,id:n[e]}}}else if(u.includes(e)){var r=a[e].modelName,o=n[e].map((function(e){return{type:r,id:e}}));h[_e(e)]={data:o}}else l.data.attributes[_e(e)]=n[e];else l.data.attributes[_e(e)]=n[e]})),Object.keys(h).length&&(l.data.relationships=h),l},getCoalescedIds:function(e){return e.queryParams&&e.queryParams.ids}}).extend({serializeIds:"always",keyForModel:function(e){return ge(e)},keyForAttribute:function(e){return ge(e)},keyForRelationship:function(e){return ge(this._container.inflector.pluralize(e))},keyForEmbeddedRelationship:function(e){return ge(e)},keyForRelationshipIds:function(e){return ge(this._container.inflector.pluralize(e))},keyForForeignKey:function(e){return ge(this._container.inflector.singularize(e))},getCoalescedIds:function(e){return e.queryParams&&e.queryParams.ids}})}}]);
2//# sourceMappingURL=vendors-mirage-esm-5d4afc1bb1e85402b5a4.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.