"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var image_studio_opener_loader_exports = {};
__export(image_studio_opener_loader_exports, {
  getImageStudioPackage: () => getImageStudioPackage
});
module.exports = __toCommonJS(image_studio_opener_loader_exports);
function loadScript(src) {
  return new Promise((resolve) => {
    const script = document.createElement("script");
    script.src = src;
    script.onload = resolve;
    document.head.appendChild(script);
  });
}
const IMAGE_STUDIO_OPENER_SRC = (
  // oxlint-disable-next-line max-len
  "https://static.parastorage.com/unpkg/@wix/media-image-studio-opener@3.299.0/dist/statics/MediaImageStudio.bundle.min.js"
);
let mediaImageStudioPackageLoader;
function getImageStudioPackage() {
  if (!mediaImageStudioPackageLoader) {
    disableRequireJS();
    mediaImageStudioPackageLoader = loadScript(IMAGE_STUDIO_OPENER_SRC);
  }
  return mediaImageStudioPackageLoader.then(() => {
    enableRequireJS();
    return window.MediaImageStudio;
  });
}
function disableRequireJS() {
  if (window.requirejs && !window.requirejsBackup) {
    window.requirejsBackup = {
      define: window.define,
      require: window.require,
      requirejs: window.requirejs
    };
    window.define = void 0;
    window.require = void 0;
    window.requirejs = void 0;
  }
}
function enableRequireJS() {
  if (window.requirejsBackup) {
    Object.assign(window, window.requirejsBackup);
    window.requirejsBackup = void 0;
  }
}
//# sourceMappingURL=image-studio-opener-loader.js.map
