@nextgis/ngw-map 3.0.0-alpha.3 → 3.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.3; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 3.0.0-alpha.5; author: NextGIS */
2
2
  var domain;
3
3
 
4
4
  // This constructor is used to store event handlers. Instantiating this is
@@ -29,7 +29,7 @@ EventEmitter.init = function() {
29
29
  this.domain = null;
30
30
  if (EventEmitter.usingDomains) {
31
31
  // if there is an active domain, then attach to it.
32
- if (domain.active ) ;
32
+ if (domain.active) ;
33
33
  }
34
34
 
35
35
  if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
@@ -824,12 +824,12 @@ function fixUrlStr(url) {
824
824
  return url.replace(/([^:]\/)\/+/g, "$1");
825
825
  }
826
826
 
827
- var __defProp$K = Object.defineProperty;
828
- var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
829
- var __publicField$v = (obj, key, value) => __defNormalProp$K(obj, typeof key !== "symbol" ? key + "" : key, value);
827
+ var __defProp$P = Object.defineProperty;
828
+ var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
829
+ var __publicField$y = (obj, key, value) => __defNormalProp$P(obj, typeof key !== "symbol" ? key + "" : key, value);
830
830
  const _Cache = class _Cache {
831
831
  constructor(options = {}) {
832
- __publicField$v(this, "cache", []);
832
+ __publicField$y(this, "cache", []);
833
833
  var _a;
834
834
  const namespace = (_a = options.namespace) != null ? _a : "default";
835
835
  if (_Cache.instance[namespace]) {
@@ -935,12 +935,12 @@ const _Cache = class _Cache {
935
935
  return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
936
936
  }
937
937
  };
938
- __publicField$v(_Cache, "instance", {});
938
+ __publicField$y(_Cache, "instance", {});
939
939
  let Cache = _Cache;
940
940
 
941
941
  var pkg = {
942
942
  name: "@nextgis/ngw-connector",
943
- version: "3.0.0-alpha.3",
943
+ version: "3.0.0-alpha.5",
944
944
  _priority: 12,
945
945
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
946
946
  main: "index.js",
@@ -949,15 +949,15 @@ var pkg = {
949
949
  jsdelivr: "lib/ngw-connector.global.prod.js",
950
950
  types: "lib/index.d.ts",
951
951
  dependencies: {
952
- "@nextgis/cache": "^3.0.0-alpha.3",
953
- "@nextgis/cancelable-promise": "^3.0.0-alpha.3",
954
- "@nextgis/utils": "^3.0.0-alpha.3",
952
+ "@nextgis/cache": "^3.0.0-alpha.5",
953
+ "@nextgis/cancelable-promise": "^3.0.0-alpha.5",
954
+ "@nextgis/utils": "^3.0.0-alpha.5",
955
955
  "@types/events": "^3.0.0",
956
956
  events: "*",
957
957
  "form-data": "^4.0.0"
958
958
  },
959
959
  devDependencies: {
960
- "@nextgis/build-tools": "^3.0.0-alpha.3"
960
+ "@nextgis/build-tools": "^3.0.0-alpha.5"
961
961
  },
962
962
  scripts: {
963
963
  clean: "rimraf ./lib",
@@ -991,87 +991,179 @@ var pkg = {
991
991
  type: "git",
992
992
  url: "git://github.com/nextgis/nextgis_frontend.git"
993
993
  },
994
+ engines: {
995
+ node: ">=18.20.4"
996
+ },
994
997
  gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
995
998
  };
996
999
 
997
- var __defProp$J = Object.defineProperty;
998
- var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
999
- var __publicField$u = (obj, key, value) => __defNormalProp$J(obj, typeof key !== "symbol" ? key + "" : key, value);
1000
+ const CONNECTORS = [];
1001
+ function addConnector(connector) {
1002
+ CONNECTORS.push(connector);
1003
+ }
1004
+ function findConnector(options) {
1005
+ return CONNECTORS.find((x) => {
1006
+ if (x.options.baseUrl === options.baseUrl) {
1007
+ if (options.auth) {
1008
+ if (x.options.auth) {
1009
+ return objectDeepEqual(x.options.auth, options.auth);
1010
+ }
1011
+ } else {
1012
+ return true;
1013
+ }
1014
+ }
1015
+ });
1016
+ }
1017
+ function removeConnector(connector) {
1018
+ const index = CONNECTORS.indexOf(connector);
1019
+ if (index !== -1) {
1020
+ CONNECTORS.splice(index, 1);
1021
+ }
1022
+ }
1023
+
1024
+ class AbortError extends Error {
1025
+ constructor(message = "AbortError") {
1026
+ super(message);
1027
+ this.name = "AbortError";
1028
+ }
1029
+ }
1030
+
1031
+ var __defProp$O = Object.defineProperty;
1032
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1033
+ var __publicField$x = (obj, key, value) => __defNormalProp$O(obj, typeof key !== "symbol" ? key + "" : key, value);
1000
1034
  class NgwError extends Error {
1001
1035
  constructor(er) {
1002
1036
  super();
1003
- __publicField$u(this, "name", "NgwError");
1004
- __publicField$u(this, "title");
1005
- __publicField$u(this, "message");
1006
- __publicField$u(this, "detail");
1007
- __publicField$u(this, "exception");
1008
- __publicField$u(this, "status_code");
1009
- __publicField$u(this, "data");
1010
- __publicField$u(this, "guru_meditation");
1037
+ __publicField$x(this, "name", "NgwError");
1038
+ __publicField$x(this, "title");
1039
+ __publicField$x(this, "message");
1040
+ __publicField$x(this, "detail");
1041
+ __publicField$x(this, "exception");
1042
+ __publicField$x(this, "status_code");
1043
+ __publicField$x(this, "data");
1044
+ __publicField$x(this, "guru_meditation");
1011
1045
  Object.assign(this, er);
1012
1046
  Object.setPrototypeOf(this, NgwError.prototype);
1013
1047
  }
1014
1048
  }
1015
1049
 
1016
- var __defProp$I = Object.defineProperty;
1017
- var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1018
- var __publicField$t = (obj, key, value) => __defNormalProp$I(obj, typeof key !== "symbol" ? key + "" : key, value);
1050
+ var __defProp$N = Object.defineProperty;
1051
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1052
+ var __publicField$w = (obj, key, value) => __defNormalProp$N(obj, typeof key !== "symbol" ? key + "" : key, value);
1053
+ class InsufficientPermissionsError extends NgwError {
1054
+ constructor(obj) {
1055
+ super(obj);
1056
+ __publicField$w(this, "name", "InsufficientPermissionsError");
1057
+ __publicField$w(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
1058
+ Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1059
+ }
1060
+ }
1061
+
1062
+ var __defProp$M = Object.defineProperty;
1063
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1064
+ var __publicField$v = (obj, key, value) => __defNormalProp$M(obj, typeof key !== "symbol" ? key + "" : key, value);
1019
1065
  class ResourceNotFoundError extends NgwError {
1020
1066
  constructor(obj) {
1021
1067
  super(obj);
1022
- __publicField$t(this, "name", "ResourceNotFoundError");
1023
- __publicField$t(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
1068
+ __publicField$v(this, "name", "ResourceNotFoundError");
1069
+ __publicField$v(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
1024
1070
  Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
1025
1071
  }
1026
1072
  }
1027
1073
 
1028
- function isObject(val) {
1029
- return Object.prototype.toString.call(val) === "[object Object]";
1074
+ var __defProp$L = Object.defineProperty;
1075
+ var __defNormalProp$L = (obj, key, value) => key in obj ? __defProp$L(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1076
+ var __publicField$u = (obj, key, value) => __defNormalProp$L(obj, typeof key !== "symbol" ? key + "" : key, value);
1077
+ class BaseAPIError extends Error {
1078
+ constructor(message) {
1079
+ super(message || "Something went wrong.");
1080
+ __publicField$u(this, "title");
1081
+ this.name = "BaseAPIError";
1082
+ this.title = "Unknown API error";
1083
+ if (Error.captureStackTrace) {
1084
+ Error.captureStackTrace(this, BaseAPIError);
1085
+ }
1086
+ }
1030
1087
  }
1031
-
1032
- function resourceCompare(res1, res2) {
1033
- return objectDeepEqual(res1, res2);
1088
+ class NetworksResponseError extends BaseAPIError {
1089
+ // prettier-ignore
1090
+ constructor(message) {
1091
+ super(message || "There is no response from the server or problem connecting to server.");
1092
+ __publicField$u(this, "detail");
1093
+ this.title = "Network error";
1094
+ this.detail = "Check network connectivity and try again later.";
1095
+ }
1034
1096
  }
1035
-
1036
- const exclude = ["description"];
1037
- function resourceToQuery(resource, prefix = "") {
1038
- prefix = prefix ? prefix + "__" : "";
1039
- const query = {};
1040
- for (const [key, value] of Object.entries(resource)) {
1041
- if (exclude.indexOf(key) === -1) {
1042
- if (isObject(value)) {
1043
- if (key === "owner_user") {
1044
- const children = resourceToQuery(value, key);
1045
- Object.assign(query, children);
1046
- } else if (key === "parent" && "id" in value) {
1047
- query.parent_id = value.id;
1048
- }
1049
- } else if (defined(value)) {
1050
- query[prefix + key] = value;
1051
- }
1097
+ class InvalidResponseError extends BaseAPIError {
1098
+ constructor(message) {
1099
+ super(message || "Something went wrong.");
1100
+ this.title = "Unexpected server response";
1101
+ }
1102
+ }
1103
+ class ServerResponseError extends BaseAPIError {
1104
+ constructor(data) {
1105
+ super(data.message);
1106
+ __publicField$u(this, "detail");
1107
+ __publicField$u(this, "data");
1108
+ this.title = data.title || this.title;
1109
+ this.detail = data.detail || null;
1110
+ this.data = data;
1111
+ }
1112
+ }
1113
+ class LunkwillError extends Error {
1114
+ // prettier-ignore
1115
+ constructor(message, data = {}) {
1116
+ super(message || "Unexpected error while processing long-running request.");
1117
+ __publicField$u(this, "title");
1118
+ __publicField$u(this, "data");
1119
+ this.name = "LunkwillError";
1120
+ this.title = "Long-running request error";
1121
+ this.data = data;
1122
+ if (Error.captureStackTrace) {
1123
+ Error.captureStackTrace(this, LunkwillError);
1052
1124
  }
1053
1125
  }
1054
- return query;
1126
+ }
1127
+ class LunkwillRequestCancelled extends LunkwillError {
1128
+ constructor(data) {
1129
+ super("Long-running request was cancelled.", data);
1130
+ }
1131
+ }
1132
+ class LunkwillRequestFailed extends LunkwillError {
1133
+ constructor(data) {
1134
+ super(void 0, data);
1135
+ }
1055
1136
  }
1056
1137
 
1057
- var __defProp$H = Object.defineProperty;
1058
- var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1059
- var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1060
- var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1061
- var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1062
- var __spreadValues$v = (a, b) => {
1138
+ var __defProp$K = Object.defineProperty;
1139
+ var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
1140
+ var __hasOwnProp$y = Object.prototype.hasOwnProperty;
1141
+ var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
1142
+ var __defNormalProp$K = (obj, key, value) => key in obj ? __defProp$K(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1143
+ var __spreadValues$x = (a, b) => {
1063
1144
  for (var prop in b || (b = {}))
1064
- if (__hasOwnProp$w.call(b, prop))
1065
- __defNormalProp$H(a, prop, b[prop]);
1066
- if (__getOwnPropSymbols$w)
1067
- for (var prop of __getOwnPropSymbols$w(b)) {
1068
- if (__propIsEnum$w.call(b, prop))
1069
- __defNormalProp$H(a, prop, b[prop]);
1145
+ if (__hasOwnProp$y.call(b, prop))
1146
+ __defNormalProp$K(a, prop, b[prop]);
1147
+ if (__getOwnPropSymbols$y)
1148
+ for (var prop of __getOwnPropSymbols$y(b)) {
1149
+ if (__propIsEnum$y.call(b, prop))
1150
+ __defNormalProp$K(a, prop, b[prop]);
1070
1151
  }
1071
1152
  return a;
1072
1153
  };
1073
- var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1074
- var __async$s = (__this, __arguments, generator) => {
1154
+ var __objRest$5 = (source, exclude) => {
1155
+ var target = {};
1156
+ for (var prop in source)
1157
+ if (__hasOwnProp$y.call(source, prop) && exclude.indexOf(prop) < 0)
1158
+ target[prop] = source[prop];
1159
+ if (source != null && __getOwnPropSymbols$y)
1160
+ for (var prop of __getOwnPropSymbols$y(source)) {
1161
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$y.call(source, prop))
1162
+ target[prop] = source[prop];
1163
+ }
1164
+ return target;
1165
+ };
1166
+ var __async$u = (__this, __arguments, generator) => {
1075
1167
  return new Promise((resolve, reject) => {
1076
1168
  var fulfilled = (value) => {
1077
1169
  try {
@@ -1091,307 +1183,238 @@ var __async$s = (__this, __arguments, generator) => {
1091
1183
  step((generator = generator.apply(__this, __arguments)).next());
1092
1184
  });
1093
1185
  };
1094
- class ResourcesControl {
1095
- constructor({
1096
- connector,
1097
- cacheId
1098
- }) {
1099
- __publicField$s(this, "cache");
1100
- __publicField$s(this, "connector");
1101
- this.connector = connector;
1102
- this.cache = new Cache({ namespace: cacheId });
1103
- }
1104
- // -------------------------------------------------------------------------
1105
- // Resource Methods
1106
- // -------------------------------------------------------------------------
1107
- /**
1108
- * Receive resource from NGW by id, keyname or search-object parameter.
1109
- * @param resource - Resource id, keyname or search-object
1110
- *
1111
- * @remarks
1112
- * Fetching resource would be cached to speed up next call
1113
- */
1114
- getOne(resource, requestOptions) {
1115
- const opt = __spreadValues$v({}, requestOptions);
1116
- if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
1117
- if (resource.id !== void 0) {
1118
- resource.id;
1119
- } else {
1120
- if (resource.keyname) {
1121
- resource.keyname;
1122
- }
1123
- if (resource.display_name) {
1124
- resource.display_name;
1125
- }
1186
+ function lunkwillCheckResponse(lwResp) {
1187
+ const ct = lwResp.headers.get("content-type");
1188
+ return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
1189
+ }
1190
+ function responseJson(response) {
1191
+ return __async$u(this, null, function* () {
1192
+ try {
1193
+ return response.json();
1194
+ } catch (e) {
1195
+ throw new Error();
1196
+ }
1197
+ });
1198
+ }
1199
+ function lunkwillResponseUrl(lwResp) {
1200
+ return __async$u(this, null, function* () {
1201
+ const lwData = yield responseJson(lwResp);
1202
+ let delay = lwData.delay_ms;
1203
+ const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
1204
+ const sum = `/api/lunkwill/${lwData.id}/summary`;
1205
+ const res = `/api/lunkwill/${lwData.id}/response`;
1206
+ const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec));
1207
+ let failed = false;
1208
+ let ready = false;
1209
+ while (!ready) {
1210
+ yield sleep(failed ? retry : delay);
1211
+ failed = false;
1212
+ let lwResp2;
1213
+ let lwData2;
1214
+ try {
1215
+ lwResp2 = yield fetch(sum, { credentials: "same-origin" });
1216
+ lwData2 = yield lwResp2.json();
1217
+ } catch (e) {
1218
+ failed = true;
1219
+ continue;
1220
+ }
1221
+ switch (lwData2.status) {
1222
+ case void 0:
1223
+ throw new LunkwillError(void 0, lwData2);
1224
+ case "ready":
1225
+ ready = true;
1226
+ break;
1227
+ case "cancelled":
1228
+ throw new LunkwillRequestCancelled(lwData2);
1229
+ case "failed":
1230
+ throw new LunkwillRequestFailed(lwData2);
1231
+ case "spooled":
1232
+ case "processing":
1233
+ case "buffering":
1234
+ delay = lwData2.delay_ms;
1235
+ break;
1236
+ default:
1237
+ throw new LunkwillError(void 0, lwData2);
1126
1238
  }
1127
1239
  }
1128
- if (typeof resource === "string") {
1129
- return this._fetchResourceBy({ keyname: resource }, opt);
1130
- } else if (typeof resource === "number") {
1131
- return this._fetchResourceById(resource, opt);
1132
- } else if (isObject(resource)) {
1133
- return this._fetchResourceBy(resource, opt);
1240
+ return res;
1241
+ });
1242
+ }
1243
+ function lunkwillFetch(lwRespUrl) {
1244
+ return __async$u(this, null, function* () {
1245
+ try {
1246
+ return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1247
+ } catch (e) {
1248
+ throw new NetworksResponseError();
1134
1249
  }
1135
- return Promise.resolve(void 0);
1136
- }
1137
- getOneOrFail(resource, requestOptions) {
1138
- return this.getOne(resource, requestOptions).then((res) => {
1139
- if (res) {
1140
- return res;
1141
- }
1142
- throw new ResourceNotFoundError();
1143
- });
1144
- }
1145
- /**
1146
- * A fast way to retrieve resource ID for any resource definition.
1147
- * @param resource - Any available resource definition
1148
- *
1149
- * @remarks
1150
- * There are situations when exactly the resource id is needed
1151
- * (for example, to compose the correct request to the api)
1152
- * then this method will come in handy to facilitate the extraction of the identifier
1153
- * if the resource is specified through a keyname or other parameters.
1154
- */
1155
- getId(resource, requestOptions) {
1156
- if (typeof resource === "number") {
1157
- return Promise.resolve(resource);
1158
- } else if (typeof resource === "string" || isObject(resource)) {
1159
- return this.getOne(resource, requestOptions).then((res) => {
1160
- if (res) {
1161
- return res.resource.id;
1250
+ });
1251
+ }
1252
+ const mediaContentTypes = [
1253
+ "application/pdf",
1254
+ "image/png",
1255
+ "image/jpeg",
1256
+ "image/tiff",
1257
+ "text/csv"
1258
+ ];
1259
+ const mediaContentTypesRegex = new RegExp(mediaContentTypes.join("|"));
1260
+ function isMediaContentType(contentType) {
1261
+ return mediaContentTypesRegex.test(contentType);
1262
+ }
1263
+ function encodeQueryParams(value) {
1264
+ const result = [];
1265
+ for (const [k, v] of Object.entries(value)) {
1266
+ if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
1267
+ result.push(`${k}=${encodeURIComponent(v)}`);
1268
+ } else if (Array.isArray(v)) {
1269
+ result.push(`${k}=${v.map(encodeURIComponent).join(",")}`);
1270
+ } else {
1271
+ for (const [sk, sv] of Object.entries(v)) {
1272
+ const ske = `${k}[${encodeURIComponent(sk)}]`;
1273
+ if (typeof sv === "string" || typeof sv === "number" || typeof sv === "boolean") {
1274
+ result.push(`${ske}=${encodeURIComponent(sv)}`);
1275
+ } else if (Array.isArray(sv)) {
1276
+ const sve = sv.map(encodeURIComponent);
1277
+ result.push(`${ske}=${sve.join(",")}`);
1162
1278
  }
1163
- });
1279
+ }
1164
1280
  }
1165
- return Promise.resolve(void 0);
1166
1281
  }
1167
- /**
1168
- * A fast way to retrieve resource ID for any resource definition.
1169
- * @param resource - Any available resource definition
1170
- *
1171
- * @remarks
1172
- * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
1173
- * To not make one more checks if the resource is definitely exists
1174
- */
1175
- getIdOrFail(resource, requestOptions) {
1176
- return this.getId(resource, requestOptions).then((resp) => {
1177
- if (resp === void 0) {
1178
- throw new Error();
1179
- }
1180
- return resp;
1181
- });
1282
+ return result.join("&");
1283
+ }
1284
+ function generateUrl(path, query) {
1285
+ let urlParams = "";
1286
+ if (query !== void 0) {
1287
+ urlParams = "?" + encodeQueryParams(query);
1182
1288
  }
1183
- getMany(resource, requestOptions) {
1184
- return this._resourceCacheFilter(resource).then((items) => {
1185
- if (!items.length) {
1186
- const query = {};
1187
- if (resource.keyname) {
1188
- query.keyname = resource.keyname;
1289
+ return path + urlParams;
1290
+ }
1291
+ function request(path, options, cacheEngine) {
1292
+ return __async$u(this, null, function* () {
1293
+ var _b;
1294
+ const defaults = {
1295
+ method: "GET",
1296
+ credentials: "same-origin",
1297
+ headers: {}
1298
+ };
1299
+ const _a = __spreadValues$x(__spreadValues$x({}, defaults), options), {
1300
+ withCredentials,
1301
+ responseType,
1302
+ cacheProps,
1303
+ cacheName,
1304
+ lunkwill,
1305
+ cache,
1306
+ query,
1307
+ json
1308
+ } = _a, opt = __objRest$5(_a, [
1309
+ "withCredentials",
1310
+ "responseType",
1311
+ "cacheProps",
1312
+ "cacheName",
1313
+ "lunkwill",
1314
+ "cache",
1315
+ "query",
1316
+ "json"
1317
+ ]);
1318
+ if (withCredentials) {
1319
+ opt.credentials = "include";
1320
+ }
1321
+ let useLunkwill = false;
1322
+ if (lunkwill !== void 0) {
1323
+ lunkwill.toHeaders(opt.headers || {});
1324
+ useLunkwill = true;
1325
+ }
1326
+ const lunkwillReturnUrl = !!opt.lunkwillReturnUrl;
1327
+ delete opt.lunkwillReturnUrl;
1328
+ if (json !== void 0) {
1329
+ opt.body = JSON.stringify(json);
1330
+ const headers = opt.headers || {};
1331
+ headers["Content-Type"] = "application/json";
1332
+ opt.headers = headers;
1333
+ }
1334
+ const url = generateUrl(path, query);
1335
+ const makeRequest = () => __async$u(this, null, function* () {
1336
+ let response;
1337
+ try {
1338
+ response = yield fetch(url, opt);
1339
+ } catch (e) {
1340
+ if (e.name === "AbortError") {
1341
+ throw e;
1342
+ }
1343
+ throw new NetworksResponseError();
1344
+ }
1345
+ if (useLunkwill && lunkwillCheckResponse(response)) {
1346
+ const lwRespUrl = yield lunkwillResponseUrl(response);
1347
+ if (lunkwillReturnUrl) {
1348
+ return lwRespUrl;
1349
+ }
1350
+ response = yield lunkwillFetch(lwRespUrl);
1351
+ }
1352
+ const respCType = response.headers.get("content-type");
1353
+ const respJSON = respCType && (respCType.includes("application/json") || respCType.includes("application/vnd.lunkwill.request-summary+json"));
1354
+ let body;
1355
+ try {
1356
+ const respMedia = respCType && isMediaContentType(respCType);
1357
+ if (responseType === "blob" || respMedia) {
1358
+ body = yield response.blob();
1359
+ } else if (respJSON) {
1360
+ body = yield response.json();
1189
1361
  } else {
1190
- Object.assign(query, resourceToQuery(resource));
1362
+ throw new InvalidResponseError();
1191
1363
  }
1192
- return this.connector.get("resource.search", requestOptions, __spreadValues$v({
1193
- serialization: "full"
1194
- }, query)).then((resources) => {
1195
- if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
1196
- for (const x of resources) {
1197
- this.cache.add("resource.item", Promise.resolve(x), {
1198
- id: x.resource.id
1199
- });
1200
- }
1201
- }
1202
- return resources;
1203
- });
1364
+ } catch (e) {
1365
+ if (e.name === "AbortError" || e instanceof InvalidResponseError) {
1366
+ throw e;
1367
+ }
1368
+ throw new InvalidResponseError();
1204
1369
  }
1205
- return items;
1206
- });
1207
- }
1208
- getParent(resource, requestOptions) {
1209
- return this.getOne(resource, requestOptions).then((child) => {
1210
- if (child) {
1211
- return this.getOne(child.resource.parent.id, requestOptions);
1370
+ if (400 <= response.status && response.status <= 599) {
1371
+ throw new ServerResponseError(body);
1212
1372
  }
1213
- return Promise.resolve(void 0);
1373
+ return body;
1214
1374
  });
1215
- }
1216
- getChildrenOf(resource, requestOptions) {
1217
- return this.getIdOrFail(resource).then(
1218
- (parent) => this._getChildrenOf(parent, requestOptions)
1219
- );
1220
- }
1221
- update(resource, data) {
1222
- return this.getId(resource).then((id) => {
1223
- if (id !== void 0) {
1224
- return this.connector.put("resource.item", { data }, { id });
1225
- }
1226
- });
1227
- }
1228
- /**
1229
- * Fast way to delete resource from NGW and clean cache.
1230
- * @param resource - Resource definition
1231
- */
1232
- delete(resource) {
1233
- return this.getId(resource).then((id) => {
1234
- if (id !== void 0) {
1235
- return this.connector.delete("resource.item", null, { id }).then(() => {
1236
- this._cleanResourceItemCache(id);
1237
- return void 0;
1238
- });
1239
- }
1240
- });
1241
- }
1242
- _getChildrenOf(parent, requestOptions, _items = []) {
1243
- return this.connector.get("resource.collection", requestOptions, {
1244
- parent
1245
- }).then((items) => {
1246
- const recursivePromises = [];
1247
- for (const item of items) {
1248
- if (requestOptions == null ? void 0 : requestOptions.cache) {
1249
- this.cache.add("resource.item", Promise.resolve(item), {
1250
- id: item.resource.id
1251
- });
1252
- }
1253
- _items.push(item);
1254
- if ((requestOptions == null ? void 0 : requestOptions.recursive) && item.resource.children) {
1255
- recursivePromises.push(
1256
- this._getChildrenOf(item.resource.id, requestOptions, _items)
1257
- );
1258
- }
1259
- }
1260
- if (recursivePromises.length) {
1261
- return Promise.all(recursivePromises).then(() => {
1262
- return _items;
1263
- });
1264
- }
1265
- return _items;
1266
- });
1267
- }
1268
- _cleanResourceItemCache(id) {
1269
- return __async$s(this, null, function* () {
1270
- var _a;
1271
- const all = this.cache.all();
1272
- const toDelete = [];
1273
- for (const c of all) {
1274
- const cid = (_a = c.props) == null ? void 0 : _a.id;
1275
- if (["resource.item", "resource"].includes(c.key) && cid !== void 0) {
1276
- if (typeof cid === "number") {
1277
- if (cid === id) {
1278
- toDelete.push(c);
1279
- }
1280
- } else {
1281
- const rid = yield this.getId(cid);
1282
- if (rid === id) {
1283
- toDelete.push(c);
1284
- }
1285
- }
1286
- }
1287
- }
1288
- for (const d of toDelete) {
1289
- this.cache.delete(d);
1290
- }
1291
- });
1292
- }
1293
- _fetchResourceById(id, requestOptions) {
1294
- return this.connector.get("resource.item", requestOptions, { id });
1295
- }
1296
- _fetchResourceBy(resource, requestOptions) {
1297
- return this.getMany(resource, requestOptions).then((resources) => {
1298
- return resources[0];
1299
- });
1300
- }
1301
- _resourceCacheFilter(resource) {
1302
- return Promise.all(this.cache.matchAll("resource.item")).then(
1303
- (resources) => {
1304
- const items = [];
1305
- resources.filter((x) => {
1306
- if (x) {
1307
- if (resource.keyname && x.resource.keyname) {
1308
- return resource.keyname === x.resource.keyname;
1309
- }
1310
- if (defined(resource.id) && defined(x.resource.id)) {
1311
- return resource.id === x.resource.id;
1312
- }
1313
- return resourceCompare(resource, x.resource);
1314
- }
1315
- });
1316
- return items;
1317
- }
1318
- );
1319
- }
1320
- }
1321
-
1322
- const CONNECTORS = [];
1323
- function addConnector(connector) {
1324
- CONNECTORS.push(connector);
1325
- }
1326
- function findConnector(options) {
1327
- return CONNECTORS.find((x) => {
1328
- if (x.options.baseUrl === options.baseUrl) {
1329
- if (options.auth) {
1330
- if (x.options.auth) {
1331
- return objectDeepEqual(x.options.auth, options.auth);
1332
- }
1333
- } else {
1334
- return true;
1335
- }
1336
- }
1337
- });
1338
- }
1339
- function removeConnector(connector) {
1340
- const index = CONNECTORS.indexOf(connector);
1341
- if (index !== -1) {
1342
- CONNECTORS.splice(index, 1);
1343
- }
1344
- }
1345
-
1346
- class AbortError extends Error {
1347
- constructor(message = "AbortError") {
1348
- super(message);
1349
- this.name = "AbortError";
1350
- }
1351
- }
1352
-
1353
- var __defProp$G = Object.defineProperty;
1354
- var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1355
- var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
1356
- class InsufficientPermissionsError extends NgwError {
1357
- constructor(obj) {
1358
- super(obj);
1359
- __publicField$r(this, "name", "InsufficientPermissionsError");
1360
- __publicField$r(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
1361
- Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1362
- }
1363
- }
1364
-
1365
- const templateRe = /\{ *([\w_-]+) *\}/g;
1366
- function template(str, data) {
1367
- return str.replace(templateRe, (s, key) => {
1368
- let value = data[key];
1369
- if (value === void 0) {
1370
- throw new Error("No value provided for letiable " + s);
1371
- } else if (typeof value === "function") {
1372
- value = value(data);
1375
+ if (cacheEngine && cache && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1376
+ const cacheOptions = cacheProps ? cacheProps : __spreadValues$x({}, objectRemoveEmpty({
1377
+ withCredentials,
1378
+ responseType
1379
+ }));
1380
+ return cacheEngine.add(cacheName || url, makeRequest, cacheOptions, false);
1373
1381
  }
1374
- return value;
1382
+ return makeRequest();
1375
1383
  });
1376
1384
  }
1377
1385
 
1378
- var __defProp$F = Object.defineProperty;
1379
- var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1380
- var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1381
- var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
1382
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1383
- var __spreadValues$u = (a, b) => {
1386
+ var __defProp$J = Object.defineProperty;
1387
+ var __defProps$h = Object.defineProperties;
1388
+ var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
1389
+ var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
1390
+ var __hasOwnProp$x = Object.prototype.hasOwnProperty;
1391
+ var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
1392
+ var __defNormalProp$J = (obj, key, value) => key in obj ? __defProp$J(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1393
+ var __spreadValues$w = (a, b) => {
1384
1394
  for (var prop in b || (b = {}))
1385
- if (__hasOwnProp$v.call(b, prop))
1386
- __defNormalProp$F(a, prop, b[prop]);
1387
- if (__getOwnPropSymbols$v)
1388
- for (var prop of __getOwnPropSymbols$v(b)) {
1389
- if (__propIsEnum$v.call(b, prop))
1390
- __defNormalProp$F(a, prop, b[prop]);
1395
+ if (__hasOwnProp$x.call(b, prop))
1396
+ __defNormalProp$J(a, prop, b[prop]);
1397
+ if (__getOwnPropSymbols$x)
1398
+ for (var prop of __getOwnPropSymbols$x(b)) {
1399
+ if (__propIsEnum$x.call(b, prop))
1400
+ __defNormalProp$J(a, prop, b[prop]);
1391
1401
  }
1392
1402
  return a;
1393
1403
  };
1394
- var __async$r = (__this, __arguments, generator) => {
1404
+ var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
1405
+ var __objRest$4 = (source, exclude) => {
1406
+ var target = {};
1407
+ for (var prop in source)
1408
+ if (__hasOwnProp$x.call(source, prop) && exclude.indexOf(prop) < 0)
1409
+ target[prop] = source[prop];
1410
+ if (source != null && __getOwnPropSymbols$x)
1411
+ for (var prop of __getOwnPropSymbols$x(source)) {
1412
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$x.call(source, prop))
1413
+ target[prop] = source[prop];
1414
+ }
1415
+ return target;
1416
+ };
1417
+ var __async$t = (__this, __arguments, generator) => {
1395
1418
  return new Promise((resolve, reject) => {
1396
1419
  var fulfilled = (value) => {
1397
1420
  try {
@@ -1411,70 +1434,94 @@ var __async$r = (__this, __arguments, generator) => {
1411
1434
  step((generator = generator.apply(__this, __arguments)).next());
1412
1435
  });
1413
1436
  };
1414
- function apiRequest(opt) {
1415
- return __async$r(this, null, function* () {
1416
- const { params, name, connector, requestOptions } = opt;
1417
- const apiItems = yield connector.connect();
1418
- let apiItem = apiItems && apiItems[name];
1419
- if (apiItem) {
1420
- apiItem = [...apiItem];
1421
- let url = apiItem.shift();
1422
- if (apiItem.length) {
1423
- const replaceParams = {};
1424
- for (let fry = 0; fry < apiItem.length; fry++) {
1425
- const arg = apiItem[fry];
1426
- replaceParams[fry] = `{${arg}}`;
1427
- if (params[arg] === void 0) {
1428
- throw new Error(`\`${arg}\` URL API argument is not specified`);
1429
- }
1430
- }
1431
- if (url) {
1432
- url = template(url, replaceParams);
1433
- }
1434
- }
1435
- if (params) {
1436
- const paramArray = [];
1437
- const paramList = params.paramList;
1438
- if (Array.isArray(paramList)) {
1439
- paramList.forEach(([key, value]) => {
1440
- paramArray.push(`${key}=${value}`);
1441
- });
1442
- }
1443
- for (const p in params) {
1444
- if (apiItem.indexOf(p) === -1) {
1445
- paramArray.push(`${p}=${params[p]}`);
1446
- }
1447
- }
1448
- if (paramArray.length) {
1449
- url = `${url}?${paramArray.join("&")}`;
1450
- }
1451
- }
1452
- if (url) {
1453
- return connector.makeQuery(url, params, __spreadValues$u({
1454
- cacheName: name
1455
- }, requestOptions));
1456
- } else {
1457
- throw new Error("Request URL is not set");
1458
- }
1459
- } else {
1460
- return void 0;
1437
+ function routeURL(name, baseUrl, routeData, ...rest) {
1438
+ const [template, ...params] = routeData[name];
1439
+ const first = rest[0];
1440
+ let sub;
1441
+ if (first === void 0) {
1442
+ sub = [];
1443
+ } else if (typeof first === "object" && first !== null) {
1444
+ if (rest.length > 1) {
1445
+ throw new Error("Too many arguments for route(name, object)!");
1446
+ }
1447
+ sub = [];
1448
+ for (const [p, v] of Object.entries(first)) {
1449
+ sub[params.indexOf(p)] = String(v);
1461
1450
  }
1462
- });
1451
+ } else {
1452
+ sub = rest.map((v) => String(v));
1453
+ }
1454
+ return fixUrlStr(
1455
+ baseUrl + template.replace(/\{(\w+)\}/g, function(m, a) {
1456
+ const idx = parseInt(a);
1457
+ const value = sub[idx];
1458
+ if (value === void 0) {
1459
+ const msg = `Undefined parameter ${idx} in "${template}".`;
1460
+ throw new Error(msg);
1461
+ }
1462
+ return String(value);
1463
+ })
1464
+ );
1465
+ }
1466
+ function route(name, connector, ...rest) {
1467
+ const result = {
1468
+ url: (opt) => __async$t(this, null, function* () {
1469
+ var _a;
1470
+ const routeData = yield connector.connect();
1471
+ const template = routeURL(
1472
+ name,
1473
+ (_a = connector.options.baseUrl) != null ? _a : "",
1474
+ routeData,
1475
+ ...rest
1476
+ );
1477
+ return generateUrl(template, opt == null ? void 0 : opt.query);
1478
+ })
1479
+ };
1480
+ const methods = ["get", "post", "put", "delete", "patch"];
1481
+ for (const method of methods) {
1482
+ const methodResp = (requestOptions) => __async$t(this, null, function* () {
1483
+ var _b;
1484
+ const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$4(_a, ["headers"]);
1485
+ const routeData = yield connector.connect();
1486
+ const template = routeURL(
1487
+ name,
1488
+ (_b = connector.options.baseUrl) != null ? _b : "",
1489
+ routeData,
1490
+ ...rest
1491
+ );
1492
+ const headers = objectRemoveEmpty(__spreadValues$w(__spreadValues$w({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1493
+ return request(
1494
+ template,
1495
+ __spreadProps$h(__spreadValues$w({
1496
+ headers
1497
+ }, restOpt), {
1498
+ method
1499
+ }),
1500
+ connector.cache
1501
+ );
1502
+ });
1503
+ result[method] = methodResp;
1504
+ }
1505
+ return result;
1463
1506
  }
1464
1507
 
1465
- var __defProp$E = Object.defineProperty;
1466
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1467
- var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
1508
+ var __defProp$I = Object.defineProperty;
1509
+ var __defNormalProp$I = (obj, key, value) => key in obj ? __defProp$I(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1510
+ var __publicField$t = (obj, key, value) => __defNormalProp$I(obj, key + "" , value);
1468
1511
  class NetworkError extends Error {
1469
1512
  constructor(url) {
1470
1513
  super();
1471
- __publicField$q(this, "name", "NetworkError");
1514
+ __publicField$t(this, "name", "NetworkError");
1472
1515
  Object.setPrototypeOf(this, NetworkError.prototype);
1473
1516
  this.message = `Unable to request ${url}.
1474
1517
  Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
1475
1518
  }
1476
1519
  }
1477
1520
 
1521
+ function isObject(val) {
1522
+ return Object.prototype.toString.call(val) === "[object Object]";
1523
+ }
1524
+
1478
1525
  let loadData;
1479
1526
  {
1480
1527
  loadData = (url, callback, options = {}, error, onCancel) => {
@@ -1557,39 +1604,52 @@ let loadData;
1557
1604
  };
1558
1605
  }
1559
1606
 
1560
- var __defProp$D = Object.defineProperty;
1561
- var __defProps$f = Object.defineProperties;
1562
- var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
1563
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1564
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1565
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1566
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1567
- var __spreadValues$t = (a, b) => {
1568
- for (var prop in b || (b = {}))
1569
- if (__hasOwnProp$u.call(b, prop))
1570
- __defNormalProp$D(a, prop, b[prop]);
1571
- if (__getOwnPropSymbols$u)
1572
- for (var prop of __getOwnPropSymbols$u(b)) {
1573
- if (__propIsEnum$u.call(b, prop))
1574
- __defNormalProp$D(a, prop, b[prop]);
1607
+ const templateRe = /\{ *([\w_-]+) *\}/g;
1608
+ function template(str, data) {
1609
+ return str.replace(templateRe, (s, key) => {
1610
+ let value = data[key];
1611
+ if (value === void 0) {
1612
+ throw new Error("No value provided for letiable " + s);
1613
+ } else if (typeof value === "function") {
1614
+ value = value(data);
1615
+ }
1616
+ return value;
1617
+ });
1618
+ }
1619
+
1620
+ var __defProp$H = Object.defineProperty;
1621
+ var __defProps$g = Object.defineProperties;
1622
+ var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
1623
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1624
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1625
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1626
+ var __defNormalProp$H = (obj, key, value) => key in obj ? __defProp$H(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1627
+ var __spreadValues$v = (a, b) => {
1628
+ for (var prop in b || (b = {}))
1629
+ if (__hasOwnProp$w.call(b, prop))
1630
+ __defNormalProp$H(a, prop, b[prop]);
1631
+ if (__getOwnPropSymbols$w)
1632
+ for (var prop of __getOwnPropSymbols$w(b)) {
1633
+ if (__propIsEnum$w.call(b, prop))
1634
+ __defNormalProp$H(a, prop, b[prop]);
1575
1635
  }
1576
1636
  return a;
1577
1637
  };
1578
- var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
1579
- var __objRest$2 = (source, exclude) => {
1638
+ var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
1639
+ var __objRest$3 = (source, exclude) => {
1580
1640
  var target = {};
1581
1641
  for (var prop in source)
1582
- if (__hasOwnProp$u.call(source, prop) && exclude.indexOf(prop) < 0)
1642
+ if (__hasOwnProp$w.call(source, prop) && exclude.indexOf(prop) < 0)
1583
1643
  target[prop] = source[prop];
1584
- if (source != null && __getOwnPropSymbols$u)
1585
- for (var prop of __getOwnPropSymbols$u(source)) {
1586
- if (exclude.indexOf(prop) < 0 && __propIsEnum$u.call(source, prop))
1644
+ if (source != null && __getOwnPropSymbols$w)
1645
+ for (var prop of __getOwnPropSymbols$w(source)) {
1646
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$w.call(source, prop))
1587
1647
  target[prop] = source[prop];
1588
1648
  }
1589
1649
  return target;
1590
1650
  };
1591
- var __publicField$p = (obj, key, value) => __defNormalProp$D(obj, typeof key !== "symbol" ? key + "" : key, value);
1592
- var __async$q = (__this, __arguments, generator) => {
1651
+ var __publicField$s = (obj, key, value) => __defNormalProp$H(obj, typeof key !== "symbol" ? key + "" : key, value);
1652
+ var __async$s = (__this, __arguments, generator) => {
1593
1653
  return new Promise((resolve, reject) => {
1594
1654
  var fulfilled = (value) => {
1595
1655
  try {
@@ -1614,24 +1674,23 @@ let REQUEST_ID = 0;
1614
1674
  class NgwConnector {
1615
1675
  constructor(options) {
1616
1676
  this.options = options;
1617
- __publicField$p(this, "id", ID$2++);
1618
- __publicField$p(this, "emitter", new EventEmitter());
1619
- __publicField$p(this, "user");
1620
- __publicField$p(this, "resources");
1621
- __publicField$p(this, "cache");
1622
- __publicField$p(this, "withCredentials");
1623
- __publicField$p(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
1624
- __publicField$p(this, "routeStr", "/api/component/pyramid/route");
1625
- __publicField$p(this, "activeRequests", {});
1626
- __publicField$p(this, "requestTransform");
1677
+ __publicField$s(this, "id", ID$2++);
1678
+ __publicField$s(this, "emitter", new EventEmitter());
1679
+ __publicField$s(this, "user");
1680
+ __publicField$s(this, "cache");
1681
+ __publicField$s(this, "withCredentials");
1682
+ __publicField$s(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
1683
+ __publicField$s(this, "routeStr", "/api/component/pyramid/route");
1684
+ __publicField$s(this, "activeRequests", {});
1685
+ __publicField$s(this, "requestTransform");
1627
1686
  const exist = findConnector(options);
1628
1687
  this.cache = new Cache({ namespace: options.cacheId });
1629
1688
  if (exist) {
1630
1689
  return exist;
1631
1690
  } else {
1632
- const { route, requestTransform, withCredentials } = this.options;
1633
- if (route) {
1634
- this.routeStr = route;
1691
+ const { route: route2, requestTransform, withCredentials } = this.options;
1692
+ if (route2) {
1693
+ this.routeStr = route2;
1635
1694
  }
1636
1695
  if (requestTransform) {
1637
1696
  this.requestTransform = requestTransform;
@@ -1639,10 +1698,6 @@ class NgwConnector {
1639
1698
  if (withCredentials !== void 0) {
1640
1699
  this.withCredentials = withCredentials;
1641
1700
  }
1642
- this.resources = new ResourcesControl({
1643
- connector: this,
1644
- cacheId: options.cacheId
1645
- });
1646
1701
  addConnector(this);
1647
1702
  }
1648
1703
  }
@@ -1654,7 +1709,6 @@ class NgwConnector {
1654
1709
  */
1655
1710
  clearCache() {
1656
1711
  this.cache.clean();
1657
- this.resources.cache.clean();
1658
1712
  }
1659
1713
  setRequestTransform(requestTransform) {
1660
1714
  this.requestTransform = requestTransform;
@@ -1676,14 +1730,14 @@ class NgwConnector {
1676
1730
  * Can be used to check connection.
1677
1731
  * @example
1678
1732
  * ```javascript
1679
- * const connector = new NgwConnector({baseUrl: 'https://demo.nextgis.com'});
1733
+ * const connector = new NgwConnector({ baseUrl: 'https://demo.nextgis.com' });
1680
1734
  * connector.connect()
1681
1735
  * .then(() => console.log('Ok'))
1682
1736
  * .catch((er) => console.log('Connection problem', er));
1683
1737
  * ```
1684
1738
  */
1685
1739
  connect() {
1686
- return __async$q(this, null, function* () {
1740
+ return __async$s(this, null, function* () {
1687
1741
  const auth = this.options.auth;
1688
1742
  if (auth) {
1689
1743
  const { login, password } = auth;
@@ -1728,15 +1782,16 @@ class NgwConnector {
1728
1782
  this.emitter.emit("logout");
1729
1783
  }
1730
1784
  getUserInfo(credentials, options) {
1731
- return __async$q(this, null, function* () {
1785
+ return __async$s(this, null, function* () {
1732
1786
  if (this.user && this.user.id) {
1733
1787
  return this.user;
1734
1788
  }
1735
1789
  if (credentials) {
1736
1790
  this.options.auth = credentials;
1737
1791
  }
1738
- const options_ = __spreadValues$t({
1739
- headers: this.getAuthorizationHeaders(credentials)
1792
+ const options_ = __spreadValues$v({
1793
+ headers: this.getAuthorizationHeaders(credentials),
1794
+ cache: true
1740
1795
  }, options);
1741
1796
  return this.makeQuery(
1742
1797
  "/api/component/auth/current_user",
@@ -1755,6 +1810,7 @@ class NgwConnector {
1755
1810
  Authorization: `Basic ${client}`
1756
1811
  };
1757
1812
  }
1813
+ return {};
1758
1814
  }
1759
1815
  makeClientId(credentials) {
1760
1816
  credentials = credentials || this.options.auth;
@@ -1774,124 +1830,10 @@ class NgwConnector {
1774
1830
  this.activeRequests = {};
1775
1831
  }
1776
1832
  getActiveApiRequests() {
1777
- return __spreadValues$t({}, this.activeRequests);
1778
- }
1779
- /**
1780
- * Send request to NGW api router.
1781
- * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1782
- * @param params - Request item params or query params
1783
- * @param requestOptions - Request options
1784
- *
1785
- * @example
1786
- * ```javascript
1787
- *
1788
- * // there is such an NGW route item
1789
- * // "feature_layer.feature.item": [
1790
- * // "/api/resource/{0}/feature/{1}",
1791
- * // "id",
1792
- * // "fid"
1793
- * // ],
1794
- *
1795
- * const connector = new NgwConnector({ baseUrl: 'https://example.nextgis.com' });
1796
- * connector.apiRequest('feature_layer.feature.item', {
1797
- * // request params for {0} and {1}
1798
- * 'id': 2011,
1799
- * 'fid': 101,
1800
- * // query params
1801
- * 'srs': 4326,
1802
- * 'geom_format': 'geojson',
1803
- * }, { method: 'GET' });
1804
- * // send get-request to 'https://example.nextgis.com/api/resource/2011/feature/101?srs=4326&geom_format=geojson'
1805
- *
1806
- * ```
1807
- */
1808
- apiRequest(name, params_ = {}, requestOptions = {}) {
1809
- var _a;
1810
- params_ = (_a = requestOptions.params) != null ? _a : params_;
1811
- const params = objectRemoveEmpty(params_);
1812
- return apiRequest({ name, params, requestOptions, connector: this });
1813
- }
1814
- /**
1815
- * Shortcut method for send POST request to NGW.
1816
- * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1817
- * @param options - Request options
1818
- * @param params - Request item params or query params
1819
- *
1820
- * @example
1821
- * ```javascript
1822
- * connector.post('resource.collection', { data: POST_PAYLOAD })
1823
- * .then((newResource) => console.log(newResource))
1824
- * .catch((error) => console.warn(error));
1825
- * ```
1826
- */
1827
- post(name, options, params) {
1828
- options = options || {};
1829
- options.method = "POST";
1830
- return this.apiRequest(
1831
- name,
1832
- params,
1833
- options
1834
- );
1835
- }
1836
- /**
1837
- * Shortcut method for send GET request to NGW.
1838
- * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1839
- * @param options - Request options
1840
- * @param params - Request item params or query params
1841
- */
1842
- get(name, options, params) {
1843
- options = options || {};
1844
- options.method = "GET";
1845
- return this.apiRequest(
1846
- name,
1847
- params,
1848
- options
1849
- );
1850
- }
1851
- /**
1852
- * Shortcut method for send PATCH request to NGW.
1853
- * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1854
- * @param options - Request options
1855
- * @param params - Request item params or query params
1856
- */
1857
- patch(name, options, params) {
1858
- options = options || {};
1859
- options.method = "PATCH";
1860
- return this.apiRequest(
1861
- name,
1862
- params,
1863
- options
1864
- );
1865
- }
1866
- /**
1867
- * Shortcut method for send PUT request to NGW.
1868
- * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1869
- * @param options - Request options
1870
- * @param params - Request item params or query params
1871
- */
1872
- put(name, options, params) {
1873
- options = options || {};
1874
- options.method = "PUT";
1875
- return this.apiRequest(
1876
- name,
1877
- params,
1878
- options
1879
- );
1833
+ return __spreadValues$v({}, this.activeRequests);
1880
1834
  }
1881
- /**
1882
- * Shortcut method for send DELETE request to NGW.
1883
- * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1884
- * @param options - Request options
1885
- * @param params - Request item params or query params
1886
- */
1887
- delete(name, options, params) {
1888
- options = options || {};
1889
- options.method = "DELETE";
1890
- return this.apiRequest(
1891
- name,
1892
- params,
1893
- options
1894
- );
1835
+ route(name, ...rest) {
1836
+ return route(name, this, ...rest);
1895
1837
  }
1896
1838
  /**
1897
1839
  * Send request to NGW.
@@ -1900,18 +1842,18 @@ class NgwConnector {
1900
1842
  * @param options - Request options
1901
1843
  */
1902
1844
  makeQuery(_0, _1) {
1903
- return __async$q(this, arguments, function* (url, params, options = {}) {
1845
+ return __async$s(this, arguments, function* (url, params, options = {}) {
1904
1846
  var _b;
1905
1847
  url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1906
1848
  if (!url) {
1907
1849
  throw new Error("Empty `url` not allowed");
1908
1850
  }
1909
1851
  if (params) {
1910
- const _a = params, restParams = __objRest$2(_a, ["paramList"]);
1852
+ const _a = params, restParams = __objRest$3(_a, ["paramList"]);
1911
1853
  url = template(url, restParams);
1912
1854
  }
1913
1855
  url = encodeURI(fixUrlStr(url));
1914
- options = __spreadValues$t({ withCredentials: this.withCredentials }, options);
1856
+ options = __spreadValues$v({ withCredentials: this.withCredentials }, options);
1915
1857
  const {
1916
1858
  cache,
1917
1859
  signal: externalSignal,
@@ -1933,7 +1875,7 @@ class NgwConnector {
1933
1875
  });
1934
1876
  }
1935
1877
  options.signal = internalSignal;
1936
- const createPromise = () => __async$q(this, null, function* () {
1878
+ const createPromise = () => __async$s(this, null, function* () {
1937
1879
  const id = REQUEST_ID++;
1938
1880
  this.activeRequests[id] = internalAbortController;
1939
1881
  try {
@@ -1943,7 +1885,7 @@ class NgwConnector {
1943
1885
  }
1944
1886
  });
1945
1887
  if (cache && method === "GET") {
1946
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$f(__spreadValues$t({}, objectRemoveEmpty({
1888
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$g(__spreadValues$v({}, objectRemoveEmpty({
1947
1889
  headers,
1948
1890
  withCredentials,
1949
1891
  responseType,
@@ -1962,6 +1904,590 @@ class NgwConnector {
1962
1904
  return createPromise();
1963
1905
  });
1964
1906
  }
1907
+ _loadData(url, options) {
1908
+ options.responseType = options.responseType || "json";
1909
+ return new Promise((resolve, reject) => {
1910
+ var _a;
1911
+ if (this.user) {
1912
+ options = options || {};
1913
+ options.headers = __spreadValues$v(__spreadValues$v({}, this.getAuthorizationHeaders()), options.headers);
1914
+ }
1915
+ if (this.requestTransform) {
1916
+ const [transUrl, transOptions] = this.requestTransform(url, options);
1917
+ url = transUrl;
1918
+ options = transOptions;
1919
+ }
1920
+ let runOnAbort = void 0;
1921
+ loadData(url, resolve, options, reject, (handler) => {
1922
+ runOnAbort = handler;
1923
+ });
1924
+ (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
1925
+ if (runOnAbort !== void 0) {
1926
+ runOnAbort();
1927
+ }
1928
+ reject(new AbortError());
1929
+ });
1930
+ }).catch((httpError) => {
1931
+ if (httpError.name !== "AbortError") {
1932
+ {
1933
+ console.warn("DEV WARN", httpError);
1934
+ }
1935
+ const er = this._handleHttpError(httpError);
1936
+ if (er) {
1937
+ throw er;
1938
+ }
1939
+ }
1940
+ throw httpError;
1941
+ });
1942
+ }
1943
+ _login(credentials, options) {
1944
+ return __async$s(this, null, function* () {
1945
+ try {
1946
+ const data = yield this.getUserInfo(credentials, options);
1947
+ this.user = data;
1948
+ this.emitter.emit("login", data);
1949
+ return data;
1950
+ } catch (er) {
1951
+ this.emitter.emit("login:error", er);
1952
+ throw er;
1953
+ }
1954
+ });
1955
+ }
1956
+ _cleanActiveRequest(requestId) {
1957
+ delete this.activeRequests[requestId];
1958
+ }
1959
+ _handleHttpError(er) {
1960
+ if (er) {
1961
+ if (er instanceof NgwError) {
1962
+ if (er.exception === "nextgisweb.resource.exception.ResourceNotFound") {
1963
+ throw new ResourceNotFoundError(er);
1964
+ } else if (er.exception === "nextgisweb.core.exception.InsufficientPermissions") {
1965
+ throw new InsufficientPermissionsError(er);
1966
+ }
1967
+ }
1968
+ }
1969
+ return er;
1970
+ }
1971
+ }
1972
+ __publicField$s(NgwConnector, "errors", {
1973
+ NgwError,
1974
+ ResourceNotFoundError
1975
+ });
1976
+
1977
+ function resourceCompare(res1, res2) {
1978
+ return objectDeepEqual(res1, res2);
1979
+ }
1980
+
1981
+ const exclude = ["description"];
1982
+ function resourceToQuery(resource, prefix = "") {
1983
+ prefix = prefix ? prefix + "__" : "";
1984
+ const query = {};
1985
+ for (const [key, value] of Object.entries(resource)) {
1986
+ if (exclude.indexOf(key) === -1) {
1987
+ if (isObject(value)) {
1988
+ if (key === "owner_user") {
1989
+ const children = resourceToQuery(value, key);
1990
+ Object.assign(query, children);
1991
+ } else if (key === "parent" && "id" in value) {
1992
+ query.parent_id = value.id;
1993
+ }
1994
+ } else if (defined(value)) {
1995
+ query[prefix + key] = value;
1996
+ }
1997
+ }
1998
+ }
1999
+ return query;
2000
+ }
2001
+
2002
+ var __defProp$G = Object.defineProperty;
2003
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
2004
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
2005
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
2006
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2007
+ var __spreadValues$u = (a, b) => {
2008
+ for (var prop in b || (b = {}))
2009
+ if (__hasOwnProp$v.call(b, prop))
2010
+ __defNormalProp$G(a, prop, b[prop]);
2011
+ if (__getOwnPropSymbols$v)
2012
+ for (var prop of __getOwnPropSymbols$v(b)) {
2013
+ if (__propIsEnum$v.call(b, prop))
2014
+ __defNormalProp$G(a, prop, b[prop]);
2015
+ }
2016
+ return a;
2017
+ };
2018
+ var __publicField$r = (obj, key, value) => __defNormalProp$G(obj, typeof key !== "symbol" ? key + "" : key, value);
2019
+ var __async$r = (__this, __arguments, generator) => {
2020
+ return new Promise((resolve, reject) => {
2021
+ var fulfilled = (value) => {
2022
+ try {
2023
+ step(generator.next(value));
2024
+ } catch (e) {
2025
+ reject(e);
2026
+ }
2027
+ };
2028
+ var rejected = (value) => {
2029
+ try {
2030
+ step(generator.throw(value));
2031
+ } catch (e) {
2032
+ reject(e);
2033
+ }
2034
+ };
2035
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2036
+ step((generator = generator.apply(__this, __arguments)).next());
2037
+ });
2038
+ };
2039
+ class ResourcesControl {
2040
+ constructor({
2041
+ connector,
2042
+ cacheId
2043
+ }) {
2044
+ __publicField$r(this, "cache");
2045
+ __publicField$r(this, "connector");
2046
+ this.connector = connector;
2047
+ this.cache = new Cache({ namespace: cacheId });
2048
+ }
2049
+ // -------------------------------------------------------------------------
2050
+ // Resource Methods
2051
+ // -------------------------------------------------------------------------
2052
+ /**
2053
+ * Receive resource from NGW by id, keyname or search-object parameter.
2054
+ * @param resource - Resource id, keyname or search-object
2055
+ *
2056
+ * @remarks
2057
+ * Fetching resource would be cached to speed up next call
2058
+ */
2059
+ getOne(resource, requestOptions) {
2060
+ const opt = __spreadValues$u({}, requestOptions);
2061
+ if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
2062
+ if (resource.id !== void 0) {
2063
+ resource.id;
2064
+ } else {
2065
+ if (resource.keyname) {
2066
+ resource.keyname;
2067
+ }
2068
+ if (resource.display_name) {
2069
+ resource.display_name;
2070
+ }
2071
+ }
2072
+ }
2073
+ if (typeof resource === "string") {
2074
+ return this._fetchResourceBy({ keyname: resource }, opt);
2075
+ } else if (typeof resource === "number") {
2076
+ return this._fetchResourceById(resource, opt);
2077
+ } else if (isObject(resource)) {
2078
+ return this._fetchResourceBy(resource, opt);
2079
+ }
2080
+ return Promise.resolve(void 0);
2081
+ }
2082
+ getOneOrFail(resource, requestOptions) {
2083
+ return this.getOne(resource, requestOptions).then((res) => {
2084
+ if (res) {
2085
+ return res;
2086
+ }
2087
+ throw new ResourceNotFoundError();
2088
+ });
2089
+ }
2090
+ /**
2091
+ * A fast way to retrieve resource ID for any resource definition.
2092
+ * @param resource - Any available resource definition
2093
+ *
2094
+ * @remarks
2095
+ * There are situations when exactly the resource id is needed
2096
+ * (for example, to compose the correct request to the api)
2097
+ * then this method will come in handy to facilitate the extraction of the identifier
2098
+ * if the resource is specified through a keyname or other parameters.
2099
+ */
2100
+ getId(resource, requestOptions) {
2101
+ if (typeof resource === "number") {
2102
+ return Promise.resolve(resource);
2103
+ } else if (typeof resource === "string" || isObject(resource)) {
2104
+ return this.getOne(resource, requestOptions).then((res) => {
2105
+ if (res) {
2106
+ return res.resource.id;
2107
+ }
2108
+ });
2109
+ }
2110
+ return Promise.resolve(void 0);
2111
+ }
2112
+ /**
2113
+ * A fast way to retrieve resource ID for any resource definition.
2114
+ * @param resource - Any available resource definition
2115
+ *
2116
+ * @remarks
2117
+ * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
2118
+ * To not make one more checks if the resource is definitely exists
2119
+ */
2120
+ getIdOrFail(resource, requestOptions) {
2121
+ return this.getId(resource, requestOptions).then((resp) => {
2122
+ if (resp === void 0) {
2123
+ throw new Error();
2124
+ }
2125
+ return resp;
2126
+ });
2127
+ }
2128
+ getMany(resource, requestOptions) {
2129
+ return this._resourceCacheFilter(resource).then((items) => {
2130
+ if (!items.length) {
2131
+ const query = {};
2132
+ if (resource.keyname) {
2133
+ query.keyname = resource.keyname;
2134
+ } else {
2135
+ Object.assign(query, resourceToQuery(resource));
2136
+ }
2137
+ return this.connector.get("resource.search", requestOptions, __spreadValues$u({
2138
+ serialization: "full"
2139
+ }, query)).then((resources) => {
2140
+ if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
2141
+ for (const x of resources) {
2142
+ this.cache.add("resource.item", Promise.resolve(x), {
2143
+ id: x.resource.id
2144
+ });
2145
+ }
2146
+ }
2147
+ return resources;
2148
+ });
2149
+ }
2150
+ return items;
2151
+ });
2152
+ }
2153
+ getParent(resource, requestOptions) {
2154
+ return this.getOne(resource, requestOptions).then((child) => {
2155
+ if (child) {
2156
+ return this.getOne(child.resource.parent.id, requestOptions);
2157
+ }
2158
+ return Promise.resolve(void 0);
2159
+ });
2160
+ }
2161
+ getChildrenOf(resource, requestOptions) {
2162
+ return this.getIdOrFail(resource).then(
2163
+ (parent) => this._getChildrenOf(parent, requestOptions)
2164
+ );
2165
+ }
2166
+ update(resource, data) {
2167
+ return this.getId(resource).then((id) => {
2168
+ if (id !== void 0) {
2169
+ return this.connector.put("resource.item", { data }, { id });
2170
+ }
2171
+ });
2172
+ }
2173
+ /**
2174
+ * Fast way to delete resource from NGW and clean cache.
2175
+ * @param resource - Resource definition
2176
+ */
2177
+ delete(resource) {
2178
+ return this.getId(resource).then((id) => {
2179
+ if (id !== void 0) {
2180
+ return this.connector.delete("resource.item", null, { id }).then(() => {
2181
+ this._cleanResourceItemCache(id);
2182
+ return void 0;
2183
+ });
2184
+ }
2185
+ });
2186
+ }
2187
+ _getChildrenOf(parent, requestOptions, _items = []) {
2188
+ return this.connector.get("resource.collection", requestOptions, {
2189
+ parent
2190
+ }).then((items) => {
2191
+ const recursivePromises = [];
2192
+ for (const item of items) {
2193
+ if (requestOptions == null ? void 0 : requestOptions.cache) {
2194
+ this.cache.add("resource.item", Promise.resolve(item), {
2195
+ id: item.resource.id
2196
+ });
2197
+ }
2198
+ _items.push(item);
2199
+ if ((requestOptions == null ? void 0 : requestOptions.recursive) && item.resource.children) {
2200
+ recursivePromises.push(
2201
+ this._getChildrenOf(item.resource.id, requestOptions, _items)
2202
+ );
2203
+ }
2204
+ }
2205
+ if (recursivePromises.length) {
2206
+ return Promise.all(recursivePromises).then(() => {
2207
+ return _items;
2208
+ });
2209
+ }
2210
+ return _items;
2211
+ });
2212
+ }
2213
+ _cleanResourceItemCache(id) {
2214
+ return __async$r(this, null, function* () {
2215
+ var _a;
2216
+ const all = this.cache.all();
2217
+ const toDelete = [];
2218
+ for (const c of all) {
2219
+ const cid = (_a = c.props) == null ? void 0 : _a.id;
2220
+ if (["resource.item", "resource"].includes(c.key) && cid !== void 0) {
2221
+ if (typeof cid === "number") {
2222
+ if (cid === id) {
2223
+ toDelete.push(c);
2224
+ }
2225
+ } else {
2226
+ const rid = yield this.getId(cid);
2227
+ if (rid === id) {
2228
+ toDelete.push(c);
2229
+ }
2230
+ }
2231
+ }
2232
+ }
2233
+ for (const d of toDelete) {
2234
+ this.cache.delete(d);
2235
+ }
2236
+ });
2237
+ }
2238
+ _fetchResourceById(id, requestOptions) {
2239
+ return this.connector.get("resource.item", requestOptions, { id });
2240
+ }
2241
+ _fetchResourceBy(resource, requestOptions) {
2242
+ return this.getMany(resource, requestOptions).then((resources) => {
2243
+ return resources[0];
2244
+ });
2245
+ }
2246
+ _resourceCacheFilter(resource) {
2247
+ return Promise.all(this.cache.matchAll("resource.item")).then(
2248
+ (resources) => {
2249
+ const items = [];
2250
+ resources.filter((x) => {
2251
+ if (x) {
2252
+ if (resource.keyname && x.resource.keyname) {
2253
+ return resource.keyname === x.resource.keyname;
2254
+ }
2255
+ if (defined(resource.id) && defined(x.resource.id)) {
2256
+ return resource.id === x.resource.id;
2257
+ }
2258
+ return resourceCompare(resource, x.resource);
2259
+ }
2260
+ });
2261
+ return items;
2262
+ }
2263
+ );
2264
+ }
2265
+ }
2266
+
2267
+ var __defProp$F = Object.defineProperty;
2268
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
2269
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
2270
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
2271
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2272
+ var __spreadValues$t = (a, b) => {
2273
+ for (var prop in b || (b = {}))
2274
+ if (__hasOwnProp$u.call(b, prop))
2275
+ __defNormalProp$F(a, prop, b[prop]);
2276
+ if (__getOwnPropSymbols$u)
2277
+ for (var prop of __getOwnPropSymbols$u(b)) {
2278
+ if (__propIsEnum$u.call(b, prop))
2279
+ __defNormalProp$F(a, prop, b[prop]);
2280
+ }
2281
+ return a;
2282
+ };
2283
+ var __async$q = (__this, __arguments, generator) => {
2284
+ return new Promise((resolve, reject) => {
2285
+ var fulfilled = (value) => {
2286
+ try {
2287
+ step(generator.next(value));
2288
+ } catch (e) {
2289
+ reject(e);
2290
+ }
2291
+ };
2292
+ var rejected = (value) => {
2293
+ try {
2294
+ step(generator.throw(value));
2295
+ } catch (e) {
2296
+ reject(e);
2297
+ }
2298
+ };
2299
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2300
+ step((generator = generator.apply(__this, __arguments)).next());
2301
+ });
2302
+ };
2303
+ function apiRequest(opt) {
2304
+ return __async$q(this, null, function* () {
2305
+ const { params, name, connector, requestOptions } = opt;
2306
+ const apiItems = yield connector.connect();
2307
+ let apiItem = apiItems && apiItems[name];
2308
+ if (apiItem) {
2309
+ apiItem = [...apiItem];
2310
+ let url = apiItem.shift();
2311
+ if (apiItem.length) {
2312
+ const replaceParams = {};
2313
+ for (let fry = 0; fry < apiItem.length; fry++) {
2314
+ const arg = apiItem[fry];
2315
+ replaceParams[fry] = `{${arg}}`;
2316
+ if (params[arg] === void 0) {
2317
+ throw new Error(`\`${arg}\` URL API argument is not specified`);
2318
+ }
2319
+ }
2320
+ if (url) {
2321
+ url = template(url, replaceParams);
2322
+ }
2323
+ }
2324
+ if (params) {
2325
+ const paramArray = [];
2326
+ const paramList = params.paramList;
2327
+ if (Array.isArray(paramList)) {
2328
+ paramList.forEach(([key, value]) => {
2329
+ paramArray.push(`${key}=${value}`);
2330
+ });
2331
+ }
2332
+ for (const p in params) {
2333
+ if (apiItem.indexOf(p) === -1) {
2334
+ paramArray.push(`${p}=${params[p]}`);
2335
+ }
2336
+ }
2337
+ if (paramArray.length) {
2338
+ url = `${url}?${paramArray.join("&")}`;
2339
+ }
2340
+ }
2341
+ if (url) {
2342
+ return connector.makeQuery(url, params, __spreadValues$t({
2343
+ cacheName: name
2344
+ }, requestOptions));
2345
+ } else {
2346
+ throw new Error("Request URL is not set");
2347
+ }
2348
+ } else {
2349
+ return void 0;
2350
+ }
2351
+ });
2352
+ }
2353
+
2354
+ var __defProp$E = Object.defineProperty;
2355
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2356
+ var __publicField$q = (obj, key, value) => __defNormalProp$E(obj, key + "" , value);
2357
+ class NgwConnectorExtended extends NgwConnector {
2358
+ constructor(options) {
2359
+ super(options);
2360
+ this.options = options;
2361
+ __publicField$q(this, "resources");
2362
+ this.resources = new ResourcesControl({
2363
+ connector: this,
2364
+ cacheId: options.cacheId
2365
+ });
2366
+ }
2367
+ /**
2368
+ * Clear the cache.
2369
+ */
2370
+ clearCache() {
2371
+ super.clearCache();
2372
+ this.resources.cache.clean();
2373
+ }
2374
+ /**
2375
+ * Send request to NGW api router.
2376
+ * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
2377
+ * @param params - Request item params or query params
2378
+ * @param requestOptions - Request options
2379
+ *
2380
+ * @example
2381
+ * ```javascript
2382
+ *
2383
+ * // there is such an NGW route item
2384
+ * // "feature_layer.feature.item": [
2385
+ * // "/api/resource/{0}/feature/{1}",
2386
+ * // "id",
2387
+ * // "fid"
2388
+ * // ],
2389
+ *
2390
+ * const connector = new NgwConnector({ baseUrl: 'https://example.nextgis.com' });
2391
+ * connector.apiRequest('feature_layer.feature.item', {
2392
+ * // request params for {0} and {1}
2393
+ * 'id': 2011,
2394
+ * 'fid': 101,
2395
+ * // query params
2396
+ * 'srs': 4326,
2397
+ * 'geom_format': 'geojson',
2398
+ * }, { method: 'GET' });
2399
+ * // send get-request to 'https://example.nextgis.com/api/resource/2011/feature/101?srs=4326&geom_format=geojson'
2400
+ *
2401
+ * ```
2402
+ */
2403
+ apiRequest(name, params_ = {}, requestOptions = {}) {
2404
+ var _a;
2405
+ params_ = (_a = requestOptions.params) != null ? _a : params_;
2406
+ const params = objectRemoveEmpty(params_);
2407
+ return apiRequest({ name, params, requestOptions, connector: this });
2408
+ }
2409
+ /**
2410
+ * Shortcut method for send POST request to NGW.
2411
+ * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
2412
+ * @param options - Request options
2413
+ * @param params - Request item params or query params
2414
+ *
2415
+ * @example
2416
+ * ```javascript
2417
+ * connector.post('resource.collection', { data: POST_PAYLOAD })
2418
+ * .then((newResource) => console.log(newResource))
2419
+ * .catch((error) => console.warn(error));
2420
+ * ```
2421
+ */
2422
+ post(name, options, params) {
2423
+ options = options || {};
2424
+ options.method = "POST";
2425
+ return this.apiRequest(
2426
+ name,
2427
+ params,
2428
+ options
2429
+ );
2430
+ }
2431
+ /**
2432
+ * Shortcut method for send GET request to NGW.
2433
+ * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
2434
+ * @param options - Request options
2435
+ * @param params - Request item params or query params
2436
+ */
2437
+ get(name, options, params) {
2438
+ options = options || {};
2439
+ options.method = "GET";
2440
+ return this.apiRequest(
2441
+ name,
2442
+ params,
2443
+ options
2444
+ );
2445
+ }
2446
+ /**
2447
+ * Shortcut method for send PATCH request to NGW.
2448
+ * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
2449
+ * @param options - Request options
2450
+ * @param params - Request item params or query params
2451
+ */
2452
+ patch(name, options, params) {
2453
+ options = options || {};
2454
+ options.method = "PATCH";
2455
+ return this.apiRequest(
2456
+ name,
2457
+ params,
2458
+ options
2459
+ );
2460
+ }
2461
+ /**
2462
+ * Shortcut method for send PUT request to NGW.
2463
+ * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
2464
+ * @param options - Request options
2465
+ * @param params - Request item params or query params
2466
+ */
2467
+ put(name, options, params) {
2468
+ options = options || {};
2469
+ options.method = "PUT";
2470
+ return this.apiRequest(
2471
+ name,
2472
+ params,
2473
+ options
2474
+ );
2475
+ }
2476
+ /**
2477
+ * Shortcut method for send DELETE request to NGW.
2478
+ * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
2479
+ * @param options - Request options
2480
+ * @param params - Request item params or query params
2481
+ */
2482
+ delete(name, options, params) {
2483
+ options = options || {};
2484
+ options.method = "DELETE";
2485
+ return this.apiRequest(
2486
+ name,
2487
+ params,
2488
+ options
2489
+ );
2490
+ }
1965
2491
  // -------------------------------------------------------------------------
1966
2492
  // Resource Methods
1967
2493
  // -------------------------------------------------------------------------
@@ -2037,92 +2563,21 @@ class NgwConnector {
2037
2563
  deleteResource(resource) {
2038
2564
  return this.resources.delete(resource);
2039
2565
  }
2040
- /**
2041
- * @internal
2042
- */
2043
- _loadData(url, options) {
2044
- options.responseType = options.responseType || "json";
2045
- return new Promise((resolve, reject) => {
2046
- var _a;
2047
- if (this.user) {
2048
- options = options || {};
2049
- options.headers = __spreadValues$t(__spreadValues$t({}, this.getAuthorizationHeaders()), options.headers);
2050
- }
2051
- if (this.requestTransform) {
2052
- const [transUrl, transOptions] = this.requestTransform(url, options);
2053
- url = transUrl;
2054
- options = transOptions;
2055
- }
2056
- let runOnAbort = void 0;
2057
- loadData(url, resolve, options, reject, (handler) => {
2058
- runOnAbort = handler;
2059
- });
2060
- (_a = options.signal) == null ? void 0 : _a.addEventListener("abort", () => {
2061
- if (runOnAbort !== void 0) {
2062
- runOnAbort();
2063
- }
2064
- reject(new AbortError());
2065
- });
2066
- }).catch((httpError) => {
2067
- if (httpError.name !== "AbortError") {
2068
- {
2069
- console.warn("DEV WARN", httpError);
2070
- }
2071
- const er = this._handleHttpError(httpError);
2072
- if (er) {
2073
- throw er;
2074
- }
2075
- }
2076
- throw httpError;
2077
- });
2078
- }
2079
- _login(credentials, options) {
2080
- return __async$q(this, null, function* () {
2081
- try {
2082
- const data = yield this.getUserInfo(credentials, options);
2083
- this.user = data;
2084
- this.emitter.emit("login", data);
2085
- return data;
2086
- } catch (er) {
2087
- this.emitter.emit("login:error", er);
2088
- throw er;
2089
- }
2090
- });
2091
- }
2092
- _cleanActiveRequest(requestId) {
2093
- delete this.activeRequests[requestId];
2094
- }
2095
- _handleHttpError(er) {
2096
- if (er) {
2097
- if (er instanceof NgwError) {
2098
- if (er.exception === "nextgisweb.resource.exception.ResourceNotFound") {
2099
- throw new ResourceNotFoundError(er);
2100
- } else if (er.exception === "nextgisweb.core.exception.InsufficientPermissions") {
2101
- throw new InsufficientPermissionsError(er);
2102
- }
2103
- }
2104
- }
2105
- return er;
2106
- }
2107
2566
  }
2108
- __publicField$p(NgwConnector, "errors", {
2109
- NgwError,
2110
- ResourceNotFoundError
2111
- });
2112
2567
 
2113
- var __defProp$C = Object.defineProperty;
2568
+ var __defProp$D = Object.defineProperty;
2114
2569
  var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2115
2570
  var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2116
2571
  var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2117
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2572
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2118
2573
  var __spreadValues$s = (a, b) => {
2119
2574
  for (var prop in b || (b = {}))
2120
2575
  if (__hasOwnProp$t.call(b, prop))
2121
- __defNormalProp$C(a, prop, b[prop]);
2576
+ __defNormalProp$D(a, prop, b[prop]);
2122
2577
  if (__getOwnPropSymbols$t)
2123
2578
  for (var prop of __getOwnPropSymbols$t(b)) {
2124
2579
  if (__propIsEnum$t.call(b, prop))
2125
- __defNormalProp$C(a, prop, b[prop]);
2580
+ __defNormalProp$D(a, prop, b[prop]);
2126
2581
  }
2127
2582
  return a;
2128
2583
  };
@@ -2204,25 +2659,25 @@ function propertiesFilter(properties, filters) {
2204
2659
  return logic === "any" ? filters_.some(filterFunction) : filters_.every(filterFunction);
2205
2660
  }
2206
2661
 
2207
- var __defProp$B = Object.defineProperty;
2208
- var __defProps$e = Object.defineProperties;
2209
- var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2662
+ var __defProp$C = Object.defineProperty;
2663
+ var __defProps$f = Object.defineProperties;
2664
+ var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
2210
2665
  var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2211
2666
  var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2212
2667
  var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2213
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2668
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2214
2669
  var __spreadValues$r = (a, b) => {
2215
2670
  for (var prop in b || (b = {}))
2216
2671
  if (__hasOwnProp$s.call(b, prop))
2217
- __defNormalProp$B(a, prop, b[prop]);
2672
+ __defNormalProp$C(a, prop, b[prop]);
2218
2673
  if (__getOwnPropSymbols$s)
2219
2674
  for (var prop of __getOwnPropSymbols$s(b)) {
2220
2675
  if (__propIsEnum$s.call(b, prop))
2221
- __defNormalProp$B(a, prop, b[prop]);
2676
+ __defNormalProp$C(a, prop, b[prop]);
2222
2677
  }
2223
2678
  return a;
2224
2679
  };
2225
- var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2680
+ var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
2226
2681
  var __async$p = (__this, __arguments, generator) => {
2227
2682
  return new Promise((resolve, reject) => {
2228
2683
  var fulfilled = (value) => {
@@ -2327,13 +2782,13 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2327
2782
  for (const f of filters_) {
2328
2783
  if (isPropertyFilter(f)) {
2329
2784
  _queries.push(
2330
- fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$r({}, opt), {
2785
+ fetchNgwLayerItemsRequest(__spreadProps$f(__spreadValues$r({}, opt), {
2331
2786
  paramList: [..._parentAllParams, ...paramList, createParam(f)]
2332
2787
  }))
2333
2788
  );
2334
2789
  } else {
2335
2790
  getQueries(
2336
- __spreadProps$e(__spreadValues$r({}, opt), {
2791
+ __spreadProps$f(__spreadValues$r({}, opt), {
2337
2792
  filters: f
2338
2793
  }),
2339
2794
  _queries,
@@ -2354,7 +2809,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2354
2809
  if (propertiesFilterList.length) {
2355
2810
  for (const x of propertiesFilterList) {
2356
2811
  getQueries(
2357
- __spreadProps$e(__spreadValues$r({}, opt), {
2812
+ __spreadProps$f(__spreadValues$r({}, opt), {
2358
2813
  filters: x
2359
2814
  }),
2360
2815
  _queries,
@@ -2363,7 +2818,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2363
2818
  }
2364
2819
  } else {
2365
2820
  _queries.push(
2366
- fetchNgwLayerItemsRequest(__spreadProps$e(__spreadValues$r({}, opt), {
2821
+ fetchNgwLayerItemsRequest(__spreadProps$f(__spreadValues$r({}, opt), {
2367
2822
  paramList: [..._parentAllParams, ...paramList, ...filters2]
2368
2823
  }))
2369
2824
  );
@@ -2428,25 +2883,25 @@ function fetchNgwLayerItemsRequest(options) {
2428
2883
  );
2429
2884
  }
2430
2885
 
2431
- var __defProp$A = Object.defineProperty;
2432
- var __defProps$d = Object.defineProperties;
2433
- var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
2886
+ var __defProp$B = Object.defineProperty;
2887
+ var __defProps$e = Object.defineProperties;
2888
+ var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2434
2889
  var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2435
2890
  var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2436
2891
  var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2437
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2892
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2438
2893
  var __spreadValues$q = (a, b) => {
2439
2894
  for (var prop in b || (b = {}))
2440
2895
  if (__hasOwnProp$r.call(b, prop))
2441
- __defNormalProp$A(a, prop, b[prop]);
2896
+ __defNormalProp$B(a, prop, b[prop]);
2442
2897
  if (__getOwnPropSymbols$r)
2443
2898
  for (var prop of __getOwnPropSymbols$r(b)) {
2444
2899
  if (__propIsEnum$r.call(b, prop))
2445
- __defNormalProp$A(a, prop, b[prop]);
2900
+ __defNormalProp$B(a, prop, b[prop]);
2446
2901
  }
2447
2902
  return a;
2448
2903
  };
2449
- var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
2904
+ var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2450
2905
  var __async$o = (__this, __arguments, generator) => {
2451
2906
  return new Promise((resolve, reject) => {
2452
2907
  var fulfilled = (value) => {
@@ -2484,45 +2939,45 @@ function fetchNgwLayerItem(options) {
2484
2939
  if (resp.geom) {
2485
2940
  return createGeoJsonFeature(resp);
2486
2941
  } else {
2487
- const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$d(__spreadValues$q({}, options), {
2942
+ const onlyGeomItem = yield fetchNgwLayerItem(__spreadProps$e(__spreadValues$q({}, options), {
2488
2943
  geom: true,
2489
2944
  fields: null,
2490
2945
  extensions: null
2491
2946
  }));
2492
2947
  const geom = onlyGeomItem.geom;
2493
- return createGeoJsonFeature(__spreadProps$d(__spreadValues$q({}, resp), { geom }));
2948
+ return createGeoJsonFeature(__spreadProps$e(__spreadValues$q({}, resp), { geom }));
2494
2949
  }
2495
2950
  });
2496
- return __spreadProps$d(__spreadValues$q({}, resp), {
2951
+ return __spreadProps$e(__spreadValues$q({}, resp), {
2497
2952
  toGeojson
2498
2953
  });
2499
2954
  });
2500
2955
  }
2501
2956
 
2502
- var __defProp$z = Object.defineProperty;
2957
+ var __defProp$A = Object.defineProperty;
2503
2958
  var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2504
2959
  var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2505
2960
  var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2506
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2961
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2507
2962
  var __spreadValues$p = (a, b) => {
2508
2963
  for (var prop in b || (b = {}))
2509
2964
  if (__hasOwnProp$q.call(b, prop))
2510
- __defNormalProp$z(a, prop, b[prop]);
2965
+ __defNormalProp$A(a, prop, b[prop]);
2511
2966
  if (__getOwnPropSymbols$q)
2512
2967
  for (var prop of __getOwnPropSymbols$q(b)) {
2513
2968
  if (__propIsEnum$q.call(b, prop))
2514
- __defNormalProp$z(a, prop, b[prop]);
2969
+ __defNormalProp$A(a, prop, b[prop]);
2515
2970
  }
2516
2971
  return a;
2517
2972
  };
2518
- var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2973
+ var __publicField$p = (obj, key, value) => __defNormalProp$A(obj, typeof key !== "symbol" ? key + "" : key, value);
2519
2974
  class BookmarkItem {
2520
2975
  constructor(options) {
2521
2976
  this.options = options;
2522
- __publicField$o(this, "name");
2523
- __publicField$o(this, "resourceId");
2524
- __publicField$o(this, "item");
2525
- __publicField$o(this, "_extent");
2977
+ __publicField$p(this, "name");
2978
+ __publicField$p(this, "resourceId");
2979
+ __publicField$p(this, "item");
2980
+ __publicField$p(this, "_extent");
2526
2981
  this.resourceId = options.resourceId;
2527
2982
  const item = options.item;
2528
2983
  this.item = item;
@@ -2668,14 +3123,14 @@ function treeEvery_(item, filterFunc = (x) => !!x, relation, _filtered = []) {
2668
3123
  return true;
2669
3124
  }
2670
3125
 
2671
- var __defProp$y = Object.defineProperty;
2672
- var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2673
- var __publicField$n = (obj, key, value) => __defNormalProp$y(obj, typeof key !== "symbol" ? key + "" : key, value);
3126
+ var __defProp$z = Object.defineProperty;
3127
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3128
+ var __publicField$o = (obj, key, value) => __defNormalProp$z(obj, typeof key !== "symbol" ? key + "" : key, value);
2674
3129
  class TreeHelper {
2675
3130
  constructor(item) {
2676
- __publicField$n(this, "item");
2677
- __publicField$n(this, "_children", []);
2678
- __publicField$n(this, "_parent");
3131
+ __publicField$o(this, "item");
3132
+ __publicField$o(this, "_children", []);
3133
+ __publicField$o(this, "_parent");
2679
3134
  this.item = item;
2680
3135
  }
2681
3136
  setParent(parent) {
@@ -2738,19 +3193,19 @@ class TreeHelper {
2738
3193
  }
2739
3194
  }
2740
3195
 
2741
- var __defProp$x = Object.defineProperty;
2742
- var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2743
- var __publicField$m = (obj, key, value) => __defNormalProp$x(obj, typeof key !== "symbol" ? key + "" : key, value);
3196
+ var __defProp$y = Object.defineProperty;
3197
+ var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3198
+ var __publicField$n = (obj, key, value) => __defNormalProp$y(obj, typeof key !== "symbol" ? key + "" : key, value);
2744
3199
  class BaseProperty {
2745
3200
  constructor(name, item, options) {
2746
- __publicField$m(this, "options");
2747
- __publicField$m(this, "emitter", new EventEmitter());
2748
- __publicField$m(this, "name");
2749
- __publicField$m(this, "item");
2750
- __publicField$m(this, "_blocked", false);
2751
- __publicField$m(this, "_container");
2752
- __publicField$m(this, "_value");
2753
- __publicField$m(this, "_removeEventsListener");
3201
+ __publicField$n(this, "options");
3202
+ __publicField$n(this, "emitter", new EventEmitter());
3203
+ __publicField$n(this, "name");
3204
+ __publicField$n(this, "item");
3205
+ __publicField$n(this, "_blocked", false);
3206
+ __publicField$n(this, "_container");
3207
+ __publicField$n(this, "_value");
3208
+ __publicField$n(this, "_removeEventsListener");
2754
3209
  this.item = item;
2755
3210
  this.options = Object.assign({}, options);
2756
3211
  this.name = name;
@@ -2847,23 +3302,23 @@ class BaseProperty {
2847
3302
  }
2848
3303
  }
2849
3304
 
2850
- var __defProp$w = Object.defineProperty;
3305
+ var __defProp$x = Object.defineProperty;
2851
3306
  var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
2852
3307
  var __hasOwnProp$p = Object.prototype.hasOwnProperty;
2853
3308
  var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
2854
- var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3309
+ var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2855
3310
  var __spreadValues$o = (a, b) => {
2856
3311
  for (var prop in b || (b = {}))
2857
3312
  if (__hasOwnProp$p.call(b, prop))
2858
- __defNormalProp$w(a, prop, b[prop]);
3313
+ __defNormalProp$x(a, prop, b[prop]);
2859
3314
  if (__getOwnPropSymbols$p)
2860
3315
  for (var prop of __getOwnPropSymbols$p(b)) {
2861
3316
  if (__propIsEnum$p.call(b, prop))
2862
- __defNormalProp$w(a, prop, b[prop]);
3317
+ __defNormalProp$x(a, prop, b[prop]);
2863
3318
  }
2864
3319
  return a;
2865
3320
  };
2866
- var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, key + "" , value);
3321
+ var __publicField$m = (obj, key, value) => __defNormalProp$x(obj, key + "" , value);
2867
3322
  const _CheckProperty = class _CheckProperty extends BaseProperty {
2868
3323
  constructor(name, item, options) {
2869
3324
  super(name, item, __spreadValues$o(__spreadValues$o({}, _CheckProperty.options), options));
@@ -2971,7 +3426,7 @@ const _CheckProperty = class _CheckProperty extends BaseProperty {
2971
3426
  }
2972
3427
  }
2973
3428
  };
2974
- __publicField$l(_CheckProperty, "options", {
3429
+ __publicField$m(_CheckProperty, "options", {
2975
3430
  hierarchy: true,
2976
3431
  bubble: false,
2977
3432
  propagation: false,
@@ -2980,31 +3435,31 @@ __publicField$l(_CheckProperty, "options", {
2980
3435
  });
2981
3436
  let CheckProperty = _CheckProperty;
2982
3437
 
2983
- var __defProp$v = Object.defineProperty;
3438
+ var __defProp$w = Object.defineProperty;
2984
3439
  var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
2985
3440
  var __hasOwnProp$o = Object.prototype.hasOwnProperty;
2986
3441
  var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
2987
- var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3442
+ var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2988
3443
  var __spreadValues$n = (a, b) => {
2989
3444
  for (var prop in b || (b = {}))
2990
3445
  if (__hasOwnProp$o.call(b, prop))
2991
- __defNormalProp$v(a, prop, b[prop]);
3446
+ __defNormalProp$w(a, prop, b[prop]);
2992
3447
  if (__getOwnPropSymbols$o)
2993
3448
  for (var prop of __getOwnPropSymbols$o(b)) {
2994
3449
  if (__propIsEnum$o.call(b, prop))
2995
- __defNormalProp$v(a, prop, b[prop]);
3450
+ __defNormalProp$w(a, prop, b[prop]);
2996
3451
  }
2997
3452
  return a;
2998
3453
  };
2999
- var __publicField$k = (obj, key, value) => __defNormalProp$v(obj, typeof key !== "symbol" ? key + "" : key, value);
3454
+ var __publicField$l = (obj, key, value) => __defNormalProp$w(obj, typeof key !== "symbol" ? key + "" : key, value);
3000
3455
  const BOOLEAN_TYPE = "boolean";
3001
3456
  const STRING_TYPE = "string";
3002
3457
  const _ItemProperties = class _ItemProperties {
3003
3458
  constructor(item, propertiesList) {
3004
3459
  this.item = item;
3005
- __publicField$k(this, "options", {});
3006
- __publicField$k(this, "_properties", {});
3007
- __publicField$k(this, "_propertiesList", []);
3460
+ __publicField$l(this, "options", {});
3461
+ __publicField$l(this, "_properties", {});
3462
+ __publicField$l(this, "_propertiesList", []);
3008
3463
  if (propertiesList) {
3009
3464
  propertiesList.forEach(this._setPropertyHandler.bind(this));
3010
3465
  }
@@ -3067,35 +3522,35 @@ const _ItemProperties = class _ItemProperties {
3067
3522
  return Handler;
3068
3523
  }
3069
3524
  };
3070
- __publicField$k(_ItemProperties, "handlers", {
3525
+ __publicField$l(_ItemProperties, "handlers", {
3071
3526
  CheckProperty
3072
3527
  });
3073
3528
  let ItemProperties = _ItemProperties;
3074
3529
 
3075
- var __defProp$u = Object.defineProperty;
3530
+ var __defProp$v = Object.defineProperty;
3076
3531
  var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
3077
3532
  var __hasOwnProp$n = Object.prototype.hasOwnProperty;
3078
3533
  var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
3079
- var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3534
+ var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3080
3535
  var __spreadValues$m = (a, b) => {
3081
3536
  for (var prop in b || (b = {}))
3082
3537
  if (__hasOwnProp$n.call(b, prop))
3083
- __defNormalProp$u(a, prop, b[prop]);
3538
+ __defNormalProp$v(a, prop, b[prop]);
3084
3539
  if (__getOwnPropSymbols$n)
3085
3540
  for (var prop of __getOwnPropSymbols$n(b)) {
3086
3541
  if (__propIsEnum$n.call(b, prop))
3087
- __defNormalProp$u(a, prop, b[prop]);
3542
+ __defNormalProp$v(a, prop, b[prop]);
3088
3543
  }
3089
3544
  return a;
3090
3545
  };
3091
- var __publicField$j = (obj, key, value) => __defNormalProp$u(obj, typeof key !== "symbol" ? key + "" : key, value);
3546
+ var __publicField$k = (obj, key, value) => __defNormalProp$v(obj, typeof key !== "symbol" ? key + "" : key, value);
3092
3547
  let ID$1 = 0;
3093
3548
  class Item {
3094
3549
  constructor(options) {
3095
- __publicField$j(this, "options", {});
3096
- __publicField$j(this, "properties");
3097
- __publicField$j(this, "tree");
3098
- __publicField$j(this, "id", ID$1);
3550
+ __publicField$k(this, "options", {});
3551
+ __publicField$k(this, "properties");
3552
+ __publicField$k(this, "tree");
3553
+ __publicField$k(this, "id", ID$1);
3099
3554
  ID$1 += 1;
3100
3555
  this.options = __spreadValues$m({}, options);
3101
3556
  this.tree = new TreeHelper(this);
@@ -3149,25 +3604,25 @@ class WebmapLayerOpacityPropertyHandler extends BaseProperty {
3149
3604
  }
3150
3605
  }
3151
3606
 
3152
- var __defProp$t = Object.defineProperty;
3153
- var __defProps$c = Object.defineProperties;
3154
- var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
3607
+ var __defProp$u = Object.defineProperty;
3608
+ var __defProps$d = Object.defineProperties;
3609
+ var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
3155
3610
  var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
3156
3611
  var __hasOwnProp$m = Object.prototype.hasOwnProperty;
3157
3612
  var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
3158
- var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3613
+ var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3159
3614
  var __spreadValues$l = (a, b) => {
3160
3615
  for (var prop in b || (b = {}))
3161
3616
  if (__hasOwnProp$m.call(b, prop))
3162
- __defNormalProp$t(a, prop, b[prop]);
3617
+ __defNormalProp$u(a, prop, b[prop]);
3163
3618
  if (__getOwnPropSymbols$m)
3164
3619
  for (var prop of __getOwnPropSymbols$m(b)) {
3165
3620
  if (__propIsEnum$m.call(b, prop))
3166
- __defNormalProp$t(a, prop, b[prop]);
3621
+ __defNormalProp$u(a, prop, b[prop]);
3167
3622
  }
3168
3623
  return a;
3169
3624
  };
3170
- var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
3625
+ var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
3171
3626
  function getNgwWebmapExtent(webmap) {
3172
3627
  const bottom = webmap["extent_bottom"];
3173
3628
  const left = webmap["extent_left"];
@@ -3235,14 +3690,14 @@ function fetchNgwResourceExtent(item, connector, options) {
3235
3690
  if (resource.cls && resource.cls.indexOf("style") !== -1) {
3236
3691
  return connector.getResource(resource.parent.id, options).then((res) => {
3237
3692
  if (res) {
3238
- return fetchNgwLayerExtent(__spreadProps$c(__spreadValues$l({}, options), {
3693
+ return fetchNgwLayerExtent(__spreadProps$d(__spreadValues$l({}, options), {
3239
3694
  resourceId: res.resource.id,
3240
3695
  connector
3241
3696
  }));
3242
3697
  }
3243
3698
  });
3244
3699
  } else {
3245
- return fetchNgwLayerExtent(__spreadProps$c(__spreadValues$l({}, options), {
3700
+ return fetchNgwLayerExtent(__spreadProps$d(__spreadValues$l({}, options), {
3246
3701
  resourceId: resource.id,
3247
3702
  connector
3248
3703
  }));
@@ -3250,9 +3705,9 @@ function fetchNgwResourceExtent(item, connector, options) {
3250
3705
  }
3251
3706
  }
3252
3707
 
3253
- var __defProp$s = Object.defineProperty;
3254
- var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3255
- var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3708
+ var __defProp$t = Object.defineProperty;
3709
+ var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3710
+ var __publicField$j = (obj, key, value) => __defNormalProp$t(obj, typeof key !== "symbol" ? key + "" : key, value);
3256
3711
  var __async$n = (__this, __arguments, generator) => {
3257
3712
  return new Promise((resolve, reject) => {
3258
3713
  var fulfilled = (value) => {
@@ -3275,9 +3730,9 @@ var __async$n = (__this, __arguments, generator) => {
3275
3730
  };
3276
3731
  class NgwResource {
3277
3732
  constructor() {
3278
- __publicField$i(this, "item");
3279
- __publicField$i(this, "connector");
3280
- __publicField$i(this, "_extent");
3733
+ __publicField$j(this, "item");
3734
+ __publicField$j(this, "connector");
3735
+ __publicField$j(this, "_extent");
3281
3736
  }
3282
3737
  /** @deprecated use {@link NgwResource.getBounds} instead */
3283
3738
  getExtent() {
@@ -3396,23 +3851,23 @@ function updateQmsOptions(qms) {
3396
3851
  };
3397
3852
  }
3398
3853
 
3399
- var __defProp$r = Object.defineProperty;
3854
+ var __defProp$s = Object.defineProperty;
3400
3855
  var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
3401
3856
  var __hasOwnProp$l = Object.prototype.hasOwnProperty;
3402
3857
  var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
3403
- var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3858
+ var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3404
3859
  var __spreadValues$k = (a, b) => {
3405
3860
  for (var prop in b || (b = {}))
3406
3861
  if (__hasOwnProp$l.call(b, prop))
3407
- __defNormalProp$r(a, prop, b[prop]);
3862
+ __defNormalProp$s(a, prop, b[prop]);
3408
3863
  if (__getOwnPropSymbols$l)
3409
3864
  for (var prop of __getOwnPropSymbols$l(b)) {
3410
3865
  if (__propIsEnum$l.call(b, prop))
3411
- __defNormalProp$r(a, prop, b[prop]);
3866
+ __defNormalProp$s(a, prop, b[prop]);
3412
3867
  }
3413
3868
  return a;
3414
3869
  };
3415
- var __objRest$1 = (source, exclude) => {
3870
+ var __objRest$2 = (source, exclude) => {
3416
3871
  var target = {};
3417
3872
  for (var prop in source)
3418
3873
  if (__hasOwnProp$l.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -3424,7 +3879,7 @@ var __objRest$1 = (source, exclude) => {
3424
3879
  }
3425
3880
  return target;
3426
3881
  };
3427
- var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3882
+ var __publicField$i = (obj, key, value) => __defNormalProp$s(obj, typeof key !== "symbol" ? key + "" : key, value);
3428
3883
  var __async$l = (__this, __arguments, generator) => {
3429
3884
  return new Promise((resolve, reject) => {
3430
3885
  var fulfilled = (value) => {
@@ -3449,7 +3904,7 @@ const URL = "https://qms.nextgis.com";
3449
3904
  function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
3450
3905
  let webMap;
3451
3906
  if ("webMap" in webMapOrOptions) {
3452
- const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$1(_a, ["webMap", "url"]);
3907
+ const _a = webMapOrOptions, { webMap: webMap_, url: url_ } = _a, adapterOptions = __objRest$2(_a, ["webMap", "url"]);
3453
3908
  webMap = webMap_;
3454
3909
  if (url_) {
3455
3910
  url = url_;
@@ -3465,9 +3920,9 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
3465
3920
  }
3466
3921
  class QmsAdapter {
3467
3922
  constructor(map, options) {
3468
- __publicField$h(this, "qms");
3469
- __publicField$h(this, "options");
3470
- __publicField$h(this, "map");
3923
+ __publicField$i(this, "qms");
3924
+ __publicField$i(this, "options");
3925
+ __publicField$i(this, "map");
3471
3926
  this.map = map;
3472
3927
  const opt = __spreadValues$k(__spreadValues$k({}, createOpt), options);
3473
3928
  this.options = opt;
@@ -3521,29 +3976,29 @@ function createQmsAdapter(webMapOrOptions, url = URL, createOpt = {}) {
3521
3976
  return QmsAdapter;
3522
3977
  }
3523
3978
 
3524
- var __defProp$q = Object.defineProperty;
3979
+ var __defProp$r = Object.defineProperty;
3525
3980
  var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
3526
3981
  var __hasOwnProp$k = Object.prototype.hasOwnProperty;
3527
3982
  var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
3528
- var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3983
+ var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3529
3984
  var __spreadValues$j = (a, b) => {
3530
3985
  for (var prop in b || (b = {}))
3531
3986
  if (__hasOwnProp$k.call(b, prop))
3532
- __defNormalProp$q(a, prop, b[prop]);
3987
+ __defNormalProp$r(a, prop, b[prop]);
3533
3988
  if (__getOwnPropSymbols$k)
3534
3989
  for (var prop of __getOwnPropSymbols$k(b)) {
3535
3990
  if (__propIsEnum$k.call(b, prop))
3536
- __defNormalProp$q(a, prop, b[prop]);
3991
+ __defNormalProp$r(a, prop, b[prop]);
3537
3992
  }
3538
3993
  return a;
3539
3994
  };
3540
- var __publicField$g = (obj, key, value) => __defNormalProp$q(obj, typeof key !== "symbol" ? key + "" : key, value);
3995
+ var __publicField$h = (obj, key, value) => __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
3541
3996
  class QmsKit {
3542
3997
  constructor(options) {
3543
- __publicField$g(this, "options", {
3998
+ __publicField$h(this, "options", {
3544
3999
  url: "https://qms.nextgis.com"
3545
4000
  });
3546
- __publicField$g(this, "url");
4001
+ __publicField$h(this, "url");
3547
4002
  this.options = __spreadValues$j(__spreadValues$j({}, this.options), options);
3548
4003
  this.url = this.options.url;
3549
4004
  }
@@ -3559,31 +4014,31 @@ class QmsKit {
3559
4014
  return createQmsAdapter({ webMap, url: this.url });
3560
4015
  }
3561
4016
  }
3562
- __publicField$g(QmsKit, "utils", {
4017
+ __publicField$h(QmsKit, "utils", {
3563
4018
  createQmsAdapter
3564
4019
  });
3565
4020
 
3566
- var __defProp$p = Object.defineProperty;
3567
- var __defProps$b = Object.defineProperties;
3568
- var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
4021
+ var __defProp$q = Object.defineProperty;
4022
+ var __defProps$c = Object.defineProperties;
4023
+ var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
3569
4024
  var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
3570
4025
  var __getProtoOf$2 = Object.getPrototypeOf;
3571
4026
  var __hasOwnProp$j = Object.prototype.hasOwnProperty;
3572
4027
  var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
3573
4028
  var __reflectGet$2 = Reflect.get;
3574
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4029
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3575
4030
  var __spreadValues$i = (a, b) => {
3576
4031
  for (var prop in b || (b = {}))
3577
4032
  if (__hasOwnProp$j.call(b, prop))
3578
- __defNormalProp$p(a, prop, b[prop]);
4033
+ __defNormalProp$q(a, prop, b[prop]);
3579
4034
  if (__getOwnPropSymbols$j)
3580
4035
  for (var prop of __getOwnPropSymbols$j(b)) {
3581
4036
  if (__propIsEnum$j.call(b, prop))
3582
- __defNormalProp$p(a, prop, b[prop]);
4037
+ __defNormalProp$q(a, prop, b[prop]);
3583
4038
  }
3584
4039
  return a;
3585
4040
  };
3586
- var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
4041
+ var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
3587
4042
  var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
3588
4043
  var __async$k = (__this, __arguments, generator) => {
3589
4044
  return new Promise((resolve, reject) => {
@@ -3628,7 +4083,7 @@ function createBasemapLayerAdapter(_0) {
3628
4083
  class BasemapTileAdapter extends TileAdapter {
3629
4084
  addLayer(opt) {
3630
4085
  return __async$k(this, null, function* () {
3631
- return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$b(__spreadValues$i({}, opt), { url }));
4086
+ return __superGet$2(BasemapTileAdapter.prototype, this, "addLayer").call(this, __spreadProps$c(__spreadValues$i({}, opt), { url }));
3632
4087
  });
3633
4088
  }
3634
4089
  }
@@ -3707,25 +4162,25 @@ function prepareNgwFieldsToPropertiesFilter(fields) {
3707
4162
  return fields;
3708
4163
  }
3709
4164
 
3710
- var __defProp$o = Object.defineProperty;
3711
- var __defProps$a = Object.defineProperties;
3712
- var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
4165
+ var __defProp$p = Object.defineProperty;
4166
+ var __defProps$b = Object.defineProperties;
4167
+ var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
3713
4168
  var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
3714
4169
  var __hasOwnProp$i = Object.prototype.hasOwnProperty;
3715
4170
  var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
3716
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4171
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3717
4172
  var __spreadValues$h = (a, b) => {
3718
4173
  for (var prop in b || (b = {}))
3719
4174
  if (__hasOwnProp$i.call(b, prop))
3720
- __defNormalProp$o(a, prop, b[prop]);
4175
+ __defNormalProp$p(a, prop, b[prop]);
3721
4176
  if (__getOwnPropSymbols$i)
3722
4177
  for (var prop of __getOwnPropSymbols$i(b)) {
3723
4178
  if (__propIsEnum$i.call(b, prop))
3724
- __defNormalProp$o(a, prop, b[prop]);
4179
+ __defNormalProp$p(a, prop, b[prop]);
3725
4180
  }
3726
4181
  return a;
3727
4182
  };
3728
- var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
4183
+ var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
3729
4184
  var __async$j = (__this, __arguments, generator) => {
3730
4185
  return new Promise((resolve, reject) => {
3731
4186
  var fulfilled = (value) => {
@@ -3751,13 +4206,13 @@ function fetchNgwLayerItems(options) {
3751
4206
  var _a;
3752
4207
  const filters = options.filters;
3753
4208
  if (filters) {
3754
- let data = yield createFeatureFieldFilterQueries(__spreadProps$a(__spreadValues$h({}, options), {
4209
+ let data = yield createFeatureFieldFilterQueries(__spreadProps$b(__spreadValues$h({}, options), {
3755
4210
  filters
3756
4211
  }));
3757
4212
  const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
3758
4213
  if (clientFilterValidate) {
3759
4214
  data = data.filter((y) => {
3760
- const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps$a(__spreadValues$h({}, y.fields), {
4215
+ const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps$b(__spreadValues$h({}, y.fields), {
3761
4216
  id: y.id
3762
4217
  }));
3763
4218
  const result = propertiesFilter(fields, filters);
@@ -3845,28 +4300,28 @@ function getLayerFilterOptions(options) {
3845
4300
  return filterOptions;
3846
4301
  }
3847
4302
 
3848
- var __defProp$n = Object.defineProperty;
3849
- var __defProps$9 = Object.defineProperties;
3850
- var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
4303
+ var __defProp$o = Object.defineProperty;
4304
+ var __defProps$a = Object.defineProperties;
4305
+ var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
3851
4306
  var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
3852
4307
  var __getProtoOf$1 = Object.getPrototypeOf;
3853
4308
  var __hasOwnProp$h = Object.prototype.hasOwnProperty;
3854
4309
  var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
3855
4310
  var __reflectGet$1 = Reflect.get;
3856
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4311
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3857
4312
  var __spreadValues$g = (a, b) => {
3858
4313
  for (var prop in b || (b = {}))
3859
4314
  if (__hasOwnProp$h.call(b, prop))
3860
- __defNormalProp$n(a, prop, b[prop]);
4315
+ __defNormalProp$o(a, prop, b[prop]);
3861
4316
  if (__getOwnPropSymbols$h)
3862
4317
  for (var prop of __getOwnPropSymbols$h(b)) {
3863
4318
  if (__propIsEnum$h.call(b, prop))
3864
- __defNormalProp$n(a, prop, b[prop]);
4319
+ __defNormalProp$o(a, prop, b[prop]);
3865
4320
  }
3866
4321
  return a;
3867
4322
  };
3868
- var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
3869
- var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
4323
+ var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
4324
+ var __publicField$g = (obj, key, value) => __defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
3870
4325
  var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
3871
4326
  var __async$h = (__this, __arguments, generator) => {
3872
4327
  return new Promise((resolve, reject) => {
@@ -3939,11 +4394,11 @@ function createGeoJsonAdapter(props) {
3939
4394
  class NgwGeoJsonAdapter extends GeoJsonAdapter {
3940
4395
  constructor() {
3941
4396
  super(...arguments);
3942
- __publicField$f(this, "emitter", new EventEmitter());
3943
- __publicField$f(this, "__onMapMove");
3944
- __publicField$f(this, "__onMapMoveStart");
3945
- __publicField$f(this, "__enableMapMoveListener");
3946
- __publicField$f(this, "__disableMapMoveListener");
4397
+ __publicField$g(this, "emitter", new EventEmitter());
4398
+ __publicField$g(this, "__onMapMove");
4399
+ __publicField$g(this, "__onMapMoveStart");
4400
+ __publicField$g(this, "__enableMapMoveListener");
4401
+ __publicField$g(this, "__disableMapMoveListener");
3947
4402
  }
3948
4403
  addLayer(opt) {
3949
4404
  return __async$h(this, null, function* () {
@@ -4016,10 +4471,10 @@ function createGeoJsonAdapter(props) {
4016
4471
  getCount() {
4017
4472
  return fetchNgwLayerCount({ connector, resourceId, cache: true });
4018
4473
  }
4019
- updateLayer(filterArgs) {
4474
+ updateLayer(opt) {
4020
4475
  return __async$h(this, null, function* () {
4021
4476
  var _a2;
4022
- filterArgs = filterArgs || _lastFilterArgs || {};
4477
+ const filterArgs = opt || _lastFilterArgs || {};
4023
4478
  if ((_a2 = this.options.strategy) == null ? void 0 : _a2.startsWith("BBOX")) {
4024
4479
  yield webMap.onLoad("create");
4025
4480
  filterArgs.options = filterArgs.options || {};
@@ -4044,7 +4499,7 @@ function createGeoJsonAdapter(props) {
4044
4499
  try {
4045
4500
  this.emitter.emit("preupdate", filterArgs);
4046
4501
  webMap._emitLayerEvent("layer:preupdate", options.id || "", filterArgs);
4047
- const data = yield getData(filterArgs.filters, __spreadProps$9(__spreadValues$g({}, filterArgs.options), {
4502
+ const data = yield getData(filterArgs.filters, __spreadProps$a(__spreadValues$g({}, filterArgs.options), {
4048
4503
  srs: this.options.srs
4049
4504
  }));
4050
4505
  let newData = data;
@@ -4097,7 +4552,7 @@ function createGeoJsonAdapter(props) {
4097
4552
  if (this.clearLayer) {
4098
4553
  this.clearLayer();
4099
4554
  }
4100
- const data = yield getData(filters, __spreadProps$9(__spreadValues$g({}, opt), {
4555
+ const data = yield getData(filters, __spreadProps$a(__spreadValues$g({}, opt), {
4101
4556
  srs: this.options.srs
4102
4557
  }));
4103
4558
  this.setData(data);
@@ -4286,26 +4741,26 @@ function ngwApiToAdapterOptions({
4286
4741
  }
4287
4742
  }
4288
4743
 
4289
- var __defProp$m = Object.defineProperty;
4290
- var __defProps$8 = Object.defineProperties;
4291
- var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
4744
+ var __defProp$n = Object.defineProperty;
4745
+ var __defProps$9 = Object.defineProperties;
4746
+ var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
4292
4747
  var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
4293
4748
  var __hasOwnProp$g = Object.prototype.hasOwnProperty;
4294
4749
  var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
4295
- var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4750
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4296
4751
  var __spreadValues$f = (a, b) => {
4297
4752
  for (var prop in b || (b = {}))
4298
4753
  if (__hasOwnProp$g.call(b, prop))
4299
- __defNormalProp$m(a, prop, b[prop]);
4754
+ __defNormalProp$n(a, prop, b[prop]);
4300
4755
  if (__getOwnPropSymbols$g)
4301
4756
  for (var prop of __getOwnPropSymbols$g(b)) {
4302
4757
  if (__propIsEnum$g.call(b, prop))
4303
- __defNormalProp$m(a, prop, b[prop]);
4758
+ __defNormalProp$n(a, prop, b[prop]);
4304
4759
  }
4305
4760
  return a;
4306
4761
  };
4307
- var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
4308
- var __publicField$e = (obj, key, value) => __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
4762
+ var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
4763
+ var __publicField$f = (obj, key, value) => __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
4309
4764
  var __async$f = (__this, __arguments, generator) => {
4310
4765
  return new Promise((resolve, reject) => {
4311
4766
  var fulfilled = (value) => {
@@ -4326,11 +4781,47 @@ var __async$f = (__this, __arguments, generator) => {
4326
4781
  step((generator = generator.apply(__this, __arguments)).next());
4327
4782
  });
4328
4783
  };
4784
+ class Legend {
4785
+ constructor({
4786
+ layerId,
4787
+ legend,
4788
+ onSymbolRenderChange
4789
+ }) {
4790
+ __publicField$f(this, "layerId");
4791
+ __publicField$f(this, "legend");
4792
+ __publicField$f(this, "onSymbolRenderChange");
4793
+ this.layerId = layerId;
4794
+ this.legend = this.createLegend(legend);
4795
+ this.onSymbolRenderChange = onSymbolRenderChange;
4796
+ }
4797
+ createLegend(items) {
4798
+ return items.map((params) => __spreadProps$9(__spreadValues$f({}, params), {
4799
+ /** @deprecated use display_name instead */
4800
+ name: params.display_name,
4801
+ /** @deprecated use icon instead */
4802
+ symbol: params.icon
4803
+ }));
4804
+ }
4805
+ setSymbolRender(symbolIndex, status) {
4806
+ const legendItem = this.legend.find((l) => l.index === symbolIndex);
4807
+ if (legendItem) {
4808
+ const render = legendItem.render;
4809
+ if (render !== status) {
4810
+ legendItem.render = status;
4811
+ if (this.onSymbolRenderChange) {
4812
+ this.onSymbolRenderChange(
4813
+ this.legend.filter((l) => l.render).map((l) => l.index)
4814
+ );
4815
+ }
4816
+ }
4817
+ }
4818
+ }
4819
+ }
4329
4820
  function createRasterAdapter(_0) {
4330
4821
  return __async$f(this, arguments, function* ({
4331
4822
  layerOptions,
4332
- webMap,
4333
4823
  connector,
4824
+ webMap,
4334
4825
  item
4335
4826
  }) {
4336
4827
  const resourceCls = item.resource.cls;
@@ -4359,16 +4850,17 @@ function createRasterAdapter(_0) {
4359
4850
  constructor(map, _options) {
4360
4851
  super(map, _options);
4361
4852
  this.map = map;
4362
- // options = {};
4363
- __publicField$e(this, "item", item);
4364
- __publicField$e(this, "resourceId", resourceId);
4853
+ __publicField$f(this, "item", item);
4854
+ __publicField$f(this, "resourceId", resourceId);
4855
+ __publicField$f(this, "_blocked", false);
4856
+ __publicField$f(this, "_layerVisibility");
4365
4857
  const opt = ngwApiToAdapterOptions({
4366
4858
  options: layerOptions,
4367
4859
  webMap,
4368
4860
  baseUrl: connector.options.baseUrl || ""
4369
4861
  });
4370
4862
  if (opt) {
4371
- const layerAdapterOptions = __spreadProps$8(__spreadValues$f(__spreadValues$f({}, opt), layerOptions.adapterOptions), {
4863
+ const layerAdapterOptions = __spreadProps$9(__spreadValues$f(__spreadValues$f({}, opt), layerOptions.adapterOptions), {
4372
4864
  params: { resource: resourceId },
4373
4865
  layers: opt.layers || String(resourceId),
4374
4866
  resourceId
@@ -4382,25 +4874,19 @@ function createRasterAdapter(_0) {
4382
4874
  addLayer(addOptions) {
4383
4875
  return super.addLayer(__spreadValues$f(__spreadValues$f({}, this.options), addOptions));
4384
4876
  }
4385
- getLegend(options) {
4386
- return __async$f(this, null, function* () {
4387
- const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4388
- params: { id: resourceId },
4389
- cache: true
4390
- }, options));
4391
- const id = this.options.id;
4392
- if (id !== void 0) {
4393
- const legend = {
4394
- layerId: id,
4395
- legend: ngwLegend.map(({ display_name, icon }) => ({
4396
- name: display_name,
4397
- symbol: icon
4398
- }))
4399
- };
4400
- return [legend];
4877
+ showLayer() {
4878
+ this._layerVisibility = true;
4879
+ if (this.layer) {
4880
+ if (!this._blocked) {
4881
+ webMap.mapAdapter.showLayer(this.layer);
4401
4882
  }
4402
- return [];
4403
- });
4883
+ }
4884
+ }
4885
+ hideLayer() {
4886
+ this._layerVisibility = false;
4887
+ if (this.layer) {
4888
+ webMap.mapAdapter.hideLayer(this.layer);
4889
+ }
4404
4890
  }
4405
4891
  getIdentificationIds() {
4406
4892
  return __async$f(this, null, function* () {
@@ -4416,8 +4902,69 @@ function createRasterAdapter(_0) {
4416
4902
  return [];
4417
4903
  });
4418
4904
  }
4419
- // beforeRemove() {
4420
- // }
4905
+ getLegend(options) {
4906
+ return __async$f(this, null, function* () {
4907
+ const id = this.options.id;
4908
+ if (id !== void 0) {
4909
+ const ngwLegend = yield connector.get("render.legend_symbols", __spreadValues$f({
4910
+ params: { id: resourceId },
4911
+ cache: true
4912
+ }, options));
4913
+ const legend = new Legend({
4914
+ layerId: id,
4915
+ legend: ngwLegend,
4916
+ onSymbolRenderChange: this._setLegendSymbol.bind(this)
4917
+ });
4918
+ return [legend];
4919
+ }
4920
+ return [];
4921
+ });
4922
+ }
4923
+ _hideLayer() {
4924
+ if (this.options.id) {
4925
+ webMap.mapAdapter.hideLayer(this.layer);
4926
+ }
4927
+ }
4928
+ _showLayer() {
4929
+ if (this.options.id) {
4930
+ if (this._layerVisibility) {
4931
+ webMap.showLayer(this.options.id, { silent: true });
4932
+ }
4933
+ }
4934
+ }
4935
+ _setLegendSymbol(renderIndexes) {
4936
+ const intervals = this._consolidateIntervals(renderIndexes);
4937
+ if (!intervals.length) {
4938
+ this._hideLayer();
4939
+ this._blocked = true;
4940
+ } else {
4941
+ this._blocked = false;
4942
+ this._showLayer();
4943
+ }
4944
+ if (this.updateLayer) {
4945
+ this.updateLayer({
4946
+ params: {
4947
+ [`symbols[${resourceId}]`]: intervals.join(",") || void 0
4948
+ }
4949
+ });
4950
+ }
4951
+ }
4952
+ _consolidateIntervals(symbols) {
4953
+ const sortedSymbols = symbols.slice().sort((a, b) => a - b);
4954
+ const intervals = [];
4955
+ let start = sortedSymbols[0];
4956
+ let end = start;
4957
+ for (let i = 1; i <= sortedSymbols.length; i++) {
4958
+ if (sortedSymbols[i] === end + 1) {
4959
+ end = sortedSymbols[i];
4960
+ } else {
4961
+ intervals.push(start === end ? `${start}` : `${start}-${end}`);
4962
+ start = sortedSymbols[i];
4963
+ end = start;
4964
+ }
4965
+ }
4966
+ return intervals;
4967
+ }
4421
4968
  };
4422
4969
  } else {
4423
4970
  throw new Error(adapter + " not supported yet. Only TILE");
@@ -4425,25 +4972,25 @@ function createRasterAdapter(_0) {
4425
4972
  });
4426
4973
  }
4427
4974
 
4428
- var __defProp$l = Object.defineProperty;
4429
- var __defProps$7 = Object.defineProperties;
4430
- var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
4975
+ var __defProp$m = Object.defineProperty;
4976
+ var __defProps$8 = Object.defineProperties;
4977
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
4431
4978
  var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
4432
4979
  var __hasOwnProp$f = Object.prototype.hasOwnProperty;
4433
4980
  var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
4434
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4981
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4435
4982
  var __spreadValues$e = (a, b) => {
4436
4983
  for (var prop in b || (b = {}))
4437
4984
  if (__hasOwnProp$f.call(b, prop))
4438
- __defNormalProp$l(a, prop, b[prop]);
4985
+ __defNormalProp$m(a, prop, b[prop]);
4439
4986
  if (__getOwnPropSymbols$f)
4440
4987
  for (var prop of __getOwnPropSymbols$f(b)) {
4441
4988
  if (__propIsEnum$f.call(b, prop))
4442
- __defNormalProp$l(a, prop, b[prop]);
4989
+ __defNormalProp$m(a, prop, b[prop]);
4443
4990
  }
4444
4991
  return a;
4445
4992
  };
4446
- var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
4993
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
4447
4994
  var __async$e = (__this, __arguments, generator) => {
4448
4995
  return new Promise((resolve, reject) => {
4449
4996
  var fulfilled = (value) => {
@@ -4491,7 +5038,7 @@ function createAdapterFromFirstStyle(_0) {
4491
5038
  const firstStyle = childrenStyles && childrenStyles[0];
4492
5039
  if (firstStyle) {
4493
5040
  return createAsyncAdapter(
4494
- __spreadProps$7(__spreadValues$e({}, layerOptions), { resource: firstStyle.resource.id }),
5041
+ __spreadProps$8(__spreadValues$e({}, layerOptions), { resource: firstStyle.resource.id }),
4495
5042
  webMap,
4496
5043
  connector
4497
5044
  );
@@ -4514,7 +5061,7 @@ function createAsyncAdapter(options, webMap, connector) {
4514
5061
  }
4515
5062
  if (item) {
4516
5063
  const cls = item.resource.cls;
4517
- const layerOptions = __spreadProps$7(__spreadValues$e({}, options), {
5064
+ const layerOptions = __spreadProps$8(__spreadValues$e({}, options), {
4518
5065
  resource: resourceId
4519
5066
  });
4520
5067
  const adapterOptions = {
@@ -4551,10 +5098,10 @@ function createAsyncAdapter(options, webMap, connector) {
4551
5098
  item.resource.parent.id
4552
5099
  );
4553
5100
  if (parentItem) {
4554
- const parentOptions = __spreadProps$7(__spreadValues$e({}, options), {
5101
+ const parentOptions = __spreadProps$8(__spreadValues$e({}, options), {
4555
5102
  resource: item.resource.parent.id
4556
5103
  });
4557
- adapter = createGeoJsonAdapter(__spreadProps$7(__spreadValues$e({}, adapterOptions), {
5104
+ adapter = createGeoJsonAdapter(__spreadProps$8(__spreadValues$e({}, adapterOptions), {
4558
5105
  item: parentItem,
4559
5106
  layerOptions: parentOptions
4560
5107
  }));
@@ -4598,31 +5145,46 @@ function createAsyncAdapter(options, webMap, connector) {
4598
5145
  });
4599
5146
  }
4600
5147
 
4601
- var __defProp$k = Object.defineProperty;
5148
+ var __defProp$l = Object.defineProperty;
5149
+ var __defProps$7 = Object.defineProperties;
5150
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
4602
5151
  var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
4603
5152
  var __hasOwnProp$e = Object.prototype.hasOwnProperty;
4604
5153
  var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
4605
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5154
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4606
5155
  var __spreadValues$d = (a, b) => {
4607
5156
  for (var prop in b || (b = {}))
4608
5157
  if (__hasOwnProp$e.call(b, prop))
4609
- __defNormalProp$k(a, prop, b[prop]);
5158
+ __defNormalProp$l(a, prop, b[prop]);
4610
5159
  if (__getOwnPropSymbols$e)
4611
5160
  for (var prop of __getOwnPropSymbols$e(b)) {
4612
5161
  if (__propIsEnum$e.call(b, prop))
4613
- __defNormalProp$k(a, prop, b[prop]);
5162
+ __defNormalProp$l(a, prop, b[prop]);
4614
5163
  }
4615
5164
  return a;
4616
5165
  };
5166
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
5167
+ var __objRest$1 = (source, exclude) => {
5168
+ var target = {};
5169
+ for (var prop in source)
5170
+ if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
5171
+ target[prop] = source[prop];
5172
+ if (source != null && __getOwnPropSymbols$e)
5173
+ for (var prop of __getOwnPropSymbols$e(source)) {
5174
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
5175
+ target[prop] = source[prop];
5176
+ }
5177
+ return target;
5178
+ };
4617
5179
  function updateImageParams(params, resourceId) {
4618
- const { bbox, width, height, nd } = params;
4619
- return {
5180
+ const _a = params, { bbox, width, height, nd } = _a, rest = __objRest$1(_a, ["bbox", "width", "height", "nd"]);
5181
+ return __spreadProps$7(__spreadValues$d({}, rest), {
4620
5182
  resource: Array.isArray(resourceId) ? resourceId.join(",") : resourceId,
4621
5183
  extent: bbox,
4622
5184
  size: width + "," + height,
4623
5185
  timestamp: Date.now(),
4624
5186
  nd: nd != null ? nd : 200
4625
- };
5187
+ });
4626
5188
  }
4627
5189
  const vectorLayerGeomToPaintTypeAlias = {
4628
5190
  POINT: "point",
@@ -4682,26 +5244,26 @@ function setScaleRatio(scale, lat = 0) {
4682
5244
  return zoom;
4683
5245
  }
4684
5246
 
4685
- var __defProp$j = Object.defineProperty;
5247
+ var __defProp$k = Object.defineProperty;
4686
5248
  var __defProps$6 = Object.defineProperties;
4687
5249
  var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
4688
5250
  var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
4689
5251
  var __hasOwnProp$d = Object.prototype.hasOwnProperty;
4690
5252
  var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
4691
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5253
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4692
5254
  var __spreadValues$c = (a, b) => {
4693
5255
  for (var prop in b || (b = {}))
4694
5256
  if (__hasOwnProp$d.call(b, prop))
4695
- __defNormalProp$j(a, prop, b[prop]);
5257
+ __defNormalProp$k(a, prop, b[prop]);
4696
5258
  if (__getOwnPropSymbols$d)
4697
5259
  for (var prop of __getOwnPropSymbols$d(b)) {
4698
5260
  if (__propIsEnum$d.call(b, prop))
4699
- __defNormalProp$j(a, prop, b[prop]);
5261
+ __defNormalProp$k(a, prop, b[prop]);
4700
5262
  }
4701
5263
  return a;
4702
5264
  };
4703
5265
  var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
4704
- var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
5266
+ var __publicField$e = (obj, key, value) => __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
4705
5267
  var __async$d = (__this, __arguments, generator) => {
4706
5268
  return new Promise((resolve, reject) => {
4707
5269
  var fulfilled = (value) => {
@@ -4726,11 +5288,11 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4726
5288
  constructor(webMap, item, options, connector, parent, noInit) {
4727
5289
  super(__spreadValues$c(__spreadValues$c({}, _NgwWebmapItem.options), options));
4728
5290
  this.webMap = webMap;
4729
- __publicField$d(this, "item");
4730
- __publicField$d(this, "connector");
4731
- __publicField$d(this, "layer");
4732
- __publicField$d(this, "emitter", new EventEmitter());
4733
- __publicField$d(this, "_rootDescendantsCount", 0);
5291
+ __publicField$e(this, "item");
5292
+ __publicField$e(this, "connector");
5293
+ __publicField$e(this, "layer");
5294
+ __publicField$e(this, "emitter", new EventEmitter());
5295
+ __publicField$e(this, "_rootDescendantsCount", 0);
4734
5296
  if (connector) {
4735
5297
  this.connector = connector;
4736
5298
  }
@@ -4792,10 +5354,12 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4792
5354
  }, options));
4793
5355
  const legend = {
4794
5356
  layerId: id,
4795
- legend: ngwLegend.map(({ display_name, icon }) => ({
4796
- name: display_name,
4797
- symbol: icon
4798
- }))
5357
+ legend: ngwLegend.map((legend2) => __spreadValues$c({
5358
+ /** @deprecated use display_name instead */
5359
+ name: legend2.display_name,
5360
+ /** @deprecated use icon instead */
5361
+ symbol: legend2.icon
5362
+ }, legend2))
4799
5363
  };
4800
5364
  return [legend];
4801
5365
  }
@@ -4918,8 +5482,8 @@ const _NgwWebmapItem = class _NgwWebmapItem extends Item {
4918
5482
  return totalValue;
4919
5483
  }
4920
5484
  };
4921
- __publicField$d(_NgwWebmapItem, "GetAdapterFromLayerType", {});
4922
- __publicField$d(_NgwWebmapItem, "options", {
5485
+ __publicField$e(_NgwWebmapItem, "GetAdapterFromLayerType", {});
5486
+ __publicField$e(_NgwWebmapItem, "options", {
4923
5487
  properties: [
4924
5488
  {
4925
5489
  type: "boolean",
@@ -4959,23 +5523,23 @@ __publicField$d(_NgwWebmapItem, "options", {
4959
5523
  });
4960
5524
  let NgwWebmapItem = _NgwWebmapItem;
4961
5525
 
4962
- var __defProp$i = Object.defineProperty;
5526
+ var __defProp$j = Object.defineProperty;
4963
5527
  var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
4964
5528
  var __hasOwnProp$c = Object.prototype.hasOwnProperty;
4965
5529
  var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
4966
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5530
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4967
5531
  var __spreadValues$b = (a, b) => {
4968
5532
  for (var prop in b || (b = {}))
4969
5533
  if (__hasOwnProp$c.call(b, prop))
4970
- __defNormalProp$i(a, prop, b[prop]);
5534
+ __defNormalProp$j(a, prop, b[prop]);
4971
5535
  if (__getOwnPropSymbols$c)
4972
5536
  for (var prop of __getOwnPropSymbols$c(b)) {
4973
5537
  if (__propIsEnum$c.call(b, prop))
4974
- __defNormalProp$i(a, prop, b[prop]);
5538
+ __defNormalProp$j(a, prop, b[prop]);
4975
5539
  }
4976
5540
  return a;
4977
5541
  };
4978
- var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5542
+ var __publicField$d = (obj, key, value) => __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
4979
5543
  var __async$c = (__this, __arguments, generator) => {
4980
5544
  return new Promise((resolve, reject) => {
4981
5545
  var fulfilled = (value) => {
@@ -5005,10 +5569,10 @@ function createOnFirstShowAdapter(_0) {
5005
5569
  }) {
5006
5570
  class OnFirstShowAdapter {
5007
5571
  constructor() {
5008
- __publicField$c(this, "options", {});
5009
- __publicField$c(this, "layer", []);
5010
- __publicField$c(this, "_removed", false);
5011
- __publicField$c(this, "_creatingInProgress", false);
5572
+ __publicField$d(this, "options", {});
5573
+ __publicField$d(this, "layer", []);
5574
+ __publicField$d(this, "_removed", false);
5575
+ __publicField$d(this, "_creatingInProgress", false);
5012
5576
  }
5013
5577
  addLayer() {
5014
5578
  return this.layer;
@@ -5136,26 +5700,26 @@ function createOnFirstShowNgwAdapter(_0) {
5136
5700
 
5137
5701
  const WEBMAP_BASELAYER_ID_PREFIX = "webmap-baselayer";
5138
5702
 
5139
- var __defProp$h = Object.defineProperty;
5703
+ var __defProp$i = Object.defineProperty;
5140
5704
  var __defProps$5 = Object.defineProperties;
5141
5705
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
5142
5706
  var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
5143
5707
  var __hasOwnProp$b = Object.prototype.hasOwnProperty;
5144
5708
  var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
5145
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5709
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5146
5710
  var __spreadValues$a = (a, b) => {
5147
5711
  for (var prop in b || (b = {}))
5148
5712
  if (__hasOwnProp$b.call(b, prop))
5149
- __defNormalProp$h(a, prop, b[prop]);
5713
+ __defNormalProp$i(a, prop, b[prop]);
5150
5714
  if (__getOwnPropSymbols$b)
5151
5715
  for (var prop of __getOwnPropSymbols$b(b)) {
5152
5716
  if (__propIsEnum$b.call(b, prop))
5153
- __defNormalProp$h(a, prop, b[prop]);
5717
+ __defNormalProp$i(a, prop, b[prop]);
5154
5718
  }
5155
5719
  return a;
5156
5720
  };
5157
5721
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5158
- var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5722
+ var __publicField$c = (obj, key, value) => __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
5159
5723
  var __async$a = (__this, __arguments, generator) => {
5160
5724
  return new Promise((resolve, reject) => {
5161
5725
  var fulfilled = (value) => {
@@ -5180,21 +5744,20 @@ class NgwWebmapLayerAdapter {
5180
5744
  constructor(map, options) {
5181
5745
  this.map = map;
5182
5746
  this.options = options;
5183
- __publicField$b(this, "layer");
5184
- __publicField$b(this, "NgwWebmapItem", NgwWebmapItem);
5747
+ __publicField$c(this, "layer");
5748
+ __publicField$c(this, "NgwWebmapItem", NgwWebmapItem);
5185
5749
  /**
5186
5750
  * Radius for searching objects in pixels
5187
5751
  */
5188
- __publicField$b(this, "pixelRadius", 10);
5752
+ __publicField$c(this, "pixelRadius", 10);
5189
5753
  // webmapSettings.identify_radius,
5190
- __publicField$b(this, "resourceId");
5191
- __publicField$b(this, "webmapClassName", "webmap");
5192
- __publicField$b(this, "emitter", new EventEmitter());
5193
- __publicField$b(this, "_extent");
5194
- __publicField$b(this, "response");
5195
- __publicField$b(this, "_webmapLayersIds");
5196
- __publicField$b(this, "_webmapBaselayersIds", []);
5197
- __publicField$b(this, "_lastActiveBaselayer");
5754
+ __publicField$c(this, "resourceId");
5755
+ __publicField$c(this, "webmapClassName", "webmap");
5756
+ __publicField$c(this, "emitter", new EventEmitter());
5757
+ __publicField$c(this, "_extent");
5758
+ __publicField$c(this, "response");
5759
+ __publicField$c(this, "_webmapBaselayersIds", []);
5760
+ __publicField$c(this, "_lastActiveBaselayer");
5198
5761
  const r = options.resourceId;
5199
5762
  if (Array.isArray(r)) {
5200
5763
  this.resourceId = r[0];
@@ -5237,7 +5800,6 @@ class NgwWebmapLayerAdapter {
5237
5800
  }
5238
5801
  delete this.layer;
5239
5802
  delete this.response;
5240
- delete this._webmapLayersIds;
5241
5803
  }
5242
5804
  showLayer() {
5243
5805
  return __async$a(this, null, function* () {
@@ -5328,26 +5890,19 @@ class NgwWebmapLayerAdapter {
5328
5890
  getIdentificationIds(options) {
5329
5891
  return __async$a(this, null, function* () {
5330
5892
  const visibleLayers = [];
5331
- let ids = this._webmapLayersIds;
5332
- if (!ids) {
5333
- ids = yield this._getWebMapIds(options);
5334
- this._webmapLayersIds = ids;
5335
- }
5336
- if (ids && ids.length) {
5337
- let deps = this.getDependLayers();
5338
- deps = deps.sort((a, b) => b.id - a.id);
5339
- deps.forEach((x) => {
5340
- const item = x.item;
5341
- const parentId = item.parentId;
5342
- if (parentId !== void 0 && item.item_type === "layer" && item.layer_identifiable) {
5343
- const visible = x.properties.property("visibility");
5344
- const isVisible = visible.get() && !visible.isBlocked();
5345
- if (isVisible) {
5346
- visibleLayers.push(parentId);
5347
- }
5893
+ let deps = this.getDependLayers();
5894
+ deps = deps.sort((a, b) => b.id - a.id);
5895
+ deps.forEach((x) => {
5896
+ const item = x.item;
5897
+ const parentId = item.style_parent_id;
5898
+ if (parentId !== void 0 && item.item_type === "layer" && item.layer_identifiable) {
5899
+ const visible = x.properties.property("visibility");
5900
+ const isVisible = visible.get() && !visible.isBlocked();
5901
+ if (isVisible) {
5902
+ visibleLayers.push(parentId);
5348
5903
  }
5349
- });
5350
- }
5904
+ }
5905
+ });
5351
5906
  return visibleLayers;
5352
5907
  });
5353
5908
  }
@@ -5476,50 +6031,25 @@ class NgwWebmapLayerAdapter {
5476
6031
  }
5477
6032
  return item;
5478
6033
  }
5479
- _getWebMapIds(options) {
5480
- return __async$a(this, null, function* () {
5481
- const webMapItem = this.layer;
5482
- if (webMapItem && webMapItem.item.item_type === "root") {
5483
- const layers = webMapItem.tree.getDescendants();
5484
- const promises = [];
5485
- for (const x of layers) {
5486
- const item = x.item;
5487
- if (item.item_type === "layer") {
5488
- const id = item.layer_style_id;
5489
- const promise = this.options.connector.getResource(id, options).then((y) => {
5490
- if (y) {
5491
- const parentId = Number(y.resource.parent.id);
5492
- item.parentId = parentId;
5493
- return parentId;
5494
- }
5495
- });
5496
- promises.push(promise);
5497
- }
5498
- }
5499
- const ids = yield Promise.all(promises);
5500
- return ids.filter((x) => x !== void 0);
5501
- }
5502
- });
5503
- }
5504
6034
  }
5505
6035
 
5506
- var __defProp$g = Object.defineProperty;
6036
+ var __defProp$h = Object.defineProperty;
5507
6037
  var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
5508
6038
  var __hasOwnProp$a = Object.prototype.hasOwnProperty;
5509
6039
  var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
5510
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6040
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5511
6041
  var __spreadValues$9 = (a, b) => {
5512
6042
  for (var prop in b || (b = {}))
5513
6043
  if (__hasOwnProp$a.call(b, prop))
5514
- __defNormalProp$g(a, prop, b[prop]);
6044
+ __defNormalProp$h(a, prop, b[prop]);
5515
6045
  if (__getOwnPropSymbols$a)
5516
6046
  for (var prop of __getOwnPropSymbols$a(b)) {
5517
6047
  if (__propIsEnum$a.call(b, prop))
5518
- __defNormalProp$g(a, prop, b[prop]);
6048
+ __defNormalProp$h(a, prop, b[prop]);
5519
6049
  }
5520
6050
  return a;
5521
6051
  };
5522
- var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
6052
+ var __publicField$b = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
5523
6053
  var __async$9 = (__this, __arguments, generator) => {
5524
6054
  return new Promise((resolve, reject) => {
5525
6055
  var fulfilled = (value) => {
@@ -5543,9 +6073,9 @@ var __async$9 = (__this, __arguments, generator) => {
5543
6073
  class NgwKit {
5544
6074
  constructor(options) {
5545
6075
  this.options = options;
5546
- __publicField$a(this, "url");
5547
- __publicField$a(this, "connector");
5548
- __publicField$a(this, "webMap");
6076
+ __publicField$b(this, "url");
6077
+ __publicField$b(this, "connector");
6078
+ __publicField$b(this, "webMap");
5549
6079
  if (this.options.connector) {
5550
6080
  this.url = this.options.connector.options.baseUrl || "";
5551
6081
  this.connector = this.options.connector;
@@ -5555,7 +6085,7 @@ class NgwKit {
5555
6085
  } else {
5556
6086
  throw new Error("url is not defined");
5557
6087
  }
5558
- this.connector = new NgwConnector({
6088
+ this.connector = new NgwConnectorExtended({
5559
6089
  baseUrl: this.url,
5560
6090
  auth: this.options.auth
5561
6091
  });
@@ -5606,37 +6136,37 @@ class NgwKit {
5606
6136
  }
5607
6137
  }
5608
6138
 
5609
- var __defProp$f = Object.defineProperty;
6139
+ var __defProp$g = Object.defineProperty;
5610
6140
  var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
5611
6141
  var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
5612
6142
  var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
5613
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6143
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5614
6144
  var __spreadValues$8 = (a, b) => {
5615
6145
  for (var prop in b || (b = {}))
5616
6146
  if (__hasOwnProp$9.call(b, prop))
5617
- __defNormalProp$f(a, prop, b[prop]);
6147
+ __defNormalProp$g(a, prop, b[prop]);
5618
6148
  if (__getOwnPropSymbols$9)
5619
6149
  for (var prop of __getOwnPropSymbols$9(b)) {
5620
6150
  if (__propIsEnum$9.call(b, prop))
5621
- __defNormalProp$f(a, prop, b[prop]);
6151
+ __defNormalProp$g(a, prop, b[prop]);
5622
6152
  }
5623
6153
  return a;
5624
6154
  };
5625
- var __publicField$9 = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
6155
+ var __publicField$a = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
5626
6156
  class IdentifyItem {
5627
6157
  constructor(options) {
5628
- __publicField$9(this, "id");
5629
- __publicField$9(this, "label");
5630
- __publicField$9(this, "layerId");
5631
- __publicField$9(this, "parent");
5632
- __publicField$9(this, "fields");
5633
- __publicField$9(this, "geom");
5634
- __publicField$9(this, "extensions");
5635
- __publicField$9(this, "connector");
5636
- __publicField$9(this, "_item");
5637
- __publicField$9(this, "_geojson");
5638
- __publicField$9(this, "_resource");
5639
- __publicField$9(this, "_extent");
6158
+ __publicField$a(this, "id");
6159
+ __publicField$a(this, "label");
6160
+ __publicField$a(this, "layerId");
6161
+ __publicField$a(this, "parent");
6162
+ __publicField$a(this, "fields");
6163
+ __publicField$a(this, "geom");
6164
+ __publicField$a(this, "extensions");
6165
+ __publicField$a(this, "connector");
6166
+ __publicField$a(this, "_item");
6167
+ __publicField$a(this, "_geojson");
6168
+ __publicField$a(this, "_resource");
6169
+ __publicField$a(this, "_extent");
5640
6170
  const f = options.feature;
5641
6171
  this.id = f.id;
5642
6172
  this.geom = f.geom;
@@ -5722,21 +6252,21 @@ function fetchNgwLayerFeature(options) {
5722
6252
  });
5723
6253
  }
5724
6254
 
5725
- var __defProp$e = Object.defineProperty;
6255
+ var __defProp$f = Object.defineProperty;
5726
6256
  var __defProps$4 = Object.defineProperties;
5727
6257
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
5728
6258
  var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
5729
6259
  var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
5730
6260
  var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
5731
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6261
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5732
6262
  var __spreadValues$7 = (a, b) => {
5733
6263
  for (var prop in b || (b = {}))
5734
6264
  if (__hasOwnProp$8.call(b, prop))
5735
- __defNormalProp$e(a, prop, b[prop]);
6265
+ __defNormalProp$f(a, prop, b[prop]);
5736
6266
  if (__getOwnPropSymbols$8)
5737
6267
  for (var prop of __getOwnPropSymbols$8(b)) {
5738
6268
  if (__propIsEnum$8.call(b, prop))
5739
- __defNormalProp$e(a, prop, b[prop]);
6269
+ __defNormalProp$f(a, prop, b[prop]);
5740
6270
  }
5741
6271
  return a;
5742
6272
  };
@@ -6580,19 +7110,19 @@ const typeExpressions = {
6580
7110
  typeof: evaluateArgs(([arg]) => typeOfValue(arg))
6581
7111
  };
6582
7112
 
6583
- var __defProp$d = Object.defineProperty;
7113
+ var __defProp$e = Object.defineProperty;
6584
7114
  var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
6585
7115
  var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
6586
7116
  var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
6587
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7117
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6588
7118
  var __spreadValues$6 = (a, b) => {
6589
7119
  for (var prop in b || (b = {}))
6590
7120
  if (__hasOwnProp$7.call(b, prop))
6591
- __defNormalProp$d(a, prop, b[prop]);
7121
+ __defNormalProp$e(a, prop, b[prop]);
6592
7122
  if (__getOwnPropSymbols$7)
6593
7123
  for (var prop of __getOwnPropSymbols$7(b)) {
6594
7124
  if (__propIsEnum$7.call(b, prop))
6595
- __defNormalProp$d(a, prop, b[prop]);
7125
+ __defNormalProp$e(a, prop, b[prop]);
6596
7126
  }
6597
7127
  return a;
6598
7128
  };
@@ -6617,19 +7147,19 @@ function evaluate(expression, data = {}) {
6617
7147
  throw new Error(`Expression "${name}" is not supported.`);
6618
7148
  }
6619
7149
 
6620
- var __defProp$c = Object.defineProperty;
7150
+ var __defProp$d = Object.defineProperty;
6621
7151
  var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
6622
7152
  var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
6623
7153
  var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
6624
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7154
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6625
7155
  var __spreadValues$5 = (a, b) => {
6626
7156
  for (var prop in b || (b = {}))
6627
7157
  if (__hasOwnProp$6.call(b, prop))
6628
- __defNormalProp$c(a, prop, b[prop]);
7158
+ __defNormalProp$d(a, prop, b[prop]);
6629
7159
  if (__getOwnPropSymbols$6)
6630
7160
  for (var prop of __getOwnPropSymbols$6(b)) {
6631
7161
  if (__propIsEnum$6.call(b, prop))
6632
- __defNormalProp$c(a, prop, b[prop]);
7162
+ __defNormalProp$d(a, prop, b[prop]);
6633
7163
  }
6634
7164
  return a;
6635
7165
  };
@@ -6668,19 +7198,19 @@ function createExpressionCallback(paint) {
6668
7198
  return;
6669
7199
  }
6670
7200
 
6671
- var __defProp$b = Object.defineProperty;
7201
+ var __defProp$c = Object.defineProperty;
6672
7202
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
6673
7203
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
6674
7204
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
6675
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7205
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6676
7206
  var __spreadValues$4 = (a, b) => {
6677
7207
  for (var prop in b || (b = {}))
6678
7208
  if (__hasOwnProp$5.call(b, prop))
6679
- __defNormalProp$b(a, prop, b[prop]);
7209
+ __defNormalProp$c(a, prop, b[prop]);
6680
7210
  if (__getOwnPropSymbols$5)
6681
7211
  for (var prop of __getOwnPropSymbols$5(b)) {
6682
7212
  if (__propIsEnum$5.call(b, prop))
6683
- __defNormalProp$b(a, prop, b[prop]);
7213
+ __defNormalProp$c(a, prop, b[prop]);
6684
7214
  }
6685
7215
  return a;
6686
7216
  };
@@ -6804,95 +7334,95 @@ function preparePaint({
6804
7334
  return newPaint;
6805
7335
  }
6806
7336
 
6807
- var __defProp$a = Object.defineProperty;
6808
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6809
- var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
7337
+ var __defProp$b = Object.defineProperty;
7338
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7339
+ var __publicField$9 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
6810
7340
  class KeyCodes {
6811
7341
  constructor() {
6812
- __publicField$8(this, "backspace", 8);
6813
- __publicField$8(this, "tab", 9);
6814
- __publicField$8(this, "enter", 13);
6815
- __publicField$8(this, "shift", 16);
6816
- __publicField$8(this, "ctrl", 17);
6817
- __publicField$8(this, "alt", 18);
6818
- __publicField$8(this, "pause/break", 19);
6819
- __publicField$8(this, "caps_lock", 20);
6820
- __publicField$8(this, "escape", 27);
6821
- __publicField$8(this, "page_up", 33);
6822
- __publicField$8(this, "page_down", 34);
6823
- __publicField$8(this, "end", 35);
6824
- __publicField$8(this, "home", 36);
6825
- __publicField$8(this, "left_arrow", 37);
6826
- __publicField$8(this, "up_arrow", 38);
6827
- __publicField$8(this, "right_arrow", 39);
6828
- __publicField$8(this, "down_arrow", 40);
6829
- __publicField$8(this, "insert", 45);
6830
- __publicField$8(this, "delete", 46);
6831
- __publicField$8(this, "left_window_key", 91);
6832
- __publicField$8(this, "right_window_key", 92);
6833
- __publicField$8(this, "select_key", 93);
6834
- __publicField$8(this, "numpad_0", 96);
6835
- __publicField$8(this, "numpad_1", 97);
6836
- __publicField$8(this, "numpad_2", 98);
6837
- __publicField$8(this, "numpad_3", 99);
6838
- __publicField$8(this, "numpad_4", 100);
6839
- __publicField$8(this, "numpad_5", 101);
6840
- __publicField$8(this, "numpad_6", 102);
6841
- __publicField$8(this, "numpad_7", 103);
6842
- __publicField$8(this, "numpad_8", 104);
6843
- __publicField$8(this, "numpad_9", 105);
6844
- __publicField$8(this, "multiply", 106);
6845
- __publicField$8(this, "add", 107);
6846
- __publicField$8(this, "subtract", 109);
6847
- __publicField$8(this, "decimal_point", 110);
6848
- __publicField$8(this, "divide", 111);
6849
- __publicField$8(this, "f1", 112);
6850
- __publicField$8(this, "f2", 113);
6851
- __publicField$8(this, "f3", 114);
6852
- __publicField$8(this, "f4", 115);
6853
- __publicField$8(this, "f5", 116);
6854
- __publicField$8(this, "f6", 117);
6855
- __publicField$8(this, "f7", 118);
6856
- __publicField$8(this, "f8", 119);
6857
- __publicField$8(this, "f9", 120);
6858
- __publicField$8(this, "f10", 121);
6859
- __publicField$8(this, "f11", 122);
6860
- __publicField$8(this, "f12", 123);
6861
- __publicField$8(this, "num_lock", 144);
6862
- __publicField$8(this, "scroll_lock", 145);
6863
- __publicField$8(this, "semi-colon", 186);
6864
- __publicField$8(this, "equal_sign", 187);
6865
- __publicField$8(this, ",", 188);
7342
+ __publicField$9(this, "backspace", 8);
7343
+ __publicField$9(this, "tab", 9);
7344
+ __publicField$9(this, "enter", 13);
7345
+ __publicField$9(this, "shift", 16);
7346
+ __publicField$9(this, "ctrl", 17);
7347
+ __publicField$9(this, "alt", 18);
7348
+ __publicField$9(this, "pause/break", 19);
7349
+ __publicField$9(this, "caps_lock", 20);
7350
+ __publicField$9(this, "escape", 27);
7351
+ __publicField$9(this, "page_up", 33);
7352
+ __publicField$9(this, "page_down", 34);
7353
+ __publicField$9(this, "end", 35);
7354
+ __publicField$9(this, "home", 36);
7355
+ __publicField$9(this, "left_arrow", 37);
7356
+ __publicField$9(this, "up_arrow", 38);
7357
+ __publicField$9(this, "right_arrow", 39);
7358
+ __publicField$9(this, "down_arrow", 40);
7359
+ __publicField$9(this, "insert", 45);
7360
+ __publicField$9(this, "delete", 46);
7361
+ __publicField$9(this, "left_window_key", 91);
7362
+ __publicField$9(this, "right_window_key", 92);
7363
+ __publicField$9(this, "select_key", 93);
7364
+ __publicField$9(this, "numpad_0", 96);
7365
+ __publicField$9(this, "numpad_1", 97);
7366
+ __publicField$9(this, "numpad_2", 98);
7367
+ __publicField$9(this, "numpad_3", 99);
7368
+ __publicField$9(this, "numpad_4", 100);
7369
+ __publicField$9(this, "numpad_5", 101);
7370
+ __publicField$9(this, "numpad_6", 102);
7371
+ __publicField$9(this, "numpad_7", 103);
7372
+ __publicField$9(this, "numpad_8", 104);
7373
+ __publicField$9(this, "numpad_9", 105);
7374
+ __publicField$9(this, "multiply", 106);
7375
+ __publicField$9(this, "add", 107);
7376
+ __publicField$9(this, "subtract", 109);
7377
+ __publicField$9(this, "decimal_point", 110);
7378
+ __publicField$9(this, "divide", 111);
7379
+ __publicField$9(this, "f1", 112);
7380
+ __publicField$9(this, "f2", 113);
7381
+ __publicField$9(this, "f3", 114);
7382
+ __publicField$9(this, "f4", 115);
7383
+ __publicField$9(this, "f5", 116);
7384
+ __publicField$9(this, "f6", 117);
7385
+ __publicField$9(this, "f7", 118);
7386
+ __publicField$9(this, "f8", 119);
7387
+ __publicField$9(this, "f9", 120);
7388
+ __publicField$9(this, "f10", 121);
7389
+ __publicField$9(this, "f11", 122);
7390
+ __publicField$9(this, "f12", 123);
7391
+ __publicField$9(this, "num_lock", 144);
7392
+ __publicField$9(this, "scroll_lock", 145);
7393
+ __publicField$9(this, "semi-colon", 186);
7394
+ __publicField$9(this, "equal_sign", 187);
7395
+ __publicField$9(this, ",", 188);
6866
7396
  // "comma";
6867
- __publicField$8(this, "-", 189);
7397
+ __publicField$9(this, "-", 189);
6868
7398
  // "dash";
6869
- __publicField$8(this, ".", 190);
7399
+ __publicField$9(this, ".", 190);
6870
7400
  // "period";
6871
- __publicField$8(this, "/", 191);
7401
+ __publicField$9(this, "/", 191);
6872
7402
  // "forward slash";
6873
- __publicField$8(this, "`", 192);
7403
+ __publicField$9(this, "`", 192);
6874
7404
  // "grave accent";
6875
- __publicField$8(this, "[", 219);
7405
+ __publicField$9(this, "[", 219);
6876
7406
  // "open bracket";
6877
- __publicField$8(this, "\\", 220);
7407
+ __publicField$9(this, "\\", 220);
6878
7408
  // "back slash";
6879
- __publicField$8(this, "]", 221);
7409
+ __publicField$9(this, "]", 221);
6880
7410
  // "close braket";
6881
- __publicField$8(this, "'", 222);
7411
+ __publicField$9(this, "'", 222);
6882
7412
  }
6883
7413
  // "single quote"
6884
7414
  }
6885
7415
 
6886
- var __defProp$9 = Object.defineProperty;
6887
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6888
- var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
7416
+ var __defProp$a = Object.defineProperty;
7417
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7418
+ var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
6889
7419
  class Keys {
6890
7420
  constructor() {
6891
- __publicField$7(this, "keyCodeAlias", new KeyCodes());
6892
- __publicField$7(this, "keys", {});
6893
- __publicField$7(this, "_windowOnFocus");
6894
- __publicField$7(this, "_keysPressed");
6895
- __publicField$7(this, "_keysReleased");
7421
+ __publicField$8(this, "keyCodeAlias", new KeyCodes());
7422
+ __publicField$8(this, "keys", {});
7423
+ __publicField$8(this, "_windowOnFocus");
7424
+ __publicField$8(this, "_keysPressed");
7425
+ __publicField$8(this, "_keysReleased");
6896
7426
  this._windowOnFocus = this.windowOnFocus.bind(this);
6897
7427
  this._keysPressed = this.keysPressed.bind(this);
6898
7428
  this._keysReleased = this.keysReleased.bind(this);
@@ -6931,15 +7461,15 @@ class Keys {
6931
7461
  }
6932
7462
  }
6933
7463
 
6934
- var __defProp$8 = Object.defineProperty;
6935
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6936
- var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
7464
+ var __defProp$9 = Object.defineProperty;
7465
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7466
+ var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
6937
7467
  class StateItem {
6938
7468
  constructor(webMap, opt) {
6939
7469
  this.webMap = webMap;
6940
- __publicField$6(this, "name");
6941
- __publicField$6(this, "event");
6942
- __publicField$6(this, "value");
7470
+ __publicField$7(this, "name");
7471
+ __publicField$7(this, "event");
7472
+ __publicField$7(this, "value");
6943
7473
  if (opt) {
6944
7474
  if (opt.value) {
6945
7475
  this.setValue(opt.value);
@@ -6948,7 +7478,11 @@ class StateItem {
6948
7478
  this.name = opt.name;
6949
7479
  }
6950
7480
  if (opt.event) {
6951
- this.event = opt.event;
7481
+ if (typeof opt.event === "string") {
7482
+ this.event = [opt.event];
7483
+ } else {
7484
+ this.event = opt.event;
7485
+ }
6952
7486
  }
6953
7487
  }
6954
7488
  }
@@ -6960,6 +7494,34 @@ class StateItem {
6960
7494
  }
6961
7495
  }
6962
7496
 
7497
+ var __defProp$8 = Object.defineProperty;
7498
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7499
+ var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
7500
+ class BoundState extends StateItem {
7501
+ constructor() {
7502
+ super(...arguments);
7503
+ __publicField$6(this, "name", "bounds");
7504
+ __publicField$6(this, "event", ["moveend"]);
7505
+ }
7506
+ getValue() {
7507
+ return this.webMap.getBounds();
7508
+ }
7509
+ setValue(bounds) {
7510
+ this.webMap.setView({ bounds });
7511
+ }
7512
+ toString() {
7513
+ const data = this.getValue();
7514
+ if (data) {
7515
+ return data.slice(0, 4).map((x) => x.toFixed(5)).join("_");
7516
+ }
7517
+ return void 0;
7518
+ }
7519
+ parse(str) {
7520
+ const lngLat = str.split("_").map(Number);
7521
+ return lngLat;
7522
+ }
7523
+ }
7524
+
6963
7525
  var __defProp$7 = Object.defineProperty;
6964
7526
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6965
7527
  var __publicField$5 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -6967,7 +7529,7 @@ class CenterState extends StateItem {
6967
7529
  constructor() {
6968
7530
  super(...arguments);
6969
7531
  __publicField$5(this, "name", "center");
6970
- __publicField$5(this, "event", "moveend");
7532
+ __publicField$5(this, "event", ["moveend"]);
6971
7533
  }
6972
7534
  getValue() {
6973
7535
  return this.webMap.getCenter();
@@ -6975,9 +7537,13 @@ class CenterState extends StateItem {
6975
7537
  setValue(val) {
6976
7538
  this.webMap.setCenter(val);
6977
7539
  }
6978
- toString(data) {
6979
- const d = data.map((x) => x.toFixed(5));
6980
- return d[0] + "_" + d[1];
7540
+ toString() {
7541
+ const data = this.getValue();
7542
+ if (data) {
7543
+ const d = data.map((x) => x.toFixed(5));
7544
+ return d[0] + "_" + d[1];
7545
+ }
7546
+ return "";
6981
7547
  }
6982
7548
  parse(str) {
6983
7549
  const lngLat = str.split("_").map(Number);
@@ -6992,7 +7558,7 @@ class ZoomState extends StateItem {
6992
7558
  constructor() {
6993
7559
  super(...arguments);
6994
7560
  __publicField$4(this, "name", "zoom");
6995
- __publicField$4(this, "event", "zoomend");
7561
+ __publicField$4(this, "event", ["zoomend"]);
6996
7562
  }
6997
7563
  getValue() {
6998
7564
  const zoom = this.webMap.getZoom();
@@ -7001,8 +7567,8 @@ class ZoomState extends StateItem {
7001
7567
  setValue(val) {
7002
7568
  this.webMap.setZoom(val);
7003
7569
  }
7004
- toString(val) {
7005
- return String(val);
7570
+ toString() {
7571
+ return String(this.getValue());
7006
7572
  }
7007
7573
  parse(str) {
7008
7574
  return Number(str);
@@ -7071,14 +7637,14 @@ const _WebMapMain = class _WebMapMain {
7071
7637
  __publicField$3(this, "mapAdapter");
7072
7638
  __publicField$3(this, "runtimeParams", []);
7073
7639
  __publicField$3(this, "getPaintFunctions", _WebMapMain.getPaintFunctions);
7074
- __publicField$3(this, "mapState", [CenterState, ZoomState]);
7640
+ __publicField$3(this, "mapStateItems", [CenterState, ZoomState, BoundState]);
7075
7641
  __publicField$3(this, "id", ID++);
7076
7642
  /**
7077
7643
  * From runtime params
7078
7644
  */
7645
+ __publicField$3(this, "mapState", []);
7079
7646
  __publicField$3(this, "_initMapState", {});
7080
7647
  __publicField$3(this, "_starterKits");
7081
- __publicField$3(this, "_mapState", []);
7082
7648
  __publicField$3(this, "_extent");
7083
7649
  __publicField$3(this, "_eventsStatus", {});
7084
7650
  __publicField$3(this, "_coordFromMapClickAbort");
@@ -7113,7 +7679,7 @@ const _WebMapMain = class _WebMapMain {
7113
7679
  create() {
7114
7680
  return __async$6(this, null, function* () {
7115
7681
  if (!this.getEventStatus("create")) {
7116
- yield this._setInitMapState(this.mapState);
7682
+ yield this._setInitMapState(this.mapStateItems);
7117
7683
  yield this._setupMap();
7118
7684
  this._emitStatusEvent("create", this);
7119
7685
  }
@@ -7133,16 +7699,22 @@ const _WebMapMain = class _WebMapMain {
7133
7699
  this.mapAdapter.destroy();
7134
7700
  }
7135
7701
  }
7136
- getState() {
7702
+ mapStateWithFunc(func) {
7137
7703
  const state = {};
7138
- this._mapState.forEach((x) => {
7139
- state[x.name] = x.getValue();
7704
+ this.mapState.forEach((x) => {
7705
+ state[x.name] = func(x);
7140
7706
  });
7141
7707
  return state;
7142
7708
  }
7709
+ getStateAsString() {
7710
+ return this.mapStateWithFunc((x) => x.toString());
7711
+ }
7712
+ getState() {
7713
+ return this.mapStateWithFunc((x) => x.getValue());
7714
+ }
7143
7715
  getRuntimeParams() {
7144
7716
  const state = {};
7145
- this._mapState.forEach((x) => {
7717
+ this.mapState.forEach((x) => {
7146
7718
  for (const r of this.runtimeParams) {
7147
7719
  const val = r.get(x.name);
7148
7720
  if (val !== void 0) {
@@ -7484,7 +8056,7 @@ const _WebMapMain = class _WebMapMain {
7484
8056
  _setInitMapState(states) {
7485
8057
  for (const X of states) {
7486
8058
  const state = new X(this);
7487
- this._mapState.push(state);
8059
+ this.mapState.push(state);
7488
8060
  for (const r of this.runtimeParams) {
7489
8061
  const str = r.get(state.name);
7490
8062
  if (str !== void 0) {
@@ -7520,13 +8092,15 @@ const _WebMapMain = class _WebMapMain {
7520
8092
  events.forEach((x) => {
7521
8093
  this._mapEvents[x] = (data) => {
7522
8094
  if (this.runtimeParams.length) {
7523
- const mapStatusEvent = this._mapState.find((y) => y.event === x);
7524
- if (mapStatusEvent) {
7525
- const value = mapStatusEvent.toString(mapStatusEvent.getValue());
8095
+ const mapStatusEvents = this.mapState.filter(
8096
+ (y) => y.event.includes(x)
8097
+ );
8098
+ mapStatusEvents.forEach((mapStatusEvent) => {
8099
+ const value = mapStatusEvent.toString();
7526
8100
  this.runtimeParams.forEach((r) => {
7527
8101
  r.set(mapStatusEvent.name, value);
7528
8102
  });
7529
- }
8103
+ });
7530
8104
  }
7531
8105
  if (this._eventsStatus) {
7532
8106
  this.emitter.emit(x, data);
@@ -8102,11 +8676,11 @@ class WebMapLayers extends WebMapMain {
8102
8676
  }
8103
8677
  return Promise.resolve();
8104
8678
  }
8105
- updateLayer(layerDef) {
8679
+ updateLayer(layerDef, options) {
8106
8680
  const layer = this.getLayer(layerDef);
8107
8681
  if (layer) {
8108
8682
  if (layer.updateLayer) {
8109
- return Promise.resolve(layer.updateLayer());
8683
+ return Promise.resolve(layer.updateLayer(options));
8110
8684
  } else if (this.isLayerVisible(layer)) {
8111
8685
  return this.hideLayer(layer, { silent: true }).then(() => {
8112
8686
  return this.showLayer(layer, { silent: true });
@@ -9023,7 +9597,7 @@ function prepareWebMapOptions(options) {
9023
9597
  });
9024
9598
  }
9025
9599
  if (!options.connector) {
9026
- options.connector = new NgwConnector({
9600
+ options.connector = new NgwConnectorExtended({
9027
9601
  baseUrl: options.baseUrl || "",
9028
9602
  auth: options.auth,
9029
9603
  withCredentials: options.withCredentials
@@ -9297,7 +9871,7 @@ const _NgwMap = class _NgwMap extends WebMap {
9297
9871
  if (mem.layer.getDependLayers) {
9298
9872
  const dependLayers = mem.layer.getDependLayers();
9299
9873
  const dependFit = dependLayers.find((x) => {
9300
- return x.item && x.item.parentId === id;
9874
+ return x.item && x.item.style_parent_id === id;
9301
9875
  });
9302
9876
  if (dependFit) {
9303
9877
  return dependFit.layer;