PageSourceSearch

https://laverstockford-pc.gov.uk/wp-content/uploads/parish-cache/xmap-embed.mjs?ver=1791558300

js laverstockford-pc.gov.uk collected 2026-10-10 00:33:05 UTC 1,085,014 bytes, 33,131 lines download raw bytes

vendor: 8,315 bytes, lines 1-301
1function Om(e) {
2  e("EPSG:4326", "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"), e("EPSG:4269", "+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"), e("EPSG:3857", "+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"), e.WGS84 = e["EPSG:4326"], e["EPSG:3785"] = e["EPSG:3857"], e.GOOGLE = e["EPSG:3857"], e["EPSG:900913"] = e["EPSG:3857"], e["EPSG:102113"] = e["EPSG:3857"];
3}
4var Tn = 1, In = 2, ls = 3, Fm = 4, dl = 5, Sc = 6378137, km = 6356752314e-3, Tc = 0.0066943799901413165, nr = 484813681109536e-20, A = Math.PI / 2, Dm = 0.16666666666666666, Nm = 0.04722222222222222, Gm = 0.022156084656084655, G = 1e-10, Zt = 0.017453292519943295, Wi = 57.29577951308232, Et = Math.PI / 4, cr = Math.PI * 2, Gt = 3.14159265359, Se = {};
5Se.greenwich = 0;
6Se.lisbon = -9.131906111111;
7Se.paris = 2.337229166667;
8Se.bogota = -74.080916666667;
9Se.madrid = -3.687938888889;
10Se.rome = 12.452333333333;
11Se.bern = 7.439583333333;
12Se.jakarta = 106.807719444444;
13Se.ferro = -17.666666666667;
14Se.brussels = 4.367975;
15Se.stockholm = 18.058277777778;
16Se.athens = 23.7163375;
17Se.oslo = 10.722916666667;
18const zm = {
19  ft: { to_meter: 0.3048 },
20  "us-ft": { to_meter: 1200 / 3937 }
21};
22var Ic = /[\s_\-\/\(\)]/g;
23function tn(e, t) {
24  if (e[t])
25    return e[t];
26  for (var i = Object.keys(e), n = t.toLowerCase().replace(Ic, ""), s = -1, r, o; ++s < i.length; )
27    if (r = i[s], o = r.toLowerCase().replace(Ic, ""), o === n)
28      return e[r];
29}
30function fl(e) {
31  var t = {}, i = e.split("+").map(function(a) {
32    return a.trim();
33  }).filter(function(a) {
34    return a;
35  }).reduce(function(a, l) {
36    var h = l.split("=");
37    return h.push(!0), a[h[0].toLowerCase()] = h[1], a;
38  }, {}), n, s, r, o = {
39    proj: "projName",
40    datum: "datumCode",
41    rf: function(a) {
42      t.rf = parseFloat(a);
43    },
44    lat_0: function(a) {
45      t.lat0 = a * Zt;
46    },
47    lat_1: function(a) {
48      t.lat1 = a * Zt;
49    },
50    lat_2: function(a) {
51      t.lat2 = a * Zt;
52    },
53    lat_ts: function(a) {
54      t.lat_ts = a * Zt;
55    },
56    lon_0: function(a) {
57      t.long0 = a * Zt;
58    },
59    lon_1: function(a) {
60      t.long1 = a * Zt;
61    },
62    lon_2: function(a) {
63      t.long2 = a * Zt;
64    },
65    alpha: function(a) {
66      t.alpha = parseFloat(a) * Zt;
67    },
68    gamma: function(a) {
69      t.rectified_grid_angle = parseFloat(a);
70    },
71    lonc: function(a) {
72      t.longc = a * Zt;
73    },
74    x_0: function(a) {
75      t.x0 = parseFloat(a);
76    },
77    y_0: function(a) {
78      t.y0 = parseFloat(a);
79    },
80    k_0: function(a) {
81      t.k0 = parseFloat(a);
82    },
83    k: function(a) {
84      t.k0 = parseFloat(a);
85    },
86    a: function(a) {
87      t.a = parseFloat(a);
88    },
89    b: function(a) {
90      t.b = parseFloat(a);
91    },
92    r_a: function() {
93      t.R_A = !0;
94    },
95    zone: function(a) {
96      t.zone = parseInt(a, 10);
97    },
98    south: function() {
99      t.utmSouth = !0;
100    },
101    towgs84: function(a) {
102      t.datum_params = a.split(",").map(function(l) {
103        return parseFloat(l);
104      });
105    },
106    to_meter: function(a) {
107      t.to_meter = parseFloat(a);
108    },
109    units: function(a) {
110      t.units = a;
111      var l = tn(zm, a);
112      l && (t.to_meter = l.to_meter);
113    },
114    from_greenwich: function(a) {
115      t.from_greenwich = a * Zt;
116    },
117    pm: function(a) {
118      var l = tn(Se, a);
119      t.from_greenwich = (l || parseFloat(a)) * Zt;
120    },
121    nadgrids: function(a) {
122      a === "@null" ? t.datumCode = "none" : t.nadgrids = a;
123    },
124    axis: function(a) {
125      var l = "ewnsud";
126      a.length === 3 && l.indexOf(a.substr(0, 1)) !== -1 && l.indexOf(a.substr(1, 1)) !== -1 && l.indexOf(a.substr(2, 1)) !== -1 && (t.axis = a);
127    },
128    approx: function() {
129      t.approx = !0;
130    }
131  };
132  for (n in i)
133    s = i[n], n in o ? (r = o[n], typeof r == "function" ? r(s) : t[r] = s) : t[n] = s;
134  return typeof t.datumCode == "string" && t.datumCode !== "WGS84" && (t.datumCode = t.datumCode.toLowerCase()), t;
135}
136var ur = 1, Id = 2, Rd = 3, Io = 4, Pd = 5, Jl = -1, jm = /\s/, Wm = /[A-Za-z]/, Bm = /[A-Za-z84_]/, ia = /[,\]]/, Ld = /[\d\.E\-\+]/;
137function Ii(e) {
138  if (typeof e != "string")
139    throw new Error("not a string");
140  this.text = e.trim(), this.level = 0, this.place = 0, this.root = null, this.stack = [], this.currentObject = null, this.state = ur;
141}
142Ii.prototype.readCharicter = function() {
143  var e = this.text[this.place++];
144  if (this.state !== Io)
145    for (; jm.test(e); ) {
146      if (this.place >= this.text.length)
147        return;
148      e = this.text[this.place++];
149    }
150  switch (this.state) {
151    case ur:
152      return this.neutral(e);
153    case Id:
154      return this.keyword(e);
155    case Io:
156      return this.quoted(e);
157    case Pd:
158      return this.afterquote(e);
159    case Rd:
160      return this.number(e);
161    case Jl:
162      return;
163  }
164};
165Ii.prototype.afterquote = function(e) {
166  if (e === '"') {
167    this.word += '"', this.state = Io;
168    return;
169  }
170  if (ia.test(e)) {
171    this.word = this.word.trim(), this.afterItem(e);
172    return;
173  }
174  throw new Error(`havn't handled "` + e + '" in afterquote yet, index ' + this.place);
175};
176Ii.prototype.afterItem = function(e) {
177  if (e === ",") {
178    this.word !== null && this.currentObject.push(this.word), this.word = null, this.state = ur;
179    return;
180  }
181  if (e === "]") {
182    this.level--, this.word !== null && (this.currentObject.push(this.word), this.word = null), this.state = ur, this.currentObject = this.stack.pop(), this.currentObject || (this.state = Jl);
183    return;
184  }
185};
186Ii.prototype.number = function(e) {
187  if (Ld.test(e)) {
188    this.word += e;
189    return;
190  }
191  if (ia.test(e)) {
192    this.word = parseFloat(this.word), this.afterItem(e);
193    return;
194  }
195  throw new Error(`havn't handled "` + e + '" in number yet, index ' + this.place);
196};
197Ii.prototype.quoted = function(e) {
198  if (e === '"') {
199    this.state = Pd;
200    return;
201  }
202  this.word += e;
203};
204Ii.prototype.keyword = function(e) {
205  if (Bm.test(e)) {
206    this.word += e;
207    return;
208  }
209  if (e === "[") {
210    var t = [];
211    t.push(this.word), this.level++, this.root === null ? this.root = t : this.currentObject.push(t), this.stack.push(this.currentObject), this.currentObject = t, this.state = ur;
212    return;
213  }
214  if (ia.test(e)) {
215    this.afterItem(e);
216    return;
217  }
218  throw new Error(`havn't handled "` + e + '" in keyword yet, index ' + this.place);
219};
220Ii.prototype.neutral = function(e) {
221  if (Wm.test(e)) {
222    this.word = e, this.state = Id;
223    return;
224  }
225  if (e === '"') {
226    this.word = "", this.state = Io;
227    return;
228  }
229  if (Ld.test(e)) {
230    this.word = e, this.state = Rd;
231    return;
232  }
233  if (ia.test(e)) {
234    this.afterItem(e);
235    return;
236  }
237  throw new Error(`havn't handled "` + e + '" in neutral yet, index ' + this.place);
238};
239Ii.prototype.output = function() {
240  for (; this.place < this.text.length; )
241    this.readCharicter();
242  if (this.state === Jl)
243    return this.root;
244  throw new Error('unable to parse string "' + this.text + '". State is ' + this.state);
245};
246function Um(e) {
247  var t = new Ii(e);
248  return t.output();
249}
250function Rc(e, t, i) {
251  Array.isArray(t) && (i.unshift(t), t = null);
252  var n = t ? {} : e, s = i.reduce(function(r, o) {
253    return Qn(o, r), r;
254  }, n);
255  t && (e[t] = s);
256}
257function Qn(e, t) {
258  if (!Array.isArray(e)) {
259    t[e] = !0;
260    return;
261  }
262  var i = e.shift();
263  if (i === "PARAMETER" && (i = e.shift()), e.length === 1) {
264    if (Array.isArray(e[0])) {
265      t[i] = {}, Qn(e[0], t[i]);
266      return;
267    }
268    t[i] = e[0];
269    return;
270  }
271  if (!e.length) {
272    t[i] = !0;
273    return;
274  }
275  if (i === "TOWGS84") {
276    t[i] = e;
277    return;
278  }
279  if (i === "AXIS") {
280    i in t || (t[i] = []), t[i].push(e);
281    return;
282  }
283  Array.isArray(i) || (t[i] = {});
284  var n;
285  switch (i) {
286    case "UNIT":
287    case "PRIMEM":
288    case "VERT_DATUM":
289      t[i] = {
290        name: e[0].toLowerCase(),
291        convert: e[1]
292      }, e.length === 3 && Qn(e[2], t[i]);
293      return;
294    case "SPHEROID":
295    case "ELLIPSOID":
296      t[i] = {
297        name: e[0],
298        a: e[1],
299        rf: e[2]
300      }, e.length === 4 && Qn(e[3], t[i]);
301      return;
302    case "PROJECTEDCRS":
303    case "PROJCRS":
304    case "GEOGCS":
305    case "GEOCCS":
306    case "PROJCS":
307    case "LOCAL_CS":
308    case "GEODCRS":
309    case "GEODETICCRS":
310    case "GEODETICDATUM":
311    case "EDATUM":
312    case "ENGINEERINGDATUM":
313    case "VERT_CS":
314    case "VERTCRS":
315    case "VERTICALCRS":
316    case "COMPD_CS":
317    case "COMPOUNDCRS":
318    case "ENGINEERINGCRS":
319    case "ENGCRS":
320    case "FITTED_CS":
321    case "LOCAL_DATUM":
322    case "DATUM":
323      e[0] = ["name", e[0]], Rc(t, i, e);
324      return;
325    default:
326      for (n = -1; ++n < e.length; )
327        if (!Array.isArray(e[n]))
328          return Qn(e, t[i]);
329      return Rc(t, i, e);
330  }
331}
332var Xm = 0.017453292519943295;
333function $m(e, t) {
334  var i = t[0], n = t[1];
335  !(i in e) && n in e && (e[i] = e[n], t.length === 3 && (e[i] = t[2](e[i])));
336}
337function ei(e) {
338  return e * Xm;
339}
340function Ym(e) {
341  if (e.type === "GEOGCS" ? e.projName = "longlat" : e.type === "LOCAL_CS" ? (e.projName = "identity", e.local = !0) : typeof e.PROJECTION == "object" ? e.projName = Object.keys(e.PROJECTION)[0] : e.projName = e.PROJECTION, e.AXIS) {
342    for (var t = "", i = 0, n = e.AXIS.length; i < n; ++i) {
343      var s = [e.AXIS[i][0].toLowerCase(), e.AXIS[i][1].toLowerCase()];
344      s[0].indexOf("north") !== -1 || (s[0] === "y" || s[0] === "lat") && s[1] === "north" ? t += "n" : s[0].indexOf("south") !== -1 || (s[0] === "y" || s[0] === "lat") && s[1] === "south" ? t += "s" : s[0].indexOf("east") !== -1 || (s[0] === "x" || s[0] === "lon") && s[1] === "east" ? t += "e" : (s[0].indexOf("west") !== -1 || (s[0] === "x" || s[0] === "lon") && s[1] === "west") && (t += "w");
345    }
346    t.length === 2 && (t += "u"), t.length === 3 && (e.axis = t);
347  }
348  e.UNIT && (e.units = e.UNIT.name.toLowerCase(), e.units === "metre" && (e.units = "meter"), e.UNIT.convert && (e.type === "GEOGCS" ? e.DATUM && e.DATUM.SPHEROID && (e.to_meter = e.UNIT.convert * e.DATUM.SPHEROID.a) : e.to_meter = e.UNIT.convert));
349  var r = e.GEOGCS;
350  e.type === "GEOGCS" && (r = e), r && (r.DATUM ? e.datumCode = r.DATUM.name.toLowerCase() : e.datumCode = r.name.toLowerCase(), e.datumCode.slice(0, 2) === "d_" && (e.datumCode = e.datumCode.slice(2)), (e.datumCode === "new_zealand_geodetic_datum_1949" || e.datumCode === "new_zealand_1949") && (e.datumCode = "nzgd49"), (e.datumCode === "wgs_1984" || e.datumCode === "world_geodetic_system_1984") && (e.PROJECTION === "Mercator_Auxiliary_Sphere" && (e.sphere = !0), e.datumCode = "wgs84"), e.datumCode.slice(-6) === "_ferro" && (e.datumCode = e.datumCode.slice(0, -6)), e.datumCode.slice(-8) === "_jakarta" && (e.datumCode = e.datumCode.slice(0, -8)), ~e.datumCode.indexOf("belge") && (e.datumCode = "rnb72"), r.DATUM && r.DATUM.SPHEROID && (e.ellps = r.DATUM.SPHEROID.name.replace("_19", "").replace(/[Cc]larke\_18/, "clrk"), e.ellps.toLowerCase().slice(0, 13) === "international" && (e.ellps = "intl"), e.a = r.DATUM.SPHEROID.a, e.rf = parseFloat(r.DATUM.SPHEROID.rf, 10)), r.DATUM && r.DATUM.TOWGS84 && (e.datum_params = r.DATUM.TOWGS84), ~e.datumCode.indexOf("osgb_1936") && (e.datumCode = "osgb36"), ~e.datumCode.indexOf("osni_1952") && (e.datumCode = "osni52"), (~e.datumCode.indexOf("tm65") || ~e.datumCode.indexOf("geodetic_datum_of_1965")) && (e.datumCode = "ire65"), e.datumCode === "ch1903+" && (e.datumCode = "ch1903"), ~e.datumCode.indexOf("israel") && (e.datumCode = "isr93")), e.b && !isFinite(e.b) && (e.b = e.a);
351  function o(h) {
352    var c = e.to_meter || 1;
353    return h * c;
354  }
355  var a = function(h) {
356    return $m(e, h);
357  }, l = [
358    ["standard_parallel_1", "Standard_Parallel_1"],
359    ["standard_parallel_1", "Latitude of 1st standard parallel"],
360    ["standard_parallel_2", "Standard_Parallel_2"],
361    ["standard_parallel_2", "Latitude of 2nd standard parallel"],
362    ["false_easting", "False_Easting"],
363    ["false_easting", "False easting"],
364    ["false-easting", "Easting at false origin"],
365    ["false_northing", "False_Northing"],
366    ["false_northing", "False northing"],
367    ["false_northing", "Northing at false origin"],
368    ["central_meridian", "Central_Meridian"],
369    ["central_meridian", "Longitude of natural origin"],
370    ["central_meridian", "Longitude of false origin"],
371    ["latitude_of_origin", "Latitude_Of_Origin"],
372    ["latitude_of_origin", "Central_Parallel"],
373    ["latitude_of_origin", "Latitude of natural origin"],
374    ["latitude_of_origin", "Latitude of false origin"],
375    ["scale_factor", "Scale_Factor"],
376    ["k0", "scale_factor"],
377    ["latitude_of_center", "Latitude_Of_Center"],
378    ["latitude_of_center", "Latitude_of_center"],
379    ["lat0", "latitude_of_center", ei],
380    ["longitude_of_center", "Longitude_Of_Center"],
381    ["longitude_of_center", "Longitude_of_center"],
382    ["longc", "longitude_of_center", ei],
383    ["x0", "false_easting", o],
384    ["y0", "false_northing", o],
385    ["long0", "central_meridian", ei],
386    ["lat0", "latitude_of_origin", ei],
387    ["lat0", "standard_parallel_1", ei],
388    ["lat1", "standard_parallel_1", ei],
389    ["lat2", "standard_parallel_2", ei],
390    ["azimuth", "Azimuth"],
391    ["alpha", "azimuth", ei],
392    ["srsCode", "name"]
393  ];
394  l.forEach(a), !e.long0 && e.longc && (e.projName === "Albers_Conic_Equal_Area" || e.projName === "Lambert_Azimuthal_Equal_Area") && (e.long0 = e.longc), !e.lat_ts && e.lat1 && (e.projName === "Stereographic_South_Pole" || e.projName === "Polar Stereographic (variant B)") ? (e.lat0 = ei(e.lat1 > 0 ? 90 : -90), e.lat_ts = e.lat1) : !e.lat_ts && e.lat0 && e.projName === "Polar_Stereographic" && (e.lat_ts = e.lat0, e.lat0 = ei(e.lat0 >
394 0 ? 90 : -90));
395}
396function Ad(e) {
397  var t = Um(e), i = t.shift(), n = t.shift();
398  t.unshift(["name", n]), t.unshift(["type", i]);
399  var s = {};
400  return Qn(t, s), Ym(s), s;
401}
402function fe(e) {
403  var t = this;
404  if (arguments.length === 2) {
405    var i = arguments[1];
406    typeof i == "string" ? i.charAt(0) === "+" ? fe[e] = fl(arguments[1]) : fe[e] = Ad(arguments[1]) : fe[e] = i;
407  } else if (arguments.length === 1) {
408    if (Array.isArray(e))
409      return e.map(function(n) {
410        Array.isArray(n) ? fe.apply(t, n) : fe(n);
411      });
412    if (typeof e == "string") {
413      if (e in fe)
414        return fe[e];
415    } else
416      "EPSG" in e ? fe["EPSG:" + e.EPSG] = e : "ESRI" in e ? fe["ESRI:" + e.ESRI] = e : "IAU2000" in e && (fe["IAU2000:" + e.IAU2000] = e);
417    return;
418  }
419}
420Om(fe);
421function Km(e) {
422  return typeof e == "string";
423}
424function Vm(e) {
425  return e in fe;
426}
427var qm = ["PROJECTEDCRS", "PROJCRS", "GEOGCS", "GEOCCS", "PROJCS", "LOCAL_CS", "GEODCRS", "GEODETICCRS", "GEODETICDATUM", "ENGCRS", "ENGINEERINGCRS"];
428function Hm(e) {
429  return qm.some(function(t) {
430    return e.indexOf(t) > -1;
431  });
432}
433var Zm = ["3857", "900913", "3785", "102113"];
434function Jm(e) {
435  var t = tn(e, "authority");
436  if (t) {
437    var i = tn(t, "epsg");
438    return i && Zm.indexOf(i) > -1;
439  }
440}
441function Qm(e) {
442  var t = tn(e, "extension");
443  if (t)
444    return tn(t, "proj4");
445}
446function t_(e) {
447  return e[0] === "+";
448}
449function e_(e) {
450  if (Km(e)) {
451    if (Vm(e))
452      return fe[e];
453    if (Hm(e)) {
454      var t = Ad(e);
455      if (Jm(t))
456        return fe["EPSG:3857"];
457      var i = Qm(t);
458      return i ? fl(i) : t;
459    }
460    if (t_(e))
461      return fl(e);
462  } else
463    return e;
464}
465function Pc(e, t) {
466  e = e || {};
467  var i, n;
468  if (!t)
469    return e;
470  for (n in t)
471    i = t[n], i !== void 0 && (e[n] = i);
472  return e;
473}
474function di(e, t, i) {
475  var n = e * t;
476  return i / Math.sqrt(1 - n * n);
477}
478function Pr(e) {
479  return e < 0 ? -1 : 1;
480}
481function X(e) {
482  return Math.abs(e) <= Gt ? e : e - Pr(e) * cr;
483}
484function Ve(e, t, i) {
485  var n = e * i, s = 0.5 * e;
486  return n = Math.pow((1 - n) / (1 + n), s), Math.tan(0.5 * (A - t)) / n;
487}
488function dr(e, t) {
489  for (var i = 0.5 * e, n, s, r = A - 2 * Math.atan(t), o = 0; o <= 15; o++)
490    if (n = e * Math.sin(r), s = A - 2 * Math.atan(t * Math.pow((1 - n) / (1 + n), i)) - r, r += s, Math.abs(s) <= 1e-10)
491      return r;
492  return -9999;
493}
494function i_() {
495  var e = this.b / this.a;
496  this.es = 1 - e * e, "x0" in this || (this.x0 = 0), "y0" in this || (this.y0 = 0), this.e = Math.sqrt(this.es), this.lat_ts ? this.sphere ? this.k0 = Math.cos(this.lat_ts) : this.k0 = di(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) : this.k0 || (this.k ? this.k0 = this.k : this.k0 = 1);
497}
498function n_(e) {
499  var t = e.x, i = e.y;
500  if (i * Wi > 90 && i * Wi < -90 && t * Wi > 180 && t * Wi < -180)
501    return null;
502  var n, s;
503  if (Math.abs(Math.abs(i) - A) <= G)
504    return null;
505  if (this.sphere)
506    n = this.x0 + this.a * this.k0 * X(t - this.long0), s = this.y0 + this.a * this.k0 * Math.log(Math.tan(Et + 0.5 * i));
507  else {
508    var r = Math.sin(i), o = Ve(this.e, i, r);
509    n = this.x0 + this.a * this.k0 * X(t - this.long0), s = this.y0 - this.a * this.k0 * Math.log(o);
510  }
511  return e.x = n, e.y = s, e;
512}
513function s_(e) {
514  var t = e.x - this.x0, i = e.y - this.y0, n, s;
515  if (this.sphere)
516    s = A - 2 * Math.atan(Math.exp(-i / (this.a * this.k0)));
517  else {
518    var r = Math.exp(-i / (this.a * this.k0));
519    if (s = dr(this.e, r), s === -9999)
520      return null;
521  }
522  return n = X(this.long0 + t / (this.a * this.k0)), e.x = n, e.y = s, e;
523}
524var r_ = ["Mercator", "Popular Visualisation Pseudo Mercator", "Mercator_1SP", "Mercator_Auxiliary_Sphere", "merc"];
525const o_ = {
526  init: i_,
527  forward: n_,
528  inverse: s_,
529  names: r_
530};
531function a_() {
532}
533function Lc(e) {
534  return e;
535}
536var l_ = ["longlat", "identity"];
537const h_ = {
538  init: a_,
539  forward: Lc,
540  inverse: Lc,
541  names: l_
542};
543var c_ = [o_, h_], vo = {}, Ro = [];
544function Od(e, t) {
545  var i = Ro.length;
546  return e.names ? (Ro[i] = e, e.names.forEach(function(n) {
547    vo[n.toLowerCase()] = i;
548  }), this) : !0;
549}
550function u_(e) {
551  if (!e)
552    return !1;
553  var t = e.toLowerCase();
554  if (typeof vo[t] < "u" && Ro[vo[t]])
555    return Ro[vo[t]];
556}
557function d_() {
558  c_.forEach(Od);
559}
560const f_ = {
561  start: d_,
562  add: Od,
563  get: u_
564};
565var rt = {};
566rt.MERIT = {
567  a: 6378137,
568  rf: 298.257,
569  ellipseName: "MERIT 1983"
570};
571rt.SGS85 = {
572  a: 6378136,
573  rf: 298.257,
574  ellipseName: "Soviet Geodetic System 85"
575};
576rt.GRS80 = {
577  a: 6378137,
578  rf: 298.257222101,
579  ellipseName: "GRS 1980(IUGG, 1980)"
580};
581rt.IAU76 = {
582  a: 6378140,
583  rf: 298.257,
584  ellipseName: "IAU 1976"
585};
586rt.airy = {
587  a: 6377563396e-3,
588  b: 635625691e-2,
589  ellipseName: "Airy 1830"
590};
591rt.APL4 = {
592  a: 6378137,
593  rf: 298.25,
594  ellipseName: "Appl. Physics. 1965"
595};
596rt.NWL9D = {
597  a: 6378145,
598  rf: 298.25,
599  ellipseName: "Naval Weapons Lab., 1965"
600};
601rt.mod_airy = {
602  a: 6377340189e-3,
603  b: 6356034446e-3,
604  ellipseName: "Modified Airy"
605};
606rt.andrae = {
607  a: 637710443e-2,
608  rf: 300,
609  ellipseName: "Andrae 1876 (Den., Iclnd.)"
610};
611rt.aust_SA = {
612  a: 6378160,
613  rf: 298.25,
614  ellipseName: "Australian Natl & S. Amer. 1969"
615};
616rt.GRS67 = {
617  a: 6378160,
618  rf: 298.247167427,
619  ellipseName: "GRS 67(IUGG 1967)"
620};
621rt.bessel = {
622  a: 6377397155e-3,
623  rf: 299.1528128,
624  ellipseName: "Bessel 1841"
625};
626rt.bess_nam = {
627  a: 6377483865e-3,
628  rf: 299.1528128,
629  ellipseName: "Bessel 1841 (Namibia)"
630};
631rt.clrk66 = {
632  a: 63782064e-1,
633  b: 63565838e-1,
634  ellipseName: "Clarke 1866"
635};
636rt.clrk80 = {
637  a: 6378249145e-3,
638  rf: 293.4663,
639  ellipseName: "Clarke 1880 mod."
640};
641rt.clrk80ign = {
642  a: 63782492e-1,
643  b: 6356515,
644  rf: 293.4660213,
645  ellipseName: "Clarke 1880 (IGN)"
646};
647rt.clrk58 = {
648  a: 6378293645208759e-9,
649  rf: 294.2606763692654,
650  ellipseName: "Clarke 1858"
651};
652rt.CPM = {
653  a: 63757387e-1,
654  rf: 334.29,
655  ellipseName: "Comm. des Poids et Mesures 1799"
656};
657rt.delmbr = {
658  a: 6376428,
659  rf: 311.5,
660  ellipseName: "Delambre 1810 (Belgium)"
661};
662rt.engelis = {
663  a: 637813605e-2,
664  rf: 298.2566,
665  ellipseName: "Engelis 1985"
666};
667rt.evrst30 = {
668  a: 6377276345e-3,
669  rf: 300.8017,
670  ellipseName: "Everest 1830"
671};
672rt.evrst48 = {
673  a: 6377304063e-3,
674  rf: 300.8017,
675  ellipseName: "Everest 1948"
676};
677rt.evrst56 = {
678  a: 6377301243e-3,
679  rf: 300.8017,
680  ellipseName: "Everest 1956"
681};
682rt.evrst69 = {
683  a: 6377295664e-3,
684  rf: 300.8017,
685  ellipseName: "Everest 1969"
686};
687rt.evrstSS = {
688  a: 6377298556e-3,
689  rf: 300.8017,
690  ellipseName: "Everest (Sabah & Sarawak)"
691};
692rt.fschr60 = {
693  a: 6378166,
694  rf: 298.3,
695  ellipseName: "Fischer (Mercury Datum) 1960"
696};
697rt.fschr60m = {
698  a: 6378155,
699  rf: 298.3,
700  ellipseName: "Fischer 1960"
701};
702rt.fschr68 = {
703  a: 6378150,
704  rf: 298.3,
705  ellipseName: "Fischer 1968"
706};
707rt.helmert = {
708  a: 6378200,
709  rf: 298.3,
710  ellipseName: "Helmert 1906"
711};
712rt.hough = {
713  a: 6378270,
714  rf: 297,
715  ellipseName: "Hough"
716};
717rt.intl = {
718  a: 6378388,
719  rf: 297,
720  ellipseName: "International 1909 (Hayford)"
721};
722rt.kaula = {
723  a: 6378163,
724  rf: 298.24,
725  ellipseName: "Kaula 1961"
726};
727rt.lerch = {
728  a: 6378139,
729  rf: 298.257,
730  ellipseName: "Lerch 1979"
731};
732rt.mprts = {
733  a: 6397300,
734  rf: 191,
735  ellipseName: "Maupertius 1738"
736};
737rt.new_intl = {
738  a: 63781575e-1,
739  b: 63567722e-1,
740  ellipseName: "New International 1967"
741};
742rt.plessis = {
743  a: 6376523,
744  rf: 6355863,
745  ellipseName: "Plessis 1817 (France)"
746};
747rt.krass = {
748  a: 6378245,
749  rf: 298.3,
750  ellipseName: "Krassovsky, 1942"
751};
752rt.SEasia = {
753  a: 6378155,
754  b: 63567733205e-4,
755  ellipseName: "Southeast Asia"
756};
757rt.walbeck = {
758  a: 6376896,
759  b: 63558348467e-4,
760  ellipseName: "Walbeck"
761};
762rt.WGS60 = {
763  a: 6378165,
764  rf: 298.3,
765  ellipseName: "WGS 60"
766};
767rt.WGS66 = {
768  a: 6378145,
769  rf: 298.25,
770  ellipseName: "WGS 66"
771};
772rt.WGS7 = {
773  a: 6378135,
774  rf: 298.26,
775  ellipseName: "WGS 72"
776};
777var g_ = rt.WGS84 = {
778  a: 6378137,
779  rf: 298.257223563,
780  ellipseName: "WGS 84"
781};
782rt.sphere = {
783  a: 6370997,
784  b: 6370997,
785  ellipseName: "Normal Sphere (r=6370997)"
786};
787function m_(e, t, i, n) {
788  var s = e * e, r = t * t, o = (s - r) / s, a = 0;
789  n ? (e *= 1 - o * (Dm + o * (Nm + o * Gm)), s = e * e, o = 0) : a = Math.sqrt(o);
790  var l = (s - r) / r;
791  return {
792    es: o,
793    e: a,
794    ep2: l
795  };
796}
797function __(e, t, i, n, s) {
798  if (!e) {
799    var r = tn(rt, n);
800    r || (r = g_), e = r.a, t = r.b, i = r.rf;
801  }
802  return i && !t && (t = (1 - 1 / i) * e), (i === 0 || Math.abs(e - t) < G) && (s = !0, t = e), {
803    a: e,
804    b: t,
805    rf: i,
806    sphere: s
807  };
808}
809var Ht = {};
810Ht.wgs84 = {
811  towgs84: "0,0,0",
812  ellipse: "WGS84",
813  datumName: "WGS84"
814};
815Ht.ch1903 = {
816  towgs84: "674.374,15.056,405.346",
817  ellipse: "bessel",
818  datumName: "swiss"
819};
820Ht.ggrs87 = {
821  towgs84: "-199.87,74.79,246.62",
822  ellipse: "GRS80",
823  datumName: "Greek_Geodetic_Reference_System_1987"
824};
825Ht.nad83 = {
826  towgs84: "0,0,0",
827  ellipse: "GRS80",
828  datumName: "North_American_Datum_1983"
829};
830Ht.nad27 = {
831  nadgrids: "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",
832  ellipse: "clrk66",
833  datumName: "North_American_Datum_1927"
834};
835Ht.potsdam = {
836  towgs84: "598.1,73.7,418.2,0.202,0.045,-2.455,6.7",
837  ellipse: "bessel",
838  datumName: "Potsdam Rauenberg 1950 DHDN"
839};
840Ht.carthage = {
841  towgs84: "-263.0,6.0,431.0",
842  ellipse: "clark80",
843  datumName: "Carthage 1934 Tunisia"
844};
845Ht.hermannskogel = {
846  towgs84: "577.326,90.129,463.919,5.137,1.474,5.297,2.4232",
847  ellipse: "bessel",
848  datumName: "Hermannskogel"
849};
850Ht.osni52 = {
851  towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
852  ellipse: "airy",
853  datumName: "Irish National"
854};
855Ht.ire65 = {
856  towgs84: "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
857  ellipse: "mod_airy",
858  datumName: "Ireland 1965"
859};
860Ht.rassadiran = {
861  towgs84: "-133.63,-157.5,-158.62",
862  ellipse: "intl",
863  datumName: "Rassadiran"
864};
865Ht.nzgd49 = {
866  towgs84: "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
867  ellipse: "intl",
868  datumName: "New Zealand Geodetic Datum 1949"
869};
870Ht.osgb36 = {
871  towgs84: "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
872  ellipse: "airy",
873  datumName: "Airy 1830"
874};
875Ht.s_jtsk = {
876  towgs84: "589,76,480",
877  ellipse: "bessel",
878  datumName: "S-JTSK (Ferro)"
879};
880Ht.beduaram = {
881  towgs84: "-106,-87,188",
882  ellipse: "clrk80",
883  datumName: "Beduaram"
884};
885Ht.gunung_segara = {
886  towgs84: "-403,684,41",
887  ellipse: "bessel",
888  datumName: "Gunung Segara Jakarta"
889};
890Ht.rnb72 = {
891  towgs84: "106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",
892  ellipse: "intl",
893  datumName: "Reseau National Belge 1972"
894};
895function p_(e, t, i, n, s, r, o) {
896  var a = {};
897  return e === void 0 || e === "none" ? a.datum_type = dl : a.datum_type = Fm, t && (a.datum_params = t.map(parseFloat), (a.datum_params[0] !== 0 || a.datum_params[1] !== 0 || a.datum_params[2] !== 0) && (a.datum_type = Tn), a.datum_params.length > 3 && (a.datum_params[3] !== 0 || a.datum_params[4] !== 0 || a.datum_params[5] !== 0 || a.datum_params[6] !== 0) && (a.datum_type = In, a.datum_params[3] *= nr, a.datum_params[4] *= nr, a.datum_params[5] *= nr, a.datum_params[6] = a.datum_params[6] / 1e6 + 1)), o && (a.datum_type = ls, a.grids = o), a.a = i, a.b = n, a.es = s, a.ep2 = r, a;
898}
899var Fd = {};
900function y_(e, t) {
901  var i = new DataView(t), n = E_(i), s = C_(i, n);
902  s.nSubgrids > 1;
903  var r = M_(i, s, n), o = { header: s, subgrids: r };
904  return Fd[e] = o, o;
905}
906function x_(e) {
907  if (e === void 0)
908    return null;
909  var t = e.split(",");
910  return t.map(v_);
911}
912function v_(e) {
913  if (e.length === 0)
914    return null;
915  var t = e[0] === "@";
916  return t && (e = e.slice(1)), e === "null" ? { name: "null", mandatory: !t, grid: null, isNull: !0 } : {
917    name: e,
918    mandatory: !t,
919    grid: Fd[e] || null,
920    isNull: !1
921  };
922}
923function ts(e) {
924  return e / 3600 * Math.PI / 180;
925}
926function E_(e) {
927  var t = e.getInt32(8, !1);
928  return t === 11 ? !1 : (t = e.getInt32(8, !0), !0);
929}
930function C_(e, t) {
931  return {
932    nFields: e.getInt32(8, t),
933    nSubgridFields: e.getInt32(24, t),
934    nSubgrids: e.getInt32(40, t),
935    shiftType: gl(e, 56, 56 + 8).trim(),
936    fromSemiMajorAxis: e.getFloat64(120, t),
937    fromSemiMinorAxis: e.getFloat64(136, t),
938    toSemiMajorAxis: e.getFloat64(152, t),
939    toSemiMinorAxis: e.getFloat64(168, t)
940  };
941}
942function gl(e, t, i) {
943  return String.fromCharCode.apply(null, new Uint8Array(e.buffer.slice(t, i)));
944}
945function M_(e, t, i) {
946  for (var n = 176, s = [], r = 0; r < t.nSubgrids; r++) {
947    var o = w_(e, n, i), a = S_(e, n, o, i), l = Math.round(
948      1 + (o.upperLongitude - o.lowerLongitude) / o.longitudeInterval
949    ), h = Math.round(
950      1 + (o.upperLatitude - o.lowerLatitude) / o.latitudeInterval
951    );
952    s.push({
953      ll: [ts(o.lowerLongitude), ts(o.lowerLatitude)],
954      del: [ts(o.longitudeInterval), ts(o.latitudeInterval)],
955      lim: [l, h],
956      count: o.gridNodeCount,
957      cvs: b_(a)
958    });
959  }
960  return s;
961}
962function b_(e) {
963  return e.map(function(t) {
964    return [ts(t.longitudeShift), ts(t.latitudeShift)];
965  });
966}
967function w_(e, t, i) {
968  return {
969    name: gl(e, t + 8, t + 16).trim(),
970    parent: gl(e, t + 24, t + 24 + 8).trim(),
971    lowerLatitude: e.getFloat64(t + 72, i),
972    upperLatitude: e.getFloat64(t + 88, i),
973    lowerLongitude: e.getFloat64(t + 104, i),
974    upperLongitude: e.getFloat64(t + 120, i),
975    latitudeInterval: e.getFloat64(t + 136, i),
976    longitudeInterval: e.getFloat64(t + 152, i),
977    gridNodeCount: e.getInt32(t + 168, i)
978  };
979}
980function S_(e, t, i, n) {
981  for (var s = t + 176, r = 16, o = [], a = 0; a < i.gridNodeCount; a++) {
982    var l = {
983      latitudeShift: e.getFloat32(s + a * r, n),
984      longitudeShift: e.getFloat32(s + a * r + 4, n),
985      latitudeAccuracy: e.getFloat32(s + a * r + 8, n),
986      longitudeAccuracy: e.getFloat32(s + a * r + 12, n)
987    };
988    o.push(l);
989  }
990  return o;
991}
992function hi(e, t) {
993  if (!(this instanceof hi))
994    return new hi(e);
995  t = t || function(h) {
996    if (h)
997      throw h;
998  };
999  var i = e_(e);
1000  if (typeof i != "object") {
1001    t(e);
1002    return;
1003  }
1004  var n = hi.projections.get(i.projName);
1005  if (!n) {
1006    t(e);
1007    return;
1008  }
1009  if (i.datumCode && i.datumCode !== "none") {
1010    var s = tn(Ht, i.datumCode);
1011    s && (i.datum_params = i.datum_params || (s.towgs84 ? s.towgs84.split(",") : null), i.ellps = s.ellipse, i.datumName = s.datumName ? s.datumName : i.datumCode);
1012  }
vendor: 5,232 bytes, lines 1013-1160
1013  i.k0 = i.k0 || 1, i.axis = i.axis || "enu", i.ellps = i.ellps || "wgs84", i.lat1 = i.lat1 || i.lat0;
1014  var r = __(i.a, i.b, i.rf, i.ellps, i.sphere), o = m_(r.a, r.b, r.rf, i.R_A), a = x_(i.nadgrids), l = i.datum || p_(
1015    i.datumCode,
1016    i.datum_params,
1017    r.a,
1018    r.b,
1019    o.es,
1020    o.ep2,
1021    a
1022  );
1023  Pc(this, i), Pc(this, n), this.a = r.a, this.b = r.b, this.rf = r.rf, this.sphere = r.sphere, this.es = o.es, this.e = o.e, this.ep2 = o.ep2, this.datum = l, this.init(), t(null, this);
1024}
1025hi.projections = f_;
1026hi.projections.start();
1027function T_(e, t) {
1028  return e.datum_type !== t.datum_type || e.a !== t.a || Math.abs(e.es - t.es) > 5e-11 ? !1 : e.datum_type === Tn ? e.datum_params[0] === t.datum_params[0] && e.datum_params[1] === t.datum_params[1] && e.datum_params[2] === t.datum_params[2] : e.datum_type === In ? e.datum_params[0] === t.datum_params[0] && e.datum_params[1] === t.datum_params[1] && e.datum_params[2] === t.datum_params[2] && e.datum_params[3] === t.datum_params[3] && e.datum_params[4] === t.datum_params[4] && e.datum_params[5] === t.datum_params[5] && e.datum_params[6] === t.datum_params[6] : !0;
1029}
1030function kd(e, t, i) {
1031  var n = e.x, s = e.y, r = e.z ? e.z : 0, o, a, l, h;
1032  if (s < -A && s > -1.001 * A)
1033    s = -A;
1034  else if (s > A && s < 1.001 * A)
1035    s = A;
1036  else {
1037    if (s < -A)
1038      return { x: -1 / 0, y: -1 / 0, z: e.z };
1039    if (s > A)
1040      return { x: 1 / 0, y: 1 / 0, z: e.z };
1041  }
1042  return n > Math.PI && (n -= 2 * Math.PI), a = Math.sin(s), h = Math.cos(s), l = a * a, o = i / Math.sqrt(1 - t * l), {
1043    x: (o + r) * h * Math.cos(n),
1044    y: (o + r) * h * Math.sin(n),
1045    z: (o * (1 - t) + r) * a
1046  };
1047}
1048function Dd(e, t, i, n) {
1049  var s = 1e-12, r = s * s, o = 30, a, l, h, c, u, d, f, g, m, _, p, y, x, E = e.x, M = e.y, w = e.z ? e.z : 0, L, I, z;
1050  if (a = Math.sqrt(E * E + M * M), l = Math.sqrt(E * E + M * M + w * w), a / i < s) {
1051    if (L = 0, l / i < s)
1052      return I = A, z = -n, {
1053        x: e.x,
1054        y: e.y,
1055        z: e.z
1056      };
1057  } else
1058    L = Math.atan2(M, E);
1059  h = w / l, c = a / l, u = 1 / Math.sqrt(1 - t * (2 - t) * c * c), g = c * (1 - t) * u, m = h * u, x = 0;
1060  do
1061    x++, f = i / Math.sqrt(1 - t * m * m), z = a * g + w * m - f * (1 - t * m * m), d = t * f / (f + z), u = 1 / Math.sqrt(1 - d * (2 - d) * c * c), _ = c * (1 - d) * u, p = h * u, y = p * g - _ * m, g = _, m = p;
1062  while (y * y > r && x < o);
1063  return I = Math.atan(p / Math.abs(_)), {
1064    x: L,
1065    y: I,
1066    z
1067  };
1068}
1069function I_(e, t, i) {
1070  if (t === Tn)
1071    return {
1072      x: e.x + i[0],
1073      y: e.y + i[1],
1074      z: e.z + i[2]
1075    };
1076  if (t === In) {
1077    var n = i[0], s = i[1], r = i[2], o = i[3], a = i[4], l = i[5], h = i[6];
1078    return {
1079      x: h * (e.x - l * e.y + a * e.z) + n,
1080      y: h * (l * e.x + e.y - o * e.z) + s,
1081      z: h * (-a * e.x + o * e.y + e.z) + r
1082    };
1083  }
1084}
1085function R_(e, t, i) {
1086  if (t === Tn)
1087    return {
1088      x: e.x - i[0],
1089      y: e.y - i[1],
1090      z: e.z - i[2]
1091    };
1092  if (t === In) {
1093    var n = i[0], s = i[1], r = i[2], o = i[3], a = i[4], l = i[5], h = i[6], c = (e.x - n) / h, u = (e.y - s) / h, d = (e.z - r) / h;
1094    return {
1095      x: c + l * u - a * d,
1096      y: -l * c + u + o * d,
1097      z: a * c - o * u + d
1098    };
1099  }
1100}
1101function Vr(e) {
1102  return e === Tn || e === In;
1103}
1104function P_(e, t, i) {
1105  if (T_(e, t) || e.datum_type === dl || t.datum_type === dl)
1106    return i;
1107  var n = e.a, s = e.es;
1108  if (e.datum_type === ls) {
1109    var r = Ac(e, !1, i);
1110    if (r !== 0)
1111      return;
1112    n = Sc, s = Tc;
1113  }
1114  var o = t.a, a = t.b, l = t.es;
1115  if (t.datum_type === ls && (o = Sc, a = km, l = Tc), s === l && n === o && !Vr(e.datum_type) && !Vr(t.datum_type))
1116    return i;
1117  if (i = kd(i, s, n), Vr(e.datum_type) && (i = I_(i, e.datum_type, e.datum_params)), Vr(t.datum_type) && (i = R_(i, t.datum_type, t.datum_params)), i = Dd(i, l, o, a), t.datum_type === ls) {
1118    var h = Ac(t, !0, i);
1119    if (h !== 0)
1120      return;
1121  }
1122  return i;
1123}
1124function Ac(e, t, i) {
1125  if (e.grids === null || e.grids.length === 0)
1126    return -1;
1127  for (var n = { x: -i.x, y: i.y }, s = { x: Number.NaN, y: Number.NaN }, r = [], o = 0; o < e.grids.length; o++) {
1128    var a = e.grids[o];
1129    if (r.push(a.name), a.isNull) {
1130      s = n;
1131      break;
1132    }
1133    if (a.mandatory, a.grid === null) {
1134      if (a.mandatory)
1135        return -1;
1136      continue;
1137    }
1138    var l = a.grid.subgrids[0], h = (Math.abs(l.del[1]) + Math.abs(l.del[0])) / 1e4, c = l.ll[0] - h, u = l.ll[1] - h, d = l.ll[0] + (l.lim[0] - 1) * l.del[0] + h, f = l.ll[1] + (l.lim[1] - 1) * l.del[1] + h;
1139    if (!(u > n.y || c > n.x || f < n.y || d < n.x) && (s = L_(n, t, l), !isNaN(s.x)))
1140      break;
1141  }
1142  return isNaN(s.x) ? -1 : (i.x = -s.x, i.y = s.y, 0);
1143}
1144function L_(e, t, i) {
1145  var n = { x: Number.NaN, y: Number.NaN };
1146  if (isNaN(e.x))
1147    return n;
1148  var s = { x: e.x, y: e.y };
1149  s.x -= i.ll[0], s.y -= i.ll[1], s.x = X(s.x - Math.PI) + Math.PI;
1150  var r = Oc(s, i);
1151  if (t) {
1152    if (isNaN(r.x))
1153      return n;
1154    r.x = s.x - r.x, r.y = s.y - r.y;
1155    var o = 9, a = 1e-12, l, h;
1156    do {
1157      if (h = Oc(r, i), isNaN(h.x))
1158        break;
1159      l = { x: s.x - (h.x + r.x), y: s.y - (h.y + r.y) }, r.x += l.x, r.y += l.y;
1160    } while (o-- && Math.abs(l.x) >
1160 a && Math.abs(l.y) > a);
1161    if (o < 0)
1162      return n;
1163    n.x = X(r.x + i.ll[0]), n.y = r.y + i.ll[1];
1164  } else
1165    isNaN(r.x) || (n.x = e.x + r.x, n.y = e.y + r.y);
1166  return n;
1167}
1168function Oc(e, t) {
1169  var i = { x: e.x / t.del[0], y: e.y / t.del[1] }, n = { x: Math.floor(i.x), y: Math.floor(i.y) }, s = { x: i.x - 1 * n.x, y: i.y - 1 * n.y }, r = { x: Number.NaN, y: Number.NaN }, o;
1170  if (n.x < 0 || n.x >= t.lim[0] || n.y < 0 || n.y >= t.lim[1])
1171    return r;
1172  o = n.y * t.lim[0] + n.x;
1173  var a = { x: t.cvs[o][0], y: t.cvs[o][1] };
1174  o++;
1175  var l = { x: t.cvs[o][0], y: t.cvs[o][1] };
1176  o += t.lim[0];
1177  var h = { x: t.cvs[o][0], y: t.cvs[o][1] };
1178  o--;
1179  var c = { x: t.cvs[o][0], y: t.cvs[o][1] }, u = s.x * s.y, d = s.x * (1 - s.y), f = (1 - s.x) * (1 - s.y), g = (1 - s.x) * s.y;
1180  return r.x = f * a.x + d * l.x + g * c.x + u * h.x, r.y = f * a.y + d * l.y + g * c.y + u * h.y, r;
1181}
1182function Fc(e, t, i) {
1183  var n = i.x, s = i.y, r = i.z || 0, o, a, l, h = {};
1184  for (l = 0; l < 3; l++)
1185    if (!(t && l === 2 && i.z === void 0))
1186      switch (l === 0 ? (o = n, "ew".indexOf(e.axis[l]) !== -1 ? a = "x" : a = "y") : l === 1 ? (o = s, "ns".indexOf(e.axis[l]) !== -1 ? a = "y" : a = "x") : (o = r, a = "z"), e.axis[l]) {
1187        case "e":
1188          h[a] = o;
1189          break;
1190        case "w":
1191          h[a] = -o;
1192          break;
1193        case "n":
1194          h[a] = o;
1195          break;
1196        case "s":
1197          h[a] = -o;
1198          break;
1199        case "u":
1200          i[a] !== void 0 && (h.z = o);
1201          break;
1202        case "d":
1203          i[a] !== void 0 && (h.z = -o);
1204          break;
1205        default:
1206          return null;
1207      }
1208  return h;
1209}
1210function Nd(e) {
1211  var t = {
1212    x: e[0],
1213    y: e[1]
1214  };
1215  return e.length > 2 && (t.z = e[2]), e.length > 3 && (t.m = e[3]), t;
1216}
1217function A_(e) {
1218  kc(e.x), kc(e.y);
1219}
1220function kc(e) {
1221  if (typeof Number.isFinite == "function") {
1222    if (Number.isFinite(e))
1223      return;
1224    throw new TypeError("coordinates must be finite numbers");
1225  }
1226  if (typeof e != "number" || e !== e || !isFinite(e))
1227    throw new TypeError("coordinates must be finite numbers");
1228}
1229function O_(e, t) {
1230  return (e.datum.datum_type === Tn || e.datum.datum_type === In || e.datum.datum_type === ls) && t.datumCode !== "WGS84" || (t.datum.datum_type === Tn || t.datum.datum_type === In || t.datum.datum_type === ls) && e.datumCode !== "WGS84";
1231}
1232function Po(e, t, i, n) {
1233  var s;
1234  Array.isArray(i) ? i = Nd(i) : i = {
1235    x: i.x,
1236    y: i.y,
1237    z: i.z,
1238    m: i.m
1239  };
1240  var r = i.z !== void 0;
1241  if (A_(i), e.datum && t.datum && O_(e, t) && (s = new hi("WGS84"), i = Po(e, s, i, n), e = s), n && e.axis !== "enu" && (i = Fc(e, !1, i)), e.projName === "longlat")
1242    i = {
1243      x: i.x * Zt,
1244      y: i.y * Zt,
1245      z: i.z || 0
1246    };
1247  else if (e.to_meter && (i = {
1248    x: i.x * e.to_meter,
1249    y: i.y * e.to_meter,
1250    z: i.z || 0
1251  }), i = e.inverse(i), !i)
1252    return;
1253  if (e.from_greenwich && (i.x += e.from_greenwich), i = P_(e.datum, t.datum, i), !!i)
1254    return t.from_greenwich && (i = {
1255      x: i.x - t.from_greenwich,
1256      y: i.y,
1257      z: i.z || 0
1258    }), t.projName === "longlat" ? i = {
1259      x: i.x * Wi,
1260      y: i.y * Wi,
1261      z: i.z || 0
1262    } : (i = t.forward(i), t.to_meter && (i = {
1263      x: i.x / t.to_meter,
1264      y: i.y / t.to_meter,
1265      z: i.z || 0
1266    })), n && t.axis !== "enu" ? Fc(t, !0, i) : (r || delete i.z, i);
1267}
1268var Dc = hi("WGS84");
1269function Aa(e, t, i, n) {
1270  var s, r, o;
1271  return Array.isArray(i) ? (s = Po(e, t, i, n) || { x: NaN, y: NaN }, i.length > 2 ? typeof e.name < "u" && e.name === "geocent" || typeof t.name < "u" && t.name === "geocent" ? typeof s.z == "number" ? [s.x, s.y, s.z].concat(i.splice(3)) : [s.x, s.y, i[2]].concat(i.splice(3)) : [s.x, s.y].concat(i.splice(2)) : [s.x, s.y]) : (r = Po(e, t, i, n), o = Object.keys(i), o.length === 2 || o.forEach(function(a) {
1272    if (typeof e.name < "u" && e.name === "geocent" || typeof t.name < "u" && t.name === "geocent") {
1273      if (a === "x" || a === "y" || a === "z")
1274        return;
1275    } else if (a === "x" || a === "y")
1276      return;
1277    r[a] = i[a];
1278  }), r);
1279}
1280function Nc(e) {
1281  return e instanceof hi ? e : e.oProj ? e.oProj : hi(e);
1282}
1283function Me(e, t, i) {
1284  e = Nc(e);
1285  var n = !1, s;
1286  return typeof t > "u" ? (t = e, e = Dc, n = !0) : (typeof t.x < "u" || Array.isArray(t)) && (i = t, t = e, e = Dc, n = !0), t = Nc(t), i ? Aa(e, t, i) : (s = {
1287    forward: function(r, o) {
1288      return Aa(e, t, r, o);
1289    },
1290    inverse: function(r, o) {
1291      return Aa(t, e, r, o);
1292    }
1293  }, n && (s.oProj = t), s);
1294}
1295var Gc = 6, Gd = "AJSAJS", zd = "AFAFAF", es = 65, xe = 73, Fe = 79, Hs = 86, Zs = 90;
1296const F_ = {
1297  forward: jd,
1298  inverse: k_,
1299  toPoint: Wd
1300};
vendor: 60,669 bytes, lines 1301-2433
1301function jd(e, t) {
1302  return t = t || 5, G_(D_({
1303    lat: e[1],
1304    lon: e[0]
1305  }), t);
1306}
1307function k_(e) {
1308  var t = Ql(Ud(e.toUpperCase()));
1309  return t.lat && t.lon ? [t.lon, t.lat, t.lon, t.lat] : [t.left, t.bottom, t.right, t.top];
1310}
1311function Wd(e) {
1312  var t = Ql(Ud(e.toUpperCase()));
1313  return t.lat && t.lon ? [t.lon, t.lat] : [(t.left + t.right) / 2, (t.top + t.bottom) / 2];
1314}
1315function Oa(e) {
1316  return e * (Math.PI / 180);
1317}
1318function zc(e) {
1319  return 180 * (e / Math.PI);
1320}
1321function D_(e) {
1322  var t = e.lat, i = e.lon, n = 6378137, s = 669438e-8, r = 0.9996, o, a, l, h, c, u, d, f = Oa(t), g = Oa(i), m, _;
1323  _ = Math.floor((i + 180) / 6) + 1, i === 180 && (_ = 60), t >= 56 && t < 64 && i >= 3 && i < 12 && (_ = 32), t >= 72 && t < 84 && (i >= 0 && i < 9 ? _ = 31 : i >= 9 && i < 21 ? _ = 33 : i >= 21 && i < 33 ? _ = 35 : i >= 33 && i < 42 && (_ = 37)), o = (_ - 1) * 6 - 180 + 3, m = Oa(o), a = s / (1 - s), l = n / Math.sqrt(1 - s * Math.sin(f) * Math.sin(f)), h = Math.tan(f) * Math.tan(f), c = a * Math.cos(f) * Math.cos(f), u = Math.cos(f) * (g - m), d = n * ((1 - s / 4 - 3 * s * s / 64 - 5 * s * s * s / 256) * f - (3 * s / 8 + 3 * s * s / 32 + 45 * s * s * s / 1024) * Math.sin(2 * f) + (15 * s * s / 256 + 45 * s * s * s / 1024) * Math.sin(4 * f) - 35 * s * s * s / 3072 * Math.sin(6 * f));
1324  var p = r * l * (u + (1 - h + c) * u * u * u / 6 + (5 - 18 * h + h * h + 72 * c - 58 * a) * u * u * u * u * u / 120) + 5e5, y = r * (d + l * Math.tan(f) * (u * u / 2 + (5 - h + 9 * c + 4 * c * c) * u * u * u * u / 24 + (61 - 58 * h + h * h + 600 * c - 330 * a) * u * u * u * u * u * u / 720));
1325  return t < 0 && (y += 1e7), {
1326    northing: Math.round(y),
1327    easting: Math.round(p),
1328    zoneNumber: _,
1329    zoneLetter: N_(t)
1330  };
1331}
1332function Ql(e) {
1333  var t = e.northing, i = e.easting, n = e.zoneLetter, s = e.zoneNumber;
1334  if (s < 0 || s > 60)
1335    return null;
1336  var r = 0.9996, o = 6378137, a = 669438e-8, l, h = (1 - Math.sqrt(1 - a)) / (1 + Math.sqrt(1 - a)), c, u, d, f, g, m, _, p, y, x = i - 5e5, E = t;
1337  n < "N" && (E -= 1e7), _ = (s - 1) * 6 - 180 + 3, l = a / (1 - a), m = E / r, p = m / (o * (1 - a / 4 - 3 * a * a / 64 - 5 * a * a * a / 256)), y = p + (3 * h / 2 - 27 * h * h * h / 32) * Math.sin(2 * p) + (21 * h * h / 16 - 55 * h * h * h * h / 32) * Math.sin(4 * p) + 151 * h * h * h / 96 * Math.sin(6 * p), c = o / Math.sqrt(1 - a * Math.sin(y) * Math.sin(y)), u = Math.tan(y) * Math.tan(y), d = l * Math.cos(y) * Math.cos(y), f = o * (1 - a) / Math.pow(1 - a * Math.sin(y) * Math.sin(y), 1.5), g = x / (c * r);
1338  var M = y - c * Math.tan(y) / f * (g * g / 2 - (5 + 3 * u + 10 * d - 4 * d * d - 9 * l) * g * g * g * g / 24 + (61 + 90 * u + 298 * d + 45 * u * u - 252 * l - 3 * d * d) * g * g * g * g * g * g / 720);
1339  M = zc(M);
1340  var w = (g - (1 + 2 * u + d) * g * g * g / 6 + (5 - 2 * d + 28 * u - 3 * d * d + 8 * l + 24 * u * u) * g * g * g * g * g / 120) / Math.cos(y);
1341  w = _ + zc(w);
1342  var L;
1343  if (e.accuracy) {
1344    var I = Ql({
1345      northing: e.northing + e.accuracy,
1346      easting: e.easting + e.accuracy,
1347      zoneLetter: e.zoneLetter,
1348      zoneNumber: e.zoneNumber
1349    });
1350    L = {
1351      top: I.lat,
1352      right: I.lon,
1353      bottom: M,
1354      left: w
1355    };
1356  } else
1357    L = {
1358      lat: M,
1359      lon: w
1360    };
1361  return L;
1362}
1363function N_(e) {
1364  var t = "Z";
1365  return 84 >= e && e >= 72 ? t = "X" : 72 > e && e >= 64 ? t = "W" : 64 > e && e >= 56 ? t = "V" : 56 > e && e >= 48 ? t = "U" : 48 > e && e >= 40 ? t = "T" : 40 > e && e >= 32 ? t = "S" : 32 > e && e >= 24 ? t = "R" : 24 > e && e >= 16 ? t = "Q" : 16 > e && e >= 8 ? t = "P" : 8 > e && e >= 0 ? t = "N" : 0 > e && e >= -8 ? t = "M" : -8 > e && e >= -16 ? t = "L" : -16 > e && e >= -24 ? t = "K" : -24 > e && e >= -32 ? t = "J" : -32 > e && e >= -40 ? t = "H" : -40 > e && e >= -48 ? t = "G" : -48 > e && e >= -56 ? t = "F" : -56 > e && e >= -64 ? t = "E" : -64 > e && e >= -72 ? t = "D" : -72 > e && e >= -80 && (t = "C"), t;
1366}
1367function G_(e, t) {
1368  var i = "00000" + e.easting, n = "00000" + e.northing;
1369  return e.zoneNumber + e.zoneLetter + z_(e.easting, e.northing, e.zoneNumber) + i.substr(i.length - 5, t) + n.substr(n.length - 5, t);
1370}
1371function z_(e, t, i) {
1372  var n = Bd(i), s = Math.floor(e / 1e5), r = Math.floor(t / 1e5) % 20;
1373  return j_(s, r, n);
1374}
1375function Bd(e) {
1376  var t = e % Gc;
1377  return t === 0 && (t = Gc), t;
1378}
1379function j_(e, t, i) {
1380  var n = i - 1, s = Gd.charCodeAt(n), r = zd.charCodeAt(n), o = s + e - 1, a = r + t, l = !1;
1381  o > Zs && (o = o - Zs + es - 1, l = !0), (o === xe || s < xe && o > xe || (o > xe || s < xe) && l) && o++, (o === Fe || s < Fe && o > Fe || (o > Fe || s < Fe) && l) && (o++, o === xe && o++), o > Zs && (o = o - Zs + es - 1), a > Hs ? (a = a - Hs + es - 1, l = !0) : l = !1, (a === xe || r < xe && a > xe || (a > xe || r < xe) && l) && a++, (a === Fe || r < Fe && a > Fe || (a > Fe || r < Fe) && l) && (a++, a === xe && a++), a > Hs && (a = a - Hs + es - 1);
1382  var h = String.fromCharCode(o) + String.fromCharCode(a);
1383  return h;
1384}
1385function Ud(e) {
1386  if (e && e.length === 0)
1387    throw "MGRSPoint coverting from nothing";
1388  for (var t = e.length, i = null, n = "", s, r = 0; !/[A-Z]/.test(s = e.charAt(r)); ) {
1389    if (r >= 2)
1390      throw "MGRSPoint bad conversion from: " + e;
1391    n += s, r++;
1392  }
1393  var o = parseInt(n, 10);
1394  if (r === 0 || r + 3 > t)
1395    throw "MGRSPoint bad conversion from: " + e;
1396  var a = e.charAt(r++);
1397  if (a <= "A" || a === "B" || a === "Y" || a >= "Z" || a === "I" || a === "O")
1398    throw "MGRSPoint zone letter " + a + " not handled: " + e;
1399  i = e.substring(r, r += 2);
1400  for (var l = Bd(o), h = W_(i.charAt(0), l), c = B_(i.charAt(1), l); c < U_(a); )
1401    c += 2e6;
1402  var u = t - r;
1403  if (u % 2 !== 0)
1404    throw `MGRSPoint has to have an even number 
1405of digits after the zone letter and two 100km letters - front 
1406half for easting meters, second half for 
1407northing meters` + e;
1408  var d = u / 2, f = 0, g = 0, m, _, p, y, x;
1409  return d > 0 && (m = 1e5 / Math.pow(10, d), _ = e.substring(r, r + d), f = parseFloat(_) * m, p = e.substring(r + d), g = parseFloat(p) * m), y = f + h, x = g + c, {
1410    easting: y,
1411    northing: x,
1412    zoneLetter: a,
1413    zoneNumber: o,
1414    accuracy: m
1415  };
1416}
1417function W_(e, t) {
1418  for (var i = Gd.charCodeAt(t - 1), n = 1e5, s = !1; i !== e.charCodeAt(0); ) {
1419    if (i++, i === xe && i++, i === Fe && i++, i > Zs) {
1420      if (s)
1421        throw "Bad character: " + e;
1422      i = es, s = !0;
1423    }
1424    n += 1e5;
1425  }
1426  return n;
1427}
1428function B_(e, t) {
1429  if (e > "V")
1430    throw "MGRSPoint given invalid Northing " + e;
1431  for (var i = zd.charCodeAt(t - 1), n = 0, s = !1; i !== e.charCodeAt(0); ) {
1432    if (i++, i === xe && i++, i === Fe && i++, i > Hs) {
1433      if (s)
1434        throw "Bad character: " + e;
1435      i = es, s = !0;
1436    }
1437    n += 1e5;
1438  }
1439  return n;
1440}
1441function U_(e) {
1442  var t;
1443  switch (e) {
1444    case "C":
1445      t = 11e5;
1446      break;
1447    case "D":
1448      t = 2e6;
1449      break;
1450    case "E":
1451      t = 28e5;
1452      break;
1453    case "F":
1454      t = 37e5;
1455      break;
1456    case "G":
1457      t = 46e5;
1458      break;
1459    case "H":
1460      t = 55e5;
1461      break;
1462    case "J":
1463      t = 64e5;
1464      break;
1465    case "K":
1466      t = 73e5;
1467      break;
1468    case "L":
1469      t = 82e5;
1470      break;
1471    case "M":
1472      t = 91e5;
1473      break;
1474    case "N":
1475      t = 0;
1476      break;
1477    case "P":
1478      t = 8e5;
1479      break;
1480    case "Q":
1481      t = 17e5;
1482      break;
1483    case "R":
1484      t = 26e5;
1485      break;
1486    case "S":
1487      t = 35e5;
1488      break;
1489    case "T":
1490      t = 44e5;
1491      break;
1492    case "U":
1493      t = 53e5;
1494      break;
1495    case "V":
1496      t = 62e5;
1497      break;
1498    case "W":
1499      t = 7e6;
1500      break;
1501    case "X":
1502      t = 79e5;
1503      break;
1504    default:
1505      t = -1;
1506  }
1507  if (t >= 0)
1508    return t;
1509  throw "Invalid zone letter: " + e;
1510}
1511function Cs(e, t, i) {
1512  if (!(this instanceof Cs))
1513    return new Cs(e, t, i);
1514  if (Array.isArray(e))
1515    this.x = e[0], this.y = e[1], this.z = e[2] || 0;
1516  else if (typeof e == "object")
1517    this.x = e.x, this.y = e.y, this.z = e.z || 0;
1518  else if (typeof e == "string" && typeof t > "u") {
1519    var n = e.split(",");
1520    this.x = parseFloat(n[0], 10), this.y = parseFloat(n[1], 10), this.z = parseFloat(n[2], 10) || 0;
1521  } else
1522    this.x = e, this.y = t, this.z = i || 0;
1523}
1524Cs.fromMGRS = function(e) {
1525  return new Cs(Wd(e));
1526};
1527Cs.prototype.toMGRS = function(e) {
1528  return jd([this.x, this.y], e);
1529};
1530var X_ = 1, $_ = 0.25, jc = 0.046875, Wc = 0.01953125, Bc = 0.01068115234375, Y_ = 0.75, K_ = 0.46875, V_ = 0.013020833333333334, q_ = 0.007120768229166667, H_ = 0.3645833333333333, Z_ = 0.005696614583333333, J_ = 0.3076171875;
1531function Xd(e) {
1532  var t = [];
1533  t[0] = X_ - e * ($_ + e * (jc + e * (Wc + e * Bc))), t[1] = e * (Y_ - e * (jc + e * (Wc + e * Bc)));
1534  var i = e * e;
1535  return t[2] = i * (K_ - e * (V_ + e * q_)), i *= e, t[3] = i * (H_ - e * Z_), t[4] = i * e * J_, t;
1536}
1537function na(e, t, i, n) {
1538  return i *= t, t *= t, n[0] * e - i * (n[1] + t * (n[2] + t * (n[3] + t * n[4])));
1539}
1540var Q_ = 20;
1541function $d(e, t, i) {
1542  for (var n = 1 / (1 - t), s = e, r = Q_; r; --r) {
1543    var o = Math.sin(s), a = 1 - t * o * o;
1544    if (a = (na(s, o, Math.cos(s), i) - e) * (a * Math.sqrt(a)) * n, s -= a, Math.abs(a) < G)
1545      return s;
1546  }
1547  return s;
1548}
1549function t0() {
1550  this.x0 = this.x0 !== void 0 ? this.x0 : 0, this.y0 = this.y0 !== void 0 ? this.y0 : 0, this.long0 = this.long0 !== void 0 ? this.long0 : 0, this.lat0 = this.lat0 !== void 0 ? this.lat0 : 0, this.es && (this.en = Xd(this.es), this.ml0 = na(this.lat0, Math.sin(this.lat0), Math.cos(this.lat0), this.en));
1551}
1552function e0(e) {
1553  var t = e.x, i = e.y, n = X(t - this.long0), s, r, o, a = Math.sin(i), l = Math.cos(i);
1554  if (this.es) {
1555    var c = l * n, u = Math.pow(c, 2), d = this.ep2 * Math.pow(l, 2), f = Math.pow(d, 2), g = Math.abs(l) > G ? Math.tan(i) : 0, m = Math.pow(g, 2), _ = Math.pow(m, 2);
1556    s = 1 - this.es * Math.pow(a, 2), c = c / Math.sqrt(s);
1557    var p = na(i, a, l, this.en);
1558    r = this.a * (this.k0 * c * (1 + u / 6 * (1 - m + d + u / 20 * (5 - 18 * m + _ + 14 * d - 58 * m * d + u / 42 * (61 + 179 * _ - _ * m - 479 * m))))) + this.x0, o = this.a * (this.k0 * (p - this.ml0 + a * n * c / 2 * (1 + u / 12 * (5 - m + 9 * d + 4 * f + u / 30 * (61 + _ - 58 * m + 270 * d - 330 * m * d + u / 56 * (1385 + 543 * _ - _ * m - 3111 * m)))))) + this.y0;
1559  } else {
1560    var h = l * Math.sin(n);
1561    if (Math.abs(Math.abs(h) - 1) < G)
1562      return 93;
1563    if (r = 0.5 * this.a * this.k0 * Math.log((1 + h) / (1 - h)) + this.x0, o = l * Math.cos(n) / Math.sqrt(1 - Math.pow(h, 2)), h = Math.abs(o), h >= 1) {
1564      if (h - 1 > G)
1565        return 93;
1566      o = 0;
1567    } else
1568      o = Math.acos(o);
1569    i < 0 && (o = -o), o = this.a * this.k0 * (o - this.lat0) + this.y0;
1570  }
1571  return e.x = r, e.y = o, e;
1572}
1573function i0(e) {
1574  var t, i, n, s, r = (e.x - this.x0) * (1 / this.a), o = (e.y - this.y0) * (1 / this.a);
1575  if (this.es)
1576    if (t = this.ml0 + o / this.k0, i = $d(t, this.es, this.en), Math.abs(i) < A) {
1577      var u = Math.sin(i), d = Math.cos(i), f = Math.abs(d) > G ? Math.tan(i) : 0, g = this.ep2 * Math.pow(d, 2), m = Math.pow(g, 2), _ = Math.pow(f, 2), p = Math.pow(_, 2);
1578      t = 1 - this.es * Math.pow(u, 2);
1579      var y = r * Math.sqrt(t) / this.k0, x = Math.pow(y, 2);
1580      t = t * f, n = i - t * x / (1 - this.es) * 0.5 * (1 - x / 12 * (5 + 3 * _ - 9 * g * _ + g - 4 * m - x / 30 * (61 + 90 * _ - 252 * g * _ + 45 * p + 46 * g - x / 56 * (1385 + 3633 * _ + 4095 * p + 1574 * p * _)))), s = X(this.long0 + y * (1 - x / 6 * (1 + 2 * _ + g - x / 20 * (5 + 28 * _ + 24 * p + 8 * g * _ + 6 * g - x / 42 * (61 + 662 * _ + 1320 * p + 720 * p * _)))) / d);
1581    } else
1582      n = A * Pr(o), s = 0;
1583  else {
1584    var a = Math.exp(r / this.k0), l = 0.5 * (a - 1 / a), h = this.lat0 + o / this.k0, c = Math.cos(h);
1585    t = Math.sqrt((1 - Math.pow(c, 2)) / (1 + Math.pow(l, 2))), n = Math.asin(t), o < 0 && (n = -n), l === 0 && c === 0 ? s = 0 : s = X(Math.atan2(l, c) + this.long0);
1586  }
1587  return e.x = s, e.y = n, e;
1588}
1589var n0 = ["Fast_Transverse_Mercator", "Fast Transverse Mercator"];
1590const Eo = {
1591  init: t0,
1592  forward: e0,
1593  inverse: i0,
1594  names: n0
1595};
1596function Yd(e) {
1597  var t = Math.exp(e);
1598  return t = (t - 1 / t) / 2, t;
1599}
1600function We(e, t) {
1601  e = Math.abs(e), t = Math.abs(t);
1602  var i = Math.max(e, t), n = Math.min(e, t) / (i || 1);
1603  return i * Math.sqrt(1 + Math.pow(n, 2));
1604}
1605function s0(e) {
1606  var t = 1 + e, i = t - 1;
1607  return i === 0 ? e : e * Math.log(t) / i;
1608}
1609function r0(e) {
1610  var t = Math.abs(e);
1611  return t = s0(t * (1 + t / (We(1, t) + 1))), e < 0 ? -t : t;
1612}
1613function th(e, t) {
1614  for (var i = 2 * Math.cos(2 * t), n = e.length - 1, s = e[n], r = 0, o; --n >= 0; )
1615    o = -r + i * s + e[n], r = s, s = o;
1616  return t + o * Math.sin(2 * t);
1617}
1618function o0(e, t) {
1619  for (var i = 2 * Math.cos(t), n = e.length - 1, s = e[n], r = 0, o; --n >= 0; )
1620    o = -r + i * s + e[n], r = s, s = o;
1621  return Math.sin(t) * o;
1622}
1623function a0(e) {
1624  var t = Math.exp(e);
1625  return t = (t + 1 / t) / 2, t;
1626}
1627function Kd(e, t, i) {
1628  for (var n = Math.sin(t), s = Math.cos(t), r = Yd(i), o = a0(i), a = 2 * s * o, l = -2 * n * r, h = e.length - 1, c = e[h], u = 0, d = 0, f = 0, g, m; --h >= 0; )
1629    g = d, m = u, d = c, u = f, c = -g + a * d - l * u + e[h], f = -m + l * d + a * u;
1630  return a = n * o, l = s * r, [a * c - l * f, a * f + l * c];
1631}
1632function l0() {
1633  if (!this.approx && (isNaN(this.es) || this.es <= 0))
1634    throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');
1635  this.approx && (Eo.init.apply(this), this.forward = Eo.forward, this.inverse = Eo.inverse), this.x0 = this.x0 !== void 0 ? this.x0 : 0, this.y0 = this.y0 !== void 0 ? this.y0 : 0, this.long0 = this.long0 !== void 0 ? this.long0 : 0, this.lat0 = this.lat0 !== void 0 ? this.lat0 : 0, this.cgb = [], this.cbg = [], this.utg = [], this.gtu = [];
1636  var e = this.es / (1 + Math.sqrt(1 - this.es)), t = e / (2 - e), i = t;
1637  this.cgb[0] = t * (2 + t * (-2 / 3 + t * (-2 + t * (116 / 45 + t * (26 / 45 + t * (-2854 / 675)))))), this.cbg[0] = t * (-2 + t * (2 / 3 + t * (4 / 3 + t * (-82 / 45 + t * (32 / 45 + t * (4642 / 4725)))))), i = i * t, this.cgb[1] = i * (7 / 3 + t * (-8 / 5 + t * (-227 / 45 + t * (2704 / 315 + t * (2323 / 945))))), this.cbg[1] = i * (5 / 3 + t * (-16 / 15 + t * (-13 / 9 + t * (904 / 315 + t * (-1522 / 945))))), i = i * t, this.cgb[2] = i * (56 / 15 + t * (-136 / 35 + t * (-1262 / 105 + t * (73814 / 2835)))), this.cbg[2] = i * (-26 / 15 + t * (34 / 21 + t * (8 / 5 + t * (-12686 / 2835)))), i = i * t, this.cgb[3] = i * (4279 / 630 + t * (-332 / 35 + t * (-399572 / 14175))), this.cbg[3] = i * (1237 / 630 + t * (-12 / 5 + t * (-24832 / 14175))), i = i * t, this.cgb[4] = i * (4174 / 315 + t * (-144838 / 6237)), this.cbg[4] = i * (-734 / 315 + t * (109598 / 31185)), i = i * t, this.cgb[5] = i * (601676 / 22275), this.cbg[5] = i * (444337 / 155925), i = Math.pow(t, 2), this.Qn = this.k0 / (1 + t) * (1 + i * (1 / 4 + i * (1 / 64 + i / 256))), this.utg[0] = t * (-0.5 + t * (2 / 3 + t * (-37 / 96 + t * (1 / 360 + t * (81 / 512 + t * (-96199 / 604800)))))), this.gtu[0] = t * (0.5 + t * (-2 / 3 + t * (5 / 16 + t * (41 / 180 + t * (-127 / 288 + t * (7891 / 37800)))))), this.utg[1] = i * (-1 / 48 + t * (-1 / 15 + t * (437 / 1440 + t * (-46 / 105 + t * (1118711 / 3870720))))), this.gtu[1] = i * (13 / 48 + t * (-3 / 5 + t * (557 / 1440 + t * (281 / 630 + t * (-1983433 / 1935360))))), i = i * t, this.utg[2] = i * (-17 / 480 + t * (37 / 840 + t * (209 / 4480 + t * (-5569 / 90720)))), this.gtu[2] = i * (61 / 240 + t * (-103 / 140 + t * (15061 / 26880 + t * (167603 / 181440)))), i = i * t, this.utg[3] = i * (-4397 / 161280 + t * (11 / 504 + t * (830251 / 7257600))), this.gtu[3] = i * (49561 / 161280 + t * (-179 / 168 + t * (6601661 / 7257600))), i = i * t, this.utg[4] = i * (-4583 / 161280 + t * (108847 / 3991680)), this.gtu[4] = i * (34729 / 80640 + t * (-3418889 / 1995840)), i = i * t, this.utg[5] = i * (-20648693 / 638668800), this.gtu[5] = i * (212378941 / 319334400);
1638  var n = th(this.cbg, this.lat0);
1639  this.Zb = -this.Qn * (n + o0(this.gtu, 2 * n));
1640}
1641function h0(e) {
1642  var t = X(e.x - this.long0), i = e.y;
1643  i = th(this.cbg, i);
1644  var n = Math.sin(i), s = Math.cos(i), r = Math.sin(t), o = Math.cos(t);
1645  i = Math.atan2(n, o * s), t = Math.atan2(r * s, We(n, s * o)), t = r0(Math.tan(t));
1646  var a = Kd(this.gtu, 2 * i, 2 * t);
1647  i = i + a[0], t = t + a[1];
1648  var l, h;
1649  return Math.abs(t) <= 2.623395162778 ? (l = this.a * (this.Qn * t) + this.x0, h = this.a * (this.Qn * i + this.Zb) + this.y0) : (l = 1 / 0, h = 1 / 0), e.x = l, e.y = h, e;
1650}
1651function c0(e) {
1652  var t = (e.x - this.x0) * (1 / this.a), i = (e.y - this.y0) * (1 / this.a);
1653  i = (i - this.Zb) / this.Qn, t = t / this.Qn;
1654  var n, s;
1655  if (Math.abs(t) <= 2.623395162778) {
1656    var r = Kd(this.utg, 2 * i, 2 * t);
1657    i = i + r[0], t = t + r[1], t = Math.atan(Yd(t));
1658    var o = Math.sin(i), a = Math.cos(i), l = Math.sin(t), h = Math.cos(t);
1659    i = Math.atan2(o * h, We(l, h * a)), t = Math.atan2(l, h * a), n = X(t + this.long0), s = th(this.cgb, i);
1660  } else
1661    n = 1 / 0, s = 1 / 0;
1662  return e.x = n, e.y = s, e;
1663}
1664var u0 = ["Extended_Transverse_Mercator", "Extended Transverse Mercator", "etmerc", "Transverse_Mercator", "Transverse Mercator", "tmerc"];
1665const Co = {
1666  init: l0,
1667  forward: h0,
1668  inverse: c0,
1669  names: u0
1670};
1671function d0(e, t) {
1672  if (e === void 0) {
1673    if (e = Math.floor((X(t) + Math.PI) * 30 / Math.PI) + 1, e < 0)
1674      return 0;
1675    if (e > 60)
1676      return 60;
1677  }
1678  return e;
1679}
1680var f0 = "etmerc";
1681function g0() {
1682  var e = d0(this.zone, this.long0);
1683  if (e === void 0)
1684    throw new Error("unknown utm zone");
1685  this.lat0 = 0, this.long0 = (6 * Math.abs(e) - 183) * Zt, this.x0 = 5e5, this.y0 = this.utmSouth ? 1e7 : 0, this.k0 = 0.9996, Co.init.apply(this), this.forward = Co.forward, this.inverse = Co.inverse;
1686}
1687var m0 = ["Universal Transverse Mercator System", "utm"];
1688const _0 = {
1689  init: g0,
1690  names: m0,
1691  dependsOn: f0
1692};
1693function eh(e, t) {
1694  return Math.pow((1 - e) / (1 + e), t);
1695}
1696var p0 = 20;
1697function y0() {
1698  var e = Math.sin(this.lat0), t = Math.cos(this.lat0);
1699  t *= t, this.rc = Math.sqrt(1 - this.es) / (1 - this.es * e * e), this.C = Math.sqrt(1 + this.es * t * t / (1 - this.es)), this.phic0 = Math.asin(e / this.C), this.ratexp = 0.5 * this.C * this.e, this.K = Math.tan(0.5 * this.phic0 + Et) / (Math.pow(Math.tan(0.5 * this.lat0 + Et), this.C) * eh(this.e * e, this.ratexp));
1700}
1701function x0(e) {
1702  var t = e.x, i = e.y;
1703  return e.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * i + Et), this.C) * eh(this.e * Math.sin(i), this.ratexp)) - A, e.x = this.C * t, e;
1704}
1705function v0(e) {
1706  for (var t = 1e-14, i = e.x / this.C, n = e.y, s = Math.pow(Math.tan(0.5 * n + Et) / this.K, 1 / this.C), r = p0; r > 0 && (n = 2 * Math.atan(s * eh(this.e * Math.sin(e.y), -0.5 * this.e)) - A, !(Math.abs(n - e.y) < t)); --r)
1707    e.y = n;
1708  return r ? (e.x = i, e.y = n, e) : null;
1709}
1710var E0 = ["gauss"];
1711const ih = {
1712  init: y0,
1713  forward: x0,
1714  inverse: v0,
1715  names: E0
1716};
1717function C0() {
1718  ih.init.apply(this), this.rc && (this.sinc0 = Math.sin(this.phic0), this.cosc0 = Math.cos(this.phic0), this.R2 = 2 * this.rc, this.title || (this.title = "Oblique Stereographic Alternative"));
1719}
1720function M0(e) {
1721  var t, i, n, s;
1722  return e.x = X(e.x - this.long0), ih.forward.apply(this, [e]), t = Math.sin(e.y), i = Math.cos(e.y), n = Math.cos(e.x), s = this.k0 * this.R2 / (1 + this.sinc0 * t + this.cosc0 * i * n), e.x = s * i * Math.sin(e.x), e.y = s * (this.cosc0 * t - this.sinc0 * i * n), e.x = this.a * e.x + this.x0, e.y = this.a * e.y + this.y0, e;
1723}
1724function b0(e) {
1725  var t, i, n, s, r;
1726  if (e.x = (e.x - this.x0) / this.a, e.y = (e.y - this.y0) / this.a, e.x /= this.k0, e.y /= this.k0, r = Math.sqrt(e.x * e.x + e.y * e.y)) {
1727    var o = 2 * Math.atan2(r, this.R2);
1728    t = Math.sin(o), i = Math.cos(o), s = Math.asin(i * this.sinc0 + e.y * t * this.cosc0 / r), n = Math.atan2(e.x * t, r * this.cosc0 * i - e.y * this.sinc0 * t);
1729  } else
1730    s = this.phic0, n = 0;
1731  return e.x = n, e.y = s, ih.inverse.apply(this, [e]), e.x = X(e.x + this.long0), e;
1732}
1733var w0 = ["Stereographic_North_Pole", "Oblique_Stereographic", "Polar_Stereographic", "sterea", "Oblique Stereographic Alternative", "Double_Stereographic"];
1734const S0 = {
1735  init: C0,
1736  forward: M0,
1737  inverse: b0,
1738  names: w0
1739};
1740function T0(e, t, i) {
1741  return t *= i, Math.tan(0.5 * (A + e)) * Math.pow((1 - t) / (1 + t), 0.5 * i);
1742}
1743function I0() {
1744  this.coslat0 = Math.cos(this.lat0), this.sinlat0 = Math.sin(this.lat0), this.sphere ? this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= G && (this.k0 = 0.5 * (1 + Pr(this.lat0) * Math.sin(this.lat_ts))) : (Math.abs(this.coslat0) <= G && (this.lat0 > 0 ? this.con = 1 : this.con = -1), this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e)), this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= G && (this.k0 = 0.5 * this.cons * di(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / Ve(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts))), this.ms1 = di(this.e, this.sinlat0, this.coslat0), this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - A, this.cosX0 = Math.cos(this.X0), this.sinX0 = Math.sin(this.X0));
1745}
1746function R0(e) {
1747  var t = e.x, i = e.y, n = Math.sin(i), s = Math.cos(i), r, o, a, l, h, c, u = X(t - this.long0);
1748  return Math.abs(Math.abs(t - this.long0) - Math.PI) <= G && Math.abs(i + this.lat0) <= G ? (e.x = NaN, e.y = NaN, e) : this.sphere ? (r = 2 * this.k0 / (1 + this.sinlat0 * n + this.coslat0 * s * Math.cos(u)), e.x = this.a * r * s * Math.sin(u) + this.x0, e.y = this.a * r * (this.coslat0 * n - this.sinlat0 * s * Math.cos(u)) + this.y0, e) : (o = 2 * Math.atan(this.ssfn_(i, n, this.e)) - A, l = Math.cos(o), a = Math.sin(o), Math.abs(this.coslat0) <= G ? (h = Ve(this.e, i * this.con, this.con * n), c = 2 * this.a * this.k0 * h / this.cons, e.x = this.x0 + c * Math.sin(t - this.long0), e.y = this.y0 - this.con * c * Math.cos(t - this.long0), e) : (Math.abs(this.sinlat0) < G ? (r = 2 * this.a * this.k0 / (1 + l * Math.cos(u)), e.y = r * a) : (r = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * a + this.cosX0 * l * Math.cos(u))), e.y = r * (this.cosX0 * a - this.sinX0 * l * Math.cos(u)) + this.y0), e.x = r * l * Math.sin(u) + this.x0, e));
1749}
1750function P0(e) {
1751  e.x -= this.x0, e.y -= this.y0;
1752  var t, i, n, s, r, o = Math.sqrt(e.x * e.x + e.y * e.y);
1753  if (this.sphere) {
1754    var a = 2 * Math.atan(o / (2 * this.a * this.k0));
1755    return t = this.long0, i = this.lat0, o <= G ? (e.x = t, e.y = i, e) : (i = Math.asin(Math.cos(a) * this.sinlat0 + e.y * Math.sin(a) * this.coslat0 / o), Math.abs(this.coslat0) < G ? this.lat0 > 0 ? t = X(this.long0 + Math.atan2(e.x, -1 * e.y)) : t = X(this.long0 + Math.atan2(e.x, e.y)) : t = X(this.long0 + Math.atan2(e.x * Math.sin(a), o * this.coslat0 * Math.cos(a) - e.y * this.sinlat0 * Math.sin(a))), e.x = t, e.y = i, e);
1756  } else if (Math.abs(this.coslat0) <= G) {
1757    if (o <= G)
1758      return i = this.lat0, t = this.long0, e.x = t, e.y = i, e;
1759    e.x *= this.con, e.y *= this.con, n = o * this.cons / (2 * this.a * this.k0), i = this.con * dr(this.e, n), t = this.con * X(this.con * this.long0 + Math.atan2(e.x, -1 * e.y));
1760  } else
1761    s = 2 * Math.atan(o * this.cosX0 / (2 * this.a * this.k0 * this.ms1)), t = this.long0, o <= G ? r = this.X0 : (r = Math.asin(Math.cos(s) * this.sinX0 + e.y * Math.sin(s) * this.cosX0 / o), t = X(this.long0 + Math.atan2(e.x * Math.sin(s), o * this.cosX0 * Math.cos(s) - e.y * this.sinX0 * Math.sin(s)))), i = -1 * dr(this.e, Math.tan(0.5 * (A + r)));
1762  return e.x = t, e.y = i, e;
1763}
1764var L0 = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)"];
1765const A0 = {
1766  init: I0,
1767  forward: R0,
1768  inverse: P0,
1769  names: L0,
1770  ssfn_: T0
1771};
1772function O0() {
1773  var e = this.lat0;
1774  this.lambda0 = this.long0;
1775  var t = Math.sin(e), i = this.a, n = this.rf, s = 1 / n, r = 2 * s - Math.pow(s, 2), o = this.e = Math.sqrt(r);
1776  this.R = this.k0 * i * Math.sqrt(1 - r) / (1 - r * Math.pow(t, 2)), this.alpha = Math.sqrt(1 + r / (1 - r) * Math.pow(Math.cos(e), 4)), this.b0 = Math.asin(t / this.alpha);
1777  var a = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2)), l = Math.log(Math.tan(Math.PI / 4 + e / 2)), h = Math.log((1 + o * t) / (1 - o * t));
1778  this.K = a - this.alpha * l + this.alpha * o / 2 * h;
1779}
1780function F0(e) {
1781  var t = Math.log(Math.tan(Math.PI / 4 - e.y / 2)), i = this.e / 2 * Math.log((1 + this.e * Math.sin(e.y)) / (1 - this.e * Math.sin(e.y))), n = -this.alpha * (t + i) + this.K, s = 2 * (Math.atan(Math.exp(n)) - Math.PI / 4), r = this.alpha * (e.x - this.lambda0), o = Math.atan(Math.sin(r) / (Math.sin(this.b0) * Math.tan(s) + Math.cos(this.b0) * Math.cos(r))), a = Math.asin(Math.cos(this.b0) * Math.sin(s) - Math.sin(this.b0) * Math.cos(s) * Math.cos(r));
1782  return e.y = this.R / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a))) + this.y0, e.x = this.R * o + this.x0, e;
1783}
1784function k0(e) {
1785  for (var t = e.x - this.x0, i = e.y - this.y0, n = t / this.R, s = 2 * (Math.atan(Math.exp(i / this.R)) - Math.PI / 4), r = Math.asin(Math.cos(this.b0) * Math.sin(s) + Math.sin(this.b0) * Math.cos(s) * Math.cos(n)), o = Math.atan(Math.sin(n) / (Math.cos(this.b0) * Math.cos(n) - Math.sin(this.b0) * Math.tan(s))), a = this.lambda0 + o / this.alpha, l = 0, h = r, c = -1e3, u = 0; Math.abs(h - c) > 1e-7; ) {
1786    if (++u > 20)
1787      return;
1788    l = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + r / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(h)) / 2)), c = h, h = 2 * Math.atan(Math.exp(l)) - Math.PI / 2;
1789  }
1790  return e.x = a, e.y = h, e;
1791}
1792var D0 = ["somerc"];
1793const N0 = {
1794  init: O0,
1795  forward: F0,
1796  inverse: k0,
1797  names: D0
1798};
1799var Vn = 1e-7;
1800function G0(e) {
1801  var t = ["Hotine_Oblique_Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin"], i = typeof e.PROJECTION == "object" ? Object.keys(e.PROJECTION)[0] : e.PROJECTION;
1802  return "no_uoff" in e || "no_off" in e || t.indexOf(i) !== -1;
1803}
1804function z0() {
1805  var e, t, i, n, s, r, o, a, l, h, c = 0, u, d = 0, f = 0, g = 0, m = 0, _ = 0, p = 0;
1806  this.no_off = G0(this), this.no_rot = "no_rot" in this;
1807  var y = !1;
1808  "alpha" in this && (y = !0);
1809  var x = !1;
1810  if ("rectified_grid_angle" in this && (x = !0), y && (p = this.alpha), x && (c = this.rectified_grid_angle * Zt), y || x)
1811    d = this.longc;
1812  else if (f = this.long1, m = this.lat1, g = this.long2, _ = this.lat2, Math.abs(m - _) <= Vn || (e = Math.abs(m)) <= Vn || Math.abs(e - A) <= Vn || Math.abs(Math.abs(this.lat0) - A) <= Vn || Math.abs(Math.abs(_) - A) <= Vn)
1813    throw new Error();
1814  var E = 1 - this.es;
1815  t = Math.sqrt(E), Math.abs(this.lat0) > G ? (a = Math.sin(this.lat0), i = Math.cos(this.lat0), e = 1 - this.es * a * a, this.B = i * i, this.B = Math.sqrt(1 + this.es * this.B * this.B / E), this.A = this.B * this.k0 * t / e, n = this.B * t / (i * Math.sqrt(e)), s = n * n - 1, s <= 0 ? s = 0 : (s = Math.sqrt(s), this.lat0 < 0 && (s = -s)), this.E = s += n, this.E *= Math.pow(Ve(this.e, this.lat0, a), this.B)) : (this.B = 1 / t, this.A = this.k0, this.E = n = s = 1), y || x ? (y ? (u = Math.asin(Math.sin(p) / n), x || (c = p)) : (u = c, p = Math.asin(n * Math.sin(u))), this.lam0 = d - Math.asin(0.5 * (s - 1 / s) * Math.tan(u)) / this.B) : (r = Math.pow(Ve(this.e, m, Math.sin(m)), this.B), o = Math.pow(Ve(this.e, _, Math.sin(_)), this.B), s = this.E / r, l = (o - r) / (o + r), h = this.E * this.E, h = (h - o * r) / (h + o * r), e = f - g, e < -Math.pi ? g -= cr : e > Math.pi && (g += cr), this.lam0 = X(0.5 * (f + g) - Math.atan(h * Math.tan(0.5 * this.B * (f - g)) / l) / this.B), u = Math.atan(2 * Math.sin(this.B * X(f - this.lam0)) / (s - 1 / s)), c = p = Math.asin(n * Math.sin(u))), this.singam = Math.sin(u), this.cosgam = Math.cos(u), this.sinrot = Math.sin(c), this.cosrot = Math.cos(c), this.rB = 1 / this.B, this.ArB = this.A * this.rB, this.BrA = 1 / this.ArB, this.A * this.B, this.no_off ? this.u_0 = 0 : (this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(n * n - 1) / Math.cos(p))), this.lat0 < 0 && (this.u_0 = -this.u_0)), s = 0.5 * u, this.v_pole_n = this.ArB * Math.log(Math.tan(Et - s)), this.v_pole_s = this.ArB * Math.log(Math.tan(Et + s));
1816}
1817function j0(e) {
1818  var t = {}, i, n, s, r, o, a, l, h;
1819  if (e.x = e.x - this.lam0, Math.abs(Math.abs(e.y) - A) > G) {
1820    if (o = this.E / Math.pow(Ve(this.e, e.y, Math.sin(e.y)), this.B), a = 1 / o, i = 0.5 * (o - a), n = 0.5 * (o + a), r = Math.sin(this.B * e.x), s = (i * this.singam - r * this.cosgam) / n, Math.abs(Math.abs(s) - 1) < G)
1821      throw new Error();
1822    h = 0.5 * this.ArB * Math.log((1 - s) / (1 + s)), a = Math.cos(this.B * e.x), Math.abs(a) < Vn ? l = this.A * e.x : l = this.ArB * Math.atan2(i * this.cosgam + r * this.singam, a);
1823  } else
1824    h = e.y > 0 ? this.v_pole_n : this.v_pole_s, l = this.ArB * e.y;
1825  return this.no_rot ? (t.x = l, t.y = h) : (l -= this.u_0, t.x = h * this.cosrot + l * this.sinrot, t.y = l * this.cosrot - h * this.sinrot), t.x = this.a * t.x + this.x0, t.y = this.a * t.y + this.y0, t;
1826}
1827function W0(e) {
1828  var t, i, n, s, r, o, a, l = {};
1829  if (e.x = (e.x - this.x0) * (1 / this.a), e.y = (e.y - this.y0) * (1 / this.a), this.no_rot ? (i = e.y, t = e.x) : (i = e.x * this.cosrot - e.y * this.sinrot, t = e.y * this.cosrot + e.x * this.sinrot + this.u_0), n = Math.exp(-this.BrA * i), s = 0.5 * (n - 1 / n), r = 0.5 * (n + 1 / n), o = Math.sin(this.BrA * t), a = (o * this.cosgam + s * this.singam) / r, Math.abs(Math.abs(a) - 1) < G)
1830    l.x = 0, l.y = a < 0 ? -A : A;
1831  else {
1832    if (l.y = this.E / Math.sqrt((1 + a) / (1 - a)), l.y = dr(this.e, Math.pow(l.y, 1 / this.B)), l.y === 1 / 0)
1833      throw new Error();
1834    l.x = -this.rB * Math.atan2(s * this.cosgam - o * this.singam, Math.cos(this.BrA * t));
1835  }
1836  return l.x += this.lam0, l;
1837}
1838var B0 = ["Hotine_Oblique_Mercator", "Hotine Oblique Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "Hotine_Oblique_Mercator_Azimuth_Center", "Oblique_Mercator", "omerc"];
1839const U0 = {
1840  init: z0,
1841  forward: j0,
1842  inverse: W0,
1843  names: B0
1844};
1845function X0() {
1846  if (this.lat2 || (this.lat2 = this.lat1), this.k0 || (this.k0 = 1), this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, !(Math.abs(this.lat1 + this.lat2) < G)) {
1847    var e = this.b / this.a;
1848    this.e = Math.sqrt(1 - e * e);
1849    var t = Math.sin(this.lat1), i = Math.cos(this.lat1), n = di(this.e, t, i), s = Ve(this.e, this.lat1, t), r = Math.sin(this.lat2), o = Math.cos(this.lat2), a = di(this.e, r, o), l = Ve(this.e, this.lat2, r), h = Ve(this.e, this.lat0, Math.sin(this.lat0));
1850    Math.abs(this.lat1 - this.lat2) > G ? this.ns = Math.log(n / a) / Math.log(s / l) : this.ns = t, isNaN(this.ns) && (this.ns = t), this.f0 = n / (this.ns * Math.pow(s, this.ns)), this.rh = this.a * this.f0 * Math.pow(h, this.ns), this.title || (this.title = "Lambert Conformal Conic");
1851  }
1852}
1853function $0(e) {
1854  var t = e.x, i = e.y;
1855  Math.abs(2 * Math.abs(i) - Math.PI) <= G && (i = Pr(i) * (A - 2 * G));
1856  var n = Math.abs(Math.abs(i) - A), s, r;
1857  if (n > G)
1858    s = Ve(this.e, i, Math.sin(i)), r = this.a * this.f0 * Math.pow(s, this.ns);
1859  else {
1860    if (n = i * this.ns, n <= 0)
1861      return null;
1862    r = 0;
1863  }
1864  var o = this.ns * X(t - this.long0);
1865  return e.x = this.k0 * (r * Math.sin(o)) + this.x0, e.y = this.k0 * (this.rh - r * Math.cos(o)) + this.y0, e;
1866}
1867function Y0(e) {
1868  var t, i, n, s, r, o = (e.x - this.x0) / this.k0, a = this.rh - (e.y - this.y0) / this.k0;
1869  this.ns > 0 ? (t = Math.sqrt(o * o + a * a), i = 1) : (t = -Math.sqrt(o * o + a * a), i = -1);
1870  var l = 0;
1871  if (t !== 0 && (l = Math.atan2(i * o, i * a)), t !== 0 || this.ns > 0) {
1872    if (i = 1 / this.ns, n = Math.pow(t / (this.a * this.f0), i), s = dr(this.e, n), s === -9999)
1873      return null;
1874  } else
1875    s = -A;
1876  return r = X(l / this.ns + this.long0), e.x = r, e.y = s, e;
1877}
1878var K0 = [
1879  "Lambert Tangential Conformal Conic Projection",
1880  "Lambert_Conformal_Conic",
1881  "Lambert_Conformal_Conic_1SP",
1882  "Lambert_Conformal_Conic_2SP",
1883  "lcc",
1884  "Lambert Conic Conformal (1SP)",
1885  "Lambert Conic Conformal (2SP)"
1886];
1887const V0 = {
1888  init: X0,
1889  forward: $0,
1890  inverse: Y0,
1891  names: K0
1892};
1893function q0() {
1894  this.a = 6377397155e-3, this.es = 0.006674372230614, this.e = Math.sqrt(this.es), this.lat0 || (this.lat0 = 0.863937979737193), this.long0 || (this.long0 = 0.7417649320975901 - 0.308341501185665), this.k0 || (this.k0 = 0.9999), this.s45 = 0.785398163397448, this.s90 = 2 * this.s45, this.fi0 = this.lat0, this.e2 = this.es, this.e = Math.sqrt(this.e2), this.alfa = Math.sqrt(1 + this.e2 * Math.pow(Math.cos(this.fi0), 4) / (1 - this.e2)), this.uq = 1.04216856380474, this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa), this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2), this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g, this.k1 = this.k0, this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2)), this.s0 = 1.37008346281555, this.n = Math.sin(this.s0), this.ro0 = this.k1 * this.n0 / Math.tan(this.s0), this.ad = this.s90 - this.uq;
1895}
1896function H0(e) {
1897  var t, i, n, s, r, o, a, l = e.x, h = e.y, c = X(l - this.long0);
1898  return t = Math.pow((1 + this.e * Math.sin(h)) / (1 - this.e * Math.sin(h)), this.alfa * this.e / 2), i = 2 * (Math.atan(this.k * Math.pow(Math.tan(h / 2 + this.s45), this.alfa) / t) - this.s45), n = -c * this.alfa, s = Math.asin(Math.cos(this.ad) * Math.sin(i) + Math.sin(this.ad) * Math.cos(i) * Math.cos(n)), r = Math.asin(Math.cos(i) * Math.sin(n) / Math.cos(s)), o = this.n * r, a = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n), e.y = a * Math.cos(o) / 1, e.x = a * Math.sin(o) / 1, this.czech || (e.y *= -1, e.x *= -1), e;
1899}
1900function Z0(e) {
1901  var t, i, n, s, r, o, a, l, h = e.x;
1902  e.x = e.y, e.y = h, this.czech || (e.y *= -1, e.x *= -1), o = Math.sqrt(e.x * e.x + e.y * e.y), r = Math.atan2(e.y, e.x), s = r / Math.sin(this.s0), n = 2 * (Math.atan(Math.pow(this.ro0 / o, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45), t = Math.asin(Math.cos(this.ad) * Math.sin(n) - Math.sin(this.ad) * Math.cos(n) * Math.cos(s)), i = Math.asin(Math.cos(n) * Math.sin(s) / Math.cos(t)), e.x = this.long0 - i / this.alfa, a = t, l = 0;
1903  var c = 0;
1904  do
1905    e.y = 2 * (Math.atan(Math.pow(this.k, -1 / this.alfa) * Math.pow(Math.tan(t / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(a)) / (1 - this.e * Math.sin(a)), this.e / 2)) - this.s45), Math.abs(a - e.y) < 1e-10 && (l = 1), a = e.y, c += 1;
1906  while (l === 0 && c < 15);
1907  return c >= 15 ? null : e;
1908}
1909var J0 = ["Krovak", "krovak"];
1910const Q0 = {
1911  init: q0,
1912  forward: H0,
1913  inverse: Z0,
1914  names: J0
1915};
1916function _e(e, t, i, n, s) {
1917  return e * s - t * Math.sin(2 * s) + i * Math.sin(4 * s) - n * Math.sin(6 * s);
1918}
1919function Lr(e) {
1920  return 1 - 0.25 * e * (1 + e / 16 * (3 + 1.25 * e));
1921}
1922function Ar(e) {
1923  return 0.375 * e * (1 + 0.25 * e * (1 + 0.46875 * e));
1924}
1925function Or(e) {
1926  return 0.05859375 * e * e * (1 + 0.75 * e);
1927}
1928function Fr(e) {
1929  return e * e * e * (35 / 3072);
1930}
1931function Ms(e, t, i) {
1932  var n = t * i;
1933  return e / Math.sqrt(1 - n * n);
1934}
1935function ks(e) {
1936  return Math.abs(e) < A ? e : e - Pr(e) * Math.PI;
1937}
1938function Lo(e, t, i, n, s) {
1939  var r, o;
1940  r = e / t;
1941  for (var a = 0; a < 15; a++)
1942    if (o = (e - (t * r - i * Math.sin(2 * r) + n * Math.sin(4 * r) - s * Math.sin(6 * r))) / (t - 2 * i * Math.cos(2 * r) + 4 * n * Math.cos(4 * r) - 6 * s * Math.cos(6 * r)), r += o, Math.abs(o) <= 1e-10)
1943      return r;
1944  return NaN;
1945}
1946function tp() {
1947  this.sphere || (this.e0 = Lr(this.es), this.e1 = Ar(this.es), this.e2 = Or(this.es), this.e3 = Fr(this.es), this.ml0 = this.a * _e(this.e0, this.e1, this.e2, this.e3, this.lat0));
1948}
1949function ep(e) {
1950  var t, i, n = e.x, s = e.y;
1951  if (n = X(n - this.long0), this.sphere)
1952    t = this.a * Math.asin(Math.cos(s) * Math.sin(n)), i = this.a * (Math.atan2(Math.tan(s), Math.cos(n)) - this.lat0);
1953  else {
1954    var r = Math.sin(s), o = Math.cos(s), a = Ms(this.a, this.e, r), l = Math.tan(s) * Math.tan(s), h = n * Math.cos(s), c = h * h, u = this.es * o * o / (1 - this.es), d = this.a * _e(this.e0, this.e1, this.e2, this.e3, s);
1955    t = a * h * (1 - c * l * (1 / 6 - (8 - l + 8 * u) * c / 120)), i = d - this.ml0 + a * r / o * c * (0.5 + (5 - l + 6 * u) * c / 24);
1956  }
1957  return e.x = t + this.x0, e.y = i + this.y0, e;
1958}
1959function ip(e) {
1960  e.x -= this.x0, e.y -= this.y0;
1961  var t = e.x / this.a, i = e.y / this.a, n, s;
1962  if (this.sphere) {
1963    var r = i + this.lat0;
1964    n = Math.asin(Math.sin(r) * Math.cos(t)), s = Math.atan2(Math.tan(t), Math.cos(r));
1965  } else {
1966    var o = this.ml0 / this.a + i, a = Lo(o, this.e0, this.e1, this.e2, this.e3);
1967    if (Math.abs(Math.abs(a) - A) <= G)
1968      return e.x = this.long0, e.y = A, i < 0 && (e.y *= -1), e;
1969    var l = Ms(this.a, this.e, Math.sin(a)), h = l * l * l / this.a / this.a * (1 - this.es), c = Math.pow(Math.tan(a), 2), u = t * this.a / l, d = u * u;
1970    n = a - l * Math.tan(a) / h * u * u * (0.5 - (1 + 3 * c) * u * u / 24), s = u * (1 - d * (c / 3 + (1 + 3 * c) * c * d / 15)) / Math.cos(a);
1971  }
1972  return e.x = X(s + this.long0), e.y = ks(n), e;
1973}
1974var np = ["Cassini", "Cassini_Soldner", "cass"];
1975const sp = {
1976  init: tp,
1977  forward: ep,
1978  inverse: ip,
1979  names: np
1980};
1981function Vi(e, t) {
1982  var i;
1983  return e > 1e-7 ? (i = e * t, (1 - e * e) * (t / (1 - i * i) - 0.5 / e * Math.log((1 - i) / (1 + i)))) : 2 * t;
1984}
1985var rp = 1, op = 2, ap = 3, lp = 4;
1986function hp() {
1987  var e = Math.abs(this.lat0);
1988  if (Math.abs(e - A) < G ? this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE : Math.abs(e) < G ? this.mode = this.EQUIT : this.mode = this.OBLIQ, this.es > 0) {
1989    var t;
1990    switch (this.qp = Vi(this.e, 1), this.mmf = 0.5 / (1 - this.es), this.apa = yp(this.es), this.mode) {
1991      case this.N_POLE:
1992        this.dd = 1;
1993        break;
1994      case this.S_POLE:
1995        this.dd = 1;
1996        break;
1997      case this.EQUIT:
1998        this.rq = Math.sqrt(0.5 * this.qp), this.dd = 1 / this.rq, this.xmf = 1, this.ymf = 0.5 * this.qp;
1999        break;
2000      case this.OBLIQ:
2001        this.rq = Math.sqrt(0.5 * this.qp), t = Math.sin(this.lat0), this.sinb1 = Vi(this.e, t) / this.qp, this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1), this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * t * t) * this.rq * this.cosb1), this.ymf = (this.xmf = this.rq) / this.dd, this.xmf *= this.dd;
2002        break;
2003    }
2004  } else
2005    this.mode === this.OBLIQ && (this.sinph0 = Math.sin(this.lat0), this.cosph0 = Math.cos(this.lat0));
2006}
2007function cp(e) {
2008  var t, i, n, s, r, o, a, l, h, c, u = e.x, d = e.y;
2009  if (u = X(u - this.long0), this.sphere) {
2010    if (r = Math.sin(d), c = Math.cos(d), n = Math.cos(u), this.mode === this.OBLIQ || this.mode === this.EQUIT) {
2011      if (i = this.mode === this.EQUIT ? 1 + c * n : 1 + this.sinph0 * r + this.cosph0 * c * n, i <= G)
2012        return null;
2013      i = Math.sqrt(2 / i), t = i * c * Math.sin(u), i *= this.mode === this.EQUIT ? r : this.cosph0 * r - this.sinph0 * c * n;
2014    } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
2015      if (this.mode === this.N_POLE && (n = -n), Math.abs(d + this.lat0) < G)
2016        return null;
2017      i = Et - d * 0.5, i = 2 * (this.mode === this.S_POLE ? Math.cos(i) : Math.sin(i)), t = i * Math.sin(u), i *= n;
2018    }
2019  } else {
2020    switch (a = 0, l = 0, h = 0, n = Math.cos(u), s = Math.sin(u), r = Math.sin(d), o = Vi(this.e, r), (this.mode === this.OBLIQ || this.mode === this.EQUIT) && (a = o / this.qp, l = Math.sqrt(1 - a * a)), this.mode) {
2021      case this.OBLIQ:
2022        h = 1 + this.sinb1 * a + this.cosb1 * l * n;
2023        break;
2024      case this.EQUIT:
2025        h = 1 + l * n;
2026        break;
2027      case this.N_POLE:
2028        h = A + d, o = this.qp - o;
2029        break;
2030      case this.S_POLE:
2031        h = d - A, o = this.qp + o;
2032        break;
2033    }
2034    if (Math.abs(h) < G)
2035      return null;
2036    switch (this.mode) {
2037      case this.OBLIQ:
2038      case this.EQUIT:
2039        h = Math.sqrt(2 / h), this.mode === this.OBLIQ ? i = this.ymf * h * (this.cosb1 * a - this.sinb1 * l * n) : i = (h = Math.sqrt(2 / (1 + l * n))) * a * this.ymf, t = this.xmf * h * l * s;
2040        break;
2041      case this.N_POLE:
2042      case this.S_POLE:
2043        o >= 0 ? (t = (h = Math.sqrt(o)) * s, i = n * (this.mode === this.S_POLE ? h : -h)) : t = i = 0;
2044        break;
2045    }
2046  }
2047  return e.x = this.a * t + this.x0, e.y = this.a * i + this.y0, e;
2048}
2049function up(e) {
2050  e.x -= this.x0, e.y -= this.y0;
2051  var t = e.x / this.a, i = e.y / this.a, n, s, r, o, a, l, h;
2052  if (this.sphere) {
2053    var c = 0, u, d = 0;
2054    if (u = Math.sqrt(t * t + i * i), s = u * 0.5, s > 1)
2055      return null;
2056    switch (s = 2 * Math.asin(s), (this.mode === this.OBLIQ || this.mode === this.EQUIT) && (d = Math.sin(s), c = Math.cos(s)), this.mode) {
2057      case this.EQUIT:
2058        s = Math.abs(u) <= G ? 0 : Math.asin(i * d / u), t *= d, i = c * u;
2059        break;
2060      case this.OBLIQ:
2061        s = Math.abs(u) <= G ? this.lat0 : Math.asin(c * this.sinph0 + i * d * this.cosph0 / u), t *= d * this.cosph0, i = (c - Math.sin(s) * this.sinph0) * u;
2062        break;
2063      case this.N_POLE:
2064        i = -i, s = A - s;
2065        break;
2066      case this.S_POLE:
2067        s -= A;
2068        break;
2069    }
2070    n = i === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ) ? 0 : Math.atan2(t, i);
2071  } else {
2072    if (h = 0, this.mode === this.OBLIQ || this.mode === this.EQUIT) {
2073      if (t /= this.dd, i *= this.dd, l = Math.sqrt(t * t + i * i), l < G)
2074        return e.x = this.long0, e.y = this.lat0, e;
2075      o = 2 * Math.asin(0.5 * l / this.rq), r = Math.cos(o), t *= o = Math.sin(o), this.mode === this.OBLIQ ? (h = r * this.sinb1 + i * o * this.cosb1 / l, a = this.qp * h, i = l * this.cosb1 * r - i * this.sinb1 * o) : (h = i * o / l, a = this.qp * h, i = l * r);
2076    } else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
2077      if (this.mode === this.N_POLE && (i = -i), a = t * t + i * i, !a)
2078        return e.x = this.long0, e.y = this.lat0, e;
2079      h = 1 - a / this.qp, this.mode === this.S_POLE && (h = -h);
2080    }
2081    n = Math.atan2(t, i), s = xp(Math.asin(h), this.apa);
2082  }
2083  return e.x = X(this.long0 + n), e.y = s, e;
2084}
2085var dp = 0.3333333333333333, fp = 0.17222222222222222, gp = 0.10257936507936508, mp = 0.06388888888888888, _p = 0.0664021164021164, pp = 0.016415012942191543;
2086function yp(e) {
2087  var t, i = [];
2088  return i[0] = e * dp, t = e * e, i[0] += t * fp, i[1] = t * mp, t *= e, i[0] += t * gp, i[1] += t * _p, i[2] = t * pp, i;
2089}
2090function xp(e, t) {
2091  var i = e + e;
2092  return e + t[0] * Math.sin(i) + t[1] * Math.sin(i + i) + t[2] * Math.sin(i + i + i);
2093}
2094var vp = ["Lambert Azimuthal Equal Area", "Lambert_Azimuthal_Equal_Area", "laea"];
2095const Ep = {
2096  init: hp,
2097  forward: cp,
2098  inverse: up,
2099  names: vp,
2100  S_POLE: rp,
2101  N_POLE: op,
2102  EQUIT: ap,
2103  OBLIQ: lp
2104};
2105function en(e) {
2106  return Math.abs(e) > 1 && (e = e > 1 ? 1 : -1), Math.asin(e);
2107}
2108function Cp() {
2109  Math.abs(this.lat1 + this.lat2) < G || (this.temp = this.b / this.a, this.es = 1 - Math.pow(this.temp, 2), this.e3 = Math.sqrt(this.es), this.sin_po = Math.sin(this.lat1), this.cos_po = Math.cos(this.lat1), this.t1 = this.sin_po, this.con = this.sin_po, this.ms1 = di(this.e3, this.sin_po, this.cos_po), this.qs1 = Vi(this.e3, this.sin_po), this.sin_po = Math.sin(this.lat2), this.cos_po = Math.cos(this.lat2), this.t2 = this.sin_po, this.ms2 = di(this.e3, this.sin_po, this.cos_po), this.qs2 = Vi(this.e3, this.sin_po), this.sin_po = Math.sin(this.lat0), this.cos_po = Math.cos(this.lat0), this.t3 = this.sin_po, this.qs0 = Vi(this.e3, this.sin_po), Math.abs(this.lat1 - this.lat2) > G ? this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1) : this.ns0 = this.con, this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1, this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0);
2110}
2111function Mp(e) {
2112  var t = e.x, i = e.y;
2113  this.sin_phi = Math.sin(i), this.cos_phi = Math.cos(i);
2114  var n = Vi(this.e3, this.sin_phi), s = this.a * Math.sqrt(this.c - this.ns0 * n) / this.ns0, r = this.ns0 * X(t - this.long0), o = s * Math.sin(r) + this.x0, a = this.rh - s * Math.cos(r) + this.y0;
2115  return e.x = o, e.y = a, e;
2116}
2117function bp(e) {
2118  var t, i, n, s, r, o;
2119  return e.x -= this.x0, e.y = this.rh - e.y + this.y0, this.ns0 >= 0 ? (t = Math.sqrt(e.x * e.x + e.y * e.y), n = 1) : (t = -Math.sqrt(e.x * e.x + e.y * e.y), n = -1), s = 0, t !== 0 && (s = Math.atan2(n * e.x, n * e.y)), n = t * this.ns0 / this.a, this.sphere ? o = Math.asin((this.c - n * n) / (2 * this.ns0)) : (i = (this.c - n * n) / this.ns0, o = this.phi1z(this.e3, i)), r = X(s / this.ns0 + this.long0), e.x = r, e.y = o, e;
2120}
2121function wp(e, t) {
2122  var i, n, s, r, o, a = en(0.5 * t);
2123  if (e < G)
2124    return a;
2125  for (var l = e * e, h = 1; h <= 25; h++)
2126    if (i = Math.sin(a), n = Math.cos(a), s = e * i, r = 1 - s * s, o = 0.5 * r * r / n * (t / (1 - l) - i / r + 0.5 / e * Math.log((1 - s) / (1 + s))), a = a + o, Math.abs(o) <= 1e-7)
2127      return a;
2128  return null;
2129}
2130var Sp = ["Albers_Conic_Equal_Area", "Albers", "aea"];
2131const Tp = {
2132  init: Cp,
2133  forward: Mp,
2134  inverse: bp,
2135  names: Sp,
2136  phi1z: wp
2137};
2138function Ip() {
2139  this.sin_p14 = Math.sin(this.lat0), this.cos_p14 = Math.cos(this.lat0), this.infinity_dist = 1e3 * this.a, this.rc = 1;
2140}
2141function Rp(e) {
2142  var t, i, n, s, r, o, a, l, h = e.x, c = e.y;
2143  return n = X(h - this.long0), t = Math.sin(c), i = Math.cos(c), s = Math.cos(n), o = this.sin_p14 * t + this.cos_p14 * i * s, r = 1, o > 0 || Math.abs(o) <= G ? (a = this.x0 + this.a * r * i * Math.sin(n) / o, l = this.y0 + this.a * r * (this.cos_p14 * t - this.sin_p14 * i * s) / o) : (a = this.x0 + this.infinity_dist * i * Math.sin(n), l = this.y0 + this.infinity_dist * (this.cos_p14 * t - this.sin_p14 * i * s)), e.x = a, e.y = l, e;
2144}
2145function Pp(e) {
2146  var t, i, n, s, r, o;
2147  return e.x = (e.x - this.x0) / this.a, e.y = (e.y - this.y0) / this.a, e.x /= this.k0, e.y /= this.k0, (t = Math.sqrt(e.x * e.x + e.y * e.y)) ? (s = Math.atan2(t, this.rc), i = Math.sin(s), n = Math.cos(s), o = en(n * this.sin_p14 + e.y * i * this.cos_p14 / t), r = Math.atan2(e.x * i, t * this.cos_p14 * n - e.y * this.sin_p14 * i), r = X(this.long0 + r)) : (o = this.phic0, r = 0), e.x = r, e.y = o, e;
2148}
2149var Lp = ["gnom"];
2150const Ap = {
2151  init: Ip,
2152  forward: Rp,
2153  inverse: Pp,
2154  names: Lp
2155};
2156function Op(e, t) {
2157  var i = 1 - (1 - e * e) / (2 * e) * Math.log((1 - e) / (1 + e));
2158  if (Math.abs(Math.abs(t) - i) < 1e-6)
2159    return t < 0 ? -1 * A : A;
2160  for (var n = Math.asin(0.5 * t), s, r, o, a, l = 0; l < 30; l++)
2161    if (r = Math.sin(n), o = Math.cos(n), a = e * r, s = Math.pow(1 - a * a, 2) / (2 * o) * (t / (1 - e * e) - r / (1 - a * a) + 0.5 / e * Math.log((1 - a) / (1 + a))), n += s, Math.abs(s) <= 1e-10)
2162      return n;
2163  return NaN;
2164}
2165function Fp() {
2166  this.sphere || (this.k0 = di(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)));
2167}
2168function kp(e) {
2169  var t = e.x, i = e.y, n, s, r = X(t - this.long0);
2170  if (this.sphere)
2171    n = this.x0 + this.a * r * Math.cos(this.lat_ts), s = this.y0 + this.a * Math.sin(i) / Math.cos(this.lat_ts);
2172  else {
2173    var o = Vi(this.e, Math.sin(i));
2174    n = this.x0 + this.a * this.k0 * r, s = this.y0 + this.a * o * 0.5 / this.k0;
2175  }
2176  return e.x = n, e.y = s, e;
2177}
2178function Dp(e) {
2179  e.x -= this.x0, e.y -= this.y0;
2180  var t, i;
2181  return this.sphere ? (t = X(this.long0 + e.x / this.a / Math.cos(this.lat_ts)), i = Math.asin(e.y / this.a * Math.cos(this.lat_ts))) : (i = Op(this.e, 2 * e.y * this.k0 / this.a), t = X(this.long0 + e.x / (this.a * this.k0))), e.x = t, e.y = i, e;
2182}
2183var Np = ["cea"];
2184const Gp = {
2185  init: Fp,
2186  forward: kp,
2187  inverse: Dp,
2188  names: Np
2189};
2190function zp() {
2191  this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, this.lat0 = this.lat0 || 0, this.long0 = this.long0 || 0, this.lat_ts = this.lat_ts || 0, this.title = this.title || "Equidistant Cylindrical (Plate Carre)", this.rc = Math.cos(this.lat_ts);
2192}
2193function jp(e) {
2194  var t = e.x, i = e.y, n = X(t - this.long0), s = ks(i - this.lat0);
2195  return e.x = this.x0 + this.a * n * this.rc, e.y = this.y0 + this.a * s, e;
2196}
2197function Wp(e) {
2198  var t = e.x, i = e.y;
2199  return e.x = X(this.long0 + (t - this.x0) / (this.a * this.rc)), e.y = ks(this.lat0 + (i - this.y0) / this.a), e;
2200}
2201var Bp = ["Equirectangular", "Equidistant_Cylindrical", "eqc"];
2202const Up = {
2203  init: zp,
2204  forward: jp,
2205  inverse: Wp,
2206  names: Bp
2207};
2208var Uc = 20;
2209function Xp() {
2210  this.temp = this.b / this.a, this.es = 1 - Math.pow(this.temp, 2), this.e = Math.sqrt(this.es), this.e0 = Lr(this.es), this.e1 = Ar(this.es), this.e2 = Or(this.es), this.e3 = Fr(this.es), this.ml0 = this.a * _e(this.e0, this.e1, this.e2, this.e3, this.lat0);
2211}
2212function $p(e) {
2213  var t = e.x, i = e.y, n, s, r, o = X(t - this.long0);
2214  if (r = o * Math.sin(i), this.sphere)
2215    Math.abs(i) <= G ? (n = this.a * o, s = -1 * this.a * this.lat0) : (n = this.a * Math.sin(r) / Math.tan(i), s = this.a * (ks(i - this.lat0) + (1 - Math.cos(r)) / Math.tan(i)));
2216  else if (Math.abs(i) <= G)
2217    n = this.a * o, s = -1 * this.ml0;
2218  else {
2219    var a = Ms(this.a, this.e, Math.sin(i)) / Math.tan(i);
2220    n = a * Math.sin(r), s = this.a * _e(this.e0, this.e1, this.e2, this.e3, i) - this.ml0 + a * (1 - Math.cos(r));
2221  }
2222  return e.x = n + this.x0, e.y = s + this.y0, e;
2223}
2224function Yp(e) {
2225  var t, i, n, s, r, o, a, l, h;
2226  if (n = e.x - this.x0, s = e.y - this.y0, this.sphere)
2227    if (Math.abs(s + this.a * this.lat0) <= G)
2228      t = X(n / this.a + this.long0), i = 0;
2229    else {
2230      o = this.lat0 + s / this.a, a = n * n / this.a / this.a + o * o, l = o;
2231      var c;
2232      for (r = Uc; r; --r)
2233        if (c = Math.tan(l), h = -1 * (o * (l * c + 1) - l - 0.5 * (l * l + a) * c) / ((l - o) / c - 1), l += h, Math.abs(h) <= G) {
2234          i = l;
2235          break;
2236        }
2237      t = X(this.long0 + Math.asin(n * Math.tan(l) / this.a) / Math.sin(i));
2238    }
2239  else if (Math.abs(s + this.ml0) <= G)
2240    i = 0, t = X(this.long0 + n / this.a);
2241  else {
2242    o = (this.ml0 + s) / this.a, a = n * n / this.a / this.a + o * o, l = o;
2243    var u, d, f, g, m;
2244    for (r = Uc; r; --r)
2245      if (m = this.e * Math.sin(l), u = Math.sqrt(1 - m * m) * Math.tan(l), d = this.a * _e(this.e0, this.e1, this.e2, this.e3, l), f = this.e0 - 2 * this.e1 * Math.cos(2 * l) + 4 * this.e2 * Math.cos(4 * l) - 6 * this.e3 * Math.cos(6 * l), g = d / this.a, h = (o * (u * g + 1) - g - 0.5 * u * (g * g + a)) / (this.es * Math.sin(2 * l) * (g * g + a - 2 * o * g) / (4 * u) + (o - g) * (u * f - 2 / Math.sin(2 * l)) - f), l -= h, Math.abs(h) <= G) {
2246        i = l;
2247        break;
2248      }
2249    u = Math.sqrt(1 - this.es * Math.pow(Math.sin(i), 2)) * Math.tan(i), t = X(this.long0 + Math.asin(n * u / this.a) / Math.sin(i));
2250  }
2251  return e.x = t, e.y = i, e;
2252}
2253var Kp = ["Polyconic", "poly"];
2254const Vp = {
2255  init: Xp,
2256  forward: $p,
2257  inverse: Yp,
2258  names: Kp
2259};
2260function qp() {
2261  this.A = [], this.A[1] = 0.6399175073, this.A[2] = -0.1358797613, this.A[3] = 0.063294409, this.A[4] = -0.02526853, this.A[5] = 0.0117879, this.A[6] = -55161e-7, this.A[7] = 26906e-7, this.A[8] = -1333e-6, this.A[9] = 67e-5, this.A[10] = -34e-5, this.B_re = [], this.B_im = [], this.B_re[1] = 0.7557853228, this.B_im[1] = 0, this.B_re[2] = 0.249204646, this.B_im[2] = 3371507e-9, this.B_re[3] = -1541739e-9, this.B_im[3] = 0.04105856, this.B_re[4] = -0.10162907, this.B_im[4] = 0.01727609, this.B_re[5] = -0.26623489, this.B_im[5] = -0.36249218, this.B_re[6] = -0.6870983, this.B_im[6] = -1.1651967, this.C_re = [], this.C_im = [], this.C_re[1] = 1.3231270439, this.C_im[1] = 0, this.C_re[2] = -0.577245789, this.C_im[2] = -7809598e-9, this.C_re[3] = 0.508307513, this.C_im[3] = -0.112208952, this.C_re[4] = -0.15094762, this.C_im[4] = 0.18200602, this.C_re[5] = 1.01418179, this.C_im[5] = 1.64497696, this.C_re[6] = 1.9660549, this.C_im[6] = 2.5127645, this.D = [], this.D[1] = 1.5627014243, this.D[2] = 0.5185406398, this.D[3] = -0.03333098, this.D[4] = -0.1052906, this.D[5] = -0.0368594, this.D[6] = 7317e-6, this.D[7] = 0.0122, this.D[8] = 394e-5, this.D[9] = -13e-4;
2262}
2263function Hp(e) {
2264  var t, i = e.x, n = e.y, s = n - this.lat0, r = i - this.long0, o = s / nr * 1e-5, a = r, l = 1, h = 0;
2265  for (t = 1; t <= 10; t++)
2266    l = l * o, h = h + this.A[t] * l;
2267  var c = h, u = a, d = 1, f = 0, g, m, _ = 0, p = 0;
2268  for (t = 1; t <= 6; t++)
2269    g = d * c - f * u, m = f * c + d * u, d = g, f = m, _ = _ + this.B_re[t] * d - this.B_im[t] * f, p = p + this.B_im[t] * d + this.B_re[t] * f;
2270  return e.x = p * this.a + this.x0, e.y = _ * this.a + this.y0, e;
2271}
2272function Zp(e) {
2273  var t, i = e.x, n = e.y, s = i - this.x0, r = n - this.y0, o = r / this.a, a = s / this.a, l = 1, h = 0, c, u, d = 0, f = 0;
2274  for (t = 1; t <= 6; t++)
2275    c = l * o - h * a, u = h * o + l * a, l = c, h = u, d = d + this.C_re[t] * l - this.C_im[t] * h, f = f + this.C_im[t] * l + this.C_re[t] * h;
2276  for (var g = 0; g < this.iterations; g++) {
2277    var m = d, _ = f, p, y, x = o, E = a;
2278    for (t = 2; t <= 6; t++)
2279      p = m * d - _ * f, y = _ * d + m * f, m = p, _ = y, x = x + (t - 1) * (this.B_re[t] * m - this.B_im[t] * _), E = E + (t - 1) * (this.B_im[t] * m + this.B_re[t] * _);
2280    m = 1, _ = 0;
2281    var M = this.B_re[1], w = this.B_im[1];
2282    for (t = 2; t <= 6; t++)
2283      p = m * d - _ * f, y = _ * d + m * f, m = p, _ = y, M = M + t * (this.B_re[t] * m - this.B_im[t] * _), w = w + t * (this.B_im[t] * m + this.B_re[t] * _);
2284    var L = M * M + w * w;
2285    d = (x * M + E * w) / L, f = (E * M - x * w) / L;
2286  }
2287  var I = d, z = f, U = 1, q = 0;
2288  for (t = 1; t <= 9; t++)
2289    U = U * I, q = q + this.D[t] * U;
2290  var K = this.lat0 + q * nr * 1e5, Z = this.long0 + z;
2291  return e.x = Z, e.y = K, e;
2292}
2293var Jp = ["New_Zealand_Map_Grid", "nzmg"];
2294const Qp = {
2295  init: qp,
2296  forward: Hp,
2297  inverse: Zp,
2298  names: Jp
2299};
2300function ty() {
2301}
2302function ey(e) {
2303  var t = e.x, i = e.y, n = X(t - this.long0), s = this.x0 + this.a * n, r = this.y0 + this.a * Math.log(Math.tan(Math.PI / 4 + i / 2.5)) * 1.25;
2304  return e.x = s, e.y = r, e;
2305}
2306function iy(e) {
2307  e.x -= this.x0, e.y -= this.y0;
2308  var t = X(this.long0 + e.x / this.a), i = 2.5 * (Math.atan(Math.exp(0.8 * e.y / this.a)) - Math.PI / 4);
2309  return e.x = t, e.y = i, e;
2310}
2311var ny = ["Miller_Cylindrical", "mill"];
2312const sy = {
2313  init: ty,
2314  forward: ey,
2315  inverse: iy,
2316  names: ny
2317};
2318var ry = 20;
2319function oy() {
2320  this.sphere ? (this.n = 1, this.m = 0, this.es = 0, this.C_y = Math.sqrt((this.m + 1) / this.n), this.C_x = this.C_y / (this.m + 1)) : this.en = Xd(this.es);
2321}
2322function ay(e) {
2323  var t, i, n = e.x, s = e.y;
2324  if (n = X(n - this.long0), this.sphere) {
2325    if (!this.m)
2326      s = this.n !== 1 ? Math.asin(this.n * Math.sin(s)) : s;
2327    else
2328      for (var r = this.n * Math.sin(s), o = ry; o; --o) {
2329        var a = (this.m * s + Math.sin(s) - r) / (this.m + Math.cos(s));
2330        if (s -= a, Math.abs(a) < G)
2331          break;
2332      }
2333    t = this.a * this.C_x * n * (this.m + Math.cos(s)), i = this.a * this.C_y * s;
2334  } else {
2335    var l = Math.sin(s), h = Math.cos(s);
2336    i = this.a * na(s, l, h, this.en), t = this.a * n * h / Math.sqrt(1 - this.es * l * l);
2337  }
2338  return e.x = t, e.y = i, e;
2339}
2340function ly(e) {
2341  var t, i, n, s;
2342  return e.x -= this.x0, n = e.x / this.a, e.y -= this.y0, t = e.y / this.a, this.sphere ? (t /= this.C_y, n = n / (this.C_x * (this.m + Math.cos(t))), this.m ? t = en((this.m * t + Math.sin(t)) / this.n) : this.n !== 1 && (t = en(Math.sin(t) / this.n)), n = X(n + this.long0), t = ks(t)) : (t = $d(e.y / this.a, this.es, this.en), s = Math.abs(t), s < A ? (s = Math.sin(t), i = this.long0 + e.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(t)), n = X(i)) : s - G < A && (n = this.long0)), e.x = n, e.y = t, e;
2343}
2344var hy = ["Sinusoidal", "sinu"];
2345const cy = {
2346  init: oy,
2347  forward: ay,
2348  inverse: ly,
2349  names: hy
2350};
2351function uy() {
2352}
2353function dy(e) {
2354  for (var t = e.x, i = e.y, n = X(t - this.long0), s = i, r = Math.PI * Math.sin(i); ; ) {
2355    var o = -(s + Math.sin(s) - r) / (1 + Math.cos(s));
2356    if (s += o, Math.abs(o) < G)
2357      break;
2358  }
2359  s /= 2, Math.PI / 2 - Math.abs(i) < G && (n = 0);
2360  var a = 0.900316316158 * this.a * n * Math.cos(s) + this.x0, l = 1.4142135623731 * this.a * Math.sin(s) + this.y0;
2361  return e.x = a, e.y = l, e;
2362}
2363function fy(e) {
2364  var t, i;
2365  e.x -= this.x0, e.y -= this.y0, i = e.y / (1.4142135623731 * this.a), Math.abs(i) > 0.999999999999 && (i = 0.999999999999), t = Math.asin(i);
2366  var n = X(this.long0 + e.x / (0.900316316158 * this.a * Math.cos(t)));
2367  n < -Math.PI && (n = -Math.PI), n > Math.PI && (n = Math.PI), i = (2 * t + Math.sin(2 * t)) / Math.PI, Math.abs(i) > 1 && (i = 1);
2368  var s = Math.asin(i);
2369  return e.x = n, e.y = s, e;
2370}
2371var gy = ["Mollweide", "moll"];
2372const my = {
2373  init: uy,
2374  forward: dy,
2375  inverse: fy,
2376  names: gy
2377};
2378function _y() {
2379  Math.abs(this.lat1 + this.lat2) < G || (this.lat2 = this.lat2 || this.lat1, this.temp = this.b / this.a, this.es = 1 - Math.pow(this.temp, 2), this.e = Math.sqrt(this.es), this.e0 = Lr(this.es), this.e1 = Ar(this.es), this.e2 = Or(this.es), this.e3 = Fr(this.es), this.sinphi = Math.sin(this.lat1), this.cosphi = Math.cos(this.lat1), this.ms1 = di(this.e, this.sinphi, this.cosphi), this.ml1 = _e(this.e0, this.e1, this.e2, this.e3, this.lat1), Math.abs(this.lat1 - this.lat2) < G ? this.ns = this.sinphi : (this.sinphi = Math.sin(this.lat2), this.cosphi = Math.cos(this.lat2), this.ms2 = di(this.e, this.sinphi, this.cosphi), this.ml2 = _e(this.e0, this.e1, this.e2, this.e3, this.lat2), this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1)), this.g = this.ml1 + this.ms1 / this.ns, this.ml0 = _e(this.e0, this.e1, this.e2, this.e3, this.lat0), this.rh = this.a * (this.g - this.ml0));
2380}
2381function py(e) {
2382  var t = e.x, i = e.y, n;
2383  if (this.sphere)
2384    n = this.a * (this.g - i);
2385  else {
2386    var s = _e(this.e0, this.e1, this.e2, this.e3, i);
2387    n = this.a * (this.g - s);
2388  }
2389  var r = this.ns * X(t - this.long0), o = this.x0 + n * Math.sin(r), a = this.y0 + this.rh - n * Math.cos(r);
2390  return e.x = o, e.y = a, e;
2391}
2392function yy(e) {
2393  e.x -= this.x0, e.y = this.rh - e.y + this.y0;
2394  var t, i, n, s;
2395  this.ns >= 0 ? (i = Math.sqrt(e.x * e.x + e.y * e.y), t = 1) : (i = -Math.sqrt(e.x * e.x + e.y * e.y), t = -1);
2396  var r = 0;
2397  if (i !== 0 && (r = Math.atan2(t * e.x, t * e.y)), this.sphere)
2398    return s = X(this.long0 + r / this.ns), n = ks(this.g - i / this.a), e.x = s, e.y = n, e;
2399  var o = this.g - i / this.a;
2400  return n = Lo(o, this.e0, this.e1, this.e2, this.e3), s = X(this.long0 + r / this.ns), e.x = s, e.y = n, e;
2401}
2402var xy = ["Equidistant_Conic", "eqdc"];
2403const vy = {
2404  init: _y,
2405  forward: py,
2406  inverse: yy,
2407  names: xy
2408};
2409function Ey() {
2410  this.R = this.a;
2411}
2412function Cy(e) {
2413  var t = e.x, i = e.y, n = X(t - this.long0), s, r;
2414  Math.abs(i) <= G && (s = this.x0 + this.R * n, r = this.y0);
2415  var o = en(2 * Math.abs(i / Math.PI));
2416  (Math.abs(n) <= G || Math.abs(Math.abs(i) - A) <= G) && (s = this.x0, i >= 0 ? r = this.y0 + Math.PI * this.R * Math.tan(0.5 * o) : r = this.y0 + Math.PI * this.R * -Math.tan(0.5 * o));
2417  var a = 0.5 * Math.abs(Math.PI / n - n / Math.PI), l = a * a, h = Math.sin(o), c = Math.cos(o), u = c / (h + c - 1), d = u * u, f = u * (2 / h - 1), g = f * f, m = Math.PI * this.R * (a * (u - g) + Math.sqrt(l * (u - g) * (u - g) - (g + l) * (d - g))) / (g + l);
2418  n < 0 && (m = -m), s = this.x0 + m;
2419  var _ = l + u;
2420  return m = Math.PI * this.R * (f * _ - a * Math.sqrt((g + l) * (l + 1) - _ * _)) / (g + l), i >= 0 ? r = this.y0 + m : r = this.y0 - m, e.x = s, e.y = r, e;
2421}
2422function My(e) {
2423  var t, i, n, s, r, o, a, l, h, c, u, d, f;
2424  return e.x -= this.x0, e.y -= this.y0, u = Math.PI * this.R, n = e.x / u, s = e.y / u, r = n * n + s * s, o = -Math.abs(s) * (1 + r), a = o - 2 * s * s + n * n, l = -2 * o + 1 + 2 * s * s + r * r, f = s * s / l + (2 * a * a * a / l / l / l - 9 * o * a / l / l) / 27, h = (o - a * a / 3 / l) / l, c = 2 * Math.sqrt(-h / 3), u = 3 * f / h / c, Math.abs(u) > 1 && (u >= 0 ? u = 1 : u = -1), d = Math.acos(u) / 3, e.y >= 0 ? i = (-c * Math.cos(d + Math.PI / 3) - a / 3 / l) * Math.PI : i = -(-c * Math.cos(d + Math.PI / 3) - a / 3 / l) * Math.PI, Math.abs(n) < G ? t = this.long0 : t = X(this.long0 + Math.PI * (r - 1 + Math.sqrt(1 + 2 * (n * n - s * s) + r * r)) / 2 / n), e.x = t, e.y = i, e;
2425}
2426var by = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
2427const wy = {
2428  init: Ey,
2429  forward: Cy,
2430  inverse: My,
2431  names: by
2432};
2433function Sy() {
2434  this.sin_p12 = Math.sin(this.lat0), this.cos_p12 = Math.cos(this.lat0);
2435}
2436function Ty(e) {
2437  var t = e.x, i = e.y, n = Math.sin(e.y), s = Math.cos(e.y), r = X(t - this.long0), o, a, l, h, c, u, d, f, g, m, _, p, y, x, E, M, w, L, I, z, U, q, K;
2438  return this.sphere ? Math.abs(this.sin_p12 - 1) <= G ? (e.x = this.x0 + this.a * (A - i) * Math.sin(r), e.y = this.y0 - this.a * (A - i) * Math.cos(r), e) : Math.abs(this.sin_p12 + 1) <= G ? (e.x = this.x0 + this.a * (A + i) * Math.sin(r), e.y = this.y0 + this.a * (A + i) * Math.cos(r), e) : (L = this.sin_p12 * n + this.cos_p12 * s * Math.cos(r), M = Math.acos(L), w = M ? M / Math.sin(M) : 1, e.x = this.x0 + this.a * w * s * Math.sin(r), e.y = this.y0 + this.a * w * (this.cos_p12 * n - this.sin_p12 * s * Math.cos(r)), e) : (o = Lr(this.es), a = Ar(this.es), l = Or(this.es), h = Fr(this.es), Math.abs(this.sin_p12 - 1) <= G ? (c = this.a * _e(o, a, l, h, A), u = this.a * _e(o, a, l, h, i), e.x = this.x0 + (c - u) * Math.sin(r), e.y = this.y0 - (c - u) * Math.cos(r), e) : Math.abs(this.sin_p12 + 1) <= G ? (c = this.a * _e(o, a, l, h, A), u = this.a * _e(o, a, l, h, i), e.x = this.x0 + (c + u) * Math.sin(r), e.y = this.y0 + (c + u) * Math.cos(r), e) : (d = n / s, f = Ms(this.a, this.e, this.sin_p12), g = Ms(this.a, this.e, n), m = Math.atan((1 - this.es) * d + this.es * f * this.sin_p12 / (g * s)), _ = Math.atan2(Math.sin(r), this.cos_p12 * Math.tan(m) - this.sin_p12 * Math.cos(r)), _ === 0 ? I = Math.asin(this.cos_p12 * Math.sin(m) - this.sin_p12 * Math.cos(m)) : Math.abs(Math.abs(_) - Math.PI) <= G ? I = -Math.asin(this.cos_p12 * Math.sin(m) - this.sin_p12 * Math.cos(m)) : I = Math.asin(Math.sin(r) * Math.cos(m) / Math.sin(_)), p = this.e * this.sin_p12 / Math.sqrt(1 - this.es), y = this.e * this.cos_p12 * Math.cos(_) / Math.sqrt(1 - this.es), x = p * y, E = y * y, z = I * I, U = z * I, q = U * I, K = q * I, M = f * I * (1 - z * E * (1 - E) / 6 + U / 8 * x * (1 - 2 * E) + q / 120 * (E * (4 - 7 * E) - 3 * p * p * (1 - 7 * E)) - K / 48 * x), e.x = this.x0 + M * Math.sin(_), e.y = this.y0 + M * Math.cos(_), e));
2439}
2440function Iy(e) {
2441  e.x -= this.x0, e.y -= this.y0;
2442  var t, i, n, s, r, o, a, l, h, c, u, d, f, g, m, _, p, y, x, E, M, w, L, I;
2443  return this.sphere ? (t = Math.sqrt(e.x * e.x + e.y * e.y), t > 2 * A * this.a ? void 0 : (i = t / this.a, n = Math.sin(i), s = Math.cos(i), r = this.long0, Math.abs(t) <= G ? o = this.lat0 : (o = en(s * this.sin_p12 + e.y * n * this.cos_p12 / t), a = Math.abs(this.lat0) - A, Math.abs(a) <= G ? this.lat0 >= 0 ? r = X(this.long0 + Math.atan2(e.x, -e.y)) : r = X(this.long0 - Math.atan2(-e.x, e.y)) : r = X(this.long0 + Math.atan2(e.x * n, t * this.cos_p12 * s - e.y * this.sin_p12 * n))), e.x = r, e.y = o, e)) : (l = Lr(this.es), h = Ar(this.es), c = Or(this.es), u = Fr(this.es), Math.abs(this.sin_p12 - 1) <= G ? (d = this.a * _e(l, h, c, u, A), t = Math.sqrt(e.x * e.x + e.y * e.y), f = d - t, o = Lo(f / this.a, l, h, c, u), r = X(this.long0 + Math.atan2(e.x, -1 * e.y)), e.x = r, e.y = o, e) : Math.abs(this.sin_p12 + 1) <= G ? (d = this.a * _e(l, h, c, u, A), t = Math.sqrt(e.x * e.x + e.y * e.y), f = t - d, o = Lo(f / this.a, l, h, c, u), r = X(this.long0 + Math.atan2(e.x, e.y)), e.x = r, e.y = o, e) : (t = Math.sqrt(e.x * e.x + e.y * e.y), _ = Math.atan2(e.x, e.y), g = Ms(this.a, this.e, this.sin_p12), p = Math.cos(_), y = this.e * this.cos_p12 * p, x = -y * y / (1 - this.es), E = 3 * this.es * (1 - x) * this.sin_p12 * this.cos_p12 * p / (1 - this.es), M = t / g, w = M - x * (1 + x) * Math.pow(M, 3) / 6 - E * (1 + 3 * x) * Math.pow(M, 4) / 24, L = 1 - x * w * w / 2 - M * w * w * w / 6, m = Math.asin(this.sin_p12 * Math.cos(w) + this.cos_p12 * Math.sin(w) * p), r = X(this.long0 + Math.asin(Math.sin(_) * Math.sin(w) / Math.cos(m))), I = Math.sin(m), o = Math.atan2((I - this.es * L * this.sin_p12) * Math.tan(m), I * (1 - this.es)), e.x = r, e.y = o, e));
2444}
2445var Ry = ["Azimuthal_Equidistant", "aeqd"];
2446const Py = {
2447  init: Sy,
2448  forward: Ty,
2449  inverse: Iy,
2450  names: Ry
2451};
2452function Ly() {
2453  this.sin_p14 = Math.sin(this.lat0), this.cos_p14 = Math.cos(this.lat0);
2454}
2455function Ay(e) {
2456  var t, i, n, s, r, o, a, l, h = e.x, c = e.y;
2457  return n = X(h - this.long0), t = Math.sin(c), i = Math.cos(c), s = Math.cos(n), o = this.sin_p14 * t + this.cos_p14 * i * s, r = 1, (o > 0 || Math.abs(o) <= G) && (a = this.a * r * i * Math.sin(n), l = this.y0 + this.a * r * (this.cos_p14 * t - this.sin_p14 * i * s)), e.x = a, e.y = l, e;
2458}
2459function Oy(e) {
2460  var t, i, n, s, r, o, a;
2461  return e.x -= this.x0, e.y -= this.y0, t = Math.sqrt(e.x * e.x + e.y * e.y), i = en(t / this.a), n = Math.sin(i), s = Math.cos(i), o = this.long0, Math.abs(t) <= G ? (a = this.lat0, e.x = o, e.y = a, e) : (a = en(s * this.sin_p14 + e.y * n * this.cos_p14 / t), r = Math.abs(this.lat0) - A, Math.abs(r) <= G ? (this.lat0 >= 0 ? o = X(this.long0 + Math.atan2(e.x, -e.y)) : o = X(this.long0 - Math.atan2(-e.x, e.y)), e.x = o, e.y = a, e) : (o = X(this.long0 + Math.atan2(e.x * n, t * this.cos_p14 * s - e.y * this.sin_p14 * n)), e.x = o, e.y = a, e));
2462}
2463var Fy = ["ortho"];
2464const ky = {
2465  init: Ly,
2466  forward: Ay,
2467  inverse: Oy,
2468  names: Fy
2469};
2470var Ft = {
2471  FRONT: 1,
2472  RIGHT: 2,
2473  BACK: 3,
2474  LEFT: 4,
2475  TOP: 5,
2476  BOTTOM: 6
2477}, Ct = {
2478  AREA_0: 1,
2479  AREA_1: 2,
2480  AREA_2: 3,
2481  AREA_3: 4
2482};
2483function Dy() {
2484  this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, this.lat0 = this.lat0 || 0, this.long0 = this.long0 || 0, this.lat_ts = this.lat_ts || 0, this.title = this.title || "Quadrilateralized Spherical Cube", this.lat0 >= A - Et / 2 ? this.face = Ft.TOP : this.lat0 <= -(A - Et / 2) ? this.face = Ft.BOTTOM : Math.abs(this.long0) <= Et ? this.face = Ft.FRONT : Math.abs(this.long0) <= A + Et ? this.face = this.long0 > 0 ? Ft.RIGHT : Ft.LEFT : this.face = Ft.BACK, this.es !== 0 && (this.one_minus_f = 1 - (this.a - this.b) / this.a, this.one_minus_f_squared = this.one_minus_f * this.one_minus_f);
2485}
2486function Ny(e) {
2487  var t = { x: 0, y: 0 }, i, n, s, r, o, a, l = { value: 0 };
2488  if (e.x -= this.long0, this.es !== 0 ? i = Math.atan(this.one_minus_f_squared * Math.tan(e.y)) : i = e.y, n = e.x, this.face === Ft.TOP)
2489    r = A - i, n >= Et && n <= A + Et ? (l.value = Ct.AREA_0, s = n - A) : n > A + Et || n <= -(A + Et) ? (l.value = Ct.AREA_1, s = n > 0 ? n - Gt : n + Gt) : n > -(A + Et) && n <= -Et ? (l.value = Ct.AREA_2, s = n + A) : (l.value = Ct.AREA_3, s = n);
2490  else if (this.face === Ft.BOTTOM)
2491    r = A + i, n >
vendor: 12,152 bytes, lines 2491-2760
2491= Et && n <= A + Et ? (l.value = Ct.AREA_0, s = -n + A) : n < Et && n >= -Et ? (l.value = Ct.AREA_1, s = -n) : n < -Et && n >= -(A + Et) ? (l.value = Ct.AREA_2, s = -n - A) : (l.value = Ct.AREA_3, s = n > 0 ? -n + Gt : -n - Gt);
2492  else {
2493    var h, c, u, d, f, g, m;
2494    this.face === Ft.RIGHT ? n = hs(n, +A) : this.face === Ft.BACK ? n = hs(n, +Gt) : this.face === Ft.LEFT && (n = hs(n, -A)), d = Math.sin(i), f = Math.cos(i), g = Math.sin(n), m = Math.cos(n), h = f * m, c = f * g, u = d, this.face === Ft.FRONT ? (r = Math.acos(h), s = qr(r, u, c, l)) : this.face === Ft.RIGHT ? (r = Math.acos(c), s = qr(r, u, -h, l)) : this.face === Ft.BACK ? (r = Math.acos(-h), s = qr(r, u, -c, l)) : this.face === Ft.LEFT ? (r = Math.acos(-c), s = qr(r, u, h, l)) : (r = s = 0, l.value = Ct.AREA_0);
2495  }
2496  return a = Math.atan(12 / Gt * (s + Math.acos(Math.sin(s) * Math.cos(Et)) - A)), o = Math.sqrt((1 - Math.cos(r)) / (Math.cos(a) * Math.cos(a)) / (1 - Math.cos(Math.atan(1 / Math.cos(s))))), l.value === Ct.AREA_1 ? a += A : l.value === Ct.AREA_2 ? a += Gt : l.value === Ct.AREA_3 && (a += 1.5 * Gt), t.x = o * Math.cos(a), t.y = o * Math.sin(a), t.x = t.x * this.a + this.x0, t.y = t.y * this.a + this.y0, e.x = t.x, e.y = t.y, e;
2497}
2498function Gy(e) {
2499  var t = { lam: 0, phi: 0 }, i, n, s, r, o, a, l, h, c, u = { value: 0 };
2500  if (e.x = (e.x - this.x0) / this.a, e.y = (e.y - this.y0) / this.a, n = Math.atan(Math.sqrt(e.x * e.x + e.y * e.y)), i = Math.atan2(e.y, e.x), e.x >= 0 && e.x >= Math.abs(e.y) ? u.value = Ct.AREA_0 : e.y >= 0 && e.y >= Math.abs(e.x) ? (u.value = Ct.AREA_1, i -= A) : e.x < 0 && -e.x >= Math.abs(e.y) ? (u.value = Ct.AREA_2, i = i < 0 ? i + Gt : i - Gt) : (u.value = Ct.AREA_3, i += A), c = Gt / 12 * Math.tan(i), o = Math.sin(c) / (Math.cos(c) - 1 / Math.sqrt(2)), a = Math.atan(o), s = Math.cos(i), r = Math.tan(n), l = 1 - s * s * r * r * (1 - Math.cos(Math.atan(1 / Math.cos(a)))), l < -1 ? l = -1 : l > 1 && (l = 1), this.face === Ft.TOP)
2501    h = Math.acos(l), t.phi = A - h, u.value === Ct.AREA_0 ? t.lam = a + A : u.value === Ct.AREA_1 ? t.lam = a < 0 ? a + Gt : a - Gt : u.value === Ct.AREA_2 ? t.lam = a - A : t.lam = a;
2502  else if (this.face === Ft.BOTTOM)
2503    h = Math.acos(l), t.phi = h - A, u.value === Ct.AREA_0 ? t.lam = -a + A : u.value === Ct.AREA_1 ? t.lam = -a : u.value === Ct.AREA_2 ? t.lam = -a - A : t.lam = a < 0 ? -a - Gt : -a + Gt;
2504  else {
2505    var d, f, g;
2506    d = l, c = d * d, c >= 1 ? g = 0 : g = Math.sqrt(1 - c) * Math.sin(a), c += g * g, c >= 1 ? f = 0 : f = Math.sqrt(1 - c), u.value === Ct.AREA_1 ? (c = f, f = -g, g = c) : u.value === Ct.AREA_2 ? (f = -f, g = -g) : u.value === Ct.AREA_3 && (c = f, f = g, g = -c), this.face === Ft.RIGHT ? (c = d, d = -f, f = c) : this.face === Ft.BACK ? (d = -d, f = -f) : this.face === Ft.LEFT && (c = d, d = f, f = -c), t.phi = Math.acos(-g) - A, t.lam = Math.atan2(f, d), this.face === Ft.RIGHT ? t.lam = hs(t.lam, -A) : this.face === Ft.BACK ? t.lam = hs(t.lam, -Gt) : this.face === Ft.LEFT && (t.lam = hs(t.lam, +A));
2507  }
2508  if (this.es !== 0) {
2509    var m, _, p;
2510    m = t.phi < 0 ? 1 : 0, _ = Math.tan(t.phi), p = this.b / Math.sqrt(_ * _ + this.one_minus_f_squared), t.phi = Math.atan(Math.sqrt(this.a * this.a - p * p) / (this.one_minus_f * p)), m && (t.phi = -t.phi);
2511  }
2512  return t.lam += this.long0, e.x = t.lam, e.y = t.phi, e;
2513}
2514function qr(e, t, i, n) {
2515  var s;
2516  return e < G ? (n.value = Ct.AREA_0, s = 0) : (s = Math.atan2(t, i), Math.abs(s) <= Et ? n.value = Ct.AREA_0 : s > Et && s <= A + Et ? (n.value = Ct.AREA_1, s -= A) : s > A + Et || s <= -(A + Et) ? (n.value = Ct.AREA_2, s = s >= 0 ? s - Gt : s + Gt) : (n.value = Ct.AREA_3, s += A)), s;
2517}
2518function hs(e, t) {
2519  var i = e + t;
2520  return i < -Gt ? i += cr : i > +Gt && (i -= cr), i;
2521}
2522var zy = ["Quadrilateralized Spherical Cube", "Quadrilateralized_Spherical_Cube", "qsc"];
2523const jy = {
2524  init: Dy,
2525  forward: Ny,
2526  inverse: Gy,
2527  names: zy
2528};
2529var ml = [
2530  [1, 22199e-21, -715515e-10, 31103e-10],
2531  [0.9986, -482243e-9, -24897e-9, -13309e-10],
2532  [0.9954, -83103e-8, -448605e-10, -986701e-12],
2533  [0.99, -135364e-8, -59661e-9, 36777e-10],
2534  [0.9822, -167442e-8, -449547e-11, -572411e-11],
2535  [0.973, -214868e-8, -903571e-10, 18736e-12],
2536  [0.96, -305085e-8, -900761e-10, 164917e-11],
2537  [0.9427, -382792e-8, -653386e-10, -26154e-10],
2538  [0.9216, -467746e-8, -10457e-8, 481243e-11],
2539  [0.8962, -536223e-8, -323831e-10, -543432e-11],
2540  [0.8679, -609363e-8, -113898e-9, 332484e-11],
2541  [0.835, -698325e-8, -640253e-10, 934959e-12],
2542  [0.7986, -755338e-8, -500009e-10, 935324e-12],
2543  [0.7597, -798324e-8, -35971e-9, -227626e-11],
2544  [0.7186, -851367e-8, -701149e-10, -86303e-10],
2545  [0.6732, -986209e-8, -199569e-9, 191974e-10],
2546  [0.6213, -0.010418, 883923e-10, 624051e-11],
2547  [0.5722, -906601e-8, 182e-6, 624051e-11],
2548  [0.5322, -677797e-8, 275608e-9, 624051e-11]
2549], Js = [
2550  [-520417e-23, 0.0124, 121431e-23, -845284e-16],
2551  [0.062, 0.0124, -126793e-14, 422642e-15],
2552  [0.124, 0.0124, 507171e-14, -160604e-14],
2553  [0.186, 0.0123999, -190189e-13, 600152e-14],
2554  [0.248, 0.0124002, 710039e-13, -224e-10],
2555  [0.31, 0.0123992, -264997e-12, 835986e-13],
2556  [0.372, 0.0124029, 988983e-12, -311994e-12],
2557  [0.434, 0.0123893, -369093e-11, -435621e-12],
2558  [0.4958, 0.0123198, -102252e-10, -345523e-12],
2559  [0.5571, 0.0121916, -154081e-10, -582288e-12],
2560  [0.6176, 0.0119938, -241424e-10, -525327e-12],
2561  [0.6769, 0.011713, -320223e-10, -516405e-12],
2562  [0.7346, 0.0113541, -397684e-10, -609052e-12],
2563  [0.7903, 0.0109107, -489042e-10, -104739e-11],
2564  [0.8435, 0.0103431, -64615e-9, -140374e-14],
2565  [0.8936, 969686e-8, -64636e-9, -8547e-9],
2566  [0.9394, 840947e-8, -192841e-9, -42106e-10],
2567  [0.9761, 616527e-8, -256e-6, -42106e-10],
2568  [1, 328947e-8, -319159e-9, -42106e-10]
2569], Vd = 0.8487, qd = 1.3523, Hd = Wi / 5, Wy = 1 / Hd, is = 18, Ao = function(e, t) {
2570  return e[0] + t * (e[1] + t * (e[2] + t * e[3]));
2571}, By = function(e, t) {
2572  return e[1] + t * (2 * e[2] + t * 3 * e[3]);
2573};
2574function Uy(e, t, i, n) {
2575  for (var s = t; n; --n) {
2576    var r = e(s);
2577    if (s -= r, Math.abs(r) < i)
2578      break;
2579  }
2580  return s;
2581}
2582function Xy() {
2583  this.x0 = this.x0 || 0, this.y0 = this.y0 || 0, this.long0 = this.long0 || 0, this.es = 0, this.title = this.title || "Robinson";
2584}
2585function $y(e) {
2586  var t = X(e.x - this.long0), i = Math.abs(e.y), n = Math.floor(i * Hd);
2587  n < 0 ? n = 0 : n >= is && (n = is - 1), i = Wi * (i - Wy * n);
2588  var s = {
2589    x: Ao(ml[n], i) * t,
2590    y: Ao(Js[n], i)
2591  };
2592  return e.y < 0 && (s.y = -s.y), s.x = s.x * this.a * Vd + this.x0, s.y = s.y * this.a * qd + this.y0, s;
2593}
2594function Yy(e) {
2595  var t = {
2596    x: (e.x - this.x0) / (this.a * Vd),
2597    y: Math.abs(e.y - this.y0) / (this.a * qd)
2598  };
2599  if (t.y >= 1)
2600    t.x /= ml[is][0], t.y = e.y < 0 ? -A : A;
2601  else {
2602    var i = Math.floor(t.y * is);
2603    for (i < 0 ? i = 0 : i >= is && (i = is - 1); ; )
2604      if (Js[i][0] > t.y)
2605        --i;
2606      else if (Js[i + 1][0] <= t.y)
2607        ++i;
2608      else
2609        break;
2610    var n = Js[i], s = 5 * (t.y - n[0]) / (Js[i + 1][0] - n[0]);
2611    s = Uy(function(r) {
2612      return (Ao(n, r) - t.y) / By(n, r);
2613    }, s, G, 100), t.x /= Ao(ml[i], s), t.y = (5 * i + s) * Zt, e.y < 0 && (t.y = -t.y);
2614  }
2615  return t.x = X(t.x + this.long0), t;
2616}
2617var Ky = ["Robinson", "robin"];
2618const Vy = {
2619  init: Xy,
2620  forward: $y,
2621  inverse: Yy,
2622  names: Ky
2623};
2624function qy() {
2625  this.name = "geocent";
2626}
2627function Hy(e) {
2628  var t = kd(e, this.es, this.a);
2629  return t;
2630}
2631function Zy(e) {
2632  var t = Dd(e, this.es, this.a, this.b);
2633  return t;
2634}
2635var Jy = ["Geocentric", "geocentric", "geocent", "Geocent"];
2636const Qy = {
2637  init: qy,
2638  forward: Hy,
2639  inverse: Zy,
2640  names: Jy
2641};
2642var ne = {
2643  N_POLE: 0,
2644  S_POLE: 1,
2645  EQUIT: 2,
2646  OBLIQ: 3
2647}, Xs = {
2648  h: { def: 1e5, num: !0 },
2649  // default is Karman line, no default in PROJ.7
2650  azi: { def: 0, num: !0, degrees: !0 },
2651  // default is North
2652  tilt: { def: 0, num: !0, degrees: !0 },
2653  // default is Nadir
2654  long0: { def: 0, num: !0 },
2655  // default is Greenwich, conversion to rad is automatic
2656  lat0: { def: 0, num: !0 }
2657  // default is Equator, conversion to rad is automatic
2658};
2659function tx() {
2660  if (Object.keys(Xs).forEach((function(i) {
2661    if (typeof this[i] > "u")
2662      this[i] = Xs[i].def;
2663    else {
2664      if (Xs[i].num && isNaN(this[i]))
2665        throw new Error("Invalid parameter value, must be numeric " + i + " = " + this[i]);
2666      Xs[i].num && (this[i] = parseFloat(this[i]));
2667    }
2668    Xs[i].degrees && (this[i] = this[i] * Zt);
2669  }).bind(this)), Math.abs(Math.abs(this.lat0) - A) < G ? this.mode = this.lat0 < 0 ? ne.S_POLE : ne.N_POLE : Math.abs(this.lat0) < G ? this.mode = ne.EQUIT : (this.mode = ne.OBLIQ, this.sinph0 = Math.sin(this.lat0), this.cosph0 = Math.cos(this.lat0)), this.pn1 = this.h / this.a, this.pn1 <= 0 || this.pn1 > 1e10)
2670    throw new Error("Invalid height");
2671  this.p = 1 + this.pn1, this.rp = 1 / this.p, this.h1 = 1 / this.pn1, this.pfact = (this.p + 1) * this.h1, this.es = 0;
2672  var e = this.tilt, t = this.azi;
2673  this.cg = Math.cos(t), this.sg = Math.sin(t), this.cw = Math.cos(e), this.sw = Math.sin(e);
2674}
2675function ex(e) {
2676  e.x -= this.long0;
2677  var t = Math.sin(e.y), i = Math.cos(e.y), n = Math.cos(e.x), s, r;
2678  switch (this.mode) {
2679    case ne.OBLIQ:
2680      r = this.sinph0 * t + this.cosph0 * i * n;
2681      break;
2682    case ne.EQUIT:
2683      r = i * n;
2684      break;
2685    case ne.S_POLE:
2686      r = -t;
2687      break;
2688    case ne.N_POLE:
2689      r = t;
2690      break;
2691  }
2692  switch (r = this.pn1 / (this.p - r), s = r * i * Math.sin(e.x), this.mode) {
2693    case ne.OBLIQ:
2694      r *= this.cosph0 * t - this.sinph0 * i * n;
2695      break;
2696    case ne.EQUIT:
2697      r *= t;
2698      break;
2699    case ne.N_POLE:
2700      r *= -(i * n);
2701      break;
2702    case ne.S_POLE:
2703      r *= i * n;
2704      break;
2705  }
2706  var o, a;
2707  return o = r * this.cg + s * this.sg, a = 1 / (o * this.sw * this.h1 + this.cw), s = (s * this.cg - r * this.sg) * this.cw * a, r = o * a, e.x = s * this.a, e.y = r * this.a, e;
2708}
2709function ix(e) {
2710  e.x /= this.a, e.y /= this.a;
2711  var t = { x: e.x, y: e.y }, i, n, s;
2712  s = 1 / (this.pn1 - e.y * this.sw), i = this.pn1 * e.x * s, n = this.pn1 * e.y * this.cw * s, e.x = i * this.cg + n * this.sg, e.y = n * this.cg - i * this.sg;
2713  var r = We(e.x, e.y);
2714  if (Math.abs(r) < G)
2715    t.x = 0, t.y = e.y;
2716  else {
2717    var o, a;
2718    switch (a = 1 - r * r * this.pfact, a = (this.p - Math.sqrt(a)) / (this.pn1 / r + r / this.pn1), o = Math.sqrt(1 - a * a), this.mode) {
2719      case ne.OBLIQ:
2720        t.y = Math.asin(o * this.sinph0 + e.y * a * this.cosph0 / r), e.y = (o - this.sinph0 * Math.sin(t.y)) * r, e.x *= a * this.cosph0;
2721        break;
2722      case ne.EQUIT:
2723        t.y = Math.asin(e.y * a / r), e.y = o * r, e.x *= a;
2724        break;
2725      case ne.N_POLE:
2726        t.y = Math.asin(o), e.y = -e.y;
2727        break;
2728      case ne.S_POLE:
2729        t.y = -Math.asin(o);
2730        break;
2731    }
2732    t.x = Math.atan2(e.x, e.y);
2733  }
2734  return e.x = t.x + this.long0, e.y = t.y, e;
2735}
2736var nx = ["Tilted_Perspective", "tpers"];
2737const sx = {
2738  init: tx,
2739  forward: ex,
2740  inverse: ix,
2741  names: nx
2742};
2743function rx() {
2744  if (this.flip_axis = this.sweep === "x" ? 1 : 0, this.h = Number(this.h), this.radius_g_1 = this.h / this.a, this.radius_g_1 <= 0 || this.radius_g_1 > 1e10)
2745    throw new Error();
2746  if (this.radius_g = 1 + this.radius_g_1, this.C = this.radius_g * this.radius_g - 1, this.es !== 0) {
2747    var e = 1 - this.es, t = 1 / e;
2748    this.radius_p = Math.sqrt(e), this.radius_p2 = e, this.radius_p_inv2 = t, this.shape = "ellipse";
2749  } else
2750    this.radius_p = 1, this.radius_p2 = 1, this.radius_p_inv2 = 1, this.shape = "sphere";
2751  this.title || (this.title = "Geostationary Satellite View");
2752}
2753function ox(e) {
2754  var t = e.x, i = e.y, n, s, r, o;
2755  if (t = t - this.long0, this.shape === "ellipse") {
2756    i = Math.atan(this.radius_p2 * Math.tan(i));
2757    var a = this.radius_p / We(this.radius_p * Math.cos(i), Math.sin(i));
2758    if (s = a * Math.cos(t) * Math.cos(i), r = a * Math.sin(t) * Math.cos(i), o = a * Math.sin(i), (this.radius_g - s) * s - r * r - o * o * this.radius_p_inv2 < 0)
2759      return e.x = Number.NaN, e.y = Number.NaN, e;
2760    n = this.radius_g - s, this.flip_axis ? (e.x = this.radius_g_1 * Math.atan(r / We(o, n)
2760), e.y = this.radius_g_1 * Math.atan(o / n)) : (e.x = this.radius_g_1 * Math.atan(r / n), e.y = this.radius_g_1 * Math.atan(o / We(r, n)));
2761  } else
2762    this.shape === "sphere" && (n = Math.cos(i), s = Math.cos(t) * n, r = Math.sin(t) * n, o = Math.sin(i), n = this.radius_g - s, this.flip_axis ? (e.x = this.radius_g_1 * Math.atan(r / We(o, n)), e.y = this.radius_g_1 * Math.atan(o / n)) : (e.x = this.radius_g_1 * Math.atan(r / n), e.y = this.radius_g_1 * Math.atan(o / We(r, n))));
2763  return e.x = e.x * this.a, e.y = e.y * this.a, e;
2764}
2765function ax(e) {
2766  var t = -1, i = 0, n = 0, s, r, o, a;
2767  if (e.x = e.x / this.a, e.y = e.y / this.a, this.shape === "ellipse") {
2768    this.flip_axis ? (n = Math.tan(e.y / this.radius_g_1), i = Math.tan(e.x / this.radius_g_1) * We(1, n)) : (i = Math.tan(e.x / this.radius_g_1), n = Math.tan(e.y / this.radius_g_1) * We(1, i));
2769    var l = n / this.radius_p;
2770    if (s = i * i + l * l + t * t, r = 2 * this.radius_g * t, o = r * r - 4 * s * this.C, o < 0)
2771      return e.x = Number.NaN, e.y = Number.NaN, e;
2772    a = (-r - Math.sqrt(o)) / (2 * s), t = this.radius_g + a * t, i *= a, n *= a, e.x = Math.atan2(i, t), e.y = Math.atan(n * Math.cos(e.x) / t), e.y = Math.atan(this.radius_p_inv2 * Math.tan(e.y));
2773  } else if (this.shape === "sphere") {
2774    if (this.flip_axis ? (n = Math.tan(e.y / this.radius_g_1), i = Math.tan(e.x / this.radius_g_1) * Math.sqrt(1 + n * n)) : (i = Math.tan(e.x / this.radius_g_1), n = Math.tan(e.y / this.radius_g_1) * Math.sqrt(1 + i * i)), s = i * i + n * n + t * t, r = 2 * this.radius_g * t, o = r * r - 4 * s * this.C, o < 0)
2775      return e.x = Number.NaN, e.y = Number.NaN, e;
2776    a = (-r - Math.sqrt(o)) / (2 * s), t = this.radius_g + a * t, i *= a, n *= a, e.x = Math.atan2(i, t), e.y = Math.atan(n * Math.cos(e.x) / t);
2777  }
2778  return e.x = e.x + this.long0, e;
2779}
2780var lx = ["Geostationary Satellite View", "Geostationary_Satellite", "geos"];
2781const hx = {
2782  init: rx,
2783  forward: ox,
2784  inverse: ax,
2785  names: lx
2786};
2787function cx(e) {
2788  e.Proj.projections.add(Eo), e.Proj.projections.add(Co), e.Proj.projections.add(_0), e.Proj.projections.add(S0), e.Proj.projections.add(A0), e.Proj.projections.add(N0), e.Proj.projections.add(U0), e.Proj.projections.add(V0), e.Proj.projections.add(Q0), e.Proj.projections.add(sp), e.Proj.projections.add(Ep), e.Proj.projections.add(Tp), e.Proj.projections.add(Ap), e.Proj.projections.add(Gp), e.Proj.projections.add(Up), e.Proj.projections.add(Vp), e.Proj.projections.add(Qp), e.Proj.projections.add(sy), e.Proj.projections.add(cy), e.Proj.projections.add(my), e.Proj.projections.add(vy), e.Proj.projections.add(wy), e.Proj.projections.add(Py), e.Proj.projections.add(ky), e.Proj.projections.add(jy), e.Proj.projections.add(Vy), e.Proj.projections.add(Qy), e.Proj.projections.add(sx), e.Proj.projections.add(hx);
2789}
2790Me.defaultDatum = "WGS84";
2791Me.Proj = hi;
2792Me.WGS84 = new Me.Proj("WGS84");
2793Me.Point = Cs;
2794Me.toPoint = Nd;
2795Me.defs = fe;
2796Me.nadgrid = y_;
2797Me.transform = Po;
2798Me.mgrs = F_;
2799Me.version = "__VERSION__";
2800cx(Me);
2801const fr = {
2802  // use the radius of the Normal sphere
2803  radians: 6370997 / (2 * Math.PI),
2804  degrees: 2 * Math.PI * 6370997 / 360,
2805  ft: 0.3048,
2806  m: 1,
2807  "us-ft": 1200 / 3937
2808};
2809class ux {
2810  /**
2811   * @param {Options} options Projection options.
2812   */
2813  constructor(t) {
2814    this.code_ = t.code, this.units_ = /** @type {import("./Units.js").Units} */
2815    t.units, this.extent_ = t.extent !== void 0 ? t.extent : null, this.worldExtent_ = t.worldExtent !== void 0 ? t.worldExtent : null, this.axisOrientation_ = t.axisOrientation !== void 0 ? t.axisOrientation : "enu", this.global_ = t.global !== void 0 ? t.global : !1, this.canWrapX_ = !!(this.global_ && this.extent_), this.getPointResolutionFunc_ = t.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = t.metersPerUnit;
2816  }
2817  /**
2818   * @return {boolean} The projection is suitable for wrapping the x-axis
2819   */
2820  canWrapX() {
2821    return this.canWrapX_;
2822  }
2823  /**
2824   * Get the code for this projection, e.g. 'EPSG:4326'.
2825   * @return {string} Code.
2826   * @api
2827   */
2828  getCode() {
2829    return this.code_;
2830  }
2831  /**
2832   * Get the validity extent for this projection.
2833   * @return {import("../extent.js").Extent} Extent.
2834   * @api
2835   */
2836  getExtent() {
2837    return this.extent_;
2838  }
2839  /**
2840   * Get the units of this projection.
2841   * @return {import("./Units.js").Units} Units.
2842   * @api
2843   */
2844  getUnits() {
2845    return this.units_;
2846  }
2847  /**
2848   * Get the amount of meters per unit of this projection.  If the projection is
2849   * not configured with `metersPerUnit` or a units identifier, the return is
2850   * `undefined`.
2851   * @return {number|undefined} Meters.
2852   * @api
2853   */
2854  getMetersPerUnit() {
2855    return this.metersPerUnit_ || fr[this.units_];
2856  }
2857  /**
2858   * Get the world extent for this projection.
2859   * @return {import("../extent.js").Extent} Extent.
2860   * @api
2861   */
2862  getWorldExtent() {
2863    return this.worldExtent_;
2864  }
2865  /**
2866   * Get the axis orientation of this projection.
2867   * Example values are:
2868   * enu - the default easting, northing, elevation.
2869   * neu - northing, easting, up - useful for "lat/long" geographic coordinates,
2870   *     or south orientated transverse mercator.
2871   * wnu - westing, northing, up - some planetary coordinate systems have
2872   *     "west positive" coordinate systems
2873   * @return {string} Axis orientation.
2874   * @api
2875   */
2876  getAxisOrientation() {
2877    return this.axisOrientation_;
2878  }
2879  /**
2880   * Is this projection a global projection which spans the whole world?
2881   * @return {boolean} Whether the projection is global.
2882   * @api
2883   */
2884  isGlobal() {
2885    return this.global_;
2886  }
2887  /**
2888   * Set if the projection is a global projection which spans the whole world
2889   * @param {boolean} global Whether the projection is global.
2890   * @api
2891   */
2892  setGlobal(t) {
2893    this.global_ = t, this.canWrapX_ = !!(t && this.extent_);
2894  }
2895  /**
2896   * @return {import("../tilegrid/TileGrid.js").default} The default tile grid.
2897   */
2898  getDefaultTileGrid() {
2899    return this.defaultTileGrid_;
2900  }
2901  /**
2902   * @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid.
2903   */
2904  setDefaultTileGrid(t) {
2905    this.defaultTileGrid_ = t;
2906  }
2907  /**
2908   * Set the validity extent for this projection.
2909   * @param {import("../extent.js").Extent} extent Extent.
2910   * @api
2911   */
2912  setExtent(t) {
2913    this.extent_ = t, this.canWrapX_ = !!(this.global_ && t);
2914  }
2915  /**
2916   * Set the world extent for this projection.
2917   * @param {import("../extent.js").Extent} worldExtent World extent
2918   *     [minlon, minlat, maxlon, maxlat].
2919   * @api
2920   */
2921  setWorldExtent(t) {
2922    this.worldExtent_ = t;
2923  }
2924  /**
2925   * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}
2926   * for this projection.
2927   * @param {function(number, import("../coordinate.js").Coordinate):number}
2927 func Function
2928   * @api
2929   */
2930  setGetPointResolution(t) {
2931    this.getPointResolutionFunc_ = t;
2932  }
2933  /**
2934   * Get the custom point resolution function for this projection (if set).
2935   * @return {function(number, import("../coordinate.js").Coordinate):number|undefined} The custom point
2936   * resolution function (if set).
2937   */
2938  getPointResolutionFunc() {
2939    return this.getPointResolutionFunc_;
2940  }
2941}
2942const nh = ux, kr = 6378137, ns = Math.PI * kr, dx = [-ns, -ns, ns, ns], fx = [-180, -85, 180, 85], Hr = kr * Math.log(Math.tan(Math.PI / 2));
2943class Bn extends nh {
2944  /**
2945   * @param {string} code Code.
2946   */
2947  constructor(t) {
2948    super({
2949      code: t,
2950      units: "m",
2951      extent: dx,
2952      global: !0,
2953      worldExtent: fx,
2954      getPointResolution: function(i, n) {
2955        return i / Math.cosh(n[1] / kr);
2956      }
2957    });
2958  }
2959}
2960const Xc = [
2961  new Bn("EPSG:3857"),
2962  new Bn("EPSG:102100"),
2963  new Bn("EPSG:102113"),
2964  new Bn("EPSG:900913"),
2965  new Bn("http://www.opengis.net/def/crs/EPSG/0/3857"),
2966  new Bn("http://www.opengis.net/gml/srs/epsg.xml#3857")
2967];
2968function gx(e, t, i) {
2969  const n = e.length;
2970  i = i > 1 ? i : 2, t === void 0 && (i > 2 ? t = e.slice() : t = new Array(n));
2971  for (let s = 0; s < n; s += i) {
2972    t[s] = ns * e[s] / 180;
2973    let r = kr * Math.log(Math.tan(Math.PI * (+e[s + 1] + 90) / 360));
2974    r > Hr ? r = Hr : r < -Hr && (r = -Hr), t[s + 1] = r;
2975  }
2976  return t;
2977}
2978function mx(e, t, i) {
2979  const n = e.length;
2980  i = i > 1 ? i : 2, t === void 0 && (i > 2 ? t = e.slice() : t = new Array(n));
2981  for (let s = 0; s < n; s += i)
2982    t[s] = 180 * e[s] / ns, t[s + 1] = 360 * Math.atan(Math.exp(e[s + 1] / kr)) / Math.PI - 90;
2983  return t;
2984}
2985const _x = 6378137, $c = [-180, -90, 180, 90], px = Math.PI * _x / 180;
2986class un extends nh {
2987  /**
2988   * @param {string} code Code.
2989   * @param {string} [axisOrientation] Axis orientation.
2990   */
2991  constructor(t, i) {
2992    super({
2993      code: t,
2994      units: "degrees",
2995      extent: $c,
2996      axisOrientation: i,
2997      global: !0,
2998      metersPerUnit: px,
2999      worldExtent: $c
3000    });
3001  }
3002}
3003const Yc = [
3004  new un("CRS:84"),
3005  new un("EPSG:4326", "neu"),
3006  new un("urn:ogc:def:crs:OGC:1.3:CRS84"),
3007  new un("urn:ogc:def:crs:OGC:2:84"),
3008  new un("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),
3009  new un("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"),
3010  new un("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")
3011];
3012let _l = {};
3013function yx(e) {
3014  return _l[e] || _l[e.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, "EPSG:$3")] || null;
3015}
3016function xx(e, t) {
3017  _l[e] = t;
3018}
3019function Dr(e) {
3020  for (const t in e)
3021    delete e[t];
3022}
3023function bs(e) {
3024  let t;
3025  for (t in e)
3026    return !1;
3027  return !t;
3028}
3029let cs = {};
3030function ws(e, t, i) {
3031  const n = e.getCode(), s = t.getCode();
3032  n in cs || (cs[n] = {}), cs[n][s] = i;
3033}
3034function Zd(e, t) {
3035  let i;
3036  return e in cs && t in cs[e] && (i = cs[e][t]), i;
3037}
3038const Yt = {
3039  UNKNOWN: 0,
3040  INTERSECTING: 1,
3041  ABOVE: 2,
3042  RIGHT: 4,
3043  BELOW: 8,
3044  LEFT: 16
3045}, vx = {
3046  1: "The view center is not defined",
3047  2: "The view resolution is not defined",
3048  3: "The view rotation is not defined",
3049  4: "`image` and `src` cannot be provided at the same time",
3050  5: "`imgSize` must be set when `image` is provided",
3051  7: "`format` must be set when `url` is set",
3052  8: "Unknown `serverType` configured",
3053  9: "`url` must be configured or set using `#setUrl()`",
3054  10: "The default `geometryFunction` can only handle `Point` geometries",
3055  11: "`options.featureTypes` must be an Array",
3056  12: "`options.geometryName` must also be provided when `options.bbox` is set",
3057  13: "Invalid corner",
3058  14: "Invalid color",
3059  15: "Tried to get a value for a key that does not exist in the cache",
3060  16: "Tried to set a value for a key that is used already",
3061  17: "`resolutions` must be sorted in descending order",
3062  18: "Either `origin` or `origins` must be configured, never both",
3063  19: "Number of `tileSizes` and `resolutions` must be equal",
3064  20: "Number of `origins` and `resolutions` must be equal",
3065  22: "Either `tileSize` or `tileSizes` must be configured, never both",
3066  24: "Invalid extent or geometry provided as `geometry`",
3067  25: "Cannot fit empty extent provided as `geometry`",
3068  26: "Features must have an id set",
3069  27: "Features must have an id set",
3070  28: '`renderMode` must be `"hybrid"` or `"vector"`',
3071  30: "The passed `feature` was already added to the source",
3072  31: "Tried to enqueue an `element` that was already added to the queue",
3073  32: "Transformation matrix cannot be inverted",
3074  33: "Invalid units",
3075  34: "Invalid geometry layout",
3076  36: "Unknown SRS type",
3077  37: "Unknown geometry type found",
3078  38: "`styleMapValue` has an unknown type",
3079  39: "Unknown geometry type",
3080  40: "Expected `feature` to have a geometry",
3081  41: "Expected an `ol/style/Style` or an array of `ol/style/Style.js`",
3082  42: "Question unknown, the answer is 42",
3083  43: "Expected `layers` to be an array or a `Collection`",
3084  47: "Expected `controls` to be an array or an `ol/Collection`",
3085  48: "Expected `interactions` to be an array or an `ol/Collection`",
3086  49: "Expected `overlays` to be an array or an `ol/Collection`",
3087  50: "`options.featureTypes` should be an Array",
3088  51: "Either `url` or `tileJSON` options must be provided",
3089  52: "Unknown `serverType` configured",
3090  53: "Unknown `tierSizeCalculation` configured",
3091  55: "The {-y} placeholder requires a tile grid with extent",
3092  56: "mapBrowserEvent must originate from a pointer event",
3093  57: "At least 2 conditions are required",
3094  59: "Invalid command found in the PBF",
3095  60: "Missing or invalid `size`",
3096  61: "Cannot determine IIIF Image API version from provided image information JSON",
3097  62: "A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",
3098  64: "Layer opacity must be a number",
3099  66: "`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",
3100  67: "A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",
3101  68: "A VectorTile source can only be rendered if it has a projection compatible with the view projection",
3102  69: "`width` or `height` cannot be provided together with `scale`"
3103};
3104class Ex extends Error {
3105  /**
3106   * @param {number} code Error code.
3107   */
3108  constructor(t) {
3109    const i = vx[t];
3110    super(i), this.code = t, this.name = "AssertionError", this.message = i;
3111  }
3112}
3113const Jd = Ex;
3114function ht(e, t) {
3115  if (!e)
3116    throw new Jd(t);
3117}
3118function ge(e) {
3119  const t = be();
3120  for (let i = 0, n = e.length; i < n; ++i)
3121    sr(t, e[i]);
3122  return t;
3123}
3124function Cx(e, t, i) {
3125  const n = Math.min.apply(null, e), s = Math.min.apply(null, t), r = Math.max.apply(null, e), o = Math.max.apply(null, t);
3126  return fi(n, s, r, o, i);
3127}
3128function Rn(e, t, i) {
3129  return i ? (i[0] = e[0] - t, i[1] = e[1] - t, i[2] = e[2] + t, i[3] = e[3] + t, i) : [
3130    e[0] - t,
3131    e[1] - t,
3132    e[2] + t,
3133    e[3] + t
3134  ];
3135}
3136function Qd(e, t) {
3137  return t ? (t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t) : e.slice();
3138}
3139function kn(e, t, i) {
3140  let n, s;
3141  return t < e[0] ? n = e[0] - t : e[2] < t ? n = t - e[2] : n = 0, i < e[1] ? s = e[1] - i : e[3] < i ? s = i - e[3] : s = 0, n * n + s * s;
3142}
3143function Ds(e, t) {
3144  return sh(e, t[0], t[1]);
3145}
3146function Bi(e, t) {
3147  return e[0] <= t[0] && t[2] <= e[2] && e[1] <= t[1] && t[3] <= e[3];
3148}
3149function sh(e, t, i) {
3150  return e[0] <= t && t <= e[2] && e[1] <= i && i <= e[3];
3151}
3152function pl(e, t) {
3153  const i = e[0], n = e[1], s = e[2], r = e[3], o = t[0], a = t[1];
3154  let l = Yt.UNKNOWN;
3155  return o < i ? l = l | Yt.LEFT : o > s && (l = l | Yt.RIGHT), a < n ? l = l | Yt.BELOW : a > r && (l = l | Yt.ABOVE), l === Yt.UNKNOWN && (l = Yt.INTERSECTING), l;
3156}
3157function be() {
3158  return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
3159}
3160function fi(e, t, i, n, s) {
3161  return s ? (s[0] = e, s[1] = t, s[2] = i, s[3] = n, s) : [e, t, i, n];
3162}
3163function Ns(e) {
3164  return fi(1 / 0, 1 / 0, -1 / 0, -1 / 0, e);
3165}
3166function Mo(e, t) {
3167  const i = e[0], n = e[1];
3168  return fi(i, n, i, n, t);
3169}
3170function tf(e, t, i, n, s) {
3171  const r = Ns(s);
3172  return nf(r, e, t, i, n);
3173}
3174function Ss(e, t) {
3175  return e[0] == t[0] && e[2] == t[2] && e[1] == t[1] && e[3] == t[3];
3176}
3177function ef(e, t) {
3178  return t[0] < e[0] && (e[0] = t[0]), t[2] > e[2] && (e[2] = t[2]), t[1] < e[1] && (e[1] = t[1]), t[3] > e[3] && (e[3] = t[3]), e;
3179}
3180function sr(e, t) {
3181  t[0] < e[0] && (e[0] = t[0]), t[0] > e[2] && (e[2] = t[0]), t[1] < e[1] && (e[1] = t[1]), t[1] > e[3] && (e[3] = t[1]);
3182}
3183function nf(e, t, i, n, s) {
3184  for (; i < n; i += s)
3185    Mx(e, t[i], t[i + 1]);
3186  return e;
3187}
3188function Mx(e, t, i) {
3189  e[0] = Math.min(e[0], t), e[1] = Math.min(e[1], i), e[2] = Math.max(e[2], t), e[3] = Math.max(e[3], i);
3190}
3191function rh(e, t) {
3192  let i;
3193  return i = t(sa(e)), i || (i = t(ra(e)), i) || (i = t(oa(e)), i) || (i = t(Dn(e)), i) ? i : !1;
3194}
3195function yl(e) {
3196  let t = 0;
3197  return Nn(e) || (t = xt(e) * qt(e)), t;
3198}
3199function sa(e) {
3200  return [e[0], e[1]];
3201}
3202function ra(e) {
3203  return [e[2], e[1]];
3204}
3205function Je(e) {
3206  return [(e[0] + e[2]) / 2, (e[1] + e[3]) / 2];
3207}
3208function bx(e, t) {
3209  let i;
3210  return t === "bottom-left" ? i = sa(e) : t === "bottom-right" ? i = ra(e) : t === "top-left" ? i = Dn(e) : t === "top-right" ? i = oa(e) : ht(!1, 13), i;
3211}
3212function us(e, t, i, n, s) {
3213  const [r, o, a, l, h, c, u, d] = xl(
3214    e,
3215    t,
3216    i,
3217    n
3218  );
3219  return fi(
3220    Math.min(r, a, h, u),
3221    Math.min(o, l, c, d),
3222    Math.max(r, a, h, u),
3223    Math.max(o, l, c, d),
3224    s
3225  );
3226}
3227function xl(e, t, i, n) {
3228  const s = t * n[0] / 2, r = t * n[1] / 2, o = Math.cos(i), a = Math.sin(i), l = s * o, h = s * a, c = r * o, u = r * a, d = e[0], f = e[1];
3229  return [
3230    d - l + u,
3231    f - h - c,
3232    d - l - u,
3233    f - h + c,
3234    d + l - u,
3235    f + h + c,
3236    d + l + u,
3237    f + h - c,
3238    d - l + u,
3239    f - h - c
3240  ];
3241}
3242function qt(e) {
3243  return e[3] - e[1];
3244}
3245function En(e, t, i) {
3246  const n = i || be();
3247  return re(e, t) ? (e[0] > t[0] ? n[0] = e[0] : n[0] = t[0], e[1] > t[1] ? n[1] = e[1] : n[1] = t[1], e[2] < t[2] ? n[2] = e[2] : n[2] = t[2], e[3] < t[3] ? n[3] = e[3] : n[3] = t[3]) : Ns(n), n;
3248}
3249function Dn(e) {
3250  return [e[0], e[3]];
3251}
3252function oa(e) {
3253  return [e[2], e[3]];
3254}
3255function xt(e) {
3256  return e[2] - e[0];
3257}
3258function re(e, t) {
3259  return e[0] <= t[2] && e[2] >= t[0] && e[1] <= t[3] && e[3] >= t[1];
3260}
3261function Nn(e) {
3262  return e[2] < e[0] || e[3] < e[1];
3263}
3264function wx(e, t) {
3265  return t ? (t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t) : e;
3266}
3267function Sx(e, t, i) {
3268  let n = !1;
3269  const s = pl(e, t), r = pl(e, i);
3270  if (s === Yt.INTERSECTING || r === Yt.INTERSECTING)
3271    n = !0;
3272  else {
3273    const o = e[0], a = e[1], l = e[2], h = e[3], c = t[0], u = t[1], d = i[0], f = i[1], g = (f - u) / (d - c);
3274    let m, _;
3275    r & Yt.ABOVE && !(s & Yt.ABOVE) && (m = d - (f - h) / g, n = m >= o && m <= l), !n && r & Yt.RIGHT && !(s & Yt.RIGHT) && (_ = f - (d - l) * g, n = _ >= a && _ <= h), !n && r & Yt.BELOW && !(s & Yt.BELOW) && (m = d - (f - a) / g, n = m >= o && m <= l), !n && r & Yt.LEFT && !(s & Yt.LEFT) && (_ = f - (d - o) * g, n = _ >= a && _ <= h);
3276  }
3277  return n;
3278}
3279function Tx(e, t, i, n) {
3280  if (Nn(e))
3281    return Ns(i);
3282  let s = [];
3283  if (n > 1) {
3284    const a = e[2] - e[0], l = e[3] - e[1];
3285    for (let h = 0; h < n; ++h)
3286      s.push(
3287        e[0] + a * h / n,
3288        e[1],
3289        e[2],
3290        e[1] + l * h / n,
3291        e[2] - a * h / n,
3292        e[3],
3293        e[0],
3294        e[3] - l * h / n
3295      );
3296  } else
3297    s = [
3298      e[0],
3299      e[1],
3300      e[2],
3301      e[1],
3302      e[2],
3303      e[3],
3304      e[0],
3305      e[3]
3306    ];
3307  t(s, s, 2);
3308  const r = [], o = [];
3309  for (let a = 0, l = s.length; a < l; a += 2)
3310    r.push(s[a]), o.push(s[a + 1]);
3311  return Cx(r, o, i);
3312}
3313function sf(e, t) {
3314  const i = t.getExtent(), n = Je(e);
3315  if (t.canWrapX() && (n[0] < i[0] || n[0] >= i[2])) {
3316    const s = xt(i), o = Math.floor(
3317      (n[0] - i[0]) / s
3318    ) * s;
3319    e[0] -= o, e[2] -= o;
3320  }
3321  return e;
3322}
3323function Ix(e, t) {
3324  if (t.canWrapX()) {
3325    const i = t.getExtent();
3326    if (!isFinite(e[0]) || !isFinite(e[2]))
3327      return [[i[0], e[1], i[2], e[3]]];
3328    sf(e, t);
3329    const n = xt(i);
3330    if (xt(e) > n)
3331      return [[i[0], e[1], i[2], e[3]]];
3332    if (e[0] < i[0])
3333      return [
3334        [e[0] + n, e[1], i[2], e[3]],
3335        [i[0], e[1], e[2], e[3]]
3336      ];
3337    if (e[2] > i[2])
3338      return [
3339        [e[0], e[1], i[2], e[3]],
3340        [i[0], e[1], e[2] - n, e[3]]
3341      ];
3342  }
3343  return [e];
3344}
3345function kt(e, t, i) {
3346  return Math.min(Math.max(e, t), i);
3347}
3348function Rx(e, t, i, n, s, r) {
3349  const o = s - i, a = r - n;
3350  if (o !== 0 || a !== 0) {
3351    const l = ((e - i) * o + (t - n) * a) / (o * o + a * a);
3352    l > 1 ? (i = s, n = r) : l > 0 && (i += o * l, n += a * l);
3353  }
3354  return Mi(e, t, i, n);
3355}
3356function Mi(e, t, i, n) {
3357  const s = i - e, r = n - t;
3358  return s * s + r * r;
3359}
3360function Px(e) {
3361  const t = e.length;
3362  for (let n = 0; n < t; n++) {
3363    let s = n, r = Math.abs(e[n][n]);
3364    for (let a = n + 1; a < t; a++) {
3365      const l = Math.abs(e[a][n]);
3366      l > r && (r = l, s = a);
3367    }
3368    if (r === 0)
3369      return null;
3370    const o = e[s];
3371    e[s] = e[n], e[n] = o;
3372    for (let a = n + 1; a < t; a++) {
3373      const l = -e[a][n] / e[n][n];
3374      for (let h = n; h < t + 1; h++)
3375        n == h ? e[a][h] = 0 : e[a][h] += l * e[n][h];
3376    }
3377  }
3378  const i = new Array(t);
3379  for (let n = t - 1; n >= 0; n--) {
3380    i[n] = e[n][t] / e[n][n];
3381    for (let s = n - 1; s >= 0; s--)
3382      e[s][t] -= e[s][n] * i[n];
3383  }
3384  return i;
3385}
3386function Kc(e) {
3387  return e * 180 / Math.PI;
3388}
3389function Cn(e) {
3390  return e * Math.PI / 180;
3391}
3392function qi(e, t) {
3393  const i = e % t;
3394  return i * t < 0 ? i + t : i;
3395}
3396function Pe(e, t, i) {
3397  return e + i * (t - e);
3398}
3399function Nr(e, t) {
3400  const i = Math.pow(10, t);
3401  return Math.round(e * i) / i;
3402}
3403function Vc(e, t) {
3404  return Math.round(Nr(e, t));
3405}
3406function ss(e, t) {
3407  return Math.floor(Nr(e, t));
3408}
3409function Ui(e, t) {
3410  return Math.ceil(Nr(e, t));
3411}
3412function rf(e, t) {
3413  const i = ("" + e).split("."), n = ("" + t).split(".");
3414  for (let s = 0; s < Math.max(i.length, n.length); s++) {
3415    const r = parseInt(i[s] || "0", 10), o = parseInt(n[s] || "0", 10);
3416    if (r > o)
3417      return 1;
3418    if (o > r)
3419      return -1;
3420  }
3421  return 0;
3422}
3423function Lx(e, t) {
3424  return e[0] += +t[0], e[1] += +t[1], e;
3425}
3426function Ax(e, t) {
3427  const i = t.getRadius(), n = t.getCenter(), s = n[0], r = n[1], o = e[0], a = e[1];
3428  let l = o - s;
3429  const h = a - r;
3430  l === 0 && h === 0 && (l = 1);
3431  const c = Math.sqrt(l * l + h * h), u = s + i * l / c, d = r + i * h / c;
3432  return [u, d];
3433}
3434function oh(e, t) {
3435  const i = e[0], n = e[1], s = t[0], r = t[1], o = s[0], a = s[1], l = r[0], h = r[1], c = l - o, u = h - a, d = c === 0 && u === 0 ? 0 : (c * (i - o) + u * (n - a)) / (c * c + u * u || 0);
3436  let f, g;
3437  return d <= 0 ? (f = o, g = a) : d >= 1 ? (f = l, g = h) : (f = o + d * c, g = a + d * u), [f, g];
3438}
3439function je(e, t) {
3440  let i = !0;
3441  for (let n = e.length - 1; n >= 0; --n)
3442    if (e[n] != t[n]) {
3443      i = !1;
3444      break;
3445    }
3446  return i;
3447}
3448function ah(e, t) {
3449  const i = Math.cos(t), n = Math.sin(t), s = e[0] * i - e[1] * n, r = e[1] * i + e[0] * n;
3450  return e[0] = s, e[1] = r, e;
3451}
3452function Ox(e, t) {
3453  return e[0] *= t, e[1] *= t, e;
3454}
3455function bi(e, t) {
3456  const i = e[0] - t[0], n = e[1] - t[1];
3457  return i * i + n * n;
3458}
3459function Oo(e, t) {
3460  return Math.sqrt(bi(e, t));
3461}
3462function Fx(e, t) {
3463  return bi(e, oh(e, t));
3464}
3465function of(e, t) {
3466  if (t.canWrapX()) {
3467    const i = xt(t.getExtent()), n = af(e, t, i);
3468    n && (e[0] -= n * i);
3469  }
3470  return e;
3471}
3472function af(e, t, i) {
3473  const n = t.getExtent();
3474  let s = 0;
3475  return t.canWrapX() && (e[0] < n[0] || e[0] > n[2]) && (i = i || xt(n), s = Math.floor(
3476    (e[0] - n[0]) / i
3477  )), s;
3478}
3479const lf = 63710088e-1;
3480function qc(e, t, i) {
3481  i = i || lf;
3482  const n = Cn(e[1]), s = Cn(t[1]), r = (s - n) / 2, o = Cn(t[0] - e[0]) / 2, a = Math.sin(r) * Math.sin(r) + Math.sin(o) * Math.sin(o) * Math.cos(n) * Math.cos(s);
3483  return 2 * i * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
3484}
3485function kx(e, t, i, n) {
3486  n = n || lf;
3487  const s = Cn(e[1]), r = Cn(e[0]), o = t / n, a = Math.asin(
3488    Math.sin(s) * Math.cos(o) + Math.cos(s) * Math.sin(o) * Math.cos(i)
3489  ), l = r + Math.atan2(
3490    Math.sin(i) * Math.sin(o) * Math.cos(s),
3491    Math.cos(o) - Math.sin(s) * Math.sin(a)
3492  );
3493  return [Kc(l), Kc(a)];
3494}
3495const hf = {
3496  info: 1,
3497  warn: 2,
3498  error: 3,
3499  none: 4
3500};
3501let Dx = hf.info;
3502function cf(...e) {
3503  Dx > hf.warn;
3504}
3505let vl = !0;
3506function Nx(e) {
3507  vl = !(e === void 0 ? !0 : e);
3508}
3509function lh(e, t) {
3510  if (t !== void 0) {
3511    for (let i = 0, n = e.length; i < n; ++i)
3512      t[i] = e[i];
3513    t = t;
3514  } else
3515    t = e.slice();
3516  return t;
3517}
3518function hh(e, t) {
3519  if (t !== void 0 && e !== t) {
3520    for (let i = 0, n = e.length; i < n; ++i)
3521      t[i] = e[i];
3522    e = t;
3523  }
3524  return e;
3525}
3526function uf(e) {
3527  xx(e.getCode(), e), ws(e, e, lh);
3528}
3529function Gx(e) {
3530  e.forEach(uf);
3531}
3532function It(e) {
3533  return typeof e == "string" ? yx(
3534    /** @type {string} */
3535    e
3536  ) : (
3537    /** @type {Projection} */
3538    e || null
3539  );
3540}
3541function Hc(e, t, i, n) {
3542  e = It(e);
3543  let s;
3544  const r = e.getPointResolutionFunc();
3545  if (r) {
3546    if (s = r(t, i), n && n !== e.getUnits()) {
3547      const o = e.getMetersPerUnit();
3548      o && (s = s * o / fr[n]);
3549    }
3550  } else {
3551    const o = e.getUnits();
3552    if (o == "degrees" && !n || n == "degrees")
3553      s = t;
3554    else {
3555      const a = aa(
3556        e,
3557        It("EPSG:4326")
3558      );
3559      if (a === hh && o !== "degrees")
3560        s = t * e.getMetersPerUnit();
3561      else {
3562        let h = [
3563          i[0] - t / 2,
3564          i[1],
3565          i[0] + t / 2,
3566          i[1],
3567          i[0],
3568          i[1] - t / 2,
3569          i[0],
3570          i[1] + t / 2
3571        ];
3572        h = a(h, h, 2);
3573        const c = qc(h.slice(0, 2), h.slice(2, 4)), u = qc(h.slice(4, 6), h.slice(6, 8));
3574        s = (c + u) / 2;
3575      }
3576      const l = n ? fr[n] : e.getMetersPerUnit();
3577      l !== void 0 && (s /= l);
3578    }
3579  }
3580  return s;
3581}
3582function El(e) {
3583  Gx(e), e.forEach(function(t) {
3584    e.forEach(function(i) {
3585      t !== i && ws(t, i, lh);
3586    });
3587  });
3588}
3589function zx(e, t, i, n) {
3590  e.forEach(function(s) {
3591    t.forEach(function(r) {
3592      ws(s, r, i), ws(r, s, n);
3593    });
3594  });
3595}
3596function ch(e, t) {
3597  return e ? typeof e == "string" ? It(e) : (
3598    /** @type {Projection} */
3599    e
3600  ) : It(t);
3601}
3602function Zc(e) {
3603  return (
3604    /**
3605     * @param {Array<number>} input Input.
3606     * @param {Array<number>} [output] Output.
3607     * @param {number} [dimension] Dimension.
3608     * @return {Array<number>} Output.
3609     */
3610    function(t, i, n) {
3611      const s = t.length;
3612      n = n !== void 0 ? n : 2, i = i !== void 0 ? i : new Array(s);
3613      for (let r = 0; r < s; r += n) {
3614        const o = e(t.slice(r, r + n)), a = o.length;
3615        for (let l = 0, h = n; l < h; ++l)
3616          i[r + l] = l >= a ? t[r + l] : o[l];
3617      }
3618      return i;
3619    }
3620  );
3621}
3622function jx(e, t, i, n) {
3623  const s = It(e), r = It(t);
3624  ws(
3625    s,
3626    r,
3627    Zc(i)
3628  ), ws(
3629    r,
3630    s,
3631    Zc(n)
3632  );
3633}
3634function Ci(e, t) {
3635  if (e === t)
3636    return !0;
3637  const i = e.getUnits() === t.getUnits();
3638  return (e.getCode() === t.getCode() || aa(e, t) === lh) && i;
3639}
3640function aa(e, t) {
3641  const i = e.getCode(), n = t.getCode();
3642  let s = Zd(i, n);
3643  return s || (s = hh), s;
3644}
3645function gr(e, t) {
3646  const i = It(e), n = It(t);
3647  return aa(i, n);
3648}
3649function Ts(e, t, i) {
3650  return gr(t, i)(e, void 0, e.length);
3651}
3652function Wx(e, t, i, n) {
3653  const s = gr(t, i);
3654  return Tx(e, s, void 0, n);
3655}
3656function Pn(e, t) {
3657  return e;
3658}
3659function Lt(e, t) {
3660  return vl && !je(e, [0, 0]) && e[0] >= -180 && e[0] <= 180 && e[1] >= -90 && e[1] <= 90 && (vl = !1, cf(
3661    "Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates."
3662  )), e;
3663}
3664function la(e, t) {
3665  return e;
3666}
3667function ai(e, t) {
3668  return e;
3669}
3670function Jc(e, t, i) {
3671  return function(n) {
3672    let s, r;
3673    if (e.canWrapX()) {
3674      const o = e.getExtent(), a = xt(o);
3675      n = n.slice(0), r = af(n, e, a), r && (n[0] = n[0] - r * a), n[0] = kt(n[0], o[0], o[2]), n[1] = kt(n[1], o[1], o[3]), s = i(n);
3676    } else
3677      s = i(n);
3678    return r && t.canWrapX() && (s[0] += r * xt(t.getExtent())), s;
3679  };
3680}
3681function Bx() {
3682  El(Xc), El(Yc), zx(
3683    Yc,
3684    Xc,
3685    gx,
3686    mx
3687  );
3688}
3689Bx();
3690let Ux = null;
3691function Xx(e) {
3692  Ux = e;
3693  const t = Object.keys(e.defs), i = t.length;
3694  let n, s;
3695  for (n = 0; n < i; ++n) {
3696    const r = t[n];
3697    if (!It(r)) {
3698      const o = e.defs(r);
3699      let a = (
3700        /** @type {import("./Units.js").Units} */
3701        o.units
3702      );
3703      !a && o.projName === "longlat" && (a = "degrees"), uf(
3704        new nh({
3705          code: r,
3706          axisOrientation: o.axis,
3707          metersPerUnit: o.to_meter,
3708          units: a
3709        })
3710      );
3711    }
3712  }
3713  for (n = 0; n < i; ++n) {
3714    const r = t[n], o = It(r);
3715    for (s = 0; s < i; ++s) {
3716      const a = t[s], l = It(a);
3717      if (!Zd(r, a))
3718        if (e.defs[r] === e.defs[a])
3719          El([o, l]);
3720        else {
3721          const h = e(r, a);
3722          jx(
3723            o,
3724            l,
3725            Jc(o, l, h.forward),
3726            Jc(l, o, h.inverse)
3727          );
3728        }
3729    }
3730  }
3731}
3732function uh(e, t) {
3733  const i = /* @__PURE__ */ Object.create(null), n = e.split(",");
3734  for (let s = 0; s < n.length; s++)
3735    i[n[s]] = !0;
3736  return t ? (s) => !!i[s.toLowerCase()] : (s) => !!i[s];
3737}
3738const At = {}, ds = [], qe = () => {
3739}, $x = () => !1, Yx = /^on[^a-z]/, ha = (e) => Yx.test(e), dh = (e) => e.startsWith("onUpdate:"), Ut = Object.assign, fh = (e, t) => {
3740  const i = e.indexOf(t);
3741  i > -1 && e.splice(i, 1);
3742}, Kx = Object.prototype.hasOwnProperty, yt = (e, t) => Kx.call(e, t), nt = Array.isArray, fs = (e) => ca(e) === "[object Map]", df = (e) => ca(e) === "[object Set]", dt = (e) => typeof e == "function", Xt = (e) => typeof e == "string", gh = (e) => typeof e == "symbol", Dt = (e) => e !== null && typeof e == "object", ff = (e) => Dt(e) && dt(e.then) && dt(e.catch), gf = Object.prototype.toString, ca = (e) => gf.call(e), Vx = (e) => ca(e).slice(8, -1), mf = (e) => ca(e) === "[object Object]", mh = (e) => Xt(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, bo = /* @__PURE__ */ uh(
3743  // the leading comma is intentional so empty string "" is also included
3744  ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
3745), ua = (e) => {
3746  const t = /* @__PURE__ */ Object.create(null);
3747  return (i) => t[i] || (t[i] = e(i));
3748}, qx = /-(\w)/g, wi = ua((e) => e.replace(qx, (t, i) => i ? i.toUpperCase() : "")), Hx = /\B([A-Z])/g, Be = ua(
3749  (e) => e.replace(Hx, "-$1").toLowerCase()
3750), _f = ua(
3751  (e) => e.charAt(0).toUpperCase() + e.slice(1)
3752), Fa = ua(
3753  (e) => e ? `on${_f(e)}` : ""
3754), Fo = (e, t) => !Object.is(e, t), ka = (e, t) => {
3755  for (let i = 0; i < e.length; i++)
3756    e[i](t);
3757}, ko = (e, t, i) => {
3758  Object.defineProperty(e, t, {
3759    configurable: !0,
3760    enumerable: !1,
3761    value: i
3762  });
3763}, Zx = (e) => {
3764  const t = parseFloat(e);
3765  return isNaN(t) ? e : t;
3766}, Qc = (e) => {
3767  const t = Xt(e) ? Number(e) : NaN;
3768  return isNaN(t) ? e : t;
3769};
3770let tu;
3771const Cl = () => tu || (tu = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
3772function Gr(e) {
3773  if (nt(e)) {
3774    const t = {};
3775    for (let i = 0; i < e.length; i++) {
3776      const n = e[i], s = Xt(n) ? e1(n) : Gr(n);
3777      if (s)
3778        for (const r in s)
3779          t[r] = s[r];
3780    }
3781    return t;
3782  } else {
3783    if (Xt(e))
3784      return e;
3785    if (Dt(e))
3786      return e;
3787  }
3788}
3789const Jx = /;(?![^(]*\))/g, Qx = /:([^]+)/, t1 = /\/\*[^]*?\*\//g;
3790function e1(e) {
3791  const t = {};
3792  return e.replace(t1, "").split(Jx).forEach((i) => {
3793    if (i) {
3794      const n = i.split(Qx);
3795      n.length > 1 && (t[n[0].trim()] = n[1].trim());
3796    }
3797  }), t;
3798}
3799function Ue(e) {
3800  let t = "";
3801  if (Xt(e))
3802    t = e;
3803  else if (nt(e))
3804    for (let i = 0; i < e.length; i++) {
3805      const n = Ue(e[i]);
3806      n && (t += n + " ");
3807    }
3808  else if (Dt(e))
3809    for (const i in e)
3810      e[i] && (t += i + " ");
3811  return t.trim();
3812}
3813const i1 = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", n1 = /* @__PURE__ */ uh(i1);
3814function pf(e) {
3815  return !!e || e === "";
3816}
3817const Wt = (e) => Xt(e) ? e : e == null ? "" : nt(e) || Dt(e) && (e.toString === gf || !dt(e.toString)) ? JSON.stringify(e, yf, 2) : String(e), yf = (e, t) => t && t.__v_isRef ? yf(e, t.value) : fs(t) ? {
3818  [`Map(${t.size})`]: [...t.entries()].reduce((i, [n, s]) => (i[`${n} =>`] = s, i), {})
3819} : df(t) ? {
3820  [`Set(${t.size})`]: [...t.values()]
3821} : Dt(t) && !nt(t) && !mf(t) ? String(t) : t;
3822let ze;
3823class s1 {
3824  constructor(t = !1) {
3825    this.detached = t, this._active = !0, this.effects = [], this.cleanups = [], this.parent = ze, 
vendor: 29,047 bytes, lines 3825-5023
3825!t && ze && (this.index = (ze.scopes || (ze.scopes = [])).push(
3826      this
3827    ) - 1);
3828  }
3829  get active() {
3830    return this._active;
3831  }
3832  run(t) {
3833    if (this._active) {
3834      const i = ze;
3835      try {
3836        return ze = this, t();
3837      } finally {
3838        ze = i;
3839      }
3840    }
3841  }
3842  /**
3843   * This should only be called on non-detached scopes
3844   * @internal
3845   */
3846  on() {
3847    ze = this;
3848  }
3849  /**
3850   * This should only be called on non-detached scopes
3851   * @internal
3852   */
3853  off() {
3854    ze = this.parent;
3855  }
3856  stop(t) {
3857    if (this._active) {
3858      let i, n;
3859      for (i = 0, n = this.effects.length; i < n; i++)
3860        this.effects[i].stop();
3861      for (i = 0, n = this.cleanups.length; i < n; i++)
3862        this.cleanups[i]();
3863      if (this.scopes)
3864        for (i = 0, n = this.scopes.length; i < n; i++)
3865          this.scopes[i].stop(!0);
3866      if (!this.detached && this.parent && !t) {
3867        const s = this.parent.scopes.pop();
3868        s && s !== this && (this.parent.scopes[this.index] = s, s.index = this.index);
3869      }
3870      this.parent = void 0, this._active = !1;
3871    }
3872  }
3873}
3874function r1(e, t = ze) {
3875  t && t.active && t.effects.push(e);
3876}
3877function o1() {
3878  return ze;
3879}
3880const _h = (e) => {
3881  const t = new Set(e);
3882  return t.w = 0, t.n = 0, t;
3883}, xf = (e) => (e.w & nn) > 0, vf = (e) => (e.n & nn) > 0, a1 = ({ deps: e }) => {
3884  if (e.length)
3885    for (let t = 0; t < e.length; t++)
3886      e[t].w |= nn;
3887}, l1 = (e) => {
3888  const { deps: t } = e;
3889  if (t.length) {
3890    let i = 0;
3891    for (let n = 0; n < t.length; n++) {
3892      const s = t[n];
3893      xf(s) && !vf(s) ? s.delete(e) : t[i++] = s, s.w &= ~nn, s.n &= ~nn;
3894    }
3895    t.length = i;
3896  }
3897}, Ml = /* @__PURE__ */ new WeakMap();
3898let Qs = 0, nn = 1;
3899const bl = 30;
3900let Xe;
3901const Mn = Symbol(""), wl = Symbol("");
3902class ph {
3903  constructor(t, i = null, n) {
3904    this.fn = t, this.scheduler = i, this.active = !0, this.deps = [], this.parent = void 0, r1(this, n);
3905  }
3906  run() {
3907    if (!this.active)
3908      return this.fn();
3909    let t = Xe, i = Hi;
3910    for (; t; ) {
3911      if (t === this)
3912        return;
3913      t = t.parent;
3914    }
3915    try {
3916      return this.parent = Xe, Xe = this, Hi = !0, nn = 1 << ++Qs, Qs <= bl ? a1(this) : eu(this), this.fn();
3917    } finally {
3918      Qs <= bl && l1(this), nn = 1 << --Qs, Xe = this.parent, Hi = i, this.parent = void 0, this.deferStop && this.stop();
3919    }
3920  }
3921  stop() {
3922    Xe === this ? this.deferStop = !0 : this.active && (eu(this), this.onStop && this.onStop(), this.active = !1);
3923  }
3924}
3925function eu(e) {
3926  const { deps: t } = e;
3927  if (t.length) {
3928    for (let i = 0; i < t.length; i++)
3929      t[i].delete(e);
3930    t.length = 0;
3931  }
3932}
3933let Hi = !0;
3934const Ef = [];
3935function Gs() {
3936  Ef.push(Hi), Hi = !1;
3937}
3938function zs() {
3939  const e = Ef.pop();
3940  Hi = e === void 0 ? !0 : e;
3941}
3942function we(e, t, i) {
3943  if (Hi && Xe) {
3944    let n = Ml.get(e);
3945    n || Ml.set(e, n = /* @__PURE__ */ new Map());
3946    let s = n.get(i);
3947    s || n.set(i, s = _h()), Cf(s);
3948  }
3949}
3950function Cf(e, t) {
3951  let i = !1;
3952  Qs <= bl ? vf(e) || (e.n |= nn, i = !xf(e)) : i = !e.has(Xe), i && (e.add(Xe), Xe.deps.push(e));
3953}
3954function Ti(e, t, i, n, s, r) {
3955  const o = Ml.get(e);
3956  if (!o)
3957    return;
3958  let a = [];
3959  if (t === "clear")
3960    a = [...o.values()];
3961  else if (i === "length" && nt(e)) {
3962    const l = Number(n);
3963    o.forEach((h, c) => {
3964      (c === "length" || c >= l) && a.push(h);
3965    });
3966  } else
3967    switch (i !== void 0 && a.push(o.get(i)), t) {
3968      case "add":
3969        nt(e) ? mh(i) && a.push(o.get("length")) : (a.push(o.get(Mn)), fs(e) && a.push(o.get(wl)));
3970        break;
3971      case "delete":
3972        nt(e) || (a.push(o.get(Mn)), fs(e) && a.push(o.get(wl)));
3973        break;
3974      case "set":
3975        fs(e) && a.push(o.get(Mn));
3976        break;
3977    }
3978  if (a.length === 1)
3979    a[0] && Sl(a[0]);
3980  else {
3981    const l = [];
3982    for (const h of a)
3983      h && l.push(...h);
3984    Sl(_h(l));
3985  }
3986}
3987function Sl(e, t) {
3988  const i = nt(e) ? e : [...e];
3989  for (const n of i)
3990    n.computed && iu(n);
3991  for (const n of i)
3992    n.computed || iu(n);
3993}
3994function iu(e, t) {
3995  (e !== Xe || e.allowRecurse) && (e.scheduler ? e.scheduler() : e.run());
3996}
3997const h1 = /* @__PURE__ */ uh("__proto__,__v_isRef,__isVue"), Mf = new Set(
3998  /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(gh)
3999), c1 = /* @__PURE__ */ yh(), u1 = /* @__PURE__ */ yh(!1, !0), d1 = /* @__PURE__ */ yh(!0), nu = /* @__PURE__ */ f1();
4000function f1() {
4001  const e = {};
4002  return ["includes", "indexOf", "lastIndexOf"].forEach((t) => {
4003    e[t] = function(...i) {
4004      const n = Tt(this);
4005      for (let r = 0, o = this.length; r < o; r++)
4006        we(n, "get", r + "");
4007      const s = n[t](...i);
4008      return s === -1 || s === !1 ? n[t](...i.map(Tt)) : s;
4009    };
4010  }), ["push", "pop", "shift", "unshift", "splice"].forEach((t) => {
4011    e[t] = function(...i) {
4012      Gs();
4013      const n = Tt(this)[t].apply(this, i);
4014      return zs(), n;
4015    };
4016  }), e;
4017}
4018function g1(e) {
4019  const t = Tt(this);
4020  return we(t, "has", e), t.hasOwnProperty(e);
4021}
4022function yh(e = !1, t = !1) {
4023  return function(n, s, r) {
4024    if (s === "__v_isReactive")
4025      return !e;
4026    if (s === "__v_isReadonly")
4027      return e;
4028    if (s === "__v_isShallow")
4029      return t;
4030    if (s === "__v_raw" && r === (e ? t ? P1 : If : t ? Tf : Sf).get(n))
4031      return n;
4032    const o = nt(n);
4033    if (!e) {
4034      if (o && yt(nu, s))
4035        return Reflect.get(nu, s, r);
4036      if (s === "hasOwnProperty")
4037        return g1;
4038    }
4039    const a = Reflect.get(n, s, r);
4040    return (gh(s) ? Mf.has(s) : h1(s)) || (e || we(n, "get", s), t) ? a : pe(a) ? o && mh(s) ? a : a.value : Dt(a) ? e ? Rf(a) : fa(a) : a;
4041  };
4042}
4043const m1 = /* @__PURE__ */ bf(), _1 = /* @__PURE__ */ bf(!0);
4044function bf(e = !1) {
4045  return function(i, n, s, r) {
4046    let o = i[n];
4047    if (mr(o) && pe(o) && !pe(s))
4048      return !1;
4049    if (!e && (!Tl(s) && !mr(s) && (o = Tt(o), s = Tt(s)), !nt(i) && pe(o) && !pe(s)))
4050      return o.value = s, !0;
4051    const a = nt(i) && mh(n) ? Number(n) < i.length : yt(i, n), l = Reflect.set(i, n, s, r);
4052    return i === Tt(r) && (a ? Fo(s, o) && Ti(i, "set", n, s) : Ti(i, "add", n, s)), l;
4053  };
4054}
4055function p1(e, t) {
4056  const i = yt(e, t);
4057  e[t];
4058  const n = Reflect.deleteProperty(e, t);
4059  return n && i && Ti(e, "delete", t, void 0), n;
4060}
4061function y1(e, t) {
4062  const i = Reflect.has(e, t);
4063  return (!gh(t) || !Mf.has(t)) && we(e, "has", t), i;
4064}
4065function x1(e) {
4066  return we(e, "iterate", nt(e) ? "length" : Mn), Reflect.ownKeys(e);
4067}
4068const wf = {
4069  get: c1,
4070  set: m1,
4071  deleteProperty: p1,
4072  has: y1,
4073  ownKeys: x1
4074}, v1 = {
4075  get: d1,
4076  set(e, t) {
4077    return !0;
4078  },
4079  deleteProperty(e, t) {
4080    return !0;
4081  }
4082}, E1 = /* @__PURE__ */ Ut(
4083  {},
4084  wf,
4085  {
4086    get: u1,
4087    set: _1
4088  }
4089), xh = (e) => e, da = (e) => Reflect.getPrototypeOf(e);
4090function Zr(e, t, i = !1, n = !1) {
4091  e = e.__v_raw;
4092  const s = Tt(e), r = Tt(t);
4093  i || (t !== r && we(s, "get", t), we(s, "get", r));
4094  const { has: o } = da(s), a = n ? xh : i ? Mh : Ch;
4095  if (o.call(s, t))
4096    return a(e.get(t));
4097  if (o.call(s, r))
4098    return a(e.get(r));
4099  e !== s && e.get(t);
4100}
4101function Jr(e, t = !1) {
4102  const i = this.__v_raw, n = Tt(i), s = Tt(e);
4103  return t || (e !== s && we(n, "has", e), we(n, "has", s)), e === s ? i.has(e) : i.has(e) || i.has(s);
4104}
4105function Qr(e, t = !1) {
4106  return e = e.__v_raw, !t && we(Tt(e), "iterate", Mn), Reflect.get(e, "size", e);
4107}
4108function su(e) {
4109  e = Tt(e);
4110  const t = Tt(this);
4111  return da(t).has.call(t, e) || (t.add(e), Ti(t, "add", e, e)), this;
4112}
4113function ru(e, t) {
4114  t = Tt(t);
4115  const i = Tt(this), { has: n, get: s } = da(i);
4116  let r = n.call(i, e);
4117  r || (e = Tt(e), r = n.call(i, e));
4118  const o = s.call(i, e);
4119  return i.set(e, t), r ? Fo(t, o) && Ti(i, "set", e, t) : Ti(i, "add", e, t), this;
4120}
4121function ou(e) {
4122  const t = Tt(this), { has: i, get: n } = da(t);
4123  let s = i.call(t, e);
4124  s || (e = Tt(e), s = i.call(t, e)), n && n.call(t, e);
4125  const r = t.delete(e);
4126  return s && Ti(t, "delete", e, void 0), r;
4127}
4128function au() {
4129  const e = Tt(this), t = e.size !== 0, i = e.clear();
4130  return t && Ti(e, "clear", void 0, void 0), i;
4131}
4132function to(e, t) {
4133  return function(n, s) {
4134    const r = this, o = r.__v_raw, a = Tt(o), l = t ? xh : e ? Mh : Ch;
4135    return !e && we(a, "iterate", Mn), o.forEach((h, c) => n.call(s, l(h), l(c), r));
4136  };
4137}
4138function eo(e, t, i) {
4139  return function(...n) {
4140    const s = this.__v_raw, r = Tt(s), o = fs(r), a = e === "entries" || e === Symbol.iterator && o, l = e === "keys" && o, h = s[e](...n), c = i ? xh : t ? Mh : Ch;
4141    return !t && we(
4142      r,
4143      "iterate",
4144      l ? wl : Mn
4145    ), {
4146      // iterator protocol
4147      next() {
4148        const { value: u, done: d } = h.next();
4149        return d ? { value: u, done: d } : {
4150          value: a ? [c(u[0]), c(u[1])] : c(u),
4151          done: d
4152        };
4153      },
4154      // iterable protocol
4155      [Symbol.iterator]() {
4156        return this;
4157      }
4158    };
4159  };
4160}
4161function Ai(e) {
4162  return function(...t) {
4163    return e === "delete" ? !1 : this;
4164  };
4165}
4166function C1() {
4167  const e = {
4168    get(r) {
4169      return Zr(this, r);
4170    },
4171    get size() {
4172      return Qr(this);
4173    },
4174    has: Jr,
4175    add: su,
4176    set: ru,
4177    delete: ou,
4178    clear: au,
4179    forEach: to(!1, !1)
4180  }, t = {
4181    get(r) {
4182      return Zr(this, r, !1, !0);
4183    },
4184    get size() {
4185      return Qr(this);
4186    },
4187    has: Jr,
4188    add: su,
4189    set: ru,
4190    delete: ou,
4191    clear: au,
4192    forEach: to(!1, !0)
4193  }, i = {
4194    get(r) {
4195      return Zr(this, r, !0);
4196    },
4197    get size() {
4198      return Qr(this, !0);
4199    },
4200    has(r) {
4201      return Jr.call(this, r, !0);
4202    },
4203    add: Ai("add"),
4204    set: Ai("set"),
4205    delete: Ai("delete"),
4206    clear: Ai("clear"),
4207    forEach: to(!0, !1)
4208  }, n = {
4209    get(r) {
4210      return Zr(this, r, !0, !0);
4211    },
4212    get size() {
4213      return Qr(this, !0);
4214    },
4215    has(r) {
4216      return Jr.call(this, r, !0);
4217    },
4218    add: Ai("add"),
4219    set: Ai("set"),
4220    delete: Ai("delete"),
4221    clear: Ai("clear"),
4222    forEach: to(!0, !0)
4223  };
4224  return ["keys", "values", "entries", Symbol.iterator].forEach((r) => {
4225    e[r] = eo(
4226      r,
4227      !1,
4228      !1
4229    ), i[r] = eo(
4230      r,
4231      !0,
4232      !1
4233    ), t[r] = eo(
4234      r,
4235      !1,
4236      !0
4237    ), n[r] = eo(
4238      r,
4239      !0,
4240      !0
4241    );
4242  }), [
4243    e,
4244    i,
4245    t,
4246    n
4247  ];
4248}
4249const [
4250  M1,
4251  b1,
4252  w1,
4253  S1
4254] = /* @__PURE__ */ C1();
4255function vh(e, t) {
4256  const i = t ? e ? S1 : w1 : e ? b1 : M1;
4257  return (n, s, r) => s === "__v_isReactive" ? !e : s === "__v_isReadonly" ? e : s === "__v_raw" ? n : Reflect.get(
4258    yt(i, s) && s in n ? i : n,
4259    s,
4260    r
4261  );
4262}
4263const T1 = {
4264  get: /* @__PURE__ */ vh(!1, !1)
4265}, I1 = {
4266  get: /* @__PURE__ */ vh(!1, !0)
4267}, R1 = {
4268  get: /* @__PURE__ */ vh(!0, !1)
4269}, Sf = /* @__PURE__ */ new WeakMap(), Tf = /* @__PURE__ */ new WeakMap(), If = /* @__PURE__ */ new WeakMap(), P1 = /* @__PURE__ */ new WeakMap();
4270function L1(e) {
4271  switch (e) {
4272    case "Object":
4273    case "Array":
4274      return 1;
4275    case "Map":
4276    case "Set":
4277    case "WeakMap":
4278    case "WeakSet":
4279      return 2;
4280    default:
4281      return 0;
4282  }
4283}
4284function A1(e) {
4285  return e.__v_skip || !Object.isExtensible(e) ? 0 : L1(Vx(e));
4286}
4287function fa(e) {
4288  return mr(e) ? e : Eh(
4289    e,
4290    !1,
4291    wf,
4292    T1,
4293    Sf
4294  );
4295}
4296function O1(e) {
4297  return Eh(
4298    e,
4299    !1,
4300    E1,
4301    I1,
4302    Tf
4303  );
4304}
4305function Rf(e) {
4306  return Eh(
4307    e,
4308    !0,
4309    v1,
4310    R1,
4311    If
4312  );
4313}
4314function Eh(e, t, i, n, s) {
4315  if (!Dt(e) || e.__v_raw && !(t && e.__v_isReactive))
4316    return e;
4317  const r = s.get(e);
4318  if (r)
4319    return r;
4320  const o = A1(e);
4321  if (o === 0)
4322    return e;
4323  const a = new Proxy(
4324    e,
4325    o === 2 ? n : i
4326  );
4327  return s.set(e, a), a;
4328}
4329function gs(e) {
4330  return mr(e) ? gs(e.__v_raw) : !!(e && e.__v_isReactive);
4331}
4332function mr(e) {
4333  return !!(e && e.__v_isReadonly);
4334}
4335function Tl(e) {
4336  return !!(e && e.__v_isShallow);
4337}
4338function Pf(e) {
4339  return gs(e) || mr(e);
4340}
4341function Tt(e) {
4342  const t = e && e.__v_raw;
4343  return t ? Tt(t) : e;
4344}
4345function Is(e) {
4346  return ko(e, "__v_skip", !0), e;
4347}
4348const Ch = (e) => Dt(e) ? fa(e) : e, Mh = (e) => Dt(e) ? Rf(e) : e;
4349function F1(e) {
4350  Hi && Xe && (e = Tt(e), Cf(e.dep || (e.dep = _h())));
4351}
4352function k1(e, t) {
4353  e = Tt(e);
4354  const i = e.dep;
4355  i && Sl(i);
4356}
4357function pe(e) {
4358  return !!(e && e.__v_isRef === !0);
4359}
4360function D1(e) {
4361  return pe(e) ? e.value : e;
4362}
4363const N1 = {
4364  get: (e, t, i) => D1(Reflect.get(e, t, i)),
4365  set: (e, t, i, n) => {
4366    const s = e[t];
4367    return pe(s) && !pe(i) ? (s.value = i, !0) : Reflect.set(e, t, i, n);
4368  }
4369};
4370function Lf(e) {
4371  return gs(e) ? e : new Proxy(e, N1);
4372}
4373class G1 {
4374  constructor(t, i, n, s) {
4375    this._setter = i, this.dep = void 0, this.__v_isRef = !0, this.__v_isReadonly = !1, this._dirty = !0, this.effect = new ph(t, () => {
4376      this._dirty || (this._dirty = !0, k1(this));
4377    }), this.effect.computed = this, this.effect.active = this._cacheable = !s, this.__v_isReadonly = n;
4378  }
4379  get value() {
4380    const t = Tt(this);
4381    return F1(t), (t._dirty || !t._cacheable) && (t._dirty = !1, t._value = t.effect.run()), t._value;
4382  }
4383  set value(t) {
4384    this._setter(t);
4385  }
4386}
4387function z1(e, t, i = !1) {
4388  let n, s;
4389  const r = dt(e);
4390  return r ? (n = e, s = qe) : (n = e.get, s = e.set), new G1(n, s, r || !s, i);
4391}
4392function Zi(e, t, i, n) {
4393  let s;
4394  try {
4395    s = n ? e(...n) : e();
4396  } catch (r) {
4397    ga(r, t, i);
4398  }
4399  return s;
4400}
4401function He(e, t, i, n) {
4402  if (dt(e)) {
4403    const r = Zi(e, t, i, n);
4404    return r && ff(r) && r.catch((o) => {
4405      ga(o, t, i);
4406    }), r;
4407  }
4408  const s = [];
4409  for (let r = 0; r < e.length; r++)
4410    s.push(He(e[r], t, i, n));
4411  return s;
4412}
4413function ga(e, t, i, n = !0) {
4414  const s = t ? t.vnode : null;
4415  if (t) {
4416    let r = t.parent;
4417    const o = t.proxy, a = i;
4418    for (; r; ) {
4419      const h = r.ec;
4420      if (h) {
4421        for (let c = 0; c < h.length; c++)
4422          if (h[c](e, o, a) === !1)
4423            return;
4424      }
4425      r = r.parent;
4426    }
4427    const l = t.appContext.config.errorHandler;
4428    if (l) {
4429      Zi(
4430        l,
4431        null,
4432        10,
4433        [e, o, a]
4434      );
4435      return;
4436    }
4437  }
4438}
4439let _r = !1, Il = !1;
4440const oe = [];
4441let si = 0;
4442const ms = [];
4443let vi = null, _n = 0;
4444const Af = /* @__PURE__ */ Promise.resolve();
4445let bh = null;
4446function Of(e) {
4447  const t = bh || Af;
4448  return e ? t.then(this ? e.bind(this) : e) : t;
4449}
4450function j1(e) {
4451  let t = si + 1, i = oe.length;
4452  for (; t < i; ) {
4453    const n = t + i >>> 1;
4454    pr(oe[n]) < e ? t = n + 1 : i = n;
4455  }
4456  return t;
4457}
4458function wh(e) {
4459  (!oe.length || !oe.includes(
4460    e,
4461    _r && e.allowRecurse ? si + 1 : si
4462  )) && (e.id == null ? oe.push(e) : oe.splice(j1(e.id), 0, e), Ff());
4463}
4464function Ff() {
4465  !_r && !Il && (Il = !0, bh = Af.then(Df));
4466}
4467function W1(e) {
4468  const t = oe.indexOf(e);
4469  t > si && oe.splice(t, 1);
4470}
4471function B1(e) {
4472  nt(e) ? ms.push(...e) : (!vi || !vi.includes(
4473    e,
4474    e.allowRecurse ? _n + 1 : _n
4475  )) && ms.push(e), Ff();
4476}
4477function lu(e, t = _r ? si + 1 : 0) {
4478  for (; t < oe.length; t++) {
4479    const i = oe[t];
4480    i && i.pre && (oe.splice(t, 1), t--, i());
4481  }
4482}
4483function kf(e) {
4484  if (ms.length) {
4485    const t = [...new Set(ms)];
4486    if (ms.length = 0, vi) {
4487      vi.push(...t);
4488      return;
4489    }
4490    for (vi = t, vi.sort((i, n) => pr(i) - pr(n)), _n = 0; _n < vi.length; _n++)
4491      vi[_n]();
4492    vi = null, _n = 0;
4493  }
4494}
4495const pr = (e) => e.id == null ? 1 / 0 : e.id, U1 = (e, t) => {
4496  const i = pr(e) - pr(t);
4497  if (i === 0) {
4498    if (e.pre && !t.pre)
4499      return -1;
4500    if (t.pre && !e.pre)
4501      return 1;
4502  }
4503  return i;
4504};
4505function Df(e) {
4506  Il = !1, _r = !0, oe.sort(U1);
4507  const t = qe;
4508  try {
4509    for (si = 0; si < oe.length; si++) {
4510      const i = oe[si];
4511      i && i.active !== !1 && Zi(i, null, 14);
4512    }
4513  } finally {
4514    si = 0, oe.length = 0, kf(), _r = !1, bh = null, (oe.length || ms.length) && Df();
4515  }
4516}
4517function X1(e, t, ...i) {
4518  if (e.isUnmounted)
4519    return;
4520  const n = e.vnode.props || At;
4521  let s = i;
4522  const r = t.startsWith("update:"), o = r && t.slice(7);
4523  if (o && o in n) {
4524    const c = `${o === "modelValue" ? "model" : o}Modifiers`, { number: u, trim: d } = n[c] || At;
4525    d && (s = i.map((f) => Xt(f) ? f.trim() : f)), u && (s = i.map(Zx));
4526  }
4527  let a, l = n[a = Fa(t)] || // also try camelCase event handler (#2249)
4528  n[a = Fa(wi(t))];
4529  !l && r && (l = n[a = Fa(Be(t))]), l && He(
4530    l,
4531    e,
4532    6,
4533    s
4534  );
4535  const h = n[a + "Once"];
4536  if (h) {
4537    if (!e.emitted)
4538      e.emitted = {};
4539    else if (e.emitted[a])
4540      return;
4541    e.emitted[a] = !0, He(
4542      h,
4543      e,
4544      6,
4545      s
4546    );
4547  }
4548}
4549function Nf(e, t, i = !1) {
4550  const n = t.emitsCache, s = n.get(e);
4551  if (s !== void 0)
4552    return s;
4553  const r = e.emits;
4554  let o = {}, a = !1;
4555  if (!dt(e)) {
4556    const l = (h) => {
4557      const c = Nf(h, t, !0);
4558      c && (a = !0, Ut(o, c));
4559    };
4560    !i && t.mixins.length && t.mixins.forEach(l), e.extends && l(e.extends), e.mixins && e.mixins.forEach(l);
4561  }
4562  return !r && !a ? (Dt(e) && n.set(e, null), null) : (nt(r) ? r.forEach((l) => o[l] = null) : Ut(o, r), Dt(e) && n.set(e, o), o);
4563}
4564function ma(e, t) {
4565  return !e || !ha(t) ? !1 : (t = t.slice(2).replace(/Once$/, ""), yt(e, t[0].toLowerCase() + t.slice(1)) || yt(e, Be(t)) || yt(e, t));
4566}
4567let Ee = null, Gf = null;
4568function Do(e) {
4569  const t = Ee;
4570  return Ee = e, Gf = e && e.type.__scopeId || null, t;
4571}
4572function $1(e, t = Ee, i) {
4573  if (!t || e._n)
4574    return e;
4575  const n = (...s) => {
4576    n._d && yu(-1);
4577    const r = Do(t);
4578    let o;
4579    try {
4580      o = e(...s);
4581    } finally {
4582      Do(r), n._d && yu(1);
4583    }
4584    return o;
4585  };
4586  return n._n = !0, n._c = !0, n._d = !0, n;
4587}
4588function Da(e) {
4589  const {
4590    type: t,
4591    vnode: i,
4592    proxy: n,
4593    withProxy: s,
4594    props: r,
4595    propsOptions: [o],
4596    slots: a,
4597    attrs: l,
4598    emit: h,
4599    render: c,
4600    renderCache: u,
4601    data: d,
4602    setupState: f,
4603    ctx: g,
4604    inheritAttrs: m
4605  } = e;
4606  let _, p;
4607  const y = Do(e);
4608  try {
4609    if (i.shapeFlag & 4) {
4610      const E = s || n;
4611      _ = ni(
4612        c.call(
4613          E,
4614          E,
4615          u,
4616          r,
4617          f,
4618          d,
4619          g
4620        )
4621      ), p = l;
4622    } else {
4623      const E = t;
4624      _ = ni(
4625        E.length > 1 ? E(
4626          r,
4627          { attrs: l, slots: a, emit: h }
4628        ) : E(
4629          r,
4630          null
4631          /* we know it doesn't need it */
4632        )
4633      ), p = t.props ? l : Y1(l);
4634    }
4635  } catch (E) {
4636    ar.length = 0, ga(E, e, 1), _ = Ze(sn);
4637  }
4638  let x = _;
4639  if (p && m !== !1) {
4640    const E = Object.keys(p), { shapeFlag: M } = x;
4641    E.length && M & 7 && (o && E.some(dh) && (p = K1(
4642      p,
4643      o
4644    )), x = Rs(x, p));
4645  }
4646  return i.dirs && (x = Rs(x), x.dirs = x.dirs ? x.dirs.concat(i.dirs) : i.dirs), i.transition && (x.transition = i.transition), _ = x, Do(y), _;
4647}
4648const Y1 = (e) => {
4649  let t;
4650  for (const i in e)
4651    (i === "class" || i === "style" || ha(i)) && ((t || (t = {}))[i] = e[i]);
4652  return t;
4653}, K1 = (e, t) => {
4654  const i = {};
4655  for (const n in e)
4656    (!dh(n) || !(n.slice(9) in t)) && (i[n] = e[n]);
4657  return i;
4658};
4659function V1(e, t, i) {
4660  const { props: n, children: s, component: r } = e, { props: o, children: a, patchFlag: l } = t, h = r.emitsOptions;
4661  if (t.dirs || t.transition)
4662    return !0;
4663  if (i && l >= 0) {
4664    if (l & 1024)
4665      return !0;
4666    if (l & 16)
4667      return n ? hu(n, o, h) : !!o;
4668    if (l & 8) {
4669      const c = t.dynamicProps;
4670      for (let u = 0; u < c.length; u++) {
4671        const d = c[u];
4672        if (o[d] !== n[d] && !ma(h, d))
4673          return !0;
4674      }
4675    }
4676  } else
4677    return (s || a) && (!a || !a.$stable) ? !0 : n === o ? !1 : n ? o ? hu(n, o, h) : !0 : !!o;
4678  return !1;
4679}
4680function hu(e, t, i) {
4681  const n = Object.keys(t);
4682  if (n.length !== Object.keys(e).length)
4683    return !0;
4684  for (let s = 0; s < n.length; s++) {
4685    const r = n[s];
4686    if (t[r] !== e[r] && !ma(i, r))
4687      return !0;
4688  }
4689  return !1;
4690}
4691function q1({ vnode: e, parent: t }, i) {
4692  for (; t && t.subTree === e; )
4693    (e = t.vnode).el = i, t = t.parent;
4694}
4695const H1 = (e) => e.__isSuspense;
4696function Z1(e, t) {
4697  t && t.pendingBranch ? nt(e) ? t.effects.push(...e) : t.effects.push(e) : B1(e);
4698}
4699const io = {};
4700function Na(e, t, i) {
4701  return zf(e, t, i);
4702}
4703function zf(e, t, { immediate: i, deep: n, flush: s, onTrack: r, onTrigger: o } = At) {
4704  var a;
4705  const l = o1() === ((a = ae) == null ? void 0 : a.scope) ? ae : null;
4706  let h, c = !1, u = !1;
4707  if (pe(e) ? (h = () => e.value, c = Tl(e)) : gs(e) ? (h = () => e, n = !0) : nt(e) ? (u = !0, c = e.some((E) => gs(E) || Tl(E)), h = () => e.map((E) => {
4708    if (pe(E))
4709      return E.value;
4710    if (gs(E))
4711      return rs(E);
4712    if (dt(E))
4713      return Zi(E, l, 2);
4714  })) : dt(e) ? t ? h = () => Zi(e, l, 2) : h = () => {
4715    if (!(l && l.isUnmounted))
4716      return d && d(), He(
4717        e,
4718        l,
4719        3,
4720        [f]
4721      );
4722  } : h = qe, t && n) {
4723    const E = h;
4724    h = () => rs(E());
4725  }
4726  let d, f = (E) => {
4727    d = y.onStop = () => {
4728      Zi(E, l, 4);
4729    };
4730  }, g;
4731  if (xr)
4732    if (f = qe, t ? i && He(t, l, 3, [
4733      h(),
4734      u ? [] : void 0,
4735      f
4736    ]) : h(), s === "sync") {
4737      const E = $v();
4738      g = E.__watcherHandles || (E.__watcherHandles = []);
4739    } else
4740      return qe;
4741  let m = u ? new Array(e.length).fill(io) : io;
4742  const _ = () => {
4743    if (y.active)
4744      if (t) {
4745        const E = y.run();
4746        (n || c || (u ? E.some(
4747          (M, w) => Fo(M, m[w])
4748        ) : Fo(E, m))) && (d && d(), He(t, l, 3, [
4749          E,
4750          // pass undefined as the old value when it's changed for the first time
4751          m === io ? void 0 : u && m[0] === io ? [] : m,
4752          f
4753        ]), m = E);
4754      } else
4755        y.run();
4756  };
4757  _.allowRecurse = !!t;
4758  let p;
4759  s === "sync" ? p = _ : s === "post" ? p = () => ve(_, l && l.suspense) : (_.pre = !0, l && (_.id = l.uid), p = () => wh(_));
4760  const y = new ph(h, p);
4761  t ? i ? _() : m = y.run() : s === "post" ? ve(
4762    y.run.bind(y),
4763    l && l.suspense
4764  ) : y.run();
4765  const x = () => {
4766    y.stop(), l && l.scope && fh(l.scope.effects, y);
4767  };
4768  return g && g.push(x), x;
4769}
4770function J1(e, t, i) {
4771  const n = this.proxy, s = Xt(e) ? e.includes(".") ? jf(n, e) : () => n[e] : e.bind(n, n);
4772  let r;
4773  dt(t) ? r = t : (r = t.handler, i = t);
4774  const o = ae;
4775  Ps(this);
4776  const a = zf(s, r.bind(n), i);
4777  return o ? Ps(o) : bn(), a;
4778}
4779function jf(e, t) {
4780  const i = t.split(".");
4781  return () => {
4782    let n = e;
4783    for (let s = 0; s < i.length && n; s++)
4784      n = n[i[s]];
4785    return n;
4786  };
4787}
4788function rs(e, t) {
4789  if (!Dt(e) || e.__v_skip || (t = t || /* @__PURE__ */ new Set(), t.has(e)))
4790    return e;
4791  if (t.add(e), pe(e))
4792    rs(e.value, t);
4793  else if (nt(e))
4794    for (let i = 0; i < e.length; i++)
4795      rs(e[i], t);
4796  else if (df(e) || fs(e))
4797    e.forEach((i) => {
4798      rs(i, t);
4799    });
4800  else if (mf(e))
4801    for (const i in e)
4802      rs(e[i], t);
4803  return e;
4804}
4805function dn(e, t, i, n) {
4806  const s = e.dirs, r = t && t.dirs;
4807  for (let o = 0; o < s.length; o++) {
4808    const a = s[o];
4809    r && (a.oldValue = r[o].value);
4810    let l = a.dir[n];
4811    l && (Gs(), He(l, i, 8, [
4812      e.el,
4813      a,
4814      e,
4815      t
4816    ]), zs());
4817  }
4818}
4819function Q1(e, t) {
4820  return dt(e) ? (
4821    // #8326: extend call and options.name access are considered side-effects
4822    // by Rollup, so we have to wrap it in a pure-annotated IIFE.
4823    /* @__PURE__ */ (() => Ut({ name: e.name }, t, { setup: e }))()
4824  ) : e;
4825}
4826const rr = (e) => !!e.type.__asyncLoader, Wf = (e) => e.type.__isKeepAlive;
4827function tv(e, t) {
4828  Bf(e, "a", t);
4829}
4830function ev(e, t) {
4831  Bf(e, "da", t);
4832}
4833function Bf(e, t, i = ae) {
4834  const n = e.__wdc || (e.__wdc = () => {
4835    let s = i;
4836    for (; s; ) {
4837      if (s.isDeactivated)
4838        return;
4839      s = s.parent;
4840    }
4841    return e();
4842  });
4843  if (_a(t, n, i), i) {
4844    let s = i.parent;
4845    for (; s && s.parent; )
4846      Wf(s.parent.vnode) && iv(n, t, i, s), s = s.parent;
4847  }
4848}
4849function iv(e, t, i, n) {
4850  const s = _a(
4851    t,
4852    e,
4853    n,
4854    !0
4855    /* prepend */
4856  );
4857  Uf(() => {
4858    fh(n[t], s);
4859  }, i);
4860}
4861function _a(e, t, i = ae, n = !1) {
4862  if (i) {
4863    const s = i[e] || (i[e] = []), r = t.__weh || (t.__weh = (...o) => {
4864      if (i.isUnmounted)
4865        return;
4866      Gs(), Ps(i);
4867      const a = He(t, i, e, o);
4868      return bn(), zs(), a;
4869    });
4870    return n ? s.unshift(r) : s.push(r), r;
4871  }
4872}
4873const Ri = (e) => (t, i = ae) => (
4874  // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4875  (!xr || e === "sp") && _a(e, (...n) => t(...n), i)
4876), nv = Ri("bm"), sv = Ri("m"), rv = Ri("bu"), ov = Ri("u"), av = Ri("bum"), Uf = Ri("um"), lv = Ri("sp"), hv = Ri(
4877  "rtg"
4878), cv = Ri(
4879  "rtc"
4880);
4881function uv(e, t = ae) {
4882  _a("ec", e, t);
4883}
4884const dv = Symbol.for("v-ndc");
4885function _s(e, t, i, n) {
4886  let s;
4887  const r = i && i[n];
4888  if (nt(e) || Xt(e)) {
4889    s = new Array(e.length);
4890    for (let o = 0, a = e.length; o < a; o++)
4891      s[o] = t(e[o], o, void 0, r && r[o]);
4892  } else if (typeof e == "number") {
4893    s = new Array(e);
4894    for (let o = 0; o < e; o++)
4895      s[o] = t(o + 1, o, void 0, r && r[o]);
4896  } else if (Dt(e))
4897    if (e[Symbol.iterator])
4898      s = Array.from(
4899        e,
4900        (o, a) => t(o, a, void 0, r && r[a])
4901      );
4902    else {
4903      const o = Object.keys(e);
4904      s = new Array(o.length);
4905      for (let a = 0, l = o.length; a < l; a++) {
4906        const h = o[a];
4907        s[a] = t(e[h], h, a, r && r[a]);
4908      }
4909    }
4910  else
4911    s = [];
4912  return i && (i[n] = s), s;
4913}
4914function Xf(e, t, i = {}, n, s) {
4915  if (Ee.isCE || Ee.parent && rr(Ee.parent) && Ee.parent.isCE)
4916    return t !== "default" && (i.name = t), Ze("slot", i, n && n());
4917  let r = e[t];
4918  r && r._c && (r._d = !1), it();
4919  const o = r && $f(r(i)), a = eg(
4920    jt,
4921    {
4922      key: i.key || // slot content array of a dynamic conditional slot may have a branch
4923      // key attached in the `createSlots` helper, respect that
4924      o && o.key || `_${t}`
4925    },
4926    o || (n ? n() : []),
4927    o && e._ === 1 ? 64 : -2
4928  );
4929  return !s && a.scopeId && (a.slotScopeIds = [a.scopeId + "-s"]), r && r._c && (r._d = !0), a;
4930}
4931function $f(e) {
4932  return e.some((t) => ig(t) ? !(t.type === sn || t.type === jt && !$f(t.children)) : !0) ? e : null;
4933}
4934const Rl = (e) => e ? rg(e) ? Ph(e) || e.proxy : Rl(e.parent) : null, or = (
4935  // Move PURE marker to new line to workaround compiler discarding it
4936  // due to type annotation
4937  /* @__PURE__ */ Ut(/* @__PURE__ */ Object.create(null), {
4938    $: (e) => e,
4939    $el: (e) => e.vnode.el,
4940    $data: (e) => e.data,
4941    $props: (e) => e.props,
4942    $attrs: (e) => e.attrs,
4943    $slots: (e) => e.slots,
4944    $refs: (e) => e.refs,
4945    $parent: (e) => Rl(e.parent),
4946    $root: (e) => Rl(e.root),
4947    $emit: (e) => e.emit,
4948    $options: (e) => Sh(e),
4949    $forceUpdate: (e) => e.f || (e.f = () => wh(e.update)),
4950    $nextTick: (e) => e.n || (e.n = Of.bind(e.proxy)),
4951    $watch: (e) => J1.bind(e)
4952  })
4953), Ga = (e, t) => e !== At && !e.__isScriptSetup && yt(e, t), fv = {
4954  get({ _: e }, t) {
4955    const { ctx: i, setupState: n, data: s, props: r, accessCache: o, type: a, appContext: l } = e;
4956    let h;
4957    if (t[0] !== "$") {
4958      const f = o[t];
4959      if (f !== void 0)
4960        switch (f) {
4961          case 1:
4962            return n[t];
4963          case 2:
4964            return s[t];
4965          case 4:
4966            return i[t];
4967          case 3:
4968            return r[t];
4969        }
4970      else {
4971        if (Ga(n, t))
4972          return o[t] = 1, n[t];
4973        if (s !== At && yt(s, t))
4974          return o[t] = 2, s[t];
4975        if (
4976          // only cache other properties when instance has declared (thus stable)
4977          // props
4978          (h = e.propsOptions[0]) && yt(h, t)
4979        )
4980          return o[t] = 3, r[t];
4981        if (i !== At && yt(i, t))
4982          return o[t] = 4, i[t];
4983        Pl && (o[t] = 0);
4984      }
4985    }
4986    const c = or[t];
4987    let u, d;
4988    if (c)
4989      return t === "$attrs" && we(e, "get", t), c(e);
4990    if (
4991      // css module (injected by vue-loader)
4992      (u = a.__cssModules) && (u = u[t])
4993    )
4994      return u;
4995    if (i !== At && yt(i, t))
4996      return o[t] = 4, i[t];
4997    if (
4998      // global properties
4999      d = l.config.globalProperties, yt(d, t)
5000    )
5001      return d[t];
5002  },
5003  set({ _: e }, t, i) {
5004    const { data: n, setupState: s, ctx: r } = e;
5005    return Ga(s, t) ? (s[t] = i, !0) : n !== At && yt(n, t) ? (n[t] = i, !0) : yt(e.props, t) || t[0] === "$" && t.slice(1) in e ? !1 : (r[t] = i, !0);
5006  },
5007  has({
5008    _: { data: e, setupState: t, accessCache: i, ctx: n, appContext: s, propsOptions: r }
5009  }, o) {
5010    let a;
5011    return !!i[o] || e !== At && yt(e, o) || Ga(t, o) || (a = r[0]) && yt(a, o) || yt(n, o) || yt(or, o) || yt(s.config.globalProperties, o);
5012  },
5013  defineProperty(e, t, i) {
5014    return i.get != null ? e._.accessCache[t] = 0 : yt(i, "value") && this.set(e, t, i.value, null), Reflect.defineProperty(e, t, i);
5015  }
5016};
5017function cu(e) {
5018  return nt(e) ? e.reduce(
5019    (t, i) => (t[i] = null, t),
5020    {}
5021  ) : e;
5022}
5023let Pl = !0;
vendor: 4,746 bytes, lines 5024-5229
5024function gv(e) {
5025  const t = Sh(e), i = e.proxy, n = e.ctx;
5026  Pl = !1, t.beforeCreate && uu(t.beforeCreate, e, "bc");
5027  const {
5028    // state
5029    data: s,
5030    computed: r,
5031    methods: o,
5032    watch: a,
5033    provide: l,
5034    inject: h,
5035    // lifecycle
5036    created: c,
5037    beforeMount: u,
5038    mounted: d,
5039    beforeUpdate: f,
5040    updated: g,
5041    activated: m,
5042    deactivated: _,
5043    beforeDestroy: p,
5044    beforeUnmount: y,
5045    destroyed: x,
5046    unmounted: E,
5047    render: M,
5048    renderTracked: w,
5049    renderTriggered: L,
5050    errorCaptured: I,
5051    serverPrefetch: z,
5052    // public API
5053    expose: U,
5054    inheritAttrs: q,
5055    // assets
5056    components: K,
5057    directives: Z,
5058    filters: Mt
5059  } = t;
5060  if (h && mv(h, n, null), o)
5061    for (const O in o) {
5062      const W = o[O];
5063      dt(W) && (n[O] = W.bind(i));
5064    }
5065  if (s) {
5066    const O = s.call(i, i);
5067    Dt(O) && (e.data = fa(O));
5068  }
5069  if (Pl = !0, r)
5070    for (const O in r) {
5071      const W = r[O], gt = dt(W) ? W.bind(i, i) : dt(W.get) ? W.get.bind(i, i) : qe, _t = !dt(W) && dt(W.set) ? W.set.bind(i) : qe, Pt = Uv({
5072        get: gt,
5073        set: _t
5074      });
5075      Object.defineProperty(n, O, {
5076        enumerable: !0,
5077        configurable: !0,
5078        get: () => Pt.value,
5079        set: (R) => Pt.value = R
5080      });
5081    }
5082  if (a)
5083    for (const O in a)
5084      Yf(a[O], n, i, O);
5085  if (l) {
5086    const O = dt(l) ? l.call(i) : l;
5087    Reflect.ownKeys(O).forEach((W) => {
5088      Ev(W, O[W]);
5089    });
5090  }
5091  c && uu(c, e, "c");
5092  function Y(O, W) {
5093    nt(W) ? W.forEach((gt) => O(gt.bind(i))) : W && O(W.bind(i));
5094  }
5095  if (Y(nv, u), Y(sv, d), Y(rv, f), Y(ov, g), Y(tv, m), Y(ev, _), Y(uv, I), Y(cv, w), Y(hv, L), Y(av, y), Y(Uf, E), Y(lv, z), nt(U))
5096    if (U.length) {
5097      const O = e.exposed || (e.exposed = {});
5098      U.forEach((W) => {
5099        Object.defineProperty(O, W, {
5100          get: () => i[W],
5101          set: (gt) => i[W] = gt
5102        });
5103      });
5104    } else
5105      e.exposed || (e.exposed = {});
5106  M && e.render === qe && (e.render = M), q != null && (e.inheritAttrs = q), K && (e.components = K), Z && (e.directives = Z);
5107}
5108function mv(e, t, i = qe) {
5109  nt(e) && (e = Ll(e));
5110  for (const n in e) {
5111    const s = e[n];
5112    let r;
5113    Dt(s) ? "default" in s ? r = wo(
5114      s.from || n,
5115      s.default,
5116      !0
5117      /* treat default function as factory */
5118    ) : r = wo(s.from || n) : r = wo(s), pe(r) ? Object.defineProperty(t, n, {
5119      enumerable: !0,
5120      configurable: !0,
5121      get: () => r.value,
5122      set: (o) => r.value = o
5123    }) : t[n] = r;
5124  }
5125}
5126function uu(e, t, i) {
5127  He(
5128    nt(e) ? e.map((n) => n.bind(t.proxy)) : e.bind(t.proxy),
5129    t,
5130    i
5131  );
5132}
5133function Yf(e, t, i, n) {
5134  const s = n.includes(".") ? jf(i, n) : () => i[n];
5135  if (Xt(e)) {
5136    const r = t[e];
5137    dt(r) && Na(s, r);
5138  } else if (dt(e))
5139    Na(s, e.bind(i));
5140  else if (Dt(e))
5141    if (nt(e))
5142      e.forEach((r) => Yf(r, t, i, n));
5143    else {
5144      const r = dt(e.handler) ? e.handler.bind(i) : t[e.handler];
5145      dt(r) && Na(s, r, e);
5146    }
5147}
5148function Sh(e) {
5149  const t = e.type, { mixins: i, extends: n } = t, {
5150    mixins: s,
5151    optionsCache: r,
5152    config: { optionMergeStrategies: o }
5153  } = e.appContext, a = r.get(t);
5154  let l;
5155  return a ? l = a : !s.length && !i && !n ? l = t : (l = {}, s.length && s.forEach(
5156    (h) => No(l, h, o, !0)
5157  ), No(l, t, o)), Dt(t) && r.set(t, l), l;
5158}
5159function No(e, t, i, n = !1) {
5160  const { mixins: s, extends: r } = t;
5161  r && No(e, r, i, !0), s && s.forEach(
5162    (o) => No(e, o, i, !0)
5163  );
5164  for (const o in t)
5165    if (!(n && o === "expose")) {
5166      const a = _v[o] || i && i[o];
5167      e[o] = a ? a(e[o], t[o]) : t[o];
5168    }
5169  return e;
5170}
5171const _v = {
5172  data: du,
5173  props: fu,
5174  emits: fu,
5175  // objects
5176  methods: tr,
5177  computed: tr,
5178  // lifecycle
5179  beforeCreate: ue,
5180  created: ue,
5181  beforeMount: ue,
5182  mounted: ue,
5183  beforeUpdate: ue,
5184  updated: ue,
5185  beforeDestroy: ue,
5186  beforeUnmount: ue,
5187  destroyed: ue,
5188  unmounted: ue,
5189  activated: ue,
5190  deactivated: ue,
5191  errorCaptured: ue,
5192  serverPrefetch: ue,
5193  // assets
5194  components: tr,
5195  directives: tr,
5196  // watch
5197  watch: yv,
5198  // provide / inject
5199  provide: du,
5200  inject: pv
5201};
5202function du(e, t) {
5203  return t ? e ? function() {
5204    return Ut(
5205      dt(e) ? e.call(this, this) : e,
5206      dt(t) ? t.call(this, this) : t
5207    );
5208  } : t : e;
5209}
5210function pv(e, t) {
5211  return tr(Ll(e), Ll(t));
5212}
5213function Ll(e) {
5214  if (nt(e)) {
5215    const t = {};
5216    for (let i = 0; i < e.length; i++)
5217      t[e[i]] = e[i];
5218    return t;
5219  }
5220  return e;
5221}
5222function ue(e, t) {
5223  return e ? [...new Set([].concat(e, t))] : t;
5224}
5225function tr(e, t) {
5226  return e ? Ut(/* @__PURE__ */ Object.create(null), e, t) : t;
5227}
5228function fu(e, t) {
5229  return e ? nt(e) && nt(t) ? [.../* @__PURE__ */ new Set([...e, ...t])] : Ut(
vendor: 45,702 bytes, lines 5230-7081
5230    /* @__PURE__ */ Object.create(null),
5231    cu(e),
5232    cu(t ?? {})
5233  ) : t;
5234}
5235function yv(e, t) {
5236  if (!e)
5237    return t;
5238  if (!t)
5239    return e;
5240  const i = Ut(/* @__PURE__ */ Object.create(null), e);
5241  for (const n in t)
5242    i[n] = ue(e[n], t[n]);
5243  return i;
5244}
5245function Kf() {
5246  return {
5247    app: null,
5248    config: {
5249      isNativeTag: $x,
5250      performance: !1,
5251      globalProperties: {},
5252      optionMergeStrategies: {},
5253      errorHandler: void 0,
5254      warnHandler: void 0,
5255      compilerOptions: {}
5256    },
5257    mixins: [],
5258    components: {},
5259    directives: {},
5260    provides: /* @__PURE__ */ Object.create(null),
5261    optionsCache: /* @__PURE__ */ new WeakMap(),
5262    propsCache: /* @__PURE__ */ new WeakMap(),
5263    emitsCache: /* @__PURE__ */ new WeakMap()
5264  };
5265}
5266let xv = 0;
5267function vv(e, t) {
5268  return function(n, s = null) {
5269    dt(n) || (n = Ut({}, n)), s != null && !Dt(s) && (s = null);
5270    const r = Kf(), o = /* @__PURE__ */ new Set();
5271    let a = !1;
5272    const l = r.app = {
5273      _uid: xv++,
5274      _component: n,
5275      _props: s,
5276      _container: null,
5277      _context: r,
5278      _instance: null,
5279      version: Yv,
5280      get config() {
5281        return r.config;
5282      },
5283      set config(h) {
5284      },
5285      use(h, ...c) {
5286        return o.has(h) || (h && dt(h.install) ? (o.add(h), h.install(l, ...c)) : dt(h) && (o.add(h), h(l, ...c))), l;
5287      },
5288      mixin(h) {
5289        return r.mixins.includes(h) || r.mixins.push(h), l;
5290      },
5291      component(h, c) {
5292        return c ? (r.components[h] = c, l) : r.components[h];
5293      },
5294      directive(h, c) {
5295        return c ? (r.directives[h] = c, l) : r.directives[h];
5296      },
5297      mount(h, c, u) {
5298        if (!a) {
5299          const d = Ze(
5300            n,
5301            s
5302          );
5303          return d.appContext = r, c && t ? t(d, h) : e(d, h, u), a = !0, l._container = h, h.__vue_app__ = l, Ph(d.component) || d.component.proxy;
5304        }
5305      },
5306      unmount() {
5307        a && (e(null, l._container), delete l._container.__vue_app__);
5308      },
5309      provide(h, c) {
5310        return r.provides[h] = c, l;
5311      },
5312      runWithContext(h) {
5313        Go = l;
5314        try {
5315          return h();
5316        } finally {
5317          Go = null;
5318        }
5319      }
5320    };
5321    return l;
5322  };
5323}
5324let Go = null;
5325function Ev(e, t) {
5326  if (ae) {
5327    let i = ae.provides;
5328    const n = ae.parent && ae.parent.provides;
5329    n === i && (i = ae.provides = Object.create(n)), i[e] = t;
5330  }
5331}
5332function wo(e, t, i = !1) {
5333  const n = ae || Ee;
5334  if (n || Go) {
5335    const s = n ? n.parent == null ? n.vnode.appContext && n.vnode.appContext.provides : n.parent.provides : Go._context.provides;
5336    if (s && e in s)
5337      return s[e];
5338    if (arguments.length > 1)
5339      return i && dt(t) ? t.call(n && n.proxy) : t;
5340  }
5341}
5342function Cv(e, t, i, n = !1) {
5343  const s = {}, r = {};
5344  ko(r, ya, 1), e.propsDefaults = /* @__PURE__ */ Object.create(null), Vf(e, t, s, r);
5345  for (const o in e.propsOptions[0])
5346    o in s || (s[o] = void 0);
5347  i ? e.props = n ? s : O1(s) : e.type.props ? e.props = s : e.props = r, e.attrs = r;
5348}
5349function Mv(e, t, i, n) {
5350  const {
5351    props: s,
5352    attrs: r,
5353    vnode: { patchFlag: o }
5354  } = e, a = Tt(s), [l] = e.propsOptions;
5355  let h = !1;
5356  if (
5357    // always force full diff in dev
5358    // - #1942 if hmr is enabled with sfc component
5359    // - vite#872 non-sfc component used by sfc component
5360    (n || o > 0) && !(o & 16)
5361  ) {
5362    if (o & 8) {
5363      const c = e.vnode.dynamicProps;
5364      for (let u = 0; u < c.length; u++) {
5365        let d = c[u];
5366        if (ma(e.emitsOptions, d))
5367          continue;
5368        const f = t[d];
5369        if (l)
5370          if (yt(r, d))
5371            f !== r[d] && (r[d] = f, h = !0);
5372          else {
5373            const g = wi(d);
5374            s[g] = Al(
5375              l,
5376              a,
5377              g,
5378              f,
5379              e,
5380              !1
5381              /* isAbsent */
5382            );
5383          }
5384        else
5385          f !== r[d] && (r[d] = f, h = !0);
5386      }
5387    }
5388  } else {
5389    Vf(e, t, s, r) && (h = !0);
5390    let c;
5391    for (const u in a)
5392      (!t || // for camelCase
5393      !yt(t, u) && // it's possible the original props was passed in as kebab-case
5394      // and converted to camelCase (#955)
5395      ((c = Be(u)) === u || !yt(t, c))) && (l ? i && // for camelCase
5396      (i[u] !== void 0 || // for kebab-case
5397      i[c] !== void 0) && (s[u] = Al(
5398        l,
5399        a,
5400        u,
5401        void 0,
5402        e,
5403        !0
5404        /* isAbsent */
5405      )) : delete s[u]);
5406    if (r !== a)
5407      for (const u in r)
5408        (!t || !yt(t, u)) && (delete r[u], h = !0);
5409  }
5410  h && Ti(e, "set", "$attrs");
5411}
5412function Vf(e, t, i, n) {
5413  const [s, r] = e.propsOptions;
5414  let o = !1, a;
5415  if (t)
5416    for (let l in t) {
5417      if (bo(l))
5418        continue;
5419      const h = t[l];
5420      let c;
5421      s && yt(s, c = wi(l)) ? !r || !r.includes(c) ? i[c] = h : (a || (a = {}))[c] = h : ma(e.emitsOptions, l) || (!(l in n) || h !== n[l]) && (n[l] = h, o = !0);
5422    }
5423  if (r) {
5424    const l = Tt(i), h = a || At;
5425    for (let c = 0; c < r.length; c++) {
5426      const u = r[c];
5427      i[u] = Al(
5428        s,
5429        l,
5430        u,
5431        h[u],
5432        e,
5433        !yt(h, u)
5434      );
5435    }
5436  }
5437  return o;
5438}
5439function Al(e, t, i, n, s, r) {
5440  const o = e[i];
5441  if (o != null) {
5442    const a = yt(o, "default");
5443    if (a && n === void 0) {
5444      const l = o.default;
5445      if (o.type !== Function && !o.skipFactory && dt(l)) {
5446        const { propsDefaults: h } = s;
5447        i in h ? n = h[i] : (Ps(s), n = h[i] = l.call(
5448          null,
5449          t
5450        ), bn());
5451      } else
5452        n = l;
5453    }
5454    o[
5455      0
5456      /* shouldCast */
5457    ] && (r && !a ? n = !1 : o[
5458      1
5459      /* shouldCastTrue */
5460    ] && (n === "" || n === Be(i)) && (n = !0));
5461  }
5462  return n;
5463}
5464function qf(e, t, i = !1) {
5465  const n = t.propsCache, s = n.get(e);
5466  if (s)
5467    return s;
5468  const r = e.props, o = {}, a = [];
5469  let l = !1;
5470  if (!dt(e)) {
5471    const c = (u) => {
5472      l = !0;
5473      const [d, f] = qf(u, t, !0);
5474      Ut(o, d), f && a.push(...f);
5475    };
5476    !i && t.mixins.length && t.mixins.forEach(c), e.extends && c(e.extends), e.mixins && e.mixins.forEach(c);
5477  }
5478  if (!r && !l)
5479    return Dt(e) && n.set(e, ds), ds;
5480  if (nt(r))
5481    for (let c = 0; c < r.length; c++) {
5482      const u = wi(r[c]);
5483      gu(u) && (o[u] = At);
5484    }
5485  else if (r)
5486    for (const c in r) {
5487      const u = wi(c);
5488      if (gu(u)) {
5489        const d = r[c], f = o[u] = nt(d) || dt(d) ? { type: d } : Ut({}, d);
5490        if (f) {
5491          const g = pu(Boolean, f.type), m = pu(String, f.type);
5492          f[
5493            0
5494            /* shouldCast */
5495          ] = g > -1, f[
5496            1
5497            /* shouldCastTrue */
5498          ] = m < 0 || g < m, (g > -1 || yt(f, "default")) && a.push(u);
5499        }
5500      }
5501    }
5502  const h = [o, a];
5503  return Dt(e) && n.set(e, h), h;
5504}
5505function gu(e) {
5506  return e[0] !== "$";
5507}
5508function mu(e) {
5509  const t = e && e.toString().match(/^\s*(function|class) (\w+)/);
5510  return t ? t[2] : e === null ? "null" : "";
5511}
5512function _u(e, t) {
5513  return mu(e) === mu(t);
5514}
5515function pu(e, t) {
5516  return nt(t) ? t.findIndex((i) => _u(i, e)) : dt(t) && _u(t, e) ? 0 : -1;
5517}
5518const Hf = (e) => e[0] === "_" || e === "$stable", Th = (e) => nt(e) ? e.map(ni) : [ni(e)], bv = (e, t, i) => {
5519  if (t._n)
5520    return t;
5521  const n = $1((...s) => Th(t(...s)), i);
5522  return n._c = !1, n;
5523}, Zf = (e, t, i) => {
5524  const n = e._ctx;
5525  for (const s in e) {
5526    if (Hf(s))
5527      continue;
5528    const r = e[s];
5529    if (dt(r))
5530      t[s] = bv(s, r, n);
5531    else if (r != null) {
5532      const o = Th(r);
5533      t[s] = () => o;
5534    }
5535  }
5536}, Jf = (e, t) => {
5537  const i = Th(t);
5538  e.slots.default = () => i;
5539}, wv = (e, t) => {
5540  if (e.vnode.shapeFlag & 32) {
5541    const i = t._;
5542    i ? (e.slots = Tt(t), ko(t, "_", i)) : Zf(
5543      t,
5544      e.slots = {}
5545    );
5546  } else
5547    e.slots = {}, t && Jf(e, t);
5548  ko(e.slots, ya, 1);
5549}, Sv = (e, t, i) => {
5550  const { vnode: n, slots: s } = e;
5551  let r = !0, o = At;
5552  if (n.shapeFlag & 32) {
5553    const a = t._;
5554    a ? i && a === 1 ? r = !1 : (Ut(s, t), !i && a === 1 && delete s._) : (r = !t.$stable, Zf(t, s)), o = t;
5555  } else
5556    t && (Jf(e, t), o = { default: 1 });
5557  if (r)
5558    for (const a in s)
5559      !Hf(a) && !(a in o) && delete s[a];
5560};
5561function Ol(e, t, i, n, s = !1) {
5562  if (nt(e)) {
5563    e.forEach(
5564      (d, f) => Ol(
5565        d,
5566        t && (nt(t) ? t[f] : t),
5567        i,
5568        n,
5569        s
5570      )
5571    );
5572    return;
5573  }
5574  if (rr(n) && !s)
5575    return;
5576  const r = n.shapeFlag & 4 ? Ph(n.component) || n.component.proxy : n.el, o = s ? null : r, { i: a, r: l } = e, h = t && t.r, c = a.refs === At ? a.refs = {} : a.refs, u = a.setupState;
5577  if (h != null && h !== l && (Xt(h) ? (c[h] = null, yt(u, h) && (u[h] = null)) : pe(h) && (h.value = null)), dt(l))
5578    Zi(l, a, 12, [o, c]);
5579  else {
5580    const d = Xt(l), f = pe(l);
5581    if (d || f) {
5582      const g = () => {
5583        if (e.f) {
5584          const m = d ? yt(u, l) ? u[l] : c[l] : l.value;
5585          s ? nt(m) && fh(m, r) : nt(m) ? m.includes(r) || m.push(r) : d ? (c[l] = [r], yt(u, l) && (u[l] = c[l])) : (l.value = [r], e.k && (c[e.k] = l.value));
5586        } else
5587          d ? (c[l] = o, yt(u, l) && (u[l] = o)) : f && (l.value = o, e.k && (c[e.k] = o));
5588      };
5589      o ? (g.id = -1, ve(g, i)) : g();
5590    }
5591  }
5592}
5593const ve = Z1;
5594function Tv(e) {
5595  return Iv(e);
5596}
5597function Iv(e, t) {
5598  const i = Cl();
5599  i.__VUE__ = !0;
5600  const {
5601    insert: n,
5602    remove: s,
5603    patchProp: r,
5604    createElement: o,
5605    createText: a,
5606    createComment: l,
5607    setText: h,
5608    setElementText: c,
5609    parentNode: u,
5610    nextSibling: d,
5611    setScopeId: f = qe,
5612    insertStaticContent: g
5613  } = e, m = (v, C, b, T = null, S = null, k = null, N = !1, F = null, D = !!C.dynamicChildren) => {
5614    if (v === C)
5615      return;
5616    v && !$s(v, C) && (T = ce(v), R(v, S, k, !0), v = null), C.patchFlag === -2 && (D = !1, C.dynamicChildren = null);
5617    const { type: P, ref: B, shapeFlag: j } = C;
5618    switch (P) {
5619      case pa:
5620        _(v, C, b, T);
5621        break;
5622      case sn:
5623        p(v, C, b, T);
5624        break;
5625      case za:
5626        v == null && y(C, b, T, N);
5627        break;
5628      case jt:
5629        K(
5630          v,
5631          C,
5632          b,
5633          T,
5634          S,
5635          k,
5636          N,
5637          F,
5638          D
5639        );
5640        break;
5641      default:
5642        j & 1 ? M(
5643          v,
5644          C,
5645          b,
5646          T,
5647          S,
5648          k,
5649          N,
5650          F,
5651          D
5652        ) : j & 6 ? Z(
5653          v,
5654          C,
5655          b,
5656          T,
5657          S,
5658          k,
5659          N,
5660          F,
5661          D
5662        ) : (j & 64 || j & 128) && P.process(
5663          v,
5664          C,
5665          b,
5666          T,
5667          S,
5668          k,
5669          N,
5670          F,
5671          D,
5672          Qt
5673        );
5674    }
5675    B != null && S && Ol(B, v && v.ref, k, C || v, !C);
5676  }, _ = (v, C, b, T) => {
5677    if (v == null)
5678      n(
5679        C.el = a(C.children),
5680        b,
5681        T
5682      );
5683    else {
5684      const S = C.el = v.el;
5685      C.children !== v.children && h(S, C.children);
5686    }
5687  }, p = (v, C, b, T) => {
5688    v == null ? n(
5689      C.el = l(C.children || ""),
5690      b,
5691      T
5692    ) : C.el = v.el;
5693  }, y = (v, C, b, T) => {
5694    [v.el, v.anchor] = g(
5695      v.children,
5696      C,
5697      b,
5698      T,
5699      v.el,
5700      v.anchor
5701    );
5702  }, x = ({ el: v, anchor: C }, b, T) => {
5703    let S;
5704    for (; v && v !== C; )
5705      S = d(v), n(v, b, T), v = S;
5706    n(C, b, T);
5707  }, E = ({ el: v, anchor: C }) => {
5708    let b;
5709    for (; v && v !== C; )
5710      b = d(v), s(v), v = b;
5711    s(C);
5712  }, M = (v, C, b, T, S, k, N, F, D) => {
5713    N = N || C.type === "svg", v == null ? w(
5714      C,
5715      b,
5716      T,
5717      S,
5718      k,
5719      N,
5720      F,
5721      D
5722    ) : z(
5723      v,
5724      C,
5725      S,
5726      k,
5727      N,
5728      F,
5729      D
5730    );
5731  }, w = (v, C, b, T, S, k, N, F) => {
5732    let D, P;
5733    const { type: B, props: j, shapeFlag: $, transition: H, dirs: ot } = v;
5734    if (D = v.el = o(
5735      v.type,
5736      k,
5737      j && j.is,
5738      j
5739    ), $ & 8 ? c(D, v.children) : $ & 16 && I(
5740      v.children,
5741      D,
5742      null,
5743      T,
5744      S,
5745      k && B !== "foreignObject",
5746      N,
5747      F
5748    ), ot && dn(v, null, T, "created"), L(D, v, v.scopeId, N, T), j) {
5749      for (const ft in j)
5750        ft !== "value" && !bo(ft) && r(
5751          D,
5752          ft,
5753          null,
5754          j[ft],
5755          k,
5756          v.children,
5757          T,
5758          S,
5759          $t
5760        );
5761      "value" in j && r(D, "value", null, j.value), (P = j.onVnodeBeforeMount) && ii(P, T, v);
5762    }
5763    ot && dn(v, null, T, "beforeMount");
5764    const pt = (!S || S && !S.pendingBranch) && H && !H.persisted;
5765    pt && H.beforeEnter(D), n(D, C, b), ((P = j && j.onVnodeMounted) || pt || ot) && ve(() => {
5766      P && ii(P, T, v), pt && H.enter(D), ot && dn(v, null, T, "mounted");
5767    }, S);
5768  }, L = (v, C, b, T, S) => {
5769    if (b && f(v, b), T)
5770      for (let k = 0; k < T.length; k++)
5771        f(v, T[k]);
5772    if (S) {
5773      let k = S.subTree;
5774      if (C === k) {
5775        const N = S.vnode;
5776        L(
5777          v,
5778          N,
5779          N.scopeId,
5780          N.slotScopeIds,
5781          S.parent
5782        );
5783      }
5784    }
5785  }, I = (v, C, b, T, S, k, N, F, D = 0) => {
5786    for (let P = D; P < v.length; P++) {
5787      const B = v[P] = F ? zi(v[P]) : ni(v[P]);
5788      m(
5789        null,
5790        B,
5791        C,
5792        b,
5793        T,
5794        S,
5795        k,
5796        N,
5797        F
5798      );
5799    }
5800  }, z = (v, C, b, T, S, k, N) => {
5801    const F = C.el = v.el;
5802    let { patchFlag: D, dynamicChildren: P, dirs: B } = C;
5803    D |= v.patchFlag & 16;
5804    const j = v.props || At, $ = C.props || At;
5805    let H;
5806    b && fn(b, !1), (H = $.onVnodeBeforeUpdate) && ii(H, b, C, v), B && dn(C, v, b, "beforeUpdate"), b && fn(b, !0);
5807    const ot = S && C.type !== "foreignObject";
5808    if (P ? U(
5809      v.dynamicChildren,
5810      P,
5811      F,
5812      b,
5813      T,
5814      ot,
5815      k
5816    ) : N || W(
5817      v,
5818      C,
5819      F,
5820      null,
5821      b,
5822      T,
5823      ot,
5824      k,
5825      !1
5826    ), D > 0) {
5827      if (D & 16)
5828        q(
5829          F,
5830          C,
5831          j,
5832          $,
5833          b,
5834          T,
5835          S
5836        );
5837      else if (D & 2 && j.class !== $.class && r(F, "class", null, $.class, S), D & 4 && r(F, "style", j.style, $.style, S), D & 8) {
5838        const pt = C.dynamicProps;
5839        for (let ft = 0; ft < pt.length; ft++) {
5840          const Rt = pt[ft], te = j[Rt], Nt = $[Rt];
5841          (Nt !== te || Rt === "value") && r(
5842            F,
5843            Rt,
5844            te,
5845            Nt,
5846            S,
5847            v.children,
5848            b,
5849            T,
5850            $t
5851          );
5852        }
5853      }
5854      D & 1 && v.children !== C.children && c(F, C.children);
5855    } else
5856      !N && P == null && q(
5857        F,
5858        C,
5859        j,
5860        $,
5861        b,
5862        T,
5863        S
5864      );
5865    ((H = $.onVnodeUpdated) || B) && ve(() => {
5866      H && ii(H, b, C, v), B && dn(C, v, b, "updated");
5867    }, T);
5868  }, U = (v, C, b, T, S, k, N) => {
5869    for (let F = 0; F < C.length; F++) {
5870      const D = v[F], P = C[F], B = (
5871        // oldVNode may be an errored async setup() component inside Suspense
5872        // which will not have a mounted element
5873        D.el && // - In the case of a Fragment, we need to provide the actual parent
5874        // of the Fragment itself so it can move its children.
5875        (D.type === jt || // - In the case of different nodes, there is going to be a replacement
5876        // which also requires the correct parent container
5877        !$s(D, P) || // - In the case of a component, it could contain anything.
5878        D.shapeFlag & 70) ? u(D.el) : (
5879          // In other cases, the parent container is not actually used so we
5880          // just pass the block element here to avoid a DOM parentNode call.
5881          b
5882        )
5883      );
5884      m(
5885        D,
5886        P,
5887        B,
5888        null,
5889        T,
5890        S,
5891        k,
5892        N,
5893        !0
5894      );
5895    }
5896  }, q = (v, C, b, T, S, k, N) => {
5897    if (b !== T) {
5898      if (b !== At)
5899        for (const F in b)
5900          !bo(F) && !(F in T) && r(
5901            v,
5902            F,
5903            b[F],
5904            null,
5905            N,
5906            C.children,
5907            S,
5908            k,
5909            $t
5910          );
5911      for (const F in T) {
5912        if (bo(F))
5913          continue;
5914        const D = T[F], P = b[F];
5915        D !== P && F !== "value" && r(
5916          v,
5917          F,
5918          P,
5919          D,
5920          N,
5921          C.children,
5922          S,
5923          k,
5924          $t
5925        );
5926      }
5927      "value" in T && r(v, "value", b.value, T.value);
5928    }
5929  }, K = (v, C, b, T, S, k, N, F, D) => {
5930    const P = C.el = v ? v.el : a(""), B = C.anchor = v ? v.anchor : a("");
5931    let { patchFlag: j, dynamicChildren: $, slotScopeIds: H } = C;
5932    H && (F = F ? F.concat(H) : H), v == null ? (n(P, b, T), n(B, b, T), I(
5933      C.children,
5934      b,
5935      B,
5936      S,
5937      k,
5938      N,
5939      F,
5940      D
5941    )) : j > 0 && j & 64 && $ && // #2715 the previous fragment could've been a BAILed one as a result
5942    // of renderSlot() with no valid children
5943    v.dynamicChildren ? (U(
5944      v.dynamicChildren,
5945      $,
5946      b,
5947      S,
5948      k,
5949      N,
5950      F
5951    ), // #2080 if the stable fragment has a key, it's a <template v-for> that may
5952    //  get moved around. Make sure all root level vnodes inherit el.
5953    // #2134 or if it's a component root, it may also get moved around
5954    // as the component is being moved.
5955    (C.key != null || S && C === S.subTree) && Qf(
5956      v,
5957      C,
5958      !0
5959      /* shallow */
5960    )) : W(
5961      v,
5962      C,
5963      b,
5964      B,
5965      S,
5966      k,
5967      N,
5968      F,
5969      D
5970    );
5971  }, Z = (v, C, b, T, S, k, N, F, D) => {
5972    C.slotScopeIds = F, v == null ? C.shapeFlag & 512 ? S.ctx.activate(
5973      C,
5974      b,
5975      T,
5976      N,
5977      D
5978    ) : Mt(
5979      C,
5980      b,
5981      T,
5982      S,
5983      k,
5984      N,
5985      D
5986    ) : V(v, C, D);
5987  }, Mt = (v, C, b, T, S, k, N) => {
5988    const F = v.component = Nv(
5989      v,
5990      T,
5991      S
5992    );
5993    if (Wf(v) && (F.ctx.renderer = Qt), Gv(F), F.asyncDep) {
5994      if (S && S.registerDep(F, Y), !v.el) {
5995        const D = F.subTree = Ze(sn);
5996        p(null, D, C, b);
5997      }
5998      return;
5999    }
6000    Y(
6001      F,
6002      v,
6003      C,
6004      b,
6005      S,
6006      k,
6007      N
6008    );
6009  }, V = (v, C, b) => {
6010    const T = C.component = v.component;
6011    if (V1(v, C, b))
6012      if (T.asyncDep && !T.asyncResolved) {
6013        O(T, C, b);
6014        return;
6015      } else
6016        T.next = C, W1(T.update), T.update();
6017    else
6018      C.el = v.el, T.vnode = C;
6019  }, Y = (v, C, b, T, S, k, N) => {
6020    const F = () => {
6021      if (v.isMounted) {
6022        let { next: B, bu: j, u: $, parent: H, vnode: ot } = v, pt = B, ft;
6023        fn(v, !1), B ? (B.el = ot.el, O(v, B, N)) : B = ot, j && ka(j), (ft = B.props && B.props.onVnodeBeforeUpdate) && ii(ft, H, B, ot), fn(v, !0);
6024        const Rt = Da(v), te = v.subTree;
6025        v.subTree = Rt, m(
6026          te,
6027          Rt,
6028          // parent may have changed if it's in a teleport
6029          u(te.el),
6030          // anchor may have changed if it's in a fragment
6031          ce(te),
6032          v,
6033          S,
6034          k
6035        ), B.el = Rt.el, pt === null && q1(v, Rt.el), $ && ve($, S), (ft = B.props && B.props.onVnodeUpdated) && ve(
6036          () => ii(ft, H, B, ot),
6037          S
6038        );
6039      } else {
6040        let B;
6041        const { el: j, props: $ } = C, { bm: H, m: ot, parent: pt } = v, ft = rr(C);
6042        if (fn(v, !1), H && ka(H), !ft && (B = $ && $.onVnodeBeforeMount) && ii(B, pt, C), fn(v, !0), j && Li) {
6043          const Rt = () => {
6044            v.subTree = Da(v), Li(
6045              j,
6046              v.subTree,
6047              v,
6048              S,
6049              null
6050            );
6051          };
6052          ft ? C.type.__asyncLoader().then(
6053            // note: we are moving the render call into an async callback,
6054            // which means it won't track dependencies - but it's ok because
6055            // a server-rendered async wrapper is already in resolved state
6056            // and it will never need to change.
6057            () => !v.isUnmounted && Rt()
6058          ) : Rt();
6059        } else {
6060          const Rt = v.subTree = Da(v);
6061          m(
6062            null,
6063            Rt,
6064            b,
6065            T,
6066            v,
6067            S,
6068            k
6069          ), C.el = Rt.el;
6070        }
6071        if (ot && ve(ot, S), !ft && (B = $ && $.onVnodeMounted)) {
6072          const Rt = C;
6073          ve(
6074            () => ii(B, pt, Rt),
6075            S
6076          );
6077        }
6078        (C.shapeFlag & 256 || pt && rr(pt.vnode) && pt.vnode.shapeFlag & 256) && v.a && ve(v.a, S), v.isMounted = !0, C = b = T = null;
6079      }
6080    }, D = v.effect = new ph(
6081      F,
6082      () => wh(P),
6083      v.scope
6084      // track it in component's effect scope
6085    ), P = v.update = () => D.run();
6086    P.id = v.uid, fn(v, !0), P();
6087  }, O = (v, C, b) => {
6088    C.component = v;
6089    const T = v.vnode.props;
6090    v.vnode = C, v.next = null, Mv(v, C.props, T, b), Sv(v, C.children, b), Gs(), lu(), zs();
6091  }, W = (v, C, b, T, S, k, N, F, D = !1) => {
6092    const P = v && v.children, B = v ? v.shapeFlag : 0, j = C.children, { patchFlag: $, shapeFlag: H } = C;
6093    if ($ > 0) {
6094      if ($ & 128) {
6095        _t(
6096          P,
6097          j,
6098          b,
6099          T,
6100          S,
6101          k,
6102          N,
6103          F,
6104          D
6105        );
6106        return;
6107      } else if ($ & 256) {
6108        gt(
6109          P,
6110          j,
6111          b,
6112          T,
6113          S,
6114          k,
6115          N,
6116          F,
6117          D
6118        );
6119        return;
6120      }
6121    }
6122    H & 8 ? (B & 16 && $t(P, S, k), j !== P && c(b, j)) : B & 16 ? H & 16 ? _t(
6123      P,
6124      j,
6125      b,
6126      T,
6127      S,
6128      k,
6129      N,
6130      F,
6131      D
6132    ) : $t(P, S, k, !0) : (B & 8 && c(b, ""), H & 16 && I(
6133      j,
6134      b,
6135      T,
6136      S,
6137      k,
6138      N,
6139      F,
6140      D
6141    ));
6142  }, gt = (v, C, b, T, S, k, N, F, D) => {
6143    v = v || ds, C = C || ds;
6144    const P = v.length, B = C.length, j = Math.min(P, B);
6145    let $;
6146    for ($ = 0; $ < j; $++) {
6147      const H = C[$] = D ? zi(C[$]) : ni(C[$]);
6148      m(
6149        v[$],
6150        H,
6151        b,
6152        null,
6153        S,
6154        k,
6155        N,
6156        F,
6157        D
6158      );
6159    }
6160    P > B ? $t(
6161      v,
6162      S,
6163      k,
6164      !0,
6165      !1,
6166      j
6167    ) : I(
6168      C,
6169      b,
6170      T,
6171      S,
6172      k,
6173      N,
6174      F,
6175      D,
6176      j
6177    );
6178  }, _t = (v, C, b, T, S, k, N, F, D) => {
6179    let P = 0;
6180    const B = C.length;
6181    let j = v.length - 1, $ = B - 1;
6182    for (; P <= j && P <= $; ) {
6183      const H = v[P], ot = C[P] = D ? zi(C[P]) : ni(C[P]);
6184      if ($s(H, ot))
6185        m(
6186          H,
6187          ot,
6188          b,
6189          null,
6190          S,
6191          k,
6192          N,
6193          F,
6194          D
6195        );
6196      else
6197        break;
6198      P++;
6199    }
6200    for (; P <= j && P <= $; ) {
6201      const H = v[j], ot = C[$] = D ? zi(C[$]) : ni(C[$]);
6202      if ($s(H, ot))
6203        m(
6204          H,
6205          ot,
6206          b,
6207          null,
6208          S,
6209          k,
6210          N,
6211          F,
6212          D
6213        );
6214      else
6215        break;
6216      j--, $--;
6217    }
6218    if (P > j) {
6219      if (P <= $) {
6220        const H = $ + 1, ot = H < B ? C[H].el : T;
6221        for (; P <= $; )
6222          m(
6223            null,
6224            C[P] = D ? zi(C[P]) : ni(C[P]),
6225            b,
6226            ot,
6227            S,
6228            k,
6229            N,
6230            F,
6231            D
6232          ), P++;
6233      }
6234    } else if (P > $)
6235      for (; P <= j; )
6236        R(v[P], S, k, !0), P++;
6237    else {
6238      const H = P, ot = P, pt = /* @__PURE__ */ new Map();
6239      for (P = ot; P <= $; P++) {
6240        const ee = C[P] = D ? zi(C[P]) : ni(C[P]);
6241        ee.key != null && pt.set(ee.key, P);
6242      }
6243      let ft, Rt = 0;
6244      const te = $ - ot + 1;
6245      let Nt = !1, zn = 0;
6246      const cn = new Array(te);
6247      for (P = 0; P < te; P++)
6248        cn[P] = 0;
6249      for (P = H; P <= j; P++) {
6250        const ee = v[P];
6251        if (Rt >= te) {
6252          R(ee, S, k, !0);
6253          continue;
6254        }
6255        let Te;
6256        if (ee.key != null)
6257          Te = pt.get(ee.key);
6258        else
6259          for (ft = ot; ft <= $; ft++)
6260            if (cn[ft - ot] === 0 && $s(ee, C[ft])) {
6261              Te = ft;
6262              break;
6263            }
6264        Te === void 0 ? R(ee, S, k, !0) : (cn[Te - ot] = P + 1, Te >= zn ? zn = Te : Nt = !0, m(
6265          ee,
6266          C[Te],
6267          b,
6268          null,
6269          S,
6270          k,
6271          N,
6272          F,
6273          D
6274        ), Rt++);
6275      }
6276      const $r = Nt ? Rv(cn) : ds;
6277      for (ft = $r.length - 1, P = te - 1; P >= 0; P--) {
6278        const ee = ot + P, Te = C[ee], jn = ee + 1 < B ? C[ee + 1].el : T;
6279        cn[P] === 0 ? m(
6280          null,
6281          Te,
6282          b,
6283          jn,
6284          S,
6285          k,
6286          N,
6287          F,
6288          D
6289        ) : Nt && (ft < 0 || P !== $r[ft] ? Pt(Te, b, jn, 2) : ft--);
6290      }
6291    }
6292  }, Pt = (v, C, b, T, S = null) => {
6293    const { el: k, type: N, transition: F, children: D, shapeFlag: P } = v;
6294    if (P & 6) {
6295      Pt(v.component.subTree, C, b, T);
6296      return;
6297    }
6298    if (P & 128) {
6299      v.suspense.move(C, b, T);
6300      return;
6301    }
6302    if (P & 64) {
6303      N.move(v, C, b, Qt);
6304      return;
6305    }
6306    if (N === jt) {
6307      n(k, C, b);
6308      for (let j = 0; j < D.length; j++)
6309        Pt(D[j], C, b, T);
6310      n(v.anchor, C, b);
6311      return;
6312    }
6313    if (N === za) {
6314      x(v, C, b);
6315      return;
6316    }
6317    if (T !== 2 && P & 1 && F)
6318      if (T === 0)
6319        F.beforeEnter(k), n(k, C, b), ve(() => F.enter(k), S);
6320      else {
6321        const { leave: j, delayLeave: $, afterLeave: H } = F, ot = () => n(k, C, b), pt = () => {
6322          j(k, () => {
6323            ot(), H && H();
6324          });
6325        };
6326        $ ? $(k, ot, pt) : pt();
6327      }
6328    else
6329      n(k, C, b);
6330  }, R = (v, C, b, T = !1, S = !1) => {
6331    const {
6332      type: k,
6333      props: N,
6334      ref: F,
6335      children: D,
6336      dynamicChildren: P,
6337      shapeFlag: B,
6338      patchFlag: j,
6339      dirs: $
6340    } = v;
6341    if (F != null && Ol(F, null, b, v, !0), B & 256) {
6342      C.ctx.deactivate(v);
6343      return;
6344    }
6345    const H = B & 1 && $, ot = !rr(v);
6346    let pt;
6347    if (ot && (pt = N && N.onVnodeBeforeUnmount) && ii(pt, C, v), B & 6)
6348      bt(v.component, b, T);
6349    else {
6350      if (B & 128) {
6351        v.suspense.unmount(b, T);
6352        return;
6353      }
6354      H && dn(v, null, C, "beforeUnmount"), B & 64 ? v.type.remove(
6355        v,
6356        C,
6357        b,
6358        S,
6359        Qt,
6360        T
6361      ) : P && // #1153: fast path should not be taken for non-stable (v-for) fragments
6362      (k !== jt || j > 0 && j & 64) ? $t(
6363        P,
6364        C,
6365        b,
6366        !1,
6367        !0
6368      ) : (k === jt && j & 384 || !S && B & 16) && $t(D, C, b), T && Jt(v);
6369    }
6370    (ot && (pt = N && N.onVnodeUnmounted) || H) && ve(() => {
6371      pt && ii(pt, C, v), H && dn(v, null, C, "unmounted");
6372    }, b);
6373  }, Jt = (v) => {
6374    const { type: C, el: b, anchor: T, transition: S } = v;
6375    if (C === jt) {
6376      vt(b, T);
6377      return;
6378    }
6379    if (C === za) {
6380      E(v);
6381      return;
6382    }
6383    const k = () => {
6384      s(b), S && !S.persisted && S.afterLeave && S.afterLeave();
6385    };
6386    if (v.shapeFlag & 1 && S && !S.persisted) {
6387      const { leave: N, delayLeave: F } = S, D = () => N(b, k);
6388      F ? F(v.el, k, D) : D();
6389    } else
6390      k();
6391  }, vt = (v, C) => {
6392    let b;
6393    for (; v !== C; )
6394      b = d(v), s(v), v = b;
6395    s(C);
6396  }, bt = (v, C, b) => {
6397    const { bum: T, scope: S, update: k, subTree: N, um: F } = v;
6398    T && ka(T), S.stop(), k && (k.active = !1, R(N, v, C, b)), F && ve(F, C), ve(() => {
6399      v.isUnmounted = !0;
6400    }, C), C && C.pendingBranch && !C.isUnmounted && v.asyncDep && !v.asyncResolved && v.suspenseId === C.pendingId && (C.deps--, C.deps === 0 && C.resolve());
6401  }, $t = (v, C, b, T = !1, S = !1, k = 0) => {
6402    for (let N = k; N < v.length; N++)
6403      R(v[N], C, b, T, S);
6404  }, ce = (v) => v.shapeFlag & 6 ? ce(v.component.subTree) : v.shapeFlag & 128 ? v.suspense.next() : d(v.anchor || v.el), zt = (v, C, b) => {
6405    v == null ? C._vnode && R(C._vnode, null, null, !0) : m(C._vnode || null, v, C, null, null, null, b), lu(), kf(), C._vnode = v;
6406  }, Qt = {
6407    p: m,
6408    um: R,
6409    m: Pt,
6410    r: Jt,
6411    mt: Mt,
6412    mc: I,
6413    pc: W,
6414    pbc: U,
6415    n: ce,
6416    o: e
6417  };
6418  let ti, Li;
6419  return t && ([ti, Li] = t(
6420    Qt
6421  )), {
6422    render: zt,
6423    hydrate: ti,
6424    createApp: vv(zt, ti)
6425  };
6426}
6427function fn({ effect: e, update: t }, i) {
6428  e.allowRecurse = t.allowRecurse = i;
6429}
6430function Qf(e, t, i = !1) {
6431  const n = e.children, s = t.children;
6432  if (nt(n) && nt(s))
6433    for (let r = 0; r < n.length; r++) {
6434      const o = n[r];
6435      let a = s[r];
6436      a.shapeFlag & 1 && !a.dynamicChildren && ((a.patchFlag <= 0 || a.patchFlag === 32) && (a = s[r] = zi(s[r]), a.el = o.el), i || Qf(o, a)), a.type === pa && (a.el = o.el);
6437    }
6438}
6439function Rv(e) {
6440  const t = e.slice(), i = [0];
6441  let n, s, r, o, a;
6442  const l = e.length;
6443  for (n = 0; n < l; n++) {
6444    const h = e[n];
6445    if (h !== 0) {
6446      if (s = i[i.length - 1], e[s] < h) {
6447        t[n] = s, i.push(n);
6448        continue;
6449      }
6450      for (r = 0, o = i.length - 1; r < o; )
6451        a = r + o >> 1, e[i[a]] < h ? r = a + 1 : o = a;
6452      h < e[i[r]] && (r > 0 && (t[n] = i[r - 1]), i[r] = n);
6453    }
6454  }
6455  for (r = i.length, o = i[r - 1]; r-- > 0; )
6456    i[r] = o, o = t[o];
6457  return i;
6458}
6459const Pv = (e) => e.__isTeleport, jt = Symbol.for("v-fgt"), pa = Symbol.for("v-txt"), sn = Symbol.for("v-cmt"), za = Symbol.for("v-stc"), ar = [];
6460let $e = null;
6461function it(e = !1) {
6462  ar.push($e = e ? null : []);
6463}
6464function Lv() {
6465  ar.pop(), $e = ar[ar.length - 1] || null;
6466}
6467let yr = 1;
6468function yu(e) {
6469  yr += e;
6470}
6471function tg(e) {
6472  return e.dynamicChildren = yr > 0 ? $e || ds : null, Lv(), yr > 0 && $e && $e.push(e), e;
6473}
6474function st(e, t, i, n, s, r) {
6475  return tg(
6476    ut(
6477      e,
6478      t,
6479      i,
6480      n,
6481      s,
6482      r,
6483      !0
6484      /* isBlock */
6485    )
6486  );
6487}
6488function eg(e, t, i, n, s) {
6489  return tg(
6490    Ze(
6491      e,
6492      t,
6493      i,
6494      n,
6495      s,
6496      !0
6497      /* isBlock: prevent a block from tracking itself */
6498    )
6499  );
6500}
6501function ig(e) {
6502  return e ? e.__v_isVNode === !0 : !1;
6503}
6504function $s(e, t) {
6505  return e.type === t.type && e.key === t.key;
6506}
6507const ya = "__vInternal", ng = ({ key: e }) => e ?? null, So = ({
6508  ref: e,
6509  ref_key: t,
6510  ref_for: i
6511}) => (typeof e == "number" && (e = "" + e), e != null ? Xt(e) || pe(e) || dt(e) ? { i: Ee, r: e, k: t, f: !!i } : e : null);
6512function ut(e, t = null, i = null, n = 0, s = null, r = e === jt ? 0 : 1, o = !1, a = !1) {
6513  const l = {
6514    __v_isVNode: !0,
6515    __v_skip: !0,
6516    type: e,
6517    props: t,
6518    key: t && ng(t),
6519    ref: t && So(t),
6520    scopeId: Gf,
6521    slotScopeIds: null,
6522    children: i,
6523    component: null,
6524    suspense: null,
6525    ssContent: null,
6526    ssFallback: null,
6527    dirs: null,
6528    transition: null,
6529    el: null,
6530    anchor: null,
6531    target: null,
6532    targetAnchor: null,
6533    staticCount: 0,
6534    shapeFlag: r,
6535    patchFlag: n,
6536    dynamicProps: s,
6537    dynamicChildren: null,
6538    appContext: null,
6539    ctx: Ee
6540  };
6541  return a ? (Ih(l, i), r & 128 && e.normalize(l)) : i && (l.shapeFlag |= Xt(i) ? 8 : 16), yr > 0 && // avoid a block node from tracking itself
6542  !o && // has current parent block
6543  $e && // presence of a patch flag indicates this node needs patching on updates.
6544  // component nodes also should always be patched, because even if the
6545  // component doesn't need to update, it needs to persist the instance on to
6546  // the next vnode so that it can be properly unmounted later.
6547  (l.patchFlag > 0 || r & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
6548  // vnode should not be considered dynamic due to handler caching.
6549  l.patchFlag !== 32 && $e.push(l), l;
6550}
6551const Ze = Av;
6552function Av(e, t = null, i = null, n = 0, s = null, r = !1) {
6553  if ((!e || e === dv) && (e = sn), ig(e)) {
6554    const a = Rs(
6555      e,
6556      t,
6557      !0
6558      /* mergeRef: true */
6559    );
6560    return i && Ih(a, i), yr > 0 && !r && $e && (a.shapeFlag & 6 ? $e[$e.indexOf(e)] = a : $e.push(a)), a.patchFlag |= -2, a;
6561  }
6562  if (Bv(e) && (e = e.__vccOpts), t) {
6563    t = Ov(t);
6564    let { class: a, style: l } = t;
6565    a && !Xt(a) && (t.class = Ue(a)), Dt(l) && (Pf(l) && !nt(l) && (l = Ut({}, l)), t.style = Gr(l));
6566  }
6567  const o = Xt(e) ? 1 : H1(e) ? 128 : Pv(e) ? 64 : Dt(e) ? 4 : dt(e) ? 2 : 0;
6568  return ut(
6569    e,
6570    t,
6571    i,
6572    n,
6573    s,
6574    o,
6575    r,
6576    !0
6577  );
6578}
6579function Ov(e) {
6580  return e ? Pf(e) || ya in e ? Ut({}, e) : e : null;
6581}
6582function Rs(e, t, i = !1) {
6583  const { props: n, ref: s, patchFlag: r, children: o } = e, a = t ? Fv(n || {}, t) : n;
6584  return {
6585    __v_isVNode: !0,
6586    __v_skip: !0,
6587    type: e.type,
6588    props: a,
6589    key: a && ng(a),
6590    ref: t && t.ref ? (
6591      // #2078 in the case of <component :is="vnode" ref="extra"/>
6592      // if the vnode itself already has a ref, cloneVNode will need to merge
6593      // the refs so the single vnode can be set on multiple refs
6594      i && s ? nt(s) ? s.concat(So(t)) : [s, So(t)] : So(t)
6595    ) : s,
6596    scopeId: e.scopeId,
6597    slotScopeIds: e.slotScopeIds,
6598    children: o,
6599    target: e.target,
6600    targetAnchor: e.targetAnchor,
6601    staticCount: e.staticCount,
6602    shapeFlag: e.shapeFlag,
6603    // if the vnode is cloned with extra props, we can no longer assume its
6604    // existing patch flag to be reliable and need to add the FULL_PROPS flag.
6605    // note: preserve flag for fragments since they use the flag for children
6606    // fast paths only.
6607    patchFlag: t && e.type !== jt ? r === -1 ? 16 : r | 16 : r,
6608    dynamicProps: e.dynamicProps,
6609    dynamicChildren: e.dynamicChildren,
6610    appContext: e.appContext,
6611    dirs: e.dirs,
6612    transition: e.transition,
6613    // These should technically only be non-null on mounted VNodes. However,
6614    // they *should* be copied for kept-alive vnodes. So we just always copy
6615    // them since them being non-null during a mount doesn't affect the logic as
6616    // they will simply be overwritten.
6617    component: e.component,
6618    suspense: e.suspense,
6619    ssContent: e.ssContent && Rs(e.ssContent),
6620    ssFallback: e.ssFallback && Rs(e.ssFallback),
6621    el: e.el,
6622    anchor: e.anchor,
6623    ctx: e.ctx,
6624    ce: e.ce
6625  };
6626}
6627function sg(e = " ", t = 0) {
6628  return Ze(pa, null, e, t);
6629}
6630function me(e = "", t = !1) {
6631  return t ? (it(), eg(sn, null, e)) : Ze(sn, null, e);
6632}
6633function ni(e) {
6634  return e == null || typeof e == "boolean" ? Ze(sn) : nt(e) ? Ze(
6635    jt,
6636    null,
6637    // #3666, avoid reference pollution when reusing vnode
6638    e.slice()
6639  ) : typeof e == "object" ? zi(e) : Ze(pa, null, String(e));
6640}
6641function zi(e) {
6642  return e.el === null && e.patchFlag !== -1 || e.memo ? e : Rs(e);
6643}
6644function Ih(e, t) {
6645  let i = 0;
6646  const { shapeFlag: n } = e;
6647  if (t == null)
6648    t = null;
6649  else if (nt(t))
6650    i = 16;
6651  else if (typeof t == "object")
6652    if (n & 65) {
6653      const s = t.default;
6654      s && (s._c && (s._d = !1), Ih(e, s()), s._c && (s._d = !0));
6655      return;
6656    } else {
6657      i = 32;
6658      const s = t._;
6659      !s && !(ya in t) ? t._ctx = Ee : s === 3 && Ee && (Ee.slots._ === 1 ? t._ = 1 : (t._ = 2, e.patchFlag |= 1024));
6660    }
6661  else
6662    dt(t) ? (t = { default: t, _ctx: Ee }, i = 32) : (t = String(t), n & 64 ? (i = 16, t = [sg(t)]) : i = 8);
6663  e.children = t, e.shapeFlag |= i;
6664}
6665function Fv(...e) {
6666  const t = {};
6667  for (let i = 0; i < e.length; i++) {
6668    const n = e[i];
6669    for (const s in n)
6670      if (s === "class")
6671        t.class !== n.class && (t.class = Ue([t.class, n.class]));
6672      else if (s === "style")
6673        t.style = Gr([t.style, n.style]);
6674      else if (ha(s)) {
6675        const r = t[s], o = n[s];
6676        o && r !== o && !(nt(r) && r.includes(o)) && (t[s] = r ? [].concat(r, o) : o);
6677      } else
6678        s !== "" && (t[s] = n[s]);
6679  }
6680  return t;
6681}
6682function ii(e, t, i, n = null) {
6683  He(e, t, 7, [
6684    i,
6685    n
6686  ]);
6687}
6688const kv = Kf();
6689let Dv = 0;
6690function Nv(e, t, i) {
6691  const n = e.type, s = (t ? t.appContext : e.appContext) || kv, r = {
6692    uid: Dv++,
6693    vnode: e,
6694    type: n,
6695    parent: t,
6696    appContext: s,
6697    root: null,
6698    // to be immediately set
6699    next: null,
6700    subTree: null,
6701    // will be set synchronously right after creation
6702    effect: null,
6703    update: null,
6704    // will be set synchronously right after creation
6705    scope: new s1(
6706      !0
6707      /* detached */
6708    ),
6709    render: null,
6710    proxy: null,
6711    exposed: null,
6712    exposeProxy: null,
6713    withProxy: null,
6714    provides: t ? t.provides : Object.create(s.provides),
6715    accessCache: null,
6716    renderCache: [],
6717    // local resolved assets
6718    components: null,
6719    directives: null,
6720    // resolved props and emits options
6721    propsOptions: qf(n, s),
6722    emitsOptions: Nf(n, s),
6723    // emit
6724    emit: null,
6725    // to be set immediately
6726    emitted: null,
6727    // props default value
6728    propsDefaults: At,
6729    // inheritAttrs
6730    inheritAttrs: n.inheritAttrs,
6731    // state
6732    ctx: At,
6733    data: At,
6734    props: At,
6735    attrs: At,
6736    slots: At,
6737    refs: At,
6738    setupState: At,
6739    setupContext: null,
6740    attrsProxy: null,
6741    slotsProxy: null,
6742    // suspense related
6743    suspense: i,
6744    suspenseId: i ? i.pendingId : 0,
6745    asyncDep: null,
6746    asyncResolved: !1,
6747    // lifecycle hooks
6748    // not using enums here because it results in computed properties
6749    isMounted: !1,
6750    isUnmounted: !1,
6751    isDeactivated: !1,
6752    bc: null,
6753    c: null,
6754    bm: null,
6755    m: null,
6756    bu: null,
6757    u: null,
6758    um: null,
6759    bum: null,
6760    da: null,
6761    a: null,
6762    rtg: null,
6763    rtc: null,
6764    ec: null,
6765    sp: null
6766  };
6767  return r.ctx = { _: r }, r.root = t ? t.root : r, r.emit = X1.bind(null, r), e.ce && e.ce(r), r;
6768}
6769let ae = null, Rh, Un, xu = "__VUE_INSTANCE_SETTERS__";
6770(Un = Cl()[xu]) || (Un = Cl()[xu] = []), Un.push((e) => ae = e), Rh = (e) => {
6771  Un.length > 1 ? Un.forEach((t) => t(e)) : Un[0](e);
6772};
6773const Ps = (e) => {
6774  Rh(e), e.scope.on();
6775}, bn = () => {
6776  ae && ae.scope.off(), Rh(null);
6777};
6778function rg(e) {
6779  return e.vnode.shapeFlag & 4;
6780}
6781let xr = !1;
6782function Gv(e, t = !1) {
6783  xr = t;
6784  const { props: i, children: n } = e.vnode, s = rg(e);
6785  Cv(e, i, s, t), wv(e, n);
6786  const r = s ? zv(e, t) : void 0;
6787  return xr = !1, r;
6788}
6789function zv(e, t) {
6790  const i = e.type;
6791  e.accessCache = /* @__PURE__ */ Object.create(null), e.proxy = Is(new Proxy(e.ctx, fv));
6792  const { setup: n } = i;
6793  if (n) {
6794    const s = e.setupContext = n.length > 1 ? Wv(e) : null;
6795    Ps(e), Gs();
6796    const r = Zi(
6797      n,
6798      e,
6799      0,
6800      [e.props, s]
6801    );
6802    if (zs(), bn(), ff(r)) {
6803      if (r.then(bn, bn), t)
6804        return r.then((o) => {
6805          vu(e, o, t);
6806        }).catch((o) => {
6807          ga(o, e, 0);
6808        });
6809      e.asyncDep = r;
6810    } else
6811      vu(e, r, t);
6812  } else
6813    og(e, t);
6814}
6815function vu(e, t, i) {
6816  dt(t) ? e.type.__ssrInlineRender ? e.ssrRender = t : e.render = t : Dt(t) && (e.setupState = Lf(t)), og(e, i);
6817}
6818let Eu;
6819function og(e, t, i) {
6820  const n = e.type;
6821  if (!e.render) {
6822    if (!t && Eu && !n.render) {
6823      const s = n.template || Sh(e).template;
6824      if (s) {
6825        const { isCustomElement: r, compilerOptions: o } = e.appContext.config, { delimiters: a, compilerOptions: l } = n, h = Ut(
6826          Ut(
6827            {
6828              isCustomElement: r,
6829              delimiters: a
6830            },
6831            o
6832          ),
6833          l
6834        );
6835        n.render = Eu(s, h);
6836      }
6837    }
6838    e.render = n.render || qe;
6839  }
6840  Ps(e), Gs(), gv(e), zs(), bn();
6841}
6842function jv(e) {
6843  return e.attrsProxy || (e.attrsProxy = new Proxy(
6844    e.attrs,
6845    {
6846      get(t, i) {
6847        return we(e, "get", "$attrs"), t[i];
6848      }
6849    }
6850  ));
6851}
6852function Wv(e) {
6853  const t = (i) => {
6854    e.exposed = i || {};
6855  };
6856  return {
6857    get attrs() {
6858      return jv(e);
6859    },
6860    slots: e.slots,
6861    emit: e.emit,
6862    expose: t
6863  };
6864}
6865function Ph(e) {
6866  if (e.exposed)
6867    return e.exposeProxy || (e.exposeProxy = new Proxy(Lf(Is(e.exposed)), {
6868      get(t, i) {
6869        if (i in t)
6870          return t[i];
6871        if (i in or)
6872          return or[i](e);
6873      },
6874      has(t, i) {
6875        return i in t || i in or;
6876      }
6877    }));
6878}
6879function Bv(e) {
6880  return dt(e) && "__vccOpts" in e;
6881}
6882const Uv = (e, t) => z1(e, t, xr), Xv = Symbol.for("v-scx"), $v = () => wo(Xv), Yv = "3.3.4", Kv = "http://www.w3.org/2000/svg", pn = typeof document < "u" ? document : null, Cu = pn && /* @__PURE__ */ pn.createElement("template"), Vv = {
6883  insert: (e, t, i) => {
6884    t.insertBefore(e, i || null);
6885  },
6886  remove: (e) => {
6887    const t = e.parentNode;
6888    t && t.removeChild(e);
6889  },
6890  createElement: (e, t, i, n) => {
6891    const s = t ? pn.createElementNS(Kv, e) : pn.createElement(e, i ? { is: i } : void 0);
6892    return e === "select" && n && n.multiple != null && s.setAttribute("multiple", n.multiple), s;
6893  },
6894  createText: (e) => pn.createTextNode(e),
6895  createComment: (e) => pn.createComment(e),
6896  setText: (e, t) => {
6897    e.nodeValue = t;
6898  },
6899  setElementText: (e, t) => {
6900    e.textContent = t;
6901  },
6902  parentNode: (e) => e.parentNode,
6903  nextSibling: (e) => e.nextSibling,
6904  querySelector: (e) => pn.querySelector(e),
6905  setScopeId(e, t) {
6906    e.setAttribute(t, "");
6907  },
6908  // __UNSAFE__
6909  // Reason: innerHTML.
6910  // Static content here can only come from compiled templates.
6911  // As long as the user only uses trusted templates, this is safe.
6912  insertStaticContent(e, t, i, n, s, r) {
6913    const o = i ? i.previousSibling : t.lastChild;
6914    if (s && (s === r || s.nextSibling))
6915      for (; t.insertBefore(s.cloneNode(!0), i), !(s === r || !(s = s.nextSibling)); )
6916        ;
6917    else {
6918      Cu.innerHTML = n ? `<svg>${e}</svg>` : e;
6919      const a = Cu.content;
6920      if (n) {
6921        const l = a.firstChild;
6922        for (; l.firstChild; )
6923          a.appendChild(l.firstChild);
6924        a.removeChild(l);
6925      }
6926      t.insertBefore(a, i);
6927    }
6928    return [
6929      // first
6930      o ? o.nextSibling : t.firstChild,
6931      // last
6932      i ? i.previousSibling : t.lastChild
6933    ];
6934  }
6935};
6936function qv(e, t, i) {
6937  const n = e._vtc;
6938  n && (t = (t ? [t, ...n] : [...n]).join(" ")), t == null ? e.removeAttribute("class") : i ? e.setAttribute("class", t) : e.className = t;
6939}
6940function Hv(e, t, i) {
6941  const n = e.style, s = Xt(i);
6942  if (i && !s) {
6943    if (t && !Xt(t))
6944      for (const r in t)
6945        i[r] == null && Fl(n, r, "");
6946    for (const r in i)
6947      Fl(n, r, i[r]);
6948  } else {
6949    const r = n.display;
6950    s ? t !== i && (n.cssText = i) : t && e.removeAttribute("style"), "_vod" in e && (n.display = r);
6951  }
6952}
6953const Mu = /\s*!important$/;
6954function Fl(e, t, i) {
6955  if (nt(i))
6956    i.forEach((n) => Fl(e, t, n));
6957  else if (i == null && (i = ""), t.startsWith("--"))
6958    e.setProperty(t, i);
6959  else {
6960    const n = Zv(e, t);
6961    Mu.test(i) ? e.setProperty(
6962      Be(n),
6963      i.replace(Mu, ""),
6964      "important"
6965    ) : e[n] = i;
6966  }
6967}
6968const bu = ["Webkit", "Moz", "ms"], ja = {};
6969function Zv(e, t) {
6970  const i = ja[t];
6971  if (i)
6972    return i;
6973  let n = wi(t);
6974  if (n !== "filter" && n in e)
6975    return ja[t] = n;
6976  n = _f(n);
6977  for (let s = 0; s < bu.length; s++) {
6978    const r = bu[s] + n;
6979    if (r in e)
6980      return ja[t] = r;
6981  }
6982  return t;
6983}
6984const wu = "http://www.w3.org/1999/xlink";
6985function Jv(e, t, i, n, s) {
6986  if (n && t.startsWith("xlink:"))
6987    i == null ? e.removeAttributeNS(wu, t.slice(6, t.length)) : e.setAttributeNS(wu, t, i);
6988  else {
6989    const r = n1(t);
6990    i == null || r && !pf(i) ? e.removeAttribute(t) : e.setAttribute(t, r ? "" : i);
6991  }
6992}
6993function Qv(e, t, i, n, s, r, o) {
6994  if (t === "innerHTML" || t === "textContent") {
6995    n && o(n, s, r), e[t] = i ?? "";
6996    return;
6997  }
6998  const a = e.tagName;
6999  if (t === "value" && a !== "PROGRESS" && // custom elements may use _value internally
7000  !a.includes("-")) {
7001    e._value = i;
7002    const h = a === "OPTION" ? e.getAttribute("value") : e.value, c = i ?? "";
7003    h !== c && (e.value = c), i == null && e.removeAttribute(t);
7004    return;
7005  }
7006  let l = !1;
7007  if (i === "" || i == null) {
7008    const h = typeof e[t];
7009    h === "boolean" ? i = pf(i) : i == null && h === "string" ? (i = "", l = !0) : h === "number" && (i = 0, l = !0);
7010  }
7011  try {
7012    e[t] = i;
7013  } catch {
7014  }
7015  l && e.removeAttribute(t);
7016}
7017function tE(e, t, i, n) {
7018  e.addEventListener(t, i, n);
7019}
7020function eE(e, t, i, n) {
7021  e.removeEventListener(t, i, n);
7022}
7023function iE(e, t, i, n, s = null) {
7024  const r = e._vei || (e._vei = {}), o = r[t];
7025  if (n && o)
7026    o.value = n;
7027  else {
7028    const [a, l] = nE(t);
7029    if (n) {
7030      const h = r[t] = oE(n, s);
7031      tE(e, a, h, l);
7032    } else
7033      o && (eE(e, a, o, l), r[t] = void 0);
7034  }
7035}
7036const Su = /(?:Once|Passive|Capture)$/;
7037function nE(e) {
7038  let t;
7039  if (Su.test(e)) {
7040    t = {};
7041    let n;
7042    for (; n = e.match(Su); )
7043      e = e.slice(0, e.length - n[0].length), t[n[0].toLowerCase()] = !0;
7044  }
7045  return [e[2] === ":" ? e.slice(3) : Be(e.slice(2)), t];
7046}
7047let Wa = 0;
7048const sE = /* @__PURE__ */ Promise.resolve(), rE = () => Wa || (sE.then(() => Wa = 0), Wa = Date.now());
7049function oE(e, t) {
7050  const i = (n) => {
7051    if (!n._vts)
7052      n._vts = Date.now();
7053    else if (n._vts <= i.attached)
7054      return;
7055    He(
7056      aE(n, i.value),
7057      t,
7058      5,
7059      [n]
7060    );
7061  };
7062  return i.value = e, i.attached = rE(), i;
7063}
7064function aE(e, t) {
7065  if (nt(t)) {
7066    const i = e.stopImmediatePropagation;
7067    return e.stopImmediatePropagation = () => {
7068      i.call(e), e._stopped = !0;
7069    }, t.map((n) => (s) => !s._stopped && n && n(s));
7070  } else
7071    return t;
7072}
7073const Tu = /^on[a-z]/, lE = (e, t, i, n, s = !1, r, o, a, l) => {
7074  t === "class" ? qv(e, n, s) : t === "style" ? Hv(e, i, n) : ha(t) ? dh(t) || iE(e, t, i, n, o) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : hE(e, t, n, s)) ? Qv(
7075    e,
7076    t,
7077    n,
7078    r,
7079    o,
7080    a,
7081    l
7082  ) : (t === "true-value" ? e._trueValue = n : t === "false-value" && (e._falseValue = n), Jv(e, t, n, s));
7083};
7084function hE(e, t, i, n) {
7085  return n ? !!(t === "innerHTML" || t === "textContent" || t in e && Tu.test(t) && dt(i)) : t === "spellcheck" || t === "draggable" || t === "translate" || t === "form" || t === "list" && e.tagName === "INPUT" || t === "type" && e.tagName === "TEXTAREA" || Tu.test(t) && Xt(i) ? !1 : t in e;
7086}
7087function on(e, t) {
7088  const i = Q1(e);
7089  class n extends Lh {
7090    constructor(r) {
7091      super(i, r, t);
7092    }
7093  }
7094  return n.def = i, n;
7095}
7096const cE = typeof HTMLElement < "u" ? HTMLElement : class {
7097};
7098class Lh extends cE {
7099  constructor(t, i = {}, n) {
7100    super(), this._def = t, this._props = i, this._instance = null, this._connected = !1, this._resolved = !1, this._numberProps = null, this.shadowRoot && n ? n(this._createVNode(), this.shadowRoot) : (this.attachShadow({ mode: "open" }), this._def.__asyncLoader || this._resolveProps(this._def));
7101  }
7102  connectedCallback() {
7103    this._connected = !0, this._instance || (this._resolved ? this._update() : this._resolveDef());
7104  }
7105  disconnectedCallback() {
7106    this._connected = !1, Of(() => {
7107      this._connected || (Ru(null, this.shadowRoot), this._instance = null);
7108    });
7109  }
7110  /**
7111   * resolve inner component definition (handle possible async component)
7112   */
7113  _resolveDef() {
7114    this._resolved = !0;
7115    for (let n = 0; n < this.attributes.length; n++)
7116      this._setAttr(this.attributes[n].name);
7117    new MutationObserver((n) => {
7118      for (const s of n)
7119        this._setAttr(s.attributeName);
7120    }).observe(this, { attributes: !0 });
7121    const t = (n, s = !1) => {
7122      const { props: r, styles: o } = n;
7123      let a;
7124      if (r && !nt(r))
7125        for (const l in r) {
7126          const h = r[l];
7127          (h === Number || h && h.type === Number) && (l in this._props && (this._props[l] = Qc(this._props[l])), (a || (a = /* @__PURE__ */ Object.create(null)))[wi(l)] = !0);
7128        }
7129      this._numberProps = a, s && this._resolveProps(n), this._applyStyles(o), this._update();
7130    }, i = this._def.__asyncLoader;
7131    i ? i().then((n) => t(n, !0)) : t(this._def);
7132  }
7133  _resolveProps(t) {
7134    const { props: i } = t, n = nt(i) ? i : Object.keys(i || {});
7135    for (const s of Object.keys(this))
7136      s[0] !== "_" && n.includes(s) && this._setProp(s, this[s], !0, !1);
7137    for (const s of n.map(wi))
7138      Object.defineProperty(this, s, {
7139        get() {
7140          return this._getProp(s);
7141        },
7142        set(r) {
7143          this._setProp(s, r);
7144        }
7145      });
7146  }
7147  _setAttr(t) {
7148    let i = this.getAttribute(t);
7149    const n = wi(t);
7150    this._numberProps && this._numberProps[n] && (i = Qc(i)), this._setProp(n, i, !1);
7151  }
7152  /**
7153   * @internal
7154   */
7155  _getProp(t) {
7156    return this._props[t];
7157  }
7158  /**
7159   * @internal
7160   */
7161  _setProp(t, i, n = !0, s = !0) {
7162    i !== this._props[t] && (this._props[t] = i, s && this._instance && this._update(), n && (i === !0 ? this.setAttribute(Be(t), "") : typeof i == "string" || typeof i == "number" ? this.setAttribute(Be(t), i + "") : i || this.removeAttribute(Be(t))));
7163  }
7164  _update() {
7165    Ru(this._createVNode(), this.shadowRoot);
7166  }
7167  _createVNode() {
7168    const t = Ze(this._def, Ut({}, this._props));
7169    return this._instance || (t.ce = (i) => {
7170      this._instance = i, i.isCE = !0;
7171      const n = (r, o) => {
7172        this.dispatchEvent(
7173          new CustomEvent(r, {
7174            detail: o
7175          })
7176        );
7177      };
7178      i.emit = (r, ...o) => {
7179        n(r, o), Be(r) !== r && n(Be(r), o);
7180      };
7181      let s = this;
7182      for (; s = s && (s.parentNode || s.host); )
7183        if (s instanceof Lh) {
7184          i.parent = s._instance, i.provides = s._instance.provides;
7185          break;
7186        }
7187    }), t;
7188  }
7189  _applyStyles(t) {
7190    t && t.forEach((i) => {
7191      const n = document.createElement("style");
7192      n.textContent = i, this.shadowRoot.appendChild(n);
7193    });
7194  }
7195}
7196const uE = ["ctrl", "shift", "alt", "meta"], dE = {
7197  stop: (e) => e.stopPropagation(),
7198  prevent: (e) => e.preventDefault(),
7199  self: (e) => e.target !== e.currentTarget,
7200  ctrl: (e) => !e.ctrlKey,
7201  shift: (e) => !e.shiftKey,
7202  alt: (e) => !e.altKey,
7203  meta: (e) => !e.metaKey,
7204  left: (e) => "button" in e && e.button !== 0,
7205  middle: (e) => "button" in e && e.button !== 1,
7206  right: (e) => "button" in e && e.button !== 2,
7207  exact: (e, t) => uE.some((i) => e[`${i}Key`] && !t.includes(i))
7208}, ag = (e, t) => (i, ...n) => {
7209  for (let s = 0; s < t.length; s++) {
7210    const r = dE[t[s]];
7211    if (r && r(i, t))
7212      return;
7213  }
7214  return e(i, ...n);
7215}, fE = /* @__PURE__ */ Ut({ patchProp: lE }, Vv);
7216let Iu;
7217function gE() {
7218  return Iu || (Iu = Tv(fE));
7219}
7220const Ru = (...e) => {
7221  gE().render(...e);
7222};
7223function Ba(e) {
7224  return parseInt(e, 16) || e;
7225}
7226function Ua(e) {
7227  return Ba(e) / 255 <= 0.03928 ? Ba(e) / 255 / 12.92 : Math.pow((Ba(e) / 255 + 0.055) / 1.055, 2.4);
7228}
7229function Pu(e) {
7230  return 0.2126 * Ua(e.substr(1, 2)) + 0.7152 * Ua(e.substr(3, 2)) + 0.0722 * Ua(e.substr(-2));
7231}
7232function zo(e, t) {
7233  const i = Pu(e), n = Pu(t);
7234  return (Math.max(i, n) + 0.05) / (Math.min(i, n) + 0.05);
7235}
7236function mE(e) {
7237  const t = zo(e, "#ffffff"), i = zo(e, "#000000");
7238  return t > i ? "#ffffff" : "#000000";
7239}
7240function _E(e) {
7241  const t = zo(e, "#ffffff"), i = zo(e, "#000000");
7242  return t > i;
7243}
7244const pE = `.xmap{height:100%;display:flex;flex-flow:column;font-family:Roboto,sans-serif!important;border:1px solid black}.xmap-main{height:calc(100% - 25px)}.xmap-web-map-footer{width:100%;height:25px;min-height:25px;background-color:var(--xmap-primary);font-size:.8em}.xmap-web-map-footer div{float:right;padding-right:5px;height:100%;line-height:25px}.xmap-web-map-footer div span{color:var(--xmap-footer-text);opacity:.9;height:100%;line-height:25px;padding-right:5px}.xmap-web-map-footer div a,.xmap-web-map-footer div a:hover,.xmap-web-map-footer div a:focus,.xmap-web-map-footer div a:active{text-decoration:none;color:var(--xmap-footer-text);float:right}
7245`, xa = (e, t) => {
7246  const i = e.__vccOpts || e;
7247  for (const [n, s] of t)
7248    i[n] = s;
7249  return i;
7250}, yE = {
7251  name: "Xmap",
7252  mounted() {
7253  },
7254  data: () => ({
7255    allowedVariants: ["xmap", "parishonline"]
7256  }),
7257  computed: {
7258    footerTextColor() {
7259      return mE(this.primaryColor);
7260    },
7261    // The footer logo links to the site of the brand it shows.
7262    logoHref() {
7263      return this.appVariant === "parishonline" ? "https://parish-online.co.uk" : "https://xmap.geoxphere.com";
7264    },
7265    logoType() {
7266      let e = _E(this.primaryColor) ? "light" : "dark";
7267      return `https://embed.xmap.cloud/${this.appVariant}-${e}.png`;
7268    },
7269    // Theme colours as named CSS custom properties, set through the normal :style
7270    // render path. Not v-bind() in <style>: Vue's useCssVars writes those from a
7271    // post-flush job that never lands in the Power Apps canvas player (XMP-2224).
7272    themeVars() {
7273      return {
7274        "--xmap-primary": this.primaryColor,
7275        "--xmap-secondary": this.secondaryColor,
7276        "--xmap-footer-text": this.footerTextColor
7277      };
7278    },
7279    appVariant() {
7280      return this.allowedVariants.includes(this.variant) ? this.variant : this.allowedVariants[0];
7281    }
7282  },
7283  provide() {
7284    return {
7285      primaryColor: this.primaryColor,
7286      secondaryColor: this.secondaryColor,
7287      variant: this.appVariant
7288    };
7289  },
7290  methods: {
7291    handleUpdate(e) {
7292    }
7293  },
7294  watch: {
7295    primaryColor(e) {
7296    }
7297  },
7298  props: {
7299    variant: {
7300      type: String,
7301      default: "xmap"
7302    },
7303    primaryColor: {
7304      type: String,
7305      default: "#263746"
7306    },
7307    secondaryColor: {
7308      type: String,
7309      default: "#a1d0ca"
7310    }
7311  }
7312}, xE = {
7313  ref: "xmapMain",
7314  class: "xmap-main"
7315}, vE = {
7316  ref: "footer",
7317  class: "xmap-web-map-footer"
7318}, EE = /* @__PURE__ */ ut("span", null, "Powered by ", -1), CE = ["href"], ME = ["src"];
7319function bE(e, t, i, n, s, r) {
7320  return it(), st("div", {
7321    class: "xmap",
7322    style: Gr(r.themeVars)
7323  }, [
7324    ut("div", xE, [
7325      Xf(e.$slots, "default", {
7326        "onUpdate:x": t[0] || (t[0] = (...o) => r.handleUpdate && r.handleUpdate(...o))
7327      })
7328    ], 512),
7329    ut("div", vE, [
7330      ut("div", null, [
7331        EE,
7332        ut("a", {
7333          target: "_blank",
7334          href: r.logoHref
7335        }, [
7336          ut("img", {
7337            style: { height: "20px", "margin-top": "2.5px" },
7338            alt: "A Logo",
7339            src: `${r.logoType}`
7340          }, null, 8, ME)
7341        ], 8, CE)
7342      ])
7343    ], 512)
7344  ], 4);
7345}
7346const wE = /* @__PURE__ */ xa(yE, [["render", bE], ["styles", [pE]]]);
7347class SE {
7348  /**
7349   * @param {string} type Type.
7350   */
7351  constructor(t) {
7352    this.propagationStopped, this.defaultPrevented, this.type = t, this.target = null;
7353  }
7354  /**
7355   * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
7356   * will be fired.
7357   * @api
7358   */
7359  preventDefault() {
7360    this.defaultPrevented = !0;
7361  }
7362  /**
7363   * Stop event propagation.
7364   * @api
7365   */
7366  stopPropagation() {
7367    this.propagationStopped = !0;
7368  }
7369}
7370const Le = SE, Ls = {
7371  /**
7372   * Triggered when a property is changed.
7373   * @event module:ol/Object.ObjectEvent#propertychange
7374   * @api
7375   */
7376  PROPERTYCHANGE: "propertychange"
7377};
7378class TE {
7379  constructor() {
7380    this.disposed = !1;
7381  }
7382  /**
7383   * Clean up.
7384   */
7385  dispose() {
7386    this.disposed || (this.disposed = !0, this.disposeInternal());
7387  }
7388  /**
7389   * Extension point for disposable objects.
7390   * @protected
7391   */
7392  disposeInternal() {
7393  }
7394}
7395const Ah = TE;
7396function IE(e, t, i) {
7397  let n, s;
7398  i = i || Ln;
7399  let r = 0, o = e.length, a = !1;
7400  for (; r < o; )
7401    n = r + (o - r >> 1), s = +i(e[n], t), s < 0 ? r = n + 1 : (o = n, a = !s);
7402  return a ? r : ~r;
7403}
7404function Ln(e, t) {
7405  return e > t ? 1 : e < t ? -1 : 0;
7406}
7407function va(e, t, i) {
7408  if (e[0] <= t)
7409    return 0;
7410  const n = e.length;
7411  if (t <= e[n - 1])
7412    return n - 1;
7413  if (typeof i == "function") {
7414    for (let s = 1; s < n; ++s) {
7415      const r = e[s];
7416      if (r === t)
7417        return s;
7418      if (r < t)
7419        return i(t, e[s - 1], r) > 0 ? s - 1 : s;
7420    }
7421    return n - 1;
7422  }
7423  if (i > 0) {
7424    for (let s = 1; s < n; ++s)
7425      if (e[s] < t)
7426        return s - 1;
7427    return n - 1;
7428  }
7429  if (i < 0) {
7430    for (let s = 1; s < n; ++s)
7431      if (e[s] <= t)
7432        return s;
7433    return n - 1;
7434  }
7435  for (let s = 1; s < n; ++s) {
7436    if (e[s] == t)
7437      return s;
7438    if (e[s] < t)
7439      return e[s - 1] - t < t - e[s] ? s - 1 : s;
7440  }
7441  return n - 1;
7442}
7443function RE(e, t, i) {
7444  for (; t < i; ) {
7445    const n = e[t];
7446    e[t] = e[i], e[i] = n, ++t, --i;
7447  }
7448}
7449function ci(e, t) {
7450  const i = Array.isArray(t) ? t : [t], n = i.length;
7451  for (let s = 0; s < n; s++)
7452    e[e.length] = i[s];
7453}
7454function Pi(e, t) {
7455  const i = e.length;
7456  if (i !== t.length)
7457    return !1;
7458  for (let n = 0; n < i; n++)
7459    if (e[n] !== t[n])
7460      return !1;
7461  return !0;
7462}
7463function PE(e, t, i) {
7464  const n = t || Ln;
7465  return e.every(function(s, r) {
7466    if (r === 0)
7467      return !0;
7468    const o = n(e[r - 1], s);
7469    return !(o > 0 || i && o === 0);
7470  });
7471}
7472function An() {
7473  return !0;
7474}
7475function Gn() {
7476  return !1;
7477}
7478function As() {
7479}
7480function LE(e) {
7481  let t = !1, i, n, s;
7482  return function() {
7483    const r = Array.prototype.slice.call(arguments);
7484    return (!t || this !== s || !Pi(r, n)) && (t = !0, s = this, n = r, i = e.apply(this, arguments)), i;
7485  };
7486}
7487class AE extends Ah {
7488  /**
7489   * @param {*} [target] Default event target for dispatched events.
7490   */
7491  constructor(t) {
7492    super(), this.eventTarget_ = t, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null;
7493  }
7494  /**
7495   * @param {string} type Type.
7496   * @param {import("../events.js").Listener} listener Listener.
7497   */
7498  addEventListener(t, i) {
7499    if (!t || !i)
7500      return;
7501    const n = this.listeners_ || (this.listeners_ = {}), s = n[t] || (n[t] = []);
7502    s.includes(i) || s.push(i);
7503  }
7504  /**
7505   * Dispatches an event and calls all listeners listening for events
7506   * of this type. The event parameter can either be a string or an
7507   * Object with a `type` property.
7508   *
7509   * @param {import("./Event.js").default|string} event Event object.
7510   * @return {boolean|undefined} `false` if anyone called preventDefault on the
7511   *     event object or if any of the listeners returned false.
7512   * @api
7513   */
7514  dispatchEvent(t) {
7515    const i = typeof t == "string", n = i ? t : t.type, s = this.listeners_ && this.listeners_[n];
7516    if (!s)
7517      return;
7518    const r = i ? new Le(t) : (
7519      /** @type {Event} */
7520      t
7521    );
7522    r.target || (r.target = this.eventTarget_ || this);
7523    const o = this.dispatching_ || (this.dispatching_ = {}), a = this.pendingRemovals_ || (this.pendingRemovals_ = {});
7524    n in o || (o[n] = 0, a[n] = 0), ++o[n];
7525    let l;
7526    for (let h = 0, c = s.length; h < c; ++h)
7527      if ("handleEvent" in s[h] ? l = /** @type {import("../events.js").ListenerObject} */
7528      s[h].handleEvent(r) : l = /** @type {import("../events.js").ListenerFunction} */
7529      s[h].call(this, r), l === !1 || r.propagationStopped) {
7530        l = !1;
7531        break;
7532      }
7533    if (--o[n] === 0) {
7534      let h = a[n];
7535      for (delete a[n]; h--; )
7536        this.removeEventListener(n, As);
7537      delete o[n];
7538    }
7539    return l;
7540  }
7541  /**
7542   * Clean up.
7543   */
7544  disposeInternal() {
7545    this.listeners_ && Dr(this.listeners_);
7546  }
7547  /**
7548   * Get the listeners for a specified event type. Listeners are returned in the
7549   * order that they will be called in.
7550   *
7551   * @param {string} type Type.
7552   * @return {Array<import("../events.js").Listener>|undefined} Listeners.
7553   */
7554  getListeners(t) {
7555    return this.listeners_ && this.listeners_[t] || void 0;
7556  }
7557  /**
7558   * @param {string} [type] Type. If not provided,
7559   *     `true` will be returned if this event target has any listeners.
7560   * @return {boolean} Has listeners.
7561   */
7562  hasListener(t) {
7563    return this.listeners_ ? t ? t in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1;
7564  }
7565  /**
7566   * @param {string} type Type.
7567   * @param {import("../events.js").Listener} listener Listener.
7568   */
7569  removeEventListener(t, i) {
7570    const n = this.listeners_ && this.listeners_[t];
7571    if (n) {
7572      const s = n.indexOf(i);
7573      s !== -1 && (this.pendingRemovals_ && t in this.pendingRemovals_ ? (n[s] = As, ++this.pendingRemovals_[t]) : (n.splice(s, 1), n.length === 0 && delete this.listeners_[t]));
7574    }
7575  }
7576}
7577const zr = AE, et = {
7578  /**
7579   * Generic change event. Triggered when the revision counter is increased.
7580   * @event module:ol/events/Event~BaseEvent#change
7581   * @api
7582   */
7583  CHANGE: "change",
7584  /**
7585   * Generic error event. Triggered when an error occurs.
7586   * @event module:ol/events/Event~BaseEvent#error
7587   * @api
7588   */
7589  ERROR: "error",
7590  BLUR: "blur",
7591  CLEAR: "clear",
7592  CONTEXTMENU: "contextmenu",
7593  CLICK: "click",
7594  DBLCLICK: "dblclick",
7595  DRAGENTER: "dragenter",
7596  DRAGOVER: "dragover",
7597  DROP: "drop",
7598  FOCUS: "focus",
7599  KEYDOWN: "keydown",
7600  KEYPRESS: "keypress",
7601  LOAD: "load",
7602  RESIZE: "resize",
7603  TOUCHMOVE: "touchmove",
7604  WHEEL: "wheel"
7605};
7606function ct(e, t, i, n, s) {
7607  if (n && n !== e && (i = i.bind(n)), s) {
7608    const o = i;
7609    i = function() {
7610      e.removeEventListener(t, i), o.apply(this, arguments);
7611    };
7612  }
7613  const r = {
7614    target: e,
7615    type: t,
7616    listener: i
7617  };
7618  return e.addEventListener(t, i), r;
7619}
7620function jo(e, t, i, n) {
7621  return ct(e, t, i, n, !0);
7622}
7623function St(e) {
7624  e && e.target && (e.target.removeEventListener(e.type, e.listener), Dr(e));
7625}
7626class Ea extends zr {
7627  constructor() {
7628    super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
7629    this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
7630    this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */
7631    this.unInternal, this.revision_ = 0;
7632  }
7633  /**
7634   * Increases the revision counter and dispatches a 'change' event.
7635   * @api
7636   */
7637  changed() {
7638    ++this.revision_, this.dispatchEvent(et.CHANGE);
7639  }
7640  /**
7641   * Get the version number for this object.  Each time the object is modified,
7642   * its version number will be incremented.
7643   * @return {number} Revision.
7644   * @api
7645   */
7646  getRevision() {
7647    return this.revision_;
7648  }
7649  /**
7650   * @param {string|Array<string>} type Type.
7651   * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
7652   * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
7653   * @protected
7654   */
7655  onInternal(t, i) {
7656    if (Array.isArray(t)) {
7657      const n = t.length, s = new Array(n);
7658      for (let r = 0; r < n; ++r)
7659        s[r] = ct(this, t[r], i);
7660      return s;
7661    }
7662    return ct(
7663      this,
7664      /** @type {string} */
7665      t,
7666      i
7667    );
7668  }
7669  /**
7670   * @param {string|Array<string>} type Type.
7671   * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
7672   * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
7673   * @protected
7674   */
7675  onceInternal(t, i) {
7676    let n;
7677    if (Array.isArray(t)) {
7678      const s = t.length;
7679      n = new Array(s);
7680      for (let r = 0; r < s; ++r)
7681        n[r] = jo(this, t[r], i);
7682    } else
7683      n = jo(
7684        this,
7685        /** @type {string} */
7686        t,
7687        i
7688      );
7689    return i.ol_key = n, n;
7690  }
7691  /**
7692   * Unlisten for a certain type of event.
7693   * @param {string|Array<string>} type Type.
7694   * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
7695   * @protected
7696   */
7697  unInternal(t, i) {
7698    const n = (
7699      /** @type {Object} */
7700      i.ol_key
7701    );
7702    if (n)
7703      OE(n);
7704    else if (Array.isArray(t))
7705      for (let s = 0, r = t.length; s < r; ++s)
7706        this.removeEventListener(t[s], i);
7707    else
7708      this.removeEventListener(t, i);
7709  }
7710}
7711Ea.prototype.on;
7712Ea.prototype.once;
7713Ea.prototype.un;
7714function OE(e) {
7715  if (Array.isArray(e))
7716    for (let t = 0, i = e.length; t < i; ++t)
7717      St(e[t]);
7718  else
7719    St(
7720      /** @type {import("./events.js").EventsKey} */
7721      e
7722    );
7723}
7724const lg = Ea;
7725function Q() {
7726  throw new Error("Unimplemented abstract method.");
7727}
7728let FE = 0;
7729function lt(e) {
7730  return e.ol_uid || (e.ol_uid = String(++FE));
7731}
7732class Lu extends Le {
7733  /**
7734   * @param {string} type The event type.
7735   * @param {string} key The property name.
7736   * @param {*} oldValue The old value for `key`.
7737   */
7738  constructor(t, i, n) {
7739    super(t), this.key = i, this.oldValue = n;
7740  }
7741}
7742class kE extends lg {
7743  /**
7744   * @param {Object<string, *>} [values] An object with key-value pairs.
7745   */
7746  constructor(t) {
7747    super(), this.on, this.once, this.un, lt(this), this.values_ = null, t !== void 0 && this.setProperties(t);
7748  }
7749  /**
7750   * Gets a value.
7751   * @param {string} key Key name.
7752   * @return {*} Value.
7753   * @api
7754   */
7755  get(t) {
7756    let i;
7757    return this.values_ && this.values_.hasOwnProperty(t) && (i = this.values_[t]), i;
7758  }
7759  /**
7760   * Get a list of object property names.
7761   * @return {Array<string>} List of property names.
7762   * @api
7763   */
7764  getKeys() {
7765    return this.values_ && Object.keys(this.values_) || [];
7766  }
7767  /**
7768   * Get an object of all property names and values.
7769   * @return {Object<string, *>} Object.
7770   * @api
7771   */
7772  getProperties() {
7773    return this.values_ && Object.assign({}, this.values_) || {};
7774  }
7775  /**
7776   * @return {boolean} The object has properties.
7777   */
7778  hasProperties() {
7779    return !!this.values_;
7780  }
7781  /**
7782   * @param {string} key Key name.
7783   * @param {*} oldValue Old value.
7784   */
7785  notify(t, i) {
7786    let n;
7787    n = `change:${t}`, this.hasListener(n) && this.dispatchEvent(new Lu(n, t, i)), n = Ls.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new Lu(n, t, i));
7788  }
7789  /**
7790   * @param {string} key Key name.
7791   * @param {import("./events.js").Listener} listener Listener.
7792   */
7793  addChangeListener(t, i) {
7794    this.addEventListener(`change:${t}`, i);
7795  }
7796  /**
7797   * @param {string} key Key name.
7798   * @param {import("./events.js").Listener} listener Listener.
7799   */
7800  removeChangeListener(t, i) {
7801    this.removeEventListener(`change:${t}`, i);
7802  }
7803  /**
7804   * Sets a value.
7805   * @param {string} key Key name.
7806   * @param {*} value Value.
7807   * @param {boolean} [silent] Update without triggering an event.
7808   * @api
7809   */
7810  set(t, i, n) {
7811    const s = this.values_ || (this.values_ = {});
7812    if (n)
7813      s[t] = i;
7814    else {
7815      const r = s[t];
7816      s[t] = i, r !== i && this.notify(t, r);
7817    }
7818  }
7819  /**
7820   * Sets a collection of key-value pairs.  Note that this changes any existing
7821   * properties and adds new ones (it does not remove any existing properties).
7822   * @param {Object<string, *>} values Values.
7823   * @param {boolean} [silent] Update without triggering an event.
7824   * @api
7825   */
7826  setProperties(t, i) {
7827    for (const n in t)
7828      this.set(n, t[n], i);
7829  }
7830  /**
7831   * Apply any properties from another object without triggering events.
7832   * @param {BaseObject} source The source object.
7833   * @protected
7834   */
7835  applyProperties(t) {
7836    t.values_ && Object.assign(this.values_ || (this.values_ = {}), t.values_);
7837  }
7838  /**
7839   * Unsets a property.
7840   * @param {string} key Key name.
7841   * @param {boolean} [silent] Unset without triggering an event.
7842   * @api
7843   */
7844  unset(t, i) {
7845    if (this.values_ && t in this.values_) {
7846      const n = this.values_[t];
7847      delete this.values_[t], bs(this.values_) && (this.values_ = null), i || this.notify(t, n);
7848    }
7849  }
7850}
7851const Qe = kE, Vt = {
7852  /**
7853   * Triggered when an item is added to the collection.
7854   * @event module:ol/Collection.CollectionEvent#add
7855   * @api
7856   */
7857  ADD: "add",
7858  /**
7859   * Triggered when an item is removed from the collection.
7860   * @eve
7860nt module:ol/Collection.CollectionEvent#remove
7861   * @api
7862   */
7863  REMOVE: "remove"
7864}, Au = {
7865  LENGTH: "length"
7866};
7867class no extends Le {
7868  /**
7869   * @param {import("./CollectionEventType.js").default} type Type.
7870   * @param {T} element Element.
7871   * @param {number} index The index of the added or removed element.
7872   */
7873  constructor(t, i, n) {
7874    super(t), this.element = i, this.index = n;
7875  }
7876}
7877class DE extends Qe {
7878  /**
7879   * @param {Array<T>} [array] Array.
7880   * @param {Options} [options] Collection options.
7881   */
7882  constructor(t, i) {
7883    if (super(), this.on, this.once, this.un, i = i || {}, this.unique_ = !!i.unique, this.array_ = t || [], this.unique_)
7884      for (let n = 0, s = this.array_.length; n < s; ++n)
7885        this.assertUnique_(this.array_[n], n);
7886    this.updateLength_();
7887  }
7888  /**
7889   * Remove all elements from the collection.
7890   * @api
7891   */
7892  clear() {
7893    for (; this.getLength() > 0; )
7894      this.pop();
7895  }
7896  /**
7897   * Add elements to the collection.  This pushes each item in the provided array
7898   * to the end of the collection.
7899   * @param {!Array<T>} arr Array.
7900   * @return {Collection<T>} This collection.
7901   * @api
7902   */
7903  extend(t) {
7904    for (let i = 0, n = t.length; i < n; ++i)
7905      this.push(t[i]);
7906    return this;
7907  }
7908  /**
7909   * Iterate over each element, calling the provided callback.
7910   * @param {function(T, number, Array<T>): *} f The function to call
7911   *     for every element. This function takes 3 arguments (the element, the
7912   *     index and the array). The return value is ignored.
7913   * @api
7914   */
7915  forEach(t) {
7916    const i = this.array_;
7917    for (let n = 0, s = i.length; n < s; ++n)
7918      t(i[n], n, i);
7919  }
7920  /**
7921   * Get a reference to the underlying Array object. Warning: if the array
7922   * is mutated, no events will be dispatched by the collection, and the
7923   * collection's "length" property won't be in sync with the actual length
7924   * of the array.
7925   * @return {!Array<T>} Array.
7926   * @api
7927   */
7928  getArray() {
7929    return this.array_;
7930  }
7931  /**
7932   * Get the element at the provided index.
7933   * @param {number} index Index.
7934   * @return {T} Element.
7935   * @api
7936   */
7937  item(t) {
7938    return this.array_[t];
7939  }
7940  /**
7941   * Get the length of this collection.
7942   * @return {number} The length of the array.
7943   * @observable
7944   * @api
7945   */
7946  getLength() {
7947    return this.get(Au.LENGTH);
7948  }
7949  /**
7950   * Insert an element at the provided index.
7951   * @param {number} index Index.
7952   * @param {T} elem Element.
7953   * @api
7954   */
7955  insertAt(t, i) {
7956    if (t < 0 || t > this.getLength())
7957      throw new Error("Index out of bounds: " + t);
7958    this.unique_ && this.assertUnique_(i), this.array_.splice(t, 0, i), this.updateLength_(), this.dispatchEvent(
7959      new no(Vt.ADD, i, t)
7960    );
7961  }
7962  /**
7963   * Remove the last element of the collection and return it.
7964   * Return `undefined` if the collection is empty.
7965   * @return {T|undefined} Element.
7966   * @api
7967   */
7968  pop() {
7969    return this.removeAt(this.getLength() - 1);
7970  }
7971  /**
7972   * Insert the provided element at the end of the collection.
7973   * @param {T} elem Element.
7974   * @return {number} New length of the collection.
7975   * @api
7976   */
7977  push(t) {
7978    this.unique_ && this.assertUnique_(t);
7979    const i = this.getLength();
7980    return this.insertAt(i, t), this.getLength();
7981  }
7982  /**
7983   * Remove the first occurrence of an element from the collection.
7984   * @param {T} elem Element.
7985   * @return {T|undefined} The removed element or undefined if none found.
7986   * @api
7987   */
7988  remove(t) {
7989    const i = this.array_;
7990    for (let n = 0, s = i.length; n < s; ++n)
7991      if (i[n] === t)
7992        return this.removeAt(n);
7993  }
7994  /**
7995   * Remove the element at the provided index and return it.
7996   * Return `undefined` if the collection does not contain this index.
7997   * @param {number} index Index.
7998   * @return {T|undefined} Value.
7999   * @api
8000   */
8001  removeAt(t) {
8002    if (t < 0 || t >= this.getLength())
8003      return;
8004    const i = this.array_[t];
8005    return this.array_.splice(t, 1), this.updateLength_(), this.dispatchEvent(
8006      /** @type {CollectionEvent<T>} */
8007      new no(Vt.REMOVE, i, t)
8008    ), i;
8009  }
8010  /**
8011   * Set the element at the provided index.
8012   * @param {number} index Index.
8013   * @param {T} elem Element.
8014   * @api
8015   */
8016  setAt(t, i) {
8017    const n = this.getLength();
8018    if (t >= n) {
8019      this.insertAt(t, i);
8020      return;
8021    }
8022    if (t < 0)
8023      throw new Error("Index out of bounds: " + t);
8024    this.unique_ && this.assertUnique_(i, t);
8025    const s = this.array_[t];
8026    this.array_[t] = i, this.dispatchEvent(
8027      /** @type {CollectionEvent<T>} */
8028      new no(Vt.REMOVE, s, t)
8029    ), this.dispatchEvent(
8030      /** @type {CollectionEvent<T>} */
8031      new no(Vt.ADD, i, t)
8032    );
8033  }
8034  /**
8035   * @private
8036   */
8037  updateLength_() {
8038    this.set(Au.LENGTH, this.array_.length);
8039  }
8040  /**
8041   * @private
8042   * @param {T} elem Element.
8043   * @param {number} [except] Optional index to ignore.
8044   */
8045  assertUnique_(t, i) {
8046    for (let n = 0, s = this.array_.length; n < s; ++n)
8047      if (this.array_[n] === t && n !== i)
8048        throw new Jd(58);
8049  }
8050}
8051const De = DE, rn = typeof navigator < "u" && typeof navigator.userAgent < "u" ? navigator.userAgent.toLowerCase() : "", NE = rn.includes("firefox"), GE = rn.includes("safari") && !rn.includes("chrom");
8052GE && (rn.includes("version/15.4") || /cpu (os|iphone os) 15_4 like mac os x/.test(rn));
8053const zE = rn.includes("webkit") && !rn.includes("edge"), jE = rn.includes("macintosh"), hg = typeof devicePixelRatio < "u" ? devicePixelRatio : 1, Oh = typeof WorkerGlobalScope < "u" && typeof OffscreenCanvas < "u" && self instanceof WorkerGlobalScope, WE = typeof Image < "u" && Image.prototype.decode, cg = function() {
8054  let e = !1;
8055  try {
8056    const t = Object.defineProperty({}, "passive", {
8057      get: function() {
8058        e = !0;
8059      }
8060    });
8061    window.addEventListener("_", null, t), window.removeEventListener("_", null, t);
8062  } catch {
8063  }
8064  return e;
8065}();
8066new Array(6);
8067function ui() {
8068  return [1, 0, 0, 1, 0, 0];
8069}
8070function BE(e, t, i, n, s, r, o) {
8071  return e[0] = t, e[1] = i, e[2] = n, e[3] = s, e[4] = r, e[5] = o, e;
8072}
8073function UE(e, t) {
8074  return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e[4] = t[4], e[5] = t[5], e;
8075}
8076function Bt(e, t) {
8077  const i = t[0], n = t[1];
8078  return t[0] = e[0] * i + e[2] * n + e[4], t[1] = e[1] * i + e[3] * n + e[5], t;
8079}
8080function XE(e, t, i) {
8081  return BE(e, t, 0, 0, i, 0, 0);
8082}
8083function gi(e, t, i, n, s, r, o, a) {
8084  const l = Math.sin(r), h = Math.cos(r);
8085  return e[0] = n * h, e[1] = s * l, e[2] = -n * l, e[3] = s * h, e[4] = o * n * h - a * n * l + t, e[5] = o * s * l + a * s * h + i, e;
8086}
8087function Ca(e, t) {
8088  const i = $E(t);
8089  ht(i !== 0, 32);
8090  const n = t[0], s = t[1], r = t[2], o = t[3], a = t[4], l = t[5];
8091  return e[0] = o / i, e[1] = -s / i, e[2] = -r / i, e[3] = n / i, e[4] = (r * l - o * a) / i, e[5] = -(n * l - s * a) / i, e;
8092}
8093function $E(e) {
8094  return e[0] * e[3] - e[1] * e[2];
8095}
8096let Ou;
8097function Fh(e) {
8098  const t = "matrix(" + e.join(", ") + ")";
8099  if (Oh)
8100    return t;
8101  const i = Ou || (Ou = document.createElement("div"));
8102  return i.style.transform = t, i.style.transform;
8103}
8104const YE = /^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i, KE = /^([a-z]*)$|^hsla?\(.*\)$/i;
8105function ug(e) {
8106  return typeof e == "string" ? e : dg(e);
8107}
8108function VE(e) {
8109  const t = document.createElement("div");
8110  if (t.style.color = e, t.style.color !== "") {
8111    document.body.appendChild(t);
8112    const i = getComputedStyle(t).color;
8113    return document.body.removeChild(t), i;
8114  }
8115  return "";
8116}
8117const qE = function() {
8118  const t = {};
8119  let i = 0;
8120  return (
8121    /**
8122     * @param {string} s String.
8123     * @return {Color} Color.
8124     */
8125    function(n) {
8126      let s;
8127      if (t.hasOwnProperty(n))
8128        s = t[n];
8129      else {
8130        if (i >= 1024) {
8131          let r = 0;
8132          for (const o in t)
8133            r++ & 3 || (delete t[o], --i);
8134        }
8135        s = HE(n), t[n] = s, ++i;
8136      }
8137      return s;
8138    }
8139  );
8140}();
8141function Wo(e) {
8142  return Array.isArray(e) ? e : qE(e);
8143}
8144function HE(e) {
8145  let t, i, n, s, r;
8146  if (KE.exec(e) && (e = VE(e)), YE.exec(e)) {
8147    const o = e.length - 1;
8148    let a;
8149    o <= 4 ? a = 1 : a = 2;
8150    const l = o === 4 || o === 8;
8151    t = parseInt(e.substr(1 + 0 * a, a), 16), i = parseInt(e.substr(1 + 1 * a, a), 16), n = parseInt(e.substr(1 + 2 * a, a), 16), l ? s = parseInt(e.substr(1 + 3 * a, a), 16) : s = 255, a == 1 && (t = (t << 4) + t, i = (i << 4) + i, n = (n << 4) + n, l && (s = (s << 4) + s)), r = [t, i, n, s / 255];
8152  } else
8153    e.startsWith("rgba(") ? (r = e.slice(5, -1).split(",").map(Number), Fu(r)) : e.startsWith("rgb(") ? (r = e.slice(4, -1).split(",").map(Number), r.push(1), Fu(r)) : ht(!1, 14);
8154  return r;
8155}
8156function Fu(e) {
8157  return e[0] = kt(e[0] + 0.5 | 0, 0, 255), e[1] = kt(e[1] + 0.5 | 0, 0, 255), e[2] = kt(e[2] + 0.5 | 0, 0, 255), e[3] = kt(e[3], 0, 1), e;
8158}
8159function dg(e) {
8160  let t = e[0];
8161  t != (t | 0) && (t = t + 0.5 | 0);
8162  let i = e[1];
8163  i != (i | 0) && (i = i + 0.5 | 0);
8164  let n = e[2];
8165  n != (n | 0) && (n = n + 0.5 | 0);
8166  const s = e[3] === void 0 ? 1 : Math.round(e[3] * 100) / 100;
8167  return "rgba(" + t + "," + i + "," + n + "," + s + ")";
8168}
8169class ZE {
8170  constructor() {
8171    this.cache_ = {}, this.cacheSize_ = 0, this.maxCacheSize_ = 32;
8172  }
8173  /**
8174   * FIXME empty description for jsdoc
8175   */
8176  clear() {
8177    this.cache_ = {}, this.cacheSize_ = 0;
8178  }
8179  /**
8180   * @return {boolean} Can expire cache.
8181   */
8182  canExpireCache() {
8183    return this.cacheSize_ > this.maxCacheSize_;
8184  }
8185  /**
8186   * FIXME empty description for jsdoc
8187   */
8188  expire() {
8189    if (this.canExpireCache()) {
8190      let t = 0;
8191      for (const i in this.cache_) {
8192        const n = this.cache_[i];
8193        !(t++ & 3) && !n.hasListener() && (delete this.cache_[i], --this.cacheSize_);
8194      }
8195    }
8196  }
8197  /**
8198   * @param {string} src Src.
8199   * @param {?string} crossOrigin Cross origin.
8200   * @param {import("../color.js").Color} color Color.
8201   * @return {import("./IconImage.js").default} Icon image.
8202   */
8203  get(t, i, n) {
8204    const s = ku(t, i, n);
8205    return s in this.cache_ ? this.cache_[s] : null;
8206  }
8207  /**
8208   * @param {string} src Src.
8209   * @param {?string} crossOrigin Cross origin.
8210   * @param {import("../color.js").Color} color Color.
8211   * @param {import("./IconImage.js").default} iconImage Icon image.
8212   */
8213  set(t, i, n, s) {
8214    const r = ku(t, i, n);
8215    this.cache_[r] = s, ++this.cacheSize_;
8216  }
8217  /**
8218   * Set the cache size of the icon cache. Default is `32`. Change this value when
8219   * your map uses more than 32 different icon images and you are not caching icon
8220   * styles on the application level.
8221   * @param {number} maxCacheSize Cache max size.
8222   * @api
8223   */
8224  setSize(t) {
8225    this.maxCacheSize_ = t, this.expire();
8226  }
8227}
8228function ku(e, t, i) {
8229  const n = i ? ug(i) : "null";
8230  return t + ":" + e + ":" + n;
8231}
8232const Bo = new ZE(), wt = {
8233  OPACITY: "opacity",
8234  VISIBLE: "visible",
8235  EXTENT: "extent",
8236  Z_INDEX: "zIndex",
8237  MAX_RESOLUTION: "maxResolution",
8238  MIN_RESOLUTION: "minResolution",
8239  MAX_ZOOM: "maxZoom",
8240  MIN_ZOOM: "minZoom",
8241  SOURCE: "source",
8242  MAP: "map"
8243};
8244class JE extends Qe {
8245  /**
8246   * @param {Options} options Layer options.
8247   */
8248  constructor(t) {
8249    super(), this.on, this.once, this.un, this.background_ = t.background;
8250    const i = Object.assign({}, t);
8251    typeof t.properties == "object" && (delete i.properties, Object.assign(i, t.properties)), i[wt.OPACITY] = t.opacity !== void 0 ? t.opacity : 1, ht(typeof i[wt.OPACITY] == "number", 64), i[wt.VISIBLE] = t.visible !== void 0 ? t.visible : !0, i[wt.Z_INDEX] = t.zIndex, i[wt.MAX_RESOLUTION] = t.maxResolution !== void 0 ? t.maxResolution : 1 / 0, i[wt.MIN_RESOLUTION] = t.minResolution !== void 0 ? t.minResolution : 0, i[wt.MIN_ZOOM] = t.minZoom !== void 0 ? t.minZoom : -1 / 0, i[wt.MAX_ZOOM] = t.maxZoom !== void 0 ? t.maxZoom : 1 / 0, this.className_ = i.className !== void 0 ? i.className : "ol-layer", delete i.className, this.setProperties(i), this.state_ = null;
8252  }
8253  /**
8254   * Get the background for this layer.
8255   * @return {BackgroundColor|false} Layer background.
8256   */
8257  getBackground() {
8258    return this.background_;
8259  }
8260  /**
8261   * @return {string} CSS class name.
8262   */
8263  getClassName() {
8264    return this.className_;
8265  }
8266  /**
8267   * This method is not meant to be called by layers or layer renderers because the state
8268   * is incorrect if the layer is included in a layer group.
8269   *
8270   * @param {boolean} [managed] Layer is managed.
8271   * @return {import("./Layer.js").State} Layer state.
8272   */
8273  getLayerState(t) {
8274    const i = this.state_ || /** @type {?} */
8275    {
8276      layer: this,
8277      managed: t === void 0 ? !0 : t
8278    }, n = this.getZIndex();
8279    return i.opacity = kt(Math.round(this.getOpacity() * 100) / 100, 0, 1), i.visible = this.getVisible(), i.extent = this.getExtent(), i.zIndex = n === void 0 && !i.managed ? 1 / 0 : n, i.maxResolution = this.getMaxResolution(), i.minResolution = Math.max(this.getMinResolution(), 0), i.minZoom = this.getMinZoom(), i.maxZoom = this.getMaxZoom(), this.state_ = i, i;
8280  }
8281  /**
8282   * @abstract
8283   * @param {Array<import("./Layer.js").default>} [array] Array of layers (to be
8284   *     modified in place).
8285   * @return {Array<import("./Layer.js").default>} Array of layers.
8286   */
8287  getLayersArray(t) {
8288    return Q();
8289  }
8290  /**
8291   * @abstract
8292   * @param {Array<import("./Layer.js").State>} [states] Optional list of layer
8293   *     states (to be modified in place).
8294   * @return {Array<import("./Layer.js").State>} List of layer states.
8295   */
8296  getLayerStatesArray(t) {
8297    return Q();
8298  }
8299  /**
8300   * Return the {@link module:ol/extent~Extent extent} of the layer or `undefined` if it
8301   * will be visible regardless of extent.
8302   * @return {import("../extent.js").Extent|undefined} The layer extent.
8303   * @observable
8304   * @api
8305   */
8306  getExtent() {
8307    return (
8308      /** @type {import("../extent.js").Extent|undefined} */
8309      this.get(wt.EXTENT)
8310    );
8311  }
8312  /**
8313   * Return the maximum resolution of the layer.
8314   * @return {number} The maximum resolution of the layer.
8315   * @observable
8316   * @api
8317   */
8318  getMaxResolution() {
8319    return (
8320      /** @type {number} */
8321      this.get(wt.MAX_RESOLUTION)
8322    );
8323  }
8324  /**
8325   * Return the minimum resolution of the layer.
8326   * @return {number} The minimum resolution of the layer.
8327   * @observable
8328   * @api
8329   */
8330  getMinResolution() {
8331    return (
8332      /** @type {number} */
8333      this.get(wt.MIN_RESOLUTION)
8334    );
8335  }
8336  /**
8337   * Return the minimum zoom level of the layer.
8338   * @return {number} The minimum zoom level of the layer.
8339   * @observable
8340   * @api
8341   */
8342  getMinZoom() {
8343    return (
8344      /** @type {number} */
8345      this.get(wt.MIN_ZOOM)
8346    );
8347  }
8348  /**
8349   * Return the maximum zoom level of the layer.
8350   * @return {number} The maximum zoom level of the layer.
8351   * @observable
8352   * @api
8353   */
8354  getMaxZoom() {
8355    return (
8356      /** @type {number} */
8357      this.get(wt.MAX_ZOOM)
8358    );
8359  }
8360  /**
8361   * Return the opacity of the layer (between 0 and 1).
8362   * @return {number} The opacity of the layer.
8363   * @observable
8364   * @api
8365   */
8366  getOpacity() {
8367    return (
8368      /** @type {number} */
8369      this.get(wt.OPACITY)
8370    );
8371  }
8372  /**
8373   * @abstract
8374   * @return {import("../source/Source.js").State} Source state.
8375   */
8376  getSourceState() {
8377    return Q();
8378  }
8379  /**
8380   * Return the value of this layer's `visible` property. To find out whether the layer
8381   * is visible on a map, use `isVisible()` instead.
8382   * @return {boolean} The value of the `visible` property of the layer.
8383   * @observable
8384   * @api
8385   */
8386  getVisible() {
8387    return (
8388      /** @type {boolean} */
8389      this.get(wt.VISIBLE)
8390    );
8391  }
8392  /**
8393   * Return the Z-index of the layer, which is used to order layers before
8394   * rendering. The default Z-index is 0.
8395   * @return {number} The Z-index of the layer.
8396   * @observable
8397   * @api
8398   */
8399  getZIndex() {
8400    return (
8401      /** @type {number} */
8402      this.get(wt.Z_INDEX)
8403    );
8404  }
8405  /**
8406   * Sets the background color.
8407   * @param {BackgroundColor} [background] Background color.
8408   */
8409  setBackground(t) {
8410    this.background_ = t, this.changed();
8411  }
8412  /**
8413   * Set the extent at which the layer is visible.  If `undefined`, the layer
8414   * will be visible at all extents.
8415   * @param {import("../extent.js").Extent|undefined} extent The extent of the layer.
8416   * @observable
8417   * @api
8418   */
8419  setExtent(t) {
8420    this.set(wt.EXTENT, t);
8421  }
8422  /**
8423   * Set the maximum resolution at which the layer is visible.
8424   * @param {number} maxResolution The maximum resolution of the layer.
8425   * @observable
8426   * @api
8427   */
8428  setMaxResolution(t) {
8429    this.set(wt.MAX_RESOLUTION, t);
8430  }
8431  /**
8432   * Set the minimum resolution at which the layer is visible.
8433   * @param {number} minResolution The minimum resolution of the layer.
8434   * @observable
8435   * @api
8436   */
8437  setMinResolution(t) {
8438    this.set(wt.MIN_RESOLUTION, t);
8439  }
8440  /**
8441   * Set the maximum zoom (exclusive) at which the layer is visible.
8442   * Note that the zoom levels for layer visibility are based on the
8443   * view zoom level, which may be different from a tile source zoom level.
8444   * @param {number} maxZoom The maximum zoom of the layer.
8445   * @observable
8446   * @api
8447   */
8448  setMaxZoom(t) {
8449    this.set(wt.MAX_ZOOM, t);
8450  }
8451  /**
8452   * Set the minimum zoom (inclusive) at which the layer is visible.
8453   * Note that the zoom levels for layer visibility are based on the
8454   * view zoom level, which may be different from a tile source zoom level.
8455   * @param {number} minZoom The minimum zoom of the layer.
8456   * @observable
8457   * @api
8458   */
8459  setMinZoom(t) {
8460    this.set(wt.MIN_ZOOM, t);
8461  }
8462  /**
8463   * Set the opacity of the layer, allowed values range from 0 to 1.
8464   * @param {number} opacity The opacity of the layer.
8465   * @observable
8466   * @api
8467   */
8468  setOpacity(t) {
8469    ht(typeof t == "number", 64), this.set(wt.OPACITY, t);
8470  }
8471  /**
8472   * Set the visibility of the layer (`true` or `false`).
8473   * @param {boolean} visible The visibility of the layer.
8474   * @observable
8475   * @api
8476   */
8477  setVisible(t) {
8478    this.set(wt.VISIBLE, t);
8479  }
8480  /**
8481   * Set Z-index of the layer, which is used to order layers before rendering.
8482   * The default Z-index is 0.
8483   * @param {number} zindex The z-index of the layer.
8484   * @observable
8485   * @api
8486   */
8487  setZIndex(t) {
8488    this.set(wt.Z_INDEX, t);
8489  }
8490  /**
8491   * Clean up.
8492   */
8493  disposeInternal() {
8494    this.state_ && (this.state_.layer = null, this.state_ = null), super.disposeInternal();
8495  }
8496}
8497const fg = JE, Ji = {
8498  /**
8499   * Triggered before a layer is rendered.
8500   * @event module:ol/render/Event~RenderEvent#prerender
8501   * @api
8502   */
8503  PRERENDER: "prerender",
8504  /**
8505   * Triggered after a layer is rendered.
8506   * @event module:ol/render/Event~RenderEvent#postrender
8507   * @api
8508   */
8509  POSTRENDER: "postrender",
8510  /**
8511   * Triggered before layers are composed.  When dispatched by the map, the event object will not have
8512   * a `context` set.  When dispatched by a layer, the event object will have a `context` set.  Only
8513   * WebGL layers currently dispatch this event.
8514   * @event module:ol/render/Event~RenderEvent#precompose
8515   * @api
8516   */
8517  PRECOMPOSE: "precompose",
8518  /**
8519   * Triggered after layers are composed.  When dispatched by the map, the event object will not have
8520   * a `context` set.  When dispatched by a layer, the event object will have a `context` set.  Only
8521   * WebGL layers currently dispatch this event.
8522   * @event module:ol/render/Event~RenderEvent#postcompose
8523   * @api
8524   */
8525  POSTCOMPOSE: "postcompose",
8526  /**
8527   * Triggered when rendering is complete, i.e. all sources and tiles have
8528   * finished loading for the current viewport, and all tiles are faded in.
8529   * The event object will not have a `context` set.
8530   * @event module:ol/render/Event~RenderEvent#rendercomplete
8531   * @api
8532   */
8533  RENDERCOMPLETE: "rendercomplete"
8534}, Kt = {
8535  ANIMATING: 0,
8536  INTERACTING: 1
8537}, Ge = {
8538  CENTER: "center",
8539  RESOLUTION: "resolution",
8540  ROTATION: "rotation"
8541}, QE = 42, kh = 256;
8542function Du(e, t, i) {
8543  return (
8544    /**
8545     * @param {import("./coordinate.js").Coordinate|undefined} center Center.
8546     * @param {number|undefined} resolution Resolution.
8547     * @param {import("./size.js").Size} size Viewport size; unused if `onlyCenter` was specified.
8548     * @param {boolean} [isMoving] True if an interaction or animation is in progress.
8549     * @param {Array<number>} [centerShift] Shift between map center and viewport center.
8550     * @return {import("./coordinate.js").Coordinate|undefined} Center.
8551     */
8552    function(n, s, r, o, a) {
8553      if (!n)
8554        return;
8555      if (!s && !t)
8556        return n;
8557      const l = t ? 0 : r[0] * s, h = t ? 0 : r[1] * s, c = a ? a[0] : 0, u = a ? a[1] : 0;
8558      let d = e[0] + l / 2 + c, f = e[2] - l / 2 + c, g = e[1] + h / 2 + u, m = e[3] - h / 2 + u;
8559      d > f && (d = (f + d) / 2, f = d), g > m && (g = (m + g) / 2, m = g);
8560      let _ = kt(n[0], d, f), p = kt(n[1], g, m);
8561      if (o && i && s) {
8562        const y = 30 * s;
8563        _ += -y * Math.log(1 + Math.max(0, d - n[0]) / y) + y * Math.log(1 + Math.max(0, n[0] - f) / y), p += -y * Math.log(1 + Math.max(0, g - n[1]) / y) + y * Math.log(1 + Math.max(0, n[1] - m) / y);
8564      }
8565      return [_, p];
8566    }
8567  );
8568}
8569function tC(e) {
8570  return e;
8571}
8572function Dh(e, t, i, n) {
8573  const s = xt(t) / i[0], r = qt(t) / i[1];
8574  return n ? Math.min(e, Math.max(s, r)) : Math.min(e, Math.min(s, r));
8575}
8576function Nh(e, t, i) {
8577  let n = Math.min(e, t);
8578  const s = 50;
8579  return n *= Math.log(1 + s * Math.max(0, e / t - 1)) / s + 1, i && (n = Math.max(n, i), n /= Math.log(1 + s * Math.max(0, i / e - 1)) / s + 1), kt(n, i / 2, t * 2);
8580}
8581function eC(e, t, i, n) {
8582  return t = t !== void 0 ? t : !0, /**
8583   * @param {number|undefined} resolution Resolution.
8584   * @param {number} direction Direction.
8585   * @param {import("./size.js").Size} size Viewport size.
8586   * @param {boolean} [isMoving] True if an interaction or animation is in progress.
8587   * @return {number|undefined} Resolution.
8588   */
8589  function(s, r, o, a) {
8590    if (s !== void 0) {
8591      const l = e[0], h = e[e.length - 1], c = i ? Dh(
8592        l,
8593        i,
8594        o,
8595        n
8596      ) : l;
8597      if (a)
8598        return t ? Nh(
8599          s,
8600          c,
8601          h
8602        ) : kt(s, h, c);
8603      const u = Math.min(c, s), d = Math.floor(va(e, u, r));
8604      return e[d] > c && d < e.length - 1 ? e[d + 1] : e[d];
8605    }
8606  };
8607}
8608function iC(e, t, i, n, s, r) {
8609  return n = n !== void 0 ? n : !0, i = i !== void 0 ? i : 0, /**
8610   * @param {number|undefined} resolution Resolution.
8611   * @param {number} direction Direction.
8612   * @param {import("./size.js").Size} size Viewport size.
8613   * @param {boolean} [isMoving] True if an interaction or animation is in progress.
8614   * @return {number|undefined} Resolution.
8615   */
8616  function(o, a, l, h) {
8617    if (o !== void 0) {
8618      const c = s ? Dh(
8619        t,
8620        s,
8621        l,
8622        r
8623      ) : t;
8624      if (h)
8625        return n ? Nh(
8626          o,
8627          c,
8628          i
8629        ) : kt(o, i, c);
8630      const u = 1e-9, d = Math.ceil(
8631        Math.log(t / c) / Math.log(e) - u
8632      ), f = -a * (0.5 - u) + 0.5, g = Math.min(c, o), m = Math.floor(
8633        Math.log(t / g) / Math.log(e) + f
8634      ), _ = Math.max(d, m), p = t / Math.pow(e, _);
8635      return kt(p, i, c);
8636    }
8637  };
8638}
8639function Nu(e, t, i, n, s) {
8640  return i = i !== void 0 ? i : !0, /**
8641   * @param {number|undefined} resolution Resolution.
8642   * @param {number} direction Direction.
8643   * @param {import("./size.js").Size} size Viewport size.
8644   * @param {boolean} [isMoving] True if an interaction or animation is in progress.
8645   * @return {number|undefined} Resolution.
8646   */
8647  function(r, o, a, l) {
8648    if (r !== void 0) {
8649      const h = n ? Dh(
8650        e,
8651        n,
8652        a,
8653        s
8654      ) : e;
8655      return !i || !l ? kt(r, t, h) : Nh(
8656        r,
8657        h,
8658        t
8659      );
8660    }
8661  };
8662}
8663function Gh(e) {
8664  if (e !== void 0)
8665    return 0;
8666}
8667function Gu(e) {
8668  if (e !== void 0)
8669    return e;
8670}
8671function nC(e) {
8672  const t = 2 * Math.PI / e;
8673  return (
8674    /**
8675     * @param {number|undefined} rotation Rotation.
8676     * @param {boolean} [isMoving] True if an interaction or animation is in progress.
8677     * @return {number|undefined} Rotation.
8678     */
8679    function(i, n) {
8680      if (n)
8681        return i;
8682      if (i !== void 0)
8683        return i = Math.floor(i / t + 0.5) * t, i;
8684    }
8685  );
8686}
8687function sC(e) {
8688  return e = e || Cn(5), /**
8689   * @param {number|undefined} rotation Rotation.
8690   * @param {boolean} [isMoving] True if an interaction or animation is in progress.
8691   * @return {number|undefined} Rotation.
8692   */
8693  function(t, i) {
8694    if (i)
8695      return t;
8696    if (t !== void 0)
8697      return Math.abs(t) <= e ? 0 : t;
8698  };
8699}
8700function gg(e) {
8701  return Math.pow(e, 3);
8702}
8703function js(e) {
8704  return 1 - gg(1 - e);
8705}
8706function rC(e) {
8707  return 3 * e * e - 2 * e * e * e;
8708}
8709function oC(e) {
8710  return e;
8711}
8712function wn(e, t, i, n, s, r) {
8713  r = r || [];
8714  let o = 0;
8715  for (let a = t; a < i; a += n) {
8716    const l = e[a], h = e[a + 1];
8717    r[o++] = s[0] * l + s[2] * h + s[4], r[o++] = s[1] * l + s[3] * h + s[5];
8718  }
8719  return r && r.length != o && (r.length = o), r;
8720}
8721function zh(e, t, i, n, s, r, o) {
8722  o = o || [];
8723  const a = Math.cos(s), l = Math.sin(s), h = r[0], c = r[1];
8724  let u = 0;
8725  for (let d = t; d < i; d += n) {
8726    const f = e[d] - h, g = e[d + 1] - c;
8727    o[u++] = h + f * a - g * l, o[u++] = c + f * l + g * a;
8728    for (let m = d + 2; m < d + n; ++m)
8729      o[u++] = e[m];
8730  }
8731  return o && o.length != u && (o.length = u), o;
8732}
8733function aC(e, t, i, n, s, r, o, a) {
8734  a = a || [];
8735  const l = o[0], h = o[1];
8736  let c = 0;
8737  for (let u = t; u < i; u += n) {
8738    const d = e[u] - l, f = e[u + 1] - h;
8739    a[c++] = l + s * d, a[c++] = h + r * f;
8740    for (let g = u + 2; g < u + n; ++g)
8741      a[c++] = e[g];
8742  }
8743  return a && a.length != c && (a.length = c), a;
8744}
8745function lC(e, t, i, n, s, r, o) {
8746  o = o || [];
8747  let a = 0;
8748  for (let l = t; l < i; l += n) {
8749    o[a++] = e[l] + s, o[a++] = e[l + 1] + r;
8750    for (let h = l + 2; h < l + n; ++h)
8751      o[a++] = e[h];
8752  }
8753  return o && o.length != a && (o.length = a), o;
8754}
8755const zu = ui();
8756class hC extends Qe {
8757  constructor() {
8758    super(), this.extent_ = be(), this.extentRevision_ = -1, this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = 0, this.simplifyTransformedInternal = LE(function(t, i, n) {
8759      if (!n)
8760        return this.getSimplifiedGeometry(i);
8761      const s = this.clone();
8762      return s.applyTransform(n), s.getSimplifiedGeometry(i);
8763    });
8764  }
8765  /**
8766   * Get a transformed and simplified version of the geometry.
8767   * @abstract
8768   * @param {number} squaredTolerance Squared tolerance.
8769   * @param {import("../proj.js").TransformFunction} [transform] Optional transform function.
8770   * @return {Geometry} Simplified geometry.
8771   */
8772  simplifyTransformed(t, i) {
8773    return this.simplifyTransformedInternal(
8774      this.getRevision(),
8775      t,
8776      i
8777    );
8778  }
8779  /**
8780   * Make a complete copy of the geometry.
8781   * @abstract
8782   * @return {!Geometry} Clone.
8783   */
8784  clone() {
8785    return Q();
8786  }
8787  /**
8788   * @abstract
8789   * @param {number} x X.
8790   * @param {number} y Y.
8791   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
8792   * @param {number} minSquaredDistance Minimum squared distance.
8793   * @return {number} Minimum squared distance.
8794   */
8795  closestPointXY(t, i, n, s) {
8796    return Q();
8797  }
8798  /**
8799   * @param {number} x X.
8800   * @param {number} y Y.
8801   * @return {boolean} Contains (x, y).
8802   */
8803  containsXY(t, i) {
8804    const n = this.getClosestPoint([t, i]);
8805    return n[0] === t && n[1] === i;
8806  }
8807  /**
8808   * Return the closest point of the geometry to the passed point as
8809   * {@link module:ol/coordinate~Coordinate coordinate}.
8810   * @param {import("../coordinate.js").Coordinate} point Point.
8811   * @param {import("../coordinate.js").Coordinate} [closestPoint] Closest point.
8812   * @return {import("../coordinate.js").Coordinate} Closest point.
8813   * @api
8814   */
8815  getClosestPoint(t, i) {
8816    return i = i || [NaN, NaN], this.closestPointXY(t[0], t[1], i, 1 / 0), i;
8817  }
8818  /**
8819   * Returns true if this geometry includes the specified coordinate. If the
8820   * coordinate is on the boundary of the geometry, returns false.
8821   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
8822   * @return {boolean} Contains coordinate.
8823   * @api
8824   */
8825  intersectsCoordinate(t) {
8826    return this.containsXY(t[0], t[1]);
8827  }
8828  /**
8829   * @abstract
8830   * @param {import("../extent.js").Extent} extent Extent.
8831   * @protected
8832   * @return {import("../extent.js").Extent} extent Extent.
8833   */
8834  computeExtent(t) {
8835    return Q();
8836  }
8837  /**
8838   * Get the extent of the geometry.
8839   * @param {import("../extent.js").Extent} [extent] Extent.
8840   * @return {import("../extent.js").Extent} extent Extent.
8841   * @api
8842   */
8843  getExtent(t) {
8844    if (this.extentRevision_ != this.getRevision()) {
8845      const i = this.computeExtent(this.extent_);
8846      (isNaN(i[0]) || isNaN(i[1])) && Ns(i), this.extentRevision_ = this.getRevision();
8847    }
8848    return wx(this.extent_, t);
8849  }
8850  /**
8851   * Rotate the geometry around a given coordinate. This modifies the geometry
8852   * coordinates in place.
8853   * @abstract
8854   * @param {number} angle Rotation angle in radians.
8855   * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
8856   * @api
8857   */
8858  rotate(t, i) {
8859    Q();
8860  }
8861  /**
8862   * Scale the geometry (with an optional origin).  This modifies the geometry
8863   * coordinates in place.
8864   * @abstract
8865   * @param {number} sx The scaling factor in the x-direction.
8866   * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
8867   * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
8868   *     of the geometry extent).
8869   * @api
8870   */
8871  scale(t, i, n) {
8872    Q();
8873  }
8874  /**
8875   * Create a simplified version of this geometry.  For linestrings, this uses
8876   * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)
8877   * algorithm.  For polygons, a quantization-based
8878   * simplification is used to preserve topology.
8879   * @param {number} tolerance The tolerance distance for simplification.
8880   * @return {Geometry} A new, simplified version of the original geometry.
8881   * @api
8882   */
8883  simplify(t) {
8884    return this.getSimplifiedGeometry(t * t);
8885  }
8886  /**
8887   * Create a simplified version of this geometry using the Douglas Peucker
8888   * algorithm.
8889   * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.
8890   * @abstract
8891   * @param {number} squaredTolerance Squared tolerance.
8892   * @return {Geometry} Simplified geometry.
8893   */
8894  getSimplifiedGeometry(t) {
8895    return Q();
8896  }
8897  /**
8898   * Get the type of this geometry.
8899   * @abstract
8900   * @return {Type} Geometry type.
8901   */
8902  getType() {
8903    return Q();
8904  }
8905  /**
8906   * Apply a transform function to the coordinates of the geometry.
8907   * The geometry is modified in place.
8908   * If you do not want the geometry modified in place, first `clone()` it and
8909   * then use this function on the clone.
8910   * @abstract
8911   * @param {import("../proj.js").TransformFunction} transformFn Transform function.
8912   * Called with a flat array of geometry coordinates.
8913   */
8914  applyTransform(t) {
8915    Q();
8916  }
8917  /**
8918   * Test if the geometry and the passed extent intersect.
8919   * @abstract
8920   * @param {import("../extent.js").Extent} extent Extent.
8921   * @return {boolean} `true` if the geometry and the extent intersect.
8922   */
8923  intersectsExtent(t) {
8924    return Q();
8925  }
8926  /**
8927   * Translate the geometry.  This modifies the geometry coordinates in place.  If
8928   * instead you want a new geometry, first `clone()` this geometry.
8929   * @abstract
8930   * @param {number} deltaX Delta X.
8931   * @param {number} deltaY Delta Y.
8932   * @api
8933   */
8934  translate(t, i) {
8935    Q();
8936  }
8937  /**
8938   * Transform each coordinate of the geometry from one coordinate reference
8939   * system to another. The geometry is modified in place.
8940   * For example, a line will be transformed to a line and a circle to a circle.
8941   * If you do not want the geometry modified in place, first `clone()` it and
8942   * then use this function on the clone.
8943   *
8944   * @param {import("../proj.js").ProjectionLike} source The current projection.  Can be a
8945   *     string identifier or a {@link module:ol/proj/Projection~Projection} object.
8946   * @param {import("../proj.js").ProjectionLike} destination The desired projection.  Can be a
8947   *     string identifier or a {@link module:ol/proj/Projection~Projection} object.
8948   * @return {Geometry} This geometry.  Note that original geometry is
8949   *     modified in place.
8950   * @api
8951   */
8952  transform(t, i) {
8953    const n = It(t), s = n.getUnits() == "tile-pixels" ? function(r, o, a) {
8954      const l = n.getExtent(), h = n.getWorldExtent(), c = qt(h) / qt(l);
8955      return gi(
8956        zu,
8957        h[0],
8958        h[3],
8959        c,
8960        -c,
8961        0,
8962        0,
8963        0
8964      ), wn(
8965        r,
8966        0,
8967        r.length,
8968        a,
8969        zu,
8970        o
8971      ), gr(n, i)(
8972        r,
8973        o,
8974        a
8975      );
8976    } : gr(n, i);
8977    return this.applyTransform(s), this;
8978  }
8979}
8980const mg = hC;
8981class cC extends mg {
8982  constructor() {
8983    super(), this.layout = "XY", this.stride = 2, this.flatCoordinates = null;
8984  }
8985  /**
8986   * @param {import("../extent.js").Extent} extent Extent.
8987   * @protected
8988   * @return {import("../extent.js").Extent} extent Extent.
8989   */
8990  computeExtent(t) {
8991    return tf(
8992      this.flatCoordinates,
8993      0,
8994      this.flatCoordinates.length,
8995      this.stride,
8996      t
8997    );
8998  }
8999  /**
9000   * @abstract
9001   * @return {Array<*> | null} Coordinates.
9002   */
9003  getCoordinates() {
9004    return Q();
9005  }
9006  /**
9007   * Return the first coordinate of the geometry.
9008   * @return {import("../coordinate.js").Coordinate} First coordinate.
9009   * @api
9010   */
9011  getFirstCoordinate() {
9012    return this.flatCoordinates.slice(0, this.stride);
9013  }
9014  /**
9015   * @return {Array<number>} Flat coordinates.
9016   */
9017  getFlatCoordinates() {
9018    return this.flatCoordinates;
9019  }
9020  /**
9021   * Return the last coordinate of the geometry.
9022   * @return {import("../coordinate.js").Coordinate} Last point.
9023   * @api
9024   */
9025  getLastCoordinate() {
9026    return this.flatCoordinates.slice(
9027      this.flatCoordinates.length - this.stride
9028    );
9029  }
9030  /**
9031   * Return the {@link import("./Geometry.js").GeometryLayout layout} of the geometry.
9032   * @return {import("./Geometry.js").GeometryLayout} Layout.
9033   * @api
9034   */
9035  getLayout() {
9036    return this.layout;
9037  }
9038  /**
9039   * Create a simplified version of this geometry using the Douglas Peucker algorithm.
9040   * @param {number} squaredTolerance Squared tolerance.
9041   * @return {SimpleGeometry} Simplified geometry.
9042   */
9043  getSimplifiedGeometry(t) {
9044    if (this.simplifiedGeometryRevision !== this.getRevision() && (this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = this.getRevision()), t 
9044< 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && t <= this.simplifiedGeometryMaxMinSquaredTolerance)
9045      return this;
9046    const i = this.getSimplifiedGeometryInternal(t);
9047    return i.getFlatCoordinates().length < this.flatCoordinates.length ? i : (this.simplifiedGeometryMaxMinSquaredTolerance = t, this);
9048  }
9049  /**
9050   * @param {number} squaredTolerance Squared tolerance.
9051   * @return {SimpleGeometry} Simplified geometry.
9052   * @protected
9053   */
9054  getSimplifiedGeometryInternal(t) {
9055    return this;
9056  }
9057  /**
9058   * @return {number} Stride.
9059   */
9060  getStride() {
9061    return this.stride;
9062  }
9063  /**
9064   * @param {import("./Geometry.js").GeometryLayout} layout Layout.
9065   * @param {Array<number>} flatCoordinates Flat coordinates.
9066   */
9067  setFlatCoordinates(t, i) {
9068    this.stride = Uo(t), this.layout = t, this.flatCoordinates = i;
9069  }
9070  /**
9071   * @abstract
9072   * @param {!Array<*>} coordinates Coordinates.
9073   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
9074   */
9075  setCoordinates(t, i) {
9076    Q();
9077  }
9078  /**
9079   * @param {import("./Geometry.js").GeometryLayout|undefined} layout Layout.
9080   * @param {Array<*>} coordinates Coordinates.
9081   * @param {number} nesting Nesting.
9082   * @protected
9083   */
9084  setLayout(t, i, n) {
9085    let s;
9086    if (t)
9087      s = Uo(t);
9088    else {
9089      for (let r = 0; r < n; ++r) {
9090        if (i.length === 0) {
9091          this.layout = "XY", this.stride = 2;
9092          return;
9093        }
9094        i = /** @type {Array} */
9095        i[0];
9096      }
9097      s = i.length, t = uC(s);
9098    }
9099    this.layout = t, this.stride = s;
9100  }
9101  /**
9102   * Apply a transform function to the coordinates of the geometry.
9103   * The geometry is modified in place.
9104   * If you do not want the geometry modified in place, first `clone()` it and
9105   * then use this function on the clone.
9106   * @param {import("../proj.js").TransformFunction} transformFn Transform function.
9107   * Called with a flat array of geometry coordinates.
9108   * @api
9109   */
9110  applyTransform(t) {
9111    this.flatCoordinates && (t(this.flatCoordinates, this.flatCoordinates, this.stride), this.changed());
9112  }
9113  /**
9114   * Rotate the geometry around a given coordinate. This modifies the geometry
9115   * coordinates in place.
9116   * @param {number} angle Rotation angle in counter-clockwise radians.
9117   * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
9118   * @api
9119   */
9120  rotate(t, i) {
9121    const n = this.getFlatCoordinates();
9122    if (n) {
9123      const s = this.getStride();
9124      zh(
9125        n,
9126        0,
9127        n.length,
9128        s,
9129        t,
9130        i,
9131        n
9132      ), this.changed();
9133    }
9134  }
9135  /**
9136   * Scale the geometry (with an optional origin).  This modifies the geometry
9137   * coordinates in place.
9138   * @param {number} sx The scaling factor in the x-direction.
9139   * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
9140   * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
9141   *     of the geometry extent).
9142   * @api
9143   */
9144  scale(t, i, n) {
9145    i === void 0 && (i = t), n || (n = Je(this.getExtent()));
9146    const s = this.getFlatCoordinates();
9147    if (s) {
9148      const r = this.getStride();
9149      aC(
9150        s,
9151        0,
9152        s.length,
9153        r,
9154        t,
9155        i,
9156        n,
9157        s
9158      ), this.changed();
9159    }
9160  }
9161  /**
9162   * Translate the geometry.  This modifies the geometry coordinates in place.  If
9163   * instead you want a new geometry, first `clone()` this geometry.
9164   * @param {number} deltaX Delta X.
9165   * @param {number} deltaY Delta Y.
9166   * @api
9167   */
9168  translate(t, i) {
9169    const n = this.getFlatCoordinates();
9170    if (n) {
9171      const s = this.getStride();
9172      lC(
9173        n,
9174        0,
9175        n.length,
9176        s,
9177        t,
9178        i,
9179        n
9180      ), this.changed();
9181    }
9182  }
9183}
9184function uC(e) {
9185  let t;
9186  return e == 2 ? t = "XY" : e == 3 ? t = "XYZ" : e == 4 && (t = "XYZM"), /** @type {import("./Geometry.js").GeometryLayout} */
9187  t;
9188}
9189function Uo(e) {
9190  let t;
9191  return e == "XY" ? t = 2 : e == "XYZ" || e == "XYM" ? t = 3 : e == "XYZM" && (t = 4), /** @type {number} */
9192  t;
9193}
9194function dC(e, t, i) {
9195  const n = e.getFlatCoordinates();
9196  if (!n)
9197    return null;
9198  const s = e.getStride();
9199  return wn(
9200    n,
9201    0,
9202    n.length,
9203    s,
9204    t,
9205    i
9206  );
9207}
9208const an = cC;
9209function ju(e, t, i, n, s, r, o) {
9210  const a = e[t], l = e[t + 1], h = e[i] - a, c = e[i + 1] - l;
9211  let u;
9212  if (h === 0 && c === 0)
9213    u = t;
9214  else {
9215    const d = ((s - a) * h + (r - l) * c) / (h * h + c * c);
9216    if (d > 1)
9217      u = i;
9218    else if (d > 0) {
9219      for (let f = 0; f < n; ++f)
9220        o[f] = Pe(
9221          e[t + f],
9222          e[i + f],
9223          d
9224        );
9225      o.length = n;
9226      return;
9227    } else
9228      u = t;
9229  }
9230  for (let d = 0; d < n; ++d)
9231    o[d] = e[u + d];
9232  o.length = n;
9233}
9234function jh(e, t, i, n, s) {
9235  let r = e[t], o = e[t + 1];
9236  for (t += n; t < i; t += n) {
9237    const a = e[t], l = e[t + 1], h = Mi(r, o, a, l);
9238    h > s && (s = h), r = a, o = l;
9239  }
9240  return s;
9241}
9242function Wh(e, t, i, n, s) {
9243  for (let r = 0, o = i.length; r < o; ++r) {
9244    const a = i[r];
9245    s = jh(e, t, a, n, s), t = a;
9246  }
9247  return s;
9248}
9249function fC(e, t, i, n, s) {
9250  for (let r = 0, o = i.length; r < o; ++r) {
9251    const a = i[r];
9252    s = Wh(e, t, a, n, s), t = a[a.length - 1];
9253  }
9254  return s;
9255}
9256function Bh(e, t, i, n, s, r, o, a, l, h, c) {
9257  if (t == i)
9258    return h;
9259  let u, d;
9260  if (s === 0) {
9261    if (d = Mi(
9262      o,
9263      a,
9264      e[t],
9265      e[t + 1]
9266    ), d < h) {
9267      for (u = 0; u < n; ++u)
9268        l[u] = e[t + u];
9269      return l.length = n, d;
9270    }
9271    return h;
9272  }
9273  c = c || [NaN, NaN];
9274  let f = t + n;
9275  for (; f < i; )
9276    if (ju(
9277      e,
9278      f - n,
9279      f,
9280      n,
9281      o,
9282      a,
9283      c
9284    ), d = Mi(o, a, c[0], c[1]), d < h) {
9285      for (h = d, u = 0; u < n; ++u)
9286        l[u] = c[u];
9287      l.length = n, f += n;
9288    } else
9289      f += n * Math.max(
9290        (Math.sqrt(d) - Math.sqrt(h)) / s | 0,
9291        1
9292      );
9293  if (r && (ju(
9294    e,
9295    i - n,
9296    t,
9297    n,
9298    o,
9299    a,
9300    c
9301  ), d = Mi(o, a, c[0], c[1]), d < h)) {
9302    for (h = d, u = 0; u < n; ++u)
9303      l[u] = c[u];
9304    l.length = n;
9305  }
9306  return h;
9307}
9308function Uh(e, t, i, n, s, r, o, a, l, h, c) {
9309  c = c || [NaN, NaN];
9310  for (let u = 0, d = i.length; u < d; ++u) {
9311    const f = i[u];
9312    h = Bh(
9313      e,
9314      t,
9315      f,
9316      n,
9317      s,
9318      r,
9319      o,
9320      a,
9321      l,
9322      h,
9323      c
9324    ), t = f;
9325  }
9326  return h;
9327}
9328function gC(e, t, i, n, s, r, o, a, l, h, c) {
9329  c = c || [NaN, NaN];
9330  for (let u = 0, d = i.length; u < d; ++u) {
9331    const f = i[u];
9332    h = Uh(
9333      e,
9334      t,
9335      f,
9336      n,
9337      s,
9338      r,
9339      o,
9340      a,
9341      l,
9342      h,
9343      c
9344    ), t = f[f.length - 1];
9345  }
9346  return h;
9347}
9348function _g(e, t, i, n) {
9349  for (let s = 0, r = i.length; s < r; ++s)
9350    e[t++] = i[s];
9351  return t;
9352}
9353function Ma(e, t, i, n) {
9354  for (let s = 0, r = i.length; s < r; ++s) {
9355    const o = i[s];
9356    for (let a = 0; a < n; ++a)
9357      e[t++] = o[a];
9358  }
9359  return t;
9360}
9361function Xh(e, t, i, n, s) {
9362  s = s || [];
9363  let r = 0;
9364  for (let o = 0, a = i.length; o < a; ++o) {
9365    const l = Ma(
9366      e,
9367      t,
9368      i[o],
9369      n
9370    );
9371    s[r++] = l, t = l;
9372  }
9373  return s.length = r, s;
9374}
9375function mC(e, t, i, n, s) {
9376  s = s || [];
9377  let r = 0;
9378  for (let o = 0, a = i.length; o < a; ++o) {
9379    const l = Xh(
9380      e,
9381      t,
9382      i[o],
9383      n,
9384      s[r]
9385    );
9386    l.length === 0 && (l[0] = t), s[r++] = l, t = l[l.length - 1];
9387  }
9388  return s.length = r, s;
9389}
9390function $h(e, t, i, n, s, r, o) {
9391  const a = (i - t) / n;
9392  if (a < 3) {
9393    for (; t < i; t += n)
9394      r[o++] = e[t], r[o++] = e[t + 1];
9395    return o;
9396  }
9397  const l = new Array(a);
9398  l[0] = 1, l[a - 1] = 1;
9399  const h = [t, i - n];
9400  let c = 0;
9401  for (; h.length > 0; ) {
9402    const u = h.pop(), d = h.pop();
9403    let f = 0;
9404    const g = e[d], m = e[d + 1], _ = e[u], p = e[u + 1];
9405    for (let y = d + n; y < u; y += n) {
9406      const x = e[y], E = e[y + 1], M = Rx(x, E, g, m, _, p);
9407      M > f && (c = y, f = M);
9408    }
9409    f > s && (l[(c - t) / n] = 1, d + n < c && h.push(d, c), c + n < u && h.push(c, u));
9410  }
9411  for (let u = 0; u < a; ++u)
9412    l[u] && (r[o++] = e[t + u * n], r[o++] = e[t + u * n + 1]);
9413  return o;
9414}
9415function _C(e, t, i, n, s, r, o, a) {
9416  for (let l = 0, h = i.length; l < h; ++l) {
9417    const c = i[l];
9418    o = $h(
9419      e,
9420      t,
9421      c,
9422      n,
9423      s,
9424      r,
9425      o
9426    ), a.push(o), t = c;
9427  }
9428  return o;
9429}
9430function mn(e, t) {
9431  return t * Math.round(e / t);
9432}
9433function pC(e, t, i, n, s, r, o) {
9434  if (t == i)
9435    return o;
9436  let a = mn(e[t], s), l = mn(e[t + 1], s);
9437  t += n, r[o++] = a, r[o++] = l;
9438  let h, c;
9439  do
9440    if (h = mn(e[t], s), c = mn(e[t + 1], s), t += n, t == i)
9441      return r[o++] = h, r[o++] = c, o;
9442  while (h == a && c == l);
9443  for (; t < i; ) {
9444    const u = mn(e[t], s), d = mn(e[t + 1], s);
9445    if (t += n, u == h && d == c)
9446      continue;
9447    const f = h - a, g = c - l, m = u - a, _ = d - l;
9448    if (f * _ == g * m && (f < 0 && m < f || f == m || f > 0 && m > f) && (g < 0 && _ < g || g == _ || g > 0 && _ > g)) {
9449      h = u, c = d;
9450      continue;
9451    }
9452    r[o++] = h, r[o++] = c, a = h, l = c, h = u, c = d;
9453  }
9454  return r[o++] = h, r[o++] = c, o;
9455}
9456function pg(e, t, i, n, s, r, o, a) {
9457  for (let l = 0, h = i.length; l < h; ++l) {
9458    const c = i[l];
9459    o = pC(
9460      e,
9461      t,
9462      c,
9463      n,
9464      s,
9465      r,
9466      o
9467    ), a.push(o), t = c;
9468  }
9469  return o;
9470}
9471function yC(e, t, i, n, s, r, o, a) {
9472  for (let l = 0, h = i.length; l < h; ++l) {
9473    const c = i[l], u = [];
9474    o = pg(
9475      e,
9476      t,
9477      c,
9478      n,
9479      s,
9480      r,
9481      o,
9482      u
9483    ), a.push(u), t = c[c.length - 1];
9484  }
9485  return o;
9486}
9487function Xi(e, t, i, n, s) {
9488  s = s !== void 0 ? s : [];
9489  let r = 0;
9490  for (let o = t; o < i; o += n)
9491    s[r++] = e.slice(o, o + n);
9492  return s.length = r, s;
9493}
9494function vr(e, t, i, n, s) {
9495  s = s !== void 0 ? s : [];
9496  let r = 0;
9497  for (let o = 0, a = i.length; o < a; ++o) {
9498    const l = i[o];
9499    s[r++] = Xi(
9500      e,
9501      t,
9502      l,
9503      n,
9504      s[r]
9505    ), t = l;
9506  }
9507  return s.length = r, s;
9508}
9509function kl(e, t, i, n, s) {
9510  s = s !== void 0 ? s : [];
9511  let r = 0;
9512  for (let o = 0, a = i.length; o < a; ++o) {
9513    const l = i[o];
9514    s[r++] = l.length === 1 && l[0] === t ? [] : vr(
9515      e,
9516      t,
9517      l,
9518      n,
9519      s[r]
9520    ), t = l[l.length - 1];
9521  }
9522  return s.length = r, s;
9523}
9524function yg(e, t, i, n) {
9525  let s = 0, r = e[i - n], o = e[i - n + 1];
9526  for (; t < i; t += n) {
9527    const a = e[t], l = e[t + 1];
9528    s += o * a - r * l, r = a, o = l;
9529  }
9530  return s / 2;
9531}
9532function xg(e, t, i, n) {
9533  let s = 0;
9534  for (let r = 0, o = i.length; r < o; ++r) {
9535    const a = i[r];
9536    s += yg(e, t, a, n), t = a;
9537  }
9538  return s;
9539}
9540function xC(e, t, i, n) {
9541  let s = 0;
9542  for (let r = 0, o = i.length; r < o; ++r) {
9543    const a = i[r];
9544    s += xg(e, t, a, n), t = a[a.length - 1];
9545  }
9546  return s;
9547}
9548class Xo extends an {
9549  /**
9550   * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
9551   *     For internal use, flat coordinates in combination with `layout` are also accepted.
9552   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
9553   */
9554  constructor(t, i) {
9555    super(), this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, i !== void 0 && !Array.isArray(t[0]) ? this.setFlatCoordinates(
9556      i,
9557      /** @type {Array<number>} */
9558      t
9559    ) : this.setCoordinates(
9560      /** @type {Array<import("../coordinate.js").Coordinate>} */
9561      t,
9562      i
9563    );
9564  }
9565  /**
9566   * Make a complete copy of the geometry.
9567   * @return {!LinearRing} Clone.
9568   * @api
9569   */
9570  clone() {
9571    return new Xo(this.flatCoordinates.slice(), this.layout);
9572  }
9573  /**
9574   * @param {number} x X.
9575   * @param {number} y Y.
9576   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
9577   * @param {number} minSquaredDistance Minimum squared distance.
9578   * @return {number} Minimum squared distance.
9579   */
9580  closestPointXY(t, i, n, s) {
9581    return s < kn(this.getExtent(), t, i) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
9582      jh(
9583        this.flatCoordinates,
9584        0,
9585        this.flatCoordinates.length,
9586        this.stride,
9587        0
9588      )
9589    ), this.maxDeltaRevision_ = this.getRevision()), Bh(
9590      this.flatCoordinates,
9591      0,
9592      this.flatCoordinates.length,
9593      this.stride,
9594      this.maxDelta_,
9595      !0,
9596      t,
9597      i,
9598      n,
9599      s
9600    ));
9601  }
9602  /**
9603   * Return the area of the linear ring on projected plane.
9604   * @return {number} Area (on projected plane).
9605   * @api
9606   */
9607  getArea() {
9608    return yg(
9609      this.flatCoordinates,
9610      0,
9611      this.flatCoordinates.length,
9612      this.stride
9613    );
9614  }
9615  /**
9616   * Return the coordinates of the linear ring.
9617   * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
9618   * @api
9619   */
9620  getCoordinates() {
9621    return Xi(
9622      this.flatCoordinates,
9623      0,
9624      this.flatCoordinates.length,
9625      this.stride
9626    );
9627  }
9628  /**
9629   * @param {number} squaredTolerance Squared tolerance.
9630   * @return {LinearRing} Simplified LinearRing.
9631   * @protected
9632   */
9633  getSimplifiedGeometryInternal(t) {
9634    const i = [];
9635    return i.length = $h(
9636      this.flatCoordinates,
9637      0,
9638      this.flatCoordinates.length,
9639      this.stride,
9640      t,
9641      i,
9642      0
9643    ), new Xo(i, "XY");
9644  }
9645  /**
9646   * Get the type of this geometry.
9647   * @return {import("./Geometry.js").Type} Geometry type.
9648   * @api
9649   */
9650  getType() {
9651    return "LinearRing";
9652  }
9653  /**
9654   * Test if the geometry and the passed extent intersect.
9655   * @param {import("../extent.js").Extent} extent Extent.
9656   * @return {boolean} `true` if the geometry and the extent intersect.
9657   * @api
9658   */
9659  intersectsExtent(t) {
9660    return !1;
9661  }
9662  /**
9663   * Set the coordinates of the linear ring.
9664   * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
9665   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
9666   * @api
9667   */
9668  setCoordinates(t, i) {
9669    this.setLayout(i, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = Ma(
9670      this.flatCoordinates,
9671      0,
9672      t,
9673      this.stride
9674    ), this.changed();
9675  }
9676}
9677const Wu = Xo;
9678class Yh extends an {
9679  /**
9680   * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
9681   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
9682   */
9683  constructor(t, i) {
9684    super(), this.setCoordinates(t, i);
9685  }
9686  /**
9687   * Make a complete copy of the geometry.
9688   * @return {!Point} Clone.
9689   * @api
9690   */
9691  clone() {
9692    const t = new Yh(this.flatCoordinates.slice(), this.layout);
9693    return t.applyProperties(this), t;
9694  }
9695  /**
9696   * @param {number} x X.
9697   * @param {number} y Y.
9698   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
9699   * @param {number} minSquaredDistance Minimum squared distance.
9700   * @return {number} Minimum squared distance.
9701   */
9702  closestPointXY(t, i, n, s) {
9703    const r = this.flatCoordinates, o = Mi(
9704      t,
9705      i,
9706      r[0],
9707      r[1]
9708    );
9709    if (o < s) {
9710      const a = this.stride;
9711      for (let l = 0; l < a; ++l)
9712        n[l] = r[l];
9713      return n.length = a, o;
9714    }
9715    return s;
9716  }
9717  /**
9718   * Return the coordinate of the point.
9719   * @return {import("../coordinate.js").Coordinate} Coordinates.
9720   * @api
9721   */
9722  getCoordinates() {
9723    return this.flatCoordinates ? this.flatCoordinates.slice() : [];
9724  }
9725  /**
9726   * @param {import("../extent.js").Extent} extent Extent.
9727   * @protected
9728   * @return {import("../extent.js").Extent} extent Extent.
9729   */
9730  computeExtent(t) {
9731    return Mo(this.flatCoordinates, t);
9732  }
9733  /**
9734   * Get the type of this geometry.
9735   * @return {import("./Geometry.js").Type} Geometry type.
9736   * @api
9737   */
9738  getType() {
9739    return "Point";
9740  }
9741  /**
9742   * Test if the geometry and the passed extent intersect.
9743   * @param {import("../extent.js").Extent} extent Extent.
9744   * @return {boolean} `true` if the geometry and the extent intersect.
9745   * @api
9746   */
9747  intersectsExtent(t) {
9748    return sh(t, this.flatCoordinates[0], this.flatCoordinates[1]);
9749  }
9750  /**
9751   * @param {!Array<*>} coordinates Coordinates.
9752   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
9753   * @api
9754   */
9755  setCoordinates(t, i) {
9756    this.setLayout(i, t, 0), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = _g(
9757      this.flatCoordinates,
9758      0,
9759      t,
9760      this.stride
9761    ), this.changed();
9762  }
9763}
9764const Ne = Yh;
9765function vC(e, t, i, n, s) {
9766  return !rh(
9767    s,
9768    /**
9769     * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
9770     * @return {boolean} Contains (x, y).
9771     */
9772    function(o) {
9773      return !yn(
9774        e,
9775        t,
9776        i,
9777        n,
9778        o[0],
9779        o[1]
9780      );
9781    }
9782  );
9783}
9784function yn(e, t, i, n, s, r) {
9785  let o = 0, a = e[i - n], l = e[i - n + 1];
9786  for (; t < i; t += n) {
9787    const h = e[t], c = e[t + 1];
9788    l <= r ? c > r && (h - a) * (r - l) - (s - a) * (c - l) > 0 && o++ : c <= r && (h - a) * (r - l) - (s - a) * (c - l) < 0 && o--, a = h, l = c;
9789  }
9790  return o !== 0;
9791}
9792function Kh(e, t, i, n, s, r) {
9793  if (i.length === 0 || !yn(e, t, i[0], n, s, r))
9794    return !1;
9795  for (let o = 1, a = i.length; o < a; ++o)
9796    if (yn(e, i[o - 1], i[o], n, s, r))
9797      return !1;
9798  return !0;
9799}
9800function EC(e, t, i, n, s, r) {
9801  if (i.length === 0)
9802    return !1;
9803  for (let o = 0, a = i.length; o < a; ++o) {
9804    const l = i[o];
9805    if (Kh(e, t, l, n, s, r))
9806      return !0;
9807    t = l[l.length - 1];
9808  }
9809  return !1;
9810}
9811function vg(e, t, i, n, s, r, o) {
9812  let a, l, h, c, u, d, f;
9813  const g = s[r + 1], m = [];
9814  for (let y = 0, x = i.length; y < x; ++y) {
9815    const E = i[y];
9816    for (c = e[E - n], d = e[E - n + 1], a = t; a < E; a += n)
9817      u = e[a], f = e[a + 1], (g <= d && f <= g || d <= g && g <= f) && (h = (g - d) / (f - d) * (u - c) + c, m.push(h)), c = u, d = f;
9818  }
9819  let _ = NaN, p = -1 / 0;
9820  for (m.sort(Ln), c = m[0], a = 1, l = m.length; a < l; ++a) {
9821    u = m[a];
9822    const y = Math.abs(u - c);
9823    y > p && (h = (c + u) / 2, Kh(e, t, i, n, h, g) && (_ = h, p = y)), c = u;
9824  }
9825  return isNaN(_) && (_ = s[r]), o ? (o.push(_, g, p), o) : [_, g, p];
9826}
9827function CC(e, t, i, n, s) {
9828  let r = [];
9829  for (let o = 0, a = i.length; o < a; ++o) {
9830    const l = i[o];
9831    r = vg(
9832      e,
9833      t,
9834      l,
9835      n,
9836      s,
9837      2 * o,
9838      r
9839    ), t = l[l.length - 1];
9840  }
9841  return r;
9842}
9843function Eg(e, t, i, n, s) {
9844  let r;
9845  for (t += n; t < i; t += n)
9846    if (r = s(
9847      e.slice(t - n, t),
9848      e.slice(t, t + n)
9849    ), r)
9850      return r;
9851  return !1;
9852}
9853function ba(e, t, i, n, s) {
9854  const r = nf(
9855    be(),
9856    e,
9857    t,
9858    i,
9859    n
9860  );
9861  return re(s, r) ? Bi(s, r) || r[0] >= s[0] && r[2] <= s[2] || r[1] >= s[1] && r[3] <= s[3] ? !0 : Eg(
9862    e,
9863    t,
9864    i,
9865    n,
9866    /**
9867     * @param {import("../../coordinate.js").Coordinate} point1 Start point.
9868     * @param {import("../../coordinate.js").Coordinate} point2 End point.
9869     * @return {boolean} `true` if the segment and the extent intersect,
9870     *     `false` otherwise.
9871     */
9872    function(o, a) {
9873      return Sx(s, o, a);
9874    }
9875  ) : !1;
9876}
9877function MC(e, t, i, n, s) {
9878  for (let r = 0, o = i.length; r < o; ++r) {
9879    if (ba(e, t, i[r], n, s))
9880      return !0;
9881    t = i[r];
9882  }
9883  return !1;
9884}
9885function Cg(e, t, i, n, s) {
9886  return !!(ba(e, t, i, n, s) || yn(
9887    e,
9888    t,
9889    i,
9890    n,
9891    s[0],
9892    s[1]
9893  ) || yn(
9894    e,
9895    t,
9896    i,
9897    n,
9898    s[0],
9899    s[3]
9900  ) || yn(
9901    e,
9902    t,
9903    i,
9904    n,
9905    s[2],
9906    s[1]
9907  ) || yn(
9908    e,
9909    t,
9910    i,
9911    n,
9912    s[2],
9913    s[3]
9914  ));
9915}
9916function Mg(e, t, i, n, s) {
9917  if (!Cg(e, t, i[0], n, s))
9918    return !1;
9919  if (i.length === 1)
9920    return !0;
9921  for (let r = 1, o = i.length; r < o; ++r)
9922    if (vC(
9923      e,
9924      i[r - 1],
9925      i[r],
9926      n,
9927      s
9928    ) && !ba(
9929      e,
9930      i[r - 1],
9931      i[r],
9932      n,
9933      s
9934    ))
9935      return !1;
9936  return !0;
9937}
9938function bC(e, t, i, n, s) {
9939  for (let r = 0, o = i.length; r < o; ++r) {
9940    const a = i[r];
9941    if (Mg(e, t, a, n, s))
9942      return !0;
9943    t = a[a.length - 1];
9944  }
9945  return !1;
9946}
9947function wC(e, t, i, n) {
9948  for (; t < i - n; ) {
9949    for (let s = 0; s < n; ++s) {
9950      const r = e[t + s];
9951      e[t + s] = e[i - n + s], e[i - n + s] = r;
9952    }
9953    t += n, i -= n;
9954  }
9955}
9956function bg(e, t, i, n) {
9957  let s = 0, r = e[i - n], o = e[i - n + 1];
9958  for (; t < i; t += n) {
9959    const a = e[t], l = e[t + 1];
9960    s += (a - r) * (l + o), r = a, o = l;
9961  }
9962  return s === 0 ? void 0 : s > 0;
9963}
9964function wg(e, t, i, n, s) {
9965  s = s !== void 0 ? s : !1;
9966  for (let r = 0, o = i.length; r < o; ++r) {
9967    const a = i[r], l = bg(
9968      e,
9969      t,
9970      a,
9971      n
9972    );
9973    if (r === 0) {
9974      if (s && l || !s && !l)
9975        return !1;
9976    } else if (s && !l || !s && l)
9977      return !1;
9978    t = a;
9979  }
9980  return !0;
9981}
9982function SC(e, t, i, n, s) {
9983  for (let r = 0, o = i.length; r < o; ++r) {
9984    const a = i[r];
9985    if (!wg(e, t, a, n, s))
9986      return !1;
9987    a.length && (t = a[a.length - 1]);
9988  }
9989  return !0;
9990}
9991function Dl(e, t, i, n, s) {
9992  s = s !== void 0 ? s : !1;
9993  for (let r = 0, o = i.length; r < o; ++r) {
9994    const a = i[r], l = bg(
9995      e,
9996      t,
9997      a,
9998      n
9999    );
10000    (r === 0 ? s && l || !s && !l : s && !l || !s && l) && wC(e, t, a, n), t = a;
10001  }
10002  return t;
10003}
10004function Bu(e, t, i, n, s) {
10005  for (let r = 0, o = i.length; r < o; ++r)
10006    t = Dl(
10007      e,
10008      t,
10009      i[r],
10010      n,
10011      s
10012    );
10013  return t;
10014}
10015class On extends an {
10016  /**
10017   * @param {!Array<Array<import("../coordinate.js").Coordinate>>|!Array<number>} coordinates
10018   *     Array of linear rings that define the polygon. The first linear ring of the
10019   *     array defines the outer-boundary or surface of the polygon. Each subsequent
10020   *     linear ring defines a hole in the surface of the polygon. A linear ring is
10021   *     an array of vertices' coordinates where the first coordinate and the last are
10022   *     equivalent. (For internal use, flat coordinates in combination with
10023   *     `layout` and `ends` are also accepted.)
10024   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
10025   * @param {Array<number>} [ends] Ends (for internal use with flat coordinates).
10026   */
10027  constructor(t, i, n) {
10028    super(), this.ends_ = [], this.flatInteriorPointRevision_ = -1, this.flatInteriorPoint_ = null, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, this.orientedRevision_ = -1, this.orientedFlatCoordinates_ = null, i !== void 0 && n ? (this.setFlatCoordinates(
10029      i,
10030      /** @type {Array<number>} */
10031      t
10032    ), this.ends_ = n) : this.setCoordinates(
10033      /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */
10034      t,
10035      i
10036    );
10037  }
10038  /**
10039   * Append the passed linear ring to this polygon.
10040   * @param {LinearRing} linearRing Linear ring.
10041   * @api
10042   */
10043  appendLinearRing(t) {
10044    this.flatCoordinates ? ci(this.flatCoordinates, t.getFlatCoordinates()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.ends_.push(this.flatCoordinates.length), this.changed();
10045  }
10046  /**
10047   * Make a complete copy of the geometry.
10048   * @return {!Polygon} Clone.
10049   * @api
10050   */
10051  clone() {
10052    const t = new On(
10053      this.flatCoordinates.slice(),
10054      this.layout,
10055      this.ends_.slice()
10056    );
10057    return t.applyProperties(this), t;
10058  }
10059  /**
10060   * @param {number} x X.
10061   * @param {number} y Y.
10062   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
10063   * @param {number} minSquaredDistance Minimum squared distance.
10064   * @return {number} Minimum squared distance.
10065   */
10066  closestPointXY(t, i, n, s) {
10067    return s < kn(this.getExtent(), t, i) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
10068      Wh(
10069        this.flatCoordinates,
10070        0,
10071        this.ends_,
10072        this.stride,
10073        0
10074      )
10075    ), this.maxDeltaRevision_ = this.getRevision()), Uh(
10076      this.flatCoordinates,
10077      0,
10078      this.ends_,
10079      this.stride,
10080      this.maxDelta_,
10081      !0,
10082      t,
10083      i,
10084      n,
10085      s
10086    ));
10087  }
10088  /**
10089   * @param {number} x X.
10090   * @param {number} y Y.
10091   * @return {boolean} Contains (x, y).
10092   */
10093  containsXY(t, i) {
10094    return Kh(
10095      this.getOrientedFlatCoordinates(),
10096      0,
10097      this.ends_,
10098      this.stride,
10099      t,
10100      i
10101    );
10102  }
10103  /**
10104   * Return the area of the polygon on projected plane.
10105   * @return {number} Area (on projected plane).
10106   * @api
10107   */
10108  getArea() {
10109    return xg(
10110      this.getOrientedFlatCoordinates(),
10111      0,
10112      this.ends_,
10113      this.stride
10114    );
10115  }
10116  /**
10117   * Get the coordinate array for this geometry.  This array has the structure
10118   * of a GeoJSON coordinate array for polygons.
10119   *
10120   * @param {boolean} [right] Orient coordinates according to the right-hand
10121   *     rule (counter-clockwise for exterior and clockwise for interior rings).
10122   *     If `false`, coordinates will be oriented according to the left-hand rule
10123   *     (clockwise for exterior and counter-clockwise for interior rings).
10124   *     By default, coordinate orientation will depend on how the geometry was
10125   *     constructed.
10126   * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
10127   * @api
10128   */
10129  getCoordinates(t) {
10130    let i;
10131    return t !== void 0 ? (i = this.getOrientedFlatCoordinates().slice(), Dl(i, 0, this.ends_, this.stride, t)) : i = this.flatCoordinates, vr(i, 0, this.ends_, this.stride);
10132  }
10133  /**
10134   * @return {Array<number>} Ends.
10135   */
10136  getEnds() {
10137    return this.ends_;
10138  }
10139  /**
10140   * @return {Array<number>} Interior point.
10141   */
10142  getFlatInteriorPoint() {
10143    if (this.flatInteriorPointRevision_ != this.getRevision()) {
10144      const t = Je(this.getExtent());
10145      this.flatInteriorPoint_ = vg(
10146        this.getOrientedFlatCoordinates(),
10147        0,
10148        this.ends_,
10149        this.stride,
10150        t,
10151        0
10152      ), this.flatInteriorPointRevision_ = this.getRevision();
10153    }
10154    return this.flatInteriorPoint_;
10155  }
10156  /**
10157   * Return an interior point of the polygon.
10158   * @return {Point} Interior point as XYM coordinate, where M is the
10159   * length of the horizontal intersection that the point belongs to.
10160   * @api
10161   */
10162  getInteriorPoint() {
10163    return new Ne(this.getFlatInteriorPoint(), "XYM");
10164  }
10165  /**
10166   * Return the number of rings of the polygon,  this includes the exterior
10167   * ring and any interior rings.
10168   *
10169   * @return {number} Number of rings.
10170   * @api
10171   */
10172  getLinearRingCount() {
10173    return this.ends_.length;
10174  }
10175  /**
10176   * Return the Nth linear ring of the polygon geometry. Return `null` if the
10177   * given index is out of range.
10178   * The exterior linear ring is available at index `0` and the interior rings
10179   * at index `1` and beyond.
10180   *
10181   * @param {number} index Index.
10182   * @return {LinearRing|null} Linear ring.
10183   * @api
10184   */
10185  getLinearRing(t) {
10186    return t < 0 || this.ends_.length <= t ? null : new Wu(
10187      this.flatCoordinates.slice(
10188        t === 0 ? 0 : this.ends_[t - 1],
10189        this.ends_[t]
10190      ),
10191      this.layout
10192    );
10193  }
10194  /**
10195   * Return the linear rings of the polygon.
10196   * @return {Array<LinearRing>} Linear rings.
10197   * @api
10198   */
10199  getLinearRings() {
10200    const t = this.layout, i = this.flatCoordinates, n = this.ends_, s = [];
10201    let r = 0;
10202    for (let o = 0, a = n.length; o < a; ++o) {
10203      const l = n[o], h = new Wu(
10204        i.slice(r, l),
10205        t
10206      );
10207      s.push(h), r = l;
10208    }
10209    return s;
10210  }
10211  /**
10212   * @return {Array<number>} Oriented flat coordinates.
10213   */
10214  getOrientedFlatCoordinates() {
10215    if (this.orientedRevision_ != this.getRevision()) {
10216      const t = this.flatCoordinates;
10217      wg(t, 0, this.ends_, this.stride) ? this.orientedFlatCoordinates_ = t : (this.orientedFlatCoordinates_ = t.slice(), this.orientedFlatCoordinates_.length = Dl(
10218        this.orientedFlatCoordinates_,
10219        0,
10220        this.ends_,
10221        this.stride
10222      )), this.orientedRevision_ = this.getRevision();
10223    }
10224    return this.orientedFlatCoordinates_;
10225  }
10226  /**
10227   * @param {number} squaredTolerance Squared tolerance.
10228   * @return {Polygon} Simplified Polygon.
10229   * @protected
10230   */
10231  getSimplifiedGeometryInternal(t) {
10232    const i = [], n = [];
10233    return i.length = pg(
10234      this.flatCoordinates,
10235      0,
10236      this.ends_,
10237      this.stride,
10238      Math.sqrt(t),
10239      i,
10240      0,
10241      n
10242    ), new On(i, "XY", n);
10243  }
10244  /**
10245   * Get the type of this geometry.
10246   * @return {import("./Geometry.js").Type} Geometry type.
10247   * @api
10248   */
10249  getType() {
10250    return "Polygon";
10251  }
10252  /**
10253   * Test if the geometry and the passed extent intersect.
10254   * @param {import("../extent.js").Extent} extent Extent.
10255   * @return {boolean} `true` if the geometry and the extent intersect.
10256   * @api
10257   */
10258  intersectsExtent(t) {
10259    return Mg(
10260      this.getOrientedFlatCoordinates(),
10261      0,
10262      this.ends_,
10263      this.stride,
10264      t
10265    );
10266  }
10267  /**
10268   * Set the coordinates of the polygon.
10269   * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
10270   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
10271   * @api
10272   */
10273  setCoordinates(t, i) {
10274    this.setLayout(i, t, 2), this.flatCoordinates || (this.flatCoordinates = []);
10275    const n = Xh(
10276      this.flatCoordinates,
10277      0,
10278      t,
10279      this.stride,
10280      this.ends_
10281    );
10282    this.flatCoordinates.length = n.length === 0 ? 0 : n[n.length - 1], this.changed();
10283  }
10284}
10285const Fn = On;
10286function TC(e, t, i, n) {
10287  i = i || 32;
10288  const s = [];
10289  for (let r = 0; r < i; ++r)
10290    ci(
10291      s,
10292      kx(e, t, 2 * Math.PI * r / i, n)
10293    );
10294  return s.push(s[0], s[1]), new On(s, "XY", [s.length]);
10295}
10296function Uu(e) {
10297  const t = e[0], i = e[1], n = e[2], s = e[3], r = [
10298    t,
10299    i,
10300    t,
10301    s,
10302    n,
10303    s,
10304    n,
10305    i,
10306    t,
10307    i
10308  ];
10309  return new On(r, "XY", [r.length]);
10310}
10311function IC(e, t, i) {
10312  t = t || 32;
10313  const n = e.getStride(), s = e.getLayout(), r = e.getCenter(), o = n * (t + 1), a = new Array(o);
10314  for (let c = 0; c < o; c += n) {
10315    a[c] = 0, a[c + 1] = 0;
10316    for (let u = 2; u < n; u++)
10317      a[c + u] = r[u];
10318  }
10319  const l = [a.length], h = new On(a, s, l);
10320  return RC(h, r, e.getRadius(), i), h;
10321}
10322function RC(e, t, i, n) {
10323  const s = e.getFlatCoordinates(), r = e.getStride(), o = s.length / r - 1, a = n || 0;
10324  for (let l = 0; l <= o; ++l) {
10325    const h = l * r, c = a + qi(l, o) * 2 * Math.PI / o;
10326    s[h] = t[0] + i * Math.cos(c), s[h + 1] = t[1] + i * Math.sin(c);
10327  }
10328  e.changed();
10329}
10330const Xa = 0;
10331class PC extends Qe {
10332  /**
10333   * @param {ViewOptions} [options] View options.
10334   */
10335  constructor(t) {
10336    super(), this.on, this.once, this.un, t = Object.assign({}, t), this.hints_ = [0, 0], this.animations_ = [], this.updateAnimationKey_, this.projection_ = ch(t.projection, "EPSG:3857"), this.viewportSize_ = [100, 100], this.targetCenter_ = null, this.targetResolution_, this.targetRotation_, this.nextCenter_ = null, this.nextResolution_, this.nextRotation_, this.cancelAnchor_ = void 0, t.projection && Nx(), t.center && (t.center = Lt(t.center, this.projection_)), t.extent && (t.extent = ai(t.extent, this.projection_)), this.applyOptions_(t);
10337  }
10338  /**
10339   * Set up the view with the given options.
10340   * @param {ViewOptions} options View options.
10341   */
10342  applyOptions_(t) {
10343    const i = Object.assign({}, t);
10344    for (const a in Ge)
10345      delete i[a];
10346    this.setProperties(i, !0);
10347    const n = AC(t);
10348    this.maxResolution_ = n.maxResolution, this.minResolution_ = n.minResolution, this.zoomFactor_ = n.zoomFactor, this.resolutions_ = t.resolutions, this.padding_ = t.padding, this.minZoom_ = n.minZoom;
10349    const s = LC(t), r = n.constraint, o = OC(t);
10350    this.constraints_ = {
10351      center: s,
10352      resolution: r,
10353      rotation: o
10354    }, this.setRotation(t.rotation !== void 0 ? t.rotation : 0), this.setCenterInternal(
10355      t.center !== void 0 ? t.center : null
10356    ), t.resolution !== void 0 ? this.setResolution(t.resolution) : t.zoom !== void 0 && this.setZoom(t.zoom);
10357  }
10358  /**
10359   * Padding (in css pixels).
10360   * If the map viewport is partially covered with other content (overlays) along
10361   * its edges, this setting allows to shift the center of the viewport away from that
10362   * content. The order of the values in the array is top, right, bottom, left.
10363   * The default is no padding, which is equivalent to `[0, 0, 0, 0]`.
10364   * @type {Array<number>|undefined}
10365   * @api
10366   */
10367  get padding() {
10368    return this.padding_;
10369  }
10370  set padding(t) {
10371    let i = this.padding_;
10372    this.padding_ = t;
10373    const n = this.getCenterInternal();
10374    if (n) {
10375      const s = t || [0, 0, 0, 0];
10376      i = i || [0, 0, 0, 0];
10377      const r = this.getResolution(), o = r / 2 * (s[3] - i[3] + i[
103771] - s[1]), a = r / 2 * (s[0] - i[0] + i[2] - s[2]);
10378      this.setCenterInternal([n[0] + o, n[1] - a]);
10379    }
10380  }
10381  /**
10382   * Get an updated version of the view options used to construct the view.  The
10383   * current resolution (or zoom), center, and rotation are applied to any stored
10384   * options.  The provided options can be used to apply new min/max zoom or
10385   * resolution limits.
10386   * @param {ViewOptions} newOptions New options to be applied.
10387   * @return {ViewOptions} New options updated with the current view state.
10388   */
10389  getUpdatedOptions_(t) {
10390    const i = this.getProperties();
10391    return i.resolution !== void 0 ? i.resolution = this.getResolution() : i.zoom = this.getZoom(), i.center = this.getCenterInternal(), i.rotation = this.getRotation(), Object.assign({}, i, t);
10392  }
10393  /**
10394   * Animate the view.  The view's center, zoom (or resolution), and rotation
10395   * can be animated for smooth transitions between view states.  For example,
10396   * to animate the view to a new zoom level:
10397   *
10398   *     view.animate({zoom: view.getZoom() + 1});
10399   *
10400   * By default, the animation lasts one second and uses in-and-out easing.  You
10401   * can customize this behavior by including `duration` (in milliseconds) and
10402   * `easing` options (see {@link module:ol/easing}).
10403   *
10404   * To chain together multiple animations, call the method with multiple
10405   * animation objects.  For example, to first zoom and then pan:
10406   *
10407   *     view.animate({zoom: 10}, {center: [0, 0]});
10408   *
10409   * If you provide a function as the last argument to the animate method, it
10410   * will get called at the end of an animation series.  The callback will be
10411   * called with `true` if the animation series completed on its own or `false`
10412   * if it was cancelled.
10413   *
10414   * Animations are cancelled by user interactions (e.g. dragging the map) or by
10415   * calling `view.setCenter()`, `view.setResolution()`, or `view.setRotation()`
10416   * (or another method that calls one of these).
10417   *
10418   * @param {...(AnimationOptions|function(boolean): void)} var_args Animation
10419   *     options.  Multiple animations can be run in series by passing multiple
10420   *     options objects.  To run multiple animations in parallel, call the method
10421   *     multiple times.  An optional callback can be provided as a final
10422   *     argument.  The callback will be called with a boolean indicating whether
10423   *     the animation completed without being cancelled.
10424   * @api
10425   */
10426  animate(t) {
10427    this.isDef() && !this.getAnimating() && this.resolveConstraints(0);
10428    const i = new Array(arguments.length);
10429    for (let n = 0; n < i.length; ++n) {
10430      let s = arguments[n];
10431      s.center && (s = Object.assign({}, s), s.center = Lt(
10432        s.center,
10433        this.getProjection()
10434      )), s.anchor && (s = Object.assign({}, s), s.anchor = Lt(
10435        s.anchor,
10436        this.getProjection()
10437      )), i[n] = s;
10438    }
10439    this.animateInternal.apply(this, i);
10440  }
10441  /**
10442   * @param {...(AnimationOptions|function(boolean): void)} var_args Animation options.
10443   */
10444  animateInternal(t) {
10445    let i = arguments.length, n;
10446    i > 1 && typeof arguments[i - 1] == "function" && (n = arguments[i - 1], --i);
10447    let s = 0;
10448    for (; s < i && !this.isDef(); ++s) {
10449      const c = arguments[s];
10450      c.center && this.setCenterInternal(c.center), c.zoom !== void 0 ? this.setZoom(c.zoom) : c.resolution && this.setResolution(c.resolution), c.rotation !== void 0 && this.setRotation(c.rotation);
10451    }
10452    if (s === i) {
10453      n && so(n, !0);
10454      return;
10455    }
10456    let r = Date.now(), o = this.targetCenter_.slice(), a = this.targetResolution_, l = this.targetRotation_;
10457    const h = [];
10458    for (; s < i; ++s) {
10459      const c = (
10460        /** @type {AnimationOptions} */
10461        arguments[s]
10462      ), u = {
10463        start: r,
10464        complete: !1,
10465        anchor: c.anchor,
10466        duration: c.duration !== void 0 ? c.duration : 1e3,
10467        easing: c.easing || rC,
10468        callback: n
10469      };
10470      if (c.center && (u.sourceCenter = o, u.targetCenter = c.center.slice(), o = u.targetCenter), c.zoom !== void 0 ? (u.sourceResolution = a, u.targetResolution = this.getResolutionForZoom(c.zoom), a = u.targetResolution) : c.resolution && (u.sourceResolution = a, u.targetResolution = c.resolution, a = u.targetResolution), c.rotation !== void 0) {
10471        u.sourceRotation = l;
10472        const d = qi(c.rotation - l + Math.PI, 2 * Math.PI) - Math.PI;
10473        u.targetRotation = l + d, l = u.targetRotation;
10474      }
10475      FC(u) ? u.complete = !0 : r += u.duration, h.push(u);
10476    }
10477    this.animations_.push(h), this.setHint(Kt.ANIMATING, 1), this.updateAnimations_();
10478  }
10479  /**
10480   * Determine if the view is being animated.
10481   * @return {boolean} The view is being animated.
10482   * @api
10483   */
10484  getAnimating() {
10485    return this.hints_[Kt.ANIMATING] > 0;
10486  }
10487  /**
10488   * Determine if the user is interacting with the view, such as panning or zooming.
10489   * @return {boolean} The view is being interacted with.
10490   * @api
10491   */
10492  getInteracting() {
10493    return this.hints_[Kt.INTERACTING] > 0;
10494  }
10495  /**
10496   * Cancel any ongoing animations.
10497   * @api
10498   */
10499  cancelAnimations() {
10500    this.setHint(Kt.ANIMATING, -this.hints_[Kt.ANIMATING]);
10501    let t;
10502    for (let i = 0, n = this.animations_.length; i < n; ++i) {
10503      const s = this.animations_[i];
10504      if (s[0].callback && so(s[0].callback, !1), !t)
10505        for (let r = 0, o = s.length; r < o; ++r) {
10506          const a = s[r];
10507          if (!a.complete) {
10508            t = a.anchor;
10509            break;
10510          }
10511        }
10512    }
10513    this.animations_.length = 0, this.cancelAnchor_ = t, this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN;
10514  }
10515  /**
10516   * Update all animations.
10517   */
10518  updateAnimations_() {
10519    if (this.updateAnimationKey_ !== void 0 && (cancelAnimationFrame(this.updateAnimationKey_), this.updateAnimationKey_ = void 0), !this.getAnimating())
10520      return;
10521    const t = Date.now();
10522    let i = !1;
10523    for (let n = this.animations_.length - 1; n >= 0; --n) {
10524      const s = this.animations_[n];
10525      let r = !0;
10526      for (let o = 0, a = s.length; o < a; ++o) {
10527        const l = s[o];
10528        if (l.complete)
10529          continue;
10530        const h = t - l.start;
10531        let c = l.duration > 0 ? h / l.duration : 1;
10532        c >= 1 ? (l.complete = !0, c = 1) : r = !1;
10533        const u = l.easing(c);
10534        if (l.sourceCenter) {
10535          const d = l.sourceCenter[0], f = l.sourceCenter[1], g = l.targetCenter[0], m = l.targetCenter[1];
10536          this.nextCenter_ = l.targetCenter;
10537          const _ = d + u * (g - d), p = f + u * (m - f);
10538          this.targetCenter_ = [_, p];
10539        }
10540        if (l.sourceResolution && l.targetResolution) {
10541          const d = u === 1 ? l.targetResolution : l.sourceResolution + u * (l.targetResolution - l.sourceResolution);
10542          if (l.anchor) {
10543            const f = this.getViewportSize_(this.getRotation()), g = this.constraints_.resolution(
10544              d,
10545              0,
10546              f,
10547              !0
10548            );
10549            this.targetCenter_ = this.calculateCenterZoom(
10550              g,
10551              l.anchor
10552            );
10553          }
10554          this.nextResolution_ = l.targetResolution, this.targetResolution_ = d, this.applyTargetState_(!0);
10555        }
10556        if (l.sourceRotation !== void 0 && l.targetRotation !== void 0) {
10557          const d = u === 1 ? qi(l.targetRotation + Math.PI, 2 * Math.PI) - Math.PI : l.sourceRotation + u * (l.targetRotation - l.sourceRotation);
10558          if (l.anchor) {
10559            const f = this.constraints_.rotation(
10560              d,
10561              !0
10562            );
10563            this.targetCenter_ = this.calculateCenterRotate(
10564              f,
10565              l.anchor
10566            );
10567          }
10568          this.nextRotation_ = l.targetRotation, this.targetRotation_ = d;
10569        }
10570        if (this.applyTargetState_(!0), i = !0, !l.complete)
10571          break;
10572      }
10573      if (r) {
10574        this.animations_[n] = null, this.setHint(Kt.ANIMATING, -1), this.nextCenter_ = null, this.nextResolution_ = NaN, this.nextRotation_ = NaN;
10575        const o = s[0].callback;
10576        o && so(o, !0);
10577      }
10578    }
10579    this.animations_ = this.animations_.filter(Boolean), i && this.updateAnimationKey_ === void 0 && (this.updateAnimationKey_ = requestAnimationFrame(
10580      this.updateAnimations_.bind(this)
10581    ));
10582  }
10583  /**
10584   * @param {number} rotation Target rotation.
10585   * @param {import("./coordinate.js").Coordinate} anchor Rotation anchor.
10586   * @return {import("./coordinate.js").Coordinate|undefined} Center for rotation and anchor.
10587   */
10588  calculateCenterRotate(t, i) {
10589    let n;
10590    const s = this.getCenterInternal();
10591    return s !== void 0 && (n = [s[0] - i[0], s[1] - i[1]], ah(n, t - this.getRotation()), Lx(n, i)), n;
10592  }
10593  /**
10594   * @param {number} resolution Target resolution.
10595   * @param {import("./coordinate.js").Coordinate} anchor Zoom anchor.
10596   * @return {import("./coordinate.js").Coordinate|undefined} Center for resolution and anchor.
10597   */
10598  calculateCenterZoom(t, i) {
10599    let n;
10600    const s = this.getCenterInternal(), r = this.getResolution();
10601    if (s !== void 0 && r !== void 0) {
10602      const o = i[0] - t * (i[0] - s[0]) / r, a = i[1] - t * (i[1] - s[1]) / r;
10603      n = [o, a];
10604    }
10605    return n;
10606  }
10607  /**
10608   * Returns the current viewport size.
10609   * @private
10610   * @param {number} [rotation] Take into account the rotation of the viewport when giving the size
10611   * @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
10612   */
10613  getViewportSize_(t) {
10614    const i = this.viewportSize_;
10615    if (t) {
10616      const n = i[0], s = i[1];
10617      return [
10618        Math.abs(n * Math.cos(t)) + Math.abs(s * Math.sin(t)),
10619        Math.abs(n * Math.sin(t)) + Math.abs(s * Math.cos(t))
10620      ];
10621    }
10622    return i;
10623  }
10624  /**
10625   * Stores the viewport size on the view. The viewport size is not read every time from the DOM
10626   * to avoid performance hit and layout reflow.
10627   * This should be done on map size change.
10628   * Note: the constraints are not resolved during an animation to avoid stopping it
10629   * @param {import("./size.js").Size}
10629 [size] Viewport size; if undefined, [100, 100] is assumed
10630   */
10631  setViewportSize(t) {
10632    this.viewportSize_ = Array.isArray(t) ? t.slice() : [100, 100], this.getAnimating() || this.resolveConstraints(0);
10633  }
10634  /**
10635   * Get the view center.
10636   * @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
10637   * @observable
10638   * @api
10639   */
10640  getCenter() {
10641    const t = this.getCenterInternal();
10642    return t && Pn(t, this.getProjection());
10643  }
10644  /**
10645   * Get the view center without transforming to user projection.
10646   * @return {import("./coordinate.js").Coordinate|undefined} The center of the view.
10647   */
10648  getCenterInternal() {
10649    return (
10650      /** @type {import("./coordinate.js").Coordinate|undefined} */
10651      this.get(Ge.CENTER)
10652    );
10653  }
10654  /**
10655   * @return {Constraints} Constraints.
10656   */
10657  getConstraints() {
10658    return this.constraints_;
10659  }
10660  /**
10661   * @return {boolean} Resolution constraint is set
10662   */
10663  getConstrainResolution() {
10664    return this.get("constrainResolution");
10665  }
10666  /**
10667   * @param {Array<number>} [hints] Destination array.
10668   * @return {Array<number>} Hint.
10669   */
10670  getHints(t) {
10671    return t !== void 0 ? (t[0] = this.hints_[0], t[1] = this.hints_[1], t) : this.hints_.slice();
10672  }
10673  /**
10674   * Calculate the extent for the current view state and the passed size.
10675   * The size is the pixel dimensions of the box into which the calculated extent
10676   * should fit. In most cases you want to get the extent of the entire map,
10677   * that is `map.getSize()`.
10678   * @param {import("./size.js").Size} [size] Box pixel size. If not provided, the size
10679   * of the map that uses this view will be used.
10680   * @return {import("./extent.js").Extent} Extent.
10681   * @api
10682   */
10683  calculateExtent(t) {
10684    const i = this.calculateExtentInternal(t);
10685    return la(i, this.getProjection());
10686  }
10687  /**
10688   * @param {import("./size.js").Size} [size] Box pixel size. If not provided,
10689   * the map's last known viewport size will be used.
10690   * @return {import("./extent.js").Extent} Extent.
10691   */
10692  calculateExtentInternal(t) {
10693    t = t || this.getViewportSizeMinusPadding_();
10694    const i = (
10695      /** @type {!import("./coordinate.js").Coordinate} */
10696      this.getCenterInternal()
10697    );
10698    ht(i, 1);
10699    const n = (
10700      /** @type {!number} */
10701      this.getResolution()
10702    );
10703    ht(n !== void 0, 2);
10704    const s = (
10705      /** @type {!number} */
10706      this.getRotation()
10707    );
10708    return ht(s !== void 0, 3), us(i, n, s, t);
10709  }
10710  /**
10711   * Get the maximum resolution of the view.
10712   * @return {number} The maximum resolution of the view.
10713   * @api
10714   */
10715  getMaxResolution() {
10716    return this.maxResolution_;
10717  }
10718  /**
10719   * Get the minimum resolution of the view.
10720   * @return {number} The minimum resolution of the view.
10721   * @api
10722   */
10723  getMinResolution() {
10724    return this.minResolution_;
10725  }
10726  /**
10727   * Get the maximum zoom level for the view.
10728   * @return {number} The maximum zoom level.
10729   * @api
10730   */
10731  getMaxZoom() {
10732    return (
10733      /** @type {number} */
10734      this.getZoomForResolution(this.minResolution_)
10735    );
10736  }
10737  /**
10738   * Set a new maximum zoom level for the view.
10739   * @param {number} zoom The maximum zoom level.
10740   * @api
10741   */
10742  setMaxZoom(t) {
10743    this.applyOptions_(this.getUpdatedOptions_({ maxZoom: t }));
10744  }
10745  /**
10746   * Get the minimum zoom level for the view.
10747   * @return {number} The minimum zoom level.
10748   * @api
10749   */
10750  getMinZoom() {
10751    return (
10752      /** @type {number} */
10753      this.getZoomForResolution(this.maxResolution_)
10754    );
10755  }
10756  /**
10757   * Set a new minimum zoom level for the view.
10758   * @param {number} zoom The minimum zoom level.
10759   * @api
10760   */
10761  setMinZoom(t) {
10762    this.applyOptions_(this.getUpdatedOptions_({ minZoom: t }));
10763  }
10764  /**
10765   * Set whether the view should allow intermediary zoom levels.
10766   * @param {boolean} enabled Whether the resolution is constrained.
10767   * @api
10768   */
10769  setConstrainResolution(t) {
10770    this.applyOptions_(this.getUpdatedOptions_({ constrainResolution: t }));
10771  }
10772  /**
10773   * Get the view projection.
10774   * @return {import("./proj/Projection.js").default} The projection of the view.
10775   * @api
10776   */
10777  getProjection() {
10778    return this.projection_;
10779  }
10780  /**
10781   * Get the view resolution.
10782   * @return {number|undefined} The resolution of the view.
10783   * @observable
10784   * @api
10785   */
10786  getResolution() {
10787    return (
10788      /** @type {number|undefined} */
10789      this.get(Ge.RESOLUTION)
10790    );
10791  }
10792  /**
10793   * Get the resolutions for the view. This returns the array of resolutions
10794   * passed to the constructor of the View, or undefined if none were given.
10795   * @return {Array<number>|undefined} The resolutions of the view.
10796   * @api
10797   */
10798  getResolutions() {
10799    return this.resolutions_;
10800  }
10801  /**
10802   * Get the resolution for a provided extent (in map units) and size (in pixels).
10803   * @param {import("./extent.js").Extent} extent Extent.
10804   * @param {import("./size.js").Size} [size] Box pixel size.
10805   * @return {number} The resolution at which the provided extent will render at
10806   *     the given size.
10807   * @api
10808   */
10809  getResolutionForExtent(t, i) {
10810    return this.getResolutionForExtentInternal(
10811      ai(t, this.getProjection()),
10812      i
10813    );
10814  }
10815  /**
10816   * Get the resolution for a provided extent (in map units) and size (in pixels).
10817   * @param {import("./extent.js").Extent} extent Extent.
10818   * @param {import("./size.js").Size} [size] Box pixel size.
10819   * @return {number} The resolution at which the provided extent will render at
10820   *     the given size.
10821   */
10822  getResolutionForExtentInternal(t, i) {
10823    i = i || this.getViewportSizeMinusPadding_();
10824    const n = xt(t) / i[0], s = qt(t) / i[1];
10825    return Math.max(n, s);
10826  }
10827  /**
10828   * Return a function that returns a value between 0 and 1 for a
10829   * resolution. Exponential scaling is assumed.
10830   * @param {number} [power] Power.
10831   * @return {function(number): number} Resolution for value function.
10832   */
10833  getResolutionForValueFunction(t) {
10834    t = t || 2;
10835    const i = this.getConstrainedResolution(this.maxResolution_), n = this.minResolution_, s = Math.log(i / n) / Math.log(t);
10836    return (
10837      /**
10838       * @param {number} value Value.
10839       * @return {number} Resolution.
10840       */
10841      function(r) {
10842        return i / Math.pow(t, r * s);
10843      }
10844    );
10845  }
10846  /**
10847   * Get the view rotation.
10848   * @return {number} The rotation of the view in radians.
10849   * @observable
10850   * @api
10851   */
10852  getRotation() {
10853    return (
10854      /** @type {number} */
10855      this.get(Ge.ROTATION)
10856    );
10857  }
10858  /**
10859   * Return a function that returns a resolution for a value between
10860   * 0 and 1. Exponential scaling is assumed.
10861   * @param {number} [power] Power.
10862   * @return {function(number): number} Value for resolution function.
10863   */
10864  getValueForResolutionFunction(t) {
10865    const i = Math.log(t || 2), n = this.getConstrainedResolution(this.maxResolution_), s = this.minResolution_, r = Math.log(n / s) / i;
10866    return (
10867      /**
10868       * @param {number} resolution Resolution.
10869       * @return {number} Value.
10870       */
10871      function(o) {
10872        return Math.log(n / o) / i / r;
10873      }
10874    );
10875  }
10876  /**
10877   * Returns the size of the viewport minus padding.
10878   * @private
10879   * @param {number} [rotation] Take into account the rotation of the viewport when giving the size
10880   * @return {import("./size.js").Size} Viewport size reduced by the padding.
10881   */
10882  getViewportSizeMinusPadding_(t) {
10883    let i = this.getViewportSize_(t);
10884    const n = this.padding_;
10885    return n && (i = [
10886      i[0] - n[1] - n[3],
10887      i[1] - n[0] - n[2]
10888    ]), i;
10889  }
10890  /**
10891   * @return {State} View state.
10892   */
10893  getState() {
10894    const t = this.getProjection(), i = this.getResolution(), n = this.getRotation();
10895    let s = (
10896      /** @type {import("./coordinate.js").Coordinate} */
10897      this.getCenterInternal()
10898    );
10899    const r = this.padding_;
10900    if (r) {
10901      const o = this.getViewportSizeMinusPadding_();
10902      s = $a(
10903        s,
10904        this.getViewportSize_(),
10905        [o[0] / 2 + r[3], o[1] / 2 + r[0]],
10906        i,
10907        n
10908      );
10909    }
10910    return {
10911      center: s.slice(0),
10912      projection: t !== void 0 ? t : null,
10913      resolution: i,
10914      nextCenter: this.nextCenter_,
10915      nextResolution: this.nextResolution_,
10916      nextRotation: this.nextRotation_,
10917      rotation: n,
10918      zoom: this.getZoom()
10919    };
10920  }
10921  /**
10922   * @return {ViewStateLayerStateExtent} Like `FrameState`, but just `viewState` and `extent`.
10923   */
10924  getViewStateAndExtent() {
10925    return {
10926      viewState: this.getState(),
10927      extent: this.calculateExtent()
10928    };
10929  }
10930  /**
10931   * Get the current zoom level. This method may return non-integer zoom levels
10932   * if the view does not constrain the resolution, or if an interaction or
10933   * animation is underway.
10934   * @return {number|undefined} Zoom.
10935   * @api
10936   */
10937  getZoom() {
10938    let t;
10939    const i = this.getResolution();
10940    return i !== void 0 && (t = this.getZoomForResolution(i)), t;
10941  }
10942  /**
10943   * Get the zoom level for a resolution.
10944   * @param {number} resolution The resolution.
10945   * @return {number|undefined} The zoom level for the provided resolution.
10946   * @api
10947   */
10948  getZoomForResolution(t) {
10949    let i = this.minZoom_ || 0, n, s;
10950    if (this.resolutions_) {
10951      const r = va(this.resolutions_, t, 1);
10952      i = r, n = this.resolutions_[r], r == this.resolutions_.length - 1 ? s = 2 : s = n / this.resolutions_[r + 1];
10953    } else
10954      n = this.maxResolution_, s = this.zoomFactor_;
10955    return i + Math.log(n / t) / Math.log(s);
10956  }
10957  /**
10958   * Get the resolution for a zoom level.
10959   * @param {number} zoom Zoom level.
10960   * @return {number} The view resolution for the provided zoom level.
10961   * @api
10962   */
10963  getResolutionForZoom(t) {
10964    if (this.resolutions_) {
10965      if (this.resolutions_.length <= 1)
10966        return 0;
10967      const i = kt(
10968        Math.floor(t),
10969        0,
10970        this.resolutions_.length - 2
10971      ), n = this.resolutions_[i] / this.resolutions_[i + 1];
10972      return this.resolutions_[i] / Math.pow(n, kt(t - i, 0, 1));
10973    }
10974    return this.maxResolution_ / Math.pow(this.zoomFactor_, t - this.minZoom_);
10975  }
10976  /**
10977   * Fit the given geometry or extent based on the given map size and border.
10978   * The size is pixel dimensions of the box to fit the extent into.
10979   * In most cases you will want to use the map size, that is `map.getSize()`.
10980   * Takes care of the map angle.
10981   * @param {import("./geom/SimpleGeometry.js").default|import("./extent.js").Extent} geometryOrExtent The geometry or
10982   *     extent to fit the view to.
10983   * @param {FitOptions} [options] Options.
10984   * @api
10985   */
10986  fit(t, i) {
10987    let n;
10988    if (ht(
10989      Array.isArray(t) || typeof /** @type {?} */
10990      t.getSimplifiedGeometry == "function",
10991      24
10992    ), Array.isArray(t)) {
10993      ht(!Nn(t), 25);
10994      const s = ai(t, this.getProjection());
10995      n = Uu(s);
10996    } else if (t.getType() === "Circle") {
10997      const s = ai(
10998        t.getExtent(),
10999        this.getProjection()
11000      );
11001      n = Uu(s), n.rotate(this.getRotation(), Je(s));
11002    } else
11003      n = t;
11004    this.fitInternal(n, i);
11005  }
11006  /**
11007   * Calculate rotated extent
11008   * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
11009   * @return {import("./extent").Extent} The rotated extent for the geometry.
11010   */
11011  rotatedExtentForGeometry(t) {
11012    const i = this.getRotation(), n = Math.cos(i), s = Math.sin(-i), r = t.getFlatCoordinates(), o = t.getStride();
11013    let a = 1 / 0, l = 1 / 0, h = -1 / 0, c = -1 / 0;
11014    for (let u = 0, d = r.length; u < d; u += o) {
11015      const f = r[u] * n - r[u + 1] * s, g = r[u] * s + r[u + 1] * n;
11016      a = Math.min(a, f), l = Math.min(l, g), h = Math.max(h, f), c = Math.max(c, g);
11017    }
11018    return [a, l, h, c];
11019  }
11020  /**
11021   * @param {import("./geom/SimpleGeometry.js").default} geometry The geometry.
11022   * @param {FitOptions} [options] Options.
11023   */
11024  fitInternal(t, i) {
11025    i = i || {};
11026    let n = i.size;
11027    n || (n = this.getViewportSizeMinusPadding_());
11028    const s = i.padding !== void 0 ? i.padding : [0, 0, 0, 0], r = i.nearest !== void 0 ? i.nearest : !1;
11029    let o;
11030    i.minResolution !== void 0 ? o = i.minResolution : i.maxZoom !== void 0 ? o = this.getResolutionForZoom(i.maxZoom) : o = 0;
11031    const a = this.rotatedExtentForGeometry(t);
11032    let l = this.getResolutionForExtentInternal(a, [
11033      n[0] - s[1] - s[3],
11034      n[1] - s[0] - s[2]
11035    ]);
11036    l = isNaN(l) ? o : Math.max(l, o), l = this.getConstrainedResolution(l, r ? 0 : 1);
11037    const h = this.getRotation(), c = Math.sin(h), u = Math.cos(h), d = Je(a);
11038    d[0] += (s[1] - s[3]) / 2 * l, d[1] += (s[0] - s[2]) / 2 * l;
11039    const f = d[0] * u - d[1] * c, g = d[1] * u + d[0] * c, m = this.getConstrainedCenter([f, g], l), _ = i.callback ? i.callback : As;
11040    i.duration !== void 0 ? this.animateInternal(
11041      {
11042        resolution: l,
11043        center: m,
11044        duration: i.duration,
11045        easing: i.easing
11046      },
11047      _
11048    ) : (this.targetResolution_ = l, this.targetCenter_ = m, this.applyTargetState_(!1, !0), so(_, !0));
11049  }
11050  /**
11051   * Center on coordinate and view position.
11052   * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
11053   * @param {import("./size.js").Size} size Box pixel size.
11054   * @param {import("./pixel.js").Pixel} position Position on the view to center on.
11055   * @api
11056   */
11057  centerOn(t, i, n) {
11058    this.centerOnInternal(
11059      Lt(t, this.getProjection()),
11060      i,
11061      n
11062    );
11063  }
11064  /**
11065   * @param {import("./coordinate.js").Coordinate} coordinate Coordinate.
11066   * @param {import("./size.js").Size} size Box pixel size.
11067   * @param {import("./pixel.js").Pixel} position Position on the view to center on.
11068   */
11069  centerOnInternal(t, i, n) {
11070    this.setCenterInternal(
11071      $a(
11072        t,
11073        i,
11074        n,
11075        this.getResolution(),
11076        this.getRotation()
11077      )
11078    );
11079  }
11080  /**
11081   * Calculates the shift between map and viewport center.
11082   * @param {import("./coordinate.js").Coordinate} center Center.
11083   * @param {number} resolution Resolution.
11084   * @param {number} rotation Rotation.
11085   * @param {import("./size.js").Size} size Size.
11086   * @return {Array<number>|undefined} Center shift.
11087   */
11088  calculateCenterShift(t, i, n, s) {
11089    let r;
11090    const o = this.padding_;
11091    if (o && t) {
11092      const a = this.getViewportSizeMinusPadding_(-n), l = $a(
11093        t,
11094        s,
11095        [a[0] / 2 + o[3], a[1] / 2 + o[0]],
11096        i,
11097        n
11098      );
11099      r = [
11100        t[0] - l[0],
11101        t[1] - l[1]
11102      ];
11103    }
11104    return r;
11105  }
11106  /**
11107   * @return {boolean} Is defined.
11108   */
11109  isDef() {
11110    return !!this.getCenterInternal() && this.getResolution() !== void 0;
11111  }
11112  /**
11113   * Adds relative coordinates to the center of the view. Any extent constraint will apply.
11114   * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
11115   * @api
11116   */
11117  adjustCenter(t) {
11118    const i = Pn(this.targetCenter_, this.getProjection());
11119    this.setCenter([
11120      i[0] + t[0],
11121      i[1] + t[1]
11122    ]);
11123  }
11124  /**
11125   * Adds relative coordinates to the center of the view. Any extent constraint will apply.
11126   * @param {import("./coordinate.js").Coordinate} deltaCoordinates Relative value to add.
11127   */
11128  adjustCenterInternal(t) {
11129    const i = this.targetCenter_;
11130    this.setCenterInternal([
11131      i[0] + t[0],
11132      i[1] + t[1]
11133    ]);
11134  }
11135  /**
11136   * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
11137   * constraint will apply.
11138   * @param {number} ratio The ratio to apply on the view resolution.
11139   * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
11140   * @api
11141   */
11142  adjustResolution(t, i) {
11143    i = i && Lt(i, this.getProjection()), this.adjustResolutionInternal(t, i);
11144  }
11145  /**
11146   * Multiply the view resolution by a ratio, optionally using an anchor. Any resolution
11147   * constraint will apply.
11148   * @param {number} ratio The ratio to apply on the view resolution.
11149   * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
11150   */
11151  adjustResolutionInternal(t, i) {
11152    const n = this.getAnimating() || this.getInteracting(), s = this.getViewportSize_(this.getRotation()), r = this.constraints_.resolution(
11153      this.targetResolution_ * t,
11154      0,
11155      s,
11156      n
11157    );
11158    i && (this.targetCenter_ = this.calculateCenterZoom(r, i)), this.targetResolution_ *= t, this.applyTargetState_();
11159  }
11160  /**
11161   * Adds a value to the view zoom level, optionally using an anchor. Any resolution
11162   * constraint will apply.
11163   * @param {number} delta Relative value to add to the zoom level.
11164   * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
11165   * @api
11166   */
11167  adjustZoom(t, i) {
11168    this.adjustResolution(Math.pow(this.zoomFactor_, -t), i);
11169  }
11170  /**
11171   * Adds a value to the view rotation, optionally using an anchor. Any rotation
11172   * constraint will apply.
11173   * @param {number} delta Relative value to add to the zoom rotation, in radians.
11174   * @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
11175   * @api
11176   */
11177  adjustRotation(t, i) {
11178    i && (i = Lt(i, this.getProjection())), this.adjustRotationInternal(t, i);
11179  }
11180  /**
11181   * @param {number} delta Relative value to add to the zoom rotation, in radians.
11182   * @param {import("./coordinate.js").Coordinate} [anchor] The rotation center.
11183   */
11184  adjustRotationInternal(t, i) {
11185    const n = this.getAnimating() || this.getInteracting(), s = this.constraints_.rotation(
11186      this.targetRotation_ + t,
11187      n
11188    );
11189    i && (this.targetCenter_ = this.calculateCenterRotate(s, i)), this.targetRotation_ += t, this.applyTargetState_();
11190  }
11191  /**
11192   * Set the center of the current view. Any extent constraint will apply.
11193   * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
11194   * @observable
11195   * @api
11196   */
11197  setCenter(t) {
11198    this.setCenterInternal(
11199      t && Lt(t, this.getProjection())
11200    );
11201  }
11202  /**
11203   * Set the center using the view projection (not the user projection).
11204   * @param {import("./coordinate.js").Coordinate|undefined} center The center of the view.
11205   */
11206  setCenterInternal(t) {
11207    this.targetCenter_ = t, this.applyTargetState_();
11208  }
11209  /**
11210   * @param {import("./ViewHint.js").default} hint Hint.
11211   * @param {number} delta Delta.
11212   * @return {number} New value.
11213   */
11214  setHint(t, i) {
11215    return this.hints_[t] += i, this.changed(), this.hints_[t];
11216  }
11217  /**
11218   * Set the resolution for this view. Any resolution constraint will apply.
11219   * @param {number|undefined} resolution The resolution of the view.
11220   * @observable
11221   * @api
11222   */
11223  setResolution(t) {
11224    this.targetResolution_ = t, this.applyTargetState_();
11225  }
11226  /**
11227   * Set the rotation for this view. Any rotation constraint will apply.
11228   * @param {number} rotation The rotation of the view in radians.
11229   * @observable
11230   * @api
11231   */
11232  setRotation(t) {
11233    this.targetRotation_ = t, this.applyTargetState_();
11234  }
11235  /**
11236   * Zoom to a specific zoom level. Any resolution constrain will apply.
11237   * @param {number} zoom Zoom level.
11238   * @api
11239   */
11240  setZoom(t) {
11241    this.setResolution(this.getResolutionForZoom(t));
11242  }
11243  /**
11244   * Recompute rotation/resolution/center based on target values.
11245   * Note: we have to compute rotation first, then resolution and center considering that
11246   * parameters can influence one another in case a view extent constraint is present.
11247   * @param {boolean}
11247 [doNotCancelAnims] Do not cancel animations.
11248   * @param {boolean} [forceMoving] Apply constraints as if the view is moving.
11249   * @private
11250   */
11251  applyTargetState_(t, i) {
11252    const n = this.getAnimating() || this.getInteracting() || i, s = this.constraints_.rotation(
11253      this.targetRotation_,
11254      n
11255    ), r = this.getViewportSize_(s), o = this.constraints_.resolution(
11256      this.targetResolution_,
11257      0,
11258      r,
11259      n
11260    ), a = this.constraints_.center(
11261      this.targetCenter_,
11262      o,
11263      r,
11264      n,
11265      this.calculateCenterShift(
11266        this.targetCenter_,
11267        o,
11268        s,
11269        r
11270      )
11271    );
11272    this.get(Ge.ROTATION) !== s && this.set(Ge.ROTATION, s), this.get(Ge.RESOLUTION) !== o && (this.set(Ge.RESOLUTION, o), this.set("zoom", this.getZoom(), !0)), (!a || !this.get(Ge.CENTER) || !je(this.get(Ge.CENTER), a)) && this.set(Ge.CENTER, a), this.getAnimating() && !t && this.cancelAnimations(), this.cancelAnchor_ = void 0;
11273  }
11274  /**
11275   * If any constraints need to be applied, an animation will be triggered.
11276   * This is typically done on interaction end.
11277   * Note: calling this with a duration of 0 will apply the constrained values straight away,
11278   * without animation.
11279   * @param {number} [duration] The animation duration in ms.
11280   * @param {number} [resolutionDirection] Which direction to zoom.
11281   * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
11282   */
11283  resolveConstraints(t, i, n) {
11284    t = t !== void 0 ? t : 200;
11285    const s = i || 0, r = this.constraints_.rotation(this.targetRotation_), o = this.getViewportSize_(r), a = this.constraints_.resolution(
11286      this.targetResolution_,
11287      s,
11288      o
11289    ), l = this.constraints_.center(
11290      this.targetCenter_,
11291      a,
11292      o,
11293      !1,
11294      this.calculateCenterShift(
11295        this.targetCenter_,
11296        a,
11297        r,
11298        o
11299      )
11300    );
11301    if (t === 0 && !this.cancelAnchor_) {
11302      this.targetResolution_ = a, this.targetRotation_ = r, this.targetCenter_ = l, this.applyTargetState_();
11303      return;
11304    }
11305    n = n || (t === 0 ? this.cancelAnchor_ : void 0), this.cancelAnchor_ = void 0, (this.getResolution() !== a || this.getRotation() !== r || !this.getCenterInternal() || !je(this.getCenterInternal(), l)) && (this.getAnimating() && this.cancelAnimations(), this.animateInternal({
11306      rotation: r,
11307      center: l,
11308      resolution: a,
11309      duration: t,
11310      easing: js,
11311      anchor: n
11312    }));
11313  }
11314  /**
11315   * Notify the View that an interaction has started.
11316   * The view state will be resolved to a stable one if needed
11317   * (depending on its constraints).
11318   * @api
11319   */
11320  beginInteraction() {
11321    this.resolveConstraints(0), this.setHint(Kt.INTERACTING, 1);
11322  }
11323  /**
11324   * Notify the View that an interaction has ended. The view state will be resolved
11325   * to a stable one if needed (depending on its constraints).
11326   * @param {number} [duration] Animation duration in ms.
11327   * @param {number} [resolutionDirection] Which direction to zoom.
11328   * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
11329   * @api
11330   */
11331  endInteraction(t, i, n) {
11332    n = n && Lt(n, this.getProjection()), this.endInteractionInternal(t, i, n);
11333  }
11334  /**
11335   * Notify the View that an interaction has ended. The view state will be resolved
11336   * to a stable one if needed (depending on its constraints).
11337   * @param {number} [duration] Animation duration in ms.
11338   * @param {number} [resolutionDirection] Which direction to zoom.
11339   * @param {import("./coordinate.js").Coordinate} [anchor] The origin of the transformation.
11340   */
11341  endInteractionInternal(t, i, n) {
11342    this.getInteracting() && (this.setHint(Kt.INTERACTING, -1), this.resolveConstraints(t, i, n));
11343  }
11344  /**
11345   * Get a valid position for the view center according to the current constraints.
11346   * @param {import("./coordinate.js").Coordinate|undefined} targetCenter Target center position.
11347   * @param {number} [targetResolution] Target resolution. If not supplied, the current one will be used.
11348   * This is useful to guess a valid center position at a different zoom level.
11349   * @return {import("./coordinate.js").Coordinate|undefined} Valid center position.
11350   */
11351  getConstrainedCenter(t, i) {
11352    const n = this.getViewportSize_(this.getRotation());
11353    return this.constraints_.center(
11354      t,
11355      i || this.getResolution(),
11356      n
11357    );
11358  }
11359  /**
11360   * Get a valid zoom level according to the current view constraints.
11361   * @param {number|undefined} targetZoom Target zoom.
11362   * @param {number} [direction=0] Indicate which resolution should be used
11363   * by a renderer if the view resolution does not match any resolution of the tile source.
11364   * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
11365   * will be used. If -1, the nearest higher resolution will be used.
11366   * @return {number|undefined} Valid zoom level.
11367   */
11368  getConstrainedZoom(t, i) {
11369    const n = this.getResolutionForZoom(t);
11370    return this.getZoomForResolution(
11371      this.getConstrainedResolution(n, i)
11372    );
11373  }
11374  /**
11375   * Get a valid resolution according to the current view constraints.
11376   * @param {number|undefined} targetResolution Target resolution.
11377   * @param {number} [direction=0] Indicate which resolution should be used
11378   * by a renderer if the view resolution does not match any resolution of the tile source.
11379   * If 0, the nearest resolution will be used. If 1, the nearest lower resolution
11380   * will be used. If -1, the nearest higher resolution will be used.
11381   * @return {number|undefined} Valid resolution.
11382   */
11383  getConstrainedResolution(t, i) {
11384    i = i || 0;
11385    const n = this.getViewportSize_(this.getRotation());
11386    return this.constraints_.resolution(t, i, n);
11387  }
11388}
11389function so(e, t) {
11390  setTimeout(function() {
11391    e(t);
11392  }, 0);
11393}
11394function LC(e) {
11395  if (e.extent !== void 0) {
11396    const i = e.smoothExtentConstraint !== void 0 ? e.smoothExtentConstraint : !0;
11397    return Du(e.extent, e.constrainOnlyCenter, i);
11398  }
11399  const t = ch(e.projection, "EPSG:3857");
11400  if (e.multiWorld !== !0 && t.isGlobal()) {
11401    const i = t.getExtent().slice();
11402    return i[0] = -1 / 0, i[2] = 1 / 0, Du(i, !1, !1);
11403  }
11404  return tC;
11405}
11406function AC(e) {
11407  let t, i, n, o = e.minZoom !== void 0 ? e.minZoom : Xa, a = e.maxZoom !== void 0 ? e.maxZoom : 28;
11408  const l = e.zoomFactor !== void 0 ? e.zoomFactor : 2, h = e.multiWorld !== void 0 ? e.multiWorld : !1, c = e.smoothResolutionConstraint !== void 0 ? e.smoothResolutionConstraint : !0, u = e.showFullExtent !== void 0 ? e.showFullExtent : !1, d = ch(e.projection, "EPSG:3857"), f = d.getExtent();
11409  let g = e.constrainOnlyCenter, m = e.extent;
11410  if (!h && !m && d.isGlobal() && (g = !1, m = f), e.resolutions !== void 0) {
11411    const _ = e.resolutions;
11412    i = _[o], n = _[a] !== void 0 ? _[a] : _[_.length - 1], e.constrainResolution ? t = eC(
11413      _,
11414      c,
11415      !g && m,
11416      u
11417    ) : t = Nu(
11418      i,
11419      n,
11420      c,
11421      !g && m,
11422      u
11423    );
11424  } else {
11425    const p = (f ? Math.max(xt(f), qt(f)) : (
11426      // use an extent that can fit the whole world if need be
11427      360 * fr.degrees / d.getMetersPerUnit()
11428    )) / kh / Math.pow(2, Xa), y = p / Math.pow(2, 28 - Xa);
11429    i = e.maxResolution, i !== void 0 ? o = 0 : i = p / Math.pow(l, o), n = e.minResolution, n === void 0 && (e.maxZoom !== void 0 ? e.maxResolution !== void 0 ? n = i / Math.pow(l, a) : n = p / Math.pow(l, a) : n = y), a = o + Math.floor(
11430      Math.log(i / n) / Math.log(l)
11431    ), n = i / Math.pow(l, a - o), e.constrainResolution ? t = iC(
11432      l,
11433      i,
11434      n,
11435      c,
11436      !g && m,
11437      u
11438    ) : t = Nu(
11439      i,
11440      n,
11441      c,
11442      !g && m,
11443      u
11444    );
11445  }
11446  return {
11447    constraint: t,
11448    maxResolution: i,
11449    minResolution: n,
11450    minZoom: o,
11451    zoomFactor: l
11452  };
11453}
11454function OC(e) {
11455  if (e.enableRotation !== void 0 ? e.enableRotation : !0) {
11456    const i = e.constrainRotation;
11457    return i === void 0 || i === !0 ? sC() : i === !1 ? Gu : typeof i == "number" ? nC(i) : Gu;
11458  }
11459  return Gh;
11460}
11461function FC(e) {
11462  return !(e.sourceCenter && e.targetCenter && !je(e.sourceCenter, e.targetCenter) || e.sourceResolution !== e.targetResolution || e.sourceRotation !== e.targetRotation);
11463}
11464function $a(e, t, i, n, s) {
11465  const r = Math.cos(-s);
11466  let o = Math.sin(-s), a = e[0] * r - e[1] * o, l = e[1] * r + e[0] * o;
11467  a += (t[0] / 2 - i[0]) * n, l += (i[1] - t[1] / 2) * n, o = -o;
11468  const h = a * r - l * o, c = l * r + a * o;
11469  return [h, c];
11470}
11471const ri = PC;
11472class kC extends fg {
11473  /**
11474   * @param {Options<SourceType>} options Layer options.
11475   */
11476  constructor(t) {
11477    const i = Object.assign({}, t);
11478    delete i.source, super(i), this.on, this.once, this.un, this.mapPrecomposeKey_ = null, this.mapRenderKey_ = null, this.sourceChangeKey_ = null, this.renderer_ = null, this.sourceReady_ = !1, this.rendered = !1, t.render && (this.render = t.render), t.map && this.setMap(t.map), this.addChangeListener(
11479      wt.SOURCE,
11480      this.handleSourcePropertyChange_
11481    );
11482    const n = t.source ? (
11483      /** @type {SourceType} */
11484      t.source
11485    ) : null;
11486    this.setSource(n);
11487  }
11488  /**
11489   * @param {Array<import("./Layer.js").default>} [array] Array of layers (to be modified in place).
11490   * @return {Array<import("./Layer.js").default>} Array of layers.
11491   */
11492  getLayersArray(t) {
11493    return t = t || [], t.push(this), t;
11494  }
11495  /**
11496   * @param {Array<import("./Layer.js").State>} [states] Optional list of layer states (to be modified in place).
11497   * @return {Array<import("./Layer.js").State>} List of layer states.
11498   */
11499  getLayerStatesArray(t) {
11500    return t = t || [], t.push(this.getLayerState()), t;
11501  }
11502  /**
11503   * Get the layer source.
11504   * @return {SourceType|null} The layer source (or `null` if not yet set).
11505   * @observable
11506   * @api
11507   */
11508  getSource() {
11509    return (
11510      /** @type {SourceType} */
11511      this.get(wt.SOURCE) || null
11512    );
11513  }
11514  /**
11515   * @return {SourceType|null} The source being rendered.
11516   */
11517  getRenderSource() {
11518    return this.getSource();
11519  }
11520  /**
11521   * @return {import("../source/Source.js").State} Source state.
11522   */
11523  getSourceState() {
11524    const t = this.getSource();
11525    return t ? t.getState() : "undefined";
11526  }
11527  /**
11528   * @private
11529   */
11530  handleSourceChange_() {
11531    this.changed(), !(this.sourceReady_ || this.getSource().getState() !== "ready") && (this.sourceReady_ = !0, this.dispatchEvent("sourceready"));
11532  }
11533  /**
11534   * @private
11535   */
11536  handleSourcePropertyChange_() {
11537    this.sourceChangeKey_ && (St(this.sourceChangeKey_), this.sourceChangeKey_ = null), this.sourceReady_ = !1;
11538    const t = this.getSource();
11539    t && (this.sourceChangeKey_ = ct(
11540      t,
11541      et.CHANGE,
11542      this.handleSourceChange_,
11543      this
11544    ), t.getState() === "ready" && (this.sourceReady_ = !0, setTimeout(() => {
11545      this.dispatchEvent("sourceready");
11546    }, 0))), this.changed();
11547  }
11548  /**
11549   * @param {import("../pixel").Pixel} pixel Pixel.
11550   * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with
11551   * an array of features.
11552   */
11553  getFeatures(t) {
11554    return this.renderer_ ? this.renderer_.getFeatures(t) : Promise.resolve([]);
11555  }
11556  /**
11557   * @param {import("../pixel").Pixel} pixel Pixel.
11558   * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
11559   */
11560  getData(t) {
11561    return !this.renderer_ || !this.rendered ? null : this.renderer_.getData(t);
11562  }
11563  /**
11564   * The layer is visible on the map view, i.e. within its min/max resolution or zoom and
11565   * extent, not set to `visible: false`, and not inside a layer group that is set
11566   * to `visible: false`.
11567   * @param {View|import("../View.js").ViewStateLayerStateExtent} [view] View or {@link import("../Map.js").FrameState}.
11568   * Only required when the layer is not added to a map.
11569   * @return {boolean} The layer is visible in the map view.
11570   * @api
11571   */
11572  isVisible(t) {
11573    let i;
11574    const n = this.getMapInternal();
11575    !t && n && (t = n.getView()), t instanceof ri ? i = {
11576      viewState: t.getState(),
11577      extent: t.calculateExtent()
11578    } : i = t, !i.layerStatesArray && n && (i.layerStatesArray = n.getLayerGroup().getLayerStatesArray());
11579    let s;
11580    i.layerStatesArray ? s = i.layerStatesArray.find(
11581      (o) => o.layer === this
11582    ) : s = this.getLayerState();
11583    const r = this.getExtent();
11584    return Vh(s, i.viewState) && (!r || re(r, i.extent));
11585  }
11586  /**
11587   * Get the attributions of the source of this layer for the given view.
11588   * @param {View|import("../View.js").ViewStateLayerStateExtent} [view] View or {@link import("../Map.js").FrameState}.
11589   * Only required when the layer is not added to a map.
11590   * @return {Array<string>} Attributions for this layer at the given view.
11591   * @api
11592   */
11593  getAttributions(t) {
11594    if (!this.isVisible(t))
11595      return [];
11596    let i;
11597    const n = this.getSource();
11598    if (n && (i = n.getAttributions()), !i)
11599      return [];
11600    const s = t instanceof ri ? t.getViewStateAndExtent() : t;
11601    let r = i(s);
11602    return Array.isArray(r) || (r = [r]), r;
11603  }
11604  /**
11605   * In charge to manage the rendering of the layer. One layer type is
11606   * bounded with one layer renderer.
11607   * @param {?import("../Map.js").FrameState} frameState Frame state.
11608   * @param {HTMLElement} target Target which the renderer may (but need not) use
11609   * for rendering its content.
11610   * @return {HTMLElement|null} The rendered element.
11611   */
11612  render(t, i) {
11613    const n = this.getRenderer();
11614    return n.prepareFrame(t) ? (this.rendered = !0, n.renderFrame(t, i)) : null;
11615  }
11616  /**
11617   * Called when a layer is not visible during a map render.
11618   */
11619  unrender() {
11620    this.rendered = !1;
11621  }
11622  /**
11623   * For use inside the library only.
11624   * @param {import("../Map.js").default|null} map Map.
11625   */
11626  setMapInternal(t) {
11627    t || this.unrender(), this.set(wt.MAP, t);
11628  }
11629  /**
11630   * For use inside the library only.
11631   * @return {import("../Map.js").default|null} Map.
11632   */
11633  getMapInternal() {
11634    return this.get(wt.MAP);
11635  }
11636  /**
11637   * Sets the layer to be rendered on top of other layers on a map. The map will
11638   * not manage this layer in its layers collection. This
11639   * is useful for temporary layers. To remove an unmanaged layer from the map,
11640   * use `#setMap(null)`.
11641   *
11642   * To add the layer to a map and have it managed by the map, use
11643   * {@link module:ol/Map~Map#addLayer} instead.
11644   * @param {import("../Map.js").default|null} map Map.
11645   * @api
11646   */
11647  setMap(t) {
11648    this.mapPrecomposeKey_ && (St(this.mapPrecomposeKey_), this.mapPrecomposeKey_ = null), t || this.changed(), this.mapRenderKey_ && (St(this.mapRenderKey_), this.mapRenderKey_ = null), t && (this.mapPrecomposeKey_ = ct(
11649      t,
11650      Ji.PRECOMPOSE,
11651      function(i) {
11652        const s = /** @type {import("../render/Event.js").default} */ i.frameState.layerStatesArray, r = this.getLayerState(!1);
11653        ht(
11654          !s.some(function(o) {
11655            return o.layer === r.layer;
11656          }),
11657          67
11658        ), s.push(r);
11659      },
11660      this
11661    ), this.mapRenderKey_ = ct(this, et.CHANGE, t.render, t), this.changed());
11662  }
11663  /**
11664   * Set the layer source.
11665   * @param {SourceType|null} source The layer source.
11666   * @observable
11667   * @api
11668   */
11669  setSource(t) {
11670    this.set(wt.SOURCE, t);
11671  }
11672  /**
11673   * Get the renderer for this layer.
11674   * @return {RendererType|null} The layer renderer.
11675   */
11676  getRenderer() {
11677    return this.renderer_ || (this.renderer_ = this.createRenderer()), this.renderer_;
11678  }
11679  /**
11680   * @return {boolean} The layer has a renderer.
11681   */
11682  hasRenderer() {
11683    return !!this.renderer_;
11684  }
11685  /**
11686   * Create a renderer for this layer.
11687   * @return {RendererType} A layer renderer.
11688   * @protected
11689   */
11690  createRenderer() {
11691    return null;
11692  }
11693  /**
11694   * Clean up.
11695   */
11696  disposeInternal() {
11697    this.renderer_ && (this.renderer_.dispose(), delete this.renderer_), this.setSource(null), super.disposeInternal();
11698  }
11699}
11700function Vh(e, t) {
11701  if (!e.visible)
11702    return !1;
11703  const i = t.resolution;
11704  if (i < e.minResolution || i >= e.maxResolution)
11705    return !1;
11706  const n = t.zoom;
11707  return n > e.minZoom && n <= e.maxZoom;
11708}
11709const jr = kC;
11710class DC extends Ah {
11711  /**
11712   * @param {import("../Map.js").default} map Map.
11713   */
11714  constructor(t) {
11715    super(), this.map_ = t;
11716  }
11717  /**
11718   * @abstract
11719   * @param {import("../render/EventType.js").default} type Event type.
11720   * @param {import("../Map.js").FrameState} frameState Frame state.
11721   */
11722  dispatchRenderEvent(t, i) {
11723    Q();
11724  }
11725  /**
11726   * @param {import("../Map.js").FrameState} frameState FrameState.
11727   * @protected
11728   */
11729  calculateMatrices2D(t) {
11730    const i = t.viewState, n = t.coordinateToPixelTransform, s = t.pixelToCoordinateTransform;
11731    gi(
11732      n,
11733      t.size[0] / 2,
11734      t.size[1] / 2,
11735      1 / i.resolution,
11736      -1 / i.resolution,
11737      -i.rotation,
11738      -i.center[0],
11739      -i.center[1]
11740    ), Ca(s, n);
11741  }
11742  /**
11743   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
11744   * @param {import("../Map.js").FrameState} frameState FrameState.
11745   * @param {number} hitTolerance Hit tolerance in pixels.
11746   * @param {boolean} checkWrapped Check for wrapped geometries.
11747   * @param {import("./vector.js").FeatureCallback<T>}
11747 callback Feature callback.
11748   * @param {S} thisArg Value to use as `this` when executing `callback`.
11749   * @param {function(this: U, import("../layer/Layer.js").default): boolean} layerFilter Layer filter
11750   *     function, only layers which are visible and for which this function
11751   *     returns `true` will be tested for features.  By default, all visible
11752   *     layers will be tested.
11753   * @param {U} thisArg2 Value to use as `this` when executing `layerFilter`.
11754   * @return {T|undefined} Callback result.
11755   * @template S,T,U
11756   */
11757  forEachFeatureAtCoordinate(t, i, n, s, r, o, a, l) {
11758    let h;
11759    const c = i.viewState;
11760    function u(E, M, w, L) {
11761      return r.call(o, M, E ? w : null, L);
11762    }
11763    const d = c.projection, f = of(t.slice(), d), g = [[0, 0]];
11764    if (d.canWrapX() && s) {
11765      const E = d.getExtent(), M = xt(E);
11766      g.push([-M, 0], [M, 0]);
11767    }
11768    const m = i.layerStatesArray, _ = m.length, p = (
11769      /** @type {Array<HitMatch<T>>} */
11770      []
11771    ), y = [];
11772    for (let E = 0; E < g.length; E++)
11773      for (let M = _ - 1; M >= 0; --M) {
11774        const w = m[M], L = w.layer;
11775        if (L.hasRenderer() && Vh(w, c) && a.call(l, L)) {
11776          const I = L.getRenderer(), z = L.getSource();
11777          if (I && z) {
11778            const U = z.getWrapX() ? f : t, q = u.bind(
11779              null,
11780              w.managed
11781            );
11782            y[0] = U[0] + g[E][0], y[1] = U[1] + g[E][1], h = I.forEachFeatureAtCoordinate(
11783              y,
11784              i,
11785              n,
11786              q,
11787              p
11788            );
11789          }
11790          if (h)
11791            return h;
11792        }
11793      }
11794    if (p.length === 0)
11795      return;
11796    const x = 1 / p.length;
11797    return p.forEach((E, M) => E.distanceSq += M * x), p.sort((E, M) => E.distanceSq - M.distanceSq), p.some((E) => h = E.callback(E.feature, E.layer, E.geometry)), h;
11798  }
11799  /**
11800   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
11801   * @param {import("../Map.js").FrameState} frameState FrameState.
11802   * @param {number} hitTolerance Hit tolerance in pixels.
11803   * @param {boolean} checkWrapped Check for wrapped geometries.
11804   * @param {function(this: U, import("../layer/Layer.js").default): boolean} layerFilter Layer filter
11805   *     function, only layers which are visible and for which this function
11806   *     returns `true` will be tested for features.  By default, all visible
11807   *     layers will be tested.
11808   * @param {U} thisArg Value to use as `this` when executing `layerFilter`.
11809   * @return {boolean} Is there a feature at the given coordinate?
11810   * @template U
11811   */
11812  hasFeatureAtCoordinate(t, i, n, s, r, o) {
11813    return this.forEachFeatureAtCoordinate(
11814      t,
11815      i,
11816      n,
11817      s,
11818      An,
11819      this,
11820      r,
11821      o
11822    ) !== void 0;
11823  }
11824  /**
11825   * @return {import("../Map.js").default} Map.
11826   */
11827  getMap() {
11828    return this.map_;
11829  }
11830  /**
11831   * Render.
11832   * @abstract
11833   * @param {?import("../Map.js").FrameState} frameState Frame state.
11834   */
11835  renderFrame(t) {
11836    Q();
11837  }
11838  /**
11839   * @param {import("../Map.js").FrameState} frameState Frame state.
11840   * @protected
11841   */
11842  scheduleExpireIconCache(t) {
11843    Bo.canExpireCache() && t.postRenderFunctions.push(NC);
11844  }
11845}
11846function NC(e, t) {
11847  Bo.expire();
11848}
11849const GC = DC;
11850class zC extends Le {
11851  /**
11852   * @param {import("./EventType.js").default} type Type.
11853   * @param {import("../transform.js").Transform} [inversePixelTransform] Transform for
11854   *     CSS pixels to rendered pixels.
11855   * @param {import("../Map.js").FrameState} [frameState] Frame state.
11856   * @param {?(CanvasRenderingContext2D|WebGLRenderingContext)} [context] Context.
11857   */
11858  constructor(t, i, n, s) {
11859    super(t), this.inversePixelTransform = i, this.frameState = n, this.context = s;
11860  }
11861}
11862const Sg = zC, ro = "ol-hidden", wa = "ol-unselectable", qh = "ol-control", Xu = "ol-collapsed", jC = new RegExp(
11863  [
11864    "^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)",
11865    "(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)",
11866    "(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)",
11867    "(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?",
11868    "(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))",
11869    "(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",
11870    `?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`
11871  ].join(""),
11872  "i"
11873), $u = [
11874  "style",
11875  "variant",
11876  "weight",
11877  "size",
11878  "lineHeight",
11879  "family"
11880], Tg = function(e) {
11881  const t = e.match(jC);
11882  if (!t)
11883    return null;
11884  const i = (
11885    /** @type {FontParameters} */
11886    {
11887      lineHeight: "normal",
11888      size: "1.2em",
11889      style: "normal",
11890      weight: "normal",
11891      variant: "normal"
11892    }
11893  );
11894  for (let n = 0, s = $u.length; n < s; ++n) {
11895    const r = t[n + 1];
11896    r !== void 0 && (i[$u[n]] = r);
11897  }
11898  return i.families = i.family.split(/,\s?/), i;
11899};
11900function he(e, t, i, n) {
11901  let s;
11902  return i && i.length ? s = i.shift() : Oh ? s = new OffscreenCanvas(e || 300, t || 300) : s = document.createElement("canvas"), e && (s.width = e), t && (s.height = t), /** @type {CanvasRenderingContext2D} */
11903  s.getContext("2d", n);
11904}
11905function Sa(e) {
11906  const t = e.canvas;
11907  t.width = 1, t.height = 1, e.clearRect(0, 0, 1, 1);
11908}
11909function Yu(e, t) {
11910  const i = t.parentNode;
11911  i && i.replaceChild(e, t);
11912}
11913function Nl(e) {
11914  return e && e.parentNode ? e.parentNode.removeChild(e) : null;
11915}
11916function WC(e) {
11917  for (; e.lastChild; )
11918    e.removeChild(e.lastChild);
11919}
11920function BC(e, t) {
11921  const i = e.childNodes;
11922  for (let n = 0; ; ++n) {
11923    const s = i[n], r = t[n];
11924    if (!s && !r)
11925      break;
11926    if (s !== r) {
11927      if (!s) {
11928        e.appendChild(r);
11929        continue;
11930      }
11931      if (!r) {
11932        e.removeChild(s), --n;
11933        continue;
11934      }
11935      e.insertBefore(r, s);
11936    }
11937  }
11938}
11939const Ig = "10px sans-serif", Si = "#000", $o = "round", Er = [], Cr = 0, Os = "round", Mr = 10, br = "#000", wr = "center", Yo = "middle", xn = [0, 0, 0, 0], Sr = 1, xi = new Qe();
11940let qn = null, Gl;
11941const zl = {}, UC = function() {
11942  const t = "32px ", i = ["monospace", "serif"], n = i.length, s = "wmytzilWMYTZIL@#/&?$%10";
11943  let r, o;
11944  function a(h, c, u) {
11945    let d = !0;
11946    for (let f = 0; f < n; ++f) {
11947      const g = i[f];
11948      if (o = Ko(
11949        h + " " + c + " " + t + g,
11950        s
11951      ), u != g) {
11952        const m = Ko(
11953          h + " " + c + " " + t + u + "," + g,
11954          s
11955        );
11956        d = d && m != o;
11957      }
11958    }
11959    return !!d;
11960  }
11961  function l() {
11962    let h = !0;
11963    const c = xi.getKeys();
11964    for (let u = 0, d = c.length; u < d; ++u) {
11965      const f = c[u];
11966      xi.get(f) < 100 && (a.apply(this, f.split(`
11967`)) ? (Dr(zl), qn = null, Gl = void 0, xi.set(f, 100)) : (xi.set(f, xi.get(f) + 1, !0), h = !1));
11968    }
11969    h && (clearInterval(r), r = void 0);
11970  }
11971  return function(h) {
11972    const c = Tg(h);
11973    if (!c)
11974      return;
11975    const u = c.families;
11976    for (let d = 0, f = u.length; d < f; ++d) {
11977      const g = u[d], m = c.style + `
11978` + c.weight + `
11979` + g;
11980      xi.get(m) === void 0 && (xi.set(m, 100, !0), a(c.style, c.weight, g) || (xi.set(m, 0, !0), r === void 0 && (r = setInterval(l, 32))));
11981    }
11982  };
11983}(), XC = function() {
11984  let e;
11985  return function(t) {
11986    let i = zl[t];
11987    if (i == null) {
11988      if (Oh) {
11989        const n = Tg(t), s = Rg(t, "Žg");
11990        i = (isNaN(Number(n.lineHeight)) ? 1.2 : Number(n.lineHeight)) * (s.actualBoundingBoxAscent + s.actualBoundingBoxDescent);
11991      } else
11992        e || (e = document.createElement("div"), e.innerHTML = "M", e.style.minHeight = "0", e.style.maxHeight = "none", e.style.height = "auto", e.style.padding = "0", e.style.border = "none", e.style.position = "absolute", e.style.display = "block", e.style.left = "-99999px"), e.style.font = t, document.body.appendChild(e), i = e.offsetHeight, document.body.removeChild(e);
11993      zl[t] = i;
11994    }
11995    return i;
11996  };
11997}();
11998function Rg(e, t) {
11999  return qn || (qn = he(1, 1)), e != Gl && (qn.font = e, Gl = qn.font), qn.measureText(t);
12000}
12001function Ko(e, t) {
12002  return Rg(e, t).width;
12003}
12004function Ku(e, t, i) {
12005  if (t in i)
12006    return i[t];
12007  const n = t.split(`
12008`).reduce((s, r) => Math.max(s, Ko(e, r)), 0);
12009  return i[t] = n, n;
12010}
12011function $C(e, t) {
12012  const i = [], n = [], s = [];
12013  let r = 0, o = 0, a = 0, l = 0;
12014  for (let h = 0, c = t.length; h <= c; h += 2) {
12015    const u = t[h];
12016    if (u === `
12017` || h === c) {
12018      r = Math.max(r, o), s.push(o), o = 0, a += l;
12019      continue;
12020    }
12021    const d = t[h + 1] || e.font, f = Ko(d, u);
12022    i.push(f), o += f;
12023    const g = XC(d);
12024    n.push(g), l = Math.max(l, g);
12025  }
12026  return { width: r, height: a, widths: i, heights: n, lineWidths: s };
12027}
12028function YC(e, t, i, n, s, r, o, a, l, h, c) {
12029  e.save(), i !== 1 && (e.globalAlpha *= i), t && e.setTransform.apply(e, t), /** @type {*} */
12030  n.contextInstructions ? (e.translate(l, h), e.scale(c[0], c[1]), KC(
12031    /** @type {Label} */
12032    n,
12033    e
12034  )) : c[0] < 0 || c[1] < 0 ? (e.translate(l, h), e.scale(c[0], c[1]), e.drawImage(
12035    /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */
12036    n,
12037    s,
12038    r,
12039    o,
12040    a,
12041    0,
12042    0,
12043    o,
12044    a
12045  )) : e.drawImage(
12046    /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */
12047    n,
12048    s,
12049    r,
12050    o,
12051    a,
12052    l,
12053    h,
12054    o * c[0],
12055    a * c[1]
12056  ), e.restore();
12057}
12058function KC(e, t) {
12059  const i = e.contextInstructions;
12060  for (let n = 0, s = i.length; n < s; n += 2)
12061    Array.isArray(i[n + 1]) ? t[i[n]].apply(
12062      t,
12063      i[n + 1]
12064    ) : t[i[n]] = i[n + 1];
12065}
12066class VC extends GC {
12067  /**
12068   * @param {import("../Map.js").default} map Map.
12069   */
12070  constructor(t) {
12071    super(t), this.fontChangeListenerKey_ = ct(
12072      xi,
12073      Ls.PROPERTYCHANGE,
12074      t.redrawText.bind(t)
12075    ), this.element_ = document.createElement("div");
12076    const i = this.element_.style;
12077    i.position = "absolute", i.width = "100%", i.height = "100%", i.zIndex = "0", this.element_.className = wa + " ol-layers";
12078    const n = t.getViewport();
12079    n.insertBefore(this.element_, n.firstChild || null), this.children_ = [], this.renderedVisible_ = !0;
12080  }
12081  /**
12082   * @param {import("../render/EventType.js").default} type Event type.
12083   * @param {import("../Map.js").FrameState} frameState Frame state.
12084   */
12085  dispatchRenderEvent(t, i) {
12086    const n = this.getMap();
12087    if (n.hasListener(t)) {
12088      const s = new Sg(t, void 0, i);
12089      n.dispatchEvent(s);
12090    }
12091  }
12092  disposeInternal() {
12093    St(this.fontChangeListenerKey_), this.element_.parentNode.removeChild(this.element_), super.disposeInternal();
12094  }
12095  /**
12096   * Render.
12097   * @param {?import("../Map.js").FrameState} frameState Frame state.
12098   */
12099  renderFrame(t) {
12100    if (!t) {
12101      this.renderedVisible_ && (this.element_.style.display = "none", this.renderedVisible_ = !1);
12102      return;
12103    }
12104    this.calculateMatrices2D(t), this.dispatchRenderEvent(Ji.PRECOMPOSE, t);
12105    const i = t.layerStatesArray.sort(function(o, a) {
12106      return o.zIndex - a.zIndex;
12107    }), n = t.viewState;
12108    this.children_.length = 0;
12109    const s = [];
12110    let r = null;
12111    for (let o = 0, a = i.length; o < a; ++o) {
12112      const l = i[o];
12113      t.layerIndex = o;
12114      const h = l.layer, c = h.getSourceState();
12115      if (!Vh(l, n) || c != "ready" && c != "undefined") {
12116        h.unrender();
12117        continue;
12118      }
12119      const u = h.render(t, r);
12120      u && (u !== r && (this.children_.push(u), r = u), "getDeclutter" in h && s.push(
12121        /** @type {import("../layer/BaseVector.js").default} */
12122        h
12123      ));
12124    }
12125    for (let o = s.length - 1; o >= 0; --o)
12126      s[o].renderDeclutter(t);
12127    BC(this.element_, this.children_), this.dispatchRenderEvent(Ji.POSTCOMPOSE, t), this.renderedVisible_ || (this.element_.style.display = "", this.renderedVisible_ = !0), this.scheduleExpireIconCache(t);
12128  }
12129}
12130const qC = VC;
12131class ji extends Le {
12132  /**
12133   * @param {EventType} type The event type.
12134   * @param {BaseLayer} layer The layer.
12135   */
12136  constructor(t, i) {
12137    super(t), this.layer = i;
12138  }
12139}
12140const Ya = {
12141  LAYERS: "layers"
12142};
12143class Hh extends fg {
12144  /**
12145   * @param {Options} [options] Layer options.
12146   */
12147  constructor(t) {
12148    t = t || {};
12149    const i = (
12150      /** @type {Options} */
12151      Object.assign({}, t)
12152    );
12153    delete i.layers;
12154    let n = t.layers;
12155    super(i), this.on, this.once, this.un, this.layersListenerKeys_ = [], this.listenerKeys_ = {}, this.addChangeListener(Ya.LAYERS, this.handleLayersChanged_), n ? Array.isArray(n) ? n = new De(n.slice(), { unique: !0 }) : ht(typeof /** @type {?} */
12156    n.getArray == "function", 43) : n = new De(void 0, { unique: !0 }), this.setLayers(n);
12157  }
12158  /**
12159   * @private
12160   */
12161  handleLayerChange_() {
12162    this.changed();
12163  }
12164  /**
12165   * @private
12166   */
12167  handleLayersChanged_() {
12168    this.layersListenerKeys_.forEach(St), this.layersListenerKeys_.length = 0;
12169    const t = this.getLayers();
12170    this.layersListenerKeys_.push(
12171      ct(t, Vt.ADD, this.handleLayersAdd_, this),
12172      ct(t, Vt.REMOVE, this.handleLayersRemove_, this)
12173    );
12174    for (const n in this.listenerKeys_)
12175      this.listenerKeys_[n].forEach(St);
12176    Dr(this.listenerKeys_);
12177    const i = t.getArray();
12178    for (let n = 0, s = i.length; n < s; n++) {
12179      const r = i[n];
12180      this.registerLayerListeners_(r), this.dispatchEvent(new ji("addlayer", r));
12181    }
12182    this.changed();
12183  }
12184  /**
12185   * @param {BaseLayer} layer The layer.
12186   */
12187  registerLayerListeners_(t) {
12188    const i = [
12189      ct(
12190        t,
12191        Ls.PROPERTYCHANGE,
12192        this.handleLayerChange_,
12193        this
12194      ),
12195      ct(t, et.CHANGE, this.handleLayerChange_, this)
12196    ];
12197    t instanceof Hh && i.push(
12198      ct(t, "addlayer", this.handleLayerGroupAdd_, this),
12199      ct(t, "removelayer", this.handleLayerGroupRemove_, this)
12200    ), this.listenerKeys_[lt(t)] = i;
12201  }
12202  /**
12203   * @param {GroupEvent} event The layer group event.
12204   */
12205  handleLayerGroupAdd_(t) {
12206    this.dispatchEvent(new ji("addlayer", t.layer));
12207  }
12208  /**
12209   * @param {GroupEvent} event The layer group event.
12210   */
12211  handleLayerGroupRemove_(t) {
12212    this.dispatchEvent(new ji("removelayer", t.layer));
12213  }
12214  /**
12215   * @param {import("../Collection.js").CollectionEvent<import("./Base.js").default>} collectionEvent CollectionEvent.
12216   * @private
12217   */
12218  handleLayersAdd_(t) {
12219    const i = t.element;
12220    this.registerLayerListeners_(i), this.dispatchEvent(new ji("addlayer", i)), this.changed();
12221  }
12222  /**
12223   * @param {import("../Collection.js").CollectionEvent<import("./Base.js").default>} collectionEvent CollectionEvent.
12224   * @private
12225   */
12226  handleLayersRemove_(t) {
12227    const i = t.element, n = lt(i);
12228    this.listenerKeys_[n].forEach(St), delete this.listenerKeys_[n], this.dispatchEvent(new ji("removelayer", i)), this.changed();
12229  }
12230  /**
12231   * Returns the {@link module:ol/Collection~Collection collection} of {@link module:ol/layer/Layer~Layer layers}
12232   * in this group.
12233   * @return {!Collection<import("./Base.js").default>} Collection of
12234   *   {@link module:ol/layer/Base~BaseLayer layers} that are part of this group.
12235   * @observable
12236   * @api
12237   */
12238  getLayers() {
12239    return (
12240      /** @type {!Collection<import("./Base.js").default>} */
12241      this.get(Ya.LAYERS)
12242    );
12243  }
12244  /**
12245   * Set the {@link module:ol/Collection~Collection collection} of {@link module:ol/layer/Layer~Layer layers}
12246   * in this group.
12247   * @param {!Collection<import("./Base.js").default>} layers Collection of
12248   *   {@link module:ol/layer/Base~BaseLayer layers} that are part of this group.
12249   * @observable
12250   * @api
12251   */
12252  setLayers(t) {
12253    const i = this.getLayers();
12254    if (i) {
12255      const n = i.getArray();
12256      for (let s = 0, r = n.length; s < r; ++s)
12257        this.dispatchEvent(new ji("removelayer", n[s]));
12258    }
12259    this.set(Ya.LAYERS, t);
12260  }
12261  /**
12262   * @param {Array<import("./Layer.js").default>} [array] Array of layers (to be modified in place).
12263   * @return {Array<import("./Layer.js").default>} Array of layers.
12264   */
12265  getLayersArray(t) {
12266    return t = t !== void 0 ? t : [], this.getLayers().forEach(function(i) {
12267      i.getLayersArray(t);
12268    }), t;
12269  }
12270  /**
12271   * Get the layer states list and use this groups z-index as the default
12272   * for all layers in this and nested groups, if it is unset at this point.
12273   * If dest is not provided and this group's z-index is undefined
12274   * 0 is used a the default z-index.
12275   * @param {Array<import("./Layer.js").State>} [dest] Optional list
12276   * of layer states (to be modified in place).
12277   * @return {Array<import("./Layer.js").State>} List of layer states.
12278   */
12279  getLayerStatesArray(t) {
12280    const i = t !== void 0 ? t : [], n = i.length;
12281    this.getLayers().forEach(function(o) {
12282      o.getLayerStatesArray(i);
12283    });
12284    const s = this.getLayerState();
12285    let r = s.zIndex;
12286    !t && s.zIndex === void 0 && (r = 0);
12287    for (let o = n, a = i.length; o < a; o++) {
12288      const l = i[o];
12289      l.opacity *= s.opacity, l.visible = l.visible && s.visible, l.maxResolution = Math.min(
12290        l.maxResolution,
12291        s.maxResolution
12292      ), l.minResolution = Math.max(
12293        l.minResolution,
12294        s.minResolution
12295      ), l.minZoom = Math.max(l.minZoom, s.minZoom), l.maxZoom = Math.min(l.maxZoom, s.maxZoom), s.extent !== void 0 && (l.extent !== void 0 ? l.extent = En(
12296        l.extent,
12297        s.extent
12298      ) : l.extent = s.extent), l.zIndex === void 0 && (l.zIndex = r);
12299    }
12300    return i;
12301  }
12302  /**
12303   * @return {import("../source/Source.js").State} Source state.
12304   */
12305  getSourceState() {
12306    return "ready";
12307  }
12308}
12309const Ta = Hh;
12310class HC extends Le {
12311  /**
12312   * @param {string} type Event type.
12313   * @param {import("./Map.js").default} map Map.
12314   * @param {?import("./Map.js").FrameState} [frameState] Frame state.
12315   */
12316  constructor(t, i, n) {
12317    super(t), this.map = i, this.frameState = n !== void 0 ? n : null;
12318  }
12319}
12320const Hn = HC;
12321class ZC extends Hn {
12322  /**
12323   * @param {string} type Event type.
12324   * @param {import("./Map.js").default} map Map.
12325   * @param {EVENT} originalEvent Original event.
12326   * @param {boolean} [dragging] Is the map currently being dragged?
12327   * @param {import("./Map.js").FrameState} [frameState] Frame state.
12328   * @param {Array<PointerEvent>} [activePointers] Active pointers.
12329   */
12330  constructor(t, i, n, s, r, o) {
12331    super(t, i, r), this.originalEvent = n, this.pixel_ = null, this.coordinate_ = null, this.dragging = s !== void 0 ? s : !1, this.activePointers = o;
12332  }
12333  /**
12334   * The map pixel relative to the viewport corresponding to the original event.
12335   * @type {import("./pixel.js").Pixel}
12336   * @api
12337   */
12338  get pixel() {
12339    return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_;
12340  }
12341  set pixel(t) {
12342    this.pixel_ = t;
12343  }
12344  /**
12345   * The coordinate corresponding to the original browser event.  This will be in the user
12346   * projection if one is set.  Otherwise it will be in the view projection.
12347   * @type {import("./coordinate.js").Coordinate}
12348   * @api
12349   */
12350  get coordinate() {
12351    return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_;
12352  }
12353  set coordinate(t) {
12354    this.coordinate_ = t;
12355  }
12356  /**
12357   * Prevents the default browser action.
12358   * See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault.
12359   * @api
12360   */
12361  preventDefault() {
12362    super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault();
12363  }
12364  /**
12365   * Prevents further propagation of the current event.
12366   * See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation.
12367   * @api
12368   */
12369  stopPropagation() {
12370    super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation();
12371  }
12372}
12373const Ei = ZC, mt = {
12374  /**
12375   * A true single click with no dragging and no double click. Note that this
12376   * event is delayed by 250 ms to ensure that it is not a double click.
12377   * @event module:ol/MapBrowserEvent~MapBrowserEvent#singleclick
12378   * @api
12379   */
12380  SINGLECLICK: "singleclick",
12381  /**
12382   * A click with no dragging. A double click will fire two of this.
12383   * @event module:ol/MapBrowserEvent~MapBrowserEvent#click
12384   * @api
12385   */
12386  CLICK: et.CLICK,
12387  /**
12388   * A true double click, with no dragging.
12389   * @event module:ol/MapBrowserEvent~MapBrowserEvent#dblclick
12390   * @api
12391   */
12392  DBLCLICK: et.DBLCLICK,
12393  /**
12394   * Triggered when a pointer is dragged.
12395   * @event module:ol/MapBrowserEvent~MapBrowserEvent#pointerdrag
12396   * @api
12397   */
12398  POINTERDRAG: "pointerdrag",
12399  /**
12400   * Triggered when a pointer is moved. Note that on touch devices this is
12401   * triggered when the map is panned, so is not the same as mousemove.
12402   * @event module:ol/MapBrowserEvent~MapBrowserEvent#pointermove
12403   * @api
12404   */
12405  POINTERMOVE: "pointermove",
12406  POINTERDOWN: "pointerdown",
12407  POINTERUP: "pointerup",
12408  POINTEROVER: "pointerover",
12409  POINTEROUT: "pointerout",
12410  POINTERENTER: "pointerenter",
12411  POINTERLEAVE: "pointerleave",
12412  POINTERCANCEL: "pointercancel"
12413}, jl = {
12414  POINTERMOVE: "pointermove",
12415  POINTERDOWN: "pointerdown",
12416  POINTERUP: "pointerup",
12417  POINTEROVER: "pointerover",
12418  POINTEROUT: "pointerout",
12419  POINTERENTER: "pointerenter",
12420  POINTERLEAVE: "pointerleave",
12421  POINTERCANCEL: "pointercancel"
12422};
12423class JC extends zr {
12424  /**
12425   * @param {import("./Map.js").default} map The map with the viewport to listen to events on.
12426   * @param {number} [moveTolerance] The minimal distance the pointer must travel to trigger a move.
12427   */
12428  constructor(t, i) {
12429    super(t), this.map_ = t, this.clickTimeoutId_, this.emulateClicks_ = !1, this.dragging_ = !1, this.dragListenerKeys_ = [], this.moveTolerance_ = i === void 0 ? 1 : i, this.down_ = null;
12430    const n = this.map_.getViewport();
12431    this.activePointers_ = [], this.trackedTouches_ = {}, this.element_ = n, this.pointerdownListenerKey_ = ct(
12432      n,
12433      jl.POINTERDOWN,
12434      this.handlePointerDown_,
12435      this
12436    ), this.originalPointerMoveEvent_, this.relayedListenerKey_ = ct(
12437      n,
12438      jl.POINTERMOVE,
12439      this.relayMoveEvent_,
12440      this
12441    ), this.boundHandleTouchMove_ = this.handleTouchMove_.bind(this), this.element_.addEventListener(
12442      et.TOUCHMOVE,
12443      this.boundHandleTouchMove_,
12444      cg ? { passive: !1 } : !1
12445    );
12446  }
12447  /**
12448   * @param {PointerEvent} pointerEvent Pointer
12449   * event.
12450   * @private
12451   */
12452  emulateClick_(t) {
12453    let i = new Ei(
12454      mt.CLICK,
12455      this.map_,
12456      t
12457    );
12458    this.dispatchEvent(i), this.clickTimeoutId_ !== void 0 ? (clearTimeout(this.clickTimeoutId_), this.clickTimeoutId_ = void 0, i = new Ei(
12459      mt.DBLCLICK,
12460      this.map_,
12461      t
12462    ), this.dispatchEvent(i)) : this.clickTimeoutId_ = setTimeout(() => {
12463      this.clickTimeoutId_ = void 0;
12464      const n = new Ei(
12465        mt.SINGLECLICK,
12466        this.map_,
12467        t
12468      );
12469      this.dispatchEvent(n);
12470    }, 250);
12471  }
12472  /**
12473   * Keeps track on how many pointers are currently active.
12474   *
12475   * @param {PointerEvent} pointerEvent Pointer
12476   * event.
12477   * @private
12478   */
12479  updateActivePointers_(t) {
12480    const i = t, n = i.pointerId;
12481    if (i.type == mt.POINTERUP || i.type == mt.POINTERCANCEL) {
12482      delete this.trackedTouches_[n];
12483      for (const s in this.trackedTouches_)
12484        if (this.trackedTouches_[s].target !== i.target) {
12485          delete this.trackedTouches_[s];
12486          break;
12487        }
12488    } else
12489      (i.type == mt.POINTERDOWN || i.type == mt.POINTERMOVE) && (this.trackedTouches_[n] = i);
12490    this.activePointers_ = Object.values(this.trackedTouches_);
12491  }
12492  /**
12493   * @param {PointerEvent} pointerEvent Pointer
12494   * event.
12495   * @private
12496   */
12497  handlePointerUp_(t) {
12498    this.updateActivePointers_(t);
12499    const i = new Ei(
12500      mt.POINTERUP,
12501      this.map_,
12502      t,
12503      void 0,
12504      void 0,
12505      this.activePointers_
12506    );
12507    this.dispatchEvent(i), this.emulateClicks_ && !i.defaultPrevented && !this.dragging_ && this.isMouseActionButton_(t) && this.emulateClick_(this.down_), this.activePointers_.length === 0 && (this.dragListenerKeys_.forEach(St), this.dragListenerKeys_.length = 0, this.dragging_ = !1, this.down_ = null);
12508  }
12509  /**
12510   * @param {PointerEvent} pointerEvent Pointer
12511   * event.
12512   * @return {boolean} If the left mouse button was pressed.
12513   * @private
12514   */
12515  isMouseActionButton_(t) {
12516    return t.button === 0;
12517  }
12518  /**
12519   * @param {PointerEvent} pointerEvent Pointer
12520   * event.
12521   * @private
12522   */
12523  handlePointerDown_(t) {
12524    this.emulateClicks_ = this.activePointers_.length === 0, this.updateActivePointers_(t);
12525    const i = new Ei(
12526      mt.POINTERDOWN,
12527      this.map_,
12528      t,
12529      void 0,
12530      void 0,
12531      this.activePointers_
12532    );
12533    if (this.dispatchEvent(i), this.down_ = new PointerEvent(t.type, t), Object.defineProperty(this.down_, "target", {
12534      writable: !1,
12535      value: t.target
12536    }), this.dragListenerKeys_.length === 0) {
12537      const n = this.map_.getOwnerDocument();
12538      this.dragListenerKeys_.push(
12539        ct(
12540          n,
12541          mt.POINTERMOVE,
12542          this.handlePointerMove_,
12543          this
12544        ),
12545        ct(n, mt.POINTERUP, this.handlePointerUp_, this),
12546        /* Note that the listener for `pointercancel is set up on
12547         * `pointerEventHandler_` and not `documentPointerEventHandler_` like
12548         * the `pointerup` and `pointermove` listeners.
12549         *
12550         * The reason for this is the following: `TouchSource.vacuumTouches_()`
12551         * issues `pointercancel` events, when there was no `touchend` for a
12552         * `touchstart`. Now, let's say a first `touchstart` is registered on
12553         * `pointerEventHandler_`. The `documentPointerEventHandler_` is set up.
12554         * But `documentPointerEventHandler_` doesn't know about the first
12555         * `touchstart`. If there is no `touchend` for the `touchstart`, we can
12556         * only receive a `touchcancel` from `pointerEventHandler_`, because it is
12557         * only registered there.
12558         */
12559        ct(
12560          this.element_,
12561          mt.POINTERCANCEL,
12562          this.handlePointerUp_,
12563          this
12564        )
12565      ), this.element_.getRootNode && this.element_.getRootNode() !== n && this.dragListenerKeys_.push(
12566        ct(
12567          this.element_.getRootNode(),
12568          mt.POINTERUP,
12569          this.handlePointerUp_,
12570          this
12571        )
12572      );
12573    }
12574  }
12575  /**
12576   * @param {PointerEvent} pointerEvent Pointer
12577   * event.
12578   * @private
12579   */
12580  handlePointerMove_(t) {
12581    if (this.isMoving_(t)) {
12582      this.updateActivePointers_(t), this.dragging_ = !0;
12583      const i = new Ei(
12584        mt.POINTERDRAG,
12585        this.map_,
12586        t,
12587        this.dragging_,
12588        void 0,
12589        this.activePointers_
12590      );
12591      this.dispatchEvent(i);
12592    }
12593  }
12594  /**
12595   * Wrap and relay a pointermove event.
12596   * @param {PointerEvent} pointerEvent Pointer
12597   * event.
12598   * @private
12599   */
12600  relayMoveEvent_(t) {
12601    this.originalPointerMoveEvent_ = t;
12602    const i = !!(this.down_ && this.isMoving_(t));
12603    this.dispatchEvent(
12604      new Ei(
12605        mt.POINTERMOVE,
12606        this.map_,
12607        t,
12608        i
12609      )
12610    );
12611  }
12612  /**
12613   * Flexible handling of a `touch-action: none` css equivalent: because calling
12614   * `preventDefault()` on a `pointermove` event does not stop n
12614ative page scrolling
12615   * and zooming, we also listen for `touchmove` and call `preventDefault()` on it
12616   * when an interaction (currently `DragPan` handles the event.
12617   * @param {TouchEvent} event Event.
12618   * @private
12619   */
12620  handleTouchMove_(t) {
12621    const i = this.originalPointerMoveEvent_;
12622    (!i || i.defaultPrevented) && (typeof t.cancelable != "boolean" || t.cancelable === !0) && t.preventDefault();
12623  }
12624  /**
12625   * @param {PointerEvent} pointerEvent Pointer
12626   * event.
12627   * @return {boolean} Is moving.
12628   * @private
12629   */
12630  isMoving_(t) {
12631    return this.dragging_ || Math.abs(t.clientX - this.down_.clientX) > this.moveTolerance_ || Math.abs(t.clientY - this.down_.clientY) > this.moveTolerance_;
12632  }
12633  /**
12634   * Clean up.
12635   */
12636  disposeInternal() {
12637    this.relayedListenerKey_ && (St(this.relayedListenerKey_), this.relayedListenerKey_ = null), this.element_.removeEventListener(
12638      et.TOUCHMOVE,
12639      this.boundHandleTouchMove_
12640    ), this.pointerdownListenerKey_ && (St(this.pointerdownListenerKey_), this.pointerdownListenerKey_ = null), this.dragListenerKeys_.forEach(St), this.dragListenerKeys_.length = 0, this.element_ = null, super.disposeInternal();
12641  }
12642}
12643const QC = JC, Gi = {
12644  /**
12645   * Triggered after a map frame is rendered.
12646   * @event module:ol/MapEvent~MapEvent#postrender
12647   * @api
12648   */
12649  POSTRENDER: "postrender",
12650  /**
12651   * Triggered when the map starts moving.
12652   * @event module:ol/MapEvent~MapEvent#movestart
12653   * @api
12654   */
12655  MOVESTART: "movestart",
12656  /**
12657   * Triggered after the map is moved.
12658   * @event module:ol/MapEvent~MapEvent#moveend
12659   * @api
12660   */
12661  MOVEEND: "moveend",
12662  /**
12663   * Triggered when loading of additional map data (tiles, images, features) starts.
12664   * @event module:ol/MapEvent~MapEvent#loadstart
12665   * @api
12666   */
12667  LOADSTART: "loadstart",
12668  /**
12669   * Triggered when loading of additional map data has completed.
12670   * @event module:ol/MapEvent~MapEvent#loadend
12671   * @api
12672   */
12673  LOADEND: "loadend"
12674}, ie = {
12675  LAYERGROUP: "layergroup",
12676  SIZE: "size",
12677  TARGET: "target",
12678  VIEW: "view"
12679}, Vo = 1 / 0;
12680class tM {
12681  /**
12682   * @param {function(T): number} priorityFunction Priority function.
12683   * @param {function(T): string} keyFunction Key function.
12684   */
12685  constructor(t, i) {
12686    this.priorityFunction_ = t, this.keyFunction_ = i, this.elements_ = [], this.priorities_ = [], this.queuedElements_ = {};
12687  }
12688  /**
12689   * FIXME empty description for jsdoc
12690   */
12691  clear() {
12692    this.elements_.length = 0, this.priorities_.length = 0, Dr(this.queuedElements_);
12693  }
12694  /**
12695   * Remove and return the highest-priority element. O(log N).
12696   * @return {T} Element.
12697   */
12698  dequeue() {
12699    const t = this.elements_, i = this.priorities_, n = t[0];
12700    t.length == 1 ? (t.length = 0, i.length = 0) : (t[0] = t.pop(), i[0] = i.pop(), this.siftUp_(0));
12701    const s = this.keyFunction_(n);
12702    return delete this.queuedElements_[s], n;
12703  }
12704  /**
12705   * Enqueue an element. O(log N).
12706   * @param {T} element Element.
12707   * @return {boolean} The element was added to the queue.
12708   */
12709  enqueue(t) {
12710    ht(!(this.keyFunction_(t) in this.queuedElements_), 31);
12711    const i = this.priorityFunction_(t);
12712    return i != Vo ? (this.elements_.push(t), this.priorities_.push(i), this.queuedElements_[this.keyFunction_(t)] = !0, this.siftDown_(0, this.elements_.length - 1), !0) : !1;
12713  }
12714  /**
12715   * @return {number} Count.
12716   */
12717  getCount() {
12718    return this.elements_.length;
12719  }
12720  /**
12721   * Gets the index of the left child of the node at the given index.
12722   * @param {number} index The index of the node to get the left child for.
12723   * @return {number} The index of the left child.
12724   * @private
12725   */
12726  getLeftChildIndex_(t) {
12727    return t * 2 + 1;
12728  }
12729  /**
12730   * Gets the index of the right child of the node at the given index.
12731   * @param {number} index The index of the node to get the right child for.
12732   * @return {number} The index of the right child.
12733   * @private
12734   */
12735  getRightChildIndex_(t) {
12736    return t * 2 + 2;
12737  }
12738  /**
12739   * Gets the index of the parent of the node at the given index.
12740   * @param {number} index The index of the node to get the parent for.
12741   * @return {number} The index of the parent.
12742   * @private
12743   */
12744  getParentIndex_(t) {
12745    return t - 1 >> 1;
12746  }
12747  /**
12748   * Make this a heap. O(N).
12749   * @private
12750   */
12751  heapify_() {
12752    let t;
12753    for (t = (this.elements_.length >> 1) - 1; t >= 0; t--)
12754      this.siftUp_(t);
12755  }
12756  /**
12757   * @return {boolean} Is empty.
12758   */
12759  isEmpty() {
12760    return this.elements_.length === 0;
12761  }
12762  /**
12763   * @param {string} key Key.
12764   * @return {boolean} Is key queued.
12765   */
12766  isKeyQueued(t) {
12767    return t in this.queuedElements_;
12768  }
12769  /**
12770   * @param {T} element Element.
12771   * @return {boolean} Is queued.
12772   */
12773  isQueued(t) {
12774    return this.isKeyQueued(this.keyFunction_(t));
12775  }
12776  /**
12777   * @param {number} index The index of the node to move down.
12778   * @private
12779   */
12780  siftUp_(t) {
12781    const i = this.elements_, n = this.priorities_, s = i.length, r = i[t], o = n[t], a = t;
12782    for (; t < s >> 1; ) {
12783      const l = this.getLeftChildIndex_(t), h = this.getRightChildIndex_(t), c = h < s && n[h] < n[l] ? h : l;
12784      i[t] = i[c], n[t] = n[c], t = c;
12785    }
12786    i[t] = r, n[t] = o, this.siftDown_(a, t);
12787  }
12788  /**
12789   * @param {number} startIndex The index of the root.
12790   * @param {number} index The index of the node to move up.
12791   * @private
12792   */
12793  siftDown_(t, i) {
12794    const n = this.elements_, s = this.priorities_, r = n[i], o = s[i];
12795    for (; i > t; ) {
12796      const a = this.getParentIndex_(i);
12797      if (s[a] > o)
12798        n[i] = n[a], s[i] = s[a], i = a;
12799      else
12800        break;
12801    }
12802    n[i] = r, s[i] = o;
12803  }
12804  /**
12805   * FIXME empty description for jsdoc
12806   */
12807  reprioritize() {
12808    const t = this.priorityFunction_, i = this.elements_, n = this.priorities_;
12809    let s = 0;
12810    const r = i.length;
12811    let o, a, l;
12812    for (a = 0; a < r; ++a)
12813      o = i[a], l = t(o), l == Vo ? delete this.queuedElements_[this.keyFunction_(o)] : (n[s] = l, i[s++] = o);
12814    i.length = s, n.length = s, this.heapify_();
12815  }
12816}
12817const eM = tM, J = {
12818  IDLE: 0,
12819  LOADING: 1,
12820  LOADED: 2,
12821  /**
12822   * Indicates that tile loading failed
12823   * @type {number}
12824   */
12825  ERROR: 3,
12826  EMPTY: 4
12827};
12828class iM extends eM {
12829  /**
12830   * @param {PriorityFunction} tilePriorityFunction Tile priority function.
12831   * @param {function(): ?} tileChangeCallback Function called on each tile change event.
12832   */
12833  constructor(t, i) {
12834    super(
12835      /**
12836       * @param {Array} element Element.
12837       * @return {number} Priority.
12838       */
12839      function(n) {
12840        return t.apply(null, n);
12841      },
12842      /**
12843       * @param {Array} element Element.
12844       * @return {string} Key.
12845       */
12846      function(n) {
12847        return (
12848          /** @type {import("./Tile.js").default} */
12849          n[0].getKey()
12850        );
12851      }
12852    ), this.boundHandleTileChange_ = this.handleTileChange.bind(this), this.tileChangeCallback_ = i, this.tilesLoading_ = 0, this.tilesLoadingKeys_ = {};
12853  }
12854  /**
12855   * @param {Array} element Element.
12856   * @return {boolean} The element was added to the queue.
12857   */
12858  enqueue(t) {
12859    const i = super.enqueue(t);
12860    return i && t[0].addEventListener(et.CHANGE, this.boundHandleTileChange_), i;
12861  }
12862  /**
12863   * @return {number} Number of tiles loading.
12864   */
12865  getTilesLoading() {
12866    return this.tilesLoading_;
12867  }
12868  /**
12869   * @param {import("./events/Event.js").default} event Event.
12870   * @protected
12871   */
12872  handleTileChange(t) {
12873    const i = (
12874      /** @type {import("./Tile.js").default} */
12875      t.target
12876    ), n = i.getState();
12877    if (n === J.LOADED || n === J.ERROR || n === J.EMPTY) {
12878      n !== J.ERROR && i.removeEventListener(et.CHANGE, this.boundHandleTileChange_);
12879      const s = i.getKey();
12880      s in this.tilesLoadingKeys_ && (delete this.tilesLoadingKeys_[s], --this.tilesLoading_), this.tileChangeCallback_();
12881    }
12882  }
12883  /**
12884   * @param {number} maxTotalLoading Maximum number tiles to load simultaneously.
12885   * @param {number} maxNewLoads Maximum number of new tiles to load.
12886   */
12887  loadMoreTiles(t, i) {
12888    let n = 0, s, r, o;
12889    for (; this.tilesLoading_ < t && n < i && this.getCount() > 0; )
12890      r = /** @type {import("./Tile.js").default} */
12891      this.dequeue()[0], o = r.getKey(), s = r.getState(), s === J.IDLE && !(o in this.tilesLoadingKeys_) && (this.tilesLoadingKeys_[o] = !0, ++this.tilesLoading_, ++n, r.load());
12892  }
12893}
12894const nM = iM;
12895function sM(e, t, i, n, s) {
12896  if (!e || !(i in e.wantedTiles) || !e.wantedTiles[i][t.getKey()])
12897    return Vo;
12898  const r = e.viewState.center, o = n[0] - r[0], a = n[1] - r[1];
12899  return 65536 * Math.log(s) + Math.sqrt(o * o + a * a) / s;
12900}
12901class rM extends Qe {
12902  /**
12903   * @param {Options} options Control options.
12904   */
12905  constructor(t) {
12906    super();
12907    const i = t.element;
12908    i && !t.target && !i.style.pointerEvents && (i.style.pointerEvents = "auto"), this.element = i || null, this.target_ = null, this.map_ = null, this.listenerKeys = [], t.render && (this.render = t.render), t.target && this.setTarget(t.target);
12909  }
12910  /**
12911   * Clean up.
12912   */
12913  disposeInternal() {
12914    Nl(this.element), super.disposeInternal();
12915  }
12916  /**
12917   * Get the map associated with this control.
12918   * @return {import("../Map.js").default|null} Map.
12919   * @api
12920   */
12921  getMap() {
12922    return this.map_;
12923  }
12924  /**
12925   * Remove the control from its current map and attach it to the new map.
12926   * Pass `null` to just remove the control from the current map.
12927   * Subclasses may set up event handlers to get notified about changes to
12928   * the map here.
12929   * @param {import("../Map.js").default|null} map Map.
12930   * @api
12931   */
12932  setMap(t) {
12933    this.map_ && Nl(this.element);
12934    for (let i = 0, n = this.listenerKeys.length; i < n; ++i)
12935      St(this.listenerKeys[i]);
12936    this.listenerKeys.length = 0, this.map_ = t, t && ((this.target_ ? this.target_ : t.getOverlayContainerStopEvent()).appendChild(this.element), this.render !== As && this.listenerKeys.push(
12937      ct(t, Gi.POSTRENDER, this.render, this)
12938    ), t.render());
12939  }
12940  /**
12941   * Renders the control.
12942   * @param {import("../MapEvent.js").default} mapEvent Map event.
12943   * @api
12944   */
12945  render(t) {
12946  }
12947  /**
12948   * This function is used to set a target element for the control. It has no
12949   * effect if it is called after the control has been added to the map (i.e.
12950   * after `setMap` is called on the control). If no `target` is set in the
12951   * options passed to the control constructor and if `setTarget` is not called
12952   * then the control is added to the map's overlay container.
12953   * @param {HTMLElement|string} target Target.
12954   * @api
12955   */
12956  setTarget(t) {
12957    this.target_ = typeof t == "string" ? document.getElementById(t) : t;
12958  }
12959}
12960const Zh = rM;
12961class oM extends Zh {
12962  /**
12963   * @param {Options} [options] Attribution options.
12964   */
12965  constructor(t) {
12966    t = t || {}, super({
12967      element: document.createElement("div"),
12968      render: t.render,
12969      target: t.target
12970    }), this.ulElement_ = document.createElement("ul"), this.collapsed_ = t.collapsed !== void 0 ? t.collapsed : !0, this.userCollapsed_ = this.collapsed_, this.overrideCollapsible_ = t.collapsible !== void 0, this.collapsible_ = t.collapsible !== void 0 ? t.collapsible : !0, this.collapsible_ || (this.collapsed_ = !1);
12971    const i = t.className !== void 0 ? t.className : "ol-attribution", n = t.tipLabel !== void 0 ? t.tipLabel : "Attributions", s = t.expandClassName !== void 0 ? t.expandClassName : i + "-expand", r = t.collapseLabel !== void 0 ? t.collapseLabel : "›", o = t.collapseClassName !== void 0 ? t.collapseClassName : i + "-collapse";
12972    typeof r == "string" ? (this.collapseLabel_ = document.createElement("span"), this.collapseLabel_.textContent = r, this.collapseLabel_.className = o) : this.collapseLabel_ = r;
12973    const a = t.label !== void 0 ? t.label : "i";
12974    typeof a == "string" ? (this.label_ = document.createElement("span"), this.label_.textContent = a, this.label_.className = s) : this.label_ = a;
12975    const l = this.collapsible_ && !this.collapsed_ ? this.collapseLabel_ : this.label_;
12976    this.toggleButton_ = document.createElement("button"), this.toggleButton_.setAttribute("type", "button"), this.toggleButton_.setAttribute("aria-expanded", String(!this.collapsed_)), this.toggleButton_.title = n, this.toggleButton_.appendChild(l), this.toggleButton_.addEventListener(
12977      et.CLICK,
12978      this.handleClick_.bind(this),
12979      !1
12980    );
12981    const h = i + " " + wa + " " + qh + (this.collapsed_ && this.collapsible_ ? " " + Xu : "") + (this.collapsible_ ? "" : " ol-uncollapsible"), c = this.element;
12982    c.className = h, c.appendChild(this.toggleButton_), c.appendChild(this.ulElement_), this.renderedAttributions_ = [], this.renderedVisible_ = !0;
12983  }
12984  /**
12985   * Collect a list of visible attributions and set the collapsible state.
12986   * @param {import("../Map.js").FrameState} frameState Frame state.
12987   * @return {Array<string>} Attributions.
12988   * @private
12989   */
12990  collectSourceAttributions_(t) {
12991    const i = Array.from(
12992      new Set(
12993        this.getMap().getAllLayers().flatMap((s) => s.getAttributions(t))
12994      )
12995    ), n = !this.getMap().getAllLayers().some(
12996      (s) => s.getSource() && s.getSource().getAttributionsCollapsible() === !1
12997    );
12998    return this.overrideCollapsible_ || this.setCollapsible(n), i;
12999  }
13000  /**
13001   * @private
13002   * @param {?import("../Map.js").FrameState} frameState Frame state.
13003   */
13004  updateElement_(t) {
13005    if (!t) {
13006      this.renderedVisible_ && (this.element.style.display = "none", this.renderedVisible_ = !1);
13007      return;
13008    }
13009    const i = this.collectSourceAttributions_(t), n = i.length > 0;
13010    if (this.renderedVisible_ != n && (this.element.style.display = n ? "" : "none", this.renderedVisible_ = n), !Pi(i, this.renderedAttributions_)) {
13011      WC(this.ulElement_);
13012      for (let s = 0, r = i.length; s < r; ++s) {
13013        const o = document.createElement("li");
13014        o.innerHTML = i[s], this.ulElement_.appendChild(o);
13015      }
13016      this.renderedAttributions_ = i;
13017    }
13018  }
13019  /**
13020   * @param {MouseEvent} event The event to handle
13021   * @private
13022   */
13023  handleClick_(t) {
13024    t.preventDefault(), this.handleToggle_(), this.userCollapsed_ = this.collapsed_;
13025  }
13026  /**
13027   * @private
13028   */
13029  handleToggle_() {
13030    this.element.classList.toggle(Xu), this.collapsed_ ? Yu(this.collapseLabel_, this.label_) : Yu(this.label_, this.collapseLabel_), this.collapsed_ = !this.collapsed_, this.toggleButton_.setAttribute("aria-expanded", String(!this.collapsed_));
13031  }
13032  /**
13033   * Return `true` if the attribution is collapsible, `false` otherwise.
13034   * @return {boolean} True if the widget is collapsible.
13035   * @api
13036   */
13037  getCollapsible() {
13038    return this.collapsible_;
13039  }
13040  /**
13041   * Set whether the attribution should be collapsible.
13042   * @param {boolean} collapsible True if the widget is collapsible.
13043   * @api
13044   */
13045  setCollapsible(t) {
13046    this.collapsible_ !== t && (this.collapsible_ = t, this.element.classList.toggle("ol-uncollapsible"), this.userCollapsed_ && this.handleToggle_());
13047  }
13048  /**
13049   * Collapse or expand the attribution according to the passed parameter. Will
13050   * not do anything if the attribution isn't collapsible or if the current
13051   * collapsed state is already the one requested.
13052   * @param {boolean} collapsed True if the widget is collapsed.
13053   * @api
13054   */
13055  setCollapsed(t) {
13056    this.userCollapsed_ = t, !(!this.collapsible_ || this.collapsed_ === t) && this.handleToggle_();
13057  }
13058  /**
13059   * Return `true` when the attribution is currently collapsed or `false`
13060   * otherwise.
13061   * @return {boolean} True if the widget is collapsed.
13062   * @api
13063   */
13064  getCollapsed() {
13065    return this.collapsed_;
13066  }
13067  /**
13068   * Update the attribution element.
13069   * @param {import("../MapEvent.js").default} mapEvent Map event.
13070   * @override
13071   */
13072  render(t) {
13073    this.updateElement_(t.frameState);
13074  }
13075}
13076const aM = oM;
13077class lM extends Zh {
13078  /**
13079   * @param {Options} [options] Rotate options.
13080   */
13081  constructor(t) {
13082    t = t || {}, super({
13083      element: document.createElement("div"),
13084      render: t.render,
13085      target: t.target
13086    });
13087    const i = t.className !== void 0 ? t.className : "ol-rotate", n = t.label !== void 0 ? t.label : "⇧", s = t.compassClassName !== void 0 ? t.compassClassName : "ol-compass";
13088    this.label_ = null, typeof n == "string" ? (this.label_ = document.createElement("span"), this.label_.className = s, this.label_.textContent = n) : (this.label_ = n, this.label_.classList.add(s));
13089    const r = t.tipLabel ? t.tipLabel : "Reset rotation", o = document.createElement("button");
13090    o.className = i + "-reset", o.setAttribute("type", "button"), o.title = r, o.appendChild(this.label_), o.addEventListener(
13091      et.CLICK,
13092      this.handleClick_.bind(this),
13093      !1
13094    );
13095    const a = i + " " + wa + " " + qh, l = this.element;
13096    l.className = a, l.appendChild(o), this.callResetNorth_ = t.resetNorth ? t.resetNorth : void 0, this.duration_ = t.duration !== void 0 ? t.duration : 250, this.autoHide_ = t.autoHide !== void 0 ? t.autoHide : !0, this.rotation_ = void 0, this.autoHide_ && this.element.classList.add(ro);
13097  }
13098  /**
13099   * @param {MouseEvent} event The event to handle
13100   * @private
13101   */
13102  handleClick_(t) {
13103    t.preventDefault(), this.callResetNorth_ !== void 0 ? this.callResetNorth_() : this.resetNorth_();
13104  }
13105  /**
13106   * @private
13107   */
13108  resetNorth_() {
13109    const i = this.getMap().getView();
13110    if (!i)
13111      return;
13112    const n = i.getRotation();
13113    n !== void 0 && (this.duration_ > 0 && n % (2 * Math.PI) !== 0 ? i.animate({
13114      rotation: 0,
13115      duration: this.duration_,
13116      easing: js
13117    }) : i.setRotation(0));
13118  }
13119  /**
13120   * Update the rotate control element.
13121   * @param {import("../MapEvent.js").default} mapEvent Map event.
13122   * @override
13123   */
13124  render(t) {
13125    const i = t.frameState;
13126    if (!i)
13127      return;
13128    const n = i.viewState.rotation;
13129    if (n != this.rotation_) {
13130      const s = "rotate(" + n + "rad)";
13131      if (this.autoHide_) {
13132        const r = this.element.classList.contains(ro);
13133        !r && n === 0 ? this.element.classList.add(ro) : r && n !== 0 && this.element.classList.remove(ro);
13134      }
13135      this.label_.style.transform = s;
13136    }
13137    this.rotation_ = n;
13138  }
13139}
13140const hM = lM;
13141class cM extends Zh {
13142  /**
13143   * @param {Options} [options] Zoom options.
13144   */
13145  constructor(t) {
13146    t = t || {}, super({
13147      element: document.createElement("div"),
13148      target: t.target
13149    });
13150    const i = t.className !== void 0 ? t.className : "ol-zoom", n = t.delta !== void 0 ? t.delta : 1, s = t.zoomInClassName !== void 0 ? t.zoomInClassName : i + "-in", r = t.zoomOutClassName !== void 0 ? t.zoomOutClassName : i + "-out", o = t.zoomInLabel !== void 0 ? t.zoomInLabel : "+", a = t.zoomOutLabel !== void 0 ? t.zoomOutLabel : "–", l = t.zoomInTipLabel !== void 0 ? t.zoomInTipLabel : "Zoom in", h = t.zoomOutTipLabel !== void 0 ? t.zoomOutTipLabel : "Zoom out", c = document.createElement("button");
13151    c.className = s, c.setAttribute("type", "button"), c.title = l, c.appendChild(
13152      typeof o == "string" ? document.createTextNode(o) : o
13153    ), c.addEventListener(
13154      et.CLICK,
13155      this.handleClick_.bind(this, n),
13156      !1
13157    );
13158    const u = document.createElement("button");
13159    u.className = r, u.setAttribute("type", "button"), u.title = h, u.appendChild(
13160      typeof a == "string" ? document.createTextNode(a) : a
13161    ), u.addEventListener(
13162      et.CLICK,
13163      this.handleClick_.bind(this, -n),
13164      !1
13165    );
13166    const d = i + " " + wa + " " + qh, f = this.element;
13167    f.className = d, f.appendChild(c), f.appendChild(u), this.duration_ = t.duration !== void 0 ? t.duration : 250;
13168  }
13169  /**
13170   * @param {number} delta Zoom delta.
13171   * @param {MouseEvent} event The event to handle
13172   * @private
13173   */
13174  handleClick_(t, i) {
13175    i.preventDefault(), this.zoomByDelta_(t);
13176  }
13177  /**
13178   * @param {number} delta Zoom delta.
13179   * @private
13180   */
13181  zoomByDelta_(t) {
13182    const n = this.getMap().getView();
13183    if (!n)
13184      return;
13185    const s = n.getZoom();
13186    if (s !== void 0) {
13187      const r = n.getConstrainedZoom(s + t);
13188      this.duration_ > 0 ? (n.getAnimating() && n.cancelAnimations(), n.animate({
13189        zoom: r,
13190        duration: this.duration_,
13191        easing: js
13192      })) : n.setZoom(r);
13193    }
13194  }
13195}
13196const uM = cM;
13197function dM(e) {
13198  e = e || {};
13199  const t = new De();
13200  return (e.zoom !== void 0 ? e.zoom : !0) && t.push(new uM(e.zoomOptions)), (e.rotate !== void 0 ? e.rotate : !0) && t.push(new hM(e.rotateOptions)), (e.attribution !== void 0 ? e.attribution : !0) && t.push(new aM(e.attributionOptions)), t;
13201}
13202const Wl = {
13203  ACTIVE: "active"
13204};
13205class fM extends Qe {
13206  /**
13207   * @param {InteractionOptions} [options] Options.
13208   */
13209  constructor(t) {
13210    super(), this.on, this.once, this.un, t && t.handleEvent && (this.handleEvent = t.handleEvent), this.map_ = null, this.setActive(!0);
13211  }
13212  /**
13213   * Return whether the interaction is currently active.
13214   * @return {boolean} `true` if the interaction is active, `false` otherwise.
13215   * @observable
13216   * @api
13217   */
13218  getActive() {
13219    return (
13220      /** @type {boolean} */
13221      this.get(Wl.ACTIVE)
13222    );
13223  }
13224  /**
13225   * Get the map associated with this interaction.
13226   * @return {import("../Map.js").default|null} Map.
13227   * @api
13228   */
13229  getMap() {
13230    return this.map_;
13231  }
13232  /**
13233   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event}.
13234   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
13235   * @return {boolean} `false` to stop event propagation.
13236   * @api
13237   */
13238  handleEvent(t) {
13239    return !0;
13240  }
13241  /**
13242   * Activate or deactivate the interaction.
13243   * @param {boolean} active Active.
13244   * @observable
13245   * @api
13246   */
13247  setActive(t) {
13248    this.set(Wl.ACTIVE, t);
13249  }
13250  /**
13251   * Remove the interaction from its current map and attach it to the new map.
13252   * Subclasses may set up event handlers to get notified about changes to
13253   * the map here.
13254   * @param {import("../Map.js").default|null} map Map.
13255   */
13256  setMap(t) {
13257    this.map_ = t;
13258  }
13259}
13260function gM(e, t, i) {
13261  const n = e.getCenterInternal();
13262  if (n) {
13263    const s = [n[0] + t[0], n[1] + t[1]];
13264    e.animateInternal({
13265      duration: i !== void 0 ? i : 250,
13266      easing: oC,
13267      center: e.getConstrainedCenter(s)
13268    });
13269  }
13270}
13271function Jh(e, t, i, n) {
13272  const s = e.getZoom();
13273  if (s === void 0)
13274    return;
13275  const r = e.getConstrainedZoom(s + t), o = e.getResolutionForZoom(r);
13276  e.getAnimating() && e.cancelAnimations(), e.animate({
13277    resolution: o,
13278    anchor: i,
13279    duration: n !== void 0 ? n : 250,
13280    easing: js
13281  });
13282}
13283const Wr = fM;
13284class mM extends Wr {
13285  /**
13286   * @param {Options} [options] Options.
13287   */
13288  constructor(t) {
13289    super(), t = t || {}, this.delta_ = t.delta ? t.delta : 1, this.duration_ = t.duration !== void 0 ? t.duration : 250;
13290  }
13291  /**
13292   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} (if it was a
13293   * doubleclick) and eventually zooms the map.
13294   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
13295   * @return {boolean} `false` to stop event propagation.
13296   */
13297  handleEvent(t) {
13298    let i = !1;
13299    if (t.type == mt.DBLCLICK) {
13300      const n = (
13301        /** @type {MouseEvent} */
13302        t.originalEvent
13303      ), s = t.map, r = t.coordinate, o = n.shiftKey ? -this.delta_ : this.delta_, a = s.getView();
13304      Jh(a, o, r, this.duration_), n.preventDefault(), i = !0;
13305    }
13306    return !i;
13307  }
13308}
13309const Pg = mM;
13310class _M extends Wr {
13311  /**
13312   * @param {Options} [options] Options.
13313   */
13314  constructor(t) {
13315    t = t || {}, super(
13316      /** @type {import("./Interaction.js").InteractionOptions} */
13317      t
13318    ), t.handleDownEvent && (this.handleDownEvent = t.handleDownEvent), t.handleDragEvent && (this.handleDragEvent = t.handleDragEvent), t.handleMoveEvent && (this.handleMoveEvent = t.handleMoveEvent), t.handleUpEvent && (this.handleUpEvent = t.handleUpEvent), t.stopDown && (this.stopDown = t.stopDown), this.handlingDownUpSequence = !1, this.targetPointers = [];
13319  }
13320  /**
13321   * Returns the current number of pointers involved in the interaction,
13322   * e.g. `2` when two fingers are used.
13323   * @return {number} The number of pointers.
13324   * @api
13325   */
13326  getPointerCount() {
13327    return this.targetPointers.length;
13328  }
13329  /**
13330   * Handle pointer down events.
13331   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13332   * @return {boolean} If the event was consumed.
13333   * @protected
13334   */
13335  handleDownEvent(t) {
13336    return !1;
13337  }
13338  /**
13339   * Handle pointer drag events.
13340   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13341   * @protected
13342   */
13343  handleDragEvent(t) {
13344  }
13345  /**
13346   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may call into
13347   * other functions, if event sequences like e.g. 'drag' or 'down-up' etc. are
13348   * detected.
13349   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
13350   * @return {boolean} `false` to stop event propagation.
13351   * @api
13352   */
13353  handleEvent(t) {
13354    if (!t.originalEvent)
13355      return !0;
13356    let i = !1;
13357    if (this.updateTrackedPointers_(t), this.handlingDownUpSequence) {
13358      if (t.type == mt.POINTERDRAG)
13359        this.handleDragEvent(t), t.originalEvent.preventDefault();
13360      else if (t.type == mt.POINTERUP) {
13361        const n = this.handleUpEvent(t);
13362        this.handlingDownUpSequence = n && this.targetPointers.length > 0;
13363      }
13364    } else if (t.type == mt.POINTERDOWN) {
13365      const n = this.handleDownEvent(t);
13366      this.handlingDownUpSequence = n, i = this.stopDown(n);
13367    } else
13368      t.type == mt.POINTERMOVE && this.handleMoveEvent(t);
13369    return !i;
13370  }
13371  /**
13372   * Handle pointer move events.
13373   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13374   * @protected
13375   */
13376  handleMoveEvent(t) {
13377  }
13378  /**
13379   * Handle pointer up events.
13380   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13381   * @return {boolean} If the event was consumed.
13382   * @protected
13383   */
13384  handleUpEvent(t) {
13385    return !1;
13386  }
13387  /**
13388   * This function is used to determine if "down" events should be propagated
13389   * to other interactions or should be stopped.
13390   * @param {boolean} handled Was the event handled by the interaction?
13391   * @return {boolean} Should the `down` event be stopped?
13392   */
13393  stopDown(t) {
13394    return t;
13395  }
13396  /**
13397   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13398   * @private
13399   */
13400  updateTrackedPointers_(t) {
13401    t.activePointers && (this.targetPointers = t.activePointers);
13402  }
13403}
13404function Qh(e) {
13405  const t = e.length;
13406  let i = 0, n = 0;
13407  for (let s = 0; s < t; s++)
13408    i += e[s].clientX, n += e[s].clientY;
13409  return { clientX: i / t, clientY: n / t };
13410}
13411const ln = _M;
13412function Bl(e) {
13413  const t = arguments;
13414  return function(i) {
13415    let n = !0;
13416    for (let s = 0, r = t.length; s < r && (n = n && t[s](i), !!n); ++s)
13417      ;
13418    return n;
13419  };
13420}
13421const pM = function(e) {
13422  const t = (
13423    /** @type {KeyboardEvent|MouseEvent|TouchEvent} */
13424    e.originalEvent
13425  );
13426  return t.altKey && !(t.metaKey || t.ctrlKey) && !t.shiftKey;
13427}, yM = function(e) {
13428  const t = (
13429    /** @type {KeyboardEvent|MouseEvent|TouchEvent} */
13430    e.originalEvent
13431  );
13432  return t.altKey && !(t.metaKey || t.ctrlKey) && t.shiftKey;
13433}, xM = function(e) {
13434  const t = e.map.getTargetElement(), i = e.map.getOwnerDocument().activeElement;
13435  return t.contains(i);
13436}, Lg = function(e) {
13437  return e.map.getTargetElement().hasAttribute("tabindex") ? xM(e) : !0;
13438}, qo = An, Ag = function(e) {
13439  const t = (
13440    /** @type {MouseEvent} */
13441    e.originalEvent
13442  );
13443  return t.button == 0 && !(zE && jE && t.ctrlKey);
13444}, vM = Gn, EM = function(e) {
13445  return e.type == mt.SINGLECLICK;
13446}, tc = function(e) {
13447  const t = (
13448    /** @type {KeyboardEvent|MouseEvent|TouchEvent} */
13449    e.originalEvent
13450  );
13451  return !t.altKey && !(t.metaKey || t.ctrlKey) && !t.shiftKey;
13452}, Og = function(e) {
13453  const t = (
13454    /** @type {KeyboardEvent|MouseEvent|TouchEvent} */
13455    e.originalEvent
13456  );
13457  return !t.altKey && !(t.metaKey || t.ctrlKey) && t.shiftKey;
13458}, Fg = function(e) {
13459  const t = (
13460    /** @type {KeyboardEvent|MouseEvent|TouchEvent} */
13461    e.originalEvent
13462  ), i = (
13463    /** @type {Element} */
13464    t.target.tagName
13465  );
13466  return i !== "INPUT" && i !== "SELECT" && i !== "TEXTAREA" && // `isContentEditable` is only available on `HTMLElement`, but it may al
13466so be a
13467  // different type like `SVGElement`.
13468  // @ts-ignore
13469  !t.target.isContentEditable;
13470}, Ka = function(e) {
13471  const t = (
13472    /** @type {import("../MapBrowserEvent").default} */
13473    e.originalEvent
13474  );
13475  return ht(t !== void 0, 56), t.pointerType == "mouse";
13476}, kg = function(e) {
13477  const t = (
13478    /** @type {import("../MapBrowserEvent").default} */
13479    e.originalEvent
13480  );
13481  return ht(t !== void 0, 56), t.isPrimary && t.button === 0;
13482};
13483class CM extends ln {
13484  /**
13485   * @param {Options} [options] Options.
13486   */
13487  constructor(t) {
13488    super({
13489      stopDown: Gn
13490    }), t = t || {}, this.kinetic_ = t.kinetic, this.lastCentroid = null, this.lastPointersCount_, this.panning_ = !1;
13491    const i = t.condition ? t.condition : Bl(tc, kg);
13492    this.condition_ = t.onFocusOnly ? Bl(Lg, i) : i, this.noKinetic_ = !1;
13493  }
13494  /**
13495   * Handle pointer drag events.
13496   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13497   */
13498  handleDragEvent(t) {
13499    const i = t.map;
13500    this.panning_ || (this.panning_ = !0, i.getView().beginInteraction());
13501    const n = this.targetPointers, s = i.getEventPixel(Qh(n));
13502    if (n.length == this.lastPointersCount_) {
13503      if (this.kinetic_ && this.kinetic_.update(s[0], s[1]), this.lastCentroid) {
13504        const r = [
13505          this.lastCentroid[0] - s[0],
13506          s[1] - this.lastCentroid[1]
13507        ], a = t.map.getView();
13508        Ox(r, a.getResolution()), ah(r, a.getRotation()), a.adjustCenterInternal(r);
13509      }
13510    } else
13511      this.kinetic_ && this.kinetic_.begin();
13512    this.lastCentroid = s, this.lastPointersCount_ = n.length, t.originalEvent.preventDefault();
13513  }
13514  /**
13515   * Handle pointer up events.
13516   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13517   * @return {boolean} If the event was consumed.
13518   */
13519  handleUpEvent(t) {
13520    const i = t.map, n = i.getView();
13521    if (this.targetPointers.length === 0) {
13522      if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
13523        const s = this.kinetic_.getDistance(), r = this.kinetic_.getAngle(), o = n.getCenterInternal(), a = i.getPixelFromCoordinateInternal(o), l = i.getCoordinateFromPixelInternal([
13524          a[0] - s * Math.cos(r),
13525          a[1] - s * Math.sin(r)
13526        ]);
13527        n.animateInternal({
13528          center: n.getConstrainedCenter(l),
13529          duration: 500,
13530          easing: js
13531        });
13532      }
13533      return this.panning_ && (this.panning_ = !1, n.endInteraction()), !1;
13534    }
13535    return this.kinetic_ && this.kinetic_.begin(), this.lastCentroid = null, !0;
13536  }
13537  /**
13538   * Handle pointer down events.
13539   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13540   * @return {boolean} If the event was consumed.
13541   */
13542  handleDownEvent(t) {
13543    if (this.targetPointers.length > 0 && this.condition_(t)) {
13544      const n = t.map.getView();
13545      return this.lastCentroid = null, n.getAnimating() && n.cancelAnimations(), this.kinetic_ && this.kinetic_.begin(), this.noKinetic_ = this.targetPointers.length > 1, !0;
13546    }
13547    return !1;
13548  }
13549}
13550const MM = CM;
13551class bM extends ln {
13552  /**
13553   * @param {Options} [options] Options.
13554   */
13555  constructor(t) {
13556    t = t || {}, super({
13557      stopDown: Gn
13558    }), this.condition_ = t.condition ? t.condition : yM, this.lastAngle_ = void 0, this.duration_ = t.duration !== void 0 ? t.duration : 250;
13559  }
13560  /**
13561   * Handle pointer drag events.
13562   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13563   */
13564  handleDragEvent(t) {
13565    if (!Ka(t))
13566      return;
13567    const i = t.map, n = i.getView();
13568    if (n.getConstraints().rotation === Gh)
13569      return;
13570    const s = i.getSize(), r = t.pixel, o = Math.atan2(s[1] / 2 - r[1], r[0] - s[0] / 2);
13571    if (this.lastAngle_ !== void 0) {
13572      const a = o - this.lastAngle_;
13573      n.adjustRotationInternal(-a);
13574    }
13575    this.lastAngle_ = o;
13576  }
13577  /**
13578   * Handle pointer up events.
13579   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13580   * @return {boolean} If the event was consumed.
13581   */
13582  handleUpEvent(t) {
13583    return Ka(t) ? (t.map.getView().endInteraction(this.duration_), !1) : !0;
13584  }
13585  /**
13586   * Handle pointer down events.
13587   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13588   * @return {boolean} If the event was consumed.
13589   */
13590  handleDownEvent(t) {
13591    return Ka(t) && Ag(t) && this.condition_(t) ? (t.map.getView().beginInteraction(), this.lastAngle_ = void 0, !0) : !1;
13592  }
13593}
13594const wM = bM;
13595class SM extends Ah {
13596  /**
13597   * @param {string} className CSS class name.
13598   */
13599  constructor(t) {
13600    super(), this.geometry_ = null, this.element_ = document.createElement("div"), this.element_.style.position = "absolute", this.element_.style.pointerEvents = "auto", this.element_.className = "ol-box " + t, this.map_ = null, this.startPixel_ = null, this.endPixel_ = null;
13601  }
13602  /**
13603   * Clean up.
13604   */
13605  disposeInternal() {
13606    this.setMap(null);
13607  }
13608  /**
13609   * @private
13610   */
13611  render_() {
13612    const t = this.startPixel_, i = this.endPixel_, n = "px", s = this.element_.style;
13613    s.left = Math.min(t[0], i[0]) + n, s.top = Math.min(t[1], i[1]) + n, s.width = Math.abs(i[0] - t[0]) + n, s.height = Math.abs(i[1] - t[1]) + n;
13614  }
13615  /**
13616   * @param {import("../Map.js").default|null} map Map.
13617   */
13618  setMap(t) {
13619    if (this.map_) {
13620      this.map_.getOverlayContainer().removeChild(this.element_);
13621      const i = this.element_.style;
13622      i.left = "inherit", i.top = "inherit", i.width = "inherit", i.height = "
13622inherit";
13623    }
13624    this.map_ = t, this.map_ && this.map_.getOverlayContainer().appendChild(this.element_);
13625  }
13626  /**
13627   * @param {import("../pixel.js").Pixel} startPixel Start pixel.
13628   * @param {import("../pixel.js").Pixel} endPixel End pixel.
13629   */
13630  setPixels(t, i) {
13631    this.startPixel_ = t, this.endPixel_ = i, this.createOrUpdateGeometry(), this.render_();
13632  }
13633  /**
13634   * Creates or updates the cached geometry.
13635   */
13636  createOrUpdateGeometry() {
13637    const t = this.startPixel_, i = this.endPixel_, s = [
13638      t,
13639      [t[0], i[1]],
13640      i,
13641      [i[0], t[1]]
13642    ].map(
13643      this.map_.getCoordinateFromPixelInternal,
13644      this.map_
13645    );
13646    s[4] = s[0].slice(), this.geometry_ ? this.geometry_.setCoordinates([s]) : this.geometry_ = new Fn([s]);
13647  }
13648  /**
13649   * @return {import("../geom/Polygon.js").default} Geometry.
13650   */
13651  getGeometry() {
13652    return this.geometry_;
13653  }
13654}
13655const TM = SM, oo = {
13656  /**
13657   * Triggered upon drag box start.
13658   * @event DragBoxEvent#boxstart
13659   * @api
13660   */
13661  BOXSTART: "boxstart",
13662  /**
13663   * Triggered on drag when box is active.
13664   * @event DragBoxEvent#boxdrag
13665   * @api
13666   */
13667  BOXDRAG: "boxdrag",
13668  /**
13669   * Triggered upon drag box end.
13670   * @event DragBoxEvent#boxend
13671   * @api
13672   */
13673  BOXEND: "boxend",
13674  /**
13675   * Triggered upon drag box canceled.
13676   * @event DragBoxEvent#boxcancel
13677   * @api
13678   */
13679  BOXCANCEL: "boxcancel"
13680};
13681class Va extends Le {
13682  /**
13683   * @param {string} type The event type.
13684   * @param {import("../coordinate.js").Coordinate} coordinate The event coordinate.
13685   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Originating event.
13686   */
13687  constructor(t, i, n) {
13688    super(t), this.coordinate = i, this.mapBrowserEvent = n;
13689  }
13690}
13691class IM extends ln {
13692  /**
13693   * @param {Options} [options] Options.
13694   */
13695  constructor(t) {
13696    super(), this.on, this.once, this.un, t = t || {}, this.box_ = new TM(t.className || "ol-dragbox"), this.minArea_ = t.minArea !== void 0 ? t.minArea : 64, t.onBoxEnd && (this.onBoxEnd = t.onBoxEnd), this.startPixel_ = null, this.condition_ = t.condition ? t.condition : Ag, this.boxEndCondition_ = t.boxEndCondition ? t.boxEndCondition : this.defaultBoxEndCondition;
13697  }
13698  /**
13699   * The default condition for determining whether the boxend event
13700   * should fire.
13701   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent The originating MapBrowserEvent
13702   *     leading to the box end.
13703   * @param {import("../pixel.js").Pixel} startPixel The starting pixel of the box.
13704   * @param {import("../pixel.js").Pixel} endPixel The end pixel of the box.
13705   * @return {boolean} Whether or not the boxend condition should be fired.
13706   */
13707  defaultBoxEndCondition(t, i, n) {
13708    const s = n[0] - i[0], r = n[1] - i[1];
13709    return s * s + r * r >= this.minArea_;
13710  }
13711  /**
13712   * Returns geometry of last drawn box.
13713   * @return {import("../geom/Polygon.js").default} Geometry.
13714   * @api
13715   */
13716  getGeometry() {
13717    return this.box_.getGeometry();
13718  }
13719  /**
13720   * Handle pointer drag events.
13721   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13722   */
13723  handleDragEvent(t) {
13724    this.box_.setPixels(this.startPixel_, t.pixel), this.dispatchEvent(
13725      new Va(
13726        oo.BOXDRAG,
13727        t.coordinate,
13728        t
13729      )
13730    );
13731  }
13732  /**
13733   * Handle pointer up events.
13734   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13735   * @return {boolean} If the event was consumed.
13736   */
13737  handleUpEvent(t) {
13738    this.box_.setMap(null);
13739    const i = this.boxEndCondition_(
13740      t,
13741      this.startPixel_,
13742      t.pixel
13743    );
13744    return i && this.onBoxEnd(t), this.dispatchEvent(
13745      new Va(
13746        i ? oo.BOXEND : oo.BOXCANCEL,
13747        t.coordinate,
13748        t
13749      )
13750    ), !1;
13751  }
13752  /**
13753   * Handle pointer down events.
13754   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
13755   * @return {boolean} If the event was consumed.
13756   */
13757  handleDownEvent(t) {
13758    return this.condition_(t) ? (this.startPixel_ = t.pixel, this.box_.setMap(t.map), this.box_.setPixels(this.startPixel_, this.startPixel_), this.dispatchEvent(
13759      new Va(
13760        oo.BOXSTART,
13761        t.coordinate,
13762        t
13763      )
13764    ), !0) : !1;
13765  }
13766  /**
13767   * Function to execute just before `onboxend` is fired
13768   * @param {import("../MapBrowserEvent.js").default} event Event.
13769   */
13770  onBoxEnd(t) {
13771  }
13772}
13773const RM = IM;
13774class PM extends RM {
13775  /**
13776   * @param {Options} [options] Options.
13777   */
13778  constructor(t) {
13779    t = t || {};
13780    const i = t.condition ? t.condition : Og;
13781    super({
13782      condition: i,
13783      className: t.className || "ol-dragzoom",
13784      minArea: t.minArea
13785    }), this.duration_ = t.duration !== void 0 ? t.duration : 200, this.out_ = t.out !== void 0 ? t.out : !1;
13786  }
13787  /**
13788   * Function to execute just before `onboxend` is fired
13789   * @param {import("../MapBrowserEvent.js").default} event Event.
13790   */
13791  onBoxEnd(t) {
13792    const n = (
13793      /** @type {!import("../View.js").default} */
13794      this.getMap().getView()
13795    );
13796    let s = this.getGeometry();
13797    if (this.out_) {
13798      const r = n.rotatedExtentForGeometry(s), o = n.getResolutionForExtentInternal(r), a = n.getResolution() / o;
13799      s = s.clone(), s.scale(a * a);
13800    }
13801    n.fitInternal(s, {
13802      duration: this.duration_,
13803      easing: js
13804    });
13805  }
13806}
13807const LM = PM, gn = {
13808  LEFT: "ArrowLeft",
13809  UP: "ArrowUp",
13810  RIGHT: "ArrowRight",
13811  DOWN: "ArrowDown"
13812};
13813class AM extends Wr {
13814  /**
13815   * @param {Options} [options] Options.
13816   */
13817  constructor(t) {
13818    super(), t = t || {}, this.defaultCondition_ = function(i) {
13819      return tc(i) && Fg(i);
13820    }, this.condition_ = t.condition !== void 0 ? t.condition : this.defaultCondition_, this.duration_ = t.duration !== void 0 ? t.duration : 100, this.pixelDelta_ = t.pixelDelta !== void 0 ? t.pixelDelta : 128;
13821  }
13822  /**
13823   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} if it was a
13824   * `KeyEvent`, and decides the direction to pan to (if an arrow key was
13825   * pressed).
13826   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
13827   * @return {boolean} `false` to stop event propagation.
13828   */
13829  handleEvent(t) {
13830    let i = !1;
13831    if (t.type == et.KEYDOWN) {
13832      const n = (
13833        /** @type {KeyboardEvent} */
13834        t.originalEvent
13835      ), s = n.key;
13836      if (this.condition_(t) && (s == gn.DOWN || s == gn.LEFT || s == gn.RIGHT || s == gn.UP)) {
13837        const o = t.map.getView(), a = o.getResolution() * this.pixelDelta_;
13838        let l = 0, h = 0;
13839        s == gn.DOWN ? h = -a : s == gn.LEFT ? l = -a : s == gn.RIGHT ? l = a : h = a;
13840        const c = [l, h];
13841        ah(c, o.getRotation()), gM(o, c, this.duration_), n.preventDefault(), i = !0;
13842      }
13843    }
13844    return !i;
13845  }
13846}
13847const OM = AM;
13848class FM extends Wr {
13849  /**
13850   * @param {Options} [options] Options.
13851   */
13852  constructor(t) {
13853    super(), t = t || {}, this.condition_ = t.condition ? t.condition : Fg, this.delta_ = t.delta ? t.delta : 1, this.duration_ = t.duration !== void 0 ? t.duration : 100;
13854  }
13855  /**
13856   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} if it was a
13857   * `KeyEvent`, and decides whether to zoom in or out (depending on whether the
13858   * key pressed was '+' or '-').
13859   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
13860   * @return {boolean} `false` to stop event propagation.
13861   */
13862  handleEvent(t) {
13863    let i = !1;
13864    if (t.type == et.KEYDOWN || t.type == et.KEYPRESS) {
13865      const n = (
13866        /** @type {KeyboardEvent} */
13867        t.originalEvent
13868      ), s = n.key;
13869      if (this.condition_(t) && (s === "+" || s === "-")) {
13870        const r = t.map, o = s === "+" ? this.delta_ : -this.delta_, a = r.getView();
13871        Jh(a, o, void 0, this.duration_), n.preventDefault(), i = !0;
13872      }
13873    }
13874    return !i;
13875  }
13876}
13877const kM = FM;
13878class DM {
13879  /**
13880   * @param {number} decay Rate of decay (must be negative).
13881   * @param {number} minVelocity Minimum velocity (pixels/millisecond).
13882   * @param {number} delay Delay to consider to calculate the kinetic
13883   *     initial values (milliseconds).
13884   */
13885  constructor(t, i, n) {
13886    this.decay_ = t, this.minVelocity_ = i, this.delay_ = n, this.points_ = [], this.angle_ = 0, this.initialVelocity_ = 0;
13887  }
13888  /**
13889   * FIXME empty description for jsdoc
13890   */
13891  begin() {
13892    this.points_.length = 0, this.angle_ = 0, this.initialVelocity_ = 0;
13893  }
13894  /**
13895   * @param {number} x X.
13896   * @param {number} y Y.
13897   */
13898  update(t, i) {
13899    this.points_.push(t, i, Date.now());
13900  }
13901  /**
13902   * @return {boolean} Whether we should do kinetic animation.
13903   */
13904  end() {
13905    if (this.points_.length < 6)
13906      return !1;
13907    const t = Date.now() - this.delay_, i = this.points_.length - 3;
13908    if (this.points_[i + 2] < t)
13909      return !1;
13910    let n = i - 3;
13911    for (; n > 0 && this.points_[n + 2] > t; )
13912      n -= 3;
13913    const s = this.points_[i + 2] - this.points_[n + 2];
13914    if (s < 1e3 / 60)
13915      return !1;
13916    const r = this.points_[i] - this.points_[n], o = this.points_[i + 1] - this.points_[n + 1];
13917    return this.angle_ = Math.atan2(o, r), this.initialVelocity_ = Math.sqrt(r * r + o * o) / s, this.initialVelocity_ > this.minVelocity_;
13918  }
13919  /**
13920   * @return {number} Total distance travelled (pixels).
13921   */
13922  getDistance() {
13923    return (this.minVelocity_ - this.initialVelocity_) / this.decay_;
13924  }
13925  /**
13926   * @return {number} Angle of the kinetic panning animation (radians).
13927   */
13928  getAngle() {
13929    return this.angle_;
13930  }
13931}
13932const NM = DM;
13933class GM extends Wr {
13934  /**
13935   * @param {Options} [options] Options.
13936   */
13937  constructor(t) {
13938    t = t || {}, super(
13939      /** @type {import("./Interaction.js").InteractionOptions} */
13940      t
13941    ), this.totalDelta_ = 0, this.lastDelta_ = 0, this.maxDelta_ = t.maxDelta !== void 0 ? t.maxDelta : 1, this.duration_ = t.duration !== void 0 ? t.duration : 250, this.timeout_ = t.timeout !== void 0 ? t.timeout : 80, this.useAnchor_ = t.useAnchor !== void 0 ? t.useAnchor : !0, this.constrainResolution_ = t.constrainResolution !== void 0 ? t.constrainResolution : !1;
13942    const i = t.condition ? t.condition : qo;
13943    this.condition_ = t.onFocusOnly ? Bl(Lg, i) : i, this.lastAnchor_ = null, this.startTime_ = void 0, this.timeoutId_, this.mode_ = void 0, this.trackpadEventGap_ = 400, this.trackpadTimeoutId_, this.deltaPerZoom_ = 300;
13944  }
13945  /**
13946   * @private
13947   */
13948  endInteraction_() {
13949    this.trackpadTimeoutId_ = void 0;
13950    const t = this.getMap();
13951    if (!t)
13952      return;
13953    t.getView().endInteraction(
13954      void 0,
13955      this.lastDelta_ ? this.lastDelta_ > 0 ? 1 : -1 : 0,
13956      this.lastAnchor_
13957    );
13958  }
13959  /**
13960   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} (if it was a mousewheel-event) and eventually
13961   * zooms the map.
13962   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
13963   * @return {boolean} `false` to stop event propagation.
13964   */
13965  handleEvent(t) {
13966    if (!this.condition_(t) || t.type !== et.WHEEL)
13967      return !0;
13968    const n = t.map, s = (
13969      /** @type {WheelEvent} */
13970      t.originalEvent
13971    );
13972    s.preventDefault(), this.useAnchor_ && (this.lastAnchor_ = t.coordinate);
13973    let r;
13974    if (t.type == et.WHEEL && (r = s.deltaY, NE && s.deltaMode === WheelEvent.DOM_DELTA_PIXEL && (r /= hg), s.deltaMode === WheelEvent.DOM_DELTA_LINE && (r *= 40)), r === 0)
13975      return !1;
13976    this.lastDelta_ = r;
13977    const o = Date.now();
13978    this.startTime_ === void 0 && (this.startTime_ = o), (!this.mode_ || o - this.startTime_ > this.trackpadEventGap_) && (this.mode_ = Math.abs(r) < 4 ? "trackpad" : "wheel");
13979    const a = n.getView();
13980    if (this.mode_ === "trackpad" && !(a.getConstrainResolution() || this.constrainResolution_))
13981      return this.trackpadTimeoutId_ ? clearTimeout(this.trackpadTimeoutId_) : (a.getAnimating() && a.cancelAnimations(), a.beginInteraction()), this.trackpadTimeoutId_ = setTimeout(
13982        this.endInteraction_.bind(this),
13983        this.timeout_
13984      ), a.adjustZoom(-r / this.deltaPerZoom_, this.lastAnchor_), this.startTime_ = o, !1;
13985    this.totalDelta_ += r;
13986    const l = Math.max(this.timeout_ - (o - this.startTime_), 0);
13987    return clearTimeout(this.timeoutId_), this.timeoutId_ = setTimeout(
13988      this.handleWheelZoom_.bind(this, n),
13989      l
13990    ), !1;
13991  }
13992  /**
13993   * @private
13994   * @param {import("../Map.js").default} map Map.
13995   */
13996  handleWheelZoom_(t) {
13997    const i = t.getView();
13998    i.getAnimating() && i.cancelAnimations();
13999    let n = -kt(
14000      this.totalDelta_,
14001      -this.maxDelta_ * this.deltaPerZoom_,
14002      this.maxDelta_ * this.deltaPerZoom_
14003    ) / this.deltaPerZoom_;
14004    (i.getConstrainResolution() || this.constrainResolution_) && (n = n ? n > 0 ? 1 : -1 : 0), Jh(i, n, this.lastAnchor_, this.duration_), this.mode_ = void 0, this.totalDelta_ = 0, this.lastAnchor_ = null, this.startTime_ = void 0, this.timeoutId_ = void 0;
14005  }
14006  /**
14007   * Enable or disable using the mouse's location as an anchor when zooming
14008   * @param {boolean} useAnchor true to zoom to the mouse's location, false
14009   * to zoom to the center of the map
14010   * @api
14011   */
14012  setMouseAnchor(t) {
14013    this.useAnchor_ = t, t || (this.lastAnchor_ = null);
14014  }
14015}
14016const zM = GM;
14017class jM extends ln {
14018  /**
14019   * @param {Options} [options] Options.
14020   */
14021  constructor(t) {
14022    t = t || {};
14023    const i = (
14024      /** @type {import("./Pointer.js").Options} */
14025      t
14026    );
14027    i.stopDown || (i.stopDown = Gn), super(i), this.anchor_ = null, this.lastAngle_ = void 0, this.rotating_ = !1, this.rotationDelta_ = 0, this.threshold_ = t.threshold !== void 0 ? t.threshold : 0.3, this.duration_ = t.duration !== void 0 ? t.duration : 250;
14028  }
14029  /**
14030   * Handle pointer drag events.
14031   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
14032   */
14033  handleDragEvent(t) {
14034    let i = 0;
14035    const n = this.targetPointers[0], s = this.targetPointers[1], r = Math.atan2(
14036      s.clientY - n.clientY,
14037      s.clientX - n.clientX
14038    );
14039    if (this.lastAngle_ !== void 0) {
14040      const l = r - this.lastAngle_;
14041      this.rotationDelta_ += l, !this.rotating_ && Math.abs(this.rotationDelta_) > this.threshold_ && (this.rotating_ = !0), i = l;
14042    }
14043    this.lastAngle_ = r;
14044    const o = t.map, a = o.getView();
14045    a.getConstraints().rotation !== Gh && (this.anchor_ = o.getCoordinateFromPixelInternal(
14046      o.getEventPixel(Qh(this.targetPointers))
14047    ), this.rotating_ && (o.render(), a.adjustRotationInternal(i, this.anchor_)));
14048  }
14049  /**
14050   * Handle pointer up events.
14051   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
14052   * @return {boolean} If the event was consumed.
14053   */
14054  handleUpEvent(t) {
14055    return this.targetPointers.length < 2 ? (t.map.getView().endInteraction(this.duration_), !1) : !0;
14056  }
14057  /**
14058   * Handle pointer down events.
14059   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
14060   * @return {boolean} If the event was consumed.
14061   */
14062  handleDownEvent(t) {
14063    if (this.targetPointers.length >= 2) {
14064      const i = t.map;
14065      return this.anchor_ = null, this.lastAngle_ = void 0, this.rotating_ = !1, this.rotationDelta_ = 0, this.handlingDownUpSequence || i.getView().beginInteraction(), !0;
14066    }
14067    return !1;
14068  }
14069}
14070const WM = jM;
14071class BM extends ln {
14072  /**
14073   * @param {Options} [options] Options.
14074   */
14075  constructor(t) {
14076    t = t || {};
14077    const i = (
14078      /** @type {import("./Pointer.js").Options} */
14079      t
14080    );
14081    i.stopDown || (i.stopDown = Gn), super(i), this.anchor_ = null, this.duration_ = t.duration !== void 0 ? t.duration : 400, this.lastDistance_ = void 0, this.lastScaleDelta_ = 1;
14082  }
14083  /**
14084   * Handle pointer drag events.
14085   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
14086   */
14087  handleDragEvent(t) {
14088    let i = 1;
14089    const n = this.targetPointers[0], s = this.targetPointers[1], r = n.clientX - s.clientX, o = n.clientY - s.clientY, a = Math.sqrt(r * r + o * o);
14090    this.lastDistance_ !== void 0 && (i = this.lastDistance_ / a), this.lastDistance_ = a;
14091    const l = t.map, h = l.getView();
14092    i != 1 && (this.lastScaleDelta_ = i), this.anchor_ = l.getCoordinateFromPixelInternal(
14093      l.getEventPixel(Qh(this.targetPointers))
14094    ), l.render(), h.adjustResolutionInternal(i, this.anchor_);
14095  }
14096  /**
14097   * Handle pointer up events.
14098   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
14099   * @return {boolean} If the event was consumed.
14100   */
14101  handleUpEvent(t) {
14102    if (this.targetPointers.length < 2) {
14103      const n = t.map.getView(), s = this.lastScaleDelta_ > 1 ? 1 : -1;
14104      return n.endInteraction(this.duration_, s), !1;
14105    }
14106    return !0;
14107  }
14108  /**
14109   * Handle pointer down events.
14110   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Event.
14111   * @return {boolean} If the event was consumed.
14112   */
14113  handleDownEvent(t) {
14114    if (this.targetPointers.length >= 2) {
14115      const i = t.map;
14116      return this.anchor_ = null, this.lastDistance_ = void 0, this.lastScaleDelta_ = 1, this.handlingDownUpSequence || i.getView().beginInteraction(), !0;
14117    }
14118    return !1;
14119  }
14120}
14121const UM = BM;
14122function XM(e) {
14123  e = e || {};
14124  const t = new De(), i = new NM(-5e-3, 0.05, 100);
14125  return (e.altShiftDragRotate !== void 0 ? e.altShiftDragRotate : !0) && t.push(new wM()), (e.doubleClickZoom !== void 0 ? e.doubleClickZoom : !0) && t.push(
14126    new Pg({
14127      delta: e.zoomDelta,
14128      duration: e.zoomDuration
14129    })
14130  ), (e.dragPan !== void 0 ? e.dragPan : !0) && t.push(
14131    new MM({
14132      onFocusOnly: e.onFocusOnly,
14133      kinetic: i
14134    })
14135  ), (e.pinchRotate !== void 0 ? e.pinchRotate : !0) && t.push(new WM()), (e.pinchZoom !== void 0 ? e.pinchZoom : !0) && t.push(
14136    new UM({
14137      duration: e.zoomDuration
14138    })
14139  ), (e.keyboard !== void 0 ? e.keyboard : !0) && (t.push(new OM()), t.push(
14140    new kM({
14141      delta: e.zoomDelta,
14142      duration: e.zoomDuration
14143    })
14144  )), (e.mouseWheelZoom !== void 0 ? e.mouseWheelZoom : !0) && t.push(
14145    new zM({
14146      onFocusOnly: e.onFocusOnly,
14147      duration: e.zoomDuration
14148    })
14149  ), (e.shiftDragZoom !== void 0 ? e.shiftDragZoom : !0) && t.push(
14150    new LM({
14151      duration: e.zoomDuration
14152    })
14153  ), t;
14154}
14155function Vu(e, t, i) {
14156  return i === void 0 && (i = [0, 0]), i[0] = e[0] + 2 * t, i[1] = e[1] + 2 * t, i;
14157}
14158function qu(e) {
14159  return e[0] > 0 && e[1] > 0;
14160}
14161function Dg(e, t, i) {
14162  return i === void 0 && (i = [0, 0]), i[0] = e[0] * t + 0.5 | 0, i[1] = e[1] * t + 0.5 | 0, i;
14163}
14164function Ce(e, t) {
14165  return Array.isArray(e) ? e : (t === void 0 ? t = [e, e] : (t[0] = e, t[1] = e), t);
14166}
14167function Ng(e) {
14168  if (e instanceof jr) {
14169    e.setMapInternal(null);
14170    return;
14171  }
14172  e instanceof Ta && e.getLayers().forEach(Ng);
14173}
14174function Gg(e, t) {
14175  if (e instanceof jr) {
14176    e.setMapInternal(t);
14177    return;
14178  }
14179  if (e instanceof Ta) {
14180    const i = e.getLayers().getArray();
14181    for (let n = 0, s = i.length; n < s; ++n)
14182      Gg(i[n], t);
14183  }
14184}
14185let $M = class extends Qe {
14186  /**
14187   * @param {MapOptions} [options] Map options.
14188   */
14189  constructor(t) {
14190    super(), t = t || {}, this.on, this.once, this.un;
14191    const i = YM(t);
14192    this.renderComplete_, this.loaded_ = !0, this.boundHandleBrowserEvent_ = this.handleBrowserEvent.bind(this), this.maxTilesLoading_ = t.maxTilesLoading !== void 0 ? t.maxTilesLoading : 16, this.pixelRatio_ = t.pixelRatio !== void 0 ? t.pixelRatio : hg, this.postRenderTimeoutHandle_, this.animationDelayKey_, this.animationDelay_ = this.animationDelay_.bind(this), this.coordinateToPixelTransform_ = ui(), this.pixelToCoordinateTransform_ = ui(), this.frameIndex_ = 0, this.frameState_ = null, this.previousExtent_ = null, this.viewPropertyListenerKey_ = null, this.viewChangeListenerKey_ = null, this.layerGroupPropertyListenerKeys_ = null, this.viewport_ = document.createElement("div"), this.viewport_.className = "ol-viewport" + ("ontouchstart" in window ? " ol-touch" : ""), this.viewport_.style.position = "relative", this.viewport_.style.overflow = "hidden", this.viewport_.style.width = "100%", this.viewport_.style.height = "100%", this.overlayContainer_ = document.createElement("div"), this.overlayContainer_.style.position = "absolute", this.overlayContainer_.style.zIndex = "0", this.overlayContainer_.style.width = "100%", this.overlayContainer_.style.height = "100%", this.overlayContainer_.style.pointerEvents = "none", this.overlayContainer_.className = "ol-overlaycontainer", this.viewport_.appendChild(this.overlayContainer_), this.overlayContainerStopEvent_ = document.createElement("div"), this.overlayContainerStopEvent_.style.position = "absolute", this.overlayContainerStopEvent_.style.zIndex = "0", this.overlayContainerStopEvent_.style.width = "100%", this.overlayContainerStopEvent_.style.height = "100%", this.overlayContainerStopEvent_.style.pointerEvents = "none", this.overlayContainerStopEvent_.className = "ol-overlaycontainer-stopevent", this.viewport_.appendChild(this.overlayContainerStopEvent_), this.mapBrowserEventHandler_ = null, this.moveTolerance_ = t.moveTolerance, this.keyboardEventTarget_ = i.keyboardEventTarget, this.targetChangeHandlerKeys_ = null, this.targetElement_ = null, this.resizeObserver_ = new ResizeObserver(() => this.updateSize()), this.controls = i.controls || dM(), this.interactions = i.interactions || XM({
14193      onFocusOnly: !0
14194    }), this.overlays_ = i.overlays, this.overlayIdIndex_ = {}, this.renderer_ = null, this.postRenderFunctions_ = [], this.tileQueue_ = new nM(
14195      this.getTilePriority.bind(this),
14196      this.handleTileChange_.bind(this)
14197    ), this.addChangeListener(
14198      ie.LAYERGROUP,
14199      this.handleLayerGroupChanged_
14200    ), this.addChangeListener(ie.VIEW, this.handleViewChanged_), this.addChangeListener(ie.SIZE, this.handleSizeChanged_), this.addChangeListener(ie.TARGET, this.handleTargetChanged_), this.setProperties(i.values);
14201    const n = this;
14202    t.view && !(t.view instanceof ri) && t.view.then(function(s) {
14203      n.setView(new ri(s));
14204    }), this.controls.addEventListener(
14205      Vt.ADD,
14206      /**
14207       * @param {import("./Collection.js").CollectionEvent<import("./control/Control.js").default>} event CollectionEvent
14208       */
14209      (s) => {
14210        s.element.setMap(this);
14211      }
14212    ), this.controls.addEventListener(
14213      Vt.REMOVE,
14214      /**
14215       * @param {import("./Collection.js").CollectionEvent<import("./control/Control.js").default>} event CollectionEvent.
14216       */
14217      (s) => {
14218        s.element.setMap(null);
14219      }
14220    ), this.interactions.addEventListener(
14221      Vt.ADD,
14222      /**
14223       * @param {import("./Collection.js").CollectionEvent<import("./interaction/Interaction.js").default>} event CollectionEvent.
14224       */
14225      (s) => {
14226        s.element.setMap(this);
14227      }
14228    ), this.interactions.addEventListener(
14229      Vt.REMOVE,
14230      /**
14231       * @param {import("./Collection.js").CollectionEvent<import("./interaction/Interaction.js").default>} event CollectionEvent.
14232       */
14233      (s) => {
14234        s.element.setMap(null);
14235      }
14236    ), this.overlays_.addEventListener(
14237      Vt.ADD,
14238      /**
14239       * @param {import("./Collection.js").CollectionEvent<import("./Overlay.js").default>} event CollectionEvent.
14240       */
14241      (s) => {
14242        this.addOverlayInternal_(s.element);
14243      }
14244    ), this.overlays_.addEventListener(
14245      Vt.REMOVE,
14246      /**
14247       * @param {import("./Collection.js").CollectionEvent<import("./Overlay.js").default>} event CollectionEvent.
14248       */
14249      (s) => {
14250        const r = s.element.getId();
14251        r !== void 0 && delete this.overlayIdIndex_[r.toString()], s.element.setMap(null);
14252      }
14253    ), this.controls.forEach(
14254      /**
14255       * @param {import("./control/Control.js").default} control Control.
14256       */
14257      (s) => {
14258        s.setMap(this);
14259      }
14260    ), this.interactions.forEach(
14261      /**
14262       * @param {import("./interaction/Interaction.js").default} interaction Interaction.
14263       */
14264      (s) => {
14265        s.setMap(this);
14266      }
14267    ), this.overlays_.forEach(this.addOverlayInternal_.bind(this));
14268  }
14269  /**
14270   * Add the given control to the map.
14271   * @param {import("./control/Control.js").default} control Control.
14272   * @api
14273   */
14274  addControl(t) {
14275    this.getControls().push(t);
14276  }
14277  /**
14278   * Add the given interaction to the map. If you want to add an interaction
14279   * at another point of the collection use `getInteractions()` and the methods
14280   * available on {@link module:ol/Collection~Collection}. This can be used to
14281   * stop the event propagation from the handleEvent function. The interactions
14282   * get to handle the events in the reverse order of this collection.
14283   * @param {import("./interaction/Interaction.js").default} interaction Interaction to add.
14284   * @api
14285   */
14286  addInteraction(t) {
14287    this.getInteractions().push(t);
14288  }
14289  /**
14290   * Adds the given layer to the top of this map. If you want to add a layer
14291   * elsewhere in the stack, use `getLayers()` and the methods available on
14292   * {@link module:ol/Collection~Collection}.
14293   * @param {import("./layer/Base.js").default} layer Layer.
14294   * @api
14295   */
14296  addLayer(t) {
14297    this.getLayerGroup().getLayers().push(t);
14298  }
14299  /**
14300   * @param {import("./layer/Group.js").GroupEvent} event The layer add event.
14301   * @private
14302   */
14303  handleLayerAdd_(t) {
14304    Gg(t.layer, this);
14305  }
14306  /**
14307   * Add the given overlay to the map.
14308   * @param {import("./Overlay.js").default} overlay Overlay.
14309   * @api
14310   */
14311  addOverlay(t) {
14312    this.getOverlays().push(t);
14313  }
14314  /**
14315   * This deals with map's overlay collection changes.
14316   * @param {import("./Overlay.js").default} overlay Overlay.
14317   * @private
14318   */
14319  addOverlayInternal_(t) {
14320    const i = t.getId();
14321    i !== void 0 && (this.overlayIdIndex_[i.toString()] = t), t.setMap(this);
14322  }
14323  /**
14324   *
14325   * Clean up.
14326   */
14327  disposeInternal() {
14328    this.controls.clear(), this.interactions.clear(), this.overlays_.clear(), this.resizeObserver_.disconnect(), this.setTarget(null), super.disposeInternal();
14329  }
14330  /**
14331   * Detect features that intersect a pixel on the viewport, and execute a
14332   * callback with each intersecting feature. Layers included in the detection can
14333   * be configured through the `layerFilter` option in `options`.
14334   * @param {import("./pixel.js").Pixel} pixel Pixel.
14335   * @param {function(import("./Feature.js").FeatureLike, import("./layer/Layer.js").default<import("./source/Source").default>, import("./geom/SimpleGeometry.js").default): T} callback Feature callback. The callback will be
14336   *     called with two arguments. The first argument is one
14337   *     {@link module:ol/Feature~Feature feature} or
14338   *     {@link module:ol/render/Feature~RenderFeature render feature} at the pixel, the second is
14339   *     the {@link module:ol/layer/Layer~Layer layer} of the feature and will be null for
14340   *     unmanaged layers. To stop detection, callback functions can return a
14341   *     truthy value.
14342   * @param {AtPixelOptions} [options] Optional options.
14343   * @return {T|undefined} Callback result, i.e. the return value of last
14344   * callback execution, or the first truthy callback return value.
14345   * @template T
14346   * @api
14347   */
14348  forEachFeatureAtPixel(t, i, n) {
14349    if (!this.frameState_ || !this.renderer_)
14350      return;
14351    const s = this.getCoordinateFromPixelInternal(t);
14352    n = n !== void 0 ? n : {};
14353    const r = n.hitTolerance !== void 0 ? n.hitTolerance : 0, o = n.layerFilter !== void 0 ? n.layerFilter : An, a = n.checkWrapped !== !1;
14354    return this.renderer_.forEachFeatureAtCoordinate(
14355      s,
14356      this.frameState_,
14357      r,
14358      a,
14359      i,
14360      null,
14361      o,
14362      null
14363    );
14364  }
14365  /**
14366   * Get all features that intersect a pixel on the viewport.
14367   * @param {import("./pixel.js").Pixel} pixel Pixel.
14368   * @param {AtPixelOptions} [options] Optional options.
14369   * @return {Array<import("./Feature.js").FeatureLike>} The detected features or
14370   * an empty array if none were found.
14371   * @api
14372   */
14373  getFeaturesAtPixel(t, i) {
14374    const n = [];
14375    return this.forEachFeatureAtPixel(
14376      t,
14377      function(s) {
14378        n.push(s);
14379      },
14380      i
14381    ), n;
14382  }
14383  /**
14384   * Get all layers from all layer groups.
14385   * @return {Array<import("./layer/Layer.js").default>} Layers.
14386   * @api
14387   */
14388  getAllLayers() {
14389    const t = [];
14390    function i(n) {
14391      n.forEach(function(s) {
14392        s instanceof Ta ? i(s.getLayers()) : t.push(s);
14393      });
14394    }
14395    return i(this.getLayers()), t;
14396  }
14397  /**
14398   * Detect if features intersect a pixel on the viewport. Layers included in the
14399   * detection can be configured through the `layerFilter` option.
14400   * @param {import("./pixel.js").Pixel} pixel Pixel.
14401   * @param {AtPixelOptions} [options] Optional options.
14402   * @return {boolean} Is there a feature at the given pixel?
14403   * @api
14404   */
14405  hasFeatureAtPixel(t, i) {
14406    if (!this.frameState_ || !this.renderer_)
14407      return !1;
14408    const n = this.getCoordinateFromPixelInternal(t);
14409    i = i !== void 0 ? i : {};
14410    const s = i.layerFilter !== void 0 ? i.layerFilter : An, r = i.hitTolerance !== void 0 ? i.hitTolerance : 0, o = i.checkWrapped !== !1;
14411    return this.renderer_.hasFeatureAtCoordinate(
14412      n,
14413      this.frameState_,
14414      r,
14415      o,
14416      s,
14417      null
14418    );
14419  }
14420  /**
14421   * Returns the coordinate in user projection for a browser event.
14422   * @param {MouseEvent} event Event.
14423   * @return {import("./coordinate.js").Coordinate} Coordinate.
14424   * @api
14425   */
14426  getEventCoordinate(t) {
14427    return this.getCoordinateFromPixel(this.getEventPixel(t));
14428  }
14429  /**
14430   * Returns the coordinate in view projection for a browser event.
14431   * @param {MouseEvent} event Event.
14432   * @return {import("./coordinate.js").Coordinate} Coordinate.
14433   */
14434  getEventCoordinateInternal(t) {
14435    return this.getCoordinateFromPixelInternal(this.getEventPixel(t));
14436  }
14437  /**
14438   * Returns the map pixel position for a browser event relative to the viewport.
14439   * @param {UIEvent|{clientX: number, clientY: number}} event Event.
14440   * @return {import("./pixel.js").Pixel} Pixel.
14441   * @api
14442   */
14443  getEventPixel(t) {
14444    const n = this.viewport_.getBoundingClientRect(), s = this.getSize(), r = n.width / s[0], o = n.height / s[1], a = (
14445      //FIXME Are we really calling this with a TouchEvent anywhere?
14446      "changedTouches" in t ? (
14447        /** @type {TouchEvent} */
14448        t.changedTouches[0]
14449      ) : (
14450        /** @type {MouseEvent} */
14451        t
14452      )
14453    );
14454    return [
14455      (a.clientX - n.left) / r,
14456      (a.clientY - n.top) / o
14457    ];
14458  }
14459  /**
14460   * Get the target in which this map is rendered.
14461   * Note that this returns what is entered as an option or in setTarget:
14462   * if that was an element, it returns an element; if a string, it returns that.
14463   * @return {HTMLElement|string|undefined} The Element or id of the Element that the
14464   *     map is rendered in.
14465   * @observable
14466   * @api
14467   */
14468  getTarget() {
14469    return (
14470      /** @type {HTMLElement|string|undefined} */
14471      this.get(ie.TARGET)
14472    );
14473  }
14474  /**
14475   * Get the DOM element into which this map is rendered. In contrast to
14476   * `getTarget` this method always return an `Element`, or `null` if the
14477   * map has no target.
14478   * @return {HTMLElement} The element that the map is rendered in.
14479   * @api
14480   */
14481  getTargetElement() {
14482    return this.targetElement_;
14483  }
14484  /**
14485   * Get the coordinate for a given pixel.  This returns a coordinate in the
14486   * user projection.
14487   * @param {import("./pixel.js").Pixel} pixel Pixel position in the map viewport.
14488   * @return {import("./coordinate.js").Coordinate} The coordinate for the pixel position.
14489   * @api
14490   */
14491  getCoordinateFromPixel(t) {
14492    return Pn(
14493      this.getCoordinateFromPixelInternal(t),
14494      this.getView().getProjection()
14495    );
14496  }
14497  /**
14498   * Get the coordinate for a given pixel.  This returns a coordinate in the
14499   * map view projection.
14500   * @param {import("./pixel.js").Pixel} pixel Pixel position in the map viewport.
14501   * @return {import("./coordinate.js").Coordinate} The coordinate for the pixel position.
14502   */
14503  getCoordinateFromPixelInternal(t) {
14504    const i = this.frameState_;
14505    return i ? Bt(i.pixelToCoordinateTransform, t.slice()) : null;
14506  }
14507  /**
14508   * Get the map controls. Modifying this collection changes the controls
14509   * associated with the map.
14510   * @return {Collection<import("./control/Control.js").default>} Controls.
14511   * @api
14512   */
14513  getControls() {
14514    return this.controls;
14515  }
14516  /**
14517   * Get the map overlays. Modifying this collection changes the overlays
14518   * associated with the map.
14519   * @return {Collection<import("./Overlay.js").default>} Overlays.
14520   * @api
14521   */
14522  getOverlays() {
14523    return this.overlays_;
14524  }
14525  /**
14526   * Get an overlay by its identifier (the value returned by overlay.getId()).
14527   * Note that the index treats string and numeric identifiers as the same. So
14528   * `map.getOverlayById(2)` will return an overlay with id `'2'` or `2`.
14529   * @param {string|number} id Overlay identifier.
14530   * @return {import("./Overlay.js").default} Overlay.
14531   * @api
14532   */
14533  getOverlayById(t) {
14534    const i = this.overlayIdIndex_[t.toString()];
14535    return i !== void 0 ? i : null;
14536  }
14537  /**
14538   * Get the map interactions. Modifying this collection changes the interactions
14539   * associated with the map.
14540   *
14541   * Interactions are used for e.g. pan, zoom and rotate.
14542   * @return {Collection<import("./interaction/Interaction.js").default>} Interactions.
14543   * @api
14544   */
14545  getInteractions() {
14546    return this.interactions;
14547  }
14548  /**
14549   * Get the layergroup associated with this map.
14550   * @return {LayerGroup} A layer group containing the layers in this map.
14551   * @observable
14552   * @api
14553   */
14554  getLayerGroup() {
14555    return (
14556      /** @type {LayerGroup} */
14557      this.get(ie.LAYERGROUP)
14558    );
14559  }
14560  /**
14561   * Clear any existing layers and add layers to the map.
14562   * @param {Array<import("./layer/Base.js").default>|Collection<import("./layer/Base.js").default>} layers The layers to be added to the map.
14563   * @api
14564   */
14565  setLayers(t) {
14566    const i = this.getLayerGroup();
14567    if (t instanceof De) {
14568      i.setLayers(t);
14569      return;
14570    }
14571    const n = i.getLayers();
14572    n.clear(), n.extend(t);
14573  }
14574  /**
14575   * Get the collection of layers associated with this map.
14576   * @return {!Collection<import("./layer/Base.js").default>} Layers.
14577   * @api
14578   */
14579  getLayers() {
14580    return this.getLayerGroup().getLayers();
14581  }
14582  /**
14583   * @return {boolean} Layers have sources that are still loading.
14584   */
14585  getLoadingOrNotReady() {
14586    const t = this.getLayerGroup().getLayerStatesArray();
14587    for (let i = 0, n = t.length; i < n; ++i) {
14588      const s = t[i];
14589      if (!s.visible)
14590        continue;
14591      const r = s.layer.getRenderer();
14592      if (r && !r.ready)
14593        return !0;
14594      const o = s.layer.getSource();
14595      if (o && o.loading)
14596        return !0;
14597    }
14598    return !1;
14599  }
14600  /**
14601   * Get the pixel for a coordinate.  This takes a coordinate in the user
14602   * projection and returns the corresponding pixel.
14603   * @param {import("./coordinate.js").Coordinate} coordinate A map coordinate.
14604   * @return {import("./pixel.js").Pixel} A pixel position in the map viewport.
14605   * @api
14606   */
14607  getPixelFromCoordinate(t) {
14608    const i = Lt(
14609      t,
14610      this.getView().getProjection()
14611    );
14612    return this.getPixelFromCoordinateInternal(i);
14613  }
14614  /**
14615   * Get the pixel for a coordinate.  This takes a coordinate in the map view
14616   * projection and returns the corresponding pixel.
14617   * @param {import("./coordinate.js").Coordinate} coordinate A map coordinate.
14618   * @return {import("./pixel.js").Pixel} A pixel position in the map viewport.
14619   */
14620  getPixelFromCoordinateInternal(t) {
14621    const i = this.frameState_;
14622    return i ? Bt(
14623      i.coordinateToPixelTransform,
14624      t.slice(0, 2)
14625    ) : null;
14626  }
14627  /**
14628   * Get the map renderer.
14629   * @return {import("./renderer/Map.js").default|null} Renderer
14630   */
14631  getRenderer() {
14632    return this.renderer_;
14633  }
14634  /**
14635   * Get the size of this map.
14636   * @return {import("./size.js").Size|undefined} The size in pixels of the map in the DOM.
14637   * @observable
14638   * @api
14639   */
14640  getSize() {
14641    return (
14642      /** @type {import("./size.js").Size|undefined} */
14643      this.get(ie.SIZE)
14644    );
14645  }
14646  /**
14647   * Get the view associated with this map. A view manages properties such as
14648   * center and resolution.
14649   * @return {View} The view that controls this map.
14650   * @observable
14651   * @api
14652   */
14653  getView() {
14654    return (
14655      /** @type {View} */
14656      this.get(ie.VIEW)
14657    );
14658  }
14659  /**
14660   * Get the element that serves as the map viewport.
14661   * @return {HTMLElement} Viewport.
14662   * @api
14663   */
14664  getViewport() {
14665    return this.viewport_;
14666  }
14667  /**
14668   * Get the element that serves as the container for overlays.  Elements added to
14669   * this container will let mousedown and touchstart events through to the map,
14670   * so clicks and gestures on an overlay will trigger {@link module:ol/MapBrowserEvent~MapBrowserEvent}
14671   * events.
14672   * @return {!HTMLElement} The map's overlay container.
14673   */
14674  getOverlayContainer() {
14675    return this.overlayContainer_;
14676  }
14677  /**
14678   * Get the element that serves as a container for overlays that don't allow
14679   * event propagation. Elements added to this container won't let mousedown and
14680   * touchstart events through to the map, so clicks and gestures on an overlay
14681   * don't trigger any {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
14682   * @return {!HTMLElement} The map's overlay container that stops events.
14683   */
14684  getOverlayContainerStopEvent() {
14685    return this.overlayContainerStopEvent_;
14686  }
14687  /**
14688   * @return {!Document} The document where the map is displayed.
14689   */
14690  getOwnerDocument() {
14691    const t = this.getTargetElement();
14692    return t ? t.ownerDocument : document;
14693  }
14694  /**
14695   * @param {import("./Tile.js").default} tile Tile.
14696   * @param {string} tileSourceKey Tile source key.
14697   * @param {import("./coordinate.js").Coordinate} tileCenter Tile center.
14698   * @param {number} tileResolution Tile resolution.
14699   * @return {number} Tile priority.
14700   */
14701  getTilePriority(t, i, n, s) {
14702    return sM(
14703      this.frameState_,
14704      t,
14705      i,
14706      n,
14707      s
14708    );
14709  }
14710  /**
14711   * @param {UIEvent} browserEvent Browser event.
14712   * @param {string} [type] Type.
14713   */
14714  handleBrowserEvent(t, i) {
14715    i = i || t.type;
14716    const n = new Ei(i, this, t);
14717    this.handleMapBrowserEvent(n);
14718  }
14719  /**
14720   * @param {MapBrowserEvent} mapBrowserEvent The event to handle.
14721   */
14722  handleMapBrowserEvent(t) {
14723    if (!this.frameState_)
14724      return;
14725    const i = (
14726      /** @type {PointerEvent} */
14727      t.originalEvent
14728    ), n = i.type;
14729    if (n === jl.POINTERDOWN || n === et.WHEEL || n === et.KEYDOWN) {
14730      const s = this.getOwnerDocument(), r = this.viewport_.getRootNode ? this.viewport_.getRootNode() : s, o = (
14731        /** @type {Node} */
14732        i.target
14733      );
14734      if (
14735        // Abort if the target is a child of the container for elements whose events are not meant
14736        // to be handled by map interactions.
14737        this.overlayContainerStopEvent_.contains(o) || // Abort if the event target is a child of the container that is no longer in the page.
14738        // It's possible for the target to no longer be in the page if it has been removed in an
14739        // event listener, this might happen in a Control that recreates it's content based on
14740        // user interaction either manually or via a render in something like https://reactjs.org/
14741        !(r === s ? s.documentElement : r).contains(o)
14742      )
14743        return;
14744    }
14745    if (t.frameState = this.frameState_, this.dispatchEvent(t) !== !1) {
14746      const s = this.getInteractions().getArray().slice();
14747      for (let r = s.length - 1; r >= 0; r--) {
14748        const o = s[r];
14749        if (o.getMap() !== this || !o.getActive() || !this.getTargetElement())
14750          continue;
14751        if (!o.handleEvent(t) || t.propagationStopped)
14752          break;
14753      }
14754    }
14755  }
14756  /**
14757   * @protected
14758   */
14759  handlePostRender() {
14760    const t = this.frameState_, i = this.tileQueue_;
14761    if (!i.isEmpty()) {
14762      let s = this.maxTilesLoading_, r = s;
14763      if (t) {
14764        const o = t.viewHints;
14765        if (o[Kt.ANIMATING] || o[Kt.INTERACTING]) {
14766          const a = Date.now() - t.time > 8;
14767          s = a ? 0 : 8, r = a ? 0 : 2;
14768        }
14769      }
14770      i.getTilesLoading() < s && (i.reprioritize(), i.loadMoreTiles(s, r));
14771    }
14772    t && this.renderer_ && !t.animate && (this.renderComplete_ === !0 ? (this.hasListener(Ji.RENDERCOMPLETE) && this.renderer_.dispatchRenderEvent(
14773      Ji.RENDERCOMPLETE,
14774      t
14775    ), this.loaded_ === !1 && (this.loaded_ = !0, this.dispatchEvent(
14776      new Hn(Gi.LOADEND, this, t)
14777    ))) : this.loaded_ === !0 && (this.loaded_ = !1, this.dispatchEvent(
14778      new Hn(Gi.LOADSTART, this, t)
14779    )));
14780    const n = this.postRenderFunctions_;
14781    for (let s = 0, r = n.length; s < r; ++s)
14782      n[s](this, t);
14783    n.length = 0;
14784  }
14785  /**
14786   * @private
14787   */
14788  handleSizeChanged_() {
14789    this.getView() && !this.getView().getAnimating() && this.getView().resolveConstraints(0), this.render();
14790  }
14791  /**
14792   * @private
14793   */
14794  handleTargetChanged_() {
14795    if (this.mapBrowserEventHandler_) {
14796      for (let n = 0, s = this.targetChangeHandlerKeys_.length; n < s; ++n)
14797        St(this.targetChangeHandlerKeys_[n]);
14798      this.targetChangeHandlerKeys_ = null, this.viewport_.removeEventListener(
14799        et.CONTEXTMENU,
14800        this.boundHandleBrowserEvent_
14801      ), this.viewport_.removeEventListener(
14802        et.WHEEL,
14803        this.boundHandleBrowserEvent_
14804      ), this.mapBrowserEventHandler_.dispose(), this.mapBrowserEventHandler_ = null, Nl(this.viewport_);
14805    }
14806    if (this.targetElement_) {
14807      this.resizeObserver_.unobserve(this.targetElement_);
14808      const n = this.targetElement_.getRootNode();
14809      n instanceof ShadowRoot && this.resizeObserver_.unobserve(n.host), this.setSize(void 0);
14810    }
14811    const t = this.getTarget(), i = typeof t == "string" ? document.getElementById(t) : t;
14812    if (this.targetElement_ = i, !i)
14813      this.renderer_ && (clearTimeout(this.postRenderTimeoutHandle_), this.postRenderTimeoutHandle_ = void 0, this.postRenderFunctions_.length = 0, this.renderer_.dispose(), this.renderer_ = null), this.animationDelayKey_ && (cancelAnimationFrame(this.animationDelayKey_), this.animationDelayKey_ = void 0);
14814    else {
14815      i.appendChild(this.viewport_), this.renderer_ || (this.renderer_ = new qC(this)), this.mapBrowserEventHandler_ = new QC(
14816        this,
14817        this.moveTolerance_
14818      );
14819      for (const r in mt)
14820        this.mapBrowserEventHandler_.addEventListener(
14821          mt[r],
14822          this.handleMapBrowserEvent.bind(this)
14823        );
14824      this.viewport_.addEventListener(
14825        et.CONTEXTMENU,
14826        this.boundHandleBrowserEvent_,
14827        !1
14828      ), this.viewport_.addEventListener(
14829        et.WHEEL,
14830        this.boundHandleBrowserEvent_,
14831        cg ? { passive: !1 } : !1
14832      );
14833      const n = this.keyboardEventTarget_ ? this.keyboardEventTarget_ : i;
14834      this.targetChangeHandlerKeys_ = [
14835        ct(
14836          n,
14837          et.KEYDOWN,
14838          this.handleBrowserEvent,
14839          this
14840        ),
14841        ct(
14842          n,
14843          et.KEYPRESS,
14844          this.handleBrowserEvent,
14845          this
14846        )
14847      ];
14848      const s = i.getRootNode();
14849      s instanceof ShadowRoot && this.resizeObserver_.observe(s.host), this.resizeObserver_.observe(i);
14850    }
14851    this.updateSize();
14852  }
14853  /**
14854   * @private
14855   */
14856  handleTileChange_() {
14857    this.render();
14858  }
14859  /**
14860   * @private
14861   */
14862  handleViewPropertyChanged_() {
14863    this.render();
14864  }
14865  /**
14866   * @private
14867   */
14868  handleViewChanged_() {
14869    this.viewPropertyListenerKey_ && (St(this.viewPropertyListenerKey_), this.viewPropertyListenerKey_ = null), this.viewChangeListenerKey_ && (St(this.viewChangeListenerKey_), this.viewChangeListenerKey_ = null);
14870    const t = this.getView();
14871    t && (this.updateViewportSize_(), this.viewPropertyListenerKey_ = ct(
14872      t,
14873      Ls.PROPERTYCHANGE,
14874      this.handleViewPropertyChanged_,
14875      this
14876    ), this.viewChangeListenerKey_ = ct(
14877      t,
14878      et.CHANGE,
14879      this.handleViewPropertyChanged_,
14880      this
14881    ), t.resolveConstraints(0)), this.render();
14882  }
14883  /**
14884   * @private
14885   */
14886  handleLayerGroupChanged_() {
14887    this.layerGroupPropertyListenerKeys_ && (this.layerGroupPropertyListenerKeys_.forEach(St), this.layerGroupPropertyListenerKeys_ = null);
14888    const t = this.getLayerGroup();
14889    t && (this.handleLayerAdd_(new ji("addlayer", t)), this.layerGroupPropertyListenerKeys_ = [
14890      ct(t, Ls.PROPERTYCHANGE, this.render, this),
14891      ct(t, et.CHANGE, this.render, this),
14892      ct(t, "addlayer", this.handleLayerAdd_, this),
14893      ct(t, "removelayer", this.handleLayerRemove_, this)
14894    ]), this.render();
14895  }
14896  /**
14897   * @return {boolean} Is rendered.
14898   */
14899  isRendered() {
14900    return !!this.frameState_;
14901  }
14902  /**
14903   * @private
14904   */
14905  animationDelay_() {
14906    this.animationDelayKey_ = void 0, this.renderFrame_(Date.now());
14907  }
14908  /**
14909   * Requests an immediate render in a synchronous manner.
14910   * @api
14911   */
14912  renderSync() {
14913    this.animationDelayKey_ && cancelAnimationFrame(this.animationDelayKey_), this.animationDelay_();
14914  }
14915  /**
14916   * Redraws all text after new fonts have loaded
14917   */
14918  redrawText() {
14919    const t = this.getLayerGroup().getLayerStatesArray();
14920    for (let i = 0, n = t.length; i < n; ++i) {
14921      const s = t[i].layer;
14922      s.hasRenderer() && s.getRenderer().handleFontsChanged();
14923    }
14924  }
14925  /**
14926   * Request a map rendering (at the next animation frame).
14927   * @api
14928   */
14929  render() {
14930    this.renderer_ && this.animationDelayKey_ === void 0 && (this.animationDelayKey_ = requestAnimationFrame(this.animationDelay_));
14931  }
14932  /**
14933   * Remove the given control from the map.
14934   * @param {import("./control/Control.js").default} control Control.
14935   * @return {import("./control/Control.js").default|undefined} The removed control (or undefined
14936   *     if the control was not found).
14937   * @api
14938   */
14939  removeControl(t) {
14940    return this.getControls().remove(t);
14941  }
14942  /**
14943   * Remove the given interaction from the map.
14944   * @param {import("./interaction/Interaction.js").default} interaction Interaction to remove.
14945   * @return {import("./interaction/Interaction.js").default|undefined} The removed interaction (or
14946   *     undefined if the interaction was not found).
14947   * @api
14948   */
14949  removeInteraction(t) {
14950    return this.getInteractions().remove(t);
14951  }
14952  /**
14953   * Removes the given layer from the map.
14954   * @param {import("./layer/Base.js").default} layer Layer.
14955   * @return {import("./layer/Base.js").default|undefined} The removed layer (or undefined if the
14956   *     layer was not found).
14957   * @api
14958   */
14959  removeLayer(t) {
14960    return this.getLayerGroup().getLayers().remove(t);
14961  }
14962  /**
14963   * @param {import("./layer/Group.js").GroupEvent} event The layer remove event.
14964   * @private
14965   */
14966  handleLayerRemove_(t) {
14967    Ng(t.layer);
14968  }
14969  /**
14970   * Remove the given overlay from the map.
14971   * @param {import("./Overlay.js").default} overlay Overlay.
14972   * @return {import("./Overlay.js").default|undefined} The removed overlay (or undefined
14973   *     if the overlay was not found).
14974   * @api
14975   */
14976  removeOverlay(t) {
14977    return this.getOverlays().remove(t);
14978  }
14979  /**
14980   * @param {number} time Time.
14981   * @private
14982   */
14983  renderFrame_(t) {
14984    const i = this.getSize(), n = this.getView(), s = this.frameState_;
14985    let r = null;
14986    if (i !== void 0 && qu(i) && n && n.isDef()) {
14987      const o = n.getHints(
14988        this.frameState_ ? this.frameState_.viewHints : void 0
14989      ), a = n.getState();
14990      if (r = {
14991        animate: !1,
14992        coordinateToPixelTransform: this.coordinateToPixelTransform_,
14993        declutterTree: null,
14994        extent: us(
14995          a.center,
14996          a.resolution,
14997          a.rotation,
14998          i
14999        ),
15000        index: this.frameIndex_++,
15001        layerIndex: 0,
15002        layerStatesArray: this.getLayerGroup().getLayerStatesArray(),
15003        pixelRatio: this.pixelRatio_,
15004        pixelToCoordinateTransform: this.pixelToCoordinateTransform_,
15005        postRenderFunctions: [],
15006        size: i,
15007        tileQueue: this.tileQueue_,
15008        time: t,
15009        usedTiles: {},
15010        viewState: a,
15011        viewHints: o,
15012        wantedTiles: {},
15013        mapId: lt(this),
15014        renderTargets: {}
15015      }, a.nextCenter && a.nextResolution) {
15016        const l = isNaN(a.nextRotation) ? a.rotation : a.nextRotation;
15017        r.nextExtent = us(
15018          a.nextCenter,
15019          a.nextResolution,
15020          l,
15021          i
15022        );
15023      }
15024    }
15025    this.frameState_ = r, this.renderer_.renderFrame(r), r && (r.animate && this.render(), Array.prototype.push.apply(
15026      this.postRenderFunctions_,
15027      r.postRenderFunctions
15028    ), s && (!this.previousExtent_ || !Nn(this.previousExtent_) && !Ss(r.extent, this.previousExtent_)) && (this.dispatchEvent(
15029      new Hn(Gi.MOVESTART, this, s)
15030    ), this.previousExtent_ = Ns(this.previousExtent_)), this.previousExtent_ && !r.viewHints[Kt.ANIMATING] && !r.viewHints[Kt.INTERACTING] && !Ss(r.extent, this.previousExtent_) && (this.dispatchEvent(
15031      new Hn(Gi.MOVEEND, this, r)
15032    ), Qd(r.extent, this.previousExtent_))), this.dispatchEvent(new Hn(Gi.POSTRENDER, this, r)), this.renderComplete_ = this.hasListener(Gi.LOADSTART) || this.hasListener(Gi.LOADEND) || this.hasListener(Ji.RENDERCOMPLETE) ? !this.tileQueue_.getTilesLoading() && !this.tileQueue_.getCount() && !this.getLoadingOrNotReady() : void 0, this.postRenderTimeoutHandle_ || (this.postRenderTimeoutHandle_ = setTimeout(() => {
15033      this.postRenderTimeoutHandle_ = void 0, this.handlePostRender();
15034    }, 0));
15035  }
15036  /**
15037   * Sets the layergroup of this map.
15038   * @param {LayerGroup} layerGroup A layer group containing the layers in this map.
15039   * @observable
15040   * @api
15041   */
15042  setLayerGroup(t) {
15043    const i = this.getLayerGroup();
15044    i && this.handleLayerRemove_(new ji("removelayer", i)), this.set(ie.LAYERGROUP, t);
15045  }
15046  /**
15047   * Set the size of this map.
15048   * @param {import("./size.js").Size|undefined} size The size in pixels of the map in the DOM.
15049   * @observable
15050   * @api
15051   */
15052  setSize(t) {
15053    this.set(ie.SIZE, t);
15054  }
15055  /**
15056   * Set the target element to render this map into.
15057   * @param {HTMLElement|string} [target] The Element or id of the Element
15058   *     that the map is rendered in.
15059   * @observable
15060   * @api
15061   */
15062  setTarget(t) {
15063    this.set(ie.TARGET, t);
15064  }
15065  /**
15066   * Set the view for this map.
15067   * @param {View|Promise<import("./View.js").ViewOptions>} view The view that controls this map.
15068   * It is also possible to pass a promise that resolves to options for c
15068onstructing a view.  This
15069   * alternative allows view properties to be resolved by sources or other components that load
15070   * view-related metadata.
15071   * @observable
15072   * @api
15073   */
15074  setView(t) {
15075    if (!t || t instanceof ri) {
15076      this.set(ie.VIEW, t);
15077      return;
15078    }
15079    this.set(ie.VIEW, new ri());
15080    const i = this;
15081    t.then(function(n) {
15082      i.setView(new ri(n));
15083    });
15084  }
15085  /**
15086   * Force a recalculation of the map viewport size.  This should be called when
15087   * third-party code changes the size of the map viewport.
15088   * @api
15089   */
15090  updateSize() {
15091    const t = this.getTargetElement();
15092    let i;
15093    if (t) {
15094      const s = getComputedStyle(t), r = t.offsetWidth - parseFloat(s.borderLeftWidth) - parseFloat(s.paddingLeft) - parseFloat(s.paddingRight) - parseFloat(s.borderRightWidth), o = t.offsetHeight - parseFloat(s.borderTopWidth) - parseFloat(s.paddingTop) - parseFloat(s.paddingBottom) - parseFloat(s.borderBottomWidth);
15095      !isNaN(r) && !isNaN(o) && (i = [r, o], !qu(i) && (t.offsetWidth || t.offsetHeight || t.getClientRects().length) && cf(
15096        "No map visible because the map container's width or height are 0."
15097      ));
15098    }
15099    const n = this.getSize();
15100    i && (!n || !Pi(i, n)) && (this.setSize(i), this.updateViewportSize_());
15101  }
15102  /**
15103   * Recomputes the viewport size and save it on the view object (if any)
15104   * @private
15105   */
15106  updateViewportSize_() {
15107    const t = this.getView();
15108    if (t) {
15109      let i;
15110      const n = getComputedStyle(this.viewport_);
15111      n.width && n.height && (i = [
15112        parseInt(n.width, 10),
15113        parseInt(n.height, 10)
15114      ]), t.setViewportSize(i);
15115    }
15116  }
15117};
15118function YM(e) {
15119  let t = null;
15120  e.keyboardEventTarget !== void 0 && (t = typeof e.keyboardEventTarget == "string" ? document.getElementById(e.keyboardEventTarget) : e.keyboardEventTarget);
15121  const i = {}, n = e.layers && typeof /** @type {?} */
15122  e.layers.getLayers == "function" ? (
15123    /** @type {LayerGroup} */
15124    e.layers
15125  ) : new Ta({
15126    layers: (
15127      /** @type {Collection<import("./layer/Base.js").default>|Array<import("./layer/Base.js").default>} */
15128      e.layers
15129    )
15130  });
15131  i[ie.LAYERGROUP] = n, i[ie.TARGET] = e.target, i[ie.VIEW] = e.view instanceof ri ? e.view : new ri();
15132  let s;
15133  e.controls !== void 0 && (Array.isArray(e.controls) ? s = new De(e.controls.slice()) : (ht(
15134    typeof /** @type {?} */
15135    e.controls.getArray == "function",
15136    47
15137  ), s = e.controls));
15138  let r;
15139  e.interactions !== void 0 && (Array.isArray(e.interactions) ? r = new De(e.interactions.slice()) : (ht(
15140    typeof /** @type {?} */
15141    e.interactions.getArray == "function",
15142    48
15143  ), r = e.interactions));
15144  let o;
15145  return e.overlays !== void 0 ? Array.isArray(e.overlays) ? o = new De(e.overlays.slice()) : (ht(
15146    typeof /** @type {?} */
15147    e.overlays.getArray == "function",
15148    49
15149  ), o = e.overlays) : o = new De(), {
15150    controls: s,
15151    interactions: r,
15152    keyboardEventTarget: t,
15153    overlays: o,
15154    values: i
15155  };
15156}
15157const KM = $M;
15158class ec extends Qe {
15159  /**
15160   * @param {Geometry|ObjectWithGeometry<Geometry>} [geometryOrProperties]
15161   *     You may pass a Geometry object directly, or an object literal containing
15162   *     properties. If you pass an object literal, you may include a Geometry
15163   *     associated with a `geometry` key.
15164   */
15165  constructor(t) {
15166    if (super(), this.on, this.once, this.un, this.id_ = void 0, this.geometryName_ = "geometry", this.style_ = null, this.styleFunction_ = void 0, this.geometryChangeKey_ = null, this.addChangeListener(this.geometryName_, this.handleGeometryChanged_), t)
15167      if (typeof /** @type {?} */
15168      t.getSimplifiedGeometry == "function") {
15169        const i = (
15170          /** @type {Geometry} */
15171          t
15172        );
15173        this.setGeometry(i);
15174      } else {
15175        const i = t;
15176        this.setProperties(i);
15177      }
15178  }
15179  /**
15180   * Clone this feature. If the original feature has a geometry it
15181   * is also cloned. The feature id is not set in the clone.
15182   * @return {Feature<Geometry>} The clone.
15183   * @api
15184   */
15185  clone() {
15186    const t = (
15187      /** @type {Feature<Geometry>} */
15188      new ec(this.hasProperties() ? this.getProperties() : null)
15189    );
15190    t.setGeometryName(this.getGeometryName());
15191    const i = this.getGeometry();
15192    i && t.setGeometry(
15193      /** @type {Geometry} */
15194      i.clone()
15195    );
15196    const n = this.getStyle();
15197    return n && t.setStyle(n), t;
15198  }
15199  /**
15200   * Get the feature's default geometry.  A feature may have any number of named
15201   * geometries.  The "default" geometry (the one that is rendered by default) is
15202   * set when calling {@link module:ol/Feature~Feature#setGeometry}.
15203   * @return {Geometry|undefined} The default geometry for the feature.
15204   * @api
15205   * @observable
15206   */
15207  getGeometry() {
15208    return (
15209      /** @type {Geometry|undefined} */
15210      this.get(this.geometryName_)
15211    );
15212  }
15213  /**
15214   * Get the feature identifier.  This is a stable identifier for the feature and
15215   * is either set when reading data from a remote source or set explicitly by
15216   * calling {@link module:ol/Feature~Feature#setId}.
15217   * @return {number|string|undefined} Id.
15218   * @api
15219   */
15220  getId() {
15221    return this.id_;
15222  }
15223  /**
15224   * Get the name of the feature's default geometry.  By default, the default
15225   * geometry is named `geometry`.
15226   * @return {string} Get the property name associated with the default geometry
15227   *     for this feature.
15228   * @api
15229   */
15230  getGeometryName() {
15231    return this.geometryName_;
15232  }
15233  /**
15234   * Get the feature's style. Will return what was provided to the
15235   * {@link module:ol/Feature~Feature#setStyle} method.
15236   * @return {import("./style/Style.js").StyleLike|undefined} The feature style.
15237   * @api
15238   */
15239  getStyle() {
15240    return this.style_;
15241  }
15242  /**
15243   * Get the feature's style function.
15244   * @return {import("./style/Style.js").StyleFunction|undefined} Return a function
15245   * representing the current style of this feature.
15246   * @api
15247   */
15248  getStyleFunction() {
15249    return this.styleFunction_;
15250  }
15251  /**
15252   * @private
15253   */
15254  handleGeometryChange_() {
15255    this.changed();
15256  }
15257  /**
15258   * @private
15259   */
15260  handleGeometryChanged_() {
15261    this.geometryChangeKey_ && (St(this.geometryChangeKey_), this.geometryChangeKey_ = null);
15262    const t = this.getGeometry();
15263    t && (this.geometryChangeKey_ = ct(
15264      t,
15265      et.CHANGE,
15266      this.handleGeometryChange_,
15267      this
15268    )), this.changed();
15269  }
15270  /**
15271   * Set the default geometry for the feature.  This will update the property
15272   * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.
15273   * @param {Geometry|undefined} geometry The new geometry.
15274   * @api
15275   * @observable
15276   */
15277  setGeometry(t) {
15278    this.set(this.geometryName_, t);
15279  }
15280  /**
15281   * Set the style for the feature to override the layer style.  This can be a
15282   * single style object, an array of styles, or a function that takes a
15283   * resolution and returns an array of styles. To unset the feature style, call
15284   * `setStyle()` without arguments or a falsey value.
15285   * @param {import("./style/Style.js").StyleLike} [style] Style for this feature.
15286   * @api
15287   * @fires module:ol/events/Event~BaseEvent#event:change
15288   */
15289  setStyle(t) {
15290    this.style_ = t, this.styleFunction_ = t ? VM(t) : void 0, this.changed();
15291  }
15292  /**
15293   * Set the feature id.  The feature id is considered stable and may be used when
15294   * requesting features or comparing identifiers returned from a remote source.
15295   * The feature id can be used with the
15296   * {@link module:ol/source/Vector~VectorSource#getFeatureById} method.
15297   * @param {number|string|undefined} id The feature id.
15298   * @api
15299   * @fires module:ol/events/Event~BaseEvent#event:change
15300   */
15301  setId(t) {
15302    this.id_ = t, this.changed();
15303  }
15304  /**
15305   * Set the property name to be used when getting the feature's default geometry.
15306   * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with
15307   * this name will be returned.
15308   * @param {string} name The property name of the default geometry.
15309   * @api
15310   */
15311  setGeometryName(t) {
15312    this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_), this.geometryName_ = t, this.addChangeListener(this.geometryName_, this.handleGeometryChanged_), this.handleGeometryChanged_();
15313  }
15314}
15315function VM(e) {
15316  if (typeof e == "function")
15317    return e;
15318  let t;
15319  return Array.isArray(e) ? t = e : (ht(typeof /** @type {?} */
15320  e.getZIndex == "function", 41), t = [
15321    /** @type {import("./style/Style.js").default} */
15322    e
15323  ]), function() {
15324    return t;
15325  };
15326}
15327const ke = ec, Ot = {
15328  ACCURACY: "accuracy",
15329  ACCURACY_GEOMETRY: "accuracyGeometry",
15330  ALTITUDE: "altitude",
15331  ALTITUDE_ACCURACY: "altitudeAccuracy",
15332  HEADING: "heading",
15333  POSITION: "position",
15334  PROJECTION: "projection",
15335  SPEED: "speed",
15336  TRACKING: "tracking",
15337  TRACKING_OPTIONS: "trackingOptions"
15338}, qM = {
15339  /**
15340   * Triggered when a `GeolocationPositionError` occurs.
15341   * @event module:ol/Geolocation.GeolocationError#error
15342   * @api
15343   */
15344  ERROR: "error"
15345};
15346class HM extends Le {
15347  /**
15348   * @param {GeolocationPositionError} error error object.
15349   */
15350  constructor(t) {
15351    super(qM.ERROR), this.code = t.code, this.message = t.message;
15352  }
15353}
15354class ZM extends Qe {
15355  /**
15356   * @param {Options} [options] Options.
15357   */
15358  constructor(t) {
15359    super(), this.on, this.once, this.un, t = t || {}, this.position_ = null, this.transform_ = hh, this.watchId_ = void 0, this.addChangeListener(Ot.PROJECTION, this.handleProjectionChanged_), this.addChangeListener(Ot.TRACKING, this.handleTrackingChanged_), t.projection !== void 0 && this.setProjection(t.projection), t.trackingOptions !== void 0 && this.setTrackingOptions(t.trackingOptions), this.setTracking(t.tracking !== void 0 ? t.tracking : !1);
15360  }
15361  /**
15362   * Clean up.
15363   */
15364  disposeInternal() {
15365    this.setTracking(!1), super.disposeInternal();
15366  }
15367  /**
15368   * @private
15369   */
15370  handleProjectionChanged_() {
15371    const t = this.getProjection();
15372    t && (this.transform_ = aa(
15373      It("EPSG:4326"),
15374      t
15375    ), this.position_ && this.set(Ot.POSITION, this.transform_(this.position_)));
15376  }
15377  /**
15378   * @private
15379   */
15380  handleTrackingChanged_() {
15381    if ("geolocation" in navigator) {
15382      const t = this.getTracking();
15383      t && this.watchId_ === void 0 ? this.watchId_ = navigator.geolocation.watchPosition(
15384        this.positionChange_.bind(this),
15385        this.positionError_.bind(this),
15386        this.getTrackingOptions()
15387      ) : !t && this.watchId_ !== void 0 && (navigator.geolocation.clearWatch(this.watchId_), this.watchId_ = void 0);
15388    }
15389  }
15390  /**
15391   * @private
15392   * @param {GeolocationPosition} position position event.
15393   */
15394  positionChange_(t) {
15395    const i = t.coords;
15396    this.set(Ot.ACCURACY, i.accuracy), this.set(
15397      Ot.ALTITUDE,
15398      i.altitude === null ? void 0 : i.altitude
15399    ), this.set(
15400      Ot.ALTITUDE_ACCURACY,
15401      i.altitudeAccuracy === null ? void 0 : i.altitudeAccuracy
15402    ), this.set(
15403      Ot.HEADING,
15404      i.heading === null ? void 0 : Cn(i.heading)
15405    ), this.position_ ? (this.position_[0] = i.longitude, this.position_[1] = i.latitude) : this.position_ = [i.longitude, i.latitude];
15406    const n = this.transform_(this.position_);
15407    this.set(Ot.POSITION, n.slice()), this.set(Ot.SPEED, i.speed === null ? void 0 : i.speed);
15408    const s = TC(this.position_, i.accuracy);
15409    s.applyTransform(this.transform_), this.set(Ot.ACCURACY_GEOMETRY, s), this.changed();
15410  }
15411  /**
15412   * @private
15413   * @param {GeolocationPositionError} error error object.
15414   */
15415  positionError_(t) {
15416    this.dispatchEvent(new HM(t));
15417  }
15418  /**
15419   * Get the accuracy of the position in meters.
15420   * @return {number|undefined} The accuracy of the position measurement in
15421   *     meters.
15422   * @observable
15423   * @api
15424   */
15425  getAccuracy() {
15426    return (
15427      /** @type {number|undefined} */
15428      this.get(Ot.ACCURACY)
15429    );
15430  }
15431  /**
15432   * Get a geometry of the position accuracy.
15433   * @return {?import("./geom/Polygon.js").default} A geometry of the position accuracy.
15434   * @observable
15435   * @api
15436   */
15437  getAccuracyGeometry() {
15438    return (
15439      /** @type {?import("./geom/Polygon.js").default} */
15440      this.get(Ot.ACCURACY_GEOMETRY) || null
15441    );
15442  }
15443  /**
15444   * Get the altitude associated with the position.
15445   * @return {number|undefined} The altitude of the position in meters above mean
15446   *     sea level.
15447   * @observable
15448   * @api
15449   */
15450  getAltitude() {
15451    return (
15452      /** @type {number|undefined} */
15453      this.get(Ot.ALTITUDE)
15454    );
15455  }
15456  /**
15457   * Get the altitude accuracy of the position.
15458   * @return {number|undefined} The accuracy of the altitude measurement in
15459   *     meters.
15460   * @observable
15461   * @api
15462   */
15463  getAltitudeAccuracy() {
15464    return (
15465      /** @type {number|undefined} */
15466      this.get(Ot.ALTITUDE_ACCURACY)
15467    );
15468  }
15469  /**
15470   * Get the heading as radians clockwise from North.
15471   * Note: depending on the browser, the heading is only defined if the `enableHighAccuracy`
15472   * is set to `true` in the tracking options.
15473   * @return {number|undefined} The heading of the device in radians from north.
15474   * @observable
15475   * @api
15476   */
15477  getHeading() {
15478    return (
15479      /** @type {number|undefined} */
15480      this.get(Ot.HEADING)
15481    );
15482  }
15483  /**
15484   * Get the position of the device.
15485   * @return {import("./coordinate.js").Coordinate|undefined} The current position of the device reported
15486   *     in the current projection.
15487   * @observable
15488   * @api
15489   */
15490  getPosition() {
15491    return (
15492      /** @type {import("./coordinate.js").Coordinate|undefined} */
15493      this.get(Ot.POSITION)
15494    );
15495  }
15496  /**
15497   * Get the projection associated with the position.
15498   * @return {import("./proj/Projection.js").default|undefined} The projection the position is
15499   *     reported in.
15500   * @observable
15501   * @api
15502   */
15503  getProjection() {
15504    return (
15505      /** @type {import("./proj/Projection.js").default|undefined} */
15506      this.get(Ot.PROJECTION)
15507    );
15508  }
15509  /**
15510   * Get the speed in meters per second.
15511   * @return {number|undefined} The instantaneous speed of the device in meters
15512   *     per second.
15513   * @observable
15514   * @api
15515   */
15516  getSpeed() {
15517    return (
15518      /** @type {number|undefined} */
15519      this.get(Ot.SPEED)
15520    );
15521  }
15522  /**
15523   * Determine if the device location is being tracked.
15524   * @return {boolean} The device location is being tracked.
15525   * @observable
15526   * @api
15527   */
15528  getTracking() {
15529    return (
15530      /** @type {boolean} */
15531      this.get(Ot.TRACKING)
15532    );
15533  }
15534  /**
15535   * Get the tracking options.
15536   * See https://www.w3.org/TR/geolocation-API/#position-options.
15537   * @return {PositionOptions|undefined} PositionOptions as defined by
15538   *     the [HTML5 Geolocation spec
15539   *     ](https://www.w3.org/TR/geolocation-API/#position_options_interface).
15540   * @observable
15541   * @api
15542   */
15543  getTrackingOptions() {
15544    return (
15545      /** @type {PositionOptions|undefined} */
15546      this.get(Ot.TRACKING_OPTIONS)
15547    );
15548  }
15549  /**
15550   * Set the projection to use for transforming the coordinates.
15551   * @param {import("./proj.js").ProjectionLike} projection The projection the position is
15552   *     reported in.
15553   * @observable
15554   * @api
15555   */
15556  setProjection(t) {
15557    this.set(Ot.PROJECTION, It(t));
15558  }
15559  /**
15560   * Enable or disable tracking.
15561   * @param {boolean} tracking Enable tracking.
15562   * @observable
15563   * @api
15564   */
15565  setTracking(t) {
15566    this.set(Ot.TRACKING, t);
15567  }
15568  /**
15569   * Set the tracking options.
15570   * See http://www.w3.org/TR/geolocation-API/#position-options.
15571   * @param {PositionOptions} options PositionOptions as defined by the
15572   *     [HTML5 Geolocation spec
15573   *     ](http://www.w3.org/TR/geolocation-API/#position_options_interface).
15574   * @observable
15575   * @api
15576   */
15577  setTrackingOptions(t) {
15578    this.set(Ot.TRACKING_OPTIONS, t);
15579  }
15580}
15581const JM = ZM;
15582class ic {
15583  /**
15584   * @param {Options} [options] Options.
15585   */
15586  constructor(t) {
15587    t = t || {}, this.color_ = t.color !== void 0 ? t.color : null;
15588  }
15589  /**
15590   * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.
15591   * @return {Fill} The cloned style.
15592   * @api
15593   */
15594  clone() {
15595    const t = this.getColor();
15596    return new ic({
15597      color: Array.isArray(t) ? t.slice() : t || void 0
15598    });
15599  }
15600  /**
15601   * Get the fill color.
15602   * @return {import("../color.js").Color|import("../colorlike.js").ColorLike|null} Color.
15603   * @api
15604   */
15605  getColor() {
15606    return this.color_;
15607  }
15608  /**
15609   * Set the color.
15610   *
15611   * @param {import("../color.js").Color|import("../colorlike.js").ColorLike|null} color Color.
15612   * @api
15613   */
15614  setColor(t) {
15615    this.color_ = t;
15616  }
15617}
15618const Ye = ic;
15619function zg(e, t, i, n, s, r, o) {
15620  let a, l;
15621  const h = (i - t) / n;
15622  if (h === 1)
15623    a = t;
15624  else if (h === 2)
15625    a = t, l = s;
15626  else if (h !== 0) {
15627    let c = e[t], u = e[t + 1], d = 0;
15628    const f = [0];
15629    for (let _ = t + n; _ < i; _ += n) {
15630      const p = e[_], y = e[_ + 1];
15631      d += Math.sqrt((p - c) * (p - c) + (y - u) * (y - u)), f.push(d), c = p, u = y;
15632    }
15633    const g = s * d, m = IE(f, g);
15634    m < 0 ? (l = (g - f[-m - 2]) / (f[-m - 1] - f[-m - 2]), a = t + (-m - 2) * n) : a = t + m * n;
15635  }
15636  o = o > 1 ? o : 2, r = r || new Array(o);
15637  for (let c = 0; c < o; ++c)
15638    r[c] = a === void 0 ? NaN : l === void 0 ? e[a + c] : Pe(e[a + c], e[a + n + c], l);
15639  return r;
15640}
15641function Ul(e, t, i, n, s, r) {
15642  if (i == t)
15643    return null;
15644  let o;
15645  if (s < e[t + n - 1])
15646    return r ? (o = e.slice(t, t + n), o[n - 1] = s, o) : null;
15647  if (e[i - 1] < s)
15648    return r ? (o = e.slice(i - n, i), o[n - 1] = s, o) : null;
15649  if (s == e[t + n - 1])
15650    return e.slice(t, t + n);
15651  let a = t / n, l = i / n;
15652  for (; a < l; ) {
15653    const d = a + l >> 1;
15654    s < e[(d + 1) * n - 1] ? l = d : a = d + 1;
15655  }
15656  const h = e[a * n - 1];
15657  if (s == h)
15658    return e.slice((a - 1) * n, (a - 1) * n + n);
15659  const c = e[(a + 1) * n - 1], u = (s - h) / (c - h);
15660  o = [];
15661  for (let d = 0; d < n - 1; ++d)
15662    o.push(
15663      Pe(
15664        e[(a - 1) * n + d],
15665        e[a * n + d],
15666        u
15667      )
15668    );
15669  return o.push(s), o;
15670}
15671function QM(e, t, i, n, s, r, o) {
15672  if (o)
15673    return Ul(
15674      e,
15675      t,
15676      i[i.length - 1],
15677      n,
15678      s,
15679      r
15680    );
15681  let a;
15682  if (s < e[n - 1])
15683    return r ? (a = e.slice(0, n), a[n - 1] = s, a) : null;
15684  if (e[e.length - 1] < s)
15685    return r ? (a = e.slice(e.length - n), a[n - 1] = s, a) : null;
15686  for (let l = 0, h = i.length; l < h; ++l) {
15687    const c = i[l];
15688    if (t != c) {
15689      if (s < e[t + n - 1])
15690        return null;
15691      if (s <= e[c - 1])
15692        return Ul(
15693          e,
15694          t,
15695          c,
15696          n,
15697          s,
15698          !1
15699        );
15700      t = c;
15701    }
15702  }
15703  return null;
15704}
15705function jg(e, t, i, n) {
15706  let s = e[t], r = e[t + 1], o = 0;
15707  for (let a = t + n; a < i; a += n) {
15708    const l = e[a], h = e[a + 1];
15709    o += Math.sqrt((l - s) * (l - s) + (h - r) * (h - r)), s = l, r = h;
15710  }
15711  return o;
15712}
15713class Ho extends an {
15714  /**
15715   * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
15716   *     For internal use, flat coordinates in combination with `layout` are also accepted.
15717   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
15718   */
15719  constructor(t, i) {
15720    super(), this.flatMidpoint_ = null, this.flatMidpointRevision_ = -1, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, i !== void 0 && !Array.isArray(t[0]) ? this.setFlatCoordinates(
15721      i,
15722      /** @type {Array<number>} */
15723      t
15724    ) : this.setCoordinates(
15725      /** @type {Array<import("../coordinate.js").Coordinate>} */
15726      t,
15727      i
15728    );
15729  }
15730  /**
15731   * Append the passed coordinate to the coordinates of the linestring.
15732   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
15733   * @api
15734   */
15735  appendCoordinate(t) {
15736    this.flatCoordinates ? ci(this.flatCoordinates, t) : this.flatCoordinates = t.slice(), this.changed();
15737  }
15738  /**
15739   * Make a complete copy of the geometry.
15740   * @return {!LineString} Clone.
15741   * @api
15742   */
15743  clone() {
15744    const t = new Ho(
15745      this.flatCoordinates.slice(),
15746      this.layout
15747    );
15748    return t.applyProperties(this), t;
15749  }
15750  /**
15751   * @param {number} x X.
15752   * @param {number} y Y.
15753   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
15754   * @param {number} minSquaredDistance Minimum squared distance.
15755   * @return {number} Minimum squared distance.
15756   */
15757  closestPointXY(t, i, n, s) {
15758    return s < kn(this.getExtent(), t, i) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
15759      jh(
15760        this.flatCoordinates,
15761        0,
15762        this.flatCoordinates.length,
15763        this.stride,
15764        0
15765      )
15766    ), this.maxDeltaRevision_ = this.getRevision()), Bh(
15767      this.flatCoordinates,
15768      0,
15769      this.flatCoordinates.length,
15770      this.stride,
15771      this.maxDelta_,
15772      !1,
15773      t,
15774      i,
15775      n,
15776      s
15777    ));
15778  }
15779  /**
15780   * Iterate over each segment, calling the provided callback.
15781   * If the callback returns a truthy value the function returns that
15782   * value immediately. Otherwise the function returns `false`.
15783   *
15784   * @param {function(this: S, import("../coordinate.js").Coordinate, import("../coordinate.js").Coordinate): T} callback Function
15785   *     called for each segment. The function will receive two arguments, the start and end coordinates of the segment.
15786   * @return {T|boolean} Value.
15787   * @template T,S
15788   * @api
15789   */
15790  forEachSegment(t) {
15791    return Eg(
15792      this.flatCoordinates,
15793      0,
15794      this.flatCoordinates.length,
15795      this.stride,
15796      t
15797    );
15798  }
15799  /**
15800   * Returns the coordinate at `m` using linear interpolation, or `null` if no
15801   * such coordinate exists.
15802   *
15803   * `extrapolate` controls extrapolation beyond the range of Ms in the
15804   * MultiLineString. If `extrapolate` is `true` then Ms less than the first
15805   * M will return the first coordinate and Ms greater than the last M will
15806   * return the last coordinate.
15807   *
15808   * @param {number} m M.
15809   * @param {boolean} [extrapolate] Extrapolate. Default is `false`.
15810   * @return {import("../coordinate.js").Coordinate|null} Coordinate.
15811   * @api
15812   */
15813  getCoordinateAtM(t, i) {
15814    return this.layout != "XYM" && this.layout != "XYZM" ? null : (i = i !== void 0 ? i : !1, Ul(
15815      this.flatCoordinates,
15816      0,
15817      this.flatCoordinates.length,
15818      this.stride,
15819      t,
15820      i
15821    ));
15822  }
15823  /**
15824   * Return the coordinates of the linestring.
15825   * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
15826   * @api
15827   */
15828  getCoordinates() {
15829    return Xi(
15830      this.flatCoordinates,
15831      0,
15832      this.flatCoordinates.length,
15833      this.stride
15834    );
15835  }
15836  /**
15837   * Return the coordinate at the provided fraction along the linestring.
15838   * The `fraction` is a number between 0 and 1, where 0 is the start of the
15839   * linestring and 1 is the end.
15840   * @param {number} fraction Fraction.
15841   * @param {import("../coordinate.js").Coordinate} [dest] Optional coordinate whose values will
15842   *     be modified. If not provided, a new coordinate will be returned.
15843   * @return {import("../coordinate.js").Coordinate} Coordinate of the interpolated point.
15844   * @api
15845   */
15846  getCoordinateAt(t, i) {
15847    return zg(
15848      this.flatCoordinates,
15849      0,
15850      this.flatCoordinates.length,
15851      this.stride,
15852      t,
15853      i,
15854      this.stride
15855    );
15856  }
15857  /**
15858   * Return the length of the linestring on projected plane.
15859   * @return {number} Length (on projected plane).
15860   * @api
15861   */
15862  getLength() {
15863    return jg(
15864      this.flatCoordinates,
15865      0,
15866      this.flatCoordinates.length,
15867      this.stride
15868    );
15869  }
15870  /**
15871   * @return {Array<number>} Flat midpoint.
15872   */
15873  getFlatMidpoint() {
15874    return this.flatMidpointRevision_ != this.getRevision() && (this.flatMidpoint_ = this.getCoordinateAt(0.5, this.flatMidpoint_), this.flatMidpointRevision_ = this.getRevision()), this.flatMidpoint_;
15875  }
15876  /**
15877   * @param {number} squaredTolerance Squared tolerance.
15878   * @return {LineString} Simplified LineString.
15879   * @protected
15880   */
15881  getSimplifiedGeometryInternal(t) {
15882    const i = [];
15883    return i.length = $h(
15884      this.flatCoordinates,
15885      0,
15886      this.flatCoordinates.length,
15887      this.stride,
15888      t,
15889      i,
15890      0
15891    ), new Ho(i, "XY");
15892  }
15893  /**
15894   * Get the type of this geometry.
15895   * @return {import("./Geometry.js").Type} Geometry type.
15896   * @api
15897   */
15898  getType() {
15899    return "LineString";
15900  }
15901  /**
15902   * Test if the geometry and the passed extent intersect.
15903   * @param {import("../extent.js").Extent} extent Extent.
15904   * @return {boolean} `true` if the geometry and the extent intersect.
15905   * @api
15906   */
15907  intersectsExtent(t) {
15908    return ba(
15909      this.flatCoordinates,
15910      0,
15911      this.flatCoordinates.length,
15912      this.stride,
15913      t
15914    );
15915  }
15916  /**
15917   * Set the coordinates of the linestring.
15918   * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
15919   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
15920   * @api
15921   */
15922  setCoordinates(t, i) {
15923    this.setLayout(i, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = Ma(
15924      this.flatCoordinates,
15925      0,
15926      t,
15927      this.stride
15928    ), this.changed();
15929  }
15930}
15931const Qi = Ho;
15932class nc {
15933  /**
15934   * @param {Options} [options] Options.
15935   */
15936  constructor(t) {
15937    t = t || {}, this.color_ = t.color !== void 0 ? t.color : null, this.lineCap_ = t.lineCap, this.lineDash_ = t.lineDash !== void 0 ? t.lineDash : null, this.lineDashOffset_ = t.lineDashOffset, this.lineJoin_ = t.lineJoin, this.miterLimit_ = t.miter
15937Limit, this.width_ = t.width;
15938  }
15939  /**
15940   * Clones the style.
15941   * @return {Stroke} The cloned style.
15942   * @api
15943   */
15944  clone() {
15945    const t = this.getColor();
15946    return new nc({
15947      color: Array.isArray(t) ? t.slice() : t || void 0,
15948      lineCap: this.getLineCap(),
15949      lineDash: this.getLineDash() ? this.getLineDash().slice() : void 0,
15950      lineDashOffset: this.getLineDashOffset(),
15951      lineJoin: this.getLineJoin(),
15952      miterLimit: this.getMiterLimit(),
15953      width: this.getWidth()
15954    });
15955  }
15956  /**
15957   * Get the stroke color.
15958   * @return {import("../color.js").Color|import("../colorlike.js").ColorLike} Color.
15959   * @api
15960   */
15961  getColor() {
15962    return this.color_;
15963  }
15964  /**
15965   * Get the line cap type for the stroke.
15966   * @return {CanvasLineCap|undefined} Line cap.
15967   * @api
15968   */
15969  getLineCap() {
15970    return this.lineCap_;
15971  }
15972  /**
15973   * Get the line dash style for the stroke.
15974   * @return {Array<number>|null} Line dash.
15975   * @api
15976   */
15977  getLineDash() {
15978    return this.lineDash_;
15979  }
15980  /**
15981   * Get the line dash offset for the stroke.
15982   * @return {number|undefined} Line dash offset.
15983   * @api
15984   */
15985  getLineDashOffset() {
15986    return this.lineDashOffset_;
15987  }
15988  /**
15989   * Get the line join type for the stroke.
15990   * @return {CanvasLineJoin|undefined} Line join.
15991   * @api
15992   */
15993  getLineJoin() {
15994    return this.lineJoin_;
15995  }
15996  /**
15997   * Get the miter limit for the stroke.
15998   * @return {number|undefined} Miter limit.
15999   * @api
16000   */
16001  getMiterLimit() {
16002    return this.miterLimit_;
16003  }
16004  /**
16005   * Get the stroke width.
16006   * @return {number|undefined} Width.
16007   * @api
16008   */
16009  getWidth() {
16010    return this.width_;
16011  }
16012  /**
16013   * Set the color.
16014   *
16015   * @param {import("../color.js").Color|import("../colorlike.js").ColorLike} color Color.
16016   * @api
16017   */
16018  setColor(t) {
16019    this.color_ = t;
16020  }
16021  /**
16022   * Set the line cap.
16023   *
16024   * @param {CanvasLineCap|undefined} lineCap Line cap.
16025   * @api
16026   */
16027  setLineCap(t) {
16028    this.lineCap_ = t;
16029  }
16030  /**
16031   * Set the line dash.
16032   *
16033   * @param {Array<number>|null} lineDash Line dash.
16034   * @api
16035   */
16036  setLineDash(t) {
16037    this.lineDash_ = t;
16038  }
16039  /**
16040   * Set the line dash offset.
16041   *
16042   * @param {number|undefined} lineDashOffset Line dash offset.
16043   * @api
16044   */
16045  setLineDashOffset(t) {
16046    this.lineDashOffset_ = t;
16047  }
16048  /**
16049   * Set the line join.
16050   *
16051   * @param {CanvasLineJoin|undefined} lineJoin Line join.
16052   * @api
16053   */
16054  setLineJoin(t) {
16055    this.lineJoin_ = t;
16056  }
16057  /**
16058   * Set the miter limit.
16059   *
16060   * @param {number|undefined} miterLimit Miter limit.
16061   * @api
16062   */
16063  setMiterLimit(t) {
16064    this.miterLimit_ = t;
16065  }
16066  /**
16067   * Set the width.
16068   *
16069   * @param {number|undefined} width Width.
16070   * @api
16071   */
16072  setWidth(t) {
16073    this.width_ = t;
16074  }
16075}
16076const Ke = nc, at = {
16077  IDLE: 0,
16078  LOADING: 1,
16079  LOADED: 2,
16080  ERROR: 3,
16081  EMPTY: 4
16082};
16083class sc {
16084  /**
16085   * @param {Options} options Options.
16086   */
16087  constructor(t) {
16088    this.opacity_ = t.opacity, this.rotateWithView_ = t.rotateWithView, this.rotation_ = t.rotation, this.scale_ = t.scale, this.scaleArray_ = Ce(t.scale), this.displacement_ = t.displacement, this.declutterMode_ = t.declutterMode;
16089  }
16090  /**
16091   * Clones the style.
16092   * @return {ImageStyle} The cloned style.
16093   * @api
16094   */
16095  clone() {
16096    const t = this.getScale();
16097    return new sc({
16098      opacity: this.getOpacity(),
16099      scale: Array.isArray(t) ? t.slice() : t,
16100      rotation: this.getRotation(),
16101      rotateWithView: this.getRotateWithView(),
16102      displacement: this.getDisplacement().slice(),
16103      declutterMode: this.getDeclutterMode()
16104    });
16105  }
16106  /**
16107   * Get the symbolizer opacity.
16108   * @return {number} Opacity.
16109   * @api
16110   */
16111  getOpacity() {
16112    return this.opacity_;
16113  }
16114  /**
16115   * Determine whether the symbolizer rotates with the map.
16116   * @return {boolean} Rotate with map.
16117   * @api
16118   */
16119  getRotateWithView() {
16120    return this.rotateWithView_;
16121  }
16122  /**
16123   * Get the symoblizer rotation.
16124   * @return {number} Rotation.
16125   * @api
16126   */
16127  getRotation() {
16128    return this.rotation_;
16129  }
16130  /**
16131   * Get the symbolizer scale.
16132   * @return {number|import("../size.js").Size} Scale.
16133   * @api
16134   */
16135  getScale() {
16136    return this.scale_;
16137  }
16138  /**
16139   * Get the symbolizer scale array.
16140   * @return {import("../size.js").Size} Scale array.
16141   */
16142  getScaleArray() {
16143    return this.scaleArray_;
16144  }
16145  /**
16146   * Get the displacement of the shape
16147   * @return {Array<number>} Shape's center displacement
16148   * @api
16149   */
16150  getDisplacement() {
16151    return this.displacement_;
16152  }
16153  /**
16154   * Get the declutter mode of the shape
16155   * @return {"declutter"|"obstacle"|"none"|undefined} Shape's declutter mode
16156   * @api
16157   */
16158  getDeclutterMode() {
16159    return this.declutterMode_;
16160  }
16161  /**
16162   * Get the anchor point in pixels. The anchor determines the center point for the
16163   * symbolizer.
16164   * @abstract
16165   * @return {Array<number>} Anchor.
16166   */
16167  getAnchor() {
16168    return Q();
16169  }
16170  /**
16171   * Get the image element for the symbolizer.
16172   * @abstract
16173   * @param {number} pixelRatio Pixel ratio.
16174   * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
16175   */
16176  getImage(t) {
16177    return Q();
16178  }
16179  /**
16180   * @abstract
16181   * @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
16182   */
16183  getHitDetectionImage() {
16184    return Q();
16185  }
16186  /**
16187   * Get the image pixel ratio.
16188   * @param {number} pixelRatio Pixel ratio.
16189   * @return {number} Pixel ratio.
16190   */
16191  getPixelRatio(t) {
16192    return 1;
16193  }
16194  /**
16195   * @abstract
16196   * @return {import("../ImageState.js").default} Image state.
16197   */
16198  getImageState() {
16199    return Q();
16200  }
16201  /**
16202   * @abstract
16203   * @return {import("../size.js").Size} Image size.
16204   */
16205  getImageSize() {
16206    return Q();
16207  }
16208  /**
16209   * Get the origin of the symbolizer.
16210   * @abstract
16211   * @return {Array<number>} Origin.
16212   */
16213  getOrigin() {
16214    return Q();
16215  }
16216  /**
16217   * Get the size of the symbolizer (in pixels).
16218   * @abstract
16219   * @return {import("../size.js").Size} Size.
16220   */
16221  getSize() {
16222    return Q();
16223  }
16224  /**
16225   * Set the displacement.
16226   *
16227   * @param {Array<number>} displacement Displacement.
16228   * @api
16229   */
16230  setDisplacement(t) {
16231    this.displacement_ = t;
16232  }
16233  /**
16234   * Set the opacity.
16235   *
16236   * @param {number} opacity Opacity.
16237   * @api
16238   */
16239  setOpacity(t) {
16240    this.opacity_ = t;
16241  }
16242  /**
16243   * Set whether to rotate the style with the view.
16244   *
16245   * @param {boolean} rotateWithView Rotate with map.
16246   * @api
16247   */
16248  setRotateWithView(t) {
16249    this.rotateWithView_ = t;
16250  }
16251  /**
16252   * Set the rotation.
16253   *
16254   * @param {number} rotation Rotation.
16255   * @api
16256   */
16257  setRotation(t) {
16258    this.rotation_ = t;
16259  }
16260  /**
16261   * Set the scale.
16262   *
16263   * @param {number|import("../size.js").Size} scale Scale.
16264   * @api
16265   */
16266  setScale(t) {
16267    this.scale_ = t, this.scaleArray_ = Ce(t);
16268  }
16269  /**
16270   * @abstract
16271   * @param {function(import("../events/Event.js").default): void} listener Listener function.
16272   */
16273  listenImageChange(t) {
16274    Q();
16275  }
16276  /**
16277   * Load not yet loaded URI.
16278   * @abstract
16279   */
16280  load() {
16281    Q();
16282  }
16283  /**
16284   * @abstract
16285   * @param {function(import("../events/Event.js").default): void} listener Listener function.
16286   */
16287  unlistenImageChange(t) {
16288    Q();
16289  }
16290}
16291const Wg = sc;
16292function li(e) {
16293  return Array.isArray(e) ? dg(e) : e;
16294}
16295class rc extends Wg {
16296  /**
16297   * @param {Options} options Options.
16298   */
16299  constructor(t) {
16300    const i = t.rotateWithView !== void 0 ? t.rotateWithView : !1;
16301    super({
16302      opacity: 1,
16303      rotateWithView: i,
16304      rotation: t.rotation !== void 0 ? t.rotation : 0,
16305      scale: t.scale !== void 0 ? t.scale : 1,
16306      displacement: t.displacement !== void 0 ? t.displacement : [0, 0],
16307      declutterMode: t.declutterMode
16308    }), this.canvas_ = void 0, this.hitDetectionCanvas_ = null, this.fill_ = t.fill !== void 0 ? t.fill : null, this.origin_ = [0, 0], this.points_ = t.points, this.radius_ = t.radius !== void 0 ? t.radius : t.radius1, this.radius2_ = t.radius2, this.angle_ = t.angle !== void 0 ? t.angle : 0, this.stroke_ = t.stroke !== void 0 ? t.stroke : null, this.size_ = null, this.renderOptions_ = null, this.render();
16309  }
16310  /**
16311   * Clones the style.
16312   * @return {RegularShape} The cloned style.
16313   * @api
16314   */
16315  clone() {
16316    const t = this.getScale(), i = new rc({
16317      fill: this.getFill() ? this.getFill().clone() : void 0,
16318      points: this.getPoints(),
16319      radius: this.getRadius(),
16320      radius2: this.getRadius2(),
16321      angle: this.getAngle(),
16322      stroke: this.getStroke() ? this.getStroke().clone() : void 0,
16323      rotation: this.getRotation(),
16324      rotateWithView: this.getRotateWithView(),
16325      scale: Array.isArray(t) ? t.slice() : t,
16326      displacement: this.getDisplacement().slice(),
16327      declutterMode: this.getDeclutterMode()
16328    });
16329    return i.setOpacity(this.getOpacity()), i;
16330  }
16331  /**
16332   * Get the anchor point in pixels. The anchor determines the center point for the
16333   * symbolizer.
16334   * @return {Array<number>} Anchor.
16335   * @api
16336   */
16337  getAnchor() {
16338    const t = this.size_;
16339    if (!t)
16340      return null;
16341    const i = this.getDisplacement(), n = this.getScaleArray();
16342    return [
16343      t[0] / 2 - i[0] / n[0],
16344      t[1] / 2 + i[1] / n[1]
16345    ];
16346  }
16347  /**
16348   * Get the angle used in generating the shape.
16349   * @return {number} Shape's rotation in radians.
16350   * @api
16351   */
16352  getAngle() {
16353    return this.angle_;
16354  }
16355  /**
16356   * Get the fill style for the shape.
16357   * @return {import("./Fill.js").default} Fill style.
16358   * @api
16359   */
16360  getFill() {
16361    return this.fill_;
16362  }
16363  /**
16364   * Set the fill style.
16365   * @param {import("./Fill.js").default} fill Fill style.
16366   * @api
16367   */
16368  setFill(t) {
16369    this.fill_ = t, this.render();
16370  }
16371  /**
16372   * @return {HTMLCanvasElement} Image element.
16373   */
16374  getHitDetectionImage() {
16375    return this.hitDetectionCanvas_ || this.createHitDetectionCanvas_(this.renderOptions_), this.hitDetectionCanvas_;
16376  }
16377  /**
16378   * Get the image icon.
16379   * @param {number} pixelRatio Pixel ratio.
16380   * @return {HTMLCanvasElement} Image or Canvas element.
16381   * @api
16382   */
16383  getImage(t) {
16384    let i = this.canvas_[t];
16385    if (!i) {
16386      const n = this.renderOptions_, s = he(
16387        n.size * t,
16388        n.size * t
16389      );
16390      this.draw_(n, s, t), i = s.canvas, this.canvas_[t] = i;
16391    }
16392    return i;
16393  }
16394  /**
16395   * Get the image pixel ratio.
16396   * @param {number} pixelRatio Pixel ratio.
16397   * @return {number} Pixel ratio.
16398   */
16399  getPixelRatio(t) {
16400    return t;
16401  }
16402  /**
16403   * @return {import("../size.js").Size} Image size.
16404   */
16405  getImageSize() {
16406    return this.size_;
16407  }
16408  /**
16409   * @return {import("../ImageState.js").default} Image state.
16410   */
16411  getImageState() {
16412    return at.LOADED;
16413  }
16414  /**
16415   * Get the origin of the symbolizer.
16416   * @return {Array<number>} Origin.
16417   * @api
16418   */
16419  getOrigin() {
16420    return this.origin_;
16421  }
16422  /**
16423   * Get the number of points for generating the shape.
16424   * @return {number} Number of points for stars and regular polygons.
16425   * @api
16426   */
16427  getPoints() {
16428    return this.points_;
16429  }
16430  /**
16431   * Get the (primary) radius for the shape.
16432   * @return {number} Radius.
16433   * @api
16434   */
16435  getRadius() {
16436    return this.radius_;
16437  }
16438  /**
16439   * Get the secondary radius for the shape.
16440   * @return {number|undefined} Radius2.
16441   * @api
16442   */
16443  getRadius2() {
16444    return this.radius2_;
16445  }
16446  /**
16447   * Get the size of the symbolizer (in pixels).
16448   * @return {import("../size.js").Size} Size.
16449   * @api
16450   */
16451  getSize() {
16452    return this.size_;
16453  }
16454  /**
16455   * Get the stroke style for the shape.
16456   * @return {import("./Stroke.js").default} Stroke style.
16457   * @api
16458   */
16459  getStroke() {
16460    return this.stroke_;
16461  }
16462  /**
16463   * Set the stroke style.
16464   * @param {import("./Stroke.js").default} stroke Stroke style.
16465   * @api
16466   */
16467  setStroke(t) {
16468    this.stroke_ = t, this.render();
16469  }
16470  /**
16471   * @param {function(import("../events/Event.js").default): void} listener Listener function.
16472   */
16473  listenImageChange(t) {
16474  }
16475  /**
16476   * Load not yet loaded URI.
16477   */
16478  load() {
16479  }
16480  /**
16481   * @param {function(import("../events/Event.js").default): void} listener Listener function.
16482   */
16483  unlistenImageChange(t) {
16484  }
16485  /**
16486   * Calculate additional canvas size needed for the miter.
16487   * @param {string}
16487 lineJoin Line join
16488   * @param {number} strokeWidth Stroke width
16489   * @param {number} miterLimit Miter limit
16490   * @return {number} Additional canvas size needed
16491   * @private
16492   */
16493  calculateLineJoinSize_(t, i, n) {
16494    if (i === 0 || this.points_ === 1 / 0 || t !== "bevel" && t !== "miter")
16495      return i;
16496    let s = this.radius_, r = this.radius2_ === void 0 ? s : this.radius2_;
16497    if (s < r) {
16498      const w = s;
16499      s = r, r = w;
16500    }
16501    const o = this.radius2_ === void 0 ? this.points_ : this.points_ * 2, a = 2 * Math.PI / o, l = r * Math.sin(a), h = Math.sqrt(r * r - l * l), c = s - h, u = Math.sqrt(l * l + c * c), d = u / l;
16502    if (t === "miter" && d <= n)
16503      return d * i;
16504    const f = i / 2 / d, g = i / 2 * (c / u), _ = Math.sqrt((s + f) * (s + f) + g * g) - s;
16505    if (this.radius2_ === void 0 || t === "bevel")
16506      return _ * 2;
16507    const p = s * Math.sin(a), y = Math.sqrt(s * s - p * p), x = r - y, M = Math.sqrt(p * p + x * x) / p;
16508    if (M <= n) {
16509      const w = M * i / 2 - r - s;
16510      return 2 * Math.max(_, w);
16511    }
16512    return _ * 2;
16513  }
16514  /**
16515   * @return {RenderOptions}  The render options
16516   * @protected
16517   */
16518  createRenderOptions() {
16519    let t = Os, i = 0, n = null, s = 0, r, o = 0;
16520    this.stroke_ && (r = this.stroke_.getColor(), r === null && (r = br), r = li(r), o = this.stroke_.getWidth(), o === void 0 && (o = Sr), n = this.stroke_.getLineDash(), s = this.stroke_.getLineDashOffset(), t = this.stroke_.getLineJoin(), t === void 0 && (t = Os), i = this.stroke_.getMiterLimit(), i === void 0 && (i = Mr));
16521    const a = this.calculateLineJoinSize_(t, o, i), l = Math.max(this.radius_, this.radius2_ || 0), h = Math.ceil(2 * l + a);
16522    return {
16523      strokeStyle: r,
16524      strokeWidth: o,
16525      size: h,
16526      lineDash: n,
16527      lineDashOffset: s,
16528      lineJoin: t,
16529      miterLimit: i
16530    };
16531  }
16532  /**
16533   * @protected
16534   */
16535  render() {
16536    this.renderOptions_ = this.createRenderOptions();
16537    const t = this.renderOptions_.size;
16538    this.canvas_ = {}, this.size_ = [t, t];
16539  }
16540  /**
16541   * @private
16542   * @param {RenderOptions} renderOptions Render options.
16543   * @param {CanvasRenderingContext2D} context The rendering context.
16544   * @param {number} pixelRatio The pixel ratio.
16545   */
16546  draw_(t, i, n) {
16547    if (i.scale(n, n), i.translate(t.size / 2, t.size / 2), this.createPath_(i), this.fill_) {
16548      let s = this.fill_.getColor();
16549      s === null && (s = Si), i.fillStyle = li(s), i.fill();
16550    }
16551    this.stroke_ && (i.strokeStyle = t.strokeStyle, i.lineWidth = t.strokeWidth, t.lineDash && (i.setLineDash(t.lineDash), i.lineDashOffset = t.lineDashOffset), i.lineJoin = t.lineJoin, i.miterLimit = t.miterLimit, i.stroke());
16552  }
16553  /**
16554   * @private
16555   * @param {RenderOptions} renderOptions Render options.
16556   */
16557  createHitDetectionCanvas_(t) {
16558    if (this.fill_) {
16559      let i = this.fill_.getColor(), n = 0;
16560      if (typeof i == "string" && (i = Wo(i)), i === null ? n = 1 : Array.isArray(i) && (n = i.length === 4 ? i[3] : 1), n === 0) {
16561        const s = he(
16562          t.size,
16563          t.size
16564        );
16565        this.hitDetectionCanvas_ = s.canvas, this.drawHitDetectionCanvas_(t, s);
16566      }
16567    }
16568    this.hitDetectionCanvas_ || (this.hitDetectionCanvas_ = this.getImage(1));
16569  }
16570  /**
16571   * @private
16572   * @param {CanvasRenderingContext2D} context The context to draw in.
16573   */
16574  createPath_(t) {
16575    let i = this.points_;
16576    const n = this.radius_;
16577    if (i === 1 / 0)
16578      t.arc(0, 0, n, 0, 2 * Math.PI);
16579    else {
16580      const s = this.radius2_ === void 0 ? n : this.radius2_;
16581      this.radius2_ !== void 0 && (i *= 2);
16582      const r = this.angle_ - Math.PI / 2, o = 2 * Math.PI / i;
16583      for (let a = 0; a < i; a++) {
16584        const l = r + a * o, h = a % 2 === 0 ? n : s;
16585        t.lineTo(h * Math.cos(l), h * Math.sin(l));
16586      }
16587      t.closePath();
16588    }
16589  }
16590  /**
16591   * @private
16592   * @param {RenderOptions} renderOptions Render options.
16593   * @param {CanvasRenderingContext2D} context The context.
16594   */
16595  drawHitDetectionCanvas_(t, i) {
16596    i.translate(t.size / 2, t.size / 2), this.createPath_(i), i.fillStyle = Si, i.fill(), this.stroke_ && (i.strokeStyle = t.strokeStyle, i.lineWidth = t.strokeWidth, t.lineDash && (i.setLineDash(t.lineDash), i.lineDashOffset = t.lineDashOffset), i.lineJoin = t.lineJoin, i.miterLimit = t.miter
16596Limit, i.stroke());
16597  }
16598}
16599const Bg = rc;
16600class oc extends Bg {
16601  /**
16602   * @param {Options} [options] Options.
16603   */
16604  constructor(t) {
16605    t = t || { radius: 5 }, super({
16606      points: 1 / 0,
16607      fill: t.fill,
16608      radius: t.radius,
16609      stroke: t.stroke,
16610      scale: t.scale !== void 0 ? t.scale : 1,
16611      rotation: t.rotation !== void 0 ? t.rotation : 0,
16612      rotateWithView: t.rotateWithView !== void 0 ? t.rotateWithView : !1,
16613      displacement: t.displacement !== void 0 ? t.displacement : [0, 0],
16614      declutterMode: t.declutterMode
16615    });
16616  }
16617  /**
16618   * Clones the style.
16619   * @return {CircleStyle} The cloned style.
16620   * @api
16621   */
16622  clone() {
16623    const t = this.getScale(), i = new oc({
16624      fill: this.getFill() ? this.getFill().clone() : void 0,
16625      stroke: this.getStroke() ? this.getStroke().clone() : void 0,
16626      radius: this.getRadius(),
16627      scale: Array.isArray(t) ? t.slice() : t,
16628      rotation: this.getRotation(),
16629      rotateWithView: this.getRotateWithView(),
16630      displacement: this.getDisplacement().slice(),
16631      declutterMode: this.getDeclutterMode()
16632    });
16633    return i.setOpacity(this.getOpacity()), i;
16634  }
16635  /**
16636   * Set the circle radius.
16637   *
16638   * @param {number} radius Circle radius.
16639   * @api
16640   */
16641  setRadius(t) {
16642    this.radius_ = t, this.render();
16643  }
16644}
16645const Fs = oc;
16646class $i {
16647  /**
16648   * @param {Options} [options] Style options.
16649   */
16650  constructor(t) {
16651    t = t || {}, this.geometry_ = null, this.geometryFunction_ = Hu, t.geometry !== void 0 && this.setGeometry(t.geometry), this.fill_ = t.fill !== void 0 ? t.fill : null, this.image_ = t.image !== void 0 ? t.image : null, this.renderer_ = t.renderer !== void 0 ? t.renderer : null, this.hitDetectionRenderer_ = t.hitDetectionRenderer !== void 0 ? t.hitDetectionRenderer : null, this.stroke_ = t.stroke !== void 0 ? t.stroke : null, this.text_ = t.text !== void 0 ? t.text : null, this.zIndex_ = t.zIndex;
16652  }
16653  /**
16654   * Clones the style.
16655   * @return {Style} The cloned style.
16656   * @api
16657   */
16658  clone() {
16659    let t = this.getGeometry();
16660    return t && typeof t == "object" && (t = /** @type {import("../geom/Geometry.js").default} */
16661    t.clone()), new $i({
16662      geometry: t,
16663      fill: this.getFill() ? this.getFill().clone() : void 0,
16664      image: this.getImage() ? this.getImage().clone() : void 0,
16665      renderer: this.getRenderer(),
16666      stroke: this.getStroke() ? this.getStroke().clone() : void 0,
16667      text: this.getText() ? this.getText().clone() : void 0,
16668      zIndex: this.getZIndex()
16669    });
16670  }
16671  /**
16672   * Get the custom renderer function that was configured with
16673   * {@link #setRenderer} or the `renderer` constructor option.
16674   * @return {RenderFunction|null} Custom renderer function.
16675   * @api
16676   */
16677  getRenderer() {
16678    return this.renderer_;
16679  }
16680  /**
16681   * Sets a custom renderer function for this style. When set, `fill`, `stroke`
16682   * and `image` options of the style will be ignored.
16683   * @param {RenderFunction|null} renderer Custom renderer function.
16684   * @api
16685   */
16686  setRenderer(t) {
16687    this.renderer_ = t;
16688  }
16689  /**
16690   * Sets a custom renderer function for this style used
16691   * in hit detection.
16692   * @param {RenderFunction|null} renderer Custom renderer function.
16693   * @api
16694   */
16695  setHitDetectionRenderer(t) {
16696    this.hitDetectionRenderer_ = t;
16697  }
16698  /**
16699   * Get the custom renderer function that was configured with
16700   * {@link #setHitDetectionRenderer} or the `hitDetectionRenderer` constructor option.
16701   * @return {RenderFunction|null} Custom renderer function.
16702   * @api
16703   */
16704  getHitDetectionRenderer() {
16705    return this.hitDetectionRenderer_;
16706  }
16707  /**
16708   * Get the geometry to be rendered.
16709   * @return {string|import("../geom/Geometry.js").default|GeometryFunction}
16710   * Feature property or geometry or function that returns the geometry that will
16711   * be rendered with this style.
16712   * @api
16713   */
16714  getGeometry() {
16715    return this.geometry_;
16716  }
16717  /**
16718   * Get the function used to generate a geometry for rendering.
16719   * @return {!GeometryFunction} Function that is called with a feature
16720   * and returns the geometry to render instead of the feature's geometry.
16721   * @api
16722   */
16723  getGeometryFunction() {
16724    return this.geometryFunction_;
16725  }
16726  /**
16727   * Get the fill style.
16728   * @return {import("./Fill.js").default} Fill style.
16729   * @api
16730   */
16731  getFill() {
16732    return this.fill_;
16733  }
16734  /**
16735   * Set the fill style.
16736   * @param {import("./Fill.js").default} fill Fill style.
16737   * @api
16738   */
16739  setFill(t) {
16740    this.fill_ = t;
16741  }
16742  /**
16743   * Get the image style.
16744   * @return {import("./Image.js").default} Image style.
16745   * @api
16746   */
16747  getImage() {
16748    return this.image_;
16749  }
16750  /**
16751   * Set the image style.
16752   * @param {import("./Image.js").default} image Image style.
16753   * @api
16754   */
16755  setImage(t) {
16756    this.image_ = t;
16757  }
16758  /**
16759   * Get the stroke style.
16760   * @return {import("./Stroke.js").default} Stroke style.
16761   * @api
16762   */
16763  getStroke() {
16764    return this.stroke_;
16765  }
16766  /**
16767   * Set the stroke style.
16768   * @param {import("./Stroke.js").default} stroke Stroke style.
16769   * @api
16770   */
16771  setStroke(t) {
16772    this.stroke_ = t;
16773  }
16774  /**
16775   * Get the text style.
16776   * @return {import("./Text.js").default} Text style.
16777   * @api
16778   */
16779  getText() {
16780    return this.text_;
16781  }
16782  /**
16783   * Set the text style.
16784   * @param {import("./Text.js").default} text Text style.
16785   * @api
16786   */
16787  setText(t) {
16788    this.text_ = t;
16789  }
16790  /**
16791   * Get the z-index for the style.
16792   * @return {number|undefined} ZIndex.
16793   * @api
16794   */
16795  getZIndex() {
16796    return this.zIndex_;
16797  }
16798  /**
16799   * Set a geometry that is rendered instead of the feature's geometry.
16800   *
16801   * @param {string|import("../geom/Geometry.js").default|GeometryFunction} geometry
16802   *     Feature property or geometry or function returning a geometry to render
16803   *     for this style.
16804   * @api
16805   */
16806  setGeometry(t) {
16807    typeof t == "function" ? this.geometryFunction_ = t : typeof t == "string" ? this.geometryFunction_ = function(i) {
16808      return (
16809        /** @type {import("../geom/Geometry.js").default} */
16810        i.get(t)
16811      );
16812    } : t ? t !== void 0 && (this.geometryFunction_ = function() {
16813      return (
16814        /** @type {import("../geom/Geometry.js").default} */
16815        t
16816      );
16817    }) : this.geometryFunction_ = Hu, this.geometry_ = t;
16818  }
16819  /**
16820   * Set the z-index.
16821   *
16822   * @param {number|undefined} zIndex ZIndex.
16823   * @api
16824   */
16825  setZIndex(t) {
16826    this.zIndex_ = t;
16827  }
16828}
16829function tb(e) {
16830  let t;
16831  if (typeof e == "function")
16832    t = e;
16833  else {
16834    let i;
16835    Array.isArray(e) ? i = e : (ht(typeof /** @type {?} */
16836    e.getZIndex == "function", 41), i = [
16837      /** @type {Style} */
16838      e
16839    ]), t = function() {
16840      return i;
16841    };
16842  }
16843  return t;
16844}
16845let qa = null;
16846function eb(e, t) {
16847  if (!qa) {
16848    const i = new Ye({
16849      color: "rgba(255,255,255,0.4)"
16850    }), n = new Ke({
16851      color: "#3399CC",
16852      width: 1.25
16853    });
16854    qa = [
16855      new $i({
16856        image: new Fs({
16857          fill: i,
16858          stroke: n,
16859          radius: 5
16860        }),
16861        fill: i,
16862        stroke: n
16863      })
16864    ];
16865  }
16866  return qa;
16867}
16868function Ug() {
16869  const e = {}, t = [255, 255, 255, 1], i = [0, 153, 255, 1], n = 3;
16870  return e.Polygon = [
16871    new $i({
16872      fill: new Ye({
16873        color: [255, 255, 255, 0.5]
16874      })
16875    })
16876  ], e.MultiPolygon = e.Polygon, e.LineString = [
16877    new $i({
16878      stroke: new Ke({
16879        color: t,
16880        width: n + 2
16881      })
16882    }),
16883    new $i({
16884      stroke: new Ke({
16885        color: i,
16886        width: n
16887      })
16888    })
16889  ], e.MultiLineString = e.LineString, e.Circle = e.Polygon.concat(e.LineString), e.Point = [
16890    new $i({
16891      image: new Fs({
16892        radius: n * 2,
16893        fill: new Ye({
16894          color: i
16895        }),
16896        stroke: new Ke({
16897          color: t,
16898          width: n / 2
16899        })
16900      }),
16901      zIndex: 1 / 0
16902    })
16903  ], e.MultiPoint = e.Point, e.GeometryCollection = e.Polygon.concat(
16904    e.LineString,
16905    e.Point
16906  ), e;
16907}
16908function Hu(e) {
16909  return e.getGeometry();
16910}
16911const Sn = $i, ib = "#333";
16912class ac {
16913  /**
16914   * @param {Options} [options] Options.
16915   */
16916  constructor(t) {
16917    t = t || {}, this.font_ = t.font, this.rotation_ = t.rotation, this.rotateWithView_ = t.rotateWithView, this.scale_ = t.scale, this.scaleArray_ = Ce(t.scale !== void 0 ? t.scale : 1), this.text_ = t.text, this.textAlign_ = t.textAlign, this.justify_ = t.justify, this.repeat_ = t.repeat, this.textBaseline_ = t.textBaseline, this.fill_ = t.fill !== void 0 ? t.fill : new Ye({ color: ib }), this.maxAngle_ = t.maxAngle !== void 0 ? t.maxAngle : Math.PI / 4, this.placement_ = t.placement !== void 0 ? t.placement : "point", this.overflow_ = !!t.overflow, this.stroke_ = t.stroke !== void 0 ? t.stroke : null, this.offsetX_ = t.offsetX !== void 0 ? t.offsetX : 0, this.offsetY_ = t.offsetY !== void 0 ? t.offsetY : 0, this.backgroundFill_ = t.backgroundFill ? t.backgroundFill : null, this.backgroundStroke_ = t.backgroundStroke ? t.backgroundStroke : null, this.padding_ = t.padding === void 0 ? null : t.padding;
16918  }
16919  /**
16920   * Clones the style.
16921   * @return {Text} The cloned style.
16922   * @api
16923   */
16924  clone() {
16925    const t = this.getScale();
16926    return new ac({
16927      font: this.getFont(),
16928      placement: this.getPlacement(),
16929      repeat: this.getRepeat(),
16930      maxAngle: this.getMaxAngle(),
16931      overflow: this.getOverflow(),
16932      rotation: this.getRotation(),
16933      rotateWithView: this.getRotateWithView(),
16934      scale: Array.isArray(t) ? t.slice() : t,
16935      text: this.getText(),
16936      textAlign: this.getTextAlign(),
16937      justify: this.getJustify(),
16938      textBaseline: this.getTextBaseline(),
16939      fill: this.getFill() ? this.getFill().clone() : void 0,
16940      stroke: this.getStroke() ? this.getStroke().clone() : void 0,
16941      offsetX: this.getOffsetX(),
16942      offsetY: this.getOffsetY(),
16943      backgroundFill: this.getBackgroundFill() ? this.getBackgroundFill().clone() : void 0,
16944      backgroundStroke: this.getBackgroundStroke() ? this.getBackgroundStroke().clone() : void 0,
16945      padding: this.getPadding() || void 0
16946    });
16947  }
16948  /**
16949   * Get the `overflow` configuration.
16950   * @return {boolean} Let text overflow the length of the path they follow.
16951   * @api
16952   */
16953  getOverflow() {
16954    return this.overflow_;
16955  }
16956  /**
16957   * Get the font name.
16958   * @return {string|undefined} Font.
16959   * @api
16960   */
16961  getFont() {
16962    return this.font_;
16963  }
16964  /**
16965   * Get the maximum angle between adjacent characters.
16966   * @return {number} Angle in radians.
16967   * @api
16968   */
16969  getMaxAngle() {
16970    return this.maxAngle_;
16971  }
16972  /**
16973   * Get the label placement.
16974   * @return {TextPlacement} Text placement.
16975   * @api
16976   */
16977  getPlacement() {
16978    return this.placement_;
16979  }
16980  /**
16981   * Get the repeat interval of the text.
16982   * @return {number|undefined} Repeat interval in pixels.
16983   * @api
16984   */
16985  getRepeat() {
16986    return this.repeat_;
16987  }
16988  /**
16989   * Get the x-offset for the text.
16990   * @return {number} Horizontal text offset.
16991   * @api
16992   */
16993  getOffsetX() {
16994    return this.offsetX_;
16995  }
16996  /**
16997   * Get the y-offset for the text.
16998   * @return {number} Vertical text offset.
16999   * @api
17000   */
17001  getOffsetY() {
17002    return this.offsetY_;
17003  }
17004  /**
17005   * Get the fill style for the text.
17006   * @return {import("./Fill.js").default} Fill style.
17007   * @api
17008   */
17009  getFill() {
17010    return this.fill_;
17011  }
17012  /**
17013   * Determine whether the text rotates with the map.
17014   * @return {boolean|undefined} Rotate with map.
17015   * @api
17016   */
17017  getRotateWithView() {
17018    return this.rotateWithView_;
17019  }
17020  /**
17021   * Get the text rotation.
17022   * @return {number|undefined} Rotation.
17023   * @api
17024   */
17025  getRotation() {
17026    return this.rotation_;
17027  }
17028  /**
17029   * Get the text scale.
17030   * @return {number|import("../size.js").Size|undefined} Scale.
17031   * @api
17032   */
17033  getScale() {
17034    return this.scale_;
17035  }
17036  /**
17037   * Get the symbolizer scale array.
17038   * @return {import("../size.js").Size} Scale array.
17039   */
17040  getScaleArray() {
17041    return this.scaleArray_;
17042  }
17043  /**
17044   * Get the stroke style for the text.
17045   * @return {import("./Stroke.js").default} Stroke style.
17046   * @api
17047   */
17048  getStroke() {
17049    return this.stroke_;
17050  }
17051  /**
17052   * Get the text to be rendered.
17053   * @return {string|Array<string>|undefined} Text.
17054   * @api
17055   */
17056  getText() {
17057    return this.text_;
17058  }
17059  /**
17060   * Get the text alignment.
17061   * @return {CanvasTextAlign|undefined} Text align.
17062   * @api
17063   */
17064  getTextAlign() {
17065    return this.textAlign_;
17066  }
17067  /**
17068   * Get the justification.
17069   * @return {TextJustify|undefined} Justification.
17070   * @api
17071   */
17072  getJustify() {
17073    return this.justify_;
17074  }
17075  /**
17076   * Get the text baseline.
17077   * @return {CanvasTextBaseline|undefined} Text baseline.
17078   * @api
17079   */
17080  getTextBaseline() {
17081    return this.textBaseline_;
17082  }
17083  /**
17084   * Get the background fill style for the text.
17085   * @return {import("./Fill.js").default} Fill style.
17086   * @api
17087   */
vendor: 9,852 bytes, lines 17088-17473
17088  getBackgroundFill() {
17089    return this.backgroundFill_;
17090  }
17091  /**
17092   * Get the background stroke style for the text.
17093   * @return {import("./Stroke.js").default} Stroke style.
17094   * @api
17095   */
17096  getBackgroundStroke() {
17097    return this.backgroundStroke_;
17098  }
17099  /**
17100   * Get the padding for the text.
17101   * @return {Array<number>|null} Padding.
17102   * @api
17103   */
17104  getPadding() {
17105    return this.padding_;
17106  }
17107  /**
17108   * Set the `overflow` property.
17109   *
17110   * @param {boolean} overflow Let text overflow the path that it follows.
17111   * @api
17112   */
17113  setOverflow(t) {
17114    this.overflow_ = t;
17115  }
17116  /**
17117   * Set the font.
17118   *
17119   * @param {string|undefined} font Font.
17120   * @api
17121   */
17122  setFont(t) {
17123    this.font_ = t;
17124  }
17125  /**
17126   * Set the maximum angle between adjacent characters.
17127   *
17128   * @param {number} maxAngle Angle in radians.
17129   * @api
17130   */
17131  setMaxAngle(t) {
17132    this.maxAngle_ = t;
17133  }
17134  /**
17135   * Set the x offset.
17136   *
17137   * @param {number} offsetX Horizontal text offset.
17138   * @api
17139   */
17140  setOffsetX(t) {
17141    this.offsetX_ = t;
17142  }
17143  /**
17144   * Set the y offset.
17145   *
17146   * @param {number} offsetY Vertical text offset.
17147   * @api
17148   */
17149  setOffsetY(t) {
17150    this.offsetY_ = t;
17151  }
17152  /**
17153   * Set the text placement.
17154   *
17155   * @param {TextPlacement} placement Placement.
17156   * @api
17157   */
17158  setPlacement(t) {
17159    this.placement_ = t;
17160  }
17161  /**
17162   * Set the repeat interval of the text.
17163   * @param {number|undefined} [repeat] Repeat interval in pixels.
17164   * @api
17165   */
17166  setRepeat(t) {
17167    this.repeat_ = t;
17168  }
17169  /**
17170   * Set whether to rotate the text with the view.
17171   *
17172   * @param {boolean} rotateWithView Rotate with map.
17173   * @api
17174   */
17175  setRotateWithView(t) {
17176    this.rotateWithView_ = t;
17177  }
17178  /**
17179   * Set the fill.
17180   *
17181   * @param {import("./Fill.js").default} fill Fill style.
17182   * @api
17183   */
17184  setFill(t) {
17185    this.fill_ = t;
17186  }
17187  /**
17188   * Set the rotation.
17189   *
17190   * @param {number|undefined} rotation Rotation.
17191   * @api
17192   */
17193  setRotation(t) {
17194    this.rotation_ = t;
17195  }
17196  /**
17197   * Set the scale.
17198   *
17199   * @param {number|import("../size.js").Size|undefined} scale Scale.
17200   * @api
17201   */
17202  setScale(t) {
17203    this.scale_ = t, this.scaleArray_ = Ce(t !== void 0 ? t : 1);
17204  }
17205  /**
17206   * Set the stroke.
17207   *
17208   * @param {import("./Stroke.js").default} stroke Stroke style.
17209   * @api
17210   */
17211  setStroke(t) {
17212    this.stroke_ = t;
17213  }
17214  /**
17215   * Set the text.
17216   *
17217   * @param {string|Array<string>|undefined} text Text.
17218   * @api
17219   */
17220  setText(t) {
17221    this.text_ = t;
17222  }
17223  /**
17224   * Set the text alignment.
17225   *
17226   * @param {CanvasTextAlign|undefined} textAlign Text align.
17227   * @api
17228   */
17229  setTextAlign(t) {
17230    this.textAlign_ = t;
17231  }
17232  /**
17233   * Set the justification.
17234   *
17235   * @param {TextJustify|undefined} justify Justification.
17236   * @api
17237   */
17238  setJustify(t) {
17239    this.justify_ = t;
17240  }
17241  /**
17242   * Set the text baseline.
17243   *
17244   * @param {CanvasTextBaseline|undefined} textBaseline Text baseline.
17245   * @api
17246   */
17247  setTextBaseline(t) {
17248    this.textBaseline_ = t;
17249  }
17250  /**
17251   * Set the background fill.
17252   *
17253   * @param {import("./Fill.js").default} fill Fill style.
17254   * @api
17255   */
17256  setBackgroundFill(t) {
17257    this.backgroundFill_ = t;
17258  }
17259  /**
17260   * Set the background stroke.
17261   *
17262   * @param {import("./Stroke.js").default} stroke Stroke style.
17263   * @api
17264   */
17265  setBackgroundStroke(t) {
17266    this.backgroundStroke_ = t;
17267  }
17268  /**
17269   * Set the padding (`[top, right, bottom, left]`).
17270   *
17271   * @param {Array<number>|null} padding Padding.
17272   * @api
17273   */
17274  setPadding(t) {
17275    this.padding_ = t;
17276  }
17277}
17278const nb = ac;
17279function sb(e, t, i, n, s) {
17280  Xg(e, t, i || 0, n || e.length - 1, s || rb);
17281}
17282function Xg(e, t, i, n, s) {
17283  for (; n > i; ) {
17284    if (n - i > 600) {
17285      var r = n - i + 1, o = t - i + 1, a = Math.log(r), l = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * l * (r - l) / r) * (o - r / 2 < 0 ? -1 : 1), c = Math.max(i, Math.floor(t - o * l / r + h)), u = Math.min(n, Math.floor(t + (r - o) * l / r + h));
17286      Xg(e, t, c, u, s);
17287    }
17288    var d = e[t], f = i, g = n;
17289    for (Ys(e, i, t), s(e[n], d) > 0 && Ys(e, i, n); f < g; ) {
17290      for (Ys(e, f, g), f++, g--; s(e[f], d) < 0; )
17291        f++;
17292      for (; s(e[g], d) > 0; )
17293        g--;
17294    }
17295    s(e[i], d) === 0 ? Ys(e, i, g) : (g++, Ys(e, g, n)), g <= t && (i = g + 1), t <= g && (n = g - 1);
17296  }
17297}
17298function Ys(e, t, i) {
17299  var n = e[t];
17300  e[t] = e[i], e[i] = n;
17301}
17302function rb(e, t) {
17303  return e < t ? -1 : e > t ? 1 : 0;
17304}
17305let $g = class {
17306  constructor(t = 9) {
17307    this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
17308  }
17309  all() {
17310    return this._all(this.data, []);
17311  }
17312  search(t) {
17313    let i = this.data;
17314    const n = [];
17315    if (!lo(t, i))
17316      return n;
17317    const s = this.toBBox, r = [];
17318    for (; i; ) {
17319      for (let o = 0; o < i.children.length; o++) {
17320        const a = i.children[o], l = i.leaf ? s(a) : a;
17321        lo(t, l) && (i.leaf ? n.push(a) : Za(t, l) ? this._all(a, n) : r.push(a));
17322      }
17323      i = r.pop();
17324    }
17325    return n;
17326  }
17327  collides(t) {
17328    let i = this.data;
17329    if (!lo(t, i))
17330      return !1;
17331    const n = [];
17332    for (; i; ) {
17333      for (let s = 0; s < i.children.length; s++) {
17334        const r = i.children[s], o = i.leaf ? this.toBBox(r) : r;
17335        if (lo(t, o)) {
17336          if (i.leaf || Za(t, o))
17337            return !0;
17338          n.push(r);
17339        }
17340      }
17341      i = n.pop();
17342    }
17343    return !1;
17344  }
17345  load(t) {
17346    if (!(t && t.length))
17347      return this;
17348    if (t.length < this._minEntries) {
17349      for (let n = 0; n < t.length; n++)
17350        this.insert(t[n]);
17351      return this;
17352    }
17353    let i = this._build(t.slice(), 0, t.length - 1, 0);
17354    if (!this.data.children.length)
17355      this.data = i;
17356    else if (this.data.height === i.height)
17357      this._splitRoot(this.data, i);
17358    else {
17359      if (this.data.height < i.height) {
17360        const n = this.data;
17361        this.data = i, i = n;
17362      }
17363      this._insert(i, this.data.height - i.height - 1, !0);
17364    }
17365    return this;
17366  }
17367  insert(t) {
17368    return t && this._insert(t, this.data.height - 1), this;
17369  }
17370  clear() {
17371    return this.data = Zn([]), this;
17372  }
17373  remove(t, i) {
17374    if (!t)
17375      return this;
17376    let n = this.data;
17377    const s = this.toBBox(t), r = [], o = [];
17378    let a, l, h;
17379    for (; n || r.length; ) {
17380      if (n || (n = r.pop(), l = r[r.length - 1], a = o.pop(), h = !0), n.leaf) {
17381        const c = ob(t, n.children, i);
17382        if (c !== -1)
17383          return n.children.splice(c, 1), r.push(n), this._condense(r), this;
17384      }
17385      !h && !n.leaf && Za(n, s) ? (r.push(n), o.push(a), a = 0, l = n, n = n.children[0]) : l ? (a++, n = l.children[a], h = !1) : n = null;
17386    }
17387    return this;
17388  }
17389  toBBox(t) {
17390    return t;
17391  }
17392  compareMinX(t, i) {
17393    return t.minX - i.minX;
17394  }
17395  compareMinY(t, i) {
17396    return t.minY - i.minY;
17397  }
17398  toJSON() {
17399    return this.data;
17400  }
17401  fromJSON(t) {
17402    return this.data = t, this;
17403  }
17404  _all(t, i) {
17405    const n = [];
17406    for (; t; )
17407      t.leaf ? i.push(...t.children) : n.push(...t.children), t = n.pop();
17408    return i;
17409  }
17410  _build(t, i, n, s) {
17411    const r = n - i + 1;
17412    let o = this._maxEntries, a;
17413    if (r <= o)
17414      return a = Zn(t.slice(i, n + 1)), Xn(a, this.toBBox), a;
17415    s || (s = Math.ceil(Math.log(r) / Math.log(o)), o = Math.ceil(r / Math.pow(o, s - 1))), a = Zn([]), a.leaf = !1, a.height = s;
17416    const l = Math.ceil(r / o), h = l * Math.ceil(Math.sqrt(o));
17417    Zu(t, i, n, h, this.compareMinX);
17418    for (let c = i; c <= n; c += h) {
17419      const u = Math.min(c + h - 1, n);
17420      Zu(t, c, u, l, this.compareMinY);
17421      for (let d = c; d <= u; d += l) {
17422        const f = Math.min(d + l - 1, u);
17423        a.children.push(this._build(t, d, f, s - 1));
17424      }
17425    }
17426    return Xn(a, this.toBBox), a;
17427  }
17428  _chooseSubtree(t, i, n, s) {
17429    for (; s.push(i), !(i.leaf || s.length - 1 === n); ) {
17430      let r = 1 / 0, o = 1 / 0, a;
17431      for (let l = 0; l < i.children.length; l++) {
17432        const h = i.children[l], c = Ha(h), u = hb(t, h) - c;
17433        u < o ? (o = u, r = c < r ? c : r, a = h) : u === o && c < r && (r = c, a = h);
17434      }
17435      i = a || i.children[0];
17436    }
17437    return i;
17438  }
17439  _insert(t, i, n) {
17440    const s = n ? t : this.toBBox(t), r = [], o = this._chooseSubtree(s, this.data, i, r);
17441    for (o.children.push(t), ir(o, s); i >= 0 && r[i].children.length > this._maxEntries; )
17442      this._split(r, i), i--;
17443    this._adjustParentBBoxes(s, r, i);
17444  }
17445  // split overflowed node into two
17446  _split(t, i) {
17447    const n = t[i], s = n.children.length, r = this._minEntries;
17448    this._chooseSplitAxis(n, r, s);
17449    const o = this._chooseSplitIndex(n, r, s), a = Zn(n.children.splice(o, n.children.length - o));
17450    a.height = n.height, a.leaf = n.leaf, Xn(n, this.toBBox), Xn(a, this.toBBox), i ? t[i - 1].children.push(a) : this._splitRoot(n, a);
17451  }
17452  _splitRoot(t, i) {
17453    this.data = Zn([t, i]), this.data.height = t.height + 1, this.data.leaf = !1, Xn(this.data, this.toBBox);
17454  }
17455  _chooseSplitIndex(t, i, n) {
17456    let s, r = 1 / 0, o = 1 / 0;
17457    for (let a = i; a <= n - i; a++) {
17458      const l = er(t, 0, a, this.toBBox), h = er(t, a, n, this.toBBox), c = cb(l, h), u = Ha(l) + Ha(h);
17459      c < r ? (r = c, s = a, o = u < o ? u : o) : c === r && u < o && (o = u, s = a);
17460    }
17461    return s || n - i;
17462  }
17463  // sorts node children by the best axis for split
17464  _chooseSplitAxis(t, i, n) {
17465    const s = t.leaf ? this.compareMinX : ab, r = t.leaf ? this.compareMinY : lb, o = this._allDistMargin(t, i, n, s), a = this._allDistMargin(t, i, n, r);
17466    o < a && t.children.sort(s);
17467  }
17468  // total margin of all possible split distributions where each node is at least m full
17469  _allDistMargin(t, i, n, s) {
17470    t.children.sort(s);
17471    const r = this.toBBox, o = er(t, 0, i, r), a = er(t, n - i, n, r);
17472    let l = ao(o) + ao(a);
17473    for (let h = i;
17473 h < n - i; h++) {
17474      const c = t.children[h];
17475      ir(o, t.leaf ? r(c) : c), l += ao(o);
17476    }
17477    for (let h = n - i - 1; h >= i; h--) {
17478      const c = t.children[h];
17479      ir(a, t.leaf ? r(c) : c), l += ao(a);
17480    }
17481    return l;
17482  }
17483  _adjustParentBBoxes(t, i, n) {
17484    for (let s = n; s >= 0; s--)
17485      ir(i[s], t);
17486  }
17487  _condense(t) {
17488    for (let i = t.length - 1, n; i >= 0; i--)
17489      t[i].children.length === 0 ? i > 0 ? (n = t[i - 1].children, n.splice(n.indexOf(t[i]), 1)) : this.clear() : Xn(t[i], this.toBBox);
17490  }
17491};
17492function ob(e, t, i) {
17493  if (!i)
17494    return t.indexOf(e);
17495  for (let n = 0; n < t.length; n++)
17496    if (i(e, t[n]))
17497      return n;
17498  return -1;
17499}
17500function Xn(e, t) {
17501  er(e, 0, e.children.length, t, e);
17502}
17503function er(e, t, i, n, s) {
17504  s || (s = Zn(null)), s.minX = 1 / 0, s.minY = 1 / 0, s.maxX = -1 / 0, s.maxY = -1 / 0;
17505  for (let r = t; r < i; r++) {
17506    const o = e.children[r];
17507    ir(s, e.leaf ? n(o) : o);
17508  }
17509  return s;
17510}
17511function ir(e, t) {
17512  return e.minX = Math.min(e.minX, t.minX), e.minY = Math.min(e.minY, t.minY), e.maxX = Math.max(e.maxX, t.maxX), e.maxY = Math.max(e.maxY, t.maxY), e;
17513}
17514function ab(e, t) {
17515  return e.minX - t.minX;
17516}
17517function lb(e, t) {
17518  return e.minY - t.minY;
17519}
17520function Ha(e) {
17521  return (e.maxX - e.minX) * (e.maxY - e.minY);
17522}
17523function ao(e) {
17524  return e.maxX - e.minX + (e.maxY - e.minY);
17525}
17526function hb(e, t) {
17527  return (Math.max(t.maxX, e.maxX) - Math.min(t.minX, e.minX)) * (Math.max(t.maxY, e.maxY) - Math.min(t.minY, e.minY));
17528}
17529function cb(e, t) {
17530  const i = Math.max(e.minX, t.minX), n = Math.max(e.minY, t.minY), s = Math.min(e.maxX, t.maxX), r = Math.min(e.maxY, t.maxY);
17531  return Math.max(0, s - i) * Math.max(0, r - n);
17532}
17533function Za(e, t) {
17534  return e.minX <= t.minX && e.minY <= t.minY && t.maxX <= e.maxX && t.maxY <= e.maxY;
17535}
17536function lo(e, t) {
17537  return t.minX <= e.maxX && t.minY <= e.maxY && t.maxX >= e.minX && t.maxY >= e.minY;
17538}
17539function Zn(e) {
17540  return {
17541    children: e,
17542    height: 1,
17543    leaf: !0,
17544    minX: 1 / 0,
17545    minY: 1 / 0,
17546    maxX: -1 / 0,
17547    maxY: -1 / 0
17548  };
17549}
17550function Zu(e, t, i, n, s) {
17551  const r = [t, i];
17552  for (; r.length; ) {
17553    if (i = r.pop(), t = r.pop(), i - t <= n)
17554      continue;
17555    const o = t + Math.ceil((i - t) / n / 2) * n;
17556    sb(e, o, t, i, s), r.push(t, o, o, i);
17557  }
17558}
17559class ub extends zr {
17560  /**
17561   * @param {import("./extent.js").Extent} extent Extent.
17562   * @param {number|undefined} resolution Resolution.
17563   * @param {number} pixelRatio Pixel ratio.
17564   * @param {import("./ImageState.js").default} state State.
17565   */
17566  constructor(t, i, n, s) {
17567    super(), this.extent = t, this.pixelRatio_ = n, this.resolution = i, this.state = s;
17568  }
17569  /**
17570   * @protected
17571   */
17572  changed() {
17573    this.dispatchEvent(et.CHANGE);
17574  }
17575  /**
17576   * @return {import("./extent.js").Extent} Extent.
17577   */
17578  getExtent() {
17579    return this.extent;
17580  }
17581  /**
17582   * @abstract
17583   * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
17584   */
17585  getImage() {
17586    return Q();
17587  }
17588  /**
17589   * @return {number} PixelRatio.
17590   */
17591  getPixelRatio() {
17592    return this.pixelRatio_;
17593  }
17594  /**
17595   * @return {number} Resolution.
17596   */
17597  getResolution() {
17598    return (
17599      /** @type {number} */
17600      this.resolution
17601    );
17602  }
17603  /**
17604   * @return {import("./ImageState.js").default} State.
17605   */
17606  getState() {
17607    return this.state;
17608  }
17609  /**
17610   * Load not yet loaded URI.
17611   * @abstract
17612   */
17613  load() {
17614    Q();
17615  }
17616}
17617const Yg = ub;
17618class db extends Yg {
17619  /**
17620   * @param {import("./extent.js").Extent} extent Extent.
17621   * @param {number|undefined} resolution Resolution.
17622   * @param {number} pixelRatio Pixel ratio.
17623   * @param {string} src Image source URI.
17624   * @param {?string} crossOrigin Cross origin.
17625   * @param {LoadFunction} imageLoadFunction Image load function.
17626   * @param {CanvasRenderingContext2D} [context] Canvas context. When provided, the image will be
17627   *    drawn into the context's canvas, and `getImage()` will return the canvas once the image
17628   *    has finished loading.
17629   */
17630  constructor(t, i, n, s, r, o, a) {
17631    super(t, i, n, at.IDLE), this.src_ = s, this.image_ = new Image(), r !== null && (this.image_.crossOrigin = r), this.context_ = a, this.unlisten_ = null, this.state = at.IDLE, this.imageLoadFunction_ = o;
17632  }
17633  /**
17634   * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
17635   * @api
17636   */
17637  getImage() {
17638    if (this.state == at.LOADED && this.context_ && !(this.image_ instanceof HTMLCanvasElement)) {
17639      const t = this.context_.canvas;
17640      t.width = this.image_.width, t.height = this.image_.height, this.context_.drawImage(this.image_, 0, 0
17640), this.image_ = this.context_.canvas;
17641    }
17642    return this.image_;
17643  }
17644  /**
17645   * Tracks loading or read errors.
17646   *
17647   * @private
17648   */
17649  handleImageError_() {
17650    this.state = at.ERROR, this.unlistenImage_(), this.changed();
17651  }
17652  /**
17653   * Tracks successful image load.
17654   *
17655   * @private
17656   */
17657  handleImageLoad_() {
17658    this.resolution === void 0 && (this.resolution = qt(this.extent) / this.image_.height), this.state = at.LOADED, this.unlistenImage_(), this.changed();
17659  }
17660  /**
17661   * Load the image or retry if loading previously failed.
17662   * Loading is taken care of by the tile queue, and calling this method is
17663   * only needed for preloading or for reloading in case of an error.
17664   * @api
17665   */
17666  load() {
17667    (this.state == at.IDLE || this.state == at.ERROR) && (this.state = at.LOADING, this.changed(), this.imageLoadFunction_(this, this.src_), this.unlisten_ = lc(
17668      this.image_,
17669      this.handleImageLoad_.bind(this),
17670      this.handleImageError_.bind(this)
17671    ));
17672  }
17673  /**
17674   * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
17675   */
17676  setImage(t) {
17677    this.image_ = t, this.resolution = qt(this.extent) / this.image_.height;
17678  }
17679  /**
17680   * Discards event handlers which listen for load completion or errors.
17681   *
17682   * @private
17683   */
17684  unlistenImage_() {
17685    this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
17686  }
17687}
17688function lc(e, t, i) {
17689  const n = (
17690    /** @type {HTMLImageElement} */
17691    e
17692  );
17693  let s = !0, r = !1, o = !1;
17694  const a = [
17695    jo(n, et.LOAD, function() {
17696      o = !0, r || t();
17697    })
17698  ];
17699  return n.src && WE ? (r = !0, n.decode().then(function() {
17700    s && t();
17701  }).catch(function(l) {
17702    s && (o ? t() : i());
17703  })) : a.push(jo(n, et.ERROR, i)), function() {
17704    s = !1, a.forEach(St);
17705  };
17706}
17707const fb = db;
17708let Ks = null;
17709class gb extends zr {
17710  /**
17711   * @param {HTMLImageElement|HTMLCanvasElement} image Image.
17712   * @param {string|undefined} src Src.
17713   * @param {import("../size.js").Size} size Size.
17714   * @param {?string} crossOrigin Cross origin.
17715   * @param {import("../ImageState.js").default} imageState Image state.
17716   * @param {import("../color.js").Color} color Color.
17717   */
17718  constructor(t, i, n, s, r, o) {
17719    super(), this.hitDetectionImage_ = null, this.image_ = t, this.crossOrigin_ = s, this.canvas_ = {}, this.color_ = o, this.unlisten_ = null, this.imageState_ = r, this.size_ = n, this.src_ = i, this.tainted_;
17720  }
17721  /**
17722   * @private
17723   */
17724  initializeImage_() {
17725    this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_);
17726  }
17727  /**
17728   * @private
17729   * @return {boolean} The image canvas is tainted.
17730   */
17731  isTainted_() {
17732    if (this.tainted_ === void 0 && this.imageState_ === at.LOADED) {
17733      Ks || (Ks = he(1, 1, void 0, {
17734        willReadFrequently: !0
17735      })), Ks.drawImage(this.image_, 0, 0);
17736      try {
17737        Ks.getImageData(0, 0, 1, 1), this.tainted_ = !1;
17738      } catch {
17739        Ks = null, this.tainted_ = !0;
17740      }
17741    }
17742    return this.tainted_ === !0;
17743  }
17744  /**
17745   * @private
17746   */
17747  dispatchChangeEvent_() {
17748    this.dispatchEvent(et.CHANGE);
17749  }
17750  /**
17751   * @private
17752   */
17753  handleImageError_() {
17754    this.imageState_ = at.ERROR, this.unlistenImage_(), this.dispatchChangeEvent_();
17755  }
17756  /**
17757   * @private
17758   */
17759  handleImageLoad_() {
17760    this.imageState_ = at.LOADED, this.size_ ? (this.image_.width = this.size_[0], this.image_.height = this.size_[1]) : this.size_ = [this.image_.width, this.image_.height], this.unlistenImage_(), this.dispatchChangeEvent_();
17761  }
17762  /**
17763   * @param {number} pixelRatio Pixel ratio.
17764   * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
17765   */
17766  getImage(t) {
17767    return this.image_ || this.initializeImage_(), this.replaceColor_(t), this.canvas_[t] ? this.canvas_[t] : this.image_;
17768  }
17769  /**
17770   * @param {number} pixelRatio Pixel ratio.
17771   * @return {number} Image or Canvas element.
17772   */
17773  getPixelRatio(t) {
17774    return this.replaceColor_(t), this.canvas_[t] ? t : 1;
17775  }
17776  /**
17777   * @return {import("../ImageState.js").default} Image state.
17778   */
17779  getImageState() {
17780    return this.imageState_;
17781  }
17782  /**
17783   * @return {HTMLImageElement|HTMLCanvasElement} Image element.
17784   */
17785  getHitDetectionImage() {
17786    if (this.image_ || this.initializeImage_(), !this.hitDetectionImage_)
17787      if (this.isTainted_()) {
17788        const t = this.size_[0], i = this.size_[1], n = he(t, i);
17789        n.fillRect(0, 0, t, i), this.hitDetectionImage_ = n.canvas;
17790      } else
17791        this.hitDetectionImage_ = this.image_;
17792    return this.hitDetectionImage_;
17793  }
17794  /**
17795   * Get the size of the icon (in pixels).
17796   * @return {import("../size.js").Size} Image size.
17797   */
17798  getSize() {
17799    return this.size_;
17800  }
17801  /**
17802   * @return {string|undefined} Image src.
17803   */
17804  getSrc() {
17805    return this.src_;
17806  }
17807  /**
17808   * Load not yet loaded URI.
17809   */
17810  load() {
17811    if (this.imageState_ === at.IDLE) {
17812      this.image_ || this.initializeImage_(), this.imageState_ = at.LOADING;
17813      try {
17814        this.image_.src = this.src_;
17815      } catch {
17816        this.handleImageError_();
17817      }
17818      this.unlisten_ = lc(
17819        this.image_,
17820        this.handleImageLoad_.bind(this),
17821        this.handleImageError_.bind(this)
17822      );
17823    }
17824  }
17825  /**
17826   * @param {number} pixelRatio Pixel ratio.
17827   * @private
17828   */
17829  replaceColor_(t) {
17830    if (!this.color_ || this.canvas_[t] || this.imageState_ !== at.LOADED)
17831      return;
17832    const i = this.image_, n = document.createElement("canvas");
17833    n.width = Math.ceil(i.width * t), n.height = Math.ceil(i.height * t);
17834    const s = n.getContext("2d");
17835    s.scale(t, t), s.drawImage(i, 0, 0), s.globalCompositeOperation = "multiply", s.fillStyle = ug(this.color_), s.fillRect(0, 0, n.width / t, n.height / t), s.globalCompositeOperation = "destination-in", s.drawImage(i, 0, 0), this.canvas_[t] = n;
17836  }
17837  /**
17838   * Discards event handlers which listen for load completion or errors.
17839   *
17840   * @private
17841   */
17842  unlistenImage_() {
17843    this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
17844  }
17845}
17846function mb(e, t, i, n, s, r) {
17847  let o = Bo.get(t, n, r);
17848  return o || (o = new gb(e, t, i, n, s, r), Bo.set(t, n, r, o)), o;
17849}
17850function Ju(e, t, i, n) {
17851  return i !== void 0 && n !== void 0 ? [i / e, n / t] : i !== void 0 ? i / e : n !== void 0 ? n / t : 1;
17852}
17853class hc extends Wg {
17854  /**
17855   * @param {Options} [options] Options.
17856   */
17857  constructor(t) {
17858    t = t || {};
17859    const i = t.opacity !== void 0 ? t.opacity : 1, n = t.rotation !== void 0 ? t.rotation : 0, s = t.scale !== void 0 ? t.scale : 1, r = t.rotateWithView !== void 0 ? t.rotateWithView : !1;
17860    super({
17861      opacity: i,
17862      rotation: n,
17863      scale: s,
17864      displacement: t.displacement !== void 0 ? t.displacement : [0, 0],
17865      rotateWithView: r,
17866      declutterMode: t.declutterMode
17867    }), this.anchor_ = t.anchor !== void 0 ? t.anchor : [0.5, 0.5], this.normalizedAnchor_ = null, this.anchorOrigin_ = t.anchorOrigin !== void 0 ? t.anchorOrigin : "top-left", this.anchorXUnits_ = t.anchorXUnits !== void 0 ? t.anchorXUnits : "fraction", this.anchorYUnits_ = t.anchorYUnits !== void 0 ? t.anchorYUnits : "fraction", this.crossOrigin_ = t.crossOrigin !== void 0 ? t.crossOrigin : null;
17868    const o = t.img !== void 0 ? t.img : null;
17869    this.imgSize_ = t.imgSize;
17870    let a = t.src;
17871    ht(!(a !== void 0 && o), 4), ht(!o || o && this.imgSize_, 5), (a === void 0 || a.length === 0) && o && (a = /** @type {HTMLImageElement} */
17872    o.src || lt(o)), ht(a !== void 0 && a.length > 0, 6), ht(
17873      !((t.width !== void 0 || t.height !== void 0) && t.scale !== void 0),
17874      69
17875    );
17876    const l = t.src !== void 0 ? at.IDLE : at.LOADED;
17877    if (this.color_ = t.color !== void 0 ? Wo(t.color) : null, this.iconImage_ = mb(
17878      o,
17879      /** @type {string} */
17880      a,
17881      this.imgSize_ !== void 0 ? this.imgSize_ : null,
17882      this.crossOrigin_,
17883      l,
17884      this.color_
17885    ), this.offset_ = t.offset !== void 0 ? t.offset : [0, 0], this.offsetOrigin_ = t.offsetOrigin !== void 0 ? t.offsetOrigin : "top-left", this.origin_ = null, this.size_ = t.size !== void 0 ? t.size : null, t.width !== void 0 || t.height !== void 0) {
17886      let h, c;
17887      if (t.size)
17888        [h, c] = t.size;
17889      else {
17890        const u = this.getImage(1);
17891        if (u instanceof HTMLCanvasElement || u.src && u.complete)
17892          h = u.width, c = u.height;
17893        else {
17894          this.initialOptions_ = t;
17895          const d = () => {
17896            if (this.unlistenImageChange(d), !this.initialOptions_)
17897              return;
17898            const f = this.iconImage_.getSize();
17899            this.setScale(
17900              Ju(
17901                f[0],
17902                f[1],
17903                t.width,
17904                t.height
17905              )
17906            );
17907          };
17908          this.listenImageChange(d);
17909          return;
17910        }
17911      }
17912      h !== void 0 && this.setScale(
17913        Ju(h, c, t.width, t.height)
17914      );
17915    }
17916  }
17917  /**
17918   * Clones the style. The underlying Image/HTMLCanvasElement is not cloned.
17919   * @return {Icon} The cloned style.
17920   * @api
17921   */
17922  clone() {
17923    let t, i, n;
17924    return this.initialOptions_ ? (i = this.initialOptions_.width, n = this.initialOptions_.height) : (t = this.getScale(), t = Array.isArray(t) ? t.slice() : t), new hc({
17925      anchor: this.anchor_.slice(),
17926      anchorOrigin: this.anchorOrigin_,
17927      anchorXUnits: this.anchorXUnits_,
17928      anchorYUnits: this.anchorYUnits_,
17929      color: this.color_ && this.color_.slice ? this.color_.slice() : this.color_ || void 0,
17930      crossOrigin: this.crossOrigin_,
17931      imgSize: this.imgSize_,
17932      offset: this.offset_.slice(),
17933      offsetOrigin: this.offsetOrigin_,
17934      opacity: this.getOpacity(),
17935      rotateWithView: this.getRotateWithView(),
17936      rotation: this.getRotation(),
17937      scale: t,
17938      width: i,
17939      height: n,
17940      size: this.size_ !== null ? this.size_.slice() : void 0,
17941      src: this.getSrc(),
17942      displacement: this.getDisplacement().slice(),
17943      declutterMode: this.getDeclutterMode()
17944    });
17945  }
17946  /**
17947   * Get the anchor point in pixels. The anchor determines the center point for the
17948   * symbolizer.
17949   * @return {Array<number>} Anchor.
17950   * @api
17951   */
17952  getAnchor() {
17953    let t = this.normalizedAnchor_;
17954    if (!t) {
17955      t = this.anchor_;
17956      const s = this.getSize();
17957      if (this.anchorXUnits_ == "fraction" || this.anchorYUnits_ == "fraction") {
17958        if (!s)
17959          return null;
17960        t = this.anchor_.slice(), this.anchorXUnits_ == "fraction" && (t[0] *= s[0]), this.anchorYUnits_ == "fraction" && (t[1] *= s[1]);
17961      }
17962      if (this.anchorOrigin_ != "top-left") {
17963        if (!s)
17964          return null;
17965        t === this.anchor_ && (t = this.anchor_.slice()), (this.anchorOrigin_ == "top-right" || this.anchorOrigin_ == "bottom-right") && (t[0] = 
17965-t[0] + s[0]), (this.anchorOrigin_ == "bottom-left" || this.anchorOrigin_ == "bottom-right") && (t[1] = -t[1] + s[1]);
17966      }
17967      this.normalizedAnchor_ = t;
17968    }
17969    const i = this.getDisplacement(), n = this.getScaleArray();
17970    return [
17971      t[0] - i[0] / n[0],
17972      t[1] + i[1] / n[1]
17973    ];
17974  }
17975  /**
17976   * Set the anchor point. The anchor determines the center point for the
17977   * symbolizer.
17978   *
17979   * @param {Array<number>} anchor Anchor.
17980   * @api
17981   */
17982  setAnchor(t) {
17983    this.anchor_ = t, this.normalizedAnchor_ = null;
17984  }
17985  /**
17986   * Get the icon color.
17987   * @return {import("../color.js").Color} Color.
17988   * @api
17989   */
17990  getColor() {
17991    return this.color_;
17992  }
17993  /**
17994   * Get the image icon.
17995   * @param {number} pixelRatio Pixel ratio.
17996   * @return {HTMLImageElement|HTMLCanvasElement} Image or Canvas element.
17997   * @api
17998   */
17999  getImage(t) {
18000    return this.iconImage_.getImage(t);
18001  }
18002  /**
18003   * Get the pixel ratio.
18004   * @param {number} pixelRatio Pixel ratio.
18005   * @return {number} The pixel ratio of the image.
18006   * @api
18007   */
18008  getPixelRatio(t) {
18009    return this.iconImage_.getPixelRatio(t);
18010  }
18011  /**
18012   * @return {import("../size.js").Size} Image size.
18013   */
18014  getImageSize() {
18015    return this.iconImage_.getSize();
18016  }
18017  /**
18018   * @return {import("../ImageState.js").default} Image state.
18019   */
18020  getImageState() {
18021    return this.iconImage_.getImageState();
18022  }
18023  /**
18024   * @return {HTMLImageElement|HTMLCanvasElement} Image element.
18025   */
18026  getHitDetectionImage() {
18027    return this.iconImage_.getHitDetectionImage();
18028  }
18029  /**
18030   * Get the origin of the symbolizer.
18031   * @return {Array<number>} Origin.
18032   * @api
18033   */
18034  getOrigin() {
18035    if (this.origin_)
18036      return this.origin_;
18037    let t = this.offset_;
18038    if (this.offsetOrigin_ != "top-left") {
18039      const i = this.getSize(), n = this.iconImage_.getSize();
18040      if (!i || !n)
18041        return null;
18042      t = t.slice(), (this.offsetOrigin_ == "top-right" || this.offsetOrigin_ == "bottom-right") && (t[0] = n[0] - i[0] - t[0]), (this.offsetOrigin_ == "bottom-left" || this.offsetOrigin_ == "bottom-right") && (t[1] = n[1] - i[1] - t[1]);
18043    }
18044    return this.origin_ = t, this.origin_;
18045  }
18046  /**
18047   * Get the image URL.
18048   * @return {string|undefined} Image src.
18049   * @api
18050   */
18051  getSrc() {
18052    return this.iconImage_.getSrc();
18053  }
18054  /**
18055   * Get the size of the icon (in pixels).
18056   * @return {import("../size.js").Size} Image size.
18057   * @api
18058   */
18059  getSize() {
18060    return this.size_ ? this.size_ : this.iconImage_.getSize();
18061  }
18062  /**
18063   * Get the width of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
18064   * @return {number} Icon width (in pixels).
18065   * @api
18066   */
18067  getWidth() {
18068    const t = this.getScaleArray();
18069    if (this.size_)
18070      return this.size_[0] * t[0];
18071    if (this.iconImage_.getImageState() == at.LOADED)
18072      return this.iconImage_.getSize()[0] * t[0];
18073  }
18074  /**
18075   * Get the height of the icon (in pixels). Will return undefined when the icon image is not yet loaded.
18076   * @return {number} Icon height (in pixels).
18077   * @api
18078   */
18079  getHeight() {
18080    const t = this.getScaleArray();
18081    if (this.size_)
18082      return this.size_[1] * t[1];
18083    if (this.iconImage_.getImageState() == at.LOADED)
18084      return this.iconImage_.getSize()[1] * t[1];
18085  }
18086  /**
18087   * Set the scale.
18088   *
18089   * @param {number|import("../size.js").Size} scale Scale.
18090   * @api
18091   */
18092  setScale(t) {
18093    delete this.initialOptions_, super.setScale(t);
18094  }
18095  /**
18096   * @param {function(import("../events/Event.js").default): void} listener Listener function.
18097   */
18098  listenImageChange(t) {
18099    this.iconImage_.addEventListener(et.CHANGE, t);
18100  }
18101  /**
18102   * Load not yet loaded URI.
18103   * When rendering a feature with an icon style, the vector renderer will
18104   * automatically call this method. However, you might want to call this
18105   * method yourself for preloading or other purposes.
18106   * @api
18107   */
18108  load() {
18109    this.iconImage_.load();
18110  }
18111  /**
18112   * @param {function(import("../events/Event.js").default): void} listener Listener function.
18113   */
18114  unlistenImageChange(t) {
18115    this.iconImage_.removeEventListener(et.CHANGE, t);
18116  }
18117}
18118const Kg = hc;
18119function Qu(e) {
18120  return new Sn({
18121    fill: Tr(e, ""),
18122    stroke: Ir(e, ""),
18123    text: _b(e),
18124    image: pb(e)
18125  });
18126}
18127function Tr(e, t) {
18128  const i = e[t + "fill-color"];
18129  if (i)
18130    return new Ye({ color: i });
18131}
18132function Ir(e, t) {
18133  const i = e[t + "stroke-width"], n = e[t + "stroke-color"];
18134  if (!(!i && !n))
18135    return new Ke({
18136      width: i,
18137      color: n,
18138      lineCap: e[t + "stroke-line-cap"],
18139      lineJoin: e[t + "stroke-line-join"],
18140      lineDash: e[t + "stroke-line-dash"],
18141      lineDashOffset: e[t + "stroke-line-dash-offset"],
18142      miterLimit: e[t + "stroke-miter-limit"]
18143    });
18144}
18145function _b(e) {
18146  const t = e["text-value"];
18147  return t ? new nb({
18148    text: t,
18149    font: e["text-font"],
18150    maxAngle: e["text-max-angle"],
18151    offsetX: e["text-offset-x"],
18152    offsetY: e["text-offset-y"],
18153    overflow: e["text-overflow"],
18154    placement: e["text-placement"],
18155    repeat: e["text-repeat"],
18156    scale: e["text-scale"],
18157    rotateWithView: e["text-rotate-with-view"],
18158    rotation: e["text-rotation"],
18159    textAlign: e["text-align"],
18160    justify: e["text-justify"],
18161    textBaseline: e["text-baseline"],
18162    padding: e["text-padding"],
18163    fill: Tr(e, "text-"),
18164    backgroundFill: Tr(e, "text-background-"),
18165    stroke: Ir(e, "text-"),
18166    backgroundStroke: Ir(e, "text-background-")
18167  }) : void 0;
18168}
18169function pb(e) {
18170  const t = e["icon-src"], i = e["icon-img"];
18171  if (t || i)
18172    return new Kg({
18173      src: t,
18174      img: i,
18175      imgSize: e["icon-img-size"],
18176      anchor: e["icon-anchor"],
18177      anchorOrigin: e["icon-anchor-origin"],
18178      anchorXUnits: e["icon-anchor-x-units"],
18179      anchorYUnits: e["icon-anchor-y-units"],
18180      color: e["icon-color"],
18181      crossOrigin: e["icon-cross-origin"],
18182      offset: e["icon-offset"],
18183      displacement: e["icon-displacement"],
18184      opacity: e["icon-opacity"],
18185      scale: e["icon-scale"],
18186      width: e["icon-width"],
18187      height: e["icon-height"],
18188      rotation: e["icon-rotation"],
18189      rotateWithView: e["icon-rotate-with-view"],
18190      size: e["icon-size"],
18191      declutterMode: e["icon-declutter-mode"]
18192    });
18193  const n = e["shape-points"];
18194  if (n) {
18195    const r = "shape-";
18196    return new Bg({
18197      points: n,
18198      fill: Tr(e, r),
18199      stroke: Ir(e, r),
18200      radius: e["shape-radius"],
18201      radius1: e["shape-radius1"],
18202      radius2: e["shape-radius2"],
18203      angle: e["shape-angle"],
18204      displacement: e["shape-displacement"],
18205      rotation: e["shape-rotation"],
18206      rotateWithView: e["shape-rotate-with-view"],
18207      scale: e["shape-scale"],
18208      declutterMode: e["shape-declutter-mode"]
18209    });
18210  }
18211  const s = e["circle-radius"];
18212  if (s) {
18213    const r = "circle-";
18214    return new Fs({
18215      radius: s,
18216      fill: Tr(e, r),
18217      stroke: Ir(e, r),
18218      displacement: e["circle-displacement"],
18219      scale: e["circle-scale"],
18220      rotation: e["circle-rotation"],
18221      rotateWithView: e["circle-rotate-with-view"],
18222      declutterMode: e["circle-declutter-mode"]
18223    });
18224  }
18225}
18226const td = {
18227  RENDER_ORDER: "renderOrder"
18228};
18229class yb extends jr {
18230  /**
18231   * @param {Options<VectorSourceType>} [options] Options.
18232   */
18233  constructor(t) {
18234    t = t || {};
18235    const i = Object.assign({}, t);
18236    delete i.style, delete i.renderBuffer, delete i.updateWhileAnimating, delete i.updateWhileInteracting, super(i), this.declutter_ = t.declutter !== void 0 ? t.declutter : !1, this.renderBuffer_ = t.renderBuffer !== void 0 ? t.renderBuffer : 100, this.style_ = null, this.styleFunction_ = void 0, this.setStyle(t.style), this.updateWhileAnimating_ = t.updateWhileAnimating !== void 0 ? t.updateWhileAnimating : !1, this.updateWhileInteracting_ = t.updateWhileInteracting !== void 0 ? t.updateWhileInteracting : !1;
18237  }
18238  /**
18239   * @return {boolean} Declutter.
18240   */
18241  getDeclutter() {
18242    return this.declutter_;
18243  }
18244  /**
18245   * Get the topmost feature that intersects the given pixel on the viewport. Returns a promise
18246   * that resolves with an array of features. The array will either contain the topmost feature
18247   * when a hit was detected, or it will be empty.
18248   *
18249   * The hit detection algorithm used for this method is optimized for performance, but is less
18250   * accurate than the one used in [map.getFeaturesAtPixel()]{@link import("../Map.js").default#getFeaturesAtPixel}.
18251   * Text is not considered, and icons are only represented by their bounding box instead of the exact
18252   * image.
18253   *
18254   * @param {import("../pixel.js").Pixel} pixel Pixel.
18255   * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with an array of features.
18256   * @api
18257   */
18258  getFeatures(t) {
18259    return super.getFeatures(t);
18260  }
18261  /**
18262   * @return {number|undefined} Render buffer.
18263   */
18264  getRenderBuffer() {
18265    return this.renderBuffer_;
18266  }
18267  /**
18268   * @return {function(import("../Feature.js").default, import("../Feature.js").default): number|null|undefined} Render
18269   *     order.
18270   */
18271  getRenderOrder() {
18272    return (
18273      /** @type {import("../render.js").OrderFunction|null|undefined} */
18274      this.get(td.RENDER_ORDER)
18275    );
18276  }
18277  /**
18278   * Get the style for features.  This returns whatever was passed to the `style`
18279   * option at construction or to the `setStyle` method.
18280   * @return {import("../style/Style.js").StyleLike|null|undefined} Layer style.
18281   * @api
18282   */
18283  getStyle() {
18284    return this.style_;
18285  }
18286  /**
18287   * Get the style function.
18288   * @return {import("../style/Style.js").StyleFunction|undefined} Layer style function.
18289   * @api
18290   */
18291  getStyleFunction() {
18292    return this.styleFunction_;
18293  }
18294  /**
18295   * @return {boolean} Whether the rendered layer should be updated while
18296   *     animating.
18297   */
18298  getUpdateWhileAnimating() {
18299    return this.updateWhileAnimating_;
18300  }
18301  /**
18302   * @return {boolean} Whether the rendered layer should be updated while
18303   *     interacting.
18304   */
18305  getUpdateWhileInteracting() {
18306    return this.updateWhileInteracting_;
18307  }
18308  /**
18309   * Render declutter items for this layer
18310   * @param {import("../Map.js").FrameState} frameState Frame state.
18311   */
18312  renderDeclutter(t) {
18313    t.declutterTree || (t.declutterTree = new $g(9)), this.getRenderer().renderDeclutter(t);
18314  }
18315  /**
18316   * @param {import("../render.js").OrderFunction|null|undefined} renderOrder
18317   *     Render order.
18318   */
18319  setRenderOrder(t) {
18320    this.set(td.RENDER_ORDER, t);
18321  }
18322  /**
18323   * Set the style for features.  This can be a single style object, an array
18324   * of styles, or a function that takes a feature and resolution and returns
18325   * an array of styles. If set to `null`, the layer has no style (a `null` style),
18326   * so only features that have their own styles will be rendered in the layer. C
18326all
18327   * `setStyle()` without arguments to reset to the default style. See
18328   * [the ol/style/Style module]{@link module:ol/style/Style~Style} for information on the default style.
18329   *
18330   * If your layer has a static style, you can use [flat style]{@link module:ol/style/flat~FlatStyle} object
18331   * literals instead of using the `Style` and symbolizer constructors (`Fill`, `Stroke`, etc.):
18332   * ```js
18333   * vectorLayer.setStyle({
18334   *   "fill-color": "yellow",
18335   *   "stroke-color": "black",
18336   *   "stroke-width": 4
18337   * })
18338   * ```
18339   *
18340   * @param {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [style] Layer style.
18341   * @api
18342   */
18343  setStyle(t) {
18344    let i;
18345    if (t === void 0)
18346      i = eb;
18347    else if (t === null)
18348      i = null;
18349    else if (typeof t == "function")
18350      i = t;
18351    else if (t instanceof Sn)
18352      i = t;
18353    else if (Array.isArray(t)) {
18354      const n = t.length, s = new Array(n);
18355      for (let r = 0; r < n; ++r) {
18356        const o = t[r];
18357        o instanceof Sn ? s[r] = o : s[r] = Qu(o);
18358      }
18359      i = s;
18360    } else
18361      i = Qu(t);
18362    this.style_ = i, this.styleFunction_ = t === null ? void 0 : tb(this.style_), this.changed();
18363  }
18364}
18365const xb = yb, Br = {
18366  BEGIN_GEOMETRY: 0,
18367  BEGIN_PATH: 1,
18368  CIRCLE: 2,
18369  CLOSE_PATH: 3,
18370  CUSTOM: 4,
18371  DRAW_CHARS: 5,
18372  DRAW_IMAGE: 6,
18373  END_GEOMETRY: 7,
18374  FILL: 8,
18375  MOVE_TO_LINE_TO: 9,
18376  SET_FILL_STYLE: 10,
18377  SET_STROKE_STYLE: 11,
18378  STROKE: 12
18379}, ho = [Br.FILL], Yi = [Br.STROKE], vn = [Br.BEGIN_PATH], ed = [Br.CLOSE_PATH], tt = Br;
18380class vb {
18381  /**
18382   * Render a geometry with a custom renderer.
18383   *
18384   * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
18385   * @param {import("../Feature.js").FeatureLike} feature Feature.
18386   * @param {Function} renderer Renderer.
18387   * @param {Function} hitDetectionRenderer Renderer.
18388   */
18389  drawCustom(t, i, n, s) {
18390  }
18391  /**
18392   * Render a geometry.
18393   *
18394   * @param {import("../geom/Geometry.js").default} geometry The geometry to render.
18395   */
18396  drawGeometry(t) {
18397  }
18398  /**
18399   * Set the rendering style.
18400   *
18401   * @param {import("../style/Style.js").default} style The rendering style.
18402   */
18403  setStyle(t) {
18404  }
18405  /**
18406   * @param {import("../geom/Circle.js").default} circleGeometry Circle geometry.
18407   * @param {import("../Feature.js").default} feature Feature.
18408   */
18409  drawCircle(t, i) {
18410  }
18411  /**
18412   * @param {import("../Feature.js").default} feature Feature.
18413   * @param {import("../style/Style.js").default} style Style.
18414   */
18415  drawFeature(t, i) {
18416  }
18417  /**
18418   * @param {import("../geom/GeometryCollection.js").default} geometryCollectionGeometry Geometry collection.
18419   * @param {import("../Feature.js").default} feature Feature.
18420   */
18421  drawGeometryCollection(t, i) {
18422  }
18423  /**
18424   * @param {import("../geom/LineString.js").default|import("./Feature.js").default} lineStringGeometry Line string geometry.
18425   * @param {import("../Feature.js").FeatureLike} feature Feature.
18426   */
18427  drawLineString(t, i) {
18428  }
18429  /**
18430   * @param {import("../geom/MultiLineString.js").default|import("./Feature.js").default} multiLineStringGeometry MultiLineString geometry.
18431   * @param {import("../Feature.js").FeatureLike} feature Feature.
18432   */
18433  drawMultiLineString(t, i) {
18434  }
18435  /**
18436   * @param {import("../geom/MultiPoint.js").default|import("./Feature.js").default} multiPointGeometry MultiPoint geometry.
18437   * @param {import("../Feature.js").FeatureLike} feature Feature.
18438   */
18439  drawMultiPoint(t, i) {
18440  }
18441  /**
18442   * @param {import("../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry.
18443   * @param {import("../Feature.js").FeatureLike} feature Feature.
18444   */
18445  drawMultiPolygon(t, i) {
18446  }
18447  /**
18448   * @param {import("../geom/Point.js").default|import("./Feature.js").default} pointGeometry Point geometry.
18449   * @param {import("../Feature.js").FeatureLike} feature Feature.
18450   */
18451  drawPoint(t, i) {
18452  }
18453  /**
18454   * @param {import("../geom/Polygon.js").default|import("./Feature.js").default} polygonGeometry Polygon geometry.
18455   * @param {import("../Feature.js").FeatureLike} feature Feature.
18456   */
18457  drawPolygon(t, i) {
18458  }
18459  /**
18460   * @param {import("../geom/SimpleGeometry.js").default|import("./Feature.js").default} geometry Geometry.
18461   * @param {import("../Feature.js").FeatureLike} feature Feature.
18462   */
18463  drawText(t, i) {
18464  }
18465  /**
18466   * @param {import("../style/Fill.js").default} fillStyle Fill style.
18467   * @param {import("../style/Stroke.js").default} strokeStyle Stroke style.
18468   */
18469  setFillStrokeStyle(t, i) {
18470  }
18471  /**
18472   * @param {import("../style/Image.js").default} imageStyle Image style.
18473   * @param {import("../render/canvas.js").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with a text style.
18474   */
18475  setImageStyle(t, i) {
18476  }
18477  /**
18478   * @param {import("../style/Text.js").default} textStyle Text style.
18479   * @param {import("../render/canvas.js").DeclutterImageWithText} [declutterImageWithText] Shared data for combined decluttering with an image style.
18480   */
18481  setTextStyle(t, i) {
18482  }
18483}
18484const Vg = vb;
18485class Eb extends Vg {
18486  /**
18487   * @param {number} tolerance Tolerance.
18488   * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
18489   * @param {number} resolution Resolution.
18490   * @param {number} pixelRatio Pixel ratio.
18491   */
18492  constructor(t, i, n, s) {
18493    super(), this.tolerance = t, this.maxExtent = i, this.pixelRatio = s, this.maxLineWidth = 0, this.resolution = n, this.beginGeometryInstruction1_ = null, this.beginGeometryInstruction2_ = null, this.bufferedMaxExtent_ = null, this.instructions = [], this.coordinates = [], this.tmpCoordinate_ = [], this.hitDetectionInstructions = [], this.state = /** @type {import("../canvas.js").FillStrokeState} */
18494    {};
18495  }
18496  /**
18497   * @protected
18498   * @param {Array<number>} dashArray Dash array.
18499   * @return {Array<number>} Dash array with pixel ratio applied
18500   */
18501  applyPixelRatio(t) {
18502    const i = this.pixelRatio;
18503    return i == 1 ? t : t.map(function(n) {
18504      return n * i;
18505    });
18506  }
18507  /**
18508   * @param {Array<number>} flatCoordinates Flat coordinates.
18509   * @param {number} stride Stride.
18510   * @protected
18511   * @return {number} My end
18512   */
18513  appendFlatPointCoordinates(t, i) {
18514    const n = this.getBufferedMaxExtent(), s = this.tmpCoordinate_, r = this.coordinates;
18515    let o = r.length;
18516    for (let a = 0, l = t.length; a < l; a += i)
18517      s[0] = t[a], s[1] = t[a + 1], Ds(n, s) && (r[o++] = s[0], r[o++] = s[
185171]);
18518    return o;
18519  }
18520  /**
18521   * @param {Array<number>} flatCoordinates Flat coordinates.
18522   * @param {number} offset Offset.
18523   * @param {number} end End.
18524   * @param {number} stride Stride.
18525   * @param {boolean} closed Last input coordinate equals first.
18526   * @param {boolean} skipFirst Skip first coordinate.
18527   * @protected
18528   * @return {number} My end.
18529   */
18530  appendFlatLineCoordinates(t, i, n, s, r, o) {
18531    const a = this.coordinates;
18532    let l = a.length;
18533    const h = this.getBufferedMaxExtent();
18534    o && (i += s);
18535    let c = t[i], u = t[i + 1];
18536    const d = this.tmpCoordinate_;
18537    let f = !0, g, m, _;
18538    for (g = i + s; g < n; g += s)
18539      d[0] = t[g], d[1] = t[g + 1], _ = pl(h, d), _ !== m ? (f && (a[l++] = c, a[l++] = u, f = !1), a[l++] = d[0], a[l++] = d[1]) : _ === Yt.INTERSECTING ? (a[l++] = d[0], a[l++] = d[1], f = !1) : f = !0, c = d[0], u = d[1], m = _;
18540    return (r && f || g === i + s) && (a[l++] = c, a[l++] = u), l;
18541  }
18542  /**
18543   * @param {Array<number>} flatCoordinates Flat coordinates.
18544   * @param {number} offset Offset.
18545   * @param {Array<number>} ends Ends.
18546   * @param {number} stride Stride.
18547   * @param {Array<number>} builderEnds Builder ends.
18548   * @return {number} Offset.
18549   */
18550  drawCustomCoordinates_(t, i, n, s, r) {
18551    for (let o = 0, a = n.length; o < a; ++o) {
18552      const l = n[o], h = this.appendFlatLineCoordinates(
18553        t,
18554        i,
18555        l,
18556        s,
18557        !1,
18558        !1
18559      );
18560      r.push(h), i = l;
18561    }
18562    return i;
18563  }
18564  /**
18565   * @param {import("../../geom/SimpleGeometry.js").default} geometry Geometry.
18566   * @param {import("../../Feature.js").FeatureLike} feature Feature.
18567   * @param {Function} renderer Renderer.
18568   * @param {Function} hitDetectionRenderer Renderer.
18569   */
18570  drawCustom(t, i, n, s) {
18571    this.beginGeometry(t, i);
18572    const r = t.getType(), o = t.getStride(), a = this.coordinates.length;
18573    let l, h, c, u, d;
18574    switch (r) {
18575      case "MultiPolygon":
18576        l = /** @type {import("../../geom/MultiPolygon.js").default} */
18577        t.getOrientedFlatCoordinates(), u = [];
18578        const f = (
18579          /** @type {import("../../geom/MultiPolygon.js").default} */
18580          t.getEndss()
18581        );
18582        d = 0;
18583        for (let g = 0, m = f.length; g < m; ++g) {
18584          const _ = [];
18585          d = this.drawCustomCoordinates_(
18586            l,
18587            d,
18588            f[g],
18589            o,
18590            _
18591          ), u.push(_);
18592        }
18593        this.instructions.push([
18594          tt.CUSTOM,
18595          a,
18596          u,
18597          t,
18598          n,
18599          kl
18600        ]), this.hitDetectionInstructions.push([
18601          tt.CUSTOM,
18602          a,
18603          u,
18604          t,
18605          s || n,
18606          kl
18607        ]);
18608        break;
18609      case "Polygon":
18610      case "MultiLineString":
18611        c = [], l = r == "Polygon" ? (
18612          /** @type {import("../../geom/Polygon.js").default} */
18613          t.getOrientedFlatCoordinates()
18614        ) : t.getFlatCoordinates(), d = this.drawCustomCoordinates_(
18615          l,
18616          0,
18617          /** @type {import("../../geom/Polygon.js").default|import("../../geom/MultiLineString.js").default} */
18618          t.getEnds(),
18619          o,
18620          c
18621        ), this.instructions.push([
18622          tt.CUSTOM,
18623          a,
18624          c,
18625          t,
18626          n,
18627          vr
18628        ]), this.hitDetectionInstructions.push([
18629          tt.CUSTOM,
18630          a,
18631          c,
18632          t,
18633          s || n,
18634          vr
18635        ]);
18636        break;
18637      case "LineString":
18638      case "Circle":
18639        l = t.getFlatCoordinates(), h = this.appendFlatLineCoordinates(
18640          l,
18641          0,
18642          l.length,
18643          o,
18644          !1,
18645          !1
18646        ), this.instructions.push([
18647          tt.CUSTOM,
18648          a,
18649          h,
18650          t,
18651          n,
18652          Xi
18653        ]), this.hitDetectionInstructions.push([
18654          tt.CUSTOM,
18655          a,
18656          h,
18657          t,
18658          s || n,
18659          Xi
18660        ]);
18661        break;
18662      case "MultiPoint":
18663        l = t.getFlatCoordinates(), h = this.appendFlatPointCoordinates(l, o), h > a && (this.instructions.push([
18664          tt.CUSTOM,
18665          a,
18666          h,
18667          t,
18668          n,
18669          Xi
18670        ]), this.hitDetectionInstructions.push([
18671          tt.CUSTOM,
18672          a,
18673          h,
18674          t,
18675          s || n,
18676          Xi
18677        ]));
18678        break;
18679      case "Point":
18680        l = t.getFlatCoordinates(), this.coordinates.push(l[0], l[1]), h = this.coordinates.length, this.instructions.push([
18681          tt.CUSTOM,
18682          a,
18683          h,
18684          t,
18685          n
18686        ]), this.hitDetectionInstructions.push([
18687          tt.CUSTOM,
18688          a,
18689          h,
18690          t,
18691          s || n
18692        ]);
18693        break;
18694    }
18695    this.endGeometry(i);
18696  }
18697  /**
18698   * @protected
18699   * @param {import("../../geom/Geometry").default|import("../Feature.js").default} geometry The geometry.
18700   * @param {import("../../Feature.js").FeatureLike} feature Feature.
18701   */
18702  beginGeometry(t, i) {
18703    this.beginGeometryInstruction1_ = [
18704      tt.BEGIN_GEOMETRY,
18705      i,
18706      0,
18707      t
18708    ], this.instructions.push(this.beginGeometryInstruction1_), this.beginGeometryInstruction2_ = [
18709      tt.BEGIN_GEOMETRY,
18710      i,
18711      0,
18712      t
18713    ], this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
18714  }
18715  /**
18716   * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
18717   */
18718  finish() {
18719    return {
18720      instructions: this.instructions,
18721      hitDetectionInstructions: this.hitDetectionInstructions,
18722      coordinates: this.coordinates
18723    };
18724  }
18725  /**
18726   * Reverse the hit detection instructions.
18727   */
18728  reverseHitDetectionInstructions() {
18729    const t = this.hitDetectionInstructions;
18730    t.reverse();
18731    let i;
18732    const n = t.length;
18733    let s, r, o = -1;
18734    for (i = 0; i < n; ++i)
18735      s = t[i], r = /** @type {import("./Instruction.js").default} */
18736      s[0], r == tt.END_GEOMETRY ? o = i : r == tt.BEGIN_GEOMETRY && (s[2] = i, RE(this.hitDetectionInstructions, o, i), o = -1);
18737  }
18738  /**
18739   * @param {import("../../style/Fill.js").default} fillStyle Fill style.
18740   * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style.
18741   */
18742  setFillStrokeStyle(t, i) {
18743    const n = this.state;
18744    if (t) {
18745      const s = t.getColor();
18746      n.fillStyle = li(
18747        s || Si
18748      );
18749    } else
18750      n.fillStyle = void 0;
18751    if (i) {
18752      const s = i.getColor();
18753      n.strokeStyle = li(
18754        s || br
18755      );
18756      const r = i.getLineCap();
18757      n.lineCap = r !== void 0 ? r : $o;
18758      const o = i.getLineDash();
18759      n.lineDash = o ? o.slice() : Er;
18760      const a = i.getLineDashOffset();
18761      n.lineDashOffset = a || Cr;
18762      const l = i.getLineJoin();
18763      n.lineJoin = l !== void 0 ? l : Os;
18764      const h = i.getWidth();
18765      n.lineWidth = h !== void 0 ? h : Sr;
18766      const c = i.getMiterLimit();
18767      n.miterLimit = c !== void 0 ? c : Mr, n.lineWidth > this.maxLineWidth && (this.maxLineWidth = n.lineWidth, this.bufferedMaxExtent_ = null);
18768    } else
18769      n.strokeStyle = void 0, n.lineCap = void 0, n.lineDash = null, n.lineDashOffset = void 0, n.lineJoin = void 0, n.lineWidth = void 0, n.miterLimit = void 0;
18770  }
18771  /**
18772   * @param {import("../canvas.js").FillStrokeState} state State.
18773   * @return {Array<*>} Fill instruction.
18774   */
18775  createFill(t) {
18776    const i = t.fillStyle, n = [tt.SET_FILL_STYLE, i];
18777    return typeof i != "string" && n.push(!0), n;
18778  }
18779  /**
18780   * @param {import("../canvas.js").FillStrokeState} state State.
18781   */
18782  applyStroke(t) {
18783    this.instructions.push(this.createStroke(t));
18784  }
18785  /**
18786   * @param {import("../canvas.js").FillStrokeState} state State.
18787   * @return {Array<*>} Stroke instruction.
18788   */
18789  createStroke(t) {
18790    return [
18791      tt.SET_STROKE_STYLE,
18792      t.strokeStyle,
18793      t.lineWidth * this.pixelRatio,
18794      t.lineCap,
18795      t.lineJoin,
18796      t.miterLimit,
18797      this.applyPixelRatio(t.lineDash),
18798      t.lineDashOffset * this.pixelRatio
18799    ];
18800  }
18801  /**
18802   * @param {import("../canvas.js").FillStrokeState} state State.
18803   * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState):Array<*>} createFill Create fill.
18804   */
18805  updateFillStyle(t, i) {
18806    const n = t.fillStyle;
18807    (typeof n != "string" || t.currentFillStyle != n) && (n !== void 0 && this.instructions.push(i.call(this, t)), t.currentFillStyle = n);
18808  }
18809  /**
18810   * @param {import("../canvas.js").FillStrokeState} state State.
18811   * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState): void} applyStroke Apply stroke.
18812   */
18813  updateStrokeStyle(t, i) {
18814    const n = t.strokeStyle, s = t.lineCap, r = t.lineDash, o = t.lineDashOffset, a = t.lineJoin, l = t.lineWidth, h = t.miter
18814Limit;
18815    (t.currentStrokeStyle != n || t.currentLineCap != s || r != t.currentLineDash && !Pi(t.currentLineDash, r) || t.currentLineDashOffset != o || t.currentLineJoin != a || t.currentLineWidth != l || t.currentMiterLimit != h) && (n !== void 0 && i.call(this, t), t.currentStrokeStyle = n, t.currentLineCap = s, t.currentLineDash = r, t.currentLineDashOffset = o, t.currentLineJoin = a, t.currentLineWidth = l, t.currentMiterLimit = h);
18816  }
18817  /**
18818   * @param {import("../../Feature.js").FeatureLike} feature Feature.
18819   */
18820  endGeometry(t) {
18821    this.beginGeometryInstruction1_[2] = this.instructions.length, this.beginGeometryInstruction1_ = null, this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length, this.beginGeometryInstruction2_ = null;
18822    const i = [tt.END_GEOMETRY, t];
18823    this.instructions.push(i), this.hitDetectionInstructions.push(i);
18824  }
18825  /**
18826   * Get the buffered rendering extent.  Rendering will be clipped to the extent
18827   * provided to the constructor.  To account for symbolizers that may intersect
18828   * this extent, we calculate a buffered extent (e.g. based on stroke width).
18829   * @return {import("../../extent.js").Extent} The buffered rendering extent.
18830   * @protected
18831   */
18832  getBufferedMaxExtent() {
18833    if (!this.bufferedMaxExtent_ && (this.bufferedMaxExtent_ = Qd(this.maxExtent), this.maxLineWidth > 0)) {
18834      const t = this.resolution * (this.maxLineWidth + 1) / 2;
18835      Rn(this.bufferedMaxExtent_, t, this.bufferedMaxExtent_);
18836    }
18837    return this.bufferedMaxExtent_;
18838  }
18839}
18840const Ur = Eb;
18841class Cb extends Ur {
18842  /**
18843   * @param {number} tolerance Tolerance.
18844   * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
18845   * @param {number} resolution Resolution.
18846   * @param {number} pixelRatio Pixel ratio.
18847   */
18848  constructor(t, i, n, s) {
18849    super(t, i, n, s), this.hitDetectionImage_ = null, this.image_ = null, this.imagePixelRatio_ = void 0, this.anchorX_ = void 0, this.anchorY_ = void 0, this.height_ = void 0, this.opacity_ = void 0, this.originX_ = void 0, this.originY_ = void 0, this.rotateWithView_ = void 0, this.rotation_ = void 0, this.scale_ = void 0, this.width_ = void 0, this.declutterMode_ = void 0, this.declutterImageWithText_ = void 0;
18850  }
18851  /**
18852   * @param {import("../../geom/Point.js").default|import("../Feature.js").default} pointGeometry Point geometry.
18853   * @param {import("../../Feature.js").FeatureLike} feature Feature.
18854   */
18855  drawPoint(t, i) {
18856    if (!this.image_)
18857      return;
18858    this.beginGeometry(t, i);
18859    const n = t.getFlatCoordinates(), s = t.getStride(), r = this.coordinates.length, o = this.appendFlatPointCoordinates(n, s);
18860    this.instructions.push([
18861      tt.DRAW_IMAGE,
18862      r,
18863      o,
18864      this.image_,
18865      // Remaining arguments to DRAW_IMAGE are in alphabetical order
18866      this.anchorX_ * this.imagePixelRatio_,
18867      this.anchorY_ * this.imagePixelRatio_,
18868      Math.ceil(this.height_ * this.imagePixelRatio_),
18869      this.opacity_,
18870      this.originX_ * this.imagePixelRatio_,
18871      this.originY_ * this.imagePixelRatio_,
18872      this.rotateWithView_,
18873      this.rotation_,
18874      [
18875        this.scale_[0] * this.pixelRatio / this.imagePixelRatio_,
18876        this.scale_[1] * this.pixelRatio / this.imagePixelRatio_
18877      ],
18878      Math.ceil(this.width_ * this.imagePixelRatio_),
18879      this.declutterMode_,
18880      this.declutterImageWithText_
18881    ]), this.hitDetectionInstructions.push([
18882      tt.DRAW_IMAGE,
18883      r,
18884      o,
18885      this.hitDetectionImage_,
18886      // Remaining arguments to DRAW_IMAGE are in alphabetical order
18887      this.anchorX_,
18888      this.anchorY_,
18889      this.height_,
18890      this.opacity_,
18891      this.originX_,
18892      this.originY_,
18893      this.rotateWithView_,
18894      this.rotation_,
18895      this.scale_,
18896      this.width_,
18897      this.declutterMode_,
18898      this.declutterImageWithText_
18899    ]), this.endGeometry(i);
18900  }
18901  /**
18902   * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} multiPointGeometry MultiPoint geometry.
18903   * @param {import("../../Feature.js").FeatureLike} feature Feature.
18904   */
18905  drawMultiPoint(t, i) {
18906    if (!this.image_)
18907      return;
18908    this.beginGeometry(t, i);
18909    const n = t.getFlatCoordinates(), s = t.getStride(), r = this.coordinates.length, o = this.appendFlatPointCoordinates(n, s);
18910    this.instructions.push([
18911      tt.DRAW_IMAGE,
18912      r,
18913      o,
18914      this.image_,
18915      // Remaining arguments to DRAW_IMAGE are in alphabetical order
18916      this.anchorX_ * this.imagePixelRatio_,
18917      this.anchorY_ * this.imagePixelRatio_,
18918      Math.ceil(this.height_ * this.imagePixelRatio_),
18919      this.opacity_,
18920      this.originX_ * this.imagePixelRatio_,
18921      this.originY_ * this.imagePixelRatio_,
18922      this.rotateWithView_,
18923      this.rotation_,
18924      [
18925        this.scale_[0] * this.pixelRatio / this.imagePixelRatio_,
18926        this.scale_[1] * this.pixelRatio / this.imagePixelRatio_
18927      ],
18928      Math.ceil(this.width_ * this.imagePixelRatio_),
18929      this.declutterMode_,
18930      this.declutterImageWithText_
18931    ]), this.hitDetectionInstructions.push([
18932      tt.DRAW_IMAGE,
18933      r,
18934      o,
18935      this.hitDetectionImage_,
18936      // Remaining arguments to DRAW_IMAGE are in alphabetical order
18937      this.anchorX_,
18938      this.anchorY_,
18939      this.height_,
18940      this.opacity_,
18941      this.originX_,
18942      this.originY_,
18943      this.rotateWithView_,
18944      this.rotation_,
18945      this.scale_,
18946      this.width_,
18947      this.declutterMode_,
18948      this.declutterImageWithText_
18949    ]), this.endGeometry(i);
18950  }
18951  /**
18952   * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
18953   */
18954  finish() {
18955    return this.reverseHitDetectionInstructions(), this.anchorX_ = void 0, this.anchorY_ = void 0, this.hitDetectionImage_ = null, this.image_ = null, this.imagePixelRatio_ = void 0, this.height_ = void 0, this.scale_ = void 0, this.opacity_ = void 0, this.originX_ = void 0, this.originY_ = void 0, this.rotateWithView_ = void 0, this.rotation_ = void 0, this.width_ = void 0, super.finish();
18956  }
18957  /**
18958   * @param {import("../../style/Image.js").default} imageStyle Image style.
18959   * @param {Object} [sharedData] Shared data.
18960   */
18961  setImageStyle(t, i) {
18962    const n = t.getAnchor(), s = t.getSize(), r = t.getOrigin();
18963    this.imagePixelRatio_ = t.getPixelRatio(this.pixelRatio), this.anchorX_ = n[0], this.anchorY_ = n[1], this.hitDetectionImage_ = t.getHitDetectionImage(), this.image_ = t.getImage(this.pixelRatio), this.height_ = s[1], this.opacity_ = t.getOpacity(), this.originX_ = r[0], this.originY_ = r[1], this.rotateWithView_ = t.getRotateWithView(), this.rotation_ = t.getRotation(), this.scale_ = t.getScaleArray(), this.width_ = s[0], this.declutterMode_ = t.getDeclutterMode(), this.declutterImageWithText_ = i;
18964  }
18965}
18966const Mb = Cb;
18967class bb extends Ur {
18968  /**
18969   * @param {number} tolerance Tolerance.
18970   * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
18971   * @param {number} resolution Resolution.
18972   * @param {number} pixelRatio Pixel ratio.
18973   */
18974  constructor(t, i, n, s) {
18975    super(t, i, n, s);
18976  }
18977  /**
18978   * @param {Array<number>} flatCoordinates Flat coordinates.
18979   * @param {number} offset Offset.
18980   * @param {number} end End.
18981   * @param {number} stride Stride.
18982   * @private
18983   * @return {number} end.
18984   */
18985  drawFlatCoordinates_(t, i, n, s) {
18986    const r = this.coordinates.length, o = this.appendFlatLineCoordinates(
18987      t,
18988      i,
18989      n,
18990      s,
18991      !1,
18992      !1
18993    ), a = [
18994      tt.MOVE_TO_LINE_TO,
18995      r,
18996      o
18997    ];
18998    return this.instructions.push(a), this.hitDetectionInstructions.push(a), n;
18999  }
19000  /**
19001   * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} lineStringGeometry Line string geometry.
19002   * @param {import("../../Feature.js").FeatureLike} feature Feature.
19003   */
19004  drawLineString(t, i) {
19005    const n = this.state, s = n.strokeStyle, r = n.lineWidth;
19006    if (s === void 0 || r === void 0)
19007      return;
19008    this.updateStrokeStyle(n, this.applyStroke), this.beginGeometry(t, i), this.hitDetectionInstructions.push(
19009      [
19010        tt.SET_STROKE_STYLE,
19011        n.strokeStyle,
19012        n.lineWidth,
19013        n.lineCap,
19014        n.lineJoin,
19015        n.miterLimit,
19016        Er,
19017        Cr
19018      ],
19019      vn
19020    );
19021    const o = t.getFlatCoordinates(), a = t.getStride();
19022    this.drawFlatCoordinates_(
19023      o,
19024      0,
19025      o.length,
19026      a
19027    ), this.hitDetectionInstructions.push(Yi), this.endGeometry(i);
19028  }
19029  /**
19030   * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} multiLineStringGeometry MultiLineString geometry.
19031   * @param {import("../../Feature.js").FeatureLike} feature Feature.
19032   */
19033  drawMultiLineString(t, i) {
19034    const n = this.state, s = n.strokeStyle, r = n.lineWidth;
19035    if (s === void 0 || r === void 0)
19036      return;
19037    this.updateStrokeStyle(n, this.applyStroke), this.beginGeometry(t, i), this.hitDetectionInstructions.push(
19038      [
19039        tt.SET_STROKE_STYLE,
19040        n.strokeStyle,
19041        n.lineWidth,
19042        n.lineCap,
19043        n.lineJoin,
19044        n.miterLimit,
19045        n.lineDash,
19046        n.lineDashOffset
19047      ],
19048      vn
19049    );
19050    const o = t.getEnds(), a = t.getFlatCoordinates(), l = t.getStride();
19051    let h = 0;
19052    for (let c = 0, u = o.length; c < u; ++c)
19053      h = this.drawFlatCoordinates_(
19054        a,
19055        h,
19056        /** @type {number} */
19057        o[c],
19058        l
19059      );
19060    this.hitDetectionInstructions.push(Yi), this.endGeometry(i);
19061  }
19062  /**
19063   * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
19064   */
19065  finish() {
19066    const t = this.state;
19067    return t.lastStroke != null && t.lastStroke != this.coordinates.length && this.instructions.push(Yi), this.reverseHitDetectionInstructions(), this.state = null, super.finish();
19068  }
19069  /**
19070   * @param {import("../canvas.js").FillStrokeState} state State.
19071   */
19072  applyStroke(t) {
19073    t.lastStroke != null && t.lastStroke != this.coordinates.length && (this.instructions.push(Yi), t.lastStroke = this.coordinates.length), t.lastStroke = 0, super.applyStroke(t), this.instructions.push(vn);
19074  }
19075}
19076const wb = bb;
19077class Sb extends Ur {
19078  /**
19079   * @param {number} tolerance Tolerance.
19080   * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
19081   * @param {number} resolution Resolution.
19082   * @param {number} pixelRatio Pixel ratio.
19083   */
19084  constructor(t, i, n, s) {
19085    super(t, i, n, s);
19086  }
19087  /**
19088   * @param {Array<number>} flatCoordinates Flat coordinates.
19089   * @param {number} offset Offset.
19090   * @param {Array<number>} ends Ends.
19091   * @param {number} stride Stride.
19092   * @private
19093   * @return {number} End.
19094   */
19095  drawFlatCoordinatess_(t, i, n, s) {
19096    const r = this.state, o = r.fillStyle !== void 0, a = r.strokeStyle !== void 0, l = n.length;
19097    this.instructions.push(vn), this.hitDetectionInstructions.push(vn);
19098    for (let h = 0; h < l; ++h) {
19099      const c = n[h], u = this.coordinates.length, d = this.appendFlatLineCoordinates(
19100        t,
19101        i,
19102        c,
19103        s,
19104        !0,
19105        !a
19106      ), f = [
19107        tt.MOVE_TO_LINE_TO,
19108        u,
19109        d
19110      ];
19111      this.instructions.push(f), this.hitDetectionInstructions.push(f), a && (this.instructions.push(ed), this.hitDetectionInstructions.push(ed)), i = c;
19112    }
19113    return o && (this.instructions.push(ho), this.hitDetectionInstructions.push(ho)), a && (this.instructions.push(Yi), this.hitDetectionInstructions.push(Yi)), i;
19114  }
19115  /**
19116   * @param {import("../../geom/Circle.js").default} circleGeometry Circle geometry.
19117   * @param {import("../../Feature.js").default} feature Feature.
19118   */
19119  drawCircle(t, i) {
19120    const n = this.state, s = n.fillStyle, r = n.strokeStyle;
19121    if (s === void 0 && r === void 0)
19122      return;
19123    this.setFillStrokeStyles_(), this.beginGeometry(t, i), n.fillStyle !== void 0 && this.hitDetectionInstructions.push([
19124      tt.SET_FILL_STYLE,
19125      Si
19126    ]), n.strokeStyle !== void 0 && this.hitDetectionInstructions.push([
19127      tt.SET_STROKE_STYLE,
19128      n.strokeStyle,
19129      n.lineWidth,
19130      n.lineCap,
19131      n.lineJoin,
19132      n.miterLimit,
19133      n.lineDash,
19134      n.lineDashOffset
19135    ]);
19136    const o = t.getFlatCoordinates(), a = t.getStride(), l = this.coordinates.length;
19137    this.appendFlatLineCoordinates(
19138      o,
19139      0,
19140      o.length,
19141      a,
19142      !1,
19143      !1
19144    );
19145    const h = [tt.CIRCLE, l];
19146    this.instructions.push(vn, h), this.hitDetectionInstructions.push(vn, h), n.fillStyle !== void 0 && (this.instructions.push(ho), this.hitDetectionInstructions.push(ho)), n.strokeStyle !== void 0 && (this.instructions.push(Yi), this.hitDetectionInstructions.push(Yi)), this.endGeometry(i);
19147  }
19148  /**
19149   * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} polygonGeometry Polygon geometry.
19150   * @param {import("../../Feature.js").FeatureLike} feature Feature.
19151   */
19152  drawPolygon(t, i) {
19153    const n = this.state, s = n.fillStyle, r = n.strokeStyle;
19154    if (s === void 0 && r === void 0)
19155      return;
19156    this.setFillStrokeStyles_(), this.beginGeometry(t, i), n.fillStyle !== void 0 && this.hitDetectionInstructions.push([
19157      tt.SET_FILL_STYLE,
19158      Si
19159    ]), n.strokeStyle !== void 0 && this.hitDetectionInstructions.push([
19160      tt.SET_STROKE_STYLE,
19161      n.strokeStyle,
19162      n.lineWidth,
19163      n.lineCap,
19164      n.lineJoin,
19165      n.miterLimit,
19166      n.lineDash,
19167      n.lineDashOffset
19168    ]);
19169    const o = t.getEnds(), a = t.getOrientedFlatCoordinates(), l = t.getStride();
19170    this.drawFlatCoordinatess_(
19171      a,
19172      0,
19173      /** @type {Array<number>} */
19174      o,
19175      l
19176    ), this.endGeometry(i);
19177  }
19178  /**
19179   * @param {import("../../geom/MultiPolygon.js").default} multiPolygonGeometry MultiPolygon geometry.
19180   * @param {import("../../Feature.js").FeatureLike} feature Feature.
19181   */
19182  drawMultiPolygon(t, i) {
19183    const n = this.state, s = n.fillStyle, r = n.strokeStyle;
19184    if (s === void 0 && r === void 0)
19185      return;
19186    this.setFillStrokeStyles_(), this.beginGeometry(t, i), n.fillStyle !== void 0 && this.hitDetectionInstructions.push([
19187      tt.SET_FILL_STYLE,
19188      Si
19189    ]), n.strokeStyle !== void 0 && this.hitDetectionInstructions.push([
19190      tt.SET_STROKE_STYLE,
19191      n.strokeStyle,
19192      n.lineWidth,
19193      n.lineCap,
19194      n.lineJoin,
19195      n.miterLimit,
19196      n.lineDash,
19197      n.lineDashOffset
19198    ]);
19199    const o = t.getEndss(), a = t.getOrientedFlatCoordinates(), l = t.getStride();
19200    let h = 0;
19201    for (let c = 0, u = o.length; c < u; ++c)
19202      h = this.drawFlatCoordinatess_(
19203        a,
19204        h,
19205        o[c],
19206        l
19207      );
19208    this.endGeometry(i);
19209  }
19210  /**
19211   * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
19212   */
19213  finish() {
19214    this.reverseHitDetectionInstructions(), this.state = null;
19215    const t = this.tolerance;
19216    if (t !== 0) {
19217      const i = this.coordinates;
19218      for (let n = 0, s = i.length; n < s; ++n)
19219        i[n] = mn(i[n], t);
19220    }
19221    return super.finish();
19222  }
19223  /**
19224   * @private
19225   */
19226  setFillStrokeStyles_() {
19227    const t = this.state;
19228    t.fillStyle !== void 0 && this.updateFillStyle(t, this.createFill), t.strokeStyle !== void 0 && this.updateStrokeStyle(t, this.applyStroke);
19229  }
19230}
19231const id = Sb;
19232function Tb(e, t, i, n, s) {
19233  const r = [];
19234  let o = i, a = 0, l = t.slice(i, 2);
19235  for (; a < e && o + s < n; ) {
19236    const [h, c] = l.slice(-2), u = t[o + s], d = t[o + s + 1], f = Math.sqrt(
19237      (u - h) * (u - h) + (d - c) * (d - c)
19238    );
19239    if (a += f, a >= e) {
19240      const g = (e - a + f) / f, m = Pe(h, u, g), _ = Pe(c, d, g);
19241      l.push(m, _), r.push(l), l = [m, _], a == e && (o += s), a = 0;
19242    } else if (a < e)
19243      l.push(
19244        t[o + s],
19245        t[o + s + 1]
19246      ), o += s;
19247    else {
19248      const g = f - a, m = Pe(h, u, g / f), _ = Pe(c, d, g / f);
19249      l.push(m, _), r.push(l), l = [m, _], a = 0, o += s;
19250    }
19251  }
19252  return a > 0 && r.push(l), r;
19253}
19254function Ib(e, t, i, n, s) {
19255  let r = i, o = i, a = 0, l = 0, h = i, c, u, d, f, g, m, _, p, y, x;
19256  for (u = i; u < n; u += s) {
19257    const E = t[u], M = t[u + 1];
19258    g !== void 0 && (y = E - g, x = M - m, f = Math.sqrt(y * y + x * x), _ !== void 0 && (l += d, c = Math.acos((_ * y + p * x) / (d * f)), c > e && (l > a && (a = l, r = h, o = u), l = 0, h = u - s)), d = f, _ = y, p = x), g = E, m = M;
19259  }
19260  return l += f, l > a ? [h, u] : [r, o];
19261}
19262const l
19262r = {
19263  left: 0,
19264  end: 0,
19265  center: 0.5,
19266  right: 1,
19267  start: 1,
19268  top: 0,
19269  middle: 0.5,
19270  hanging: 0.2,
19271  alphabetic: 0.8,
19272  ideographic: 0.8,
19273  bottom: 1
19274};
19275class Rb extends Ur {
19276  /**
19277   * @param {number} tolerance Tolerance.
19278   * @param {import("../../extent.js").Extent} maxExtent Maximum extent.
19279   * @param {number} resolution Resolution.
19280   * @param {number} pixelRatio Pixel ratio.
19281   */
19282  constructor(t, i, n, s) {
19283    super(t, i, n, s), this.labels_ = null, this.text_ = "", this.textOffsetX_ = 0, this.textOffsetY_ = 0, this.textRotateWithView_ = void 0, this.textRotation_ = 0, this.textFillState_ = null, this.fillStates = {}, this.textStrokeState_ = null, this.strokeStates = {}, this.textState_ = /** @type {import("../canvas.js").TextState} */
19284    {}, this.textStates = {}, this.textKey_ = "", this.fillKey_ = "", this.strokeKey_ = "", this.declutterImageWithText_ = void 0;
19285  }
19286  /**
19287   * @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
19288   */
19289  finish() {
19290    const t = super.finish();
19291    return t.textStates = this.textStates, t.fillStates = this.fillStates, t.strokeStates = this.strokeStates, t;
19292  }
19293  /**
19294   * @param {import("../../geom/SimpleGeometry.js").default|import("../Feature.js").default} geometry Geometry.
19295   * @param {import("../../Feature.js").FeatureLike} feature Feature.
19296   */
19297  drawText(t, i) {
19298    const n = this.textFillState_, s = this.textStrokeState_, r = this.textState_;
19299    if (this.text_ === "" || !r || !n && !s)
19300      return;
19301    const o = this.coordinates;
19302    let a = o.length;
19303    const l = t.getType();
19304    let h = null, c = t.getStride();
19305    if (r.placement === "line" && (l == "LineString" || l == "MultiLineString" || l == "Polygon" || l == "MultiPolygon")) {
19306      if (!re(this.getBufferedMaxExtent(), t.getExtent()))
19307        return;
19308      let u;
19309      if (h = t.getFlatCoordinates(), l == "LineString")
19310        u = [h.length];
19311      else if (l == "MultiLineString")
19312        u = /** @type {import("../../geom/MultiLineString.js").default} */
19313        t.getEnds();
19314      else if (l == "Polygon")
19315        u = /** @type {import("../../geom/Polygon.js").default} */
19316        t.getEnds().slice(0, 1);
19317      else if (l == "MultiPolygon") {
19318        const m = (
19319          /** @type {import("../../geom/MultiPolygon.js").default} */
19320          t.getEndss()
19321        );
19322        u = [];
19323        for (let _ = 0, p = m.length; _ < p; ++_)
19324          u.push(m[_][0]);
19325      }
19326      this.beginGeometry(t, i);
19327      const d = r.repeat, f = d ? void 0 : r.textAlign;
19328      let g = 0;
19329      for (let m = 0, _ = u.length; m < _; ++m) {
19330        let p;
19331        d ? p = Tb(
19332          d * this.resolution,
19333          h,
19334          g,
19335          u[m],
19336          c
19337        ) : p = [h.slice(g, u[m])];
19338        for (let y = 0, x = p.length; y < x; ++y) {
19339          const E = p[y];
19340          let M = 0, w = E.length;
19341          if (f == null) {
19342            const I = Ib(
19343              r.maxAngle,
19344              E,
19345              0,
19346              E.length,
19347              2
19348            );
19349            M = I[0], w = I[1];
19350          }
19351          for (let I = M; I < w; I += c)
19352            o.push(E[I], E[I + 1]);
19353          const L = o.length;
19354          g = u[m], this.drawChars_(a, L), a = L;
19355        }
19356      }
19357      this.endGeometry(i);
19358    } else {
19359      let u = r.overflow ? null : [];
19360      switch (l) {
19361        case "Point":
19362        case "MultiPoint":
19363          h = /** @type {import("../../geom/MultiPoint.js").default} */
19364          t.getFlatCoordinates();
19365          break;
19366        case "LineString":
19367          h = /** @type {import("../../geom/LineString.js").default} */
19368          t.getFlatMidpoint();
19369          break;
19370        case "Circle":
19371          h = /** @type {import("../../geom/Circle.js").default} */
19372          t.getCenter();
19373          break;
19374        case "MultiLineString":
19375          h = /** @type {import("../../geom/MultiLineString.js").default} */
19376          t.getFlatMidpoints(), c = 2;
19377          break;
19378        case "Polygon":
19379          h = /** @type {import("../../geom/Polygon.js").default} */
19380          t.getFlatInteriorPoint(), r.overflow || u.push(h[2] / this.resolution), c = 3;
19381          break;
19382        case "MultiPolygon":
19383          const _ = (
19384            /** @type {import("../../geom/MultiPolygon.js").default} */
19385            t.getFlatInteriorPoints()
19386          );
19387          h = [];
19388          for (let p = 0, y = _.length; p < y; p += 3)
19389            r.overflow || u.push(_[p + 2] / this.resolution), h.push(_[p], _[p + 1]);
19390          if (h.length === 0)
19391            return;
19392          c = 2;
19393          break;
19394      }
19395      const d = this.appendFlatPointCoordinates(h, c);
19396      if (d === a)
19397        return;
19398      if (u && (d - a) / 2 !== h.length / c) {
19399        let _ = a / 2;
19400        u = u.filter((p, y) => {
19401          const x = o[(_ + y) * 2] === h[y * c] && o[(_ + y) * 2 + 1] === h[y * c + 1];
19402          return x || --_, x;
19403        });
19404      }
19405      this.saveTextStates_(), (r.backgroundFill || r.backgroundStroke) && (this.setFillStrokeStyle(
19406        r.backgroundFill,
19407        r.backgroundStroke
19408      ), r.backgroundFill && (this.updateFillStyle(this.state, this.createFill), this.hitDetectionInstructions.push(this.createFill(this.state))), r.backgroundStroke && (this.updateStrokeStyle(this.state, this.applyStroke), this.hitDetectionInstructions.push(this.createStroke(this.state)))), this.beginGeometry(t, i);
19409      let f = r.padding;
19410      if (f != xn && (r.scale[0] < 0 || r.scale[1] < 0)) {
19411        let _ = r.padding[0], p = r.padding[1], y = r.padding[2], x = r.padding[3];
19412        r.scale[0] < 0 && (p = -p, x = -x), r.scale[1] < 0 && (_ = -_, y = -y), f = [_, p, y, x];
19413      }
19414      const g = this.pixelRatio;
19415      this.instructions.push([
19416        tt.DRAW_IMAGE,
19417        a,
19418        d,
19419        null,
19420        NaN,
19421        NaN,
19422        NaN,
19423        1,
19424        0,
19425        0,
19426        this.textRotateWithView_,
19427        this.textRotation_,
19428        [1, 1],
19429        NaN,
19430        void 0,
19431        this.declutterImageWithText_,
19432        f == xn ? xn : f.map(function(_) {
19433          return _ * g;
19434        }),
19435        !!r.backgroundFill,
19436        !!r.backgroundStroke,
19437        this.text_,
19438        this.textKey_,
19439        this.strokeKey_,
19440        this.fillKey_,
19441        this.textOffsetX_,
19442        this.textOffsetY_,
19443        u
19444      ]);
19445      const m = 1 / g;
19446      this.hitDetectionInstructions.push([
19447        tt.DRAW_IMAGE,
19448        a,
19449        d,
19450        null,
19451        NaN,
19452        NaN,
19453        NaN,
19454        1,
19455        0,
19456        0,
19457        this.textRotateWithView_,
19458        this.textRotation_,
19459        [m, m],
19460        NaN,
19461        void 0,
19462        this.declutterImageWithText_,
19463        f,
19464        !!r.backgroundFill,
19465        !!r.backgroundStroke,
19466        this.text_,
19467        this.textKey_,
19468        this.strokeKey_,
19469        this.fillKey_,
19470        this.textOffsetX_,
19471        this.textOffsetY_,
19472        u
19473      ]), this.endGeometry(i);
19474    }
19475  }
19476  /**
19477   * @private
19478   */
19479  saveTextStates_() {
19480    const t = this.textStrokeState_, i = this.textState_, n = this.textFillState_, s = this.strokeKey_;
19481    t && (s in this.strokeStates || (this.strokeStates[s] = {
19482      strokeStyle: t.strokeStyle,
19483      lineCap: t.lineCap,
19484      lineDashOffset: t.lineDashOffset,
19485      lineWidth: t.lineWidth,
19486      lineJoin: t.lineJoin,
19487      miterLimit: t.miterLimit,
19488      lineDash: t.lineDash
19489    }));
19490    const r = this.textKey_;
19491    r in this.textStates || (this.textStates[r] = {
19492      font: i.font,
19493      textAlign: i.textAlign || wr,
19494      justify: i.justify,
19495      textBaseline: i.textBaseline || Yo,
19496      scale: i.scale
19497    });
19498    const o = this.fillKey_;
19499    n && (o in this.fillStates || (this.fillStates[o] = {
19500      fillStyle: n.fillStyle
19501    }));
19502  }
19503  /**
19504   * @private
19505   * @param {number} begin Begin.
19506   * @param {number} end End.
19507   */
19508  drawChars_(t, i) {
19509    const n = this.textStrokeState_, s = this.textState_, r = this.strokeKey_, o = this.textKey_, a = this.fillKey_;
19510    this.saveTextStates_();
19511    const l = this.pixelRatio, h = lr[s.textBaseline], c = this.textOffsetY_ * l, u = this.text_, d = n ? n.lineWidth * Math.abs(s.scale[0]) / 2 : 0;
19512    this.instructions.push([
19513      tt.DRAW_CHARS,
19514      t,
19515      i,
19516      h,
19517      s.overflow,
19518      a,
19519      s.maxAngle,
19520      l,
19521      c,
19522      r,
19523      d * l,
19524      u,
19525      o,
19526      1
19527    ]), this.hitDetectionInstructions.push([
19528      tt.DRAW_CHARS,
19529      t,
19530      i,
19531      h,
19532      s.overflow,
19533      a,
19534      s.maxAngle,
19535      1,
19536      c,
19537      r,
19538      d,
19539      u,
19540      o,
19541      1 / l
19542    ]);
19543  }
19544  /**
19545   * @param {import("../../style/Text.js").default} textStyle Text style.
19546   * @param {Object} [sharedData] Shared data.
19547   */
19548  setTextStyle(t, i) {
19549    let n, s, r;
19550    if (!t)
19551      this.text_ = "";
19552    else {
19553      const o = t.getFill();
19554      o ? (s = this.textFillState_, s || (s = /** @type {import("../canvas.js").FillState} */
19555      {}, this.textFillState_ = s), s.fillStyle = li(
19556        o.getColor() || Si
19557      )) : (s = null, this.textFillState_ = s);
19558      const a = t.getStroke();
19559      if (!a)
19560        r = null, this.textStrokeState_ = r;
19561      else {
19562        r = this.textStrokeState_, r || (r = /** @type {import("../canvas.js").StrokeState} */
19563        {}, this.textStrokeState_ = r);
19564        const g = a.getLineDash(), m = a.getLineDashOffset(), _ = a.getWidth(), p = a.getMiterLimit();
19565        r.lineCap = a.getLineCap() || $o, r.lineDash = g ? g.slice() : Er, r.lineDashOffset = m === void 0 ? Cr : m, r.lineJoin = a.getLineJoin() || Os, r.lineWidth = _ === void 0 ? Sr : _, r.miterLimit = p === void 0 ? Mr : p, r.strokeStyle = li(
19566          a.getColor() || br
19567        );
19568      }
19569      n = this.textState_;
19570      const l = t.getFont() || Ig;
19571      UC(l);
19572      const h = t.getScaleArray();
19573      n.overflow = t.getOverflow(), n.font = l, n.maxAngle = t.getMaxAngle(), n.placement = t.getPlacement(), n.textAlign = t.getTextAlign(), n.repeat = t.getRepeat(), n.justify = t.getJustify(), n.textBaseline = t.getTextBaseline() || Yo, n.backgroundFill = t.getBackgroundFill(), n.backgroundStroke = t.getBackgroundStroke(), n.padding = t.getPadding() || xn, n.scale = h === void 0 ? [1, 1] : h;
19574      const c = t.getOffsetX(), u = t.getOffsetY(), d = t.getRotateWithView(), f = t.getRotation();
19575      this.text_ = t.getText() || "", this.textOffsetX_ = c === void 0 ? 0 : c, this.textOffsetY_ = u === void 0 ? 0 : u, this.textRotateWithView_ = d === void 0 ? !1 : d, this.textRotation_ = f === void 0 ? 0 : f, this.strokeKey_ = r ? (typeof r.strokeStyle == "string" ? r.strokeStyle : lt(r.strokeStyle)) + r.lineCap + r.lineDashOffset + "|" + r.lineWidth + r.lineJoin + r.miterLimit + "[" + r.lineDash.join() + "]" : "", this.textKey_ = n.font + n.scale + (n.textAlign || "?") + (n.repeat || "?") + (n.justify || "?") + (n.textBaseline || "?"), this.fillKey_ = s ? typeof s.fillStyle == "string" ? s.fillStyle : "|" + lt(s.fillStyle) : "";
19576    }
19577    this.declutterImageWithText_ = i;
19578  }
19579}
19580const Pb = {
19581  Circle: id,
19582  Default: Ur,
19583  Image: Mb,
19584  LineString: wb,
19585  Polygon: id,
19586  Text: Rb
19587};
19588class Lb {
19589  /**
19590   * @param {number} tolerance Tolerance.
19591   * @param {import("../../extent.js").Extent} maxExtent Max extent.
19592   * @param {number} resolution Resolution.
19593   * @param {number} pixelRatio Pixel ratio.
19594   */
19595  constructor(t, i, n, s) {
19596    this.tolerance_ = t, this.maxExtent_ = i, this.pixelRatio_ = s, this.resolution_ = n, this.buildersByZIndex_ = {};
19597  }
19598  /**
19599   * @return {!Object<string, !Object<import("../canvas.js").BuilderType, import("./Builder.js").SerializableInstructions>>}
19599 The serializable instructions
19600   */
19601  finish() {
19602    const t = {};
19603    for (const i in this.buildersByZIndex_) {
19604      t[i] = t[i] || {};
19605      const n = this.buildersByZIndex_[i];
19606      for (const s in n) {
19607        const r = n[s].finish();
19608        t[i][s] = r;
19609      }
19610    }
19611    return t;
19612  }
19613  /**
19614   * @param {number|undefined} zIndex Z index.
19615   * @param {import("../canvas.js").BuilderType} builderType Replay type.
19616   * @return {import("../VectorContext.js").default} Replay.
19617   */
19618  getBuilder(t, i) {
19619    const n = t !== void 0 ? t.toString() : "0";
19620    let s = this.buildersByZIndex_[n];
19621    s === void 0 && (s = {}, this.buildersByZIndex_[n] = s);
19622    let r = s[i];
19623    if (r === void 0) {
19624      const o = Pb[i];
19625      r = new o(
19626        this.tolerance_,
19627        this.maxExtent_,
19628        this.resolution_,
19629        this.pixelRatio_
19630      ), s[i] = r;
19631    }
19632    return r;
19633  }
19634}
19635const nd = Lb;
19636class Ab extends lg {
19637  /**
19638   * @param {LayerType} layer Layer.
19639   */
19640  constructor(t) {
19641    super(), this.ready = !0, this.boundHandleImageChange_ = this.handleImageChange_.bind(this), this.layer_ = t, this.declutterExecutorGroup = null;
19642  }
19643  /**
19644   * Asynchronous layer level hit detection.
19645   * @param {import("../pixel.js").Pixel} pixel Pixel.
19646   * @return {Promise<Array<import("../Feature").FeatureLike>>} Promise that resolves with
19647   * an array of features.
19648   */
19649  getFeatures(t) {
19650    return Q();
19651  }
19652  /**
19653   * @param {import("../pixel.js").Pixel} pixel Pixel.
19654   * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
19655   */
19656  getData(t) {
19657    return null;
19658  }
19659  /**
19660   * Determine whether render should be called.
19661   * @abstract
19662   * @param {import("../Map.js").FrameState} frameState Frame state.
19663   * @return {boolean} Layer is ready to be rendered.
19664   */
19665  prepareFrame(t) {
19666    return Q();
19667  }
19668  /**
19669   * Render the layer.
19670   * @abstract
19671   * @param {import("../Map.js").FrameState} frameState Frame state.
19672   * @param {HTMLElement} target Target that may be used to render content to.
19673   * @return {HTMLElement} The rendered element.
19674   */
19675  renderFrame(t, i) {
19676    return Q();
19677  }
19678  /**
19679   * @param {Object<number, Object<string, import("../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level.
19680   * @param {number} zoom Zoom level.
19681   * @param {import("../Tile.js").default} tile Tile.
19682   * @return {boolean|void} If `false`, the tile will not be considered loaded.
19683   */
19684  loadedTileCallback(t, i, n) {
19685    t[i] || (t[i] = {}), t[i][n.tileCoord.toString()] = n;
19686  }
19687  /**
19688   * Create a function that adds loaded tiles to the tile lookup.
19689   * @param {import("../source/Tile.js").default} source Tile source.
19690   * @param {import("../proj/Projection.js").default} projection Projection of the tiles.
19691   * @param {Object<number, Object<string, import("../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level.
19692   * @return {function(number, import("../TileRange.js").default):boolean} A function that can be
19693   *     called with a zoom level and a tile range to add loaded tiles to the lookup.
19694   * @protected
19695   */
19696  createLoadedTileFinder(t, i, n) {
19697    return (
19698      /**
19699       * @param {number} zoom Zoom level.
19700       * @param {import("../TileRange.js").default} tileRange Tile range.
19701       * @return {boolean} The tile range is fully loaded.
19702       */
19703      (s, r) => {
19704        const o = this.loadedTileCallback.bind(this, n, s);
19705        return t.forEachLoadedTile(i, s, r, o);
19706      }
19707    );
19708  }
19709  /**
19710   * @abstract
19711   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
19712   * @param {import("../Map.js").FrameState} frameState Frame state.
19713   * @param {number} hitTolerance Hit tolerance in pixels.
19714   * @param {import("./vector.js").FeatureCallback<T>} callback Feature callback.
19715   * @param {Array<import("./Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
19716   * @return {T|undefined} Callback result.
19717   * @template T
19718   */
19719  forEachFeatureAtCoordinate(t, i, n, s, r) {
19720  }
19721  /**
19722   * @return {LayerType} Layer.
19723   */
19724  getLayer() {
19725    return this.layer_;
19726  }
19727  /**
19728   * Perform action necessary to get the layer rendered after new fonts have loaded
19729   * @abstract
19730   */
19731  handleFontsChanged() {
19732  }
19733  /**
19734   * Handle changes in image state.
19735   * @param {import("../events/Event.js").default} event Image change event.
19736   * @private
19737   */
19738  handleImageChange_(t) {
19739    /** @type {import("../Image.js").default} */
19740    t.target.getState() === at.LOADED && this.renderIfReadyAndVisible();
19741  }
19742  /**
19743   * Load the image if not already loaded, and register the image change
19744   * listener if needed.
19745   * @param {import("../ImageBase.js").default} image Image.
19746   * @return {boolean} `true` if the image is already loaded, `false` otherwise.
19747   * @protected
19748   */
19749  loadImage(t) {
19750    let i = t.getState();
19751    return i != at.LOADED && i != at.ERROR && t.addEventListener(et.CHANGE, this.boundHandleImageChange_), i == at.IDLE && (t.load(), i = t.getState()), i == at.LOADED;
19752  }
19753  /**
19754   * @protected
19755   */
19756  renderIfReadyAndVisible() {
19757    const t = this.getLayer();
19758    t && t.getVisible() && t.getSourceState() === "ready" && t.changed();
19759  }
19760  /**
19761   * Clean up.
19762   */
19763  disposeInternal() {
19764    delete this.layer_, super.disposeInternal();
19765  }
19766}
19767const Ob = Ab, sd = [];
19768let Jn = null;
19769function Fb() {
19770  Jn = he(1, 1, void 0, {
19771    willReadFrequently: !0
19772  });
19773}
19774class kb extends Ob {
19775  /**
19776   * @param {LayerType} layer Layer.
19777   */
19778  constructor(t) {
19779    super(t), this.container = null, this.renderedResolution, this.tempTransform = ui(), this.pixelTransform = ui(), this.inversePixelTransform = ui(), this.context = null, this.containerReused = !1, this.pixelContext_ = null, this.frameState = null;
19780  }
19781  /**
19782   * @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
19783   * @param {number} col The column index.
19784   * @param {number} row The row index.
19785   * @return {Uint8ClampedArray|null} The image data.
19786   */
19787  getImageData(t, i, n) {
19788    Jn || Fb(), Jn.clearRect(0, 0, 1, 1);
19789    let s;
19790    try {
19791      Jn.drawImage(t, i, n, 1, 1, 0, 0, 1, 1), s = Jn.getImageData(0, 0, 1, 1).data;
19792    } catch {
19793      return Jn = null, null;
19794    }
19795    return s;
19796  }
19797  /**
19798   * @param {import('../../Map.js').FrameState} frameState Frame state.
19799   * @return {string}
19799 Background color.
19800   */
19801  getBackground(t) {
19802    let n = this.getLayer().getBackground();
19803    return typeof n == "function" && (n = n(t.viewState.resolution)), n || void 0;
19804  }
19805  /**
19806   * Get a rendering container from an existing target, if compatible.
19807   * @param {HTMLElement} target Potential render target.
19808   * @param {string} transform CSS Transform.
19809   * @param {string} [backgroundColor] Background color.
19810   */
19811  useContainer(t, i, n) {
19812    const s = this.getLayer().getClassName();
19813    let r, o;
19814    if (t && t.className === s && (!n || t && t.style.backgroundColor && Pi(
19815      Wo(t.style.backgroundColor),
19816      Wo(n)
19817    ))) {
19818      const a = t.firstElementChild;
19819      a instanceof HTMLCanvasElement && (o = a.getContext("2d"));
19820    }
19821    if (o && o.canvas.style.transform === i ? (this.container = t, this.context = o, this.containerReused = !0) : this.containerReused && (this.container = null, this.context = null, this.containerReused = !1), !this.container) {
19822      r = document.createElement("div"), r.className = s;
19823      let a = r.style;
19824      a.position = "absolute", a.width = "100%", a.height = "100%", o = he();
19825      const l = o.canvas;
19826      r.appendChild(l), a = l.style, a.position = "absolute", a.left = "0", a.transformOrigin = "top left", this.container = r, this.context = o;
19827    }
19828    !this.containerReused && n && !this.container.style.backgroundColor && (this.container.style.backgroundColor = n);
19829  }
19830  /**
19831   * @param {CanvasRenderingContext2D} context Context.
19832   * @param {import("../../Map.js").FrameState} frameState Frame state.
19833   * @param {import("../../extent.js").Extent} extent Clip extent.
19834   * @protected
19835   */
19836  clipUnrotated(t, i, n) {
19837    const s = Dn(n), r = oa(n), o = ra(n), a = sa(n);
19838    Bt(i.coordinateToPixelTransform, s), Bt(i.coordinateToPixelTransform, r), Bt(i.coordinateToPixelTransform, o), Bt(i.coordinateToPixelTransform, a);
19839    const l = this.inversePixelTransform;
19840    Bt(l, s), Bt(l, r), Bt(l, o), Bt(l, a), t.save(), t.beginPath(), t.moveTo(Math.round(s[0]), Math.round(s[1])), t.lineTo(Math.round(r[0]), Math.round(r[1])
19840), t.lineTo(Math.round(o[0]), Math.round(o[1])), t.lineTo(Math.round(a[0]), Math.round(a[1])), t.clip();
19841  }
19842  /**
19843   * @param {import("../../render/EventType.js").default} type Event type.
19844   * @param {CanvasRenderingContext2D} context Context.
19845   * @param {import("../../Map.js").FrameState} frameState Frame state.
19846   * @private
19847   */
19848  dispatchRenderEvent_(t, i, n) {
19849    const s = this.getLayer();
19850    if (s.hasListener(t)) {
19851      const r = new Sg(
19852        t,
19853        this.inversePixelTransform,
19854        n,
19855        i
19856      );
19857      s.dispatchEvent(r);
19858    }
19859  }
19860  /**
19861   * @param {CanvasRenderingContext2D} context Context.
19862   * @param {import("../../Map.js").FrameState} frameState Frame state.
19863   * @protected
19864   */
19865  preRender(t, i) {
19866    this.frameState = i, this.dispatchRenderEvent_(Ji.PRERENDER, t, i);
19867  }
19868  /**
19869   * @param {CanvasRenderingContext2D} context Context.
19870   * @param {import("../../Map.js").FrameState} frameState Frame state.
19871   * @protected
19872   */
19873  postRender(t, i) {
19874    this.dispatchRenderEvent_(Ji.POSTRENDER, t, i);
19875  }
19876  /**
19877   * Creates a transform for rendering to an element that will be rotated after rendering.
19878   * @param {import("../../coordinate.js").Coordinate} center Center.
19879   * @param {number} resolution Resolution.
19880   * @param {number} rotation Rotation.
19881   * @param {number} pixelRatio Pixel ratio.
19882   * @param {number} width Width of the rendered element (in pixels).
19883   * @param {number} height Height of the rendered element (in pixels).
19884   * @param {number} offsetX Offset on the x-axis in view coordinates.
19885   * @protected
19886   * @return {!import("../../transform.js").Transform} Transform.
19887   */
19888  getRenderTransform(t, i, n, s, r, o, a) {
19889    const l = r / 2, h = o / 2, c = s / i, u = -c, d = -t[0] + a, f = -t[1];
19890    return gi(
19891      this.tempTransform,
19892      l,
19893      h,
19894      c,
19895      u,
19896      -n,
19897      d,
19898      f
19899    );
19900  }
19901  /**
19902   * Clean up.
19903   */
19904  disposeInternal() {
19905    delete this.frameState, super.disposeInternal();
19906  }
19907}
19908const cc = kb;
19909function Db(e, t, i, n, s, r, o, a, l, h, c, u) {
19910  let d = e[t], f = e[t + 1], g = 0, m = 0, _ = 0, p = 0;
19911  function y() {
19912    g = d, m = f, t += n, d = e[t], f = e[t + 1], p += _, _ = Math.sqrt((d - g) * (d - g) + (f - m) * (f - m));
19913  }
19914  do
19915    y();
19916  while (t < i - n && p + _ < r);
19917  let x = _ === 0 ? 0 : (r - p) / _;
19918  const E = Pe(g, d, x), M = Pe(m, f, x), w = t - n, L = p, I = r + a * l(h, s, c);
19919  for (; t < i - n && p + _ < I; )
19920    y();
19921  x = _ === 0 ? 0 : (I - p) / _;
19922  const z = Pe(g, d, x), U = Pe(m, f, x);
19923  let q;
19924  if (u) {
19925    const Y = [E, M, z, U];
19926    zh(Y, 0, 4, 2, u, Y, Y), q = Y[0] > Y[2];
19927  } else
19928    q = E > z;
19929  const K = Math.PI, Z = [], Mt = w + n === t;
19930  t = w, _ = 0, p = L, d = e[t], f = e[t + 1];
19931  let V;
19932  if (Mt) {
19933    y(), V = Math.atan2(f - m, d - g), q && (V += V > 0 ? -K : K);
19934    const Y = (z + E) / 2, O = (U + M) / 2;
19935    return Z[0] = [Y, O, (I - r) / 2, V, s], Z;
19936  }
19937  s = s.replace(/\n/g, " ");
19938  for (let Y = 0, O = s.length; Y < O; ) {
19939    y();
19940    let W = Math.atan2(f - m, d - g);
19941    if (q && (W += W > 0 ? -K : K), V !== void 0) {
19942      let vt = W - V;
19943      if (vt += vt > K ? -2 * K : vt < -K ? 2 * K : 0, Math.abs(vt) > o)
19944        return null;
19945    }
19946    V = W;
19947    const gt = Y;
19948    let _t = 0;
19949    for (; Y < O; ++Y) {
19950      const vt = q ? O - Y - 1 : Y, bt = a * l(h, s[vt], c);
19951      if (t + n < i && p + _ < r + _t + bt / 2)
19952        break;
19953      _t += bt;
19954    }
19955    if (Y === gt)
19956      continue;
19957    const Pt = q ? s.substring(O - gt, O - Y) : s.substring(gt, Y);
19958    x = _ === 0 ? 0 : (r + _t / 2 - p) / _;
19959    const R = Pe(g, d, x), Jt = Pe(m, f, x);
19960    Z.push([R, Jt, _t / 2, W, Pt]), r += _t;
19961  }
19962  return Z;
19963}
19964const $n = be(), Oi = [], pi = [], yi = [], Fi = [];
19965function rd(e) {
19966  return e[3].declutterBox;
19967}
19968const Nb = new RegExp(
19969  /* eslint-disable prettier/prettier */
19970  "[" + String.fromCharCode(1425) + "-" + String.fromCharCode(2303) + String.fromCharCode(64285) + "-" + String.fromCharCode(65023) + String.fromCharCode(65136) + "-" + String.fromCharCode(65276) + String.fromCharCode(67584) + "-" + String.fromCharCode(69631) + String.fromCharCode(124928) + "-" + String.fromCharCode(126975) + "]"
19971  /* eslint-enable prettier/prettier */
19972);
19973function od(e, t) {
19974  return (t === "start" || t === "end") && !Nb.test(e) && (t = t === "start" ? "left" : "right"), lr[t];
19975}
19976function Gb(e, t, i) {
19977  return i > 0 && e.push(`
19978`, ""), e.push(t, ""), e;
19979}
19980class zb {
19981  /**
19982   * @param {number} resolution Resolution.
19983   * @param {number} pixelRatio Pixel ratio.
19984   * @param {boolean} overlaps The replay can have overlapping geometries.
19985   * @param {import("../canvas.js").SerializableInstructions}
19985 instructions The serializable instructions
19986   */
19987  constructor(t, i, n, s) {
19988    this.overlaps = n, this.pixelRatio = i, this.resolution = t, this.alignFill_, this.instructions = s.instructions, this.coordinates = s.coordinates, this.coordinateCache_ = {}, this.renderedTransform_ = ui(), this.hitDetectionInstructions = s.hitDetectionInstructions, this.pixelCoordinates_ = null, this.viewRotation_ = 0, this.fillStates = s.fillStates || {}, this.strokeStates = s.strokeStates || {}, this.textStates = s.textStates || {}, this.widths_ = {}, this.labels_ = {};
19989  }
19990  /**
19991   * @param {string|Array<string>} text Text.
19992   * @param {string} textKey Text style key.
19993   * @param {string} fillKey Fill style key.
19994   * @param {string} strokeKey Stroke style key.
19995   * @return {import("../canvas.js").Label} Label.
19996   */
19997  createLabel(t, i, n, s) {
19998    const r = t + i + n + s;
19999    if (this.labels_[r])
20000      return this.labels_[r];
20001    const o = s ? this.strokeStates[s] : null, a = n ? this.fillStates[n] : null, l = this.textStates[i], h = this.pixelRatio, c = [
20002      l.scale[0] * h,
20003      l.scale[1] * h
20004    ], u = Array.isArray(t), d = l.justify ? lr[l.justify] : od(
20005      Array.isArray(t) ? t[0] : t,
20006      l.textAlign || wr
20007    ), f = s && o.lineWidth ? o.lineWidth : 0, g = u ? t : t.split(`
20008`).reduce(Gb, []), { width: m, height: _, widths: p, heights: y, lineWidths: x } = $C(
20009      l,
20010      g
20011    ), E = m + f, M = [], w = (E + 2) * c[0], L = (_ + f) * c[1], I = {
20012      width: w < 0 ? Math.floor(w) : Math.ceil(w),
20013      height: L < 0 ? Math.floor(L) : Math.ceil(L),
20014      contextInstructions: M
20015    };
20016    (c[0] != 1 || c[1] != 1) && M.push("scale", c), s && (M.push("strokeStyle", o.strokeStyle), M.push("lineWidth", f), M.push("lineCap", o.lineCap), M.push("lineJoin", o.lineJoin), M.push("miterLimit", o.miterLimit), M.push("setLineDash", [o.lineDash]), M.push("lineDashOffset", o.lineDashOffset)), n && M.push("fillStyle", a.fillStyle), M.push("textBaseline", "middle"), M.push("textAlign", "center");
20017    const z = 0.5 - d;
20018    let U = d * E + z * f;
20019    const q = [], K = [];
20020    let Z = 0, Mt = 0, V = 0, Y = 0, O;
20021    for (let W = 0, gt = g.length; W < gt; W += 2) {
20022      const _t = g[W];
20023      if (_t === `
20024`) {
20025        Mt += Z, Z = 0, U = d * E + z * f, ++Y;
20026        continue;
20027      }
20028      const Pt = g[W + 1] || l.font;
20029      Pt !== O && (s && q.push("font", Pt), n && K.push("font", Pt), O = Pt), Z = Math.max(Z, y[V]);
20030      const R = [
20031        _t,
20032        U + z * p[V] + d * (p[V] - x[Y]),
20033        0.5 * (f + Z) + Mt
20034      ];
20035      U += p[V], s && q.push("strokeText", R), n && K.push("fillText", R), ++V;
20036    }
20037    return Array.prototype.push.apply(M, q), Array.prototype.push.apply(M, K), this.labels_[r] = I, I;
20038  }
20039  /**
20040   * @param {CanvasRenderingContext2D} context Context.
20041   * @param {import("../../coordinate.js").Coordinate} p1 1st point of the background box.
20042   * @param {import("../../coordinate.js").Coordinate} p2 2nd point of the background box.
20043   * @param {import("../../coordinate.js").Coordinate} p3 3rd point of the background box.
20044   * @param {import("../../coordinate.js").Coordinate} p4 4th point of the background box.
20045   * @param {Array<*>} fillInstruction Fill instruction.
20046   * @param {Array<*>} strokeInstruction Stroke instruction.
20047   */
20048  replayTextBackground_(t, i, n, s, r, o, a) {
20049    t.beginPath(), t.moveTo.apply(t, i), t.lineTo.apply(t, n), t.lineTo.apply(t, s), t.lineTo.apply(t, r), t.lineTo.apply(t, i), o && (this.alignFill_ = /** @type {boolean} */
20050    o[2], this.fill_(t)), a && (this.setStrokeStyle_(
20051      t,
20052      /** @type {Array<*>} */
20053      a
20054    ), t.stroke());
20055  }
20056  /**
20057   * @private
20058   * @param {number} sheetWidth Width of the sprite sheet.
20059   * @param {number} sheetHeight Height of the sprite sheet.
20060   * @param {number} centerX X.
20061   * @param {number} centerY Y.
20062   * @param {number} width Width.
20063   * @param {number} height Height.
20064   * @param {number} anchorX Anchor X.
20065   * @param {number} anchorY Anchor Y.
20066   * @param {number} originX Origin X.
20067   * @param {number} originY Origin Y.
20068   * @param {number} rotation Rotation.
20069   * @param {import("../../size.js").Size} scale Scale.
20070   * @param {boolean} snapToPixel Snap to pixel.
20071   * @param {Array<number>} padding Padding.
20072   * @param {boolean}
20072 fillStroke Background fill or stroke.
20073   * @param {import("../../Feature.js").FeatureLike} feature Feature.
20074   * @return {ImageOrLabelDimensions} Dimensions for positioning and decluttering the image or label.
20075   */
20076  calculateImageOrLabelDimensions_(t, i, n, s, r, o, a, l, h, c, u, d, f, g, m, _) {
20077    a *= d[0], l *= d[1];
20078    let p = n - a, y = s - l;
20079    const x = r + h > t ? t - h : r, E = o + c > i ? i - c : o, M = g[3] + x * d[0] + g[1], w = g[0] + E * d[1] + g[2], L = p - g[3], I = y - g[0];
20080    (m || u !== 0) && (Oi[0] = L, Fi[0] = L, Oi[1] = I, pi[1] = I, pi[0] = L + M, yi[0] = pi[0], yi[1] = I + w, Fi[1] = yi[1]);
20081    let z;
20082    return u !== 0 ? (z = gi(
20083      ui(),
20084      n,
20085      s,
20086      1,
20087      1,
20088      u,
20089      -n,
20090      -s
20091    ), Bt(z, Oi), Bt(z, pi), Bt(z, yi), Bt(z, Fi), fi(
20092      Math.min(Oi[0], pi[0], yi[0], Fi[0]),
20093      Math.min(Oi[1], pi[1], yi[1], Fi[1]),
20094      Math.max(Oi[0], pi[0], yi[0], Fi[0]),
20095      Math.max(Oi[1], pi[1], yi[1], Fi[1]),
20096      $n
20097    )) : fi(
20098      Math.min(L, L + M),
20099      Math.min(I, I + w),
20100      Math.max(L, L + M),
20101      Math.max(I, I + w),
20102      $n
20103    ), f && (p = Math.round(p), y = Math.round(y)), {
20104      drawImageX: p,
20105      drawImageY: y,
20106      drawImageW: x,
20107      drawImageH: E,
20108      originX: h,
20109      originY: c,
20110      declutterBox: {
20111        minX: $n[0],
20112        minY: $n[1],
20113        maxX: $n[2],
20114        maxY: $n[3],
20115        value: _
20116      },
20117      canvasTransform: z,
20118      scale: d
20119    };
20120  }
20121  /**
20122   * @private
20123   * @param {CanvasRenderingContext2D} context Context.
20124   * @param {number} contextScale Scale of the context.
20125   * @param {import("../canvas.js").Label|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} imageOrLabel Image.
20126   * @param {ImageOrLabelDimensions} dimensions Dimensions.
20127   * @param {number} opacity Opacity.
20128   * @param {Array<*>} fillInstruction Fill instruction.
20129   * @param {Array<*>} strokeInstruction Stroke instruction.
20130   * @return {boolean} The image or label was rendered.
20131   */
20132  replayImageOrLabel_(t, i, n, s, r, o, a) {
20133    const l = !!(o || a), h = s.declutterBox, c = t.canvas, u = a ? a[2] * s.scale[0] / 2 : 0;
20134    return h.minX - u <= c.width / i && h.maxX + u >= 0 && h.minY - u <= c.height / i && h.maxY + u >= 0 && (l && this.replayTextBackground_(
20135      t,
20136      Oi,
20137      pi,
20138      yi,
20139      Fi,
20140      /** @type {Array<*>} */
20141      o,
20142      /** @type {Array<*>} */
20143      a
20144    ), YC(
20145      t,
20146      s.canvasTransform,
20147      r,
20148      n,
20149      s.originX,
20150      s.originY,
20151      s.drawImageW,
20152      s.drawImageH,
20153      s.drawImageX,
20154      s.drawImageY,
20155      s.scale
20156    )), !0;
20157  }
20158  /**
20159   * @private
20160   * @param {CanvasRenderingContext2D} context Context.
20161   */
20162  fill_(t) {
20163    if (this.alignFill_) {
20164      const i = Bt(this.renderedTransform_, [0, 0]), n = 512 * this.pixelRatio;
20165      t.save(), t.translate(i[0] % n, i[1] % n), t.rotate(this.viewRotation_);
20166    }
20167    t.fill(), this.alignFill_ && t.restore();
20168  }
20169  /**
20170   * @private
20171   * @param {CanvasRenderingContext2D} context Context.
20172   * @param {Array<*>} instruction Instruction.
20173   */
20174  setStrokeStyle_(t, i) {
20175    t.strokeStyle = /** @type {import("../../colorlike.js").ColorLike} */
20176    i[1], t.lineWidth = /** @type {number} */
20177    i[2], t.lineCap = /** @type {CanvasLineCap} */
20178    i[3], t.lineJoin = /** @type {CanvasLineJoin} */
20179    i[4], t.miterLimit = /** @type {number} */
20180    i[5], t.lineDashOffset = /** @type {number} */
20181    i[7], t.setLineDash(
20182      /** @type {Array<number>} */
20183      i[6]
20184    );
20185  }
20186  /**
20187   * @private
20188   * @param {string|Array<string>} text The text to draw.
20189   * @param {string} textKey The key of the text state.
20190   * @param {string} strokeKey The key for the stroke state.
20191   * @param {string} fillKey The key for the fill state.
20192   * @return {{label: import("../canvas.js").Label, anchorX: number, anchorY: number}} The text image and its anchor.
20193   */
20194  drawLabelWithPointPlacement_(t, i, n, s) {
20195    const r = this.textStates[i], o = this.createLabel(t, i, s, n), a = this.strokeStates[n], l = this.pixelRatio, h = od(
20196      Array.isArray(t) ? t[0] : t,
20197      r.textAlign || wr
20198    ), c = lr[r.textBaseline || Yo], u = a && a.lineWidth ? a.lineWidth : 0, d = o.width / l - 2 * r.scale[0], f = h * d + 2 * (0.5 - h) * u, g = c * o.height / l + 2 * (0.5 - c) * u;
20199    return {
20200      label: o,
20201      anchorX: f,
20202      anchorY: g
20203    };
20204  }
20205  /**
20206   * @private
20207   * @param {CanvasRenderingContext2D} context Context.
20208   * @param {number} contextScale Scale of the context.
20209   * @param {import("../../transform.js").Transform} transform Transform.
20210   * @param {Array<*>}
20210 instructions Instructions array.
20211   * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
20212   * @param {FeatureCallback<T>} [featureCallback] Feature callback.
20213   * @param {import("../../extent.js").Extent} [hitExtent] Only check
20214   *     features that intersect this extent.
20215   * @param {import("rbush").default} [declutterTree] Declutter tree.
20216   * @return {T|undefined} Callback result.
20217   * @template T
20218   */
20219  execute_(t, i, n, s, r, o, a, l) {
20220    let h;
20221    this.pixelCoordinates_ && Pi(n, this.renderedTransform_) ? h = this.pixelCoordinates_ : (this.pixelCoordinates_ || (this.pixelCoordinates_ = []), h = wn(
20222      this.coordinates,
20223      0,
20224      this.coordinates.length,
20225      2,
20226      n,
20227      this.pixelCoordinates_
20228    ), UE(this.renderedTransform_, n));
20229    let c = 0;
20230    const u = s.length;
20231    let d = 0, f, g, m, _, p, y, x, E, M, w, L, I, z = 0, U = 0, q = null, K = null;
20232    const Z = this.coordinateCache_, Mt = this.viewRotation_, V = Math.round(Math.atan2(-n[1], n[0]) * 1e12) / 1e12, Y = (
20233      /** @type {import("../../render.js").State} */
20234      {
20235        context: t,
20236        pixelRatio: this.pixelRatio,
20237        resolution: this.resolution,
20238        rotation: Mt
20239      }
20240    ), O = this.instructions != s || this.overlaps ? 0 : 200;
20241    let W, gt, _t, Pt;
20242    for (; c < u; ) {
20243      const R = s[c];
20244      switch (
20245        /** @type {import("./Instruction.js").default} */
20246        R[0]
20247      ) {
20248        case tt.BEGIN_GEOMETRY:
20249          W = /** @type {import("../../Feature.js").FeatureLike} */
20250          R[1], Pt = R[3], W.getGeometry() ? a !== void 0 && !re(a, Pt.getExtent()) ? c = /** @type {number} */
20251          R[2] + 1 : ++c : c = /** @type {number} */
20252          R[2];
20253          break;
20254        case tt.BEGIN_PATH:
20255          z > O && (this.fill_(t), z = 0), U > O && (t.stroke(), U = 0), !z && !U && (t.beginPath(), _ = NaN, p = NaN), ++c;
20256          break;
20257        case tt.CIRCLE:
20258          d = /** @type {number} */
20259          R[1];
20260          const vt = h[d], bt = h[d + 1], $t = h[d + 2], ce = h[d + 3], zt = $t - vt, Qt = ce - bt, ti = Math.sqrt(zt * zt + Qt * Qt);
20261          t.moveTo(vt + ti, bt), t.arc(vt, bt, ti, 0, 2 * Math.PI, !0), ++c;
20262          break;
20263        case tt.CLOSE_PATH:
20264          t.closePath(), ++c;
20265          break;
20266        case tt.CUSTOM:
20267          d = /** @type {number} */
20268          R[1], f = R[2];
20269          const Li = (
20270            /** @type {import("../../geom/SimpleGeometry.js").default} */
20271            R[3]
20272          ), v = R[4], C = R.length == 6 ? R[5] : void 0;
20273          Y.geometry = Li, Y.feature = W, c in Z || (Z[c] = []);
20274          const b = Z[c];
20275          C ? C(h, d, f, 2, b) : (b[0] = h[d], b[1] = h[d + 1], b.length = 2), v(b, Y), ++c;
20276          break;
20277        case tt.DRAW_IMAGE:
20278          d = /** @type {number} */
20279          R[1], f = /** @type {number} */
20280          R[2], E = /** @type {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} */
20281          R[3], g = /** @type {number} */
20282          R[4], m = /** @type {number} */
20283          R[5];
20284          let T = (
20285            /** @type {number} */
20286            R[6]
20287          );
20288          const S = (
20289            /** @type {number} */
20290            R[7]
20291          ), k = (
20292            /** @type {number} */
20293            R[8]
20294          ), N = (
20295            /** @type {number} */
20296            R[9]
20297          ), F = (
20298            /** @type {boolean} */
20299            R[10]
20300          );
20301          let D = (
20302            /** @type {number} */
20303            R[11]
20304          );
20305          const P = (
20306            /** @type {import("../../size.js").Size} */
20307            R[12]
20308          );
20309          let B = (
20310            /** @type {number} */
20311            R[13]
20312          );
20313          const j = (
20314            /** @type {"declutter"|"obstacle"|"none"|undefined} */
20315            R[14]
20316          ), $ = (
20317            /** @type {import("../canvas.js").DeclutterImageWithText} */
20318            R[15]
20319          );
20320          if (!E && R.length >= 20) {
20321            M = /** @type {string} */
20322            R[19], w = /** @type {string} */
20323            R[20], L = /** @type {string} */
20324            R[21], I = /** @type {string} */
20325            R[22];
20326            const Ie = this.drawLabelWithPointPlacement_(
20327              M,
20328              w,
20329              L,
20330              I
20331            );
20332            E = Ie.label, R[3] = E;
20333            const Wn = (
20334              /** @type {number} */
20335              R[23]
20336            );
20337            g = (Ie.anchorX - Wn) * this.pixelRatio, R[4] = g;
20338            const Ae = (
20339              /** @type {number} */
20340              R[24]
20341            );
20342            m = (Ie.anchorY - Ae) * this.pixelRatio, R[5] = m, T = E.height, R[6] = T, B = E.width, R[13] = B;
20343          }
20344          let H;
20345          R.length > 25 && (H = /** @type {number} */
20346          R[25]);
20347          let ot, pt, ft;
20348          R.length > 17 ? (ot = /** @type {Array<number>} */
20349          R[16], pt = /** @type {boolean} */
20350          R[17], ft = /** @type {boolean} */
20351          R[18]) : (ot = xn, pt = !1, ft = !1), F && V ? D += Mt : !F && !V && (D -= Mt);
20352          let Rt = 0;
20353          for (; d < f; d += 2) {
20354            if (H && H[Rt++] < B / this.pixelRatio)
20355              continue;
20356            const Ie = this.calculateImageOrLabelDimensions_(
20357              E.width,
20358              E.height,
20359              h[d],
20360              h[d + 1],
20361              B,
20362              T,
20363              g,
20364              m,
20365              k,
20366              N,
20367              D,
20368              P,
20369              r,
20370              ot,
20371              pt || ft,
20372              W
20373            ), Wn = [
20374              t,
20375              i,
20376              E,
20377              Ie,
20378              S,
20379              pt ? (
20380                /** @type {Array<*>} */
20381                q
20382              ) : null,
20383              ft ? (
20384                /** @type {Array<*>} */
20385                K
20386              ) : null
20387            ];
20388            if (l) {
20389              if (j === "none")
20390                continue;
20391              if (j === "obstacle") {
20392                l.insert(Ie.declutterBox);
20393                continue;
20394              } else {
20395                let Ae, mi;
20396                if ($) {
20397                  const Re = f - d;
20398                  if (!$[Re]) {
20399                    $[Re] = Wn;
20400                    continue;
20401                  }
20402                  if (Ae = $[Re], delete $[Re], mi = rd(Ae), l.collides(mi))
20403                    continue;
20404                }
20405                if (l.collides(Ie.declutterBox))
20406                  continue;
20407                Ae && (l.insert(mi), this.replayImageOrLabel_.apply(this, Ae)), l.insert(Ie.declutterBox);
20408              }
20409            }
20410            this.replayImageOrLabel_.apply(this, Wn);
20411          }
20412          ++c;
20413          break;
20414        case tt.DRAW_CHARS:
20415          const te = (
20416            /** @type {number} */
20417            R[1]
20418          ), Nt = (
20419            /** @type {number} */
20420            R[2]
20421          ), zn = (
20422            /** @type {number} */
20423            R[3]
20424          ), cn = (
20425            /** @type {number} */
20426            R[4]
20427          );
20428          I = /** @type {string} */
20429          R[5];
20430          const $r = (
20431            /** @type {number} */
20432            R[6]
20433          ), ee = (
20434            /** @type {number} */
20435            R[7]
20436          ), Te = (
20437            /** @type {number} */
20438            R[8]
20439          );
20440          L = /** @type {string} */
20441          R[9];
20442          const jn = (
20443            /** @type {number} */
20444            R[10]
20445          );
20446          M = /** @type {string} */
20447          R[11], w = /** @type {string} */
20448          R[12];
20449          const Mc = [
20450            /** @type {number} */
20451            R[13],
20452            /** @type {number} */
20453            R[13]
20454          ], La = this.textStates[w], Ws = La.font, Bs = [
20455            La.scale[0] * ee,
20456            La.scale[1] * ee
20457          ];
20458          let Us;
20459          Ws in this.widths_ ? Us = this.widths_[Ws] : (Us = {}, this.widths_[Ws] = Us);
20460          const bc = jg(h, te, Nt, 2), wc = Math.abs(Bs[0]) * Ku(Ws, M, Us);
20461          if (cn || wc <= bc) {
20462            const Ie = this.textStates[w].textAlign, Wn = (bc - wc) * lr[Ie], Ae = Db(
20463              h,
20464              te,
20465              Nt,
20466              2,
20467              M,
20468              Wn,
20469              $r,
20470              Math.abs(Bs[0]),
20471              Ku,
20472              Ws,
20473              Us,
20474              V ? 0 : this.viewRotation_
20475            );
20476            t:
20477              if (Ae) {
20478                const mi = [];
20479                let Re, Yr, Kr, ye, Oe;
20480                if (L)
20481                  for (Re = 0, Yr = Ae.length; Re < Yr; ++Re) {
20482                    Oe = Ae[Re], Kr = /** @type {string} */
20483                    Oe[4], ye = this.createLabel(Kr, w, "", L), g = /** @type {number} */
20484                    Oe[2] + (Bs[0] < 0 ? -jn : jn), m = zn * ye.height + (0.5 - zn) * 2 * jn * Bs[1] / Bs[0] - Te;
20485                    const _i = this.calculateImageOrLabelDimensions_(
20486                      ye.width,
20487                      ye.height,
20488                      Oe[0],
20489                      Oe[1],
20490                      ye.width,
20491                      ye.height,
20492                      g,
20493                      m,
20494                      0,
20495                      0,
20496                      Oe[3],
20497                      Mc,
20498                      !1,
20499                      xn,
20500                      !1,
20501                      W
20502                    );
20503                    if (l && l.collides(_i.declutterBox))
20504                      break t;
20505                    mi.push([
20506                      t,
20507                      i,
20508                      ye,
20509                      _i,
20510                      1,
20511                      null,
20512                      null
20513                    ]);
20514                  }
20515                if (I)
20516                  for (Re = 0, Yr = Ae.length; Re < Yr; ++Re) {
20517                    Oe = Ae[Re], Kr = /** @type {string} */
20518                    Oe[4], ye = this.createLabel(Kr, w, I, ""), g = /** @type {number} */
20519                    Oe[2], m = zn * ye.height - Te;
20520                    const _i = this.calculateImageOrLabelDimensions_(
20521                      ye.width,
20522                      ye.height,
20523                      Oe[0],
20524                      Oe[1],
20525                      ye.width,
20526                      ye.height,
20527                      g,
20528                      m,
20529                      0,
20530                      0,
20531                      Oe[3],
20532                      Mc,
20533                      !1,
20534                      xn,
20535                      !1,
20536                      W
20537                    );
20538                    if (l && l.collides(_i.declutterBox))
20539                      break t;
20540                    mi.push([
20541                      t,
20542                      i,
20543                      ye,
20544                      _i,
20545                      1,
20546                      null,
20547                      null
20548                    ]);
20549                  }
20550                l && l.load(mi.map(rd));
20551                for (let _i = 0, Am = mi.length; _i < Am; ++_i)
20552                  this.replayImageOrLabel_.apply(this, mi[_i]);
20553              }
20554          }
20555          ++c;
20556          break;
20557        case tt.END_GEOMETRY:
20558          if (o !== void 0) {
20559            W = /** @type {import("../../Feature.js").FeatureLike} */
20560            R[1];
20561            const Ie = o(W, Pt);
20562            if (Ie)
20563              return Ie;
20564          }
20565          ++c;
20566          break;
20567        case tt.FILL:
20568          O ? z++ : this.fill_(t), ++c;
20569          break;
20570        case tt.MOVE_TO_LINE_TO:
20571          for (d = /** @type {number} */
20572          R[1], f = /** @type {number} */
20573          R[2], gt = h[d], _t = h[d + 1], y = gt + 0.5 | 0, x = _t + 0.5 | 0, (y !== _ || x !== p) && (t.moveTo(gt, _t), _ = y, p = x), d += 2; d < f; d += 2)
20574            gt = h[d], _t = h[d + 1], y = gt + 0.5 | 0, x = _t + 0.5 | 0, (d == f - 2 || y !== _ || x !== p) && (t.lineTo(gt, _t), _ = y, p = x);
20575          ++c;
20576          break;
20577        case tt.SET_FILL_STYLE:
20578          q = R, this.alignFill_ = R[2], z && (this.fill_(t), z = 0, U && (t.stroke(), U = 0)), t.fillStyle = /** @type {import("../../colorlike.js").ColorLike} */
20579          R[1], ++c;
20580          break;
20581        case tt.SET_STROKE_STYLE:
20582          K = R, U && (t.stroke(), U = 0), this.setStrokeStyle_(
20583            t,
20584            /** @type {Array<*>} */
20585            R
20586          ), ++c;
20587          break;
20588        case tt.STROKE:
20589          O ? U++ : t.stroke(), ++c;
20590          break;
20591        default:
20592          ++c;
20593          break;
20594      }
20595    }
20596    z && this.fill_(t), U && t.stroke();
20597  }
20598  /**
20599   * @param {CanvasRenderingContext2D} context Context.
20600   * @param {number} contextScale Scale of the context.
20601   * @param {import("../../transform.js").Transform} transform Transform.
20602   * @param {number} viewRotation View rotation.
20603   * @param {boolean} snapToPixel Snap point symbols and text to integer pixels.
20604   * @param {import("rbush").default} [declutterTree] Declutter tree.
20605   */
20606  execute(t, i, n, s, r, o) {
20607    this.viewRotation_ = s, this.execute_(
20608      t,
20609      i,
20610      n,
20611      this.instructions,
20612      r,
20613      void 0,
20614      void 0,
20615      o
20616    );
20617  }
20618  /**
20619   * @param {CanvasRenderingContext2D} context Context.
20620   * @param {import("../../transform.js").Transform} transform Transform.
20621   * @param {number} viewRotation View rotation.
20622   * @param {FeatureCallback<T>} [featureCallback] Feature callback.
20623   * @param {import("../../extent.js").Extent} [hitExtent] Only check
20624   *     features that intersect this extent.
20625   * @return {T|undefined} Callback result.
20626   * @template T
20627   */
20628  executeHitDetection(t, i, n, s, r) {
20629    return this.viewRotation_ = n, this.execute_(
20630      t,
20631      1,
20632      i,
20633      this.hitDetectionInstructions,
20634      !0,
20635      s,
20636      r
20637    );
20638  }
20639}
20640const jb = zb, Ja = ["Polygon", "Circle", "LineString", "Image", "Text", "Default"];
20641class Wb {
20642  /**
20643   * @param {import("../../extent.js").Extent} maxExtent Max extent for clipping. When a
20644   * `maxExtent` was set on the Builder for this executor group, the same `maxExtent`
20645   * should be set here, unless the target context does not exceed that extent (which
20646   * can be the case when rendering to tiles).
20647   * @param {number} resolution Resolution.
20648   * @param {number} pixelRatio Pixel ratio.
20649   * @param {boolean} overlaps The executor group can have overlapping geometries.
20650   * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>} allInstructions
20651   * The serializable instructions.
20652   * @param {number} [renderBuffer] Optional rendering buffer.
20653   */
20654  constructor(t, i, n, s, r, o) {
20655    this.maxExtent_ = t, this.overlaps_ = s, this.pixelRatio_ = n, this.resolution_ = i, this.renderBuffer_ = o, this.executorsByZIndex_ = {}, this.hitDetectionContext_ = null, this.hitDetectionTransform_ = ui(), this.createExecutors_(r);
20656  }
20657  /**
20658   * @param {CanvasRenderingContext2D} context Context.
20659   * @param {import("../../transform.js").Transform} transform Transform.
20660   */
20661  clip(t, i) {
20662    const n = this.getClipCoords(i);
20663    t.beginPath(), t.moveTo(n[0], n[1]), t.lineTo(n[2], n[3]), t.lineTo(n[4], n[5]), t.lineTo(n[6], n[7]), t.clip();
20664  }
20665  /**
20666   * Create executors and populate them using the provided instructions.
20667   * @private
20668   * @param {!Object<string, !Object<import("../canvas.js").BuilderType, import("../canvas.js").SerializableInstructions>>}
20668 allInstructions The serializable instructions
20669   */
20670  createExecutors_(t) {
20671    for (const i in t) {
20672      let n = this.executorsByZIndex_[i];
20673      n === void 0 && (n = {}, this.executorsByZIndex_[i] = n);
20674      const s = t[i];
20675      for (const r in s) {
20676        const o = s[r];
20677        n[r] = new jb(
20678          this.resolution_,
20679          this.pixelRatio_,
20680          this.overlaps_,
20681          o
20682        );
20683      }
20684    }
20685  }
20686  /**
20687   * @param {Array<import("../canvas.js").BuilderType>} executors Executors.
20688   * @return {boolean} Has executors of the provided types.
20689   */
20690  hasExecutors(t) {
20691    for (const i in this.executorsByZIndex_) {
20692      const n = this.executorsByZIndex_[i];
20693      for (let s = 0, r = t.length; s < r; ++s)
20694        if (t[s] in n)
20695          return !0;
20696    }
20697    return !1;
20698  }
20699  /**
20700   * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
20701   * @param {number} resolution Resolution.
20702   * @param {number} rotation Rotation.
20703   * @param {number} hitTolerance Hit tolerance in pixels.
20704   * @param {function(import("../../Feature.js").FeatureLike, import("../../geom/SimpleGeometry.js").default, number): T} callback Feature callback.
20705   * @param {Array<import("../../Feature.js").FeatureLike>} declutteredFeatures Decluttered features.
20706   * @return {T|undefined} Callback result.
20707   * @template T
20708   */
20709  forEachFeatureAtCoordinate(t, i, n, s, r, o) {
20710    s = Math.round(s);
20711    const a = s * 2 + 1, l = gi(
20712      this.hitDetectionTransform_,
20713      s + 0.5,
20714      s + 0.5,
20715      1 / i,
20716      -1 / i,
20717      -n,
20718      -t[0],
20719      -t[1]
20720    ), h = !this.hitDetectionContext_;
20721    h && (this.hitDetectionContext_ = he(
20722      a,
20723      a,
20724      void 0,
20725      { willReadFrequently: !0 }
20726    ));
20727    const c = this.hitDetectionContext_;
20728    c.canvas.width !== a || c.canvas.height !== a ? (c.canvas.width = a, c.canvas.height = a) : h || c.clearRect(0, 0, a, a);
20729    let u;
20730    this.renderBuffer_ !== void 0 && (u = be(), sr(u, t), Rn(
20731      u,
20732      i * (this.renderBuffer_ + s),
20733      u
20734    ));
20735    const d = Bb(s);
20736    let f;
20737    function g(M, w) {
20738      const L = c.getImageData(
20739        0,
20740        0,
20741        a,
20742        a
20743      ).data;
20744      for (let I = 0, z = d.length; I < z; I++)
20745        if (L[d[I]] > 0) {
20746          if (!o || f !== "Image" && f !== "Text" || o.includes(M)) {
20747            const U = (d[I] - 3) / 4, q = s - U % a, K = s - (U / a | 0), Z = r(M, w, q * q + K * K);
20748            if (Z)
20749              return Z;
20750          }
20751          c.clearRect(0, 0, a, a);
20752          break;
20753        }
20754    }
20755    const m = Object.keys(this.executorsByZIndex_).map(Number);
20756    m.sort(Ln);
20757    let _, p, y, x, E;
20758    for (_ = m.length - 1; _ >= 0; --_) {
20759      const M = m[_].toString();
20760      for (y = this.executorsByZIndex_[M], p = Ja.length - 1; p >= 0; --p)
20761        if (f = Ja[p], x = y[f], x !== void 0 && (E = x.executeHitDetection(
20762          c,
20763          l,
20764          n,
20765          g,
20766          u
20767        ), E))
20768          return E;
20769    }
20770  }
20771  /**
20772   * @param {import("../../transform.js").Transform} transform Transform.
20773   * @return {Array<number>|null} Clip coordinates.
20774   */
20775  getClipCoords(t) {
20776    const i = this.maxExtent_;
20777    if (!i)
20778      return null;
20779    const n = i[0], s = i[1], r = i[2], o = i[3], a = [n, s, n, o, r, o, r, s];
20780    return wn(a, 0, 8, 2, t, a), a;
20781  }
20782  /**
20783   * @return {boolean} Is empty.
20784   */
20785  isEmpty() {
20786    return bs(this.executorsByZIndex_);
20787  }
20788  /**
20789   * @param {CanvasRenderingContext2D} context Context.
20790   * @param {number} contextScale Scale of the context.
20791   * @param {import("../../transform.js").Transform} transform Transform.
20792   * @param {number} viewRotation View rotation.
20793   * @param {boolean} snapToPixel Snap point symbols and test to integer pixel.
20794   * @param {Array<import("../canvas.js").BuilderType>} [builderTypes] Ordered replay types to replay.
20795   *     Default is {@link module:ol/render/replay~ORDER}
20796   * @param {import("rbush").default} [declutterTree] Declutter tree.
20797   */
20798  execute(t, i, n, s, r, o, a) {
20799    const l = Object.keys(this.executorsByZIndex_).map(Number);
20800    l.sort(Ln), this.maxExtent_ && (t.save(), this.clip(t, n)), o = o || Ja;
20801    let h, c, u, d, f, g;
20802    for (a && l.reverse(), h = 0, c = l.length; h < c; ++h) {
20803      const m = l[h].toString();
20804      for (f = this.executorsByZIndex_[m], u = 0, d = o.length; u < d; ++u) {
20805        const _ = o[u];
20806        g = f[_], g !== void 0 && g.execute(
20807          t,
20808          i,
20809          n,
20810          s,
20811          r,
20812          a
20813        );
20814      }
20815    }
20816    this.maxExtent_ && t.restore();
20817  }
20818}
20819const Qa = {};
20820function Bb(e) {
20821  if (Qa[e] !== void 0)
20822    return Qa[e];
20823  const t = e * 2 + 1, i = e * e, n = new Array(i + 1);
20824  for (let r = 0; r <= e; ++r)
20825    for (let o = 0; o <= e; ++o) {
20826      const a = r * r + o * o;
20827      if (a > i)
20828        break;
20829      let l = n[a];
20830      l || (l = [], n[a] = l), l.push(((e + r) * t + (e + o)) * 4 + 3), r > 0 && l.push(((e - r) * t + (e + o)) * 4 + 3), o > 0 && (l.push(((e + r) * t + (e - o)) * 4 + 3), r > 0 && l.push(((e - r) * t + (e - o)) * 4 + 3));
20831    }
20832  const s = [];
20833  for (let r = 0, o = n.length; r < o; ++r)
20834    n[r] && s.push(...n[r]);
20835  return Qa[e] = s, s;
20836}
20837const ad = Wb;
20838class Ub extends Vg {
20839  /**
20840   * @param {CanvasRenderingContext2D} context Context.
20841   * @param {number} pixelRatio Pixel ratio.
20842   * @param {import("../../extent.js").Extent} extent Extent.
20843   * @param {import("../../transform.js").Transform} transform Transform.
20844   * @param {number} viewRotation View rotation.
20845   * @param {number} [squaredTolerance] Optional squared tolerance for simplification.
20846   * @param {import("../../proj.js").TransformFunction} [userTransform] Transform from user to view projection.
20847   */
20848  constructor(t, i, n, s, r, o, a) {
20849    super(), this.context_ = t, this.pixelRatio_ = i, this.extent_ = n, this.transform_ = s, this.transformRotation_ = s ? Nr(Math.atan2(s[1], s[0]), 10) : 0, this.viewRotation_ = r, this.squaredTolerance_ = o, this.userTransform_ = a, this.contextFillState_ = null, this.contextStrokeState_ = null, this.contextTextState_ = null, this.fillState_ = null, this.strokeState_ = null, this.image_ = null, this.imageAnchorX_ = 0, this.imageAnchorY_ = 0, this.imageHeight_ = 0, this.imageOpacity_ = 0, this.imageOriginX_ = 0, this.imageOriginY_ = 0, this.imageRotateWithView_ = !1, this.imageRotation_ = 0, this.imageScale_ = [0, 0], this.imageWidth_ = 0, this.text_ = "", this.textOffsetX_ = 0, this.textOffsetY_ = 0, this.textRotateWithView_ = !1, this.textRotation_ = 0, this.textScale_ = [0, 0], this.textFillState_ = null, this.textStrokeState_ = null, this.textState_ = null, this.pixelCoordinates_ = [], this.tmpLocalTransform_ = ui();
20850  }
20851  /**
20852   * @param {Array<number>} flatCoordinates Flat coordinates.
20853   * @param {number} offset Offset.
20854   * @param {number} end End.
20855   * @param {number} stride Stride.
20856   * @private
20857   */
20858  drawImages_(t, i, n, s) {
20859    if (!this.image_)
20860      return;
20861    const r = wn(
20862      t,
20863      i,
20864      n,
20865      s,
20866      this.transform_,
20867      this.pixelCoordinates_
20868    ), o = this.context_, a = this.tmpLocalTransform_, l = o.globalAlpha;
20869    this.imageOpacity_ != 1 && (o.globalAlpha = l * this.imageOpacity_);
20870    let h = this.imageRotation_;
20871    this.transformRotation_ === 0 && (h -= this.viewRotation_), this.imageRotateWithView_ && (h += this.viewRotation_);
20872    for (let c = 0, u = r.length; c < u; c += 2) {
20873      const d = r[c] - this.imageAnchorX_, f = r[c + 1] - this.imageAnchorY_;
20874      if (h !== 0 || this.imageScale_[0] != 1 || this.imageScale_[1] != 1) {
20875        const g = d + this.imageAnchorX_, m = f + this.imageAnchorY_;
20876        gi(
20877          a,
20878          g,
20879          m,
20880          1,
20881          1,
20882          h,
20883          -g,
20884          -m
20885        ), o.setTransform.apply(o, a), o.translate(g, m), o.scale(this.imageScale_[0], this.imageScale_[1]), o.drawImage(
20886          this.image_,
20887          this.imageOriginX_,
20888          this.imageOriginY_,
20889          this.imageWidth_,
20890          this.imageHeight_,
20891          -this.imageAnchorX_,
20892          -this.imageAnchorY_,
20893          this.imageWidth_,
20894          this.imageHeight_
20895        ), o.setTransform(1, 0, 0, 1, 0, 0);
20896      } else
20897        o.drawImage(
20898          this.image_,
20899          this.imageOriginX_,
20900          this.imageOriginY_,
20901          this.imageWidth_,
20902          this.imageHeight_,
20903          d,
20904          f,
20905          this.imageWidth_,
20906          this.imageHeight_
20907        );
20908    }
20909    this.imageOpacity_ != 1 && (o.globalAlpha = l);
20910  }
20911  /**
20912   * @param {Array<number>} flatCoordinates Flat coordinates.
20913   * @param {number} offset Offset.
20914   * @param {number} end End.
20915   * @param {number} stride Stride.
20916   * @private
20917   */
20918  drawText_(t, i, n, s) {
20919    if (!this.textState_ || this.text_ === "")
20920      return;
20921    this.textFillState_ && this.setContextFillState_(this.textFillState_), this.textStrokeState_ && this.setContextStrokeState_(this.textStrokeState_), this.setContextTextState_(this.textState_);
20922    const r = wn(
20923      t,
20924      i,
20925      n,
20926      s,
20927      this.transform_,
20928      this.pixelCoordinates_
20929    ), o = this.context_;
20930    let a = this.textRotation_;
20931    for (this.transformRotation_ === 0 && (a -= this.viewRotation_), this.textRotateWithView_ && (a += this.viewRotation_); i < n; i += s) {
20932      const l = r[i] + this.textOffsetX_, h = r[i + 1] + this.textOffsetY_;
20933      a !== 0 || this.textScale_[0] != 1 || this.textScale_[1] != 1 ? (o.translate(l - this.textOffsetX_, h - this.textOffsetY_), o.rotate(a), o.translate(this.textOffsetX_, this.textOffsetY_), o.scale(this.textScale_[0], this.textScale_[1]), this.textStrokeState_ && o.strokeText(this.text_, 0, 0
20933), this.textFillState_ && o.fillText(this.text_, 0, 0), o.setTransform(1, 0, 0, 1, 0, 0)) : (this.textStrokeState_ && o.strokeText(this.text_, l, h), this.textFillState_ && o.fillText(this.text_, l, h));
20934    }
20935  }
20936  /**
20937   * @param {Array<number>} flatCoordinates Flat coordinates.
20938   * @param {number} offset Offset.
20939   * @param {number} end End.
20940   * @param {number} stride Stride.
20941   * @param {boolean} close Close.
20942   * @private
20943   * @return {number} end End.
20944   */
20945  moveToLineTo_(t, i, n, s, r) {
20946    const o = this.context_, a = wn(
20947      t,
20948      i,
20949      n,
20950      s,
20951      this.transform_,
20952      this.pixelCoordinates_
20953    );
20954    o.moveTo(a[0], a[1]);
20955    let l = a.length;
20956    r && (l -= 2);
20957    for (let h = 2; h < l; h += 2)
20958      o.lineTo(a[h], a[h + 1]);
20959    return r && o.closePath(), n;
20960  }
20961  /**
20962   * @param {Array<number>} flatCoordinates Flat coordinates.
20963   * @param {number} offset Offset.
20964   * @param {Array<number>} ends Ends.
20965   * @param {number} stride Stride.
20966   * @private
20967   * @return {number} End.
20968   */
20969  drawRings_(t, i, n, s) {
20970    for (let r = 0, o = n.length; r < o; ++r)
20971      i = this.moveToLineTo_(
20972        t,
20973        i,
20974        n[r],
20975        s,
20976        !0
20977      );
20978    return i;
20979  }
20980  /**
20981   * Render a circle geometry into the canvas.  Rendering is immediate and uses
20982   * the current fill and stroke styles.
20983   *
20984   * @param {import("../../geom/Circle.js").default} geometry Circle geometry.
20985   * @api
20986   */
20987  drawCircle(t) {
20988    if (this.squaredTolerance_ && (t = /** @type {import("../../geom/Circle.js").default} */
20989    t.simplifyTransformed(
20990      this.squaredTolerance_,
20991      this.userTransform_
20992    )), !!re(this.extent_, t.getExtent())) {
20993      if (this.fillState_ || this.strokeState_) {
20994        this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_);
20995        const i = dC(
20996          t,
20997          this.transform_,
20998          this.pixelCoordinates_
20999        ), n = i[2] - i[0], s = i[3] - i[1], r = Math.sqrt(n * n + s * s), o = this.context_;
21000        o.beginPath(), o.arc(
21001          i[0],
21002          i[1],
21003          r,
21004          0,
21005          2 * Math.PI
21006        ), this.fillState_ && o.fill(), this.strokeState_ && o.stroke();
21007      }
21008      this.text_ !== "" && this.drawText_(t.getCenter(), 0, 2, 2);
21009    }
21010  }
21011  /**
21012   * Set the rendering style.  Note that since this is an immediate rendering API,
21013   * any `zIndex` on the provided style will be ignored.
21014   *
21015   * @param {import("../../style/Style.js").default} style The rendering style.
21016   * @api
21017   */
21018  setStyle(t) {
21019    this.setFillStrokeStyle(t.getFill(), t.getStroke()), this.setImageStyle(t.getImage()), this.setTextStyle(t.getText());
21020  }
21021  /**
21022   * @param {import("../../transform.js").Transform} transform Transform.
21023   */
21024  setTransform(t) {
21025    this.transform_ = t;
21026  }
21027  /**
21028   * Render a geometry into the canvas.  Call
21029   * {@link module:ol/render/canvas/Immediate~CanvasImmediateRenderer#setStyle renderer.setStyle()} first to set the rendering style.
21030   *
21031   * @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry The geometry to render.
21032   * @api
21033   */
21034  drawGeometry(t) {
21035    switch (t.getType()) {
21036      case "Point":
21037        this.drawPoint(
21038          /** @type {import("../../geom/Point.js").default} */
21039          t
21040        );
21041        break;
21042      case "LineString":
21043        this.drawLineString(
21044          /** @type {import("../../geom/LineString.js").default} */
21045          t
21046        );
21047        break;
21048      case "Polygon":
21049        this.drawPolygon(
21050          /** @type {import("../../geom/Polygon.js").default} */
21051          t
21052        );
21053        break;
21054      case "MultiPoint":
21055        this.drawMultiPoint(
21056          /** @type {import("../../geom/MultiPoint.js").default} */
21057          t
21058        );
21059        break;
21060      case "MultiLineString":
21061        this.drawMultiLineString(
21062          /** @type {import("../../geom/MultiLineString.js").default} */
21063          t
21064        );
21065        break;
21066      case "MultiPolygon":
21067        this.drawMultiPolygon(
21068          /** @type {import("../../geom/MultiPolygon.js").default} */
21069          t
21070        );
21071        break;
21072      case "GeometryCollection":
21073        this.drawGeometryCollection(
21074          /** @type {import("../../geom/GeometryCollection.js").default} */
21075          t
21076        );
21077        break;
21078      case "Circle":
21079        this.drawCircle(
21080          /** @type {import("../../geom/Circle.js").default} */
21081          t
21082        );
21083        break;
21084    }
21085  }
21086  /**
21087   * Render a feature into the canvas.  Note that any `zIndex` on the provided
21088   * style will be ignored - features are rendered immediately in the order that
21089   * this method is called.  If you need `zIndex` support, you should be using an
21090   * {@link module:ol/layer/Vector~VectorLayer} instead.
21091   *
21092   * @param {import("../../Feature.js").default} feature Feature.
21093   * @param {import("../../style/Style.js").default} style Style.
21094   * @api
21095   */
21096  drawFeature(t, i) {
21097    const n = i.getGeometryFunction()(t);
21098    n && (this.setStyle(i), this.drawGeometry(n));
21099  }
21100  /**
21101   * Render a GeometryCollection to the canvas.  Rendering is immediate and
21102   * uses the current styles appropriate for each geometry in the collection.
21103   *
21104   * @param {import("../../geom/GeometryCollection.js").default} geometry Geometry collection.
21105   */
21106  drawGeometryCollection(t) {
21107    const i = t.getGeometriesArray();
21108    for (let n = 0, s = i.length; n < s; ++n)
21109      this.drawGeometry(i[n]);
21110  }
21111  /**
21112   * Render a Point geometry into the canvas.  Rendering is immediate and uses
21113   * the current style.
21114   *
21115   * @param {import("../../geom/Point.js").default|import("../Feature.js").default} geometry Point geometry.
21116   */
21117  drawPoint(t) {
21118    this.squaredTolerance_ && (t = /** @type {import("../../geom/Point.js").default} */
21119    t.simplifyTransformed(
21120      this.squaredTolerance_,
21121      this.userTransform_
21122    ));
21123    const i = t.getFlatCoordinates(), n = t.getStride();
21124    this.image_ && this.drawImages_(i, 0, i.length, n), this.text_ !== "" && this.drawText_(i, 0, i.length, n);
21125  }
21126  /**
21127   * Render a MultiPoint geometry  into the canvas.  Rendering is immediate and
21128   * uses the current style.
21129   *
21130   * @param {import("../../geom/MultiPoint.js").default|import("../Feature.js").default} geometry MultiPoint geometry.
21131   */
21132  drawMultiPoint(t) {
21133    this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiPoint.js").default} */
21134    t.simplifyTransformed(
21135      this.squaredTolerance_,
21136      this.userTransform_
21137    ));
21138    const i = t.getFlatCoordinates(), n = t.getStride();
21139    this.image_ && this.drawImages_(i, 0, i.length, n), this.text_ !== "" && this.drawText_(i, 0, i.length, n);
21140  }
21141  /**
21142   * Render a LineString into the canvas.  Rendering is immediate and uses
21143   * the current style.
21144   *
21145   * @param {import("../../geom/LineString.js").default|import("../Feature.js").default} geometry LineString geometry.
21146   */
21147  drawLineString(t) {
21148    if (this.squaredTolerance_ && (t = /** @type {import("../../geom/LineString.js").default} */
21149    t.simplifyTransformed(
21150      this.squaredTolerance_,
21151      this.userTransform_
21152    )), !!re(this.extent_, t.getExtent())) {
21153      if (this.strokeState_) {
21154        this.setContextStrokeState_(this.strokeState_);
21155        const i = this.context_, n = t.getFlatCoordinates();
21156        i.beginPath(), this.moveToLineTo_(
21157          n,
21158          0,
21159          n.length,
21160          t.getStride(),
21161          !1
21162        ), i.stroke();
21163      }
21164      if (this.text_ !== "") {
21165        const i = t.getFlatMidpoint();
21166        this.drawText_(i, 0, 2, 2);
21167      }
21168    }
21169  }
21170  /**
21171   * Render a MultiLineString geometry into the canvas.  Rendering is immediate
21172   * and uses the current style.
21173   *
21174   * @param {import("../../geom/MultiLineString.js").default|import("../Feature.js").default} geometry MultiLineString geometry.
21175   */
21176  drawMultiLineString(t) {
21177    this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiLineString.js").default} */
21178    t.simplifyTransformed(
21179      this.squaredTolerance_,
21180      this.userTransform_
21181    ));
21182    const i = t.getExtent();
21183    if (re(this.extent_, i)) {
21184      if (this.strokeState_) {
21185        this.setContextStrokeState_(this.strokeState_);
21186        const n = this.context_, s = t.getFlatCoordinates();
21187        let r = 0;
21188        const o = (
21189          /** @type {Array<number>} */
21190          t.getEnds()
21191        ), a = t.getStride();
21192        n.beginPath();
21193        for (let l = 0, h = o.length; l < h; ++l)
21194          r = this.moveToLineTo_(
21195            s,
21196            r,
21197            o[l],
21198            a,
21199            !1
21200          );
21201        n.stroke();
21202      }
21203      if (this.text_ !== "") {
21204        const n = t.getFlatMidpoints();
21205        this.drawText_(n, 0, n.length, 2);
21206      }
21207    }
21208  }
21209  /**
21210   * Render a Polygon geometry into the canvas.  Rendering is immediate and uses
21211   * the current style.
21212   *
21213   * @param {import("../../geom/Polygon.js").default|import("../Feature.js").default} geometry Polygon geometry.
21214   */
21215  drawPolygon(t) {
21216    if (this.squaredTolerance_ && (t = /** @type {import("../../geom/Polygon.js").default} */
21217    t.simplifyTransformed(
21218      this.squaredTolerance_,
21219      this.userTransform_
21220    )), !!re(this.extent_, t.getExtent())) {
21221      if (this.strokeState_ || this.fillState_) {
21222        this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_);
21223        const i = this.context_;
21224        i.beginPath(), this.drawRings_(
21225          t.getOrientedFlatCoordinates(),
21226          0,
21227          /** @type {Array<number>} */
21228          t.getEnds(),
21229          t.getStride()
21230        ), this.fillState_ && i.fill(), this.strokeState_ && i.stroke();
21231      }
21232      if (this.text_ !== "") {
21233        const i = t.getFlatInteriorPoint();
21234        this.drawText_(i, 0, 2, 2);
21235      }
21236    }
21237  }
21238  /**
21239   * Render MultiPolygon geometry into the canvas.  Rendering is immediate and
21240   * uses the current style.
21241   * @param {import("../../geom/MultiPolygon.js").default} geometry MultiPolygon geometry.
21242   */
21243  drawMultiPolygon(t) {
21244    if (this.squaredTolerance_ && (t = /** @type {import("../../geom/MultiPolygon.js").default} */
21245    t.simplifyTransformed(
21246      this.squaredTolerance_,
21247      this.userTransform_
21248    )), !!re(this.extent_, t.getExtent())) {
21249      if (this.strokeState_ || this.fillState_) {
21250        this.fillState_ && this.setContextFillState_(this.fillState_), this.strokeState_ && this.setContextStrokeState_(this.strokeState_);
21251        const i = this.context_, n = t.getOrientedFlatCoordinates();
21252        let s = 0;
21253        const r = t.getEndss(), o = t.getStride();
21254        i.beginPath();
21255        for (let a = 0, l = r.length; a < l; ++a) {
21256          const h = r[a];
21257          s = this.drawRings_(n, s, h, o);
21258        }
21259        this.fillState_ && i.fill(), this.strokeState_ && i.stroke();
21260      }
21261      if (this.text_ !== "") {
21262        const i = t.getFlatInteriorPoints();
21263        this.drawText_(i, 0, i.length, 2);
21264      }
21265    }
21266  }
21267  /**
21268   * @param {import("../canvas.js").FillState} fillState Fill state.
21269   * @private
21270   */
21271  setContextFillState_(t) {
21272    const i = this.context_, n = this.contextFillState_;
21273    n ? n.fillStyle != t.fillStyle && (n.fillStyle = t.fillStyle, i.fillStyle = t.fillStyle) : (i.fillStyle = t.fillStyle, this.contextFillState_ = {
21274      fillStyle: t.fillStyle
21275    });
21276  }
21277  /**
21278   * @param {import("../canvas.js").StrokeState} strokeState Stroke state.
21279   * @private
21280   */
21281  setContextStrokeState_(t) {
21282    const i = this.context_, n = this.contextStrokeState_;
21283    n ? (n.lineCap != t.lineCap && (n.lineCap = t.lineCap, i.lineCap = t.lineCap), Pi(n.lineDash, t.lineDash) || i.setLineDash(
21284      n.lineDash = t.lineDash
21285    ), n.lineDashOffset != t.lineDashOffset && (n.lineDashOffset = t.lineDashOffset, i.lineDashOffset = t.lineDashOffset), n.lineJoin != t.lineJoin && (n.lineJoin = t.lineJoin, i.lineJoin = t.lineJoin), n.lineWidth != t.lineWidth && (n.lineWidth = t.lineWidth, i.lineWidth = t.lineWidth), n.miterLimit != t.miter
21285Limit && (n.miterLimit = t.miterLimit, i.miterLimit = t.miterLimit), n.strokeStyle != t.strokeStyle && (n.strokeStyle = t.strokeStyle, i.strokeStyle = t.strokeStyle)) : (i.lineCap = t.lineCap, i.setLineDash(t.lineDash), i.lineDashOffset = t.lineDashOffset, i.lineJoin = t.lineJoin, i.lineWidth = t.lineWidth, i.miterLimit = t.miterLimit, i.strokeStyle = t.strokeStyle, this.contextStrokeState_ = {
21286      lineCap: t.lineCap,
21287      lineDash: t.lineDash,
21288      lineDashOffset: t.lineDashOffset,
21289      lineJoin: t.lineJoin,
21290      lineWidth: t.lineWidth,
21291      miterLimit: t.miterLimit,
21292      strokeStyle: t.strokeStyle
21293    });
21294  }
21295  /**
21296   * @param {import("../canvas.js").TextState} textState Text state.
21297   * @private
21298   */
21299  setContextTextState_(t) {
21300    const i = this.context_, n = this.contextTextState_, s = t.textAlign ? t.textAlign : wr;
21301    n ? (n.font != t.font && (n.font = t.font, i.font = t.font), n.textAlign != s && (n.textAlign = s, i.textAlign = s), n.textBaseline != t.textBaseline && (n.textBaseline = t.textBaseline, i.textBaseline = t.textBaseline)) : (i.font = t.font, i.textAlign = s, i.textBaseline = t.textBaseline, this.contextTextState_ = {
21302      font: t.font,
21303      textAlign: s,
21304      textBaseline: t.textBaseline
21305    });
21306  }
21307  /**
21308   * Set the fill and stroke style for subsequent draw operations.  To clear
21309   * either fill or stroke styles, pass null for the appropriate parameter.
21310   *
21311   * @param {import("../../style/Fill.js").default} fillStyle Fill style.
21312   * @param {import("../../style/Stroke.js").default} strokeStyle Stroke style.
21313   */
21314  setFillStrokeStyle(t, i) {
21315    if (!t)
21316      this.fillState_ = null;
21317    else {
21318      const n = t.getColor();
21319      this.fillState_ = {
21320        fillStyle: li(
21321          n || Si
21322        )
21323      };
21324    }
21325    if (!i)
21326      this.strokeState_ = null;
21327    else {
21328      const n = i.getColor(), s = i.getLineCap(), r = i.getLineDash(), o = i.getLineDashOffset(), a = i.getLineJoin(), l = i.getWidth(), h = i.getMiterLimit(), c = r || Er;
21329      this.strokeState_ = {
21330        lineCap: s !== void 0 ? s : $o,
21331        lineDash: this.pixelRatio_ === 1 ? c : c.map((u) => u * this.pixelRatio_),
21332        lineDashOffset: (o || Cr) * this.pixelRatio_,
21333        lineJoin: a !== void 0 ? a : Os,
21334        lineWidth: (l !== void 0 ? l : Sr) * this.pixelRatio_,
21335        miterLimit: h !== void 0 ? h : Mr,
21336        strokeStyle: li(
21337          n || br
21338        )
21339      };
21340    }
21341  }
21342  /**
21343   * Set the image style for subsequent draw operations.  Pass null to remove
21344   * the image style.
21345   *
21346   * @param {import("../../style/Image.js").default} imageStyle Image style.
21347   */
21348  setImageStyle(t) {
21349    let i;
21350    if (!t || !(i = t.getSize())) {
21351      this.image_ = null;
21352      return;
21353    }
21354    const n = t.getPixelRatio(this.pixelRatio_), s = t.getAnchor(), r = t.getOrigin();
21355    this.image_ = t.getImage(this.pixelRatio_), this.imageAnchorX_ = s[0] * n, this.imageAnchorY_ = s[1] * n, this.imageHeight_ = i[1] * n, this.imageOpacity_ = t.getOpacity(), this.imageOriginX_ = r[0], this.imageOriginY_ = r[1], this.imageRotateWithView_ = t.getRotateWithView(), this.imageRotation_ = t.getRotation();
21356    const o = t.getScaleArray();
21357    this.imageScale_ = [
21358      o[0] * this.pixelRatio_ / n,
21359      o[1] * this.pixelRatio_ / n
21360    ], this.imageWidth_ = i[0] * n;
21361  }
21362  /**
21363   * Set the text style for subsequent draw operations.  Pass null to
21364   * remove the text style.
21365   *
21366   * @param {import("../../style/Text.js").default} textStyle Text style.
21367   */
21368  setTextStyle(t) {
21369    if (!t)
21370      this.text_ = "";
21371    else {
21372      const i = t.getFill();
21373      if (!i)
21374        this.textFillState_ = null;
21375      else {
21376        const f = i.getColor();
21377        this.textFillState_ = {
21378          fillStyle: li(
21379            f || Si
21380          )
21381        };
21382      }
21383      const n = t.getStroke();
21384      if (!n)
21385        this.textStrokeState_ = null;
21386      else {
21387        const f = n.getColor(), g = n.getLineCap(), m = n.getLineDash(), _ = n.getLineDashOffset(), p = n.getLineJoin(), y = n.getWidth(), x = n.getMiterLimit();
21388        this.textStrokeState_ = {
21389          lineCap: g !== void 0 ? g : $o,
21390          lineDash: m || Er,
21391          lineDashOffset: _ || Cr,
21392          lineJoin: p !== void 0 ? p : Os,
21393          lineWidth: y !== void 0 ? y : Sr,
21394          miterLimit: x !== void 0 ? x : Mr,
21395          strokeStyle: li(
21396            f || br
21397          )
21398        };
21399      }
21400      const s = t.getFont(), r = t.getOffsetX(), o = t.getOffsetY(), a = t.getRotateWithView(), l = t.getRotation(), h = t.getScaleArray(), c = t.getText(), u = t.getTextAlign(), d = t.getTextBaseline();
21401      this.textState_ = {
21402        font: s !== void 0 ? s : Ig,
21403        textAlign: u !== void 0 ? u : wr,
21404        textBaseline: d !== void 0 ? d : Yo
21405      }, this.text_ = c !== void 0 ? Array.isArray(c) ? c.reduce((f, g, m) => f += m % 2 ? " " : g, "") : c : "", this.textOffsetX_ = r !== void 0 ? this.pixelRatio_ * r : 0, this.textOffsetY_ = o !== void 0 ? this.pixelRatio_ * o : 0, this.textRotateWithView_ = a !== void 0 ? a : !1, this.textRotation_ = l !== void 0 ? l : 0, this.textScale_ = [
21406        this.pixelRatio_ * h[0],
21407        this.pixelRatio_ * h[1]
21408      ];
21409    }
21410  }
21411}
21412const Xb = Ub, oi = 0.5;
21413function $b(e, t, i, n, s, r, o) {
21414  const a = e[0] * oi, l = e[1] * oi, h = he(a, l);
21415  h.imageSmoothingEnabled = !1;
21416  const c = h.canvas, u = new Xb(
21417    h,
21418    oi,
21419    s,
21420    null,
21421    o
21422  ), d = i.length, f = Math.floor((256 * 256 * 256 - 1) / d), g = {};
21423  for (let _ = 1; _ <= d; ++_) {
21424    const p = i[_ - 1], y = p.getStyleFunction() || n;
21425    if (!n)
21426      continue;
21427    let x = y(p, r);
21428    if (!x)
21429      continue;
21430    Array.isArray(x) || (x = [x]);
21431    const M = (_ * f).toString(16).padStart(7, "#00000");
21432    for (let w = 0, L = x.length; w < L; ++w) {
21433      const I = x[w], z = I.getGeometryFunction()(p);
21434      if (!z || !re(s, z.getExtent()))
21435        continue;
21436      const U = I.clone(), q = U.getFill();
21437      q && q.setColor(M);
21438      const K = U.getStroke();
21439      K && (K.setColor(M), K.setLineDash(null)), U.setText(void 0);
21440      const Z = I.getImage();
21441      if (Z && Z.getOpacity() !== 0) {
21442        const O = Z.getImageSize();
21443        if (!O)
21444          continue;
21445        const W = he(
21446          O[0],
21447          O[1],
21448          void 0,
21449          { alpha: !1 }
21450        ), gt = W.canvas;
21451        W.fillStyle = M, W.fillRect(0, 0, gt.width, gt.height), U.setImage(
21452          new Kg({
21453            img: gt,
21454            imgSize: O,
21455            anchor: Z.getAnchor(),
21456            anchorXUnits: "pixels",
21457            anchorYUnits: "pixels",
21458            offset: Z.getOrigin(),
21459            opacity: 1,
21460            size: Z.getSize(),
21461            scale: Z.getScale(),
21462            rotation: Z.getRotation(),
21463            rotateWithView: Z.getRotateWithView()
21464          })
21465        );
21466      }
21467      const Mt = U.getZIndex() || 0;
21468      let V = g[Mt];
21469      V || (V = {}, g[Mt] = V, V.Polygon = [], V.Circle = [], V.LineString = [], V.Point = []);
21470      const Y = z.getType();
21471      if (Y === "GeometryCollection") {
21472        const O = (
21473          /** @type {import("../../geom/GeometryCollection.js").default} */
21474          z.getGeometriesArrayRecursive()
21475        );
21476        for (let W = 0, gt = O.length; W < gt; ++W) {
21477          const _t = O[W];
21478          V[_t.getType().replace("Multi", "")].push(
21479            _t,
21480            U
21481          );
21482        }
21483      } else
21484        V[Y.replace("Multi", "")].push(z, U);
21485    }
21486  }
21487  const m = Object.keys(g).map(Number).sort(Ln);
21488  for (let _ = 0, p = m.length; _ < p; ++_) {
21489    const y = g[m[_]];
21490    for (const x in y) {
21491      const E = y[x];
21492      for (let M = 0, w = E.length; M < w; M += 2) {
21493        u.setStyle(E[M + 1]);
21494        for (let L = 0, I = t.length; L < I; ++L)
21495          u.setTransform(t[L]), u.drawGeometry(E[M]);
21496      }
21497    }
21498  }
21499  return h.getImageData(0, 0, c.width, c.height);
21500}
21501function Yb(e, t, i) {
21502  const n = [];
21503  if (i) {
21504    const s = Math.floor(Math.round(e[0]) * oi), r = Math.floor(Math.round(e[1]) * oi), o = (kt(s, 0, i.width - 1) + kt(r, 0, i.height - 1) * i.width) * 4, a = i.data[o], l = i.data[o + 1], c = i.data[o + 2] + 256 * (l + 256 * a), u = Math.floor((256 * 256 * 256 - 1) / t.length);
21505    c && c % u === 0 && n.push(t[c / u - 1]);
21506  }
21507  return n;
21508}
21509const Kb = 0.5, qg = {
21510  Point: iw,
21511  LineString: Qb,
21512  Polygon: sw,
21513  MultiPoint: nw,
21514  MultiLineString: tw,
21515  MultiPolygon: ew,
21516  GeometryCollection: Jb,
21517  Circle: Hb
21518};
21519function Vb(e, t) {
21520  return parseInt(lt(e), 10) - parseInt(lt(t), 10);
21521}
21522function qb(e, t) {
21523  const i = Xl(e, t);
21524  return i * i;
21525}
21526function Xl(e, t) {
21527  return Kb * e / t;
21528}
21529function Hb(e, t, i, n, s) {
21530  const r = i.getFill(), o = i.getStroke();
21531  if (r || o) {
21532    const l = e.getBuilder(i.getZIndex(), "Circle");
21533    l.setFillStrokeStyle(r, o), l.drawCircle(t, n);
21534  }
21535  const a = i.getText();
21536  if (a && a.getText()) {
21537    const l = (s || e).getBuilder(
21538      i.getZIndex(),
21539      "Text"
21540    );
21541    l.setTextStyle(a), l.drawText(t, n);
21542  }
21543}
21544function ld(e, t, i, n, s, r, o) {
21545  let a = !1;
21546  const l = i.getImage();
21547  if (l) {
21548    const h = l.getImageState();
21549    h == at.LOADED || h == at.ERROR ? l.unlistenImageChange(s) : (h == at.IDLE && l.load(), l.listenImageChange(s), a = !0);
21550  }
21551  return Zb(
21552    e,
21553    t,
21554    i,
21555    n,
21556    r,
21557    o
21558  ), a;
21559}
21560function Zb(e, t, i, n, s, r) {
21561  const o = i.getGeometryFunction()(t);
21562  if (!o)
21563    return;
21564  const a = o.simplifyTransformed(
21565    n,
21566    s
21567  );
21568  if (i.getRenderer())
21569    Hg(e, a, i, t);
21570  else {
21571    const h = qg[a.getType()];
21572    h(
21573      e,
21574      a,
21575      i,
21576      t,
21577      r
21578    );
21579  }
21580}
21581function Hg(e, t, i, n) {
21582  if (t.getType() == "GeometryCollection") {
21583    const r = (
21584      /** @type {import("../geom/GeometryCollection.js").default} */
21585      t.getGeometries()
21586    );
21587    for (let o = 0, a = r.length; o < a; ++o)
21588      Hg(e, r[o], i, n);
21589    return;
21590  }
21591  e.getBuilder(i.getZIndex(), "Default").drawCustom(
21592    /** @type {import("../geom/SimpleGeometry.js").default} */
21593    t,
21594    n,
21595    i.getRenderer(),
21596    i.getHitDetectionRenderer()
21597  );
21598}
21599function Jb(e, t, i, n, s) {
21600  const r = t.getGeometriesArray();
21601  let o, a;
21602  for (o = 0, a = r.length; o < a; ++o) {
21603    const l = qg[r[o].getType()];
21604    l(
21605      e,
21606      r[o],
21607      i,
21608      n,
21609      s
21610    );
21611  }
21612}
21613function Qb(e, t, i, n, s) {
21614  const r = i.getStroke();
21615  if (r) {
21616    const a = e.getBuilder(
21617      i.getZIndex(),
21618      "LineString"
21619    );
21620    a.setFillStrokeStyle(null, r), a.drawLineString(t, n);
21621  }
21622  const o = i.getText();
21623  if (o && o.getText()) {
21624    const a = (s || e).getBuilder(
21625      i.getZIndex(),
21626      "Text"
21627    );
21628    a.setTextStyle(o), a.drawText(t, n);
21629  }
21630}
21631function tw(e, t, i, n, s) {
21632  const r = i.getStroke();
21633  if (r) {
21634    const a = e.getBuilder(
21635      i.getZIndex(),
21636      "LineString"
21637    );
21638    a.setFillStrokeStyle(null, r), a.drawMultiLineString(t, n);
21639  }
21640  const o = i.getText();
21641  if (o && o.getText()) {
21642    const a = (s || e).getBuilder(
21643      i.getZIndex(),
21644      "Text"
21645    );
21646    a.setTextStyle(o), a.drawText(t, n);
21647  }
21648}
21649function ew(e, t, i, n, s) {
21650  const r = i.getFill(), o = i.getStroke();
21651  if (o || r) {
21652    const l = e.getBuilder(i.getZIndex(), "Polygon");
21653    l.setFillStrokeStyle(r, o), l.drawMultiPolygon(t, n);
21654  }
21655  const a = i.getText();
21656  if (a && a.getText()) {
21657    const l = (s || e).getBuilder(
21658      i.getZIndex(),
21659      "Text"
21660    );
21661    l.setTextStyle(a), l.drawText(t, n);
21662  }
21663}
21664function iw(e, t, i, n, s) {
21665  const r = i.getImage(), o = i.getText();
21666  let a;
21667  if (r) {
21668    if (r.getImageState() != at.LOADED)
21669      return;
21670    let l = e;
21671    if (s) {
21672      const c = r.getDeclutterMode();
21673      if (c !== "none")
21674        if (l = s, c === "obstacle") {
21675          const u = e.getBuilder(
21676            i.getZIndex(),
21677            "Image"
21678          );
21679          u.setImageStyle(r, a), u.drawPoint(t, n);
21680        } else
21681          o && o.getText() && (a = {});
21682    }
21683    const h = l.getBuilder(
21684      i.getZIndex(),
21685      "Image"
21686    );
21687    h.setImageStyle(r, a), h.drawPoint(t, n);
21688  }
21689  if (o && o.getText()) {
21690    let l = e;
21691    s && (l = s);
21692    const h = l.getBuilder(i.getZIndex(), "Text");
21693    h.setTextStyle(o, a), h.drawText(t, n);
21694  }
21695}
21696function nw(e, t, i, n, s) {
21697  const r = i.getImage(), o = i.getText();
21698  let a;
21699  if (r) {
21700    if (r.getImageState() != at.LOADED)
21701      return;
21702    let l = e;
21703    if (s) {
21704      const c = r.getDeclutterMode();
21705      if (c !== "none")
21706        if (l = s, c === "obstacle") {
21707          const u = e.getBuilder(
21708            i.getZIndex(),
21709            "Image"
21710          );
21711          u.setImageStyle(r, a), u.drawMultiPoint(t, n);
21712        } else
21713          o && o.getText() && (a = {});
21714    }
21715    const h = l.getBuilder(
21716      i.getZIndex(),
21717      "Image"
21718    );
21719    h.setImageStyle(r, a), h.drawMultiPoint(t, n);
21720  }
21721  if (o && o.getText()) {
21722    let l = e;
21723    s && (l = s);
21724    const h = l.getBuilder(i.getZIndex(), "Text");
21725    h.setTextStyle(o, a), h.drawText(t, n);
21726  }
21727}
21728function sw(e, t, i, n, s) {
21729  const r = i.getFill(), o = i.getStroke();
21730  if (r || o) {
21731    const l = e.getBuilder(i.getZIndex(), "Polygon");
21732    l.setFillStrokeStyle(r, o), l.drawPolygon(t, n);
21733  }
21734  const a = i.getText();
21735  if (a && a.getText()) {
21736    const l = (s || e).getBuilder(
21737      i.getZIndex(),
21738      "Text"
21739    );
21740    l.setTextStyle(a), l.drawText(t, n);
21741  }
21742}
21743class rw extends cc {
21744  /**
21745   * @param {import("../../layer/BaseVector.js").default} vectorLayer Vector layer.
21746   */
21747  constructor(t) {
21748    super(t), this.boundHandleStyleImageChange_ = this.handleStyleImageChange_.bind(this), this.animatingOrInteracting_, this.hitDetectionImageData_ = null, this.renderedFeatures_ = null, this.renderedRevision_ = -1, this.renderedResolution_ = NaN, this.renderedExtent_ = be(), this.wrappedRenderedExtent_ = be(), this.renderedRotation_, this.renderedCenter_ = null, this.renderedProjection_ = null, this.renderedRenderOrder_ = null, this.replayGroup_ = null, this.replayGroupChanged = !0, this.declutterExecutorGroup = null, this.clipping = !0, this.compositionContext_ = null, this.opacity_ = 1;
21749  }
21750  /**
21751   * @param {ExecutorGroup} executorGroup Executor group.
21752   * @param {import("../../Map.js").FrameState} frameState Frame state.
21753   * @param {import("rbush").default} [declutterTree] Declutter tree.
21754   */
21755  renderWorlds(t, i, n) {
21756    const s = i.extent, r = i.viewState, o = r.center, a = r.resolution, l = r.projection, h = r.rotation, c = l.getExtent(), u = this.getLayer().getSource(), d = i.pixelRatio, f = i.viewHints, g = !(f[Kt.ANIMATING] || f[Kt.INTERACTING]), m = this.compositionContext_, _ = Math.round(i.size[0] * d), p = Math.round(i.size[1] * d), y = u.getWrapX() && l.canWrapX(), x = y ? xt(c) : null, E = y ? Math.ceil((s[2] - c[2]) / x) + 1 : 1;
21757    let M = y ? Math.floor((s[0] - c[0]) / x) : 0;
21758    do {
21759      const w = this.getRenderTransform(
21760        o,
21761        a,
21762        h,
21763        d,
21764        _,
21765        p,
21766        M * x
21767      );
21768      t.execute(
21769        m,
21770        1,
21771        w,
21772        h,
21773        g,
21774        void 0,
21775        n
21776      );
21777    } while (++M < E);
21778  }
21779  setupCompositionContext_() {
21780    if (this.opacity_ !== 1) {
21781      const t = he(
21782        this.context.canvas.width,
21783        this.context.canvas.height,
21784        sd
21785      );
21786      this.compositionContext_ = t;
21787    } else
21788      this.compositionContext_ = this.context;
21789  }
21790  releaseCompositionContext_() {
21791    if (this.opacity_ !== 1) {
21792      const t = this.context.globalAlpha;
21793      this.context.globalAlpha = this.opacity_, this.context.drawImage(this.compositionContext_.canvas, 0, 0), this.context.globalAlpha = t, Sa(this.compositionContext_), sd.push(this.compositionContext_.canvas), this.compositionContext_ = null;
21794    }
21795  }
21796  /**
21797   * Render declutter items for this layer
21798   * @param {import("../../Map.js").FrameState} frameState Frame state.
21799   */
21800  renderDeclutter(t) {
21801    this.declutterExecutorGroup && (this.setupCompositionContext_(), this.renderWorlds(
21802      this.declutterExecutorGroup,
21803      t,
21804      t.declutterTree
21805    ), this.releaseCompositionContext_());
21806  }
21807  /**
21808   * Render the layer.
21809   * @param {import("../../Map.js").FrameState} frameState Frame state.
21810   * @param {HTMLElement} target Target that may be used to render content to.
21811   * @return {HTMLElement} The rendered element.
21812   */
21813  renderFrame(t, i) {
21814    const n = t.pixelRatio, s = t.layerStatesArray[t.layerIndex];
21815    XE(this.p
21815ixelTransform, 1 / n, 1 / n), Ca(this.inversePixelTransform, this.pixelTransform);
21816    const r = Fh(this.pixelTransform);
21817    this.useContainer(i, r, this.getBackground(t));
21818    const o = this.context, a = o.canvas, l = this.replayGroup_, h = this.declutterExecutorGroup;
21819    if ((!l || l.isEmpty()) && (!h || h.isEmpty()))
21820      return null;
21821    const c = Math.round(t.size[0] * n), u = Math.round(t.size[1] * n);
21822    a.width != c || a.height != u ? (a.width = c, a.height = u, a.style.transform !== r && (a.style.transform = r)) : this.containerReused || o.clearRect(0, 0, c, u), this.preRender(o, t);
21823    const d = t.viewState;
21824    d.projection, this.opacity_ = s.opacity, this.setupCompositionContext_();
21825    let f = !1, g = !0;
21826    if (s.extent && this.clipping) {
21827      const m = ai(s.extent);
21828      g = re(m, t.extent), f = g && !Bi(m, t.extent), f && this.clipUnrotated(this.compositionContext_, t, m);
21829    }
21830    return g && this.renderWorlds(l, t), f && this.compositionContext_.restore(), this.releaseCompositionContext_(), this.postRender(o, t), this.renderedRotation_ !== d.rotation && (this.renderedRotation_ = d.rotation, this.hitDetectionImageData_ = null), this.container;
21831  }
21832  /**
21833   * Asynchronous layer level hit detection.
21834   * @param {import("../../pixel.js").Pixel} pixel Pixel.
21835   * @return {Promise<Array<import("../../Feature").default>>} Promise
21836   * that resolves with an array of features.
21837   */
21838  getFeatures(t) {
21839    return new Promise((i) => {
21840      if (!this.hitDetectionImageData_ && !this.animatingOrInteracting_) {
21841        const n = [this.context.canvas.width, this.context.canvas.height];
21842        Bt(this.pixelTransform, n);
21843        const s = this.renderedCenter_, r = this.renderedResolution_, o = this.renderedRotation_, a = this.renderedProjection_, l = this.wrappedRenderedExtent_, h = this.getLayer(), c = [], u = n[0] * oi, d = n[1] * oi;
21844        c.push(
21845          this.getRenderTransform(
21846            s,
21847            r,
21848            o,
21849            oi,
21850            u,
21851            d,
21852            0
21853          ).slice()
21854        );
21855        const f = h.getSource(), g = a.getExtent();
21856        if (f.getWrapX() && a.canWrapX() && !Bi(g, l)) {
21857          let m = l[0];
21858          const _ = xt(g);
21859          let p = 0, y;
21860          for (; m < g[0]; )
21861            --p, y = _ * p, c.push(
21862              this.getRenderTransform(
21863                s,
21864                r,
21865                o,
21866                oi,
21867                u,
21868                d,
21869                y
21870              ).slice()
21871            ), m += _;
21872          for (p = 0, m = l[2]; m > g[2]; )
21873            ++p, y = _ * p, c.push(
21874              this.getRenderTransform(
21875                s,
21876                r,
21877                o,
21878                oi,
21879                u,
21880                d,
21881                y
21882              ).slice()
21883            ), m -= _;
21884        }
21885        this.hitDetectionImageData_ = $b(
21886          n,
21887          c,
21888          this.renderedFeatures_,
21889          h.getStyleFunction(),
21890          l,
21891          r,
21892          o
21893        );
21894      }
21895      i(
21896        Yb(t, this.renderedFeatures_, this.hitDetectionImageData_)
21897      );
21898    });
21899  }
21900  /**
21901   * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
21902   * @param {import("../../Map.js").FrameState} frameState Frame state.
21903   * @param {number} hitTolerance Hit tolerance in pixels.
21904   * @param {import("../vector.js").FeatureCallback<T>} callback Feature callback.
21905   * @param {Array<import("../Map.js").HitMatch<T>>} matches The hit detected matches with tolerance.
21906   * @return {T|undefined} Callback result.
21907   * @template T
21908   */
21909  forEachFeatureAtCoordinate(t, i, n, s, r) {
21910    if (!this.replayGroup_)
21911      return;
21912    const o = i.viewState.resolution, a = i.viewState.rotation, l = this.getLayer(), h = {}, c = function(f, g, m) {
21913      const _ = lt(f), p = h[_];
21914      if (p) {
21915        if (p !== !0 && m < p.distanceSq) {
21916          if (m === 0)
21917            return h[_] = !0, r.splice(r.lastIndexOf(p), 1), s(f, l, g);
21918          p.geometry = g, p.distanceSq = m;
21919        }
21920      } else {
21921        if (m === 0)
21922          return h[_] = !0, s(f, l, g);
21923        r.push(
21924          h[_] = {
21925            feature: f,
21926            layer: l,
21927            geometry: g,
21928            distanceSq: m,
21929            callback: s
21930          }
21931        );
21932      }
21933    };
21934    let u;
21935    const d = [this.replayGroup_];
21936    return this.declutterExecutorGroup && d.push(this.declutterExecutorGroup), d.some((f) => u = f.forEachFeatureAtCoordinate(
21937      t,
21938      o,
21939      a,
21940      n,
21941      c,
21942      f === this.declutterExecutorGroup && i.declutterTree ? i.declutterTree.all().map((g) => g.value) : null
21943    )), u;
21944  }
21945  /**
21946   * Perform action necessary to get the layer rendered after new fonts have loaded
21947   */
21948  handleFontsChanged() {
21949    const t = this.getLayer();
21950    t.getVisible() && this.replayGroup_ && t.changed();
21951  }
21952  /**
21953   * Handle changes in image style state.
21954   * @param {import("../../events/Event.js").default} event Image style change event.
21955   * @private
21956   */
21957  handleStyleImageChange_(t) {
21958    this.renderIfReadyAndVisible();
21959  }
21960  /**
21961   * Determine whether render should be called.
21962   * @param {import("../../Map.js").FrameState} frameState Frame state.
21963   * @return {boolean} Layer is ready to be rendered.
21964   */
21965  prepareFrame(t) {
21966    const i = this.getLayer(), n = i.getSource();
21967    if (!n)
21968      return !1;
21969    const s = t.viewHints[Kt.ANIMATING], r = t.viewHints[Kt.INTERACTING], o = i.getUpd
21969ateWhileAnimating(), a = i.getUpdateWhileInteracting();
21970    if (this.ready && !o && s || !a && r)
21971      return this.animatingOrInteracting_ = !0, !0;
21972    this.animatingOrInteracting_ = !1;
21973    const l = t.extent, h = t.viewState, c = h.projection, u = h.resolution, d = t.pixelRatio, f = i.getRevision(), g = i.getRenderBuffer();
21974    let m = i.getRenderOrder();
21975    m === void 0 && (m = Vb);
21976    const _ = h.center.slice(), p = Rn(
21977      l,
21978      g * u
21979    ), y = p.slice(), x = [p.slice()], E = c.getExtent();
21980    if (n.getWrapX() && c.canWrapX() && !Bi(E, t.extent)) {
21981      const V = xt(E), Y = Math.max(xt(p) / 2, V);
21982      p[0] = E[0] - Y, p[2] = E[2] + Y, of(_, c);
21983      const O = sf(x[0], c);
21984      O[0] < E[0] && O[2] < E[2] ? x.push([
21985        O[0] + V,
21986        O[1],
21987        O[2] + V,
21988        O[3]
21989      ]) : O[0] > E[0] && O[2] > E[2] && x.push([
21990        O[0] - V,
21991        O[1],
21992        O[2] - V,
21993        O[3]
21994      ]);
21995    }
21996    if (this.ready && this.renderedResolution_ == u && this.renderedRevision_ == f && this.renderedRenderOrder_ == m && Bi(this.wrappedRenderedExtent_, p))
21997      return Pi(this.renderedExtent_, y) || (this.hitDetectionImageData_ = null, this.renderedExtent_ = y), this.renderedCenter_ = _, this.replayGroupChanged = !1, !0;
21998    this.replayGroup_ = null;
21999    const M = new nd(
22000      Xl(u, d),
22001      p,
22002      u,
22003      d
22004    );
22005    let w;
22006    this.getLayer().getDeclutter() && (w = new nd(
22007      Xl(u, d),
22008      p,
22009      u,
22010      d
22011    ));
22012    let L;
22013    for (let V = 0, Y = x.length; V < Y; ++V)
22014      n.loadFeatures(x[V], u, c);
22015    const I = qb(u, d);
22016    let z = !0;
22017    const U = (
22018      /**
22019       * @param {import("../../Feature.js").default} feature Feature.
22020       */
22021      (V) => {
22022        let Y;
22023        const O = V.getStyleFunction() || i.getStyleFunction();
22024        if (O && (Y = O(V, u)), Y) {
22025          const W = this.renderFeature(
22026            V,
22027            I,
22028            Y,
22029            M,
22030            L,
22031            w
22032          );
22033          z = z && !W;
22034        }
22035      }
22036    ), q = la(p), K = n.getFeaturesInExtent(q);
22037    m && K.sort(m);
22038    for (let V = 0, Y = K.length; V < Y; ++V)
22039      U(K[V]);
22040    this.renderedFeatures_ = K, this.ready = z;
22041    const Z = M.finish(), Mt = new ad(
22042      p,
22043      u,
22044      d,
22045      n.getOverlaps(),
22046      Z,
22047      i.getRenderBuffer()
22048    );
22049    return w && (this.declutterExecutorGroup = new ad(
22050      p,
22051      u,
22052      d,
22053      n.getOverlaps(),
22054      w.finish(),
22055      i.getRenderBuffer()
22056    )), this.renderedResolution_ = u, this.renderedRevision_ = f, this.renderedRenderOrder_ = m, this.renderedExtent_ = y, this.wrappedRenderedExtent_ = p, this.renderedCenter_ = _, this.renderedProjection_ = c, this.replayGroup_ = Mt, this.hitDetectionImageData_ = null, this.replayGroupChanged = !0, !0;
22057  }
22058  /**
22059   * @param {import("../../Feature.js").default} feature Feature.
22060   * @param {number} squaredTolerance Squared render tolerance.
22061   * @param {import("../../style/Style.js").default|Array<import("../../style/Style.js").default>} styles The style or array of styles.
22062   * @param {import("../../render/canvas/BuilderGroup.js").default} builderGroup Builder group.
22063   * @param {import("../../proj.js").TransformFunction} [transform] Transform from user to view projection.
22064   * @param {import("../../render/canvas/BuilderGroup.js").default} [declutterBuilderGroup] Builder for decluttering.
22065   * @return {boolean} `true` if an image is loading.
22066   */
22067  renderFeature(t, i, n, s, r, o) {
22068    if (!n)
22069      return !1;
22070    let a = !1;
22071    if (Array.isArray(n))
22072      for (let l = 0, h = n.length; l < h; ++l)
22073        a = ld(
22074          s,
22075          t,
22076          n[l],
22077          i,
22078          this.boundHandleStyleImageChange_,
22079          r,
22080          o
22081        ) || a;
22082    else
22083      a = ld(
22084        s,
22085        t,
22086        n,
22087        i,
22088        this.boundHandleStyleImageChange_,
22089        r,
22090        o
22091      );
22092    return a;
22093  }
22094}
22095const ow = rw;
22096class aw extends xb {
22097  /**
22098   * @param {import("./BaseVector.js").Options<VectorSourceType>} [options] Options.
22099   */
22100  constructor(t) {
22101    super(t);
22102  }
22103  createRenderer() {
22104    return new ow(this);
22105  }
22106}
22107const ps = aw;
22108class lw {
22109  /**
22110   * @param {number} [maxEntries] Max entries.
22111   */
22112  constructor(t) {
22113    this.rbush_ = new $g(t), this.items_ = {};
22114  }
22115  /**
22116   * Insert a value into the RBush.
22117   * @param {import("../extent.js").Extent} extent Extent.
22118   * @param {T} value Value.
22119   */
22120  insert(t, i) {
22121    const n = {
22122      minX: t[0],
22123      minY: t[1],
22124      maxX: t[2],
22125      maxY: t[3],
22126      value: i
22127    };
22128    this.rbush_.insert(n), this.items_[lt(i)] = n;
22129  }
22130  /**
22131   * Bulk-insert values into the RBush.
22132   * @param {Array<import("../extent.js").Extent>} extents Extents.
22133   * @param {Array<T>} values Values.
22134   */
22135  load(t, i) {
22136    const n = new Array(i.length);
22137    for (let s = 0, r = i.length; s < r; s++) {
22138      const o = t[s], a = i[s], l = {
22139        minX: o[0],
22140        minY: o[1],
22141        maxX: o[2],
22142        maxY: o[3],
22143        value: a
22144      };
22145      n[s] = l, this.items_[lt(a)] = l;
22146    }
22147    this.rbush_.load(n);
22148  }
22149  /**
22150   * Remove a value from the RBush.
22151   * @param {T} value Value.
22152   * @return {boolean} Removed.
22153   */
22154  remove(t) {
22155    const i = lt(t), n = this.items_[i];
22156    return delete this.items_[i], this.rbush_.remove(n) !== null;
22157  }
22158  /**
22159   * Update the extent of a value in the RBush.
22160   * @param {import("../extent.js").Extent} extent Extent.
22161   * @param {T} value Value.
22162   */
22163  update(t, i) {
22164    const n = this.items_[lt(i)], s = [n.minX, n.minY, n.maxX, n.maxY];
22165    Ss(s, t) || (this.remove(i), this.insert(t, i));
22166  }
22167  /**
22168   * Return all values in the RBush.
22169   * @return {Array<T>} All.
22170   */
22171  getAll() {
22172    return this.rbush_.all().map(function(i) {
22173      return i.value;
22174    });
22175  }
22176  /**
22177   * Return all values in the given extent.
22178   * @param {import("../extent.js").Extent} extent Extent.
22179   * @return {Array<T>} All in extent.
22180   */
22181  getInExtent(t) {
22182    const i = {
22183      minX: t[0],
22184      minY: t[1],
22185      maxX: t[2],
22186      maxY: t[3]
22187    };
22188    return this.rbush_.search(i).map(function(s) {
22189      return s.value;
22190    });
22191  }
22192  /**
22193   * Calls a callback function with each value in the tree.
22194   * If the callback returns a truthy value, this value is returned without
22195   * checking the rest of the tree.
22196   * @param {function(T): *} callback Callback.
22197   * @return {*} Callback return value.
22198   */
22199  forEach(t) {
22200    return this.forEach_(this.getAll(), t);
22201  }
22202  /**
22203   * Calls a callback function with each value in the provided extent.
22204   * @param {import("../extent.js").Extent} extent Extent.
22205   * @param {function(T): *} callback Callback.
22206   * @return {*} Callback return value.
22207   */
22208  forEachInExtent(t, i) {
22209    return this.forEach_(this.getInExtent(t), i);
22210  }
22211  /**
22212   * @param {Array<T>} values Values.
22213   * @param {function(T): *} callback Callback.
22214   * @private
22215   * @return {*} Callback return value.
22216   */
22217  forEach_(t, i) {
22218    let n;
22219    for (let s = 0, r = t.length; s < r; s++)
22220      if (n = i(t[s]), n)
22221        return n;
22222    return n;
22223  }
22224  /**
22225   * @return {boolean} Is empty.
22226   */
22227  isEmpty() {
22228    return bs(this.items_);
22229  }
22230  /**
22231   * Remove all values from the RBush.
22232   */
22233  clear() {
22234    this.rbush_.clear(), this.items_ = {};
22235  }
22236  /**
22237   * @param {import("../extent.js").Extent} [extent] Extent.
22238   * @return {import("../extent.js").Extent} Extent.
22239   */
22240  getExtent(t) {
22241    const i = this.rbush_.toJSON();
22242    return fi(i.minX, i.minY, i.maxX, i.maxY, t);
22243  }
22244  /**
22245   * @param {RBush} rbush R-Tree.
22246   */
22247  concat(t) {
22248    this.rbush_.load(t.rbush_.all());
22249    for (const i in t.items_)
22250      this.items_[i] = t.items_[i];
22251  }
22252}
22253const Zo = lw;
22254class hw extends Qe {
22255  /**
22256   * @param {Options} options Source options.
22257   */
22258  constructor(t) {
22259    super(), this.projection = It(t.projection), this.attributions_ = hd(t.attributions), this.attributionsCollapsible_ = t.attributionsCollapsible !== void 0 ? t.attributionsCollapsible : !0, this.loading = !1, this.state_ = t.state !== void 0 ? t.state : "ready", this.wrapX_ = t.wrapX !== void 0 ? t.wrapX : !1, this.interpolate_ = !!t.interpolate, this.viewResolver = null, this.viewRejector = null;
22260    const i = this;
22261    this.viewPromise_ = new Promise(function(n, s) {
22262      i.viewResolver = n, i.viewRejector = s;
22263    });
22264  }
22265  /**
22266   * Get the attribution function for the source.
22267   * @return {?Attribution} Attribution function.
22268   * @api
22269   */
22270  getAttributions() {
22271    return this.attributions_;
22272  }
22273  /**
22274   * @return {boolean} Attributions are collapsible.
22275   * @api
22276   */
22277  getAttributionsCollapsible() {
22278    return this.attributionsCollapsible_;
22279  }
22280  /**
22281   * Get the projection of the source.
22282   * @return {import("../proj/Projection.js").default|null} Projection.
22283   * @api
22284   */
22285  getProjection() {
22286    return this.projection;
22287  }
22288  /**
22289   * @param {import("../proj/Projection").default} [projection] Projection.
22290   * @return {Array<number>|null} Resolutions.
22291   */
22292  getResolutions(t) {
22293    return null;
22294  }
22295  /**
22296   * @return {Promise<import("../View.js").ViewOptions>} A promise for view-related properties.
22297   */
22298  getView() {
22299    return this.viewPromise_;
22300  }
22301  /**
22302   * Get the state of the source, see {@link import("./Source.js").State} for possible states.
22303   * @return {import("./Source.js").State} State.
22304   * @api
22305   */
22306  getState() {
22307    return this.state_;
22308  }
22309  /**
22310   * @return {boolean|undefined} Wrap X.
22311   */
22312  getWrapX() {
22313    return this.wrapX_;
22314  }
22315  /**
22316   * @return {boolean} Use linear interpolation when resampling.
22317   */
22318  getInterpolate() {
22319    return this.interpolate_;
22320  }
22321  /**
22322   * Refreshes the source. The source will be cleared, and data from the server will be reloaded.
22323   * @api
22324   */
22325  refresh() {
22326    this.changed();
22327  }
22328  /**
22329   * Set the attributions of the source.
22330   * @param {AttributionLike|undefined} attributions Attributions.
22331   *     Can be passed as `string`, `Array<string>`, {@link module:ol/source/Source~Attribution},
22332   *     or `undefined`.
22333   * @api
22334   */
22335  setAttributions(t) {
22336    this.attributions_ = hd(t), this.changed();
22337  }
22338  /**
22339   * Set the state of the source.
22340   * @param {import("./Source.js").State} state State.
22341   */
22342  setState(t) {
22343    this.state_ = t, this.changed();
22344  }
22345}
22346function hd(e) {
22347  return e ? Array.isArray(e) ? function(t) {
22348    return e;
22349  } : typeof e == "function" ? e : function(t) {
22350    return [e];
22351  } : null;
22352}
22353const uc = hw, de = {
22354  /**
22355   * Triggered when a feature is added to the source.
22356   * @event module:ol/source/Vector.VectorSourceEvent#addfeature
22357   * @api
22358   */
22359  ADDFEATURE: "addfeature",
22360  /**
22361   * Triggered when a feature is updated.
22362   * @event module:ol/source/Vector.VectorSourceEvent#changefeature
22363   * @api
22364   */
22365  CHANGEFEATURE: "changefeature",
22366  /**
22367   * Triggered when the clear method is called on the source.
22368   * @event module:ol/source/Vector.VectorSourceEvent#clear
22369   * @api
22370   */
22371  CLEAR: "clear",
22372  /**
22373   * Triggered when a feature is removed from the source.
22374   * See {@link module:ol/source/Vector~VectorSource#clear source.clear()} for exceptions.
22375   * @event module:ol/source/Vector.VectorSourceEvent#removefeature
22376   * @api
22377   */
22378  REMOVEFEATURE: "removefeature",
22379  /**
22380   * Triggered when features starts loading.
22381   * @event module:ol/source/Vector.VectorSourceEvent#featuresloadstart
22382   * @api
22383   */
22384  FEATURESLOADSTART: "featuresloadstart",
22385  /**
22386   * Triggered when features finishes loading.
22387   * @event module:ol/source/Vector.VectorSourceEvent#featuresloadend
22388   * @api
22389   */
22390  FEATURESLOADEND: "featuresloadend",
22391  /**
22392   * Triggered if feature loading results in an error.
22393   * @event module:ol/source/Vector.VectorSourceEvent#featuresloaderror
22394   * @api
22395   */
22396  FEATURESLOADERROR: "featuresloaderror"
22397};
22398function cw(e, t) {
22399  return [[-1 / 0, -1 / 0, 1 / 0, 1 / 0]];
22400}
22401let uw = !1;
22402function dw(e, t, i, n, s, r, o) {
22403  const a = new XMLHttpRequest();
22404  a.open(
22405    "GET",
22406    typeof e == "function" ? e(i, n, s) : e,
22407    !0
22408  ), t.getType() == "arraybuffer" && (a.responseType = "arraybuffer"), a.withCredentials = uw, a.onload = function(l) {
22409    if (!a.status || a.status >= 200 && a.status < 300) {
22410      const h = t.getType();
22411      let c;
22412      h == "json" || h == "text" ? c = a.responseText : h == "xml" ? (c = a.responseXML, c || (c = new DOMParser().parseFromString(
22413        a.responseText,
22414        "application/xml"
22415      ))) : h == "arraybuffer" && (c = /** @type {ArrayBuffer} */
22416      a.response), c ? r(
22417        /** @type {Array<import("./Feature.js").default>} */
22418        t.readFeatures(c, {
22419          extent: i,
22420          featureProjection: s
22421        }),
22422        t.readProjection(c)
22423      ) : o();
22424    } else
22425      o();
22426  }, a.onerror = o, a.send();
22427}
22428function cd(e, t) {
22429  return function(i, n, s, r, o) {
22430    const a = (
22431      /** @type {import("./source/Vector").default} */
22432      this
22433    );
22434    dw(
22435      e,
22436      t,
22437      i,
22438      n,
22439      s,
22440      /**
22441       * @param {Array<import("./Feature.js").default>} features The loaded features.
22442       * @param {import("./proj/Projection.js").default} dataProjection Data
22443       * projection.
22444       */
22445      function(l, h) {
22446        a.addFeatures(l), r !== void 0 && r(l);
22447      },
22448      /* FIXME handle error */
22449      o || As
22450    );
22451  };
22452}
22453class ki extends Le {
22454  /**
22455   * @param {string} type Type.
22456   * @param {import("../Feature.js").default<Geometry>} [feature] Feature.
22457   * @param {Array<import("../Feature.js").default<Geometry>>} [features] Features.
22458   */
22459  constructor(t, i, n) {
22460    super(t), this.feature = i, this.features = n;
22461  }
22462}
22463class fw extends uc {
22464  /**
22465   * @param {Options<Geometry>} [options] Vector source options.
22466   */
22467  constructor(t) {
22468    t = t || {}, super({
22469      attributions: t.attributions,
22470      interpolate: !0,
22471      projection: void 0,
22472      state: "ready",
22473      wrapX: t.wrapX !== void 0 ? t.wrapX : !0
22474    }), this.on, this.once, this.un, this.loader_ = As, this.format_ = t.format, this.overlaps_ = t.overlaps === void 0 ? !0 : t.overlaps, this.url_ = t.url, t.loader !== void 0 ? this.loader_ = t.loader : this.url_ !== void 0 && (ht(this.format_, 7), this.loader_ = cd(
22475      this.url_,
22476      /** @type {import("../format/Feature.js").default} */
22477      this.format_
22478    )), this.strategy_ = t.strategy !== void 0 ? t.strategy : cw;
22479    const i = t.useSpatialIndex !== void 0 ? t.useSpatialIndex : !0;
22480    this.featuresRtree_ = i ? new Zo() : null, this.loadedExtentsRtree_ = new Zo(), this.loadingExtentsCount_ = 0, this.nullGeometryFeatures_ = {}, this.idIndex_ = {}, this.uidIndex_ = {}, this.featureChangeKeys_ = {}, this.featuresCollection_ = null;
22481    let n, s;
22482    Array.isArray(t.features) ? s = t.features : t.features && (n = t.features, s = n.getArray()), !i && n === void 0 && (n = new De(s)), s !== void 0 && this.addFeaturesInternal(s), n !== void 0 && this.bindFeaturesCollection_(n);
22483  }
22484  /**
22485   * Add a single feature to the source.  If you want to add a batch of features
22486   * at once, call {@link module:ol/source/Vector~VectorSource#addFeatures #addFeatures()}
22487   * instead. A feature will not be added to the source if feature with
22488   * the same id is already there. The reason for this behavior is to avoid
22489   * feature duplication when using bbox or tile loading strategies.
22490   * Note: this also applies if an {@link module:ol/Collection~Collection} is used for features,
22491   * meaning that if a feature with a duplicate id is added in the collection, it will
22492   * be removed from it right away.
22493   * @param {import("../Feature.js").default<Geometry>} feature Feature to add.
22494   * @api
22495   */
22496  addFeature(t) {
22497    this.addFeatureInternal(t), this.changed();
22498  }
22499  /**
22500   * Add a feature without firing a `change` event.
22501   * @param {import("../Feature.js").default<Geometry>} feature Feature.
22502   * @protected
22503   */
22504  addFeatureInternal(t) {
22505    const i = lt(t);
22506    if (!this.addToIndex_(i, t)) {
22507      this.featuresCollection_ && this.featuresCollection_.remove(t);
22508      return;
22509    }
22510    this.setupChangeEvents_(i, t);
22511    const n = t.getGeometry();
22512    if (n) {
22513      const s = n.getExtent();
22514      this.featuresRtree_ && this.featuresRtree_.insert(s, t);
22515    } else
22516      this.nullGeometryFeatures_[i] = t;
22517    this.dispatchEvent(
22518      new ki(de.ADDFEATURE, t)
22519    );
22520  }
22521  /**
22522   * @param {string} featureKey Unique identifier for the feature.
22523   * @param {import("../Feature.js").d
22523efault<Geometry>} feature The feature.
22524   * @private
22525   */
22526  setupChangeEvents_(t, i) {
22527    this.featureChangeKeys_[t] = [
22528      ct(i, et.CHANGE, this.handleFeatureChange_, this),
22529      ct(
22530        i,
22531        Ls.PROPERTYCHANGE,
22532        this.handleFeatureChange_,
22533        this
22534      )
22535    ];
22536  }
22537  /**
22538   * @param {string} featureKey Unique identifier for the feature.
22539   * @param {import("../Feature.js").default<Geometry>} feature The feature.
22540   * @return {boolean} The feature is "valid", in the sense that it is also a
22541   *     candidate for insertion into the Rtree.
22542   * @private
22543   */
22544  addToIndex_(t, i) {
22545    let n = !0;
22546    const s = i.getId();
22547    return s !== void 0 && (s.toString() in this.idIndex_ ? n = !1 : this.idIndex_[s.toString()] = i), n && (ht(!(t in this.uidIndex_), 30), this.uidIndex_[t] = i), n;
22548  }
22549  /**
22550   * Add a batch of features to the source.
22551   * @param {Array<import("../Feature.js").default<Geometry>>} features Features to add.
22552   * @api
22553   */
22554  addFeatures(t) {
22555    this.addFeaturesInternal(t), this.changed();
22556  }
22557  /**
22558   * Add features without firing a `change` event.
22559   * @param {Array<import("../Feature.js").default<Geometry>>} features Features.
22560   * @protected
22561   */
22562  addFeaturesInternal(t) {
22563    const i = [], n = [], s = [];
22564    for (let r = 0, o = t.length; r < o; r++) {
22565      const a = t[r], l = lt(a);
22566      this.addToIndex_(l, a) && n.push(a);
22567    }
22568    for (let r = 0, o = n.length; r < o; r++) {
22569      const a = n[r], l = lt(a);
22570      this.setupChangeEvents_(l, a);
22571      const h = a.getGeometry();
22572      if (h) {
22573        const c = h.getExtent();
22574        i.push(c), s.push(a);
22575      } else
22576        this.nullGeometryFeatures_[l] = a;
22577    }
22578    if (this.featuresRtree_ && this.featuresRtree_.load(i, s), this.hasListener(de.ADDFEATURE))
22579      for (let r = 0, o = n.length; r < o; r++)
22580        this.dispatchEvent(
22581          new ki(de.ADDFEATURE, n[r])
22582        );
22583  }
22584  /**
22585   * @param {!Collection<import("../Feature.js").default<Geometry>>} collection Collection.
22586   * @private
22587   */
22588  bindFeaturesCollection_(t) {
22589    let i = !1;
22590    this.addEventListener(
22591      de.ADDFEATURE,
22592      /**
22593       * @param {VectorSourceEvent<Geometry>} evt The vector source event
22594       */
22595      function(n) {
22596        i || (i = !0, t.push(n.feature), i = !1);
22597      }
22598    ), this.addEventListener(
22599      de.REMOVEFEATURE,
22600      /**
22601       * @param {VectorSourceEvent<Geometry>} evt The vector source event
22602       */
22603      function(n) {
22604        i || (i = !0, t.remove(n.feature), i = !1);
22605      }
22606    ), t.addEventListener(
22607      Vt.ADD,
22608      /**
22609       * @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event
22610       */
22611      (n) => {
22612        i || (i = !0, this.addFeature(n.element), i = !1);
22613      }
22614    ), t.addEventListener(
22615      Vt.REMOVE,
22616      /**
22617       * @param {import("../Collection.js").CollectionEvent<import("../Feature.js").default<Geometry>>} evt The collection event
22618       */
22619      (n) => {
22620        i || (i = !0, this.removeFeature(n.element), i = !1);
22621      }
22622    ), this.featuresCollection_ = t;
22623  }
22624  /**
22625   * Remove all features from the source.
22626   * @param {boolean} [fast] Skip dispatching of {@link module:ol/source/Vector.VectorSourceEvent#event:removefeature} events.
22627   * @api
22628   */
22629  clear(t) {
22630    if (t) {
22631      for (const n in this.featureChangeKeys_)
22632        this.featureChangeKeys_[n].forEach(St);
22633      this.featuresCollection_ || (this.featureChangeKeys_ = {}, this.idIndex_ = {}, this.uidIndex_ = {});
22634    } else if (this.featuresRtree_) {
22635      const n = (s) => {
22636        this.removeFeatureInternal(s);
22637      };
22638      this.featuresRtree_.forEach(n);
22639      for (const s in this.nullGeometryFeatures_)
22640        this.removeFeatureInternal(this.nullGeometryFeatures_[s]);
22641    }
22642    this.featuresCollection_ && this.featuresCollection_.clear(), this.featuresRtree_ && this.featuresRtree_.clear(), this.nullGeometryFeatures_ = {};
22643    const i = new ki(de.CLEAR);
22644    this.dispatchEvent(i), this.changed();
22645  }
22646  /**
22647   * Iterate through all features on the source, calling the provided callback
22648   * with each one.  If the callback returns any "truthy" value, iteration will
22649   * stop and the function will return the same value.
22650   * Note: this function only iterate through the feature that have a defined geometry.
22651   *
22652   * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
22653   *     on the source.  Return a truthy value to stop iteration.
22654   * @return {T|undefined} The return value from the last call to the callback.
22655   * @template T
22656   * @api
22657   */
22658  forEachFeature(t) {
22659    if (this.featuresRtree_)
22660      return this.featuresRtree_.forEach(t);
22661    this.featuresCollection_ && this.featuresCollection_.forEach(t);
22662  }
22663  /**
22664   * Iterate through all features whose geometries contain the provided
22665   * coordinate, calling the callback with each feature.  If the callback returns
22666   * a "truthy" value, iteration will stop and the function will return the same
22667   * value.
22668   *
22669   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
22670   * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
22671   *     whose goemetry contains the provided coordinate.
22672   * @return {T|undefined} The return value from the last call to the callback.
22673   * @template T
22674   */
22675  forEachFeatureAtCoordinateDirect(t, i) {
22676    const n = [t[0], t[1], t[0], t[1]];
22677    return this.forEachFeatureInExtent(n, function(s) {
22678      if (s.getGeometry().intersectsCoordinate(t))
22679        return i(s);
22680    });
22681  }
22682  /**
22683   * Iterate through all features whose bounding box intersects the provided
22684   * extent (note that the feature's geometry may not intersect the extent),
22685   * calling the callback with each feature.  If the callback returns a "truthy"
22686   * value, iteration will stop and the function will return the same value.
22687   *
22688   * If you are interested in features whose geometry intersects an extent, call
22689   * the {@link module:ol/source/Vector~VectorSource#forEachFeatureIntersectingExtent #forEachFeatureIntersectingExtent()} method instead.
22690   *
22691   * When `useSpatialIndex` is set to false, this method will loop through all
22692   * features, equivalent to {@link module:ol/source/Vector~VectorSource#forEachFeature #forEachFeature()}.
22693   *
22694   * @param {import("../extent.js").Extent} extent Extent.
22695   * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
22696   *     whose bounding box intersects the provided extent.
22697   * @return {T|undefined} The return value from the last call to the callback.
22698   * @template T
22699   * @api
22700   */
22701  forEachFeatureInExtent(t, i) {
22702    if (this.featuresRtree_)
22703      return this.featuresRtree_.forEachInExtent(t, i);
22704    this.featuresCollection_ && this.featuresCollection_.forEach(i);
22705  }
22706  /**
22707   * Iterate through all features whose geometry intersects the provided extent,
22708   * calling the callback with each feature.  If the callback returns a "truthy"
22709   * value, iteration will stop and the function will return the same value.
22710   *
22711   * If you only want to test for bounding box intersection, call the
22712   * {@link module:ol/source/Vector~VectorSource#forEachFeatureInExtent #forEachFeatureInExtent()} method instead.
22713   *
22714   * @param {import("../extent.js").Extent} extent Extent.
22715   * @param {function(import("../Feature.js").default<Geometry>): T} callback Called with each feature
22716   *     whose geometry intersects the provided extent.
22717   * @return {T|undefined} The return value from the last call to the callback.
22718   * @template T
22719   * @api
22720   */
22721  forEachFeatureIntersectingExtent(t, i) {
22722    return this.forEachFeatureInExtent(
22723      t,
22724      /**
22725       * @param {import("../Feature.js").default<Geometry>} feature Feature.
22726       * @return {T|undefined} The return value from the last call to the callback.
22727       */
22728      function(n) {
22729        if (n.getGeometry().intersectsExtent(t)) {
22730          const r = i(n);
22731          if (r)
22732            return r;
22733        }
22734      }
22735    );
22736  }
22737  /**
22738   * Get the features collection associated with this source. Will be `null`
22739   * unless the source was configured with `useSpatialIndex` set to `false`, or
22740   * with an {@link module:ol/Collection~Collection} as `features`.
22741   * @return {Collection<import("../Feature.js").default<Geometry>>|null} The collection of features.
22742   * @api
22743   */
22744  getFeaturesCollection() {
22745    return this.featuresCollection_;
22746  }
22747  /**
22748   * Get a snapshot of the features currently on the source in random order. The returned array
22749   * is a copy, the features are references to the features in the source.
22750   * @return {Array<import("../Feature.js").default<Geometry>>} Features.
22751   * @api
22752   */
22753  getFeatures() {
22754    let t;
22755    return this.featuresCollection_ ? t = this.featuresCollection_.getArray().slice(0) : this.featuresRtree_ && (t = this.featuresRtree_.getAll(), bs(this.nullGeometryFeatures_) || ci(t, Object.values(this.nullGeometryFeatures_))), /** @type {Array<import("../Feature.js").default<Geometry>>} */
22756    t;
22757  }
22758  /**
22759   * Get all features whose geometry intersects the provided coordinate.
22760   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
22761   * @return {Array<import("../Feature.js").default<Geometry>>} Features.
22762   * @api
22763   */
22764  getFeaturesAtCoordinate(t) {
22765    const i = [];
22766    return this.forEachFeatureAtCoordinateDirect(t, function(n) {
22767      i.push(n);
22768    }), i;
22769  }
22770  /**
22771   * Get all features whose bounding box intersects the provided extent.  Note that this returns an array of
22772   * all features intersecting the given extent in random order (so it may include
22773   * features whose geometries do not intersect the extent).
22774   *
22775   * When `useSpatialIndex` is set to false, this method will return all
22776   * features.
22777   *
22778   * @param {import("../extent.js").Extent} extent Extent.
22779   * @param {import("../proj/Projection.js").default} [projection] Include features
22780   * where `extent` exceeds the x-axis bounds of `projection` and wraps around the world.
22781   * @return {Array<import("../Feature.js").default<Geometry>>} Features.
22782   * @api
22783   */
22784  getFeaturesInExtent(t, i) {
22785    if (this.featuresRtree_) {
22786      if (!(i && i.canWrapX() && this.getWrapX()))
22787        return this.featuresRtree_.getInExtent(t);
22788      const s = Ix(t, i);
22789      return [].concat(
22790        ...s.map((r) => this.featuresRtree_.getInExtent(r))
22791      );
22792    }
22793    return this.featuresCollection_ ? this.featuresCollection_.getArray().slice(0) : [];
22794  }
22795  /**
22796   * Get the closest feature to the provided coordinate.
22797   *
22798   * This method is not available when the source is configured with
22799   * `useSpatialIndex` set to `false`.
22800   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
22801   * @param {function(import("../Feature.js").default<Geometry>):boolean} [filter] Feature filter function.
22802   *     The filter function will receive one argument, the {@link module:ol/Feature~Feature feature}
22803   *     and it should return a boolean value. By default, no filtering is made.
22804   * @return {import("../Feature.js").default<Geometry>} Closest feature.
22805   * @api
22806   */
22807  getClosestFeatureToCoordinate(t, i) {
22808    const n = t[0], s = t[1];
22809    let r = null;
22810    const o = [NaN, NaN];
22811    let a = 1 / 0;
22812    const l = [-1 / 0, -1 / 0, 1 / 0, 1 / 0];
22813    return i = i || An, this.featuresRtree_.forEachInExtent(
22814      l,
22815      /**
22816       * @param {import("../Feature.js").default<Geometry>} feature Feature.
22817       */
22818      function(h) {
22819        if (i(h)) {
22820          const c = h.getGeometry(), u = a;
22821          if (a = c.closestPointXY(
22822            n,
22823            s,
22824            o,
22825            a
22826          ), a < u) {
22827            r = h;
22828            const d = Math.sqrt(a);
22829            l[0] = n - d, l[1] = s - d, l[2] = n + d, l[3] = s + d;
22830          }
22831        }
22832      }
22833    ), r;
22834  }
22835  /**
22836   * Get the extent of the features currently in the source.
22837   *
22838   * This method is not available when the source is configured with
22839   * `useSpatialIndex` set to `false`.
22840   * @param {import("../extent.js").Extent} [extent] Destination extent. If provided, no new extent
22841   *     will be created. Instead, that extent's coordinates will be overwritten.
22842   * @return {import("../extent.js").Extent} Extent.
22843   * @api
22844   */
22845  getExtent(t) {
22846    return this.featuresRtree_.getExtent(t);
22847  }
22848  /**
22849   * Get a feature by its identifier (the value returned by feature.getId()).
22850   * Note that the index treats string and numeric identifiers as the same.  So
22851   * `source.getFeatureById(2)` will return a feature with id `'2'` or `2`.
22852   *
22853   * @param {string|number} id Feature identifier.
22854   * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
22855   * @api
22856   */
22857  getFeatureById(t) {
22858    const i = this.idIndex_[t.toString()];
22859    return i !== void 0 ? i : null;
22860  }
22861  /**
22862   * Get a feature by its internal unique identifier (using `getUid`).
22863   *
22864   * @param {string} uid Feature identifier.
22865   * @return {import("../Feature.js").default<Geometry>|null} The feature (or `null` if not found).
22866   */
22867  getFeatureByUid(t) {
22868    const i = this.uidIndex_[t];
22869    return i !== void 0 ? i : null;
22870  }
22871  /**
22872   * Get the format associated with this source.
22873   *
22874   * @return {import("../format/Feature.js").default|undefined} The feature format.
22875   * @api
22876   */
22877  getFormat() {
22878    return this.format_;
22879  }
22880  /**
22881   * @return {boolean} The source can have overlapping geometries.
22882   */
22883  getOverlaps() {
22884    return this.overlaps_;
22885  }
22886  /**
22887   * Get the url associated with this source.
22888   *
22889   * @return {string|import("../featureloader.js").FeatureUrlFunction|undefined} The url.
22890   * @api
22891   */
22892  getUrl() {
22893    return this.url_;
22894  }
22895  /**
22896   * @param {Event} event Event.
22897   * @private
22898   */
22899  handleFeatureChange_(t) {
22900    const i = (
22901      /** @type {import("../Feature.js").default<Geometry>} */
22902      t.target
22903    ), n = lt(i), s = i.getGeometry();
22904    if (!s)
22905      n in this.nullGeometryFeatures_ || (this.featuresRtree_ && this.featuresRtree_.remove(i), this.nullGeometryFeatures_[n] = i);
22906    else {
22907      const o = s.getExtent();
22908      n in this.nullGeometryFeatures_ ? (delete this.nullGeometryFeatures_[n], this.featuresRtree_ && this.featuresRtree_.insert(o, i)) : this.featuresRtree_ && this.featuresRtree_.update(o, i);
22909    }
22910    const r = i.getId();
22911    if (r !== void 0) {
22912      const o = r.toString();
22913      this.idIndex_[o] !== i && (this.removeFromIdIndex_(i), this.idIndex_[o] = i);
22914    } else
22915      this.removeFromIdIndex_(i), this.uidIndex_[n] = i;
22916    this.changed(), this.dispatchEvent(
22917      new ki(de.CHANGEFEATURE, i)
22918    );
22919  }
22920  /**
22921   * Returns true if the feature is contained within the source.
22922   * @param {import("../Feature.js").default<Geometry>} feature Feature.
22923   * @return {boolean} Has feature.
22924   * @api
22925   */
22926  hasFeature(t) {
22927    const i = t.getId();
22928    return i !== void 0 ? i in this.idIndex_ : lt(t) in this.uidIndex_;
22929  }
22930  /**
22931   * @return {boolean} Is empty.
22932   */
22933  isEmpty() {
22934    return this.featuresRtree_ ? this.featuresRtree_.isEmpty() && bs(this.nullGeometryFeatures_) : this.featuresCollection_ ? this.featuresCollection_.getLength() === 0 : !0;
22935  }
22936  /**
22937   * @param {import("../extent.js").Extent} extent Extent.
22938   * @param {number} resolution Resolution.
22939   * @param {import("../proj/Projection.js").default} projection Projection.
22940   */
22941  loadFeatures(t, i, n) {
22942    const s = this.loadedExtentsRtree_, r = this.strategy_(t, i, n);
22943    for (let o = 0, a = r.length; o < a; ++o) {
22944      const l = r[o];
22945      s.forEachInExtent(
22946        l,
22947        /**
22948         * @param {{extent: import("../extent.js").Extent}} object Object.
22949         * @return {boolean} Contains.
22950         */
22951        function(c) {
22952          return Bi(c.extent, l);
22953        }
22954      ) || (++this.loadingExtentsCount_, this.dispatchEvent(
22955        new ki(de.FEATURESLOADSTART)
22956      ), this.loader_.call(
22957        this,
22958        l,
22959        i,
22960        n,
22961        (c) => {
22962          --this.loadingExtentsCount_, this.dispatchEvent(
22963            new ki(
22964              de.FEATURESLOADEND,
22965              void 0,
22966              c
22967            )
22968          );
22969        },
22970        () => {
22971          --this.loadingExtentsCount_, this.dispatchEvent(
22972            new ki(de.FEATURESLOADERROR)
22973          );
22974        }
22975      ), s.insert(l, { extent: l.slice() }));
22976    }
22977    this.loading = this.loader_.length < 4 ? !1 : this.loadingExtentsCount_ > 0;
22978  }
22979  refresh() {
22980    this.clear(!0), this.loadedExtentsRtree_.clear(), super.refresh();
22981  }
22982  /**
22983   * Remove an extent from the list of loaded extents.
22984   * @param {import("../extent.js").Extent} extent Extent.
22985   * @api
22986   */
22987  removeLoadedExtent(t) {
22988    const i = this.loadedExtentsRtree_;
22989    let n;
22990    i.forEachInExtent(t, function(s) {
22991      if (Ss(s.extent, t))
22992        return n = s, !0;
22993    }), n && i.remove(n);
22994  }
22995  /**
22996   * Remove a single feature from the source.  If you want to remove all features
22997   * at once, use the {@link module:ol/source/Vector~VectorSource#clear #clear()} method
22998   * instead.
22999   * @param {import("../Feature.js").default<Geometry>} feature Feature to remove.
23000   * @api
23001   */
23002  removeFeature(t) {
23003    if (!t)
23004      return;
23005    const i = lt(t);
23006    i in this.nullGeometryFeatures_ ? delete this.nullGeometryFeatures_[i] : this.featuresRtree_ && this.featuresRtree_.remove(t), this.removeFeatureInternal(t) && this.changed();
23007  }
23008  /**
23009   * Remove feature without firing a `change` event.
23010   * @param {import("../Feature.js").default<Geometry>} feature Feature.
23011   * @return {import("../Feature.js").default<Geometry>|undefined} The removed feature
23012   *     (or undefined if the feature was not found).
23013   * @protected
23014   */
23015  removeFeatureInternal(t) {
23016    const i = lt(t), n = this.featureChangeKeys_[i];
23017    if (!n)
23018      return;
23019    n.forEach(St), delete this.featureChangeKeys_[i];
23020    const s = t.getId();
23021    return s !== void 0 && delete this.idIndex_[s.toString()], delete this.uidIndex_[i], this.dispatchEvent(
23022      new ki(de.REMOVEFEATURE, t)
23023    ), t;
23024  }
23025  /**
23026   * Remove a feature from the id index.  Called internally when the feature id
23027   * may have changed.
23028   * @param {import("../Feature.js").default<Geometry>} feature The feature.
23029   * @return {boolean} Removed the feature from the index.
23030   * @private
23031   */
23032  removeFromIdIndex_(t) {
23033    let i = !1;
23034    for (const n in this.idIndex_)
23035      if (this.idIndex_[n] === t) {
23036        delete this.idIndex_[n], i = !0;
23037        break;
23038      }
23039    return i;
23040  }
23041  /**
23042   * Set the new loader of the source. The next render cycle will use the
23043   * new loader.
23044   * @param {import("../featureloader.js").FeatureLoader} loader The loader to set.
23045   * @api
23046   */
23047  setLoader(t) {
23048    this.loader_ = t;
23049  }
23050  /**
23051   * Points the source to a new url. The next render cycle will use the new url.
23052   * @param {string|import("../featureloader.js").FeatureUrlFunction} url Url.
23053   * @api
23054   */
23055  setUrl(t) {
23056    ht(this.format_, 7), this.url_ = t, this.setLoader(cd(t, this.format_));
23057  }
23058}
23059const ys = fw;
23060class gw extends zr {
23061  /**
23062   * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
23063   * @param {import("./TileState.js").default} state State.
23064   * @param {Options} [options] Tile options.
23065   */
23066  constructor(t, i, n) {
23067    super(), n = n || {}, this.tileCoord = t, this.state = i, this.interimTile = null, this.key = "", this.transition_ = n.transition === void 0 ? 250 : n.transition, this.transitionStarts_ = {}, this.interpolate = !!n.interpolate;
23068  }
23069  /**
23070   * @protected
23071   */
23072  changed() {
23073    this.dispatchEvent(et.CHANGE);
23074  }
23075  /**
23076   * Called by the tile cache when the tile is removed from the cache due to expiry
23077   */
23078  release() {
23079    this.state === J.ERROR && this.setState(J.EMPTY);
23080  }
23081  /**
23082   * @return {string} Key.
23083   */
23084  getKey() {
23085    return this.key + "/" + this.tileCoord;
23086  }
23087  /**
23088   * Get the interim tile most suitable for rendering using the chain of interim
23089   * tiles. This corresponds to the  most recent tile that has been loaded, if no
23090   * such tile exists, the original tile is returned.
23091   * @return {!Tile} Best tile for rendering.
23092   */
23093  getInterimTile() {
23094    if (!this.interimTile)
23095      return this;
23096    let t = this.interimTile;
23097    do {
23098      if (t.getState() == J.LOADED)
23099        return this.transition_ = 0, t;
23100      t = t.interimTile;
23101    } while (t);
23102    return this;
23103  }
23104  /**
23105   * Goes through the chain of interim tiles and discards sections of the chain
23106   * that are no longer relevant.
23107   */
23108  refreshInterimChain() {
23109    if (!this.interimTile)
23110      return;
23111    let t = this.interimTile, i = this;
23112    do {
23113      if (t.getState() == J.LOADED) {
23114        t.interimTile = null;
23115        break;
23116      } else
23117        t.getState() == J.LOADING ? i = t : t.getState() == J.IDLE ? i.interimTile = t.interimTile : i = t;
23118      t = i.interimTile;
23119    } while (t);
23120  }
23121  /**
23122   * Get the tile coordinate for this tile.
23123   * @return {import("./tilecoord.js").TileCoord} The tile coordinate.
23124   * @api
23125   */
23126  getTileCoord() {
23127    return this.tileCoord;
23128  }
23129  /**
23130   * @return {import("./TileState.js").default} State.
23131   */
23132  getState() {
23133    return this.state;
23134  }
23135  /**
23136   * Sets the state of this tile. If you write your own {@link module:ol/Tile~LoadFunction tileLoadFunction} ,
23137   * it is important to set the state correctly to {@link module:ol/TileState~ERROR}
23138   * when the tile cannot be loaded. Otherwise the tile cannot be removed from
23139   * the tile queue and will block other requests.
23140   * @param {import("./TileState.js").default} state State.
23141   * @api
23142   */
23143  setState(t) {
23144    if (this.state !== J.ERROR && this.state > t)
23145      throw new Error("Tile load sequence violation");
23146    this.state = t, this.changed();
23147  }
23148  /**
23149   * Load the image or retry if loading previously failed.
23150   * Loading is taken care of by the tile queue, and calling this method is
23151   * only needed for preloading or for reloading in case of an error.
23152   * @abstract
23153   * @api
23154   */
23155  load() {
23156    Q();
23157  }
23158  /**
23159   * Get the alpha value for rendering.
23160   * @param {string} id An id for the renderer.
23161   * @param {number} time The render frame time.
23162   * @return {number} A number between 0 and 1.
23163   */
23164  getAlpha(t, i) {
23165    if (!this.transition_)
23166      return 1;
23167    let n = this.transitionStarts_[t];
23168    if (!n)
23169      n = i, this.transitionStarts_[t] = n;
23170    else if (n === -1)
23171      return 1;
23172    const s = i - n + 1e3 / 60;
23173    return s >= this.transition_ ? 1 : gg(s / this.transition_);
23174  }
23175  /**
23176   * Determine if a tile is in an alpha transition.  A tile is considered in
23177   * transition if tile.getAlpha() has not yet been called or has been called
23178   * and returned 1.
23179   * @param {string} id An id for the renderer.
23180   * @return {boolean} The tile is in transition.
23181   */
23182  inTransition(t) {
23183    return this.transition_ ? this.transitionStarts_[t] !== -1 : !1;
23184  }
23185  /**
23186   * Mark a transition as complete.
23187   * @param {string} id An id for the renderer.
23188   */
23189  endTransition(t) {
23190    this.transition_ && (this.transitionStarts_[t] = -1);
23191  }
23192}
23193const Zg = gw;
23194class mw extends Zg {
23195  /**
23196   * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
23197   * @param {import("./TileState.js").default} state State.
23198   * @param {string} src Image source URI.
23199   * @param {?string} crossOrigin Cross origin.
23200   * @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
23201   * @param {import("./Tile.js").Options} [options] Tile options.
23202   */
23203  constructor(t, i, n, s, r, o) {
23204    super(t, i, o), this.crossOrigin_ = s, this.src_ = n, this.key = n, this.image_ = new Image(), s !== null && (this.image_.crossOrigin = s), this.unlisten_ = null, this.tileLoadFunction_ = r;
23205  }
23206  /**
23207   * Get the HTML image element for this tile (may be a Canvas, Image, or Video).
23208   * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
23209   * @api
23210   */
23211  getImage() {
23212    return this.image_;
23213  }
23214  /**
23215   * Sets an HTML image element for this tile (may be a Canvas or preloaded Image).
23216   * @param {HTMLCanvasElement|HTMLImageElement} element Element.
23217   */
23218  setImage(t) {
23219    this.image_ = t, this.state = J.LOADED, this.unlistenImage_(), this.changed();
23220  }
23221  /**
23222   * Tracks loading or read errors.
23223   *
23224   * @private
23225   */
23226  handleImageError_() {
23227    this.state = J.ERROR, this.unlistenImage_(), this.image_ = _w(), this.changed();
23228  }
23229  /**
23230   * Tracks successful image load.
23231   *
23232   * @private
23233   */
23234  handleImageLoad_() {
23235    const t = (
23236      /** @type {HTMLImageElement} */
23237      this.image_
23238    );
23239    t.naturalWidth && t.naturalHeight ? this.state = J.LOADED : this.state = J.EMPTY, this.unlistenImage_(), this.changed();
23240  }
23241  /**
23242   * Load the image or retry if loading previously failed.
23243   * Loading is taken care of by the tile queue, and calling this method is
23244   * only needed for preloading or for reloading in case of an error.
23245   *
23246   * To retry loading tiles on failed requests, use a custom `tileLoadFunction`
23247   * that checks for error status codes and reloads only when the status code is
23248   * 408, 429, 500, 502, 503 and 504, and only when not too many retries have been
23249   * made already:
23250   *
23251   * ```js
23252   * const retryCodes = [408, 429, 500, 502, 503, 504];
23253   * const retries = {};
23254   * source.setTileLoadFunction((tile, src) => {
23255   *   const image = tile.getImage();
23256   *   fetch(src)
23257   *     .then((response) => {
23258   *       if (retryCodes.includes(response.status)) {
23259   *         retries[src] = (retries[src] || 0) + 1;
23260   *         if (retries[src] <= 3) {
23261   *           setTimeout(() => tile.load(), retries[src] * 1000);
23262   *         }
23263   *         return Promise.reject();
23264   *       }
23265   *       return response.blob();
23266   *     })
23267   *     .then((blob) => {
23268   *       const imageUrl = URL.createObjectURL(blob);
23269   *       image.src = imageUrl;
23270   *       setTimeout(() => URL.revokeObjectURL(imageUrl), 5000);
23271   *     })
23272   *     .catch(() => tile.setState(3)); // error
23273   * });
23274   * ```
23275   *
23276   * @api
23277   */
23278  load() {
23279    this.state == J.ERROR && (this.state = J.IDLE, this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_)), this.state == J.IDLE && (this.state = J.LOADING, this.changed(), this.tileLoadFunction_(this, this.src_), this.unlisten_ = lc(
23280      this.image_,
23281      this.handleImageLoad_.bind(this),
23282      this.handleImageError_.bind(this)
23283    ));
23284  }
23285  /**
23286   * Discards event handlers which listen for load completion or errors.
23287   *
23288   * @private
23289   */
23290  unlistenImage_() {
23291    this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
23292  }
23293}
23294function _w() {
23295  const e = he(1, 1);
23296  return e.fillStyle = "rgba(0,0,0,0)", e.fillRect(0, 0, 1, 1), e.canvas;
23297}
23298const Jg = mw;
23299class pw {
23300  /**
23301   * @param {number} [highWaterMark] High water mark.
23302   */
23303  constructor(t) {
23304    this.highWaterMark = t !== void 0 ? t : 2048, this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null;
23305  }
23306  /**
23307   * @return {boolean} Can expire cache.
23308   */
23309  canExpireCache() {
23310    return this.highWaterMark > 0 && this.getCount() > this.highWaterMark;
23311  }
23312  /**
23313   * Expire the cache.
23314   * @param {!Object<string, boolean>} [keep] Keys to keep. To be implemented by subclasses.
23315   */
23316  expireCache(t) {
23317    for (; this.canExpireCache(); )
23318      this.pop();
23319  }
23320  /**
23321   * FIXME empty description for jsdoc
23322   */
23323  clear() {
23324    this.count_ = 0, this.entries_ = {}, this.oldest_ = null, this.newest_ = null;
23325  }
23326  /**
23327   * @param {string} key Key.
23328   * @return {boolean} Contains key.
23329   */
23330  containsKey(t) {
23331    return this.entries_.hasOwnProperty(t);
23332  }
23333  /**
23334   * @param {function(T, string, LRUCache<T>): ?} f The function
23335   *     to call for every entry from the oldest to the newer. This function takes
23336   *     3 arguments (the entry value, the entry key and the LRUCache object).
23337   *     The return value is ignored.
23338   */
23339  forEach(t) {
23340    let i = this.oldest_;
23341    for (; i; )
23342      t(i.value_, i.key_, this), i = i.newer;
23343  }
23344  /**
23345   * @param {string} key Key.
23346   * @param {*} [options] Options (reserved for subclasses).
23347   * @return {T} Value.
23348   */
23349  get(t, i) {
23350    const n = this.entries_[t];
23351    return ht(n !== void 0, 15), n === this.newest_ || (n === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
23352    this.oldest_.newer, this.oldest_.older = null) : (n.newer.older = n.older, n.older.newer = n.newer), n.newer = null, n.older = this.newest_, this.newest_.newer = n, this.newest_ = n), n.value_;
23353  }
23354  /**
23355   * Remove an entry from the cache.
23356   * @param {string} key The entry key.
23357   * @return {T} The removed entry.
23358   */
23359  remove(t) {
23360    const i = this.entries_[t];
23361    return ht(i !== void 0, 15), i === this.newest_ ? (this.newest_ = /** @type {Entry} */
23362    i.older, this.newest_ && (this.newest_.newer = null)) : i === this.oldest_ ? (this.oldest_ = /** @type {Entry} */
23363    i.newer, this.oldest_ && (this.oldest_.older = null)) : (i.newer.older = i.older, i.older.newer = i.newer), delete this.entries_[t], --this.count_, i.value_;
23364  }
23365  /**
23366   * @return {number} Count.
23367   */
23368  getCount() {
23369    return this.count_;
23370  }
23371  /**
23372   * @return {Array<string>} Keys.
23373   */
23374  getKeys() {
23375    const t = new Array(this.count_);
23376    let i = 0, n;
23377    for (n = this.newest_; n; n = n.older)
23378      t[i++] = n.key_;
23379    return t;
23380  }
23381  /**
23382   * @return {Array<T>} Values.
23383   */
23384  getValues() {
23385    const t = new Array(this.count_);
23386    let i = 0, n;
23387    for (n = this.newest_; n; n = n.older)
23388      t[i++] = n.value_;
23389    return t;
23390  }
23391  /**
23392   * @return {T} Last value.
23393   */
23394  peekLast() {
23395    return this.oldest_.value_;
23396  }
23397  /**
23398   * @return {string} Last key.
23399   */
23400  peekLastKey() {
23401    return this.oldest_.key_;
23402  }
23403  /**
23404   * Get the key of the newest item in the cache.  Throws if the cache is empty.
23405   * @return {string} The newest key.
23406   */
23407  peekFirstKey() {
23408    return this.newest_.key_;
23409  }
23410  /**
23411   * Return an entry without updating least recently used time.
23412   * @param {string} key Key.
23413   * @return {T} Value.
23414   */
23415  peek(t) {
23416    if (this.containsKey(t))
23417      return this.entries_[t].value_;
23418  }
23419  /**
23420   * @return {T} value Value.
23421   */
23422  pop() {
23423    const t = this.oldest_;
23424    return delete this.entries_[t.key_], t.newer && (t.newer.older = null), this.oldest_ = /** @type {Entry} */
23425    t.newer, this.oldest_ || (this.newest_ = null), --this.count_, t.value_;
23426  }
23427  /**
23428   * @param {string} key Key.
23429   * @param {T} value Value.
23430   */
23431  replace(t, i) {
23432    this.get(t), this.entries_[t].value_ = i;
23433  }
23434  /**
23435   * @param {string} key Key.
23436   * @param {T} value Value.
23437   */
23438  set(t, i) {
23439    ht(!(t in this.entries_), 16);
23440    const n = {
23441      key_: t,
23442      newer: null,
23443      older: this.newest_,
23444      value_: i
23445    };
23446    this.newest_ ? this.newest_.newer = n : this.oldest_ = n, this.newest_ = n, this.entries_[t] = n, ++this.count_;
23447  }
23448  /**
23449   * Set a maximum number of entries for the cache.
23450   * @param {number} size Cache size.
23451   * @api
23452   */
23453  setSize(t) {
23454    this.highWaterMark = t;
23455  }
23456}
23457const yw = pw;
23458function ud(e, t, i, n) {
23459  return n !== void 0 ? (n[0] = e, n[1] = t, n[2] = i, n) : [e, t, i];
23460}
23461function Ia(e, t, i) {
23462  return e + "/" + t + "/" + i;
23463}
23464function Qg(e) {
23465  return Ia(e[0], e[1], e[2]);
23466}
23467function xw(e) {
23468  return e.split("/").map(Number);
23469}
23470function tm(e) {
23471  return (e[1] << e[0]) + e[2];
23472}
23473function vw(e, t) {
23474  const i = e[0], n = e[1], s = e[2];
23475  if (t.getMinZoom() > i || i > t.getMaxZoom())
23476    return !1;
23477  const r = t.getFullTileRange(i);
23478  return r ? r.containsXY(n, s) : !0;
23479}
23480class Ew extends yw {
23481  clear() {
23482    for (; this.getCount() > 0; )
23483      this.pop().release();
23484    super.clear();
23485  }
23486  /**
23487   * @param {!Object<string, boolean>} usedTiles Used tiles.
23488   */
23489  expireCache(t) {
23490    for (; this.canExpireCache() && !(this.peekLast().getKey() in t); )
23491      this.pop().release();
23492  }
23493  /**
23494   * Prune all tiles from the cache that don't have the same z as the newest tile.
23495   */
23496  pruneExceptNewestZ() {
23497    if (this.getCount() === 0)
23498      return;
23499    const t = this.peekFirstKey(), n = xw(t)[0];
23500    this.forEach((s) => {
23501      s.tileCoord[0] !== n && (this.remove(Qg(s.tileCoord)), s.release());
23502    });
23503  }
23504}
23505const em = Ew;
23506class im {
23507  /**
23508   * @param {number} minX Minimum X.
23509   * @param {number} maxX Maximum X.
23510   * @param {number} minY Minimum Y.
23511   * @param {number} maxY Maximum Y.
23512   */
23513  constructor(t, i, n, s) {
23514    this.minX = t, this.maxX = i, this.minY = n, this.maxY = s;
23515  }
23516  /**
23517   * @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
23518   * @return {boolean} Contains tile coordinate.
23519   */
23520  contains(t) {
23521    return this.containsXY(t[1], t[2]);
23522  }
23523  /**
23524   * @param {TileRange} tileRange Tile range.
23525   * @return {boolean} Contains.
23526   */
23527  containsTileRange(t) {
23528    return this.minX <= t.minX && t.maxX <= this.maxX && this.minY <= t.minY && t.maxY <= this.maxY;
23529  }
23530  /**
23531   * @param {number} x Tile coordinate x.
23532   * @param {number} y Tile coordinate y.
23533   * @return {boolean} Contains coordinate.
23534   */
23535  containsXY(t, i) {
23536    return this.minX <= t && t <= this.maxX && this.minY <= i && i <= this.maxY;
23537  }
23538  /**
23539   * @param {TileRange} tileRange Tile range.
23540   * @return {boolean} Equals.
23541   */
23542  equals(t) {
23543    return this.minX == t.minX && this.minY == t.minY && this.maxX == t.maxX && this.maxY == t.maxY;
23544  }
23545  /**
23546   * @param {TileRange} tileRange Tile range.
23547   */
23548  extend(t) {
23549    t.minX < this.minX && (this.minX = t.minX), t.maxX > this.maxX && (this.maxX = t.maxX), t.minY < this.minY && (this.minY = t.minY), t.maxY > this.maxY && (this.maxY = t.maxY);
23550  }
23551  /**
23552   * @return {number} Height.
23553   */
23554  getHeight() {
23555    return this.maxY - this.minY + 1;
23556  }
23557  /**
23558   * @return {import("./size.js").Size} Size.
23559   */
23560  getSize() {
23561    return [this.getWidth(), this.getHeight()];
23562  }
23563  /**
23564   * @return {number} Width.
23565   */
23566  getWidth() {
23567    return this.maxX - this.minX + 1;
23568  }
23569  /**
23570   * @param {TileRange} tileRange Tile range.
23571   * @return {boolean} Intersects.
23572   */
23573  intersects(t) {
23574    return this.minX <= t.maxX && this.maxX >= t.minX && this.minY <= t.maxY && this.maxY >= t.minY;
23575  }
23576}
23577function Yn(e, t, i, n, s) {
23578  return s !== void 0 ? (s.minX = e, s.maxX = t, s.minY = i, s.maxY = n, s) : new im(e, t, i, n);
23579}
23580const nm = im, dd = 0, hr = 1, fd = [0, 0, 0, 0], xs = [], tl = {
23581  /**
23582   * Triggered upon feature modification start
23583   * @event ModifyEvent#modifystart
23584   * @api
23585   */
23586  MODIFYSTART: "modifystart",
23587  /**
23588   * Triggered upon feature modification end
23589   * @event ModifyEvent#modifyend
23590   * @api
23591   */
23592  MODIFYEND: "modifyend"
23593};
23594class el extends Le {
23595  /**
23596   * @param {ModifyEventType} type Type.
23597   * @param {Collection<Feature>} features
23598   * The features modified.
23599   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent
23600   * Associated {@link module:ol/MapBrowserEvent~MapBrowserEvent}.
23601   */
23602  constructor(t, i, n) {
23603    super(t), this.features = i, this.mapBrowserEvent = n;
23604  }
23605}
23606class Cw extends ln {
23607  /**
23608   * @param {Options} options Options.
23609   */
23610  constructor(t) {
23611    super(
23612      /** @type {import("./Pointer.js").Options} */
23613      t
23614    ), this.on, this.once, this.un, this.boundHandleFeatureChange_ = this.handleFeatureChange_.bind(this), this.condition_ = t.condition ? t.condition : kg, this.defaultDeleteCondition_ = function(n) {
23615      return pM(n) && EM(n);
23616    }, this.deleteCondition_ = t.deleteCondition ? t.deleteCondition : this.defaultDeleteCondition_, this.insertVertexCondition_ = t.insertVertexCondition ? t.insertVertexCondition : qo, this.vertexFeature_ = null, this.vertexSegments_ = null, this.lastPixel_ = [0, 0], this.ignoreNextSingleClick_ = !1, this.featuresBeingModified_ = null, this.rBush_ = new Zo(), this.pixelTolerance_ = t.pixelTolerance !== void 0 ? t.pixelTolerance : 10, this.snappedToVertex_ = !1, this.changingFeature_ = !1, this.dragSegments_ = [], this.overlay_ = new ps({
23617      source: new ys({
23618        useSpatialIndex: !1,
23619        wrapX: !!t.wrapX
23620      }),
23621      style: t.style ? t.style : bw(),
23622      updateWhileAnimating: !0,
23623      updateWhileInteracting: !0
23624    }), this.SEGMENT_WRITERS_ = {
23625      Point: this.writePointGeometry_.bind(this),
23626      LineString: this.writeLineStringGeometry_.bind(this),
23627      LinearRing: this.writeLineStringGeometry_.bind(this),
23628      Polygon: this.writePolygonGeometry_.bind(this),
23629      MultiPoint: this.writeMultiPointGeometry_.bind(this),
23630      MultiLineString: this.writeMultiLineStringGeometry_.bind(this),
23631      MultiPolygon: this.writeMultiPolygonGeometry_.bind(this),
23632      Circle: this.writeCircleGeometry_.bind(this),
23633      GeometryCollection: this.writeGeometryCollectionGeometry_.bind(this)
23634    }, this.source_ = null, this.hitDetection_ = null;
23635    let i;
23636    if (t.features ? i = t.features : t.source && (this.source_ = t.source, i = new De(this.source_.getFeatures()), this.source_.addEventListener(
23637      de.ADDFEATURE,
23638      this.handleSourceAdd_.bind(this)
23639    ), this.source_.addEventListener(
23640      de.REMOVEFEATURE,
23641      this.handleSourceRemove_.bind(this)
23642    )), !i)
23643      throw new Error(
23644        "The modify interaction requires features, a source or a layer"
23645      );
23646    t.hitDetection && (this.hitDetection_ = t.hitDetection), this.features_ = i, this.features_.forEach(this.addFeature_.bind(this)), this.features_.addEventListener(
23647      Vt.ADD,
23648      this.handleFeatureAdd_.bind(this)
23649    ), this.features_.addEventListener(
23650      Vt.REMOVE,
23651      this.handleFeatureRemove_.bind(this)
23652    ), this.lastPointerEvent_ = null, this.delta_ = [0, 0], this.snapToPointer_ = t.snapToPointer === void 0 ? !this.hitDetection_ : t.snapToPointer;
23653  }
23654  /**
23655   * @param {Feature} feature Feature.
23656   * @private
23657   */
23658  addFeature_(t) {
23659    const i = t.getGeometry();
23660    if (i) {
23661      const s = this.SEGMENT_WRITERS_[i.getType()];
23662      s && s(t, i);
23663    }
23664    const n = this.getMap();
23665    n && n.isRendered() && this.getActive() && this.handlePointerAtPixel_(this.lastPixel_, n), t.addEventListener(et.CHANGE, this.boundHandleFeatureChange_);
23666  }
23667  /**
23668   * @param {import("../MapBrowserEvent.js").default} evt Map browser event.
23669   * @param {Array<Array<SegmentData>>} segments The segments subject to modification.
23670   * @private
23671   */
23672  willModifyFeatures_(t, i) {
23673    if (!this.featuresBeingModified_) {
23674      this.featuresBeingModified_ = new De();
23675      const n = this.featuresBeingModified_.getArray();
23676      for (let s = 0, r = i.length; s < r; ++s) {
23677        const o = i[s];
23678        for (let a = 0, l = o.length; a < l; ++a) {
23679          const h = o[a].feature;
23680          h && !n.includes(h) && this.featuresBeingModified_.push(h);
23681        }
23682      }
23683      this.featuresBeingModified_.getLength() === 0 ? this.featuresBeingModified_ = null : this.dispatchEvent(
23684        new el(
23685          tl.MODIFYSTART,
23686          this.featuresBeingModified_,
23687          t
23688        )
23689      );
23690    }
23691  }
23692  /**
23693   * @param {Feature} feature Feature.
23694   * @private
23695   */
23696  removeFeature_(t) {
23697    this.removeFeatureSegmentData_(t), this.vertexFeature_ && this.features_.getLength() === 0 && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), t.removeEventListener(
23698      et.CHANGE,
23699      this.boundHandleFeatureChange_
23700    );
23701  }
23702  /**
23703   * @param {Feature} feature Feature.
23704   * @private
23705   */
23706  removeFeatureSegmentData_(t) {
23707    const i = this.rBush_, n = [];
23708    i.forEach(
23709      /**
23710       * @param {SegmentData} node RTree node.
23711       */
23712      function(s) {
23713        t === s.feature && n.push(s);
23714      }
23715    );
23716    for (let s = n.length - 1; s >= 0; --s) {
23717      const r = n[s];
23718      for (let o = this.dragSegments_.length - 1; o >= 0; --o)
23719        this.dragSegments_[o][0] === r && this.dragSegments_.splice(o, 1);
23720      i.remove(r);
23721    }
23722  }
23723  /**
23724   * Activate or deactivate the interaction.
23725   * @param {boolean} active Active.
23726   * @observable
23727   * @api
23728   */
23729  setActive(t) {
23730    this.vertexFeature_ && !t && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null), super.setActive(t);
23731  }
23732  /**
23733   * Remove the interaction from its current map and attach it to the new map.
23734   * Subclasses may set up event handlers to get notified about changes to
23735   * the map here.
23736   * @param {import("../Map.js").default} map Map.
23737   */
23738  setMap(t) {
23739    this.overlay_.setMap(t), super.setMap(t);
23740  }
23741  /**
23742   * Get the overlay layer that this interaction renders the modification point or vertex to.
23743   * @return {VectorLayer} Overlay layer.
23744   * @api
23745   */
23746  getOverlay() {
23747    return this.overlay_;
23748  }
23749  /**
23750   * @param {import("../source/Vector.js").VectorSourceEvent} event Event.
23751   * @private
23752   */
23753  handleSourceAdd_(t) {
23754    t.feature && this.features_.push(t.feature);
23755  }
23756  /**
23757   * @param {import("../source/Vector.js").VectorSourceEvent} event Event.
23758   * @private
23759   */
23760  handleSourceRemove_(t) {
23761    t.feature && this.features_.remove(t.feature);
23762  }
23763  /**
23764   * @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
23765   * @private
23766   */
23767  handleFeatureAdd_(t) {
23768    this.addFeature_(t.element);
23769  }
23770  /**
23771   * @param {import("../events/Event.js").default} evt Event.
23772   * @private
23773   */
23774  handleFeatureChange_(t) {
23775    if (!this.changingFeature_) {
23776      const i = (
23777        /** @type {Feature} */
23778        t.target
23779      );
23780      this.removeFeature_(i), this.addFeature_(i);
23781    }
23782  }
23783  /**
23784   * @param {import("../Collection.js").CollectionEvent<Feature>} evt Event.
23785   * @private
23786   */
23787  handleFeatureRemove_(t) {
23788    this.removeFeature_(t.element);
23789  }
23790  /**
23791   * @param {Feature} feature Feature
23792   * @param {Point} geometry Geometry.
23793   * @private
23794   */
23795  writePointGeometry_(t, i) {
23796    const n = i.getCoordinates(), s = {
23797      feature: t,
23798      geometry: i,
23799      segment: [n, n]
23800    };
23801    this.rBush_.insert(i.getExtent(), s);
23802  }
23803  /**
23804   * @param {Feature} feature Feature
23805   * @param {import("../geom/MultiPoint.js").default} geometry Geometry.
23806   * @private
23807   */
23808  writeMultiPointGeometry_(t, i) {
23809    const n = i.getCoordinates();
23810    for (let s = 0, r = n.length; s < r; ++s) {
23811      const o = n[s], a = {
23812        feature: t,
23813        geometry: i,
23814        depth: [s],
23815        index: s,
23816        segment: [o, o]
23817      };
23818      this.rBush_.insert(i.getExtent(), a);
23819    }
23820  }
23821  /**
23822   * @param {Feature} feature Feature
23823   * @param {import("../geom/LineString.js").default} geometry Geometry.
23824   * @private
23825   */
23826  writeLineStringGeometry_(t, i) {
23827    const n = i.getCoordinates();
23828    for (let s = 0, r = n.length - 1; s < r; ++s) {
23829      const o = n.slice(s, s + 2), a = {
23830        feature: t,
23831        geometry: i,
23832        index: s,
23833        segment: o
23834      };
23835      this.rBush_.insert(ge(o), a);
23836    }
23837  }
23838  /**
23839   * @param {Feature} feature Feature
23840   * @param {import("../geom/MultiLineString.js").default} geometry Geometry.
23841   * @private
23842   */
23843  writeMultiLineStringGeometry_(t, i) {
23844    const n = i.getCoordinates();
23845    for (let s = 0, r = n.length; s < r; ++s) {
23846      const o = n[s];
23847      for (let a = 0, l = o.length - 1; a < l; ++a) {
23848        const h = o.slice(a, a + 2), c = {
23849          feature: t,
23850          geometry: i,
23851          depth: [s],
23852          index: a,
23853          segment: h
23854        };
23855        this.rBush_.insert(ge(h), c);
23856      }
23857    }
23858  }
23859  /**
23860   * @param {Feature} feature Feature
23861   * @param {import("../geom/Polygon.js").default} geometry Geometry.
23862   * @private
23863   */
23864  writePolygonGeometry_(t, i) {
23865    const n = i.getCoordinates();
23866    for (let s = 0, r = n.length; s < r; ++s) {
23867      const o = n[s];
23868      for (let a = 0, l = o.length - 1; a < l; ++a) {
23869        const h = o.slice(a, a + 2), c = {
23870          feature: t,
23871          geometry: i,
23872          depth: [s],
23873          index: a,
23874          segment: h
23875        };
23876        this.rBush_.insert(ge(h), c);
23877      }
23878    }
23879  }
23880  /**
23881   * @param {Feature} feature Feature
23882   * @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
23883   * @private
23884   */
23885  writeMultiPolygonGeometry_(t, i) {
23886    const n = i.getCoordinates();
23887    for (let s = 0, r = n.length; s < r; ++s) {
23888      const o = n[s];
23889      for (let a = 0, l = o.length; a < l; ++a) {
23890        const h = o[a];
23891        for (let c = 0, u = h.length - 1; c < u; ++c) {
23892          const d = h.slice(c, c + 2), f = {
23893            feature: t,
23894            geometry: i,
23895            depth: [a, s],
23896            index: c,
23897            segment: d
23898          };
23899          this.rBush_.insert(ge(d), f);
23900        }
23901      }
23902    }
23903  }
23904  /**
23905   * We convert a circle into two segments.  The segment at index
23906   * {@link CIRCLE_CENTER_INDEX} is the
23907   * circle's center (a point).  The segment at index
23908   * {@link CIRCLE_CIRCUMFERENCE_INDEX} is
23909   * the circumference, and is not a line segment.
23910   *
23911   * @param {Feature} feature Feature.
23912   * @param {import("../geom/Circle.js").default} geometry Geometry.
23913   * @private
23914   */
23915  writeCircleGeometry_(t, i) {
23916    const n = i.getCenter(), s = {
23917      feature: t,
23918      geometry: i,
23919      index: dd,
23920      segment: [n, n]
23921    }, r = {
23922      feature: t,
23923      geometry: i,
23924      index: hr,
23925      segment: [n, n]
23926    }, o = [s, r];
23927    s.featureSegments = o, r.featureSegments = o, this.rBush_.insert(Mo(n), s);
23928    let a = (
23929      /** @type {import("../geom/Geometry.js").default} */
23930      i
23931    );
23932    this.rBush_.insert(a.getExtent(), r);
23933  }
23934  /**
23935   * @param {Feature} feature Feature
23936   * @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
23937   * @private
23938   */
23939  writeGeometryCollectionGeometry_(t, i) {
23940    const n = i.getGeometriesArray();
23941    for (let s = 0; s < n.length; ++s) {
23942      const r = n[s], o = this.SEGMENT_WRITERS_[r.getType()];
23943      o(t, r);
23944    }
23945  }
23946  /**
23947   * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
23948   * @param {Array<Feature>} features The features being modified.
23949   * @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
23950   * @return {Feature} Vertex feature.
23951   * @private
23952   */
23953  createOrUpdateVertexFeature_(t, i, n) {
23954    let s = this.vertexFeature_;
23955    return s ? s.getGeometry().setCoordinates(t) : (s = new ke(new Ne(t)), this.vertexFeature_ = s, this.overlay_.getSource().addFeature(s)), s.set("features", i), s.set("geometries", n), s;
23956  }
23957  /**
23958   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may modify the geometry.
23959   * @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
23960   * @return {boolean} `false` to stop event propagation.
23961   */
23962  handleEvent(t) {
23963    if (!t.originalEvent)
23964      return !0;
23965    this.lastPointerEvent_ = t;
23966    let i;
23967    return !t.map.getView().getInteracting() && t.type == mt.POINTERMOVE && !this.handlingDownUpSequence && this.handlePointerMove_(t), this.vertexFeature_ && this.deleteCondition_(t) && (t.type != mt.SINGLECLICK || !this.ignoreNextSingleClick_ ? i = this.removePoint() : i = !0), t.type == mt.SINGLECLICK && (this.ignoreNextSingleClick_ = !1), super.handleEvent(t) && !i;
23968  }
23969  /**
23970   * Handle pointer drag events.
23971   * @param {import("../MapBrowserEvent.js").default} evt Event.
23972   */
23973  handleDragEvent(t) {
23974    this.ignoreNextSingleClick_ = !1, this.willModifyFeatures_(t, this.dragSegments_);
23975    const i = [
23976      t.coordinate[0] + this.delta_[0],
23977      t.coordinate[1] + this.delta_[1]
23978    ], n = [], s = [];
23979    for (let r = 0, o = this.dragSegments_.length; r < o; ++r) {
23980      const a = this.dragSegments_[r], l = a[0], h = l.feature;
23981      n.includes(h) || n.push(h);
23982      const c = l.geometry;
23983      s.includes(c) || s.push(c);
23984      const u = l.depth;
23985      let d;
23986      const f = l.segment, g = a[1];
23987      for (; i.length < c.getStride(); )
23988        i.push(f[g][i.length]);
23989      switch (c.getType()) {
23990        case "Point":
23991          d = i, f[0] = i, f[1] = i;
23992          break;
23993        case "MultiPoint":
23994          d = c.getCoordinates(), d[l.index] = i, f[0] = i, f[1] = i;
23995          break;
23996        case "LineString":
23997          d = c.getCoordinates(), d[l.index + g] = i, f[g] = i;
23998          break;
23999        case "MultiLineString":
24000          d = c.getCoordinates(), d[u[0]][l.index + g] = i, f[g] = i;
24001          break;
24002        case "Polygon":
24003          d = c.getCoordinates(), d[u[0]][l.index + g] = i, f[g] = i;
24004          break;
24005        case "MultiPolygon":
24006          d = c.getCoordinates(), d[u[1]][u[0]][l.index + g] = i, f[g] = i;
24007          break;
24008        case "Circle":
24009          if (f[0] = i, f[1] = i, l.index === dd)
24010            this.changingFeature_ = !0, c.setCenter(i), this.changingFeature_ = !1;
24011          else {
24012            this.changingFeature_ = !0, t.map.getView().getProjection();
24013            let m = Oo(
24014              Lt(c.getCenter()),
24015              Lt(i)
24016            );
24017            c.setRadius(m), this.changingFeature_ = !1;
24018          }
24019          break;
24020      }
24021      d && this.setGeometryCoordinates_(c, d);
24022    }
24023    this.createOrUpdateVertexFeature_(i, n, s);
24024  }
24025  /**
24026   * Handle pointer down events.
24027   * @param {import("../MapBrowserEvent.js").default} evt Event.
24028   * @return {boolean} If the event was consumed.
24029   */
24030  handleDownEvent(t) {
24031    if (!this.condition_(t))
24032      return !1;
24033    const i = t.coordinate;
24034    this.handlePointerAtPixel_(t.pixel, t.map, i), this.dragSegments_.length = 0, this.featuresBeingModified_ = null;
24035    const n = this.vertexFeature_;
24036    if (n) {
24037      t.map.getView().getProjection();
24038      const s = [], r = n.getGeometry().getCoordinates(), o = ge([r]), a = this.rBush_.getInExtent(o), l = {};
24039      a.sort(Mw);
24040      for (let h = 0, c = a.length; h < c; ++h) {
24041        const u = a[h], d = u.segment;
24042        let f = lt(u.geometry);
24043        const g = u.depth;
24044        if (g && (f += "-" + g.join("-")), l[f] || (l[f] = new Array(2)), u.geometry.getType() === "Circle" && u.index === hr) {
24045          const m = md(
24046            i,
24047            u
24048          );
24049          je(m, r) && !l[f][0] && (this.dragSegments_.push([u, 0]), l[f][0] = u);
24050          continue;
24051        }
24052        if (je(d[0], r) && !l[f][0]) {
24053          this.dragSegments_.push([u, 0]), l[f][0] = u;
24054          continue;
24055        }
24056        if (je(d[1], r) && !l[f][1]) {
24057          if (l[f][0] && l[f][0].index === 0) {
24058            let m = u.geometry.getCoordinates();
24059            switch (u.geometry.getType()) {
24060              case "LineString":
24061              case "MultiLineString":
24062                continue;
24063              case "MultiPolygon":
24064                m = m[g[1]];
24065              case "Polygon":
24066                if (u.index !== m[g[0]].length - 2)
24067                  continue;
24068                break;
24069            }
24070          }
24071          this.dragSegments_.push([u, 1]), l[f][1] = u;
24072          continue;
24073        }
24074        lt(d) in this.vertexSegments_ && !l[f][0] && !l[f][1] && this.insertVertexCondition_(t) && s.push(u);
24075      }
24076      s.length && this.willModifyFeatures_(t, [s]);
24077      for (let h = s.length - 1; h >= 0; --h)
24078        this.insertVertex_(s[h], r);
24079    }
24080    return !!this.vertexFeature_;
24081  }
24082  /**
24083   * Handle pointer up events.
24084   * @param {import("../MapBrowserEvent.js").default} evt Event.
24085   * @return {boolean} If the event was consumed.
24086   */
24087  handleUpEvent(t) {
24088    for (let i = this.dragSegments_.length - 1; i >= 0; --i) {
24089      const n = this.dragSegments_[i][0], s = n.geometry;
24090      if (s.getType() === "Circle") {
24091        const r = s.getCenter(), o = n.featureSegments[0], a = n.featureSegments[1];
24092        o.segment[0] = r, o.segment[1] = r, a.segment[0] = r, a.segment[1] = r, this.rBush_.update(Mo(r), o);
24093        let l = s;
24094        this.rBush_.update(
24095          l.getExtent(),
24096          a
24097        );
24098      } else
24099        this.rBush_.update(ge(n.segment), n);
24100    }
24101    return this.featuresBeingModified_ && (this.dispatchEvent(
24102      new el(
24103        tl.MODIFYEND,
24104        this.featuresBeingModified_,
24105        t
24106      )
24107    ), this.featuresBeingModified_ = null), !1;
24108  }
24109  /**
24110   * @param {import("../MapBrowserEvent.js").default} evt Event.
24111   * @private
24112   */
24113  handlePointerMove_(t) {
24114    this.lastPixel_ = t.pixel, this.handlePointerAtPixel_(t.pixel, t.map, t.coordinate);
24115  }
24116  /**
24117   * @param {import("../pixel.js").Pixel} pixel Pixel
24118   * @param {import("../Map.js").default} map Map.
24119   * @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate.
24120   * @private
24121   */
24122  handlePointerAtPixel_(t, i, n) {
24123    const s = n || i.getCoordinateFromPixel(t);
24124    i.getView().getProjection();
24125    const r = function(l, h) {
24126      return gd(s, l) - gd(s, h);
24127    };
24128    let o, a;
24129    if (this.hitDetection_) {
24130      const l = typeof this.hitDetection_ == "object" ? (h) => h === this.hitDetection_ : void 0;
24131      i.forEachFeatureAtPixel(
24132        t,
24133        (h, c, u) => {
24134          u && (u = new Ne(
24135            Pn(u.getCoordinates())
24136          ));
24137          const d = u || h.getGeometry();
24138          if (d.getType() === "Point" && h instanceof ke && this.features_.getArray().includes(h)) {
24139            a = /** @type {Point} */
24140            d;
24141            const f = (
24142              /** @type {Point} */
24143              h.getGeometry().getFlatCoordinates().slice(0, 2)
24144            );
24145            o = [
24146              {
24147                feature: h,
24148                geometry: a,
24149                segment: [f, f]
24150              }
24151            ];
24152          }
24153          return !0;
24154        },
24155        { layerFilter: l }
24156      );
24157    }
24158    if (!o) {
24159      const l = ai(
24160        Mo(s, fd)
24161      ), h = i.getView().getResolution() * this.pixelTolerance_, c = la(
24162        Rn(l, h, fd)
24163      );
24164      o = this.rBush_.getInExtent(c);
24165    }
24166    if (o && o.length > 0) {
24167      const l = o.sort(r)[0], h = l.segment;
24168      let c = md(s, l);
24169      const u = i.getPixelFromCoordinate(c);
24170      let d = Oo(t, u);
24171      if (a || d <= this.pixelTolerance_) {
24172        const f = {};
24173        if (f[lt(h)] = !0, this.snapToPointer_ || (this.delta_[0] = c[0] - s[0], this.delta_[1] = c[1] - s[1]), l.geometry.getType() === "Circle" && l.index === hr)
24174          this.snappedToVertex_ = !0, this.createOrUpdateVertexFeature_(
24175            c,
24176            [l.feature],
24177            [l.geometry]
24178          );
24179        else {
24180          const g = i.getPixelFromCoordinate(h[0]), m = i.getPixelFromCoordinate(h[1]), _ = bi(u, g), p = bi(u, m);
24181          d = Math.sqrt(Math.min(_, p)), this.snappedToVertex_ = d <= this.pixelTolerance_, this.snappedToVertex_ && (c = _ > p ? h[1] : h[0]), this.createOrUpdateVertexFeature_(
24182            c,
24183            [l.feature],
24184            [l.geometry]
24185          );
24186          const y = {};
24187          y[lt(l.geometry)] = !0;
24188          for (let x = 1, E = o.length; x < E; ++x) {
24189            const M = o[x].segment;
24190            if (je(h[0], M[0]) && je(h[1], M[1]) || je(h[0], M[1]) && je(h[1], M[0])) {
24191              const w = lt(o[x].geometry);
24192              w in y || (y[w] = !0, f[lt(M)] = !0);
24193            } else
24194              break;
24195          }
24196        }
24197        this.vertexSegments_ = f;
24198        return;
24199      }
24200    }
24201    this.vertexFeature_ && (this.overlay_.getSource().removeFeature(this.vertexFeature_), this.vertexFeature_ = null);
24202  }
24203  /**
24204   * @param {SegmentData} segmentData Segment data.
24205   * @param {import("../coordinate.js").Coordinate} vertex Vertex.
24206   * @private
24207   */
24208  insertVertex_(t, i) {
24209    const n = t.segment, s = t.feature, r = t.geometry, o = t.depth, a = t.index;
24210    let l;
24211    for (; i.length < r.getStride(); )
24212      i.push(0);
24213    switch (r.getType()) {
24214      case "MultiLineString":
24215        l = r.getCoordinates(), l[o[0]].splice(a + 1, 0, i);
24216        break;
24217      case "Polygon":
24218        l = r.getCoordinates(), l[o[0]].splice(a + 1, 0, i);
24219        break;
24220      case "MultiPolygon":
24221        l = r.getCoordinates(), l[o[1]][o[0]].splice(a + 1, 0, i);
24222        break;
24223      case "LineString":
24224        l = r.getCoordinates(), l.splice(a + 1, 0, i);
24225        break;
24226      default:
24227        return;
24228    }
24229    this.setGeometryCoordinates_(r, l);
24230    const h = this.rBush_;
24231    h.remove(t), this.updateSegmentIndices_(r, a, o, 1);
24232    const c = {
24233      segment: [n[0], i],
24234      feature: s,
24235      geometry: r,
24236      depth: o,
24237      index: a
24238    };
24239    h.insert(ge(c.segment), c), this.dragSegments_.push([c, 1]);
24240    const u = {
24241      segment: [i, n[1]],
24242      feature: s,
24243      geometry: r,
24244      depth: o,
24245      index: a + 1
24246    };
24247    h.insert(ge(u.segment), u), this.dragSegments_.push([u, 0]), this.ignoreNextSingleClick_ = !0;
24248  }
24249  /**
24250   * Removes the vertex currently being pointed.
24251   * @return {boolean} True when a vertex was removed.
24252   * @api
24253   */
24254  removePoint() {
24255    if (this.lastPointerEvent_ && this.lastPointerEvent_.type != mt.POINTERDRAG) {
24256      const t = this.lastPointerEvent_;
24257      this.willModifyFeatures_(t, this.dragSegments_);
24258      const i = this.removeVertex_();
24259      return this.featuresBeingModified_ && this.dispatchEvent(
24260        new el(
24261          tl.MODIFYEND,
24262          this.featuresBeingModified_,
24263          t
24264        )
24265      ), this.featuresBeingModified_ = null, i;
24266    }
24267    return !1;
24268  }
24269  /**
24270   * Removes a vertex from all matching features.
24271   * @return {boolean} True when a vertex was removed.
24272   * @private
24273   */
24274  removeVertex_() {
24275    const t = this.dragSegments_, i = {};
24276    let n = !1, s, r, o, a, l, h, c, u, d, f, g;
24277    for (l = t.length - 1; l >= 0; --l)
24278      o = t[l], f = o[0], g = lt(f.feature), f.depth && (g += "-" + f.depth.join("-")), g in i || (i[g] = {}), o[1] === 0 ? (i[g].right = f, i[g].index = f.index) : o[1] == 1 && (i[g].left = f, i[g].index = f.index + 1);
24279    for (g in i) {
24280      switch (d = i[g].right, c = i[g].left, h = i[g].index, u = h - 1, c !== void 0 ? f = c : f = d, u < 0 && (u = 0), a = f.geometry, r = a.getCoordinates(), s = r, n = !1, a.getType()) {
24281        case "MultiLineString":
24282          r[f.depth[0]].length > 2 && (r[f.depth[0]].splice(h, 1), n = !0);
24283          break;
24284        case "LineString":
24285          r.length > 2 && (r.splice(h, 1), n = !0);
24286          break;
24287        case "MultiPolygon":
24288          s = s[f.depth[1]];
24289        case "Polygon":
24290          s = s[f.depth[0]], s.length > 4 && (h == s.length - 1 && (h = 0), s.splice(h, 1), n = !0, h === 0 && (s.pop(), s.push(s[0]), u = s.length - 1));
24291          break;
24292      }
24293      if (n) {
24294        this.setGeometryCoordinates_(a, r);
24295        const m = [];
24296        if (c !== void 0 && (this.rBush_.remove(c), m.push(c.segment[0])), d !== void 0 && (this.rBush_.remove(d), m.push(d.segment[1])), c !== void 0 && d !== void 0) {
24297          const _ = {
24298            depth: f.depth,
24299            feature: f.feature,
24300            geometry: f.geometry,
24301            index: u,
24302            segment: m
24303          };
24304          this.rBush_.insert(
24305            ge(_.segment),
24306            _
24307          );
24308        }
24309        this.updateSegmentIndices_(a, h, f.depth, -1), this.vertexFeature_ && (this.overlay_.getSource().removeFeature
24309(this.vertexFeature_), this.vertexFeature_ = null), t.length = 0;
24310      }
24311    }
24312    return n;
24313  }
24314  /**
24315   * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
24316   * @param {Array} coordinates Coordinates.
24317   * @private
24318   */
24319  setGeometryCoordinates_(t, i) {
24320    this.changingFeature_ = !0, t.setCoordinates(i), this.changingFeature_ = !1;
24321  }
24322  /**
24323   * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
24324   * @param {number} index Index.
24325   * @param {Array<number>|undefined} depth Depth.
24326   * @param {number} delta Delta (1 or -1).
24327   * @private
24328   */
24329  updateSegmentIndices_(t, i, n, s) {
24330    this.rBush_.forEachInExtent(
24331      t.getExtent(),
24332      function(r) {
24333        r.geometry === t && (n === void 0 || r.depth === void 0 || Pi(r.depth, n)) && r.index > i && (r.index += s);
24334      }
24335    );
24336  }
24337}
24338function Mw(e, t) {
24339  return e.index - t.index;
24340}
24341function gd(e, t, i) {
24342  const n = t.geometry;
24343  if (n.getType() === "Circle") {
24344    let r = (
24345      /** @type {import("../geom/Circle.js").default} */
24346      n
24347    );
24348    if (t.index === hr) {
24349      const o = bi(
24350        r.getCenter(),
24351        Lt(e)
24352      ), a = Math.sqrt(o) - r.getRadius();
24353      return a * a;
24354    }
24355  }
24356  const s = Lt(e);
24357  return xs[0] = Lt(t.segment[0]), xs[1] = Lt(t.segment[1]), Fx(s, xs);
24358}
24359function md(e, t, i) {
24360  const n = t.geometry;
24361  if (n.getType() === "Circle" && t.index === hr)
24362    return Pn(
24363      /** @type {import("../geom/Circle.js").default} */
24364      n.getClosestPoint(
24365        Lt(e)
24366      )
24367    );
24368  const s = Lt(e);
24369  return xs[0] = Lt(t.segment[0]), xs[1] = Lt(t.segment[1]), Pn(
24370    oh(s, xs)
24371  );
24372}
24373function bw() {
24374  const e = Ug();
24375  return function(t, i) {
24376    return e.Point;
24377  };
24378}
24379const ww = Cw, le = fa({
24380  geometry: null,
24381  // GeoJSON geometry: { type, coordinates } — Point | LineString | Polygon
24382  hasPoint: !1,
24383  resetSeq: 0
24384  // bumped by requestReportReset() so the map can clear its geometry
24385});
24386function il(e) {
24387  le.geometry = e, le.hasPoint = !0;
24388}
24389function _d() {
24390  le.geometry = null, le.hasPoint = !1;
24391}
24392function Sw() {
24393  le.geometry = null, le.hasPoint = !1, le.resetSeq++;
24394}
24395class Ra extends an {
24396  /**
24397   * @param {!import("../coordinate.js").Coordinate} center Center.
24398   *     For internal use, flat coordinates in combination with `layout` and no
24399   *     `radius` are also accepted.
24400   * @param {number} [radius] Radius.
24401   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
24402   */
24403  constructor(t, i, n) {
24404    super(), n !== void 0 && i === void 0 ? this.setFlatCoordinates(n, t) : (i = i || 0, this.setCenterAndRadius(t, i, n));
24405  }
24406  /**
24407   * Make a complete copy of the geometry.
24408   * @return {!Circle} Clone.
24409   * @api
24410   */
24411  clone() {
24412    const t = new Ra(
24413      this.flatCoordinates.slice(),
24414      void 0,
24415      this.layout
24416    );
24417    return t.applyProperties(this), t;
24418  }
24419  /**
24420   * @param {number} x X.
24421   * @param {number} y Y.
24422   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
24423   * @param {number} minSquaredDistance Minimum squared distance.
24424   * @return {number} Minimum squared distance.
24425   */
24426  closestPointXY(t, i, n, s) {
24427    const r = this.flatCoordinates, o = t - r[0], a = i - r[1], l = o * o + a * a;
24428    if (l < s) {
24429      if (l === 0)
24430        for (let h = 0; h < this.stride; ++h)
24431          n[h] = r[h];
24432      else {
24433        const h = this.getRadius() / Math.sqrt(l);
24434        n[0] = r[0] + h * o, n[1] = r[1] + h * a;
24435        for (let c = 2; c < this.stride; ++c)
24436          n[c] = r[c];
24437      }
24438      return n.length = this.stride, l;
24439    }
24440    return s;
24441  }
24442  /**
24443   * @param {number} x X.
24444   * @param {number} y Y.
24445   * @return {boolean} Contains (x, y).
24446   */
24447  containsXY(t, i) {
24448    const n = this.flatCoordinates, s = t - n[0], r = i - n[1];
24449    return s * s + r * r <= this.getRadiusSquared_();
24450  }
24451  /**
24452   * Return the center of the circle as {@link module:ol/coordinate~Coordinate coordinate}.
24453   * @return {import("../coordinate.js").Coordinate} Center.
24454   * @api
24455   */
24456  getCenter() {
24457    return this.flatCoordinates.slice(0, this.stride);
24458  }
24459  /**
24460   * @param {import("../extent.js").Extent} extent Extent.
24461   * @protected
24462   * @return {import("../extent.js").Extent} extent Extent.
24463   */
24464  computeExtent(t) {
24465    const i = this.flatCoordinates, n = i[this.stride] - i[0];
24466    return fi(
24467      i[0] - n,
24468      i[1] - n,
24469      i[0] + n,
24470      i[1] + n,
24471      t
24472    );
24473  }
24474  /**
24475   * Return the radius of the circle.
24476   * @return {number} Radius.
24477   * @api
24478   */
24479  getRadius() {
24480    return Math.sqrt(this.getRadiusSquared_());
24481  }
24482  /**
24483   * @private
24484   * @return {number} Radius squared.
24485   */
24486  getRadiusSquared_() {
24487    const t = this.flatCoordinates[this.stride] - this.flatCoordinates[0], i = this.flatCoordinates[this.stride + 1] - this.flatCoordinates[1];
24488    return t * t + i * i;
24489  }
24490  /**
24491   * Get the type of this geometry.
24492   * @return {import("./Geometry.js").Type} Geometry type.
24493   * @api
24494   */
24495  getType() {
24496    return "Circle";
24497  }
24498  /**
24499   * Test if the geometry and the passed extent intersect.
24500   * @param {import("../extent.js").Extent} extent Extent.
24501   * @return {boolean} `true` if the geometry and the extent intersect.
24502   * @api
24503   */
24504  intersectsExtent(t) {
24505    const i = this.getExtent();
24506    if (re(t, i)) {
24507      const n = this.getCenter();
24508      return t[0] <= n[0] && t[2] >= n[0] || t[1] <= n[1] && t[3] >= n[1] ? !0 : rh(t, this.intersectsCoordinate.bind(this));
24509    }
24510    return !1;
24511  }
24512  /**
24513   * Set the center of the circle as {@link module:ol/coordinate~Co
24513ordinate coordinate}.
24514   * @param {import("../coordinate.js").Coordinate} center Center.
24515   * @api
24516   */
24517  setCenter(t) {
24518    const i = this.stride, n = this.flatCoordinates[i] - this.flatCoordinates[0], s = t.slice();
24519    s[i] = s[0] + n;
24520    for (let r = 1; r < i; ++r)
24521      s[i + r] = t[r];
24522    this.setFlatCoordinates(this.layout, s), this.changed();
24523  }
24524  /**
24525   * Set the center (as {@link module:ol/coordinate~Coordinate coordinate}) and the radius (as
24526   * number) of the circle.
24527   * @param {!import("../coordinate.js").Coordinate} center Center.
24528   * @param {number} radius Radius.
24529   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
24530   * @api
24531   */
24532  setCenterAndRadius(t, i, n) {
24533    this.setLayout(n, t, 0), this.flatCoordinates || (this.flatCoordinates = []);
24534    const s = this.flatCoordinates;
24535    let r = _g(s, 0, t, this.stride);
24536    s[r++] = s[0] + i;
24537    for (let o = 1, a = this.stride; o < a; ++o)
24538      s[r++] = s[o];
24539    s.length = r, this.changed();
24540  }
24541  getCoordinates() {
24542    return null;
24543  }
24544  setCoordinates(t, i) {
24545  }
24546  /**
24547   * Set the radius of the circle. The radius is in the units of the projection.
24548   * @param {number} radius Radius.
24549   * @api
24550   */
24551  setRadius(t) {
24552    this.flatCoordinates[this.stride] = this.flatCoordinates[0] + t, this.changed();
24553  }
24554  /**
24555   * Rotate the geometry around a given coordinate. This modifies the geometry
24556   * coordinates in place.
24557   * @param {number} angle Rotation angle in counter-clockwise radians.
24558   * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
24559   * @api
24560   */
24561  rotate(t, i) {
24562    const n = this.getCenter(), s = this.getStride();
24563    this.setCenter(
24564      zh(n, 0, n.length, s, t, i, n)
24565    ), this.changed();
24566  }
24567}
24568Ra.prototype.transform;
24569const Tw = Ra;
24570class Jo extends mg {
24571  /**
24572   * @param {Array<Geometry>} [geometries] Geometries.
24573   */
24574  constructor(t) {
24575    super(), this.geometries_ = t || null, this.changeEventsKeys_ = [], this.listenGeometriesChange_();
24576  }
24577  /**
24578   * @private
24579   */
24580  unlistenGeometriesChange_() {
24581    this.changeEventsKeys_.forEach(St), this.changeEventsKeys_.length = 0;
24582  }
24583  /**
24584   * @private
24585   */
24586  listenGeometriesChange_() {
24587    if (this.geometries_)
24588      for (let t = 0, i = this.geometries_.length; t < i; ++t)
24589        this.changeEventsKeys_.push(
24590          ct(this.geometries_[t], et.CHANGE, this.changed, this)
24591        );
24592  }
24593  /**
24594   * Make a complete copy of the geometry.
24595   * @return {!GeometryCollection} Clone.
24596   * @api
24597   */
24598  clone() {
24599    const t = new Jo(null);
24600    return t.setGeometries(this.geometries_), t.applyProperties(this), t;
24601  }
24602  /**
24603   * @param {number} x X.
24604   * @param {number} y Y.
24605   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
24606   * @param {number} minSquaredDistance Minimum squared distance.
24607   * @return {number} Minimum squared distance.
24608   */
24609  closestPointXY(t, i, n, s) {
24610    if (s < kn(this.getExtent(), t, i))
24611      return s;
24612    const r = this.geometries_;
24613    for (let o = 0, a = r.length; o < a; ++o)
24614      s = r[o].closestPointXY(
24615        t,
24616        i,
24617        n,
24618        s
24619      );
24620    return s;
24621  }
24622  /**
24623   * @param {number} x X.
24624   * @param {number} y Y.
24625   * @return {boolean} Contains (x, y).
24626   */
24627  containsXY(t, i) {
24628    const n = this.geometries_;
24629    for (let s = 0, r = n.length; s < r; ++s)
24630      if (n[s].containsXY(t, i))
24631        return !0;
24632    return !1;
24633  }
24634  /**
24635   * @param {import("../extent.js").Extent} extent Extent.
24636   * @protected
24637   * @return {import("../extent.js").Extent} extent Extent.
24638   */
24639  computeExtent(t) {
24640    Ns(t);
24641    const i = this.geometries_;
24642    for (let n = 0, s = i.length; n < s; ++n)
24643      ef(t, i[n].getExtent());
24644    return t;
24645  }
24646  /**
24647   * Return the geometries that make up this geometry collection.
24648   * @return {Array<Geometry>} Geometries.
24649   * @api
24650   */
24651  getGeometries() {
24652    return pd(this.geometries_);
24653  }
24654  /**
24655   * @return {Array<Geometry>} Geometries.
24656   */
24657  getGeometriesArray() {
24658    return this.geometries_;
24659  }
24660  /**
24661   * @return {Array<Geometry>} Geometries.
24662   */
24663  getGeometriesArrayRecursive() {
24664    let t = [];
24665    const i = this.geometries_;
24666    for (let n = 0, s = i.length; n < s; ++n)
24667      i[n].getType() === this.getType() ? t = t.concat(
24668        /** @type {GeometryCollection} */
24669        i[n].getGeometriesArrayRecursive()
24670      ) : t.push(i[n]);
24671    return t;
24672  }
24673  /**
24674   * Create a simplified version of this geometry using the Douglas Peucker algorithm.
24675   * @param {number} squaredTolerance Squared tolerance.
24676   * @return {GeometryCollection} Simplified GeometryCollection.
24677   */
24678  getSimplifiedGeometry(t) {
24679    if (this.simplifiedGeometryRevision !== this.getRevision() && (this.simplifiedGeometryMaxMinSquaredTolerance = 0, this.simplifiedGeometryRevision = this.getRevision()), t 
24679< 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && t < this.simplifiedGeometryMaxMinSquaredTolerance)
24680      return this;
24681    const i = [], n = this.geometries_;
24682    let s = !1;
24683    for (let r = 0, o = n.length; r < o; ++r) {
24684      const a = n[r], l = a.getSimplifiedGeometry(t);
24685      i.push(l), l !== a && (s = !0);
24686    }
24687    if (s) {
24688      const r = new Jo(null);
24689      return r.setGeometriesArray(i), r;
24690    }
24691    return this.simplifiedGeometryMaxMinSquaredTolerance = t, this;
24692  }
24693  /**
24694   * Get the type of this geometry.
24695   * @return {import("./Geometry.js").Type} Geometry type.
24696   * @api
24697   */
24698  getType() {
24699    return "GeometryCollection";
24700  }
24701  /**
24702   * Test if the geometry and the passed extent intersect.
24703   * @param {import("../extent.js").Extent} extent Extent.
24704   * @return {boolean} `true` if the geometry and the extent intersect.
24705   * @api
24706   */
24707  intersectsExtent(t) {
24708    const i = this.geometries_;
24709    for (let n = 0, s = i.length; n < s; ++n)
24710      if (i[n].intersectsExtent(t))
24711        return !0;
24712    return !1;
24713  }
24714  /**
24715   * @return {boolean} Is empty.
24716   */
24717  isEmpty() {
24718    return this.geometries_.length === 0;
24719  }
24720  /**
24721   * Rotate the geometry around a given coordinate. This modifies the geometry
24722   * coordinates in place.
24723   * @param {number} angle Rotation angle in radians.
24724   * @param {import("../coordinate.js").Coordinate} anchor The rotation center.
24725   * @api
24726   */
24727  rotate(t, i) {
24728    const n = this.geometries_;
24729    for (let s = 0, r = n.length; s < r; ++s)
24730      n[s].rotate(t, i);
24731    this.changed();
24732  }
24733  /**
24734   * Scale the geometry (with an optional origin).  This modifies the geometry
24735   * coordinates in place.
24736   * @abstract
24737   * @param {number} sx The scaling factor in the x-direction.
24738   * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
24739   * @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
24740   *     of the geometry extent).
24741   * @api
24742   */
24743  scale(t, i, n) {
24744    n || (n = Je(this.getExtent()));
24745    const s = this.geometries_;
24746    for (let r = 0, o = s.length; r < o; ++r)
24747      s[r].scale(t, i, n);
24748    this.changed();
24749  }
24750  /**
24751   * Set the geometries that make up this geometry collection.
24752   * @param {Array<Geometry>} geometries Geometries.
24753   * @api
24754   */
24755  setGeometries(t) {
24756    this.setGeometriesArray(pd(t));
24757  }
24758  /**
24759   * @param {Array<Geometry>} geometries Geometries.
24760   */
24761  setGeometriesArray(t) {
24762    this.unlistenGeometriesChange_(), this.geometries_ = t, this.listenGeometriesChange_(), this.changed();
24763  }
24764  /**
24765   * Apply a transform function to the coordinates of the geometry.
24766   * The geometry is modified in place.
24767   * If you do not want the geometry modified in place, first `clone()` it and
24768   * then use this function on the clone.
24769   * @param {import("../proj.js").TransformFunction} transformFn Transform function.
24770   * Called with a flat array of geometry coordinates.
24771   * @api
24772   */
24773  applyTransform(t) {
24774    const i = this.geometries_;
24775    for (let n = 0, s = i.length; n < s; ++n)
24776      i[n].applyTransform(t);
24777    this.changed();
24778  }
24779  /**
24780   * Translate the geometry.  This modifies the geometry coordinates in place.  If
24781   * instead you want a new geometry, first `clone()` this geometry.
24782   * @param {number} deltaX Delta X.
24783   * @param {number} deltaY Delta Y.
24784   * @api
24785   */
24786  translate(t, i) {
24787    const n = this.geometries_;
24788    for (let s = 0, r = n.length; s < r; ++s)
24789      n[s].translate(t, i);
24790    this.changed();
24791  }
24792  /**
24793   * Clean up.
24794   */
24795  disposeInternal() {
24796    this.unlistenGeometriesChange_(), super.disposeInternal();
24797  }
24798}
24799function pd(e) {
24800  const t = [];
24801  for (let i = 0, n = e.length; i < n; ++i)
24802    t.push(e[i].clone());
24803  return t;
24804}
24805const sm = Jo;
24806class Qo extends an {
24807  /**
24808   * @param {Array<Array<import("../coordinate.js").Coordinate>|LineString>|Array<number>} coordinates
24809   *     Coordinates or LineString geometries. (For internal use, flat coordinates in
24810   *     combination with `layout` and `ends` are also accepted.)
24811   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
24812   * @param {Array<number>} [ends] Flat coordinate ends for internal use.
24813   */
24814  constructor(t, i, n) {
24815    if (super(), this.ends_ = [], this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, Array.isArray(t[0]))
24816      this.setCoordinates(
24817        /** @type {Array<Array<import("../coordinate.js").Coordinate>>} */
24818        t,
24819        i
24820      );
24821    else if (i !== void 0 && n)
24822      this.setFlatCoordinates(
24823        i,
24824        /** @type {Array<number>} */
24825        t
24826      ), this.ends_ = n;
24827    else {
24828      let s = this.getLayout();
24829      const r = (
24830        /** @type {Array<LineString>} */
24831        t
24832      ), o = [], a = [];
24833      for (let l = 0, h = r.length; l < h; ++l) {
24834        const c = r[l];
24835        l === 0 && (s = c.getLayout()), ci(o, c.getFlatCoordinates()), a.push(o.length);
24836      }
24837      this.setFlatCoordinates(s, o), this.ends_ = a;
24838    }
24839  }
24840  /**
24841   * Append the passed linestring to the multilinestring.
24842   * @param {LineString} lineString LineString.
24843   * @api
24844   */
24845  appendLineString(t) {
24846    this.flatCoordinates ? ci(this.flatCoordinates, t.getFlatCoordinates().slice()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.ends_.push(this.flatCoordinates.length), this.changed();
24847  }
24848  /**
24849   * Make a complete copy of the geometry.
24850   * @return {!MultiLineString} Clone.
24851   * @api
24852   */
24853  clone() {
24854    const t = new Qo(
24855      this.flatCoordinates.slice(),
24856      this.layout,
24857      this.ends_.slice()
24858    );
24859    return t.applyProperties(this), t;
24860  }
24861  /**
24862   * @param {number} x X.
24863   * @param {number} y Y.
24864   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
24865   * @param {number} minSquaredDistance Minimum squared distance.
24866   * @return {number} Minimum squared distance.
24867   */
24868  closestPointXY(t, i, n, s) {
24869    return s < kn(this.getExtent(), t, i) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
24870      Wh(
24871        this.flatCoordinates,
24872        0,
24873        this.ends_,
24874        this.stride,
24875        0
24876      )
24877    ), this.maxDeltaRevision_ = this.getRevision()), Uh(
24878      this.flatCoordinates,
24879      0,
24880      this.ends_,
24881      this.stride,
24882      this.maxDelta_,
24883      !1,
24884      t,
24885      i,
24886      n,
24887      s
24888    ));
24889  }
24890  /**
24891   * Returns the coordinate at `m` using linear interpolation, or `null` if no
24892   * such coordinate exists.
24893   *
24894   * `extrapolate` controls extrapolation beyond the range of Ms in the
24895   * MultiLineString. If `extrapolate` is `true` then Ms less than the first
24896   * M will return the first coordinate and Ms greater than the last M will
24897   * return the last coordinate.
24898   *
24899   * `interpolate` controls interpolation between consecutive LineStrings
24900   * within the MultiLineString. If `interpolate` is `true` the coordinates
24901   * will be linearly interpolated between the last coordinate of one LineString
24902   * and the first coordinate of the next LineString.  If `interpolate` is
24903   * `false` then the function will return `null` for Ms falling between
24904   * LineStrings.
24905   *
24906   * @param {number} m M.
24907   * @param {boolean} [extrapolate] Extrapolate. Default is `false`.
24908   * @param {boolean} [interpolate] Interpolate. Default is `false`.
24909   * @return {import("../coordinate.js").Coordinate|null} Coordinate.
24910   * @api
24911   */
24912  getCoordinateAtM(t, i, n) {
24913    return this.layout != "XYM" && this.layout != "XYZM" || this.flatCoordinates.length === 0 ? null : (i = i !== void 0 ? i : !1, n = n !== void 0 ? n : !1, QM(
24914      this.flatCoordinates,
24915      0,
24916      this.ends_,
24917      this.stride,
24918      t,
24919      i,
24920      n
24921    ));
24922  }
24923  /**
24924   * Return the coordinates of the multilinestring.
24925   * @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
24926   * @api
24927   */
24928  getCoordinates() {
24929    return vr(
24930      this.flatCoordinates,
24931      0,
24932      this.ends_,
24933      this.stride
24934    );
24935  }
24936  /**
24937   * @return {Array<number>} Ends.
24938   */
24939  getEnds() {
24940    return this.ends_;
24941  }
24942  /**
24943   * Return the linestring at the specified index.
24944   * @param {number} index Index.
24945   * @return {LineString} LineString.
24946   * @api
24947   */
24948  getLineString(t) {
24949    return t < 0 || this.ends_.length <= t ? null : new Qi(
24950      this.flatCoordinates.slice(
24951        t === 0 ? 0 : this.ends_[t - 1],
24952        this.ends_[t]
24953      ),
24954      this.layout
24955    );
24956  }
24957  /**
24958   * Return the linestrings of this multilinestring.
24959   * @return {Array<LineString>} LineStrings.
24960   * @api
24961   */
24962  getLineStrings() {
24963    const t = this.flatCoordinates, i = this.ends_, n = this.layout, s = [];
24964    let r = 0;
24965    for (let o = 0, a = i.length; o < a; ++o) {
24966      const l = i[o], h = new Qi(
24967        t.slice(r, l),
24968        n
24969      );
24970      s.push(h), r = l;
24971    }
24972    return s;
24973  }
24974  /**
24975   * @return {Array<number>} Flat midpoints.
24976   */
24977  getFlatMidpoints() {
24978    const t = [], i = this.flatCoordinates;
24979    let n = 0;
24980    const s = this.ends_, r = this.stride;
24981    for (let o = 0, a = s.length; o < a; ++o) {
24982      const l = s[o], h = zg(
24983        i,
24984        n,
24985        l,
24986        r,
24987        0.5
24988      );
24989      ci(t, h), n = l;
24990    }
24991    return t;
24992  }
24993  /**
24994   * @param {number} squaredTolerance Squared tolerance.
24995   * @return {MultiLineString} Simplified MultiLineString.
24996   * @protected
24997   */
24998  getSimplifiedGeometryInternal(t) {
24999    const i = [], n = [];
25000    return i.length = _C(
25001      this.flatCoordinates,
25002      0,
25003      this.ends_,
25004      this.stride,
25005      t,
25006      i,
25007      0,
25008      n
25009    ), new Qo(i, "XY", n);
25010  }
25011  /**
25012   * Get the type of this geometry.
25013   * @return {import("./Geometry.js").Type} Geometry type.
25014   * @api
25015   */
25016  getType() {
25017    return "MultiLineString";
25018  }
25019  /**
25020   * Test if the geometry and the passed extent intersect.
25021   * @param {import("../extent.js").Extent} extent Extent.
25022   * @return {boolean} `true` if the geometry and the extent intersect.
25023   * @api
25024   */
25025  intersectsExtent(t) {
25026    return MC(
25027      this.flatCoordinates,
25028      0,
25029      this.ends_,
25030      this.stride,
25031      t
25032    );
25033  }
25034  /**
25035   * Set the coordinates of the multilinestring.
25036   * @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
25037   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
25038   * @api
25039   */
25040  setCoordinates(t, i) {
25041    this.setLayout(i, t, 2), this.flatCoordinates || (this.flatCoordinates = []);
25042    const n = Xh(
25043      this.flatCoordinates,
25044      0,
25045      t,
25046      this.stride,
25047      this.ends_
25048    );
25049    this.flatCoordinates.length = n.length === 0 ? 0 : n[n.length - 1], this.changed();
25050  }
25051}
25052const dc = Qo;
25053class fc extends an {
25054  /**
25055   * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
25056   *     For internal use, flat coordinates in combination with `layout` are also accepted.
25057   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
25058   */
25059  constructor(t, i) {
25060    super(), i && !Array.isArray(t[0]) ? this.setFlatCoordinates(
25061      i,
25062      /** @type {Array<number>} */
25063      t
25064    ) : this.setCoordinates(
25065      /** @type {Array<import("../coordinate.js").Coordinate>} */
25066      t,
25067      i
25068    );
25069  }
25070  /**
25071   * Append the passed point to this multipoint.
25072   * @param {Point} point Point.
25073   * @api
25074   */
25075  appendPoint(t) {
25076    this.flatCoordinates ? ci(this.flatCoordinates, t.getFlatCoordinates()) : this.flatCoordinates = t.getFlatCoordinates().slice(), this.changed();
25077  }
25078  /**
25079   * Make a complete copy of the geometry.
25080   * @return {!MultiPoint} Clone.
25081   * @api
25082   */
25083  clone() {
25084    const t = new fc(
25085      this.flatCoordinates.slice(),
25086      this.layout
25087    );
25088    return t.applyProperties(this), t;
25089  }
25090  /**
25091   * @param {number} x X.
25092   * @param {number} y Y.
25093   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
25094   * @param {number} minSquaredDistance Minimum squared distance.
25095   * @return {number} Minimum squared distance.
25096   */
25097  closestPointXY(t, i, n, s) {
25098    if (s < kn(this.getExtent(), t, i))
25099      return s;
25100    const r = this.flatCoordinates, o = this.stride;
25101    for (let a = 0, l = r.length; a < l; a += o) {
25102      const h = Mi(
25103        t,
25104        i,
25105        r[a],
25106        r[a + 1]
25107      );
25108      if (h < s) {
25109        s = h;
25110        for (let c = 0; c < o; ++c)
25111          n[c] = r[a + c];
25112        n.length = o;
25113      }
25114    }
25115    return s;
25116  }
25117  /**
25118   * Return the coordinates of the multipoint.
25119   * @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
25120   * @api
25121   */
25122  getCoordinates() {
25123    return Xi(
25124      this.flatCoordinates,
25125      0,
25126      this.flatCoordinates.length,
25127      this.stride
25128    );
25129  }
25130  /**
25131   * Return the point at the specified index.
25132   * @param {number} index Index.
25133   * @return {Point} Point.
25134   * @api
25135   */
25136  getPoint(t) {
25137    const i = this.flatCoordinates ? this.flatCoordinates.length / this.stride : 0;
25138    return t < 0 || i <= t ? null : new Ne(
25139      this.flatCoordinates.slice(
25140        t * this.stride,
25141        (t + 1) * this.stride
25142      ),
25143      this.layout
25144    );
25145  }
25146  /**
25147   * Return the points of this multipoint.
25148   * @return {Array<Point>} Points.
25149   * @api
25150   */
25151  getPoints() {
25152    const t = this.flatCoordinates, i = this.layout, n = this.stride, s = [];
25153    for (let r = 0, o = t.length; r < o; r += n) {
25154      const a = new Ne(t.slice(r, r + n), i);
25155      s.push(a);
25156    }
25157    return s;
25158  }
25159  /**
25160   * Get the type of this geometry.
25161   * @return {import("./Geometry.js").Type} Geometry type.
25162   * @api
25163   */
25164  getType() {
25165    return "MultiPoint";
25166  }
25167  /**
25168   * Test if the geometry and the passed extent intersect.
25169   * @param {import("../extent.js").Extent} extent Extent.
25170   * @return {boolean} `true` if the geometry and the extent intersect.
25171   * @api
25172   */
25173  intersectsExtent(t) {
25174    const i = this.flatCoordinates, n = this.stride;
25175    for (let s = 0, r = i.length; s < r; s += n) {
25176      const o = i[s], a = i[s + 1];
25177      if (sh(t, o, a))
25178        return !0;
25179    }
25180    return !1;
25181  }
25182  /**
25183   * Set the coordinates of the multipoint.
25184   * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
25185   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
25186   * @api
25187   */
25188  setCoordinates(t, i) {
25189    this.setLayout(i, t, 1), this.flatCoordinates || (this.flatCoordinates = []), this.flatCoordinates.length = Ma(
25190      this.flatCoordinates,
25191      0,
25192      t,
25193      this.stride
25194    ), this.changed();
25195  }
25196}
25197const gc = fc;
25198function Iw(e, t, i, n) {
25199  const s = [];
25200  let r = be();
25201  for (let o = 0, a = i.length; o < a; ++o) {
25202    const l = i[o];
25203    r = tf(
25204      e,
25205      t,
25206      l[0],
25207      n
25208    ), s.push((r[0] + r[2]) / 2, (r[1] + r[3]) / 2), t = l[l.length - 1];
25209  }
25210  return s;
25211}
25212class ta extends an {
25213  /**
25214   * @param {Array<Array<Array<import("../coordinate.js").Coordinate>>|Polygon>|Array<number>} coordinates Coordinates.
25215   *     For internal use, flat coordinates in combination with `layout` and `endss` are also accepted.
25216   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
25217   * @param {Array<Array<number>>} [endss] Array of ends for internal use with flat coordinates.
25218   */
25219  constructor(t, i, n) {
25220    if (super(), this.endss_ = [], this.flatInteriorPointsRevision_ = -1, this.flatInteriorPoints_ = null, this.maxDelta_ = -1, this.maxDeltaRevision_ = -1, this.orientedRevision_ = -1, this.orientedFlatCoordinates_ = null, !n && !Array.isArray(t[0])) {
25221      let s = this.getLayout();
25222      const r = (
25223        /** @type {Array<Polygon>} */
25224        t
25225      ), o = [], a = [];
25226      for (let l = 0, h = r.length; l < h; ++l) {
25227        const c = r[l];
25228        l === 0 && (s = c.getLayout());
25229        const u = o.length, d = c.getEnds();
25230        for (let f = 0, g = d.length; f < g; ++f)
25231          d[f] += u;
25232        ci(o, c.getFlatCoordinates()), a.push(d);
25233      }
25234      i = s, t = o, n = a;
25235    }
25236    i !== void 0 && n ? (this.setFlatCoordinates(
25237      i,
25238      /** @type {Array<number>} */
25239      t
25240    ), this.endss_ = n) : this.setCoordinates(
25241      /** @type {Array<Array<Array<import("../coordinate.js").Coordinate>>>} */
25242      t,
25243      i
25244    );
25245  }
25246  /**
25247   * Append the passed polygon to this multipolygon.
25248   * @param {Polygon} polygon Polygon.
25249   * @api
25250   */
25251  appendPolygon(t) {
25252    let i;
25253    if (!this.flatCoordinates)
25254      this.flatCoordinates = t.getFlatCoordinates().slice(), i = t.getEnds().slice(), this.endss_.push();
25255    else {
25256      const n = this.flatCoordinates.length;
25257      ci(this.flatCoordinates, t.getFlatCoordinates()), i = t.getEnds().slice();
25258      for (let s = 0, r = i.length; s < r; ++s)
25259        i[s] += n;
25260    }
25261    this.endss_.push(i), this.changed();
25262  }
25263  /**
25264   * Make a complete copy of the geometry.
25265   * @return {!MultiPolygon} Clone.
25266   * @api
25267   */
25268  clone() {
25269    const t = this.endss_.length, i = new Array(t);
25270    for (let s = 0; s < t; ++s)
25271      i[s] = this.endss_[s].slice();
25272    const n = new ta(
25273      this.flatCoordinates.slice(),
25274      this.layout,
25275      i
25276    );
25277    return n.applyProperties(this), n;
25278  }
25279  /**
25280   * @param {number} x X.
25281   * @param {number} y Y.
25282   * @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
25283   * @param {number} minSquaredDistance Minimum squared distance.
25284   * @return {number} Minimum squared distance.
25285   */
25286  closestPointXY(t, i, n, s) {
25287    return s < kn(this.getExtent(), t, i) ? s : (this.maxDeltaRevision_ != this.getRevision() && (this.maxDelta_ = Math.sqrt(
25288      fC(
25289        this.flatCoordinates,
25290        0,
25291        this.endss_,
25292        this.stride,
25293        0
25294      )
25295    ), this.maxDeltaRevision_ = this.getRevision()), gC(
25296      this.getOrientedFlatCoordinates(),
25297      0,
25298      this.endss_,
25299      this.stride,
25300      this.maxDelta_,
25301      !0,
25302      t,
25303      i,
25304      n,
25305      s
25306    ));
25307  }
25308  /**
25309   * @param {number} x X.
25310   * @param {number} y Y.
25311   * @return {boolean} Contains (x, y).
25312   */
25313  containsXY(t, i) {
25314    return EC(
25315      this.getOrientedFlatCoordinates(),
25316      0,
25317      this.endss_,
25318      this.stride,
25319      t,
25320      i
25321    );
25322  }
25323  /**
25324   * Return the area of the multipolygon on projected plane.
25325   * @return {number} Area (on projected plane).
25326   * @api
25327   */
25328  getArea() {
25329    return xC(
25330      this.getOrientedFlatCoordinates(),
25331      0,
25332      this.endss_,
25333      this.stride
25334    );
25335  }
25336  /**
25337   * Get the coordinate array for this geometry.  This array has the structure
25338   * of a GeoJSON coordinate array for multi-polygons.
25339   *
25340   * @param {boolean} [right] Orient coordinates according to the right-hand
25341   *     rule (counter-clockwise for exterior and clockwise for interior rings).
25342   *     If `false`, coordinates will be oriented according to the left-hand rule
25343   *     (clockwise for exterior and counter-clockwise for interior rings).
25344   *     By default, coordinate orientation will depend on how the geometry was
25345   *     constructed.
25346   * @return {Array<Array<Array<import("../coordinate.js").Coordinate>>>} Coordinates.
25347   * @api
25348   */
25349  getCoordinates(t) {
25350    let i;
25351    return t !== void 0 ? (i = this.getOrientedFlatCoordinates().slice(), Bu(
25352      i,
25353      0,
25354      this.endss_,
25355      this.stride,
25356      t
25357    )) : i = this.flatCoordinates, kl(
25358      i,
25359      0,
25360      this.endss_,
25361      this.stride
25362    );
25363  }
25364  /**
25365   * @return {Array<Array<number>>} Endss.
25366   */
25367  getEndss() {
25368    return this.endss_;
25369  }
25370  /**
25371   * @return {Array<number>} Flat interior points.
25372   */
25373  getFlatInteriorPoints() {
25374    if (this.flatInteriorPointsRevision_ != this.getRevision()) {
25375      const t = Iw(
25376        this.flatCoordinates,
25377        0,
25378        this.endss_,
25379        this.stride
25380      );
25381      this.flatInteriorPoints_ = CC(
25382        this.getOrientedFlatCoordinates(),
25383        0,
25384        this.endss_,
25385        this.stride,
25386        t
25387      ), this.flatInteriorPointsRevision_ = this.getRevision();
25388    }
25389    return this.flatInteriorPoints_;
25390  }
25391  /**
25392   * Return the interior points as {@link module:ol/geom/MultiPoint~MultiPoint multipoint}.
25393   * @return {MultiPoint} Interior points as XYM coordinates, where M is
25394   * the length of the horizontal intersection that the point belongs to.
25395   * @api
25396   */
25397  getInteriorPoints() {
25398    return new gc(this.getFlatInteriorPoints().slice(), "XYM");
25399  }
25400  /**
25401   * @return {Array<number>} Oriented flat coordinates.
25402   */
25403  getOrientedFlatCoordinates() {
25404    if (this.orientedRevision_ != this.getRevision()) {
25405      const t = this.flatCoordinates;
25406      SC(t, 0, this.endss_, this.stride) ? this.orientedFlatCoordinates_ = t : (this.orientedFlatCoordinates_ = t.slice(), this.orientedFlatCoordinates_.length = Bu(
25407        this.orientedFlatCoordinates_,
25408        0,
25409        this.endss_,
25410        this.stride
25411      )), this.orientedRevision_ = this.getRevision();
25412    }
25413    return this.orientedFlatCoordinates_;
25414  }
25415  /**
25416   * @param {number} squaredTolerance Squared tolerance.
25417   * @return {MultiPolygon} Simplified MultiPolygon.
25418   * @protected
25419   */
25420  getSimplifiedGeometryInternal(t) {
25421    const i = [], n = [];
25422    return i.length = yC(
25423      this.flatCoordinates,
25424      0,
25425      this.endss_,
25426      this.stride,
25427      Math.sqrt(t),
25428      i,
25429      0,
25430      n
25431    ), new ta(i, "XY", n);
25432  }
25433  /**
25434   * Return the polygon at the specified index.
25435   * @param {number} index Index.
25436   * @return {Polygon} Polygon.
25437   * @api
25438   */
25439  getPolygon(t) {
25440    if (t < 0 || this.endss_.length <= t)
25441      return null;
25442    let i;
25443    if (t === 0)
25444      i = 0;
25445    else {
25446      const r = this.endss_[t - 1];
25447      i = r[r.length - 1];
25448    }
25449    const n = this.endss_[t].slice(), s = n[n.length - 1];
25450    if (i !== 0)
25451      for (let r = 0, o = n.length; r < o; ++r)
25452        n[r] -= i;
25453    return new Fn(
25454      this.flatCoordinates.slice(i, s),
25455      this.layout,
25456      n
25457    );
25458  }
25459  /**
25460   * Return the polygons of this multipolygon.
25461   * @return {Array<Polygon>} Polygons.
25462   * @api
25463   */
25464  getPolygons() {
25465    const t = this.layout, i = this.flatCoordinates, n = this.endss_, s = [];
25466    let r = 0;
25467    for (let o = 0, a = n.length; o < a; ++o) {
25468      const l = n[o].slice(), h = l[l.length - 1];
25469      if (r !== 0)
25470        for (let u = 0, d = l.length; u < d; ++u)
25471          l[u] -= r;
25472      const c = new Fn(
25473        i.slice(r, h),
25474        t,
25475        l
25476      );
25477      s.push(c), r = h;
25478    }
25479    return s;
25480  }
25481  /**
25482   * Get the type of this geometry.
25483   * @return {import("./Geometry.js").Type} Geometry type.
25484   * @api
25485   */
25486  getType() {
25487    return "MultiPolygon";
25488  }
25489  /**
25490   * Test if the geometry and the passed extent intersect.
25491   * @param {import("../extent.js").Extent} extent Extent.
25492   * @return {boolean} `true` if the geometry and the extent intersect.
25493   * @api
25494   */
25495  intersectsExtent(t) {
25496    return bC(
25497      this.getOrientedFlatCoordinates(),
25498      0,
25499      this.endss_,
25500      this.stride,
25501      t
25502    );
25503  }
25504  /**
25505   * Set the coordinates of the multipolygon.
25506   * @param {!Array<Array<Array<import("../coordinate.js").Coordinate>>>} coordinates Coordinates.
25507   * @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
25508   * @api
25509   */
25510  setCoordinates(t, i) {
25511    this.setLayout(i, t, 3), this.flatCoordinates || (this.flatCoordinates = []);
25512    const n = mC(
25513      this.flatCoordinates,
25514      0,
25515      t,
25516      this.stride,
25517      this.endss_
25518    );
25519    if (n.length === 0)
25520      this.flatCoordinates.length = 0;
25521    else {
25522      const s = n[n.length - 1];
25523      this.flatCoordinates.length = s.length === 0 ? 0 : s[s.length - 1];
25524    }
25525    this.changed();
25526  }
25527}
25528const mc = ta, co = {
25529  /**
25530   * Triggered upon feature draw start
25531   * @event DrawEvent#drawstart
25532   * @api
25533   */
25534  DRAWSTART: "drawstart",
25535  /**
25536   * Triggered upon feature draw end
25537   * @event DrawEvent#drawend
25538   * @api
25539   */
25540  DRAWEND: "drawend",
25541  /**
25542   * Triggered upon feature draw abortion
25543   * @event DrawEvent#drawabort
25544   * @api
25545   */
25546  DRAWABORT: "drawabort"
25547};
25548class uo extends Le {
25549  /**
25550   * @param {DrawEventType} type Type.
25551   * @param {Feature} feature The feature drawn.
25552   */
25553  constructor(t, i) {
25554    super(t), this.feature = i;
25555  }
25556}
25557function Rw(e, t) {
25558  const i = [];
25559  for (let n = 0; n < t.length; ++n) {
25560    const r = t[n].getGeometry();
25561    rm(e, r, i);
25562  }
25563  return i;
25564}
25565function fo(e, t) {
25566  return Mi(e[0], e[1], t[0], t[1]);
25567}
25568function os(e, t) {
25569  const i = e.length;
25570  return t < 0 ? e[t + i] : t >= i ? e[t - i] : e[t];
25571}
25572function go(e, t, i) {
25573  let n, s;
25574  t < i ? (n = t, s = i) : (n = i, s = t);
25575  const r = Math.ceil(n), o = Math.floor(s);
25576  if (r > o) {
25577    const l = as(e, n), h = as(e, s);
25578    return fo(l, h);
25579  }
25580  let a = 0;
25581  if (n < r) {
25582    const l = as(e, n), h = os(e, r);
25583    a += fo(l, h);
25584  }
25585  if (o < s) {
25586    const l = os(e, o), h = as(e, s);
25587    a += fo(l, h);
25588  }
25589  for (let l = r; l < o - 1; ++l) {
25590    const h = os(e, l), c = os(e, l + 1);
25591    a += fo(h, c);
25592  }
25593  return a;
25594}
25595function rm(e, t, i) {
25596  if (t instanceof Qi) {
25597    mo(e, t.getCoordinates(), !1, i);
25598    return;
25599  }
25600  if (t instanceof dc) {
25601    const n = t.getCoordinates();
25602    for (let s = 0, r = n.length; s < r; ++s)
25603      mo(e, n[s], !1, i);
25604    return;
25605  }
25606  if (t instanceof Fn) {
25607    const n = t.getCoordinates();
25608    for (let s = 0, r = n.length; s < r; ++s)
25609      mo(e, n[s], !0, i);
25610    return;
25611  }
25612  if (t instanceof mc) {
25613    const n = t.getCoordinates();
25614    for (let s = 0, r = n.length; s < r; ++s) {
25615      const o = n[s];
25616      for (let a = 0, l = o.length; a < l; ++a)
25617        mo(e, o[a], !0, i);
25618    }
25619    return;
25620  }
25621  if (t instanceof sm) {
25622    const n = t.getGeometries();
25623    for (let s = 0; s < n.length; ++s)
25624      rm(e, n[s], i);
25625    return;
25626  }
25627}
25628const nl = { index: -1, endIndex: NaN };
25629function Pw(e, t, i, n) {
25630  const s = e[0], r = e[1];
25631  let o = 1 / 0, a = -1, l = NaN;
25632  for (let u = 0; u < t.targets.length; ++u) {
25633    const d = t.targets[u], f = d.coordinates;
25634    let g = 1 / 0, m;
25635    for (let _ = 0; _ < f.length - 1; ++_) {
25636      const p = f[_], y = f[_ + 1], x = om(s, r, p, y);
25637      x.squaredDistance < g && (g = x.squaredDistance, m = _ + x.along);
25638    }
25639    g < o && (o = g, d.ring && t.targetIndex === u && (d.endIndex > d.startIndex ? m < d.startIndex && (m += f.length) : d.endIndex < d.startIndex && m > d.startIndex && (m -= f.length)), l = m, a = u);
25640  }
25641  const h = t.targets[a];
25642  let c = h.ring;
25643  if (t.targetIndex === a && c) {
25644    const u = as(
25645      h.coordinates,
25646      l
25647    ), d = i.getPixelFromCoordinate(u);
25648    Oo(d, t.startPx) > n && (c = !1);
25649  }
25650  if (c) {
25651    const u = h.coordinates, d = u.length, f = h.startIndex, g = l;
25652    if (f < g) {
25653      const m = go(
25654        u,
25655        f,
25656        g
25657      );
25658      go(
25659        u,
25660        f,
25661        g - d
25662      ) < m && (l -= d);
25663    } else {
25664      const m = go(
25665        u,
25666        f,
25667        g
25668      );
25669      go(
25670        u,
25671        f,
25672        g + d
25673      ) < m && (l += d);
25674    }
25675  }
25676  return nl.index = a, nl.endIndex = l, nl;
25677}
25678function mo(e, t, i, n) {
25679  const s = e[0], r = e[1];
25680  for (let o = 0, a = t.length - 1; o < a; ++o) {
25681    const l = t[o], h = t[o + 1], c = om(s, r, l, h);
25682    if (c.squaredDistance === 0) {
25683      const u = o + c.along;
25684      n.push({
25685        coordinates: t,
25686        ring: i,
25687        startIndex: u,
25688        endIndex: u
25689      });
25690      return;
25691    }
25692  }
25693}
25694const sl = { along: 0, squaredDistance: 0 };
25695function om(e, t, i, n) {
25696  const s = i[0], r = i[1], o = n[0], a = n[1], l = o - s, h = a - r;
25697  let c = 0, u = s, d = r;
25698  return (l !== 0 || h !== 0) && (c = kt(((e - s) * l + (t - r) * h) / (l * l + h * h), 0, 1), u += l * c, d += h * c), sl.along = c, sl.squaredDistance = Nr(Mi(e, t, u, d), 10), sl;
25699}
25700function as(e, t) {
25701  const i = e.length;
25702  let n = Math.floor(t);
25703  const s = t - n;
25704  n >= i ? n -= i : n < 0 && (n += i);
25705  let r = n + 1;
25706  r >= i && (r -= i);
25707  const o = e[n], a = o[0], l = o[1], h = e[r], c = h[0] - a, u = h[1] - l;
25708  return [a + c * s, l + u * s];
25709}
25710class Lw extends ln {
25711  /**
25712   * @param {Options} options Options.
25713   */
25714  constructor(t) {
25715    const i = (
25716      /** @type {import("./Pointer.js").Options} */
25717      t
25718    );
25719    i.stopDown || (i.stopDown = Gn), super(i), this.on, this.once, this.un, this.shouldHandle_ = !1, this.downPx_ = null, this.downTimeout_, this.lastDragTime_, this.pointerType_, this.freehand_ = !1, this.source_ = t.source ? t.source : null, this.features_ = t.features ? t.features : null, this.snapTolerance_ = t.snapTolerance ? t.snapTolerance : 12, this.type_ = /** @type {import("../geom/Geometry.js").Type} */
25720    t.type, this.mode_ = Ow(this.type_), this.stopClick_ = !!t.stopClick, this.minPoints_ = t.minPoints ? t.minPoints : this.mode_ === "Polygon" ? 3 : 2, this.maxPoints_ = this.mode_ === "Circle" ? 2 : t.maxPoints ? t.maxPoints : 1 / 0, this.finishCondition_ = t.finishCondition ? t.finishCondition : An, this.geometryLayout_ = t.geometryLayout ? t.geometryLayout : "XY";
25721    let n = t.geometryFunction;
25722    if (!n) {
25723      const s = this.mode_;
25724      if (s === "Circle")
25725        n = function(r, o, a) {
25726          const l = o || new Tw([NaN, NaN]), h = Lt(r[0]), c = bi(
25727            h,
25728            Lt(r[r.length - 1])
25729          );
25730          return l.setCenterAndRadius(
25731            h,
25732            Math.sqrt(c),
25733            this.geometryLayout_
25734          ), l;
25735        };
25736      else {
25737        let r;
25738        s === "Point" ? r = Ne : s === "LineString" ? r = Qi : s === "Polygon" && (r = Fn), n = function(o, a, l) {
25739          return a ? s === "Polygon" ? o[0].length ? a.setCoordinates(
25740            [o[0].concat([o[0][0]])],
25741            this.geometryLayout_
25742          ) : a.setCoordinates([], this.geometryLayout_) : a.setCoordinates(o, this.geometryLayout_) : a = new r(o, this.geometryLayout_), a;
25743        };
25744      }
25745    }
25746    this.geometryFunction_ = n, this.dragVertexDelay_ = t.dragVertexDelay !== void 0 ? t.dragVertexDelay : 500, this.finishCoordinate_ = null, this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchCoords_ = null, this.sketchLine_ = null, this.sketchLineCoords_ = null, this.squaredClickTolerance_ = t.clickTolerance ? t.clickTolerance * t.clickTolerance : 36, this.overlay_ = new ps({
25747      source: new ys({
25748        useSpatialIndex: !1,
25749        wrapX: t.wrapX ? t.wrapX : !1
25750      }),
25751      style: t.style ? t.style : Aw(),
25752      updateWhileInteracting: !0
25753    }), this.geometryName_ = t.geometryName, this.condition_ = t.condition ? t.condition : tc, this.freehandCondition_, t.freehand ? this.freehandCondition_ = qo : this.freehandCondition_ = t.freehandCondition ? t.freehandCondition : Og, this.traceCondition_, this.setTrace(t.trace || !1), this.traceState_ = { active: !1 }
25753, this.traceSource_ = t.traceSource || t.source || null, this.addChangeListener(Wl.ACTIVE, this.updateState_);
25754  }
25755  /**
25756   * Toggle tracing mode or set a tracing condition.
25757   *
25758   * @param {boolean|import("../events/condition.js").Condition} trace A boolean to toggle tracing mode or an event
25759   *     condition that will be checked when a feature is clicked to determine if tracing should be active.
25760   */
25761  setTrace(t) {
25762    let i;
25763    t ? t === !0 ? i = qo : i = t : i = vM, this.traceCondition_ = i;
25764  }
25765  /**
25766   * Remove the interaction from its current map and attach it to the new map.
25767   * Subclasses may set up event handlers to get notified about changes to
25768   * the map here.
25769   * @param {import("../Map.js").default} map Map.
25770   */
25771  setMap(t) {
25772    super.setMap(t), this.updateState_();
25773  }
25774  /**
25775   * Get the overlay layer that this interaction renders sketch features to.
25776   * @return {VectorLayer} Overlay layer.
25777   * @api
25778   */
25779  getOverlay() {
25780    return this.overlay_;
25781  }
25782  /**
25783   * Handles the {@link module:ol/MapBrowserEvent~MapBrowserEvent map browser event} and may actually draw or finish the drawing.
25784   * @param {import("../MapBrowserEvent.js").default} event Map browser event.
25785   * @return {boolean} `false` to stop event propagation.
25786   * @api
25787   */
25788  handleEvent(t) {
25789    t.originalEvent.type === et.CONTEXTMENU && t.originalEvent.preventDefault(), this.freehand_ = this.mode_ !== "Point" && this.freehandCondition_(t);
25790    let i = t.type === mt.POINTERMOVE, n = !0;
25791    return !this.freehand_ && this.lastDragTime_ && t.type === mt.POINTERDRAG && (Date.now() - this.lastDragTime_ >= this.dragVertexDelay_ ? (this.downPx_ = t.pixel, this.shouldHandle_ = !this.freehand_, i = !0) : this.lastDragTime_ = void 0, this.shouldHandle_ && this.downTimeout_ !== void 0 && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0)), this.freehand_ && t.type === mt.POINTERDRAG && this.sketchFeature_ !== null ? (this.addToDrawing_(t.coordinate), n = !1) : this.freehand_ && t.type === mt.POINTERDOWN ? n = !1 : i && this.getPointerCount() < 2 ? (n = t.type === mt.POINTERMOVE, n && this.freehand_ ? (this.handlePointerMove_(t), this.shouldHandle_ && t.originalEvent.preventDefault()) : (t.originalEvent.pointerType === "mouse" || t.type === mt.POINTERDRAG && this.downTimeout_ === void 0) && this.handlePointerMove_(t)) : t.type === mt.DBLCLICK && (n = !1), super.handleEvent(t) && n;
25792  }
25793  /**
25794   * Handle pointer down events.
25795   * @param {import("../MapBrowserEvent.js").default} event Event.
25796   * @return {boolean} If the event was consumed.
25797   */
25798  handleDownEvent(t) {
25799    return this.shouldHandle_ = !this.freehand_, this.freehand_ ? (this.downPx_ = t.pixel, this.finishCoordinate_ || this.startDrawing_(t.coordinate), !0) : this.condition_(t) ? (this.lastDragTime_ = Date.now(), this.downTimeout_ = setTimeout(() => {
25800      this.handlePointerMove_(
25801        new Ei(
25802          mt.POINTERMOVE,
25803          t.map,
25804          t.originalEvent,
25805          !1,
25806          t.frameState
25807        )
25808      );
25809    }, this.dragVertexDelay_), this.downPx_ = t.pixel, !0) : (this.lastDragTime_ = void 0, !1);
25810  }
25811  /**
25812   * @private
25813   */
25814  deactivateTrace_() {
25815    this.traceState_ = { active: !1 };
25816  }
25817  /**
25818   * Activate or deactivate trace state based on a browser event.
25819   * @param {import("../MapBrowserEvent.js").default} event Event.
25820   * @private
25821   */
25822  toggleTraceState_(t) {
25823    if (!this.traceSource_ || !this.traceCondition_(t))
25824      return;
25825    if (this.traceState_.active) {
25826      this.deactivateTrace_();
25827      return;
25828    }
25829    const i = this.getMap(), n = i.getCoordinateFromPixel([
25830      t.pixel[0] - this.snapTolerance_,
25831      t.pixel[1] + this.snapTolerance_
25832    ]), s = i.getCoordinateFromPixel([
25833      t.pixel[0] + this.snapTolerance_,
25834      t.pixel[1] - this.snapTolerance_
25835    ]), r = ge([n, s]), o = this.traceSource_.getFeaturesInExtent(r);
25836    if (o.length === 0)
25837      return;
25838    const a = Rw(t.coordinate, o);
25839    a.length && (this.traceState_ = {
25840      active: !0,
25841      startPx: t.pixel.slice(),
25842      targets: a,
25843      targetIndex: -1
25844    });
25845  }
25846  /**
25847   * @param {TraceTarget} target The trace target.
25848   * @param {number} endIndex The new end index of the trace.
25849   * @private
25850   */
25851  addOrRemoveTracedCoordinates_(t, i) {
25852    const n = t.startIndex <= t.endIndex, s = t.startIndex <= i;
25853    n === s ? n && i > t.endIndex || !n && i < t.endIndex ? this.addTracedCoordinates_(t, t.endIndex, i) : (n && i < t.endIndex || !n && i > t.endIndex) && this.removeTracedCoordinates_(i, t.endIndex) : (this.removeTracedCoordinates_(t.startIndex, t.endIndex), this.addTracedCoordinates_(t, t.startIndex, i));
25854  }
25855  /**
25856   * @param {number} fromIndex The start index.
25857   * @param {number} toIndex The end index.
25858   * @private
25859   */
25860  removeTracedCoordinates_(t, i) {
25861    if (t === i)
25862      return;
25863    let n = 0;
25864    if (t < i) {
25865      const s = Math.ceil(t);
25866      let r = Math.floor(i);
25867      r === i && (r -= 1), n = r - s + 1;
25868    } else {
25869      const s = Math.floor(t);
25870      let r = Math.ceil(i);
25871      r === i && (r += 1), n = s - r + 1;
25872    }
25873    n > 0 && this.removeLastPoints_(n);
25874  }
25875  /**
25876   * @param {TraceTarget} target The trace target.
25877   * @param {number} fromIndex The start index.
25878   * @param {number} toIndex The end index.
25879   * @private
25880   */
25881  addTracedCoordinates_(t, i, n) {
25882    if (i === n)
25883      return;
25884    const s = [];
25885    if (i < n) {
25886      const r = Math.ceil(i);
25887      let o = Math.floor(n);
25888      o === n && (o -= 1);
25889      for (let a = r; a <= o; ++a)
25890        s.push(os(t.coordinates, a));
25891    } else {
25892      const r = Math.floor(i);
25893      let o = Math.ceil(n);
25894      o === n && (o += 1);
25895      for (let a = r; a >= o; --a)
25896        s.push(os(t.coordinates, a));
25897    }
25898    s.length && this.appendCoordinates(s);
25899  }
25900  /**
25901   * Update the trace.
25902   * @param {import("../MapBrowserEvent.js").default} event Event.
25903   * @private
25904   */
25905  updateTrace_(t) {
25906    const i = this.traceState_;
25907    if (!i.active || i.targetIndex === -1 && Oo(i.startPx, t.pixel) < this.snapTolerance_)
25908      return;
25909    const n = Pw(
25910      t.coordinate,
25911      i,
25912      this.getMap(),
25913      this.snapTolerance_
25914    );
25915    if (i.targetIndex !== n.index) {
25916      if (i.targetIndex !== -1) {
25917        const l = i.targets[i.targetIndex];
25918        this.removeTracedCoordinates_(l.startIndex, l.endIndex);
25919      }
25920      const a = i.targets[n.index];
25921      this.addTracedCoordinates_(
25922        a,
25923        a.startIndex,
25924        n.endIndex
25925      );
25926    } else {
25927      const a = i.targets[i.targetIndex];
25928      this.addOrRemoveTracedCoordinates_(a, n.endIndex);
25929    }
25930    i.targetIndex = n.index;
25931    const s = i.targets[i.targetIndex];
25932    s.endIndex = n.endIndex;
25933    const r = as(
25934      s.coordinates,
25935      s.endIndex
25936    ), o = this.getMap().getPixelFromCoordinate(r);
25937    t.coordinate = r, t.pixel = [Math.round(o[0]), Math.round(o[1])];
25938  }
25939  /**
25940   * Handle pointer up events.
25941   * @param {import("../MapBrowserEvent.js").default} event Event.
25942   * @return {boolean} If the event was consumed.
25943   */
25944  handleUpEvent(t) {
25945    let i = !0;
25946    if (this.getPointerCount() === 0) {
25947      this.downTimeout_ && (clearTimeout(this.downTimeout_), this.downTimeout_ = void 0), this.handlePointerMove_(t);
25948      const n = this.traceState_.active;
25949      if (this.toggleTraceState_(t), this.shouldHandle_) {
25950        const s = !this.finishCoordinate_;
25951        s && this.startDrawing_(t.coordinate), !s && this.freehand_ ? this.finishDrawing() : !this.freehand_ && (!s || this.mode_ === "Point") && (this.atFinish_(t.pixel, n) ? this.finishCondition_(t) && this.finishDrawing() : this.addToDrawing_(t.coordinate)), i = !1;
25952      } else
25953        this.freehand_ && this.abortDrawing();
25954    }
25955    return !i && this.stopClick_ && t.preventDefault(), i;
25956  }
25957  /**
25958   * Handle move events.
25959   * @param {import("../MapBrowserEvent.js").default} event A move event.
25960   * @private
25961   */
25962  handlePointerMove_(t) {
25963    if (this.pointerType_ = t.originalEvent.pointerType, this.downPx_ && (!this.freehand_ && this.shouldHandle_ || this.freehand_ && !this.shouldHandle_)) {
25964      const i = this.downPx_, n = t.pixel, s = i[0] - n[0], r = i[
259641] - n[1], o = s * s + r * r;
25965      if (this.shouldHandle_ = this.freehand_ ? o > this.squaredClickTolerance_ : o <= this.squaredClickTolerance_, !this.shouldHandle_)
25966        return;
25967    }
25968    if (!this.finishCoordinate_) {
25969      this.createOrUpdateSketchPoint_(t.coordinate.slice());
25970      return;
25971    }
25972    this.updateTrace_(t), this.modifyDrawing_(t.coordinate);
25973  }
25974  /**
25975   * Determine if an event is within the snapping tolerance of the start coord.
25976   * @param {import("../pixel.js").Pixel} pixel Pixel.
25977   * @param {boolean} [tracing] Drawing in trace mode (only stop if at the starting point).
25978   * @return {boolean} The event is within the snapping tolerance of the start.
25979   * @private
25980   */
25981  atFinish_(t, i) {
25982    let n = !1;
25983    if (this.sketchFeature_) {
25984      let s = !1, r = [this.finishCoordinate_];
25985      const o = this.mode_;
25986      if (o === "Point")
25987        n = !0;
25988      else if (o === "Circle")
25989        n = this.sketchCoords_.length === 2;
25990      else if (o === "LineString")
25991        s = !i && this.sketchCoords_.length > this.minPoints_;
25992      else if (o === "Polygon") {
25993        const a = (
25994          /** @type {PolyCoordType} */
25995          this.sketchCoords_
25996        );
25997        s = a[0].length > this.minPoints_, r = [
25998          a[0][0],
25999          a[0][a[0].length - 2]
26000        ], i ? r = [a[0][0]] : r = [
26001          a[0][0],
26002          a[0][a[0].length - 2]
26003        ];
26004      }
26005      if (s) {
26006        const a = this.getMap();
26007        for (let l = 0, h = r.length; l < h; l++) {
26008          const c = r[l], u = a.getPixelFromCoordinate(c), d = t[0] - u[0], f = t[1] - u[1], g = this.freehand_ ? 1 : this.snapTolerance_;
26009          if (n = Math.sqrt(d * d + f * f) <= g, n) {
26010            this.finishCoordinate_ = c;
26011            break;
26012          }
26013        }
26014      }
26015    }
26016    return n;
26017  }
26018  /**
26019   * @param {import("../coordinate").Coordinate} coordinates Coordinate.
26020   * @private
26021   */
26022  createOrUpdateSketchPoint_(t) {
26023    this.sketchPoint_ ? this.sketchPoint_.getGeometry().setCoordinates(t) : (this.sketchPoint_ = new ke(new Ne(t)), this.updateSketchFeatures_());
26024  }
26025  /**
26026   * @param {import("../geom/Polygon.js").default} geometry Polygon geometry.
26027   * @private
26028   */
26029  createOrUpdateCustomSketchLine_(t) {
26030    this.sketchLine_ || (this.sketchLine_ = new ke());
26031    const i = t.getLinearRing(0);
26032    let n = this.sketchLine_.getGeometry();
26033    n ? (n.setFlatCoordinates(
26034      i.getLayout(),
26035      i.getFlatCoordinates()
26036    ), n.changed()) : (n = new Qi(
26037      i.getFlatCoordinates(),
26038      i.getLayout()
26039    ), this.sketchLine_.setGeometry(n));
26040  }
26041  /**
26042   * Start the drawing.
26043   * @param {import("../coordinate.js").Coordinate} start Start coordinate.
26044   * @private
26045   */
26046  startDrawing_(t) {
26047    const i = this.getMap().getView().getProjection(), n = Uo(this.geometryLayout_);
26048    for (; t.length < n; )
26049      t.push(0);
26050    this.finishCoordinate_ = t, this.mode_ === "Point" ? this.sketchCoords_ = t.slice() : this.mode_ === "Polygon" ? (this.sketchCoords_ = [[t.slice(), t.slice()]], this.sketchLineCoords_ = this.sketchCoords_[0]) : this.sketchCoords_ = [t.slice(), t.slice()], this.sketchLineCoords_ && (this.sketchLine_ = new ke(new Qi(this.sketchLineCoords_)));
26051    const s = this.geometryFunction_(
26052      this.sketchCoords_,
26053      void 0,
26054      i
26055    );
26056    this.sketchFeature_ = new ke(), this.geometryName_ && this.sketchFeature_.setGeometryName(this.geometryName_), this.sketchFeature_.setGeometry(s), this.updateSketchFeatures_(), this.dispatchEvent(
26057      new uo(co.DRAWSTART, this.sketchFeature_)
26058    );
26059  }
26060  /**
26061   * Modify the drawing.
26062   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
26063   * @private
26064   */
26065  modifyDrawing_(t) {
26066    const i = this.getMap(), n = this.sketchFeature_.getGeometry(), s = i.getView().getProjection(), r = Uo(this.geometryLayout_);
26067    let o, a;
26068    for (; t.length < r; )
26069      t.push(0);
26070    this.mode_ === "Point" ? a = this.sketchCoords_ : this.mode_ === "Polygon" ? (o = /** @type {PolyCoordType} */
26071    this.sketchCoords_[0], a = o[o.length - 1], this.atFinish_(i.getPixelFromCoordinate(t)) && (t = this.finishCoordinate_.slice())) : (o = this.sketchCoords_, a = o[o.length - 1]), a[0] = t[0], a[1] = t[1], this.geometryFunction_(
26072      /** @type {!LineCoordType} */
26073      this.sketchCoords_,
26074      n,
26075      s
26076    ), this.sketchPoint_ && this.sketchPoint_.getGeometry().setCoordinates(t), n.getType() === "Polygon" && this.mode_ !== "Polygon" ? this.createOrUpdateCustomSketchLine_(
26077      /** @type {Polygon} */
26078      n
26079    ) : this.sketchLineCoords_ && this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_), this.updateSketchFeatures_();
26080  }
26081  /**
26082   * Add a new coordinate to the drawing.
26083   * @param {!PointCoordType} coordinate Coordinate
26084   * @private
26085   */
26086  addToDrawing_(t) {
26087    const i = this.sketchFeature_.getGeometry(), n = this.getMap().getView().getProjection();
26088    let s, r;
26089    const o = this.mode_;
26090    o === "LineString" || o === "Circle" ? (this.finishCoordinate_ = t.slice(), r = /** @type {LineCoordType} */
26091    this.sketchCoords_, r.length >= this.maxPoints_ && (this.freehand_ ? r.pop() : s = !0), r.push(t.slice()), this.geometryFunction_(r, i, n)) : o === "Polygon" && (r = /** @type {PolyCoordType} */
26092    this.sketchCoords_[0], r.length >= this.maxPoints_ && (this.freehand_ ? r.pop() : s = !0), r.push(t.slice()), s && (this.finishCoordinate_ = r[0]), this.geometryFunction_(this.sketchCoords_, i, n)), this.createOrUpdateSketchPoint_(t.slice()), this.updateSketchFeatures_(), s && this.finishDrawing();
26093  }
26094  /**
26095   * @param {number} n The number of points to remove.
26096   */
26097  removeLastPoints_(t) {
26098    if (!this.sketchFeature_)
26099      return;
26100    const i = this.sketchFeature_.getGeometry(), n = this.getMap().getView().getProjection(), s = this.mode_;
26101    for (let r = 0; r < t; ++r) {
26102      let o;
26103      if (s === "LineString" || s === "Circle") {
26104        if (o = /** @type {LineCoordType} */
26105        this.sketchCoords_, o.splice(-2, 1), o.length >= 2) {
26106          this.finishCoordinate_ = o[o.length - 2].slice();
26107          const a = this.finishCoordinate_.slice();
26108          o[o.length - 1] = a, this.createOrUpdateSketchPoint_(a);
26109        }
26110        this.geometryFunction_(o, i, n), i.getType() === "Polygon" && this.sketchLine_ && this.createOrUpdateCustomSketchLine_(
26111          /** @type {Polygon} */
26112          i
26113        );
26114      } else if (s === "Polygon") {
26115        o = /** @type {PolyCoordType} */
26116        this.sketchCoords_[0], o.splice(-2, 1);
26117        const a = this.sketchLine_.getGeometry();
26118        if (o.length >= 2) {
26119          const l = o[o.length - 2].slice();
26120          o[o.length - 1] = l, this.createOrUpdateSketchPoint_(l);
26121        }
26122        a.setCoordinates(o), this.geometryFunction_(this.sketchCoords_, i, n);
26123      }
26124      if (o.length === 1) {
26125        this.abortDrawing();
26126        break;
26127      }
26128    }
26129    this.updateSketchFeatures_();
26130  }
26131  /**
26132   * Remove last point of the feature currently being drawn. Does not do anything when
26133   * drawing POINT or MULTI_POINT geometries.
26134   * @api
26135   */
26136  removeLastPoint() {
26137    this.removeLastPoints_(1);
26138  }
26139  /**
26140   * Stop drawing and add the sketch feature to the target layer.
26141   * The {@link module:ol/interaction/Draw~DrawEventType.DRAWEND} event is
26142   * dispatched before inserting the feature.
26143   * @api
26144   */
26145  finishDrawing() {
26146    const t = this.abortDrawing_();
26147    if (!t)
26148      return;
26149    let i = this.sketchCoords_;
26150    const n = t.getGeometry(), s = this.getMap().getView().getProjection();
26151    this.mode_ === "LineString" ? (i.pop(), this.geometryFunction_(i, n, s)) : this.mode_ === "Polygon" && (i[0].pop(), this.geometryFunction_(i, n, s), i = n.getCoordinates()), this.type_ === "MultiPoint" ? t.setGeometry(
26152      new gc([
26153        /** @type {PointCoordType} */
26154        i
26155      ])
26156    ) : this.type_ === "MultiLineString" ? t.setGeometry(
26157      new dc([
26158        /** @type {LineCoordType} */
26159        i
26160      ])
26161    ) : this.type_ === "MultiPolygon" && t.setGeometry(
26162      new mc([
26163        /** @type {PolyCoordType} */
26164        i
26165      ])
26166    ), this.dispatchEvent(new uo(co.DRAWEND, t)), this.features_ && this.features_.push(t), this.source_ && this.source_.addFeature(t);
26167  }
26168  /**
26169   * Stop drawing without adding the sketch feature to the target layer.
26170   * @return {Feature<import("../geom/SimpleGeometry.js").default>|null} The sketch feature (or null if none).
26171   * @private
26172   */
26173  abortDrawing_() {
26174    this.finishCoordinate_ = null;
26175    const t = this.sketchFeature_;
26176    return this.sketchFeature_ = null, this.sketchPoint_ = null, this.sketchLine_ = null, this.overlay_.getSource().clear(!0), this.deactivateTrace_(), t;
26177  }
26178  /**
26179   * Stop drawing without adding the sketch feature to the target layer.
26180   * @api
26181   */
26182  abortDrawing() {
26183    const t = this.abortDrawing_();
26184    t && this.dispatchEvent(new uo(co.DRAWABORT, t));
26185  }
26186  /**
26187   * Append coordinates to the end of the geometry that is currently being drawn.
26188   * This can be used when drawing LineStrings or Polygons. Coordinates will
26189   * either be appended to the current LineString or the outer ring of the current
26190   * Polygon. If no geometry is being drawn, a new one will be created.
26191   * @param {!LineCoordType}
26191 coordinates Linear coordinates to be appended to
26192   * the coordinate array.
26193   * @api
26194   */
26195  appendCoordinates(t) {
26196    const i = this.mode_, n = !this.sketchFeature_;
26197    n && this.startDrawing_(t[0]);
26198    let s;
26199    if (i === "LineString" || i === "Circle")
26200      s = /** @type {LineCoordType} */
26201      this.sketchCoords_;
26202    else if (i === "Polygon")
26203      s = this.sketchCoords_ && this.sketchCoords_.length ? (
26204        /** @type {PolyCoordType} */
26205        this.sketchCoords_[0]
26206      ) : [];
26207    else
26208      return;
26209    n && s.shift(), s.pop();
26210    for (let o = 0; o < t.length; o++)
26211      this.addToDrawing_(t[o]);
26212    const r = t[t.length - 1];
26213    this.addToDrawing_(r), this.modifyDrawing_(r);
26214  }
26215  /**
26216   * Initiate draw mode by starting from an existing geometry which will
26217   * receive new additional points. This only works on features with
26218   * `LineString` geometries, where the interaction will extend lines by adding
26219   * points to the end of the coordinates array.
26220   * This will change the original feature, instead of drawing a copy.
26221   *
26222   * The function will dispatch a `drawstart` event.
26223   *
26224   * @param {!Feature<LineString>} feature Feature to be extended.
26225   * @api
26226   */
26227  extend(t) {
26228    const n = t.getGeometry();
26229    this.sketchFeature_ = t, this.sketchCoords_ = n.getCoordinates();
26230    const s = this.sketchCoords_[this.sketchCoords_.length - 1];
26231    this.finishCoordinate_ = s.slice(), this.sketchCoords_.push(s.slice()), this.sketchPoint_ = new ke(new Ne(s)), this.updateSketchFeatures_(), this.dispatchEvent(
26232      new uo(co.DRAWSTART, this.sketchFeature_)
26233    );
26234  }
26235  /**
26236   * Redraw the sketch features.
26237   * @private
26238   */
26239  updateSketchFeatures_() {
26240    const t = [];
26241    this.sketchFeature_ && t.push(this.sketchFeature_), this.sketchLine_ && t.push(this.sketchLine_), this.sketchPoint_ && t.push(this.sketchPoint_);
26242    const i = this.overlay_.getSource();
26243    i.clear(!0), i.addFeatures(t);
26244  }
26245  /**
26246   * @private
26247   */
26248  updateState_() {
26249    const t = this.getMap(), i = this.getActive();
26250    (!t || !i) && this.abortDrawing(), this.overlay_.setMap(i ? t : null);
26251  }
26252}
26253function Aw() {
26254  const e = Ug();
26255  return function(t, i) {
26256    return e[t.getGeometry().getType()];
26257  };
26258}
26259function Ow(e) {
26260  switch (e) {
26261    case "Point":
26262    case "MultiPoint":
26263      return "Point";
26264    case "LineString":
26265    case "MultiLineString":
26266      return "LineString";
26267    case "Polygon":
26268    case "MultiPolygon":
26269      return "Polygon";
26270    case "Circle":
26271      return "Circle";
26272    default:
26273      throw new Error("Invalid type: " + e);
26274  }
26275}
26276const Fw = Lw;
26277function yd(e) {
26278  return (
26279    /** @type {import("../source/Vector.js").VectorSourceEvent} */
26280    e.feature ? (
26281      /** @type {import("../source/Vector.js").VectorSourceEvent} */
26282      e.feature
26283    ) : (
26284      /** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */
26285      e.element ? (
26286        /** @type {import("../Collection.js").CollectionEvent<import("../Feature.js").default>} */
26287        e.element
26288      ) : null
26289    )
26290  );
26291}
26292const rl = [];
26293class kw extends ln {
26294  /**
26295   * @param {Options} [options] Options.
26296   */
26297  constructor(t) {
26298    t = t || {};
26299    const i = (
26300      /** @type {import("./Pointer.js").Options} */
26301      t
26302    );
26303    i.handleDownEvent || (i.handleDownEvent = An), i.stopDown || (i.stopDown = Gn), super(i), this.source_ = t.source ? t.source : null, this.vertex_ = t.vertex !== void 0 ? t.vertex : !0, this.edge_ = t.edge !== void 0 ? t.edge : !0, this.features_ = t.features ? t.features : null, this.featuresListenerKeys_ = [], this.featureChangeListenerKeys_ = {}, this.indexedFeaturesExtents_ = {}, this.pendingFeatures_ = {}, this.pixelTolerance_ = t.pixelTolerance !== void 0 ? t.pixelTolerance : 10, this.rBush_ = new Zo(), this.GEOMETRY_SEGMENTERS_ = {
26304      Point: this.segmentPointGeometry_.bind(this),
26305      LineString: this.segmentLineStringGeometry_.bind(this),
26306      LinearRing: this.segmentLineStringGeometry_.bind(this),
26307      Polygon: this.segmentPolygonGeometry_.bind(this),
26308      MultiPoint: this.segmentMultiPointGeometry_.bind(this),
26309      MultiLineString: this.segmentMultiLineStringGeometry_.bind(this),
26310      MultiPolygon: this.segmentMultiPolygonGeometry_.bind(this),
26311      GeometryCollection: this.segmentGeometryCollectionGeometry_.bind(this),
26312      Circle: this.segmentCircleGeometry_.bind(this)
26313    };
26314  }
26315  /**
26316   * Add a feature to the collection of features that we may snap to.
26317   * @param {import("../Feature.js").default} feature Feature.
26318   * @param {boolean} [register] Whether to listen to the feature change or not
26319   *     Defaults to `true`.
26320   * @api
26321   */
26322  addFeature(t, i) {
26323    i = i !== void 0 ? i : !0;
26324    const n = lt(t), s = t.getGeometry();
26325    if (s) {
26326      const r = this.GEOMETRY_SEGMENTERS_[s.getType()];
26327      if (r) {
26328        this.indexedFeaturesExtents_[n] = s.getExtent(
26329          be()
26330        );
26331        const o = (
26332          /** @type {Array<Array<import('../coordinate.js').Coordinate>>} */
26333          []
26334        );
26335        if (r(o, s), o.length === 1)
26336          this.rBush_.insert(ge(o[0]), {
26337            feature: t,
26338            segment: o[0]
26339          });
26340        else if (o.length > 1) {
26341          const a = o.map((h) => ge(h)), l = o.map((h) => ({
26342            feature: t,
26343            segment: h
26344          }));
26345          this.rBush_.load(a, l);
26346        }
26347      }
26348    }
26349    i && (this.featureChangeListenerKeys_[n] = ct(
26350      t,
26351      et.CHANGE,
26352      this.handleFeatureChange_,
26353      this
26354    ));
26355  }
26356  /**
26357   * @return {import("../Collection.js").default<import("../Feature.js").default>|Array<import("../Feature.js").default>} Features.
26358   * @private
26359   */
26360  getFeatures_() {
26361    let t;
26362    return this.features_ ? t = this.features_ : this.source_ && (t = this.source_.getFeatures()), t;
26363  }
26364  /**
26365   * @param {import("../MapBrowserEvent.js").default} evt Map browser event.
26366   * @return {boolean} `false` to stop event propagation.
26367   */
26368  handleEvent(t) {
26369    const i = this.snapTo(t.pixel, t.coordinate, t.map);
26370    return i && (t.coordinate = i.vertex.slice(0, 2), t.pixel = i.vertexPixel), super.handleEvent(t);
26371  }
26372  /**
26373   * @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
26374   * @private
26375   */
26376  handleFeatureAdd_(t) {
26377    const i = yd(t);
26378    i && this.addFeature(i);
26379  }
26380  /**
26381   * @param {import("../source/Vector.js").VectorSourceEvent|import("../Collection.js").CollectionEvent<import("../Feature.js").default>} evt Event.
26382   * @private
26383   */
26384  handleFeatureRemove_(t) {
26385    const i = yd(t);
26386    i && this.removeFeature(i);
26387  }
26388  /**
26389   * @param {import("../events/Event.js").default} evt Event.
26390   * @private
26391   */
26392  handleFeatureChange_(t) {
26393    const i = (
26394      /** @type {import("../Feature.js").default} */
26395      t.target
26396    );
26397    if (this.handlingDownUpSequence) {
26398      const n = lt(i);
26399      n in this.pendingFeatures_ || (this.pendingFeatures_[n] = i);
26400    } else
26401      this.updateFeature_(i);
26402  }
26403  /**
26404   * Handle pointer up events.
26405   * @param {import("../MapBrowserEvent.js").default} evt Event.
26406   * @return {boolean} If the event was consumed.
26407   */
26408  handleUpEvent(t) {
26409    const i = Object.values(this.pendingFeatures_);
26410    return i.length && (i.forEach(this.updateFeature_.bind(this)), this.pendingFeatures_ = {}), !1;
26411  }
26412  /**
26413   * Remove a feature from the collection of features that we may snap to.
26414   * @param {import("../Feature.js").default} feature Feature
26415   * @param {boolean} [unlisten] Whether to unlisten to the feature change
26416   *     or not. Defaults to `true`.
26417   * @api
26418   */
26419  removeFeature(t, i) {
26420    const n = i !== void 0 ? i : !0, s = lt(t), r = this.indexedFeaturesExtents_[s];
26421    if (r) {
26422      const o = this.rBush_, a = [];
26423      o.forEachInExtent(r, function(l) {
26424        t === l.feature && a.push(l);
26425      });
26426      for (let l = a.length - 1; l >= 0; --l)
26427        o.remove(a[l]);
26428    }
26429    n && (St(this.featureChangeListenerKeys_[s]), delete this.featureChangeListenerKeys_[s]);
26430  }
26431  /**
26432   * Remove the interaction from its current map and attach it to the new map.
26433   * Subclasses may set up event handlers to get notified about changes to
26434   * the map here.
26435   * @param {import("../Map.js").default} map Map.
26436   */
26437  setMap(t) {
26438    const i = this.getMap(), n = this.featuresListenerKeys_, s = (
26439      /** @type {Array<import("../Feature.js").default>} */
26440      this.getFeatures_()
26441    );
26442    i && (n.forEach(St), n.length = 0, this.rBush_.clear(), Object.values(this.featureChangeListenerKeys_).forEach(St), this.featureChangeListenerKeys_ = {}), super.setMap(t), t && (this.features_ ? n.push(
26443      ct(
26444        this.features_,
26445        Vt.ADD,
26446        this.handleFeatureAdd_,
26447        this
26448      ),
26449      ct(
26450        this.features_,
26451        Vt.REMOVE,
26452        this.handleFeatureRemove_,
26453        this
26454      )
26455    ) : this.source_ && n.push(
26456      ct(
26457        this.source_,
26458        de.ADDFEATURE,
26459        this.handleFeatureAdd_,
26460        this
26461      ),
26462      ct(
26463        this.source_,
26464        de.REMOVEFEATURE,
26465        this.handleFeatureRemove_,
26466        this
26467      )
26468    ), s.forEach((r) => this.addFeature(r)));
26469  }
26470  /**
26471   * @param {import("../pixel.js").Pixel} pixel Pixel
26472   * @param {import("../coordinate.js").Coordinate} pixelCoordinate Coordinate
26473   * @param {import("../Map.js").default} map Map.
26474   * @return {Result|null} Snap result
26475   */
26476  snapTo(t, i, n) {
26477    n.getView().getProjection();
26478    const s = Lt(i), r = la(
26479      Rn(
26480        ge([s]),
26481        n.getView().getResolution() * this.pixelTolerance_
26482      )
26483    ), o = this.rBush_.getInExtent(r), a = o.length;
26484    if (a === 0)
26485      return null;
26486    let l, h = 1 / 0;
26487    const c = this.pixelTolerance_ * this.pixelTolerance_, u = () => {
26488      if (l) {
26489        const d = n.getPixelFromCoordinate(l);
26490        if (bi(t, d) <= c)
26491          return {
26492            vertex: l,
26493            vertexPixel: [
26494              Math.round(d[0]),
26495              Math.round(d[1])
26496            ]
26497          };
26498      }
26499      return null;
26500    };
26501    if (this.vertex_) {
26502      for (let f = 0; f < a; ++f) {
26503        const g = o[f];
26504        g.feature.getGeometry().getType() !== "Circle" && g.segment.forEach((m) => {
26505          const _ = Lt(m), p = bi(s, _);
26506          p < h && (l = m, h = p);
26507        });
26508      }
26509      const d = u();
26510      if (d)
26511        return d;
26512    }
26513    if (this.edge_) {
26514      for (let f = 0; f < a; ++f) {
26515        let g = null;
26516        const m = o[f];
26517        if (m.feature.getGeometry().getType() === "Circle") {
26518          let _ = m.feature.getGeometry();
26519          g = Ax(
26520            s,
26521            /** @type {import("../geom/Circle.js").default} */
26522            _
26523          );
26524        } else {
26525          const [_, p] = m.segment;
26526          p && (rl[0] = Lt(_), rl[1] = Lt(p), g = oh(s, rl));
26527        }
26528        if (g) {
26529          const _ = bi(s, g);
26530          _ < h && (l = Pn(g), h = _);
26531        }
26532      }
26533      const d = u();
26534      if (d)
26535        return d;
26536    }
26537    return null;
26538  }
26539  /**
26540   * @param {import("../Feature.js").default} feature Feature
26541   * @private
26542   */
26543  updateFeature_(t) {
26544    this.removeFeature(t, !1), this.addFeature(t, !1);
26545  }
26546  /**
26547   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26548   * @param {import("../geom/Circle.js").default} geometry Geometry.
26549   * @private
26550   */
26551  segmentCircleGeometry_(t, i) {
26552    this.getMap().getView().getProjection();
26553    const r = IC(i).getCoordinates()[0];
26554    for (let o = 0, a = r.length - 1; o < a; ++o)
26555      t.push(r.slice(o, o + 2));
26556  }
26557  /**
26558   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26559   * @param {import("../geom/GeometryCollection.js").default} geometry Geometry.
26560   * @private
26561   */
26562  segmentGeometryCollectionGeometry_(t, i) {
26563    const n = i.getGeometriesArray();
26564    for (let s = 0; s < n.length; ++s) {
26565      const r = this.GEOMETRY_SEGMENTERS_[n[s].getType()];
26566      r && r(t, n[s]);
26567    }
26568  }
26569  /**
26570   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26571   * @param {import("../geom/LineString.js").default} geometry Geometry.
26572   * @private
26573   */
26574  segmentLineStringGeometry_(t, i) {
26575    const n = i.getCoordinates();
26576    for (let s = 0, r = n.length - 1; s < r; ++s)
26577      t.push(n.slice(s, s + 2));
26578  }
26579  /**
26580   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26581   * @param {import("../geom/MultiLineString.js").default} geometry Geometry.
26582   * @private
26583   */
26584  segmentMultiLineStringGeometry_(t, i) {
26585    const n = i.getCoordinates();
26586    for (let s = 0, r = n.length; s < r; ++s) {
26587      const o = n[s];
26588      for (let a = 0, l = o.length - 1; a < l; ++a)
26589        t.push(o.slice(a, a + 2));
26590    }
26591  }
26592  /**
26593   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26594   * @param {import("../geom/MultiPoint.js").default} geometry Geometry.
26595   * @private
26596   */
26597  segmentMultiPointGeometry_(t, i) {
26598    i.getCoordinates().forEach((n) => {
26599      t.push([n]);
26600    });
26601  }
26602  /**
26603   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26604   * @param {import("../geom/MultiPolygon.js").default} geometry Geometry.
26605   * @private
26606   */
26607  segmentMultiPolygonGeometry_(t, i) {
26608    const n = i.getCoordinates();
26609    for (let s = 0, r = n.length; s < r; ++s) {
26610      const o = n[s];
26611      for (let a = 0, l = o.length; a < l; ++a) {
26612        const h = o[a];
26613        for (let c = 0, u = h.length - 1; c < u; ++c)
26614          t.push(h.slice(c, c + 2));
26615      }
26616    }
26617  }
26618  /**
26619   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26620   * @param {import("../geom/Point.js").default} geometry Geometry.
26621   * @private
26622   */
26623  segmentPointGeometry_(t, i) {
26624    t.push([i.getCoordinates()]);
26625  }
26626  /**
26627   * @param {Array<Array<import('../coordinate.js').Coordinate>>} segments Segments
26628   * @param {import("../geom/Polygon.js").default} geometry Geometry.
26629   * @private
26630   */
26631  segmentPolygonGeometry_(t, i) {
26632    const n = i.getCoordinates();
26633    for (let s = 0, r = n.length; s < r; ++s) {
26634      const o = n[s];
26635      for (let a = 0, l = o.length - 1; a < l; ++a)
26636        t.push(o.slice(a, a + 2));
26637    }
26638  }
26639}
26640const Dw = kw, _o = 100, am = {
26641  Point: "Point",
26642  LineString: "LineString",
26643  Polygon: "Polygon"
26644};
26645function Xr(e) {
26646  return Array.isArray(e) ? Array.isArray(e[0]) ? e.map(Xr) : [Math.round(e[0] * _o) / _o, Math.round(e[1] * _o) / _o] : e;
26647}
26648function xd(e) {
26649  var s, r, o;
26650  const t = (s = e == null ? void 0 : e.getGeometry) == null ? void 0 : s.call(e), i = am[(r = t == null ? void 0 : t.getType) == null ? void 0 : r.call(t)];
26651  if (!i)
26652    return null;
26653  const n = (o = t.getCoordinates) == null ? void 0 : o.call(t);
26654  return Array.isArray(n) ? { type: i, coordinates: Xr(n) } : null;
26655}
26656function lm(e) {
26657  if (!e || !Array.isArray(e.coordinates))
26658    return !1;
26659  const t = (i) => new Set(i.map((n) => `${n[0]},${n[1]}`)).size;
26660  switch (e.type) {
26661    case "Point":
26662      return e.coordinates.length === 2 && e.coordinates.every(Number.isFinite);
26663    case "LineString":
26664      return t(e.coordinates) >= 2;
26665    case "Polygon":
26666      return t(e.coordinates[0] || []) >= 3;
26667    default:
26668      return !1;
26669  }
26670}
26671function hm(e, t = 1) {
26672  const i = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(String(e ?? "").trim());
26673  if (!i)
26674    return e;
26675  let n = i[1];
26676  n.length === 3 && (n = n.split("").map((r) => r + r).join(""));
26677  const s = parseInt(n, 16);
26678  return `rgba(${s >> 16 & 255}, ${s >> 8 & 255}, ${s & 255}, ${t})`;
26679}
26680function cm(e) {
26681  if (!e || !Array.isArray(e.coordinates))
26682    return null;
26683  let t;
26684  switch (e.type) {
26685    case "Point":
26686      t = [e.coordinates];
26687      break;
26688    case "LineString":
26689      t = e.coordinates;
26690      break;
26691    case "Polygon":
26692      t = (e.coordinates[0] || []).slice(0, -1);
26693      break;
26694    default:
26695      return null;
26696  }
26697  const i = /* @__PURE__ */ new Set(), n = t.filter((r) => {
26698    if (!Array.isArray(r) || !Number.isFinite(r[0]) || !Number.isFinite(r[1]))
26699      return !1;
26700    const o = `${r[0]},${r[1]}`;
26701    return i.has(o) ? !1 : (i.add(o), !0);
26702  });
26703  if (!n.length)
26704    return null;
26705  const s = n.reduce((r, o) => [r[0] + o[0], r[1] + o[1]], [0, 0]);
26706  return Xr([s[0] / n.length, s[1] / n.length]);
26707}
26708const um = { Point: 0, LineString: 1, Polygon: 2 };
26709function dm(e, t) {
26710  if (!Array.isArray(e))
26711    return null;
26712  if (t === 0) {
26713    const [n, s] = e;
26714    return Number.isFinite(n) && Number.isFinite(s) ? [n, s] : null;
26715  }
26716  const i = [];
26717  for (const n of e) {
26718    const s = dm(n, t - 1);
26719    if (!s)
26720      return null;
26721    i.push(s);
26722  }
26723  return i;
26724}
26725function Nw(e) {
26726  let t = e;
26727  if (typeof t == "string") {
26728    const r = t.trim();
26729    if (!r)
26730      return null;
26731    try {
26732      t = JSON.parse(r);
26733    } catch {
26734      return null;
26735    }
26736  }
26737  if (t && typeof t == "object" && t.type === "Feature" && (t = t.geometry), !t || typeof t != "object" || Array.isArray(t))
26738    return null;
26739  const i = am[t.type];
26740  if (!i)
26741    return null;
26742  const n = dm(t.coordinates, um[i]);
26743  if (!n)
26744    return null;
26745  const s = { type: i, coordinates: n };
26746  return lm(s) ? s : null;
26747}
26748function fm(e, t) {
26749  const i = (n, s) => s === 0 ? t(n) : n.map((r) => i(r, s - 1));
26750  return { type: e.type, coordinates: i(e.coordinates, um[e.type]) };
26751}
26752function po(e, t = 100) {
26753  const i = Math.max(Number.isFinite(Number(t)) ? Number(t) : 100, 1);
26754  let n = 1 / 0, s = 1 / 0, r = -1 / 0, o = -1 / 0;
26755  return fm(e, ([a, l]) => (n = Math.min(n, a), s = Math.min(s, l), r = Math.max(r, a), o = Math.max(o, l), [a, l])), [n - i, s - i, r + i, o + i];
26756}
26757const _c = "EPSG:27700", Gw = "#263746", zw = "#a1d0ca", jw = {
26758  "EPSG:27700": "EPSG:27700",
26759  27700: "EPSG:27700",
26760  "EPSG:4326": "EPSG:4326",
26761  4326: "EPSG:4326"
26762};
26763function pc(e) {
26764  return e == null ? null : jw[String(e).trim().toUpperCase()] || null;
26765}
26766const Ww = /* @__PURE__ */ new Set([
26767  "FeatureCollection",
26768  "Feature",
26769  "Point",
26770  "MultiPoint",
26771  "LineString",
26772  "MultiLineString",
26773  "Polygon",
26774  "MultiPolygon",
26775  "GeometryCollection"
26776]);
26777function Bw(e) {
26778  if (typeof e != "string" || !e.trim())
26779    return { ok: !1, message: "Invalid GeoJSON (empty response)" };
26780  let t;
26781  try {
26782    t = JSON.parse(e);
26783  } catch {
26784    return { ok: !1, message: "Invalid GeoJSON (not JSON)" };
26785  }
26786  return !t || typeof t != "object" || Array.isArray(t) || !Ww.has(t.type) ? { ok: !1, message: 'Invalid GeoJSON (no recognised "type")' } : { ok: !0, object: t };
26787}
26788function Uw(e, t) {
26789  var n, s;
26790  const i = e == null ? "" : String(e).trim();
26791  if (i)
26792    return pc(i);
26793  if (!((s = (n = t == null ? void 0 : t.crs) == null ? void 0 : n.properties) != null && s.name))
26794    return _c;
26795}
26796const $l = (e, t) => String(t).split(".").reduce((i, n) => i == null ? void 0 : i[n], e), vd = (e) => {
26797  if (typeof e == "number")
26798    return Number.isFinite(e) ? e : null;
26799  if (typeof e == "string" && e.trim() !== "") {
26800    const t = Number(e);
26801    return Number.isFinite(t) ? t : null;
26802  }
26803  return null;
26804};
26805function Xw(e, { xField: t, yField: i } = {}) {
26806  const n = [];
26807  let s = 0;
26808  for (const r of e) {
26809    if (!r || typeof r != "object") {
26810      s++;
26811      continue;
26812    }
26813    const o = vd($l(r, t)), a = vd($l(r, i));
26814    if (o === null || a === null) {
26815      s++;
26816      continue;
26817    }
26818    const l = { ...r };
26819    delete l[t], delete l[i], n.push({ type: "Feature", properties: l, geometry: { type: "Point", coordinates: [o, a] } });
26820  }
26821  return { type: "FeatureCollection", features: n, skipped: s };
26822}
26823function $w(e, { xField: t, yField: i, recordsField: n } = {}) {
26824  const s = Bw(e);
26825  if (s.ok)
26826    return { ok: !0, object: s.object, skipped: 0 };
26827  let r;
26828  try {
26829    r = JSON.parse(e);
26830  } catch {
26831    return s;
26832  }
26833  const o = n ? $l(r, n) : r;
26834  if (!Array.isArray(o))
26835    return n ? { ok: !1, message: `Invalid GeoJSON, and "${n}" is not an array of records` } : s;
26836  if (!t || !i)
26837    return { ok: !1, message: "Body is an array of records, not GeoJSON: set x-field and y-field to read it" };
26838  const a = Xw(o, { xField: t, yField: i });
26839  return { ok: !0, object: a, skipped: a.skipped };
26840}
26841const Yw = /* @__PURE__ */ new Set(["", "true", "1", "yes", "on"]), Kw = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
26842function se(e, t = !1) {
26843  if (e == null)
26844    return t;
26845  if (typeof e == "boolean")
26846    return e;
26847  const i = String(e).trim().toLowerCase();
26848  return Yw.has(i) ? !0 : Kw.has(i) ? !1 : t;
26849}
26850const gm = (e, t) => {
26851  const i = Number(e);
26852  return Number.isFinite(i) && i > 0 ? i : t;
26853};
26854function mm({ fillColor: e, strokeColor: t, strokeWidth: i, primary: n, secondary: s } = {}) {
26855  const r = n || Gw, o = s || zw;
26856  return {
26857    stroke: t || r,
26858    strokeWidth: gm(i, 2),
26859    polygonFill: e || hm(o, 0.35),
26860    pointFill: e || o
26861  };
26862}
26863function Vw({ fillColor: e, strokeColor: t, strokeWidth: i, pointRadius: n, primary: s, secondary: r } = {}) {
26864  const o = mm({ fillColor: e, strokeColor: t, strokeWidth: i, primary: s, secondary: r });
26865  return new Sn({
26866    stroke: new Ke({ color: o.stroke, width: o.strokeWidth }),
26867    fill: new Ye({ color: o.polygonFill }),
26868    image: new Fs({
26869      radius: gm(n, 6),
26870      fill: new Ye({ color: o.pointFill }),
26871      stroke: new Ke({ color: o.stroke, width: 2 })
26872    })
26873  });
26874}
26875function qw(e, { layer: t, projection: i } = {}) {
26876  const n = String(e ?? "").trim();
26877  if (!n)
26878    return n;
26879  const s = n.indexOf("#"), r = s === -1 ? n : n.slice(0, s), o = r.indexOf("?"), a = o === -1 ? r : r.slice(0, o), l = o === -1 ? "" : r.slice(o + 1), h = /* @__PURE__ */ new Map();
26880  for (const x of l.split("&")) {
26881    if (!x)
26882      continue;
26883    const E = x.indexOf("="), M = decodeURIComponent(E === -1 ? x : x.slice(0, E)).toLowerCase();
26884    h.set(M, E === -1 ? "" : x.slice(E + 1));
26885  }
26886  const c = /\/wfs\/?$/i.test(a), u = (h.get("service") || "").toLowerCase() === "wfs";
26887  if (!c && !u || h.has("request"))
26888    return n;
26889  const f = a.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i, "").replace(/\/+$/, "").split("/").filter(
26889Boolean), g = c && f.length >= 3 ? f[f.length - 2] : "", m = String(t ?? "").trim() || g, _ = pc(i) || _c, p = [];
26890  h.has("service") || p.push("service=WFS"), h.has("version") || p.push("version=2.0.0"), p.push("request=GetFeature"), !h.has("typenames") && !h.has("typename") && m && p.push(`typeNames=${encodeURIComponent(m)}`), h.has("outputformat") || p.push("outputFormat=application/json"), h.has("srsname") || p.push(`srsName=${encodeURIComponent(_)}`);
26891  const y = l ? l.endsWith("&") ? "" : "&" : "?";
26892  return `${a}${o === -1 ? "" : "?" + l}${o === -1 ? "?" : y}${p.join("&")}`.replace("??", "?");
26893}
26894const Hw = ["select", "fail", "warn"];
26895function Zw(e, t) {
26896  if (e == null)
26897    return null;
26898  const i = /^\s*([0-9]*\.?[0-9]+)\s*(px|m)?\s*$/i.exec(String(e));
26899  if (!i)
26900    return null;
26901  const n = Number(i[1]);
26902  return !Number.isFinite(n) || n < 0 ? null : (i[2] || "").toLowerCase() === "px" ? Number.isFinite(t) && t > 0 ? n * t : null : n;
26903}
26904function Jw(e) {
26905  const t = String(e ?? "").trim().toLowerCase();
26906  return Hw.includes(t) ? t : null;
26907}
26908function Qw(e, t, i) {
26909  if (!Array.isArray(e) || !Array.isArray(t) || !(i >= 0))
26910    return null;
26911  let n = null;
26912  for (const s of e) {
26913    const r = Pa(s, t);
26914    r && r.distance <= i && (!n || r.distance < n.distance) && (n = { feature: s, ...r });
26915  }
26916  return n;
26917}
26918function Pa(e, t) {
26919  var o, a, l;
26920  const i = (o = e == null ? void 0 : e.getGeometry) == null ? void 0 : o.call(e);
26921  if (!(i != null && i.getClosestPoint) || !Array.isArray(t))
26922    return null;
26923  const n = ((a = i.getType) == null ? void 0 : a.call(i)) === "Polygon" && ((l = i.intersectsCoordinate) == null ? void 0 : l.call(i, t)), s = n ? t : i.getClosestPoint(t);
26924  return { distance: n ? 0 : Math.hypot(s[0] - t[0], s[1] - t[1]), closest: s };
26925}
26926function tS(e, t, i) {
26927  if (!(e != null && e.forEachFeatureIntersectingExtent) || !Array.isArray(t))
26928    return [];
26929  const n = [];
26930  return e.forEachFeatureIntersectingExtent(t, (s) => {
26931    const r = Pa(s, i);
26932    r && n.push({ feature: s, ...r });
26933  }), n.sort((s, r) => s.distance - r.distance);
26934}
26935function eS(e, t, i) {
26936  var r;
26937  const n = (r = e == null ? void 0 : e.getSource) == null ? void 0 : r.call(e);
26938  if (!n)
26939    return [];
26940  const s = Math.max(i, 0);
26941  return n.getFeaturesInExtent ? n.getFeaturesInExtent([t[0] - s, t[1] - s, t[0] + s, t[1] + s]) : n.getFeatures ? n.getFeatures() : [];
26942}
26943const ol = (e) => Math.round(e * 100) / 100;
26944function iS(e, t) {
26945  var a, l, h, c, u, d, f;
26946  const i = { ...((l = (a = t.feature).getProperties) == null ? void 0 : l.call(a)) || {} };
26947  delete i.geometry;
26948  const n = ((h = e == null ? void 0 : e.get) == null ? void 0 : h.call(e, "assetId")) || "id", s = i[n], r = (u = (c = t.feature).getGeometry) == null ? void 0 : u.call(c), o = ((d = r == null ? void 0 : r.getType) == null ? void 0 : d.call(r)) === "Point" ? r.getCoordinates() : t.closest;
26949  return {
26950    layerId: ((f = e == null ? void 0 : e.get) == null ? void 0 : f.call(e, "id")) ?? null,
26951    assetId: s == null || s === "" ? null : String(s),
26952    distance: ol(t.distance),
26953    coordinates: [ol(o[0]), ol(o[1])],
26954    properties: i
26955  };
26956}
26957function nS(e, t, { findLayer: i, resolution: n, messages: s, prefer: r } = {}) {
26958  const o = (s == null ? void 0 : s.generic) || "We could not check this location. Please try again.", a = e.message || (s == null ? void 0 : s.rule) || "This location cannot be used. Please choose another.", l = { name: e.name, url: null, layer: e.layer, data: null, status: null, selection: null, warning: null }, h = Jw(e.match), c = Zw(e.within, n);
26959  if (!e.layer || !h || c == null)
26960    return { ...l, passed: !1, reason: "error", message: o };
26961  const u = typeof i == "function" ? i(e.layer) : null;
26962  if (!u)
26963    return h !== "select" ? { ...l, passed: !0, reason: null, message: null } : { ...l, passed: !1, reason: "error", message: o };
26964  if (!Array.isArray(t))
26965    return h !== "select" ? { ...l, passed: !0, reason: null, message: null } : { ...l, passed: !1, reason: "rule", message: a };
26966  const d = h === "select" && (r != null && r.feature) && r.layerId === e.layer ? Pa(r.feature, t) : null, f = d && d.distance <= c ? { feature: r.feature, ...d } : Qw(eS(u, t, c), t, c), g = f ? iS(u, f) : null;
26967  return h === "select" ? f ? { ...l, passed: !0, reason: null, message: null, data: g, selection: g } : { ...l, passed: !1, reason: "rule", message: a } : h === "warn" ? f ? { ...l, passed: !0, reason: null, message: null, data: g, warning: a } : { ...l, passed: !0, reason: null, message: null } : f ? { ...l, passed: !1, reason: "rule", message: a, data: g } : { ...l, passed: !0, reason: null, message: null };
26968}
26969const _m = 8e3, sS = 27700, Vs = "We could not check this location. Please try again.", Ed = "This location cannot be used. Please choose another.", Yl = (e) => e !== null && typeof e == "object" && !Array.isArray(e);
26970function rS(e, [t, i]) {
26971  const n = String(e ?? ""), s = n.indexOf("#"), r = s === -1 ? n : n.slice(0, s), o = r.includes("?") ? r.endsWith("?") || r.endsWith("&") ? "" : "&" : "?";
26972  return `${r}${o}x=${encodeURIComponent(t)}&y=${encodeURIComponent(i)}`;
26973}
26974function oS(e, t) {
26975  const i = {};
26976  return e.apiKey && (i["x-api-key"] = e.apiKey), (t == null ? void 0 : t.type) === "Point" ? { url: rS(e.url, t.coordinates), init: { method: "GET", headers: i } }
26976 : (i["content-type"] = "application/json", {
26977    url: String(e.url ?? ""),
26978    init: { method: "POST", headers: i, body: JSON.stringify({ geometry: t, srid: sS }) }
26979  });
26980}
26981function pm(e) {
26982  return e == null ? !0 : Array.isArray(e) ? e.length === 0 : Yl(e) ? Array.isArray(e.matches) ? e.matches.length === 0 : Array.isArray(e.results) ? e.results.every(pm) : e.found === !1 ? !0 : Object.keys(e).length === 0 : !1;
26983}
26984function aS(e, { required: t = !1 } = {}) {
26985  const i = typeof e == "string" && /^(true|false)$/i.test(e.trim()) ? e.trim().toLowerCase() === "true" : e;
26986  return i === !0 ? { passed: !0, reason: null } : i === !1 ? { passed: !1, reason: "rule" } : t && pm(i) ? { passed: !1, reason: "empty" } : { passed: !0, reason: null };
26987}
26988const al = (e, t) => Number.isFinite(Number(e)) && Number.isFinite(Number(t)) ? [Number(e), Number(t)] : null;
26989function Kl(e, t = 8) {
26990  let i = null;
26991  const n = (s, r) => {
26992    if (r > t || s == null || typeof s != "object")
26993      return null;
26994    if (Array.isArray(s)) {
26995      for (const o of s) {
26996        const a = n(o, r + 1);
26997        if (a)
26998          return a;
26999      }
27000      return null;
27001    }
27002    if (s.type === "Point" && Array.isArray(s.coordinates)) {
27003      const o = al(s.coordinates[0], s.coordinates[1]);
27004      if (o)
27005        return o;
27006    }
27007    i || (i = al(s.easting, s.northing) || al(s.x, s.y) || null);
27008    for (const o of Object.keys(s)) {
27009      const a = n(s[o], r + 1);
27010      if (a)
27011        return a;
27012    }
27013    return null;
27014  };
27015  return n(e, 0) || i;
27016}
27017function lS(e, t, i = 8) {
27018  const n = String(t ?? "").trim();
27019  if (!n)
27020    return null;
27021  let s = null;
27022  const r = (g, m, _) => {
27023    if (m > i || g == null || typeof g != "object")
27024      return null;
27025    if (Array.isArray(g)) {
27026      for (const E of g) {
27027        const M = r(E, m + 1, _);
27028        if (M)
27029          return M;
27030      }
27031      return null;
27032    }
27033    const p = typeof g.layer == "string" ? g.layer : _, y = Yl(g.attributes) ? g.attributes : null;
27034    if (Object.prototype.hasOwnProperty.call(g, n) || y && Object.prototype.hasOwnProperty.call(y, n))
27035      return { node: g, layer: p };
27036    !s && Kl(g, 1) && (s = { node: g, layer: p });
27037    for (const E of Object.keys(g)) {
27038      if (E === "attributes")
27039        continue;
27040      const M = r(g[E], m + 1, p);
27041      if (M)
27042        return M;
27043    }
27044    return null;
27045  }, o = r(e, 0, null) || s;
27046  if (!o)
27047    return null;
27048  const { node: a, layer: l } = o, h = Yl(a.attributes) ? a.attributes : {}, c = Object.prototype.hasOwnProperty.call(a, n) ? a[n] : h[n], u = Kl(a), d = { ...h };
27049  for (const g of ["id", "name"])
27050    a[g] != null && !(g in d) && (d[g] = a[g]);
27051  const f = Number.isFinite(Number(a.distance)) ? Math.round(Number(a.distance) * 100) / 100 : null;
27052  return {
27053    layerId: l ?? null,
27054    assetId: c == null || c === "" ? null : String(c),
27055    distance: f,
27056    coordinates: u ? [Math.round(u[0] * 100) / 100, Math.round(u[1] * 100) / 100] : null,
27057    properties: d
27058  };
27059}
27060async function hS(e, t, { fetchFn: i = globalThis.fetch, timeoutMs: n, signal: s, findLayer: r, resolution: o, prefer: a } = {}) {
27061  if (e.layer || !e.url && (e.within != null || e.match)) {
27062    const p = (t == null ? void 0 : t.type) === "Point" ? t.coordinates : String(e.match ?? "").toLowerCase() === "select" ? null : cm(t);
27063    return nS(e, p, { findLayer: r, resolution: o, prefer: a, messages: { generic: Vs, rule: Ed } });
27064  }
27065  const { url: l, init: h } = oS(e, t), c = e.message || Ed, u = { name: e.name, url: l, data: null, status: null }, d = new AbortController();
27066  let f = !1;
27067  const g = Number.isFinite(Number(n ?? e.timeout)) && Number(n ?? e.timeout) > 0 ? Number(n ?? e.timeout) : _m, m = setTimeout(() => {
27068    f = !0, d.abort();
27069  }, g), _ = () => d.abort();
27070  s && (s.aborted ? _() : s.addEventListener("abort", _, { once: !0 }));
27071  try {
27072    const p = await i(l, { ...h, signal: d.signal }), y = await p.text();
27073    if (!p.ok)
27074      return { ...u, status: p.status, passed: !1, reason: "error", message: Vs };
27075    let x;
27076    try {
27077      x = y.trim() === "" ? null : JSON.parse(y);
27078    } catch {
27079      return { ...u, status: p.status, passed: !1, reason: "error", message: Vs };
27080    }
27081    const { passed: E, reason: M } = aS(x, { required: !!e.required }), w = E && e.assetId && x !== null && typeof x == "object" ? lS(x, e.assetId) : null;
27082    return { ...u, status: p.status, data: x, passed: E, reason: M, message: E ? null : c, selection: w };
27083  } catch (p) {
27084    return (p == null ? void 0 : p.name) === "AbortError" || d.signal.aborted ? f ? { ...u, passed: !1, reason: "timeout", message: Vs } : { ...u, passed: !1, reason: "aborted", message: null } : { ...u, passed: !1, reason: "error", message: Vs };
27085  } finally {
27086    clearTimeout(m), s && s.removeEventListener("abort", _);
27087  }
27088}
27089function cS(e) {
27090  const t = {};
27091  let i = !0;
27092  for (const n of e)
27093    t[n.name] = { passed: n.passed, data: n.data, reason: n.reason, warning: n.warning ?? null }, n.passed || (i = !1);
27094  return { passed: i, results: t };
27095}
27096let Cd = 0;
27097function yc() {
27098  return Cd += 1, Cd;
27099}
27100const vs = (e) => e == null ? "" : String(e).trim();
27101function ym({ layerTitle: e, layerId: t, layer: i } = {}) {
27102  return vs(e) || vs(t) || vs(i) || "Layer";
27103}
27104function uS(e) {
27105  return vs(e) || "Legend";
27106}
27107function dS(e, t, i) {
27108  const n = vs(i);
27109  return n ? [n] : e != null && e.getLegendUrl ? vs(t).split(",").map((s) => s.trim()).filter(Boolean).map((s) => e.getLegendUrl(void 0, { LAYER: s })).filter(Boolean) : [];
27110}
27111const fS = {
27112  Point: "point",
27113  MultiPoint: "point",
27114  LineString: "line",
27115  MultiLineString: "line",
27116  Polygon: "polygon",
27117  MultiPolygon: "polygon"
27118};
27119function gS(e) {
27120  var i, n, s;
27121  let t = null;
27122  for (const r of e || []) {
27123    const o = fS[(s = (n = (i = r == null ? void 0 : r.getGeometry) == null ? void 0 : i.call(r)) == null ? void 0 : n.getType) == null ? void 0 : s.call(n)];
27124    if (o) {
27125      if (t && t !== o)
27126        return "polygon";
27127      t = o;
27128    }
27129  }
27130  return t;
27131}
27132function mS(e, t) {
27133  const i = t || "polygon";
27134  return {
27135    shape: i,
27136    fill: i === "point" ? e.pointFill : i === "polygon" ? e.polygonFill : "none",
27137    stroke: e.stroke,
27138    strokeWidth: e.strokeWidth
27139  };
27140}
27141function _S(e) {
27142  return (e || []).filter((t) => t && t.visible !== !1).slice().sort((t, i) => (i.zIndex || 0) - (t.zIndex || 0) || (i.seq || 0) - (t.seq || 0));
27143}
27144const pS = { enableHighAccuracy: !0, timeout: 15e3, maximumAge: 1e4 }, yS = 3e4, xS = 100, Vl = 2e3, To = {
27145  finding: "Finding your location…",
27146  shown: "Your location is shown on the map.",
27147  denied: "Location access is turned off for this site. Allow it in your browser settings, or move the map yourself.",
27148  unavailable: "Your location could not be found. Move the map to the place instead.",
27149  timeout: "Finding your location took too long. Try again, or move the map yourself.",
27150  unsupported: "Your browser cannot share your location here."
27151};
27152function vS(e = globalThis) {
27153  var n;
27154  if ((e == null ? void 0 : e.isSecureContext) === !1)
27155    return "insecure";
27156  if (!((n = e == null ? void 0 : e.navigator) != null && n.geolocation))
27157    return "unsupported";
27158  const t = e.document, i = (t == null ? void 0 : t.permissionsPolicy) || (t == null ? void 0 : t.featurePolicy);
27159  try {
27160    if (i != null && i.allowsFeature && i.allowsFeature("geolocation") === !1)
27161      return "blocked";
27162  } catch {
27163  }
27164  return "ok";
27165}
27166function ES(e) {
27167  return e && typeof e.code == "string" ? e.code : { 1: "denied", 2: "unavailable", 3: "timeout" }[e == null ? void 0 : e.code] || "unavailable";
27168}
27169function CS(e) {
27170  const t = Number(e);
27171  return Number.isFinite(t) ? Math.min(Math.max(t, xS), Vl) : Vl;
27172}
27173function xm(e) {
27174  const t = Number(e);
27175  return !Number.isFinite(t) || t > Vl;
27176}
27177function vm(e) {
27178  const t = Number(e);
27179  if (!Number.isFinite(t))
27180    return "an unknown distance";
27181  if (t < 1e3)
27182    return `about ${Math.max(5, Math.round(t / 5) * 5)} metres`;
27183  const i = Math.round(t / 1e3);
27184  return `about ${i} ${i === 1 ? "kilometre" : "kilometres"}`;
27185}
27186function MS({ accuracy: e, centred: t }) {
27187  return t ? xm(e) ? Em(e) : `The map is centred on your location, accurate to ${vm(e)}.` : To.shown;
27188}
27189function Em(e) {
27190  return `Your location is approximate, to within ${vm(e)}. Move the map to the exact place.`;
27191}
27192function bS(e, t) {
27193  const i = Xr(e);
27194  let n = null;
27195  try {
27196    n = Ts(e, "EPSG:27700", "EPSG:4326");
27197  } catch {
27198    n = null;
27199  }
27200  const s = (r) => Math.round(r * 1e6) / 1e6;
27201  return {
27202    coordinates: i,
27203    easting: i[0],
27204    northing: i[1],
27205    longitude: n ? s(n[0]) : null,
27206    latitude: n ? s(n[1]) : null,
27207    accuracy: Number.isFinite(t) ? Math.round(t * 10) / 10 : null
27208  };
27209}
27210const Cm = 10, wS = 50, xc = {
27211  label: "Choose from the list",
27212  placeholder: "Make a selection",
27213  zoom: "Zoom in to list the options.",
27214  none: "There are none in the map view. Move or zoom the map to find one.",
27215  loading: "Loading options…",
27216  unavailable: "Options are not available."
27217}, vc = (e) => e == null ? "" : String(e).trim();
27218function SS(e, t = 1 / 0) {
27219  const i = Number.isFinite(t) && t > 0 ? t : 1 / 0, n = vc(e).toLowerCase();
27220  if (!n)
27221    return { value: i, invalid: !1 };
27222  if (n === "none")
27223    return { value: 1 / 0, invalid: !1 };
27224  const s = Number(n);
27225  return Number.isFinite(s) && s > 0 ? { value: s, invalid: !1 } : { value: i, invalid: !0 };
27226}
27227function TS(e) {
27228  const t = Math.floor(Number(e));
27229  return e == null || e === "" || !Number.isFinite(t) || t < 1 ? Cm : Math.min(t, wS);
27230}
27231const IS = /^[\s\-–—,:;|/]+|[\s\-–—,:;|/]+$/g;
27232function RS(e, t = {}, { assetKey: i = "id", index: n = 0 } = {}) {
27233  const s = t || {}, o = (vc(e) || `{${i}}`).replace(/\{([^{}]+)\}/g, (l, h) => {
27234    const c = s[h.trim()];
27235    return c == null ? "" : String(c);
27236  }).replace(/\s+/g, " ").replace(IS, "").trim();
27237  if (o)
27238    return o;
27239  const a = s[i];
27240  return a == null || a === "" ? `Item ${n + 1}` : String(a);
27241}
27242function PS(e) {
27243  return Number.isFinite(e) ? e < 1e3 ? `${Math.round(e)} m` : `${(e / 1e3).toFixed(1)} km` : "";
27244}
27245const Md = new Intl.Collator(void 0, { numeric: !0, sensitivity: "base" });
27246function LS(e, { template: t, assetKey: i = "id", limit: n = Cm, showDistance: s = !1, chosen: r = null } = {}) {
27247  const o = (g) => {
27248    var _;
27249    const m = (_ = g.properties) == null ? void 0 : _[i];
27250    return m == null || m === "" ? null : String(m);
27251  }, a = r ? o(r) : null, l = /* @__PURE__ */ new Set(), h = [];
27252  for (const g of e || []) {
27253    const m = o(g);
27254    if (m != null) {
27255      if (l.has(m))
27256        continue;
27257      l.add(m);
27258    }
27259    m != null && m === a && g.key !== r.key || h.push(g);
27260  }
27261  const c = h.slice(0, TS(n));
27262  r && !c.some((g) => g.key === r.key) && c.push(r);
27263  const u = c.map((g, m) => {
27264    var p;
27265    const _ = (p = g.properties) == null ? void 0 : p[i];
27266    return {
27267      key: String(g.key),
27268      assetId: _ == null || _ === "" ? null : String(_),
27269      base: RS(t, g.properties, { assetKey: i, index: m }),
27270      distance: Math.round(g.distance * 100) / 100
27271    };
27272  });
27273  u.sort((g, m) => Md.compare(g.base, m.base) || g.distance - m.distance || Md.compare(g.key, m.key));
27274  const d = {};
27275  for (const g of u)
27276    d[g.base] = (d[g.base] || 0) + 1;
27277  const f = {};
27278  return u.map((g) => {
27279    let m = g.base;
27280    return (s || d[g.base] > 1) && (m = `${m} (${PS(g.distance)})`), f[m] = (f[m] || 0) + 1, f[m] > 1 && (m = `${m} ${f[m]}`), { key: g.key, text: m, assetId: g.assetId, distance: g.distance };
27281  });
27282}
27283function AS({ hasLayer: e, loadState: t, resolution: i, maxResolution: n, count: s }) {
27284  return !e || t === "error" ? "unavailable" : Number.isFinite(n) && !(i < n) ? "zoom" : t === "loading" && !s ? "loading" : s ? "ready" : "none";
27285}
27286function OS(e, t, i = {}) {
27287  const n = { ...xc, ...i };
27288  return e === "ready" ? `${t} in the map view, in alphabetical order.` : n[e] || "";
27289}
27290function FS(e, t, { label: i, count: n, texts: s = {} } = {}) {
27291  if (e === t)
27292    return null;
27293  const r = { ...xc, ...s };
27294  return t === "ready" ? `${vc(i) || r.label}: ${n} ${n === 1 ? "option" : "options"} in the map view.` : t === "none" ? r.none : t === "zoom" && (e === "ready" || e === "none") ? r.zoom : null;
27295}
27296function bd(e) {
27297  return (e || []).map((t) => `${t.key}�${t.text}`).join("�");
27298}
27299const kS = `:root,:host{--ol-background-color: white;--ol-accent-background-color: #F5F5F5;--ol-subtle-background-color: rgba(128, 128, 128, .25);--ol-partial-background-color: rgba(255, 255, 255, .75);--ol-foreground-color: #333333;--ol-subtle-foreground-color: #666666;--ol-brand-color: #00AAFF}.ol-box{box-sizing:border-box;border-radius:2px;border:1.5px solid var(--ol-background-color);background-color:var(--ol-partial-background-color)}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:var(--ol-partial-background-color);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute}.ol-scale-line-inner{border:1px solid var(--ol-subtle-foreground-color);border-top:none;color:var(--ol-foreground-color);font-size:10px;text-align:center;margin:1px;will-change:contents,width;transition:all .25s}.ol-scale-bar{position:absolute;bottom:8px;left:8px}.ol-scale-bar-inner{display:flex}.ol-scale-step-marker{width:1px;height:15px;background-color:var(--ol-foreground-color);float:right;z-index:10}.ol-scale-step-text{position:absolute;bottom:-5px;font-size:10px;z-index:11;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color),0 1.5px var(--ol-partial-background-color),1.5px 0 var(--ol-partial-background-color),0 -1.5px var(--ol-partial-background-color)}.ol-scale-text{position:absolute;font-size:12px;text-align:center;bottom:25px;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color),0 1.5px var(--ol-partial-background-color),1.5px 0 var(--ol-partial-background-color),0 -1.5px var(--ol-partial-background-color)}.ol-scale-singlebar{position:relative;height:10px;z-index:9;box-sizing:border-box;border:1px solid var(--ol-foreground-color)}.ol-scale-singlebar-even{background-color:var(--ol-subtle-foreground-color)}.ol-scale-singlebar-odd{background-color:var(--ol-background-color)}
27299.ol-unsupported{display:none}.ol-viewport,.ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-viewport canvas{all:unset}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;-moz-user-select:text;user-select:text}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{position:absolute;background-color:var(--ol-subtle-background-color);border-radius:4px}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}.ol-control button{display:block;margin:1px;padding:0;color:var(--ol-subtle-foreground-color);font-weight:700;text-decoration:none;font-size:inherit;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:var(--ol-background-color);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:hover,.ol-control button:focus{text-decoration:none;outline:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em);display:flex;flex-flow:row-reverse;align-items:center}.ol-attribution a{color:var(--ol-subtle-foreground-color);text-decoration:none}.ol-attribution ul{margin:0;padding:1px .5em;color:var(--ol-foreground-color);text-shadow:0 0 2px var(--ol-background-color);font-size:12px}.ol-attribution li{display:inline;list-style:none}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button{flex-shrink:0}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:var(--ol-partial-background-color)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:block}.ol-overviewmap .ol-overviewmap-map{border:1px solid var(--ol-subtle-foreground-color);height:150px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:0;left:0;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:var(--ol-subtle-background-color)}.ol-overviewmap-box{border:1.5px dotted var(--ol-subtle-foreground-color)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}.ol-control{background-color:var(--xmap-primary);border:1px solid var(--xmap-secondary)}.ol-control button{background-color:var(--xmap-primary);margin:0;color:var(--xmap-secondary);font-size:1.2em;line-height:1.2em}.ol-control button:focus{color:var(--xmap-secondary);outline:1px solid var(--xmap-secondary)}.ol-control button:hover{background-color:var(--xmap-secondary);color:var(--xmap-primary);outline:none;cursor:pointer}.xmap-web-map-container{height:100%;width:100%;display:flex;flex-direction:column;position:relative}.xmap-draw-hud{position:absolute;top:.5em;right:.5em;z-index:1;padding:2px}.xmap-draw-hud button{display:flex;align-items:center;justify-content:center;width:1.7em;height:1.7em;padding:0;line-height:1}.xmap-locate{position:absolute;top:4.2em;left:.5em;z-index:1;padding:0}.xmap-locate button{display:flex;align-items:center;justify-content:center;width:1.375em;height:1.375em;padding:0;line-height:1}.xmap-locate--busy svg{animation:xmap-locate-pulse 1s ease-in-out infinite}@keyframes xmap-locate-pulse{50%{opacity:.35}}@media (prefers-reduced-motion: reduce){.xmap-locate--busy svg{animation:none}}.xmap-check-banner{position:absolute;
27299left:.5em;right:.5em;bottom:.5em;z-index:1;padding:.5em .75em;border-radius:4px;border:1px solid var(--xmap-secondary);background-color:var(--xmap-primary);color:var(--xmap-secondary);font-size:.95em;line-height:1.3;pointer-events:none}.xmap-check-banner--fail{border-left:.4em solid #c0392b}.xmap-check-banner--warn{border-left:.4em solid #e67e22}.xmap-check-banner--info{border-left:.4em solid var(--xmap-secondary)}.xmap-legend{position:absolute;z-index:1;max-width:min(16em,100% - 1em);display:flex;flex-direction:column;max-height:calc(100% - 1em)}.xmap-legend--top-right{top:.5em;right:.5em;align-items:flex-end}.xmap-legend--top-left{top:4.2em;left:.5em;align-items:flex-start;max-height:calc(100% - 4.7em)}.xmap-legend--bottom-right{bottom:.5em;right:.5em;align-items:flex-end;flex-direction:column-reverse}.xmap-legend--bottom-left{bottom:.5em;left:.5em;align-items:flex-start;flex-direction:column-reverse}.xmap-legend--below-hud{top:2.9em;max-height:calc(100% - 3.4em)}.xmap-legend--below-locate{top:6.4em;max-height:calc(100% - 6.9em)}.xmap-legend-header{position:static;padding:2px}.xmap-legend-header button{display:flex;align-items:center;gap:.3em;width:auto;height:1.7em;padding:0 .5em;font-size:.95em;line-height:1}.xmap-legend-chevron{transition:transform .15s}.xmap-legend-chevron--open{transform:rotate(180deg)}.xmap-legend-body{list-style:none;margin:2px 0;padding:.4em .5em;overflow-y:auto;min-height:0;border-radius:4px;border:1px solid var(--xmap-secondary);background-color:#ffffffeb;color:var(--xmap-primary);font-size:.85em;line-height:1.3}.xmap-legend-item{display:flex;align-items:center;gap:.4em;padding:.15em 0}.xmap-legend-item--wms{flex-direction:column;align-items:flex-start}.xmap-legend-swatch{flex:none}.xmap-legend-label{overflow-wrap:anywhere}.xmap-legend-image{display:block;max-width:100%;max-height:12em;object-fit:contain}.xmap-web-map-footer{align-self:flex-end}.xmap-web-map-stage{position:relative;flex:1 1 auto;min-height:0}.xmap-feature-list{flex:none;display:flex;flex-direction:column;text-align:left;gap:.2em;padding:.4em .5em;background-color:#fff;color:var(--xmap-primary);border-bottom:1px solid var(--xmap-secondary);font-size:.95em;line-height:1.3}.xmap-feature-list-label{font-weight:600}.xmap-feature-list-select{min-height:2.4em;max-width:100%;padding:.2em .4em;font:inherit;color:inherit;background-color:#fff;border:1px solid var(--xmap-primary);border-radius:4px}.xmap-feature-list-select:focus{outline:2px solid var(--xmap-primary);outline-offset:1px}.xmap-feature-list-hint{margin:0;font-size:.85em;opacity:.85;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.xmap-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}#xmap-map{height:100%;min-height:0}
27300`, DS = {
27301  name: "XmapWebMap",
27302  inject: ["primaryColor", "secondaryColor"],
27303  emits: ["xmap-geometry-changed", "xmap-geometry-cleared", "xmap-geometry-loaded"],
27304  props: {
27305    extent: {
27306      type: String,
27307      default: null
27308    },
27309    width: {
27310      type: Number,
27311      default: "auto"
27312    },
27313    height: {
27314      type: Number,
27315      default: "auto"
27316    },
27317    x: {
27318      type: Number,
27319      default: 0
27320    },
27321    y: {
27322      type: Number,
27323      default: 0
27324    },
27325    z: {
27326      type: Number,
27327      default: 0
27328    },
27329    // Interaction mode, not a layer: "point" | "line" | "polygon".
27330    // Per the object-vs-behaviour principle, draw is an attribute on the map.
27331    draw: {
27332      type: String,
27333      default: null
27334    },
27335    // A saved location to show: GeoJSON geometry (Point | LineString | Polygon)
27336    // or a Feature wrapping one. Shown zoomed in as the accepted selection; no
27337    // checks run and no xmap-geometry-changed fires (see showGeometry).
27338    geometry: {
27339      type: String,
27340      default: null
27341    },
27342    // EPSG:27700 (default) or EPSG:4326 for the `geometry` coordinates.
27343    geometryProjection: {
27344      type: String,
27345      default: null
27346    },
27347    // Metres of context around the shown geometry (default 100). A string, like
27348    // the other attributes, and parsed in geometryOptions().
27349    geometryBuffer: {
27350      type: String,
27351      default: null
27352    },
27353    // "false" keeps the map's own `extent` view instead of zooming to the geometry.
27354    geometryFit: {
27355      type: String,
27356      default: null
27357    },
27358    // Legend panel. Boolean-as-strings (Vue's CE wrapper only coerces Number
27359    // props), read through boolAttr: `legend` shows it, `legend-collapsed`
27360    // starts it folded. `legend-position`: top-right (default) | top-left |
27361    // bottom-right | bottom-left. `legend-title`: heading text, default "Legend".
27362    legend: {
27363      type: String,
27364      default: null
27365    },
27366    legendPosition: {
27367      type: String,
27368      default: null
27369    },
27370    legendCollapsed: {
27371      type: String,
27372      default: null
27373    },
27374    legendTitle: {
27375      type: String,
27376      default: null
27377    },
27378    // Boolean-as-string: show a locate button that centres the map on the
27379    // device position. Read through boolAttr.
27380    geolocate: {
27381      type: String,
27382      default: null
27383    }
27384  },
27385  methods: {
27386    updateMaxWidth() {
27387      this.maxWidth = this.$parent.$refs.xmapMain.clientWidth;
27388    },
27389    updateMaxHeight() {
27390      this.maxHeight = this.$parent.$refs.xmapMain.clientHeight;
27391    },
27392    // Fit the view to an arbitrary extent, deferring until the map has a real
27393    // size (XMP-2228). Shared by the map's own `extent` and by child layers'
27394    // `fit` (XMP-2234). Returns true when applied now.
27395    fitToExtent(e, t = {}) {
27396      if (!this.map || !e)
27397        return !1;
27398      const i = this.map.getSize();
27399      return !i || !i[0] || !i[1] ? (this.map.once("change:size", () => this.fitToExtent(e, t)), !1) : (this.map.getView().fit(e, { size: i, ...t }), !0);
27400    },
27401    // Fit the view to `extent`. Returns true when applied. No-op without an
27402    // extent; deferred until the first non-zero size when the map is unsized.
27403    // Keeps its own guard so `_pendingFit` still means "one pending fit of the
27404    // map's own extent" and a deferred layer fit cannot cancel it.
27405    fitExtent() {
27406      if (!this.map || !this.extent)
27407        return !1;
27408      const e = this.map.getSize();
27409      return !e || !e[0] || !e[1] ? (this._pendingFit || (this._pendingFit = !0, this.map.once("change:size", () => {
27410        this._pendingFit = !1, this.fitExtent();
27411      })), !1) : this.fitToExtent(this.formattedExtent);
27412    },
27413    // ---- Draw / Report It ---------------------------------------------------
27414    setupDraw() {
27415      !this.map || !this.drawType || (this.teardownDraw(), this._drawSource = new ys(), this._drawLayer = new ps({
27416        source: this._drawSource,
27417        zIndex: 100,
27418        style: this.featureStyle()
27419      }), this.map.addLayer(this._drawLayer), this.drawType !== "Point" && (this._dblClickZoom = this.map.getInteractions().getArray().find((e) => e instanceof Pg) || null, this._dblClickZoom && this._dblClickZoom.setActive(!1)), this._draw = new Fw({ source: this._drawSource, type: this.drawType }), this._modify = new ww({ source: this._drawSource }), this._snap = new Dw({ source: this._drawSource }), this.map.addInteraction(this._draw), this.map.addInteraction(this._modify), this.map.addInteraction(this._snap), this._draw.on("drawend", (e) => {
27420        this._draw.setActive(!1), this.captureGeometry(e.feature);
27421      }), this._modify.on("modifyend", (e) => this.captureGeometry(e.features.item(0))));
27422    },
27423    // One style covers all three geometry types: `stroke` draws the line and
27424    // the polygon outline, `fill` gives the polygon body (which also makes it
27425    // grabbable by its interior, not just its edges), and `image` keeps point
27426    // rendering plus vertex visibility for Modify. A style carrying only
27427    // `image` renders lines and polygons as nothing at all. Shared by the draw
27428    // layer and the view-only layer, so a shown geometry looks like a drawn one.
27429    featureStyle() {
27430      const e = this.primaryColor || "#263746";
27431      return new Sn({
27432        stroke: new Ke({ color: e, width: 3 }),
27433        fill: new Ye({ color: hm(e, 0.2) }),
27434        image: new Fs({
27435          radius: 7,
27436          fill: new Ye({ color: e }),
27437          stroke: new Ke({ color: "#fff", width: 2 })
27438        })
27439      });
27440    },
27441    // Remove the drawn geometry and re-enable drawing a new one (e.g. after submit).
27442    clearMapPoint() {
27443      this._featureChosen = null, this.featureListValue = "", this._drawSource && this._drawSource.clear(), this._viewSource && this._viewSource.clear(), this._shown = null, this._draw && this._draw.setActive(!0), _d();
27444    },
27445    // Public counterpart to clearMapPoint(): removes the geometry AND tells the host.
27446    // Used by the Clear control and exposed on the custom element as clearGeometry().
27447    // Only announces when there was something to clear, so (a) a first draw that is
27448    // immediately degenerate stays silent, and (b) the post-submit reset — where
27449    // requestReportReset() has already emptied the bus — does not fire a spurious
27450    // event on top of xmap-report-submitted.
27451    clearGeometry() {
27452      this.locationMessage = "";
27453      const e = le.hasPoint, t = !!this.checking;
27454      this.abortChecks(), this.clearMapPoint(), e && this.emitHost("xmap-geometry-cleared", {});
27455      const i = !!this._lastPassing;
27456      this._lastPassing = null, this._selection = null, this.checkBanner = null, this.hasChecks() && (e || t || i) && this.emitChecksCleared();
27457    },
27458    teardownDraw() {
27459      this._draw && this.map && this.map.removeInteraction(this._draw), this._draw = null, this._modify && this.map && this.map.removeInteraction(this._modify), this._modify = null, this._snap && this.map && this.map.removeInteraction(this._snap), this._snap = null, this._drawLayer && this.map && this.map.removeLayer(this._drawLayer), this._drawLayer = null, this._drawSource = null, this._dblClickZoom && this._dblClickZoom.setActive(!0), this._dblClickZoom = null, _d();
27460    },
27461    // Capture whatever was drawn (Point | LineString | Polygon) as GeoJSON in
27462    // EPSG:27700 — the map's native projection, so no reprojection.
27463    //
27464    // With <xmap-web-check> children declared, the raw draw is still announced
27465    // (xmap-geometry-changed, the bus) and then the checks run; a failing check
27466    // reverts the selection (see runChecks). `run: false` is the internal
27467    // re-capture after a snap, which must not start a second run.
27468    captureGeometry(e, { run: t = !0, prefer: i = null } = {}) {
27469      this._shown = null, this.locationMessage = "";
27470      const n = xd(e);
27471      if (!lm(n)) {
27472        this.clearGeometry();
27473        return;
27474      }
27475      if (il(n), this.emitHost("xmap-geometry-changed", this.geometryDetail(n)), !!t) {
27476        if (this.hasChecks())
27477          return this.runChecks(e, n, { prefer: i });
27478        this.rememberPassing(e, n), this.afterPinSettled({ geometry: n, reason: "passed" });
27479      }
27480    },
27481    geometryDetail(e) {
27482      return {
27483        geometry: e,
27484        type: e.type,
27485        coordinates: e.coordinates,
27486        // Kept for the common point case so a listener reads coordinates directly.
27487        ...e.type === "Point" ? { easting: e.coordinates[0], northing: e.coordinates[1] } : {},
27488        point: this.pointDetail(e),
27489        // The asset a match="select" layer check put the pin on, or null.
27490        selection: this._selection || null
27491      };
27492    },
27493    // A representative EPSG:27700 position with its WGS84 equivalent, for hosts
27494    // that store a location summary next to the geometry (the PCF's `details`
27495    // bound format). null when the geometry has no usable position.
27496    pointDetail(e) {
27497      const t = cm(e);
27498      if (!t)
27499        return null;
27500      let i = null;
27501      try {
27502        i = Ts(t, "EPSG:27700", "EPSG:4326");
27503      } catch {
27504        i = null;
27505      }
27506      const n = (s) => Math.round(s * 1e6) / 1e6;
27507      return {
27508        easting: t[0],
27509        northing: t[1],
27510        longitude: i ? n(i[0]) : null,
27511        latitude: i ? n(i[1]) : null
27512      };
27513    },
27514    // ---- Showing a saved geometry --------------------------------------------
27515    //
27516    // The `geometry` attribute (and its twin, host.setGeometry()) puts a saved
27517    // location on the map: a summary step, or a revisited location step. It is
27518    // the accepted selection, so a later refused edit restores it, but it is not
27519    // a user action: no checks run, no xmap-geometry-changed fires (a host that
27520    // writes that event to a column would rewrite the record), and it announces
27521    // itself with xmap-geometry-loaded instead.
27522    // The attribute values as showGeometry() options.
27523    geometryOptions() {
27524      const e = Number(this.geometryBuffer);
27525      return {
27526        fit: se(this.geometryFit, !0),
27527        buffer: this.geometryBuffer != null && this.geometryBuffer !== "" && Number.isFinite(e) && e >= 0 ? e : 100,
27528        projection: this.geometryProjection || "EPSG:27700",
27529        source: "attribute"
27530      };
27531    },
27532    // Parse + reproject to EPSG:27700; null when there is nothing showable.
27533    resolveGeometryInput(e, t) {
27534      const i = Nw(e);
27535      if (!i)
27536        return null;
27537      if (pc(t) !== "EPSG:4326")
27538        return i;
27539      try {
27540        return fm(i, (n) => Xr(Ts(n, "EPSG:4326", "EPSG:27700")));
27541      } catch {
27542        return null;
27543      }
27544    },
27545    scheduleGeometryAttr() {
27546      this._geometryAttrQueued || !this.map || (this._geometryAttrQueued = !0, this.$nextTick(() => {
27547        this._geometryAttrQueued = !1, this.applyGeometryAttr();
27548      }));
27549    },
27550    // Apply the `geometry` attribute: show it, or quietly clear when it is empty.
27551    applyGeometryAttr(e = {}) {
27552      return this.geometry == null || String(this.geometry).trim() === "" ? (this.hideGeometry(), !1) : this.showGeometry(this.geometry, { ...this.geometryOptions(), ...e });
27553    },
27554    showGeometry(e, { fit: t = !0, buffer: i = 100, projection: n = "EPSG:27700", source: s = "method" } = {}) {
27555      const r = this.resolveGeometryInput(e, n);
27556      if (!r) {
27557        const o = typeof e == "string" ? e : JSON.stringify(e);
27558        return this._warnedGeometry || (this._warnedGeometry = /* @__PURE__ */ new Set()), this._warnedGeometry.has(o) || this._warnedGeometry.add(o), this.hideGeometry(), !1;
27559      }
27560      return this.abortChecks(), this.locationMessage = "", this.checkBanner = null, this._selection = null, this.placeGeometry(r), t && this.map && this.fitToExtent(po(r, i)), this.emitHost("xmap-geometry-loaded", { ...this.geometryDetail(r), source: s }), !0;
27561    },
27562    // Put `geometry` on the map as the accepted selection, with no event and no
27563    // fit. Into the draw source when drawing is on (Draw stays off: one feature,
27564    // which Modify edits), otherwise into a view-only layer.
27565    placeGeometry(e) {
27566      if (!this.map)
27567        return;
27568      const t = { Point: Ne, LineString: Qi, Polygon: Fn }[e.type], i = new ke(new t(e.coordinates));
27569      this._viewSource && this._viewSource.clear(), this._drawSource ? (this._drawSource.clear(), this._drawSource.addFeature(i), this._draw && this._draw.setActive(!1)) : (this.ensureViewLayer(), this._viewSource.addFeature(i)), il(e), this.rememberPassing(i, e), this._shown = { geometry: e }, this.syncFeatureListValue(e);
27570    },
27571    // Quiet clear: the host removed the attribute (or called setGeometry(null)),
27572    // so it already knows; no xmap-geometry-cleared.
27573    hideGeometry() {
27574      this.abortChecks(), this.clearMapPoint(), this._lastPassing = null, this._selection = null, this.checkBanner = null;
27575    },
27576    ensureViewLayer() {
27577      this._viewSource || !this.map || (this._viewSource = new ys(), this._viewLayer = new ps({ source: this._viewSource, zIndex: 100, style: this.featureStyle() }), this.map.addLayer(this._viewLayer));
27578    },
27579    teardownViewLayer() {
27580      this._viewLayer && this.map && this.map.removeLayer(this._viewLayer), this._viewLayer = null, this._viewSource = null;
27581    },
27582    attachHostMethods() {
27583      var t, i, n;
27584      const e = (n = (i = (t = this.$el) == null ? void 0 : t.getRootNode) == null ? void 0 : i.call(t)) == null ? void 0 : n.host;
27585      e && (e.clearGeometry = () => this.clearGeometry(), e.locate = () => this.locate(), e.setGeometry = (s, r = {}) => s == null || s === "" ? (this.hideGeometry(), !1) : this.showGeometry(s, { ...r, source: "method" }));
27586    },
27587    // ---- Location checks (<xmap-web-check>) ---------------------------------
27588    //
27589    // Mirrors what Walsall's WMBC.Mapping control does: a selection that fails
27590    // its checks is refused outright. The drawn geometry is removed and the
27591    // last one that passed is put back, so what is on the map is always what
27592    // the host (and a bound form column) has been told about. With no checks
27593    // declared none of this runs and the map behaves exactly as before.
27594    // Registered by <xmap-web-check> on mount. Plain array, never reactive:
27595    // these are component instances (see the markRaw note in created()).
27596    registerCheck(e) {
27597      this._checks || (this._checks = []), this._checks.includes(e) || this._checks.push(e);
27598    },
27599    unregisterCheck(e) {
27600      this._checks && (this._checks = this._checks.filter((t) => t !== e));
27601    },
27602    hasChecks() {
27603      return !!(this._checks && this._checks.length);
27604    },
27605    // ---- Feature list (<xmap-web-feature-list>) ------------------------------
27606    //
27607    // The features of one layer in the current view, listed in a select above
27608    // the canvas. The list element pushes a plain descriptor (setFeatureList);
27609    // the map computes the entries on every moveend (debounced), and a pick
27610    // goes through placePoint -> captureGeometry, the path a click takes, so
27611    // checks, selection, events and the PCF's bound column are unchanged.
27612    // Reactive state is plain data only; the OL features behind the entries
27613    // live on underscore fields (see the markRaw note in created()).
27614    setFeatureList(e, t) {
27615      const i = this.featureLists.findIndex((n) => n.key === e);
27616      t ? i !== -1 ? this.featureLists.splice(i, 1, { ...t, key: e }) : (this.featureLists.push({ ...t, key: e }), this.featureLists.length > 1) : i !== -1 && this.featureLists.splice(i, 1), this.scheduleFeatureListRefresh();
27617    },
27618    // One refresh 200 ms after the last call: a drag, a kinetic pan and an
27619    // animated fit end in several moveends but make one refresh.
27620    scheduleFeatureListRefresh() {
27621      clearTimeout(this._featureListTimer), this._featureListTimer = setTimeout(() => this.refreshFeatureList(), 200);
27622    },
27623    // Follow the list's layer: a load, a reload, a failure or a threshold change
27624    // all refresh the list. Rebound only when the layer itself changes.
27625    bindFeatureListLayer(e) {
27626      var i;
27627      if (this._featureListLayer === e)
27628        return;
27629      for (const n of this._featureListKeys || [])
27630        n.target.un(n.type, n.listener);
27631      if (this._featureListKeys = [], this._featureListLayer = e || null, !e)
27632        return;
27633      const t = (n, s) => {
27634        if (!(n != null && n.on))
27635          return;
27636        const r = () => this.scheduleFeatureListRefresh();
27637        n.on(s, r), this._featureListKeys.push({ target: n, type: s, listener: r });
27638      };
27639      t(e, "propertychange"), t((i = e.getSource) == null ? void 0 : i.call(e), "change");
27640    },
27641    // Compute the set for the current view and apply it, or hold it while the
27642    // select has focus so options never move under a keyboard user.
27643    refreshFeatureList() {
27644      var L, I, z, U, q;
27645      const e = this.featureList;
27646      if (!e || !this.map || !this.featureListShown) {
27647        this.bindFeatureListLayer(null);
27648        return;
27649      }
27650      const t = this.findLayer(e.layer), i = (L = t == null ? void 0 : t.getSource) == null ? void 0 : L.call(t), n = !!(i != null && i.forEachFeatureIntersectingExtent);
27651      this.bindFeatureListLayer(t);
27652      const s = this.map.getView(), r = this.map.getSize();
27653      if (!r || !r[0] || !r[1])
27654        return;
27655      const o = s.getResolution(), a = s.calculateExtent(r), l = s.getCenter(), h = SS(e.maxResolution, (I = t == null ? void 0 : t.getMaxResolution) == null ? void 0 : I.call(t)).value, c = !(Number.isFinite(h) && !(o < h)), u = n && c ? tS(i, a, l) : [], d = this._featureChosen, f = n && c && !!(d != null && d.feature) && !!((z = i.hasFeature) != null && z.call(i, d.feature)), g = AS({
27656        hasLayer: n,
27657        loadState: (U = t == null ? void 0 : t.get) == null ? void 0 : U.call(t, "loadState"),
27658        resolution: o,
27659        maxResolution: h,
27660        count: u.length + (f ? 1 : 0)
27661      }), m = ((q = t == null ? void 0 : t.get) == null ? void 0 : q.call(t, "assetId")) || "id", _ = (K) => {
27662        var Mt, V;
27663        const Z = { ...((V = (Mt = K.feature).getProperties) == null ? void 0 : V.call(Mt)) || {} };
27664        return delete Z.geometry, { key: lt(K.feature), properties: Z, distance: K.distance, feature: K.feature };
27665      }, p = u.map(_);
27666      let y = null;
27667      if (g === "ready" && f) {
27668        const K = Pa(d.feature, l);
27669        y = _({ feature: d.feature, distance: K ? K.distance : 0 });
27670      }
27671      const x = g === "ready" ? LS(p, { template: e.itemLabel, assetKey: m, limit: e.limit, showDistance: se(e.showDistance, !1), chosen: y }) : [], E = /* @__PURE__ */ Object.create(null);
27672      for (const K of y ? [...p, y] : p)
27673        E[K.key] = K.feature;
27674      const M = /* @__PURE__ */ Object.create(null);
27675      for (const K of x)
27676        M[K.key] = E[K.key];
27677      const w = { state: g, entries: x, refs: M, extent: a, centre: l, resolution: o, layerId: e.layer, name: e.name };
27678      this.featureListFocused ? this._pendingFeatureList = w : this.applyFeatureList(w);
27679    },
27680    applyFeatureList(e) {
27681      this._pendingFeatureList = null;
27682      const t = this.featureListState, i = t !== e.state || bd(this.featureEntries) !== bd(e.entries);
27683      this.featureEntries = e.entries, this._featureRefs = e.refs, this.featureListState = e.state, this.featureListValue && !e.entries.some((s) =>
27683 s.key === this.featureListValue) && (this.featureListValue = "");
27684      const n = FS(t, e.state, {
27685        label: this.featureListLabel,
27686        count: e.entries.length,
27687        texts: this.featureListTexts
27688      });
27689      n && this.announceFeatureList(n), i && this.emitHost("xmap-feature-list-changed", {
27690        name: e.name,
27691        layerId: e.layerId,
27692        state: e.state,
27693        extent: e.extent,
27694        center: e.centre,
27695        resolution: e.resolution,
27696        count: e.entries.length,
27697        entries: e.entries.map((s) => ({ assetId: s.assetId, label: s.text, distance: s.distance }))
27698      });
27699    },
27700    announceFeatureList(e) {
27701      this.featureListAnnouncement = this.featureListAnnouncement === e ? `${e} ` : e;
27702    },
27703    onFeatureListFocus() {
27704      this.featureListFocused = !0;
27705    },
27706    onFeatureListBlur() {
27707      this.featureListFocused = !1, this._pendingFeatureList && this.applyFeatureList(this._pendingFeatureList);
27708    },
27709    // Applied on change, coalesced: arrowing through a closed select fires a
27710    // change per key on Windows, and each one would otherwise run the checks.
27711    onFeatureListChange(e) {
27712      this.featureListValue = e || "", clearTimeout(this._featurePickTimer), e && (this._featurePickTimer = setTimeout(() => this.pickFeatureListEntry(e), 250));
27713    },
27714    pickFeatureListEntry(e) {
27715      var o, a, l;
27716      const t = this.featureList, i = this.featureEntries.find((h) => h.key === e);
27717      if (!t || !i)
27718        return !1;
27719      const n = this.findLayer(t.layer), s = (o = n == null ? void 0 : n.getSource) == null ? void 0 : o.call(n);
27720      let r = (a = this._featureRefs) == null ? void 0 : a[e];
27721      if (r && (s != null && s.hasFeature) && !s.hasFeature(r)) {
27722        const h = ((l = n.get) == null ? void 0 : l.call(n, "assetId")) || "id";
27723        r = i.assetId == null ? null : s.getFeatures().find((c) => String(c.get(h)) === i.assetId) || null;
27724      }
27725      return r ? (this._listPick = { key: e, text: i.text, feature: r }, this.selectFeature(t.layer, r)) : (this.featureListValue = "", this.announceFeatureList("That option is no longer available."), this.scheduleFeatureListRefresh(), !1);
27726    },
27727    // The generic hook: put the pin on a feature of a layer as if the user had
27728    // clicked it. A point gives its coordinates, a single-point MultiPoint its
27729    // point, anything else the closest point on it to the view centre.
27730    selectFeature(e, t) {
27731      var r, o;
27732      const i = (r = t == null ? void 0 : t.getGeometry) == null ? void 0 : r.call(t);
27733      if (!i)
27734        return !1;
27735      const n = (o = i.getType) == null ? void 0 : o.call(i);
27736      let s;
27737      return n === "Point" ? s = i.getCoordinates() : n === "MultiPoint" && i.getCoordinates().length ? s = i.getCoordinates()[0] : s = i.getClosestPoint(this.map.getView().getCenter()), this.placePoint(s, { prefer: { layerId: e, feature: t } });
27738    },
27739    // Place (or move) the pin at `coords` through the click path: a new pin is
27740    // what drawend does, an existing one is moved as a Modify drag moves it.
27741    placePoint(e, { prefer: t = null } = {}) {
27742      if (this.drawType !== "Point" || !this._drawSource || !Array.isArray(e))
27743        return !1;
27744      let i = this._drawSource.getFeatures()[0];
27745      i ? i.getGeometry().setCoordinates(e) : (i = new ke(new Ne(e)), this._drawSource.addFeature(i), this._draw && this._draw.setActive(!1));
27746      const n = this.captureGeometry(i, { prefer: t });
27747      return n === void 0 ? !0 : n;
27748    },
27749    // After a pin settles (checks committed or reverted, or no checks): show
27750    // the entry under it, announce a passing list pick, and bring a list pick
27751    // that landed out of view back into it. Its moveend lands in a held list.
27752    afterPinSettled(e) {
27753      var r, o, a, l;
27754      const t = this._listPick;
27755      if (this._listPick = null, this.syncFeatureListValue((e == null ? void 0 : e.geometry) || null), !t || (e == null ? void 0 : e.reason) !== "passed" || !e.geometry)
27756        return;
27757      this.announceFeatureList(`Selected ${t.text}.`);
27758      const i = e.geometry.coordinates, n = (o = (r = this.map) == null ? void 0 : r.getView) == null ? void 0 : o.call(r), s = (l = (a = this.map) == null ? void 0 : a.getSize) == null ? void 0 : l.call(a);
27759      n && s && s[0] && s[1] && !Ds(n.calculateExtent(s), i) && n.setCenter(i);
27760    },
27761    // The select shows the listed feature the pin sits on (within 1 cm), or nothing.
27762    syncFeatureListValue(e) {
27763      var s, r, o;
27764      if (!this.featureList)
27765        return;
27766      const t = (e == null ? void 0 : e.type) === "Point" ? e.coordinates : null;
27767      let i = null;
27768      if (t) {
27769        const a = this.findLayer(this.featureList.layer), l = (s = a == null ? void 0 : a.getSource) == null ? void 0 : s.call(a), h = ((r = l == null ? void 0 : l.getFeaturesInExtent) == null ? void 0 : r.call(l, [t[0] - 0.01, t[1] - 0.01, t[0] + 0.01, t[1] + 0.01])) || [], c = this._selection, u = ((o = a == null ? void 0 : a.get) == null ? void 0 : o.call(a, "assetId")) || "id";
27770        i = (c == null ? void 0 : c.assetId) != null && h.find((d) => String(d.get(u)) === c.assetId) || h[0] || null;
27771      }
27772      this._featureChosen = i ? { feature: i } : null;
27773      const n = i ? lt(i) : "";
27774      this.featureListValue = n && this.featureEntries.some((a) => a.key === n) ? n : "", n && !this.featureListValue && this.scheduleFeatureListRefresh();
27775    },
27776    // ---- Geolocation (`geolocate`) -------------------------------------------
27777    //
27778    // One fix per press through OL's Geolocation: tracking is switched on for
27779    // the press and off again at the first position or error, so continuous
27780    // tracking later is a flag, not a rewrite. The fix only centres the view
27781    // and draws a "you are here" marker on its own layer; it never places the
27782    // pin, writes the bus or runs a check. The OL objects live on underscore
27783    // fields (the markRaw rule in created()).
27784    ensureGeolocation() {
27785      return this._geolocation || (this._geolocation = new JM({ projection: "EPSG:27700", trackingOptions: pS })), this._geolocation;
27786    },
27787    // Resolves with the xmap-location-found detail, or null on failure.
27788    async locate() {
27789      var s, r;
27790      if (!this.geolocateOn || this.locating)
27791        return null;
27792      if (this.locateSupport !== "ok")
27793        return this.locationFailed("unsupported");
27794      const e = this._locateToken = (this._locateToken || 0) + 1;
27795      this.locating = !0, this.locationMessage = "", this.announce
27795Location(To.finding);
27796      let t = !1;
27797      const i = () => {
27798        t = !0;
27799      };
27800      (s = this.map) == null || s.on("movestart", i);
27801      const n = this.ensureGeolocation();
27802      try {
27803        const o = await new Promise((u, d) => {
27804          let f = null;
27805          const g = (p, y) => {
27806            clearTimeout(f), n.un("change", m), n.un("error", _), n.setTracking(!1), this._locateCancel = null, p(y);
27807          }, m = () => g(u, {
27808            position: n.getPosition(),
27809            accuracy: n.getAccuracy(),
27810            accuracyGeometry: n.getAccuracyGeometry()
27811          }), _ = (p) => g(d, p);
27812          f = setTimeout(() => g(d, { code: "timeout" }), yS), this._locateCancel = () => g(d, { code: "cancelled" }), n.on("change", m), n.on("error", _), n.setTracking(!0);
27813        });
27814        if (e !== this._locateToken || !Array.isArray(o.position))
27815          return null;
27816        const a = bS(o.position, o.accuracy);
27817        this.showLocation(o.position, o.accuracyGeometry);
27818        const l = !t;
27819        l && this.fitToExtent(po({ type: "Point", coordinates: o.position }, CS(o.accuracy)));
27820        const h = xm(o.accuracy);
27821        this.announceLocation(MS({ accuracy: o.accuracy, centred: l })), h && l && (this.locationMessage = Em(o.accuracy));
27822        const c = { ...a, approximate: h, centred: l, timestamp: Date.now() };
27823        return this.emitHost("xmap-location-found", c), c;
27824      } catch (o) {
27825        const a = ES(o);
27826        return e !== this._locateToken || a === "cancelled" ? null : this.locationFailed(a);
27827      } finally {
27828        (r = this.map) == null || r.un("movestart", i), e === this._locateToken && (this.locating = !1);
27829      }
27830    },
27831    // Cancelable: a host that calls preventDefault() shows its own message.
27832    locationFailed(e) {
27833      const t = To[e] || To.unavailable;
27834      return this.emitHost("xmap-location-error", { code: e, message: t }, { cancelable: !0 }) !== !1 && (this.locationMessage = t, this.announceLocation(t)), null;
27835    },
27836    // The "you are here" marker: an accuracy halo and a dot, on a layer of its
27837    // own above the data (50) and below the pin (100). No id, not a child
27838    // element, not in the draw source: checks, lists and the legend never see it.
27839    showLocation(e, t) {
27840      if (!this.map)
27841        return;
27842      if (this._locationSource || (this._locationSource = new ys(), this._locationLayer = new ps({ source: this._locationSource, zIndex: 90 }), this.map.addLayer(this._locationLayer)), this._locationSource.clear(), t) {
27843        const n = new ke(t);
27844        n.setStyle(new Sn({
27845          fill: new Ye({ color: "rgba(26, 115, 232, 0.12)" }),
27846          stroke: new Ke({ color: "rgba(26, 115, 232, 0.6)", width: 1 })
27847        })), this._locationSource.addFeature(n);
27848      }
27849      const i = new ke(new Ne(e));
27850      i.setStyle(new Sn({
27851        image: new Fs({ radius: 5, fill: new Ye({ color: "#1a73e8" }), stroke: new Ke({ color: "#fff", width: 3 }) })
27852      })), this._locationSource.addFeature(i);
27853    },
27854    // `geolocate` off and unmount: drop a pending request, the marker and the message.
27855    teardownLocation() {
27856      this._locateToken = (this._locateToken || 0) + 1, this._locateCancel && this._locateCancel(), this._geolocation && (this._geolocation.setTracking(!1), this._geolocation.dispose(), this._geolocation = null), this._locationLayer && this.map && this.map.removeLayer(this._locationLayer), this._locationLayer = null, this._locationSource = null, this.locating = !1, this.locationMessage = "";
27857    },
27858    announceLocation(e) {
27859      this.locationAnnouncement = this.locationAnnouncement === e ? `${e} ` : e;
27860    },
27861    // ---- Legend --------------------------------------------------------------
27862    // Called by the layer elements with a plain descriptor (lib/legend.js), or
27863    // null to drop their entry. Reactive on purpose, which is safe because the
27864    // descriptors hold strings and numbers only, never an OL object. A replaced
27865    // entry keeps its registration sequence, so its place in the legend.
27866    setLegendEntry(e, t) {
27867      const i = this.legendEntries.findIndex((n) => n.key === e);
27868      if (!t) {
27869        i !== -1 && this.legendEntries.splice(i, 1);
27870        return;
27871      }
27872      i !== -1 ? this.legendEntries.splice(i, 1, { ...t, key: e, seq: this.legendEntries[i].seq }) : (this._legendSeq = (this._legendSeq || 0) + 1, this.legendEntries.push({ ...t, key: e, seq: this._legendSeq }));
27873    },
27874    // A layer by its `layer-id` (the OL layer's `id` property), for layer checks.
27875    findLayer(e) {
27876      return !this.map || !e ? null : this.map.getLayers().getArray().find((t) => t.get && t.get("id") === e) || null;
27877    },
27878    // The most recent geometry every check accepted (or, with no checks, the
27879    // most recent geometry full stop). `coords` are the raw OL coordinates so a
27880    // rejected Modify restores the exact previous vertices, not rounded ones.
27881    rememberPassing(e, t) {
27882      var n, s, r;
27883      const i = (r = (s = (n = e == null ? void 0 : e.getGeometry) == null ? void 0 : n.call(e)) == null ? void 0 : s.getCoordinates) == null ? void 0 : r.call(s);
27884      this._lastPassing = { geometry: t, type: t.type, coords: i ?? t.coordinates, selection: this._selection || null };
27885    },
27886    // Abandon an in-flight run: its results are dropped when they arrive.
27887    abortChecks() {
27888      this._runToken = (this._runToken || 0) + 1, this._checkController && (this._checkController.abort(), this._checkController = null), this.checking = !1;
27889    },
27890    async runChecks(e, t, { prefer: i = null } = {}) {
27891      var h, c, u, d;
27892      this.abortChecks();
27893      const n = this._runToken, s = new AbortController();
27894      this._checkController = s;
27895      const r = this._checks.map((f) => f.spec());
27896      this.checking = !0, this.checkBanner = null, this._selection = null;
27897      const o = (d = (u = (c = (h = this.map) == null ? void 0 : h.getView) == null ? void 0 : c.call(h)) == null ? void 0 : u.getResolution) == null ? void 0 : d.call(u), a = await Promise.all(r.map(
27898        (f) => hS(f, t, {
27899          signal: s.signal,
27900          fetchFn: this._checkFetch || void 0,
27901          findLayer: (g) => this.findLayer(g),
27902          resolution: o,
27903          prefer: i
27904        })
27905      ));
27906      if (n !== this._runToken)
27907        return;
27908      this._checkController = null, this.checking = !1;
27909      const l = a.every((f) => f.passed) ? this.commitChecks(e, t, r, a) : this.revertChecks(e);
27910      this.emitCheckEvents(r, a, l), this.afterPinSettled(l);
27911    },
27912    // Every check passed. A snap="true" check that returned coordinates moves
27913    // the drawn point onto them (nearest asset); the re-capture announces the
27914    // moved geometry without starting another run.
27915    // Every check passed. A layer check with match="select" moves the pin onto
27916    // the asset it found and records the selection; a URL check with asset-id
27917    // records its nearest match as the selection and moves the pin only when it
27918    // also says snap="true"; failing both, a snap="true" URL check that returned
27919    // coordinates moves it. Either way the re-capture announces the moved
27920    // geometry without starting another run. Snaps happen only now, after every
27921    // rule has passed, so all rules judged the same click.
27922    commitChecks(e, t, i, n) {
27923      var a;
27924      let s = t;
27925      const r = n.findIndex((l) => l.selection), o = r === -1 ? null : n[r];
27926      if (this._selection = o ? o.selection : null, t.type === "Point") {
27927        let h = o && (i[r].layer || i[r].snap) && o.selection.coordinates || null;
27928        if (!h)
27929          for (let u = 0; u < i.length && !h; u++)
27930            i[u].snap && (h = Kl(n[u].data));
27931        const c = (a = e == null ? void 0 : e.getGeometry) == null ? void 0 : a.call(e);
27932        h && (c != null && c.setCoordinates) && (c.setCoordinates(h), this.captureGeometry(e, { run: !1 }), s = xd(e) || t);
27933      }
27934      return this.rememberPassing(e, s), this.checkBanner = null, { geometry: s, reason: "passed" };
27935    },
27936    // A check failed: refuse the selection. A rejected edit of a previously
27937    // passing geometry puts the old vertices back; a rejected first draw leaves
27938    // the map empty with Draw re-enabled.
27939    revertChecks(e) {
27940      var n, s;
27941      this._selection = this._lastPassing && this._lastPassing.selection || null;
27942      const t = this._lastPassing, i = (n = e == null ? void 0 : e.getGeometry) == null ? void 0 : n.call(e);
27943      return t && ((s = i == null ? void 0 : i.getType) == null ? void 0 : s.call(i)) === t.type && i.setCoordinates ? (i.setCoordinates(t.coords), this._drawSource && !this._drawSource.hasFeature(e) && this._drawSource.addFeature(e), this._draw && this._draw.setActive(!1), il(t.geometry), this.emitHost("xmap-geometry-changed", this.geometryDetail(t.geometry)), { geometry: t.geometry, reason: "rejected" }) : (this._lastPassing = null, this.clearMapPoint(), this.emitHost("xmap-geometry-cleared", {}), { geometry: null, reason: "rejected" });
27944    },
27945    // After the map has committed or reverted, so a listener already sees the
27946    // final state: one xmap-check-result per check, one xmap-check-failed per
27947    // failing check (cancelable: preventDefault() suppresses the banner), then
27948    // one xmap-checks-completed. The banner shows the first failing check that
27949    // was not suppressed, in declaration order. When every check passed, each
27950    // warn rule that found something fires xmap-check-warned (also cancelable)
27951    // and the first unsuppressed one becomes a warn banner: the pin stays.
27952    emitCheckEvents(e, t, i) {
27953      const n = cS(t);
27954      for (const o of t)
27955        this.emitHost("xmap-check-result", { name: o.name, url: o.url, passed: o.passed, data: o.data, reason: o.reason, warning: o.warning ?? null });
27956      let s = null, r = "fail";
27957      t.forEach((o, a) => {
27958        if (o.passed)
27959          return;
27960        const l = this.emitHost(
27961          "xmap-check-failed",
27962          { name: o.name, url: o.url, message: o.message, reason: o.reason, data: o.data, status: o.status },
27963          { cancelable: !0 }
27964        );
27965        s === null && e[a].banner && l !== !1 && (s = o.message);
27966      }), i.reason === "passed" && t.forEach((o, a) => {
27967        if (!o.warning)
27968          return;
27969        const l = this.emitHost(
27970          "xmap-check-warned",
27971          { name: o.name, layer: o.layer ?? null, message: o.warning, data: o.data },
27972          { cancelable: !0 }
27973        );
27974        s === null && e[a].banner && l !== !1 && (s = o.warning, r = "warn");
27975      }), this.emitHost("xmap-checks-completed", {
27976        passed: n.passed,
27977        results: n.results,
27978        geometry: i.geometry,
27979        reason: i.reason,
27980        point: i.geometry ? this.pointDetail(i.geometry) : null,
27981        selection: i.geometry && this._selection || null
27982      }), i.reason === "passed" && this._selection && this.emitHost("xmap-asset-selected", { ...this._selection, geometry: i.geometry }), this.checkBanner = s ? { kind: r, text: s } : null;
27983    },
27984    emitChecksCleared() {
27985      this.emitHost("xmap-checks-completed", { passed: !1, results: {}, geometry: null, reason: "cleared", point: null, selection: null });
27986    },
27987    // Dispatch on the custom-element host so the event reaches the host page
27988    // (composed:true to cross the shadow boundary). Returns dispatchEvent's
27989    // result: false when a cancelable event had preventDefault() called on it.
27990    emitHost(e, t, { cancelable: i = !1 } = {}) {
27991      var s, r, o;
27992      const n = ((o = (r = (s = this.$el) == null ? void 0 : s.getRootNode) == null ? void 0 : r.call(s)) == null ? void 0 : o.host) || this.$el;
27993      return n == null ? void 0 : n.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0, cancelable: i }));
27994    }
27995  },
27996  computed: {
27997    drawType() {
27998      return this.draw && { point: "Point", line: "LineString", polygon: "Polygon" }[String(this.draw).toLowerCase()] || null;
27999    },
28000    // Drives the Clear control. Reads the bus rather than the vector source so it
28001    // stays reactive — an OL source is markRaw'd and its mutations are invisible to Vue.
28002    hasGeometry() {
28003      return le.hasPoint;
28004    },
28005    busResetSeq() {
28006      return le.resetSeq;
28007    },
28008    legendOn() {
28009      return se(this.legend, !1);
28010    },
28011    legendCorner() {
28012      const e = String(this.legendPosition || "").trim().toLowerCase();
28013      return ["top-right", "top-left", "bottom-right", "bottom-left"].includes(e) ? e : "top-right";
28014    },
28015    legendHeading() {
28016      return uS(this.legendTitle);
28017    },
28018    // As the layers appear on the map: topmost first, hidden layers dropped.
28019    shownLegendEntries() {
28020      return _S(this.legendEntries);
28021    },
28022    geolocateOn() {
28023      return se(this.geolocate, !1);
28024    },
28025    geolocateShown() {
28026      return this.geolocateOn && this.locateSupport === "ok";
28027    },
28028    // The locate button sits under the zoom buttons, in the top-left legend's spot.
28029    legendBelowLocate() {
28030      return this.legendCorner === "top-left" && this.geolocateShown;
28031    },
28032    // The first registered list; one per map.
28033    featureList() {
28034      return this.featureLists[0] || null;
28035    },
28036    // Point draw only: the pick places a point. Hidden on a read-only map.
28037    featureListShown() {
28038      return !!this.featureList && this.drawType === "Point";
28039    },
28040    featureListTexts() {
28041      const e = this.featureList || {};
28042      return {
28043        ...xc,
28044        ...e.label ? { label: e.label } : {},
28045        ...e.placeholder ? { placeholder: e.placeholder } : {},
28046        ...e.zoomText ? { zoom: e.zoomText } : {},
28047        ...e.noneText ? { none: e.noneText } : {}
28048      };
28049    },
28050    featureListLabel() {
28051      return this.featureListTexts.label;
28052    },
28053    featureListPlaceholder() {
28054      return this.featureListTexts.placeholder;
28055    },
28056    featureListHint() {
28057      return OS(this.featureListState, this.featureEntries.length, this.featureListTexts);
28058    },
28059    // The clear-drawing HUD owns the top-right corner while it shows.
28060    legendBelowHud() {
28061      return this.legendCorner === "top-right" && !!(this.drawType && this.hasGeometry);
28062    },
28063    mapX: {
28064      get() {
28065        return this.x;
28066      },
28067      set(e) {
28068        this.$emit("update:x", e);
28069      }
28070    },
28071    formattedExtent() {
28072      return this.extent && Array.isArray(this.extent) ? this.extent : this.extent ? this.extent.split(",").map((e) => Number(e)) : [Number(this.mapX), Number(this.y), Number(this.mapX), Number(this.y)];
28073    }
28074  },
28075  data: () => ({
28076    map: null,
28077    maxWidth: 0,
28078    maxHeight: 0,
28079    // Location checks banner state (the only reactive check state; the
28080    // registered check components and the last passing geometry are plain fields).
28081    checking: !1,
28082    checkBanner: null,
28083    // {kind: 'fail' | 'warn', text}
28084    // Legend: plain descriptors from the layer elements, the panel's open
28085    // state, and legend image URLs that failed to load.
28086    legendEntries: [],
28087    legendOpen: !0,
28088    legendFailed: {},
28089    // Feature list: registered descriptors and what the select renders (plain
28090    // data only; the OL features are on _featureRefs, never reactive).
28091    featureLists: [],
28092    featureEntries: [],
28093    featureListState: null,
28094    featureListValue: "",
28095    featureListFocused: !1,
28096    featureListAnnouncement: "",
28097    // Geolocation: plain values only (the OL Geolocation and marker layer are
28098    // underscore fields).
28099    locateSupport: "ok",
28100    locating: !1,
28101    locationMessage: "",
28102    locationAnnouncement: ""
28103  }),
28104  mounted() {
28105    this.$nextTick(() => {
28106      this.updateMaxWidth(), this.updateMaxHeight(), this.map.setTarget(this.$refs.map), window.XMAP_MAP = this.map, this.draw && this.setupDraw();
28107      const e = this.applyGeometryAttr({ fit: !1 });
28108      this.attachHostMethods(), this.$nextTick(() => {
28109        const t = this.geometryOptions();
28110        e && t.fit && this._shown ? this.fitToExtent(po(this._shown.geometry, t.buffer)) : this.fitExtent();
28111      });
28112    }), window.addEventListener("resize", (e) => {
28113      this.updateMaxWidth(), this.updateMaxHeight(), this.map.updateSize();
28114    });
28115  },
28116  watch: {
28117    // Re-fit when the host changes the attribute after mount.
28118    extent() {
28119      this.fitExtent();
28120    },
28121    // Toggle draw mode reactively when the attribute is set/changed/removed.
28122    // A shown geometry the user has not touched survives the toggle (moved
28123    // between the draw source and the view layer, no event); a user's drawing
28124    // is dropped, as before.
28125    draw() {
28126      if (!this.map)
28127        return;
28128      const e = this._shown;
28129      this.teardownDraw(), this.draw && this.setupDraw(), e && this.placeGeometry(e.geometry), this.attachHostMethods();
28130    },
28131    // The host changed or removed the saved geometry after mount. Coalesced to
28132    // one apply per tick: a host that sets `geometry` and then
28133    // `geometry-projection` must not see the coordinates read in the wrong
28134    // projection (and announced) in between.
28135    geometry() {
28136      this.scheduleGeometryAttr();
28137    },
28138    geometryProjection() {
28139      this.geometry && this.scheduleGeometryAttr();
28140    },
28141    // Turning the button off drops a pending request and the marker.
28142    geolocateOn(e) {
28143      e || this.teardownLocation();
28144    },
28145    // A list appears only in point draw: recompute when that changes.
28146    featureListShown() {
28147      this.scheduleFeatureListRefresh();
28148    },
28149    // The attribute resets the panel; the user's toggle otherwise wins.
28150    legendCollapsed(e) {
28151      this.legendOpen = !se(e, !1);
28152    },
28153    // The form requests a reset after a successful submit -> clear the point.
28154    // Drives the Clear control. Reads the bus rather than the vector source so it
28155    // stays reactive — an OL source is markRaw'd and its mutations are invisible to Vue.
28156    hasGeometry() {
28157      return le.hasPoint;
28158    },
28159    busResetSeq() {
28160      this.abortChecks(), this.clearMapPoint();
28161      const e = !!this._lastPassing;
28162      this._lastPassing = null, this.checkBanner = null, this.hasChecks() && e && this.emitChecksCleared();
28163    }
28164  },
28165  beforeUnmount() {
28166    clearTimeout(this._featureListTimer), clearTimeout(this._featurePickTimer), this.bindFeatureListLayer(null), this.teardownLocation(), this.abortChecks(), this.teardownDraw(), this.teardownViewLayer();
28167  },
28168  created() {
28169    this.legendOpen = !se(this.legendCollapsed, !1), this.locateSupport = vS();
28170    const e = this.geometry ? this.resolveGeometryInput(this.geometry, this.geometryProjection) : null;
28171    let t = Je(e ? po(e, 100) : this.formattedExtent);
28172    this.map = Is(new KM({
28173      view: new ri({
28174        projection: "EPSG:27700",
28175        center: t,
28176        zoom: this.z || 0,
28177        constrainResolution: !1
28178      })
28179    })), this.map.on("pointerdrag", () => {
28180      this.locationMessage && (this.locationMessage = "");
28181    }), this.map.on("moveend", (i) => {
28182      this.featureList && this.scheduleFeatureListRefresh();
28183      let n = i.map.getView().getCenter();
28184      this.mapX = n[0], n[1], i.map.getView().getZoom();
28185    });
28186  }
28187}, NS = {
28188  key: 0,
28189  class: "xmap-feature-list"
28190}, GS = {
28191  for: "xmap-feature-list-select",
28192  class: "xmap-feature-list-label"
28193}, zS = ["value"], jS = { value: "" }, WS = ["value"], BS = {
28194  id: "xmap-feature-list-hint",
28195  class: "xmap-feature-list-hint"
28196}, US = {
28197  class: "xmap-visually-hidden",
28198  role: "status",
28199  "aria-live": "polite"
28200}, XS = { class: "xmap-web-map-stage" }, $S = {
28201  ref: "map",
28202  id: "xmap-map"
28203}, YS = ["aria-busy", "aria-disabled"], KS = /* @__PURE__ */ ut("svg", {
28204  viewBox: "0 0 24 24",
28205  width: "1em",
28206  height: "1em",
28207  fill: "none",
28208  stroke: "currentColor",
28209  "stroke-width": "2",
28210  "stroke-linecap": "round",
28211  "stroke-linejoin": "round",
28212  "aria-hidden": "true",
28213  focusable: "false"
28214}, [
28215  /* @__PURE__ */ ut("circle", {
28216    cx: "12",
28217    cy: "12",
28218    r: "7"
28219  }),
28220  /* @__PURE__ */ ut("circle", {
28221    cx: "12",
28222    cy: "12",
28223    r: "2.5",
28224    fill: "currentColor"
28225  }),
28226  /* @__PURE__ */ ut("path", { d: "M12 2v3M12 19v3M2 12h3M19 12h3" })
28227], -1), VS = [
28228  KS
28229], qS = {
28230  key: 1,
28231  class: "xmap-visually-hidden",
28232  role: "status",
28233  "aria-live": "polite"
28234}, HS = {
28235  key: 2,
28236  class: "ol-control xmap-draw-hud"
28237}, ZS = /* @__PURE__ */ ut("svg", {
28238  viewBox: "0 0 24 24",
28239  width: "1em",
28240  height: "1em",
28241  fill: "none",
28242  stroke: "currentColor",
28243  "stroke-width": "2",
28244  "stroke-linecap": "round",
28245  "stroke-linejoin": "round",
28246  "aria-hidden": "true",
28247  focusable: "false"
28248}, [
28249  /* @__PURE__ */ ut("path", { d: "M3 6h18" }),
28250  /* @__PURE__ */ ut("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
28251  /* @__PURE__ */ ut("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
28252  /* @__PURE__ */ ut("path", { d: "M10 11v6" }),
28253  /* @__PURE__ */ ut("path", { d: "M14 11v6" })
28254], -1), JS = [
28255  ZS
28256], QS = ["aria-label"], tT = { class: "ol-control xmap-legend-header" }, eT = ["aria-expanded"], iT = /* @__PURE__ */ ut("path", { d: "M6 9l6 6 6-6" }, null, -1), nT = [
28257  iT
28258], sT = {
28259  key: 0,
28260  id: "xmap-legend-body",
28261  class: "xmap-legend-body"
28262}, rT = {
28263  class: "xmap-legend-swatch",
28264  viewBox: "0 0 20 20",
28265  width: "20",
28266  height: "20",
28267  "aria-hidden": "true",
28268  focusable: "false"
28269}, oT = ["fill", "stroke"], aT = ["stroke", "stroke-width"], lT = ["fill", "stroke", "stroke-width"], hT = { class: "xmap-legend-label" }, cT = { class: "xmap-legend-label" }, uT = ["src", "alt", "onError"], dT = {
28270  key: 5,
28271  class: "xmap-check-banner xmap-check-banner--info"
28272};
28273function fT(e, t, i, n, s, r) {
28274  var o, a;
28275  return it(), st("div", {
28276    class: "xmap-web-map xmap-web-map-container",
28277    style: Gr({
28278      width: `${e.maxWidth}px`,
28279      height: `${e.maxHeight}px`,
28280      "--xmap-primary": r.primaryColor || "#263746",
28281      "--xmap-secondary": r.secondaryColor || "#a1d0ca"
28282    })
28283  }, [
28284    r.featureListShown ? (it(), st("div", NS, [
28285      ut("label", GS, Wt(r.featureListLabel), 1),
28286      ut("select", {
28287        id: "xmap-feature-list-select",
28288        class: "xmap-feature-list-select",
28289        value: e.featureListValue,
28290        "aria-describedby": "xmap-feature-list-hint",
28291        onFocus: t[0] || (t[0] = (...l) => r.onFeatureListFocus && r.onFeatureListFocus(...l)),
28292        onBlur: t[1] || (t[1] = (...l) => r.onFeatureListBlur && r.onFeatureListBlur(...l)),
28293        onChange: t[2] || (t[2] = (l) => r.onFeatureListChange(l.target.value))
28294      }, [
28295        ut("option", jS, Wt(e.featureEntries.length ? r.featureListPlaceholder : r.featureListHint), 1),
28296        (it(!0), st(jt, null, _s(e.featureEntries, (l) => (it(), st("option", {
28297          key: l.key,
28298          value: l.key
28299        }, Wt(l.text), 9, WS))), 128))
28300      ], 40, zS),
28301      ut("p", BS, Wt(r.featureListHint), 1),
28302      ut("div", US, Wt(e.featureListAnnouncement), 1)
28303    ])) : me("", !0),
28304    ut("div", XS, [
28305      ut("div", $S, null, 512),
28306      r.geolocateShown ? (it(), st("div", {
28307        key: 0,
28308        class: Ue(["ol-control xmap-locate", { "xmap-locate--busy": e.locating }])
28309      }, [
28310        ut("button", {
28311          type: "button",
28312          "aria-label": "Show my location",
28313          title: "Show my location",
28314          "aria-busy": String(e.locating),
28315          "aria-disabled": String(e.locating),
28316          onClick: t[3] || (t[3] = (l) => r.locate())
28317        }, VS, 8, YS)
28318      ], 2)) : me("", !0),
28319      r.geolocateOn ? (it(), st("div", qS, Wt(e.locationAnnouncement), 1)) : me("", !0),
28320      r.drawType && r.hasGeometry ? (it(), st("div", HS, [
28321        ut("button", {
28322          type: "button",
28323          onClick: t[4] || (t[4] = (l) => r.clearGeometry()),
28324          "aria-label": "Clear drawing",
28325          title: "Clear drawing"
28326        }, JS)
28327      ])) : me("", !0),
28328      r.legendOn && r.shownLegendEntries.length ? (it(), st("section", {
28329        key: 3,
28330        class: Ue(["xmap-legend", [`xmap-legend--${r.legendCorner}`, { "xmap-legend--below-hud": r.legendBelowHud, "xmap-legend--below-locate": r.legendBelowLocate }]]),
28331        role: "region",
28332        "aria-label": r.legendHeading
28333      }, [
28334        ut("div", tT, [
28335          ut("button", {
28336            type: "button",
28337            "aria-expanded": String(e.legendOpen),
28338            "aria-controls": "xmap-legend-body",
28339            onClick: t[5] || (t[5] = (l) => e.legendOpen = !e.legendOpen)
28340          }, [
28341            ut("span", null, Wt(r.legendHeading), 1),
28342            (it(), st("svg", {
28343              viewBox: "0 0 24 24",
28344              width: "1em",
28345              height: "1em",
28346              fill: "none",
28347              stroke: "currentColor",
28348              "stroke-width": "2",
28349              "stroke-linecap": "round",
28350              "stroke-linejoin": "round",
28351              "aria-hidden": "true",
28352              focusable: "false",
28353              class: Ue([{ "xmap-legend-chevron--open": e.legendOpen }, "xmap-legend-chevron"])
28354            }, nT, 2))
28355          ], 8, eT)
28356        ]),
28357        e.legendOpen ? (it(), st("ul", sT, [
28358          (it(!0), st(jt, null, _s(r.shownLegendEntries, (l) => (it(), st("li", {
28359            key: l.key,
28360            class: Ue(["xmap-legend-item", `xmap-legend-item--${l.kind}`])
28361          }, [
28362            l.kind === "geojson" ? (it(), st(jt, { key: 0 }, [
28363              (it(), st("svg", rT, [
28364                l.swatch.shape === "point" ? (it(), st("circle", {
28365                  key: 0,
28366                  cx: "10",
28367                  cy: "10",
28368                  r: "6",
28369                  fill: l.swatch.fill,
28370                  stroke: l.swatch.stroke,
28371                  "stroke-width": "2"
28372                }, null, 8, oT)) : l.swatch.shape === "line" ? (it(), st("path", {
28373                  key: 1,
28374                  d: "M2 14 L8 6 L12 12 L18 4",
28375                  fill: "none",
28376                  stroke: l.swatch.stroke,
28377                  "stroke-width": l.swatch.strokeWidth,
28378                  "stroke-linecap": "round",
28379                  "stroke-linejoin": "round"
28380                }, null, 8, aT)) : (it(), st("rect", {
28381                  key: 2,
28382                  x: "2",
28383                  y: "4",
28384                  width: "16",
28385                  height: "12",
28386                  fill: l.swatch.fill,
28387                  stroke: l.swatch.stroke,
28388                  "stroke-width": l.swatch.strokeWidth
28389                }, null, 8, lT))
28390              ])),
28391              ut("span", hT, Wt(l.label), 1)
28392            ], 64)) : (it(), st(jt, { key: 1 }, [
28393              ut("span", cT, Wt(l.label), 1),
28394              (it(!0), st(jt, null, _s(l.images, (h) => (it(), st(jt, { key: h }, [
28395                e.legendFailed[h] ? me("", !0) : (it(), st("img", {
28396                  key: 0,
28397                  class: "xmap-legend-image",
28398                  src: h,
28399                  alt: l.label,
28400                  loading: "lazy",
28401                  onError: (c) => e.legendFailed[h] = !0
28402                }, null, 40, uT))
28403              ], 64))), 128))
28404            ], 64))
28405          ], 2))), 128))
28406        ])) : me("", !0)
28407      ], 10, QS)) : me("", !0),
28408      e.checking || e.checkBanner ? (it(), st("div", {
28409        key: 4,
28410        class: Ue(["xmap-check-banner", {
28411          "xmap-check-banner--fail": !e.checking && ((o = e.checkBanner) == null ? void 0 : o.kind) === "fail",
28412          "xmap-check-banner--warn": !e.checking && ((a = e.checkBanner) == null ? void 0 : a.kind) === "warn"
28413        }]),
28414        role: "status",
28415        "aria-live": "polite"
28416      }, Wt(e.checking ? "Checking the location…" : e.checkBanner.text), 3)) : me("", !0),
28417      e.locationMessage && !e.checking && !e.checkBanner ? (it(), st("div", dT, Wt(e.locationMessage), 1)) : me("", !0)
28418    ])
28419  ], 4);
28420}
28421const gT = /* @__PURE__ */ xa(DS, [["render", fT], ["styles", [kS]]]), Mm = 0.5, mT = 10, wd = 0.25;
28422class _T {
28423  /**
28424   * @param {import("../proj/Projection.js").default} sourceProj Source projection.
28425   * @param {import("../proj/Projection.js").default} targetProj Target projection.
28426   * @param {import("../extent.js").Extent} targetExtent Target extent to triangulate.
28427   * @param {import("../extent.js").Extent} maxSourceExtent Maximal source extent that can be used.
28428   * @param {number} errorThreshold Acceptable error (in source units).
28429   * @param {?number} destinationResolution The (optional) resolution of the destination.
28430   */
28431  constructor(t, i, n, s, r, o) {
28432    this.sourceProj_ = t, this.targetProj_ = i;
28433    let a = {};
28434    const l = gr(this.targetProj_, this.sourceProj_);
28435    this.transformInv_ = function(y) {
28436      const x = y[0] + "/" + y[1];
28437      return a[x] || (a[x] = l(y)), a[x];
28438    }, this.maxSourceExtent_ = s, this.errorThresholdSquared_ = r * r, this.triangles_ = [], this.wrapsXInSource_ = !1, this.canWrapXInSource_ = this.sourceProj_.canWrapX() && !!s && !!this.sourceProj_.getExtent() && xt(s) >= xt(this.sourceProj_.getExtent()), this.sourceWorldWidth_ = this.sourceProj_.getExtent() ? xt(this.sourceProj_.getExtent()) : null, this.targetWorldWidth_ = this.targetProj_.getExtent() ? xt(this.targetProj_.getExtent()) : null;
28439    const h = Dn(n), c = oa(n), u = ra(n), d = sa(n), f = this.transformInv_(h), g = this.transformInv_(c), m = this.transformInv_(u), _ = this.transformInv_(d), p = mT + (o ? Math.max(
28440      0,
28441      Math.ceil(
28442        Math.log2(
28443          yl(n) / (o * o * 256 * 256)
28444        )
28445      )
28446    ) : 0);
28447    if (this.addQuad_(
28448      h,
28449      c,
28450      u,
28451      d,
28452      f,
28453      g,
28454      m,
28455      _,
28456      p
28457    ), this.wrapsXInSource_) {
28458      let y = 1 / 0;
28459      this.triangles_.forEach(function(x, E, M) {
28460        y = Math.min(
28461          y,
28462          x.source[0][0],
28463          x.source[1][0],
28464          x.source[2][0]
28465        );
28466      }), this.triangles_.forEach((x) => {
28467        if (Math.max(
28468          x.source[0][0],
28469          x.source[1][0],
28470          x.source[2][0]
28471        ) - y > this.sourceWorldWidth_ / 2) {
28472          const E = [
28473            [x.source[0][0], x.source[0][1]],
28474            [x.source[1][0], x.source[1][1]],
28475            [x.source[2][0], x.source[2][1]]
28476          ];
28477          E[0][0] - y > this.sourceWorldWidth_ / 2 && (E[0][0] -= this.sourceWorldWidth_), E[1][0] - y > this.sourceWorldWidth_ / 2 && (E[1][0] -= this.sourceWorldWidth_), E[2][0] - y > this.sourceWorldWidth_ / 2 && (E[2][0] -= this.sourceWorldWidth_);
28478          const M = Math.min(
28479            E[0][0],
28480            E[1][0],
28481            E[2][0]
28482          );
28483          Math.max(
28484            E[0][0],
28485            E[1][0],
28486            E[2][0]
28487          ) - M < this.sourceWorldWidth_ / 2 && (x.source = E);
28488        }
28489      });
28490    }
28491    a = {};
28492  }
28493  /**
28494   * Adds triangle to the triangulation.
28495   * @param {import("../coordinate.js").Coordinate} a The target a coordinate.
28496   * @param {import("../coordinate.js").Coordinate} b The target b coordinate.
28497   * @param {import("../coordinate.js").Coordinate} c The target c coordinate.
28498   * @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
28499   * @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
28500   * @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
28501   * @private
28502   */
28503  addTriangle_(t, i, n, s, r, o) {
28504    this.triangles_.push({
28505      source: [s, r, o],
28506      target: [t, i, n]
28507    });
28508  }
28509  /**
28510   * Adds quad (points in clock-wise order) to the triangulation
28511   * (and reprojects the vertices) if valid.
28512   * Performs quad subdivision if needed to increase precision.
28513   *
28514   * @param {import("../coordinate.js").Coordinate} a The target a coordinate.
28515   * @param {import("../coordinate.js").Coordinate} b The target b coordinate.
28516   * @param {import("../coordinate.js").Coordinate} c The target c coordinate.
28517   * @param {import("../coordinate.js").Coordinate} d The target d coordinate.
28518   * @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
28519   * @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
28520   * @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
28521   * @param {import("../coordinate.js").Coordinate} dSrc The source d coordinate.
28522   * @param {number} maxSubdivision Maximal allowed subdivision of the quad.
28523   * @private
28524   */
28525  addQuad_(t, i, n, s, r, o, a, l, h) {
28526    const c = ge([r, o, a, l]), u = this.sourceWorldWidth_ ? xt(c) / this.sourceWorldWidth_ : null, d = (
28527      /** @type {number} */
28528      this.sourceWorldWidth_
28529    ), f = this.sourceProj_.canWrapX() && u > 0.5 && u < 1;
28530    let g = !1;
28531    if (h > 0) {
28532      if (this.targetProj_.isGlobal() && this.targetWorldWidth_) {
28533        const _ = ge([t, i, n, s]);
28534        g = xt(_) / this.targetWorldWidth_ > wd || g;
28535      }
28536      !f && this.sourceProj_.isGlobal() && u && (g = u > wd || g);
28537    }
28538    if (!g && this.maxSourceExtent_ && isFinite(c[0]) && isFinite(c[1]) && isFinite(c[2]) && isFinite(c[3]) && !re(c, this.maxSourceExtent_))
28539      return;
28540    let m = 0;
28541    if (!g && (!isFinite(r[0]) || !isFinite(r[1]) || !isFinite(o[0]) || !isFinite(o[1]) || !isFinite(a[0]) || !isFinite(a[1]) || !isFinite(l[0]) || !isFinite(l[1]))) {
28542      if (h > 0)
28543        g = !0;
28544      else if (m = (!isFinite(r[0]) || !isFinite(r[1]) ? 8 : 0) + (!isFinite(o[0]) || !isFinite(o[1]) ? 4 : 0) + (!isFinite(a[0]) || !isFinite(a[1]) ? 2 : 0) + (!isFinite(l[0]) || !isFinite(l[1]) ? 1 : 0), m != 1 && m != 2 && m != 4 && m != 8)
28545        return;
28546    }
28547    if (h > 0) {
28548      if (!g) {
28549        const _ = [(t[0] + n[0]) / 2, (t[1] + n[1]) / 2], p = this.transformInv_(_);
28550        let y;
28551        f ? y = (qi(r[0], d) + qi(a[0], d)) / 2 - qi(p[0], d) : y = (r[0] + a[0]) / 2 - p[0];
28552        const x = (r[1] + a[1]) / 2 - p[1];
28553        g = y * y + x * x > this.errorThresholdSquared_;
28554      }
28555      if (g) {
28556        if (Math.abs(t[0] - n[0]) <= Math.abs(t[1] - n[1])) {
28557          const _ = [(i[0] + n[0]) / 2, (i[1] + n[1]) / 2], p = this.transformInv_(_), y = [(s[0] + t[0]) / 2, (s[1] + t[1]) / 2], x = this.transformInv_(y);
28558          this.addQuad_(
28559            t,
28560            i,
28561            _,
28562            y,
28563            r,
28564            o,
28565            p,
28566            x,
28567            h - 1
28568          ), this.addQuad_(
28569            y,
28570            _,
28571            n,
28572            s,
28573            x,
28574            p,
28575            a,
28576            l,
28577            h - 1
28578          );
28579        } else {
28580          const _ = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], p = this.transformInv_(_), y = [(n[0] + s[0]) / 2, (n[1] + s[1]) / 2], x = this.transformInv_(y);
28581          this.addQuad_(
28582            t,
28583            _,
28584            y,
28585            s,
28586            r,
28587            p,
28588            x,
28589            l,
28590            h - 1
28591          ), this.addQuad_(
28592            _,
28593            i,
28594            n,
28595            y,
28596            p,
28597            o,
28598            a,
28599            x,
28600            h - 1
28601          );
28602        }
28603        return;
28604      }
28605    }
28606    if (f) {
28607      if (!this.canWrapXInSource_)
28608        return;
28609      this.wrapsXInSource_ = !0;
28610    }
28611    m & 11 || this.addTriangle_(t, n, s, r, a, l), m & 14 || this.addTriangle_(t, n, i, r, a, o), m && (m & 13 || this.addTriangle_(i, s, t, o, l, r), m & 7 || this.addTriangle_(i, s, n, o, l, a));
28612  }
28613  /**
28614   * Calculates extent of the `source` coordinates from all the triangles.
28615   *
28616   * @return {import("../extent.js").Extent} Calculated extent.
28617   */
28618  calculateSourceExtent() {
28619    const t = be();
28620    return this.triangles_.forEach(function(i, n, s) {
28621      const r = i.source;
28622      sr(t, r[0]), sr(t, r[1]), sr(t, r[2]);
28623    }), t;
28624  }
28625  /**
28626   * @return {Array<Triangle>} Array of the calculated triangles.
28627   */
28628  getTriangles() {
28629    return this.triangles_;
28630  }
28631}
28632const bm = _T;
28633let ll;
28634const Es = [];
28635function Sd(e, t, i, n, s) {
28636  e.beginPath(), e.moveTo(0, 0), e.lineTo(t, i), e.lineTo(n, s), e.closePath(), e.save(), e.clip(), e.fillRect(0, 0, Math.max(t, n) + 1, Math.max(i, s)), e.restore(
28636);
28637}
28638function hl(e, t) {
28639  return Math.abs(e[t * 4] - 210) > 2 || Math.abs(e[t * 4 + 3] - 0.75 * 255) > 2;
28640}
28641function pT() {
28642  if (ll === void 0) {
28643    const e = he(6, 6, Es);
28644    e.globalCompositeOperation = "lighter", e.fillStyle = "rgba(210, 0, 0, 0.75)", Sd(e, 4, 5, 4, 0), Sd(e, 4, 5, 0, 5);
28645    const t = e.getImageData(0, 0, 3, 3).data;
28646    ll = hl(t, 0) || hl(t, 4) || hl(t, 8), Sa(e), Es.push(e.canvas);
28647  }
28648  return ll;
28649}
28650function Rr(e, t, i, n) {
28651  const s = Ts(i, t, e);
28652  let r = Hc(
28653    t,
28654    n,
28655    i
28656  );
28657  const o = t.getMetersPerUnit();
28658  o !== void 0 && (r *= o);
28659  const a = e.getMetersPerUnit();
28660  a !== void 0 && (r /= a);
28661  const l = e.getExtent();
28662  if (!l || Ds(l, s)) {
28663    const h = Hc(e, r, s) / r;
28664    isFinite(h) && h > 0 && (r /= h);
28665  }
28666  return r;
28667}
28668function yT(e, t, i, n) {
28669  const s = Je(i);
28670  let r = Rr(
28671    e,
28672    t,
28673    s,
28674    n
28675  );
28676  return (!isFinite(r) || r <= 0) && rh(i, function(o) {
28677    return r = Rr(
28678      e,
28679      t,
28680      o,
28681      n
28682    ), isFinite(r) && r > 0;
28683  }), r;
28684}
28685function wm(e, t, i, n, s, r, o, a, l, h, c, u) {
28686  const d = he(
28687    Math.round(i * e),
28688    Math.round(i * t),
28689    Es
28690  );
28691  if (u || (d.imageSmoothingEnabled = !1), l.length === 0)
28692    return d.canvas;
28693  d.scale(i, i);
28694  function f(E) {
28695    return Math.round(E * i) / i;
28696  }
28697  d.globalCompositeOperation = "lighter";
28698  const g = be();
28699  l.forEach(function(E, M, w) {
28700    ef(g, E.extent);
28701  });
28702  const m = xt(g), _ = qt(g), p = he(
28703    Math.round(i * m / n),
28704    Math.round(i * _ / n),
28705    Es
28706  );
28707  u || (p.imageSmoothingEnabled = !1);
28708  const y = i / n;
28709  l.forEach(function(E, M, w) {
28710    const L = E.extent[0] - g[0], I = -(E.extent[3] - g[3]), z = xt(E.extent), U = qt(E.extent);
28711    E.image.width > 0 && E.image.height > 0 && p.drawImage(
28712      E.image,
28713      h,
28714      h,
28715      E.image.width - 2 * h,
28716      E.image.height - 2 * h,
28717      L * y,
28718      I * y,
28719      z * y,
28720      U * y
28721    );
28722  });
28723  const x = Dn(o);
28724  return a.getTriangles().forEach(function(E, M, w) {
28725    const L = E.source, I = E.target;
28726    let z = L[0][0], U = L[0][1], q = L[1][0], K = L[1][1], Z = L[2][0], Mt = L[2][1];
28727    const V = f((I[0][0] - x[0]) / r), Y = f(
28728      -(I[0][1] - x[1]) / r
28729    ), O = f((I[1][0] - x[0]) / r), W = f(
28730      -(I[1][1] - x[1]) / r
28731    ), gt = f((I[2][0] - x[0]) / r), _t = f(
28732      -(I[2][1] - x[1]) / r
28733    ), Pt = z, R = U;
28734    z = 0, U = 0, q -= Pt, K -= R, Z -= Pt, Mt -= R;
28735    const Jt = [
28736      [q, K, 0, 0, O - V],
28737      [Z, Mt, 0, 0, gt - V],
28738      [0, 0, q, K, W - Y],
28739      [0, 0, Z, Mt, _t - Y]
28740    ], vt = Px(Jt);
28741    if (vt) {
28742      if (d.save(), d.beginPath(), pT() || !u) {
28743        d.moveTo(O, W);
28744        const bt = 4, $t = V - O, ce = Y - W;
28745        for (let zt = 0; zt < bt; zt++)
28746          d.lineTo(
28747            O + f((zt + 1) * $t / bt),
28748            W + f(zt * ce / (bt - 1))
28749          ), zt != bt - 1 && d.lineTo(
28750            O + f((zt + 1) * $t / bt),
28751            W + f((zt + 1) * ce / (bt - 1))
28752          );
28753        d.lineTo(gt, _t);
28754      } else
28755        d.moveTo(O, W), d.lineTo(V, Y), d.lineTo(gt, _t);
28756      d.clip(), d.transform(
28757        vt[0],
28758        vt[2],
28759        vt[1],
28760        vt[3],
28761        V,
28762        Y
28763      ), d.translate(
28764        g[0] - Pt,
28765        g[3] - R
28766      ), d.scale(
28767        n / i,
28768        -n / i
28769      ), d.drawImage(p.canvas, 0, 0), d.restore();
28770    }
28771  }), Sa(p), Es.push(p.canvas), c && (d.save(), d.globalCompositeOperation = "source-over", d.strokeStyle = "black", d.lineWidth = 1, a.getTriangles().forEac
28771h(function(E, M, w) {
28772    const L = E.target, I = (L[0][0] - x[0]) / r, z = -(L[0][1] - x[1]) / r, U = (L[1][0] - x[0]) / r, q = -(L[1][1] - x[1]) / r, K = (L[2][0] - x[0]) / r, Z = -(L[2][1] - x[1]) / r;
28773    d.beginPath(), d.moveTo(U, q), d.lineTo(I, z), d.lineTo(K, Z), d.closePath(), d.stroke();
28774  }), d.restore()), d.canvas;
28775}
28776class xT extends Yg {
28777  /**
28778   * @param {import("../proj/Projection.js").default} sourceProj Source projection (of the data).
28779   * @param {import("../proj/Projection.js").default} targetProj Target projection.
28780   * @param {import("../extent.js").Extent} targetExtent Target extent.
28781   * @param {number} targetResolution Target resolution.
28782   * @param {number} pixelRatio Pixel ratio.
28783   * @param {FunctionType} getImageFunction
28784   *     Function returning source images (extent, resolution, pixelRatio).
28785   * @param {boolean} interpolate Use linear interpolation when resampling.
28786   */
28787  constructor(t, i, n, s, r, o, a) {
28788    let l = t.getExtent();
28789    l && t.canWrapX() && (l = l.slice(), l[0] = -1 / 0, l[2] = 1 / 0);
28790    let h = i.getExtent();
28791    h && i.canWrapX() && (h = h.slice(), h[0] = -1 / 0, h[2] = 1 / 0);
28792    const c = h ? En(n, h) : n, u = Je(c), d = Rr(
28793      t,
28794      i,
28795      u,
28796      s
28797    ), f = Mm, g = new bm(
28798      t,
28799      i,
28800      c,
28801      l,
28802      d * f,
28803      s
28804    ), m = g.calculateSourceExtent(), _ = Nn(m) ? null : o(m, d, r), p = _ ? at.IDLE : at.EMPTY, y = _ ? _.getPixelRatio() : 1;
28805    super(n, s, y, p), this.targetProj_ = i, this.maxSourceExtent_ = l, this.triangulation_ = g, this.targetResolution_ = s, this.targetExtent_ = n, this.sourceImage_ = _, this.sourcePixelRatio_ = y, this.interpolate_ = a, this.canvas_ = null, this.sourceListenerKey_ = null;
28806  }
28807  /**
28808   * Clean up.
28809   */
28810  disposeInternal() {
28811    this.state == at.LOADING && this.unlistenSource_(), super.disposeInternal();
28812  }
28813  /**
28814   * @return {HTMLCanvasElement} Image.
28815   */
28816  getImage() {
28817    return this.canvas_;
28818  }
28819  /**
28820   * @return {import("../proj/Projection.js").default} Projection.
28821   */
28822  getProjection() {
28823    return this.targetProj_;
28824  }
28825  /**
28826   * @private
28827   */
28828  reproject_() {
28829    const t = this.sourceImage_.getState();
28830    if (t == at.LOADED) {
28831      const i = xt(this.targetExtent_) / this.targetResolution_, n = qt(this.targetExtent_) / this.targetResolution_;
28832      this.canvas_ = wm(
28833        i,
28834        n,
28835        this.sourcePixelRatio_,
28836        this.sourceImage_.getResolution(),
28837        this.maxSourceExtent_,
28838        this.targetResolution_,
28839        this.targetExtent_,
28840        this.triangulation_,
28841        [
28842          {
28843            extent: this.sourceImage_.getExtent(),
28844            image: this.sourceImage_.getImage()
28845          }
28846        ],
28847        0,
28848        void 0,
28849        this.interpolate_
28850      );
28851    }
28852    this.state = t, this.changed();
28853  }
28854  /**
28855   * Load not yet loaded URI.
28856   */
28857  load() {
28858    if (this.state == at.IDLE) {
28859      this.state = at.LOADING, this.changed();
28860      const t = this.sourceImage_.getState();
28861      t == at.LOADED || t == at.ERROR ? this.reproject_() : (this.sourceListenerKey_ = ct(
28862        this.sourceImage_,
28863        et.CHANGE,
28864        function(i) {
28865          const n = this.sourceImage_.getState();
28866          (n == at.LOADED || n == at.ERROR) && (this.unlistenSource_(), this.reproject_());
28867        },
28868        this
28869      ), this.sourceImage_.load());
28870    }
28871  }
28872  /**
28873   * @private
28874   */
28875  unlistenSource_() {
28876    St(
28877      /** @type {!import("../events.js").EventsKey} */
28878      this.sourceListenerKey_
28879    ), this.sourceListenerKey_ = null;
28880  }
28881}
28882const vT = xT, cl = {
28883  /**
28884   * Triggered when an image starts loading.
28885   * @event module:ol/source/Image.ImageSourceEvent#imageloadstart
28886   * @api
28887   */
28888  IMAGELOADSTART: "imageloadstart",
28889  /**
28890   * Triggered when an image finishes loading.
28891   * @event module:ol/source/Image.ImageSourceEvent#imageloadend
28892   * @api
28893   */
28894  IMAGELOADEND: "imageloadend",
28895  /**
28896   * Triggered if image loading results in an error.
28897   * @event module:ol/source/Image.ImageSourceEvent#imageloaderror
28898   * @api
28899   */
28900  IMAGELOADERROR: "imageloaderror"
28901};
28902class ET extends Le {
28903  /**
28904   * @param {string} type Type.
28905   * @param {import("../Image.js").default} image The image.
28906   */
28907  constructor(t, i) {
28908    super(t), this.image = i;
28909  }
28910}
28911class CT extends uc {
28912  /**
28913   * @param {Options} options Single image source options.
28914   */
28915  constructor(t) {
28916    super({
28917      attributions: t.attributions,
28918      projection: t.projection,
28919      state: t.state,
28920      interpolate: t.interpolate !== void 0 ? t.interpolate : !0
28921    }), this.on, this.once, this.un, this.resolutions_ = t.resolutions !== void 0 ? t.resolutions : null, this.reprojectedImage_ = null, this.reprojectedRevision_ = 0;
28922  }
28923  /**
28924   * @return {Array<number>|null} Resolutions.
28925   */
28926  getResolutions() {
28927    return this.resolutions_;
28928  }
28929  /**
28930   * @param {Array<number>|null} resolutions Resolutions.
28931   */
28932  setResolutions(t) {
28933    this.resolutions_ = t;
28934  }
28935  /**
28936   * @protected
28937   * @param {number} resolution Resolution.
28938   * @return {number} Resolution.
28939   */
28940  findNearestResolution(t) {
28941    const i = this.getResolutions();
28942    if (i) {
28943      const n = va(i, t, 0);
28944      t = i[n];
28945    }
28946    return t;
28947  }
28948  /**
28949   * @param {import("../extent.js").Extent} extent Extent.
28950   * @param {number} resolution Resolution.
28951   * @param {number} pixelRatio Pixel ratio.
28952   * @param {import("../proj/Projection.js").default} projection Projection.
28953   * @return {import("../ImageBase.js").default} Single image.
28954   */
28955  getImage(t, i, n, s) {
28956    const r = this.getProjection();
28957    if (!r || !s || Ci(r, s))
28958      return r && (s = r), this.getImageInternal(t, i, n, s);
28959    if (this.reprojectedImage_) {
28960      if (this.reprojectedRevision_ == this.getRevision() && Ci(this.reprojectedImage_.getProjection(), s) && this.reprojectedImage_.getResolution() == i && Ss(this.reprojectedImage_.getExtent(), t))
28961        return this.reprojectedImage_;
28962      this.reprojectedImage_.dispose(), this.reprojectedImage_ = null;
28963    }
28964    return this.reprojectedImage_ = new vT(
28965      r,
28966      s,
28967      t,
28968      i,
28969      n,
28970      (o, a, l) => this.getImageInternal(o, a, l, r),
28971      this.getInterpolate()
28972    ), this.reprojectedRevision_ = this.getRevision(), this.reprojectedImage_;
28973  }
28974  /**
28975   * @abstract
28976   * @param {import("../extent.js").Extent} extent Extent.
28977   * @param {number} resolution Resolution.
28978   * @param {number} pixelRatio Pixel ratio.
28979   * @param {import("../proj/Projection.js").default} projection Projection.
28980   * @return {import("../ImageBase.js").default} Single image.
28981   * @protected
28982   */
28983  getImageInternal(t, i, n, s) {
28984    return Q();
28985  }
28986  /**
28987   * Handle image change events.
28988   * @param {import("../events/Event.js").default} event Event.
28989   * @protected
28990   */
28991  handleImageChange(t) {
28992    const i = (
28993      /** @type {import("../Image.js").default} */
28994      t.target
28995    );
28996    let n;
28997    switch (i.getState()) {
28998      case at.LOADING:
28999        this.loading = !0, n = cl.IMAGELOADSTART;
29000        break;
29001      case at.LOADED:
29002        this.loading = !1, n = cl.IMAGELOADEND;
29003        break;
29004      case at.ERROR:
29005        this.loading = !1, n = cl.IMAGELOADERROR;
29006        break;
29007      default:
29008        return;
29009    }
29010    this.hasListener(n) && this.dispatchEvent(new ET(n, i));
29011  }
29012}
29013function MT(e, t) {
29014  e.getImage().src = t;
29015}
29016const bT = CT, Ki = "1.3.0";
29017function ea(e, t) {
29018  const i = [];
29019  Object.keys(t).forEach(function(s) {
29020    t[s] !== null && t[s] !== void 0 && i.push(s + "=" + encodeURIComponent(t[s]));
29021  });
29022  const n = i.join("&");
29023  return e = e.replace(/[?&]$/, ""), e += e.includes("?") ? "&" : "?", e + n;
29024}
29025const Di = 4, Td = [101, 101];
29026class wT extends bT {
29027  /**
29028   * @param {Options} [options] ImageWMS options.
29029   */
29030  constructor(t) {
29031    t = t || {}, super({
29032      attributions: t.attributions,
29033      interpolate: t.interpolate,
29034      projection: t.projection,
29035      resolutions: t.resolutions
29036    }), this.context_ = he(1, 1), this.crossOrigin_ = t.crossOrigin !== void 0 ? t.crossOrigin : null, this.url_ = t.url, this.imageLoadFunction_ = t.imageLoadFunction !== void 0 ? t.imageLoadFunction : MT, this.params_ = Object.assign({}, t.params), this.v13_ = !0, this.updateV13_(), this.serverType_ = t.serverType, this.hidpi_ = t.hidpi !== void 0 ? t.hidpi : !0, this.image_ = null, this.imageSize_ = [0, 0], this.renderedRevision_ = 0, this.ratio_ = t.ratio !== void 0 ? t.ratio : 1.5;
29037  }
29038  /**
29039   * Return the GetFeatureInfo URL for the passed coordinate, resolution, and
29040   * projection. Return `undefined` if the GetFeatureInfo URL cannot be
29041   * constructed.
29042   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
29043   * @param {number} resolution Resolution.
29044   * @param {import("../proj.js").ProjectionLike} projection Projection.
29045   * @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
29046   *     be provided. If `QUERY_LAYERS` is not provided then the layers specified
29047   *     in the `LAYERS` parameter will be used. `VERSION` should not be
29048   *     specified here.
29049   * @return {string|undefined} GetFeatureInfo URL.
29050   * @api
29051   */
29052  getFeatureInfoUrl(t, i, n, s) {
29053    if (this.url_ === void 0)
29054      return;
29055    const r = It(n), o = this.getProjection();
29056    o && o !== r && (i = Rr(
29057      o,
29058      r,
29059      t,
29060      i
29061    ), t = Ts(t, r, o));
29062    const a = us(
29063      t,
29064      i,
29065      0,
29066      Td
29067    ), l = {
29068      SERVICE: "WMS",
29069      VERSION: Ki,
29070      REQUEST: "GetFeatureInfo",
29071      FORMAT: "image/png",
29072      TRANSPARENT: !0,
29073      QUERY_LAYERS: this.params_.LAYERS
29074    };
29075    Object.assign(l, this.params_, s);
29076    const h = ss((t[0] - a[0]) / i, Di), c = ss((a[3] - t[1]) / i, Di);
29077    return l[this.v13_ ? "I" : "X"] = h, l[this.v13_ ? "J" : "Y"] = c, this.getRequestUrl_(
29078      a,
29079      Td,
29080      1,
29081      o || r,
29082      l
29083    );
29084  }
29085  /**
29086   * Return the GetLegendGraphic URL, optionally optimized for the passed
29087   * resolution and possibly including any passed specific parameters. Returns
29088   * `undefined` if the GetLegendGraphic URL cannot be constructed.
29089   *
29090   * @param {number} [resolution] Resolution. If set to undefined, `SCALE`
29091   *     will not be calculated and included in URL.
29092   * @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the
29093   *     request is generated for this wms layer, else it will try to use the
29094   *     configured wms layer. Default `FORMAT` is `image/png`.
29095   *     `VERSION` should not be specified here.
29096   * @return {string|undefined} GetLegendGraphic URL.
29097   * @api
29098   */
29099  getLegendUrl(t, i) {
29100    if (this.url_ === void 0)
29101      return;
29102    const n = {
29103      SERVICE: "WMS",
29104      VERSION: Ki,
29105      REQUEST: "GetLegendGraphic",
29106      FORMAT: "image/png"
29107    };
29108    if (i === void 0 || i.LAYER === void 0) {
29109      const s = this.params_.LAYERS;
29110      if (!(!Array.isArray(s) || s.length === 1))
29111        return;
29112      n.LAYER = s;
29113    }
29114    if (t !== void 0) {
29115      const s = this.getProjection() ? this.getProjection().getMetersPerUnit() : 1, r = 28e-5;
29116      n.SCALE = t * s / r;
29117    }
29118    return Object.assign(n, i), ea(
29119      /** @type {string} */
29120      this.url_,
29121      n
29122    );
29123  }
29124  /**
29125   * Get the user-provided params, i.e. those passed to the constructor through
29126   * the "params" option, and possibly updated using the updateParams method.
29127   * @return {Object} Params.
29128   * @api
29129   */
29130  getParams() {
29131    return this.params_;
29132  }
29133  /**
29134   * @param {import("../extent.js").Extent} extent Extent.
29135   * @param {number} resolution Resolution.
29136   * @param {number} pixelRatio Pixel ratio.
29137   * @param {import("../proj/Projection.js").default} projection Projection.
29138   * @return {import("../Image.js").default} Single image.
29139   */
29140  getImageInternal(t, i, n, s) {
29141    if (this.url_ === void 0)
29142      return null;
29143    i = this.findNearestResolution(i), n != 1 && (!this.hidpi_ || this.serverType_ === void 0) && (n = 1);
29144    const r = i / n, o = Je(t), a = Ui(xt(t) / r, Di), l = Ui(qt(t) / r, Di), h = us(o, r, 0, [
29145      a,
29146      l
29147    ]), c = Ui(
29148      this.ratio_ * xt(t) / r,
29149      Di
29150    ), u = Ui(
29151      this.ratio_ * qt(t) / r,
29152      Di
29153    ), d = us(o, r, 0, [
29154      c,
29155      u
29156    ]), f = this.image_;
29157    if (f && this.renderedRevision_ == this.getRevision() && f.getResolution() == i && f.getPixelRatio() == n && Bi(f.getExtent(), h))
29158      return f;
29159    const g = {
29160      SERVICE: "WMS",
29161      VERSION: Ki,
29162      REQUEST: "GetMap",
29163      FORMAT: "image/png",
29164      TRANSPARENT: !0
29165    };
29166    Object.assign(g, this.params_), this.imageSize_[0] = Vc(
29167      xt(d) / r,
29168      Di
29169    ), this.imageSize_[1] = Vc(
29170      qt(d) / r,
29171      Di
29172    );
29173    const m = this.getRequestUrl_(
29174      d,
29175      this.imageSize_,
29176      n,
29177      s,
29178      g
29179    );
29180    return this.image_ = new fb(
29181      d,
29182      i,
29183      n,
29184      m,
29185      this.crossOrigin_,
29186      this.imageLoadFunction_,
29187      this.context_
29188    ), this.renderedRevision_ = this.getRevision(), this.image_.addEventListener(
29189      et.CHANGE,
29190      this.handleImageChange.bind(this)
29191    ), this.image_;
29192  }
29193  /**
29194   * Return the image load function of the source.
29195   * @return {import("../Image.js").LoadFunction} The image load function.
29196   * @api
29197   */
29198  getImageLoadFunction() {
29199    return this.imageLoadFunction_;
29200  }
29201  /**
29202   * @param {import("../extent.js").Extent} extent Extent.
29203   * @param {import("../size.js").Size} size Size.
29204   * @param {number} pixelRatio Pixel ratio.
29205   * @param {import("../proj/Projection.js").default} projection Projection.
29206   * @param {Object} params Params.
29207   * @return {string} Request URL.
29208   * @private
29209   */
29210  getRequestUrl_(t, i, n, s, r) {
29211    if (ht(this.url_ !== void 0, 9), r[this.v13_ ? "CRS" : "SRS"] = s.getCode(), "
29211STYLES" in this.params_ || (r.STYLES = ""), n != 1)
29212      switch (this.serverType_) {
29213        case "geoserver":
29214          const l = 90 * n + 0.5 | 0;
29215          "FORMAT_OPTIONS" in r ? r.FORMAT_OPTIONS += ";dpi:" + l : r.FORMAT_OPTIONS = "dpi:" + l;
29216          break;
29217        case "mapserver":
29218          r.MAP_RESOLUTION = 90 * n;
29219          break;
29220        case "carmentaserver":
29221        case "qgis":
29222          r.DPI = 90 * n;
29223          break;
29224        default:
29225          ht(!1, 8);
29226          break;
29227      }
29228    r.WIDTH = i[0], r.HEIGHT = i[1];
29229    const o = s.getAxisOrientation();
29230    let a;
29231    return this.v13_ && o.substr(0, 2) == "ne" ? a = [t[1], t[0], t[3], t[2]] : a = t, r.BBOX = a.join(","), ea(
29232      /** @type {string} */
29233      this.url_,
29234      r
29235    );
29236  }
29237  /**
29238   * Return the URL used for this WMS source.
29239   * @return {string|undefined} URL.
29240   * @api
29241   */
29242  getUrl() {
29243    return this.url_;
29244  }
29245  /**
29246   * Set the image load function of the source.
29247   * @param {import("../Image.js").LoadFunction} imageLoadFunction Image load function.
29248   * @api
29249   */
29250  setImageLoadFunction(t) {
29251    this.image_ = null, this.imageLoadFunction_ = t, this.changed();
29252  }
29253  /**
29254   * Set the URL to use for requests.
29255   * @param {string|undefined} url URL.
29256   * @api
29257   */
29258  setUrl(t) {
29259    t != this.url_ && (this.url_ = t, this.image_ = null, this.changed());
29260  }
29261  /**
29262   * Update the user-provided params.
29263   * @param {Object} params Params.
29264   * @api
29265   */
29266  updateParams(t) {
29267    Object.assign(this.params_, t), this.updateV13_(), this.image_ = null, this.changed();
29268  }
29269  /**
29270   * @private
29271   */
29272  updateV13_() {
29273    const t = this.params_.VERSION || Ki;
29274    this.v13_ = rf(t, "1.3") >= 0;
29275  }
29276}
29277const ST = wT;
29278class TT extends Zg {
29279  /**
29280   * @param {import("../proj/Projection.js").default} sourceProj Source projection.
29281   * @param {import("../tilegrid/TileGrid.js").default} sourceTileGrid Source tile grid.
29282   * @param {import("../proj/Projection.js").default} targetProj Target projection.
29283   * @param {import("../tilegrid/TileGrid.js").default} targetTileGrid Target tile grid.
29284   * @param {import("../tilecoord.js").TileCoord} tileCoord Coordinate of the tile.
29285   * @param {import("../tilecoord.js").TileCoord} wrappedTileCoord Coordinate of the tile wrapped in X.
29286   * @param {number} pixelRatio Pixel ratio.
29287   * @param {number} gutter Gutter of the source tiles.
29288   * @param {FunctionType} getTileFunction
29289   *     Function returning source tiles (z, x, y, pixelRatio).
29290   * @param {number} [errorThreshold] Acceptable reprojection error (in px).
29291   * @param {boolean} [renderEdges] Render reprojection edges.
29292   * @param {boolean} [interpolate] Use linear interpolation when resampling.
29293   */
29294  constructor(t, i, n, s, r, o, a, l, h, c, u, d) {
29295    super(r, J.IDLE, { interpolate: !!d }), this.renderEdges_ = u !== void 0 ? u : !1, this.pixelRatio_ = a, this.gutter_ = l, this.canvas_ = null, this.sourceTileGrid_ = i, this.targetTileGrid_ = s, this.wrappedTileCoord_ = o || r, this.sourceTiles_ = [], this.sourcesListenerKeys_ = null, this.sourceZ_ = 0;
29296    const f = s.getTileCoordExtent(
29297      this.wrappedTileCoord_
29298    ), g = this.targetTileGrid_.getExtent();
29299    let m = this.sourceTileGrid_.getExtent();
29300    const _ = g ? En(f, g) : f;
29301    if (yl(_) === 0) {
29302      this.state = J.EMPTY;
29303      return;
29304    }
29305    const p = t.getExtent();
29306    p && (m ? m = En(m, p) : m = p);
29307    const y = s.getResolution(
29308      this.wrappedTileCoord_[0]
29309    ), x = yT(
29310      t,
29311      n,
29312      _,
29313      y
29314    );
29315    if (!isFinite(x) || x <= 0) {
29316      this.state = J.EMPTY;
29317      return;
29318    }
29319    const E = c !== void 0 ? c : Mm;
29320    if (this.triangulation_ = new bm(
29321      t,
29322      n,
29323      _,
29324      m,
29325      x * E,
29326      y
29327    ), this.triangulation_.getTriangles().length === 0) {
29328      this.state = J.EMPTY;
29329      return;
29330    }
29331    this.sourceZ_ = i.getZForResolution(x);
29332    let M = this.triangulation_.calculateSourceExtent();
29333    if (m && (t.canWrapX() ? (M[1] = kt(
29334      M[1],
29335      m[1],
29336      m[3]
29337    ), M[3] = kt(
29338      M[3],
29339      m[1],
29340      m[3]
29341    )) : M = En(M, m)), !yl(M))
29342      this.state = J.EMPTY;
29343    else {
29344      const w = i.getTileRangeForExtentAndZ(
29345        M,
29346        this.sourceZ_
29347      );
29348      for (let L = w.minX; L <= w.maxX; L++)
29349        for (let I = w.minY; I <= w.maxY; I++) {
29350          const z = h(this.sourceZ_, L, I, a);
29351          z && this.sourceTiles_.push(z);
29352        }
29353      this.sourceTiles_.length === 0 && (this.state = J.EMPTY);
29354    }
29355  }
29356  /**
29357   * Get the HTML Canvas element for this tile.
29358   * @return {HTMLCanvasElement} Canvas.
29359   */
29360  getImage() {
29361    return this.canvas_;
29362  }
29363  /**
29364   * @private
29365   */
29366  reproject_() {
29367    const t = [];
29368    if (this.sourceTiles_.forEach((i) => {
29369      i && i.getState() == J.LOADED && t.push({
29370        extent: this.sourceTileGrid_.getTileCoordExtent(i.tileCoord),
29371        image: i.getImage()
29372      });
29373    }), this.sourceTiles_.length = 0, t.length === 0)
29374      this.state = J.ERROR;
29375    else {
29376      const i = this.wrappedTileCoord_[0], n = this.targetTileGrid_.getTileSize(i), s = typeof n == "number" ? n : n[0], r = typeof n == "number" ? n : n[1], o = this.targetTileGrid_.getResolution(i), a = this.sourceTileGrid_.getResolution(
29377        this.sourceZ_
29378      ), l = this.targetTileGrid_.getTileCoordExtent(
29379        this.wrappedTileCoord_
29380      );
29381      this.canvas_ = wm(
29382        s,
29383        r,
29384        this.pixelRatio_,
29385        a,
29386        this.sourceTileGrid_.getExtent(),
29387        o,
29388        l,
29389        this.triangulation_,
29390        t,
29391        this.gutter_,
29392        this.renderEdges_,
29393        this.interpolate
29394      ), this.state = J.LOADED;
29395    }
29396    this.changed();
29397  }
29398  /**
29399   * Load not yet loaded URI.
29400   */
29401  load() {
29402    if (this.state == J.IDLE) {
29403      this.state = J.LOADING, this.changed();
29404      let t = 0;
29405      this.sourcesListenerKeys_ = [], this.sourceTiles_.forEach((i) => {
29406        const n = i.getState();
29407        if (n == J.IDLE || n == J.LOADING) {
29408          t++;
29409          const s = ct(
29410            i,
29411            et.CHANGE,
29412            function(r) {
29413              const o = i.getState();
29414              (o == J.LOADED || o == J.ERROR || o == J.EMPTY) && (St(s), t--, t === 0 && (this.unlistenSources_(), this.reproject_()));
29415            },
29416            this
29417          );
29418          this.sourcesListenerKeys_.push(s);
29419        }
29420      }), t === 0 ? setTimeout(this.reproject_.bind(this), 0) : this.sourceTiles_.forEach(function(i, n, s) {
29421        i.getState() == J.IDLE && i.load();
29422      });
29423    }
29424  }
29425  /**
29426   * @private
29427   */
29428  unlistenSources_() {
29429    this.sourcesListenerKeys_.forEach(St), this.sourcesListenerKeys_ = null;
29430  }
29431  /**
29432   * Remove from the cache due to expiry
29433   */
29434  release() {
29435    this.canvas_ && (Sa(this.canvas_.getContext("2d")), Es.push(this.canvas_), this.canvas_ = null), super.release();
29436  }
29437}
29438const ql = TT, ul = {
29439  /**
29440   * Triggered when a tile starts loading.
29441   * @event module:ol/source/Tile.TileSourceEvent#tileloadstart
29442   * @api
29443   */
29444  TILELOADSTART: "tileloadstart",
29445  /**
29446   * Triggered when a tile finishes loading, either when its data is loaded,
29447   * or when loading was aborted because the tile is no longer needed.
29448   * @event module:ol/source/Tile.TileSourceEvent#tileloadend
29449   * @api
29450   */
29451  TILELOADEND: "tileloadend",
29452  /**
29453   * Triggered if tile loading results in an error. Note that this is not the
29454   * right place to re-fetch tiles. See {@link module:ol/ImageTile~ImageTile#load}
29455   * for details.
29456   * @event module:ol/source/Tile.TileSourceEvent#tileloaderror
29457   * @api
29458   */
29459  TILELOADERROR: "tileloaderror"
29460}, Kn = [0, 0, 0], Ni = 5;
29461class IT {
29462  /**
29463   * @param {Options} options Tile grid options.
29464   */
29465  constructor(t) {
29466    this.minZoom = t.minZoom !== void 0 ? t.minZoom : 0, this.resolutions_ = t.resolutions, ht(
29467      PE(
29468        this.resolutions_,
29469        function(s, r) {
29470          return r - s;
29471        },
29472        !0
29473      ),
29474      17
29475    );
29476    let i;
29477    if (!t.origins) {
29478      for (let s = 0, r = this.resolutions_.length - 1; s < r; ++s)
29479        if (!i)
29480          i = this.resolutions_[s] / this.resolutions_[s + 1];
29481        else if (this.resolutions_[s] / this.resolutions_[s + 1] !== i) {
29482          i = void 0;
29483          break;
29484        }
29485    }
29486    this.zoomFactor_ = i, this.maxZoom = this.resolutions_.length - 1, this.origin_ = t.origin !== void 0 ? t.origin : null, this.origins_ = null, t.origins !== void 0 && (this.origins_ = t.origins, ht(this.origins_.length == this.resolutions_.length, 20));
29487    const n = t.extent;
29488    n !== void 0 && !this.origin_ && !this.origins_ && (this.origin_ = Dn(n)), ht(
29489      !this.origin_ && this.origins_ || this.origin_ && !this.origins_,
29490      18
29491    ), this.tileSizes_ = null, t.tileSizes !== void 0 && (this.tileSizes_ = t.tileSizes, ht(this.tileSizes_.length == this.resolutions_.length, 19)), this.tileSize_ = t.tileSize !== void 0 ? t.tileSize : this.tileSizes_ ? null : kh, ht(
29492      !this.tileSize_ && this.tileSizes_ || this.tileSize_ && !this.tileSizes_,
29493      22
29494    ), this.extent_ = n !== void 0 ? n : null, this.fullTileRanges_ = null, this.tmpSize_ = [0, 0], this.tmpExtent_ = [0, 0, 0, 0], t.sizes !== void 0 ? this.fullTileRanges_ = t.sizes.map(function(s, r) {
29495      const o = new nm(
29496        Math.min(0, s[0]),
29497        Math.max(s[0] - 1, -1),
29498        Math.min(0, s[1]),
29499        Math.max(s[1] - 1, -1)
29500      );
29501      if (n) {
29502        const a = this.getTileRangeForExtentAndZ(n, r);
29503        o.minX = Math.max(a.minX, o.minX), o.maxX = Math.min(a.maxX, o.maxX), o.minY = Math.max(a.minY, o.minY), o.maxY = Math.min(a.maxY, o.maxY);
29504      }
29505      return o;
29506    }, this) : n && this.calculateTileRanges_(n);
29507  }
29508  /**
29509   * Call a function with each tile coordinate for a given extent and zoom level.
29510   *
29511   * @param {import("../extent.js").Extent} extent Extent.
29512   * @param {number} zoom Integer zoom level.
29513   * @param {function(import("../tilecoord.js").TileCoord): void} callback Function called with each tile coordinate.
29514   * @api
29515   */
29516  forEachTileCoord(t, i, n) {
29517    const s = this.getTileRangeForExtentAndZ(t, i);
29518    for (let r = s.minX, o = s.maxX; r <= o; ++r)
29519      for (let a = s.minY, l = s.maxY; a <= l; ++a)
29520        n([i, r, a]);
29521  }
29522  /**
29523   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
29524   * @param {function(number, import("../TileRange.js").default): boolean} callback Callback.
29525   * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
29526   * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
29527   * @return {boolean} Callback succeeded.
29528   */
29529  forEachTileCoordParentTileRange(t, i, n, s) {
29530    let r, o, a, l = null, h = t[0] - 1;
29531    for (this.zoomFactor_ === 2 ? (o = t[1], a = t[2]) : l = this.getTileCoordExtent(t, s); h >= this.minZoom; ) {
29532      if (this.zoomFactor_ === 2 ? (o = Math.floor(o / 2), a = Math.floor(a / 2), r = Yn(o, o, a, a, n)) : r = this.getTileRangeForExtentAndZ(
29533        l,
29534        h,
29535        n
29536      ), i(h, r))
29537        return !0;
29538      --h;
29539    }
29540    return !1;
29541  }
29542  /**
29543   * Get the extent for this tile grid, if it was configured.
29544   * @return {import("../extent.js").Extent} Extent.
29545   * @api
29546   */
29547  getExtent() {
29548    return this.extent_;
29549  }
29550  /**
29551   * Get the maximum zoom level for the grid.
29552   * @return {number} Max zoom.
29553   * @api
29554   */
29555  getMaxZoom() {
29556    return this.maxZoom;
29557  }
29558  /**
29559   * Get the minimum zoom level for the grid.
29560   * @return {number} Min zoom.
29561   * @api
29562   */
29563  getMinZoom() {
29564    return this.minZoom;
29565  }
29566  /**
29567   * Get the origin for the grid at the given zoom level.
29568   * @param {number} z Integer zoom level.
29569   * @return {import("../coordinate.js").Coordinate} Origin.
29570   * @api
29571   */
29572  getOrigin(t) {
29573    return this.origin_ ? this.origin_ : this.origins_[t];
29574  }
29575  /**
29576   * Get the resolution for the given zoom level.
29577   * @param {number} z Integer zoom level.
29578   * @return {number} Resolution.
29579   * @api
29580   */
29581  getResolution(t) {
29582    return this.resolutions_[t];
29583  }
29584  /**
29585   * Get the list of resolutions for the tile grid.
29586   * @return {Array<number>} Resolutions.
29587   * @api
29588   */
29589  getResolutions() {
29590    return this.resolutions_;
29591  }
29592  /**
29593   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
29594   * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
29595   * @param {import("../extent.js").Extent} [tempExtent] Temporary import("../extent.js").Extent object.
29596   * @return {import("../TileRange.js").default|null} Tile range.
29597   */
29598  getTileCoordChildTileRange(t, i, n) {
29599    if (t[0] < this.maxZoom) {
29600      if (this.zoomFactor_ === 2) {
29601        const r = t[1] * 2, o = t[2] * 2;
29602        return Yn(
29603          r,
29604          r + 1,
29605          o,
29606          o + 1,
29607          i
29608        );
29609      }
29610      const s = this.getTileCoordExtent(
29611        t,
29612        n || this.tmpExtent_
29613      );
29614      return this.getTileRangeForExtentAndZ(
29615        s,
29616        t[0] + 1,
29617        i
29618      );
29619    }
29620    return null;
29621  }
29622  /**
29623   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
29624   * @param {number} z Integer zoom level.
29625   * @param {import("../TileRange.js").default} [tempTileRange] Temporary import("../TileRange.js").default object.
29626   * @return {import("../TileRange.js").default|null} Tile range.
29627   */
29628  getTileRangeForTileCoordAndZ(t, i, n) {
29629    if (i > this.maxZoom || i < this.minZoom)
29630      return null;
29631    const s = t[0], r = t[1], o = t[2];
29632    if (i === s)
29633      return Yn(
29634        r,
29635        o,
29636        r,
29637        o,
29638        n
29639      );
29640    if (this.zoomFactor_) {
29641      const l = Math.pow(this.zoomFactor_, i - s), h = Math.floor(r * l), c = Math.floor(o * l);
29642      if (i < s)
29643        return Yn(h, h, c, c, n);
29644      const u = Math.floor(l * (r + 1)) - 1, d = Math.floor(l * (o + 1)) - 1;
29645      return Yn(h, u, c, d, n);
29646    }
29647    const a = this.getTileCoordExtent(t, this.tmpExtent_);
29648    return this.getTileRangeForExtentAndZ(a, i, n);
29649  }
29650  /**
29651   * Get a tile range for the given extent and integer zoom level.
29652   * @param {import("../extent.js").Extent} extent Extent.
29653   * @param {number} z Integer zoom level.
29654   * @param {import("../TileRange.js").default} [tempTileRange] Temporary tile range object.
29655   * @return {import("../TileRange.js").default} Tile range.
29656   */
29657  getTileRangeForExtentAndZ(t, i, n) {
29658    this.getTileCoordForXYAndZ_(t[0], t[3], i, !1, Kn);
29659    const s = Kn[1], r = Kn[2];
29660    this.getTileCoordForXYAndZ_(t[2], t[1], i, !0, Kn);
29661    const o = Kn[1], a = Kn[2];
29662    return Yn(s, o, r, a, n);
29663  }
29664  /**
29665   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
29666   * @return {import("../coordinate.js").Coordinate} Tile center.
29667   */
29668  getTileCoordCenter(t) {
29669    const i = this.getOrigin(t[0]), n = this.getResolution(t[0]), s = Ce(this.getTileSize(t[0]), this.tmpSize_);
29670    return [
29671      i[0] + (t[1] + 0.5) * s[0] * n,
29672      i[1] - (t[2] + 0.5) * s[1] * n
29673    ];
29674  }
29675  /**
29676   * Get the extent of a tile coordinate.
29677   *
29678   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
29679   * @param {import("../extent.js").Extent} [tempExtent] Temporary extent object.
29680   * @return {import("../extent.js").Extent} Extent.
29681   * @api
29682   */
29683  getTileCoordExtent(t, i) {
29684    const n = this.getOrigin(t[0]), s = this.getResolution(t[0]), r = Ce(this.getTileSize(t[0]), this.tmpSize_), o = n[0] + t[1] * r[0] * s, a = n[1] - (t[2] + 1) * r[1] * s, l = o + r[0] * s, h = a + r[1] * s;
29685    return fi(o, a, l, h, i);
29686  }
29687  /**
29688   * Get the tile coordinate for the given map coordinate and resolution.  This
29689   * method considers that coordinates that intersect tile boundaries should be
29690   * assigned the higher tile coordinate.
29691   *
29692   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
29693   * @param {number} resolution Resolution.
29694   * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
29695   * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
29696   * @api
29697   */
29698  getTileCoordForCoordAndResolution(t, i, n) {
29699    return this.getTileCoordForXYAndResolution_(
29700      t[0],
29701      t[1],
29702      i,
29703      !1,
29704      n
29705    );
29706  }
29707  /**
29708   * Note that this method should not be called for resolutions that correspond
29709   * to an integer zoom level.  Instea
29709d call the `getTileCoordForXYAndZ_` method.
29710   * @param {number} x X.
29711   * @param {number} y Y.
29712   * @param {number} resolution Resolution (for a non-integer zoom level).
29713   * @param {boolean} reverseIntersectionPolicy Instead of letting edge
29714   *     intersections go to the higher tile coordinate, let edge intersections
29715   *     go to the lower tile coordinate.
29716   * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
29717   * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
29718   * @private
29719   */
29720  getTileCoordForXYAndResolution_(t, i, n, s, r) {
29721    const o = this.getZForResolution(n), a = n / this.getResolution(o), l = this.getOrigin(o), h = Ce(this.getTileSize(o), this.tmpSize_);
29722    let c = a * (t - l[0]) / n / h[0], u = a * (l[1] - i) / n / h[1];
29723    return s ? (c = Ui(c, Ni) - 1, u = Ui(u, Ni) - 1) : (c = ss(c, Ni), u = ss(u, Ni)), ud(o, c, u, r);
29724  }
29725  /**
29726   * Although there is repetition between this method and `getTileCoordForXYAndResolution_`,
29727   * they should have separate implementations.  This method is for integer zoom
29728   * levels.  The other method should only be called for resolutions corresponding
29729   * to non-integer zoom levels.
29730   * @param {number} x Map x coordinate.
29731   * @param {number} y Map y coordinate.
29732   * @param {number} z Integer zoom level.
29733   * @param {boolean} reverseIntersectionPolicy Instead of letting edge
29734   *     intersections go to the higher tile coordinate, let edge intersections
29735   *     go to the lower tile coordinate.
29736   * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Temporary import("../tilecoord.js").TileCoord object.
29737   * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
29738   * @private
29739   */
29740  getTileCoordForXYAndZ_(t, i, n, s, r) {
29741    const o = this.getOrigin(n), a = this.getResolution(n), l = Ce(this.getTileSize(n), this.tmpSize_);
29742    let h = (t - o[0]) / a / l[0], c = (o[1] - i) / a / l[1];
29743    return s ? (h = Ui(h, Ni) - 1, c = Ui(c, Ni) - 1) : (h = ss(h, Ni), c = ss(c, Ni)), ud(n, h, c, r);
29744  }
29745  /**
29746   * Get a tile coordinate given a map coordinate and zoom level.
29747   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
29748   * @param {number} z Zoom level.
29749   * @param {import("../tilecoord.js").TileCoord} [opt_tileCoord] Destination import("../tilecoord.js").TileCoord object.
29750   * @return {import("../tilecoord.js").TileCoord} Tile coordinate.
29751   * @api
29752   */
29753  getTileCoordForCoordAndZ(t, i, n) {
29754    return this.getTileCoordForXYAndZ_(
29755      t[0],
29756      t[1],
29757      i,
29758      !1,
29759      n
29760    );
29761  }
29762  /**
29763   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
29764   * @return {number} Tile resolution.
29765   */
29766  getTileCoordResolution(t) {
29767    return this.resolutions_[t[0]];
29768  }
29769  /**
29770   * Get the tile size for a zoom level. The type of the return value matches the
29771   * `tileSize` or `tileSizes` that the tile grid was configured with. To always
29772   * get an {@link import("../size.js").Size}, run the result through {@link module:ol/size.toSize}.
29773   * @param {number} z Z.
29774   * @return {number|import("../size.js").Size} Tile size.
29775   * @api
29776   */
29777  getTileSize(t) {
29778    return this.tileSize_ ? this.tileSize_ : this.tileSizes_[t];
29779  }
29780  /**
29781   * @param {number} z Zoom level.
29782   * @return {import("../TileRange.js").default} Extent tile range for the specified zoom level.
29783   */
29784  getFullTileRange(t) {
29785    return this.fullTileRanges_ ? this.fullTileRanges_[t] : this.extent_ ? this.getTileRangeForExtentAndZ(this.extent_, t) : null;
29786  }
29787  /**
29788   * @param {number} resolution Resolution.
29789   * @param {number|import("../array.js").NearestDirectionFunction} [opt_direction]
29790   *     If 0, the nearest resolution will be used.
29791   *     If 1, the nearest higher resolution (lower Z) will be used. If -1, the
29792   *     nearest lower resolution (higher Z) will be used. Default is 0.
29793   *     Use a {@link module:ol/array~NearestDirectionFunction} for more precise control.
29794   *
29795   * For example to change tile Z at the midpoint of zoom levels
29796   * ```js
29797   * function(value, high, low) {
29798   *   return value - low * Math.sqrt(high / low);
29799   * }
29800   * ```
29801   * @return {number} Z.
29802   * @api
29803   */
29804  getZForResolution(t, i) {
29805    const n = va(
29806      this.resolutions_,
29807      t,
29808      i || 0
29809    );
29810    return kt(n, this.minZoom, this.maxZoom);
29811  }
29812  /**
29813   * The tile with the provided tile coordinate intersects the given viewport.
29814   * @param {import('../tilecoord.js').TileCoord} tileCoord Tile coordinate.
29815   * @param {Array<number>} viewport Viewport as returned from {@link module:ol/extent.getRotatedViewport}.
29816   * @return {boolean} The tile with the provided tile coordinate intersects the given viewport.
29817   */
29818  tileCoordIntersectsViewport(t, i) {
29819    return Cg(
29820      i,
29821      0,
29822      i.length,
29823      2,
29824      this.getTileCoordExtent(t)
29825    );
29826  }
29827  /**
29828   * @param {!import("../extent.js").Extent} extent Extent for this tile grid.
29829   * @private
29830   */
29831  calculateTileRanges_(t) {
29832    const i = this.resolutions_.length, n = new Array(i);
29833    for (let s = this.minZoom; s < i; ++s)
29834      n[s] = this.getTileRangeForExtentAndZ(t, s);
29835    this.fullTileRanges_ = n;
29836  }
29837}
29838const RT = IT;
29839function Sm(e) {
29840  let t = e.getDefaultTileGrid();
29841  return t || (t = OT(e), e.setDefaultTileGrid(t)), t;
29842}
29843function PT(e, t, i) {
29844  const n = t[0], s = e.getTileCoordCenter(t), r = Tm(i);
29845  if (!Ds(r, s)) {
29846    const o = xt(r), a = Math.ceil(
29847      (r[0] - s[0]) / o
29848    );
29849    return s[0] += o * a, e.getTileCoordForCoordAndZ(s, n);
29850  }
29851  return t;
29852}
29853function LT(e, t, i, n) {
29854  n = n !== void 0 ? n : "top-left";
29855  const s = AT(e, t, i);
29856  return new RT({
29857    extent: e,
29858    origin: bx(e, n),
29859    resolutions: s,
29860    tileSize: i
29861  });
29862}
29863function AT(e, t, i, n) {
29864  t = t !== void 0 ? t : QE, i = Ce(i !== void 0 ? i : kh);
29865  const s = qt(e), r = xt(e);
29866  n = n > 0 ? n : Math.max(r / i[0], s / i[1]);
29867  const o = t + 1, a = new Array(o);
29868  for (let l = 0; l < o; ++l)
29869    a[l] = n / Math.pow(2, l);
29870  return a;
29871}
29872function OT(e, t, i, n) {
29873  const s = Tm(e);
29874  return LT(s, t, i, n);
29875}
29876function Tm(e) {
29877  e = It(e);
29878  let t = e.getExtent();
29879  if (!t) {
29880    const i = 180 * fr.degrees / e.getMetersPerUnit();
29881    t = fi(-i, -i, i, i);
29882  }
29883  return t;
29884}
29885class FT extends uc {
29886  /**
29887   * @param {Options} options SourceTile source options.
29888   */
29889  constructor(t) {
29890    super({
29891      attributions: t.attributions,
29892      attributionsCollapsible: t.attributionsCollapsible,
29893      projection: t.projection,
29894      state: t.state,
29895      wrapX: t.wrapX,
29896      interpolate: t.interpolate
29897    }), this.on, this.once, this.un, this.opaque_ = t.opaque !== void 0 ? t.opaque : !1, this.tilePixelRatio_ = t.tilePixelRatio !== void 0 ? t.tilePixelRatio : 1, this.tileGrid = t.tileGrid !== void 0 ? t.tileGrid : null;
29898    const i = [256, 256];
29899    this.tileGrid && Ce(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()), i), this.tileCache = new em(t.cacheSize || 0), this.tmpSize = [0, 0], this.key_ = t.key || "", this.tileOptions = {
29900      transition: t.transition,
29901      interpolate: t.interpolate
29902    }, this.zDirection = t.zDirection ? t.zDirection : 0;
29903  }
29904  /**
29905   * @return {boolean} Can expire cache.
29906   */
29907  canExpireCache() {
29908    return this.tileCache.canExpireCache();
29909  }
29910  /**
29911   * @param {import("../proj/Projection.js").default} projection Projection.
29912   * @param {!Object<string, boolean>} usedTiles Used tiles.
29913   */
29914  expireCache(t, i) {
29915    const n = this.getTileCacheForProjection(t);
29916    n && n.expireCache(i);
29917  }
29918  /**
29919   * @param {import("../proj/Projection.js").default} projection Projection.
29920   * @param {number} z Zoom level.
29921   * @param {import("../TileRange.js").default} tileRange Tile range.
29922   * @param {function(import("../Tile.js").default):(boolean|void)} callback Called with each
29923   *     loaded tile.  If the callback returns `false`, the tile will not be
29924   *     considered loaded.
29925   * @return {boolean} The tile range is fully covered with loaded tiles.
29926   */
29927  forEachLoadedTile(t, i, n, s) {
29928    const r = this.getTileCacheForProjection(t);
29929    if (!r)
29930      return !1;
29931    let o = !0, a, l, h;
29932    for (let c = n.minX; c <= n.maxX; ++c)
29933      for (let u = n.minY; u <= n.maxY; ++u)
29934        l = Ia(i, c, u), h = !1, r.containsKey(l) && (a = /** @type {!import("../Tile.js").default} */
29935        r.get(l), h = a.getState() === J.LOADED, h && (h = s(a) !== !1)), h || (o = !1);
29936    return o;
29937  }
29938  /**
29939   * @param {import("../proj/Projection.js").default} projection Projection.
29940   * @return {number} Gutter.
29941   */
29942  getGutterForProjection(t) {
29943    return 0;
29944  }
29945  /**
29946   * Return the key to be used for all tiles in the source.
29947   * @return {string} The key for all tiles.
29948   */
29949  getKey() {
29950    return this.key_;
29951  }
29952  /**
29953   * Set the value to be used as the key for all tiles in the source.
29954   * @param {string} key The key for tiles.
29955   * @protected
29956   */
29957  setKey(t) {
29958    this.key_ !== t && (this.key_ = t, this.changed());
29959  }
29960  /**
29961   * @param {import("../proj/Projection.js").default} projection Projection.
29962   * @return {boolean} Opaque.
29963   */
29964  getOpaque(t) {
29965    return this.opaque_;
29966  }
29967  /**
29968   * @param {import("../proj/Projection").default} [projection] Projection.
29969   * @return {Array<number>|null} Resolutions.
29970   */
29971  getResolutions(t) {
29972    const i = t ? this.getTileGridForProjection(t) : this.tileGrid;
29973    return i ? i.getResolutions() : null;
29974  }
29975  /**
29976   * @abstract
29977   * @param {number} z Tile coordinate z.
29978   * @param {number} x Tile coordinate x.
29979   * @param {number} y Tile coordinate y.
29980   * @param {number} pixelRatio Pixel ratio.
29981   * @param {import("../proj/Projection.js").default} projection Projection.
29982   * @return {!import("../Tile.js").default} Tile.
29983   */
29984  getTile(t, i, n, s, r) {
29985    return Q();
29986  }
29987  /**
29988   * Return the tile grid of the tile source.
29989   * @return {import("../tilegrid/TileGrid.js").default|null} Tile grid.
29990   * @api
29991   */
29992  getTileGrid() {
29993    return this.tileGrid;
29994  }
29995  /**
29996   * @param {import("../proj/Projection.js").default} projection Projection.
29997   * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
29998   */
29999  getTileGridForProjection(t) {
30000    return this.tileGrid ? this.tileGrid : Sm(t);
30001  }
30002  /**
30003   * @param {import("../proj/Projection.js").default} projection Projection.
30004   * @return {import("../TileCache.js").default} Tile cache.
30005   * @protected
30006   */
30007  getTileCacheForProjection(t) {
30008    const i = this.getProjection();
30009    return ht(
30010      i === null || Ci(i, t),
30011      68
30012      // A VectorTile source can only be rendered if it has a projection compatible with the view projection.
30013    ), this.tileCache;
30014  }
30015  /**
30016   * Get the tile pixel ratio for this source. Subclasses may override this
30017   * method, which is meant to return a supported pixel ratio that matches the
30018   * provided `pixelRatio` as close as possible.
30019   * @param {number} pixelRatio Pixel ratio.
30020   * @return {number} Tile pixel ratio.
30021   */
30022  getTilePixelRatio(t) {
30023    return this.tilePixelRatio_;
30024  }
30025  /**
30026   * @param {number} z Z.
30027   * @param {number} pixelRatio Pixel ratio.
30028   * @param {import("../proj/Projection.js").default} projection Projection.
30029   * @return {import("../size.js").Size} Tile size.
30030   */
30031  getTilePixelSize(t, i, n) {
30032    const s = this.getTileGridForProjection(n), r = this.getTilePixelRatio(i), o = Ce(s.getTileSize(t), this.tmpSize);
30033    return r == 1 ? o : Dg(o, r, this.tmpSize);
30034  }
30035  /**
30036   * Returns a tile coordinate wrapped around the x-axis. When the tile coordinate
30037   * is outside the resolution and extent range of the tile grid, `null` will be
30038   * returned.
30039   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
30040   * @param {import("../proj/Projection.js").default} [projection] Projection.
30041   * @return {import("../tilecoord.js").TileCoord} Tile coordinate to be passed to the tileUrlFunction or
30042   *     null if no tile URL should be created for the passed `tileCoord`.
30043   */
30044  getTileCoordForTileUrlFunction(t, i) {
30045    i = i !== void 0 ? i : this.getProjection();
30046    const n = this.getTileGridForProjection(i);
30047    return this.getWrapX() && i.isGlobal() && (t = PT(n, t, i)), vw(t, n) ? t : null;
30048  }
30049  /**
30050   * Remove all cached tiles from the source. The next render cycle will fetch new tiles.
30051   * @api
30052   */
30053  clear() {
30054    this.tileCache.clear();
30055  }
30056  refresh() {
30057    this.clear(), super.refresh();
30058  }
30059  /**
30060   * Increases the cache size if needed
30061   * @param {number} tileCount Minimum number of tiles needed.
30062   * @param {import("../proj/Projection.js").default} projection Projection.
30063   */
30064  updateCacheSize(t, i) {
30065    const n = this.getTileCacheForProjection(i);
30066    t > n.highWaterMark && (n.highWaterMark = t);
30067  }
30068  /**
30069   * Marks a tile coord as being used, without triggering a load.
30070   * @abstract
30071   * @param {number} z Tile coordinate z.
30072   * @param {number} x Tile coordinate x.
30073   * @param {number} y Tile coordinate y.
30074   * @param {import("../proj/Projection.js").default} projection Projection.
30075   */
30076  useTile(t, i, n, s) {
30077  }
30078}
30079class kT extends Le {
30080  /**
30081   * @param {string} type Type.
30082   * @param {import("../Tile.js").default} tile The tile.
30083   */
30084  constructor(t, i) {
30085    super(t), this.tile = i;
30086  }
30087}
30088const DT = FT;
30089function NT(e, t) {
30090  const i = /\{z\}/g, n = /\{x\}/g, s = /\{y\}/g, r = /\{-y\}/g;
30091  return (
30092    /**
30093     * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
30094     * @param {number} pixelRatio Pixel ratio.
30095     * @param {import("./proj/Projection.js").default} projection Projection.
30096     * @return {string|undefined} Tile URL.
30097     */
30098    function(o, a, l) {
30099      if (o)
30100        return e.replace(i, o[0].toString()).replace(n, o[1].toString()).replace(s, o[2].toString()).replace(r, function() {
30101          const h = o[0], c = t.getFullTileRange(h);
30102          return ht(c, 55), (c.getHeight() - o[2] - 1).toString();
30103        });
30104    }
30105  );
30106}
30107function GT(e, t) {
30108  const i = e.length, n = new Array(i);
30109  for (let s = 0; s < i; ++s)
30110    n[s] = NT(e[s], t);
30111  return zT(n);
30112}
30113function zT(e) {
30114  return e.length === 1 ? e[0] : (
30115    /**
30116     * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
30117     * @param {number} pixelRatio Pixel ratio.
30118     * @param {import("./proj/Projection.js").default} projection Projection.
30119     * @return {string|undefined} Tile URL.
30120     */
30121    function(t, i, n) {
30122      if (!t)
30123        return;
30124      const s = tm(t), r = qi(s, e.length);
30125      return e[r](t, i, n);
30126    }
30127  );
30128}
30129function jT(e) {
30130  const t = [];
30131  let i = /\{([a-z])-([a-z])\}/.exec(e);
30132  if (i) {
30133    const n = i[1].charCodeAt(0), s = i[2].charCodeAt(0);
30134    let r;
30135    for (r = n; r <= s; ++r)
30136      t.push(e.replace(i[0], String.fromCharCode(r)));
30137    return t;
30138  }
30139  if (i = /\{(\d+)-(\d+)\}/.exec(e), i) {
30140    const n = parseInt(i[2], 10);
30141    for (let s = parseInt(i[1], 10); s <= n; s++)
30142      t.push(e.replace(i[0], s.toString()));
30143    return t;
30144  }
30145  return t.push(e), t;
30146}
30147class Ec extends DT {
30148  /**
30149   * @param {Options} options Image tile options.
30150   */
30151  constructor(t) {
30152    super({
30153      attributions: t.attributions,
30154      cacheSize: t.cacheSize,
30155      opaque: t.opaque,
30156      projection: t.projection,
30157      state: t.state,
30158      tileGrid: t.tileGrid,
30159      tilePixelRatio: t.tilePixelRatio,
30160      wrapX: t.wrapX,
30161      transition: t.transition,
30162      interpolate: t.interpolate,
30163      key: t.key,
30164      attributionsCollapsible: t.attributionsCollapsible,
30165      zDirection: t.zDirection
30166    }), this.generateTileUrlFunction_ = this.tileUrlFunction === Ec.prototype.tileUrlFunction, this.tileLoadFunction = t.tileLoadFunction, t.tileUrlFunction && (this.tileUrlFunction = t.tileUrlFunction), this.urls = null, t.urls ? this.setUrls(t.urls) : t.url && this.setUrl(t.url), this.tileLoadingKeys_ = {};
30167  }
30168  /**
30169   * Return the tile load function of the source.
30170   * @return {import("../Tile.js").LoadFunction} TileLoadFunction
30171   * @api
30172   */
30173  getTileLoadFunction() {
30174    return this.tileLoadFunction;
30175  }
30176  /**
30177   * Return the tile URL function of the source.
30178   * @return {import("../Tile.js").UrlFunction} TileUrlFunction
30179   * @api
30180   */
30181  getTileUrlFunction() {
30182    return Object.getPrototypeOf(this).tileUrlFunction === this.tileUrlFunction ? this.tileUrlFunction.bind(this) : this.tileUrlFunction;
30183  }
30184  /**
30185   * Return the URLs used for this source.
30186   * When a tileUrlFunction is used instead of url or urls,
30187   * null will be returned.
30188   * @return {!Array<string>|null} URLs.
30189   * @api
30190   */
30191  getUrls() {
30192    return this.urls;
30193  }
30194  /**
30195   * Handle tile change events.
30196   * @param {import("../events/Event.js").default} event Event.
30197   * @protected
30198   */
30199  handleTileChange(t) {
30200    const i = (
30201      /** @type {import("../Tile.js").default} */
30202      t.target
30203    ), n = lt(i), s = i.getState();
30204    let r;
30205    s == J.LOADING ? (this.tileLoadingKeys_[n] = !0, r = ul.TILELOADSTART) : n in this.tileLoadingKeys_ && (delete this.tileLoadingKeys_[n], r = s == J.ERROR ? ul.TILELOADERROR : s == J.LOADED ? ul.TILELOADEND : void 0), r != null && this.dispatchEvent(new kT(r, i));
30206  }
30207  /**
30208   * Set the tile load function of the source.
30209   * @param {import("../Tile.js").LoadFunction} tileLoadFunction Tile load function.
30210   * @api
30211   */
30212  setTileLoadFunction(t) {
30213    this.tileCache.clear(), this.tileLoadFunction = t, this.changed();
30214  }
30215  /**
30216   * Set the tile URL function of the source.
30217   * @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
30218   * @param {string} [key] Optional new tile key for the source.
30219   * @api
30220   */
30221  setTileUrlFunction(t, i) {
30222    this.tileUrlFunction = t, this.tileCache.pruneExceptNewestZ(), typeof i < "u" ? this.setKey(i) : this.changed();
30223  }
30224  /**
30225   * Set the URL to use for requests.
30226   * @param {string} url URL.
30227   * @api
30228   */
30229  setUrl(t) {
30230    const i = jT(t);
30231    this.urls = i, this.setUrls(i);
30232  }
30233  /**
30234   * Set the URLs to use for requests.
30235   * @param {Array<string>} urls URLs.
30236   * @api
30237   */
30238  setUrls(t) {
30239    this.urls = t;
30240    const i = t.join(`
30241`);
30242    this.generateTileUrlFunction_ ? this.setTileUrlFunction(GT(t, this.tileGrid), i) : this.setKey(i);
30243  }
30244  /**
30245   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
30246   * @param {number} pixelRatio Pixel ratio.
30247   * @param {import("../proj/Projection.js").default} projection Projection.
30248   * @return {string|undefined} Tile URL.
30249   */
30250  tileUrlFunction(t, i, n) {
30251  }
30252  /**
30253   * Marks a tile coord as being used, without triggering a load.
30254   * @param {number} z Tile coordinate z.
30255   * @param {number} x Tile coordinate x.
30256   * @param {number} y Tile coordinate y.
30257   */
30258  useTile(t, i, n) {
30259    const s = Ia(t, i, n);
30260    this.tileCache.containsKey(s) && this.tileCache.get(s);
30261  }
30262}
30263const WT = Ec;
30264class BT extends WT {
30265  /**
30266   * @param {!Options} options Image tile options.
30267   */
30268  constructor(t) {
30269    super({
30270      attributions: t.attributions,
30271      cacheSize: t.cacheSize,
30272      opaque: t.opaque,
30273      projection: t.projection,
30274      state: t.state,
30275      tileGrid: t.tileGrid,
30276      tileLoadFunction: t.tileLoadFunction ? t.tileLoadFunction : UT,
30277      tilePixelRatio: t.tilePixelRatio,
30278      tileUrlFunction: t.tileUrlFunction,
30279      url: t.url,
30280      urls: t.urls,
30281      wrapX: t.wrapX,
30282      transition: t.transition,
30283      interpolate: t.interpolate !== void 0 ? t.interpolate : !0,
30284      key: t.key,
30285      attributionsCollapsible: t.attributionsCollapsible,
30286      zDirection: t.zDirection
30287    }), this.crossOrigin = t.crossOrigin !== void 0 ? t.crossOrigin : null, this.tileClass = t.tileClass !== void 0 ? t.tileClass : Jg, this.tileCacheForProjection = {}, this.tileGridForProjection = {}, this.reprojectionErrorThreshold_ = t.reprojectionErrorThreshold, this.renderReprojectionEdges_ = !1;
30288  }
30289  /**
30290   * @return {boolean} Can expire cache.
30291   */
30292  canExpireCache() {
30293    if (this.tileCache.canExpireCache())
30294      return !0;
30295    for (const t in this.tileCacheForProjection)
30296      if (this.tileCacheForProjection[t].canExpireCache())
30297        return !0;
30298    return !1;
30299  }
30300  /**
30301   * @param {import("../proj/Projection.js").default} projection Projection.
30302   * @param {!Object<string, boolean>} usedTiles Used tiles.
30303   */
30304  expireCache(t, i) {
30305    const n = this.getTileCacheForProjection(t);
30306    this.tileCache.expireCache(
30307      this.tileCache == n ? i : {}
30308    );
30309    for (const s in this.tileCacheForProjection) {
30310      const r = this.tileCacheForProjection[s];
30311      r.expireCache(r == n ? i : {});
30312    }
30313  }
30314  /**
30315   * @param {import("../proj/Projection.js").default} projection Projection.
30316   * @return {number} Gutter.
30317   */
30318  getGutterForProjection(t) {
30319    return this.getProjection() && t && !Ci(this.getProjection(), t) ? 0 : this.getGutter();
30320  }
30321  /**
30322   * @return {number} Gutter.
30323   */
30324  getGutter() {
30325    return 0;
30326  }
30327  /**
30328   * Return the key to be used for all tiles in the source.
30329   * @return {string} The key for all tiles.
30330   */
30331  getKey() {
30332    let t = super.getKey();
30333    return this.getInterpolate() || (t += ":disable-interpolation"), t;
30334  }
30335  /**
30336   * @param {import("../proj/Projection.js").default} projection Projection.
30337   * @return {boolean} Opaque.
30338   */
30339  getOpaque(t) {
30340    return this.getProjection() && t && !Ci(this.getProjection(), t) ? !1 : super.getOpaque(t);
30341  }
30342  /**
30343   * @param {import("../proj/Projection.js").default} projection Projection.
30344   * @return {!import("../tilegrid/TileGrid.js").default} Tile grid.
30345   */
30346  getTileGridForProjection(t) {
30347    const i = this.getProjection();
30348    if (this.tileGrid && (!i || Ci(i, t)))
30349      return this.tileGrid;
30350    const n = lt(t);
30351    return n in this.tileGridForProjection || (this.tileGridForProjection[n] = Sm(t)), this.tileGridForProjection[n];
30352  }
30353  /**
30354   * @param {import("../proj/Projection.js").default} projection Projection.
30355   * @return {import("../TileCache.js").default} Tile cache.
30356   */
30357  getTileCacheForProjection(t) {
30358    const i = this.getProjection();
30359    if (!i || Ci(i, t))
30360      return this.tileCache;
30361    const n = lt(t);
30362    return n in this.tileCacheForProjection || (this.tileCacheForProjection[n] = new em(
30363      this.tileCache.highWaterMark
30364    )), this.tileCacheForProjection[n];
30365  }
30366  /**
30367   * @param {number} z Tile coordinate z.
30368   * @param {number} x Tile coordinate x.
30369   * @param {number} y Tile coordinate y.
30370   * @param {number} pixelRatio Pixel ratio.
30371   * @param {import("../proj/Projection.js").default} projection Projection.
30372   * @param {string} key The key set on the tile.
30373   * @return {!ImageTile} Tile.
30374   * @private
30375   */
30376  createTile_(t, i, n, s, r, o) {
30377    const a = [t, i, n], l = this.getTileCoordForTileUrlFunction(
30378      a,
30379      r
30380    ), h = l ? this.tileUrlFunction(l, s, r) : void 0, c = new this.tileClass(
30381      a,
30382      h !== void 0 ? J.IDLE : J.EMPTY,
30383      h !== void 0 ? h : "",
30384      this.crossOrigin,
30385      this.tileLoadFunction,
30386      this.tileOptions
30387    );
30388    return c.key = o, c.addEventListener(et.CHANGE, this.handleTileChange.bind(this)), c;
30389  }
30390  /**
30391   * @param {number} z Tile coordinate z.
30392   * @param {number} x Tile coordinate x.
30393   * @param {number} y Tile coordinate y.
30394   * @param {number} pixelRatio Pixel ratio.
30395   * @param {import("../proj/Projection.js").default} projection Projection.
30396   * @return {!(ImageTile|ReprojTile)} Tile.
30397   */
30398  getTile(t, i, n, s, r) {
30399    const o = this.getProjection();
30400    if (!o || !r || Ci(o, r))
30401      return this.getTileInternal(
30402        t,
30403        i,
30404        n,
30405        s,
30406        o || r
30407      );
30408    const a = this.getTileCacheForProjection(r), l = [t, i, n];
30409    let h;
30410    const c = Qg(l);
30411    a.containsKey(c) && (h = a.get(c));
30412    const u = this.getKey();
30413    if (h && h.key == u)
30414      return h;
30415    const d = this.getTileGridForProjection(o), f = this.getTileGridForProjection(r), g = this.getTileCoordForTileUrlFunction(
30416      l,
30417      r
30418    ), m = new ql(
30419      o,
30420      d,
30421      r,
30422      f,
30423      l,
30424      g,
30425      this.getTilePixelRatio(s),
30426      this.getGutter(),
30427      (_, p, y, x) => this.getTileInternal(_, p, y, x, o),
30428      this.reprojectionErrorThreshold_,
30429      this.renderReprojectionEdges_,
30430      this.getInterpolate()
30431    );
30432    return m.key = u, h ? (m.interimTile = h, m.refreshInterimChain(), a.replace(c, m)) : a.set(c, m), m;
30433  }
30434  /**
30435   * @param {number} z Tile coordinate z.
30436   * @param {number} x Tile coordinate x.
30437   * @param {number} y Tile coordinate y.
30438   * @param {number} pixelRatio Pixel ratio.
30439   * @param {!import("../proj/Projection.js").default} projection Projection.
30440   * @return {!ImageTile} Tile.
30441   * @protected
30442   */
30443  getTileInternal(t, i, n, s, r) {
30444    let o = null;
30445    const a = Ia(t, i, n), l = this.getKey();
30446    if (!this.tileCache.containsKey(a))
30447      o = this.createTile_(t, i, n, s, r, l), this.tileCache.set(a, o);
30448    else if (o = this.tileCache.get(a), o.key != l) {
30449      const h = o;
30450      o = this.createTile_(t, i, n, s, r, l), h.getState() == J.IDLE ? o.interimTile = h.interimTile : o.interimTile = h, o.refreshInterimChain(), this.tileCache.replace(a, o);
30451    }
30452    return o;
30453  }
30454  /**
30455   * Sets whether to render reprojection edges or not (usually for debugging).
30456   * @param {boolean} render Render the edges.
30457   * @api
30458   */
30459  setRenderReprojectionEdges(t) {
30460    if (this.renderReprojectionEdges_ != t) {
30461      this.renderReprojectionEdges_ = t;
30462      for (const i in this.tileCacheForProjection)
30463        this.tileCacheForProjection[i].clear();
30464      this.changed();
30465    }
30466  }
30467  /**
30468   * Sets the tile grid to use when reprojecting the tiles to the given
30469   * projection instead of the default tile grid for the projection.
30470   *
30471   * This can be useful when the default tile grid cannot be created
30472   * (e.g. projection has no extent defined) or
30473   * for optimization reasons (custom tile size, resolutions, ...).
30474   *
30475   * @param {import("../proj.js").ProjectionLike} projection Projection.
30476   * @param {import("../tilegrid/TileGrid.js").default} tilegrid Tile grid to use for the projection.
30477   * @api
30478   */
30479  setTileGridForProjection(t, i) {
30480    const n = It(t);
30481    if (n) {
30482      const s = lt(n);
30483      s in this.tileGridForProjection || (this.tileGridForProjection[s] = i);
30484    }
30485  }
30486  clear() {
30487    super.clear();
30488    for (const t in this.tileCacheForProjection)
30489      this.tileCacheForProjection[t].clear();
30490  }
30491}
30492function UT(e, t) {
30493  e.getImage().src = t;
30494}
30495const XT = BT;
30496class $T extends XT {
30497  /**
30498   * @param {Options} [options] Tile WMS options.
30499   */
30500  constructor(t) {
30501    t = t || /** @type {Options} */
30502    {};
30503    const i = Object.assign({}, t.params), n = "TRANSPARENT" in i ? i.TRANSPARENT : !0;
30504    super({
30505      attributions: t.attributions,
30506      attributionsCollapsible: t.attributionsCollapsible,
30507      cacheSize: t.cacheSize,
30508      crossOrigin: t.crossOrigin,
30509      interpolate: t.interpolate,
30510      opaque: !n,
30511      projection: t.projection,
30512      reprojectionErrorThreshold: t.reprojectionErrorThreshold,
30513      tileClass: t.tileClass,
30514      tileGrid: t.tileGrid,
30515      tileLoadFunction: t.tileLoadFunction,
30516      url: t.url,
30517      urls: t.urls,
30518      wrapX: t.wrapX !== void 0 ? t.wrapX : !0,
30519      transition: t.transition,
30520      zDirection: t.zDirection
30521    }), this.gutter_ = t.gutter !== void 0 ? t.gutter : 0, this.params_ = i, this.v13_ = !0, this.serverType_ = t.serverType, this.hidpi_ = t.hidpi !== void 0 ? t.hidpi : !0, this.tmpExtent_ = be(), this.updateV13_(), this.setKey(this.getKeyForParams_());
30522  }
30523  /**
30524   * Return the GetFeatureInfo URL for the passed coordinate, resolution, and
30525   * projection. Return `undefined` if the GetFeatureInfo URL cannot be
30526   * constructed.
30527   * @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
30528   * @param {number} resolution Resolution.
30529   * @param {import("../proj.js").ProjectionLike} projection Projection.
30530   * @param {!Object} params GetFeatureInfo params. `INFO_FORMAT` at least should
30531   *     be provided. If `QUERY_LAYERS` is not provided then the layers specified
30532   *     in the `LAYERS` parameter will be used. `VERSION` should not be
30533   *     specified here.
30534   * @return {string|undefined} GetFeatureInfo URL.
30535   * @api
30536   */
30537  getFeatureInfoUrl(t, i, n, s) {
30538    const r = It(n), o = this.getProjection();
30539    let a = this.getTileGrid();
30540    a || (a = this.getTileGridForProjection(r));
30541    const l = a.getZForResolution(i, this.zDirection), h = a.getTileCoordForCoordAndZ(t, l);
30542    if (a.getResolutions().length <= h[0])
30543      return;
30544    let c = a.getResolution(h[0]), u = a.getTileCoordExtent(h, this.tmpExtent_), d = Ce(a.getTileSize(h[0]), this.tmpSize);
30545    const f = this.gutter_;
30546    f !== 0 && (d = Vu(d, f, this.tmpSize), u = Rn(u, c * f, u)), o && o !== r && (c = Rr(
30547      o,
30548      r,
30549      t,
30550      c
30551    ), u = Wx(
30552      u,
30553      r,
30554      o
30555    ), t = Ts(t, r, o));
30556    const g = {
30557      SERVICE: "WMS",
30558      VERSION: Ki,
30559      REQUEST: "GetFeatureInfo",
30560      FORMAT: "image/png",
30561      TRANSPARENT: !0,
30562      QUERY_LAYERS: this.params_.LAYERS
30563    };
30564    Object.assign(g, this.params_, s);
30565    const m = Math.floor((t[0] - u[0]) / c), _ = Math.floor((u[3] - t[1]) / c);
30566    return g[this.v13_ ? "I" : "X"] = m, g[this.v13_ ? "J" : "Y"] = _, this.getRequestUrl_(
30567      h,
30568      d,
30569      u,
30570      1,
30571      o || r,
30572      g
30573    );
30574  }
30575  /**
30576   * Return the GetLegendGraphic URL, optionally optimized for the passed
30577   * resolution and possibly including any passed specific parameters. Returns
30578   * `undefined` if the GetLegendGraphic URL cannot be constructed.
30579   *
30580   * @param {number} [resolution] Resolution. If set to undefined, `SCALE`
30581   *     will not be calculated and included in URL.
30582   * @param {Object} [params] GetLegendGraphic params. If `LAYER` is set, the
30583   *     request is generated for this wms layer, else it will try to use the
30584   *     configured wms layer. Default `FORMAT` is `image/png`.
30585   *     `VERSION` should not be specified here.
30586   * @return {string|undefined} GetLegendGraphic URL.
30587   * @api
30588   */
30589  getLegendUrl(t, i) {
30590    if (this.urls[0] === void 0)
30591      return;
30592    const n = {
30593      SERVICE: "WMS",
30594      VERSION: Ki,
30595      REQUEST: "GetLegendGraphic",
30596      FORMAT: "image/png"
30597    };
30598    if (i === void 0 || i.LAYER === void 0) {
30599      const s = this.params_.LAYERS;
30600      if (!(!Array.isArray(s) || s.length === 1))
30601        return;
30602      n.LAYER = s;
30603    }
30604    if (t !== void 0) {
30605      const s = this.getProjection() ? this.getProjection().getMetersPerUnit() : 1, r = 28e-5;
30606      n.SCALE = t * s / r;
30607    }
30608    return Object.assign(n, i), ea(
30609      /** @type {string} */
30610      this.urls[0],
30611      n
30612    );
30613  }
30614  /**
30615   * @return {number} Gutter.
30616   */
30617  getGutter() {
30618    return this.gutter_;
30619  }
30620  /**
30621   * Get the user-provided params, i.e. those passed to the constructor through
30622   * the "params" option, and possibly updated using the updateParams method.
30623   * @return {Object} Params.
30624   * @api
30625   */
30626  getParams() {
30627    return this.params_;
30628  }
30629  /**
30630   * @param {import("../tilecoord.js").TileCoord} tileCoord Tile coordinate.
30631   * @param {import("../size.js").Size} tileSize Tile size.
30632   * @param {import("../extent.js").Extent} tileExtent Tile extent.
30633   * @param {number} pixelRatio Pixel ratio.
30634   * @param {import("../proj/Projection.js").default} projection Projection.
30635   * @param {Object} params Params.
30636   * @return {string|undefined} Request URL.
30637   * @private
30638   */
30639  getRequestUrl_(t, i, n, s, r, o) {
30640    const a = this.urls;
30641    if (!a)
30642      return;
30643    if (o.WIDTH = i[0], o.HEIGHT = i[1], o[this.v13_ ? "CRS" : "SRS"] = r.getCode(), "STYLES" in this.params_ || (o.STYLES = ""), s != 1)
30644      switch (this.serverType_) {
30645        case "geoserver":
30646          const u = 90 * s + 0.5 | 0;
30647          "FORMAT_OPTIONS" in o ? o.FORMAT_OPTIONS += ";dpi:" + u : o.FORMAT_OPTIONS = "dpi:" + u;
30648          break;
30649        case "mapserver":
30650          o.MAP_RESOLUTION = 90 * s;
30651          break;
30652        case "carmentaserver":
30653        case "qgis":
30654          o.DPI = 90 * s;
30655          break;
30656        default:
30657          ht(!1, 52);
30658          break;
30659      }
30660    const l = r.getAxisOrientation(), h = n;
30661    if (this.v13_ && l.substr(0, 2) == "ne") {
30662      let u;
30663      u = n[0], h[0] = n[1], h[1] = u, u = n[2], h[2] = n[3], h[3] = u;
30664    }
30665    o.BBOX = h.join(",");
30666    let c;
30667    if (a.length == 1)
30668      c = a[0];
30669    else {
30670      const u = qi(tm(t), a.length);
30671      c = a[u];
30672    }
30673    return ea(c, o);
30674  }
30675  /**
30676   * Get the tile pixel ratio for this source.
30677   * @param {number} pixelRatio Pixel ratio.
30678   * @return {number} Tile pixel ratio.
30679   */
30680  getTilePixelRatio(t) {
30681    return !this.hidpi_ || this.serverType_ === void 0 ? 1 : t;
30682  }
30683  /**
30684   * @private
30685   * @return {string} The key for the current params.
30686   */
30687  getKeyForParams_() {
30688    let t = 0;
30689    const i = [];
30690    for (const n in this.params_)
30691      i[t++] = n + "-" + this.params_[n];
30692    return i.join("/");
30693  }
30694  /**
30695   * Update the user-provided params.
30696   * @param {Object} params Params.
30697   * @api
30698   */
30699  updateParams(t) {
30700    Object.assign(this.params_, t), this.updateV13_(), this.setKey(this.getKeyForParams_());
30701  }
30702  /**
30703   * @private
30704   */
30705  updateV13_() {
30706    const t = this.params_.VERSION || Ki;
30707    this.v13_ = rf(t, "1.3") >= 0;
30708  }
30709  /**
30710   * @param {import("../tilecoord.js").TileCoord} tileCoord The tile coordinate
30711   * @param {number} pixelRatio The pixel ratio
30712   * @param {import("../proj/Projection.js").default} projection The projection
30713   * @return {string|undefined} The tile URL
30714   * @override
30715   */
30716  tileUrlFunction(t, i, n) {
30717    let s = this.getTileGrid();
30718    if (s || (s = this.getTileGridForProjection(n)), s.getResolutions().length <= t[0])
30719      return;
30720    i != 1 && (!this.hidpi_ || this.serverType_ === void 0) && (i = 1);
30721    const r = s.getResolution(t[0]);
30722    let o = s.getTileCoordExtent(t, this.tmpExtent_), a = Ce(s.getTileSize(t[0]), this.tmpSize);
30723    const l = this.gutter_;
30724    l !== 0 && (a = Vu(a, l, this.tmpSize), o = Rn(o, r * l, o)), i != 1 && (a = Dg(a, i, this.tmpSize));
30725    const h = {
30726      SERVICE: "WMS",
30727      VERSION: Ki,
30728      REQUEST: "GetMap",
30729      FORMAT: "image/png",
30730      TRANSPARENT: !0
30731    };
30732    return Object.assign(h, this.params_), this.getRequestUrl_(
30733      t,
30734      a,
30735      o,
30736      i,
30737      n,
30738      h
30739    );
30740  }
30741}
30742const YT = $T;
30743class KT extends jr {
30744  /**
30745   * @param {Options<ImageSourceType>} [options] Layer options.
30746   */
30747  constructor(t) {
30748    t = t || {}, super(t);
30749  }
30750}
30751const VT = KT;
30752class qT extends cc {
30753  /**
30754   * @param {import("../../layer/Image.js").default} imageLayer Image layer.
30755   */
30756  constructor(t) {
30757    super(t), this.image_ = null;
30758  }
30759  /**
30760   * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
30761   */
30762  getImage() {
30763    return this.image_ ? this.image_.getImage() : null;
30764  }
30765  /**
30766   * Determine whether render should be called.
30767   * @param {import("../../Map.js").FrameState} frameState Frame state.
30768   * @return {boolean} Layer is ready to be rendered.
30769   */
30770  prepareFrame(t) {
30771    const i = t.layerStatesArray[t.layerIndex], n = t.pixelRatio, s = t.viewState, r = s.resolution, o = this.getLayer().getSource(), a = t.viewHints;
30772    let l = t.extent;
30773    if (i.extent !== void 0 && (l = En(
30774      l,
30775      ai(i.extent, s.projection)
30776    )), !a[Kt.ANIMATING] && !a[Kt.INTERACTING] && !Nn(l))
30777      if (o) {
30778        const h = s.projection, c = o.getImage(
30779          l,
30780          r,
30781          n,
30782          h
30783        );
30784        c && (this.loadImage(c) ? this.image_ = c : c.getState() === at.EMPTY && (this.image_ = null));
30785      } else
30786        this.image_ = null;
30787    return !!this.image_;
30788  }
30789  /**
30790   * @param {import("../../pixel.js").Pixel} pixel Pixel.
30791   * @return {Uint8ClampedArray} Data at the pixel location.
30792   */
30793  getData(t) {
30794    const i = this.frameState;
30795    if (!i)
30796      return null;
30797    const n = this.getLayer(), s = Bt(
30798      i.pixelToCoordinateTransform,
30799      t.slice()
30800    ), r = n.getExtent();
30801    if (r && !Ds(r, s))
30802      return null;
30803    const o = this.image_.getExtent(), a = this.getImage(), l = xt(o), h = Math.floor(
30804      a.width * ((s[0] - o[0]) / l)
30805    );
30806    if (h < 0 || h >= a.width)
30807      return null;
30808    const c = qt(o), u = Math.floor(
30809      a.height * ((o[3] - s[1]) / c)
30810    );
30811    return u < 0 || u >= a.height ? null : this.getImageData(a, h, u);
30812  }
30813  /**
30814   * Render the layer.
30815   * @param {import("../../Map.js").FrameState} frameState Frame state.
30816   * @param {HTMLElement} target Target that may be used to render content to.
30817   * @return {HTMLElement} The rendered element.
30818   */
30819  renderFrame(t, i) {
30820    const n = this.image_, s = n.getExtent(), r = n.getResolution(), o = n.getPixelRatio(), a = t.layerStatesArray[t.layerIndex], l = t.pixelRatio, h = t.viewState, c = h.center, u = h.resolution, d = l * r / (u * o), f = t.extent, g = h.resolution, m = h.rotation, _ = Math.round(xt(f) / g * l), p 
30820= Math.round(qt(f) / g * l);
30821    gi(
30822      this.pixelTransform,
30823      t.size[0] / 2,
30824      t.size[1] / 2,
30825      1 / l,
30826      1 / l,
30827      m,
30828      -_ / 2,
30829      -p / 2
30830    ), Ca(this.inversePixelTransform, this.pixelTransform);
30831    const y = Fh(this.pixelTransform);
30832    this.useContainer(i, y, this.getBackground(t));
30833    const x = this.context, E = x.canvas;
30834    E.width != _ || E.height != p ? (E.width = _, E.height = p) : this.containerReused || x.clearRect(0, 0, _, p);
30835    let M = !1, w = !0;
30836    if (a.extent) {
30837      const q = ai(
30838        a.extent,
30839        h.projection
30840      );
30841      w = re(q, t.extent), M = w && !Bi(q, t.extent), M && this.clipUnrotated(x, t, q);
30842    }
30843    const L = this.getImage(), I = gi(
30844      this.tempTransform,
30845      _ / 2,
30846      p / 2,
30847      d,
30848      d,
30849      0,
30850      o * (s[0] - c[0]) / r,
30851      o * (c[1] - s[3]) / r
30852    );
30853    this.renderedResolution = r * l / o;
30854    const z = L.width * I[0], U = L.height * I[3];
30855    if (this.getLayer().getSource().getInterpolate() || (x.imageSmoothingEnabled = !1), this.preRender(x, t), w && z >= 0.5 && U >= 0.5) {
30856      const q = I[4], K = I[5], Z = a.opacity;
30857      let Mt;
30858      Z !== 1 && (Mt = x.globalAlpha, x.globalAlpha = Z), x.drawImage(L, 0, 0, +L.width, +L.height, q, K, z, U), Z !== 1 && (x.globalAlpha = Mt);
30859    }
30860    return this.postRender(x, t), M && x.restore(), x.imageSmoothingEnabled = !0, y !== E.style.transform && (E.style.transform = y), this.container;
30861  }
30862}
30863const HT = qT;
30864class ZT extends VT {
30865  /**
30866   * @param {import("./BaseImage.js").Options<ImageSourceType>} [options] Layer options.
30867   */
30868  constructor(t) {
30869    super(t);
30870  }
30871  createRenderer() {
30872    return new HT(this);
30873  }
30874  /**
30875   * Get data for a pixel location.  A four element RGBA array will be returned.  For requests outside the
30876   * layer extent, `null` will be returned.  Data for an image can only be retrieved if the
30877   * source's `crossOrigin` property is set.
30878   *
30879   * ```js
30880   * // display layer data on every pointer move
30881   * map.on('pointermove', (event) => {
30882   *   console.log(layer.getData(event.pixel));
30883   * });
30884   * ```
30885   * @param {import("../pixel").Pixel} pixel Pixel.
30886   * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
30887   * @api
30888   */
30889  getData(t) {
30890    return super.getData(t);
30891  }
30892}
30893const JT = ZT, yo = {
30894  PRELOAD: "preload",
30895  USE_INTERIM_TILES_ON_ERROR: "useInterimTilesOnError"
30896};
30897class QT extends jr {
30898  /**
30899   * @param {Options<TileSourceType>} [options] Tile layer options.
30900   */
30901  constructor(t) {
30902    t = t || {};
30903    const i = Object.assign({}, t);
30904    delete i.preload, delete i.useInterimTilesOnError, super(i), this.on, this.once, this.un, this.setPreload(t.preload !== void 0 ? t.preload : 0), this.setUseInterimTilesOnError(
30905      t.useInterimTilesOnError !== void 0 ? t.useInterimTilesOnError : !0
30906    );
30907  }
30908  /**
30909   * Return the level as number to which we will preload tiles up to.
30910   * @return {number} The level to preload tiles up to.
30911   * @observable
30912   * @api
30913   */
30914  getPreload() {
30915    return (
30916      /** @type {number} */
30917      this.get(yo.PRELOAD)
30918    );
30919  }
30920  /**
30921   * Set the level as number to which we will preload tiles up to.
30922   * @param {number} preload The level to preload tiles up to.
30923   * @observable
30924   * @api
30925   */
30926  setPreload(t) {
30927    this.set(yo.PRELOAD, t);
30928  }
30929  /**
30930   * Whether we use interim tiles on error.
30931   * @return {boolean} Use interim tiles on error.
30932   * @observable
30933   * @api
30934   */
30935  getUseInterimTilesOnError() {
30936    return (
30937      /** @type {boolean} */
30938      this.get(yo.USE_INTERIM_TILES_ON_ERROR)
30939    );
30940  }
30941  /**
30942   * Set whether we use interim tiles on error.
30943   * @param {boolean} useInterimTilesOnError Use interim tiles on error.
30944   * @observable
30945   * @api
30946   */
30947  setUseInterimTilesOnError(t) {
30948    this.set(yo.USE_INTERIM_TILES_ON_ERROR, t);
30949  }
30950  /**
30951   * Get data for a pixel location.  The return type depends on the source data.  For image tiles,
30952   * a four element RGBA array will be returned.  For data tiles, the array length will match the
30953   * number of bands in the dataset.  For requests outside the layer extent, `null` will be returned.
30954   * Data for a image tiles can only be retrieved if the source's `crossOrigin` property is set.
30955   *
30956   * ```js
30957   * // display layer data on every pointer move
30958   * map.on('pointermove', (event) => {
30959   *   console.log(layer.getData(event.pixel));
30960   * });
30961   * ```
30962   * @param {import("../pixel").Pixel} pixel Pixel.
30963   * @return {Uint8ClampedArray|Uint8Array|Float32Array|DataView|null} Pixel data.
30964   * @api
30965   */
30966  getData(t) {
30967    return super.getData(t);
30968  }
30969}
30970const tI = QT;
30971class eI extends cc {
30972  /**
30973   * @param {LayerType} tileLayer Tile layer.
30974   */
30975  constructor(t) {
30976    super(t), this.extentChanged = !0, this.renderedExtent_ = null, this.renderedPixelRatio, this.renderedProjection = null, this.renderedRevision, this.renderedTiles = [], this.newTiles_ = !1, this.tmpExtent = be(), this.tmpTileRange_ = new nm(0, 0, 0, 0);
30977  }
30978  /**
30979   * @protected
30980   * @param {import("../../Tile.js").default} tile Tile.
30981   * @return {boolean} Tile is drawable.
30982   */
30983  isDrawableTile(t) {
30984    const i = this.getLayer(), n = t.getState(), s = i.getUseInterimTilesOnError();
30985    return n == J.LOADED || n == J.EMPTY || n == J.ERROR && !s;
30986  }
30987  /**
30988   * @param {number} z Tile coordinate z.
30989   * @param {number} x Tile coordinate x.
30990   * @param {number} y Tile coordinate y.
30991   * @param {import("../../Map.js").FrameState} frameState Frame state.
30992   * @return {!import("../../Tile.js").default} Tile.
30993   */
30994  getTile(t, i, n, s) {
30995    const r = s.pixelRatio, o = s.viewState.projection, a = this.getLayer();
30996    let h = a.getSource().getTile(t, i, n, r, o);
30997    return h.getState() == J.ERROR && a.getUseInterimTilesOnError() && a.getPreload() > 0 && (this.newTiles_ = !0), this.isDrawableTile(h) || (h = h.getInterimTile()), h;
30998  }
30999  /**
31000   * @param {import("../../pixel.js").Pixel} pixel Pixel.
31001   * @return {Uint8ClampedArray} Data at the pixel location.
31002   */
31003  getData(t) {
31004    const i = this.frameState;
31005    if (!i)
31006      return null;
31007    const n = this.getLayer(), s = Bt(
31008      i.pixelToCoordinateTransform,
31009      t.slice()
31010    ), r = n.getExtent();
31011    if (r && !Ds(r, s))
31012      return null;
31013    const o = i.pixelRatio, a = i.viewState.projection, l = i.viewState, h = n.getRenderSource(), c = h.getTileGridForProjection(l.projection), u = h.getTilePixelRatio(i.pixelRatio);
31014    for (let d = c.getZForResolution(l.resolution); d >= c.getMinZoom(); --d) {
31015      const f = c.getTileCoordForCoordAndZ(s, d), g = h.getTile(
31016        d,
31017        f[1],
31018        f[2],
31019        o,
31020        a
31021      );
31022      if (!(g instanceof Jg || g instanceof ql) || g instanceof ql && g.getState() === J.EMPTY)
31023        return null;
31024      if (g.getState() !== J.LOADED)
31025        continue;
31026      const m = c.getOrigin(d), _ = Ce(c.getTileSize(d)), p = c.getResolution(d), y = Math.floor(
31027        u * ((s[0] - m[0]) / p - f[1] * _[0])
31028      ), x = Math.floor(
31029        u * ((m[1] - s[1]) / p - f[2] * _[1])
31030      ), E = Math.round(
31031        u * h.getGutterForProjection(l.projection)
31032      );
31033      return this.getImageData(g.getImage(), y + E, x + E);
31034    }
31035    return null;
31036  }
31037  /**
31038   * @param {Object<number, Object<string, import("../../Tile.js").default>>} tiles Lookup of loaded tiles by zoom level.
31039   * @param {number} zoom Zoom level.
31040   * @param {import("../../Tile.js").default} tile Tile.
31041   * @return {boolean|void} If `false`, the tile will not be considered loaded.
31042   */
31043  loadedTileCallback(t, i, n) {
31044    return this.isDrawableTile(n) ? super.loadedTileCallback(t, i, n) : !1;
31045  }
31046  /**
31047   * Determine whether render should be called.
31048   * @param {import("../../Map.js").FrameState} frameState Frame state.
31049   * @return {boolean} Layer is ready to be rendered.
31050   */
31051  prepareFrame(t) {
31052    return !!this.getLayer().getSource();
31053  }
31054  /**
31055   * Render the layer.
31056   * @param {import("../../Map.js").FrameState} frameState Frame state.
31057   * @param {HTMLElement} target Target that may be used to render content to.
31058   * @return {HTMLElement} The rendered element.
31059   */
31060  renderFrame(t, i) {
31061    const n = t.layerStatesArray[t.layerIndex], s = t.viewState, r = s.projection, o = s.resolution, a = s.center, l = s.rotation, h = t.pixelRatio, c = this.getLayer(), u = c.getSource(), d = u.getRevision(), f = u.getTileGridForProjection(r), g = f.getZForResolution(o, u.zDirection), m = f.getResolution(g);
31062    let _ = t.extent;
31063    const p = t.viewState.resolution, y = u.getTilePixelRatio(h), x = Math.round(xt(_) / p * h), E = Math.round(qt(_) / p * h), M = n.extent && ai(n.extent);
31064    M && (_ = En(
31065      _,
31066      ai(n.extent)
31067    ));
31068    const w = m * x / 2 / y, L = m * E / 2 / y, I = [
31069      a[0] - w,
31070      a[1] - L,
31071      a[0] + w,
31072      a[1] + L
31073    ], z = f.getTileRangeForExtentAndZ(_, g), U = {};
31074    U[g] = {};
31075    const q = this.createLoadedTileFinder(
31076      u,
31077      r,
31078      U
31079    ), K = this.tmpExtent, Z = this.tmpTileRange_;
31080    this.newTiles_ = !1;
31081    const Mt = l ? xl(
31082      s.center,
31083      p,
31084      l,
31085      t.size
31086    ) : void 0;
31087    for (let Jt = z.minX; Jt <= z.maxX; ++Jt)
31088      for (let vt = z.minY; vt <= z.maxY; ++vt) {
31089        if (l && !f.tileCoordIntersectsViewport([g, Jt, vt], Mt))
31090          continue;
31091        const bt = this.getTile(g, Jt, vt, t);
31092        if (this.isDrawableTile(bt)) {
31093          const zt = lt(this);
31094          if (bt.getState() == J.LOADED) {
31095            U[g][bt.tileCoord.toString()] = bt;
31096            let Qt = bt.inTransition(zt);
31097            Qt && n.opacity !== 1 && (bt.endTransition(zt), Qt = !1), !this.newTiles_ && (Qt || !this.renderedTiles.includes(bt)) && (this.newTiles_ = !0);
31098          }
31099          if (bt.getAlpha(zt, t.time) === 1)
31100            continue;
31101        }
31102        const $t = f.getTileCoordChildTileRange(
31103          bt.tileCoord,
31104          Z,
31105          K
31106        );
31107        let ce = !1;
31108        $t && (ce = q(g + 1, $t)), ce || f.forEachTileCoordParentTileRange(
31109          bt.tileCoord,
31110          q,
31111          Z,
31112          K
31113        );
31114      }
31115    const V = m / o * h / y;
31116    gi(
31117      this.pixelTransform,
31118      t.size[0] / 2,
31119      t.size[1] / 2,
31120      1 / h,
31121      1 / h,
31122      l,
31123      -x / 2,
31124      -E / 2
31125    );
31126    const Y = Fh(this.pixelTransform);
31127    this.useContainer(i, Y, this.getBackground(t));
31128    const O = this.context, W = O.canvas;
31129    Ca(this.inversePixelTransform, this.pixelTransform), gi(
31130      this.tempTransform,
31131      x / 2,
31132      E / 2,
31133      V,
31134      V,
31135      0,
31136      -x / 2,
31137      -E / 2
31138    ), W.width != x || W.height != E ? (W.width = x, W.height = E) : this.containerReused || O.clearRect(0, 0, x, E), M && this.clipUnrotated(O, t, M), u.getInterpolate() || (O.imageSmoothingEnabled = !1), this.preRender(O, t), this.renderedTiles.length = 0;
31139    let gt = Object.keys(U).map(Number);
31140    gt.sort(Ln);
31141    let _t, Pt, R;
31142    n.opacity === 1 && (!this.containerReused || u.getOpaque(t.viewState.projection)) ? gt = gt.reverse() : (_t = [], Pt = []);
31143    for (let Jt = gt.length - 1; Jt >= 0; --Jt) {
31144      const vt = gt[Jt], bt = u.getTilePixelSize(
31145        vt,
31146        h,
31147        r
31148      ), ce = f.getResolution(vt) / m, zt = bt[0] * ce * V, Qt = bt[1] * ce * V, ti = f.getTileCoordForCoordAndZ(
31149        Dn(I),
31150        vt
31151      ), Li = f.getTileCoordExtent(ti), v = Bt(this.tempTransform, [
31152        y * (Li[0] - I[0]) / m,
31153        y * (I[3] - Li[3]) / m
31154      ]), C = y * u.getGutterForProjection(r), b = U[vt];
31155      for (const T in b) {
31156        const S = (
31157          /** @type {import("../../ImageTile.js").default} */
31158          b[T]
31159        ), k = S.tileCoord, N = ti[1] - k[1], F = Math.round(v[0] - (N - 1) * zt), D = ti[2] - k[2], P = Math.round(v[1] - (D - 1) * Qt), B = Math.round(v[0] - N * zt), j = Math.round(v[1] - D * Qt), $ = F - B, H = P - j, ot = g === vt, pt = ot && S.getAlpha(lt(this), t.time) !== 1;
31160        let ft = !1;
31161        if (!pt)
31162          if (_t) {
31163            R = [B, j, B + $, j, B + $, j + H, B, j + H];
31164            for (let Rt = 0, te = _t.length; Rt < te; ++Rt)
31165              if (g !== vt && vt < Pt[Rt]) {
31166                const Nt = _t[Rt];
31167                re(
31168                  [B, j, B + $, j + H],
31169                  [Nt[0], Nt[3], Nt[4], Nt[7]]
31170                ) && (ft || (O.save(), ft = !0), O.beginPath(), O.moveTo(R[0], R[1]), O.lineTo(R[2], R[3]), O.lineTo(R[4], R[5]), O.lineTo(R[6], R[7]), O.moveTo(Nt[6], Nt[7]), O.lineTo(Nt[4], Nt[5]), O.lineTo(Nt[2], Nt[3]), O.lineTo(Nt[0], Nt[1]), O.clip());
31171              }
31172            _t.push(R), Pt.push(vt);
31173          } else
31174            O.clearRect(B, j, $, H);
31175        this.drawTileImage(
31176          S,
31177          t,
31178          B,
31179          j,
31180          $,
31181          H,
31182          C,
31183          ot
31184        ), _t && !pt ? (ft && O.restore(), this.renderedTiles.unshift(S)) : this.renderedTiles.push(S), this.updateUsedTiles(t.usedTiles, u, S);
31185      }
31186    }
31187    return this.renderedRevision = d, this.renderedResolution = m, this.extentChanged = !this.renderedExtent_ || !Ss(this.renderedExtent_, I), this.renderedExtent_ = I, this.renderedPixelRatio = h, this.renderedProjection = r, this.manageTilePyramid(
31188      t,
31189      u,
31190      f,
31191      h,
31192      r,
31193      _,
31194      g,
31195      c.getPreload()
31196    ), this.scheduleExpireCache(t, u), this.postRender(O, t), n.extent && O.restore(), O.imageSmoothingEnabled = !0, Y !== W.style.transform && (W.style.transform = Y), this.container;
31197  }
31198  /**
31199   * @param {import("../../ImageTile.js").default} tile Tile.
31200   * @param {import("../../Map.js").FrameState} frameState Frame state.
31201   * @param {number} x Left of the tile.
31202   * @param {number} y Top of the tile.
31203   * @param {number} w Width of the tile.
31204   * @param {number} h Height of the tile.
31205   * @param {number} gutter Tile gutter.
31206   * @param {boolean} transition Apply an alpha transition.
31207   */
31208  drawTileImage(t, i, n, s, r, o, a, l) {
31209    const h = this.getTileImage(t);
31210    if (!h)
31211      return;
31212    const c = lt(this), u = i.layerStatesArray[i.layerIndex], d = u.opacity * (l ? t.getAlpha(c, i.time) : 1), f = d !== this.context.globalAlpha;
31213    f && (this.context.save(), this.context.globalAlpha = d), this.context.drawImage(
31214      h,
31215      a,
31216      a,
31217      h.width - 2 * a,
31218      h.height - 2 * a,
31219      n,
31220      s,
31221      r,
31222      o
31223    ), f && this.context.restore(), d !== u.opacity ? i.animate = !0 : l && t.endTransition(c);
31224  }
31225  /**
31226   * @return {HTMLCanvasElement} Image
31227   */
31228  getImage() {
31229    const t = this.context;
31230    return t ? t.canvas : null;
31231  }
31232  /**
31233   * Get the image from a tile.
31234   * @param {import("../../ImageTile.js").default} tile Tile.
31235   * @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
31236   * @protected
31237   */
31238  getTileImage(t) {
31239    return t.getImage();
31240  }
31241  /**
31242   * @param {import("../../Map.js").FrameState} frameState Frame state.
31243   * @param {import("../../source/Tile.js").default} tileSource Tile source.
31244   * @protected
31245   */
31246  scheduleExpireCache(t, i) {
31247    if (i.canExpireCache()) {
31248      const n = (function(s, r, o) {
31249        const a = lt(s);
31250        a in o.usedTiles && s.expireCache(
31251          o.viewState.projection,
31252          o.usedTiles[a]
31253        );
31254      }).bind(null, i);
31255      t.postRenderFunctions.push(
31256        /** @type {import("../../Map.js").PostRenderFunction} */
31257        n
31258      );
31259    }
31260  }
31261  /**
31262   * @param {!Object<string, !Object<string, boolean>>} usedTiles Used tiles.
31263   * @param {import("../../source/Tile.js").default} tileSource Tile source.
31264   * @param {import('../../Tile.js').default} tile Tile.
31265   * @protected
31266   */
31267  updateUsedTiles(t, i, n) {
31268    const s = lt(i);
31269    s in t || (t[s] = {}), t[s][n.getKey()] = !0;
31270  }
31271  /**
31272   * Manage tile pyramid.
31273   * This function performs a number of functions related to the tiles at the
31274   * current zoom and lower zoom levels:
31275   * - registers idle tiles in frameState.wantedTiles so that they are not
31276   *   discarded by the tile queue
31277   * - enqueues missing tiles
31278   * @param {import("../../Map.js").FrameState} frameState Frame state.
31279   * @param {import("../../source/Tile.js").default} tileSource Tile source.
31280   * @param {import("../../tilegrid/TileGrid.js").default} tileGrid Tile grid.
31281   * @param {number} pixelRatio Pixel ratio.
31282   * @param {import("../../proj/Projection.js").default} projection Projection.
31283   * @param {import("../../extent.js").Extent} extent Extent.
31284   * @param {number} currentZ Current Z.
31285   * @param {number} preload Load low resolution tiles up to `preload` levels.
31286   * @param {function(import("../../Tile.js").default):void} [tileCallback] Tile callback.
31287   * @protected
31288   */
31289  manageTilePyramid(t, i, n, s, r, o, a, l, h) {
31290    const c = lt(i);
31291    c in t.wantedTiles || (t.wantedTiles[c] = {});
31292    const u = t.wantedTiles[c], d = t.tileQueue, f = n.getMinZoom(), g = t.viewState.rotation, m = g ? xl(
31293      t.viewState.center,
31294      t.viewState.resolution,
31295      g,
31296      t.size
31297    ) : void 0;
31298    let _ = 0, p, y, x, E, M, w;
31299    for (w = f; w <= a; ++w)
31300      for (y = n.getTileRangeForExtentAndZ(o, w, y), x = n.getResolution(w), E = y.minX; E <= y.maxX; ++E)
31301        for (M = y.minY; M <= y.maxY; ++M)
31302          g && !n.tileCoordIntersectsViewport([w, E, M], m) || (a - w <= l ? (++_, p = i.getTile(w, E, M, s, r), p.get
31302State() == J.IDLE && (u[p.getKey()] = !0, d.isKeyQueued(p.getKey()) || d.enqueue([
31303            p,
31304            c,
31305            n.getTileCoordCenter(p.tileCoord),
31306            x
31307          ])), h !== void 0 && h(p)) : i.useTile(w, E, M, r));
31308    i.updateCacheSize(_, r);
31309  }
31310}
31311const iI = eI;
31312class nI extends tI {
31313  /**
31314   * @param {import("./BaseTile.js").Options<TileSourceType>} [options] Tile layer options.
31315   */
31316  constructor(t) {
31317    super(t);
31318  }
31319  createRenderer() {
31320    return new iI(this);
31321  }
31322}
31323const sI = nI, rI = {
31324  name: "XmapWebLayerWms",
31325  props: {
31326    url: {
31327      type: String,
31328      default: null
31329    },
31330    layer: {
31331      type: String,
31332      default: null
31333    },
31334    opacity: {
31335      type: Number,
31336      default: 100
31337    },
31338    // Boolean-as-string: Vue's custom-element wrapper only coerces Number props.
31339    tiled: {
31340      type: String,
31341      default: null
31342    },
31343    // Names the layer for <xmap-web-check layer="…">; set as the OL layer's `id`.
31344    layerId: {
31345      type: String,
31346      default: null
31347    },
31348    // Human name for the layer: the legend label, falling back to layer-id/layer.
31349    layerTitle: {
31350      type: String,
31351      default: null
31352    },
31353    // Boolean-as-string, default on: legend="false" leaves the layer out of the legend.
31354    legend: {
31355      type: String,
31356      default: null
31357    },
31358    // An image to show in the legend instead of the server's GetLegendGraphic.
31359    legendUrl: {
31360      type: String,
31361      default: null
31362    }
31363  },
31364  created() {
31365    this.l = Is(this.buildLayer()), this.l.set("id", this.layerId || null), this._legendKey = yc();
31366  },
31367  methods: {
31368    isTiled() {
31369      return se(this.tiled, !1);
31370    },
31371    buildLayer() {
31372      const e = this.opacity / 100, t = {
31373        projection: "EPSG:27700",
31374        url: this.url,
31375        params: { LAYERS: this.layer }
31376      };
31377      return this.isTiled() ? new sI({
31378        opacity: e,
31379        source: new YT({ ...t, params: { ...t.params, TILED: !0 } })
31380      }) : new JT({
31381        opacity: e,
31382        source: new ST(t)
31383      });
31384    },
31385    // Plain descriptor for the map's legend, or null when opted out.
31386    legendEntry() {
31387      return !se(this.legend, !0) || !this.l ? null : {
31388        key: this._legendKey,
31389        kind: "wms",
31390        label: ym({ layerTitle: this.layerTitle, layerId: this.layerId, layer: this.layer }),
31391        visible: !0,
31392        zIndex: this.l.getZIndex() ?? 0,
31393        images: dS(this.l.getSource(), this.layer, this.legendUrl)
31394      };
31395    },
31396    publishLegend() {
31397      var e, t;
31398      (t = (e = this._mapComponent) == null ? void 0 : e.setLegendEntry) == null || t.call(e, this._legendKey, this.legendEntry());
31399    }
31400  },
31401  watch: {
31402    opacity(e) {
31403      this.l.setOpacity(e / 100);
31404    },
31405    layerId(e) {
31406      this.l.set("id", e || null), this.publishLegend();
31407    },
31408    layerTitle() {
31409      this.publishLegend();
31410    },
31411    legend() {
31412      this.publishLegend();
31413    },
31414    legendUrl() {
31415      this.publishLegend();
31416    }
31417  },
31418  mounted() {
31419    const e = this.$parent;
31420    e.map.addLayer(this.l), this._mapComponent = e, this.publishLegend();
31421  },
31422  beforeUnmount() {
31423    var t, i, n;
31424    (i = (t = this._mapComponent) == null ? void 0 : t.setLegendEntry) == null || i.call(t, this._legendKey, null);
31425    const e = (n = this._mapComponent) == null ? void 0 : n.map;
31426    e && this.l && e.removeLayer(this.l), this._mapComponent = null;
31427  }
31428}, oI = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit", aI = "https://challenges.cloudflare.com/turnstile/";
31429let qs = null;
31430function lI(e = globalThis.document, t = globalThis.window) {
31431  return t && t.turnstile ? Promise.resolve(t.turnstile) : qs || (qs = new Promise((i, n) => {
31432    const s = e.querySelector(`script[src^="${aI}"]`), r = s || e.createElement("script");
31433    s || (r.src = oI, r.async = !0, r.defer = !0), r.addEventListener("load", () => {
31434      t.turnstile ? i(t.turnstile) : n(new Error("Turnstile script loaded but window.turnstile is missing"));
31435    }), r.addEventListener("error", () => {
31436      qs = null, n(new Error("Turnstile script failed to load"));
31437    }), s || e.head.appendChild(r);
31438  }), qs);
31439}
31440const hI = `.xmap-report-form{display:flex;flex-direction:column;gap:8px;font-family:Roboto,system-ui,sans-serif;
31440color:#1a1a1a}.xrf-fields{display:flex;flex-direction:column;gap:8px}.xrf-field{display:flex;flex-direction:column;gap:4px}.xrf-field label{font-size:13px;font-weight:600}.xrf-field input,.xrf-field textarea,.xrf-field select{font:inherit;padding:6px 8px;border:1px solid #b3bcc4;border-radius:4px}.xmap-report-form button{font:inherit;font-weight:600;padding:9px 14px;border:0;border-radius:4px;background:#263746;color:#fff;cursor:pointer;align-self:flex-start}.xmap-report-form button:disabled{background:#9aa7b1;cursor:not-allowed}.xrf-hint{font-size:12px;color:#505a62;margin:0}.xrf-hint.error{color:#d4351c}::slotted(.xrf-turnstile){display:block;min-height:65px}.xrf-status{font-size:13px;min-height:1.2em;margin:0}.xrf-status.error{color:#d4351c}.xrf-status.ok{color:#00703c}
31441`, cI = "https://api.hub.xmap.cloud", uI = "cf-turnstile-response", dI = "turnstile_failed", fI = "Please wait for the security check to finish, then try again.", gI = "We could not verify your browser. Please try again.", mI = "The security check could not load. Please refresh the page and try again.", _I = {
31442  name: "XmapReportForm",
31443  emits: ["xmap-report-submitted", "xmap-report-error"],
31444  props: {
31445    customer: { type: String, default: null },
31446    target: { type: String, default: null },
31447    apiBase: { type: String, default: cI },
31448    geometryField: { type: String, default: "geometry" },
31449    // Declarative schema. Accepts an Array (JS property) or a JSON string (attribute).
31450    fields: { type: [Array, String], default: () => [] },
31451    submitLabel: { type: String, default: "Submit report" },
31452    // Keep the drawn geometry on the map after a successful submit. Default false
31453    // preserves the existing clear-on-submit behaviour for navigate-away flows;
31454    // set it when the host prefills a form on the same page, so the citizen's
31455    // geometry does not vanish while they are still filling fields in.
31456    keepGeometry: { type: Boolean, default: !1 },
31457    // Cloudflare Turnstile site key (public). When set, a widget is rendered above
31458    // the button and submission is refused until a token exists (XMP-2294). The
31459    // Hub verifies the token server-side; a missing/replayed token is a 403.
31460    turnstileSiteKey: { type: String, default: null }
31461  },
31462  data() {
31463    return {
31464      slotMode: !1,
31465      submitting: !1,
31466      status: "",
31467      statusKind: "",
31468      turnstileToken: null,
31469      turnstileWidgetId: null,
31470      turnstileState: "idle"
31471      // idle | loading | ready | error
31472    };
31473  },
31474  computed: {
31475    hasPoint() {
31476      return le.hasPoint;
31477    },
31478    parsedFields() {
31479      if (Array.isArray(this.fields))
31480        return this.fields;
31481      if (typeof this.fields == "string" && this.fields.trim())
31482        try {
31483          return JSON.parse(this.fields);
31484        } catch {
31485          return [];
31486        }
31487      return [];
31488    },
31489    turnstileEnabled() {
31490      return !!(this.turnstileSiteKey && String(this.turnstileSiteKey).trim());
31491    },
31492    canSubmit() {
31493      return !this.submitting && this.hasPoint && (!this.turnstileEnabled || !!this.turnstileToken);
31494    },
31495    turnstileHint() {
31496      return !this.turnstileEnabled || this.turnstileToken ? "" : this.turnstileState === "error" ? mI : "Checking your browser…";
31497    }
31498  },
31499  watch: {
31500    // `immediate` covers a key present at mount; the watcher itself covers hosts
31501    // that bind the key from config loaded after mount (the Hub does).
31502    turnstileSiteKey: {
31503      immediate: !0,
31504      handler() {
31505        this.mountTurnstile();
31506      }
31507    }
31508  },
31509  mounted() {
31510    const e = this.hostEl();
31511    this.slotMode = !!(e && e.querySelectorAll("[name]").length);
31512  },
31513  beforeUnmount() {
31514    this.removeTurnstile();
31515  },
31516  methods: {
31517    hostEl() {
31518      var e, t, i;
31519      return ((i = (t = (e = this.$el) == null ? void 0 : e.getRootNode) == null ? void 0 : t.call(e)) == null ? void 0 : i.host) || null;
31520    },
31521    collectFields() {
31522      const e = {};
31523      return ((i) => {
31524        i && i.querySelectorAll("[name]").forEach((n) => {
31525          const s = n.getAttribute("name");
31526          s && (e[s] = n.type === "checkbox" ? n.checked : n.value);
31527        });
31528      })(this.slotMode ? this.hostEl() : this.$refs.form), e;
31529    },
31530    validate() {
31531      if (this.slotMode) {
31532        const e = this.hostEl();
31533        return e ? [...e.querySelectorAll("[name]")].every(
31534          (t) => typeof t.reportValidity == "function" ? t.reportValidity() : !0
31535        ) : !0;
31536      }
31537      return this.$refs.form.reportValidity();
31538    },
31539    async onSubmit() {
31540      var t;
31541      if (this.submitting)
31542        return;
31543      if (!this.customer || !this.target) {
31544        this.fail('Misconfigured: "customer" and "target" are required.');
31545        return;
31546      }
31547      if (!le.hasPoint) {
31548        this.fail("Please add a location on the map first.");
31549        return;
31550      }
31551      if (!this.validate())
31552        return;
31553      if (this.turnstileEnabled && !this.turnstileToken) {
31554        this.fail(fI);
31555        return;
31556      }
31557      const e = {
31558        ...this.collectFields(),
31559        [this.geometryField]: le.geometry
31560      };
31561      this.turnstileEnabled && (e[uI] = this.turnstileToken), this.submitting = !0, this.setStatus("Submitting…", "");
31562      try {
31563        const i = await fetch(`${this.apiBase}/${this.customer}/report/${this.target}`, {
31564          method: "POST",
31565          headers: { "content-type": "application/json" },
31566          body: JSON.stringify(e)
31567        }), n = await i.json().catch(() => ({}));
31568        if (!i.ok) {
31569          if (n.code === dI) {
31570            this.fail(gI, i.status, n.code);
31571            return;
31572          }
31573          this.fail(n.error || `Submission failed (${i.status})`, i.status, n.code);
31574          return;
31575        }
31576        const s = ((t = n.data) == null ? void 0 : t[0]) ?? {}, r = le.geometry ? JSON.parse(JSON.stringify(le.geometry)) : null;
31577        this.setStatus("Report submitted. Thank you.", "ok"), this.emitHost("xmap-report-submitted", {
31578          id: s.id ?? null,
31579          // The Hub aliases its columns on the way out: target_pk_value -> object_id,
31580          // geom_stats -> metadata (report-queries.js:30). Read the wire names.
31581          targetPk: s.object_id ?? null,
31582          // PK of the row created in the council's layer
31583          stats: s.metadata ?? null,
31584          // geometry stats derived server-side
31585          geometry: r
31586        }), this.keepGeometry || Sw();
31587      } catch (i) {
31588        this.fail(i.message || "Network error");
31589      } finally {
31590        this.submitting = !1, this.turnstileEnabled && this.resetTurnstile();
31591      }
31592    },
31593    // --- Turnstile -------------------------------------------------------------
31594    async mountTurnstile() {
31595      if (this.removeTurnstile(), !this.turnstileEnabled)
31596        return;
31597      this.turnstileState = "loading";
31598      const e = this.turnstileSiteKey;
31599      try {
31600        await this.$nextTick();
31601        const t = await lI();
31602        if (e !== this.turnstileSiteKey)
31603          return;
31604        const i = this.ensureTurnstileContainer();
31605        if (!i)
31606          return;
31607        this.turnstileWidgetId = t.render(i, {
31608          sitekey: e,
31609          // We hold the token in state and add it to the body ourselves, so slot
31610          // and schema mode behave identically. Cloudflare's hidden input would
31611          // otherwise be harvested by collectFields() in one mode and not the other.
31612          "response-field": !1,
31613          callback: (n) => {
31614            this.turnstileToken = n, this.turnstileState = "ready";
31615          },
31616          "expired-callback": () => {
31617            this.turnstileToken = null;
31618          },
31619          "timeout-callback": () => {
31620            this.turnstileToken = null;
31621          },
31622          "error-callback": () => {
31623            this.turnstileToken = null, this.turnstileState = "error";
31624          }
31625        });
31626      } catch {
31627        this.turnstileToken = null, this.turnstileState = "error";
31628      }
31629    },
31630    // Light-DOM container for the widget (see the template comment). The div goes on
31631    // the host element and is projected through the default <slot>. It carries no
31632    // `name`, so slot-mode harvesting and the slotMode check ignore it.
31633    ensureTurnstileContainer() {
31634      const e = this.hostEl();
31635      if (!e)
31636        return null;
31637      let t = e.querySelector(":scope > .xrf-turnstile");
31638      return t || (t = e.ownerDocument.createElement("div"), t.className = "xrf-turnstile", t.setAttribute("data-xmap-turnstile", ""), e.appendChild(t)), t;
31639    },
31640    resetTurnstile() {
31641      var t;
31642      this.turnstileToken = null;
31643      const e = (t = globalThis.window) == null ? void 0 : t.turnstile;
31644      if (e && this.turnstileWidgetId != null)
31645        try {
31646          e.reset(this.turnstileWidgetId);
31647        } catch {
31648        }
31649    },
31650    removeTurnstile() {
31651      var i, n;
31652      this.turnstileToken = null;
31653      const e = (i = globalThis.window) == null ? void 0 : i.turnstile;
31654      if (e && this.turnstileWidgetId != null)
31655        try {
31656          e.remove(this.turnstileWidgetId);
31657        } catch {
31658        }
31659      this.turnstileWidgetId = null, this.turnstileState = "idle";
31660      const t = this.hostEl();
31661      (n = t == null ? void 0 : t.querySelector(":scope > .xrf-turnstile")) == null || n.remove();
31662    },
31663    fail(e, t, i) {
31664      this.setStatus(e, "error");
31665      const n = { status: t, message: e };
31666      i && (n.code = i), this.emitHost("xmap-report-error", n);
31667    },
31668    setStatus(e, t) {
31669      this.status = e, this.statusKind = t;
31670    },
31671    emitHost(e, t) {
31672      const i = this.hostEl() || this.$el;
31673      i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
31674    }
31675  }
31676}, pI = {
31677  key: 0,
31678  class: "xrf-fields"
31679}, yI = ["for"], xI = { key: 0 }, vI = ["id", "name", "required", "placeholder"], EI = ["id", "name", "required"], CI = ["value"], MI = ["id", "name", "required"], bI = ["type", "id", "name", "required", "placeholder", "pattern"], wI = ["disabled"], SI = {
31680  key: 1,
31681  class: "xrf-hint"
31682};
31683function TI(e, t, i, n, s, r) {
31684  return it(), st("form", {
31685    ref: "form",
31686    class: "xmap-report-form",
31687    onSubmit: t[0] || (t[0] = ag((...o) => r.onSubmit && r.onSubmit(...o), ["prevent"]))
31688  }, [
31689    s.slotMode ? me("", !0) : (it(), st("div", pI, [
31690      (it(!0), st(jt, null, _s(r.parsedFields, (o) => (it(), st("div", {
31691        key: o.name,
31692        class: "xrf-field"
31693      }, [
31694        ut("label", {
31695          for: `xrf-${o.name}`
31696        }, [
31697          sg(Wt(o.label || o.name), 1),
31698          o.required ? (it(), st("span", xI, " *")) : me("", !0)
31699        ], 8, yI),
31700        o.type === "textarea" ? (it(), st("textarea", {
31701          key: 0,
31702          id: `xrf-${o.name}`,
31703          name: o.name,
31704          required: !!o.required,
31705          placeholder: o.placeholder || ""
31706        }, null, 8, vI)) : o.type === "select" ? (it(), st("select", {
31707          key: 1,
31708          id: `xrf-${o.name}`,
31709          name: o.name,
31710          required: !!o.required
31711        }, [
31712          (it(!0), st(jt, null, _s(o.options || [], (a) => (it(), st("option", {
31713            key: a,
31714            value: a
31715          }, Wt(a), 9, CI))), 128))
31716        ], 8, EI)) : o.type === "checkbox" ? (it(), st("input", {
31717          key: 2,
31718          type: "checkbox",
31719          id: `xrf-${o.name}`,
31720          name: o.name,
31721          required: !!o.required
31722        }, null, 8, MI)) : (it(), st("input", {
31723          key: 3,
31724          type: o.type || "text",
31725          id: `xrf-${o.name}`,
31726          name: o.name,
31727          required: !!o.required,
31728          placeholder: o.placeholder || "",
31729          pattern: o.pattern || null
31730        }, null, 8, bI))
31731      ]))), 128))
31732    ])),
31733    Xf(e.$slots, "default"),
31734    ut("button", {
31735      type: "submit",
31736      disabled: !r.canSubmit
31737    }, Wt(s.submitting ? "Submitting…" : i.submitLabel), 9, wI),
31738    r.hasPoint ? r.turnstileHint ? (it(), st("p", {
31739      key: 2,
31740      class: Ue(["xrf-hint", { error: s.turnstileState === "error" }])
31741    }, Wt(r.turnstileHint), 3)) : me("", !0) : (it(), st("p", SI, "Add a location on the map to enable submission.")),
31742    ut("p", {
31743      class: Ue(["xrf-status", s.statusKind])
31744    }, Wt(s.status), 3)
31745  ], 544);
31746}
31747const II = /* @__PURE__ */ xa(_I, [["render", TI], ["styles", [hI]]]), Im = "https://search.xmap.cloud", Rm = { llpg: "llpg/v2", ngd: "ngd" };
31748function Pm(e) {
31749  const t = String(e || "").toLowerCase();
31750  return Rm[t] ? t : "llpg";
31751}
31752function RI(e, t, i, n = "llpg") {
31753  const s = String(e || Im).replace(/\/+$/, ""), r = Rm[Pm(n)];
31754  return `${s}/${encodeURIComponent(t)}/${r}?query=${encodeURIComponent(i)}`;
31755}
31756function PI(e) {
31757  if (!e)
31758    return null;
31759  const t = (s) => s == null || s === "" ? NaN : Number(s), i = t(e.easting), n = t(e.northing);
31760  return !Number.isFinite(i) || !Number.isFinite(n) ? null : {
31761    address: e.postal_address || "",
31762    uprn: e.uprn != null ? String(e.uprn) : null,
31763    usrn: e.usrn != null ? String(e.usrn) : null,
31764    postcode: e.postcode || null,
31765    easting: i,
31766    northing: n,
31767    geometry: { type: "Point", coordinates: [i, n] }
31768  };
31769}
31770function LI(e) {
31771  var i, n;
31772  const t = ((i = e == null ? void 0 : e.data) == null ? void 0 : i.status) ?? (e == null ? void 0 : e.status);
31773  return t && t !== "success" ? ((n = e == null ? void 0 : e.data) == null ? void 0 : n.message) || (e == null ? void 0 : e.message) || `Search failed (${t})` : null;
31774}
31775function AI(e) {
31776  return /key\s*fail|access key/i.test(String(e || ""));
31777}
31778function OI(e, t = 10) {
31779  var s;
31780  const i = (s = e == null ? void 0 : e.data) == null ? void 0 : s.lpi;
31781  if (!Array.isArray(i))
31782    return [];
31783  const n = [];
31784  for (const r of i) {
31785    const o = PI(r);
31786    if (o && n.push(o), n.length >= t)
31787      break;
31788  }
31789  return n;
31790}
31791const FI = `.xmap-address-search{position:relative;font-family:Roboto,system-ui,sans-serif;color:#1a1a1a;text-align:left}.xas-row{display:flex;gap:6px}.xmap-address-search input{font:inherit;flex:1 1 auto;min-width:0;box-sizing:border-box;padding:6px 8px;border:1px solid #b3bcc4;border-radius:4px}.xas-button{font:inherit;font-weight:600;padding:6px 12px;border:0;border-radius:4px;background:#263746;color:#fff;cursor:pointer;white-space:nowrap}.xas-button:disabled{background:#9aa7b1;cursor:not-allowed}.xas-list{position:absolute;z-index:10;left:0;right:0;margin:2px 0 0;padding:0;list-style:none;max-height:240px;overflow-y:auto;background:#fff;border:1px solid #b3bcc4;border-radius:4px;box-shadow:0 4px 12px #0000001f;font-size:13px}.xas-list li{padding:6px 8px;cursor:pointer}.xas-list li.active{background:#263746;color:#fff}.xas-note{color:#505a62;cursor:default}.xas-error{color:#d4351c}
31792`, kI = {
31793  name: "XmapAddressSearch",
31794  emits: ["xmap-address-selected", "xmap-address-error"],
31795  props: {
31796    apiBase: { type: String, default: Im },
31797    apiKey: { type: String, default: null },
31798    // Which gazetteer to query: "llpg" (default) or "ngd".
31799    source: { type: String, default: "llpg" },
31800    // "submit" (default): search on Enter or the Search button.
31801    // "typeahead": search as the user types (debounced).
31802    mode: { type: String, default: "submit" },
31803    // Client-side cap: llpg/v2 ignores its limit param.
31804    limit: { type: [Number, String], default: 10 },
31805    minChars: { type: [Number, String], default: 3 },
31806    placeholder: { type: String, default: "Search for an address" },
31807    searchLabel: { type: String, default: "Search" },
31808    // Typeahead only. Also guards the explicit path against double-fires
31809    // (Enter then an immediate click) by collapsing them into one request.
31810    debounce: { type: [Number, String], default: 300 }
31811  },
31812  data() {
31813    return {
31814      text: "",
31815      suggestions: [],
31816      activeIndex: -1,
31817      open: !1,
31818      loading: !1,
31819      error: "",
31820      _timer: null,
31821      _controller: null
31822    };
31823  },
31824  computed: {
31825    activeId() {
31826      return this.activeIndex >= 0 ? `xas-opt-${this.activeIndex}` : null;
31827    },
31828    isTypeahead() {
31829      return String(this.mode).toLowerCase() === "typeahead";
31830    },
31831    canSearch() {
31832      return this.text.trim().length >= Number(this.minChars);
31833    },
31834    sourceKey() {
31835      return Pm(this.source);
31836    }
31837  },
31838  methods: {
31839    hostEl() {
31840      var e, t, i;
31841      return ((i = (t = (e = this.$el) == null ? void 0 : e.getRootNode) == null ? void 0 : t.call(e)) == null ? void 0 : i.host) || null;
31842    },
31843    emitHost(e, t) {
31844      const i = this.hostEl() || this.$el;
31845      i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
31846    },
31847    onInput(e) {
31848      if (this.text = e.target.value, this.activeIndex = -1, clearTimeout(this._timer), !this.canSearch) {
31849        this.abort(), this.suggestions = [], this.open = !1;
31850        return;
31851      }
31852      if (!this.isTypeahead) {
31853        this.suggestions = [], this.open = !1;
31854        return;
31855      }
31856      this.scheduleSearch();
31857    },
31858    // Every search goes through one debounced timer, so rapid triggers
31859    // (keystrokes in typeahead, Enter + click in submit mode) coalesce.
31860    scheduleSearch() {
31861      clearTimeout(this._timer), this._timer = setTimeout(() => this.search(this.text.trim()), Number(this.debounce));
31862    },
31863    submitSearch() {
31864      this.canSearch && this.scheduleSearch();
31865    },
31866    onFocus() {
31867      this.suggestions.length && (this.open = !0);
31868    },
31869    onBlur() {
31870      setTimeout(() => {
31871        this.open = !1;
31872      }, 120);
31873    },
31874    onKeydown(e) {
31875      const t = this.open && this.suggestions.length > 0;
31876      if (e.key === "Escape") {
31877        this.open = !1;
31878        return;
31879      }
31880      if (e.key === "Enter") {
31881        e.preventDefault(), t && (this.activeIndex >= 0 || this.isTypeahead) ? this.select(this.suggestions[Math.max(this.activeIndex, 0)]) : this.submitSearch();
31882        return;
31883      }
31884      if (!t)
31885        return;
31886      const i = this.suggestions.length;
31887      e.key === "ArrowDown" ? (e.preventDefault(), this.activeIndex = (this.activeIndex + 1) % i) : e.key === "ArrowUp" && (e.preventDefault(), this.activeIndex = (this.activeIndex - 1 + i) % i);
31888    },
31889    abort() {
31890      this._controller && (this._controller.abort(), this._controller = null), this.loading = !1;
31891    },
31892    async search(e) {
31893      if (!this.apiKey) {
31894        this.error = 'Misconfigured: "api-key" is required.', this.open = !0, this.emitHost("xmap-address-error", { message: this.error });
31895        return;
31896      }
31897      this.abort();
31898      const t = new AbortController();
31899      this._controller = t, this.loading = !0, this.error = "", this.open = !0;
31900      try {
31901        const i = await fetch(RI(this.apiBase, this.apiKey, e, this.sourceKey), { signal: t.signal }), n = await i.json().catch(() => ({}));
31902        if (t.signal.aborted)
31903          return;
31904        if (!i.ok) {
31905          this.fail(n.message || `Search failed (${i.status})`, i.status);
31906          return;
31907        }
31908        const s = LI(n);
31909        if (s) {
31910          this.fail(AI(s) ? "Address search is not configured correctly (invalid API key)." : s, i.status);
31911          return;
31912        }
31913        this.suggestions = OI(n, Number(this.limit)), this.activeIndex = -1;
31914      } catch (i) {
31915        if (i.name === "AbortError")
31916          return;
31917        this.fail(i.message || "Network error");
31918      } finally {
31919        this._controller === t && (this._controller = null, this.loading = !1);
31920      }
31921    },
31922    fail(e, t) {
31923      this.suggestions = [], this.error = e, this.emitHost("xmap-address-error", { status: t, message: e });
31924    },
31925    select(e) {
31926      e && (this.text = e.address, this.open = !1, this.suggestions = [e], this.activeIndex = 0, this.emitHost("xmap-address-selected", JSON.parse(JSON.stringify(e))));
31927    }
31928  },
31929  beforeUnmount() {
31930    clearTimeout(this._timer), this.abort();
31931  }
31932}, DI = ["aria-expanded"], NI = { class: "xas-row" }, GI = ["placeholder", "value", "aria-activedescendant"], zI = ["disabled"], jI = {
31933  key: 0,
31934  id: "xas-list",
31935  class: "xas-list",
31936  role: "listbox"
31937}, WI = {
31938  key: 0,
31939  class: "xas-note"
31940}, BI = {
31941  key: 1,
31942  class: "xas-note xas-error"
31943}, UI = {
31944  key: 2,
31945  class: "xas-note"
31946}, XI = ["id", "aria-selected", "onMousedown", "onMousemove"];
31947function $I(e, t, i, n, s, r) {
31948  return it(), st("div", {
31949    class: "xmap-address-search",
31950    role: "combobox",
31951    "aria-expanded": s.open ? "true" : "false",
31952    "aria-haspopup": "listbox",
31953    "aria-owns": "xas-list"
31954  }, [
31955    ut("div", NI, [
31956      ut("input", {
31957        ref: "input",
31958        type: "text",
31959        autocomplete: "off",
31960        spellcheck: "false",
31961        maxlength: "100",
31962        placeholder: i.placeholder,
31963        value: s.text,
31964        "aria-activedescendant": r.activeId,
31965        "aria-autocomplete": "list",
31966        "aria-controls": "xas-list",
31967        onInput: t[0] || (t[0] = (...o) => r.onInput && r.onInput(...o)),
31968        onKeydown: t[1] || (t[1] = (...o) => r.onKeydown && r.onKeydown(...o)),
31969        onFocus: t[2] || (t[2] = (...o) => r.onFocus && r.onFocus(...o)),
31970        onBlur: t[3] || (t[3] = (...o) => r.onBlur && r.onBlur(...o))
31971      }, null, 40, GI),
31972      r.isTypeahead ? me("", !0) : (it(), st("button", {
31973        key: 0,
31974        type: "button",
31975        class: "xas-button",
31976        disabled: s.loading || !r.canSearch,
31977        onClick: t[4] || (t[4] = (o) => r.submitSearch())
31978      }, Wt(i.searchLabel), 9, zI))
31979    ]),
31980    s.open ? (it(), st("ul", jI, [
31981      s.loading ? (it(), st("li", WI, "Searching…")) : s.error ? (it(), st("li", BI, Wt(s.error), 1)) : s.suggestions.length ? me("", !0) : (it(), st("li", UI, "No addresses found")),
31982      (it(!0), st(jt, null, _s(s.suggestions, (o, a) => (it(), st("li", {
31983        key: o.uprn || a,
31984        id: `xas-opt-${a}`,
31985        role: "option",
31986        class: Ue({ active: a === s.activeIndex }),
31987        "aria-selected": a === s.activeIndex ? "true" : "false",
31988        onMousedown: ag((l) => r.select(o), ["prevent"]),
31989        onMousemove: (l) => s.activeIndex = a
31990      }, Wt(o.address), 43, XI))), 128))
31991    ])) : me("", !0)
31992  ], 8, DI);
31993}
31994const YI = /* @__PURE__ */ xa(kI, [["render", $I], ["styles", [FI]]]);
31995class KI {
31996  constructor() {
31997    this.dataProjection = void 0, this.defaultFeatureProjection = void 0, this.supportedMediaTypes = null;
31998  }
31999  /**
32000   * Adds the data projection to the read options.
32001   * @param {Document|Element|Object|string} source Source.
32002   * @param {ReadOptions} [options] Options.
32003   * @return {ReadOptions|undefined} Options.
32004   * @protected
32005   */
32006  getReadOptions(t, i) {
32007    if (i) {
32008      let n = i.dataProjection ? It(i.dataProjection) : this.readProjection(t);
32009      i.extent && n && n.getUnits() === "tile-pixels" && (n = It(n), n.setWorldExtent(i.extent)), i = {
32010        dataProjection: n,
32011        featureProjection: i.featureProjection
32012      };
32013    }
32014    return this.adaptOptions(i);
32015  }
32016  /**
32017   * Sets the `dataProjection` on the options, if no `dataProjection`
32018   * is set.
32019   * @param {WriteOptions|ReadOptions|undefined} options
32020   *     Options.
32021   * @protected
32022   * @return {WriteOptions|ReadOptions|undefined}
32023   *     Updated options.
32024   */
32025  adaptOptions(t) {
32026    return Object.assign(
32027      {
32028        dataProjection: this.dataProjection,
32029        featureProjection: this.defaultFeatureProjection
32030      },
32031      t
32032    );
32033  }
32034  /**
32035   * @abstract
32036   * @return {Type} The format type.
32037   */
32038  getType() {
32039    return Q();
32040  }
32041  /**
32042   * Read a single feature from a source.
32043   *
32044   * @abstract
32045   * @param {Document|Element|Object|string} source Source.
32046   * @param {ReadOptions} [options] Read options.
32047   * @return {import("../Feature.js").FeatureLike} Feature.
32048   */
32049  readFeature(t, i) {
32050    return Q();
32051  }
32052  /**
32053   * Read all features from a source.
32054   *
32055   * @abstract
32056   * @param {Document|Element|ArrayBuffer|Object|string} source Source.
32057   * @param {ReadOptions} [options] Read options.
32058   * @return {Array<import("../Feature.js").FeatureLike>} Features.
32059   */
32060  readFeatures(t, i) {
32061    return Q();
32062  }
32063  /**
32064   * Read a single geometry from a source.
32065   *
32066   * @abstract
32067   * @param {Document|Element|Object|string} source Source.
32068   * @param {ReadOptions} [options] Read options.
32069   * @return {import("../geom/Geometry.js").default} Geometry.
32070   */
32071  readGeometry(t, i) {
32072    return Q();
32073  }
32074  /**
32075   * Read the projection from a source.
32076   *
32077   * @abstract
32078   * @param {Document|Element|Object|string} source Source.
32079   * @return {import("../proj/Projection.js").default|undefined} Projection.
32080   */
32081  readProjection(t) {
32082    return Q();
32083  }
32084  /**
32085   * Encode a feature in this format.
32086   *
32087   * @abstract
32088   * @param {import("../Feature.js").default} feature Feature.
32089   * @param {WriteOptions} [options] Write options.
32090   * @return {string|ArrayBuffer} Result.
32091   */
32092  writeFeature(t, i) {
32093    return Q();
32094  }
32095  /**
32096   * Encode an array of features in this format.
32097   *
32098   * @abstract
32099   * @param {Array<import("../Feature.js").default>} features Features.
32100   * @param {WriteOptions} [options] Write options.
32101   * @return {string|ArrayBuffer} Result.
32102   */
32103  writeFeatures(t, i) {
32104    return Q();
32105  }
32106  /**
32107   * Write a single geometry in this format.
32108   *
32109   * @abstract
32110   * @param {import("../geom/Geometry.js").default} geometry Geometry.
32111   * @param {WriteOptions} [options] Write options.
32112   * @return {string|ArrayBuffer} Result.
32113   */
32114  writeGeometry(t, i) {
32115    return Q();
32116  }
32117}
32118function Lm(e, t, i) {
32119  const n = i ? It(i.featureProjection) : null, s = i ? It(i.dataProjection) : null;
32120  let r;
32121  if (n && s && !Ci(n, s) ? r = (t ? e.clone() : e).transform(
32122    t ? n : s,
32123    t ? s : n
32124  ) : r = e, t && i && /** @type {WriteOptions} */
32125  i.decimals !== void 0) {
32126    const o = Math.pow(
32127      10,
32128      /** @type {WriteOptions} */
32129      i.decimals
32130    ), a = function(l) {
32131      for (let h = 0, c = l.length; h < c; ++h)
32132        l[h] = Math.round(l[h] * o) / o;
32133      return l;
32134    };
32135    r === e && (r = e.clone()), r.applyTransform(a);
32136  }
32137  return r;
32138}
32139class VI extends KI {
32140  constructor() {
32141    super();
32142  }
32143  /**
32144   * @return {import("./Feature.js").Type} Format.
32145   */
32146  getType() {
32147    return "json";
32148  }
32149  /**
32150   * Read a feature.  Only works for a single feature. Use `readFeatures` to
32151   * read a feature collection.
32152   *
32153   * @param {ArrayBuffer|Document|Element|Object|string} source Source.
32154   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32155   * @return {import("../Feature.js").default} Feature.
32156   * @api
32157   */
32158  readFeature(t, i) {
32159    return this.readFeatureFromObject(
32160      xo(t),
32161      this.getReadOptions(t, i)
32162    );
32163  }
32164  /**
32165   * Read all features.  Works with both a single feature and a feature
32166   * collection.
32167   *
32168   * @param {ArrayBuffer|Document|Element|Object|string} source Source.
32169   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32170   * @return {Array<import("../Feature.js").default>} Features.
32171   * @api
32172   */
32173  readFeatures(t, i) {
32174    return this.readFeaturesFromObject(
32175      xo(t),
32176      this.getReadOptions(t, i)
32177    );
32178  }
32179  /**
32180   * @abstract
32181   * @param {Object} object Object.
32182   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32183   * @protected
32184   * @return {import("../Feature.js").default} Feature.
32185   */
32186  readFeatureFromObject(t, i) {
32187    return Q();
32188  }
32189  /**
32190   * @abstract
32191   * @param {Object} object Object.
32192   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32193   * @protected
32194   * @return {Array<import("../Feature.js").default>} Features.
32195   */
32196  readFeaturesFromObject(t, i) {
32197    return Q();
32198  }
32199  /**
32200   * Read a geometry.
32201   *
32202   * @param {ArrayBuffer|Document|Element|Object|string} source Source.
32203   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32204   * @return {import("../geom/Geometry.js").default} Geometry.
32205   * @api
32206   */
32207  readGeometry(t, i) {
32208    return this.readGeometryFromObject(
32209      xo(t),
32210      this.getReadOptions(t, i)
32211    );
32212  }
32213  /**
32214   * @abstract
32215   * @param {Object} object Object.
32216   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32217   * @protected
32218   * @return {import("../geom/Geometry.js").default} Geometry.
32219   */
32220  readGeometryFromObject(t, i) {
32221    return Q();
32222  }
32223  /**
32224   * Read the projection.
32225   *
32226   * @param {ArrayBuffer|Document|Element|Object|string} source Source.
32227   * @return {import("../proj/Projection.js").default} Projection.
32228   * @api
32229   */
32230  readProjection(t) {
32231    return this.readProjectionFromObject(xo(t));
32232  }
32233  /**
32234   * @abstract
32235   * @param {Object} object Object.
32236   * @protected
32237   * @return {import("../proj/Projection.js").default} Projection.
32238   */
32239  readProjectionFromObject(t) {
32240    return Q();
32241  }
32242  /**
32243   * Encode a feature as string.
32244   *
32245   * @param {import("../Feature.js").default} feature Feature.
32246   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32247   * @return {string} Encoded feature.
32248   * @api
32249   */
32250  writeFeature(t, i) {
32251    return JSON.stringify(this.writeFeatureObject(t, i));
32252  }
32253  /**
32254   * @abstract
32255   * @param {import("../Feature.js").default} feature Feature.
32256   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32257   * @return {Object} Object.
32258   */
32259  writeFeatureObject(t, i) {
32260    return Q();
32261  }
32262  /**
32263   * Encode an array of features as string.
32264   *
32265   * @param {Array<import("../Feature.js").default>} features Features.
32266   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32267   * @return {string} Encoded features.
32268   * @api
32269   */
32270  writeFeatures(t, i) {
32271    return JSON.stringify(this.writeFeaturesObject(t, i));
32272  }
32273  /**
32274   * @abstract
32275   * @param {Array<import("../Feature.js").default>} features Features.
32276   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32277   * @return {Object} Object.
32278   */
32279  writeFeaturesObject(t, i) {
32280    return Q();
32281  }
32282  /**
32283   * Encode a geometry as string.
32284   *
32285   * @param {import("../geom/Geometry.js").default} geometry Geometry.
32286   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32287   * @return {string} Encoded geometry.
32288   * @api
32289   */
32290  writeGeometry(t, i) {
32291    return JSON.stringify(this.writeGeometryObject(t, i));
32292  }
32293  /**
32294   * @abstract
32295   * @param {import("../geom/Geometry.js").default} geometry Geometry.
32296   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32297   * @return {Object} Object.
32298   */
32299  writeGeometryObject(t, i) {
32300    return Q();
32301  }
32302}
32303function xo(e) {
32304  if (typeof e == "string") {
32305    const t = JSON.parse(e);
32306    return t || null;
32307  }
32308  return e !== null ? e : null;
32309}
32310const qI = VI;
32311class HI extends qI {
32312  /**
32313   * @param {Options} [options] Options.
32314   */
32315  constructor(t) {
32316    t = t || {}, super(), this.dataProjection = It(
32317      t.dataProjection ? t.dataProjection : "EPSG:4326"
32318    ), t.featureProjection && (this.defaultFeatureProjection = It(t.featureProjection)), this.geometryName_ = t.geometryName, this.extractGeometryName_ = t.extractGeometryName, this.supportedMediaTypes = [
32319      "application/geo+json",
32320      "application/vnd.geo+json"
32321    ];
32322  }
32323  /**
32324   * @param {Object} object Object.
32325   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32326   * @protected
32327   * @return {import("../Feature.js").default} Feature.
32328   */
32329  readFeatureFromObject(t, i) {
32330    let n = null;
32331    t.type === "Feature" ? n = /** @type {GeoJSONFeature} */
32332    t : n = {
32333      type: "Feature",
32334      geometry: (
32335        /** @type {GeoJSONGeometry} */
32336        t
32337      ),
32338      properties: null
32339    };
32340    const s = Hl(n.geometry, i), r = new ke();
32341    return this.geometryName_ ? r.setGeometryName(this.geometryName_) : this.extractGeometryName_ && "geometry_name" in n !== void 0 && r.setGeometryName(n.geometry_name), r.setGeometry(s), "id" in n && r.setId(n.id), n.properties && r.setProperties(n.properties, !0), r;
32342  }
32343  /**
32344   * @param {Object} object Object.
32345   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32346   * @protected
32347   * @return {Array<Feature>} Features.
32348   */
32349  readFeaturesFromObject(t, i) {
32350    const n = (
32351      /** @type {GeoJSONObject} */
32352      t
32353    );
32354    let s = null;
32355    if (n.type === "FeatureCollection") {
32356      const r = (
32357        /** @type {GeoJSONFeatureCollection} */
32358        t
32359      );
32360      s = [];
32361      const o = r.features;
32362      for (let a = 0, l = o.length; a < l; ++a)
32363        s.push(this.readFeatureFromObject(o[a], i));
32364    } else
32365      s = [this.readFeatureFromObject(t, i)];
32366    return s;
32367  }
32368  /**
32369   * @param {GeoJSONGeometry} object Object.
32370   * @param {import("./Feature.js").ReadOptions} [options] Read options.
32371   * @protected
32372   * @return {import("../geom/Geometry.js").default} Geometry.
32373   */
32374  readGeometryFromObject(t, i) {
32375    return Hl(t, i);
32376  }
32377  /**
32378   * @param {Object} object Object.
32379   * @protected
32380   * @return {import("../proj/Projection.js").default} Projection.
32381   */
32382  readProjectionFromObject(t) {
32383    const i = t.crs;
32384    let n;
32385    return i ? i.type == "name" ? n = It(i.properties.name) : i.type === "EPSG" ? n = It("EPSG:" + i.properties.code) : ht(!1, 36) : n = this.dataProjection, /** @type {import("../proj/Projection.js").default} */
32386    n;
32387  }
32388  /**
32389   * Encode a feature as a GeoJSON Feature object.
32390   *
32391   * @param {import("../Feature.js").default} feature Feature.
32392   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32393   * @return {GeoJSONFeature} Object.
32394   * @api
32395   */
32396  writeFeatureObject(t, i) {
32397    i = this.adaptOptions(i);
32398    const n = {
32399      type: "Feature",
32400      geometry: null,
32401      properties: null
32402    }, s = t.getId();
32403    if (s !== void 0 && (n.id = s), !t.hasProperties())
32404      return n;
32405    const r = t.getProperties(), o = t.getGeometry();
32406    return o && (n.geometry = Zl(o, i), delete r[t.getGeometryName()]), bs(r) || (n.properties = r), n;
32407  }
32408  /**
32409   * Encode an array of features as a GeoJSON object.
32410   *
32411   * @param {Array<import("../Feature.js").default>} features Features.
32412   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32413   * @return {GeoJSONFeatureCollection} GeoJSON Object.
32414   * @api
32415   */
32416  writeFeaturesObject(t, i) {
32417    i = this.adaptOptions(i);
32418    const n = [];
32419    for (let s = 0, r = t.length; s < r; ++s)
32420      n.push(this.writeFeatureObject(t[s], i));
32421    return {
32422      type: "FeatureCollection",
32423      features: n
32424    };
32425  }
32426  /**
32427   * Encode a geometry as a GeoJSON object.
32428   *
32429   * @param {import("../geom/Geometry.js").default} geometry Geometry.
32430   * @param {import("./Feature.js").WriteOptions} [options] Write options.
32431   * @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.
32432   * @api
32433   */
32434  writeGeometryObject(t, i) {
32435    return Zl(t, this.adaptOptions(i));
32436  }
32437}
32438function Hl(e, t) {
32439  if (!e)
32440    return null;
32441  let i;
32442  switch (e.type) {
32443    case "Point": {
32444      i = JI(
32445        /** @type {GeoJSONPoint} */
32446        e
32447      );
32448      break;
32449    }
32450    case "LineString": {
32451      i = QI(
32452        /** @type {GeoJSONLineString} */
32453        e
32454      );
32455      break;
32456    }
32457    case "Polygon": {
32458      i = nR(
32459        /** @type {GeoJSONPolygon} */
32460        e
32461      );
32462      break;
32463    }
32464    case "MultiPoint": {
32465      i = eR(
32466        /** @type {GeoJSONMultiPoint} */
32467        e
32468      );
32469      break;
32470    }
32471    case "MultiLineString": {
32472      i = tR(
32473        /** @type {GeoJSONMultiLineString} */
32474        e
32475      );
32476      break;
32477    }
32478    case "MultiPolygon": {
32479      i = iR(
32480        /** @type {GeoJSONMultiPolygon} */
32481        e
32482      );
32483      break;
32484    }
32485    case "GeometryCollection": {
32486      i = ZI(
32487        /** @type {GeoJSONGeometryCollection} */
32488        e
32489      );
32490      break;
32491    }
32492    default:
32493      throw new Error("Unsupported GeoJSON type: " + e.type);
32494  }
32495  return Lm(i, !1, t);
32496}
32497function ZI(e, t) {
32498  const i = e.geometries.map(
32499    /**
32500     * @param {GeoJSONGeometry} geometry Geometry.
32501     * @return {import("../geom/Geometry.js").default} geometry Geometry.
32502     */
32503    function(n) {
32504      return Hl(n, t);
32505    }
32506  );
32507  return new sm(i);
32508}
32509function JI(e) {
32510  return new Ne(e.coordinates);
32511}
32512function QI(e) {
32513  return new Qi(e.coordinates);
32514}
32515function tR(e) {
32516  return new dc(e.coordinates);
32517}
32518function eR(e) {
32519  return new gc(e.coordinates);
32520}
32521function iR(e) {
32522  return new mc(e.coordinates);
32523}
32524function nR(e) {
32525  return new Fn(e.coordinates);
32526}
32527function Zl(e, t) {
32528  e = Lm(e, !0, t);
32529  const i = e.getType();
32530  let n;
32531  switch (i) {
32532    case "Point": {
32533      n = hR(
32534        /** @type {Point} */
32535        e
32536      );
32537      break;
32538    }
32539    case "LineString": {
32540      n = rR(
32541        /** @type {LineString} */
32542        e
32543      );
32544      break;
32545    }
32546    case "Polygon": {
32547      n = cR(
32548        /** @type {Polygon} */
32549        e,
32550        t
32551      );
32552      break;
32553    }
32554    case "MultiPoint": {
32555      n = aR(
32556        /** @type {MultiPoint} */
32557        e
32558      );
32559      break;
32560    }
32561    case "MultiLineString": {
32562      n = oR(
32563        /** @type {MultiLineString} */
32564        e
32565      );
32566      break;
32567    }
32568    case "MultiPolygon": {
32569      n = lR(
32570        /** @type {MultiPolygon} */
32571        e,
32572        t
32573      );
32574      break;
32575    }
32576    case "GeometryCollection": {
32577      n = sR(
32578        /** @type {GeometryCollection} */
32579        e,
32580        t
32581      );
32582      break;
32583    }
32584    case "Circle": {
32585      n = {
32586        type: "GeometryCollection",
32587        geometries: []
32588      };
32589      break;
32590    }
32591    default:
32592      throw new Error("Unsupported geometry type: " + i);
32593  }
32594  return n;
32595}
32596function sR(e, t) {
32597  return t = Object.assign({}, t), delete t.featureProjection, {
32598    type: "GeometryCollection",
32599    geometries: e.getGeometriesArray().map(function(n) {
32600      return Zl(n, t);
32601    })
32602  };
32603}
32604function rR(e, t) {
32605  return {
32606    type: "LineString",
32607    coordinates: e.getCoordinates()
32608  };
32609}
32610function oR(e, t) {
32611  return {
32612    type: "MultiLineString",
32613    coordinates: e.getCoordinates()
32614  };
32615}
32616function aR(e, t) {
32617  return {
32618    type: "MultiPoint",
32619    coordinates: e.getCoordinates()
32620  };
32621}
32622function lR(e, t) {
32623  let i;
32624  return t && (i = t.rightHanded), {
32625    type: "MultiPolygon",
32626    coordinates: e.getCoordinates(i)
32627  };
32628}
32629function hR(e, t) {
32630  return {
32631    type: "Point",
32632    coordinates: e.getCoordinates()
32633  };
32634}
32635function cR(e, t) {
32636  let i;
32637  return t && (i = t.rightHanded), {
32638    type: "Polygon",
32639    coordinates: e.getCoordinates(i)
32640  };
32641}
32642const uR = HI;
32643function Cc(e) {
32644  let t = e == null ? void 0 : e.$parent;
32645  for (; t; ) {
32646    if (t.map)
32647      return t;
32648    t = t.$parent;
32649  }
32650  return null;
32651}
32652const dR = {
32653  name: "XmapWebLayerGeoJson",
32654  // Nothing to render: the layer lives on the parent's map. An explicit null
32655  // render keeps Vue from warning about a missing template.
32656  render() {
32657    return null;
32658  },
32659  // Defaults so a layer placed outside <xmap-app> (or in a test) does not warn.
32660  inject: {
32661    primaryColor: { default: null },
32662    secondaryColor: { default: null }
32663  },
32664  props: {
32665    // Fetched on mount and on change. Ignored while `data` is non-empty. A bare
32666    // WFS endpoint is completed by buildLayerUrl (see lib/geojson-layer.js).
32667    url: { type: String, default: null },
32668    // WFS typeNames when the URL is a bare endpoint whose path does not name the layer.
32669    layer: { type: String, default: null },
32670    // Inline GeoJSON text. Wins over `url`.
32671    data: { type: String, default: null },
32672    // EPSG:27700 (default) | EPSG:4326. Absent + a `crs` member → OL reads the member.
32673    projection: { type: String, default: null },
32674    // 0–100, as the WMS layer.
32675    opacity: { type: Number, default: 100 },
32676    // String, not Boolean: Vue only coerces Number attributes, so a Boolean prop
32677    // would make visible="false" truthy. Read through boolAttr().
32678    visible: { type: String, default: null },
32679    // Fit the view to the loaded extent once per load (XMP-2228 guard applies).
32680    fit: { type: String, default: null },
32681    fillColor: { type: String, default: null },
32682    strokeColor: { type: String, default: null },
32683    strokeWidth: { type: Number, default: 2 },
32684    pointRadius: { type: Number, default: 6 },
32685    // For bodies that are an array of records rather than GeoJSON: the keys
32686    // holding the point coordinates, and optionally the key (dotted path) of
32687    // the array inside a wrapping object. Each record becomes a Point.
32688    xField: { type: String, default: null },
32689    yField: { type: String, default: null },
32690    recordsField: { type: String, default: null },
32691    // Identity for checks: `layer-id` names the layer (set as the OL layer's
32692    // `id` property, so <xmap-web-check layer="…"> can find it); `asset-id` is
32693    // the feature property holding the asset reference (default `id`).
32694    layerId: { type: String, default: null },
32695    assetId: { type: String, default: null },
32696    // Human name for the layer: the legend label, falling back to layer-id/layer.
32697    layerTitle: { type: String, default: null },
32698    // Boolean-as-string, default on: legend="false" leaves the layer out of the legend.
32699    legend: { type: String, default: null },
32700    // Metres per pixel: the layer is drawn only below this resolution (OL's own
32701    // maxResolution). A feature list on this layer inherits it.
32702    maxResolution: { type: String, default: null }
32703  },
32704  methods: {
32705    // Walk up to the component that owns the map rather than reading
32706    // this.$parent.map blind (shared with <xmap-web-check>, see lib/parent-map.js).
32707    resolveMapComponent() {
32708      return Cc(this);
32709    },
32710    currentStyle() {
32711      return Vw({
32712        fillColor: this.fillColor,
32713        strokeColor: this.strokeColor,
32714        strokeWidth: this.strokeWidth,
32715        pointRadius: this.pointRadius,
32716        primary: this.primaryColor,
32717        secondary: this.secondaryColor
32718      });
32719    },
32720    ensureLayer() {
32721      this._layer || (this._source = Is(new ys()), this._layer = Is(new ps({
32722        source: this._source,
32723        // Above the WMS layers (no zIndex → 0), below the draw layer (100): the
32724        // user's own drawing is never hidden behind loaded data.
32725        zIndex: 50,
32726        style: this.currentStyle(),
32727        opacity: this.opacity / 100,
32728        visible: se(this.visible, !0),
32729        maxResolution: this.layerMaxResolution()
32730      })), this.applyIdentity());
32731    },
32732    // Absent or not a positive number: no threshold (OL's default).
32733    layerMaxResolution() {
32734      const e = Number(this.maxResolution);
32735      return this.maxResolution != null && this.maxResolution !== "" && Number.isFinite(e) && e > 0 ? e : 1 / 0;
32736    },
32737    // Read by the map's feature list: loading | loaded | error, on the OL layer.
32738    setLoadState(e) {
32739      var t;
32740      (t = this._layer) == null || t.set("loadState", e);
32741    },
32742    applyIdentity() {
32743      this._layer && (this._layer.set("id", this.layerId || null), this._layer.set("assetId", this.assetId || "id"));
32744    },
32745    applyStyle() {
32746      this._layer && this._layer.setStyle(this.currentStyle()), this.publishLegend();
32747    },
32748    // Plain descriptor for the map's legend, or null when opted out. The swatch
32749    // uses the same resolved colours as currentStyle().
32750    legendEntry() {
32751      var t;
32752      if (!se(this.legend, !0))
32753        return null;
32754      const e = mm({
32755        fillColor: this.fillColor,
32756        strokeColor: this.strokeColor,
32757        strokeWidth: this.strokeWidth,
32758        primary: this.primaryColor,
32759        secondary: this.secondaryColor
32760      });
32761      return {
32762        key: this._legendKey,
32763        kind: "geojson",
32764        label: ym({ layerTitle: this.layerTitle, layerId: this.layerId, layer: this.layer }),
32765        visible: se(this.visible, !0),
32766        zIndex: ((t = this._layer) == null ? void 0 : t.getZIndex()) ?? 50,
32767        swatch: mS(e, this._geometryKind)
32768      };
32769    },
32770    publishLegend() {
32771      var e, t;
32772      this._legendKey != null && ((t = (e = this._mapComponent) == null ? void 0 : e.setLegendEntry) == null || t.call(e, this._legendKey, this.legendEntry()));
32773    },
32774    abort() {
32775      this._controller && (this._controller.abort(), this._controller = null);
32776    },
32777    // Re-read the source. Precedence: data (trimmed, non-empty) → url → empty
32778    // layer. Both absent is not an error; it is an empty layer and emits nothing.
32779    async reload() {
32780      if (this.abort(), this._fitted = !1, !this._source)
32781        return;
32782      const e = typeof this.data == "string" ? this.data.trim() : "";
32783      if (e) {
32784        this.setFromText(e);
32785        return;
32786      }
32787      if (!this.url) {
32788        this._source.clear();
32789        return;
32790      }
32791      const t = new AbortController();
32792      this._controller = t, this.setLoadState("loading");
32793      try {
32794        const i = await fetch(qw(this.url, { layer: this.layer, projection: this.projection }), { signal: t.signal }), n = await i.text();
32795        if (t.signal.aborted)
32796          return;
32797        if (!i.ok) {
32798          this.fail(`Layer request failed (${i.status})`);
32799          return;
32800        }
32801        this.setFromText(n);
32802      } catch (i) {
32803        if ((i == null ? void 0 : i.name) === "AbortError")
32804          return;
32805        this.fail((i == null ? void 0 : i.message) || "Network error");
32806      } finally {
32807        this._controller === t && (this._controller = null);
32808      }
32809    },
32810    setFromText(e) {
32811      if (!this._source)
32812        return;
32813      const t = $w(e, { xField: this.xField, yField: this.yField, recordsField: this.recordsField });
32814      if (!t.ok) {
32815        this.fail(t.message);
32816        return;
32817      }
32818      const i = Uw(this.projection, t.object);
32819      if (i === null) {
32820        this.fail(`Unsupported projection "${this.projection}" (use EPSG:27700 or EPSG:4326)`);
32821        return;
32822      }
32823      let n;
32824      try {
32825        n = new uR().readFeatures(t.object, {
32826          ...i ? { dataProjection: i } : {},
32827          featureProjection: _c
32828        });
32829      } catch (r) {
32830        this.fail(`Invalid GeoJSON (${(r == null ? void 0 : r.message) || "unreadable geometry"})`);
32831        return;
32832      }
32833      this._source.clear(), this._source.addFeatures(n);
32834      const s = gS(n);
32835      s && (this._geometryKind = s, this.publishLegend()), this.setLoadState("loaded"), this.emitHost("xmap-layer-loaded", { count: n.length, skipped: t.skipped }), this.maybeFit();
32836    },
32837    // Once per load, only when `fit` is on. Delegates to the map component's
32838    // fitToExtent so the XMP-2228 sized-map guard applies. maxZoom is not
32839    // optional: a single point has a zero-size extent and view.fit would
32840    // otherwise zoom to the view's maximum.
32841    maybeFit() {
32842      var t, i;
32843      if (this._fitted || !this._source || !se(this.fit, !1))
32844        return;
32845      const e = this._source.getExtent();
32846      Nn(e) || (this._fitted = !0, (i = (t = this._mapComponent) == null ? void 0 : t.fitToExtent) == null || i.call(t, e, { padding: [24, 24, 24, 24], maxZoom: 18 }));
32847    },
32848    // Every failure path: clear our own source, touch nothing else on the map.
32849    fail(e) {
32850      this._source && this._source.clear(), this.setLoadState("error"), this.emitHost("xmap-layer-error", { message: e });
32851    },
32852    // Dispatch on the custom-element host so the event reaches the host page.
32853    // A template-less component's $el is Vue's placeholder comment inside the
32854    // shadow root; getRootNode().host on it is still the custom element.
32855    emitHost(e, t) {
32856      var n, s, r;
32857      const i = ((r = (s = (n = this.$el) == null ? void 0 : n.getRootNode) == null ? void 0 : s.call(n)) == null ? void 0 : r.host) || this.$el;
32858      i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
32859    },
32860    // False when no parent map is reachable; otherwise the (truthy) promise of
32861    // the first load, so callers can await it.
32862    //
32863    // The first load is deferred to the next task on purpose. Custom elements
32864    // upgrade synchronously when the bundle defines them, so an inline `data`
32865    // load would emit xmap-layer-loaded before a host script placed after the
32866    // bundle has added its listener, and the event would be lost. A microtask
32867    // is not enough: the browser runs a microtask checkpoint between scripts.
32868    attach() {
32869      const e = this.resolveMapComponent();
32870      return e ? (this._mapComponent = e, this.ensureLayer(), e.map.addLayer(this._layer), this._legendKey == null && (this._legendKey = yc()), this.publishLegend(), new Promise((t) => setTimeout(() => t(this.reload()), 0))) : !1;
32871    }
32872  },
32873  watch: {
32874    url() {
32875      this.reload();
32876    },
32877    layer() {
32878      this.reload(), this.publishLegend();
32879    },
32880    data() {
32881      this.reload();
32882    },
32883    projection() {
32884      this.reload();
32885    },
32886    xField() {
32887      this.reload();
32888    },
32889    yField() {
32890      this.reload();
32891    },
32892    recordsField() {
32893      this.reload();
32894    },
32895    opacity(e) {
32896      this._layer && this._layer.setOpacity(e / 100);
32897    },
32898    maxResolution() {
32899      this._layer && this._layer.setMaxResolution(this.layerMaxResolution());
32900    },
32901    visible(e) {
32902      this._layer && this._layer.setVisible(se(e, !0)), this.publishLegend();
32903    },
32904    fit() {
32905      this._fitted = !1, this.maybeFit();
32906    },
32907    layerId() {
32908      this.applyIdentity(), this.publishLegend();
32909    },
32910    layerTitle() {
32911      this.publishLegend();
32912    },
32913    legend() {
32914      this.publishLegend();
32915    },
32916    assetId() {
32917      this.applyIdentity();
32918    },
32919    fillColor() {
32920      this.applyStyle();
32921    },
32922    strokeColor() {
32923      this.applyStyle();
32924    },
32925    strokeWidth() {
32926      this.applyStyle();
32927    },
32928    pointRadius() {
32929      this.applyStyle();
32930    }
32931  },
32932  mounted() {
32933    this.attach() || this.$nextTick(() => {
32934      this.attach() || this.emitHost("xmap-layer-error", { message: "<xmap-web-layer-geojson> must be a child of <xmap-web-map>" });
32935    });
32936  },
32937  beforeUnmount() {
32938    var t, i, n;
32939    this.abort();
32940    const e = (t = this._mapComponent) == null ? void 0 : t.map;
32941    e && this._layer && e.removeLayer(this._layer), this._legendKey != null && ((n = (i = this._mapComponent) == null ? void 0 : i.set
32941LegendEntry) == null || n.call(i, this._legendKey, null)), this._layer = null, this._source = null, this._mapComponent = null;
32942  }
32943}, fR = {
32944  name: "XmapWebCheck",
32945  render() {
32946    return null;
32947  },
32948  props: {
32949    // Key in the aggregate results and in every event detail.
32950    name: { type: String, default: null },
32951    // The endpoint. Query string preserved; x/y appended for a Point.
32952    url: { type: String, default: null },
32953    // Shown when the rule fails (false, or required + empty). Not for transport errors.
32954    message: { type: String, default: null },
32955    // String, not Boolean: Vue only coerces Number attributes. Read through boolAttr().
32956    // `required`: an object/array result that is empty fails the check.
32957    required: { type: String, default: null },
32958    // `snap`: on a passing object result with coordinates, move the drawn point onto them.
32959    snap: { type: String, default: null },
32960    // Milliseconds before the request is abandoned and the check fails closed.
32961    timeout: { type: Number, default: _m },
32962    // banner="false": never show this check's message in the map's banner.
32963    banner: { type: String, default: null },
32964    // Sent as an x-api-key header, for Hub endpoints gated by key.
32965    apiKey: { type: String, default: null },
32966    // URL checks: the response attribute holding the asset reference. A passing
32967    // object body then records its nearest match as the selection (`asset` in
32968    // the events and the details envelope), as a layer select does. With
32969    // snap="true" the pin also moves onto it. Layer checks read asset-id from
32970    // the layer instead.
32971    assetId: { type: String, default: null },
32972    // Layer checks: the layer-id of a layer on the map, a distance ("15" metres
32973    // or "15px"), and the verdict when a feature is that close: select | fail | warn.
32974    layer: { type: String, default: null },
32975    within: { type: String, default: null },
32976    match: { type: String, default: null }
32977  },
32978  methods: {
32979    // Plain object handed to the map's runner. Read fresh on every run, so an
32980    // attribute changed after mount is picked up without any re-registration.
32981    spec() {
32982      return {
32983        name: this.name || this.url || this.layer || "check",
32984        url: this.url,
32985        message: this.message || null,
32986        required: se(this.required, !1),
32987        snap: se(this.snap, !1),
32988        timeout: this.timeout,
32989        banner: se(this.banner, !0),
32990        apiKey: this.apiKey || null,
32991        assetId: this.assetId || null,
32992        layer: this.layer || null,
32993        within: this.within ?? null,
32994        match: this.match || null
32995      };
32996    },
32997    // Dispatch on the custom-element host so the event reaches the host page.
32998    emitHost(e, t) {
32999      var n, s, r;
33000      const i = ((r = (s = (n = this.$el) == null ? void 0 : n.getRootNode) == null ? void 0 : s.call(n)) == null ? void 0 : r.host) || this.$el;
33001      i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
33002    },
33003    // False when no parent map is reachable. Nothing to do until a geometry
33004    // exists, so unlike the layers there is no deferred first load.
33005    attach() {
33006      const e = Cc(this);
33007      return !e || typeof e.registerCheck != "function" ? !1 : (this._mapComponent = e, e.registerCheck(this), !0);
33008    }
33009  },
33010  mounted() {
33011    this.attach() || this.$nextTick(() => {
33012      this.attach() || this.emitHost("xmap-check-error", { message: "<xmap-web-check> must be a child of <xmap-web-map>" });
33013    });
33014  },
33015  beforeUnmount() {
33016    var e, t;
33017    (t = (e = this._mapComponent) == null ? void 0 : e.unregisterCheck) == null || t.call(e, this), this._mapComponent = null;
33018  }
33019}, gR = {
33020  name: "XmapWebFeatureList",
33021  render() {
33022    return null;
33023  },
33024  props: {
33025    // The layer-id of a vector layer on the map.
33026    layer: { type: String, default: null },
33027    // The select's visible label, and the list's name in announcements.
33028    label: { type: String, default: null },
33029    // Entry text: {prop} is replaced by that feature property. Default: the asset id.
33030    itemLabel: { type: String, default: null },
33031    // Most entries shown (1–50, default 10), nearest the view centre kept.
33032    limit: { type: String, default: null },
33033    // Metres per pixel; zoomed out past it the list asks the user to zoom in.
33034    // Absent: the layer's own max-resolution. "none": no threshold.
33035    maxResolution: { type: String, default: null },
33036    placeholder: { type: String, default: null },
33037    zoomText: { type: String, default: null },
33038    noneText: { type: String, default: null },
33039    // Boolean-as-string: append each entry's distance from the view centre.
33040    showDistance: { type: String, default: null },
33041    // Key in xmap-feature-list-changed. Default: the layer.
33042    name: { type: String, default: null }
33043  },
33044  methods: {
33045    descriptor() {
33046      return {
33047        layer: this.layer || null,
33048        label: this.label || null,
33049        itemLabel: this.itemLabel || null,
33050        limit: this.limit ?? null,
33051        maxResolution: this.maxResolution ?? null,
33052        placeholder: this.placeholder || null,
33053        zoomText: this.zoomText || null,
33054        noneText: this.noneText || null,
33055        showDistance: this.showDistance ?? null,
33056        name: this.name || this.layer || "list"
33057      };
33058    },
33059    publish() {
33060      var e, t;
33061      (t = (e = this._mapComponent) == null ? void 0 : e.setFeatureList) == null || t.call(e, this._key, this.descriptor());
33062    },
33063    // Dispatch on the custom-element host so the event reaches the host page.
33064    emitHost(e, t) {
33065      var n, s, r;
33066      const i = ((r = (s = (n = this.$el) == null ? void 0 : n.getRootNode) == null ? void 0 : s.call(n)) == null ? void 0 : r.host) || this.$el;
33067      i == null || i.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
33068    },
33069    // False when no parent map is reachable.
33070    attach() {
33071      const e = Cc(this);
33072      return !e || typeof e.setFeatureList != "function" ? !1 : (this._mapComponent = e, this._key == null && (this._key = yc()), this.publish(), !0);
33073    }
33074  },
33075  watch: {
33076    layer() {
33077      this.publish();
33078    },
33079    label() {
33080      this.publish();
33081    },
33082    itemLabel() {
33083      this.publish();
33084    },
33085    limit() {
33086      this.publish();
33087    },
33088    maxResolution() {
33089      this.publish();
33090    },
33091    placeholder() {
33092      this.publish();
33093    },
33094    zoomText() {
33095      this.publish();
33096    },
33097    noneText() {
33098      this.publish();
33099    },
33100    showDistance() {
33101      this.publish();
33102    },
33103    name() {
33104      this.publish();
33105    }
33106  },
33107  mounted() {
33108    this.attach() || this.$nextTick(() => {
33109      this.attach() || this.emitHost("xmap-feature-list-error", { message: "<xmap-web-feature-list> must be a child of <xmap-web-map>" });
33110    });
33111  },
33112  beforeUnmount() {
33113    var e, t;
33114    (t = (e = this._mapComponent) == null ? void 0 : e.setFeatureList) == null || t.call(e, this._key, null), this._mapComponent = null;
33115  }
33116};
33117Me.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
33118Xx(Me);
33119const mR = It("EPSG:27700");
33120mR.setExtent([0, 0, 7e5, 13e5]);
33121const _R = on(wE), pR = on(gT), yR = on(rI), xR = on(II), vR = on(YI), ER = on(dR), CR = on(fR), MR = on(gR), hn = (e, t) => {
33122  customElements.get(e) || customElements.define(e, t);
33123};
33124hn("xmap-app", _R);
33125hn("xmap-web-map", pR);
33126hn("xmap-web-layer-wms", yR);
33127hn("xmap-report-form", xR);
33128hn("xmap-address-search", vR);
33129hn("xmap-web-layer-geojson", ER);
33130hn("xmap-web-check", CR);
33131hn("xmap-web-feature-list", MR);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.