react-mindee-js
Version:
Front-End Computer Vision SDK for React
1,518 lines • 2.33 MB
JavaScript
var ea = Object.defineProperty;
var aa = (s, r, e) => r in s ? ea(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
var ar = (s, r, e) => (aa(s, typeof r != "symbol" ? r + "" : r, e), e), Pr = (s, r, e) => {
if (!r.has(s))
throw TypeError("Cannot " + e);
};
var F = (s, r, e) => (Pr(s, r, "read from private field"), e ? e.call(s) : r.get(s)), l0 = (s, r, e) => {
if (r.has(s))
throw TypeError("Cannot add the same private member more than once");
r instanceof WeakSet ? r.add(s) : r.set(s, e);
}, C0 = (s, r, e, a) => (Pr(s, r, "write to private field"), a ? a.call(s, e) : r.set(s, e), e);
var gr = (s, r, e, a) => ({
set _(t) {
C0(s, r, t, e);
},
get _() {
return F(s, r, a);
}
}), p0 = (s, r, e) => (Pr(s, r, "access private method"), e);
import require$$0, { useRef, useEffect } from "react";
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function getDefaultExportFromCjs(s) {
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
function getAugmentedNamespace(s) {
if (s.__esModule)
return s;
var r = s.default;
if (typeof r == "function") {
var e = function a() {
return this instanceof a ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
};
e.prototype = r.prototype;
} else
e = {};
return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(s).forEach(function(a) {
var t = Object.getOwnPropertyDescriptor(s, a);
Object.defineProperty(e, a, t.get ? t : {
enumerable: !0,
get: function() {
return s[a];
}
});
}), e;
}
var jsxRuntime = { exports: {} }, reactJsxRuntime_production = {};
/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactJsxRuntime_production;
function requireReactJsxRuntime_production() {
if (hasRequiredReactJsxRuntime_production)
return reactJsxRuntime_production;
hasRequiredReactJsxRuntime_production = 1;
var s = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
function e(a, t, f) {
var n = null;
if (f !== void 0 && (n = "" + f), t.key !== void 0 && (n = "" + t.key), "key" in t) {
f = {};
for (var o in t)
o !== "key" && (f[o] = t[o]);
} else
f = t;
return t = f.ref, {
$$typeof: s,
type: a,
key: n,
ref: t !== void 0 ? t : null,
props: f
};
}
return reactJsxRuntime_production.Fragment = r, reactJsxRuntime_production.jsx = e, reactJsxRuntime_production.jsxs = e, reactJsxRuntime_production;
}
var reactJsxRuntime_development = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var hasRequiredReactJsxRuntime_development;
function requireReactJsxRuntime_development() {
return hasRequiredReactJsxRuntime_development || (hasRequiredReactJsxRuntime_development = 1, process.env.NODE_ENV !== "production" && function() {
function s(O) {
if (O == null)
return null;
if (typeof O == "function")
return O.$$typeof === W ? null : O.displayName || O.name || null;
if (typeof O == "string")
return O;
switch (O) {
case b:
return "Fragment";
case w:
return "Profiler";
case _:
return "StrictMode";
case y:
return "Suspense";
case G:
return "SuspenseList";
case M:
return "Activity";
}
if (typeof O == "object")
switch (typeof O.tag == "number" && console.error(
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
), O.$$typeof) {
case m:
return "Portal";
case C:
return O.displayName || "Context";
case p:
return (O._context.displayName || "Context") + ".Consumer";
case d:
var a0 = O.render;
return O = O.displayName, O || (O = a0.displayName || a0.name || "", O = O !== "" ? "ForwardRef(" + O + ")" : "ForwardRef"), O;
case Z:
return a0 = O.displayName || null, a0 !== null ? a0 : s(O.type) || "Memo";
case R:
a0 = O._payload, O = O._init;
try {
return s(O(a0));
} catch {
}
}
return null;
}
function r(O) {
return "" + O;
}
function e(O) {
try {
r(O);
var a0 = !1;
} catch {
a0 = !0;
}
if (a0) {
a0 = console;
var P = a0.error, k = typeof Symbol == "function" && Symbol.toStringTag && O[Symbol.toStringTag] || O.constructor.name || "Object";
return P.call(
a0,
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
k
), r(O);
}
}
function a(O) {
if (O === b)
return "<>";
if (typeof O == "object" && O !== null && O.$$typeof === R)
return "<...>";
try {
var a0 = s(O);
return a0 ? "<" + a0 + ">" : "<...>";
} catch {
return "<...>";
}
}
function t() {
var O = Y.A;
return O === null ? null : O.getOwner();
}
function f() {
return Error("react-stack-top-frame");
}
function n(O) {
if (U.call(O, "key")) {
var a0 = Object.getOwnPropertyDescriptor(O, "key").get;
if (a0 && a0.isReactWarning)
return !1;
}
return O.key !== void 0;
}
function o(O, a0) {
function P() {
A0 || (A0 = !0, console.error(
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
a0
));
}
P.isReactWarning = !0, Object.defineProperty(O, "key", {
get: P,
configurable: !0
});
}
function A() {
var O = s(this.type);
return s0[O] || (s0[O] = !0, console.error(
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
)), O = this.props.ref, O !== void 0 ? O : null;
}
function l(O, a0, P, k, I, B) {
var N = P.ref;
return O = {
$$typeof: g,
type: O,
key: a0,
props: P,
_owner: k
}, (N !== void 0 ? N : null) !== null ? Object.defineProperty(O, "ref", {
enumerable: !1,
get: A
}) : Object.defineProperty(O, "ref", { enumerable: !1, value: null }), O._store = {}, Object.defineProperty(O._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: 0
}), Object.defineProperty(O, "_debugInfo", {
configurable: !1,
enumerable: !1,
writable: !0,
value: null
}), Object.defineProperty(O, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: I
}), Object.defineProperty(O, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: B
}), Object.freeze && (Object.freeze(O.props), Object.freeze(O)), O;
}
function u(O, a0, P, k, I, B) {
var N = a0.children;
if (N !== void 0)
if (k)
if (L(N)) {
for (k = 0; k < N.length; k++)
h(N[k]);
Object.freeze && Object.freeze(N);
} else
console.error(
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
);
else
h(N);
if (U.call(a0, "key")) {
N = s(O);
var D = Object.keys(a0).filter(function(K) {
return K !== "key";
});
k = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", Q[N + k] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,
k,
N,
D,
N
), Q[N + k] = !0);
}
if (N = null, P !== void 0 && (e(P), N = "" + P), n(a0) && (e(a0.key), N = "" + a0.key), "key" in a0) {
P = {};
for (var H in a0)
H !== "key" && (P[H] = a0[H]);
} else
P = a0;
return N && o(
P,
typeof O == "function" ? O.displayName || O.name || "Unknown" : O
), l(
O,
N,
P,
t(),
I,
B
);
}
function h(O) {
c(O) ? O._store && (O._store.validated = 1) : typeof O == "object" && O !== null && O.$$typeof === R && (O._payload.status === "fulfilled" ? c(O._payload.value) && O._payload.value._store && (O._payload.value._store.validated = 1) : O._store && (O._store.validated = 1));
}
function c(O) {
return typeof O == "object" && O !== null && O.$$typeof === g;
}
var v = require$$0, g = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), _ = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), p = Symbol.for("react.consumer"), C = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), y = Symbol.for("react.suspense"), G = Symbol.for("react.suspense_list"), Z = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), W = Symbol.for("react.client.reference"), Y = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, L = Array.isArray, r0 = console.createTask ? console.createTask : function() {
return null;
};
v = {
react_stack_bottom_frame: function(O) {
return O();
}
};
var A0, s0 = {}, E = v.react_stack_bottom_frame.bind(
v,
f
)(), V = r0(a(f)), Q = {};
reactJsxRuntime_development.Fragment = b, reactJsxRuntime_development.jsx = function(O, a0, P) {
var k = 1e4 > Y.recentlyCreatedOwnerStacks++;
return u(
O,
a0,
P,
!1,
k ? Error("react-stack-top-frame") : E,
k ? r0(a(O)) : V
);
}, reactJsxRuntime_development.jsxs = function(O, a0, P) {
var k = 1e4 > Y.recentlyCreatedOwnerStacks++;
return u(
O,
a0,
P,
!0,
k ? Error("react-stack-top-frame") : E,
k ? r0(a(O)) : V
);
};
}()), reactJsxRuntime_development;
}
process.env.NODE_ENV === "production" ? jsxRuntime.exports = requireReactJsxRuntime_production() : jsxRuntime.exports = requireReactJsxRuntime_development();
var jsxRuntimeExports = jsxRuntime.exports, PI_OVER_180 = Math.PI / 180;
function detectBrowser() {
return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
}
const glob = typeof global < "u" ? global : typeof window < "u" ? window : typeof WorkerGlobalScope < "u" ? self : {}, Konva$2 = {
_global: glob,
version: "8.4.3",
isBrowser: detectBrowser(),
isUnminified: /param/.test((function(s) {
}).toString()),
dblClickWindow: 400,
getAngle(s) {
return Konva$2.angleDeg ? s * PI_OVER_180 : s;
},
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 Konva$2.DD.isDragging;
},
isDragReady() {
return !!Konva$2.DD.node;
},
releaseCanvasOnDestroy: !0,
document: glob.document,
_injectGlobal(s) {
glob.Konva = s;
}
}, _registerNode = (s) => {
Konva$2[s.prototype.getClassName()] = s;
};
Konva$2._injectGlobal(Konva$2);
class Transform {
constructor(r = [1, 0, 0, 1, 0, 0]) {
this.dirty = !1, this.m = r && r.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 Transform(this.m);
}
copyInto(r) {
r.m[0] = this.m[0], r.m[1] = this.m[1], r.m[2] = this.m[2], r.m[3] = this.m[3], r.m[4] = this.m[4], r.m[5] = this.m[5];
}
point(r) {
var e = this.m;
return {
x: e[0] * r.x + e[2] * r.y + e[4],
y: e[1] * r.x + e[3] * r.y + e[5]
};
}
translate(r, e) {
return this.m[4] += this.m[0] * r + this.m[2] * e, this.m[5] += this.m[1] * r + this.m[3] * e, this;
}
scale(r, e) {
return this.m[0] *= r, this.m[1] *= r, this.m[2] *= e, this.m[3] *= e, this;
}
rotate(r) {
var e = Math.cos(r), a = Math.sin(r), t = this.m[0] * e + this.m[2] * a, f = this.m[1] * e + this.m[3] * a, n = this.m[0] * -a + this.m[2] * e, o = this.m[1] * -a + this.m[3] * e;
return this.m[0] = t, this.m[1] = f, this.m[2] = n, this.m[3] = o, this;
}
getTranslation() {
return {
x: this.m[4],
y: this.m[5]
};
}
skew(r, e) {
var a = this.m[0] + this.m[2] * e, t = this.m[1] + this.m[3] * e, f = this.m[2] + this.m[0] * r, n = this.m[3] + this.m[1] * r;
return this.m[0] = a, this.m[1] = t, this.m[2] = f, this.m[3] = n, this;
}
multiply(r) {
var e = this.m[0] * r.m[0] + this.m[2] * r.m[1], a = this.m[1] * r.m[0] + this.m[3] * r.m[1], t = this.m[0] * r.m[2] + this.m[2] * r.m[3], f = this.m[1] * r.m[2] + this.m[3] * r.m[3], n = this.m[0] * r.m[4] + this.m[2] * r.m[5] + this.m[4], o = this.m[1] * r.m[4] + this.m[3] * r.m[5] + this.m[5];
return this.m[0] = e, this.m[1] = a, this.m[2] = t, this.m[3] = f, this.m[4] = n, this.m[5] = o, this;
}
invert() {
var r = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]), e = this.m[3] * r, a = -this.m[1] * r, t = -this.m[2] * r, f = this.m[0] * r, n = r * (this.m[2] * this.m[5] - this.m[3] * this.m[4]), o = r * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
return this.m[0] = e, this.m[1] = a, this.m[2] = t, this.m[3] = f, this.m[4] = n, this.m[5] = o, this;
}
getMatrix() {
return this.m;
}
decompose() {
var r = this.m[0], e = this.m[1], a = this.m[2], t = this.m[3], f = this.m[4], n = this.m[5], o = r * t - e * a;
let A = {
x: f,
y: n,
rotation: 0,
scaleX: 0,
scaleY: 0,
skewX: 0,
skewY: 0
};
if (r != 0 || e != 0) {
var l = Math.sqrt(r * r + e * e);
A.rotation = e > 0 ? Math.acos(r / l) : -Math.acos(r / l), A.scaleX = l, A.scaleY = o / l, A.skewX = (r * a + e * t) / o, A.skewY = 0;
} else if (a != 0 || t != 0) {
var u = Math.sqrt(a * a + t * t);
A.rotation = Math.PI / 2 - (t > 0 ? Math.acos(-a / u) : -Math.acos(a / u)), A.scaleX = o / u, A.scaleY = u, A.skewX = 0, A.skewY = (r * a + e * t) / o;
}
return A.rotation = Util._getRotation(A.rotation), A;
}
}
var OBJECT_ARRAY = "[object Array]", OBJECT_NUMBER = "[object Number]", OBJECT_STRING = "[object String]", OBJECT_BOOLEAN = "[object Boolean]", PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH$1 = "#", EMPTY_STRING$1 = "", ZERO = "0", KONVA_WARNING = "Konva warning: ", KONVA_ERROR = "Konva error: ", RGB_PAREN = "rgb(", COLORS = {
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]
}, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/, animQueue = [];
const req = typeof requestAnimationFrame < "u" && requestAnimationFrame || function(s) {
setTimeout(s, 60);
}, Util = {
_isElement(s) {
return !!(s && s.nodeType == 1);
},
_isFunction(s) {
return !!(s && s.constructor && s.call && s.apply);
},
_isPlainObject(s) {
return !!s && s.constructor === Object;
},
_isArray(s) {
return Object.prototype.toString.call(s) === OBJECT_ARRAY;
},
_isNumber(s) {
return Object.prototype.toString.call(s) === OBJECT_NUMBER && !isNaN(s) && isFinite(s);
},
_isString(s) {
return Object.prototype.toString.call(s) === OBJECT_STRING;
},
_isBoolean(s) {
return Object.prototype.toString.call(s) === OBJECT_BOOLEAN;
},
isObject(s) {
return s instanceof Object;
},
isValidSelector(s) {
if (typeof s != "string")
return !1;
var r = s[0];
return r === "#" || r === "." || r === r.toUpperCase();
},
_sign(s) {
return s === 0 || s > 0 ? 1 : -1;
},
requestAnimFrame(s) {
animQueue.push(s), animQueue.length === 1 && req(function() {
const r = animQueue;
animQueue = [], r.forEach(function(e) {
e();
});
});
},
createCanvasElement() {
var s = document.createElement("canvas");
try {
s.style = s.style || {};
} catch {
}
return s;
},
createImageElement() {
return document.createElement("img");
},
_isInDocument(s) {
for (; s = s.parentNode; )
if (s == document)
return !0;
return !1;
},
_urlToImage(s, r) {
var e = Util.createImageElement();
e.onload = function() {
r(e);
}, e.src = s;
},
_rgbToHex(s, r, e) {
return ((1 << 24) + (s << 16) + (r << 8) + e).toString(16).slice(1);
},
_hexToRgb(s) {
s = s.replace(HASH$1, EMPTY_STRING$1);
var r = parseInt(s, 16);
return {
r: r >> 16 & 255,
g: r >> 8 & 255,
b: r & 255
};
},
getRandomColor() {
for (var s = (Math.random() * 16777215 << 0).toString(16); s.length < 6; )
s = ZERO + s;
return HASH$1 + s;
},
getRGB(s) {
var r;
return s in COLORS ? (r = COLORS[s], {
r: r[0],
g: r[1],
b: r[2]
}) : s[0] === HASH$1 ? this._hexToRgb(s.substring(1)) : s.substr(0, 4) === RGB_PAREN ? (r = RGB_REGEX.exec(s.replace(/ /g, "")), {
r: parseInt(r[1], 10),
g: parseInt(r[2], 10),
b: parseInt(r[3], 10)
}) : {
r: 0,
g: 0,
b: 0
};
},
colorToRGBA(s) {
return s = s || "black", Util._namedColorToRBA(s) || Util._hex3ColorToRGBA(s) || Util._hex4ColorToRGBA(s) || Util._hex6ColorToRGBA(s) || Util._hex8ColorToRGBA(s) || Util._rgbColorToRGBA(s) || Util._rgbaColorToRGBA(s) || Util._hslColorToRGBA(s);
},
_namedColorToRBA(s) {
var r = COLORS[s.toLowerCase()];
return r ? {
r: r[0],
g: r[1],
b: r[2],
a: 1
} : null;
},
_rgbColorToRGBA(s) {
if (s.indexOf("rgb(") === 0) {
s = s.match(/rgb\(([^)]+)\)/)[1];
var r = s.split(/ *, */).map(Number);
return {
r: r[0],
g: r[1],
b: r[2],
a: 1
};
}
},
_rgbaColorToRGBA(s) {
if (s.indexOf("rgba(") === 0) {
s = s.match(/rgba\(([^)]+)\)/)[1];
var r = s.split(/ *, */).map((e, a) => e.slice(-1) === "%" ? a === 3 ? parseInt(e) / 100 : parseInt(e) / 100 * 255 : Number(e));
return {
r: r[0],
g: r[1],
b: r[2],
a: r[3]
};
}
},
_hex8ColorToRGBA(s) {
if (s[0] === "#" && s.length === 9)
return {
r: parseInt(s.slice(1, 3), 16),
g: parseInt(s.slice(3, 5), 16),
b: parseInt(s.slice(5, 7), 16),
a: parseInt(s.slice(7, 9), 16) / 255
};
},
_hex6ColorToRGBA(s) {
if (s[0] === "#" && s.length === 7)
return {
r: parseInt(s.slice(1, 3), 16),
g: parseInt(s.slice(3, 5), 16),
b: parseInt(s.slice(5, 7), 16),
a: 1
};
},
_hex4ColorToRGBA(s) {
if (s[0] === "#" && s.length === 5)
return {
r: parseInt(s[1] + s[1], 16),
g: parseInt(s[2] + s[2], 16),
b: parseInt(s[3] + s[3], 16),
a: parseInt(s[4] + s[4], 16) / 255
};
},
_hex3ColorToRGBA(s) {
if (s[0] === "#" && s.length === 4)
return {
r: parseInt(s[1] + s[1], 16),
g: parseInt(s[2] + s[2], 16),
b: parseInt(s[3] + s[3], 16),
a: 1
};
},
_hslColorToRGBA(s) {
if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(s)) {
const [r, ...e] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(s), a = Number(e[0]) / 360, t = Number(e[1]) / 100, f = Number(e[2]) / 100;
let n, o, A;
if (t === 0)
return A = f * 255, {
r: Math.round(A),
g: Math.round(A),
b: Math.round(A),
a: 1
};
f < 0.5 ? n = f * (1 + t) : n = f + t - f * t;
const l = 2 * f - n, u = [0, 0, 0];
for (let h = 0; h < 3; h++)
o = a + 1 / 3 * -(h - 1), o < 0 && o++, o > 1 && o--, 6 * o < 1 ? A = l + (n - l) * 6 * o : 2 * o < 1 ? A = n : 3 * o < 2 ? A = l + (n - l) * (2 / 3 - o) * 6 : A = l, u[h] = A * 255;
return {
r: Math.round(u[0]),
g: Math.round(u[1]),
b: Math.round(u[2]),
a: 1
};
}
},
haveIntersection(s, r) {
return !(r.x > s.x + s.width || r.x + r.width < s.x || r.y > s.y + s.height || r.y + r.height < s.y);
},
cloneObject(s) {
var r = {};
for (var e in s)
this._isPlainObject(s[e]) ? r[e] = this.cloneObject(s[e]) : this._isArray(s[e]) ? r[e] = this.cloneArray(s[e]) : r[e] = s[e];
return r;
},
cloneArray(s) {
return s.slice(0);
},
degToRad(s) {
return s * PI_OVER_DEG180;
},
radToDeg(s) {
return s * DEG180_OVER_PI;
},
_degToRad(s) {
return Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."), Util.degToRad(s);
},
_radToDeg(s) {
return Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."), Util.radToDeg(s);
},
_getRotation(s) {
return Konva$2.angleDeg ? Util.radToDeg(s) : s;
},
_capitalize(s) {
return s.charAt(0).toUpperCase() + s.slice(1);
},
throw(s) {
throw new Error(KONVA_ERROR + s);
},
error(s) {
console.error(KONVA_ERROR + s);
},
warn(s) {
Konva$2.showWarnings && console.warn(KONVA_WARNING + s);
},
each(s, r) {
for (var e in s)
r(e, s[e]);
},
_inRange(s, r, e) {
return r <= s && s < e;
},
_getProjectionToSegment(s, r, e, a, t, f) {
var n, o, A, l = (s - e) * (s - e) + (r - a) * (r - a);
if (l == 0)
n = s, o = r, A = (t - e) * (t - e) + (f - a) * (f - a);
else {
var u = ((t - s) * (e - s) + (f - r) * (a - r)) / l;
u < 0 ? (n = s, o = r, A = (s - t) * (s - t) + (r - f) * (r - f)) : u > 1 ? (n = e, o = a, A = (e - t) * (e - t) + (a - f) * (a - f)) : (n = s + u * (e - s), o = r + u * (a - r), A = (n - t) * (n - t) + (o - f) * (o - f));
}
return [n, o, A];
},
_getProjectionToLine(s, r, e) {
var a = Util.cloneObject(s), t = Number.MAX_VALUE;
return r.forEach(function(f, n) {
if (!(!e && n === r.length - 1)) {
var o = r[(n + 1) % r.length], A = Util._getProjectionToSegment(f.x, f.y, o.x, o.y, s.x, s.y), l = A[0], u = A[1], h = A[2];
h < t && (a.x = l, a.y = u, t = h);
}
}), a;
},
_prepareArrayForTween(s, r, e) {
var a, t = [], f = [];
if (s.length > r.length) {
var n = r;
r = s, s = n;
}
for (a = 0; a < s.length; a += 2)
t.push({
x: s[a],
y: s[a + 1]
});
for (a = 0; a < r.length; a += 2)
f.push({
x: r[a],
y: r[a + 1]
});
var o = [];
return f.forEach(function(A) {
var l = Util._getProjectionToLine(A, t, e);
o.push(l.x), o.push(l.y);
}), o;
},
_prepareToStringify(s) {
var r;
s.visitedByCircularReferenceRemoval = !0;
for (var e in s)
if (s.hasOwnProperty(e) && s[e] && typeof s[e] == "object") {
if (r = Object.getOwnPropertyDescriptor(s, e), s[e].visitedByCircularReferenceRemoval || Util._isElement(s[e]))
if (r.configurable)
delete s[e];
else
return null;
else if (Util._prepareToStringify(s[e]) === null)
if (r.configurable)
delete s[e];
else
return null;
}
return delete s.visitedByCircularReferenceRemoval, s;
},
_assign(s, r) {
for (var e in r)
s[e] = r[e];
return s;
},
_getFirstPointerId(s) {
return s.touches ? s.changedTouches[0].identifier : s.pointerId || 999;
},
releaseCanvas(...s) {
Konva$2.releaseCanvasOnDestroy && s.forEach((r) => {
r.width = 0, r.height = 0;
});
},
drawRoundedRectPath(s, r, e, a) {
let t = 0, f = 0, n = 0, o = 0;
typeof a == "number" ? t = f = n = o = Math.min(a, r / 2, e / 2) : (t = Math.min(a[0] || 0, r / 2, e / 2), f = Math.min(a[1] || 0, r / 2, e / 2), o = Math.min(a[2] || 0, r / 2, e / 2), n = Math.min(a[3] || 0, r / 2, e / 2)), s.moveTo(t, 0), s.lineTo(r - f, 0), s.arc(r - f, f, f, Math.PI * 3 / 2, 0, !1), s.lineTo(r, e - o), s.arc(r - o, e - o, o, 0, Math.PI / 2, !1), s.lineTo(n, e), s.arc(n, e - n, n, Math.PI / 2, Math.PI, !1), s.lineTo(0, t), s.arc(t, t, t, Math.PI, Math.PI * 3 / 2, !1);
}
};
function _formatValue(s) {
return Util._isString(s) ? '"' + s + '"' : Object.prototype.toString.call(s) === "[object Number]" || Util._isBoolean(s) ? s : Object.prototype.toString.call(s);
}
function RGBComponent(s) {
return s > 255 ? 255 : s < 0 ? 0 : Math.round(s);
}
function getNumberValidator() {
if (Konva$2.isUnminified)
return function(s, r) {
return Util._isNumber(s) || Util.warn(_formatValue(s) + ' is a not valid value for "' + r + '" attribute. The value should be a number.'), s;
};
}
function getNumberOrArrayOfNumbersValidator(s) {
if (Konva$2.isUnminified)
return function(r, e) {
let a = Util._isNumber(r), t = Util._isArray(r) && r.length == s;
return !a && !t && Util.warn(_formatValue(r) + ' is a not valid value for "' + e + '" attribute. The value should be a number or Array<number>(' + s + ")"), r;
};
}
function getNumberOrAutoValidator() {
if (Konva$2.isUnminified)
return function(s, r) {
var e = Util._isNumber(s), a = s === "auto";
return e || a || Util.warn(_formatValue(s) + ' is a not valid value for "' + r + '" attribute. The value should be a number or "auto".'), s;
};
}
function getStringValidator() {
if (Konva$2.isUnminified)
return function(s, r) {
return Util._isString(s) || Util.warn(_formatValue(s) + ' is a not valid value for "' + r + '" attribute. The value should be a string.'), s;
};
}
function getStringOrGradientValidator() {
if (Konva$2.isUnminified)
return function(s, r) {
const e = Util._isString(s), a = Object.prototype.toString.call(s) === "[object CanvasGradient]" || s && s.addColorStop;
return e || a || Util.warn(_formatValue(s) + ' is a not valid value for "' + r + '" attribute. The value should be a string or a native gradient.'), s;
};
}
function getNumberArrayValidator() {
if (Konva$2.isUnminified)
return function(s, r) {
const e = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
return e && s instanceof e || (Util._isArray(s) ? s.forEach(function(a) {
Util._isNumber(a) || Util.warn('"' + r + '" attribute has non numeric element ' + a + ". Make sure that all elements are numbers.");
}) : Util.warn(_formatValue(s) + ' is a not valid value for "' + r + '" attribute. The value should be a array of numbers.')), s;
};
}
function getBooleanValidator() {
if (Konva$2.isUnminified)
return function(s, r) {
var e = s === !0 || s === !1;
return e || Util.warn(_formatValue(s) + ' is a not valid value for "' + r + '" attribute. The value should be a boolean.'), s;
};
}
function getComponentValidator(s) {
if (Konva$2.isUnminified)
return function(r, e) {
return r == null || Util.isObject(r) || Util.warn(_formatValue(r) + ' is a not valid value for "' + e + '" attribute. The value should be an object with properties ' + s), r;
};
}
var GET = "get", SET$1 = "set";
const Factory = {
addGetterSetter(s, r, e, a, t) {
Factory.addGetter(s, r, e), Factory.addSetter(s, r, a, t), Factory.addOverloadedGetterSetter(s, r);
},
addGetter(s, r, e) {
var a = GET + Util._capitalize(r);
s.prototype[a] = s.prototype[a] || function() {
var t = this.attrs[r];
return t === void 0 ? e : t;
};
},
addSetter(s, r, e, a) {
var t = SET$1 + Util._capitalize(r);
s.prototype[t] || Factory.overWriteSetter(s, r, e, a);
},
overWriteSetter(s, r, e, a) {
var t = SET$1 + Util._capitalize(r);
s.prototype[t] = function(f) {
return e && f !== void 0 && f !== null && (f = e.call(this, f, r)), this._setAttr(r, f), a && a.call(this), this;
};
},
addComponentsGetterSetter(s, r, e, a, t) {
var f = e.length, n = Util._capitalize, o = GET + n(r), A = SET$1 + n(r), l, u;
s.prototype[o] = function() {
var c = {};
for (l = 0; l < f; l++)
u = e[l], c[u] = this.getAttr(r + n(u));
return c;
};
var h = getComponentValidator(e);
s.prototype[A] = function(c) {
var v = this.attrs[r], g;
a && (c = a.call(this, c)), h && h.call(this, c, r);
for (g in c)
c.hasOwnProperty(g) && this._setAttr(r + n(g), c[g]);
return c || e.forEach((m) => {
this._setAttr(r + n(m), void 0);
}), this._fireChangeEvent(r, v, c), t && t.call(this), this;
}, Factory.addOverloadedGetterSetter(s, r);
},
addOverloadedGetterSetter(s, r) {
var e = Util._capitalize(r), a = SET$1 + e, t = GET + e;
s.prototype[r] = function() {
return arguments.length ? (this[a](arguments[0]), this) : this[t]();
};
},
addDeprecatedGetterSetter(s, r, e, a) {
Util.error("Adding deprecated " + r);
var t = GET + Util._capitalize(r), f = r + " property is deprecated and will be removed soon. Look at Konva change log for more information.";
s.prototype[t] = function() {
Util.error(f);
var n = this.attrs[r];
return n === void 0 ? e : n;
}, Factory.addSetter(s, r, a, function() {
Util.error(f);
}), Factory.addOverloadedGetterSetter(s, r);
},
backCompat(s, r) {
Util.each(r, function(e, a) {
var t = s.prototype[a], f = GET + Util._capitalize(e), n = SET$1 + Util._capitalize(e);
function o() {
t.apply(this, arguments), Util.error('"' + e + '" method is deprecated and will be removed soon. Use ""' + a + '" instead.');
}
s.prototype[e] = o, s.prototype[f] = o, s.prototype[n] = o;
});
},
afterSetFilter() {
this._filterUpToDate = !1;
}
};
function simplifyArray(s) {
var r = [], e = s.length, a = Util, t, f;
for (t = 0; t < e; t++)
f = s[t], a._isNumber(f) ? f = Math.round(f * 1e3) / 1e3 : a._isString(f) || (f = f + ""), r.push(f);
return r;
}
var COMMA = ",", OPEN_PAREN = "(", CLOSE_PAREN = ")", OPEN_PAREN_BRACKET = "([", CLOSE_BRACKET_PAREN = "])", SEMICOLON = ";", DOUBLE_PAREN = "()", EQUALS = "=", CONTEXT_METHODS = [
"arc",
"arcTo",
"beginPath",
"bezierCurveTo",
"clearRect",
"clip",
"closePath",
"createLinearGradient",
"createPattern",
"createRadialGradient",
"drawImage",
"ellipse",
"fill",
"fillText",
"getImageData",
"createImageData",
"lineTo",
"moveTo",
"putImageData",
"quadraticCurveTo",
"rect",
"restore",
"rotate",
"save",
"scale",
"setLineDash",
"setTransform",
"stroke",
"strokeText",
"transform",
"translate"
], CONTEXT_PROPERTIES = [
"fillStyle",
"strokeStyle",
"shadowColor",
"shadowBlur",
"shadowOffsetX",
"shadowOffsetY",
"lineCap",
"lineDashOffset",
"lineJoin",
"lineWidth",
"miterLimit",
"font",
"textAlign",
"textBaseline",
"globalAlpha",
"globalCompositeOperation",
"imageSmoothingEnabled"
];
const traceArrMax = 100;
class Context {
constructor(r) {
this.canvas = r, Konva$2.enableTrace && (this.traceArr = [], this._enableTrace());
}
fillShape(r) {
r.fillEnabled() && this._fill(r);
}
_fill(r) {
}
strokeShape(r) {
r.hasStroke() && this._stroke(r);
}
_stroke(r) {
}
fillStrokeShape(r) {
r.attrs.fillAfterStrokeEnabled ? (this.strokeShape(r), this.fillShape(r)) : (this.fillShape(r), this.strokeShape(r));
}
getTrace(r, e) {
var a = this.traceArr, t = a.length, f = "", n, o, A, l;
for (n = 0; n < t; n++)
o = a[n], A = o.method, A ? (l = o.args, f += A, r ? f += DOUBLE_PAREN : Util._isArray(l[0]) ? f += OPEN_PAREN_BRACKET + l.join(COMMA) + CLOSE_BRACKET_PAREN : (e && (l = l.map((u) => typeof u == "number" ? Math.floor(u) : u)), f += OPEN_PAREN + l.join(COMMA) + CLOSE_PAREN)) : (f += o.property, r || (f += EQUALS + o.val)), f += SEMICOLON;
return f;
}
clearTrace() {
this.traceArr = [];
}
_trace(r) {
var e = this.traceArr, a;
e.push(r), a = e.length, a >= traceArrMax && e.shift();
}
reset() {
var r = this.getCanvas().getPixelRatio();
this.setTransform(1 * r, 0, 0, 1 * r, 0, 0);
}
getCanvas() {
return this.canvas;
}
clear(r) {
var e = this.getCanvas();
r ? this.clearRect(r.x || 0, r.y || 0, r.width || 0, r.height || 0) : this.clearRect(0, 0, e.getWidth() / e.pixelRatio, e.getHeight() / e.pixelRatio);
}
_applyLineCap(r) {
const e = r.attrs.lineCap;
e && this.setAttr("lineCap", e);
}
_applyOpacity(r) {
var e = r.getAbsoluteOpacity();
e !== 1 && this.setAttr("globalAlpha", e);
}
_applyLineJoin(r) {
const e = r.attrs.lineJoin;
e && this.setAttr("lineJoin", e);
}
setAttr(r, e) {
this._context[r] = e;
}
arc(r, e, a, t, f, n) {
this._context.arc(r, e, a, t, f, n);
}
arcTo(r, e, a, t, f) {
this._context.arcTo(r, e, a, t, f);
}
beginPath() {
this._context.beginPath();
}
bezierCurveTo(r, e, a, t, f, n) {
this._context.bezierCurveTo(r, e, a, t, f, n);
}
clearRect(r, e, a, t) {
this._context.clearRect(r, e, a, t);
}
clip() {
this._context.clip();
}
closePath() {
this._context.closePath();
}
createImageData(r, e) {
var a = arguments;
if (a.length === 2)
return this._context.createImageData(r, e);
if (a.length === 1)
return this._context.createImageData(r);
}
createLinearGradient(r, e, a, t) {
return this._context.createLinearGradient(r, e, a, t);
}
createPattern(r, e) {
return this._context.createPattern(r, e);
}
createRadialGradient(r, e, a, t, f, n) {
return this._context.createRadialGradient(r, e, a, t, f, n);
}
drawImage(r, e, a, t, f, n, o, A, l) {
var u = arguments, h = this._context;
u.length === 3 ? h.drawImage(r, e, a) : u.length === 5 ? h.drawImage(r, e, a, t, f) : u.length === 9 && h.drawImage(r, e, a, t, f, n, o, A, l);
}
ellipse(r, e, a, t, f, n, o, A) {
this._context.ellipse(r, e, a, t, f, n, o, A);
}
isPointInPath(r, e, a, t) {
return a ? this._context.isPointInPath(a, r, e, t) : this._context.isPointInPath(r, e, t);
}
fill(r) {
r ? this._context.fill(r) : this._context.fill();
}
fillRect(r, e, a, t) {
this._context.fillRect(r, e, a, t);
}
strokeRect(r, e, a, t) {
this._context.strokeRect(r, e, a, t);
}
fillText(r, e, a, t) {
t ? this._context.fillText(r, e, a, t) : this._context.fillText(r, e, a);
}
measureText(r) {
return this._context.measureText(r);
}
getImageData(r, e, a, t) {
return this._context.getImageData(r, e, a, t);
}
lineTo(r, e) {
this._context.lineTo(r, e);
}
moveTo(r, e) {
this._context.moveTo(r, e);
}
rect(r, e, a, t) {
this._context.rect(r, e, a, t);
}
putImageData(r, e, a) {
this._context.putImageData(r, e, a);
}
quadraticCurveTo(r, e, a, t) {
this._context.quadraticCurveTo(r, e, a, t);
}
restore() {
this._context.restore();
}
rotate(r) {
this._context.rotate(r);
}
save() {
this._context.save();
}
scale(r, e) {
this._context.scale(r, e);
}
setLineDash(r) {
this._context.setLineDash ? this._context.setLineDash(r) : "mozDash" in this._context ? this._context.mozDash = r : "webkitLineDash" in this._context && (this._context.webkitLineDash = r);
}
getLineDash() {
return this._context.getLineDash();
}
setTransform(r, e, a, t, f, n) {
this._context.setTransform(r, e, a, t, f, n);
}
stroke(r) {
r ? this._context.stroke(r) : this._context.stroke();
}
strokeText(r, e, a, t) {
this._context.strokeText(r, e, a, t);
}
transform(r, e, a, t, f, n) {
this._context.transform(r, e, a, t, f, n);
}
translate(r, e) {
this._context.translate(r, e);
}
_enableTrace() {
var r = this, e = CONTEXT_METHODS.length, a = this.setAttr, t, f, n = function(o) {
var A = r[o], l;
r[o] = function() {
return f = simplifyArray(Array.prototype.slice.call(arguments, 0)), l = A.apply(r, arguments), r._trace({
method: o,
args: f
}), l;
};
};
for (t = 0; t < e; t++)
n(CONTEXT_METHODS[t]);
r.setAttr = function() {
a.apply(r, arguments);
var o = arguments[0], A = arguments[1];
(o === "shadowOffsetX" || o === "shadowOffsetY" || o === "shadowBlur") && (A = A / this.canvas.getPixelRatio()), r._trace({
property: o,
val: A
});
};
}
_applyGlobalCompositeOperation(r) {
const e = r.attrs.globalCompositeOperation;
var a = !e || e === "source-over";
a || this.setAttr("globalCompositeOperation", e);
}
}
CONTEXT_PROPERTIES.forEach(function(s) {
Object.defineProperty(Context.prototype, s, {
get() {
return this._context[s];
},
set(r) {
this._context[s] = r;
}
});
});
class SceneContext extends Context {
constructor(r) {
super(r), this._context = r._canvas.getContext("2d");
}
_fillColor(r) {
var e = r.fill();
this.setAttr("fillStyle", e), r._fillFunc(this);
}
_fillPattern(r) {
this.setAttr("fillStyle", r._getFillPattern()), r._fillFunc(this);
}
_fillLinearGradient(r) {
var e = r._getLinearGradient();
e && (this.setAttr("fillStyle", e), r._fillFunc(this));
}
_fillRadialGradient(r) {
const e = r._getRadialGradient();
e && (this.setAttr("fillStyle", e), r._fillFunc(this));
}
_fill(r) {
const e = r.fill(), a = r.getFillPriority();
if (e && a === "color") {
this._fillColor(r);
return;
}
const t = r.getFillPatternImage();
if (t && a === "pattern") {
this._fillPattern(r);
return;
}
const f = r.getFillLinearGradientColorStops();
if (f && a === "linear-gradient") {
this._fillLinearGradient(r);
return;
}
const n = r.getFillRadialGradientColorStops();
if (n && a === "radial-gradient") {
this._fillRadialGradient(r);
return;
}
e ? this._fillColor(r) : t ? this._fillPattern(r) : f ? this._fillLinearGradient(r) : n && this._fillRadialGradient(r);
}
_strokeLinearGradient(r) {
const e = r.getStrokeLinearGradientStartPoint(), a = r.getStrokeLinearGradientEndPoint(), t = r.getStrokeLinearGradientColorStops(), f = this.createLinearGradient(e.x, e.y, a.x, a.y);
if (t) {
for (var n = 0; n < t.length; n += 2)
f.addColorStop(t[n], t[n + 1]);
this.setAttr("strokeStyle", f);
}
}
_stroke(r) {
var e = r.dash(), a = r.getStrokeScaleEnabled();
if (r.hasStroke()) {
if (!a) {
this.save();
var t = this.getCanvas().getPixelRatio();
this.setTransform(t, 0, 0, t, 0, 0);
}
this._applyLineCap(r), e && r.dashEnabled() && (this.setLineDash(e), this.setAttr("lineDashOffset", r.dashOffset())), this.setAttr("lineWidth", r.strokeWidth()), r.getShadowForStrokeEnabled() || this.setAttr("shadowColor", "rgba(0,0,0,0)");
var f = r.getStrokeLinearGradientColorStops();
f ? this._strokeLinearGradient(r) : this.setAttr("strokeStyle", r.stroke()), r._strokeFunc(this), a || this.restore();
}
}
_applyShadow(r) {
var e, a, t, f = (e = r.getShadowRGBA()) !== null && e !== void 0 ? e : "black", n = (a = r.getShadowBlur()) !== null && a !== void 0 ? a : 5, o = (t = r.getShadowOffset()) !== null && t !== void 0 ? t : {
x: 0,
y: 0
}, A = r.getAbsoluteScale(), l = this.canvas.getPixelRatio(), u = A.x * l, h = A.y * l;
this.setAttr("shadowColor", f), this.setAttr("shadowBlur", n * Math.min(Math.abs(u), Math.abs(h))), this.setAttr("shadowOffsetX", o.x * u), this.setAttr("shadowOffsetY", o.y * h);
}
}
class HitContext extends Context {
constructor(r) {
super(r), this._context = r._canvas.getContext("2d", {
willReadFrequently: !0
});
}
_fill(r) {
this.save(), this.setAttr("fillStyle", r.colorKey), r._fillFuncHit(this), this.restore();
}
strokeShape(r) {
r.hasHitStroke() && this._stroke(r);
}
_stroke(r) {
if (r.hasHitStroke()) {
const f = r.getStrokeScaleEnabled();
if (!f) {
this.save();
var e = this.getCanvas().getPixelRatio();
this.setTransform(e, 0, 0, e, 0, 0);
}
this._applyLineCap(r);
var a = r.hitStrokeWidth(), t = a === "auto" ? r.strokeWidth() : a;
this.setAttr("lineWidth", t), this.setAttr("strokeStyle", r.colorKey), r._strokeFuncHit(this), f || this.restore();
}
}
}
var _pixelRatio;
function getDevicePixelRatio() {
if (_pixelRatio)
return _pixelRatio;
var s = Util.createCanvasElement(), r = s.getContext("2d");
return _pixelRatio = function() {
var e = Konva$2._global.devicePixelRatio || 1, a = r.webkitBackingStorePixelRatio || r.mozBackingStorePixelRatio || r.msBackingStorePixelRatio || r.oBackingStorePixelRatio || r.backingStorePixelRatio || 1;
return e / a;
}(), Util.releaseCanvas(s), _pixelRatio;
}
class Canvas {
constructor(r) {
this.pixelRatio = 1, this.width = 0, this.height = 0, this.isCache = !1;
var e = r || {}, a = e.pixelRatio || Konva$2.pixelRatio || getDevicePixelRatio();
this.pixelRatio = a, this._canvas = 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(r) {
var e = this.pixelRatio;
this.pixelRatio = r, this.setSize(this.getWidth() / e, this.getHeight() / e);
}
setWidth(r) {
this.width = this._canvas.width = r * this.pixelRatio, this._canvas.style.width = r + "px";
var e = this.pixelRatio, a = this.getContext()._context;
a.scale(e, e);
}
setHeight(r) {
this.height = this._canvas.height = r * this.pixelRatio, this._canvas.style.height = r + "px";
var e = this.pixelRatio, a = this.getContext()._context;
a.scale(e, e);
}
getWidth() {
return this.width;
}
getHeight() {
return this.height;
}
setSize(r, e) {
this.setWidth(r || 0), this.setHeight(e || 0);
}
toDataURL(r, e) {
try {
return this._canvas.toDataURL(r, e);
} catch {
try {
return this._canvas.toDataURL();
} catch (t) {
return Util.error("Unable to get data URL. " + t.message + " For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."), "";
}
}
}
}
Factory.addGetterSetter(Canvas, "pixelRatio", void 0, getNumberValidator());
class SceneCanvas extends Canvas {
constructor(r = { width: 0, height: 0 }) {
super(r), this.context = new SceneContext(this), this.setSize(r.width, r.height);
}
}
class HitCanvas extends Canvas {
constructor(r = { width: 0, height: 0 }) {
super(r), this.hitCanvas = !0, this.context = new HitContext(this), this.setSize(r.width, r.height);
}
}
const DD = {
get isDragging() {
var s = !1;
return DD._dragElements.forEach((r) => {
r.dragStatus === "dragging" && (s = !0);
}), s;
},
justDragged: !1,
get node() {
var s;
return DD._dragElements.forEach((r) => {
s = r.node;
}), s;
},
_dragElements: /* @__PURE__ */ new Map(),
_drag(s) {
const r = [];
DD._dragElements.forEach((e, a) => {
const { node: t } = e, f = t.getStage();
f.setPointersPositions(s), e.pointerId === void 0 && (e.pointerId = Util._getFirstPointerId(s));
const n = f._changedPointerPositions.find((l) => l.id === e.pointerId);
if (n) {
if (e.dragStatus !== "dragging") {
var o = t.dragDistance(), A = Math.max(Math.abs(n.x - e.startPointerPos.x), Math.abs(n.y - e.startPointerPos.y));
if (A < o || (t.startDrag({ evt: s }), !t.isDragging()))
return;
}
t._setDragPosition(s, e), r.push(t);
}
}), r.forEach((e) => {
e.fire("dragmove", {
type: "dragmove",
target: e,
evt: s
}, !0);
});
},
_endDragBefore(s) {
const r = [];
DD._dragElements.forEach((e) => {
const { node: a } = e, t = a.getS