"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/worker/index.ts
var index_exports = {};
__export(index_exports, {
  CanvasFactory: () => CanvasFactory,
  getData: () => getData,
  getPath: () => getPath
});
module.exports = __toCommonJS(index_exports);
var import_node_path = __toESM(require("node:path"), 1);
var import_node_url = require("node:url");

// dataurl:/home/runner/work/pdf-parse/pdf-parse/node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs
var pdf_worker_min_default = "data:text/javascript;base64,[encoded data, 1465556 characters]";

// src/worker/canvas.ts
var import_canvas = require("@napi-rs/canvas");
global.DOMMatrix = import_canvas.DOMMatrix;
global.Path2D = import_canvas.Path2D;
global.ImageData = import_canvas.ImageData;
var CanvasFactory = class {
  create(width, height) {
    if (width <= 0 || height <= 0) {
      throw new Error("Invalid canvas size");
    }
    const canvas = (0, import_canvas.createCanvas)(width, height);
    const context = canvas.getContext("2d");
    return { canvas, context };
  }
  reset(canvasAndContext, width, height) {
    if (!canvasAndContext.canvas) {
      throw new Error("Canvas is not specified");
    }
    if (width <= 0 || height <= 0) {
      throw new Error("Invalid canvas size");
    }
    canvasAndContext.canvas.width = width;
    canvasAndContext.canvas.height = height;
  }
  destroy(canvasAndContext) {
    if (!canvasAndContext.canvas) {
      throw new Error("Canvas is not specified");
    }
    canvasAndContext.canvas.width = 0;
    canvasAndContext.canvas.height = 0;
    canvasAndContext.canvas = null;
    canvasAndContext.context = null;
  }
};

// src/worker/index.ts
var runtimeDirname;
if (typeof __dirname !== "undefined") {
  runtimeDirname = __dirname;
} else {
  const __filename = (0, import_node_url.fileURLToPath)("file://D:\\temp");
  runtimeDirname = import_node_path.default.dirname(__filename);
}
(async () => {
  try {
    await import("pdfjs-dist/legacy/build/pdf.worker.mjs");
  } catch (err) {
    console.error("pdf.worker load error!..\n", err);
  }
})();
function getData() {
  return pdf_worker_min_default;
}
function getPath() {
  return import_node_path.default.resolve(runtimeDirname, "../pdf.worker.mjs");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CanvasFactory,
  getData,
  getPath
});
