import { defineComponent as O, ref as $, computed as R, watch as d, createElementBlock as g, openBlock as m, normalizeClass as j, unref as a, renderSlot as s, createCommentVNode as q, normalizeProps as v, guardReactiveProps as y, normalizeStyle as N, Fragment as D, renderList as H, createVNode as J } from "vue";
import { usePdfViewer as M } from "../index.js";
import { _ as W } from "./DoojyiWY.js";
const T = /* @__PURE__ */ O({
  __name: "vPdfViewer",
  props: {
    pdf: {
      type: Object,
      required: !0
    },
    scale: {
      type: Number,
      default: 1
    },
    scaling: {
      type: Number,
      default: 1
    },
    gap: {
      type: Number,
      default: 10
    },
    rotation: {
      type: Number,
      default: 0,
      validator: (t) => {
        const l = t % 90 == 0;
        if (!l)
          throw new Error(`Rotation must be a multiple of 90, ${t} given.`);
        return l;
      }
    },
    view: {
      type: String,
      default: "vertical"
    },
    page: {
      type: Number,
      default: 1
    },
    textLayer: {
      type: Boolean,
      default: !1
    },
    smoothJump: {
      type: Boolean,
      default: !1
    },
    renderDelay: {
      type: Number,
      default: 50
    },
    renderOffset: {
      type: Number,
      default: 256
    },
    onProgress: {
      type: Function,
      default: () => {
      }
    }
  },
  emits: ["update:page", "update:scale", "progress"],
  setup(t, { expose: l, emit: B }) {
    const i = t, p = B, h = $(), n = $(1), o = R(() => ({
      numPages: k,
      progress: b,
      pages: I,
      container: f,
      currentPage: w,
      visiblePages: c,
      render: u,
      viewMode: x,
      changePage: z,
      nextPage: L,
      prevPage: V,
      fitWidth: C,
      fitHeight: S,
      fitPage: E
    })), {
      totalPage: k,
      pageInfo: I,
      containerBounds: f,
      progress: b,
      render: u,
      currentPage: w,
      visiblePages: c,
      scale: P,
      viewMode: x,
      nextPage: L,
      prevPage: V,
      changePage: z,
      fitWidth: C,
      fitHeight: S,
      fitPage: E
    } = M(h, i);
    return d(b, (e) => {
      i.onProgress(e), p("progress", e);
    }), d(w, (e) => {
      p("update:page", e);
    }), d(P, (e) => {
      p("update:scale", e);
    }), d([() => P.value, () => i.scaling], (e) => {
    }), l(o.value), (e, A) => (m(), g("div", {
      ref_key: "container",
      ref: h,
      class: j(["vpdf:relative vpdf:grid vpdf:h-full vpdf:min-h-0 vpdf:w-full vpdf:min-w-0 vpdf:items-center vpdf:overflow-scroll vpdf:bg-foreground/15", {
        "vpdf:grid vpdf:items-center": a(x) != "vertical"
      }])
    }, [
      s(e.$slots, "prepend", v(y(o.value))),
      t.pdf ? (m(), g("div", {
        key: 0,
        class: "vpdf:relative vpdf:mx-auto",
        style: N({
          width: `${a(f).width * n.value}px`,
          height: `${a(f).height * n.value}px`
        })
      }, [
        s(e.$slots, "default", v(y(o.value)), () => [
          (m(!0), g(D, null, H(a(c), (r) => s(e.$slots, "renderer", {
            key: r.id,
            pdf: t.pdf,
            pageInfo: r,
            render: a(u)
          }, () => [
            J(W, {
              pdf: t.pdf,
              pageInfo: r,
              scale: 0.5,
              textLayer: t.textLayer,
              render: a(u),
              visible: a(c).findIndex((F) => F.page == r.page) > -1,
              class: "vpdf:absolute",
              style: N({
                top: `${r.bounds.inner.top * n.value}px`,
                left: `${r.bounds.inner.left * n.value}px`,
                width: `${r.viewport.width * n.value}px`,
                height: `${r.viewport.height * n.value}px`
              })
            }, null, 8, ["pdf", "pageInfo", "textLayer", "render", "visible", "style"])
          ])), 128))
        ])
      ], 4)) : q("", !0),
      s(e.$slots, "append", v(y(o.value)))
    ], 2));
  }
});
export {
  T as _
};
