"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Vue = require("vue");
const mountComponent = require("../utils/mount-component.js");
const ImagePreview = require("./ImagePreview.js");
const basic = require("../utils/basic.js");
let instance;
const defaultConfig = {
  loop: true,
  images: [],
  maxZoom: 3,
  minZoom: 1 / 3,
  onScale: void 0,
  onClose: void 0,
  onChange: void 0,
  vertical: false,
  teleport: "body",
  className: "",
  showIndex: true,
  closeable: false,
  closeIcon: "clear",
  transition: void 0,
  beforeClose: void 0,
  doubleScale: true,
  overlayStyle: void 0,
  overlayClass: void 0,
  startPosition: 0,
  swipeDuration: 300,
  showIndicators: false,
  closeOnPopstate: true,
  closeOnClickOverlay: true,
  closeIconPosition: "top-right"
};
function initInstance() {
  ({
    instance
  } = mountComponent.mountComponent({
    setup() {
      const {
        state,
        toggle
      } = mountComponent.usePopupState();
      const onClosed = () => {
        state.images = [];
      };
      return () => Vue.createVNode(ImagePreview.default, Vue.mergeProps(state, {
        "onClosed": onClosed,
        "onUpdate:show": toggle
      }), null);
    }
  }));
}
const showImagePreview = (options, startPosition = 0) => {
  if (!basic.inBrowser) {
    return;
  }
  if (!instance) {
    initInstance();
  }
  options = Array.isArray(options) ? {
    images: options,
    startPosition
  } : options;
  instance.open(basic.extend({}, defaultConfig, options));
  return instance;
};
exports.showImagePreview = showImagePreview;
