(self.webpackChunkRemoteClient = self.webpackChunkRemoteClient || []).push([
  [332],
  {
    60332: (e, n, t) => {
      'use strict';
      t.r(n), t.d(n, { registerFunctions: () => y });
      var r = t(1886),
        i = t(97944),
        a = t(72256),
        l = t(50406),
        s = t(72274),
        o = t(9506),
        f = t(97546);
      function u(e, n, t) {
        const r = e.getVariables();
        if (r.length > 0) {
          const i = [];
          for (let e = 0; e < r.length; e++) {
            const a = { name: r[e] };
            i.push(n.evaluateIdentifier(t, a));
          }
          return (0, l.$6)(i).then((n) => {
            const t = {};
            for (let e = 0; e < r.length; e++) t[r[e]] = n[e];
            return (e.parameters = t), e;
          });
        }
        return (0, l.DB)(e);
      }
      function c(e, n, t = null) {
        for (const t in e) if (t.toLowerCase() === n.toLowerCase()) return e[t];
        return t;
      }
      function d(e) {
        if (null === e) return null;
        const n = { type: c(e, 'type', ''), name: c(e, 'name', '') };
        if ('range' === n.type) n.range = c(e, 'range', []);
        else {
          n.codedValues = [];
          for (const t of c(e, 'codedValues', []))
            n.codedValues.push({ name: c(t, 'name', ''), code: c(t, 'code', null) });
        }
        return n;
      }
      function p(e) {
        if (null === e) return null;
        const n = {},
          t = c(e, 'wkt', null);
        null !== t && (n.wkt = t);
        const r = c(e, 'wkid', null);
        return null !== r && (n.wkid = r), n;
      }
      function m(e) {
        if (null === e) return null;
        const n = { hasZ: c(e, 'hasz', !1), hasM: c(e, 'hasm', !1) },
          t = c(e, 'spatialreference', null);
        t && (n.spatialReference = p(t));
        const r = c(e, 'x', null);
        if (null !== r) return (n.x = r), (n.y = c(e, 'y', null)), n;
        const i = c(e, 'rings', null);
        if (null !== i) return (n.rings = i), n;
        const a = c(e, 'paths', null);
        if (null !== a) return (n.paths = a), n;
        const l = c(e, 'points', null);
        if (null !== l) return (n.points = l), n;
        for (const t of ['xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax', 'mmin', 'mmax']) {
          const r = c(e, t, null);
          null !== r && (n[t] = r);
        }
        return n;
      }
      function y(e) {
        'async' === e.mode &&
          ((e.functions.getuser = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, t, a) => {
              (0, r.p)(a, 1, 2);
              let l = (0, r.U)(a[1], ''),
                s = !0 === l;
              if (((l = !0 === l || !1 === l ? '' : (0, r.t)(l)), a[0] instanceof r.O)) {
                let e = null;
                return (
                  n.services && n.services.portal && (e = n.services.portal),
                  (e = (0, i.g)(a[0], e)),
                  (0, i.l)(e, l, s).then((e) => {
                    if (e) {
                      const n = JSON.parse(JSON.stringify(e));
                      for (const e of ['lastLogin', 'created', 'modified'])
                        void 0 !== n[e] && null !== n[e] && (n[e] = new Date(n[e]));
                      return r.D.convertObjectToArcadeDictionary(n);
                    }
                    return null;
                  })
                );
              }
              let o = null;
              if (((0, r.z)(a[0]) && (o = a[0]), o))
                return (
                  (s = !1),
                  l
                    ? null
                    : o
                        .load()
                        .then(() => o.getOwningSystemUrl())
                        .then((e) => {
                          if (!e)
                            return l
                              ? null
                              : o
                                  .getIdentityUser()
                                  .then((e) =>
                                    e ? r.D.convertObjectToArcadeDictionary({ username: e }) : null,
                                  );
                          let t = null;
                          return (
                            n.services && n.services.portal && (t = n.services.portal),
                            (t = (0, i.g)(new r.O(e), t)),
                            (0, i.l)(t, l, s).then((e) => {
                              if (e) {
                                const n = JSON.parse(JSON.stringify(e));
                                for (const e of ['lastLogin', 'created', 'modified'])
                                  void 0 !== n[e] && null !== n[e] && (n[e] = new Date(n[e]));
                                return r.D.convertObjectToArcadeDictionary(n);
                              }
                              return null;
                            })
                          );
                        })
                );
              throw new Error('Invalid Parameter');
            });
          }),
          e.signatures.push({ name: 'getuser', min: '1', max: '2' }),
          (e.functions.featuresetbyid = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, n, t) => {
              if (((0, r.p)(t, 2, 4), t[0] instanceof i.F)) {
                const e = (0, r.t)(t[1]);
                let n = (0, r.U)(t[2], null);
                const i = (0, r.Z)((0, r.U)(t[3], !0));
                if ((null === n && (n = ['*']), !1 === (0, r.u)(n)))
                  throw new Error('Invalid Parameter');
                return t[0].featureSetById(e, i, n);
              }
              throw new Error('Invalid Parameter');
            });
          }),
          e.signatures.push({ name: 'featuresetbyid', min: '2', max: '4' }),
          (e.functions.featuresetbyportalitem = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, t, a) => {
              if (((0, r.p)(a, 2, 5), null === a[0])) throw new Error('Portal is required');
              if (a[0] instanceof r.O) {
                const e = (0, r.t)(a[1]),
                  t = (0, r.t)(a[2]);
                let l = (0, r.U)(a[3], null);
                const s = (0, r.Z)((0, r.U)(a[4], !0));
                if ((null === l && (l = ['*']), !1 === (0, r.u)(l)))
                  throw new Error('Invalid Parameter');
                let o = null;
                return (
                  n.services && n.services.portal && (o = n.services.portal),
                  (o = (0, i.g)(a[0], o)),
                  (0, i.c)(e, t, n.spatialReference, l, s, o, n.lrucache, n.interceptor)
                );
              }
              if (!1 === (0, r.w)(a[0])) throw new Error('Portal is required');
              const l = (0, r.t)(a[0]),
                s = (0, r.t)(a[1]);
              let o = (0, r.U)(a[2], null);
              const f = (0, r.Z)((0, r.U)(a[3], !0));
              if ((null === o && (o = ['*']), !1 === (0, r.u)(o)))
                throw new Error('Invalid Parameter');
              if (n.services && n.services.portal)
                return (0, i.c)(
                  l,
                  s,
                  n.spatialReference,
                  o,
                  f,
                  n.services.portal,
                  n.lrucache,
                  n.interceptor,
                );
              throw new Error('Portal is required');
            });
          }),
          e.signatures.push({ name: 'featuresetbyportalitem', min: '2', max: '5' }),
          (e.functions.featuresetbyname = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, n, t) => {
              if (((0, r.p)(t, 2, 4), t[0] instanceof i.F)) {
                const e = (0, r.t)(t[1]);
                let n = (0, r.U)(t[2], null);
                const i = (0, r.Z)((0, r.U)(t[3], !0));
                if ((null === n && (n = ['*']), !1 === (0, r.u)(n)))
                  throw new Error('Invalid Parameter');
                return t[0].featureSetByName(e, i, n);
              }
              throw new Error('Invalid Parameter');
            });
          }),
          e.signatures.push({ name: 'featuresetbyname', min: '2', max: '4' }),
          (e.functions.featureset = function (n, t) {
            return e.standardFunction(n, t, (e, t, a) => {
              (0, r.p)(a, 1, 1);
              let l = a[0];
              const s = {
                layerDefinition: {
                  geometryType: '',
                  objectIdField: '',
                  globalIdField: '',
                  typeIdField: '',
                  fields: [],
                },
                featureSet: { geometryType: '', features: [] },
              };
              if ((0, r.w)(l))
                (l = JSON.parse(l)),
                  void 0 !== l.layerDefinition
                    ? ((s.layerDefinition = l.layerDefinition),
                      (s.featureSet = l.featureSet),
                      l.layerDefinition.spatialReference &&
                        (s.layerDefinition.spatialReference = l.layerDefinition.spatialReference))
                    : ((s.featureSet.features = l.features),
                      (s.featureSet.geometryType = l.geometryType),
                      (s.layerDefinition.geometryType = s.featureSet.geometryType),
                      (s.layerDefinition.objectIdField = l.objectIdFieldName),
                      (s.layerDefinition.typeIdField = l.typeIdFieldName),
                      (s.layerDefinition.globalIdField = l.globalIdFieldName),
                      (s.layerDefinition.fields = l.fields),
                      l.spatialReference &&
                        (s.layerDefinition.spatialReference = l.spatialReference));
              else {
                if (!(a[0] instanceof r.D)) throw new Error('Invalid Parameter');
                {
                  l = JSON.parse(a[0].castToText());
                  const e = c(l, 'layerdefinition');
                  if (null !== e) {
                    (s.layerDefinition.geometryType = c(e, 'geometrytype', '')),
                      (s.featureSet.geometryType = s.layerDefinition.geometryType),
                      (s.layerDefinition.globalIdField = c(e, 'globalidfield', '')),
                      (s.layerDefinition.objectIdField = c(e, 'objectidfield', '')),
                      (s.layerDefinition.typeIdField = c(e, 'typeidfield', ''));
                    const n = c(e, 'spatialreference', null);
                    n && (s.layerDefinition.spatialReference = p(n));
                    for (const n of c(e, 'fields', [])) {
                      const e = {
                        name: c(n, 'name', ''),
                        alias: c(n, 'alias', ''),
                        type: c(n, 'type', ''),
                        nullable: c(n, 'nullable', !0),
                        editable: c(n, 'editable', !0),
                        length: c(n, 'length', null),
                        domain: d(c(n, 'domain')),
                      };
                      s.layerDefinition.fields.push(e);
                    }
                    const t = c(l, 'featureset', null);
                    if (t) {
                      const e = {};
                      for (const n of s.layerDefinition.fields) e[n.name.toLowerCase()] = n.name;
                      for (const n of c(t, 'features', [])) {
                        const t = {},
                          r = c(n, 'attributes', {});
                        for (const n in r) t[e[n.toLowerCase()]] = r[n];
                        s.featureSet.features.push({
                          attributes: t,
                          geometry: m(c(n, 'geometry', null)),
                        });
                      }
                    }
                  } else {
                    (s.layerDefinition.geometryType = c(l, 'geometrytype', '')),
                      (s.featureSet.geometryType = s.layerDefinition.geometryType),
                      (s.layerDefinition.objectIdField = c(l, 'objectidfieldname', '')),
                      (s.layerDefinition.typeIdField = c(l, 'typeidfieldname', ''));
                    const e = c(l, 'spatialreference', null);
                    e && (s.layerDefinition.spatialReference = p(e));
                    for (const e of c(l, 'fields', [])) {
                      const n = {
                        name: c(e, 'name', ''),
                        alias: c(e, 'alias', ''),
                        type: c(e, 'type', ''),
                        nullable: c(e, 'nullable', !0),
                        editable: c(e, 'editable', !0),
                        length: c(e, 'length', null),
                        domain: d(c(e, 'domain')),
                      };
                      s.layerDefinition.fields.push(n);
                    }
                    const n = {};
                    for (const e of s.layerDefinition.fields) n[e.name.toLowerCase()] = e.name;
                    for (const e of c(l, 'features', [])) {
                      const t = {},
                        r = c(e, 'attributes', {});
                      for (const e in r) t[n[e.toLowerCase()]] = r[e];
                      s.featureSet.features.push({
                        attributes: t,
                        geometry: m(c(e, 'geometry', null)),
                      });
                    }
                  }
                }
              }
              if (
                0 ==
                (!!(o = s).layerDefinition &&
                  !!o.featureSet &&
                  !1 !==
                    (function (e, n) {
                      for (const n of [
                        '',
                        'esriGeometryPoint',
                        'esriGeometryPolyline',
                        'esriGeometryPolygon',
                        'esriGeometryMultipoint',
                        'esriGeometryEnvelope',
                      ])
                        if (n === e) return !0;
                      return !1;
                    })(o.layerDefinition.geometryType) &&
                  null !== o.layerDefinition.objectIdField &&
                  '' !== o.layerDefinition.objectIdField &&
                  !1 !== (0, r.u)(o.layerDefinition.fields) &&
                  !1 !== (0, r.u)(o.featureSet.features))
              )
                throw new Error('Invalid Parameter');
              var o;
              return i.a.create(s, n.spatialReference);
            });
          }),
          e.signatures.push({ name: 'featureset', min: '1', max: '1' }),
          (e.functions.filter = function (n, t) {
            return e.standardFunctionAsync(
              n,
              t,
              (t, a, o) => (
                (0, r.p)(o, 2, 2),
                (0, r.z)(o[0])
                  ? o[0].load().then((t) => {
                      const r = s.WhereClause.create(o[1], t.getFieldsIndex()),
                        a = r.getVariables();
                      if (a.length > 0) {
                        const t = [];
                        for (let r = 0; r < a.length; r++) {
                          const i = { name: a[r] };
                          t.push(e.evaluateIdentifier(n, i));
                        }
                        return (0, l.$6)(t).then((e) => {
                          const n = {};
                          for (let t = 0; t < a.length; t++) n[a[t]] = e[t];
                          return (
                            (r.parameters = n), new i.b({ parentfeatureset: o[0], whereclause: r })
                          );
                        });
                      }
                      return (0, l.DB)(new i.b({ parentfeatureset: o[0], whereclause: r }));
                    })
                  : e.failDefferred('Filter cannot accept this parameter type')
              ),
            );
          }),
          e.signatures.push({ name: 'filter', min: '2', max: '2' }),
          (e.functions.orderby = function (n, t) {
            return e.standardFunctionAsync(n, t, (n, t, a) => {
              if (((0, r.p)(a, 2, 2), (0, r.z)(a[0]))) {
                const e = new i.O(a[1]);
                return (0, l.DB)(new i.d({ parentfeatureset: a[0], orderbyclause: e }));
              }
              return e.failDefferred('Order cannot accept this parameter type');
            });
          }),
          e.signatures.push({ name: 'orderby', min: '2', max: '2' }),
          (e.functions.top = function (n, t) {
            return e.standardFunctionAsync(
              n,
              t,
              (n, t, a) => (
                (0, r.p)(a, 2, 2),
                (0, r.z)(a[0])
                  ? (0, l.DB)(new i.T({ parentfeatureset: a[0], topnum: a[1] }))
                  : (0, r.u)(a[0])
                  ? (0, r.C)(a[1]) >= a[0].length
                    ? a[0].slice(0)
                    : a[0].slice(0, (0, r.C)(a[1]))
                  : (0, r.x)(a[0])
                  ? (0, r.C)(a[1]) >= a[0].length()
                    ? a[0].slice(0)
                    : a[0].slice(0, (0, r.C)(a[1]))
                  : e.failDefferred('Top cannot accept this parameter type')
              ),
            );
          }),
          e.signatures.push({ name: 'top', min: '2', max: '2' }),
          (e.functions.first = function (n, t) {
            return e.standardFunctionAsync(
              n,
              t,
              (e, n, t) => (
                (0, r.p)(t, 1, 1),
                (0, r.z)(t[0])
                  ? t[0].first(e.abortSignal).then((e) => {
                      if (null !== e) {
                        const n = r.y.createFromGraphicLikeObject(e.geometry, e.attributes, t[0]);
                        (n._underlyingGraphic = e), (e = n);
                      }
                      return e;
                    })
                  : (0, r.u)(t[0])
                  ? 0 === t[0].length
                    ? (0, l.DB)(null)
                    : (0, l.DB)(t[0][0])
                  : (0, r.x)(t[0])
                  ? 0 === t[0].length()
                    ? (0, l.DB)(null)
                    : (0, l.DB)(t[0].get(0))
                  : null
              ),
            );
          }),
          e.signatures.push({ name: 'first', min: '1', max: '1' }),
          (e.functions.attachments = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, t, a) => {
              (0, r.p)(a, 1, 2);
              const l = { minsize: -1, maxsize: -1, types: null };
              if (a.length > 1)
                if (a[1] instanceof r.D) {
                  if (
                    (a[1].hasField('minsize') && (l.minsize = (0, r.C)(a[1].field('minsize'))),
                    a[1].hasField('maxsize') && (l.maxsize = (0, r.C)(a[1].field('maxsize'))),
                    a[1].hasField('types'))
                  ) {
                    const e = (0, r.ah)(a[1].field('types'), !1);
                    e.length > 0 && (l.types = e);
                  }
                } else if (null !== a[1]) throw new Error('Invalid Parameter');
              if (a[0] instanceof r.y) {
                let e = a[0]._layer;
                return (
                  e instanceof o.default &&
                    (e = (0, i.e)(e, n.spatialReference, ['*'], !0, n.lrucache, n.interceptor)),
                  null === e || !1 === (0, r.z)(e)
                    ? []
                    : e
                        .load()
                        .then(() =>
                          e.queryAttachments(
                            a[0].field(e.objectIdField),
                            l.minsize,
                            l.maxsize,
                            l.types,
                          ),
                        )
                );
              }
              if (null === a[0]) return [];
              throw new Error('Invalid Parameter');
            });
          }),
          e.signatures.push({ name: 'attachments', min: '1', max: '2' }),
          (e.functions.featuresetbyrelationshipname = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, t, l) => {
              (0, r.p)(l, 2, 4);
              const f = l[0],
                u = (0, r.t)(l[1]);
              let c = (0, r.U)(l[2], null);
              const d = (0, r.Z)((0, r.U)(l[3], !0));
              if ((null === c && (c = ['*']), !1 === (0, r.u)(c)))
                throw new Error('Invalid Parameter');
              if (null === l[0]) return null;
              if (!(l[0] instanceof r.y)) throw new Error('Invalid Parameter');
              let p = f._layer;
              return (
                p instanceof o.default &&
                  (p = (0, i.e)(p, n.spatialReference, ['*'], !0, n.lrucache, n.interceptor)),
                null === p || !1 === (0, r.z)(p)
                  ? null
                  : p.load().then((e) => {
                      const t = e.relationshipMetaData().filter((e) => e.name === u);
                      if (0 === t.length) return null;
                      if (
                        void 0 !== t[0].relationshipTableId &&
                        null !== t[0].relationshipTableId &&
                        t[0].relationshipTableId > -1
                      )
                        return (0, i.f)(
                          e,
                          t[0],
                          f.field(e.objectIdField),
                          e.spatialReference,
                          c,
                          d,
                          n.lrucache,
                          n.interceptor,
                        );
                      let r = e.serviceUrl();
                      return r
                        ? ((r =
                            '/' === r.charAt(r.length - 1)
                              ? r + t[0].relatedTableId.toString()
                              : r + '/' + t[0].relatedTableId.toString()),
                          (0, i.h)(r, e.spatialReference, c, d, n.lrucache, n.interceptor).then(
                            (n) =>
                              n
                                .load()
                                .then(() => n.relationshipMetaData())
                                .then((r) => {
                                  if (
                                    ((r = r.filter((e) => e.id === t[0].id)),
                                    !1 === f.hasField(t[0].keyField) ||
                                      null === f.field(t[0].keyField))
                                  )
                                    return e
                                      .getFeatureByObjectId(f.field(e.objectIdField), [
                                        t[0].keyField,
                                      ])
                                      .then((e) => {
                                        if (e) {
                                          const i = s.WhereClause.create(
                                            r[0].keyField + '= @id',
                                            n.getFieldsIndex(),
                                          );
                                          return (
                                            (i.parameters = { id: e.attributes[t[0].keyField] }),
                                            n.filter(i)
                                          );
                                        }
                                        return new a.E({ parentfeatureset: n });
                                      });
                                  const i = s.WhereClause.create(
                                    r[0].keyField + '= @id',
                                    n.getFieldsIndex(),
                                  );
                                  return (
                                    (i.parameters = { id: f.field(t[0].keyField) }), n.filter(i)
                                  );
                                }),
                          ))
                        : null;
                    })
              );
            });
          }),
          e.signatures.push({ name: 'featuresetbyrelationshipname', min: '2', max: '4' }),
          (e.functions.featuresetbyassociation = function (n, t) {
            return e.standardFunctionAsync(n, t, (e, t, a) => {
              (0, r.p)(a, 2, 3);
              const l = a[0],
                u = (0, r.t)((0, r.U)(a[1], '')).toLowerCase(),
                c = (0, r.w)(a[2]) ? (0, r.t)(a[2]) : null;
              if (null === a[0]) return null;
              if (!(a[0] instanceof r.y)) throw new Error('Invalid Parameter');
              let d = l._layer;
              return (
                d instanceof o.default &&
                  (d = (0, i.e)(d, n.spatialReference, ['*'], !0, n.lrucache, n.interceptor)),
                null === d || !1 === (0, r.z)(d)
                  ? null
                  : d
                      .load()
                      .then(() => {
                        const e = d.serviceUrl();
                        return (0, i.i)(e, n.spatialReference);
                      })
                      .then((e) => {
                        let n = null,
                          t = null,
                          a = !1;
                        if (null !== c && '' !== c && void 0 !== c) {
                          for (const n of e.terminals) n.terminalName === c && (t = n.terminalId);
                          null === t && (a = !0);
                        }
                        const o = e.associations.getFieldsIndex(),
                          p = o.get('TOGLOBALID').name,
                          m = o.get('FROMGLOBALID').name,
                          y = o.get('TOTERMINALID').name,
                          h = o.get('FROMTERMINALID').name,
                          g = o.get('FROMNETWORKSOURCEID').name,
                          D = o.get('TONETWORKSOURCEID').name,
                          I = o.get('ASSOCIATIONTYPE').name,
                          F = o.get('ISCONTENTVISIBLE').name,
                          E = o.get('OBJECTID').name;
                        for (const e of d.fields)
                          if ('global-id' === e.type) {
                            n = l.field(e.name);
                            break;
                          }
                        let w = null,
                          b = new i.S(
                            new f.Z({
                              name: 'percentalong',
                              alias: 'percentalong',
                              type: 'double',
                            }),
                            s.WhereClause.create('0', e.associations.getFieldsIndex()),
                          ),
                          A = new i.S(
                            new f.Z({ name: 'side', alias: 'side', type: 'string' }),
                            s.WhereClause.create("''", e.associations.getFieldsIndex()),
                          );
                        const x = 'globalid',
                          N = 'globalId',
                          S = {};
                        for (const n in e.lkp) S[n] = e.lkp[n].sourceId;
                        const C = new i.j(
                          new f.Z({ name: 'classname', alias: 'classname', type: 'string' }),
                          null,
                          S,
                        );
                        let $ = '';
                        switch (u) {
                          case 'midspan': {
                            ($ = `((${p}='${n}') OR ( ${m}='${n}')) AND (${I} IN (5))`),
                              (C.codefield = s.WhereClause.create(
                                `CASE WHEN (${p}='${n}') THEN ${g} ELSE ${D} END`,
                                e.associations.getFieldsIndex(),
                              ));
                            const t = (0, r.a2)(i.A.findField(e.associations.fields, m));
                            (t.name = x),
                              (t.alias = x),
                              (w = new i.S(
                                t,
                                s.WhereClause.create(
                                  `CASE WHEN (${m}='${n}') THEN ${p} ELSE ${m} END`,
                                  e.associations.getFieldsIndex(),
                                ),
                              )),
                              (b =
                                e.unVersion >= 4
                                  ? new i.m(
                                      i.A.findField(
                                        e.associations.fields,
                                        o.get('PERCENTALONG').name,
                                      ),
                                    )
                                  : new i.S(
                                      new f.Z({
                                        name: 'percentalong',
                                        alias: 'percentalong',
                                        type: 'double',
                                      }),
                                      s.WhereClause.create('0', e.associations.getFieldsIndex()),
                                    ));
                            break;
                          }
                          case 'junctionedge': {
                            ($ = `((${p}='${n}') OR ( ${m}='${n}')) AND (${I} IN (4,6))`),
                              (C.codefield = s.WhereClause.create(
                                `CASE WHEN (${p}='${n}') THEN ${g} ELSE ${D} END`,
                                e.associations.getFieldsIndex(),
                              ));
                            const t = (0, r.a2)(i.A.findField(e.associations.fields, m));
                            (t.name = x),
                              (t.alias = x),
                              (w = new i.S(
                                t,
                                s.WhereClause.create(
                                  `CASE WHEN (${m}='${n}') THEN ${p} ELSE ${m} END`,
                                  e.associations.getFieldsIndex(),
                                ),
                              )),
                              (A = new i.S(
                                new f.Z({ name: 'side', alias: 'side', type: 'string' }),
                                s.WhereClause.create(
                                  `CASE WHEN (${I}=4) THEN 'from' ELSE 'to' END`,
                                  e.associations.getFieldsIndex(),
                                ),
                              ));
                            break;
                          }
                          case 'connected': {
                            let a = `${p}='@T'`,
                              l = `${m}='@T'`;
                            null !== t && ((a += ` AND ${y}=@A`), (l += ` AND ${h}=@A`)),
                              ($ = '((' + a + ') OR (' + l + '))'),
                              ($ = (0, r.ai)($, '@T', n)),
                              (a = (0, r.ai)(a, '@T', n)),
                              null !== t &&
                                ((a = (0, r.ai)(a, '@A', t.toString())),
                                ($ = (0, r.ai)($, '@A', t.toString()))),
                              (C.codefield = s.WhereClause.create(
                                'CASE WHEN ' + a + ` THEN ${g} ELSE ${D} END`,
                                e.associations.getFieldsIndex(),
                              ));
                            const o = (0, r.a2)(i.A.findField(e.associations.fields, m));
                            (o.name = x),
                              (o.alias = x),
                              (w = new i.S(
                                o,
                                s.WhereClause.create(
                                  'CASE WHEN ' + a + ` THEN ${m} ELSE ${p} END`,
                                  e.associations.getFieldsIndex(),
                                ),
                              ));
                            break;
                          }
                          case 'container':
                            ($ = `${p}='${n}' AND ${I} = 2`),
                              null !== t && ($ += ` AND ${y} = ` + t.toString()),
                              (C.codefield = g),
                              ($ = '( ' + $ + ' )'),
                              (w = new i.k(i.A.findField(e.associations.fields, m), x, x));
                          case 'content':
                            ($ = `(${m}='${n}' AND ${I} = 2)`),
                              null !== t && ($ += ` AND ${h} = ` + t.toString()),
                              (C.codefield = D),
                              ($ = '( ' + $ + ' )'),
                              (w = new i.k(i.A.findField(e.associations.fields, p), x, x));
                            break;
                          case 'structure':
                            ($ = `(${p}='${n}' AND ${I} = 3)`),
                              null !== t && ($ += ` AND ${y} = ` + t.toString()),
                              (C.codefield = g),
                              ($ = '( ' + $ + ' )'),
                              (w = new i.k(i.A.findField(e.associations.fields, m), x, N));
                            break;
                          case 'attached':
                            ($ = `(${m}='${n}' AND ${I} = 3)`),
                              null !== t && ($ += ` AND ${h} = ` + t.toString()),
                              (C.codefield = D),
                              ($ = '( ' + $ + ' )'),
                              (w = new i.k(i.A.findField(e.associations.fields, p), x, N));
                            break;
                          default:
                            throw new Error('Invalid Parameter');
                        }
                        return (
                          a && ($ = '1 <> 1'),
                          new i.A({
                            parentfeatureset: e.associations,
                            adaptedFields: [
                              new i.m(i.A.findField(e.associations.fields, E)),
                              new i.m(i.A.findField(e.associations.fields, F)),
                              w,
                              A,
                              C,
                              b,
                            ],
                            extraFilter: $
                              ? s.WhereClause.create($, e.associations.getFieldsIndex())
                              : null,
                          })
                        );
                      })
              );
            });
          }),
          e.signatures.push({ name: 'featuresetbyassociation', min: '2', max: '6' }),
          (e.functions.groupby = function (n, t) {
            return e.standardFunctionAsync(
              n,
              t,
              (t, i, o) => (
                (0, r.p)(o, 3, 3),
                (0, r.z)(o[0])
                  ? o[0].load().then((t) => {
                      const i = [],
                        f = [];
                      let c = !1,
                        d = [];
                      if ((0, r.w)(o[1])) d.push(o[1]);
                      else if (o[1] instanceof r.D) d.push(o[1]);
                      else if ((0, r.u)(o[1])) d = o[1];
                      else {
                        if (!(0, r.x)(o[1])) return e.failDefferred('Illegal Value: GroupBy');
                        d = o[1].toArray();
                      }
                      for (const n of d)
                        if ((0, r.w)(n)) {
                          const e = s.WhereClause.create((0, r.t)(n), t.getFieldsIndex()),
                            l = !0 === (0, a.i)(e) ? (0, r.t)(n) : '%%%%FIELDNAME';
                          i.push({ name: l, expression: e }), '%%%%FIELDNAME' === l && (c = !0);
                        } else {
                          if (!(n instanceof r.D)) return e.failDefferred('Illegal Value: GroupBy');
                          {
                            const r = n.hasField('name') ? n.field('name') : '%%%%FIELDNAME',
                              a = n.hasField('expression') ? n.field('expression') : '';
                            if (('%%%%FIELDNAME' === r && (c = !0), !r))
                              return e.failDefferred('Illegal Value: GroupBy');
                            i.push({
                              name: r,
                              expression: s.WhereClause.create(a || r, t.getFieldsIndex()),
                            });
                          }
                        }
                      if (((d = []), (0, r.w)(o[2]))) d.push(o[2]);
                      else if ((0, r.u)(o[2])) d = o[2];
                      else if ((0, r.x)(o[2])) d = o[2].toArray();
                      else {
                        if (!(o[2] instanceof r.D))
                          return e.failDefferred('Illegal Value: GroupBy');
                        d.push(o[2]);
                      }
                      for (const n of d) {
                        if (!(n instanceof r.D)) return e.failDefferred('Illegal Value: GroupBy');
                        {
                          const r = n.hasField('name') ? n.field('name') : '',
                            i = n.hasField('statistic') ? n.field('statistic') : '',
                            a = n.hasField('expression') ? n.field('expression') : '';
                          if (!r || !i || !a) return e.failDefferred('Illegal Value: GroupBy');
                          f.push({
                            name: r,
                            statistic: i.toLowerCase(),
                            expression: s.WhereClause.create(a, t.getFieldsIndex()),
                          });
                        }
                      }
                      if (c) {
                        const e = {};
                        for (const n of t.fields) e[n.name.toLowerCase()] = 1;
                        for (const n of i)
                          '%%%%FIELDNAME' !== n.name && (e[n.name.toLowerCase()] = 1);
                        for (const n of f)
                          '%%%%FIELDNAME' !== n.name && (e[n.name.toLowerCase()] = 1);
                        let n = 0;
                        for (const t of i)
                          if ('%%%%FIELDNAME' === t.name) {
                            for (; 1 === e['field_' + n.toString()]; ) n++;
                            (e['field_' + n.toString()] = 1), (t.name = 'FIELD_' + n.toString());
                          }
                      }
                      const p = [];
                      for (const t of i) p.push(u(t.expression, e, n));
                      for (const t of f) p.push(u(t.expression, e, n));
                      return p.length > 0
                        ? (0, l.$6)(p).then(() => (0, l.DB)(o[0].groupby(i, f)))
                        : (0, l.DB)(o[0].groupby(i, f));
                    })
                  : e.failDefferred('Illegal Value: GroupBy')
              ),
            );
          }),
          e.signatures.push({ name: 'groupby', min: '3', max: '3' }),
          (e.functions.distinct = function (n, t) {
            return e.standardFunctionAsync(n, t, (t, i, o) =>
              (0, r.z)(o[0])
                ? ((0, r.p)(o, 2, 2),
                  o[0].load().then((t) => {
                    const i = [];
                    let f = [];
                    if ((0, r.w)(o[1])) f.push(o[1]);
                    else if (o[1] instanceof r.D) f.push(o[1]);
                    else if ((0, r.u)(o[1])) f = o[1];
                    else {
                      if (!(0, r.x)(o[1])) return e.failDefferred('Illegal Value: GroupBy');
                      f = o[1].toArray();
                    }
                    let c = !1;
                    for (const n of f)
                      if ((0, r.w)(n)) {
                        const e = s.WhereClause.create((0, r.t)(n), t.getFieldsIndex()),
                          l = !0 === (0, a.i)(e) ? (0, r.t)(n) : '%%%%FIELDNAME';
                        i.push({ name: l, expression: e }), '%%%%FIELDNAME' === l && (c = !0);
                      } else {
                        if (!(n instanceof r.D)) return e.failDefferred('Illegal Value: GroupBy');
                        {
                          const r = n.hasField('name') ? n.field('name') : '%%%%FIELDNAME',
                            a = n.hasField('expression') ? n.field('expression') : '';
                          if (('%%%%FIELDNAME' === r && (c = !0), !r))
                            return e.failDefferred('Illegal Value: GroupBy');
                          i.push({
                            name: r,
                            expression: s.WhereClause.create(a || r, t.getFieldsIndex()),
                          });
                        }
                      }
                    if (c) {
                      const e = {};
                      for (const n of t.fields) e[n.name.toLowerCase()] = 1;
                      for (const n of i)
                        '%%%%FIELDNAME' !== n.name && (e[n.name.toLowerCase()] = 1);
                      let n = 0;
                      for (const t of i)
                        if ('%%%%FIELDNAME' === t.name) {
                          for (; 1 === e['field_' + n.toString()]; ) n++;
                          (e['field_' + n.toString()] = 1), (t.name = 'FIELD_' + n.toString());
                        }
                    }
                    const d = [];
                    for (const t of i) d.push(u(t.expression, e, n));
                    return d.length > 0
                      ? (0, l.$6)(d).then(() => (0, l.DB)(o[0].groupby(i, [])))
                      : (0, l.DB)(o[0].groupby(i, []));
                  }))
                : (function (e, n, t, i) {
                    if (1 === i.length) {
                      if ((0, r.u)(i[0])) return (0, r.aj)(e, i[0], -1);
                      if ((0, r.x)(i[0])) return (0, r.aj)(e, i[0].toArray(), -1);
                    }
                    return (0, r.aj)(e, i, -1);
                  })('distinct', 0, 0, o),
            );
          }));
      }
      t(91597),
        t(92143),
        t(31450),
        t(76506),
        t(71552),
        t(40642),
        t(34250),
        t(91306),
        t(86656),
        t(22723),
        t(86787),
        t(97714),
        t(17533),
        t(81172),
        t(2906),
        t(73796),
        t(74673),
        t(21972),
        t(23639),
        t(91055),
        t(27794),
        t(6906),
        t(60991),
        t(26341),
        t(60947),
        t(35132),
        t(89623),
        t(21801),
        t(84069),
        t(44567),
        t(98380),
        t(92896),
        t(56240),
        t(3482),
        t(32422),
        t(40267),
        t(88762),
        t(32101),
        t(21929),
        t(74569),
        t(22781),
        t(57251),
        t(92228),
        t(82058),
        t(23761),
        t(86748),
        t(15324),
        t(76996),
        t(14249),
        t(9801),
        t(53523),
        t(59465),
        t(42911),
        t(46826),
        t(45433),
        t(60217),
        t(29107),
        t(30574),
        t(2157),
        t(25977),
        t(7471),
        t(54414),
        t(1648),
        t(8925),
        t(33921),
        t(45154),
        t(16769),
        t(55531),
        t(30582),
        t(593),
        t(85699),
        t(63136),
        t(96055),
        t(47776),
        t(18033),
        t(6331),
        t(62048),
        t(4292),
        t(75626),
        t(72652),
        t(29641),
        t(30493),
        t(70821),
        t(82673),
        t(34229),
        t(37029),
        t(96467),
        t(63571),
        t(30776),
        t(48027),
        t(54174),
        t(82426),
        t(63130),
        t(25696),
        t(66396),
        t(42775),
        t(95834),
        t(34394),
        t(57150),
        t(76726),
        t(20444),
        t(76393),
        t(78548),
        t(2497),
        t(49906),
        t(46527),
        t(48649),
        t(9960),
        t(3101),
        t(5853),
        t(39141),
        t(38742),
        t(48243),
        t(34635),
        t(10401),
        t(49900),
        t(66284),
        t(73173),
        t(22739),
        t(20543),
        t(67477),
        t(78533),
        t(74653),
        t(91091),
        t(58943),
        t(70737),
        t(8487),
        t(17817),
        t(90814),
        t(15459),
        t(61847),
        t(16796),
        t(16955),
        t(22401),
        t(77894),
        t(55187),
        t(8586),
        t(44509),
        t(69814),
        t(11305),
        t(62259),
        t(44790),
        t(5909),
        t(60669),
        t(48208),
        t(51589),
        t(81317),
        t(76733),
        t(11385),
        t(53785),
        t(95587),
        t(87258),
        t(54732),
        t(31292),
        t(93314),
        t(35197),
        t(69218),
        t(27207),
        t(15528),
        t(91171),
        t(81731),
        t(53426),
        t(49214),
        t(95533),
        t(94751),
        t(55823),
        t(92847),
        t(34446),
        t(48190),
        t(46646),
        t(39210),
        t(90549),
        t(658),
        t(78303),
        t(46495),
        t(56420),
        t(74742),
        t(28239),
        t(42870),
        t(65514),
        t(46987),
        t(37453),
        t(5777),
        t(55306),
        t(65684),
        t(12158),
        t(74864),
        t(63683),
        t(94479),
        t(45702),
        t(51127),
        t(74071),
        t(51723),
        t(23243),
        t(51669),
        t(6090),
        t(3977),
        t(36741),
        t(11253),
        t(90319),
        t(38822),
        t(74057),
        t(85557),
        t(94070),
        t(16218),
        t(9075),
        t(67541),
        t(71206),
        t(89241),
        t(91700),
        t(51979),
        t(32037),
        t(60698),
        t(90811),
        t(86758),
        t(95310),
        t(93939),
        t(238),
        t(71831),
        t(49500),
        t(20208),
        t(82933),
        t(54179),
        t(50161),
        t(10691),
        t(38949),
        t(71777),
        t(27371),
        t(78648),
        t(87558),
        t(13063),
        t(17153),
        t(35962),
        t(9252),
        t(67350),
        t(11471),
        t(83748),
        t(28376),
        t(62554),
        t(29027),
        t(41617),
        t(48687),
        t(21781),
        t(75025),
        t(21132),
        t(11118),
        t(8547),
        t(89440),
        t(43022),
        t(47842),
        t(17298),
        t(62162),
        t(41864),
        t(16647),
        t(58912),
        t(19902),
        t(59765),
        t(77361),
        t(13322),
        t(14460),
        t(77807),
        t(50203),
        t(30439),
        t(6941),
        t(83290),
        t(47346),
        t(17055),
        t(68653),
        t(2180),
        t(14327),
        t(68714),
        t(78893);
    },
  },
]);
