shadow$provide.module$node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics = function(global, require, module, exports) {
  global = require("module$node_modules$tiny_lru$dist$tiny_lru_cjs");
  var adapter = require("module$node_modules$pixi_DOT_js$lib$environment$adapter"), measureTaggedText = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$measureTaggedText"), parseTaggedText = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$parseTaggedText"), textTokenization = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$textTokenization"), wordWrap = require("module$node_modules$pixi_DOT_js$lib$scene$text$canvas$utils$wordWrap");
  "use strict";
  const contextSettings = {willReadFrequently:!0}, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34 = class {
    static get experimentalLetterSpacingSupported() {
      var result = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._experimentalLetterSpacingSupported;
      void 0 === result && (result = adapter.DOMAdapter.get().getCanvasRenderingContext2D().prototype, result = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._experimentalLetterSpacingSupported = "letterSpacing" in result || "textLetterSpacing" in result);
      return result;
    }
    constructor(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties, taggedData) {
      this.text = text;
      this.style = style;
      this.width = width;
      this.height = height;
      this.lines = lines;
      this.lineWidths = lineWidths;
      this.lineHeight = lineHeight;
      this.maxLineWidth = maxLineWidth;
      this.fontProperties = fontProperties;
      taggedData && (this.runsByLine = taggedData.runsByLine, this.lineAscents = taggedData.lineAscents, this.lineDescents = taggedData.lineDescents, this.lineHeights = taggedData.lineHeights, this.hasDropShadow = taggedData.hasDropShadow);
    }
    static measureText(text = " ", style, canvas = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._canvas, wordWrap2 = style.wordWrap) {
      const textKey = `${text}-${style.styleKey}-wordWrap-${wordWrap2}`;
      if (node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measurementCache.has(textKey)) {
        return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measurementCache.get(textKey);
      }
      if (parseTaggedText.hasTagStyles(style) && parseTaggedText.hasTagMarkup(text)) {
        var result = measureTaggedText.measureTaggedText(text, style, wordWrap2, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._context, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measureText, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measureTextAdvance, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.measureFont, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.canBreakChars, 
        node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.wordWrapSplit);
        text = new node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34(text, style, result.width, result.height, result.lines, result.lineWidths, result.lineHeight, result.maxLineWidth, result.fontProperties, {runsByLine:result.runsByLine, lineAscents:result.lineAscents, lineDescents:result.lineDescents, lineHeights:result.lineHeights, hasDropShadow:result.hasDropShadow});
        node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measurementCache.set(textKey, text);
        return text;
      }
      var font = style._fontString;
      result = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.measureFont(font);
      0 === result.fontSize && (result.fontSize = style.fontSize, result.ascent = style.fontSize, result.descent = 0);
      var context = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._context;
      context.font = font;
      canvas = (wordWrap2 ? node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._wordWrap(text, style, canvas) : text).split(textTokenization.NEWLINE_MATCH_REGEX);
      wordWrap2 = Array(canvas.length);
      font = 0;
      for (var i = 0; i < canvas.length; i++) {
        var lineWidth = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measureText(canvas[i], style.letterSpacing, context);
        wordWrap2[i] = lineWidth;
        font = Math.max(font, lineWidth);
      }
      lineWidth = style._stroke?.width ?? 0;
      context = style.lineHeight || result.fontSize;
      i = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._adjustWidthForStyle(font, style);
      lineWidth = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._adjustHeightForStyle(Math.max(context, result.fontSize + lineWidth) + (canvas.length - 1) * (context + style.leading), style);
      text = new node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34(text, style, i, lineWidth, canvas, wordWrap2, context + style.leading, font, result);
      node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measurementCache.set(textKey, text);
      return text;
    }
    static _adjustWidthForStyle(baseWidth, style) {
      baseWidth += style._stroke?.width || 0;
      style.dropShadow && (baseWidth += style.dropShadow.distance);
      return baseWidth;
    }
    static _adjustHeightForStyle(baseHeight, style) {
      style.dropShadow && (baseHeight += style.dropShadow.distance);
      return baseHeight;
    }
    static _measureText(text, letterSpacing, context) {
      const {metricWidth, metrics, letterSpacingVal} = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measureTextCore(text, letterSpacing, context);
      text = (metrics.actualBoundingBoxRight ?? 0) - -(metrics.actualBoundingBoxLeft ?? 0);
      0 < metrics.width && (text += letterSpacingVal);
      return Math.max(metricWidth, text);
    }
    static _measureTextAdvance(text, letterSpacing, context) {
      return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measureTextCore(text, letterSpacing, context).metricWidth;
    }
    static _measureTextCore(text, letterSpacing, context) {
      let useExperimentalLetterSpacing = !1;
      node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.experimentalLetterSpacingSupported && (node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.experimentalLetterSpacing ? (context.letterSpacing = `${letterSpacing}px`, context.textLetterSpacing = `${letterSpacing}px`, useExperimentalLetterSpacing = !0) : (context.letterSpacing = "0px", context.textLetterSpacing = "0px"));
      context = context.measureText(text);
      let metricWidth = context.width, letterSpacingVal = 0;
      0 < metricWidth && (letterSpacingVal = useExperimentalLetterSpacing ? -letterSpacing : (node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.graphemeSegmenter(text).length - 1) * letterSpacing, metricWidth += letterSpacingVal);
      return {metricWidth, metrics:context, letterSpacingVal};
    }
    static _wordWrap(text, style, canvas = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._canvas) {
      return wordWrap.wordWrap(text, style, canvas, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._measureTextAdvance, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.canBreakWords, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.canBreakChars, node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.wordWrapSplit);
    }
    static isBreakingSpace(char, _nextChar) {
      return textTokenization.isBreakingSpace(char, _nextChar);
    }
    static canBreakWords(_token, breakWords) {
      return breakWords;
    }
    static canBreakChars(_char, _nextChar, _token, _index, _breakWords) {
      return !0;
    }
    static wordWrapSplit(token) {
      return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.graphemeSegmenter(token);
    }
    static measureFont(font) {
      if (node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._fonts[font]) {
        return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._fonts[font];
      }
      var context = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._context;
      context.font = font;
      var metrics = context.measureText(node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.METRICS_STRING + node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.BASELINE_SYMBOL);
      context = metrics.actualBoundingBoxAscent ?? 0;
      metrics = metrics.actualBoundingBoxDescent ?? 0;
      context = {ascent:context, descent:metrics, fontSize:context + metrics};
      return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._fonts[font] = context;
    }
    static clearMetrics(font = "") {
      font ? delete node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._fonts[font] : node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._fonts = {};
    }
    static get _canvas() {
      if (!node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__canvas) {
        let canvas;
        try {
          const c = new OffscreenCanvas(0, 0);
          if (c.getContext("2d", contextSettings)?.measureText) {
            return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__canvas = c;
          }
          canvas = adapter.DOMAdapter.get().createCanvas();
        } catch (_cx) {
          canvas = adapter.DOMAdapter.get().createCanvas();
        }
        canvas.width = canvas.height = 10;
        node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__canvas = canvas;
      }
      return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__canvas;
    }
    static get _context() {
      node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__context || (node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__context = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34._canvas.getContext("2d", contextSettings));
      return node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34.__context;
    }
  };
  require = node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics$classdecl$var34;
  require.METRICS_STRING = "|ÉqÅ";
  require.BASELINE_SYMBOL = "M";
  require.BASELINE_MULTIPLIER = 1.4;
  require.HEIGHT_MULTIPLIER = 2;
  require.graphemeSegmenter = (() => {
    if ("function" === typeof Intl?.Segmenter) {
      const segmenter = new Intl.Segmenter();
      return s => {
        s = segmenter.segment(s);
        const result = [];
        let i = 0;
        for (const segment of s) {
          result[i++] = segment.segment;
        }
        return result;
      };
    }
    return s => [...s];
  })();
  require.experimentalLetterSpacing = !1;
  require._fonts = {};
  require._measurementCache = global.lru(1e3);
  exports.CanvasTextMetrics = require;
};

//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$scene$text$canvas$CanvasTextMetrics.js.map
