@wemap/osm 10.11.2 → 11.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,47 +1,38 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => {
5
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
- return value;
7
- };
8
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
9
- const saxes = require("saxes");
10
- const geo = require("@wemap/geo");
11
- class OsmElement {
12
- constructor(id, tags) {
13
- __publicField(this, "id");
14
- __publicField(this, "tags");
15
- this.id = id;
16
- this.tags = tags || {};
1
+ var Jt = Object.defineProperty;
2
+ var Kt = (s, t, e) => t in s ? Jt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var M = (s, t, e) => (Kt(s, typeof t != "symbol" ? t + "" : t, e), e);
4
+ class $t {
5
+ constructor(t, e) {
6
+ M(this, "id");
7
+ M(this, "tags");
8
+ this.id = t, this.tags = e || {};
17
9
  }
18
10
  }
19
- class OsmModel {
20
- constructor(nodes, ways) {
21
- __publicField(this, "nodes");
22
- __publicField(this, "ways");
23
- this.nodes = nodes || [];
24
- this.ways = ways || [];
11
+ class Zt {
12
+ constructor(t, e) {
13
+ M(this, "nodes");
14
+ M(this, "ways");
15
+ this.nodes = t || [], this.ways = e || [];
25
16
  }
26
- getNodeById(id) {
27
- return this.nodes.find((node) => node.id === id) || null;
17
+ getNodeById(t) {
18
+ return this.nodes.find((e) => e.id === t) || null;
28
19
  }
29
- getNodeByName(name) {
30
- return this.nodes.find((node) => node.tags.name === name) || null;
20
+ getNodeByName(t) {
21
+ return this.nodes.find((e) => e.tags.name === t) || null;
31
22
  }
32
- getWayById(id) {
33
- return this.ways.find((way) => way.id === id) || null;
23
+ getWayById(t) {
24
+ return this.ways.find((e) => e.id === t) || null;
34
25
  }
35
- getWayByName(name) {
36
- return this.ways.find((way) => way.tags.name === name) || null;
26
+ getWayByName(t) {
27
+ return this.ways.find((e) => e.tags.name === t) || null;
37
28
  }
38
29
  }
39
- class OsmNode extends OsmElement {
40
- constructor(id, coords, tags) {
41
- super(id, tags);
42
- __publicField(this, "coords");
43
- __publicField(this, "ways", []);
44
- this.coords = coords;
30
+ class te extends $t {
31
+ constructor(e, i, n) {
32
+ super(e, n);
33
+ M(this, "coords");
34
+ M(this, "ways", []);
35
+ this.coords = i;
45
36
  }
46
37
  get isElevator() {
47
38
  return this.tags.highway === "elevator";
@@ -50,12 +41,1945 @@ class OsmNode extends OsmElement {
50
41
  return this.isElevator;
51
42
  }
52
43
  }
53
- class OsmWay extends OsmElement {
54
- constructor(id, tags, level = null) {
55
- super(id, tags);
56
- __publicField(this, "nodes", []);
57
- __publicField(this, "level", null);
58
- this.level = level;
44
+ var Ct = {}, Wt = {};
45
+ (function(s) {
46
+ /**
47
+ * Character classes and associated utilities for the 5th edition of XML 1.0.
48
+ *
49
+ * @author Louis-Dominique Dubeau
50
+ * @license MIT
51
+ * @copyright Louis-Dominique Dubeau
52
+ */
53
+ Object.defineProperty(s, "__esModule", { value: !0 }), s.CHAR = `
54
+ \r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`, s.S = ` \r
55
+ `, s.NAME_START_CHAR = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}", s.NAME_CHAR = "-" + s.NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040", s.CHAR_RE = new RegExp("^[" + s.CHAR + "]$", "u"), s.S_RE = new RegExp("^[" + s.S + "]+$", "u"), s.NAME_START_CHAR_RE = new RegExp("^[" + s.NAME_START_CHAR + "]$", "u"), s.NAME_CHAR_RE = new RegExp("^[" + s.NAME_CHAR + "]$", "u"), s.NAME_RE = new RegExp("^[" + s.NAME_START_CHAR + "][" + s.NAME_CHAR + "]*$", "u"), s.NMTOKEN_RE = new RegExp("^[" + s.NAME_CHAR + "]+$", "u");
56
+ var t = 9, e = 10, i = 13, n = 32;
57
+ s.S_LIST = [n, e, i, t];
58
+ function r(o) {
59
+ return o >= n && o <= 55295 || o === e || o === i || o === t || o >= 57344 && o <= 65533 || o >= 65536 && o <= 1114111;
60
+ }
61
+ s.isChar = r;
62
+ function a(o) {
63
+ return o === n || o === e || o === i || o === t;
64
+ }
65
+ s.isS = a;
66
+ function l(o) {
67
+ return o >= 65 && o <= 90 || o >= 97 && o <= 122 || o === 58 || o === 95 || o === 8204 || o === 8205 || o >= 192 && o <= 214 || o >= 216 && o <= 246 || o >= 248 && o <= 767 || o >= 880 && o <= 893 || o >= 895 && o <= 8191 || o >= 8304 && o <= 8591 || o >= 11264 && o <= 12271 || o >= 12289 && o <= 55295 || o >= 63744 && o <= 64975 || o >= 65008 && o <= 65533 || o >= 65536 && o <= 983039;
68
+ }
69
+ s.isNameStartChar = l;
70
+ function c(o) {
71
+ return l(o) || o >= 48 && o <= 57 || o === 45 || o === 46 || o === 183 || o >= 768 && o <= 879 || o >= 8255 && o <= 8256;
72
+ }
73
+ s.isNameChar = c;
74
+ })(Wt);
75
+ var Xt = {};
76
+ (function(s) {
77
+ /**
78
+ * Character classes and associated utilities for the 2nd edition of XML 1.1.
79
+ *
80
+ * @author Louis-Dominique Dubeau
81
+ * @license MIT
82
+ * @copyright Louis-Dominique Dubeau
83
+ */
84
+ Object.defineProperty(s, "__esModule", { value: !0 }), s.CHAR = "-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}", s.RESTRICTED_CHAR = "-\b\v\f-\x7F-\x84\x86-\x9F", s.S = ` \r
85
+ `, s.NAME_START_CHAR = ":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}", s.NAME_CHAR = "-" + s.NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040", s.CHAR_RE = new RegExp("^[" + s.CHAR + "]$", "u"), s.RESTRICTED_CHAR_RE = new RegExp("^[" + s.RESTRICTED_CHAR + "]$", "u"), s.S_RE = new RegExp("^[" + s.S + "]+$", "u"), s.NAME_START_CHAR_RE = new RegExp("^[" + s.NAME_START_CHAR + "]$", "u"), s.NAME_CHAR_RE = new RegExp("^[" + s.NAME_CHAR + "]$", "u"), s.NAME_RE = new RegExp("^[" + s.NAME_START_CHAR + "][" + s.NAME_CHAR + "]*$", "u"), s.NMTOKEN_RE = new RegExp("^[" + s.NAME_CHAR + "]+$", "u");
86
+ var t = 9, e = 10, i = 13, n = 32;
87
+ s.S_LIST = [n, e, i, t];
88
+ function r(h) {
89
+ return h >= 1 && h <= 55295 || h >= 57344 && h <= 65533 || h >= 65536 && h <= 1114111;
90
+ }
91
+ s.isChar = r;
92
+ function a(h) {
93
+ return h >= 1 && h <= 8 || h === 11 || h === 12 || h >= 14 && h <= 31 || h >= 127 && h <= 132 || h >= 134 && h <= 159;
94
+ }
95
+ s.isRestrictedChar = a;
96
+ function l(h) {
97
+ return h === 9 || h === 10 || h === 13 || h > 31 && h < 127 || h === 133 || h > 159 && h <= 55295 || h >= 57344 && h <= 65533 || h >= 65536 && h <= 1114111;
98
+ }
99
+ s.isCharAndNotRestricted = l;
100
+ function c(h) {
101
+ return h === n || h === e || h === i || h === t;
102
+ }
103
+ s.isS = c;
104
+ function o(h) {
105
+ return h >= 65 && h <= 90 || h >= 97 && h <= 122 || h === 58 || h === 95 || h === 8204 || h === 8205 || h >= 192 && h <= 214 || h >= 216 && h <= 246 || h >= 248 && h <= 767 || h >= 880 && h <= 893 || h >= 895 && h <= 8191 || h >= 8304 && h <= 8591 || h >= 11264 && h <= 12271 || h >= 12289 && h <= 55295 || h >= 63744 && h <= 64975 || h >= 65008 && h <= 65533 || h >= 65536 && h <= 983039;
106
+ }
107
+ s.isNameStartChar = o;
108
+ function u(h) {
109
+ return o(h) || h >= 48 && h <= 57 || h === 45 || h === 46 || h === 183 || h >= 768 && h <= 879 || h >= 8255 && h <= 8256;
110
+ }
111
+ s.isNameChar = u;
112
+ })(Xt);
113
+ var qt = {};
114
+ (function(s) {
115
+ /**
116
+ * Character class utilities for XML NS 1.0 edition 3.
117
+ *
118
+ * @author Louis-Dominique Dubeau
119
+ * @license MIT
120
+ * @copyright Louis-Dominique Dubeau
121
+ */
122
+ Object.defineProperty(s, "__esModule", { value: !0 }), s.NC_NAME_START_CHAR = "A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}", s.NC_NAME_CHAR = "-" + s.NC_NAME_START_CHAR + ".0-9\xB7\u0300-\u036F\u203F-\u2040", s.NC_NAME_START_CHAR_RE = new RegExp("^[" + s.NC_NAME_START_CHAR + "]$", "u"), s.NC_NAME_CHAR_RE = new RegExp("^[" + s.NC_NAME_CHAR + "]$", "u"), s.NC_NAME_RE = new RegExp("^[" + s.NC_NAME_START_CHAR + "][" + s.NC_NAME_CHAR + "]*$", "u");
123
+ function t(i) {
124
+ return i >= 65 && i <= 90 || i === 95 || i >= 97 && i <= 122 || i >= 192 && i <= 214 || i >= 216 && i <= 246 || i >= 248 && i <= 767 || i >= 880 && i <= 893 || i >= 895 && i <= 8191 || i >= 8204 && i <= 8205 || i >= 8304 && i <= 8591 || i >= 11264 && i <= 12271 || i >= 12289 && i <= 55295 || i >= 63744 && i <= 64975 || i >= 65008 && i <= 65533 || i >= 65536 && i <= 983039;
125
+ }
126
+ s.isNCNameStartChar = t;
127
+ function e(i) {
128
+ return t(i) || i === 45 || i === 46 || i >= 48 && i <= 57 || i === 183 || i >= 768 && i <= 879 || i >= 8255 && i <= 8256;
129
+ }
130
+ s.isNCNameChar = e;
131
+ })(qt);
132
+ Object.defineProperty(Ct, "__esModule", { value: !0 });
133
+ const z = Wt, ee = Xt, Tt = qt;
134
+ var v = z.isS, se = z.isChar, Q = z.isNameStartChar, bt = z.isNameChar, Vt = z.S_LIST, ie = z.NAME_RE, ne = ee.isChar, ae = Tt.isNCNameStartChar, re = Tt.isNCNameChar, oe = Tt.NC_NAME_RE;
135
+ const ot = "http://www.w3.org/XML/1998/namespace", G = "http://www.w3.org/2000/xmlns/", le = {
136
+ __proto__: null,
137
+ xml: ot,
138
+ xmlns: G
139
+ }, he = {
140
+ __proto__: null,
141
+ amp: "&",
142
+ gt: ">",
143
+ lt: "<",
144
+ quot: '"',
145
+ apos: "'"
146
+ }, E = -1, S = -2, vt = 0, ce = 1, ht = 2, ue = 3, W = 4, de = 5, fe = 6, ge = 7, ct = 8, me = 9, _e = 10, xe = 11, Ee = 12, T = 13, tt = 14, ut = 15, pe = 16, dt = 17, Ae = 18, Fe = 19, ft = 20, Ce = 21, Te = 22, Ne = 23, wt = 24, gt = 25, et = 26, Dt = 27, be = 28, ve = 29, yt = 30, we = 31, De = 32, O = 33, ye = 34, mt = 35, J = 36, _t = 37, Se = 38, St = 39, Mt = 40, Me = 41, Rt = 42, Re = 43, Ie = 44, xt = 9, y = 10, Et = 13, It = 32, kt = 33, Yt = 34, K = 38, Gt = 39, st = 45, it = 47, ke = 59, k = 60, V = 61, A = 62, F = 63, zt = 91, Y = 93, Pt = 133, Lt = 8232, nt = (s) => s === Yt || s === Gt, Ut = [Yt, Gt], Pe = [...Ut, zt, A], Le = [...Ut, k, Y], Oe = [V, F, ...Vt], Be = [...Vt, A, K, k];
147
+ function At(s, t, e) {
148
+ switch (t) {
149
+ case "xml":
150
+ e !== ot && s.fail(`xml prefix must be bound to ${ot}.`);
151
+ break;
152
+ case "xmlns":
153
+ e !== G && s.fail(`xmlns prefix must be bound to ${G}.`);
154
+ break;
155
+ }
156
+ switch (e) {
157
+ case G:
158
+ s.fail(t === "" ? `the default namespace may not be set to ${e}.` : `may not assign a prefix (even "xmlns") to the URI ${G}.`);
159
+ break;
160
+ case ot:
161
+ switch (t) {
162
+ case "xml":
163
+ break;
164
+ case "":
165
+ s.fail(`the default namespace may not be set to ${e}.`);
166
+ break;
167
+ default:
168
+ s.fail("may not assign the xml namespace to another prefix.");
169
+ }
170
+ break;
171
+ }
172
+ }
173
+ function He(s, t) {
174
+ for (const e of Object.keys(t))
175
+ At(s, e, t[e]);
176
+ }
177
+ const $e = (s) => oe.test(s), We = (s) => ie.test(s), B = 0, Ot = 1, pt = 2;
178
+ Ct.EVENTS = [
179
+ "xmldecl",
180
+ "text",
181
+ "processinginstruction",
182
+ "doctype",
183
+ "comment",
184
+ "opentagstart",
185
+ "attribute",
186
+ "opentag",
187
+ "closetag",
188
+ "cdata",
189
+ "error",
190
+ "end",
191
+ "ready"
192
+ ];
193
+ const Bt = {
194
+ xmldecl: "xmldeclHandler",
195
+ text: "textHandler",
196
+ processinginstruction: "piHandler",
197
+ doctype: "doctypeHandler",
198
+ comment: "commentHandler",
199
+ opentagstart: "openTagStartHandler",
200
+ attribute: "attributeHandler",
201
+ opentag: "openTagHandler",
202
+ closetag: "closeTagHandler",
203
+ cdata: "cdataHandler",
204
+ error: "errorHandler",
205
+ end: "endHandler",
206
+ ready: "readyHandler"
207
+ };
208
+ class Xe {
209
+ constructor(t) {
210
+ this.opt = t != null ? t : {}, this.fragmentOpt = !!this.opt.fragment;
211
+ const e = this.xmlnsOpt = !!this.opt.xmlns;
212
+ if (this.trackPosition = this.opt.position !== !1, this.fileName = this.opt.fileName, e) {
213
+ this.nameStartCheck = ae, this.nameCheck = re, this.isName = $e, this.processAttribs = this.processAttribsNS, this.pushAttrib = this.pushAttribNS, this.ns = Object.assign({ __proto__: null }, le);
214
+ const i = this.opt.additionalNamespaces;
215
+ i != null && (He(this, i), Object.assign(this.ns, i));
216
+ } else
217
+ this.nameStartCheck = Q, this.nameCheck = bt, this.isName = We, this.processAttribs = this.processAttribsPlain, this.pushAttrib = this.pushAttribPlain;
218
+ this.stateTable = [
219
+ this.sBegin,
220
+ this.sBeginWhitespace,
221
+ this.sDoctype,
222
+ this.sDoctypeQuote,
223
+ this.sDTD,
224
+ this.sDTDQuoted,
225
+ this.sDTDOpenWaka,
226
+ this.sDTDOpenWakaBang,
227
+ this.sDTDComment,
228
+ this.sDTDCommentEnding,
229
+ this.sDTDCommentEnded,
230
+ this.sDTDPI,
231
+ this.sDTDPIEnding,
232
+ this.sText,
233
+ this.sEntity,
234
+ this.sOpenWaka,
235
+ this.sOpenWakaBang,
236
+ this.sComment,
237
+ this.sCommentEnding,
238
+ this.sCommentEnded,
239
+ this.sCData,
240
+ this.sCDataEnding,
241
+ this.sCDataEnding2,
242
+ this.sPIFirstChar,
243
+ this.sPIRest,
244
+ this.sPIBody,
245
+ this.sPIEnding,
246
+ this.sXMLDeclNameStart,
247
+ this.sXMLDeclName,
248
+ this.sXMLDeclEq,
249
+ this.sXMLDeclValueStart,
250
+ this.sXMLDeclValue,
251
+ this.sXMLDeclSeparator,
252
+ this.sXMLDeclEnding,
253
+ this.sOpenTag,
254
+ this.sOpenTagSlash,
255
+ this.sAttrib,
256
+ this.sAttribName,
257
+ this.sAttribNameSawWhite,
258
+ this.sAttribValue,
259
+ this.sAttribValueQuoted,
260
+ this.sAttribValueClosed,
261
+ this.sAttribValueUnquoted,
262
+ this.sCloseTag,
263
+ this.sCloseTagSawWhite
264
+ ], this._init();
265
+ }
266
+ get closed() {
267
+ return this._closed;
268
+ }
269
+ _init() {
270
+ var t;
271
+ this.openWakaBang = "", this.text = "", this.name = "", this.piTarget = "", this.entity = "", this.q = null, this.tags = [], this.tag = null, this.topNS = null, this.chunk = "", this.chunkPosition = 0, this.i = 0, this.prevI = 0, this.carriedFromPrevious = void 0, this.forbiddenState = B, this.attribList = [];
272
+ const { fragmentOpt: e } = this;
273
+ this.state = e ? T : vt, this.reportedTextBeforeRoot = this.reportedTextAfterRoot = this.closedRoot = this.sawRoot = e, this.xmlDeclPossible = !e, this.xmlDeclExpects = ["version"], this.entityReturnState = void 0;
274
+ let { defaultXMLVersion: i } = this.opt;
275
+ if (i === void 0) {
276
+ if (this.opt.forceXMLVersion === !0)
277
+ throw new Error("forceXMLVersion set but defaultXMLVersion is not set");
278
+ i = "1.0";
279
+ }
280
+ this.setXMLVersion(i), this.positionAtNewLine = 0, this.doctype = !1, this._closed = !1, this.xmlDecl = {
281
+ version: void 0,
282
+ encoding: void 0,
283
+ standalone: void 0
284
+ }, this.line = 1, this.column = 0, this.ENTITIES = Object.create(he), (t = this.readyHandler) === null || t === void 0 || t.call(this);
285
+ }
286
+ get position() {
287
+ return this.chunkPosition + this.i;
288
+ }
289
+ get columnIndex() {
290
+ return this.position - this.positionAtNewLine;
291
+ }
292
+ on(t, e) {
293
+ this[Bt[t]] = e;
294
+ }
295
+ off(t) {
296
+ this[Bt[t]] = void 0;
297
+ }
298
+ makeError(t) {
299
+ var e;
300
+ let i = (e = this.fileName) !== null && e !== void 0 ? e : "";
301
+ return this.trackPosition && (i.length > 0 && (i += ":"), i += `${this.line}:${this.column}`), i.length > 0 && (i += ": "), new Error(i + t);
302
+ }
303
+ fail(t) {
304
+ const e = this.makeError(t), i = this.errorHandler;
305
+ if (i === void 0)
306
+ throw e;
307
+ return i(e), this;
308
+ }
309
+ write(t) {
310
+ if (this.closed)
311
+ return this.fail("cannot write after close; assign an onready handler.");
312
+ let e = !1;
313
+ t === null ? (e = !0, t = "") : typeof t == "object" && (t = t.toString()), this.carriedFromPrevious !== void 0 && (t = `${this.carriedFromPrevious}${t}`, this.carriedFromPrevious = void 0);
314
+ let i = t.length;
315
+ const n = t.charCodeAt(i - 1);
316
+ !e && (n === Et || n >= 55296 && n <= 56319) && (this.carriedFromPrevious = t[i - 1], i--, t = t.slice(0, i));
317
+ const { stateTable: r } = this;
318
+ for (this.chunk = t, this.i = 0; this.i < i; )
319
+ r[this.state].call(this);
320
+ return this.chunkPosition += i, e ? this.end() : this;
321
+ }
322
+ close() {
323
+ return this.write(null);
324
+ }
325
+ getCode10() {
326
+ const { chunk: t, i: e } = this;
327
+ if (this.prevI = e, this.i = e + 1, e >= t.length)
328
+ return E;
329
+ const i = t.charCodeAt(e);
330
+ if (this.column++, i < 55296) {
331
+ if (i >= It || i === xt)
332
+ return i;
333
+ switch (i) {
334
+ case y:
335
+ return this.line++, this.column = 0, this.positionAtNewLine = this.position, y;
336
+ case Et:
337
+ return t.charCodeAt(e + 1) === y && (this.i = e + 2), this.line++, this.column = 0, this.positionAtNewLine = this.position, S;
338
+ default:
339
+ return this.fail("disallowed character."), i;
340
+ }
341
+ }
342
+ if (i > 56319)
343
+ return i >= 57344 && i <= 65533 || this.fail("disallowed character."), i;
344
+ const n = 65536 + (i - 55296) * 1024 + (t.charCodeAt(e + 1) - 56320);
345
+ return this.i = e + 2, n > 1114111 && this.fail("disallowed character."), n;
346
+ }
347
+ getCode11() {
348
+ const { chunk: t, i: e } = this;
349
+ if (this.prevI = e, this.i = e + 1, e >= t.length)
350
+ return E;
351
+ const i = t.charCodeAt(e);
352
+ if (this.column++, i < 55296) {
353
+ if (i > 31 && i < 127 || i > 159 && i !== Lt || i === xt)
354
+ return i;
355
+ switch (i) {
356
+ case y:
357
+ return this.line++, this.column = 0, this.positionAtNewLine = this.position, y;
358
+ case Et: {
359
+ const r = t.charCodeAt(e + 1);
360
+ (r === y || r === Pt) && (this.i = e + 2);
361
+ }
362
+ case Pt:
363
+ case Lt:
364
+ return this.line++, this.column = 0, this.positionAtNewLine = this.position, S;
365
+ default:
366
+ return this.fail("disallowed character."), i;
367
+ }
368
+ }
369
+ if (i > 56319)
370
+ return i >= 57344 && i <= 65533 || this.fail("disallowed character."), i;
371
+ const n = 65536 + (i - 55296) * 1024 + (t.charCodeAt(e + 1) - 56320);
372
+ return this.i = e + 2, n > 1114111 && this.fail("disallowed character."), n;
373
+ }
374
+ getCodeNorm() {
375
+ const t = this.getCode();
376
+ return t === S ? y : t;
377
+ }
378
+ unget() {
379
+ this.i = this.prevI, this.column--;
380
+ }
381
+ captureTo(t) {
382
+ let { i: e } = this;
383
+ const { chunk: i } = this;
384
+ for (; ; ) {
385
+ const n = this.getCode(), r = n === S, a = r ? y : n;
386
+ if (a === E || t.includes(a))
387
+ return this.text += i.slice(e, this.prevI), a;
388
+ r && (this.text += `${i.slice(e, this.prevI)}
389
+ `, e = this.i);
390
+ }
391
+ }
392
+ captureToChar(t) {
393
+ let { i: e } = this;
394
+ const { chunk: i } = this;
395
+ for (; ; ) {
396
+ let n = this.getCode();
397
+ switch (n) {
398
+ case S:
399
+ this.text += `${i.slice(e, this.prevI)}
400
+ `, e = this.i, n = y;
401
+ break;
402
+ case E:
403
+ return this.text += i.slice(e), !1;
404
+ }
405
+ if (n === t)
406
+ return this.text += i.slice(e, this.prevI), !0;
407
+ }
408
+ }
409
+ captureNameChars() {
410
+ const { chunk: t, i: e } = this;
411
+ for (; ; ) {
412
+ const i = this.getCode();
413
+ if (i === E)
414
+ return this.name += t.slice(e), E;
415
+ if (!bt(i))
416
+ return this.name += t.slice(e, this.prevI), i === S ? y : i;
417
+ }
418
+ }
419
+ skipSpaces() {
420
+ for (; ; ) {
421
+ const t = this.getCodeNorm();
422
+ if (t === E || !v(t))
423
+ return t;
424
+ }
425
+ }
426
+ setXMLVersion(t) {
427
+ this.currentXMLVersion = t, t === "1.0" ? (this.isChar = se, this.getCode = this.getCode10) : (this.isChar = ne, this.getCode = this.getCode11);
428
+ }
429
+ sBegin() {
430
+ this.chunk.charCodeAt(0) === 65279 && (this.i++, this.column++), this.state = ce;
431
+ }
432
+ sBeginWhitespace() {
433
+ const t = this.i, e = this.skipSpaces();
434
+ switch (this.prevI !== t && (this.xmlDeclPossible = !1), e) {
435
+ case k:
436
+ if (this.state = ut, this.text.length !== 0)
437
+ throw new Error("no-empty text at start");
438
+ break;
439
+ case E:
440
+ break;
441
+ default:
442
+ this.unget(), this.state = T, this.xmlDeclPossible = !1;
443
+ }
444
+ }
445
+ sDoctype() {
446
+ var t;
447
+ const e = this.captureTo(Pe);
448
+ switch (e) {
449
+ case A: {
450
+ (t = this.doctypeHandler) === null || t === void 0 || t.call(this, this.text), this.text = "", this.state = T, this.doctype = !0;
451
+ break;
452
+ }
453
+ case E:
454
+ break;
455
+ default:
456
+ this.text += String.fromCodePoint(e), e === zt ? this.state = W : nt(e) && (this.state = ue, this.q = e);
457
+ }
458
+ }
459
+ sDoctypeQuote() {
460
+ const t = this.q;
461
+ this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.q = null, this.state = ht);
462
+ }
463
+ sDTD() {
464
+ const t = this.captureTo(Le);
465
+ t !== E && (this.text += String.fromCodePoint(t), t === Y ? this.state = ht : t === k ? this.state = fe : nt(t) && (this.state = de, this.q = t));
466
+ }
467
+ sDTDQuoted() {
468
+ const t = this.q;
469
+ this.captureToChar(t) && (this.text += String.fromCodePoint(t), this.state = W, this.q = null);
470
+ }
471
+ sDTDOpenWaka() {
472
+ const t = this.getCodeNorm();
473
+ switch (this.text += String.fromCodePoint(t), t) {
474
+ case kt:
475
+ this.state = ge, this.openWakaBang = "";
476
+ break;
477
+ case F:
478
+ this.state = xe;
479
+ break;
480
+ default:
481
+ this.state = W;
482
+ }
483
+ }
484
+ sDTDOpenWakaBang() {
485
+ const t = String.fromCodePoint(this.getCodeNorm()), e = this.openWakaBang += t;
486
+ this.text += t, e !== "-" && (this.state = e === "--" ? ct : W, this.openWakaBang = "");
487
+ }
488
+ sDTDComment() {
489
+ this.captureToChar(st) && (this.text += "-", this.state = me);
490
+ }
491
+ sDTDCommentEnding() {
492
+ const t = this.getCodeNorm();
493
+ this.text += String.fromCodePoint(t), this.state = t === st ? _e : ct;
494
+ }
495
+ sDTDCommentEnded() {
496
+ const t = this.getCodeNorm();
497
+ this.text += String.fromCodePoint(t), t === A ? this.state = W : (this.fail("malformed comment."), this.state = ct);
498
+ }
499
+ sDTDPI() {
500
+ this.captureToChar(F) && (this.text += "?", this.state = Ee);
501
+ }
502
+ sDTDPIEnding() {
503
+ const t = this.getCodeNorm();
504
+ this.text += String.fromCodePoint(t), t === A && (this.state = W);
505
+ }
506
+ sText() {
507
+ this.tags.length !== 0 ? this.handleTextInRoot() : this.handleTextOutsideRoot();
508
+ }
509
+ sEntity() {
510
+ let { i: t } = this;
511
+ const { chunk: e } = this;
512
+ t:
513
+ for (; ; )
514
+ switch (this.getCode()) {
515
+ case S:
516
+ this.entity += `${e.slice(t, this.prevI)}
517
+ `, t = this.i;
518
+ break;
519
+ case ke: {
520
+ const { entityReturnState: i } = this, n = this.entity + e.slice(t, this.prevI);
521
+ this.state = i;
522
+ let r;
523
+ n === "" ? (this.fail("empty entity name."), r = "&;") : (r = this.parseEntity(n), this.entity = ""), (i !== T || this.textHandler !== void 0) && (this.text += r);
524
+ break t;
525
+ }
526
+ case E:
527
+ this.entity += e.slice(t);
528
+ break t;
529
+ }
530
+ }
531
+ sOpenWaka() {
532
+ const t = this.getCode();
533
+ if (Q(t))
534
+ this.state = ye, this.unget(), this.xmlDeclPossible = !1;
535
+ else
536
+ switch (t) {
537
+ case it:
538
+ this.state = Re, this.xmlDeclPossible = !1;
539
+ break;
540
+ case kt:
541
+ this.state = pe, this.openWakaBang = "", this.xmlDeclPossible = !1;
542
+ break;
543
+ case F:
544
+ this.state = Ne;
545
+ break;
546
+ default:
547
+ this.fail("disallowed character in tag name"), this.state = T, this.xmlDeclPossible = !1;
548
+ }
549
+ }
550
+ sOpenWakaBang() {
551
+ switch (this.openWakaBang += String.fromCodePoint(this.getCodeNorm()), this.openWakaBang) {
552
+ case "[CDATA[":
553
+ !this.sawRoot && !this.reportedTextBeforeRoot && (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = !0), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = !0), this.state = ft, this.openWakaBang = "";
554
+ break;
555
+ case "--":
556
+ this.state = dt, this.openWakaBang = "";
557
+ break;
558
+ case "DOCTYPE":
559
+ this.state = ht, (this.doctype || this.sawRoot) && this.fail("inappropriately located doctype declaration."), this.openWakaBang = "";
560
+ break;
561
+ default:
562
+ this.openWakaBang.length >= 7 && this.fail("incorrect syntax.");
563
+ }
564
+ }
565
+ sComment() {
566
+ this.captureToChar(st) && (this.state = Ae);
567
+ }
568
+ sCommentEnding() {
569
+ var t;
570
+ const e = this.getCodeNorm();
571
+ e === st ? (this.state = Fe, (t = this.commentHandler) === null || t === void 0 || t.call(this, this.text), this.text = "") : (this.text += `-${String.fromCodePoint(e)}`, this.state = dt);
572
+ }
573
+ sCommentEnded() {
574
+ const t = this.getCodeNorm();
575
+ t !== A ? (this.fail("malformed comment."), this.text += `--${String.fromCodePoint(t)}`, this.state = dt) : this.state = T;
576
+ }
577
+ sCData() {
578
+ this.captureToChar(Y) && (this.state = Ce);
579
+ }
580
+ sCDataEnding() {
581
+ const t = this.getCodeNorm();
582
+ t === Y ? this.state = Te : (this.text += `]${String.fromCodePoint(t)}`, this.state = ft);
583
+ }
584
+ sCDataEnding2() {
585
+ var t;
586
+ const e = this.getCodeNorm();
587
+ switch (e) {
588
+ case A: {
589
+ (t = this.cdataHandler) === null || t === void 0 || t.call(this, this.text), this.text = "", this.state = T;
590
+ break;
591
+ }
592
+ case Y:
593
+ this.text += "]";
594
+ break;
595
+ default:
596
+ this.text += `]]${String.fromCodePoint(e)}`, this.state = ft;
597
+ }
598
+ }
599
+ sPIFirstChar() {
600
+ const t = this.getCodeNorm();
601
+ this.nameStartCheck(t) ? (this.piTarget += String.fromCodePoint(t), this.state = wt) : t === F || v(t) ? (this.fail("processing instruction without a target."), this.state = t === F ? et : gt) : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(t), this.state = wt);
602
+ }
603
+ sPIRest() {
604
+ const { chunk: t, i: e } = this;
605
+ for (; ; ) {
606
+ const i = this.getCodeNorm();
607
+ if (i === E) {
608
+ this.piTarget += t.slice(e);
609
+ return;
610
+ }
611
+ if (!this.nameCheck(i)) {
612
+ this.piTarget += t.slice(e, this.prevI);
613
+ const n = i === F;
614
+ n || v(i) ? this.piTarget === "xml" ? (this.xmlDeclPossible || this.fail("an XML declaration must be at the start of the document."), this.state = n ? O : Dt) : this.state = n ? et : gt : (this.fail("disallowed character in processing instruction name."), this.piTarget += String.fromCodePoint(i));
615
+ break;
616
+ }
617
+ }
618
+ }
619
+ sPIBody() {
620
+ if (this.text.length === 0) {
621
+ const t = this.getCodeNorm();
622
+ t === F ? this.state = et : v(t) || (this.text = String.fromCodePoint(t));
623
+ } else
624
+ this.captureToChar(F) && (this.state = et);
625
+ }
626
+ sPIEnding() {
627
+ var t;
628
+ const e = this.getCodeNorm();
629
+ if (e === A) {
630
+ const { piTarget: i } = this;
631
+ i.toLowerCase() === "xml" && this.fail("the XML declaration must appear at the start of the document."), (t = this.piHandler) === null || t === void 0 || t.call(this, {
632
+ target: i,
633
+ body: this.text
634
+ }), this.piTarget = this.text = "", this.state = T;
635
+ } else
636
+ e === F ? this.text += "?" : (this.text += `?${String.fromCodePoint(e)}`, this.state = gt);
637
+ this.xmlDeclPossible = !1;
638
+ }
639
+ sXMLDeclNameStart() {
640
+ const t = this.skipSpaces();
641
+ if (t === F) {
642
+ this.state = O;
643
+ return;
644
+ }
645
+ t !== E && (this.state = be, this.name = String.fromCodePoint(t));
646
+ }
647
+ sXMLDeclName() {
648
+ const t = this.captureTo(Oe);
649
+ if (t === F) {
650
+ this.state = O, this.name += this.text, this.text = "", this.fail("XML declaration is incomplete.");
651
+ return;
652
+ }
653
+ if (!!(v(t) || t === V)) {
654
+ if (this.name += this.text, this.text = "", !this.xmlDeclExpects.includes(this.name))
655
+ switch (this.name.length) {
656
+ case 0:
657
+ this.fail("did not expect any more name/value pairs.");
658
+ break;
659
+ case 1:
660
+ this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);
661
+ break;
662
+ default:
663
+ this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`);
664
+ }
665
+ this.state = t === V ? yt : ve;
666
+ }
667
+ }
668
+ sXMLDeclEq() {
669
+ const t = this.getCodeNorm();
670
+ if (t === F) {
671
+ this.state = O, this.fail("XML declaration is incomplete.");
672
+ return;
673
+ }
674
+ v(t) || (t !== V && this.fail("value required."), this.state = yt);
675
+ }
676
+ sXMLDeclValueStart() {
677
+ const t = this.getCodeNorm();
678
+ if (t === F) {
679
+ this.state = O, this.fail("XML declaration is incomplete.");
680
+ return;
681
+ }
682
+ v(t) || (nt(t) ? this.q = t : (this.fail("value must be quoted."), this.q = It), this.state = we);
683
+ }
684
+ sXMLDeclValue() {
685
+ const t = this.captureTo([this.q, F]);
686
+ if (t === F) {
687
+ this.state = O, this.text = "", this.fail("XML declaration is incomplete.");
688
+ return;
689
+ }
690
+ if (t === E)
691
+ return;
692
+ const e = this.text;
693
+ switch (this.text = "", this.name) {
694
+ case "version": {
695
+ this.xmlDeclExpects = ["encoding", "standalone"];
696
+ const i = e;
697
+ this.xmlDecl.version = i, /^1\.[0-9]+$/.test(i) ? this.opt.forceXMLVersion || this.setXMLVersion(i) : this.fail("version number must match /^1\\.[0-9]+$/.");
698
+ break;
699
+ }
700
+ case "encoding":
701
+ /^[A-Za-z][A-Za-z0-9._-]*$/.test(e) || this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."), this.xmlDeclExpects = ["standalone"], this.xmlDecl.encoding = e;
702
+ break;
703
+ case "standalone":
704
+ e !== "yes" && e !== "no" && this.fail('standalone value must match "yes" or "no".'), this.xmlDeclExpects = [], this.xmlDecl.standalone = e;
705
+ break;
706
+ }
707
+ this.name = "", this.state = De;
708
+ }
709
+ sXMLDeclSeparator() {
710
+ const t = this.getCodeNorm();
711
+ if (t === F) {
712
+ this.state = O;
713
+ return;
714
+ }
715
+ v(t) || (this.fail("whitespace required."), this.unget()), this.state = Dt;
716
+ }
717
+ sXMLDeclEnding() {
718
+ var t;
719
+ this.getCodeNorm() === A ? (this.piTarget !== "xml" ? this.fail("processing instructions are not allowed before root.") : this.name !== "version" && this.xmlDeclExpects.includes("version") && this.fail("XML declaration must contain a version."), (t = this.xmldeclHandler) === null || t === void 0 || t.call(this, this.xmlDecl), this.name = "", this.piTarget = this.text = "", this.state = T) : this.fail("The character ? is disallowed anywhere in XML declarations."), this.xmlDeclPossible = !1;
720
+ }
721
+ sOpenTag() {
722
+ var t;
723
+ const e = this.captureNameChars();
724
+ if (e === E)
725
+ return;
726
+ const i = this.tag = {
727
+ name: this.name,
728
+ attributes: /* @__PURE__ */ Object.create(null)
729
+ };
730
+ switch (this.name = "", this.xmlnsOpt && (this.topNS = i.ns = /* @__PURE__ */ Object.create(null)), (t = this.openTagStartHandler) === null || t === void 0 || t.call(this, i), this.sawRoot = !0, !this.fragmentOpt && this.closedRoot && this.fail("documents may contain only one root."), e) {
731
+ case A:
732
+ this.openTag();
733
+ break;
734
+ case it:
735
+ this.state = mt;
736
+ break;
737
+ default:
738
+ v(e) || this.fail("disallowed character in tag name."), this.state = J;
739
+ }
740
+ }
741
+ sOpenTagSlash() {
742
+ this.getCode() === A ? this.openSelfClosingTag() : (this.fail("forward-slash in opening tag not followed by >."), this.state = J);
743
+ }
744
+ sAttrib() {
745
+ const t = this.skipSpaces();
746
+ t !== E && (Q(t) ? (this.unget(), this.state = _t) : t === A ? this.openTag() : t === it ? this.state = mt : this.fail("disallowed character in attribute name."));
747
+ }
748
+ sAttribName() {
749
+ const t = this.captureNameChars();
750
+ t === V ? this.state = St : v(t) ? this.state = Se : t === A ? (this.fail("attribute without value."), this.pushAttrib(this.name, this.name), this.name = this.text = "", this.openTag()) : t !== E && this.fail("disallowed character in attribute name.");
751
+ }
752
+ sAttribNameSawWhite() {
753
+ const t = this.skipSpaces();
754
+ switch (t) {
755
+ case E:
756
+ return;
757
+ case V:
758
+ this.state = St;
759
+ break;
760
+ default:
761
+ this.fail("attribute without value."), this.text = "", this.name = "", t === A ? this.openTag() : Q(t) ? (this.unget(), this.state = _t) : (this.fail("disallowed character in attribute name."), this.state = J);
762
+ }
763
+ }
764
+ sAttribValue() {
765
+ const t = this.getCodeNorm();
766
+ nt(t) ? (this.q = t, this.state = Mt) : v(t) || (this.fail("unquoted attribute value."), this.state = Rt, this.unget());
767
+ }
768
+ sAttribValueQuoted() {
769
+ const { q: t, chunk: e } = this;
770
+ let { i } = this;
771
+ for (; ; )
772
+ switch (this.getCode()) {
773
+ case t:
774
+ this.pushAttrib(this.name, this.text + e.slice(i, this.prevI)), this.name = this.text = "", this.q = null, this.state = Me;
775
+ return;
776
+ case K:
777
+ this.text += e.slice(i, this.prevI), this.state = tt, this.entityReturnState = Mt;
778
+ return;
779
+ case y:
780
+ case S:
781
+ case xt:
782
+ this.text += `${e.slice(i, this.prevI)} `, i = this.i;
783
+ break;
784
+ case k:
785
+ this.text += e.slice(i, this.prevI), this.fail("disallowed character.");
786
+ return;
787
+ case E:
788
+ this.text += e.slice(i);
789
+ return;
790
+ }
791
+ }
792
+ sAttribValueClosed() {
793
+ const t = this.getCodeNorm();
794
+ v(t) ? this.state = J : t === A ? this.openTag() : t === it ? this.state = mt : Q(t) ? (this.fail("no whitespace between attributes."), this.unget(), this.state = _t) : this.fail("disallowed character in attribute name.");
795
+ }
796
+ sAttribValueUnquoted() {
797
+ const t = this.captureTo(Be);
798
+ switch (t) {
799
+ case K:
800
+ this.state = tt, this.entityReturnState = Rt;
801
+ break;
802
+ case k:
803
+ this.fail("disallowed character.");
804
+ break;
805
+ case E:
806
+ break;
807
+ default:
808
+ this.text.includes("]]>") && this.fail('the string "]]>" is disallowed in char data.'), this.pushAttrib(this.name, this.text), this.name = this.text = "", t === A ? this.openTag() : this.state = J;
809
+ }
810
+ }
811
+ sCloseTag() {
812
+ const t = this.captureNameChars();
813
+ t === A ? this.closeTag() : v(t) ? this.state = Ie : t !== E && this.fail("disallowed character in closing tag.");
814
+ }
815
+ sCloseTagSawWhite() {
816
+ switch (this.skipSpaces()) {
817
+ case A:
818
+ this.closeTag();
819
+ break;
820
+ case E:
821
+ break;
822
+ default:
823
+ this.fail("disallowed character in closing tag.");
824
+ }
825
+ }
826
+ handleTextInRoot() {
827
+ let { i: t, forbiddenState: e } = this;
828
+ const { chunk: i, textHandler: n } = this;
829
+ t:
830
+ for (; ; )
831
+ switch (this.getCode()) {
832
+ case k: {
833
+ if (this.state = ut, n !== void 0) {
834
+ const { text: r } = this, a = i.slice(t, this.prevI);
835
+ r.length !== 0 ? (n(r + a), this.text = "") : a.length !== 0 && n(a);
836
+ }
837
+ e = B;
838
+ break t;
839
+ }
840
+ case K:
841
+ this.state = tt, this.entityReturnState = T, n !== void 0 && (this.text += i.slice(t, this.prevI)), e = B;
842
+ break t;
843
+ case Y:
844
+ switch (e) {
845
+ case B:
846
+ e = Ot;
847
+ break;
848
+ case Ot:
849
+ e = pt;
850
+ break;
851
+ case pt:
852
+ break;
853
+ default:
854
+ throw new Error("impossible state");
855
+ }
856
+ break;
857
+ case A:
858
+ e === pt && this.fail('the string "]]>" is disallowed in char data.'), e = B;
859
+ break;
860
+ case S:
861
+ n !== void 0 && (this.text += `${i.slice(t, this.prevI)}
862
+ `), t = this.i, e = B;
863
+ break;
864
+ case E:
865
+ n !== void 0 && (this.text += i.slice(t));
866
+ break t;
867
+ default:
868
+ e = B;
869
+ }
870
+ this.forbiddenState = e;
871
+ }
872
+ handleTextOutsideRoot() {
873
+ let { i: t } = this;
874
+ const { chunk: e, textHandler: i } = this;
875
+ let n = !1;
876
+ t:
877
+ for (; ; ) {
878
+ const r = this.getCode();
879
+ switch (r) {
880
+ case k: {
881
+ if (this.state = ut, i !== void 0) {
882
+ const { text: a } = this, l = e.slice(t, this.prevI);
883
+ a.length !== 0 ? (i(a + l), this.text = "") : l.length !== 0 && i(l);
884
+ }
885
+ break t;
886
+ }
887
+ case K:
888
+ this.state = tt, this.entityReturnState = T, i !== void 0 && (this.text += e.slice(t, this.prevI)), n = !0;
889
+ break t;
890
+ case S:
891
+ i !== void 0 && (this.text += `${e.slice(t, this.prevI)}
892
+ `), t = this.i;
893
+ break;
894
+ case E:
895
+ i !== void 0 && (this.text += e.slice(t));
896
+ break t;
897
+ default:
898
+ v(r) || (n = !0);
899
+ }
900
+ }
901
+ !n || (!this.sawRoot && !this.reportedTextBeforeRoot && (this.fail("text data outside of root node."), this.reportedTextBeforeRoot = !0), this.closedRoot && !this.reportedTextAfterRoot && (this.fail("text data outside of root node."), this.reportedTextAfterRoot = !0));
902
+ }
903
+ pushAttribNS(t, e) {
904
+ var i;
905
+ const { prefix: n, local: r } = this.qname(t), a = { name: t, prefix: n, local: r, value: e };
906
+ if (this.attribList.push(a), (i = this.attributeHandler) === null || i === void 0 || i.call(this, a), n === "xmlns") {
907
+ const l = e.trim();
908
+ this.currentXMLVersion === "1.0" && l === "" && this.fail("invalid attempt to undefine prefix in XML 1.0"), this.topNS[r] = l, At(this, r, l);
909
+ } else if (t === "xmlns") {
910
+ const l = e.trim();
911
+ this.topNS[""] = l, At(this, "", l);
912
+ }
913
+ }
914
+ pushAttribPlain(t, e) {
915
+ var i;
916
+ const n = { name: t, value: e };
917
+ this.attribList.push(n), (i = this.attributeHandler) === null || i === void 0 || i.call(this, n);
918
+ }
919
+ end() {
920
+ var t, e;
921
+ this.sawRoot || this.fail("document must contain a root element.");
922
+ const { tags: i } = this;
923
+ for (; i.length > 0; ) {
924
+ const r = i.pop();
925
+ this.fail(`unclosed tag: ${r.name}`);
926
+ }
927
+ this.state !== vt && this.state !== T && this.fail("unexpected end.");
928
+ const { text: n } = this;
929
+ return n.length !== 0 && ((t = this.textHandler) === null || t === void 0 || t.call(this, n), this.text = ""), this._closed = !0, (e = this.endHandler) === null || e === void 0 || e.call(this), this._init(), this;
930
+ }
931
+ resolve(t) {
932
+ var e, i;
933
+ let n = this.topNS[t];
934
+ if (n !== void 0)
935
+ return n;
936
+ const { tags: r } = this;
937
+ for (let a = r.length - 1; a >= 0; a--)
938
+ if (n = r[a].ns[t], n !== void 0)
939
+ return n;
940
+ return n = this.ns[t], n !== void 0 ? n : (i = (e = this.opt).resolvePrefix) === null || i === void 0 ? void 0 : i.call(e, t);
941
+ }
942
+ qname(t) {
943
+ const e = t.indexOf(":");
944
+ if (e === -1)
945
+ return { prefix: "", local: t };
946
+ const i = t.slice(e + 1), n = t.slice(0, e);
947
+ return (n === "" || i === "" || i.includes(":")) && this.fail(`malformed name: ${t}.`), { prefix: n, local: i };
948
+ }
949
+ processAttribsNS() {
950
+ var t;
951
+ const { attribList: e } = this, i = this.tag;
952
+ {
953
+ const { prefix: a, local: l } = this.qname(i.name);
954
+ i.prefix = a, i.local = l;
955
+ const c = i.uri = (t = this.resolve(a)) !== null && t !== void 0 ? t : "";
956
+ a !== "" && (a === "xmlns" && this.fail('tags may not have "xmlns" as prefix.'), c === "" && (this.fail(`unbound namespace prefix: ${JSON.stringify(a)}.`), i.uri = a));
957
+ }
958
+ if (e.length === 0)
959
+ return;
960
+ const { attributes: n } = i, r = /* @__PURE__ */ new Set();
961
+ for (const a of e) {
962
+ const { name: l, prefix: c, local: o } = a;
963
+ let u, h;
964
+ c === "" ? (u = l === "xmlns" ? G : "", h = l) : (u = this.resolve(c), u === void 0 && (this.fail(`unbound namespace prefix: ${JSON.stringify(c)}.`), u = c), h = `{${u}}${o}`), r.has(h) && this.fail(`duplicate attribute: ${h}.`), r.add(h), a.uri = u, n[l] = a;
965
+ }
966
+ this.attribList = [];
967
+ }
968
+ processAttribsPlain() {
969
+ const { attribList: t } = this, e = this.tag.attributes;
970
+ for (const { name: i, value: n } of t)
971
+ e[i] !== void 0 && this.fail(`duplicate attribute: ${i}.`), e[i] = n;
972
+ this.attribList = [];
973
+ }
974
+ openTag() {
975
+ var t;
976
+ this.processAttribs();
977
+ const { tags: e } = this, i = this.tag;
978
+ i.isSelfClosing = !1, (t = this.openTagHandler) === null || t === void 0 || t.call(this, i), e.push(i), this.state = T, this.name = "";
979
+ }
980
+ openSelfClosingTag() {
981
+ var t, e, i;
982
+ this.processAttribs();
983
+ const { tags: n } = this, r = this.tag;
984
+ r.isSelfClosing = !0, (t = this.openTagHandler) === null || t === void 0 || t.call(this, r), (e = this.closeTagHandler) === null || e === void 0 || e.call(this, r), (this.tag = (i = n[n.length - 1]) !== null && i !== void 0 ? i : null) === null && (this.closedRoot = !0), this.state = T, this.name = "";
985
+ }
986
+ closeTag() {
987
+ const { tags: t, name: e } = this;
988
+ if (this.state = T, this.name = "", e === "") {
989
+ this.fail("weird empty close tag."), this.text += "</>";
990
+ return;
991
+ }
992
+ const i = this.closeTagHandler;
993
+ let n = t.length;
994
+ for (; n-- > 0; ) {
995
+ const r = this.tag = t.pop();
996
+ if (this.topNS = r.ns, i == null || i(r), r.name === e)
997
+ break;
998
+ this.fail("unexpected close tag.");
999
+ }
1000
+ n === 0 ? this.closedRoot = !0 : n < 0 && (this.fail(`unmatched closing tag: ${e}.`), this.text += `</${e}>`);
1001
+ }
1002
+ parseEntity(t) {
1003
+ if (t[0] !== "#") {
1004
+ const i = this.ENTITIES[t];
1005
+ return i !== void 0 ? i : (this.fail(this.isName(t) ? "undefined entity." : "disallowed character in entity name."), `&${t};`);
1006
+ }
1007
+ let e = NaN;
1008
+ return t[1] === "x" && /^#x[0-9a-f]+$/i.test(t) ? e = parseInt(t.slice(2), 16) : /^#[0-9]+$/.test(t) && (e = parseInt(t.slice(1), 10)), this.isChar(e) ? String.fromCodePoint(e) : (this.fail("malformed character entity."), `&${t};`);
1009
+ }
1010
+ }
1011
+ var qe = Ct.SaxesParser = Xe, Ve = Object.defineProperty, Ye = (s, t, e) => t in s ? Ve(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, d = (s, t, e) => (Ye(s, typeof t != "symbol" ? t + "" : t, e), e);
1012
+ const Ft = 1e-8, L = 1e-3;
1013
+ var Ge = Object.defineProperty, ze = (s, t, e) => t in s ? Ge(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, R = (s, t, e) => (ze(s, typeof t != "symbol" ? t + "" : t, e), e);
1014
+ class Ue {
1015
+ static concat(t, e) {
1016
+ return t.concat(e);
1017
+ }
1018
+ }
1019
+ class m extends Ue {
1020
+ static norm(t) {
1021
+ return Math.sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]);
1022
+ }
1023
+ static normalize(t) {
1024
+ const e = this.norm(t), i = new Array(3);
1025
+ for (let n = 0; n < 3; n++)
1026
+ i[n] = t[n] / e;
1027
+ return i;
1028
+ }
1029
+ static sum(t, e) {
1030
+ return [t[0] + e[0], t[1] + e[1], t[2] + e[2]];
1031
+ }
1032
+ static subtract(t, e) {
1033
+ return [t[0] - e[0], t[1] - e[1], t[2] - e[2]];
1034
+ }
1035
+ static distance(t, e) {
1036
+ return m.norm(m.subtract(t, e));
1037
+ }
1038
+ static cross(t, e) {
1039
+ return [
1040
+ t[1] * e[2] - t[2] * e[1],
1041
+ t[2] * e[0] - t[0] * e[2],
1042
+ t[0] * e[1] - t[1] * e[0]
1043
+ ];
1044
+ }
1045
+ static dot(t, e) {
1046
+ return t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
1047
+ }
1048
+ static multiplyScalar(t, e) {
1049
+ const i = new Array(3);
1050
+ for (let n = 0; n < 3; n++)
1051
+ i[n] = t[n] * e;
1052
+ return i;
1053
+ }
1054
+ }
1055
+ const C = class {
1056
+ static get identity() {
1057
+ return [1, 0, 0, 0];
1058
+ }
1059
+ static sum(s, t) {
1060
+ return [s[0] + t[0], s[1] + t[1], s[2] + t[2], s[3] + t[3]];
1061
+ }
1062
+ static rotateMatlab(s, t) {
1063
+ const [e, i, n, r] = s, [a, l, c] = t;
1064
+ return [
1065
+ e * (e * a - n * c + r * l) - n * (e * c - i * l + n * a) + i * (i * a + n * l + r * c) + r * (e * l + i * c - r * a),
1066
+ e * (e * l + i * c - r * a) + i * (e * c - i * l + n * a) + n * (i * a + n * l + r * c) - r * (e * a - n * c + r * l),
1067
+ e * (e * c - i * l + n * a) - i * (e * l + i * c - r * a) + n * (e * a - n * c + r * l) + r * (i * a + n * l + r * c)
1068
+ ];
1069
+ }
1070
+ static rotate(s, t) {
1071
+ const [e, i, n, r] = s, a = [i, n, r];
1072
+ let l = m.cross(a, t);
1073
+ l = m.sum(l, l);
1074
+ const c = m.sum(t, m.multiplyScalar(l, e));
1075
+ return m.sum(c, m.cross(a, l));
1076
+ }
1077
+ static inverse(s) {
1078
+ return [-s[0], s[1], s[2], s[3]];
1079
+ }
1080
+ static multiply(...s) {
1081
+ if (s.length === 2) {
1082
+ const [t, e, i, n] = s[0], [r, a, l, c] = s[1];
1083
+ return [
1084
+ t * r - e * a - i * l - n * c,
1085
+ t * a + r * e + i * c - n * l,
1086
+ t * l + r * i + n * a - e * c,
1087
+ t * c + r * n + e * l - i * a
1088
+ ];
1089
+ }
1090
+ return s.reduce((t, e) => this.multiply(t, e), C.identity);
1091
+ }
1092
+ static fromAxisAngle(s, t) {
1093
+ const e = Math.sin(t / 2);
1094
+ return [Math.cos(t / 2), s[0] * e, s[1] * e, s[2] * e];
1095
+ }
1096
+ static rotX(s) {
1097
+ return this.fromAxisAngle([1, 0, 0], s);
1098
+ }
1099
+ static rotY(s) {
1100
+ return this.fromAxisAngle([0, 1, 0], s);
1101
+ }
1102
+ static rotZ(s) {
1103
+ return this.fromAxisAngle([0, 0, 1], s);
1104
+ }
1105
+ static fromMatrix3(s) {
1106
+ const t = Math.sqrt(1 + s[0][0] + s[1][1] + s[2][2]) / 2, e = (s[2][1] - s[1][2]) / (4 * t), i = (s[0][2] - s[2][0]) / (4 * t), n = (s[1][0] - s[0][1]) / (4 * t);
1107
+ return [t, e, i, n];
1108
+ }
1109
+ static fromMatrix3Matlab(s) {
1110
+ const t = Math.sqrt(1 + s[0][0] + s[1][1] + s[2][2]) / 2, e = (s[1][2] - s[2][1]) / (4 * t), i = (s[2][0] - s[0][2]) / (4 * t), n = (s[0][1] - s[1][0]) / (4 * t);
1111
+ return [t, e, i, n];
1112
+ }
1113
+ static toMatrix3(s) {
1114
+ const [t, e, i, n] = s, r = t * e, a = t * i, l = t * n, c = e * e, o = e * i, u = e * n, h = i * i, x = i * n, _ = n * n;
1115
+ return [
1116
+ [1 - 2 * (h + _), 2 * (o - l), 2 * (u + a)],
1117
+ [2 * (o + l), 1 - 2 * (c + _), 2 * (x - r)],
1118
+ [2 * (u - a), 2 * (x + r), 1 - 2 * (c + h)]
1119
+ ];
1120
+ }
1121
+ static wxyz2xyzw(s) {
1122
+ return [s[1], s[2], s[3], s[0]];
1123
+ }
1124
+ static xyzw2wxyz(s) {
1125
+ return [s[3], s[0], s[1], s[2]];
1126
+ }
1127
+ static distance(s, t) {
1128
+ return Math.acos(Math.min(2 * C.dot(s, t) ** 2 - 1, 1));
1129
+ }
1130
+ static equals(s, t) {
1131
+ return C.distance(s, t) < 1e-8;
1132
+ }
1133
+ static normalize(s) {
1134
+ const t = this.norm(s), e = new Array(4);
1135
+ for (let i = 0; i < 4; i++)
1136
+ e[i] = s[i] / t;
1137
+ return e;
1138
+ }
1139
+ static norm(s) {
1140
+ return Math.sqrt(s[0] ** 2 + s[1] ** 2 + s[2] ** 2 + s[3] ** 2);
1141
+ }
1142
+ static dot(s, t) {
1143
+ return s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3];
1144
+ }
1145
+ static getRotationBetweenTwoVectors(s, t) {
1146
+ const e = m.normalize(s), i = m.normalize(t), n = m.dot(e, i);
1147
+ let r;
1148
+ if (n < -0.999999)
1149
+ return r = m.cross([1, 0, 0], e), m.norm(r) < 1e-6 && (r = m.cross([0, 1, 0], e)), r = m.normalize(r), C.fromAxisAngle(r, Math.PI);
1150
+ if (n > 0.999999)
1151
+ return C.identity;
1152
+ r = m.cross(e, i);
1153
+ const a = [1 + n, r[0], r[1], r[2]];
1154
+ return C.normalize(a);
1155
+ }
1156
+ static slerp(s, t, e) {
1157
+ const i = s[1], n = s[2], r = s[3], a = s[0];
1158
+ let l = t[1], c = t[2], o = t[3], u = t[0], h, x, _;
1159
+ h = i * l + n * c + r * o + a * u, h < 0 && (h = -h, u = -u, l = -l, c = -c, o = -o);
1160
+ const I = 1 - h < 1e-6;
1161
+ if (I)
1162
+ x = 1 - e, _ = e;
1163
+ else {
1164
+ const j = Math.acos(h), Nt = Math.sin(j);
1165
+ x = Math.sin((1 - e) * j) / Nt, _ = Math.sin(e * j) / Nt;
1166
+ }
1167
+ let U = [
1168
+ x * a + _ * u,
1169
+ x * i + _ * l,
1170
+ x * n + _ * c,
1171
+ x * r + _ * o
1172
+ ];
1173
+ return I && (U = C.normalize(U)), U;
1174
+ }
1175
+ static toString(s) {
1176
+ return `[${s[0].toFixed(2)}, ${s[1].toFixed(2)}, ${s[2].toFixed(2)}, ${s[3].toFixed(2)}]`;
1177
+ }
1178
+ };
1179
+ let b = C;
1180
+ R(b, "ROTX_PI2", C.rotX(Math.PI / 2)), R(b, "ROTX_PI", C.rotX(Math.PI)), R(b, "ROTX_MPI2", C.rotX(-Math.PI / 2)), R(b, "ROTY_PI2", C.rotY(Math.PI / 2)), R(b, "ROTY_PI", C.rotY(Math.PI)), R(b, "ROTY_MPI2", C.rotY(-Math.PI / 2)), R(b, "ROTZ_PI2", C.rotZ(Math.PI / 2)), R(b, "ROTZ_PI", C.rotZ(Math.PI)), R(b, "ROTZ_MPI2", C.rotZ(-Math.PI / 2));
1181
+ function N(s) {
1182
+ return s * (Math.PI / 180);
1183
+ }
1184
+ function at(s) {
1185
+ return s * 180 / Math.PI;
1186
+ }
1187
+ function je(s, t) {
1188
+ return Math.atan2(Math.sin(s - t), Math.cos(s - t));
1189
+ }
1190
+ function Qe(s, t) {
1191
+ let e = Math.abs(je(s, t));
1192
+ return e > Math.PI / 2 && (e = Math.PI - e), e;
1193
+ }
1194
+ function Je(s, t, e) {
1195
+ const i = e - t, n = ((s - t) % i + i) % i + t;
1196
+ return n === t ? e : n;
1197
+ }
1198
+ const w = class {
1199
+ static checkType(s) {
1200
+ if (s !== null && !(typeof s == "number" && !isNaN(s))) {
1201
+ if (Array.isArray(s) && s.length === 2) {
1202
+ const [t, e] = s;
1203
+ if (typeof t == "number" && !isNaN(t) && typeof e == "number" && !isNaN(e)) {
1204
+ if (t > e || t === e)
1205
+ throw Error(`Invalid level range: [${t}, ${e}]`);
1206
+ return;
1207
+ }
1208
+ }
1209
+ throw Error(`Unknown level format: ${s}`);
1210
+ }
1211
+ }
1212
+ static isRange(s) {
1213
+ return w.VERIFY_TYPING && this.checkType(s), Array.isArray(s);
1214
+ }
1215
+ static clone(s) {
1216
+ return w.VERIFY_TYPING && this.checkType(s), s === null ? null : typeof s == "number" ? s : [s[0], s[1]];
1217
+ }
1218
+ static fromString(s) {
1219
+ if (s === null)
1220
+ return null;
1221
+ if (typeof s != "string")
1222
+ throw Error(`argument must be a string, got ${typeof s}`);
1223
+ if (!isNaN(Number(s)))
1224
+ return parseFloat(s);
1225
+ const t = s.split(";");
1226
+ if (t.length === 2) {
1227
+ const e = Number(t[0]), i = Number(t[1]);
1228
+ return this.checkType([e, i]), [parseFloat(t[0]), parseFloat(t[1])];
1229
+ }
1230
+ throw Error(`Cannot parse following level: ${s}`);
1231
+ }
1232
+ static contains(s, t) {
1233
+ return w.VERIFY_TYPING && (this.checkType(s), this.checkType(t)), s === t ? !0 : Array.isArray(s) ? Array.isArray(t) ? s[0] <= t[0] && s[1] >= t[1] : t === null ? !1 : s[0] <= t && s[1] >= t : s === null || t === null ? !1 : s <= t[0] && s >= t[1];
1234
+ }
1235
+ static intersection(s, t) {
1236
+ if (w.VERIFY_TYPING && (this.checkType(s), this.checkType(t)), s === null || t === null)
1237
+ return null;
1238
+ if (this.equals(s, t))
1239
+ return this.clone(s);
1240
+ if (typeof s == "number" && typeof t == "number")
1241
+ return s === t ? s : null;
1242
+ if (Array.isArray(s) && !Array.isArray(t))
1243
+ return this.contains(s, t) ? t : null;
1244
+ if (!Array.isArray(s) && Array.isArray(t))
1245
+ return this.contains(t, s) ? s : null;
1246
+ const e = Math.max(s[0], t[0]), i = Math.min(s[1], t[1]);
1247
+ return i === e ? i : i < e ? null : [e, i];
1248
+ }
1249
+ static intersect(s, t) {
1250
+ return w.VERIFY_TYPING && (this.checkType(s), this.checkType(t)), s === null && t === null ? !0 : this.intersection(s, t) !== null;
1251
+ }
1252
+ static union(s, t) {
1253
+ if (w.VERIFY_TYPING && (this.checkType(s), this.checkType(t)), s === t)
1254
+ return this.clone(s);
1255
+ if (t === null)
1256
+ return this.clone(s);
1257
+ if (s === null)
1258
+ return this.clone(t);
1259
+ let e, i;
1260
+ return !Array.isArray(s) && !Array.isArray(t) ? (e = Math.min(s, t), i = Math.max(s, t)) : Array.isArray(s) && !Array.isArray(t) ? (e = Math.min(s[0], t), i = Math.max(s[1], t)) : !Array.isArray(s) && Array.isArray(t) ? (e = Math.min(t[0], s), i = Math.max(t[1], s)) : (e = Math.min(s[0], t[0]), i = Math.max(s[1], t[1])), e === i ? e : [e, i];
1261
+ }
1262
+ static multiplyBy(s, t) {
1263
+ return w.VERIFY_TYPING && this.checkType(s), s === null ? null : Array.isArray(s) ? [s[0] * t, s[1] * t] : s * t;
1264
+ }
1265
+ static toString(s) {
1266
+ return w.VERIFY_TYPING && this.checkType(s), s === null ? null : Array.isArray(s) ? s[0] + ";" + s[1] : String(s);
1267
+ }
1268
+ static equals(s, t) {
1269
+ return w.VERIFY_TYPING && (this.checkType(s), this.checkType(t)), s === t ? !0 : Array.isArray(s) && Array.isArray(t) ? s[0] === t[0] && s[1] === t[1] : !1;
1270
+ }
1271
+ static diff(s, t) {
1272
+ return w.VERIFY_TYPING && (this.checkType(s), this.checkType(t)), s === null || t === null ? null : !Array.isArray(s) && !Array.isArray(t) ? t - s : Array.isArray(s) && !Array.isArray(t) ? s[0] === t ? t - s[1] : s[1] === t ? t - s[0] : null : Array.isArray(t) && !Array.isArray(s) ? s === t[0] ? t[1] - s : s === t[1] ? t[0] - s : null : w.equals(s, t) ? 0 : null;
1273
+ }
1274
+ };
1275
+ let f = w;
1276
+ d(f, "VERIFY_TYPING", !1);
1277
+ class g {
1278
+ constructor(t, e, i = null, n = null) {
1279
+ d(this, "_lat"), d(this, "_lng"), d(this, "_alt", null), d(this, "_level", null), d(this, "_ecef"), d(this, "autoWrap", !0), this.lat = t, this.lng = e, this.alt = i, this.level = n, this._ecef = null;
1280
+ }
1281
+ get lat() {
1282
+ return this._lat;
1283
+ }
1284
+ set lat(t) {
1285
+ if (Math.abs(t) <= 90)
1286
+ this._lat = t;
1287
+ else
1288
+ throw new Error("lat argument is not in [-90; 90]");
1289
+ this._ecef = null;
1290
+ }
1291
+ get latitude() {
1292
+ return this._lat;
1293
+ }
1294
+ set latitude(t) {
1295
+ throw new Error("Please use Coordinates#lat setter instead of Coordinate#latitude");
1296
+ }
1297
+ get lng() {
1298
+ return this._lng;
1299
+ }
1300
+ set lng(t) {
1301
+ this._lng = t, this.autoWrap && this.wrap(), this._ecef = null;
1302
+ }
1303
+ get longitude() {
1304
+ return this._lng;
1305
+ }
1306
+ set longitude(t) {
1307
+ throw new Error("Please use Coordinates#lng setter instead of Coordinate#longitude");
1308
+ }
1309
+ get alt() {
1310
+ return this._alt;
1311
+ }
1312
+ set alt(t) {
1313
+ this._alt = t, this._ecef = null;
1314
+ }
1315
+ get level() {
1316
+ return this._level;
1317
+ }
1318
+ set level(t) {
1319
+ f.checkType(t), this._level = t;
1320
+ }
1321
+ clone() {
1322
+ const t = new g(this.lat, this.lng, this.alt);
1323
+ return this.level !== null && (t.level = f.clone(this.level)), t;
1324
+ }
1325
+ wrap() {
1326
+ (this._lng <= -180 || this._lng > 180) && (this._lng = Je(this._lng, -180, 180));
1327
+ }
1328
+ static equals(t, e, i = Ft, n = L) {
1329
+ return t === null && t === e ? !0 : !(t instanceof g) || !(e instanceof g) ? !1 : Math.abs(e.lat - t.lat) < i && Math.abs(e.lng - t.lng) < i && (t.alt === e.alt || t.alt !== null && e.alt !== null && Math.abs(e.alt - t.alt) < n) && f.equals(t.level, e.level);
1330
+ }
1331
+ equals(t) {
1332
+ return g.equals(this, t);
1333
+ }
1334
+ destinationPoint(t, e, i = null) {
1335
+ const n = this.clone();
1336
+ return n.move(t, e, i), n;
1337
+ }
1338
+ move(t, e, i = null) {
1339
+ const n = t / 6378137, r = Math.cos(n), a = Math.sin(n), l = N(this.lat), c = N(this.lng), o = Math.asin(
1340
+ Math.sin(l) * r + Math.cos(l) * a * Math.cos(e)
1341
+ ), u = c + Math.atan2(
1342
+ Math.sin(e) * a * Math.cos(l),
1343
+ r - Math.sin(l) * Math.sin(o)
1344
+ );
1345
+ if (this.lat = at(o), this.lng = at(u), i !== null) {
1346
+ if (this.alt === null)
1347
+ throw new Error("Point altitude is not defined");
1348
+ this.alt += i;
1349
+ }
1350
+ return this;
1351
+ }
1352
+ distanceTo(t) {
1353
+ const e = this.lat, i = this.lng, n = t.lat, r = t.lng, a = N(n - e), l = N(r - i), c = Math.sin(l / 2), o = Math.sin(a / 2), u = N(e), h = Math.cos(u), x = N(n), _ = Math.cos(x), I = o * o + h * _ * c * c, U = Math.sqrt(I), j = Math.sqrt(1 - I);
1354
+ return 6378137 * (2 * Math.atan2(U, j));
1355
+ }
1356
+ static distanceBetween(t, e) {
1357
+ return t.distanceTo(e);
1358
+ }
1359
+ bearingTo(t) {
1360
+ const e = N(this.lat), i = N(t.lat), n = N(t.lng - this.lng);
1361
+ return Math.atan2(
1362
+ Math.sin(n) * Math.cos(i),
1363
+ Math.cos(e) * Math.sin(i) - Math.sin(e) * Math.cos(i) * Math.cos(n)
1364
+ );
1365
+ }
1366
+ static bearingTo(t, e) {
1367
+ return t.bearingTo(e);
1368
+ }
1369
+ get enuToEcefRotation() {
1370
+ const t = b.fromAxisAngle([0, 0, 1], Math.PI / 2 + N(this.lng)), e = b.fromAxisAngle([1, 0, 0], Math.PI / 2 - N(this.lat));
1371
+ return b.multiply(t, e);
1372
+ }
1373
+ get ecefToEnuRotation() {
1374
+ const t = b.fromAxisAngle([1, 0, 0], N(this.lat) - Math.PI / 2), e = b.fromAxisAngle([0, 0, 1], -N(this.lng) - Math.PI / 2);
1375
+ return b.multiply(t, e);
1376
+ }
1377
+ get ecef() {
1378
+ if (!this._ecef) {
1379
+ const t = N(this.lat), e = N(this.lng), i = this.alt || 0, n = (6378137 + i) * Math.cos(t) * Math.cos(e), r = (6378137 + i) * Math.cos(t) * Math.sin(e), a = (6378137 + i) * Math.sin(t);
1380
+ this._ecef = [n, r, a];
1381
+ }
1382
+ return this._ecef;
1383
+ }
1384
+ static fromECEF(t) {
1385
+ const e = t[0], i = t[1], n = t[2], r = Math.sqrt(e ** 2 + i ** 2);
1386
+ let a = Math.atan2(i, e);
1387
+ const l = Math.atan2(n, r), c = r / Math.cos(l) - 6378137;
1388
+ a = a % (2 * Math.PI);
1389
+ const o = new g(at(l), at(a), c);
1390
+ return o._ecef = t, o;
1391
+ }
1392
+ getSegmentProjection(t, e) {
1393
+ const i = m.normalize(t.ecef), n = m.normalize(e.ecef), r = m.normalize(this.ecef), a = m.cross(i, n);
1394
+ if (m.norm(a) === 0)
1395
+ return null;
1396
+ const l = m.cross(r, a), c = m.normalize(m.cross(a, l)), o = m.multiplyScalar(c, 6378137), u = g.fromECEF(o);
1397
+ let h;
1398
+ t.alt !== null && e.alt !== null && (h = (t.alt + e.alt) / 2);
1399
+ const x = new g(
1400
+ u.lat,
1401
+ u.lng,
1402
+ h,
1403
+ f.intersection(t.level, e.level)
1404
+ );
1405
+ return Math.abs(t.distanceTo(e) - t.distanceTo(x) - e.distanceTo(x)) > L ? null : x;
1406
+ }
1407
+ toString() {
1408
+ let t = "[" + this._lat.toFixed(7) + ", " + this._lng.toFixed(7);
1409
+ return this._alt !== null && (t += ", " + this._alt.toFixed(2)), this._level !== null && (t += ", [" + f.toString(this._level) + "]"), t += "]", t;
1410
+ }
1411
+ toJson() {
1412
+ return {
1413
+ lat: this.lat,
1414
+ lng: this.lng,
1415
+ ...this.alt !== null && { alt: this.alt },
1416
+ ...this.level !== null && { level: this.level }
1417
+ };
1418
+ }
1419
+ static fromJson(t) {
1420
+ return new g(t.lat, t.lng, t.alt, t.level);
1421
+ }
1422
+ toCompressedJson() {
1423
+ return this.level !== null ? [this.lat, this.lng, this.alt, this.level] : this.alt !== null ? [this.lat, this.lng, this.alt] : [this.lat, this.lng];
1424
+ }
1425
+ static fromCompressedJson(t) {
1426
+ const e = new g(t[0], t[1]);
1427
+ return t.length > 2 && (e.alt = t[2]), t.length > 3 && (e.level = t[3]), e;
1428
+ }
1429
+ }
1430
+ class P extends g {
1431
+ constructor(t, e, i = null, n = null, r = null, a = null, l = null) {
1432
+ super(t, e, i, n), d(this, "_time", null), d(this, "_accuracy", null), d(this, "_bearing", null), this.time = r, this.accuracy = a, this.bearing = l;
1433
+ }
1434
+ get time() {
1435
+ return this._time;
1436
+ }
1437
+ set time(t) {
1438
+ this._time = t;
1439
+ }
1440
+ get accuracy() {
1441
+ return this._accuracy;
1442
+ }
1443
+ set accuracy(t) {
1444
+ if (t !== null && t < 0)
1445
+ throw new Error("accuracy argument is not a positive number");
1446
+ this._accuracy = t;
1447
+ }
1448
+ get bearing() {
1449
+ return this._bearing;
1450
+ }
1451
+ set bearing(t) {
1452
+ this._bearing = t !== null ? t % (2 * Math.PI) : null;
1453
+ }
1454
+ move(t, e, i = null) {
1455
+ return super.move(t, e, i), this;
1456
+ }
1457
+ destinationPoint(t, e, i = null) {
1458
+ const n = this.clone();
1459
+ return n.move(t, e, i), n;
1460
+ }
1461
+ static fromCoordinates(t) {
1462
+ return new P(
1463
+ t.lat,
1464
+ t.lng,
1465
+ t.alt,
1466
+ t.level
1467
+ );
1468
+ }
1469
+ clone() {
1470
+ const t = P.fromCoordinates(super.clone());
1471
+ return t.time = this.time, t.accuracy = this.accuracy, t.bearing = this.bearing, t;
1472
+ }
1473
+ static equals(t, e, i = Ft, n = L) {
1474
+ return t === null && t === e ? !0 : !(t instanceof P) || !(e instanceof P) || !super.equals(t, e, i, n) ? !1 : t.time === e.time && t.accuracy === e.accuracy && t.bearing === e.bearing;
1475
+ }
1476
+ equals(t, e = Ft, i = L) {
1477
+ return P.equals(this, t, e, i);
1478
+ }
1479
+ toJson() {
1480
+ return {
1481
+ ...super.toJson(),
1482
+ ...this.time !== null && { time: this.time },
1483
+ ...this.accuracy !== null && { accuracy: this.accuracy },
1484
+ ...this.bearing !== null && { bearing: this.bearing }
1485
+ };
1486
+ }
1487
+ static fromJson(t) {
1488
+ const e = P.fromCoordinates(g.fromJson(t));
1489
+ return typeof t.time < "u" && (e.time = t.time), typeof t.accuracy < "u" && (e.accuracy = t.accuracy), typeof t.bearing < "u" && (e.bearing = t.bearing), e;
1490
+ }
1491
+ }
1492
+ class Z {
1493
+ constructor(t, e) {
1494
+ if (d(this, "northEast"), d(this, "southWest"), this.northEast = t, this.southWest = e, this.northEast && this.southWest && this.getNorth() < this.getSouth())
1495
+ throw new Error("Incorrect bounding box");
1496
+ }
1497
+ get center() {
1498
+ const t = (this.southWest.lat + this.northEast.lat) / 2, e = (this.northEast.lng + this.southWest.lng) / 2;
1499
+ return new g(t, e);
1500
+ }
1501
+ contains(t) {
1502
+ return t.lat <= this.northEast.lat && t.lat >= this.southWest.lat && t.lng <= this.northEast.lng && t.lng >= this.southWest.lng;
1503
+ }
1504
+ extend(t) {
1505
+ const e = this.southWest, i = this.northEast;
1506
+ let n, r;
1507
+ if (t instanceof g)
1508
+ n = t, r = t;
1509
+ else if (t instanceof Z)
1510
+ n = t.southWest, r = t.northEast;
1511
+ else
1512
+ throw new Error("Unknown parameter");
1513
+ return this.southWest = new g(
1514
+ Math.min(n.lat, e.lat),
1515
+ Math.min(n.lng, e.lng)
1516
+ ), this.northEast = new g(
1517
+ Math.max(r.lat, i.lat),
1518
+ Math.max(r.lng, i.lng)
1519
+ ), this;
1520
+ }
1521
+ extendsWithMeasure(t) {
1522
+ if (typeof t != "number")
1523
+ throw new Error("measure is not a number");
1524
+ return this.northEast = this.northEast.destinationPoint(t, 0).move(t, Math.PI / 2), this.southWest = this.southWest.clone().destinationPoint(t, -Math.PI / 2).destinationPoint(t, Math.PI), this;
1525
+ }
1526
+ pad(t) {
1527
+ const e = this.southWest, i = this.northEast, n = Math.abs(e.lat - i.lat) * t, r = Math.abs(e.lng - i.lng) * t;
1528
+ return this.southWest = new g(e.lat - n, e.lng - r), this.northEast = new g(i.lat + n, i.lng + r), this;
1529
+ }
1530
+ getSouthWest() {
1531
+ return this.southWest;
1532
+ }
1533
+ getNorthEast() {
1534
+ return this.northEast;
1535
+ }
1536
+ getNorthWest() {
1537
+ return new g(this.getNorth(), this.getWest());
1538
+ }
1539
+ getSouthEast() {
1540
+ return new g(this.getSouth(), this.getEast());
1541
+ }
1542
+ getWest() {
1543
+ return this.southWest.lng;
1544
+ }
1545
+ getSouth() {
1546
+ return this.southWest.lat;
1547
+ }
1548
+ getEast() {
1549
+ return this.northEast.lng;
1550
+ }
1551
+ getNorth() {
1552
+ return this.northEast.lat;
1553
+ }
1554
+ static equals(t, e) {
1555
+ return g.equals(t.northEast, e.northEast) && g.equals(t.southWest, e.southWest);
1556
+ }
1557
+ equals(t) {
1558
+ return Z.equals(this, t);
1559
+ }
1560
+ static fromArray(t) {
1561
+ return new Z(
1562
+ new g(t[3], t[2]),
1563
+ new g(t[1], t[0])
1564
+ );
1565
+ }
1566
+ toArray() {
1567
+ return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()];
1568
+ }
1569
+ }
1570
+ class D {
1571
+ constructor(t, e = null) {
1572
+ d(this, "coords"), d(this, "edges", []), d(this, "builtFrom"), d(this, "io", !1), this.coords = t, this.builtFrom = e;
1573
+ }
1574
+ distanceTo(t) {
1575
+ return this.coords.distanceTo(t.coords);
1576
+ }
1577
+ bearingTo(t) {
1578
+ return this.coords.bearingTo(t.coords);
1579
+ }
1580
+ equals(t) {
1581
+ return this.coords.equals(t.coords) && this.builtFrom === t.builtFrom;
1582
+ }
1583
+ clone() {
1584
+ const t = new D(this.coords, this.builtFrom);
1585
+ return t.edges = this.edges.slice(0), t.io = this.io, t;
1586
+ }
1587
+ toJson() {
1588
+ return this.coords.toCompressedJson();
1589
+ }
1590
+ static fromJson(t, e = null) {
1591
+ return new D(g.fromCompressedJson(t), e);
1592
+ }
1593
+ _generateLevelFromEdges() {
1594
+ let t = null;
1595
+ for (let e = 0; e < this.edges.length; e++) {
1596
+ const i = this.edges[e];
1597
+ if (i.level !== null) {
1598
+ if (t === null)
1599
+ t = f.clone(i.level);
1600
+ else if (t = f.intersection(t, i.level), t === null)
1601
+ throw Error("Something bad happend during parsing: We cannot retrieve node level from adjacent ways: " + this.coords);
1602
+ }
1603
+ }
1604
+ this.coords.level = t;
1605
+ }
1606
+ _inferNodeLevelByRecursion() {
1607
+ const { level: t } = this.coords;
1608
+ if (t === null || !f.isRange(t) || this.edges.length > 1)
1609
+ return;
1610
+ const e = (n, r) => {
1611
+ if (r.push(n), n.coords.level === null)
1612
+ return null;
1613
+ if (!f.isRange(n.coords.level))
1614
+ return n.coords.level;
1615
+ let a = null;
1616
+ for (let l = 0; l < n.edges.length; l++) {
1617
+ const c = n.edges[l], o = c.node1 === n ? c.node2 : c.node1;
1618
+ r.includes(o) || (a = f.union(e(o, r), a));
1619
+ }
1620
+ return a;
1621
+ }, i = e(this, []);
1622
+ if (i !== null) {
1623
+ if (!f.isRange(i)) {
1624
+ this.coords.level = i === t[0] ? t[1] : t[0];
1625
+ return;
1626
+ }
1627
+ throw Error("Level of: " + this.coords.toString() + " cannot be decided");
1628
+ }
1629
+ }
1630
+ _inferNodeLevelByNeighboors() {
1631
+ const { level: t } = this.coords;
1632
+ if (t === null || !f.isRange(t))
1633
+ return !0;
1634
+ let e = null;
1635
+ for (let i = 0; i < this.edges.length; i++) {
1636
+ const n = this.edges[i], r = n.node1 === this ? n.node2 : n.node1;
1637
+ e = f.union(r.coords.level, e);
1638
+ }
1639
+ return (e === null || !f.isRange(e)) && (this.coords.level = e === t[0] ? t[1] : t[0]), !0;
1640
+ }
1641
+ _checkIO() {
1642
+ return this.io = this.coords.level !== null && this.edges.some((t) => t.level === null), !0;
1643
+ }
1644
+ static generateNodesLevels(t) {
1645
+ t.forEach((e) => e._generateLevelFromEdges()), t.forEach((e) => e._inferNodeLevelByNeighboors()), t.forEach((e) => e._inferNodeLevelByRecursion()), t.forEach((e) => e._checkIO());
1646
+ }
1647
+ }
1648
+ class $ {
1649
+ constructor(t, e, i = null, n = null) {
1650
+ d(this, "_node1"), d(this, "_node2"), d(this, "_level", null), d(this, "_bearing", null), d(this, "_length", null), d(this, "_computedSizeAndBearing", !1), d(this, "builtFrom"), d(this, "isOneway", !1), this.node1 = t, this.node2 = e, this.level = i, this.builtFrom = n;
1651
+ }
1652
+ get node1() {
1653
+ return this._node1;
1654
+ }
1655
+ set node1(t) {
1656
+ if (!(t instanceof D))
1657
+ throw new TypeError("node1 is not a GraphNode");
1658
+ this._node1 instanceof D && this._node2 !== this._node1 && (this._node1.edges = this._node1.edges.filter((e) => e !== this)), t.edges.push(this), this._node1 = t, this._computedSizeAndBearing = !1;
1659
+ }
1660
+ get node2() {
1661
+ return this._node2;
1662
+ }
1663
+ set node2(t) {
1664
+ if (!(t instanceof D))
1665
+ throw new TypeError("node2 is not a GraphNode");
1666
+ this._node2 instanceof D && this._node2 !== this._node1 && (this._node2.edges = this._node2.edges.filter((e) => e !== this)), t.edges.push(this), this._node2 = t, this._computedSizeAndBearing = !1;
1667
+ }
1668
+ get level() {
1669
+ return this._level;
1670
+ }
1671
+ set level(t) {
1672
+ f.checkType(t), this._level = t;
1673
+ }
1674
+ get bearing() {
1675
+ return this._computedSizeAndBearing || this._computeSizeAndBearing(), this._bearing;
1676
+ }
1677
+ get length() {
1678
+ return this._computedSizeAndBearing || this._computeSizeAndBearing(), this._length;
1679
+ }
1680
+ _computeSizeAndBearing() {
1681
+ this._length = this.node1.distanceTo(this.node2), this._bearing = this.node1.bearingTo(this.node2), this._computedSizeAndBearing = !0;
1682
+ }
1683
+ equals(t) {
1684
+ return this === t ? !0 : t instanceof $ ? t.node1.equals(this.node1) && t.node2.equals(this.node2) && f.equals(t.level, this.level) && t.isOneway === this.isOneway && t.builtFrom === this.builtFrom : !1;
1685
+ }
1686
+ clone() {
1687
+ const t = new $(this.node1, this.node2, this.level, this.builtFrom);
1688
+ return t.isOneway = this.isOneway, t;
1689
+ }
1690
+ }
1691
+ function Ke(s, t, e) {
1692
+ return s.find(
1693
+ (i) => t === i.node1 && e === i.node2 || e === i.node1 && t === i.node2
1694
+ );
1695
+ }
1696
+ class lt {
1697
+ constructor(t, e) {
1698
+ d(this, "nodes"), d(this, "edges"), this.nodes = Array.isArray(t) ? t : [], this.edges = Array.isArray(e) ? e : [];
1699
+ }
1700
+ getNodeByCoords(t) {
1701
+ return this.nodes.find((e) => e.coords.equals(t));
1702
+ }
1703
+ getEdgeByNodes(t, e) {
1704
+ return Ke(this.edges, t, e);
1705
+ }
1706
+ getBoundingBox(t) {
1707
+ if (!this.nodes.length)
1708
+ return null;
1709
+ const e = this.nodes.reduce(
1710
+ (i, n) => i.extend(n.coords),
1711
+ new Z(this.nodes[0].coords, this.nodes[0].coords)
1712
+ );
1713
+ return t && e.extendsWithMeasure(t), e;
1714
+ }
1715
+ toDetailedString(t, e) {
1716
+ let i = t;
1717
+ i || (i = (a) => `${a.builtFrom}`);
1718
+ let n = e;
1719
+ e || (n = (a) => `${a.builtFrom}`);
1720
+ let r = `--- Network ---
1721
+ Nodes: ${this.nodes.length}
1722
+ Edges: ${this.edges.length}
1723
+ ---
1724
+ Nodes
1725
+ `;
1726
+ return this.nodes.forEach((a) => {
1727
+ r += `${i(a)} [edges: ${a.edges.length}]
1728
+ `;
1729
+ }), r += `---
1730
+ Edges
1731
+ `, this.edges.forEach((a) => {
1732
+ r += `${n(a)} `, r += `[${i(a.node1)} -- ${i(a.node2)}]
1733
+ `;
1734
+ }), r += "---", r;
1735
+ }
1736
+ toCompressedJson() {
1737
+ return {
1738
+ nodes: this.nodes.map((t) => t.toJson()),
1739
+ edges: this.edges.map((t) => {
1740
+ const e = this.nodes.indexOf(t.node1), i = this.nodes.indexOf(t.node2);
1741
+ return t.isOneway ? [e, i, t.level, !0] : t.level ? [e, i, t.level] : [e, i];
1742
+ })
1743
+ };
1744
+ }
1745
+ static fromCompressedJson(t) {
1746
+ const e = new lt();
1747
+ return e.nodes = t.nodes.map((i) => D.fromJson(i, null)), e.edges = t.edges.map((i) => {
1748
+ const n = new $(
1749
+ e.nodes[i[0]],
1750
+ e.nodes[i[1]],
1751
+ i[2],
1752
+ null
1753
+ );
1754
+ return i.length > 3 && i[3] && (n.isOneway = !0), n;
1755
+ }), e;
1756
+ }
1757
+ static fromCoordinates(t) {
1758
+ const e = new lt(), i = (r) => {
1759
+ const a = e.nodes.find((c) => c.coords.equals(r));
1760
+ if (a)
1761
+ return a;
1762
+ const l = new D(r, null);
1763
+ return e.nodes.push(l), l;
1764
+ }, n = (r, a) => new $(r, a, f.union(r.coords.level, a.coords.level), null);
1765
+ for (const r of t) {
1766
+ let a = null;
1767
+ for (const l of r) {
1768
+ const c = i(l);
1769
+ if (a) {
1770
+ const o = n(c, a);
1771
+ e.edges.push(o);
1772
+ }
1773
+ a = c;
1774
+ }
1775
+ }
1776
+ return e;
1777
+ }
1778
+ getEdgesAtLevel(t, e = !0) {
1779
+ return this.edges.filter(
1780
+ ({ level: i }) => e ? f.intersect(t, i) : f.contains(t, i)
1781
+ );
1782
+ }
1783
+ }
1784
+ class Ze {
1785
+ constructor(t, e, i, n) {
1786
+ d(this, "origin"), d(this, "distanceFromNearestElement"), d(this, "coords"), d(this, "nearestElement"), this.origin = t, this.distanceFromNearestElement = e, this.coords = i, this.nearestElement = n;
1787
+ }
1788
+ }
1789
+ const H = class {
1790
+ constructor(s = null) {
1791
+ d(this, "network", null), d(this, "_maxDistance", Number.MAX_VALUE), d(this, "_maxAngleBearing", Math.PI), this.network = s;
1792
+ }
1793
+ set maxAngleBearing(s) {
1794
+ this._maxAngleBearing = s;
1795
+ }
1796
+ get maxAngleBearing() {
1797
+ return this._maxAngleBearing;
1798
+ }
1799
+ set maxDistance(s) {
1800
+ this._maxDistance = s;
1801
+ }
1802
+ get maxDistance() {
1803
+ return this._maxDistance;
1804
+ }
1805
+ _shouldProjectOnEdgeAndNodes(s, t, e, i, n) {
1806
+ if (!n(s))
1807
+ return [!1, !1, !1];
1808
+ let r = f.intersect(t.level, s.level), a = f.intersect(t.level, s.node1.coords.level), l = f.intersect(t.level, s.node2.coords.level);
1809
+ return a = a || s.node1.io && t.level === null, l = l || s.node2.io && t.level === null, i || (r = r && !f.isRange(s.level), a = a && !f.isRange(s.node1.coords.level), l = l && !f.isRange(s.node2.coords.level)), e && (r && Qe(s.bearing, t.bearing) > this._maxAngleBearing && (r = !1), a = !1, l = !1), [r, a, l];
1810
+ }
1811
+ static _assignLatLngLevel(s, t) {
1812
+ t.lat = s.lat, t.lng = s.lng, t.level = f.clone(s.level);
1813
+ }
1814
+ static _handleLevelsWithIONodes(s, t, e) {
1815
+ t.level === null && e.io && (s.level = null);
1816
+ }
1817
+ getProjection(s, t = !1, e = !1, i = !0, n = () => !0) {
1818
+ if (this.network === null)
1819
+ throw new Error("Network has not been set yet");
1820
+ if (!(s instanceof g))
1821
+ throw new TypeError("location is not an instance of Coordinates");
1822
+ if (e && (!("bearing" in s && s.bearing !== null) || !this._maxAngleBearing))
1823
+ return null;
1824
+ let r = Number.MAX_VALUE;
1825
+ const a = s.clone();
1826
+ let l = null;
1827
+ const c = (o) => o < r && (!t || o <= this._maxDistance);
1828
+ for (const o of this.network.edges) {
1829
+ const [u, h, x] = this._shouldProjectOnEdgeAndNodes(
1830
+ o,
1831
+ s,
1832
+ e,
1833
+ i,
1834
+ n
1835
+ );
1836
+ if (h) {
1837
+ const _ = s.distanceTo(o.node1.coords);
1838
+ if ((c(_) || _ <= L) && (r = _, l = o.node1, H._assignLatLngLevel(o.node1.coords, a), H._handleLevelsWithIONodes(a, s, o.node1), _ <= L))
1839
+ break;
1840
+ }
1841
+ if (x) {
1842
+ const _ = s.distanceTo(o.node2.coords);
1843
+ if ((c(_) || _ <= L) && (r = _, l = o.node2, H._assignLatLngLevel(o.node2.coords, a), H._handleLevelsWithIONodes(a, s, o.node2), _ <= L))
1844
+ break;
1845
+ }
1846
+ if (u) {
1847
+ const _ = s.getSegmentProjection(o.node1.coords, o.node2.coords);
1848
+ if (_) {
1849
+ const I = s.distanceTo(_);
1850
+ c(I) && (r = I, l = o, H._assignLatLngLevel(_, a), H._updateProjectionLevelFromEdge(o, a));
1851
+ }
1852
+ }
1853
+ }
1854
+ return l ? (a instanceof P && a.accuracy !== null && (a.accuracy += r), new Ze(
1855
+ s,
1856
+ r,
1857
+ a,
1858
+ l
1859
+ )) : null;
1860
+ }
1861
+ };
1862
+ let ts = H;
1863
+ d(ts, "_updateProjectionLevelFromEdge", (s, t) => {
1864
+ t.level = f.clone(s.level);
1865
+ });
1866
+ var es = Object.defineProperty, ss = (s, t, e) => t in s ? es(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, X = (s, t, e) => (ss(s, typeof t != "symbol" ? t + "" : t, e), e);
1867
+ const rt = [
1868
+ "error",
1869
+ "ok",
1870
+ "warn",
1871
+ "flux",
1872
+ "deprecated",
1873
+ "info",
1874
+ "log",
1875
+ "debug"
1876
+ ];
1877
+ function is(s) {
1878
+ return "wemap" in s;
1879
+ }
1880
+ const p = class {
1881
+ static enable(s) {
1882
+ p.ENABLED = Boolean(s);
1883
+ }
1884
+ static level(s) {
1885
+ return arguments.length && (p.LOG_LEVEL = s), p.LOG_LEVEL;
1886
+ }
1887
+ static clearHistory() {
1888
+ p.HISTORY = [];
1889
+ }
1890
+ static _canUseLog(s) {
1891
+ const t = rt.indexOf(s), e = rt.indexOf(p.LOG_LEVEL);
1892
+ return e === -1 ? !1 : t <= e;
1893
+ }
1894
+ static _getColorByType(s) {
1895
+ let t = null;
1896
+ switch (s) {
1897
+ case "flux":
1898
+ t = "background: #0083E0; color: #FFFFFF;";
1899
+ break;
1900
+ case "ok":
1901
+ t = "background: #00FF22; color: #272727;";
1902
+ break;
1903
+ case "deprecated":
1904
+ t = "background: #CA0AFA; color: #FFFFFF;";
1905
+ break;
1906
+ case "error":
1907
+ t = "background: #CC0000; color: #FFFFFF;";
1908
+ break;
1909
+ case "warn":
1910
+ t = "background: #DD7908; color: #FFFFFF;";
1911
+ break;
1912
+ case "debug":
1913
+ t = "background: #999999; color: #FFFFFF;";
1914
+ break;
1915
+ case "info":
1916
+ t = "background: #DCFF4E; color: #000000;";
1917
+ break;
1918
+ default:
1919
+ t = "background: #F4F4F4; color: #999999;";
1920
+ break;
1921
+ }
1922
+ return t;
1923
+ }
1924
+ static _getOriginByType(s, t) {
1925
+ let e = null, i = null, n = t;
1926
+ if (arguments.length < 2)
1927
+ return "";
1928
+ try {
1929
+ for (e = "", i = s.stack && s.stack.length ? s.stack.split(`
1930
+ `).splice(3) : [], (n < 0 || n >= i.length) && (n = i.length); n; )
1931
+ e += `\r
1932
+ ` + i[0].trim(), i = i.splice(1), n--;
1933
+ return e;
1934
+ } catch {
1935
+ return "";
1936
+ }
1937
+ }
1938
+ static _log(s, t, e) {
1939
+ const i = "color: auto;", n = "color: #6A6A6A;";
1940
+ let r, a = null, l = null, c = null, o = null, u = "", h = !1;
1941
+ if (a = s, o = new Error(t), l = p._getColorByType(s), c = p._getOriginByType(o, e), a === "deprecated" && (a = "warn", h = "deprecated"), c = p._COLOR_TOKEN + c, r = p._COLOR_TOKEN + " " + o.message, u = p._COLOR_TOKEN, u += p._TYPE_PREFIX, u += h || s, u += p._TYPE_SUFFIX, typeof window < "u" && is(window)) {
1942
+ const x = performance && performance.now ? performance.now() : new Date().getTime();
1943
+ u += "[" + Math.round(x - window.wemap.startTime) + "ms]";
1944
+ }
1945
+ return r = u + r + c, p.HISTORY.push(r), !this._canUseLog(s) || arguments.length < 2 || !p.ENABLED ? !1 : (console && s !== "ok" && s !== "flux" && s !== "deprecated" && console[s] && rt.indexOf(s) <= rt.indexOf("info") ? console[s](r, l, i, n) : console.log(r, l, i, n), !0);
1946
+ }
1947
+ static external(s) {
1948
+ return console.log("LIVEMAP :: " + s);
1949
+ }
1950
+ static flux(s) {
1951
+ return p._log("flux", s, 0);
1952
+ }
1953
+ static ok(s) {
1954
+ return p._log("ok", s, 1);
1955
+ }
1956
+ static error(s, t = -1) {
1957
+ return p._log("error", s, t);
1958
+ }
1959
+ static warn(s, t = 2) {
1960
+ return p._log("warn", s, t);
1961
+ }
1962
+ static deprecated(s, t = 2) {
1963
+ return p._log("deprecated", s, t);
1964
+ }
1965
+ static debug(s, t = -1) {
1966
+ return p._log("debug", s, t);
1967
+ }
1968
+ static info(s, t = 0) {
1969
+ return p._log("info", s, t);
1970
+ }
1971
+ static log(s, t = 1) {
1972
+ return p._log("log", s, t);
1973
+ }
1974
+ };
1975
+ let q = p;
1976
+ X(q, "LOG_LEVEL", "debug"), X(q, "ENABLED", !0), X(q, "HISTORY", []), X(q, "_COLOR_TOKEN", "%c"), X(q, "_TYPE_PREFIX", "<<<< "), X(q, "_TYPE_SUFFIX", " >>>>");
1977
+ class Ht extends $t {
1978
+ constructor(e, i, n = null) {
1979
+ super(e, i);
1980
+ M(this, "nodes", []);
1981
+ M(this, "level", null);
1982
+ this.level = n;
59
1983
  }
60
1984
  get areStairs() {
61
1985
  return this.tags.highway === "steps";
@@ -73,224 +1997,142 @@ class OsmWay extends OsmElement {
73
1997
  return this.nodes[0] === this.nodes[this.nodes.length - 1];
74
1998
  }
75
1999
  }
76
- class OsmParser {
77
- static parseOsmXmlString(osmXmlString) {
78
- const model = new OsmModel();
79
- const parser = new saxes.SaxesParser();
80
- let buffer;
81
- const isDeleted = (element) => element.attributes.action && element.attributes.action === "delete";
82
- parser.on("opentag", (node) => {
83
- switch (node.name) {
2000
+ class cs {
2001
+ static parseOsmXmlString(t) {
2002
+ const e = new Zt(), i = new qe();
2003
+ let n;
2004
+ const r = (a) => a.attributes.action && a.attributes.action === "delete";
2005
+ i.on("opentag", (a) => {
2006
+ switch (a.name) {
84
2007
  case "node": {
85
- if (isDeleted(node)) {
86
- buffer = null;
2008
+ if (r(a)) {
2009
+ n = null;
87
2010
  break;
88
2011
  }
89
- const osmNode = this._parseNode(node.attributes);
90
- buffer = osmNode;
91
- model.nodes.push(osmNode);
2012
+ const l = this._parseNode(a.attributes);
2013
+ n = l, e.nodes.push(l);
92
2014
  break;
93
2015
  }
94
2016
  case "way": {
95
- if (isDeleted(node)) {
96
- buffer = null;
2017
+ if (r(a)) {
2018
+ n = null;
97
2019
  break;
98
2020
  }
99
- const osmWay = this._parseWay(node.attributes);
100
- buffer = osmWay;
101
- model.ways.push(osmWay);
2021
+ const l = this._parseWay(a.attributes);
2022
+ n = l, e.ways.push(l);
102
2023
  break;
103
2024
  }
104
2025
  case "tag": {
105
- if (!buffer) {
2026
+ if (!n)
106
2027
  return;
107
- }
108
2028
  const {
109
- k,
110
- v
111
- } = node.attributes;
112
- buffer.tags[k] = v;
2029
+ k: l,
2030
+ v: c
2031
+ } = a.attributes;
2032
+ n.tags[l] = c;
113
2033
  break;
114
2034
  }
115
2035
  case "nd": {
116
- if (!buffer || !(buffer instanceof OsmWay)) {
2036
+ if (!n || !(n instanceof Ht))
117
2037
  return;
118
- }
119
- const nodeId = Number(node.attributes.ref);
120
- const refNode = model.getNodeById(nodeId);
121
- if (!refNode) {
122
- throw Error("Node: " + nodeId + " in way " + buffer.id + " not found");
123
- }
124
- buffer.nodes.push(refNode);
125
- refNode.ways.push(buffer);
2038
+ const l = Number(a.attributes.ref), c = e.getNodeById(l);
2039
+ if (!c)
2040
+ throw Error("Node: " + l + " in way " + n.id + " not found");
2041
+ n.nodes.push(c), c.ways.push(n);
126
2042
  break;
127
2043
  }
128
2044
  }
129
- });
130
- parser.write(osmXmlString);
131
- for (let i = 0; i < model.ways.length; i++) {
132
- const way = model.ways[i];
133
- if (way.tags.level) {
134
- way.level = geo.Level.fromString(way.tags.level);
135
- }
2045
+ }), i.write(t);
2046
+ for (let a = 0; a < e.ways.length; a++) {
2047
+ const l = e.ways[a];
2048
+ l.tags.level && (l.level = f.fromString(l.tags.level));
136
2049
  }
137
- return model;
2050
+ return e;
138
2051
  }
139
- static _parseNode(attr) {
140
- return new OsmNode(
141
- Number(attr.id),
142
- new geo.Coordinates(Number(attr.lat), Number(attr.lon))
2052
+ static _parseNode(t) {
2053
+ return new te(
2054
+ Number(t.id),
2055
+ new g(Number(t.lat), Number(t.lon))
143
2056
  );
144
2057
  }
145
- static _parseWay(attr) {
146
- return new OsmWay(Number(attr.id));
2058
+ static _parseWay(t) {
2059
+ return new Ht(Number(t.id));
147
2060
  }
148
2061
  }
149
- class OsmGraphNode$1 extends geo.GraphNode {
150
- }
151
- class OsmGraphNode extends geo.GraphEdge {
152
- }
153
- class OsmGraphItinerary extends geo.GraphItinerary {
154
- static fromNetworkNodes(start, end, networkNodes, edgesWeights) {
155
- return super.fromNetworkNodes(start, end, networkNodes, edgesWeights);
156
- }
157
- }
158
- class OsmNetwork extends geo.Network {
159
- static fromCoordinates(segments) {
160
- return super.fromCoordinates(segments);
161
- }
162
- }
163
- class OsmGraphProjection extends geo.GraphProjection {
164
- }
165
- class OsmGraphRouter extends geo.GraphRouter {
166
- }
167
- class OsmGraphRouterOptions extends geo.GraphRouterOptions {
2062
+ const jt = ["footway", "steps", "pedestrian", "living_street", "path", "track", "sidewalk"], Qt = (s) => jt.includes(s.tags.highway) || s.tags.footway === "sidewalk" || s.tags.public_transport === "platform" || s.tags.railway === "platform";
2063
+ function ns(s, t) {
2064
+ return s.nodes.find(({ builtFrom: e }) => (e == null ? void 0 : e.tags.name) === t);
168
2065
  }
169
- class OsmMapMatching extends geo.MapMatching {
2066
+ function as(s, t) {
2067
+ return s.edges.find(({ builtFrom: e }) => (e == null ? void 0 : e.tags.name) === t);
170
2068
  }
171
- const HIGHWAYS_PEDESTRIANS = ["footway", "steps", "pedestrian", "living_street", "path", "track", "sidewalk"];
172
- const DEFAULT_WAY_SELECTOR = (way) => {
173
- return HIGHWAYS_PEDESTRIANS.includes(way.tags.highway) || way.tags.footway === "sidewalk" || way.tags.public_transport === "platform" || way.tags.railway === "platform";
174
- };
175
- function getNodeByName(network, name) {
176
- return network.nodes.find(({ builtFrom }) => (builtFrom == null ? void 0 : builtFrom.tags.name) === name);
177
- }
178
- function getEdgeByName(network, name) {
179
- return network.edges.find(({ builtFrom }) => (builtFrom == null ? void 0 : builtFrom.tags.name) === name);
180
- }
181
- function manageOneWay(edge, way) {
182
- const { highway, oneway, conveying } = way.tags;
183
- edge.isOneway = Boolean(oneway === "yes" || oneway === "true" || oneway === "1" || conveying && highway && ["forward", "backward"].includes(conveying));
184
- if (edge.isOneway && conveying === "backward") {
185
- const tmpNode = edge.node1;
186
- edge.node1 = edge.node2;
187
- edge.node2 = tmpNode;
2069
+ function rs(s, t) {
2070
+ const { highway: e, oneway: i, conveying: n } = t.tags;
2071
+ if (s.isOneway = Boolean(i === "yes" || i === "true" || i === "1" || n && e && ["forward", "backward"].includes(n)), s.isOneway && n === "backward") {
2072
+ const r = s.node1;
2073
+ s.node1 = s.node2, s.node2 = r;
188
2074
  }
189
2075
  }
190
- function createNodesAndEdgesFromElevator(nodes, edges, elevatorNode) {
191
- const createdNodes = [];
192
- const getOrCreateLevelNode = (level, builtFrom) => {
193
- let levelNode = createdNodes.find(({ coords }) => geo.Level.equals(level, coords.level));
194
- if (!levelNode) {
195
- levelNode = new OsmGraphNode$1(elevatorNode.coords.clone(), builtFrom);
196
- levelNode.coords.level = level;
197
- createdNodes.push(levelNode);
198
- nodes.push(levelNode);
199
- }
200
- return levelNode;
2076
+ function os(s, t, e) {
2077
+ const i = [], n = (a, l) => {
2078
+ let c = i.find(({ coords: o }) => f.equals(a, o.level));
2079
+ return c || (c = new D(e.coords.clone(), l), c.coords.level = a, i.push(c), s.push(c)), c;
201
2080
  };
202
- elevatorNode.edges.forEach((edge) => {
203
- if (geo.Level.isRange(edge.level)) {
2081
+ e.edges.forEach((a) => {
2082
+ if (f.isRange(a.level))
204
2083
  throw new Error("Cannot handle this elevator edge due to ambiguity");
205
- }
206
- const levelNode = getOrCreateLevelNode(edge.level, elevatorNode.builtFrom);
207
- if (edge.node1 === elevatorNode) {
208
- edge.node1 = levelNode;
209
- } else {
210
- edge.node2 = levelNode;
211
- }
212
- levelNode.edges.push(edge);
2084
+ const l = n(a.level, e.builtFrom);
2085
+ a.node1 === e ? a.node1 = l : a.node2 = l, l.edges.push(a);
213
2086
  });
214
- for (let i = 0; i < createdNodes.length; i++) {
215
- for (let j = i + 1; j < createdNodes.length; j++) {
216
- const createdNode1 = createdNodes[i];
217
- const createdNode2 = createdNodes[j];
218
- if (createdNode1.coords.level === null || createdNode2.coords.level === null) {
2087
+ for (let a = 0; a < i.length; a++)
2088
+ for (let l = a + 1; l < i.length; l++) {
2089
+ const c = i[a], o = i[l];
2090
+ if (c.coords.level === null || o.coords.level === null)
219
2091
  continue;
220
- }
221
- const minLevel = Math.min(createdNode1.coords.level, createdNode2.coords.level);
222
- const maxLevel = Math.max(createdNode1.coords.level, createdNode2.coords.level);
223
- const newEdge = new OsmGraphNode(
224
- createdNode1,
225
- createdNode2,
226
- [minLevel, maxLevel],
227
- elevatorNode.builtFrom
2092
+ const u = Math.min(c.coords.level, o.coords.level), h = Math.max(c.coords.level, o.coords.level), x = new $(
2093
+ c,
2094
+ o,
2095
+ [u, h],
2096
+ e.builtFrom
228
2097
  );
229
- edges.push(newEdge);
2098
+ t.push(x);
230
2099
  }
231
- }
232
- const elevatorNodeIndex = nodes.indexOf(elevatorNode);
233
- if (elevatorNodeIndex > -1) {
234
- nodes.splice(elevatorNodeIndex, 1);
235
- }
2100
+ const r = s.indexOf(e);
2101
+ r > -1 && s.splice(r, 1);
236
2102
  }
237
- function createNetworkFromOsmModel(osmModel, waySelectionFilter = DEFAULT_WAY_SELECTOR) {
238
- const nodes = [];
239
- const edges = [];
240
- const nodesCreated = {};
241
- const elevatorNodes = [];
242
- const getOrCreateNode = (osmNode) => {
243
- let node = nodesCreated[osmNode.id];
244
- if (!node) {
245
- node = new OsmGraphNode$1(osmNode.coords, osmNode);
246
- nodesCreated[osmNode.id] = node;
247
- nodes.push(node);
248
- if (osmNode.tags.highway === "elevator") {
249
- elevatorNodes.push(node);
250
- }
251
- }
252
- return node;
2103
+ function ls(s, t = Qt) {
2104
+ const e = [], i = [], n = {}, r = [], a = (c) => {
2105
+ let o = n[c.id];
2106
+ return o || (o = new D(c.coords, c), n[c.id] = o, e.push(o), c.tags.highway === "elevator" && r.push(o)), o;
253
2107
  };
254
- osmModel.ways.forEach((way) => {
255
- if (!waySelectionFilter(way)) {
2108
+ s.ways.forEach((c) => {
2109
+ if (!t(c))
256
2110
  return;
2111
+ let o = a(c.nodes[0]);
2112
+ for (let u = 1; u < c.nodes.length; u++) {
2113
+ const h = a(c.nodes[u]), x = new $(o, h, c.level, c);
2114
+ rs(x, c), i.push(x), o = h;
257
2115
  }
258
- let firstNode = getOrCreateNode(way.nodes[0]);
259
- for (let i = 1; i < way.nodes.length; i++) {
260
- const secondNode = getOrCreateNode(way.nodes[i]);
261
- const edge = new OsmGraphNode(firstNode, secondNode, way.level, way);
262
- manageOneWay(edge, way);
263
- edges.push(edge);
264
- firstNode = secondNode;
265
- }
266
- });
267
- elevatorNodes.forEach((node) => {
268
- createNodesAndEdgesFromElevator(nodes, edges, node);
2116
+ }), r.forEach((c) => {
2117
+ os(e, i, c);
269
2118
  });
270
- const networkModel = new OsmNetwork(nodes, edges);
271
- OsmGraphNode$1.generateNodesLevels(networkModel.nodes);
272
- return networkModel;
2119
+ const l = new lt(e, i);
2120
+ return D.generateNodesLevels(l.nodes), l;
273
2121
  }
274
- const OsmNetworkUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2122
+ const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
275
2123
  __proto__: null,
276
- HIGHWAYS_PEDESTRIANS,
277
- DEFAULT_WAY_SELECTOR,
278
- getNodeByName,
279
- getEdgeByName,
280
- createNetworkFromOsmModel
2124
+ HIGHWAYS_PEDESTRIANS: jt,
2125
+ DEFAULT_WAY_SELECTOR: Qt,
2126
+ getNodeByName: ns,
2127
+ getEdgeByName: as,
2128
+ createNetworkFromOsmModel: ls
281
2129
  }, Symbol.toStringTag, { value: "Module" }));
282
- exports.OsmElement = OsmElement;
283
- exports.OsmGraphEdge = OsmGraphNode;
284
- exports.OsmGraphItinerary = OsmGraphItinerary;
285
- exports.OsmGraphNode = OsmGraphNode$1;
286
- exports.OsmGraphProjection = OsmGraphProjection;
287
- exports.OsmGraphRouter = OsmGraphRouter;
288
- exports.OsmGraphRouterOptions = OsmGraphRouterOptions;
289
- exports.OsmMapMatching = OsmMapMatching;
290
- exports.OsmModel = OsmModel;
291
- exports.OsmNetwork = OsmNetwork;
292
- exports.OsmNetworkUtils = OsmNetworkUtils;
293
- exports.OsmNode = OsmNode;
294
- exports.OsmParser = OsmParser;
295
- exports.OsmWay = OsmWay;
2130
+ export {
2131
+ $t as OsmElement,
2132
+ Zt as OsmModel,
2133
+ us as OsmNetworkUtils,
2134
+ te as OsmNode,
2135
+ cs as OsmParser,
2136
+ Ht as OsmWay
2137
+ };
296
2138
  //# sourceMappingURL=index.js.map