;(function (c, h) {
  typeof exports == 'object' && typeof module < 'u'
    ? h(exports)
    : typeof define == 'function' && define.amd
    ? define(['exports'], h)
    : ((c = typeof globalThis < 'u' ? globalThis : c || self),
      h((c.viverse = {})))
})(this, function (c) {
  'use strict'
  var me = Object.defineProperty
  var pe = (c, h, f) =>
    h in c
      ? me(c, h, { enumerable: !0, configurable: !0, writable: !0, value: f })
      : (c[h] = f)
  var s = (c, h, f) => (pe(c, typeof h != 'symbol' ? h + '' : h, f), f)
  const h = (r) => {
      r.indexOf('#') > -1 && (r = r.substring(0, r.indexOf('#')))
      const e = new URLSearchParams(r)
      return { state: e.get('state'), code: e.get('code') || void 0 }
    },
    f = () => {
      if (typeof window > 'u') return
      const r = window.location.search.substring(1),
        e = new URLSearchParams(r)
      e.delete('code'), e.delete('state'), e.delete('api_url')
      const t = `${window.location.origin}${window.location.pathname}${
        e.size > 0 ? `?${e.toString()}` : ''
      }`
      window.history.replaceState({}, document.title, t)
    },
    v = () => window.crypto,
    S = () => {
      const r =
        '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.'
      let e = ''
      return (
        Array.from(v().getRandomValues(new Uint8Array(43))).forEach(
          (a) => (e += r[a % r.length])
        ),
        e
      )
    },
    A = (r) => btoa(r),
    P = (r) => atob(r),
    K = (r) =>
      Object.keys(r)
        .filter((e) => typeof r[e] < 'u')
        .reduce((e, t) => ({ ...e, [t]: r[t] }), {}),
    _ = ({ ...r }) => new URLSearchParams(K({ ...r })).toString(),
    M = async (r) =>
      await v().subtle.digest({ name: 'SHA-256' }, new TextEncoder().encode(r)),
    D = (r) => {
      const e = { '+': '-', '/': '_', '=': '' }
      return r.replace(/[+/=]/g, (t) => e[t])
    },
    R = (r) => {
      const e = new Uint8Array(r)
      return D(window.btoa(String.fromCharCode(...Array.from(e))))
    },
    x = () => {
      if (!v())
        throw new Error('For security reasons, `window.crypto` is required.')
      if (typeof v().subtle > 'u')
        throw new Error('window.crypto.subtle must run on a secure origin.')
    },
    L = (r) => (/^https?:\/\//.test(r) ? r : `https://${r}`),
    $ = (r) => Array.from(new Set(r)),
    O = (...r) => $(r.filter(Boolean).join(' ').trim().split(/\s+/)).join(' '),
    j = (r, e, t, a, n, i) => ({
      client_id: r.clientId,
      state: e,
      scope: t,
      response_type: 'code',
      redirection_url: a,
      authorities: n,
      code_challenge: i,
      code_challenge_method: 'S256',
    })
  function z(r) {
    return new Promise((e, t) => {
      const a = document.createElement('script')
      ;(a.type = 'text/javascript'),
        (a.async = !0),
        (a.src = r),
        (a.onload = () => e()),
        (a.onerror = () => t(new Error(`Script load error for ${r}`))),
        document.body.appendChild(a)
    })
  }
  function C(r, e, t, a = 0) {
    return (
      (a += 1),
      new Promise((n, i) => {
        r[e] === t
          ? n(t)
          : a >= 300
          ? i()
          : setTimeout(async () => {
              await C(r, e, t, a)
                .then((o) => n(o))
                .catch(() => i())
            }, 100)
      })
    )
  }
  var y =
    (globalThis && globalThis.__assign) ||
    function () {
      return (
        (y =
          Object.assign ||
          function (r) {
            for (var e, t = 1, a = arguments.length; t < a; t++) {
              e = arguments[t]
              for (var n in e)
                Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n])
            }
            return r
          }),
        y.apply(this, arguments)
      )
    }
  function g(r, e) {
    if (!e) return ''
    var t = '; ' + r
    return e === !0 ? t : t + '=' + e
  }
  function F(r) {
    if (typeof r.expires == 'number') {
      var e = new Date()
      e.setMilliseconds(e.getMilliseconds() + r.expires * 864e5),
        (r.expires = e)
    }
    return (
      g('Expires', r.expires ? r.expires.toUTCString() : '') +
      g('Domain', r.domain) +
      g('Path', r.path) +
      g('Secure', r.secure) +
      g('SameSite', r.sameSite)
    )
  }
  function N(r, e, t) {
    return (
      encodeURIComponent(r)
        .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
        .replace(/\(/g, '%28')
        .replace(/\)/g, '%29') +
      '=' +
      encodeURIComponent(e).replace(
        /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
        decodeURIComponent
      ) +
      F(t)
    )
  }
  function B(r) {
    for (
      var e = {}, t = r ? r.split('; ') : [], a = 0, n = t;
      a < n.length;
      a++
    ) {
      var i = n[a],
        o = i.split('='),
        l = o.slice(1).join('=')
      l[0] === '"' && (l = l.slice(1, -1))
      try {
        var u = decodeURIComponent(o[0])
        e[u] = l.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent)
      } catch {}
    }
    return e
  }
  function G() {
    return B(document.cookie)
  }
  function V(r) {
    return G()[r]
  }
  function b(r, e, t) {
    document.cookie = N(r, e, y({ path: '/' }, t))
  }
  function q(r, e) {
    b(r, '', y(y({}, e), { expires: -1 }))
  }
  const J = {
      get(r) {
        const e = V(r)
        if (!(typeof e > 'u')) return JSON.parse(e)
      },
      save(r, e, t) {
        let a = {}
        window.location.protocol === 'https:' &&
          (a = { secure: !0, sameSite: 'lax' }),
          t != null && t.daysUntilExpire && (a.expires = t.daysUntilExpire),
          t != null && t.cookieDomain && (a.domain = t.cookieDomain),
          b(r, JSON.stringify(e), a)
      },
      remove(r, e) {
        let t = {}
        e != null && e.cookieDomain && (t.domain = e.cookieDomain), q(r, t)
      },
    },
    H = {
      get(r) {
        if (typeof sessionStorage > 'u') return
        const e = sessionStorage.getItem(r)
        if (e != null) return JSON.parse(e)
      },
      save(r, e) {
        sessionStorage.setItem(r, JSON.stringify(e))
      },
      remove(r) {
        sessionStorage.removeItem(r)
      },
    },
    W = 'viverse-client/tx'
  class Y {
    constructor(e, t, a) {
      s(this, 'storageKey')
      ;(this.storage = e),
        (this.clientId = t),
        (this.cookieDomain = a),
        (this.storageKey = `${W}/${this.clientId}`)
    }
    create(e) {
      this.storage.save(this.storageKey, e, {
        daysUntilExpire: 1,
        cookieDomain: this.cookieDomain,
      })
    }
    get() {
      return this.storage.get(this.storageKey)
    }
    remove() {
      this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain })
    }
  }
  const k = '@viverse'
  class d {
    constructor(e, t = k, a) {
      s(this, 'clientId')
      s(this, 'scope')
      ;(this.prefix = t),
        (this.suffix = a),
        (this.clientId = e.clientId),
        (this.scope = e.scope)
    }
    toKey() {
      return [this.prefix, this.clientId, this.scope, this.suffix]
        .filter(Boolean)
        .join('::')
    }
    static fromKey(e) {
      const [t, a, n] = e.split('::')
      return new d({ clientId: a, scope: n }, t)
    }
    static fromCacheEntry(e) {
      const { scope: t, client_id: a } = e
      return new d({ scope: t, clientId: a })
    }
  }
  const X = 0
  class Q {
    constructor(e, t, a) {
      s(this, 'nowProvider')
      ;(this.cache = e),
        (this.keyManifest = t),
        (this.nowProvider = a || (() => Date.now()))
    }
    async get(e, t = X) {
      var o
      let a = await this.cache.get(e.toKey())
      if (!a) {
        const l = await this.getCacheKeys()
        if (!l) return
        const u = this.matchExistingCacheKey(e, l)
        u && (a = await this.cache.get(u))
      }
      if (!a) return
      const n = await this.nowProvider(),
        i = Math.floor(n / 1e3)
      if (a.expiresAt - t < i) {
        if (a.body.refresh_token)
          return (
            (a.body = { refresh_token: a.body.refresh_token }),
            await this.cache.set(e.toKey(), a),
            a.body
          )
        await this.cache.remove(e.toKey()),
          await ((o = this.keyManifest) == null ? void 0 : o.remove(e.toKey()))
        return
      }
      return a.body
    }
    async set(e) {
      var n
      const t = new d({ clientId: e.client_id, scope: e.scope }),
        a = await this.wrapCacheEntry(e)
      await this.cache.set(t.toKey(), a),
        await ((n = this.keyManifest) == null ? void 0 : n.add(t.toKey()))
    }
    async clear(e) {
      var a
      const t = await this.getCacheKeys()
      t &&
        (await t
          .filter((n) => (e ? n.includes(e) : !0))
          .reduce(async (n, i) => {
            await n, await this.cache.remove(i)
          }, Promise.resolve()),
        await ((a = this.keyManifest) == null ? void 0 : a.clear()))
    }
    async wrapCacheEntry(e) {
      const t = await this.nowProvider(),
        a = Math.floor(t / 1e3) + e.expires_in
      return { body: e, expiresAt: a }
    }
    async getCacheKeys() {
      var e
      if (this.keyManifest)
        return (e = await this.keyManifest.get()) == null ? void 0 : e.keys
      if (this.cache.allKeys) return this.cache.allKeys()
    }
    matchExistingCacheKey(e, t) {
      return t.filter((a) => {
        var u
        const n = d.fromKey(a),
          i = new Set(n.scope && n.scope.split(' ')),
          o = ((u = e.scope) == null ? void 0 : u.split(' ')) || [],
          l = n.scope && o.reduce((p, U) => p && i.has(U), !0)
        return n.prefix === k && n.clientId === e.clientId && l
      })[0]
    }
  }
  class Z {
    constructor(e, t) {
      s(this, 'manifestKey')
      ;(this.cache = e),
        (this.clientId = t),
        (this.manifestKey = this.createManifestKeyFrom(this.clientId))
    }
    async add(e) {
      var a
      const t = new Set(
        ((a = await this.cache.get(this.manifestKey)) == null
          ? void 0
          : a.keys) || []
      )
      t.add(e), await this.cache.set(this.manifestKey, { keys: [...t] })
    }
    async remove(e) {
      const t = await this.cache.get(this.manifestKey)
      if (t) {
        const a = new Set(t.keys)
        return (
          a.delete(e),
          a.size > 0
            ? await this.cache.set(this.manifestKey, { keys: [...a] })
            : await this.cache.remove(this.manifestKey)
        )
      }
    }
    get() {
      return this.cache.get(this.manifestKey)
    }
    clear() {
      return this.cache.remove(this.manifestKey)
    }
    createManifestKeyFrom(e) {
      return `${k}::${e}`
    }
  }
  class ee {
    constructor() {
      s(
        this,
        'enclosedCache',
        (function () {
          let e = {}
          return {
            set(t, a) {
              e[t] = a
            },
            get(t) {
              const a = e[t]
              if (a) return a
            },
            remove(t) {
              delete e[t]
            },
            allKeys() {
              return Object.keys(e)
            },
          }
        })()
      )
    }
  }
  const te = 3,
    I = 1e4
  class m extends Error {
    constructor(e, t) {
      super(t),
        (this.error = e),
        (this.error_description = t),
        Object.setPrototypeOf(this, m.prototype)
    }
    static fromPayload({ error: e, error_description: t }) {
      return new m(e, t)
    }
  }
  class T extends m {
    constructor() {
      super('missing_refresh_token', 'Missing Refresh Token'),
        Object.setPrototypeOf(this, T.prototype)
    }
  }
  const re = () => new AbortController(),
    ae = async (r, e) => {
      const t = await fetch(r, e)
      return { ok: t.ok, json: await t.json() }
    },
    ne = async (r, e, t) => {
      const a = re()
      e.signal = a.signal
      let n
      return Promise.race([
        ae(r, e),
        new Promise((i, o) => {
          n = setTimeout(() => {
            a.abort(), o(new Error("Timeout when executing 'fetch'"))
          }, t)
        }),
      ]).finally(() => {
        clearTimeout(n)
      })
    },
    ie = async (r, e, t = I) => ne(r, e, t)
  async function w(r, e, t) {
    let a = null,
      n
    for (let p = 0; p < te; p++)
      try {
        ;(n = await ie(r, t, e)), (a = null)
        break
      } catch (U) {
        a = U
      }
    if (a) throw a
    const {
      json: { error: i, error_description: o, ...l },
      ok: u,
    } = n
    if (!u) {
      const p = o || `HTTP error. Unable to fetch ${r}`
      throw i === 'missing_refresh_token'
        ? new T()
        : new m(i || 'request_error', p)
    }
    return l
  }
  async function oe({ baseUrl: r, timeout: e, scope: t, ...a }) {
    const n = _(a)
    return await w(`${r}/SS/api/oauth/v1/vendor/token/authorization-code`, e, {
      method: 'POST',
      body: n,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    })
  }
  async function se({ baseUrl: r, timeout: e, scope: t, ...a }) {
    const n = _(a)
    return await w(`${r}/SS/api/oauth/v1/vendor/token/refresh-token`, e, {
      method: 'POST',
      body: n,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    })
  }
  const ce = 'email'
  class he {
    constructor(e) {
      s(this, 'transactionManager')
      s(this, 'cacheManager')
      s(this, 'cookieStorage')
      s(this, 'nowProvider', () => Date.now())
      s(this, 'httpTimeoutMs')
      s(this, 'domainUrl')
      s(this, 'scope')
      s(this, 'authorities')
      s(this, 'tokenCookieName')
      s(this, 'options')
      ;(this.options = {
        ...e,
        authorizationParams: { ...e.authorizationParams },
      }),
        typeof window < 'u' && x()
      let t = new ee().enclosedCache
      ;(this.httpTimeoutMs = e.httpTimeoutInMS ?? I),
        (this.domainUrl = L(this.options.domain)),
        (this.scope = O(this.options.authorizationParams.scope || ce)),
        (this.tokenCookieName = `.viverse.${this.options.clientId}.token`),
        (this.cookieStorage = J),
        (this.transactionManager = new Y(
          H,
          this.options.clientId,
          this.options.domain
        )),
        (this.cacheManager = new Q(
          t,
          t.allKeys ? void 0 : new Z(t, this.options.clientId),
          this.nowProvider
        )),
        (this.authorities =
          this.options.authorizationParams.authorities ??
          'htc.com metamask.com walletconnect.com google.com steam.com'),
        this._initializeCache()
    }
    async _initializeCache() {
      const e = this.cookieStorage.get(this.tokenCookieName)
      e && (await this.cacheManager.set(e))
    }
    _url(e) {
      return `${this.domainUrl}${e}`
    }
    _authorizeUrl(e) {
      return this._url(`/SS/Services/OAuth/Authorize?${_(e)}`)
    }
    async _prepareAuthorizeUrl(e) {
      const t = e.state ? A(e.state) : A(S()),
        a = S(),
        n = await M(a),
        i = R(n),
        o = j(
          this.options,
          t,
          this.scope,
          e.redirectionUrl ||
            `${window.location.origin}${window.location.pathname}`,
          this.authorities,
          i
        ),
        l = this._authorizeUrl(o)
      return {
        state: t,
        scope: o.scope,
        redirection_url: o.redirection_url,
        code_verifier: a,
        url: l,
      }
    }
    async _saveEntryInCache(e) {
      await this.cacheManager.set(e),
        this.cookieStorage.save(this.tokenCookieName, e, {
          daysUntilExpire: e.expires_in / 86400,
          cookieDomain: this.options.cookieDomain,
        })
    }
    async _requestToken(e) {
      const t = await oe({
        baseUrl: this.domainUrl,
        client_id: this.options.clientId,
        timeout: this.httpTimeoutMs,
        ...e,
      })
      return (
        await this._saveEntryInCache({
          ...t,
          scope: e.scope,
          client_id: this.options.clientId,
        }),
        t
      )
    }
    async _requestTokenViaRefreshToken(e) {
      const t = await se({
        baseUrl: this.domainUrl,
        client_id: this.options.clientId,
        timeout: this.httpTimeoutMs,
        ...e,
      })
      return (
        await this._saveEntryInCache({
          ...t,
          scope: e.scopes,
          client_id: this.options.clientId,
        }),
        t
      )
    }
    async loginWithRedirect(e = {}) {
      const { url: t, ...a } = await this._prepareAuthorizeUrl(e)
      this.transactionManager.create({ ...a }),
        e.openUrl ? await e.openUrl(t) : window.location.assign(t)
    }
    async handleRedirectCallback(e = window.location.href) {
      const t = e.split('?').slice(1)
      if (t.length === 0)
        throw new Error('There are no query params available for parsing.')
      const { state: a, code: n } = h(t.join('')),
        i = this.transactionManager.get()
      if (!i) throw new m('missing_transaction', 'Invalid state')
      if (
        (this.transactionManager.remove(),
        f(),
        !i.code_verifier || (i.state && i.state !== a))
      )
        throw new m('state_mismatch', 'Invalid state')
      const o = await this._requestToken({
        scope: i.scope,
        code_verifier: i.code_verifier,
        grant_type: 'authorization_code',
        code: n,
      })
      return {
        state: P(a),
        access_token: o.access_token,
        account_id: o.account_id,
        expire_in: o.expires_in,
      }
    }
    async getToken(e = {}) {
      const t = await this._getEntryFromCache({
        scope: this.scope,
        clientId: this.options.clientId,
      })
      if (t != null && t.access_token)
        return e.detailedResponse ? t : t.access_token
      const a = await this.cacheManager.get(
        new d({ scope: this.scope, clientId: this.options.clientId })
      )
      if (a != null && a.refresh_token)
        return await this.getTokenViaRefreshToken(e)
    }
    async getTokenViaRefreshToken(e = {}) {
      const t = await this.cacheManager.get(
        new d({ scope: this.scope, clientId: this.options.clientId })
      )
      if (t != null && t.refresh_token) {
        const {
          access_token: a,
          account_id: n,
          expires_in: i,
        } = await this._requestTokenViaRefreshToken({
          grant_type: 'refresh_token',
          refresh_token: t.refresh_token,
          scopes: t.scope || this.scope,
        })
        return e.detailedResponse
          ? { access_token: a, account_id: n, expires_in: i }
          : a
      }
    }
    _buildLogoutUrl(e) {
      return this._url(
        `/logout?${_({
          client_id: this.options.clientId,
          redirect_url: e.redirectionUrl,
        })}`
      )
    }
    async logout(e) {
      const { openUrl: t, ...a } = e
      await this.cacheManager.clear(this.options.clientId),
        this.cookieStorage.remove(this.tokenCookieName, {
          cookieDomain: this.options.cookieDomain,
        })
      const n = this._buildLogoutUrl(a)
      t ? await t(n) : window.location.assign(n)
    }
    async _getEntryFromCache({ scope: e, clientId: t }) {
      const a = await this.cacheManager.get(
        new d({ scope: e, clientId: t }),
        60
      )
      if (a) {
        const { access_token: n, account_id: i, expires_in: o } = a
        return { access_token: n, account_id: i, expires_in: o }
      }
    }
  }
  async function le({ baseUrl: r, timeout: e, token: t }) {
    return await w(`${r}api/meetingareaselector/v2/newgenavatar/sdk/me`, e, {
      method: 'GET',
      headers: { 'Content-Type': 'application/json', AccessToken: t },
    })
  }
  async function E({ baseUrl: r, timeout: e, token: t }) {
    return await w(
      `${r}api/meetingareaselector/v1/newgenavatar/getavatarlist`,
      e,
      {
        method: 'GET',
        headers: { 'Content-Type': 'application/json', AccessToken: t },
      }
    )
  }
  async function ue({ baseUrl: r, timeout: e }) {
    return await w(`${r}items/publicAvatar`, e, {
      method: 'GET',
      headers: { 'Content-Type': 'application/json' },
    })
  }
  async function de({ baseUrl: r, timeout: e, avatarID: t }) {
    return await w(`${r}items/publicAvatar/${t}`, e, {
      method: 'GET',
      headers: { 'Content-Type': 'application/json' },
    })
  }
  class fe {
    constructor(e) {
      s(
        this,
        'avatarSDKUrl',
        'https://avatar.viverse.com/static-misc/avatar-js-sdk/1.1.1/Avatar-SDK.js'
      )
      s(this, 'baseURL')
      s(this, 'token')
      s(this, 'anonymousAvatarSDK')
      s(this, 'scriptLoading', !1)
      ;(this.baseURL = e.baseURL),
        (this.token = e.token || null),
        this._initializeAvatar()
    }
    async _initializeAvatar() {
      globalThis.newViveAvatarSdk ||
        ((this.scriptLoading = !0),
        await z(this.avatarSDKUrl),
        (this.scriptLoading = !1)),
        (this.anonymousAvatarSDK = globalThis.newViveAvatarSdk(
          {
            workerMinimum: 1,
            workerMaximum: Math.max(
              1,
              window.navigator.hardwareConcurrency - 1
            ),
          },
          this.avatarSDKUrl
        ))
    }
    async getProfile() {
      if (!this.token)
        throw Error('This API is only available to logged-in users.')
      const [e, t] = await Promise.all([
        this._getMe(this.token),
        this.getActiveAvatar(),
      ])
      return { name: (e == null ? void 0 : e.Name) || '', activeAvatar: t }
    }
    async _getMe(e) {
      try {
        const { data: t } = await le({ baseUrl: this.baseURL, token: e })
        return t
      } catch (t) {
        return console.error('Get me error:', t), null
      }
    }
    async getAvatarList() {
      if (!this.token)
        throw Error('This API is only available to logged-in users.')
      return await E({ baseUrl: this.baseURL, token: this.token })
        .then(({ data: t }) => t.Avatars ?? [])
        .then((t) => t.map(this._formatPrivateAvatar))
        .catch((t) => (console.error('Get avatar list error:', t), []))
    }
    async getActiveAvatar() {
      if (!this.token)
        throw Error('This API is only available to logged-in users.')
      return await E({ baseUrl: this.baseURL, token: this.token })
        .then(({ data: t }) => {
          if (!t.CurrentAvatarId || !t.Avatars) return null
          const a = t.Avatars.find((n) => n.id === t.CurrentAvatarId)
          return a ? this._formatPrivateAvatar(a) : null
        })
        .catch((t) => (console.error('Get avatar list error:', t), null))
    }
    async getPublicAvatarList() {
      try {
        const { data: e } = await ue({ baseUrl: this.baseURL })
        return e.map((t) =>
          this._formatPublicAvatar(this._parsePublicAvatarUrl(t))
        )
      } catch (e) {
        return console.error('Get public avatar list error:', e), []
      }
    }
    async getPublicAvatarByID(e) {
      try {
        const { data: t } = await de({ baseUrl: this.baseURL, avatarID: e })
        return this._formatPublicAvatar(this._parsePublicAvatarUrl(t))
      } catch (t) {
        return console.error('Get public avatar error:', t), null
      }
    }
    _formatPrivateAvatar(e) {
      return {
        id: e.id || '',
        isPrivate: !0,
        vrmUrl: e.VrmBinaryDataUrl || '',
        headIconUrl: e.HeadIconDataUrl || '',
        snapshot: e.SnapshotDataUrl || '',
        createTime: e.CreateTime * 1e3 || 0,
        updateTime: e.UpdateTime * 1e3 || 0,
      }
    }
    _formatPublicAvatar(e) {
      return {
        id: e.id || 0,
        isPrivate: !1,
        vrmUrl: e.model,
        headIconUrl: e.head_icon,
        snapshot: e.snapshot,
        createTime: new Date(e.date_created).getTime(),
        updateTime: e.date_updated
          ? new Date(e.date_updated).getTime()
          : new Date(e.date_created).getTime(),
      }
    }
    _parsePublicAvatarUrl(e) {
      return {
        ...e,
        head_icon: `${this.baseURL}assets/${e.head_icon}`,
        model: `${this.baseURL}assets/${e.model}`,
        snapshot: `${this.baseURL}assets/${e.snapshot}`,
      }
    }
    async getAvatarFileWithSDK(e) {
      return typeof (await C(this, 'scriptLoading', !1)) > 'u'
        ? (console.error('avatar SDK script loading error'), null)
        : (this.anonymousAvatarSDK || (await this._initializeAvatar()),
          await this.anonymousAvatarSDK
            .viaWorker({
              action: 'downloadAndDecrypt',
              params: { modelUrl: e },
            })
            .then((n) => n.arrayBuffer)
            .catch(
              (n) => (
                console.error('Get avatar file via worker error: ', n), null
              )
            ))
    }
  }
  ;(c.avatar = fe),
    (c.client = he),
    Object.defineProperty(c, Symbol.toStringTag, { value: 'Module' })
})
