/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
const u = {
  "top-left": "top-left",
  "top-right": "top-right",
  "bottom-left": "bottom-left",
  "bottom-right": "bottom-right",
  "bottom-leading": "bottom-start",
  "bottom-trailing": "bottom-end",
  "top-leading": "top-start",
  "top-trailing": "top-end"
}, g = ["manual"];
function b(t) {
  t.el.childElem && (t.el.childElem.ownedBy = t.el), t.position && g.includes(t.position) ? t.el.removeAttribute("slot") : t.position && (t.el.slot = u[t.position]);
  const e = h(t);
  if (!e) {
    const i = v(t);
    if (!i) {
      d(t);
      return;
    }
    return f(i, t, !0), i;
  }
  return y(e, t.el.parent) || (t.el.parent = e, e.localName === "arcgis-expand" ? E(e, t) : e.localName === "arcgis-placement" ? p(e, t) : f(e, t, !1)), e;
}
function h({ el: t }) {
  for (let e = t.parentElement; e; e = e?.parentElement ?? null) {
    if (a.has(e.localName))
      return e;
    if ("ownedBy" in e && e.ownedBy instanceof HTMLElement && a.has(e.ownedBy.localName))
      return e.ownedBy;
  }
}
const a = /* @__PURE__ */ new Set([
  "arcgis-map",
  "arcgis-scene",
  "arcgis-link-chart",
  "arcgis-expand",
  "arcgis-placement"
]);
function y(t, e) {
  if (t !== e)
    return !1;
  const i = t.localName;
  return i === "arcgis-expand" || i === "arcgis-placement";
}
function n(t, e, i = "arcgisReady") {
  const r = t;
  if (r.view)
    e(r.view);
  else {
    let s = function(l) {
      l.target === t && (n(t, e, i), t.removeEventListener(i, s));
    };
    t.addEventListener(i, s);
  }
}
const E = (t, e) => n(t, (i) => {
  const r = o(e);
  e.el.shadowRoot ? t.content = e.el : e.el.childElem && t.content != null && r.append(e.el.childElem), e.el.view = i;
}), p = (t, e) => n(t, (i) => {
  const r = o(e);
  e.el.childElem && r.append(e.el.childElem), e.el.view = i;
}), f = (t, e, i) => n(
  t,
  (r) => {
    i && d(e), e.el.view = r, e.referenceElement = t;
  },
  "arcgisViewReadyChange"
);
function C(t) {
  return t == null || t === "";
}
function N(t, e) {
  return e != null && t?.position === e.position && t?.heading === e.heading && t?.tilt === e.tilt && t?.fov === e.fov;
}
function S(t, e) {
  return e === void 0 || t?.targetGeometry !== e?.targetGeometry || t?.rotation !== e?.rotation || t?.scale !== e?.scale;
}
function T(t, e) {
  return c(e?.center, t);
}
function c(t, e) {
  if (typeof e == "string")
    return c(t, e.split(",").map(Number));
  if (!t)
    return e;
  if (Array.isArray(e)) {
    const i = e[0], r = e[1], s = e.length > 2 ? e[2] : void 0;
    if (i !== t.longitude || r !== t.latitude || s !== t.z)
      return e;
  } else if (e && !t?.equals(e))
    return e;
}
function d(t) {
  t.el.childElem && o(t).append(t.el.childElem);
}
function o(t) {
  return t.el.shadowRoot ?? t.el;
}
function v(t, e) {
  const i = t.referenceElement;
  if (typeof i != "string")
    return i ?? void 0;
  const r = i.includes("#") || i.includes(".") || i.includes("["), s = t.el.getRootNode();
  return (r ? void 0 : s.querySelector(`#${i}`)) ?? s.querySelector(i) ?? void 0;
}
const P = (t) => t.el.childElem;
async function R(t) {
  const e = typeof t == "function" ? t() : t;
  e && ("setFocus" in e && typeof e.setFocus == "function" ? await e.setFocus() : e instanceof HTMLElement && e.focus());
}
export {
  b as a,
  N as b,
  T as c,
  C as d,
  P as g,
  S as i,
  c as p,
  R as s
};
