import { watch as ge, reactive as ti, ref as ei, watchEffect as Sn, toRaw as Nr, computed as bh } from "vue";
var Gr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function wh(s) {
  return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
var Cn = {}, V = {}, et = {}, $ = {};
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s._registerNode = s.Konva = s.glob = void 0;
  const t = Math.PI / 180;
  function e() {
    return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
  }
  s.glob = typeof Gr < "u" ? Gr : typeof window < "u" ? window : typeof WorkerGlobalScope < "u" ? self : {}, s.Konva = {
    _global: s.glob,
    version: "9.3.6",
    isBrowser: e(),
    isUnminified: /param/.test((function(n) {
    }).toString()),
    dblClickWindow: 400,
    getAngle(n) {
      return s.Konva.angleDeg ? n * t : n;
    },
    enableTrace: !1,
    pointerEventsEnabled: !0,
    autoDrawEnabled: !0,
    hitOnDragEnabled: !1,
    capturePointerEventsEnabled: !1,
    _mouseListenClick: !1,
    _touchListenClick: !1,
    _pointerListenClick: !1,
    _mouseInDblClickWindow: !1,
    _touchInDblClickWindow: !1,
    _pointerInDblClickWindow: !1,
    _mouseDblClickPointerId: null,
    _touchDblClickPointerId: null,
    _pointerDblClickPointerId: null,
    pixelRatio: typeof window < "u" && window.devicePixelRatio || 1,
    dragDistance: 3,
    angleDeg: !0,
    showWarnings: !0,
    dragButtons: [0, 1],
    isDragging() {
      return s.Konva.DD.isDragging;
    },
    isTransforming() {
      var n;
      return (n = s.Konva.Transformer) === null || n === void 0 ? void 0 : n.isTransforming();
    },
    isDragReady() {
      return !!s.Konva.DD.node;
    },
    releaseCanvasOnDestroy: !0,
    document: s.glob.document,
    _injectGlobal(n) {
      s.glob.Konva = n;
    }
  };
  const i = (n) => {
    s.Konva[n.prototype.getClassName()] = n;
  };
  s._registerNode = i, s.Konva._injectGlobal(s.Konva);
})($);
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.Util = s.Transform = void 0;
  const t = $;
  class e {
    constructor(y = [1, 0, 0, 1, 0, 0]) {
      this.dirty = !1, this.m = y && y.slice() || [1, 0, 0, 1, 0, 0];
    }
    reset() {
      this.m[0] = 1, this.m[1] = 0, this.m[2] = 0, this.m[3] = 1, this.m[4] = 0, this.m[5] = 0;
    }
    copy() {
      return new e(this.m);
    }
    copyInto(y) {
      y.m[0] = this.m[0], y.m[1] = this.m[1], y.m[2] = this.m[2], y.m[3] = this.m[3], y.m[4] = this.m[4], y.m[5] = this.m[5];
    }
    point(y) {
      var x = this.m;
      return {
        x: x[0] * y.x + x[2] * y.y + x[4],
        y: x[1] * y.x + x[3] * y.y + x[5]
      };
    }
    translate(y, x) {
      return this.m[4] += this.m[0] * y + this.m[2] * x, this.m[5] += this.m[1] * y + this.m[3] * x, this;
    }
    scale(y, x) {
      return this.m[0] *= y, this.m[1] *= y, this.m[2] *= x, this.m[3] *= x, this;
    }
    rotate(y) {
      var x = Math.cos(y), b = Math.sin(y), C = this.m[0] * x + this.m[2] * b, w = this.m[1] * x + this.m[3] * b, E = this.m[0] * -b + this.m[2] * x, S = this.m[1] * -b + this.m[3] * x;
      return this.m[0] = C, this.m[1] = w, this.m[2] = E, this.m[3] = S, this;
    }
    getTranslation() {
      return {
        x: this.m[4],
        y: this.m[5]
      };
    }
    skew(y, x) {
      var b = this.m[0] + this.m[2] * x, C = this.m[1] + this.m[3] * x, w = this.m[2] + this.m[0] * y, E = this.m[3] + this.m[1] * y;
      return this.m[0] = b, this.m[1] = C, this.m[2] = w, this.m[3] = E, this;
    }
    multiply(y) {
      var x = this.m[0] * y.m[0] + this.m[2] * y.m[1], b = this.m[1] * y.m[0] + this.m[3] * y.m[1], C = this.m[0] * y.m[2] + this.m[2] * y.m[3], w = this.m[1] * y.m[2] + this.m[3] * y.m[3], E = this.m[0] * y.m[4] + this.m[2] * y.m[5] + this.m[4], S = this.m[1] * y.m[4] + this.m[3] * y.m[5] + this.m[5];
      return this.m[0] = x, this.m[1] = b, this.m[2] = C, this.m[3] = w, this.m[4] = E, this.m[5] = S, this;
    }
    invert() {
      var y = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]), x = this.m[3] * y, b = -this.m[1] * y, C = -this.m[2] * y, w = this.m[0] * y, E = y * (this.m[2] * this.m[5] - this.m[3] * this.m[4]), S = y * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
      return this.m[0] = x, this.m[1] = b, this.m[2] = C, this.m[3] = w, this.m[4] = E, this.m[5] = S, this;
    }
    getMatrix() {
      return this.m;
    }
    decompose() {
      var y = this.m[0], x = this.m[1], b = this.m[2], C = this.m[3], w = this.m[4], E = this.m[5], S = y * C - x * b;
      let P = {
        x: w,
        y: E,
        rotation: 0,
        scaleX: 0,
        scaleY: 0,
        skewX: 0,
        skewY: 0
      };
      if (y != 0 || x != 0) {
        var k = Math.sqrt(y * y + x * x);
        P.rotation = x > 0 ? Math.acos(y / k) : -Math.acos(y / k), P.scaleX = k, P.scaleY = S / k, P.skewX = (y * b + x * C) / S, P.skewY = 0;
      } else if (b != 0 || C != 0) {
        var F = Math.sqrt(b * b + C * C);
        P.rotation = Math.PI / 2 - (C > 0 ? Math.acos(-b / F) : -Math.acos(b / F)), P.scaleX = S / F, P.scaleY = F, P.skewX = 0, P.skewY = (y * b + x * C) / S;
      }
      return P.rotation = s.Util._getRotation(P.rotation), P;
    }
  }
  s.Transform = e;
  var i = "[object Array]", n = "[object Number]", r = "[object String]", a = "[object Boolean]", o = Math.PI / 180, h = 180 / Math.PI, l = "#", A = "", u = "0", f = "Konva warning: ", c = "Konva error: ", d = "rgb(", p = {
    aliceblue: [240, 248, 255],
    antiquewhite: [250, 235, 215],
    aqua: [0, 255, 255],
    aquamarine: [127, 255, 212],
    azure: [240, 255, 255],
    beige: [245, 245, 220],
    bisque: [255, 228, 196],
    black: [0, 0, 0],
    blanchedalmond: [255, 235, 205],
    blue: [0, 0, 255],
    blueviolet: [138, 43, 226],
    brown: [165, 42, 42],
    burlywood: [222, 184, 135],
    cadetblue: [95, 158, 160],
    chartreuse: [127, 255, 0],
    chocolate: [210, 105, 30],
    coral: [255, 127, 80],
    cornflowerblue: [100, 149, 237],
    cornsilk: [255, 248, 220],
    crimson: [220, 20, 60],
    cyan: [0, 255, 255],
    darkblue: [0, 0, 139],
    darkcyan: [0, 139, 139],
    darkgoldenrod: [184, 132, 11],
    darkgray: [169, 169, 169],
    darkgreen: [0, 100, 0],
    darkgrey: [169, 169, 169],
    darkkhaki: [189, 183, 107],
    darkmagenta: [139, 0, 139],
    darkolivegreen: [85, 107, 47],
    darkorange: [255, 140, 0],
    darkorchid: [153, 50, 204],
    darkred: [139, 0, 0],
    darksalmon: [233, 150, 122],
    darkseagreen: [143, 188, 143],
    darkslateblue: [72, 61, 139],
    darkslategray: [47, 79, 79],
    darkslategrey: [47, 79, 79],
    darkturquoise: [0, 206, 209],
    darkviolet: [148, 0, 211],
    deeppink: [255, 20, 147],
    deepskyblue: [0, 191, 255],
    dimgray: [105, 105, 105],
    dimgrey: [105, 105, 105],
    dodgerblue: [30, 144, 255],
    firebrick: [178, 34, 34],
    floralwhite: [255, 255, 240],
    forestgreen: [34, 139, 34],
    fuchsia: [255, 0, 255],
    gainsboro: [220, 220, 220],
    ghostwhite: [248, 248, 255],
    gold: [255, 215, 0],
    goldenrod: [218, 165, 32],
    gray: [128, 128, 128],
    green: [0, 128, 0],
    greenyellow: [173, 255, 47],
    grey: [128, 128, 128],
    honeydew: [240, 255, 240],
    hotpink: [255, 105, 180],
    indianred: [205, 92, 92],
    indigo: [75, 0, 130],
    ivory: [255, 255, 240],
    khaki: [240, 230, 140],
    lavender: [230, 230, 250],
    lavenderblush: [255, 240, 245],
    lawngreen: [124, 252, 0],
    lemonchiffon: [255, 250, 205],
    lightblue: [173, 216, 230],
    lightcoral: [240, 128, 128],
    lightcyan: [224, 255, 255],
    lightgoldenrodyellow: [250, 250, 210],
    lightgray: [211, 211, 211],
    lightgreen: [144, 238, 144],
    lightgrey: [211, 211, 211],
    lightpink: [255, 182, 193],
    lightsalmon: [255, 160, 122],
    lightseagreen: [32, 178, 170],
    lightskyblue: [135, 206, 250],
    lightslategray: [119, 136, 153],
    lightslategrey: [119, 136, 153],
    lightsteelblue: [176, 196, 222],
    lightyellow: [255, 255, 224],
    lime: [0, 255, 0],
    limegreen: [50, 205, 50],
    linen: [250, 240, 230],
    magenta: [255, 0, 255],
    maroon: [128, 0, 0],
    mediumaquamarine: [102, 205, 170],
    mediumblue: [0, 0, 205],
    mediumorchid: [186, 85, 211],
    mediumpurple: [147, 112, 219],
    mediumseagreen: [60, 179, 113],
    mediumslateblue: [123, 104, 238],
    mediumspringgreen: [0, 250, 154],
    mediumturquoise: [72, 209, 204],
    mediumvioletred: [199, 21, 133],
    midnightblue: [25, 25, 112],
    mintcream: [245, 255, 250],
    mistyrose: [255, 228, 225],
    moccasin: [255, 228, 181],
    navajowhite: [255, 222, 173],
    navy: [0, 0, 128],
    oldlace: [253, 245, 230],
    olive: [128, 128, 0],
    olivedrab: [107, 142, 35],
    orange: [255, 165, 0],
    orangered: [255, 69, 0],
    orchid: [218, 112, 214],
    palegoldenrod: [238, 232, 170],
    palegreen: [152, 251, 152],
    paleturquoise: [175, 238, 238],
    palevioletred: [219, 112, 147],
    papayawhip: [255, 239, 213],
    peachpuff: [255, 218, 185],
    peru: [205, 133, 63],
    pink: [255, 192, 203],
    plum: [221, 160, 203],
    powderblue: [176, 224, 230],
    purple: [128, 0, 128],
    rebeccapurple: [102, 51, 153],
    red: [255, 0, 0],
    rosybrown: [188, 143, 143],
    royalblue: [65, 105, 225],
    saddlebrown: [139, 69, 19],
    salmon: [250, 128, 114],
    sandybrown: [244, 164, 96],
    seagreen: [46, 139, 87],
    seashell: [255, 245, 238],
    sienna: [160, 82, 45],
    silver: [192, 192, 192],
    skyblue: [135, 206, 235],
    slateblue: [106, 90, 205],
    slategray: [119, 128, 144],
    slategrey: [119, 128, 144],
    snow: [255, 255, 250],
    springgreen: [0, 255, 127],
    steelblue: [70, 130, 180],
    tan: [210, 180, 140],
    teal: [0, 128, 128],
    thistle: [216, 191, 216],
    transparent: [255, 255, 255, 0],
    tomato: [255, 99, 71],
    turquoise: [64, 224, 208],
    violet: [238, 130, 238],
    wheat: [245, 222, 179],
    white: [255, 255, 255],
    whitesmoke: [245, 245, 245],
    yellow: [255, 255, 0],
    yellowgreen: [154, 205, 5]
  }, m = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/, v = [];
  const _ = typeof requestAnimationFrame < "u" && requestAnimationFrame || function(g) {
    setTimeout(g, 60);
  };
  s.Util = {
    _isElement(g) {
      return !!(g && g.nodeType == 1);
    },
    _isFunction(g) {
      return !!(g && g.constructor && g.call && g.apply);
    },
    _isPlainObject(g) {
      return !!g && g.constructor === Object;
    },
    _isArray(g) {
      return Object.prototype.toString.call(g) === i;
    },
    _isNumber(g) {
      return Object.prototype.toString.call(g) === n && !isNaN(g) && isFinite(g);
    },
    _isString(g) {
      return Object.prototype.toString.call(g) === r;
    },
    _isBoolean(g) {
      return Object.prototype.toString.call(g) === a;
    },
    isObject(g) {
      return g instanceof Object;
    },
    isValidSelector(g) {
      if (typeof g != "string")
        return !1;
      var y = g[0];
      return y === "#" || y === "." || y === y.toUpperCase();
    },
    _sign(g) {
      return g === 0 || g > 0 ? 1 : -1;
    },
    requestAnimFrame(g) {
      v.push(g), v.length === 1 && _(function() {
        const y = v;
        v = [], y.forEach(function(x) {
          x();
        });
      });
    },
    createCanvasElement() {
      var g = document.createElement("canvas");
      try {
        g.style = g.style || {};
      } catch {
      }
      return g;
    },
    createImageElement() {
      return document.createElement("img");
    },
    _isInDocument(g) {
      for (; g = g.parentNode; )
        if (g == document)
          return !0;
      return !1;
    },
    _urlToImage(g, y) {
      var x = s.Util.createImageElement();
      x.onload = function() {
        y(x);
      }, x.src = g;
    },
    _rgbToHex(g, y, x) {
      return ((1 << 24) + (g << 16) + (y << 8) + x).toString(16).slice(1);
    },
    _hexToRgb(g) {
      g = g.replace(l, A);
      var y = parseInt(g, 16);
      return {
        r: y >> 16 & 255,
        g: y >> 8 & 255,
        b: y & 255
      };
    },
    getRandomColor() {
      for (var g = (Math.random() * 16777215 << 0).toString(16); g.length < 6; )
        g = u + g;
      return l + g;
    },
    getRGB(g) {
      var y;
      return g in p ? (y = p[g], {
        r: y[0],
        g: y[1],
        b: y[2]
      }) : g[0] === l ? this._hexToRgb(g.substring(1)) : g.substr(0, 4) === d ? (y = m.exec(g.replace(/ /g, "")), {
        r: parseInt(y[1], 10),
        g: parseInt(y[2], 10),
        b: parseInt(y[3], 10)
      }) : {
        r: 0,
        g: 0,
        b: 0
      };
    },
    colorToRGBA(g) {
      return g = g || "black", s.Util._namedColorToRBA(g) || s.Util._hex3ColorToRGBA(g) || s.Util._hex4ColorToRGBA(g) || s.Util._hex6ColorToRGBA(g) || s.Util._hex8ColorToRGBA(g) || s.Util._rgbColorToRGBA(g) || s.Util._rgbaColorToRGBA(g) || s.Util._hslColorToRGBA(g);
    },
    _namedColorToRBA(g) {
      var y = p[g.toLowerCase()];
      return y ? {
        r: y[0],
        g: y[1],
        b: y[2],
        a: 1
      } : null;
    },
    _rgbColorToRGBA(g) {
      if (g.indexOf("rgb(") === 0) {
        g = g.match(/rgb\(([^)]+)\)/)[1];
        var y = g.split(/ *, */).map(Number);
        return {
          r: y[0],
          g: y[1],
          b: y[2],
          a: 1
        };
      }
    },
    _rgbaColorToRGBA(g) {
      if (g.indexOf("rgba(") === 0) {
        g = g.match(/rgba\(([^)]+)\)/)[1];
        var y = g.split(/ *, */).map((x, b) => x.slice(-1) === "%" ? b === 3 ? parseInt(x) / 100 : parseInt(x) / 100 * 255 : Number(x));
        return {
          r: y[0],
          g: y[1],
          b: y[2],
          a: y[3]
        };
      }
    },
    _hex8ColorToRGBA(g) {
      if (g[0] === "#" && g.length === 9)
        return {
          r: parseInt(g.slice(1, 3), 16),
          g: parseInt(g.slice(3, 5), 16),
          b: parseInt(g.slice(5, 7), 16),
          a: parseInt(g.slice(7, 9), 16) / 255
        };
    },
    _hex6ColorToRGBA(g) {
      if (g[0] === "#" && g.length === 7)
        return {
          r: parseInt(g.slice(1, 3), 16),
          g: parseInt(g.slice(3, 5), 16),
          b: parseInt(g.slice(5, 7), 16),
          a: 1
        };
    },
    _hex4ColorToRGBA(g) {
      if (g[0] === "#" && g.length === 5)
        return {
          r: parseInt(g[1] + g[1], 16),
          g: parseInt(g[2] + g[2], 16),
          b: parseInt(g[3] + g[3], 16),
          a: parseInt(g[4] + g[4], 16) / 255
        };
    },
    _hex3ColorToRGBA(g) {
      if (g[0] === "#" && g.length === 4)
        return {
          r: parseInt(g[1] + g[1], 16),
          g: parseInt(g[2] + g[2], 16),
          b: parseInt(g[3] + g[3], 16),
          a: 1
        };
    },
    _hslColorToRGBA(g) {
      if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(g)) {
        const [y, ...x] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(g), b = Number(x[0]) / 360, C = Number(x[1]) / 100, w = Number(x[2]) / 100;
        let E, S, P;
        if (C === 0)
          return P = w * 255, {
            r: Math.round(P),
            g: Math.round(P),
            b: Math.round(P),
            a: 1
          };
        w < 0.5 ? E = w * (1 + C) : E = w + C - w * C;
        const k = 2 * w - E, F = [0, 0, 0];
        for (let L = 0; L < 3; L++)
          S = b + 1 / 3 * -(L - 1), S < 0 && S++, S > 1 && S--, 6 * S < 1 ? P = k + (E - k) * 6 * S : 2 * S < 1 ? P = E : 3 * S < 2 ? P = k + (E - k) * (2 / 3 - S) * 6 : P = k, F[L] = P * 255;
        return {
          r: Math.round(F[0]),
          g: Math.round(F[1]),
          b: Math.round(F[2]),
          a: 1
        };
      }
    },
    haveIntersection(g, y) {
      return !(y.x > g.x + g.width || y.x + y.width < g.x || y.y > g.y + g.height || y.y + y.height < g.y);
    },
    cloneObject(g) {
      var y = {};
      for (var x in g)
        this._isPlainObject(g[x]) ? y[x] = this.cloneObject(g[x]) : this._isArray(g[x]) ? y[x] = this.cloneArray(g[x]) : y[x] = g[x];
      return y;
    },
    cloneArray(g) {
      return g.slice(0);
    },
    degToRad(g) {
      return g * o;
    },
    radToDeg(g) {
      return g * h;
    },
    _degToRad(g) {
      return s.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."), s.Util.degToRad(g);
    },
    _radToDeg(g) {
      return s.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."), s.Util.radToDeg(g);
    },
    _getRotation(g) {
      return t.Konva.angleDeg ? s.Util.radToDeg(g) : g;
    },
    _capitalize(g) {
      return g.charAt(0).toUpperCase() + g.slice(1);
    },
    throw(g) {
      throw new Error(c + g);
    },
    error(g) {
      console.error(c + g);
    },
    warn(g) {
      t.Konva.showWarnings && console.warn(f + g);
    },
    each(g, y) {
      for (var x in g)
        y(x, g[x]);
    },
    _inRange(g, y, x) {
      return y <= g && g < x;
    },
    _getProjectionToSegment(g, y, x, b, C, w) {
      var E, S, P, k = (g - x) * (g - x) + (y - b) * (y - b);
      if (k == 0)
        E = g, S = y, P = (C - x) * (C - x) + (w - b) * (w - b);
      else {
        var F = ((C - g) * (x - g) + (w - y) * (b - y)) / k;
        F < 0 ? (E = g, S = y, P = (g - C) * (g - C) + (y - w) * (y - w)) : F > 1 ? (E = x, S = b, P = (x - C) * (x - C) + (b - w) * (b - w)) : (E = g + F * (x - g), S = y + F * (b - y), P = (E - C) * (E - C) + (S - w) * (S - w));
      }
      return [E, S, P];
    },
    _getProjectionToLine(g, y, x) {
      var b = s.Util.cloneObject(g), C = Number.MAX_VALUE;
      return y.forEach(function(w, E) {
        if (!(!x && E === y.length - 1)) {
          var S = y[(E + 1) % y.length], P = s.Util._getProjectionToSegment(w.x, w.y, S.x, S.y, g.x, g.y), k = P[0], F = P[1], L = P[2];
          L < C && (b.x = k, b.y = F, C = L);
        }
      }), b;
    },
    _prepareArrayForTween(g, y, x) {
      var b, C = [], w = [];
      if (g.length > y.length) {
        var E = y;
        y = g, g = E;
      }
      for (b = 0; b < g.length; b += 2)
        C.push({
          x: g[b],
          y: g[b + 1]
        });
      for (b = 0; b < y.length; b += 2)
        w.push({
          x: y[b],
          y: y[b + 1]
        });
      var S = [];
      return w.forEach(function(P) {
        var k = s.Util._getProjectionToLine(P, C, x);
        S.push(k.x), S.push(k.y);
      }), S;
    },
    _prepareToStringify(g) {
      var y;
      g.visitedByCircularReferenceRemoval = !0;
      for (var x in g)
        if (g.hasOwnProperty(x) && g[x] && typeof g[x] == "object") {
          if (y = Object.getOwnPropertyDescriptor(g, x), g[x].visitedByCircularReferenceRemoval || s.Util._isElement(g[x]))
            if (y.configurable)
              delete g[x];
            else
              return null;
          else if (s.Util._prepareToStringify(g[x]) === null)
            if (y.configurable)
              delete g[x];
            else
              return null;
        }
      return delete g.visitedByCircularReferenceRemoval, g;
    },
    _assign(g, y) {
      for (var x in y)
        g[x] = y[x];
      return g;
    },
    _getFirstPointerId(g) {
      return g.touches ? g.changedTouches[0].identifier : g.pointerId || 999;
    },
    releaseCanvas(...g) {
      t.Konva.releaseCanvasOnDestroy && g.forEach((y) => {
        y.width = 0, y.height = 0;
      });
    },
    drawRoundedRectPath(g, y, x, b) {
      let C = 0, w = 0, E = 0, S = 0;
      typeof b == "number" ? C = w = E = S = Math.min(b, y / 2, x / 2) : (C = Math.min(b[0] || 0, y / 2, x / 2), w = Math.min(b[1] || 0, y / 2, x / 2), S = Math.min(b[2] || 0, y / 2, x / 2), E = Math.min(b[3] || 0, y / 2, x / 2)), g.moveTo(C, 0), g.lineTo(y - w, 0), g.arc(y - w, w, w, Math.PI * 3 / 2, 0, !1), g.lineTo(y, x - S), g.arc(y - S, x - S, S, 0, Math.PI / 2, !1), g.lineTo(E, x), g.arc(E, x - E, E, Math.PI / 2, Math.PI, !1), g.lineTo(0, C), g.arc(C, C, C, Math.PI, Math.PI * 3 / 2, !1);
    }
  };
})(et);
var O = {};
Object.defineProperty(O, "__esModule", { value: !0 });
O.getComponentValidator = O.getBooleanValidator = O.getNumberArrayValidator = O.getFunctionValidator = O.getStringOrGradientValidator = O.getStringValidator = O.getNumberOrAutoValidator = O.getNumberOrArrayOfNumbersValidator = O.getNumberValidator = O.alphaComponent = O.RGBComponent = void 0;
const Kt = $, ht = et;
function Zt(s) {
  return ht.Util._isString(s) ? '"' + s + '"' : Object.prototype.toString.call(s) === "[object Number]" || ht.Util._isBoolean(s) ? s : Object.prototype.toString.call(s);
}
function Sh(s) {
  return s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
}
O.RGBComponent = Sh;
function Ch(s) {
  return s > 1 ? 1 : s < 1e-4 ? 1e-4 : s;
}
O.alphaComponent = Ch;
function Mh() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      return ht.Util._isNumber(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a number.'), s;
    };
}
O.getNumberValidator = Mh;
function Ph(s) {
  if (Kt.Konva.isUnminified)
    return function(t, e) {
      let i = ht.Util._isNumber(t), n = ht.Util._isArray(t) && t.length == s;
      return !i && !n && ht.Util.warn(Zt(t) + ' is a not valid value for "' + e + '" attribute. The value should be a number or Array<number>(' + s + ")"), t;
    };
}
O.getNumberOrArrayOfNumbersValidator = Ph;
function Eh() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      var e = ht.Util._isNumber(s), i = s === "auto";
      return e || i || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a number or "auto".'), s;
    };
}
O.getNumberOrAutoValidator = Eh;
function Fh() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      return ht.Util._isString(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a string.'), s;
    };
}
O.getStringValidator = Fh;
function kh() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      const e = ht.Util._isString(s), i = Object.prototype.toString.call(s) === "[object CanvasGradient]" || s && s.addColorStop;
      return e || i || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a string or a native gradient.'), s;
    };
}
O.getStringOrGradientValidator = kh;
function Dh() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      return ht.Util._isFunction(s) || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a function.'), s;
    };
}
O.getFunctionValidator = Dh;
function Ih() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      const e = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
      return e && s instanceof e || (ht.Util._isArray(s) ? s.forEach(function(i) {
        ht.Util._isNumber(i) || ht.Util.warn('"' + t + '" attribute has non numeric element ' + i + ". Make sure that all elements are numbers.");
      }) : ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a array of numbers.')), s;
    };
}
O.getNumberArrayValidator = Ih;
function Th() {
  if (Kt.Konva.isUnminified)
    return function(s, t) {
      var e = s === !0 || s === !1;
      return e || ht.Util.warn(Zt(s) + ' is a not valid value for "' + t + '" attribute. The value should be a boolean.'), s;
    };
}
O.getBooleanValidator = Th;
function Lh(s) {
  if (Kt.Konva.isUnminified)
    return function(t, e) {
      return t == null || ht.Util.isObject(t) || ht.Util.warn(Zt(t) + ' is a not valid value for "' + e + '" attribute. The value should be an object with properties ' + s), t;
    };
}
O.getComponentValidator = Lh;
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.Factory = void 0;
  const t = et, e = O;
  var i = "get", n = "set";
  s.Factory = {
    addGetterSetter(r, a, o, h, l) {
      s.Factory.addGetter(r, a, o), s.Factory.addSetter(r, a, h, l), s.Factory.addOverloadedGetterSetter(r, a);
    },
    addGetter(r, a, o) {
      var h = i + t.Util._capitalize(a);
      r.prototype[h] = r.prototype[h] || function() {
        var l = this.attrs[a];
        return l === void 0 ? o : l;
      };
    },
    addSetter(r, a, o, h) {
      var l = n + t.Util._capitalize(a);
      r.prototype[l] || s.Factory.overWriteSetter(r, a, o, h);
    },
    overWriteSetter(r, a, o, h) {
      var l = n + t.Util._capitalize(a);
      r.prototype[l] = function(A) {
        return o && A !== void 0 && A !== null && (A = o.call(this, A, a)), this._setAttr(a, A), h && h.call(this), this;
      };
    },
    addComponentsGetterSetter(r, a, o, h, l) {
      var A = o.length, u = t.Util._capitalize, f = i + u(a), c = n + u(a), d, p;
      r.prototype[f] = function() {
        var v = {};
        for (d = 0; d < A; d++)
          p = o[d], v[p] = this.getAttr(a + u(p));
        return v;
      };
      var m = (0, e.getComponentValidator)(o);
      r.prototype[c] = function(v) {
        var _ = this.attrs[a], g;
        h && (v = h.call(this, v)), m && m.call(this, v, a);
        for (g in v)
          v.hasOwnProperty(g) && this._setAttr(a + u(g), v[g]);
        return v || o.forEach((y) => {
          this._setAttr(a + u(y), void 0);
        }), this._fireChangeEvent(a, _, v), l && l.call(this), this;
      }, s.Factory.addOverloadedGetterSetter(r, a);
    },
    addOverloadedGetterSetter(r, a) {
      var o = t.Util._capitalize(a), h = n + o, l = i + o;
      r.prototype[a] = function() {
        return arguments.length ? (this[h](arguments[0]), this) : this[l]();
      };
    },
    addDeprecatedGetterSetter(r, a, o, h) {
      t.Util.error("Adding deprecated " + a);
      var l = i + t.Util._capitalize(a), A = a + " property is deprecated and will be removed soon. Look at Konva change log for more information.";
      r.prototype[l] = function() {
        t.Util.error(A);
        var u = this.attrs[a];
        return u === void 0 ? o : u;
      }, s.Factory.addSetter(r, a, h, function() {
        t.Util.error(A);
      }), s.Factory.addOverloadedGetterSetter(r, a);
    },
    backCompat(r, a) {
      t.Util.each(a, function(o, h) {
        var l = r.prototype[h], A = i + t.Util._capitalize(o), u = n + t.Util._capitalize(o);
        function f() {
          l.apply(this, arguments), t.Util.error('"' + o + '" method is deprecated and will be removed soon. Use ""' + h + '" instead.');
        }
        r.prototype[o] = f, r.prototype[A] = f, r.prototype[u] = f;
      });
    },
    afterSetFilter() {
      this._filterUpToDate = !1;
    }
  };
})(V);
var ft = {}, rt = {}, It = {}, Xt = {};
Object.defineProperty(Xt, "__esModule", { value: !0 });
Xt.HitContext = Xt.SceneContext = Xt.Context = void 0;
const Ja = et, Rh = $;
function Oh(s) {
  var t = [], e = s.length, i = Ja.Util, n, r;
  for (n = 0; n < e; n++)
    r = s[n], i._isNumber(r) ? r = Math.round(r * 1e3) / 1e3 : i._isString(r) || (r = r + ""), t.push(r);
  return t;
}
var Br = ",", Nh = "(", Gh = ")", Bh = "([", zh = "])", Uh = ";", Hh = "()", Vh = "=", zr = [
  "arc",
  "arcTo",
  "beginPath",
  "bezierCurveTo",
  "clearRect",
  "clip",
  "closePath",
  "createLinearGradient",
  "createPattern",
  "createRadialGradient",
  "drawImage",
  "ellipse",
  "fill",
  "fillText",
  "getImageData",
  "createImageData",
  "lineTo",
  "moveTo",
  "putImageData",
  "quadraticCurveTo",
  "rect",
  "roundRect",
  "restore",
  "rotate",
  "save",
  "scale",
  "setLineDash",
  "setTransform",
  "stroke",
  "strokeText",
  "transform",
  "translate"
], $h = [
  "fillStyle",
  "strokeStyle",
  "shadowColor",
  "shadowBlur",
  "shadowOffsetX",
  "shadowOffsetY",
  "letterSpacing",
  "lineCap",
  "lineDashOffset",
  "lineJoin",
  "lineWidth",
  "miterLimit",
  "direction",
  "font",
  "textAlign",
  "textBaseline",
  "globalAlpha",
  "globalCompositeOperation",
  "imageSmoothingEnabled"
];
const Wh = 100;
class Mn {
  constructor(t) {
    this.canvas = t, Rh.Konva.enableTrace && (this.traceArr = [], this._enableTrace());
  }
  fillShape(t) {
    t.fillEnabled() && this._fill(t);
  }
  _fill(t) {
  }
  strokeShape(t) {
    t.hasStroke() && this._stroke(t);
  }
  _stroke(t) {
  }
  fillStrokeShape(t) {
    t.attrs.fillAfterStrokeEnabled ? (this.strokeShape(t), this.fillShape(t)) : (this.fillShape(t), this.strokeShape(t));
  }
  getTrace(t, e) {
    var i = this.traceArr, n = i.length, r = "", a, o, h, l;
    for (a = 0; a < n; a++)
      o = i[a], h = o.method, h ? (l = o.args, r += h, t ? r += Hh : Ja.Util._isArray(l[0]) ? r += Bh + l.join(Br) + zh : (e && (l = l.map((A) => typeof A == "number" ? Math.floor(A) : A)), r += Nh + l.join(Br) + Gh)) : (r += o.property, t || (r += Vh + o.val)), r += Uh;
    return r;
  }
  clearTrace() {
    this.traceArr = [];
  }
  _trace(t) {
    var e = this.traceArr, i;
    e.push(t), i = e.length, i >= Wh && e.shift();
  }
  reset() {
    var t = this.getCanvas().getPixelRatio();
    this.setTransform(1 * t, 0, 0, 1 * t, 0, 0);
  }
  getCanvas() {
    return this.canvas;
  }
  clear(t) {
    var e = this.getCanvas();
    t ? this.clearRect(t.x || 0, t.y || 0, t.width || 0, t.height || 0) : this.clearRect(0, 0, e.getWidth() / e.pixelRatio, e.getHeight() / e.pixelRatio);
  }
  _applyLineCap(t) {
    const e = t.attrs.lineCap;
    e && this.setAttr("lineCap", e);
  }
  _applyOpacity(t) {
    var e = t.getAbsoluteOpacity();
    e !== 1 && this.setAttr("globalAlpha", e);
  }
  _applyLineJoin(t) {
    const e = t.attrs.lineJoin;
    e && this.setAttr("lineJoin", e);
  }
  setAttr(t, e) {
    this._context[t] = e;
  }
  arc(t, e, i, n, r, a) {
    this._context.arc(t, e, i, n, r, a);
  }
  arcTo(t, e, i, n, r) {
    this._context.arcTo(t, e, i, n, r);
  }
  beginPath() {
    this._context.beginPath();
  }
  bezierCurveTo(t, e, i, n, r, a) {
    this._context.bezierCurveTo(t, e, i, n, r, a);
  }
  clearRect(t, e, i, n) {
    this._context.clearRect(t, e, i, n);
  }
  clip(...t) {
    this._context.clip.apply(this._context, t);
  }
  closePath() {
    this._context.closePath();
  }
  createImageData(t, e) {
    var i = arguments;
    if (i.length === 2)
      return this._context.createImageData(t, e);
    if (i.length === 1)
      return this._context.createImageData(t);
  }
  createLinearGradient(t, e, i, n) {
    return this._context.createLinearGradient(t, e, i, n);
  }
  createPattern(t, e) {
    return this._context.createPattern(t, e);
  }
  createRadialGradient(t, e, i, n, r, a) {
    return this._context.createRadialGradient(t, e, i, n, r, a);
  }
  drawImage(t, e, i, n, r, a, o, h, l) {
    var A = arguments, u = this._context;
    A.length === 3 ? u.drawImage(t, e, i) : A.length === 5 ? u.drawImage(t, e, i, n, r) : A.length === 9 && u.drawImage(t, e, i, n, r, a, o, h, l);
  }
  ellipse(t, e, i, n, r, a, o, h) {
    this._context.ellipse(t, e, i, n, r, a, o, h);
  }
  isPointInPath(t, e, i, n) {
    return i ? this._context.isPointInPath(i, t, e, n) : this._context.isPointInPath(t, e, n);
  }
  fill(...t) {
    this._context.fill.apply(this._context, t);
  }
  fillRect(t, e, i, n) {
    this._context.fillRect(t, e, i, n);
  }
  strokeRect(t, e, i, n) {
    this._context.strokeRect(t, e, i, n);
  }
  fillText(t, e, i, n) {
    n ? this._context.fillText(t, e, i, n) : this._context.fillText(t, e, i);
  }
  measureText(t) {
    return this._context.measureText(t);
  }
  getImageData(t, e, i, n) {
    return this._context.getImageData(t, e, i, n);
  }
  lineTo(t, e) {
    this._context.lineTo(t, e);
  }
  moveTo(t, e) {
    this._context.moveTo(t, e);
  }
  rect(t, e, i, n) {
    this._context.rect(t, e, i, n);
  }
  roundRect(t, e, i, n, r) {
    this._context.roundRect(t, e, i, n, r);
  }
  putImageData(t, e, i) {
    this._context.putImageData(t, e, i);
  }
  quadraticCurveTo(t, e, i, n) {
    this._context.quadraticCurveTo(t, e, i, n);
  }
  restore() {
    this._context.restore();
  }
  rotate(t) {
    this._context.rotate(t);
  }
  save() {
    this._context.save();
  }
  scale(t, e) {
    this._context.scale(t, e);
  }
  setLineDash(t) {
    this._context.setLineDash ? this._context.setLineDash(t) : "mozDash" in this._context ? this._context.mozDash = t : "webkitLineDash" in this._context && (this._context.webkitLineDash = t);
  }
  getLineDash() {
    return this._context.getLineDash();
  }
  setTransform(t, e, i, n, r, a) {
    this._context.setTransform(t, e, i, n, r, a);
  }
  stroke(t) {
    t ? this._context.stroke(t) : this._context.stroke();
  }
  strokeText(t, e, i, n) {
    this._context.strokeText(t, e, i, n);
  }
  transform(t, e, i, n, r, a) {
    this._context.transform(t, e, i, n, r, a);
  }
  translate(t, e) {
    this._context.translate(t, e);
  }
  _enableTrace() {
    var t = this, e = zr.length, i = this.setAttr, n, r, a = function(o) {
      var h = t[o], l;
      t[o] = function() {
        return r = Oh(Array.prototype.slice.call(arguments, 0)), l = h.apply(t, arguments), t._trace({
          method: o,
          args: r
        }), l;
      };
    };
    for (n = 0; n < e; n++)
      a(zr[n]);
    t.setAttr = function() {
      i.apply(t, arguments);
      var o = arguments[0], h = arguments[1];
      (o === "shadowOffsetX" || o === "shadowOffsetY" || o === "shadowBlur") && (h = h / this.canvas.getPixelRatio()), t._trace({
        property: o,
        val: h
      });
    };
  }
  _applyGlobalCompositeOperation(t) {
    const e = t.attrs.globalCompositeOperation;
    var i = !e || e === "source-over";
    i || this.setAttr("globalCompositeOperation", e);
  }
}
Xt.Context = Mn;
$h.forEach(function(s) {
  Object.defineProperty(Mn.prototype, s, {
    get() {
      return this._context[s];
    },
    set(t) {
      this._context[s] = t;
    }
  });
});
class Yh extends Mn {
  constructor(t, { willReadFrequently: e = !1 } = {}) {
    super(t), this._context = t._canvas.getContext("2d", {
      willReadFrequently: e
    });
  }
  _fillColor(t) {
    var e = t.fill();
    this.setAttr("fillStyle", e), t._fillFunc(this);
  }
  _fillPattern(t) {
    this.setAttr("fillStyle", t._getFillPattern()), t._fillFunc(this);
  }
  _fillLinearGradient(t) {
    var e = t._getLinearGradient();
    e && (this.setAttr("fillStyle", e), t._fillFunc(this));
  }
  _fillRadialGradient(t) {
    const e = t._getRadialGradient();
    e && (this.setAttr("fillStyle", e), t._fillFunc(this));
  }
  _fill(t) {
    const e = t.fill(), i = t.getFillPriority();
    if (e && i === "color") {
      this._fillColor(t);
      return;
    }
    const n = t.getFillPatternImage();
    if (n && i === "pattern") {
      this._fillPattern(t);
      return;
    }
    const r = t.getFillLinearGradientColorStops();
    if (r && i === "linear-gradient") {
      this._fillLinearGradient(t);
      return;
    }
    const a = t.getFillRadialGradientColorStops();
    if (a && i === "radial-gradient") {
      this._fillRadialGradient(t);
      return;
    }
    e ? this._fillColor(t) : n ? this._fillPattern(t) : r ? this._fillLinearGradient(t) : a && this._fillRadialGradient(t);
  }
  _strokeLinearGradient(t) {
    const e = t.getStrokeLinearGradientStartPoint(), i = t.getStrokeLinearGradientEndPoint(), n = t.getStrokeLinearGradientColorStops(), r = this.createLinearGradient(e.x, e.y, i.x, i.y);
    if (n) {
      for (var a = 0; a < n.length; a += 2)
        r.addColorStop(n[a], n[a + 1]);
      this.setAttr("strokeStyle", r);
    }
  }
  _stroke(t) {
    var e = t.dash(), i = t.getStrokeScaleEnabled();
    if (t.hasStroke()) {
      if (!i) {
        this.save();
        var n = this.getCanvas().getPixelRatio();
        this.setTransform(n, 0, 0, n, 0, 0);
      }
      this._applyLineCap(t), e && t.dashEnabled() && (this.setLineDash(e), this.setAttr("lineDashOffset", t.dashOffset())), this.setAttr("lineWidth", t.strokeWidth()), t.getShadowForStrokeEnabled() || this.setAttr("shadowColor", "rgba(0,0,0,0)");
      var r = t.getStrokeLinearGradientColorStops();
      r ? this._strokeLinearGradient(t) : this.setAttr("strokeStyle", t.stroke()), t._strokeFunc(this), i || this.restore();
    }
  }
  _applyShadow(t) {
    var e, i, n, r = (e = t.getShadowRGBA()) !== null && e !== void 0 ? e : "black", a = (i = t.getShadowBlur()) !== null && i !== void 0 ? i : 5, o = (n = t.getShadowOffset()) !== null && n !== void 0 ? n : {
      x: 0,
      y: 0
    }, h = t.getAbsoluteScale(), l = this.canvas.getPixelRatio(), A = h.x * l, u = h.y * l;
    this.setAttr("shadowColor", r), this.setAttr("shadowBlur", a * Math.min(Math.abs(A), Math.abs(u))), this.setAttr("shadowOffsetX", o.x * A), this.setAttr("shadowOffsetY", o.y * u);
  }
}
Xt.SceneContext = Yh;
class Xh extends Mn {
  constructor(t) {
    super(t), this._context = t._canvas.getContext("2d", {
      willReadFrequently: !0
    });
  }
  _fill(t) {
    this.save(), this.setAttr("fillStyle", t.colorKey), t._fillFuncHit(this), this.restore();
  }
  strokeShape(t) {
    t.hasHitStroke() && this._stroke(t);
  }
  _stroke(t) {
    if (t.hasHitStroke()) {
      const r = t.getStrokeScaleEnabled();
      if (!r) {
        this.save();
        var e = this.getCanvas().getPixelRatio();
        this.setTransform(e, 0, 0, e, 0, 0);
      }
      this._applyLineCap(t);
      var i = t.hitStrokeWidth(), n = i === "auto" ? t.strokeWidth() : i;
      this.setAttr("lineWidth", n), this.setAttr("strokeStyle", t.colorKey), t._strokeFuncHit(this), r || this.restore();
    }
  }
}
Xt.HitContext = Xh;
Object.defineProperty(It, "__esModule", { value: !0 });
It.HitCanvas = It.SceneCanvas = It.Canvas = void 0;
const on = et, to = Xt, eo = $, jh = V, qh = O;
var $i;
function Qh() {
  if ($i)
    return $i;
  var s = on.Util.createCanvasElement(), t = s.getContext("2d");
  return $i = function() {
    var e = eo.Konva._global.devicePixelRatio || 1, i = t.webkitBackingStorePixelRatio || t.mozBackingStorePixelRatio || t.msBackingStorePixelRatio || t.oBackingStorePixelRatio || t.backingStorePixelRatio || 1;
    return e / i;
  }(), on.Util.releaseCanvas(s), $i;
}
class Pn {
  constructor(t) {
    this.pixelRatio = 1, this.width = 0, this.height = 0, this.isCache = !1;
    var e = t || {}, i = e.pixelRatio || eo.Konva.pixelRatio || Qh();
    this.pixelRatio = i, this._canvas = on.Util.createCanvasElement(), this._canvas.style.padding = "0", this._canvas.style.margin = "0", this._canvas.style.border = "0", this._canvas.style.background = "transparent", this._canvas.style.position = "absolute", this._canvas.style.top = "0", this._canvas.style.left = "0";
  }
  getContext() {
    return this.context;
  }
  getPixelRatio() {
    return this.pixelRatio;
  }
  setPixelRatio(t) {
    var e = this.pixelRatio;
    this.pixelRatio = t, this.setSize(this.getWidth() / e, this.getHeight() / e);
  }
  setWidth(t) {
    this.width = this._canvas.width = t * this.pixelRatio, this._canvas.style.width = t + "px";
    var e = this.pixelRatio, i = this.getContext()._context;
    i.scale(e, e);
  }
  setHeight(t) {
    this.height = this._canvas.height = t * this.pixelRatio, this._canvas.style.height = t + "px";
    var e = this.pixelRatio, i = this.getContext()._context;
    i.scale(e, e);
  }
  getWidth() {
    return this.width;
  }
  getHeight() {
    return this.height;
  }
  setSize(t, e) {
    this.setWidth(t || 0), this.setHeight(e || 0);
  }
  toDataURL(t, e) {
    try {
      return this._canvas.toDataURL(t, e);
    } catch {
      try {
        return this._canvas.toDataURL();
      } catch (n) {
        return on.Util.error("Unable to get data URL. " + n.message + " For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."), "";
      }
    }
  }
}
It.Canvas = Pn;
jh.Factory.addGetterSetter(Pn, "pixelRatio", void 0, (0, qh.getNumberValidator)());
class Kh extends Pn {
  constructor(t = { width: 0, height: 0, willReadFrequently: !1 }) {
    super(t), this.context = new to.SceneContext(this, {
      willReadFrequently: t.willReadFrequently
    }), this.setSize(t.width, t.height);
  }
}
It.SceneCanvas = Kh;
class Zh extends Pn {
  constructor(t = { width: 0, height: 0 }) {
    super(t), this.hitCanvas = !0, this.context = new to.HitContext(this), this.setSize(t.width, t.height);
  }
}
It.HitCanvas = Zh;
var En = {};
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.DD = void 0;
  const t = $, e = et;
  s.DD = {
    get isDragging() {
      var i = !1;
      return s.DD._dragElements.forEach((n) => {
        n.dragStatus === "dragging" && (i = !0);
      }), i;
    },
    justDragged: !1,
    get node() {
      var i;
      return s.DD._dragElements.forEach((n) => {
        i = n.node;
      }), i;
    },
    _dragElements: /* @__PURE__ */ new Map(),
    _drag(i) {
      const n = [];
      s.DD._dragElements.forEach((r, a) => {
        const { node: o } = r, h = o.getStage();
        h.setPointersPositions(i), r.pointerId === void 0 && (r.pointerId = e.Util._getFirstPointerId(i));
        const l = h._changedPointerPositions.find((f) => f.id === r.pointerId);
        if (l) {
          if (r.dragStatus !== "dragging") {
            var A = o.dragDistance(), u = Math.max(Math.abs(l.x - r.startPointerPos.x), Math.abs(l.y - r.startPointerPos.y));
            if (u < A || (o.startDrag({ evt: i }), !o.isDragging()))
              return;
          }
          o._setDragPosition(i, r), n.push(o);
        }
      }), n.forEach((r) => {
        r.fire("dragmove", {
          type: "dragmove",
          target: r,
          evt: i
        }, !0);
      });
    },
    _endDragBefore(i) {
      const n = [];
      s.DD._dragElements.forEach((r) => {
        const { node: a } = r, o = a.getStage();
        if (i && o.setPointersPositions(i), !o._changedPointerPositions.find((A) => A.id === r.pointerId))
          return;
        (r.dragStatus === "dragging" || r.dragStatus === "stopped") && (s.DD.justDragged = !0, t.Konva._mouseListenClick = !1, t.Konva._touchListenClick = !1, t.Konva._pointerListenClick = !1, r.dragStatus = "stopped");
        const l = r.node.getLayer() || r.node instanceof t.Konva.Stage && r.node;
        l && n.indexOf(l) === -1 && n.push(l);
      }), n.forEach((r) => {
        r.draw();
      });
    },
    _endDragAfter(i) {
      s.DD._dragElements.forEach((n, r) => {
        n.dragStatus === "stopped" && n.node.fire("dragend", {
          type: "dragend",
          target: n.node,
          evt: i
        }, !0), n.dragStatus !== "dragging" && s.DD._dragElements.delete(r);
      });
    }
  }, t.Konva.isBrowser && (window.addEventListener("mouseup", s.DD._endDragBefore, !0), window.addEventListener("touchend", s.DD._endDragBefore, !0), window.addEventListener("mousemove", s.DD._drag), window.addEventListener("touchmove", s.DD._drag), window.addEventListener("mouseup", s.DD._endDragAfter, !1), window.addEventListener("touchend", s.DD._endDragAfter, !1));
})(En);
Object.defineProperty(rt, "__esModule", { value: !0 });
rt.Node = void 0;
const W = et, Oi = V, mi = It, se = $, Ct = En, ct = O;
var rn = "absoluteOpacity", Wi = "allEventListeners", Wt = "absoluteTransform", Ur = "absoluteScale", xe = "canvas", Jh = "Change", tl = "children", el = "konva", Xs = "listening", Hr = "mouseenter", Vr = "mouseleave", $r = "set", Wr = "Shape", an = " ", Yr = "stage", he = "transform", il = "Stage", js = "visible", nl = [
  "xChange.konva",
  "yChange.konva",
  "scaleXChange.konva",
  "scaleYChange.konva",
  "skewXChange.konva",
  "skewYChange.konva",
  "rotationChange.konva",
  "offsetXChange.konva",
  "offsetYChange.konva",
  "transformsEnabledChange.konva"
].join(an);
let sl = 1, U = class qs {
  constructor(t) {
    this._id = sl++, this.eventListeners = {}, this.attrs = {}, this.index = 0, this._allEventListeners = null, this.parent = null, this._cache = /* @__PURE__ */ new Map(), this._attachedDepsListeners = /* @__PURE__ */ new Map(), this._lastPos = null, this._batchingTransformChange = !1, this._needClearTransformCache = !1, this._filterUpToDate = !1, this._isUnderCache = !1, this._dragEventId = null, this._shouldFireChangeEvents = !1, this.setAttrs(t), this._shouldFireChangeEvents = !0;
  }
  hasChildren() {
    return !1;
  }
  _clearCache(t) {
    (t === he || t === Wt) && this._cache.get(t) ? this._cache.get(t).dirty = !0 : t ? this._cache.delete(t) : this._cache.clear();
  }
  _getCache(t, e) {
    var i = this._cache.get(t), n = t === he || t === Wt, r = i === void 0 || n && i.dirty === !0;
    return r && (i = e.call(this), this._cache.set(t, i)), i;
  }
  _calculate(t, e, i) {
    if (!this._attachedDepsListeners.get(t)) {
      const n = e.map((r) => r + "Change.konva").join(an);
      this.on(n, () => {
        this._clearCache(t);
      }), this._attachedDepsListeners.set(t, !0);
    }
    return this._getCache(t, i);
  }
  _getCanvasCache() {
    return this._cache.get(xe);
  }
  _clearSelfAndDescendantCache(t) {
    this._clearCache(t), t === Wt && this.fire("absoluteTransformChange");
  }
  clearCache() {
    if (this._cache.has(xe)) {
      const { scene: t, filter: e, hit: i } = this._cache.get(xe);
      W.Util.releaseCanvas(t, e, i), this._cache.delete(xe);
    }
    return this._clearSelfAndDescendantCache(), this._requestDraw(), this;
  }
  cache(t) {
    var e = t || {}, i = {};
    (e.x === void 0 || e.y === void 0 || e.width === void 0 || e.height === void 0) && (i = this.getClientRect({
      skipTransform: !0,
      relativeTo: this.getParent() || void 0
    }));
    var n = Math.ceil(e.width || i.width), r = Math.ceil(e.height || i.height), a = e.pixelRatio, o = e.x === void 0 ? Math.floor(i.x) : e.x, h = e.y === void 0 ? Math.floor(i.y) : e.y, l = e.offset || 0, A = e.drawBorder || !1, u = e.hitCanvasPixelRatio || 1;
    if (!n || !r) {
      W.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");
      return;
    }
    const f = Math.abs(Math.round(i.x) - o) > 0.5 ? 1 : 0, c = Math.abs(Math.round(i.y) - h) > 0.5 ? 1 : 0;
    n += l * 2 + f, r += l * 2 + c, o -= l, h -= l;
    var d = new mi.SceneCanvas({
      pixelRatio: a,
      width: n,
      height: r
    }), p = new mi.SceneCanvas({
      pixelRatio: a,
      width: 0,
      height: 0,
      willReadFrequently: !0
    }), m = new mi.HitCanvas({
      pixelRatio: u,
      width: n,
      height: r
    }), v = d.getContext(), _ = m.getContext();
    return m.isCache = !0, d.isCache = !0, this._cache.delete(xe), this._filterUpToDate = !1, e.imageSmoothingEnabled === !1 && (d.getContext()._context.imageSmoothingEnabled = !1, p.getContext()._context.imageSmoothingEnabled = !1), v.save(), _.save(), v.translate(-o, -h), _.translate(-o, -h), this._isUnderCache = !0, this._clearSelfAndDescendantCache(rn), this._clearSelfAndDescendantCache(Ur), this.drawScene(d, this), this.drawHit(m, this), this._isUnderCache = !1, v.restore(), _.restore(), A && (v.save(), v.beginPath(), v.rect(0, 0, n, r), v.closePath(), v.setAttr("strokeStyle", "red"), v.setAttr("lineWidth", 5), v.stroke(), v.restore()), this._cache.set(xe, {
      scene: d,
      filter: p,
      hit: m,
      x: o,
      y: h
    }), this._requestDraw(), this;
  }
  isCached() {
    return this._cache.has(xe);
  }
  getClientRect(t) {
    throw new Error('abstract "getClientRect" method call');
  }
  _transformedRect(t, e) {
    var i = [
      { x: t.x, y: t.y },
      { x: t.x + t.width, y: t.y },
      { x: t.x + t.width, y: t.y + t.height },
      { x: t.x, y: t.y + t.height }
    ], n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0, h = this.getAbsoluteTransform(e);
    return i.forEach(function(l) {
      var A = h.point(l);
      n === void 0 && (n = a = A.x, r = o = A.y), n = Math.min(n, A.x), r = Math.min(r, A.y), a = Math.max(a, A.x), o = Math.max(o, A.y);
    }), {
      x: n,
      y: r,
      width: a - n,
      height: o - r
    };
  }
  _drawCachedSceneCanvas(t) {
    t.save(), t._applyOpacity(this), t._applyGlobalCompositeOperation(this);
    const e = this._getCanvasCache();
    t.translate(e.x, e.y);
    var i = this._getCachedSceneCanvas(), n = i.pixelRatio;
    t.drawImage(i._canvas, 0, 0, i.width / n, i.height / n), t.restore();
  }
  _drawCachedHitCanvas(t) {
    var e = this._getCanvasCache(), i = e.hit;
    t.save(), t.translate(e.x, e.y), t.drawImage(i._canvas, 0, 0, i.width / i.pixelRatio, i.height / i.pixelRatio), t.restore();
  }
  _getCachedSceneCanvas() {
    var t = this.filters(), e = this._getCanvasCache(), i = e.scene, n = e.filter, r = n.getContext(), a, o, h, l;
    if (t) {
      if (!this._filterUpToDate) {
        var A = i.pixelRatio;
        n.setSize(i.width / i.pixelRatio, i.height / i.pixelRatio);
        try {
          for (a = t.length, r.clear(), r.drawImage(i._canvas, 0, 0, i.getWidth() / A, i.getHeight() / A), o = r.getImageData(0, 0, n.getWidth(), n.getHeight()), h = 0; h < a; h++) {
            if (l = t[h], typeof l != "function") {
              W.Util.error("Filter should be type of function, but got " + typeof l + " instead. Please check correct filters");
              continue;
            }
            l.call(this, o), r.putImageData(o, 0, 0);
          }
        } catch (u) {
          W.Util.error("Unable to apply filter. " + u.message + " This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.");
        }
        this._filterUpToDate = !0;
      }
      return n;
    }
    return i;
  }
  on(t, e) {
    if (this._cache && this._cache.delete(Wi), arguments.length === 3)
      return this._delegate.apply(this, arguments);
    var i = t.split(an), n = i.length, r, a, o, h, l;
    for (r = 0; r < n; r++)
      a = i[r], o = a.split("."), h = o[0], l = o[1] || "", this.eventListeners[h] || (this.eventListeners[h] = []), this.eventListeners[h].push({
        name: l,
        handler: e
      });
    return this;
  }
  off(t, e) {
    var i = (t || "").split(an), n = i.length, r, a, o, h, l, A;
    if (this._cache && this._cache.delete(Wi), !t)
      for (a in this.eventListeners)
        this._off(a);
    for (r = 0; r < n; r++)
      if (o = i[r], h = o.split("."), l = h[0], A = h[1], l)
        this.eventListeners[l] && this._off(l, A, e);
      else
        for (a in this.eventListeners)
          this._off(a, A, e);
    return this;
  }
  dispatchEvent(t) {
    var e = {
      target: this,
      type: t.type,
      evt: t
    };
    return this.fire(t.type, e), this;
  }
  addEventListener(t, e) {
    return this.on(t, function(i) {
      e.call(this, i.evt);
    }), this;
  }
  removeEventListener(t) {
    return this.off(t), this;
  }
  _delegate(t, e, i) {
    var n = this;
    this.on(t, function(r) {
      for (var a = r.target.findAncestors(e, !0, n), o = 0; o < a.length; o++)
        r = W.Util.cloneObject(r), r.currentTarget = a[o], i.call(a[o], r);
    });
  }
  remove() {
    return this.isDragging() && this.stopDrag(), Ct.DD._dragElements.delete(this._id), this._remove(), this;
  }
  _clearCaches() {
    this._clearSelfAndDescendantCache(Wt), this._clearSelfAndDescendantCache(rn), this._clearSelfAndDescendantCache(Ur), this._clearSelfAndDescendantCache(Yr), this._clearSelfAndDescendantCache(js), this._clearSelfAndDescendantCache(Xs);
  }
  _remove() {
    this._clearCaches();
    var t = this.getParent();
    t && t.children && (t.children.splice(this.index, 1), t._setChildrenIndices(), this.parent = null);
  }
  destroy() {
    return this.remove(), this.clearCache(), this;
  }
  getAttr(t) {
    var e = "get" + W.Util._capitalize(t);
    return W.Util._isFunction(this[e]) ? this[e]() : this.attrs[t];
  }
  getAncestors() {
    for (var t = this.getParent(), e = []; t; )
      e.push(t), t = t.getParent();
    return e;
  }
  getAttrs() {
    return this.attrs || {};
  }
  setAttrs(t) {
    return this._batchTransformChanges(() => {
      var e, i;
      if (!t)
        return this;
      for (e in t)
        e !== tl && (i = $r + W.Util._capitalize(e), W.Util._isFunction(this[i]) ? this[i](t[e]) : this._setAttr(e, t[e]));
    }), this;
  }
  isListening() {
    return this._getCache(Xs, this._isListening);
  }
  _isListening(t) {
    if (!this.listening())
      return !1;
    const i = this.getParent();
    return i && i !== t && this !== t ? i._isListening(t) : !0;
  }
  isVisible() {
    return this._getCache(js, this._isVisible);
  }
  _isVisible(t) {
    if (!this.visible())
      return !1;
    const i = this.getParent();
    return i && i !== t && this !== t ? i._isVisible(t) : !0;
  }
  shouldDrawHit(t, e = !1) {
    if (t)
      return this._isVisible(t) && this._isListening(t);
    var i = this.getLayer(), n = !1;
    Ct.DD._dragElements.forEach((a) => {
      a.dragStatus === "dragging" && (a.node.nodeType === "Stage" || a.node.getLayer() === i) && (n = !0);
    });
    var r = !e && !se.Konva.hitOnDragEnabled && (n || se.Konva.isTransforming());
    return this.isListening() && this.isVisible() && !r;
  }
  show() {
    return this.visible(!0), this;
  }
  hide() {
    return this.visible(!1), this;
  }
  getZIndex() {
    return this.index || 0;
  }
  getAbsoluteZIndex() {
    var t = this.getDepth(), e = this, i = 0, n, r, a, o;
    function h(A) {
      for (n = [], r = A.length, a = 0; a < r; a++)
        o = A[a], i++, o.nodeType !== Wr && (n = n.concat(o.getChildren().slice())), o._id === e._id && (a = r);
      n.length > 0 && n[0].getDepth() <= t && h(n);
    }
    const l = this.getStage();
    return e.nodeType !== il && l && h(l.getChildren()), i;
  }
  getDepth() {
    for (var t = 0, e = this.parent; e; )
      t++, e = e.parent;
    return t;
  }
  _batchTransformChanges(t) {
    this._batchingTransformChange = !0, t(), this._batchingTransformChange = !1, this._needClearTransformCache && (this._clearCache(he), this._clearSelfAndDescendantCache(Wt)), this._needClearTransformCache = !1;
  }
  setPosition(t) {
    return this._batchTransformChanges(() => {
      this.x(t.x), this.y(t.y);
    }), this;
  }
  getPosition() {
    return {
      x: this.x(),
      y: this.y()
    };
  }
  getRelativePointerPosition() {
    const t = this.getStage();
    if (!t)
      return null;
    var e = t.getPointerPosition();
    if (!e)
      return null;
    var i = this.getAbsoluteTransform().copy();
    return i.invert(), i.point(e);
  }
  getAbsolutePosition(t) {
    let e = !1, i = this.parent;
    for (; i; ) {
      if (i.isCached()) {
        e = !0;
        break;
      }
      i = i.parent;
    }
    e && !t && (t = !0);
    var n = this.getAbsoluteTransform(t).getMatrix(), r = new W.Transform(), a = this.offset();
    return r.m = n.slice(), r.translate(a.x, a.y), r.getTranslation();
  }
  setAbsolutePosition(t) {
    const { x: e, y: i, ...n } = this._clearTransform();
    this.attrs.x = e, this.attrs.y = i, this._clearCache(he);
    var r = this._getAbsoluteTransform().copy();
    return r.invert(), r.translate(t.x, t.y), t = {
      x: this.attrs.x + r.getTranslation().x,
      y: this.attrs.y + r.getTranslation().y
    }, this._setTransform(n), this.setPosition({ x: t.x, y: t.y }), this._clearCache(he), this._clearSelfAndDescendantCache(Wt), this;
  }
  _setTransform(t) {
    var e;
    for (e in t)
      this.attrs[e] = t[e];
  }
  _clearTransform() {
    var t = {
      x: this.x(),
      y: this.y(),
      rotation: this.rotation(),
      scaleX: this.scaleX(),
      scaleY: this.scaleY(),
      offsetX: this.offsetX(),
      offsetY: this.offsetY(),
      skewX: this.skewX(),
      skewY: this.skewY()
    };
    return this.attrs.x = 0, this.attrs.y = 0, this.attrs.rotation = 0, this.attrs.scaleX = 1, this.attrs.scaleY = 1, this.attrs.offsetX = 0, this.attrs.offsetY = 0, this.attrs.skewX = 0, this.attrs.skewY = 0, t;
  }
  move(t) {
    var e = t.x, i = t.y, n = this.x(), r = this.y();
    return e !== void 0 && (n += e), i !== void 0 && (r += i), this.setPosition({ x: n, y: r }), this;
  }
  _eachAncestorReverse(t, e) {
    var i = [], n = this.getParent(), r, a;
    if (!(e && e._id === this._id)) {
      for (i.unshift(this); n && (!e || n._id !== e._id); )
        i.unshift(n), n = n.parent;
      for (r = i.length, a = 0; a < r; a++)
        t(i[a]);
    }
  }
  rotate(t) {
    return this.rotation(this.rotation() + t), this;
  }
  moveToTop() {
    if (!this.parent)
      return W.Util.warn("Node has no parent. moveToTop function is ignored."), !1;
    var t = this.index, e = this.parent.getChildren().length;
    return t < e - 1 ? (this.parent.children.splice(t, 1), this.parent.children.push(this), this.parent._setChildrenIndices(), !0) : !1;
  }
  moveUp() {
    if (!this.parent)
      return W.Util.warn("Node has no parent. moveUp function is ignored."), !1;
    var t = this.index, e = this.parent.getChildren().length;
    return t < e - 1 ? (this.parent.children.splice(t, 1), this.parent.children.splice(t + 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
  }
  moveDown() {
    if (!this.parent)
      return W.Util.warn("Node has no parent. moveDown function is ignored."), !1;
    var t = this.index;
    return t > 0 ? (this.parent.children.splice(t, 1), this.parent.children.splice(t - 1, 0, this), this.parent._setChildrenIndices(), !0) : !1;
  }
  moveToBottom() {
    if (!this.parent)
      return W.Util.warn("Node has no parent. moveToBottom function is ignored."), !1;
    var t = this.index;
    return t > 0 ? (this.parent.children.splice(t, 1), this.parent.children.unshift(this), this.parent._setChildrenIndices(), !0) : !1;
  }
  setZIndex(t) {
    if (!this.parent)
      return W.Util.warn("Node has no parent. zIndex parameter is ignored."), this;
    (t < 0 || t >= this.parent.children.length) && W.Util.warn("Unexpected value " + t + " for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to " + (this.parent.children.length - 1) + ".");
    var e = this.index;
    return this.parent.children.splice(e, 1), this.parent.children.splice(t, 0, this), this.parent._setChildrenIndices(), this;
  }
  getAbsoluteOpacity() {
    return this._getCache(rn, this._getAbsoluteOpacity);
  }
  _getAbsoluteOpacity() {
    var t = this.opacity(), e = this.getParent();
    return e && !e._isUnderCache && (t *= e.getAbsoluteOpacity()), t;
  }
  moveTo(t) {
    return this.getParent() !== t && (this._remove(), t.add(this)), this;
  }
  toObject() {
    var t = this.getAttrs(), e, i, n, r, a;
    const o = {
      attrs: {},
      className: this.getClassName()
    };
    for (e in t)
      i = t[e], a = W.Util.isObject(i) && !W.Util._isPlainObject(i) && !W.Util._isArray(i), !a && (n = typeof this[e] == "function" && this[e], delete t[e], r = n ? n.call(this) : null, t[e] = i, r !== i && (o.attrs[e] = i));
    return W.Util._prepareToStringify(o);
  }
  toJSON() {
    return JSON.stringify(this.toObject());
  }
  getParent() {
    return this.parent;
  }
  findAncestors(t, e, i) {
    var n = [];
    e && this._isMatch(t) && n.push(this);
    for (var r = this.parent; r; ) {
      if (r === i)
        return n;
      r._isMatch(t) && n.push(r), r = r.parent;
    }
    return n;
  }
  isAncestorOf(t) {
    return !1;
  }
  findAncestor(t, e, i) {
    return this.findAncestors(t, e, i)[0];
  }
  _isMatch(t) {
    if (!t)
      return !1;
    if (typeof t == "function")
      return t(this);
    var e = t.replace(/ /g, "").split(","), i = e.length, n, r;
    for (n = 0; n < i; n++)
      if (r = e[n], W.Util.isValidSelector(r) || (W.Util.warn('Selector "' + r + '" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'), W.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'), W.Util.warn("Konva is awesome, right?")), r.charAt(0) === "#") {
        if (this.id() === r.slice(1))
          return !0;
      } else if (r.charAt(0) === ".") {
        if (this.hasName(r.slice(1)))
          return !0;
      } else if (this.className === r || this.nodeType === r)
        return !0;
    return !1;
  }
  getLayer() {
    var t = this.getParent();
    return t ? t.getLayer() : null;
  }
  getStage() {
    return this._getCache(Yr, this._getStage);
  }
  _getStage() {
    var t = this.getParent();
    return t ? t.getStage() : null;
  }
  fire(t, e = {}, i) {
    return e.target = e.target || this, i ? this._fireAndBubble(t, e) : this._fire(t, e), this;
  }
  getAbsoluteTransform(t) {
    return t ? this._getAbsoluteTransform(t) : this._getCache(Wt, this._getAbsoluteTransform);
  }
  _getAbsoluteTransform(t) {
    var e;
    if (t)
      return e = new W.Transform(), this._eachAncestorReverse(function(n) {
        var r = n.transformsEnabled();
        r === "all" ? e.multiply(n.getTransform()) : r === "position" && e.translate(n.x() - n.offsetX(), n.y() - n.offsetY());
      }, t), e;
    e = this._cache.get(Wt) || new W.Transform(), this.parent ? this.parent.getAbsoluteTransform().copyInto(e) : e.reset();
    var i = this.transformsEnabled();
    if (i === "all")
      e.multiply(this.getTransform());
    else if (i === "position") {
      const n = this.attrs.x || 0, r = this.attrs.y || 0, a = this.attrs.offsetX || 0, o = this.attrs.offsetY || 0;
      e.translate(n - a, r - o);
    }
    return e.dirty = !1, e;
  }
  getAbsoluteScale(t) {
    for (var e = this; e; )
      e._isUnderCache && (t = e), e = e.getParent();
    const n = this.getAbsoluteTransform(t).decompose();
    return {
      x: n.scaleX,
      y: n.scaleY
    };
  }
  getAbsoluteRotation() {
    return this.getAbsoluteTransform().decompose().rotation;
  }
  getTransform() {
    return this._getCache(he, this._getTransform);
  }
  _getTransform() {
    var t, e, i = this._cache.get(he) || new W.Transform();
    i.reset();
    var n = this.x(), r = this.y(), a = se.Konva.getAngle(this.rotation()), o = (t = this.attrs.scaleX) !== null && t !== void 0 ? t : 1, h = (e = this.attrs.scaleY) !== null && e !== void 0 ? e : 1, l = this.attrs.skewX || 0, A = this.attrs.skewY || 0, u = this.attrs.offsetX || 0, f = this.attrs.offsetY || 0;
    return (n !== 0 || r !== 0) && i.translate(n, r), a !== 0 && i.rotate(a), (l !== 0 || A !== 0) && i.skew(l, A), (o !== 1 || h !== 1) && i.scale(o, h), (u !== 0 || f !== 0) && i.translate(-1 * u, -1 * f), i.dirty = !1, i;
  }
  clone(t) {
    var e = W.Util.cloneObject(this.attrs), i, n, r, a, o;
    for (i in t)
      e[i] = t[i];
    var h = new this.constructor(e);
    for (i in this.eventListeners)
      for (n = this.eventListeners[i], r = n.length, a = 0; a < r; a++)
        o = n[a], o.name.indexOf(el) < 0 && (h.eventListeners[i] || (h.eventListeners[i] = []), h.eventListeners[i].push(o));
    return h;
  }
  _toKonvaCanvas(t) {
    t = t || {};
    var e = this.getClientRect(), i = this.getStage(), n = t.x !== void 0 ? t.x : Math.floor(e.x), r = t.y !== void 0 ? t.y : Math.floor(e.y), a = t.pixelRatio || 1, o = new mi.SceneCanvas({
      width: t.width || Math.ceil(e.width) || (i ? i.width() : 0),
      height: t.height || Math.ceil(e.height) || (i ? i.height() : 0),
      pixelRatio: a
    }), h = o.getContext();
    const l = new mi.SceneCanvas({
      width: o.width / o.pixelRatio + Math.abs(n),
      height: o.height / o.pixelRatio + Math.abs(r),
      pixelRatio: o.pixelRatio
    });
    return t.imageSmoothingEnabled === !1 && (h._context.imageSmoothingEnabled = !1), h.save(), (n || r) && h.translate(-1 * n, -1 * r), this.drawScene(o, void 0, l), h.restore(), o;
  }
  toCanvas(t) {
    return this._toKonvaCanvas(t)._canvas;
  }
  toDataURL(t) {
    t = t || {};
    var e = t.mimeType || null, i = t.quality || null, n = this._toKonvaCanvas(t).toDataURL(e, i);
    return t.callback && t.callback(n), n;
  }
  toImage(t) {
    return new Promise((e, i) => {
      try {
        const n = t == null ? void 0 : t.callback;
        n && delete t.callback, W.Util._urlToImage(this.toDataURL(t), function(r) {
          e(r), n == null || n(r);
        });
      } catch (n) {
        i(n);
      }
    });
  }
  toBlob(t) {
    return new Promise((e, i) => {
      try {
        const n = t == null ? void 0 : t.callback;
        n && delete t.callback, this.toCanvas(t).toBlob((r) => {
          e(r), n == null || n(r);
        }, t == null ? void 0 : t.mimeType, t == null ? void 0 : t.quality);
      } catch (n) {
        i(n);
      }
    });
  }
  setSize(t) {
    return this.width(t.width), this.height(t.height), this;
  }
  getSize() {
    return {
      width: this.width(),
      height: this.height()
    };
  }
  getClassName() {
    return this.className || this.nodeType;
  }
  getType() {
    return this.nodeType;
  }
  getDragDistance() {
    return this.attrs.dragDistance !== void 0 ? this.attrs.dragDistance : this.parent ? this.parent.getDragDistance() : se.Konva.dragDistance;
  }
  _off(t, e, i) {
    var n = this.eventListeners[t], r, a, o;
    for (r = 0; r < n.length; r++)
      if (a = n[r].name, o = n[r].handler, (a !== "konva" || e === "konva") && (!e || a === e) && (!i || i === o)) {
        if (n.splice(r, 1), n.length === 0) {
          delete this.eventListeners[t];
          break;
        }
        r--;
      }
  }
  _fireChangeEvent(t, e, i) {
    this._fire(t + Jh, {
      oldVal: e,
      newVal: i
    });
  }
  addName(t) {
    if (!this.hasName(t)) {
      var e = this.name(), i = e ? e + " " + t : t;
      this.name(i);
    }
    return this;
  }
  hasName(t) {
    if (!t)
      return !1;
    const e = this.name();
    if (!e)
      return !1;
    var i = (e || "").split(/\s/g);
    return i.indexOf(t) !== -1;
  }
  removeName(t) {
    var e = (this.name() || "").split(/\s/g), i = e.indexOf(t);
    return i !== -1 && (e.splice(i, 1), this.name(e.join(" "))), this;
  }
  setAttr(t, e) {
    var i = this[$r + W.Util._capitalize(t)];
    return W.Util._isFunction(i) ? i.call(this, e) : this._setAttr(t, e), this;
  }
  _requestDraw() {
    if (se.Konva.autoDrawEnabled) {
      const t = this.getLayer() || this.getStage();
      t == null || t.batchDraw();
    }
  }
  _setAttr(t, e) {
    var i = this.attrs[t];
    i === e && !W.Util.isObject(e) || (e == null ? delete this.attrs[t] : this.attrs[t] = e, this._shouldFireChangeEvents && this._fireChangeEvent(t, i, e), this._requestDraw());
  }
  _setComponentAttr(t, e, i) {
    var n;
    i !== void 0 && (n = this.attrs[t], n || (this.attrs[t] = this.getAttr(t)), this.attrs[t][e] = i, this._fireChangeEvent(t, n, i));
  }
  _fireAndBubble(t, e, i) {
    e && this.nodeType === Wr && (e.target = this);
    var n = (t === Hr || t === Vr) && (i && (this === i || this.isAncestorOf && this.isAncestorOf(i)) || this.nodeType === "Stage" && !i);
    if (!n) {
      this._fire(t, e);
      var r = (t === Hr || t === Vr) && i && i.isAncestorOf && i.isAncestorOf(this) && !i.isAncestorOf(this.parent);
      (e && !e.cancelBubble || !e) && this.parent && this.parent.isListening() && !r && (i && i.parent ? this._fireAndBubble.call(this.parent, t, e, i) : this._fireAndBubble.call(this.parent, t, e));
    }
  }
  _getProtoListeners(t) {
    var e, i, n;
    const r = (e = this._cache.get(Wi)) !== null && e !== void 0 ? e : {};
    let a = r == null ? void 0 : r[t];
    if (a === void 0) {
      a = [];
      let o = Object.getPrototypeOf(this);
      for (; o; ) {
        const h = (n = (i = o.eventListeners) === null || i === void 0 ? void 0 : i[t]) !== null && n !== void 0 ? n : [];
        a.push(...h), o = Object.getPrototypeOf(o);
      }
      r[t] = a, this._cache.set(Wi, r);
    }
    return a;
  }
  _fire(t, e) {
    e = e || {}, e.currentTarget = this, e.type = t;
    const i = this._getProtoListeners(t);
    if (i)
      for (var n = 0; n < i.length; n++)
        i[n].handler.call(this, e);
    const r = this.eventListeners[t];
    if (r)
      for (var n = 0; n < r.length; n++)
        r[n].handler.call(this, e);
  }
  draw() {
    return this.drawScene(), this.drawHit(), this;
  }
  _createDragElement(t) {
    var e = t ? t.pointerId : void 0, i = this.getStage(), n = this.getAbsolutePosition();
    if (i) {
      var r = i._getPointerById(e) || i._changedPointerPositions[0] || n;
      Ct.DD._dragElements.set(this._id, {
        node: this,
        startPointerPos: r,
        offset: {
          x: r.x - n.x,
          y: r.y - n.y
        },
        dragStatus: "ready",
        pointerId: e
      });
    }
  }
  startDrag(t, e = !0) {
    Ct.DD._dragElements.has(this._id) || this._createDragElement(t);
    const i = Ct.DD._dragElements.get(this._id);
    i.dragStatus = "dragging", this.fire("dragstart", {
      type: "dragstart",
      target: this,
      evt: t && t.evt
    }, e);
  }
  _setDragPosition(t, e) {
    const i = this.getStage()._getPointerById(e.pointerId);
    if (i) {
      var n = {
        x: i.x - e.offset.x,
        y: i.y - e.offset.y
      }, r = this.dragBoundFunc();
      if (r !== void 0) {
        const a = r.call(this, n, t);
        a ? n = a : W.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.");
      }
      (!this._lastPos || this._lastPos.x !== n.x || this._lastPos.y !== n.y) && (this.setAbsolutePosition(n), this._requestDraw()), this._lastPos = n;
    }
  }
  stopDrag(t) {
    const e = Ct.DD._dragElements.get(this._id);
    e && (e.dragStatus = "stopped"), Ct.DD._endDragBefore(t), Ct.DD._endDragAfter(t);
  }
  setDraggable(t) {
    this._setAttr("draggable", t), this._dragChange();
  }
  isDragging() {
    const t = Ct.DD._dragElements.get(this._id);
    return t ? t.dragStatus === "dragging" : !1;
  }
  _listenDrag() {
    this._dragCleanup(), this.on("mousedown.konva touchstart.konva", function(t) {
      var e = t.evt.button !== void 0, i = !e || se.Konva.dragButtons.indexOf(t.evt.button) >= 0;
      if (i && !this.isDragging()) {
        var n = !1;
        Ct.DD._dragElements.forEach((r) => {
          this.isAncestorOf(r.node) && (n = !0);
        }), n || this._createDragElement(t);
      }
    });
  }
  _dragChange() {
    if (this.attrs.draggable)
      this._listenDrag();
    else {
      this._dragCleanup();
      var t = this.getStage();
      if (!t)
        return;
      const e = Ct.DD._dragElements.get(this._id), i = e && e.dragStatus === "dragging", n = e && e.dragStatus === "ready";
      i ? this.stopDrag() : n && Ct.DD._dragElements.delete(this._id);
    }
  }
  _dragCleanup() {
    this.off("mousedown.konva"), this.off("touchstart.konva");
  }
  isClientRectOnScreen(t = { x: 0, y: 0 }) {
    const e = this.getStage();
    if (!e)
      return !1;
    const i = {
      x: -t.x,
      y: -t.y,
      width: e.width() + 2 * t.x,
      height: e.height() + 2 * t.y
    };
    return W.Util.haveIntersection(i, this.getClientRect());
  }
  static create(t, e) {
    return W.Util._isString(t) && (t = JSON.parse(t)), this._createNode(t, e);
  }
  static _createNode(t, e) {
    var i = qs.prototype.getClassName.call(t), n = t.children, r, a, o;
    e && (t.attrs.container = e), se.Konva[i] || (W.Util.warn('Can not find a node with class name "' + i + '". Fallback to "Shape".'), i = "Shape");
    const h = se.Konva[i];
    if (r = new h(t.attrs), n)
      for (a = n.length, o = 0; o < a; o++)
        r.add(qs._createNode(n[o]));
    return r;
  }
};
rt.Node = U;
U.prototype.nodeType = "Node";
U.prototype._attrsAffectingSize = [];
U.prototype.eventListeners = {};
U.prototype.on.call(U.prototype, nl, function() {
  if (this._batchingTransformChange) {
    this._needClearTransformCache = !0;
    return;
  }
  this._clearCache(he), this._clearSelfAndDescendantCache(Wt);
});
U.prototype.on.call(U.prototype, "visibleChange.konva", function() {
  this._clearSelfAndDescendantCache(js);
});
U.prototype.on.call(U.prototype, "listeningChange.konva", function() {
  this._clearSelfAndDescendantCache(Xs);
});
U.prototype.on.call(U.prototype, "opacityChange.konva", function() {
  this._clearSelfAndDescendantCache(rn);
});
const J = Oi.Factory.addGetterSetter;
J(U, "zIndex");
J(U, "absolutePosition");
J(U, "position");
J(U, "x", 0, (0, ct.getNumberValidator)());
J(U, "y", 0, (0, ct.getNumberValidator)());
J(U, "globalCompositeOperation", "source-over", (0, ct.getStringValidator)());
J(U, "opacity", 1, (0, ct.getNumberValidator)());
J(U, "name", "", (0, ct.getStringValidator)());
J(U, "id", "", (0, ct.getStringValidator)());
J(U, "rotation", 0, (0, ct.getNumberValidator)());
Oi.Factory.addComponentsGetterSetter(U, "scale", ["x", "y"]);
J(U, "scaleX", 1, (0, ct.getNumberValidator)());
J(U, "scaleY", 1, (0, ct.getNumberValidator)());
Oi.Factory.addComponentsGetterSetter(U, "skew", ["x", "y"]);
J(U, "skewX", 0, (0, ct.getNumberValidator)());
J(U, "skewY", 0, (0, ct.getNumberValidator)());
Oi.Factory.addComponentsGetterSetter(U, "offset", ["x", "y"]);
J(U, "offsetX", 0, (0, ct.getNumberValidator)());
J(U, "offsetY", 0, (0, ct.getNumberValidator)());
J(U, "dragDistance", null, (0, ct.getNumberValidator)());
J(U, "width", 0, (0, ct.getNumberValidator)());
J(U, "height", 0, (0, ct.getNumberValidator)());
J(U, "listening", !0, (0, ct.getBooleanValidator)());
J(U, "preventDefault", !0, (0, ct.getBooleanValidator)());
J(U, "filters", null, function(s) {
  return this._filterUpToDate = !1, s;
});
J(U, "visible", !0, (0, ct.getBooleanValidator)());
J(U, "transformsEnabled", "all", (0, ct.getStringValidator)());
J(U, "size");
J(U, "dragBoundFunc");
J(U, "draggable", !1, (0, ct.getBooleanValidator)());
Oi.Factory.backCompat(U, {
  rotateDeg: "rotate",
  setRotationDeg: "setRotation",
  getRotationDeg: "getRotation"
});
var bt = {};
Object.defineProperty(bt, "__esModule", { value: !0 });
bt.releaseCapture = bt.setPointerCapture = bt.hasPointerCapture = bt.createEvent = bt.getCapturedShape = void 0;
const rl = $, Ei = /* @__PURE__ */ new Map(), io = rl.Konva._global.PointerEvent !== void 0;
function al(s) {
  return Ei.get(s);
}
bt.getCapturedShape = al;
function dr(s) {
  return {
    evt: s,
    pointerId: s.pointerId
  };
}
bt.createEvent = dr;
function ol(s, t) {
  return Ei.get(s) === t;
}
bt.hasPointerCapture = ol;
function hl(s, t) {
  no(s), t.getStage() && (Ei.set(s, t), io && t._fire("gotpointercapture", dr(new PointerEvent("gotpointercapture"))));
}
bt.setPointerCapture = hl;
function no(s, t) {
  const e = Ei.get(s);
  if (!e)
    return;
  const i = e.getStage();
  i && i.content, Ei.delete(s), io && e._fire("lostpointercapture", dr(new PointerEvent("lostpointercapture")));
}
bt.releaseCapture = no;
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.Shape = s.shapes = void 0;
  const t = $, e = et, i = V, n = rt, r = O, a = $, o = bt;
  var h = "hasShadow", l = "shadowRGBA", A = "patternImage", u = "linearGradient", f = "radialGradient";
  let c;
  function d() {
    return c || (c = e.Util.createCanvasElement().getContext("2d"), c);
  }
  s.shapes = {};
  function p(E) {
    const S = this.attrs.fillRule;
    S ? E.fill(S) : E.fill();
  }
  function m(E) {
    E.stroke();
  }
  function v(E) {
    E.fill();
  }
  function _(E) {
    E.stroke();
  }
  function g() {
    this._clearCache(h);
  }
  function y() {
    this._clearCache(l);
  }
  function x() {
    this._clearCache(A);
  }
  function b() {
    this._clearCache(u);
  }
  function C() {
    this._clearCache(f);
  }
  class w extends n.Node {
    constructor(S) {
      super(S);
      let P;
      for (; P = e.Util.getRandomColor(), !(P && !(P in s.shapes)); )
        ;
      this.colorKey = P, s.shapes[P] = this;
    }
    getContext() {
      return e.Util.warn("shape.getContext() method is deprecated. Please do not use it."), this.getLayer().getContext();
    }
    getCanvas() {
      return e.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."), this.getLayer().getCanvas();
    }
    getSceneFunc() {
      return this.attrs.sceneFunc || this._sceneFunc;
    }
    getHitFunc() {
      return this.attrs.hitFunc || this._hitFunc;
    }
    hasShadow() {
      return this._getCache(h, this._hasShadow);
    }
    _hasShadow() {
      return this.shadowEnabled() && this.shadowOpacity() !== 0 && !!(this.shadowColor() || this.shadowBlur() || this.shadowOffsetX() || this.shadowOffsetY());
    }
    _getFillPattern() {
      return this._getCache(A, this.__getFillPattern);
    }
    __getFillPattern() {
      if (this.fillPatternImage()) {
        var S = d();
        const P = S.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || "repeat");
        if (P && P.setTransform) {
          const k = new e.Transform();
          k.translate(this.fillPatternX(), this.fillPatternY()), k.rotate(t.Konva.getAngle(this.fillPatternRotation())), k.scale(this.fillPatternScaleX(), this.fillPatternScaleY()), k.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
          const F = k.getMatrix(), L = typeof DOMMatrix > "u" ? {
            a: F[0],
            b: F[1],
            c: F[2],
            d: F[3],
            e: F[4],
            f: F[5]
          } : new DOMMatrix(F);
          P.setTransform(L);
        }
        return P;
      }
    }
    _getLinearGradient() {
      return this._getCache(u, this.__getLinearGradient);
    }
    __getLinearGradient() {
      var S = this.fillLinearGradientColorStops();
      if (S) {
        for (var P = d(), k = this.fillLinearGradientStartPoint(), F = this.fillLinearGradientEndPoint(), L = P.createLinearGradient(k.x, k.y, F.x, F.y), I = 0; I < S.length; I += 2)
          L.addColorStop(S[I], S[I + 1]);
        return L;
      }
    }
    _getRadialGradient() {
      return this._getCache(f, this.__getRadialGradient);
    }
    __getRadialGradient() {
      var S = this.fillRadialGradientColorStops();
      if (S) {
        for (var P = d(), k = this.fillRadialGradientStartPoint(), F = this.fillRadialGradientEndPoint(), L = P.createRadialGradient(k.x, k.y, this.fillRadialGradientStartRadius(), F.x, F.y, this.fillRadialGradientEndRadius()), I = 0; I < S.length; I += 2)
          L.addColorStop(S[I], S[I + 1]);
        return L;
      }
    }
    getShadowRGBA() {
      return this._getCache(l, this._getShadowRGBA);
    }
    _getShadowRGBA() {
      if (this.hasShadow()) {
        var S = e.Util.colorToRGBA(this.shadowColor());
        if (S)
          return "rgba(" + S.r + "," + S.g + "," + S.b + "," + S.a * (this.shadowOpacity() || 1) + ")";
      }
    }
    hasFill() {
      return this._calculate("hasFill", [
        "fillEnabled",
        "fill",
        "fillPatternImage",
        "fillLinearGradientColorStops",
        "fillRadialGradientColorStops"
      ], () => this.fillEnabled() && !!(this.fill() || this.fillPatternImage() || this.fillLinearGradientColorStops() || this.fillRadialGradientColorStops()));
    }
    hasStroke() {
      return this._calculate("hasStroke", [
        "strokeEnabled",
        "strokeWidth",
        "stroke",
        "strokeLinearGradientColorStops"
      ], () => this.strokeEnabled() && this.strokeWidth() && !!(this.stroke() || this.strokeLinearGradientColorStops()));
    }
    hasHitStroke() {
      const S = this.hitStrokeWidth();
      return S === "auto" ? this.hasStroke() : this.strokeEnabled() && !!S;
    }
    intersects(S) {
      var P = this.getStage();
      if (!P)
        return !1;
      const k = P.bufferHitCanvas;
      return k.getContext().clear(), this.drawHit(k, void 0, !0), k.context.getImageData(Math.round(S.x), Math.round(S.y), 1, 1).data[3] > 0;
    }
    destroy() {
      return n.Node.prototype.destroy.call(this), delete s.shapes[this.colorKey], delete this.colorKey, this;
    }
    _useBufferCanvas(S) {
      var P;
      if (!((P = this.attrs.perfectDrawEnabled) !== null && P !== void 0 ? P : !0))
        return !1;
      const F = S || this.hasFill(), L = this.hasStroke(), I = this.getAbsoluteOpacity() !== 1;
      if (F && L && I)
        return !0;
      const z = this.hasShadow(), T = this.shadowForStrokeEnabled();
      return !!(F && L && z && T);
    }
    setStrokeHitEnabled(S) {
      e.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."), S ? this.hitStrokeWidth("auto") : this.hitStrokeWidth(0);
    }
    getStrokeHitEnabled() {
      return this.hitStrokeWidth() !== 0;
    }
    getSelfRect() {
      var S = this.size();
      return {
        x: this._centroid ? -S.width / 2 : 0,
        y: this._centroid ? -S.height / 2 : 0,
        width: S.width,
        height: S.height
      };
    }
    getClientRect(S = {}) {
      const P = S.skipTransform, k = S.relativeTo, F = this.getSelfRect(), I = !S.skipStroke && this.hasStroke() && this.strokeWidth() || 0, z = F.width + I, T = F.height + I, G = !S.skipShadow && this.hasShadow(), H = G ? this.shadowOffsetX() : 0, R = G ? this.shadowOffsetY() : 0, N = z + Math.abs(H), q = T + Math.abs(R), it = G && this.shadowBlur() || 0, tt = N + it * 2, Ut = q + it * 2, dt = {
        width: tt,
        height: Ut,
        x: -(I / 2 + it) + Math.min(H, 0) + F.x,
        y: -(I / 2 + it) + Math.min(R, 0) + F.y
      };
      return P ? dt : this._transformedRect(dt, k);
    }
    drawScene(S, P, k) {
      var F = this.getLayer(), L = S || F.getCanvas(), I = L.getContext(), z = this._getCanvasCache(), T = this.getSceneFunc(), G = this.hasShadow(), H, R, N = L.isCache, q = P === this;
      if (!this.isVisible() && !q)
        return this;
      if (z) {
        I.save();
        var it = this.getAbsoluteTransform(P).getMatrix();
        return I.transform(it[0], it[1], it[2], it[3], it[4], it[5]), this._drawCachedSceneCanvas(I), I.restore(), this;
      }
      if (!T)
        return this;
      if (I.save(), this._useBufferCanvas() && !N) {
        H = this.getStage();
        const dt = k || H.bufferCanvas;
        R = dt.getContext(), R.clear(), R.save(), R._applyLineJoin(this);
        var tt = this.getAbsoluteTransform(P).getMatrix();
        R.transform(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5]), T.call(this, R, this), R.restore();
        var Ut = dt.pixelRatio;
        G && I._applyShadow(this), I._applyOpacity(this), I._applyGlobalCompositeOperation(this), I.drawImage(dt._canvas, 0, 0, dt.width / Ut, dt.height / Ut);
      } else {
        if (I._applyLineJoin(this), !q) {
          var tt = this.getAbsoluteTransform(P).getMatrix();
          I.transform(tt[0], tt[1], tt[2], tt[3], tt[4], tt[5]), I._applyOpacity(this), I._applyGlobalCompositeOperation(this);
        }
        G && I._applyShadow(this), T.call(this, I, this);
      }
      return I.restore(), this;
    }
    drawHit(S, P, k = !1) {
      if (!this.shouldDrawHit(P, k))
        return this;
      var F = this.getLayer(), L = S || F.hitCanvas, I = L && L.getContext(), z = this.hitFunc() || this.sceneFunc(), T = this._getCanvasCache(), G = T && T.hit;
      if (this.colorKey || e.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"), G) {
        I.save();
        var H = this.getAbsoluteTransform(P).getMatrix();
        return I.transform(H[0], H[1], H[2], H[3], H[4], H[5]), this._drawCachedHitCanvas(I), I.restore(), this;
      }
      if (!z)
        return this;
      if (I.save(), I._applyLineJoin(this), !(this === P)) {
        var N = this.getAbsoluteTransform(P).getMatrix();
        I.transform(N[0], N[1], N[2], N[3], N[4], N[5]);
      }
      return z.call(this, I, this), I.restore(), this;
    }
    drawHitFromCache(S = 0) {
      var P = this._getCanvasCache(), k = this._getCachedSceneCanvas(), F = P.hit, L = F.getContext(), I = F.getWidth(), z = F.getHeight(), T, G, H, R, N, q;
      L.clear(), L.drawImage(k._canvas, 0, 0, I, z);
      try {
        for (T = L.getImageData(0, 0, I, z), G = T.data, H = G.length, R = e.Util._hexToRgb(this.colorKey), N = 0; N < H; N += 4)
          q = G[N + 3], q > S ? (G[N] = R.r, G[N + 1] = R.g, G[N + 2] = R.b, G[N + 3] = 255) : G[N + 3] = 0;
        L.putImageData(T, 0, 0);
      } catch (it) {
        e.Util.error("Unable to draw hit graph from cached scene canvas. " + it.message);
      }
      return this;
    }
    hasPointerCapture(S) {
      return o.hasPointerCapture(S, this);
    }
    setPointerCapture(S) {
      o.setPointerCapture(S, this);
    }
    releaseCapture(S) {
      o.releaseCapture(S, this);
    }
  }
  s.Shape = w, w.prototype._fillFunc = p, w.prototype._strokeFunc = m, w.prototype._fillFuncHit = v, w.prototype._strokeFuncHit = _, w.prototype._centroid = !1, w.prototype.nodeType = "Shape", (0, a._registerNode)(w), w.prototype.eventListeners = {}, w.prototype.on.call(w.prototype, "shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", g), w.prototype.on.call(w.prototype, "shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva", y), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva", x), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva", b), w.prototype.on.call(w.prototype, "fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva", C), i.Factory.addGetterSetter(w, "stroke", void 0, (0, r.getStringOrGradientValidator)()), i.Factory.addGetterSetter(w, "strokeWidth", 2, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillAfterStrokeEnabled", !1), i.Factory.addGetterSetter(w, "hitStrokeWidth", "auto", (0, r.getNumberOrAutoValidator)()), i.Factory.addGetterSetter(w, "strokeHitEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "perfectDrawEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "shadowForStrokeEnabled", !0, (0, r.getBooleanValidator)()), i.Factory.addGetterSetter(w, "lineJoin"), i.Factory.addGetterSetter(w, "lineCap"), i.Factory.addGetterSetter(w, "sceneFunc"), i.Factory.addGetterSetter(w, "hitFunc"), i.Factory.addGetterSetter(w, "dash"), i.Factory.addGetterSetter(w, "dashOffset", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowColor", void 0, (0, r.getStringValidator)()), i.Factory.addGetterSetter(w, "shadowBlur", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowOpacity", 1, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "shadowOffset", ["x", "y"]), i.Factory.addGetterSetter(w, "shadowOffsetX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "shadowOffsetY", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternImage"), i.Factory.addGetterSetter(w, "fill", void 0, (0, r.getStringOrGradientValidator)()), i.Factory.addGetterSetter(w, "fillPatternX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternY", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillLinearGradientColorStops"), i.Factory.addGetterSetter(w, "strokeLinearGradientColorStops"), i.Factory.addGetterSetter(w, "fillRadialGradientStartRadius", 0), i.Factory.addGetterSetter(w, "fillRadialGradientEndRadius", 0), i.Factory.addGetterSetter(w, "fillRadialGradientColorStops"), i.Factory.addGetterSetter(w, "fillPatternRepeat", "repeat"), i.Factory.addGetterSetter(w, "fillEnabled", !0), i.Factory.addGetterSetter(w, "strokeEnabled", !0), i.Factory.addGetterSetter(w, "shadowEnabled", !0), i.Factory.addGetterSetter(w, "dashEnabled", !0), i.Factory.addGetterSetter(w, "strokeScaleEnabled", !0), i.Factory.addGetterSetter(w, "fillPriority", "color"), i.Factory.addComponentsGetterSetter(w, "fillPatternOffset", ["x", "y"]), i.Factory.addGetterSetter(w, "fillPatternOffsetX", 0, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternOffsetY", 0, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "fillPatternScale", ["x", "y"]), i.Factory.addGetterSetter(w, "fillPatternScaleX", 1, (0, r.getNumberValidator)()), i.Factory.addGetterSetter(w, "fillPatternScaleY", 1, (0, r.getNumberValidator)()), i.Factory.addComponentsGetterSetter(w, "fillLinearGradientStartPoint", [
    "x",
    "y"
  ]), i.Factory.addComponentsGetterSetter(w, "strokeLinearGradientStartPoint", [
    "x",
    "y"
  ]), i.Factory.addGetterSetter(w, "fillLinearGradientStartPointX", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientStartPointX", 0), i.Factory.addGetterSetter(w, "fillLinearGradientStartPointY", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientStartPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillLinearGradientEndPoint", [
    "x",
    "y"
  ]), i.Factory.addComponentsGetterSetter(w, "strokeLinearGradientEndPoint", [
    "x",
    "y"
  ]), i.Factory.addGetterSetter(w, "fillLinearGradientEndPointX", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientEndPointX", 0), i.Factory.addGetterSetter(w, "fillLinearGradientEndPointY", 0), i.Factory.addGetterSetter(w, "strokeLinearGradientEndPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillRadialGradientStartPoint", [
    "x",
    "y"
  ]), i.Factory.addGetterSetter(w, "fillRadialGradientStartPointX", 0), i.Factory.addGetterSetter(w, "fillRadialGradientStartPointY", 0), i.Factory.addComponentsGetterSetter(w, "fillRadialGradientEndPoint", [
    "x",
    "y"
  ]), i.Factory.addGetterSetter(w, "fillRadialGradientEndPointX", 0), i.Factory.addGetterSetter(w, "fillRadialGradientEndPointY", 0), i.Factory.addGetterSetter(w, "fillPatternRotation", 0), i.Factory.addGetterSetter(w, "fillRule", void 0, (0, r.getStringValidator)()), i.Factory.backCompat(w, {
    dashArray: "dash",
    getDashArray: "getDash",
    setDashArray: "getDash",
    drawFunc: "sceneFunc",
    getDrawFunc: "getSceneFunc",
    setDrawFunc: "setSceneFunc",
    drawHitFunc: "hitFunc",
    getDrawHitFunc: "getHitFunc",
    setDrawHitFunc: "setHitFunc"
  });
})(ft);
Object.defineProperty(Cn, "__esModule", { value: !0 });
var Ni = Cn.Circle = void 0;
const ll = V, Al = ft, cl = O, dl = $;
class oi extends Al.Shape {
  _sceneFunc(t) {
    t.beginPath(), t.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, !1), t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    return this.radius() * 2;
  }
  getHeight() {
    return this.radius() * 2;
  }
  setWidth(t) {
    this.radius() !== t / 2 && this.radius(t / 2);
  }
  setHeight(t) {
    this.radius() !== t / 2 && this.radius(t / 2);
  }
}
Ni = Cn.Circle = oi;
oi.prototype._centroid = !0;
oi.prototype.className = "Circle";
oi.prototype._attrsAffectingSize = ["radius"];
(0, dl._registerNode)(oi);
ll.Factory.addGetterSetter(oi, "radius", 0, (0, cl.getNumberValidator)());
var Gi = {};
Object.defineProperty(Gi, "__esModule", { value: !0 });
var Fn = Gi.Line = void 0;
const kn = V, ul = ft, so = O, fl = $;
function Qs(s, t, e, i, n, r, a) {
  var o = Math.sqrt(Math.pow(e - s, 2) + Math.pow(i - t, 2)), h = Math.sqrt(Math.pow(n - e, 2) + Math.pow(r - i, 2)), l = a * o / (o + h), A = a * h / (o + h), u = e - l * (n - s), f = i - l * (r - t), c = e + A * (n - s), d = i + A * (r - t);
  return [u, f, c, d];
}
function Xr(s, t) {
  var e = s.length, i = [], n, r;
  for (n = 2; n < e - 2; n += 2)
    r = Qs(s[n - 2], s[n - 1], s[n], s[n + 1], s[n + 2], s[n + 3], t), !isNaN(r[0]) && (i.push(r[0]), i.push(r[1]), i.push(s[n]), i.push(s[n + 1]), i.push(r[2]), i.push(r[3]));
  return i;
}
class pe extends ul.Shape {
  constructor(t) {
    super(t), this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva", function() {
      this._clearCache("tensionPoints");
    });
  }
  _sceneFunc(t) {
    var e = this.points(), i = e.length, n = this.tension(), r = this.closed(), a = this.bezier(), o, h, l;
    if (i) {
      if (t.beginPath(), t.moveTo(e[0], e[1]), n !== 0 && i > 4) {
        for (o = this.getTensionPoints(), h = o.length, l = r ? 0 : 4, r || t.quadraticCurveTo(o[0], o[1], o[2], o[3]); l < h - 2; )
          t.bezierCurveTo(o[l++], o[l++], o[l++], o[l++], o[l++], o[l++]);
        r || t.quadraticCurveTo(o[h - 2], o[h - 1], e[i - 2], e[i - 1]);
      } else if (a)
        for (l = 2; l < i; )
          t.bezierCurveTo(e[l++], e[l++], e[l++], e[l++], e[l++], e[l++]);
      else
        for (l = 2; l < i; l += 2)
          t.lineTo(e[l], e[l + 1]);
      r ? (t.closePath(), t.fillStrokeShape(this)) : t.strokeShape(this);
    }
  }
  getTensionPoints() {
    return this._getCache("tensionPoints", this._getTensionPoints);
  }
  _getTensionPoints() {
    return this.closed() ? this._getTensionPointsClosed() : Xr(this.points(), this.tension());
  }
  _getTensionPointsClosed() {
    var t = this.points(), e = t.length, i = this.tension(), n = Qs(t[e - 2], t[e - 1], t[0], t[1], t[2], t[3], i), r = Qs(t[e - 4], t[e - 3], t[e - 2], t[e - 1], t[0], t[1], i), a = Xr(t, i), o = [n[2], n[3]].concat(a).concat([
      r[0],
      r[1],
      t[e - 2],
      t[e - 1],
      r[2],
      r[3],
      n[0],
      n[1],
      t[0],
      t[1]
    ]);
    return o;
  }
  getWidth() {
    return this.getSelfRect().width;
  }
  getHeight() {
    return this.getSelfRect().height;
  }
  getSelfRect() {
    var t = this.points();
    if (t.length < 4)
      return {
        x: t[0] || 0,
        y: t[1] || 0,
        width: 0,
        height: 0
      };
    this.tension() !== 0 ? t = [
      t[0],
      t[1],
      ...this._getTensionPoints(),
      t[t.length - 2],
      t[t.length - 1]
    ] : t = this.points();
    for (var e = t[0], i = t[0], n = t[1], r = t[1], a, o, h = 0; h < t.length / 2; h++)
      a = t[h * 2], o = t[h * 2 + 1], e = Math.min(e, a), i = Math.max(i, a), n = Math.min(n, o), r = Math.max(r, o);
    return {
      x: e,
      y: n,
      width: i - e,
      height: r - n
    };
  }
}
Fn = Gi.Line = pe;
pe.prototype.className = "Line";
pe.prototype._attrsAffectingSize = ["points", "bezier", "tension"];
(0, fl._registerNode)(pe);
kn.Factory.addGetterSetter(pe, "closed", !1);
kn.Factory.addGetterSetter(pe, "bezier", !1);
kn.Factory.addGetterSetter(pe, "tension", 0, (0, so.getNumberValidator)());
kn.Factory.addGetterSetter(pe, "points", [], (0, so.getNumberArrayValidator)());
let qt = !1;
const qe = navigator.userAgent, Ju = (s) => qt = s, ro = /iPhone|iPad|iPod|Android/i.test(qe);
let gl = /(?:Android)/.test(qe), pl = /(?:Firefox)/.test(qe);
const yl = /(?:iPad|PlayBook|Tablet)/.test(qe) || gl && !/(?:Mobile)/.test(qe) || pl && /(?:Tablet)/.test(qe) || ro && (window.innerWidth < window.innerHeight ? window.innerWidth : window.innerHeight) > 600, hn = ro || yl;
var hi = {}, ao = {};
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.t2length = s.getQuadraticArcLength = s.getCubicArcLength = s.binomialCoefficients = s.cValues = s.tValues = void 0, s.tValues = [
    [],
    [],
    [
      -0.5773502691896257,
      0.5773502691896257
    ],
    [
      0,
      -0.7745966692414834,
      0.7745966692414834
    ],
    [
      -0.33998104358485626,
      0.33998104358485626,
      -0.8611363115940526,
      0.8611363115940526
    ],
    [
      0,
      -0.5384693101056831,
      0.5384693101056831,
      -0.906179845938664,
      0.906179845938664
    ],
    [
      0.6612093864662645,
      -0.6612093864662645,
      -0.2386191860831969,
      0.2386191860831969,
      -0.932469514203152,
      0.932469514203152
    ],
    [
      0,
      0.4058451513773972,
      -0.4058451513773972,
      -0.7415311855993945,
      0.7415311855993945,
      -0.9491079123427585,
      0.9491079123427585
    ],
    [
      -0.1834346424956498,
      0.1834346424956498,
      -0.525532409916329,
      0.525532409916329,
      -0.7966664774136267,
      0.7966664774136267,
      -0.9602898564975363,
      0.9602898564975363
    ],
    [
      0,
      -0.8360311073266358,
      0.8360311073266358,
      -0.9681602395076261,
      0.9681602395076261,
      -0.3242534234038089,
      0.3242534234038089,
      -0.6133714327005904,
      0.6133714327005904
    ],
    [
      -0.14887433898163122,
      0.14887433898163122,
      -0.4333953941292472,
      0.4333953941292472,
      -0.6794095682990244,
      0.6794095682990244,
      -0.8650633666889845,
      0.8650633666889845,
      -0.9739065285171717,
      0.9739065285171717
    ],
    [
      0,
      -0.26954315595234496,
      0.26954315595234496,
      -0.5190961292068118,
      0.5190961292068118,
      -0.7301520055740494,
      0.7301520055740494,
      -0.8870625997680953,
      0.8870625997680953,
      -0.978228658146057,
      0.978228658146057
    ],
    [
      -0.1252334085114689,
      0.1252334085114689,
      -0.3678314989981802,
      0.3678314989981802,
      -0.5873179542866175,
      0.5873179542866175,
      -0.7699026741943047,
      0.7699026741943047,
      -0.9041172563704749,
      0.9041172563704749,
      -0.9815606342467192,
      0.9815606342467192
    ],
    [
      0,
      -0.2304583159551348,
      0.2304583159551348,
      -0.44849275103644687,
      0.44849275103644687,
      -0.6423493394403402,
      0.6423493394403402,
      -0.8015780907333099,
      0.8015780907333099,
      -0.9175983992229779,
      0.9175983992229779,
      -0.9841830547185881,
      0.9841830547185881
    ],
    [
      -0.10805494870734367,
      0.10805494870734367,
      -0.31911236892788974,
      0.31911236892788974,
      -0.5152486363581541,
      0.5152486363581541,
      -0.6872929048116855,
      0.6872929048116855,
      -0.827201315069765,
      0.827201315069765,
      -0.9284348836635735,
      0.9284348836635735,
      -0.9862838086968123,
      0.9862838086968123
    ],
    [
      0,
      -0.20119409399743451,
      0.20119409399743451,
      -0.3941513470775634,
      0.3941513470775634,
      -0.5709721726085388,
      0.5709721726085388,
      -0.7244177313601701,
      0.7244177313601701,
      -0.8482065834104272,
      0.8482065834104272,
      -0.937273392400706,
      0.937273392400706,
      -0.9879925180204854,
      0.9879925180204854
    ],
    [
      -0.09501250983763744,
      0.09501250983763744,
      -0.2816035507792589,
      0.2816035507792589,
      -0.45801677765722737,
      0.45801677765722737,
      -0.6178762444026438,
      0.6178762444026438,
      -0.755404408355003,
      0.755404408355003,
      -0.8656312023878318,
      0.8656312023878318,
      -0.9445750230732326,
      0.9445750230732326,
      -0.9894009349916499,
      0.9894009349916499
    ],
    [
      0,
      -0.17848418149584785,
      0.17848418149584785,
      -0.3512317634538763,
      0.3512317634538763,
      -0.5126905370864769,
      0.5126905370864769,
      -0.6576711592166907,
      0.6576711592166907,
      -0.7815140038968014,
      0.7815140038968014,
      -0.8802391537269859,
      0.8802391537269859,
      -0.9506755217687678,
      0.9506755217687678,
      -0.9905754753144174,
      0.9905754753144174
    ],
    [
      -0.0847750130417353,
      0.0847750130417353,
      -0.2518862256915055,
      0.2518862256915055,
      -0.41175116146284263,
      0.41175116146284263,
      -0.5597708310739475,
      0.5597708310739475,
      -0.6916870430603532,
      0.6916870430603532,
      -0.8037049589725231,
      0.8037049589725231,
      -0.8926024664975557,
      0.8926024664975557,
      -0.9558239495713977,
      0.9558239495713977,
      -0.9915651684209309,
      0.9915651684209309
    ],
    [
      0,
      -0.16035864564022537,
      0.16035864564022537,
      -0.31656409996362983,
      0.31656409996362983,
      -0.46457074137596094,
      0.46457074137596094,
      -0.600545304661681,
      0.600545304661681,
      -0.7209661773352294,
      0.7209661773352294,
      -0.8227146565371428,
      0.8227146565371428,
      -0.9031559036148179,
      0.9031559036148179,
      -0.96020815213483,
      0.96020815213483,
      -0.9924068438435844,
      0.9924068438435844
    ],
    [
      -0.07652652113349734,
      0.07652652113349734,
      -0.22778585114164507,
      0.22778585114164507,
      -0.37370608871541955,
      0.37370608871541955,
      -0.5108670019508271,
      0.5108670019508271,
      -0.636053680726515,
      0.636053680726515,
      -0.7463319064601508,
      0.7463319064601508,
      -0.8391169718222188,
      0.8391169718222188,
      -0.912234428251326,
      0.912234428251326,
      -0.9639719272779138,
      0.9639719272779138,
      -0.9931285991850949,
      0.9931285991850949
    ],
    [
      0,
      -0.1455618541608951,
      0.1455618541608951,
      -0.2880213168024011,
      0.2880213168024011,
      -0.4243421202074388,
      0.4243421202074388,
      -0.5516188358872198,
      0.5516188358872198,
      -0.6671388041974123,
      0.6671388041974123,
      -0.7684399634756779,
      0.7684399634756779,
      -0.8533633645833173,
      0.8533633645833173,
      -0.9200993341504008,
      0.9200993341504008,
      -0.9672268385663063,
      0.9672268385663063,
      -0.9937521706203895,
      0.9937521706203895
    ],
    [
      -0.06973927331972223,
      0.06973927331972223,
      -0.20786042668822127,
      0.20786042668822127,
      -0.34193582089208424,
      0.34193582089208424,
      -0.469355837986757,
      0.469355837986757,
      -0.5876404035069116,
      0.5876404035069116,
      -0.6944872631866827,
      0.6944872631866827,
      -0.7878168059792081,
      0.7878168059792081,
      -0.8658125777203002,
      0.8658125777203002,
      -0.926956772187174,
      0.926956772187174,
      -0.9700604978354287,
      0.9700604978354287,
      -0.9942945854823992,
      0.9942945854823992
    ],
    [
      0,
      -0.1332568242984661,
      0.1332568242984661,
      -0.26413568097034495,
      0.26413568097034495,
      -0.3903010380302908,
      0.3903010380302908,
      -0.5095014778460075,
      0.5095014778460075,
      -0.6196098757636461,
      0.6196098757636461,
      -0.7186613631319502,
      0.7186613631319502,
      -0.8048884016188399,
      0.8048884016188399,
      -0.8767523582704416,
      0.8767523582704416,
      -0.9329710868260161,
      0.9329710868260161,
      -0.9725424712181152,
      0.9725424712181152,
      -0.9947693349975522,
      0.9947693349975522
    ],
    [
      -0.06405689286260563,
      0.06405689286260563,
      -0.1911188674736163,
      0.1911188674736163,
      -0.3150426796961634,
      0.3150426796961634,
      -0.4337935076260451,
      0.4337935076260451,
      -0.5454214713888396,
      0.5454214713888396,
      -0.6480936519369755,
      0.6480936519369755,
      -0.7401241915785544,
      0.7401241915785544,
      -0.820001985973903,
      0.820001985973903,
      -0.8864155270044011,
      0.8864155270044011,
      -0.9382745520027328,
      0.9382745520027328,
      -0.9747285559713095,
      0.9747285559713095,
      -0.9951872199970213,
      0.9951872199970213
    ]
  ], s.cValues = [
    [],
    [],
    [1, 1],
    [
      0.8888888888888888,
      0.5555555555555556,
      0.5555555555555556
    ],
    [
      0.6521451548625461,
      0.6521451548625461,
      0.34785484513745385,
      0.34785484513745385
    ],
    [
      0.5688888888888889,
      0.47862867049936647,
      0.47862867049936647,
      0.23692688505618908,
      0.23692688505618908
    ],
    [
      0.3607615730481386,
      0.3607615730481386,
      0.46791393457269104,
      0.46791393457269104,
      0.17132449237917036,
      0.17132449237917036
    ],
    [
      0.4179591836734694,
      0.3818300505051189,
      0.3818300505051189,
      0.27970539148927664,
      0.27970539148927664,
      0.1294849661688697,
      0.1294849661688697
    ],
    [
      0.362683783378362,
      0.362683783378362,
      0.31370664587788727,
      0.31370664587788727,
      0.22238103445337448,
      0.22238103445337448,
      0.10122853629037626,
      0.10122853629037626
    ],
    [
      0.3302393550012598,
      0.1806481606948574,
      0.1806481606948574,
      0.08127438836157441,
      0.08127438836157441,
      0.31234707704000286,
      0.31234707704000286,
      0.26061069640293544,
      0.26061069640293544
    ],
    [
      0.29552422471475287,
      0.29552422471475287,
      0.26926671930999635,
      0.26926671930999635,
      0.21908636251598204,
      0.21908636251598204,
      0.1494513491505806,
      0.1494513491505806,
      0.06667134430868814,
      0.06667134430868814
    ],
    [
      0.2729250867779006,
      0.26280454451024665,
      0.26280454451024665,
      0.23319376459199048,
      0.23319376459199048,
      0.18629021092773426,
      0.18629021092773426,
      0.1255803694649046,
      0.1255803694649046,
      0.05566856711617366,
      0.05566856711617366
    ],
    [
      0.24914704581340277,
      0.24914704581340277,
      0.2334925365383548,
      0.2334925365383548,
      0.20316742672306592,
      0.20316742672306592,
      0.16007832854334622,
      0.16007832854334622,
      0.10693932599531843,
      0.10693932599531843,
      0.04717533638651183,
      0.04717533638651183
    ],
    [
      0.2325515532308739,
      0.22628318026289723,
      0.22628318026289723,
      0.2078160475368885,
      0.2078160475368885,
      0.17814598076194574,
      0.17814598076194574,
      0.13887351021978725,
      0.13887351021978725,
      0.09212149983772845,
      0.09212149983772845,
      0.04048400476531588,
      0.04048400476531588
    ],
    [
      0.2152638534631578,
      0.2152638534631578,
      0.2051984637212956,
      0.2051984637212956,
      0.18553839747793782,
      0.18553839747793782,
      0.15720316715819355,
      0.15720316715819355,
      0.12151857068790319,
      0.12151857068790319,
      0.08015808715976021,
      0.08015808715976021,
      0.03511946033175186,
      0.03511946033175186
    ],
    [
      0.2025782419255613,
      0.19843148532711158,
      0.19843148532711158,
      0.1861610000155622,
      0.1861610000155622,
      0.16626920581699392,
      0.16626920581699392,
      0.13957067792615432,
      0.13957067792615432,
      0.10715922046717194,
      0.10715922046717194,
      0.07036604748810812,
      0.07036604748810812,
      0.03075324199611727,
      0.03075324199611727
    ],
    [
      0.1894506104550685,
      0.1894506104550685,
      0.18260341504492358,
      0.18260341504492358,
      0.16915651939500254,
      0.16915651939500254,
      0.14959598881657674,
      0.14959598881657674,
      0.12462897125553388,
      0.12462897125553388,
      0.09515851168249279,
      0.09515851168249279,
      0.062253523938647894,
      0.062253523938647894,
      0.027152459411754096,
      0.027152459411754096
    ],
    [
      0.17944647035620653,
      0.17656270536699264,
      0.17656270536699264,
      0.16800410215645004,
      0.16800410215645004,
      0.15404576107681028,
      0.15404576107681028,
      0.13513636846852548,
      0.13513636846852548,
      0.11188384719340397,
      0.11188384719340397,
      0.08503614831717918,
      0.08503614831717918,
      0.0554595293739872,
      0.0554595293739872,
      0.02414830286854793,
      0.02414830286854793
    ],
    [
      0.1691423829631436,
      0.1691423829631436,
      0.16427648374583273,
      0.16427648374583273,
      0.15468467512626524,
      0.15468467512626524,
      0.14064291467065065,
      0.14064291467065065,
      0.12255520671147846,
      0.12255520671147846,
      0.10094204410628717,
      0.10094204410628717,
      0.07642573025488905,
      0.07642573025488905,
      0.0497145488949698,
      0.0497145488949698,
      0.02161601352648331,
      0.02161601352648331
    ],
    [
      0.1610544498487837,
      0.15896884339395434,
      0.15896884339395434,
      0.15276604206585967,
      0.15276604206585967,
      0.1426067021736066,
      0.1426067021736066,
      0.12875396253933621,
      0.12875396253933621,
      0.11156664554733399,
      0.11156664554733399,
      0.09149002162245,
      0.09149002162245,
      0.06904454273764123,
      0.06904454273764123,
      0.0448142267656996,
      0.0448142267656996,
      0.019461788229726478,
      0.019461788229726478
    ],
    [
      0.15275338713072584,
      0.15275338713072584,
      0.14917298647260374,
      0.14917298647260374,
      0.14209610931838204,
      0.14209610931838204,
      0.13168863844917664,
      0.13168863844917664,
      0.11819453196151841,
      0.11819453196151841,
      0.10193011981724044,
      0.10193011981724044,
      0.08327674157670475,
      0.08327674157670475,
      0.06267204833410907,
      0.06267204833410907,
      0.04060142980038694,
      0.04060142980038694,
      0.017614007139152118,
      0.017614007139152118
    ],
    [
      0.14608113364969041,
      0.14452440398997005,
      0.14452440398997005,
      0.13988739479107315,
      0.13988739479107315,
      0.13226893863333747,
      0.13226893863333747,
      0.12183141605372853,
      0.12183141605372853,
      0.10879729916714838,
      0.10879729916714838,
      0.09344442345603386,
      0.09344442345603386,
      0.0761001136283793,
      0.0761001136283793,
      0.057134425426857205,
      0.057134425426857205,
      0.036953789770852494,
      0.036953789770852494,
      0.016017228257774335,
      0.016017228257774335
    ],
    [
      0.13925187285563198,
      0.13925187285563198,
      0.13654149834601517,
      0.13654149834601517,
      0.13117350478706238,
      0.13117350478706238,
      0.12325237681051242,
      0.12325237681051242,
      0.11293229608053922,
      0.11293229608053922,
      0.10041414444288096,
      0.10041414444288096,
      0.08594160621706773,
      0.08594160621706773,
      0.06979646842452049,
      0.06979646842452049,
      0.052293335152683286,
      0.052293335152683286,
      0.03377490158481415,
      0.03377490158481415,
      0.0146279952982722,
      0.0146279952982722
    ],
    [
      0.13365457218610619,
      0.1324620394046966,
      0.1324620394046966,
      0.12890572218808216,
      0.12890572218808216,
      0.12304908430672953,
      0.12304908430672953,
      0.11499664022241136,
      0.11499664022241136,
      0.10489209146454141,
      0.10489209146454141,
      0.09291576606003515,
      0.09291576606003515,
      0.07928141177671895,
      0.07928141177671895,
      0.06423242140852585,
      0.06423242140852585,
      0.04803767173108467,
      0.04803767173108467,
      0.030988005856979445,
      0.030988005856979445,
      0.013411859487141771,
      0.013411859487141771
    ],
    [
      0.12793819534675216,
      0.12793819534675216,
      0.1258374563468283,
      0.1258374563468283,
      0.12167047292780339,
      0.12167047292780339,
      0.1155056680537256,
      0.1155056680537256,
      0.10744427011596563,
      0.10744427011596563,
      0.09761865210411388,
      0.09761865210411388,
      0.08619016153195327,
      0.08619016153195327,
      0.0733464814110803,
      0.0733464814110803,
      0.05929858491543678,
      0.05929858491543678,
      0.04427743881741981,
      0.04427743881741981,
      0.028531388628933663,
      0.028531388628933663,
      0.0123412297999872,
      0.0123412297999872
    ]
  ], s.binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
  const t = (a, o, h) => {
    let l, A, u;
    l = h / 2, A = 0;
    for (let c = 0; c < 20; c++)
      u = l * s.tValues[20][c] + l, A += s.cValues[20][c] * i(a, o, u);
    return l * A;
  };
  s.getCubicArcLength = t;
  const e = (a, o, h) => {
    h === void 0 && (h = 1);
    const l = a[0] - 2 * a[1] + a[2], A = o[0] - 2 * o[1] + o[2], u = 2 * a[1] - 2 * a[0], f = 2 * o[1] - 2 * o[0], c = 4 * (l * l + A * A), d = 4 * (l * u + A * f), p = u * u + f * f;
    if (c === 0)
      return h * Math.sqrt(Math.pow(a[2] - a[0], 2) + Math.pow(o[2] - o[0], 2));
    const m = d / (2 * c), v = p / c, _ = h + m, g = v - m * m, y = _ * _ + g > 0 ? Math.sqrt(_ * _ + g) : 0, x = m * m + g > 0 ? Math.sqrt(m * m + g) : 0, b = m + Math.sqrt(m * m + g) !== 0 ? g * Math.log(Math.abs((_ + y) / (m + x))) : 0;
    return Math.sqrt(c) / 2 * (_ * y - m * x + b);
  };
  s.getQuadraticArcLength = e;
  function i(a, o, h) {
    const l = n(1, h, a), A = n(1, h, o), u = l * l + A * A;
    return Math.sqrt(u);
  }
  const n = (a, o, h) => {
    const l = h.length - 1;
    let A, u;
    if (l === 0)
      return 0;
    if (a === 0) {
      u = 0;
      for (let f = 0; f <= l; f++)
        u += s.binomialCoefficients[l][f] * Math.pow(1 - o, l - f) * Math.pow(o, f) * h[f];
      return u;
    } else {
      A = new Array(l);
      for (let f = 0; f < l; f++)
        A[f] = l * (h[f + 1] - h[f]);
      return n(a - 1, o, A);
    }
  }, r = (a, o, h) => {
    let l = 1, A = a / o, u = (a - h(A)) / o, f = 0;
    for (; l > 1e-3; ) {
      const c = h(A + u), d = Math.abs(a - c) / o;
      if (d < l)
        l = d, A += u;
      else {
        const p = h(A - u), m = Math.abs(a - p) / o;
        m < l ? (l = m, A -= u) : u /= 2;
      }
      if (f++, f > 500)
        break;
    }
    return A;
  };
  s.t2length = r;
})(ao);
Object.defineProperty(hi, "__esModule", { value: !0 });
var Ci = hi.Path = void 0;
const ml = V, vl = ft, _l = $, Ge = ao;
class ut extends vl.Shape {
  constructor(t) {
    super(t), this.dataArray = [], this.pathLength = 0, this._readDataAttribute(), this.on("dataChange.konva", function() {
      this._readDataAttribute();
    });
  }
  _readDataAttribute() {
    this.dataArray = ut.parsePathData(this.data()), this.pathLength = ut.getPathLength(this.dataArray);
  }
  _sceneFunc(t) {
    var e = this.dataArray;
    t.beginPath();
    for (var i = !1, n = 0; n < e.length; n++) {
      var r = e[n].command, a = e[n].points;
      switch (r) {
        case "L":
          t.lineTo(a[0], a[1]);
          break;
        case "M":
          t.moveTo(a[0], a[1]);
          break;
        case "C":
          t.bezierCurveTo(a[0], a[1], a[2], a[3], a[4], a[5]);
          break;
        case "Q":
          t.quadraticCurveTo(a[0], a[1], a[2], a[3]);
          break;
        case "A":
          var o = a[0], h = a[1], l = a[2], A = a[3], u = a[4], f = a[5], c = a[6], d = a[7], p = l > A ? l : A, m = l > A ? 1 : l / A, v = l > A ? A / l : 1;
          t.translate(o, h), t.rotate(c), t.scale(m, v), t.arc(0, 0, p, u, u + f, 1 - d), t.scale(1 / m, 1 / v), t.rotate(-c), t.translate(-o, -h);
          break;
        case "z":
          i = !0, t.closePath();
          break;
      }
    }
    !i && !this.hasFill() ? t.strokeShape(this) : t.fillStrokeShape(this);
  }
  getSelfRect() {
    var t = [];
    this.dataArray.forEach(function(l) {
      if (l.command === "A") {
        var A = l.points[4], u = l.points[5], f = l.points[4] + u, c = Math.PI / 180;
        if (Math.abs(A - f) < c && (c = Math.abs(A - f)), u < 0)
          for (let d = A - c; d > f; d -= c) {
            const p = ut.getPointOnEllipticalArc(l.points[0], l.points[1], l.points[2], l.points[3], d, 0);
            t.push(p.x, p.y);
          }
        else
          for (let d = A + c; d < f; d += c) {
            const p = ut.getPointOnEllipticalArc(l.points[0], l.points[1], l.points[2], l.points[3], d, 0);
            t.push(p.x, p.y);
          }
      } else if (l.command === "C")
        for (let d = 0; d <= 1; d += 0.01) {
          const p = ut.getPointOnCubicBezier(d, l.start.x, l.start.y, l.points[0], l.points[1], l.points[2], l.points[3], l.points[4], l.points[5]);
          t.push(p.x, p.y);
        }
      else
        t = t.concat(l.points);
    });
    for (var e = t[0], i = t[0], n = t[1], r = t[1], a, o, h = 0; h < t.length / 2; h++)
      a = t[h * 2], o = t[h * 2 + 1], isNaN(a) || (e = Math.min(e, a), i = Math.max(i, a)), isNaN(o) || (n = Math.min(n, o), r = Math.max(r, o));
    return {
      x: e,
      y: n,
      width: i - e,
      height: r - n
    };
  }
  getLength() {
    return this.pathLength;
  }
  getPointAtLength(t) {
    return ut.getPointAtLengthOfDataArray(t, this.dataArray);
  }
  static getLineLength(t, e, i, n) {
    return Math.sqrt((i - t) * (i - t) + (n - e) * (n - e));
  }
  static getPathLength(t) {
    let e = 0;
    for (var i = 0; i < t.length; ++i)
      e += t[i].pathLength;
    return e;
  }
  static getPointAtLengthOfDataArray(t, e) {
    var i, n = 0, r = e.length;
    if (!r)
      return null;
    for (; n < r && t > e[n].pathLength; )
      t -= e[n].pathLength, ++n;
    if (n === r)
      return i = e[n - 1].points.slice(-2), {
        x: i[0],
        y: i[1]
      };
    if (t < 0.01)
      return i = e[n].points.slice(0, 2), {
        x: i[0],
        y: i[1]
      };
    var a = e[n], o = a.points;
    switch (a.command) {
      case "L":
        return ut.getPointOnLine(t, a.start.x, a.start.y, o[0], o[1]);
      case "C":
        return ut.getPointOnCubicBezier((0, Ge.t2length)(t, ut.getPathLength(e), (p) => (0, Ge.getCubicArcLength)([a.start.x, o[0], o[2], o[4]], [a.start.y, o[1], o[3], o[5]], p)), a.start.x, a.start.y, o[0], o[1], o[2], o[3], o[4], o[5]);
      case "Q":
        return ut.getPointOnQuadraticBezier((0, Ge.t2length)(t, ut.getPathLength(e), (p) => (0, Ge.getQuadraticArcLength)([a.start.x, o[0], o[2]], [a.start.y, o[1], o[3]], p)), a.start.x, a.start.y, o[0], o[1], o[2], o[3]);
      case "A":
        var h = o[0], l = o[1], A = o[2], u = o[3], f = o[4], c = o[5], d = o[6];
        return f += c * t / a.pathLength, ut.getPointOnEllipticalArc(h, l, A, u, f, d);
    }
    return null;
  }
  static getPointOnLine(t, e, i, n, r, a, o) {
    a === void 0 && (a = e), o === void 0 && (o = i);
    var h = (r - i) / (n - e + 1e-8), l = Math.sqrt(t * t / (1 + h * h));
    n < e && (l *= -1);
    var A = h * l, u;
    if (n === e)
      u = {
        x: a,
        y: o + A
      };
    else if ((o - i) / (a - e + 1e-8) === h)
      u = {
        x: a + l,
        y: o + A
      };
    else {
      var f, c, d = this.getLineLength(e, i, n, r), p = (a - e) * (n - e) + (o - i) * (r - i);
      p = p / (d * d), f = e + p * (n - e), c = i + p * (r - i);
      var m = this.getLineLength(a, o, f, c), v = Math.sqrt(t * t - m * m);
      l = Math.sqrt(v * v / (1 + h * h)), n < e && (l *= -1), A = h * l, u = {
        x: f + l,
        y: c + A
      };
    }
    return u;
  }
  static getPointOnCubicBezier(t, e, i, n, r, a, o, h, l) {
    function A(m) {
      return m * m * m;
    }
    function u(m) {
      return 3 * m * m * (1 - m);
    }
    function f(m) {
      return 3 * m * (1 - m) * (1 - m);
    }
    function c(m) {
      return (1 - m) * (1 - m) * (1 - m);
    }
    var d = h * A(t) + a * u(t) + n * f(t) + e * c(t), p = l * A(t) + o * u(t) + r * f(t) + i * c(t);
    return {
      x: d,
      y: p
    };
  }
  static getPointOnQuadraticBezier(t, e, i, n, r, a, o) {
    function h(c) {
      return c * c;
    }
    function l(c) {
      return 2 * c * (1 - c);
    }
    function A(c) {
      return (1 - c) * (1 - c);
    }
    var u = a * h(t) + n * l(t) + e * A(t), f = o * h(t) + r * l(t) + i * A(t);
    return {
      x: u,
      y: f
    };
  }
  static getPointOnEllipticalArc(t, e, i, n, r, a) {
    var o = Math.cos(a), h = Math.sin(a), l = {
      x: i * Math.cos(r),
      y: n * Math.sin(r)
    };
    return {
      x: t + (l.x * o - l.y * h),
      y: e + (l.x * h + l.y * o)
    };
  }
  static parsePathData(t) {
    if (!t)
      return [];
    var e = t, i = [
      "m",
      "M",
      "l",
      "L",
      "v",
      "V",
      "h",
      "H",
      "z",
      "Z",
      "c",
      "C",
      "q",
      "Q",
      "t",
      "T",
      "s",
      "S",
      "a",
      "A"
    ];
    e = e.replace(new RegExp(" ", "g"), ",");
    for (var n = 0; n < i.length; n++)
      e = e.replace(new RegExp(i[n], "g"), "|" + i[n]);
    var r = e.split("|"), a = [], o = [], h = 0, l = 0, A = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi, u;
    for (n = 1; n < r.length; n++) {
      var f = r[n], c = f.charAt(0);
      for (f = f.slice(1), o.length = 0; u = A.exec(f); )
        o.push(u[0]);
      for (var d = [], p = 0, m = o.length; p < m; p++) {
        if (o[p] === "00") {
          d.push(0, 0);
          continue;
        }
        var v = parseFloat(o[p]);
        isNaN(v) ? d.push(0) : d.push(v);
      }
      for (; d.length > 0 && !isNaN(d[0]); ) {
        var _ = "", g = [], y = h, x = l, b, C, w, E, S, P, k, F, L, I;
        switch (c) {
          case "l":
            h += d.shift(), l += d.shift(), _ = "L", g.push(h, l);
            break;
          case "L":
            h = d.shift(), l = d.shift(), g.push(h, l);
            break;
          case "m":
            var z = d.shift(), T = d.shift();
            if (h += z, l += T, _ = "M", a.length > 2 && a[a.length - 1].command === "z") {
              for (var G = a.length - 2; G >= 0; G--)
                if (a[G].command === "M") {
                  h = a[G].points[0] + z, l = a[G].points[1] + T;
                  break;
                }
            }
            g.push(h, l), c = "l";
            break;
          case "M":
            h = d.shift(), l = d.shift(), _ = "M", g.push(h, l), c = "L";
            break;
          case "h":
            h += d.shift(), _ = "L", g.push(h, l);
            break;
          case "H":
            h = d.shift(), _ = "L", g.push(h, l);
            break;
          case "v":
            l += d.shift(), _ = "L", g.push(h, l);
            break;
          case "V":
            l = d.shift(), _ = "L", g.push(h, l);
            break;
          case "C":
            g.push(d.shift(), d.shift(), d.shift(), d.shift()), h = d.shift(), l = d.shift(), g.push(h, l);
            break;
          case "c":
            g.push(h + d.shift(), l + d.shift(), h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "C", g.push(h, l);
            break;
          case "S":
            C = h, w = l, b = a[a.length - 1], b.command === "C" && (C = h + (h - b.points[2]), w = l + (l - b.points[3])), g.push(C, w, d.shift(), d.shift()), h = d.shift(), l = d.shift(), _ = "C", g.push(h, l);
            break;
          case "s":
            C = h, w = l, b = a[a.length - 1], b.command === "C" && (C = h + (h - b.points[2]), w = l + (l - b.points[3])), g.push(C, w, h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "C", g.push(h, l);
            break;
          case "Q":
            g.push(d.shift(), d.shift()), h = d.shift(), l = d.shift(), g.push(h, l);
            break;
          case "q":
            g.push(h + d.shift(), l + d.shift()), h += d.shift(), l += d.shift(), _ = "Q", g.push(h, l);
            break;
          case "T":
            C = h, w = l, b = a[a.length - 1], b.command === "Q" && (C = h + (h - b.points[0]), w = l + (l - b.points[1])), h = d.shift(), l = d.shift(), _ = "Q", g.push(C, w, h, l);
            break;
          case "t":
            C = h, w = l, b = a[a.length - 1], b.command === "Q" && (C = h + (h - b.points[0]), w = l + (l - b.points[1])), h += d.shift(), l += d.shift(), _ = "Q", g.push(C, w, h, l);
            break;
          case "A":
            E = d.shift(), S = d.shift(), P = d.shift(), k = d.shift(), F = d.shift(), L = h, I = l, h = d.shift(), l = d.shift(), _ = "A", g = this.convertEndpointToCenterParameterization(L, I, h, l, k, F, E, S, P);
            break;
          case "a":
            E = d.shift(), S = d.shift(), P = d.shift(), k = d.shift(), F = d.shift(), L = h, I = l, h += d.shift(), l += d.shift(), _ = "A", g = this.convertEndpointToCenterParameterization(L, I, h, l, k, F, E, S, P);
            break;
        }
        a.push({
          command: _ || c,
          points: g,
          start: {
            x: y,
            y: x
          },
          pathLength: this.calcLength(y, x, _ || c, g)
        });
      }
      (c === "z" || c === "Z") && a.push({
        command: "z",
        points: [],
        start: void 0,
        pathLength: 0
      });
    }
    return a;
  }
  static calcLength(t, e, i, n) {
    var r, a, o, h, l = ut;
    switch (i) {
      case "L":
        return l.getLineLength(t, e, n[0], n[1]);
      case "C":
        return (0, Ge.getCubicArcLength)([t, n[0], n[2], n[4]], [e, n[1], n[3], n[5]], 1);
      case "Q":
        return (0, Ge.getQuadraticArcLength)([t, n[0], n[2]], [e, n[1], n[3]], 1);
      case "A":
        r = 0;
        var A = n[4], u = n[5], f = n[4] + u, c = Math.PI / 180;
        if (Math.abs(A - f) < c && (c = Math.abs(A - f)), a = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], A, 0), u < 0)
          for (h = A - c; h > f; h -= c)
            o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], h, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), a = o;
        else
          for (h = A + c; h < f; h += c)
            o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], h, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), a = o;
        return o = l.getPointOnEllipticalArc(n[0], n[1], n[2], n[3], f, 0), r += l.getLineLength(a.x, a.y, o.x, o.y), r;
    }
    return 0;
  }
  static convertEndpointToCenterParameterization(t, e, i, n, r, a, o, h, l) {
    var A = l * (Math.PI / 180), u = Math.cos(A) * (t - i) / 2 + Math.sin(A) * (e - n) / 2, f = -1 * Math.sin(A) * (t - i) / 2 + Math.cos(A) * (e - n) / 2, c = u * u / (o * o) + f * f / (h * h);
    c > 1 && (o *= Math.sqrt(c), h *= Math.sqrt(c));
    var d = Math.sqrt((o * o * (h * h) - o * o * (f * f) - h * h * (u * u)) / (o * o * (f * f) + h * h * (u * u)));
    r === a && (d *= -1), isNaN(d) && (d = 0);
    var p = d * o * f / h, m = d * -h * u / o, v = (t + i) / 2 + Math.cos(A) * p - Math.sin(A) * m, _ = (e + n) / 2 + Math.sin(A) * p + Math.cos(A) * m, g = function(S) {
      return Math.sqrt(S[0] * S[0] + S[1] * S[1]);
    }, y = function(S, P) {
      return (S[0] * P[0] + S[1] * P[1]) / (g(S) * g(P));
    }, x = function(S, P) {
      return (S[0] * P[1] < S[1] * P[0] ? -1 : 1) * Math.acos(y(S, P));
    }, b = x([1, 0], [(u - p) / o, (f - m) / h]), C = [(u - p) / o, (f - m) / h], w = [(-1 * u - p) / o, (-1 * f - m) / h], E = x(C, w);
    return y(C, w) <= -1 && (E = Math.PI), y(C, w) >= 1 && (E = 0), a === 0 && E > 0 && (E = E - 2 * Math.PI), a === 1 && E < 0 && (E = E + 2 * Math.PI), [v, _, o, h, b, E, A, a];
  }
}
Ci = hi.Path = ut;
ut.prototype.className = "Path";
ut.prototype._attrsAffectingSize = ["data"];
(0, _l._registerNode)(ut);
ml.Factory.addGetterSetter(ut, "data");
var Bi = {};
Object.defineProperty(Bi, "__esModule", { value: !0 });
var oo = Bi.Rect = void 0;
const xl = V, bl = ft, wl = $, Sl = et, Cl = O;
class Dn extends bl.Shape {
  _sceneFunc(t) {
    var e = this.cornerRadius(), i = this.width(), n = this.height();
    t.beginPath(), e ? Sl.Util.drawRoundedRectPath(t, i, n, e) : t.rect(0, 0, i, n), t.closePath(), t.fillStrokeShape(this);
  }
}
oo = Bi.Rect = Dn;
Dn.prototype.className = "Rect";
(0, wl._registerNode)(Dn);
xl.Factory.addGetterSetter(Dn, "cornerRadius", 0, (0, Cl.getNumberOrArrayOfNumbersValidator)(4));
const we = (s, t = !1) => {
  let e = s;
  const i = t ? s.getTransform().copy() : new et.Transform();
  for (; e = e.parent; )
    i.multiply(e.getTransform());
  return i;
};
function t1(s) {
  const [t, e, i, n] = s.m, r = Math.sqrt(t * t + i * i), a = Math.sqrt(e * e + n * n), o = Math.atan2(i, t), h = o, l = o + Math.PI / 2;
  return console.log(h, l), { x: r, y: a };
}
const Gt = (s, t, e = !1) => {
  let i = s, n = e ? s.scale() : { x: 1, y: 1 };
  for (; i = i.parent; ) {
    const r = i.scale();
    n.x *= r.x, n.y *= r.y;
  }
  return [t[0] / n.x, t[1] / n.y];
};
var li = {}, Ee = {};
Object.defineProperty(Ee, "__esModule", { value: !0 });
Ee.Container = void 0;
const Ai = V, Ss = rt, In = O;
let Fe = class extends Ss.Node {
  constructor() {
    super(...arguments), this.children = [];
  }
  getChildren(t) {
    if (!t)
      return this.children || [];
    const e = this.children || [];
    var i = [];
    return e.forEach(function(n) {
      t(n) && i.push(n);
    }), i;
  }
  hasChildren() {
    return this.getChildren().length > 0;
  }
  removeChildren() {
    return this.getChildren().forEach((t) => {
      t.parent = null, t.index = 0, t.remove();
    }), this.children = [], this._requestDraw(), this;
  }
  destroyChildren() {
    return this.getChildren().forEach((t) => {
      t.parent = null, t.index = 0, t.destroy();
    }), this.children = [], this._requestDraw(), this;
  }
  add(...t) {
    if (t.length === 0)
      return this;
    if (t.length > 1) {
      for (var e = 0; e < t.length; e++)
        this.add(t[e]);
      return this;
    }
    const i = t[0];
    return i.getParent() ? (i.moveTo(this), this) : (this._validateAdd(i), i.index = this.getChildren().length, i.parent = this, i._clearCaches(), this.getChildren().push(i), this._fire("add", {
      child: i
    }), this._requestDraw(), this);
  }
  destroy() {
    return this.hasChildren() && this.destroyChildren(), super.destroy(), this;
  }
  find(t) {
    return this._generalFind(t, !1);
  }
  findOne(t) {
    var e = this._generalFind(t, !0);
    return e.length > 0 ? e[0] : void 0;
  }
  _generalFind(t, e) {
    var i = [];
    return this._descendants((n) => {
      const r = n._isMatch(t);
      return r && i.push(n), !!(r && e);
    }), i;
  }
  _descendants(t) {
    let e = !1;
    const i = this.getChildren();
    for (const n of i) {
      if (e = t(n), e)
        return !0;
      if (n.hasChildren() && (e = n._descendants(t), e))
        return !0;
    }
    return !1;
  }
  toObject() {
    var t = Ss.Node.prototype.toObject.call(this);
    return t.children = [], this.getChildren().forEach((e) => {
      t.children.push(e.toObject());
    }), t;
  }
  isAncestorOf(t) {
    for (var e = t.getParent(); e; ) {
      if (e._id === this._id)
        return !0;
      e = e.getParent();
    }
    return !1;
  }
  clone(t) {
    var e = Ss.Node.prototype.clone.call(this, t);
    return this.getChildren().forEach(function(i) {
      e.add(i.clone());
    }), e;
  }
  getAllIntersections(t) {
    var e = [];
    return this.find("Shape").forEach((i) => {
      i.isVisible() && i.intersects(t) && e.push(i);
    }), e;
  }
  _clearSelfAndDescendantCache(t) {
    var e;
    super._clearSelfAndDescendantCache(t), !this.isCached() && ((e = this.children) === null || e === void 0 || e.forEach(function(i) {
      i._clearSelfAndDescendantCache(t);
    }));
  }
  _setChildrenIndices() {
    var t;
    (t = this.children) === null || t === void 0 || t.forEach(function(e, i) {
      e.index = i;
    }), this._requestDraw();
  }
  drawScene(t, e, i) {
    var n = this.getLayer(), r = t || n && n.getCanvas(), a = r && r.getContext(), o = this._getCanvasCache(), h = o && o.scene, l = r && r.isCache;
    if (!this.isVisible() && !l)
      return this;
    if (h) {
      a.save();
      var A = this.getAbsoluteTransform(e).getMatrix();
      a.transform(A[0], A[1], A[2], A[3], A[4], A[5]), this._drawCachedSceneCanvas(a), a.restore();
    } else
      this._drawChildren("drawScene", r, e, i);
    return this;
  }
  drawHit(t, e) {
    if (!this.shouldDrawHit(e))
      return this;
    var i = this.getLayer(), n = t || i && i.hitCanvas, r = n && n.getContext(), a = this._getCanvasCache(), o = a && a.hit;
    if (o) {
      r.save();
      var h = this.getAbsoluteTransform(e).getMatrix();
      r.transform(h[0], h[1], h[2], h[3], h[4], h[5]), this._drawCachedHitCanvas(r), r.restore();
    } else
      this._drawChildren("drawHit", n, e);
    return this;
  }
  _drawChildren(t, e, i, n) {
    var r, a = e && e.getContext(), o = this.clipWidth(), h = this.clipHeight(), l = this.clipFunc(), A = typeof o == "number" && typeof h == "number" || l;
    const u = i === this;
    if (A) {
      a.save();
      var f = this.getAbsoluteTransform(i), c = f.getMatrix();
      a.transform(c[0], c[1], c[2], c[3], c[4], c[5]), a.beginPath();
      let v;
      if (l)
        v = l.call(this, a, this);
      else {
        var d = this.clipX(), p = this.clipY();
        a.rect(d || 0, p || 0, o, h);
      }
      a.clip.apply(a, v), c = f.copy().invert().getMatrix(), a.transform(c[0], c[1], c[2], c[3], c[4], c[5]);
    }
    var m = !u && this.globalCompositeOperation() !== "source-over" && t === "drawScene";
    m && (a.save(), a._applyGlobalCompositeOperation(this)), (r = this.children) === null || r === void 0 || r.forEach(function(v) {
      v[t](e, i, n);
    }), m && a.restore(), A && a.restore();
  }
  getClientRect(t = {}) {
    var e, i = t.skipTransform, n = t.relativeTo, r, a, o, h, l = {
      x: 1 / 0,
      y: 1 / 0,
      width: 0,
      height: 0
    }, A = this;
    (e = this.children) === null || e === void 0 || e.forEach(function(p) {
      if (p.visible()) {
        var m = p.getClientRect({
          relativeTo: A,
          skipShadow: t.skipShadow,
          skipStroke: t.skipStroke
        });
        m.width === 0 && m.height === 0 || (r === void 0 ? (r = m.x, a = m.y, o = m.x + m.width, h = m.y + m.height) : (r = Math.min(r, m.x), a = Math.min(a, m.y), o = Math.max(o, m.x + m.width), h = Math.max(h, m.y + m.height)));
      }
    });
    for (var u = this.find("Shape"), f = !1, c = 0; c < u.length; c++) {
      var d = u[c];
      if (d._isVisible(this)) {
        f = !0;
        break;
      }
    }
    return f && r !== void 0 ? l = {
      x: r,
      y: a,
      width: o - r,
      height: h - a
    } : l = {
      x: 0,
      y: 0,
      width: 0,
      height: 0
    }, i ? l : this._transformedRect(l, n);
  }
};
Ee.Container = Fe;
Ai.Factory.addComponentsGetterSetter(Fe, "clip", [
  "x",
  "y",
  "width",
  "height"
]);
Ai.Factory.addGetterSetter(Fe, "clipX", void 0, (0, In.getNumberValidator)());
Ai.Factory.addGetterSetter(Fe, "clipY", void 0, (0, In.getNumberValidator)());
Ai.Factory.addGetterSetter(Fe, "clipWidth", void 0, (0, In.getNumberValidator)());
Ai.Factory.addGetterSetter(Fe, "clipHeight", void 0, (0, In.getNumberValidator)());
Ai.Factory.addGetterSetter(Fe, "clipFunc");
Object.defineProperty(li, "__esModule", { value: !0 });
var Nt = li.Group = void 0;
const Ml = et, Pl = Ee, El = $;
class ur extends Pl.Container {
  _validateAdd(t) {
    var e = t.getType();
    e !== "Group" && e !== "Shape" && Ml.Util.throw("You may only add groups and shapes to groups.");
  }
}
Nt = li.Group = ur;
ur.prototype.nodeType = "Group";
(0, El._registerNode)(ur);
const jr = document.createElement("div"), Fl = (s) => {
  jr.innerHTML = s;
  const t = jr.querySelector("svg"), e = [t.width.baseVal.value, t.height.baseVal.value];
  return {
    paths: Array.from(t.querySelectorAll("path")).map((r) => {
      const a = r.getAttribute("fill"), o = r.getAttribute("d"), h = r.getAttribute("stroke"), l = r.getAttribute("stroke-width");
      return {
        fill: a,
        data: o,
        stroke: h,
        strokeWidth: l && Number(l)
      };
    }),
    size: e
  };
}, kl = (s, t = !1) => {
  const e = s.size, n = (s.realWidth || s.size[0]) / e[0], r = e.map((m) => m * n), a = (s.offset || [0, 0]).map((m) => m * n), o = s.strokeWidth ? s.strokeWidth * n : 1, h = s.strokeColor || "#000", l = s.paths.map((m) => typeof m == "string" ? {
    strokeWidth: o,
    stroke: h,
    fill: h,
    data: m
  } : m), A = l.map(
    (m, v) => new Ci({
      data: m.data,
      id: `path-${v}`,
      name: "path",
      strokeScaleEnabled: !!s.fixed,
      scale: { x: n, y: n }
    })
  ), u = () => {
    A.forEach((m, v) => {
      const _ = l[v];
      _.fill && m.fill(_.fill), _.stroke && m.stroke(_.stroke), _.strokeWidth && m.strokeWidth(_.strokeWidth);
    });
  }, f = new oo({
    x: a[0],
    y: a[1],
    name: "rect",
    width: r[0],
    height: r[1],
    fill: `rgba(0, 0, 0, ${t ? 0.3 : 0})`
  }), c = () => {
    let [m, v] = Gt(p, [1, 1]);
    p.scale({ x: m, y: v });
  }, d = new Nt();
  d.add(...A, f), d.x(-r[0] / 2), d.y(-r[0] / 2);
  const p = new Nt();
  return p.add(d), {
    getSize: () => {
      const m = f.getSize();
      if (s.fixed) {
        let [v] = Gt(p, [1, 1]);
        return [m.width * v, m.height * v];
      }
      return [m.width, m.height];
    },
    shape: p,
    setData(m) {
      p.position(m), s.fixed && c(), p.rotation(m.rotate || 0);
    },
    common: u
  };
}, ho = (s) => {
  const e = s.evt.target.getBoundingClientRect(), i = s.evt.changedTouches[0].pageX - e.left, n = s.evt.changedTouches[0].pageY - e.top;
  return {
    offsetX: i,
    offsetY: n
  };
};
/**
 * @license
 * Copyright 2010-2024 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const lo = "164", Ao = 300, qr = 1e3, Yi = 1001, Qr = 1002, Kr = 1003, Dl = 1006, Il = 1008, Tl = 1009, Ll = 1014, Rl = 1020, Ol = 1023, Cs = 1026, Zr = 1027, co = "", le = "srgb", fr = "srgb-linear", Nl = "display-p3", uo = "display-p3-linear", Ks = "linear", Jr = "srgb", ta = "rec709", ea = "p3", Gl = 515, Xi = 2e3, ia = 2001;
class fo {
  addEventListener(t, e) {
    this._listeners === void 0 && (this._listeners = {});
    const i = this._listeners;
    i[t] === void 0 && (i[t] = []), i[t].indexOf(e) === -1 && i[t].push(e);
  }
  hasEventListener(t, e) {
    if (this._listeners === void 0)
      return !1;
    const i = this._listeners;
    return i[t] !== void 0 && i[t].indexOf(e) !== -1;
  }
  removeEventListener(t, e) {
    if (this._listeners === void 0)
      return;
    const n = this._listeners[t];
    if (n !== void 0) {
      const r = n.indexOf(e);
      r !== -1 && n.splice(r, 1);
    }
  }
  dispatchEvent(t) {
    if (this._listeners === void 0)
      return;
    const i = this._listeners[t.type];
    if (i !== void 0) {
      t.target = this;
      const n = i.slice(0);
      for (let r = 0, a = n.length; r < a; r++)
        n[r].call(this, t);
      t.target = null;
    }
  }
}
const pt = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
let na = 1234567;
const go = Math.PI / 180, po = 180 / Math.PI;
function Tn() {
  const s = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0;
  return (pt[s & 255] + pt[s >> 8 & 255] + pt[s >> 16 & 255] + pt[s >> 24 & 255] + "-" + pt[t & 255] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 15 | 64] + pt[t >> 24 & 255] + "-" + pt[e & 63 | 128] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 255] + pt[e >> 24 & 255] + pt[i & 255] + pt[i >> 8 & 255] + pt[i >> 16 & 255] + pt[i >> 24 & 255]).toLowerCase();
}
function mt(s, t, e) {
  return Math.max(t, Math.min(e, s));
}
function gr(s, t) {
  return (s % t + t) % t;
}
function Bl(s, t, e, i, n) {
  return i + (s - t) * (n - i) / (e - t);
}
function zl(s, t, e) {
  return s !== t ? (e - s) / (t - s) : 0;
}
function Mi(s, t, e) {
  return (1 - e) * s + e * t;
}
function Ul(s, t, e, i) {
  return Mi(s, t, 1 - Math.exp(-e * i));
}
function Hl(s, t = 1) {
  return t - Math.abs(gr(s, t * 2) - t);
}
function Vl(s, t, e) {
  return s <= t ? 0 : s >= e ? 1 : (s = (s - t) / (e - t), s * s * (3 - 2 * s));
}
function $l(s, t, e) {
  return s <= t ? 0 : s >= e ? 1 : (s = (s - t) / (e - t), s * s * s * (s * (s * 6 - 15) + 10));
}
function Wl(s, t) {
  return s + Math.floor(Math.random() * (t - s + 1));
}
function Yl(s, t) {
  return s + Math.random() * (t - s);
}
function Xl(s) {
  return s * (0.5 - Math.random());
}
function jl(s) {
  s !== void 0 && (na = s);
  let t = na += 1831565813;
  return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
}
function ql(s) {
  return s * go;
}
function Ql(s) {
  return s * po;
}
function Kl(s) {
  return (s & s - 1) === 0 && s !== 0;
}
function Zl(s) {
  return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2));
}
function Jl(s) {
  return Math.pow(2, Math.floor(Math.log(s) / Math.LN2));
}
function tA(s, t, e, i, n) {
  const r = Math.cos, a = Math.sin, o = r(e / 2), h = a(e / 2), l = r((t + i) / 2), A = a((t + i) / 2), u = r((t - i) / 2), f = a((t - i) / 2), c = r((i - t) / 2), d = a((i - t) / 2);
  switch (n) {
    case "XYX":
      s.set(o * A, h * u, h * f, o * l);
      break;
    case "YZY":
      s.set(h * f, o * A, h * u, o * l);
      break;
    case "ZXZ":
      s.set(h * u, h * f, o * A, o * l);
      break;
    case "XZX":
      s.set(o * A, h * d, h * c, o * l);
      break;
    case "YXY":
      s.set(h * c, o * A, h * d, o * l);
      break;
    case "ZYZ":
      s.set(h * d, h * c, o * A, o * l);
      break;
    default:
      console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + n);
  }
}
function eA(s, t) {
  switch (t.constructor) {
    case Float32Array:
      return s;
    case Uint32Array:
      return s / 4294967295;
    case Uint16Array:
      return s / 65535;
    case Uint8Array:
      return s / 255;
    case Int32Array:
      return Math.max(s / 2147483647, -1);
    case Int16Array:
      return Math.max(s / 32767, -1);
    case Int8Array:
      return Math.max(s / 127, -1);
    default:
      throw new Error("Invalid component type.");
  }
}
function iA(s, t) {
  switch (t.constructor) {
    case Float32Array:
      return s;
    case Uint32Array:
      return Math.round(s * 4294967295);
    case Uint16Array:
      return Math.round(s * 65535);
    case Uint8Array:
      return Math.round(s * 255);
    case Int32Array:
      return Math.round(s * 2147483647);
    case Int16Array:
      return Math.round(s * 32767);
    case Int8Array:
      return Math.round(s * 127);
    default:
      throw new Error("Invalid component type.");
  }
}
const de = {
  DEG2RAD: go,
  RAD2DEG: po,
  generateUUID: Tn,
  clamp: mt,
  euclideanModulo: gr,
  mapLinear: Bl,
  inverseLerp: zl,
  lerp: Mi,
  damp: Ul,
  pingpong: Hl,
  smoothstep: Vl,
  smootherstep: $l,
  randInt: Wl,
  randFloat: Yl,
  randFloatSpread: Xl,
  seededRandom: jl,
  degToRad: ql,
  radToDeg: Ql,
  isPowerOfTwo: Kl,
  ceilPowerOfTwo: Zl,
  floorPowerOfTwo: Jl,
  setQuaternionFromProperEuler: tA,
  normalize: iA,
  denormalize: eA
};
class X {
  constructor(t = 0, e = 0) {
    X.prototype.isVector2 = !0, this.x = t, this.y = e;
  }
  get width() {
    return this.x;
  }
  set width(t) {
    this.x = t;
  }
  get height() {
    return this.y;
  }
  set height(t) {
    this.y = t;
  }
  set(t, e) {
    return this.x = t, this.y = e, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setComponent(t, e) {
    switch (t) {
      case 0:
        this.x = e;
        break;
      case 1:
        this.y = e;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this;
  }
  addVectors(t, e) {
    return this.x = t.x + e.x, this.y = t.y + e.y, this;
  }
  addScaledVector(t, e) {
    return this.x += t.x * e, this.y += t.y * e, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this;
  }
  subVectors(t, e) {
    return this.x = t.x - e.x, this.y = t.y - e.y, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this;
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  applyMatrix3(t) {
    const e = this.x, i = this.y, n = t.elements;
    return this.x = n[0] * e + n[3] * i + n[6], this.y = n[1] * e + n[4] * i + n[7], this;
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this;
  }
  clamp(t, e) {
    return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this;
  }
  clampScalar(t, e) {
    return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this;
  }
  clampLength(t, e) {
    const i = this.length();
    return this.divideScalar(i || 1).multiplyScalar(Math.max(t, Math.min(e, i)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this;
  }
  dot(t) {
    return this.x * t.x + this.y * t.y;
  }
  cross(t) {
    return this.x * t.y - this.y * t.x;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  angle() {
    return Math.atan2(-this.y, -this.x) + Math.PI;
  }
  angleTo(t) {
    const e = Math.sqrt(this.lengthSq() * t.lengthSq());
    if (e === 0)
      return Math.PI / 2;
    const i = this.dot(t) / e;
    return Math.acos(mt(i, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const e = this.x - t.x, i = this.y - t.y;
    return e * e + i * i;
  }
  manhattanDistanceTo(t) {
    return Math.abs(this.x - t.x) + Math.abs(this.y - t.y);
  }
  setLength(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, e) {
    return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this;
  }
  lerpVectors(t, e, i) {
    return this.x = t.x + (e.x - t.x) * i, this.y = t.y + (e.y - t.y) * i, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y;
  }
  fromArray(t, e = 0) {
    return this.x = t[e], this.y = t[e + 1], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.x, t[e + 1] = this.y, t;
  }
  fromBufferAttribute(t, e) {
    return this.x = t.getX(e), this.y = t.getY(e), this;
  }
  rotateAround(t, e) {
    const i = Math.cos(e), n = Math.sin(e), r = this.x - t.x, a = this.y - t.y;
    return this.x = r * i - a * n + t.x, this.y = r * n + a * i + t.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class Jt {
  constructor(t, e, i, n, r, a, o, h, l) {
    Jt.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, e, i, n, r, a, o, h, l);
  }
  set(t, e, i, n, r, a, o, h, l) {
    const A = this.elements;
    return A[0] = t, A[1] = n, A[2] = o, A[3] = e, A[4] = r, A[5] = h, A[6] = i, A[7] = a, A[8] = l, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(t) {
    const e = this.elements, i = t.elements;
    return e[0] = i[0], e[1] = i[1], e[2] = i[2], e[3] = i[3], e[4] = i[4], e[5] = i[5], e[6] = i[6], e[7] = i[7], e[8] = i[8], this;
  }
  extractBasis(t, e, i) {
    return t.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this;
  }
  setFromMatrix4(t) {
    const e = t.elements;
    return this.set(
      e[0],
      e[4],
      e[8],
      e[1],
      e[5],
      e[9],
      e[2],
      e[6],
      e[10]
    ), this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, e) {
    const i = t.elements, n = e.elements, r = this.elements, a = i[0], o = i[3], h = i[6], l = i[1], A = i[4], u = i[7], f = i[2], c = i[5], d = i[8], p = n[0], m = n[3], v = n[6], _ = n[1], g = n[4], y = n[7], x = n[2], b = n[5], C = n[8];
    return r[0] = a * p + o * _ + h * x, r[3] = a * m + o * g + h * b, r[6] = a * v + o * y + h * C, r[1] = l * p + A * _ + u * x, r[4] = l * m + A * g + u * b, r[7] = l * v + A * y + u * C, r[2] = f * p + c * _ + d * x, r[5] = f * m + c * g + d * b, r[8] = f * v + c * y + d * C, this;
  }
  multiplyScalar(t) {
    const e = this.elements;
    return e[0] *= t, e[3] *= t, e[6] *= t, e[1] *= t, e[4] *= t, e[7] *= t, e[2] *= t, e[5] *= t, e[8] *= t, this;
  }
  determinant() {
    const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8];
    return e * a * A - e * o * l - i * r * A + i * o * h + n * r * l - n * a * h;
  }
  invert() {
    const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8], u = A * a - o * l, f = o * h - A * r, c = l * r - a * h, d = e * u + i * f + n * c;
    if (d === 0)
      return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const p = 1 / d;
    return t[0] = u * p, t[1] = (n * l - A * i) * p, t[2] = (o * i - n * a) * p, t[3] = f * p, t[4] = (A * e - n * h) * p, t[5] = (n * r - o * e) * p, t[6] = c * p, t[7] = (i * h - l * e) * p, t[8] = (a * e - i * r) * p, this;
  }
  transpose() {
    let t;
    const e = this.elements;
    return t = e[1], e[1] = e[3], e[3] = t, t = e[2], e[2] = e[6], e[6] = t, t = e[5], e[5] = e[7], e[7] = t, this;
  }
  getNormalMatrix(t) {
    return this.setFromMatrix4(t).invert().transpose();
  }
  transposeIntoArray(t) {
    const e = this.elements;
    return t[0] = e[0], t[1] = e[3], t[2] = e[6], t[3] = e[1], t[4] = e[4], t[5] = e[7], t[6] = e[2], t[7] = e[5], t[8] = e[8], this;
  }
  setUvTransform(t, e, i, n, r, a, o) {
    const h = Math.cos(r), l = Math.sin(r);
    return this.set(
      i * h,
      i * l,
      -i * (h * a + l * o) + a + t,
      -n * l,
      n * h,
      -n * (-l * a + h * o) + o + e,
      0,
      0,
      1
    ), this;
  }
  //
  scale(t, e) {
    return this.premultiply(Ms.makeScale(t, e)), this;
  }
  rotate(t) {
    return this.premultiply(Ms.makeRotation(-t)), this;
  }
  translate(t, e) {
    return this.premultiply(Ms.makeTranslation(t, e)), this;
  }
  // for 2D Transforms
  makeTranslation(t, e) {
    return t.isVector2 ? this.set(
      1,
      0,
      t.x,
      0,
      1,
      t.y,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      t,
      0,
      1,
      e,
      0,
      0,
      1
    ), this;
  }
  makeRotation(t) {
    const e = Math.cos(t), i = Math.sin(t);
    return this.set(
      e,
      -i,
      0,
      i,
      e,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, e) {
    return this.set(
      t,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      1
    ), this;
  }
  //
  equals(t) {
    const e = this.elements, i = t.elements;
    for (let n = 0; n < 9; n++)
      if (e[n] !== i[n])
        return !1;
    return !0;
  }
  fromArray(t, e = 0) {
    for (let i = 0; i < 9; i++)
      this.elements[i] = t[i + e];
    return this;
  }
  toArray(t = [], e = 0) {
    const i = this.elements;
    return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const Ms = /* @__PURE__ */ new Jt();
function sa(s) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", s);
}
const ra = /* @__PURE__ */ new Jt().set(
  0.8224621,
  0.177538,
  0,
  0.0331941,
  0.9668058,
  0,
  0.0170827,
  0.0723974,
  0.9105199
), aa = /* @__PURE__ */ new Jt().set(
  1.2249401,
  -0.2249404,
  0,
  -0.0420569,
  1.0420571,
  0,
  -0.0196376,
  -0.0786361,
  1.0982735
), ji = {
  [fr]: {
    transfer: Ks,
    primaries: ta,
    toReference: (s) => s,
    fromReference: (s) => s
  },
  [le]: {
    transfer: Jr,
    primaries: ta,
    toReference: (s) => s.convertSRGBToLinear(),
    fromReference: (s) => s.convertLinearToSRGB()
  },
  [uo]: {
    transfer: Ks,
    primaries: ea,
    toReference: (s) => s.applyMatrix3(aa),
    fromReference: (s) => s.applyMatrix3(ra)
  },
  [Nl]: {
    transfer: Jr,
    primaries: ea,
    toReference: (s) => s.convertSRGBToLinear().applyMatrix3(aa),
    fromReference: (s) => s.applyMatrix3(ra).convertLinearToSRGB()
  }
}, nA = /* @__PURE__ */ new Set([fr, uo]), Ft = {
  enabled: !0,
  _workingColorSpace: fr,
  get workingColorSpace() {
    return this._workingColorSpace;
  },
  set workingColorSpace(s) {
    if (!nA.has(s))
      throw new Error(`Unsupported working color space, "${s}".`);
    this._workingColorSpace = s;
  },
  convert: function(s, t, e) {
    if (this.enabled === !1 || t === e || !t || !e)
      return s;
    const i = ji[t].toReference, n = ji[e].fromReference;
    return n(i(s));
  },
  fromWorkingColorSpace: function(s, t) {
    return this.convert(s, this._workingColorSpace, t);
  },
  toWorkingColorSpace: function(s, t) {
    return this.convert(s, t, this._workingColorSpace);
  },
  getPrimaries: function(s) {
    return ji[s].primaries;
  },
  getTransfer: function(s) {
    return s === co ? Ks : ji[s].transfer;
  }
};
function Qe(s) {
  return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4);
}
function Ps(s) {
  return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055;
}
let Be;
class sA {
  static getDataURL(t) {
    if (/^data:/i.test(t.src) || typeof HTMLCanvasElement > "u")
      return t.src;
    let e;
    if (t instanceof HTMLCanvasElement)
      e = t;
    else {
      Be === void 0 && (Be = sa("canvas")), Be.width = t.width, Be.height = t.height;
      const i = Be.getContext("2d");
      t instanceof ImageData ? i.putImageData(t, 0, 0) : i.drawImage(t, 0, 0, t.width, t.height), e = Be;
    }
    return e.width > 2048 || e.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", t), e.toDataURL("image/jpeg", 0.6)) : e.toDataURL("image/png");
  }
  static sRGBToLinear(t) {
    if (typeof HTMLImageElement < "u" && t instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && t instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap) {
      const e = sa("canvas");
      e.width = t.width, e.height = t.height;
      const i = e.getContext("2d");
      i.drawImage(t, 0, 0, t.width, t.height);
      const n = i.getImageData(0, 0, t.width, t.height), r = n.data;
      for (let a = 0; a < r.length; a++)
        r[a] = Qe(r[a] / 255) * 255;
      return i.putImageData(n, 0, 0), e;
    } else if (t.data) {
      const e = t.data.slice(0);
      for (let i = 0; i < e.length; i++)
        e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[i] = Math.floor(Qe(e[i] / 255) * 255) : e[i] = Qe(e[i]);
      return {
        data: e,
        width: t.width,
        height: t.height
      };
    } else
      return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), t;
  }
}
let rA = 0;
class aA {
  constructor(t = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: rA++ }), this.uuid = Tn(), this.data = t, this.dataReady = !0, this.version = 0;
  }
  set needsUpdate(t) {
    t === !0 && this.version++;
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string";
    if (!e && t.images[this.uuid] !== void 0)
      return t.images[this.uuid];
    const i = {
      uuid: this.uuid,
      url: ""
    }, n = this.data;
    if (n !== null) {
      let r;
      if (Array.isArray(n)) {
        r = [];
        for (let a = 0, o = n.length; a < o; a++)
          n[a].isDataTexture ? r.push(Es(n[a].image)) : r.push(Es(n[a]));
      } else
        r = Es(n);
      i.url = r;
    }
    return e || (t.images[this.uuid] = i), i;
  }
}
function Es(s) {
  return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? sA.getDataURL(s) : s.data ? {
    data: Array.from(s.data),
    width: s.width,
    height: s.height,
    type: s.data.constructor.name
  } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let oA = 0;
class Ae extends fo {
  constructor(t = Ae.DEFAULT_IMAGE, e = Ae.DEFAULT_MAPPING, i = Yi, n = Yi, r = Dl, a = Il, o = Ol, h = Tl, l = Ae.DEFAULT_ANISOTROPY, A = co) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: oA++ }), this.uuid = Tn(), this.name = "", this.source = new aA(t), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = i, this.wrapT = n, this.magFilter = r, this.minFilter = a, this.anisotropy = l, this.format = o, this.internalFormat = null, this.type = h, this.offset = new X(0, 0), this.repeat = new X(1, 1), this.center = new X(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new Jt(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = A, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
  }
  get image() {
    return this.source.data;
  }
  set image(t = null) {
    this.source.data = t;
  }
  updateMatrix() {
    this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(t) {
    return this.name = t.name, this.source = t.source, this.mipmaps = t.mipmaps.slice(0), this.mapping = t.mapping, this.channel = t.channel, this.wrapS = t.wrapS, this.wrapT = t.wrapT, this.magFilter = t.magFilter, this.minFilter = t.minFilter, this.anisotropy = t.anisotropy, this.format = t.format, this.internalFormat = t.internalFormat, this.type = t.type, this.offset.copy(t.offset), this.repeat.copy(t.repeat), this.center.copy(t.center), this.rotation = t.rotation, this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrix.copy(t.matrix), this.generateMipmaps = t.generateMipmaps, this.premultiplyAlpha = t.premultiplyAlpha, this.flipY = t.flipY, this.unpackAlignment = t.unpackAlignment, this.colorSpace = t.colorSpace, this.userData = JSON.parse(JSON.stringify(t.userData)), this.needsUpdate = !0, this;
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string";
    if (!e && t.textures[this.uuid] !== void 0)
      return t.textures[this.uuid];
    const i = {
      metadata: {
        version: 4.6,
        type: "Texture",
        generator: "Texture.toJSON"
      },
      uuid: this.uuid,
      name: this.name,
      image: this.source.toJSON(t).uuid,
      mapping: this.mapping,
      channel: this.channel,
      repeat: [this.repeat.x, this.repeat.y],
      offset: [this.offset.x, this.offset.y],
      center: [this.center.x, this.center.y],
      rotation: this.rotation,
      wrap: [this.wrapS, this.wrapT],
      format: this.format,
      internalFormat: this.internalFormat,
      type: this.type,
      colorSpace: this.colorSpace,
      minFilter: this.minFilter,
      magFilter: this.magFilter,
      anisotropy: this.anisotropy,
      flipY: this.flipY,
      generateMipmaps: this.generateMipmaps,
      premultiplyAlpha: this.premultiplyAlpha,
      unpackAlignment: this.unpackAlignment
    };
    return Object.keys(this.userData).length > 0 && (i.userData = this.userData), e || (t.textures[this.uuid] = i), i;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(t) {
    if (this.mapping !== Ao)
      return t;
    if (t.applyMatrix3(this.matrix), t.x < 0 || t.x > 1)
      switch (this.wrapS) {
        case qr:
          t.x = t.x - Math.floor(t.x);
          break;
        case Yi:
          t.x = t.x < 0 ? 0 : 1;
          break;
        case Qr:
          Math.abs(Math.floor(t.x) % 2) === 1 ? t.x = Math.ceil(t.x) - t.x : t.x = t.x - Math.floor(t.x);
          break;
      }
    if (t.y < 0 || t.y > 1)
      switch (this.wrapT) {
        case qr:
          t.y = t.y - Math.floor(t.y);
          break;
        case Yi:
          t.y = t.y < 0 ? 0 : 1;
          break;
        case Qr:
          Math.abs(Math.floor(t.y) % 2) === 1 ? t.y = Math.ceil(t.y) - t.y : t.y = t.y - Math.floor(t.y);
          break;
      }
    return this.flipY && (t.y = 1 - t.y), t;
  }
  set needsUpdate(t) {
    t === !0 && (this.version++, this.source.needsUpdate = !0);
  }
  set needsPMREMUpdate(t) {
    t === !0 && this.pmremVersion++;
  }
}
Ae.DEFAULT_IMAGE = null;
Ae.DEFAULT_MAPPING = Ao;
Ae.DEFAULT_ANISOTROPY = 1;
class ci {
  constructor(t = 0, e = 0, i = 0, n = 1) {
    this.isQuaternion = !0, this._x = t, this._y = e, this._z = i, this._w = n;
  }
  static slerpFlat(t, e, i, n, r, a, o) {
    let h = i[n + 0], l = i[n + 1], A = i[n + 2], u = i[n + 3];
    const f = r[a + 0], c = r[a + 1], d = r[a + 2], p = r[a + 3];
    if (o === 0) {
      t[e + 0] = h, t[e + 1] = l, t[e + 2] = A, t[e + 3] = u;
      return;
    }
    if (o === 1) {
      t[e + 0] = f, t[e + 1] = c, t[e + 2] = d, t[e + 3] = p;
      return;
    }
    if (u !== p || h !== f || l !== c || A !== d) {
      let m = 1 - o;
      const v = h * f + l * c + A * d + u * p, _ = v >= 0 ? 1 : -1, g = 1 - v * v;
      if (g > Number.EPSILON) {
        const x = Math.sqrt(g), b = Math.atan2(x, v * _);
        m = Math.sin(m * b) / x, o = Math.sin(o * b) / x;
      }
      const y = o * _;
      if (h = h * m + f * y, l = l * m + c * y, A = A * m + d * y, u = u * m + p * y, m === 1 - o) {
        const x = 1 / Math.sqrt(h * h + l * l + A * A + u * u);
        h *= x, l *= x, A *= x, u *= x;
      }
    }
    t[e] = h, t[e + 1] = l, t[e + 2] = A, t[e + 3] = u;
  }
  static multiplyQuaternionsFlat(t, e, i, n, r, a) {
    const o = i[n], h = i[n + 1], l = i[n + 2], A = i[n + 3], u = r[a], f = r[a + 1], c = r[a + 2], d = r[a + 3];
    return t[e] = o * d + A * u + h * c - l * f, t[e + 1] = h * d + A * f + l * u - o * c, t[e + 2] = l * d + A * c + o * f - h * u, t[e + 3] = A * d - o * u - h * f - l * c, t;
  }
  get x() {
    return this._x;
  }
  set x(t) {
    this._x = t, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(t) {
    this._y = t, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(t) {
    this._z = t, this._onChangeCallback();
  }
  get w() {
    return this._w;
  }
  set w(t) {
    this._w = t, this._onChangeCallback();
  }
  set(t, e, i, n) {
    return this._x = t, this._y = e, this._z = i, this._w = n, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._w);
  }
  copy(t) {
    return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this;
  }
  setFromEuler(t, e = !0) {
    const i = t._x, n = t._y, r = t._z, a = t._order, o = Math.cos, h = Math.sin, l = o(i / 2), A = o(n / 2), u = o(r / 2), f = h(i / 2), c = h(n / 2), d = h(r / 2);
    switch (a) {
      case "XYZ":
        this._x = f * A * u + l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u - f * c * d;
        break;
      case "YXZ":
        this._x = f * A * u + l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u + f * c * d;
        break;
      case "ZXY":
        this._x = f * A * u - l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u - f * c * d;
        break;
      case "ZYX":
        this._x = f * A * u - l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u + f * c * d;
        break;
      case "YZX":
        this._x = f * A * u + l * c * d, this._y = l * c * u + f * A * d, this._z = l * A * d - f * c * u, this._w = l * A * u - f * c * d;
        break;
      case "XZY":
        this._x = f * A * u - l * c * d, this._y = l * c * u - f * A * d, this._z = l * A * d + f * c * u, this._w = l * A * u + f * c * d;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + a);
    }
    return e === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(t, e) {
    const i = e / 2, n = Math.sin(i);
    return this._x = t.x * n, this._y = t.y * n, this._z = t.z * n, this._w = Math.cos(i), this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t) {
    const e = t.elements, i = e[0], n = e[4], r = e[8], a = e[1], o = e[5], h = e[9], l = e[2], A = e[6], u = e[10], f = i + o + u;
    if (f > 0) {
      const c = 0.5 / Math.sqrt(f + 1);
      this._w = 0.25 / c, this._x = (A - h) * c, this._y = (r - l) * c, this._z = (a - n) * c;
    } else if (i > o && i > u) {
      const c = 2 * Math.sqrt(1 + i - o - u);
      this._w = (A - h) / c, this._x = 0.25 * c, this._y = (n + a) / c, this._z = (r + l) / c;
    } else if (o > u) {
      const c = 2 * Math.sqrt(1 + o - i - u);
      this._w = (r - l) / c, this._x = (n + a) / c, this._y = 0.25 * c, this._z = (h + A) / c;
    } else {
      const c = 2 * Math.sqrt(1 + u - i - o);
      this._w = (a - n) / c, this._x = (r + l) / c, this._y = (h + A) / c, this._z = 0.25 * c;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(t, e) {
    let i = t.dot(e) + 1;
    return i < Number.EPSILON ? (i = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = i) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = i)) : (this._x = t.y * e.z - t.z * e.y, this._y = t.z * e.x - t.x * e.z, this._z = t.x * e.y - t.y * e.x, this._w = i), this.normalize();
  }
  angleTo(t) {
    return 2 * Math.acos(Math.abs(mt(this.dot(t), -1, 1)));
  }
  rotateTowards(t, e) {
    const i = this.angleTo(t);
    if (i === 0)
      return this;
    const n = Math.min(1, e / i);
    return this.slerp(t, n), this;
  }
  identity() {
    return this.set(0, 0, 0, 1);
  }
  invert() {
    return this.conjugate();
  }
  conjugate() {
    return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
  }
  dot(t) {
    return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w;
  }
  lengthSq() {
    return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  }
  length() {
    return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  }
  normalize() {
    let t = this.length();
    return t === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this;
  }
  multiply(t) {
    return this.multiplyQuaternions(this, t);
  }
  premultiply(t) {
    return this.multiplyQuaternions(t, this);
  }
  multiplyQuaternions(t, e) {
    const i = t._x, n = t._y, r = t._z, a = t._w, o = e._x, h = e._y, l = e._z, A = e._w;
    return this._x = i * A + a * o + n * l - r * h, this._y = n * A + a * h + r * o - i * l, this._z = r * A + a * l + i * h - n * o, this._w = a * A - i * o - n * h - r * l, this._onChangeCallback(), this;
  }
  slerp(t, e) {
    if (e === 0)
      return this;
    if (e === 1)
      return this.copy(t);
    const i = this._x, n = this._y, r = this._z, a = this._w;
    let o = a * t._w + i * t._x + n * t._y + r * t._z;
    if (o < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, o = -o) : this.copy(t), o >= 1)
      return this._w = a, this._x = i, this._y = n, this._z = r, this;
    const h = 1 - o * o;
    if (h <= Number.EPSILON) {
      const c = 1 - e;
      return this._w = c * a + e * this._w, this._x = c * i + e * this._x, this._y = c * n + e * this._y, this._z = c * r + e * this._z, this.normalize(), this;
    }
    const l = Math.sqrt(h), A = Math.atan2(l, o), u = Math.sin((1 - e) * A) / l, f = Math.sin(e * A) / l;
    return this._w = a * u + this._w * f, this._x = i * u + this._x * f, this._y = n * u + this._y * f, this._z = r * u + this._z * f, this._onChangeCallback(), this;
  }
  slerpQuaternions(t, e, i) {
    return this.copy(t).slerp(e, i);
  }
  random() {
    const t = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), i = Math.random(), n = Math.sqrt(1 - i), r = Math.sqrt(i);
    return this.set(
      n * Math.sin(t),
      n * Math.cos(t),
      r * Math.sin(e),
      r * Math.cos(e)
    );
  }
  equals(t) {
    return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w;
  }
  fromArray(t, e = 0) {
    return this._x = t[e], this._y = t[e + 1], this._z = t[e + 2], this._w = t[e + 3], this._onChangeCallback(), this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._w, t;
  }
  fromBufferAttribute(t, e) {
    return this._x = t.getX(e), this._y = t.getY(e), this._z = t.getZ(e), this._w = t.getW(e), this._onChangeCallback(), this;
  }
  toJSON() {
    return this.toArray();
  }
  _onChange(t) {
    return this._onChangeCallback = t, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._w;
  }
}
class j {
  constructor(t = 0, e = 0, i = 0) {
    j.prototype.isVector3 = !0, this.x = t, this.y = e, this.z = i;
  }
  set(t, e, i) {
    return i === void 0 && (i = this.z), this.x = t, this.y = e, this.z = i, this;
  }
  setScalar(t) {
    return this.x = t, this.y = t, this.z = t, this;
  }
  setX(t) {
    return this.x = t, this;
  }
  setY(t) {
    return this.y = t, this;
  }
  setZ(t) {
    return this.z = t, this;
  }
  setComponent(t, e) {
    switch (t) {
      case 0:
        this.x = e;
        break;
      case 1:
        this.y = e;
        break;
      case 2:
        this.z = e;
        break;
      default:
        throw new Error("index is out of range: " + t);
    }
    return this;
  }
  getComponent(t) {
    switch (t) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      default:
        throw new Error("index is out of range: " + t);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z);
  }
  copy(t) {
    return this.x = t.x, this.y = t.y, this.z = t.z, this;
  }
  add(t) {
    return this.x += t.x, this.y += t.y, this.z += t.z, this;
  }
  addScalar(t) {
    return this.x += t, this.y += t, this.z += t, this;
  }
  addVectors(t, e) {
    return this.x = t.x + e.x, this.y = t.y + e.y, this.z = t.z + e.z, this;
  }
  addScaledVector(t, e) {
    return this.x += t.x * e, this.y += t.y * e, this.z += t.z * e, this;
  }
  sub(t) {
    return this.x -= t.x, this.y -= t.y, this.z -= t.z, this;
  }
  subScalar(t) {
    return this.x -= t, this.y -= t, this.z -= t, this;
  }
  subVectors(t, e) {
    return this.x = t.x - e.x, this.y = t.y - e.y, this.z = t.z - e.z, this;
  }
  multiply(t) {
    return this.x *= t.x, this.y *= t.y, this.z *= t.z, this;
  }
  multiplyScalar(t) {
    return this.x *= t, this.y *= t, this.z *= t, this;
  }
  multiplyVectors(t, e) {
    return this.x = t.x * e.x, this.y = t.y * e.y, this.z = t.z * e.z, this;
  }
  applyEuler(t) {
    return this.applyQuaternion(oa.setFromEuler(t));
  }
  applyAxisAngle(t, e) {
    return this.applyQuaternion(oa.setFromAxisAngle(t, e));
  }
  applyMatrix3(t) {
    const e = this.x, i = this.y, n = this.z, r = t.elements;
    return this.x = r[0] * e + r[3] * i + r[6] * n, this.y = r[1] * e + r[4] * i + r[7] * n, this.z = r[2] * e + r[5] * i + r[8] * n, this;
  }
  applyNormalMatrix(t) {
    return this.applyMatrix3(t).normalize();
  }
  applyMatrix4(t) {
    const e = this.x, i = this.y, n = this.z, r = t.elements, a = 1 / (r[3] * e + r[7] * i + r[11] * n + r[15]);
    return this.x = (r[0] * e + r[4] * i + r[8] * n + r[12]) * a, this.y = (r[1] * e + r[5] * i + r[9] * n + r[13]) * a, this.z = (r[2] * e + r[6] * i + r[10] * n + r[14]) * a, this;
  }
  applyQuaternion(t) {
    const e = this.x, i = this.y, n = this.z, r = t.x, a = t.y, o = t.z, h = t.w, l = 2 * (a * n - o * i), A = 2 * (o * e - r * n), u = 2 * (r * i - a * e);
    return this.x = e + h * l + a * u - o * A, this.y = i + h * A + o * l - r * u, this.z = n + h * u + r * A - a * l, this;
  }
  project(t) {
    return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);
  }
  unproject(t) {
    return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);
  }
  transformDirection(t) {
    const e = this.x, i = this.y, n = this.z, r = t.elements;
    return this.x = r[0] * e + r[4] * i + r[8] * n, this.y = r[1] * e + r[5] * i + r[9] * n, this.z = r[2] * e + r[6] * i + r[10] * n, this.normalize();
  }
  divide(t) {
    return this.x /= t.x, this.y /= t.y, this.z /= t.z, this;
  }
  divideScalar(t) {
    return this.multiplyScalar(1 / t);
  }
  min(t) {
    return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this;
  }
  max(t) {
    return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this;
  }
  clamp(t, e) {
    return this.x = Math.max(t.x, Math.min(e.x, this.x)), this.y = Math.max(t.y, Math.min(e.y, this.y)), this.z = Math.max(t.z, Math.min(e.z, this.z)), this;
  }
  clampScalar(t, e) {
    return this.x = Math.max(t, Math.min(e, this.x)), this.y = Math.max(t, Math.min(e, this.y)), this.z = Math.max(t, Math.min(e, this.z)), this;
  }
  clampLength(t, e) {
    const i = this.length();
    return this.divideScalar(i || 1).multiplyScalar(Math.max(t, Math.min(e, i)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
  }
  dot(t) {
    return this.x * t.x + this.y * t.y + this.z * t.z;
  }
  // TODO lengthSquared?
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(t) {
    return this.normalize().multiplyScalar(t);
  }
  lerp(t, e) {
    return this.x += (t.x - this.x) * e, this.y += (t.y - this.y) * e, this.z += (t.z - this.z) * e, this;
  }
  lerpVectors(t, e, i) {
    return this.x = t.x + (e.x - t.x) * i, this.y = t.y + (e.y - t.y) * i, this.z = t.z + (e.z - t.z) * i, this;
  }
  cross(t) {
    return this.crossVectors(this, t);
  }
  crossVectors(t, e) {
    const i = t.x, n = t.y, r = t.z, a = e.x, o = e.y, h = e.z;
    return this.x = n * h - r * o, this.y = r * a - i * h, this.z = i * o - n * a, this;
  }
  projectOnVector(t) {
    const e = t.lengthSq();
    if (e === 0)
      return this.set(0, 0, 0);
    const i = t.dot(this) / e;
    return this.copy(t).multiplyScalar(i);
  }
  projectOnPlane(t) {
    return Fs.copy(this).projectOnVector(t), this.sub(Fs);
  }
  reflect(t) {
    return this.sub(Fs.copy(t).multiplyScalar(2 * this.dot(t)));
  }
  angleTo(t) {
    const e = Math.sqrt(this.lengthSq() * t.lengthSq());
    if (e === 0)
      return Math.PI / 2;
    const i = this.dot(t) / e;
    return Math.acos(mt(i, -1, 1));
  }
  distanceTo(t) {
    return Math.sqrt(this.distanceToSquared(t));
  }
  distanceToSquared(t) {
    const e = this.x - t.x, i = this.y - t.y, n = this.z - t.z;
    return e * e + i * i + n * n;
  }
  manhattanDistanceTo(t) {
    return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z);
  }
  setFromSpherical(t) {
    return this.setFromSphericalCoords(t.radius, t.phi, t.theta);
  }
  setFromSphericalCoords(t, e, i) {
    const n = Math.sin(e) * t;
    return this.x = n * Math.sin(i), this.y = Math.cos(e) * t, this.z = n * Math.cos(i), this;
  }
  setFromCylindrical(t) {
    return this.setFromCylindricalCoords(t.radius, t.theta, t.y);
  }
  setFromCylindricalCoords(t, e, i) {
    return this.x = t * Math.sin(e), this.y = i, this.z = t * Math.cos(e), this;
  }
  setFromMatrixPosition(t) {
    const e = t.elements;
    return this.x = e[12], this.y = e[13], this.z = e[14], this;
  }
  setFromMatrixScale(t) {
    const e = this.setFromMatrixColumn(t, 0).length(), i = this.setFromMatrixColumn(t, 1).length(), n = this.setFromMatrixColumn(t, 2).length();
    return this.x = e, this.y = i, this.z = n, this;
  }
  setFromMatrixColumn(t, e) {
    return this.fromArray(t.elements, e * 4);
  }
  setFromMatrix3Column(t, e) {
    return this.fromArray(t.elements, e * 3);
  }
  setFromEuler(t) {
    return this.x = t._x, this.y = t._y, this.z = t._z, this;
  }
  setFromColor(t) {
    return this.x = t.r, this.y = t.g, this.z = t.b, this;
  }
  equals(t) {
    return t.x === this.x && t.y === this.y && t.z === this.z;
  }
  fromArray(t, e = 0) {
    return this.x = t[e], this.y = t[e + 1], this.z = t[e + 2], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.x, t[e + 1] = this.y, t[e + 2] = this.z, t;
  }
  fromBufferAttribute(t, e) {
    return this.x = t.getX(e), this.y = t.getY(e), this.z = t.getZ(e), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
  }
  randomDirection() {
    const t = Math.random() * Math.PI * 2, e = Math.random() * 2 - 1, i = Math.sqrt(1 - e * e);
    return this.x = i * Math.cos(t), this.y = e, this.z = i * Math.sin(t), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const Fs = /* @__PURE__ */ new j(), oa = /* @__PURE__ */ new ci();
class ot {
  constructor(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m) {
    ot.prototype.isMatrix4 = !0, this.elements = [
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ], t !== void 0 && this.set(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m);
  }
  set(t, e, i, n, r, a, o, h, l, A, u, f, c, d, p, m) {
    const v = this.elements;
    return v[0] = t, v[4] = e, v[8] = i, v[12] = n, v[1] = r, v[5] = a, v[9] = o, v[13] = h, v[2] = l, v[6] = A, v[10] = u, v[14] = f, v[3] = c, v[7] = d, v[11] = p, v[15] = m, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  clone() {
    return new ot().fromArray(this.elements);
  }
  copy(t) {
    const e = this.elements, i = t.elements;
    return e[0] = i[0], e[1] = i[1], e[2] = i[2], e[3] = i[3], e[4] = i[4], e[5] = i[5], e[6] = i[6], e[7] = i[7], e[8] = i[8], e[9] = i[9], e[10] = i[10], e[11] = i[11], e[12] = i[12], e[13] = i[13], e[14] = i[14], e[15] = i[15], this;
  }
  copyPosition(t) {
    const e = this.elements, i = t.elements;
    return e[12] = i[12], e[13] = i[13], e[14] = i[14], this;
  }
  setFromMatrix3(t) {
    const e = t.elements;
    return this.set(
      e[0],
      e[3],
      e[6],
      0,
      e[1],
      e[4],
      e[7],
      0,
      e[2],
      e[5],
      e[8],
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractBasis(t, e, i) {
    return t.setFromMatrixColumn(this, 0), e.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(t, e, i) {
    return this.set(
      t.x,
      e.x,
      i.x,
      0,
      t.y,
      e.y,
      i.y,
      0,
      t.z,
      e.z,
      i.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(t) {
    const e = this.elements, i = t.elements, n = 1 / ze.setFromMatrixColumn(t, 0).length(), r = 1 / ze.setFromMatrixColumn(t, 1).length(), a = 1 / ze.setFromMatrixColumn(t, 2).length();
    return e[0] = i[0] * n, e[1] = i[1] * n, e[2] = i[2] * n, e[3] = 0, e[4] = i[4] * r, e[5] = i[5] * r, e[6] = i[6] * r, e[7] = 0, e[8] = i[8] * a, e[9] = i[9] * a, e[10] = i[10] * a, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  }
  makeRotationFromEuler(t) {
    const e = this.elements, i = t.x, n = t.y, r = t.z, a = Math.cos(i), o = Math.sin(i), h = Math.cos(n), l = Math.sin(n), A = Math.cos(r), u = Math.sin(r);
    if (t.order === "XYZ") {
      const f = a * A, c = a * u, d = o * A, p = o * u;
      e[0] = h * A, e[4] = -h * u, e[8] = l, e[1] = c + d * l, e[5] = f - p * l, e[9] = -o * h, e[2] = p - f * l, e[6] = d + c * l, e[10] = a * h;
    } else if (t.order === "YXZ") {
      const f = h * A, c = h * u, d = l * A, p = l * u;
      e[0] = f + p * o, e[4] = d * o - c, e[8] = a * l, e[1] = a * u, e[5] = a * A, e[9] = -o, e[2] = c * o - d, e[6] = p + f * o, e[10] = a * h;
    } else if (t.order === "ZXY") {
      const f = h * A, c = h * u, d = l * A, p = l * u;
      e[0] = f - p * o, e[4] = -a * u, e[8] = d + c * o, e[1] = c + d * o, e[5] = a * A, e[9] = p - f * o, e[2] = -a * l, e[6] = o, e[10] = a * h;
    } else if (t.order === "ZYX") {
      const f = a * A, c = a * u, d = o * A, p = o * u;
      e[0] = h * A, e[4] = d * l - c, e[8] = f * l + p, e[1] = h * u, e[5] = p * l + f, e[9] = c * l - d, e[2] = -l, e[6] = o * h, e[10] = a * h;
    } else if (t.order === "YZX") {
      const f = a * h, c = a * l, d = o * h, p = o * l;
      e[0] = h * A, e[4] = p - f * u, e[8] = d * u + c, e[1] = u, e[5] = a * A, e[9] = -o * A, e[2] = -l * A, e[6] = c * u + d, e[10] = f - p * u;
    } else if (t.order === "XZY") {
      const f = a * h, c = a * l, d = o * h, p = o * l;
      e[0] = h * A, e[4] = -u, e[8] = l * A, e[1] = f * u + p, e[5] = a * A, e[9] = c * u - d, e[2] = d * u - c, e[6] = o * A, e[10] = p * u + f;
    }
    return e[3] = 0, e[7] = 0, e[11] = 0, e[12] = 0, e[13] = 0, e[14] = 0, e[15] = 1, this;
  }
  makeRotationFromQuaternion(t) {
    return this.compose(hA, t, lA);
  }
  lookAt(t, e, i) {
    const n = this.elements;
    return xt.subVectors(t, e), xt.lengthSq() === 0 && (xt.z = 1), xt.normalize(), re.crossVectors(i, xt), re.lengthSq() === 0 && (Math.abs(i.z) === 1 ? xt.x += 1e-4 : xt.z += 1e-4, xt.normalize(), re.crossVectors(i, xt)), re.normalize(), qi.crossVectors(xt, re), n[0] = re.x, n[4] = qi.x, n[8] = xt.x, n[1] = re.y, n[5] = qi.y, n[9] = xt.y, n[2] = re.z, n[6] = qi.z, n[10] = xt.z, this;
  }
  multiply(t) {
    return this.multiplyMatrices(this, t);
  }
  premultiply(t) {
    return this.multiplyMatrices(t, this);
  }
  multiplyMatrices(t, e) {
    const i = t.elements, n = e.elements, r = this.elements, a = i[0], o = i[4], h = i[8], l = i[12], A = i[1], u = i[5], f = i[9], c = i[13], d = i[2], p = i[6], m = i[10], v = i[14], _ = i[3], g = i[7], y = i[11], x = i[15], b = n[0], C = n[4], w = n[8], E = n[12], S = n[1], P = n[5], k = n[9], F = n[13], L = n[2], I = n[6], z = n[10], T = n[14], G = n[3], H = n[7], R = n[11], N = n[15];
    return r[0] = a * b + o * S + h * L + l * G, r[4] = a * C + o * P + h * I + l * H, r[8] = a * w + o * k + h * z + l * R, r[12] = a * E + o * F + h * T + l * N, r[1] = A * b + u * S + f * L + c * G, r[5] = A * C + u * P + f * I + c * H, r[9] = A * w + u * k + f * z + c * R, r[13] = A * E + u * F + f * T + c * N, r[2] = d * b + p * S + m * L + v * G, r[6] = d * C + p * P + m * I + v * H, r[10] = d * w + p * k + m * z + v * R, r[14] = d * E + p * F + m * T + v * N, r[3] = _ * b + g * S + y * L + x * G, r[7] = _ * C + g * P + y * I + x * H, r[11] = _ * w + g * k + y * z + x * R, r[15] = _ * E + g * F + y * T + x * N, this;
  }
  multiplyScalar(t) {
    const e = this.elements;
    return e[0] *= t, e[4] *= t, e[8] *= t, e[12] *= t, e[1] *= t, e[5] *= t, e[9] *= t, e[13] *= t, e[2] *= t, e[6] *= t, e[10] *= t, e[14] *= t, e[3] *= t, e[7] *= t, e[11] *= t, e[15] *= t, this;
  }
  determinant() {
    const t = this.elements, e = t[0], i = t[4], n = t[8], r = t[12], a = t[1], o = t[5], h = t[9], l = t[13], A = t[2], u = t[6], f = t[10], c = t[14], d = t[3], p = t[7], m = t[11], v = t[15];
    return d * (+r * h * u - n * l * u - r * o * f + i * l * f + n * o * c - i * h * c) + p * (+e * h * c - e * l * f + r * a * f - n * a * c + n * l * A - r * h * A) + m * (+e * l * u - e * o * c - r * a * u + i * a * c + r * o * A - i * l * A) + v * (-n * o * A - e * h * u + e * o * f + n * a * u - i * a * f + i * h * A);
  }
  transpose() {
    const t = this.elements;
    let e;
    return e = t[1], t[1] = t[4], t[4] = e, e = t[2], t[2] = t[8], t[8] = e, e = t[6], t[6] = t[9], t[9] = e, e = t[3], t[3] = t[12], t[12] = e, e = t[7], t[7] = t[13], t[13] = e, e = t[11], t[11] = t[14], t[14] = e, this;
  }
  setPosition(t, e, i) {
    const n = this.elements;
    return t.isVector3 ? (n[12] = t.x, n[13] = t.y, n[14] = t.z) : (n[12] = t, n[13] = e, n[14] = i), this;
  }
  invert() {
    const t = this.elements, e = t[0], i = t[1], n = t[2], r = t[3], a = t[4], o = t[5], h = t[6], l = t[7], A = t[8], u = t[9], f = t[10], c = t[11], d = t[12], p = t[13], m = t[14], v = t[15], _ = u * m * l - p * f * l + p * h * c - o * m * c - u * h * v + o * f * v, g = d * f * l - A * m * l - d * h * c + a * m * c + A * h * v - a * f * v, y = A * p * l - d * u * l + d * o * c - a * p * c - A * o * v + a * u * v, x = d * u * h - A * p * h - d * o * f + a * p * f + A * o * m - a * u * m, b = e * _ + i * g + n * y + r * x;
    if (b === 0)
      return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const C = 1 / b;
    return t[0] = _ * C, t[1] = (p * f * r - u * m * r - p * n * c + i * m * c + u * n * v - i * f * v) * C, t[2] = (o * m * r - p * h * r + p * n * l - i * m * l - o * n * v + i * h * v) * C, t[3] = (u * h * r - o * f * r - u * n * l + i * f * l + o * n * c - i * h * c) * C, t[4] = g * C, t[5] = (A * m * r - d * f * r + d * n * c - e * m * c - A * n * v + e * f * v) * C, t[6] = (d * h * r - a * m * r - d * n * l + e * m * l + a * n * v - e * h * v) * C, t[7] = (a * f * r - A * h * r + A * n * l - e * f * l - a * n * c + e * h * c) * C, t[8] = y * C, t[9] = (d * u * r - A * p * r - d * i * c + e * p * c + A * i * v - e * u * v) * C, t[10] = (a * p * r - d * o * r + d * i * l - e * p * l - a * i * v + e * o * v) * C, t[11] = (A * o * r - a * u * r - A * i * l + e * u * l + a * i * c - e * o * c) * C, t[12] = x * C, t[13] = (A * p * n - d * u * n + d * i * f - e * p * f - A * i * m + e * u * m) * C, t[14] = (d * o * n - a * p * n - d * i * h + e * p * h + a * i * m - e * o * m) * C, t[15] = (a * u * n - A * o * n + A * i * h - e * u * h - a * i * f + e * o * f) * C, this;
  }
  scale(t) {
    const e = this.elements, i = t.x, n = t.y, r = t.z;
    return e[0] *= i, e[4] *= n, e[8] *= r, e[1] *= i, e[5] *= n, e[9] *= r, e[2] *= i, e[6] *= n, e[10] *= r, e[3] *= i, e[7] *= n, e[11] *= r, this;
  }
  getMaxScaleOnAxis() {
    const t = this.elements, e = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], i = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], n = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
    return Math.sqrt(Math.max(e, i, n));
  }
  makeTranslation(t, e, i) {
    return t.isVector3 ? this.set(
      1,
      0,
      0,
      t.x,
      0,
      1,
      0,
      t.y,
      0,
      0,
      1,
      t.z,
      0,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      0,
      t,
      0,
      1,
      0,
      e,
      0,
      0,
      1,
      i,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationX(t) {
    const e = Math.cos(t), i = Math.sin(t);
    return this.set(
      1,
      0,
      0,
      0,
      0,
      e,
      -i,
      0,
      0,
      i,
      e,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationY(t) {
    const e = Math.cos(t), i = Math.sin(t);
    return this.set(
      e,
      0,
      i,
      0,
      0,
      1,
      0,
      0,
      -i,
      0,
      e,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationZ(t) {
    const e = Math.cos(t), i = Math.sin(t);
    return this.set(
      e,
      -i,
      0,
      0,
      i,
      e,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationAxis(t, e) {
    const i = Math.cos(e), n = Math.sin(e), r = 1 - i, a = t.x, o = t.y, h = t.z, l = r * a, A = r * o;
    return this.set(
      l * a + i,
      l * o - n * h,
      l * h + n * o,
      0,
      l * o + n * h,
      A * o + i,
      A * h - n * a,
      0,
      l * h - n * o,
      A * h + n * a,
      r * h * h + i,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(t, e, i) {
    return this.set(
      t,
      0,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      0,
      i,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeShear(t, e, i, n, r, a) {
    return this.set(
      1,
      i,
      r,
      0,
      t,
      1,
      a,
      0,
      e,
      n,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(t, e, i) {
    const n = this.elements, r = e._x, a = e._y, o = e._z, h = e._w, l = r + r, A = a + a, u = o + o, f = r * l, c = r * A, d = r * u, p = a * A, m = a * u, v = o * u, _ = h * l, g = h * A, y = h * u, x = i.x, b = i.y, C = i.z;
    return n[0] = (1 - (p + v)) * x, n[1] = (c + y) * x, n[2] = (d - g) * x, n[3] = 0, n[4] = (c - y) * b, n[5] = (1 - (f + v)) * b, n[6] = (m + _) * b, n[7] = 0, n[8] = (d + g) * C, n[9] = (m - _) * C, n[10] = (1 - (f + p)) * C, n[11] = 0, n[12] = t.x, n[13] = t.y, n[14] = t.z, n[15] = 1, this;
  }
  decompose(t, e, i) {
    const n = this.elements;
    let r = ze.set(n[0], n[1], n[2]).length();
    const a = ze.set(n[4], n[5], n[6]).length(), o = ze.set(n[8], n[9], n[10]).length();
    this.determinant() < 0 && (r = -r), t.x = n[12], t.y = n[13], t.z = n[14], kt.copy(this);
    const l = 1 / r, A = 1 / a, u = 1 / o;
    return kt.elements[0] *= l, kt.elements[1] *= l, kt.elements[2] *= l, kt.elements[4] *= A, kt.elements[5] *= A, kt.elements[6] *= A, kt.elements[8] *= u, kt.elements[9] *= u, kt.elements[10] *= u, e.setFromRotationMatrix(kt), i.x = r, i.y = a, i.z = o, this;
  }
  makePerspective(t, e, i, n, r, a, o = Xi) {
    const h = this.elements, l = 2 * r / (e - t), A = 2 * r / (i - n), u = (e + t) / (e - t), f = (i + n) / (i - n);
    let c, d;
    if (o === Xi)
      c = -(a + r) / (a - r), d = -2 * a * r / (a - r);
    else if (o === ia)
      c = -a / (a - r), d = -a * r / (a - r);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);
    return h[0] = l, h[4] = 0, h[8] = u, h[12] = 0, h[1] = 0, h[5] = A, h[9] = f, h[13] = 0, h[2] = 0, h[6] = 0, h[10] = c, h[14] = d, h[3] = 0, h[7] = 0, h[11] = -1, h[15] = 0, this;
  }
  makeOrthographic(t, e, i, n, r, a, o = Xi) {
    const h = this.elements, l = 1 / (e - t), A = 1 / (i - n), u = 1 / (a - r), f = (e + t) * l, c = (i + n) * A;
    let d, p;
    if (o === Xi)
      d = (a + r) * u, p = -2 * u;
    else if (o === ia)
      d = r * u, p = -1 * u;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);
    return h[0] = 2 * l, h[4] = 0, h[8] = 0, h[12] = -f, h[1] = 0, h[5] = 2 * A, h[9] = 0, h[13] = -c, h[2] = 0, h[6] = 0, h[10] = p, h[14] = -d, h[3] = 0, h[7] = 0, h[11] = 0, h[15] = 1, this;
  }
  equals(t) {
    const e = this.elements, i = t.elements;
    for (let n = 0; n < 16; n++)
      if (e[n] !== i[n])
        return !1;
    return !0;
  }
  fromArray(t, e = 0) {
    for (let i = 0; i < 16; i++)
      this.elements[i] = t[i + e];
    return this;
  }
  toArray(t = [], e = 0) {
    const i = this.elements;
    return t[e] = i[0], t[e + 1] = i[1], t[e + 2] = i[2], t[e + 3] = i[3], t[e + 4] = i[4], t[e + 5] = i[5], t[e + 6] = i[6], t[e + 7] = i[7], t[e + 8] = i[8], t[e + 9] = i[9], t[e + 10] = i[10], t[e + 11] = i[11], t[e + 12] = i[12], t[e + 13] = i[13], t[e + 14] = i[14], t[e + 15] = i[15], t;
  }
}
const ze = /* @__PURE__ */ new j(), kt = /* @__PURE__ */ new ot(), hA = /* @__PURE__ */ new j(0, 0, 0), lA = /* @__PURE__ */ new j(1, 1, 1), re = /* @__PURE__ */ new j(), qi = /* @__PURE__ */ new j(), xt = /* @__PURE__ */ new j(), ha = /* @__PURE__ */ new ot(), la = /* @__PURE__ */ new ci();
class zi {
  constructor(t = 0, e = 0, i = 0, n = zi.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = t, this._y = e, this._z = i, this._order = n;
  }
  get x() {
    return this._x;
  }
  set x(t) {
    this._x = t, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(t) {
    this._y = t, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(t) {
    this._z = t, this._onChangeCallback();
  }
  get order() {
    return this._order;
  }
  set order(t) {
    this._order = t, this._onChangeCallback();
  }
  set(t, e, i, n = this._order) {
    return this._x = t, this._y = e, this._z = i, this._order = n, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._order);
  }
  copy(t) {
    return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this;
  }
  setFromRotationMatrix(t, e = this._order, i = !0) {
    const n = t.elements, r = n[0], a = n[4], o = n[8], h = n[1], l = n[5], A = n[9], u = n[2], f = n[6], c = n[10];
    switch (e) {
      case "XYZ":
        this._y = Math.asin(mt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-A, c), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(f, l), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-mt(A, -1, 1)), Math.abs(A) < 0.9999999 ? (this._y = Math.atan2(o, c), this._z = Math.atan2(h, l)) : (this._y = Math.atan2(-u, r), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(mt(f, -1, 1)), Math.abs(f) < 0.9999999 ? (this._y = Math.atan2(-u, c), this._z = Math.atan2(-a, l)) : (this._y = 0, this._z = Math.atan2(h, r));
        break;
      case "ZYX":
        this._y = Math.asin(-mt(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(f, c), this._z = Math.atan2(h, r)) : (this._x = 0, this._z = Math.atan2(-a, l));
        break;
      case "YZX":
        this._z = Math.asin(mt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(-A, l), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, c));
        break;
      case "XZY":
        this._z = Math.asin(-mt(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(f, l), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-A, c), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + e);
    }
    return this._order = e, i === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(t, e, i) {
    return ha.makeRotationFromQuaternion(t), this.setFromRotationMatrix(ha, e, i);
  }
  setFromVector3(t, e = this._order) {
    return this.set(t.x, t.y, t.z, e);
  }
  reorder(t) {
    return la.setFromEuler(this), this.setFromQuaternion(la, t);
  }
  equals(t) {
    return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order;
  }
  fromArray(t) {
    return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this._x, t[e + 1] = this._y, t[e + 2] = this._z, t[e + 3] = this._order, t;
  }
  _onChange(t) {
    return this._onChangeCallback = t, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._order;
  }
}
zi.DEFAULT_ORDER = "XYZ";
class AA {
  constructor() {
    this.mask = 1;
  }
  set(t) {
    this.mask = (1 << t | 0) >>> 0;
  }
  enable(t) {
    this.mask |= 1 << t | 0;
  }
  enableAll() {
    this.mask = -1;
  }
  toggle(t) {
    this.mask ^= 1 << t | 0;
  }
  disable(t) {
    this.mask &= ~(1 << t | 0);
  }
  disableAll() {
    this.mask = 0;
  }
  test(t) {
    return (this.mask & t.mask) !== 0;
  }
  isEnabled(t) {
    return (this.mask & (1 << t | 0)) !== 0;
  }
}
let cA = 0;
const Aa = /* @__PURE__ */ new j(), Ue = /* @__PURE__ */ new ci(), Vt = /* @__PURE__ */ new ot(), Qi = /* @__PURE__ */ new j(), vi = /* @__PURE__ */ new j(), dA = /* @__PURE__ */ new j(), uA = /* @__PURE__ */ new ci(), ca = /* @__PURE__ */ new j(1, 0, 0), da = /* @__PURE__ */ new j(0, 1, 0), ua = /* @__PURE__ */ new j(0, 0, 1), fa = { type: "added" }, fA = { type: "removed" }, He = { type: "childadded", child: null }, ks = { type: "childremoved", child: null };
class Se extends fo {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: cA++ }), this.uuid = Tn(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = Se.DEFAULT_UP.clone();
    const t = new j(), e = new zi(), i = new ci(), n = new j(1, 1, 1);
    function r() {
      i.setFromEuler(e, !1);
    }
    function a() {
      e.setFromQuaternion(i, void 0, !1);
    }
    e._onChange(r), i._onChange(a), Object.defineProperties(this, {
      position: {
        configurable: !0,
        enumerable: !0,
        value: t
      },
      rotation: {
        configurable: !0,
        enumerable: !0,
        value: e
      },
      quaternion: {
        configurable: !0,
        enumerable: !0,
        value: i
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: n
      },
      modelViewMatrix: {
        value: new ot()
      },
      normalMatrix: {
        value: new Jt()
      }
    }), this.matrix = new ot(), this.matrixWorld = new ot(), this.matrixAutoUpdate = Se.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = Se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new AA(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  }
  onBeforeShadow() {
  }
  onAfterShadow() {
  }
  onBeforeRender() {
  }
  onAfterRender() {
  }
  applyMatrix4(t) {
    this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(t), this.matrix.decompose(this.position, this.quaternion, this.scale);
  }
  applyQuaternion(t) {
    return this.quaternion.premultiply(t), this;
  }
  setRotationFromAxisAngle(t, e) {
    this.quaternion.setFromAxisAngle(t, e);
  }
  setRotationFromEuler(t) {
    this.quaternion.setFromEuler(t, !0);
  }
  setRotationFromMatrix(t) {
    this.quaternion.setFromRotationMatrix(t);
  }
  setRotationFromQuaternion(t) {
    this.quaternion.copy(t);
  }
  rotateOnAxis(t, e) {
    return Ue.setFromAxisAngle(t, e), this.quaternion.multiply(Ue), this;
  }
  rotateOnWorldAxis(t, e) {
    return Ue.setFromAxisAngle(t, e), this.quaternion.premultiply(Ue), this;
  }
  rotateX(t) {
    return this.rotateOnAxis(ca, t);
  }
  rotateY(t) {
    return this.rotateOnAxis(da, t);
  }
  rotateZ(t) {
    return this.rotateOnAxis(ua, t);
  }
  translateOnAxis(t, e) {
    return Aa.copy(t).applyQuaternion(this.quaternion), this.position.add(Aa.multiplyScalar(e)), this;
  }
  translateX(t) {
    return this.translateOnAxis(ca, t);
  }
  translateY(t) {
    return this.translateOnAxis(da, t);
  }
  translateZ(t) {
    return this.translateOnAxis(ua, t);
  }
  localToWorld(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(t) {
    return this.updateWorldMatrix(!0, !1), t.applyMatrix4(Vt.copy(this.matrixWorld).invert());
  }
  lookAt(t, e, i) {
    t.isVector3 ? Qi.copy(t) : Qi.set(t, e, i);
    const n = this.parent;
    this.updateWorldMatrix(!0, !1), vi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Vt.lookAt(vi, Qi, this.up) : Vt.lookAt(Qi, vi, this.up), this.quaternion.setFromRotationMatrix(Vt), n && (Vt.extractRotation(n.matrixWorld), Ue.setFromRotationMatrix(Vt), this.quaternion.premultiply(Ue.invert()));
  }
  add(t) {
    if (arguments.length > 1) {
      for (let e = 0; e < arguments.length; e++)
        this.add(arguments[e]);
      return this;
    }
    return t === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", t), this) : (t && t.isObject3D ? (t.removeFromParent(), t.parent = this, this.children.push(t), t.dispatchEvent(fa), He.child = t, this.dispatchEvent(He), He.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", t), this);
  }
  remove(t) {
    if (arguments.length > 1) {
      for (let i = 0; i < arguments.length; i++)
        this.remove(arguments[i]);
      return this;
    }
    const e = this.children.indexOf(t);
    return e !== -1 && (t.parent = null, this.children.splice(e, 1), t.dispatchEvent(fA), ks.child = t, this.dispatchEvent(ks), ks.child = null), this;
  }
  removeFromParent() {
    const t = this.parent;
    return t !== null && t.remove(this), this;
  }
  clear() {
    return this.remove(...this.children);
  }
  attach(t) {
    return this.updateWorldMatrix(!0, !1), Vt.copy(this.matrixWorld).invert(), t.parent !== null && (t.parent.updateWorldMatrix(!0, !1), Vt.multiply(t.parent.matrixWorld)), t.applyMatrix4(Vt), t.removeFromParent(), t.parent = this, this.children.push(t), t.updateWorldMatrix(!1, !0), t.dispatchEvent(fa), He.child = t, this.dispatchEvent(He), He.child = null, this;
  }
  getObjectById(t) {
    return this.getObjectByProperty("id", t);
  }
  getObjectByName(t) {
    return this.getObjectByProperty("name", t);
  }
  getObjectByProperty(t, e) {
    if (this[t] === e)
      return this;
    for (let i = 0, n = this.children.length; i < n; i++) {
      const a = this.children[i].getObjectByProperty(t, e);
      if (a !== void 0)
        return a;
    }
  }
  getObjectsByProperty(t, e, i = []) {
    this[t] === e && i.push(this);
    const n = this.children;
    for (let r = 0, a = n.length; r < a; r++)
      n[r].getObjectsByProperty(t, e, i);
    return i;
  }
  getWorldPosition(t) {
    return this.updateWorldMatrix(!0, !1), t.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(vi, t, dA), t;
  }
  getWorldScale(t) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(vi, uA, t), t;
  }
  getWorldDirection(t) {
    this.updateWorldMatrix(!0, !1);
    const e = this.matrixWorld.elements;
    return t.set(e[8], e[9], e[10]).normalize();
  }
  raycast() {
  }
  traverse(t) {
    t(this);
    const e = this.children;
    for (let i = 0, n = e.length; i < n; i++)
      e[i].traverse(t);
  }
  traverseVisible(t) {
    if (this.visible === !1)
      return;
    t(this);
    const e = this.children;
    for (let i = 0, n = e.length; i < n; i++)
      e[i].traverseVisible(t);
  }
  traverseAncestors(t) {
    const e = this.parent;
    e !== null && (t(e), e.traverseAncestors(t));
  }
  updateMatrix() {
    this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  }
  updateMatrixWorld(t) {
    this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || t) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, t = !0);
    const e = this.children;
    for (let i = 0, n = e.length; i < n; i++) {
      const r = e[i];
      (r.matrixWorldAutoUpdate === !0 || t === !0) && r.updateMatrixWorld(t);
    }
  }
  updateWorldMatrix(t, e) {
    const i = this.parent;
    if (t === !0 && i !== null && i.matrixWorldAutoUpdate === !0 && i.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), e === !0) {
      const n = this.children;
      for (let r = 0, a = n.length; r < a; r++) {
        const o = n[r];
        o.matrixWorldAutoUpdate === !0 && o.updateWorldMatrix(!1, !0);
      }
    }
  }
  toJSON(t) {
    const e = t === void 0 || typeof t == "string", i = {};
    e && (t = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, i.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const n = {};
    n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.castShadow === !0 && (n.castShadow = !0), this.receiveShadow === !0 && (n.receiveShadow = !0), this.visible === !1 && (n.visible = !1), this.frustumCulled === !1 && (n.frustumCulled = !1), this.renderOrder !== 0 && (n.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (n.userData = this.userData), n.layers = this.layers.mask, n.matrix = this.matrix.toArray(), n.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (n.matrixAutoUpdate = !1), this.isInstancedMesh && (n.type = "InstancedMesh", n.count = this.count, n.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (n.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (n.type = "BatchedMesh", n.perObjectFrustumCulled = this.perObjectFrustumCulled, n.sortObjects = this.sortObjects, n.drawRanges = this._drawRanges, n.reservedRanges = this._reservedRanges, n.visibility = this._visibility, n.active = this._active, n.bounds = this._bounds.map((o) => ({
      boxInitialized: o.boxInitialized,
      boxMin: o.box.min.toArray(),
      boxMax: o.box.max.toArray(),
      sphereInitialized: o.sphereInitialized,
      sphereRadius: o.sphere.radius,
      sphereCenter: o.sphere.center.toArray()
    })), n.maxGeometryCount = this._maxGeometryCount, n.maxVertexCount = this._maxVertexCount, n.maxIndexCount = this._maxIndexCount, n.geometryInitialized = this._geometryInitialized, n.geometryCount = this._geometryCount, n.matricesTexture = this._matricesTexture.toJSON(t), this.boundingSphere !== null && (n.boundingSphere = {
      center: n.boundingSphere.center.toArray(),
      radius: n.boundingSphere.radius
    }), this.boundingBox !== null && (n.boundingBox = {
      min: n.boundingBox.min.toArray(),
      max: n.boundingBox.max.toArray()
    }));
    function r(o, h) {
      return o[h.uuid] === void 0 && (o[h.uuid] = h.toJSON(t)), h.uuid;
    }
    if (this.isScene)
      this.background && (this.background.isColor ? n.background = this.background.toJSON() : this.background.isTexture && (n.background = this.background.toJSON(t).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (n.environment = this.environment.toJSON(t).uuid);
    else if (this.isMesh || this.isLine || this.isPoints) {
      n.geometry = r(t.geometries, this.geometry);
      const o = this.geometry.parameters;
      if (o !== void 0 && o.shapes !== void 0) {
        const h = o.shapes;
        if (Array.isArray(h))
          for (let l = 0, A = h.length; l < A; l++) {
            const u = h[l];
            r(t.shapes, u);
          }
        else
          r(t.shapes, h);
      }
    }
    if (this.isSkinnedMesh && (n.bindMode = this.bindMode, n.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (r(t.skeletons, this.skeleton), n.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const o = [];
        for (let h = 0, l = this.material.length; h < l; h++)
          o.push(r(t.materials, this.material[h]));
        n.material = o;
      } else
        n.material = r(t.materials, this.material);
    if (this.children.length > 0) {
      n.children = [];
      for (let o = 0; o < this.children.length; o++)
        n.children.push(this.children[o].toJSON(t).object);
    }
    if (this.animations.length > 0) {
      n.animations = [];
      for (let o = 0; o < this.animations.length; o++) {
        const h = this.animations[o];
        n.animations.push(r(t.animations, h));
      }
    }
    if (e) {
      const o = a(t.geometries), h = a(t.materials), l = a(t.textures), A = a(t.images), u = a(t.shapes), f = a(t.skeletons), c = a(t.animations), d = a(t.nodes);
      o.length > 0 && (i.geometries = o), h.length > 0 && (i.materials = h), l.length > 0 && (i.textures = l), A.length > 0 && (i.images = A), u.length > 0 && (i.shapes = u), f.length > 0 && (i.skeletons = f), c.length > 0 && (i.animations = c), d.length > 0 && (i.nodes = d);
    }
    return i.object = n, i;
    function a(o) {
      const h = [];
      for (const l in o) {
        const A = o[l];
        delete A.metadata, h.push(A);
      }
      return h;
    }
  }
  clone(t) {
    return new this.constructor().copy(this, t);
  }
  copy(t, e = !0) {
    if (this.name = t.name, this.up.copy(t.up), this.position.copy(t.position), this.rotation.order = t.rotation.order, this.quaternion.copy(t.quaternion), this.scale.copy(t.scale), this.matrix.copy(t.matrix), this.matrixWorld.copy(t.matrixWorld), this.matrixAutoUpdate = t.matrixAutoUpdate, this.matrixWorldAutoUpdate = t.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = t.matrixWorldNeedsUpdate, this.layers.mask = t.layers.mask, this.visible = t.visible, this.castShadow = t.castShadow, this.receiveShadow = t.receiveShadow, this.frustumCulled = t.frustumCulled, this.renderOrder = t.renderOrder, this.animations = t.animations.slice(), this.userData = JSON.parse(JSON.stringify(t.userData)), e === !0)
      for (let i = 0; i < t.children.length; i++) {
        const n = t.children[i];
        this.add(n.clone());
      }
    return this;
  }
}
Se.DEFAULT_UP = /* @__PURE__ */ new j(0, 1, 0);
Se.DEFAULT_MATRIX_AUTO_UPDATE = !0;
Se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const yo = {
  aliceblue: 15792383,
  antiquewhite: 16444375,
  aqua: 65535,
  aquamarine: 8388564,
  azure: 15794175,
  beige: 16119260,
  bisque: 16770244,
  black: 0,
  blanchedalmond: 16772045,
  blue: 255,
  blueviolet: 9055202,
  brown: 10824234,
  burlywood: 14596231,
  cadetblue: 6266528,
  chartreuse: 8388352,
  chocolate: 13789470,
  coral: 16744272,
  cornflowerblue: 6591981,
  cornsilk: 16775388,
  crimson: 14423100,
  cyan: 65535,
  darkblue: 139,
  darkcyan: 35723,
  darkgoldenrod: 12092939,
  darkgray: 11119017,
  darkgreen: 25600,
  darkgrey: 11119017,
  darkkhaki: 12433259,
  darkmagenta: 9109643,
  darkolivegreen: 5597999,
  darkorange: 16747520,
  darkorchid: 10040012,
  darkred: 9109504,
  darksalmon: 15308410,
  darkseagreen: 9419919,
  darkslateblue: 4734347,
  darkslategray: 3100495,
  darkslategrey: 3100495,
  darkturquoise: 52945,
  darkviolet: 9699539,
  deeppink: 16716947,
  deepskyblue: 49151,
  dimgray: 6908265,
  dimgrey: 6908265,
  dodgerblue: 2003199,
  firebrick: 11674146,
  floralwhite: 16775920,
  forestgreen: 2263842,
  fuchsia: 16711935,
  gainsboro: 14474460,
  ghostwhite: 16316671,
  gold: 16766720,
  goldenrod: 14329120,
  gray: 8421504,
  green: 32768,
  greenyellow: 11403055,
  grey: 8421504,
  honeydew: 15794160,
  hotpink: 16738740,
  indianred: 13458524,
  indigo: 4915330,
  ivory: 16777200,
  khaki: 15787660,
  lavender: 15132410,
  lavenderblush: 16773365,
  lawngreen: 8190976,
  lemonchiffon: 16775885,
  lightblue: 11393254,
  lightcoral: 15761536,
  lightcyan: 14745599,
  lightgoldenrodyellow: 16448210,
  lightgray: 13882323,
  lightgreen: 9498256,
  lightgrey: 13882323,
  lightpink: 16758465,
  lightsalmon: 16752762,
  lightseagreen: 2142890,
  lightskyblue: 8900346,
  lightslategray: 7833753,
  lightslategrey: 7833753,
  lightsteelblue: 11584734,
  lightyellow: 16777184,
  lime: 65280,
  limegreen: 3329330,
  linen: 16445670,
  magenta: 16711935,
  maroon: 8388608,
  mediumaquamarine: 6737322,
  mediumblue: 205,
  mediumorchid: 12211667,
  mediumpurple: 9662683,
  mediumseagreen: 3978097,
  mediumslateblue: 8087790,
  mediumspringgreen: 64154,
  mediumturquoise: 4772300,
  mediumvioletred: 13047173,
  midnightblue: 1644912,
  mintcream: 16121850,
  mistyrose: 16770273,
  moccasin: 16770229,
  navajowhite: 16768685,
  navy: 128,
  oldlace: 16643558,
  olive: 8421376,
  olivedrab: 7048739,
  orange: 16753920,
  orangered: 16729344,
  orchid: 14315734,
  palegoldenrod: 15657130,
  palegreen: 10025880,
  paleturquoise: 11529966,
  palevioletred: 14381203,
  papayawhip: 16773077,
  peachpuff: 16767673,
  peru: 13468991,
  pink: 16761035,
  plum: 14524637,
  powderblue: 11591910,
  purple: 8388736,
  rebeccapurple: 6697881,
  red: 16711680,
  rosybrown: 12357519,
  royalblue: 4286945,
  saddlebrown: 9127187,
  salmon: 16416882,
  sandybrown: 16032864,
  seagreen: 3050327,
  seashell: 16774638,
  sienna: 10506797,
  silver: 12632256,
  skyblue: 8900331,
  slateblue: 6970061,
  slategray: 7372944,
  slategrey: 7372944,
  snow: 16775930,
  springgreen: 65407,
  steelblue: 4620980,
  tan: 13808780,
  teal: 32896,
  thistle: 14204888,
  tomato: 16737095,
  turquoise: 4251856,
  violet: 15631086,
  wheat: 16113331,
  white: 16777215,
  whitesmoke: 16119285,
  yellow: 16776960,
  yellowgreen: 10145074
}, ae = { h: 0, s: 0, l: 0 }, Ki = { h: 0, s: 0, l: 0 };
function Ds(s, t, e) {
  return e < 0 && (e += 1), e > 1 && (e -= 1), e < 1 / 6 ? s + (t - s) * 6 * e : e < 1 / 2 ? t : e < 2 / 3 ? s + (t - s) * 6 * (2 / 3 - e) : s;
}
class pr {
  constructor(t, e, i) {
    return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(t, e, i);
  }
  set(t, e, i) {
    if (e === void 0 && i === void 0) {
      const n = t;
      n && n.isColor ? this.copy(n) : typeof n == "number" ? this.setHex(n) : typeof n == "string" && this.setStyle(n);
    } else
      this.setRGB(t, e, i);
    return this;
  }
  setScalar(t) {
    return this.r = t, this.g = t, this.b = t, this;
  }
  setHex(t, e = le) {
    return t = Math.floor(t), this.r = (t >> 16 & 255) / 255, this.g = (t >> 8 & 255) / 255, this.b = (t & 255) / 255, Ft.toWorkingColorSpace(this, e), this;
  }
  setRGB(t, e, i, n = Ft.workingColorSpace) {
    return this.r = t, this.g = e, this.b = i, Ft.toWorkingColorSpace(this, n), this;
  }
  setHSL(t, e, i, n = Ft.workingColorSpace) {
    if (t = gr(t, 1), e = mt(e, 0, 1), i = mt(i, 0, 1), e === 0)
      this.r = this.g = this.b = i;
    else {
      const r = i <= 0.5 ? i * (1 + e) : i + e - i * e, a = 2 * i - r;
      this.r = Ds(a, r, t + 1 / 3), this.g = Ds(a, r, t), this.b = Ds(a, r, t - 1 / 3);
    }
    return Ft.toWorkingColorSpace(this, n), this;
  }
  setStyle(t, e = le) {
    function i(r) {
      r !== void 0 && parseFloat(r) < 1 && console.warn("THREE.Color: Alpha component of " + t + " will be ignored.");
    }
    let n;
    if (n = /^(\w+)\(([^\)]*)\)/.exec(t)) {
      let r;
      const a = n[1], o = n[2];
      switch (a) {
        case "rgb":
        case "rgba":
          if (r = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
            return i(r[4]), this.setRGB(
              Math.min(255, parseInt(r[1], 10)) / 255,
              Math.min(255, parseInt(r[2], 10)) / 255,
              Math.min(255, parseInt(r[3], 10)) / 255,
              e
            );
          if (r = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
            return i(r[4]), this.setRGB(
              Math.min(100, parseInt(r[1], 10)) / 100,
              Math.min(100, parseInt(r[2], 10)) / 100,
              Math.min(100, parseInt(r[3], 10)) / 100,
              e
            );
          break;
        case "hsl":
        case "hsla":
          if (r = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))
            return i(r[4]), this.setHSL(
              parseFloat(r[1]) / 360,
              parseFloat(r[2]) / 100,
              parseFloat(r[3]) / 100,
              e
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + t);
      }
    } else if (n = /^\#([A-Fa-f\d]+)$/.exec(t)) {
      const r = n[1], a = r.length;
      if (a === 3)
        return this.setRGB(
          parseInt(r.charAt(0), 16) / 15,
          parseInt(r.charAt(1), 16) / 15,
          parseInt(r.charAt(2), 16) / 15,
          e
        );
      if (a === 6)
        return this.setHex(parseInt(r, 16), e);
      console.warn("THREE.Color: Invalid hex color " + t);
    } else if (t && t.length > 0)
      return this.setColorName(t, e);
    return this;
  }
  setColorName(t, e = le) {
    const i = yo[t.toLowerCase()];
    return i !== void 0 ? this.setHex(i, e) : console.warn("THREE.Color: Unknown color " + t), this;
  }
  clone() {
    return new this.constructor(this.r, this.g, this.b);
  }
  copy(t) {
    return this.r = t.r, this.g = t.g, this.b = t.b, this;
  }
  copySRGBToLinear(t) {
    return this.r = Qe(t.r), this.g = Qe(t.g), this.b = Qe(t.b), this;
  }
  copyLinearToSRGB(t) {
    return this.r = Ps(t.r), this.g = Ps(t.g), this.b = Ps(t.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(t = le) {
    return Ft.fromWorkingColorSpace(yt.copy(this), t), Math.round(mt(yt.r * 255, 0, 255)) * 65536 + Math.round(mt(yt.g * 255, 0, 255)) * 256 + Math.round(mt(yt.b * 255, 0, 255));
  }
  getHexString(t = le) {
    return ("000000" + this.getHex(t).toString(16)).slice(-6);
  }
  getHSL(t, e = Ft.workingColorSpace) {
    Ft.fromWorkingColorSpace(yt.copy(this), e);
    const i = yt.r, n = yt.g, r = yt.b, a = Math.max(i, n, r), o = Math.min(i, n, r);
    let h, l;
    const A = (o + a) / 2;
    if (o === a)
      h = 0, l = 0;
    else {
      const u = a - o;
      switch (l = A <= 0.5 ? u / (a + o) : u / (2 - a - o), a) {
        case i:
          h = (n - r) / u + (n < r ? 6 : 0);
          break;
        case n:
          h = (r - i) / u + 2;
          break;
        case r:
          h = (i - n) / u + 4;
          break;
      }
      h /= 6;
    }
    return t.h = h, t.s = l, t.l = A, t;
  }
  getRGB(t, e = Ft.workingColorSpace) {
    return Ft.fromWorkingColorSpace(yt.copy(this), e), t.r = yt.r, t.g = yt.g, t.b = yt.b, t;
  }
  getStyle(t = le) {
    Ft.fromWorkingColorSpace(yt.copy(this), t);
    const e = yt.r, i = yt.g, n = yt.b;
    return t !== le ? `color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})` : `rgb(${Math.round(e * 255)},${Math.round(i * 255)},${Math.round(n * 255)})`;
  }
  offsetHSL(t, e, i) {
    return this.getHSL(ae), this.setHSL(ae.h + t, ae.s + e, ae.l + i);
  }
  add(t) {
    return this.r += t.r, this.g += t.g, this.b += t.b, this;
  }
  addColors(t, e) {
    return this.r = t.r + e.r, this.g = t.g + e.g, this.b = t.b + e.b, this;
  }
  addScalar(t) {
    return this.r += t, this.g += t, this.b += t, this;
  }
  sub(t) {
    return this.r = Math.max(0, this.r - t.r), this.g = Math.max(0, this.g - t.g), this.b = Math.max(0, this.b - t.b), this;
  }
  multiply(t) {
    return this.r *= t.r, this.g *= t.g, this.b *= t.b, this;
  }
  multiplyScalar(t) {
    return this.r *= t, this.g *= t, this.b *= t, this;
  }
  lerp(t, e) {
    return this.r += (t.r - this.r) * e, this.g += (t.g - this.g) * e, this.b += (t.b - this.b) * e, this;
  }
  lerpColors(t, e, i) {
    return this.r = t.r + (e.r - t.r) * i, this.g = t.g + (e.g - t.g) * i, this.b = t.b + (e.b - t.b) * i, this;
  }
  lerpHSL(t, e) {
    this.getHSL(ae), t.getHSL(Ki);
    const i = Mi(ae.h, Ki.h, e), n = Mi(ae.s, Ki.s, e), r = Mi(ae.l, Ki.l, e);
    return this.setHSL(i, n, r), this;
  }
  setFromVector3(t) {
    return this.r = t.x, this.g = t.y, this.b = t.z, this;
  }
  applyMatrix3(t) {
    const e = this.r, i = this.g, n = this.b, r = t.elements;
    return this.r = r[0] * e + r[3] * i + r[6] * n, this.g = r[1] * e + r[4] * i + r[7] * n, this.b = r[2] * e + r[5] * i + r[8] * n, this;
  }
  equals(t) {
    return t.r === this.r && t.g === this.g && t.b === this.b;
  }
  fromArray(t, e = 0) {
    return this.r = t[e], this.g = t[e + 1], this.b = t[e + 2], this;
  }
  toArray(t = [], e = 0) {
    return t[e] = this.r, t[e + 1] = this.g, t[e + 2] = this.b, t;
  }
  fromBufferAttribute(t, e) {
    return this.r = t.getX(e), this.g = t.getY(e), this.b = t.getZ(e), this;
  }
  toJSON() {
    return this.getHex();
  }
  *[Symbol.iterator]() {
    yield this.r, yield this.g, yield this.b;
  }
}
const yt = /* @__PURE__ */ new pr();
pr.NAMES = yo;
class gA extends Ae {
  constructor(t, e, i, n, r, a, o, h, l, A) {
    if (A = A !== void 0 ? A : Cs, A !== Cs && A !== Zr)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    i === void 0 && A === Cs && (i = Ll), i === void 0 && A === Zr && (i = Rl), super(null, n, r, a, o, h, A, i, l), this.isDepthTexture = !0, this.image = { width: t, height: e }, this.magFilter = o !== void 0 ? o : Kr, this.minFilter = h !== void 0 ? h : Kr, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  }
  copy(t) {
    return super.copy(t), this.compareFunction = t.compareFunction, this;
  }
  toJSON(t) {
    const e = super.toJSON(t);
    return this.compareFunction !== null && (e.compareFunction = this.compareFunction), e;
  }
}
const pA = /* @__PURE__ */ new gA(1, 1);
pA.compareFunction = Gl;
const yA = {
  triangulate: function(s, t, e = 2) {
    const i = t && t.length, n = i ? t[0] * e : s.length;
    let r = mo(s, 0, n, e, !0);
    const a = [];
    if (!r || r.next === r.prev)
      return a;
    let o, h, l, A, u, f, c;
    if (i && (r = bA(s, t, r, e)), s.length > 80 * e) {
      o = l = s[0], h = A = s[1];
      for (let d = e; d < n; d += e)
        u = s[d], f = s[d + 1], u < o && (o = u), f < h && (h = f), u > l && (l = u), f > A && (A = f);
      c = Math.max(l - o, A - h), c = c !== 0 ? 32767 / c : 0;
    }
    return Fi(r, a, e, o, h, c, 0), a;
  }
};
function mo(s, t, e, i, n) {
  let r, a;
  if (n === TA(s, t, e, i) > 0)
    for (r = t; r < e; r += i)
      a = ga(r, s[r], s[r + 1], a);
  else
    for (r = e - i; r >= t; r -= i)
      a = ga(r, s[r], s[r + 1], a);
  return a && Ln(a, a.next) && (Di(a), a = a.next), a;
}
function Ce(s, t) {
  if (!s)
    return s;
  t || (t = s);
  let e = s, i;
  do
    if (i = !1, !e.steiner && (Ln(e, e.next) || at(e.prev, e, e.next) === 0)) {
      if (Di(e), e = t = e.prev, e === e.next)
        break;
      i = !0;
    } else
      e = e.next;
  while (i || e !== t);
  return t;
}
function Fi(s, t, e, i, n, r, a) {
  if (!s)
    return;
  !a && r && PA(s, i, n, r);
  let o = s, h, l;
  for (; s.prev !== s.next; ) {
    if (h = s.prev, l = s.next, r ? vA(s, i, n, r) : mA(s)) {
      t.push(h.i / e | 0), t.push(s.i / e | 0), t.push(l.i / e | 0), Di(s), s = l.next, o = l.next;
      continue;
    }
    if (s = l, s === o) {
      a ? a === 1 ? (s = _A(Ce(s), t, e), Fi(s, t, e, i, n, r, 2)) : a === 2 && xA(s, t, e, i, n, r) : Fi(Ce(s), t, e, i, n, r, 1);
      break;
    }
  }
}
function mA(s) {
  const t = s.prev, e = s, i = s.next;
  if (at(t, e, i) >= 0)
    return !1;
  const n = t.x, r = e.x, a = i.x, o = t.y, h = e.y, l = i.y, A = n < r ? n < a ? n : a : r < a ? r : a, u = o < h ? o < l ? o : l : h < l ? h : l, f = n > r ? n > a ? n : a : r > a ? r : a, c = o > h ? o > l ? o : l : h > l ? h : l;
  let d = i.next;
  for (; d !== t; ) {
    if (d.x >= A && d.x <= f && d.y >= u && d.y <= c && Ye(n, o, r, h, a, l, d.x, d.y) && at(d.prev, d, d.next) >= 0)
      return !1;
    d = d.next;
  }
  return !0;
}
function vA(s, t, e, i) {
  const n = s.prev, r = s, a = s.next;
  if (at(n, r, a) >= 0)
    return !1;
  const o = n.x, h = r.x, l = a.x, A = n.y, u = r.y, f = a.y, c = o < h ? o < l ? o : l : h < l ? h : l, d = A < u ? A < f ? A : f : u < f ? u : f, p = o > h ? o > l ? o : l : h > l ? h : l, m = A > u ? A > f ? A : f : u > f ? u : f, v = Zs(c, d, t, e, i), _ = Zs(p, m, t, e, i);
  let g = s.prevZ, y = s.nextZ;
  for (; g && g.z >= v && y && y.z <= _; ) {
    if (g.x >= c && g.x <= p && g.y >= d && g.y <= m && g !== n && g !== a && Ye(o, A, h, u, l, f, g.x, g.y) && at(g.prev, g, g.next) >= 0 || (g = g.prevZ, y.x >= c && y.x <= p && y.y >= d && y.y <= m && y !== n && y !== a && Ye(o, A, h, u, l, f, y.x, y.y) && at(y.prev, y, y.next) >= 0))
      return !1;
    y = y.nextZ;
  }
  for (; g && g.z >= v; ) {
    if (g.x >= c && g.x <= p && g.y >= d && g.y <= m && g !== n && g !== a && Ye(o, A, h, u, l, f, g.x, g.y) && at(g.prev, g, g.next) >= 0)
      return !1;
    g = g.prevZ;
  }
  for (; y && y.z <= _; ) {
    if (y.x >= c && y.x <= p && y.y >= d && y.y <= m && y !== n && y !== a && Ye(o, A, h, u, l, f, y.x, y.y) && at(y.prev, y, y.next) >= 0)
      return !1;
    y = y.nextZ;
  }
  return !0;
}
function _A(s, t, e) {
  let i = s;
  do {
    const n = i.prev, r = i.next.next;
    !Ln(n, r) && vo(n, i, i.next, r) && ki(n, r) && ki(r, n) && (t.push(n.i / e | 0), t.push(i.i / e | 0), t.push(r.i / e | 0), Di(i), Di(i.next), i = s = r), i = i.next;
  } while (i !== s);
  return Ce(i);
}
function xA(s, t, e, i, n, r) {
  let a = s;
  do {
    let o = a.next.next;
    for (; o !== a.prev; ) {
      if (a.i !== o.i && kA(a, o)) {
        let h = _o(a, o);
        a = Ce(a, a.next), h = Ce(h, h.next), Fi(a, t, e, i, n, r, 0), Fi(h, t, e, i, n, r, 0);
        return;
      }
      o = o.next;
    }
    a = a.next;
  } while (a !== s);
}
function bA(s, t, e, i) {
  const n = [];
  let r, a, o, h, l;
  for (r = 0, a = t.length; r < a; r++)
    o = t[r] * i, h = r < a - 1 ? t[r + 1] * i : s.length, l = mo(s, o, h, i, !1), l === l.next && (l.steiner = !0), n.push(FA(l));
  for (n.sort(wA), r = 0; r < n.length; r++)
    e = SA(n[r], e);
  return e;
}
function wA(s, t) {
  return s.x - t.x;
}
function SA(s, t) {
  const e = CA(s, t);
  if (!e)
    return t;
  const i = _o(e, s);
  return Ce(i, i.next), Ce(e, e.next);
}
function CA(s, t) {
  let e = t, i = -1 / 0, n;
  const r = s.x, a = s.y;
  do {
    if (a <= e.y && a >= e.next.y && e.next.y !== e.y) {
      const f = e.x + (a - e.y) * (e.next.x - e.x) / (e.next.y - e.y);
      if (f <= r && f > i && (i = f, n = e.x < e.next.x ? e : e.next, f === r))
        return n;
    }
    e = e.next;
  } while (e !== t);
  if (!n)
    return null;
  const o = n, h = n.x, l = n.y;
  let A = 1 / 0, u;
  e = n;
  do
    r >= e.x && e.x >= h && r !== e.x && Ye(a < l ? r : i, a, h, l, a < l ? i : r, a, e.x, e.y) && (u = Math.abs(a - e.y) / (r - e.x), ki(e, s) && (u < A || u === A && (e.x > n.x || e.x === n.x && MA(n, e))) && (n = e, A = u)), e = e.next;
  while (e !== o);
  return n;
}
function MA(s, t) {
  return at(s.prev, s, t.prev) < 0 && at(t.next, s, s.next) < 0;
}
function PA(s, t, e, i) {
  let n = s;
  do
    n.z === 0 && (n.z = Zs(n.x, n.y, t, e, i)), n.prevZ = n.prev, n.nextZ = n.next, n = n.next;
  while (n !== s);
  n.prevZ.nextZ = null, n.prevZ = null, EA(n);
}
function EA(s) {
  let t, e, i, n, r, a, o, h, l = 1;
  do {
    for (e = s, s = null, r = null, a = 0; e; ) {
      for (a++, i = e, o = 0, t = 0; t < l && (o++, i = i.nextZ, !!i); t++)
        ;
      for (h = l; o > 0 || h > 0 && i; )
        o !== 0 && (h === 0 || !i || e.z <= i.z) ? (n = e, e = e.nextZ, o--) : (n = i, i = i.nextZ, h--), r ? r.nextZ = n : s = n, n.prevZ = r, r = n;
      e = i;
    }
    r.nextZ = null, l *= 2;
  } while (a > 1);
  return s;
}
function Zs(s, t, e, i, n) {
  return s = (s - e) * n | 0, t = (t - i) * n | 0, s = (s | s << 8) & 16711935, s = (s | s << 4) & 252645135, s = (s | s << 2) & 858993459, s = (s | s << 1) & 1431655765, t = (t | t << 8) & 16711935, t = (t | t << 4) & 252645135, t = (t | t << 2) & 858993459, t = (t | t << 1) & 1431655765, s | t << 1;
}
function FA(s) {
  let t = s, e = s;
  do
    (t.x < e.x || t.x === e.x && t.y < e.y) && (e = t), t = t.next;
  while (t !== s);
  return e;
}
function Ye(s, t, e, i, n, r, a, o) {
  return (n - a) * (t - o) >= (s - a) * (r - o) && (s - a) * (i - o) >= (e - a) * (t - o) && (e - a) * (r - o) >= (n - a) * (i - o);
}
function kA(s, t) {
  return s.next.i !== t.i && s.prev.i !== t.i && !DA(s, t) && // dones't intersect other edges
  (ki(s, t) && ki(t, s) && IA(s, t) && // locally visible
  (at(s.prev, s, t.prev) || at(s, t.prev, t)) || // does not create opposite-facing sectors
  Ln(s, t) && at(s.prev, s, s.next) > 0 && at(t.prev, t, t.next) > 0);
}
function at(s, t, e) {
  return (t.y - s.y) * (e.x - t.x) - (t.x - s.x) * (e.y - t.y);
}
function Ln(s, t) {
  return s.x === t.x && s.y === t.y;
}
function vo(s, t, e, i) {
  const n = Ji(at(s, t, e)), r = Ji(at(s, t, i)), a = Ji(at(e, i, s)), o = Ji(at(e, i, t));
  return !!(n !== r && a !== o || n === 0 && Zi(s, e, t) || r === 0 && Zi(s, i, t) || a === 0 && Zi(e, s, i) || o === 0 && Zi(e, t, i));
}
function Zi(s, t, e) {
  return t.x <= Math.max(s.x, e.x) && t.x >= Math.min(s.x, e.x) && t.y <= Math.max(s.y, e.y) && t.y >= Math.min(s.y, e.y);
}
function Ji(s) {
  return s > 0 ? 1 : s < 0 ? -1 : 0;
}
function DA(s, t) {
  let e = s;
  do {
    if (e.i !== s.i && e.next.i !== s.i && e.i !== t.i && e.next.i !== t.i && vo(e, e.next, s, t))
      return !0;
    e = e.next;
  } while (e !== s);
  return !1;
}
function ki(s, t) {
  return at(s.prev, s, s.next) < 0 ? at(s, t, s.next) >= 0 && at(s, s.prev, t) >= 0 : at(s, t, s.prev) < 0 || at(s, s.next, t) < 0;
}
function IA(s, t) {
  let e = s, i = !1;
  const n = (s.x + t.x) / 2, r = (s.y + t.y) / 2;
  do
    e.y > r != e.next.y > r && e.next.y !== e.y && n < (e.next.x - e.x) * (r - e.y) / (e.next.y - e.y) + e.x && (i = !i), e = e.next;
  while (e !== s);
  return i;
}
function _o(s, t) {
  const e = new Js(s.i, s.x, s.y), i = new Js(t.i, t.x, t.y), n = s.next, r = t.prev;
  return s.next = t, t.prev = s, e.next = n, n.prev = e, i.next = e, e.prev = i, r.next = i, i.prev = r, i;
}
function ga(s, t, e, i) {
  const n = new Js(s, t, e);
  return i ? (n.next = i.next, n.prev = i, i.next.prev = n, i.next = n) : (n.prev = n, n.next = n), n;
}
function Di(s) {
  s.next.prev = s.prev, s.prev.next = s.next, s.prevZ && (s.prevZ.nextZ = s.nextZ), s.nextZ && (s.nextZ.prevZ = s.prevZ);
}
function Js(s, t, e) {
  this.i = s, this.x = t, this.y = e, this.prev = null, this.next = null, this.z = 0, this.prevZ = null, this.nextZ = null, this.steiner = !1;
}
function TA(s, t, e, i) {
  let n = 0;
  for (let r = t, a = e - i; r < e; r += i)
    n += (s[a] - s[r]) * (s[r + 1] + s[a + 1]), a = r;
  return n;
}
class yr {
  // calculate area of the contour polygon
  static area(t) {
    const e = t.length;
    let i = 0;
    for (let n = e - 1, r = 0; r < e; n = r++)
      i += t[n].x * t[r].y - t[r].x * t[n].y;
    return i * 0.5;
  }
  static isClockWise(t) {
    return yr.area(t) < 0;
  }
  static triangulateShape(t, e) {
    const i = [], n = [], r = [];
    pa(t), ya(i, t);
    let a = t.length;
    e.forEach(pa);
    for (let h = 0; h < e.length; h++)
      n.push(a), a += e[h].length, ya(i, e[h]);
    const o = yA.triangulate(i, n);
    for (let h = 0; h < o.length; h += 3)
      r.push(o.slice(h, h + 3));
    return r;
  }
}
function pa(s) {
  const t = s.length;
  t > 2 && s[t - 1].equals(s[0]) && s.pop();
}
function ya(s, t) {
  for (let e = 0; e < t.length; e++)
    s.push(t[e].x), s.push(t[e].y);
}
const ma = /* @__PURE__ */ new j(), tn = /* @__PURE__ */ new j();
class LA {
  constructor(t = new j(), e = new j()) {
    this.start = t, this.end = e;
  }
  set(t, e) {
    return this.start.copy(t), this.end.copy(e), this;
  }
  copy(t) {
    return this.start.copy(t.start), this.end.copy(t.end), this;
  }
  getCenter(t) {
    return t.addVectors(this.start, this.end).multiplyScalar(0.5);
  }
  delta(t) {
    return t.subVectors(this.end, this.start);
  }
  distanceSq() {
    return this.start.distanceToSquared(this.end);
  }
  distance() {
    return this.start.distanceTo(this.end);
  }
  at(t, e) {
    return this.delta(e).multiplyScalar(t).add(this.start);
  }
  closestPointToPointParameter(t, e) {
    ma.subVectors(t, this.start), tn.subVectors(this.end, this.start);
    const i = tn.dot(tn);
    let r = tn.dot(ma) / i;
    return e && (r = mt(r, 0, 1)), r;
  }
  closestPointToPoint(t, e, i) {
    const n = this.closestPointToPointParameter(t, e);
    return this.delta(i).multiplyScalar(n).add(this.start);
  }
  applyMatrix4(t) {
    return this.start.applyMatrix4(t), this.end.applyMatrix4(t), this;
  }
  equals(t) {
    return t.start.equals(this.start) && t.end.equals(this.end);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: lo
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = lo);
const tr = (s) => new X(s[2] - s[0], s[3] - s[1]).normalize(), va = 1e-6, oe = (s, t) => Math.abs(s[0] - t[0]) < va && Math.abs(s[1] - t[1]) < va, Et = (s, t) => new X(s[0], s[1]).distanceTo({ x: t[0], y: t[1] }), i1 = (s) => new X(s[0], s[1]).length(), ce = (s) => tr(s).toArray(), mr = (s) => new X(-s[1], s[0]).normalize().toArray(), RA = (s, t) => {
  const e = new Jt().set(
    Math.cos(t),
    -Math.sin(t),
    0,
    Math.sin(t),
    Math.cos(t),
    0,
    0,
    0,
    1
  ), i = new X(s[0], s[1]);
  return i.applyMatrix3(e), i.toArray();
}, Ke = (s, t, e) => {
  const i = new X(s[0], s[1]);
  return [
    ...t,
    ...i.multiplyScalar(e).add({ x: t[0], y: t[1] }).toArray()
  ];
}, OA = (s) => mr(ce(s)), n1 = (s, t = [0, 0], e = 1) => {
  const i = mr(s), n = new X(i[0], i[1]);
  return n.multiplyScalar(e).add({ x: t[0], y: t[1] }), [...t, ...n.toArray()];
}, Xe = (s, t) => {
  const e = new X(s[0], s[1]), i = new X(t[0], t[1]), n = e.angleTo(i);
  return e.cross(i) > 0 ? n : -n;
}, NA = (s, t) => Xe(ce(s), ce(t)), GA = (s, t) => Xe(t, ce(s)), s1 = (s) => [(s[0] + s[2]) / 2, (s[1] + s[3]) / 2], Ot = (s, t = 2) => {
  const e = Math.pow(10, t);
  return Math.round(s * e) / e;
};
var xo = /* @__PURE__ */ ((s) => (s.Overlap = "Overlap", s.Intersect = "Intersect", s.ExtendIntersect = "ExtendIntersect", s.Parallel = "Parallel", s.Join = "Join", s.Equal = "Equal", s.None = "None", s))(xo || {});
const bo = (s, t) => {
  const e = s.slice(0, 2), i = t.slice(0, 2), n = s.slice(2, 4), r = t.slice(2, 4);
  if (oe(e, i) && oe(n, r))
    return "Equal";
  const a = oe(e, i) || oe(e, r) || oe(n, i) || oe(n, r), o = tr(s), h = tr(t), l = new X(-o.y, o.x).normalize(), A = new X(-h.y, h.x).normalize(), u = new X(s[0], s[1]), f = new X(t[0], t[1]), c = new X(s[2], s[3]), d = new X(t[2], t[3]), p = Ot(
    A.dot(f.clone().sub(u).normalize()) / A.dot(o),
    6
  ), m = Ot(
    l.dot(u.clone().sub(f).normalize()) / l.dot(h),
    6
  ), v = A.negate();
  if (p === 0 && m === 0)
    return "Overlap";
  if (oe([l.x, l.y], [A.x, A.y]) || oe([l.x, l.y], [v.x, v.y]))
    return a ? "Overlap" : "Parallel";
  {
    if (a)
      return "Join";
    const _ = (d.y - f.y) * (c.x - u.x) - (d.x - f.x) * (c.y - u.y), g = Ot(
      ((d.x - f.x) * (u.y - f.y) - (d.y - f.y) * (u.x - f.x)) / _,
      6
    ), y = Ot(
      ((c.x - u.x) * (u.y - f.y) - (c.y - u.y) * (u.x - f.x)) / _,
      6
    );
    return g >= 0 && g <= 1 && y >= 0 && y <= 1 ? "Intersect" : "ExtendIntersect";
  }
}, wo = (s, t, e = [
  "Overlap",
  "Intersect",
  "ExtendIntersect",
  "Parallel",
  "Join",
  "Equal",
  "None"
  /* None */
]) => {
  let i = bo(s, t);
  if (!e.includes(i))
    return null;
  const n = new X(s[0], s[1]), r = new X(s[2], s[3]), a = new X(t[0], t[1]), o = new X(t[2], t[3]), h = r.clone().sub(n), l = o.clone().sub(a), A = h.x, u = -l.x, f = h.y, c = -l.y, d = a.x - n.x, p = a.y - n.y, m = (c * d - u * p) / (A * c - u * f);
  return n.clone().add(h.clone().multiplyScalar(m)).toArray();
}, Ui = (s, t) => {
  const e = new X(s[0], s[1]), i = new X(s[2], s[3]), n = new X(t[0], t[1]), r = i.clone().sub(e), o = n.clone().sub(e).dot(r.normalize()), h = e.add(r.multiplyScalar(o));
  return {
    point: h.toArray(),
    len: h.distanceTo(e)
  };
}, BA = (s, t) => {
  const e = new LA(
    new j(s[0], s[1], 0),
    new j(s[2], s[3], 0)
  ), i = new j(t[0], t[1], 0), n = e.closestPointToPoint(i, !0, new j());
  return [n.x, n.y];
}, zA = (s, t) => {
  const e = BA(s, t);
  return Et(t, e);
}, r1 = (s) => {
  const t = s.map((e) => new X(e[0], e[1]));
  return yr.isClockWise(t);
}, a1 = (s, t, e = 5) => {
  const i = [];
  for (let n = 0; n < e; n++) {
    const r = t.map((o) => o *= n + 1), a = Ui(s, [
      s[0] + r[0],
      s[1] + r[1]
    ]).point;
    i.push(a);
  }
  return i;
}, UA = (s, t) => {
  for (let e = 0; e < s.length - 1; e++) {
    const i = [...s[e], ...s[e + 1]];
    if (bo(i, t) === "Intersect")
      return !0;
  }
  return !1;
};
let be = !1;
const Pi = [], So = () => {
  be = !0, Pi.forEach((s) => s.draggable(!1));
}, Co = () => {
  be = !1, Pi.forEach((s) => s.draggable(!0));
}, Is = (s, t = []) => ["draging", "active", "hover", "common"].find((i) => s[i] && !t.includes(i)), _a = (s, t, e = "mouse-style") => {
  s.listening(!0);
  const i = [], n = (_, g) => {
    s.on(_, g), i.push(_);
  };
  let r;
  t.bus && t.bus.on("statusChange", (_) => {
    r = _, A();
  });
  const a = {
    hover: !1,
    draging: !1,
    active: !1,
    common: !1
  };
  let o = "common", h = "common", l;
  const A = (_, g) => {
    const y = Is(a);
    if (t.bus && (h !== y || l !== g)) {
      const C = o;
      h = y, t.bus.emit("shapeStatusChange", {
        current: y,
        before: C,
        type: g
      });
    }
    let x = r ? Is(r) : be ? null : y;
    const b = r ? [r, a] : [a];
    for (const C of b) {
      const w = { ...C };
      for (; x && !(x in t); )
        w[x] = !1, x = Is(w);
      if (x)
        break;
    }
    x = x || "common", o !== x && (t[x] && t[x](_), o = x);
  };
  n(`mouseenter.${e}`, (_) => {
    a.hover = !0, A(_, "mouse");
  }), n(`mouseleave.${e}`, (_) => {
    a.hover = !1, A(_, "mouse");
  });
  let u, f = 0;
  n(`click.${e} touchend.${e}`, (_) => {
    a.active = !0, A(_, "click"), f = Date.now();
  });
  const c = `click.${e}${s.id()} touchend.${e}${s.id()}`;
  let d = 3, p, m = !1;
  const v = setInterval(() => {
    if (!(p = s.getStage())) {
      d < -5 && clearInterval(v), --d < 0 && (m && console.error("可能发生资源泄露"), m = !0);
      return;
    }
    clearInterval(v), p.on(c, (_) => {
      Date.now() - f > 50 && _.target !== s && (a.active = !1, A(_, "click"));
    });
  }, 100);
  return u = () => {
    p && p.off(c), clearInterval(v);
  }, n(`dragstart.${e}`, (_) => {
    a.draging = !0, A(_, "mouse");
  }), n(`dragend.${e}`, (_) => {
    setTimeout(() => {
      a.draging = !1, A(_, "mouse");
    }, 16);
  }), () => {
    s.listening(!1), s.off(i.join(" ")), u && u();
  };
}, vr = (s, t, e = !0, i = !1) => {
  let n = null;
  return be || s.draggable(!0), Pi.push(s), s.dragBoundFunc((r, a) => {
    if (!be) {
      let o = r;
      e && (o = we(s, i).invert().point(r)), t.moveHandler([o.x, o.y], n, a);
    }
    return s.absolutePosition();
  }), t.readyHandler && s.on("dragstart.drag", (r) => {
    be || (n = t.readyHandler(r));
  }), t.endHandler && s.on("dragend.drag", (r) => {
    be || t.endHandler(n, r);
  }), () => {
    const r = Pi.indexOf(s);
    ~r && Pi.splice(r, 1), s.draggable(!1), s.off("dragstart.drag dragend.drag");
  };
}, ln = (s, t) => {
  s.enableDrag({
    readyHandler(e) {
      return t.readyHandler && t.readyHandler(s.attrib, e);
    },
    moveHandler(e, i, n) {
      return t.moveHandler(s.attrib, e, i, n);
    },
    endHandler(e, i) {
      return t.endHandler && t.endHandler(s.attrib, e, i);
    }
  });
}, Mo = (s, t) => {
  if (t(s))
    return s;
  if ("children" in s) {
    for (const e of s.children)
      if (Mo(e, t))
        return e;
  }
  return null;
}, Po = (s, t) => {
  for (; s; ) {
    if (t(s))
      return s;
    s = s.parent;
  }
  return null;
}, o1 = (s, t) => !!Mo(s, (i) => i === t), HA = Object.prototype.toString, VA = (s) => HA.call(s), An = (s) => VA(s).slice(8, -1), We = (s, t, e) => {
  if (s === t)
    return !1;
  const i = An(s), n = An(t);
  if (i !== n)
    return !0;
  if (i === "String" || i === "Number" || i === "Boolean")
    return i === "Number" && isNaN(s) && isNaN(t) ? !1 : s !== t;
  const r = Array.from(e.values());
  for (const a of r)
    if (a.includes(s) && a.includes(t))
      return !1;
  if (e.add([s, t]), i === "Array")
    return s.length !== t.length || s.some((a, o) => We(a, t[o], e));
  if (i === "Object") {
    const a = Object.keys(s).sort(), o = Object.keys(t).sort();
    return We(a, o, e) || a.some((h) => We(s[h], t[h], e));
  } else if (i === "Map") {
    const a = Array.from(s.keys()).sort(), o = Array.from(t.keys()).sort();
    return We(a, o, e) || a.some((h) => We(s.get(h), t.get(h), e));
  } else
    return i === "Set" ? di(Array.from(s.values()), Array.from(t.values())) : s !== t;
}, di = (s, t) => We(s, t, /* @__PURE__ */ new Set()), h1 = (s, t) => {
  for (const e in t)
    typeof s[e] == "function" && s[e](t[e]);
}, Eo = (s, t = []) => {
  const e = s.filter((r) => !t.includes(r)), i = t.filter((r) => !s.includes(r)), n = t.filter((r) => s.includes(r));
  return { addPort: e, delPort: i, holdPort: n };
}, Rn = (s, t) => {
  const e = s.map(({ id: a }) => a), i = t.map(({ id: a }) => a), n = Eo(e, i), r = s.filter(
    (a) => !t.includes(a) && i.includes(a.id)
  ).map((a) => a.id);
  return t = s, { ...n, changePort: r };
}, l1 = (s, t, e = !0) => ge(
  () => [...s],
  (i, n = []) => {
    t(Rn(i, n));
  },
  { immediate: e, flush: "sync" }
), A1 = (s) => {
  const t = ti(s()), e = ge(s, (i) => {
    di(t, i) && (Array.isArray(i) ? i.forEach((n, r) => {
      t[r] = n;
    }) : (Object.keys(t).forEach((n) => delete t[n]), Object.assign(t, i)));
  });
  return {
    data: t,
    stop: e
  };
}, c1 = (s) => {
  const t = ti(s()), e = ge(s, (i, n) => {
    const { addPort: r, delPort: a, changePort: o } = Rn(
      i,
      n
    );
    for (const h of a) {
      const l = t.findIndex((A) => A.id === h);
      ~l && t.splice(l, 1);
    }
    for (const h of r) {
      const l = i.find((A) => A.id === h);
      l && t.push(l);
    }
    for (const h of o) {
      const l = t.findIndex((u) => u.id === h), A = i.findIndex((u) => u.id === h);
      di(t[l], i[A]) && (t[l] = i[A]);
    }
  });
  return {
    data: t,
    stop: e
  };
}, Ts = (s, t) => {
  var l, A;
  if (!di(s, t))
    return t;
  if (!t)
    return s;
  const e = s, i = t, n = An(e);
  if (An(t) !== n)
    return s;
  switch (n) {
    case "Array":
      if ((l = e[0]) != null && l.id || (A = i[0]) != null && A.id) {
        var { changePort: r, addPort: a, delPort: o } = Rn(e, i);
        a.forEach((p) => {
          i.push(e.find(({ id: m }) => m === p));
        }), o.forEach((p) => {
          const m = i.findIndex(({ id: v }) => v === p);
          ~m && i.splice(m, 1);
        }), r.forEach((p) => {
          const m = e.find(({ id: _ }) => _ === p), v = i.findIndex(({ id: _ }) => _ === p);
          i[v] = Ts(m, i[v]);
        });
      } else {
        for (let c = 0; c < e.length; c++)
          i[c] = Ts(e[c], i[c]);
        for (; i.length !== e.length; )
          i.pop();
      }
      break;
    case "Object":
      const u = Object.keys(i).sort(), f = Object.keys(e).sort();
      var { addPort: a, delPort: o, holdPort: h } = Eo(f, u);
      for (let c = 0; c < h.length; c++)
        i[u[c]] = Ts(
          e[h[c]],
          i[h[c]]
        );
      a.forEach((c) => i[c] = e[c]), o.forEach((c) => delete i[c]);
      break;
    default:
      return s;
  }
  return t;
}, d1 = (s, t) => {
  t.forEach((e) => {
    const i = new Ni({
      fill: "red",
      radius: 5,
      x: e[0],
      y: e[1]
    });
    s.children[0].add(i);
  });
}, Fo = (s) => {
  const t = [];
  for (const e of s.children)
    t.push(e, ...Fo(e));
  return t;
}, $A = (s) => (Math.max(1, ...s.map(({ id: t }) => Number(t))) + 1).toString(), _r = (...s) => () => {
  s.forEach((t) => {
    Array.isArray(t) ? t.forEach((e) => e()) : t();
  });
}, WA = Math.PI / 180;
function YA(s) {
  return s * WA;
}
const XA = (s) => s ? {
  reactive: s.props.reactive,
  readonly: s.props.reactive
} : {}, jA = (s, t, e, i, n) => {
  const r = new t({
    attrib: s,
    ...XA(e)
  });
  return i && i(r), e && (r.container = e.container, r.setParent(e)), r.init(), r.mount(r.teleport), e != null && e.isMounted && r.mounted(), n && n(r), r;
}, Pt = (s, t, e, i) => {
  let n = [];
  const r = (l, A) => l.find((u) => u.id === A), a = {}, o = (l) => {
    const A = a[l];
    return A.destory(), delete a[l], A;
  }, h = (l) => {
    const A = jA(l, s, t, e, i);
    return a[l.id] = A, A;
  };
  return (l) => {
    const A = Array.isArray(l) ? l : [l], { addPort: u, delPort: f, changePort: c } = Rn(
      A,
      n
    ), d = f.map(o), p = u.map((v) => h(r(A, v))), m = c.map((v) => {
      const _ = r(A, v);
      return a[v].setAttrib(_), a[v];
    });
    return n = [...A], {
      adds: p,
      dels: d,
      upds: m
    };
  };
}, qA = (s) => {
  const t = s.count || 1, e = s.entity, i = e.shape.getPosition();
  let n = s.dire, r = s.size;
  if (!s.dire) {
    const h = e.shape.rotation(), l = new et.Transform();
    l.rotate(YA(h));
    const A = l.point({ x: r[0], y: r[1] }), u = l.point({ x: 1, y: 0 }), f = new X(u.x, u.y).normalize();
    n = [f.x, f.y], r = [A.x, A.y], console.log(n);
  }
  const a = Ke(n, [i.x, i.y], 10), o = e.container.getSameLevelData(e);
  for (let h = 0; h < t; h++) {
    const l = r.map((f) => f *= h + 1), A = Ui(a, [
      i.x + l[0],
      i.y + l[1]
    ]).point, u = {
      id: $A(o),
      ...s.factoryAttrib(A)
    };
    o.push(u);
  }
}, Ls = /* @__PURE__ */ new WeakMap(), u1 = (s, t) => {
  const e = Ls.get(s);
  e && e();
  let i = !1;
  const n = () => {
    i || (hn ? s.stage.off("touchend.addEntity") : s.stage.off("click.addEntity"), Co(), Ls.delete(s), i = !0);
  }, r = (A) => {
    n(), o(A);
  }, a = () => {
    n(), h("cancel");
  };
  let o, h;
  return {
    promise: new Promise((A, u) => {
      o = A, h = u;
      const f = (c) => {
        let d = c.evt;
        c.evt instanceof TouchEvent && (d = ho(c));
        const p = s.getRealFromStage([d.offsetX, d.offsetY]);
        r(t(p));
      };
      So(), Ls.set(s, a), hn ? s.stage.on("touchend.addEntity", f) : s.stage.on("click.addEntity", f);
    }),
    interrupt: a
  };
}, f1 = (s, t) => {
  s.bus.emit("statusChange", { [t]: !0 });
}, QA = (s) => {
  const t = ei(!1), e = ei(!1);
  s.bus.on("shapeStatusChange", ({ current: r, type: a }) => {
    r === "active" ? e.value = !e.value : a === "click" ? e.value = !1 : e.value || (t.value = !!r);
  });
  const i = (r) => {
    s.bus.emit("statusChange", { [r]: !0 });
  }, n = ge(
    () => [t.value, e.value],
    ([r, a]) => {
      i(a ? "active" : r ? "hover" : "common");
    },
    { flush: "post" }
  );
  return {
    light: t,
    active: e,
    stop: n
  };
}, g1 = (s) => {
  const t = ei(), e = ei(), i = s.map(QA);
  s.forEach((n) => {
    n.bus.on("destroyed", () => {
      const r = s.indexOf(n);
      ~r && (i[r].stop(), i.splice(r, 1), s.splice(r, 1));
    });
  }), Sn(() => {
    for (let n = 0; n < i.length; n++) {
      const { active: r, light: a } = i[n];
      r.value ? t.value = s[n].attrib.id : t.value === s[n].attrib.id && (t.value = null), a.value ? e.value = s[n].attrib.id : e.value === s[n].attrib.id && (e.value = null);
    }
  });
}, Mt = {
  fill: "#ffffff",
  radius: 6,
  stroke: "#409EFF",
  strokeWidth: 3,
  zIndex: 3,
  hitStrokeWidth: 5,
  activeFill: "#ffffff",
  activeStroke: "#E6A23C"
}, On = () => {
  const s = new Ni({
    radius: Mt.radius,
    name: "wpoint",
    strokeWidth: Mt.strokeWidth,
    hitStrokeWidth: Mt.hitStrokeWidth
  }), t = () => {
    const [n] = Gt(s, [1, 1]);
    s.scale({ x: n, y: n });
  }, e = () => {
    t(), s.fill(Mt.fill).stroke(Mt.stroke);
  }, i = () => {
    t(), s.fill(Mt.activeFill).stroke(Mt.activeStroke);
  };
  return e(), {
    shape: s,
    setData(n) {
      t(), s.x(n[0]), s.y(n[1]);
    },
    common: e,
    hover: i,
    active: i,
    draging: i
  };
}, je = {
  strokeWidth: 5,
  hitStrokeWidth: 20,
  stroke: "rgba(230, 162, 60, 1)",
  zIndex: 1,
  activeStroke: "rgba(64, 158, 255, 1)"
}, ui = () => {
  const s = new Fn({
    strokeScaleEnabled: !1,
    strokeWidth: je.strokeWidth,
    hitStrokeWidth: je.hitStrokeWidth
  }), t = () => {
    s.stroke(je.stroke);
  }, e = () => {
    s.stroke(je.activeStroke);
  };
  return t(), {
    shape: s,
    setData(i) {
      s.points(i);
    },
    common: t,
    hover: t,
    active: e,
    draging: e
  };
}, cn = {
  stroke: "rgba(0,0,0,0)",
  strokeWidth: 0,
  fill: "rgba(230, 162, 60, 0.30)",
  activeFill: "rgba(64, 158, 255, 0.3)",
  zIndex: 0
}, Nn = (s = {}) => {
  let t = "rgba(0, 0, 0, 0)";
  if (qt) {
    const o = new pr();
    o.setHSL(de.randFloat(0, 1), 1, 0.8), t = "#" + o.getHexString();
  }
  const e = new Nt(), i = new Fn({
    name: "polygon-line",
    closed: !0,
    fill: t
  }), n = s.autoClose ? s.lineFactory ? s.lineFactory() : ui() : null;
  e.add(i), n && e.add(n.shape);
  const r = (o) => {
    i.fill(cn.fill), n && n.common(o);
  }, a = (o) => {
    i.fill(cn.activeFill), n && n.active && n.active(o);
  };
  return r(), {
    closeLine: n,
    shape: e,
    setData(o) {
      if (i.points(o), n)
        if (o.length > 4) {
          const h = [o.length - 2, o.length - 1, 0, 1];
          n.setData(h.map((l) => o[l])), n.shape.visible(!0);
        } else
          n.shape.visible(!1);
    },
    common: r,
    hover: r,
    active: a,
    draging: a
  };
}, p1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  line: je,
  lineShapeFactory: ui,
  point: Mt,
  pointShapeFactory: On,
  polygon: cn,
  polygonShapeFactory: Nn
}, Symbol.toStringTag, { value: "Module" }));
var xr = { exports: {} }, Gn = {}, ko = {}, Ii = {};
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.Stage = s.stages = void 0;
  const t = et, e = V, i = Ee, n = $, r = It, a = En, o = $, h = bt;
  var l = "Stage", A = "string", u = "px", f = "mouseout", c = "mouseleave", d = "mouseover", p = "mouseenter", m = "mousemove", v = "mousedown", _ = "mouseup", g = "pointermove", y = "pointerdown", x = "pointerup", b = "pointercancel", C = "lostpointercapture", w = "pointerout", E = "pointerleave", S = "pointerover", P = "pointerenter", k = "contextmenu", F = "touchstart", L = "touchend", I = "touchmove", z = "touchcancel", T = "wheel", G = 5, H = [
    [p, "_pointerenter"],
    [v, "_pointerdown"],
    [m, "_pointermove"],
    [_, "_pointerup"],
    [c, "_pointerleave"],
    [F, "_pointerdown"],
    [I, "_pointermove"],
    [L, "_pointerup"],
    [z, "_pointercancel"],
    [d, "_pointerover"],
    [T, "_wheel"],
    [k, "_contextmenu"],
    [y, "_pointerdown"],
    [g, "_pointermove"],
    [x, "_pointerup"],
    [b, "_pointercancel"],
    [C, "_lostpointercapture"]
  ];
  const R = {
    mouse: {
      [w]: f,
      [E]: c,
      [S]: d,
      [P]: p,
      [g]: m,
      [y]: v,
      [x]: _,
      [b]: "mousecancel",
      pointerclick: "click",
      pointerdblclick: "dblclick"
    },
    touch: {
      [w]: "touchout",
      [E]: "touchleave",
      [S]: "touchover",
      [P]: "touchenter",
      [g]: I,
      [y]: F,
      [x]: L,
      [b]: z,
      pointerclick: "tap",
      pointerdblclick: "dbltap"
    },
    pointer: {
      [w]: w,
      [E]: E,
      [S]: S,
      [P]: P,
      [g]: g,
      [y]: y,
      [x]: x,
      [b]: b,
      pointerclick: "pointerclick",
      pointerdblclick: "pointerdblclick"
    }
  }, N = (dt) => dt.indexOf("pointer") >= 0 ? "pointer" : dt.indexOf("touch") >= 0 ? "touch" : "mouse", q = (dt) => {
    const M = N(dt);
    if (M === "pointer")
      return n.Konva.pointerEventsEnabled && R.pointer;
    if (M === "touch")
      return R.touch;
    if (M === "mouse")
      return R.mouse;
  };
  function it(dt = {}) {
    return (dt.clipFunc || dt.clipWidth || dt.clipHeight) && t.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."), dt;
  }
  const tt = "Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";
  s.stages = [];
  class Ut extends i.Container {
    constructor(M) {
      super(it(M)), this._pointerPositions = [], this._changedPointerPositions = [], this._buildDOM(), this._bindContentEvents(), s.stages.push(this), this.on("widthChange.konva heightChange.konva", this._resizeDOM), this.on("visibleChange.konva", this._checkVisibility), this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva", () => {
        it(this.attrs);
      }), this._checkVisibility();
    }
    _validateAdd(M) {
      const D = M.getType() === "Layer", B = M.getType() === "FastLayer";
      D || B || t.Util.throw("You may only add layers to the stage.");
    }
    _checkVisibility() {
      if (!this.content)
        return;
      const M = this.visible() ? "" : "none";
      this.content.style.display = M;
    }
    setContainer(M) {
      if (typeof M === A) {
        if (M.charAt(0) === ".") {
          var D = M.slice(1);
          M = document.getElementsByClassName(D)[0];
        } else {
          var B;
          M.charAt(0) !== "#" ? B = M : B = M.slice(1), M = document.getElementById(B);
        }
        if (!M)
          throw "Can not find container in document with id " + B;
      }
      return this._setAttr("container", M), this.content && (this.content.parentElement && this.content.parentElement.removeChild(this.content), M.appendChild(this.content)), this;
    }
    shouldDrawHit() {
      return !0;
    }
    clear() {
      var M = this.children, D = M.length, B;
      for (B = 0; B < D; B++)
        M[B].clear();
      return this;
    }
    clone(M) {
      return M || (M = {}), M.container = typeof document < "u" && document.createElement("div"), i.Container.prototype.clone.call(this, M);
    }
    destroy() {
      super.destroy();
      var M = this.content;
      M && t.Util._isInDocument(M) && this.container().removeChild(M);
      var D = s.stages.indexOf(this);
      return D > -1 && s.stages.splice(D, 1), t.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas), this;
    }
    getPointerPosition() {
      const M = this._pointerPositions[0] || this._changedPointerPositions[0];
      return M ? {
        x: M.x,
        y: M.y
      } : (t.Util.warn(tt), null);
    }
    _getPointerById(M) {
      return this._pointerPositions.find((D) => D.id === M);
    }
    getPointersPositions() {
      return this._pointerPositions;
    }
    getStage() {
      return this;
    }
    getContent() {
      return this.content;
    }
    _toKonvaCanvas(M) {
      M = M || {}, M.x = M.x || 0, M.y = M.y || 0, M.width = M.width || this.width(), M.height = M.height || this.height();
      var D = new r.SceneCanvas({
        width: M.width,
        height: M.height,
        pixelRatio: M.pixelRatio || 1
      }), B = D.getContext()._context, st = this.children;
      return (M.x || M.y) && B.translate(-1 * M.x, -1 * M.y), st.forEach(function(K) {
        if (K.isVisible()) {
          var At = K._toKonvaCanvas(M);
          B.drawImage(At._canvas, M.x, M.y, At.getWidth() / At.getPixelRatio(), At.getHeight() / At.getPixelRatio());
        }
      }), D;
    }
    getIntersection(M) {
      if (!M)
        return null;
      var D = this.children, B = D.length, st = B - 1, K;
      for (K = st; K >= 0; K--) {
        const At = D[K].getIntersection(M);
        if (At)
          return At;
      }
      return null;
    }
    _resizeDOM() {
      var M = this.width(), D = this.height();
      this.content && (this.content.style.width = M + u, this.content.style.height = D + u), this.bufferCanvas.setSize(M, D), this.bufferHitCanvas.setSize(M, D), this.children.forEach((B) => {
        B.setSize({ width: M, height: D }), B.draw();
      });
    }
    add(M, ...D) {
      if (arguments.length > 1) {
        for (var B = 0; B < arguments.length; B++)
          this.add(arguments[B]);
        return this;
      }
      super.add(M);
      var st = this.children.length;
      return st > G && t.Util.warn("The stage has " + st + " layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."), M.setSize({ width: this.width(), height: this.height() }), M.draw(), n.Konva.isBrowser && this.content.appendChild(M.canvas._canvas), this;
    }
    getParent() {
      return null;
    }
    getLayer() {
      return null;
    }
    hasPointerCapture(M) {
      return h.hasPointerCapture(M, this);
    }
    setPointerCapture(M) {
      h.setPointerCapture(M, this);
    }
    releaseCapture(M) {
      h.releaseCapture(M, this);
    }
    getLayers() {
      return this.children;
    }
    _bindContentEvents() {
      n.Konva.isBrowser && H.forEach(([M, D]) => {
        this.content.addEventListener(M, (B) => {
          this[D](B);
        }, { passive: !1 });
      });
    }
    _pointerenter(M) {
      this.setPointersPositions(M);
      const D = q(M.type);
      D && this._fire(D.pointerenter, {
        evt: M,
        target: this,
        currentTarget: this
      });
    }
    _pointerover(M) {
      this.setPointersPositions(M);
      const D = q(M.type);
      D && this._fire(D.pointerover, {
        evt: M,
        target: this,
        currentTarget: this
      });
    }
    _getTargetShape(M) {
      let D = this[M + "targetShape"];
      return D && !D.getStage() && (D = null), D;
    }
    _pointerleave(M) {
      const D = q(M.type), B = N(M.type);
      if (D) {
        this.setPointersPositions(M);
        var st = this._getTargetShape(B), K = !(n.Konva.isDragging() || n.Konva.isTransforming()) || n.Konva.hitOnDragEnabled;
        st && K ? (st._fireAndBubble(D.pointerout, { evt: M }), st._fireAndBubble(D.pointerleave, { evt: M }), this._fire(D.pointerleave, {
          evt: M,
          target: this,
          currentTarget: this
        }), this[B + "targetShape"] = null) : K && (this._fire(D.pointerleave, {
          evt: M,
          target: this,
          currentTarget: this
        }), this._fire(D.pointerout, {
          evt: M,
          target: this,
          currentTarget: this
        })), this.pointerPos = null, this._pointerPositions = [];
      }
    }
    _pointerdown(M) {
      const D = q(M.type), B = N(M.type);
      if (D) {
        this.setPointersPositions(M);
        var st = !1;
        this._changedPointerPositions.forEach((K) => {
          var At = this.getIntersection(K);
          if (a.DD.justDragged = !1, n.Konva["_" + B + "ListenClick"] = !0, !At || !At.isListening())
            return;
          n.Konva.capturePointerEventsEnabled && At.setPointerCapture(K.id), this[B + "ClickStartShape"] = At, At._fireAndBubble(D.pointerdown, {
            evt: M,
            pointerId: K.id
          }), st = !0;
          const St = M.type.indexOf("touch") >= 0;
          At.preventDefault() && M.cancelable && St && M.preventDefault();
        }), st || this._fire(D.pointerdown, {
          evt: M,
          target: this,
          currentTarget: this,
          pointerId: this._pointerPositions[0].id
        });
      }
    }
    _pointermove(M) {
      const D = q(M.type), B = N(M.type);
      if (!D)
        return;
      n.Konva.isDragging() && a.DD.node.preventDefault() && M.cancelable && M.preventDefault(), this.setPointersPositions(M);
      var st = !(n.Konva.isDragging() || n.Konva.isTransforming()) || n.Konva.hitOnDragEnabled;
      if (!st)
        return;
      var K = {};
      let At = !1;
      var St = this._getTargetShape(B);
      this._changedPointerPositions.forEach((ne) => {
        const nt = h.getCapturedShape(ne.id) || this.getIntersection(ne), Oe = ne.id, Ht = { evt: M, pointerId: Oe };
        var Ne = St !== nt;
        if (Ne && St && (St._fireAndBubble(D.pointerout, { ...Ht }, nt), St._fireAndBubble(D.pointerleave, { ...Ht }, nt)), nt) {
          if (K[nt._id])
            return;
          K[nt._id] = !0;
        }
        nt && nt.isListening() ? (At = !0, Ne && (nt._fireAndBubble(D.pointerover, { ...Ht }, St), nt._fireAndBubble(D.pointerenter, { ...Ht }, St), this[B + "targetShape"] = nt), nt._fireAndBubble(D.pointermove, { ...Ht })) : St && (this._fire(D.pointerover, {
          evt: M,
          target: this,
          currentTarget: this,
          pointerId: Oe
        }), this[B + "targetShape"] = null);
      }), At || this._fire(D.pointermove, {
        evt: M,
        target: this,
        currentTarget: this,
        pointerId: this._changedPointerPositions[0].id
      });
    }
    _pointerup(M) {
      const D = q(M.type), B = N(M.type);
      if (!D)
        return;
      this.setPointersPositions(M);
      const st = this[B + "ClickStartShape"], K = this[B + "ClickEndShape"];
      var At = {};
      let St = !1;
      this._changedPointerPositions.forEach((ne) => {
        const nt = h.getCapturedShape(ne.id) || this.getIntersection(ne);
        if (nt) {
          if (nt.releaseCapture(ne.id), At[nt._id])
            return;
          At[nt._id] = !0;
        }
        const Oe = ne.id, Ht = { evt: M, pointerId: Oe };
        let Ne = !1;
        n.Konva["_" + B + "InDblClickWindow"] ? (Ne = !0, clearTimeout(this[B + "DblTimeout"])) : a.DD.justDragged || (n.Konva["_" + B + "InDblClickWindow"] = !0, clearTimeout(this[B + "DblTimeout"])), this[B + "DblTimeout"] = setTimeout(function() {
          n.Konva["_" + B + "InDblClickWindow"] = !1;
        }, n.Konva.dblClickWindow), nt && nt.isListening() ? (St = !0, this[B + "ClickEndShape"] = nt, nt._fireAndBubble(D.pointerup, { ...Ht }), n.Konva["_" + B + "ListenClick"] && st && st === nt && (nt._fireAndBubble(D.pointerclick, { ...Ht }), Ne && K && K === nt && nt._fireAndBubble(D.pointerdblclick, { ...Ht }))) : (this[B + "ClickEndShape"] = null, n.Konva["_" + B + "ListenClick"] && this._fire(D.pointerclick, {
          evt: M,
          target: this,
          currentTarget: this,
          pointerId: Oe
        }), Ne && this._fire(D.pointerdblclick, {
          evt: M,
          target: this,
          currentTarget: this,
          pointerId: Oe
        }));
      }), St || this._fire(D.pointerup, {
        evt: M,
        target: this,
        currentTarget: this,
        pointerId: this._changedPointerPositions[0].id
      }), n.Konva["_" + B + "ListenClick"] = !1, M.cancelable && B !== "touch" && M.preventDefault();
    }
    _contextmenu(M) {
      this.setPointersPositions(M);
      var D = this.getIntersection(this.getPointerPosition());
      D && D.isListening() ? D._fireAndBubble(k, { evt: M }) : this._fire(k, {
        evt: M,
        target: this,
        currentTarget: this
      });
    }
    _wheel(M) {
      this.setPointersPositions(M);
      var D = this.getIntersection(this.getPointerPosition());
      D && D.isListening() ? D._fireAndBubble(T, { evt: M }) : this._fire(T, {
        evt: M,
        target: this,
        currentTarget: this
      });
    }
    _pointercancel(M) {
      this.setPointersPositions(M);
      const D = h.getCapturedShape(M.pointerId) || this.getIntersection(this.getPointerPosition());
      D && D._fireAndBubble(x, h.createEvent(M)), h.releaseCapture(M.pointerId);
    }
    _lostpointercapture(M) {
      h.releaseCapture(M.pointerId);
    }
    setPointersPositions(M) {
      var D = this._getContentPosition(), B = null, st = null;
      M = M || window.event, M.touches !== void 0 ? (this._pointerPositions = [], this._changedPointerPositions = [], Array.prototype.forEach.call(M.touches, (K) => {
        this._pointerPositions.push({
          id: K.identifier,
          x: (K.clientX - D.left) / D.scaleX,
          y: (K.clientY - D.top) / D.scaleY
        });
      }), Array.prototype.forEach.call(M.changedTouches || M.touches, (K) => {
        this._changedPointerPositions.push({
          id: K.identifier,
          x: (K.clientX - D.left) / D.scaleX,
          y: (K.clientY - D.top) / D.scaleY
        });
      })) : (B = (M.clientX - D.left) / D.scaleX, st = (M.clientY - D.top) / D.scaleY, this.pointerPos = {
        x: B,
        y: st
      }, this._pointerPositions = [{ x: B, y: st, id: t.Util._getFirstPointerId(M) }], this._changedPointerPositions = [
        { x: B, y: st, id: t.Util._getFirstPointerId(M) }
      ]);
    }
    _setPointerPosition(M) {
      t.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'), this.setPointersPositions(M);
    }
    _getContentPosition() {
      if (!this.content || !this.content.getBoundingClientRect)
        return {
          top: 0,
          left: 0,
          scaleX: 1,
          scaleY: 1
        };
      var M = this.content.getBoundingClientRect();
      return {
        top: M.top,
        left: M.left,
        scaleX: M.width / this.content.clientWidth || 1,
        scaleY: M.height / this.content.clientHeight || 1
      };
    }
    _buildDOM() {
      if (this.bufferCanvas = new r.SceneCanvas({
        width: this.width(),
        height: this.height()
      }), this.bufferHitCanvas = new r.HitCanvas({
        pixelRatio: 1,
        width: this.width(),
        height: this.height()
      }), !!n.Konva.isBrowser) {
        var M = this.container();
        if (!M)
          throw "Stage has no container. A container is required.";
        M.innerHTML = "", this.content = document.createElement("div"), this.content.style.position = "relative", this.content.style.userSelect = "none", this.content.className = "konvajs-content", this.content.setAttribute("role", "presentation"), M.appendChild(this.content), this._resizeDOM();
      }
    }
    cache() {
      return t.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."), this;
    }
    clearCache() {
      return this;
    }
    batchDraw() {
      return this.getChildren().forEach(function(M) {
        M.batchDraw();
      }), this;
    }
  }
  s.Stage = Ut, Ut.prototype.nodeType = l, (0, o._registerNode)(Ut), e.Factory.addGetterSetter(Ut, "container");
})(Ii);
var Hi = {};
Object.defineProperty(Hi, "__esModule", { value: !0 });
var br = Hi.Layer = void 0;
const $t = et, Rs = Ee, Ve = rt, wr = V, xa = It, KA = O, ZA = ft, JA = $;
var tc = "#", ec = "beforeDraw", ic = "draw", Do = [
  { x: 0, y: 0 },
  { x: -1, y: -1 },
  { x: 1, y: -1 },
  { x: 1, y: 1 },
  { x: -1, y: 1 }
], nc = Do.length;
class fi extends Rs.Container {
  constructor(t) {
    super(t), this.canvas = new xa.SceneCanvas(), this.hitCanvas = new xa.HitCanvas({
      pixelRatio: 1
    }), this._waitingForDraw = !1, this.on("visibleChange.konva", this._checkVisibility), this._checkVisibility(), this.on("imageSmoothingEnabledChange.konva", this._setSmoothEnabled), this._setSmoothEnabled();
  }
  createPNGStream() {
    return this.canvas._canvas.createPNGStream();
  }
  getCanvas() {
    return this.canvas;
  }
  getNativeCanvasElement() {
    return this.canvas._canvas;
  }
  getHitCanvas() {
    return this.hitCanvas;
  }
  getContext() {
    return this.getCanvas().getContext();
  }
  clear(t) {
    return this.getContext().clear(t), this.getHitCanvas().getContext().clear(t), this;
  }
  setZIndex(t) {
    super.setZIndex(t);
    var e = this.getStage();
    return e && e.content && (e.content.removeChild(this.getNativeCanvasElement()), t < e.children.length - 1 ? e.content.insertBefore(this.getNativeCanvasElement(), e.children[t + 1].getCanvas()._canvas) : e.content.appendChild(this.getNativeCanvasElement())), this;
  }
  moveToTop() {
    Ve.Node.prototype.moveToTop.call(this);
    var t = this.getStage();
    return t && t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.appendChild(this.getNativeCanvasElement())), !0;
  }
  moveUp() {
    var t = Ve.Node.prototype.moveUp.call(this);
    if (!t)
      return !1;
    var e = this.getStage();
    return !e || !e.content ? !1 : (e.content.removeChild(this.getNativeCanvasElement()), this.index < e.children.length - 1 ? e.content.insertBefore(this.getNativeCanvasElement(), e.children[this.index + 1].getCanvas()._canvas) : e.content.appendChild(this.getNativeCanvasElement()), !0);
  }
  moveDown() {
    if (Ve.Node.prototype.moveDown.call(this)) {
      var t = this.getStage();
      if (t) {
        var e = t.children;
        t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.insertBefore(this.getNativeCanvasElement(), e[this.index + 1].getCanvas()._canvas));
      }
      return !0;
    }
    return !1;
  }
  moveToBottom() {
    if (Ve.Node.prototype.moveToBottom.call(this)) {
      var t = this.getStage();
      if (t) {
        var e = t.children;
        t.content && (t.content.removeChild(this.getNativeCanvasElement()), t.content.insertBefore(this.getNativeCanvasElement(), e[1].getCanvas()._canvas));
      }
      return !0;
    }
    return !1;
  }
  getLayer() {
    return this;
  }
  remove() {
    var t = this.getNativeCanvasElement();
    return Ve.Node.prototype.remove.call(this), t && t.parentNode && $t.Util._isInDocument(t) && t.parentNode.removeChild(t), this;
  }
  getStage() {
    return this.parent;
  }
  setSize({ width: t, height: e }) {
    return this.canvas.setSize(t, e), this.hitCanvas.setSize(t, e), this._setSmoothEnabled(), this;
  }
  _validateAdd(t) {
    var e = t.getType();
    e !== "Group" && e !== "Shape" && $t.Util.throw("You may only add groups and shapes to a layer.");
  }
  _toKonvaCanvas(t) {
    return t = t || {}, t.width = t.width || this.getWidth(), t.height = t.height || this.getHeight(), t.x = t.x !== void 0 ? t.x : this.x(), t.y = t.y !== void 0 ? t.y : this.y(), Ve.Node.prototype._toKonvaCanvas.call(this, t);
  }
  _checkVisibility() {
    this.visible() ? this.canvas._canvas.style.display = "block" : this.canvas._canvas.style.display = "none";
  }
  _setSmoothEnabled() {
    this.getContext()._context.imageSmoothingEnabled = this.imageSmoothingEnabled();
  }
  getWidth() {
    if (this.parent)
      return this.parent.width();
  }
  setWidth() {
    $t.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
  }
  getHeight() {
    if (this.parent)
      return this.parent.height();
  }
  setHeight() {
    $t.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
  }
  batchDraw() {
    return this._waitingForDraw || (this._waitingForDraw = !0, $t.Util.requestAnimFrame(() => {
      this.draw(), this._waitingForDraw = !1;
    })), this;
  }
  getIntersection(t) {
    if (!this.isListening() || !this.isVisible())
      return null;
    for (var e = 1, i = !1; ; ) {
      for (let n = 0; n < nc; n++) {
        const r = Do[n], a = this._getIntersection({
          x: t.x + r.x * e,
          y: t.y + r.y * e
        }), o = a.shape;
        if (o)
          return o;
        if (i = !!a.antialiased, !a.antialiased)
          break;
      }
      if (i)
        e += 1;
      else
        return null;
    }
  }
  _getIntersection(t) {
    const e = this.hitCanvas.pixelRatio, i = this.hitCanvas.context.getImageData(Math.round(t.x * e), Math.round(t.y * e), 1, 1).data, n = i[3];
    if (n === 255) {
      const r = $t.Util._rgbToHex(i[0], i[1], i[2]), a = ZA.shapes[tc + r];
      return a ? {
        shape: a
      } : {
        antialiased: !0
      };
    } else if (n > 0)
      return {
        antialiased: !0
      };
    return {};
  }
  drawScene(t, e) {
    var i = this.getLayer(), n = t || i && i.getCanvas();
    return this._fire(ec, {
      node: this
    }), this.clearBeforeDraw() && n.getContext().clear(), Rs.Container.prototype.drawScene.call(this, n, e), this._fire(ic, {
      node: this
    }), this;
  }
  drawHit(t, e) {
    var i = this.getLayer(), n = t || i && i.hitCanvas;
    return i && i.clearBeforeDraw() && i.getHitCanvas().getContext().clear(), Rs.Container.prototype.drawHit.call(this, n, e), this;
  }
  enableHitGraph() {
    return this.hitGraphEnabled(!0), this;
  }
  disableHitGraph() {
    return this.hitGraphEnabled(!1), this;
  }
  setHitGraphEnabled(t) {
    $t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening(t);
  }
  getHitGraphEnabled(t) {
    return $t.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."), this.listening();
  }
  toggleHitCanvas() {
    if (!(!this.parent || !this.parent.content)) {
      var t = this.parent, e = !!this.hitCanvas._canvas.parentNode;
      e ? t.content.removeChild(this.hitCanvas._canvas) : t.content.appendChild(this.hitCanvas._canvas);
    }
  }
  destroy() {
    return $t.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas), super.destroy();
  }
}
br = Hi.Layer = fi;
fi.prototype.nodeType = "Layer";
(0, JA._registerNode)(fi);
wr.Factory.addGetterSetter(fi, "imageSmoothingEnabled", !0);
wr.Factory.addGetterSetter(fi, "clearBeforeDraw", !0);
wr.Factory.addGetterSetter(fi, "hitGraphEnabled", !0, (0, KA.getBooleanValidator)());
var Bn = {};
Object.defineProperty(Bn, "__esModule", { value: !0 });
Bn.FastLayer = void 0;
const sc = et, rc = Hi, ac = $;
class Sr extends rc.Layer {
  constructor(t) {
    super(t), this.listening(!1), sc.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
  }
}
Bn.FastLayer = Sr;
Sr.prototype.nodeType = "FastLayer";
(0, ac._registerNode)(Sr);
var gi = {};
Object.defineProperty(gi, "__esModule", { value: !0 });
gi.Animation = void 0;
const Os = $, ba = et, Ns = function() {
  return Os.glob.performance && Os.glob.performance.now ? function() {
    return Os.glob.performance.now();
  } : function() {
    return (/* @__PURE__ */ new Date()).getTime();
  };
}();
class Rt {
  constructor(t, e) {
    this.id = Rt.animIdCounter++, this.frame = {
      time: 0,
      timeDiff: 0,
      lastTime: Ns(),
      frameRate: 0
    }, this.func = t, this.setLayers(e);
  }
  setLayers(t) {
    let e = [];
    return t && (e = Array.isArray(t) ? t : [t]), this.layers = e, this;
  }
  getLayers() {
    return this.layers;
  }
  addLayer(t) {
    const e = this.layers, i = e.length;
    for (let n = 0; n < i; n++)
      if (e[n]._id === t._id)
        return !1;
    return this.layers.push(t), !0;
  }
  isRunning() {
    const e = Rt.animations, i = e.length;
    for (let n = 0; n < i; n++)
      if (e[n].id === this.id)
        return !0;
    return !1;
  }
  start() {
    return this.stop(), this.frame.timeDiff = 0, this.frame.lastTime = Ns(), Rt._addAnimation(this), this;
  }
  stop() {
    return Rt._removeAnimation(this), this;
  }
  _updateFrameObject(t) {
    this.frame.timeDiff = t - this.frame.lastTime, this.frame.lastTime = t, this.frame.time += this.frame.timeDiff, this.frame.frameRate = 1e3 / this.frame.timeDiff;
  }
  static _addAnimation(t) {
    this.animations.push(t), this._handleAnimation();
  }
  static _removeAnimation(t) {
    const e = t.id, i = this.animations, n = i.length;
    for (let r = 0; r < n; r++)
      if (i[r].id === e) {
        this.animations.splice(r, 1);
        break;
      }
  }
  static _runFrames() {
    const t = {}, e = this.animations;
    for (let i = 0; i < e.length; i++) {
      const n = e[i], r = n.layers, a = n.func;
      n._updateFrameObject(Ns());
      const o = r.length;
      let h;
      if (a ? h = a.call(n, n.frame) !== !1 : h = !0, !!h)
        for (let l = 0; l < o; l++) {
          const A = r[l];
          A._id !== void 0 && (t[A._id] = A);
        }
    }
    for (let i in t)
      t.hasOwnProperty(i) && t[i].batchDraw();
  }
  static _animationLoop() {
    const t = Rt;
    t.animations.length ? (t._runFrames(), ba.Util.requestAnimFrame(t._animationLoop)) : t.animRunning = !1;
  }
  static _handleAnimation() {
    this.animRunning || (this.animRunning = !0, ba.Util.requestAnimFrame(this._animationLoop));
  }
}
gi.Animation = Rt;
Rt.animations = [];
Rt.animIdCounter = 0;
Rt.animRunning = !1;
var Io = {};
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.Easings = s.Tween = void 0;
  const t = et, e = gi, i = rt, n = $;
  var r = {
    node: 1,
    duration: 1,
    easing: 1,
    onFinish: 1,
    yoyo: 1
  }, a = 1, o = 2, h = 3, l = 0, A = ["fill", "stroke", "shadowColor"];
  class u {
    constructor(d, p, m, v, _, g, y) {
      this.prop = d, this.propFunc = p, this.begin = v, this._pos = v, this.duration = g, this._change = 0, this.prevPos = 0, this.yoyo = y, this._time = 0, this._position = 0, this._startTime = 0, this._finish = 0, this.func = m, this._change = _ - this.begin, this.pause();
    }
    fire(d) {
      var p = this[d];
      p && p();
    }
    setTime(d) {
      d > this.duration ? this.yoyo ? (this._time = this.duration, this.reverse()) : this.finish() : d < 0 ? this.yoyo ? (this._time = 0, this.play()) : this.reset() : (this._time = d, this.update());
    }
    getTime() {
      return this._time;
    }
    setPosition(d) {
      this.prevPos = this._pos, this.propFunc(d), this._pos = d;
    }
    getPosition(d) {
      return d === void 0 && (d = this._time), this.func(d, this.begin, this._change, this.duration);
    }
    play() {
      this.state = o, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onPlay");
    }
    reverse() {
      this.state = h, this._time = this.duration - this._time, this._startTime = this.getTimer() - this._time, this.onEnterFrame(), this.fire("onReverse");
    }
    seek(d) {
      this.pause(), this._time = d, this.update(), this.fire("onSeek");
    }
    reset() {
      this.pause(), this._time = 0, this.update(), this.fire("onReset");
    }
    finish() {
      this.pause(), this._time = this.duration, this.update(), this.fire("onFinish");
    }
    update() {
      this.setPosition(this.getPosition(this._time)), this.fire("onUpdate");
    }
    onEnterFrame() {
      var d = this.getTimer() - this._startTime;
      this.state === o ? this.setTime(d) : this.state === h && this.setTime(this.duration - d);
    }
    pause() {
      this.state = a, this.fire("onPause");
    }
    getTimer() {
      return (/* @__PURE__ */ new Date()).getTime();
    }
  }
  class f {
    constructor(d) {
      var p = this, m = d.node, v = m._id, _, g = d.easing || s.Easings.Linear, y = !!d.yoyo, x;
      typeof d.duration > "u" ? _ = 0.3 : d.duration === 0 ? _ = 1e-3 : _ = d.duration, this.node = m, this._id = l++;
      var b = m.getLayer() || (m instanceof n.Konva.Stage ? m.getLayers() : null);
      b || t.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."), this.anim = new e.Animation(function() {
        p.tween.onEnterFrame();
      }, b), this.tween = new u(x, function(C) {
        p._tweenFunc(C);
      }, g, 0, 1, _ * 1e3, y), this._addListeners(), f.attrs[v] || (f.attrs[v] = {}), f.attrs[v][this._id] || (f.attrs[v][this._id] = {}), f.tweens[v] || (f.tweens[v] = {});
      for (x in d)
        r[x] === void 0 && this._addAttr(x, d[x]);
      this.reset(), this.onFinish = d.onFinish, this.onReset = d.onReset, this.onUpdate = d.onUpdate;
    }
    _addAttr(d, p) {
      var m = this.node, v = m._id, _, g, y, x, b, C, w, E;
      if (y = f.tweens[v][d], y && delete f.attrs[v][y][d], _ = m.getAttr(d), t.Util._isArray(p))
        if (g = [], b = Math.max(p.length, _.length), d === "points" && p.length !== _.length && (p.length > _.length ? (w = _, _ = t.Util._prepareArrayForTween(_, p, m.closed())) : (C = p, p = t.Util._prepareArrayForTween(p, _, m.closed()))), d.indexOf("fill") === 0)
          for (x = 0; x < b; x++)
            if (x % 2 === 0)
              g.push(p[x] - _[x]);
            else {
              var S = t.Util.colorToRGBA(_[x]);
              E = t.Util.colorToRGBA(p[x]), _[x] = S, g.push({
                r: E.r - S.r,
                g: E.g - S.g,
                b: E.b - S.b,
                a: E.a - S.a
              });
            }
        else
          for (x = 0; x < b; x++)
            g.push(p[x] - _[x]);
      else
        A.indexOf(d) !== -1 ? (_ = t.Util.colorToRGBA(_), E = t.Util.colorToRGBA(p), g = {
          r: E.r - _.r,
          g: E.g - _.g,
          b: E.b - _.b,
          a: E.a - _.a
        }) : g = p - _;
      f.attrs[v][this._id][d] = {
        start: _,
        diff: g,
        end: p,
        trueEnd: C,
        trueStart: w
      }, f.tweens[v][d] = this._id;
    }
    _tweenFunc(d) {
      var p = this.node, m = f.attrs[p._id][this._id], v, _, g, y, x, b, C, w;
      for (v in m) {
        if (_ = m[v], g = _.start, y = _.diff, w = _.end, t.Util._isArray(g))
          if (x = [], C = Math.max(g.length, w.length), v.indexOf("fill") === 0)
            for (b = 0; b < C; b++)
              b % 2 === 0 ? x.push((g[b] || 0) + y[b] * d) : x.push("rgba(" + Math.round(g[b].r + y[b].r * d) + "," + Math.round(g[b].g + y[b].g * d) + "," + Math.round(g[b].b + y[b].b * d) + "," + (g[b].a + y[b].a * d) + ")");
          else
            for (b = 0; b < C; b++)
              x.push((g[b] || 0) + y[b] * d);
        else
          A.indexOf(v) !== -1 ? x = "rgba(" + Math.round(g.r + y.r * d) + "," + Math.round(g.g + y.g * d) + "," + Math.round(g.b + y.b * d) + "," + (g.a + y.a * d) + ")" : x = g + y * d;
        p.setAttr(v, x);
      }
    }
    _addListeners() {
      this.tween.onPlay = () => {
        this.anim.start();
      }, this.tween.onReverse = () => {
        this.anim.start();
      }, this.tween.onPause = () => {
        this.anim.stop();
      }, this.tween.onFinish = () => {
        var d = this.node, p = f.attrs[d._id][this._id];
        p.points && p.points.trueEnd && d.setAttr("points", p.points.trueEnd), this.onFinish && this.onFinish.call(this);
      }, this.tween.onReset = () => {
        var d = this.node, p = f.attrs[d._id][this._id];
        p.points && p.points.trueStart && d.points(p.points.trueStart), this.onReset && this.onReset();
      }, this.tween.onUpdate = () => {
        this.onUpdate && this.onUpdate.call(this);
      };
    }
    play() {
      return this.tween.play(), this;
    }
    reverse() {
      return this.tween.reverse(), this;
    }
    reset() {
      return this.tween.reset(), this;
    }
    seek(d) {
      return this.tween.seek(d * 1e3), this;
    }
    pause() {
      return this.tween.pause(), this;
    }
    finish() {
      return this.tween.finish(), this;
    }
    destroy() {
      var d = this.node._id, p = this._id, m = f.tweens[d], v;
      this.pause();
      for (v in m)
        delete f.tweens[d][v];
      delete f.attrs[d][p];
    }
  }
  s.Tween = f, f.attrs = {}, f.tweens = {}, i.Node.prototype.to = function(c) {
    var d = c.onFinish;
    c.node = this, c.onFinish = function() {
      this.destroy(), d && d();
    };
    var p = new f(c);
    p.play();
  }, s.Easings = {
    BackEaseIn(c, d, p, m) {
      var v = 1.70158;
      return p * (c /= m) * c * ((v + 1) * c - v) + d;
    },
    BackEaseOut(c, d, p, m) {
      var v = 1.70158;
      return p * ((c = c / m - 1) * c * ((v + 1) * c + v) + 1) + d;
    },
    BackEaseInOut(c, d, p, m) {
      var v = 1.70158;
      return (c /= m / 2) < 1 ? p / 2 * (c * c * (((v *= 1.525) + 1) * c - v)) + d : p / 2 * ((c -= 2) * c * (((v *= 1.525) + 1) * c + v) + 2) + d;
    },
    ElasticEaseIn(c, d, p, m, v, _) {
      var g = 0;
      return c === 0 ? d : (c /= m) === 1 ? d + p : (_ || (_ = m * 0.3), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), -(v * Math.pow(2, 10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _)) + d);
    },
    ElasticEaseOut(c, d, p, m, v, _) {
      var g = 0;
      return c === 0 ? d : (c /= m) === 1 ? d + p : (_ || (_ = m * 0.3), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), v * Math.pow(2, -10 * c) * Math.sin((c * m - g) * (2 * Math.PI) / _) + p + d);
    },
    ElasticEaseInOut(c, d, p, m, v, _) {
      var g = 0;
      return c === 0 ? d : (c /= m / 2) === 2 ? d + p : (_ || (_ = m * (0.3 * 1.5)), !v || v < Math.abs(p) ? (v = p, g = _ / 4) : g = _ / (2 * Math.PI) * Math.asin(p / v), c < 1 ? -0.5 * (v * Math.pow(2, 10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _)) + d : v * Math.pow(2, -10 * (c -= 1)) * Math.sin((c * m - g) * (2 * Math.PI) / _) * 0.5 + p + d);
    },
    BounceEaseOut(c, d, p, m) {
      return (c /= m) < 1 / 2.75 ? p * (7.5625 * c * c) + d : c < 2 / 2.75 ? p * (7.5625 * (c -= 1.5 / 2.75) * c + 0.75) + d : c < 2.5 / 2.75 ? p * (7.5625 * (c -= 2.25 / 2.75) * c + 0.9375) + d : p * (7.5625 * (c -= 2.625 / 2.75) * c + 0.984375) + d;
    },
    BounceEaseIn(c, d, p, m) {
      return p - s.Easings.BounceEaseOut(m - c, 0, p, m) + d;
    },
    BounceEaseInOut(c, d, p, m) {
      return c < m / 2 ? s.Easings.BounceEaseIn(c * 2, 0, p, m) * 0.5 + d : s.Easings.BounceEaseOut(c * 2 - m, 0, p, m) * 0.5 + p * 0.5 + d;
    },
    EaseIn(c, d, p, m) {
      return p * (c /= m) * c + d;
    },
    EaseOut(c, d, p, m) {
      return -p * (c /= m) * (c - 2) + d;
    },
    EaseInOut(c, d, p, m) {
      return (c /= m / 2) < 1 ? p / 2 * c * c + d : -p / 2 * (--c * (c - 2) - 1) + d;
    },
    StrongEaseIn(c, d, p, m) {
      return p * (c /= m) * c * c * c * c + d;
    },
    StrongEaseOut(c, d, p, m) {
      return p * ((c = c / m - 1) * c * c * c * c + 1) + d;
    },
    StrongEaseInOut(c, d, p, m) {
      return (c /= m / 2) < 1 ? p / 2 * c * c * c * c * c + d : p / 2 * ((c -= 2) * c * c * c * c + 2) + d;
    },
    Linear(c, d, p, m) {
      return p * c / m + d;
    }
  };
})(Io);
(function(s) {
  Object.defineProperty(s, "__esModule", { value: !0 }), s.Konva = void 0;
  const t = $, e = et, i = rt, n = Ee, r = Ii, a = Hi, o = Bn, h = li, l = En, A = ft, u = gi, f = Io, c = Xt, d = It;
  s.Konva = e.Util._assign(t.Konva, {
    Util: e.Util,
    Transform: e.Transform,
    Node: i.Node,
    Container: n.Container,
    Stage: r.Stage,
    stages: r.stages,
    Layer: a.Layer,
    FastLayer: o.FastLayer,
    Group: h.Group,
    DD: l.DD,
    Shape: A.Shape,
    shapes: A.shapes,
    Animation: u.Animation,
    Tween: f.Tween,
    Easings: f.Easings,
    Context: c.Context,
    Canvas: d.Canvas
  }), s.default = s.Konva;
})(ko);
var zn = {};
Object.defineProperty(zn, "__esModule", { value: !0 });
zn.Arc = void 0;
const Un = V, oc = ft, wa = $, Hn = O, hc = $;
class te extends oc.Shape {
  _sceneFunc(t) {
    var e = wa.Konva.getAngle(this.angle()), i = this.clockwise();
    t.beginPath(), t.arc(0, 0, this.outerRadius(), 0, e, i), t.arc(0, 0, this.innerRadius(), e, 0, !i), t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    return this.outerRadius() * 2;
  }
  getHeight() {
    return this.outerRadius() * 2;
  }
  setWidth(t) {
    this.outerRadius(t / 2);
  }
  setHeight(t) {
    this.outerRadius(t / 2);
  }
  getSelfRect() {
    const t = this.innerRadius(), e = this.outerRadius(), i = this.clockwise(), n = wa.Konva.getAngle(i ? 360 - this.angle() : this.angle()), r = Math.cos(Math.min(n, Math.PI)), a = 1, o = Math.sin(Math.min(Math.max(Math.PI, n), 3 * Math.PI / 2)), h = Math.sin(Math.min(n, Math.PI / 2)), l = r * (r > 0 ? t : e), A = a * e, u = o * (o > 0 ? t : e), f = h * (h > 0 ? e : t);
    return {
      x: l,
      y: i ? -1 * f : u,
      width: A - l,
      height: f - u
    };
  }
}
zn.Arc = te;
te.prototype._centroid = !0;
te.prototype.className = "Arc";
te.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
(0, hc._registerNode)(te);
Un.Factory.addGetterSetter(te, "innerRadius", 0, (0, Hn.getNumberValidator)());
Un.Factory.addGetterSetter(te, "outerRadius", 0, (0, Hn.getNumberValidator)());
Un.Factory.addGetterSetter(te, "angle", 0, (0, Hn.getNumberValidator)());
Un.Factory.addGetterSetter(te, "clockwise", !1, (0, Hn.getBooleanValidator)());
var Vn = {};
Object.defineProperty(Vn, "__esModule", { value: !0 });
Vn.Arrow = void 0;
const $n = V, lc = Gi, To = O, Ac = $, Sa = hi;
class ke extends lc.Line {
  _sceneFunc(t) {
    super._sceneFunc(t);
    var e = Math.PI * 2, i = this.points(), n = i, r = this.tension() !== 0 && i.length > 4;
    r && (n = this.getTensionPoints());
    var a = this.pointerLength(), o = i.length, h, l;
    if (r) {
      const f = [
        n[n.length - 4],
        n[n.length - 3],
        n[n.length - 2],
        n[n.length - 1],
        i[o - 2],
        i[o - 1]
      ], c = Sa.Path.calcLength(n[n.length - 4], n[n.length - 3], "C", f), d = Sa.Path.getPointOnQuadraticBezier(Math.min(1, 1 - a / c), f[0], f[1], f[2], f[3], f[4], f[5]);
      h = i[o - 2] - d.x, l = i[o - 1] - d.y;
    } else
      h = i[o - 2] - i[o - 4], l = i[o - 1] - i[o - 3];
    var A = (Math.atan2(l, h) + e) % e, u = this.pointerWidth();
    this.pointerAtEnding() && (t.save(), t.beginPath(), t.translate(i[o - 2], i[o - 1]), t.rotate(A), t.moveTo(0, 0), t.lineTo(-a, u / 2), t.lineTo(-a, -u / 2), t.closePath(), t.restore(), this.__fillStroke(t)), this.pointerAtBeginning() && (t.save(), t.beginPath(), t.translate(i[0], i[1]), r ? (h = (n[0] + n[2]) / 2 - i[0], l = (n[1] + n[3]) / 2 - i[1]) : (h = i[2] - i[0], l = i[3] - i[1]), t.rotate((Math.atan2(-l, -h) + e) % e), t.moveTo(0, 0), t.lineTo(-a, u / 2), t.lineTo(-a, -u / 2), t.closePath(), t.restore(), this.__fillStroke(t));
  }
  __fillStroke(t) {
    var e = this.dashEnabled();
    e && (this.attrs.dashEnabled = !1, t.setLineDash([])), t.fillStrokeShape(this), e && (this.attrs.dashEnabled = !0);
  }
  getSelfRect() {
    const t = super.getSelfRect(), e = this.pointerWidth() / 2;
    return {
      x: t.x - e,
      y: t.y - e,
      width: t.width + e * 2,
      height: t.height + e * 2
    };
  }
}
Vn.Arrow = ke;
ke.prototype.className = "Arrow";
(0, Ac._registerNode)(ke);
$n.Factory.addGetterSetter(ke, "pointerLength", 10, (0, To.getNumberValidator)());
$n.Factory.addGetterSetter(ke, "pointerWidth", 10, (0, To.getNumberValidator)());
$n.Factory.addGetterSetter(ke, "pointerAtBeginning", !1);
$n.Factory.addGetterSetter(ke, "pointerAtEnding", !0);
var Wn = {};
Object.defineProperty(Wn, "__esModule", { value: !0 });
Wn.Ellipse = void 0;
const Cr = V, cc = ft, Lo = O, dc = $;
class ye extends cc.Shape {
  _sceneFunc(t) {
    var e = this.radiusX(), i = this.radiusY();
    t.beginPath(), t.save(), e !== i && t.scale(1, i / e), t.arc(0, 0, e, 0, Math.PI * 2, !1), t.restore(), t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    return this.radiusX() * 2;
  }
  getHeight() {
    return this.radiusY() * 2;
  }
  setWidth(t) {
    this.radiusX(t / 2);
  }
  setHeight(t) {
    this.radiusY(t / 2);
  }
}
Wn.Ellipse = ye;
ye.prototype.className = "Ellipse";
ye.prototype._centroid = !0;
ye.prototype._attrsAffectingSize = ["radiusX", "radiusY"];
(0, dc._registerNode)(ye);
Cr.Factory.addComponentsGetterSetter(ye, "radius", ["x", "y"]);
Cr.Factory.addGetterSetter(ye, "radiusX", 0, (0, Lo.getNumberValidator)());
Cr.Factory.addGetterSetter(ye, "radiusY", 0, (0, Lo.getNumberValidator)());
var Yn = {};
Object.defineProperty(Yn, "__esModule", { value: !0 });
Yn.Image = void 0;
const Gs = et, De = V, uc = ft, fc = $, Vi = O;
let Bt = class Ro extends uc.Shape {
  constructor(t) {
    super(t), this.on("imageChange.konva", () => {
      this._setImageLoad();
    }), this._setImageLoad();
  }
  _setImageLoad() {
    const t = this.image();
    t && t.complete || t && t.readyState === 4 || t && t.addEventListener && t.addEventListener("load", () => {
      this._requestDraw();
    });
  }
  _useBufferCanvas() {
    return super._useBufferCanvas(!0);
  }
  _sceneFunc(t) {
    const e = this.getWidth(), i = this.getHeight(), n = this.cornerRadius(), r = this.attrs.image;
    let a;
    if (r) {
      const o = this.attrs.cropWidth, h = this.attrs.cropHeight;
      o && h ? a = [
        r,
        this.cropX(),
        this.cropY(),
        o,
        h,
        0,
        0,
        e,
        i
      ] : a = [r, 0, 0, e, i];
    }
    (this.hasFill() || this.hasStroke() || n) && (t.beginPath(), n ? Gs.Util.drawRoundedRectPath(t, e, i, n) : t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this)), r && (n && t.clip(), t.drawImage.apply(t, a));
  }
  _hitFunc(t) {
    var e = this.width(), i = this.height(), n = this.cornerRadius();
    t.beginPath(), n ? Gs.Util.drawRoundedRectPath(t, e, i, n) : t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    var t, e;
    return (t = this.attrs.width) !== null && t !== void 0 ? t : (e = this.image()) === null || e === void 0 ? void 0 : e.width;
  }
  getHeight() {
    var t, e;
    return (t = this.attrs.height) !== null && t !== void 0 ? t : (e = this.image()) === null || e === void 0 ? void 0 : e.height;
  }
  static fromURL(t, e, i = null) {
    var n = Gs.Util.createImageElement();
    n.onload = function() {
      var r = new Ro({
        image: n
      });
      e(r);
    }, n.onerror = i, n.crossOrigin = "Anonymous", n.src = t;
  }
};
Yn.Image = Bt;
Bt.prototype.className = "Image";
(0, fc._registerNode)(Bt);
De.Factory.addGetterSetter(Bt, "cornerRadius", 0, (0, Vi.getNumberOrArrayOfNumbersValidator)(4));
De.Factory.addGetterSetter(Bt, "image");
De.Factory.addComponentsGetterSetter(Bt, "crop", ["x", "y", "width", "height"]);
De.Factory.addGetterSetter(Bt, "cropX", 0, (0, Vi.getNumberValidator)());
De.Factory.addGetterSetter(Bt, "cropY", 0, (0, Vi.getNumberValidator)());
De.Factory.addGetterSetter(Bt, "cropWidth", 0, (0, Vi.getNumberValidator)());
De.Factory.addGetterSetter(Bt, "cropHeight", 0, (0, Vi.getNumberValidator)());
var ii = {};
Object.defineProperty(ii, "__esModule", { value: !0 });
var Oo = ii.Tag = Bo = ii.Label = void 0;
const Xn = V, gc = ft, pc = li, Mr = O, No = $;
var Go = [
  "fontFamily",
  "fontSize",
  "fontStyle",
  "padding",
  "lineHeight",
  "text",
  "width",
  "height",
  "pointerDirection",
  "pointerWidth",
  "pointerHeight"
], yc = "Change.konva", mc = "none", er = "up", ir = "right", nr = "down", sr = "left", vc = Go.length;
class Pr extends pc.Group {
  constructor(t) {
    super(t), this.on("add.konva", function(e) {
      this._addListeners(e.child), this._sync();
    });
  }
  getText() {
    return this.find("Text")[0];
  }
  getTag() {
    return this.find("Tag")[0];
  }
  _addListeners(t) {
    var e = this, i, n = function() {
      e._sync();
    };
    for (i = 0; i < vc; i++)
      t.on(Go[i] + yc, n);
  }
  getWidth() {
    return this.getText().width();
  }
  getHeight() {
    return this.getText().height();
  }
  _sync() {
    var t = this.getText(), e = this.getTag(), i, n, r, a, o, h, l;
    if (t && e) {
      switch (i = t.width(), n = t.height(), r = e.pointerDirection(), a = e.pointerWidth(), l = e.pointerHeight(), o = 0, h = 0, r) {
        case er:
          o = i / 2, h = -1 * l;
          break;
        case ir:
          o = i + a, h = n / 2;
          break;
        case nr:
          o = i / 2, h = n + l;
          break;
        case sr:
          o = -1 * a, h = n / 2;
          break;
      }
      e.setAttrs({
        x: -1 * o,
        y: -1 * h,
        width: i,
        height: n
      }), t.setAttrs({
        x: -1 * o,
        y: -1 * h
      });
    }
  }
}
var Bo = ii.Label = Pr;
Pr.prototype.className = "Label";
(0, No._registerNode)(Pr);
class Ie extends gc.Shape {
  _sceneFunc(t) {
    var e = this.width(), i = this.height(), n = this.pointerDirection(), r = this.pointerWidth(), a = this.pointerHeight(), o = this.cornerRadius();
    let h = 0, l = 0, A = 0, u = 0;
    typeof o == "number" ? h = l = A = u = Math.min(o, e / 2, i / 2) : (h = Math.min(o[0] || 0, e / 2, i / 2), l = Math.min(o[1] || 0, e / 2, i / 2), u = Math.min(o[2] || 0, e / 2, i / 2), A = Math.min(o[3] || 0, e / 2, i / 2)), t.beginPath(), t.moveTo(h, 0), n === er && (t.lineTo((e - r) / 2, 0), t.lineTo(e / 2, -1 * a), t.lineTo((e + r) / 2, 0)), t.lineTo(e - l, 0), t.arc(e - l, l, l, Math.PI * 3 / 2, 0, !1), n === ir && (t.lineTo(e, (i - a) / 2), t.lineTo(e + r, i / 2), t.lineTo(e, (i + a) / 2)), t.lineTo(e, i - u), t.arc(e - u, i - u, u, 0, Math.PI / 2, !1), n === nr && (t.lineTo((e + r) / 2, i), t.lineTo(e / 2, i + a), t.lineTo((e - r) / 2, i)), t.lineTo(A, i), t.arc(A, i - A, A, Math.PI / 2, Math.PI, !1), n === sr && (t.lineTo(0, (i + a) / 2), t.lineTo(-1 * r, i / 2), t.lineTo(0, (i - a) / 2)), t.lineTo(0, h), t.arc(h, h, h, Math.PI, Math.PI * 3 / 2, !1), t.closePath(), t.fillStrokeShape(this);
  }
  getSelfRect() {
    var t = 0, e = 0, i = this.pointerWidth(), n = this.pointerHeight(), r = this.pointerDirection(), a = this.width(), o = this.height();
    return r === er ? (e -= n, o += n) : r === nr ? o += n : r === sr ? (t -= i * 1.5, a += i) : r === ir && (a += i * 1.5), {
      x: t,
      y: e,
      width: a,
      height: o
    };
  }
}
Oo = ii.Tag = Ie;
Ie.prototype.className = "Tag";
(0, No._registerNode)(Ie);
Xn.Factory.addGetterSetter(Ie, "pointerDirection", mc);
Xn.Factory.addGetterSetter(Ie, "pointerWidth", 0, (0, Mr.getNumberValidator)());
Xn.Factory.addGetterSetter(Ie, "pointerHeight", 0, (0, Mr.getNumberValidator)());
Xn.Factory.addGetterSetter(Ie, "cornerRadius", 0, (0, Mr.getNumberOrArrayOfNumbersValidator)(4));
var jn = {};
Object.defineProperty(jn, "__esModule", { value: !0 });
jn.RegularPolygon = void 0;
const zo = V, _c = ft, Uo = O, xc = $;
class Te extends _c.Shape {
  _sceneFunc(t) {
    const e = this._getPoints();
    t.beginPath(), t.moveTo(e[0].x, e[0].y);
    for (var i = 1; i < e.length; i++)
      t.lineTo(e[i].x, e[i].y);
    t.closePath(), t.fillStrokeShape(this);
  }
  _getPoints() {
    const t = this.attrs.sides, e = this.attrs.radius || 0, i = [];
    for (var n = 0; n < t; n++)
      i.push({
        x: e * Math.sin(n * 2 * Math.PI / t),
        y: -1 * e * Math.cos(n * 2 * Math.PI / t)
      });
    return i;
  }
  getSelfRect() {
    const t = this._getPoints();
    var e = t[0].x, i = t[0].y, n = t[0].x, r = t[0].y;
    return t.forEach((a) => {
      e = Math.min(e, a.x), i = Math.max(i, a.x), n = Math.min(n, a.y), r = Math.max(r, a.y);
    }), {
      x: e,
      y: n,
      width: i - e,
      height: r - n
    };
  }
  getWidth() {
    return this.radius() * 2;
  }
  getHeight() {
    return this.radius() * 2;
  }
  setWidth(t) {
    this.radius(t / 2);
  }
  setHeight(t) {
    this.radius(t / 2);
  }
}
jn.RegularPolygon = Te;
Te.prototype.className = "RegularPolygon";
Te.prototype._centroid = !0;
Te.prototype._attrsAffectingSize = ["radius"];
(0, xc._registerNode)(Te);
zo.Factory.addGetterSetter(Te, "radius", 0, (0, Uo.getNumberValidator)());
zo.Factory.addGetterSetter(Te, "sides", 0, (0, Uo.getNumberValidator)());
var qn = {};
Object.defineProperty(qn, "__esModule", { value: !0 });
qn.Ring = void 0;
const Ho = V, bc = ft, Vo = O, wc = $;
var Ca = Math.PI * 2;
class Le extends bc.Shape {
  _sceneFunc(t) {
    t.beginPath(), t.arc(0, 0, this.innerRadius(), 0, Ca, !1), t.moveTo(this.outerRadius(), 0), t.arc(0, 0, this.outerRadius(), Ca, 0, !0), t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    return this.outerRadius() * 2;
  }
  getHeight() {
    return this.outerRadius() * 2;
  }
  setWidth(t) {
    this.outerRadius(t / 2);
  }
  setHeight(t) {
    this.outerRadius(t / 2);
  }
}
qn.Ring = Le;
Le.prototype.className = "Ring";
Le.prototype._centroid = !0;
Le.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
(0, wc._registerNode)(Le);
Ho.Factory.addGetterSetter(Le, "innerRadius", 0, (0, Vo.getNumberValidator)());
Ho.Factory.addGetterSetter(Le, "outerRadius", 0, (0, Vo.getNumberValidator)());
var Qn = {};
Object.defineProperty(Qn, "__esModule", { value: !0 });
Qn.Sprite = void 0;
const Re = V, Sc = ft, Cc = gi, $o = O, Mc = $;
class zt extends Sc.Shape {
  constructor(t) {
    super(t), this._updated = !0, this.anim = new Cc.Animation(() => {
      var e = this._updated;
      return this._updated = !1, e;
    }), this.on("animationChange.konva", function() {
      this.frameIndex(0);
    }), this.on("frameIndexChange.konva", function() {
      this._updated = !0;
    }), this.on("frameRateChange.konva", function() {
      this.anim.isRunning() && (clearInterval(this.interval), this._setInterval());
    });
  }
  _sceneFunc(t) {
    var e = this.animation(), i = this.frameIndex(), n = i * 4, r = this.animations()[e], a = this.frameOffsets(), o = r[n + 0], h = r[n + 1], l = r[n + 2], A = r[n + 3], u = this.image();
    if ((this.hasFill() || this.hasStroke()) && (t.beginPath(), t.rect(0, 0, l, A), t.closePath(), t.fillStrokeShape(this)), u)
      if (a) {
        var f = a[e], c = i * 2;
        t.drawImage(u, o, h, l, A, f[c + 0], f[c + 1], l, A);
      } else
        t.drawImage(u, o, h, l, A, 0, 0, l, A);
  }
  _hitFunc(t) {
    var e = this.animation(), i = this.frameIndex(), n = i * 4, r = this.animations()[e], a = this.frameOffsets(), o = r[n + 2], h = r[n + 3];
    if (t.beginPath(), a) {
      var l = a[e], A = i * 2;
      t.rect(l[A + 0], l[A + 1], o, h);
    } else
      t.rect(0, 0, o, h);
    t.closePath(), t.fillShape(this);
  }
  _useBufferCanvas() {
    return super._useBufferCanvas(!0);
  }
  _setInterval() {
    var t = this;
    this.interval = setInterval(function() {
      t._updateIndex();
    }, 1e3 / this.frameRate());
  }
  start() {
    if (!this.isRunning()) {
      var t = this.getLayer();
      this.anim.setLayers(t), this._setInterval(), this.anim.start();
    }
  }
  stop() {
    this.anim.stop(), clearInterval(this.interval);
  }
  isRunning() {
    return this.anim.isRunning();
  }
  _updateIndex() {
    var t = this.frameIndex(), e = this.animation(), i = this.animations(), n = i[e], r = n.length / 4;
    t < r - 1 ? this.frameIndex(t + 1) : this.frameIndex(0);
  }
}
Qn.Sprite = zt;
zt.prototype.className = "Sprite";
(0, Mc._registerNode)(zt);
Re.Factory.addGetterSetter(zt, "animation");
Re.Factory.addGetterSetter(zt, "animations");
Re.Factory.addGetterSetter(zt, "frameOffsets");
Re.Factory.addGetterSetter(zt, "image");
Re.Factory.addGetterSetter(zt, "frameIndex", 0, (0, $o.getNumberValidator)());
Re.Factory.addGetterSetter(zt, "frameRate", 17, (0, $o.getNumberValidator)());
Re.Factory.backCompat(zt, {
  index: "frameIndex",
  getIndex: "getFrameIndex",
  setIndex: "setFrameIndex"
});
var Kn = {};
Object.defineProperty(Kn, "__esModule", { value: !0 });
Kn.Star = void 0;
const Er = V, Pc = ft, Fr = O, Ec = $;
class me extends Pc.Shape {
  _sceneFunc(t) {
    var e = this.innerRadius(), i = this.outerRadius(), n = this.numPoints();
    t.beginPath(), t.moveTo(0, 0 - i);
    for (var r = 1; r < n * 2; r++) {
      var a = r % 2 === 0 ? i : e, o = a * Math.sin(r * Math.PI / n), h = -1 * a * Math.cos(r * Math.PI / n);
      t.lineTo(o, h);
    }
    t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    return this.outerRadius() * 2;
  }
  getHeight() {
    return this.outerRadius() * 2;
  }
  setWidth(t) {
    this.outerRadius(t / 2);
  }
  setHeight(t) {
    this.outerRadius(t / 2);
  }
}
Kn.Star = me;
me.prototype.className = "Star";
me.prototype._centroid = !0;
me.prototype._attrsAffectingSize = ["innerRadius", "outerRadius"];
(0, Ec._registerNode)(me);
Er.Factory.addGetterSetter(me, "numPoints", 5, (0, Fr.getNumberValidator)());
Er.Factory.addGetterSetter(me, "innerRadius", 0, (0, Fr.getNumberValidator)());
Er.Factory.addGetterSetter(me, "outerRadius", 0, (0, Fr.getNumberValidator)());
var Me = {};
Object.defineProperty(Me, "__esModule", { value: !0 });
var dn = Me.Text = Me.stringToArray = void 0;
const rr = et, vt = V, Fc = ft, ve = O, kc = $;
function Wo(s) {
  return Array.from(s);
}
Me.stringToArray = Wo;
var $e = "auto", Dc = "center", Yo = "inherit", _i = "justify", Ic = "Change.konva", Tc = "2d", Ma = "-", Xo = "left", Lc = "text", Rc = "Text", Oc = "top", Nc = "bottom", Pa = "middle", jo = "normal", Gc = "px ", en = " ", Bc = "right", Ea = "rtl", zc = "word", Uc = "char", Fa = "none", Bs = "…", qo = [
  "direction",
  "fontFamily",
  "fontSize",
  "fontStyle",
  "fontVariant",
  "padding",
  "align",
  "verticalAlign",
  "lineHeight",
  "text",
  "width",
  "height",
  "wrap",
  "ellipsis",
  "letterSpacing"
], Hc = qo.length;
function Vc(s) {
  return s.split(",").map((t) => {
    t = t.trim();
    const e = t.indexOf(" ") >= 0, i = t.indexOf('"') >= 0 || t.indexOf("'") >= 0;
    return e && !i && (t = `"${t}"`), t;
  }).join(", ");
}
var nn;
function zs() {
  return nn || (nn = rr.Util.createCanvasElement().getContext(Tc), nn);
}
function $c(s) {
  s.fillText(this._partialText, this._partialTextX, this._partialTextY);
}
function Wc(s) {
  s.setAttr("miterLimit", 2), s.strokeText(this._partialText, this._partialTextX, this._partialTextY);
}
function Yc(s) {
  return s = s || {}, !s.fillLinearGradientColorStops && !s.fillRadialGradientColorStops && !s.fillPatternImage && (s.fill = s.fill || "black"), s;
}
class lt extends Fc.Shape {
  constructor(t) {
    super(Yc(t)), this._partialTextX = 0, this._partialTextY = 0;
    for (var e = 0; e < Hc; e++)
      this.on(qo[e] + Ic, this._setTextData);
    this._setTextData();
  }
  _sceneFunc(t) {
    var e = this.textArr, i = e.length;
    if (this.text()) {
      var n = this.padding(), r = this.fontSize(), a = this.lineHeight() * r, o = this.verticalAlign(), h = this.direction(), l = 0, A = this.align(), u = this.getWidth(), f = this.letterSpacing(), c = this.fill(), d = this.textDecoration(), p = d.indexOf("underline") !== -1, m = d.indexOf("line-through") !== -1, v;
      h = h === Yo ? t.direction : h;
      var _ = 0, _ = a / 2, g = 0, y = 0;
      for (h === Ea && t.setAttr("direction", h), t.setAttr("font", this._getContextFont()), t.setAttr("textBaseline", Pa), t.setAttr("textAlign", Xo), o === Pa ? l = (this.getHeight() - i * a - n * 2) / 2 : o === Nc && (l = this.getHeight() - i * a - n * 2), t.translate(n, l + n), v = 0; v < i; v++) {
        var g = 0, y = 0, x = e[v], b = x.text, C = x.width, w = x.lastInParagraph, E, S, P;
        if (t.save(), A === Bc ? g += u - C - n * 2 : A === Dc && (g += (u - C - n * 2) / 2), p) {
          t.save(), t.beginPath(), t.moveTo(g, _ + y + Math.round(r / 2)), E = b.split(" ").length - 1, S = E === 0, P = A === _i && !w ? u - n * 2 : C, t.lineTo(g + Math.round(P), _ + y + Math.round(r / 2)), t.lineWidth = r / 15;
          const T = this._getLinearGradient();
          t.strokeStyle = T || c, t.stroke(), t.restore();
        }
        if (m) {
          t.save(), t.beginPath(), t.moveTo(g, _ + y), E = b.split(" ").length - 1, S = E === 0, P = A === _i && w && !S ? u - n * 2 : C, t.lineTo(g + Math.round(P), _ + y), t.lineWidth = r / 15;
          const T = this._getLinearGradient();
          t.strokeStyle = T || c, t.stroke(), t.restore();
        }
        if (h !== Ea && (f !== 0 || A === _i)) {
          E = b.split(" ").length - 1;
          for (var k = Wo(b), F = 0; F < k.length; F++) {
            var L = k[F];
            L === " " && !w && A === _i && (g += (u - n * 2 - C) / E), this._partialTextX = g, this._partialTextY = _ + y, this._partialText = L, t.fillStrokeShape(this), g += this.measureSize(L).width + f;
          }
        } else
          f !== 0 && t.setAttr("letterSpacing", `${f}px`), this._partialTextX = g, this._partialTextY = _ + y, this._partialText = b, t.fillStrokeShape(this);
        t.restore(), i > 1 && (_ += a);
      }
    }
  }
  _hitFunc(t) {
    var e = this.getWidth(), i = this.getHeight();
    t.beginPath(), t.rect(0, 0, e, i), t.closePath(), t.fillStrokeShape(this);
  }
  setText(t) {
    var e = rr.Util._isString(t) ? t : t == null ? "" : t + "";
    return this._setAttr(Lc, e), this;
  }
  getWidth() {
    var t = this.attrs.width === $e || this.attrs.width === void 0;
    return t ? this.getTextWidth() + this.padding() * 2 : this.attrs.width;
  }
  getHeight() {
    var t = this.attrs.height === $e || this.attrs.height === void 0;
    return t ? this.fontSize() * this.textArr.length * this.lineHeight() + this.padding() * 2 : this.attrs.height;
  }
  getTextWidth() {
    return this.textWidth;
  }
  getTextHeight() {
    return rr.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
  }
  measureSize(t) {
    var e = zs(), i = this.fontSize(), n;
    return e.save(), e.font = this._getContextFont(), n = e.measureText(t), e.restore(), {
      width: n.width,
      height: i
    };
  }
  _getContextFont() {
    return this.fontStyle() + en + this.fontVariant() + en + (this.fontSize() + Gc) + Vc(this.fontFamily());
  }
  _addTextLine(t) {
    this.align() === _i && (t = t.trim());
    var i = this._getTextWidth(t);
    return this.textArr.push({
      text: t,
      width: i,
      lastInParagraph: !1
    });
  }
  _getTextWidth(t) {
    var e = this.letterSpacing(), i = t.length;
    return zs().measureText(t).width + (i ? e * (i - 1) : 0);
  }
  _setTextData() {
    var t = this.text().split(`
`), e = +this.fontSize(), i = 0, n = this.lineHeight() * e, r = this.attrs.width, a = this.attrs.height, o = r !== $e && r !== void 0, h = a !== $e && a !== void 0, l = this.padding(), A = r - l * 2, u = a - l * 2, f = 0, c = this.wrap(), d = c !== Fa, p = c !== Uc && d, m = this.ellipsis();
    this.textArr = [], zs().font = this._getContextFont();
    for (var v = m ? this._getTextWidth(Bs) : 0, _ = 0, g = t.length; _ < g; ++_) {
      var y = t[_], x = this._getTextWidth(y);
      if (o && x > A)
        for (; y.length > 0; ) {
          for (var b = 0, C = y.length, w = "", E = 0; b < C; ) {
            var S = b + C >>> 1, P = y.slice(0, S + 1), k = this._getTextWidth(P) + v;
            k <= A ? (b = S + 1, w = P, E = k) : C = S;
          }
          if (w) {
            if (p) {
              var F, L = y[w.length], I = L === en || L === Ma;
              I && E <= A ? F = w.length : F = Math.max(w.lastIndexOf(en), w.lastIndexOf(Ma)) + 1, F > 0 && (b = F, w = w.slice(0, b), E = this._getTextWidth(w));
            }
            w = w.trimRight(), this._addTextLine(w), i = Math.max(i, E), f += n;
            var z = this._shouldHandleEllipsis(f);
            if (z) {
              this._tryToAddEllipsisToLastLine();
              break;
            }
            if (y = y.slice(b), y = y.trimLeft(), y.length > 0 && (x = this._getTextWidth(y), x <= A)) {
              this._addTextLine(y), f += n, i = Math.max(i, x);
              break;
            }
          } else
            break;
        }
      else
        this._addTextLine(y), f += n, i = Math.max(i, x), this._shouldHandleEllipsis(f) && _ < g - 1 && this._tryToAddEllipsisToLastLine();
      if (this.textArr[this.textArr.length - 1] && (this.textArr[this.textArr.length - 1].lastInParagraph = !0), h && f + n > u)
        break;
    }
    this.textHeight = e, this.textWidth = i;
  }
  _shouldHandleEllipsis(t) {
    var e = +this.fontSize(), i = this.lineHeight() * e, n = this.attrs.height, r = n !== $e && n !== void 0, a = this.padding(), o = n - a * 2, h = this.wrap(), l = h !== Fa;
    return !l || r && t + i > o;
  }
  _tryToAddEllipsisToLastLine() {
    var t = this.attrs.width, e = t !== $e && t !== void 0, i = this.padding(), n = t - i * 2, r = this.ellipsis(), a = this.textArr[this.textArr.length - 1];
    if (!(!a || !r)) {
      if (e) {
        var o = this._getTextWidth(a.text + Bs) < n;
        o || (a.text = a.text.slice(0, a.text.length - 3));
      }
      this.textArr.splice(this.textArr.length - 1, 1), this._addTextLine(a.text + Bs);
    }
  }
  getStrokeScaleEnabled() {
    return !0;
  }
  _useBufferCanvas() {
    const t = this.textDecoration().indexOf("underline") !== -1 || this.textDecoration().indexOf("line-through") !== -1, e = this.hasShadow();
    return t && e ? !0 : super._useBufferCanvas();
  }
}
dn = Me.Text = lt;
lt.prototype._fillFunc = $c;
lt.prototype._strokeFunc = Wc;
lt.prototype.className = Rc;
lt.prototype._attrsAffectingSize = [
  "text",
  "fontSize",
  "padding",
  "wrap",
  "lineHeight",
  "letterSpacing"
];
(0, kc._registerNode)(lt);
vt.Factory.overWriteSetter(lt, "width", (0, ve.getNumberOrAutoValidator)());
vt.Factory.overWriteSetter(lt, "height", (0, ve.getNumberOrAutoValidator)());
vt.Factory.addGetterSetter(lt, "direction", Yo);
vt.Factory.addGetterSetter(lt, "fontFamily", "Arial");
vt.Factory.addGetterSetter(lt, "fontSize", 12, (0, ve.getNumberValidator)());
vt.Factory.addGetterSetter(lt, "fontStyle", jo);
vt.Factory.addGetterSetter(lt, "fontVariant", jo);
vt.Factory.addGetterSetter(lt, "padding", 0, (0, ve.getNumberValidator)());
vt.Factory.addGetterSetter(lt, "align", Xo);
vt.Factory.addGetterSetter(lt, "verticalAlign", Oc);
vt.Factory.addGetterSetter(lt, "lineHeight", 1, (0, ve.getNumberValidator)());
vt.Factory.addGetterSetter(lt, "wrap", zc);
vt.Factory.addGetterSetter(lt, "ellipsis", !1, (0, ve.getBooleanValidator)());
vt.Factory.addGetterSetter(lt, "letterSpacing", 0, (0, ve.getNumberValidator)());
vt.Factory.addGetterSetter(lt, "text", "", (0, ve.getStringValidator)());
vt.Factory.addGetterSetter(lt, "textDecoration", "");
var Zn = {};
Object.defineProperty(Zn, "__esModule", { value: !0 });
Zn.TextPath = void 0;
const Us = et, Lt = V, Xc = ft, xi = hi, Hs = Me, Qo = O, jc = $;
var qc = "", Ko = "normal";
function Zo(s) {
  s.fillText(this.partialText, 0, 0);
}
function Jo(s) {
  s.strokeText(this.partialText, 0, 0);
}
class gt extends Xc.Shape {
  constructor(t) {
    super(t), this.dummyCanvas = Us.Util.createCanvasElement(), this.dataArray = [], this._readDataAttribute(), this.on("dataChange.konva", function() {
      this._readDataAttribute(), this._setTextData();
    }), this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva", this._setTextData), this._setTextData();
  }
  _getTextPathLength() {
    return xi.Path.getPathLength(this.dataArray);
  }
  _getPointAtLength(t) {
    if (!this.attrs.data)
      return null;
    const e = this.pathLength;
    return t - 1 > e ? null : xi.Path.getPointAtLengthOfDataArray(t, this.dataArray);
  }
  _readDataAttribute() {
    this.dataArray = xi.Path.parsePathData(this.attrs.data), this.pathLength = this._getTextPathLength();
  }
  _sceneFunc(t) {
    t.setAttr("font", this._getContextFont()), t.setAttr("textBaseline", this.textBaseline()), t.setAttr("textAlign", "left"), t.save();
    var e = this.textDecoration(), i = this.fill(), n = this.fontSize(), r = this.glyphInfo;
    e === "underline" && t.beginPath();
    for (var a = 0; a < r.length; a++) {
      t.save();
      var o = r[a].p0;
      t.translate(o.x, o.y), t.rotate(r[a].rotation), this.partialText = r[a].text, t.fillStrokeShape(this), e === "underline" && (a === 0 && t.moveTo(0, n / 2 + 1), t.lineTo(n, n / 2 + 1)), t.restore();
    }
    e === "underline" && (t.strokeStyle = i, t.lineWidth = n / 20, t.stroke()), t.restore();
  }
  _hitFunc(t) {
    t.beginPath();
    var e = this.glyphInfo;
    if (e.length >= 1) {
      var i = e[0].p0;
      t.moveTo(i.x, i.y);
    }
    for (var n = 0; n < e.length; n++) {
      var r = e[n].p1;
      t.lineTo(r.x, r.y);
    }
    t.setAttr("lineWidth", this.fontSize()), t.setAttr("strokeStyle", this.colorKey), t.stroke();
  }
  getTextWidth() {
    return this.textWidth;
  }
  getTextHeight() {
    return Us.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."), this.textHeight;
  }
  setText(t) {
    return Hs.Text.prototype.setText.call(this, t);
  }
  _getContextFont() {
    return Hs.Text.prototype._getContextFont.call(this);
  }
  _getTextSize(t) {
    var e = this.dummyCanvas, i = e.getContext("2d");
    i.save(), i.font = this._getContextFont();
    var n = i.measureText(t);
    return i.restore(), {
      width: n.width,
      height: parseInt(`${this.fontSize()}`, 10)
    };
  }
  _setTextData() {
    const { width: t, height: e } = this._getTextSize(this.attrs.text);
    if (this.textWidth = t, this.textHeight = e, this.glyphInfo = [], !this.attrs.data)
      return null;
    const i = this.letterSpacing(), n = this.align(), r = this.kerningFunc(), a = Math.max(this.textWidth + ((this.attrs.text || "").length - 1) * i, 0);
    let o = 0;
    n === "center" && (o = Math.max(0, this.pathLength / 2 - a / 2)), n === "right" && (o = Math.max(0, this.pathLength - a));
    const h = (0, Hs.stringToArray)(this.text());
    let l = o;
    for (var A = 0; A < h.length; A++) {
      const u = this._getPointAtLength(l);
      if (!u)
        return;
      let f = this._getTextSize(h[A]).width + i;
      if (h[A] === " " && n === "justify") {
        const _ = this.text().split(" ").length - 1;
        f += (this.pathLength - a) / _;
      }
      const c = this._getPointAtLength(l + f);
      if (!c)
        return;
      const d = xi.Path.getLineLength(u.x, u.y, c.x, c.y);
      let p = 0;
      if (r)
        try {
          p = r(h[A - 1], h[A]) * this.fontSize();
        } catch {
          p = 0;
        }
      u.x += p, c.x += p, this.textWidth += p;
      const m = xi.Path.getPointOnLine(p + d / 2, u.x, u.y, c.x, c.y), v = Math.atan2(c.y - u.y, c.x - u.x);
      this.glyphInfo.push({
        transposeX: m.x,
        transposeY: m.y,
        text: h[A],
        rotation: v,
        p0: u,
        p1: c
      }), l += f;
    }
  }
  getSelfRect() {
    if (!this.glyphInfo.length)
      return {
        x: 0,
        y: 0,
        width: 0,
        height: 0
      };
    var t = [];
    this.glyphInfo.forEach(function(A) {
      t.push(A.p0.x), t.push(A.p0.y), t.push(A.p1.x), t.push(A.p1.y);
    });
    for (var e = t[0] || 0, i = t[0] || 0, n = t[1] || 0, r = t[1] || 0, a, o, h = 0; h < t.length / 2; h++)
      a = t[h * 2], o = t[h * 2 + 1], e = Math.min(e, a), i = Math.max(i, a), n = Math.min(n, o), r = Math.max(r, o);
    var l = this.fontSize();
    return {
      x: e - l / 2,
      y: n - l / 2,
      width: i - e + l,
      height: r - n + l
    };
  }
  destroy() {
    return Us.Util.releaseCanvas(this.dummyCanvas), super.destroy();
  }
}
Zn.TextPath = gt;
gt.prototype._fillFunc = Zo;
gt.prototype._strokeFunc = Jo;
gt.prototype._fillFuncHit = Zo;
gt.prototype._strokeFuncHit = Jo;
gt.prototype.className = "TextPath";
gt.prototype._attrsAffectingSize = ["text", "fontSize", "data"];
(0, jc._registerNode)(gt);
Lt.Factory.addGetterSetter(gt, "data");
Lt.Factory.addGetterSetter(gt, "fontFamily", "Arial");
Lt.Factory.addGetterSetter(gt, "fontSize", 12, (0, Qo.getNumberValidator)());
Lt.Factory.addGetterSetter(gt, "fontStyle", Ko);
Lt.Factory.addGetterSetter(gt, "align", "left");
Lt.Factory.addGetterSetter(gt, "letterSpacing", 0, (0, Qo.getNumberValidator)());
Lt.Factory.addGetterSetter(gt, "textBaseline", "middle");
Lt.Factory.addGetterSetter(gt, "fontVariant", Ko);
Lt.Factory.addGetterSetter(gt, "text", qc);
Lt.Factory.addGetterSetter(gt, "textDecoration", null);
Lt.Factory.addGetterSetter(gt, "kerningFunc", null);
var Jn = {};
Object.defineProperty(Jn, "__esModule", { value: !0 });
var th = Jn.Transformer = void 0;
const Z = et, Q = V, ka = rt, Qc = ft, Kc = Bi, Da = li, Dt = $, _e = O, Zc = $;
var eh = "tr-konva", Jc = [
  "resizeEnabledChange",
  "rotateAnchorOffsetChange",
  "rotateEnabledChange",
  "enabledAnchorsChange",
  "anchorSizeChange",
  "borderEnabledChange",
  "borderStrokeChange",
  "borderStrokeWidthChange",
  "borderDashChange",
  "anchorStrokeChange",
  "anchorStrokeWidthChange",
  "anchorFillChange",
  "anchorCornerRadiusChange",
  "ignoreStrokeChange",
  "anchorStyleFuncChange"
].map((s) => s + `.${eh}`).join(" "), Ia = "nodesRect", t0 = [
  "widthChange",
  "heightChange",
  "scaleXChange",
  "scaleYChange",
  "skewXChange",
  "skewYChange",
  "rotationChange",
  "offsetXChange",
  "offsetYChange",
  "transformsEnabledChange",
  "strokeWidthChange"
], e0 = {
  "top-left": -45,
  "top-center": 0,
  "top-right": 45,
  "middle-right": -90,
  "middle-left": 90,
  "bottom-left": -135,
  "bottom-center": 180,
  "bottom-right": 135
};
const i0 = "ontouchstart" in Dt.Konva._global;
function n0(s, t, e) {
  if (s === "rotater")
    return e;
  t += Z.Util.degToRad(e0[s] || 0);
  var i = (Z.Util.radToDeg(t) % 360 + 360) % 360;
  return Z.Util._inRange(i, 315 + 22.5, 360) || Z.Util._inRange(i, 0, 22.5) ? "ns-resize" : Z.Util._inRange(i, 45 - 22.5, 45 + 22.5) ? "nesw-resize" : Z.Util._inRange(i, 90 - 22.5, 90 + 22.5) ? "ew-resize" : Z.Util._inRange(i, 135 - 22.5, 135 + 22.5) ? "nwse-resize" : Z.Util._inRange(i, 180 - 22.5, 180 + 22.5) ? "ns-resize" : Z.Util._inRange(i, 225 - 22.5, 225 + 22.5) ? "nesw-resize" : Z.Util._inRange(i, 270 - 22.5, 270 + 22.5) ? "ew-resize" : Z.Util._inRange(i, 315 - 22.5, 315 + 22.5) ? "nwse-resize" : (Z.Util.error("Transformer has unknown angle for cursor detection: " + i), "pointer");
}
var un = [
  "top-left",
  "top-center",
  "top-right",
  "middle-right",
  "middle-left",
  "bottom-left",
  "bottom-center",
  "bottom-right"
], Ta = 1e8;
function s0(s) {
  return {
    x: s.x + s.width / 2 * Math.cos(s.rotation) + s.height / 2 * Math.sin(-s.rotation),
    y: s.y + s.height / 2 * Math.cos(s.rotation) + s.width / 2 * Math.sin(s.rotation)
  };
}
function ih(s, t, e) {
  const i = e.x + (s.x - e.x) * Math.cos(t) - (s.y - e.y) * Math.sin(t), n = e.y + (s.x - e.x) * Math.sin(t) + (s.y - e.y) * Math.cos(t);
  return {
    ...s,
    rotation: s.rotation + t,
    x: i,
    y: n
  };
}
function r0(s, t) {
  const e = s0(s);
  return ih(s, t, e);
}
function a0(s, t, e) {
  let i = t;
  for (let n = 0; n < s.length; n++) {
    const r = Dt.Konva.getAngle(s[n]), a = Math.abs(r - t) % (Math.PI * 2);
    Math.min(a, Math.PI * 2 - a) < e && (i = r);
  }
  return i;
}
let ar = 0;
class Y extends Da.Group {
  constructor(t) {
    super(t), this._movingAnchorName = null, this._transforming = !1, this._createElements(), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this.update = this.update.bind(this), this.on(Jc, this.update), this.getNode() && this.update();
  }
  attachTo(t) {
    return this.setNode(t), this;
  }
  setNode(t) {
    return Z.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."), this.setNodes([t]);
  }
  getNode() {
    return this._nodes && this._nodes[0];
  }
  _getEventNamespace() {
    return eh + this._id;
  }
  setNodes(t = []) {
    this._nodes && this._nodes.length && this.detach();
    const e = t.filter((n) => n.isAncestorOf(this) ? (Z.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"), !1) : !0);
    this._nodes = t = e, t.length === 1 && this.useSingleNodeRotation() ? this.rotation(t[0].getAbsoluteRotation()) : this.rotation(0), this._nodes.forEach((n) => {
      const r = () => {
        this.nodes().length === 1 && this.useSingleNodeRotation() && this.rotation(this.nodes()[0].getAbsoluteRotation()), this._resetTransformCache(), !this._transforming && !this.isDragging() && this.update();
      }, a = n._attrsAffectingSize.map((o) => o + "Change." + this._getEventNamespace()).join(" ");
      n.on(a, r), n.on(t0.map((o) => o + `.${this._getEventNamespace()}`).join(" "), r), n.on(`absoluteTransformChange.${this._getEventNamespace()}`, r), this._proxyDrag(n);
    }), this._resetTransformCache();
    var i = !!this.findOne(".top-left");
    return i && this.update(), this;
  }
  _proxyDrag(t) {
    let e;
    t.on(`dragstart.${this._getEventNamespace()}`, (i) => {
      e = t.getAbsolutePosition(), !this.isDragging() && t !== this.findOne(".back") && this.startDrag(i, !1);
    }), t.on(`dragmove.${this._getEventNamespace()}`, (i) => {
      if (!e)
        return;
      const n = t.getAbsolutePosition(), r = n.x - e.x, a = n.y - e.y;
      this.nodes().forEach((o) => {
        if (o === t || o.isDragging())
          return;
        const h = o.getAbsolutePosition();
        o.setAbsolutePosition({
          x: h.x + r,
          y: h.y + a
        }), o.startDrag(i);
      }), e = null;
    });
  }
  getNodes() {
    return this._nodes || [];
  }
  getActiveAnchor() {
    return this._movingAnchorName;
  }
  detach() {
    this._nodes && this._nodes.forEach((t) => {
      t.off("." + this._getEventNamespace());
    }), this._nodes = [], this._resetTransformCache();
  }
  _resetTransformCache() {
    this._clearCache(Ia), this._clearCache("transform"), this._clearSelfAndDescendantCache("absoluteTransform");
  }
  _getNodeRect() {
    return this._getCache(Ia, this.__getNodeRect);
  }
  __getNodeShape(t, e = this.rotation(), i) {
    var n = t.getClientRect({
      skipTransform: !0,
      skipShadow: !0,
      skipStroke: this.ignoreStroke()
    }), r = t.getAbsoluteScale(i), a = t.getAbsolutePosition(i), o = n.x * r.x - t.offsetX() * r.x, h = n.y * r.y - t.offsetY() * r.y;
    const l = (Dt.Konva.getAngle(t.getAbsoluteRotation()) + Math.PI * 2) % (Math.PI * 2), A = {
      x: a.x + o * Math.cos(l) + h * Math.sin(-l),
      y: a.y + h * Math.cos(l) + o * Math.sin(l),
      width: n.width * r.x,
      height: n.height * r.y,
      rotation: l
    };
    return ih(A, -Dt.Konva.getAngle(e), {
      x: 0,
      y: 0
    });
  }
  __getNodeRect() {
    var t = this.getNode();
    if (!t)
      return {
        x: -Ta,
        y: -Ta,
        width: 0,
        height: 0,
        rotation: 0
      };
    const e = [];
    this.nodes().map((l) => {
      const A = l.getClientRect({
        skipTransform: !0,
        skipShadow: !0,
        skipStroke: this.ignoreStroke()
      });
      var u = [
        { x: A.x, y: A.y },
        { x: A.x + A.width, y: A.y },
        { x: A.x + A.width, y: A.y + A.height },
        { x: A.x, y: A.y + A.height }
      ], f = l.getAbsoluteTransform();
      u.forEach(function(c) {
        var d = f.point(c);
        e.push(d);
      });
    });
    const i = new Z.Transform();
    i.rotate(-Dt.Konva.getAngle(this.rotation()));
    var n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0;
    e.forEach(function(l) {
      var A = i.point(l);
      n === void 0 && (n = a = A.x, r = o = A.y), n = Math.min(n, A.x), r = Math.min(r, A.y), a = Math.max(a, A.x), o = Math.max(o, A.y);
    }), i.invert();
    const h = i.point({ x: n, y: r });
    return {
      x: h.x,
      y: h.y,
      width: a - n,
      height: o - r,
      rotation: Dt.Konva.getAngle(this.rotation())
    };
  }
  getX() {
    return this._getNodeRect().x;
  }
  getY() {
    return this._getNodeRect().y;
  }
  getWidth() {
    return this._getNodeRect().width;
  }
  getHeight() {
    return this._getNodeRect().height;
  }
  _createElements() {
    this._createBack(), un.forEach((t) => {
      this._createAnchor(t);
    }), this._createAnchor("rotater");
  }
  _createAnchor(t) {
    var e = new Kc.Rect({
      stroke: "rgb(0, 161, 255)",
      fill: "white",
      strokeWidth: 1,
      name: t + " _anchor",
      dragDistance: 0,
      draggable: !0,
      hitStrokeWidth: i0 ? 10 : "auto"
    }), i = this;
    e.on("mousedown touchstart", function(n) {
      i._handleMouseDown(n);
    }), e.on("dragstart", (n) => {
      e.stopDrag(), n.cancelBubble = !0;
    }), e.on("dragend", (n) => {
      n.cancelBubble = !0;
    }), e.on("mouseenter", () => {
      var n = Dt.Konva.getAngle(this.rotation()), r = this.rotateAnchorCursor(), a = n0(t, n, r);
      e.getStage().content && (e.getStage().content.style.cursor = a), this._cursorChange = !0;
    }), e.on("mouseout", () => {
      e.getStage().content && (e.getStage().content.style.cursor = ""), this._cursorChange = !1;
    }), this.add(e);
  }
  _createBack() {
    var t = new Qc.Shape({
      name: "back",
      width: 0,
      height: 0,
      draggable: !0,
      sceneFunc(e, i) {
        var n = i.getParent(), r = n.padding();
        e.beginPath(), e.rect(-r, -r, i.width() + r * 2, i.height() + r * 2), e.moveTo(i.width() / 2, -r), n.rotateEnabled() && n.rotateLineVisible() && e.lineTo(i.width() / 2, -n.rotateAnchorOffset() * Z.Util._sign(i.height()) - r), e.fillStrokeShape(i);
      },
      hitFunc: (e, i) => {
        if (this.shouldOverdrawWholeArea()) {
          var n = this.padding();
          e.beginPath(), e.rect(-n, -n, i.width() + n * 2, i.height() + n * 2), e.fillStrokeShape(i);
        }
      }
    });
    this.add(t), this._proxyDrag(t), t.on("dragstart", (e) => {
      e.cancelBubble = !0;
    }), t.on("dragmove", (e) => {
      e.cancelBubble = !0;
    }), t.on("dragend", (e) => {
      e.cancelBubble = !0;
    }), this.on("dragmove", (e) => {
      this.update();
    });
  }
  _handleMouseDown(t) {
    this._movingAnchorName = t.target.name().split(" ")[0];
    var e = this._getNodeRect(), i = e.width, n = e.height, r = Math.sqrt(Math.pow(i, 2) + Math.pow(n, 2));
    this.sin = Math.abs(n / r), this.cos = Math.abs(i / r), typeof window < "u" && (window.addEventListener("mousemove", this._handleMouseMove), window.addEventListener("touchmove", this._handleMouseMove), window.addEventListener("mouseup", this._handleMouseUp, !0), window.addEventListener("touchend", this._handleMouseUp, !0)), this._transforming = !0;
    var a = t.target.getAbsolutePosition(), o = t.target.getStage().getPointerPosition();
    this._anchorDragOffset = {
      x: o.x - a.x,
      y: o.y - a.y
    }, ar++, this._fire("transformstart", { evt: t.evt, target: this.getNode() }), this._nodes.forEach((h) => {
      h._fire("transformstart", { evt: t.evt, target: h });
    });
  }
  _handleMouseMove(t) {
    var e, i, n, r = this.findOne("." + this._movingAnchorName), a = r.getStage();
    a.setPointersPositions(t);
    const o = a.getPointerPosition();
    let h = {
      x: o.x - this._anchorDragOffset.x,
      y: o.y - this._anchorDragOffset.y
    };
    const l = r.getAbsolutePosition();
    this.anchorDragBoundFunc() && (h = this.anchorDragBoundFunc()(l, h, t)), r.setAbsolutePosition(h);
    const A = r.getAbsolutePosition();
    if (!(l.x === A.x && l.y === A.y)) {
      if (this._movingAnchorName === "rotater") {
        var u = this._getNodeRect();
        e = r.x() - u.width / 2, i = -r.y() + u.height / 2;
        let F = Math.atan2(-i, e) + Math.PI / 2;
        u.height < 0 && (F -= Math.PI);
        var f = Dt.Konva.getAngle(this.rotation());
        const L = f + F, I = Dt.Konva.getAngle(this.rotationSnapTolerance()), T = a0(this.rotationSnaps(), L, I) - u.rotation, G = r0(u, T);
        this._fitNodesInto(G, t);
        return;
      }
      var c = this.shiftBehavior(), d;
      c === "inverted" ? d = this.keepRatio() && !t.shiftKey : c === "none" ? d = this.keepRatio() : d = this.keepRatio() || t.shiftKey;
      var g = this.centeredScaling() || t.altKey;
      if (this._movingAnchorName === "top-left") {
        if (d) {
          var p = g ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".bottom-right").x(),
            y: this.findOne(".bottom-right").y()
          };
          n = Math.sqrt(Math.pow(p.x - r.x(), 2) + Math.pow(p.y - r.y(), 2));
          var m = this.findOne(".top-left").x() > p.x ? -1 : 1, v = this.findOne(".top-left").y() > p.y ? -1 : 1;
          e = n * this.cos * m, i = n * this.sin * v, this.findOne(".top-left").x(p.x - e), this.findOne(".top-left").y(p.y - i);
        }
      } else if (this._movingAnchorName === "top-center")
        this.findOne(".top-left").y(r.y());
      else if (this._movingAnchorName === "top-right") {
        if (d) {
          var p = g ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".bottom-left").x(),
            y: this.findOne(".bottom-left").y()
          };
          n = Math.sqrt(Math.pow(r.x() - p.x, 2) + Math.pow(p.y - r.y(), 2));
          var m = this.findOne(".top-right").x() < p.x ? -1 : 1, v = this.findOne(".top-right").y() > p.y ? -1 : 1;
          e = n * this.cos * m, i = n * this.sin * v, this.findOne(".top-right").x(p.x + e), this.findOne(".top-right").y(p.y - i);
        }
        var _ = r.position();
        this.findOne(".top-left").y(_.y), this.findOne(".bottom-right").x(_.x);
      } else if (this._movingAnchorName === "middle-left")
        this.findOne(".top-left").x(r.x());
      else if (this._movingAnchorName === "middle-right")
        this.findOne(".bottom-right").x(r.x());
      else if (this._movingAnchorName === "bottom-left") {
        if (d) {
          var p = g ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".top-right").x(),
            y: this.findOne(".top-right").y()
          };
          n = Math.sqrt(Math.pow(p.x - r.x(), 2) + Math.pow(r.y() - p.y, 2));
          var m = p.x < r.x() ? -1 : 1, v = r.y() < p.y ? -1 : 1;
          e = n * this.cos * m, i = n * this.sin * v, r.x(p.x - e), r.y(p.y + i);
        }
        _ = r.position(), this.findOne(".top-left").x(_.x), this.findOne(".bottom-right").y(_.y);
      } else if (this._movingAnchorName === "bottom-center")
        this.findOne(".bottom-right").y(r.y());
      else if (this._movingAnchorName === "bottom-right") {
        if (d) {
          var p = g ? {
            x: this.width() / 2,
            y: this.height() / 2
          } : {
            x: this.findOne(".top-left").x(),
            y: this.findOne(".top-left").y()
          };
          n = Math.sqrt(Math.pow(r.x() - p.x, 2) + Math.pow(r.y() - p.y, 2));
          var m = this.findOne(".bottom-right").x() < p.x ? -1 : 1, v = this.findOne(".bottom-right").y() < p.y ? -1 : 1;
          e = n * this.cos * m, i = n * this.sin * v, this.findOne(".bottom-right").x(p.x + e), this.findOne(".bottom-right").y(p.y + i);
        }
      } else
        console.error(new Error("Wrong position argument of selection resizer: " + this._movingAnchorName));
      var g = this.centeredScaling() || t.altKey;
      if (g) {
        var y = this.findOne(".top-left"), x = this.findOne(".bottom-right"), b = y.x(), C = y.y(), w = this.getWidth() - x.x(), E = this.getHeight() - x.y();
        x.move({
          x: -b,
          y: -C
        }), y.move({
          x: w,
          y: E
        });
      }
      var S = this.findOne(".top-left").getAbsolutePosition();
      e = S.x, i = S.y;
      var P = this.findOne(".bottom-right").x() - this.findOne(".top-left").x(), k = this.findOne(".bottom-right").y() - this.findOne(".top-left").y();
      this._fitNodesInto({
        x: e,
        y: i,
        width: P,
        height: k,
        rotation: Dt.Konva.getAngle(this.rotation())
      }, t);
    }
  }
  _handleMouseUp(t) {
    this._removeEvents(t);
  }
  getAbsoluteTransform() {
    return this.getTransform();
  }
  _removeEvents(t) {
    var e;
    if (this._transforming) {
      this._transforming = !1, typeof window < "u" && (window.removeEventListener("mousemove", this._handleMouseMove), window.removeEventListener("touchmove", this._handleMouseMove), window.removeEventListener("mouseup", this._handleMouseUp, !0), window.removeEventListener("touchend", this._handleMouseUp, !0));
      var i = this.getNode();
      ar--, this._fire("transformend", { evt: t, target: i }), (e = this.getLayer()) === null || e === void 0 || e.batchDraw(), i && this._nodes.forEach((n) => {
        var r;
        n._fire("transformend", { evt: t, target: n }), (r = n.getLayer()) === null || r === void 0 || r.batchDraw();
      }), this._movingAnchorName = null;
    }
  }
  _fitNodesInto(t, e) {
    var i = this._getNodeRect();
    const n = 1;
    if (Z.Util._inRange(t.width, -this.padding() * 2 - n, n)) {
      this.update();
      return;
    }
    if (Z.Util._inRange(t.height, -this.padding() * 2 - n, n)) {
      this.update();
      return;
    }
    var r = new Z.Transform();
    if (r.rotate(Dt.Konva.getAngle(this.rotation())), this._movingAnchorName && t.width < 0 && this._movingAnchorName.indexOf("left") >= 0) {
      const f = r.point({
        x: -this.padding() * 2,
        y: 0
      });
      t.x += f.x, t.y += f.y, t.width += this.padding() * 2, this._movingAnchorName = this._movingAnchorName.replace("left", "right"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y;
    } else if (this._movingAnchorName && t.width < 0 && this._movingAnchorName.indexOf("right") >= 0) {
      const f = r.point({
        x: this.padding() * 2,
        y: 0
      });
      this._movingAnchorName = this._movingAnchorName.replace("right", "left"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.width += this.padding() * 2;
    }
    if (this._movingAnchorName && t.height < 0 && this._movingAnchorName.indexOf("top") >= 0) {
      const f = r.point({
        x: 0,
        y: -this.padding() * 2
      });
      t.x += f.x, t.y += f.y, this._movingAnchorName = this._movingAnchorName.replace("top", "bottom"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.height += this.padding() * 2;
    } else if (this._movingAnchorName && t.height < 0 && this._movingAnchorName.indexOf("bottom") >= 0) {
      const f = r.point({
        x: 0,
        y: this.padding() * 2
      });
      this._movingAnchorName = this._movingAnchorName.replace("bottom", "top"), this._anchorDragOffset.x -= f.x, this._anchorDragOffset.y -= f.y, t.height += this.padding() * 2;
    }
    if (this.boundBoxFunc()) {
      const f = this.boundBoxFunc()(i, t);
      f ? t = f : Z.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!");
    }
    const a = 1e7, o = new Z.Transform();
    o.translate(i.x, i.y), o.rotate(i.rotation), o.scale(i.width / a, i.height / a);
    const h = new Z.Transform(), l = t.width / a, A = t.height / a;
    this.flipEnabled() === !1 ? (h.translate(t.x, t.y), h.rotate(t.rotation), h.translate(t.width < 0 ? t.width : 0, t.height < 0 ? t.height : 0), h.scale(Math.abs(l), Math.abs(A))) : (h.translate(t.x, t.y), h.rotate(t.rotation), h.scale(l, A));
    const u = h.multiply(o.invert());
    this._nodes.forEach((f) => {
      var c;
      const d = f.getParent().getAbsoluteTransform(), p = f.getTransform().copy();
      p.translate(f.offsetX(), f.offsetY());
      const m = new Z.Transform();
      m.multiply(d.copy().invert()).multiply(u).multiply(d).multiply(p);
      const v = m.decompose();
      f.setAttrs(v), (c = f.getLayer()) === null || c === void 0 || c.batchDraw();
    }), this.rotation(Z.Util._getRotation(t.rotation)), this._nodes.forEach((f) => {
      this._fire("transform", { evt: e, target: f }), f._fire("transform", { evt: e, target: f });
    }), this._resetTransformCache(), this.update(), this.getLayer().batchDraw();
  }
  forceUpdate() {
    this._resetTransformCache(), this.update();
  }
  _batchChangeChild(t, e) {
    this.findOne(t).setAttrs(e);
  }
  update() {
    var t, e = this._getNodeRect();
    this.rotation(Z.Util._getRotation(e.rotation));
    var i = e.width, n = e.height, r = this.enabledAnchors(), a = this.resizeEnabled(), o = this.padding(), h = this.anchorSize();
    const l = this.find("._anchor");
    l.forEach((u) => {
      u.setAttrs({
        width: h,
        height: h,
        offsetX: h / 2,
        offsetY: h / 2,
        stroke: this.anchorStroke(),
        strokeWidth: this.anchorStrokeWidth(),
        fill: this.anchorFill(),
        cornerRadius: this.anchorCornerRadius()
      });
    }), this._batchChangeChild(".top-left", {
      x: 0,
      y: 0,
      offsetX: h / 2 + o,
      offsetY: h / 2 + o,
      visible: a && r.indexOf("top-left") >= 0
    }), this._batchChangeChild(".top-center", {
      x: i / 2,
      y: 0,
      offsetY: h / 2 + o,
      visible: a && r.indexOf("top-center") >= 0
    }), this._batchChangeChild(".top-right", {
      x: i,
      y: 0,
      offsetX: h / 2 - o,
      offsetY: h / 2 + o,
      visible: a && r.indexOf("top-right") >= 0
    }), this._batchChangeChild(".middle-left", {
      x: 0,
      y: n / 2,
      offsetX: h / 2 + o,
      visible: a && r.indexOf("middle-left") >= 0
    }), this._batchChangeChild(".middle-right", {
      x: i,
      y: n / 2,
      offsetX: h / 2 - o,
      visible: a && r.indexOf("middle-right") >= 0
    }), this._batchChangeChild(".bottom-left", {
      x: 0,
      y: n,
      offsetX: h / 2 + o,
      offsetY: h / 2 - o,
      visible: a && r.indexOf("bottom-left") >= 0
    }), this._batchChangeChild(".bottom-center", {
      x: i / 2,
      y: n,
      offsetY: h / 2 - o,
      visible: a && r.indexOf("bottom-center") >= 0
    }), this._batchChangeChild(".bottom-right", {
      x: i,
      y: n,
      offsetX: h / 2 - o,
      offsetY: h / 2 - o,
      visible: a && r.indexOf("bottom-right") >= 0
    }), this._batchChangeChild(".rotater", {
      x: i / 2,
      y: -this.rotateAnchorOffset() * Z.Util._sign(n) - o,
      visible: this.rotateEnabled()
    }), this._batchChangeChild(".back", {
      width: i,
      height: n,
      visible: this.borderEnabled(),
      stroke: this.borderStroke(),
      strokeWidth: this.borderStrokeWidth(),
      dash: this.borderDash(),
      x: 0,
      y: 0
    });
    const A = this.anchorStyleFunc();
    A && l.forEach((u) => {
      A(u);
    }), (t = this.getLayer()) === null || t === void 0 || t.batchDraw();
  }
  isTransforming() {
    return this._transforming;
  }
  stopTransform() {
    if (this._transforming) {
      this._removeEvents();
      var t = this.findOne("." + this._movingAnchorName);
      t && t.stopDrag();
    }
  }
  destroy() {
    return this.getStage() && this._cursorChange && this.getStage().content && (this.getStage().content.style.cursor = ""), Da.Group.prototype.destroy.call(this), this.detach(), this._removeEvents(), this;
  }
  toObject() {
    return ka.Node.prototype.toObject.call(this);
  }
  clone(t) {
    var e = ka.Node.prototype.clone.call(this, t);
    return e;
  }
  getClientRect() {
    return this.nodes().length > 0 ? super.getClientRect() : { x: 0, y: 0, width: 0, height: 0 };
  }
}
th = Jn.Transformer = Y;
Y.isTransforming = () => ar > 0;
function o0(s) {
  return s instanceof Array || Z.Util.warn("enabledAnchors value should be an array"), s instanceof Array && s.forEach(function(t) {
    un.indexOf(t) === -1 && Z.Util.warn("Unknown anchor name: " + t + ". Available names are: " + un.join(", "));
  }), s || [];
}
Y.prototype.className = "Transformer";
(0, Zc._registerNode)(Y);
Q.Factory.addGetterSetter(Y, "enabledAnchors", un, o0);
Q.Factory.addGetterSetter(Y, "flipEnabled", !0, (0, _e.getBooleanValidator)());
Q.Factory.addGetterSetter(Y, "resizeEnabled", !0);
Q.Factory.addGetterSetter(Y, "anchorSize", 10, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "rotateEnabled", !0);
Q.Factory.addGetterSetter(Y, "rotateLineVisible", !0);
Q.Factory.addGetterSetter(Y, "rotationSnaps", []);
Q.Factory.addGetterSetter(Y, "rotateAnchorOffset", 50, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "rotateAnchorCursor", "crosshair");
Q.Factory.addGetterSetter(Y, "rotationSnapTolerance", 5, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "borderEnabled", !0);
Q.Factory.addGetterSetter(Y, "anchorStroke", "rgb(0, 161, 255)");
Q.Factory.addGetterSetter(Y, "anchorStrokeWidth", 1, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "anchorFill", "white");
Q.Factory.addGetterSetter(Y, "anchorCornerRadius", 0, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "borderStroke", "rgb(0, 161, 255)");
Q.Factory.addGetterSetter(Y, "borderStrokeWidth", 1, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "borderDash");
Q.Factory.addGetterSetter(Y, "keepRatio", !0);
Q.Factory.addGetterSetter(Y, "shiftBehavior", "default");
Q.Factory.addGetterSetter(Y, "centeredScaling", !1);
Q.Factory.addGetterSetter(Y, "ignoreStroke", !1);
Q.Factory.addGetterSetter(Y, "padding", 0, (0, _e.getNumberValidator)());
Q.Factory.addGetterSetter(Y, "node");
Q.Factory.addGetterSetter(Y, "nodes");
Q.Factory.addGetterSetter(Y, "boundBoxFunc");
Q.Factory.addGetterSetter(Y, "anchorDragBoundFunc");
Q.Factory.addGetterSetter(Y, "anchorStyleFunc");
Q.Factory.addGetterSetter(Y, "shouldOverdrawWholeArea", !1);
Q.Factory.addGetterSetter(Y, "useSingleNodeRotation", !0);
Q.Factory.backCompat(Y, {
  lineEnabled: "borderEnabled",
  rotateHandlerOffset: "rotateAnchorOffset",
  enabledHandlers: "enabledAnchors"
});
var ts = {};
Object.defineProperty(ts, "__esModule", { value: !0 });
ts.Wedge = void 0;
const es = V, h0 = ft, l0 = $, nh = O, A0 = $;
class ee extends h0.Shape {
  _sceneFunc(t) {
    t.beginPath(), t.arc(0, 0, this.radius(), 0, l0.Konva.getAngle(this.angle()), this.clockwise()), t.lineTo(0, 0), t.closePath(), t.fillStrokeShape(this);
  }
  getWidth() {
    return this.radius() * 2;
  }
  getHeight() {
    return this.radius() * 2;
  }
  setWidth(t) {
    this.radius(t / 2);
  }
  setHeight(t) {
    this.radius(t / 2);
  }
}
ts.Wedge = ee;
ee.prototype.className = "Wedge";
ee.prototype._centroid = !0;
ee.prototype._attrsAffectingSize = ["radius"];
(0, A0._registerNode)(ee);
es.Factory.addGetterSetter(ee, "radius", 0, (0, nh.getNumberValidator)());
es.Factory.addGetterSetter(ee, "angle", 0, (0, nh.getNumberValidator)());
es.Factory.addGetterSetter(ee, "clockwise", !1);
es.Factory.backCompat(ee, {
  angleDeg: "angle",
  getAngleDeg: "getAngle",
  setAngleDeg: "setAngle"
});
var is = {};
Object.defineProperty(is, "__esModule", { value: !0 });
is.Blur = void 0;
const La = V, c0 = rt, d0 = O;
function Ra() {
  this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null;
}
var u0 = [
  512,
  512,
  456,
  512,
  328,
  456,
  335,
  512,
  405,
  328,
  271,
  456,
  388,
  335,
  292,
  512,
  454,
  405,
  364,
  328,
  298,
  271,
  496,
  456,
  420,
  388,
  360,
  335,
  312,
  292,
  273,
  512,
  482,
  454,
  428,
  405,
  383,
  364,
  345,
  328,
  312,
  298,
  284,
  271,
  259,
  496,
  475,
  456,
  437,
  420,
  404,
  388,
  374,
  360,
  347,
  335,
  323,
  312,
  302,
  292,
  282,
  273,
  265,
  512,
  497,
  482,
  468,
  454,
  441,
  428,
  417,
  405,
  394,
  383,
  373,
  364,
  354,
  345,
  337,
  328,
  320,
  312,
  305,
  298,
  291,
  284,
  278,
  271,
  265,
  259,
  507,
  496,
  485,
  475,
  465,
  456,
  446,
  437,
  428,
  420,
  412,
  404,
  396,
  388,
  381,
  374,
  367,
  360,
  354,
  347,
  341,
  335,
  329,
  323,
  318,
  312,
  307,
  302,
  297,
  292,
  287,
  282,
  278,
  273,
  269,
  265,
  261,
  512,
  505,
  497,
  489,
  482,
  475,
  468,
  461,
  454,
  447,
  441,
  435,
  428,
  422,
  417,
  411,
  405,
  399,
  394,
  389,
  383,
  378,
  373,
  368,
  364,
  359,
  354,
  350,
  345,
  341,
  337,
  332,
  328,
  324,
  320,
  316,
  312,
  309,
  305,
  301,
  298,
  294,
  291,
  287,
  284,
  281,
  278,
  274,
  271,
  268,
  265,
  262,
  259,
  257,
  507,
  501,
  496,
  491,
  485,
  480,
  475,
  470,
  465,
  460,
  456,
  451,
  446,
  442,
  437,
  433,
  428,
  424,
  420,
  416,
  412,
  408,
  404,
  400,
  396,
  392,
  388,
  385,
  381,
  377,
  374,
  370,
  367,
  363,
  360,
  357,
  354,
  350,
  347,
  344,
  341,
  338,
  335,
  332,
  329,
  326,
  323,
  320,
  318,
  315,
  312,
  310,
  307,
  304,
  302,
  299,
  297,
  294,
  292,
  289,
  287,
  285,
  282,
  280,
  278,
  275,
  273,
  271,
  269,
  267,
  265,
  263,
  261,
  259
], f0 = [
  9,
  11,
  12,
  13,
  13,
  14,
  14,
  15,
  15,
  15,
  15,
  16,
  16,
  16,
  16,
  17,
  17,
  17,
  17,
  17,
  17,
  17,
  18,
  18,
  18,
  18,
  18,
  18,
  18,
  18,
  18,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  20,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  21,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  23,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24,
  24
];
function g0(s, t) {
  var e = s.data, i = s.width, n = s.height, r, a, o, h, l, A, u, f, c, d, p, m, v, _, g, y, x, b, C, w, E, S, P, k, F = t + t + 1, L = i - 1, I = n - 1, z = t + 1, T = z * (z + 1) / 2, G = new Ra(), H = null, R = G, N = null, q = null, it = u0[t], tt = f0[t];
  for (o = 1; o < F; o++)
    R = R.next = new Ra(), o === z && (H = R);
  for (R.next = G, u = A = 0, a = 0; a < n; a++) {
    for (y = x = b = C = f = c = d = p = 0, m = z * (w = e[A]), v = z * (E = e[A + 1]), _ = z * (S = e[A + 2]), g = z * (P = e[A + 3]), f += T * w, c += T * E, d += T * S, p += T * P, R = G, o = 0; o < z; o++)
      R.r = w, R.g = E, R.b = S, R.a = P, R = R.next;
    for (o = 1; o < z; o++)
      h = A + ((L < o ? L : o) << 2), f += (R.r = w = e[h]) * (k = z - o), c += (R.g = E = e[h + 1]) * k, d += (R.b = S = e[h + 2]) * k, p += (R.a = P = e[h + 3]) * k, y += w, x += E, b += S, C += P, R = R.next;
    for (N = G, q = H, r = 0; r < i; r++)
      e[A + 3] = P = p * it >> tt, P !== 0 ? (P = 255 / P, e[A] = (f * it >> tt) * P, e[A + 1] = (c * it >> tt) * P, e[A + 2] = (d * it >> tt) * P) : e[A] = e[A + 1] = e[A + 2] = 0, f -= m, c -= v, d -= _, p -= g, m -= N.r, v -= N.g, _ -= N.b, g -= N.a, h = u + ((h = r + t + 1) < L ? h : L) << 2, y += N.r = e[h], x += N.g = e[h + 1], b += N.b = e[h + 2], C += N.a = e[h + 3], f += y, c += x, d += b, p += C, N = N.next, m += w = q.r, v += E = q.g, _ += S = q.b, g += P = q.a, y -= w, x -= E, b -= S, C -= P, q = q.next, A += 4;
    u += i;
  }
  for (r = 0; r < i; r++) {
    for (x = b = C = y = c = d = p = f = 0, A = r << 2, m = z * (w = e[A]), v = z * (E = e[A + 1]), _ = z * (S = e[A + 2]), g = z * (P = e[A + 3]), f += T * w, c += T * E, d += T * S, p += T * P, R = G, o = 0; o < z; o++)
      R.r = w, R.g = E, R.b = S, R.a = P, R = R.next;
    for (l = i, o = 1; o <= t; o++)
      A = l + r << 2, f += (R.r = w = e[A]) * (k = z - o), c += (R.g = E = e[A + 1]) * k, d += (R.b = S = e[A + 2]) * k, p += (R.a = P = e[A + 3]) * k, y += w, x += E, b += S, C += P, R = R.next, o < I && (l += i);
    for (A = r, N = G, q = H, a = 0; a < n; a++)
      h = A << 2, e[h + 3] = P = p * it >> tt, P > 0 ? (P = 255 / P, e[h] = (f * it >> tt) * P, e[h + 1] = (c * it >> tt) * P, e[h + 2] = (d * it >> tt) * P) : e[h] = e[h + 1] = e[h + 2] = 0, f -= m, c -= v, d -= _, p -= g, m -= N.r, v -= N.g, _ -= N.b, g -= N.a, h = r + ((h = a + z) < I ? h : I) * i << 2, f += y += N.r = e[h], c += x += N.g = e[h + 1], d += b += N.b = e[h + 2], p += C += N.a = e[h + 3], N = N.next, m += w = q.r, v += E = q.g, _ += S = q.b, g += P = q.a, y -= w, x -= E, b -= S, C -= P, q = q.next, A += i;
  }
}
const p0 = function(t) {
  var e = Math.round(this.blurRadius());
  e > 0 && g0(t, e);
};
is.Blur = p0;
La.Factory.addGetterSetter(c0.Node, "blurRadius", 0, (0, d0.getNumberValidator)(), La.Factory.afterSetFilter);
var ns = {};
Object.defineProperty(ns, "__esModule", { value: !0 });
ns.Brighten = void 0;
const Oa = V, y0 = rt, m0 = O, v0 = function(s) {
  var t = this.brightness() * 255, e = s.data, i = e.length, n;
  for (n = 0; n < i; n += 4)
    e[n] += t, e[n + 1] += t, e[n + 2] += t;
};
ns.Brighten = v0;
Oa.Factory.addGetterSetter(y0.Node, "brightness", 0, (0, m0.getNumberValidator)(), Oa.Factory.afterSetFilter);
var ss = {};
Object.defineProperty(ss, "__esModule", { value: !0 });
ss.Contrast = void 0;
const Na = V, _0 = rt, x0 = O, b0 = function(s) {
  var t = Math.pow((this.contrast() + 100) / 100, 2), e = s.data, i = e.length, n = 150, r = 150, a = 150, o;
  for (o = 0; o < i; o += 4)
    n = e[o], r = e[o + 1], a = e[o + 2], n /= 255, n -= 0.5, n *= t, n += 0.5, n *= 255, r /= 255, r -= 0.5, r *= t, r += 0.5, r *= 255, a /= 255, a -= 0.5, a *= t, a += 0.5, a *= 255, n = n < 0 ? 0 : n > 255 ? 255 : n, r = r < 0 ? 0 : r > 255 ? 255 : r, a = a < 0 ? 0 : a > 255 ? 255 : a, e[o] = n, e[o + 1] = r, e[o + 2] = a;
};
ss.Contrast = b0;
Na.Factory.addGetterSetter(_0.Node, "contrast", 0, (0, x0.getNumberValidator)(), Na.Factory.afterSetFilter);
var rs = {};
Object.defineProperty(rs, "__esModule", { value: !0 });
rs.Emboss = void 0;
const ue = V, as = rt, w0 = et, sh = O, S0 = function(s) {
  var t = this.embossStrength() * 10, e = this.embossWhiteLevel() * 255, i = this.embossDirection(), n = this.embossBlend(), r = 0, a = 0, o = s.data, h = s.width, l = s.height, A = h * 4, u = l;
  switch (i) {
    case "top-left":
      r = -1, a = -1;
      break;
    case "top":
      r = -1, a = 0;
      break;
    case "top-right":
      r = -1, a = 1;
      break;
    case "right":
      r = 0, a = 1;
      break;
    case "bottom-right":
      r = 1, a = 1;
      break;
    case "bottom":
      r = 1, a = 0;
      break;
    case "bottom-left":
      r = 1, a = -1;
      break;
    case "left":
      r = 0, a = -1;
      break;
    default:
      w0.Util.error("Unknown emboss direction: " + i);
  }
  do {
    var f = (u - 1) * A, c = r;
    u + c < 1 && (c = 0), u + c > l && (c = 0);
    var d = (u - 1 + c) * h * 4, p = h;
    do {
      var m = f + (p - 1) * 4, v = a;
      p + v < 1 && (v = 0), p + v > h && (v = 0);
      var _ = d + (p - 1 + v) * 4, g = o[m] - o[_], y = o[m + 1] - o[_ + 1], x = o[m + 2] - o[_ + 2], b = g, C = b > 0 ? b : -b, w = y > 0 ? y : -y, E = x > 0 ? x : -x;
      if (w > C && (b = y), E > C && (b = x), b *= t, n) {
        var S = o[m] + b, P = o[m + 1] + b, k = o[m + 2] + b;
        o[m] = S > 255 ? 255 : S < 0 ? 0 : S, o[m + 1] = P > 255 ? 255 : P < 0 ? 0 : P, o[m + 2] = k > 255 ? 255 : k < 0 ? 0 : k;
      } else {
        var F = e - b;
        F < 0 ? F = 0 : F > 255 && (F = 255), o[m] = o[m + 1] = o[m + 2] = F;
      }
    } while (--p);
  } while (--u);
};
rs.Emboss = S0;
ue.Factory.addGetterSetter(as.Node, "embossStrength", 0.5, (0, sh.getNumberValidator)(), ue.Factory.afterSetFilter);
ue.Factory.addGetterSetter(as.Node, "embossWhiteLevel", 0.5, (0, sh.getNumberValidator)(), ue.Factory.afterSetFilter);
ue.Factory.addGetterSetter(as.Node, "embossDirection", "top-left", null, ue.Factory.afterSetFilter);
ue.Factory.addGetterSetter(as.Node, "embossBlend", !1, null, ue.Factory.afterSetFilter);
var os = {};
Object.defineProperty(os, "__esModule", { value: !0 });
os.Enhance = void 0;
const Ga = V, C0 = rt, M0 = O;
function Vs(s, t, e, i, n) {
  var r = e - t, a = n - i, o;
  return r === 0 ? i + a / 2 : a === 0 ? i : (o = (s - t) / r, o = a * o + i, o);
}
const P0 = function(s) {
  var t = s.data, e = t.length, i = t[0], n = i, r, a = t[1], o = a, h, l = t[2], A = l, u, f, c = this.enhance();
  if (c !== 0) {
    for (f = 0; f < e; f += 4)
      r = t[f + 0], r < i ? i = r : r > n && (n = r), h = t[f + 1], h < a ? a = h : h > o && (o = h), u = t[f + 2], u < l ? l = u : u > A && (A = u);
    n === i && (n = 255, i = 0), o === a && (o = 255, a = 0), A === l && (A = 255, l = 0);
    var d, p, m, v, _, g, y, x, b;
    for (c > 0 ? (p = n + c * (255 - n), m = i - c * (i - 0), _ = o + c * (255 - o), g = a - c * (a - 0), x = A + c * (255 - A), b = l - c * (l - 0)) : (d = (n + i) * 0.5, p = n + c * (n - d), m = i + c * (i - d), v = (o + a) * 0.5, _ = o + c * (o - v), g = a + c * (a - v), y = (A + l) * 0.5, x = A + c * (A - y), b = l + c * (l - y)), f = 0; f < e; f += 4)
      t[f + 0] = Vs(t[f + 0], i, n, m, p), t[f + 1] = Vs(t[f + 1], a, o, g, _), t[f + 2] = Vs(t[f + 2], l, A, b, x);
  }
};
os.Enhance = P0;
Ga.Factory.addGetterSetter(C0.Node, "enhance", 0, (0, M0.getNumberValidator)(), Ga.Factory.afterSetFilter);
var hs = {};
Object.defineProperty(hs, "__esModule", { value: !0 });
hs.Grayscale = void 0;
const E0 = function(s) {
  var t = s.data, e = t.length, i, n;
  for (i = 0; i < e; i += 4)
    n = 0.34 * t[i] + 0.5 * t[i + 1] + 0.16 * t[i + 2], t[i] = n, t[i + 1] = n, t[i + 2] = n;
};
hs.Grayscale = E0;
var ls = {};
Object.defineProperty(ls, "__esModule", { value: !0 });
ls.HSL = void 0;
const ni = V, kr = rt, Dr = O;
ni.Factory.addGetterSetter(kr.Node, "hue", 0, (0, Dr.getNumberValidator)(), ni.Factory.afterSetFilter);
ni.Factory.addGetterSetter(kr.Node, "saturation", 0, (0, Dr.getNumberValidator)(), ni.Factory.afterSetFilter);
ni.Factory.addGetterSetter(kr.Node, "luminance", 0, (0, Dr.getNumberValidator)(), ni.Factory.afterSetFilter);
const F0 = function(s) {
  var t = s.data, e = t.length, i = 1, n = Math.pow(2, this.saturation()), r = Math.abs(this.hue() + 360) % 360, a = this.luminance() * 127, o, h = i * n * Math.cos(r * Math.PI / 180), l = i * n * Math.sin(r * Math.PI / 180), A = 0.299 * i + 0.701 * h + 0.167 * l, u = 0.587 * i - 0.587 * h + 0.33 * l, f = 0.114 * i - 0.114 * h - 0.497 * l, c = 0.299 * i - 0.299 * h - 0.328 * l, d = 0.587 * i + 0.413 * h + 0.035 * l, p = 0.114 * i - 0.114 * h + 0.293 * l, m = 0.299 * i - 0.3 * h + 1.25 * l, v = 0.587 * i - 0.586 * h - 1.05 * l, _ = 0.114 * i + 0.886 * h - 0.2 * l, g, y, x, b;
  for (o = 0; o < e; o += 4)
    g = t[o + 0], y = t[o + 1], x = t[o + 2], b = t[o + 3], t[o + 0] = A * g + u * y + f * x + a, t[o + 1] = c * g + d * y + p * x + a, t[o + 2] = m * g + v * y + _ * x + a, t[o + 3] = b;
};
ls.HSL = F0;
var As = {};
Object.defineProperty(As, "__esModule", { value: !0 });
As.HSV = void 0;
const si = V, Ir = rt, Tr = O, k0 = function(s) {
  var t = s.data, e = t.length, i = Math.pow(2, this.value()), n = Math.pow(2, this.saturation()), r = Math.abs(this.hue() + 360) % 360, a, o = i * n * Math.cos(r * Math.PI / 180), h = i * n * Math.sin(r * Math.PI / 180), l = 0.299 * i + 0.701 * o + 0.167 * h, A = 0.587 * i - 0.587 * o + 0.33 * h, u = 0.114 * i - 0.114 * o - 0.497 * h, f = 0.299 * i - 0.299 * o - 0.328 * h, c = 0.587 * i + 0.413 * o + 0.035 * h, d = 0.114 * i - 0.114 * o + 0.293 * h, p = 0.299 * i - 0.3 * o + 1.25 * h, m = 0.587 * i - 0.586 * o - 1.05 * h, v = 0.114 * i + 0.886 * o - 0.2 * h, _, g, y, x;
  for (a = 0; a < e; a += 4)
    _ = t[a + 0], g = t[a + 1], y = t[a + 2], x = t[a + 3], t[a + 0] = l * _ + A * g + u * y, t[a + 1] = f * _ + c * g + d * y, t[a + 2] = p * _ + m * g + v * y, t[a + 3] = x;
};
As.HSV = k0;
si.Factory.addGetterSetter(Ir.Node, "hue", 0, (0, Tr.getNumberValidator)(), si.Factory.afterSetFilter);
si.Factory.addGetterSetter(Ir.Node, "saturation", 0, (0, Tr.getNumberValidator)(), si.Factory.afterSetFilter);
si.Factory.addGetterSetter(Ir.Node, "value", 0, (0, Tr.getNumberValidator)(), si.Factory.afterSetFilter);
var cs = {};
Object.defineProperty(cs, "__esModule", { value: !0 });
cs.Invert = void 0;
const D0 = function(s) {
  var t = s.data, e = t.length, i;
  for (i = 0; i < e; i += 4)
    t[i] = 255 - t[i], t[i + 1] = 255 - t[i + 1], t[i + 2] = 255 - t[i + 2];
};
cs.Invert = D0;
var ds = {};
Object.defineProperty(ds, "__esModule", { value: !0 });
ds.Kaleidoscope = void 0;
const fn = V, rh = rt, Ba = et, ah = O;
var I0 = function(s, t, e) {
  var i = s.data, n = t.data, r = s.width, a = s.height, o = e.polarCenterX || r / 2, h = e.polarCenterY || a / 2, l, A, u, f = 0, c = 0, d = 0, p = 0, m, v = Math.sqrt(o * o + h * h);
  A = r - o, u = a - h, m = Math.sqrt(A * A + u * u), v = m > v ? m : v;
  var _ = a, g = r, y, x, b = 360 / g * Math.PI / 180, C, w;
  for (x = 0; x < g; x += 1)
    for (C = Math.sin(x * b), w = Math.cos(x * b), y = 0; y < _; y += 1)
      A = Math.floor(o + v * y / _ * w), u = Math.floor(h + v * y / _ * C), l = (u * r + A) * 4, f = i[l + 0], c = i[l + 1], d = i[l + 2], p = i[l + 3], l = (x + y * r) * 4, n[l + 0] = f, n[l + 1] = c, n[l + 2] = d, n[l + 3] = p;
}, T0 = function(s, t, e) {
  var i = s.data, n = t.data, r = s.width, a = s.height, o = e.polarCenterX || r / 2, h = e.polarCenterY || a / 2, l, A, u, f, c, d = 0, p = 0, m = 0, v = 0, _, g = Math.sqrt(o * o + h * h);
  A = r - o, u = a - h, _ = Math.sqrt(A * A + u * u), g = _ > g ? _ : g;
  var y = a, x = r, b, C, w = 0, E, S;
  for (A = 0; A < r; A += 1)
    for (u = 0; u < a; u += 1)
      f = A - o, c = u - h, b = Math.sqrt(f * f + c * c) * y / g, C = (Math.atan2(c, f) * 180 / Math.PI + 360 + w) % 360, C = C * x / 360, E = Math.floor(C), S = Math.floor(b), l = (S * r + E) * 4, d = i[l + 0], p = i[l + 1], m = i[l + 2], v = i[l + 3], l = (u * r + A) * 4, n[l + 0] = d, n[l + 1] = p, n[l + 2] = m, n[l + 3] = v;
};
const L0 = function(s) {
  var t = s.width, e = s.height, i, n, r, a, o, h, l, A, u, f, c = Math.round(this.kaleidoscopePower()), d = Math.round(this.kaleidoscopeAngle()), p = Math.floor(t * (d % 360) / 360);
  if (!(c < 1)) {
    var m = Ba.Util.createCanvasElement();
    m.width = t, m.height = e;
    var v = m.getContext("2d").getImageData(0, 0, t, e);
    Ba.Util.releaseCanvas(m), I0(s, v, {
      polarCenterX: t / 2,
      polarCenterY: e / 2
    });
    for (var _ = t / Math.pow(2, c); _ <= 8; )
      _ = _ * 2, c -= 1;
    _ = Math.ceil(_);
    var g = _, y = 0, x = g, b = 1;
    for (p + _ > t && (y = g, x = 0, b = -1), n = 0; n < e; n += 1)
      for (i = y; i !== x; i += b)
        r = Math.round(i + p) % t, u = (t * n + r) * 4, o = v.data[u + 0], h = v.data[u + 1], l = v.data[u + 2], A = v.data[u + 3], f = (t * n + i) * 4, v.data[f + 0] = o, v.data[f + 1] = h, v.data[f + 2] = l, v.data[f + 3] = A;
    for (n = 0; n < e; n += 1)
      for (g = Math.floor(_), a = 0; a < c; a += 1) {
        for (i = 0; i < g + 1; i += 1)
          u = (t * n + i) * 4, o = v.data[u + 0], h = v.data[u + 1], l = v.data[u + 2], A = v.data[u + 3], f = (t * n + g * 2 - i - 1) * 4, v.data[f + 0] = o, v.data[f + 1] = h, v.data[f + 2] = l, v.data[f + 3] = A;
        g *= 2;
      }
    T0(v, s, { polarRotation: 0 });
  }
};
ds.Kaleidoscope = L0;
fn.Factory.addGetterSetter(rh.Node, "kaleidoscopePower", 2, (0, ah.getNumberValidator)(), fn.Factory.afterSetFilter);
fn.Factory.addGetterSetter(rh.Node, "kaleidoscopeAngle", 0, (0, ah.getNumberValidator)(), fn.Factory.afterSetFilter);
var us = {};
Object.defineProperty(us, "__esModule", { value: !0 });
us.Mask = void 0;
const za = V, R0 = rt, O0 = O;
function sn(s, t, e) {
  var i = (e * s.width + t) * 4, n = [];
  return n.push(s.data[i++], s.data[i++], s.data[i++], s.data[i++]), n;
}
function bi(s, t) {
  return Math.sqrt(Math.pow(s[0] - t[0], 2) + Math.pow(s[1] - t[1], 2) + Math.pow(s[2] - t[2], 2));
}
function N0(s) {
  for (var t = [0, 0, 0], e = 0; e < s.length; e++)
    t[0] += s[e][0], t[1] += s[e][1], t[2] += s[e][2];
  return t[0] /= s.length, t[1] /= s.length, t[2] /= s.length, t;
}
function G0(s, t) {
  var e = sn(s, 0, 0), i = sn(s, s.width - 1, 0), n = sn(s, 0, s.height - 1), r = sn(s, s.width - 1, s.height - 1), a = t || 10;
  if (bi(e, i) < a && bi(i, r) < a && bi(r, n) < a && bi(n, e) < a) {
    for (var o = N0([i, e, r, n]), h = [], l = 0; l < s.width * s.height; l++) {
      var A = bi(o, [
        s.data[l * 4],
        s.data[l * 4 + 1],
        s.data[l * 4 + 2]
      ]);
      h[l] = A < a ? 0 : 255;
    }
    return h;
  }
}
function B0(s, t) {
  for (var e = 0; e < s.width * s.height; e++)
    s.data[4 * e + 3] = t[e];
}
function z0(s, t, e) {
  for (var i = [1, 1, 1, 1, 0, 1, 1, 1, 1], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
    for (var h = 0; h < t; h++) {
      for (var l = o * t + h, A = 0, u = 0; u < n; u++)
        for (var f = 0; f < n; f++) {
          var c = o + u - r, d = h + f - r;
          if (c >= 0 && c < e && d >= 0 && d < t) {
            var p = c * t + d, m = i[u * n + f];
            A += s[p] * m;
          }
        }
      a[l] = A === 255 * 8 ? 255 : 0;
    }
  return a;
}
function U0(s, t, e) {
  for (var i = [1, 1, 1, 1, 1, 1, 1, 1, 1], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
    for (var h = 0; h < t; h++) {
      for (var l = o * t + h, A = 0, u = 0; u < n; u++)
        for (var f = 0; f < n; f++) {
          var c = o + u - r, d = h + f - r;
          if (c >= 0 && c < e && d >= 0 && d < t) {
            var p = c * t + d, m = i[u * n + f];
            A += s[p] * m;
          }
        }
      a[l] = A >= 255 * 4 ? 255 : 0;
    }
  return a;
}
function H0(s, t, e) {
  for (var i = [0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111, 0.1111111111111111], n = Math.round(Math.sqrt(i.length)), r = Math.floor(n / 2), a = [], o = 0; o < e; o++)
    for (var h = 0; h < t; h++) {
      for (var l = o * t + h, A = 0, u = 0; u < n; u++)
        for (var f = 0; f < n; f++) {
          var c = o + u - r, d = h + f - r;
          if (c >= 0 && c < e && d >= 0 && d < t) {
            var p = c * t + d, m = i[u * n + f];
            A += s[p] * m;
          }
        }
      a[l] = A;
    }
  return a;
}
const V0 = function(s) {
  var t = this.threshold(), e = G0(s, t);
  return e && (e = z0(e, s.width, s.height), e = U0(e, s.width, s.height), e = H0(e, s.width, s.height), B0(s, e)), s;
};
us.Mask = V0;
za.Factory.addGetterSetter(R0.Node, "threshold", 0, (0, O0.getNumberValidator)(), za.Factory.afterSetFilter);
var fs = {};
Object.defineProperty(fs, "__esModule", { value: !0 });
fs.Noise = void 0;
const Ua = V, $0 = rt, W0 = O, Y0 = function(s) {
  var t = this.noise() * 255, e = s.data, i = e.length, n = t / 2, r;
  for (r = 0; r < i; r += 4)
    e[r + 0] += n - 2 * n * Math.random(), e[r + 1] += n - 2 * n * Math.random(), e[r + 2] += n - 2 * n * Math.random();
};
fs.Noise = Y0;
Ua.Factory.addGetterSetter($0.Node, "noise", 0.2, (0, W0.getNumberValidator)(), Ua.Factory.afterSetFilter);
var gs = {};
Object.defineProperty(gs, "__esModule", { value: !0 });
gs.Pixelate = void 0;
const Ha = V, X0 = et, j0 = rt, q0 = O, Q0 = function(s) {
  var t = Math.ceil(this.pixelSize()), e = s.width, i = s.height, n, r, a, o, h, l, A, u = Math.ceil(e / t), f = Math.ceil(i / t), c, d, p, m, v, _, g, y = s.data;
  if (t <= 0) {
    X0.Util.error("pixelSize value can not be <= 0");
    return;
  }
  for (v = 0; v < u; v += 1)
    for (_ = 0; _ < f; _ += 1) {
      for (o = 0, h = 0, l = 0, A = 0, c = v * t, d = c + t, p = _ * t, m = p + t, g = 0, n = c; n < d; n += 1)
        if (!(n >= e))
          for (r = p; r < m; r += 1)
            r >= i || (a = (e * r + n) * 4, o += y[a + 0], h += y[a + 1], l += y[a + 2], A += y[a + 3], g += 1);
      for (o = o / g, h = h / g, l = l / g, A = A / g, n = c; n < d; n += 1)
        if (!(n >= e))
          for (r = p; r < m; r += 1)
            r >= i || (a = (e * r + n) * 4, y[a + 0] = o, y[a + 1] = h, y[a + 2] = l, y[a + 3] = A);
    }
};
gs.Pixelate = Q0;
Ha.Factory.addGetterSetter(j0.Node, "pixelSize", 8, (0, q0.getNumberValidator)(), Ha.Factory.afterSetFilter);
var ps = {};
Object.defineProperty(ps, "__esModule", { value: !0 });
ps.Posterize = void 0;
const Va = V, K0 = rt, Z0 = O, J0 = function(s) {
  var t = Math.round(this.levels() * 254) + 1, e = s.data, i = e.length, n = 255 / t, r;
  for (r = 0; r < i; r += 1)
    e[r] = Math.floor(e[r] / n) * n;
};
ps.Posterize = J0;
Va.Factory.addGetterSetter(K0.Node, "levels", 0.5, (0, Z0.getNumberValidator)(), Va.Factory.afterSetFilter);
var ys = {};
Object.defineProperty(ys, "__esModule", { value: !0 });
ys.RGB = void 0;
const gn = V, Lr = rt, td = O, ed = function(s) {
  var t = s.data, e = t.length, i = this.red(), n = this.green(), r = this.blue(), a, o;
  for (a = 0; a < e; a += 4)
    o = (0.34 * t[a] + 0.5 * t[a + 1] + 0.16 * t[a + 2]) / 255, t[a] = o * i, t[a + 1] = o * n, t[a + 2] = o * r, t[a + 3] = t[a + 3];
};
ys.RGB = ed;
gn.Factory.addGetterSetter(Lr.Node, "red", 0, function(s) {
  return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
});
gn.Factory.addGetterSetter(Lr.Node, "green", 0, function(s) {
  return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
});
gn.Factory.addGetterSetter(Lr.Node, "blue", 0, td.RGBComponent, gn.Factory.afterSetFilter);
var ms = {};
Object.defineProperty(ms, "__esModule", { value: !0 });
ms.RGBA = void 0;
const Ti = V, vs = rt, id = O, nd = function(s) {
  var t = s.data, e = t.length, i = this.red(), n = this.green(), r = this.blue(), a = this.alpha(), o, h;
  for (o = 0; o < e; o += 4)
    h = 1 - a, t[o] = i * a + t[o] * h, t[o + 1] = n * a + t[o + 1] * h, t[o + 2] = r * a + t[o + 2] * h;
};
ms.RGBA = nd;
Ti.Factory.addGetterSetter(vs.Node, "red", 0, function(s) {
  return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
});
Ti.Factory.addGetterSetter(vs.Node, "green", 0, function(s) {
  return this._filterUpToDate = !1, s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
});
Ti.Factory.addGetterSetter(vs.Node, "blue", 0, id.RGBComponent, Ti.Factory.afterSetFilter);
Ti.Factory.addGetterSetter(vs.Node, "alpha", 1, function(s) {
  return this._filterUpToDate = !1, s > 1 ? 1 : s < 0 ? 0 : s;
});
var _s = {};
Object.defineProperty(_s, "__esModule", { value: !0 });
_s.Sepia = void 0;
const sd = function(s) {
  var t = s.data, e = t.length, i, n, r, a;
  for (i = 0; i < e; i += 4)
    n = t[i + 0], r = t[i + 1], a = t[i + 2], t[i + 0] = Math.min(255, n * 0.393 + r * 0.769 + a * 0.189), t[i + 1] = Math.min(255, n * 0.349 + r * 0.686 + a * 0.168), t[i + 2] = Math.min(255, n * 0.272 + r * 0.534 + a * 0.131);
};
_s.Sepia = sd;
var xs = {};
Object.defineProperty(xs, "__esModule", { value: !0 });
xs.Solarize = void 0;
const rd = function(s) {
  var t = s.data, e = s.width, i = s.height, n = e * 4, r = i;
  do {
    var a = (r - 1) * n, o = e;
    do {
      var h = a + (o - 1) * 4, l = t[h], A = t[h + 1], u = t[h + 2];
      l > 127 && (l = 255 - l), A > 127 && (A = 255 - A), u > 127 && (u = 255 - u), t[h] = l, t[h + 1] = A, t[h + 2] = u;
    } while (--o);
  } while (--r);
};
xs.Solarize = rd;
var bs = {};
Object.defineProperty(bs, "__esModule", { value: !0 });
bs.Threshold = void 0;
const $a = V, ad = rt, od = O, hd = function(s) {
  var t = this.threshold() * 255, e = s.data, i = e.length, n;
  for (n = 0; n < i; n += 1)
    e[n] = e[n] < t ? 0 : 255;
};
bs.Threshold = hd;
$a.Factory.addGetterSetter(ad.Node, "threshold", 0.5, (0, od.getNumberValidator)(), $a.Factory.afterSetFilter);
Object.defineProperty(Gn, "__esModule", { value: !0 });
Gn.Konva = void 0;
const Wa = ko, ld = zn, Ad = Vn, cd = Cn, dd = Wn, ud = Yn, Ya = ii, fd = Gi, gd = hi, pd = Bi, yd = jn, md = qn, vd = Qn, _d = Kn, xd = Me, bd = Zn, wd = Jn, Sd = ts, Cd = is, Md = ns, Pd = ss, Ed = rs, Fd = os, kd = hs, Dd = ls, Id = As, Td = cs, Ld = ds, Rd = us, Od = fs, Nd = gs, Gd = ps, Bd = ys, zd = ms, Ud = _s, Hd = xs, Vd = bs;
Gn.Konva = Wa.Konva.Util._assign(Wa.Konva, {
  Arc: ld.Arc,
  Arrow: Ad.Arrow,
  Circle: cd.Circle,
  Ellipse: dd.Ellipse,
  Image: ud.Image,
  Label: Ya.Label,
  Tag: Ya.Tag,
  Line: fd.Line,
  Path: gd.Path,
  Rect: pd.Rect,
  RegularPolygon: yd.RegularPolygon,
  Ring: md.Ring,
  Sprite: vd.Sprite,
  Star: _d.Star,
  Text: xd.Text,
  TextPath: bd.TextPath,
  Transformer: wd.Transformer,
  Wedge: Sd.Wedge,
  Filters: {
    Blur: Cd.Blur,
    Brighten: Md.Brighten,
    Contrast: Pd.Contrast,
    Emboss: Ed.Emboss,
    Enhance: Fd.Enhance,
    Grayscale: kd.Grayscale,
    HSL: Dd.HSL,
    HSV: Id.HSV,
    Invert: Td.Invert,
    Kaleidoscope: Ld.Kaleidoscope,
    Mask: Rd.Mask,
    Noise: Od.Noise,
    Pixelate: Nd.Pixelate,
    Posterize: Gd.Posterize,
    RGB: Bd.RGB,
    RGBA: zd.RGBA,
    Sepia: Ud.Sepia,
    Solarize: Hd.Solarize,
    Threshold: Vd.Threshold
  }
});
var $d = xr.exports;
Object.defineProperty($d, "__esModule", { value: !0 });
const Wd = Gn;
xr.exports = Wd.Konva;
var Yd = xr.exports;
const Yt = /* @__PURE__ */ wh(Yd);
function Rr(s) {
  return { all: s = s || /* @__PURE__ */ new Map(), on: function(t, e) {
    var i = s.get(t);
    i ? i.push(e) : s.set(t, [e]);
  }, off: function(t, e) {
    var i = s.get(t);
    i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : s.set(t, []));
  }, emit: function(t, e) {
    var i = s.get(t);
    i && i.slice().map(function(n) {
      n(e);
    }), (i = s.get("*")) && i.slice().map(function(n) {
      n(t, e);
    });
  } };
}
class ie {
  constructor(t) {
    this.bus = Rr(), this.children = [], this.flush = "pre", this.isMounted = !1, this.name = t.name, this.teleport = t.teleport, this.props = t, this.attrib = t.reactive ? ti(t.attrib) : t.attrib, this.zIndex = t.zIndex || 0;
  }
  getShape() {
    return this.shape;
  }
  redraw() {
    this.diffRedraw(), this.children.forEach((t) => t.redraw());
  }
  setAttrib(t) {
    "id" in t && t.id !== this.attrib.id && (console.log(t, this.attrib, t.id, this.attrib.id), console.error("id 确定后无法更改")), t.id = this.attrib.id, this.props.reactive ? Nr(t) !== Nr(this.attrib) && (this.attrib = this.props.reactive ? ti(t) : t, this.bus.emit("updateAttrib"), this.initReactive()) : (this.attrib = t, this.diffRedraw());
  }
  initReactive(t = this.flush) {
    this.destoryReactive && this.destoryReactive();
    let e = !1;
    const i = Sn(
      () => {
        e || this.diffRedraw();
      },
      { flush: t }
    );
    return this.flush = t, () => {
      e = !0, i();
    };
  }
  init() {
    this.shape = this.initShape(), this.shape.id(this.name), this.bus.emit("created");
  }
  mount(t) {
    if (this.shape instanceof Ii.Stage)
      throw "stage 为顶级容器无法挂载";
    if (t && this.shape instanceof br && !(t instanceof Ii.Stage))
      throw console.log(this.name, t), "layer 只能挂载到 Stage";
    if (this.teleport && this.teleport === t)
      return;
    this.children.sort((i, n) => i.zIndex - n.zIndex);
    const e = t || this.parent.shape;
    if (e.add(this.shape), this.teleport = e, this.setZIndex(this.zIndex), this.props.reactive && (this.destoryReactive = this.initReactive()), qt) {
      let i = { ...this.attrib };
      ge(
        () => this.attrib.id,
        (n, r) => {
          n !== r && console.error("changeId", i, this.attrib, n, r);
        },
        { flush: "sync" }
      );
    }
  }
  mounted() {
    this.diffRedraw(), this.children.forEach((t) => t.mounted()), this.isMounted = !0, this.bus.emit("mounted");
  }
  setParent(t) {
    if (this.parent) {
      const e = this.parent.children.indexOf(this);
      ~e && this.parent.children.splice(e, 1);
    }
    this.parent = t, t && this.parent.children.push(this);
  }
  getLevelNdx(t = this.parent) {
    if (t) {
      const e = t.children;
      for (let i = e.length - 1; i >= 0; i--)
        if (e[i] !== this && e[i].zIndex <= this.zIndex)
          return i;
      return -1;
    }
    return null;
  }
  setZIndex(t) {
    this.zIndex = t;
    const e = this.getLevelNdx();
    if (e === null)
      return;
    const i = this.parent.children;
    if (i.indexOf(this) !== e + 1) {
      let l = this;
      for (let A = e + 1; A < i.length; A++) {
        const u = i[A];
        i[A] = l, l = u;
      }
    }
    const r = this.teleport, a = r.children, o = e === -1 ? 0 : a.indexOf(i[e].getShape()) + 1;
    if (a.indexOf(this.shape) !== o)
      if (o !== 0) {
        let l = this.shape;
        for (let A = o; A < a.length; A++) {
          const u = a[A];
          r.add(l), l.zIndex(A), l = u;
        }
      } else
        this.shape.zIndex(0);
  }
  enableDrag(t) {
    this.disableDrag(), this.dragDestory = vr(this.shape, t);
  }
  disableDrag() {
    this.dragDestory && this.dragDestory(), this.dragDestory = null;
  }
  enableActive(t) {
    this.disableActive(), this.activeDestory = _a(
      this.shape,
      {
        active: () => t(!0),
        bus: this.bus,
        common: () => t(!1)
      },
      "mouse-active"
    );
  }
  disableActive() {
    this.activeDestory && this.activeDestory(), this.activeDestory = null;
  }
  enableMouseAct(t) {
    this.disableMouseAct(), this.mouseActDestory = _a(
      this.shape,
      { ...t, bus: this.bus },
      "act-mouse"
    );
  }
  disableMouseAct() {
    this.mouseActDestory && this.mouseActDestory(), this.mouseActDestory = null;
  }
  visible(t) {
    this.shape.visible(t);
  }
  destory() {
    for (; this.children.length; )
      this.children[0].destory();
    if (this.setParent(null), this.destoryReactive && this.destoryReactive(), this.disableDrag(), this.disableActive(), this.disableMouseAct(), qt && console.log(this.name, "destory"), this.shape instanceof Yt.Group ? this.shape.destroyChildren() : this.shape.destroy(), this.parent) {
      const t = this.parent.children.indexOf(this);
      ~t && this.parent.children.splice(t, 1);
    }
    this.bus.emit("destroyed"), this.bus.off("*");
  }
  find(t) {
    for (const e of this.children) {
      if (e.name === t)
        return e;
      const i = e.find(t);
      if (i)
        return i;
    }
    return null;
  }
}
const yn = class yn extends ie {
  constructor(t) {
    t.zIndex = t.zIndex || 4, t.name = t.name || yn.namespace + t.attrib.id, super(t);
  }
  setConfig(t) {
    this.config = t;
  }
  initShape() {
    const t = new Yt.Label({
      opacity: 0.75,
      name: "label",
      listening: !1
    });
    t.add(
      new Yt.Tag({
        name: "tag",
        fill: "rgba(0, 0, 0, 0.8)",
        pointerDirection: "down",
        pointerWidth: 5,
        pointerHeight: 5,
        lineJoin: "round",
        shadowColor: "black",
        shadowBlur: 10,
        shadowOffsetX: 10,
        shadowOffsetY: 10,
        shadowOpacity: 0.5,
        listening: !1
      }),
      new Yt.Text({
        name: "text",
        text: "text",
        fontFamily: "Calibri",
        fontSize: 10,
        padding: 3,
        fill: "white",
        listening: !1
      })
    );
    const e = 8, i = new Nt({ name: "offset" });
    return i.add(t).add(
      new Yt.Arrow({
        name: "arrow-1",
        visible: !1,
        points: [0, 0],
        pointerLength: e,
        pointerWidth: e,
        fill: "black",
        stroke: "black",
        strokeWidth: 4,
        listening: !1
      }),
      new Yt.Arrow({
        name: "arrow-2",
        visible: !1,
        points: [0, 0],
        pointerLength: e,
        pointerWidth: e,
        fill: "black",
        stroke: "black",
        strokeWidth: 4,
        listening: !1
      })
    ), i;
  }
  diffRedraw() {
    const t = this.attrib.pointIds.map(
      (o) => this.config.points.find((h) => h.id === o)
    );
    if (t.some((o) => !o))
      return null;
    let e = !1;
    const i = [];
    for (const o of this.config.polygons)
      for (const h of o.lineIds) {
        const l = this.config.lines.find(({ id: A }) => A === h);
        l.pointIds.includes(this.attrib.pointIds[0]) && l.pointIds.includes(this.attrib.pointIds[1]) && (i.push(`${l.id} [${l.pointIds.join(",")}]`), e = e || l.pointIds[0] === this.attrib.pointIds[1]);
      }
    const n = [];
    t.forEach(({ x: o, y: h }, l) => {
      n[l * 2] = o, n[l * 2 + 1] = h;
    });
    let r = Gt(
      this.shape.findOne(".label"),
      [1, 1]
    );
    const a = de.radToDeg(GA(n, [0, 1]));
    this.shape.findOne(".label").x((n[0] + n[2]) / 2).y((n[1] + n[3]) / 2).scale({ x: r[0], y: r[1] }).rotation(a < 0 ? a + 90 : a - 90), this.shape.findOne(".arrow-1").x(n[2]).y(n[3]).scale({ x: r[0], y: r[1] }).rotation(a + 90).visible(!0), e ? this.shape.findOne(".arrow-2").x(n[0]).y(n[1]).rotation(a - 90).scale({ x: r[0], y: r[1] }).visible(!0) : this.shape.findOne(".arrow-2").visible(!1), this.shape.findOne(".text").text(i.join(" | "));
  }
};
yn.namespace = "line-helper";
let or = yn;
const mn = class mn extends ie {
  constructor(t) {
    t.zIndex = t.zIndex || 5, t.name = t.name || mn.namespace + t.attrib.id, super(t);
  }
  initShape() {
    const t = new Yt.Label({ opacity: 0.75, name: "label" });
    return t.add(
      new Yt.Tag({
        name: "tag",
        fill: "rgba(0, 0, 0, 0.8)",
        pointerDirection: "down",
        pointerWidth: 5,
        pointerHeight: 5,
        lineJoin: "round",
        shadowColor: "black",
        shadowBlur: 10,
        shadowOffsetX: 10,
        shadowOffsetY: 10,
        shadowOpacity: 0.5
      }),
      new Yt.Text({
        name: "text",
        text: `P${this.attrib.id}`,
        fontFamily: "Calibri",
        fontSize: 10,
        padding: 3,
        fill: "white"
      })
    ), t;
  }
  diffRedraw() {
    this.shape.x(this.attrib.x).y(this.attrib.y);
    const t = Gt(this.shape, [1, 1]);
    this.shape.scale({ x: t[0], y: t[0] });
  }
};
mn.namespace = "point-helper";
let hr = mn;
const vn = class vn extends ie {
  constructor(t) {
    t.zIndex = t.zIndex || Mt.zIndex, t.name = t.name || vn.namespace + t.attrib.id, super(t), this.actShapeFactory = On;
  }
  setActShapeFactory(t) {
    this.actShapeFactory = t;
  }
  initShape() {
    return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
  }
  diffRedraw() {
    this.actShape.setData([this.attrib.x, this.attrib.y]);
  }
  mounted() {
    super.mounted(), this.actShape.common(null);
  }
};
vn.namespace = "point";
let Tt = vn, ws = 0;
const Xd = (s) => ws = s, oh = (s) => (Math.max(1, ws, ...s.lines.map(({ id: t }) => Number(t))) + 1).toString(), hh = (s) => (Math.max(1, ws, ...s.points.map(({ id: t }) => Number(t))) + 1).toString(), lh = (s, t = []) => (Math.max(
  1,
  ws,
  ...s.polygons.map(({ id: e }) => Number(e)),
  ...t.map(Number)
) + 1).toString(), Pe = (s, t) => s.points.find((e) => e.id === t), _t = (s, t) => t ? t.map((e) => Pe(s, e)) : s.points, Ah = (s, t) => s.lines.filter(({ pointIds: e }) => e.includes(t)), jd = (s, t, e = !1) => s.lines.filter(({ pointIds: i }) => {
  let n = i.includes(t[0]) && i.includes(t[1]);
  return n || (e && (n = i.includes(t[1]) && i.includes(t[0])), n);
}), qd = (s, t) => Ah(s, t.id), wt = (s, t) => s.lines.find(({ id: e }) => e === t), ch = (s, t) => t.map((e) => wt(s, e)), pi = (s, t) => _t(s, wt(s, t).pointIds), y1 = (s) => s.lines.map((t) => _t(s, t.pointIds)), yi = (s, t) => s.polygons.find((e) => e.id === t), Qd = (s, t) => yi(s, t).lineIds.map(
  (e) => pi(s, e)
), dh = (s, t) => {
  const e = yi(s, t);
  return e ? e.lineIds.map(
    (i) => wt(s, i)
  ) : [];
}, m1 = (s, t) => s.lines.filter(({ pointIds: e }) => e.includes(t)).map((e) => pi(s, e.id)), uh = (s, t) => {
  const e = [];
  for (const i of s.polygons) {
    const n = i.lineIds.filter(
      (r) => wt(s, r).pointIds.includes(t)
    ).map((r) => pi(s, r));
    n.length && e.push({
      polygonId: i.id,
      lines: n
    });
  }
  return e;
}, v1 = (s, t) => s.polygons.filter((e) => e.lineIds.some(
  (i) => wt(s, i).pointIds.includes(t)
)), ri = (s, t) => {
  const e = yi(s, t);
  if (!e)
    return [];
  const { lineIds: i } = e, n = [];
  for (let r = 0; r < i.length; r++) {
    const a = wt(s, i[r]);
    n.push(Pe(s, a.pointIds[0])), r === i.length - 1 && n.push(Pe(s, a.pointIds[1]));
  }
  return n;
}, Si = (...s) => {
  const t = {};
  for (const e of s)
    for (const i in e)
      if (!t[i])
        t[i] = Object.fromEntries(
          Object.entries(e[i]).map(([n, r]) => [
            n,
            [...r]
          ])
        );
      else
        for (const n in e[i]) {
          if (!t[i][n]) {
            t[i][n] = [...e[i][n]];
            break;
          }
          const r = e[i][n], a = t[i][n];
          for (const o of r)
            a.every(({ id: h }) => h !== o.id) && a.push(o);
        }
  return t;
}, fh = (s, t) => s.lines.findIndex(
  ({ pointIds: e }) => e[0] === t[0] && e[1] === t[1]
), fe = (s, t) => {
  const e = {
    lineChange: { add: [] }
  };
  let i = fh(s, t);
  return ~i || (i = s.lines.push({
    id: oh(s),
    pointIds: [...t]
  }) - 1, e.lineChange.add.push(s.lines[i])), { line: s.lines[i], change: e };
}, ai = (s, t, e = !0) => {
  const i = {
    lineChange: { del: [] },
    pointChange: { del: [] }
  }, n = fh(s, t), r = s.lines[n];
  return ~n ? (s.polygons.every(
    ({ lineIds: o }) => !o.includes(r.id)
  ) && (s.lines.splice(n, 1), i.lineChange.del.push(r)), e && t.forEach((o) => {
    const h = s.points.findIndex(({ id: l }) => l === o);
    ~h && s.lines.every(({ pointIds: l }) => !l.includes(o)) && (i.pointChange.del.push(s.points[h]), s.points.splice(h, 1));
  }), { line: r, change: i }) : { change: i };
}, gh = (s, t) => {
  const e = s.polygons.findIndex(({ id: i }) => t === i);
  if (~e) {
    const i = s.polygons[e];
    s.polygons.splice(e, 1), i.lineIds.map(
      (r) => wt(s, r)
    ).forEach((r) => {
      ai(s, r.pointIds);
    });
  }
}, Xa = (s, t, e = !0) => {
  t = Array.isArray(t) ? t : [t];
  const i = {
    lineChange: {
      del: [],
      add: []
    },
    polygonChange: {
      update: [],
      del: []
    },
    pointChange: {
      del: []
    }
  };
  let n = 100;
  for (let r = 0; r < s.polygons.length; r++) {
    const a = s.polygons[r], o = a.lineIds;
    let h = o.length, l;
    for (let A = 0; A < h; A++) {
      const u = ch(s, o), f = u[A], c = t.includes(f.pointIds[0]), d = t.includes(f.pointIds[1]);
      if (!(c || d))
        continue;
      l = l || [...o];
      let p = A, m = null;
      if (d) {
        let v = A + 1;
        for (v; v < u.length; v++) {
          const _ = u[v].pointIds[1];
          if (!t.includes(_) && _ !== f.pointIds[0])
            break;
        }
        if (v !== u.length) {
          const _ = fe(s, [
            f.pointIds[0],
            u[v].pointIds[1]
          ]);
          i.lineChange.add.push(..._.change.lineChange.add), o[A] = _.line.id, m = _.line.id;
        }
      }
      if (~p) {
        const v = u[A].pointIds;
        m ? o.splice(A, 1, m) : (o.splice(A, 1), u.splice(A, 1), h--, A--);
        const _ = ai(
          s,
          v,
          e
        );
        if (i.lineChange.del.push(..._.change.lineChange.del), i.pointChange.del.push(..._.change.pointChange.del), n-- < 0)
          break;
      }
    }
    if (l) {
      const A = { ...a, lineIds: l };
      a.lineIds.length === 0 ? (s.polygons.splice(r--, 1), i.polygonChange.del.push(A)) : i.polygonChange.update.push({
        before: A,
        after: a
      });
    }
  }
  return e && t.forEach((r) => {
    if (!i.pointChange.del.some(({ id: a }) => a === r)) {
      const a = s.points.findIndex(({ id: o }) => o === r);
      ~a && (i.pointChange.del.push(s.points[a]), s.points.splice(a, 1));
    }
  }), i;
}, lr = (s, t, e) => {
  const i = {
    lineChange: {
      del: [],
      add: []
    },
    polygonChange: {
      update: []
    },
    pointChange: {
      add: [],
      del: []
    }
  };
  let n = null;
  const r = t.map((a) => a.id);
  if (r.includes(e))
    return { addedPoints: n, change: i };
  for (const a of s.polygons) {
    let o;
    for (let h = 0; h < a.lineIds.length; h++) {
      const l = wt(s, a.lineIds[h]);
      if (r.includes(l.pointIds[0]) && r.includes(l.pointIds[1])) {
        o = o || [...a.lineIds], n = n || [
          l.pointIds[0],
          e,
          l.pointIds[1]
        ];
        const A = fe(s, [
          l.pointIds[0],
          e
        ]), u = fe(s, [
          e,
          l.pointIds[1]
        ]);
        i.lineChange.add.push(
          ...A.change.lineChange.add,
          ...u.change.lineChange.add
        ), a.lineIds.splice(h, 1, A.line.id, u.line.id);
        const f = ai(s, l.pointIds);
        i.lineChange.del.push(...f.change.lineChange.del), i.pointChange.del.push(...f.change.pointChange.del);
      }
    }
    o && i.polygonChange.update.push({
      before: { ...a, lineIds: o },
      after: a
    });
  }
  return { addedPoints: n, change: i };
}, Ar = (s, t, e) => {
  const i = {
    pointChange: {
      del: []
    },
    lineChange: {
      del: [],
      add: [],
      update: []
    },
    polygonChange: {
      del: [],
      update: []
    }
  }, n = [];
  for (let r = 0; r < s.polygons.length; r++) {
    const a = s.polygons[r];
    let o;
    for (const h of t) {
      if (h === e)
        break;
      for (let l = 0; l < a.lineIds.length; l++) {
        const A = wt(s, a.lineIds[l]);
        let u = A.pointIds.indexOf(h);
        if (!~u)
          continue;
        o = o || [...a.lineIds];
        const f = [...A.pointIds];
        if (f[u] = e, f[0] === f[1])
          a.lineIds.splice(l, 1);
        else {
          const c = fe(s, f);
          a.lineIds[l] = c.line.id, i.lineChange.del.push(...c.change.lineChange.add);
        }
        n.push(A.pointIds), l--;
      }
      if (o) {
        const l = { ...a, lineIds: o };
        a.lineIds.length === 0 ? (i.polygonChange.del.push(l), s.polygons.splice(r--, 1), console.log("del polygon")) : i.polygonChange.update.push({
          before: l,
          after: a
        });
      }
    }
  }
  return n.forEach((r) => {
    const a = ai(s, r);
    i.lineChange.del.push(...a.change.lineChange.del), i.pointChange.del.push(...a.change.pointChange.del);
  }), i;
}, Kd = (s, t, e, i) => {
  const n = {
    lineChange: {
      update: [],
      add: []
    },
    polygonChange: {
      update: []
    }
  }, r = jd(
    s,
    t.map(({ id: h }) => h),
    !0
  );
  s.lines.forEach((h) => {
    let l = -1;
    if (r.includes(h) || !~(l = h.pointIds.indexOf(e)))
      return;
    const A = [...h.pointIds];
    A[l] = i, n.lineChange.update.push({
      before: { ...h, pointIds: [...h.pointIds] },
      after: { ...h, pointIds: [...A] }
    }), h.pointIds = A;
  });
  let a, o;
  for (const h of s.polygons) {
    let l;
    for (let A = 0; A < h.lineIds.length; A++) {
      if (!r.some(({ id: v }) => v === h.lineIds[A]))
        continue;
      const f = wt(s, h.lineIds[A]).pointIds.indexOf(e) === 1, c = ((f ? A + 1 : A - 1) + h.lineIds.length) % h.lineIds.length, d = wt(s, h.lineIds[c]);
      if (f ? d.pointIds[0] === e : d.pointIds[1] === e)
        continue;
      l = l || [...h.lineIds];
      let p;
      if (f) {
        if (!o) {
          const { line: v, change: _ } = fe(s, [
            e,
            i
          ]);
          _.lineChange.add.push(..._.lineChange.add), o = v;
        }
        p = o;
      } else {
        if (!a) {
          const { line: v, change: _ } = fe(s, [
            i,
            e
          ]);
          _.lineChange.add.push(..._.lineChange.add), a = v;
        }
        p = a;
      }
      const m = f ? A + 1 : A;
      h.lineIds.splice(m, 0, p.id);
    }
    l && n.polygonChange.update.push({
      before: { ...h, lineIds: l },
      after: h
    });
  }
  return { change: n };
}, _n = class _n extends ie {
  constructor(t) {
    t.zIndex = t.zIndex || je.zIndex, t.name = t.name || _n.namespace + t.attrib.id, super(t), this.actShapeFactory = ui;
  }
  setActShapeFactory(t) {
    this.actShapeFactory = t;
  }
  initShape() {
    return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
  }
  diffRedraw() {
    const t = this.getCoords();
    t.length ? this.actShape.setData(t) : console.error("line:", this.attrib, "找不到对应的点坐标", [
      ...this.config.points
    ]);
  }
  setConfig(t) {
    this.config = t;
  }
  getCoords() {
    const t = [], e = _t(this.config, this.attrib.pointIds);
    return e.some((i) => !i) || e.forEach(({ x: i, y: n }, r) => {
      t[r * 2] = i, t[r * 2 + 1] = n;
    }), t;
  }
  initReactive() {
    return super.initReactive("post");
  }
  mounted() {
    super.mounted(), this.actShape.common(null);
  }
};
_n.namespace = "line";
let Qt = _n;
const xn = class xn extends ie {
  constructor(t) {
    t.zIndex = t.zIndex || cn.zIndex, t.name = t.name || xn.namespace + t.attrib.id, super(t), this.actShapeFactory = Nn;
  }
  setActShapeFactory(t) {
    this.actShapeFactory = t;
  }
  initShape() {
    return this.actShape = this.actShapeFactory(this.attrib, this), this.actShape.shape;
  }
  diffRedraw() {
    this.actShape.setData(this.getCoords());
  }
  setConfig(t) {
    this.config = t;
  }
  getCoords() {
    const t = [], e = ri(this.config, this.attrib.id);
    return e.some((i) => !i) || e.forEach(({ x: i, y: n }, r) => {
      t[r * 2] = i, t[r * 2 + 1] = n;
    }), t;
  }
  mounted() {
    super.mounted(), this.actShape.common(null);
  }
};
xn.namespace = "polygon";
let Li = xn;
const bn = class bn extends ie {
  constructor(t) {
    t.name = t.name || bn.namespace + t.attrib.id, super(t);
  }
  initIncFactory() {
    this.incLinesFactory = Pt(
      Qt,
      this,
      (t) => {
        t.setConfig(this.attrib);
      }
    ), this.incPointsFactory = Pt(
      Tt,
      this
    ), this.incPolygonFactory = Pt(
      Li,
      this,
      (t) => {
        t.setConfig(this.attrib);
      }
    ), qt && (this.incLinesHelperFactory = Pt(
      or,
      this,
      (t) => {
        t.setConfig(this.attrib);
      }
    ), this.incPointsHelperFactory = Pt(
      hr,
      this
    ));
  }
  init() {
    this.initIncFactory(), super.init();
  }
  initShape() {
    return new Nt({ id: this.name });
  }
  getRedrawLines() {
    const t = [];
    for (let e = this.attrib.lines.length - 1; e >= 0; e--) {
      const i = this.attrib.lines[e];
      let n = 0;
      for (n = 0; n < e; n++) {
        const r = this.attrib.lines[n];
        if (r.pointIds.includes(i.pointIds[0]) && r.pointIds.includes(i.pointIds[1]))
          break;
      }
      e === n && t.push(i);
    }
    return t;
  }
  diffRedraw() {
    const t = this.getRedrawLines();
    qt && (this.incLinesHelperFactory(t), this.incPointsHelperFactory(this.attrib.points));
    const e = this.incPointsFactory(this.attrib.points), i = this.incLinesFactory(t), n = this.incPolygonFactory(
      this.attrib.polygons
    );
    return { lineEntityInc: i, pointEntityInc: e, polygonEntityInc: n };
  }
  initReactive() {
    return ge(
      () => ({
        pointIds: this.attrib.points.map(({ id: t }) => t),
        lineIds: this.attrib.lines.map(({ id: t }) => t)
      }),
      this.diffRedraw.bind(this),
      { immediate: !0, flush: "pre" }
    );
  }
};
bn.namespace = "whole-line";
let Ri = bn, jt;
const Zd = () => {
  const s = {}, t = {}, e = (n, r) => {
    s[n] = r, t[n] = r;
  }, i = (n) => {
    for (const r in s)
      s[r] = t[r] / n;
  };
  return e("WHOLE_LINE_POINT_EQ_DIST", 1e-3), e("WHOLE_LINE_POINT_MERGE_DIST", 10), e("WHOLE_LINE_POINT_CHECK_DIST", 500), {
    addConstant: e,
    updateConstantScale: i,
    use() {
      jt = s;
    },
    unuse() {
      jt === s && (jt = null);
    }
  };
}, Ze = (s, t) => {
  const e = "id" in t && t.id ? t.id : hh(s);
  if (s.points.some(({ id: i }) => i === e))
    return t;
  {
    const i = {
      ...t,
      id: e
    };
    return s.points.push(i), i;
  }
}, Jd = (s, t, e) => {
  const i = pi(s, t), n = Ui(
    i.flatMap(({ x: h, y: l }) => [h, l]),
    [e.x, e.y]
  ).point, r = Ze(s, {
    ...e,
    x: n[0],
    y: n[1]
  }), { change: a, addedPoints: o } = lr(
    s,
    i,
    r.id
  );
  return a.pointChange.add.push(r), { change: a, addedPoints: o };
}, tu = (s, t, e) => {
  const i = yi(s, t);
  return eu(
    s,
    t,
    i.lineIds[i.lineIds.length - 1],
    e
  );
}, eu = (s, t, e, i) => {
  const n = yi(s, t), r = pi(s, e), a = Ze(s, i);
  let { line: o, change: h } = fe(s, [
    r[1].id,
    a.id
  ]);
  return h = Si(h, {
    pointChange: {
      add: [a]
    },
    polygonChange: {
      update: [
        {
          before: { ...n, lineIds: [...n.lineIds] },
          after: {
            ...n,
            lineIds: [...n.lineIds, o.id]
          }
        }
      ]
    }
  }), n.lineIds.push(o.id), { line: o, change: h };
}, iu = (s) => {
  let t = Math.max(...s.points.map((e) => Number(e.id) || 0));
  return (e) => {
    const i = {
      ...e,
      id: (++t).toString()
    };
    return s.points.push(i), i;
  };
}, nu = (s) => {
  const t = (o) => [o[0].x, o[0].y, o[1].x, o[1].y].join("-"), e = {}, i = (o, h) => [t(o), t(h)].join("-"), n = {}, r = [], a = iu(s);
  return (o) => {
    let h;
    const l = t(o);
    if (h = e[l])
      return h;
    if (h = e[t([o[1], o[0]])])
      return h = [...h].reverse(), e[l] = h, h;
    h = [];
    const A = o;
    for (const f of s.polygons) {
      const c = Qd(s, f.id);
      for (const d of c) {
        const p = i(o, d), m = {
          polygonId: f.id,
          line: d
        };
        if (p in n)
          n[p] && h.push({
            passive: m,
            intersection: n[p]
          });
        else {
          const v = d, _ = wo(
            [A[0].x, A[0].y, A[1].x, A[1].y],
            [v[0].x, v[0].y, v[1].x, v[1].y],
            [xo.Intersect]
          );
          if (_) {
            qt && console.log("join split", A[0].id, A[1].id, v[0].id, v[1].id);
            let g = -1, y = Number.MAX_VALUE;
            for (let b = 0; b < r.length; b++) {
              const C = [r[b].x, r[b].y], w = Et(C, _);
              y > w && (g = b, y = w);
            }
            let x;
            y <= jt.WHOLE_LINE_POINT_EQ_DIST ? x = r[g] : (x = a({ x: _[0], y: _[1] }), console.log("add", x.id), r.push(x)), h.push({
              passive: m,
              intersection: x
            }), n[p] = x;
          } else
            n[p] = null;
        }
      }
    }
    const u = [A[0].x, A[0].y];
    return h.sort(
      (f, c) => Et([f.intersection.x, f.intersection.y], u) - Et([c.intersection.x, c.intersection.y], u)
    ), e[l] = h, h;
  };
}, ja = (s, t, e, i) => {
  const n = s.map(({ id: h }) => h);
  if (!(n.includes(e[0].id) && n.includes(e[1].id)))
    return s;
  let a = Number.MAX_VALUE, o = -1;
  for (let h = 1; h < i.length; h++) {
    const l = [i[h - 1], i[h]], A = zA(
      [l[0].x, l[0].y, l[1].x, l[1].y],
      [t.x, t.y]
    );
    A < a && (a = A, o = h);
  }
  return ~o ? s[0] === s[0] ? [i[o - 1], i[o]] : [i[o], i[o - 1]] : s;
}, su = (s, t) => {
  const e = nu(s), i = [];
  for (let n = 1; n < t.length; n++) {
    let r = 0;
    for (; r < n && !(t[n].includes(t[r][0]) && t[n].includes(t[r][1])); r++)
      ;
    r !== n && t.splice(n--, 1);
  }
  for (const n of t) {
    const r = e(n), a = n;
    r.forEach((o) => {
      const h = [...o.passive.line];
      i.some((A) => {
        if (o.intersection.id !== A.intersection.id)
          return !1;
        const u = [...A.passive], f = [...A.splitLine];
        return f.includes(a[0]) && f.includes(a[1]) && u.includes(h[0]) && u.includes(h[1]) || u.includes(a[0]) && u.includes(a[1]) && f.includes(h[0]) && f.includes(h[1]);
      }) || i.push({
        splitLine: n,
        passive: o.passive.line,
        intersection: o.intersection
      });
    });
  }
  for (let n = 0; n < i.length; n++) {
    const { passive: r, splitLine: a, intersection: o } = i[n], h = lr(
      s,
      a,
      o.id
    ).addedPoints, l = lr(
      s,
      r,
      o.id
    ).addedPoints;
    if (qt && (h || console.error(
      `添加 addedPointIds 失败， 
交点：`,
      o.id,
      `
 线段：`,
      a
    ), l || console.error(
      `添加 passiveAddedPointIds 失败， 
交点：`,
      o,
      `
线段：`,
      r
    )), !h && !l)
      continue;
    const A = h && _t(s, h), u = l && _t(s, l), f = (c, d) => {
      const p = c;
      return h && (c = ja(
        c,
        d,
        a,
        A
      )), l && (c = ja(
        c,
        d,
        r,
        u
      )), qt && p !== c && console.log(
        "fix line",
        p.map(({ id: m }) => m),
        `
after: ,`,
        c.map(({ id: m }) => m)
      ), c;
    };
    for (let c = n + 1; c < i.length; c++) {
      const d = i[c];
      d.passive = f(d.passive, d.intersection), d.splitLine = f(d.splitLine, d.intersection);
    }
  }
}, $s = (s, t) => su(
  s,
  uh(s, t).reduce((e, i) => (e.push(...i.lines), e), [])
), ru = (s, t) => {
  const e = [t], i = s.points.filter(
    (n) => !e.includes(n) && Et([n.x, n.y], [t.x, t.y]) < jt.WHOLE_LINE_POINT_MERGE_DIST
  );
  return i.length ? i.length > 1 ? {
    main: t,
    merges: i,
    mergeAfterPosition: [t.x, t.y]
  } : {
    main: i[0],
    merges: [t],
    mergeAfterPosition: [i[0].x, i[0].y]
  } : null;
}, au = (s, t) => {
  const e = ru(
    s,
    Pe(s, t)
  );
  if (!e)
    return;
  const i = Ar(
    s,
    e.merges.map(({ id: r }) => r),
    e.main.id
  ), n = Pe(s, e.main.id);
  return n && (n.x = e.mergeAfterPosition[0], n.y = e.mergeAfterPosition[1]), {
    info: e,
    change: i
  };
}, ou = (s, t, e, i = [10, 170]) => {
  const n = {}, r = t.pointIds, a = _t(s, [r[0], r[1]]), o = ce([
    a[0].x,
    a[0].y,
    a[1].x,
    a[1].y
  ]), h = _t(s, [r[1], r[0]]), l = ce([
    h[0].x,
    h[0].y,
    h[1].x,
    h[1].y
  ]), A = (u, f) => {
    let c = !0;
    const d = r[f];
    if (!n[d])
      n[d] = {};
    else
      return c = !1, { ...n[d], isFirst: c };
    const p = Ah(s, d).filter(
      (F) => !(F.pointIds.includes(r[0]) && F.pointIds.includes(r[1]))
    ), m = [], v = f === 0 ? o : l;
    let _ = Number.MAX_VALUE, g, y = null, x = -Number.MAX_VALUE, b, C = null;
    for (let { pointIds: F, id: L } of p) {
      F = [
        r[f],
        ...F.filter((G) => G !== r[f])
      ];
      const I = _t(s, F), z = ce([
        I[0].x,
        I[0].y,
        I[1].x,
        I[1].y
      ]);
      m.push(z);
      const T = Xe(v, z);
      T > 0 ? T < _ && (_ = T, g = L, y = z) : T > x && (x = T, b = L, C = z);
    }
    let w = null, E = null, S = null;
    !y || !C ? (w = y || C, S = y ? g : b, E = y ? _ : x) : Math.abs(Xe(u, y)) < Math.abs(Xe(u, C)) ? (w = y, S = g, E = _) : (w = C, S = b, E = x);
    let P = !1, k = Math.abs(de.radToDeg(E));
    if (w !== null && k > i[1] || k < i[0])
      console.log(
        "夹角不在范围，分割",
        S,
        f === 0 ? a : h,
        k
      ), S = null, w = mr(w), P = !0;
    else if (p.length > 1) {
      const F = w;
      for (let L = 0; L < p.length; L++) {
        if (F === m[L])
          continue;
        const I = (Xe(F, m[L]) + Math.PI) % Math.PI;
        if (Ot(I, 3) > 0) {
          console.log("方向不同，分割"), P = !0;
          break;
        }
      }
    }
    return n[d].refDire = w, n[d].lineDire = v, n[d].id = S, n[d].split = P, n[d].isFirst = c, n[d];
  };
  return (u) => {
    const f = new X(u[0], u[1]).normalize().toArray(), c = [
      A(f, 0),
      A(f, 1)
    ], d = [
      [e[0][0] + u[0], e[0][1] + u[1]],
      [e[1][0] + u[0], e[1][1] + u[1]]
    ], p = _t(s, t.pointIds);
    if (c[0].refDire || c[1].refDire) {
      const m = [], v = c.map(
        ({ refDire: S }) => S === null ? c[0].refDire || c[1].refDire : S
      );
      for (let S = 0; S < c.length; S++) {
        const P = v[S], k = c[S].split && c[S].isFirst, F = Ke(P, e[S], 10);
        if (k) {
          const L = hh(s);
          s.points.push({
            ...p[S],
            id: L
          }), Kd(
            s,
            a,
            t.pointIds[S],
            L
          );
        }
        m[S] = Ui(F, d[S]).point;
      }
      const _ = Et(m[0], e[0]) < Et(m[1], e[1]), g = _ ? o : l, y = _ ? m[0] : m[1], x = _ ? v[1] : v[0], b = _ ? e[1] : e[0], C = Ke(g, y, 10), w = Ke(x, b, 10), E = wo(C, w);
      _ ? (d[0] = y, d[1] = E) : (d[1] = y, d[0] = E);
    }
    p[0].x = d[0][0], p[0].y = d[0][1], p[1].x = d[1][0], p[1].y = d[1][1];
  };
}, Ws = (s) => {
  for (let e = 0; e < s.lines.length; e++) {
    const i = s.lines[e], n = _t(s, i.pointIds);
    if (Ot(
      Et([n[0].x, n[0].y], [n[1].x, n[1].y]),
      4
    ) !== 0)
      continue;
    const a = Ar(s, [n[1].id], n[0].id);
    e = Math.max(e - a.lineChange.del.length, 0);
  }
  const t = [];
  for (let e = 0; e < s.polygons.length; e++) {
    const i = s.polygons[e];
    for (let n = 0; n < i.lineIds.length; n++) {
      const r = wt(s, i.lineIds[n]), a = (n + 1) % i.lineIds.length, o = wt(s, i.lineIds[a]);
      if (r.pointIds[0] === o.pointIds[1] && r.pointIds[1] === o.pointIds[0]) {
        t.push(_t(s, r.pointIds)), n > a ? (i.lineIds.splice(n, 1), i.lineIds.splice(a, 1)) : (i.lineIds.splice(n, 2), n -= 1), ai(s, r.pointIds), ai(s, o.pointIds);
        continue;
      }
      const h = _t(s, r.pointIds);
      Et(
        [h[0].x, h[0].y],
        [h[1].x, h[1].y]
      ) < jt.WHOLE_LINE_POINT_MERGE_DIST && (Ar(s, [h[0].id], h[1].id), n--);
    }
    i.lineIds.length === 0 && (console.log("del polygon"), s.polygons.splice(e--, 1));
  }
  t.forEach((e) => {
    if (e[0].id === e[1].id)
      return;
    const i = lh(s), n = oh(s);
    e = e.map((r) => s.points.some(({ id: a }) => a === r.id) ? r : Ze(s, { x: r.x, y: r.y })), s.lines.push({
      id: n,
      pointIds: e.map(({ id: r }) => r)
    }), s.polygons.push({
      id: i,
      lineIds: [n]
    });
  });
}, hu = ({
  tree: s,
  position: t,
  refPointName: e = "adsord-point",
  exclusionIds: i = [],
  radius: n = 10
}) => {
  const r = s.stage.find(`.${e}`).filter((a) => !i.includes(a.id())).map((a) => {
    const o = a.position();
    return [o.x, o.y];
  });
  return lu({ refPositions: r, radius: n, position: t });
}, lu = ({
  position: s,
  radius: t = 10,
  refPositions: e
}) => {
  let i = null, n = Number.MAX_VALUE;
  for (const r of e) {
    const a = Et(r, s);
    a < t && a < n && (n = a, i = r);
  }
  return i;
}, wi = [0, 90, 180, 270, 360], ph = ({
  position: s,
  refLines: t,
  angle: e = 3
}) => {
  let i = null, n = null, r = !1;
  for (const a of t) {
    const h = [
      [a[0], a[1]],
      [a[2], a[3]]
    ].map((u) => (de.radToDeg(
      NA(a, [...u, ...s])
    ) + 360) % 360);
    let l = 0, A = 0;
    for (l = 0; l < h.length; l++) {
      for (A = 0; A < wi.length; A++) {
        const u = wi[A];
        if (h[l] >= u - e && h[l] <= u + e)
          break;
      }
      if (A !== wi.length)
        break;
    }
    if (A !== wi.length || l !== h.length) {
      n = a, i = wi[A];
      const u = RA(
        ce(n),
        de.degToRad(i)
      ), f = Et([n[0], n[1]], s) > Et([n[2], n[3]], s) ? [n[2], n[3]] : [n[0], n[1]];
      n = Ke(u, f, 10), s = Ui(n, s).point, r = !0;
    }
  }
  if (r)
    return s;
}, Au = ({
  position: s,
  angle: t,
  points: e
}) => {
  if (e != null && e.length && e.length === 1) {
    const i = e[0], n = [
      [i[0] - 1, i[1], i[0] + 1, i[1]],
      [i[0], i[1] - 1, i[0], i[1] + 1]
    ];
    return ph({ position: s, refLines: n, angle: t });
  }
}, qa = ({
  position: s,
  points: t,
  angle: e
}) => {
  if (!(t != null && t.length))
    return;
  const i = t.slice(0, 2).flatMap((o) => o), n = t.slice(t.length - 2, t.length).flatMap((o) => o), r = [
    i,
    // createLineByDire(getVerticaLineDire(last), [last[2], last[3]], 10),
    Ke(OA(n), [n[2], n[3]], 10)
  ];
  let a;
  if (a = ph({
    position: s,
    refLines: r,
    angle: e
  }))
    return a;
}, yh = (s) => {
  const t = s.position || s.tree.getRealFromStage(s.pixel);
  let e;
  if (e = hu({ ...s, position: t }))
    return e;
  if (e = Au({ ...s, position: t }))
    return e;
  if (e = qa({ ...s, position: t }))
    return e;
  if (s.pointsArray) {
    for (let i = 0; i < s.pointsArray.length; i++)
      if (e = qa({
        ...s,
        position: t,
        points: s.pointsArray[i]
      }))
        return e;
  }
  return t;
}, Qa = ({
  tree: s,
  config: t,
  polygonId: e,
  pointAttribFactory: i,
  quotePoint: n,
  canOper: r,
  autoAdd: a,
  adsorbRadius: o,
  canDelPoint: h,
  closeAutoQuit: l,
  changePolygon: A,
  autoClose: u
}) => {
  i = i || ((b) => ({
    x: b[0],
    y: b[1]
  }));
  const f = (b) => {
    if (b)
      return t.polygons.find(({ id: C }) => C === b);
    {
      const C = lh(t);
      return t.polygons.push({
        id: C,
        lineIds: []
      }), t.polygons[t.polygons.length - 1];
    }
  };
  let c, d = !1, p = null, m = !0;
  const v = (b) => {
    if (c = f(b), !c)
      throw `${b}的多边形不存在！`;
    A && A(c.id), e = c.id, d = !b, p = null, m = a || c.lineIds.length < 2;
  };
  v(e);
  const _ = () => {
    const b = t.polygons.indexOf(c);
    ~b && t.polygons.splice(b, 1);
  }, g = (b) => {
    let C = {
      lineChange: {
        del: [],
        update: [],
        add: []
      },
      polygonChange: {
        add: [],
        update: [],
        del: []
      },
      pointChange: {
        add: [],
        del: []
      }
    };
    const w = Po(b.target, (T) => {
      const G = T.id();
      return G.includes(Qt.namespace) || G.includes(Tt.namespace);
    });
    let E = w && s.find(w.id());
    const S = [b.evt.offsetX, b.evt.offsetY];
    if (console.log(E), E instanceof Qt && (!r || r(E, b.target)) && c.lineIds.includes(E.attrib.id)) {
      const { change: T } = Jd(
        t,
        E.attrib.id,
        i(s.getRealFromStage(S))
      );
      return { change: Si(C, T), isClose: !1 };
    }
    let P;
    const k = ri(t, c.id);
    let F;
    for (; ; ) {
      if (E instanceof Tt) {
        if (r && !r(E, b.target))
          return { change: C, isClose: !1 };
        if (F = typeof n == "function" ? n(E.attrib) : !!n, P = F ? E.attrib : { ...E.attrib }, c.id === p)
          return { change: C, isClose: !1 };
      } else {
        let T;
        if (o) {
          const R = k.map(({ x: N, y: q }) => [N, q]);
          if (p) {
            const N = Pe(t, p);
            R.push([N.x, N.y]);
          }
          T = yh({
            tree: s,
            pixel: S,
            radius: o,
            points: [...R].reverse()
          }), console.log(T);
        } else
          T = s.getRealFromStage(S);
        const G = Fo(s);
        let H = 0;
        for (; H < G.length; H++)
          if (G[H] instanceof Tt) {
            const R = G[H];
            if (Ot(R.attrib.x - T[0], 10) === 0 && Ot(R.attrib.y - T[1], 10) === 0) {
              E = s.children[H];
              break;
            }
          }
        if (H !== G.length) {
          E = G[H];
          continue;
        }
        P = i(T);
      }
      break;
    }
    const L = k.findIndex(({ id: T }) => T === P.id), I = L === 0 && (!u || k.length >= 3);
    if (L >= 0 && !I) {
      const T = Xa(
        t,
        P.id,
        !h || h(P, b)
      );
      if (C = Si(C, T), c.lineIds.length === 0) {
        gh(t, c.id);
        const G = T.pointChange.del.find(
          ({ id: R }) => R !== P.id
        );
        v(null);
        const H = Ze(t, { ...G, id: void 0 });
        p = H.id, C.pointChange.add.push(H);
      }
      return { change: C, isClose: I };
    }
    F || delete P.id;
    const z = (T) => (!l && I && v(null), { change: T, isClose: I });
    if (c.lineIds.length > 0)
      if (d) {
        const T = tu(
          t,
          e,
          P
        ).change;
        return z(Si(C, T));
      } else
        return m ? (v(null), g(b)) : { change: C, isClose: I };
    else if (p) {
      const [T] = Gt(s.stage, [4, 4], !0), G = Pe(t, p);
      if (!(Math.abs(P.x - G.x) > T || Math.abs(P.y - G.y) > T))
        return z(C);
      const { line: H, change: R } = fe(t, [
        p,
        Ze(t, P).id
      ]);
      return C = Si(C, R, {
        polygonChange: {
          update: [
            {
              before: { ...c, lineIds: [...c.lineIds] },
              after: {
                ...c,
                lineIds: [...c.lineIds, H.id]
              }
            }
          ]
        },
        pointChange: {
          add: [P]
        }
      }), c.lineIds.push(H.id), p = null, z(C);
    } else {
      const T = Ze(t, P);
      return p = T.id, C.pointChange.add.push(T), z(C);
    }
  };
  return {
    continuous: g,
    end: () => {
      c.lineIds.length === 0 && (p && Xa(t, p), _()), A && A(null);
    },
    getStatus: () => ({
      newMode: d,
      polyginAttribId: c.id,
      prevId: p,
      config: t
    }),
    setStatus: (b) => {
      d = b.newMode, c = b.config.polygons.find(
        ({ id: C }) => C === b.polyginAttribId
      ), e = c.id, p = b.prevId, t = b.config;
    }
  };
}, cu = "data:image/x-icon;base64, ", du = "data:image/x-icon;base64, ", uu = (s) => {
  const t = () => JSON.parse(JSON.stringify(s.config)), e = Qa({ ...s }), i = Qa({
    ...s,
    closeAutoQuit: !0,
    changePolygon: void 0,
    config: t()
  }), n = () => {
    const y = e.getStatus();
    i.setStatus({
      ...y,
      config: t()
    });
  }, r = s.tree.stage, a = ei();
  let o = !1;
  const h = () => {
    o = !0;
  }, l = (y) => {
    if (o)
      return;
    n();
    const { change: x } = i.continuous(y), { config: b } = i.getStatus();
    a.value = {
      change: x,
      config: b
    };
  }, A = (y) => {
    o = !1, l(y);
  };
  let u, f;
  const c = (y) => {
    const [x] = Gt(r, [4, 4], !0);
    u && Math.abs(y.evt.offsetX - u.x) < x && Math.abs(y.evt.offsetY - u.y) < x || (f = setTimeout(() => {
      const { isClose: b, change: C } = e.continuous(y);
      n(), b && s.closeAutoQuit && g(), s.onChange && s.onChange(C), u = null;
    }));
  }, d = (y) => {
    const x = ho(y);
    y.evt.offsetX = x.offsetX, y.evt.offsetY = x.offsetY;
  }, p = (y) => {
    y.evt.preventDefault(), d(y), l(y), !a.value.change.lineChange.add.length && !a.value.change.lineChange.del.length && (v(y), u = {
      x: y.evt.offsetX,
      y: y.evt.offsetY
    });
  }, m = (y) => {
    y.evt.preventDefault(), d(y), l(y);
  }, v = (y) => {
    y.evt.preventDefault(), d(y), c(y), a.value = void 0;
  }, _ = (y) => {
    clearTimeout(f), y instanceof KeyboardEvent ? y.key === "Escape" && g() : (g(), y.preventDefault());
  };
  let g = () => {
    hn ? (r.off("touchstart.editPolygonsMode", p), r.off("touchmove.editPolygonsMode", m), r.off("touchend.editPolygonsMode", v)) : (r.off("click.editPolygonsMode", c), r.off("mousedown.editPolygonsMode", h), r.off("mousemove.editPolygonsMode", l), r.off("mouseup.editPolygonsMode", A), document.removeEventListener("contextmenu", _), document.removeEventListener("keydown", _)), a.value = void 0, e.end(), i.end(), s.quitHandler && s.quitHandler();
  };
  return hn ? (r.on("touchstart.editPolygonsMode", p), r.on("touchmove.editPolygonsMode", m), r.on("touchend.editPolygonsMode", v)) : (r.on("click.editPolygonsMode", c), r.on("mousedown.editPolygonsMode", h), r.on("mousemove.editPolygonsMode", l), r.on("mouseup.editPolygonsMode", A), document.addEventListener("contextmenu", _), document.addEventListener("keydown", _)), {
    helperInfo: a,
    destory() {
      g && (g(), g = null);
    }
  };
}, fu = (s, t) => {
  var o, h, l;
  const { lineChange: e, polygonChange: i } = s;
  if (!e || !((o = i == null ? void 0 : i.update) != null && o.length))
    return !1;
  const n = i.update.find(
    ({ after: A }) => A.id === t
  );
  if (!n)
    return !1;
  const { before: r, after: a } = n;
  if ((h = e.del) != null && h.length) {
    if ((l = e.add) != null && l.length)
      return !1;
  } else if (a.lineIds.length >= 2)
    return "after";
  if (a.lineIds.length !== r.lineIds.length)
    if (a.lineIds.includes(r.lineIds[r.lineIds.length - 1])) {
      if (!a.lineIds.includes(r.lineIds[0]))
        return "before";
    } else
      return "after";
  return !1;
}, gu = (s, t = !1) => {
  var o, h, l, A, u, f, c, d, p, m, v, _, g, y, x, b;
  const e = [];
  (h = (o = s.change) == null ? void 0 : o.pointChange) != null && h.add && e.push(
    ...(A = (l = s.change) == null ? void 0 : l.pointChange) == null ? void 0 : A.add.map(({ x: C, y: w }) => [C, w])
  );
  const i = [];
  (f = (u = s.change) == null ? void 0 : u.pointChange) != null && f.del && i.push(...(d = (c = s.change) == null ? void 0 : c.pointChange) == null ? void 0 : d.del.map(({ id: C }) => C));
  const n = [];
  if ((m = (p = s.change) == null ? void 0 : p.lineChange) != null && m.add) {
    const C = s.change.lineChange.add.map(
      ({ pointIds: w }) => w
    );
    n.push(
      ...C.map((w) => _t(s.config, w).flatMap(({ x: S, y: P }) => [S, P]))
    );
  }
  const r = [];
  (_ = (v = s.change) == null ? void 0 : v.lineChange) != null && _.del && r.push(...(y = (g = s.change) == null ? void 0 : g.lineChange) == null ? void 0 : y.del.map(({ id: C }) => C));
  const a = {};
  return t && ((b = (x = s.change) == null ? void 0 : x.polygonChange) != null && b.update) && s.change.polygonChange.update.forEach((C) => {
    if (fu(s.change, C.after.id)) {
      const w = ch(s.config, [
        C.after.lineIds[C.after.lineIds.length - 1],
        C.after.lineIds[0]
      ]);
      a[C.after.id] = _t(s.config, [
        w[0].pointIds[1],
        w[1].pointIds[0]
      ]).flatMap(({ x: E, y: S }) => [E, S]);
    }
  }), {
    addLines: n,
    delLines: r,
    addPoints: e,
    delPoints: i,
    cloneLines: a
  };
}, Or = (s, t) => {
  const { helperInfo: e, destory: i } = uu({
    ...s,
    quitHandler: () => {
      o(), s.quitHandler && s.quitHandler();
    }
  }), n = bh(
    () => e.value && gu(e.value, s.autoClose)
  ), r = On();
  r.shape.listening(!1);
  const a = ui();
  a.active(), a.shape.dash([5, 5]), a.shape.listening(!1);
  const o = Sn((h) => {
    if (!n.value)
      return;
    const { addLines: l, cloneLines: A, addPoints: u } = n.value, f = [...l, ...Object.values(A)].map(
      (m) => (a.setData(m), a.shape.clone())
    ), [c] = Gt(t, [1, 1]), d = u.map((m) => (r.setData(m), r.shape.scale({ x: c, y: c }), r.shape.clone()));
    t.add(...f, ...d);
    let p;
    n.value.delPoints.length ? p = s.tree.setCursor(du) : u.length && (p = s.tree.setCursor(cu)), h(() => {
      [...f, ...d].forEach((m) => {
        m.remove();
      }), p && p();
    });
  });
  return i;
};
class _1 extends Ri {
  diffRedraw() {
    const t = super.diffRedraw();
    return t.lineEntityInc.adds.forEach((e) => {
      ln(e, this.lineDragHandler), e.enableMouseAct({ ...e.actShape, active: void 0 }), e.shape.name("adsord-line");
    }), t.pointEntityInc.adds.forEach((e) => {
      ln(e, this.pointDragHandler), e.enableMouseAct({ ...e.actShape, active: void 0 }), e.shape.addName("adsord-point");
    }), t;
  }
  getChildByPointsAttrib(t) {
    const e = [];
    for (let i = 0; i < t.length; i++) {
      const n = Tt.namespace + t[i].id;
      e.includes(n) || e.push(n), this.attrib.lines.filter(({ pointIds: r }) => r.includes(t[i].id)).forEach(({ id: r }) => {
        const a = Qt.namespace + r;
        e.includes(a) || e.push(a);
      });
    }
    return this.children.filter((i) => e.includes(i.name));
  }
  editPolygon(t) {
    So(), this.container.constant.use();
    const e = /* @__PURE__ */ new Set();
    let i = !1;
    this.endCreatePolygon && this.endCreatePolygon(), this.container.bus.emit("dataChangeBefore");
    const n = Rr();
    let r = !1;
    const a = new Promise((o) => {
      this.endCreatePolygon = Or(
        {
          polygonId: t,
          quotePoint: !0,
          autoClose: !1,
          tree: this.container,
          autoAdd: !0,
          adsorbRadius: jt.WHOLE_LINE_POINT_MERGE_DIST,
          config: this.attrib,
          changePolygon: (h) => {
            console.log("changePolygon", h), h && e.add(h);
          },
          onChange(h) {
            !r && h.pointChange.add.length && (n.emit("penStart"), r = !0);
          },
          quitHandler: () => {
            this.endCreatePolygon = null, e.forEach((h) => {
              const l = yi(this.attrib, h);
              l && (i ? gh(this.attrib, h) : this.polygonAfterHandler(l));
            }), o(i ? "cancel" : "submit"), Co(), this.container.constant.unuse(), this.container.bus.emit("dataChangeAfter");
          }
        },
        this.shape
      );
    });
    return {
      bus: n,
      submit: this.endCreatePolygon.bind(this),
      cancel: () => {
        i = !0, this.endCreatePolygon();
      },
      promise: a
    };
  }
  createPolygon() {
    return this.editPolygon();
  }
  pointAfterHandler(t) {
    this.container.constant.use();
    const e = au(this.attrib, t.id);
    $s(
      this.attrib,
      (e == null ? void 0 : e.info.main.id) || t.id
    ), Ws(this.attrib), this.container.constant.unuse();
  }
  lineAfterHandler(t) {
    this.container.constant.use();
    for (let e = 0; e < t.pointIds.length; e++)
      $s(this.attrib, t.pointIds[e]);
    Ws(this.attrib), this.container.constant.unuse();
  }
  polygonAfterHandler(t) {
    this.container.constant.use(), ri(this.attrib, t.id).forEach(
      (e) => {
        this.attrib.points.includes(e) && $s(this.attrib, e.id);
      }
    ), Ws(this.attrib), this.container.constant.unuse();
  }
  init() {
    this.lineDragHandler = {
      readyHandler: (t) => {
        this.container.bus.emit("dataChangeBefore"), this.container.tempDraw();
        const e = pi(this.attrib, t.id);
        return ou(
          this.attrib,
          t,
          e.map(({ x: i, y: n }) => [i, n])
        );
      },
      moveHandler: (t, e, i) => {
        i(e);
      },
      endHandler: (t) => {
        this.lineAfterHandler(t), this.container.bus.emit("dataChangeAfter");
      }
    }, this.pointDragHandler = {
      readyHandler: (t) => (this.container.constant.use(), this.container.bus.emit("dataChangeBefore"), uh(
        this.attrib,
        t.id
      ).map(({ polygonId: n }) => {
        let r = ri(this.attrib, n);
        const a = r.indexOf(t), o = r[0] === r[r.length - 1] ? r.length - 1 : r.length;
        return r = [
          ...r.slice(a + 1, o),
          ...r.slice(0, a)
        ], console.log(r), r.map((h) => [h.x, h.y]);
      })),
      moveHandler: (t, e, i) => {
        const n = qd(
          this.attrib,
          t
        ).map((a) => Qt.namespace + a.id);
        n.push(Tt.namespace + t.id);
        const r = yh({
          tree: this.container,
          position: e,
          radius: jt.WHOLE_LINE_POINT_MERGE_DIST,
          radiusInner: jt.WHOLE_LINE_POINT_CHECK_DIST,
          pointsArray: i,
          exclusionIds: n
        });
        t.x = r[0], t.y = r[1];
      },
      endHandler: (t) => {
        this.container.constant.unuse(), this.pointAfterHandler(t), this.container.bus.emit("dataChangeAfter");
      }
    }, super.init();
  }
  destory() {
    this.endCreatePolygon && this.endCreatePolygon(), super.destory();
  }
}
const pu = (s, t) => {
  const e = t.parent, i = ui(), n = () => !!(e.editPolygonId.value && dh(
    e.attrib,
    e.editPolygonId.value
  ).some(({ id: o }) => o === s.id)), r = () => {
    var o, h, l;
    ((l = (h = (o = e.helperInfo) == null ? void 0 : o.value) == null ? void 0 : h.delLines) == null ? void 0 : l.includes(s.id)) ? i.shape.stroke("rgba(0, 0, 0, 0)") : n() ? i.active() : i.common();
  };
  return {
    shape: i.shape,
    setData(a) {
      i.setData(a), r();
    },
    common: r
  };
}, mh = (s) => (t, e) => {
  const i = e.parent, n = () => i.editPolygonId.value === t.id, r = Nn({ autoClose: s }), a = (o) => {
    n() ? r.active(o) : r.common(o);
  };
  return {
    shape: r.shape,
    setData(o) {
      var l, A, u, f;
      a(), r.setData(o);
      const h = (A = (l = i.helperInfo) == null ? void 0 : l.value) != null && A.cloneLines ? Object.keys((f = (u = i.helperInfo) == null ? void 0 : u.value) == null ? void 0 : f.cloneLines).includes(
        t.id
      ) : !1;
      r.shape.children[1].visible(!h);
    },
    common: a
  };
}, yu = mh(!0), mu = mh(!1);
class x1 extends Ri {
  constructor() {
    super(...arguments), this.editPolygonId = ei(), this.autoClose = !0, this._leaveEditMode = void 0;
  }
  dragAttach(t) {
    t.pointEntityInc.adds.forEach((e) => {
      ln(e, {
        readyHandler: (i) => [i.x, i.y],
        moveHandler: (i, n) => {
          this.editPolygonId.value && (i.x = n[0], i.y = n[1]);
        }
      }), e.enableMouseAct(e.actShape);
    }), t.lineEntityInc.adds.forEach((e) => {
      e.enableMouseAct(e.actShape);
    }), t.polygonEntityInc.adds.forEach((e) => {
      e.enableMouseAct(e.actShape);
    });
  }
  diffRedraw() {
    const t = super.diffRedraw();
    return this.dragAttach(t), t;
  }
  initIncFactory() {
    super.initIncFactory(), this.incLinesFactory = Pt(
      Qt,
      this,
      (t) => {
        t.actShapeFactory = pu, t.setConfig(this.attrib);
      }
    ), this.incPointsFactory = Pt(
      Tt,
      this
    ), this.incPolygonFactory = Pt(
      Li,
      this,
      (t) => {
        t.actShapeFactory = this.autoClose ? yu : mu, t.setConfig(this.attrib);
      }
    );
  }
  enterEditMode(t) {
    this._leaveEditMode && this._leaveEditMode(), this._leaveEditMode = Or(
      {
        ...t,
        closeAutoQuit: !0,
        tree: this.container,
        autoAdd: !1,
        autoClose: this.autoClose,
        config: this.attrib,
        changePolygon: (e) => {
          this.editPolygonId.value = e;
        },
        quitHandler: () => {
          t.quitHandler && t.quitHandler();
        }
      },
      this.shape
    );
  }
  leaveEditMode() {
    this._leaveEditMode && this._leaveEditMode();
  }
  destory() {
    this.leaveEditMode(), super.destory();
  }
}
class vu extends ie {
  constructor(t) {
    for (const i in t.types)
      t.data[i] = t.data[i] || [];
    for (const i in t.data)
      i in t.types || delete t.data[i];
    super({
      name: "container",
      attrib: { id: "0", data: t.data },
      ...t
    }), this.entrys = {}, this.incFactorys = {}, this.constant = Zd(), this.config = t, this.container = this;
    const { dom: e } = this.config;
    this.stage = new Ii.Stage({
      container: e,
      width: e.offsetWidth,
      height: e.offsetHeight
    });
  }
  initShape() {
    return new br();
  }
  init() {
    this.initIncFactory(), super.init(), this.mount(this.stage), this.mounted();
  }
  initIncFactory() {
    const t = this.config.types;
    for (const e in t)
      this.incFactorys[e] = Pt(
        t[e],
        this,
        (i) => {
          const n = i;
          this.entrys[e] || (this.entrys[e] = []), this.entrys[e].push(n), n.bus.on("destroyed", () => {
            const r = this.entrys[e].indexOf(n);
            ~r && this.entrys[e].splice(r, 1);
          });
        }
      );
  }
  diffRedraw() {
    const t = this.attrib.data, e = {};
    for (const i in t)
      i in this.incFactorys && (e[i] = this.incFactorys[i](t[i]));
    return e;
  }
  initReactive() {
    return super.initReactive("sync");
  }
  // 临时绘制
  tempDraw(...t) {
    const e = t.map((i) => i.teleport);
    return t.forEach((i) => {
      i.mount(this.tempLayer);
    }), () => {
      t.forEach((i, n) => {
        i.mount(e[n]);
      });
    };
  }
  getPixelFromStage(t) {
    const e = we(this.stage, !0), { x: i, y: n } = e.point({ x: t[0], y: t[1] });
    return [i, n];
  }
  getRealFromStage(t) {
    const e = we(this.stage, !0).invert(), { x: i, y: n } = e.point({ x: t[0], y: t[1] });
    return [i, n];
  }
  setCursor(t) {
    return t = ["move", "inherit", "pointer"].includes(t) ? t : t ? `url("${t}"), auto` : "inherit", this.config.dom.style.cursor = t, this.prevCursor = t, () => {
      this.prevCursor === t && (this.config.dom.style.cursor = "inherit", this.prevCursor = "inherit");
    };
  }
  getSameLevelData(t) {
    const e = this.attrib.data;
    for (const i in e)
      if (Array.isArray(e[i]) && ~e[i].indexOf(t.attrib))
        return e[i];
  }
  updateViewMat(t) {
    const e = new j(), i = new ci(), n = new j();
    t.decompose(e, i, n);
    const r = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
    let a = new zi();
    for (let l = 0; l < r.length; l++) {
      a.setFromQuaternion(i, r[l]);
      const A = Math.abs(de.radToDeg(a.z) % 90);
      if (Math.abs(A) < 5)
        break;
    }
    a.setFromQuaternion(i, "XYZ");
    const o = a.z, h = this.stage.scale();
    this.stage.scale({ x: n.x, y: n.y }), this.stage.position({ x: e.x, y: e.y }), this.stage.rotation(de.radToDeg(o)), Math.abs(h.x - n.x) < 1e-3 && Math.abs(h.y - n.y) < 1e-3 || this.redraw(), this.shape.batchDraw(), this.constant.updateConstantScale(Math.min(n.x, n.y)), this.bus.emit("viewChange", {
      mat: we(this.shape, !0),
      size: [this.stage.width(), this.stage.height()]
    });
  }
}
const _u = () => {
  const s = new Ni({
    radius: 3,
    fill: "red"
  }), t = () => {
    const [e] = Gt(s, [1, 1]);
    s.scale({ x: e, y: e });
  };
  return {
    getSize: () => [3, 3],
    shape: s,
    common() {
    },
    setData(e) {
      t(), s.position(e), e.rotate && s.rotate(e.rotate);
    }
  };
}, vh = {}, xu = (s, t) => {
  vh[s] = t;
}, wn = class wn extends ie {
  constructor(t) {
    t.zIndex = t.zIndex || 5, t.name = t.name || wn.namespace + t.attrib.id, super(t), this.showLabel = !1;
  }
  setShowLabel(t) {
    this.showLabel = t, this.diffRedraw();
  }
  initShape() {
    const t = vh[this.attrib.type] || _u;
    return this.actShape = t(this.attrib, this), this.actShape.shape;
  }
  diffRedraw() {
    this.actShape.setData(this.attrib);
  }
  mounted() {
    super.mounted(), this.actShape.common(null);
  }
};
wn.namespace = "poi";
let pn = wn;
class b1 extends pn {
  initShape() {
    const t = super.initShape(), e = t.findOne(".rect"), i = e.parent, n = new th({
      visible: !1,
      name: "tf",
      resizeEnabled: !1,
      nodes: [e]
    });
    i.add(n);
    const r = {
      rotation: e.rotation(),
      position: { ...e.position() },
      scale: { ...e.scale() }
    };
    let a = !1;
    return e.on("transformstart", () => {
      a = !1, console.log("start"), this.container.bus.emit("dataChangeBefore");
    }), e.on("transform", () => {
      const o = n.rotation();
      e.rotation(r.rotation), e.position(r.position), e.scale(r.scale), (this.attrib.rotate || 0) !== o && (a = !0, this.attrib.rotate = o, this.diffRedraw());
    }), e.on("transformend", () => {
      a && this.container.bus.emit("dataChange"), this.container.bus.emit("dataChangeAfter");
    }), t;
  }
  isIntersecting() {
    const t = this.container.attrib.data.rooms[0];
    if (!t)
      return;
    const e = t.points, i = t.lines.map(
      (A) => A.pointIds.flatMap((u) => e.find(({ id: f }) => u === f))
    ), n = 0.8, r = 0.8 * (800 / 1e3), a = this.attrib, o = [
      [a.x - n / 2, a.y - r / 2],
      [a.x + n / 2, a.y - r / 2],
      [a.x + n / 2, a.y + r / 2],
      [a.x - n / 2, a.y + r / 2],
      [a.x - n / 2, a.y - r / 2]
    ], h = new et.Transform().translate(a.x, a.y).rotate(de.degToRad(a.rotate || 0)).translate(-a.x, -a.y);
    o.forEach((A) => {
      const u = h.point({ x: A[0], y: A[1] });
      A[0] = u.x, A[1] = u.y;
    });
    const l = i.some((A) => UA(o, [
      A[0].x,
      A[0].y,
      A[1].x,
      A[1].y
    ]));
    return this.attrib.intersect = l, l;
  }
  diffRedraw() {
    this.isIntersecting(), super.diffRedraw();
  }
  mounted() {
    super.enableMouseAct(this.actShape), this.bus.on("shapeStatusChange", (t) => {
      t.type === "click" && (t.current === "active" ? this.container.bus.emit("active", { active: !0, entity: this }) : this.container.bus.emit("active", { active: !1, entity: this }));
    }), super.enableDrag({
      readyHandler: () => {
        this.container.bus.emit("dataChangeBefore");
      },
      moveHandler: (t) => {
        this.attrib.x = t[0], this.attrib.y = t[1];
      },
      endHandler: () => {
        this.container.bus.emit("dataChangeAfter");
      }
    }), super.mounted();
  }
  del() {
    const t = this.container.getSameLevelData(this);
    t && t.splice(t.indexOf(this.attrib), 1), this.container.bus.emit("dataChange");
  }
  copy(t = {}) {
    let e = 0;
    qA({
      ...t,
      entity: this,
      size: this.actShape.getSize(),
      factoryAttrib: (i) => ({
        id: (Date.now() + e++).toString(),
        x: i[0],
        y: i[1],
        rotate: this.attrib.rotate,
        type: this.attrib.type
      })
    }), this.container.bus.emit("dataChange");
  }
}
const bu = (s, t) => (i, n, r = !1) => {
  const a = document.createElement("div");
  a.style.width = "100%", a.style.height = "100%";
  const o = new vu({
    dom: a,
    readonly: r,
    types: s,
    data: n,
    reactive: !r
  });
  o.init();
  const h = {};
  if (t)
    for (const u in t) {
      const f = t[u];
      f.setTree(o), h[u] = f;
    }
  let l = null;
  const A = (u) => {
    a.parentElement && a.parentElement.removeChild(a), u.appendChild(a), a.style.width = "100%", a.style.height = "100%", o.stage.width(a.offsetWidth), o.stage.height(a.offsetHeight), l = u;
  };
  return i ? A(i) : (a.style.width = "300px", a.style.height = "300px"), {
    types: s,
    tree: o,
    setData(u) {
      o.setAttrib({ data: u });
    },
    getData() {
      return o.attrib.data;
    },
    destory() {
      for (const u in t) {
        const f = t[u];
        f.destory && f.destory();
      }
      o.destory();
    },
    mountedDom: l,
    mount: A,
    ...h
  };
}, Je = new Jt(), wu = (s, t) => {
  Je.identity().translate(-t[0], -t[1]);
  const e = new X(s[0], s[1]).applyMatrix3(Je), i = new X(s[2], s[3]).applyMatrix3(Je);
  return [e.x, e.y, i.x, i.y];
}, Su = (s, t, e) => {
  Je.identity().translate(-t[0], -t[1]).scale(e, e).translate(t[0], t[1]);
  const i = new X(s[0], s[1]).applyMatrix3(Je), n = new X(s[2], s[3]).applyMatrix3(Je);
  return [i.x, i.y, n.x, n.y];
};
class Cu {
  constructor(t = {}) {
    this.bound = t.bound, this.props = t, this.props.move = t.move || !1, this.props.wheel = t.wheel || !1;
  }
  disableMove() {
    this.props.move = !1, this.dragDestory && this.dragDestory();
  }
  enableMove(t) {
    if (this.disableMove(), this.props.move = !0, !this.tree)
      return;
    const { stage: e } = this.tree;
    this.dragDestory = vr(
      e,
      {
        readyHandler: () => ({
          tf: we(e, !0).invert(),
          initBound: this.bound
        }),
        moveHandler: (i, { tf: n, initBound: r }) => {
          const a = n.point({ x: i[0], y: i[1] }), o = [a.x, a.y];
          let h = wu(r, o);
          if (t) {
            const l = t(h, o);
            if (typeof l != "boolean")
              h = l;
            else if (!l)
              return;
          }
          this.setBound(h);
        }
      },
      !1
    );
  }
  disableWheel() {
    this.props.wheel = !1, this.wheelDestory && this.wheelDestory();
  }
  enableWheel(t) {
    if (this.disableWheel(), this.props.wheel = !0, !this.tree)
      return;
    const {
      stage: e,
      config: { dom: i }
    } = this.tree, n = (r) => {
      const a = 1 + r.deltaY / 200, o = e.getRelativePointerPosition(), h = [o.x, o.y];
      let l = Su(this.bound, h, a);
      if (t) {
        const A = t(l, h, a);
        if (typeof A != "boolean")
          l = A;
        else if (!A)
          return;
      }
      this.bound = l, this.update(), r.stopPropagation(), r.preventDefault();
    };
    i.addEventListener("wheel", n), this.wheelDestory = () => i.removeEventListener("wheel", n);
  }
  setBound(t) {
    this.bound = t, this.update();
  }
  setSize(t, e) {
    this.tree.stage.width(t), this.tree.stage.height(e);
  }
  setTree(t) {
    if (this.tree = t, !this.bound) {
      const e = t.stage.getSize(), i = t.stage.position();
      this.bound = [i.x, i.y, e.width, e.height];
    }
    this.props.move && this.enableMove(), this.props.wheel && this.enableWheel();
  }
  update() {
    const { stage: t } = this.tree, e = this.bound[2] - this.bound[0], i = this.bound[3] - this.bound[1], n = t.width() / e, r = t.height() / i, a = -this.bound[0] * n, o = -this.bound[1] * r;
    t.scale({ x: n, y: r }), t.position({ x: a, y: o }), this.tree.bus.emit("viewChange", {
      mat: t.getTransform(),
      size: [t.width(), t.height()]
    }), this.tree.redraw(), this.tree.stage.draw();
  }
}
var _h = {};
Object.defineProperty(_h, "__esModule", { value: !0 });
var Mu = function(t) {
  for (var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, i = t.length, n = e ^ i, r = 0, a = void 0; i >= 4; )
    a = t.charCodeAt(r) & 255 | (t.charCodeAt(++r) & 255) << 8 | (t.charCodeAt(++r) & 255) << 16 | (t.charCodeAt(++r) & 255) << 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), a ^= a >>> 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16) ^ a, i -= 4, ++r;
  switch (i) {
    case 3:
      n ^= (t.charCodeAt(r + 2) & 255) << 16;
    case 2:
      n ^= (t.charCodeAt(r + 1) & 255) << 8;
    case 1:
      n ^= t.charCodeAt(r) & 255, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16);
  }
  return n ^= n >>> 13, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16), n ^= n >>> 15, n >>> 0;
}, Pu = Mu, Eu = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(s) {
  return typeof s;
} : function(s) {
  return s && typeof Symbol == "function" && s.constructor === Symbol && s !== Symbol.prototype ? "symbol" : typeof s;
};
function Fu(s) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2, e = /* @__PURE__ */ new Set(), i = JSON.stringify(s, function(n, r) {
    return (typeof r > "u" ? "undefined" : Eu(r)) === "object" && r !== null ? e.has(r) ? void 0 : e.add(r) && r : r;
  }, t);
  return e = null, i;
}
var Ka = Object.assign || function(s) {
  for (var t = 1; t < arguments.length; t++) {
    var e = arguments[t];
    for (var i in e)
      Object.prototype.hasOwnProperty.call(e, i) && (s[i] = e[i]);
  }
  return s;
};
function ku(s) {
  if (Array.isArray(s)) {
    for (var t = 0, e = Array(s.length); t < s.length; t++)
      e[t] = s[t];
    return e;
  } else
    return Array.from(s);
}
var xh = {
  // StateNode => { Chunks, Children }
  toRecord: function(t) {
    return {
      chunks: [Ka({}, t, { children: void 0 })],
      children: t.children
    };
  },
  // { Chunks, Children } => StateNode
  fromRecord: function(t) {
    var e = t.chunks, i = t.children;
    return Ka({}, e[0], { children: i });
  }
}, Du = function s(t, e) {
  for (var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1, a = i.findIndex(function(v) {
    var _ = v.match;
    return _(t);
  }), o = i[a] || xh, h = o.toRecord(t), l = h.chunks, A = h.children, u = A, f = [], c = 0; c < l.length; c++) {
    var d = Fu(l[c], 0), p = Pu(d);
    f.push(p), e[p] = d;
  }
  if (r !== -1 && Array.isArray(n && n.children)) {
    var m = [].concat(ku(n.children));
    return m[r] = s(u[r], e, i), { hashes: f, ruleIndex: a, children: m };
  } else
    return {
      hashes: f,
      ruleIndex: a,
      children: A && A.map(function(v) {
        return s(v, e, i);
      })
    };
}, Iu = function s(t, e) {
  var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = t.hashes, r = t.ruleIndex, a = t.children, o = n.map(function(l) {
    return JSON.parse(e[l]);
  }), h = i[r] || xh;
  return h.fromRecord({
    chunks: o,
    children: a && a.map(function(l) {
      return s(l, e, i);
    })
  });
}, Tu = /* @__PURE__ */ function() {
  function s(t, e) {
    for (var i = 0; i < e.length; i++) {
      var n = e[i];
      n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n);
    }
  }
  return function(t, e, i) {
    return e && s(t.prototype, e), i && s(t, i), t;
  };
}();
function Lu(s, t) {
  if (!(s instanceof t))
    throw new TypeError("Cannot call a class as a function");
}
var Za = function() {
}, Ru = function() {
  function s() {
    var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
      initialState: void 0,
      rules: [],
      delay: 50,
      maxLength: 100,
      onChange: Za,
      useChunks: !0
    };
    Lu(this, s), this.rules = t.rules || [], this.delay = t.delay || 50, this.maxLength = t.maxLength || 100, this.useChunks = t.useChunks === void 0 ? !0 : t.useChunks, this.onChange = Za, this.$index = -1, this.$records = [], this.$chunks = {}, this.$pending = {
      state: null,
      pickIndex: null,
      onResolves: [],
      timer: null
    }, this.$debounceTime = null, t.initialState !== void 0 && this.pushSync(t.initialState), t.onChange && (this.onChange = t.onChange);
  }
  return Tu(s, [{
    key: "get",
    // void => State
    value: function() {
      var e = this.$records[this.$index], i = void 0;
      return e ? this.useChunks ? i = Iu(e, this.$chunks, this.rules) : i = e : i = null, this.onChange(i), i;
    }
    // (State, number?) => History
  }, {
    key: "pushSync",
    value: function(e) {
      var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1, r = this.$records[this.$index] || null, a = this.useChunks ? Du(e, this.$chunks, this.rules, r, n) : e;
      this.$index++, this.$records[this.$index] = a;
      for (var o = this.$index + 1; o < this.$records.length; o++)
        this.$records[o] = null;
      return this.$index >= this.maxLength && (this.$records[this.$index - this.maxLength] = null), this.$pending.timer && (clearTimeout(this.$pending.timer), this.$pending.state = null, this.$pending.pickIndex = null, this.$pending.timer = null, this.$debounceTime = null, this.$pending.onResolves.forEach(function(h) {
        return h(i);
      }), this.$pending.onResolves = []), this.onChange(e), this;
    }
    // (State, number?) => Promise<History>
  }, {
    key: "push",
    value: function(e) {
      var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : -1, r = +/* @__PURE__ */ new Date(), a = function() {
        i.$pending.state = e, i.$pending.pickIndex = n, i.$debounceTime = r;
        var h = new Promise(function(l, A) {
          i.$pending.onResolves.push(l), i.$pending.timer = setTimeout(function() {
            i.pushSync(i.$pending.state, i.$pending.pickIndex);
          }, i.delay);
        });
        return h;
      };
      return this.$pending.timer === null ? a() : r - this.$debounceTime < this.delay ? (clearTimeout(this.$pending.timer), this.$pending.timer = null, a()) : Promise.reject(new Error("Invalid push ops"));
    }
    // void => History
  }, {
    key: "undo",
    value: function() {
      return this.hasUndo && this.$index--, this;
    }
    // void => History
  }, {
    key: "redo",
    value: function() {
      return this.hasRedo && this.$index++, this;
    }
    // void => History
  }, {
    key: "reset",
    value: function() {
      var e = this;
      return this.$index = -1, this.$records.forEach(function(i) {
      }), Object.keys(this.$chunks).forEach(function(i) {
        e.$chunks[i] = null;
      }), this.$records = [], this.$chunks = {}, clearTimeout(this.$pending.timer), this.$pending = {
        state: null,
        pickIndex: null,
        onResolves: [],
        timer: null
      }, this.$debounceTime = null, this;
    }
  }, {
    key: "hasRedo",
    get: function() {
      if (this.$index === this.$records.length - 1)
        return !1;
      for (var e = !1, i = this.$index + 1; i < this.$records.length; i++)
        this.$records[i] !== null && (e = !0);
      return e;
    }
    // : boolean
  }, {
    key: "hasUndo",
    get: function() {
      var e = Math.max(this.$records.length - this.maxLength, 0);
      return this.$index > e;
    }
    // : number
  }, {
    key: "length",
    get: function() {
      return Math.min(this.$records.length, this.maxLength);
    }
  }]), s;
}(), Ou = _h.History = Ru;
class w1 {
  constructor() {
    this.state = ti({
      hasUndo: !1,
      hasRedo: !1
    }), this.disabled = !0;
  }
  setDisable(t) {
    this.disabled = t, t ? this.state.hasRedo = this.state.hasUndo = !1 : this.syncState();
  }
  syncState() {
    !this.history || this.disabled || (this.state.hasRedo = this.history.hasRedo, this.state.hasUndo = this.history.hasUndo);
  }
  setTree(t) {
    this.tree = t, this.history = new Ou(), this.setDisable(!1), this.push(this.tree.attrib), this.timelyPush();
  }
  undo() {
    !this.disabled && this.history.hasUndo && (this.history.undo(), this.tree.setAttrib(this.history.get()), this.syncState());
  }
  redo() {
    !this.disabled && this.history.hasRedo && (this.history.redo(), this.tree.setAttrib(this.history.get()), this.syncState());
  }
  push(t) {
    const e = this.history.get();
    e && delete e.children, di(t, e) && (t = JSON.parse(JSON.stringify(t)), this.history.pushSync(t), this.syncState());
  }
  clear() {
    this.history.reset();
  }
  timelyPush() {
    this.timelyPushDestory && this.timelyPushDestory();
    const t = () => {
      this.push(this.tree.attrib);
    }, e = () => {
      this.setDisable(!0);
    }, i = () => {
      this.setDisable(!1), t();
    };
    this.tree.bus.on("dataChange", t), this.tree.bus.on("dataChangeBefore", e), this.tree.bus.on("dataChangeAfter", i), this.timelyPushDestory = () => {
      this.tree.bus.off("dataChange", t), this.tree.bus.off("dataChangeBefore", e), this.tree.bus.off("dataChangeAfter", i), this.timelyPushDestory = null;
    };
  }
}
class S1 {
  constructor(t = {}) {
    this.clipMat = new ot(), this.bus = Rr(), this.props = t, this.props.move = t.move || !1, this.props.wheel = t.wheel || !1, this.cameraMat = new ot(), this.retainScale = t.retainScale || !1, t.size && this.setSize(t.size[0], t.size[1]), t.bound && this.setBound(t.bound, t.padding);
  }
  disableMove() {
    this.props.move = !1, this.dragDestory && this.dragDestory();
  }
  enableMove() {
    if (this.disableMove(), this.props.move = !0, !this.tree)
      return;
    const { stage: t } = this.tree;
    this.dragDestory = vr(
      t,
      {
        readyHandler: () => this.cameraMat.clone(),
        moveHandler: (e, i) => {
          const n = this.clipMat.clone().multiply(i).invert(), r = new j(e[0], e[1], 0).applyMatrix4(n);
          this.move([r.x, r.y], i);
        }
      },
      !1
    );
  }
  disableWheel() {
    this.props.wheel = !1, this.wheelDestory && this.wheelDestory();
  }
  enableWheel() {
    if (this.disableWheel(), this.props.wheel = !0, !this.tree)
      return;
    const {
      config: { dom: t }
    } = this.tree, e = (i) => {
      const n = 1 - i.deltaY / 1e3, r = new j(i.offsetX, i.offsetY, 0).applyMatrix4(
        this.clipMat.clone().multiply(this.cameraMat).invert()
      );
      this.scale([r.x, r.y], n);
    };
    t.addEventListener("wheel", e), this.wheelDestory = () => t.removeEventListener("wheel", e);
  }
  move(t, e = this.cameraMat) {
    this.mutMat(
      new ot().setPosition(t[0], t[1], 0),
      e
    );
  }
  scale(t, e, i = this.cameraMat) {
    this.mutMat(
      new ot().makeTranslation(t[0], t[1], 0).multiply(
        new ot().makeScale(e, e, 1).multiply(new ot().makeTranslation(-t[0], -t[1], 0))
      ),
      i
    );
  }
  rotate(t, e, i = this.cameraMat) {
    this.mutMat(
      new ot().makeTranslation(t[0], t[1], 0).multiply(
        new ot().makeRotationAxis(new j(0, 0, 1), e).multiply(new ot().makeTranslation(-t[0], -t[1], 0))
      ),
      i
    );
  }
  mutMat(t, e = this.cameraMat) {
    t instanceof ot ? e = e.clone().multiply(t) : e = e.multiply(new ot().fromArray(t)), this.setCameraMat(e), this.bus.emit("cameraChange", this.cameraMat.toArray());
  }
  setCameraMat(t) {
    t instanceof ot ? this.cameraMat = t : this.cameraMat.fromArray(t), this.update();
  }
  autoBound(t, e = [".wpoint"]) {
    const i = e.flatMap(
      (r) => this.tree.stage.find(r).map((a) => a.position())
    );
    if (i.length < 2)
      return;
    const n = [
      Number.MAX_VALUE,
      Number.MAX_VALUE,
      -Number.MAX_VALUE,
      -Number.MAX_VALUE
    ];
    for (const r of i)
      n[0] = Math.min(n[0], r.x), n[1] = Math.min(n[1], r.y), n[2] = Math.max(n[2], r.x), n[3] = Math.max(n[3], r.y);
    this.setBound(n, t);
  }
  setBound(t, e) {
    e = Array.isArray(e) ? e : [e || 0, e || 0], e.length === 1 && e.push(e[0]);
    const i = t[2] - t[0], n = t[3] - t[1], r = this.tree.stage.width(), a = this.tree.stage.height(), o = this.tree.stage.width() - e[0] * 2, h = this.tree.stage.height() - e[1] * 2;
    let l = o / i, A = h / n;
    if (this.retainScale) {
      const d = Math.min(l, A);
      l = d, A = d;
    }
    const u = (r - i * l) / 2 - t[0] * l, f = (a - n * A) / 2 - t[1] * A, c = new ot().scale(new j(l, A, 1)).setPosition(u, f, 0);
    this.bound = t, this.padding = e, this.clipMat = c, this.update();
  }
  updateSelfBound() {
    this.bound && this.setBound(this.bound, this.padding);
  }
  setRetainScale(t) {
    this.retainScale = t, this.updateSelfBound();
  }
  setSize(t, e) {
    this.tree.stage.width(t), this.tree.stage.height(e), this.updateSelfBound();
  }
  setTree(t) {
    this.tree = t, this.props.move && this.enableMove(), this.props.wheel && this.enableWheel();
  }
  update() {
    this.tree.updateViewMat(this.clipMat.clone().multiply(this.cameraMat));
  }
}
var cr = /* @__PURE__ */ ((s) => (s.border = "边界点", s.center = "中心点", s.marker = "标志点", s.mapSelect = "地图选点", s.other = "其他", s))(cr || {});
const Ys = {
  边界点: "#409EFF",
  中心点: "#41bf7a",
  标志点: "#f76065",
  地图选点: "#58d2e7",
  其他: "#e2a33f"
}, Nu = (s, t) => {
  const e = t.parent, i = { width: 43, height: 44 }, n = new Ci({
    data: "M22 44C32.6667 33.891 38 25.891 38 20C38 11.1634 30.8366 4 22 4C13.1634 4 6 11.1634 6 20C6 25.891 11.3333 33.891 22 44Z",
    strokeScaleEnabled: !0,
    stroke: "#ffffff",
    strokeWidth: 1
  }), r = new Ci({
    fill: "#fff",
    data: "M22 30C27.5228 30 32 25.5228 32 20C32 14.4772 27.5228 10 22 10C16.4772 10 12 14.4772 12 20C12 25.5228 16.4772 30 22 30Z"
  }), a = new Ci({
    fill: "#409EFF",
    offset: {
      x: -5,
      y: -5
    },
    data: "M20.5143 12.213C20.7983 12.497 20.7983 12.9575 20.5143 13.2415L15.2727 18.4831L11.8494 15.0597C11.5654 14.7757 11.5654 14.3152 11.8494 14.0312C12.1334 13.7472 12.5939 13.7472 12.8779 14.0312L15.2727 16.426L19.4857 12.213C19.7698 11.929 20.2302 11.929 20.5143 12.213Z"
  }), o = new Nt({
    name: "anchor-move"
  }), h = new Ni({
    name: "anchor-move",
    radius: Math.min(i.width, i.height) / 2,
    fill: "rgba(0, 0, 0, 0)",
    offset: { x: -i.width / 2, y: -i.height / 2 }
  }), l = On();
  Mt.radius = 5, Mt.hitStrokeWidth = Mt.strokeWidth = 4, l.shape.name("anchor-point");
  const A = new dn({
    name: "text",
    text: "1",
    fontFamily: "Calibri",
    fontSize: 12,
    padding: 5,
    offsetY: -8,
    fill: "#000"
  }), u = new Bo({
    visible: !1,
    opacity: 1,
    name: "label",
    offsetX: -i.width / 2,
    offsetY: -6
  });
  o.add(A, u, h);
  const f = new dn({
    name: "text",
    text: s.title || `P${s.id}`,
    fontFamily: "Inter",
    fontSize: 12,
    padding: 8,
    fill: "#303133"
  });
  u.add(
    new Oo({
      name: "tag",
      fill: "rgba(255, 255, 255, 1)",
      pointerDirection: "down",
      pointerWidth: 8,
      pointerHeight: 8,
      lineJoin: "round",
      shadowColor: "black",
      cornerRadius: 2,
      opacity: 1,
      shadowBlur: 10,
      shadowOffsetX: 10,
      shadowOffsetY: 10,
      shadowOpacity: 0.5
    }),
    f
  );
  const c = new Nt();
  c.add(n, r, a, o), c.x(-i.width / 2), c.y(-i.height);
  const d = new Nt();
  d.add(c, l.shape);
  const p = (v) => {
    n.fill(v), a.fill(v);
  };
  return {
    shape: d,
    common() {
      l.common(), u.visible(!1);
    },
    hover: () => {
      u.visible(!0), s.rtk || p("#409EFF");
    },
    setData(v) {
      let [_, g] = Gt(d, [1, 1]);
      d.scale({ x: _, y: g }), d.x(v[0]), d.y(v[1]), f.text(t.attrib.title || `P${s.id}`), p(
        t.attrib.rtk ? Ys[t.attrib.type] || Ys[cr.other] : Ys[cr.mapSelect]
      ), ~t.editPolygonNdx ? (A.text((t.editPolygonNdx + 1).toString()).visible(!0), A.offsetX(-h.width() / 2 + A.width() / 2), l.shape.visible(!0), a.visible(!1)) : (A.visible(!1), l.shape.visible(!1), a.visible(e.status.selectPoiIds.includes(s.id)));
    },
    draging() {
      ~t.editPolygonNdx && p("#e0403c");
    }
  };
};
class Gu extends Tt {
  constructor() {
    super(...arguments), this.actShape = null;
  }
  get editPolygonNdx() {
    const t = this.parent;
    return t.status.editPolygonId ? ri(
      t.attrib,
      t.status.editPolygonId
    ).map(({ id: i }) => i).indexOf(this.attrib.id) : -1;
  }
  init() {
    this.actShapeFactory = Nu, super.init(), this.enableMouseAct(this.actShape);
  }
  initReactive() {
    const t = this.parent;
    return this.bus.on("shapeStatusChange", ({ current: e, type: i }) => {
      e === "active" && i === "click" && t.bus.emit("clickPoint", this.attrib);
    }), _r(
      super.initReactive(),
      ge(
        () => this.editPolygonNdx,
        (e, i, n) => {
          if (!~e || this.attrib.rtk)
            return n(() => {
            });
          const r = this.shape.findOne(".anchor-move");
          let a = null;
          r.on("mouseenter.anchor", () => {
            a && a(), a = this.container.setCursor("move");
          }), r.on("mouseleave.anchor", () => {
            a && a(), a = null;
          }), ln(this, {
            readyHandler: (o) => [o.x, o.y],
            moveHandler: (o, h) => {
              ~this.editPolygonNdx && (o.x = h[0], o.y = h[1]);
            }
          }), n(() => {
            r.off("mouseenter.anchor mouseleave.anchor"), a && a(), this.disableDrag();
          });
        },
        { immediate: !0 }
      ),
      Sn(
        () => {
          t.status.lightPointId === this.attrib.id ? this.bus.emit("statusChange", { hover: !0 }) : this.bus.emit("statusChange", null);
        },
        { flush: "post" }
      )
    );
  }
}
const Bu = () => {
  const s = Nn({
    autoClose: !0
  }), t = s.shape.findOne(".polygon-line");
  return {
    ...s,
    common() {
      t.fill("rgba(0, 0, 0, 0)"), s.closeLine.common();
    },
    hover() {
      t.fill("rgba(230, 162, 60, 0.3)"), s.closeLine.hover();
    },
    active() {
      t.fill("rgba(64, 158, 255, 0.3)"), s.closeLine.active();
    }
  };
};
class zu extends Li {
  constructor() {
    super(...arguments), this.actShapeFactory = Bu;
  }
  init() {
    super.init(), this.enableMouseAct(this.actShape);
  }
  initReactive() {
    const t = (i) => {
      this.bus.emit("statusChange", { [i]: !0 });
    };
    t("common");
    const e = this.parent;
    return this.bus.on("shapeStatusChange", ({ current: i, type: n }) => {
      e.status.editPolygonId || (i === "active" ? n === "click" && e.bus.emit("activePolygonId", this.attrib.id) : e.status.lightPolygonId === this.attrib.id ? n === "click" && e.bus.emit("activePolygonId", null) : t(i));
    }), _r(
      super.initReactive(),
      ge(
        () => [e.status.editPolygonId, e.status.lightPolygonId],
        ([i, n]) => {
          i === this.attrib.id ? t("active") : n === this.attrib.id ? t("hover") : t("common");
        },
        { flush: "post" }
      )
    );
  }
}
const Uu = (s) => ({
  rtk: !1,
  title: "",
  x: s[0],
  y: s[1]
}), Hu = (s, t) => {
  const e = t.parent, i = ui(), n = () => !!(e.status.editPolygonId && dh(
    e.attrib,
    e.status.editPolygonId
  ).some(({ id: o }) => o === s.id)), r = () => {
    n() ? i.active() : i.common();
  };
  return {
    shape: i.shape,
    setData(a) {
      i.setData(a), r();
    },
    common: r
  };
};
class Vu extends Ri {
  constructor() {
    super(...arguments), this.status = ti({
      selectPoiIds: [],
      newModel: !1
    });
  }
  removePolygon(t) {
    const e = this.attrib.polygons.findIndex(({ id: r }) => r === t);
    if (!~e)
      return;
    const i = this.attrib.polygons[e].lineIds;
    let n = [];
    for (; i.length; ) {
      const r = this.attrib.lines.findIndex(
        ({ id: a }) => a === i[0]
      );
      ~r && (n.push(...this.attrib.lines[r].pointIds), this.attrib.lines.splice(r, 1)), i.shift();
    }
    for (n = Array.from(new Set(n)); n.length; ) {
      const r = this.attrib.points.findIndex(
        ({ id: a }) => a === n[0]
      );
      ~r && !this.attrib.points[r].rtk && this.attrib.points.splice(r, 1), n.shift();
    }
    this.attrib.polygons.splice(e, 1);
  }
  initIncFactory() {
    super.initIncFactory(), this.incPointsFactory = Pt(Gu, this), this.incLinesFactory = Pt(
      Qt,
      this,
      (t) => {
        t.setConfig(this.attrib), t.actShapeFactory = Hu;
      }
    ), this.incPolygonFactory = Pt(zu, this, (t) => {
      t.setConfig(this.attrib);
    });
  }
  editPolygon(t) {
    return this.endEditPolygon && this.endEditPolygon(), this.status.newModel = !t, this.endEditPolygon = Or(
      {
        polygonId: t,
        pointAttribFactory: Uu,
        canOper: (e, i) => {
          if (!e.name.includes(Tt.namespace))
            return !0;
          const n = ri(
            this.attrib,
            this.status.editPolygonId
          ), r = e.attrib.id, a = n.some(({ id: o }) => o === r);
          return !!Po(
            i,
            (o) => o.name() === (a ? "anchor-point" : "anchor-move")
          );
        },
        quitHandler: () => {
          this.status.newModel = !1, this.bus.emit("penEndHandler"), this.endEditPolygon = null;
        },
        canDelPoint: (e) => !e.rtk,
        quotePoint: (e) => e.rtk,
        closeAutoQuit: !0,
        tree: this.container,
        autoAdd: !1,
        autoClose: !0,
        config: this.attrib,
        changePolygon: (e) => {
          this.status.editPolygonId = e;
        }
      },
      this.shape
    ), this.endEditPolygon;
  }
  destory() {
    this.endEditPolygon && this.endEditPolygon(), super.destory();
  }
}
function $u(s) {
  const t = Wu();
  for (let e = 0, i = s.length; e < i; ++e)
    Yu(t, s[e]);
  return t;
}
function Wu() {
  return [1 / 0, 1 / 0, -1 / 0, -1 / 0];
}
function Yu(s, t) {
  t[0] < s[0] && (s[0] = t[0]), t[0] > s[2] && (s[2] = t[0]), t[1] < s[1] && (s[1] = t[1]), t[1] > s[3] && (s[3] = t[1]);
}
const Xu = `<svg width="96" height="96" viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
  <path
    d="M72 48C72 61.2548 61.2548 72 48 72C34.7452 72 24 61.2548 24 48C24 34.7452 34.7452 24 48 24C61.2548 24 72 34.7452 72 48Z"
    fill="white" />
  <path
    d="M38 58.2759L48 55.2017L58 58.2759L48 35L38 58.2759ZM48 37.5333L56.2281 56.685L48 54.1555V37.5333Z"
    fill="black" />
  <path
    d="M41.0838 11.1168L40.0239 11.4601L41.4821 14.7157L44.326 13.5088V16.0501H47.698V1.42212H44.326V4.62812H40.854V7.95812H44.326V9.95863C43.082 10.4198 41.9096 10.8493 41.0838 11.1168Z"
    fill="white" />
  <path
    d="M55.7856 5.90817L53.4853 3.10772L52.7077 3.8062C52.2849 4.18598 51.753 4.61099 51.17 5.03535V1.43612H47.784V12.6701C47.784 13.5379 47.8745 14.4323 48.4211 15.0717C49.0134 15.7645 49.8846 15.8821 50.66 15.8821H52.746C53.2147 15.8821 53.6913 15.8052 54.1254 15.5671C54.5733 15.3215 54.888 14.953 55.1053 14.5224C55.5006 13.7389 55.6219 12.635 55.6906 11.3515L55.7358 10.5057L54.9089 10.3219C54.6839 10.2719 54.2525 10.072 54.018 9.89612L52.4998 8.7575L52.4189 10.6535C52.3763 11.6524 52.3375 12.2352 52.2795 12.5801H51.17V8.87969C52.4714 8.15697 53.8241 7.34512 54.9329 6.53282L55.7856 5.90817Z"
    fill="white" />
  <path
    d="M41.3921 12.0681C42.3861 11.7461 43.8561 11.2001 45.3261 10.6541V6.95812H41.8541V5.62812H45.3261V2.42212H46.6981V15.0501H45.3261V11.9981L41.9941 13.4121L41.3921 12.0681ZM53.3761 4.55012L54.3421 5.72612C53.1381 6.60812 51.6121 7.50412 50.1701 8.28812V12.6981C50.1701 13.4541 50.2681 13.5801 50.8281 13.5801C51.0941 13.5801 52.3121 13.5801 52.6201 13.5801C53.2361 13.5801 53.3201 12.9921 53.4181 10.6961C53.7541 10.9481 54.3141 11.2141 54.6921 11.2981C54.5521 13.9161 54.2021 14.8821 52.7461 14.8821C52.4381 14.8821 50.9401 14.8821 50.6601 14.8821C49.2181 14.8821 48.7841 14.3921 48.7841 12.6701V2.43612H50.1701V6.91612C51.3601 6.17412 52.5501 5.29212 53.3761 4.55012Z"
    fill="black" />
</svg>`;
xu("compass", (s, t) => {
  const e = kl({
    ...Fl(Xu),
    fixed: !0
  });
  return {
    ...e,
    setData(i) {
      const n = we(e.shape).copy().invert(), r = t.container.stage.width(), a = n.point({ x: r - 60, y: 120 });
      e.setData({ ...i, ...a });
    }
  };
});
class ju extends ie {
  constructor(t) {
    t.name = t.name || "pixel-scale", t.zIndex = 1e3, !t.attrib.left && !t.attrib.right && (t.attrib.left = 10), !t.attrib.top && !t.attrib.bottom && (t.attrib.bottom = 10), super(t), this.allowable = 0.01, this.fontSize = 12, this.padding = 4, this.getScaleUnit = (e) => Math.max(...e) * 1e4, this.getScaleText = (e) => e + "";
  }
  get height() {
    return this.fontSize + this.padding;
  }
  initShape() {
    const t = new Nt();
    return t.add(
      new Fn({
        name: "scale-line",
        points: [
          0,
          this.height / 2,
          0,
          this.height,
          100,
          this.height,
          100,
          this.height / 2
        ],
        strokeScaleEnabled: !1,
        strokeWidth: 1.5,
        stroke: "#fff"
      }),
      new dn({
        name: "scale-text",
        text: "",
        fontFamily: "Calibri",
        x: 0,
        y: 0,
        align: "center",
        fontSize: this.fontSize,
        fill: "#fff"
      })
    ), t;
  }
  setColor(t) {
    this.shape.findOne(".scale-line").stroke(t), this.shape.findOne(".scale-text").fill(t);
  }
  diffRedraw() {
    if (!this.mat || !this.pixelScale || isNaN(this.pixelScale))
      return;
    let t = 1, e, i;
    for (let c = this.attrib.minWidth; c <= this.attrib.maxWidth; c++) {
      const d = c * this.pixelScale, p = Ot(d, 10) - d, m = d < 1e3 ? 5 : 500;
      if (p < this.allowable && d % m < 1) {
        e = c, i = d;
        break;
      } else
        p < t && (e = c, i = d, t = p);
    }
    if (e === 0 || i === 0)
      return;
    const n = this.shape.findOne(".scale-line"), r = this.shape.findOne(".scale-text"), a = n.points();
    a[4] = a[6] = e, r.width(e), r.text(this.getScaleText(i));
    const o = this.container.stage;
    let h = this.attrib.left, l = this.attrib.top;
    typeof h != "number" && typeof this.attrib.right == "number" && (h = o.width() - e - this.attrib.right), typeof l != "number" && typeof this.attrib.bottom == "number" && (l = o.height() - this.height - this.attrib.bottom);
    const A = this.mat.point({ x: 1, y: 1 }), u = this.mat.point({ x: 0, y: 0 }), f = {
      x: A.x - u.x,
      y: A.y - u.y
    };
    this.shape.position(this.mat.point({ x: h, y: l })).scale(f), this.shape.draw();
  }
  setPixelScale(t, e) {
    t = t.copy().invert();
    const i = t.point({ x: 0, y: 0 }), n = t.point({ x: e[0], y: e[1] });
    this.mat = t, this.pixelScale = this.getScaleUnit([
      (n.x - i.x) / e[0],
      (n.y - i.y) / e[1]
    ]);
  }
  initReactive() {
    const t = ({ mat: e, size: i }) => {
      this.setPixelScale(e, i);
    };
    return this.container.bus.on("viewChange", t), _r(
      super.initReactive(),
      () => this.container.bus.off("viewChange", t)
    );
  }
  mounted() {
    super.mounted();
    const t = this.container.stage;
    this.setPixelScale(we(t, !0), [
      t.width(),
      t.height()
    ]), console.log(t), t.on("click", (e) => {
      console.log(
        this.container.getRealFromStage([e.evt.offsetX, e.evt.offsetY])
      );
    });
  }
}
const qu = (s, t, e) => {
  let i = e == null ? void 0 : e.getView();
  const n = () => i.calculateExtent(e.getSize()), r = (h) => {
    const l = $u([
      [h[0], h[1]],
      [h[2], h[3]]
    ]);
    i.fit(l, {
      size: e.getSize(),
      padding: [0, 0, 0, 0]
      // 根据需要调整边距
    });
  }, a = () => {
    if (t && e) {
      const h = n();
      (!s.bound || di(s.bound, h)) && (s.setSize(t.offsetWidth, t.offsetHeight), s.setBound([h[0], h[3], h[2], h[1]]));
    }
  }, o = (h) => {
    e && (i.removeEventListener("change:center", a), i.removeEventListener("change:resolution", a), e.removeEventListener("moveend", a)), i = h.getView(), i.addEventListener("change:center", a), i.addEventListener("change:resolution", a), e.addEventListener("moveend", a), e = h, a();
  };
  return s.enableMove((h) => (e && r(h), !0)), s.enableWheel((h) => (e && r(h), !0)), {
    setMap: o,
    setBoardBound: a,
    setMountDom(h) {
      t = h, a();
    },
    destory() {
      i.removeEventListener("change:center", a), i.removeEventListener("change:resolution", a), e.removeEventListener("moveend", a);
    }
  };
};
function Qu(s, t, e) {
  const i = t.getSize();
  s.width = i[0] * e, s.height = i[1] * e, s.style.width = i[0] + "px", s.style.height = i[1] + "px";
  const n = s.getContext("2d"), r = t.getViewport().querySelector("canvas");
  return n.drawImage(r, 0, 0, s.width, s.height), s.toDataURL();
}
const Ku = bu(
  { polygons: Vu, compass: pn, scale: ju },
  { bound: new Cu() }
);
Xd(5e6);
const C1 = (s = {}) => {
  const t = {
    id: "0",
    x: 0,
    y: 0,
    type: "compass"
  }, e = {
    id: "0",
    left: 20,
    bottom: 20,
    minWidth: 100,
    maxWidth: 150
  }, i = s.store || [
    { id: "0", points: [], polygons: [], lines: [] }
  ], n = Ku(s.dom, { polygons: i, compass: t, scale: e }, !1), r = qu(n.bound, s.dom, s.map), a = (l = {}) => {
    l.dom && (n.mount(l.dom), r.setMountDom(l.dom)), l.map && r.setMap(l.map);
  };
  a(s);
  let o;
  const h = n.tree.entrys.scale[0];
  return h.allowable = 0.01, h.getScaleUnit = (l) => {
    if (!s.map)
      return;
    const f = s.map.getView().getProjection().getMetersPerUnit();
    return l[0] * f;
  }, h.getScaleText = (l) => {
    if (l > 1e3) {
      let A = Ot(l / 1e3, 1), u = A % 1;
      return A = Math.floor(A) + (u > 0.5 ? 1 : u < 0.5 ? -1 : 0.5), A + " km";
    } else
      return Math.floor(l) + " m";
  }, {
    raw: n,
    scale: h,
    setProps: a,
    getData() {
      return n.getData().polygons[0];
    },
    setData(l) {
      n.setData({ polygons: [l], compass: t, scale: e });
    },
    destory() {
      r.destory(), n.destory();
    },
    get polygon() {
      return n.tree.children[0];
    },
    getPixelFromCoordinate(l) {
      return n.tree.getPixelFromStage(l);
    },
    async toDataURL(l = 1) {
      const A = n.tree.stage.toDataURL({ pixelRatio: l });
      if (!s.map)
        return A;
      const u = [n.tree.stage.width(), n.tree.stage.height()];
      o || (o = document.createElement("canvas")), o.width = u[0] * l, o.height = u[1] * l, o.style.width = u[0] + "px", o.style.height = u[1] + "px";
      const f = o.getContext("2d");
      return f.clearRect(0, 0, o.width, o.height), f.save(), Qu(o, s.map, l), f.restore(), new Promise((c, d) => {
        const p = new Image();
        p.src = A, p.onload = () => {
          f.drawImage(
            p,
            0,
            0,
            o.width,
            o.height
          );
          const m = o.toDataURL("image/png");
          c(m);
        }, p.onerror = d;
      });
    }
  };
};
export {
  Cu as BoundQueryPlugin,
  S1 as CameraQueryPlugin,
  vu as Container,
  qt as DEV,
  b1 as EditPoi,
  _1 as EditWholeLine,
  ie as Entity,
  w1 as HistoryPlugin,
  x1 as PenEditWholeLine,
  zu as PoPath,
  Gu as PoPoint,
  pn as Poi,
  cr as PointTypeEnum,
  Vu as Polygons,
  xo as RelationshipEnum,
  Ri as WholeLine,
  Qt as WholeLineLine,
  or as WholeLineLineHelper,
  Tt as WholeLinePoint,
  hr as WholeLinePointHelper,
  Li as WholeLinePolygon,
  u1 as addEntityAttrib,
  Fl as analysisSvg,
  Ju as changeEnv,
  yu as closePenPolygonActShapeFactory,
  qA as copyEntityAttrib,
  C1 as createBoard,
  Ke as createLineByDire,
  _u as defaultPoiShapeFactory,
  Ts as depPartialUpdate,
  A1 as deptComputed,
  So as disableMouse,
  Co as enableMouse,
  QA as entityActiveDualControl,
  jA as entityFactory,
  g1 as entitysActiveDualControl,
  oe as eqPoint,
  Ws as fixWholeLineConfig,
  $A as generateId,
  oh as generateWholeLineLineId,
  hh as generateWholeLinePointId,
  lh as generateWholeLinePoygonId,
  we as getAbsoluteTransform,
  Is as getActiveKey,
  Rn as getChangeAllPoart,
  Eo as getChangePart,
  Xe as getDire2Angle,
  i1 as getDireDist,
  Fo as getFlatChildren,
  NA as getLine2Angle,
  s1 as getLineCenter,
  ce as getLineDire,
  GA as getLineDireAngle,
  Et as getLineDist,
  a1 as getLineInnerContinuityPoints,
  wo as getLineIntersection,
  BA as getLineNearPoint,
  zA as getLineNearPointDist,
  Ui as getLineProjection,
  bo as getLineRelationship,
  Gt as getRealAbsoluteSize,
  RA as getRotateDire,
  t1 as getTfScaleFactors,
  ho as getTouchOffset,
  OA as getVerticaLineDire,
  mr as getVerticalDire,
  n1 as getVerticalDireLine,
  pi as getWholeLineLine,
  fh as getWholeLineLineNdxByPointIds,
  wt as getWholeLineLineRaw,
  y1 as getWholeLineLines,
  m1 as getWholeLineLinesByPointId,
  ch as getWholeLineLinesRaw,
  qd as getWholeLineLinesRawByPoint,
  Ah as getWholeLineLinesRawByPointId,
  jd as getWholeLineLinesRawByPointIds,
  Pe as getWholeLinePoint,
  ru as getWholeLinePointMerge,
  _t as getWholeLinePoints,
  v1 as getWholeLinePolygonByPoint,
  Qd as getWholeLinePolygonLines,
  uh as getWholeLinePolygonLinesByPoint,
  dh as getWholeLinePolygonLinesRaw,
  ri as getWholeLinePolygonPoints,
  yi as getWholeLinePolygonRaw,
  hn as hasTouchEvents,
  di as inRevise,
  Pt as incEntitysFactoryGenerate,
  xu as injectPoiType,
  UA as isLineIntersectingPolygon,
  ro as isMobile,
  yl as isTablet,
  Si as mergeChange,
  _r as mergeFuns,
  au as mergeWholeLinePointsByPoint,
  fu as needUpdatePolygonClose,
  HA as objectToString,
  ln as openEntityDrag,
  vr as openShapeDrag,
  _a as openShapeMouseStyles,
  c1 as partialComputed,
  kl as pathsToActShape,
  pu as penLineActShapeFactory,
  mu as penPolygonActShapeFactory,
  Qa as penWholeLinePoygonsEdit,
  uu as penWholeLinePoygonsEditWithHelperMouse,
  Or as penWholeLinePoygonsEditWithHelperShapesMouse,
  vh as poiTypes,
  Ys as pointColorMap,
  r1 as polygonCounterclockwise,
  bu as register,
  ou as repeatMoveWholeLineLine,
  iu as repeatablePushWholeLinePoint,
  nu as repeatableWholeLineLineIntersections,
  Ot as round,
  Xd as setGenerateStartId,
  h1 as setShapeConfig,
  Po as shapeParentsEq,
  o1 as shapeTreeContain,
  Mo as shapeTreeEq,
  su as spliceWholeLineLineByLines,
  $s as spliceWholeLineLineByPoint,
  d1 as testPoint,
  An as toRawType,
  VA as toTypeString,
  f1 as updateEntityStatus,
  l1 as watchAttribs,
  fe as wholeLineAddLineByPointIds,
  Ze as wholeLineAddPoint,
  gu as wholeLineAnalysisHelperInfo,
  ai as wholeLineDelLineByPointIds,
  Xa as wholeLineDelPointByPointIds,
  gh as wholeLineDelPolygon,
  Jd as wholeLineFixLineAddPoint,
  lr as wholeLineLineAddPoint,
  Kd as wholeLineLineIsolatePoint,
  eu as wholeLinePolygonAddPoint,
  tu as wholeLinePolygonLastAddPoint,
  Ar as wholeLineReplacePoint,
  p1 as wholeLineStyle
};
