/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../lang","../maybe","./PropertyOrigin"],(function(t,i,e){"use strict";return function(){function r(){this._propertyOriginMap=new Map,this._originStores=new Array(e.OriginIdNum),this._values=new Map,this.multipleOriginsSupported=!0}var s=r.prototype;return s.clone=function(i){const s=new r,n=this._originStores[e.OriginId.DEFAULTS];n&&n.forEach(((i,r)=>{s.set(r,t.clone(i),e.OriginId.DEFAULTS)}));for(let r=e.OriginId.SERVICE;r<e.OriginIdNum;r++){const e=this._originStores[r];e&&e.forEach(((e,n)=>{i&&i.has(n)||s.set(n,t.clone(e),r)}))}return s},s.get=function(t,i){const e=void 0===i?this._values:this._originStores[i];return e?e.get(t):void 0},s.keys=function(t){const i=null==t?this._values:this._originStores[t];return i?[...i.keys()]:[]},s.set=function(t,r,s=e.OriginId.USER){let n=this._originStores[s];if(n||(n=new Map,this._originStores[s]=n),n.set(t,r),!this._values.has(t)||i.assumeNonNull(this._propertyOriginMap.get(t))<=s){const i=this._values.get(t);return this._values.set(t,r),this._propertyOriginMap.set(t,s),i!==r}return!1},s.delete=function(t,i=e.OriginId.USER){const r=this._originStores[i];if(!r)return;const s=r.get(t);if(r.delete(t),this._values.has(t)&&this._propertyOriginMap.get(t)===i){this._values.delete(t);for(let e=i-1;e>=0;e--){const i=this._originStores[e];if(i&&i.has(t)){this._values.set(t,i.get(t)),this._propertyOriginMap.set(t,e);break}}}return s},s.has=function(t,i){const e=void 0===i?this._values:this._originStores[i];return!!e&&e.has(t)},s.revert=function(t,i){for(;i>0&&!this.has(t,i);)--i;const e=this._originStores[i],r=e&&e.get(t),s=this._values.get(t);return this._values.set(t,r),this._propertyOriginMap.set(t,i),s!==r},s.originOf=function(t){return this._propertyOriginMap.get(t)||e.OriginId.DEFAULTS},s.forEach=function(t){this._values.forEach(t)},r}()}));
