@mapcreator/sdk 1.5.6 → 1.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/initMap.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { MCMap } from './MCMap';
2
- import { Env, JobObjectAugmented, Mode } from './types';
2
+ import { JobObject } from './types/jobObject';
3
+ import { Env, Mode } from './types';
3
4
  export declare function initMap(options: {
4
5
  container: HTMLElement | string;
5
- job: JobObjectAugmented | string;
6
+ job: JobObject | string;
6
7
  accessToken: string;
7
8
  mode?: Mode | undefined;
8
9
  env?: Env | undefined;
@@ -40263,29 +40263,57 @@ function Lu(e) {
40263
40263
  }
40264
40264
  //#endregion
40265
40265
  //#region node_modules/bezier-easing/src/index.js
40266
- function Ru(e) {
40267
- return e;
40268
- }
40269
- var { cbrt: zu, sqrt: Bu, PI: Vu } = Math, Hu = (e, t, n, r, i) => {
40270
- let a = t + n * e, o = a ** 2 + r;
40271
- if (o > 0) {
40272
- let e = Bu(o);
40273
- return zu(a + e) + zu(a - e) - i;
40266
+ var Ru = /* @__PURE__ */ o(((e, t) => {
40267
+ var n = 4, r = .001, i = 1e-7, a = 10, o = 11, s = 1 / (o - 1), c = typeof Float32Array == "function";
40268
+ function l(e, t) {
40269
+ return 1 - 3 * t + 3 * e;
40274
40270
  }
40275
- let s = zu(Bu(a * a - o)), c = a ? Math.atan(Bu(-o) / a) : -Vu / 2, l;
40276
- return l = n < 0 ? (a > 0 ? 2 * Vu : Vu) - c : i < 0 ? (a > 0 ? 2 * Vu : -3 * Vu) + c : (a > 0 ? 0 : Vu) + c, 2 * s * Math.cos(l / 3) - i;
40277
- }, Uu = (e, t, n, r) => ((t * e + 3 * n) * e + r) * e;
40278
- function Wu(e, t, n, r) {
40279
- if (!(0 <= e && e <= 1 && 0 <= n && n <= 1)) throw Error("bezier x values must be in [0, 1] range");
40280
- if (e === t && n === r) return Ru;
40281
- let i = 6 * (3 * e - 3 * n + 1), a = 6 * (n - 2 * e), o = 3 * e, s = i * i, c = a * a, l = a / i, u = 3 * a * o / s - c * a / (s * i), d = 2 * o / i - c / s, f = d * d * d, p = 3 / i, m = 3 * t - 3 * r + 1, h = r - 2 * t, g = 3 * t, _ = i ? Hu : Ru;
40282
- return function(e) {
40283
- return e === 0 || e === 1 ? e : Uu(_(e, u, p, f, l), m, h, g);
40271
+ function u(e, t) {
40272
+ return 3 * t - 6 * e;
40273
+ }
40274
+ function d(e) {
40275
+ return 3 * e;
40276
+ }
40277
+ function f(e, t, n) {
40278
+ return ((l(t, n) * e + u(t, n)) * e + d(t)) * e;
40279
+ }
40280
+ function p(e, t, n) {
40281
+ return 3 * l(t, n) * e * e + 2 * u(t, n) * e + d(t);
40282
+ }
40283
+ function m(e, t, n, r, o) {
40284
+ var s, c, l = 0;
40285
+ do
40286
+ c = t + (n - t) / 2, s = f(c, r, o) - e, s > 0 ? n = c : t = c;
40287
+ while (Math.abs(s) > i && ++l < a);
40288
+ return c;
40289
+ }
40290
+ function h(e, t, r, i) {
40291
+ for (var a = 0; a < n; ++a) {
40292
+ var o = p(t, r, i);
40293
+ if (o === 0) return t;
40294
+ var s = f(t, r, i) - e;
40295
+ t -= s / o;
40296
+ }
40297
+ return t;
40298
+ }
40299
+ function g(e) {
40300
+ return e;
40301
+ }
40302
+ t.exports = function(e, t, n, i) {
40303
+ if (!(0 <= e && e <= 1 && 0 <= n && n <= 1)) throw Error("bezier x values must be in [0, 1] range");
40304
+ if (e === t && n === i) return g;
40305
+ for (var a = c ? new Float32Array(o) : Array(o), l = 0; l < o; ++l) a[l] = f(l * s, e, n);
40306
+ function u(t) {
40307
+ for (var i = 0, c = 1, l = o - 1; c !== l && a[c] <= t; ++c) i += s;
40308
+ --c;
40309
+ var u = (t - a[c]) / (a[c + 1] - a[c]), d = i + u * s, f = p(d, e, n);
40310
+ return f >= r ? h(t, d, e, n) : f === 0 ? d : m(t, i, i + s, e, n);
40311
+ }
40312
+ return function(e) {
40313
+ return e === 0 ? 0 : e === 1 ? 1 : f(u(e), t, i);
40314
+ };
40284
40315
  };
40285
- }
40286
- //#endregion
40287
- //#region src/utils/video/monotonicCurve.ts
40288
- var Gu = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
40316
+ })), zu = /* @__PURE__ */ o(((e, t) => {
40289
40317
  t.exports = n;
40290
40318
  function n(e, t, n, r) {
40291
40319
  var i, a, o, s, c, l, u, d, f, p, m, h, g, _;
@@ -40296,11 +40324,11 @@ var Gu = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
40296
40324
  }
40297
40325
  return g && console.log("Newton-Raphson: Maximum iterations reached (" + c + ")"), !1;
40298
40326
  }
40299
- })))(), 1), Ku = class {
40327
+ })), Bu = /* @__PURE__ */ c(Ru(), 1), Vu = /* @__PURE__ */ c(zu(), 1), Hu = class {
40300
40328
  segments;
40301
40329
  constructor(e) {
40302
40330
  this.segments = [];
40303
- let t = new qu(), n = Lu(t);
40331
+ let t = new Uu(), n = Lu(t);
40304
40332
  n.lineStart();
40305
40333
  for (let t of e) n.point(t.x, t.y);
40306
40334
  n.lineEnd(), this.segments = t.segments;
@@ -40312,17 +40340,17 @@ var Gu = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
40312
40340
  return t.startY !== t.endY && t.easing !== void 0 ? N(t.startY, t.endY, t.easing(n)) : N(t.startY, t.endY, n);
40313
40341
  }
40314
40342
  solve(e, t) {
40315
- let n = (0, Gu.default)((t) => this.sample(t) - e, t);
40343
+ let n = (0, Vu.default)((t) => this.sample(t) - e, t);
40316
40344
  return n === !1 ? t : n;
40317
40345
  }
40318
- }, qu = class {
40346
+ }, Uu = class {
40319
40347
  previousPoint = {
40320
40348
  x: 0,
40321
40349
  y: 0
40322
40350
  };
40323
40351
  segments = [];
40324
40352
  bezierCurveTo(e, t, n, r, i, a) {
40325
- let o = this.previousPoint.x, s = this.previousPoint.y, c = i === o ? void 0 : Wu((e - o) / (i - o), (t - s) / (a - s), (n - o) / (i - o), (r - s) / (a - s));
40353
+ let o = this.previousPoint.x, s = this.previousPoint.y, c = i === o ? void 0 : (0, Bu.default)((e - o) / (i - o), (t - s) / (a - s), (n - o) / (i - o), (r - s) / (a - s));
40326
40354
  this.segments.push({
40327
40355
  startX: o,
40328
40356
  endX: i,
@@ -40360,25 +40388,25 @@ var Gu = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
40360
40388
  };
40361
40389
  //#endregion
40362
40390
  //#region src/utils/video/easings.ts
40363
- function Ju(e, t, n, r) {
40391
+ function Wu(e, t, n, r) {
40364
40392
  return t + n / r * e;
40365
40393
  }
40366
- function Yu(e, t, n, r) {
40394
+ function Gu(e, t, n, r) {
40367
40395
  return n * ((e = e / r - 1) * e * e + 1) + t;
40368
40396
  }
40369
- function Xu(e, t, n, r) {
40397
+ function Ku(e, t, n, r) {
40370
40398
  let i = 1.70158, a = 0, o = n;
40371
40399
  return e === 0 ? t : (e /= r) === 1 ? t + n : (a ||= r * .3, o < Math.abs(n) ? (o = n, i = a / 4) : i = a / (2 * Math.PI) * Math.asin(n / o), o * 2 ** (-10 * e) * Math.sin((e * r - i) * (2 * Math.PI) / a) + n + t);
40372
40400
  }
40373
- function Zu(e, t, n, r, i) {
40401
+ function qu(e, t, n, r, i) {
40374
40402
  return i === void 0 && (i = 1.70158), n * ((e = e / r - 1) * e * ((i + 1) * e + i) + 1) + t;
40375
40403
  }
40376
- function Qu(e, t, n, r) {
40404
+ function Ju(e, t, n, r) {
40377
40405
  return (e /= r) < 1 / 2.75 ? n * (7.5625 * e * e) + t : e < 2 / 2.75 ? n * (7.5625 * (e -= 1.5 / 2.75) * e + .75) + t : e < 2.5 / 2.75 ? n * (7.5625 * (e -= 2.25 / 2.75) * e + .9375) + t : n * (7.5625 * (e -= 2.625 / 2.75) * e + .984375) + t;
40378
40406
  }
40379
40407
  //#endregion
40380
40408
  //#region src/utils/video/cameraCurve.ts
40381
- var $u = class {
40409
+ var Yu = class {
40382
40410
  script;
40383
40411
  xCurve;
40384
40412
  yCurve;
@@ -40436,7 +40464,7 @@ var $u = class {
40436
40464
  y: l
40437
40465
  });
40438
40466
  }
40439
- return new Ku(n);
40467
+ return new Hu(n);
40440
40468
  }
40441
40469
  sampleAutoHideOpacity(e) {
40442
40470
  let t = this.script;
@@ -40447,12 +40475,12 @@ var $u = class {
40447
40475
  if (r.hideLabels === (a?.hideLabels ?? !1)) o = r.hideLabels ? 0 : 1;
40448
40476
  else {
40449
40477
  let t = e - r.time, n = Math.min(400, i.time - r.time);
40450
- o = P(Yu(t, r.hideLabels ? 1 : 0, r.hideLabels ? -1 : 1, n), 0, 1);
40478
+ o = P(Gu(t, r.hideLabels ? 1 : 0, r.hideLabels ? -1 : 1, n), 0, 1);
40451
40479
  }
40452
40480
  let s;
40453
40481
  if (n === t.length - 2 && r.hideLabels) {
40454
40482
  let t = Math.max(r.time, i.time - 400);
40455
- s = P(Yu(e - t, 0, 1, i.time - t), 0, 1);
40483
+ s = P(Gu(e - t, 0, 1, i.time - t), 0, 1);
40456
40484
  } else s = 0;
40457
40485
  return Math.max(o, s);
40458
40486
  }
@@ -40466,8 +40494,8 @@ var $u = class {
40466
40494
  getKeyframeValue(e, t) {
40467
40495
  return t === "altitude" ? Eu(e.zoom) : e[t];
40468
40496
  }
40469
- }, ed = td;
40470
- function td(e, t, n) {
40497
+ }, Xu = Zu;
40498
+ function Zu(e, t, n) {
40471
40499
  var r = null, i = null, a = function() {
40472
40500
  r &&= (clearTimeout(r), i = null, null);
40473
40501
  }, o = function() {
@@ -40489,32 +40517,32 @@ function td(e, t, n) {
40489
40517
  }
40490
40518
  //#endregion
40491
40519
  //#region src/utils/video/animations.ts
40492
- var nd = {
40493
- linear: Ju,
40494
- easeOutCubic: Yu,
40495
- easeOutBack: Zu,
40496
- easeOutBounce: Qu,
40497
- easeOutElastic: Xu
40520
+ var Qu = {
40521
+ linear: Wu,
40522
+ easeOutCubic: Gu,
40523
+ easeOutBack: qu,
40524
+ easeOutBounce: Ju,
40525
+ easeOutElastic: Ku
40498
40526
  };
40499
- function rd(e) {
40527
+ function $u(e) {
40500
40528
  return e.entryType === "fade" || e.exitType === "fade" || e.entryType === "instant" || e.exitType === "instant";
40501
40529
  }
40502
- function id(e) {
40530
+ function ed(e) {
40503
40531
  return e.entryType === "grow" || e.exitType === "grow";
40504
40532
  }
40505
- function ad(e, t, n) {
40533
+ function td(e, t, n) {
40506
40534
  let { entry: r, entryDuration: i, exit: a, exitDuration: o } = e, { entryType: s, entryEasing: c, exitType: l, exitEasing: u } = e;
40507
- return n < r && (s === t || s === "instant" && t === "fade") || n > a && (l === t || l === "instant" && t === "fade") ? 0 : i > 0 && n < r + i && s === t ? nd[c](n - r, 0, 1, i) : o > 0 && n > a - o && l === t ? nd[u](n - (a - o), 1, -1, o) : 1;
40535
+ return n < r && (s === t || s === "instant" && t === "fade") || n > a && (l === t || l === "instant" && t === "fade") ? 0 : i > 0 && n < r + i && s === t ? Qu[c](n - r, 0, 1, i) : o > 0 && n > a - o && l === t ? Qu[u](n - (a - o), 1, -1, o) : 1;
40508
40536
  }
40509
- function od(e) {
40537
+ function nd(e) {
40510
40538
  return e.target.type === "model";
40511
40539
  }
40512
- function sd(e) {
40540
+ function rd(e) {
40513
40541
  return e.target.type === "layer" || e.target.type === "overlay";
40514
40542
  }
40515
40543
  //#endregion
40516
40544
  //#region src/Video.ts
40517
- var cd = class {
40545
+ var id = class {
40518
40546
  mcMap;
40519
40547
  cameraCurve;
40520
40548
  registryAnimations;
@@ -40542,9 +40570,9 @@ var cd = class {
40542
40570
  elevation: e.elevation ?? 0
40543
40571
  };
40544
40572
  }), u = t.video?.animations ?? [];
40545
- this.layerAnimations = u.filter(sd);
40546
- let d = u.filter(od);
40547
- this.registryAnimations = [...d.filter((e) => e.target.modelId === void 0), ...d.filter((e) => e.target.modelId !== void 0)], this.duration = Du(c), this.frameRate = Ou(t.export?.frameRate ?? 60), this.cameraCurve = new $u(c), this.registry = new fu(t), this.svgs = n, this.svgCache = r, this.mapstyle = i, this.overlays = a, this.layerInfo = o, this.backgroundColor = s;
40573
+ this.layerAnimations = u.filter(rd);
40574
+ let d = u.filter(nd);
40575
+ this.registryAnimations = [...d.filter((e) => e.target.modelId === void 0), ...d.filter((e) => e.target.modelId !== void 0)], this.duration = Du(c), this.frameRate = Ou(t.export?.frameRate ?? 60), this.cameraCurve = new Yu(c), this.registry = new fu(t), this.svgs = n, this.svgCache = r, this.mapstyle = i, this.overlays = a, this.layerInfo = o, this.backgroundColor = s;
40548
40576
  }
40549
40577
  play() {
40550
40578
  this.playbackContext === void 0 && this.duration > 0 && (this.playhead >= this.duration && (this.playhead = 0), this.playbackContext = {
@@ -40638,8 +40666,8 @@ var cd = class {
40638
40666
  let t = this.mcMap.map, { svgs: n, svgCache: r, registryAnimations: i } = this;
40639
40667
  for (let n of i) {
40640
40668
  let { target: r } = n;
40641
- if (!rd(n)) continue;
40642
- let { modelType: i, groupId: a, modelId: o } = r, s = ad(n, "fade", e);
40669
+ if (!$u(n)) continue;
40670
+ let { modelType: i, groupId: a, modelId: o } = r, s = td(n, "fade", e);
40643
40671
  if (i === "area") {
40644
40672
  let e = this.registry.models.area[a] ?? {}, n = o === void 0 ? Object.values(e) : e[o] ? [e[o]] : [];
40645
40673
  for (let e of n) t.setFeatureState({
@@ -40656,32 +40684,32 @@ var cd = class {
40656
40684
  }
40657
40685
  }
40658
40686
  for (let i of Object.values(this.registry.groups.circle)) {
40659
- let { groupAnimation: a, modelAnimations: o } = this.getGroupAnimations("circle", i.id, "scale"), s = a === void 0 ? 1 : ad(a, "grow", e);
40687
+ let { groupAnimation: a, modelAnimations: o } = this.getGroupAnimations("circle", i.id, "scale"), s = a === void 0 ? 1 : td(a, "grow", e);
40660
40688
  (a !== void 0 || o.size > 0) && t.getSource(i.id).setData({
40661
40689
  type: "FeatureCollection",
40662
40690
  features: i.models.filter((e) => e.visible ?? !0).map((t) => {
40663
40691
  let a = o.get(t.id);
40664
- return Wl(i, t, a === void 0 ? s : ad(a, "grow", e), n, r);
40692
+ return Wl(i, t, a === void 0 ? s : td(a, "grow", e), n, r);
40665
40693
  })
40666
40694
  });
40667
40695
  }
40668
40696
  for (let n of Object.values(this.registry.groups.line)) {
40669
- let { groupAnimation: i, modelAnimations: a } = this.getGroupAnimations("line", n.id, "scale"), o = i === void 0 ? 1 : ad(i, "grow", e);
40697
+ let { groupAnimation: i, modelAnimations: a } = this.getGroupAnimations("line", n.id, "scale"), o = i === void 0 ? 1 : td(i, "grow", e);
40670
40698
  (i !== void 0 || a.size > 0) && t.getSource(n.id).setData({
40671
40699
  type: "FeatureCollection",
40672
40700
  features: n.models.filter((e) => e.visible ?? !0).map((i) => {
40673
40701
  let s = a.get(i.id);
40674
- return vu(t, n, i, s === void 0 ? o : ad(s, "grow", e), r);
40702
+ return vu(t, n, i, s === void 0 ? o : td(s, "grow", e), r);
40675
40703
  })
40676
40704
  });
40677
40705
  }
40678
40706
  for (let i of Object.values(this.registry.groups.marker)) {
40679
- let { groupAnimation: a, modelAnimations: o } = this.getGroupAnimations("marker", i.id, "scale"), s = a === void 0 ? 1 : ad(a, "grow", e);
40707
+ let { groupAnimation: a, modelAnimations: o } = this.getGroupAnimations("marker", i.id, "scale"), s = a === void 0 ? 1 : td(a, "grow", e);
40680
40708
  (a !== void 0 || o.size > 0) && t.getSource(i.id).setData({
40681
40709
  type: "FeatureCollection",
40682
40710
  features: i.models.filter((e) => e.visible ?? !0).map((a) => {
40683
40711
  let c = o.get(a.id);
40684
- return Jl(t, i, a, c === void 0 ? s : ad(c, "grow", e), n, r);
40712
+ return Jl(t, i, a, c === void 0 ? s : td(c, "grow", e), n, r);
40685
40713
  })
40686
40714
  });
40687
40715
  }
@@ -40702,7 +40730,7 @@ var cd = class {
40702
40730
  delay: 0
40703
40731
  }), e.setSourceTileLodParams(1, 4), this.restoreAfterPlayback();
40704
40732
  }
40705
- restoreAfterPlayback = ed(() => {
40733
+ restoreAfterPlayback = Xu(() => {
40706
40734
  let e = this.mcMap.map;
40707
40735
  e.setCenterClampedToGround(!0), e.setRasterAlignment(!0), e.style?.stylesheet && (e.style.stylesheet.transition = void 0), e.setSourceTileLodParams(p, 3);
40708
40736
  }, 300);
@@ -40710,7 +40738,7 @@ var cd = class {
40710
40738
  let r, i = /* @__PURE__ */ new Map();
40711
40739
  for (let a of this.registryAnimations) {
40712
40740
  let { target: o } = a;
40713
- o.modelType === e && o.groupId === t && (n === "opacity" && rd(a) || n === "scale" && id(a)) && (o.modelId === void 0 ? r = a : i.set(o.modelId, a));
40741
+ o.modelType === e && o.groupId === t && (n === "opacity" && $u(a) || n === "scale" && ed(a)) && (o.modelId === void 0 ? r = a : i.set(o.modelId, a));
40714
40742
  }
40715
40743
  return {
40716
40744
  groupAnimation: r,
@@ -40725,7 +40753,7 @@ var cd = class {
40725
40753
  n.type === "layer" && n.ids.includes(e.id) && n.ids.length < a && (i = t, a = n.ids.length);
40726
40754
  }
40727
40755
  let o = this.layerInfo[e.id]?.opacity ?? m[e.type].defaultValue;
40728
- return i === void 0 ? r === void 0 ? void 0 : ad(r, "fade", t) * o : ad(i, "fade", t) * o;
40756
+ return i === void 0 ? r === void 0 ? void 0 : td(r, "fade", t) * o : td(i, "fade", t) * o;
40729
40757
  }
40730
40758
  setLayerOpacity(e, t) {
40731
40759
  let n = this.mcMap.map, r = m[e.type];
@@ -40735,11 +40763,11 @@ var cd = class {
40735
40763
  let t = this.mcMap.map, n = m[e.type], r = this.layerInfo[e.id]?.opacity;
40736
40764
  for (let i of n.props) t.setPaintProperty(e.id, i, r ?? e.paint?.[i] ?? n.defaultValue);
40737
40765
  }
40738
- }, ld = class extends l.Evented {
40766
+ }, ad = class extends l.Evented {
40739
40767
  map;
40740
40768
  video;
40741
40769
  constructor(e, t, n, r, i, a, o, s) {
40742
- super(), this.map = e, this.video = new cd(this, t, n, r, i, a, o, s);
40770
+ super(), this.map = e, this.video = new id(this, t, n, r, i, a, o, s);
40743
40771
  }
40744
40772
  on(e, t) {
40745
40773
  return super.on(e, t);
@@ -40771,9 +40799,9 @@ var cd = class {
40771
40799
  };
40772
40800
  //#endregion
40773
40801
  //#region src/initMap.ts
40774
- async function ud(e) {
40775
- let { accessToken: t, mode: n = "sdk", env: r = "production" } = e, i = r === "bleeding" ? "https://vapi.bleeding.mc-cdn.io" : r === "beta" ? "https://vapi.beta.mc-cdn.io" : "https://vapi.mc-cdn.io", a = r === "bleeding" ? "https://cdn.bleeding.mapcreator.io" : r === "beta" ? "https://cdn.beta.mapcreator.io" : "https://cdn.mapcreator.io", o = typeof e.job == "string" ? await dd(e.job, a, t) : e.job;
40776
- await fd();
40802
+ async function od(e) {
40803
+ let { accessToken: t, mode: n = "sdk", env: r = "production" } = e, i = r === "bleeding" ? "https://vapi.bleeding.mc-cdn.io" : r === "beta" ? "https://vapi.beta.mc-cdn.io" : "https://vapi.mc-cdn.io", a = r === "bleeding" ? "https://cdn.bleeding.mapcreator.io" : r === "beta" ? "https://cdn.beta.mapcreator.io" : "https://cdn.mapcreator.io", o = typeof e.job == "string" ? await sd(e.job, a, t) : e.job;
40804
+ await cd();
40777
40805
  let s = {
40778
40806
  container: e.container,
40779
40807
  attributionControl: !1,
@@ -40808,19 +40836,25 @@ async function ud(e) {
40808
40836
  let { restrictMapMovement: e, popupPosition: t } = E;
40809
40837
  e && (c.boxZoom.disable(), c.doubleClickZoom.disable(), c.dragPan.disable(), c.dragRotate.disable(), c.keyboard.disable(), c.scrollZoom.disable(), c.touchPitch.disable(), c.touchZoomRotate.disable()), f.setParams(t, x(p, y.TWO), e, g);
40810
40838
  }
40811
- let te = await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then((e) => e.json());
40812
- Bl(te), c.setStyle(null), c.setStyle(te), await c.once("style.load"), n === "app" && gd(c.getStyle().metadata?.customCssFilePath, t), _(p, c);
40813
- let F = await Yl(o.map.overlays ?? [], o.meta.layers ?? [], c, i, t, te.metadata?.styleOverride), ne = (o.map.overlays ?? []).reduce((e, t, n) => e.set(t, F[n]), /* @__PURE__ */ new Map());
40814
- yd(c, M, k, A, j, i, t), _(p, c), f.setPublication(te.metadata?.publication), f.setpopupElements(), f.setHighlightManager(), c.setProjection({ type: S === "globe" ? "globe" : "mercator" });
40815
- let ie = pd(c, S);
40816
- md(c, ie), C && hd(c, i, t, w);
40817
- let oe = _d(o.map.layerInfo, te, F);
40818
- return vd(c, oe, !v), new ld(c, o, j, M, te, ne, oe, ie);
40819
- }
40820
- function dd(e, t, n) {
40839
+ let te = o.meta?.mapstyleSet, F = te === void 0 ? {
40840
+ version: 8,
40841
+ sources: {},
40842
+ layers: []
40843
+ } : await fetch(`${i}/styles/${te}.json?access_token=${t}`).then((e) => e.json());
40844
+ Bl(F), c.setStyle(null), c.setStyle(F), await c.once("style.load"), n === "app" && fd(c.getStyle().metadata?.customCssFilePath, t), _(p, c);
40845
+ let ne = o.map.overlays ?? [], ie = o.meta?.layers ?? [];
40846
+ ne.length !== ie.length && (ne = [], ie = []);
40847
+ let oe = await Yl(ne, ie, c, i, t, F.metadata?.styleOverride), se = ne.reduce((e, t, n) => e.set(t, oe[n]), /* @__PURE__ */ new Map());
40848
+ hd(c, M, k, A, j, i, t), _(p, c), f.setPublication(F.metadata?.publication), f.setpopupElements(), f.setHighlightManager(), c.setProjection({ type: S === "globe" ? "globe" : "mercator" });
40849
+ let ce = ld(c, S);
40850
+ ud(c, ce), C && dd(c, i, t, w);
40851
+ let le = pd(o.map.layerInfo, F, oe);
40852
+ return md(c, le, !v), new ad(c, o, j, M, F, se, le, ce);
40853
+ }
40854
+ function sd(e, t, n) {
40821
40855
  return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then((e) => e.json());
40822
40856
  }
40823
- function fd() {
40857
+ function cd() {
40824
40858
  return new Promise((e) => {
40825
40859
  let t = () => {
40826
40860
  window.innerWidth > 0 && window.innerHeight > 0 && (window.removeEventListener("resize", t), e());
@@ -40828,18 +40862,18 @@ function fd() {
40828
40862
  window.addEventListener("resize", t), t();
40829
40863
  });
40830
40864
  }
40831
- function pd(e, t) {
40865
+ function ld(e, t) {
40832
40866
  let n = e.getStyle().metadata ?? {}, r = n["mc:background-color"] ?? "#f8f8f8", i = n["mc:background-color-globe"] ?? "#000000";
40833
40867
  return t === "globe" ? i : r;
40834
40868
  }
40835
- function md(e, t) {
40869
+ function ud(e, t) {
40836
40870
  e.getContainer().style.backgroundColor = t, e.setSky(e.getStyle().sky ?? u), e.setLight({ position: [
40837
40871
  1.15,
40838
40872
  210,
40839
40873
  45
40840
40874
  ] });
40841
40875
  }
40842
- function hd(e, t, n, r) {
40876
+ function dd(e, t, n, r) {
40843
40877
  e.addSource("mc-dem", {
40844
40878
  type: "raster-dem",
40845
40879
  tiles: [`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],
@@ -40851,12 +40885,12 @@ function hd(e, t, n, r) {
40851
40885
  exaggeration: r
40852
40886
  });
40853
40887
  }
40854
- function gd(e, t) {
40888
+ function fd(e, t) {
40855
40889
  if (document.getElementById("custom-style")?.remove(), !e) return;
40856
40890
  let n;
40857
40891
  e.startsWith("http") ? (e = `${e}?access_token=${t}`, n = document.createElement("link"), n.setAttribute("rel", "stylesheet"), n.setAttribute("href", e.replace(/https?:/, ""))) : (n = document.createElement("style"), n.appendChild(document.createTextNode(e))), n.setAttribute("id", "custom-style"), n.setAttribute("type", "text/css"), document.head.appendChild(n);
40858
40892
  }
40859
- function _d(e, t, n) {
40893
+ function pd(e, t, n) {
40860
40894
  let r = e?.reduce((e, t) => (e[t.id] = {
40861
40895
  visibility: t.visibility,
40862
40896
  ...t.opacity !== void 0 && { opacity: t.opacity }
@@ -40865,7 +40899,7 @@ function _d(e, t, n) {
40865
40899
  for (let e of n) for (let t of e.layers) i[t.id] = r[t.id] ?? { visibility: !1 };
40866
40900
  return i;
40867
40901
  }
40868
- function vd(e, t, n) {
40902
+ function md(e, t, n) {
40869
40903
  for (let r in t) {
40870
40904
  let i = e.getLayer(r);
40871
40905
  if (i !== void 0) {
@@ -40877,19 +40911,19 @@ function vd(e, t, n) {
40877
40911
  }
40878
40912
  }
40879
40913
  }
40880
- function yd(e, t, n, r, i, a, o) {
40914
+ function hd(e, t, n, r, i, a, o) {
40881
40915
  let { beforeNone: s = [], beforeNames: c = [], beforeBoundaries: l = [], beforeWaters: u = [] } = r;
40882
40916
  s.forEach((r) => {
40883
- bd(e, t, n, r, i, "mc-before-none", a, o);
40917
+ gd(e, t, n, r, i, "mc-before-none", a, o);
40884
40918
  }), c.forEach((r) => {
40885
- bd(e, t, n, r, i, "mc-before-names", a, o);
40919
+ gd(e, t, n, r, i, "mc-before-names", a, o);
40886
40920
  }), l.forEach((r) => {
40887
- bd(e, t, n, r, i, "mc-before-boundaries", a, o);
40921
+ gd(e, t, n, r, i, "mc-before-boundaries", a, o);
40888
40922
  }), u.forEach((r) => {
40889
- bd(e, t, n, r, i, "mc-before-waters", a, o);
40923
+ gd(e, t, n, r, i, "mc-before-waters", a, o);
40890
40924
  });
40891
40925
  }
40892
- function bd(e, t, n, r, i, a, o, s) {
40926
+ function gd(e, t, n, r, i, a, o, s) {
40893
40927
  if (r.type === "marker") {
40894
40928
  let o = n.marker?.find((e) => e.id === r.groupId);
40895
40929
  o && Kl(e, o, a, i, t);
@@ -40911,5 +40945,5 @@ function bd(e, t, n, r, i, a, o, s) {
40911
40945
  }
40912
40946
  }
40913
40947
  //#endregion
40914
- var xd = l.setRTLTextPlugin;
40915
- export { ud as initMap, xd as setRTLTextPlugin };
40948
+ var _d = l.setRTLTextPlugin;
40949
+ export { od as initMap, _d as setRTLTextPlugin };
@@ -1183,4 +1183,4 @@ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matr
1183
1183
  <div class="popup-scroll-wrapper">
1184
1184
  <div class="mc-popup data-layer text-content">${n}</div>
1185
1185
  </div>
1186
- `}return n}htmlToElement(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content.firstElementChild}addPopupControls(){let e=this.htmlToElement(su);if(e&&(e.addEventListener(`click`,()=>{this.hidePopup(),this.highlightManager.highlight(void 0)}),this.popupContainer.appendChild(e)),this.popupElements.length>1){let e=this.htmlToElement(cu);e&&(e.querySelector(`.prev`)?.addEventListener(`click`,()=>this.cyclePopups(!1)),e.querySelector(`.next`)?.addEventListener(`click`,()=>this.cyclePopups()),this.popupContainer.appendChild(e))}}fillDatalayerTemplate(e,t,n){let r=`data-mention-id`,i=new DOMParser().parseFromString(t,`text/html`).body;for(let t of i.querySelectorAll(`[${r}]`)){let i=this.getProperty(e,t.getAttribute(r),n);i!==void 0&&(t.innerText=i)}return i.innerHTML}getProperty(e,t,n){if(!t)return;let r=t.endsWith(`:en`)?[t.replace(`:en`,n),t]:[t];for(let t of r){let n=e.properties[t]??this.getVectorProperty(e,t);if(n!==void 0)return n}}getVectorProperty(e,t){let n=this.promoteIdCache.get(e.source);n===void 0&&(n=this.map.getSource(e.source)?.serialize().promoteId||`id`,this.promoteIdCache.set(e.source,n));try{let r=e.properties[n];return e.layer.metadata.properties[t][r]}catch{return}}cyclePopups(e=!0){let t=this.popupElements?.findIndex(e=>e.modelId===this.currentModelId);if(t!==-1){let n=0;n=e?t===this.popupElements.length-1?0:t+1:t===0?this.popupElements.length-1:t-1;let r=this.popupElements?.[n];this.currentModelId=r.modelId,this.highlightManager.highlight(r,!0);let i=ou(r.popup,r.popupMedia,r.dataBindings??{},this.mode),a=this.popupContainer;this.popupContainer.remove(),a.innerHTML=i,this.mapContainer.appendChild(a),this.addPopupControls(),e?this.popupContainer.querySelector(`.mc-popup-button.next`)?.focus():this.popupContainer.querySelector(`.mc-popup-button.prev`)?.focus()}}},gu=class e{static#e(e){let t=0,n=[t];for(let r=1;r<e.length;++r){let i=e[r-1],a=e[r],o=a.x-i.x,s=a.y-i.y;t+=Math.sqrt(o*o+s*s),n.push(t)}return n}static#t(e,t){return e.x===t.x&&e.y===t.y}#n;#r;#i;#a;constructor(t){this.#n=t.filter((e,n)=>n===0||t[n][0]!==t[n-1][0]||t[n][1]!==t[n-1][1]),this.#r=this.#n.map(e=>u.MercatorCoordinate.fromLngLat(e)),this.#i=e.#e(this.#r),this.#a=this.#i[this.#i.length-1]}sample(e){let t=this.#r,n=this.#i;if(t.length<2)return t[0];e*=this.#a;for(let r=1;r<t.length;++r){let i=t[r-1],a=t[r],o=n[r-1],s=n[r];if(s>=e){let t=(e-o)/(s-o);return new u.MercatorCoordinate(ee(i.x,a.x,t),ee(i.y,a.y,t))}}return new u.MercatorCoordinate(t[t.length-1].x,t[t.length-1].y)}slice(t,n){if(this.#n.length<2)return this.#n;let r=this.#r.filter((e,r)=>this.#i[r]>=t*this.#a&&this.#i[r]<=n*this.#a);if(t>0){let n=this.sample(t);e.#t(n,r[0])||r.unshift(n)}if(n<1){let t=this.sample(n);e.#t(t,r[r.length-1])||r.push(t)}return r.map(e=>{let{lng:t,lat:n}=e.toLngLat();return[t,n]})}get length(){return this.#a}},_u={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function vu(e,t,n,r){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(n=>yu(e,t,n,1,r))}}),Object.entries(_u).forEach(([r,i])=>{t.models.some(e=>(e.lineStyle??`solid`)===r)&&e.addLayer({id:`${t.id}-${r}`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`==`,[`get`,`line-style`],r]],paint:{"line-width":[`get`,`line-width`],"line-color":[`get`,`line-color`],"line-dasharray":i,"line-opacity":[`coalesce`,[`feature-state`,`opacity`],1]}},n)}),e.addLayer({id:`${t.id}-clickable`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},paint:{"line-width":[`max`,[`get`,`line-width`],15],"line-opacity":0},filter:[`==`,[`geometry-type`],`LineString`]},n),t.models.some(e=>e.svg)&&e.addLayer({id:`${t.id}-icon`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-image":[`get`,`mc-image-key`],"icon-anchor":`center`,"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],1]},filter:[`==`,[`geometry-type`],`Point`]},n)}function yu(e,t,n,r,i){let a=new gu(n.geometry).slice(0,r),o=n.svg===void 0?void 0:i.getMapLibreImageKey(mi(n.dataBindings??{},n.svg,void 0),window.devicePixelRatio*(n.iconScale??1)*e.getScale());return{type:`Feature`,id:D(n.id),properties:{id:n.id,"line-width":n.lineWidth??3,"line-color":t.lineColor||n.lineColor?fi(n.dataBindings??{},n.lineColor,t.lineColor):`#000000`,"line-style":n.lineStyle??`solid`,"mc-image-key":o,"icon-rotate":bu(n,a,e),"icon-offset":n.iconOffset,"icon-size":n.iconScale},geometry:{type:`GeometryCollection`,geometries:[{type:`LineString`,coordinates:a},{type:`Point`,coordinates:a[a.length-1]}]}}}function bu(e,t,n){return e.iconRotation?e.iconAlign?wr(t,n)+e.iconRotation:e.iconRotation:0}function xu(e,t,n,r,i,a,o){let s=jr(t),c=new Map,l=new Map;for(let e of t.models){let n=e.featureId,a=t.id,o=[],u=Sr(e),d=xr(a,e),f=l.get(d)??{model:e,featureIds:o,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{},modelIdToOutlineWidth:{}};if(e.visible??!0){f.featureIds.push(n);let a=e.fillPattern===void 0?null:i.getMapLibreImageKey(r[e.fillPattern],2*window.devicePixelRatio);f.modelIdToFillColor[n]=t.fillColor||e.fillColor?fi(e.dataBindings??{},e.fillColor,t.fillColor,s,t.choropleth?.unmatchedColor):`#000000`,f.modelIdToFillPattern[n]=a,f.modelIdToOutlineColor[n]=t.outlineColor||e.outlineColor?fi(e.dataBindings??{},e.outlineColor,t.outlineColor):`#000000`,f.modelIdToOutlineWidth[n]=e.outlineWidth??.5}c.set(u,e),l.set(d,f)}for(let t of c.keys())e.getSource(t)||e.addSource(t,{type:`vector`,url:`${a}${c.get(t).vectorUrl}?access_token=${o}`,promoteId:`id`});for(let r of l.keys()){let{model:i}=l.get(r),{sourceLayerId:a}=i,o=Sr(i);e.addLayer({id:r,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-color":`#ffffff`,"fill-outline-color":`#000000`,"fill-antialias":!1,"fill-opacity":[`coalesce`,[`feature-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${r}-pattern`,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity-${t.id}`],1]},layout:{visibility:`visible`}},n),e.addLayer({id:`${r}-outline`,type:`line`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"line-color":`#000000`,"line-width":.5,"line-opacity":[`coalesce`,[`feature-state`,`opacity-${t.id}`],1]}},n)}l.forEach((t,n)=>{let{featureIds:r,modelIdToFillColor:i,modelIdToFillPattern:a,modelIdToOutlineColor:o,modelIdToOutlineWidth:s}=t;e.setFilter(n,[`in`,`id`,...r]),e.setFilter(`${n}-outline`,[`in`,`id`,...r]),e.setPaintProperty(n,`fill-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,i]]),e.setPaintProperty(`${n}-outline`,`line-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,o]]),e.setPaintProperty(`${n}-outline`,`line-width`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,s]]),e.setFilter(`${n}-pattern`,[`to-boolean`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]]]),e.setPaintProperty(`${n}-pattern`,`fill-pattern`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]])})}function Su(e,t,n){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>Cu(t,e))}}),e.addLayer({id:t.id,type:`circle`,source:t.id,metadata:{"mc-model-type":`dot`,"mc-group-id":t.id},paint:{"circle-color":[`get`,`circle-color`],"circle-radius":[`get`,`circle-radius`],"circle-opacity":[`coalesce`,[`feature-state`,`opacity`],1]}},n)}function Cu(e,t){return{type:`Feature`,id:t.id,properties:{id:t.id,"circle-radius":t.radius,"circle-color":e.fillColor||t.fillColor?fi(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`},geometry:{type:`Point`,coordinates:[t.center.lng,t.center.lat]}}}function wu(e){let t=e.length>0?[Tu(e[0])]:[],n=0,r=0;for(let i=1;i<e.length;++i){let a=Tu(e[i]);n+=Eu(e[i-1].center[0],a.center[0]),r+=Eu(e[i-1].bearing,a.bearing),a.center[0]+=n*360,a.x+=n,a.bearing+=r*360,t.push(a)}return t}function Tu(e){return{...e,center:[e.center[0],e.center[1]]}}function Eu(e,t){if(Math.abs(e)+Math.abs(t)>180){if(e>0&&t<0)return 1;if(e<0&&t>0)return-1}return 0}function Du(e){return 2**-e}function Ou(e){return e.length>0?e[e.length-1].time:0}function ku(e){return ae(e,23.976)?24e3/1001:ae(e,29.97)?3e4/1001:ae(e,59.94)?6e4/1001:e}function Au(e,t){return e===void 0||t===void 0?e===t:e.center.lat===t.center.lat&&e.center.lng===t.center.lng&&e.zoom===t.zoom&&e.bearing===t.bearing&&e.pitch===t.pitch&&e.fov===t.fov&&e.elevation===t.elevation}function ju(e){return e<0?-1:1}function Mu(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(ju(a)+ju(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function Nu(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Pu(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function Fu(e){this._context=e}Fu.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Pu(this,this._t0,Nu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Pu(this,Nu(this,n=Mu(this,e,t)),n);break;default:Pu(this,this._t0,n=Mu(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function Iu(e){this._context=new Lu(e)}(Iu.prototype=Object.create(Fu.prototype)).point=function(e,t){Fu.prototype.point.call(this,t,e)};function Lu(e){this._context=e}Lu.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function Ru(e){return new Fu(e)}function zu(e){return e}var{cbrt:Bu,sqrt:Vu,PI:Hu}=Math,Uu=(e,t,n,r,i)=>{let a=t+n*e,o=a**2+r;if(o>0){let e=Vu(o);return Bu(a+e)+Bu(a-e)-i}let s=Bu(Vu(a*a-o)),c=a?Math.atan(Vu(-o)/a):-Hu/2,l;return l=n<0?(a>0?2*Hu:Hu)-c:i<0?(a>0?2*Hu:-3*Hu)+c:(a>0?0:Hu)+c,2*s*Math.cos(l/3)-i},Wu=(e,t,n,r)=>((t*e+3*n)*e+r)*e;function Gu(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw Error(`bezier x values must be in [0, 1] range`);if(e===t&&n===r)return zu;let i=6*(3*e-3*n+1),a=6*(n-2*e),o=3*e,s=i*i,c=a*a,l=a/i,u=3*a*o/s-c*a/(s*i),d=2*o/i-c/s,f=d*d*d,p=3/i,m=3*t-3*r+1,h=r-2*t,g=3*t,_=i?Uu:zu;return function(e){return e===0||e===1?e:Wu(_(e,u,p,f,l),m,h,g)}}var Ku=l(s(((e,t)=>{t.exports=n;function n(e,t,n,r){var i,a,o,s,c,l,u,d,f,p,m,h,g,_;for(typeof t!=`function`&&(r=n,n=t,t=null),r||={},s=r.tolerance===void 0?1e-7:r.tolerance,_=r.epsilon===void 0?2220446049250313e-31:r.epsilon,c=r.maxIterations===void 0?20:r.maxIterations,m=r.h===void 0?1e-4:r.h,g=r.verbose===void 0?!1:r.verbose,h=1/m,l=0;l++<c;){if(a=e(n),t?o=t(n):(u=e(n+m),d=e(n-m),f=e(n+2*m),p=e(n-2*m),o=(p-f+8*(u-d))*h/12),Math.abs(o)<=_*Math.abs(a))return g&&console.log(`Newton-Raphson: failed to converged due to nearly zero first derivative`),!1;if(i=n-a/o,Math.abs(i-n)<=s*Math.abs(i))return g&&console.log(`Newton-Raphson: converged to x = `+i+` after `+l+` iterations`),i;n=i}return g&&console.log(`Newton-Raphson: Maximum iterations reached (`+c+`)`),!1}}))(),1),qu=class{segments;constructor(e){this.segments=[];let t=new Ju,n=Ru(t);n.lineStart();for(let t of e)n.point(t.x,t.y);n.lineEnd(),this.segments=t.segments}sample(e){if(e<=0)return this.segments[0].startY;if(e>=this.segments[this.segments.length-1].endX)return this.segments[this.segments.length-1].endY;let t=this.segments.find(t=>e>=t.startX&&e<t.endX),n=P(t.startX,t.endX,e);return t.startY!==t.endY&&t.easing!==void 0?ee(t.startY,t.endY,t.easing(n)):ee(t.startY,t.endY,n)}solve(e,t){let n=(0,Ku.default)(t=>this.sample(t)-e,t);return n===!1?t:n}},Ju=class{previousPoint={x:0,y:0};segments=[];bezierCurveTo(e,t,n,r,i,a){let o=this.previousPoint.x,s=this.previousPoint.y,c=i===o?void 0:Gu((e-o)/(i-o),(t-s)/(a-s),(n-o)/(i-o),(r-s)/(a-s));this.segments.push({startX:o,endX:i,startY:s,endY:a,easing:c}),this.previousPoint={x:i,y:a}}lineTo(e,t){this.segments.push({startX:this.previousPoint.x,endX:e,startY:this.previousPoint.y,endY:t,easing:void 0}),this.previousPoint={x:e,y:t}}moveTo(e,t){this.previousPoint={x:e,y:t}}closePath(){}arc(){}rect(){}arcTo(){}quadraticCurveTo(){}};function Yu(e,t,n,r){return t+n/r*e}function Xu(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function Zu(e,t,n,r){let i=1.70158,a=0,o=n;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,o<Math.abs(n)?(o=n,i=a/4):i=a/(2*Math.PI)*Math.asin(n/o),o*2**(-10*e)*Math.sin((e*r-i)*(2*Math.PI)/a)+n+t)}function Qu(e,t,n,r,i){return i===void 0&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function $u(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}var ed=class{script;xCurve;yCurve;fovCurve;zoomCurve;pitchCurve;bearingCurve;altitudeCurve;elevationCurve;constructor(e){this.script=wu(e),this.xCurve=this.createMonotonicCurve(this.script,`x`),this.yCurve=this.createMonotonicCurve(this.script,`y`),this.fovCurve=this.createMonotonicCurve(this.script,`fov`),this.zoomCurve=this.createMonotonicCurve(this.script,`zoom`),this.pitchCurve=this.createMonotonicCurve(this.script,`pitch`),this.bearingCurve=this.createMonotonicCurve(this.script,`bearing`),this.altitudeCurve=this.createMonotonicCurve(this.script,`altitude`),this.elevationCurve=this.createMonotonicCurve(this.script,`elevation`)}sample(e){let t=this.zoomCurve.sample(e),n=this.altitudeCurve.solve(Du(t),e),r=this.xCurve.sample(n),i=this.yCurve.sample(n),a=this.elevationCurve.sample(n),o=this.bearingCurve.sample(e),s=this.pitchCurve.sample(e),c=this.fovCurve.sample(e);return{center:new u.MercatorCoordinate(r,i).toLngLat(),zoom:t,bearing:o,pitch:s,fov:c,elevation:a}}createMonotonicCurve(e,t){let n=[];for(let r=0;r<e.length;r++){let i=r===0,a=r===e.length-1,o=e[r],s=e[r+1],c=e[r-1],l=this.getKeyframeValue(o,t);if(i&&n.push({x:-1,y:l}),n.push({x:o.time,y:l}),!i&&!a&&c.transition===`instant`&&o.transition===`ease`&&n.push({x:o.time+.1,y:l}),!a)if(o.transition===`linear`){let e=o.time+.1,r=s.time-.1,i=P(o.time,s.time,e),a=P(o.time,s.time,r),c=this.getKeyframeValue(s,t);n.push({x:e,y:ee(l,c,i)}),n.push({x:r,y:ee(l,c,a)})}else o.transition===`instant`&&(n.push({x:o.time+.1,y:l}),n.push({x:s.time-.1,y:l}));a&&n.push({x:o.time+1,y:l})}return new qu(n)}sampleAutoHideOpacity(e){let t=this.script;if(t.length<2)return 1;let n=this.getKeyframeIndexByTime(e);if(n===-1||n===t.length-1)return 1;let r=t[n],i=t[n+1],a=n>0?t[n-1]:void 0,o;if(r.hideLabels===(a?.hideLabels??!1))o=r.hideLabels?0:1;else{let t=e-r.time,n=Math.min(400,i.time-r.time);o=te(Xu(t,r.hideLabels?1:0,r.hideLabels?-1:1,n),0,1)}let s;if(n===t.length-2&&r.hideLabels){let t=Math.max(r.time,i.time-400);s=te(Xu(e-t,0,1,i.time-t),0,1)}else s=0;return Math.max(o,s)}getKeyframeIndexByTime(e){let t=this.script;if(t.length!==0){for(let n=0;n<t.length;n++)if(e<t[n].time)return n-1;return t.length-1}}getKeyframeValue(e,t){return t===`altitude`?Du(e.zoom):e[t]}},td=nd;function nd(e,t,n){var r=null,i=null,a=function(){r&&=(clearTimeout(r),i=null,null)},o=function(){var e=i;a(),e&&e()},s=function(){if(!t)return e.apply(this,arguments);var o=this,s=arguments,c=n&&!r;if(a(),i=function(){e.apply(o,s)},r=setTimeout(function(){if(r=null,!c){var e=i;return i=null,e()}},t),c)return i()};return s.cancel=a,s.flush=o,s}var rd={linear:Yu,easeOutCubic:Xu,easeOutBack:Qu,easeOutBounce:$u,easeOutElastic:Zu};function id(e){return e.entryType===`fade`||e.exitType===`fade`||e.entryType===`instant`||e.exitType===`instant`}function ad(e){return e.entryType===`grow`||e.exitType===`grow`}function od(e,t,n){let{entry:r,entryDuration:i,exit:a,exitDuration:o}=e,{entryType:s,entryEasing:c,exitType:l,exitEasing:u}=e;return n<r&&(s===t||s===`instant`&&t===`fade`)||n>a&&(l===t||l===`instant`&&t===`fade`)?0:i>0&&n<r+i&&s===t?rd[c](n-r,0,1,i):o>0&&n>a-o&&l===t?rd[u](n-(a-o),1,-1,o):1}function sd(e){return e.target.type===`model`}function cd(e){return e.target.type===`layer`||e.target.type===`overlay`}var ld=class{mcMap;cameraCurve;registryAnimations;layerAnimations;registry;svgs;svgCache;duration;frameRate;mapstyle;overlays;layerInfo;backgroundColor;playhead;playbackContext;constructor(e,t,n,r,i,a,o,s){this.mcMap=e,this.playhead=0,this.playbackContext=void 0;let c=(t.video?.keyframes??[]).map(e=>{let{x:t,y:n}=u.MercatorCoordinate.fromLngLat(e.center);return{...e,x:t,y:n,fov:e.fov??36.87,elevation:e.elevation??0}}),l=t.video?.animations??[];this.layerAnimations=l.filter(cd);let d=l.filter(sd);this.registryAnimations=[...d.filter(e=>e.target.modelId===void 0),...d.filter(e=>e.target.modelId!==void 0)],this.duration=Ou(c),this.frameRate=ku(t.export?.frameRate??60),this.cameraCurve=new ed(c),this.registry=new pu(t),this.svgs=n,this.svgCache=r,this.mapstyle=i,this.overlays=a,this.layerInfo=o,this.backgroundColor=s}play(){this.playbackContext===void 0&&this.duration>0&&(this.playhead>=this.duration&&(this.playhead=0),this.playbackContext={startTime:Date.now(),startPlayhead:this.playhead},this.mcMap.fire(`playstart`,{time:this.playhead}),this.playFrame())}pause(){this.playbackContext!==void 0&&(this.playbackContext=void 0,this.restoreAfterPlayback.flush(),this.mcMap.fire(`playend`,{time:this.playhead}))}seekTo(e){this.duration>0&&(e=te(e,0,this.duration),this.prepareForPlayback(),this.setFrame(e),this.playbackContext!==void 0&&(this.playbackContext={startTime:Date.now(),startPlayhead:e}))}async*frames(){let e=this.mcMap.map,t=Math.ceil(this.duration*this.frameRate/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setRasterAlignment(!1),e.setCenterClampedToGround(!1),e.setSourceTileLodParams(1,4);let n=e.getCanvas(),{width:r,height:i}=n,a=new OffscreenCanvas(r,i).getContext(`2d`,{desynchronized:!0,willReadFrequently:!0}),o=e.getContainer(),s=o.getBoundingClientRect();for(let e=0;e<t;e++)yield this.captureFrame(e*1e3/this.frameRate,n,a,r,i,o,s);e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setRasterAlignment(!0),e.setCenterClampedToGround(!0),e.setSourceTileLodParams(m,3),this.playhead=0}async preload(){this.playbackContext!==void 0&&this.pause();let e=this.mcMap.map,t=Math.ceil(this.duration*this.frameRate/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setCenterClampedToGround(!1),e.setSourceTileLodParams(1,4),e.setRasterAlignment(!1);try{let n;for(let r=0;r<t;r++){let t=this.cameraCurve.sample(r*1e3/this.frameRate);Au(n,t)||(this.setCamera(t),await this.waitForRenderOrAbort()===`render`?n=t:(n!==void 0&&this.setCamera(n),e.triggerRepaint(),await e.once(`idle`),r--))}e.areTilesLoaded()||await e.once(`idle`)}finally{e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setCenterClampedToGround(!0),e.setSourceTileLodParams(m,3),e.setRasterAlignment(!0)}}waitForRenderOrAbort(){let e=this.mcMap.map;return new Promise(t=>{let n=()=>{e.off(`render`,r),e.off(`dataabort`,i)},r=()=>{n(),t(`render`)},i=e=>{e.tile?.state===`loading`&&(n(),t(`abort`))};e.on(`render`,r),e.on(`dataabort`,i)})}async captureFrame(e,t,n,r,i,a,o){return this.setFrame(e),await this.mcMap.map.once(`idle`),n.fillStyle=this.backgroundColor,n.fillRect(0,0,r,i),n.drawImage(t,0,0),await this.drawAdornments(n,a,o),n.getImageData(0,0,r,i)}async drawAdornments(e,t,n){let r=t.querySelectorAll(`.adornment-svg`),i=await Promise.all(Array.from(r).map(async e=>{let t=e.outerHTML,r=e.getBoundingClientRect(),i=r.left-n.left,a=r.top-n.top,o=r.width,s=r.height,{fontMap:c,vapiUrl:l,accessToken:u}=this.svgCache;return{image:await Jr(t,o,s,c,l,u),x:i,y:a}}));for(let t of i)e.drawImage(t.image,t.x,t.y)}playFrame(){if(this.playbackContext!==void 0){let e=this.playbackContext.startPlayhead+(Date.now()-this.playbackContext.startTime);this.prepareForPlayback(),e>this.duration?(this.setFrame(this.duration),this.playbackContext=void 0,this.restoreAfterPlayback.flush(),this.mcMap.fire(`playend`,{time:this.playhead})):(this.setFrame(e),requestAnimationFrame(()=>this.playFrame()))}}setFrame(e){this.playhead=e;let t=this.cameraCurve.sample(e);this.setCamera(t),this.applyAnimations(e),this.mcMap.fire(`play`,{time:e})}setCamera(e){let t=this.mcMap.map,n=t.getCenter(),r=t.getZoom(),i=t.getBearing(),a=t.getPitch(),o=t.getCenterElevation(),s=t.getVerticalFieldOfView();e.center.lat!==n.lat||e.center.lng!==n.lng||e.zoom!==r||e.bearing!==i||e.pitch!==a||e.elevation!==o||e.fov!==s?(t.setVerticalFieldOfView(e.fov),t.jumpTo(e)):t.triggerRepaint()}applyAnimations(e){let t=this.mcMap.map,{svgs:n,svgCache:r,registryAnimations:i}=this;for(let n of i){let{target:r}=n;if(!id(n))continue;let{modelType:i,groupId:a,modelId:o}=r,s=od(n,`fade`,e);if(i===`area`){let e=this.registry.models.area[a]??{},n=o===void 0?Object.values(e):e[o]?[e[o]]:[];for(let e of n)t.setFeatureState({source:Sr(e),sourceLayer:e.sourceLayerId,id:e.featureId},{[`opacity-${a}`]:s})}else if(i===`polygon`||i===`circle`||i===`line`||i===`marker`||i===`dot`){let e=this.registry.models[i][a]??{},n=o===void 0?Object.keys(e):[o];for(let e of n)t.setFeatureState({source:a,id:D(e)},{opacity:s})}}for(let i of Object.values(this.registry.groups.circle)){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(`circle`,i.id,`scale`),s=a===void 0?1:od(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(i.id).setData({type:`FeatureCollection`,features:i.models.filter(e=>e.visible??!0).map(t=>{let a=o.get(t.id);return Gl(i,t,a===void 0?s:od(a,`grow`,e),n,r)})})}for(let n of Object.values(this.registry.groups.line)){let{groupAnimation:i,modelAnimations:a}=this.getGroupAnimations(`line`,n.id,`scale`),o=i===void 0?1:od(i,`grow`,e);(i!==void 0||a.size>0)&&t.getSource(n.id).setData({type:`FeatureCollection`,features:n.models.filter(e=>e.visible??!0).map(i=>{let s=a.get(i.id);return yu(t,n,i,s===void 0?o:od(s,`grow`,e),r)})})}for(let i of Object.values(this.registry.groups.marker)){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(`marker`,i.id,`scale`),s=a===void 0?1:od(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(i.id).setData({type:`FeatureCollection`,features:i.models.filter(e=>e.visible??!0).map(a=>{let c=o.get(a.id);return Yl(t,i,a,c===void 0?s:od(c,`grow`,e),n,r)})})}let a=this.cameraCurve.sampleAutoHideOpacity(e);for(let t of this.mapstyle.layers){let n=this.getLayerOpacity(t,e,void 0);n===void 0?t.type===`symbol`&&this.setLayerOpacity(t,a):this.setLayerOpacity(t,n)}for(let[t,n]of this.overlays)for(let r of n.layers){let n=this.getLayerOpacity(r,e,t);n===void 0?this.resetLayerOpacity(r):this.setLayerOpacity(r,n)}}prepareForPlayback(){let e=this.mcMap.map;e.setCenterClampedToGround(!1),e.setRasterAlignment(!1),e.style?.stylesheet&&(e.style.stylesheet.transition={duration:0,delay:0}),e.setSourceTileLodParams(1,4),this.restoreAfterPlayback()}restoreAfterPlayback=td(()=>{let e=this.mcMap.map;e.setCenterClampedToGround(!0),e.setRasterAlignment(!0),e.style?.stylesheet&&(e.style.stylesheet.transition=void 0),e.setSourceTileLodParams(m,3)},300);getGroupAnimations(e,t,n){let r,i=new Map;for(let a of this.registryAnimations){let{target:o}=a;o.modelType===e&&o.groupId===t&&(n===`opacity`&&id(a)||n===`scale`&&ad(a))&&(o.modelId===void 0?r=a:i.set(o.modelId,a))}return{groupAnimation:r,modelAnimations:i}}getLayerOpacity(e,t,n){let r,i,a=1/0;n!==void 0&&(r=this.layerAnimations.find(e=>e.target.type===`overlay`&&e.target.id===n));for(let t of this.layerAnimations){let{target:n}=t;n.type===`layer`&&n.ids.includes(e.id)&&n.ids.length<a&&(i=t,a=n.ids.length)}let o=this.layerInfo[e.id]?.opacity??h[e.type].defaultValue;return i===void 0?r===void 0?void 0:od(r,`fade`,t)*o:od(i,`fade`,t)*o}setLayerOpacity(e,t){let n=this.mcMap.map,r=h[e.type];for(let i of r.props)n.setPaintProperty(e.id,i,t)}resetLayerOpacity(e){let t=this.mcMap.map,n=h[e.type],r=this.layerInfo[e.id]?.opacity;for(let i of n.props)t.setPaintProperty(e.id,i,r??e.paint?.[i]??n.defaultValue)}},ud=class extends u.Evented{map;video;constructor(e,t,n,r,i,a,o,s){super(),this.map=e,this.video=new ld(this,t,n,r,i,a,o,s)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}fire(e,t){return super.fire(e,t)}play(){this.video.play()}pause(){this.video.pause()}seekTo(e){this.video.seekTo(e)}frames(){return this.video.frames()}preload(){return this.video.preload()}};async function dd(e){let{accessToken:t,mode:n=`sdk`,env:r=`production`}=e,i=r===`bleeding`?`https://vapi.bleeding.mc-cdn.io`:r===`beta`?`https://vapi.beta.mc-cdn.io`:`https://vapi.mc-cdn.io`,a=r===`bleeding`?`https://cdn.bleeding.mapcreator.io`:r===`beta`?`https://cdn.beta.mapcreator.io`:`https://cdn.mapcreator.io`,o=typeof e.job==`string`?await fd(e.job,a,t):e.job;await pd();let s={container:e.container,attributionControl:!1,style:null,maxBounds:[-1/0,-90,1/0,90],maxPitch:85,maxZoom:22,locale:{"CooperativeGesturesHandler.WindowsHelpText":ua(`windowsHelpText`),"CooperativeGesturesHandler.MacHelpText":ua(`macHelpText`),"CooperativeGesturesHandler.MobileHelpText":ua(`mobileHelpText`)},canvasContextAttributes:{preserveDrawingBuffer:n===`video`}};n===`video`&&(s.maxTileCacheSize=1/0,s.maxTileCacheZoomLevels=1/0,s.refreshExpiredTiles=!1);let c=new u.Map(s),l=c.getContainer();l.classList.add(`mc-map`),l.classList.add(`mc-mode-${n}`);let d=new hu(c,n),{map:{language:p,pitch:m=0,rotation:h=0,center:g,hideBasemap:_,detailLevel:y=0,projection:x=`mercator`,terrain:C=!1,terrainExaggeration:w=1},registry:T={},web:E,positionOffsets:D,title:O}=o,{models:k={},slots:A={},svgs:j={}}=T,M=new si(c,await Br(r,i,t),i,t);c.resize(),n===`app`&&(document.title=O?`${O} - Mapcreator`:`Mapcreator`),c.setPitch(m),c.setBearing(h);let N=ie(o,l),ee,P;if(n===`video`?(P=o.map.zoom-y,ee=N):(P=o.map.zoom-y+Math.log2(N),ee=1),c.setScale(ee),c.setZoom(P),c.setCenter(g),c.setDetailLevel(y),c.setMinZoom(y),c.addControl(new u.AttributionControl({compact:!1})),n===`app`&&oe()&&c.cooperativeGestures.enable(),await Il(o,D??f,c,M,{center:g,zoom:P,pitch:m,rotation:h},i,a,t,ee,n),d.setJobObject(o),E){let{restrictMapMovement:e,popupPosition:t}=E;e&&(c.boxZoom.disable(),c.doubleClickZoom.disable(),c.dragPan.disable(),c.dragRotate.disable(),c.keyboard.disable(),c.scrollZoom.disable(),c.touchPitch.disable(),c.touchZoomRotate.disable()),d.setParams(t,S(p,b.TWO),e,g)}let te=await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then(e=>e.json());Vl(te),c.setStyle(null),c.setStyle(te),await c.once(`style.load`),n===`app`&&_d(c.getStyle().metadata?.customCssFilePath,t),v(p,c);let F=await Xl(o.map.overlays??[],o.meta.layers??[],c,i,t,te.metadata?.styleOverride),ne=(o.map.overlays??[]).reduce((e,t,n)=>e.set(t,F[n]),new Map);bd(c,M,k,A,j,i,t),v(p,c),d.setPublication(te.metadata?.publication),d.setpopupElements(),d.setHighlightManager(),c.setProjection({type:x===`globe`?`globe`:`mercator`});let re=md(c,x);hd(c,re),C&&gd(c,i,t,w);let ae=vd(o.map.layerInfo,te,F);return yd(c,ae,!_),new ud(c,o,j,M,te,ne,ae,re)}function fd(e,t,n){return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then(e=>e.json())}function pd(){return new Promise(e=>{let t=()=>{window.innerWidth>0&&window.innerHeight>0&&(window.removeEventListener(`resize`,t),e())};window.addEventListener(`resize`,t),t()})}function md(e,t){let n=e.getStyle().metadata??{},r=n[`mc:background-color`]??`#f8f8f8`,i=n[`mc:background-color-globe`]??`#000000`;return t===`globe`?i:r}function hd(e,t){e.getContainer().style.backgroundColor=t,e.setSky(e.getStyle().sky??d),e.setLight({position:[1.15,210,45]})}function gd(e,t,n,r){e.addSource(`mc-dem`,{type:`raster-dem`,tiles:[`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],attribution:`<a href="https://earth.jaxa.jp/en/data/policy" target="_blank">© AW3D30 (JAXA)</a>`,minzoom:0,maxzoom:12}),e.setTerrain({source:`mc-dem`,exaggeration:r})}function _d(e,t){if(document.getElementById(`custom-style`)?.remove(),!e)return;let n;e.startsWith(`http`)?(e=`${e}?access_token=${t}`,n=document.createElement(`link`),n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e.replace(/https?:/,``))):(n=document.createElement(`style`),n.appendChild(document.createTextNode(e))),n.setAttribute(`id`,`custom-style`),n.setAttribute(`type`,`text/css`),document.head.appendChild(n)}function vd(e,t,n){let r=e?.reduce((e,t)=>(e[t.id]={visibility:t.visibility,...t.opacity!==void 0&&{opacity:t.opacity}},e),{})??{},i={};for(let e of t.layers)i[e.id]=r[e.id]??{visibility:(e.layout?.visibility??`visible`)===`visible`};for(let e of n)for(let t of e.layers)i[t.id]=r[t.id]??{visibility:!1};return i}function yd(e,t,n){for(let r in t){let i=e.getLayer(r);if(i!==void 0){let a=t[r];if(e.setLayoutProperty(r,`visibility`,a.visibility&&n?`visible`:`none`),a.opacity!==void 0){let t=h[i.type];for(let n of t.props)e.setPaintProperty(r,n,a.opacity)}}}}function bd(e,t,n,r,i,a,o){let{beforeNone:s=[],beforeNames:c=[],beforeBoundaries:l=[],beforeWaters:u=[]}=r;s.forEach(r=>{xd(e,t,n,r,i,`mc-before-none`,a,o)}),c.forEach(r=>{xd(e,t,n,r,i,`mc-before-names`,a,o)}),l.forEach(r=>{xd(e,t,n,r,i,`mc-before-boundaries`,a,o)}),u.forEach(r=>{xd(e,t,n,r,i,`mc-before-waters`,a,o)})}function xd(e,t,n,r,i,a,o,s){if(r.type===`marker`){let o=n.marker?.find(e=>e.id===r.groupId);o&&ql(e,o,a,i,t)}else if(r.type===`polygon`){let o=n.polygon?.find(e=>e.id===r.groupId);o&&Hl(e,o,a,i,t)}else if(r.type===`circle`){let o=n.circle?.find(e=>e.id===r.groupId);o&&Wl(e,o,a,i,t)}else if(r.type===`line`){let i=n.line?.find(e=>e.id===r.groupId);i&&vu(e,i,a,t)}else if(r.type===`dot`){let t=n.dot?.find(e=>e.id===r.groupId);t&&Su(e,t,a)}else if(r.type===`area`){let c=n.area?.find(e=>e.id===r.groupId);c&&xu(e,c,a,i,t,o,s)}}e.initMap=dd,e.setRTLTextPlugin=u.setRTLTextPlugin});
1186
+ `}return n}htmlToElement(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content.firstElementChild}addPopupControls(){let e=this.htmlToElement(su);if(e&&(e.addEventListener(`click`,()=>{this.hidePopup(),this.highlightManager.highlight(void 0)}),this.popupContainer.appendChild(e)),this.popupElements.length>1){let e=this.htmlToElement(cu);e&&(e.querySelector(`.prev`)?.addEventListener(`click`,()=>this.cyclePopups(!1)),e.querySelector(`.next`)?.addEventListener(`click`,()=>this.cyclePopups()),this.popupContainer.appendChild(e))}}fillDatalayerTemplate(e,t,n){let r=`data-mention-id`,i=new DOMParser().parseFromString(t,`text/html`).body;for(let t of i.querySelectorAll(`[${r}]`)){let i=this.getProperty(e,t.getAttribute(r),n);i!==void 0&&(t.innerText=i)}return i.innerHTML}getProperty(e,t,n){if(!t)return;let r=t.endsWith(`:en`)?[t.replace(`:en`,n),t]:[t];for(let t of r){let n=e.properties[t]??this.getVectorProperty(e,t);if(n!==void 0)return n}}getVectorProperty(e,t){let n=this.promoteIdCache.get(e.source);n===void 0&&(n=this.map.getSource(e.source)?.serialize().promoteId||`id`,this.promoteIdCache.set(e.source,n));try{let r=e.properties[n];return e.layer.metadata.properties[t][r]}catch{return}}cyclePopups(e=!0){let t=this.popupElements?.findIndex(e=>e.modelId===this.currentModelId);if(t!==-1){let n=0;n=e?t===this.popupElements.length-1?0:t+1:t===0?this.popupElements.length-1:t-1;let r=this.popupElements?.[n];this.currentModelId=r.modelId,this.highlightManager.highlight(r,!0);let i=ou(r.popup,r.popupMedia,r.dataBindings??{},this.mode),a=this.popupContainer;this.popupContainer.remove(),a.innerHTML=i,this.mapContainer.appendChild(a),this.addPopupControls(),e?this.popupContainer.querySelector(`.mc-popup-button.next`)?.focus():this.popupContainer.querySelector(`.mc-popup-button.prev`)?.focus()}}},gu=class e{static#e(e){let t=0,n=[t];for(let r=1;r<e.length;++r){let i=e[r-1],a=e[r],o=a.x-i.x,s=a.y-i.y;t+=Math.sqrt(o*o+s*s),n.push(t)}return n}static#t(e,t){return e.x===t.x&&e.y===t.y}#n;#r;#i;#a;constructor(t){this.#n=t.filter((e,n)=>n===0||t[n][0]!==t[n-1][0]||t[n][1]!==t[n-1][1]),this.#r=this.#n.map(e=>u.MercatorCoordinate.fromLngLat(e)),this.#i=e.#e(this.#r),this.#a=this.#i[this.#i.length-1]}sample(e){let t=this.#r,n=this.#i;if(t.length<2)return t[0];e*=this.#a;for(let r=1;r<t.length;++r){let i=t[r-1],a=t[r],o=n[r-1],s=n[r];if(s>=e){let t=(e-o)/(s-o);return new u.MercatorCoordinate(ee(i.x,a.x,t),ee(i.y,a.y,t))}}return new u.MercatorCoordinate(t[t.length-1].x,t[t.length-1].y)}slice(t,n){if(this.#n.length<2)return this.#n;let r=this.#r.filter((e,r)=>this.#i[r]>=t*this.#a&&this.#i[r]<=n*this.#a);if(t>0){let n=this.sample(t);e.#t(n,r[0])||r.unshift(n)}if(n<1){let t=this.sample(n);e.#t(t,r[r.length-1])||r.push(t)}return r.map(e=>{let{lng:t,lat:n}=e.toLngLat();return[t,n]})}get length(){return this.#a}},_u={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function vu(e,t,n,r){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(n=>yu(e,t,n,1,r))}}),Object.entries(_u).forEach(([r,i])=>{t.models.some(e=>(e.lineStyle??`solid`)===r)&&e.addLayer({id:`${t.id}-${r}`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`==`,[`get`,`line-style`],r]],paint:{"line-width":[`get`,`line-width`],"line-color":[`get`,`line-color`],"line-dasharray":i,"line-opacity":[`coalesce`,[`feature-state`,`opacity`],1]}},n)}),e.addLayer({id:`${t.id}-clickable`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},paint:{"line-width":[`max`,[`get`,`line-width`],15],"line-opacity":0},filter:[`==`,[`geometry-type`],`LineString`]},n),t.models.some(e=>e.svg)&&e.addLayer({id:`${t.id}-icon`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-image":[`get`,`mc-image-key`],"icon-anchor":`center`,"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],1]},filter:[`==`,[`geometry-type`],`Point`]},n)}function yu(e,t,n,r,i){let a=new gu(n.geometry).slice(0,r),o=n.svg===void 0?void 0:i.getMapLibreImageKey(mi(n.dataBindings??{},n.svg,void 0),window.devicePixelRatio*(n.iconScale??1)*e.getScale());return{type:`Feature`,id:D(n.id),properties:{id:n.id,"line-width":n.lineWidth??3,"line-color":t.lineColor||n.lineColor?fi(n.dataBindings??{},n.lineColor,t.lineColor):`#000000`,"line-style":n.lineStyle??`solid`,"mc-image-key":o,"icon-rotate":bu(n,a,e),"icon-offset":n.iconOffset,"icon-size":n.iconScale},geometry:{type:`GeometryCollection`,geometries:[{type:`LineString`,coordinates:a},{type:`Point`,coordinates:a[a.length-1]}]}}}function bu(e,t,n){return e.iconRotation?e.iconAlign?wr(t,n)+e.iconRotation:e.iconRotation:0}function xu(e,t,n,r,i,a,o){let s=jr(t),c=new Map,l=new Map;for(let e of t.models){let n=e.featureId,a=t.id,o=[],u=Sr(e),d=xr(a,e),f=l.get(d)??{model:e,featureIds:o,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{},modelIdToOutlineWidth:{}};if(e.visible??!0){f.featureIds.push(n);let a=e.fillPattern===void 0?null:i.getMapLibreImageKey(r[e.fillPattern],2*window.devicePixelRatio);f.modelIdToFillColor[n]=t.fillColor||e.fillColor?fi(e.dataBindings??{},e.fillColor,t.fillColor,s,t.choropleth?.unmatchedColor):`#000000`,f.modelIdToFillPattern[n]=a,f.modelIdToOutlineColor[n]=t.outlineColor||e.outlineColor?fi(e.dataBindings??{},e.outlineColor,t.outlineColor):`#000000`,f.modelIdToOutlineWidth[n]=e.outlineWidth??.5}c.set(u,e),l.set(d,f)}for(let t of c.keys())e.getSource(t)||e.addSource(t,{type:`vector`,url:`${a}${c.get(t).vectorUrl}?access_token=${o}`,promoteId:`id`});for(let r of l.keys()){let{model:i}=l.get(r),{sourceLayerId:a}=i,o=Sr(i);e.addLayer({id:r,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-color":`#ffffff`,"fill-outline-color":`#000000`,"fill-antialias":!1,"fill-opacity":[`coalesce`,[`feature-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${r}-pattern`,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity-${t.id}`],1]},layout:{visibility:`visible`}},n),e.addLayer({id:`${r}-outline`,type:`line`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"line-color":`#000000`,"line-width":.5,"line-opacity":[`coalesce`,[`feature-state`,`opacity-${t.id}`],1]}},n)}l.forEach((t,n)=>{let{featureIds:r,modelIdToFillColor:i,modelIdToFillPattern:a,modelIdToOutlineColor:o,modelIdToOutlineWidth:s}=t;e.setFilter(n,[`in`,`id`,...r]),e.setFilter(`${n}-outline`,[`in`,`id`,...r]),e.setPaintProperty(n,`fill-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,i]]),e.setPaintProperty(`${n}-outline`,`line-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,o]]),e.setPaintProperty(`${n}-outline`,`line-width`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,s]]),e.setFilter(`${n}-pattern`,[`to-boolean`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]]]),e.setPaintProperty(`${n}-pattern`,`fill-pattern`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]])})}function Su(e,t,n){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>Cu(t,e))}}),e.addLayer({id:t.id,type:`circle`,source:t.id,metadata:{"mc-model-type":`dot`,"mc-group-id":t.id},paint:{"circle-color":[`get`,`circle-color`],"circle-radius":[`get`,`circle-radius`],"circle-opacity":[`coalesce`,[`feature-state`,`opacity`],1]}},n)}function Cu(e,t){return{type:`Feature`,id:t.id,properties:{id:t.id,"circle-radius":t.radius,"circle-color":e.fillColor||t.fillColor?fi(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`},geometry:{type:`Point`,coordinates:[t.center.lng,t.center.lat]}}}function wu(e){let t=e.length>0?[Tu(e[0])]:[],n=0,r=0;for(let i=1;i<e.length;++i){let a=Tu(e[i]);n+=Eu(e[i-1].center[0],a.center[0]),r+=Eu(e[i-1].bearing,a.bearing),a.center[0]+=n*360,a.x+=n,a.bearing+=r*360,t.push(a)}return t}function Tu(e){return{...e,center:[e.center[0],e.center[1]]}}function Eu(e,t){if(Math.abs(e)+Math.abs(t)>180){if(e>0&&t<0)return 1;if(e<0&&t>0)return-1}return 0}function Du(e){return 2**-e}function Ou(e){return e.length>0?e[e.length-1].time:0}function ku(e){return ae(e,23.976)?24e3/1001:ae(e,29.97)?3e4/1001:ae(e,59.94)?6e4/1001:e}function Au(e,t){return e===void 0||t===void 0?e===t:e.center.lat===t.center.lat&&e.center.lng===t.center.lng&&e.zoom===t.zoom&&e.bearing===t.bearing&&e.pitch===t.pitch&&e.fov===t.fov&&e.elevation===t.elevation}function ju(e){return e<0?-1:1}function Mu(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(ju(a)+ju(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function Nu(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Pu(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function Fu(e){this._context=e}Fu.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Pu(this,this._t0,Nu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Pu(this,Nu(this,n=Mu(this,e,t)),n);break;default:Pu(this,this._t0,n=Mu(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function Iu(e){this._context=new Lu(e)}(Iu.prototype=Object.create(Fu.prototype)).point=function(e,t){Fu.prototype.point.call(this,t,e)};function Lu(e){this._context=e}Lu.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function Ru(e){return new Fu(e)}var zu=s(((e,t)=>{var n=4,r=.001,i=1e-7,a=10,o=11,s=1/(o-1),c=typeof Float32Array==`function`;function l(e,t){return 1-3*t+3*e}function u(e,t){return 3*t-6*e}function d(e){return 3*e}function f(e,t,n){return((l(t,n)*e+u(t,n))*e+d(t))*e}function p(e,t,n){return 3*l(t,n)*e*e+2*u(t,n)*e+d(t)}function m(e,t,n,r,o){var s,c,l=0;do c=t+(n-t)/2,s=f(c,r,o)-e,s>0?n=c:t=c;while(Math.abs(s)>i&&++l<a);return c}function h(e,t,r,i){for(var a=0;a<n;++a){var o=p(t,r,i);if(o===0)return t;var s=f(t,r,i)-e;t-=s/o}return t}function g(e){return e}t.exports=function(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw Error(`bezier x values must be in [0, 1] range`);if(e===t&&n===i)return g;for(var a=c?new Float32Array(o):Array(o),l=0;l<o;++l)a[l]=f(l*s,e,n);function u(t){for(var i=0,c=1,l=o-1;c!==l&&a[c]<=t;++c)i+=s;--c;var u=(t-a[c])/(a[c+1]-a[c]),d=i+u*s,f=p(d,e,n);return f>=r?h(t,d,e,n):f===0?d:m(t,i,i+s,e,n)}return function(e){return e===0?0:e===1?1:f(u(e),t,i)}}})),Bu=s(((e,t)=>{t.exports=n;function n(e,t,n,r){var i,a,o,s,c,l,u,d,f,p,m,h,g,_;for(typeof t!=`function`&&(r=n,n=t,t=null),r||={},s=r.tolerance===void 0?1e-7:r.tolerance,_=r.epsilon===void 0?2220446049250313e-31:r.epsilon,c=r.maxIterations===void 0?20:r.maxIterations,m=r.h===void 0?1e-4:r.h,g=r.verbose===void 0?!1:r.verbose,h=1/m,l=0;l++<c;){if(a=e(n),t?o=t(n):(u=e(n+m),d=e(n-m),f=e(n+2*m),p=e(n-2*m),o=(p-f+8*(u-d))*h/12),Math.abs(o)<=_*Math.abs(a))return g&&console.log(`Newton-Raphson: failed to converged due to nearly zero first derivative`),!1;if(i=n-a/o,Math.abs(i-n)<=s*Math.abs(i))return g&&console.log(`Newton-Raphson: converged to x = `+i+` after `+l+` iterations`),i;n=i}return g&&console.log(`Newton-Raphson: Maximum iterations reached (`+c+`)`),!1}})),Vu=l(zu(),1),Hu=l(Bu(),1),Uu=class{segments;constructor(e){this.segments=[];let t=new Wu,n=Ru(t);n.lineStart();for(let t of e)n.point(t.x,t.y);n.lineEnd(),this.segments=t.segments}sample(e){if(e<=0)return this.segments[0].startY;if(e>=this.segments[this.segments.length-1].endX)return this.segments[this.segments.length-1].endY;let t=this.segments.find(t=>e>=t.startX&&e<t.endX),n=P(t.startX,t.endX,e);return t.startY!==t.endY&&t.easing!==void 0?ee(t.startY,t.endY,t.easing(n)):ee(t.startY,t.endY,n)}solve(e,t){let n=(0,Hu.default)(t=>this.sample(t)-e,t);return n===!1?t:n}},Wu=class{previousPoint={x:0,y:0};segments=[];bezierCurveTo(e,t,n,r,i,a){let o=this.previousPoint.x,s=this.previousPoint.y,c=i===o?void 0:(0,Vu.default)((e-o)/(i-o),(t-s)/(a-s),(n-o)/(i-o),(r-s)/(a-s));this.segments.push({startX:o,endX:i,startY:s,endY:a,easing:c}),this.previousPoint={x:i,y:a}}lineTo(e,t){this.segments.push({startX:this.previousPoint.x,endX:e,startY:this.previousPoint.y,endY:t,easing:void 0}),this.previousPoint={x:e,y:t}}moveTo(e,t){this.previousPoint={x:e,y:t}}closePath(){}arc(){}rect(){}arcTo(){}quadraticCurveTo(){}};function Gu(e,t,n,r){return t+n/r*e}function Ku(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function qu(e,t,n,r){let i=1.70158,a=0,o=n;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,o<Math.abs(n)?(o=n,i=a/4):i=a/(2*Math.PI)*Math.asin(n/o),o*2**(-10*e)*Math.sin((e*r-i)*(2*Math.PI)/a)+n+t)}function Ju(e,t,n,r,i){return i===void 0&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function Yu(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}var Xu=class{script;xCurve;yCurve;fovCurve;zoomCurve;pitchCurve;bearingCurve;altitudeCurve;elevationCurve;constructor(e){this.script=wu(e),this.xCurve=this.createMonotonicCurve(this.script,`x`),this.yCurve=this.createMonotonicCurve(this.script,`y`),this.fovCurve=this.createMonotonicCurve(this.script,`fov`),this.zoomCurve=this.createMonotonicCurve(this.script,`zoom`),this.pitchCurve=this.createMonotonicCurve(this.script,`pitch`),this.bearingCurve=this.createMonotonicCurve(this.script,`bearing`),this.altitudeCurve=this.createMonotonicCurve(this.script,`altitude`),this.elevationCurve=this.createMonotonicCurve(this.script,`elevation`)}sample(e){let t=this.zoomCurve.sample(e),n=this.altitudeCurve.solve(Du(t),e),r=this.xCurve.sample(n),i=this.yCurve.sample(n),a=this.elevationCurve.sample(n),o=this.bearingCurve.sample(e),s=this.pitchCurve.sample(e),c=this.fovCurve.sample(e);return{center:new u.MercatorCoordinate(r,i).toLngLat(),zoom:t,bearing:o,pitch:s,fov:c,elevation:a}}createMonotonicCurve(e,t){let n=[];for(let r=0;r<e.length;r++){let i=r===0,a=r===e.length-1,o=e[r],s=e[r+1],c=e[r-1],l=this.getKeyframeValue(o,t);if(i&&n.push({x:-1,y:l}),n.push({x:o.time,y:l}),!i&&!a&&c.transition===`instant`&&o.transition===`ease`&&n.push({x:o.time+.1,y:l}),!a)if(o.transition===`linear`){let e=o.time+.1,r=s.time-.1,i=P(o.time,s.time,e),a=P(o.time,s.time,r),c=this.getKeyframeValue(s,t);n.push({x:e,y:ee(l,c,i)}),n.push({x:r,y:ee(l,c,a)})}else o.transition===`instant`&&(n.push({x:o.time+.1,y:l}),n.push({x:s.time-.1,y:l}));a&&n.push({x:o.time+1,y:l})}return new Uu(n)}sampleAutoHideOpacity(e){let t=this.script;if(t.length<2)return 1;let n=this.getKeyframeIndexByTime(e);if(n===-1||n===t.length-1)return 1;let r=t[n],i=t[n+1],a=n>0?t[n-1]:void 0,o;if(r.hideLabels===(a?.hideLabels??!1))o=r.hideLabels?0:1;else{let t=e-r.time,n=Math.min(400,i.time-r.time);o=te(Ku(t,r.hideLabels?1:0,r.hideLabels?-1:1,n),0,1)}let s;if(n===t.length-2&&r.hideLabels){let t=Math.max(r.time,i.time-400);s=te(Ku(e-t,0,1,i.time-t),0,1)}else s=0;return Math.max(o,s)}getKeyframeIndexByTime(e){let t=this.script;if(t.length!==0){for(let n=0;n<t.length;n++)if(e<t[n].time)return n-1;return t.length-1}}getKeyframeValue(e,t){return t===`altitude`?Du(e.zoom):e[t]}},Zu=Qu;function Qu(e,t,n){var r=null,i=null,a=function(){r&&=(clearTimeout(r),i=null,null)},o=function(){var e=i;a(),e&&e()},s=function(){if(!t)return e.apply(this,arguments);var o=this,s=arguments,c=n&&!r;if(a(),i=function(){e.apply(o,s)},r=setTimeout(function(){if(r=null,!c){var e=i;return i=null,e()}},t),c)return i()};return s.cancel=a,s.flush=o,s}var $u={linear:Gu,easeOutCubic:Ku,easeOutBack:Ju,easeOutBounce:Yu,easeOutElastic:qu};function ed(e){return e.entryType===`fade`||e.exitType===`fade`||e.entryType===`instant`||e.exitType===`instant`}function td(e){return e.entryType===`grow`||e.exitType===`grow`}function nd(e,t,n){let{entry:r,entryDuration:i,exit:a,exitDuration:o}=e,{entryType:s,entryEasing:c,exitType:l,exitEasing:u}=e;return n<r&&(s===t||s===`instant`&&t===`fade`)||n>a&&(l===t||l===`instant`&&t===`fade`)?0:i>0&&n<r+i&&s===t?$u[c](n-r,0,1,i):o>0&&n>a-o&&l===t?$u[u](n-(a-o),1,-1,o):1}function rd(e){return e.target.type===`model`}function id(e){return e.target.type===`layer`||e.target.type===`overlay`}var ad=class{mcMap;cameraCurve;registryAnimations;layerAnimations;registry;svgs;svgCache;duration;frameRate;mapstyle;overlays;layerInfo;backgroundColor;playhead;playbackContext;constructor(e,t,n,r,i,a,o,s){this.mcMap=e,this.playhead=0,this.playbackContext=void 0;let c=(t.video?.keyframes??[]).map(e=>{let{x:t,y:n}=u.MercatorCoordinate.fromLngLat(e.center);return{...e,x:t,y:n,fov:e.fov??36.87,elevation:e.elevation??0}}),l=t.video?.animations??[];this.layerAnimations=l.filter(id);let d=l.filter(rd);this.registryAnimations=[...d.filter(e=>e.target.modelId===void 0),...d.filter(e=>e.target.modelId!==void 0)],this.duration=Ou(c),this.frameRate=ku(t.export?.frameRate??60),this.cameraCurve=new Xu(c),this.registry=new pu(t),this.svgs=n,this.svgCache=r,this.mapstyle=i,this.overlays=a,this.layerInfo=o,this.backgroundColor=s}play(){this.playbackContext===void 0&&this.duration>0&&(this.playhead>=this.duration&&(this.playhead=0),this.playbackContext={startTime:Date.now(),startPlayhead:this.playhead},this.mcMap.fire(`playstart`,{time:this.playhead}),this.playFrame())}pause(){this.playbackContext!==void 0&&(this.playbackContext=void 0,this.restoreAfterPlayback.flush(),this.mcMap.fire(`playend`,{time:this.playhead}))}seekTo(e){this.duration>0&&(e=te(e,0,this.duration),this.prepareForPlayback(),this.setFrame(e),this.playbackContext!==void 0&&(this.playbackContext={startTime:Date.now(),startPlayhead:e}))}async*frames(){let e=this.mcMap.map,t=Math.ceil(this.duration*this.frameRate/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setRasterAlignment(!1),e.setCenterClampedToGround(!1),e.setSourceTileLodParams(1,4);let n=e.getCanvas(),{width:r,height:i}=n,a=new OffscreenCanvas(r,i).getContext(`2d`,{desynchronized:!0,willReadFrequently:!0}),o=e.getContainer(),s=o.getBoundingClientRect();for(let e=0;e<t;e++)yield this.captureFrame(e*1e3/this.frameRate,n,a,r,i,o,s);e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setRasterAlignment(!0),e.setCenterClampedToGround(!0),e.setSourceTileLodParams(m,3),this.playhead=0}async preload(){this.playbackContext!==void 0&&this.pause();let e=this.mcMap.map,t=Math.ceil(this.duration*this.frameRate/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setCenterClampedToGround(!1),e.setSourceTileLodParams(1,4),e.setRasterAlignment(!1);try{let n;for(let r=0;r<t;r++){let t=this.cameraCurve.sample(r*1e3/this.frameRate);Au(n,t)||(this.setCamera(t),await this.waitForRenderOrAbort()===`render`?n=t:(n!==void 0&&this.setCamera(n),e.triggerRepaint(),await e.once(`idle`),r--))}e.areTilesLoaded()||await e.once(`idle`)}finally{e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setCenterClampedToGround(!0),e.setSourceTileLodParams(m,3),e.setRasterAlignment(!0)}}waitForRenderOrAbort(){let e=this.mcMap.map;return new Promise(t=>{let n=()=>{e.off(`render`,r),e.off(`dataabort`,i)},r=()=>{n(),t(`render`)},i=e=>{e.tile?.state===`loading`&&(n(),t(`abort`))};e.on(`render`,r),e.on(`dataabort`,i)})}async captureFrame(e,t,n,r,i,a,o){return this.setFrame(e),await this.mcMap.map.once(`idle`),n.fillStyle=this.backgroundColor,n.fillRect(0,0,r,i),n.drawImage(t,0,0),await this.drawAdornments(n,a,o),n.getImageData(0,0,r,i)}async drawAdornments(e,t,n){let r=t.querySelectorAll(`.adornment-svg`),i=await Promise.all(Array.from(r).map(async e=>{let t=e.outerHTML,r=e.getBoundingClientRect(),i=r.left-n.left,a=r.top-n.top,o=r.width,s=r.height,{fontMap:c,vapiUrl:l,accessToken:u}=this.svgCache;return{image:await Jr(t,o,s,c,l,u),x:i,y:a}}));for(let t of i)e.drawImage(t.image,t.x,t.y)}playFrame(){if(this.playbackContext!==void 0){let e=this.playbackContext.startPlayhead+(Date.now()-this.playbackContext.startTime);this.prepareForPlayback(),e>this.duration?(this.setFrame(this.duration),this.playbackContext=void 0,this.restoreAfterPlayback.flush(),this.mcMap.fire(`playend`,{time:this.playhead})):(this.setFrame(e),requestAnimationFrame(()=>this.playFrame()))}}setFrame(e){this.playhead=e;let t=this.cameraCurve.sample(e);this.setCamera(t),this.applyAnimations(e),this.mcMap.fire(`play`,{time:e})}setCamera(e){let t=this.mcMap.map,n=t.getCenter(),r=t.getZoom(),i=t.getBearing(),a=t.getPitch(),o=t.getCenterElevation(),s=t.getVerticalFieldOfView();e.center.lat!==n.lat||e.center.lng!==n.lng||e.zoom!==r||e.bearing!==i||e.pitch!==a||e.elevation!==o||e.fov!==s?(t.setVerticalFieldOfView(e.fov),t.jumpTo(e)):t.triggerRepaint()}applyAnimations(e){let t=this.mcMap.map,{svgs:n,svgCache:r,registryAnimations:i}=this;for(let n of i){let{target:r}=n;if(!ed(n))continue;let{modelType:i,groupId:a,modelId:o}=r,s=nd(n,`fade`,e);if(i===`area`){let e=this.registry.models.area[a]??{},n=o===void 0?Object.values(e):e[o]?[e[o]]:[];for(let e of n)t.setFeatureState({source:Sr(e),sourceLayer:e.sourceLayerId,id:e.featureId},{[`opacity-${a}`]:s})}else if(i===`polygon`||i===`circle`||i===`line`||i===`marker`||i===`dot`){let e=this.registry.models[i][a]??{},n=o===void 0?Object.keys(e):[o];for(let e of n)t.setFeatureState({source:a,id:D(e)},{opacity:s})}}for(let i of Object.values(this.registry.groups.circle)){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(`circle`,i.id,`scale`),s=a===void 0?1:nd(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(i.id).setData({type:`FeatureCollection`,features:i.models.filter(e=>e.visible??!0).map(t=>{let a=o.get(t.id);return Gl(i,t,a===void 0?s:nd(a,`grow`,e),n,r)})})}for(let n of Object.values(this.registry.groups.line)){let{groupAnimation:i,modelAnimations:a}=this.getGroupAnimations(`line`,n.id,`scale`),o=i===void 0?1:nd(i,`grow`,e);(i!==void 0||a.size>0)&&t.getSource(n.id).setData({type:`FeatureCollection`,features:n.models.filter(e=>e.visible??!0).map(i=>{let s=a.get(i.id);return yu(t,n,i,s===void 0?o:nd(s,`grow`,e),r)})})}for(let i of Object.values(this.registry.groups.marker)){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(`marker`,i.id,`scale`),s=a===void 0?1:nd(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(i.id).setData({type:`FeatureCollection`,features:i.models.filter(e=>e.visible??!0).map(a=>{let c=o.get(a.id);return Yl(t,i,a,c===void 0?s:nd(c,`grow`,e),n,r)})})}let a=this.cameraCurve.sampleAutoHideOpacity(e);for(let t of this.mapstyle.layers){let n=this.getLayerOpacity(t,e,void 0);n===void 0?t.type===`symbol`&&this.setLayerOpacity(t,a):this.setLayerOpacity(t,n)}for(let[t,n]of this.overlays)for(let r of n.layers){let n=this.getLayerOpacity(r,e,t);n===void 0?this.resetLayerOpacity(r):this.setLayerOpacity(r,n)}}prepareForPlayback(){let e=this.mcMap.map;e.setCenterClampedToGround(!1),e.setRasterAlignment(!1),e.style?.stylesheet&&(e.style.stylesheet.transition={duration:0,delay:0}),e.setSourceTileLodParams(1,4),this.restoreAfterPlayback()}restoreAfterPlayback=Zu(()=>{let e=this.mcMap.map;e.setCenterClampedToGround(!0),e.setRasterAlignment(!0),e.style?.stylesheet&&(e.style.stylesheet.transition=void 0),e.setSourceTileLodParams(m,3)},300);getGroupAnimations(e,t,n){let r,i=new Map;for(let a of this.registryAnimations){let{target:o}=a;o.modelType===e&&o.groupId===t&&(n===`opacity`&&ed(a)||n===`scale`&&td(a))&&(o.modelId===void 0?r=a:i.set(o.modelId,a))}return{groupAnimation:r,modelAnimations:i}}getLayerOpacity(e,t,n){let r,i,a=1/0;n!==void 0&&(r=this.layerAnimations.find(e=>e.target.type===`overlay`&&e.target.id===n));for(let t of this.layerAnimations){let{target:n}=t;n.type===`layer`&&n.ids.includes(e.id)&&n.ids.length<a&&(i=t,a=n.ids.length)}let o=this.layerInfo[e.id]?.opacity??h[e.type].defaultValue;return i===void 0?r===void 0?void 0:nd(r,`fade`,t)*o:nd(i,`fade`,t)*o}setLayerOpacity(e,t){let n=this.mcMap.map,r=h[e.type];for(let i of r.props)n.setPaintProperty(e.id,i,t)}resetLayerOpacity(e){let t=this.mcMap.map,n=h[e.type],r=this.layerInfo[e.id]?.opacity;for(let i of n.props)t.setPaintProperty(e.id,i,r??e.paint?.[i]??n.defaultValue)}},od=class extends u.Evented{map;video;constructor(e,t,n,r,i,a,o,s){super(),this.map=e,this.video=new ad(this,t,n,r,i,a,o,s)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}fire(e,t){return super.fire(e,t)}play(){this.video.play()}pause(){this.video.pause()}seekTo(e){this.video.seekTo(e)}frames(){return this.video.frames()}preload(){return this.video.preload()}};async function sd(e){let{accessToken:t,mode:n=`sdk`,env:r=`production`}=e,i=r===`bleeding`?`https://vapi.bleeding.mc-cdn.io`:r===`beta`?`https://vapi.beta.mc-cdn.io`:`https://vapi.mc-cdn.io`,a=r===`bleeding`?`https://cdn.bleeding.mapcreator.io`:r===`beta`?`https://cdn.beta.mapcreator.io`:`https://cdn.mapcreator.io`,o=typeof e.job==`string`?await cd(e.job,a,t):e.job;await ld();let s={container:e.container,attributionControl:!1,style:null,maxBounds:[-1/0,-90,1/0,90],maxPitch:85,maxZoom:22,locale:{"CooperativeGesturesHandler.WindowsHelpText":ua(`windowsHelpText`),"CooperativeGesturesHandler.MacHelpText":ua(`macHelpText`),"CooperativeGesturesHandler.MobileHelpText":ua(`mobileHelpText`)},canvasContextAttributes:{preserveDrawingBuffer:n===`video`}};n===`video`&&(s.maxTileCacheSize=1/0,s.maxTileCacheZoomLevels=1/0,s.refreshExpiredTiles=!1);let c=new u.Map(s),l=c.getContainer();l.classList.add(`mc-map`),l.classList.add(`mc-mode-${n}`);let d=new hu(c,n),{map:{language:p,pitch:m=0,rotation:h=0,center:g,hideBasemap:_,detailLevel:y=0,projection:x=`mercator`,terrain:C=!1,terrainExaggeration:w=1},registry:T={},web:E,positionOffsets:D,title:O}=o,{models:k={},slots:A={},svgs:j={}}=T,M=new si(c,await Br(r,i,t),i,t);c.resize(),n===`app`&&(document.title=O?`${O} - Mapcreator`:`Mapcreator`),c.setPitch(m),c.setBearing(h);let N=ie(o,l),ee,P;if(n===`video`?(P=o.map.zoom-y,ee=N):(P=o.map.zoom-y+Math.log2(N),ee=1),c.setScale(ee),c.setZoom(P),c.setCenter(g),c.setDetailLevel(y),c.setMinZoom(y),c.addControl(new u.AttributionControl({compact:!1})),n===`app`&&oe()&&c.cooperativeGestures.enable(),await Il(o,D??f,c,M,{center:g,zoom:P,pitch:m,rotation:h},i,a,t,ee,n),d.setJobObject(o),E){let{restrictMapMovement:e,popupPosition:t}=E;e&&(c.boxZoom.disable(),c.doubleClickZoom.disable(),c.dragPan.disable(),c.dragRotate.disable(),c.keyboard.disable(),c.scrollZoom.disable(),c.touchPitch.disable(),c.touchZoomRotate.disable()),d.setParams(t,S(p,b.TWO),e,g)}let te=o.meta?.mapstyleSet,F=te===void 0?{version:8,sources:{},layers:[]}:await fetch(`${i}/styles/${te}.json?access_token=${t}`).then(e=>e.json());Vl(F),c.setStyle(null),c.setStyle(F),await c.once(`style.load`),n===`app`&&pd(c.getStyle().metadata?.customCssFilePath,t),v(p,c);let ne=o.map.overlays??[],re=o.meta?.layers??[];ne.length!==re.length&&(ne=[],re=[]);let ae=await Xl(ne,re,c,i,t,F.metadata?.styleOverride),se=ne.reduce((e,t,n)=>e.set(t,ae[n]),new Map);gd(c,M,k,A,j,i,t),v(p,c),d.setPublication(F.metadata?.publication),d.setpopupElements(),d.setHighlightManager(),c.setProjection({type:x===`globe`?`globe`:`mercator`});let ce=ud(c,x);dd(c,ce),C&&fd(c,i,t,w);let le=md(o.map.layerInfo,F,ae);return hd(c,le,!_),new od(c,o,j,M,F,se,le,ce)}function cd(e,t,n){return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then(e=>e.json())}function ld(){return new Promise(e=>{let t=()=>{window.innerWidth>0&&window.innerHeight>0&&(window.removeEventListener(`resize`,t),e())};window.addEventListener(`resize`,t),t()})}function ud(e,t){let n=e.getStyle().metadata??{},r=n[`mc:background-color`]??`#f8f8f8`,i=n[`mc:background-color-globe`]??`#000000`;return t===`globe`?i:r}function dd(e,t){e.getContainer().style.backgroundColor=t,e.setSky(e.getStyle().sky??d),e.setLight({position:[1.15,210,45]})}function fd(e,t,n,r){e.addSource(`mc-dem`,{type:`raster-dem`,tiles:[`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],attribution:`<a href="https://earth.jaxa.jp/en/data/policy" target="_blank">© AW3D30 (JAXA)</a>`,minzoom:0,maxzoom:12}),e.setTerrain({source:`mc-dem`,exaggeration:r})}function pd(e,t){if(document.getElementById(`custom-style`)?.remove(),!e)return;let n;e.startsWith(`http`)?(e=`${e}?access_token=${t}`,n=document.createElement(`link`),n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e.replace(/https?:/,``))):(n=document.createElement(`style`),n.appendChild(document.createTextNode(e))),n.setAttribute(`id`,`custom-style`),n.setAttribute(`type`,`text/css`),document.head.appendChild(n)}function md(e,t,n){let r=e?.reduce((e,t)=>(e[t.id]={visibility:t.visibility,...t.opacity!==void 0&&{opacity:t.opacity}},e),{})??{},i={};for(let e of t.layers)i[e.id]=r[e.id]??{visibility:(e.layout?.visibility??`visible`)===`visible`};for(let e of n)for(let t of e.layers)i[t.id]=r[t.id]??{visibility:!1};return i}function hd(e,t,n){for(let r in t){let i=e.getLayer(r);if(i!==void 0){let a=t[r];if(e.setLayoutProperty(r,`visibility`,a.visibility&&n?`visible`:`none`),a.opacity!==void 0){let t=h[i.type];for(let n of t.props)e.setPaintProperty(r,n,a.opacity)}}}}function gd(e,t,n,r,i,a,o){let{beforeNone:s=[],beforeNames:c=[],beforeBoundaries:l=[],beforeWaters:u=[]}=r;s.forEach(r=>{_d(e,t,n,r,i,`mc-before-none`,a,o)}),c.forEach(r=>{_d(e,t,n,r,i,`mc-before-names`,a,o)}),l.forEach(r=>{_d(e,t,n,r,i,`mc-before-boundaries`,a,o)}),u.forEach(r=>{_d(e,t,n,r,i,`mc-before-waters`,a,o)})}function _d(e,t,n,r,i,a,o,s){if(r.type===`marker`){let o=n.marker?.find(e=>e.id===r.groupId);o&&ql(e,o,a,i,t)}else if(r.type===`polygon`){let o=n.polygon?.find(e=>e.id===r.groupId);o&&Hl(e,o,a,i,t)}else if(r.type===`circle`){let o=n.circle?.find(e=>e.id===r.groupId);o&&Wl(e,o,a,i,t)}else if(r.type===`line`){let i=n.line?.find(e=>e.id===r.groupId);i&&vu(e,i,a,t)}else if(r.type===`dot`){let t=n.dot?.find(e=>e.id===r.groupId);t&&Su(e,t,a)}else if(r.type===`area`){let c=n.area?.find(e=>e.id===r.groupId);c&&xu(e,c,a,i,t,o,s)}}e.initMap=sd,e.setRTLTextPlugin=u.setRTLTextPlugin});