const y = /-(\w)/g, m = (t) => t.replace(y, (e, s) => s ? s.toUpperCase() : ""), z = /\B([A-Z])/g, M = (t) => t.replace(z, "-$1").toLowerCase();
function P(t, e) {
  const s = {};
  return t.forEach((i) => {
    s[i] = e[i];
  }), s;
}
function $(t, e, s) {
  t[e] = [].concat(t[e] || []), t[e].unshift(s);
}
function N(t, e) {
  t && (t.$options[e] || []).forEach((i) => {
    i.call(t);
  });
}
function j(t, e) {
  return new CustomEvent(t, {
    bubbles: !1,
    cancelable: !1,
    detail: e ? e[0] : void 0
  });
}
const O = (t) => /function Boolean/.test(String(t)), S = (t) => /function Number/.test(String(t));
function T(t, e, { type: s } = {}) {
  if (O(s))
    return t === "true" || t === "false" ? t === "true" : t === "" || t === e || t != null ? !0 : t;
  if (S(s)) {
    const i = parseFloat(t, 10);
    return isNaN(i) ? t : i;
  } else
    return t;
}
function L(t, e) {
  const s = [];
  for (let i = 0, l = e.length; i < l; i++)
    s.push(H(t, e[i]));
  return s;
}
function H(t, e) {
  if (e.nodeType === 3)
    return e.data.trim() ? e.data : null;
  if (e.nodeType === 1) {
    const s = {
      attrs: R(e),
      domProps: {
        innerHTML: e.innerHTML
      }
    };
    return s.attrs.slot && (s.slot = s.attrs.slot, delete s.attrs.slot), t(e.tagName, s);
  } else
    return null;
}
function R(t) {
  const e = {};
  for (let s = 0, i = t.attributes.length; s < i; s++) {
    const l = t.attributes[s];
    e[l.nodeName] = l.nodeValue;
  }
  return e;
}
function V(t, e, s = {}) {
  const i = typeof e == "function" && !e.cid, { disableShadowDom: l = !1, classList: w = [], exposeMethods: _ = [] } = s;
  let h = !1, g, f, E;
  function A(u) {
    if (h) return;
    const r = typeof u == "function" ? u.options : u, c = Array.isArray(r.props) ? r.props : Object.keys(r.props || {});
    g = c.map(M), f = c.map(m);
    const a = Array.isArray(r.props) ? {} : r.props || {};
    E = f.reduce((n, o, p) => (n[o] = a[c[p]], n), {}), $(r, "beforeCreate", function() {
      const n = this.$emit;
      this.$emit = (o, ...p) => (this.$root.$options.customElement.dispatchEvent(j(o, p)), n.call(this, o, ...p));
    }), _.forEach((n) => {
      Object.defineProperty(d.prototype, n, {
        value(...o) {
          return r.methods[n].call(this.vueComponent, ...o);
        }
      });
    }), $(r, "created", function() {
      f.forEach((n) => {
        this.$root.props[n] = this[n];
      });
    }), f.forEach((n) => {
      Object.defineProperty(d.prototype, n, {
        get() {
          return this._wrapper.props[n];
        },
        set(o) {
          this._wrapper.props[n] = o;
        },
        enumerable: !1,
        configurable: !0
      });
    }), h = !0;
  }
  function C(u, r) {
    const c = m(r), a = u.hasAttribute(r) ? u.getAttribute(r) : void 0;
    u._wrapper.props[c] = T(
      a,
      r,
      E[c]
    );
  }
  class d extends HTMLElement {
    constructor() {
      const r = super();
      l || r.attachShadow({ mode: "open" });
      const c = r._wrapper = new t({
        name: l ? "light-dom-root" : "shadow-root",
        customElement: r,
        shadowRoot: r.shadowRoot,
        data() {
          return {
            props: {},
            slotChildren: []
          };
        },
        render(n) {
          return n(e, {
            ref: "inner",
            props: this.props
          }, this.slotChildren);
        }
      });
      new MutationObserver((n) => {
        let o = !1;
        for (let p = 0; p < n.length; p++) {
          const b = n[p];
          h && b.type === "attributes" && b.target === r ? C(r, b.attributeName) : o = !0;
        }
        o && (c.slotChildren = Object.freeze(L(
          c.$createElement,
          r.childNodes
        )));
      }).observe(r, {
        childList: !0,
        subtree: !0,
        characterData: !0,
        attributes: !0
      });
    }
    get vueComponent() {
      return this._wrapper.$refs.inner;
    }
    connectedCallback() {
      w.length > 0 && this.classList.add(...w);
      const r = this._wrapper;
      if (r._isMounted)
        N(this.vueComponent, "activated");
      else {
        const c = () => {
          const a = P(f, this), n = (o) => a[m(o)] === void 0;
          r.props = a, g.filter((o) => this.hasAttribute(o) || n(o)).forEach((o) => {
            C(this, o);
          });
        };
        h ? c() : e().then((a) => {
          (a.__esModule || a[Symbol.toStringTag] === "Module") && (a = a.default), A(a), c();
        }), r.slotChildren = Object.freeze(L(
          r.$createElement,
          this.childNodes
        )), r.$mount(), l ? this.appendChild(r.$el) : this.shadowRoot.appendChild(r.$el);
      }
    }
    disconnectedCallback() {
      N(this.vueComponent, "deactivated");
    }
  }
  return i || A(e), d;
}
export {
  V as w
};
//# sourceMappingURL=vue-wc-wrapper-D3J0j4yW.js.map
