@willphan1712000/frontend 1.0.2 → 1.1.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.js 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] : {};
@@ -95,6 +161,33 @@ function _object_spread_props(target, source) {
95
161
  }
96
162
  return target;
97
163
  }
164
+ function _object_without_properties(source, excluded) {
165
+ if (source == null) return {};
166
+ var target = _object_without_properties_loose(source, excluded);
167
+ var key, i;
168
+ if (Object.getOwnPropertySymbols) {
169
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
170
+ for(i = 0; i < sourceSymbolKeys.length; i++){
171
+ key = sourceSymbolKeys[i];
172
+ if (excluded.indexOf(key) >= 0) continue;
173
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
174
+ target[key] = source[key];
175
+ }
176
+ }
177
+ return target;
178
+ }
179
+ function _object_without_properties_loose(source, excluded) {
180
+ if (source == null) return {};
181
+ var target = {};
182
+ var sourceKeys = Object.keys(source);
183
+ var key, i;
184
+ for(i = 0; i < sourceKeys.length; i++){
185
+ key = sourceKeys[i];
186
+ if (excluded.indexOf(key) >= 0) continue;
187
+ target[key] = source[key];
188
+ }
189
+ return target;
190
+ }
98
191
  function _sliced_to_array(arr, i) {
99
192
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
100
193
  }
@@ -113,9 +206,102 @@ function _unsupported_iterable_to_array(o, minLen) {
113
206
  if (n === "Map" || n === "Set") return Array.from(n);
114
207
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
115
208
  }
209
+ function _ts_generator(thisArg, body) {
210
+ var f, y, t, _ = {
211
+ label: 0,
212
+ sent: function() {
213
+ if (t[0] & 1) throw t[1];
214
+ return t[1];
215
+ },
216
+ trys: [],
217
+ ops: []
218
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
219
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
220
+ return this;
221
+ }), g;
222
+ function verb(n) {
223
+ return function(v) {
224
+ return step([
225
+ n,
226
+ v
227
+ ]);
228
+ };
229
+ }
230
+ function step(op) {
231
+ if (f) throw new TypeError("Generator is already executing.");
232
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
233
+ 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;
234
+ if (y = 0, t) op = [
235
+ op[0] & 2,
236
+ t.value
237
+ ];
238
+ switch(op[0]){
239
+ case 0:
240
+ case 1:
241
+ t = op;
242
+ break;
243
+ case 4:
244
+ _.label++;
245
+ return {
246
+ value: op[1],
247
+ done: false
248
+ };
249
+ case 5:
250
+ _.label++;
251
+ y = op[1];
252
+ op = [
253
+ 0
254
+ ];
255
+ continue;
256
+ case 7:
257
+ op = _.ops.pop();
258
+ _.trys.pop();
259
+ continue;
260
+ default:
261
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
262
+ _ = 0;
263
+ continue;
264
+ }
265
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
266
+ _.label = op[1];
267
+ break;
268
+ }
269
+ if (op[0] === 6 && _.label < t[1]) {
270
+ _.label = t[1];
271
+ t = op;
272
+ break;
273
+ }
274
+ if (t && _.label < t[2]) {
275
+ _.label = t[2];
276
+ _.ops.push(op);
277
+ break;
278
+ }
279
+ if (t[2]) _.ops.pop();
280
+ _.trys.pop();
281
+ continue;
282
+ }
283
+ op = body.call(thisArg, _);
284
+ } catch (e) {
285
+ op = [
286
+ 6,
287
+ e
288
+ ];
289
+ y = 0;
290
+ } finally{
291
+ f = t = 0;
292
+ }
293
+ if (op[0] & 5) throw op[1];
294
+ return {
295
+ value: op[0] ? op[1] : void 0,
296
+ done: true
297
+ };
298
+ }
299
+ }
300
+ var __create = Object.create;
116
301
  var __defProp = Object.defineProperty;
117
302
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
118
303
  var __getOwnPropNames = Object.getOwnPropertyNames;
304
+ var __getProtoOf = Object.getPrototypeOf;
119
305
  var __hasOwnProp = Object.prototype.hasOwnProperty;
120
306
  var __export = function(target, all) {
121
307
  for(var name in all)__defProp(target, name, {
@@ -154,6 +340,16 @@ var __copyProps = function(to, from, except, desc) {
154
340
  }
155
341
  return to;
156
342
  };
343
+ var __toESM = function(mod, isNodeMode, target) {
344
+ return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
345
+ // file that has been converted to a CommonJS file using a Babel-
346
+ // compatible transform (i.e. "__esModule" has not been set), then set
347
+ // "default" to the CommonJS "module.exports" for node compatibility.
348
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
349
+ value: mod,
350
+ enumerable: true
351
+ }) : target, mod);
352
+ };
157
353
  var __toCommonJS = function(mod) {
158
354
  return __copyProps(__defProp({}, "__esModule", {
159
355
  value: true
@@ -162,12 +358,36 @@ var __toCommonJS = function(mod) {
162
358
  // index.ts
163
359
  var index_exports = {};
164
360
  __export(index_exports, {
361
+ Avatar: function() {
362
+ return Avatar_default;
363
+ },
364
+ Button: function() {
365
+ return Button_default;
366
+ },
367
+ Canvas: function() {
368
+ return Canvas;
369
+ },
165
370
  ColorPickerSlider: function() {
166
371
  return ColorPickerSlider_default;
167
372
  },
168
373
  DropdownSelect: function() {
169
374
  return DropdownSelect_default;
170
375
  },
376
+ Image: function() {
377
+ return Image_default;
378
+ },
379
+ ImageEditor: function() {
380
+ return ImageEditor_default;
381
+ },
382
+ ImageUtilities: function() {
383
+ return Image_default2;
384
+ },
385
+ InputFile: function() {
386
+ return InputFile_default;
387
+ },
388
+ InputGoogle: function() {
389
+ return InputGoogle_default;
390
+ },
171
391
  MultiSelect: function() {
172
392
  return MultiSelect_default;
173
393
  },
@@ -176,6 +396,15 @@ __export(index_exports, {
176
396
  },
177
397
  RangeSlider: function() {
178
398
  return RangeSlider_default;
399
+ },
400
+ TextArea: function() {
401
+ return TextArea_default;
402
+ },
403
+ Transform: function() {
404
+ return Transform;
405
+ },
406
+ UploadImage: function() {
407
+ return UploadImage_default;
179
408
  }
180
409
  });
181
410
  module.exports = __toCommonJS(index_exports);
@@ -1021,7 +1250,7 @@ var Search2 = function(param) {
1021
1250
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
1022
1251
  style: styles_default5.search_border,
1023
1252
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", {
1024
- placeholder: "Search",
1253
+ placeholder: "Search...",
1025
1254
  style: styles_default5.search,
1026
1255
  id: "search",
1027
1256
  name: "search",
@@ -1206,11 +1435,1594 @@ var MultiSelect = function(param) {
1206
1435
  });
1207
1436
  };
1208
1437
  var MultiSelect_default = MultiSelect;
1438
+ // src/components/Buttons/Button.tsx
1439
+ var import_react9 = require("react");
1440
+ // src/components/Buttons/gradient/Gradient.tsx
1441
+ var import_framer_motion = require("framer-motion");
1442
+ // src/components/Buttons/gradient/styles.ts
1443
+ var borderRadius = "20px";
1444
+ var styles6 = function(first, second) {
1445
+ var styles11 = {
1446
+ container: {
1447
+ position: "relative",
1448
+ borderRadius: borderRadius,
1449
+ padding: "3px"
1450
+ },
1451
+ btn: {
1452
+ position: "relative",
1453
+ zIndex: 1,
1454
+ display: "flex",
1455
+ justifyContent: "center",
1456
+ alignItems: "center",
1457
+ padding: "2px",
1458
+ borderRadius: borderRadius,
1459
+ backgroundColor: "".concat(first),
1460
+ backgroundImage: "linear-gradient(43deg, ".concat(first, " 0%, ").concat(second, " 100%)"),
1461
+ border: "none",
1462
+ cursor: "pointer"
1463
+ },
1464
+ btnAfter: {
1465
+ position: "absolute",
1466
+ top: 0,
1467
+ left: 0,
1468
+ width: "100%",
1469
+ height: "100%",
1470
+ content: '""',
1471
+ zIndex: 0,
1472
+ backgroundColor: "".concat(first),
1473
+ backgroundImage: "linear-gradient(43deg, ".concat(first, " 0%, ").concat(second, " 100%)"),
1474
+ filter: "blur(10px)"
1475
+ },
1476
+ label: {
1477
+ backgroundColor: "#111723",
1478
+ borderRadius: borderRadius,
1479
+ padding: "0.5rem 2rem",
1480
+ color: "white"
1481
+ },
1482
+ labelBefore: {
1483
+ position: "absolute",
1484
+ top: "20%",
1485
+ right: "50%",
1486
+ width: "50%",
1487
+ height: "50%",
1488
+ content: '""',
1489
+ zIndex: 0,
1490
+ backgroundColor: "".concat(first),
1491
+ filter: "blur(15px)"
1492
+ },
1493
+ labelAfter: {
1494
+ position: "absolute",
1495
+ top: "20%",
1496
+ left: "50%",
1497
+ width: "50%",
1498
+ height: "50%",
1499
+ content: '""',
1500
+ zIndex: 0,
1501
+ backgroundColor: "".concat(second),
1502
+ filter: "blur(20px)"
1503
+ },
1504
+ p: {
1505
+ position: "relative",
1506
+ zIndex: 1,
1507
+ margin: 0
1508
+ },
1509
+ neon: {
1510
+ content: '""',
1511
+ background: "conic-gradient(transparent 270deg, green, transparent)",
1512
+ position: "absolute",
1513
+ top: "50%",
1514
+ left: "50%",
1515
+ transform: "translate(-50%, -50%)",
1516
+ aspectRatio: 1,
1517
+ width: "100%"
1518
+ }
1519
+ };
1520
+ return styles11;
1521
+ };
1522
+ var styles_default6 = styles6;
1523
+ // src/components/Buttons/gradient/Gradient.tsx
1524
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1525
+ var Gradient = function() {
1526
+ var data = useButtonContext();
1527
+ var styles11 = styles_default6(data.first, data.second);
1528
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", {
1529
+ style: _object_spread_props(_object_spread({}, styles11.container), {
1530
+ overflow: data.isLoading ? "hidden" : ""
1531
+ }),
1532
+ children: [
1533
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", _object_spread_props(_object_spread({
1534
+ style: styles11.btn
1535
+ }, data.props), {
1536
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", {
1537
+ style: {
1538
+ position: "relative"
1539
+ },
1540
+ children: [
1541
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {
1542
+ style: styles11.labelBefore
1543
+ }),
1544
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {
1545
+ style: _object_spread_props(_object_spread({}, styles11.label), {
1546
+ backgroundColor: data.main
1547
+ }),
1548
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", {
1549
+ style: _object_spread_props(_object_spread({}, styles11.p), {
1550
+ color: "".concat(data.text)
1551
+ }),
1552
+ children: [
1553
+ data.children,
1554
+ " ",
1555
+ data.content
1556
+ ]
1557
+ })
1558
+ }),
1559
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {
1560
+ style: styles11.labelAfter
1561
+ })
1562
+ ]
1563
+ })
1564
+ })),
1565
+ !data.isLoading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {
1566
+ style: styles11.btnAfter
1567
+ }),
1568
+ data.isLoading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_framer_motion.motion.div, {
1569
+ style: styles11.btnAfter,
1570
+ animate: {
1571
+ rotate: 360
1572
+ },
1573
+ transition: {
1574
+ ease: "linear",
1575
+ repeat: Infinity,
1576
+ duration: 3
1577
+ }
1578
+ })
1579
+ ]
1580
+ });
1581
+ };
1582
+ var Gradient_default = Gradient;
1583
+ // src/components/Buttons/solid/styles.ts
1584
+ var styles7 = function(first) {
1585
+ var styles11 = {
1586
+ btn: {
1587
+ cursor: "pointer",
1588
+ position: "relative",
1589
+ zIndex: 0,
1590
+ display: "flex",
1591
+ justifyContent: "center",
1592
+ alignItems: "center",
1593
+ padding: "2px",
1594
+ borderRadius: "0.75rem",
1595
+ backgroundColor: first,
1596
+ border: "none"
1597
+ },
1598
+ btnAfter: {
1599
+ position: "absolute",
1600
+ top: 0,
1601
+ left: 0,
1602
+ width: "100%",
1603
+ height: "100%",
1604
+ zIndex: -1,
1605
+ backgroundColor: first,
1606
+ filter: "blur(10px)"
1607
+ },
1608
+ label: {
1609
+ borderRadius: "0.75rem",
1610
+ padding: "0.5rem 2rem",
1611
+ color: "white"
1612
+ },
1613
+ labelBefore: {
1614
+ position: "absolute",
1615
+ top: "20%",
1616
+ right: "50%",
1617
+ width: "50%",
1618
+ height: "50%",
1619
+ content: '""',
1620
+ // See note below
1621
+ zIndex: 0,
1622
+ backgroundColor: first,
1623
+ filter: "blur(15px)"
1624
+ },
1625
+ labelAfter: {
1626
+ position: "absolute",
1627
+ top: "20%",
1628
+ left: "50%",
1629
+ width: "50%",
1630
+ height: "50%",
1631
+ content: '""',
1632
+ // See note below
1633
+ zIndex: 0,
1634
+ filter: "blur(20px)"
1635
+ },
1636
+ p: {
1637
+ zIndex: 1,
1638
+ position: "relative",
1639
+ margin: 0
1640
+ }
1641
+ };
1642
+ return styles11;
1643
+ };
1644
+ var styles_default7 = styles7;
1645
+ // src/components/Buttons/solid/Solid.tsx
1646
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1647
+ var Solid = function() {
1648
+ var data = useButtonContext();
1649
+ var styles11 = styles_default7(data.first);
1650
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
1651
+ style: {
1652
+ position: "relative"
1653
+ },
1654
+ children: [
1655
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", _object_spread_props(_object_spread({
1656
+ style: styles11.btn
1657
+ }, data.props), {
1658
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
1659
+ style: {
1660
+ position: "relative"
1661
+ },
1662
+ children: [
1663
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
1664
+ style: styles11.labelBefore
1665
+ }),
1666
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
1667
+ style: _object_spread_props(_object_spread({}, styles11.label), {
1668
+ backgroundColor: data.main
1669
+ }),
1670
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", {
1671
+ style: _object_spread_props(_object_spread({}, styles11.p), {
1672
+ color: "".concat(data.text)
1673
+ }),
1674
+ children: [
1675
+ data.children,
1676
+ " ",
1677
+ data.content
1678
+ ]
1679
+ })
1680
+ }),
1681
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
1682
+ style: styles11.labelAfter
1683
+ })
1684
+ ]
1685
+ })
1686
+ })),
1687
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {
1688
+ style: styles11.btnAfter
1689
+ })
1690
+ ]
1691
+ });
1692
+ };
1693
+ var Solid_default = Solid;
1694
+ // src/components/Buttons/Button.tsx
1695
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1696
+ var ButtonContext = (0, import_react9.createContext)(void 0);
1697
+ function useButtonContext() {
1698
+ var data = (0, import_react9.useContext)(ButtonContext);
1699
+ if (data === void 0) {
1700
+ throw new Error("Select Context is undefined");
1701
+ }
1702
+ return data;
1703
+ }
1704
+ var Button = function(_param) {
1705
+ 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, [
1706
+ "buttonType",
1707
+ "content",
1708
+ "main",
1709
+ "first",
1710
+ "second",
1711
+ "text",
1712
+ "isLoading",
1713
+ "children"
1714
+ ]);
1715
+ switch(buttonType){
1716
+ case "gradient":
1717
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ButtonContext.Provider, {
1718
+ value: {
1719
+ content: content,
1720
+ main: main,
1721
+ first: first,
1722
+ second: second,
1723
+ text: text,
1724
+ props: props,
1725
+ isLoading: isLoading,
1726
+ children: children
1727
+ },
1728
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Gradient_default, {})
1729
+ });
1730
+ case "solid":
1731
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ButtonContext.Provider, {
1732
+ value: {
1733
+ content: content,
1734
+ main: main,
1735
+ first: first,
1736
+ text: text,
1737
+ props: props,
1738
+ isLoading: isLoading,
1739
+ children: children
1740
+ },
1741
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Solid_default, {})
1742
+ });
1743
+ default:
1744
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", _object_spread_props(_object_spread({}, props), {
1745
+ children: [
1746
+ children,
1747
+ " ",
1748
+ content
1749
+ ]
1750
+ }));
1751
+ }
1752
+ };
1753
+ var Button_default = Button;
1754
+ // src/components/Avatar/Avatar.tsx
1755
+ var import_io5 = require("react-icons/io5");
1756
+ var import_fa6 = require("react-icons/fa6");
1757
+ var import_ri = require("react-icons/ri");
1758
+ // src/components/Avatar/styles.ts
1759
+ var others = {
1760
+ iconSize: "20"
1761
+ };
1762
+ var button = {
1763
+ fontSize: "0.8rem",
1764
+ border: "none",
1765
+ borderRadius: "15px",
1766
+ padding: "3%",
1767
+ display: "flex",
1768
+ gap: "5px",
1769
+ justifyContent: "center",
1770
+ alignItems: "center",
1771
+ cursor: "pointer",
1772
+ position: "absolute"
1773
+ };
1774
+ var styles8 = {
1775
+ container: {
1776
+ width: "100%",
1777
+ height: "100%",
1778
+ display: "flex",
1779
+ position: "relative"
1780
+ },
1781
+ image: {
1782
+ borderRadius: "50%",
1783
+ background: "white",
1784
+ objectFit: "cover",
1785
+ width: "100%",
1786
+ height: "100%"
1787
+ },
1788
+ unknown: {
1789
+ display: "flex",
1790
+ justifyContent: "center",
1791
+ alignItems: "center",
1792
+ width: "100%",
1793
+ height: "100%"
1794
+ },
1795
+ upload: _object_spread_props(_object_spread({}, button), {
1796
+ bottom: 0,
1797
+ right: 0
1798
+ }),
1799
+ remove: _object_spread_props(_object_spread({}, button), {
1800
+ top: 0,
1801
+ right: 0
1802
+ }),
1803
+ edit: _object_spread({}, button)
1804
+ };
1805
+ var styles_default8 = styles8;
1806
+ // src/components/Avatar/Avatar.tsx
1807
+ var import_react10 = require("react");
1808
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1809
+ var Avatar = function(param) {
1810
+ var src = param.src, setValue = param.setValue;
1811
+ var setSrc = function setSrc() {
1812
+ return _async_to_generator(function() {
1813
+ var translatedSrc;
1814
+ return _ts_generator(this, function(_state) {
1815
+ switch(_state.label){
1816
+ case 0:
1817
+ return [
1818
+ 4,
1819
+ Image_default2.FromStringToImageSrc(src)
1820
+ ];
1821
+ case 1:
1822
+ translatedSrc = _state.sent();
1823
+ if (!translatedSrc) return [
1824
+ 2
1825
+ ];
1826
+ defaultImage.current = translatedSrc;
1827
+ setValue(translatedSrc);
1828
+ return [
1829
+ 2
1830
+ ];
1831
+ }
1832
+ });
1833
+ })();
1834
+ };
1835
+ var _ref = _sliced_to_array((0, import_react10.useState)(false), 2), isOpen = _ref[0], setOpen = _ref[1];
1836
+ var _ref1 = _sliced_to_array((0, import_react10.useState)(false), 2), isNew = _ref1[0], setNew = _ref1[1];
1837
+ var uploadImageRef = (0, import_react10.useRef)(null);
1838
+ var defaultImage = (0, import_react10.useRef)("");
1839
+ (0, import_react10.useEffect)(function() {
1840
+ setSrc();
1841
+ }, [
1842
+ src
1843
+ ]);
1844
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", {
1845
+ style: styles_default8.container,
1846
+ children: [
1847
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ImageEditor_default, {
1848
+ src: src,
1849
+ setSrc: setValue,
1850
+ isOpen: isOpen,
1851
+ setOpen: setOpen,
1852
+ isNew: isNew
1853
+ }),
1854
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Image_default, {
1855
+ src: src,
1856
+ style: styles_default8.image
1857
+ }),
1858
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Button_default, {
1859
+ style: styles_default8.upload,
1860
+ onClick: function() {
1861
+ var _uploadImageRef_current;
1862
+ return (_uploadImageRef_current = uploadImageRef.current) === null || _uploadImageRef_current === void 0 ? void 0 : _uploadImageRef_current.click();
1863
+ },
1864
+ children: [
1865
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_io5.IoCloudUploadOutline, {
1866
+ size: others.iconSize
1867
+ }),
1868
+ "Upload"
1869
+ ]
1870
+ }),
1871
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(UploadImage_default, {
1872
+ ref: uploadImageRef,
1873
+ setSrc: function(e) {
1874
+ setValue(e);
1875
+ setOpen(true);
1876
+ setNew(function(prev) {
1877
+ return !prev;
1878
+ });
1879
+ }
1880
+ }),
1881
+ src !== defaultImage.current && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, {
1882
+ children: [
1883
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Button_default, {
1884
+ style: styles_default8.remove,
1885
+ onClick: function() {
1886
+ setValue(defaultImage.current);
1887
+ setNew(function(prev) {
1888
+ return !prev;
1889
+ });
1890
+ },
1891
+ children: [
1892
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_fa6.FaTrashCan, {
1893
+ size: others.iconSize,
1894
+ color: "red"
1895
+ }),
1896
+ "Remove"
1897
+ ]
1898
+ }),
1899
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Button_default, {
1900
+ style: styles_default8.edit,
1901
+ onClick: function() {
1902
+ return setOpen(function(prev) {
1903
+ return !prev;
1904
+ });
1905
+ },
1906
+ children: [
1907
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ri.RiEditLine, {
1908
+ size: others.iconSize
1909
+ }),
1910
+ "Edit"
1911
+ ]
1912
+ })
1913
+ ]
1914
+ })
1915
+ ]
1916
+ });
1917
+ };
1918
+ var Avatar_default = Avatar;
1919
+ // src/components/Input/InputGoogle/InputGoogle.tsx
1920
+ var import_react11 = require("react");
1921
+ // src/components/Input/InputGoogle/InputGoogle.styles.ts
1922
+ var others2 = {
1923
+ topRelease: "50%",
1924
+ topFocus: "0",
1925
+ fontSizeRelease: "16px",
1926
+ fontSizeFocus: "14px",
1927
+ borderRelease: "#cbcbcb",
1928
+ borderFocus: "#0957d0",
1929
+ textRelease: "#000",
1930
+ textFocus: "#0957d0",
1931
+ border: "solid 2px"
1932
+ };
1933
+ var styles9 = {
1934
+ input: {
1935
+ boxSizing: "border-box",
1936
+ height: "40px",
1937
+ width: "100%",
1938
+ border: "".concat(others2.border, " ").concat(others2.borderRelease),
1939
+ borderRadius: "6px",
1940
+ padding: "10px",
1941
+ outline: "none"
1942
+ },
1943
+ container: {
1944
+ width: "100%",
1945
+ position: "relative"
1946
+ },
1947
+ label: {
1948
+ position: "absolute",
1949
+ top: "50%",
1950
+ left: "10px",
1951
+ fontSize: "16px",
1952
+ transform: "translateY(-50%)",
1953
+ transition: "all .1s linear",
1954
+ padding: "0px 5px",
1955
+ backgroundColor: "white"
1956
+ }
1957
+ };
1958
+ var InputGoogle_styles_default = styles9;
1959
+ // src/components/Input/InputGoogle/InputGoogle.tsx
1960
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1961
+ var InputGoogle = function(_param) {
1962
+ var transitionOnFocus = function transitionOnFocus() {
1963
+ setFocus(true);
1964
+ if (spanRef.current) {
1965
+ spanRef.current.style.top = others2.topFocus;
1966
+ spanRef.current.style.fontSize = others2.fontSizeFocus;
1967
+ }
1968
+ };
1969
+ var transitionOffFocus = function transitionOffFocus() {
1970
+ setFocus(false);
1971
+ if (value) return;
1972
+ if (spanRef.current) {
1973
+ spanRef.current.style.top = others2.topRelease;
1974
+ spanRef.current.style.fontSize = others2.fontSizeRelease;
1975
+ }
1976
+ };
1977
+ var handleClickOnLabel = function handleClickOnLabel() {
1978
+ var _inputRef_current;
1979
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
1980
+ };
1981
+ 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, [
1982
+ "value",
1983
+ "setValue",
1984
+ "label",
1985
+ "options"
1986
+ ]);
1987
+ var _ref = _sliced_to_array((0, import_react11.useState)(false), 2), isFocus = _ref[0], setFocus = _ref[1];
1988
+ var spanRef = (0, import_react11.useRef)(null);
1989
+ var inputRef = (0, import_react11.useRef)(null);
1990
+ var inputBorder = isFocus ? "".concat(others2.border, " ").concat(options ? options.focusColor : others2.borderFocus) : "".concat(others2.border, " ").concat(others2.borderRelease);
1991
+ var labelTextColor = isFocus ? "".concat(options ? options.focusColor : others2.textFocus) : "".concat(others2.textRelease);
1992
+ (0, import_react11.useEffect)(function() {
1993
+ transitionOnFocus();
1994
+ transitionOffFocus();
1995
+ }, []);
1996
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", {
1997
+ style: InputGoogle_styles_default.container,
1998
+ children: [
1999
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", _object_spread({
2000
+ id: "will-input-google",
2001
+ ref: inputRef,
2002
+ value: value,
2003
+ onChange: function(e) {
2004
+ return setValue(e.target.value);
2005
+ },
2006
+ type: "text",
2007
+ style: _object_spread_props(_object_spread({}, InputGoogle_styles_default.input), {
2008
+ border: inputBorder
2009
+ }),
2010
+ onFocus: transitionOnFocus,
2011
+ onBlur: transitionOffFocus
2012
+ }, props)),
2013
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", {
2014
+ ref: spanRef,
2015
+ style: _object_spread_props(_object_spread({}, InputGoogle_styles_default.label), {
2016
+ color: labelTextColor
2017
+ }),
2018
+ onClick: handleClickOnLabel,
2019
+ children: label
2020
+ })
2021
+ ]
2022
+ });
2023
+ };
2024
+ var InputGoogle_default = InputGoogle;
2025
+ // src/components/Input/TextArea/TextArea.tsx
2026
+ var import_react12 = require("react");
2027
+ // src/components/Input/TextArea/TextArea.styles.ts
2028
+ var labelHeight = 20;
2029
+ var others3 = {
2030
+ topRelease: "".concat(labelHeight + 5, "px"),
2031
+ topFocus: "0",
2032
+ fontSizeRelease: "16px",
2033
+ fontSizeFocus: "14px",
2034
+ borderRelease: "#cbcbcb",
2035
+ borderFocus: "#0957d0",
2036
+ textRelease: "#000",
2037
+ textFocus: "#0957d0",
2038
+ border: "solid 2px"
2039
+ };
2040
+ var styles10 = {
2041
+ input: {
2042
+ boxSizing: "border-box",
2043
+ height: "100%",
2044
+ width: "100%",
2045
+ border: "".concat(others3.border, " ").concat(others3.borderRelease),
2046
+ borderRadius: "6px",
2047
+ padding: "10px",
2048
+ outline: "none",
2049
+ resize: "none"
2050
+ },
2051
+ container: {
2052
+ width: "100%",
2053
+ height: "100%",
2054
+ position: "relative"
2055
+ },
2056
+ label: {
2057
+ height: "".concat(labelHeight, "px"),
2058
+ position: "absolute",
2059
+ top: "".concat(labelHeight + 5, "px"),
2060
+ left: "10px",
2061
+ fontSize: "16px",
2062
+ transform: "translateY(-50%)",
2063
+ transition: "all .1s linear",
2064
+ padding: "0px 5px",
2065
+ backgroundColor: "white"
2066
+ }
2067
+ };
2068
+ var TextArea_styles_default = styles10;
2069
+ // src/components/Input/TextArea/TextArea.tsx
2070
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2071
+ var TextArea = function(_param) {
2072
+ var transitionOnFocus = function transitionOnFocus() {
2073
+ setFocus(true);
2074
+ if (spanRef.current) {
2075
+ spanRef.current.style.top = others3.topFocus;
2076
+ spanRef.current.style.fontSize = others3.fontSizeFocus;
2077
+ }
2078
+ };
2079
+ var transitionOffFocus = function transitionOffFocus() {
2080
+ setFocus(false);
2081
+ if (value) return;
2082
+ if (spanRef.current) {
2083
+ spanRef.current.style.top = others3.topRelease;
2084
+ spanRef.current.style.fontSize = others3.fontSizeRelease;
2085
+ }
2086
+ };
2087
+ var handleClickOnLabel = function handleClickOnLabel() {
2088
+ var _inputRef_current;
2089
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
2090
+ };
2091
+ 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, [
2092
+ "value",
2093
+ "setValue",
2094
+ "label",
2095
+ "options"
2096
+ ]);
2097
+ var _ref = _sliced_to_array((0, import_react12.useState)(false), 2), isFocus = _ref[0], setFocus = _ref[1];
2098
+ var spanRef = (0, import_react12.useRef)(null);
2099
+ var inputRef = (0, import_react12.useRef)(null);
2100
+ var inputBorder = isFocus ? "".concat(others3.border, " ").concat(options ? options.focusColor : others3.borderFocus) : "".concat(others3.border, " ").concat(others3.borderRelease);
2101
+ var labelTextColor = isFocus ? "".concat(options ? options.focusColor : others3.textFocus) : "".concat(others3.textRelease);
2102
+ (0, import_react12.useEffect)(function() {
2103
+ transitionOnFocus();
2104
+ transitionOffFocus();
2105
+ }, []);
2106
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", {
2107
+ style: TextArea_styles_default.container,
2108
+ children: [
2109
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("textarea", _object_spread({
2110
+ id: "will-textarea",
2111
+ ref: inputRef,
2112
+ value: value,
2113
+ onChange: function(e) {
2114
+ return setValue(e.target.value);
2115
+ },
2116
+ style: _object_spread_props(_object_spread({}, TextArea_styles_default.input), {
2117
+ border: inputBorder
2118
+ }),
2119
+ onFocus: transitionOnFocus,
2120
+ onBlur: transitionOffFocus
2121
+ }, props)),
2122
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", {
2123
+ ref: spanRef,
2124
+ style: _object_spread_props(_object_spread({}, TextArea_styles_default.label), {
2125
+ color: labelTextColor
2126
+ }),
2127
+ onClick: handleClickOnLabel,
2128
+ children: label
2129
+ })
2130
+ ]
2131
+ });
2132
+ };
2133
+ var TextArea_default = TextArea;
2134
+ // src/components/Input/InputFile.tsx
2135
+ var import_react13 = require("react");
2136
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2137
+ var InputFile = function(_param) {
2138
+ 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, [
2139
+ "file",
2140
+ "onChoose",
2141
+ "onCancel",
2142
+ "acceptType"
2143
+ ]);
2144
+ var _ref = _sliced_to_array((0, import_react13.useState)(Date.now()), 2), key = _ref[0], setKey = _ref[1];
2145
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", _object_spread_props(_object_spread({
2146
+ type: "file"
2147
+ }, props), {
2148
+ onChange: function(e) {
2149
+ var _target_files;
2150
+ var target = e.target;
2151
+ var file2 = (_target_files = target.files) === null || _target_files === void 0 ? void 0 : _target_files[0];
2152
+ if (file2) {
2153
+ setKey(Date.now());
2154
+ onChoose(file2);
2155
+ } else {
2156
+ onCancel();
2157
+ }
2158
+ }
2159
+ }), key);
2160
+ };
2161
+ var InputFile_default = InputFile;
2162
+ // src/components/Image/UploadImage.tsx
2163
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2164
+ var UploadImage = function(_param) {
2165
+ var handleSetSrc = function handleSetSrc(file) {
2166
+ return _async_to_generator(function() {
2167
+ var src;
2168
+ return _ts_generator(this, function(_state) {
2169
+ switch(_state.label){
2170
+ case 0:
2171
+ return [
2172
+ 4,
2173
+ Image_default2.FromFileToImageSrc(file)
2174
+ ];
2175
+ case 1:
2176
+ src = _state.sent();
2177
+ if (!src) return [
2178
+ 2
2179
+ ];
2180
+ setSrc(src);
2181
+ return [
2182
+ 2
2183
+ ];
2184
+ }
2185
+ });
2186
+ })();
2187
+ };
2188
+ var _param_setSrc = _param.setSrc, setSrc = _param_setSrc === void 0 ? function() {} : _param_setSrc, props = _object_without_properties(_param, [
2189
+ "setSrc"
2190
+ ]);
2191
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, {
2192
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(InputFile_default, _object_spread_props(_object_spread({
2193
+ onChoose: handleSetSrc,
2194
+ acceptType: "image/*"
2195
+ }, props), {
2196
+ hidden: true
2197
+ }))
2198
+ });
2199
+ };
2200
+ var UploadImage_default = UploadImage;
2201
+ // src/components/Image/Image.tsx
2202
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2203
+ var Image = function(_param) {
2204
+ var props = _extends({}, _object_destructuring_empty(_param));
2205
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", _object_spread_props(_object_spread({
2206
+ style: {
2207
+ width: "100%",
2208
+ height: "100%"
2209
+ }
2210
+ }, props), {
2211
+ alt: "Will-Image-Component",
2212
+ draggable: false
2213
+ }));
2214
+ };
2215
+ var Image_default = Image;
2216
+ // src/components/Image/ImageEditor/ImageEditor.tsx
2217
+ var import_react14 = require("react");
2218
+ // src/components/Image/ImageEditor/ImageEditor.styles.ts
2219
+ var imageEditorStyles = {
2220
+ imageEditor: {
2221
+ width: "100vw",
2222
+ height: "100dvh",
2223
+ display: "flex",
2224
+ flexDirection: "column",
2225
+ justifyContent: "center",
2226
+ alignItems: "center",
2227
+ position: "fixed",
2228
+ top: 0,
2229
+ left: 0,
2230
+ backdropFilter: "blur(20px)",
2231
+ zIndex: 99,
2232
+ paddingLeft: "30px",
2233
+ paddingRight: "30px"
2234
+ },
2235
+ frame: {
2236
+ padding: "50px",
2237
+ backgroundColor: "white",
2238
+ border: "solid 4px #000",
2239
+ borderStyle: "dashed",
2240
+ borderRadius: "50%",
2241
+ overflow: "hidden",
2242
+ maxWidth: "500px",
2243
+ width: "100%",
2244
+ maxHeight: "500px",
2245
+ aspectRatio: 1 / 1,
2246
+ position: "relative"
2247
+ },
2248
+ wrapper: {
2249
+ position: "absolute",
2250
+ transformOrigin: "top left",
2251
+ userSelect: "none"
2252
+ },
2253
+ img: {
2254
+ objectFit: "contain",
2255
+ position: "absolute",
2256
+ top: 0,
2257
+ left: 0,
2258
+ display: "block",
2259
+ zIndex: 1,
2260
+ transform: "translate(-50%, -50%)"
2261
+ },
2262
+ buttons: {
2263
+ display: "flex",
2264
+ justifyContent: "center",
2265
+ alignItems: "center",
2266
+ gap: "20px",
2267
+ padding: "30px"
2268
+ }
2269
+ };
2270
+ var ImageEditor_styles_default = imageEditorStyles;
2271
+ // src/components/Image/ImageEditor/ImageEditor.tsx
2272
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2273
+ var ImageEditor = function(param) {
2274
+ 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;
2275
+ var createTransform = function createTransform() {
2276
+ return _async_to_generator(function() {
2277
+ var transform2;
2278
+ return _ts_generator(this, function(_state) {
2279
+ switch(_state.label){
2280
+ case 0:
2281
+ if (!frame.current || !wrapper.current || !img.current) return [
2282
+ 2
2283
+ ];
2284
+ transform2 = new Transform(wrapper.current, frame.current);
2285
+ return [
2286
+ 4,
2287
+ transform2.initialize()
2288
+ ];
2289
+ case 1:
2290
+ _state.sent();
2291
+ if (transformState.current) {
2292
+ transform2.setState(transformState.current);
2293
+ } else {
2294
+ transform2.reset();
2295
+ }
2296
+ setTransform(transform2);
2297
+ return [
2298
+ 2
2299
+ ];
2300
+ }
2301
+ });
2302
+ })();
2303
+ };
2304
+ var handleCanvasToSrc = function handleCanvasToSrc() {
2305
+ if (!frame.current || !wrapper.current || !img.current || !transform) return;
2306
+ var canvasInstance = new Canvas();
2307
+ var _canvasInstance_createCanvas = canvasInstance.createCanvas(700, 700), canvas = _canvasInstance_createCanvas.canvas, context = _canvasInstance_createCanvas.context;
2308
+ var _transform_exportData = transform.exportData(), x = _transform_exportData.x, y = _transform_exportData.y, angle = _transform_exportData.angle;
2309
+ transformState.current = transform.exportData();
2310
+ var _canvasInstance_drawImage = canvasInstance.drawImage(img.current, context, x, y, 1, angle, canvas, frame.current.clientWidth, frame.current.clientHeight), src2 = _canvasInstance_drawImage.src;
2311
+ return src2;
2312
+ };
2313
+ var handleAccept = function handleAccept() {
2314
+ setSrc(handleCanvasToSrc());
2315
+ setOpen(false);
2316
+ };
2317
+ var handleCancel = function handleCancel() {
2318
+ setOpen(false);
2319
+ };
2320
+ var handleReset = function handleReset() {
2321
+ if (!transform) return;
2322
+ transform.reset();
2323
+ };
2324
+ var frame = (0, import_react14.useRef)(null);
2325
+ var wrapper = (0, import_react14.useRef)(null);
2326
+ var img = (0, import_react14.useRef)(null);
2327
+ var _ref = _sliced_to_array((0, import_react14.useState)(void 0), 2), transform = _ref[0], setTransform = _ref[1];
2328
+ var transformState = (0, import_react14.useRef)(void 0);
2329
+ var originalSrc = (0, import_react14.useMemo)(function() {
2330
+ transformState.current = void 0;
2331
+ return src;
2332
+ }, [
2333
+ isNew
2334
+ ]);
2335
+ (0, import_react14.useEffect)(function() {
2336
+ isOpen ? createTransform() : setTransform(void 0);
2337
+ }, [
2338
+ isOpen
2339
+ ]);
2340
+ if (!isOpen) return;
2341
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", {
2342
+ style: ImageEditor_styles_default.imageEditor,
2343
+ children: [
2344
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", {
2345
+ children: "Drag, Zoom, or Rotate image"
2346
+ }),
2347
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", {
2348
+ ref: frame,
2349
+ style: ImageEditor_styles_default.frame,
2350
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", {
2351
+ ref: wrapper,
2352
+ style: ImageEditor_styles_default.wrapper,
2353
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("img", {
2354
+ src: originalSrc,
2355
+ style: ImageEditor_styles_default.img,
2356
+ ref: img
2357
+ })
2358
+ })
2359
+ }),
2360
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", {
2361
+ style: ImageEditor_styles_default.buttons,
2362
+ children: [
2363
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button_default, {
2364
+ buttonType: "solid",
2365
+ content: "Accept",
2366
+ onClick: handleAccept
2367
+ }),
2368
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button_default, {
2369
+ buttonType: "solid",
2370
+ content: "Cancel",
2371
+ onClick: handleCancel
2372
+ }),
2373
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button_default, {
2374
+ buttonType: "solid",
2375
+ content: "Reset",
2376
+ onClick: handleReset
2377
+ })
2378
+ ]
2379
+ })
2380
+ ]
2381
+ });
2382
+ };
2383
+ var ImageEditor_default = ImageEditor;
2384
+ // src/utilities/canvas/Canvas.ts
2385
+ var Canvas = /*#__PURE__*/ function() {
2386
+ function Canvas() {
2387
+ _class_call_check(this, Canvas);
2388
+ }
2389
+ _create_class(Canvas, [
2390
+ {
2391
+ key: "createCanvas",
2392
+ value: function createCanvas(width, height) {
2393
+ var canvas = document.createElement("canvas");
2394
+ var context = canvas.getContext("2d");
2395
+ canvas.width = width;
2396
+ canvas.height = height;
2397
+ return {
2398
+ canvas: canvas,
2399
+ context: context
2400
+ };
2401
+ }
2402
+ },
2403
+ {
2404
+ key: "drawImage",
2405
+ value: function drawImage(e, ctx, x, y, scale, angle, canvas, containerWidth, containerHeight) {
2406
+ var ratioX = canvas.width / containerWidth;
2407
+ var ratioY = canvas.height / containerHeight;
2408
+ var finalX = x * ratioX;
2409
+ var finalY = y * ratioY;
2410
+ var midleWidth = e.width * ratioX;
2411
+ var midleHeight = e.height * ratioY;
2412
+ var finalWidth = e.width * ratioX * scale;
2413
+ var finalHeight = e.height * ratioY * scale;
2414
+ ctx.save();
2415
+ ctx.translate(finalX + midleWidth / 2, finalY + midleHeight / 2);
2416
+ ctx.rotate(angle * Math.PI / 180);
2417
+ ctx.drawImage(e, -finalWidth / 2, -finalHeight / 2, finalWidth, finalHeight);
2418
+ ctx.restore();
2419
+ var src = ctx.canvas.toDataURL();
2420
+ var srcEncoded = src.split(",")[1];
2421
+ return {
2422
+ context: ctx,
2423
+ src: src
2424
+ };
2425
+ }
2426
+ },
2427
+ {
2428
+ key: "drawColor",
2429
+ value: function drawColor(type, color, ctx, width, ratio) {
2430
+ if (type === "") color = "#ffffff";
2431
+ if (type === "gradient") {
2432
+ var breakdownArr = color.split(",");
2433
+ var _ref = [
2434
+ Number(breakdownArr[0]),
2435
+ breakdownArr[1],
2436
+ Number(breakdownArr[2]),
2437
+ breakdownArr[3],
2438
+ Number(breakdownArr[4])
2439
+ ], angle = _ref[0], color1 = _ref[1], percent1 = _ref[2], color2 = _ref[3], percent2 = _ref[4];
2440
+ var radians = (angle - 180) * Math.PI / 180;
2441
+ var x0 = width / 2 + width / 2 * Math.cos(radians - Math.PI / 2);
2442
+ var y0 = width * ratio / 2 + width * ratio / 2 * Math.sin(radians - Math.PI / 2);
2443
+ var x1 = width / 2 - width / 2 * Math.cos(radians - Math.PI / 2);
2444
+ var y1 = width * ratio / 2 - width * ratio / 2 * Math.sin(radians - Math.PI / 2);
2445
+ var gradient = ctx.createLinearGradient(x0, y0, x1, y1);
2446
+ gradient.addColorStop(percent1 / 100, color1);
2447
+ gradient.addColorStop(percent2 / 100, color2);
2448
+ ctx.fillStyle = gradient;
2449
+ ctx.fillRect(0, 0, width, width * ratio);
2450
+ var srcEncoded = ctx.canvas.toDataURL().split(",")[1];
2451
+ return [
2452
+ ctx,
2453
+ srcEncoded
2454
+ ];
2455
+ } else {
2456
+ ctx.fillStyle = color;
2457
+ ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
2458
+ var srcEncoded1 = ctx.canvas.toDataURL().split(",")[1];
2459
+ return [
2460
+ ctx,
2461
+ srcEncoded1
2462
+ ];
2463
+ }
2464
+ }
2465
+ }
2466
+ ]);
2467
+ return Canvas;
2468
+ }();
2469
+ // src/utilities/canvas/Image.ts
2470
+ var Image2 = {
2471
+ /**
2472
+ * Convert file (blob) to base64 string format
2473
+ * @param file
2474
+ * @returns
2475
+ */ FromFileToImageSrc: function FromFileToImageSrc(file) {
2476
+ return new Promise(function(resolve, reject) {
2477
+ if (!file) return resolve(null);
2478
+ var reader = new FileReader();
2479
+ reader.readAsDataURL(file);
2480
+ reader.onload = function(readerEvent) {
2481
+ var _readerEvent_target;
2482
+ if ((_readerEvent_target = readerEvent.target) === null || _readerEvent_target === void 0 ? void 0 : _readerEvent_target.result) {
2483
+ var _readerEvent_target1;
2484
+ return resolve((_readerEvent_target1 = readerEvent.target) === null || _readerEvent_target1 === void 0 ? void 0 : _readerEvent_target1.result);
2485
+ }
2486
+ reject("Error getting the image source");
2487
+ };
2488
+ reader.onerror = function() {
2489
+ reject("Error getting the image source");
2490
+ };
2491
+ });
2492
+ },
2493
+ FromStringToImageSrc: /**
2494
+ * Convert urlst
2495
+ * @param url
2496
+ * @returns
2497
+ */ function FromStringToImageSrc(url) {
2498
+ return _async_to_generator(function() {
2499
+ var res, blob, src;
2500
+ return _ts_generator(this, function(_state) {
2501
+ switch(_state.label){
2502
+ case 0:
2503
+ if (!url || Image2.isBase64(url)) return [
2504
+ 2,
2505
+ null
2506
+ ];
2507
+ return [
2508
+ 4,
2509
+ fetch(url)
2510
+ ];
2511
+ case 1:
2512
+ res = _state.sent();
2513
+ return [
2514
+ 4,
2515
+ res.blob()
2516
+ ];
2517
+ case 2:
2518
+ blob = _state.sent();
2519
+ return [
2520
+ 4,
2521
+ Image2.FromFileToImageSrc(blob)
2522
+ ];
2523
+ case 3:
2524
+ src = _state.sent();
2525
+ return [
2526
+ 2,
2527
+ src
2528
+ ];
2529
+ }
2530
+ });
2531
+ })();
2532
+ },
2533
+ /**
2534
+ * Check if the url is base64 format
2535
+ * @param url
2536
+ * @deprecated Using a weak condition and might be changed later. Use checkBase64 instead
2537
+ */ checkBase64: function checkBase64(url) {
2538
+ if (!url || url === "") return false;
2539
+ return url.includes("base64,");
2540
+ },
2541
+ isBase64: function isBase64(url) {
2542
+ return Image2.checkBase64(url);
2543
+ }
2544
+ };
2545
+ var Image_default2 = Image2;
2546
+ // src/utilities/Transform/Transform.ts
2547
+ var import_jquery2 = __toESM(require("jquery"));
2548
+ // src/utilities/Transform/TransformController.ts
2549
+ var import_jquery = __toESM(require("jquery"));
2550
+ var import_fontawesome_svg_core = require("@fortawesome/fontawesome-svg-core");
2551
+ var import_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
2552
+ var TransformController = /*#__PURE__*/ function() {
2553
+ function TransformController(wrapper, frame, controller) {
2554
+ _class_call_check(this, TransformController);
2555
+ this.wrapper = wrapper;
2556
+ this.frame = frame;
2557
+ this.controller = controller;
2558
+ }
2559
+ _create_class(TransformController, [
2560
+ {
2561
+ key: "addController",
2562
+ value: function addController() {
2563
+ var _this = this;
2564
+ return new Promise(function(res) {
2565
+ var styleElement = document.createElement("style");
2566
+ styleElement.textContent = _this.css();
2567
+ document.head.appendChild(styleElement);
2568
+ (0, import_jquery.default)("." + _this.frame).after(_this.controllerTemplate());
2569
+ res();
2570
+ });
2571
+ }
2572
+ },
2573
+ {
2574
+ key: "css",
2575
+ value: function css() {
2576
+ 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 ");
2577
+ }
2578
+ },
2579
+ {
2580
+ key: "controllerTemplate",
2581
+ value: function controllerTemplate() {
2582
+ 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((0, import_fontawesome_svg_core.icon)(import_free_solid_svg_icons.faRotate).html[0], '</div>\n <div class="dot rotate shadow" style="visibility: hidden;">').concat((0, import_fontawesome_svg_core.icon)(import_free_solid_svg_icons.faRotate).html[0], '</div>\n <div class="dot delete">').concat((0, import_fontawesome_svg_core.icon)(import_free_solid_svg_icons.faTrash).html[0], '</div>\n <div class="dot delete shadow" style="visibility: hidden;">').concat((0, import_fontawesome_svg_core.icon)(import_free_solid_svg_icons.faTrash).html[0], "</div>\n </div>\n </div>\n ");
2583
+ }
2584
+ }
2585
+ ]);
2586
+ return TransformController;
2587
+ }();
2588
+ // src/utilities/Transform/Transform.ts
2589
+ var Transform = /*#__PURE__*/ function() {
2590
+ function Transform(ele1, ele2, ele3) {
2591
+ _class_call_check(this, Transform);
2592
+ this.ele1 = ele1;
2593
+ this.ele2 = ele2;
2594
+ this.x = 0;
2595
+ this.y = 0;
2596
+ this.angle = 90;
2597
+ this.w = 0;
2598
+ this.h = 0;
2599
+ if (this.ele1 === null) {
2600
+ throw new Error("wrapper elemenet is not defined or not rendered yet");
2601
+ }
2602
+ this.wrapperClass = "_" + (Date.now() + 5e3).toString();
2603
+ (0, import_jquery2.default)(this.ele1).addClass(this.wrapperClass);
2604
+ this.imgFrame = this.ele2;
2605
+ if (this.imgFrame === null) {
2606
+ throw new Error("frame element is not defined or not rendered yet");
2607
+ }
2608
+ this.frameClass = "_" + (Date.now() - 5e3).toString();
2609
+ (0, import_jquery2.default)(this.ele2).addClass(this.frameClass);
2610
+ this.img = this.ele1.querySelector("img");
2611
+ if (this.img === null) {
2612
+ throw new Error("image element is not defined or not rendered yet");
2613
+ }
2614
+ this.ratio = this.img.clientWidth / this.img.clientHeight;
2615
+ this.controllerClassName = "_" + Date.now().toString();
2616
+ this.isRotateOffScreen = false;
2617
+ }
2618
+ _create_class(Transform, [
2619
+ {
2620
+ key: "initialize",
2621
+ value: function initialize() {
2622
+ return _async_to_generator(function() {
2623
+ var transformController;
2624
+ return _ts_generator(this, function(_state) {
2625
+ switch(_state.label){
2626
+ case 0:
2627
+ transformController = new TransformController(this.wrapperClass, this.frameClass, this.controllerClassName);
2628
+ return [
2629
+ 4,
2630
+ transformController.addController()
2631
+ ];
2632
+ case 1:
2633
+ _state.sent();
2634
+ this.controllerContainer = document.querySelector("." + this.controllerClassName + "--container");
2635
+ this.controller = document.querySelector("." + this.controllerClassName);
2636
+ this.handleElementGoOffScreen("." + this.controllerClassName + " .rotate", "." + this.controllerClassName + " .rotate.shadow", "rotate").handleElementGoOffScreen("." + this.controllerClassName + " .delete", "." + this.controllerClassName + " .delete.shadow", "delete").transform();
2637
+ return [
2638
+ 2
2639
+ ];
2640
+ }
2641
+ });
2642
+ }).call(this);
2643
+ }
2644
+ },
2645
+ {
2646
+ key: "reset",
2647
+ value: function reset() {
2648
+ this.setState({
2649
+ x: 0,
2650
+ y: this.imgFrame.clientHeight / 2 - this.img.height / 2,
2651
+ angle: 0,
2652
+ w: this.imgFrame.clientWidth
2653
+ });
2654
+ }
2655
+ },
2656
+ {
2657
+ key: "setState",
2658
+ value: function setState(param) {
2659
+ var x = param.x, y = param.y, angle = param.angle, w = param.w;
2660
+ this.repositionElement(x + this.imgFrame.clientWidth / 2, y + this.img.height / 2);
2661
+ this.rotateBox(angle);
2662
+ this.resize(w, w / this.ratio);
2663
+ this.setValue(x, y, angle, w, w / this.ratio);
2664
+ }
2665
+ },
2666
+ {
2667
+ key: "setValue",
2668
+ value: function setValue(x, y, angle, w, h) {
2669
+ this.x = x !== void 0 ? x : this.x;
2670
+ this.y = y !== void 0 ? y : this.y;
2671
+ this.angle = angle !== void 0 ? angle : this.angle;
2672
+ this.w = w !== void 0 ? w : this.w;
2673
+ this.h = h !== void 0 ? h : this.h;
2674
+ }
2675
+ },
2676
+ {
2677
+ key: "exportData",
2678
+ value: function exportData() {
2679
+ return {
2680
+ x: this.x,
2681
+ y: this.y,
2682
+ angle: this.angle,
2683
+ w: this.w,
2684
+ h: this.h
2685
+ };
2686
+ }
2687
+ },
2688
+ {
2689
+ key: "repositionElement",
2690
+ value: function repositionElement(x, y) {
2691
+ var controllerWrapper = this.controllerContainer;
2692
+ var boxWrapper = this.ele1;
2693
+ boxWrapper.style.left = x + "px";
2694
+ boxWrapper.style.top = y + "px";
2695
+ controllerWrapper.style.left = x + this.imgFrame.offsetLeft + 3 + "px";
2696
+ controllerWrapper.style.top = y + this.imgFrame.offsetTop + 3 + "px";
2697
+ }
2698
+ },
2699
+ {
2700
+ key: "resize",
2701
+ value: function resize(w, h) {
2702
+ var controller = this.controller;
2703
+ var img = this.img;
2704
+ var wrapper = this.ele1;
2705
+ controller.style.width = w + "px";
2706
+ controller.style.height = h + "px";
2707
+ img.style.width = w + "px";
2708
+ wrapper.style.width = w + "px";
2709
+ }
2710
+ },
2711
+ {
2712
+ key: "rotateBox",
2713
+ value: function rotateBox(deg) {
2714
+ var controllerWrapper = this.controllerContainer;
2715
+ var boxWrapper = this.ele1;
2716
+ boxWrapper.style.transform = "rotate(".concat(deg, "deg)");
2717
+ controllerWrapper.style.rotate = "".concat(deg, "deg");
2718
+ }
2719
+ },
2720
+ {
2721
+ key: "handleElementGoOffScreen",
2722
+ value: function handleElementGoOffScreen(main, shadow, type) {
2723
+ var _this = this;
2724
+ var mainEle = document.querySelector(main);
2725
+ var shadowEle = document.querySelector(shadow);
2726
+ var options = {
2727
+ root: null,
2728
+ rootMargin: "0px",
2729
+ threshold: 0.1
2730
+ };
2731
+ var callback = function(entries) {
2732
+ entries.forEach(function(entry) {
2733
+ switch(type){
2734
+ case "rotate":
2735
+ if (!entry.isIntersecting) {
2736
+ mainEle.style.top = "auto";
2737
+ mainEle.style.bottom = "-50px";
2738
+ _this.isRotateOffScreen = true;
2739
+ } else {
2740
+ mainEle.style.bottom = "auto";
2741
+ mainEle.style.top = "-50px";
2742
+ _this.isRotateOffScreen = false;
2743
+ }
2744
+ break;
2745
+ case "delete":
2746
+ if (!entry.isIntersecting) {
2747
+ mainEle.style.bottom = "auto";
2748
+ mainEle.style.top = "-50px";
2749
+ } else {
2750
+ mainEle.style.top = "auto";
2751
+ mainEle.style.bottom = "-50px";
2752
+ }
2753
+ break;
2754
+ }
2755
+ });
2756
+ };
2757
+ var observer = new IntersectionObserver(callback, options);
2758
+ observer.observe(shadowEle);
2759
+ return this;
2760
+ }
2761
+ },
2762
+ {
2763
+ key: "transform",
2764
+ value: function transform() {
2765
+ var _this = this;
2766
+ var _this1 = this;
2767
+ var controllerWrapper = this.controllerContainer;
2768
+ var boxWrapper = this.ele1;
2769
+ var minWidth = 40;
2770
+ var minHeight = 40;
2771
+ var initX, initY, mousePressX, mousePressY, initW, initH, initRotate;
2772
+ function getCurrentRotation(el) {
2773
+ var st = window.getComputedStyle(el, null);
2774
+ var tm = st.getPropertyValue("-webkit-transform") || st.getPropertyValue("-moz-transform") || st.getPropertyValue("-ms-transform") || st.getPropertyValue("-o-transform") || st.getPropertyValue("transform");
2775
+ "none";
2776
+ if (tm != "none") {
2777
+ var values = tm.split("(")[1].split(")")[0].split(",");
2778
+ var angle = Math.round(Math.atan2(Number(values[1]), Number(values[0])) * (180 / Math.PI));
2779
+ return angle < 0 ? angle + 360 : angle;
2780
+ }
2781
+ return 0;
2782
+ }
2783
+ function mousedownCb(event) {
2784
+ event.target.classList.add("show");
2785
+ event.target.querySelector(".circle").classList.add("show");
2786
+ }
2787
+ function mouseupCb(event) {
2788
+ event.target.classList.remove("show");
2789
+ event.target.querySelector(".circle").classList.remove("show");
2790
+ }
2791
+ var handleDrag = function(event, type) {
2792
+ event.stopPropagation();
2793
+ var initX2 = boxWrapper.offsetLeft;
2794
+ var initY2 = boxWrapper.offsetTop;
2795
+ var mousePressX2 = type === "desk" ? event.clientX : event.touches[0].clientX;
2796
+ var mousePressY2 = type === "desk" ? event.clientY : event.touches[0].clientY;
2797
+ var _this_exportData = _this.exportData(), w = _this_exportData.w, h = _this_exportData.h;
2798
+ var eventMoveHandler = function(event2) {
2799
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2800
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2801
+ var posX = initX2 + (x - mousePressX2);
2802
+ var posY = initY2 + (y - mousePressY2);
2803
+ _this.repositionElement(posX, posY);
2804
+ _this.setValue(posX - w / 2, posY - h / 2, void 0, void 0, void 0);
2805
+ };
2806
+ if (type === "desk") {
2807
+ controllerWrapper.addEventListener("mousemove", eventMoveHandler, false);
2808
+ window.addEventListener("mouseup", function eventEndHandler() {
2809
+ controllerWrapper.removeEventListener("mousemove", eventMoveHandler, false);
2810
+ window.removeEventListener("mouseup", eventEndHandler);
2811
+ }, false);
2812
+ } else {
2813
+ controllerWrapper.addEventListener("touchmove", eventMoveHandler, {
2814
+ passive: true
2815
+ });
2816
+ window.addEventListener("touchend", function eventEndHandler() {
2817
+ controllerWrapper.removeEventListener("touchmove", eventMoveHandler);
2818
+ window.removeEventListener("touchend", eventEndHandler);
2819
+ }, false);
2820
+ }
2821
+ };
2822
+ controllerWrapper.addEventListener("mousedown", function(e) {
2823
+ return handleDrag(e, "desk");
2824
+ }, false);
2825
+ controllerWrapper.addEventListener("touchstart", function(e) {
2826
+ return handleDrag(e, "touch");
2827
+ }, {
2828
+ passive: true
2829
+ });
2830
+ var leftTop = document.querySelector("." + this.controllerClassName + " .resize-topleft");
2831
+ var rightTop = document.querySelector("." + this.controllerClassName + " .resize-topright");
2832
+ var rightBottom = document.querySelector("." + this.controllerClassName + " .resize-bottomright");
2833
+ var leftBottom = document.querySelector("." + this.controllerClassName + " .resize-bottomleft");
2834
+ var resizeHandler = function(event) {
2835
+ 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;
2836
+ event.stopPropagation();
2837
+ initX = boxWrapper.offsetLeft;
2838
+ initY = boxWrapper.offsetTop;
2839
+ mousePressX = type === "desk" ? event.clientX : event.touches[0].clientX;
2840
+ mousePressY = type === "desk" ? event.clientY : event.touches[0].clientY;
2841
+ initW = _this1.img.offsetWidth;
2842
+ initH = _this1.img.offsetHeight;
2843
+ initRotate = getCurrentRotation(boxWrapper);
2844
+ var initRadians = initRotate * Math.PI / 180;
2845
+ var cosFraction = Math.cos(initRadians);
2846
+ var sinFraction = Math.sin(initRadians);
2847
+ mousedownCb(event);
2848
+ var vectorC = [
2849
+ mousePressX - initX - _this1.imgFrame.offsetLeft,
2850
+ mousePressY - initY - _this1.imgFrame.offsetTop
2851
+ ];
2852
+ var eventMoveHandler = function(event2) {
2853
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2854
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2855
+ var wDiff = x - mousePressX;
2856
+ var hDiff = y - mousePressY;
2857
+ var vectorD = [
2858
+ wDiff,
2859
+ hDiff
2860
+ ];
2861
+ var c = (vectorC[0] * vectorD[0] + vectorC[1] * vectorD[1]) / (vectorC[0] * vectorC[0] + vectorC[1] * vectorC[1]);
2862
+ var vectorH = [
2863
+ c * vectorC[0],
2864
+ c * vectorC[1]
2865
+ ];
2866
+ var rotatedWDiff = cosFraction * vectorH[0] + sinFraction * vectorH[1];
2867
+ var rotatedHDiff = cosFraction * vectorH[1] - sinFraction * vectorH[0];
2868
+ rotatedHDiff = rotatedHDiff * rotatedWDiff > 0 ? rotatedWDiff / _this1.ratio : -rotatedWDiff / _this1.ratio;
2869
+ var newW = initW, newH = initH, newX = initX, newY = initY;
2870
+ if (xResize) {
2871
+ if (left) {
2872
+ newW = initW - rotatedWDiff;
2873
+ if (newW < minWidth) {
2874
+ newW = minWidth;
2875
+ rotatedWDiff = initW - minWidth;
2876
+ }
2877
+ } else {
2878
+ newW = initW + rotatedWDiff;
2879
+ if (newW < minWidth) {
2880
+ newW = minWidth;
2881
+ rotatedWDiff = minWidth - initW;
2882
+ }
2883
+ }
2884
+ newX += 0.5 * rotatedWDiff * cosFraction;
2885
+ newY += 0.5 * rotatedWDiff * sinFraction;
2886
+ }
2887
+ if (yResize) {
2888
+ if (top) {
2889
+ newH = initH - rotatedHDiff;
2890
+ if (newH < minHeight) {
2891
+ newH = minHeight;
2892
+ rotatedHDiff = initH - minHeight;
2893
+ }
2894
+ } else {
2895
+ newH = initH + rotatedHDiff;
2896
+ if (newH < minHeight) {
2897
+ newH = minHeight;
2898
+ rotatedHDiff = minHeight - initH;
2899
+ }
2900
+ }
2901
+ newX -= 0.5 * rotatedHDiff * sinFraction;
2902
+ newY += 0.5 * rotatedHDiff * cosFraction;
2903
+ }
2904
+ _this1.resize(newW, newH);
2905
+ _this1.repositionElement(newX, newY);
2906
+ _this1.setValue(newX - newW / 2, newY - newH / 2, void 0, newW, newH);
2907
+ };
2908
+ if (type === "desk") {
2909
+ window.addEventListener("mousemove", eventMoveHandler, false);
2910
+ window.addEventListener("mouseup", function eventEndHandler() {
2911
+ mouseupCb(event);
2912
+ window.removeEventListener("mousemove", eventMoveHandler, false);
2913
+ window.removeEventListener("mouseup", eventEndHandler);
2914
+ }, false);
2915
+ } else {
2916
+ window.addEventListener("touchmove", eventMoveHandler, {
2917
+ passive: true
2918
+ });
2919
+ window.addEventListener("touchend", function eventEndHandler() {
2920
+ mouseupCb(event);
2921
+ window.removeEventListener("touchmove", eventMoveHandler, false);
2922
+ window.removeEventListener("touchend", eventEndHandler);
2923
+ }, false);
2924
+ }
2925
+ };
2926
+ leftTop.addEventListener("mousedown", function(e) {
2927
+ return resizeHandler(e, true, true, true, true, "desk");
2928
+ });
2929
+ rightTop.addEventListener("mousedown", function(e) {
2930
+ return resizeHandler(e, false, true, true, true, "desk");
2931
+ });
2932
+ rightBottom.addEventListener("mousedown", function(e) {
2933
+ return resizeHandler(e, false, false, true, true, "desk");
2934
+ });
2935
+ leftBottom.addEventListener("mousedown", function(e) {
2936
+ return resizeHandler(e, true, false, true, true, "desk");
2937
+ });
2938
+ leftTop.addEventListener("touchstart", function(e) {
2939
+ return resizeHandler(e, true, true, true, true, "touch");
2940
+ }, {
2941
+ passive: true
2942
+ });
2943
+ rightTop.addEventListener("touchstart", function(e) {
2944
+ return resizeHandler(e, false, true, true, true, "touch");
2945
+ }, {
2946
+ passive: true
2947
+ });
2948
+ rightBottom.addEventListener("touchstart", function(e) {
2949
+ return resizeHandler(e, false, false, true, true, "touch");
2950
+ }, {
2951
+ passive: true
2952
+ });
2953
+ leftBottom.addEventListener("touchstart", function(e) {
2954
+ return resizeHandler(e, true, false, true, true, "touch");
2955
+ }, {
2956
+ passive: true
2957
+ });
2958
+ var rotate = document.querySelector("." + this.controllerClassName + " .rotate");
2959
+ var handleRotate = function(event, type) {
2960
+ event.stopPropagation();
2961
+ initX = event.target.offsetLeft;
2962
+ initY = event.target.offsetTop;
2963
+ mousePressX = type === "desk" ? event.clientX : event.touches[0].clientX;
2964
+ mousePressY = type === "desk" ? event.clientY : event.touches[0].clientY;
2965
+ var arrow = _this.controller;
2966
+ var arrowRects = arrow.getBoundingClientRect();
2967
+ var arrowX = arrowRects.left + arrowRects.width / 2;
2968
+ var arrowY = arrowRects.top + arrowRects.height / 2;
2969
+ var compensation = _this.isRotateOffScreen ? 180 : 0;
2970
+ var eventMoveHandler = function(event2) {
2971
+ var x = type === "desk" ? event2.clientX : event2.touches[0].clientX;
2972
+ var y = type === "desk" ? event2.clientY : event2.touches[0].clientY;
2973
+ var angle = Math.atan2(y - arrowY, x - arrowX) + Math.PI / 2;
2974
+ angle *= 180 / Math.PI;
2975
+ angle += compensation;
2976
+ _this.rotateBox(angle);
2977
+ _this.setValue(void 0, void 0, angle, void 0, void 0);
2978
+ };
2979
+ if (type === "desk") {
2980
+ window.addEventListener("mousemove", eventMoveHandler, false);
2981
+ window.addEventListener("mouseup", function eventEndHandler() {
2982
+ window.removeEventListener("mousemove", eventMoveHandler, false);
2983
+ window.removeEventListener("mouseup", eventEndHandler);
2984
+ }, false);
2985
+ } else {
2986
+ window.addEventListener("touchmove", eventMoveHandler, {
2987
+ passive: true
2988
+ });
2989
+ window.addEventListener("touchend", function eventEndHandler() {
2990
+ window.removeEventListener("touchmove", eventMoveHandler, false);
2991
+ window.removeEventListener("touchend", eventEndHandler);
2992
+ }, false);
2993
+ }
2994
+ };
2995
+ rotate.addEventListener("mousedown", function(e) {
2996
+ return handleRotate(e, "desk");
2997
+ }, false);
2998
+ rotate.addEventListener("touchstart", function(e) {
2999
+ return handleRotate(e, "touch");
3000
+ }, {
3001
+ passive: true
3002
+ });
3003
+ this.reset();
3004
+ return this;
3005
+ }
3006
+ }
3007
+ ]);
3008
+ return Transform;
3009
+ }();
1209
3010
  // Annotate the CommonJS export names for ESM import in node:
1210
3011
  0 && (module.exports = {
3012
+ Avatar: Avatar,
3013
+ Button: Button,
3014
+ Canvas: Canvas,
1211
3015
  ColorPickerSlider: ColorPickerSlider,
1212
3016
  DropdownSelect: DropdownSelect,
3017
+ Image: Image,
3018
+ ImageEditor: ImageEditor,
3019
+ ImageUtilities: ImageUtilities,
3020
+ InputFile: InputFile,
3021
+ InputGoogle: InputGoogle,
1213
3022
  MultiSelect: MultiSelect,
1214
3023
  OptionSlider: OptionSlider,
1215
- RangeSlider: RangeSlider
3024
+ RangeSlider: RangeSlider,
3025
+ TextArea: TextArea,
3026
+ Transform: Transform,
3027
+ UploadImage: UploadImage
1216
3028
  });