/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{trackAccess as t}from"./accessorSupport/tracking.js";import{SimpleObservable as s}from"./accessorSupport/tracking/SimpleObservable.js";class e{constructor(t){this._observable=new s,this._notifyPending=!1,this._batchDepth=0,this._map=new Map(t)}get size(){return t(this._observable),this._map.size}batch(t){try{this._batchDepth++,t()}finally{this._batchDepth--,this._notifyPending&&0===this._batchDepth&&(this._notifyPending=!1,this._notify())}}clear(){this._map.size>0&&(this._map.clear(),this._notify())}delete(t){const s=this._map.delete(t);return s&&this._notify(),s}entries(){return t(this._observable),this._map.entries()}forEach(s,e){t(this._observable),this._map.forEach((t,i)=>s.call(e,t,i,this),e)}get(s){return t(this._observable),this._map.get(s)}has(s){return t(this._observable),this._map.has(s)}keys(){return t(this._observable),this._map.keys()}set(t,s){return this._map.set(t,s),this._notify(),this}transformValues(t,s=this._map.keys()){this.batch(()=>{for(const e of s){if(!this._map.has(e))continue;const s=this._map.get(e),i=t(s,e);i!==s&&this.set(e,i)}})}values(){return t(this._observable),this._map.values()}[Symbol.iterator](){return t(this._observable),this._map[Symbol.iterator]()}[Symbol.dispose](){this._observable.destroy()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}_notify(){this._batchDepth>0?this._notifyPending=!0:this._observable.notify()}}export{e as default};
