
/**
 *   WARNING: This file is intended to be used within MySheerID.
 *   This file is not intended for use in other contexts and there are no guarantees about its behavior outside of MySheerID.
 */ 
/**
 *   VERSION: 2.239.0-alpha.0
 *   BUILD_TIMESTAMP: 1780013005605
 *   BUILD_DATE: Fri May 29 2026 00:03:25 GMT+0000 (Coordinated Universal Time)
 *   BUILD_COMMIT: 3344b6c0fd9fa858907db310cfb1ef5e0d224da2
 */
var a = Object.defineProperty, d = (n, e, t) => e in n ? a(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, i = (n, e, t) => (d(n, typeof e != "symbol" ? e + "" : e, t), t);
class h {
  constructor() {
    this.eventListener = {};
  }
  addEventListener(e, t) {
    return this.eventListener[e] = this.eventListener[e] || [], this.eventListener[e].push(t), this;
  }
  removeEventListener(e, t) {
    const r = this.eventListener[e];
    if (r) {
      let s;
      for (; (s = r.indexOf(t)) !== -1; )
        r.splice(s, 1);
    }
  }
  trigger(e, t) {
    (this.eventListener[e] || []).forEach((r) => {
      r(t);
    });
  }
}
const l = "v14";
class v extends h {
  constructor() {
    super(...arguments), i(this, "_handle"), i(this, "_handleSetCallbacks", []);
  }
  _setHandle(e) {
    this._handle = e, this._handleSetCallbacks.forEach((t) => t(e)), this._handleSetCallbacks = [], Object.entries(this.eventListener).forEach(([t, r]) => {
      e.addEventListener(t, r);
    }), this.eventListener = {};
  }
  addEventListener(e, t) {
    return this._handle ? (this._handle.addEventListener(e, t), this) : super.addEventListener(e, t);
  }
  removeEventListener(e, t) {
    if (this._handle)
      return this._handle.removeEventListener(e, t), this;
    super.removeEventListener(e, t);
  }
  async tearDown() {
    var e;
    if (this._handle)
      await ((e = this._handle) == null ? void 0 : e.tearDown());
    else
      return this._handleSetCallbacks.push(() => {
        this.tearDown();
      }), Promise.resolve();
  }
  get version() {
    var e;
    return (e = this._handle) == null ? void 0 : e.version;
  }
}
const c = (n) => `v${(n || l).replace(/^v/, "")}`, o = {
  init(n) {
    const e = new v();
    return import(
      /* webpackIgnore: true */
      /* @vite-ignore */
      n.sdkUrl || `https://sdk.onfido.com/${c(n.version)}/Onfido.js`
    ).then((t) => {
      const { Onfido: r } = t;
      e._setHandle(r.init(n));
    }).catch((t) => {
      var r;
      e.trigger("error", { error: t }), (r = n.onError) == null || r.call(n, t);
    }), e;
  }
};
Object.defineProperty(o, "environment", {
  get: () => window?.Onfido.environment,
  set: (n) => {
    window.Onfido = window.Onfido || {}, window.Onfido.environment = n;
  }
});
const u = o;
export {
  u as Onfido,
  c as prefixVersion
};
