/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{setDeepValue as n}from"./object.js";class o{constructor(o,i={ignoreUnknown:!1,useNumericKeys:!1}){this._jsonToAPI=o,this._options=i,this.apiValues=[],this.jsonValues=[],this._apiToJSON=t(o),this.apiValues=s(this._apiToJSON),this.jsonValues=s(this._jsonToAPI),this.read=n=>this.fromJSON(n),this.write=(o,t,s)=>{const i=this.toJSON(o);void 0!==i&&n(s,i,t)},this.write.isJSONMapWriter=!0}toJSON(n){if(null==n)return null;if(this._apiToJSON.hasOwnProperty(n)){const o=this._apiToJSON[n];return this._options.useNumericKeys?+o:o}return this._options.ignoreUnknown?null:n}fromJSON(n){return null!=n&&this._jsonToAPI.hasOwnProperty(n)?this._jsonToAPI[n]:this._options.ignoreUnknown?void 0:n}}function t(n){const o={};for(const t in n)o[n[t]]=t;return o}function s(n){const o=[];for(const t in n)o.push(t);return o.sort(),o}function i(){return function(n,t){return new o(n,{ignoreUnknown:!0,...t})}}export{o as JSONMap,i as strict};
