@inweb/markup 26.9.2 → 26.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/markup.js CHANGED
@@ -1,3 +1,26 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
1
24
  (function (global, factory) {
2
25
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
26
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -19,13 +42,12 @@
19
42
  var Global = {};
20
43
 
21
44
  var hasRequiredGlobal;
22
-
23
45
  function requireGlobal () {
24
46
  if (hasRequiredGlobal) return Global;
25
47
  hasRequiredGlobal = 1;
26
48
  (function (exports) {
27
49
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports._registerNode = exports.Konva = exports.glob = undefined;
50
+ exports._registerNode = exports.Konva = exports.glob = void 0;
29
51
  const PI_OVER_180 = Math.PI / 180;
30
52
  function detectBrowser() {
31
53
  return (typeof window !== 'undefined' &&
@@ -41,7 +63,7 @@
41
63
  : {};
42
64
  exports.Konva = {
43
65
  _global: exports.glob,
44
- version: '9.3.18',
66
+ version: '9.3.22',
45
67
  isBrowser: detectBrowser(),
46
68
  isUnminified: /param/.test(function (param) { }.toString()),
47
69
  dblClickWindow: 400,
@@ -73,7 +95,7 @@
73
95
  },
74
96
  isTransforming() {
75
97
  var _a;
76
- return (_a = exports.Konva['Transformer']) === null || _a === undefined ? undefined : _a.isTransforming();
98
+ return (_a = exports.Konva['Transformer']) === null || _a === void 0 ? void 0 : _a.isTransforming();
77
99
  },
78
100
  isDragReady() {
79
101
  return !!exports.Konva['DD'].node;
@@ -88,7 +110,7 @@
88
110
  exports.Konva[NodeClass.prototype.getClassName()] = NodeClass;
89
111
  };
90
112
  exports._registerNode = _registerNode;
91
- exports.Konva._injectGlobal(exports.Konva);
113
+ exports.Konva._injectGlobal(exports.Konva);
92
114
  } (Global));
93
115
  return Global;
94
116
  }
@@ -96,13 +118,12 @@
96
118
  var Util = {};
97
119
 
98
120
  var hasRequiredUtil;
99
-
100
121
  function requireUtil () {
101
122
  if (hasRequiredUtil) return Util;
102
123
  hasRequiredUtil = 1;
103
124
  (function (exports) {
104
125
  Object.defineProperty(exports, "__esModule", { value: true });
105
- exports.Util = exports.Transform = undefined;
126
+ exports.Util = exports.Transform = void 0;
106
127
  const Global_1 = requireGlobal();
107
128
  class Transform {
108
129
  constructor(m = [1, 0, 0, 1, 0, 0]) {
@@ -904,500 +925,162 @@
904
925
  context.lineTo(0, topLeft);
905
926
  context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
906
927
  },
907
- };
928
+ };
908
929
  } (Util));
909
930
  return Util;
910
931
  }
911
932
 
912
933
  var Node = {};
913
934
 
914
- var Factory = {};
915
-
916
- var Validators = {};
935
+ var Canvas = {};
917
936
 
918
- var hasRequiredValidators;
937
+ var Context = {};
919
938
 
920
- function requireValidators () {
921
- if (hasRequiredValidators) return Validators;
922
- hasRequiredValidators = 1;
923
- Object.defineProperty(Validators, "__esModule", { value: true });
924
- Validators.RGBComponent = RGBComponent;
925
- Validators.alphaComponent = alphaComponent;
926
- Validators.getNumberValidator = getNumberValidator;
927
- Validators.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
928
- Validators.getNumberOrAutoValidator = getNumberOrAutoValidator;
929
- Validators.getStringValidator = getStringValidator;
930
- Validators.getStringOrGradientValidator = getStringOrGradientValidator;
931
- Validators.getFunctionValidator = getFunctionValidator;
932
- Validators.getNumberArrayValidator = getNumberArrayValidator;
933
- Validators.getBooleanValidator = getBooleanValidator;
934
- Validators.getComponentValidator = getComponentValidator;
935
- const Global_1 = requireGlobal();
939
+ var hasRequiredContext;
940
+ function requireContext () {
941
+ if (hasRequiredContext) return Context;
942
+ hasRequiredContext = 1;
943
+ Object.defineProperty(Context, "__esModule", { value: true });
944
+ Context.HitContext = Context.SceneContext = Context.Context = void 0;
936
945
  const Util_1 = requireUtil();
937
- function _formatValue(val) {
938
- if (Util_1.Util._isString(val)) {
939
- return '"' + val + '"';
940
- }
941
- if (Object.prototype.toString.call(val) === '[object Number]') {
942
- return val;
943
- }
944
- if (Util_1.Util._isBoolean(val)) {
945
- return val;
946
+ const Global_1 = requireGlobal();
947
+ function simplifyArray(arr) {
948
+ const retArr = [], len = arr.length, util = Util_1.Util;
949
+ for (let n = 0; n < len; n++) {
950
+ let val = arr[n];
951
+ if (util._isNumber(val)) {
952
+ val = Math.round(val * 1000) / 1000;
953
+ }
954
+ else if (!util._isString(val)) {
955
+ val = val + '';
956
+ }
957
+ retArr.push(val);
946
958
  }
947
- return Object.prototype.toString.call(val);
959
+ return retArr;
948
960
  }
949
- function RGBComponent(val) {
950
- if (val > 255) {
951
- return 255;
961
+ const COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [
962
+ 'arc',
963
+ 'arcTo',
964
+ 'beginPath',
965
+ 'bezierCurveTo',
966
+ 'clearRect',
967
+ 'clip',
968
+ 'closePath',
969
+ 'createLinearGradient',
970
+ 'createPattern',
971
+ 'createRadialGradient',
972
+ 'drawImage',
973
+ 'ellipse',
974
+ 'fill',
975
+ 'fillText',
976
+ 'getImageData',
977
+ 'createImageData',
978
+ 'lineTo',
979
+ 'moveTo',
980
+ 'putImageData',
981
+ 'quadraticCurveTo',
982
+ 'rect',
983
+ 'roundRect',
984
+ 'restore',
985
+ 'rotate',
986
+ 'save',
987
+ 'scale',
988
+ 'setLineDash',
989
+ 'setTransform',
990
+ 'stroke',
991
+ 'strokeText',
992
+ 'transform',
993
+ 'translate',
994
+ ];
995
+ const CONTEXT_PROPERTIES = [
996
+ 'fillStyle',
997
+ 'strokeStyle',
998
+ 'shadowColor',
999
+ 'shadowBlur',
1000
+ 'shadowOffsetX',
1001
+ 'shadowOffsetY',
1002
+ 'letterSpacing',
1003
+ 'lineCap',
1004
+ 'lineDashOffset',
1005
+ 'lineJoin',
1006
+ 'lineWidth',
1007
+ 'miterLimit',
1008
+ 'direction',
1009
+ 'font',
1010
+ 'textAlign',
1011
+ 'textBaseline',
1012
+ 'globalAlpha',
1013
+ 'globalCompositeOperation',
1014
+ 'imageSmoothingEnabled',
1015
+ ];
1016
+ const traceArrMax = 100;
1017
+ let Context$1 = class Context {
1018
+ constructor(canvas) {
1019
+ this.canvas = canvas;
1020
+ if (Global_1.Konva.enableTrace) {
1021
+ this.traceArr = [];
1022
+ this._enableTrace();
1023
+ }
952
1024
  }
953
- else if (val < 0) {
954
- return 0;
1025
+ fillShape(shape) {
1026
+ if (shape.fillEnabled()) {
1027
+ this._fill(shape);
1028
+ }
955
1029
  }
956
- return Math.round(val);
957
- }
958
- function alphaComponent(val) {
959
- if (val > 1) {
960
- return 1;
1030
+ _fill(shape) {
961
1031
  }
962
- else if (val < 0.0001) {
963
- return 0.0001;
1032
+ strokeShape(shape) {
1033
+ if (shape.hasStroke()) {
1034
+ this._stroke(shape);
1035
+ }
964
1036
  }
965
- return val;
966
- }
967
- function getNumberValidator() {
968
- if (Global_1.Konva.isUnminified) {
969
- return function (val, attr) {
970
- if (!Util_1.Util._isNumber(val)) {
971
- Util_1.Util.warn(_formatValue(val) +
972
- ' is a not valid value for "' +
973
- attr +
974
- '" attribute. The value should be a number.');
975
- }
976
- return val;
977
- };
1037
+ _stroke(shape) {
978
1038
  }
979
- }
980
- function getNumberOrArrayOfNumbersValidator(noOfElements) {
981
- if (Global_1.Konva.isUnminified) {
982
- return function (val, attr) {
983
- let isNumber = Util_1.Util._isNumber(val);
984
- let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
985
- if (!isNumber && !isValidArray) {
986
- Util_1.Util.warn(_formatValue(val) +
987
- ' is a not valid value for "' +
988
- attr +
989
- '" attribute. The value should be a number or Array<number>(' +
990
- noOfElements +
991
- ')');
992
- }
993
- return val;
994
- };
1039
+ fillStrokeShape(shape) {
1040
+ if (shape.attrs.fillAfterStrokeEnabled) {
1041
+ this.strokeShape(shape);
1042
+ this.fillShape(shape);
1043
+ }
1044
+ else {
1045
+ this.fillShape(shape);
1046
+ this.strokeShape(shape);
1047
+ }
995
1048
  }
996
- }
997
- function getNumberOrAutoValidator() {
998
- if (Global_1.Konva.isUnminified) {
999
- return function (val, attr) {
1000
- var isNumber = Util_1.Util._isNumber(val);
1001
- var isAuto = val === 'auto';
1002
- if (!(isNumber || isAuto)) {
1003
- Util_1.Util.warn(_formatValue(val) +
1004
- ' is a not valid value for "' +
1005
- attr +
1006
- '" attribute. The value should be a number or "auto".');
1049
+ getTrace(relaxed, rounded) {
1050
+ let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
1051
+ for (n = 0; n < len; n++) {
1052
+ trace = traceArr[n];
1053
+ method = trace.method;
1054
+ if (method) {
1055
+ args = trace.args;
1056
+ str += method;
1057
+ if (relaxed) {
1058
+ str += DOUBLE_PAREN;
1059
+ }
1060
+ else {
1061
+ if (Util_1.Util._isArray(args[0])) {
1062
+ str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;
1063
+ }
1064
+ else {
1065
+ if (rounded) {
1066
+ args = args.map((a) => typeof a === 'number' ? Math.floor(a) : a);
1067
+ }
1068
+ str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;
1069
+ }
1070
+ }
1007
1071
  }
1008
- return val;
1009
- };
1010
- }
1011
- }
1012
- function getStringValidator() {
1013
- if (Global_1.Konva.isUnminified) {
1014
- return function (val, attr) {
1015
- if (!Util_1.Util._isString(val)) {
1016
- Util_1.Util.warn(_formatValue(val) +
1017
- ' is a not valid value for "' +
1018
- attr +
1019
- '" attribute. The value should be a string.');
1072
+ else {
1073
+ str += trace.property;
1074
+ if (!relaxed) {
1075
+ str += EQUALS + trace.val;
1076
+ }
1020
1077
  }
1021
- return val;
1022
- };
1078
+ str += SEMICOLON;
1079
+ }
1080
+ return str;
1023
1081
  }
1024
- }
1025
- function getStringOrGradientValidator() {
1026
- if (Global_1.Konva.isUnminified) {
1027
- return function (val, attr) {
1028
- const isString = Util_1.Util._isString(val);
1029
- const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
1030
- (val && val['addColorStop']);
1031
- if (!(isString || isGradient)) {
1032
- Util_1.Util.warn(_formatValue(val) +
1033
- ' is a not valid value for "' +
1034
- attr +
1035
- '" attribute. The value should be a string or a native gradient.');
1036
- }
1037
- return val;
1038
- };
1039
- }
1040
- }
1041
- function getFunctionValidator() {
1042
- if (Global_1.Konva.isUnminified) {
1043
- return function (val, attr) {
1044
- if (!Util_1.Util._isFunction(val)) {
1045
- Util_1.Util.warn(_formatValue(val) +
1046
- ' is a not valid value for "' +
1047
- attr +
1048
- '" attribute. The value should be a function.');
1049
- }
1050
- return val;
1051
- };
1052
- }
1053
- }
1054
- function getNumberArrayValidator() {
1055
- if (Global_1.Konva.isUnminified) {
1056
- return function (val, attr) {
1057
- const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
1058
- if (TypedArray && val instanceof TypedArray) {
1059
- return val;
1060
- }
1061
- if (!Util_1.Util._isArray(val)) {
1062
- Util_1.Util.warn(_formatValue(val) +
1063
- ' is a not valid value for "' +
1064
- attr +
1065
- '" attribute. The value should be a array of numbers.');
1066
- }
1067
- else {
1068
- val.forEach(function (item) {
1069
- if (!Util_1.Util._isNumber(item)) {
1070
- Util_1.Util.warn('"' +
1071
- attr +
1072
- '" attribute has non numeric element ' +
1073
- item +
1074
- '. Make sure that all elements are numbers.');
1075
- }
1076
- });
1077
- }
1078
- return val;
1079
- };
1080
- }
1081
- }
1082
- function getBooleanValidator() {
1083
- if (Global_1.Konva.isUnminified) {
1084
- return function (val, attr) {
1085
- var isBool = val === true || val === false;
1086
- if (!isBool) {
1087
- Util_1.Util.warn(_formatValue(val) +
1088
- ' is a not valid value for "' +
1089
- attr +
1090
- '" attribute. The value should be a boolean.');
1091
- }
1092
- return val;
1093
- };
1094
- }
1095
- }
1096
- function getComponentValidator(components) {
1097
- if (Global_1.Konva.isUnminified) {
1098
- return function (val, attr) {
1099
- if (val === undefined || val === null) {
1100
- return val;
1101
- }
1102
- if (!Util_1.Util.isObject(val)) {
1103
- Util_1.Util.warn(_formatValue(val) +
1104
- ' is a not valid value for "' +
1105
- attr +
1106
- '" attribute. The value should be an object with properties ' +
1107
- components);
1108
- }
1109
- return val;
1110
- };
1111
- }
1112
- }
1113
- return Validators;
1114
- }
1115
-
1116
- var hasRequiredFactory;
1117
-
1118
- function requireFactory () {
1119
- if (hasRequiredFactory) return Factory;
1120
- hasRequiredFactory = 1;
1121
- (function (exports) {
1122
- Object.defineProperty(exports, "__esModule", { value: true });
1123
- exports.Factory = undefined;
1124
- const Util_1 = requireUtil();
1125
- const Validators_1 = requireValidators();
1126
- const GET = 'get';
1127
- const SET = 'set';
1128
- exports.Factory = {
1129
- addGetterSetter(constructor, attr, def, validator, after) {
1130
- exports.Factory.addGetter(constructor, attr, def);
1131
- exports.Factory.addSetter(constructor, attr, validator, after);
1132
- exports.Factory.addOverloadedGetterSetter(constructor, attr);
1133
- },
1134
- addGetter(constructor, attr, def) {
1135
- var method = GET + Util_1.Util._capitalize(attr);
1136
- constructor.prototype[method] =
1137
- constructor.prototype[method] ||
1138
- function () {
1139
- const val = this.attrs[attr];
1140
- return val === undefined ? def : val;
1141
- };
1142
- },
1143
- addSetter(constructor, attr, validator, after) {
1144
- var method = SET + Util_1.Util._capitalize(attr);
1145
- if (!constructor.prototype[method]) {
1146
- exports.Factory.overWriteSetter(constructor, attr, validator, after);
1147
- }
1148
- },
1149
- overWriteSetter(constructor, attr, validator, after) {
1150
- var method = SET + Util_1.Util._capitalize(attr);
1151
- constructor.prototype[method] = function (val) {
1152
- if (validator && val !== undefined && val !== null) {
1153
- val = validator.call(this, val, attr);
1154
- }
1155
- this._setAttr(attr, val);
1156
- if (after) {
1157
- after.call(this);
1158
- }
1159
- return this;
1160
- };
1161
- },
1162
- addComponentsGetterSetter(constructor, attr, components, validator, after) {
1163
- const len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr);
1164
- constructor.prototype[getter] = function () {
1165
- const ret = {};
1166
- for (let n = 0; n < len; n++) {
1167
- const component = components[n];
1168
- ret[component] = this.getAttr(attr + capitalize(component));
1169
- }
1170
- return ret;
1171
- };
1172
- const basicValidator = (0, Validators_1.getComponentValidator)(components);
1173
- constructor.prototype[setter] = function (val) {
1174
- const oldVal = this.attrs[attr];
1175
- if (validator) {
1176
- val = validator.call(this, val, attr);
1177
- }
1178
- if (basicValidator) {
1179
- basicValidator.call(this, val, attr);
1180
- }
1181
- for (const key in val) {
1182
- if (!val.hasOwnProperty(key)) {
1183
- continue;
1184
- }
1185
- this._setAttr(attr + capitalize(key), val[key]);
1186
- }
1187
- if (!val) {
1188
- components.forEach((component) => {
1189
- this._setAttr(attr + capitalize(component), undefined);
1190
- });
1191
- }
1192
- this._fireChangeEvent(attr, oldVal, val);
1193
- if (after) {
1194
- after.call(this);
1195
- }
1196
- return this;
1197
- };
1198
- exports.Factory.addOverloadedGetterSetter(constructor, attr);
1199
- },
1200
- addOverloadedGetterSetter(constructor, attr) {
1201
- var capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
1202
- constructor.prototype[attr] = function () {
1203
- if (arguments.length) {
1204
- this[setter](arguments[0]);
1205
- return this;
1206
- }
1207
- return this[getter]();
1208
- };
1209
- },
1210
- addDeprecatedGetterSetter(constructor, attr, def, validator) {
1211
- Util_1.Util.error('Adding deprecated ' + attr);
1212
- const method = GET + Util_1.Util._capitalize(attr);
1213
- const message = attr +
1214
- ' property is deprecated and will be removed soon. Look at Konva change log for more information.';
1215
- constructor.prototype[method] = function () {
1216
- Util_1.Util.error(message);
1217
- const val = this.attrs[attr];
1218
- return val === undefined ? def : val;
1219
- };
1220
- exports.Factory.addSetter(constructor, attr, validator, function () {
1221
- Util_1.Util.error(message);
1222
- });
1223
- exports.Factory.addOverloadedGetterSetter(constructor, attr);
1224
- },
1225
- backCompat(constructor, methods) {
1226
- Util_1.Util.each(methods, function (oldMethodName, newMethodName) {
1227
- const method = constructor.prototype[newMethodName];
1228
- const oldGetter = GET + Util_1.Util._capitalize(oldMethodName);
1229
- const oldSetter = SET + Util_1.Util._capitalize(oldMethodName);
1230
- function deprecated() {
1231
- method.apply(this, arguments);
1232
- Util_1.Util.error('"' +
1233
- oldMethodName +
1234
- '" method is deprecated and will be removed soon. Use ""' +
1235
- newMethodName +
1236
- '" instead.');
1237
- }
1238
- constructor.prototype[oldMethodName] = deprecated;
1239
- constructor.prototype[oldGetter] = deprecated;
1240
- constructor.prototype[oldSetter] = deprecated;
1241
- });
1242
- },
1243
- afterSetFilter() {
1244
- this._filterUpToDate = false;
1245
- },
1246
- };
1247
- } (Factory));
1248
- return Factory;
1249
- }
1250
-
1251
- var Canvas = {};
1252
-
1253
- var Context = {};
1254
-
1255
- var hasRequiredContext;
1256
-
1257
- function requireContext () {
1258
- if (hasRequiredContext) return Context;
1259
- hasRequiredContext = 1;
1260
- Object.defineProperty(Context, "__esModule", { value: true });
1261
- Context.HitContext = Context.SceneContext = Context.Context = undefined;
1262
- const Util_1 = requireUtil();
1263
- const Global_1 = requireGlobal();
1264
- function simplifyArray(arr) {
1265
- const retArr = [], len = arr.length, util = Util_1.Util;
1266
- for (let n = 0; n < len; n++) {
1267
- let val = arr[n];
1268
- if (util._isNumber(val)) {
1269
- val = Math.round(val * 1000) / 1000;
1270
- }
1271
- else if (!util._isString(val)) {
1272
- val = val + '';
1273
- }
1274
- retArr.push(val);
1275
- }
1276
- return retArr;
1277
- }
1278
- const COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [
1279
- 'arc',
1280
- 'arcTo',
1281
- 'beginPath',
1282
- 'bezierCurveTo',
1283
- 'clearRect',
1284
- 'clip',
1285
- 'closePath',
1286
- 'createLinearGradient',
1287
- 'createPattern',
1288
- 'createRadialGradient',
1289
- 'drawImage',
1290
- 'ellipse',
1291
- 'fill',
1292
- 'fillText',
1293
- 'getImageData',
1294
- 'createImageData',
1295
- 'lineTo',
1296
- 'moveTo',
1297
- 'putImageData',
1298
- 'quadraticCurveTo',
1299
- 'rect',
1300
- 'roundRect',
1301
- 'restore',
1302
- 'rotate',
1303
- 'save',
1304
- 'scale',
1305
- 'setLineDash',
1306
- 'setTransform',
1307
- 'stroke',
1308
- 'strokeText',
1309
- 'transform',
1310
- 'translate',
1311
- ];
1312
- const CONTEXT_PROPERTIES = [
1313
- 'fillStyle',
1314
- 'strokeStyle',
1315
- 'shadowColor',
1316
- 'shadowBlur',
1317
- 'shadowOffsetX',
1318
- 'shadowOffsetY',
1319
- 'letterSpacing',
1320
- 'lineCap',
1321
- 'lineDashOffset',
1322
- 'lineJoin',
1323
- 'lineWidth',
1324
- 'miterLimit',
1325
- 'direction',
1326
- 'font',
1327
- 'textAlign',
1328
- 'textBaseline',
1329
- 'globalAlpha',
1330
- 'globalCompositeOperation',
1331
- 'imageSmoothingEnabled',
1332
- ];
1333
- const traceArrMax = 100;
1334
- let Context$1 = class Context {
1335
- constructor(canvas) {
1336
- this.canvas = canvas;
1337
- if (Global_1.Konva.enableTrace) {
1338
- this.traceArr = [];
1339
- this._enableTrace();
1340
- }
1341
- }
1342
- fillShape(shape) {
1343
- if (shape.fillEnabled()) {
1344
- this._fill(shape);
1345
- }
1346
- }
1347
- _fill(shape) {
1348
- }
1349
- strokeShape(shape) {
1350
- if (shape.hasStroke()) {
1351
- this._stroke(shape);
1352
- }
1353
- }
1354
- _stroke(shape) {
1355
- }
1356
- fillStrokeShape(shape) {
1357
- if (shape.attrs.fillAfterStrokeEnabled) {
1358
- this.strokeShape(shape);
1359
- this.fillShape(shape);
1360
- }
1361
- else {
1362
- this.fillShape(shape);
1363
- this.strokeShape(shape);
1364
- }
1365
- }
1366
- getTrace(relaxed, rounded) {
1367
- let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
1368
- for (n = 0; n < len; n++) {
1369
- trace = traceArr[n];
1370
- method = trace.method;
1371
- if (method) {
1372
- args = trace.args;
1373
- str += method;
1374
- if (relaxed) {
1375
- str += DOUBLE_PAREN;
1376
- }
1377
- else {
1378
- if (Util_1.Util._isArray(args[0])) {
1379
- str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;
1380
- }
1381
- else {
1382
- if (rounded) {
1383
- args = args.map((a) => typeof a === 'number' ? Math.floor(a) : a);
1384
- }
1385
- str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;
1386
- }
1387
- }
1388
- }
1389
- else {
1390
- str += trace.property;
1391
- if (!relaxed) {
1392
- str += EQUALS + trace.val;
1393
- }
1394
- }
1395
- str += SEMICOLON;
1396
- }
1397
- return str;
1398
- }
1399
- clearTrace() {
1400
- this.traceArr = [];
1082
+ clearTrace() {
1083
+ this.traceArr = [];
1401
1084
  }
1402
1085
  _trace(str) {
1403
1086
  let traceArr = this.traceArr, len;
@@ -1747,7 +1430,7 @@
1747
1430
  }
1748
1431
  _applyShadow(shape) {
1749
1432
  var _a, _b, _c;
1750
- const color = (_a = shape.getShadowRGBA()) !== null && _a !== undefined ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== undefined ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== undefined ? _c : {
1433
+ const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
1751
1434
  x: 0,
1752
1435
  y: 0,
1753
1436
  }, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
@@ -1801,17 +1484,14 @@
1801
1484
  }
1802
1485
 
1803
1486
  var hasRequiredCanvas;
1804
-
1805
1487
  function requireCanvas () {
1806
1488
  if (hasRequiredCanvas) return Canvas;
1807
1489
  hasRequiredCanvas = 1;
1808
1490
  Object.defineProperty(Canvas, "__esModule", { value: true });
1809
- Canvas.HitCanvas = Canvas.SceneCanvas = Canvas.Canvas = undefined;
1491
+ Canvas.HitCanvas = Canvas.SceneCanvas = Canvas.Canvas = void 0;
1810
1492
  const Util_1 = requireUtil();
1811
1493
  const Context_1 = requireContext();
1812
1494
  const Global_1 = requireGlobal();
1813
- const Factory_1 = requireFactory();
1814
- const Validators_1 = requireValidators();
1815
1495
  let _pixelRatio;
1816
1496
  function getDevicePixelRatio() {
1817
1497
  if (_pixelRatio) {
@@ -1860,207 +1540,539 @@
1860
1540
  this.pixelRatio = pixelRatio;
1861
1541
  this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
1862
1542
  }
1863
- setWidth(width) {
1864
- this.width = this._canvas.width = width * this.pixelRatio;
1865
- this._canvas.style.width = width + 'px';
1866
- const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
1867
- _context.scale(pixelRatio, pixelRatio);
1543
+ setWidth(width) {
1544
+ this.width = this._canvas.width = width * this.pixelRatio;
1545
+ this._canvas.style.width = width + 'px';
1546
+ const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
1547
+ _context.scale(pixelRatio, pixelRatio);
1548
+ }
1549
+ setHeight(height) {
1550
+ this.height = this._canvas.height = height * this.pixelRatio;
1551
+ this._canvas.style.height = height + 'px';
1552
+ const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
1553
+ _context.scale(pixelRatio, pixelRatio);
1554
+ }
1555
+ getWidth() {
1556
+ return this.width;
1557
+ }
1558
+ getHeight() {
1559
+ return this.height;
1560
+ }
1561
+ setSize(width, height) {
1562
+ this.setWidth(width || 0);
1563
+ this.setHeight(height || 0);
1564
+ }
1565
+ toDataURL(mimeType, quality) {
1566
+ try {
1567
+ return this._canvas.toDataURL(mimeType, quality);
1568
+ }
1569
+ catch (e) {
1570
+ try {
1571
+ return this._canvas.toDataURL();
1572
+ }
1573
+ catch (err) {
1574
+ Util_1.Util.error('Unable to get data URL. ' +
1575
+ err.message +
1576
+ ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
1577
+ return '';
1578
+ }
1579
+ }
1580
+ }
1581
+ };
1582
+ Canvas.Canvas = Canvas$1;
1583
+ class SceneCanvas extends Canvas$1 {
1584
+ constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
1585
+ super(config);
1586
+ this.context = new Context_1.SceneContext(this, {
1587
+ willReadFrequently: config.willReadFrequently,
1588
+ });
1589
+ this.setSize(config.width, config.height);
1590
+ }
1591
+ }
1592
+ Canvas.SceneCanvas = SceneCanvas;
1593
+ class HitCanvas extends Canvas$1 {
1594
+ constructor(config = { width: 0, height: 0 }) {
1595
+ super(config);
1596
+ this.hitCanvas = true;
1597
+ this.context = new Context_1.HitContext(this);
1598
+ this.setSize(config.width, config.height);
1599
+ }
1600
+ }
1601
+ Canvas.HitCanvas = HitCanvas;
1602
+ return Canvas;
1603
+ }
1604
+
1605
+ var DragAndDrop = {};
1606
+
1607
+ var hasRequiredDragAndDrop;
1608
+ function requireDragAndDrop () {
1609
+ if (hasRequiredDragAndDrop) return DragAndDrop;
1610
+ hasRequiredDragAndDrop = 1;
1611
+ (function (exports) {
1612
+ Object.defineProperty(exports, "__esModule", { value: true });
1613
+ exports.DD = void 0;
1614
+ const Global_1 = requireGlobal();
1615
+ const Util_1 = requireUtil();
1616
+ exports.DD = {
1617
+ get isDragging() {
1618
+ let flag = false;
1619
+ exports.DD._dragElements.forEach((elem) => {
1620
+ if (elem.dragStatus === 'dragging') {
1621
+ flag = true;
1622
+ }
1623
+ });
1624
+ return flag;
1625
+ },
1626
+ justDragged: false,
1627
+ get node() {
1628
+ let node;
1629
+ exports.DD._dragElements.forEach((elem) => {
1630
+ node = elem.node;
1631
+ });
1632
+ return node;
1633
+ },
1634
+ _dragElements: new Map(),
1635
+ _drag(evt) {
1636
+ const nodesToFireEvents = [];
1637
+ exports.DD._dragElements.forEach((elem, key) => {
1638
+ const { node } = elem;
1639
+ const stage = node.getStage();
1640
+ stage.setPointersPositions(evt);
1641
+ if (elem.pointerId === undefined) {
1642
+ elem.pointerId = Util_1.Util._getFirstPointerId(evt);
1643
+ }
1644
+ const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
1645
+ if (!pos) {
1646
+ return;
1647
+ }
1648
+ if (elem.dragStatus !== 'dragging') {
1649
+ const dragDistance = node.dragDistance();
1650
+ const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
1651
+ if (distance < dragDistance) {
1652
+ return;
1653
+ }
1654
+ node.startDrag({ evt });
1655
+ if (!node.isDragging()) {
1656
+ return;
1657
+ }
1658
+ }
1659
+ node._setDragPosition(evt, elem);
1660
+ nodesToFireEvents.push(node);
1661
+ });
1662
+ nodesToFireEvents.forEach((node) => {
1663
+ node.fire('dragmove', {
1664
+ type: 'dragmove',
1665
+ target: node,
1666
+ evt: evt,
1667
+ }, true);
1668
+ });
1669
+ },
1670
+ _endDragBefore(evt) {
1671
+ const drawNodes = [];
1672
+ exports.DD._dragElements.forEach((elem) => {
1673
+ const { node } = elem;
1674
+ const stage = node.getStage();
1675
+ if (evt) {
1676
+ stage.setPointersPositions(evt);
1677
+ }
1678
+ const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
1679
+ if (!pos) {
1680
+ return;
1681
+ }
1682
+ if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
1683
+ exports.DD.justDragged = true;
1684
+ Global_1.Konva._mouseListenClick = false;
1685
+ Global_1.Konva._touchListenClick = false;
1686
+ Global_1.Konva._pointerListenClick = false;
1687
+ elem.dragStatus = 'stopped';
1688
+ }
1689
+ const drawNode = elem.node.getLayer() ||
1690
+ (elem.node instanceof Global_1.Konva['Stage'] && elem.node);
1691
+ if (drawNode && drawNodes.indexOf(drawNode) === -1) {
1692
+ drawNodes.push(drawNode);
1693
+ }
1694
+ });
1695
+ drawNodes.forEach((drawNode) => {
1696
+ drawNode.draw();
1697
+ });
1698
+ },
1699
+ _endDragAfter(evt) {
1700
+ exports.DD._dragElements.forEach((elem, key) => {
1701
+ if (elem.dragStatus === 'stopped') {
1702
+ elem.node.fire('dragend', {
1703
+ type: 'dragend',
1704
+ target: elem.node,
1705
+ evt: evt,
1706
+ }, true);
1707
+ }
1708
+ if (elem.dragStatus !== 'dragging') {
1709
+ exports.DD._dragElements.delete(key);
1710
+ }
1711
+ });
1712
+ },
1713
+ };
1714
+ if (Global_1.Konva.isBrowser) {
1715
+ window.addEventListener('mouseup', exports.DD._endDragBefore, true);
1716
+ window.addEventListener('touchend', exports.DD._endDragBefore, true);
1717
+ window.addEventListener('touchcancel', exports.DD._endDragBefore, true);
1718
+ window.addEventListener('mousemove', exports.DD._drag);
1719
+ window.addEventListener('touchmove', exports.DD._drag);
1720
+ window.addEventListener('mouseup', exports.DD._endDragAfter, false);
1721
+ window.addEventListener('touchend', exports.DD._endDragAfter, false);
1722
+ window.addEventListener('touchcancel', exports.DD._endDragAfter, false);
1723
+ }
1724
+ } (DragAndDrop));
1725
+ return DragAndDrop;
1726
+ }
1727
+
1728
+ var Factory = {};
1729
+
1730
+ var Validators = {};
1731
+
1732
+ var hasRequiredValidators;
1733
+ function requireValidators () {
1734
+ if (hasRequiredValidators) return Validators;
1735
+ hasRequiredValidators = 1;
1736
+ Object.defineProperty(Validators, "__esModule", { value: true });
1737
+ Validators.RGBComponent = RGBComponent;
1738
+ Validators.alphaComponent = alphaComponent;
1739
+ Validators.getNumberValidator = getNumberValidator;
1740
+ Validators.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
1741
+ Validators.getNumberOrAutoValidator = getNumberOrAutoValidator;
1742
+ Validators.getStringValidator = getStringValidator;
1743
+ Validators.getStringOrGradientValidator = getStringOrGradientValidator;
1744
+ Validators.getFunctionValidator = getFunctionValidator;
1745
+ Validators.getNumberArrayValidator = getNumberArrayValidator;
1746
+ Validators.getBooleanValidator = getBooleanValidator;
1747
+ Validators.getComponentValidator = getComponentValidator;
1748
+ const Global_1 = requireGlobal();
1749
+ const Util_1 = requireUtil();
1750
+ function _formatValue(val) {
1751
+ if (Util_1.Util._isString(val)) {
1752
+ return '"' + val + '"';
1753
+ }
1754
+ if (Object.prototype.toString.call(val) === '[object Number]') {
1755
+ return val;
1756
+ }
1757
+ if (Util_1.Util._isBoolean(val)) {
1758
+ return val;
1759
+ }
1760
+ return Object.prototype.toString.call(val);
1761
+ }
1762
+ function RGBComponent(val) {
1763
+ if (val > 255) {
1764
+ return 255;
1765
+ }
1766
+ else if (val < 0) {
1767
+ return 0;
1768
+ }
1769
+ return Math.round(val);
1770
+ }
1771
+ function alphaComponent(val) {
1772
+ if (val > 1) {
1773
+ return 1;
1774
+ }
1775
+ else if (val < 0.0001) {
1776
+ return 0.0001;
1777
+ }
1778
+ return val;
1779
+ }
1780
+ function getNumberValidator() {
1781
+ if (Global_1.Konva.isUnminified) {
1782
+ return function (val, attr) {
1783
+ if (!Util_1.Util._isNumber(val)) {
1784
+ Util_1.Util.warn(_formatValue(val) +
1785
+ ' is a not valid value for "' +
1786
+ attr +
1787
+ '" attribute. The value should be a number.');
1788
+ }
1789
+ return val;
1790
+ };
1791
+ }
1792
+ }
1793
+ function getNumberOrArrayOfNumbersValidator(noOfElements) {
1794
+ if (Global_1.Konva.isUnminified) {
1795
+ return function (val, attr) {
1796
+ let isNumber = Util_1.Util._isNumber(val);
1797
+ let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
1798
+ if (!isNumber && !isValidArray) {
1799
+ Util_1.Util.warn(_formatValue(val) +
1800
+ ' is a not valid value for "' +
1801
+ attr +
1802
+ '" attribute. The value should be a number or Array<number>(' +
1803
+ noOfElements +
1804
+ ')');
1805
+ }
1806
+ return val;
1807
+ };
1868
1808
  }
1869
- setHeight(height) {
1870
- this.height = this._canvas.height = height * this.pixelRatio;
1871
- this._canvas.style.height = height + 'px';
1872
- const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
1873
- _context.scale(pixelRatio, pixelRatio);
1809
+ }
1810
+ function getNumberOrAutoValidator() {
1811
+ if (Global_1.Konva.isUnminified) {
1812
+ return function (val, attr) {
1813
+ const isNumber = Util_1.Util._isNumber(val);
1814
+ const isAuto = val === 'auto';
1815
+ if (!(isNumber || isAuto)) {
1816
+ Util_1.Util.warn(_formatValue(val) +
1817
+ ' is a not valid value for "' +
1818
+ attr +
1819
+ '" attribute. The value should be a number or "auto".');
1820
+ }
1821
+ return val;
1822
+ };
1874
1823
  }
1875
- getWidth() {
1876
- return this.width;
1824
+ }
1825
+ function getStringValidator() {
1826
+ if (Global_1.Konva.isUnminified) {
1827
+ return function (val, attr) {
1828
+ if (!Util_1.Util._isString(val)) {
1829
+ Util_1.Util.warn(_formatValue(val) +
1830
+ ' is a not valid value for "' +
1831
+ attr +
1832
+ '" attribute. The value should be a string.');
1833
+ }
1834
+ return val;
1835
+ };
1877
1836
  }
1878
- getHeight() {
1879
- return this.height;
1837
+ }
1838
+ function getStringOrGradientValidator() {
1839
+ if (Global_1.Konva.isUnminified) {
1840
+ return function (val, attr) {
1841
+ const isString = Util_1.Util._isString(val);
1842
+ const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
1843
+ (val && val['addColorStop']);
1844
+ if (!(isString || isGradient)) {
1845
+ Util_1.Util.warn(_formatValue(val) +
1846
+ ' is a not valid value for "' +
1847
+ attr +
1848
+ '" attribute. The value should be a string or a native gradient.');
1849
+ }
1850
+ return val;
1851
+ };
1880
1852
  }
1881
- setSize(width, height) {
1882
- this.setWidth(width || 0);
1883
- this.setHeight(height || 0);
1853
+ }
1854
+ function getFunctionValidator() {
1855
+ if (Global_1.Konva.isUnminified) {
1856
+ return function (val, attr) {
1857
+ if (!Util_1.Util._isFunction(val)) {
1858
+ Util_1.Util.warn(_formatValue(val) +
1859
+ ' is a not valid value for "' +
1860
+ attr +
1861
+ '" attribute. The value should be a function.');
1862
+ }
1863
+ return val;
1864
+ };
1884
1865
  }
1885
- toDataURL(mimeType, quality) {
1886
- try {
1887
- return this._canvas.toDataURL(mimeType, quality);
1888
- }
1889
- catch (e) {
1890
- try {
1891
- return this._canvas.toDataURL();
1866
+ }
1867
+ function getNumberArrayValidator() {
1868
+ if (Global_1.Konva.isUnminified) {
1869
+ return function (val, attr) {
1870
+ const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
1871
+ if (TypedArray && val instanceof TypedArray) {
1872
+ return val;
1892
1873
  }
1893
- catch (err) {
1894
- Util_1.Util.error('Unable to get data URL. ' +
1895
- err.message +
1896
- ' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
1897
- return '';
1874
+ if (!Util_1.Util._isArray(val)) {
1875
+ Util_1.Util.warn(_formatValue(val) +
1876
+ ' is a not valid value for "' +
1877
+ attr +
1878
+ '" attribute. The value should be a array of numbers.');
1898
1879
  }
1899
- }
1880
+ else {
1881
+ val.forEach(function (item) {
1882
+ if (!Util_1.Util._isNumber(item)) {
1883
+ Util_1.Util.warn('"' +
1884
+ attr +
1885
+ '" attribute has non numeric element ' +
1886
+ item +
1887
+ '. Make sure that all elements are numbers.');
1888
+ }
1889
+ });
1890
+ }
1891
+ return val;
1892
+ };
1900
1893
  }
1901
- };
1902
- Canvas.Canvas = Canvas$1;
1903
- Factory_1.Factory.addGetterSetter(Canvas$1, 'pixelRatio', undefined, (0, Validators_1.getNumberValidator)());
1904
- class SceneCanvas extends Canvas$1 {
1905
- constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
1906
- super(config);
1907
- this.context = new Context_1.SceneContext(this, {
1908
- willReadFrequently: config.willReadFrequently,
1909
- });
1910
- this.setSize(config.width, config.height);
1894
+ }
1895
+ function getBooleanValidator() {
1896
+ if (Global_1.Konva.isUnminified) {
1897
+ return function (val, attr) {
1898
+ const isBool = val === true || val === false;
1899
+ if (!isBool) {
1900
+ Util_1.Util.warn(_formatValue(val) +
1901
+ ' is a not valid value for "' +
1902
+ attr +
1903
+ '" attribute. The value should be a boolean.');
1904
+ }
1905
+ return val;
1906
+ };
1911
1907
  }
1912
1908
  }
1913
- Canvas.SceneCanvas = SceneCanvas;
1914
- class HitCanvas extends Canvas$1 {
1915
- constructor(config = { width: 0, height: 0 }) {
1916
- super(config);
1917
- this.hitCanvas = true;
1918
- this.context = new Context_1.HitContext(this);
1919
- this.setSize(config.width, config.height);
1909
+ function getComponentValidator(components) {
1910
+ if (Global_1.Konva.isUnminified) {
1911
+ return function (val, attr) {
1912
+ if (val === undefined || val === null) {
1913
+ return val;
1914
+ }
1915
+ if (!Util_1.Util.isObject(val)) {
1916
+ Util_1.Util.warn(_formatValue(val) +
1917
+ ' is a not valid value for "' +
1918
+ attr +
1919
+ '" attribute. The value should be an object with properties ' +
1920
+ components);
1921
+ }
1922
+ return val;
1923
+ };
1920
1924
  }
1921
1925
  }
1922
- Canvas.HitCanvas = HitCanvas;
1923
- return Canvas;
1926
+ return Validators;
1924
1927
  }
1925
1928
 
1926
- var DragAndDrop = {};
1927
-
1928
- var hasRequiredDragAndDrop;
1929
-
1930
- function requireDragAndDrop () {
1931
- if (hasRequiredDragAndDrop) return DragAndDrop;
1932
- hasRequiredDragAndDrop = 1;
1929
+ var hasRequiredFactory;
1930
+ function requireFactory () {
1931
+ if (hasRequiredFactory) return Factory;
1932
+ hasRequiredFactory = 1;
1933
1933
  (function (exports) {
1934
1934
  Object.defineProperty(exports, "__esModule", { value: true });
1935
- exports.DD = undefined;
1936
- const Global_1 = requireGlobal();
1935
+ exports.Factory = void 0;
1937
1936
  const Util_1 = requireUtil();
1938
- exports.DD = {
1939
- get isDragging() {
1940
- let flag = false;
1941
- exports.DD._dragElements.forEach((elem) => {
1942
- if (elem.dragStatus === 'dragging') {
1943
- flag = true;
1944
- }
1945
- });
1946
- return flag;
1937
+ const Validators_1 = requireValidators();
1938
+ const GET = 'get';
1939
+ const SET = 'set';
1940
+ exports.Factory = {
1941
+ addGetterSetter(constructor, attr, def, validator, after) {
1942
+ exports.Factory.addGetter(constructor, attr, def);
1943
+ exports.Factory.addSetter(constructor, attr, validator, after);
1944
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
1947
1945
  },
1948
- justDragged: false,
1949
- get node() {
1950
- let node;
1951
- exports.DD._dragElements.forEach((elem) => {
1952
- node = elem.node;
1953
- });
1954
- return node;
1946
+ addGetter(constructor, attr, def) {
1947
+ const method = GET + Util_1.Util._capitalize(attr);
1948
+ constructor.prototype[method] =
1949
+ constructor.prototype[method] ||
1950
+ function () {
1951
+ const val = this.attrs[attr];
1952
+ return val === undefined ? def : val;
1953
+ };
1955
1954
  },
1956
- _dragElements: new Map(),
1957
- _drag(evt) {
1958
- const nodesToFireEvents = [];
1959
- exports.DD._dragElements.forEach((elem, key) => {
1960
- const { node } = elem;
1961
- const stage = node.getStage();
1962
- stage.setPointersPositions(evt);
1963
- if (elem.pointerId === undefined) {
1964
- elem.pointerId = Util_1.Util._getFirstPointerId(evt);
1955
+ addSetter(constructor, attr, validator, after) {
1956
+ const method = SET + Util_1.Util._capitalize(attr);
1957
+ if (!constructor.prototype[method]) {
1958
+ exports.Factory.overWriteSetter(constructor, attr, validator, after);
1959
+ }
1960
+ },
1961
+ overWriteSetter(constructor, attr, validator, after) {
1962
+ const method = SET + Util_1.Util._capitalize(attr);
1963
+ constructor.prototype[method] = function (val) {
1964
+ if (validator && val !== undefined && val !== null) {
1965
+ val = validator.call(this, val, attr);
1966
+ }
1967
+ this._setAttr(attr, val);
1968
+ if (after) {
1969
+ after.call(this);
1970
+ }
1971
+ return this;
1972
+ };
1973
+ },
1974
+ addComponentsGetterSetter(constructor, attr, components, validator, after) {
1975
+ const len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr);
1976
+ constructor.prototype[getter] = function () {
1977
+ const ret = {};
1978
+ for (let n = 0; n < len; n++) {
1979
+ const component = components[n];
1980
+ ret[component] = this.getAttr(attr + capitalize(component));
1981
+ }
1982
+ return ret;
1983
+ };
1984
+ const basicValidator = (0, Validators_1.getComponentValidator)(components);
1985
+ constructor.prototype[setter] = function (val) {
1986
+ const oldVal = this.attrs[attr];
1987
+ if (validator) {
1988
+ val = validator.call(this, val, attr);
1965
1989
  }
1966
- const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
1967
- if (!pos) {
1968
- return;
1990
+ if (basicValidator) {
1991
+ basicValidator.call(this, val, attr);
1969
1992
  }
1970
- if (elem.dragStatus !== 'dragging') {
1971
- const dragDistance = node.dragDistance();
1972
- const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
1973
- if (distance < dragDistance) {
1974
- return;
1975
- }
1976
- node.startDrag({ evt });
1977
- if (!node.isDragging()) {
1978
- return;
1993
+ for (const key in val) {
1994
+ if (!val.hasOwnProperty(key)) {
1995
+ continue;
1979
1996
  }
1997
+ this._setAttr(attr + capitalize(key), val[key]);
1980
1998
  }
1981
- node._setDragPosition(evt, elem);
1982
- nodesToFireEvents.push(node);
1983
- });
1984
- nodesToFireEvents.forEach((node) => {
1985
- node.fire('dragmove', {
1986
- type: 'dragmove',
1987
- target: node,
1988
- evt: evt,
1989
- }, true);
1990
- });
1991
- },
1992
- _endDragBefore(evt) {
1993
- const drawNodes = [];
1994
- exports.DD._dragElements.forEach((elem) => {
1995
- const { node } = elem;
1996
- const stage = node.getStage();
1997
- if (evt) {
1998
- stage.setPointersPositions(evt);
1999
- }
2000
- const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
2001
- if (!pos) {
2002
- return;
1999
+ if (!val) {
2000
+ components.forEach((component) => {
2001
+ this._setAttr(attr + capitalize(component), undefined);
2002
+ });
2003
2003
  }
2004
- if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
2005
- exports.DD.justDragged = true;
2006
- Global_1.Konva._mouseListenClick = false;
2007
- Global_1.Konva._touchListenClick = false;
2008
- Global_1.Konva._pointerListenClick = false;
2009
- elem.dragStatus = 'stopped';
2004
+ this._fireChangeEvent(attr, oldVal, val);
2005
+ if (after) {
2006
+ after.call(this);
2010
2007
  }
2011
- const drawNode = elem.node.getLayer() ||
2012
- (elem.node instanceof Global_1.Konva['Stage'] && elem.node);
2013
- if (drawNode && drawNodes.indexOf(drawNode) === -1) {
2014
- drawNodes.push(drawNode);
2008
+ return this;
2009
+ };
2010
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
2011
+ },
2012
+ addOverloadedGetterSetter(constructor, attr) {
2013
+ const capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
2014
+ constructor.prototype[attr] = function () {
2015
+ if (arguments.length) {
2016
+ this[setter](arguments[0]);
2017
+ return this;
2015
2018
  }
2019
+ return this[getter]();
2020
+ };
2021
+ },
2022
+ addDeprecatedGetterSetter(constructor, attr, def, validator) {
2023
+ Util_1.Util.error('Adding deprecated ' + attr);
2024
+ const method = GET + Util_1.Util._capitalize(attr);
2025
+ const message = attr +
2026
+ ' property is deprecated and will be removed soon. Look at Konva change log for more information.';
2027
+ constructor.prototype[method] = function () {
2028
+ Util_1.Util.error(message);
2029
+ const val = this.attrs[attr];
2030
+ return val === undefined ? def : val;
2031
+ };
2032
+ exports.Factory.addSetter(constructor, attr, validator, function () {
2033
+ Util_1.Util.error(message);
2016
2034
  });
2017
- drawNodes.forEach((drawNode) => {
2018
- drawNode.draw();
2019
- });
2035
+ exports.Factory.addOverloadedGetterSetter(constructor, attr);
2020
2036
  },
2021
- _endDragAfter(evt) {
2022
- exports.DD._dragElements.forEach((elem, key) => {
2023
- if (elem.dragStatus === 'stopped') {
2024
- elem.node.fire('dragend', {
2025
- type: 'dragend',
2026
- target: elem.node,
2027
- evt: evt,
2028
- }, true);
2029
- }
2030
- if (elem.dragStatus !== 'dragging') {
2031
- exports.DD._dragElements.delete(key);
2037
+ backCompat(constructor, methods) {
2038
+ Util_1.Util.each(methods, function (oldMethodName, newMethodName) {
2039
+ const method = constructor.prototype[newMethodName];
2040
+ const oldGetter = GET + Util_1.Util._capitalize(oldMethodName);
2041
+ const oldSetter = SET + Util_1.Util._capitalize(oldMethodName);
2042
+ function deprecated() {
2043
+ method.apply(this, arguments);
2044
+ Util_1.Util.error('"' +
2045
+ oldMethodName +
2046
+ '" method is deprecated and will be removed soon. Use ""' +
2047
+ newMethodName +
2048
+ '" instead.');
2032
2049
  }
2050
+ constructor.prototype[oldMethodName] = deprecated;
2051
+ constructor.prototype[oldGetter] = deprecated;
2052
+ constructor.prototype[oldSetter] = deprecated;
2033
2053
  });
2034
2054
  },
2055
+ afterSetFilter() {
2056
+ this._filterUpToDate = false;
2057
+ },
2035
2058
  };
2036
- if (Global_1.Konva.isBrowser) {
2037
- window.addEventListener('mouseup', exports.DD._endDragBefore, true);
2038
- window.addEventListener('touchend', exports.DD._endDragBefore, true);
2039
- window.addEventListener('touchcancel', exports.DD._endDragBefore, true);
2040
- window.addEventListener('mousemove', exports.DD._drag);
2041
- window.addEventListener('touchmove', exports.DD._drag);
2042
- window.addEventListener('mouseup', exports.DD._endDragAfter, false);
2043
- window.addEventListener('touchend', exports.DD._endDragAfter, false);
2044
- window.addEventListener('touchcancel', exports.DD._endDragAfter, false);
2045
- }
2046
- } (DragAndDrop));
2047
- return DragAndDrop;
2059
+ } (Factory));
2060
+ return Factory;
2048
2061
  }
2049
2062
 
2050
2063
  var hasRequiredNode;
2051
-
2052
2064
  function requireNode () {
2053
2065
  if (hasRequiredNode) return Node;
2054
2066
  hasRequiredNode = 1;
2055
2067
  Object.defineProperty(Node, "__esModule", { value: true });
2056
- Node.Node = undefined;
2057
- const Util_1 = requireUtil();
2058
- const Factory_1 = requireFactory();
2068
+ Node.Node = void 0;
2059
2069
  const Canvas_1 = requireCanvas();
2060
- const Global_1 = requireGlobal();
2061
2070
  const DragAndDrop_1 = requireDragAndDrop();
2071
+ const Factory_1 = requireFactory();
2072
+ const Global_1 = requireGlobal();
2073
+ const Util_1 = requireUtil();
2062
2074
  const Validators_1 = requireValidators();
2063
- const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
2075
+ const ABSOLUTE_OPACITY = 'absoluteOpacity', ALL_LISTENERS = 'allEventListeners', ABSOLUTE_TRANSFORM = 'absoluteTransform', ABSOLUTE_SCALE = 'absoluteScale', CANVAS = 'canvas', CHANGE = 'Change', CHILDREN = 'children', KONVA = 'konva', LISTENING = 'listening', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', POINTERENTER = 'pointerenter', POINTERLEAVE = 'pointerleave', TOUCHENTER = 'touchenter', TOUCHLEAVE = 'touchleave', SET = 'set', SHAPE = 'Shape', SPACE = ' ', STAGE = 'stage', TRANSFORM = 'transform', UPPER_STAGE = 'Stage', VISIBLE = 'visible', TRANSFORM_CHANGE_STR = [
2064
2076
  'xChange.konva',
2065
2077
  'yChange.konva',
2066
2078
  'scaleXChange.konva',
@@ -2139,8 +2151,8 @@
2139
2151
  }
2140
2152
  clearCache() {
2141
2153
  if (this._cache.has(CANVAS)) {
2142
- const { scene, filter, hit } = this._cache.get(CANVAS);
2143
- Util_1.Util.releaseCanvas(scene, filter, hit);
2154
+ const { scene, filter, hit, buffer } = this._cache.get(CANVAS);
2155
+ Util_1.Util.releaseCanvas(scene, filter, hit, buffer);
2144
2156
  this._cache.delete(CANVAS);
2145
2157
  }
2146
2158
  this._clearSelfAndDescendantCache();
@@ -2184,6 +2196,11 @@
2184
2196
  width: width,
2185
2197
  height: height,
2186
2198
  }), sceneContext = cachedSceneCanvas.getContext(), hitContext = cachedHitCanvas.getContext();
2199
+ const bufferCanvas = new Canvas_1.SceneCanvas({
2200
+ width: cachedSceneCanvas.width / cachedSceneCanvas.pixelRatio + Math.abs(x),
2201
+ height: cachedSceneCanvas.height / cachedSceneCanvas.pixelRatio + Math.abs(y),
2202
+ pixelRatio: cachedSceneCanvas.pixelRatio,
2203
+ }), bufferContext = bufferCanvas.getContext();
2187
2204
  cachedHitCanvas.isCache = true;
2188
2205
  cachedSceneCanvas.isCache = true;
2189
2206
  this._cache.delete(CANVAS);
@@ -2194,12 +2211,16 @@
2194
2211
  }
2195
2212
  sceneContext.save();
2196
2213
  hitContext.save();
2214
+ bufferContext.save();
2197
2215
  sceneContext.translate(-x, -y);
2198
2216
  hitContext.translate(-x, -y);
2217
+ bufferContext.translate(-x, -y);
2218
+ bufferCanvas.x = x;
2219
+ bufferCanvas.y = y;
2199
2220
  this._isUnderCache = true;
2200
2221
  this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY);
2201
2222
  this._clearSelfAndDescendantCache(ABSOLUTE_SCALE);
2202
- this.drawScene(cachedSceneCanvas, this);
2223
+ this.drawScene(cachedSceneCanvas, this, bufferCanvas);
2203
2224
  this.drawHit(cachedHitCanvas, this);
2204
2225
  this._isUnderCache = false;
2205
2226
  sceneContext.restore();
@@ -2218,6 +2239,7 @@
2218
2239
  scene: cachedSceneCanvas,
2219
2240
  filter: cachedFilterCanvas,
2220
2241
  hit: cachedHitCanvas,
2242
+ buffer: bufferCanvas,
2221
2243
  x: x,
2222
2244
  y: y,
2223
2245
  });
@@ -2310,23 +2332,22 @@
2310
2332
  return sceneCanvas;
2311
2333
  }
2312
2334
  on(evtStr, handler) {
2313
- this._cache && this._cache.delete(ALL_LISTENERS);
2335
+ if (this._cache) {
2336
+ this._cache.delete(ALL_LISTENERS);
2337
+ }
2314
2338
  if (arguments.length === 3) {
2315
2339
  return this._delegate.apply(this, arguments);
2316
2340
  }
2317
- let events = evtStr.split(SPACE), len = events.length, n, event, parts, baseEvent, name;
2318
- for (n = 0; n < len; n++) {
2319
- event = events[n];
2320
- parts = event.split('.');
2321
- baseEvent = parts[0];
2322
- name = parts[1] || '';
2341
+ const events = evtStr.split(SPACE);
2342
+ for (let n = 0; n < events.length; n++) {
2343
+ const event = events[n];
2344
+ const parts = event.split('.');
2345
+ const baseEvent = parts[0];
2346
+ const name = parts[1] || '';
2323
2347
  if (!this.eventListeners[baseEvent]) {
2324
2348
  this.eventListeners[baseEvent] = [];
2325
2349
  }
2326
- this.eventListeners[baseEvent].push({
2327
- name: name,
2328
- handler: handler,
2329
- });
2350
+ this.eventListeners[baseEvent].push({ name, handler });
2330
2351
  }
2331
2352
  return this;
2332
2353
  }
@@ -2958,7 +2979,7 @@
2958
2979
  var _a, _b;
2959
2980
  const m = this._cache.get(TRANSFORM) || new Util_1.Transform();
2960
2981
  m.reset();
2961
- const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== undefined ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== undefined ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
2982
+ const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
2962
2983
  if (x !== 0 || y !== 0) {
2963
2984
  m.translate(x, y);
2964
2985
  }
@@ -3160,7 +3181,7 @@
3160
3181
  _requestDraw() {
3161
3182
  if (Global_1.Konva.autoDrawEnabled) {
3162
3183
  const drawNode = this.getLayer() || this.getStage();
3163
- drawNode === null || drawNode === undefined ? undefined : drawNode.batchDraw();
3184
+ drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();
3164
3185
  }
3165
3186
  }
3166
3187
  _setAttr(key, val) {
@@ -3194,14 +3215,22 @@
3194
3215
  if (evt && this.nodeType === SHAPE) {
3195
3216
  evt.target = this;
3196
3217
  }
3197
- const shouldStop = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
3218
+ const nonBubbling = [
3219
+ MOUSEENTER,
3220
+ MOUSELEAVE,
3221
+ POINTERENTER,
3222
+ POINTERLEAVE,
3223
+ TOUCHENTER,
3224
+ TOUCHLEAVE,
3225
+ ];
3226
+ const shouldStop = nonBubbling.indexOf(eventType) !== -1 &&
3198
3227
  ((compareShape &&
3199
3228
  (this === compareShape ||
3200
3229
  (this.isAncestorOf && this.isAncestorOf(compareShape)))) ||
3201
3230
  (this.nodeType === 'Stage' && !compareShape));
3202
3231
  if (!shouldStop) {
3203
3232
  this._fire(eventType, evt);
3204
- const stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
3233
+ const stopBubble = nonBubbling.indexOf(eventType) !== -1 &&
3205
3234
  compareShape &&
3206
3235
  compareShape.isAncestorOf &&
3207
3236
  compareShape.isAncestorOf(this) &&
@@ -3221,13 +3250,13 @@
3221
3250
  }
3222
3251
  _getProtoListeners(eventType) {
3223
3252
  var _a, _b, _c;
3224
- const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== undefined ? _a : {};
3225
- let events = allListeners === null || allListeners === undefined ? undefined : allListeners[eventType];
3253
+ const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== void 0 ? _a : {};
3254
+ let events = allListeners === null || allListeners === void 0 ? void 0 : allListeners[eventType];
3226
3255
  if (events === undefined) {
3227
3256
  events = [];
3228
3257
  let obj = Object.getPrototypeOf(this);
3229
3258
  while (obj) {
3230
- const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === undefined ? undefined : _b[eventType]) !== null && _c !== undefined ? _c : [];
3259
+ const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === void 0 ? void 0 : _b[eventType]) !== null && _c !== void 0 ? _c : [];
3231
3260
  events.push(...hierarchyEvents);
3232
3261
  obj = Object.getPrototypeOf(obj);
3233
3262
  }
@@ -3242,13 +3271,13 @@
3242
3271
  evt.type = eventType;
3243
3272
  const topListeners = this._getProtoListeners(eventType);
3244
3273
  if (topListeners) {
3245
- for (var i = 0; i < topListeners.length; i++) {
3274
+ for (let i = 0; i < topListeners.length; i++) {
3246
3275
  topListeners[i].handler.call(this, evt);
3247
3276
  }
3248
3277
  }
3249
3278
  const selfListeners = this.eventListeners[eventType];
3250
3279
  if (selfListeners) {
3251
- for (var i = 0; i < selfListeners.length; i++) {
3280
+ for (let i = 0; i < selfListeners.length; i++) {
3252
3281
  selfListeners[i].handler.call(this, evt);
3253
3282
  }
3254
3283
  }
@@ -3488,12 +3517,11 @@
3488
3517
  var Container = {};
3489
3518
 
3490
3519
  var hasRequiredContainer;
3491
-
3492
3520
  function requireContainer () {
3493
3521
  if (hasRequiredContainer) return Container;
3494
3522
  hasRequiredContainer = 1;
3495
3523
  Object.defineProperty(Container, "__esModule", { value: true });
3496
- Container.Container = undefined;
3524
+ Container.Container = void 0;
3497
3525
  const Factory_1 = requireFactory();
3498
3526
  const Node_1 = requireNode();
3499
3527
  const Validators_1 = requireValidators();
@@ -3503,17 +3531,11 @@
3503
3531
  this.children = [];
3504
3532
  }
3505
3533
  getChildren(filterFunc) {
3506
- if (!filterFunc) {
3507
- return this.children || [];
3508
- }
3509
3534
  const children = this.children || [];
3510
- const results = [];
3511
- children.forEach(function (child) {
3512
- if (filterFunc(child)) {
3513
- results.push(child);
3514
- }
3515
- });
3516
- return results;
3535
+ if (filterFunc) {
3536
+ return children.filter(filterFunc);
3537
+ }
3538
+ return children;
3517
3539
  }
3518
3540
  hasChildren() {
3519
3541
  return this.getChildren().length > 0;
@@ -3650,13 +3672,13 @@
3650
3672
  if (this.isCached()) {
3651
3673
  return;
3652
3674
  }
3653
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (node) {
3675
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
3654
3676
  node._clearSelfAndDescendantCache(attr);
3655
3677
  });
3656
3678
  }
3657
3679
  _setChildrenIndices() {
3658
3680
  var _a;
3659
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child, n) {
3681
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
3660
3682
  child.index = n;
3661
3683
  });
3662
3684
  this._requestDraw();
@@ -3727,7 +3749,7 @@
3727
3749
  context.save();
3728
3750
  context._applyGlobalCompositeOperation(this);
3729
3751
  }
3730
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child) {
3752
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
3731
3753
  child[drawMethod](canvas, top, bufferCanvas);
3732
3754
  });
3733
3755
  if (hasComposition) {
@@ -3749,7 +3771,7 @@
3749
3771
  height: 0,
3750
3772
  };
3751
3773
  const that = this;
3752
- (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child) {
3774
+ (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
3753
3775
  if (!child.visible()) {
3754
3776
  return;
3755
3777
  }
@@ -3825,7 +3847,6 @@
3825
3847
  var PointerEvents = {};
3826
3848
 
3827
3849
  var hasRequiredPointerEvents;
3828
-
3829
3850
  function requirePointerEvents () {
3830
3851
  if (hasRequiredPointerEvents) return PointerEvents;
3831
3852
  hasRequiredPointerEvents = 1;
@@ -3875,13 +3896,12 @@
3875
3896
  }
3876
3897
 
3877
3898
  var hasRequiredStage;
3878
-
3879
3899
  function requireStage () {
3880
3900
  if (hasRequiredStage) return Stage;
3881
3901
  hasRequiredStage = 1;
3882
3902
  (function (exports) {
3883
3903
  Object.defineProperty(exports, "__esModule", { value: true });
3884
- exports.Stage = exports.stages = undefined;
3904
+ exports.Stage = exports.stages = void 0;
3885
3905
  const Util_1 = requireUtil();
3886
3906
  const Factory_1 = requireFactory();
3887
3907
  const Container_1 = requireContainer();
@@ -3907,6 +3927,7 @@
3907
3927
  [POINTERMOVE, '_pointermove'],
3908
3928
  [POINTERUP, '_pointerup'],
3909
3929
  [POINTERCANCEL, '_pointercancel'],
3930
+ [POINTERLEAVE, '_pointerleave'],
3910
3931
  [LOSTPOINTERCAPTURE, '_lostpointercapture'],
3911
3932
  ];
3912
3933
  const EVENTS_MAP = {
@@ -4008,12 +4029,12 @@
4008
4029
  }
4009
4030
  setContainer(container) {
4010
4031
  if (typeof container === STRING) {
4032
+ let id;
4011
4033
  if (container.charAt(0) === '.') {
4012
4034
  const className = container.slice(1);
4013
4035
  container = document.getElementsByClassName(className)[0];
4014
4036
  }
4015
4037
  else {
4016
- var id;
4017
4038
  if (container.charAt(0) !== '#') {
4018
4039
  id = container;
4019
4040
  }
@@ -4582,7 +4603,7 @@
4582
4603
  stage.batchDraw();
4583
4604
  });
4584
4605
  });
4585
- }
4606
+ }
4586
4607
  } (Stage));
4587
4608
  return Stage;
4588
4609
  }
@@ -4592,13 +4613,12 @@
4592
4613
  var Shape = {};
4593
4614
 
4594
4615
  var hasRequiredShape;
4595
-
4596
4616
  function requireShape () {
4597
4617
  if (hasRequiredShape) return Shape;
4598
4618
  hasRequiredShape = 1;
4599
4619
  (function (exports) {
4600
4620
  Object.defineProperty(exports, "__esModule", { value: true });
4601
- exports.Shape = exports.shapes = undefined;
4621
+ exports.Shape = exports.shapes = void 0;
4602
4622
  const Global_1 = requireGlobal();
4603
4623
  const Util_1 = requireUtil();
4604
4624
  const Factory_1 = requireFactory();
@@ -4831,7 +4851,7 @@
4831
4851
  }
4832
4852
  _useBufferCanvas(forceFill) {
4833
4853
  var _a;
4834
- const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== undefined ? _a : true;
4854
+ const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
4835
4855
  if (!perfectDrawEnabled) {
4836
4856
  return false;
4837
4857
  }
@@ -4916,8 +4936,8 @@
4916
4936
  }
4917
4937
  drawScene(can, top, bufferCanvas) {
4918
4938
  const layer = this.getLayer();
4919
- let canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow(), stage, bufferContext;
4920
- const skipBuffer = canvas.isCache;
4939
+ const canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow();
4940
+ let stage;
4921
4941
  const cachingSelf = top === this;
4922
4942
  if (!this.isVisible() && !cachingSelf) {
4923
4943
  return this;
@@ -4934,14 +4954,14 @@
4934
4954
  return this;
4935
4955
  }
4936
4956
  context.save();
4937
- if (this._useBufferCanvas() && !skipBuffer) {
4957
+ if (this._useBufferCanvas() && true) {
4938
4958
  stage = this.getStage();
4939
4959
  const bc = bufferCanvas || stage.bufferCanvas;
4940
- bufferContext = bc.getContext();
4960
+ const bufferContext = bc.getContext();
4941
4961
  bufferContext.clear();
4942
4962
  bufferContext.save();
4943
4963
  bufferContext._applyLineJoin(this);
4944
- var o = this.getAbsoluteTransform(top).getMatrix();
4964
+ const o = this.getAbsoluteTransform(top).getMatrix();
4945
4965
  bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
4946
4966
  drawFunc.call(this, bufferContext, this);
4947
4967
  bufferContext.restore();
@@ -4951,12 +4971,12 @@
4951
4971
  }
4952
4972
  context._applyOpacity(this);
4953
4973
  context._applyGlobalCompositeOperation(this);
4954
- context.drawImage(bc._canvas, 0, 0, bc.width / ratio, bc.height / ratio);
4974
+ context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
4955
4975
  }
4956
4976
  else {
4957
4977
  context._applyLineJoin(this);
4958
4978
  if (!cachingSelf) {
4959
- var o = this.getAbsoluteTransform(top).getMatrix();
4979
+ const o = this.getAbsoluteTransform(top).getMatrix();
4960
4980
  context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
4961
4981
  context._applyOpacity(this);
4962
4982
  context._applyGlobalCompositeOperation(this);
@@ -5140,18 +5160,17 @@
5140
5160
  drawHitFunc: 'hitFunc',
5141
5161
  getDrawHitFunc: 'getHitFunc',
5142
5162
  setDrawHitFunc: 'setHitFunc',
5143
- });
5163
+ });
5144
5164
  } (Shape));
5145
5165
  return Shape;
5146
5166
  }
5147
5167
 
5148
5168
  var hasRequiredLayer;
5149
-
5150
5169
  function requireLayer () {
5151
5170
  if (hasRequiredLayer) return Layer;
5152
5171
  hasRequiredLayer = 1;
5153
5172
  Object.defineProperty(Layer, "__esModule", { value: true });
5154
- Layer.Layer = undefined;
5173
+ Layer.Layer = void 0;
5155
5174
  const Util_1 = requireUtil();
5156
5175
  const Container_1 = requireContainer();
5157
5176
  const Node_1 = requireNode();
@@ -5396,7 +5415,7 @@
5396
5415
  }
5397
5416
  return {};
5398
5417
  }
5399
- drawScene(can, top) {
5418
+ drawScene(can, top, bufferCanvas) {
5400
5419
  const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
5401
5420
  this._fire(BEFORE_DRAW, {
5402
5421
  node: this,
@@ -5404,7 +5423,7 @@
5404
5423
  if (this.clearBeforeDraw()) {
5405
5424
  canvas.getContext().clear();
5406
5425
  }
5407
- Container_1.Container.prototype.drawScene.call(this, canvas, top);
5426
+ Container_1.Container.prototype.drawScene.call(this, canvas, top, bufferCanvas);
5408
5427
  this._fire(DRAW, {
5409
5428
  node: this,
5410
5429
  });
@@ -5464,12 +5483,11 @@
5464
5483
  var FastLayer = {};
5465
5484
 
5466
5485
  var hasRequiredFastLayer;
5467
-
5468
5486
  function requireFastLayer () {
5469
5487
  if (hasRequiredFastLayer) return FastLayer;
5470
5488
  hasRequiredFastLayer = 1;
5471
5489
  Object.defineProperty(FastLayer, "__esModule", { value: true });
5472
- FastLayer.FastLayer = undefined;
5490
+ FastLayer.FastLayer = void 0;
5473
5491
  const Util_1 = requireUtil();
5474
5492
  const Layer_1 = requireLayer();
5475
5493
  const Global_1 = requireGlobal();
@@ -5489,12 +5507,11 @@
5489
5507
  var Group = {};
5490
5508
 
5491
5509
  var hasRequiredGroup;
5492
-
5493
5510
  function requireGroup () {
5494
5511
  if (hasRequiredGroup) return Group;
5495
5512
  hasRequiredGroup = 1;
5496
5513
  Object.defineProperty(Group, "__esModule", { value: true });
5497
- Group.Group = undefined;
5514
+ Group.Group = void 0;
5498
5515
  const Util_1 = requireUtil();
5499
5516
  const Container_1 = requireContainer();
5500
5517
  const Global_1 = requireGlobal();
@@ -5515,12 +5532,11 @@
5515
5532
  var Animation = {};
5516
5533
 
5517
5534
  var hasRequiredAnimation;
5518
-
5519
5535
  function requireAnimation () {
5520
5536
  if (hasRequiredAnimation) return Animation;
5521
5537
  hasRequiredAnimation = 1;
5522
5538
  Object.defineProperty(Animation, "__esModule", { value: true });
5523
- Animation.Animation = undefined;
5539
+ Animation.Animation = void 0;
5524
5540
  const Global_1 = requireGlobal();
5525
5541
  const Util_1 = requireUtil();
5526
5542
  const now = (function () {
@@ -5670,13 +5686,12 @@
5670
5686
  var Tween = {};
5671
5687
 
5672
5688
  var hasRequiredTween;
5673
-
5674
5689
  function requireTween () {
5675
5690
  if (hasRequiredTween) return Tween;
5676
5691
  hasRequiredTween = 1;
5677
5692
  (function (exports) {
5678
5693
  Object.defineProperty(exports, "__esModule", { value: true });
5679
- exports.Easings = exports.Tween = undefined;
5694
+ exports.Easings = exports.Tween = void 0;
5680
5695
  const Util_1 = requireUtil();
5681
5696
  const Animation_1 = requireAnimation();
5682
5697
  const Node_1 = requireNode();
@@ -6032,10 +6047,21 @@
6032
6047
  destroy() {
6033
6048
  const nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId];
6034
6049
  this.pause();
6050
+ if (this.anim) {
6051
+ this.anim.stop();
6052
+ }
6035
6053
  for (const key in attrs) {
6036
6054
  delete Tween.tweens[nodeId][key];
6037
6055
  }
6038
6056
  delete Tween.attrs[nodeId][thisId];
6057
+ if (Tween.tweens[nodeId]) {
6058
+ if (Object.keys(Tween.tweens[nodeId]).length === 0) {
6059
+ delete Tween.tweens[nodeId];
6060
+ }
6061
+ if (Object.keys(Tween.attrs[nodeId]).length === 0) {
6062
+ delete Tween.attrs[nodeId];
6063
+ }
6064
+ }
6039
6065
  }
6040
6066
  }
6041
6067
  exports.Tween = Tween;
@@ -6197,19 +6223,18 @@
6197
6223
  Linear(t, b, c, d) {
6198
6224
  return (c * t) / d + b;
6199
6225
  },
6200
- };
6226
+ };
6201
6227
  } (Tween));
6202
6228
  return Tween;
6203
6229
  }
6204
6230
 
6205
6231
  var hasRequired_CoreInternals;
6206
-
6207
6232
  function require_CoreInternals () {
6208
6233
  if (hasRequired_CoreInternals) return _CoreInternals;
6209
6234
  hasRequired_CoreInternals = 1;
6210
6235
  (function (exports) {
6211
6236
  Object.defineProperty(exports, "__esModule", { value: true });
6212
- exports.Konva = undefined;
6237
+ exports.Konva = void 0;
6213
6238
  const Global_1 = requireGlobal();
6214
6239
  const Util_1 = requireUtil();
6215
6240
  const Node_1 = requireNode();
@@ -6243,7 +6268,7 @@
6243
6268
  Context: Context_1.Context,
6244
6269
  Canvas: Canvas_1.Canvas,
6245
6270
  });
6246
- exports.default = exports.Konva;
6271
+ exports.default = exports.Konva;
6247
6272
  } (_CoreInternals));
6248
6273
  return _CoreInternals;
6249
6274
  }
@@ -6251,12 +6276,11 @@
6251
6276
  var Arc = {};
6252
6277
 
6253
6278
  var hasRequiredArc;
6254
-
6255
6279
  function requireArc () {
6256
6280
  if (hasRequiredArc) return Arc;
6257
6281
  hasRequiredArc = 1;
6258
6282
  Object.defineProperty(Arc, "__esModule", { value: true });
6259
- Arc.Arc = undefined;
6283
+ Arc.Arc = void 0;
6260
6284
  const Factory_1 = requireFactory();
6261
6285
  const Shape_1 = requireShape();
6262
6286
  const Global_1 = requireGlobal();
@@ -6307,7 +6331,12 @@
6307
6331
  Arc.Arc = Arc$1;
6308
6332
  Arc$1.prototype._centroid = true;
6309
6333
  Arc$1.prototype.className = 'Arc';
6310
- Arc$1.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
6334
+ Arc$1.prototype._attrsAffectingSize = [
6335
+ 'innerRadius',
6336
+ 'outerRadius',
6337
+ 'angle',
6338
+ 'clockwise',
6339
+ ];
6311
6340
  (0, Global_2._registerNode)(Arc$1);
6312
6341
  Factory_1.Factory.addGetterSetter(Arc$1, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
6313
6342
  Factory_1.Factory.addGetterSetter(Arc$1, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
@@ -6321,12 +6350,11 @@
6321
6350
  var Line = {};
6322
6351
 
6323
6352
  var hasRequiredLine;
6324
-
6325
6353
  function requireLine () {
6326
6354
  if (hasRequiredLine) return Line;
6327
6355
  hasRequiredLine = 1;
6328
6356
  Object.defineProperty(Line, "__esModule", { value: true });
6329
- Line.Line = undefined;
6357
+ Line.Line = void 0;
6330
6358
  const Factory_1 = requireFactory();
6331
6359
  const Global_1 = requireGlobal();
6332
6360
  const Shape_1 = requireShape();
@@ -6359,15 +6387,16 @@
6359
6387
  });
6360
6388
  }
6361
6389
  _sceneFunc(context) {
6362
- let points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier(), tp, len, n;
6390
+ const points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier();
6363
6391
  if (!length) {
6364
6392
  return;
6365
6393
  }
6394
+ let n = 0;
6366
6395
  context.beginPath();
6367
6396
  context.moveTo(points[0], points[1]);
6368
6397
  if (tension !== 0 && length > 4) {
6369
- tp = this.getTensionPoints();
6370
- len = tp.length;
6398
+ const tp = this.getTensionPoints();
6399
+ const len = tp.length;
6371
6400
  n = closed ? 0 : 4;
6372
6401
  if (!closed) {
6373
6402
  context.quadraticCurveTo(tp[0], tp[1], tp[2], tp[3]);
@@ -6491,13 +6520,12 @@
6491
6520
  var BezierFunctions = {};
6492
6521
 
6493
6522
  var hasRequiredBezierFunctions;
6494
-
6495
6523
  function requireBezierFunctions () {
6496
6524
  if (hasRequiredBezierFunctions) return BezierFunctions;
6497
6525
  hasRequiredBezierFunctions = 1;
6498
6526
  (function (exports) {
6499
6527
  Object.defineProperty(exports, "__esModule", { value: true });
6500
- exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = undefined;
6528
+ exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = void 0;
6501
6529
  exports.tValues = [
6502
6530
  [],
6503
6531
  [],
@@ -7284,21 +7312,20 @@
7284
7312
  }
7285
7313
  return t;
7286
7314
  };
7287
- exports.t2length = t2length;
7315
+ exports.t2length = t2length;
7288
7316
  } (BezierFunctions));
7289
7317
  return BezierFunctions;
7290
7318
  }
7291
7319
 
7292
7320
  var hasRequiredPath;
7293
-
7294
7321
  function requirePath () {
7295
7322
  if (hasRequiredPath) return Path;
7296
7323
  hasRequiredPath = 1;
7297
7324
  Object.defineProperty(Path, "__esModule", { value: true });
7298
- Path.Path = undefined;
7325
+ Path.Path = void 0;
7299
7326
  const Factory_1 = requireFactory();
7300
- const Shape_1 = requireShape();
7301
7327
  const Global_1 = requireGlobal();
7328
+ const Shape_1 = requireShape();
7302
7329
  const BezierFunctions_1 = requireBezierFunctions();
7303
7330
  let Path$1 = class Path extends Shape_1.Shape {
7304
7331
  constructor(config) {
@@ -7335,10 +7362,10 @@
7335
7362
  context.quadraticCurveTo(p[0], p[1], p[2], p[3]);
7336
7363
  break;
7337
7364
  case 'A':
7338
- var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];
7339
- var r = rx > ry ? rx : ry;
7340
- var scaleX = rx > ry ? 1 : rx / ry;
7341
- var scaleY = rx > ry ? ry / rx : 1;
7365
+ const cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6], fs = p[7];
7366
+ const r = rx > ry ? rx : ry;
7367
+ const scaleX = rx > ry ? 1 : rx / ry;
7368
+ const scaleY = rx > ry ? ry / rx : 1;
7342
7369
  context.translate(cx, cy);
7343
7370
  context.rotate(psi);
7344
7371
  context.scale(scaleX, scaleY);
@@ -7451,11 +7478,20 @@
7451
7478
  };
7452
7479
  }
7453
7480
  if (length < 0.01) {
7454
- points = dataArray[i].points.slice(0, 2);
7455
- return {
7456
- x: points[0],
7457
- y: points[1],
7458
- };
7481
+ const cmd = dataArray[i].command;
7482
+ if (cmd === 'M') {
7483
+ points = dataArray[i].points.slice(0, 2);
7484
+ return {
7485
+ x: points[0],
7486
+ y: points[1],
7487
+ };
7488
+ }
7489
+ else {
7490
+ return {
7491
+ x: dataArray[i].start.x,
7492
+ y: dataArray[i].start.y,
7493
+ };
7494
+ }
7459
7495
  }
7460
7496
  const cp = dataArray[i];
7461
7497
  const p = cp.points;
@@ -7471,15 +7507,16 @@
7471
7507
  return (0, BezierFunctions_1.getQuadraticArcLength)([cp.start.x, p[0], p[2]], [cp.start.y, p[1], p[3]], i);
7472
7508
  }), cp.start.x, cp.start.y, p[0], p[1], p[2], p[3]);
7473
7509
  case 'A':
7474
- var cx = p[0], cy = p[1], rx = p[2], ry = p[3], theta = p[4], dTheta = p[5], psi = p[6];
7510
+ const cx = p[0], cy = p[1], rx = p[2], ry = p[3], dTheta = p[5], psi = p[6];
7511
+ let theta = p[4];
7475
7512
  theta += (dTheta * length) / cp.pathLength;
7476
7513
  return Path.getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi);
7477
7514
  }
7478
7515
  return null;
7479
7516
  }
7480
7517
  static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
7481
- fromX = fromX !== null && fromX !== undefined ? fromX : P1x;
7482
- fromY = fromY !== null && fromY !== undefined ? fromY : P1y;
7518
+ fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;
7519
+ fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;
7483
7520
  const len = this.getLineLength(P1x, P1y, P2x, P2y);
7484
7521
  if (len < 1e-10) {
7485
7522
  return { x: P1x, y: P1y };
@@ -7517,10 +7554,7 @@
7517
7554
  }
7518
7555
  const x = P4x * CB1(pct) + P3x * CB2(pct) + P2x * CB3(pct) + P1x * CB4(pct);
7519
7556
  const y = P4y * CB1(pct) + P3y * CB2(pct) + P2y * CB3(pct) + P1y * CB4(pct);
7520
- return {
7521
- x: x,
7522
- y: y,
7523
- };
7557
+ return { x, y };
7524
7558
  }
7525
7559
  static getPointOnQuadraticBezier(pct, P1x, P1y, P2x, P2y, P3x, P3y) {
7526
7560
  function QB1(t) {
@@ -7534,10 +7568,7 @@
7534
7568
  }
7535
7569
  const x = P3x * QB1(pct) + P2x * QB2(pct) + P1x * QB3(pct);
7536
7570
  const y = P3y * QB1(pct) + P2y * QB2(pct) + P1y * QB3(pct);
7537
- return {
7538
- x: x,
7539
- y: y,
7540
- };
7571
+ return { x, y };
7541
7572
  }
7542
7573
  static getPointOnEllipticalArc(cx, cy, rx, ry, theta, psi) {
7543
7574
  const cosPsi = Math.cos(psi), sinPsi = Math.sin(psi);
@@ -7578,7 +7609,7 @@
7578
7609
  'A',
7579
7610
  ];
7580
7611
  cs = cs.replace(new RegExp(' ', 'g'), ',');
7581
- for (var n = 0; n < cc.length; n++) {
7612
+ for (let n = 0; n < cc.length; n++) {
7582
7613
  cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
7583
7614
  }
7584
7615
  const arr = cs.split('|');
@@ -7588,7 +7619,7 @@
7588
7619
  let cpy = 0;
7589
7620
  const re = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;
7590
7621
  let match;
7591
- for (n = 1; n < arr.length; n++) {
7622
+ for (let n = 1; n < arr.length; n++) {
7592
7623
  let str = arr[n];
7593
7624
  let c = str.charAt(0);
7594
7625
  str = str.slice(1);
@@ -7617,8 +7648,8 @@
7617
7648
  let cmd = '';
7618
7649
  let points = [];
7619
7650
  const startX = cpx, startY = cpy;
7620
- var prevCmd, ctlPtx, ctlPty;
7621
- var rx, ry, psi, fa, fs, x1, y1;
7651
+ let prevCmd, ctlPtx, ctlPty;
7652
+ let rx, ry, psi, fa, fs, x1, y1;
7622
7653
  switch (c) {
7623
7654
  case 'l':
7624
7655
  cpx += p.shift();
@@ -7632,8 +7663,8 @@
7632
7663
  points.push(cpx, cpy);
7633
7664
  break;
7634
7665
  case 'm':
7635
- var dx = p.shift();
7636
- var dy = p.shift();
7666
+ const dx = p.shift();
7667
+ const dy = p.shift();
7637
7668
  cpx += dx;
7638
7669
  cpy += dy;
7639
7670
  cmd = 'M';
@@ -7816,10 +7847,10 @@
7816
7847
  return (0, BezierFunctions_1.getQuadraticArcLength)([x, points[0], points[2]], [y, points[1], points[3]], 1);
7817
7848
  case 'A':
7818
7849
  len = 0.0;
7819
- var start = points[4];
7820
- var dTheta = points[5];
7821
- var end = points[4] + dTheta;
7822
- var inc = Math.PI / 180.0;
7850
+ const start = points[4];
7851
+ const dTheta = points[5];
7852
+ const end = points[4] + dTheta;
7853
+ let inc = Math.PI / 180.0;
7823
7854
  if (Math.abs(start - end) < inc) {
7824
7855
  inc = Math.abs(start - end);
7825
7856
  }
@@ -7903,12 +7934,11 @@
7903
7934
  }
7904
7935
 
7905
7936
  var hasRequiredArrow;
7906
-
7907
7937
  function requireArrow () {
7908
7938
  if (hasRequiredArrow) return Arrow;
7909
7939
  hasRequiredArrow = 1;
7910
7940
  Object.defineProperty(Arrow, "__esModule", { value: true });
7911
- Arrow.Arrow = undefined;
7941
+ Arrow.Arrow = void 0;
7912
7942
  const Factory_1 = requireFactory();
7913
7943
  const Line_1 = requireLine();
7914
7944
  const Validators_1 = requireValidators();
@@ -8015,12 +8045,11 @@
8015
8045
  var Circle = {};
8016
8046
 
8017
8047
  var hasRequiredCircle;
8018
-
8019
8048
  function requireCircle () {
8020
8049
  if (hasRequiredCircle) return Circle;
8021
8050
  hasRequiredCircle = 1;
8022
8051
  Object.defineProperty(Circle, "__esModule", { value: true });
8023
- Circle.Circle = undefined;
8052
+ Circle.Circle = void 0;
8024
8053
  const Factory_1 = requireFactory();
8025
8054
  const Shape_1 = requireShape();
8026
8055
  const Validators_1 = requireValidators();
@@ -8061,12 +8090,11 @@
8061
8090
  var Ellipse = {};
8062
8091
 
8063
8092
  var hasRequiredEllipse;
8064
-
8065
8093
  function requireEllipse () {
8066
8094
  if (hasRequiredEllipse) return Ellipse;
8067
8095
  hasRequiredEllipse = 1;
8068
8096
  Object.defineProperty(Ellipse, "__esModule", { value: true });
8069
- Ellipse.Ellipse = undefined;
8097
+ Ellipse.Ellipse = void 0;
8070
8098
  const Factory_1 = requireFactory();
8071
8099
  const Shape_1 = requireShape();
8072
8100
  const Validators_1 = requireValidators();
@@ -8111,12 +8139,11 @@
8111
8139
  var Image$1 = {};
8112
8140
 
8113
8141
  var hasRequiredImage;
8114
-
8115
8142
  function requireImage () {
8116
8143
  if (hasRequiredImage) return Image$1;
8117
8144
  hasRequiredImage = 1;
8118
8145
  Object.defineProperty(Image$1, "__esModule", { value: true });
8119
- Image$1.Image = undefined;
8146
+ Image$1.Image = void 0;
8120
8147
  const Util_1 = requireUtil();
8121
8148
  const Factory_1 = requireFactory();
8122
8149
  const Shape_1 = requireShape();
@@ -8125,7 +8152,11 @@
8125
8152
  class Image extends Shape_1.Shape {
8126
8153
  constructor(attrs) {
8127
8154
  super(attrs);
8128
- this.on('imageChange.konva', () => {
8155
+ this._loadListener = () => {
8156
+ this._requestDraw();
8157
+ };
8158
+ this.on('imageChange.konva', (props) => {
8159
+ this._removeImageLoad(props.oldVal);
8129
8160
  this._setImageLoad();
8130
8161
  });
8131
8162
  this._setImageLoad();
@@ -8139,11 +8170,19 @@
8139
8170
  return;
8140
8171
  }
8141
8172
  if (image && image['addEventListener']) {
8142
- image['addEventListener']('load', () => {
8143
- this._requestDraw();
8144
- });
8173
+ image['addEventListener']('load', this._loadListener);
8174
+ }
8175
+ }
8176
+ _removeImageLoad(image) {
8177
+ if (image && image['removeEventListener']) {
8178
+ image['removeEventListener']('load', this._loadListener);
8145
8179
  }
8146
8180
  }
8181
+ destroy() {
8182
+ this._removeImageLoad(this.image());
8183
+ super.destroy();
8184
+ return this;
8185
+ }
8147
8186
  _useBufferCanvas() {
8148
8187
  const hasCornerRadius = !!this.cornerRadius();
8149
8188
  const hasShadow = this.hasShadow();
@@ -8207,11 +8246,11 @@
8207
8246
  }
8208
8247
  getWidth() {
8209
8248
  var _a, _b;
8210
- return (_a = this.attrs.width) !== null && _a !== undefined ? _a : (_b = this.image()) === null || _b === undefined ? undefined : _b.width;
8249
+ return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
8211
8250
  }
8212
8251
  getHeight() {
8213
8252
  var _a, _b;
8214
- return (_a = this.attrs.height) !== null && _a !== undefined ? _a : (_b = this.image()) === null || _b === undefined ? undefined : _b.height;
8253
+ return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
8215
8254
  }
8216
8255
  static fromURL(url, callback, onError = null) {
8217
8256
  const img = Util_1.Util.createImageElement();
@@ -8242,12 +8281,11 @@
8242
8281
  var Label = {};
8243
8282
 
8244
8283
  var hasRequiredLabel;
8245
-
8246
8284
  function requireLabel () {
8247
8285
  if (hasRequiredLabel) return Label;
8248
8286
  hasRequiredLabel = 1;
8249
8287
  Object.defineProperty(Label, "__esModule", { value: true });
8250
- Label.Tag = Label.Label = undefined;
8288
+ Label.Tag = Label.Label = void 0;
8251
8289
  const Factory_1 = requireFactory();
8252
8290
  const Shape_1 = requireShape();
8253
8291
  const Group_1 = requireGroup();
@@ -8429,12 +8467,11 @@
8429
8467
  var Rect = {};
8430
8468
 
8431
8469
  var hasRequiredRect;
8432
-
8433
8470
  function requireRect () {
8434
8471
  if (hasRequiredRect) return Rect;
8435
8472
  hasRequiredRect = 1;
8436
8473
  Object.defineProperty(Rect, "__esModule", { value: true });
8437
- Rect.Rect = undefined;
8474
+ Rect.Rect = void 0;
8438
8475
  const Factory_1 = requireFactory();
8439
8476
  const Shape_1 = requireShape();
8440
8477
  const Global_1 = requireGlobal();
@@ -8464,12 +8501,11 @@
8464
8501
  var RegularPolygon = {};
8465
8502
 
8466
8503
  var hasRequiredRegularPolygon;
8467
-
8468
8504
  function requireRegularPolygon () {
8469
8505
  if (hasRequiredRegularPolygon) return RegularPolygon;
8470
8506
  hasRequiredRegularPolygon = 1;
8471
8507
  Object.defineProperty(RegularPolygon, "__esModule", { value: true });
8472
- RegularPolygon.RegularPolygon = undefined;
8508
+ RegularPolygon.RegularPolygon = void 0;
8473
8509
  const Factory_1 = requireFactory();
8474
8510
  const Shape_1 = requireShape();
8475
8511
  const Validators_1 = requireValidators();
@@ -8542,12 +8578,11 @@
8542
8578
  var Ring = {};
8543
8579
 
8544
8580
  var hasRequiredRing;
8545
-
8546
8581
  function requireRing () {
8547
8582
  if (hasRequiredRing) return Ring;
8548
8583
  hasRequiredRing = 1;
8549
8584
  Object.defineProperty(Ring, "__esModule", { value: true });
8550
- Ring.Ring = undefined;
8585
+ Ring.Ring = void 0;
8551
8586
  const Factory_1 = requireFactory();
8552
8587
  const Shape_1 = requireShape();
8553
8588
  const Validators_1 = requireValidators();
@@ -8588,12 +8623,11 @@
8588
8623
  var Sprite = {};
8589
8624
 
8590
8625
  var hasRequiredSprite;
8591
-
8592
8626
  function requireSprite () {
8593
8627
  if (hasRequiredSprite) return Sprite;
8594
8628
  hasRequiredSprite = 1;
8595
8629
  Object.defineProperty(Sprite, "__esModule", { value: true });
8596
- Sprite.Sprite = undefined;
8630
+ Sprite.Sprite = void 0;
8597
8631
  const Factory_1 = requireFactory();
8598
8632
  const Shape_1 = requireShape();
8599
8633
  const Animation_1 = requireAnimation();
@@ -8709,12 +8743,11 @@
8709
8743
  var Star = {};
8710
8744
 
8711
8745
  var hasRequiredStar;
8712
-
8713
8746
  function requireStar () {
8714
8747
  if (hasRequiredStar) return Star;
8715
8748
  hasRequiredStar = 1;
8716
8749
  Object.defineProperty(Star, "__esModule", { value: true });
8717
- Star.Star = undefined;
8750
+ Star.Star = void 0;
8718
8751
  const Factory_1 = requireFactory();
8719
8752
  const Shape_1 = requireShape();
8720
8753
  const Validators_1 = requireValidators();
@@ -8760,12 +8793,11 @@
8760
8793
  var Text = {};
8761
8794
 
8762
8795
  var hasRequiredText;
8763
-
8764
8796
  function requireText () {
8765
8797
  if (hasRequiredText) return Text;
8766
8798
  hasRequiredText = 1;
8767
8799
  Object.defineProperty(Text, "__esModule", { value: true });
8768
- Text.Text = undefined;
8800
+ Text.Text = void 0;
8769
8801
  Text.stringToArray = stringToArray;
8770
8802
  const Util_1 = requireUtil();
8771
8803
  const Factory_1 = requireFactory();
@@ -8878,8 +8910,6 @@
8878
8910
  (metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
8879
8911
  lineHeightPx / 2;
8880
8912
  }
8881
- var lineTranslateX = 0;
8882
- var lineTranslateY = 0;
8883
8913
  if (direction === RTL) {
8884
8914
  context.setAttr('direction', direction);
8885
8915
  }
@@ -8894,9 +8924,9 @@
8894
8924
  }
8895
8925
  context.translate(padding, alignY + padding);
8896
8926
  for (n = 0; n < textArrLen; n++) {
8897
- var lineTranslateX = 0;
8898
- var lineTranslateY = 0;
8899
- var obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph, spacesNumber, lineWidth;
8927
+ let lineTranslateX = 0;
8928
+ let lineTranslateY = 0;
8929
+ const obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph;
8900
8930
  context.save();
8901
8931
  if (align === RIGHT) {
8902
8932
  lineTranslateX += totalWidth - width - padding * 2;
@@ -8913,9 +8943,7 @@
8913
8943
  const x = lineTranslateX;
8914
8944
  const y = translateY + lineTranslateY + yOffset;
8915
8945
  context.moveTo(x, y);
8916
- spacesNumber = text.split(' ').length - 1;
8917
- lineWidth =
8918
- align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
8946
+ const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
8919
8947
  context.lineTo(x + Math.round(lineWidth), y);
8920
8948
  context.lineWidth = fontSize / 15;
8921
8949
  const gradient = this._getLinearGradient();
@@ -8928,9 +8956,7 @@
8928
8956
  context.beginPath();
8929
8957
  const yOffset = Global_1.Konva._fixTextRendering ? -Math.round(fontSize / 4) : 0;
8930
8958
  context.moveTo(lineTranslateX, translateY + lineTranslateY + yOffset);
8931
- spacesNumber = text.split(' ').length - 1;
8932
- lineWidth =
8933
- align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
8959
+ const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
8934
8960
  context.lineTo(lineTranslateX + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
8935
8961
  context.lineWidth = fontSize / 15;
8936
8962
  const gradient = this._getLinearGradient();
@@ -8939,7 +8965,7 @@
8939
8965
  context.restore();
8940
8966
  }
8941
8967
  if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) {
8942
- spacesNumber = text.split(' ').length - 1;
8968
+ const spacesNumber = text.split(' ').length - 1;
8943
8969
  const array = stringToArray(text);
8944
8970
  for (let li = 0; li < array.length; li++) {
8945
8971
  const letter = array[li];
@@ -9011,17 +9037,17 @@
9011
9037
  _context.restore();
9012
9038
  const scaleFactor = fontSize / 100;
9013
9039
  return {
9014
- actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== undefined ? _a : 71.58203125 * scaleFactor,
9015
- actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== undefined ? _b : 0,
9016
- actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== undefined ? _c : -7.421875 * scaleFactor,
9017
- actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== undefined ? _d : 75.732421875 * scaleFactor,
9018
- alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== undefined ? _e : 0,
9019
- emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== undefined ? _f : 100 * scaleFactor,
9020
- emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== undefined ? _g : -20 * scaleFactor,
9021
- fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== undefined ? _h : 91 * scaleFactor,
9022
- fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== undefined ? _j : 21 * scaleFactor,
9023
- hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== undefined ? _k : 72.80000305175781 * scaleFactor,
9024
- ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== undefined ? _l : -21 * scaleFactor,
9040
+ actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== void 0 ? _a : 71.58203125 * scaleFactor,
9041
+ actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== void 0 ? _b : 0,
9042
+ actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== void 0 ? _c : -7.421875 * scaleFactor,
9043
+ actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== void 0 ? _d : 75.732421875 * scaleFactor,
9044
+ alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== void 0 ? _e : 0,
9045
+ emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== void 0 ? _f : 100 * scaleFactor,
9046
+ emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== void 0 ? _g : -20 * scaleFactor,
9047
+ fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== void 0 ? _h : 91 * scaleFactor,
9048
+ fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== void 0 ? _j : 21 * scaleFactor,
9049
+ hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== void 0 ? _k : 72.80000305175781 * scaleFactor,
9050
+ ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== void 0 ? _l : -21 * scaleFactor,
9025
9051
  width: metrics.width,
9026
9052
  height: fontSize,
9027
9053
  };
@@ -9065,8 +9091,14 @@
9065
9091
  while (line.length > 0) {
9066
9092
  let low = 0, high = stringToArray(line).length, match = '', matchWidth = 0;
9067
9093
  while (low < high) {
9068
- const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr) + additionalWidth;
9069
- if (substrWidth <= maxWidth) {
9094
+ const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr);
9095
+ const shouldConsiderEllipsis = shouldAddEllipsis &&
9096
+ fixedHeight &&
9097
+ currentHeightPx + lineHeightPx > maxHeightPx;
9098
+ const effectiveWidth = shouldConsiderEllipsis
9099
+ ? substrWidth + additionalWidth
9100
+ : substrWidth;
9101
+ if (effectiveWidth <= maxWidth) {
9070
9102
  low = mid + 1;
9071
9103
  match = substr;
9072
9104
  matchWidth = substrWidth;
@@ -9208,12 +9240,11 @@
9208
9240
  var TextPath = {};
9209
9241
 
9210
9242
  var hasRequiredTextPath;
9211
-
9212
9243
  function requireTextPath () {
9213
9244
  if (hasRequiredTextPath) return TextPath;
9214
9245
  hasRequiredTextPath = 1;
9215
9246
  Object.defineProperty(TextPath, "__esModule", { value: true });
9216
- TextPath.TextPath = undefined;
9247
+ TextPath.TextPath = void 0;
9217
9248
  const Util_1 = requireUtil();
9218
9249
  const Factory_1 = requireFactory();
9219
9250
  const Shape_1 = requireShape();
@@ -9458,12 +9489,11 @@
9458
9489
  var Transformer = {};
9459
9490
 
9460
9491
  var hasRequiredTransformer;
9461
-
9462
9492
  function requireTransformer () {
9463
9493
  if (hasRequiredTransformer) return Transformer;
9464
9494
  hasRequiredTransformer = 1;
9465
9495
  Object.defineProperty(Transformer, "__esModule", { value: true });
9466
- Transformer.Transformer = undefined;
9496
+ Transformer.Transformer = void 0;
9467
9497
  const Util_1 = requireUtil();
9468
9498
  const Factory_1 = requireFactory();
9469
9499
  const Node_1 = requireNode();
@@ -9660,10 +9690,12 @@
9660
9690
  this.update();
9661
9691
  }
9662
9692
  };
9663
- const additionalEvents = node._attrsAffectingSize
9664
- .map((prop) => prop + 'Change.' + this._getEventNamespace())
9665
- .join(' ');
9666
- node.on(additionalEvents, onChange);
9693
+ if (node._attrsAffectingSize.length) {
9694
+ const additionalEvents = node._attrsAffectingSize
9695
+ .map((prop) => prop + 'Change.' + this._getEventNamespace())
9696
+ .join(' ');
9697
+ node.on(additionalEvents, onChange);
9698
+ }
9667
9699
  node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
9668
9700
  node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
9669
9701
  this._proxyDrag(node);
@@ -9982,10 +10014,10 @@
9982
10014
  else {
9983
10015
  keepProportion = this.keepRatio() || e.shiftKey;
9984
10016
  }
9985
- var centeredScaling = this.centeredScaling() || e.altKey;
10017
+ let centeredScaling = this.centeredScaling() || e.altKey;
9986
10018
  if (this._movingAnchorName === 'top-left') {
9987
10019
  if (keepProportion) {
9988
- var comparePoint = centeredScaling
10020
+ const comparePoint = centeredScaling
9989
10021
  ? {
9990
10022
  x: this.width() / 2,
9991
10023
  y: this.height() / 2,
@@ -9996,8 +10028,8 @@
9996
10028
  };
9997
10029
  newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
9998
10030
  Math.pow(comparePoint.y - anchorNode.y(), 2));
9999
- var reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;
10000
- var reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;
10031
+ const reverseX = this.findOne('.top-left').x() > comparePoint.x ? -1 : 1;
10032
+ const reverseY = this.findOne('.top-left').y() > comparePoint.y ? -1 : 1;
10001
10033
  x = newHypotenuse * this.cos * reverseX;
10002
10034
  y = newHypotenuse * this.sin * reverseY;
10003
10035
  this.findOne('.top-left').x(comparePoint.x - x);
@@ -10009,7 +10041,7 @@
10009
10041
  }
10010
10042
  else if (this._movingAnchorName === 'top-right') {
10011
10043
  if (keepProportion) {
10012
- var comparePoint = centeredScaling
10044
+ const comparePoint = centeredScaling
10013
10045
  ? {
10014
10046
  x: this.width() / 2,
10015
10047
  y: this.height() / 2,
@@ -10020,8 +10052,8 @@
10020
10052
  };
10021
10053
  newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
10022
10054
  Math.pow(comparePoint.y - anchorNode.y(), 2));
10023
- var reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;
10024
- var reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;
10055
+ const reverseX = this.findOne('.top-right').x() < comparePoint.x ? -1 : 1;
10056
+ const reverseY = this.findOne('.top-right').y() > comparePoint.y ? -1 : 1;
10025
10057
  x = newHypotenuse * this.cos * reverseX;
10026
10058
  y = newHypotenuse * this.sin * reverseY;
10027
10059
  this.findOne('.top-right').x(comparePoint.x + x);
@@ -10039,7 +10071,7 @@
10039
10071
  }
10040
10072
  else if (this._movingAnchorName === 'bottom-left') {
10041
10073
  if (keepProportion) {
10042
- var comparePoint = centeredScaling
10074
+ const comparePoint = centeredScaling
10043
10075
  ? {
10044
10076
  x: this.width() / 2,
10045
10077
  y: this.height() / 2,
@@ -10050,8 +10082,8 @@
10050
10082
  };
10051
10083
  newHypotenuse = Math.sqrt(Math.pow(comparePoint.x - anchorNode.x(), 2) +
10052
10084
  Math.pow(anchorNode.y() - comparePoint.y, 2));
10053
- var reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;
10054
- var reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;
10085
+ const reverseX = comparePoint.x < anchorNode.x() ? -1 : 1;
10086
+ const reverseY = anchorNode.y() < comparePoint.y ? -1 : 1;
10055
10087
  x = newHypotenuse * this.cos * reverseX;
10056
10088
  y = newHypotenuse * this.sin * reverseY;
10057
10089
  anchorNode.x(comparePoint.x - x);
@@ -10066,7 +10098,7 @@
10066
10098
  }
10067
10099
  else if (this._movingAnchorName === 'bottom-right') {
10068
10100
  if (keepProportion) {
10069
- var comparePoint = centeredScaling
10101
+ const comparePoint = centeredScaling
10070
10102
  ? {
10071
10103
  x: this.width() / 2,
10072
10104
  y: this.height() / 2,
@@ -10077,8 +10109,8 @@
10077
10109
  };
10078
10110
  newHypotenuse = Math.sqrt(Math.pow(anchorNode.x() - comparePoint.x, 2) +
10079
10111
  Math.pow(anchorNode.y() - comparePoint.y, 2));
10080
- var reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;
10081
- var reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;
10112
+ const reverseX = this.findOne('.bottom-right').x() < comparePoint.x ? -1 : 1;
10113
+ const reverseY = this.findOne('.bottom-right').y() < comparePoint.y ? -1 : 1;
10082
10114
  x = newHypotenuse * this.cos * reverseX;
10083
10115
  y = newHypotenuse * this.sin * reverseY;
10084
10116
  this.findOne('.bottom-right').x(comparePoint.x + x);
@@ -10089,7 +10121,7 @@
10089
10121
  console.error(new Error('Wrong position argument of selection resizer: ' +
10090
10122
  this._movingAnchorName));
10091
10123
  }
10092
- var centeredScaling = this.centeredScaling() || e.altKey;
10124
+ centeredScaling = this.centeredScaling() || e.altKey;
10093
10125
  if (centeredScaling) {
10094
10126
  const topLeft = this.findOne('.top-left');
10095
10127
  const bottomRight = this.findOne('.bottom-right');
@@ -10138,12 +10170,12 @@
10138
10170
  const node = this.getNode();
10139
10171
  activeTransformersCount--;
10140
10172
  this._fire('transformend', { evt: e, target: node });
10141
- (_a = this.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10173
+ (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10142
10174
  if (node) {
10143
10175
  this._nodes.forEach((target) => {
10144
10176
  var _a;
10145
10177
  target._fire('transformend', { evt: e, target });
10146
- (_a = target.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10178
+ (_a = target.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10147
10179
  });
10148
10180
  }
10149
10181
  this._movingAnchorName = null;
@@ -10256,7 +10288,7 @@
10256
10288
  .multiply(localTransform);
10257
10289
  const attrs = newLocalTransform.decompose();
10258
10290
  node.setAttrs(attrs);
10259
- (_a = node.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10291
+ (_a = node.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10260
10292
  });
10261
10293
  this.rotation(Util_1.Util._getRotation(newAttrs.rotation));
10262
10294
  this._nodes.forEach((node) => {
@@ -10371,7 +10403,7 @@
10371
10403
  styleFunc(node);
10372
10404
  });
10373
10405
  }
10374
- (_a = this.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10406
+ (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10375
10407
  }
10376
10408
  isTransforming() {
10377
10409
  return this._transforming;
@@ -10473,12 +10505,11 @@
10473
10505
  var Wedge = {};
10474
10506
 
10475
10507
  var hasRequiredWedge;
10476
-
10477
10508
  function requireWedge () {
10478
10509
  if (hasRequiredWedge) return Wedge;
10479
10510
  hasRequiredWedge = 1;
10480
10511
  Object.defineProperty(Wedge, "__esModule", { value: true });
10481
- Wedge.Wedge = undefined;
10512
+ Wedge.Wedge = void 0;
10482
10513
  const Factory_1 = requireFactory();
10483
10514
  const Shape_1 = requireShape();
10484
10515
  const Global_1 = requireGlobal();
@@ -10524,12 +10555,11 @@
10524
10555
  var Blur = {};
10525
10556
 
10526
10557
  var hasRequiredBlur;
10527
-
10528
10558
  function requireBlur () {
10529
10559
  if (hasRequiredBlur) return Blur;
10530
10560
  hasRequiredBlur = 1;
10531
10561
  Object.defineProperty(Blur, "__esModule", { value: true });
10532
- Blur.Blur = undefined;
10562
+ Blur.Blur = void 0;
10533
10563
  const Factory_1 = requireFactory();
10534
10564
  const Node_1 = requireNode();
10535
10565
  const Validators_1 = requireValidators();
@@ -10577,10 +10607,10 @@
10577
10607
  ];
10578
10608
  function filterGaussBlurRGBA(imageData, radius) {
10579
10609
  const pixels = imageData.data, width = imageData.width, height = imageData.height;
10580
- let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
10610
+ let p, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
10581
10611
  const div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), mul_sum = mul_table[radius], shg_sum = shg_table[radius];
10582
10612
  let stackEnd = null, stack = stackStart, stackIn = null, stackOut = null;
10583
- for (i = 1; i < div; i++) {
10613
+ for (let i = 1; i < div; i++) {
10584
10614
  stack = stack.next = new BlurStack();
10585
10615
  if (i === radiusPlus1) {
10586
10616
  stackEnd = stack;
@@ -10588,7 +10618,7 @@
10588
10618
  }
10589
10619
  stack.next = stackStart;
10590
10620
  yw = yi = 0;
10591
- for (y = 0; y < height; y++) {
10621
+ for (let y = 0; y < height; y++) {
10592
10622
  r_in_sum =
10593
10623
  g_in_sum =
10594
10624
  b_in_sum =
@@ -10607,14 +10637,14 @@
10607
10637
  b_sum += sumFactor * pb;
10608
10638
  a_sum += sumFactor * pa;
10609
10639
  stack = stackStart;
10610
- for (i = 0; i < radiusPlus1; i++) {
10640
+ for (let i = 0; i < radiusPlus1; i++) {
10611
10641
  stack.r = pr;
10612
10642
  stack.g = pg;
10613
10643
  stack.b = pb;
10614
10644
  stack.a = pa;
10615
10645
  stack = stack.next;
10616
10646
  }
10617
- for (i = 1; i < radiusPlus1; i++) {
10647
+ for (let i = 1; i < radiusPlus1; i++) {
10618
10648
  p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
10619
10649
  r_sum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
10620
10650
  g_sum += (stack.g = pg = pixels[p + 1]) * rbs;
@@ -10628,7 +10658,7 @@
10628
10658
  }
10629
10659
  stackIn = stackStart;
10630
10660
  stackOut = stackEnd;
10631
- for (x = 0; x < width; x++) {
10661
+ for (let x = 0; x < width; x++) {
10632
10662
  pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
10633
10663
  if (pa !== 0) {
10634
10664
  pa = 255 / pa;
@@ -10670,7 +10700,7 @@
10670
10700
  }
10671
10701
  yw += width;
10672
10702
  }
10673
- for (x = 0; x < width; x++) {
10703
+ for (let x = 0; x < width; x++) {
10674
10704
  g_in_sum =
10675
10705
  b_in_sum =
10676
10706
  a_in_sum =
@@ -10690,15 +10720,15 @@
10690
10720
  b_sum += sumFactor * pb;
10691
10721
  a_sum += sumFactor * pa;
10692
10722
  stack = stackStart;
10693
- for (i = 0; i < radiusPlus1; i++) {
10723
+ for (let i = 0; i < radiusPlus1; i++) {
10694
10724
  stack.r = pr;
10695
10725
  stack.g = pg;
10696
10726
  stack.b = pb;
10697
10727
  stack.a = pa;
10698
10728
  stack = stack.next;
10699
10729
  }
10700
- yp = width;
10701
- for (i = 1; i <= radius; i++) {
10730
+ let yp = width;
10731
+ for (let i = 1; i <= radius; i++) {
10702
10732
  yi = (yp + x) << 2;
10703
10733
  r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
10704
10734
  g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;
@@ -10716,7 +10746,7 @@
10716
10746
  yi = x;
10717
10747
  stackIn = stackStart;
10718
10748
  stackOut = stackEnd;
10719
- for (y = 0; y < height; y++) {
10749
+ for (let y = 0; y < height; y++) {
10720
10750
  p = yi << 2;
10721
10751
  pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
10722
10752
  if (pa > 0) {
@@ -10772,12 +10802,11 @@
10772
10802
  var Brighten = {};
10773
10803
 
10774
10804
  var hasRequiredBrighten;
10775
-
10776
10805
  function requireBrighten () {
10777
10806
  if (hasRequiredBrighten) return Brighten;
10778
10807
  hasRequiredBrighten = 1;
10779
10808
  Object.defineProperty(Brighten, "__esModule", { value: true });
10780
- Brighten.Brighten = undefined;
10809
+ Brighten.Brighten = void 0;
10781
10810
  const Factory_1 = requireFactory();
10782
10811
  const Node_1 = requireNode();
10783
10812
  const Validators_1 = requireValidators();
@@ -10797,12 +10826,11 @@
10797
10826
  var Contrast = {};
10798
10827
 
10799
10828
  var hasRequiredContrast;
10800
-
10801
10829
  function requireContrast () {
10802
10830
  if (hasRequiredContrast) return Contrast;
10803
10831
  hasRequiredContrast = 1;
10804
10832
  Object.defineProperty(Contrast, "__esModule", { value: true });
10805
- Contrast.Contrast = undefined;
10833
+ Contrast.Contrast = void 0;
10806
10834
  const Factory_1 = requireFactory();
10807
10835
  const Node_1 = requireNode();
10808
10836
  const Validators_1 = requireValidators();
@@ -10845,12 +10873,11 @@
10845
10873
  var Emboss = {};
10846
10874
 
10847
10875
  var hasRequiredEmboss;
10848
-
10849
10876
  function requireEmboss () {
10850
10877
  if (hasRequiredEmboss) return Emboss;
10851
10878
  hasRequiredEmboss = 1;
10852
10879
  Object.defineProperty(Emboss, "__esModule", { value: true });
10853
- Emboss.Emboss = undefined;
10880
+ Emboss.Emboss = void 0;
10854
10881
  const Factory_1 = requireFactory();
10855
10882
  const Node_1 = requireNode();
10856
10883
  const Util_1 = requireUtil();
@@ -10961,12 +10988,11 @@
10961
10988
  var Enhance = {};
10962
10989
 
10963
10990
  var hasRequiredEnhance;
10964
-
10965
10991
  function requireEnhance () {
10966
10992
  if (hasRequiredEnhance) return Enhance;
10967
10993
  hasRequiredEnhance = 1;
10968
10994
  Object.defineProperty(Enhance, "__esModule", { value: true });
10969
- Enhance.Enhance = undefined;
10995
+ Enhance.Enhance = void 0;
10970
10996
  const Factory_1 = requireFactory();
10971
10997
  const Node_1 = requireNode();
10972
10998
  const Validators_1 = requireValidators();
@@ -11024,7 +11050,7 @@
11024
11050
  bMax = 255;
11025
11051
  bMin = 0;
11026
11052
  }
11027
- let rMid, rGoalMax, rGoalMin, gMid, gGoalMax, gGoalMin, bMid, bGoalMax, bGoalMin;
11053
+ let rGoalMax, rGoalMin, gGoalMax, gGoalMin, bGoalMax, bGoalMin;
11028
11054
  if (enhanceAmount > 0) {
11029
11055
  rGoalMax = rMax + enhanceAmount * (255 - rMax);
11030
11056
  rGoalMin = rMin - enhanceAmount * (rMin - 0);
@@ -11034,13 +11060,13 @@
11034
11060
  bGoalMin = bMin - enhanceAmount * (bMin - 0);
11035
11061
  }
11036
11062
  else {
11037
- rMid = (rMax + rMin) * 0.5;
11063
+ const rMid = (rMax + rMin) * 0.5;
11038
11064
  rGoalMax = rMax + enhanceAmount * (rMax - rMid);
11039
11065
  rGoalMin = rMin + enhanceAmount * (rMin - rMid);
11040
- gMid = (gMax + gMin) * 0.5;
11066
+ const gMid = (gMax + gMin) * 0.5;
11041
11067
  gGoalMax = gMax + enhanceAmount * (gMax - gMid);
11042
11068
  gGoalMin = gMin + enhanceAmount * (gMin - gMid);
11043
- bMid = (bMax + bMin) * 0.5;
11069
+ const bMid = (bMax + bMin) * 0.5;
11044
11070
  bGoalMax = bMax + enhanceAmount * (bMax - bMid);
11045
11071
  bGoalMin = bMin + enhanceAmount * (bMin - bMid);
11046
11072
  }
@@ -11058,12 +11084,11 @@
11058
11084
  var Grayscale = {};
11059
11085
 
11060
11086
  var hasRequiredGrayscale;
11061
-
11062
11087
  function requireGrayscale () {
11063
11088
  if (hasRequiredGrayscale) return Grayscale;
11064
11089
  hasRequiredGrayscale = 1;
11065
11090
  Object.defineProperty(Grayscale, "__esModule", { value: true });
11066
- Grayscale.Grayscale = undefined;
11091
+ Grayscale.Grayscale = void 0;
11067
11092
  const Grayscale$1 = function (imageData) {
11068
11093
  const data = imageData.data, len = data.length;
11069
11094
  for (let i = 0; i < len; i += 4) {
@@ -11080,12 +11105,11 @@
11080
11105
  var HSL = {};
11081
11106
 
11082
11107
  var hasRequiredHSL;
11083
-
11084
11108
  function requireHSL () {
11085
11109
  if (hasRequiredHSL) return HSL;
11086
11110
  hasRequiredHSL = 1;
11087
11111
  Object.defineProperty(HSL, "__esModule", { value: true });
11088
- HSL.HSL = undefined;
11112
+ HSL.HSL = void 0;
11089
11113
  const Factory_1 = requireFactory();
11090
11114
  const Node_1 = requireNode();
11091
11115
  const Validators_1 = requireValidators();
@@ -11117,12 +11141,11 @@
11117
11141
  var HSV = {};
11118
11142
 
11119
11143
  var hasRequiredHSV;
11120
-
11121
11144
  function requireHSV () {
11122
11145
  if (hasRequiredHSV) return HSV;
11123
11146
  hasRequiredHSV = 1;
11124
11147
  Object.defineProperty(HSV, "__esModule", { value: true });
11125
- HSV.HSV = undefined;
11148
+ HSV.HSV = void 0;
11126
11149
  const Factory_1 = requireFactory();
11127
11150
  const Node_1 = requireNode();
11128
11151
  const Validators_1 = requireValidators();
@@ -11132,12 +11155,11 @@
11132
11155
  const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
11133
11156
  const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
11134
11157
  const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
11135
- let r, g, b, a;
11136
11158
  for (let i = 0; i < nPixels; i += 4) {
11137
- r = data[i + 0];
11138
- g = data[i + 1];
11139
- b = data[i + 2];
11140
- a = data[i + 3];
11159
+ const r = data[i + 0];
11160
+ const g = data[i + 1];
11161
+ const b = data[i + 2];
11162
+ const a = data[i + 3];
11141
11163
  data[i + 0] = rr * r + rg * g + rb * b;
11142
11164
  data[i + 1] = gr * r + gg * g + gb * b;
11143
11165
  data[i + 2] = br * r + bg * g + bb * b;
@@ -11154,12 +11176,11 @@
11154
11176
  var Invert = {};
11155
11177
 
11156
11178
  var hasRequiredInvert;
11157
-
11158
11179
  function requireInvert () {
11159
11180
  if (hasRequiredInvert) return Invert;
11160
11181
  hasRequiredInvert = 1;
11161
11182
  Object.defineProperty(Invert, "__esModule", { value: true });
11162
- Invert.Invert = undefined;
11183
+ Invert.Invert = void 0;
11163
11184
  const Invert$1 = function (imageData) {
11164
11185
  const data = imageData.data, len = data.length;
11165
11186
  for (let i = 0; i < len; i += 4) {
@@ -11175,12 +11196,11 @@
11175
11196
  var Kaleidoscope = {};
11176
11197
 
11177
11198
  var hasRequiredKaleidoscope;
11178
-
11179
11199
  function requireKaleidoscope () {
11180
11200
  if (hasRequiredKaleidoscope) return Kaleidoscope;
11181
11201
  hasRequiredKaleidoscope = 1;
11182
11202
  Object.defineProperty(Kaleidoscope, "__esModule", { value: true });
11183
- Kaleidoscope.Kaleidoscope = undefined;
11203
+ Kaleidoscope.Kaleidoscope = void 0;
11184
11204
  const Factory_1 = requireFactory();
11185
11205
  const Node_1 = requireNode();
11186
11206
  const Util_1 = requireUtil();
@@ -11321,12 +11341,11 @@
11321
11341
  var Mask = {};
11322
11342
 
11323
11343
  var hasRequiredMask;
11324
-
11325
11344
  function requireMask () {
11326
11345
  if (hasRequiredMask) return Mask;
11327
11346
  hasRequiredMask = 1;
11328
11347
  Object.defineProperty(Mask, "__esModule", { value: true });
11329
- Mask.Mask = undefined;
11348
+ Mask.Mask = void 0;
11330
11349
  const Factory_1 = requireFactory();
11331
11350
  const Node_1 = requireNode();
11332
11351
  const Validators_1 = requireValidators();
@@ -11475,12 +11494,11 @@
11475
11494
  var Noise = {};
11476
11495
 
11477
11496
  var hasRequiredNoise;
11478
-
11479
11497
  function requireNoise () {
11480
11498
  if (hasRequiredNoise) return Noise;
11481
11499
  hasRequiredNoise = 1;
11482
11500
  Object.defineProperty(Noise, "__esModule", { value: true });
11483
- Noise.Noise = undefined;
11501
+ Noise.Noise = void 0;
11484
11502
  const Factory_1 = requireFactory();
11485
11503
  const Node_1 = requireNode();
11486
11504
  const Validators_1 = requireValidators();
@@ -11500,42 +11518,41 @@
11500
11518
  var Pixelate = {};
11501
11519
 
11502
11520
  var hasRequiredPixelate;
11503
-
11504
11521
  function requirePixelate () {
11505
11522
  if (hasRequiredPixelate) return Pixelate;
11506
11523
  hasRequiredPixelate = 1;
11507
11524
  Object.defineProperty(Pixelate, "__esModule", { value: true });
11508
- Pixelate.Pixelate = undefined;
11525
+ Pixelate.Pixelate = void 0;
11509
11526
  const Factory_1 = requireFactory();
11510
11527
  const Util_1 = requireUtil();
11511
11528
  const Node_1 = requireNode();
11512
11529
  const Validators_1 = requireValidators();
11513
11530
  const Pixelate$1 = function (imageData) {
11514
- let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, x, y, i, red, green, blue, alpha, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), xBinStart, xBinEnd, yBinStart, yBinEnd, xBin, yBin, pixelsInBin, data = imageData.data;
11531
+ let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), data = imageData.data;
11515
11532
  if (pixelSize <= 0) {
11516
11533
  Util_1.Util.error('pixelSize value can not be <= 0');
11517
11534
  return;
11518
11535
  }
11519
- for (xBin = 0; xBin < nBinsX; xBin += 1) {
11520
- for (yBin = 0; yBin < nBinsY; yBin += 1) {
11521
- red = 0;
11522
- green = 0;
11523
- blue = 0;
11524
- alpha = 0;
11525
- xBinStart = xBin * pixelSize;
11526
- xBinEnd = xBinStart + pixelSize;
11527
- yBinStart = yBin * pixelSize;
11528
- yBinEnd = yBinStart + pixelSize;
11529
- pixelsInBin = 0;
11530
- for (x = xBinStart; x < xBinEnd; x += 1) {
11536
+ for (let xBin = 0; xBin < nBinsX; xBin += 1) {
11537
+ for (let yBin = 0; yBin < nBinsY; yBin += 1) {
11538
+ let red = 0;
11539
+ let green = 0;
11540
+ let blue = 0;
11541
+ let alpha = 0;
11542
+ const xBinStart = xBin * pixelSize;
11543
+ const xBinEnd = xBinStart + pixelSize;
11544
+ const yBinStart = yBin * pixelSize;
11545
+ const yBinEnd = yBinStart + pixelSize;
11546
+ let pixelsInBin = 0;
11547
+ for (let x = xBinStart; x < xBinEnd; x += 1) {
11531
11548
  if (x >= width) {
11532
11549
  continue;
11533
11550
  }
11534
- for (y = yBinStart; y < yBinEnd; y += 1) {
11551
+ for (let y = yBinStart; y < yBinEnd; y += 1) {
11535
11552
  if (y >= height) {
11536
11553
  continue;
11537
11554
  }
11538
- i = (width * y + x) * 4;
11555
+ const i = (width * y + x) * 4;
11539
11556
  red += data[i + 0];
11540
11557
  green += data[i + 1];
11541
11558
  blue += data[i + 2];
@@ -11547,15 +11564,15 @@
11547
11564
  green = green / pixelsInBin;
11548
11565
  blue = blue / pixelsInBin;
11549
11566
  alpha = alpha / pixelsInBin;
11550
- for (x = xBinStart; x < xBinEnd; x += 1) {
11567
+ for (let x = xBinStart; x < xBinEnd; x += 1) {
11551
11568
  if (x >= width) {
11552
11569
  continue;
11553
11570
  }
11554
- for (y = yBinStart; y < yBinEnd; y += 1) {
11571
+ for (let y = yBinStart; y < yBinEnd; y += 1) {
11555
11572
  if (y >= height) {
11556
11573
  continue;
11557
11574
  }
11558
- i = (width * y + x) * 4;
11575
+ const i = (width * y + x) * 4;
11559
11576
  data[i + 0] = red;
11560
11577
  data[i + 1] = green;
11561
11578
  data[i + 2] = blue;
@@ -11573,12 +11590,11 @@
11573
11590
  var Posterize = {};
11574
11591
 
11575
11592
  var hasRequiredPosterize;
11576
-
11577
11593
  function requirePosterize () {
11578
11594
  if (hasRequiredPosterize) return Posterize;
11579
11595
  hasRequiredPosterize = 1;
11580
11596
  Object.defineProperty(Posterize, "__esModule", { value: true });
11581
- Posterize.Posterize = undefined;
11597
+ Posterize.Posterize = void 0;
11582
11598
  const Factory_1 = requireFactory();
11583
11599
  const Node_1 = requireNode();
11584
11600
  const Validators_1 = requireValidators();
@@ -11596,12 +11612,11 @@
11596
11612
  var RGB = {};
11597
11613
 
11598
11614
  var hasRequiredRGB;
11599
-
11600
11615
  function requireRGB () {
11601
11616
  if (hasRequiredRGB) return RGB;
11602
11617
  hasRequiredRGB = 1;
11603
11618
  Object.defineProperty(RGB, "__esModule", { value: true });
11604
- RGB.RGB = undefined;
11619
+ RGB.RGB = void 0;
11605
11620
  const Factory_1 = requireFactory();
11606
11621
  const Node_1 = requireNode();
11607
11622
  const Validators_1 = requireValidators();
@@ -11647,12 +11662,11 @@
11647
11662
  var RGBA = {};
11648
11663
 
11649
11664
  var hasRequiredRGBA;
11650
-
11651
11665
  function requireRGBA () {
11652
11666
  if (hasRequiredRGBA) return RGBA;
11653
11667
  hasRequiredRGBA = 1;
11654
11668
  Object.defineProperty(RGBA, "__esModule", { value: true });
11655
- RGBA.RGBA = undefined;
11669
+ RGBA.RGBA = void 0;
11656
11670
  const Factory_1 = requireFactory();
11657
11671
  const Node_1 = requireNode();
11658
11672
  const Validators_1 = requireValidators();
@@ -11709,12 +11723,11 @@
11709
11723
  var Sepia = {};
11710
11724
 
11711
11725
  var hasRequiredSepia;
11712
-
11713
11726
  function requireSepia () {
11714
11727
  if (hasRequiredSepia) return Sepia;
11715
11728
  hasRequiredSepia = 1;
11716
11729
  Object.defineProperty(Sepia, "__esModule", { value: true });
11717
- Sepia.Sepia = undefined;
11730
+ Sepia.Sepia = void 0;
11718
11731
  const Sepia$1 = function (imageData) {
11719
11732
  const data = imageData.data, nPixels = data.length;
11720
11733
  for (let i = 0; i < nPixels; i += 4) {
@@ -11733,12 +11746,11 @@
11733
11746
  var Solarize = {};
11734
11747
 
11735
11748
  var hasRequiredSolarize;
11736
-
11737
11749
  function requireSolarize () {
11738
11750
  if (hasRequiredSolarize) return Solarize;
11739
11751
  hasRequiredSolarize = 1;
11740
11752
  Object.defineProperty(Solarize, "__esModule", { value: true });
11741
- Solarize.Solarize = undefined;
11753
+ Solarize.Solarize = void 0;
11742
11754
  const Solarize$1 = function (imageData) {
11743
11755
  const data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
11744
11756
  let y = h;
@@ -11772,12 +11784,11 @@
11772
11784
  var Threshold = {};
11773
11785
 
11774
11786
  var hasRequiredThreshold;
11775
-
11776
11787
  function requireThreshold () {
11777
11788
  if (hasRequiredThreshold) return Threshold;
11778
11789
  hasRequiredThreshold = 1;
11779
11790
  Object.defineProperty(Threshold, "__esModule", { value: true });
11780
- Threshold.Threshold = undefined;
11791
+ Threshold.Threshold = void 0;
11781
11792
  const Factory_1 = requireFactory();
11782
11793
  const Node_1 = requireNode();
11783
11794
  const Validators_1 = requireValidators();
@@ -11793,12 +11804,11 @@
11793
11804
  }
11794
11805
 
11795
11806
  var hasRequired_FullInternals;
11796
-
11797
11807
  function require_FullInternals () {
11798
11808
  if (hasRequired_FullInternals) return _FullInternals;
11799
11809
  hasRequired_FullInternals = 1;
11800
11810
  Object.defineProperty(_FullInternals, "__esModule", { value: true });
11801
- _FullInternals.Konva = undefined;
11811
+ _FullInternals.Konva = void 0;
11802
11812
  const _CoreInternals_1 = require_CoreInternals();
11803
11813
  const Arc_1 = requireArc();
11804
11814
  const Arrow_1 = requireArrow();
@@ -11881,9 +11891,7 @@
11881
11891
  }
11882
11892
 
11883
11893
  var lib = lib$1.exports;
11884
-
11885
11894
  var hasRequiredLib;
11886
-
11887
11895
  function requireLib () {
11888
11896
  if (hasRequiredLib) return lib$1.exports;
11889
11897
  hasRequiredLib = 1;
@@ -11896,28 +11904,6 @@
11896
11904
  var libExports = requireLib();
11897
11905
  var Konva = /*@__PURE__*/getDefaultExportFromCjs(libExports);
11898
11906
 
11899
- ///////////////////////////////////////////////////////////////////////////////
11900
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
11901
- // All rights reserved.
11902
- //
11903
- // This software and its documentation and related materials are owned by
11904
- // the Alliance. The software may only be incorporated into application
11905
- // programs owned by members of the Alliance, subject to a signed
11906
- // Membership Agreement and Supplemental Software License Agreement with the
11907
- // Alliance. The structure and organization of this software are the valuable
11908
- // trade secrets of the Alliance and its suppliers. The software is also
11909
- // protected by copyright law and international treaty provisions. Application
11910
- // programs incorporating this software must include the following statement
11911
- // with their copyright notices:
11912
- //
11913
- // This application incorporates Open Design Alliance software pursuant to a
11914
- // license agreement with Open Design Alliance.
11915
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
11916
- // All rights reserved.
11917
- //
11918
- // By use of this software, its documentation or related materials, you
11919
- // acknowledge and accept the above terms.
11920
- ///////////////////////////////////////////////////////////////////////////////
11921
11907
  class WorldTransform {
11922
11908
  screenToWorld(position) {
11923
11909
  return { x: position.x, y: position.y, z: 0 };
@@ -11930,62 +11916,16 @@
11930
11916
  }
11931
11917
  }
11932
11918
 
11933
- ///////////////////////////////////////////////////////////////////////////////
11934
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
11935
- // All rights reserved.
11936
- //
11937
- // This software and its documentation and related materials are owned by
11938
- // the Alliance. The software may only be incorporated into application
11939
- // programs owned by members of the Alliance, subject to a signed
11940
- // Membership Agreement and Supplemental Software License Agreement with the
11941
- // Alliance. The structure and organization of this software are the valuable
11942
- // trade secrets of the Alliance and its suppliers. The software is also
11943
- // protected by copyright law and international treaty provisions. Application
11944
- // programs incorporating this software must include the following statement
11945
- // with their copyright notices:
11946
- //
11947
- // This application incorporates Open Design Alliance software pursuant to a
11948
- // license agreement with Open Design Alliance.
11949
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
11950
- // All rights reserved.
11951
- //
11952
- // By use of this software, its documentation or related materials, you
11953
- // acknowledge and accept the above terms.
11954
- ///////////////////////////////////////////////////////////////////////////////
11955
- /**
11956
- * Defines the markup color helper object.
11957
- */
11958
11919
  class MarkupColor {
11959
- /**
11960
- * Creates an instance of the color.
11961
- *
11962
- * @param r - The `red` component of the color, as a number between 0 and 255.
11963
- * @param g - The `green` component of the color, as a number between 0 and 255.
11964
- * @param b - The `blue` component of the color, as a number between 0 and 255.
11965
- */
11966
11920
  constructor(r, g, b) {
11967
11921
  this.setColor(r, g, b);
11968
11922
  }
11969
- /**
11970
- * Returns the color as a string in hexadecimal color syntax `#RGB` using its primary color components
11971
- * (red, green, blue) written as hexadecimal numbers.
11972
- */
11973
11923
  asHex() {
11974
11924
  return "#" + this.HEX;
11975
11925
  }
11976
- /**
11977
- * Returns the color as an {r, g, b} object.
11978
- */
11979
11926
  asRGB() {
11980
11927
  return { r: this.R, g: this.G, b: this.B };
11981
11928
  }
11982
- /**
11983
- * Sets the color.
11984
- *
11985
- * @param r - The `red` component of the color, as a number between 0 and 255.
11986
- * @param g - The `green` component of the color, as a number between 0 and 255.
11987
- * @param b - The `blue` component of the color, as a number between 0 and 255.
11988
- */
11989
11929
  setColor(r, g, b) {
11990
11930
  this.R = r;
11991
11931
  this.G = g;
@@ -12001,28 +11941,6 @@
12001
11941
  }
12002
11942
  }
12003
11943
 
12004
- ///////////////////////////////////////////////////////////////////////////////
12005
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12006
- // All rights reserved.
12007
- //
12008
- // This software and its documentation and related materials are owned by
12009
- // the Alliance. The software may only be incorporated into application
12010
- // programs owned by members of the Alliance, subject to a signed
12011
- // Membership Agreement and Supplemental Software License Agreement with the
12012
- // Alliance. The structure and organization of this software are the valuable
12013
- // trade secrets of the Alliance and its suppliers. The software is also
12014
- // protected by copyright law and international treaty provisions. Application
12015
- // programs incorporating this software must include the following statement
12016
- // with their copyright notices:
12017
- //
12018
- // This application incorporates Open Design Alliance software pursuant to a
12019
- // license agreement with Open Design Alliance.
12020
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12021
- // All rights reserved.
12022
- //
12023
- // By use of this software, its documentation or related materials, you
12024
- // acknowledge and accept the above terms.
12025
- ///////////////////////////////////////////////////////////////////////////////
12026
11944
  const LineTypeSpecs = new Map([
12027
11945
  ["solid", []],
12028
11946
  ["dot", [30, 30, 0.001, 30]],
@@ -12062,8 +11980,8 @@
12062
11980
  wcsPoints.push({ x: wcsPoint.x, y: wcsPoint.y, z: wcsPoint.z });
12063
11981
  });
12064
11982
  this._ref = new Konva.Line({
12065
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12066
- strokeWidth: (_b = params.width) !== null && _b !== undefined ? _b : 4,
11983
+ stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
11984
+ strokeWidth: (_b = params.width) !== null && _b !== void 0 ? _b : 4,
12067
11985
  globalCompositeOperation: "source-over",
12068
11986
  lineCap: "round",
12069
11987
  lineJoin: "round",
@@ -12195,28 +12113,6 @@
12195
12113
  }
12196
12114
  }
12197
12115
 
12198
- ///////////////////////////////////////////////////////////////////////////////
12199
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12200
- // All rights reserved.
12201
- //
12202
- // This software and its documentation and related materials are owned by
12203
- // the Alliance. The software may only be incorporated into application
12204
- // programs owned by members of the Alliance, subject to a signed
12205
- // Membership Agreement and Supplemental Software License Agreement with the
12206
- // Alliance. The structure and organization of this software are the valuable
12207
- // trade secrets of the Alliance and its suppliers. The software is also
12208
- // protected by copyright law and international treaty provisions. Application
12209
- // programs incorporating this software must include the following statement
12210
- // with their copyright notices:
12211
- //
12212
- // This application incorporates Open Design Alliance software pursuant to a
12213
- // license agreement with Open Design Alliance.
12214
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12215
- // All rights reserved.
12216
- //
12217
- // By use of this software, its documentation or related materials, you
12218
- // acknowledge and accept the above terms.
12219
- ///////////////////////////////////////////////////////////////////////////////
12220
12116
  class KonvaText {
12221
12117
  constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12222
12118
  var _a, _b, _c;
@@ -12240,12 +12136,12 @@
12240
12136
  x: params.position.x,
12241
12137
  y: params.position.y,
12242
12138
  text: params.text,
12243
- fontSize: (_a = params.fontSize) !== null && _a !== undefined ? _a : 34,
12139
+ fontSize: (_a = params.fontSize) !== null && _a !== void 0 ? _a : 34,
12244
12140
  fontFamily: this.TEXT_FONT_FAMILY,
12245
- fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
12141
+ fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
12246
12142
  align: "left",
12247
12143
  draggable: true,
12248
- rotation: (_c = params.rotation) !== null && _c !== undefined ? _c : 0,
12144
+ rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0,
12249
12145
  });
12250
12146
  this._ref.width(this._ref.getTextWidth());
12251
12147
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
@@ -12351,28 +12247,6 @@
12351
12247
  }
12352
12248
  }
12353
12249
 
12354
- ///////////////////////////////////////////////////////////////////////////////
12355
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12356
- // All rights reserved.
12357
- //
12358
- // This software and its documentation and related materials are owned by
12359
- // the Alliance. The software may only be incorporated into application
12360
- // programs owned by members of the Alliance, subject to a signed
12361
- // Membership Agreement and Supplemental Software License Agreement with the
12362
- // Alliance. The structure and organization of this software are the valuable
12363
- // trade secrets of the Alliance and its suppliers. The software is also
12364
- // protected by copyright law and international treaty provisions. Application
12365
- // programs incorporating this software must include the following statement
12366
- // with their copyright notices:
12367
- //
12368
- // This application incorporates Open Design Alliance software pursuant to a
12369
- // license agreement with Open Design Alliance.
12370
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12371
- // All rights reserved.
12372
- //
12373
- // By use of this software, its documentation or related materials, you
12374
- // acknowledge and accept the above terms.
12375
- ///////////////////////////////////////////////////////////////////////////////
12376
12250
  class KonvaRectangle {
12377
12251
  constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12378
12252
  var _a, _b, _c, _d;
@@ -12409,15 +12283,15 @@
12409
12283
  }
12410
12284
  }
12411
12285
  this._ref = new Konva.Rect({
12412
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12413
- strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
12286
+ stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12287
+ strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
12414
12288
  globalCompositeOperation: "source-over",
12415
12289
  lineCap: "round",
12416
12290
  lineJoin: "round",
12417
12291
  x: params.position.x,
12418
12292
  y: params.position.y,
12419
- width: (_c = params.width) !== null && _c !== undefined ? _c : 200,
12420
- height: (_d = params.height) !== null && _d !== undefined ? _d : 200,
12293
+ width: (_c = params.width) !== null && _c !== void 0 ? _c : 200,
12294
+ height: (_d = params.height) !== null && _d !== void 0 ? _d : 200,
12421
12295
  draggable: true,
12422
12296
  strokeScaleEnabled: false,
12423
12297
  });
@@ -12549,28 +12423,6 @@
12549
12423
  return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
12550
12424
  }
12551
12425
 
12552
- ///////////////////////////////////////////////////////////////////////////////
12553
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12554
- // All rights reserved.
12555
- //
12556
- // This software and its documentation and related materials are owned by
12557
- // the Alliance. The software may only be incorporated into application
12558
- // programs owned by members of the Alliance, subject to a signed
12559
- // Membership Agreement and Supplemental Software License Agreement with the
12560
- // Alliance. The structure and organization of this software are the valuable
12561
- // trade secrets of the Alliance and its suppliers. The software is also
12562
- // protected by copyright law and international treaty provisions. Application
12563
- // programs incorporating this software must include the following statement
12564
- // with their copyright notices:
12565
- //
12566
- // This application incorporates Open Design Alliance software pursuant to a
12567
- // license agreement with Open Design Alliance.
12568
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12569
- // All rights reserved.
12570
- //
12571
- // By use of this software, its documentation or related materials, you
12572
- // acknowledge and accept the above terms.
12573
- ///////////////////////////////////////////////////////////////////////////////
12574
12426
  class KonvaEllipse {
12575
12427
  constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12576
12428
  var _a, _b, _c;
@@ -12596,7 +12448,7 @@
12596
12448
  if (!params.position)
12597
12449
  params.position = { x: 0, y: 0 };
12598
12450
  if (params.position2) {
12599
- (_a = params.radius) !== null && _a !== undefined ? _a : (params.radius = { x: 0, y: 0 });
12451
+ (_a = params.radius) !== null && _a !== void 0 ? _a : (params.radius = { x: 0, y: 0 });
12600
12452
  params.radius.x = getDistanceIn2D(params.position, params.position2);
12601
12453
  if (params.position3)
12602
12454
  params.radius.y = getDistanceIn2D(params.position, params.position3);
@@ -12608,8 +12460,8 @@
12608
12460
  params.radius = { x: 25, y: 25 };
12609
12461
  }
12610
12462
  this._ref = new Konva.Ellipse({
12611
- stroke: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
12612
- strokeWidth: (_c = params.lineWidth) !== null && _c !== undefined ? _c : 4,
12463
+ stroke: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
12464
+ strokeWidth: (_c = params.lineWidth) !== null && _c !== void 0 ? _c : 4,
12613
12465
  globalCompositeOperation: "source-over",
12614
12466
  lineCap: "round",
12615
12467
  lineJoin: "round",
@@ -12750,28 +12602,6 @@
12750
12602
  }
12751
12603
  }
12752
12604
 
12753
- ///////////////////////////////////////////////////////////////////////////////
12754
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12755
- // All rights reserved.
12756
- //
12757
- // This software and its documentation and related materials are owned by
12758
- // the Alliance. The software may only be incorporated into application
12759
- // programs owned by members of the Alliance, subject to a signed
12760
- // Membership Agreement and Supplemental Software License Agreement with the
12761
- // Alliance. The structure and organization of this software are the valuable
12762
- // trade secrets of the Alliance and its suppliers. The software is also
12763
- // protected by copyright law and international treaty provisions. Application
12764
- // programs incorporating this software must include the following statement
12765
- // with their copyright notices:
12766
- //
12767
- // This application incorporates Open Design Alliance software pursuant to a
12768
- // license agreement with Open Design Alliance.
12769
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12770
- // All rights reserved.
12771
- //
12772
- // By use of this software, its documentation or related materials, you
12773
- // acknowledge and accept the above terms.
12774
- ///////////////////////////////////////////////////////////////////////////////
12775
12605
  class KonvaArrow {
12776
12606
  constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12777
12607
  var _a, _b;
@@ -12793,8 +12623,8 @@
12793
12623
  if (!params.end)
12794
12624
  params.end = { x: 100, y: 100 };
12795
12625
  this._ref = new Konva.Arrow({
12796
- stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12797
- fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
12626
+ stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12627
+ fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
12798
12628
  strokeWidth: 4,
12799
12629
  globalCompositeOperation: "source-over",
12800
12630
  lineCap: "round",
@@ -12904,28 +12734,6 @@
12904
12734
  }
12905
12735
  }
12906
12736
 
12907
- ///////////////////////////////////////////////////////////////////////////////
12908
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12909
- // All rights reserved.
12910
- //
12911
- // This software and its documentation and related materials are owned by
12912
- // the Alliance. The software may only be incorporated into application
12913
- // programs owned by members of the Alliance, subject to a signed
12914
- // Membership Agreement and Supplemental Software License Agreement with the
12915
- // Alliance. The structure and organization of this software are the valuable
12916
- // trade secrets of the Alliance and its suppliers. The software is also
12917
- // protected by copyright law and international treaty provisions. Application
12918
- // programs incorporating this software must include the following statement
12919
- // with their copyright notices:
12920
- //
12921
- // This application incorporates Open Design Alliance software pursuant to a
12922
- // license agreement with Open Design Alliance.
12923
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12924
- // All rights reserved.
12925
- //
12926
- // By use of this software, its documentation or related materials, you
12927
- // acknowledge and accept the above terms.
12928
- ///////////////////////////////////////////////////////////////////////////////
12929
12737
  class KonvaImage {
12930
12738
  constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12931
12739
  var _a, _b;
@@ -12979,7 +12787,6 @@
12979
12787
  this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON
12980
12788
  ? 1
12981
12789
  : this._ref.height() / this._ref.width();
12982
- // need to rescale only if input width and height are 0 - we do not loading Viewpoint with existing params
12983
12790
  if ((params.width <= this.EPSILON || params.height <= this.EPSILON) &&
12984
12791
  (params.maxWidth >= this.EPSILON || params.maxWidth >= this.EPSILON)) {
12985
12792
  const heightOutOfCanvas = params.maxHeight - this._canvasImage.height;
@@ -13010,8 +12817,8 @@
13010
12817
  x: params.position.x,
13011
12818
  y: params.position.y,
13012
12819
  image: this._canvasImage,
13013
- width: (_a = params.width) !== null && _a !== undefined ? _a : 0,
13014
- height: (_b = params.height) !== null && _b !== undefined ? _b : 0,
12820
+ width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
12821
+ height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
13015
12822
  draggable: true,
13016
12823
  });
13017
12824
  this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
@@ -13138,28 +12945,6 @@
13138
12945
  }
13139
12946
  }
13140
12947
 
13141
- ///////////////////////////////////////////////////////////////////////////////
13142
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
13143
- // All rights reserved.
13144
- //
13145
- // This software and its documentation and related materials are owned by
13146
- // the Alliance. The software may only be incorporated into application
13147
- // programs owned by members of the Alliance, subject to a signed
13148
- // Membership Agreement and Supplemental Software License Agreement with the
13149
- // Alliance. The structure and organization of this software are the valuable
13150
- // trade secrets of the Alliance and its suppliers. The software is also
13151
- // protected by copyright law and international treaty provisions. Application
13152
- // programs incorporating this software must include the following statement
13153
- // with their copyright notices:
13154
- //
13155
- // This application incorporates Open Design Alliance software pursuant to a
13156
- // license agreement with Open Design Alliance.
13157
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
13158
- // All rights reserved.
13159
- //
13160
- // By use of this software, its documentation or related materials, you
13161
- // acknowledge and accept the above terms.
13162
- ///////////////////////////////////////////////////////////////////////////////
13163
12948
  class KonvaCloud {
13164
12949
  constructor(params, ref = null, worldTransformer = new WorldTransform()) {
13165
12950
  var _a, _b, _c, _d;
@@ -13202,10 +12987,10 @@
13202
12987
  this._ref = new Konva.Shape({
13203
12988
  x: params.position.x,
13204
12989
  y: params.position.y,
13205
- width: (_a = params.width) !== null && _a !== undefined ? _a : 200,
13206
- height: (_b = params.height) !== null && _b !== undefined ? _b : 200,
13207
- stroke: (_c = params.color) !== null && _c !== undefined ? _c : "#ff0000",
13208
- strokeWidth: (_d = params.lineWidth) !== null && _d !== undefined ? _d : 4,
12990
+ width: (_a = params.width) !== null && _a !== void 0 ? _a : 200,
12991
+ height: (_b = params.height) !== null && _b !== void 0 ? _b : 200,
12992
+ stroke: (_c = params.color) !== null && _c !== void 0 ? _c : "#ff0000",
12993
+ strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d : 4,
13209
12994
  draggable: true,
13210
12995
  strokeScaleEnabled: false,
13211
12996
  globalCompositeOperation: "source-over",
@@ -13260,8 +13045,6 @@
13260
13045
  }
13261
13046
  }
13262
13047
  context.closePath();
13263
- // (!) Konva specific method, it is very important
13264
- // it will apply are required styles
13265
13048
  context.fillStrokeShape(shape);
13266
13049
  }
13267
13050
  function drawRectangle() {
@@ -13271,8 +13054,6 @@
13271
13054
  context.lineTo(points[3].x, points[3].y);
13272
13055
  context.lineTo(points[4].x, points[4].y);
13273
13056
  context.closePath();
13274
- // (!) Konva specific method, it is very important
13275
- // it will apply are required styles
13276
13057
  context.fillStrokeShape(shape);
13277
13058
  }
13278
13059
  },
@@ -13408,28 +13189,6 @@
13408
13189
  }
13409
13190
  }
13410
13191
 
13411
- ///////////////////////////////////////////////////////////////////////////////
13412
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
13413
- // All rights reserved.
13414
- //
13415
- // This software and its documentation and related materials are owned by
13416
- // the Alliance. The software may only be incorporated into application
13417
- // programs owned by members of the Alliance, subject to a signed
13418
- // Membership Agreement and Supplemental Software License Agreement with the
13419
- // Alliance. The structure and organization of this software are the valuable
13420
- // trade secrets of the Alliance and its suppliers. The software is also
13421
- // protected by copyright law and international treaty provisions. Application
13422
- // programs incorporating this software must include the following statement
13423
- // with their copyright notices:
13424
- //
13425
- // This application incorporates Open Design Alliance software pursuant to a
13426
- // license agreement with Open Design Alliance.
13427
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
13428
- // All rights reserved.
13429
- //
13430
- // By use of this software, its documentation or related materials, you
13431
- // acknowledge and accept the above terms.
13432
- ///////////////////////////////////////////////////////////////////////////////
13433
13192
  const MarkupMode2Konva = {
13434
13193
  SelectMarkup: {
13435
13194
  name: "SelectMarkup",
@@ -13476,9 +13235,6 @@
13476
13235
  }, wait);
13477
13236
  };
13478
13237
  }
13479
- /**
13480
- * 2D markup core.
13481
- */
13482
13238
  class KonvaMarkup {
13483
13239
  constructor() {
13484
13240
  this._markupIsActive = false;
@@ -13503,7 +13259,7 @@
13503
13259
  return;
13504
13260
  const { width, height } = entries[0].contentRect;
13505
13261
  if (!width || !height)
13506
- return; // <- invisible container, or container with parent removed
13262
+ return;
13507
13263
  if (!this._konvaStage)
13508
13264
  return;
13509
13265
  this._konvaStage.width(width);
@@ -13515,7 +13271,7 @@
13515
13271
  this.resizeViewer = (event) => {
13516
13272
  const { width, height } = event;
13517
13273
  if (!width || !height)
13518
- return; // <- invisible container, or container with parent removed
13274
+ return;
13519
13275
  if (!this._konvaStage)
13520
13276
  return;
13521
13277
  this._konvaStage.width(width);
@@ -13539,12 +13295,8 @@
13539
13295
  this._viewer.emit(event);
13540
13296
  };
13541
13297
  this.getRelativePointPosition = (point, node) => {
13542
- // the function will return pointer position relative to the passed node
13543
13298
  const transform = node.getAbsoluteTransform().copy();
13544
- // to detect relative position we need to invert transform
13545
13299
  transform.invert();
13546
- // get pointer (say mouse or touch) position
13547
- // now we find relative point
13548
13300
  return transform.point(point);
13549
13301
  };
13550
13302
  this.getRelativePointerPosition = (node) => {
@@ -13555,14 +13307,14 @@
13555
13307
  if (!Konva)
13556
13308
  throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"></script> to your page?');
13557
13309
  this._viewer = viewer;
13558
- this._worldTransformer = worldTransformer !== null && worldTransformer !== undefined ? worldTransformer : new WorldTransform();
13310
+ this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform();
13559
13311
  this._container = container;
13560
13312
  this._markupContainer = document.createElement("div");
13561
13313
  this._markupContainer.id = "markup-container";
13562
13314
  this._markupContainer.style.position = "absolute";
13563
13315
  this._markupContainer.style.top = "0px";
13564
13316
  this._markupContainer.style.left = "0px";
13565
- this._markupContainer.style.outline = "0px"; // <- to eliminate grey box during delete elements
13317
+ this._markupContainer.style.outline = "0px";
13566
13318
  this._markupContainer.style.pointerEvents = "none";
13567
13319
  const parentDiv = this._container.parentElement;
13568
13320
  parentDiv.appendChild(this._markupContainer);
@@ -13586,9 +13338,9 @@
13586
13338
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
13587
13339
  }
13588
13340
  this.destroyKonva();
13589
- (_a = this._resizeObserver) === null || _a === undefined ? undefined : _a.disconnect();
13341
+ (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
13590
13342
  this._resizeObserver = undefined;
13591
- (_b = this._markupContainer) === null || _b === undefined ? undefined : _b.remove();
13343
+ (_b = this._markupContainer) === null || _b === void 0 ? void 0 : _b.remove();
13592
13344
  this._markupContainer = undefined;
13593
13345
  this._container = undefined;
13594
13346
  this._viewer = undefined;
@@ -13612,11 +13364,11 @@
13612
13364
  colorizeAllMarkup(r, g, b) {
13613
13365
  this.setMarkupColor(r, g, b);
13614
13366
  const hexColor = new MarkupColor(r, g, b).asHex();
13615
- this.getObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor); });
13367
+ this.getObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
13616
13368
  }
13617
13369
  colorizeSelectedMarkups(r, g, b) {
13618
13370
  const hexColor = new MarkupColor(r, g, b).asHex();
13619
- this.getSelectedObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor); });
13371
+ this.getSelectedObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
13620
13372
  }
13621
13373
  setViewpoint(viewpoint) {
13622
13374
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -13625,9 +13377,9 @@
13625
13377
  this.removeImageInput();
13626
13378
  this._konvaStage.scale({ x: 1, y: 1 });
13627
13379
  this._konvaStage.position({ x: 0, y: 0 });
13628
- const markupColor = ((_a = viewpoint.custom_fields) === null || _a === undefined ? undefined : _a.markup_color) || { r: 255, g: 0, b: 0 };
13380
+ const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || { r: 255, g: 0, b: 0 };
13629
13381
  this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
13630
- (_b = viewpoint.lines) === null || _b === undefined ? undefined : _b.forEach((line) => {
13382
+ (_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
13631
13383
  const linePoints = [];
13632
13384
  line.points.forEach((point) => {
13633
13385
  const screenPoint = this._worldTransformer.worldToScreen(point);
@@ -13636,32 +13388,32 @@
13636
13388
  });
13637
13389
  this.addLine(linePoints, line.color, line.type, line.width, line.id);
13638
13390
  });
13639
- (_c = viewpoint.texts) === null || _c === undefined ? undefined : _c.forEach((text) => {
13391
+ (_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text) => {
13640
13392
  const screenPoint = this._worldTransformer.worldToScreen(text.position);
13641
13393
  this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
13642
13394
  });
13643
- (_d = viewpoint.rectangles) === null || _d === undefined ? undefined : _d.forEach((rect) => {
13395
+ (_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect) => {
13644
13396
  const screenPoint = this._worldTransformer.worldToScreen(rect.position);
13645
13397
  const screenPoint2 = rect.position2 ? this._worldTransformer.worldToScreen(rect.position2) : null;
13646
13398
  this.addRectangle(screenPoint, screenPoint2, rect.width, rect.height, rect.line_width, rect.color, rect.id);
13647
13399
  });
13648
- (_e = viewpoint.ellipses) === null || _e === undefined ? undefined : _e.forEach((ellipse) => {
13400
+ (_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse) => {
13649
13401
  const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
13650
13402
  const screenPoint2 = ellipse.position2 ? this._worldTransformer.worldToScreen(ellipse.position2) : null;
13651
13403
  const screenPoint3 = ellipse.position3 ? this._worldTransformer.worldToScreen(ellipse.position3) : null;
13652
13404
  this.addEllipse(screenPoint, screenPoint2, screenPoint3, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
13653
13405
  });
13654
- (_f = viewpoint.arrows) === null || _f === undefined ? undefined : _f.forEach((arrow) => {
13406
+ (_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow) => {
13655
13407
  const startPoint = this._worldTransformer.worldToScreen(arrow.start);
13656
13408
  const endPoint = this._worldTransformer.worldToScreen(arrow.end);
13657
13409
  this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
13658
13410
  });
13659
- (_g = viewpoint.clouds) === null || _g === undefined ? undefined : _g.forEach((cloud) => {
13411
+ (_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud) => {
13660
13412
  const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
13661
13413
  const screenPoint2 = cloud.position2 ? this._worldTransformer.worldToScreen(cloud.position2) : null;
13662
13414
  this.addCloud(screenPoint, screenPoint2, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
13663
13415
  });
13664
- (_h = viewpoint.images) === null || _h === undefined ? undefined : _h.forEach((image) => {
13416
+ (_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image) => {
13665
13417
  const screenPoint = this._worldTransformer.worldToScreen(image.position);
13666
13418
  const screenPoint2 = image.position2 ? this._worldTransformer.worldToScreen(image.position2) : null;
13667
13419
  this.addImage(screenPoint, screenPoint2, image.src, image.width, image.height, image.id);
@@ -13748,7 +13500,6 @@
13748
13500
  const konvaShape = MarkupMode2Konva[type];
13749
13501
  if (!konvaShape || !konvaShape.initializer)
13750
13502
  return [];
13751
- // for "draggable" Konva uses Rectangles in Transformer. We need only Shapes from layer.
13752
13503
  return this._konvaLayer
13753
13504
  .find(konvaShape.name)
13754
13505
  .filter((ref) => ref.parent === this._konvaLayer ||
@@ -13757,7 +13508,6 @@
13757
13508
  ref.parent === this._groupTexts);
13758
13509
  }
13759
13510
  initializeKonva() {
13760
- // first we need Konva core things: stage and layer
13761
13511
  const stage = new Konva.Stage({
13762
13512
  container: this._markupContainer,
13763
13513
  width: this._container.clientWidth,
@@ -13785,7 +13535,6 @@
13785
13535
  let mouseDownPos;
13786
13536
  let lastObj;
13787
13537
  stage.on("mousedown touchstart", (e) => {
13788
- // do nothing if we mousedown on any shape
13789
13538
  if (!this._markupIsActive || e.target !== stage || this._markupMode === "Text" || this._markupMode === "Image")
13790
13539
  return;
13791
13540
  if (e.target === stage && transformer.nodes().length > 0) {
@@ -13796,7 +13545,6 @@
13796
13545
  mouseDownPos = pos;
13797
13546
  isPaint = ["Arrow", "Cloud", "Ellipse", "Line", "Rectangle"].some((m) => m === this._markupMode);
13798
13547
  if (this._markupMode === "Line") {
13799
- // add point twice, so we have some drawings even on a simple click
13800
13548
  lastLine = this.addLine([pos.x, pos.y, pos.x, pos.y]);
13801
13549
  }
13802
13550
  });
@@ -13834,8 +13582,6 @@
13834
13582
  if (!isPaint) {
13835
13583
  return;
13836
13584
  }
13837
- // prevent scrolling on touch devices
13838
- //e.evt.preventDefault();
13839
13585
  const pos = this.getRelativePointerPosition(stage);
13840
13586
  const defParams = mouseDownPos && pos.x === mouseDownPos.x && pos.y === mouseDownPos.y;
13841
13587
  const startX = defParams ? mouseDownPos.x : Math.min(mouseDownPos.x, pos.x);
@@ -13879,11 +13625,9 @@
13879
13625
  lastObj = this.addCloud({ x: startX, y: startY }, null, dX, dY);
13880
13626
  }
13881
13627
  });
13882
- // clicks should select/deselect shapes
13883
13628
  stage.on("click tap", (e) => {
13884
13629
  if (!this._markupIsActive)
13885
13630
  return;
13886
- // if click on empty area - remove all selections
13887
13631
  if (e.target === stage) {
13888
13632
  if (this._markupMode === "Text") {
13889
13633
  if (this._textInputRef && this._textInputRef.value)
@@ -13936,32 +13680,23 @@
13936
13680
  else {
13937
13681
  transformer.rotateEnabled(true);
13938
13682
  }
13939
- // do we pressed shift or ctrl?
13940
13683
  const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
13941
13684
  const isSelected = transformer.nodes().indexOf(e.target) >= 0;
13942
13685
  if (!metaPressed && !isSelected) {
13943
- // if no key pressed and the node is not selected
13944
- // select just one
13945
13686
  transformer.nodes([e.target]);
13946
13687
  }
13947
13688
  else if (metaPressed && isSelected) {
13948
- // if we pressed keys and node was selected
13949
- // we need to remove it from selection:
13950
- const nodes = transformer.nodes().slice(); // use slice to have new copy of array
13951
- // remove node from array
13689
+ const nodes = transformer.nodes().slice();
13952
13690
  nodes.splice(nodes.indexOf(e.target), 1);
13953
13691
  transformer.nodes(nodes);
13954
13692
  }
13955
13693
  else if (metaPressed && !isSelected) {
13956
- // add the node into selection
13957
13694
  const nodes = transformer.nodes().concat([e.target]);
13958
13695
  transformer.nodes(nodes);
13959
13696
  }
13960
13697
  });
13961
13698
  const container = stage.container();
13962
13699
  container.tabIndex = 1;
13963
- // focus it
13964
- // also stage will be in focus on its click
13965
13700
  container.focus();
13966
13701
  container.addEventListener("keydown", (e) => {
13967
13702
  if (!this._markupIsActive)
@@ -13979,7 +13714,7 @@
13979
13714
  this.removeTextInput();
13980
13715
  this.removeImageInput();
13981
13716
  this.clearOverlay();
13982
- (_a = this._konvaStage) === null || _a === undefined ? undefined : _a.destroy();
13717
+ (_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
13983
13718
  this._groupImages = undefined;
13984
13719
  this._groupGeometry = undefined;
13985
13720
  this._groupTexts = undefined;
@@ -14075,7 +13810,6 @@
14075
13810
  getMarkupArrows() {
14076
13811
  const arrows = [];
14077
13812
  this.konvaLayerFind("Arrow").forEach((ref) => {
14078
- // we need getAbsoluteTransform because inside Konva position starts from {0, 0}
14079
13813
  const wcsStart = ref.getAttr("wcsStart");
14080
13814
  const wcsEnd = ref.getAttr("wcsEnd");
14081
13815
  const shape = new KonvaArrow(null, ref, this._worldTransformer);
@@ -14196,7 +13930,7 @@
14196
13930
  }
14197
13931
  removeTextInput() {
14198
13932
  var _a;
14199
- (_a = this._textInputRef) === null || _a === undefined ? undefined : _a.remove();
13933
+ (_a = this._textInputRef) === null || _a === void 0 ? void 0 : _a.remove();
14200
13934
  this._textInputRef = null;
14201
13935
  this._textInputPos = null;
14202
13936
  this._textInputAngle = 0;
@@ -14239,7 +13973,7 @@
14239
13973
  }
14240
13974
  removeImageInput() {
14241
13975
  var _a;
14242
- (_a = this._imageInputRef) === null || _a === undefined ? undefined : _a.remove();
13976
+ (_a = this._imageInputRef) === null || _a === void 0 ? void 0 : _a.remove();
14243
13977
  this._imageInputRef = null;
14244
13978
  this._imageInputPos = null;
14245
13979
  }
@@ -14247,11 +13981,9 @@
14247
13981
  var _a;
14248
13982
  if (!text)
14249
13983
  return;
14250
- // in case of edit - remove old Konva.Text object
14251
- (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
13984
+ (_a = this.getSelectedObjects().shift()) === null || _a === void 0 ? void 0 : _a.delete();
14252
13985
  this.clearSelected();
14253
13986
  this.removeTextInput();
14254
- // in case we have old viewpoint without font_size
14255
13987
  const tolerance = 1.0e-6;
14256
13988
  if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
14257
13989
  const size = 0.02;
@@ -14330,8 +14062,7 @@
14330
14062
  var _a;
14331
14063
  if (!position || !src)
14332
14064
  return;
14333
- // in case of edit - remove old Image placeholder object
14334
- (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
14065
+ (_a = this.getSelectedObjects().shift()) === null || _a === void 0 ? void 0 : _a.delete();
14335
14066
  this.clearSelected();
14336
14067
  this.removeImageInput();
14337
14068
  const konvaImage = new KonvaImage({