@loaders.gl/kml 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
Files changed (43) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dist.min.js +3123 -375
  3. package/dist/es5/bundle.js +6 -0
  4. package/dist/es5/bundle.js.map +1 -0
  5. package/dist/es5/gpx-loader.js +82 -0
  6. package/dist/es5/gpx-loader.js.map +1 -0
  7. package/dist/es5/index.js +27 -0
  8. package/dist/es5/index.js.map +1 -0
  9. package/dist/es5/kml-loader.js +82 -0
  10. package/dist/es5/kml-loader.js.map +1 -0
  11. package/dist/es5/tcx-loader.js +82 -0
  12. package/dist/es5/tcx-loader.js.map +1 -0
  13. package/dist/esm/bundle.js +4 -0
  14. package/dist/esm/bundle.js.map +1 -0
  15. package/dist/esm/gpx-loader.js +55 -0
  16. package/dist/esm/gpx-loader.js.map +1 -0
  17. package/dist/esm/index.js +4 -0
  18. package/dist/esm/index.js.map +1 -0
  19. package/dist/esm/kml-loader.js +55 -0
  20. package/dist/esm/kml-loader.js.map +1 -0
  21. package/dist/esm/tcx-loader.js +55 -0
  22. package/dist/esm/tcx-loader.js.map +1 -0
  23. package/dist/gpx-loader.d.ts +16 -26
  24. package/dist/gpx-loader.d.ts.map +1 -1
  25. package/dist/gpx-loader.js +58 -49
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +12 -4
  28. package/dist/kml-loader.d.ts +14 -7
  29. package/dist/kml-loader.d.ts.map +1 -1
  30. package/dist/kml-loader.js +59 -49
  31. package/dist/tcx-loader.d.ts +14 -7
  32. package/dist/tcx-loader.d.ts.map +1 -1
  33. package/dist/tcx-loader.js +60 -50
  34. package/package.json +9 -8
  35. package/src/gpx-loader.ts +35 -14
  36. package/src/index.ts +4 -0
  37. package/src/kml-loader.ts +34 -13
  38. package/src/tcx-loader.ts +34 -12
  39. package/dist/bundle.js.map +0 -1
  40. package/dist/gpx-loader.js.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/kml-loader.js.map +0 -1
  43. package/dist/tcx-loader.js.map +0 -1
package/dist/dist.min.js CHANGED
@@ -29,6 +29,34 @@
29
29
  return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
30
30
  };
31
31
 
32
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
33
+ var init_typeof = __esm({
34
+ "../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
35
+ }
36
+ });
37
+
38
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
39
+ var init_toPrimitive = __esm({
40
+ "../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
41
+ init_typeof();
42
+ }
43
+ });
44
+
45
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
46
+ var init_toPropertyKey = __esm({
47
+ "../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
48
+ init_typeof();
49
+ init_toPrimitive();
50
+ }
51
+ });
52
+
53
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
54
+ var init_defineProperty = __esm({
55
+ "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
56
+ init_toPropertyKey();
57
+ }
58
+ });
59
+
32
60
  // ../../node_modules/@math.gl/polygon/dist/esm/polygon-utils.js
33
61
  function getPolygonSignedArea(points, options = {}) {
34
62
  const {
@@ -51,16 +79,16 @@
51
79
  // ../../node_modules/@math.gl/polygon/dist/esm/polygon.js
52
80
  var init_polygon = __esm({
53
81
  "../../node_modules/@math.gl/polygon/dist/esm/polygon.js"() {
82
+ init_defineProperty();
54
83
  init_polygon_utils();
55
84
  }
56
85
  });
57
86
 
58
87
  // ../../node_modules/@math.gl/polygon/dist/esm/earcut.js
59
- function earcut(data, holeIndices, dim, areas) {
60
- dim = dim || 2;
88
+ function earcut(positions, holeIndices, dim = 2, areas) {
61
89
  const hasHoles = holeIndices && holeIndices.length;
62
- const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
63
- let outerNode = linkedList(data, 0, outerLen, dim, true, areas && areas[0]);
90
+ const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
91
+ let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0]);
64
92
  const triangles = [];
65
93
  if (!outerNode || outerNode.next === outerNode.prev)
66
94
  return triangles;
@@ -72,13 +100,13 @@
72
100
  let x;
73
101
  let y;
74
102
  if (hasHoles)
75
- outerNode = eliminateHoles(data, holeIndices, outerNode, dim, areas);
76
- if (data.length > 80 * dim) {
77
- minX = maxX = data[0];
78
- minY = maxY = data[1];
103
+ outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas);
104
+ if (positions.length > 80 * dim) {
105
+ minX = maxX = positions[0];
106
+ minY = maxY = positions[1];
79
107
  for (let i = dim; i < outerLen; i += dim) {
80
- x = data[i];
81
- y = data[i + 1];
108
+ x = positions[i];
109
+ y = positions[i + 1];
82
110
  if (x < minX)
83
111
  minX = x;
84
112
  if (y < minY)
@@ -857,8 +885,8 @@
857
885
  lineFeaturesCount++;
858
886
  linePositionsCount += geometry.coordinates.length;
859
887
  linePathsCount++;
860
- for (const coord of geometry.coordinates) {
861
- coordLengths.add(coord.length);
888
+ for (const coord2 of geometry.coordinates) {
889
+ coordLengths.add(coord2.length);
862
890
  }
863
891
  break;
864
892
  case "MultiLineString":
@@ -866,8 +894,8 @@
866
894
  for (const line of geometry.coordinates) {
867
895
  linePositionsCount += line.length;
868
896
  linePathsCount++;
869
- for (const coord of line) {
870
- coordLengths.add(coord.length);
897
+ for (const coord2 of line) {
898
+ coordLengths.add(coord2.length);
871
899
  }
872
900
  }
873
901
  break;
@@ -877,8 +905,8 @@
877
905
  polygonRingsCount += geometry.coordinates.length;
878
906
  const flattened = geometry.coordinates.flat();
879
907
  polygonPositionsCount += flattened.length;
880
- for (const coord of flattened) {
881
- coordLengths.add(coord.length);
908
+ for (const coord2 of flattened) {
909
+ coordLengths.add(coord2.length);
882
910
  }
883
911
  break;
884
912
  case "MultiPolygon":
@@ -888,8 +916,8 @@
888
916
  polygonRingsCount += polygon.length;
889
917
  const flattened2 = polygon.flat();
890
918
  polygonPositionsCount += flattened2.length;
891
- for (const coord of flattened2) {
892
- coordLengths.add(coord.length);
919
+ for (const coord2 of flattened2) {
920
+ coordLengths.add(coord2.length);
893
921
  }
894
922
  }
895
923
  break;
@@ -1029,363 +1057,3061 @@
1029
1057
  }
1030
1058
  });
1031
1059
 
1032
- // ../../node_modules/@tmcw/togeojson/dist/togeojson.umd.js
1033
- var require_togeojson_umd = __commonJS({
1034
- "../../node_modules/@tmcw/togeojson/dist/togeojson.umd.js"(exports, module) {
1035
- !function(e, t) {
1036
- typeof exports == "object" && typeof module != "undefined" ? t(exports) : typeof define == "function" && define.amd ? define(["exports"], t) : t((e = typeof globalThis != "undefined" ? globalThis : e || self).toGeoJSON = {});
1037
- }(exports, function(e) {
1038
- "use strict";
1039
- function t(e2) {
1040
- return e2 && e2.normalize && e2.normalize(), e2 && e2.textContent || "";
1041
- }
1042
- function n(e2, t2) {
1043
- const n2 = e2.getElementsByTagName(t2);
1044
- return n2.length ? n2[0] : null;
1045
- }
1046
- function o(e2) {
1047
- const o2 = {};
1048
- if (e2) {
1049
- const s2 = n(e2, "line");
1050
- if (s2) {
1051
- const e3 = t(n(s2, "color")), r2 = parseFloat(t(n(s2, "opacity"))), i2 = parseFloat(t(n(s2, "width")));
1052
- e3 && (o2.stroke = e3), isNaN(r2) || (o2["stroke-opacity"] = r2), isNaN(i2) || (o2["stroke-width"] = 96 * i2 / 25.4);
1060
+ // ../../node_modules/@tmcw/togeojson/dist/togeojson.es.js
1061
+ function nodeVal(x) {
1062
+ if (x && x.normalize) {
1063
+ x.normalize();
1064
+ }
1065
+ return x && x.textContent || "";
1066
+ }
1067
+ function get1(x, y) {
1068
+ const n = x.getElementsByTagName(y);
1069
+ return n.length ? n[0] : null;
1070
+ }
1071
+ function getLineStyle(extensions) {
1072
+ const style = {};
1073
+ if (extensions) {
1074
+ const lineStyle = get1(extensions, "line");
1075
+ if (lineStyle) {
1076
+ const color = nodeVal(get1(lineStyle, "color")), opacity = parseFloat(nodeVal(get1(lineStyle, "opacity"))), width = parseFloat(nodeVal(get1(lineStyle, "width")));
1077
+ if (color)
1078
+ style.stroke = color;
1079
+ if (!isNaN(opacity))
1080
+ style["stroke-opacity"] = opacity;
1081
+ if (!isNaN(width))
1082
+ style["stroke-width"] = width * 96 / 25.4;
1083
+ }
1084
+ }
1085
+ return style;
1086
+ }
1087
+ function getExtensions(node) {
1088
+ let values = [];
1089
+ if (node !== null) {
1090
+ for (let i = 0; i < node.childNodes.length; i++) {
1091
+ const child = node.childNodes[i];
1092
+ if (child.nodeType !== 1)
1093
+ continue;
1094
+ const name = ["heart", "gpxtpx:hr", "hr"].includes(child.nodeName) ? "heart" : child.nodeName;
1095
+ if (name === "gpxtpx:TrackPointExtension") {
1096
+ values = values.concat(getExtensions(child));
1097
+ } else {
1098
+ const val = nodeVal(child);
1099
+ values.push([name, isNaN(val) ? val : parseFloat(val)]);
1100
+ }
1101
+ }
1102
+ }
1103
+ return values;
1104
+ }
1105
+ function getMulti(x, ys) {
1106
+ const o = {};
1107
+ let n;
1108
+ let k;
1109
+ for (k = 0; k < ys.length; k++) {
1110
+ n = get1(x, ys[k]);
1111
+ if (n)
1112
+ o[ys[k]] = nodeVal(n);
1113
+ }
1114
+ return o;
1115
+ }
1116
+ function getProperties$1(node) {
1117
+ const prop = getMulti(node, [
1118
+ "name",
1119
+ "cmt",
1120
+ "desc",
1121
+ "type",
1122
+ "time",
1123
+ "keywords"
1124
+ ]);
1125
+ const extensions = node.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3", "*");
1126
+ for (let i = 0; i < extensions.length; i++) {
1127
+ const extension = extensions[i];
1128
+ if (extension.parentNode.parentNode === node) {
1129
+ prop[extension.tagName.replace(":", "_")] = nodeVal(extension);
1130
+ }
1131
+ }
1132
+ const links = node.getElementsByTagName("link");
1133
+ if (links.length)
1134
+ prop.links = [];
1135
+ for (let i = 0; i < links.length; i++) {
1136
+ prop.links.push(Object.assign({ href: links[i].getAttribute("href") }, getMulti(links[i], ["text", "type"])));
1137
+ }
1138
+ return prop;
1139
+ }
1140
+ function coordPair$1(x) {
1141
+ const ll = [
1142
+ parseFloat(x.getAttribute("lon")),
1143
+ parseFloat(x.getAttribute("lat"))
1144
+ ];
1145
+ const ele = get1(x, "ele");
1146
+ const time = get1(x, "time");
1147
+ if (ele) {
1148
+ const e = parseFloat(nodeVal(ele));
1149
+ if (!isNaN(e)) {
1150
+ ll.push(e);
1151
+ }
1152
+ }
1153
+ return {
1154
+ coordinates: ll,
1155
+ time: time ? nodeVal(time) : null,
1156
+ extendedValues: getExtensions(get1(x, "extensions"))
1157
+ };
1158
+ }
1159
+ function getRoute(node) {
1160
+ const line = getPoints$1(node, "rtept");
1161
+ if (!line)
1162
+ return;
1163
+ return {
1164
+ type: "Feature",
1165
+ properties: Object.assign(getProperties$1(node), getLineStyle(get1(node, "extensions")), { _gpxType: "rte" }),
1166
+ geometry: {
1167
+ type: "LineString",
1168
+ coordinates: line.line
1169
+ }
1170
+ };
1171
+ }
1172
+ function getPoints$1(node, pointname) {
1173
+ const pts = node.getElementsByTagName(pointname);
1174
+ if (pts.length < 2)
1175
+ return;
1176
+ const line = [];
1177
+ const times = [];
1178
+ const extendedValues = {};
1179
+ for (let i = 0; i < pts.length; i++) {
1180
+ const c = coordPair$1(pts[i]);
1181
+ line.push(c.coordinates);
1182
+ if (c.time)
1183
+ times.push(c.time);
1184
+ for (let j = 0; j < c.extendedValues.length; j++) {
1185
+ const [name, val] = c.extendedValues[j];
1186
+ const plural = name === "heart" ? name : name.replace("gpxtpx:", "") + "s";
1187
+ if (!extendedValues[plural]) {
1188
+ extendedValues[plural] = Array(pts.length).fill(null);
1189
+ }
1190
+ extendedValues[plural][i] = val;
1191
+ }
1192
+ }
1193
+ return {
1194
+ line,
1195
+ times,
1196
+ extendedValues
1197
+ };
1198
+ }
1199
+ function getTrack(node) {
1200
+ const segments = node.getElementsByTagName("trkseg");
1201
+ const track = [];
1202
+ const times = [];
1203
+ const extractedLines = [];
1204
+ for (let i = 0; i < segments.length; i++) {
1205
+ const line = getPoints$1(segments[i], "trkpt");
1206
+ if (line) {
1207
+ extractedLines.push(line);
1208
+ if (line.times && line.times.length)
1209
+ times.push(line.times);
1210
+ }
1211
+ }
1212
+ if (extractedLines.length === 0)
1213
+ return;
1214
+ const multi = extractedLines.length > 1;
1215
+ const properties = Object.assign(getProperties$1(node), getLineStyle(get1(node, "extensions")), { _gpxType: "trk" }, times.length ? {
1216
+ coordinateProperties: {
1217
+ times: multi ? times : times[0]
1218
+ }
1219
+ } : {});
1220
+ for (let i = 0; i < extractedLines.length; i++) {
1221
+ const line = extractedLines[i];
1222
+ track.push(line.line);
1223
+ for (const [name, val] of Object.entries(line.extendedValues)) {
1224
+ if (!properties.coordinateProperties) {
1225
+ properties.coordinateProperties = {};
1226
+ }
1227
+ const props = properties.coordinateProperties;
1228
+ if (multi) {
1229
+ if (!props[name])
1230
+ props[name] = extractedLines.map((line2) => new Array(line2.line.length).fill(null));
1231
+ props[name][i] = val;
1232
+ } else {
1233
+ props[name] = val;
1234
+ }
1235
+ }
1236
+ }
1237
+ return {
1238
+ type: "Feature",
1239
+ properties,
1240
+ geometry: multi ? {
1241
+ type: "MultiLineString",
1242
+ coordinates: track
1243
+ } : {
1244
+ type: "LineString",
1245
+ coordinates: track[0]
1246
+ }
1247
+ };
1248
+ }
1249
+ function getPoint(node) {
1250
+ return {
1251
+ type: "Feature",
1252
+ properties: Object.assign(getProperties$1(node), getMulti(node, ["sym"])),
1253
+ geometry: {
1254
+ type: "Point",
1255
+ coordinates: coordPair$1(node).coordinates
1256
+ }
1257
+ };
1258
+ }
1259
+ function* gpxGen(doc) {
1260
+ const tracks = doc.getElementsByTagName("trk");
1261
+ const routes = doc.getElementsByTagName("rte");
1262
+ const waypoints = doc.getElementsByTagName("wpt");
1263
+ for (let i = 0; i < tracks.length; i++) {
1264
+ const feature = getTrack(tracks[i]);
1265
+ if (feature)
1266
+ yield feature;
1267
+ }
1268
+ for (let i = 0; i < routes.length; i++) {
1269
+ const feature = getRoute(routes[i]);
1270
+ if (feature)
1271
+ yield feature;
1272
+ }
1273
+ for (let i = 0; i < waypoints.length; i++) {
1274
+ yield getPoint(waypoints[i]);
1275
+ }
1276
+ }
1277
+ function gpx(doc) {
1278
+ return {
1279
+ type: "FeatureCollection",
1280
+ features: Array.from(gpxGen(doc))
1281
+ };
1282
+ }
1283
+ function fromEntries(arr) {
1284
+ const obj = {};
1285
+ for (const [key, value] of arr) {
1286
+ obj[key] = value;
1287
+ }
1288
+ return obj;
1289
+ }
1290
+ function getProperties(node, attributeNames) {
1291
+ const properties = [];
1292
+ for (const [tag, alias] of attributeNames) {
1293
+ let elem = get1(node, tag);
1294
+ if (!elem) {
1295
+ const elements = node.getElementsByTagNameNS(EXTENSIONS_NS, tag);
1296
+ if (elements.length) {
1297
+ elem = elements[0];
1298
+ }
1299
+ }
1300
+ const val = parseFloat(nodeVal(elem));
1301
+ if (!isNaN(val)) {
1302
+ properties.push([alias, val]);
1303
+ }
1304
+ }
1305
+ return properties;
1306
+ }
1307
+ function coordPair(x) {
1308
+ const lon = nodeVal(get1(x, "LongitudeDegrees"));
1309
+ const lat = nodeVal(get1(x, "LatitudeDegrees"));
1310
+ if (!lon.length || !lat.length) {
1311
+ return null;
1312
+ }
1313
+ const ll = [parseFloat(lon), parseFloat(lat)];
1314
+ const alt = get1(x, "AltitudeMeters");
1315
+ const heartRate = get1(x, "HeartRateBpm");
1316
+ const time = get1(x, "Time");
1317
+ let a;
1318
+ if (alt) {
1319
+ a = parseFloat(nodeVal(alt));
1320
+ if (!isNaN(a)) {
1321
+ ll.push(a);
1322
+ }
1323
+ }
1324
+ return {
1325
+ coordinates: ll,
1326
+ time: time ? nodeVal(time) : null,
1327
+ heartRate: heartRate ? parseFloat(nodeVal(heartRate)) : null,
1328
+ extensions: getProperties(x, TRACKPOINT_ATTRIBUTES)
1329
+ };
1330
+ }
1331
+ function getPoints(node, pointname) {
1332
+ const pts = node.getElementsByTagName(pointname);
1333
+ const line = [];
1334
+ const times = [];
1335
+ const heartRates = [];
1336
+ if (pts.length < 2)
1337
+ return null;
1338
+ const result = { extendedProperties: {} };
1339
+ for (let i = 0; i < pts.length; i++) {
1340
+ const c = coordPair(pts[i]);
1341
+ if (c === null)
1342
+ continue;
1343
+ line.push(c.coordinates);
1344
+ if (c.time)
1345
+ times.push(c.time);
1346
+ if (c.heartRate)
1347
+ heartRates.push(c.heartRate);
1348
+ for (const [alias, value] of c.extensions) {
1349
+ if (!result.extendedProperties[alias]) {
1350
+ result.extendedProperties[alias] = Array(pts.length).fill(null);
1351
+ }
1352
+ result.extendedProperties[alias][i] = value;
1353
+ }
1354
+ }
1355
+ return Object.assign(result, {
1356
+ line,
1357
+ times,
1358
+ heartRates
1359
+ });
1360
+ }
1361
+ function getLap(node) {
1362
+ const segments = node.getElementsByTagName("Track");
1363
+ const track = [];
1364
+ const times = [];
1365
+ const heartRates = [];
1366
+ const allExtendedProperties = [];
1367
+ let line;
1368
+ const properties = fromEntries(getProperties(node, LAP_ATTRIBUTES));
1369
+ const nameElement = get1(node, "Name");
1370
+ if (nameElement) {
1371
+ properties.name = nodeVal(nameElement);
1372
+ }
1373
+ for (let i = 0; i < segments.length; i++) {
1374
+ line = getPoints(segments[i], "Trackpoint");
1375
+ if (line) {
1376
+ track.push(line.line);
1377
+ if (line.times.length)
1378
+ times.push(line.times);
1379
+ if (line.heartRates.length)
1380
+ heartRates.push(line.heartRates);
1381
+ allExtendedProperties.push(line.extendedProperties);
1382
+ }
1383
+ }
1384
+ for (let i = 0; i < allExtendedProperties.length; i++) {
1385
+ const extendedProperties = allExtendedProperties[i];
1386
+ for (const property in extendedProperties) {
1387
+ if (segments.length === 1) {
1388
+ properties[property] = line.extendedProperties[property];
1389
+ } else {
1390
+ if (!properties[property]) {
1391
+ properties[property] = track.map((track2) => Array(track2.length).fill(null));
1392
+ }
1393
+ properties[property][i] = extendedProperties[property];
1394
+ }
1395
+ }
1396
+ }
1397
+ if (track.length === 0)
1398
+ return;
1399
+ if (times.length || heartRates.length) {
1400
+ properties.coordinateProperties = Object.assign(times.length ? {
1401
+ times: track.length === 1 ? times[0] : times
1402
+ } : {}, heartRates.length ? {
1403
+ heart: track.length === 1 ? heartRates[0] : heartRates
1404
+ } : {});
1405
+ }
1406
+ return {
1407
+ type: "Feature",
1408
+ properties,
1409
+ geometry: {
1410
+ type: track.length === 1 ? "LineString" : "MultiLineString",
1411
+ coordinates: track.length === 1 ? track[0] : track
1412
+ }
1413
+ };
1414
+ }
1415
+ function* tcxGen(doc) {
1416
+ const laps = doc.getElementsByTagName("Lap");
1417
+ for (let i = 0; i < laps.length; i++) {
1418
+ const feature = getLap(laps[i]);
1419
+ if (feature)
1420
+ yield feature;
1421
+ }
1422
+ const courses = doc.getElementsByTagName("Courses");
1423
+ for (let i = 0; i < courses.length; i++) {
1424
+ const feature = getLap(courses[i]);
1425
+ if (feature)
1426
+ yield feature;
1427
+ }
1428
+ }
1429
+ function tcx(doc) {
1430
+ return {
1431
+ type: "FeatureCollection",
1432
+ features: Array.from(tcxGen(doc))
1433
+ };
1434
+ }
1435
+ function okhash(x) {
1436
+ if (!x || !x.length)
1437
+ return 0;
1438
+ let h = 0;
1439
+ for (let i = 0; i < x.length; i++) {
1440
+ h = (h << 5) - h + x.charCodeAt(i) | 0;
1441
+ }
1442
+ return h;
1443
+ }
1444
+ function coord1(v) {
1445
+ return v.replace(removeSpace, "").split(",").map(parseFloat);
1446
+ }
1447
+ function coord(v) {
1448
+ return v.replace(trimSpace, "").split(splitSpace).map(coord1);
1449
+ }
1450
+ function xml2str(node) {
1451
+ if (node.xml !== void 0)
1452
+ return node.xml;
1453
+ if (node.tagName) {
1454
+ let output = node.tagName;
1455
+ for (let i = 0; i < node.attributes.length; i++) {
1456
+ output += node.attributes[i].name + node.attributes[i].value;
1457
+ }
1458
+ for (let i = 0; i < node.childNodes.length; i++) {
1459
+ output += xml2str(node.childNodes[i]);
1460
+ }
1461
+ return output;
1462
+ }
1463
+ if (node.nodeName === "#text") {
1464
+ return (node.nodeValue || node.value || "").trim();
1465
+ }
1466
+ if (node.nodeName === "#cdata-section") {
1467
+ return node.nodeValue;
1468
+ }
1469
+ return "";
1470
+ }
1471
+ function kmlColor(properties, elem, prefix) {
1472
+ let v = nodeVal(get1(elem, "color")) || "";
1473
+ const colorProp = prefix == "stroke" || prefix === "fill" ? prefix : prefix + "-color";
1474
+ if (v.substr(0, 1) === "#") {
1475
+ v = v.substr(1);
1476
+ }
1477
+ if (v.length === 6 || v.length === 3) {
1478
+ properties[colorProp] = v;
1479
+ } else if (v.length === 8) {
1480
+ properties[prefix + "-opacity"] = parseInt(v.substr(0, 2), 16) / 255;
1481
+ properties[colorProp] = "#" + v.substr(6, 2) + v.substr(4, 2) + v.substr(2, 2);
1482
+ }
1483
+ }
1484
+ function numericProperty(properties, elem, source, target) {
1485
+ const val = parseFloat(nodeVal(get1(elem, source)));
1486
+ if (!isNaN(val))
1487
+ properties[target] = val;
1488
+ }
1489
+ function gxCoords(root) {
1490
+ let elems = root.getElementsByTagName("coord");
1491
+ const coords = [];
1492
+ const times = [];
1493
+ if (elems.length === 0)
1494
+ elems = root.getElementsByTagName("gx:coord");
1495
+ for (let i = 0; i < elems.length; i++) {
1496
+ coords.push(nodeVal(elems[i]).split(" ").map(parseFloat));
1497
+ }
1498
+ const timeElems = root.getElementsByTagName("when");
1499
+ for (let j = 0; j < timeElems.length; j++)
1500
+ times.push(nodeVal(timeElems[j]));
1501
+ return {
1502
+ coords,
1503
+ times
1504
+ };
1505
+ }
1506
+ function getGeometry(root) {
1507
+ let geomNode;
1508
+ let geomNodes;
1509
+ let i;
1510
+ let j;
1511
+ let k;
1512
+ const geoms = [];
1513
+ const coordTimes = [];
1514
+ if (get1(root, "MultiGeometry")) {
1515
+ return getGeometry(get1(root, "MultiGeometry"));
1516
+ }
1517
+ if (get1(root, "MultiTrack")) {
1518
+ return getGeometry(get1(root, "MultiTrack"));
1519
+ }
1520
+ if (get1(root, "gx:MultiTrack")) {
1521
+ return getGeometry(get1(root, "gx:MultiTrack"));
1522
+ }
1523
+ for (i = 0; i < geotypes.length; i++) {
1524
+ geomNodes = root.getElementsByTagName(geotypes[i]);
1525
+ if (geomNodes) {
1526
+ for (j = 0; j < geomNodes.length; j++) {
1527
+ geomNode = geomNodes[j];
1528
+ if (geotypes[i] === "Point") {
1529
+ geoms.push({
1530
+ type: "Point",
1531
+ coordinates: coord1(nodeVal(get1(geomNode, "coordinates")))
1532
+ });
1533
+ } else if (geotypes[i] === "LineString") {
1534
+ geoms.push({
1535
+ type: "LineString",
1536
+ coordinates: coord(nodeVal(get1(geomNode, "coordinates")))
1537
+ });
1538
+ } else if (geotypes[i] === "Polygon") {
1539
+ const rings = geomNode.getElementsByTagName("LinearRing"), coords = [];
1540
+ for (k = 0; k < rings.length; k++) {
1541
+ coords.push(coord(nodeVal(get1(rings[k], "coordinates"))));
1053
1542
  }
1543
+ geoms.push({
1544
+ type: "Polygon",
1545
+ coordinates: coords
1546
+ });
1547
+ } else if (geotypes[i] === "Track" || geotypes[i] === "gx:Track") {
1548
+ const track = gxCoords(geomNode);
1549
+ geoms.push({
1550
+ type: "LineString",
1551
+ coordinates: track.coords
1552
+ });
1553
+ if (track.times.length)
1554
+ coordTimes.push(track.times);
1054
1555
  }
1055
- return o2;
1056
- }
1057
- function s(e2, o2) {
1058
- const s2 = {};
1059
- let r2, i2;
1060
- for (i2 = 0; i2 < o2.length; i2++)
1061
- r2 = n(e2, o2[i2]), r2 && (s2[o2[i2]] = t(r2));
1062
- return s2;
1063
- }
1064
- function r(e2) {
1065
- const n2 = s(e2, ["name", "cmt", "desc", "type", "time", "keywords"]), o2 = e2.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3", "*");
1066
- for (let s2 = 0; s2 < o2.length; s2++) {
1067
- const r3 = o2[s2];
1068
- r3.parentNode.parentNode === e2 && (n2[r3.tagName.replace(":", "_")] = t(r3));
1069
- }
1070
- const r2 = e2.getElementsByTagName("link");
1071
- r2.length && (n2.links = []);
1072
- for (let e3 = 0; e3 < r2.length; e3++)
1073
- n2.links.push(Object.assign({ href: r2[e3].getAttribute("href") }, s(r2[e3], ["text", "type"])));
1074
- return n2;
1075
- }
1076
- function i(e2) {
1077
- const o2 = [parseFloat(e2.getAttribute("lon")), parseFloat(e2.getAttribute("lat"))], s2 = n(e2, "ele"), r2 = n(e2, "gpxtpx:hr") || n(e2, "hr"), i2 = n(e2, "time");
1078
- let l2;
1079
- s2 && (l2 = parseFloat(t(s2)), isNaN(l2) || o2.push(l2));
1080
- const a2 = { coordinates: o2, time: i2 ? t(i2) : null, extendedValues: [] };
1081
- r2 && a2.extendedValues.push(["heart", parseFloat(t(r2))]);
1082
- const c2 = n(e2, "extensions");
1083
- if (c2 !== null)
1084
- for (const e3 of ["speed", "course", "hAcc", "vAcc"]) {
1085
- const o3 = parseFloat(t(n(c2, e3)));
1086
- isNaN(o3) || a2.extendedValues.push([e3, o3]);
1556
+ }
1557
+ }
1558
+ }
1559
+ return {
1560
+ geoms,
1561
+ coordTimes
1562
+ };
1563
+ }
1564
+ function getPlacemark(root, styleIndex, styleMapIndex, styleByHash) {
1565
+ const geomsAndTimes = getGeometry(root);
1566
+ let i;
1567
+ const properties = {};
1568
+ const name = nodeVal(get1(root, "name"));
1569
+ const address = nodeVal(get1(root, "address"));
1570
+ let styleUrl = nodeVal(get1(root, "styleUrl"));
1571
+ const description = nodeVal(get1(root, "description"));
1572
+ const timeSpan = get1(root, "TimeSpan");
1573
+ const timeStamp = get1(root, "TimeStamp");
1574
+ const extendedData = get1(root, "ExtendedData");
1575
+ let iconStyle = get1(root, "IconStyle");
1576
+ let labelStyle = get1(root, "LabelStyle");
1577
+ let lineStyle = get1(root, "LineStyle");
1578
+ let polyStyle = get1(root, "PolyStyle");
1579
+ const visibility = get1(root, "visibility");
1580
+ if (name)
1581
+ properties.name = name;
1582
+ if (address)
1583
+ properties.address = address;
1584
+ if (styleUrl) {
1585
+ if (styleUrl[0] !== "#") {
1586
+ styleUrl = "#" + styleUrl;
1587
+ }
1588
+ properties.styleUrl = styleUrl;
1589
+ if (styleIndex[styleUrl]) {
1590
+ properties.styleHash = styleIndex[styleUrl];
1591
+ }
1592
+ if (styleMapIndex[styleUrl]) {
1593
+ properties.styleMapHash = styleMapIndex[styleUrl];
1594
+ properties.styleHash = styleIndex[styleMapIndex[styleUrl].normal];
1595
+ }
1596
+ const style = styleByHash[properties.styleHash];
1597
+ if (style) {
1598
+ if (!iconStyle)
1599
+ iconStyle = get1(style, "IconStyle");
1600
+ if (!labelStyle)
1601
+ labelStyle = get1(style, "LabelStyle");
1602
+ if (!lineStyle)
1603
+ lineStyle = get1(style, "LineStyle");
1604
+ if (!polyStyle)
1605
+ polyStyle = get1(style, "PolyStyle");
1606
+ }
1607
+ }
1608
+ if (description)
1609
+ properties.description = description;
1610
+ if (timeSpan) {
1611
+ const begin = nodeVal(get1(timeSpan, "begin"));
1612
+ const end = nodeVal(get1(timeSpan, "end"));
1613
+ properties.timespan = { begin, end };
1614
+ }
1615
+ if (timeStamp) {
1616
+ properties.timestamp = nodeVal(get1(timeStamp, "when"));
1617
+ }
1618
+ if (iconStyle) {
1619
+ kmlColor(properties, iconStyle, "icon");
1620
+ numericProperty(properties, iconStyle, "scale", "icon-scale");
1621
+ numericProperty(properties, iconStyle, "heading", "icon-heading");
1622
+ const hotspot = get1(iconStyle, "hotSpot");
1623
+ if (hotspot) {
1624
+ const left = parseFloat(hotspot.getAttribute("x"));
1625
+ const top = parseFloat(hotspot.getAttribute("y"));
1626
+ if (!isNaN(left) && !isNaN(top))
1627
+ properties["icon-offset"] = [left, top];
1628
+ }
1629
+ const icon = get1(iconStyle, "Icon");
1630
+ if (icon) {
1631
+ const href = nodeVal(get1(icon, "href"));
1632
+ if (href)
1633
+ properties.icon = href;
1634
+ }
1635
+ }
1636
+ if (labelStyle) {
1637
+ kmlColor(properties, labelStyle, "label");
1638
+ numericProperty(properties, labelStyle, "scale", "label-scale");
1639
+ }
1640
+ if (lineStyle) {
1641
+ kmlColor(properties, lineStyle, "stroke");
1642
+ numericProperty(properties, lineStyle, "width", "stroke-width");
1643
+ }
1644
+ if (polyStyle) {
1645
+ kmlColor(properties, polyStyle, "fill");
1646
+ const fill = nodeVal(get1(polyStyle, "fill"));
1647
+ const outline = nodeVal(get1(polyStyle, "outline"));
1648
+ if (fill)
1649
+ properties["fill-opacity"] = fill === "1" ? properties["fill-opacity"] || 1 : 0;
1650
+ if (outline)
1651
+ properties["stroke-opacity"] = outline === "1" ? properties["stroke-opacity"] || 1 : 0;
1652
+ }
1653
+ if (extendedData) {
1654
+ const datas = extendedData.getElementsByTagName("Data"), simpleDatas = extendedData.getElementsByTagName("SimpleData");
1655
+ for (i = 0; i < datas.length; i++) {
1656
+ properties[datas[i].getAttribute("name")] = nodeVal(get1(datas[i], "value"));
1657
+ }
1658
+ for (i = 0; i < simpleDatas.length; i++) {
1659
+ properties[simpleDatas[i].getAttribute("name")] = nodeVal(simpleDatas[i]);
1660
+ }
1661
+ }
1662
+ if (visibility) {
1663
+ properties.visibility = nodeVal(visibility);
1664
+ }
1665
+ if (geomsAndTimes.coordTimes.length) {
1666
+ properties.coordinateProperties = {
1667
+ times: geomsAndTimes.coordTimes.length === 1 ? geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes
1668
+ };
1669
+ }
1670
+ const feature = {
1671
+ type: "Feature",
1672
+ geometry: geomsAndTimes.geoms.length === 0 ? null : geomsAndTimes.geoms.length === 1 ? geomsAndTimes.geoms[0] : {
1673
+ type: "GeometryCollection",
1674
+ geometries: geomsAndTimes.geoms
1675
+ },
1676
+ properties
1677
+ };
1678
+ if (root.getAttribute("id"))
1679
+ feature.id = root.getAttribute("id");
1680
+ return feature;
1681
+ }
1682
+ function* kmlGen(doc) {
1683
+ const styleIndex = {};
1684
+ const styleByHash = {};
1685
+ const styleMapIndex = {};
1686
+ const placemarks = doc.getElementsByTagName("Placemark");
1687
+ const styles = doc.getElementsByTagName("Style");
1688
+ const styleMaps = doc.getElementsByTagName("StyleMap");
1689
+ for (let k = 0; k < styles.length; k++) {
1690
+ const style = styles[k];
1691
+ const hash = okhash(xml2str(style)).toString(16);
1692
+ let id = style.getAttribute("id");
1693
+ if (!id && style.parentNode.tagName.replace("gx:", "") === "CascadingStyle") {
1694
+ id = style.parentNode.getAttribute("kml:id") || style.parentNode.getAttribute("id");
1695
+ }
1696
+ styleIndex["#" + id] = hash;
1697
+ styleByHash[hash] = style;
1698
+ }
1699
+ for (let l = 0; l < styleMaps.length; l++) {
1700
+ styleIndex["#" + styleMaps[l].getAttribute("id")] = okhash(xml2str(styleMaps[l])).toString(16);
1701
+ const pairs = styleMaps[l].getElementsByTagName("Pair");
1702
+ const pairsMap = {};
1703
+ for (let m = 0; m < pairs.length; m++) {
1704
+ pairsMap[nodeVal(get1(pairs[m], "key"))] = nodeVal(get1(pairs[m], "styleUrl"));
1705
+ }
1706
+ styleMapIndex["#" + styleMaps[l].getAttribute("id")] = pairsMap;
1707
+ }
1708
+ for (let j = 0; j < placemarks.length; j++) {
1709
+ const feature = getPlacemark(placemarks[j], styleIndex, styleMapIndex, styleByHash);
1710
+ if (feature)
1711
+ yield feature;
1712
+ }
1713
+ }
1714
+ function kml(doc) {
1715
+ return {
1716
+ type: "FeatureCollection",
1717
+ features: Array.from(kmlGen(doc))
1718
+ };
1719
+ }
1720
+ var EXTENSIONS_NS, TRACKPOINT_ATTRIBUTES, LAP_ATTRIBUTES, removeSpace, trimSpace, splitSpace, geotypes;
1721
+ var init_togeojson_es = __esm({
1722
+ "../../node_modules/@tmcw/togeojson/dist/togeojson.es.js"() {
1723
+ EXTENSIONS_NS = "http://www.garmin.com/xmlschemas/ActivityExtension/v2";
1724
+ TRACKPOINT_ATTRIBUTES = [
1725
+ ["heartRate", "heartRates"],
1726
+ ["Cadence", "cadences"],
1727
+ ["Speed", "speeds"],
1728
+ ["Watts", "watts"]
1729
+ ];
1730
+ LAP_ATTRIBUTES = [
1731
+ ["TotalTimeSeconds", "totalTimeSeconds"],
1732
+ ["DistanceMeters", "distanceMeters"],
1733
+ ["MaximumSpeed", "maxSpeed"],
1734
+ ["AverageHeartRateBpm", "avgHeartRate"],
1735
+ ["MaximumHeartRateBpm", "maxHeartRate"],
1736
+ ["AvgSpeed", "avgSpeed"],
1737
+ ["AvgWatts", "avgWatts"],
1738
+ ["MaxWatts", "maxWatts"]
1739
+ ];
1740
+ removeSpace = /\s*/g;
1741
+ trimSpace = /^\s*|\s*$/g;
1742
+ splitSpace = /\s+/;
1743
+ geotypes = ["Polygon", "LineString", "Point", "Track", "gx:Track"];
1744
+ }
1745
+ });
1746
+
1747
+ // ../../node_modules/@xmldom/xmldom/lib/conventions.js
1748
+ var require_conventions = __commonJS({
1749
+ "../../node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {
1750
+ "use strict";
1751
+ function find(list, predicate, ac) {
1752
+ if (ac === void 0) {
1753
+ ac = Array.prototype;
1754
+ }
1755
+ if (list && typeof ac.find === "function") {
1756
+ return ac.find.call(list, predicate);
1757
+ }
1758
+ for (var i = 0; i < list.length; i++) {
1759
+ if (Object.prototype.hasOwnProperty.call(list, i)) {
1760
+ var item = list[i];
1761
+ if (predicate.call(void 0, item, i, list)) {
1762
+ return item;
1087
1763
  }
1088
- return a2;
1764
+ }
1089
1765
  }
1090
- function l(e2) {
1091
- const t2 = a(e2, "rtept");
1092
- if (t2)
1093
- return { type: "Feature", properties: Object.assign(r(e2), o(n(e2, "extensions")), { _gpxType: "rte" }), geometry: { type: "LineString", coordinates: t2.line } };
1766
+ }
1767
+ function freeze(object, oc) {
1768
+ if (oc === void 0) {
1769
+ oc = Object;
1094
1770
  }
1095
- function a(e2, t2) {
1096
- const n2 = e2.getElementsByTagName(t2);
1097
- if (n2.length < 2)
1098
- return;
1099
- const o2 = [], s2 = [], r2 = {};
1100
- for (let e3 = 0; e3 < n2.length; e3++) {
1101
- const t3 = i(n2[e3]);
1102
- o2.push(t3.coordinates), t3.time && s2.push(t3.time);
1103
- for (let o3 = 0; o3 < t3.extendedValues.length; o3++) {
1104
- const [s3, i2] = t3.extendedValues[o3], l2 = s3 === "heart" ? s3 : s3 + "s";
1105
- r2[l2] || (r2[l2] = Array(n2.length).fill(null)), r2[l2][e3] = i2;
1771
+ return oc && typeof oc.freeze === "function" ? oc.freeze(object) : object;
1772
+ }
1773
+ var MIME_TYPE = freeze({
1774
+ HTML: "text/html",
1775
+ isHTML: function(value) {
1776
+ return value === MIME_TYPE.HTML;
1777
+ },
1778
+ XML_APPLICATION: "application/xml",
1779
+ XML_TEXT: "text/xml",
1780
+ XML_XHTML_APPLICATION: "application/xhtml+xml",
1781
+ XML_SVG_IMAGE: "image/svg+xml"
1782
+ });
1783
+ var NAMESPACE = freeze({
1784
+ HTML: "http://www.w3.org/1999/xhtml",
1785
+ isHTML: function(uri) {
1786
+ return uri === NAMESPACE.HTML;
1787
+ },
1788
+ SVG: "http://www.w3.org/2000/svg",
1789
+ XML: "http://www.w3.org/XML/1998/namespace",
1790
+ XMLNS: "http://www.w3.org/2000/xmlns/"
1791
+ });
1792
+ exports.find = find;
1793
+ exports.freeze = freeze;
1794
+ exports.MIME_TYPE = MIME_TYPE;
1795
+ exports.NAMESPACE = NAMESPACE;
1796
+ }
1797
+ });
1798
+
1799
+ // ../../node_modules/@xmldom/xmldom/lib/dom.js
1800
+ var require_dom = __commonJS({
1801
+ "../../node_modules/@xmldom/xmldom/lib/dom.js"(exports) {
1802
+ var conventions = require_conventions();
1803
+ var find = conventions.find;
1804
+ var NAMESPACE = conventions.NAMESPACE;
1805
+ function notEmptyString(input) {
1806
+ return input !== "";
1807
+ }
1808
+ function splitOnASCIIWhitespace(input) {
1809
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
1810
+ }
1811
+ function orderedSetReducer(current, element) {
1812
+ if (!current.hasOwnProperty(element)) {
1813
+ current[element] = true;
1814
+ }
1815
+ return current;
1816
+ }
1817
+ function toOrderedSet(input) {
1818
+ if (!input)
1819
+ return [];
1820
+ var list = splitOnASCIIWhitespace(input);
1821
+ return Object.keys(list.reduce(orderedSetReducer, {}));
1822
+ }
1823
+ function arrayIncludes(list) {
1824
+ return function(element) {
1825
+ return list && list.indexOf(element) !== -1;
1826
+ };
1827
+ }
1828
+ function copy2(src, dest) {
1829
+ for (var p in src) {
1830
+ if (Object.prototype.hasOwnProperty.call(src, p)) {
1831
+ dest[p] = src[p];
1832
+ }
1833
+ }
1834
+ }
1835
+ function _extends(Class, Super) {
1836
+ var pt = Class.prototype;
1837
+ if (!(pt instanceof Super)) {
1838
+ let t2 = function() {
1839
+ };
1840
+ var t = t2;
1841
+ ;
1842
+ t2.prototype = Super.prototype;
1843
+ t2 = new t2();
1844
+ copy2(pt, t2);
1845
+ Class.prototype = pt = t2;
1846
+ }
1847
+ if (pt.constructor != Class) {
1848
+ if (typeof Class != "function") {
1849
+ console.error("unknown Class:" + Class);
1850
+ }
1851
+ pt.constructor = Class;
1852
+ }
1853
+ }
1854
+ var NodeType = {};
1855
+ var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
1856
+ var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
1857
+ var TEXT_NODE = NodeType.TEXT_NODE = 3;
1858
+ var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
1859
+ var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
1860
+ var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
1861
+ var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
1862
+ var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
1863
+ var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
1864
+ var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
1865
+ var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
1866
+ var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
1867
+ var ExceptionCode = {};
1868
+ var ExceptionMessage = {};
1869
+ var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
1870
+ var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
1871
+ var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
1872
+ var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
1873
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
1874
+ var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
1875
+ var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
1876
+ var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
1877
+ var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
1878
+ var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
1879
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
1880
+ var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
1881
+ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
1882
+ var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
1883
+ var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
1884
+ function DOMException(code, message) {
1885
+ if (message instanceof Error) {
1886
+ var error = message;
1887
+ } else {
1888
+ error = this;
1889
+ Error.call(this, ExceptionMessage[code]);
1890
+ this.message = ExceptionMessage[code];
1891
+ if (Error.captureStackTrace)
1892
+ Error.captureStackTrace(this, DOMException);
1893
+ }
1894
+ error.code = code;
1895
+ if (message)
1896
+ this.message = this.message + ": " + message;
1897
+ return error;
1898
+ }
1899
+ DOMException.prototype = Error.prototype;
1900
+ copy2(ExceptionCode, DOMException);
1901
+ function NodeList() {
1902
+ }
1903
+ NodeList.prototype = {
1904
+ length: 0,
1905
+ item: function(index) {
1906
+ return this[index] || null;
1907
+ },
1908
+ toString: function(isHTML, nodeFilter) {
1909
+ for (var buf = [], i = 0; i < this.length; i++) {
1910
+ serializeToString(this[i], buf, isHTML, nodeFilter);
1911
+ }
1912
+ return buf.join("");
1913
+ },
1914
+ filter: function(predicate) {
1915
+ return Array.prototype.filter.call(this, predicate);
1916
+ },
1917
+ indexOf: function(item) {
1918
+ return Array.prototype.indexOf.call(this, item);
1919
+ }
1920
+ };
1921
+ function LiveNodeList(node, refresh) {
1922
+ this._node = node;
1923
+ this._refresh = refresh;
1924
+ _updateLiveList(this);
1925
+ }
1926
+ function _updateLiveList(list) {
1927
+ var inc = list._node._inc || list._node.ownerDocument._inc;
1928
+ if (list._inc != inc) {
1929
+ var ls = list._refresh(list._node);
1930
+ __set__(list, "length", ls.length);
1931
+ copy2(ls, list);
1932
+ list._inc = inc;
1933
+ }
1934
+ }
1935
+ LiveNodeList.prototype.item = function(i) {
1936
+ _updateLiveList(this);
1937
+ return this[i];
1938
+ };
1939
+ _extends(LiveNodeList, NodeList);
1940
+ function NamedNodeMap() {
1941
+ }
1942
+ function _findNodeIndex(list, node) {
1943
+ var i = list.length;
1944
+ while (i--) {
1945
+ if (list[i] === node) {
1946
+ return i;
1947
+ }
1948
+ }
1949
+ }
1950
+ function _addNamedNode(el, list, newAttr, oldAttr) {
1951
+ if (oldAttr) {
1952
+ list[_findNodeIndex(list, oldAttr)] = newAttr;
1953
+ } else {
1954
+ list[list.length++] = newAttr;
1955
+ }
1956
+ if (el) {
1957
+ newAttr.ownerElement = el;
1958
+ var doc = el.ownerDocument;
1959
+ if (doc) {
1960
+ oldAttr && _onRemoveAttribute(doc, el, oldAttr);
1961
+ _onAddAttribute(doc, el, newAttr);
1962
+ }
1963
+ }
1964
+ }
1965
+ function _removeNamedNode(el, list, attr) {
1966
+ var i = _findNodeIndex(list, attr);
1967
+ if (i >= 0) {
1968
+ var lastIndex = list.length - 1;
1969
+ while (i < lastIndex) {
1970
+ list[i] = list[++i];
1971
+ }
1972
+ list.length = lastIndex;
1973
+ if (el) {
1974
+ var doc = el.ownerDocument;
1975
+ if (doc) {
1976
+ _onRemoveAttribute(doc, el, attr);
1977
+ attr.ownerElement = null;
1106
1978
  }
1107
1979
  }
1108
- return { line: o2, times: s2, extendedValues: r2 };
1980
+ } else {
1981
+ throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
1109
1982
  }
1110
- function c(e2) {
1111
- const t2 = e2.getElementsByTagName("trkseg"), s2 = [], i2 = [], l2 = [];
1112
- for (let e3 = 0; e3 < t2.length; e3++) {
1113
- const n2 = a(t2[e3], "trkpt");
1114
- n2 && (l2.push(n2), n2.times && n2.times.length && i2.push(n2.times));
1983
+ }
1984
+ NamedNodeMap.prototype = {
1985
+ length: 0,
1986
+ item: NodeList.prototype.item,
1987
+ getNamedItem: function(key) {
1988
+ var i = this.length;
1989
+ while (i--) {
1990
+ var attr = this[i];
1991
+ if (attr.nodeName == key) {
1992
+ return attr;
1993
+ }
1115
1994
  }
1116
- if (l2.length === 0)
1117
- return;
1118
- const c2 = l2.length > 1, g2 = Object.assign(r(e2), o(n(e2, "extensions")), { _gpxType: "trk" }, i2.length ? { coordinateProperties: { times: c2 ? i2 : i2[0] } } : {});
1119
- for (let e3 = 0; e3 < l2.length; e3++) {
1120
- const t3 = l2[e3];
1121
- s2.push(t3.line);
1122
- for (const [n2, o2] of Object.entries(t3.extendedValues)) {
1123
- let t4 = g2;
1124
- n2 === "heart" && (g2.coordinateProperties || (g2.coordinateProperties = {}), t4 = g2.coordinateProperties), c2 ? (t4[n2] || (t4[n2] = l2.map((e4) => new Array(e4.line.length).fill(null))), t4[n2][e3] = o2) : t4[n2] = o2;
1995
+ },
1996
+ setNamedItem: function(attr) {
1997
+ var el = attr.ownerElement;
1998
+ if (el && el != this._ownerElement) {
1999
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
2000
+ }
2001
+ var oldAttr = this.getNamedItem(attr.nodeName);
2002
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
2003
+ return oldAttr;
2004
+ },
2005
+ setNamedItemNS: function(attr) {
2006
+ var el = attr.ownerElement, oldAttr;
2007
+ if (el && el != this._ownerElement) {
2008
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
2009
+ }
2010
+ oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
2011
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
2012
+ return oldAttr;
2013
+ },
2014
+ removeNamedItem: function(key) {
2015
+ var attr = this.getNamedItem(key);
2016
+ _removeNamedNode(this._ownerElement, this, attr);
2017
+ return attr;
2018
+ },
2019
+ removeNamedItemNS: function(namespaceURI, localName) {
2020
+ var attr = this.getNamedItemNS(namespaceURI, localName);
2021
+ _removeNamedNode(this._ownerElement, this, attr);
2022
+ return attr;
2023
+ },
2024
+ getNamedItemNS: function(namespaceURI, localName) {
2025
+ var i = this.length;
2026
+ while (i--) {
2027
+ var node = this[i];
2028
+ if (node.localName == localName && node.namespaceURI == namespaceURI) {
2029
+ return node;
1125
2030
  }
1126
2031
  }
1127
- return { type: "Feature", properties: g2, geometry: c2 ? { type: "MultiLineString", coordinates: s2 } : { type: "LineString", coordinates: s2[0] } };
1128
- }
1129
- function* g(e2) {
1130
- const t2 = e2.getElementsByTagName("trk"), n2 = e2.getElementsByTagName("rte"), o2 = e2.getElementsByTagName("wpt");
1131
- for (let e3 = 0; e3 < t2.length; e3++) {
1132
- const n3 = c(t2[e3]);
1133
- n3 && (yield n3);
1134
- }
1135
- for (let e3 = 0; e3 < n2.length; e3++) {
1136
- const t3 = l(n2[e3]);
1137
- t3 && (yield t3);
1138
- }
1139
- for (let e3 = 0; e3 < o2.length; e3++)
1140
- yield (a2 = o2[e3], { type: "Feature", properties: Object.assign(r(a2), s(a2, ["sym"])), geometry: { type: "Point", coordinates: i(a2).coordinates } });
1141
- var a2;
1142
- }
1143
- const u = [["heartRate", "heartRates"], ["Cadence", "cadences"], ["Speed", "speeds"], ["Watts", "watts"]], m = [["TotalTimeSeconds", "totalTimeSeconds"], ["DistanceMeters", "distanceMeters"], ["MaximumSpeed", "maxSpeed"], ["AverageHeartRateBpm", "avgHeartRate"], ["MaximumHeartRateBpm", "maxHeartRate"], ["AvgSpeed", "avgSpeed"], ["AvgWatts", "avgWatts"], ["MaxWatts", "maxWatts"]];
1144
- function p(e2, o2) {
1145
- const s2 = [];
1146
- for (const [r2, i2] of o2) {
1147
- let o3 = n(e2, r2);
1148
- if (!o3) {
1149
- const t2 = e2.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/ActivityExtension/v2", r2);
1150
- t2.length && (o3 = t2[0]);
2032
+ return null;
2033
+ }
2034
+ };
2035
+ function DOMImplementation() {
2036
+ }
2037
+ DOMImplementation.prototype = {
2038
+ hasFeature: function(feature, version) {
2039
+ return true;
2040
+ },
2041
+ createDocument: function(namespaceURI, qualifiedName, doctype) {
2042
+ var doc = new Document();
2043
+ doc.implementation = this;
2044
+ doc.childNodes = new NodeList();
2045
+ doc.doctype = doctype || null;
2046
+ if (doctype) {
2047
+ doc.appendChild(doctype);
2048
+ }
2049
+ if (qualifiedName) {
2050
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
2051
+ doc.appendChild(root);
2052
+ }
2053
+ return doc;
2054
+ },
2055
+ createDocumentType: function(qualifiedName, publicId, systemId) {
2056
+ var node = new DocumentType();
2057
+ node.name = qualifiedName;
2058
+ node.nodeName = qualifiedName;
2059
+ node.publicId = publicId || "";
2060
+ node.systemId = systemId || "";
2061
+ return node;
2062
+ }
2063
+ };
2064
+ function Node2() {
2065
+ }
2066
+ Node2.prototype = {
2067
+ firstChild: null,
2068
+ lastChild: null,
2069
+ previousSibling: null,
2070
+ nextSibling: null,
2071
+ attributes: null,
2072
+ parentNode: null,
2073
+ childNodes: null,
2074
+ ownerDocument: null,
2075
+ nodeValue: null,
2076
+ namespaceURI: null,
2077
+ prefix: null,
2078
+ localName: null,
2079
+ insertBefore: function(newChild, refChild) {
2080
+ return _insertBefore(this, newChild, refChild);
2081
+ },
2082
+ replaceChild: function(newChild, oldChild) {
2083
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
2084
+ if (oldChild) {
2085
+ this.removeChild(oldChild);
2086
+ }
2087
+ },
2088
+ removeChild: function(oldChild) {
2089
+ return _removeChild(this, oldChild);
2090
+ },
2091
+ appendChild: function(newChild) {
2092
+ return this.insertBefore(newChild, null);
2093
+ },
2094
+ hasChildNodes: function() {
2095
+ return this.firstChild != null;
2096
+ },
2097
+ cloneNode: function(deep) {
2098
+ return cloneNode(this.ownerDocument || this, this, deep);
2099
+ },
2100
+ normalize: function() {
2101
+ var child = this.firstChild;
2102
+ while (child) {
2103
+ var next = child.nextSibling;
2104
+ if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
2105
+ this.removeChild(next);
2106
+ child.appendData(next.data);
2107
+ } else {
2108
+ child.normalize();
2109
+ child = next;
1151
2110
  }
1152
- const l2 = parseFloat(t(o3));
1153
- isNaN(l2) || s2.push([i2, l2]);
1154
- }
1155
- return s2;
1156
- }
1157
- function h(e2) {
1158
- const o2 = t(n(e2, "LongitudeDegrees")), s2 = t(n(e2, "LatitudeDegrees"));
1159
- if (!o2.length || !s2.length)
1160
- return null;
1161
- const r2 = [parseFloat(o2), parseFloat(s2)], i2 = n(e2, "AltitudeMeters"), l2 = n(e2, "HeartRateBpm"), a2 = n(e2, "Time");
1162
- let c2;
1163
- return i2 && (c2 = parseFloat(t(i2)), isNaN(c2) || r2.push(c2)), { coordinates: r2, time: a2 ? t(a2) : null, heartRate: l2 ? parseFloat(t(l2)) : null, extensions: p(e2, u) };
1164
- }
1165
- function f(e2, t2) {
1166
- const n2 = e2.getElementsByTagName(t2), o2 = [], s2 = [], r2 = [];
1167
- if (n2.length < 2)
1168
- return null;
1169
- const i2 = { extendedProperties: {} };
1170
- for (let e3 = 0; e3 < n2.length; e3++) {
1171
- const t3 = h(n2[e3]);
1172
- if (t3 !== null) {
1173
- o2.push(t3.coordinates), t3.time && s2.push(t3.time), t3.heartRate && r2.push(t3.heartRate);
1174
- for (const [o3, s3] of t3.extensions)
1175
- i2.extendedProperties[o3] || (i2.extendedProperties[o3] = Array(n2.length).fill(null)), i2.extendedProperties[o3][e3] = s3;
2111
+ }
2112
+ },
2113
+ isSupported: function(feature, version) {
2114
+ return this.ownerDocument.implementation.hasFeature(feature, version);
2115
+ },
2116
+ hasAttributes: function() {
2117
+ return this.attributes.length > 0;
2118
+ },
2119
+ lookupPrefix: function(namespaceURI) {
2120
+ var el = this;
2121
+ while (el) {
2122
+ var map = el._nsMap;
2123
+ if (map) {
2124
+ for (var n in map) {
2125
+ if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
2126
+ return n;
2127
+ }
2128
+ }
1176
2129
  }
2130
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
1177
2131
  }
1178
- return Object.assign(i2, { line: o2, times: s2, heartRates: r2 });
1179
- }
1180
- function d(e2) {
1181
- const o2 = e2.getElementsByTagName("Track"), s2 = [], r2 = [], i2 = [], l2 = [];
1182
- let a2;
1183
- const c2 = function(e3) {
1184
- const t2 = {};
1185
- for (const [n2, o3] of e3)
1186
- t2[n2] = o3;
1187
- return t2;
1188
- }(p(e2, m)), g2 = n(e2, "Name");
1189
- g2 && (c2.name = t(g2));
1190
- for (let e3 = 0; e3 < o2.length; e3++)
1191
- a2 = f(o2[e3], "Trackpoint"), a2 && (s2.push(a2.line), a2.times.length && r2.push(a2.times), a2.heartRates.length && i2.push(a2.heartRates), l2.push(a2.extendedProperties));
1192
- for (let e3 = 0; e3 < l2.length; e3++) {
1193
- const t2 = l2[e3];
1194
- for (const n2 in t2)
1195
- o2.length === 1 ? c2[n2] = a2.extendedProperties[n2] : (c2[n2] || (c2[n2] = s2.map((e4) => Array(e4.length).fill(null))), c2[n2][e3] = t2[n2]);
1196
- }
1197
- if (s2.length !== 0)
1198
- return (r2.length || i2.length) && (c2.coordinateProperties = Object.assign(r2.length ? { times: s2.length === 1 ? r2[0] : r2 } : {}, i2.length ? { heart: s2.length === 1 ? i2[0] : i2 } : {})), { type: "Feature", properties: c2, geometry: { type: s2.length === 1 ? "LineString" : "MultiLineString", coordinates: s2.length === 1 ? s2[0] : s2 } };
1199
- }
1200
- function* y(e2) {
1201
- const t2 = e2.getElementsByTagName("Lap");
1202
- for (let e3 = 0; e3 < t2.length; e3++) {
1203
- const n3 = d(t2[e3]);
1204
- n3 && (yield n3);
1205
- }
1206
- const n2 = e2.getElementsByTagName("Courses");
1207
- for (let e3 = 0; e3 < n2.length; e3++) {
1208
- const t3 = d(n2[e3]);
1209
- t3 && (yield t3);
1210
- }
1211
- }
1212
- const N = /\s*/g, x = /^\s*|\s*$/g, T = /\s+/;
1213
- function b(e2) {
1214
- if (!e2 || !e2.length)
1215
- return 0;
1216
- let t2 = 0;
1217
- for (let n2 = 0; n2 < e2.length; n2++)
1218
- t2 = (t2 << 5) - t2 + e2.charCodeAt(n2) | 0;
1219
- return t2;
1220
- }
1221
- function S(e2) {
1222
- return e2.replace(N, "").split(",").map(parseFloat);
1223
- }
1224
- function k(e2) {
1225
- return e2.replace(x, "").split(T).map(S);
1226
- }
1227
- function A(e2) {
1228
- if (e2.xml !== void 0)
1229
- return e2.xml;
1230
- if (e2.tagName) {
1231
- let t2 = e2.tagName;
1232
- for (let n2 = 0; n2 < e2.attributes.length; n2++)
1233
- t2 += e2.attributes[n2].name + e2.attributes[n2].value;
1234
- for (let n2 = 0; n2 < e2.childNodes.length; n2++)
1235
- t2 += A(e2.childNodes[n2]);
1236
- return t2;
1237
- }
1238
- return e2.nodeName === "#text" ? (e2.nodeValue || e2.value || "").trim() : e2.nodeName === "#cdata-section" ? e2.nodeValue : "";
1239
- }
1240
- const B = ["Polygon", "LineString", "Point", "Track", "gx:Track"];
1241
- function E(e2, o2, s2) {
1242
- let r2 = t(n(o2, "color")) || "";
1243
- const i2 = s2 == "stroke" || s2 === "fill" ? s2 : s2 + "-color";
1244
- r2.substr(0, 1) === "#" && (r2 = r2.substr(1)), r2.length === 6 || r2.length === 3 ? e2[i2] = r2 : r2.length === 8 && (e2[s2 + "-opacity"] = parseInt(r2.substr(0, 2), 16) / 255, e2[i2] = "#" + r2.substr(6, 2) + r2.substr(4, 2) + r2.substr(2, 2));
1245
- }
1246
- function F(e2, o2, s2, r2) {
1247
- const i2 = parseFloat(t(n(o2, s2)));
1248
- isNaN(i2) || (e2[r2] = i2);
1249
- }
1250
- function P(e2) {
1251
- let n2 = e2.getElementsByTagName("coord");
1252
- const o2 = [], s2 = [];
1253
- n2.length === 0 && (n2 = e2.getElementsByTagName("gx:coord"));
1254
- for (let e3 = 0; e3 < n2.length; e3++)
1255
- o2.push(t(n2[e3]).split(" ").map(parseFloat));
1256
- const r2 = e2.getElementsByTagName("when");
1257
- for (let e3 = 0; e3 < r2.length; e3++)
1258
- s2.push(t(r2[e3]));
1259
- return { coords: o2, times: s2 };
1260
- }
1261
- function v(e2) {
1262
- let o2, s2, r2, i2, l2;
1263
- const a2 = [], c2 = [];
1264
- if (n(e2, "MultiGeometry"))
1265
- return v(n(e2, "MultiGeometry"));
1266
- if (n(e2, "MultiTrack"))
1267
- return v(n(e2, "MultiTrack"));
1268
- if (n(e2, "gx:MultiTrack"))
1269
- return v(n(e2, "gx:MultiTrack"));
1270
- for (r2 = 0; r2 < B.length; r2++)
1271
- if (s2 = e2.getElementsByTagName(B[r2]), s2) {
1272
- for (i2 = 0; i2 < s2.length; i2++)
1273
- if (o2 = s2[i2], B[r2] === "Point")
1274
- a2.push({ type: "Point", coordinates: S(t(n(o2, "coordinates"))) });
1275
- else if (B[r2] === "LineString")
1276
- a2.push({ type: "LineString", coordinates: k(t(n(o2, "coordinates"))) });
1277
- else if (B[r2] === "Polygon") {
1278
- const e3 = o2.getElementsByTagName("LinearRing"), s3 = [];
1279
- for (l2 = 0; l2 < e3.length; l2++)
1280
- s3.push(k(t(n(e3[l2], "coordinates"))));
1281
- a2.push({ type: "Polygon", coordinates: s3 });
1282
- } else if (B[r2] === "Track" || B[r2] === "gx:Track") {
1283
- const e3 = P(o2);
1284
- a2.push({ type: "LineString", coordinates: e3.coords }), e3.times.length && c2.push(e3.times);
2132
+ return null;
2133
+ },
2134
+ lookupNamespaceURI: function(prefix) {
2135
+ var el = this;
2136
+ while (el) {
2137
+ var map = el._nsMap;
2138
+ if (map) {
2139
+ if (prefix in map) {
2140
+ if (Object.prototype.hasOwnProperty.call(map, prefix)) {
2141
+ return map[prefix];
1285
2142
  }
2143
+ }
1286
2144
  }
1287
- return { geoms: a2, coordTimes: c2 };
1288
- }
1289
- function L(e2, o2, s2, r2) {
1290
- const i2 = v(e2);
1291
- let l2;
1292
- const a2 = {}, c2 = t(n(e2, "name")), g2 = t(n(e2, "address"));
1293
- let u2 = t(n(e2, "styleUrl"));
1294
- const m2 = t(n(e2, "description")), p2 = n(e2, "TimeSpan"), h2 = n(e2, "TimeStamp"), f2 = n(e2, "ExtendedData");
1295
- let d2 = n(e2, "IconStyle"), y2 = n(e2, "LabelStyle"), N2 = n(e2, "LineStyle"), x2 = n(e2, "PolyStyle");
1296
- const T2 = n(e2, "visibility");
1297
- if (c2 && (a2.name = c2), g2 && (a2.address = g2), u2) {
1298
- u2[0] !== "#" && (u2 = "#" + u2), a2.styleUrl = u2, o2[u2] && (a2.styleHash = o2[u2]), s2[u2] && (a2.styleMapHash = s2[u2], a2.styleHash = o2[s2[u2].normal]);
1299
- const e3 = r2[a2.styleHash];
1300
- e3 && (d2 || (d2 = n(e3, "IconStyle")), y2 || (y2 = n(e3, "LabelStyle")), N2 || (N2 = n(e3, "LineStyle")), x2 || (x2 = n(e3, "PolyStyle")));
1301
- }
1302
- if (m2 && (a2.description = m2), p2) {
1303
- const e3 = t(n(p2, "begin")), o3 = t(n(p2, "end"));
1304
- a2.timespan = { begin: e3, end: o3 };
1305
- }
1306
- if (h2 && (a2.timestamp = t(n(h2, "when"))), d2) {
1307
- E(a2, d2, "icon"), F(a2, d2, "scale", "icon-scale"), F(a2, d2, "heading", "icon-heading");
1308
- const e3 = n(d2, "hotSpot");
1309
- if (e3) {
1310
- const t2 = parseFloat(e3.getAttribute("x")), n2 = parseFloat(e3.getAttribute("y"));
1311
- isNaN(t2) || isNaN(n2) || (a2["icon-offset"] = [t2, n2]);
2145
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
2146
+ }
2147
+ return null;
2148
+ },
2149
+ isDefaultNamespace: function(namespaceURI) {
2150
+ var prefix = this.lookupPrefix(namespaceURI);
2151
+ return prefix == null;
2152
+ }
2153
+ };
2154
+ function _xmlEncoder(c) {
2155
+ return c == "<" && "&lt;" || c == ">" && "&gt;" || c == "&" && "&amp;" || c == '"' && "&quot;" || "&#" + c.charCodeAt() + ";";
2156
+ }
2157
+ copy2(NodeType, Node2);
2158
+ copy2(NodeType, Node2.prototype);
2159
+ function _visitNode(node, callback) {
2160
+ if (callback(node)) {
2161
+ return true;
2162
+ }
2163
+ if (node = node.firstChild) {
2164
+ do {
2165
+ if (_visitNode(node, callback)) {
2166
+ return true;
1312
2167
  }
1313
- const o3 = n(d2, "Icon");
1314
- if (o3) {
1315
- const e4 = t(n(o3, "href"));
1316
- e4 && (a2.icon = e4);
2168
+ } while (node = node.nextSibling);
2169
+ }
2170
+ }
2171
+ function Document() {
2172
+ this.ownerDocument = this;
2173
+ }
2174
+ function _onAddAttribute(doc, el, newAttr) {
2175
+ doc && doc._inc++;
2176
+ var ns = newAttr.namespaceURI;
2177
+ if (ns === NAMESPACE.XMLNS) {
2178
+ el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
2179
+ }
2180
+ }
2181
+ function _onRemoveAttribute(doc, el, newAttr, remove) {
2182
+ doc && doc._inc++;
2183
+ var ns = newAttr.namespaceURI;
2184
+ if (ns === NAMESPACE.XMLNS) {
2185
+ delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
2186
+ }
2187
+ }
2188
+ function _onUpdateChild(doc, el, newChild) {
2189
+ if (doc && doc._inc) {
2190
+ doc._inc++;
2191
+ var cs = el.childNodes;
2192
+ if (newChild) {
2193
+ cs[cs.length++] = newChild;
2194
+ } else {
2195
+ var child = el.firstChild;
2196
+ var i = 0;
2197
+ while (child) {
2198
+ cs[i++] = child;
2199
+ child = child.nextSibling;
1317
2200
  }
2201
+ cs.length = i;
2202
+ delete cs[cs.length];
1318
2203
  }
1319
- if (y2 && (E(a2, y2, "label"), F(a2, y2, "scale", "label-scale")), N2 && (E(a2, N2, "stroke"), F(a2, N2, "width", "stroke-width")), x2) {
1320
- E(a2, x2, "fill");
1321
- const e3 = t(n(x2, "fill")), o3 = t(n(x2, "outline"));
1322
- e3 && (a2["fill-opacity"] = e3 === "1" ? a2["fill-opacity"] || 1 : 0), o3 && (a2["stroke-opacity"] = o3 === "1" ? a2["stroke-opacity"] || 1 : 0);
1323
- }
1324
- if (f2) {
1325
- const e3 = f2.getElementsByTagName("Data"), o3 = f2.getElementsByTagName("SimpleData");
1326
- for (l2 = 0; l2 < e3.length; l2++)
1327
- a2[e3[l2].getAttribute("name")] = t(n(e3[l2], "value"));
1328
- for (l2 = 0; l2 < o3.length; l2++)
1329
- a2[o3[l2].getAttribute("name")] = t(o3[l2]);
1330
- }
1331
- T2 && (a2.visibility = t(T2)), i2.coordTimes.length && (a2.coordinateProperties = { times: i2.coordTimes.length === 1 ? i2.coordTimes[0] : i2.coordTimes });
1332
- const b2 = { type: "Feature", geometry: i2.geoms.length === 0 ? null : i2.geoms.length === 1 ? i2.geoms[0] : { type: "GeometryCollection", geometries: i2.geoms }, properties: a2 };
1333
- return e2.getAttribute("id") && (b2.id = e2.getAttribute("id")), b2;
1334
- }
1335
- function* M(e2) {
1336
- const o2 = {}, s2 = {}, r2 = {}, i2 = e2.getElementsByTagName("Placemark"), l2 = e2.getElementsByTagName("Style"), a2 = e2.getElementsByTagName("StyleMap");
1337
- for (let e3 = 0; e3 < l2.length; e3++) {
1338
- const t2 = b(A(l2[e3])).toString(16);
1339
- o2["#" + l2[e3].getAttribute("id")] = t2, s2[t2] = l2[e3];
1340
- }
1341
- for (let e3 = 0; e3 < a2.length; e3++) {
1342
- o2["#" + a2[e3].getAttribute("id")] = b(A(a2[e3])).toString(16);
1343
- const s3 = a2[e3].getElementsByTagName("Pair"), i3 = {};
1344
- for (let e4 = 0; e4 < s3.length; e4++)
1345
- i3[t(n(s3[e4], "key"))] = t(n(s3[e4], "styleUrl"));
1346
- r2["#" + a2[e3].getAttribute("id")] = i3;
1347
- }
1348
- for (let e3 = 0; e3 < i2.length; e3++) {
1349
- const t2 = L(i2[e3], o2, r2, s2);
1350
- t2 && (yield t2);
1351
- }
1352
- }
1353
- e.gpx = function(e2) {
1354
- return { type: "FeatureCollection", features: Array.from(g(e2)) };
1355
- }, e.gpxGen = g, e.kml = function(e2) {
1356
- return { type: "FeatureCollection", features: Array.from(M(e2)) };
1357
- }, e.kmlGen = M, e.tcx = function(e2) {
1358
- return { type: "FeatureCollection", features: Array.from(y(e2)) };
1359
- }, e.tcxGen = y, Object.defineProperty(e, "__esModule", { value: true });
1360
- });
1361
- }
1362
- });
1363
-
1364
- // src/gpx-loader.ts
1365
- function parseTextSync(text, options) {
1366
- const doc = new DOMParser().parseFromString(text, "text/xml");
1367
- const geojson = (0, import_togeojson.gpx)(doc);
1368
- switch (options?.gpx?.type) {
1369
- case "object-row-table":
1370
- return geojson.features;
1371
- default:
1372
- }
1373
- switch (options?.gis?.format) {
1374
- case "geojson":
1375
- return geojson;
1376
- case "binary":
1377
- return geojsonToBinary(geojson.features);
1378
- case "raw":
2204
+ }
2205
+ }
2206
+ function _removeChild(parentNode, child) {
2207
+ var previous = child.previousSibling;
2208
+ var next = child.nextSibling;
2209
+ if (previous) {
2210
+ previous.nextSibling = next;
2211
+ } else {
2212
+ parentNode.firstChild = next;
2213
+ }
2214
+ if (next) {
2215
+ next.previousSibling = previous;
2216
+ } else {
2217
+ parentNode.lastChild = previous;
2218
+ }
2219
+ child.parentNode = null;
2220
+ child.previousSibling = null;
2221
+ child.nextSibling = null;
2222
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
2223
+ return child;
2224
+ }
2225
+ function hasValidParentNodeType(node) {
2226
+ return node && (node.nodeType === Node2.DOCUMENT_NODE || node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node2.ELEMENT_NODE);
2227
+ }
2228
+ function hasInsertableNodeType(node) {
2229
+ return node && (isElementNode(node) || isTextNode(node) || isDocTypeNode(node) || node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node2.COMMENT_NODE || node.nodeType === Node2.PROCESSING_INSTRUCTION_NODE);
2230
+ }
2231
+ function isDocTypeNode(node) {
2232
+ return node && node.nodeType === Node2.DOCUMENT_TYPE_NODE;
2233
+ }
2234
+ function isElementNode(node) {
2235
+ return node && node.nodeType === Node2.ELEMENT_NODE;
2236
+ }
2237
+ function isTextNode(node) {
2238
+ return node && node.nodeType === Node2.TEXT_NODE;
2239
+ }
2240
+ function isElementInsertionPossible(doc, child) {
2241
+ var parentChildNodes = doc.childNodes || [];
2242
+ if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
2243
+ return false;
2244
+ }
2245
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
2246
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
2247
+ }
2248
+ function isElementReplacementPossible(doc, child) {
2249
+ var parentChildNodes = doc.childNodes || [];
2250
+ function hasElementChildThatIsNotChild(node) {
2251
+ return isElementNode(node) && node !== child;
2252
+ }
2253
+ if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
2254
+ return false;
2255
+ }
2256
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
2257
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
2258
+ }
2259
+ function assertPreInsertionValidity1to5(parent, node, child) {
2260
+ if (!hasValidParentNodeType(parent)) {
2261
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected parent node type " + parent.nodeType);
2262
+ }
2263
+ if (child && child.parentNode !== parent) {
2264
+ throw new DOMException(NOT_FOUND_ERR, "child not in parent");
2265
+ }
2266
+ if (!hasInsertableNodeType(node) || isDocTypeNode(node) && parent.nodeType !== Node2.DOCUMENT_NODE) {
2267
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Unexpected node type " + node.nodeType + " for parent node type " + parent.nodeType);
2268
+ }
2269
+ }
2270
+ function assertPreInsertionValidityInDocument(parent, node, child) {
2271
+ var parentChildNodes = parent.childNodes || [];
2272
+ var nodeChildNodes = node.childNodes || [];
2273
+ if (node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE) {
2274
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
2275
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
2276
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
2277
+ }
2278
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
2279
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
2280
+ }
2281
+ }
2282
+ if (isElementNode(node)) {
2283
+ if (!isElementInsertionPossible(parent, child)) {
2284
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
2285
+ }
2286
+ }
2287
+ if (isDocTypeNode(node)) {
2288
+ if (find(parentChildNodes, isDocTypeNode)) {
2289
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
2290
+ }
2291
+ var parentElementChild = find(parentChildNodes, isElementNode);
2292
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
2293
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
2294
+ }
2295
+ if (!child && parentElementChild) {
2296
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can not be appended since element is present");
2297
+ }
2298
+ }
2299
+ }
2300
+ function assertPreReplacementValidityInDocument(parent, node, child) {
2301
+ var parentChildNodes = parent.childNodes || [];
2302
+ var nodeChildNodes = node.childNodes || [];
2303
+ if (node.nodeType === Node2.DOCUMENT_FRAGMENT_NODE) {
2304
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
2305
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
2306
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "More than one element or text in fragment");
2307
+ }
2308
+ if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
2309
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Element in fragment can not be inserted before doctype");
2310
+ }
2311
+ }
2312
+ if (isElementNode(node)) {
2313
+ if (!isElementReplacementPossible(parent, child)) {
2314
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one element can be added and only after doctype");
2315
+ }
2316
+ }
2317
+ if (isDocTypeNode(node)) {
2318
+ let hasDoctypeChildThatIsNotChild2 = function(node2) {
2319
+ return isDocTypeNode(node2) && node2 !== child;
2320
+ };
2321
+ var hasDoctypeChildThatIsNotChild = hasDoctypeChildThatIsNotChild2;
2322
+ if (find(parentChildNodes, hasDoctypeChildThatIsNotChild2)) {
2323
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Only one doctype is allowed");
2324
+ }
2325
+ var parentElementChild = find(parentChildNodes, isElementNode);
2326
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
2327
+ throw new DOMException(HIERARCHY_REQUEST_ERR, "Doctype can only be inserted before an element");
2328
+ }
2329
+ }
2330
+ }
2331
+ function _insertBefore(parent, node, child, _inDocumentAssertion) {
2332
+ assertPreInsertionValidity1to5(parent, node, child);
2333
+ if (parent.nodeType === Node2.DOCUMENT_NODE) {
2334
+ (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
2335
+ }
2336
+ var cp = node.parentNode;
2337
+ if (cp) {
2338
+ cp.removeChild(node);
2339
+ }
2340
+ if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
2341
+ var newFirst = node.firstChild;
2342
+ if (newFirst == null) {
2343
+ return node;
2344
+ }
2345
+ var newLast = node.lastChild;
2346
+ } else {
2347
+ newFirst = newLast = node;
2348
+ }
2349
+ var pre = child ? child.previousSibling : parent.lastChild;
2350
+ newFirst.previousSibling = pre;
2351
+ newLast.nextSibling = child;
2352
+ if (pre) {
2353
+ pre.nextSibling = newFirst;
2354
+ } else {
2355
+ parent.firstChild = newFirst;
2356
+ }
2357
+ if (child == null) {
2358
+ parent.lastChild = newLast;
2359
+ } else {
2360
+ child.previousSibling = newLast;
2361
+ }
2362
+ do {
2363
+ newFirst.parentNode = parent;
2364
+ } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
2365
+ _onUpdateChild(parent.ownerDocument || parent, parent);
2366
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
2367
+ node.firstChild = node.lastChild = null;
2368
+ }
2369
+ return node;
2370
+ }
2371
+ function _appendSingleChild(parentNode, newChild) {
2372
+ if (newChild.parentNode) {
2373
+ newChild.parentNode.removeChild(newChild);
2374
+ }
2375
+ newChild.parentNode = parentNode;
2376
+ newChild.previousSibling = parentNode.lastChild;
2377
+ newChild.nextSibling = null;
2378
+ if (newChild.previousSibling) {
2379
+ newChild.previousSibling.nextSibling = newChild;
2380
+ } else {
2381
+ parentNode.firstChild = newChild;
2382
+ }
2383
+ parentNode.lastChild = newChild;
2384
+ _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
2385
+ return newChild;
2386
+ }
2387
+ Document.prototype = {
2388
+ nodeName: "#document",
2389
+ nodeType: DOCUMENT_NODE,
2390
+ doctype: null,
2391
+ documentElement: null,
2392
+ _inc: 1,
2393
+ insertBefore: function(newChild, refChild) {
2394
+ if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
2395
+ var child = newChild.firstChild;
2396
+ while (child) {
2397
+ var next = child.nextSibling;
2398
+ this.insertBefore(child, refChild);
2399
+ child = next;
2400
+ }
2401
+ return newChild;
2402
+ }
2403
+ _insertBefore(this, newChild, refChild);
2404
+ newChild.ownerDocument = this;
2405
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
2406
+ this.documentElement = newChild;
2407
+ }
2408
+ return newChild;
2409
+ },
2410
+ removeChild: function(oldChild) {
2411
+ if (this.documentElement == oldChild) {
2412
+ this.documentElement = null;
2413
+ }
2414
+ return _removeChild(this, oldChild);
2415
+ },
2416
+ replaceChild: function(newChild, oldChild) {
2417
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
2418
+ newChild.ownerDocument = this;
2419
+ if (oldChild) {
2420
+ this.removeChild(oldChild);
2421
+ }
2422
+ if (isElementNode(newChild)) {
2423
+ this.documentElement = newChild;
2424
+ }
2425
+ },
2426
+ importNode: function(importedNode, deep) {
2427
+ return importNode(this, importedNode, deep);
2428
+ },
2429
+ getElementById: function(id) {
2430
+ var rtv = null;
2431
+ _visitNode(this.documentElement, function(node) {
2432
+ if (node.nodeType == ELEMENT_NODE) {
2433
+ if (node.getAttribute("id") == id) {
2434
+ rtv = node;
2435
+ return true;
2436
+ }
2437
+ }
2438
+ });
2439
+ return rtv;
2440
+ },
2441
+ getElementsByClassName: function(classNames) {
2442
+ var classNamesSet = toOrderedSet(classNames);
2443
+ return new LiveNodeList(this, function(base) {
2444
+ var ls = [];
2445
+ if (classNamesSet.length > 0) {
2446
+ _visitNode(base.documentElement, function(node) {
2447
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
2448
+ var nodeClassNames = node.getAttribute("class");
2449
+ if (nodeClassNames) {
2450
+ var matches = classNames === nodeClassNames;
2451
+ if (!matches) {
2452
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
2453
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
2454
+ }
2455
+ if (matches) {
2456
+ ls.push(node);
2457
+ }
2458
+ }
2459
+ }
2460
+ });
2461
+ }
2462
+ return ls;
2463
+ });
2464
+ },
2465
+ createElement: function(tagName) {
2466
+ var node = new Element();
2467
+ node.ownerDocument = this;
2468
+ node.nodeName = tagName;
2469
+ node.tagName = tagName;
2470
+ node.localName = tagName;
2471
+ node.childNodes = new NodeList();
2472
+ var attrs = node.attributes = new NamedNodeMap();
2473
+ attrs._ownerElement = node;
2474
+ return node;
2475
+ },
2476
+ createDocumentFragment: function() {
2477
+ var node = new DocumentFragment();
2478
+ node.ownerDocument = this;
2479
+ node.childNodes = new NodeList();
2480
+ return node;
2481
+ },
2482
+ createTextNode: function(data) {
2483
+ var node = new Text();
2484
+ node.ownerDocument = this;
2485
+ node.appendData(data);
2486
+ return node;
2487
+ },
2488
+ createComment: function(data) {
2489
+ var node = new Comment();
2490
+ node.ownerDocument = this;
2491
+ node.appendData(data);
2492
+ return node;
2493
+ },
2494
+ createCDATASection: function(data) {
2495
+ var node = new CDATASection();
2496
+ node.ownerDocument = this;
2497
+ node.appendData(data);
2498
+ return node;
2499
+ },
2500
+ createProcessingInstruction: function(target, data) {
2501
+ var node = new ProcessingInstruction();
2502
+ node.ownerDocument = this;
2503
+ node.tagName = node.target = target;
2504
+ node.nodeValue = node.data = data;
2505
+ return node;
2506
+ },
2507
+ createAttribute: function(name) {
2508
+ var node = new Attr();
2509
+ node.ownerDocument = this;
2510
+ node.name = name;
2511
+ node.nodeName = name;
2512
+ node.localName = name;
2513
+ node.specified = true;
2514
+ return node;
2515
+ },
2516
+ createEntityReference: function(name) {
2517
+ var node = new EntityReference();
2518
+ node.ownerDocument = this;
2519
+ node.nodeName = name;
2520
+ return node;
2521
+ },
2522
+ createElementNS: function(namespaceURI, qualifiedName) {
2523
+ var node = new Element();
2524
+ var pl = qualifiedName.split(":");
2525
+ var attrs = node.attributes = new NamedNodeMap();
2526
+ node.childNodes = new NodeList();
2527
+ node.ownerDocument = this;
2528
+ node.nodeName = qualifiedName;
2529
+ node.tagName = qualifiedName;
2530
+ node.namespaceURI = namespaceURI;
2531
+ if (pl.length == 2) {
2532
+ node.prefix = pl[0];
2533
+ node.localName = pl[1];
2534
+ } else {
2535
+ node.localName = qualifiedName;
2536
+ }
2537
+ attrs._ownerElement = node;
2538
+ return node;
2539
+ },
2540
+ createAttributeNS: function(namespaceURI, qualifiedName) {
2541
+ var node = new Attr();
2542
+ var pl = qualifiedName.split(":");
2543
+ node.ownerDocument = this;
2544
+ node.nodeName = qualifiedName;
2545
+ node.name = qualifiedName;
2546
+ node.namespaceURI = namespaceURI;
2547
+ node.specified = true;
2548
+ if (pl.length == 2) {
2549
+ node.prefix = pl[0];
2550
+ node.localName = pl[1];
2551
+ } else {
2552
+ node.localName = qualifiedName;
2553
+ }
2554
+ return node;
2555
+ }
2556
+ };
2557
+ _extends(Document, Node2);
2558
+ function Element() {
2559
+ this._nsMap = {};
2560
+ }
2561
+ Element.prototype = {
2562
+ nodeType: ELEMENT_NODE,
2563
+ hasAttribute: function(name) {
2564
+ return this.getAttributeNode(name) != null;
2565
+ },
2566
+ getAttribute: function(name) {
2567
+ var attr = this.getAttributeNode(name);
2568
+ return attr && attr.value || "";
2569
+ },
2570
+ getAttributeNode: function(name) {
2571
+ return this.attributes.getNamedItem(name);
2572
+ },
2573
+ setAttribute: function(name, value) {
2574
+ var attr = this.ownerDocument.createAttribute(name);
2575
+ attr.value = attr.nodeValue = "" + value;
2576
+ this.setAttributeNode(attr);
2577
+ },
2578
+ removeAttribute: function(name) {
2579
+ var attr = this.getAttributeNode(name);
2580
+ attr && this.removeAttributeNode(attr);
2581
+ },
2582
+ appendChild: function(newChild) {
2583
+ if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
2584
+ return this.insertBefore(newChild, null);
2585
+ } else {
2586
+ return _appendSingleChild(this, newChild);
2587
+ }
2588
+ },
2589
+ setAttributeNode: function(newAttr) {
2590
+ return this.attributes.setNamedItem(newAttr);
2591
+ },
2592
+ setAttributeNodeNS: function(newAttr) {
2593
+ return this.attributes.setNamedItemNS(newAttr);
2594
+ },
2595
+ removeAttributeNode: function(oldAttr) {
2596
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
2597
+ },
2598
+ removeAttributeNS: function(namespaceURI, localName) {
2599
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
2600
+ old && this.removeAttributeNode(old);
2601
+ },
2602
+ hasAttributeNS: function(namespaceURI, localName) {
2603
+ return this.getAttributeNodeNS(namespaceURI, localName) != null;
2604
+ },
2605
+ getAttributeNS: function(namespaceURI, localName) {
2606
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
2607
+ return attr && attr.value || "";
2608
+ },
2609
+ setAttributeNS: function(namespaceURI, qualifiedName, value) {
2610
+ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
2611
+ attr.value = attr.nodeValue = "" + value;
2612
+ this.setAttributeNode(attr);
2613
+ },
2614
+ getAttributeNodeNS: function(namespaceURI, localName) {
2615
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
2616
+ },
2617
+ getElementsByTagName: function(tagName) {
2618
+ return new LiveNodeList(this, function(base) {
2619
+ var ls = [];
2620
+ _visitNode(base, function(node) {
2621
+ if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
2622
+ ls.push(node);
2623
+ }
2624
+ });
2625
+ return ls;
2626
+ });
2627
+ },
2628
+ getElementsByTagNameNS: function(namespaceURI, localName) {
2629
+ return new LiveNodeList(this, function(base) {
2630
+ var ls = [];
2631
+ _visitNode(base, function(node) {
2632
+ if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
2633
+ ls.push(node);
2634
+ }
2635
+ });
2636
+ return ls;
2637
+ });
2638
+ }
2639
+ };
2640
+ Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
2641
+ Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
2642
+ _extends(Element, Node2);
2643
+ function Attr() {
2644
+ }
2645
+ Attr.prototype.nodeType = ATTRIBUTE_NODE;
2646
+ _extends(Attr, Node2);
2647
+ function CharacterData() {
2648
+ }
2649
+ CharacterData.prototype = {
2650
+ data: "",
2651
+ substringData: function(offset, count) {
2652
+ return this.data.substring(offset, offset + count);
2653
+ },
2654
+ appendData: function(text) {
2655
+ text = this.data + text;
2656
+ this.nodeValue = this.data = text;
2657
+ this.length = text.length;
2658
+ },
2659
+ insertData: function(offset, text) {
2660
+ this.replaceData(offset, 0, text);
2661
+ },
2662
+ appendChild: function(newChild) {
2663
+ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
2664
+ },
2665
+ deleteData: function(offset, count) {
2666
+ this.replaceData(offset, count, "");
2667
+ },
2668
+ replaceData: function(offset, count, text) {
2669
+ var start = this.data.substring(0, offset);
2670
+ var end = this.data.substring(offset + count);
2671
+ text = start + text + end;
2672
+ this.nodeValue = this.data = text;
2673
+ this.length = text.length;
2674
+ }
2675
+ };
2676
+ _extends(CharacterData, Node2);
2677
+ function Text() {
2678
+ }
2679
+ Text.prototype = {
2680
+ nodeName: "#text",
2681
+ nodeType: TEXT_NODE,
2682
+ splitText: function(offset) {
2683
+ var text = this.data;
2684
+ var newText = text.substring(offset);
2685
+ text = text.substring(0, offset);
2686
+ this.data = this.nodeValue = text;
2687
+ this.length = text.length;
2688
+ var newNode = this.ownerDocument.createTextNode(newText);
2689
+ if (this.parentNode) {
2690
+ this.parentNode.insertBefore(newNode, this.nextSibling);
2691
+ }
2692
+ return newNode;
2693
+ }
2694
+ };
2695
+ _extends(Text, CharacterData);
2696
+ function Comment() {
2697
+ }
2698
+ Comment.prototype = {
2699
+ nodeName: "#comment",
2700
+ nodeType: COMMENT_NODE
2701
+ };
2702
+ _extends(Comment, CharacterData);
2703
+ function CDATASection() {
2704
+ }
2705
+ CDATASection.prototype = {
2706
+ nodeName: "#cdata-section",
2707
+ nodeType: CDATA_SECTION_NODE
2708
+ };
2709
+ _extends(CDATASection, CharacterData);
2710
+ function DocumentType() {
2711
+ }
2712
+ DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
2713
+ _extends(DocumentType, Node2);
2714
+ function Notation() {
2715
+ }
2716
+ Notation.prototype.nodeType = NOTATION_NODE;
2717
+ _extends(Notation, Node2);
2718
+ function Entity() {
2719
+ }
2720
+ Entity.prototype.nodeType = ENTITY_NODE;
2721
+ _extends(Entity, Node2);
2722
+ function EntityReference() {
2723
+ }
2724
+ EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
2725
+ _extends(EntityReference, Node2);
2726
+ function DocumentFragment() {
2727
+ }
2728
+ DocumentFragment.prototype.nodeName = "#document-fragment";
2729
+ DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
2730
+ _extends(DocumentFragment, Node2);
2731
+ function ProcessingInstruction() {
2732
+ }
2733
+ ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
2734
+ _extends(ProcessingInstruction, Node2);
2735
+ function XMLSerializer() {
2736
+ }
2737
+ XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
2738
+ return nodeSerializeToString.call(node, isHtml, nodeFilter);
2739
+ };
2740
+ Node2.prototype.toString = nodeSerializeToString;
2741
+ function nodeSerializeToString(isHtml, nodeFilter) {
2742
+ var buf = [];
2743
+ var refNode = this.nodeType == 9 && this.documentElement || this;
2744
+ var prefix = refNode.prefix;
2745
+ var uri = refNode.namespaceURI;
2746
+ if (uri && prefix == null) {
2747
+ var prefix = refNode.lookupPrefix(uri);
2748
+ if (prefix == null) {
2749
+ var visibleNamespaces = [
2750
+ { namespace: uri, prefix: null }
2751
+ ];
2752
+ }
2753
+ }
2754
+ serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
2755
+ return buf.join("");
2756
+ }
2757
+ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
2758
+ var prefix = node.prefix || "";
2759
+ var uri = node.namespaceURI;
2760
+ if (!uri) {
2761
+ return false;
2762
+ }
2763
+ if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
2764
+ return false;
2765
+ }
2766
+ var i = visibleNamespaces.length;
2767
+ while (i--) {
2768
+ var ns = visibleNamespaces[i];
2769
+ if (ns.prefix === prefix) {
2770
+ return ns.namespace !== uri;
2771
+ }
2772
+ }
2773
+ return true;
2774
+ }
2775
+ function addSerializedAttribute(buf, qualifiedName, value) {
2776
+ buf.push(" ", qualifiedName, '="', value.replace(/[<&"]/g, _xmlEncoder), '"');
2777
+ }
2778
+ function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
2779
+ if (!visibleNamespaces) {
2780
+ visibleNamespaces = [];
2781
+ }
2782
+ if (nodeFilter) {
2783
+ node = nodeFilter(node);
2784
+ if (node) {
2785
+ if (typeof node == "string") {
2786
+ buf.push(node);
2787
+ return;
2788
+ }
2789
+ } else {
2790
+ return;
2791
+ }
2792
+ }
2793
+ switch (node.nodeType) {
2794
+ case ELEMENT_NODE:
2795
+ var attrs = node.attributes;
2796
+ var len = attrs.length;
2797
+ var child = node.firstChild;
2798
+ var nodeName = node.tagName;
2799
+ isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML;
2800
+ var prefixedNodeName = nodeName;
2801
+ if (!isHTML && !node.prefix && node.namespaceURI) {
2802
+ var defaultNS;
2803
+ for (var ai = 0; ai < attrs.length; ai++) {
2804
+ if (attrs.item(ai).name === "xmlns") {
2805
+ defaultNS = attrs.item(ai).value;
2806
+ break;
2807
+ }
2808
+ }
2809
+ if (!defaultNS) {
2810
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
2811
+ var namespace = visibleNamespaces[nsi];
2812
+ if (namespace.prefix === "" && namespace.namespace === node.namespaceURI) {
2813
+ defaultNS = namespace.namespace;
2814
+ break;
2815
+ }
2816
+ }
2817
+ }
2818
+ if (defaultNS !== node.namespaceURI) {
2819
+ for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
2820
+ var namespace = visibleNamespaces[nsi];
2821
+ if (namespace.namespace === node.namespaceURI) {
2822
+ if (namespace.prefix) {
2823
+ prefixedNodeName = namespace.prefix + ":" + nodeName;
2824
+ }
2825
+ break;
2826
+ }
2827
+ }
2828
+ }
2829
+ }
2830
+ buf.push("<", prefixedNodeName);
2831
+ for (var i = 0; i < len; i++) {
2832
+ var attr = attrs.item(i);
2833
+ if (attr.prefix == "xmlns") {
2834
+ visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
2835
+ } else if (attr.nodeName == "xmlns") {
2836
+ visibleNamespaces.push({ prefix: "", namespace: attr.value });
2837
+ }
2838
+ }
2839
+ for (var i = 0; i < len; i++) {
2840
+ var attr = attrs.item(i);
2841
+ if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
2842
+ var prefix = attr.prefix || "";
2843
+ var uri = attr.namespaceURI;
2844
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
2845
+ visibleNamespaces.push({ prefix, namespace: uri });
2846
+ }
2847
+ serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
2848
+ }
2849
+ if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
2850
+ var prefix = node.prefix || "";
2851
+ var uri = node.namespaceURI;
2852
+ addSerializedAttribute(buf, prefix ? "xmlns:" + prefix : "xmlns", uri);
2853
+ visibleNamespaces.push({ prefix, namespace: uri });
2854
+ }
2855
+ if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
2856
+ buf.push(">");
2857
+ if (isHTML && /^script$/i.test(nodeName)) {
2858
+ while (child) {
2859
+ if (child.data) {
2860
+ buf.push(child.data);
2861
+ } else {
2862
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
2863
+ }
2864
+ child = child.nextSibling;
2865
+ }
2866
+ } else {
2867
+ while (child) {
2868
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
2869
+ child = child.nextSibling;
2870
+ }
2871
+ }
2872
+ buf.push("</", prefixedNodeName, ">");
2873
+ } else {
2874
+ buf.push("/>");
2875
+ }
2876
+ return;
2877
+ case DOCUMENT_NODE:
2878
+ case DOCUMENT_FRAGMENT_NODE:
2879
+ var child = node.firstChild;
2880
+ while (child) {
2881
+ serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice());
2882
+ child = child.nextSibling;
2883
+ }
2884
+ return;
2885
+ case ATTRIBUTE_NODE:
2886
+ return addSerializedAttribute(buf, node.name, node.value);
2887
+ case TEXT_NODE:
2888
+ return buf.push(node.data.replace(/[<&]/g, _xmlEncoder).replace(/]]>/g, "]]&gt;"));
2889
+ case CDATA_SECTION_NODE:
2890
+ return buf.push("<![CDATA[", node.data, "]]>");
2891
+ case COMMENT_NODE:
2892
+ return buf.push("<!--", node.data, "-->");
2893
+ case DOCUMENT_TYPE_NODE:
2894
+ var pubid = node.publicId;
2895
+ var sysid = node.systemId;
2896
+ buf.push("<!DOCTYPE ", node.name);
2897
+ if (pubid) {
2898
+ buf.push(" PUBLIC ", pubid);
2899
+ if (sysid && sysid != ".") {
2900
+ buf.push(" ", sysid);
2901
+ }
2902
+ buf.push(">");
2903
+ } else if (sysid && sysid != ".") {
2904
+ buf.push(" SYSTEM ", sysid, ">");
2905
+ } else {
2906
+ var sub = node.internalSubset;
2907
+ if (sub) {
2908
+ buf.push(" [", sub, "]");
2909
+ }
2910
+ buf.push(">");
2911
+ }
2912
+ return;
2913
+ case PROCESSING_INSTRUCTION_NODE:
2914
+ return buf.push("<?", node.target, " ", node.data, "?>");
2915
+ case ENTITY_REFERENCE_NODE:
2916
+ return buf.push("&", node.nodeName, ";");
2917
+ default:
2918
+ buf.push("??", node.nodeName);
2919
+ }
2920
+ }
2921
+ function importNode(doc, node, deep) {
2922
+ var node2;
2923
+ switch (node.nodeType) {
2924
+ case ELEMENT_NODE:
2925
+ node2 = node.cloneNode(false);
2926
+ node2.ownerDocument = doc;
2927
+ case DOCUMENT_FRAGMENT_NODE:
2928
+ break;
2929
+ case ATTRIBUTE_NODE:
2930
+ deep = true;
2931
+ break;
2932
+ }
2933
+ if (!node2) {
2934
+ node2 = node.cloneNode(false);
2935
+ }
2936
+ node2.ownerDocument = doc;
2937
+ node2.parentNode = null;
2938
+ if (deep) {
2939
+ var child = node.firstChild;
2940
+ while (child) {
2941
+ node2.appendChild(importNode(doc, child, deep));
2942
+ child = child.nextSibling;
2943
+ }
2944
+ }
2945
+ return node2;
2946
+ }
2947
+ function cloneNode(doc, node, deep) {
2948
+ var node2 = new node.constructor();
2949
+ for (var n in node) {
2950
+ if (Object.prototype.hasOwnProperty.call(node, n)) {
2951
+ var v = node[n];
2952
+ if (typeof v != "object") {
2953
+ if (v != node2[n]) {
2954
+ node2[n] = v;
2955
+ }
2956
+ }
2957
+ }
2958
+ }
2959
+ if (node.childNodes) {
2960
+ node2.childNodes = new NodeList();
2961
+ }
2962
+ node2.ownerDocument = doc;
2963
+ switch (node2.nodeType) {
2964
+ case ELEMENT_NODE:
2965
+ var attrs = node.attributes;
2966
+ var attrs2 = node2.attributes = new NamedNodeMap();
2967
+ var len = attrs.length;
2968
+ attrs2._ownerElement = node2;
2969
+ for (var i = 0; i < len; i++) {
2970
+ node2.setAttributeNode(cloneNode(doc, attrs.item(i), true));
2971
+ }
2972
+ break;
2973
+ ;
2974
+ case ATTRIBUTE_NODE:
2975
+ deep = true;
2976
+ }
2977
+ if (deep) {
2978
+ var child = node.firstChild;
2979
+ while (child) {
2980
+ node2.appendChild(cloneNode(doc, child, deep));
2981
+ child = child.nextSibling;
2982
+ }
2983
+ }
2984
+ return node2;
2985
+ }
2986
+ function __set__(object, key, value) {
2987
+ object[key] = value;
2988
+ }
2989
+ try {
2990
+ if (Object.defineProperty) {
2991
+ let getTextContent2 = function(node) {
2992
+ switch (node.nodeType) {
2993
+ case ELEMENT_NODE:
2994
+ case DOCUMENT_FRAGMENT_NODE:
2995
+ var buf = [];
2996
+ node = node.firstChild;
2997
+ while (node) {
2998
+ if (node.nodeType !== 7 && node.nodeType !== 8) {
2999
+ buf.push(getTextContent2(node));
3000
+ }
3001
+ node = node.nextSibling;
3002
+ }
3003
+ return buf.join("");
3004
+ default:
3005
+ return node.nodeValue;
3006
+ }
3007
+ };
3008
+ getTextContent = getTextContent2;
3009
+ Object.defineProperty(LiveNodeList.prototype, "length", {
3010
+ get: function() {
3011
+ _updateLiveList(this);
3012
+ return this.$$length;
3013
+ }
3014
+ });
3015
+ Object.defineProperty(Node2.prototype, "textContent", {
3016
+ get: function() {
3017
+ return getTextContent2(this);
3018
+ },
3019
+ set: function(data) {
3020
+ switch (this.nodeType) {
3021
+ case ELEMENT_NODE:
3022
+ case DOCUMENT_FRAGMENT_NODE:
3023
+ while (this.firstChild) {
3024
+ this.removeChild(this.firstChild);
3025
+ }
3026
+ if (data || String(data)) {
3027
+ this.appendChild(this.ownerDocument.createTextNode(data));
3028
+ }
3029
+ break;
3030
+ default:
3031
+ this.data = data;
3032
+ this.value = data;
3033
+ this.nodeValue = data;
3034
+ }
3035
+ }
3036
+ });
3037
+ __set__ = function(object, key, value) {
3038
+ object["$$" + key] = value;
3039
+ };
3040
+ }
3041
+ } catch (e) {
3042
+ }
3043
+ var getTextContent;
3044
+ exports.DocumentType = DocumentType;
3045
+ exports.DOMException = DOMException;
3046
+ exports.DOMImplementation = DOMImplementation;
3047
+ exports.Element = Element;
3048
+ exports.Node = Node2;
3049
+ exports.NodeList = NodeList;
3050
+ exports.XMLSerializer = XMLSerializer;
3051
+ }
3052
+ });
3053
+
3054
+ // ../../node_modules/@xmldom/xmldom/lib/entities.js
3055
+ var require_entities = __commonJS({
3056
+ "../../node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
3057
+ var freeze = require_conventions().freeze;
3058
+ exports.XML_ENTITIES = freeze({ amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' });
3059
+ exports.HTML_ENTITIES = freeze({
3060
+ lt: "<",
3061
+ gt: ">",
3062
+ amp: "&",
3063
+ quot: '"',
3064
+ apos: "'",
3065
+ Agrave: "\xC0",
3066
+ Aacute: "\xC1",
3067
+ Acirc: "\xC2",
3068
+ Atilde: "\xC3",
3069
+ Auml: "\xC4",
3070
+ Aring: "\xC5",
3071
+ AElig: "\xC6",
3072
+ Ccedil: "\xC7",
3073
+ Egrave: "\xC8",
3074
+ Eacute: "\xC9",
3075
+ Ecirc: "\xCA",
3076
+ Euml: "\xCB",
3077
+ Igrave: "\xCC",
3078
+ Iacute: "\xCD",
3079
+ Icirc: "\xCE",
3080
+ Iuml: "\xCF",
3081
+ ETH: "\xD0",
3082
+ Ntilde: "\xD1",
3083
+ Ograve: "\xD2",
3084
+ Oacute: "\xD3",
3085
+ Ocirc: "\xD4",
3086
+ Otilde: "\xD5",
3087
+ Ouml: "\xD6",
3088
+ Oslash: "\xD8",
3089
+ Ugrave: "\xD9",
3090
+ Uacute: "\xDA",
3091
+ Ucirc: "\xDB",
3092
+ Uuml: "\xDC",
3093
+ Yacute: "\xDD",
3094
+ THORN: "\xDE",
3095
+ szlig: "\xDF",
3096
+ agrave: "\xE0",
3097
+ aacute: "\xE1",
3098
+ acirc: "\xE2",
3099
+ atilde: "\xE3",
3100
+ auml: "\xE4",
3101
+ aring: "\xE5",
3102
+ aelig: "\xE6",
3103
+ ccedil: "\xE7",
3104
+ egrave: "\xE8",
3105
+ eacute: "\xE9",
3106
+ ecirc: "\xEA",
3107
+ euml: "\xEB",
3108
+ igrave: "\xEC",
3109
+ iacute: "\xED",
3110
+ icirc: "\xEE",
3111
+ iuml: "\xEF",
3112
+ eth: "\xF0",
3113
+ ntilde: "\xF1",
3114
+ ograve: "\xF2",
3115
+ oacute: "\xF3",
3116
+ ocirc: "\xF4",
3117
+ otilde: "\xF5",
3118
+ ouml: "\xF6",
3119
+ oslash: "\xF8",
3120
+ ugrave: "\xF9",
3121
+ uacute: "\xFA",
3122
+ ucirc: "\xFB",
3123
+ uuml: "\xFC",
3124
+ yacute: "\xFD",
3125
+ thorn: "\xFE",
3126
+ yuml: "\xFF",
3127
+ nbsp: "\xA0",
3128
+ iexcl: "\xA1",
3129
+ cent: "\xA2",
3130
+ pound: "\xA3",
3131
+ curren: "\xA4",
3132
+ yen: "\xA5",
3133
+ brvbar: "\xA6",
3134
+ sect: "\xA7",
3135
+ uml: "\xA8",
3136
+ copy: "\xA9",
3137
+ ordf: "\xAA",
3138
+ laquo: "\xAB",
3139
+ not: "\xAC",
3140
+ shy: "\xAD\xAD",
3141
+ reg: "\xAE",
3142
+ macr: "\xAF",
3143
+ deg: "\xB0",
3144
+ plusmn: "\xB1",
3145
+ sup2: "\xB2",
3146
+ sup3: "\xB3",
3147
+ acute: "\xB4",
3148
+ micro: "\xB5",
3149
+ para: "\xB6",
3150
+ middot: "\xB7",
3151
+ cedil: "\xB8",
3152
+ sup1: "\xB9",
3153
+ ordm: "\xBA",
3154
+ raquo: "\xBB",
3155
+ frac14: "\xBC",
3156
+ frac12: "\xBD",
3157
+ frac34: "\xBE",
3158
+ iquest: "\xBF",
3159
+ times: "\xD7",
3160
+ divide: "\xF7",
3161
+ forall: "\u2200",
3162
+ part: "\u2202",
3163
+ exist: "\u2203",
3164
+ empty: "\u2205",
3165
+ nabla: "\u2207",
3166
+ isin: "\u2208",
3167
+ notin: "\u2209",
3168
+ ni: "\u220B",
3169
+ prod: "\u220F",
3170
+ sum: "\u2211",
3171
+ minus: "\u2212",
3172
+ lowast: "\u2217",
3173
+ radic: "\u221A",
3174
+ prop: "\u221D",
3175
+ infin: "\u221E",
3176
+ ang: "\u2220",
3177
+ and: "\u2227",
3178
+ or: "\u2228",
3179
+ cap: "\u2229",
3180
+ cup: "\u222A",
3181
+ "int": "\u222B",
3182
+ there4: "\u2234",
3183
+ sim: "\u223C",
3184
+ cong: "\u2245",
3185
+ asymp: "\u2248",
3186
+ ne: "\u2260",
3187
+ equiv: "\u2261",
3188
+ le: "\u2264",
3189
+ ge: "\u2265",
3190
+ sub: "\u2282",
3191
+ sup: "\u2283",
3192
+ nsub: "\u2284",
3193
+ sube: "\u2286",
3194
+ supe: "\u2287",
3195
+ oplus: "\u2295",
3196
+ otimes: "\u2297",
3197
+ perp: "\u22A5",
3198
+ sdot: "\u22C5",
3199
+ Alpha: "\u0391",
3200
+ Beta: "\u0392",
3201
+ Gamma: "\u0393",
3202
+ Delta: "\u0394",
3203
+ Epsilon: "\u0395",
3204
+ Zeta: "\u0396",
3205
+ Eta: "\u0397",
3206
+ Theta: "\u0398",
3207
+ Iota: "\u0399",
3208
+ Kappa: "\u039A",
3209
+ Lambda: "\u039B",
3210
+ Mu: "\u039C",
3211
+ Nu: "\u039D",
3212
+ Xi: "\u039E",
3213
+ Omicron: "\u039F",
3214
+ Pi: "\u03A0",
3215
+ Rho: "\u03A1",
3216
+ Sigma: "\u03A3",
3217
+ Tau: "\u03A4",
3218
+ Upsilon: "\u03A5",
3219
+ Phi: "\u03A6",
3220
+ Chi: "\u03A7",
3221
+ Psi: "\u03A8",
3222
+ Omega: "\u03A9",
3223
+ alpha: "\u03B1",
3224
+ beta: "\u03B2",
3225
+ gamma: "\u03B3",
3226
+ delta: "\u03B4",
3227
+ epsilon: "\u03B5",
3228
+ zeta: "\u03B6",
3229
+ eta: "\u03B7",
3230
+ theta: "\u03B8",
3231
+ iota: "\u03B9",
3232
+ kappa: "\u03BA",
3233
+ lambda: "\u03BB",
3234
+ mu: "\u03BC",
3235
+ nu: "\u03BD",
3236
+ xi: "\u03BE",
3237
+ omicron: "\u03BF",
3238
+ pi: "\u03C0",
3239
+ rho: "\u03C1",
3240
+ sigmaf: "\u03C2",
3241
+ sigma: "\u03C3",
3242
+ tau: "\u03C4",
3243
+ upsilon: "\u03C5",
3244
+ phi: "\u03C6",
3245
+ chi: "\u03C7",
3246
+ psi: "\u03C8",
3247
+ omega: "\u03C9",
3248
+ thetasym: "\u03D1",
3249
+ upsih: "\u03D2",
3250
+ piv: "\u03D6",
3251
+ OElig: "\u0152",
3252
+ oelig: "\u0153",
3253
+ Scaron: "\u0160",
3254
+ scaron: "\u0161",
3255
+ Yuml: "\u0178",
3256
+ fnof: "\u0192",
3257
+ circ: "\u02C6",
3258
+ tilde: "\u02DC",
3259
+ ensp: "\u2002",
3260
+ emsp: "\u2003",
3261
+ thinsp: "\u2009",
3262
+ zwnj: "\u200C",
3263
+ zwj: "\u200D",
3264
+ lrm: "\u200E",
3265
+ rlm: "\u200F",
3266
+ ndash: "\u2013",
3267
+ mdash: "\u2014",
3268
+ lsquo: "\u2018",
3269
+ rsquo: "\u2019",
3270
+ sbquo: "\u201A",
3271
+ ldquo: "\u201C",
3272
+ rdquo: "\u201D",
3273
+ bdquo: "\u201E",
3274
+ dagger: "\u2020",
3275
+ Dagger: "\u2021",
3276
+ bull: "\u2022",
3277
+ hellip: "\u2026",
3278
+ permil: "\u2030",
3279
+ prime: "\u2032",
3280
+ Prime: "\u2033",
3281
+ lsaquo: "\u2039",
3282
+ rsaquo: "\u203A",
3283
+ oline: "\u203E",
3284
+ euro: "\u20AC",
3285
+ trade: "\u2122",
3286
+ larr: "\u2190",
3287
+ uarr: "\u2191",
3288
+ rarr: "\u2192",
3289
+ darr: "\u2193",
3290
+ harr: "\u2194",
3291
+ crarr: "\u21B5",
3292
+ lceil: "\u2308",
3293
+ rceil: "\u2309",
3294
+ lfloor: "\u230A",
3295
+ rfloor: "\u230B",
3296
+ loz: "\u25CA",
3297
+ spades: "\u2660",
3298
+ clubs: "\u2663",
3299
+ hearts: "\u2665",
3300
+ diams: "\u2666"
3301
+ });
3302
+ exports.entityMap = exports.HTML_ENTITIES;
3303
+ }
3304
+ });
3305
+
3306
+ // ../../node_modules/@xmldom/xmldom/lib/sax.js
3307
+ var require_sax = __commonJS({
3308
+ "../../node_modules/@xmldom/xmldom/lib/sax.js"(exports) {
3309
+ var NAMESPACE = require_conventions().NAMESPACE;
3310
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
3311
+ var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
3312
+ var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
3313
+ var S_TAG = 0;
3314
+ var S_ATTR = 1;
3315
+ var S_ATTR_SPACE = 2;
3316
+ var S_EQ = 3;
3317
+ var S_ATTR_NOQUOT_VALUE = 4;
3318
+ var S_ATTR_END = 5;
3319
+ var S_TAG_SPACE = 6;
3320
+ var S_TAG_CLOSE = 7;
3321
+ function ParseError(message, locator) {
3322
+ this.message = message;
3323
+ this.locator = locator;
3324
+ if (Error.captureStackTrace)
3325
+ Error.captureStackTrace(this, ParseError);
3326
+ }
3327
+ ParseError.prototype = new Error();
3328
+ ParseError.prototype.name = ParseError.name;
3329
+ function XMLReader() {
3330
+ }
3331
+ XMLReader.prototype = {
3332
+ parse: function(source, defaultNSMap, entityMap) {
3333
+ var domBuilder = this.domBuilder;
3334
+ domBuilder.startDocument();
3335
+ _copy(defaultNSMap, defaultNSMap = {});
3336
+ parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
3337
+ domBuilder.endDocument();
3338
+ }
3339
+ };
3340
+ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
3341
+ function fixedFromCharCode(code) {
3342
+ if (code > 65535) {
3343
+ code -= 65536;
3344
+ var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
3345
+ return String.fromCharCode(surrogate1, surrogate2);
3346
+ } else {
3347
+ return String.fromCharCode(code);
3348
+ }
3349
+ }
3350
+ function entityReplacer(a2) {
3351
+ var k = a2.slice(1, -1);
3352
+ if (k in entityMap) {
3353
+ return entityMap[k];
3354
+ } else if (k.charAt(0) === "#") {
3355
+ return fixedFromCharCode(parseInt(k.substr(1).replace("x", "0x")));
3356
+ } else {
3357
+ errorHandler.error("entity not found:" + a2);
3358
+ return a2;
3359
+ }
3360
+ }
3361
+ function appendText(end2) {
3362
+ if (end2 > start) {
3363
+ var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
3364
+ locator && position(start);
3365
+ domBuilder.characters(xt, 0, end2 - start);
3366
+ start = end2;
3367
+ }
3368
+ }
3369
+ function position(p, m) {
3370
+ while (p >= lineEnd && (m = linePattern.exec(source))) {
3371
+ lineStart = m.index;
3372
+ lineEnd = lineStart + m[0].length;
3373
+ locator.lineNumber++;
3374
+ }
3375
+ locator.columnNumber = p - lineStart + 1;
3376
+ }
3377
+ var lineStart = 0;
3378
+ var lineEnd = 0;
3379
+ var linePattern = /.*(?:\r\n?|\n)|.*$/g;
3380
+ var locator = domBuilder.locator;
3381
+ var parseStack = [{ currentNSMap: defaultNSMapCopy }];
3382
+ var closeMap = {};
3383
+ var start = 0;
3384
+ while (true) {
3385
+ try {
3386
+ var tagStart = source.indexOf("<", start);
3387
+ if (tagStart < 0) {
3388
+ if (!source.substr(start).match(/^\s*$/)) {
3389
+ var doc = domBuilder.doc;
3390
+ var text = doc.createTextNode(source.substr(start));
3391
+ doc.appendChild(text);
3392
+ domBuilder.currentElement = text;
3393
+ }
3394
+ return;
3395
+ }
3396
+ if (tagStart > start) {
3397
+ appendText(tagStart);
3398
+ }
3399
+ switch (source.charAt(tagStart + 1)) {
3400
+ case "/":
3401
+ var end = source.indexOf(">", tagStart + 3);
3402
+ var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, "");
3403
+ var config = parseStack.pop();
3404
+ if (end < 0) {
3405
+ tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
3406
+ errorHandler.error("end tag name: " + tagName + " is not complete:" + config.tagName);
3407
+ end = tagStart + 1 + tagName.length;
3408
+ } else if (tagName.match(/\s</)) {
3409
+ tagName = tagName.replace(/[\s<].*/, "");
3410
+ errorHandler.error("end tag name: " + tagName + " maybe not complete");
3411
+ end = tagStart + 1 + tagName.length;
3412
+ }
3413
+ var localNSMap = config.localNSMap;
3414
+ var endMatch = config.tagName == tagName;
3415
+ var endIgnoreCaseMach = endMatch || config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase();
3416
+ if (endIgnoreCaseMach) {
3417
+ domBuilder.endElement(config.uri, config.localName, tagName);
3418
+ if (localNSMap) {
3419
+ for (var prefix in localNSMap) {
3420
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
3421
+ domBuilder.endPrefixMapping(prefix);
3422
+ }
3423
+ }
3424
+ }
3425
+ if (!endMatch) {
3426
+ errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config.tagName);
3427
+ }
3428
+ } else {
3429
+ parseStack.push(config);
3430
+ }
3431
+ end++;
3432
+ break;
3433
+ case "?":
3434
+ locator && position(tagStart);
3435
+ end = parseInstruction(source, tagStart, domBuilder);
3436
+ break;
3437
+ case "!":
3438
+ locator && position(tagStart);
3439
+ end = parseDCC(source, tagStart, domBuilder, errorHandler);
3440
+ break;
3441
+ default:
3442
+ locator && position(tagStart);
3443
+ var el = new ElementAttributes();
3444
+ var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
3445
+ var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
3446
+ var len = el.length;
3447
+ if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
3448
+ el.closed = true;
3449
+ if (!entityMap.nbsp) {
3450
+ errorHandler.warning("unclosed xml attribute");
3451
+ }
3452
+ }
3453
+ if (locator && len) {
3454
+ var locator2 = copyLocator(locator, {});
3455
+ for (var i = 0; i < len; i++) {
3456
+ var a = el[i];
3457
+ position(a.offset);
3458
+ a.locator = copyLocator(locator, {});
3459
+ }
3460
+ domBuilder.locator = locator2;
3461
+ if (appendElement(el, domBuilder, currentNSMap)) {
3462
+ parseStack.push(el);
3463
+ }
3464
+ domBuilder.locator = locator;
3465
+ } else {
3466
+ if (appendElement(el, domBuilder, currentNSMap)) {
3467
+ parseStack.push(el);
3468
+ }
3469
+ }
3470
+ if (NAMESPACE.isHTML(el.uri) && !el.closed) {
3471
+ end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
3472
+ } else {
3473
+ end++;
3474
+ }
3475
+ }
3476
+ } catch (e) {
3477
+ if (e instanceof ParseError) {
3478
+ throw e;
3479
+ }
3480
+ errorHandler.error("element parse error: " + e);
3481
+ end = -1;
3482
+ }
3483
+ if (end > start) {
3484
+ start = end;
3485
+ } else {
3486
+ appendText(Math.max(tagStart, start) + 1);
3487
+ }
3488
+ }
3489
+ }
3490
+ function copyLocator(f, t) {
3491
+ t.lineNumber = f.lineNumber;
3492
+ t.columnNumber = f.columnNumber;
3493
+ return t;
3494
+ }
3495
+ function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
3496
+ function addAttribute(qname, value2, startIndex) {
3497
+ if (el.attributeNames.hasOwnProperty(qname)) {
3498
+ errorHandler.fatalError("Attribute " + qname + " redefined");
3499
+ }
3500
+ el.addValue(qname, value2, startIndex);
3501
+ }
3502
+ var attrName;
3503
+ var value;
3504
+ var p = ++start;
3505
+ var s = S_TAG;
3506
+ while (true) {
3507
+ var c = source.charAt(p);
3508
+ switch (c) {
3509
+ case "=":
3510
+ if (s === S_ATTR) {
3511
+ attrName = source.slice(start, p);
3512
+ s = S_EQ;
3513
+ } else if (s === S_ATTR_SPACE) {
3514
+ s = S_EQ;
3515
+ } else {
3516
+ throw new Error("attribute equal must after attrName");
3517
+ }
3518
+ break;
3519
+ case "'":
3520
+ case '"':
3521
+ if (s === S_EQ || s === S_ATTR) {
3522
+ if (s === S_ATTR) {
3523
+ errorHandler.warning('attribute value must after "="');
3524
+ attrName = source.slice(start, p);
3525
+ }
3526
+ start = p + 1;
3527
+ p = source.indexOf(c, start);
3528
+ if (p > 0) {
3529
+ value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
3530
+ addAttribute(attrName, value, start - 1);
3531
+ s = S_ATTR_END;
3532
+ } else {
3533
+ throw new Error("attribute value no end '" + c + "' match");
3534
+ }
3535
+ } else if (s == S_ATTR_NOQUOT_VALUE) {
3536
+ value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
3537
+ addAttribute(attrName, value, start);
3538
+ errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
3539
+ start = p + 1;
3540
+ s = S_ATTR_END;
3541
+ } else {
3542
+ throw new Error('attribute value must after "="');
3543
+ }
3544
+ break;
3545
+ case "/":
3546
+ switch (s) {
3547
+ case S_TAG:
3548
+ el.setTagName(source.slice(start, p));
3549
+ case S_ATTR_END:
3550
+ case S_TAG_SPACE:
3551
+ case S_TAG_CLOSE:
3552
+ s = S_TAG_CLOSE;
3553
+ el.closed = true;
3554
+ case S_ATTR_NOQUOT_VALUE:
3555
+ case S_ATTR:
3556
+ break;
3557
+ case S_ATTR_SPACE:
3558
+ el.closed = true;
3559
+ break;
3560
+ default:
3561
+ throw new Error("attribute invalid close char('/')");
3562
+ }
3563
+ break;
3564
+ case "":
3565
+ errorHandler.error("unexpected end of input");
3566
+ if (s == S_TAG) {
3567
+ el.setTagName(source.slice(start, p));
3568
+ }
3569
+ return p;
3570
+ case ">":
3571
+ switch (s) {
3572
+ case S_TAG:
3573
+ el.setTagName(source.slice(start, p));
3574
+ case S_ATTR_END:
3575
+ case S_TAG_SPACE:
3576
+ case S_TAG_CLOSE:
3577
+ break;
3578
+ case S_ATTR_NOQUOT_VALUE:
3579
+ case S_ATTR:
3580
+ value = source.slice(start, p);
3581
+ if (value.slice(-1) === "/") {
3582
+ el.closed = true;
3583
+ value = value.slice(0, -1);
3584
+ }
3585
+ case S_ATTR_SPACE:
3586
+ if (s === S_ATTR_SPACE) {
3587
+ value = attrName;
3588
+ }
3589
+ if (s == S_ATTR_NOQUOT_VALUE) {
3590
+ errorHandler.warning('attribute "' + value + '" missed quot(")!');
3591
+ addAttribute(attrName, value.replace(/&#?\w+;/g, entityReplacer), start);
3592
+ } else {
3593
+ if (!NAMESPACE.isHTML(currentNSMap[""]) || !value.match(/^(?:disabled|checked|selected)$/i)) {
3594
+ errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
3595
+ }
3596
+ addAttribute(value, value, start);
3597
+ }
3598
+ break;
3599
+ case S_EQ:
3600
+ throw new Error("attribute value missed!!");
3601
+ }
3602
+ return p;
3603
+ case "\x80":
3604
+ c = " ";
3605
+ default:
3606
+ if (c <= " ") {
3607
+ switch (s) {
3608
+ case S_TAG:
3609
+ el.setTagName(source.slice(start, p));
3610
+ s = S_TAG_SPACE;
3611
+ break;
3612
+ case S_ATTR:
3613
+ attrName = source.slice(start, p);
3614
+ s = S_ATTR_SPACE;
3615
+ break;
3616
+ case S_ATTR_NOQUOT_VALUE:
3617
+ var value = source.slice(start, p).replace(/&#?\w+;/g, entityReplacer);
3618
+ errorHandler.warning('attribute "' + value + '" missed quot(")!!');
3619
+ addAttribute(attrName, value, start);
3620
+ case S_ATTR_END:
3621
+ s = S_TAG_SPACE;
3622
+ break;
3623
+ }
3624
+ } else {
3625
+ switch (s) {
3626
+ case S_ATTR_SPACE:
3627
+ var tagName = el.tagName;
3628
+ if (!NAMESPACE.isHTML(currentNSMap[""]) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
3629
+ errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
3630
+ }
3631
+ addAttribute(attrName, attrName, start);
3632
+ start = p;
3633
+ s = S_ATTR;
3634
+ break;
3635
+ case S_ATTR_END:
3636
+ errorHandler.warning('attribute space is required"' + attrName + '"!!');
3637
+ case S_TAG_SPACE:
3638
+ s = S_ATTR;
3639
+ start = p;
3640
+ break;
3641
+ case S_EQ:
3642
+ s = S_ATTR_NOQUOT_VALUE;
3643
+ start = p;
3644
+ break;
3645
+ case S_TAG_CLOSE:
3646
+ throw new Error("elements closed character '/' and '>' must be connected to");
3647
+ }
3648
+ }
3649
+ }
3650
+ p++;
3651
+ }
3652
+ }
3653
+ function appendElement(el, domBuilder, currentNSMap) {
3654
+ var tagName = el.tagName;
3655
+ var localNSMap = null;
3656
+ var i = el.length;
3657
+ while (i--) {
3658
+ var a = el[i];
3659
+ var qName = a.qName;
3660
+ var value = a.value;
3661
+ var nsp = qName.indexOf(":");
3662
+ if (nsp > 0) {
3663
+ var prefix = a.prefix = qName.slice(0, nsp);
3664
+ var localName = qName.slice(nsp + 1);
3665
+ var nsPrefix = prefix === "xmlns" && localName;
3666
+ } else {
3667
+ localName = qName;
3668
+ prefix = null;
3669
+ nsPrefix = qName === "xmlns" && "";
3670
+ }
3671
+ a.localName = localName;
3672
+ if (nsPrefix !== false) {
3673
+ if (localNSMap == null) {
3674
+ localNSMap = {};
3675
+ _copy(currentNSMap, currentNSMap = {});
3676
+ }
3677
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
3678
+ a.uri = NAMESPACE.XMLNS;
3679
+ domBuilder.startPrefixMapping(nsPrefix, value);
3680
+ }
3681
+ }
3682
+ var i = el.length;
3683
+ while (i--) {
3684
+ a = el[i];
3685
+ var prefix = a.prefix;
3686
+ if (prefix) {
3687
+ if (prefix === "xml") {
3688
+ a.uri = NAMESPACE.XML;
3689
+ }
3690
+ if (prefix !== "xmlns") {
3691
+ a.uri = currentNSMap[prefix || ""];
3692
+ }
3693
+ }
3694
+ }
3695
+ var nsp = tagName.indexOf(":");
3696
+ if (nsp > 0) {
3697
+ prefix = el.prefix = tagName.slice(0, nsp);
3698
+ localName = el.localName = tagName.slice(nsp + 1);
3699
+ } else {
3700
+ prefix = null;
3701
+ localName = el.localName = tagName;
3702
+ }
3703
+ var ns = el.uri = currentNSMap[prefix || ""];
3704
+ domBuilder.startElement(ns, localName, tagName, el);
3705
+ if (el.closed) {
3706
+ domBuilder.endElement(ns, localName, tagName);
3707
+ if (localNSMap) {
3708
+ for (prefix in localNSMap) {
3709
+ if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
3710
+ domBuilder.endPrefixMapping(prefix);
3711
+ }
3712
+ }
3713
+ }
3714
+ } else {
3715
+ el.currentNSMap = currentNSMap;
3716
+ el.localNSMap = localNSMap;
3717
+ return true;
3718
+ }
3719
+ }
3720
+ function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
3721
+ if (/^(?:script|textarea)$/i.test(tagName)) {
3722
+ var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
3723
+ var text = source.substring(elStartEnd + 1, elEndStart);
3724
+ if (/[&<]/.test(text)) {
3725
+ if (/^script$/i.test(tagName)) {
3726
+ domBuilder.characters(text, 0, text.length);
3727
+ return elEndStart;
3728
+ }
3729
+ text = text.replace(/&#?\w+;/g, entityReplacer);
3730
+ domBuilder.characters(text, 0, text.length);
3731
+ return elEndStart;
3732
+ }
3733
+ }
3734
+ return elStartEnd + 1;
3735
+ }
3736
+ function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
3737
+ var pos = closeMap[tagName];
3738
+ if (pos == null) {
3739
+ pos = source.lastIndexOf("</" + tagName + ">");
3740
+ if (pos < elStartEnd) {
3741
+ pos = source.lastIndexOf("</" + tagName);
3742
+ }
3743
+ closeMap[tagName] = pos;
3744
+ }
3745
+ return pos < elStartEnd;
3746
+ }
3747
+ function _copy(source, target) {
3748
+ for (var n in source) {
3749
+ if (Object.prototype.hasOwnProperty.call(source, n)) {
3750
+ target[n] = source[n];
3751
+ }
3752
+ }
3753
+ }
3754
+ function parseDCC(source, start, domBuilder, errorHandler) {
3755
+ var next = source.charAt(start + 2);
3756
+ switch (next) {
3757
+ case "-":
3758
+ if (source.charAt(start + 3) === "-") {
3759
+ var end = source.indexOf("-->", start + 4);
3760
+ if (end > start) {
3761
+ domBuilder.comment(source, start + 4, end - start - 4);
3762
+ return end + 3;
3763
+ } else {
3764
+ errorHandler.error("Unclosed comment");
3765
+ return -1;
3766
+ }
3767
+ } else {
3768
+ return -1;
3769
+ }
3770
+ default:
3771
+ if (source.substr(start + 3, 6) == "CDATA[") {
3772
+ var end = source.indexOf("]]>", start + 9);
3773
+ domBuilder.startCDATA();
3774
+ domBuilder.characters(source, start + 9, end - start - 9);
3775
+ domBuilder.endCDATA();
3776
+ return end + 3;
3777
+ }
3778
+ var matchs = split(source, start);
3779
+ var len = matchs.length;
3780
+ if (len > 1 && /!doctype/i.test(matchs[0][0])) {
3781
+ var name = matchs[1][0];
3782
+ var pubid = false;
3783
+ var sysid = false;
3784
+ if (len > 3) {
3785
+ if (/^public$/i.test(matchs[2][0])) {
3786
+ pubid = matchs[3][0];
3787
+ sysid = len > 4 && matchs[4][0];
3788
+ } else if (/^system$/i.test(matchs[2][0])) {
3789
+ sysid = matchs[3][0];
3790
+ }
3791
+ }
3792
+ var lastMatch = matchs[len - 1];
3793
+ domBuilder.startDTD(name, pubid, sysid);
3794
+ domBuilder.endDTD();
3795
+ return lastMatch.index + lastMatch[0].length;
3796
+ }
3797
+ }
3798
+ return -1;
3799
+ }
3800
+ function parseInstruction(source, start, domBuilder) {
3801
+ var end = source.indexOf("?>", start);
3802
+ if (end) {
3803
+ var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
3804
+ if (match) {
3805
+ var len = match[0].length;
3806
+ domBuilder.processingInstruction(match[1], match[2]);
3807
+ return end + 2;
3808
+ } else {
3809
+ return -1;
3810
+ }
3811
+ }
3812
+ return -1;
3813
+ }
3814
+ function ElementAttributes() {
3815
+ this.attributeNames = {};
3816
+ }
3817
+ ElementAttributes.prototype = {
3818
+ setTagName: function(tagName) {
3819
+ if (!tagNamePattern.test(tagName)) {
3820
+ throw new Error("invalid tagName:" + tagName);
3821
+ }
3822
+ this.tagName = tagName;
3823
+ },
3824
+ addValue: function(qName, value, offset) {
3825
+ if (!tagNamePattern.test(qName)) {
3826
+ throw new Error("invalid attribute:" + qName);
3827
+ }
3828
+ this.attributeNames[qName] = this.length;
3829
+ this[this.length++] = { qName, value, offset };
3830
+ },
3831
+ length: 0,
3832
+ getLocalName: function(i) {
3833
+ return this[i].localName;
3834
+ },
3835
+ getLocator: function(i) {
3836
+ return this[i].locator;
3837
+ },
3838
+ getQName: function(i) {
3839
+ return this[i].qName;
3840
+ },
3841
+ getURI: function(i) {
3842
+ return this[i].uri;
3843
+ },
3844
+ getValue: function(i) {
3845
+ return this[i].value;
3846
+ }
3847
+ };
3848
+ function split(source, start) {
3849
+ var match;
3850
+ var buf = [];
3851
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
3852
+ reg.lastIndex = start;
3853
+ reg.exec(source);
3854
+ while (match = reg.exec(source)) {
3855
+ buf.push(match);
3856
+ if (match[1])
3857
+ return buf;
3858
+ }
3859
+ }
3860
+ exports.XMLReader = XMLReader;
3861
+ exports.ParseError = ParseError;
3862
+ }
3863
+ });
3864
+
3865
+ // ../../node_modules/@xmldom/xmldom/lib/dom-parser.js
3866
+ var require_dom_parser = __commonJS({
3867
+ "../../node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {
3868
+ var conventions = require_conventions();
3869
+ var dom = require_dom();
3870
+ var entities = require_entities();
3871
+ var sax = require_sax();
3872
+ var DOMImplementation = dom.DOMImplementation;
3873
+ var NAMESPACE = conventions.NAMESPACE;
3874
+ var ParseError = sax.ParseError;
3875
+ var XMLReader = sax.XMLReader;
3876
+ function DOMParser4(options) {
3877
+ this.options = options || { locator: {} };
3878
+ }
3879
+ DOMParser4.prototype.parseFromString = function(source, mimeType) {
3880
+ var options = this.options;
3881
+ var sax2 = new XMLReader();
3882
+ var domBuilder = options.domBuilder || new DOMHandler();
3883
+ var errorHandler = options.errorHandler;
3884
+ var locator = options.locator;
3885
+ var defaultNSMap = options.xmlns || {};
3886
+ var isHTML = /\/x?html?$/.test(mimeType);
3887
+ var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES;
3888
+ if (locator) {
3889
+ domBuilder.setDocumentLocator(locator);
3890
+ }
3891
+ sax2.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
3892
+ sax2.domBuilder = options.domBuilder || domBuilder;
3893
+ if (isHTML) {
3894
+ defaultNSMap[""] = NAMESPACE.HTML;
3895
+ }
3896
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
3897
+ if (source && typeof source === "string") {
3898
+ sax2.parse(source, defaultNSMap, entityMap);
3899
+ } else {
3900
+ sax2.errorHandler.error("invalid doc source");
3901
+ }
3902
+ return domBuilder.doc;
3903
+ };
3904
+ function buildErrorHandler(errorImpl, domBuilder, locator) {
3905
+ if (!errorImpl) {
3906
+ if (domBuilder instanceof DOMHandler) {
3907
+ return domBuilder;
3908
+ }
3909
+ errorImpl = domBuilder;
3910
+ }
3911
+ var errorHandler = {};
3912
+ var isCallback = errorImpl instanceof Function;
3913
+ locator = locator || {};
3914
+ function build(key) {
3915
+ var fn = errorImpl[key];
3916
+ if (!fn && isCallback) {
3917
+ fn = errorImpl.length == 2 ? function(msg) {
3918
+ errorImpl(key, msg);
3919
+ } : errorImpl;
3920
+ }
3921
+ errorHandler[key] = fn && function(msg) {
3922
+ fn("[xmldom " + key + "] " + msg + _locator(locator));
3923
+ } || function() {
3924
+ };
3925
+ }
3926
+ build("warning");
3927
+ build("error");
3928
+ build("fatalError");
3929
+ return errorHandler;
3930
+ }
3931
+ function DOMHandler() {
3932
+ this.cdata = false;
3933
+ }
3934
+ function position(locator, node) {
3935
+ node.lineNumber = locator.lineNumber;
3936
+ node.columnNumber = locator.columnNumber;
3937
+ }
3938
+ DOMHandler.prototype = {
3939
+ startDocument: function() {
3940
+ this.doc = new DOMImplementation().createDocument(null, null, null);
3941
+ if (this.locator) {
3942
+ this.doc.documentURI = this.locator.systemId;
3943
+ }
3944
+ },
3945
+ startElement: function(namespaceURI, localName, qName, attrs) {
3946
+ var doc = this.doc;
3947
+ var el = doc.createElementNS(namespaceURI, qName || localName);
3948
+ var len = attrs.length;
3949
+ appendElement(this, el);
3950
+ this.currentElement = el;
3951
+ this.locator && position(this.locator, el);
3952
+ for (var i = 0; i < len; i++) {
3953
+ var namespaceURI = attrs.getURI(i);
3954
+ var value = attrs.getValue(i);
3955
+ var qName = attrs.getQName(i);
3956
+ var attr = doc.createAttributeNS(namespaceURI, qName);
3957
+ this.locator && position(attrs.getLocator(i), attr);
3958
+ attr.value = attr.nodeValue = value;
3959
+ el.setAttributeNode(attr);
3960
+ }
3961
+ },
3962
+ endElement: function(namespaceURI, localName, qName) {
3963
+ var current = this.currentElement;
3964
+ var tagName = current.tagName;
3965
+ this.currentElement = current.parentNode;
3966
+ },
3967
+ startPrefixMapping: function(prefix, uri) {
3968
+ },
3969
+ endPrefixMapping: function(prefix) {
3970
+ },
3971
+ processingInstruction: function(target, data) {
3972
+ var ins = this.doc.createProcessingInstruction(target, data);
3973
+ this.locator && position(this.locator, ins);
3974
+ appendElement(this, ins);
3975
+ },
3976
+ ignorableWhitespace: function(ch, start, length) {
3977
+ },
3978
+ characters: function(chars, start, length) {
3979
+ chars = _toString.apply(this, arguments);
3980
+ if (chars) {
3981
+ if (this.cdata) {
3982
+ var charNode = this.doc.createCDATASection(chars);
3983
+ } else {
3984
+ var charNode = this.doc.createTextNode(chars);
3985
+ }
3986
+ if (this.currentElement) {
3987
+ this.currentElement.appendChild(charNode);
3988
+ } else if (/^\s*$/.test(chars)) {
3989
+ this.doc.appendChild(charNode);
3990
+ }
3991
+ this.locator && position(this.locator, charNode);
3992
+ }
3993
+ },
3994
+ skippedEntity: function(name) {
3995
+ },
3996
+ endDocument: function() {
3997
+ this.doc.normalize();
3998
+ },
3999
+ setDocumentLocator: function(locator) {
4000
+ if (this.locator = locator) {
4001
+ locator.lineNumber = 0;
4002
+ }
4003
+ },
4004
+ comment: function(chars, start, length) {
4005
+ chars = _toString.apply(this, arguments);
4006
+ var comm = this.doc.createComment(chars);
4007
+ this.locator && position(this.locator, comm);
4008
+ appendElement(this, comm);
4009
+ },
4010
+ startCDATA: function() {
4011
+ this.cdata = true;
4012
+ },
4013
+ endCDATA: function() {
4014
+ this.cdata = false;
4015
+ },
4016
+ startDTD: function(name, publicId, systemId) {
4017
+ var impl = this.doc.implementation;
4018
+ if (impl && impl.createDocumentType) {
4019
+ var dt = impl.createDocumentType(name, publicId, systemId);
4020
+ this.locator && position(this.locator, dt);
4021
+ appendElement(this, dt);
4022
+ this.doc.doctype = dt;
4023
+ }
4024
+ },
4025
+ warning: function(error) {
4026
+ console.warn("[xmldom warning] " + error, _locator(this.locator));
4027
+ },
4028
+ error: function(error) {
4029
+ console.error("[xmldom error] " + error, _locator(this.locator));
4030
+ },
4031
+ fatalError: function(error) {
4032
+ throw new ParseError(error, this.locator);
4033
+ }
4034
+ };
4035
+ function _locator(l) {
4036
+ if (l) {
4037
+ return "\n@" + (l.systemId || "") + "#[line:" + l.lineNumber + ",col:" + l.columnNumber + "]";
4038
+ }
4039
+ }
4040
+ function _toString(chars, start, length) {
4041
+ if (typeof chars == "string") {
4042
+ return chars.substr(start, length);
4043
+ } else {
4044
+ if (chars.length >= start + length || start) {
4045
+ return new java.lang.String(chars, start, length) + "";
4046
+ }
4047
+ return chars;
4048
+ }
4049
+ }
4050
+ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
4051
+ DOMHandler.prototype[key] = function() {
4052
+ return null;
4053
+ };
4054
+ });
4055
+ function appendElement(hander, node) {
4056
+ if (!hander.currentElement) {
4057
+ hander.doc.appendChild(node);
4058
+ } else {
4059
+ hander.currentElement.appendChild(node);
4060
+ }
4061
+ }
4062
+ exports.__DOMHandler = DOMHandler;
4063
+ exports.DOMParser = DOMParser4;
4064
+ exports.DOMImplementation = dom.DOMImplementation;
4065
+ exports.XMLSerializer = dom.XMLSerializer;
4066
+ }
4067
+ });
4068
+
4069
+ // ../../node_modules/@xmldom/xmldom/lib/index.js
4070
+ var require_lib = __commonJS({
4071
+ "../../node_modules/@xmldom/xmldom/lib/index.js"(exports) {
4072
+ var dom = require_dom();
4073
+ exports.DOMImplementation = dom.DOMImplementation;
4074
+ exports.XMLSerializer = dom.XMLSerializer;
4075
+ exports.DOMParser = require_dom_parser().DOMParser;
4076
+ }
4077
+ });
4078
+
4079
+ // src/gpx-loader.ts
4080
+ function parseTextSync(text, options) {
4081
+ const doc = new import_xmldom.DOMParser().parseFromString(text, "text/xml");
4082
+ const geojson = gpx(doc);
4083
+ const shape = options?.gis?.format || options?.gpx?.type || options?.gpx?.shape;
4084
+ switch (shape) {
4085
+ case "object-row-table": {
4086
+ const table = {
4087
+ shape: "object-row-table",
4088
+ data: geojson.features
4089
+ };
4090
+ return table;
4091
+ }
4092
+ case "geojson-row-table": {
4093
+ const table = {
4094
+ shape: "geojson-row-table",
4095
+ data: geojson.features
4096
+ };
4097
+ return table;
4098
+ }
4099
+ case "geojson":
4100
+ return geojson;
4101
+ case "binary":
4102
+ return geojsonToBinary(geojson.features);
4103
+ case "raw":
1379
4104
  return doc;
1380
4105
  default:
1381
- throw new Error();
4106
+ return geojson;
1382
4107
  }
1383
4108
  }
1384
- var import_togeojson, VERSION, GPX_HEADER, GPXLoader;
4109
+ var import_xmldom, VERSION, GPX_HEADER, GPXLoader;
1385
4110
  var init_gpx_loader = __esm({
1386
4111
  "src/gpx-loader.ts"() {
1387
4112
  init_src();
1388
- import_togeojson = __toModule(require_togeojson_umd());
4113
+ init_togeojson_es();
4114
+ import_xmldom = __toModule(require_lib());
1389
4115
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1390
4116
  GPX_HEADER = `<?xml version="1.0" encoding="UTF-8"?>
1391
4117
  <gpx`;
@@ -1402,7 +4128,7 @@
1402
4128
  parseTextSync,
1403
4129
  options: {
1404
4130
  gpx: {},
1405
- gis: { format: "geojson" }
4131
+ gis: {}
1406
4132
  }
1407
4133
  };
1408
4134
  }
@@ -1410,14 +4136,24 @@
1410
4136
 
1411
4137
  // src/kml-loader.ts
1412
4138
  function parseTextSync2(text, options) {
1413
- const doc = new DOMParser().parseFromString(text, "text/xml");
1414
- const geojson = (0, import_togeojson2.kml)(doc);
1415
- switch (options?.kml?.type) {
1416
- case "object-row-table":
1417
- return geojson.features;
1418
- default:
1419
- }
1420
- switch (options?.gis?.format) {
4139
+ const doc = new import_xmldom2.DOMParser().parseFromString(text, "text/xml");
4140
+ const geojson = kml(doc);
4141
+ const shape = options?.gis?.format || options?.kml?.type || options?.kml?.shape;
4142
+ switch (shape) {
4143
+ case "object-row-table": {
4144
+ const table = {
4145
+ shape: "object-row-table",
4146
+ data: geojson.features
4147
+ };
4148
+ return table;
4149
+ }
4150
+ case "geojson-row-table": {
4151
+ const table = {
4152
+ shape: "geojson-row-table",
4153
+ data: geojson.features
4154
+ };
4155
+ return table;
4156
+ }
1421
4157
  case "geojson":
1422
4158
  return geojson;
1423
4159
  case "binary":
@@ -1425,14 +4161,15 @@
1425
4161
  case "raw":
1426
4162
  return doc;
1427
4163
  default:
1428
- throw new Error();
4164
+ return geojson;
1429
4165
  }
1430
4166
  }
1431
- var import_togeojson2, VERSION2, KML_HEADER, KMLLoader;
4167
+ var import_xmldom2, VERSION2, KML_HEADER, KMLLoader;
1432
4168
  var init_kml_loader = __esm({
1433
4169
  "src/kml-loader.ts"() {
1434
4170
  init_src();
1435
- import_togeojson2 = __toModule(require_togeojson_umd());
4171
+ init_togeojson_es();
4172
+ import_xmldom2 = __toModule(require_lib());
1436
4173
  VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1437
4174
  KML_HEADER = `<?xml version="1.0" encoding="UTF-8"?>
1438
4175
  <kml xmlns="http://www.opengis.net/kml/2.2">`;
@@ -1449,22 +4186,32 @@
1449
4186
  parseTextSync: parseTextSync2,
1450
4187
  options: {
1451
4188
  kml: {},
1452
- gis: { format: "geojson" }
4189
+ gis: {}
1453
4190
  }
1454
4191
  };
1455
4192
  }
1456
4193
  });
1457
4194
 
1458
4195
  // src/tcx-loader.ts
1459
- function parseTextSync3(text, options = {}) {
1460
- const doc = new DOMParser().parseFromString(text, "text/xml");
1461
- const geojson = (0, import_togeojson3.tcx)(doc);
1462
- switch (options?.tcx?.type) {
1463
- case "object-row-table":
1464
- return geojson.features;
1465
- default:
1466
- }
1467
- switch (options?.gis?.format) {
4196
+ function parseTextSync3(text, options) {
4197
+ const doc = new import_xmldom3.DOMParser().parseFromString(text, "text/xml");
4198
+ const geojson = tcx(doc);
4199
+ const shape = options?.gis?.format || options?.tcx?.type || options?.tcx?.shape;
4200
+ switch (shape) {
4201
+ case "object-row-table": {
4202
+ const table = {
4203
+ shape: "object-row-table",
4204
+ data: geojson.features
4205
+ };
4206
+ return table;
4207
+ }
4208
+ case "geojson-row-table": {
4209
+ const table = {
4210
+ shape: "geojson-row-table",
4211
+ data: geojson.features
4212
+ };
4213
+ return table;
4214
+ }
1468
4215
  case "geojson":
1469
4216
  return geojson;
1470
4217
  case "binary":
@@ -1472,14 +4219,15 @@
1472
4219
  case "raw":
1473
4220
  return doc;
1474
4221
  default:
1475
- throw new Error();
4222
+ return geojson;
1476
4223
  }
1477
4224
  }
1478
- var import_togeojson3, VERSION3, TCX_HEADER, TCXLoader;
4225
+ var import_xmldom3, VERSION3, TCX_HEADER, TCXLoader;
1479
4226
  var init_tcx_loader = __esm({
1480
4227
  "src/tcx-loader.ts"() {
1481
4228
  init_src();
1482
- import_togeojson3 = __toModule(require_togeojson_umd());
4229
+ init_togeojson_es();
4230
+ import_xmldom3 = __toModule(require_lib());
1483
4231
  VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1484
4232
  TCX_HEADER = `<?xml version="1.0" encoding="UTF-8"?>
1485
4233
  <TrainingCenterDatabase`;
@@ -1496,7 +4244,7 @@
1496
4244
  parseTextSync: parseTextSync3,
1497
4245
  options: {
1498
4246
  tcx: {},
1499
- gis: { format: "geojson" }
4247
+ gis: {}
1500
4248
  }
1501
4249
  };
1502
4250
  }