"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
const XEUtils = require("xe-utils");
require("../../ui/index.js");
const util = require("./util.js");
const event = require("../../../../@vxe-ui/core/es/src/event.js");
const VxePrintPageBreakComponent = comp.defineVxeComponent({
  name: "VxePrintPageBreak",
  props: {},
  emits: [],
  setup(props, context) {
    const { slots, emit } = context;
    const xID = XEUtils.uniqueId();
    const $xePrint = vue.inject("$xePrint", null);
    const refElem = vue.ref();
    const reactData = vue.reactive({});
    const refMaps = {
      refElem
    };
    const computeMaps = {};
    const pageBreakConfig = vue.reactive({
      id: xID,
      slots
    });
    const $xePrintPageBreak = {
      xID,
      props,
      context,
      reactData,
      getRefMaps: () => refMaps,
      getComputeMaps: () => computeMaps
    };
    const dispatchEvent = (type, params, evnt) => {
      emit(type, event.createEvent(evnt, { $print: $xePrint }, params));
    };
    const printPageBreakMethods = {
      dispatchEvent
    };
    const printPageBreakPrivateMethods = {};
    Object.assign($xePrintPageBreak, printPageBreakMethods, printPageBreakPrivateMethods);
    if (!$xePrint) {
      $xePrintPageBreak.renderVN = () => {
        return vue.createCommentVNode();
      };
      return $xePrintPageBreak;
    }
    const renderVN = () => {
      return vue.h("div", {
        ref: refElem
      });
    };
    vue.onMounted(() => {
      const elem = refElem.value;
      if ($xePrint && elem) {
        util.assemblePageBreak($xePrint, elem, pageBreakConfig);
      }
    });
    vue.onUnmounted(() => {
      if ($xePrint) {
        util.destroyPageBreak($xePrint, pageBreakConfig);
      }
    });
    $xePrintPageBreak.renderVN = renderVN;
    return $xePrintPageBreak;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxePrintPageBreakComponent;
