(self.webpackChunkRemoteClient = self.webpackChunkRemoteClient || []).push([
  [4151],
  {
    24151: (e, t, i) => {
      'use strict';
      i.r(t), i.d(t, { default: () => y });
      var s = i(60991),
        r = i(92143),
        a = i(76506),
        o = i(92482),
        h = i(98380),
        n = i(7176),
        l = i(31292),
        d = i(59751);
      i(81172),
        i(71552),
        i(31450),
        i(40642),
        i(21801),
        i(34250),
        i(91306),
        i(86656),
        i(22723),
        i(17533),
        i(73796),
        i(74673),
        i(21972),
        i(23639),
        i(91055),
        i(27794),
        i(6906),
        i(50406),
        i(26341),
        i(97714),
        i(60947),
        i(2906),
        i(91597),
        i(86787),
        i(35132),
        i(89623),
        i(32422),
        i(84069),
        i(44567),
        i(92896),
        i(40267),
        i(24251),
        i(72334),
        i(82426),
        i(53785),
        i(57251),
        i(95587),
        i(65775),
        i(12381),
        i(73173),
        i(82058),
        i(88762),
        i(32101),
        i(92624),
        i(77314),
        i(95533),
        i(94751),
        i(74569),
        i(22781),
        i(93314),
        i(35197),
        i(59465),
        i(69218),
        i(97546),
        i(9801),
        i(53523),
        i(42911),
        i(46826),
        i(45433),
        i(54732),
        i(27207),
        i(31712),
        i(76996),
        i(3498),
        i(21929),
        i(93939),
        i(15324),
        i(82356),
        i(55029),
        i(30752),
        i(10638),
        i(86929),
        i(98788),
        i(98576),
        i(6687),
        i(11084),
        i(53326),
        i(60217);
      const u = r.L.getLogger('esri.views.2d.layers.features.support.whereUtils'),
        c = { getAttribute: (e, t) => e.field(t) },
        _ = r.L.getLogger('esri.views.2d.layers.features.controllers.FeatureFilter'),
        y = class {
          constructor(e) {
            (this._geometryBounds = (0, o.a)()),
              (this._idToVisibility = new Map()),
              (this._serviceInfo = e);
          }
          get hash() {
            return this._hash;
          }
          check(e) {
            return this._applyFilter(e);
          }
          clear() {
            const e = this._resetAllHiddenIds();
            return this.update(), { show: e, hide: [] };
          }
          invalidate() {
            this._idToVisibility.forEach((e, t) => {
              this._idToVisibility.set(t, 0);
            });
          }
          setKnownIds(e) {
            for (const t of e) this._idToVisibility.set(t, 1);
          }
          setTrue(e) {
            const t = [],
              i = [],
              s = new Set(e);
            return (
              this._idToVisibility.forEach((e, r) => {
                const a = !!(1 & this._idToVisibility.get(r)),
                  o = s.has(r);
                !a && o ? t.push(r) : a && !o && i.push(r), this._idToVisibility.set(r, o ? 3 : 0);
              }),
              { show: t, hide: i }
            );
          }
          createQuery() {
            const { geometry: e, spatialRel: t, where: i, timeExtent: s, objectIds: r } = this;
            return l.Z.fromJSON({
              geometry: e,
              spatialRel: t,
              where: i,
              timeExtent: s,
              objectIds: r,
            });
          }
          async update(e, t) {
            this._hash = JSON.stringify(e);
            const i = await (0, n.h)(e, null, t);
            await Promise.all([
              this._setGeometryFilter(i),
              this._setIdFilter(i),
              this._setAttributeFilter(i),
              this._setTimeFilter(i),
            ]);
          }
          async _setAttributeFilter(e) {
            if (!e || !e.where) return (this._clause = null), void (this.where = null);
            (this._clause = await (async function (e, t) {
              const r = await Promise.resolve().then(i.bind(i, 72274));
              try {
                const i = r.WhereClause.create(e, t);
                if (!i.isStandardized) {
                  const e = new s.Z(
                    'mapview - bad input',
                    "Unable to apply filter's definition expression, as expression is not standardized.",
                    i,
                  );
                  u.error(e);
                }
                return (e) => {
                  const t = e.readArcadeFeature();
                  return i.testFeature(t, c);
                };
              } catch (t) {
                return (
                  u.warn(
                    'mapview-bad-where-clause',
                    'Encountered an error when evaluating where clause',
                    e,
                  ),
                  (e) => !0
                );
              }
            })(e.where, this._serviceInfo.fieldsIndex)),
              (this.where = e.where);
          }
          _setIdFilter(e) {
            (this._idsToShow = e && e.objectIds && new Set(e.objectIds)),
              (this._idsToHide = e && e.hiddenIds && new Set(e.hiddenIds)),
              (this.objectIds = e && e.objectIds);
          }
          async _setGeometryFilter(e) {
            if (!e || !e.geometry)
              return (
                (this._spatialQueryOperator = null),
                (this.geometry = null),
                void (this.spatialRel = null)
              );
            const t = e.geometry,
              i = e.spatialRel || 'esriSpatialRelIntersects',
              s = await (0, n.d)(
                i,
                t,
                this._serviceInfo.geometryType,
                this._serviceInfo.hasZ,
                this._serviceInfo.hasM,
              );
            (0, h.d)(this._geometryBounds, t),
              (this._spatialQueryOperator = s),
              (this.geometry = t),
              (this.spatialRel = i);
          }
          _setTimeFilter(e) {
            if (((this.timeExtent = this._timeOperator = null), e && e.timeExtent))
              if (this._serviceInfo.timeInfo)
                (this.timeExtent = e.timeExtent),
                  (this._timeOperator = (0, n.g)(this._serviceInfo.timeInfo, e.timeExtent, d.f));
              else {
                const t = new s.Z(
                  'feature-layer-view:time-filter-not-available',
                  "Unable to apply time filter, as layer doesn't have time metadata.",
                  e.timeExtent,
                );
                _.error(t);
              }
          }
          _applyFilter(e) {
            return (
              this._filterByGeometry(e) &&
              this._filterById(e) &&
              this._filterByTime(e) &&
              this._filterByExpression(e)
            );
          }
          _filterByExpression(e) {
            return !this.where || this._clause(e);
          }
          _filterById(e) {
            return (
              (!this._idsToHide ||
                !this._idsToHide.size ||
                !this._idsToHide.has(e.getObjectId())) &&
              (!this._idsToShow || !this._idsToShow.size || this._idsToShow.has(e.getObjectId()))
            );
          }
          _filterByGeometry(e) {
            if (!this.geometry) return !0;
            const t = e.readHydratedGeometry();
            return !!t && this._spatialQueryOperator(t);
          }
          _filterByTime(e) {
            return !(0, a.i)(this._timeOperator) || this._timeOperator(e);
          }
          _resetAllHiddenIds() {
            const e = [];
            return (
              this._idToVisibility.forEach((t, i) => {
                1 & t || (this._idToVisibility.set(i, 1), e.push(i));
              }),
              e
            );
          }
        };
    },
  },
]);
