chunk-HZRKBTHJ.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {
  2. o
  3. } from "./chunk-SPWQ3AWG.js";
  4. // node_modules/@arcgis/core/core/jsonMap.js
  5. var s = class {
  6. constructor(s2, o3 = { ignoreUnknown: false, useNumericKeys: false }) {
  7. this._jsonToAPI = s2, this._options = o3, this.apiValues = [], this.jsonValues = [], this._apiToJSON = this._invertMap(s2), this.apiValues = this._getKeysSorted(this._apiToJSON), this.jsonValues = this._getKeysSorted(this._jsonToAPI), this.read = (t) => this.fromJSON(t), this.write = (s3, o4, i) => {
  8. const n = this.toJSON(s3);
  9. void 0 !== n && o(i, n, o4);
  10. }, this.write.isJSONMapWriter = true;
  11. }
  12. toJSON(t) {
  13. if (this._apiToJSON.hasOwnProperty(t)) {
  14. const s2 = this._apiToJSON[t];
  15. return this._options.useNumericKeys ? +s2 : s2;
  16. }
  17. return this._options.ignoreUnknown ? void 0 : t;
  18. }
  19. fromJSON(t) {
  20. return this._jsonToAPI.hasOwnProperty(t) ? this._jsonToAPI[t] : this._options.ignoreUnknown ? void 0 : t;
  21. }
  22. _invertMap(t) {
  23. const s2 = {};
  24. for (const o3 in t)
  25. s2[t[o3]] = o3;
  26. return s2;
  27. }
  28. _getKeysSorted(t) {
  29. const s2 = [];
  30. for (const o3 in t)
  31. s2.push(o3);
  32. return s2.sort(), s2;
  33. }
  34. };
  35. function o2() {
  36. return function(t, o3) {
  37. return new s(t, { ignoreUnknown: true, ...o3 });
  38. };
  39. }
  40. export {
  41. s,
  42. o2 as o
  43. };
  44. //# sourceMappingURL=chunk-HZRKBTHJ.js.map