/** crash-loader version: __VERSION__ */

// libs/games/crash/loader/src/lib/crash-loader.ts
var SqLoader = class {
};
var currentScript = document.currentScript;
var SqCrashLoader = class extends SqLoader {
  constructor(config) {
    super();
    this.config = config;
  }
  /**
   * init
   * @returns Promise<SqCrashLoader>
   */
  async init() {
    const iframe = document.createElement("iframe");
    iframe.src = await this.createIframeUrl(this.config);
    iframe.id = "crash-loader";
    this.config.container.appendChild(iframe);
    return this;
  }
  async createIframeUrl(config) {
    const host = this.getHost();
    const params = (config.serverUrl ? `&serverUrl=${config.serverUrl}` : "") + (config.spServerUrl ? `&spServerUrl=${config.spServerUrl}` : "") + (config.i18nUrl ? `&i18nUrl=${config.i18nUrl}` : "") + (config.provisioningUrl ? `&provisioningUrl=${config.provisioningUrl}` : "") + (config.rulesPath ? `&rulesPath=${config.rulesPath}` : "") + (config.language ? `&language=${config.language}` : "") + (config.domain ? `&domain=${config.domain}` : "") + (config.user ? `&user=${config.user}` : "") + (config.password ? `&password=${config.password}` : "") + (config.hardwareId ? `&hwId=${config.hardwareId}` : "") + (config.onlineHash ? `&onlineHash=${config.onlineHash}` : "") + (config.playlistId ? `&playlistIds=${config.playlistId}` : "");
    return `${host}/?${params.substring(1)}`;
  }
  getHost() {
    let urlString = null;
    if (currentScript) {
      urlString = currentScript.src;
    } else {
      urlString = import.meta.url;
    }
    if (urlString) {
      const hostUrl = new URL(urlString);
      return `${hostUrl.origin}${hostUrl.pathname.split("/").slice(0, -1).join("/")}`.replace("spinmatic-crash", "iframe");
    } else {
      throw new Error("ERROR: Unable to get currentScriptUrl to get the front end url");
    }
  }
};
export {
  SqCrashLoader,
  SqLoader
};
//# sourceMappingURL=loader.mjs.map
