@willphan1712000/frontend 1.0.3 → 1.2.0

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/index.mjs CHANGED
@@ -10,6 +10,54 @@ function _array_with_holes(arr) {
10
10
  function _array_without_holes(arr) {
11
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
12
12
  }
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
+ try {
15
+ var info = gen[key](arg);
16
+ var value = info.value;
17
+ } catch (error) {
18
+ reject(error);
19
+ return;
20
+ }
21
+ if (info.done) {
22
+ resolve(value);
23
+ } else {
24
+ Promise.resolve(value).then(_next, _throw);
25
+ }
26
+ }
27
+ function _async_to_generator(fn) {
28
+ return function() {
29
+ var self = this, args = arguments;
30
+ return new Promise(function(resolve, reject) {
31
+ var gen = fn.apply(self, args);
32
+ function _next(value) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
34
+ }
35
+ function _throw(err) {
36
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
37
+ }
38
+ _next(undefined);
39
+ });
40
+ };
41
+ }
42
+ function _class_call_check(instance, Constructor) {
43
+ if (!(instance instanceof Constructor)) {
44
+ throw new TypeError("Cannot call a class as a function");
45
+ }
46
+ }
47
+ function _defineProperties(target, props) {
48
+ for(var i = 0; i < props.length; i++){
49
+ var descriptor = props[i];
50
+ descriptor.enumerable = descriptor.enumerable || false;
51
+ descriptor.configurable = true;
52
+ if ("value" in descriptor) descriptor.writable = true;
53
+ Object.defineProperty(target, descriptor.key, descriptor);
54
+ }
55
+ }
56
+ function _create_class(Constructor, protoProps, staticProps) {
57
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
58
+ if (staticProps) _defineProperties(Constructor, staticProps);
59
+ return Constructor;
60
+ }
13
61
  function _define_property(obj, key, value) {
14
62
  if (key in obj) {
15
63
  Object.defineProperty(obj, key, {
@@ -23,6 +71,20 @@ function _define_property(obj, key, value) {
23
71
  }
24
72
  return obj;
25
73
  }
74
+ function _extends() {
75
+ _extends = Object.assign || function(target) {
76
+ for(var i = 1; i < arguments.length; i++){
77
+ var source = arguments[i];
78
+ for(var key in source){
79
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
80
+ target[key] = source[key];
81
+ }
82
+ }
83
+ }
84
+ return target;
85
+ };
86
+ return _extends.apply(this, arguments);
87
+ }
26
88
  function _iterable_to_array(iter) {
27
89
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
28
90
  }
@@ -56,6 +118,10 @@ function _non_iterable_rest() {
56
118
  function _non_iterable_spread() {
57
119
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
58
120
  }
121
+ function _object_destructuring_empty(o) {
122
+ if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
123
+ return o;
124
+ }
59
125
  function _object_spread(target) {
60
126
  for(var i = 1; i < arguments.length; i++){
61
127
  var source = arguments[i] != null ? arguments[i] : {};
@@ -136,6 +202,97 @@ function _unsupported_iterable_to_array(o, minLen) {
136
202
  if (n === "Map" || n === "Set") return Array.from(n);
137
203
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
138
204
  }
205
+ function _ts_generator(thisArg, body) {
206
+ var f, y, t, _ = {
207
+ label: 0,
208
+ sent: function() {
209
+ if (t[0] & 1) throw t[1];
210
+ return t[1];
211
+ },
212
+ trys: [],
213
+ ops: []
214
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
215
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
216
+ return this;
217
+ }), g;
218
+ function verb(n) {
219
+ return function(v) {
220
+ return step([
221
+ n,
222
+ v
223
+ ]);
224
+ };
225
+ }
226
+ function step(op) {
227
+ if (f) throw new TypeError("Generator is already executing.");
228
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
229
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
230
+ if (y = 0, t) op = [
231
+ op[0] & 2,
232
+ t.value
233
+ ];
234
+ switch(op[0]){
235
+ case 0:
236
+ case 1:
237
+ t = op;
238
+ break;
239
+ case 4:
240
+ _.label++;
241
+ return {
242
+ value: op[1],
243
+ done: false
244
+ };
245
+ case 5:
246
+ _.label++;
247
+ y = op[1];
248
+ op = [
249
+ 0
250
+ ];
251
+ continue;
252
+ case 7:
253
+ op = _.ops.pop();
254
+ _.trys.pop();
255
+ continue;
256
+ default:
257
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
258
+ _ = 0;
259
+ continue;
260
+ }
261
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
262
+ _.label = op[1];
263
+ break;
264
+ }
265
+ if (op[0] === 6 && _.label < t[1]) {
266
+ _.label = t[1];
267
+ t = op;
268
+ break;
269
+ }
270
+ if (t && _.label < t[2]) {
271
+ _.label = t[2];
272
+ _.ops.push(op);
273
+ break;
274
+ }
275
+ if (t[2]) _.ops.pop();
276
+ _.trys.pop();
277
+ continue;
278
+ }
279
+ op = body.call(thisArg, _);
280
+ } catch (e) {
281
+ op = [
282
+ 6,
283
+ e
284
+ ];
285
+ y = 0;
286
+ } finally{
287
+ f = t = 0;
288
+ }
289
+ if (op[0] & 5) throw op[1];
290
+ return {
291
+ value: op[0] ? op[1] : void 0,
292
+ done: true
293
+ };
294
+ }
295
+ }
139
296
  import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
140
297
  // src/components/DropdownSelect/context.ts
141
298
  import { createContext, useContext } from "react";
@@ -149,6 +306,10 @@ function useMyContext() {
149
306
  import { useEffect, useRef, useState } from "react";
150
307
  // src/components/DropdownSelect/styles.ts
151
308
  var styles = {
309
+ container: {
310
+ width: "100%",
311
+ position: "relative"
312
+ },
152
313
  select_box: {
153
314
  borderRadius: "10px",
154
315
  border: "solid 1px #dadada",
@@ -225,7 +386,7 @@ var Search = function(param) {
225
386
  name: "search",
226
387
  onChange: function(e) {
227
388
  return onSearch(options.filter(function(ele) {
228
- return ele.value.toLowerCase().includes(e.target.value.toLowerCase());
389
+ return ele.label.toLowerCase().includes(e.target.value.toLowerCase());
229
390
  }));
230
391
  }
231
392
  })
@@ -299,7 +460,7 @@ var Dropdown_default = Dropdown;
299
460
  import { IoMdClose } from "react-icons/io";
300
461
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
301
462
  var DropdownSelect = function(param) {
302
- var options = param.options, value = param.value, onChange = param.onChange, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width;
463
+ var options = param.options, value = param.value, onChange = param.onChange;
303
464
  var _useState2 = _sliced_to_array(useState2(false), 2), open = _useState2[0], setOpen = _useState2[1];
304
465
  var _useState21 = _sliced_to_array(useState2(false), 2), isHoverClose = _useState21[0], setHoverClose = _useState21[1];
305
466
  var selectRef = useRef2(null);
@@ -323,10 +484,7 @@ var DropdownSelect = function(param) {
323
484
  setOpen: setOpen
324
485
  },
325
486
  children: /* @__PURE__ */ jsxs2("div", {
326
- style: {
327
- width: "".concat(width, "px"),
328
- position: "relative"
329
- },
487
+ style: styles_default.container,
330
488
  ref: selectRef,
331
489
  children: [
332
490
  /* @__PURE__ */ jsxs2("div", {
@@ -1169,7 +1327,7 @@ import { motion } from "framer-motion";
1169
1327
  // src/components/Buttons/gradient/styles.ts
1170
1328
  var borderRadius = "20px";
1171
1329
  var styles6 = function(first, second) {
1172
- var styles8 = {
1330
+ var styles11 = {
1173
1331
  container: {
1174
1332
  position: "relative",
1175
1333
  borderRadius: borderRadius,
@@ -1244,21 +1402,21 @@ var styles6 = function(first, second) {
1244
1402
  width: "100%"
1245
1403
  }
1246
1404
  };
1247
- return styles8;
1405
+ return styles11;
1248
1406
  };
1249
1407
  var styles_default6 = styles6;
1250
1408
  // src/components/Buttons/gradient/Gradient.tsx
1251
1409
  import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1252
1410
  var Gradient = function() {
1253
1411
  var data = useButtonContext();
1254
- var styles8 = styles_default6(data.first, data.second);
1412
+ var styles11 = styles_default6(data.first, data.second);
1255
1413
  return /* @__PURE__ */ jsxs8("div", {
1256
- style: _object_spread_props(_object_spread({}, styles8.container), {
1414
+ style: _object_spread_props(_object_spread({}, styles11.container), {
1257
1415
  overflow: data.isLoading ? "hidden" : ""
1258
1416
  }),
1259
1417
  children: [
1260
1418
  /* @__PURE__ */ jsx10("button", _object_spread_props(_object_spread({
1261
- style: styles8.btn
1419
+ style: styles11.btn
1262
1420
  }, data.props), {
1263
1421
  children: /* @__PURE__ */ jsxs8("div", {
1264
1422
  style: {
@@ -1266,30 +1424,34 @@ var Gradient = function() {
1266
1424
  },
1267
1425
  children: [
1268
1426
  /* @__PURE__ */ jsx10("div", {
1269
- style: styles8.labelBefore
1427
+ style: styles11.labelBefore
1270
1428
  }),
1271
1429
  /* @__PURE__ */ jsx10("div", {
1272
- style: _object_spread_props(_object_spread({}, styles8.label), {
1430
+ style: _object_spread_props(_object_spread({}, styles11.label), {
1273
1431
  backgroundColor: data.main
1274
1432
  }),
1275
- children: /* @__PURE__ */ jsx10("p", {
1276
- style: _object_spread_props(_object_spread({}, styles8.p), {
1433
+ children: /* @__PURE__ */ jsxs8("p", {
1434
+ style: _object_spread_props(_object_spread({}, styles11.p), {
1277
1435
  color: "".concat(data.text)
1278
1436
  }),
1279
- children: data.content
1437
+ children: [
1438
+ data.children,
1439
+ " ",
1440
+ data.content
1441
+ ]
1280
1442
  })
1281
1443
  }),
1282
1444
  /* @__PURE__ */ jsx10("div", {
1283
- style: styles8.labelAfter
1445
+ style: styles11.labelAfter
1284
1446
  })
1285
1447
  ]
1286
1448
  })
1287
1449
  })),
1288
1450
  !data.isLoading && /* @__PURE__ */ jsx10("div", {
1289
- style: styles8.btnAfter
1451
+ style: styles11.btnAfter
1290
1452
  }),
1291
1453
  data.isLoading && /* @__PURE__ */ jsx10(motion.div, {
1292
- style: styles8.btnAfter,
1454
+ style: styles11.btnAfter,
1293
1455
  animate: {
1294
1456
  rotate: 360
1295
1457
  },
@@ -1305,8 +1467,8 @@ var Gradient = function() {
1305
1467
  var Gradient_default = Gradient;
1306
1468
  // src/components/Buttons/solid/styles.ts
1307
1469
  var styles7 = function(first) {
1308
- var styles8 = {
1309
- "btn": {
1470
+ var styles11 = {
1471
+ btn: {
1310
1472
  cursor: "pointer",
1311
1473
  position: "relative",
1312
1474
  zIndex: 0,
@@ -1318,7 +1480,7 @@ var styles7 = function(first) {
1318
1480
  backgroundColor: first,
1319
1481
  border: "none"
1320
1482
  },
1321
- "btnAfter": {
1483
+ btnAfter: {
1322
1484
  position: "absolute",
1323
1485
  top: 0,
1324
1486
  left: 0,
@@ -1328,12 +1490,12 @@ var styles7 = function(first) {
1328
1490
  backgroundColor: first,
1329
1491
  filter: "blur(10px)"
1330
1492
  },
1331
- "label": {
1493
+ label: {
1332
1494
  borderRadius: "0.75rem",
1333
1495
  padding: "0.5rem 2rem",
1334
1496
  color: "white"
1335
1497
  },
1336
- "labelBefore": {
1498
+ labelBefore: {
1337
1499
  position: "absolute",
1338
1500
  top: "20%",
1339
1501
  right: "50%",
@@ -1345,7 +1507,7 @@ var styles7 = function(first) {
1345
1507
  backgroundColor: first,
1346
1508
  filter: "blur(15px)"
1347
1509
  },
1348
- "labelAfter": {
1510
+ labelAfter: {
1349
1511
  position: "absolute",
1350
1512
  top: "20%",
1351
1513
  left: "50%",
@@ -1356,27 +1518,27 @@ var styles7 = function(first) {
1356
1518
  zIndex: 0,
1357
1519
  filter: "blur(20px)"
1358
1520
  },
1359
- "p": {
1521
+ p: {
1360
1522
  zIndex: 1,
1361
1523
  position: "relative",
1362
1524
  margin: 0
1363
1525
  }
1364
1526
  };
1365
- return styles8;
1527
+ return styles11;
1366
1528
  };
1367
1529
  var styles_default7 = styles7;
1368
1530
  // src/components/Buttons/solid/Solid.tsx
1369
1531
  import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1370
1532
  var Solid = function() {
1371
1533
  var data = useButtonContext();
1372
- var styles8 = styles_default7(data.first);
1534
+ var styles11 = styles_default7(data.first);
1373
1535
  return /* @__PURE__ */ jsxs9("div", {
1374
1536
  style: {
1375
1537
  position: "relative"
1376
1538
  },
1377
1539
  children: [
1378
1540
  /* @__PURE__ */ jsx11("button", _object_spread_props(_object_spread({
1379
- style: styles8.btn
1541
+ style: styles11.btn
1380
1542
  }, data.props), {
1381
1543
  children: /* @__PURE__ */ jsxs9("div", {
1382
1544
  style: {
@@ -1384,34 +1546,38 @@ var Solid = function() {
1384
1546
  },
1385
1547
  children: [
1386
1548
  /* @__PURE__ */ jsx11("div", {
1387
- style: styles8.labelBefore
1549
+ style: styles11.labelBefore
1388
1550
  }),
1389
1551
  /* @__PURE__ */ jsx11("div", {
1390
- style: _object_spread_props(_object_spread({}, styles8.label), {
1552
+ style: _object_spread_props(_object_spread({}, styles11.label), {
1391
1553
  backgroundColor: data.main
1392
1554
  }),
1393
- children: /* @__PURE__ */ jsx11("p", {
1394
- style: _object_spread_props(_object_spread({}, styles8.p), {
1555
+ children: /* @__PURE__ */ jsxs9("p", {
1556
+ style: _object_spread_props(_object_spread({}, styles11.p), {
1395
1557
  color: "".concat(data.text)
1396
1558
  }),
1397
- children: data.content
1559
+ children: [
1560
+ data.children,
1561
+ " ",
1562
+ data.content
1563
+ ]
1398
1564
  })
1399
1565
  }),
1400
1566
  /* @__PURE__ */ jsx11("div", {
1401
- style: styles8.labelAfter
1567
+ style: styles11.labelAfter
1402
1568
  })
1403
1569
  ]
1404
1570
  })
1405
1571
  })),
1406
1572
  /* @__PURE__ */ jsx11("div", {
1407
- style: styles8.btnAfter
1573
+ style: styles11.btnAfter
1408
1574
  })
1409
1575
  ]
1410
1576
  });
1411
1577
  };
1412
1578
  var Solid_default = Solid;
1413
1579
  // src/components/Buttons/Button.tsx
1414
- import { jsx as jsx12 } from "react/jsx-runtime";
1580
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1415
1581
  var ButtonContext = createContext3(void 0);
1416
1582
  function useButtonContext() {
1417
1583
  var data = useContext3(ButtonContext);
@@ -1421,14 +1587,15 @@ function useButtonContext() {
1421
1587
  return data;
1422
1588
  }
1423
1589
  var Button = function(_param) {
1424
- var _param_buttonType = _param.buttonType, buttonType = _param_buttonType === void 0 ? "normal" : _param_buttonType, content = _param.content, _param_main = _param.main, main = _param_main === void 0 ? "#111723" : _param_main, _param_first = _param.first, first = _param_first === void 0 ? "#3e8fbc" : _param_first, _param_second = _param.second, second = _param_second === void 0 ? "#aa6392" : _param_second, _param_text = _param.text, text = _param_text === void 0 ? "#fff" : _param_text, _param_isLoading = _param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, props = _object_without_properties(_param, [
1590
+ var _param_buttonType = _param.buttonType, buttonType = _param_buttonType === void 0 ? "normal" : _param_buttonType, _param_content = _param.content, content = _param_content === void 0 ? "" : _param_content, _param_main = _param.main, main = _param_main === void 0 ? "#111723" : _param_main, _param_first = _param.first, first = _param_first === void 0 ? "#3e8fbc" : _param_first, _param_second = _param.second, second = _param_second === void 0 ? "#aa6392" : _param_second, _param_text = _param.text, text = _param_text === void 0 ? "#fff" : _param_text, _param_isLoading = _param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, _param_children = _param.children, children = _param_children === void 0 ? void 0 : _param_children, props = _object_without_properties(_param, [
1425
1591
  "buttonType",
1426
1592
  "content",
1427
1593
  "main",
1428
1594
  "first",
1429
1595
  "second",
1430
1596
  "text",
1431
- "isLoading"
1597
+ "isLoading",
1598
+ "children"
1432
1599
  ]);
1433
1600
  switch(buttonType){
1434
1601
  case "gradient":
@@ -1440,7 +1607,8 @@ var Button = function(_param) {
1440
1607
  second: second,
1441
1608
  text: text,
1442
1609
  props: props,
1443
- isLoading: isLoading
1610
+ isLoading: isLoading,
1611
+ children: children
1444
1612
  },
1445
1613
  children: /* @__PURE__ */ jsx12(Gradient_default, {})
1446
1614
  });
@@ -1452,15 +1620,1279 @@ var Button = function(_param) {
1452
1620
  first: first,
1453
1621
  text: text,
1454
1622
  props: props,
1455
- isLoading: isLoading
1623
+ isLoading: isLoading,
1624
+ children: children
1456
1625
  },
1457
1626
  children: /* @__PURE__ */ jsx12(Solid_default, {})
1458
1627
  });
1459
1628
  default:
1460
- return /* @__PURE__ */ jsx12("button", _object_spread_props(_object_spread({}, props), {
1461
- children: content
1629
+ return /* @__PURE__ */ jsxs10("button", _object_spread_props(_object_spread({}, props), {
1630
+ children: [
1631
+ children,
1632
+ " ",
1633
+ content
1634
+ ]
1462
1635
  }));
1463
1636
  }
1464
1637
  };
1465
1638
  var Button_default = Button;
1466
- export { Button_default as Button, ColorPickerSlider_default as ColorPickerSlider, DropdownSelect_default as DropdownSelect, MultiSelect_default as MultiSelect, OptionSlider_default as OptionSlider, RangeSlider_default as RangeSlider };
1639
+ // src/components/Avatar/Avatar.tsx
1640
+ import { IoCloudUploadOutline } from "react-icons/io5";
1641
+ import { FaTrashCan } from "react-icons/fa6";
1642
+ import { RiEditLine } from "react-icons/ri";
1643
+ // src/components/Avatar/styles.ts
1644
+ var others = {
1645
+ iconSize: "20"
1646
+ };
1647
+ var button = {
1648
+ fontSize: "0.8rem",
1649
+ border: "none",
1650
+ borderRadius: "15px",
1651
+ padding: "3%",
1652
+ display: "flex",
1653
+ gap: "5px",
1654
+ justifyContent: "center",
1655
+ alignItems: "center",
1656
+ cursor: "pointer",
1657
+ position: "absolute"
1658
+ };
1659
+ var styles8 = {
1660
+ container: {
1661
+ width: "100%",
1662
+ height: "100%",
1663
+ display: "flex",
1664
+ position: "relative"
1665
+ },
1666
+ image: {
1667
+ borderRadius: "50%",
1668
+ background: "white",
1669
+ objectFit: "cover",
1670
+ width: "100%",
1671
+ height: "100%"
1672
+ },
1673
+ unknown: {
1674
+ display: "flex",
1675
+ justifyContent: "center",
1676
+ alignItems: "center",
1677
+ width: "100%",
1678
+ height: "100%"
1679
+ },
1680
+ upload: _object_spread_props(_object_spread({}, button), {
1681
+ bottom: 0,
1682
+ right: 0
1683
+ }),
1684
+ remove: _object_spread_props(_object_spread({}, button), {
1685
+ top: 0,
1686
+ right: 0
1687
+ }),
1688
+ edit: _object_spread({}, button)
1689
+ };
1690
+ var styles_default8 = styles8;
1691
+ // src/components/Avatar/Avatar.tsx
1692
+ import { useEffect as useEffect7, useRef as useRef7, useState as useState7 } from "react";
1693
+ import { Fragment, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1694
+ var Avatar = function(param) {
1695
+ var src = param.src, setValue = param.setValue;
1696
+ var setSrc = function setSrc() {
1697
+ return _async_to_generator(function() {
1698
+ var translatedSrc;
1699
+ return _ts_generator(this, function(_state) {
1700
+ switch(_state.label){
1701
+ case 0:
1702
+ return [
1703
+ 4,
1704
+ Image_default2.FromStringToImageSrc(src)
1705
+ ];
1706
+ case 1:
1707
+ translatedSrc = _state.sent();
1708
+ if (!translatedSrc) return [
1709
+ 2
1710
+ ];
1711
+ defaultImage.current = translatedSrc;
1712
+ setValue(translatedSrc);
1713
+ return [
1714
+ 2
1715
+ ];
1716
+ }
1717
+ });
1718
+ })();
1719
+ };
1720
+ var _useState7 = _sliced_to_array(useState7(false), 2), isOpen = _useState7[0], setOpen = _useState7[1];
1721
+ var _useState71 = _sliced_to_array(useState7(false), 2), isNew = _useState71[0], setNew = _useState71[1];
1722
+ var uploadImageRef = useRef7(null);
1723
+ var defaultImage = useRef7("");
1724
+ useEffect7(function() {
1725
+ setSrc();
1726
+ }, [
1727
+ src
1728
+ ]);
1729
+ return /* @__PURE__ */ jsxs11("div", {
1730
+ style: styles_default8.container,
1731
+ children: [
1732
+ /* @__PURE__ */ jsx13(ImageEditor_default, {
1733
+ src: src,
1734
+ setSrc: setValue,
1735
+ isOpen: isOpen,
1736
+ setOpen: setOpen,
1737
+ isNew: isNew
1738
+ }),
1739
+ /* @__PURE__ */ jsx13(Image_default, {
1740
+ src: src,
1741
+ style: styles_default8.image
1742
+ }),
1743
+ /* @__PURE__ */ jsxs11(Button_default, {
1744
+ style: styles_default8.upload,
1745
+ onClick: function() {
1746
+ var _uploadImageRef_current;
1747
+ return (_uploadImageRef_current = uploadImageRef.current) === null || _uploadImageRef_current === void 0 ? void 0 : _uploadImageRef_current.click();
1748
+ },
1749
+ children: [
1750
+ /* @__PURE__ */ jsx13(IoCloudUploadOutline, {
1751
+ size: others.iconSize
1752
+ }),
1753
+ "Upload"
1754
+ ]
1755
+ }),
1756
+ /* @__PURE__ */ jsx13(UploadImage_default, {
1757
+ ref: uploadImageRef,
1758
+ setSrc: function(e) {
1759
+ setValue(e);
1760
+ setOpen(true);
1761
+ setNew(function(prev) {
1762
+ return !prev;
1763
+ });
1764
+ }
1765
+ }),
1766
+ src !== defaultImage.current && /* @__PURE__ */ jsxs11(Fragment, {
1767
+ children: [
1768
+ /* @__PURE__ */ jsxs11(Button_default, {
1769
+ style: styles_default8.remove,
1770
+ onClick: function() {
1771
+ setValue(defaultImage.current);
1772
+ setNew(function(prev) {
1773
+ return !prev;
1774
+ });
1775
+ },
1776
+ children: [
1777
+ /* @__PURE__ */ jsx13(FaTrashCan, {
1778
+ size: others.iconSize,
1779
+ color: "red"
1780
+ }),
1781
+ "Remove"
1782
+ ]
1783
+ }),
1784
+ /* @__PURE__ */ jsxs11(Button_default, {
1785
+ style: styles_default8.edit,
1786
+ onClick: function() {
1787
+ return setOpen(function(prev) {
1788
+ return !prev;
1789
+ });
1790
+ },
1791
+ children: [
1792
+ /* @__PURE__ */ jsx13(RiEditLine, {
1793
+ size: others.iconSize
1794
+ }),
1795
+ "Edit"
1796
+ ]
1797
+ })
1798
+ ]
1799
+ })
1800
+ ]
1801
+ });
1802
+ };
1803
+ var Avatar_default = Avatar;
1804
+ // src/components/Input/InputGoogle/InputGoogle.tsx
1805
+ import { useEffect as useEffect8, useRef as useRef8, useState as useState8 } from "react";
1806
+ // src/components/Input/InputGoogle/InputGoogle.styles.ts
1807
+ var others2 = {
1808
+ topRelease: "50%",
1809
+ topFocus: "0",
1810
+ fontSizeRelease: "16px",
1811
+ fontSizeFocus: "14px",
1812
+ borderRelease: "#cbcbcb",
1813
+ borderFocus: "#0957d0",
1814
+ textRelease: "#000",
1815
+ textFocus: "#0957d0",
1816
+ border: "solid 2px"
1817
+ };
1818
+ var styles9 = {
1819
+ input: {
1820
+ boxSizing: "border-box",
1821
+ height: "40px",
1822
+ width: "100%",
1823
+ border: "".concat(others2.border, " ").concat(others2.borderRelease),
1824
+ borderRadius: "6px",
1825
+ padding: "10px",
1826
+ outline: "none"
1827
+ },
1828
+ container: {
1829
+ width: "100%",
1830
+ position: "relative"
1831
+ },
1832
+ label: {
1833
+ position: "absolute",
1834
+ top: "50%",
1835
+ left: "10px",
1836
+ fontSize: "16px",
1837
+ transform: "translateY(-50%)",
1838
+ transition: "all .1s linear",
1839
+ padding: "0px 5px",
1840
+ backgroundColor: "white"
1841
+ }
1842
+ };
1843
+ var InputGoogle_styles_default = styles9;
1844
+ // src/components/Input/InputGoogle/InputGoogle.tsx
1845
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1846
+ var InputGoogle = function(_param) {
1847
+ var transitionOnFocus = function transitionOnFocus() {
1848
+ setFocus(true);
1849
+ if (spanRef.current) {
1850
+ spanRef.current.style.top = others2.topFocus;
1851
+ spanRef.current.style.fontSize = others2.fontSizeFocus;
1852
+ }
1853
+ };
1854
+ var transitionOffFocus = function transitionOffFocus() {
1855
+ setFocus(false);
1856
+ if (value) return;
1857
+ if (spanRef.current) {
1858
+ spanRef.current.style.top = others2.topRelease;
1859
+ spanRef.current.style.fontSize = others2.fontSizeRelease;
1860
+ }
1861
+ };
1862
+ var handleClickOnLabel = function handleClickOnLabel() {
1863
+ var _inputRef_current;
1864
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
1865
+ };
1866
+ var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, _param_setValue = _param.setValue, setValue = _param_setValue === void 0 ? function() {} : _param_setValue, _param_label = _param.label, label = _param_label === void 0 ? "Input Google Component Label" : _param_label, options = _param.options, props = _object_without_properties(_param, [
1867
+ "value",
1868
+ "setValue",
1869
+ "label",
1870
+ "options"
1871
+ ]);
1872
+ var _useState8 = _sliced_to_array(useState8(false), 2), isFocus = _useState8[0], setFocus = _useState8[1];
1873
+ var spanRef = useRef8(null);
1874
+ var inputRef = useRef8(null);
1875
+ var inputBorder = isFocus ? "".concat(others2.border, " ").concat(options ? options.focusColor : others2.borderFocus) : "".concat(others2.border, " ").concat(others2.borderRelease);
1876
+ var labelTextColor = isFocus ? "".concat(options ? options.focusColor : others2.textFocus) : "".concat(others2.textRelease);
1877
+ useEffect8(function() {
1878
+ transitionOnFocus();
1879
+ transitionOffFocus();
1880
+ }, []);
1881
+ return /* @__PURE__ */ jsxs12("div", {
1882
+ style: InputGoogle_styles_default.container,
1883
+ children: [
1884
+ /* @__PURE__ */ jsx14("input", _object_spread({
1885
+ id: "will-input-google",
1886
+ ref: inputRef,
1887
+ value: value,
1888
+ onChange: function(e) {
1889
+ return setValue(e.target.value);
1890
+ },
1891
+ type: "text",
1892
+ style: _object_spread_props(_object_spread({}, InputGoogle_styles_default.input), {
1893
+ border: inputBorder
1894
+ }),
1895
+ onFocus: transitionOnFocus,
1896
+ onBlur: transitionOffFocus
1897
+ }, props)),
1898
+ /* @__PURE__ */ jsx14("span", {
1899
+ ref: spanRef,
1900
+ style: _object_spread_props(_object_spread({}, InputGoogle_styles_default.label), {
1901
+ color: labelTextColor
1902
+ }),
1903
+ onClick: handleClickOnLabel,
1904
+ children: label
1905
+ })
1906
+ ]
1907
+ });
1908
+ };
1909
+ var InputGoogle_default = InputGoogle;
1910
+ // src/components/Input/TextArea/TextArea.tsx
1911
+ import { useEffect as useEffect9, useRef as useRef9, useState as useState9 } from "react";
1912
+ // src/components/Input/TextArea/TextArea.styles.ts
1913
+ var labelHeight = 20;
1914
+ var others3 = {
1915
+ topRelease: "".concat(labelHeight + 5, "px"),
1916
+ topFocus: "0",
1917
+ fontSizeRelease: "16px",
1918
+ fontSizeFocus: "14px",
1919
+ borderRelease: "#cbcbcb",
1920
+ borderFocus: "#0957d0",
1921
+ textRelease: "#000",
1922
+ textFocus: "#0957d0",
1923
+ border: "solid 2px"
1924
+ };
1925
+ var styles10 = {
1926
+ input: {
1927
+ boxSizing: "border-box",
1928
+ height: "100%",
1929
+ width: "100%",
1930
+ border: "".concat(others3.border, " ").concat(others3.borderRelease),
1931
+ borderRadius: "6px",
1932
+ padding: "10px",
1933
+ outline: "none",
1934
+ resize: "none"
1935
+ },
1936
+ container: {
1937
+ width: "100%",
1938
+ height: "100%",
1939
+ position: "relative"
1940
+ },
1941
+ label: {
1942
+ height: "".concat(labelHeight, "px"),
1943
+ position: "absolute",
1944
+ top: "".concat(labelHeight + 5, "px"),
1945
+ left: "10px",
1946
+ fontSize: "16px",
1947
+ transform: "translateY(-50%)",
1948
+ transition: "all .1s linear",
1949
+ padding: "0px 5px",
1950
+ backgroundColor: "white"
1951
+ }
1952
+ };
1953
+ var TextArea_styles_default = styles10;
1954
+ // src/components/Input/TextArea/TextArea.tsx
1955
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1956
+ var TextArea = function(_param) {
1957
+ var transitionOnFocus = function transitionOnFocus() {
1958
+ setFocus(true);
1959
+ if (spanRef.current) {
1960
+ spanRef.current.style.top = others3.topFocus;
1961
+ spanRef.current.style.fontSize = others3.fontSizeFocus;
1962
+ }
1963
+ };
1964
+ var transitionOffFocus = function transitionOffFocus() {
1965
+ setFocus(false);
1966
+ if (value) return;
1967
+ if (spanRef.current) {
1968
+ spanRef.current.style.top = others3.topRelease;
1969
+ spanRef.current.style.fontSize = others3.fontSizeRelease;
1970
+ }
1971
+ };
1972
+ var handleClickOnLabel = function handleClickOnLabel() {
1973
+ var _inputRef_current;
1974
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
1975
+ };
1976
+ var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, _param_setValue = _param.setValue, setValue = _param_setValue === void 0 ? function() {} : _param_setValue, _param_label = _param.label, label = _param_label === void 0 ? "Text Component Label" : _param_label, options = _param.options, props = _object_without_properties(_param, [
1977
+ "value",
1978
+ "setValue",
1979
+ "label",
1980
+ "options"
1981
+ ]);
1982
+ var _useState9 = _sliced_to_array(useState9(false), 2), isFocus = _useState9[0], setFocus = _useState9[1];
1983
+ var spanRef = useRef9(null);
1984
+ var inputRef = useRef9(null);
1985
+ var inputBorder = isFocus ? "".concat(others3.border, " ").concat(options ? options.focusColor : others3.borderFocus) : "".concat(others3.border, " ").concat(others3.borderRelease);
1986
+ var labelTextColor = isFocus ? "".concat(options ? options.focusColor : others3.textFocus) : "".concat(others3.textRelease);
1987
+ useEffect9(function() {
1988
+ transitionOnFocus();
1989
+ transitionOffFocus();
1990
+ }, []);
1991
+ return /* @__PURE__ */ jsxs13("div", {
1992
+ style: TextArea_styles_default.container,
1993
+ children: [
1994
+ /* @__PURE__ */ jsx15("textarea", _object_spread({
1995
+ id: "will-textarea",
1996
+ ref: inputRef,
1997
+ value: value,
1998
+ onChange: function(e) {
1999
+ return setValue(e.target.value);
2000
+ },
2001
+ style: _object_spread_props(_object_spread({}, TextArea_styles_default.input), {
2002
+ border: inputBorder
2003
+ }),
2004
+ onFocus: transitionOnFocus,
2005
+ onBlur: transitionOffFocus
2006
+ }, props)),
2007
+ /* @__PURE__ */ jsx15("span", {
2008
+ ref: spanRef,
2009
+ style: _object_spread_props(_object_spread({}, TextArea_styles_default.label), {
2010
+ color: labelTextColor
2011
+ }),
2012
+ onClick: handleClickOnLabel,
2013
+ children: label
2014
+ })
2015
+ ]
2016
+ });
2017
+ };
2018
+ var TextArea_default = TextArea;
2019
+ // src/components/Input/InputFile.tsx
2020
+ import { useState as useState10 } from "react";
2021
+ import { jsx as jsx16 } from "react/jsx-runtime";
2022
+ var InputFile = function(_param) {
2023
+ var file = _param.file, onChoose = _param.onChoose, _param_onCancel = _param.onCancel, onCancel = _param_onCancel === void 0 ? function() {} : _param_onCancel, _param_acceptType = _param.acceptType, acceptType = _param_acceptType === void 0 ? "image/*" : _param_acceptType, props = _object_without_properties(_param, [
2024
+ "file",
2025
+ "onChoose",
2026
+ "onCancel",
2027
+ "acceptType"
2028
+ ]);
2029
+ var _useState10 = _sliced_to_array(useState10(Date.now()), 2), key = _useState10[0], setKey = _useState10[1];
2030
+ return /* @__PURE__ */ jsx16("input", _object_spread_props(_object_spread({
2031
+ type: "file"
2032
+ }, props), {
2033
+ onChange: function(e) {
2034
+ var _target_files;
2035
+ var target = e.target;
2036
+ var file2 = (_target_files = target.files) === null || _target_files === void 0 ? void 0 : _target_files[0];
2037
+ if (file2) {
2038
+ setKey(Date.now());
2039
+ onChoose(file2);
2040
+ } else {
2041
+ onCancel();
2042
+ }
2043
+ }
2044
+ }), key);
2045
+ };
2046
+ var InputFile_default = InputFile;
2047
+ // src/components/Image/UploadImage.tsx
2048
+ import { Fragment as Fragment2, jsx as jsx17 } from "react/jsx-runtime";
2049
+ var UploadImage = function(_param) {
2050
+ var handleSetSrc = function handleSetSrc(file) {
2051
+ return _async_to_generator(function() {
2052
+ var src;
2053
+ return _ts_generator(this, function(_state) {
2054
+ switch(_state.label){
2055
+ case 0:
2056
+ return [
2057
+ 4,
2058
+ Image_default2.FromFileToImageSrc(file)
2059
+ ];
2060
+ case 1:
2061
+ src = _state.sent();
2062
+ if (!src) return [
2063
+ 2
2064
+ ];
2065
+ setSrc(src);
2066
+ return [
2067
+ 2
2068
+ ];
2069
+ }
2070
+ });
2071
+ })();
2072
+ };
2073
+ var _param_setSrc = _param.setSrc, setSrc = _param_setSrc === void 0 ? function() {} : _param_setSrc, props = _object_without_properties(_param, [
2074
+ "setSrc"
2075
+ ]);
2076
+ return /* @__PURE__ */ jsx17(Fragment2, {
2077
+ children: /* @__PURE__ */ jsx17(InputFile_default, _object_spread_props(_object_spread({
2078
+ onChoose: handleSetSrc,
2079
+ acceptType: "image/*"
2080
+ }, props), {
2081
+ hidden: true
2082
+ }))
2083
+ });
2084
+ };
2085
+ var UploadImage_default = UploadImage;
2086
+ // src/components/Image/Image.tsx
2087
+ import { jsx as jsx18 } from "react/jsx-runtime";
2088
+ var Image = function(_param) {
2089
+ var props = _extends({}, _object_destructuring_empty(_param));
2090
+ return /* @__PURE__ */ jsx18("img", _object_spread_props(_object_spread({
2091
+ style: {
2092
+ width: "100%",
2093
+ height: "100%"
2094
+ }
2095
+ }, props), {
2096
+ alt: "Will-Image-Component",
2097
+ draggable: false
2098
+ }));
2099
+ };
2100
+ var Image_default = Image;
2101
+ // src/components/Image/ImageEditor/ImageEditor.tsx
2102
+ import { useEffect as useEffect10, useMemo, useRef as useRef10, useState as useState11 } from "react";
2103
+ // src/components/Image/ImageEditor/ImageEditor.styles.ts
2104
+ var imageEditorStyles = {
2105
+ imageEditor: {
2106
+ width: "100vw",
2107
+ height: "100dvh",
2108
+ display: "flex",
2109
+ flexDirection: "column",
2110
+ justifyContent: "center",
2111
+ alignItems: "center",
2112
+ position: "fixed",
2113
+ top: 0,
2114
+ left: 0,
2115
+ backdropFilter: "blur(20px)",
2116
+ zIndex: 99,
2117
+ paddingLeft: "30px",
2118
+ paddingRight: "30px"
2119
+ },
2120
+ frame: {
2121
+ padding: "50px",
2122
+ backgroundColor: "white",
2123
+ border: "solid 4px #000",
2124
+ borderStyle: "dashed",
2125
+ borderRadius: "50%",
2126
+ overflow: "hidden",
2127
+ maxWidth: "500px",
2128
+ width: "100%",
2129
+ maxHeight: "500px",
2130
+ aspectRatio: 1 / 1,
2131
+ position: "relative"
2132
+ },
2133
+ wrapper: {
2134
+ position: "absolute",
2135
+ transformOrigin: "top left",
2136
+ userSelect: "none"
2137
+ },
2138
+ img: {
2139
+ objectFit: "contain",
2140
+ position: "absolute",
2141
+ top: 0,
2142
+ left: 0,
2143
+ display: "block",
2144
+ zIndex: 1,
2145
+ transform: "translate(-50%, -50%)"
2146
+ },
2147
+ buttons: {
2148
+ display: "flex",
2149
+ justifyContent: "center",
2150
+ alignItems: "center",
2151
+ gap: "20px",
2152
+ padding: "30px"
2153
+ }
2154
+ };
2155
+ var ImageEditor_styles_default = imageEditorStyles;
2156
+ // src/components/Image/ImageEditor/ImageEditor.tsx
2157
+ import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
2158
+ var ImageEditor = function(param) {
2159
+ var src = param.src, _param_setSrc = param.setSrc, setSrc = _param_setSrc === void 0 ? function() {} : _param_setSrc, _param_isOpen = param.isOpen, isOpen = _param_isOpen === void 0 ? false : _param_isOpen, _param_setOpen = param.setOpen, setOpen = _param_setOpen === void 0 ? function() {} : _param_setOpen, _param_isNew = param.isNew, isNew = _param_isNew === void 0 ? false : _param_isNew;
2160
+ var createTransform = function createTransform() {
2161
+ return _async_to_generator(function() {
2162
+ var transform2;
2163
+ return _ts_generator(this, function(_state) {
2164
+ switch(_state.label){
2165
+ case 0:
2166
+ if (!frame.current || !wrapper.current || !img.current) return [
2167
+ 2
2168
+ ];
2169
+ transform2 = new Transform(wrapper.current, frame.current);
2170
+ return [
2171
+ 4,
2172
+ transform2.initialize()
2173
+ ];
2174
+ case 1:
2175
+ _state.sent();
2176
+ if (transformState.current) {
2177
+ transform2.setState(transformState.current);
2178
+ } else {
2179
+ transform2.reset();
2180
+ }
2181
+ setTransform(transform2);
2182
+ return [
2183
+ 2
2184
+ ];
2185
+ }
2186
+ });
2187
+ })();
2188
+ };
2189
+ var handleCanvasToSrc = function handleCanvasToSrc() {
2190
+ if (!frame.current || !wrapper.current || !img.current || !transform) return;
2191
+ var canvasInstance = new Canvas();
2192
+ var _canvasInstance_createCanvas = canvasInstance.createCanvas(700, 700), canvas = _canvasInstance_createCanvas.canvas, context = _canvasInstance_createCanvas.context;
2193
+ var _transform_exportData = transform.exportData(), x = _transform_exportData.x, y = _transform_exportData.y, angle = _transform_exportData.angle;
2194
+ transformState.current = transform.exportData();
2195
+ var _canvasInstance_drawImage = canvasInstance.drawImage(img.current, context, x, y, 1, angle, canvas, frame.current.clientWidth, frame.current.clientHeight), src2 = _canvasInstance_drawImage.src;
2196
+ return src2;
2197
+ };
2198
+ var handleAccept = function handleAccept() {
2199
+ setSrc(handleCanvasToSrc());
2200
+ setOpen(false);
2201
+ };
2202
+ var handleCancel = function handleCancel() {
2203
+ setOpen(false);
2204
+ };
2205
+ var handleReset = function handleReset() {
2206
+ if (!transform) return;
2207
+ transform.reset();
2208
+ };
2209
+ var frame = useRef10(null);
2210
+ var wrapper = useRef10(null);
2211
+ var img = useRef10(null);
2212
+ var _useState11 = _sliced_to_array(useState11(void 0), 2), transform = _useState11[0], setTransform = _useState11[1];
2213
+ var transformState = useRef10(void 0);
2214
+ var originalSrc = useMemo(function() {
2215
+ transformState.current = void 0;
2216
+ return src;
2217
+ }, [
2218
+ isNew
2219
+ ]);
2220
+ useEffect10(function() {
2221
+ isOpen ? createTransform() : setTransform(void 0);
2222
+ }, [
2223
+ isOpen
2224
+ ]);
2225
+ if (!isOpen) return;
2226
+ return /* @__PURE__ */ jsxs14("div", {
2227
+ style: ImageEditor_styles_default.imageEditor,
2228
+ children: [
2229
+ /* @__PURE__ */ jsx19("p", {
2230
+ children: "Drag, Zoom, or Rotate image"
2231
+ }),
2232
+ /* @__PURE__ */ jsx19("div", {
2233
+ ref: frame,
2234
+ style: ImageEditor_styles_default.frame,
2235
+ children: /* @__PURE__ */ jsx19("div", {
2236
+ ref: wrapper,
2237
+ style: ImageEditor_styles_default.wrapper,
2238
+ children: /* @__PURE__ */ jsx19("img", {
2239
+ src: originalSrc,
2240
+ style: ImageEditor_styles_default.img,
2241
+ ref: img
2242
+ })
2243
+ })
2244
+ }),
2245
+ /* @__PURE__ */ jsxs14("div", {
2246
+ style: ImageEditor_styles_default.buttons,
2247
+ children: [
2248
+ /* @__PURE__ */ jsx19(Button_default, {
2249
+ buttonType: "solid",
2250
+ content: "Accept",
2251
+ onClick: handleAccept
2252
+ }),
2253
+ /* @__PURE__ */ jsx19(Button_default, {
2254
+ buttonType: "solid",
2255
+ content: "Cancel",
2256
+ onClick: handleCancel
2257
+ }),
2258
+ /* @__PURE__ */ jsx19(Button_default, {
2259
+ buttonType: "solid",
2260
+ content: "Reset",
2261
+ onClick: handleReset
2262
+ })
2263
+ ]
2264
+ })
2265
+ ]
2266
+ });
2267
+ };
2268
+ var ImageEditor_default = ImageEditor;
2269
+ // src/utilities/canvas/Canvas.ts
2270
+ var Canvas = /*#__PURE__*/ function() {
2271
+ "use strict";
2272
+ function Canvas() {
2273
+ _class_call_check(this, Canvas);
2274
+ }
2275
+ _create_class(Canvas, [
2276
+ {
2277
+ key: "createCanvas",
2278
+ value: function createCanvas(width, height) {
2279
+ var canvas = document.createElement("canvas");
2280
+ var context = canvas.getContext("2d");
2281
+ canvas.width = width;
2282
+ canvas.height = height;
2283
+ return {
2284
+ canvas: canvas,
2285
+ context: context
2286
+ };
2287
+ }
2288
+ },
2289
+ {
2290
+ key: "drawImage",
2291
+ value: function drawImage(e, ctx, x, y, scale, angle, canvas, containerWidth, containerHeight) {
2292
+ var ratioX = canvas.width / containerWidth;
2293
+ var ratioY = canvas.height / containerHeight;
2294
+ var finalX = x * ratioX;
2295
+ var finalY = y * ratioY;
2296
+ var midleWidth = e.width * ratioX;
2297
+ var midleHeight = e.height * ratioY;
2298
+ var finalWidth = e.width * ratioX * scale;
2299
+ var finalHeight = e.height * ratioY * scale;
2300
+ ctx.save();
2301
+ ctx.translate(finalX + midleWidth / 2, finalY + midleHeight / 2);
2302
+ ctx.rotate(angle * Math.PI / 180);
2303
+ ctx.drawImage(e, -finalWidth / 2, -finalHeight / 2, finalWidth, finalHeight);
2304
+ ctx.restore();
2305
+ var src = ctx.canvas.toDataURL();
2306
+ var srcEncoded = src.split(",")[1];
2307
+ return {
2308
+ context: ctx,
2309
+ src: src
2310
+ };
2311
+ }
2312
+ },
2313
+ {
2314
+ key: "drawColor",
2315
+ value: function drawColor(type, color, ctx, width, ratio) {
2316
+ if (type === "") color = "#ffffff";
2317
+ if (type === "gradient") {
2318
+ var breakdownArr = color.split(",");
2319
+ var _ref = [
2320
+ Number(breakdownArr[0]),
2321
+ breakdownArr[1],
2322
+ Number(breakdownArr[2]),
2323
+ breakdownArr[3],
2324
+ Number(breakdownArr[4])
2325
+ ], angle = _ref[0], color1 = _ref[1], percent1 = _ref[2], color2 = _ref[3], percent2 = _ref[4];
2326
+ var radians = (angle - 180) * Math.PI / 180;
2327
+ var x0 = width / 2 + width / 2 * Math.cos(radians - Math.PI / 2);
2328
+ var y0 = width * ratio / 2 + width * ratio / 2 * Math.sin(radians - Math.PI / 2);
2329
+ var x1 = width / 2 - width / 2 * Math.cos(radians - Math.PI / 2);
2330
+ var y1 = width * ratio / 2 - width * ratio / 2 * Math.sin(radians - Math.PI / 2);
2331
+ var gradient = ctx.createLinearGradient(x0, y0, x1, y1);
2332
+ gradient.addColorStop(percent1 / 100, color1);
2333
+ gradient.addColorStop(percent2 / 100, color2);
2334
+ ctx.fillStyle = gradient;
2335
+ ctx.fillRect(0, 0, width, width * ratio);
2336
+ var srcEncoded = ctx.canvas.toDataURL().split(",")[1];
2337
+ return [
2338
+ ctx,
2339
+ srcEncoded
2340
+ ];
2341
+ } else {
2342
+ ctx.fillStyle = color;
2343
+ ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
2344
+ var srcEncoded1 = ctx.canvas.toDataURL().split(",")[1];
2345
+ return [
2346
+ ctx,
2347
+ srcEncoded1
2348
+ ];
2349
+ }
2350
+ }
2351
+ }
2352
+ ]);
2353
+ return Canvas;
2354
+ }();
2355
+ // src/utilities/canvas/Image.ts
2356
+ var Image2 = {
2357
+ /**
2358
+ * Convert file (blob) to base64 string format
2359
+ * @param file
2360
+ * @returns
2361
+ */ FromFileToImageSrc: function FromFileToImageSrc(file) {
2362
+ return new Promise(function(resolve, reject) {
2363
+ if (!file) return resolve(null);
2364
+ var reader = new FileReader();
2365
+ reader.readAsDataURL(file);
2366
+ reader.onload = function(readerEvent) {
2367
+ var _readerEvent_target;
2368
+ if ((_readerEvent_target = readerEvent.target) === null || _readerEvent_target === void 0 ? void 0 : _readerEvent_target.result) {
2369
+ var _readerEvent_target1;
2370
+ return resolve((_readerEvent_target1 = readerEvent.target) === null || _readerEvent_target1 === void 0 ? void 0 : _readerEvent_target1.result);
2371
+ }
2372
+ reject("Error getting the image source");
2373
+ };
2374
+ reader.onerror = function() {
2375
+ reject("Error getting the image source");
2376
+ };
2377
+ });
2378
+ },
2379
+ FromStringToImageSrc: /**
2380
+ * Convert urlst
2381
+ * @param url
2382
+ * @returns
2383
+ */ function FromStringToImageSrc(url) {
2384
+ return _async_to_generator(function() {
2385
+ var res, blob, src;
2386
+ return _ts_generator(this, function(_state) {
2387
+ switch(_state.label){
2388
+ case 0:
2389
+ if (!url || Image2.isBase64(url)) return [
2390
+ 2,
2391
+ null
2392
+ ];
2393
+ return [
2394
+ 4,
2395
+ fetch(url)
2396
+ ];
2397
+ case 1:
2398
+ res = _state.sent();
2399
+ return [
2400
+ 4,
2401
+ res.blob()
2402
+ ];
2403
+ case 2:
2404
+ blob = _state.sent();
2405
+ return [
2406
+ 4,
2407
+ Image2.FromFileToImageSrc(blob)
2408
+ ];
2409
+ case 3:
2410
+ src = _state.sent();
2411
+ return [
2412
+ 2,
2413
+ src
2414
+ ];
2415
+ }
2416
+ });
2417
+ })();
2418
+ },
2419
+ /**
2420
+ * Check if the url is base64 format
2421
+ * @param url
2422
+ * @deprecated Using a weak condition and might be changed later. Use checkBase64 instead
2423
+ */ checkBase64: function checkBase64(url) {
2424
+ if (!url || url === "") return false;
2425
+ return url.includes("base64,");
2426
+ },
2427
+ isBase64: function isBase64(url) {
2428
+ return Image2.checkBase64(url);
2429
+ }
2430
+ };
2431
+ var Image_default2 = Image2;
2432
+ // src/utilities/Transform/Transform.ts
2433
+ import $2 from "jquery";
2434
+ // src/utilities/Transform/TransformController.ts
2435
+ import $ from "jquery";
2436
+ import { icon } from "@fortawesome/fontawesome-svg-core";
2437
+ import { faRotate, faTrash } from "@fortawesome/free-solid-svg-icons";
2438
+ var TransformController = /*#__PURE__*/ function() {
2439
+ "use strict";
2440
+ function TransformController(wrapper, frame, controller) {
2441
+ _class_call_check(this, TransformController);
2442
+ this.wrapper = wrapper;
2443
+ this.frame = frame;
2444
+ this.controller = controller;
2445
+ }
2446
+ _create_class(TransformController, [
2447
+ {
2448
+ key: "addController",
2449
+ value: function addController() {
2450
+ var _this = this;
2451
+ return new Promise(function(res) {
2452
+ var styleElement = document.createElement("style");
2453
+ styleElement.textContent = _this.css();
2454
+ document.head.appendChild(styleElement);
2455
+ $("." + _this.frame).after(_this.controllerTemplate());
2456
+ res();
2457
+ });
2458
+ }
2459
+ },
2460
+ {
2461
+ key: "css",
2462
+ value: function css() {
2463
+ return "\n .".concat(this.wrapper, " {\n position: absolute;\n transform-origin: top left;\n user-select: none;\n }\n .").concat(this.wrapper, " > img {\n object-fit: contain;\n position: absolute;\n top: 0;\n left: 0;\n display: block;\n z-index: 1;\n transform: translate(-50%, -50%)\n }\n .").concat(this.controller, "--container {\n position: absolute;\n transform-origin: top left;\n user-select: none;\n }\n .").concat(this.controller, " {\n position: absolute;\n user-select: none;\n border: solid 3px #6924d5;\n z-index: 1;\n top: 0;\n left: 0;\n transform: translate(-50%, -50%);\n }\n .").concat(this.controller, " .resize {\n background-color: #fff;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;\n transition: all .1s linear;\n }\n .").concat(this.controller, " .resize.show {\n background-color: #6924d5;\n }\n .").concat(this.controller, " .resize > .circle {\n background-color: #f0f0f0a8;\n position: absolute;\n top: -15px;\n left: -15px;\n width: 50px;\n height: 50px;\n border-radius: 50%;\n box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;\n z-index: -1;\n visibility: hidden;\n transition: all .1s linear;\n }\n .").concat(this.controller, " .resize > .circle.show {\n visibility: visible;\n }\n .").concat(this.controller, " .resize.resize-topleft {\n position: absolute;\n top: -10px;\n left: -10px;\n }\n .").concat(this.controller, " .resize.resize-topright {\n position: absolute;\n top: -10px;\n right: -10px;\n }\n .").concat(this.controller, " .resize.resize-bottomleft {\n position: absolute;\n bottom: -10px;\n left: -10px;\n }\n .").concat(this.controller, " .resize.resize-bottomright {\n position: absolute;\n bottom: -10px;\n right: -10px;\n }\n .").concat(this.controller, " .rotate {\n position: absolute;\n top: -50px;\n left: calc(50% - 15px);\n width: 30px;\n height: 30px;\n background-color: #fff;\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .").concat(this.controller, " .delete {\n position: absolute;\n bottom: -50px;\n left: calc(50% + 40px);\n width: 30px;\n height: 30px;\n background-color: #fff;\n border-radius: 50%;\n display: none;\n justify-content: center;\n align-items: center;\n }\n ");
2464
+ }
2465
+ },
2466
+ {
2467
+ key: "controllerTemplate",
2468
+ value: function controllerTemplate() {
2469
+ return '\n <div class="'.concat(this.controller, '--container">\n <div class="').concat(this.controller, '">\n <div class="dot resize resize-topleft"><div class="circle"></div></div>\n <div class="dot resize resize-topright"><div class="circle"></div></div>\n <div class="dot resize resize-bottomleft"><div class="circle"></div></div>\n <div class="dot resize resize-bottomright"><div class="circle"></div></div>\n <div class="dot rotate">').concat(icon(faRotate).html[0], '</div>\n <div class="dot rotate shadow" style="visibility: hidden;">').concat(icon(faRotate).html[0], '</div>\n <div class="dot delete">').concat(icon(faTrash).html[0], '</div>\n <div class="dot delete shadow" style="visibility: hidden;">').concat(icon(faTrash).html[0], "</div>\n </div>\n </div>\n ");
2470
+ }
2471
+ }
2472
+ ]);
2473
+ return TransformController;
2474
+ }();
2475
+ // src/utilities/Transform/Transform.ts
2476
+ var Transform = /*#__PURE__*/ function() {
2477
+ "use strict";
2478
+ function Transform(ele1, ele2, ele3) {
2479
+ _class_call_check(this, Transform);
2480
+ this.ele1 = ele1;
2481
+ this.ele2 = ele2;
2482
+ this.x = 0;
2483
+ this.y = 0;
2484
+ this.angle = 90;
2485
+ this.w = 0;
2486
+ this.h = 0;
2487
+ if (this.ele1 === null) {
2488
+ throw new Error("wrapper elemenet is not defined or not rendered yet");
2489
+ }
2490
+ this.wrapperClass = "_" + (Date.now() + 5e3).toString();
2491
+ $2(this.ele1).addClass(this.wrapperClass);
2492
+ this.imgFrame = this.ele2;
2493
+ if (this.imgFrame === null) {
2494
+ throw new Error("frame element is not defined or not rendered yet");
2495
+ }
2496
+ this.frameClass = "_" + (Date.now() - 5e3).toString();
2497
+ $2(this.ele2).addClass(this.frameClass);
2498
+ this.img = this.ele1.querySelector("img");
2499
+ if (this.img === null) {
2500
+ throw new Error("image element is not defined or not rendered yet");
2501
+ }
2502
+ this.ratio = this.img.clientWidth / this.img.clientHeight;
2503
+ this.controllerClassName = "_" + Date.now().toString();
2504
+ this.isRotateOffScreen = false;
2505
+ }
2506
+ _create_class(Transform, [
2507
+ {
2508
+ key: "initialize",
2509
+ value: function initialize() {
2510
+ return _async_to_generator(function() {
2511
+ var transformController;
2512
+ return _ts_generator(this, function(_state) {
2513
+ switch(_state.label){
2514
+ case 0:
2515
+ transformController = new TransformController(this.wrapperClass, this.frameClass, this.controllerClassName);
2516
+ return [
2517
+ 4,
2518
+ transformController.addController()
2519
+ ];
2520
+ case 1:
2521
+ _state.sent();
2522
+ this.controllerContainer = document.querySelector("." + this.controllerClassName + "--container");
2523
+ this.controller = document.querySelector("." + this.controllerClassName);
2524
+ this.handleElementGoOffScreen("." + this.controllerClassName + " .rotate", "." + this.controllerClassName + " .rotate.shadow", "rotate").handleElementGoOffScreen("." + this.controllerClassName + " .delete", "." + this.controllerClassName + " .delete.shadow", "delete").transform();
2525
+ return [
2526
+ 2
2527
+ ];
2528
+ }
2529
+ });
2530
+ }).call(this);
2531
+ }
2532
+ },
2533
+ {
2534
+ key: "reset",
2535
+ value: function reset() {
2536
+ this.setState({
2537
+ x: 0,
2538
+ y: this.imgFrame.clientHeight / 2 - this.img.height / 2,
2539
+ angle: 0,
2540
+ w: this.imgFrame.clientWidth
2541
+ });
2542
+ }
2543
+ },
2544
+ {
2545
+ key: "setState",
2546
+ value: function setState(param) {
2547
+ var x = param.x, y = param.y, angle = param.angle, w = param.w;
2548
+ this.repositionElement(x + this.imgFrame.clientWidth / 2, y + this.img.height / 2);
2549
+ this.rotateBox(angle);
2550
+ this.resize(w, w / this.ratio);
2551
+ this.setValue(x, y, angle, w, w / this.ratio);
2552
+ }
2553
+ },
2554
+ {
2555
+ key: "setValue",
2556
+ value: function setValue(x, y, angle, w, h) {
2557
+ this.x = x !== void 0 ? x : this.x;
2558
+ this.y = y !== void 0 ? y : this.y;
2559
+ this.angle = angle !== void 0 ? angle : this.angle;
2560
+ this.w = w !== void 0 ? w : this.w;
2561
+ this.h = h !== void 0 ? h : this.h;
2562
+ }
2563
+ },
2564
+ {
2565
+ key: "exportData",
2566
+ value: function exportData() {
2567
+ return {
2568
+ x: this.x,
2569
+ y: this.y,
2570
+ angle: this.angle,
2571
+ w: this.w,
2572
+ h: this.h
2573
+ };
2574
+ }
2575
+ },
2576
+ {
2577
+ key: "repositionElement",
2578
+ value: function repositionElement(x, y) {
2579
+ var controllerWrapper = this.controllerContainer;
2580
+ var boxWrapper = this.ele1;
2581
+ boxWrapper.style.left = x + "px";
2582
+ boxWrapper.style.top = y + "px";
2583
+ controllerWrapper.style.left = x + this.imgFrame.offsetLeft + 3 + "px";
2584
+ controllerWrapper.style.top = y + this.imgFrame.offsetTop + 3 + "px";
2585
+ }
2586
+ },
2587
+ {
2588
+ key: "resize",
2589
+ value: function resize(w, h) {
2590
+ var controller = this.controller;
2591
+ var img = this.img;
2592
+ var wrapper = this.ele1;
2593
+ controller.style.width = w + "px";
2594
+ controller.style.height = h + "px";
2595
+ img.style.width = w + "px";
2596
+ wrapper.style.width = w + "px";
2597
+ }
2598
+ },
2599
+ {
2600
+ key: "rotateBox",
2601
+ value: function rotateBox(deg) {
2602
+ var controllerWrapper = this.controllerContainer;
2603
+ var boxWrapper = this.ele1;
2604
+ boxWrapper.style.transform = "rotate(".concat(deg, "deg)");
2605
+ controllerWrapper.style.rotate = "".concat(deg, "deg");
2606
+ }
2607
+ },
2608
+ {
2609
+ key: "handleElementGoOffScreen",
2610
+ value: function handleElementGoOffScreen(main, shadow, type) {
2611
+ var _this = this;
2612
+ var mainEle = document.querySelector(main);
2613
+ var shadowEle = document.querySelector(shadow);
2614
+ var options = {
2615
+ root: null,
2616
+ rootMargin: "0px",
2617
+ threshold: 0.1
2618
+ };
2619
+ var callback = function(entries) {
2620
+ entries.forEach(function(entry) {
2621
+ switch(type){
2622
+ case "rotate":
2623
+ if (!entry.isIntersecting) {
2624
+ mainEle.style.top = "auto";
2625
+ mainEle.style.bottom = "-50px";
2626
+ _this.isRotateOffScreen = true;
2627
+ } else {
2628
+ mainEle.style.bottom = "auto";
2629
+ mainEle.style.top = "-50px";
2630
+ _this.isRotateOffScreen = false;
2631
+ }
2632
+ break;
2633
+ case "delete":
2634
+ if (!entry.isIntersecting) {
2635
+ mainEle.style.bottom = "auto";
2636
+ mainEle.style.top = "-50px";
2637
+ } else {
2638
+ mainEle.style.top = "auto";
2639
+ mainEle.style.bottom = "-50px";
2640
+ }
2641
+ break;
2642
+ }
2643
+ });
2644
+ };
2645
+ var observer = new IntersectionObserver(callback, options);
2646
+ observer.observe(shadowEle);
2647
+ return this;
2648
+ }
2649
+ },
2650
+ {
2651
+ key: "transform",
2652
+ value: function transform() {
2653
+ var _this = this;
2654
+ var _this1 = this;
2655
+ var controllerWrapper = this.controllerContainer;
2656
+ var boxWrapper = this.ele1;
2657
+ var minWidth = 40;
2658
+ var minHeight = 40;
2659
+ var initX, initY, mousePressX, mousePressY, initW, initH, initRotate;
2660
+ function getCurrentRotation(el) {
2661
+ var st = window.getComputedStyle(el, null);
2662
+ var tm = st.getPropertyValue("-webkit-transform") || st.getPropertyValue("-moz-transform") || st.getPropertyValue("-ms-transform") || st.getPropertyValue("-o-transform") || st.getPropertyValue("transform");
2663
+ "none";
2664
+ if (tm != "none") {
2665
+ var values = tm.split("(")[1].split(")")[0].split(",");
2666
+ var angle = Math.round(Math.atan2(Number(values[1]), Number(values[0])) * (180 / Math.PI));
2667
+ return angle < 0 ? angle + 360 : angle;
2668
+ }
2669
+ return 0;
2670
+ }
2671
+ function mousedownCb(event) {
2672
+ event.target.classList.add("show");
2673
+ event.target.querySelector(".circle").classList.add("show");
2674
+ }
2675
+ function mouseupCb(event) {
2676
+ event.target.classList.remove("show");
2677
+ event.target.querySelector(".circle").classList.remove("show");
2678
+ }
2679
+ var handleDrag = function(event, type) {
2680
+ event.stopPropagation();
2681
+ var initX2 = boxWrapper.offsetLeft;
2682
+ var initY2 = boxWrapper.offsetTop;
2683
+ var mousePressX2 = type === "desk" ? event.clientX : event.touches[0].clientX;
2684
+ var mousePressY2 = type === "desk" ? event.clientY : event.touches[0].clientY;
2685
+ var _this_exportData = _this.exportData(), w = _this_exportData.w, h = _this_exportData.h;
2686
+ var eventMoveHandler = function(event2) {
2687
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2688
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2689
+ var posX = initX2 + (x - mousePressX2);
2690
+ var posY = initY2 + (y - mousePressY2);
2691
+ _this.repositionElement(posX, posY);
2692
+ _this.setValue(posX - w / 2, posY - h / 2, void 0, void 0, void 0);
2693
+ };
2694
+ if (type === "desk") {
2695
+ controllerWrapper.addEventListener("mousemove", eventMoveHandler, false);
2696
+ window.addEventListener("mouseup", function eventEndHandler() {
2697
+ controllerWrapper.removeEventListener("mousemove", eventMoveHandler, false);
2698
+ window.removeEventListener("mouseup", eventEndHandler);
2699
+ }, false);
2700
+ } else {
2701
+ controllerWrapper.addEventListener("touchmove", eventMoveHandler, {
2702
+ passive: true
2703
+ });
2704
+ window.addEventListener("touchend", function eventEndHandler() {
2705
+ controllerWrapper.removeEventListener("touchmove", eventMoveHandler);
2706
+ window.removeEventListener("touchend", eventEndHandler);
2707
+ }, false);
2708
+ }
2709
+ };
2710
+ controllerWrapper.addEventListener("mousedown", function(e) {
2711
+ return handleDrag(e, "desk");
2712
+ }, false);
2713
+ controllerWrapper.addEventListener("touchstart", function(e) {
2714
+ return handleDrag(e, "touch");
2715
+ }, {
2716
+ passive: true
2717
+ });
2718
+ var leftTop = document.querySelector("." + this.controllerClassName + " .resize-topleft");
2719
+ var rightTop = document.querySelector("." + this.controllerClassName + " .resize-topright");
2720
+ var rightBottom = document.querySelector("." + this.controllerClassName + " .resize-bottomright");
2721
+ var leftBottom = document.querySelector("." + this.controllerClassName + " .resize-bottomleft");
2722
+ var resizeHandler = function(event) {
2723
+ var left = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, top = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false, xResize = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, yResize = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false, type = arguments.length > 5 ? arguments[5] : void 0;
2724
+ event.stopPropagation();
2725
+ initX = boxWrapper.offsetLeft;
2726
+ initY = boxWrapper.offsetTop;
2727
+ mousePressX = type === "desk" ? event.clientX : event.touches[0].clientX;
2728
+ mousePressY = type === "desk" ? event.clientY : event.touches[0].clientY;
2729
+ initW = _this1.img.offsetWidth;
2730
+ initH = _this1.img.offsetHeight;
2731
+ initRotate = getCurrentRotation(boxWrapper);
2732
+ var initRadians = initRotate * Math.PI / 180;
2733
+ var cosFraction = Math.cos(initRadians);
2734
+ var sinFraction = Math.sin(initRadians);
2735
+ mousedownCb(event);
2736
+ var vectorC = [
2737
+ mousePressX - initX - _this1.imgFrame.offsetLeft,
2738
+ mousePressY - initY - _this1.imgFrame.offsetTop
2739
+ ];
2740
+ var eventMoveHandler = function(event2) {
2741
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2742
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2743
+ var wDiff = x - mousePressX;
2744
+ var hDiff = y - mousePressY;
2745
+ var vectorD = [
2746
+ wDiff,
2747
+ hDiff
2748
+ ];
2749
+ var c = (vectorC[0] * vectorD[0] + vectorC[1] * vectorD[1]) / (vectorC[0] * vectorC[0] + vectorC[1] * vectorC[1]);
2750
+ var vectorH = [
2751
+ c * vectorC[0],
2752
+ c * vectorC[1]
2753
+ ];
2754
+ var rotatedWDiff = cosFraction * vectorH[0] + sinFraction * vectorH[1];
2755
+ var rotatedHDiff = cosFraction * vectorH[1] - sinFraction * vectorH[0];
2756
+ rotatedHDiff = rotatedHDiff * rotatedWDiff > 0 ? rotatedWDiff / _this1.ratio : -rotatedWDiff / _this1.ratio;
2757
+ var newW = initW, newH = initH, newX = initX, newY = initY;
2758
+ if (xResize) {
2759
+ if (left) {
2760
+ newW = initW - rotatedWDiff;
2761
+ if (newW < minWidth) {
2762
+ newW = minWidth;
2763
+ rotatedWDiff = initW - minWidth;
2764
+ }
2765
+ } else {
2766
+ newW = initW + rotatedWDiff;
2767
+ if (newW < minWidth) {
2768
+ newW = minWidth;
2769
+ rotatedWDiff = minWidth - initW;
2770
+ }
2771
+ }
2772
+ newX += 0.5 * rotatedWDiff * cosFraction;
2773
+ newY += 0.5 * rotatedWDiff * sinFraction;
2774
+ }
2775
+ if (yResize) {
2776
+ if (top) {
2777
+ newH = initH - rotatedHDiff;
2778
+ if (newH < minHeight) {
2779
+ newH = minHeight;
2780
+ rotatedHDiff = initH - minHeight;
2781
+ }
2782
+ } else {
2783
+ newH = initH + rotatedHDiff;
2784
+ if (newH < minHeight) {
2785
+ newH = minHeight;
2786
+ rotatedHDiff = minHeight - initH;
2787
+ }
2788
+ }
2789
+ newX -= 0.5 * rotatedHDiff * sinFraction;
2790
+ newY += 0.5 * rotatedHDiff * cosFraction;
2791
+ }
2792
+ _this1.resize(newW, newH);
2793
+ _this1.repositionElement(newX, newY);
2794
+ _this1.setValue(newX - newW / 2, newY - newH / 2, void 0, newW, newH);
2795
+ };
2796
+ if (type === "desk") {
2797
+ window.addEventListener("mousemove", eventMoveHandler, false);
2798
+ window.addEventListener("mouseup", function eventEndHandler() {
2799
+ mouseupCb(event);
2800
+ window.removeEventListener("mousemove", eventMoveHandler, false);
2801
+ window.removeEventListener("mouseup", eventEndHandler);
2802
+ }, false);
2803
+ } else {
2804
+ window.addEventListener("touchmove", eventMoveHandler, {
2805
+ passive: true
2806
+ });
2807
+ window.addEventListener("touchend", function eventEndHandler() {
2808
+ mouseupCb(event);
2809
+ window.removeEventListener("touchmove", eventMoveHandler, false);
2810
+ window.removeEventListener("touchend", eventEndHandler);
2811
+ }, false);
2812
+ }
2813
+ };
2814
+ leftTop.addEventListener("mousedown", function(e) {
2815
+ return resizeHandler(e, true, true, true, true, "desk");
2816
+ });
2817
+ rightTop.addEventListener("mousedown", function(e) {
2818
+ return resizeHandler(e, false, true, true, true, "desk");
2819
+ });
2820
+ rightBottom.addEventListener("mousedown", function(e) {
2821
+ return resizeHandler(e, false, false, true, true, "desk");
2822
+ });
2823
+ leftBottom.addEventListener("mousedown", function(e) {
2824
+ return resizeHandler(e, true, false, true, true, "desk");
2825
+ });
2826
+ leftTop.addEventListener("touchstart", function(e) {
2827
+ return resizeHandler(e, true, true, true, true, "touch");
2828
+ }, {
2829
+ passive: true
2830
+ });
2831
+ rightTop.addEventListener("touchstart", function(e) {
2832
+ return resizeHandler(e, false, true, true, true, "touch");
2833
+ }, {
2834
+ passive: true
2835
+ });
2836
+ rightBottom.addEventListener("touchstart", function(e) {
2837
+ return resizeHandler(e, false, false, true, true, "touch");
2838
+ }, {
2839
+ passive: true
2840
+ });
2841
+ leftBottom.addEventListener("touchstart", function(e) {
2842
+ return resizeHandler(e, true, false, true, true, "touch");
2843
+ }, {
2844
+ passive: true
2845
+ });
2846
+ var rotate = document.querySelector("." + this.controllerClassName + " .rotate");
2847
+ var handleRotate = function(event, type) {
2848
+ event.stopPropagation();
2849
+ initX = event.target.offsetLeft;
2850
+ initY = event.target.offsetTop;
2851
+ mousePressX = type === "desk" ? event.clientX : event.touches[0].clientX;
2852
+ mousePressY = type === "desk" ? event.clientY : event.touches[0].clientY;
2853
+ var arrow = _this.controller;
2854
+ var arrowRects = arrow.getBoundingClientRect();
2855
+ var arrowX = arrowRects.left + arrowRects.width / 2;
2856
+ var arrowY = arrowRects.top + arrowRects.height / 2;
2857
+ var compensation = _this.isRotateOffScreen ? 180 : 0;
2858
+ var eventMoveHandler = function(event2) {
2859
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2860
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2861
+ var angle = Math.atan2(y - arrowY, x - arrowX) + Math.PI / 2;
2862
+ angle *= 180 / Math.PI;
2863
+ angle += compensation;
2864
+ _this.rotateBox(angle);
2865
+ _this.setValue(void 0, void 0, angle, void 0, void 0);
2866
+ };
2867
+ if (type === "desk") {
2868
+ window.addEventListener("mousemove", eventMoveHandler, false);
2869
+ window.addEventListener("mouseup", function eventEndHandler() {
2870
+ window.removeEventListener("mousemove", eventMoveHandler, false);
2871
+ window.removeEventListener("mouseup", eventEndHandler);
2872
+ }, false);
2873
+ } else {
2874
+ window.addEventListener("touchmove", eventMoveHandler, {
2875
+ passive: true
2876
+ });
2877
+ window.addEventListener("touchend", function eventEndHandler() {
2878
+ window.removeEventListener("touchmove", eventMoveHandler, false);
2879
+ window.removeEventListener("touchend", eventEndHandler);
2880
+ }, false);
2881
+ }
2882
+ };
2883
+ rotate.addEventListener("mousedown", function(e) {
2884
+ return handleRotate(e, "desk");
2885
+ }, false);
2886
+ rotate.addEventListener("touchstart", function(e) {
2887
+ return handleRotate(e, "touch");
2888
+ }, {
2889
+ passive: true
2890
+ });
2891
+ this.reset();
2892
+ return this;
2893
+ }
2894
+ }
2895
+ ]);
2896
+ return Transform;
2897
+ }();
2898
+ export { Avatar_default as Avatar, Button_default as Button, Canvas, ColorPickerSlider_default as ColorPickerSlider, DropdownSelect_default as DropdownSelect, Image_default as Image, ImageEditor_default as ImageEditor, Image_default2 as ImageUtilities, InputFile_default as InputFile, InputGoogle_default as InputGoogle, MultiSelect_default as MultiSelect, OptionSlider_default as OptionSlider, RangeSlider_default as RangeSlider, TextArea_default as TextArea, Transform, UploadImage_default as UploadImage };