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 attach_image_from_text_exports = {};
__export(attach_image_from_text_exports, {
  attachImageFromText: () => attachImageFromText
});
module.exports = __toCommonJS(attach_image_from_text_exports);
var import_attach_image_to_map = require("./attach-image-to-map.js");
var import_get_scaled_symbol_size = require("./get-scaled-symbol-size.js");
const attachImageFromText = (map, text, name, outputSize) => {
  const scaledTextSymbolSize = (0, import_get_scaled_symbol_size.getScaledSymbolSize)(outputSize);
  const canvas = document.createElement("canvas");
  canvas.width = scaledTextSymbolSize;
  canvas.height = scaledTextSymbolSize;
  const ctx = canvas.getContext("2d") ?? new CanvasRenderingContext2D();
  ctx.imageSmoothingEnabled = false;
  ctx.font = `${scaledTextSymbolSize}px DynatraceFlow`;
  ctx.textAlign = "center";
  ctx.textBaseline = "middle";
  ctx.fillText(text, scaledTextSymbolSize / 2, scaledTextSymbolSize / 2);
  const img = new Image(scaledTextSymbolSize, scaledTextSymbolSize);
  img.addEventListener("load", () => {
    (0, import_attach_image_to_map.attachImageToMap)(map, img, name, false);
  });
  img.src = canvas.toDataURL("image/png");
};
