(self.webpackChunkRemoteClient = self.webpackChunkRemoteClient || []).push([
  [8166],
  {
    93314: (e, t, i) => {
      'use strict';
      i.d(t, { Z: () => p });
      var n,
        r = i(29768),
        s = i(74673),
        a = i(76506),
        o = i(35197),
        l = i(34250),
        u = (i(91306), i(92143), i(97714)),
        c = i(17533),
        f = i(2906);
      i(21972),
        i(23639),
        i(86656),
        i(22723),
        i(91055),
        i(27794),
        i(6906),
        i(50406),
        i(60991),
        i(81172),
        i(71552),
        i(31450),
        i(40642),
        i(26341);
      let h = (n = class extends s.a {
        constructor(e) {
          super(e), (this.end = null), (this.start = null);
        }
        static get allTime() {
          return d;
        }
        static get empty() {
          return m;
        }
        readEnd(e, t) {
          return null != t.end ? new Date(t.end) : null;
        }
        writeEnd(e, t) {
          t.end = e ? e.getTime() : null;
        }
        get isAllTime() {
          return this.equals(n.allTime);
        }
        get isEmpty() {
          return this.equals(n.empty);
        }
        readStart(e, t) {
          return null != t.start ? new Date(t.start) : null;
        }
        writeStart(e, t) {
          t.start = e ? e.getTime() : null;
        }
        clone() {
          return new n({ end: this.end, start: this.start });
        }
        expandTo(e) {
          if (this.isEmpty || this.isAllTime) return this.clone();
          const t = (0, a.e)(this.start, (t) => (0, o.t)(t, e)),
            i = (0, a.e)(this.end, (t) => (0, o.o)((0, o.t)(t, e), 1, e));
          return new n({ start: t, end: i });
        }
        intersection(e) {
          if (!e) return this.clone();
          if (this.isEmpty || e.isEmpty) return n.empty;
          if (this.isAllTime) return e.clone();
          if (e.isAllTime) return this.clone();
          const t = (0, a.m)(this.start, -1 / 0, (e) => e.getTime()),
            i = (0, a.m)(this.end, 1 / 0, (e) => e.getTime()),
            r = (0, a.m)(e.start, -1 / 0, (e) => e.getTime()),
            s = (0, a.m)(e.end, 1 / 0, (e) => e.getTime());
          let o, l;
          if (
            (r >= t && r <= i ? (o = r) : t >= r && t <= s && (o = t),
            i >= r && i <= s ? (l = i) : s >= t && s <= i && (l = s),
            !isNaN(o) && !isNaN(l))
          ) {
            const e = new n();
            return (
              (e.start = o === -1 / 0 ? null : new Date(o)),
              (e.end = l === 1 / 0 ? null : new Date(l)),
              e
            );
          }
          return n.empty;
        }
        offset(e, t) {
          if (this.isEmpty || this.isAllTime) return this.clone();
          const i = new n(),
            { start: r, end: s } = this;
          return (
            (0, a.i)(r) && (i.start = (0, o.o)(r, e, t)),
            (0, a.i)(s) && (i.end = (0, o.o)(s, e, t)),
            i
          );
        }
        equals(e) {
          if (!e) return !1;
          const t = (0, a.i)(this.start) ? this.start.getTime() : this.start,
            i = (0, a.i)(this.end) ? this.end.getTime() : this.end,
            n = (0, a.i)(e.start) ? e.start.getTime() : e.start,
            r = (0, a.i)(e.end) ? e.end.getTime() : e.end;
          return t === n && i === r;
        }
        union(e) {
          if (!e || e.isEmpty) return this.clone();
          if (this.isEmpty) return e.clone();
          if (this.isAllTime || e.isAllTime) return d.clone();
          const t =
              (0, a.i)(this.start) && (0, a.i)(e.start)
                ? new Date(Math.min(this.start.getTime(), e.start.getTime()))
                : null,
            i =
              (0, a.i)(this.end) && (0, a.i)(e.end)
                ? new Date(Math.max(this.end.getTime(), e.end.getTime()))
                : null;
          return new n({ start: t, end: i });
        }
      });
      (0, r._)(
        [(0, l.Cb)({ type: Date, json: { write: { allowNull: !0 } } })],
        h.prototype,
        'end',
        void 0,
      ),
        (0, r._)([(0, u.r)('end')], h.prototype, 'readEnd', null),
        (0, r._)([(0, f.w)('end')], h.prototype, 'writeEnd', null),
        (0, r._)([(0, l.Cb)({ readOnly: !0, json: { read: !1 } })], h.prototype, 'isAllTime', null),
        (0, r._)([(0, l.Cb)({ readOnly: !0, json: { read: !1 } })], h.prototype, 'isEmpty', null),
        (0, r._)(
          [(0, l.Cb)({ type: Date, json: { write: { allowNull: !0 } } })],
          h.prototype,
          'start',
          void 0,
        ),
        (0, r._)([(0, u.r)('start')], h.prototype, 'readStart', null),
        (0, r._)([(0, f.w)('start')], h.prototype, 'writeStart', null),
        (h = n = (0, r._)([(0, c.j)('esri.TimeExtent')], h));
      const d = new h(),
        m = new h({ start: void 0, end: void 0 }),
        p = h;
    },
    89241: (e, t, i) => {
      'use strict';
      i.d(t, { L: () => r });
      var n = i(91700);
      class r {
        constructor(e, t) {
          (this._storage = new n.M()),
            (this._storage.maxSize = e),
            t && this._storage.registerRemoveFunc('', t);
        }
        put(e, t, i) {
          this._storage.put(e, t, i, 1);
        }
        pop(e) {
          return this._storage.pop(e);
        }
        get(e) {
          return this._storage.get(e);
        }
        clear() {
          this._storage.clearAll();
        }
        destroy() {
          this._storage.destroy();
        }
        get maxSize() {
          return this._storage.maxSize;
        }
        set maxSize(e) {
          this._storage.maxSize = e;
        }
      }
    },
    35197: (e, t, i) => {
      'use strict';
      i.d(t, { c: () => o, o: () => s, t: () => a }), i(76506);
      const n = {
          milliseconds: 1,
          seconds: 1e3,
          minutes: 6e4,
          hours: 36e5,
          days: 864e5,
          weeks: 6048e5,
          months: 26784e5,
          years: 31536e6,
          decades: 31536e7,
          centuries: 31536e8,
        },
        r = {
          milliseconds: { getter: 'getMilliseconds', setter: 'setMilliseconds', multiplier: 1 },
          seconds: { getter: 'getSeconds', setter: 'setSeconds', multiplier: 1 },
          minutes: { getter: 'getMinutes', setter: 'setMinutes', multiplier: 1 },
          hours: { getter: 'getHours', setter: 'setHours', multiplier: 1 },
          days: { getter: 'getDate', setter: 'setDate', multiplier: 1 },
          weeks: { getter: 'getDate', setter: 'setDate', multiplier: 7 },
          months: { getter: 'getMonth', setter: 'setMonth', multiplier: 1 },
          years: { getter: 'getFullYear', setter: 'setFullYear', multiplier: 1 },
          decades: { getter: 'getFullYear', setter: 'setFullYear', multiplier: 10 },
          centuries: { getter: 'getFullYear', setter: 'setFullYear', multiplier: 100 },
        };
      function s(e, t, i) {
        const n = new Date(e.getTime());
        if (t && i) {
          const e = r[i],
            { getter: s, setter: a, multiplier: o } = e;
          n[a](n[s]() + t * o);
        }
        return n;
      }
      function a(e, t) {
        switch (t) {
          case 'milliseconds':
            return new Date(e.getTime());
          case 'seconds':
            return new Date(
              e.getFullYear(),
              e.getMonth(),
              e.getDate(),
              e.getHours(),
              e.getMinutes(),
              e.getSeconds(),
            );
          case 'minutes':
            return new Date(
              e.getFullYear(),
              e.getMonth(),
              e.getDate(),
              e.getHours(),
              e.getMinutes(),
            );
          case 'hours':
            return new Date(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours());
          case 'days':
            return new Date(e.getFullYear(), e.getMonth(), e.getDate());
          case 'weeks':
            return new Date(e.getFullYear(), e.getMonth(), e.getDate() - e.getDay());
          case 'months':
            return new Date(e.getFullYear(), e.getMonth(), 1);
          case 'years':
            return new Date(e.getFullYear(), 0, 1);
          case 'decades':
            return new Date(e.getFullYear() - (e.getFullYear() % 10), 0, 1);
          case 'centuries':
            return new Date(e.getFullYear() - (e.getFullYear() % 100), 0, 1);
          default:
            return new Date();
        }
      }
      function o(e, t, i) {
        return 0 === e ? 0 : (e * n[t]) / n[i];
      }
    },
    68166: (e, t, i) => {
      'use strict';
      i.r(t), i.d(t, { default: () => ft });
      var n = i(29768),
        r = i(86748),
        s = i(88678),
        a = i(60991),
        o = i(76506),
        l = i(54179),
        u = i(50406),
        c = i(34250),
        f = i(91306),
        h = i(92143),
        d = i(59465),
        m = i(97714),
        p = i(17533),
        y = i(41617),
        g = i(11118),
        x = i(8547),
        w = (i(74569), i(82058)),
        v = i(63136),
        b = i(60947),
        I = i(21132),
        C = i(43022),
        _ = i(66827),
        T = i(13074),
        R = i(43352),
        S = i(1030),
        M = i(40558),
        k = i(21801),
        F = i(74673),
        P = i(20543),
        D = i(72246),
        O = i(53785),
        B = i(72334),
        z = i(35132),
        N = i(91597);
      const E = function (e, t) {
          const i = (e.isWGS84 || e.isWebMercator) && (t.isWGS84 || t.isWebMercator);
          return !(e.equals(t) || i);
        },
        A = {
          3395: 20037508.342789244,
          3410: 17334193.943686873,
          3832: 3339584.723798206,
          3857: 20037508.342788905,
          3975: 17367530.445161372,
          4087: 20037508.342789244,
          4088: 20015108.787169147,
          6933: 17367530.445161372,
          8858: 7396237.374497803,
          8859: 2465412.4581659334,
          32662: 20037508.342789244,
          53001: 20015086.79602057,
          53002: 10007543.39801029,
          53003: 20015086.79602057,
          53004: 20015086.79602057,
          53016: 14152803.599503474,
          53017: 17333573.624304302,
          53025: 7276828.3848298555,
          53031: 10384677.558821043,
          53034: 20015086.79602057,
          53036: 7389443.187332862,
          53037: 2463147.729110953,
          53079: 20015114.352186374,
          53080: 20015114.352186374,
          54001: 20037508.342789244,
          54002: 10018754.171394624,
          54003: 20037508.342789244,
          54004: 20037508.342789244,
          54016: 14168658.027268292,
          54017: 17367530.44516137,
          54025: 7311399.09166516,
          54031: 10396310.810074743,
          54034: 20037508.342789244,
          54050: 808820.9223376509,
          54053: 1920897.3915568967,
          54079: 20037508.342789244,
          54080: 20037508.342789244,
          54099: 13524439.768288724,
          54100: 20037508.342789244,
          54101: 20037508.342789244,
          102038: 4297258.582585486,
          102299: 5013965.117483125,
        };
      function L(e, t, i, n = null) {
        if (e.spatialReference.equals(t)) return e;
        const r = E(e.spatialReference, t);
        if (r && !(0, B.kR)())
          throw new a.Z(
            'rasterprojectionhelper-projectResolution',
            'projection engine is not loaded',
          );
        const s = i.center,
          o = new k.Z({
            xmin: s.x - e.x / 2,
            xmax: s.x + e.x / 2,
            ymin: s.y - e.y / 2,
            ymax: s.y + e.y / 2,
            spatialReference: e.spatialReference,
          }),
          l = r ? (0, B.iV)(o, t, n) : (0, z.iV)(o, t);
        return null == l ? null : { x: l.xmax - l.xmin, y: l.ymax - l.ymin };
      }
      function H(e, t = 0.01) {
        return (0, O.a)(e) ? t / (0, O.a)(e) : 0;
      }
      function Z(e, t, i = null, n = !0) {
        const r = e.spatialReference;
        if (r.equals(t)) return e;
        const s = E(r, t);
        if (s && !(0, B.kR)())
          throw new a.Z(
            'rasterprojectionhelper-projectResolution',
            'projection engine is not loaded',
          );
        const o = s ? (0, B.iV)(e, t, i) : (0, z.iV)(e, t);
        if (o && n && t.isGeographic) {
          const [t, i] = G(r, !0),
            n = H(r);
          n &&
            null != t &&
            null != i &&
            (Math.abs(e.x - t) < n && Math.abs(180 - o.x) < 5e-4
              ? (o.x -= 360)
              : Math.abs(e.x - i) < n && Math.abs(180 + o.x) < 5e-4 && (o.x += 360));
        }
        return o;
      }
      function J(e) {
        const t = W(e[0].spatialReference);
        if (e.length < 2 || !(0, o.i)(t)) return e[0];
        let { xmin: i, xmax: n, ymin: r, ymax: s } = e[0];
        for (let i = 1; i < e.length; i++) {
          const a = e[i];
          (n = a.xmax + t * i), (r = Math.min(r, a.ymin)), (s = Math.max(s, a.ymax));
        }
        return new k.Z({
          xmin: i,
          xmax: n,
          ymin: r,
          ymax: s,
          spatialReference: e[0].spatialReference,
        });
      }
      function j(e, t, i = null, n = !0) {
        if (e.spatialReference.equals(t)) return e;
        const r = Y(e),
          s = W(e.spatialReference, !0);
        return (0, o.i)(s) && 0 !== r
          ? J(
              e
                .clone()
                .normalize()
                .map((e) => q(e, t, i, n)),
            )
          : q(e, t, i, n);
      }
      function q(e, t, i = null, n = !0) {
        const r = e.spatialReference;
        if (r.equals(t)) return e;
        const s = E(r, t);
        if (s && !(0, B.kR)())
          throw new a.Z('rasterprojectionhelper-projectExtent', 'projection engine is not loaded');
        const o = s ? (0, B.iV)(e, t, i) : (0, z.iV)(e, t);
        let [l, u] = G(r, !0);
        if (o && n && r.isWebMercator && t.isGeographic && null != l && null != u) {
          const n = 0.001,
            s = 1e3;
          if (
            Math.abs(e.xmin - l) < n &&
            Math.abs(u - e.xmax) > s &&
            Math.abs(180 - o.xmax) < 5e-4
          ) {
            o.xmin = -180;
            const n = [];
            n.push(new N.Z(e.xmax, e.ymin, r)),
              n.push(new N.Z(e.xmax, (e.ymin + e.ymax) / 2, r)),
              n.push(new N.Z(e.xmax, e.ymax, r));
            const s = n
              .map((e) => Z(e, t, i))
              .filter((e) => !isNaN(null == e ? void 0 : e.x))
              .map((e) => e.x);
            o.xmax = Math.max.apply(null, s);
          }
          if (
            Math.abs(e.xmax - u) < n &&
            Math.abs(l - e.xmin) > s &&
            Math.abs(180 + o.xmin) < 5e-4
          ) {
            o.xmax = 180;
            const n = [];
            n.push(new N.Z(e.xmin, e.ymin, r)),
              n.push(new N.Z(e.xmin, (e.ymin + e.ymax) / 2, r)),
              n.push(new N.Z(e.xmin, e.ymax, r));
            const s = n
              .map((e) => Z(e, t, i))
              .filter((e) => !isNaN(null == e ? void 0 : e.x))
              .map((e) => e.x);
            o.xmin = Math.min.apply(null, s);
          }
        }
        [l, u] = G(t, !0);
        const c = H(t);
        return (
          c &&
            null != l &&
            null != u &&
            (Math.abs(o.xmin - l) < c && (o.xmin = l), Math.abs(o.xmax - u) < c && (o.xmax = u)),
          o
        );
      }
      function W(e, t = !1) {
        const i = t ? 20037508.342787 : 20037508.342788905;
        return e.isWebMercator ? 2 * i : e.wkid && e.isGeographic ? 360 : 2 * A[e.wkid] || null;
      }
      function G(e, t = !1) {
        const i = [],
          n = W(e, t);
        return (0, o.i)(n) && (i.push(-n / 2), i.push(n / 2)), i;
      }
      function U(e, t, i, n) {
        let r = (e - t) / i;
        return r - Math.floor(r) != 0 ? (r = Math.floor(r)) : n && (r -= 1), r;
      }
      function Y(e, t = !1) {
        const i = W(e.spatialReference);
        if (!(0, o.i)(i)) return 0;
        const n = t ? 0 : -i / 2;
        return U(e.xmax, n, i, !0) - U(e.xmin, n, i, !1);
      }
      function V(e, t, i, n = null, r = null, s = !1, l = [32, 32]) {
        if (E(e.spatialReference, t.spatialReference) && !(0, B.kR)())
          throw new a.Z(
            'rasterprojectionhelper-projectResolution',
            'projection engine is not loaded',
          );
        if (!(e && t && i)) return null;
        const { xmin: u, ymin: c, xmax: f, ymax: h } = e,
          d = e.spatialReference,
          m = t.spatialReference,
          p = W(m);
        s = s || 'gcs-shift' === (null == r ? void 0 : r.type);
        const y = { x: l[0] * i.x, y: l[1] * i.y },
          g = {
            cols: Math.ceil((f - u) / y.x - 0.1) + 1,
            rows: Math.ceil((h - c) / y.y - 0.1) + 1,
          },
          x = y.x,
          w = y.y,
          v = [];
        let b,
          I = !1;
        for (let e = 0; e < g.cols; e++) {
          const i = [];
          for (let a = 0; a < g.rows; a++) {
            let l = Z(new N.Z({ x: u + x * e, y: h - w * a, spatialReference: d }), m, n);
            r && (l = r.inverseTransform(l)),
              i.push(l),
              e > 0 && s && l && b[a] && (0, o.i)(p) && l.x < b[a].x && (l.x += p),
              l
                ? (v.push((l.x - t.xmin) / (t.xmax - t.xmin)),
                  v.push((t.ymax - l.y) / (t.ymax - t.ymin)))
                : (v.push(NaN), v.push(NaN), (I = !0));
          }
          b = i;
        }
        const C = (function (e, t) {
            const i = (e[0] + e[4] + e[4 * t.cols] + e[4 * t.cols + 4]) / 4,
              n = (e[1] + e[5] + e[4 * t.rows + 1] + e[4 * t.rows + 5]) / 4;
            return [Math.abs(i - e[2 * t.rows + 2]), Math.abs(n - e[2 * t.rows + 3])];
          })(v, g),
          _ = new Float32Array((g.cols - 1) * (g.rows - 1) * 2 * 6),
          T = new Float32Array([-0, -1, 1, -1, 1, -0, 1, -0, -0]),
          R = new Float32Array([-1, 1, 0, 0, -1, 1, 1, 0, 0]);
        for (let e = 0; e < g.cols - 1; e++) {
          for (let t = 0; t < g.rows - 1; t++) {
            let i = e * g.rows * 2 + 2 * t;
            const n = v[i],
              r = v[i + 1],
              s = v[i + 2],
              a = v[i + 3];
            i += 2 * g.rows;
            const o = v[i],
              l = v[i + 1],
              u = v[i + 2],
              c = v[i + 3];
            let f = 0,
              h = 12 * (t * (g.cols - 1) + e);
            for (let e = 0; e < 3; e++) _[h++] = T[f++] * n + T[f++] * s + T[f++] * u;
            f = 0;
            for (let e = 0; e < 3; e++) _[h++] = T[f++] * r + T[f++] * a + T[f++] * c;
            f = 0;
            for (let e = 0; e < 3; e++) _[h++] = R[f++] * n + R[f++] * o + R[f++] * u;
            f = 0;
            for (let e = 0; e < 3; e++) _[h++] = R[f++] * r + R[f++] * l + R[f++] * c;
          }
          if (I) for (let e = 0; e < _.length; e++) isNaN(_[e]) && (_[e] = -1);
        }
        return {
          offsets: v,
          error: C,
          coefficients: _,
          spacing: l,
          size: [g.cols - 1, g.rows - 1],
        };
      }
      function $(e) {
        const t = e.clone().normalize();
        return 1 === t.length ? t[0] : J(t);
      }
      function X(e, t, i) {
        const { storageInfo: n, pixelSize: r } = t;
        let s,
          a = !1;
        const { pyramidResolutions: l } = n;
        if ((0, o.i)(l) && l.length) {
          const n = (e.x + e.y) / 2,
            o = l[l.length - 1],
            u = (o.x + o.y) / 2,
            c = (r.x + r.y) / 2;
          if (n <= c) s = 0;
          else if (n >= u) (s = l.length), (a = n / u > 8);
          else {
            let e,
              t = c;
            for (let r = 1; r <= l.length; r++) {
              if (((e = (l[r - 1].x + l[r - 1].y) / 2), n <= e)) {
                n === e
                  ? (s = r)
                  : 'down' === i
                  ? ((s = r - 1), (a = n / t > 8))
                  : (s = 'up' === i || n - t > e - n || n / t > 2 ? r : r - 1);
                break;
              }
              t = e;
            }
          }
          const f = 0 === s ? r : l[s - 1];
          return {
            pyramidLevel: s,
            pyramidResolution: new N.Z({ x: f.x, y: f.y, spatialReference: t.spatialReference }),
            excessiveReading: a,
          };
        }
        const u = Math.log(e.x / r.x) / Math.LN2,
          c = Math.log(e.y / r.y) / Math.LN2,
          f = t.storageInfo.maximumPyramidLevel || 0;
        (s =
          'down' === i
            ? Math.floor(Math.min(u, c))
            : 'up' === i
            ? Math.ceil(Math.max(u, c))
            : Math.round((u + c) / 2)),
          s < 0 ? (s = 0) : s > f && ((a = s > f + 3), (s = f));
        const h = 2 ** s;
        return {
          pyramidLevel: s,
          pyramidResolution: new N.Z({
            x: h * t.nativePixelSize.x,
            y: h * t.nativePixelSize.y,
            spatialReference: t.spatialReference,
          }),
          excessiveReading: a,
        };
      }
      const K = new Map(),
        Q = new (class {
          constructor(e = 15e3, t = 5e3) {
            (this._timer = null),
              (this._cachedBlocks = new Map()),
              (this._size = -1),
              (this._duration = e),
              (this._interval = Math.min(e, t));
          }
          decreaseRefCount(e, t) {
            const i = e + '/' + t,
              n = this._cachedBlocks;
            if (n.has(i)) {
              const e = n.get(i);
              return (
                e.refCount--,
                e.refCount <= 0 && (n.delete(i), e.controller && e.controller.abort()),
                e.refCount
              );
            }
            return 0;
          }
          getBlock(e, t) {
            const i = e + '/' + t,
              n = this._cachedBlocks;
            if (n.has(i)) {
              const e = n.get(i);
              return (e.ts = Date.now()), e.refCount++, n.delete(i), n.set(i, e), e.block;
            }
            return null;
          }
          putBlock(e, t, i, n = null) {
            const r = this._cachedBlocks,
              s = e + '/' + t;
            if (r.has(s)) {
              const e = r.get(s);
              (e.ts = Date.now()), e.refCount++;
            } else r.set(s, { block: i, ts: Date.now(), refCount: 1, controller: n });
            this.trim(), this.updateTimer();
          }
          deleteBlock(e, t) {
            const i = this._cachedBlocks,
              n = e + '/' + t;
            i.has(n) && i.delete(n);
          }
          updateMaxSize(e) {
            (this._size = e), this.trim();
          }
          empty() {
            this._cachedBlocks.clear(), this.clearTimer();
          }
          getCurrentSize() {
            return this._cachedBlocks.size;
          }
          updateTimer() {
            if (null != this._timer) return;
            const e = this._cachedBlocks;
            this._timer = setInterval(() => {
              const t = Array.from(e),
                i = Date.now();
              for (let n = 0; n < t.length && t[n][1].ts <= i - this._duration; n++)
                e.delete(t[n][0]);
              0 === e.size && this.clearTimer();
            }, this._interval);
          }
          trim() {
            const e = this._cachedBlocks;
            if (-1 === this._size || this._size >= e.size) return;
            const t = Array.from(e);
            for (let i = 0; i < t.length - this._size; i++) e.delete(t[i][0]);
          }
          clearTimer() {
            null != this._timer && (clearInterval(this._timer), (this._timer = null));
          }
        })();
      function ee(e, t) {
        return null == t ? e : `${e}?sliceId=${t}`;
      }
      function te(e, t, i) {
        if (!K.has(e)) return null == t ? Q.decreaseRefCount(e, i) : 0;
        const n = K.get(e);
        if (null == n[t]) return Q.decreaseRefCount(e, i);
        const r = n[t].cache;
        if (r.has(i)) {
          const e = r.get(i);
          if ((e.refCount--, 0 === e.refCount)) {
            r.delete(i);
            for (let e = 0; e < n.length; e++) n[e] && n[e].cache.has(i) && n[e].cache.delete(i);
            e.controller && e.controller.abort();
          }
          return e.refCount;
        }
        return 0;
      }
      function ie(e, t, i) {
        if (!K.has(e)) return null == t ? Q.getBlock(e, i) : null;
        const n = K.get(e);
        if (null == n[t]) {
          for (let e = 0; e < n.length; e++)
            if (n[e] && n[e].cache.has(i)) {
              const t = n[e].cache.get(i);
              return t.refCount++, t.block;
            }
          return Q.getBlock(e, i);
        }
        const r = n[t].cache;
        if (r.has(i)) {
          const e = r.get(i);
          return e.refCount++, e.block;
        }
        for (let e = 0; e < n.length; e++)
          if (e !== t && n[e] && n[e] && n[e].cache.has(i)) {
            const t = n[e].cache.get(i);
            return t.refCount++, r.set(i, t), t.block;
          }
        return null;
      }
      function ne(e, t, i, n, r = null) {
        if (!K.has(e)) return void (null == t && Q.putBlock(e, i, n, r));
        const s = K.get(e);
        if (null == s[t]) return void Q.putBlock(e, i, n, r);
        const a = { refCount: 1, block: n, isResolved: !1, isRejected: !1, controller: r };
        n.then(() => (a.isResolved = !0)).catch(() => (a.isRejected = !0)), s[t].cache.set(i, a);
      }
      function re(e, t, i) {
        if (!K.has(e)) return void (null == t && Q.deleteBlock(e, i));
        const n = K.get(e);
        null != n[t] ? n[t].cache.delete(i) : Q.deleteBlock(e, i);
      }
      var se = i(98264);
      const ae = h.L.getLogger('esri.layers.mixins.ImageryTileMixin'),
        oe = (e) => {
          let t = class extends e {
            constructor() {
              super(...arguments),
                (this._rasterJobHandler = { instance: null, refCount: 0, connectionPromise: null }),
                (this.bandIds = null),
                (this.copyright = null),
                (this.fullExtent = null),
                (this.interpolation = 'nearest'),
                (this.raster = null),
                (this.rasterInfo = null),
                (this.sourceJSON = null),
                (this.spatialReference = null),
                (this.tileInfo = null),
                (this.symbolizer = null);
            }
            set multidimensionalDefinition(e) {
              this.raster && (this._sliceId = this.raster.getSliceIndex(e)),
                this._set('multidimensionalDefinition', e);
            }
            set url(e) {
              this._set('url', (0, I.s)(e, ae));
            }
            set renderer(e) {
              this._set('renderer', e), this.updateRenderer();
            }
            async updateRenderer() {
              if (!this.loaded) return;
              if (JSON.stringify(this._cachedRendererJson) === JSON.stringify(this.renderer))
                return;
              const e = this._rasterJobHandler.instance;
              e &&
                ((this.symbolizer.rendererJSON = (0, S.n)(this.renderer.toJSON())),
                this.symbolizer.bind(),
                await e.updateSymbolizer(this.symbolizer),
                (this._cachedRendererJson = this.renderer.toJSON()));
            }
            async applyRenderer(e, t) {
              const i = e && e.pixelBlock;
              if (!(i && i.pixels && i.pixels.length > 0)) return null;
              let n;
              this.updateRenderer();
              const r = this._rasterJobHandler.instance,
                { bandIds: s } = this;
              return (
                (n = r
                  ? await r.symbolize({ ...e, simpleStretchParams: t, bandIds: s })
                  : this.symbolizer.symbolize({ ...e, simpleStretchParams: t, bandIds: s })),
                n
              );
            }
            getTileUrl(e, t, i) {
              return 'RasterTileServer' === this.raster.datasetFormat
                ? `${this.url}/tile/${e}/${t}/${i}`
                : '';
            }
            getCompatibleTileInfo(e, t, i = !1) {
              if (!this.loaded) return null;
              if (i && e.equals(this.spatialReference)) return this.tileInfo;
              const n = (0, b.g)(e);
              return R.Z.create({
                size: 256,
                spatialReference: e,
                origin: n ? { x: n.origin[0], y: n.origin[1] } : { x: t.xmin, y: t.ymax },
              });
            }
            getCompatibleFullExtent(e) {
              return this.loaded
                ? ((this._compatibleFullExtent &&
                    this._compatibleFullExtent.spatialReference.equals(e)) ||
                    (this._compatibleFullExtent = this.raster.computeExtent(e)),
                  this._compatibleFullExtent)
                : null;
            }
            async fetchTile(e, t, i, n = {}) {
              if (n.requestAsImageElement) {
                const r = this.getTileUrl(e, t, i);
                return (0, w.default)(r, {
                  responseType: 'image',
                  query: {
                    sliceId: this._sliceId,
                    _ts: n.timestamp,
                    ...this.raster.ioConfig.customFetchParameters,
                  },
                  signal: n.signal,
                }).then((e) => e.data);
              }
              await this._initJobHandler();
              const r = 'raster-shaded-relief' === this.renderer.type ? { cols: 1, rows: 1 } : null;
              if (this.multidimensionalDefinition) {
                const e = this._sliceId;
                n = {
                  multidimensionalDefinition: this.multidimensionalDefinition,
                  sliceId: e,
                  buffer: r,
                  ...n,
                };
              }
              return this.raster.fetchTile(e, t, i, n);
            }
            async fetchPixels(e, t, i, n) {
              if ((await this._initJobHandler(), this.multidimensionalDefinition)) {
                const e = this._sliceId;
                n = {
                  multidimensionalDefinition: this.multidimensionalDefinition,
                  sliceId: e,
                  ...n,
                };
              }
              return this.raster.fetchPixels(e, t, i, n);
            }
            identify(e, t = {}) {
              return (
                this.multidimensionalDefinition &&
                  !t.multidimensionalDefinition &&
                  (t = { ...t, multidimensionalDefinition: this.multidimensionalDefinition }),
                this.raster.identify(e, t)
              );
            }
            increaseRasterJobHandlerUsage() {
              this._rasterJobHandler.refCount++;
            }
            decreaseRasterJobHandlerUsage() {
              this._rasterJobHandler.refCount--,
                this._rasterJobHandler.refCount <= 0 && this._shutdownJobHandler();
            }
            hasStandardTime() {
              var e;
              const t = this.rasterInfo.multidimensionalInfo;
              if (!(0, o.i)(t) || 'standard-time' !== this.rasterInfo.dataType) return !1;
              const i = null == (e = this.multidimensionalDefinition[0]) ? void 0 : e.variableName;
              return t.variables.some(
                (e) => e.name === i && e.dimensions.some((e) => 'StdTime' === e.name),
              );
            }
            getStandardTimeValue(e) {
              return new Date(24 * (e - 25569) * 3600 * 1e3).toString();
            }
            _configDefaultSettings() {
              this._configDefaultInterpolation(),
                this._configDefaultSlice(),
                this._configDefaultRenderer();
            }
            _initJobHandler() {
              if (null != this._rasterJobHandler.connectionPromise)
                return this._rasterJobHandler.connectionPromise;
              const e = new T.R();
              return (
                (this._rasterJobHandler.connectionPromise = e
                  .initialize()
                  .then(() => {
                    (this._rasterJobHandler.instance = e),
                      (this.raster.rasterJobHandler = e),
                      this.renderer && this.updateRenderer();
                  })
                  .catch(() => null)),
                this._rasterJobHandler.connectionPromise
              );
            }
            _shutdownJobHandler() {
              this._rasterJobHandler.instance && this._rasterJobHandler.instance.destroy(),
                (this._rasterJobHandler.instance = null),
                (this._rasterJobHandler.connectionPromise = null),
                (this._rasterJobHandler.refCount = 0),
                (this.raster.rasterJobHandler = null);
            }
            _configDefaultInterpolation() {
              if (null == this.interpolation) {
                var e;
                const t = (0, S.b)(
                  this.rasterInfo,
                  this.raster.tileType,
                  null == (e = this.sourceJSON) ? void 0 : e.defaultResamplingMethod,
                );
                this._set('interpolation', t);
              }
            }
            _configDefaultSlice() {
              const { multidimensionalInfo: e } = this.raster.rasterInfo;
              if ((0, o.i)(e)) {
                if (!this.multidimensionalDefinition) {
                  const t = e.variables[0],
                    i = [];
                  t.dimensions.forEach((e) => {
                    i.push(
                      new _.Z({
                        variableName: t.name,
                        dimensionName: e.name,
                        values: e.hasRegularIntervals ? e.extent[0] : e.values[0],
                        isSlice: !0,
                      }),
                    );
                  }),
                    (this.multidimensionalDefinition = i);
                }
                this._sliceId = this.raster.getSliceIndex(this.multidimensionalDefinition);
              }
            }
            _configDefaultRenderer() {
              const e = this.raster.rasterInfo;
              var t, i;
              this.bandIds || (this.bandIds = (0, S.a)(e)),
                this.renderer ||
                  (this.renderer = (0, S.c)(e, {
                    bandIds: this.bandIds,
                    variableName:
                      null == (t = this.multidimensionalDefinition) || null == (i = t[0])
                        ? void 0
                        : i.variableName,
                  })),
                this.symbolizer
                  ? ((this.symbolizer.rendererJSON = (0, S.n)(this.renderer.toJSON())),
                    (this.symbolizer.rasterInfo = e))
                  : (this.symbolizer = new M.R({
                      rendererJSON: this.renderer.toJSON(),
                      rasterInfo: e,
                    })),
                this.symbolizer.bind() ||
                  ae.warn(
                    'imagery-tile-mixin',
                    'The given renderer is not supported by the layer.',
                  );
            }
          };
          return (
            (0, n._)([(0, c.Cb)()], t.prototype, '_cachedRendererJson', void 0),
            (0, n._)([(0, c.Cb)()], t.prototype, '_sliceId', void 0),
            (0, n._)([(0, c.Cb)()], t.prototype, '_compatibleFullExtent', void 0),
            (0, n._)([(0, c.Cb)()], t.prototype, '_rasterJobHandler', void 0),
            (0, n._)([(0, c.Cb)()], t.prototype, 'bandIds', void 0),
            (0, n._)([(0, c.Cb)()], t.prototype, 'copyright', void 0),
            (0, n._)(
              [(0, c.Cb)({ type: k.Z }), (0, v.B)('rasterInfo.extent')],
              t.prototype,
              'fullExtent',
              void 0,
            ),
            (0, n._)([(0, c.Cb)()], t.prototype, 'interpolation', void 0),
            (0, n._)([(0, c.Cb)()], t.prototype, 'ioConfig', void 0),
            (0, n._)([(0, c.Cb)({ type: [_.Z] })], t.prototype, 'multidimensionalDefinition', null),
            (0, n._)([(0, c.Cb)()], t.prototype, 'raster', void 0),
            (0, n._)(
              [(0, c.Cb)({ readOnly: !0 }), (0, v.B)('raster.rasterInfo')],
              t.prototype,
              'rasterInfo',
              void 0,
            ),
            (0, n._)([(0, c.Cb)()], t.prototype, 'sourceJSON', void 0),
            (0, n._)(
              [(0, c.Cb)({ type: b.Z }), (0, v.B)('rasterInfo.spatialReference')],
              t.prototype,
              'spatialReference',
              void 0,
            ),
            (0, n._)(
              [(0, c.Cb)({ type: R.Z }), (0, v.B)('rasterInfo.storageInfo.tileInfo')],
              t.prototype,
              'tileInfo',
              void 0,
            ),
            (0, n._)([(0, c.Cb)(C.u)], t.prototype, 'url', null),
            (0, n._)([(0, c.Cb)({ types: s.dr })], t.prototype, 'renderer', null),
            (0, n._)([(0, c.Cb)()], t.prototype, 'symbolizer', void 0),
            (t = (0, n._)([(0, p.j)('esri.layers.ImageryTileMixin')], t)),
            t
          );
        };
      let le = class extends (0, P.a)(F.a) {
        constructor() {
          super(...arguments),
            (this.rasterJobHandler = null),
            (this.datasetName = null),
            (this.datasetFormat = null),
            (this.rasterInfo = null),
            (this.ioConfig = { sampling: 'closest' });
        }
        async init() {
          const e = (async function () {
            if ((0, B.kR)() || !(0, B.Gb)()) return null;
            await (0, B.zD)();
          })();
          this.addResolvingPromise(e), await this.when();
        }
        normalizeCtorArgs(e) {
          return (
            e &&
              e.ioConfig &&
              (e = {
                ...e,
                ioConfig: {
                  resolution: null,
                  bandIds: null,
                  sampling: 'closest',
                  tileInfo: R.Z.create(),
                  ...e.ioConfig,
                },
              }),
            e
          );
        }
        set url(e) {
          this._set('url', (0, I.s)(e, h.L.getLogger(this.declaredClass)));
        }
        async open(e) {
          throw new a.Z('BaseRaster:open-not-implemented', 'open() is not implemented');
        }
        async fetchTile(e, t, i, n = {}) {
          var r;
          const { tileInfo: s } = n,
            a = s.lodAt(e),
            l = this.getTileExtent(
              { x: a.resolution, y: a.resolution },
              t,
              i,
              s.origin,
              s.spatialReference,
              s.size,
            );
          return (
            null != (r = n.multidimensionalDefinition) &&
              r.length &&
              (0, o.i)(this.rasterInfo.multidimensionalInfo) &&
              null == n.sliceId &&
              (n = { ...n, sliceId: this.getSliceIndex(n.multidimensionalDefinition) || 0 }),
            this.fetchPixels(l, s.size[0], s.size[1], n)
          );
        }
        async identify(e, t = {}) {
          const { spatialReference: i, extent: n } = this.rasterInfo,
            { datumTransformation: r } = t;
          let s = Z(e, i, r);
          if (!n.intersects(s)) return { location: s, value: null };
          if ((0, o.i)(this.rasterInfo.transform)) {
            const e = this.rasterInfo.transform.inverseTransform(s);
            if (!this.rasterInfo.nativeExtent.intersects(e)) return { location: e, value: null };
            s = e;
          }
          let a = 0;
          if (t.srcResolution)
            a = X(t.srcResolution, this.rasterInfo, this.ioConfig.sampling).pyramidLevel;
          else if (((a = await this.computeBestPyramidLevelForLocation(e, t)), null == a))
            return { location: s, value: null };
          const l = this.identifyPixelLocation(s, a, null);
          if (null === l) return { location: s, value: null };
          const { row: u, col: c, rowOffset: f, colOffset: h } = l,
            d = ee(this.url, t.sliceId),
            m = `${a}/${u}/${c}`;
          let p = ie(d, null, m);
          (0, o.i)(p) || ((p = this.fetchRawTile(a, u, c, t)), ne(d, null, m, p));
          const y = await p;
          if (!(y && y.pixels && y.pixels.length > 0)) return { location: s, value: null };
          const g = f * this.rasterInfo.storageInfo.blockHeight + h;
          return {
            location: s,
            value: !y.mask || y.mask[g] ? y.pixels.map((e) => e[g]) : null,
            pyramidLevel: a,
          };
        }
        async fetchPixels(e, t, i, n = {}) {
          const r = Y((e = $(e))),
            s = this.rasterInfo.spatialReference,
            a = !e.spatialReference.equals(s),
            { datumTransformation: l } = n,
            u = new N.Z({
              x: (e.xmax - e.xmin) / t,
              y: (e.ymax - e.ymin) / i,
              spatialReference: e.spatialReference,
            }),
            c = n.srcResolution || (a ? L(u, s, e, l) : u);
          if (!c) return null;
          const { pyramidLevel: f, pyramidResolution: h, excessiveReading: d } = X(
            c,
            this.rasterInfo,
            this.ioConfig.sampling,
          );
          if (d) return null;
          const m = this.rasterInfo.storageInfo;
          let p = a ? j(e, s, l) : e;
          const y = (0, o.u)(this.rasterInfo.transform);
          if ((y && (p = y.inverseTransform(p)), null == p)) return null;
          const g = {
              x: Math.floor((p.xmin - m.origin.x) / h.x + 0.1),
              y: Math.floor((m.origin.y - p.ymax) / h.y + 0.1),
            },
            x = Math.ceil((p.xmax - p.xmin) / h.x - 0.1),
            w = Math.ceil((p.ymax - p.ymin) / h.y - 0.1);
          if (x / t > 8 || w / i > 8 || r >= 2) return null;
          const v = await this.fetchRawPixels(f, g, { width: x, height: w, wrapCount: r }, n);
          if (!v) return null;
          const b = f > 0 ? m.pyramidBlockWidth : m.blockWidth,
            I = f > 0 ? m.pyramidBlockHeight : m.blockHeight;
          if (!a && 1 === v.pixelBlocks.length && b === t && I === i && c.x === u.x && c.y === u.y)
            return { extent: e, srcExtent: p, pixelBlock: v.pixelBlocks[0] };
          const C = V(e, v.extent, u, l, y, r > 0);
          let _;
          const T = !n.requestRawData,
            R = { rows: C.spacing[0], cols: C.spacing[1] },
            S = (0, o.u)(this._getRasterTileAlignmentInfo(f, v.extent.xmin)),
            { pixelBlocks: M, mosaicSize: k, isPartiallyFilled: F } = v;
          if (this.rasterJobHandler)
            _ = await this.rasterJobHandler.mosaicAndTransform(
              {
                srcPixelBlocks: M,
                srcMosaicSize: k,
                destDimension: T ? { width: t, height: i } : null,
                coefs: T ? C.coefficients : null,
                sampleSpacing: T ? R : null,
                interpolation: n.interpolation,
                alignmentInfo: S,
              },
              n,
            );
          else {
            const e = (0, se.m)(M, k, null, null, S);
            _ = T ? (0, se.j)(e, { width: t, height: i }, C.coefficients, R, n.interpolation) : e;
          }
          return n.requestRawData
            ? { srcExtent: p, pixelBlock: _, transformGrid: C, extent: e, isPartiallyFilled: F }
            : { srcExtent: p, extent: e, pixelBlock: _ };
        }
        async fetchRawPixels(e, t, i, n) {
          const { origin: r, blockBoundary: s } = this.rasterInfo.storageInfo,
            { blockWidth: a, blockHeight: l } = this.getBlockWidthHeight(e);
          let { x: u, y: c } = t,
            { width: f, height: h, wrapCount: d } = i;
          const m = (0, o.u)(this._getRasterTileAlignmentInfo(e, 0));
          n.buffer &&
            ((u -= n.buffer.cols),
            (c -= n.buffer.rows),
            (f += 2 * n.buffer.cols),
            (h += 2 * n.buffer.rows));
          const p = Math.floor(u / a),
            y = Math.floor(c / l),
            g = Math.floor((u + f - 1) / a),
            x = Math.floor((c + h - 1) / l),
            w = s[e];
          if (!w) return null;
          const { minRow: v, minCol: b, maxCol: I, maxRow: C } = w;
          if (x < v || g < b || y > C || p > I) return null;
          const _ = [];
          let T,
            R = !1;
          for (let t = y; t <= x; t++)
            for (let i = p; i <= g; i++) {
              const r =
                0 === d || null == m || i < m.worldColumnCountFromOrigin
                  ? i
                  : (i % m.worldColumnCountFromOrigin) - m.originColumnOffset;
              t >= v && r >= b && C >= t && I >= r
                ? ((T = this._fetchRawTile(e, t, r, n)),
                  this.ioConfig.allowPartialFill &&
                    (T = new Promise((e) => {
                      T.then((t) => e(t)).catch(() => {
                        (R = !0), e(null);
                      });
                    })),
                  _.push(T))
                : _.push(null);
            }
          if (0 === _.length) return null;
          const S = await Promise.all(_),
            M = { height: (x - y + 1) * l, width: (g - p + 1) * a },
            { spatialReference: F } = this.rasterInfo,
            P = this.getPyramidPixelSize(e),
            { x: D, y: O } = P;
          return {
            extent: new k.Z({
              xmin: r.x + p * a * D,
              xmax: r.x + (g + 1) * a * D,
              ymin: r.y - (x + 1) * l * O,
              ymax: r.y - y * l * O,
              spatialReference: F,
            }),
            pixelBlocks: S,
            mosaicSize: M,
            isPartiallyFilled: R,
          };
        }
        async fetchRawTile(e, t, i, n) {
          throw new a.Z('BaseRaster:read-not-implemented', 'fetchRawTile() is not implemented');
        }
        computeExtent(e) {
          return j(this.rasterInfo.extent, e);
        }
        decodePixelBlock(e, t) {
          return !this.rasterJobHandler || t.useCanvas
            ? (0, M.d)(e, t)
            : this.rasterJobHandler.decode({ data: e, options: t });
        }
        async request(e, t, i) {
          var n, r;
          const { customFetchParameters: s } = this.ioConfig,
            { range: a, query: o, headers: l } = t;
          i = null != (n = null != (r = i) ? r : t.retryCount) ? n : this.ioConfig.retryCount;
          const u = a ? { Range: `bytes=${a.from}-${a.to}` } : null;
          try {
            return await (0, w.default)(e, {
              ...t,
              query: { ...o, ...s },
              headers: { ...l, ...u },
            });
          } catch (n) {
            if (i > 0) return i--, this.request(e, t, i);
            throw n;
          }
        }
        getSliceIndex(e) {
          const { multidimensionalInfo: t } = this.rasterInfo;
          if (!(0, o.i)(t) || null == e || !e.length) return null;
          let i = 0;
          const n = e[0].variableName;
          for (let r = 0; r < t.variables.length; r++) {
            const s = t.variables[r],
              a = s.dimensions;
            if (s.name !== n) {
              i += a.map((e) => this._getDimensionValuesCount(e)).reduce((e, t) => e + t);
              break;
            }
            const o = a.map((e) => this._getDimensionValuesCount(e)),
              l = a.length;
            for (let t = 0; t < l; t++) {
              const n = e.filter((e) => e.dimensionName === a[t].name)[0];
              if (null == n) return null;
              const r = Array.isArray(n.values[0]) ? n.values[0][0] : n.values[0],
                s = this._getIndexFromDimensions(r, a[t]);
              if (-1 === s) return null;
              o.shift(), (i += t === l - 1 ? s : s * o.reduce((e, t) => e + t));
            }
          }
          return i;
        }
        updateTileInfo() {
          const { storageInfo: e, spatialReference: t, extent: i, pixelSize: n } = this.rasterInfo;
          if (!e.tileInfo) {
            const r = [],
              s = e.maximumPyramidLevel || 0;
            let a = Math.max(n.x, n.y),
              o = (1 / 0.0254) * 96 * a;
            for (let e = 0; e <= s; e++)
              r.push({ level: s - e, resolution: a, scale: o }), (a *= 2), (o *= 2);
            const l = new N.Z({ x: i.xmin, y: i.ymax, spatialReference: t });
            (e.tileInfo = new R.Z({
              origin: l,
              size: [e.blockWidth, e.blockHeight],
              spatialReference: t,
              lods: r,
            })),
              (e.isVirtualTileInfo = !0);
          }
        }
        createRemoteDatasetStorageInfo(e, t = 512, i = 512, n) {
          const { width: r, height: s, nativeExtent: a, pixelSize: o, spatialReference: l } = e,
            u = new N.Z({ x: a.xmin, y: a.ymax, spatialReference: l });
          null == n && (n = Math.max(0, Math.round(Math.log(Math.max(r, s)) / Math.LN2 - 8)));
          const c = this.computeBlockBoundary(a, 512, 512, { x: a.xmin, y: a.ymax }, [o], n);
          e.storageInfo = new D.R({
            blockWidth: t,
            blockHeight: i,
            pyramidBlockWidth: t,
            pyramidBlockHeight: i,
            origin: u,
            firstPyramidLevel: 1,
            maximumPyramidLevel: n,
            blockBoundary: c,
          });
        }
        async computeBestPyramidLevelForLocation(e, t = {}) {
          return 0;
        }
        computeBlockBoundary(e, t, i, n, r, s = 0, a = 2) {
          if (1 === r.length && s > 0) {
            r = [...r];
            let { x: e, y: t } = r[0];
            for (let i = 0; i < s; i++) (e *= a), (t *= a), r.push({ x: e, y: t });
          }
          const o = [],
            { x: l, y: u } = n;
          for (let n = 0; n < r.length; n++) {
            const { x: s, y: a } = r[n];
            o.push({
              minCol: Math.floor((e.xmin - l + 0.1 * s) / t / s),
              maxCol: Math.floor((e.xmax - l - 0.1 * s) / t / s),
              minRow: Math.floor((u - e.ymax + 0.1 * a) / i / a),
              maxRow: Math.floor((u - e.ymin - 0.1 * a) / i / a),
            });
          }
          return o;
        }
        getPyramidPixelSize(e) {
          const { nativePixelSize: t } = this.rasterInfo,
            { pyramidResolutions: i, pyramidScalingFactor: n } = this.rasterInfo.storageInfo;
          if (0 === e) return t;
          if ((0, o.i)(i) && i.length) return i[e - 1];
          const r = n ** e;
          return { x: t.x * r, y: t.y * r };
        }
        identifyPixelLocation(e, t, i) {
          const { spatialReference: n, nativeExtent: r } = this.rasterInfo,
            {
              blockWidth: s,
              blockHeight: a,
              maximumPyramidLevel: o,
              origin: l,
            } = this.rasterInfo.storageInfo,
            u = Z(e, n, i);
          if (!r.intersects(u)) return null;
          if (t < 0 || t > o) return null;
          const c = this.getPyramidPixelSize(t),
            { x: f, y: h } = c,
            d = (l.y - u.y) / h / a,
            m = (u.x - l.x) / f / s,
            p = Math.min(a - 1, Math.floor((d - Math.floor(d)) * a)),
            y = Math.min(s - 1, Math.floor((m - Math.floor(m)) * s));
          return {
            pyramidLevel: t,
            row: Math.floor(d),
            col: Math.floor(m),
            rowOffset: p,
            colOffset: y,
            srcLocation: u,
          };
        }
        getTileExtent(e, t, i, n, r, s) {
          const [a, o] = s,
            l = n.x + i * a * e.x,
            u = l + a * e.x,
            c = n.y - t * o * e.y,
            f = c - o * e.y;
          return new k.Z({ xmin: l, xmax: u, ymin: f, ymax: c, spatialReference: r });
        }
        getBlockWidthHeight(e) {
          return {
            blockWidth:
              e > 0
                ? this.rasterInfo.storageInfo.pyramidBlockWidth
                : this.rasterInfo.storageInfo.blockWidth,
            blockHeight:
              e > 0
                ? this.rasterInfo.storageInfo.pyramidBlockHeight
                : this.rasterInfo.storageInfo.blockHeight,
          };
        }
        isBlockOutside(e, t, i) {
          const n = this.rasterInfo.storageInfo.blockBoundary[e];
          return !n || n.maxRow < t || n.maxCol < i || n.minRow > t || n.minCol > i;
        }
        _fetchRawTile(e, t, i, n) {
          const r = this.rasterInfo.storageInfo.blockBoundary[e];
          if (!r) return Promise.resolve(null);
          const { minRow: s, minCol: a, maxCol: l, maxRow: c } = r;
          if (t < s || i < a || t > c || i > l) return Promise.resolve(null);
          const f = ee(this.url, n.sliceId),
            h = `${e}/${t}/${i}`;
          let d = ie(f, n.registryId, h);
          if (!(0, o.i)(d)) {
            const r = (0, u.yi)();
            (d = this.fetchRawTile(e, t, i, { ...n, signal: r.signal })),
              ne(f, n.registryId, h, d, r),
              d.catch(() => {
                re(f, n.registryId, h);
              });
          }
          return (
            n.signal &&
              (0, u.fu)(n, () => {
                te(f, n.registryId, h);
              }),
            d
          );
        }
        _getIndexFromDimensions(e, t) {
          const { extent: i, interval: n, unit: r, values: s } = t;
          if (null != s && s.length)
            return Array.isArray(s[0]) ? s.findIndex((t) => t[0] <= e && t[1] >= e) : s.indexOf(e);
          if (e > i[1]) return -1;
          const a = i[0];
          let o = -1;
          if ('ISO8601' === r) {
            var l;
            switch ((null == (l = t.intervalUnit) ? void 0 : l.toLowerCase()) || 'seconds') {
              case 'seconds':
                o = Math.round((e - a) / 1e3 / n);
                break;
              case 'minutes':
                o = Math.round((e - a) / 6e4 / n);
                break;
              case 'hours':
                o = Math.round((e - a) / 36e5 / n);
                break;
              case 'days':
                o = Math.round((e - a) / 864e5 / n);
                break;
              case 'years':
                o = Math.round((new Date(e).getUTCFullYear() - new Date(a).getUTCFullYear()) / n);
                break;
              case 'decades':
                o = Math.round(
                  (new Date(e).getUTCFullYear() - new Date(a).getUTCFullYear()) / 10 / n,
                );
            }
            return o;
          }
          return Math.round((e - a) / n);
        }
        _getDimensionValuesCount(e) {
          const { extent: t, interval: i, unit: n, values: r } = e;
          let s = (null == r ? void 0 : r.length) || 0;
          if (s) return s;
          const a = t[0];
          if (0 === s && 'ISO8601' === n) {
            var o;
            switch ((null == (o = e.intervalUnit) ? void 0 : o.toLowerCase()) || 'seconds') {
              case 'seconds':
                s = Math.round((t[1] - t[0]) / 1e3 / i);
                break;
              case 'minutes':
                s = Math.round((t[1] - t[0]) / 6e4 / i);
                break;
              case 'hours':
                s = Math.round((t[1] - t[0]) / 36e5 / i);
                break;
              case 'days':
                s = Math.round((t[1] - t[0]) / 864e5 / i);
                break;
              case 'years':
                s = Math.round(
                  (new Date(t[1]).getUTCFullYear() - new Date(a).getUTCFullYear()) / i,
                );
                break;
              case 'decades':
                s = Math.round(
                  (new Date(t[1]).getUTCFullYear() - new Date(a).getUTCFullYear()) / 10 / i,
                );
            }
            return s;
          }
          return Math.round((t[1] - t[0]) / i);
        }
        _getRasterTileAlignmentInfo(e, t) {
          return (
            null == this._rasterTileAlighmentInfo &&
              (this._rasterTileAlighmentInfo = (function (e) {
                const t = e.storageInfo.origin.x,
                  i = W(e.spatialReference, !0);
                if (!(0, o.i)(i)) return { originX: t, halfWorldWidth: null, pyramidsInfo: null };
                const n = i / 2,
                  { nativePixelSize: r, storageInfo: s, extent: a } = e,
                  { maximumPyramidLevel: l, blockWidth: u, pyramidScalingFactor: c } = s;
                let f = r.x;
                const h = [],
                  d = (0, o.i)(e.transform) && 'gcs-shift' === e.transform.type,
                  m = t + n,
                  p = d ? i - t : n - t;
                for (let e = 0; e <= l; e++) {
                  const e = (a.xmax - t) / f / u,
                    n = e - Math.floor(e) == 0 ? e : Math.ceil(e),
                    r = (i / 2 - t) / f / u,
                    s = r - Math.floor(r) == 0 ? r : Math.ceil(r),
                    o = Math.floor(m / f / u),
                    l = Math.round(m / f) % u,
                    d = (u - (Math.round(p / f) % u)) % u;
                  h.push({
                    resolutionX: f,
                    blockWidth: u,
                    datsetColumnCount: n,
                    worldColumnCountFromOrigin: s,
                    leftMargin: l,
                    rightPadding: d,
                    originColumnOffset: o,
                  }),
                    (f *= c);
                }
                return { originX: t, halfWorldWidth: n, pyramidsInfo: h, hasGCSSShiftTransform: d };
              })(this.rasterInfo)),
            (0, o.i)(this._rasterTileAlighmentInfo.pyramidsInfo)
              ? {
                  startX: t,
                  halfWorldWidth: this._rasterTileAlighmentInfo.halfWorldWidth,
                  hasGCSSShiftTransform: this._rasterTileAlighmentInfo.hasGCSSShiftTransform,
                  ...this._rasterTileAlighmentInfo.pyramidsInfo[e],
                }
              : null
          );
        }
      };
      (0, n._)([(0, c.Cb)()], le.prototype, '_rasterTileAlighmentInfo', void 0),
        (0, n._)([(0, c.Cb)(C.u)], le.prototype, 'url', null),
        (0, n._)(
          [(0, c.Cb)({ type: String, json: { write: !0 } })],
          le.prototype,
          'datasetName',
          void 0,
        ),
        (0, n._)(
          [(0, c.Cb)({ type: String, json: { write: !0 } })],
          le.prototype,
          'datasetFormat',
          void 0,
        ),
        (0, n._)([(0, c.Cb)()], le.prototype, 'rasterInfo', void 0),
        (0, n._)([(0, c.Cb)()], le.prototype, 'ioConfig', void 0),
        (0, n._)([(0, c.Cb)()], le.prototype, 'sourceJSON', void 0),
        (le = (0, n._)([(0, p.j)('esri.layers.support.rasterDatasets.BaseRaster')], le));
      var ue = le;
      function ce(e, t) {
        if (!e || !t) return [];
        let i = t;
        t.indexOf('/') > -1
          ? ((i = t.slice(0, t.indexOf('/'))), (t = t.slice(t.indexOf('/') + 1)))
          : (t = '');
        const n = [];
        if (t) {
          const r = ce(e, i);
          for (let e = 0; e < r.length; e++) ce(r[e], t).forEach((e) => n.push(e));
          return n;
        }
        const r = e.getElementsByTagNameNS('*', i);
        if (!r || 0 === r.length) return [];
        for (let e = 0; e < r.length; e++) n.push(r[e] || r.item[e]);
        return n;
      }
      function fe(e, t) {
        if (!e || !t) return null;
        let i = t;
        t.indexOf('/') > -1
          ? ((i = t.slice(0, t.indexOf('/'))), (t = t.slice(t.indexOf('/') + 1)))
          : (t = '');
        const n = ce(e, i);
        return n.length > 0 ? (t ? fe(n[0], t) : n[0]) : null;
      }
      function he(e, t = null) {
        const i = t ? fe(e, t) : e;
        let n;
        return i ? ((n = i.textContent || i.nodeValue), n ? n.trim() : null) : null;
      }
      function de(e, t) {
        return (function (e, t) {
          const i = ce(e, t),
            n = [];
          let r;
          for (let e = 0; e < i.length; e++)
            (r = i[e].textContent || i[e].nodeValue), r && ((r = r.trim()), '' !== r && n.push(r));
          return n;
        })(e, t).map((e) => Number(e));
      }
      function me(e, t) {
        const i = he(e, t);
        return Number(i);
      }
      function pe(e, t) {
        var i;
        const n = null == e || null == (i = e.nodeName) ? void 0 : i.toLowerCase(),
          r = t.toLowerCase();
        return n.slice(n.lastIndexOf(':') + 1) === r;
      }
      var ye = i(89440),
        ge = i(62162),
        xe = i(16647),
        we = i(58912),
        ve = i(97546),
        be = i(88056),
        Ie = i(2906),
        Ce = i(87258),
        _e = i(32101),
        Te = i(47706),
        Re = i(9411),
        Se = i(22337),
        Me = i(78893);
      i(15324),
        i(91055),
        i(76996),
        i(21972),
        i(23639),
        i(86656),
        i(22723),
        i(27794),
        i(6906),
        i(31450),
        i(71552),
        i(40642),
        i(81172),
        i(86787),
        i(14249),
        i(9801),
        i(53523),
        i(42911),
        i(57251),
        i(26341),
        i(46826),
        i(45433),
        i(60217),
        i(73796),
        i(89623),
        i(84069),
        i(44567),
        i(98380),
        i(92896),
        i(22781),
        i(32422),
        i(29107),
        i(30574),
        i(2157),
        i(25977),
        i(7471),
        i(54414),
        i(1648),
        i(8925),
        i(33921),
        i(3482),
        i(45154),
        i(16769),
        i(55531),
        i(30582),
        i(593),
        i(85699),
        i(96055),
        i(47776),
        i(18033),
        i(6331),
        i(62048),
        i(4292),
        i(75626),
        i(72652),
        i(29641),
        i(30493),
        i(70821),
        i(82673),
        i(34229),
        i(37029),
        i(55306),
        i(96467),
        i(63571),
        i(30776),
        i(48027),
        i(54174),
        i(82426),
        i(63130),
        i(25696),
        i(66396),
        i(42775),
        i(95834),
        i(34394),
        i(57150),
        i(76726),
        i(20444),
        i(76393),
        i(78548),
        i(2497),
        i(49906),
        i(46527),
        i(48649),
        i(9960),
        i(3101),
        i(5853),
        i(39141),
        i(38742),
        i(48243),
        i(34635),
        i(10401),
        i(49900),
        i(66284),
        i(88762),
        i(73173),
        i(22739),
        i(67477),
        i(78533),
        i(74653),
        i(91091),
        i(58943),
        i(70737),
        i(8487),
        i(17817),
        i(90814),
        i(15459),
        i(61847),
        i(16796),
        i(16955),
        i(22401),
        i(77894),
        i(55187),
        i(8586),
        i(44509),
        i(69814),
        i(11305),
        i(62259),
        i(44790),
        i(5909),
        i(60669),
        i(48208),
        i(51589),
        i(65684),
        i(12158),
        i(74864),
        i(63683),
        i(94479),
        i(45702),
        i(51127),
        i(74071),
        i(51723),
        i(23243),
        i(51669),
        i(6090),
        i(3977),
        i(36741),
        i(11253),
        i(90319),
        i(38822),
        i(74057),
        i(23761),
        i(48190),
        i(85557),
        i(95587),
        i(94070),
        i(16218),
        i(9075),
        i(67541),
        i(81050),
        i(55436),
        i(62484),
        i(76223),
        i(86951),
        i(95310),
        i(93939),
        i(238),
        i(71831),
        i(49500),
        i(84225),
        i(95533),
        i(94751),
        i(7534),
        i(98402),
        i(41864),
        i(30831),
        i(91700),
        i(53269),
        i(50161),
        i(65514),
        i(46987),
        i(37453),
        i(66774),
        i(65775),
        i(12381),
        i(92482),
        i(92624),
        i(56420),
        i(74742),
        i(28239),
        i(93314),
        i(35197),
        i(47842),
        i(17298),
        i(54732),
        i(92817),
        i(46373),
        i(82933),
        i(89241),
        i(617);
      let ke = class extends F.a {
        constructor() {
          super(...arguments), (this.affectsPixelSize = !1);
        }
        forwardTransform(e) {
          return e;
        }
        inverseTransform(e) {
          return e;
        }
      };
      (0, n._)([(0, c.Cb)()], ke.prototype, 'affectsPixelSize', void 0),
        (0, n._)([(0, c.Cb)({ json: { write: !0 } })], ke.prototype, 'spatialReference', void 0),
        (ke = (0, n._)([(0, p.j)('esri.layers.support.rasterTransforms.BaseRasterTransform')], ke));
      var Fe = ke;
      let Pe = class extends Fe {
        constructor() {
          super(...arguments), (this.type = 'identity');
        }
      };
      (0, n._)([(0, d.e)({ IdentityXform: 'identity' })], Pe.prototype, 'type', void 0),
        (Pe = (0, n._)([(0, p.j)('esri.layers.support.rasterTransforms.IdentityTransform')], Pe));
      var De = Pe;
      function Oe(e, t, i) {
        const { x: n, y: r } = t;
        if (i < 2) return { x: e[0] + n * e[2] + r * e[4], y: e[1] + n * e[3] + r * e[5] };
        if (2 === i) {
          const t = n * n,
            i = r * r,
            s = n * r;
          return {
            x: e[0] + n * e[2] + r * e[4] + t * e[6] + s * e[8] + i * e[10],
            y: e[1] + n * e[3] + r * e[5] + t * e[7] + s * e[9] + i * e[11],
          };
        }
        const s = n * n,
          a = r * r,
          o = n * r,
          l = s * n,
          u = s * r,
          c = n * a,
          f = r * a;
        return {
          x:
            e[0] +
            n * e[2] +
            r * e[4] +
            s * e[6] +
            o * e[8] +
            a * e[10] +
            l * e[12] +
            u * e[14] +
            c * e[16] +
            f * e[18],
          y:
            e[1] +
            n * e[3] +
            r * e[5] +
            s * e[7] +
            o * e[9] +
            a * e[11] +
            l * e[13] +
            u * e[15] +
            c * e[17] +
            f * e[19],
        };
      }
      function Be(e, t, i) {
        const { xmin: n, ymin: r, xmax: s, ymax: a, spatialReference: o } = t;
        let l = [];
        if (i < 2)
          l.push({ x: n, y: a }),
            l.push({ x: s, y: a }),
            l.push({ x: n, y: r }),
            l.push({ x: s, y: r });
        else {
          let e = 10;
          for (let t = 0; t < e; t++)
            l.push({ x: n, y: r + ((a - r) * t) / (e - 1) }),
              l.push({ x: s, y: r + ((a - r) * t) / (e - 1) });
          e = 8;
          for (let t = 1; t <= e; t++)
            l.push({ x: n + ((s - n) * t) / e, y: r }), l.push({ x: n + ((s - n) * t) / e, y: a });
        }
        l = l.map((t) => Oe(e, t, i));
        const u = l.map((e) => e.x),
          c = l.map((e) => e.y);
        return new k.Z({
          xmin: Math.min.apply(null, u),
          xmax: Math.max.apply(null, u),
          ymin: Math.min.apply(null, c),
          ymax: Math.max.apply(null, c),
          spatialReference: o,
        });
      }
      let ze = class extends Fe {
        constructor() {
          super(...arguments), (this.polynomialOrder = 1), (this.type = 'polynomial');
        }
        readForwardCoefficients(e, t) {
          const { coeffX: i, coeffY: n } = t;
          if (null == i || !i.length || null == n || !n.length || i.length !== n.length)
            return null;
          const r = [];
          for (let e = 0; e < i.length; e++) r.push(i[e]), r.push(n[e]);
          return r;
        }
        writeForwardCoefficients(e, t, i) {
          const n = [],
            r = [];
          for (let t = 0; t < (null == e ? void 0 : e.length); t++)
            t % 2 == 0 ? n.push(e[t]) : r.push(e[t]);
          (t.coeffX = n), (t.coeffY = r);
        }
        get inverseCoefficients() {
          let e = this._get('inverseCoefficients');
          const t = this._get('forwardCoefficients');
          return (
            !e &&
              t &&
              this.polynomialOrder < 2 &&
              (e = (function (e) {
                const [t, i, n, r, s, a] = e,
                  o = n * a - s * r,
                  l = s * r - n * a;
                return [(s * i - t * a) / o, (n * i - t * r) / l, a / o, r / l, -s / o, -n / l];
              })(t)),
            e
          );
        }
        set inverseCoefficients(e) {
          this._set('inverseCoefficients', e);
        }
        readInverseCoefficients(e, t) {
          const { inverseCoeffX: i, inverseCoeffY: n } = t;
          if (null == i || !i.length || null == n || !n.length || i.length !== n.length)
            return null;
          const r = [];
          for (let e = 0; e < i.length; e++) r.push(i[e]), r.push(n[e]);
          return r;
        }
        writeInverseCoefficients(e, t, i) {
          const n = [],
            r = [];
          for (let t = 0; t < (null == e ? void 0 : e.length); t++)
            t % 2 == 0 ? n.push(e[t]) : r.push(e[t]);
          (t.inverseCoeffX = n), (t.inverseCoeffY = r);
        }
        forwardTransform(e) {
          if ('point' === e.type) {
            const t = Oe(this.forwardCoefficients, e, this.polynomialOrder);
            return new N.Z({ x: t.x, y: t.y, spatialReference: e.spatialReference });
          }
          return Be(this.forwardCoefficients, e, this.polynomialOrder);
        }
        inverseTransform(e) {
          if ('point' === e.type) {
            const t = Oe(this.inverseCoefficients, e, this.polynomialOrder);
            return new N.Z({ x: t.x, y: t.y, spatialReference: e.spatialReference });
          }
          return Be(this.inverseCoefficients, e, this.polynomialOrder);
        }
      };
      (0, n._)([(0, c.Cb)({ json: { write: !0 } })], ze.prototype, 'polynomialOrder', void 0),
        (0, n._)([(0, c.Cb)()], ze.prototype, 'forwardCoefficients', void 0),
        (0, n._)(
          [(0, m.r)('forwardCoefficients', ['coeffX', 'coeffY'])],
          ze.prototype,
          'readForwardCoefficients',
          null,
        ),
        (0, n._)(
          [(0, Ie.w)('forwardCoefficients')],
          ze.prototype,
          'writeForwardCoefficients',
          null,
        ),
        (0, n._)([(0, c.Cb)({ json: { write: !0 } })], ze.prototype, 'inverseCoefficients', null),
        (0, n._)(
          [(0, m.r)('inverseCoefficients', ['inverseCoeffX', 'inverseCoeffY'])],
          ze.prototype,
          'readInverseCoefficients',
          null,
        ),
        (0, n._)(
          [(0, Ie.w)('inverseCoefficients')],
          ze.prototype,
          'writeInverseCoefficients',
          null,
        ),
        (0, n._)([(0, c.Cb)()], ze.prototype, 'affectsPixelSize', void 0),
        (0, n._)([(0, d.e)({ PolynomialXform: 'polynomial' })], ze.prototype, 'type', void 0),
        (ze = (0, n._)([(0, p.j)('esri.layers.support.rasterTransforms.PolynomialTransform')], ze));
      var Ne = ze;
      const Ee = { PolynomialXform: Ne, IdentityXform: De },
        Ae = Object.keys(Ee),
        Le = new Map();
      Le.set('int16', 'esriFieldTypeSmallInteger'),
        Le.set('int32', 'esriFieldTypeInteger'),
        Le.set('int64', 'esriFieldTypeInteger'),
        Le.set('float32', 'esriFieldTypeSingle'),
        Le.set('float64', 'esriFieldTypeDouble'),
        Le.set('text', 'esriFieldTypeString');
      let He = class extends ue {
        constructor() {
          super(...arguments), (this.storageInfo = null), (this.datasetFormat = 'CRF');
        }
        async open(e) {
          await this.init();
          const { data: t } = await this.request(this.url + '/conf.json', {
            signal: null == e ? void 0 : e.signal,
          });
          if (!this._validateHeader(t))
            throw new a.Z('cloudraster:open', 'Invalid or unsupported conf.json.');
          this.datasetName = this.url.slice(this.url.lastIndexOf('/') + 1);
          const { storageInfo: i, rasterInfo: n } = this._parseHeader(t);
          if ('thematic' === n.dataType) {
            const e = await this._fetchAuxiliaryInformation();
            n.attributeTable = e;
          }
          this._set('storageInfo', i),
            this._set('rasterInfo', n),
            (this.ioConfig.retryCount = this.ioConfig.retryCount || 0);
        }
        async fetchRawTile(e, t, i, n = {}) {
          const r = this.rasterInfo.storageInfo.maximumPyramidLevel - e;
          if (r < 0) return null;
          const s = this._buildCacheFilePath(r, t, i, n.multidimensionalDefinition),
            a = this._getIndexRecordFromBundle(t, i),
            o = await this.request(s, {
              range: { from: 0, to: this.storageInfo.headerSize - 1 },
              responseType: 'array-buffer',
              signal: n.signal,
            });
          if (!o) return null;
          const l = new Uint8Array(o.data),
            u = this._getTileEndAndContentType(l, a);
          if (0 === u.recordSize) return null;
          const c = await this.request(s, {
            range: { from: u.position, to: u.position + u.recordSize },
            responseType: 'array-buffer',
            signal: n.signal,
          });
          return c
            ? this.decodePixelBlock(c.data, {
                width: this.rasterInfo.storageInfo.tileInfo.size[0],
                height: this.rasterInfo.storageInfo.tileInfo.size[1],
                planes: null,
                pixelType: null,
              })
            : null;
        }
        _validateHeader(e) {
          return (
            e &&
            'RasterInfo' === e.type &&
            ![
              'origin',
              'extent',
              'geodataXform',
              'LODInfos',
              'blockWidth',
              'blockHeight',
              'bandCount',
              'pixelType',
              'pixelSizeX',
              'pixelSizeY',
              'format',
              'packetSize',
            ].some((t) => !e[t])
          );
        }
        _parseHeader(e) {
          var t, i;
          const n = ['u1', 'u2', 'u4', 'u8', 's8', 'u16', 's16', 'u32', 's32', 'f32', 'f64'][
              e.pixelType
            ],
            {
              bandCount: r,
              histograms: s,
              colormap: a,
              blockWidth: o,
              blockHeight: l,
              firstPyramidLevel: u,
              maximumPyramidLevel: c,
            } = e,
            f =
              e.statistics &&
              e.statistics.map((e) => ({
                min: e.min,
                max: e.max,
                avg: e.mean,
                stddev: e.standardDeviation,
                median: e.median,
                mode: e.mode,
              })),
            h = e.extent.spatialReference,
            d = null == (t = e.geodataXform) ? void 0 : t.spatialReference,
            m = new b.Z((null != h && h.wkid) || (null != h && h.wkt) ? h : d);
          let p = new k.Z({
            xmin: e.extent.xmin,
            ymin: e.extent.ymin,
            xmax: e.extent.xmax,
            ymax: e.extent.ymax,
            spatialReference: m,
          });
          const y = new N.Z({ x: e.pixelSizeX, y: e.pixelSizeY, spatialReference: m }),
            g = Math.round((p.xmax - p.xmin) / y.x),
            x = Math.round((p.ymax - p.ymin) / y.y),
            w = this._parseTransform(e.geodataXform),
            v = w ? p : null;
          w &&
            ((p = w.forwardTransform(p)),
            (y.x = (p.xmax - p.xmin) / g),
            (y.y = (p.ymax - p.ymin) / x));
          const I = null != (i = e.properties) ? i : {},
            C = e.format.toLowerCase().replace('cache/', ''),
            _ = new N.Z(e.origin.x, e.origin.y, m);
          let T, S, M, F;
          if (a && a.colors)
            for (T = [], S = 0; S < a.colors.length; S++)
              (M = a.colors[S]),
                (F = a.values ? a.values[S] : S),
                T.push([F, 255 & M, (M << 16) >>> 24, (M << 8) >>> 24, M >>> 24]);
          const P = e.LODInfos,
            O = [];
          for (S = 0; S < P.levels.length; S++)
            O.push({
              level: P.levels[S],
              resolution: P.resolutions[S],
              scale: (96 / 0.0254) * P.resolutions[S],
            });
          const B = new R.Z({
              dpi: 96,
              lods: O,
              format: C,
              origin: _,
              size: [o, l],
              spatialReference: m,
            }),
            z = {
              recordSize: 8,
              packetSize: e.packetSize,
              headerSize: e.packetSize * e.packetSize * 8 + 64,
            },
            E = [
              { maxCol: Math.ceil(g / o) - 1, maxRow: Math.ceil(x / l) - 1, minCol: 0, minRow: 0 },
            ];
          let A = 2;
          if (c > 0)
            for (S = 0; S < c; S++)
              E.push({
                maxCol: Math.ceil(g / A / o) - 1,
                maxRow: Math.ceil(x / A / l) - 1,
                minCol: 0,
                minRow: 0,
              }),
                (A *= 2);
          const L = e.mdInfo;
          return {
            storageInfo: z,
            rasterInfo: new D.Z({
              width: g,
              height: x,
              pixelType: n,
              bandCount: r,
              extent: p,
              nativeExtent: v,
              transform: w,
              spatialReference: m,
              pixelSize: y,
              keyProperties: I,
              statistics: f,
              histograms: s,
              multidimensionalInfo: L,
              colormap: T,
              storageInfo: new D.R({
                blockWidth: o,
                blockHeight: l,
                pyramidBlockWidth: o,
                pyramidBlockHeight: l,
                origin: _,
                tileInfo: B,
                firstPyramidLevel: u,
                maximumPyramidLevel: c,
                blockBoundary: E,
              }),
            }),
          };
        }
        _parseTransform(e) {
          var t, i;
          if (
            !(function (e) {
              const t = null == e ? void 0 : e.type;
              return !e || Ae.includes(t);
            })(e)
          )
            throw new a.Z(
              'cloudraster:open',
              'the data contains unsupported geodata transform types',
            );
          const n = (function (e) {
            if (!(null == e ? void 0 : e.type)) return null;
            const t = Ee[null == e ? void 0 : e.type];
            if (t) {
              const i = new t();
              return i.read(e), i;
            }
            return null;
          })(e);
          if ('identity' === n.type) return null;
          if (
            'polynomial' !== n.type ||
            null == (t = n.forwardCoefficients) ||
            !t.length ||
            null == (i = n.inverseCoefficients) ||
            !i.length
          )
            throw new a.Z(
              'cloudraster:open',
              'the data contains unsupported geodata transforms - both forward and inverse coefficients are required currently',
            );
          return n;
        }
        async _fetchAuxiliaryInformation(e) {
          const t = this.request(this.url + '/conf.vat.json', { signal: e })
              .then((e) => e.data)
              .catch(() => null),
            i = this.request(this.url + '/conf.vat.dbf', {
              responseType: 'array-buffer',
              signal: e,
            })
              .then((e) => e.data)
              .catch(() => null),
            n = await Promise.all([t, i]);
          let r;
          if (n[0]) {
            let e = n[0].fields;
            const t = n[0].values;
            if (e && t) {
              e = e.map((e) => ({
                type: 'OID' === e.name ? 'esriFieldTypeOID' : Le.get(e.type),
                name: e.name,
                alias: e.alias || e.name,
              }));
              const i = t.map((e) => ({ attributes: e }));
              e && t && (r = { fields: e, features: i });
            }
          }
          return (
            !r &&
              n[1] &&
              (r = class {
                static get supportedVersions() {
                  return [5];
                }
                static parse(e) {
                  const t = new DataView(e),
                    i = 3 & t.getUint8(0);
                  if (3 !== i) return { header: { version: i }, recordSet: null };
                  const n = t.getUint32(4, !0),
                    r = t.getUint16(8, !0),
                    s = t.getUint16(10, !0),
                    a = { version: i, recordCount: n, headerByteCount: r, recordByteCount: s };
                  let o = 32;
                  const l = [],
                    u = [];
                  let c;
                  if (3 === i) {
                    for (; 13 !== t.getUint8(o); )
                      (c = String.fromCharCode(t.getUint8(o + 11)).trim()),
                        l.push({
                          name: (0, M.b)(new Uint8Array(e, o, 11)),
                          type: c,
                          typeName: ['String', 'Date', 'Double', 'Boolean', 'String', 'Integer'][
                            ['C', 'D', 'F', 'L', 'M', 'N'].indexOf(c)
                          ],
                          length: t.getUint8(o + 16),
                        }),
                        (o += 32);
                    if (((o += 1), l.length > 0))
                      for (; u.length < n && e.byteLength - o > s; ) {
                        const i = [];
                        32 === t.getUint8(o)
                          ? ((o += 1),
                            l.forEach((t) => {
                              if ('C' === t.type)
                                i.push((0, M.b)(new Uint8Array(e, o, t.length)).trim());
                              else if ('N' === t.type)
                                i.push(
                                  parseInt(
                                    String.fromCharCode
                                      .apply(null, new Uint8Array(e, o, t.length))
                                      .trim(),
                                    10,
                                  ),
                                );
                              else if ('F' === t.type)
                                i.push(
                                  parseFloat(
                                    String.fromCharCode
                                      .apply(null, new Uint8Array(e, o, t.length))
                                      .trim(),
                                  ),
                                );
                              else if ('D' === t.type) {
                                const n = String.fromCharCode
                                  .apply(null, new Uint8Array(e, o, t.length))
                                  .trim();
                                i.push(
                                  new Date(
                                    parseInt(n.substring(0, 4), 10),
                                    parseInt(n.substring(4, 6), 10) - 1,
                                    parseInt(n.substring(6, 8), 10),
                                  ),
                                );
                              }
                              o += t.length;
                            }),
                            u.push(i))
                          : (o += s);
                      }
                  }
                  const f = (function (e) {
                    const t = e.fields,
                      i = e.records,
                      n = t.some((e) => 'oid' === e.name.toLowerCase()) ? 'OBJECTID' : 'OID',
                      r = [{ name: n, type: 'esriFieldTypeOID', alias: 'OID' }].concat(
                        t.map((e) => ({
                          name: e.name,
                          type: 'esriFieldType' + e.typeName,
                          alias: e.name,
                        })),
                      ),
                      s = r.map((e) => e.name),
                      a = [];
                    let o = 0,
                      l = 0;
                    return (
                      i.forEach((e) => {
                        const t = {};
                        for (t[n] = o++, l = 1; l < s.length; l++) t[s[l]] = e[l - 1];
                        a.push({ attributes: t });
                      }),
                      { displayFieldName: '', fields: r, features: a }
                    );
                  })({ fields: l, records: u });
                  return { header: a, fields: l, records: u, recordSet: f };
                }
              }.parse(n[1]).recordSet),
            Ce.default.fromJSON(r)
          );
        }
        _buildCacheFilePath(e, t, i, n) {
          const r = this.storageInfo.packetSize,
            s = Math.floor(t / r) * r,
            a = Math.floor(i / r) * r,
            l = 'R' + this._toHexString4(s) + 'C' + this._toHexString4(a);
          let u = 'L';
          u += e >= 10 ? e.toString() : '0' + e.toString();
          const { multidimensionalInfo: c } = this.rasterInfo,
            f = null == n ? void 0 : n[0];
          if (!(0, o.i)(c) || !f) return `${this.url}/_alllayers/${u}/${l}.bundle`;
          let h = c.variables
            .filter((e) => e.name === f.variableName)[0]
            .dimensions[0].values.indexOf(f.values[0])
            .toString(16);
          const d = 4 - h.length;
          for (let e = 0; e < d; e++) h = '0' + h;
          return (h = 'S' + h), `${this.url}/_alllayers/${f.variableName}/${h}/${u}/${l}.bundle`;
        }
        _getIndexRecordFromBundle(e, t) {
          const i = this.storageInfo.packetSize,
            n = i * (e % i) + (t % i);
          if (n < 0) throw 'Invalid level / row / col';
          return 20 + n * this.storageInfo.recordSize + 44;
        }
        _getTileEndAndContentType(e, t) {
          const i = e.subarray(t, t + 8);
          let n,
            r = 0;
          for (n = 0; n < 5; n++) r |= (255 & i[n]) << (8 * n);
          const s = 0xffffffffff & r;
          for (r = 0, n = 5; n < 8; n++) r |= (255 & i[n]) << (8 * (n - 5));
          return { position: s, recordSize: 0xffffffffff & r };
        }
        _toHexString4(e) {
          let t = e.toString(16);
          if (4 !== t.length) {
            let e = 4 - t.length;
            for (; e-- > 0; ) t = '0' + t;
          }
          return t;
        }
      };
      (0, n._)([(0, c.Cb)({ readOnly: !0 })], He.prototype, 'storageInfo', void 0),
        (0, n._)(
          [(0, c.Cb)({ type: String, json: { write: !0 } })],
          He.prototype,
          'datasetFormat',
          void 0,
        ),
        (He = (0, n._)([(0, p.j)('esri.layers.support.rasterDatasets.CloudRaster')], He));
      var Ze = He;
      let Je = class extends ue {
        constructor() {
          super(...arguments), (this.datasetFormat = 'MEMORY');
        }
        async open(e) {
          var t;
          await this.init();
          const {
              pixelBlock: i,
              statistics: n,
              histograms: r,
              name: s,
              keyProperties: a,
              nativeExtent: o,
              transform: l,
            } = this.data,
            { width: u, height: c, pixelType: f } = i,
            h =
              this.data.extent ||
              new k.Z({
                xmin: -0.5,
                ymin: 0.5,
                xmax: u - 0.5,
                ymax: c - 0.5,
                spatialReference: new b.Z({ wkid: 3857 }),
              }),
            d = null != (t = this.data.isPseudoSpatialReference) ? t : !this.data.extent,
            m = { x: h.width / u, y: h.height / c },
            p = new D.Z({
              width: u,
              height: c,
              pixelType: f,
              extent: h,
              nativeExtent: o,
              transform: l,
              pixelSize: m,
              spatialReference: h.spatialReference,
              bandCount: 3,
              keyProperties: a || {},
              statistics: n,
              isPseudoSpatialReference: d,
              histograms: r,
            });
          this.createRemoteDatasetStorageInfo(p, 512, 512),
            this._set('rasterInfo', p),
            this.updateTileInfo(),
            await this._buildInMemoryRaster(i, { width: 512, height: 512 }, e),
            (this.datasetName = s),
            (this.url = '/InMemory/' + s);
        }
        fetchRawTile(e, t, i, n = {}) {
          const r = this._pixelBlockTiles.get(`${e}/${t}/${i}`);
          return Promise.resolve(r);
        }
        async _buildInMemoryRaster(e, t, i) {
          const n = this.rasterInfo.storageInfo.maximumPyramidLevel,
            r = this.rasterJobHandler
              ? this.rasterJobHandler.split(
                  { pixelBlock: e, tileSize: t, maximumPyramidLevel: n },
                  i,
                )
              : Promise.resolve((0, se.g)(e, t, n)),
            s = (0, o.i)(this.rasterInfo.statistics),
            l = (0, o.i)(this.rasterInfo.histograms),
            c =
              s && l
                ? Promise.resolve({ statistics: null, histograms: null })
                : this.rasterJobHandler
                ? this.rasterJobHandler.estimateStatisticsHistograms({ pixelBlock: e }, i)
                : Promise.resolve((0, se.f)(e)),
            f = await (0, u.as)([r, c]);
          if (!f[0].value && f[1].value)
            throw new a.Z('inmemory-raster:open', 'failed to build in memory raster');
          var h, d;
          (this._pixelBlockTiles = f[0].value),
            s || (this.rasterInfo.statistics = null == (h = f[1].value) ? void 0 : h.statistics),
            l && (this.rasterInfo.histograms = null == (d = f[1].value) ? void 0 : d.histograms);
        }
      };
      (0, n._)(
        [(0, c.Cb)({ type: String, json: { write: !0 } })],
        Je.prototype,
        'datasetFormat',
        void 0,
      ),
        (0, n._)([(0, c.Cb)()], Je.prototype, 'data', void 0),
        (Je = (0, n._)([(0, p.j)('esri.layers.support.rasterDatasets.InMemoryRaster')], Je));
      var je = Je;
      function qe(e, t) {
        if (!e || !t) return null;
        const i = [];
        for (let n = 0; n < e.length; n++) i.push(e[n]), i.push(t[n]);
        return i;
      }
      function We(e) {
        if (!e) return null;
        let t = Number(e);
        if (!isNaN(t) && 0 !== t) return new b.Z({ wkid: t });
        if ((e = String(e)).startsWith('COMPD_CS')) {
          if (!e.includes('VERTCS') || (!e.includes('GEOGCS') && !e.startsWith('PROJCS')))
            return null;
          const i = e.indexOf('VERTCS'),
            n = e.indexOf('PROJCS'),
            r = n > -1 ? n : e.indexOf('GEOGCS');
          if (-1 === r) return null;
          const s = e.slice(r, e.lastIndexOf(']', i) + 1).trim(),
            a = e.slice(r, e.lastIndexOf(']')).trim();
          t = Ge(s);
          const o = new b.Z(t ? { wkid: t } : { wkt: s }),
            l = Ge(a);
          return l && (o.vcsWkid = l), o;
        }
        return e.startsWith('GEOGCS') || e.startsWith('PROJCS')
          ? ((t = Ge(e)), new b.Z(0 !== t ? { wkid: t } : { wkt: e }))
          : null;
      }
      function Ge(e) {
        const t = e
            .replace(/\]/g, '[')
            .replace(/\"/g, '')
            .split('[')
            .map((e) => e.trim())
            .filter((e) => '' !== e),
          i = t[t.length - 1].split(',');
        if ('EPSG' === i[0] && e.endsWith('"]]')) {
          const e = Number(i[1]);
          if (!isNaN(e) && 0 !== e) return e;
        }
        return 0;
      }
      function Ue(e) {
        var t;
        if (
          'pamdataset' !==
          (null == e || null == (t = e.documentElement.tagName) ? void 0 : t.toLowerCase())
        )
          return {};
        const i = {
          spatialReference: null,
          transform: null,
          metadata: {},
          rasterBands: [],
          statistics: null,
          histograms: null,
        };
        e.documentElement.childNodes.forEach((e) => {
          if (1 === e.nodeType)
            if (pe(e, 'SRS')) {
              if (!i.spatialReference) {
                const t = he(e);
                i.spatialReference = We(t);
              }
            } else if (pe(e, 'Metadata'))
              if ('xml:ESRI' === e.getAttribute('domain')) {
                const { spatialReference: t, transform: n } = (function (e) {
                  var t;
                  const i = fe(e, 'GeodataXform'),
                    n = We(me(i, 'SpatialReference/WKID') || he(i, 'SpatialReference/WKT'));
                  if ('typens:PolynomialXform' !== i.getAttribute('xsi:type'))
                    return { spatialReference: n, transform: null };
                  const r = null != (t = me(i, 'PolynomialOrder')) ? t : 1,
                    s = de(i, 'CoeffX/Double'),
                    a = de(i, 'CoeffY/Double'),
                    o = de(i, 'InverseCoeffX/Double'),
                    l = de(i, 'InverseCoeffY/Double'),
                    u = qe(s, a),
                    c = qe(o, l);
                  return {
                    spatialReference: n,
                    transform: new Ne({
                      spatialReference: n,
                      polynomialOrder: r,
                      forwardCoefficients: u,
                      inverseCoefficients: c,
                    }),
                  };
                })(e);
                (i.transform = n), i.spatialReference || (i.spatialReference = t);
              } else ce(e, 'MDI').forEach((e) => (i.metadata[e.getAttribute('key')] = he(e)));
            else if (pe(e, 'PAMRasterBand')) {
              const t = (function (e) {
                var t;
                const i = me(e, 'NoDataValue'),
                  n = fe(e, 'Histograms/HistItem'),
                  r = me(n, 'HistMin'),
                  s = me(n, 'HistMax'),
                  a = me(n, 'BucketCount'),
                  o =
                    null == (t = he(n, 'HistCounts')) ? void 0 : t.split('|').map((e) => Number(e));
                let l, u, c, f;
                ce(e, 'Metadata/MDI').forEach((e) => {
                  var t;
                  const i = Number(null != (t = e.textContent) ? t : e.nodeValue);
                  switch (e.getAttribute('key').toUpperCase()) {
                    case 'STATISTICS_MINIMUM':
                      l = i;
                      break;
                    case 'STATISTICS_MAXIMUM':
                      u = i;
                      break;
                    case 'STATISTICS_MEAN':
                      c = i;
                      break;
                    case 'STATISTICS_STDDEV':
                      f = i;
                  }
                });
                const h = me(e, 'Metadata/SourceBandIndex');
                return {
                  noDataValue: i,
                  histogram:
                    null != o && o.length && null != l && null != u
                      ? { min: r, max: s, size: a || o.length, counts: o }
                      : null,
                  sourceBandIndex: h,
                  statistics: null != l && null != u ? { min: l, max: u, avg: c, stddev: f } : null,
                };
              })(e);
              null != t.sourceBandIndex && null == i.rasterBands[t.sourceBandIndex]
                ? (i.rasterBands[t.sourceBandIndex] = t)
                : i.rasterBands.push(t);
            }
        });
        const n = i.rasterBands;
        if (n) {
          const e = !!n[0].statistics;
          i.statistics = e ? n.map((e) => e.statistics) : null;
          const t = !!n[0].histogram;
          i.histograms = t ? n.map((e) => e.histogram) : null;
        }
        return i;
      }
      let Ye = class extends ue {
        async open(e) {
          await this.init();
          const t = await this._fetchData(e);
          let {
            spatialReference: i,
            statistics: n,
            histograms: r,
            transform: s,
          } = await this._fetchAuxiliaryData(e);
          const a = !i;
          a && (i = new b.Z({ wkid: 3857 })),
            null != r && r.length && null == n && (n = (0, se.h)(r));
          const { width: o, height: l } = t;
          let u = new k.Z({
            xmin: -0.5,
            ymin: 0.5 - l,
            xmax: o - 0.5,
            ymax: 0.5,
            spatialReference: i,
          });
          const c = s ? s.forwardTransform(u) : u;
          let f = !0;
          if (s) {
            const e = s.forwardCoefficients;
            (f = e && 0 === e[1] && 0 === e[2]), f && ((s = null), (u = c));
          }
          const h = new je({
            data: {
              extent: c,
              nativeExtent: u,
              transform: s,
              pixelBlock: t,
              statistics: n,
              histograms: r,
              keyProperties: { DateType: 'Processed' },
              isPseudoSpatialReference: a,
            },
          });
          await h.open(), this._set('rasterInfo', h.rasterInfo), (this._inMemoryRaster = h);
        }
        fetchRawTile(e, t, i, n = {}) {
          return this._inMemoryRaster.fetchRawTile(e, t, i, n);
        }
        async _fetchData(e) {
          const { data: t } = await this.request(this.url, {
              responseType: 'array-buffer',
              signal: null == e ? void 0 : e.signal,
            }),
            i = (0, M.g)(t).toUpperCase();
          if ('JPG' !== i && 'PNG' !== i && 'GIF' !== i && 'BMP' !== i)
            throw new a.Z('image-aux-raster:open', 'the data is not a supported format');
          return (
            this._set('datasetFormat', i),
            await this.decodePixelBlock(t, { format: 'jpg', width: 1, height: 1, useCanvas: !0 })
          );
        }
        async _fetchAuxiliaryData(e) {
          var t, i;
          const n = (0, o.u)(null == e ? void 0 : e.signal),
            r = null != (t = this.ioConfig.skipExtensions) ? t : [],
            s =
              r.indexOf('aux.xml') > -1
                ? null
                : this.request(this.url + '.aux.xml', { responseType: 'xml', signal: n }),
            a = this.datasetFormat,
            l = 'JPG' === a ? 'jgw' : 'PNG' === a ? 'pgw' : 'BMP' === a ? 'bpw' : null,
            c =
              r.indexOf(l) > -1
                ? null
                : this.request(this.url.slice(0, this.url.lastIndexOf('.')) + '.' + l, {
                    responseType: 'text',
                    signal: n,
                  }),
            f = await (0, u.as)([s, c]);
          if (null != n && n.aborted) throw (0, u.zE)();
          const h = Ue(null == (i = f[0].value) ? void 0 : i.data);
          if (!h.transform) {
            const e = f[1].value
              ? f[1].value.data
                  .split('\n')
                  .slice(0, 6)
                  .map((e) => Number(e))
              : null;
            h.transform =
              6 === (null == e ? void 0 : e.length)
                ? new Ne({ forwardCoefficients: [e[4], e[5], e[0], -e[1], e[2], -e[3]] })
                : null;
          }
          return h;
        }
      };
      (0, n._)(
        [(0, c.Cb)({ type: String, json: { write: !0 } })],
        Ye.prototype,
        'datasetFormat',
        void 0,
      ),
        (Ye = (0, n._)([(0, p.j)('esri.layers.support.rasterDatasets.ImageAuxRaster')], Ye));
      var Ve = Ye;
      let $e = class extends Fe {
        constructor() {
          super(...arguments), (this.type = 'gcs-shift'), (this.tolerance = 1e-8);
        }
        forwardTransform(e) {
          return 'point' === (e = e.clone()).type
            ? (e.x > 180 + this.tolerance && (e.x -= 360), e)
            : (e.xmin >= 180 - this.tolerance
                ? ((e.xmax -= 360), (e.xmin -= 360))
                : e.xmax > 180 + this.tolerance && ((e.xmin = -180), (e.xmax = 180)),
              e);
        }
        inverseTransform(e) {
          return 'point' === (e = e.clone()).type
            ? (e.x < -this.tolerance && (e.x += 360), e)
            : (e.xmin < -this.tolerance && ((e.xmin += 360), (e.xmax += 360)), e);
        }
      };
      (0, n._)([(0, d.e)({ GCSShiftXform: 'gcs-shift' })], $e.prototype, 'type', void 0),
        (0, n._)([(0, c.Cb)()], $e.prototype, 'tolerance', void 0),
        ($e = (0, n._)([(0, p.j)('esri.layers.support.rasterTransforms.GCSShiftTransform')], $e));
      var Xe = $e;
      let Ke = class extends ue {
        constructor() {
          super(...arguments),
            (this._levelOffset = 0),
            (this._slices = null),
            (this._tilemapCache = null),
            (this.datasetFormat = 'RasterTileServer');
        }
        async open(e) {
          await this.init();
          const t = e && e.signal,
            i = this.sourceJSON
              ? { data: this.sourceJSON }
              : await this.request(this.url, { query: { f: 'json' }, signal: t });
          i.ssl && (this.url = this.url.replace(/^http:/i, 'https:'));
          const n = i.data;
          if (((this.sourceJSON = n), !n))
            throw new a.Z(
              'imageserverraster:open',
              'cannot initialize tiled image service, missing service info',
            );
          if (!n.tileInfo)
            throw new a.Z(
              'imageserverraster:open',
              'use ImageryLayer to open non-tiled image services',
            );
          this._fixScaleInServiceInfo(),
            (this.tileType = n.cacheType),
            null == this.tileType &&
              (['jpg', 'jpeg', 'png', 'png8', 'png24', 'png32', 'mixed'].indexOf(
                n.tileInfo.format.toLowerCase(),
              ) > -1
                ? (this.tileType = 'Map')
                : 'lerc' === n.tileInfo.format.toLowerCase()
                ? (this.tileType = 'Elevation')
                : (this.tileType = 'Raster')),
            (this.datasetName = n.name.slice(n.name.indexOf('/') + 1));
          const r = await this._fetchRasterInfo({ signal: t });
          if (!(0, o.i)(r))
            throw new a.Z('image-server-raster:open', 'cannot initialize image service');
          {
            const e = 'Map' === this.tileType ? (0, Te.r)(n.tileInfo, n) : R.Z.fromJSON(n.tileInfo),
              { extent: t, pixelSize: i } = r,
              s = (0.5 / r.width) * i.x;
            let a, o;
            const l = e.lodAt(
              Math.max.apply(
                null,
                e.lods.map((e) => e.level),
              ),
            );
            'Map' !== this.tileType &&
              0 !== n.maxScale &&
              ('Raster' === this.tileType
                ? ((a = e.lods.filter((e) => e.resolution === i.x)[0]),
                  a || (a = e.lods[e.lods.length - 1]))
                : ((a = e.lods.filter((e) => Math.abs(e.scale - n.maxScale) < s)[0]),
                  a ||
                    (a = e.lods
                      .filter((e) => e.scale > n.maxScale)
                      .sort((e, t) => (e.scale > t.scale ? 1 : -1))[0])),
              (i.x = i.y = a.resolution),
              (r.width = Math.ceil((t.xmax - t.xmin) / i.x - 0.1)),
              (r.height = Math.ceil((t.ymax - t.ymin) / i.y - 0.1))),
              a || (a = l);
            const u = e.lodAt(
              Math.min.apply(
                null,
                e.lods.map((e) => e.level),
              ),
            );
            'Map' === this.tileType
              ? (this._levelOffset = e.lods[0].level)
              : 0 !== n.minScale &&
                'Elevation' === this.tileType &&
                ((o = e.lods.filter((e) => Math.abs(e.scale - n.minScale) < s)[0]),
                (this._levelOffset = o.level - u.level)),
              o || (o = u);
            const c = Math.max(i.x, i.y);
            (Math.abs(i.x - i.y) > s || !e.lods.some((e) => Math.abs(e.resolution - c) < s)) &&
              ((i.x = i.y = a.resolution),
              (r.width = Math.ceil((t.xmax - t.xmin) / i.x - 0.1)),
              (r.height = Math.ceil((t.ymax - t.ymin) / i.y - 0.1)));
            const f = a.level - o.level,
              [h, d] = e.size,
              m = [];
            e.lods.forEach((e) => {
              e.level >= o.level &&
                e.level <= a.level &&
                m.push({ x: e.resolution, y: e.resolution });
            }),
              m.sort((e, t) => e.x - t.x);
            const p = this.computeBlockBoundary(t, h, d, e.origin, m, f),
              y = m.length > 1 ? m.slice(1) : null;
            (r.storageInfo = new D.R({
              blockWidth: e.size[0],
              blockHeight: e.size[1],
              pyramidBlockWidth: e.size[0],
              pyramidBlockHeight: e.size[1],
              pyramidResolutions: y,
              compression: e.format,
              origin: e.origin,
              firstPyramidLevel: 1,
              maximumPyramidLevel: f,
              tileInfo: e,
              blockBoundary: p,
            })),
              this._fixGCSShift(r),
              this._set('rasterInfo', r);
          }
          if (n.capabilities.toLowerCase().indexOf('tilemap') > -1) {
            const e = {
              tileInfo: r.storageInfo.tileInfo,
              parsedUrl: (0, _e.mN)(this.url),
              url: this.url,
              tileServers: [],
              type: 'tile',
            };
            this._tilemapCache = new Re.T({ layer: e });
          }
        }
        async fetchRawTile(e, t, i, n = {}) {
          const { storageInfo: r, extent: s } = this.rasterInfo,
            a = r.maximumPyramidLevel - e + this._levelOffset,
            o = `${this.url}/tile/${a}/${t}/${i}`,
            l = this._slices ? { sliceId: n.sliceId || 0 } : null,
            { data: u } = await this.request(o, {
              query: l,
              responseType: 'array-buffer',
              signal: n.signal,
            });
          if (!u) return null;
          const c = await this.decodePixelBlock(u, {
              width: r.tileInfo.size[0],
              height: r.tileInfo.size[1],
              planes: null,
              pixelType: null,
              isPoint: 'Elevation' === this.tileType,
            }),
            f = r.blockBoundary[e];
          if (
            'jpg' !== r.compression ||
            (i > f.minCol && i < f.maxCol && t > f.minRow && t < f.maxRow)
          )
            return c;
          const { origin: h, blockWidth: d, blockHeight: m } = r,
            { x: p, y } = this.getPyramidPixelSize(e),
            g = Math.round((s.xmin - h.x) / p) % d,
            x = Math.round((s.xmax - h.x) / p) % d,
            w = Math.round((h.y - s.ymax) / y) % m,
            v = Math.round((h.y - s.ymin) / y) % m,
            b = i === f.minCol ? g : 0,
            I = t === f.minRow ? w : 0,
            C = i === f.maxCol ? x : d,
            _ = t === f.maxRow ? v : m;
          return (0, se.i)(c, { x: b, y: I }, { width: C - b, height: _ - I }), c;
        }
        getSliceIndex(e) {
          if (null == e || !e.length || !this._slices) return null;
          const t = e;
          for (let e = 0; e < this._slices.length; e++) {
            const i = this._slices[e].multidimensionalDefinition;
            if (
              i.length === t.length &&
              !i.some((e) => {
                const i = t.filter(
                  (t) => e.variableName === t.variableName && t.dimensionName === e.dimensionName,
                )[0];
                return (
                  !i ||
                  (Array.isArray(e.values[0]) ? e.values[0][0] : e.values[0]) !==
                    (Array.isArray(i.values[0]) ? i.values[0][0] : i.values[0])
                );
              })
            )
              return e;
          }
          return null;
        }
        async fetchVariableStatisticsHistograms(e, t) {
          const i = this.request(this.url + '/statistics', {
              query: { variable: e, f: 'json' },
              signal: t,
            }).then((e) => {
              var t;
              return null == (t = e.data) ? void 0 : t.statistics;
            }),
            n = this.request(this.url + '/histograms', {
              query: { variable: e, f: 'json' },
              signal: t,
            }).then((e) => {
              var t;
              return null == (t = e.data) ? void 0 : t.histograms;
            }),
            r = await Promise.all([i, n]);
          return (
            r[0] &&
              r[0].forEach((e) => {
                (e.avg = e.mean), (e.stddev = e.standardDeviation);
              }),
            { statistics: r[0] || null, histograms: r[1] || null }
          );
        }
        async computeBestPyramidLevelForLocation(e, t = {}) {
          if (!this._tilemapCache) return 0;
          let i = this.identifyPixelLocation(e, 0, (0, o.u)(t.datumTransformation));
          if (null === i) return null;
          let n = 0;
          const { maximumPyramidLevel: r } = this.rasterInfo.storageInfo;
          let s = r - n + this._levelOffset;
          const a = i.srcLocation;
          for (; s >= 0; ) {
            try {
              if ('available' === (await this._tilemapCache.fetchAvailability(s, i.row, i.col, t)))
                break;
            } catch {}
            if (
              (s--,
              n++,
              (i = this.identifyPixelLocation(a, n, (0, o.u)(t.datumTransformation))),
              null === i)
            )
              return null;
          }
          return -1 === s || null == i ? null : n;
        }
        async _fetchRasterInfo(e) {
          const t = this.sourceJSON,
            i = Math.ceil((t.extent.xmax - t.extent.xmin) / t.pixelSizeX - 0.1),
            n = Math.ceil((t.extent.ymax - t.extent.ymin) / t.pixelSizeY - 0.1),
            r = b.Z.fromJSON(t.spatialReference || t.extent.spatialReference);
          if ('Map' === this.tileType)
            return new D.Z({
              width: i,
              height: n,
              bandCount: 3,
              extent: k.Z.fromJSON(t.extent),
              spatialReference: r,
              pixelSize: new N.Z({ x: t.pixelSizeX, y: t.pixelSizeY, spatialReference: r }),
              pixelType: 'u8',
              statistics: null,
              keyProperties: { DataType: 'processed' },
            });
          const { slice: s, signal: a } = e,
            o =
              !!t.hasRasterAttributeTable &&
              this.request(this.url + '/rasterAttributeTable', {
                query: { slice: s, f: 'json' },
                signal: a,
              })
                .then((e) => Ce.default.fromJSON(e.data))
                .catch(() => null),
            l =
              !!t.hasColormap &&
              this.request(this.url + '/colormap', {
                query: { slice: s, f: 'json' },
                signal: a,
              }).then((e) => {
                var t;
                return null == (t = e.data) ? void 0 : t.colormap;
              }),
            u =
              !!t.hasHistograms &&
              this.request(this.url + '/histograms', {
                query: { slice: s, f: 'json' },
                signal: a,
              }).then((e) => {
                var t;
                return null == (t = e.data) ? void 0 : t.histograms;
              }),
            c = this.request(this.url + '/keyProperties', { query: { f: 'json' }, signal: a })
              .then((e) => e.data)
              .catch(() => {}),
            f = !!t.hasMultidimensions && this._fetchMultidimensionalInfo(),
            h =
              !!t.hasMultidimensions &&
              this.request(this.url + '/slices', { query: { f: 'json' }, signal: a })
                .then((e) => e.data && e.data.slices)
                .catch(() => {});
          return Promise.all([o, l, u, c, f, h]).then((e) => {
            let s = null;
            if (t.minValues && t.minValues.length === t.bandCount) {
              s = [];
              for (let e = 0; e < t.minValues.length; e++)
                s.push({
                  min: t.minValues[e],
                  max: t.maxValues[e],
                  avg: t.meanValues[e],
                  stddev: t.stdvValues[e],
                });
            }
            return (
              (this._slices = e[5] || null),
              new D.Z({
                width: i,
                height: n,
                bandCount: t.bandCount,
                extent: k.Z.fromJSON(t.extent),
                spatialReference: r,
                pixelSize: new N.Z({ x: t.pixelSizeX, y: t.pixelSizeY, spatialReference: r }),
                pixelType: t.pixelType.toLowerCase(),
                statistics: s,
                attributeTable: e[0] || null,
                colormap: e[1] || null,
                histograms: e[2] || null,
                keyProperties: e[3] || {},
                multidimensionalInfo: e[4] || null,
              })
            );
          });
        }
        async _fetchMultidimensionalInfo(e) {
          var t;
          const i = await this.request(this.url + '/multidimensionalInfo', {
            query: { f: 'json' },
            signal: e,
          }).then((e) => {
            var t;
            return null == (t = e.data) ? void 0 : t.multidimensionalInfo;
          });
          return (
            null != (t = i.variables) &&
              t.length &&
              i.variables.forEach((e) => {
                var t;
                null != (t = e.statistics) &&
                  t.length &&
                  e.statistics.forEach((e) => {
                    (e.avg = e.mean), (e.stddev = e.standardDeviation);
                  });
              }),
            i
          );
        }
        _fixScaleInServiceInfo() {
          const { sourceJSON: e } = this;
          e.minScale && e.minScale < 0 && (e.minScale = 0),
            e.maxScale && e.maxScale < 0 && (e.maxScale = 0);
        }
        _fixGCSShift(e) {
          const { extent: t, spatialReference: i } = e;
          0 === t.xmin &&
            360 === t.xmax &&
            i.wkid &&
            i.isGeographic &&
            ((e.nativeExtent = e.extent),
            (e.transform = new Xe()),
            (e.extent = e.transform.forwardTransform(t)));
        }
      };
      (0, n._)(
        [(0, c.Cb)({ type: String, json: { write: !0 } })],
        Ke.prototype,
        'datasetFormat',
        void 0,
      ),
        (0, n._)([(0, c.Cb)()], Ke.prototype, 'tileType', void 0),
        (Ke = (0, n._)([(0, p.j)('esri.layers.support.rasterDatasets.ImageServerRaster')], Ke));
      var Qe = Ke;
      const et = new Map();
      et.set('Int8', 's8'),
        et.set('UInt8', 'u8'),
        et.set('Int16', 's16'),
        et.set('UInt16', 'u16'),
        et.set('Int32', 's32'),
        et.set('UInt32', 'u32'),
        et.set('Float32', 'f32'),
        et.set('Float64', 'f32'),
        et.set('Double64', 'f32');
      const tt = new Map();
      tt.set('lerc', '.lrc'),
        tt.set('none', '.til'),
        tt.set('deflate', '.pzp'),
        tt.set('jpeg', '.jzp');
      let it = class extends ue {
        constructor() {
          super(...arguments),
            (this._files = null),
            (this._storageIndex = null),
            (this.datasetFormat = 'MRF');
        }
        async open(e) {
          var t;
          await this.init(), (this.datasetName = this.url.slice(this.url.lastIndexOf('/') + 1));
          const i = e ? (0, o.u)(e.signal) : null,
            n = await this.request(this.url, { responseType: 'xml', signal: i }),
            { rasterInfo: r, files: s } = this._parseHeader(n.data);
          if (-1 === (null == (t = this.ioConfig.skipExtensions) ? void 0 : t.indexOf('aux.xml'))) {
            const t = await this._fetchAuxiliaryData(e);
            var a;
            null != t &&
              ((r.statistics = null != (a = t.statistics) ? a : r.statistics),
              (r.histograms = t.histograms),
              t.histograms && !(0, o.i)(r.statistics) && (r.statistics = (0, se.h)(t.histograms)));
          }
          this._set('rasterInfo', r), (this._files = s);
          const l = await this.request(s.index, { responseType: 'array-buffer', signal: i });
          this._storageIndex = this._parseIndex(l.data);
          let u,
            c,
            f = 0,
            h = -1;
          const { blockWidth: d, blockHeight: m, compression: p } = this.rasterInfo.storageInfo,
            y = this.rasterInfo.storageInfo.pyramidScalingFactor,
            { width: g, height: x, bandCount: w } = this.rasterInfo,
            v = [],
            b = 'none' === p ? 1 : w;
          for (; f < this._storageIndex.length; )
            h++,
              (u = Math.ceil(g / d / y ** h)),
              (c = Math.ceil(x / m / y ** h)),
              (f += u * c * b * 4),
              v.push({ maxRow: c, maxCol: u, minCol: 0, minRow: 0 });
          (this.rasterInfo.storageInfo.blockBoundary = v),
            h > 0 &&
              ((this.rasterInfo.storageInfo.firstPyramidLevel = 1),
              (this.rasterInfo.storageInfo.maximumPyramidLevel = h)),
            this.updateTileInfo();
        }
        async fetchRawTile(e, t, i, n = {}) {
          const {
              blockWidth: r,
              blockHeight: s,
              blockBoundary: a,
              compression: o,
            } = this.rasterInfo.storageInfo,
            l = a[e];
          if (!l || l.maxRow < t || l.maxCol < i || l.minRow > t || l.minCol > i) return null;
          const { bandCount: u, pixelType: c } = this.rasterInfo,
            { ranges: f, actualTileWidth: h, actualTileHeight: d } = this._getTileLocation(e, t, i);
          if (!f || 0 === f.length) return null;
          if (0 === f[0].from && 0 === f[0].to) {
            const e = new Uint8Array(r * s);
            return new Se.Z({ width: r, height: s, pixels: null, mask: e, validPixelCount: 0 });
          }
          const { bandIds: m } = this.ioConfig,
            p = 'none' === o ? 1 : u,
            y = [];
          let g = 0;
          for (g = 0; g < p; g++)
            (!m || m.indexOf[g] > -1) &&
              y.push(
                this.request(this._files.data, {
                  range: { from: f[g].from, to: f[g].to },
                  responseType: 'array-buffer',
                  signal: n.signal,
                }),
              );
          const x = await Promise.all(y),
            w = x.map((e) => e.data.byteLength).reduce((e, t) => e + t),
            v = new Uint8Array(w);
          let b = 0;
          for (g = 0; g < p; g++) v.set(new Uint8Array(x[g].data), b), (b += x[g].data.byteLength);
          const I = 'lerc' === this.rasterInfo.storageInfo.compression ? 'lerc' : 'bip',
            C = await this.decodePixelBlock(v.buffer, {
              width: r,
              height: s,
              format: I,
              pixelType: c,
            });
          let _ = 0,
            T = 0;
          if (h !== r || d !== s) {
            let e = C.mask;
            if (e)
              for (g = 0; g < s; g++)
                if (((T = g * r), g < d)) for (_ = h; _ < r; _++) e[T + _] = 0;
                else for (_ = 0; _ < r; _++) e[T + _] = 0;
            else
              for (e = new Uint8Array(r * s), C.mask = e, g = 0; g < d; g++)
                for (T = g * r, _ = 0; _ < h; _++) e[T + _] = 1;
          }
          return C;
        }
        _parseIndex(e) {
          if (e.byteLength % 16 > 0) throw 'invalid array buffer must be multiples of 16';
          let t, i, n, r, s, a;
          if (M.i) {
            for (
              i = new Uint8Array(e),
                r = new ArrayBuffer(e.byteLength),
                n = new Uint8Array(r),
                s = 0;
              s < e.byteLength / 4;
              s++
            )
              for (a = 0; a < 4; a++) n[4 * s + a] = i[4 * s + 3 - a];
            t = new Uint32Array(r);
          } else t = new Uint32Array(e);
          return t;
        }
        _getTileLocation(e, t, i) {
          const {
              blockWidth: n,
              blockHeight: r,
              pyramidScalingFactor: s,
              compression: a,
            } = this.rasterInfo.storageInfo,
            { width: o, height: l, bandCount: u } = this.rasterInfo,
            c = 'none' === a ? 1 : u;
          let f,
            h,
            d,
            m = 0,
            p = 0;
          for (d = 0; d < e; d++)
            (p = s ** d), (f = Math.ceil(o / n / p)), (h = Math.ceil(l / r / p)), (m += f * h);
          (p = s ** e),
            (f = Math.ceil(o / n / p)),
            (h = Math.ceil(l / r / p)),
            (m += t * f + i),
            (m *= 4 * c);
          const y = this._storageIndex.subarray(m, m + 4 * c);
          let g = 0,
            x = 0;
          const w = [];
          for (let e = 0; e < c; e++)
            (g = y[4 * e + 0] * 2 ** 32 + y[4 * e + 1]),
              (x = g + y[4 * e + 2] * 2 ** 32 + y[4 * e + 3]),
              w.push({ from: g, to: x });
          return {
            ranges: w,
            actualTileWidth: i < f - 1 ? n : Math.ceil(o / p) - n * (f - 1),
            actualTileHeight: t < h - 1 ? r : Math.ceil(l / p) - r * (h - 1),
          };
        }
        _parseHeader(e) {
          const t = fe(e, 'MRF_META/Raster');
          if (!t) throw new a.Z('mrf:open', 'not a valid MRF format');
          const i = fe(t, 'Size'),
            n = parseInt(i.getAttribute('x'), 10),
            r = parseInt(i.getAttribute('y'), 10),
            s = parseInt(i.getAttribute('c'), 10),
            o = (he(t, 'Compression') || 'none').toLowerCase();
          if (!o || -1 === ['none', 'lerc'].indexOf(o))
            throw new a.Z('mrf:open', 'currently does not support compression ' + o);
          const l = he(t, 'DataType') || 'UInt8',
            u = et.get(l);
          if (null == u) throw new a.Z('mrf:open', 'currently does not support pixel type ' + l);
          const c = fe(t, 'PageSize'),
            f = parseInt(c.getAttribute('x'), 10),
            h = parseInt(c.getAttribute('y'), 10),
            d = fe(t, 'DataValues');
          let m, p;
          if (
            (d &&
              ((p = d.getAttribute('NoData')),
              null != p &&
                (m = p
                  .trim()
                  .split(' ')
                  .map((e) => parseFloat(e)))),
            fe(e, 'MRF_META/CachedSource'))
          )
            throw new a.Z(
              'mrf:open',
              'currently does not support MRF referencing other data files',
            );
          const y = fe(e, 'MRF_META/GeoTags'),
            g = fe(y, 'BoundingBox');
          if (null == g) throw new a.Z('mrf:open', 'missing node MRF_META/GeoTags/BoundingBox');
          const x = parseFloat(g.getAttribute('minx')),
            w = parseFloat(g.getAttribute('miny')),
            v = parseFloat(g.getAttribute('maxx')),
            I = parseFloat(g.getAttribute('maxy')),
            C = he(y, 'Projection') || '',
            _ = he(e, 'datafile'),
            T = he(e, 'IndexFile');
          let R;
          if ('LOCAL_CS[]' !== C)
            if (C.toLowerCase().startsWith('epsg:')) {
              const e = Number(C.slice(5));
              isNaN(e) || 0 === e || (R = new b.Z({ wkid: e }));
            } else R = We(C);
          const S = new k.Z(x, w, v, I);
          S.spatialReference = R;
          const M = fe(e, 'MRF_META/Rsets'),
            F = parseInt((M && M.getAttribute('scale')) || '2', 10),
            P = new D.R({
              origin: new N.Z({ x: S.xmin, y: S.ymax, spatialReference: R }),
              blockWidth: f,
              blockHeight: h,
              pyramidBlockWidth: f,
              pyramidBlockHeight: h,
              compression: o,
              pyramidScalingFactor: F,
            }),
            O = new N.Z({ x: (v - x) / n, y: (I - w) / r, spatialReference: R });
          return {
            rasterInfo: new D.Z({
              width: n,
              height: r,
              extent: S,
              spatialReference: R,
              bandCount: s,
              pixelType: u,
              pixelSize: O,
              noDataValue: m,
              storageInfo: P,
            }),
            files: {
              mrf: this.url,
              index: T || this.url.replace('.mrf', '.idx'),
              data: _ || this.url.replace('.mrf', tt.get(o)),
            },
          };
        }
        async _fetchAuxiliaryData(e) {
          try {
            const { data: t } = await this.request(this.url + '.aux.xml', {
              responseType: 'xml',
              signal: null == e ? void 0 : e.signal,
            });
            return Ue(t);
          } catch {
            return null;
          }
        }
      };
      (0, n._)([(0, c.Cb)()], it.prototype, '_files', void 0),
        (0, n._)([(0, c.Cb)()], it.prototype, '_storageIndex', void 0),
        (0, n._)(
          [(0, c.Cb)({ type: String, json: { write: !0 } })],
          it.prototype,
          'datasetFormat',
          void 0,
        ),
        (it = (0, n._)([(0, p.j)('esri.layers.support.rasterIO.MRFRaster')], it));
      var nt = it;
      const rt = function (e, t) {
          const i = e.get(t);
          return i && i.values;
        },
        st = function (e, t) {
          const i = e.get(t);
          return i && i.values[0];
        };
      let at = class extends ue {
        constructor() {
          super(...arguments),
            (this._files = null),
            (this._headerInfo = null),
            (this._bufferSize = 1048576),
            (this.datasetFormat = 'TIFF');
        }
        async open(e) {
          var t, i, n;
          await this.init();
          const r = e ? (0, o.u)(e.signal) : null,
            { data: s } = await this.request(this.url, {
              range: { from: 0, to: this._bufferSize },
              responseType: 'array-buffer',
              signal: r,
            });
          if (!s) throw new a.Z('tiffraster:open', 'failed to open url ' + this.url);
          this.datasetName = this.url.slice(this.url.lastIndexOf('/') + 1);
          const { littleEndian: l, firstIFD: u, isBigTiff: c } = (0, M.p)(s),
            f = [];
          await this.readIFDs(f, s, l, u, 0, c ? 8 : 4, r);
          const h = (0, M.a)(f),
            {
              width: d,
              height: m,
              tileWidth: p,
              tileHeight: y,
              planes: g,
              pixelType: x,
              compression: w,
              firstPyramidLevel: v,
              maximumPyramidLevel: I,
              pyramidBlockWidth: C,
              pyramidBlockHeight: _,
              tileBoundary: T,
              affine: R,
              metadata: S,
            } = h;
          let F = We(
              (null == (t = h.extent.spatialReference) ? void 0 : t.wkt) ||
                (null == (i = h.extent.spatialReference) ? void 0 : i.wkid),
            ),
            P = !1;
          null == F && ((P = !0), (F = new b.Z({ wkid: 3857 })));
          const O = new k.Z({ ...h.extent, spatialReference: F }),
            B = new N.Z(O ? { x: O.xmin, y: O.ymax, spatialReference: F } : { x: 0, y: 0 }),
            z = new D.R({
              blockWidth: p,
              blockHeight: y,
              pyramidBlockWidth: C,
              pyramidBlockHeight: _,
              compression: w,
              origin: B,
              firstPyramidLevel: v,
              maximumPyramidLevel: I,
              blockBoundary: T,
            }),
            E = new N.Z({
              x: (O.xmax - O.xmin) / d,
              y: (O.ymax - O.ymin) / m,
              spatialReference: F,
            }),
            A = S ? { BandProperties: S.bandProperties, DataType: S.dataType } : {},
            L = new D.Z({
              width: d,
              height: m,
              bandCount: g,
              pixelType: x,
              compression: w,
              pixelSize: E,
              storageInfo: z,
              spatialReference: F,
              isPseudoSpatialReference: P,
              keyProperties: A,
              extent: O,
              statistics: S ? S.statistics : null,
            });
          if (
            (null != R &&
              R.length &&
              ((L.nativeExtent = new k.Z({
                xmin: -0.5,
                ymin: 0.5 - m,
                xmax: d - 0.5,
                ymax: 0.5,
                spatialReference: F,
              })),
              (L.transform = new Ne({
                polynomialOrder: 1,
                forwardCoefficients: [R[2] + R[0] / 2, R[5] - R[3] / 2, R[0], R[3], -R[1], -R[4]],
              })),
              (L.extent = L.transform.forwardTransform(L.nativeExtent)),
              (L.pixelSize = new N.Z({
                x: (O.xmax - O.xmin) / d,
                y: (O.ymax - O.ymin) / m,
                spatialReference: F,
              })),
              (z.origin.x = -0.5),
              (z.origin.y = 0.5)),
            null == (n = this.ioConfig.skipExtensions) || !n.includes('aux.xml'))
          ) {
            const t = await this._fetchAuxiliaryData(e);
            if (null != t) {
              var H;
              if (
                ((L.statistics = null != (H = t.statistics) ? H : L.statistics),
                (L.histograms = t.histograms),
                t.histograms && !(0, o.i)(L.statistics) && (L.statistics = (0, se.h)(t.histograms)),
                t.transform && !R)
              ) {
                (L.transform = t.transform), (L.nativeExtent = L.extent);
                const e = L.transform.forwardTransform(L.nativeExtent);
                (L.pixelSize = new N.Z({
                  x: (e.xmax - e.xmin) / d,
                  y: (e.ymax - e.ymin) / m,
                  spatialReference: F,
                })),
                  (L.extent = e);
              }
              L.spatialReference || (L.spatialReference = t.spatialReference);
            }
          }
          if (
            (this._set('rasterInfo', L),
            (this._headerInfo = { littleEndian: l, isBigTiff: c, ifds: f, ...h }),
            !this._headerInfo.isSupported)
          )
            throw new a.Z(
              'tiffraster:open',
              'this tiff is not supported: ' + this._headerInfo.message,
            );
          this.updateTileInfo();
        }
        async fetchRawTile(e, t, i, n = {}) {
          var r;
          if (null == (r = this._headerInfo) || !r.isSupported || this.isBlockOutside(e, t, i))
            return null;
          const s = this.getTileLocation(e, t, i);
          if (!s) return null;
          const { ranges: a, actualTileWidth: o, actualTileHeight: l, ifd: u } = s,
            c = a.map((e) =>
              this.request(this.url, { range: e, responseType: 'array-buffer', signal: n.signal }),
            ),
            f = await Promise.all(c),
            h = f.map((e) => e.data.byteLength).reduce((e, t) => e + t),
            d = 1 === f.length ? f[0].data : new ArrayBuffer(h),
            m = [0],
            p = [0];
          if (f.length > 1) {
            const e = new Uint8Array(d);
            for (let t = 0, i = 0; t < f.length; t++) {
              const n = f[t].data;
              e.set(new Uint8Array(n), i), (m[t] = i), (i += n.byteLength), (p[t] = n.byteLength);
            }
          }
          const { blockWidth: y, blockHeight: g } = this.getBlockWidthHeight(e),
            x = await this.decodePixelBlock(d, {
              format: 'tiff',
              customOptions: { headerInfo: this._headerInfo, ifd: u, offsets: m, sizes: p },
              width: y,
              height: g,
              planes: null,
              pixelType: null,
            });
          let w, v, b;
          if (o !== y || l !== g) {
            let e = x.mask;
            if (e)
              for (w = 0; w < g; w++)
                if (((b = w * y), w < l)) for (v = o; v < y; v++) e[b + v] = 0;
                else for (v = 0; v < y; v++) e[b + v] = 0;
            else
              for (e = new Uint8Array(y * g), x.mask = e, w = 0; w < l; w++)
                for (b = w * y, v = 0; v < o; v++) e[b + v] = 1;
          }
          return x;
        }
        async readIFDs(e, t, i, n, r, s = 4, a) {
          if (!n) return null;
          (n >= t.byteLength || n < 0) &&
            ((t = (
              await this.request(this.url, {
                range: { from: n + r, to: n + r + this._bufferSize },
                responseType: 'array-buffer',
                signal: a,
              })
            ).data),
            (r = n + r),
            (n = 0));
          const o = await this.readIFD(t, i, n, r, M.T.TIFF_TAGS, s, a);
          if ((e.push(o.ifd), !o.nextIFD)) return null;
          await this.readIFDs(e, t, i, o.nextIFD - r, r, s, a);
        }
        async readIFD(e, t, i, n, r = M.T.TIFF_TAGS, s = 4, a) {
          if (!e) return null;
          const o = (0, M.c)(e, t, i, n, r, s);
          if (o.success) {
            const i = [];
            if (
              (o.ifd.forEach((e) => {
                e.values || i.push(e);
              }),
              i.length > 0)
            ) {
              const r = i.map((e) => e.offlineOffsetSize),
                s = Math.min.apply(
                  null,
                  r.map((e) => e[0]),
                );
              if (
                Math.min.apply(
                  null,
                  r.map((e) => e[0] + e[1]),
                ) -
                  s <=
                this._bufferSize
              ) {
                const { data: r } = await this.request(this.url, {
                  range: { from: s, to: s + this._bufferSize },
                  responseType: 'array-buffer',
                  signal: a,
                });
                (e = r), (n = s), i.forEach((i) => (0, M.e)(e, t, i, n));
              }
            }
            if (o.ifd.has('GEOKEYDIRECTORY')) {
              const i = o.ifd.get('GEOKEYDIRECTORY'),
                r = i.values;
              if (r && r.length > 4) {
                const s = r[0] + '.' + r[1] + '.' + r[2],
                  o = await this.readIFD(e, t, i.valueOffset + 6 - n, n, M.T.GEO_KEYS, 2, a);
                (i.data = o.ifd),
                  i.data &&
                    i.data.set('GEOTIFFVersion', {
                      id: 0,
                      type: 2,
                      valueCount: 1,
                      valueOffset: null,
                      values: [s],
                    });
              }
            }
            return o;
          }
          if (o.requiredBufferSize && o.requiredBufferSize !== e.byteLength) {
            const i = await this.request(this.url, {
              range: { from: n, to: n + o.requiredBufferSize + 4 },
              responseType: 'array-buffer',
              signal: a,
            });
            return (e = i.data).byteLength < o.requiredBufferSize
              ? null
              : this.readIFD(e, t, 0, n, M.T.TIFF_TAGS, 4, a);
          }
        }
        getTileLocation(e, t, i) {
          const { firstPyramidLevel: n, blockBoundary: r } = this.rasterInfo.storageInfo,
            s = 0 === e ? 0 : e - (n - 1),
            a = this._headerInfo.ifds[s];
          if (!a) return null;
          const o = (0, M.f)(a, this._headerInfo),
            l = rt(a, 'TILEOFFSETS');
          if (void 0 === l) return null;
          const u = rt(a, 'TILEBYTECOUNTS'),
            { minRow: c, minCol: f, maxRow: h, maxCol: d } = r[s];
          if (t > h || i > d || t < c || i < f) return null;
          const m = st(a, 'IMAGEWIDTH'),
            p = st(a, 'IMAGELENGTH'),
            y = st(a, 'TILEWIDTH'),
            g = st(a, 'TILELENGTH'),
            x = o ? this.rasterInfo.bandCount : 1,
            w = x * t * (d + 1) + i,
            v = [{ from: l[w], to: l[w + x - 1] + u[w + x - 1] - 1 }];
          if (o) {
            let e = !0;
            for (let t = 0; t < x; t++)
              if (l[w + t] + u[w + t] !== l[w + t + 1]) {
                e = !1;
                break;
              }
            if (!e)
              for (let e = 0; e < x; e++) v[e] = { from: l[w + e], to: l[w + e] + u[w + e] - 1 };
          }
          const b = l[w],
            I = u[w];
          return null == b || null == I
            ? null
            : {
                ranges: v,
                ifd: a,
                actualTileWidth: i === d ? m % y : y,
                actualTileHeight: t === h ? p % g : g,
              };
        }
        async _fetchAuxiliaryData(e) {
          try {
            const { data: t } = await this.request(this.url + '.aux.xml', {
              responseType: 'xml',
              signal: null == e ? void 0 : e.signal,
            });
            return Ue(t);
          } catch {
            return null;
          }
        }
      };
      (0, n._)([(0, c.Cb)()], at.prototype, '_files', void 0),
        (0, n._)([(0, c.Cb)()], at.prototype, '_headerInfo', void 0),
        (0, n._)([(0, c.Cb)()], at.prototype, '_bufferSize', void 0),
        (0, n._)(
          [(0, c.Cb)({ type: String, json: { write: !0 } })],
          at.prototype,
          'datasetFormat',
          void 0,
        ),
        (at = (0, n._)([(0, p.j)('esri.layers.support.rasterDatasets.TIFFRaster')], at));
      var ot = at;
      const lt = new Map();
      function ut() {
        return {
          enabled:
            !this.loaded ||
            ('RasterTileServer' === this.raster.datasetFormat && 'Raster' === this.raster.tileType),
        };
      }
      lt.set('CRF', { desc: 'Cloud Raster Format', constructor: Ze }),
        lt.set('MRF', { desc: 'Meta Raster Format', constructor: nt }),
        lt.set('TIFF', { desc: 'GeoTIFF', constructor: ot }),
        lt.set('RasterTileServer', { desc: 'Raster Tile Server', constructor: Qe }),
        lt.set('JPG', { desc: 'JPG Raster Format', constructor: Ve }),
        lt.set('PNG', { desc: 'PNG Raster Format', constructor: Ve }),
        lt.set('GIF', { desc: 'GIF Raster Format', constructor: Ve }),
        lt.set('BMP', { desc: 'BMP Raster Format', constructor: Ve });
      let ct = class extends (0, g.B)(
        (0, we.S)((0, xe.R)((0, ye.O)((0, ge.P)((0, x.C)(oe((0, l.M)(y.Z))))))),
      ) {
        constructor(...e) {
          super(...e),
            (this.bandIds = null),
            (this.interpolation = null),
            (this.legendEnabled = !0),
            (this.isReference = null),
            (this.listMode = 'show'),
            (this.sourceJSON = null),
            (this.version = null),
            (this.title = null),
            (this.type = 'imagery-tile'),
            (this.operationalLayerType = 'ArcGISTiledImageServiceLayer'),
            (this.popupEnabled = !0),
            (this.popupTemplate = null),
            (this.fields = null);
        }
        normalizeCtorArgs(e, t) {
          return 'string' == typeof e ? { url: e, ...t } : e;
        }
        load(e) {
          const t = (0, o.i)(e) ? e.signal : null;
          return (
            this.addResolvingPromise(
              this.loadFromPortal({ supportedTypes: ['Image Service'] }, e)
                .catch(u.r9)
                .then(() => this._openRaster(t)),
            ),
            Promise.resolve(this)
          );
        }
        get defaultPopupTemplate() {
          return this.createPopupTemplate();
        }
        get rasterFields() {
          var e, t;
          let i = [
            new ve.Z({
              name: 'Raster.ServicePixelValue',
              alias: 'Pixel Value',
              domain: null,
              editable: !1,
              length: 50,
              type: 'string',
            }),
          ];
          const n =
            null == (e = this.rasterInfo) || null == (t = e.attributeTable) ? void 0 : t.fields;
          if (n) {
            const e = n
              .filter((e) => 'oid' !== e.type && 'value' !== e.name.toLowerCase())
              .map((e) => {
                const t = e.clone();
                return (t.name = 'Raster.' + e.name), t;
              });
            i = i.concat(e);
          }
          return i;
        }
        set renderer(e) {
          this._set('renderer', e), this.updateRenderer();
        }
        readRenderer(e, t, i) {
          const n =
              t &&
              t.layerDefinition &&
              t.layerDefinition.drawingInfo &&
              t.layerDefinition.drawingInfo.renderer,
            r = (0, s.ij)(n, i) || void 0;
          if (null != r) return r;
        }
        createPopupTemplate(e) {
          return (0, Me.eZ)({ fields: this.rasterFields, title: this.title }, e);
        }
        write(e, t) {
          const { raster: i } = this;
          if (
            this.loaded
              ? 'RasterTileServer' === i.datasetFormat &&
                ('Raster' === i.tileType || 'Map' === i.tileType)
              : this.url && /\/ImageServer(\/|\/?$)/i.test(this.url)
          )
            return super.write(e, t);
          if (t && t.messages) {
            const e = `${t.origin}/${t.layerContainerType || 'operational-layers'}`;
            t.messages.push(
              new a.Z(
                'layer:unsupported',
                `Layers (${this.title}, ${this.id}) of type '${this.declaredClass}' are not supported in the context of '${e}'`,
                { layer: this },
              ),
            );
          }
          return null;
        }
        async _openRaster(e) {
          this.raster
            ? (this.raster.rasterInfo || (await this.raster.open()), (this.url = this.raster.url))
            : (this.raster = await class {
                static get supportedFormats() {
                  const e = new Set();
                  return lt.forEach((t, i) => e.add(i)), e;
                }
                static async open(e) {
                  const { url: t, ioConfig: i, sourceJSON: n } = e;
                  let r = e.datasetFormat;
                  null == r &&
                    t.lastIndexOf('.') &&
                    (r = t.slice(t.lastIndexOf('.') + 1).toUpperCase()),
                    'OVR' === r || 'TIF' === r
                      ? (r = 'TIFF')
                      : ('JPG' !== r && 'JPEG' !== r && 'JFIF' !== r) || (r = 'JPG'),
                    t.toLowerCase().indexOf('/imageserver') > -1 &&
                      -1 === t.toLowerCase().indexOf('/wcsserver') &&
                      (r = 'RasterTileServer');
                  const s = {
                    url: t,
                    sourceJSON: n,
                    datasetFormat: r,
                    ioConfig: i || { bandIds: null, sampling: null },
                  };
                  let o, l;
                  if (this.supportedFormats.has(r))
                    return (
                      (o = lt.get(r).constructor),
                      (l = new o(s)),
                      await l.open({ signal: e.signal }),
                      l
                    );
                  if (r) throw new a.Z('rasterfactory:open', 'not a supported format ' + r);
                  const u = Array.from(lt.keys());
                  let c = 0;
                  const f = function () {
                    return (
                      (r = u[c++]),
                      r
                        ? ((o = lt.get(r).constructor),
                          (l = new o(s)),
                          l
                            .open({ signal: e.signal })
                            .then(() => l)
                            .catch(() => f()))
                        : null
                    );
                  };
                  return f();
                }
                static register(e, t, i) {
                  lt.has(e.toUpperCase()) || lt.set(e.toUpperCase(), { desc: t, constructor: i });
                }
              }.open({
                url: this.url,
                sourceJSON: this.sourceJSON,
                ioConfig: {
                  sampling: 'closest',
                  ...this.ioConfig,
                  customFetchParameters: this.customParameters,
                },
                signal: e,
              }));
          const { rasterInfo: t } = this.raster;
          if (!t) throw new a.Z('imagery-tile-layer:load', 'cannot load resources on ' + this.url);
          (this.sourceJSON = this.sourceJSON || this.raster.sourceJSON),
            null != this.sourceJSON &&
              (this._set('version', this.sourceJSON.currentVersion),
              this._set('copyright', this.sourceJSON.copyrightText)),
            null == this.title && (this.title = this.raster.datasetName),
            'Map' === this.raster.tileType && (this.popupEnabled = !1),
            this._configDefaultSettings(),
            this.watch('customParameters', (e) => (this.raster.ioConfig.customFetchParameters = e));
        }
      };
      (0, n._)(
        [(0, c.Cb)({ type: [f.I], json: { write: { overridePolicy: ut } } })],
        ct.prototype,
        'bandIds',
        void 0,
      ),
        (0, n._)(
          [(0, c.Cb)({ json: { write: { overridePolicy: ut } } }), (0, d.e)(be.i)],
          ct.prototype,
          'interpolation',
          void 0,
        ),
        (0, n._)(
          [(0, c.Cb)({ json: { write: !0 } })],
          ct.prototype,
          'multidimensionalDefinition',
          void 0,
        ),
        (0, n._)([(0, c.Cb)(C.b)], ct.prototype, 'legendEnabled', void 0),
        (0, n._)(
          [
            (0, c.Cb)({
              type: Boolean,
              json: { read: !1, write: { enabled: !0, overridePolicy: () => ({ enabled: !1 }) } },
            }),
          ],
          ct.prototype,
          'isReference',
          void 0,
        ),
        (0, n._)([(0, c.Cb)({ type: ['show', 'hide'] })], ct.prototype, 'listMode', void 0),
        (0, n._)([(0, c.Cb)()], ct.prototype, 'sourceJSON', void 0),
        (0, n._)([(0, c.Cb)({ readOnly: !0 })], ct.prototype, 'version', void 0),
        (0, n._)([(0, c.Cb)()], ct.prototype, 'title', void 0),
        (0, n._)([(0, c.Cb)({ readOnly: !0, json: { read: !1 } })], ct.prototype, 'type', void 0),
        (0, n._)(
          [(0, c.Cb)({ type: ['ArcGISTiledImageServiceLayer'] })],
          ct.prototype,
          'operationalLayerType',
          void 0,
        ),
        (0, n._)(
          [
            (0, c.Cb)({
              type: Boolean,
              value: !0,
              json: {
                read: { source: 'disablePopup', reader: (e, t) => !t.disablePopup },
                write: {
                  target: 'disablePopup',
                  overridePolicy: ut,
                  writer(e, t, i) {
                    t[i] = !e;
                  },
                },
              },
            }),
          ],
          ct.prototype,
          'popupEnabled',
          void 0,
        ),
        (0, n._)(
          [
            (0, c.Cb)({
              type: r.Z,
              json: {
                read: { source: 'popupInfo' },
                write: { target: 'popupInfo', overridePolicy: ut },
              },
            }),
          ],
          ct.prototype,
          'popupTemplate',
          void 0,
        ),
        (0, n._)([(0, c.Cb)({ readOnly: !0 })], ct.prototype, 'defaultPopupTemplate', null),
        (0, n._)([(0, c.Cb)({ readOnly: !0, type: [ve.Z] })], ct.prototype, 'fields', void 0),
        (0, n._)([(0, c.Cb)({ readOnly: !0, type: [ve.Z] })], ct.prototype, 'rasterFields', null),
        (0, n._)(
          [
            (0, c.Cb)({
              types: s.dr,
              json: {
                name: 'layerDefinition.drawingInfo.renderer',
                write: { overridePolicy: ut },
                origins: {
                  'web-scene': {
                    types: s.FK,
                    name: 'layerDefinition.drawingInfo.renderer',
                    write: { overridePolicy: (e) => ({ enabled: e && 'vector-field' !== e.type }) },
                  },
                },
              },
            }),
          ],
          ct.prototype,
          'renderer',
          null,
        ),
        (0, n._)([(0, m.r)('renderer')], ct.prototype, 'readRenderer', null),
        (ct = (0, n._)([(0, p.j)('esri.layers.ImageryTileLayer')], ct));
      const ft = ct;
    },
  },
]);
