UNPKG

@thatopen/ui-obc

Version:

Collection of web components (UI components) implementations to use with @thatopen/components.

1,562 lines (1,541 loc) 322 kB
import * as S from "@thatopen/components"; import * as ln from "@thatopen/components-front"; import * as rt from "three"; import { Object3D as Nr, Vector2 as Fr, Vector3 as cn, Matrix4 as Rs } from "three"; /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const Ze = globalThis, dn = Ze.ShadowRoot && (Ze.ShadyCSS === void 0 || Ze.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, un = Symbol(), Rn = /* @__PURE__ */ new WeakMap(); let Ds = class { constructor(t, e, n) { if (this._$cssResult$ = !0, n !== un) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = t, this.t = e; } get styleSheet() { let t = this.o; const e = this.t; if (dn && t === void 0) { const n = e !== void 0 && e.length === 1; n && (t = Rn.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), n && Rn.set(e, t)); } return t; } toString() { return this.cssText; } }; const Ur = (i) => new Ds(typeof i == "string" ? i : i + "", void 0, un), hn = (i, ...t) => { const e = i.length === 1 ? i[0] : t.reduce((n, s, o) => n + ((r) => { if (r._$cssResult$ === !0) return r.cssText; if (typeof r == "number") return r; throw Error("Value passed to 'css' function must be a 'css' function result: " + r + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); })(s) + i[o + 1], i[0]); return new Ds(e, i, un); }, qr = (i, t) => { if (dn) i.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet); else for (const e of t) { const n = document.createElement("style"), s = Ze.litNonce; s !== void 0 && n.setAttribute("nonce", s), n.textContent = e.cssText, i.appendChild(n); } }, Dn = dn ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => { let e = ""; for (const n of t.cssRules) e += n.cssText; return Ur(e); })(i) : i; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const { is: Vr, defineProperty: Yr, getOwnPropertyDescriptor: Wr, getOwnPropertyNames: Gr, getOwnPropertySymbols: Xr, getPrototypeOf: Jr } = Object, $t = globalThis, Ln = $t.trustedTypes, Qr = Ln ? Ln.emptyScript : "", Ii = $t.reactiveElementPolyfillSupport, ye = (i, t) => i, ei = { toAttribute(i, t) { switch (t) { case Boolean: i = i ? Qr : null; break; case Object: case Array: i = i == null ? i : JSON.stringify(i); } return i; }, fromAttribute(i, t) { let e = i; switch (t) { case Boolean: e = i !== null; break; case Number: e = i === null ? null : Number(i); break; case Object: case Array: try { e = JSON.parse(i); } catch { e = null; } } return e; } }, pn = (i, t) => !Vr(i, t), jn = { attribute: !0, type: String, converter: ei, reflect: !1, useDefault: !1, hasChanged: pn }; Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), $t.litPropertyMetadata ?? ($t.litPropertyMetadata = /* @__PURE__ */ new WeakMap()); let Wt = class extends HTMLElement { static addInitializer(t) { this._$Ei(), (this.l ?? (this.l = [])).push(t); } static get observedAttributes() { return this.finalize(), this._$Eh && [...this._$Eh.keys()]; } static createProperty(t, e = jn) { if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) { const n = Symbol(), s = this.getPropertyDescriptor(t, n, e); s !== void 0 && Yr(this.prototype, t, s); } } static getPropertyDescriptor(t, e, n) { const { get: s, set: o } = Wr(this.prototype, t) ?? { get() { return this[e]; }, set(r) { this[e] = r; } }; return { get: s, set(r) { const a = s == null ? void 0 : s.call(this); o == null || o.call(this, r), this.requestUpdate(t, a, n); }, configurable: !0, enumerable: !0 }; } static getPropertyOptions(t) { return this.elementProperties.get(t) ?? jn; } static _$Ei() { if (this.hasOwnProperty(ye("elementProperties"))) return; const t = Jr(this); t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties); } static finalize() { if (this.hasOwnProperty(ye("finalized"))) return; if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(ye("properties"))) { const e = this.properties, n = [...Gr(e), ...Xr(e)]; for (const s of n) this.createProperty(s, e[s]); } const t = this[Symbol.metadata]; if (t !== null) { const e = litPropertyMetadata.get(t); if (e !== void 0) for (const [n, s] of e) this.elementProperties.set(n, s); } this._$Eh = /* @__PURE__ */ new Map(); for (const [e, n] of this.elementProperties) { const s = this._$Eu(e, n); s !== void 0 && this._$Eh.set(s, e); } this.elementStyles = this.finalizeStyles(this.styles); } static finalizeStyles(t) { const e = []; if (Array.isArray(t)) { const n = new Set(t.flat(1 / 0).reverse()); for (const s of n) e.unshift(Dn(s)); } else t !== void 0 && e.push(Dn(t)); return e; } static _$Eu(t, e) { const n = e.attribute; return n === !1 ? void 0 : typeof n == "string" ? n : typeof t == "string" ? t.toLowerCase() : void 0; } constructor() { super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev(); } _$Ev() { var t; this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this)); } addController(t) { var e; (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t)); } removeController(t) { var e; (e = this._$EO) == null || e.delete(t); } _$E_() { const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties; for (const n of e.keys()) this.hasOwnProperty(n) && (t.set(n, this[n]), delete this[n]); t.size > 0 && (this._$Ep = t); } createRenderRoot() { const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); return qr(t, this.constructor.elementStyles), t; } connectedCallback() { var t; this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => { var n; return (n = e.hostConnected) == null ? void 0 : n.call(e); }); } enableUpdating(t) { } disconnectedCallback() { var t; (t = this._$EO) == null || t.forEach((e) => { var n; return (n = e.hostDisconnected) == null ? void 0 : n.call(e); }); } attributeChangedCallback(t, e, n) { this._$AK(t, n); } _$ET(t, e) { var o; const n = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, n); if (s !== void 0 && n.reflect === !0) { const r = (((o = n.converter) == null ? void 0 : o.toAttribute) !== void 0 ? n.converter : ei).toAttribute(e, n.type); this._$Em = t, r == null ? this.removeAttribute(s) : this.setAttribute(s, r), this._$Em = null; } } _$AK(t, e) { var o, r; const n = this.constructor, s = n._$Eh.get(t); if (s !== void 0 && this._$Em !== s) { const a = n.getPropertyOptions(s), l = typeof a.converter == "function" ? { fromAttribute: a.converter } : ((o = a.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? a.converter : ei; this._$Em = s, this[s] = l.fromAttribute(e, a.type) ?? ((r = this._$Ej) == null ? void 0 : r.get(s)) ?? null, this._$Em = null; } } requestUpdate(t, e, n) { var s; if (t !== void 0) { const o = this.constructor, r = this[t]; if (n ?? (n = o.getPropertyOptions(t)), !((n.hasChanged ?? pn)(r, e) || n.useDefault && n.reflect && r === ((s = this._$Ej) == null ? void 0 : s.get(t)) && !this.hasAttribute(o._$Eu(t, n)))) return; this.C(t, e, n); } this.isUpdatePending === !1 && (this._$ES = this._$EP()); } C(t, e, { useDefault: n, reflect: s, wrapped: o }, r) { n && !(this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Map())).has(t) && (this._$Ej.set(t, r ?? e ?? this[t]), o !== !0 || r !== void 0) || (this._$AL.has(t) || (this.hasUpdated || n || (e = void 0), this._$AL.set(t, e)), s === !0 && this._$Em !== t && (this._$Eq ?? (this._$Eq = /* @__PURE__ */ new Set())).add(t)); } async _$EP() { this.isUpdatePending = !0; try { await this._$ES; } catch (e) { Promise.reject(e); } const t = this.scheduleUpdate(); return t != null && await t, !this.isUpdatePending; } scheduleUpdate() { return this.performUpdate(); } performUpdate() { var n; if (!this.isUpdatePending) return; if (!this.hasUpdated) { if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) { for (const [o, r] of this._$Ep) this[o] = r; this._$Ep = void 0; } const s = this.constructor.elementProperties; if (s.size > 0) for (const [o, r] of s) { const { wrapped: a } = r, l = this[o]; a !== !0 || this._$AL.has(o) || l === void 0 || this.C(o, void 0, r, l); } } let t = !1; const e = this._$AL; try { t = this.shouldUpdate(e), t ? (this.willUpdate(e), (n = this._$EO) == null || n.forEach((s) => { var o; return (o = s.hostUpdate) == null ? void 0 : o.call(s); }), this.update(e)) : this._$EM(); } catch (s) { throw t = !1, this._$EM(), s; } t && this._$AE(e); } willUpdate(t) { } _$AE(t) { var e; (e = this._$EO) == null || e.forEach((n) => { var s; return (s = n.hostUpdated) == null ? void 0 : s.call(n); }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); } _$EM() { this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; } get updateComplete() { return this.getUpdateComplete(); } getUpdateComplete() { return this._$ES; } shouldUpdate(t) { return !0; } update(t) { this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM(); } updated(t) { } firstUpdated(t) { } }; Wt.elementStyles = [], Wt.shadowRootOptions = { mode: "open" }, Wt[ye("elementProperties")] = /* @__PURE__ */ new Map(), Wt[ye("finalized")] = /* @__PURE__ */ new Map(), Ii == null || Ii({ ReactiveElement: Wt }), ($t.reactiveElementVersions ?? ($t.reactiveElementVersions = [])).push("2.1.0"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const _e = globalThis, ii = _e.trustedTypes, Bn = ii ? ii.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, Ls = "$lit$", _t = `lit$${Math.random().toFixed(9).slice(2)}$`, js = "?" + _t, Zr = `<${js}>`, Ft = document, Se = () => Ft.createComment(""), ke = (i) => i === null || typeof i != "object" && typeof i != "function", mn = Array.isArray, Kr = (i) => mn(i) || typeof (i == null ? void 0 : i[Symbol.iterator]) == "function", Ri = `[ \f\r]`, be = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Hn = /-->/g, Nn = />/g, Mt = RegExp(`>|${Ri}(?:([^\\s"'>=/]+)(${Ri}*=${Ri}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`, "g"), Fn = /'/g, Un = /"/g, Bs = /^(?:script|style|textarea|title)$/i, ta = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), fn = ta(1), Zt = Symbol.for("lit-noChange"), R = Symbol.for("lit-nothing"), qn = /* @__PURE__ */ new WeakMap(), Rt = Ft.createTreeWalker(Ft, 129); function Hs(i, t) { if (!mn(i) || !i.hasOwnProperty("raw")) throw Error("invalid template strings array"); return Bn !== void 0 ? Bn.createHTML(t) : t; } const ea = (i, t) => { const e = i.length - 1, n = []; let s, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", r = be; for (let a = 0; a < e; a++) { const l = i[a]; let c, d, u = -1, p = 0; for (; p < l.length && (r.lastIndex = p, d = r.exec(l), d !== null); ) p = r.lastIndex, r === be ? d[1] === "!--" ? r = Hn : d[1] !== void 0 ? r = Nn : d[2] !== void 0 ? (Bs.test(d[2]) && (s = RegExp("</" + d[2], "g")), r = Mt) : d[3] !== void 0 && (r = Mt) : r === Mt ? d[0] === ">" ? (r = s ?? be, u = -1) : d[1] === void 0 ? u = -2 : (u = r.lastIndex - d[2].length, c = d[1], r = d[3] === void 0 ? Mt : d[3] === '"' ? Un : Fn) : r === Un || r === Fn ? r = Mt : r === Hn || r === Nn ? r = be : (r = Mt, s = void 0); const f = r === Mt && i[a + 1].startsWith("/>") ? " " : ""; o += r === be ? l + Zr : u >= 0 ? (n.push(c), l.slice(0, u) + Ls + l.slice(u) + _t + f) : l + _t + (u === -2 ? a : f); } return [Hs(i, o + (i[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), n]; }; let Vi = class Ns { constructor({ strings: t, _$litType$: e }, n) { let s; this.parts = []; let o = 0, r = 0; const a = t.length - 1, l = this.parts, [c, d] = ea(t, e); if (this.el = Ns.createElement(c, n), Rt.currentNode = this.el.content, e === 2 || e === 3) { const u = this.el.content.firstChild; u.replaceWith(...u.childNodes); } for (; (s = Rt.nextNode()) !== null && l.length < a; ) { if (s.nodeType === 1) { if (s.hasAttributes()) for (const u of s.getAttributeNames()) if (u.endsWith(Ls)) { const p = d[r++], f = s.getAttribute(u).split(_t), b = /([.?@])?(.*)/.exec(p); l.push({ type: 1, index: o, name: b[2], strings: f, ctor: b[1] === "." ? na : b[1] === "?" ? sa : b[1] === "@" ? oa : fi }), s.removeAttribute(u); } else u.startsWith(_t) && (l.push({ type: 6, index: o }), s.removeAttribute(u)); if (Bs.test(s.tagName)) { const u = s.textContent.split(_t), p = u.length - 1; if (p > 0) { s.textContent = ii ? ii.emptyScript : ""; for (let f = 0; f < p; f++) s.append(u[f], Se()), Rt.nextNode(), l.push({ type: 2, index: ++o }); s.append(u[p], Se()); } } } else if (s.nodeType === 8) if (s.data === js) l.push({ type: 2, index: o }); else { let u = -1; for (; (u = s.data.indexOf(_t, u + 1)) !== -1; ) l.push({ type: 7, index: o }), u += _t.length - 1; } o++; } } static createElement(t, e) { const n = Ft.createElement("template"); return n.innerHTML = t, n; } }; function Kt(i, t, e = i, n) { var r, a; if (t === Zt) return t; let s = n !== void 0 ? (r = e._$Co) == null ? void 0 : r[n] : e._$Cl; const o = ke(t) ? void 0 : t._$litDirective$; return (s == null ? void 0 : s.constructor) !== o && ((a = s == null ? void 0 : s._$AO) == null || a.call(s, !1), o === void 0 ? s = void 0 : (s = new o(i), s._$AT(i, e, n)), n !== void 0 ? (e._$Co ?? (e._$Co = []))[n] = s : e._$Cl = s), s !== void 0 && (t = Kt(i, s._$AS(i, t.values), s, n)), t; } class ia { constructor(t, e) { this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e; } get parentNode() { return this._$AM.parentNode; } get _$AU() { return this._$AM._$AU; } u(t) { const { el: { content: e }, parts: n } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ?? Ft).importNode(e, !0); Rt.currentNode = s; let o = Rt.nextNode(), r = 0, a = 0, l = n[0]; for (; l !== void 0; ) { if (r === l.index) { let c; l.type === 2 ? c = new bn(o, o.nextSibling, this, t) : l.type === 1 ? c = new l.ctor(o, l.name, l.strings, this, t) : l.type === 6 && (c = new ra(o, this, t)), this._$AV.push(c), l = n[++a]; } r !== (l == null ? void 0 : l.index) && (o = Rt.nextNode(), r++); } return Rt.currentNode = Ft, s; } p(t) { let e = 0; for (const n of this._$AV) n !== void 0 && (n.strings !== void 0 ? (n._$AI(t, n, e), e += n.strings.length - 2) : n._$AI(t[e])), e++; } } let bn = class Fs { get _$AU() { var t; return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv; } constructor(t, e, n, s) { this.type = 2, this._$AH = R, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = n, this.options = s, this._$Cv = (s == null ? void 0 : s.isConnected) ?? !0; } get parentNode() { let t = this._$AA.parentNode; const e = this._$AM; return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t; } get startNode() { return this._$AA; } get endNode() { return this._$AB; } _$AI(t, e = this) { t = Kt(this, t, e), ke(t) ? t === R || t == null || t === "" ? (this._$AH !== R && this._$AR(), this._$AH = R) : t !== this._$AH && t !== Zt && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Kr(t) ? this.k(t) : this._(t); } O(t) { return this._$AA.parentNode.insertBefore(t, this._$AB); } T(t) { this._$AH !== t && (this._$AR(), this._$AH = this.O(t)); } _(t) { this._$AH !== R && ke(this._$AH) ? this._$AA.nextSibling.data = t : this.T(Ft.createTextNode(t)), this._$AH = t; } $(t) { var o; const { values: e, _$litType$: n } = t, s = typeof n == "number" ? this._$AC(t) : (n.el === void 0 && (n.el = Vi.createElement(Hs(n.h, n.h[0]), this.options)), n); if (((o = this._$AH) == null ? void 0 : o._$AD) === s) this._$AH.p(e); else { const r = new ia(s, this), a = r.u(this.options); r.p(e), this.T(a), this._$AH = r; } } _$AC(t) { let e = qn.get(t.strings); return e === void 0 && qn.set(t.strings, e = new Vi(t)), e; } k(t) { mn(this._$AH) || (this._$AH = [], this._$AR()); const e = this._$AH; let n, s = 0; for (const o of t) s === e.length ? e.push(n = new Fs(this.O(Se()), this.O(Se()), this, this.options)) : n = e[s], n._$AI(o), s++; s < e.length && (this._$AR(n && n._$AB.nextSibling, s), e.length = s); } _$AR(t = this._$AA.nextSibling, e) { var n; for ((n = this._$AP) == null ? void 0 : n.call(this, !1, !0, e); t && t !== this._$AB; ) { const s = t.nextSibling; t.remove(), t = s; } } setConnected(t) { var e; this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t)); } }; class fi { get tagName() { return this.element.tagName; } get _$AU() { return this._$AM._$AU; } constructor(t, e, n, s, o) { this.type = 1, this._$AH = R, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = o, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(new String()), this.strings = n) : this._$AH = R; } _$AI(t, e = this, n, s) { const o = this.strings; let r = !1; if (o === void 0) t = Kt(this, t, e, 0), r = !ke(t) || t !== this._$AH && t !== Zt, r && (this._$AH = t); else { const a = t; let l, c; for (t = o[0], l = 0; l < o.length - 1; l++) c = Kt(this, a[n + l], e, l), c === Zt && (c = this._$AH[l]), r || (r = !ke(c) || c !== this._$AH[l]), c === R ? t = R : t !== R && (t += (c ?? "") + o[l + 1]), this._$AH[l] = c; } r && !s && this.j(t); } j(t) { t === R ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? ""); } } let na = class extends fi { constructor() { super(...arguments), this.type = 3; } j(t) { this.element[this.name] = t === R ? void 0 : t; } }; class sa extends fi { constructor() { super(...arguments), this.type = 4; } j(t) { this.element.toggleAttribute(this.name, !!t && t !== R); } } let oa = class extends fi { constructor(t, e, n, s, o) { super(t, e, n, s, o), this.type = 5; } _$AI(t, e = this) { if ((t = Kt(this, t, e, 0) ?? R) === Zt) return; const n = this._$AH, s = t === R && n !== R || t.capture !== n.capture || t.once !== n.once || t.passive !== n.passive, o = t !== R && (n === R || s); s && this.element.removeEventListener(this.name, this, n), o && this.element.addEventListener(this.name, this, t), this._$AH = t; } handleEvent(t) { var e; typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t); } }, ra = class { constructor(t, e, n) { this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = n; } get _$AU() { return this._$AM._$AU; } _$AI(t) { Kt(this, t); } }; const Di = _e.litHtmlPolyfillSupport; Di == null || Di(Vi, bn), (_e.litHtmlVersions ?? (_e.litHtmlVersions = [])).push("3.3.0"); const aa = (i, t, e) => { const n = (e == null ? void 0 : e.renderBefore) ?? t; let s = n._$litPart$; if (s === void 0) { const o = (e == null ? void 0 : e.renderBefore) ?? null; n._$litPart$ = s = new bn(t.insertBefore(Se(), o), o, void 0, e ?? {}); } return s._$AI(i), s; }; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const jt = globalThis; let Bt = class extends Wt { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } createRenderRoot() { var e; const t = super.createRenderRoot(); return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t; } update(t) { const e = this.render(); this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = aa(e, this.renderRoot, this.renderOptions); } connectedCallback() { var t; super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0); } disconnectedCallback() { var t; super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1); } render() { return Zt; } }; var Is; Bt._$litElement$ = !0, Bt.finalized = !0, (Is = jt.litElementHydrateSupport) == null || Is.call(jt, { LitElement: Bt }); const Li = jt.litElementPolyfillSupport; Li == null || Li({ LitElement: Bt }); (jt.litElementVersions ?? (jt.litElementVersions = [])).push("4.2.0"); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const la = { attribute: !0, type: String, converter: ei, reflect: !1, hasChanged: pn }, ca = (i = la, t, e) => { const { kind: n, metadata: s } = e; let o = globalThis.litPropertyMetadata.get(s); if (o === void 0 && globalThis.litPropertyMetadata.set(s, o = /* @__PURE__ */ new Map()), n === "setter" && ((i = Object.create(i)).wrapped = !0), o.set(e.name, i), n === "accessor") { const { name: r } = e; return { set(a) { const l = t.get.call(this); t.set.call(this, a), this.requestUpdate(r, l, i); }, init(a) { return a !== void 0 && this.C(r, void 0, i, a), a; } }; } if (n === "setter") { const { name: r } = e; return function(a) { const l = this[r]; t.call(this, a), this.requestUpdate(r, l, i); }; } throw Error("Unsupported decorator location: " + n); }; function Y(i) { return (t, e) => typeof e == "object" ? ca(i, t, e) : ((n, s, o) => { const r = s.hasOwnProperty(o); return s.constructor.createProperty(o, n), r ? Object.getOwnPropertyDescriptor(s, o) : void 0; })(i, t, e); } /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ function da(i) { return Y({ ...i, state: !0, attribute: !1 }); } class ua extends Nr { /** * Constructs a new CSS2D object. * * @param {DOMElement} [element] - The DOM element. */ constructor(t = document.createElement("div")) { super(), this.isCSS2DObject = !0, this.element = t, this.element.style.position = "absolute", this.element.style.userSelect = "none", this.element.setAttribute("draggable", !1), this.center = new Fr(0.5, 0.5), this.addEventListener("removed", function() { this.traverse(function(e) { e.element instanceof e.element.ownerDocument.defaultView.Element && e.element.parentNode !== null && e.element.remove(); }); }); } copy(t, e) { return super.copy(t, e), this.element = t.element.cloneNode(!0), this.center = t.center, this; } } new cn(); new Rs(); new Rs(); new cn(); new cn(); class ha { constructor(t, e) { this._group = new rt.Group(), this._frustum = new rt.Frustum(), this._frustumMat = new rt.Matrix4(), this._regenerateDelay = 200, this._regenerateCounter = 0, this.material = new rt.LineBasicMaterial({ color: "#2e3338" }), this.numbers = new rt.Group(), this.maxRegenerateRetrys = 4, this.gridsFactor = 5, this._scaleX = 1, this._scaleY = 1, this._offsetX = 0, this._offsetY = 0, this._camera = t, this._container = e; const n = this.newGrid(-1), s = this.newGrid(-2); this.grids = { main: n, secondary: s }, this._group.add(s, n, this.numbers); } set scaleX(t) { this._scaleX = t, this.regenerate(); } get scaleX() { return this._scaleX; } set scaleY(t) { this._scaleY = t, this.regenerate(); } get scaleY() { return this._scaleY; } set offsetX(t) { this._offsetX = t, this.regenerate(); } get offsetX() { return this._offsetX; } set offsetY(t) { this._offsetY = t, this.regenerate(); } get offsetY() { return this._offsetY; } get() { return this._group; } dispose() { const { main: t, secondary: e } = this.grids; t.removeFromParent(), e.removeFromParent(), t.geometry.dispose(), t.material.dispose(), e.geometry.dispose(), e.material.dispose(); } regenerate() { if (!this.isGridReady()) { if (this._regenerateCounter++, this._regenerateCounter > this.maxRegenerateRetrys) throw new Error("Grid could not be regenerated"); setTimeout(() => this.regenerate, this._regenerateDelay); return; } this._regenerateCounter = 0, this._camera.updateMatrix(), this._camera.updateMatrixWorld(); const e = this._frustumMat.multiplyMatrices( this._camera.projectionMatrix, this._camera.matrixWorldInverse ); this._frustum.setFromProjectionMatrix(e); const { planes: n } = this._frustum, s = n[0].constant * -n[0].normal.x, o = n[1].constant * -n[1].normal.x, r = n[2].constant * -n[2].normal.y, a = n[3].constant * -n[3].normal.y, l = Math.abs(s - o), c = Math.abs(a - r), { clientWidth: d, clientHeight: u } = this._container, p = Math.max(d, u), b = Math.max(l, c) / p, v = Math.ceil(Math.log10(l / this.scaleX)), g = Math.ceil(Math.log10(c / this.scaleY)), $ = 10 ** (v - 2) * this.scaleX, y = 10 ** (g - 2) * this.scaleY, _ = $ * this.gridsFactor, w = y * this.gridsFactor, A = Math.ceil(c / w), x = Math.ceil(l / _), M = Math.ceil(c / y), N = Math.ceil(l / $), q = $ * Math.ceil(o / $), E = y * Math.ceil(r / y), ot = _ * Math.ceil(o / _), dt = w * Math.ceil(r / w), K = [...this.numbers.children]; for (const B of K) B.removeFromParent(); this.numbers.children = []; const C = [], z = 9 * b, P = 1e4, F = ot + this._offsetX, tt = Math.round(Math.abs(F / this.scaleX) * P) / P, ut = (x - 1) * _, Ti = Math.round(Math.abs((F + ut) / this.scaleX) * P) / P, Rr = Math.max(tt, Ti).toString().length * z; let Oi = Math.ceil(Rr / _) * _; for (let B = 0; B < x; B++) { let D = ot + B * _; C.push(D, a, 0, D, r, 0), D = Math.round(D * P) / P, Oi = Math.round(Oi * P) / P; const fe = D % Oi; if (!(_ < 1 || w < 1) && Math.abs(fe) > 0.01) continue; const zi = this.newNumber((D + this._offsetX) / this.scaleX), Hr = 12 * b; zi.position.set(D, r + Hr, 0); } for (let B = 0; B < A; B++) { const D = dt + B * w; C.push(o, D, 0, s, D, 0); const fe = this.newNumber(D / this.scaleY); let Mi = 12; fe.element.textContent && (Mi += 4 * fe.element.textContent.length); const zi = Mi * b; fe.position.set(o + zi, D, 0); } const Pi = []; for (let B = 0; B < N; B++) { const D = q + B * $; Pi.push(D, a, 0, D, r, 0); } for (let B = 0; B < M; B++) { const D = E + B * y; Pi.push(o, D, 0, s, D, 0); } const Dr = new rt.BufferAttribute(new Float32Array(C), 3), Lr = new rt.BufferAttribute(new Float32Array(Pi), 3), { main: jr, secondary: Br } = this.grids; jr.geometry.setAttribute("position", Dr), Br.geometry.setAttribute("position", Lr); } newNumber(t) { const e = document.createElement("bim-label"); e.textContent = String(Math.round(t * 100) / 100); const n = new ua(e); return this.numbers.add(n), n; } newGrid(t) { const e = new rt.BufferGeometry(), n = new rt.LineSegments(e, this.material); return n.frustumCulled = !1, n.renderOrder = t, n; } isGridReady() { const t = this._camera.projectionMatrix.elements; for (let e = 0; e < t.length; e++) { const n = t[e]; if (Number.isNaN(n)) return !1; } return !0; } } var pa = Object.defineProperty, ma = Object.getOwnPropertyDescriptor, Le = (i, t, e, n) => { for (var s = ma(t, e), o = i.length - 1, r; o >= 0; o--) (r = i[o]) && (s = r(t, e, s) || s); return s && pa(t, e, s), s; }; const Mn = class Mn extends Bt { constructor() { super(...arguments), this._grid = null, this._world = null, this.resize = () => { this._world && this._grid && this._grid.regenerate(); }; } set gridColor(t) { if (this._gridColor = t, !(t && this._grid)) return; const e = Number(t.replace("#", "0x")); Number.isNaN(e) || this._grid.material.color.setHex(e); } get gridColor() { return this._gridColor; } set gridScaleX(t) { this._gridScaleX = t, t && this._grid && (this._grid.scaleX = t); } get gridScaleX() { return this._gridScaleX; } set gridScaleY(t) { this._gridScaleY = t, t && this._grid && (this._grid.scaleY = t); } get gridScaleY() { return this._gridScaleY; } get gridOffsetX() { var t; return ((t = this._grid) == null ? void 0 : t.offsetX) || 0; } set gridOffsetX(t) { this._grid && (this._grid.offsetX = t); } get gridOffsetY() { var t; return ((t = this._grid) == null ? void 0 : t.offsetY) || 0; } set gridOffsetY(t) { this._grid && (this._grid.offsetY = t); } set components(t) { this.dispose(); const n = t.get(S.Worlds).create(); this._world = n, n.scene = new S.SimpleScene(t), n.scene.setup(), n.renderer = new ln.RendererWith2D(t, this); const s = new S.OrthoPerspectiveCamera(t); n.camera = s; const o = new ha(s.threeOrtho, this); this._grid = o, n.scene.three.add(o.get()), s.controls.addEventListener( "update", () => o.regenerate() ), setTimeout(async () => { n.camera.updateAspect(), s.set("Plan"), await s.controls.setLookAt(0, 0, 100, 0, 0, 0), await s.projection.set("Orthographic"), s.controls.dollySpeed = 3, s.controls.draggingSmoothTime = 0.085, s.controls.maxZoom = 1e3, s.controls.zoom(4); }); } get world() { return this._world; } dispose() { var t; (t = this.world) == null || t.dispose(), this._world = null, this._grid = null; } connectedCallback() { super.connectedCallback(), new ResizeObserver(this.resize).observe(this); } disconnectedCallback() { super.disconnectedCallback(), this.dispose(); } render() { return fn`<slot></slot>`; } }; Mn.styles = hn` :host { position: relative; display: flex; min-width: 0px; height: 100%; background-color: var(--bim-ui_bg-base); } `; let xt = Mn; Le([ Y({ type: String, attribute: "grid-color", reflect: !0 }) ], xt.prototype, "gridColor"); Le([ Y({ type: Number, attribute: "grid-scale-x", reflect: !0 }) ], xt.prototype, "gridScaleX"); Le([ Y({ type: Number, attribute: "grid-scale-y", reflect: !0 }) ], xt.prototype, "gridScaleY"); Le([ Y({ type: Number, attribute: "grid-offset-x", reflect: !0 }) ], xt.prototype, "gridOffsetX"); Le([ Y({ type: Number, attribute: "grid-offset-y", reflect: !0 }) ], xt.prototype, "gridOffsetY"); var fa = Object.defineProperty, kt = (i, t, e, n) => { for (var s = void 0, o = i.length - 1, r; o >= 0; o--) (r = i[o]) && (s = r(t, e, s) || s); return s && fa(t, e, s), s; }; const zn = class zn extends Bt { constructor() { super(...arguments), this._defaults = { size: 60 }, this._cssMatrix3D = "", this._matrix = new rt.Matrix4(), this._onRightClick = new Event("rightclick"), this._onLeftClick = new Event("leftclick"), this._onTopClick = new Event("topclick"), this._onBottomClick = new Event("bottomclick"), this._onFrontClick = new Event("frontclick"), this._onBackClick = new Event("backclick"), this._camera = null, this._epsilon = (t) => Math.abs(t) < 1e-10 ? 0 : t; } set camera(t) { this._camera = t, this.updateOrientation(); } get camera() { return this._camera; } updateOrientation() { if (!this.camera) return; this._matrix.extractRotation(this.camera.matrixWorldInverse); const { elements: t } = this._matrix; this._cssMatrix3D = `matrix3d( ${this._epsilon(t[0])}, ${this._epsilon(-t[1])}, ${this._epsilon(t[2])}, ${this._epsilon(t[3])}, ${this._epsilon(t[4])}, ${this._epsilon(-t[5])}, ${this._epsilon(t[6])}, ${this._epsilon(t[7])}, ${this._epsilon(t[8])}, ${this._epsilon(-t[9])}, ${this._epsilon(t[10])}, ${this._epsilon(t[11])}, ${this._epsilon(t[12])}, ${this._epsilon(-t[13])}, ${this._epsilon(t[14])}, ${this._epsilon(t[15])}) `; } render() { const t = this.size ?? this._defaults.size; return fn` <style> .face, .cube { width: ${t}px; height: ${t}px; transform: translateZ(-300px) ${this._cssMatrix3D}; } .face-right { translate: ${t / 2}px 0 0; } .face-left { translate: ${-t / 2}px 0 0; } .face-top { translate: 0 ${t / 2}px 0; } .face-bottom { translate: 0 ${-t / 2}px 0; } .face-front { translate: 0 0 ${t / 2}px; } .face-back { translate: 0 0 ${-t / 2}px; } </style> <div class="parent"> <div class="cube"> <div class="face x-direction face-right" @click=${() => this.dispatchEvent(this._onRightClick)} > ${this.rightText} </div> <div class="face x-direction face-left" @click=${() => this.dispatchEvent(this._onLeftClick)} > ${this.leftText} </div> <div class="face y-direction face-top" @click=${() => this.dispatchEvent(this._onTopClick)} > ${this.topText} </div> <div class="face y-direction face-bottom" @click=${() => this.dispatchEvent(this._onBottomClick)} > ${this.bottomText} </div> <div class="face z-direction face-front" @click=${() => this.dispatchEvent(this._onFrontClick)} > ${this.frontText} </div> <div class="face z-direction face-back" @click=${() => this.dispatchEvent(this._onBackClick)} > ${this.backText} </div> </div> </div> `; } }; zn.styles = hn` :host { position: absolute; z-index: 999; bottom: 1rem; right: 1rem; } .parent { perspective: 400px; } .cube { position: relative; transform-style: preserve-3d; } .face { position: absolute; display: flex; justify-content: center; user-select: none; align-items: center; cursor: pointer; text-align: center; transition: all 0.2s; color: var(--bim-view-cube--c, white); font-size: var(--bim-view-cube--fz, --bim-ui_size-2xl); } .x-direction { // background-color: var(--bim-view-cube_x--bgc, #c93830DD); background-color: var(--bim-view-cube_x--bgc, #01a6bcde); } .x-direction:hover { background-color: var(--bim-ui_accent-base, white); } .y-direction { // background-color: var(--bim-view-cube_y--bgc, #54ff19DD); background-color: var(--bim-view-cube_y--bgc, #8d0ec8de); } .y-direction:hover { background-color: var(--bim-ui_accent-base, white); } .z-direction { // background-color: var(--bim-view-cube_z--bgc, #3041c9DD); background-color: var(--bim-view-cube_z--bgc, #2718afde); } .z-direction:hover { background-color: var(--bim-ui_accent-base, white); } .face-front { transform: rotateX(180deg); } .face-back { transform: rotateZ(180deg); } .face-top { transform: rotateX(90deg); } .face-bottom { transform: rotateX(270deg); } .face-right { transform: rotateY(-270deg) rotateX(180deg); } .face-left { transform: rotateY(-90deg) rotateX(180deg); } `; let at = zn; kt([ Y({ type: Number, reflect: !0 }) ], at.prototype, "size"); kt([ Y({ type: String, attribute: "right-text", reflect: !0 }) ], at.prototype, "rightText"); kt([ Y({ type: String, attribute: "left-text", reflect: !0 }) ], at.prototype, "leftText"); kt([ Y({ type: String, attribute: "top-text", reflect: !0 }) ], at.prototype, "topText"); kt([ Y({ type: String, attribute: "bottom-text", reflect: !0 }) ], at.prototype, "bottomText"); kt([ Y({ type: String, attribute: "front-text", reflect: !0 }) ], at.prototype, "frontText"); kt([ Y({ type: String, attribute: "back-text", reflect: !0 }) ], at.prototype, "backText"); kt([ da() ], at.prototype, "_cssMatrix3D"); /** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const ba = (i) => i.strings === void 0; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const ga = { CHILD: 2 }, va = (i) => (...t) => ({ _$litDirective$: i, values: t }); class ya { constructor(t) { } get _$AU() { return this._$AM._$AU; } _$AT(t, e, n) { this._$Ct = t, this._$AM = e, this._$Ci = n; } _$AS(t, e) { return this.update(t, e); } update(t, e) { return this.render(...e); } } /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const we = (i, t) => { var n; const e = i._$AN; if (e === void 0) return !1; for (const s of e) (n = s._$AO) == null || n.call(s, t, !1), we(s, t); return !0; }, ni = (i) => { let t, e; do { if ((t = i._$AM) === void 0) break; e = t._$AN, e.delete(i), i = t; } while ((e == null ? void 0 : e.size) === 0); }, Us = (i) => { for (let t; t = i._$AM; i = t) { let e = t._$AN; if (e === void 0) t._$AN = e = /* @__PURE__ */ new Set(); else if (e.has(i)) break; e.add(i), $a(t); } }; function _a(i) { this._$AN !== void 0 ? (ni(this), this._$AM = i, Us(this)) : this._$AM = i; } function wa(i, t = !1, e = 0) { const n = this._$AH, s = this._$AN; if (s !== void 0 && s.size !== 0) if (t) if (Array.isArray(n)) for (let o = e; o < n.length; o++) we(n[o], !1), ni(n[o]); else n != null && (we(n, !1), ni(n)); else we(this, i); } const $a = (i) => { i.type == ga.CHILD && (i._$AP ?? (i._$AP = wa), i._$AQ ?? (i._$AQ = _a)); }; class xa extends ya { constructor() { super(...arguments), this._$AN = void 0; } _$AT(t, e, n) { super._$AT(t, e, n), Us(this), this.isConnected = t._$AU; } _$AO(t, e = !0) { var n, s; t !== this.isConnected && (this.isConnected = t, t ? (n = this.reconnected) == null || n.call(this) : (s = this.disconnected) == null || s.call(this)), e && (we(this, t), ni(this)); } setValue(t) { if (ba(this._$Ct)) this._$Ct._$AI(t, this); else { const e = [...this._$Ct._$AH]; e[this._$Ci] = t, this._$Ct._$AI(e, this, 0); } } disconnected() { } reconnected() { } } /** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const Yi = () => new Ca(); class Ca { } const ji = /* @__PURE__ */ new WeakMap(), Aa = va(class extends xa { render(i) { return R; } update(i, [t]) { var n; const e = t !== this.G; return e && this.G !== void 0 && this.rt(void 0), (e || this.lt !== this.ct) && (this.G = t, this.ht = (n = i.options) == null ? void 0 : n.host, this.rt(this.ct = i.element)), R; } rt(i) { if (this.isConnected || (i = void 0), typeof this.G == "function") { const t = this.ht ?? globalThis; let e = ji.get(t); e === void 0 && (e = /* @__PURE__ */ new WeakMap(), ji.set(t, e)), e.get(this.G) !== void 0 && this.G.call(this.ht, void 0), e.set(this.G, i), i !== void 0 && this.G.call(this.ht, i); } else this.G.value = i; } get lt() { var i, t; return typeof this.G == "function" ? (i = ji.get(this.ht ?? globalThis)) == null ? void 0 : i.get(this.G) : (t = this.G) == null ? void 0 : t.value; } disconnected() { this.lt === this.ct && this.rt(void 0); } reconnected() { this.rt(this.ct); } }); var Sa = Object.defineProperty, ka = (i, t, e, n) => { for (var s = void 0, o = i.length - 1, r; o >= 0; o--) (r = i[o]) && (s = r(t, e, s) || s); return s && Sa(t, e, s), s; }; const In = class In extends Bt { constructor() { super(...arguments), this.world = null, this._components = null, this._viewport = Yi(); } set components(t) { var e; if (this._components = t, this.components) { const n = this.components.get(S.Worlds); this.world = n.create(), this.world.name = this.name; } else (e = this.world) == null || e.dispose(), this.world = null; } get components() { return this._components; } connectedCallback() { super.connectedCallback(), this.world && (this.world.enabled = !0); } disconnectedCallback() { super.disconnectedCallback(), this.world && (this.world.enabled = !1); } dispose() { this.components = null, this.remove(); } firstUpdated() { const { value: t } = this._viewport; if (!(this.components && t && this.world)) return; const e = new S.SimpleScene(this.components); this.world.scene = e, e.setup(), e.three.background = null; const n = new S.SimpleRenderer(this.components, t); this.world.renderer = n; const s = new S.OrthoPerspectiveCamera(this.components); this.world.camera = s; const o = this.components.get(S.Grids).create(this.world); o.material.uniforms.uColor.value = new rt.Color(4342338), o.material.uniforms.uSize1.value = 2, o.material.uniforms.uSize2.value = 8; } onSlotChange() { const t = new Event("slotchange"); this.dispatchEvent(t); } render() { return fn` <bim-viewport ${Aa(this._viewport)}> <slot @slotchange=${this.onSlotChange}></slot> </bim-viewport>`; } }; In.styles = hn``; let si = In; ka([ Y({ type: String, reflect: !0 }) ], si.prototype, "name"); var Ea = Object.defineProperty, Ta = (i, t, e) => t in i ? Ea(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, zt = (i, t, e) => (Ta(i, typeof t != "symbol" ? t + "" : t, e), e); const te = Math.min, bt = Math.max, oi = Math.round, Ct = (i) => ({ x: i, y: i }), Oa = { left: "right", right: "left", bottom: "top", top: "bottom" }, Pa = { start: "end", end: "start" }; function Vn(i, t, e) { return bt(i, te(t, e)); } function je(i, t) { return typeof i == "function" ? i(t) : i; } function gt(i) { return i.split("-")[0]; } function bi(i) { return i.split("-")[1]; } function qs(i) { return i === "x" ? "y" : "x"; } function Vs(i) { return i === "y" ? "height" : "width"; } const Ma = /* @__PURE__ */ new Set(["top", "bottom"]); function ft(i) { return Ma.has(gt(i)) ? "y" : "x"; } function Ys(i) { return qs(ft(i)); } function za(i, t, e) { e === void 0 && (e = !1); const n = bi(i), s = Ys(i), o = Vs(s); let r = s === "x" ? n === (e ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top"; return t.reference[o] > t.floating[o] && (r = ri(r)), [r, ri(r)]; } function Ia(i) { const t = ri(i); return [Wi(i), t, Wi(t)]; } function Wi(i) { return i.replace(/start|end/g, (t) => Pa[t]); } const Yn = ["left", "right"], Wn = ["right", "left"], Ra = ["top", "bottom"], Da = ["bottom", "top"]; function La(i, t, e) { switch (i) { case "top": case "bottom": return e ? t ? Wn : Yn : t ? Yn : Wn; case "left": case "right": return t ? Ra : Da; default: return []; } } function ja(i, t, e, n) { const s = bi(i); let o = La(gt(i), e === "start", n); return s && (o = o.map((r) => r + "-" + s), t && (o = o.concat(o.map(Wi)))), o; } function ri(i) { return i.replace(/left|right|bottom|top/g, (t) => Oa[t]); } function Ba(i) { return { top: 0, right: 0, bottom: 0, left: 0, ...i }; } function Ws(i) { return typeof i != "number" ? Ba(i) : { top: i, right: i, bottom: i, left: i }; } function ee(i) { const { x: t, y: e, width: n, height: s } = i; return { width: n, height: s, top: e, left: t, right: t + n, bottom: e + s, x: t, y: e }; } function Gn(i, t, e) { let { reference: n, floating: s } = i; const o = ft(t), r = Ys(t), a = Vs(r), l = gt(t), c = o === "y", d = n.x + n.width / 2 - s.width / 2, u = n.y + n.height / 2 - s.height / 2, p = n[a] / 2 - s[a] / 2; let f; switch (l) { case "top": f = { x: d, y: n.y - s.height }; break; case "bottom": f = { x: d, y: n.y + n.height }; break; case "right": f = { x: n.x + n.width, y: u }; break; case "left": f = { x: n.x - s.width, y: u }; break; default: f = { x: n.x, y: n.y }; } switch (bi(t)) { case "start": f[r] -= p * (e && c ? -1 : 1); break; case "end": f[r] += p * (e && c ? -1 : 1); break; } return f; } const Ha = async (i, t, e) => { const { placement: n = "bottom", strategy: s = "absolute", middleware: o = [], platform: r } = e, a = o.filter(Boolean), l = await (r.isRTL == null ? void 0 : r.isRTL(t)); let c = await r.getElementRects({ reference: i, floating: t, strategy: s }), { x: d, y: u } = Gn(c, n, l), p = n, f = {}, b = 0; for (let v = 0; v < a.length; v++) { const { name: g, fn: $ } = a[v], { x: y, y: _, data: w, reset: A } = await $({ x: d, y: u, initialPlacement: n, placement: p, strategy: s, middlewareData: f, rects: c, platform: r, elements: { reference: i, floating: t } }); d = y ?? d, u = _ ?? u, f = { ...f, [g]: { ...f[g], ...w } }, A && b <= 50 && (b++, typeof A == "object" && (A.placement && (p = A.placement), A.rects && (c = A.rects === !0 ? await r.getElementRects({ reference: i, floating: t, strategy: s }) : A.rects), { x: d, y: u } = Gn(c, p, l)), v = -1); } return { x: d, y: u, placement: p, strategy: s, middlewareData: f }; }; async function Gs(i, t) { var e; t === void 0 && (t = {}); const { x: n, y: s, platform: o, rects: r, elements: a, strategy: l } = i, { boundary: c = "clippingAncestors", rootBoundary: d = "viewport", elementContext: u = "floating", altBoundary: p = !1, padding: f = 0 } = je(t, i), b = Ws(f), v = a[p ? u === "floating" ? "reference" : "floating" : u], g = ee(await o.getClippingRect({ element: (e = await (o.isElement == null ? void 0 : o.isElement(v))) == null || e ? v : v.contextElement || await (o.getDocumentElement == null ? void 0 : o.getDocumentElement(a.floating)), boundary: c, rootBoundary: d, strategy: l })), $ = u === "floating" ? { x: n, y: s, width: r.floating.width, height: r.floating.height } : r.reference, y = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(a.floating)), _ = await (o.isElement == null ? void 0 : o.isElement(y)) ? await (o.getScale == null ? void 0 : o.getScale(y)) || { x: 1, y: 1 } : { x: 1, y: 1 }, w = ee(o.convertOffsetParentRelativeRectToViewportRelativeRect ? await o.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: a, rect: $, offsetParent: y, strategy: l }) : $); return { top: (g.top - w.top + b.top) / _.y, bottom: (w.bottom - g.bottom + b.bottom) / _.y, left: (g.left - w.left + b.left) / _.x, right: (w.right - g.right + b.right) / _.x }; } const Na = function(i) { return i === void 0 && (i = {}), { name: "flip", options: i, async fn(t) { var e, n; const { placement: s, middlewareData: o, rects: r, initialPlacement: a, platform: l, elements: c } = t, { mainAxis: d = !0, crossAxis: u = !0, fallbackPlacements: p, fallbackStrategy: f = "bestFit", fallbackAxisSideDirection: b = "none", flipAlignment: v = !0, ...g } = je(i, t); if ((e = o.arrow) != null && e.alignmentOffset) return {}; const $ = gt(s), y =