UNPKG

@linkurious/ogma-annotations

Version:
1,109 lines 96.6 kB
var Fn = Object.defineProperty; var Rn = (a, h, t) => h in a ? Fn(a, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[h] = t; var m = (a, h, t) => Rn(a, typeof h != "symbol" ? h + "" : h, t); let te = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((h, t) => (t &= 63, t < 36 ? h += t.toString(36) : t < 62 ? h += (t - 26).toString(36).toUpperCase() : t > 62 ? h += "-" : h += "_", h), ""); const Nt = { strokeType: "plain", strokeColor: "#202020", strokeWidth: 1, head: "none", tail: "none" }, Oe = { id: 0, type: "Feature", properties: { type: "arrow", style: { ...Nt } }, geometry: { type: "LineString", coordinates: [ [0, 0], [100, 100] ] } // type: 'arrow', // stroke: { // type: 'plain', // color: 'black', // width: 1 // }, // head: 'none', // tail: 'arrow-plain', // start: { x: 0, y: 0 }, // end: { x: 100, y: 100 } }, qn = (a = 0, h = 0, t = 0, r = 0, o = { ...Nt }) => ({ id: te(), type: "Feature", properties: { type: "arrow", style: { ...Nt, ...o } }, geometry: { type: "LineString", coordinates: [ [a, h], [t, r] ] } }), Bn = "http://www.w3.org/2000/svg"; function xt(a) { return document.createElementNS(Bn, a); } function Ge(a) { return a.geometry.bbox || jn(a), a.geometry.bbox; } function ut(a) { const h = Ge(a); return { width: h[2] - h[0], height: h[3] - h[1] }; } function ct(a) { const h = Ge(a); return { x: h[0], y: h[1] }; } function jn(a) { const [h, t] = a.geometry.coordinates[0][0], [r, o] = a.geometry.coordinates[0][2]; a.geometry.bbox = [h, t, r, o]; } function Vn(a, h, t, r, o) { a.geometry.bbox = [h, t, h + r, t + o], a.geometry.coordinates = [ [ [h, t], [h + r, t], [h + r, t + o], [h, t + o], [h, t] ] ]; } function zt(a) { const [h, t] = a.geometry.coordinates[0]; return { x: h, y: t }; } function Vt(a, h) { const [t, r] = a.geometry.coordinates[h === "start" ? 0 : 1]; return { x: t, y: r }; } function Xt(a) { const [h, t] = a.geometry.coordinates[1]; return { x: h, y: t }; } function Ye(a, h, t) { a.geometry.coordinates[0] = [h, t]; } function Xe(a, h, t) { a.geometry.coordinates[1] = [h, t]; } function Zt(a) { return { start: zt(a), end: Xt(a) }; } function kt(a, h, t, r) { h === "start" ? Ye(a, t, r) : Xe(a, t, r); } const Ze = (a) => parseInt(a.getAttribute("data-handle-id") || "-1"); function yr(a) { return Gt(a).reduce( (h, t) => (h[0] = Math.min(t[0], h[0]), h[1] = Math.min(t[1], h[1]), h[2] = Math.max(t[0], h[2]), h[3] = Math.max(t[1], h[3]), h), [ Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY ] ); } function Un(a) { return Array.isArray(a) && a.length === 2 && a.every(isFinite); } function Wn(a, h, t, r) { for (let o = 0; o < a.coordinates.length; o++) { const l = a.coordinates[o]; if (Un(l)) l[0] = t + (l[0] - t) * h, l[1] = r + (l[1] - r) * h; else for (let u = 0; u < l.length; u++) { const d = l[u]; d[0] = t + (d[0] - t) * h, d[1] = r + (d[1] - r) * h; } } return a; } function Gt(a) { let h = []; return a.type == "Point" ? h = [a.coordinates] : a.type == "LineString" || a.type == "MultiPoint" ? h = a.coordinates : a.type == "Polygon" || a.type == "MultiLineString" ? h = a.coordinates.reduce(function(t, r) { return t.concat(r); }, []) : a.type == "MultiPolygon" ? h = a.coordinates.reduce( (t, r) => t.concat(r.reduce((o, l) => o.concat(l), [])), [] ) : a.type == "Feature" ? h = Gt(a.geometry) : a.type == "GeometryCollection" ? h = a.geometries.reduce( (t, r) => t.concat(Gt(r)), [] ) : a.type == "FeatureCollection" && (h = a.features.reduce( (t, r) => t.concat(Gt(r)), [] )), h; } function Ut(a, h, t) { const r = Math.atan2(a.y - h.y, a.x - h.x); return { x: h.x + t * Math.cos(r), y: h.y + t * Math.sin(r) }; } function Kt(a, h) { if (!h) return { x: a.clientX, y: a.clientY }; const t = h.getBoundingClientRect(); return { x: a.clientX - t.left - h.clientLeft, y: a.clientY - t.top - h.clientTop }; } function mr(a, h) { return a.startsWith("#") ? Yn(a, h) : a.startsWith("rgb") ? Xn(a, h) : a; } function Gn(a) { return a.length === 4 ? a.split("").map((h) => h + h).join("") : a; } function Yn(a, h) { const [t, r, o] = Gn(a).match(/\w\w/g).map((l) => parseInt(l, 16)); return `rgba(${t}, ${r}, ${o}, ${h})`; } function Xn(a, h) { const [t, r, o] = a.match(/\d+/g).map((l) => parseInt(l, 10)); return `rgba(${t}, ${r}, ${o}, ${h})`; } const wt = (a, h) => ({ x: a.x - h.x, y: a.y - h.y }), Tt = (a) => Math.sqrt(a.x * a.x + a.y * a.y), Ke = (a) => ({ x: -a.x, y: -a.y }), Je = (a) => { const h = Tt(a); return h === 0 ? { x: 0, y: 0 } : { x: a.x / h, y: a.y / h }; }, St = (a, h) => ({ x: a.x + h.x, y: a.y + h.y }), Qe = (a, h) => ({ x: a.x * h, y: a.y * h }), Wt = (a, h) => ({ x: a.x * h.x, y: a.y * h.y }), rt = (a, h) => { const t = Math.sin(h), r = Math.cos(h); return { x: a.x * r - a.y * t, y: a.x * t + a.y * r }; }, Zn = (a, h) => ({ x: a.x / h, y: a.y / h }), Le = (a, h) => a.x * h.x + a.y * h.y, Kn = 0.5; function tn(a, h = 5, t = 30) { var d; const { start: r, end: o } = Zt(a), l = wt(o, r), u = a.properties.style && a.properties.style.strokeWidth ? (d = a.properties.style) == null ? void 0 : d.strokeWidth : 0; return Math.min(t, Math.max(3 * u, Tt(l) * 0.01, h)); } function Ce(a, h, t, r) { const o = Qe(Ke(Je(h)), r); if (!t || t !== "arrow" && t !== "arrow-plain") return ""; const l = St(a, rt(o, Math.PI / 10)), u = St(a, rt(o, -Math.PI / 10)), d = `${a.x} ${a.y}`; return `M ${l.x} ${l.y} L ${d} ${u.x} ${u.y} ${t === "arrow" ? "" : `${l.x} ${l.y}`}`; } function Jn(a, h, t, r, o) { const { start: l, end: u } = Zt(a), { tail: d, head: y, strokeColor: f, strokeWidth: g = 0 } = a.properties.style || t, v = wt(u, l), k = tn(a, r, o), b = xt("g"), w = xt("path"); b.setAttribute("data-annotation", `${a.id}`), b.setAttribute("data-annotation-type", "arrow"); const $ = y === "arrow-plain" || d === "arrow", E = f || "none"; w.setAttribute("stroke", E), w.setAttribute("stroke-width", `${g}`), w.setAttribute("fill", $ ? f || "" : "none"), w.setAttribute("stroke-linecap", "round"), w.setAttribute("stroke-linejoin", "round"); const C = Ce(l, Ke(v), d, k), N = Ce(u, v, y, k), D = C + `M ${l.x} ${l.y} ${u.x} ${u.y}` + N; w.setAttribute("d", D), b.appendChild(w), $e(b, l, E, d, g), $e(b, u, E, y, g), h.appendChild(b); } function $e(a, h, t, r, o) { r === "halo-dot" && Pe( a, h, Qn(t), Kn, o * 4 ), (r === "dot" || r === "halo-dot") && Pe(a, h, t, 1, o * 2); } function Qn(a) { return a === "none" ? "none" : a; } function Pe(a, h, t, r, o) { const l = xt("circle"); l.setAttribute("cx", `${h.x}`), l.setAttribute("cy", `${h.y}`), l.setAttribute("r", `${o}`), l.setAttribute("fill-opacity", `${r}`), l.setAttribute("fill", t), a.appendChild(l); } const W = -1, Jt = "dragging", Qt = "dragstart", It = "dragend", pe = "select", ge = "unselect", tr = "hover", er = "unhover", ye = "remove", me = "add", nr = "cancelDrawing", ve = "update", rr = "link"; function en(a) { return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a; } var ce = { exports: {} }, ze; function ir() { return ze || (ze = 1, function(a) { var h = Object.prototype.hasOwnProperty, t = "~"; function r() { } Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1)); function o(y, f, g) { this.fn = y, this.context = f, this.once = g || !1; } function l(y, f, g, v, k) { if (typeof g != "function") throw new TypeError("The listener must be a function"); var b = new o(g, v || y, k), w = t ? t + f : f; return y._events[w] ? y._events[w].fn ? y._events[w] = [y._events[w], b] : y._events[w].push(b) : (y._events[w] = b, y._eventsCount++), y; } function u(y, f) { --y._eventsCount === 0 ? y._events = new r() : delete y._events[f]; } function d() { this._events = new r(), this._eventsCount = 0; } d.prototype.eventNames = function() { var f = [], g, v; if (this._eventsCount === 0) return f; for (v in g = this._events) h.call(g, v) && f.push(t ? v.slice(1) : v); return Object.getOwnPropertySymbols ? f.concat(Object.getOwnPropertySymbols(g)) : f; }, d.prototype.listeners = function(f) { var g = t ? t + f : f, v = this._events[g]; if (!v) return []; if (v.fn) return [v.fn]; for (var k = 0, b = v.length, w = new Array(b); k < b; k++) w[k] = v[k].fn; return w; }, d.prototype.listenerCount = function(f) { var g = t ? t + f : f, v = this._events[g]; return v ? v.fn ? 1 : v.length : 0; }, d.prototype.emit = function(f, g, v, k, b, w) { var $ = t ? t + f : f; if (!this._events[$]) return !1; var E = this._events[$], C = arguments.length, N, D; if (E.fn) { switch (E.once && this.removeListener(f, E.fn, void 0, !0), C) { case 1: return E.fn.call(E.context), !0; case 2: return E.fn.call(E.context, g), !0; case 3: return E.fn.call(E.context, g, v), !0; case 4: return E.fn.call(E.context, g, v, k), !0; case 5: return E.fn.call(E.context, g, v, k, b), !0; case 6: return E.fn.call(E.context, g, v, k, b, w), !0; } for (D = 1, N = new Array(C - 1); D < C; D++) N[D - 1] = arguments[D]; E.fn.apply(E.context, N); } else { var z = E.length, R; for (D = 0; D < z; D++) switch (E[D].once && this.removeListener(f, E[D].fn, void 0, !0), C) { case 1: E[D].fn.call(E[D].context); break; case 2: E[D].fn.call(E[D].context, g); break; case 3: E[D].fn.call(E[D].context, g, v); break; case 4: E[D].fn.call(E[D].context, g, v, k); break; default: if (!N) for (R = 1, N = new Array(C - 1); R < C; R++) N[R - 1] = arguments[R]; E[D].fn.apply(E[D].context, N); } } return !0; }, d.prototype.on = function(f, g, v) { return l(this, f, g, v, !1); }, d.prototype.once = function(f, g, v) { return l(this, f, g, v, !0); }, d.prototype.removeListener = function(f, g, v, k) { var b = t ? t + f : f; if (!this._events[b]) return this; if (!g) return u(this, b), this; var w = this._events[b]; if (w.fn) w.fn === g && (!k || w.once) && (!v || w.context === v) && u(this, b); else { for (var $ = 0, E = [], C = w.length; $ < C; $++) (w[$].fn !== g || k && !w[$].once || v && w[$].context !== v) && E.push(w[$]); E.length ? this._events[b] = E.length === 1 ? E[0] : E : u(this, b); } return this; }, d.prototype.removeAllListeners = function(f) { var g; return f ? (g = t ? t + f : f, this._events[g] && u(this, g)) : (this._events = new r(), this._eventsCount = 0), this; }, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = t, d.EventEmitter = d, a.exports = d; }(ce)), ce.exports; } var sr = ir(); const nn = /* @__PURE__ */ en(sr); class rn extends nn { constructor(t, r) { super(); m(this, "ogma"); m(this, "elements"); // layer to draw elements m(this, "layer"); m(this, "editor"); m(this, "selectedId", W); m(this, "hoveredId", W); // used to remember ogma options before we change them m(this, "ogmaOptions"); m(this, "shouldDetect"); m(this, "isDragging"); m(this, "showeditorOnHover"); m(this, "_onKeyUp", (t) => { t.code === 27 && this.selectedId !== W ? this.unselect() : (t.code === 46 || t.code === 8) && this.selectedId !== W && this._canRemove() && this.remove(this.selectedId); }); m(this, "_onClickMouseMove", (t) => { if (!t.domEvent || this.isDragging || !this.shouldDetect || t.domEvent.type !== "mousemove" && t.domEvent.target && t.domEvent.target.tagName === "a") return; const r = this.ogma.view.screenToGraphCoordinates(t), o = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(r, 0) : void 0; t.domEvent.type === "mousemove" ? o ? this.hover(o.id) : this.hoveredId !== W && this.unhover() : o ? this.select(o.id) : this.selectedId !== W && this.unselect(); }); this.ogma = t, this.elements = [], this.shouldDetect = !0, this.isDragging = !1, this.showeditorOnHover = !0, this.ogmaOptions = t.getOptions(), t.events.on(["click", "mousemove"], this._onClickMouseMove).on("keyup", this._onKeyUp).on("frame", () => { this.refreshEditor(), this.refreshDrawing(); }), this.layer = t.layers.addSVGLayer({ draw: (o) => this.draw(o) }), this.layer.moveToTop(), this.editor = t.layers.addLayer(r), this.editor.hide(); } _canRemove() { return !0; } /** * @method add * @param options Params for the annotation (merged with default) * @returns the added annotation */ add(t) { const r = this.getDefaultOptions(), o = Object.assign(t, { id: t.id === void 0 ? te() : t.id, type: t.type, properties: { ...r.properties, ...t.properties || {}, // styles need to be merged style: { ...r.properties.style, ...t.properties.style || {} } }, geometry: { ...r.geometry, ...t.geometry } }); return this.elements.push(o), this.layer.refresh(), this.emit(me, o), o; } updateStyle(t, r) { this.updateAnnotation(t, { properties: { style: r } }); } updateGeometry(t, r) { this.updateAnnotation(t, { geometry: r }); } scale(t, r, o, l) { this.updateGeometry( t, Wn(t.geometry, r, o, l) ); } /** * @method update * Updates an annotation (position, color etc) * @param id Id of the annotation to update * @param element params of the annotation */ update(t, r) { const o = this.getById(t); this.updateAnnotation(o, r); } updateAnnotation(t, r) { if (!t) return; const o = t.id; Object.keys(r).forEach((l) => { if (l !== "id") if (l === "properties") { const u = r.properties || { style: {} }; t.properties = { ...t.properties || {}, ...u || {}, style: { ...t.properties.style || {}, ...u.style || {} } }; } else l === "geometry" ? t.geometry = { ...t.geometry, ...r.geometry } : t[l] = r[l]; }), o === this.selectedId && this.refreshEditor(), this.layer.refresh(); } getById(t) { const r = Number(t); for (let o = 0; o < this.elements.length; o++) { const l = this.elements[o]; if (!(l.id !== t && l.id !== r)) return l; } } /** * @method select * @param id id of the element to select * Select element, show editor, disable Ogma dragging and fire event */ select(t) { const r = this.getById(t); r && (this.editor.show(), this.selectedId = t, this.refreshEditor(), this.layer.refresh(), this.emit(pe, r)); } hover(t) { const r = this.getById(t); r && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(tr, r)); } getSelectedFeature() { return this.selectedId === W ? null : this.getById(this.selectedId); } unselect() { const t = this.getById(this.selectedId); return t && this.emit(ge, t), this.selectedId = W, this.hoveredId === W && this.editor.hide(), this.layer.refresh(), this; } unhover() { const t = this.getById(this.hoveredId); return this.emit(er, t), this.hoveredId = W, this.selectedId === W && this.editor.hide(), this.layer.refresh(), this; } /** * @method remove * @param id Id of the annotation to remove * Removes annotation with the given id */ remove(t) { const r = this.getById(t); t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((o) => o.id !== t), r && this.emit(ye, r), this.layer.refresh(); } /** * @method disableDragging * Prevents Ogma from dragging elements or moving the view while dragging an annotation */ disableDragging() { this.ogma.setOptions({ interactions: { drag: { enabled: !1 }, pan: { enabled: !1 } }, detect: { nodes: !1, edges: !1, nodeTexts: !1, edgeTexts: !1 } }); } /** * @method restoreDragging * restore ogma options as they were before we start dragging an annotation */ restoreDragging() { this.ogma.setOptions(this.ogmaOptions); } enableDetection() { this.shouldDetect = !0; } /** * @method disableDetection * Disables the hover behaviour, used by controller to avoid hovering * arrows while dragging texts and vice versa */ disableDetection() { this.shouldDetect = !1; } refreshLayer() { this.layer.refresh(); } refreshDrawing() { } getElements() { return [...this.elements]; } destroy() { this.ogma.events.off(this._onClickMouseMove).off(this._onKeyUp), this.layer.destroy(); } } const Ne = "handle-line", He = "handle-start", Fe = "handle-end"; class or extends rn { constructor(t, r = {}) { super( t, ` <div class="arrow-handle"> <div id="${Ne}" data-handle-id="0" class="handle line"></div> <div id="${He}" data-handle-id="1" class="handle point"></div> <div id="${Fe}" data-handle-id="2" class="handle point"></div> </div> ` ); // active handle id m(this, "draggedHandle", W); m(this, "start", { x: 0, y: 0 }); m(this, "end", { x: 0, y: 0 }); m(this, "arrow", { ...Oe }); m(this, "startX", 0); m(this, "startY", 0); m(this, "minArrowHeight", 0); m(this, "maxArrowHeight", 0); m(this, "handles", []); m(this, "onHandleMouseDown", (t) => { const r = this.getById(this.selectedId) || this.getById(this.hoveredId); if (!r) return; const { x: o, y: l } = Kt(t, this.ogma.getContainer()); this.startDragging(r, o, l), this.draggedHandle = Ze(t.target); }); m(this, "onMouseUp", () => { this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = W, this.emit(It, this.arrow)); }); m(this, "onMouseMove", (t) => { if (!this.isDragging || this.draggedHandle === W) return; const { x: r, y: o } = Kt(t, this.ogma.getContainer()), l = this.handles[this.draggedHandle], u = this.ogma.view.getAngle(), { x: d, y } = rt( Zn( { x: r - this.startX, y: o - this.startY }, this.ogma.view.getZoom() ), u ), f = l.id === Ne, g = l.id === He, v = l.id === Fe; (f || g) && Ye(this.arrow, this.start.x + d, this.start.y + y), (f || v) && Xe(this.arrow, this.end.x + d, this.end.y + y), this.emit( Jt, this.arrow, f ? "line" : g ? "start" : "end" ), this.refreshEditor(), this.layer.refresh(); }); this.minArrowHeight = r.minArrowHeight || 0, this.maxArrowHeight = r.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call( this.editor.element.querySelectorAll(".arrow-handle>.handle") ), this.handles.forEach( (o) => o.addEventListener("mousedown", this.onHandleMouseDown) ), document.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("mouseup", this.onMouseUp); } /** * Start drawing a new arrow, it will also be added as a new annotation * @param x * @param y * @param arrow */ startDrawing(t, r, o = qn(t, r, t, r, Nt)) { var d; this.disableDragging(), this.add(o), this.hoveredId = o.id; const l = this.ogma.view.graphToScreenCoordinates({ x: t, y: r }), u = ((d = this.ogma.getContainer()) == null ? void 0 : d.getBoundingClientRect()) || { left: 0, top: 0 }; this.startDragging( this.getById(o.id), l.x + (u == null ? void 0 : u.left), l.y + u.top ), this.draggedHandle = 2; } cancelDrawing() { this.isDragging && (this.remove(this.arrow.id), this.emit(It, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = W); } startDragging(t, r, o) { this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = o, this.start = zt(this.arrow), this.end = Xt(this.arrow), this.disableDragging(), this.emit(Qt, this.arrow), this.isDragging = !0; } detect(t, r = 0) { return this.elements.find((o) => { const { start: l, end: u } = Zt(o), d = wt(t, { x: (l.x + u.x) / 2, y: (l.y + u.y) / 2 }), y = wt(u, l), f = Tt(y), g = Je(y), v = tn(o); return Math.abs(Le(g, d)) < f / 2 + r && Math.abs(Le(rt(g, Math.PI / 2), d)) < v / 2 + r; }); } refreshEditor() { if (+this.selectedId < 0 && +this.hoveredId < 0) return; const t = this.selectedId !== W ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Zt(t), o = this.ogma.view.graphToScreenCoordinates(r.start), l = this.ogma.view.graphToScreenCoordinates(r.end), [u, d, y] = Array.prototype.slice.call( this.editor.element.querySelectorAll(".handle") ); d.style.transform = `translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`, y.style.transform = `translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`; const f = { x: (l.x + o.x) / 2, y: (l.y + o.y) / 2 }, g = wt(l, o), v = Qe(g, 1 / Tt(g)), k = Math.atan2(v.y, v.x); u.style.width = `${Tt(g)}px`, u.style.left = `${f.x}px`, u.style.top = `${f.y}px`, u.style.transform = `translate(-50%, -50%) rotate(${k}rad)`; } getDefaultOptions() { return Oe; } draw(t) { t.innerHTML = ""; const r = xt("g"), o = this.ogma.view.getAngle(); o !== 0 && r.setAttribute("transform", `rotate(${-o * (180 / Math.PI)})`), this.elements.forEach( (l) => Jn(l, r, Nt, this.minArrowHeight, this.maxArrowHeight) ), t.appendChild(r); } refreshDrawing() { const t = this.ogma.view.getAngle(); this.layer.element !== null && t !== 0 && this.layer.element.children[0].setAttribute( "transform", `rotate(${-t * (180 / Math.PI)})` ); } destroy() { super.destroy(), document.removeEventListener("mousemove", this.onMouseMove, !0), document.removeEventListener("mouseup", this.onMouseUp); } } const _t = { font: "sans-serif", fontSize: 18, color: "#505050", background: "#f5f5f5", strokeWidth: 0, borderRadius: 8, padding: 16, strokeType: "plain" }, ue = { id: 0, type: "Feature", properties: { type: "text", content: "", style: { ..._t } }, geometry: { type: "Polygon", coordinates: [ [ [0, 0], [100, 0], [100, 50], [0, 50], [0, 0] ] ] } // position: { x: 0, y: 0 }, // size: { width: 100, height: 50 } }, Re = { handleSize: 3.5, placeholder: "Your text..." }, ar = (a = 0, h = 0, t = 100, r = 50, o = "", l = { ..._t }) => ({ id: te(), type: "Feature", properties: { type: "text", content: o, style: { ..._t, ...l } }, geometry: { type: "Polygon", coordinates: [ [ [a, h], [a + t, h], [a + t, h + r], [a, h + r], [a, h] ] ] } }); var Yt = { exports: {} }, lr = Yt.exports, qe; function hr() { return qe || (qe = 1, function(a, h) { (function(t, r) { a.exports = r(); })(lr, () => (() => { var t = { d: (e, n) => { for (var s in n) t.o(n, s) && !t.o(e, s) && Object.defineProperty(e, s, { enumerable: !0, get: n[s] }); }, o: (e, n) => Object.prototype.hasOwnProperty.call(e, n) }, r = {}; function o(e) { return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) { return typeof n; } : function(n) { return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; }, o(e); } t.d(r, { default: () => Nn }); var l = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, u = /\bsmall-caps\b/, d = /\b(?:italic|oblique)\b/, y = /\bbold(?:er)?\b/, f = 13.3333333, g = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 }; function v(e) { var n = "", s = this; return s.style && s.style !== "normal" && (n += s.style), s.variant && s.variant !== "normal" && (n += (n ? " " : "") + s.variant), s.weight && s.weight !== "normal" && (n += (n ? " " : "") + s.weight), s.size && (n += (n ? " " : "") + s.size + "px", s.height !== s.size && (n += "/" + s.height + "px")), s.family && (n += (n ? " " : "") + s.family), e && (n += "::" + s.baseline), e && (n += "::" + s.color), n; } var k = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: v, valueOf: v }; function b(e) { var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = l.exec(e); n.family = (s[6] || "").trim(); var i = g[s[2]] || parseFloat(s[2]); s[3] === "%" ? i *= 0.16 : s[3] === "em" ? i *= 16 : s[3] === "pt" && (i *= f), n.size = i; var c = parseFloat(s[4]); if (c !== "normal" && c !== "inherit" && c ? s[5] && s[5] !== "em" ? s[5] === "pt" ? n.height = c * f : s[5] === "%" ? n.height = 0.01 * i : n.height = c : n.height = c * i : n.height = Math.round(i * (7 / 6)), u.test(s[1]) && (n.variant = "small-caps"), d.test(s[1]) && (n.style = "italic"), y.test(s[1])) n.weight = "bold"; else { var p = parseInt(/\b(\d+)\b/.exec(s[1]), 10); p >= 100 && p !== 400 && (n.weight = p); } return n; } function w() { var e, n, s, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, p = 14, A = 12, x = null, S = null, T = ""; if (i && i.nodeType) { var M = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView), O = M.getComputedStyle(i, null); e = O.getPropertyValue("font-family") || "", A = parseFloat(O.getPropertyValue("font-size")), p = O.getPropertyValue("line-height"), x = O.getPropertyValue("font-weight"), S = O.getPropertyValue("font-style"), T = O.getPropertyValue("font-variant") || ""; } else if (typeof i == "string") { var _ = b(i); e = _.family, A = _.size, p = _.height, T = _.variant, S = _.style, x = _.weight; } else o(i) === "object" && (e = i.family, A = i.size, p = i.height, T = i.variant, x = i.weight, S = i.style, n = i.baseline, s = i.color); c.size && c.size < 3 && (A *= c.size), p = p !== "normal" && p ? parseFloat(p) : A * (7 / 6), c.height && c.height < 3 && (p *= c.height); var L = Object.create(k); return L.family = c.family || e || "sans-serif", L.height = p ?? 14, L.size = A ?? 12, L.variant = c.variant || T || "", L.style = c.style || S || "", L.weight = c.weight || x || "", L.baseline = n || 0, c.baseline != null && (L.baseline = c.baseline), L.color = c.color || s || "", L.id = v.call(L, !0), L; } const $ = { "\n": 0.28, "\r": 0.28, " ": 0.28, " ": 0.28, " ": 0.28, "᠎": 0, " ": 0.5, " ": 1, " ": 0.5, " ": 1, " ": 0.33, " ": 0.25, " ": 0.16, " ": 0.56, " ": 0.28, " ": 0.2, " ": 0.15, "​": 0, " ": 0.16, " ": 0.22, " ": 1, "\uFEFF": 0 }; var E, C = function(e) { var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas"); if (n && n.getContext) { var s = n.getContext("2d"); if (s && typeof s.measureText == "function") return function(i, c) { return s.font = String(c), s.measureText(i).width; }; } }(typeof document < "u" ? document : null) || (E = {}, function(e, n) { if (!E[n]) { var s = w(n); E[n] = s, /\bmonospace\b/.test(s.family) ? s.size *= 0.6 : (s.size *= 0.45, s.weight && (s.size *= 1.18)); } return e.length * E[n].size; }), N = {}, D = { trim: !0, collapse: !0 }; function z(e, n, s) { var i = Object.assign({}, D, s), c = String(e); if (!c) return 0; if (c in $) { var p = n.id + "/" + c; return p in N || (N[p] = C("_".concat(c, "_"), n) - C("__", n)), N[p]; } return i.trim && i.collapse ? i.trim ? c = c.trim() : i.collapse && (c = c.replace(/\s+/g, " ")) : c = c.replace(/\n/g, " "), C(c, n) + n.size * (e.tracking || 0); } function R(e) { return R = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) { return typeof n; } : function(n) { return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n; }, R(e); } function dt(e, n) { if (typeof n != "function" && n !== null) throw new TypeError("Super expression must either be null or a function"); e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n && Dt(e, n); } function Dt(e, n) { return Dt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(s, i) { return s.__proto__ = i, s; }, Dt(e, n); } function Mt(e) { var n = function() { if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1; if (typeof Proxy == "function") return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })), !0; } catch { return !1; } }(); return function() { var s, i = Ht(e); if (n) { var c = Ht(this).constructor; s = Reflect.construct(i, arguments, c); } else s = i.apply(this, arguments); return sn(this, s); }; } function sn(e, n) { if (n && (R(n) === "object" || typeof n == "function")) return n; if (n !== void 0) throw new TypeError("Derived constructors may only return object or undefined"); return function(s) { if (s === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return s; }(e); } function Ht(e) { return Ht = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) { return n.__proto__ || Object.getPrototypeOf(n); }, Ht(e); } function Ft(e, n) { if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function"); } function on(e, n) { for (var s = 0; s < n.length; s++) { var i = n[s]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(p, A) { if (R(p) !== "object" || p === null) return p; var x = p[Symbol.toPrimitive]; if (x !== void 0) { var S = x.call(p, A); if (R(S) !== "object") return S; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(p); }(i.key, "string"), R(c) === "symbol" ? c : String(c)), i); } var c; } function Rt(e, n, s) { return n && on(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), e; } var q = function() { function e() { var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; Ft(this, e), this.value = n, this.weight = null, this.style = null, this.font = null, this.href = null, this.sub = !1, this.sup = !1; } return Rt(e, [{ key: "clone", value: function() { var n = new e(this.value); return n.value = this.value, n.weight = this.weight, n.style = this.style, n.font = this.font, n.href = this.href, n.sub = this.sub, n.sup = this.sup, n; } }, { key: "valueOf", value: function() { return this.value; } }, { key: "toString", value: function() { return this.value; } }]), e; }(), Ot = function(e) { dt(s, e); var n = Mt(s); function s() { return Ft(this, s), n.apply(this, arguments); } return Rt(s); }(q), et = function(e) { dt(s, e); var n = Mt(s); function s() { return Ft(this, s), n.apply(this, arguments); } return Rt(s); }(q), yt = function(e) { dt(s, e); var n = Mt(s); function s() { return Ft(this, s), n.apply(this, arguments); } return Rt(s); }(q), ee = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, an = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, xe = /^[\xA0\u2011\u202F\u2060\uFEFF]/, ln = /^(?:[;\xAD%?…]|,(?!\d))/, hn = /^[´±°¢£¤$¥\u2212]/; function qt(e, n) { n !== !1 && (e = e.trim()); for (var s, i, c = [], p = e.charAt(0), A = 0, x = 1, S = e.length; x < S; x++) { s = e.charAt(x), i = e.charAt(x + 1); var T = ee.test(p), M = ee.test(s), O = M || T, _ = void 0; if ((hn.test(s) && !xe.test(p) || ln.test(p + i) && !xe.test(s)) && (O = !0), p !== "-" && p !== "‐" && p !== "–" && p !== "—" || ((_ = ee.test(e.charAt(x - 2))) && !M && (O = !1), !_ && an.test(s + i) && (O = !0)), O) { var L = e.slice(A, x); /\u00AD$/.test(L) ? (c.push(new q(L.slice(0, -1))), c.push(new yt())) : (c.push(new q(L)), c.push(new Ot())), A = x; } p = s; } return c.push(new q(e.slice(A))), c; } const we = { nbsp: " ", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "­", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", times: "×", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", divide: "÷", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", fnof: "ƒ", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", bull: "•", hellip: "…", prime: "′", Prime: "″", oline: "‾", frasl: "⁄", weierp: "℘", image: "ℑ", real: "ℜ", trade: "™", alefsym: "ℵ", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lArr: "⇐", uArr: "⇑", rArr: "⇒", dArr: "⇓", hArr: "⇔", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "⊥", or: "⊦", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", lang: "〈", rang: "〉", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦", quot: '"', amp: "&", lt: "<", gt: ">", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "‌", zwj: "‍", lrm: "‎", rlm: "‏", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", permil: "‰", lsaquo: "‹", rsaquo: "›" }; var cn = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, un = /^<\/([a-zA-Z0-9]+)([^>]*)>/, dn = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, fn = /^<!--(.+?)-->/, pn = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, be = { b: function(e) { e.weight = "bold"; }, strong: function(e) { e.weight = "bold"; }, i: function(e) { e.style = "italic"; }, em: function(e) { e.style = "italic"; }, dfn: function(e) { e.style = "italic"; }, cite: function(e) { e.style = "italic"; }, code: function(e) { e.family = "monospace"; }, kbd: function(e) { e.family = "monospace"; }, samp: function(e) { e.family = "monospace"; }, var: function(e) { e.family = "monospace"; }, tt: function(e) { e.family = "monospace"; }, sub: function(e) { e.sub = !0; }, sup: function(e) { e.sup = !0; } }, gn = { div: 1, li: 1, blockquote: 2, h1: 2, h2: 2, h3: 2, h4: 2, h5: 2, h6: 2, ul: 2, ol: 2, hr: 2, p: 2 }; function Ae(e) { return e.replace(pn, function(n, s, i, c) { if (s || i) { var p = s ? 10 : 16; return String.fromCharCode(parseInt(s || i, p)); } return c in we ? we[c] : n; }); } function yn(e) { return e && e.length > 1 && (e[0] === '"' && e[e.length - 1] === '"' || e[0] === "'" && e[e.length - 1] === "'") ? e.slice(1, -1) : e; } var mn = /^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/; function vn(e) { var n, s = {}; if (e) { do if (n = mn.exec(e)) { var i = Ae(yn(n[2] || "")).replace(/[ \r\n\t]+/g, " ").trim(); if (s[n[1]] = i, (e = e.slice(n[0].length)).length && /^\S/.test(e[0])) throw new Error("Attribute error"); } while (n && e.length); if (/\S/.test(e)) throw new Error("Attribute error"); } return s; } const Ee = { copyright: "©", textcopyright: "©", dag: "†", textdagger: "†", ddag: "‡", textdaggerdbl: "‡", guillemotleft: "«", guillemotright: "»", guilsinglleft: "‹", guilsinglright: "›", ldots: "…", dots: "…", textellipsis: "…", lq: "‘", P: "¶", textparagraph: "¶", pounds: "£", textsterling: "£", quotedblbase: "„", quotesinglbase: "‚", rq: "’", S: "§", sim: "~", textasciicircum: "^", textasciitilde: "˜", texttildelow: "~", textasteriskcentered: "*", textbackslash: "'", textbar: "|", textbardbl: "╎", textbigcircle: "◯", textbraceleft: "{", textbraceright: "}", textbullet: "•", textdollar: "$", textemdash: "—", textendash: "—", texteuro: "€", eurosym: "€", euro: "€", textexclamdown: "¡", textgreater: ">", textless: "<", textordfeminine: "ª", textordmasculine: "º", textperiodcentered: "·", cdot: "·", textquestiondown: "¿", textquotedblleft: "“", textquotedblright: "”", textquoteleft: "‘", textquoteright: "’", textquotestraightbase: "‚", textquotestraightdblbase: "„", textregistered: "®", textthreequartersemdash: "-", texttrademark: "™", texttwelveudash: "-", textunderscore: "_", textvisiblespace: "␣", gets: "←", textleftarrow: "←", to: "→", textrightarrow: "→", textdegree: "°", infty: "∞", triangle: "△", triangledown: "▽", blacktriangle: "▲", blacktriangledown: "▼", angle: "∠", sphericalangle: "∢", aleph: "ℵ", hbar: "ħ", imath: "𝚤", jmath: "𝚥", ell: "ℓ", wp: "℘", Re: "ℜ", Im: "ℑ", mho: "℧", prime: "′", emptyset: "∅", nabla: "∇", surd: "√", partial: "∂", top: "⟙", bot: "⟂", vdash: "⟝", dashv: "⟞", forall: "∀", exists: "∃", nexists: "∄", neg: "¬", lnot: "¬", flat: "♭", natural: "♮", sharp: "♯", backslash: "\\", Box: "□", Diamond: "♢", clubsuit: "♣", diamondsuit: "♦", heartsuit: "♥", spadesuit: "♠", Join: "⨝", blacksquare: "■", bigstar: "★", diagdown: "╲", diagup: "╱", blacklozenge: "⧫", rfloor: "⌋", lfloor: "⌊", rceil: "⌉", lceil: "⌈", rangle: "⟩", langle: "⟨", sum: "∑", int: "∫", oint: "∮", prod: "∏", coprod: "∏", bigcap: "∩", bigcup: "∪", bigsqcup: "⊔", bigvee: "∨", bigwedge: "∧", bigodot: "⊙", bigotimes: "⊗", bigoplus: "⊕", biguplus: "⊎", alpha: "α", beta: "β", chi: "χ", delta: "δ", epsilon: "ε", eta: "η", gamma: "γ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", omega: "ω", phi: "φ", pi: "π", psi: "ψ", rho: "ρ", sigma: "σ", tau: "τ", theta: "θ", upsilon: "υ", xi: "ξ", zeta: "ζ", Alpha: "Α", Beta: "Β", Chi: "Χ", Delta: "Δ", Epsilon: "Ε", Eta: "Η", Gamma: "Γ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Omega: "Ω", Phi: "Φ", Pi: "Π", Psi: "Ψ", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Theta: "Θ", Upsilon: "Υ", Xi: "Ξ", Zeta: "Ζ", aa: "å", AA: "Å", ae: "æ", AE: "Æ", dh: "ð", DH: "Ð", dj: "đ", DJ: "Đ", ij: "ij", IJ: "IJ", l: "ł", L: "Ł", ng: "ŋ", NG: "Ŋ", o: "ø", O: "Ø", oe: "œ", OE: "Œ", ss: "ß", SS: "SS", th: "þ", TH: "Þ" }; var xn = /^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/, wn = /^%[^\n]+(?:\n|$)/, bn = /^[^#$%&~_^\\{}]+/, An = /^\\([&{}$%#_])/, En = /(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g, kn = { "---": "—", "--": "–", "!`": "¡", "?`": "¿", "``": "“", ",,": "„", "''": "”", "`": "‘", "'": "’", "<<": "«", ">>": "»", "~": " ", "\\-": "­", "\\,": " ", "\\;": " ", "\\:": " ", "\\!": " ", "\\@": "\uFEFF", "\\\\": "\\newline{}" }, G = { bf: function(e) { e.weight = "bold"; }, it: function(e) { e.style = "italic"; }, sl: function(e) { e.style = "italic"; }, color: function(e, n) { e.color = n; }, href: function(e, n) { e.href = n; }, "^": function(e) { e.sup = !0; }, _: function(e) { e.sub = !0; }, par: function(e) { this.tokens.push(new et(), new et()); }, newline: function(e) { this.tokens.push(new et()); }, url: function(e, n) { this.open_context().href = n, this.add_token(new q(n)), this.close_context(); } }; G.textsuperscript = G["^"], G.textsubscript = G._, G.textsl = G.sl, G.mathbf = G.bf, G.mathit = G.it, G.textbf = G.bf, G.textit = G.it, G.textcolor = G.color; var Sn = /[\r\n\xA0]+/g; function Tn(e, n) { e.sup && (e.baseline = 0.45, e.size = 0.7), e.sub && (e.baseline = -0.3, e.size = 0.7); var s = n; return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (s = w(n, e)), s; } function ke(e, n, s) { for (var i, c, p = e.width; p + s.width > n && e.length; ) c = (i = e[e.length - 1]).width, i.width > s.width ? (i.value = i.value.slice(0, -1), i.width = z(i, i.font), p += i.width) : e.pop(), p -= c; e[e.length - 1] instanceof yt && e.pop(), i = e[e.length - 1] || i || {}, s.font = w(s.font, i.bold, i.italic, ""), s.href = e.length ? i.href : null, s.rel = e.length ? i.rel : null, s.target = e.length ? i.target : null, e.push(s); } function bt(e) { return Math.round(1e6 * e) / 1e6; } function Se(e) { return function(n) { if (Array.isArray(n)) return ne(n); }(e) || function(n) { if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null) return Array.from(n); }(e) || function(n, s) { if (n) { if (typeof n == "string") return ne(n, s); var i = Object.prototype.toString.call(n).slice(8, -1); return i === "Object" && n.constructor && (i = n.constructor.name), i === "Map" || i === "Set" ? Array.from(n) : i === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i) ? ne(n, s) : void 0; } }(e) || function() { throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`); }(); } function ne(e, n) { (n == null || n > e.length) && (n = e.length); for (var s = 0, i = new Array(n); s < n; s++) i[s] = e[s]; return i; } var _n = { center: "middle", right: "end" }, In = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, re = function(e, n) { return !e && !n || e === n; }; function Dn(e, n) { var s = [], i = n.font(), c = i.size, p = i.family, A = n.align(), x = n.createElement(); if (e.length) { var S = i.height, T = n.valign(), M = n.height()(), O = n.width()(0), _ = !isFinite(O) && e.length === 1, L = _ ? null : n.x(), B = bt(S / c), J = _ ? null : bt(S / (1.15 * c + (S - c) / 2)); if (In[T] && isFinite(M)) { var H = T === "bottom" ? 1 : 0.5; J += (M * H - S * e.length * H) / c; } var P = A === "justify", j = 0; A === "right" ? j = O : A === "center" && (j = O / 2); for (var F = [], Q = "tspan", Y = null, V = "", I = function() { if (V) { var mt = x(Q, Y, V); F.push(mt); } Q = "tspan", Y = null, V = ""; }, nt = 0, tt = e.length; nt < tt; nt++) { var at = "", ft = "", ot = 0, lt = e[nt]; if (lt.length) { F = []; for (var At = 0, $t = 0, ht = void 0, X = 0, Bt = lt.length; X < Bt; X++) { var U = lt[X], Z = U.font; U.whitespace && At++, $t += U.width, X && !U.tracking && !ot && re(Z.id, at) && re(U.class, ft) && re(ht, U.href) ? V += U.value : (I(), V = U.value, Y = { fontFamily: Z.family !== p ? Z.family : null, fontSize: Z.size !== c ? Z.size : null, fontWeight: Z.weight || null, fontStyle: Z.style || null, fontVariant: Z.variant !== "normal" && Z.variant || null, fill: Z.color || null, baselineShift: Z.baseline ? 100 * Z.baseline + "%" : null, className: U.class || null }, ot && (Y.dx = bt(ot), ot = 0), U.tracking && (ot = Z.size * U.tracking), U.href && !ht ? (ht = U.href, Q = "a", Y.href = ht, Y.rel = U.rel, Y.target = U.target) : ht = null, at = Z.id, ft = U.class); } if (I(), _) s.push.apply(s, Se(F)); else { var jt = null, Pt = nt === tt - 1 || lt[lt.length - 1] instanceof et; P && lt.length > 1 && !Pt && (jt = bt((O - $t) / At)), s.push(x.apply(void 0, ["tspan", { wordSpacing: jt, x: L(nt) + j, dy: bt(nt ? B : J) + "em" }].concat(Se(F)))); } } else s.push(x("tspan", { x: L(nt), dy: bt(nt ? B : J) + "em" }, " ")); } } return x.apply(void 0, ["text", { fontFamily: p, fontSize: c, textAnchor: _n[A] || "start" }].concat(s)); } var Mn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }; function On(e, n, s) { if (e.length) { s.textBaseline = "middle"; var i = n.font(), c = i.height, p = i.size, A = n.valign(), x = n.height()(), S = n.width()(0), T = n.align(), M = T === "justify", O = 0.5 * c, _ = Mn[A]; if (_ && isFinite(x)) { var L = e.length * c; O += x * _ - L * _; } e.forEach(function(B, J) { var H = n.x()(J), P = J * c + O, j = 0, F = 0; B.forEach(function(V) { V.whitespace && j++, F += V.width; }); var Q = 0, Y = J === e.length - 1 || B[B.length - 1] instanceof et; M && B.length > 1 && !Y && (Q = (S - F) / j), B.forEach(function(V) { s.font = V.font; var I = V.font, nt = I.baseline ? p * -I.baseline + 0.15 * p : 0; s.fillStyle = function(ft, ot) { return ft.color ? ft.color : ot.href ? "#00C" : "#000"; }(I, V); var tt = 0; if (T === "right" ? tt += S - F : T === "center" ? tt += S / 2 - F / 2 : T === "justify" && (V.whitespace || V instanceof et) && (H += Q), s.fillText(V.value, H + tt, P + nt), V.href) { s.beginPath(), s.strokeStyle = s.fillStyle; var at = Math.floor(P + 0.45 * p) + 0.5; s.moveTo(H + tt, at), s.lineTo(H + tt + V.width, at), s.stroke(); } H += V.width; }); }); } } function ie(e) { return ie = typeof Symbol == "function" && typeof Symbol.iterator == "symbol