all files / base/ image-editor.js

89.03% Statements 2492/2799
66.18% Branches 916/1384
93.82% Functions 167/178
89% Lines 2483/2790
5 statements, 2 functions, 11 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030          64× 64× 64× 64×     324×                 323×                                 324×                         324×                 324×             324× 324× 324×   324×   324× 324× 324× 324× 324× 324× 324× 324× 324×             324× 324× 324×   324× 324× 324× 324× 324× 324× 324×   324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324×   324×   1412× 1412× 1412× 1412× 1412× 1412× 1412× 1412× 1412× 1412× 1412× 1412×   324× 324× 324×     324×   324×             324×   1604×       331× 331× 656× 656×                                                                                                                     324× 324×   324×           324× 324×     324×   324× 324× 324×         324×                                                                                                               310× 310× 310× 310×   310×   310× 310×     310× 310× 310× 310× 310×   324×       324×         323× 323×   324× 317×       324× 324× 324× 324×   324× 324× 322× 322×     322× 322× 322× 322× 322× 322×   322×   324×     323×   324× 324× 324× 324× 324× 324× 324× 324× 324×     324× 324×       324× 324×       324× 324× 324×                                                       324×                                                                     24× 24×     24× 16×                     24×   1006× 1006× 1006× 1006× 5921× 5921× 5921× 20707× 20707× 5921× 5921×       1006×   671× 671× 671× 671× 671× 3956×     657×     657×   3956×     1324× 667×   1324×   657× 657×   659× 659×   657× 657×   659× 659×   3956× 671×     671×   325× 325× 325× 325× 325× 325× 325× 325× 325× 325× 325× 325× 325× 325× 325× 325×   325×   311× 311× 311× 311× 311× 311× 311× 311× 311× 311× 311× 311× 311× 311× 311× 311×   311× 311×   324× 324× 324× 324× 324×   324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324× 324×     324× 324× 324× 324× 324× 324× 324× 324×     324×     324×     324×     324×     324×     324×     324× 324×     324× 324× 324× 324× 324× 324×   324×   324×   324× 324× 324× 324× 324×     324× 324× 324× 324×         324×                       255×     255×                                                     433× 433× 4330× 4330×     245× 245× 245× 245×   245×   398× 398×       143× 143× 143×   234× 234× 16×     218× 218× 218× 218× 218×   234× 234×   13× 13× 13× 11× 11× 11× 11×         13×   330× 330× 330× 330×     330× 330× 330×   330× 330× 330×                                                   321×             433× 433× 433× 433× 433× 433× 433× 433× 433× 433×   433×       433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433×     433×               433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 433× 100×   433× 433× 428×   433× 433× 433×   429× 428×   433× 433× 433× 433× 433× 433× 433× 433× 433× 428×   433× 433× 433× 433×     433× 433×     433× 433×     259× 259× 259× 19× 19×     240× 218×   240× 240× 240×   259× 259× 259×   18× 18×   100× 100× 100×   100× 18×       82×                   59×   16× 16×       16× 16× 16× 16× 16× 16× 16×   16×     2061× 2061×   146× 146× 146× 46× 46× 46×   146×         146×   146×   12× 12× 12× 12× 12× 12×   12×   12×   17× 17× 17× 12× 12× 12×   12×   17×           18×               52× 52× 52× 52× 52× 52×     52×   52×   144× 144× 144× 112× 112× 112×     112×   144×                                                                                                                   328× 328× 328× 328× 328× 328×         113× 113× 113×   113× 113× 113×   11×                         345×   40× 40× 40× 40× 40×     29× 29× 29× 29× 29× 29× 29×     34× 34× 34×   31× 31× 31×   19×   12× 12× 12× 12× 12× 12×   12×             12× 12× 12× 11× 11× 11× 11×   12× 12×   11× 11× 11× 11×   11×       12× 12×   12×                                 11× 11× 11× 11× 11× 11×   11×           19× 19×               19× 19× 19× 19×                           13×       13× 13× 13×                                                                                                                                       621× 621×   621×   458× 454×                                               99× 99× 99×   93×   83× 82×                                             458× 21×     437×                                                     3781× 123×   3658× 3658× 3658× 3658×   94×     22× 22× 22× 22× 19×     19× 19× 19×     22×                                                             18×   18×               483× 483× 20×   463× 223×   240× 135×   105× 105×   483× 356× 356× 175×   175× 175× 175×   175×       47× 47× 47× 47× 47× 47×       45×     47× 47× 47× 47× 47× 47× 47× 47×   125× 125×   2992× 2992× 2840×   2992× 3257×   2992×     2992×   439× 439× 439× 439× 335×     104×   439× 4390× 4390×   439×   667×     667× 667× 667× 667× 667× 667× 667× 667× 667×   658×   657×   667× 12×     655×     415× 166× 166×   166×   415× 415× 413×   415× 415× 415× 415× 415× 415× 415× 415× 312×   415×     415× 60×   415× 415× 262× 262× 262× 262× 24×   262× 262× 133×     133×   262× 262×     415× 14× 14× 14× 14× 14× 14× 14×     14× 14× 14× 14×   14×   14×   14× 14×   14×   14×         14× 14× 14×   14×                 14×   401×                             415× 415× 415× 415× 415× 415× 415×     415× 60×     60×   355× 24× 24× 23× 23× 23× 23×   24× 24×   331× 26×   26× 26× 26× 26×   26× 26×   305×           303×   299×   164× 14×   164×     135×                           135×   415× 415×   415×   415× 415× 415× 415× 415× 415× 415× 166× 166× 166×     3082× 3082× 3082× 244×   2838×       2838× 2838×   13× 13×             13×         55× 47×                       10× 10× 10× 10× 20×     20×     20× 20×   20× 10×     10× 10×   10×   413× 413×     413×   2837× 2837×   18× 18× 18× 18× 18×   18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18× 18×   18×     18×   18× 18× 18×         18× 18×             18× 18× 18×     18× 18× 18×   19× 19× 19× 19× 19× 19×   19× 19× 19× 19× 19× 19× 19× 19× 19× 19× 19× 19× 19×   19× 19× 19×   19×                       17×   17× 17×   17× 17×   17× 17× 17×           17×   19× 19× 19× 19×   13× 13× 13× 13× 13× 13× 13×   13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13× 13×   13× 13× 13×   13×                               12×   12× 12×   12× 12× 12× 12×   12× 12×   12×   12× 12×   12×   12×   12× 12× 12×           12×   13× 13× 13× 13×   12× 12× 12× 12× 12× 12×   12× 12× 12× 12× 12× 12× 12× 12× 12× 12× 12× 12×   12× 12× 12×   12× 11× 10× 10×           11× 11× 11× 11×         11×                                         12× 12× 12× 12×                                                                                                                                                                                                                                                                                                                                                         58× 58× 58×       90×     20× 20× 20× 20×         20×       20× 20×   20×         20×   20×   47×             47× 47× 47× 47× 47× 47× 47× 47× 47× 47× 47× 47× 47× 47×   47× 47×         47× 47× 47× 47× 47× 47× 47× 47× 47× 47× 47× 22× 22×   47×                         47× 47× 47× 45×     1188×       19× 19× 19× 19× 19× 19× 19×         19× 19× 19× 18×   19× 19× 19× 19×   19× 19×     19×                     16×   19×   19× 19× 19×   490× 165× 165×   165× 165×   165× 165×     165× 165× 165×               165× 165× 165× 165× 165× 165× 165× 165× 165× 165× 165× 165×     585× 585× 585× 585× 585× 585× 585× 585×                                           165× 165× 15× 17× 17×   13×   17×       165×   324× 324× 324×   324× 324×   324× 324×     324×                                                               65× 65× 65× 65×                                                                                                                                                                                          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* istanbul ignore next */ 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) Eif (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "@syncfusion/ej2-popups", "@syncfusion/ej2-base", "./../index", "./../index", "@syncfusion/ej2-inputs"], function (require, exports, ej2_base_1, ej2_base_2, ej2_popups_1, ej2_base_3, index_1, index_2, ej2_inputs_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var UploadSettings = (function (_super) {
        __extends(UploadSettings, _super);
        function UploadSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(null)
        ], UploadSettings.prototype, "allowedExtensions", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], UploadSettings.prototype, "minFileSize", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], UploadSettings.prototype, "maxFileSize", void 0);
        return UploadSettings;
    }(ej2_base_3.ChildProperty));
    exports.UploadSettings = UploadSettings;
    var FinetuneSettings = (function (_super) {
        __extends(FinetuneSettings, _super);
        function FinetuneSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "brightness", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "contrast", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "hue", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "saturation", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "exposure", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "opacity", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FinetuneSettings.prototype, "blur", void 0);
        return FinetuneSettings;
    }(ej2_base_3.ChildProperty));
    exports.FinetuneSettings = FinetuneSettings;
    var ZoomSettings = (function (_super) {
        __extends(ZoomSettings, _super);
        function ZoomSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(null)
        ], ZoomSettings.prototype, "zoomTrigger", void 0);
        __decorate([
            ej2_base_1.Property(1)
        ], ZoomSettings.prototype, "minZoomFactor", void 0);
        __decorate([
            ej2_base_1.Property(10)
        ], ZoomSettings.prototype, "maxZoomFactor", void 0);
        __decorate([
            ej2_base_1.Property(1)
        ], ZoomSettings.prototype, "zoomFactor", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ZoomSettings.prototype, "zoomPoint", void 0);
        return ZoomSettings;
    }(ej2_base_3.ChildProperty));
    exports.ZoomSettings = ZoomSettings;
    var SelectionSettings = (function (_super) {
        __extends(SelectionSettings, _super);
        function SelectionSettings() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(true)
        ], SelectionSettings.prototype, "showCircle", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], SelectionSettings.prototype, "strokeColor", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], SelectionSettings.prototype, "fillColor", void 0);
        return SelectionSettings;
    }(ej2_base_3.ChildProperty));
    exports.SelectionSettings = SelectionSettings;
    var FontFamily = (function (_super) {
        __extends(FontFamily, _super);
        function FontFamily() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property('Arial')
        ], FontFamily.prototype, "default", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], FontFamily.prototype, "items", void 0);
        return FontFamily;
    }(ej2_base_3.ChildProperty));
    exports.FontFamily = FontFamily;
    var ImageEditor = (function (_super) {
        __extends(ImageEditor, _super);
        function ImageEditor(options, element) {
            var _this = _super.call(this, options) || this;
            _this.isImageLoaded = false;
            _this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
                flipObjColl: [], triangle: [], triangleRatio: [], rotatedAngle: 0, opacity: 1, order: null };
            _this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false, isInitialLine: false,
                isCustomCrop: false, isZoomed: false, isUndoZoom: false, isUndoAction: false, isFiltered: false, isSave: false, isResize: false, isRedact: false };
            _this.objColl = [];
            _this.pointColl = {};
            _this.freehandCounter = 0;
            _this.points = [];
            _this.togglePen = false;
            _this.togglePan = false;
            _this.img = { destLeft: 0, destTop: 0, destWidth: 0, destHeight: 0, srcLeft: 0, srcTop: 0, srcWidth: 0, srcHeight: 0 };
            _this.rotateFlipColl = [];
            _this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
                totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
                degree: 0, currFlipState: '', straighten: 0, destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
                srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
                zoomFactor: 0, previousZoomValue: 0, aspectWidth: null, aspectHeight: null, frame: 'none', straightenZoom: 0,
                adjustmentLevel: { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
                    exposure: 0, transparency: 100, sharpen: false, bw: false }, currentFilter: '' };
            _this.afterCropActions = [];
            _this.transform = { degree: 0, currFlipState: '', zoomFactor: 0, cropZoomFactor: null, defaultZoomFactor: 0, straighten: 0 };
            _this.panPoint = { currentPannedPoint: { x: 0, y: 0 }, totalPannedPoint: { x: 0, y: 0 }, totalPannedInternalPoint: { x: 0, y: 0 },
                totalPannedClientPoint: { x: 0, y: 0 } };
            _this.isUndoRedo = false;
            _this.isCropTab = false;
            _this.isCircleCrop = false;
            _this.fontSizeColl = [];
            _this.initialAdjustmentValue = '';
            _this.currentFilter = '';
            _this.canvasFilter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
                'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
            _this.toolbarHeight = 0;
            _this.isPublicMethod = false;
            _this.isCropToolbar = false;
            _this.cursor = 'default';
            _this.resizeSrc = { startX: _this.img.srcLeft, startY: _this.img.srcTop, width: _this.img.srcWidth, height: _this.img.srcHeight };
            _this.isResize = false;
            _this.isAspectRatio = false;
            _this.frameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
            _this.tempFrameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
            _this.allowDownScale = true;
            _this.gradientColor = '';
            _this.size = 20;
            _this.inset = 0;
            _this.offset = 0;
            _this.borderRadius = 0;
            _this.lineCount = 0;
            _this.prevStraightenedDegree = 0;
            _this.tempStraighten = 0;
            _this.isStraightening = false;
            _this.isFinetuning = false;
            _this.isZoomBtnClick = false;
            _this.isFinetuneBtnClick = false;
            _this.isFilterCanvasClick = false;
            _this.isFrameBtnClick = false;
            _this.isChangesSaved = false;
            _this.isShapeDrawing = false;
            _this.noPushUndo = false;
            _this.isUndoRedoStack = false;
            _this.shapeColl = [];
            _this.isKBDNavigation = false;
            _this.isMaskImage = false;
            _this.tempObjColl = [];
            _this.tempPointColl = [];
            _this.tempShapeColl = [];
            _this.isImageUpdated = false;
            _this.noRedact = false;
            _this.tempRedactBlur = 50;
            _this.tempRedactPixel = 40;
            _this.imageSettings = { width: null, height: null };
            _this.aspectRatioBaseDimension = false;
            _this.imageLoaded = false;
            _this.tempToolbarHeight = 0;
            _this.tempToolbar = [];
            ImageEditor_1.Inject(index_1.Crop, index_1.Draw, index_1.Selection, index_1.Transform, index_1.Export, index_1.ToolbarModule);
            ImageEditor_1.Inject(index_1.UndoRedo);
            ImageEditor_1.Inject(index_1.Filter);
            ImageEditor_1.Inject(index_1.Shape);
            ImageEditor_1.Inject(index_1.FreehandDrawing);
            Eif (element) {
                _this.appendTo(element);
            }
            return _this;
        }
        ImageEditor_1 = ImageEditor;
        ImageEditor.prototype.requiredModules = function () {
            var modules = [];
            modules.push({ member: 'crop', args: [this] });
            modules.push({ member: 'draw', args: [this] });
            modules.push({ member: 'selection', args: [this] });
            modules.push({ member: 'transform', args: [this] });
            modules.push({ member: 'export', args: [this] });
            modules.push({ member: 'toolbar-module', args: [this] });
            modules.push({ member: 'undo-redo', args: [this] });
            modules.push({ member: 'filter', args: [this] });
            modules.push({ member: 'shape', args: [this] });
            modules.push({ member: 'freehand-draw', args: [this] });
            return modules;
        };
        ImageEditor.prototype.preRender = function () {
            this.element.id = this.element.id || ej2_base_2.getUniqueID('ej2-image-editor');
            this.isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
            Iif (ej2_base_3.Browser.isDevice) {
                this.element.classList.add('e-device');
            }
            this.initializeThemeColl();
        };
        ImageEditor.prototype.render = function () {
            Iif (this.isAngular) {
                var originalElement = this.element;
                var clonedElement = originalElement.cloneNode(true);
                originalElement.parentNode.replaceChild(clonedElement, originalElement);
                this.element = clonedElement;
                ej2_base_2.setValue('ej2_instances', [this], this.element);
            }
            this.initialize();
        };
        ImageEditor.prototype.getModuleName = function () {
            return 'image-editor';
        };
        ImageEditor.prototype.getPersistData = function () {
            return this.addOnPersist([]);
        };
        ImageEditor.prototype.onPropertyChanged = function (newProperties, oldProperties) {
            var indexObj;
            for (var _i = 0, _a = Object.keys(newProperties); _i < _a.length; _i++) {
                var prop = _a[_i];
                switch (prop) {
                    case 'cssClass':
                        if (oldProperties.cssClass) {
                            ej2_base_1.removeClass([this.element], oldProperties.cssClass.replace(/\s+/g, ' ').trim().split(' '));
                        }
                        Eif (newProperties.cssClass) {
                            ej2_base_1.addClass([this.element], newProperties.cssClass.replace(/\s+/g, ' ').trim().split(' '));
                        }
                        break;
                    case 'disabled':
                        if (newProperties.disabled) {
                            this.element.classList.add('e-disabled', 'e-overlay');
                            this.element.style.opacity = '0.5';
                            this.unwireEvent();
                        }
                        else {
                            this.element.classList.remove('e-disabled', 'e-overlay');
                            this.element.style.opacity = '1';
                            this.wireEvent();
                        }
                        break;
                    case 'height':
                        this.element.style.height = newProperties.height;
                        this.update();
                        break;
                    case 'width':
                        this.element.style.width = newProperties.width;
                        this.update();
                        break;
                    case 'theme':
                        Eif (newProperties.theme) {
                            Eif (this.theme && this.theme !== '') {
                                this.theme = this.toPascalCase(this.theme);
                            }
                            else {
                                this.theme = 'Bootstrap5';
                            }
                            this.upperContext.strokeStyle = this.themeColl[this.theme]['primaryColor'];
                            this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
                            this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                    isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        }
                        break;
                    case 'finetuneSettings':
                        if (newProperties.finetuneSettings) {
                            this.finetuneSettings = newProperties.finetuneSettings;
                            this.notify('filter', { prop: 'update-finetunes' });
                        }
                        break;
                    case 'locale':
                        if (newProperties.locale) {
                            this.notify('toolbar', { prop: 'setLocale', onPropertyChange: false, value: { locale: newProperties.locale } });
                            this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                    isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        }
                        break;
                    case 'allowUndoRedo':
                        if (newProperties.allowUndoRedo) {
                            this.allowUndoRedo = true;
                        }
                        else {
                            this.allowUndoRedo = false;
                        }
                        this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        break;
                    case 'showQuickAccessToolbar':
                        if (newProperties.showQuickAccessToolbar) {
                            this.showQuickAccessToolbar = true;
                            this.notify('toolbar', { prop: 'create-qa-toolbar', onPropertyChange: false });
                            indexObj = { freehandSelectedIndex: null };
                            this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
                            if (this.activeObj.shape) {
                                this.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
                            }
                            else if (indexObj['freehandSelectedIndex']) {
                                this.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
                            }
                        }
                        else {
                            this.showQuickAccessToolbar = false;
                            this.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                        }
                        break;
                    case 'zoomSettings':
                        Eif (newProperties.zoomSettings) {
                            this.zoomSettings.zoomTrigger = newProperties.zoomSettings.zoomTrigger;
                        }
                        Iif (ej2_base_2.isNullOrUndefined(this.zoomSettings.zoomTrigger)) {
                            this.zoomSettings.zoomTrigger = (index_2.ZoomTrigger.MouseWheel | index_2.ZoomTrigger.Pinch | index_2.ZoomTrigger.Toolbar |
                                index_2.ZoomTrigger.Commands);
                            this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                    isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        }
                        else Eif ((newProperties.zoomSettings.zoomTrigger & index_2.ZoomTrigger.Toolbar) === index_2.ZoomTrigger.Toolbar) {
                            this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                    isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        }
                        break;
                    case 'selectionSettings':
                        Eif (newProperties.selectionSettings) {
                            this.selectionSettings = newProperties.selectionSettings;
                            Iif (this.activeObj.shape) {
                                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                                this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: this.activeObj } });
                            }
                        }
                        break;
                    case 'toolbar':
                        if (newProperties.toolbar) {
                            this.toolbar = newProperties.toolbar;
                            this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                    isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        }
                        break;
                    case 'toolbarTemplate':
                        if (newProperties.toolbarTemplate) {
                            this.notify('toolbar', { prop: 'destroy-bottom-toolbar', onPropertyChange: false });
                            this.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
                            this.element.appendChild(this.createElement('div', {
                                id: this.element.id + '_toolbarArea', className: 'e-toolbar-area'
                            }));
                            this.toolbarTemplateFn();
                        }
                        break;
                    case 'quickAccessToolbarTemplate':
                        if (newProperties.quickAccessToolbarTemplate) {
                            this.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
                            this.quickAccessToolbarTemplateFn();
                        }
                        break;
                    case 'uploadSettings':
                        if (newProperties.uploadSettings) {
                            this.uploadSettings = newProperties.uploadSettings;
                            if (!this.uploadSettings.allowedExtensions) {
                                this.uploadSettings.allowedExtensions = '.jpg, .jpeg, .png, .svg, .webp, .bmp';
                                this.notify('draw', { prop: 'setNullExtension', value: { extension: true } });
                            }
                            else {
                                this.notify('draw', { prop: 'setNullExtension', value: { extension: false } });
                            }
                            this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                                    isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                        }
                        else {
                            this.notify('draw', { prop: 'setNullExtension', value: { extension: true } });
                        }
                        this.updateDropInfoContent(this.element.querySelector('.e-ie-drop-info'));
                        break;
                    case 'imageSmoothingEnabled':
                        if (newProperties.imageSmoothingEnabled) {
                            this.imageSmoothingEnabled = true;
                            this.lowerContext.imageSmoothingQuality = 'high';
                        }
                        else {
                            this.imageSmoothingEnabled = false;
                            this.lowerContext.imageSmoothingQuality = 'low';
                        }
                        this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                        break;
                }
            }
        };
        ImageEditor.prototype.destroy = function () {
            var classList = [];
            this.element.removeAttribute('tabindex');
            var saveDialog = this.element.querySelector('#' + this.element.id + '_saveDialog');
            if (saveDialog && saveDialog.style.display === 'block') {
                ej2_base_2.getComponent(document.getElementById(this.element.id + '_saveDialog'), 'dialog').destroy();
            }
            if (this.cssClass) {
                classList = classList.concat(this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
            }
            ej2_base_1.removeClass([this.element], classList);
            Iif (!this.element.getAttribute('class')) {
                this.element.removeAttribute('class');
            }
            this.unwireEvent();
            this.notify('toolbar', { prop: 'destroySubComponents', onPropertyChange: false });
            this.notify('destroyed', null);
            _super.prototype.destroy.call(this);
            this.element.innerHTML = '';
        };
        ImageEditor.prototype.initialize = function () {
            Iif (this.disabled) {
                this.element.classList.add('e-disabled', 'e-overlay');
                this.element.style.opacity = '0.5';
            }
            if (this.toolbarTemplate) {
                this.element.appendChild(this.createElement('div', {
                    id: this.element.id + '_toolbarArea', className: 'e-toolbar-area'
                }));
                this.toolbarTemplateFn();
            }
            else {
                this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
                this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
            }
            if (!this.uploadSettings.allowedExtensions) {
                this.setProperties({ uploadSettings: { allowedExtensions: '.jpg, .jpeg, .png, .svg, .webp, .bmp' } }, true);
            }
            else {
                this.notify('draw', { prop: 'setNullExtension', value: { extension: false } });
            }
            this.createCanvas();
            Eif (this.element.offsetWidth > 359 && this.element.querySelector('.e-ie-min-drop-content') && this.element.querySelector('.e-ie-drop-content')) {
                this.element.querySelector('.e-ie-min-drop-content').style.display = 'none';
                this.element.querySelector('.e-ie-drop-content').style.display = 'block';
            }
            this.createDropUploader();
            if (this.showQuickAccessToolbar) {
                var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
                canvasWrapper.appendChild(this.createElement('div', {
                    id: this.element.id + '_quickAccessToolbarArea', className: 'e-quick-access-toolbar-area'
                }));
                var quickAccessToolbar = document.getElementById(this.element.id + '_quickAccessToolbarArea');
                quickAccessToolbar.style.position = 'absolute';
                quickAccessToolbar.style.display = 'none';
                Eif (this.activeObj) {
                    quickAccessToolbar.style.left = this.activeObj.activePoint.startX + 'px';
                    quickAccessToolbar.style.top = this.activeObj.activePoint.startY + 'px';
                }
                quickAccessToolbar.style.width = '100%';
            }
            if (this.quickAccessToolbarTemplate) {
                this.quickAccessToolbarTemplateFn();
            }
            else {
                this.notify('toolbar', { prop: 'create-qa-toolbar', onPropertyChange: false });
            }
            this.wireEvent();
            this.lowerContext = this.lowerCanvas.getContext('2d');
            this.upperContext = this.upperCanvas.getContext('2d');
            this.inMemoryContext = this.inMemoryCanvas.getContext('2d');
            this.lowerContext.filter = this.getDefaultFilter();
            this.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.lowerContext.filter } });
            this.canvasFilter = this.lowerContext.filter;
            this.notify('toolbar', { prop: 'setInitialAdjustmentValue', onPropertyChange: false, value: { value: this.lowerContext.filter } });
            Iif (this.cssClass) {
                ej2_base_1.addClass([this.element], this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
            }
            Eif (this.element) {
                ej2_popups_1.createSpinner({
                    target: this.element
                });
            }
            this.initializeZoomSettings();
            Iif (this.imgSrc) {
                this.open(this.imgSrc);
            }
        };
        ImageEditor.prototype.createDropUploader = function () {
            var _this = this;
            var proxy = this;
            var uploadObj = new ej2_inputs_1.Uploader({
                dropArea: this.element.getElementsByClassName('e-canvas-wrapper')[0],
                allowedExtensions: this.uploadSettings.allowedExtensions,
                multiple: false,
                selected: function (args) {
                    if (args.event.type === 'change' || args.event.type === 'drop') {
                        var type = args.filesData[0].type;
                        var errType = 'unsupported';
                        var extension = _this.getExtensionArray();
                        var isAllowedFileType = (extension.indexOf(type) > -1 ||
                            (type === 'jpeg' && (proxy.uploadSettings.allowedExtensions.indexOf('jpg') > -1 ||
                                proxy.uploadSettings.allowedExtensions.indexOf('jpeg') > -1)));
                        var size = args.filesData[0].size;
                        var isInvalidSize = (proxy.uploadSettings.minFileSize && size < proxy.uploadSettings.minFileSize) ||
                            (proxy.uploadSettings.maxFileSize && size > proxy.uploadSettings.maxFileSize);
                        if ((args.event.type === 'change' || (args.event.type === 'drop' && args.event.dataTransfer.files.length === 1)) && isAllowedFileType &&
                            !isInvalidSize) {
                            _this.notify('draw', { prop: 'fileSelect', value: { inputElement: _this.element.querySelector('#' + _this.element.id + '_dropfileUpload'), args: args } });
                        }
                        else {
                            if (args.event.type === 'drop' && args.event.dataTransfer.files.length > 1) {
                                errType = 'multi-select-image';
                            }
                            _this.showDialogPopup(errType, !isAllowedFileType);
                        }
                    }
                }
            });
            uploadObj.appendTo('#' + this.element.id + '_dropfileUpload');
        };
        ImageEditor.prototype.dlgCloseBtnClick = function () {
            ej2_base_2.getComponent(document.getElementById(this.element.id + '_dialog'), 'dialog').destroy();
        };
        ImageEditor.prototype.showDialogPopup = function (type, fileTypeError) {
            var content = '';
            this.element.querySelector('#' + this.element.id + '_dialog').style.display = 'block';
            var headerObj;
            var okObj = { key: 'DlgOK' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: okObj } });
            Iif (type === 'multi-select-image') {
                headerObj = { key: 'ImageErrorDialogHeader' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: headerObj } });
                var contentObj = { key: 'ImageErrorDialogContent' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
                content = '<span>' + contentObj['value'] + '</span>';
            }
            else {
                headerObj = { key: 'AlertDialogHeader' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: headerObj } });
                var contentObj = { key: 'AlertDialogContent' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
                var supportObj = { key: 'SupportText' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
                var extension = this.getExtensionString();
                var fileSizeObj = { key: 'MinMaxSizeAlert' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
                var andObj = { key: 'And' };
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
                var size = void 0;
                if (this.uploadSettings.minFileSize && this.uploadSettings.maxFileSize) {
                    size = ' ' + fileSizeObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.minFileSize) + ' </b> ' + andObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.maxFileSize) + ' </b> ';
                }
                else if (this.uploadSettings.minFileSize) {
                    fileSizeObj['key'] = 'MinSizeAlert';
                    this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
                    size = ' ' + fileSizeObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.minFileSize) + ' </b> ';
                }
                else Iif (this.uploadSettings.maxFileSize) {
                    fileSizeObj['key'] = 'MaxSizeAlert';
                    this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
                    size = ' ' + fileSizeObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.maxFileSize) + ' </b> ';
                }
                if (fileTypeError) {
                    content = '<span>' + contentObj['value'] + ' ' + supportObj['value'] + '<b>' + extension + '</b>' + '</span>';
                }
                else Eif (size) {
                    content = '<span>' + contentObj['value'] + ' ' + supportObj['value'] + size + '</span>';
                }
            }
            var dialog = new ej2_popups_1.Dialog({
                header: headerObj['value'],
                closeOnEscape: true,
                content: content,
                target: document.getElementById('target'),
                width: ej2_base_3.Browser.isDevice ? '285px' : '400px',
                isModal: true,
                animationSettings: { effect: 'Zoom' },
                close: this.dlgCloseBtnClick.bind(this),
                buttons: [
                    { click: this.dlgCloseBtnClick.bind(this),
                        buttonModel: { content: okObj['value'] }
                    }
                ]
            });
            dialog.appendTo('#' + this.element.id + '_dialog');
        };
        ImageEditor.prototype.formatSizeUnits = function (bytes) {
            var byte = '';
            Iif (bytes >= 1073741824) {
                byte = (bytes / 1073741824).toFixed(2) + ' GB';
            }
            else if (bytes >= 1048576) {
                byte = (bytes / 1048576).toFixed(2) + ' MB';
            }
            else Iif (bytes >= 1024) {
                byte = (bytes / 1024).toFixed(2) + ' KB';
            }
            else Eif (bytes > 1) {
                byte = bytes + ' bytes';
            }
            else if (bytes === 1) {
                byte = bytes + ' byte';
            }
            else {
                byte = '0 bytes';
            }
            return byte;
        };
        ImageEditor.prototype.getExtensionArray = function () {
            var validExtensions = ['jpeg', 'jpg', 'png', 'svg', 'webp', 'bmp'];
            var split = this.uploadSettings.allowedExtensions.split(',');
            var extension = [];
            for (var _i = 0, split_1 = split; _i < split_1.length; _i++) {
                var ext = split_1[_i];
                var trimmedExt = ext.trim();
                for (var _a = 0, validExtensions_1 = validExtensions; _a < validExtensions_1.length; _a++) {
                    var valid = validExtensions_1[_a];
                    if (trimmedExt.indexOf(valid) !== -1) {
                        extension.push(valid);
                        break;
                    }
                }
            }
            return extension;
        };
        ImageEditor.prototype.getExtensionString = function () {
            var andObj = { key: 'And' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
            var extension = this.getExtensionArray();
            var words = '';
            for (var i = 0; i < extension.length; i++) {
                if (i === extension.length - 1 && extension.length > 1 &&
                    !((extension[i] === 'jpeg' || extension[i] === 'jpg') &&
                        (words.indexOf('JPG') > -1))) {
                    Iif (extension.length === 2 || (extension.length === 3 && extension.indexOf('jpeg') !== -1 && extension.indexOf('jpg') !== -1)) {
                        words = words.replace(/,\s*$/, '');
                    }
                    words += ' ' + andObj['value'];
                }
                switch (extension[i]) {
                    case 'jpeg':
                    case 'jpg':
                        if (words.indexOf('JPG') === -1) {
                            words += ' JPG,';
                        }
                        break;
                    case 'png':
                        words += ' PNG,';
                        break;
                    case 'svg':
                        words += ' SVG,';
                        break;
                    case 'webp':
                        words += ' WebP,';
                        break;
                    case 'bmp':
                        words += ' BMP,';
                        break;
                }
                if (i === extension.length - 1) {
                    words = words.slice(0, -1);
                }
            }
            return words;
        };
        ImageEditor.prototype.wireEvent = function () {
            ej2_base_2.EventHandler.add(document, 'keydown', this.keyDownEventHandler, this);
            ej2_base_2.EventHandler.add(document, 'keypress', this.keyUpEventHandler, this);
            ej2_base_2.EventHandler.add(this.upperCanvas, 'mousedown', this.mouseDownEventHandler, this);
            ej2_base_2.EventHandler.add(this.upperCanvas, 'mousemove', this.mouseMoveEventHandler, this);
            ej2_base_2.EventHandler.add(this.upperCanvas, 'mouseup', this.mouseUpEventHandler, this);
            ej2_base_2.EventHandler.add(document, 'mouseup', this.mouseUpEventHandler, this);
            ej2_base_2.EventHandler.add(this.lowerCanvas, 'mousedown', this.canvasMouseDownHandler, this);
            ej2_base_2.EventHandler.add(this.lowerCanvas, 'mousemove', this.canvasMouseMoveHandler, this);
            ej2_base_2.EventHandler.add(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler, this);
            ej2_base_2.EventHandler.add(this.upperCanvas, 'touchstart', this.touchStartHandler, this);
            ej2_base_2.EventHandler.add(this.lowerCanvas, 'touchstart', this.touchStartHandler, this);
            ej2_base_2.EventHandler.add(this.lowerCanvas, 'mousewheel DOMMouseScroll', this.handleScroll, this);
            ej2_base_2.EventHandler.add(this.upperCanvas, 'mousewheel DOMMouseScroll', this.handleScroll, this);
            window.addEventListener('resize', this.windowResizeHandler.bind(this));
            Eif ((!ej2_base_3.Browser.isIos && ej2_base_3.Browser.info.name !== 'safari')) {
                screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
            }
            this.notify('shape', { prop: 'wireEvent', onPropertyChange: false });
        };
        ImageEditor.prototype.unwireEvent = function () {
            ej2_base_2.EventHandler.remove(document, 'keydown', this.keyDownEventHandler);
            ej2_base_2.EventHandler.remove(document, 'keypress', this.keyUpEventHandler);
            ej2_base_2.EventHandler.remove(this.upperCanvas, 'mousedown', this.mouseDownEventHandler);
            ej2_base_2.EventHandler.remove(this.upperCanvas, 'mousemove', this.mouseMoveEventHandler);
            ej2_base_2.EventHandler.remove(this.upperCanvas, 'mouseup', this.mouseUpEventHandler);
            ej2_base_2.EventHandler.remove(document, 'mouseup', this.mouseUpEventHandler);
            ej2_base_2.EventHandler.remove(this.lowerCanvas, 'mousedown', this.canvasMouseDownHandler);
            ej2_base_2.EventHandler.remove(this.lowerCanvas, 'mousemove', this.canvasMouseMoveHandler);
            ej2_base_2.EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
            ej2_base_2.EventHandler.remove(this.upperCanvas, 'touchstart', this.touchStartHandler);
            ej2_base_2.EventHandler.remove(this.lowerCanvas, 'touchstart', this.touchStartHandler);
            ej2_base_2.EventHandler.remove(this.lowerCanvas, 'mousewheel DOMMouseScroll', this.handleScroll);
            ej2_base_2.EventHandler.remove(this.upperCanvas, 'mousewheel DOMMouseScroll', this.handleScroll);
            window.removeEventListener('resize', this.windowResizeHandler.bind(this));
            Eif ((!ej2_base_3.Browser.isIos && ej2_base_3.Browser.info.name !== 'safari')) {
                screen.orientation.removeEventListener('change', this.screenOrientation.bind(this));
            }
            this.notify('shape', { prop: 'unWireEvent', onPropertyChange: false });
            this.notify('selection', { prop: 'unWireEvent', onPropertyChange: false });
        };
        ImageEditor.prototype.createCanvas = function () {
            this.element.style.boxSizing = 'border-box';
            var obj = { toolbarHeight: 0 };
            this.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: obj } });
            var height = obj['toolbarHeight'];
            if (this.toolbar && this.toolbar.length > 0 && this.toolbar.indexOf('Open') === -1) {
                height = 0;
            }
            this.element.style.width = this.width;
            this.element.style.height = this.height;
            var canvasWrapperElement = this.createElement('div', { id: this.element.id + '_canvasWrapper', className: 'e-canvas-wrapper' });
            canvasWrapperElement.style.cssText = "height: " + (this.element.offsetHeight - height - 2) + "px; width: " + (this.element.offsetWidth - 2) + "px; position: relative; overflow: hidden; margin: 0 auto;";
            var canvasWrapper = this.element.appendChild(canvasWrapperElement);
            var dragObj = { key: 'DragText' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: dragObj } });
            var dropObj = { key: 'DropText' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: dropObj } });
            var browseObj = { key: 'BrowseText' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: browseObj } });
            var dropAreaElement = this.createElement('div', { id: this.element.id + '_dropArea', className: 'e-ie-drop-area' });
            dropAreaElement.style.position = 'relative';
            var dropIconElement = this.createElement('span', { className: 'e-ie-drop-icon e-icons e-image' });
            var dropContentElement = this.createElement('span', { className: 'e-ie-drop-content' });
            dropContentElement.style.cssText = 'display: none;';
            dropContentElement.textContent = dragObj['value'] + ' ';
            var minDropContentElem = this.createElement('span', { className: 'e-ie-min-drop-content' });
            minDropContentElem.textContent = dropObj['value'] + ' ';
            var dropAnchorElement = this.createElement('a', { id: this.element.id + '_dropBrowse', className: 'e-ie-drop-browse' });
            dropAnchorElement.textContent = browseObj['value'];
            var minDropAnchorElem = this.createElement('a', { id: this.element.id + '_dropBrowse', className: 'e-ie-drop-browse' });
            minDropAnchorElem.textContent = browseObj['value'];
            dropContentElement.appendChild(dropAnchorElement);
            minDropContentElem.appendChild(minDropAnchorElem);
            dropAnchorElement.href = '';
            minDropAnchorElem.href = '';
            var dropInfoElement = this.createElement('span', { className: 'e-ie-drop-info' });
            this.updateDropInfoContent(dropInfoElement);
            var dropUploader = dropAreaElement.appendChild(this.createElement('input', {
                id: this.element.id + '_dropfileUpload', className: 'e-fileUpload e-image-upload'
            }));
            dropUploader.setAttribute('type', 'file');
            dropUploader.setAttribute('accept', 'image/*');
            dropAreaElement.appendChild(dropIconElement);
            dropAreaElement.appendChild(dropContentElement);
            dropAreaElement.appendChild(minDropContentElem);
            dropAreaElement.appendChild(dropInfoElement);
            canvasWrapper.appendChild(dropAreaElement);
            this.lowerCanvas = canvasWrapper.appendChild(this.createElement('canvas', {
                id: this.element.id + '_lowerCanvas', attrs: { name: 'canvasImage' }
            }));
            this.maskCanvas = canvasWrapper.appendChild(this.createElement('canvas', {
                id: this.element.id + '_maskCanvas', attrs: { name: 'canvasImage' }
            }));
            this.upperCanvas = canvasWrapper.appendChild(this.createElement('canvas', {
                id: this.element.id + '_upperCanvas', attrs: { name: 'canvasImage' }
            }));
            this.inMemoryCanvas = this.createElement('canvas', {
                id: this.element.id + '_inMemoryCanvas', attrs: { name: 'canvasImage' }
            });
            this.baseImgCanvas = this.createElement('canvas', {
                id: this.element.id + '_baseImgCanvas', attrs: { name: 'canvasImage' }
            });
            this.textArea = canvasWrapper.appendChild(this.createElement('textarea', {
                id: this.element.id + '_textArea', className: 'e-textarea', attrs: { name: 'textArea' }
            }));
            var dialog = this.element.appendChild(this.createElement('div', {
                id: this.element.id + '_dialog', className: 'e-dialog'
            }));
            dialog.style.display = 'none';
            var uploader = this.element.appendChild(this.createElement('input', {
                id: this.element.id + '_fileUpload', className: 'e-fileUpload'
            }));
            uploader.setAttribute('type', 'file');
            uploader.setAttribute('accept', 'image/*');
            uploader.style.display = 'none';
            this.textArea.setAttribute('spellcheck', 'false');
            this.textArea.style.lineHeight = 'normal';
            this.lowerCanvas.style.width = this.upperCanvas.style.width = this.maskCanvas.style.width =
                this.inMemoryCanvas.style.width = '100%';
            this.lowerCanvas.style.height = this.upperCanvas.style.height = this.maskCanvas.style.height =
                this.inMemoryCanvas.style.height = '100%';
            this.upperCanvas.style.position = this.lowerCanvas.style.position = this.maskCanvas.style.position =
                this.textArea.style.position = 'absolute';
            this.textArea.style.backgroundColor = 'transparent';
            this.textArea.style.display = 'none';
            this.maskCanvas.style.display = this.textArea.style.resize = 'none';
            this.lowerContext = this.lowerCanvas.getContext('2d');
            this.baseImg = this.createElement('img', {
                id: this.element.id + '_orgImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
            });
            this.upperCanvas.style.cursor = this.cursor = 'default';
            this.upperCanvas.style.display = 'block';
            this.upperContext = this.upperCanvas.getContext('2d');
            dropAnchorElement.addEventListener('click', function (e) {
                e.preventDefault();
                dropUploader.click();
                return false;
            });
            minDropAnchorElem.addEventListener('click', function (e) {
                e.preventDefault();
                dropUploader.click();
                return false;
            });
        };
        ImageEditor.prototype.touchStartHandler = function (e) {
            this.notify('selection', { prop: 'touchStartHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.mouseDownEventHandler = function (e) {
            Iif (e.target.className === 'e-ie-drop-browse') {
                return;
            }
            this.notify('selection', { prop: 'mouseDownEventHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.mouseMoveEventHandler = function (e) {
            this.notify('selection', { prop: 'mouseMoveEventHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.mouseUpEventHandler = function (e) {
            Iif (e.target.className === 'e-ie-drop-browse') {
                return;
            }
            this.notify('selection', { prop: 'mouseUpEventHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.keyDownEventHandler = function (e) {
            this.notify('selection', { prop: 'keyDownEventHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.keyUpEventHandler = function (e) {
            if ((this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block')
                && e.target.id === this.element.id + '_textArea') {
                this.notify('selection', { prop: 'textKeyDown', value: { e: e } });
            }
        };
        ImageEditor.prototype.canvasMouseDownHandler = function (e) {
            Iif (e.target.className === 'e-ie-drop-browse') {
                return;
            }
            this.notify('selection', { prop: 'canvasMouseDownHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
            this.notify('selection', { prop: 'canvasMouseMoveHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.canvasMouseUpHandler = function (e) {
            Iif (e.target.className === 'e-ie-drop-browse') {
                return;
            }
            this.notify('selection', { prop: 'canvasMouseUpHandler', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.handleScroll = function (e) {
            this.notify('selection', { prop: 'handleScroll', onPropertyChange: false, value: { e: e } });
        };
        ImageEditor.prototype.adjustToScreen = function () {
            this.update();
        };
        ImageEditor.prototype.screenOrientation = function () {
            if (ej2_base_3.Browser.isDevice) {
                setTimeout(this.adjustToScreen.bind(this), 100);
            }
        };
        ImageEditor.prototype.windowResizeHandler = function () {
            if (!ej2_base_3.Browser.isDevice && this.element.classList.contains('e-image-editor')) {
                this.adjustToScreen();
            }
        };
        ImageEditor.prototype.notifyResetForAllModules = function () {
            var modules = this.requiredModules();
            for (var i = 0; i < modules.length; i++) {
                var module = modules[i].member;
                this.notify(module === 'toolbar-module' ? 'toolbar' : module, { prop: 'reset', onPropertyChange: false });
            }
        };
        ImageEditor.prototype.allowShape = function (x, y) {
            this.isPublicMethod = true;
            this.applyShapes();
            var obj = { inRange: false };
            this.notify('shape', { prop: 'isPointsInRange', onPropertyChange: false,
                value: { x: x, y: y, obj: obj } });
            return obj['inRange'];
        };
        ImageEditor.prototype.manageActiveAction = function () {
            this.applyShapes();
            if (this.activeObj.shape && this.activeObj.shape.indexOf('crop') > -1) {
                this.discard();
            }
        };
        ImageEditor.prototype.clearSelection = function (resetCrop) {
            this.notify('selection', { prop: 'clearSelection', onPropertyChange: false, value: { resetCrop: resetCrop } });
        };
        ImageEditor.prototype.crop = function () {
            var obj = { isCrop: false };
            this.notify('crop', { prop: 'crop', onPropertyChange: false, value: { obj: obj } });
            return obj['isCrop'];
        };
        ImageEditor.prototype.flip = function (direction) {
            this.applyShapes();
            if (this.activeObj.shape && this.activeObj.shape.indexOf('crop') > -1) {
                this.transformSelect(direction.toLowerCase() + 'flip');
            }
            else {
                this.updateImageTransformColl(direction.toLowerCase() + 'flip');
                this.setRotateZoom();
                this.notify('transform', { prop: 'flip', value: { direction: direction } });
                this.notify('draw', { prop: 'redrawDownScale' });
                this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
            }
            var actionArgs = { action: 'flip', actionEventArgs: this.editCompleteArgs };
            this.triggerEditCompleteEvent(actionArgs);
        };
        ImageEditor.prototype.getImageData = function (includeAnnotations) {
            includeAnnotations = ej2_base_2.isNullOrUndefined(includeAnnotations) ? true : includeAnnotations;
            var imageData;
            if (includeAnnotations) {
                var obj = { canvas: null };
                this.applyShapes();
                this.notify('export', { prop: 'exportToCanvas', value: { object: obj } });
                imageData = obj['canvas'].getContext('2d').getImageData(0, 0, obj['canvas'].width, obj['canvas'].height);
            }
            else if (this.isMaskImage && this.element.getAttribute('data-value') === 'mask-drawing') {
                imageData = this.getData(true);
                this.updateColl('reset');
            }
            else {
                imageData = this.getData();
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
            }
            return imageData;
        };
        ImageEditor.prototype.open = function (data, resetChanges, imageSettings) {
            var _this = this;
            resetChanges = ej2_base_2.isNullOrUndefined(resetChanges) ? true : resetChanges;
            Eif (resetChanges) {
                Iif (ej2_base_2.isNullOrUndefined(data) || this.disabled) {
                    return;
                }
                var dropArea = document.getElementById(this.element.id + '_dropArea');
                Eif (dropArea) {
                    dropArea.style.display = 'none';
                }
                this.imageSettings = { width: null, height: null };
                this.aspectRatioBaseDimension = null;
                if (imageSettings && (imageSettings.width || imageSettings.height)) {
                    var tempImageSettings_1 = ej2_base_1.extend({}, imageSettings, {}, true);
                    imageSettings = this.scaleToFit(imageSettings);
                    this.aspectRatioBaseDimension = imageSettings.isAspectRatio;
                    if (!imageSettings.isAspectRatio && imageSettings.width && imageSettings.height) {
                        this.imageSettings.width = imageSettings.width;
                        this.imageSettings.height = imageSettings.height;
                        this.notify('draw', { prop: 'open', value: { data: data } });
                        var intervalId_1 = setInterval(function () {
                            if (_this.imageLoaded && _this.baseImg.width && _this.baseImg.height) {
                                _this.setInitialZoomLevel(tempImageSettings_1);
                                clearInterval(intervalId_1);
                            }
                        }, 1);
                    }
                    else Eif (imageSettings.width || imageSettings.height) {
                        this.notify('draw', { prop: 'open', value: { data: data } });
                        var intervalId_2 = setInterval(function () {
                            Eif (_this.imageLoaded && _this.baseImg.width && _this.baseImg.height) {
                                _this.imageSettings.width = imageSettings.width;
                                _this.imageSettings.height = imageSettings.height;
                                var originalWidth = _this.baseImg.width;
                                var originalHeight = _this.baseImg.height;
                                var maxValue = '';
                                var aspectRatioValue = void 0;
                                var value = void 0;
                                var newValue = void 0;
                                if (imageSettings.width && imageSettings.height) {
                                    maxValue = imageSettings.width > imageSettings.height ? 'width' : 'height';
                                }
                                if (maxValue === 'width' || (imageSettings.width && maxValue !== 'height')) {
                                    aspectRatioValue = imageSettings.width;
                                    value = aspectRatioValue / (originalWidth / originalHeight);
                                    newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
                                    Eif (!imageSettings.height || newValue > imageSettings.height) {
                                        _this.imageSettings.height = imageSettings.height = newValue;
                                    }
                                    else {
                                        aspectRatioValue = imageSettings.height;
                                        value = aspectRatioValue / (originalHeight / originalWidth);
                                        newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
                                        _this.imageSettings.width = imageSettings.width = newValue;
                                    }
                                }
                                else Eif (maxValue === 'height' || (imageSettings.height && maxValue !== 'width')) {
                                    aspectRatioValue = imageSettings.height;
                                    value = aspectRatioValue / (originalHeight / originalWidth);
                                    newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
                                    Eif (!imageSettings.width || newValue > imageSettings.width) {
                                        _this.imageSettings.width = imageSettings.width = newValue;
                                    }
                                    else {
                                        aspectRatioValue = imageSettings.width;
                                        value = aspectRatioValue / (originalWidth / originalHeight);
                                        newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
                                        _this.imageSettings.height = imageSettings.height = newValue;
                                    }
                                }
                                _this.notify('draw', { prop: 'open', value: { data: data } });
                                _this.setInitialZoomLevel(tempImageSettings_1);
                                clearInterval(intervalId_2);
                            }
                        }, 1);
                    }
                }
                else {
                    this.notify('draw', { prop: 'open', value: { data: data } });
                }
            }
            else {
                this.updateImage(data, imageSettings ? imageSettings.backgroundColor : null);
            }
        };
        ImageEditor.prototype.reset = function () {
            this.updateColl('reset');
            var obj = { isErrorImage: false };
            this.notify('draw', { prop: 'getErrorImage', value: { obj: obj } });
            Eif (!this.disabled && !obj['isErrorImage']) {
                this.clearContext(this.inMemoryContext);
                this.clearContext(this.lowerContext);
                this.clearContext(this.upperContext);
                this.notify('shape', { prop: 'setRedactType', onPropertyChange: false, value: { redactType: 'blur' } });
                this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                        isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
                Iif (ej2_base_3.Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
                    ej2_base_2.getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
                    this.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
                }
                var isImageLoaded = this.isImageLoaded;
                this.currObjType.isUndoAction = this.isUndoRedo = this.togglePan = this.togglePen = this.isImageLoaded = this.isFinetuning = false;
                this.isCircleCrop = this.isCropTab = false;
                this.objColl = [];
                this.transform.degree = 0;
                this.upperCanvas.style.display = 'block';
                this.transform.currFlipState = '';
                this.allowDownScale = true;
                this.upperCanvas.style.cursor = this.cursor = this.lowerCanvas.style.cursor = 'default';
                this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
                this.frameDestPoints = null;
                this.textArea.value = this.textArea.textContent = '';
                this.textArea.style.display = 'none';
                this.lowerContext.filter = this.canvasFilter = this.getDefaultFilter();
                this.img.destLeft = this.img.destTop = this.img.srcLeft = this.img.srcTop = 0;
                this.img.destWidth = this.img.destHeight = this.img.srcWidth = this.img.srcHeight = null;
                this.currSelectionPoint = null;
                this.panPoint.currentPannedPoint = { x: 0, y: 0 };
                this.rotateFlipColl = [];
                this.points = [];
                this.pointColl = {};
                this.freehandCounter = 0;
                this.notify('draw', { prop: 'resetPanPoints' });
                this.lowerCanvas.style.left = this.upperCanvas.style.left = '';
                this.fontSizeColl = [];
                this.lowerCanvas.style.top = this.upperCanvas.style.top = '';
                this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = '';
                this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = '';
                this.transform.defaultZoomFactor = this.transform.zoomFactor = 0;
                this.transform.cropZoomFactor = null;
                this.frameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
                this.tempFrameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
                this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
                    isInitialLine: false, isCustomCrop: false, isZoomed: false, isUndoZoom: false,
                    isUndoAction: false, isFiltered: false, isSave: false, isResize: false, isRedact: false };
                this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
                    totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
                    rotateFlipColl: [], degree: 0, currFlipState: '', straighten: 0, zoomFactor: 0, previousZoomValue: 0,
                    destPoints: { startX: 0, startY: 0, width: 0, height: 0 }, frame: 'none',
                    srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
                    aspectWidth: null, aspectHeight: null, straightenZoom: 0,
                    adjustmentLevel: { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
                        exposure: 0, transparency: 100, sharpen: false, bw: false }, currentFilter: '' };
                this.afterCropActions = [];
                this.currentFilter = '';
                this.tempFrameZoomLevel = null;
                this.cxtTbarHeight = null;
                this.straightenPoint = null;
                this.transform.straighten = 0;
                this.cancelCropSelection = null;
                this.aspectWidth = this.aspectHeight = null;
                this.isResize = this.isMaskImage = false;
                this.drawingShape = null;
                this.isShapeDrawing = this.noPushUndo = this.isUndoRedoStack = this.isKBDNavigation = false;
                this.shapeColl = [];
                this.tempObjColl = [];
                this.tempPointColl = [];
                this.tempShapeColl = [];
                this.isImageUpdated = false;
                this.tempToolbarHeight = 0;
                this.tempToolbar = [];
                this.tempRedactBlur = 50;
                this.tempRedactPixel = 40;
                var obj_1 = { initialZoomValue: false };
                this.editCompleteArgs = null;
                this.isFinetuneBtnClick = false;
                this.notify('draw', { prop: 'getInitialZoomValue', onPropertyChange: false, value: { obj: obj_1 } });
                if (obj_1['initialZoomValue']) {
                    this.setProperties({ zoomSettings: { zoomFactor: obj_1['initialZoomValue'] } }, true);
                }
                var qtArea = document.getElementById(this.element.id + '_quickAccessToolbarArea');
                if (qtArea) {
                    qtArea.style.display = 'none';
                }
                this.notifyResetForAllModules();
                this.notify('filter', { prop: 'update-finetunes' });
                if (this.toolbarTemplate) {
                    this.toolbarHeight = this.element.querySelector('#' + this.element.id + '_toolbarArea').clientHeight;
                }
                else if (this.element.querySelector('#' + this.element.id + '_toolbar')) {
                    this.toolbarHeight = this.element.querySelector('#' + this.element.id + '_toolbar').clientHeight;
                }
                this.notify('toolbar', { prop: 'setToolbarHeight', value: { height: this.toolbarHeight } });
                this.isImageLoaded = isImageLoaded;
                this.straightenBaseImageCanvas();
                this.isImageLoaded = false;
                this.notify('draw', { prop: 'update-canvas', onPropertyChange: false });
                this.isImageLoaded = isImageLoaded;
                this.prevStraightenedDegree = 0;
                var ctWrapper = this.element.querySelector('.e-contextual-toolbar-wrapper');
                if (ctWrapper) {
                    ctWrapper.classList.add('e-hide');
                }
                this.notify('toolbar', { prop: 'refresh-dropdown-btn', value: { isDisabled: false } });
                this.notify('toolbar', { prop: 'enable-disable-btns' });
                var straightenObj = { bool: this.isStraightening };
                Iif (ej2_base_3.Browser.isDevice && straightenObj['bool']) {
                    this.notify('crop', { prop: 'resizeWrapper' });
                }
                var saveDialog = this.element.querySelector('#' + this.element.id + '_saveDialog');
                Iif (saveDialog) {
                    ej2_base_2.getComponent(saveDialog, 'dialog').close();
                }
                var actionArgs = { action: 'reset', actionEventArgs: null };
                this.triggerEditCompleteEvent(actionArgs);
            }
        };
        ImageEditor.prototype.rotate = function (degree) {
            var obj = { isRotate: false };
            this.applyShapes();
            if (this.activeObj.shape && this.activeObj.shape.indexOf('crop') > -1) {
                this.transformSelect(degree === 90 ? 'rotateright' : 'rotateleft');
                obj['isRotate'] = true;
            }
            else {
                if (degree === 90 || degree === -90) {
                    this.updateImageTransformColl(degree === 90 ? 'rotateright' : 'rotateleft');
                }
                this.setRotateZoom();
                this.notify('transform', { prop: 'rotate', value: { degree: degree, obj: obj } });
                this.notify('draw', { prop: 'redrawDownScale' });
            }
            var actionArgs = { action: 'rotate', actionEventArgs: this.editCompleteArgs };
            this.triggerEditCompleteEvent(actionArgs);
            return obj['isRotate'];
        };
        ImageEditor.prototype.export = function (type, fileName, imageQuality) {
            this.manageActiveAction();
            this.notify('export', { prop: 'export', onPropertyChange: false, value: { type: type, fileName: fileName, imgQuality: imageQuality } });
        };
        ImageEditor.prototype.select = function (type, startX, startY, width, height) {
            this.applyShapes();
            this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + type } });
            this.notify('draw', { prop: 'select', onPropertyChange: false,
                value: { type: type, startX: startX, startY: startY, width: width, height: height } });
            if ((startX && startY) || (width && height)) {
                this.notify('draw', { prop: 'select', onPropertyChange: false,
                    value: { type: type, startX: startX, startY: startY, width: width, height: height } });
            }
            else {
                this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
                    totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
                    rotateFlipColl: [], degree: 0, currFlipState: '', straighten: 0, zoomFactor: 0, previousZoomValue: 0,
                    destPoints: { startX: 0, startY: 0, width: 0, height: 0 }, frame: 'none',
                    srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
                    aspectWidth: null, aspectHeight: null, straightenZoom: 0,
                    adjustmentLevel: { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
                        exposure: 0, transparency: 100, sharpen: false, bw: false }, currentFilter: '' };
            }
        };
        ImageEditor.prototype.freeHandDraw = function (value) {
            this.notify('freehand-draw', { prop: 'freeHandDraw', onPropertyChange: false, value: { value: value } });
        };
        ImageEditor.prototype.freehandDraw = function (value) {
            Eif (!this.disabled && this.isImageLoaded) {
                Iif (!value && this.isMaskImage) {
                    this.discard();
                    return;
                }
                this.manageActiveAction();
                this.freeHandDraw(value);
                var prevObj = { shapeSettingsObj: {} };
                this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: prevObj } });
                var shapeSettings = prevObj['shapeSettingsObj'];
                shapeSettings.type = index_1.ShapeType.FreehandDraw;
                var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
                    currentShapeSettings: shapeSettings };
                this.notify('freehand-draw', { prop: 'triggerShapeChanging', value: { shapeChangingArgs: shapeChangingArgs } });
            }
        };
        ImageEditor.prototype.pan = function (value, x, y) {
            this.applyShapes();
            this.notify('transform', { prop: 'pan', onPropertyChange: false, value: { value: value, x: x, y: y } });
        };
        ImageEditor.prototype.zoom = function (zoomFactor, zoomPoint) {
            this.isZoomBtnClick = true;
            var prevZoom = this.transform.zoomFactor;
            if (prevZoom !== 0) {
                var zoomObj = { previousZoomValue: null };
                this.notify('transform', { prop: 'getPreviousZoomValue', value: { obj: zoomObj } });
                prevZoom = zoomObj.previousZoomValue;
            }
            Iif (zoomFactor !== 1 && prevZoom !== 0 && ((prevZoom < 1 && zoomFactor > 1) || (prevZoom > 1 && zoomFactor < 1))) {
                this.notify('transform', { prop: 'zoom', onPropertyChange: false,
                    value: { zoomFactor: 1, zoomPoint: zoomPoint }
                });
            }
            this.notify('transform', { prop: 'zoom', onPropertyChange: false,
                value: { zoomFactor: zoomFactor, zoomPoint: zoomPoint } });
            this.notify('draw', { prop: 'redrawDownScale' });
        };
        ImageEditor.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor, degree, isSelected) {
            var isEllipse = false;
            var isPointsInRange = this.allowShape(x, y);
            Eif (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(x) && ej2_base_2.isNullOrUndefined(y)))) {
                isEllipse = true;
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawEllipse', onPropertyChange: false, value: { x: x, y: y, radiusX: radiusX, radiusY: radiusY,
                        strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor, degree: degree, isSelected: isSelected } });
                this.editCompleted();
            }
            return isEllipse;
        };
        ImageEditor.prototype.drawLine = function (startX, startY, endX, endY, strokeWidth, strokeColor, isSelected) {
            var isLine = false;
            var isPointsInRange = this.allowShape(startX, startY);
            if (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(startX) && ej2_base_2.isNullOrUndefined(startY)))) {
                isLine = true;
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawLine', onPropertyChange: false, value: { startX: startX, startY: startY, endX: endX,
                        endY: endY, strokeWidth: strokeWidth, strokeColor: strokeColor, isSelected: isSelected } });
                this.editCompleted();
            }
            return isLine;
        };
        ImageEditor.prototype.drawArrow = function (startX, startY, endX, endY, strokeWidth, strokeColor, arrowStart, arrowEnd, isSelected) {
            var isArrow = false;
            var isPointsInRange = this.allowShape(startX, startY);
            Eif (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(startX) && ej2_base_2.isNullOrUndefined(startY)))) {
                isArrow = true;
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawArrow', onPropertyChange: false, value: { startX: startX, startY: startY, endX: endX,
                        endY: endY, strokeWidth: strokeWidth, strokeColor: strokeColor, arrowStart: arrowStart, arrowEnd: arrowEnd,
                        isSelected: isSelected } });
                this.editCompleted();
            }
            return isArrow;
        };
        ImageEditor.prototype.drawPath = function (pointColl, strokeWidth, strokeColor, isSelected) {
            this.isPublicMethod = true;
            var obj = { inRange: false };
            var isPath = false;
            Eif (pointColl && pointColl.length > 0) {
                for (var i = 0; i < pointColl.length; i++) {
                    if (obj['inRange']) {
                        break;
                    }
                    this.notify('shape', { prop: 'isPointsInRange', onPropertyChange: false,
                        value: { x: pointColl[i].x, y: pointColl[i].y, obj: obj } });
                }
            }
            Eif (!this.disabled && this.isImageLoaded && (obj['inRange'] || ej2_base_2.isNullOrUndefined(pointColl))) {
                isPath = true;
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawPath', onPropertyChange: false, value: { pointColl: pointColl,
                        strokeWidth: strokeWidth, strokeColor: strokeColor, isSelected: isSelected } });
                this.editCompleted();
            }
            return isPath;
        };
        ImageEditor.prototype.drawRectangle = function (x, y, width, height, strokeWidth, strokeColor, fillColor, degree, isSelected, borderRadius) {
            var isRectangle = false;
            var isPointsInRange = this.allowShape(x, y);
            Eif (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(x) && ej2_base_2.isNullOrUndefined(y)))) {
                isRectangle = true;
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawRectangle', onPropertyChange: false, value: { x: x, y: y, width: width, height: height,
                        strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor, degree: degree, isSelected: isSelected,
                        radius: borderRadius } });
                this.editCompleted();
            }
            return isRectangle;
        };
        ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth, transformCollection, underline, strikethrough) {
            var isText = false;
            var isPointsInRange = this.allowShape(x, y);
            if (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(x) && ej2_base_2.isNullOrUndefined(y)))) {
                isText = true;
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawText', onPropertyChange: false, value: { x: x, y: y, text: text, fontFamily: fontFamily,
                        fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected, degree: degree, fillColor: fillColor,
                        outlineColor: strokeColor, outlineWidth: strokeWidth, transformCollection: transformCollection, underline: underline, strikethrough: strikethrough } });
                this.editCompleted();
            }
            return isText;
        };
        ImageEditor.prototype.drawImage = function (data, x, y, width, height, isAspectRatio, degree, opacity, isSelected) {
            var isImage = false;
            var isPointsInRange = this.allowShape(x, y);
            Eif (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(x) && ej2_base_2.isNullOrUndefined(y)))) {
                Eif (typeof data === 'string') {
                    try {
                        var request = new XMLHttpRequest();
                        var isBlob = data.indexOf('blob:') === 0;
                        request.open(isBlob ? 'GET' : 'HEAD', data, false);
                        request.send();
                        isImage = request.status >= 200 && request.status < 300;
                    }
                    catch (error) {
                        isImage = false;
                    }
                }
                else if (data instanceof ImageData) {
                    if (data.data instanceof Uint8ClampedArray && data.width > 0 && data.height > 0) {
                        isImage = true;
                    }
                }
                this.manageActiveAction();
                this.notify('shape', { prop: 'drawImage', onPropertyChange: false, value: { x: x, y: y, width: width, height: height,
                        src: data, degree: degree, isAspectRatio: isAspectRatio, opacity: opacity, isSelected: isSelected } });
                this.editCompleted();
            }
            return isImage;
        };
        ImageEditor.prototype.updateShape = function (setting, isSelected) {
            var obj = { isSelected: false };
            var isTextArea = false;
            var freehandObj = { bool: false };
            Iif (ej2_base_2.isNullOrUndefined(setting.id)) {
                if (setting.strokeColor) {
                    this.activeObj.strokeSettings.strokeColor = setting.strokeColor;
                }
                if (setting.fillColor) {
                    this.activeObj.strokeSettings.fillColor = setting.fillColor;
                }
                if (setting.strokeWidth) {
                    this.activeObj.strokeSettings.strokeWidth = setting.strokeWidth;
                }
                if (setting.index) {
                    this.activeObj.order = setting.index;
                }
                if (setting.type === 'FreehandDraw' && setting.strokeWidth) {
                    this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: setting.strokeWidth } });
                }
            }
            else {
                Iif (setting.type.toLowerCase() === 'text' && (this.textArea.style.display === 'block' ||
                    this.textArea.style.display === 'inline-block')) {
                    this.okBtn(null, true);
                    isTextArea = true;
                }
                this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: setting.id, obj: obj, isShape: true } });
                this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: freehandObj } });
                Eif (obj['isSelected']) {
                    var tempFontSize = this.activeObj.textSettings.fontSize;
                    this.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
                        value: { shapeSettings: setting } });
                    if (this.activeObj.shape === 'text' && tempFontSize) {
                        var diff = this.activeObj.textSettings.fontSize - tempFontSize;
                        Iif (diff !== 0) {
                            this.activeObj.activePoint.height += diff;
                            this.activeObj.activePoint.startY -= (diff / 2);
                            this.activeObj.activePoint.endY += (diff / 2);
                            this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: this.activeObj.activePoint, obj: this.activeObj,
                                    isMouseMove: null, x: null, y: null } });
                        }
                    }
                    var activeObj = ej2_base_1.extend({}, this.activeObj, {}, true);
                    this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                    this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: null } });
                    this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                    Eif (activeObj.shape) {
                        this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
                    }
                    if (this.activeObj.shape === 'text') {
                        this.notify('toolbar', { prop: 'editText', onPropertyChange: false });
                    }
                    Iif (freehandObj['bool']) {
                        this.notify('undo-redo', { prop: 'setPreventUR', value: { bool: true } });
                    }
                    this.okBtn(isSelected, true);
                    Iif (freehandObj['bool']) {
                        this.notify('undo-redo', { prop: 'setPreventUR', value: { bool: false } });
                    }
                    this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                    this.editCompleteArgs = { action: 'shape-update', currentShapeSettings: setting };
                    this.editCompleted('shape-customize');
                    Iif (isTextArea) {
                        this.enableTextEditing();
                    }
                    Iif (isSelected) {
                        this.noRedact = true;
                        this.selectShape(setting.id);
                    }
                }
            }
            return obj['isSelected'];
        };
        ImageEditor.prototype.selectShape = function (id) {
            this.applyShapes();
            var obj = { isSelected: false };
            this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: id, obj: obj, isShape: true } });
            this.editCompleted('shape-select');
            this.noRedact = false;
            return obj['isSelected'];
        };
        ImageEditor.prototype.deleteShape = function (id) {
            var shape = this.getShapeSetting(id);
            Iif (shape.type === 'Redact') {
                return;
            }
            this.applyShapes();
            this.notify('shape', { prop: 'deleteShape', onPropertyChange: false, value: { id: id, isShape: true } });
            this.editCompleted('shape-delete');
            this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
            this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
        };
        ImageEditor.prototype.getShapeSetting = function (id) {
            this.applyShapes();
            var obj = { shapeDetails: null };
            this.notify('shape', { prop: 'getShapeSetting', onPropertyChange: false,
                value: { id: id, obj: obj } });
            this.notify('draw', { prop: 'redrawDownScale' });
            var shapeDetails = obj['shapeDetails'] ? obj['shapeDetails'] : {};
            return shapeDetails;
        };
        ImageEditor.prototype.getShapeSettings = function () {
            this.applyShapes();
            var obj = { shapeDetailsColl: [] };
            this.notify('shape', { prop: 'getShapeSettings', onPropertyChange: false, value: { obj: obj } });
            this.notify('draw', { prop: 'redrawDownScale' });
            return obj.shapeDetailsColl.filter(function (item) { return item.type !== 'redact'; });
        };
        ImageEditor.prototype.getRedacts = function () {
            this.applyShapes();
            var obj = { shapeDetailsColl: [] };
            this.notify('shape', { prop: 'getRedactSettings', onPropertyChange: false, value: { obj: obj } });
            this.notify('draw', { prop: 'redrawDownScale' });
            return obj.shapeDetailsColl.filter(function (item) { return item.type !== 'redact'; });
        };
        ImageEditor.prototype.selectRedact = function (id) {
            this.applyShapes();
            var obj = { isSelected: false };
            this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: id, obj: obj, isRedact: true } });
            this.editCompleted('redact-select');
            this.noRedact = false;
            return obj['isSelected'];
        };
        ImageEditor.prototype.deleteRedact = function (id) {
            this.applyShapes();
            this.notify('shape', { prop: 'deleteShape', onPropertyChange: false, value: { id: id, isRedact: true } });
            this.editCompleted('redact-delete');
        };
        ImageEditor.prototype.updateRedact = function (setting, isSelected) {
            this.applyShapes();
            var obj = { isSelected: false };
            this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: setting.id, obj: obj, isRedact: true } });
            Eif (obj['isSelected']) {
                this.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
                    value: { shapeSettings: setting } });
                Eif (setting.blurIntensity) {
                    this.activeObj.redactBlur = setting.blurIntensity;
                }
                Iif (setting.pixelSize) {
                    this.activeObj.redactPixelate = setting.pixelSize;
                }
                this.activeObj.redactType = setting.type.toLowerCase() === 'blur' ? 'blur' : 'pixelate';
                var activeObj = ej2_base_1.extend({}, this.activeObj, {}, true);
                this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: null } });
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                Eif (activeObj.shape) {
                    this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
                }
                this.okBtn(isSelected, true);
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                this.editCompleteArgs = { action: 'redact-update', currentShapeSettings: setting };
                this.editCompleted('redact-customize');
                if (isSelected) {
                    this.selectRedact(setting.id);
                }
            }
            return obj['isSelected'];
        };
        ImageEditor.prototype.update = function () {
            this.notify('transform', { prop: 'update' });
        };
        ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
            Eif (!this.disabled && this.isImageLoaded) {
                this.manageActiveAction();
                this.notify('filter', { prop: 'finetuneImage', value: { value: value, option: finetuneOption } });
                this.editCompleteArgs = { finetune: finetuneOption, value: value };
                this.editCompleted('fine-tune');
            }
        };
        ImageEditor.prototype.applyImageFilter = function (filterOption) {
            Eif (!this.disabled && this.isImageLoaded) {
                this.manageActiveAction();
                this.notify('filter', { prop: 'applyImageFilter', value: { option: filterOption.toString() } });
                this.editCompleteArgs = { filter: filterOption };
                this.editCompleted('filter');
                this.canvasFilter = this.lowerContext.filter;
                this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
            }
        };
        ImageEditor.prototype.undo = function () {
            this.handlePenActiveState();
            this.notify('undo-redo', { prop: 'undo', onPropertyChange: false });
            this.notify('draw', { prop: 'redrawDownScale' });
        };
        ImageEditor.prototype.redo = function () {
            this.handlePenActiveState();
            this.notify('undo-redo', { prop: 'redo', onPropertyChange: false });
            this.notify('draw', { prop: 'redrawDownScale' });
        };
        ImageEditor.prototype.getImageDimension = function () {
            return { x: this.img.destLeft, y: this.img.destTop, width: this.img.destWidth, height: this.img.destHeight };
        };
        ImageEditor.prototype.resize = function (width, height, isAspectRatio) {
            var isResized = false;
            Eif (((width.toString()).length <= 4 && (height.toString()).length <= 4) && (!this.isCircleCrop || isAspectRatio)) {
                this.manageActiveAction();
                this.isPublicMethod = true;
                this.notify('toolbar', { prop: 'resizeClick', value: { bool: false } });
                var destPoints = { startX: this.img.destLeft, startY: this.img.destTop, width: this.img.destWidth,
                    height: this.img.destHeight };
                if (isAspectRatio) {
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: false, isCropping: false } });
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: false, isCropping: false } });
                }
                else {
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
                            isApplyBtn: false, isCropping: false } });
                }
                var aspectRatioWidth = this.element.querySelector('#' + this.element.id + '_resizeWidth');
                var aspectRatioHeight = this.element.querySelector('#' + this.element.id + '_resizeHeight');
                if (aspectRatioWidth && aspectRatioHeight) {
                    ej2_base_2.getComponent(aspectRatioWidth, 'numerictextbox').value = Math.floor(width);
                    aspectRatioWidth.value = Math.floor(width).toString() + ' px';
                    ej2_base_2.getComponent(aspectRatioHeight, 'numerictextbox').value = Math.floor(height);
                    aspectRatioHeight.value = Math.floor(height).toString() + ' px';
                }
                this.notify('transform', { prop: 'resize', value: { width: width, height: height, isAspectRatio: isAspectRatio } });
                if (destPoints.startX !== this.img.destLeft || destPoints.startY !== this.img.destTop ||
                    destPoints.width !== this.img.destWidth || destPoints.height !== this.img.destHeight) {
                    isResized = true;
                    this.aspectWidth = width;
                    this.aspectHeight = height;
                    if (isAspectRatio) {
                        this.aspectHeight = null;
                    }
                    this.okBtn(false, false, true);
                }
                else {
                    this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
                }
                this.isPublicMethod = false;
                this.notify('draw', { prop: 'redrawDownScale' });
            }
            return isResized;
        };
        ImageEditor.prototype.drawFrame = function (frameType, color, gradientColor, size, inset, offset, borderRadius, frameLineStyle, lineCount) {
            this.manageActiveAction();
            var isFrame = false;
            var obj = { frameChangeEventArgs: null };
            color = color ? color : '#fff';
            gradientColor = gradientColor ? gradientColor : '';
            size = size ? size : 20;
            inset = inset ? inset : 0;
            offset = offset ? offset : 0;
            borderRadius = borderRadius ? borderRadius : 0;
            frameLineStyle = frameLineStyle ? frameLineStyle : index_1.FrameLineStyle.Solid;
            lineCount = lineCount ? lineCount : 0;
            var prevFrameSettings = { type: this.toPascalCase(this.frameObj.type), color: this.frameObj.color,
                gradientColor: this.frameObj.gradientColor, size: this.frameObj.size, inset: this.frameObj.inset,
                offset: this.frameObj.offset, borderRadius: this.frameObj.radius,
                frameLineStyle: this.toPascalCase(this.frameObj.border), lineCount: this.frameObj.amount };
            ej2_base_1.extend(this.tempFrameObj, this.frameObj);
            this.tempFrameZoomLevel = this.transform.zoomFactor;
            this.frameDestPoints = ej2_base_1.extend({}, this.img, {}, true);
            this.notify('toolbar', { prop: 'frameToolbarClick' });
            this.frameObj.type = frameType.toLowerCase();
            this.frameObj.color = color;
            this.frameObj.gradientColor = gradientColor;
            this.frameObj.size = size;
            this.frameObj.inset = inset;
            this.frameObj.offset = offset;
            this.frameObj.radius = borderRadius;
            this.frameObj.border = frameLineStyle.toLowerCase();
            this.frameObj.amount = lineCount;
            this.notify('draw', { prop: 'triggerFrameChange', value: { prevFrameSettings: prevFrameSettings, obj: obj } });
            Eif (obj['frameChangeEventArgs'] && !obj['frameChangeEventArgs'].cancel) {
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
                Eif (JSON.stringify(this.frameObj) !== JSON.stringify(this.tempFrameObj)) {
                    isFrame = true;
                    this.okBtn();
                }
                else {
                    this.tempFrameZoomLevel = null;
                }
            }
            else {
                this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
                ej2_base_1.extend(this.frameObj, this.tempFrameObj);
                this.tempFrameZoomLevel = null;
            }
            this.notify('draw', { prop: 'redrawDownScale' });
            var ctxTbar = this.element.querySelector('.e-contextual-toolbar-wrapper');
            Eif (ctxTbar) {
                ctxTbar.classList.add('e-hide');
            }
            return isFrame;
        };
        ImageEditor.prototype.straightenImage = function (degree) {
            var isStraightened = false;
            Eif (degree >= -45 && degree <= 45) {
                this.applyShapes();
                isStraightened = true;
                this.notify('transform', { prop: 'straightenImage', value: { degree: degree } });
                this.notify('draw', { prop: 'redrawDownScale' });
            }
            return isStraightened;
        };
        ImageEditor.prototype.cloneShape = function (shapeId) {
            var obj = { isSelected: false };
            Eif (shapeId.split('_')[0] === 'shape') {
                this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: shapeId, obj: obj } });
                if (obj['isSelected']) {
                    this.notify('toolbar', { prop: 'duplicateShape', onPropertyChange: false, value: { isPreventUndoRedo: false } });
                    this.okBtn(null, true);
                    this.notify('draw', { prop: 'redrawDownScale' });
                }
            }
            return obj['isSelected'];
        };
        ImageEditor.prototype.getImageFilter = function (filterOption) {
            var canvas = this.createElement('canvas');
            var ctx = canvas.getContext('2d');
            this.notify('filter', { prop: 'updateAdj', value: { type: filterOption.toLowerCase(), value: null, isPreview: true, ctx: ctx } });
            return ctx.filter;
        };
        ImageEditor.prototype.enableTextEditing = function () {
            var activeObj = ej2_base_1.extend({}, this.activeObj, {}, true);
            Iif (!activeObj.order) {
                this.noPushUndo = true;
                this.okBtn();
                this.noPushUndo = false;
                this.noRedact = true;
                this.selectShape(activeObj.currIndex);
                activeObj.order = this.activeObj.order;
            }
            this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: false } });
            this.activeObj = activeObj;
            this.notify('toolbar', { prop: 'editText', onPropertyChange: false });
        };
        ImageEditor.prototype.canUndo = function () {
            var canUndo = false;
            var object = this.getUndoRedoColl();
            var undoRedoIndex = object['index'];
            Eif (undoRedoIndex > 0) {
                canUndo = true;
            }
            return canUndo;
        };
        ImageEditor.prototype.canRedo = function () {
            var canRedo = false;
            var object = this.getUndoRedoColl();
            var undoRedoColl = object['undoRedoColl'];
            var undoRedoIndex = object['index'];
            Iif (undoRedoColl && undoRedoColl.length > 0 && undoRedoIndex < undoRedoColl.length - 1) {
                canRedo = true;
            }
            Eif (undoRedoIndex === undoRedoColl.length) {
                canRedo = false;
            }
            else if (undoRedoIndex === 0 && undoRedoColl.length > 0) {
                canRedo = true;
            }
            else if (undoRedoIndex > 0) {
                canRedo = true;
            }
            return canRedo;
        };
        ImageEditor.prototype.apply = function () {
            Iif (this.isMaskImage) {
                this.discard();
            }
            else {
                this.updateColl('reset');
                this.closeOverlayTbar();
                this.okBtn(null, true);
            }
        };
        ImageEditor.prototype.discard = function () {
            this.updateColl('reset');
            this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: this.closeOverlayTbar(), isFinalCancel: true } });
        };
        ImageEditor.prototype.enableShapeDrawing = function (shapeType, isEnabled) {
            if (isEnabled) {
                this.drawingShape = shapeType.toLowerCase();
                this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            }
            if (shapeType && isEnabled) {
                this.currObjType.shape = shapeType.toLowerCase();
                this.activeObj.shape = this.currObjType.shape;
                this.currObjType.isDragging = this.currObjType.isCustomCrop = false;
                this.activeObj.shapeDegree = this.transform.degree;
                this.activeObj.shapeFlip = this.transform.currFlipState;
                this.activeObj.textFlip = this.transform.currFlipState;
                this.activeObj.flipObjColl = [];
                var orderObj = { order: null };
                this.notify('shape', { prop: 'getNewOrder', onPropertyChange: false, value: { obj: orderObj } });
                this.activeObj.order = orderObj['order'];
                this.notify('selection', { prop: 'annotate', value: { shape: this.currObjType.shape } });
                Iif (this.currObjType.shape === 'text') {
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
                            isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                }
                else Iif (this.currObjType.shape === 'redact') {
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'redact',
                            isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                }
                else {
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
                            isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
                }
                this.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
            }
            else Eif (!isEnabled) {
                this.okBtn(null, true);
            }
        };
        ImageEditor.prototype.bringToFront = function (shapeId) {
            this.noRedact = true;
            Eif (this.selectShape(shapeId)) {
                this.updateShapeOrder(shapeId, 'bringToFront');
                this.apply();
            }
        };
        ImageEditor.prototype.bringForward = function (shapeId) {
            this.noRedact = true;
            Eif (this.selectShape(shapeId)) {
                this.updateShapeOrder(shapeId, 'bringForward');
                this.apply();
            }
        };
        ImageEditor.prototype.sendToBack = function (shapeId) {
            this.noRedact = true;
            Eif (this.selectShape(shapeId)) {
                this.updateShapeOrder(shapeId, 'sendToBack');
                this.apply();
            }
        };
        ImageEditor.prototype.sendBackward = function (shapeId) {
            this.noRedact = true;
            Eif (this.selectShape(shapeId)) {
                this.updateShapeOrder(shapeId, 'sendBackward');
                this.apply();
            }
        };
        ImageEditor.prototype.clearImage = function () {
            this.reset();
            this.isImageLoaded = false;
            this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
            this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
            var btoolbar = document.getElementById(this.element.id + '_bottomToolbar');
            Iif (ej2_base_3.Browser.isDevice && btoolbar) {
                document.getElementById(this.element.id + '_bottomToolbar').style.display = 'none';
            }
            this.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
            this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
            this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
            var dropArea = document.getElementById(this.element.id + '_dropArea');
            Eif (dropArea) {
                dropArea.style.display = 'flex';
            }
        };
        ImageEditor.prototype.selectMaskImage = function (strokeWidth, color) {
            strokeWidth = strokeWidth ? strokeWidth : 10;
            color = color ? color : '#512da880';
            this.applyShapes();
            this.isMaskImage = true;
            this.updateColl('empty');
            this.enableDisableToolbar(true);
            this.update();
            this.activeObj.strokeSettings.strokeWidth = strokeWidth;
            this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: strokeWidth } });
            this.activeObj.strokeSettings.strokeColor = color;
            this.notify('freehand-draw', { prop: 'freeHandDraw', onPropertyChange: false, value: { value: true } });
            this.maskCanvas.style.display = 'block';
        };
        ImageEditor.prototype.enableDisableToolbar = function (value) {
            var toolbar;
            var elem = document.getElementById(this.element.id + '_toolbar');
            Eif (elem) {
                toolbar = ej2_base_2.getComponent(elem, 'toolbar');
                Eif (toolbar) {
                    toolbar.disable(value);
                }
            }
            elem = document.getElementById(this.element.id + '_bottomToolbar');
            Iif (elem) {
                toolbar = ej2_base_2.getComponent(elem, 'toolbar');
                if (toolbar) {
                    toolbar.disable(value);
                }
            }
        };
        ImageEditor.prototype.updateImage = function (data, imageBackgroundColor) {
            var _this = this;
            Eif (data || imageBackgroundColor || imageBackgroundColor === '') {
                var prevCropObj_1 = ej2_base_1.extend({}, this.cropObj, {}, true);
                var object = { currObj: {} };
                this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                var prevObj_1 = object['currObj'];
                prevObj_1.objColl = ej2_base_1.extend([], this.objColl, [], true);
                prevObj_1.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
                prevObj_1.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
                prevObj_1.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                if (data) {
                    this.isImageUpdated = true;
                    Iif (typeof (data) !== 'string') {
                        var canvas = this.createElement('canvas');
                        canvas.width = data.width;
                        canvas.height = data.height;
                        canvas.getContext('2d').putImageData(data, 0, 0);
                        data = canvas.toDataURL();
                    }
                    this.baseImg.src = data;
                    setTimeout(function () {
                        Eif (_this.cropObj.straighten !== 0) {
                            _this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + 'custom' } });
                            _this.noPushUndo = true;
                            _this.crop();
                            _this.noPushUndo = false;
                        }
                        else {
                            _this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                        }
                        _this.isImageUpdated = false;
                        Iif (!imageBackgroundColor) {
                            _this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'updateImage', previousObj: prevObj_1,
                                    previousObjColl: prevObj_1.objColl, previousPointColl: prevObj_1.pointColl,
                                    previousSelPointColl: prevObj_1.selPointColl, previousCropObj: prevCropObj_1,
                                    previousText: null, currentText: null, previousFilter: null, isCircleCrop: null
                                } });
                            _this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                        }
                    }, 100);
                }
                Eif (imageBackgroundColor || imageBackgroundColor === '') {
                    this.notify('draw', { prop: 'imageBackgroundColor', onPropertyChange: false, value: { color: imageBackgroundColor } });
                    this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                    if (!data) {
                        this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'bgColor', previousObj: prevObj_1,
                                previousObjColl: prevObj_1.objColl, previousPointColl: prevObj_1.pointColl, previousSelPointColl: prevObj_1.selPointColl,
                                previousCropObj: prevCropObj_1, previousText: null, currentText: null, previousFilter: null, isCircleCrop: null
                            } });
                        this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                    }
                }
                if (data && imageBackgroundColor) {
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'updateImage', previousObj: prevObj_1,
                            previousObjColl: prevObj_1.objColl, previousPointColl: prevObj_1.pointColl, previousSelPointColl: prevObj_1.selPointColl,
                            previousCropObj: prevCropObj_1, previousText: null, currentText: null, previousFilter: null, isCircleCrop: null
                        } });
                    this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                }
            }
        };
        ImageEditor.prototype.editCompleted = function (type) {
            this.notify('draw', { prop: 'redrawDownScale' });
            var actionArgs = { action: type ? type : 'shape-insert',
                actionEventArgs: this.editCompleteArgs };
            this.triggerEditCompleteEvent(actionArgs);
        };
        ImageEditor.prototype.updateColl = function (type) {
            if (!this.isMaskImage) {
                return;
            }
            if (type === 'empty') {
                this.tempToolbarHeight = this.toolbarHeight;
                this.tempToolbar = this.toolbar ? ej2_base_1.extend([], this.toolbar, [], true) : null;
                this.tempObjColl = ej2_base_1.extend([], this.objColl, [], true);
                this.tempPointColl = ej2_base_1.extend([], this.pointColl, [], true);
                this.tempShapeColl = ej2_base_1.extend([], this.shapeColl, [], true);
                this.objColl = [];
                this.pointColl = [];
                this.shapeColl = [];
                this.freehandCounter = 0;
                this.notify('freehand-draw', { prop: 'setCurrentFreehandDrawIndex',
                    value: { value: 0 } });
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
            }
            else Eif (type === 'reset') {
                this.objColl = this.tempObjColl;
                this.pointColl = this.tempPointColl;
                this.shapeColl = this.tempShapeColl;
                this.freehandCounter = this.pointColl.length;
                this.notify('freehand-draw', { prop: 'setCurrentFreehandDrawIndex',
                    value: { value: this.freehandCounter } });
                this.enableDisableToolbar(false);
                Iif (this.cropObj.straighten !== 0) {
                    this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + 'custom' } });
                    this.noPushUndo = true;
                    this.crop();
                    this.noPushUndo = false;
                }
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                this.isMaskImage = false;
                this.upperContext.globalCompositeOperation = 'source-over';
                this.maskCanvas.style.display = 'none';
                this.activeObj.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null,
                    radius: null, outlineColor: '', outlineWidth: null };
                this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: this.activeObj.strokeSettings,
                        strokeColor: '#fff', fillColor: '', strokeWidth: null, outlineWidth: null } });
                this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: 2 } });
                this.notify('freehand-draw', { prop: 'setMasking', onPropertyChange: false, value: { value: false } });
            }
        };
        ImageEditor.prototype.scaleToFit = function (imageSettings) {
            var tempImageSettings = ej2_base_1.extend({}, imageSettings, {}, true);
            var viewPortWidth = this.lowerCanvas.clientWidth;
            var viewPortHeight = this.lowerCanvas.clientHeight;
            if (imageSettings.width && imageSettings.height && (imageSettings.width > viewPortWidth ||
                imageSettings.height > viewPortHeight)) {
                var widthScale = viewPortWidth / imageSettings.width;
                var heightScale = viewPortHeight / imageSettings.height;
                var scale = Math.min(widthScale, heightScale);
                tempImageSettings.width = Math.round(imageSettings.width * scale);
                tempImageSettings.height = Math.round(imageSettings.height * scale);
            }
            else Iif (imageSettings.width && imageSettings.width > viewPortWidth) {
                var scale = viewPortWidth / imageSettings.width;
                tempImageSettings.width = Math.round(imageSettings.width * scale);
            }
            else Iif (imageSettings.height && imageSettings.height > viewPortHeight) {
                var scale = viewPortHeight / imageSettings.height;
                tempImageSettings.height = Math.round(imageSettings.height * scale);
            }
            return tempImageSettings;
        };
        ImageEditor.prototype.setInitialZoomLevel = function (oldImageSettings) {
            var _this = this;
            var zoomLevel = 1;
            var newWidth = this.img.destWidth;
            var newHeight = this.img.destHeight;
            var oldWidth = oldImageSettings.width;
            var oldHeight = oldImageSettings.height;
            var dimObj = { width: 0, height: 0 };
            this.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                value: { width: this.img.srcWidth, height: this.img.srcHeight, obj: dimObj, isImgShape: null } });
            while ((newWidth && oldWidth && oldWidth > newWidth) || (newHeight && oldHeight && oldHeight > newHeight)) {
                newWidth = dimObj['width'] + (dimObj['width'] * 0.025 * zoomLevel);
                newHeight = dimObj['height'] + (dimObj['height'] * 0.025 * zoomLevel);
                if (Math.abs(newWidth) >= Math.abs(oldWidth) && Math.abs(newHeight) >= Math.abs(oldHeight)) {
                    break;
                }
                zoomLevel++;
            }
            if (zoomLevel > 1) {
                this.isImageLoaded = true;
                var intervalId_3 = setInterval(function () {
                    Eif (_this.imageLoaded) {
                        for (var i = 1; i < zoomLevel; i++) {
                            if (Math.round(i / 4) < _this.zoomSettings.maxZoomFactor) {
                                _this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                                    value: { zoomFactor: 0.025, zoomPoint: null, isResize: true } });
                            }
                            else {
                                zoomLevel = i;
                                break;
                            }
                        }
                        _this.setProperties({ zoomSettings: { zoomFactor: Math.round(zoomLevel / 4) } }, true);
                        _this.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
                            value: { previousZoomValue: _this.zoomSettings.zoomFactor } });
                        _this.notify('toolbar', { prop: 'enable-disable-btns' });
                        clearInterval(intervalId_3);
                    }
                }, 1);
            }
        };
        ImageEditor.prototype.resetToolbar = function () {
            Iif (this.toolbarHeight !== this.tempToolbarHeight && !((ej2_base_2.isNullOrUndefined(this.toolbar) ||
                (this.toolbar && this.toolbar.length > 0)
                || !ej2_base_2.isNullOrUndefined(this.toolbarTemplate)))) {
                this.toolbarHeight = this.tempToolbarHeight;
                this.notify('toolbar', { prop: 'setToolbarHeight', value: { height: this.toolbarHeight } });
                this.toolbar = this.tempToolbar;
                if (!this.toolbarTemplate) {
                    this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
                    this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
                }
                this.update();
            }
        };
        ImageEditor.prototype.setRotateZoom = function () {
            if (this.transform.zoomFactor > 0) {
                this.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: true } });
            }
            else {
                this.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
            }
        };
        ImageEditor.prototype.getData = function (isMaskImage) {
            if (isMaskImage) {
                this.resetToolbar();
            }
            var objColl = ej2_base_1.extend([], this.objColl, null, true);
            var pointColl = ej2_base_1.extend([], this.pointColl, null, true);
            var shapeColl = ej2_base_1.extend([], this.shapeColl, null, true);
            if (isMaskImage) {
                this.notify('shape', { prop: 'updateShapeColl', onPropertyChange: false });
                for (var i = 0; i < this.freehandCounter; i++) {
                    this.pointColl[i].strokeColor = '#fff';
                }
            }
            else {
                this.objColl = [];
                this.pointColl = [];
                this.shapeColl = [];
                this.freehandCounter = 0;
            }
            var frameType = this.frameObj.type;
            this.frameObj.type = 'none';
            var aspectWidth = this.aspectWidth;
            var aspectHeight = this.aspectHeight;
            this.aspectWidth = this.aspectHeight = null;
            var straighten = this.cropObj.straighten;
            this.togglePen = false;
            this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + 'custom' } });
            var tempDestPoints = ej2_base_1.extend({}, this.img, {}, true);
            var tempCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var tempSel = ej2_base_1.extend({}, this.activeObj, {}, true);
            var tempTransform = ej2_base_1.extend({}, this.transform, {}, true);
            var panPoint = ej2_base_1.extend({}, this.panPoint, {}, true);
            Iif (straighten !== 0) {
                this.setStraighten(0);
            }
            var point = this.activeObj.activePoint;
            point.startX = this.img.destLeft;
            point.startY = this.img.destTop;
            point.width = this.img.destWidth;
            point.height = this.img.destHeight;
            point.endX = point.startX + point.width;
            point.endY = point.startY + point.height;
            this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: point, obj: this.activeObj,
                    isMouseMove: null, x: null, y: null } });
            this.noPushUndo = true;
            this.crop();
            this.noPushUndo = false;
            this.isCropTab = false;
            this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            this.notify('crop', { prop: 'resetZoom', onPropertyChange: false });
            this.isCropTab = true;
            var afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var coll = ej2_base_1.extend([], this.rotateFlipColl, [], true);
            this.notify('crop', { prop: 'revertTransform', value: { type: 'initial', coll: coll } });
            var imageData = this.getImageData();
            if (isMaskImage) {
                var canvas = this.createElement('canvas');
                var ctx = canvas.getContext('2d');
                canvas.width = imageData.width;
                canvas.height = imageData.height;
                ctx.fillRect(0, 0, canvas.width, canvas.height);
                Eif (this.pointColl.length > 0) {
                    var obj = { width: 0, height: 0 };
                    this.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                        value: { obj: obj, dimension: { width: canvas.width, height: canvas.height } } });
                    var ratio = obj;
                    this.notify('export', { prop: 'drawAnnotation', value: { context: ctx, ratio: ratio } });
                }
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
            }
            this.notify('crop', { prop: 'revertTransform', value: { type: 'reverse', coll: coll } });
            this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            this.afterCropActions = afterCropActions;
            if (!isMaskImage) {
                this.objColl = objColl;
                this.pointColl = pointColl;
                this.shapeColl = shapeColl;
                this.freehandCounter = this.pointColl.length;
            }
            this.frameObj.type = frameType;
            this.aspectWidth = aspectWidth;
            this.aspectHeight = aspectHeight;
            this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + 'custom' } });
            Iif (straighten !== 0) {
                this.setStraighten(straighten);
            }
            this.img = tempDestPoints;
            this.cropObj = tempCropObj;
            this.activeObj = tempSel;
            this.transform = tempTransform;
            this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                value: { zoomFactor: 0.1, zoomPoint: null, isResize: null } });
            this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                value: { zoomFactor: -0.1, zoomPoint: null, isResize: null } });
            Iif (this.transform.degree !== 0) {
                this.panPoint.currentPannedPoint = { x: panPoint.totalPannedClientPoint.x,
                    y: panPoint.totalPannedClientPoint.y };
                this.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panPoint.totalPannedClientPoint.x,
                        yDiff: panPoint.totalPannedClientPoint.y } });
                this.panPoint.currentPannedPoint = { x: 0, y: 0 };
                this.notify('transform', { prop: 'setTempPanMove', value: { point: null } });
            }
            this.noPushUndo = true;
            this.crop();
            this.noPushUndo = false;
            this.transform.straighten = 0;
            this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
            return imageData;
        };
        ImageEditor.prototype.applyShapes = function () {
            if (this.isUndoRedoStack) {
                return;
            }
            var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
            var dummyObj = { bool: false };
            this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: dummyObj } });
            if (dummyObj['bool'] || this.togglePen || (this.activeObj.shape && shapes.indexOf(this.activeObj.shape) !== -1) ||
                this.drawingShape) {
                this.okBtn(null, true);
            }
        };
        ImageEditor.prototype.closeOverlayTbar = function () {
            var isContextualToolbar = false;
            var frameObject = { bool: null };
            this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
            if (!frameObject['bool'] && this.element.querySelector('.e-contextual-toolbar-wrapper')) {
                Iif (!this.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
                    isContextualToolbar = true;
                }
                var straightenObj = { bool: this.isStraightening };
                Eif (!ej2_base_3.Browser.isDevice || (ej2_base_3.Browser.isDevice && !straightenObj['bool'])) {
                    this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
                }
            }
            return isContextualToolbar;
        };
        ImageEditor.prototype.toolbarTemplateFn = function () {
            var template;
            var templateID = this.element.id + '_toolbar';
            var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
            Eif (this.toolbarTemplate) {
                this.toolbarFn = this.templateParser(this.toolbarTemplate);
                Iif (this.isReact) {
                    template = this.toolbarFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
                }
                else Iif (this.isAngular) {
                    var templateColl = this.toolbarFn({ type: 'toolbar' }, this, 'Template', templateID);
                    template = (templateColl[0].nodeType === 3) ? templateColl[1] : templateColl[0];
                }
                else {
                    template = this.toolbarFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
                }
                toolbarArea.appendChild(template);
                this.toolbarHeight = toolbarArea.clientHeight;
                this.notify('toolbar', { prop: 'setToolbarHeight', value: { height: this.toolbarHeight } });
                this['renderReactTemplates']();
            }
        };
        ImageEditor.prototype.quickAccessToolbarTemplateFn = function () {
            var template;
            var templateID = this.element.id + '_quickAccessToolbar';
            var toolbarArea = this.element.querySelector('#' + this.element.id + '_quickAccessToolbarArea');
            Eif (this.quickAccessToolbarTemplate) {
                this.qatFn = this.templateParser(this.quickAccessToolbarTemplate);
                Iif (this.isReact) {
                    template = this.qatFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
                }
                else Iif (this.isAngular) {
                    var templateColl = this.qatFn({ type: 'toolbar' }, this, 'Template', templateID);
                    template = (templateColl[0].nodeType === 3) ? templateColl[1] : templateColl[0];
                }
                else {
                    template = this.qatFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
                }
                toolbarArea.appendChild(template);
                this['renderReactTemplates']();
            }
        };
        ImageEditor.prototype.templateParser = function (template) {
            Eif (template) {
                try {
                    Iif (typeof template !== 'function' && document.querySelectorAll(template).length) {
                        return ej2_base_3.compile(document.querySelector(template).innerHTML.trim());
                    }
                    else {
                        return ej2_base_3.compile(template);
                    }
                }
                catch (error) {
                    return ej2_base_3.compile(template);
                }
            }
            return undefined;
        };
        ImageEditor.prototype.getTextFromId = function (id) {
            var idToValue = { '1': 'none', '2': 'bar', '3': 'arrow', '4': 'arrowSolid',
                '5': 'circle', '6': 'circleSolid', '7': 'square', '8': 'squareSolid' };
            return idToValue["" + id];
        };
        ImageEditor.prototype.getFinetuneOption = function (type) {
            var typeToOption = { 'brightness': index_2.ImageFinetuneOption.Brightness, 'contrast': index_2.ImageFinetuneOption.Contrast,
                'hue': index_2.ImageFinetuneOption.Hue, 'saturation': index_2.ImageFinetuneOption.Saturation, 'opacity': index_2.ImageFinetuneOption.Opacity,
                'blur': index_2.ImageFinetuneOption.Blur, 'exposure': index_2.ImageFinetuneOption.Exposure };
            return typeToOption["" + type];
        };
        ImageEditor.prototype.setPenStroke = function (args) {
            this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: parseInt(args, 10) } });
        };
        ImageEditor.prototype.updateFreehandDrawColorChange = function () {
            var obj = { tempFreeHandDrawEditingStyles: null };
            this.notify('freehand-draw', { prop: 'getTempFreeHandDrawEditingStyles', value: { obj: obj } });
            this.notify('freehand-draw', { prop: 'color-change', value: { color: obj['tempFreeHandDrawEditingStyles'].strokeColor } });
        };
        ImageEditor.prototype.getUndoRedoColl = function () {
            var obj = { undoRedoColl: null, index: null };
            var undoRedoObj = { undoRedoStep: null };
            var object = { appliedUndoRedoColl: [] };
            this.notify('undo-redo', { prop: 'getAppliedUndoRedoColl', value: { obj: object } });
            this.notify('undo-redo', { prop: 'getUndoRedoStep', value: { obj: undoRedoObj } });
            obj['undoRedoColl'] = object['appliedUndoRedoColl'];
            obj['index'] = undoRedoObj['undoRedoStep'];
            return obj;
        };
        ImageEditor.prototype.updateImageTransformColl = function (type) {
            var value;
            if (type === 'rotateleft') {
                value = -90;
            }
            else if (type === 'rotateright') {
                value = 90;
            }
            else if (type === 'horizontalflip') {
                value = 'horizontal';
            }
            else Eif (type === 'verticalflip') {
                value = 'vertical';
            }
            for (var i = 0; i < this.objColl.length; i++) {
                var shape = this.objColl[i].shape;
                if (shape === 'image' || shape === 'text') {
                    if (ej2_base_2.isNullOrUndefined(this.objColl[i].rotateFlipColl)) {
                        this.objColl[i].rotateFlipColl = [];
                    }
                    this.objColl[i].rotateFlipColl.push(value);
                    var obj = { collection: this.objColl[i].rotateFlipColl };
                    this.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
                        value: { collection: this.objColl[i].rotateFlipColl, isRotateFlipCollection: false, obj: obj } });
                    this.objColl[i].rotateFlipColl = obj['collection'];
                }
            }
        };
        ImageEditor.prototype.setInitialZoomState = function () {
            this.objColl.push(this.activeObj);
            this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
            var isUndoRedo = this.isUndoRedo;
            this.isCropTab = false;
            this.isUndoRedo = true;
            if (this.transform.cropZoomFactor && this.transform.cropZoomFactor > 0) {
                this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                    value: { zoomFactor: -this.transform.cropZoomFactor, zoomPoint: null, isResize: true } });
            }
            else {
                this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                    value: { zoomFactor: Math.abs(this.transform.cropZoomFactor), zoomPoint: null, isResize: true } });
            }
            this.isUndoRedo = isUndoRedo;
            this.panPoint.totalPannedPoint = { x: 0, y: 0 };
            this.transform.cropZoomFactor = 0;
            this.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
            this.activeObj = ej2_base_1.extend({}, this.objColl[this.objColl.length - 1], {}, true);
            this.objColl.pop();
            this.isCropTab = true;
            this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: this.activeObj } });
        };
        ImageEditor.prototype.updateCropTransformItems = function () {
            this.prevCurrSelectionPoint = ej2_base_1.extend({}, this.currSelectionPoint, {}, true);
            this.notify('draw', { prop: 'updateCropSelection', onPropertyChange: false });
        };
        ImageEditor.prototype.toPascalCase = function (str, obj) {
            var strArr = [];
            if (!ej2_base_2.isNullOrUndefined(str)) {
                strArr = str.toLowerCase().split('-');
            }
            for (var i = 0; i < strArr.length; i++) {
                strArr[i] = strArr[i].charAt(0).toUpperCase() + strArr[i].slice(1);
            }
            Iif (obj) {
                obj['maxText'] = strArr.join('');
            }
            return strArr.join('');
        };
        ImageEditor.prototype.getFontSizes = function () {
            var items = [];
            this.fontSizeColl = [];
            var fontSize;
            if (this.transform.degree === 0 || this.transform.degree % 180 === 0) {
                fontSize = this.img.destWidth / 25;
            }
            else {
                fontSize = this.img.destHeight / 25;
            }
            for (var i = 1; i <= 10; i++) {
                this.fontSizeColl.push({ text: (i * (Math.round(fontSize / 2))).toString() });
                items.push({ text: (i.toString()) });
            }
            return items;
        };
        ImageEditor.prototype.updateDropInfoContent = function (dropInfoElement) {
            Iif (!dropInfoElement) {
                return;
            }
            var supportObj = { key: 'SupportText' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
            var words = this.getExtensionString();
            var fileSizeObj = { key: 'MinMaxSize' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
            var andObj = { key: 'And' };
            this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
            var size;
            if (this.uploadSettings.minFileSize && this.uploadSettings.maxFileSize) {
                size = ' ' + fileSizeObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.minFileSize) + ' ' + andObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.maxFileSize);
            }
            else if (this.uploadSettings.minFileSize) {
                fileSizeObj['key'] = 'MinSize';
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
                size = ' ' + fileSizeObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.minFileSize);
            }
            else if (this.uploadSettings.maxFileSize) {
                fileSizeObj['key'] = 'MaxSize';
                this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
                size = ' ' + fileSizeObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.maxFileSize);
            }
            if (size) {
                dropInfoElement.textContent = supportObj['value'] + words + size;
            }
            else {
                dropInfoElement.textContent = supportObj['value'] + words;
            }
        };
        ImageEditor.prototype.okBtn = function (isMouseDown, isFinalApply, isResize) {
            if (isFinalApply) {
                this.noPushUndo = false;
                var tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
                    flipObjColl: [], triangle: [], triangleRatio: [], order: null };
                this.notify('selection', { prop: 'setTempActObj', onPropertyChange: false, value: { obj: tempActiveObj } });
            }
            var ctWrapper = this.element.querySelector('.e-contextual-toolbar-wrapper');
            if (ctWrapper) {
                ctWrapper.classList.remove('e-frame-wrapper');
            }
            var isCropSelection = false;
            var splitWords;
            this.isResizeOkBtn = true;
            var aspectIcon = this.element.querySelector('#' + this.element.id + '_aspectratio');
            var nonAspectIcon = this.element.querySelector('#' + this.element.id + '_nonaspectratio');
            var blrAspRatElem = this.element.querySelector('.e-ie-toolbar-aspect-ratio-btn');
            var blrNAspRatElem = this.element.querySelector('.e-ie-toolbar-nonaspect-ratio-btn');
            if (this.activeObj.shape !== undefined) {
                splitWords = this.activeObj.shape.split('-');
            }
            Iif (splitWords === undefined && this.currObjType.isCustomCrop) {
                isCropSelection = true;
            }
            else if (splitWords !== undefined && splitWords[0] === 'crop') {
                isCropSelection = true;
            }
            this.allowDownScale = true;
            if ((this.activeObj.shape && this.activeObj.shape !== 'image' || this.togglePen) && !isCropSelection) {
                var objt = { shapeSettingsObj: {} };
                this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
                var shapeSettings = objt['shapeSettingsObj'];
                if (this.togglePen) {
                    shapeSettings.type = index_1.ShapeType.FreehandDraw;
                }
                var shapeChangedArgs = { action: 'apply', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
                if (!this.currObjType.isRedact && (isFinalApply || this.isShapeDrawing)) {
                    Iif (this.isShapeDrawing) {
                        shapeChangedArgs.action = 'draw-end';
                    }
                    this.trigger('shapeChange', shapeChangedArgs);
                }
                this.editCompleteArgs = shapeChangedArgs;
                if (this.currObjType.isRedact) {
                    this.currObjType.isRedact = false;
                }
            }
            if (aspectIcon || nonAspectIcon) {
                var obj_2 = { width: null, height: null };
                this.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj_2 } });
                var point = { x: obj_2['width'], y: obj_2['height'] };
                var obj1 = { prevCropObj: this.prevCropObj };
                var obj2 = { prevObj: this.prevObj };
                Eif (point && point.x && point.y && obj1['prevCropObj'] && obj2['prevObj']) {
                    if (nonAspectIcon || (blrNAspRatElem && !blrNAspRatElem.classList.contains('e-hidden'))) {
                        this.notify('transform', { prop: 'resize', value: { width: point.x, height: point.y, isAspectRatio: false } });
                    }
                    else Eif (aspectIcon || (blrAspRatElem && !blrAspRatElem.classList.contains('e-hidden'))) {
                        this.notify('transform', { prop: 'resize', value: { width: point.x, height: null, isAspectRatio: true } });
                    }
                    this.isResize = false;
                    this.aspectWidth = point.x;
                    this.aspectHeight = point.y;
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                            isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
                    this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                        value: { zoomFactor: -this.transform.zoomFactor, zoomPoint: null, isResize: true } });
                    this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                        value: { zoomFactor: obj2['prevObj']['defaultZoom'], zoomPoint: null, isResize: true } });
                    Eif (obj2['prevObj'].zoomFactor) {
                        this.setProperties({ zoomSettings: { zoomFactor: obj2['prevObj'].zoomFactor } }, true);
                    }
                    this.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
                        value: { previousZoomValue: this.zoomSettings.zoomFactor } });
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'resize',
                            previousObj: obj2['prevObj'], previousObjColl: obj2['prevObj']['objColl'],
                            previousPointColl: obj2['prevObj']['pointColl'], previousSelPointColl: obj2['prevObj']['selPointColl'],
                            previousCropObj: obj1['prevCropObj'], previousText: null, currentText: null, previousFilter: null,
                            isCircleCrop: null } });
                    this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                    var obj_3 = this.cancelCropSelection;
                    if ((obj_3 && (ej2_base_2.isNullOrUndefined(nonAspectIcon) || !nonAspectIcon))) {
                        obj_3.previousObj.aspectWidth = obj_3.currentObj.aspectWidth = this.aspectWidth;
                        obj_3.previousObj.aspectHeight = obj_3.currentObj.aspectHeight = this.aspectHeight;
                        obj_3.previousCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                        obj_3.currentCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                        this.notify('draw', { prop: 'updateCropSelObj' });
                    }
                    this.cancelCropSelection = null;
                }
                else if (point && (point.x === 0 || point.y === 0)) {
                    this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
                }
                else {
                    this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                            isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
                }
                this.isAspectRatio = false;
            }
            else if (isResize) {
                var isAspectRatio = false;
                Iif (this.aspectWidth && this.aspectHeight) {
                    this.notify('transform', { prop: 'resize', value: { width: this.aspectWidth, height: this.aspectHeight, isAspectRatio: false } });
                }
                else Eif (this.aspectWidth) {
                    this.notify('transform', { prop: 'resize', value: { width: this.aspectWidth, height: null, isAspectRatio: true } });
                    this.aspectHeight = this.aspectWidth / (this.img.destWidth / this.img.destHeight);
                    isAspectRatio = true;
                }
                this.isResize = false;
                this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                        isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
                this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                    value: { zoomFactor: -this.transform.zoomFactor, zoomPoint: null, isResize: true } });
                this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
                    value: { zoomFactor: this.prevObj['defaultZoom'], zoomPoint: null, isResize: true } });
                Eif (this.prevObj.zoomFactor) {
                    this.setProperties({ zoomSettings: { zoomFactor: this.prevObj.zoomFactor } }, true);
                }
                this.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
                    value: { previousZoomValue: this.zoomSettings.zoomFactor } });
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'resize',
                        previousObj: this.prevObj, previousObjColl: this.prevObj['objColl'],
                        previousPointColl: this.prevObj['pointColl'], previousSelPointColl: this.prevObj['selPointColl'],
                        previousCropObj: this.prevCropObj, previousText: null, currentText: null, previousFilter: null,
                        isCircleCrop: null } });
                this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                var obj_4 = this.cancelCropSelection;
                Eif ((obj_4 && isAspectRatio)) {
                    obj_4.previousObj.aspectWidth = obj_4.currentObj.aspectWidth = this.aspectWidth;
                    obj_4.previousObj.aspectHeight = obj_4.currentObj.aspectHeight = this.aspectHeight;
                    obj_4.previousCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                    obj_4.currentCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                    this.notify('draw', { prop: 'updateCropSelObj' });
                }
                this.cancelCropSelection = null;
                this.isAspectRatio = false;
            }
            var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
            var obj = { bool: false };
            this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
            var frameObject = { bool: null };
            this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
            var sliderWrap = document.querySelector('#' + this.element.id + '_sliderWrapper');
            Iif (selElem) {
                this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
            }
            if (isCropSelection) {
                if (this.transform.straighten !== 0 && (this.panPoint.totalPannedPoint.x !== 0 || this.panPoint.totalPannedPoint.y !== 0 ||
                    this.panPoint.totalPannedClientPoint.x !== 0 || this.panPoint.totalPannedClientPoint.y !== 0)) {
                    var temp = this.prevStraightenedDegree;
                    this.prevStraightenedDegree = this.transform.straighten;
                    this.setStraighten(this.transform.straighten - 3);
                    this.setStraighten(this.transform.straighten + 3);
                    this.prevStraightenedDegree = temp;
                }
                this.isCroppedEvent = this.crop();
            }
            else if (this.togglePen) {
                this.freeHandDraw(false);
                if (!this.isMaskImage) {
                    var widthObj = { penStrokeWidth: null };
                    this.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: widthObj } });
                    this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                    this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: widthObj['penStrokeWidth'] } });
                }
                this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
                this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
            }
            else if (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
                this.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
                    value: { x: null, y: null, isMouseDown: null } });
                this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
                this.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
                Eif (ej2_base_2.isNullOrUndefined(isMouseDown)) {
                    this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                }
                this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
                this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
            }
            else if ((sliderWrap || this.currObjType.isFiltered) && !this.drawingShape && this.activeObj.shape !== 'redact') {
                this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
                this.currObjType.isFiltered = false;
                var obj_5 = { value: null };
                this.notify('draw', { prop: 'getTempAdjustmentValue', value: { obj: obj_5 } });
                Eif (!sliderWrap || sliderWrap.parentElement.previousElementSibling.textContent !== 'Opacity') {
                    this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                }
                Iif ((this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) ||
                    (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
                    this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
                }
            }
            else if (obj['bool']) {
                this.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
                this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
                this.notify('toolbar', { prop: 'destroy-qa-toolbar' });
                this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                this.notify('freehand-draw', { prop: 'resetFreehandDrawSelectedId', onPropertyChange: false });
            }
            else if ((this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) ||
                (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
                if (this.activeObj.shape === 'image') {
                    this.notify('draw', { prop: 'setImageApply', onPropertyChange: false, value: { bool: true } });
                }
                this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
            }
            else {
                if (JSON.stringify(this.frameObj) !== JSON.stringify(this.tempFrameObj)) {
                    var object = { currObj: {} };
                    this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: {
                            operation: 'frame', previousObj: object['currObj'], previousObjColl: object['currObj']['objColl'],
                            previousPointColl: object['currObj']['pointColl'], previousSelPointColl: object['currObj']['selPointColl'],
                            previousCropObj: ej2_base_1.extend({}, this.cropObj, {}, true), previousText: null, currentText: null,
                            previousFilter: null, isCircleCrop: null
                        } });
                    this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: true } });
                    var currFrameSettings = { type: this.toPascalCase(this.frameObj.type),
                        color: this.frameObj.color, gradientColor: this.frameObj.gradientColor, size: this.frameObj.size,
                        inset: this.frameObj.inset, offset: this.frameObj.offset, borderRadius: this.frameObj.radius,
                        frameLineStyle: this.toPascalCase(this.frameObj.border), lineCount: this.frameObj.amount };
                    var prevFrameSettings = { type: this.toPascalCase(this.tempFrameObj.type),
                        color: this.tempFrameObj.color, gradientColor: this.tempFrameObj.gradientColor, size: this.tempFrameObj.size,
                        inset: this.tempFrameObj.inset, offset: this.tempFrameObj.offset, borderRadius: this.tempFrameObj.radius,
                        frameLineStyle: this.toPascalCase(this.tempFrameObj.border), lineCount: this.tempFrameObj.amount };
                    var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings,
                        currentFrameSetting: currFrameSettings };
                    this.editCompleteArgs = frameChange;
                    this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
                    this.tempFrameObj = ej2_base_1.extend({}, this.frameObj, {}, true);
                }
                this.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false, value: { isOk: true } });
            }
            Eif (!obj['isCropToolbar']) {
                this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                        isApplyBtn: false, isCropping: null, isZooming: null, cType: null } });
                this.currObjType.isRedact = false;
            }
            this.notify('draw', { prop: 'setNewPath', value: { bool: false } });
            this.transform.zoomFactor = this.transform.defaultZoomFactor;
            this.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
            this.isResizeOkBtn = false;
            this.notify('draw', { prop: 'redrawDownScale' });
            this.isChangesSaved = this.isFinetuneBtnClick = false;
            if (isFinalApply) {
                this.drawingShape = null;
                this.notify('draw', { prop: 'resetTempObjColl' });
                this.notify('draw', { prop: 'resetTempPointColl' });
            }
        };
        ImageEditor.prototype.triggerEditCompleteEvent = function (args) {
            var obj = { bool: false };
            this.notify('undo-redo', { prop: 'preventEditComplete', value: { obj: obj } });
            if (obj['bool']) {
                return;
            }
            if (args.action === 'shape-insert' && args.actionEventArgs &&
                args.actionEventArgs.currentShapeSettings &&
                args.actionEventArgs.currentShapeSettings.type.toString() === 'Redact') {
                args.action = 'redact';
            }
            this.trigger('editComplete', args);
            this.editCompleteArgs = null;
        };
        ImageEditor.prototype.getObjFromId = function (id) {
            var obj;
            if (this.activeObj.currIndex && this.activeObj.currIndex === id) {
                obj = ej2_base_1.extend({}, this.activeObj, {}, true);
            }
            else {
                for (var i = 0; i < this.shapeColl.length; i++) {
                    var shapeId = this.shapeColl[i].id ? this.shapeColl[i].id :
                        this.shapeColl[i].currIndex;
                    Eif (shapeId === id) {
                        obj = ej2_base_1.extend({}, this.shapeColl[i], {}, true);
                        break;
                    }
                }
            }
            return obj;
        };
        ImageEditor.prototype.setTempFilterProperties = function () {
            this.upperCanvas.style.display = 'block';
            this.cropSelectedState();
            var obj = { adjustmentLevel: null };
            this.notify('filter', { prop: 'getAdjustmentLevel', onPropertyChange: false,
                value: { obj: obj } });
            this.lowerContext.filter = this.initialAdjustmentValue;
            this.notify('draw', { prop: 'setTempAdjustmentValue', value: { tempAdjustmentValue: this.lowerContext.filter } });
            this.notify('filter', { prop: 'setTempAdjustmentLevel', onPropertyChange: false,
                value: { tempAdjustmentLevel: ej2_base_1.extend({}, obj['adjustmentLevel'], {}, true) } });
            this.notify('draw', { prop: 'setTempFilter', value: { tempFilter: this.currentFilter } });
            var undoRedoObj = { undoRedoStep: null };
            this.notify('undo-redo', { prop: 'getUndoRedoStep', value: { obj: undoRedoObj } });
            this.notify('draw', { prop: 'setTempUndoRedoStep', value: { tempUndoRedoStep: undoRedoObj['undoRedoStep'] } });
        };
        ImageEditor.prototype.cropSelectedState = function () {
            if (this.activeObj.shape && this.activeObj.shape.split('-')[0] === 'crop') {
                this.okBtn();
            }
        };
        ImageEditor.prototype.getCurrentCanvasData = function () {
            var tempFrame = ej2_base_1.extend({}, this.frameObj, {}, true);
            this.frameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
            var tempFilter = this.lowerContext.filter;
            this.lowerContext.filter = this.canvasFilter = 'none';
            var objColl = ej2_base_1.extend([], this.objColl, null, true);
            var pointColl = ej2_base_1.extend([], this.pointColl, null, true);
            this.objColl = [];
            this.pointColl = [];
            this.freehandCounter = 0;
            this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
            var ctWrapper = this.element.querySelector('.e-contextual-toolbar-wrapper');
            Eif (ctWrapper) {
                ctWrapper.classList.add('e-hide');
            }
            var data = this.getImageData();
            Eif (ctWrapper) {
                ctWrapper.classList.remove('e-hide');
            }
            Eif (!ej2_base_3.Browser.isDevice) {
                this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
                        isApplyBtn: true, isCropping: false } });
            }
            this.element.querySelector('#' + this.element.id + '_contextualToolbarArea').classList.remove('e-hide');
            this.objColl = objColl;
            this.pointColl = pointColl;
            this.freehandCounter = pointColl.length;
            this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
            this.lowerContext.filter = this.canvasFilter = tempFilter;
            this.frameObj = tempFrame;
            return data;
        };
        ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
            var finetuneValueChanging = { finetune: this.getFinetuneOption(type), value: value, cancel: false };
            this.trigger('finetuneValueChanging', finetuneValueChanging);
            this.editCompleteArgs = finetuneValueChanging;
            Iif (finetuneValueChanging.cancel) {
                return;
            }
            this.notify('filter', { prop: 'setCurrAdjValue', value: { type: type.toLowerCase(), value: value } });
        };
        ImageEditor.prototype.getSquarePointForPath = function (obj) {
            var point = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
            Eif (obj.pointColl.length > 0) {
                point = { startX: obj.pointColl[0].x, startY: obj.pointColl[0].y, endX: obj.pointColl[0].x, endY: obj.pointColl[0].y };
                for (var i = 1; i < obj.pointColl.length; i++) {
                    Iif (obj.pointColl[i].x < point.startX) {
                        point.startX = obj.pointColl[i].x;
                    }
                    Iif (obj.pointColl[i].y < point.startY) {
                        point.startY = obj.pointColl[i].y;
                    }
                    Eif (obj.pointColl[i].x > point.endX) {
                        point.endX = obj.pointColl[i].x;
                    }
                    if (obj.pointColl[i].y > point.endY) {
                        point.endY = obj.pointColl[i].y;
                    }
                }
                point.width = point.endX - point.startX;
                point.height = point.endY - point.startY;
            }
            return point;
        };
        ImageEditor.prototype.getSelectionType = function (type) {
            type = type === 'crop-custom' ? 'CropCustom' : type;
            var typeToSelectionType = { 'CropCustom': 'Custom', 'CropSquare': 'Square', 'CropCircle': 'Circle',
                'Crop3:2': '3:2', 'Crop4:3': '4:3', 'Crop5:4': '5:4', 'Crop7:5': '7:5', 'Crop16:9': '16:9',
                'Crop2:3': '2:3', 'Crop3:4': '3:4', 'Crop4:5': '4:5', 'Crop5:7': '5:7', 'Crop9:16': '9:16' };
            return typeToSelectionType["" + type] ? typeToSelectionType["" + type] : type.split('Crop')[1];
        };
        ImageEditor.prototype.clearContext = function (ctx) {
            ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
            ctx.clearRect(0, 0, ctx.canvas.height, ctx.canvas.width);
        };
        ImageEditor.prototype.updateArrow = function (type, id) {
            var isObjPushed = false;
            var collLength = this.objColl.length;
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            Eif (collLength !== this.objColl.length) {
                isObjPushed = true;
            }
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var object = { currObj: {} };
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            Eif (isObjPushed) {
                this.objColl.pop();
            }
            if (type === 'startArrow') {
                this.activeObj.start = this.getTextFromId(id);
            }
            else Eif (type === 'endArrow') {
                this.activeObj.end = this.getTextFromId(id);
            }
            this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                    strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
            this.objColl.push(this.activeObj);
            Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
            }
            this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            Iif (ej2_base_3.Browser.isDevice) {
                if (document.getElementById(this.element.id + '_bottomToolbar')) {
                    var toolbar_1 = ej2_base_2.getComponent(this.element.id + '_bottomToolbar', 'toolbar');
                    toolbar_1.refreshOverflow();
                }
            }
            else {
                Eif (document.getElementById(this.element.id + '_toolbar')) {
                    var toolbar_2 = ej2_base_2.getComponent(this.element.id + '_toolbar', 'toolbar');
                    toolbar_2.refreshOverflow();
                }
            }
            var shapeChangedArgs = { action: type, currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updateFontFamily = function (id) {
            this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
            var isObjPushed = false;
            var collLength = this.objColl.length;
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            Eif (collLength !== this.objColl.length) {
                isObjPushed = true;
            }
            var objColl = ej2_base_1.extend([], this.objColl, [], true);
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            Eif (isObjPushed) {
                this.objColl.pop();
            }
            if (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
                this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
                    value: { obj: this.activeObj, isTextArea: true } });
                var temp = this.activeObj.textSettings.fontFamily;
                this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('shape', { prop: 'redraw-text' });
                }
                this.objColl.push(this.activeObj);
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                }
                this.objColl.pop();
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                var width = this.activeObj.activePoint.width +
                    this.activeObj.textSettings.fontSize * 0.25;
                this.textArea.style.width = width + 'px';
                this.textArea.style.fontFamily = this.toPascalCase(id);
                this.activeObj.textSettings.fontFamily = temp;
                this.notify('shape', { prop: 'updateFontStyles', onPropertyChange: false,
                    value: { isTextBox: null } });
            }
            else {
                this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
                    value: { obj: this.activeObj, isTextArea: null } });
                var fontFamily = this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
                this.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
                    value: { textSettings: null, fontFamily: fontFamily, fontSize: null } });
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('shape', { prop: 'redraw-text' });
                }
                this.objColl.push(this.activeObj);
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: objColl,
                            previousPointColl: ej2_base_1.extend([], this.pointColl, [], true),
                            previousSelPointColl: prevObj.selPointColl, previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                }
                this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            }
            var shapeChangedArgs = { action: 'font-family', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.fontFamily = this.textArea.style.fontFamily;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updateFontSize = function (text) {
            var itemText = text;
            this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
            var isObjPushed = false;
            var collLength = this.objColl.length;
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            Eif (collLength !== this.objColl.length) {
                isObjPushed = true;
            }
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            Eif (isObjPushed) {
                this.objColl.pop();
            }
            if (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
                this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
                    value: { obj: this.activeObj, isTextArea: true } });
                var temp = this.activeObj.textSettings.fontSize;
                this.activeObj.textSettings.fontSize = parseInt(this.fontSizeColl[(parseInt(itemText, 10) - 1)].text, 10);
                this.objColl.push(this.activeObj);
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                }
                this.objColl.pop();
                var textStyle = '';
                Eif (this.textArea.style.fontWeight === 'bold') {
                    textStyle = 'bold ';
                }
                Eif (this.textArea.style.fontStyle === 'italic') {
                    textStyle = 'italic ';
                }
                Eif (this.textArea.style.fontWeight === 'bold' && this.textArea.style.fontStyle === 'italic') {
                    textStyle = 'italic bold ';
                }
                this.upperContext.font = textStyle + this.activeObj.textSettings.fontSize + 'px' + ' ' + this.textArea.style.fontFamily;
                var rows = this.textArea.value.split('\n');
                var obj = { maxText: '' };
                this.notify('shape', { prop: 'getMaxText', onPropertyChange: false,
                    value: { isTextBox: true, text: null, obj: obj } });
                var text_1 = obj['maxText'];
                var width = this.upperContext.measureText(text_1).width +
                    this.activeObj.textSettings.fontSize * 0.5;
                this.textArea.style.width = width + 'px';
                this.textArea.style.height = rows.length * (this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25) + 'px';
                this.activeObj.textSettings.fontSize = temp;
                this.upperContext.font = this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
                this.textArea.style.fontSize = parseInt(this.fontSizeColl[(parseInt(itemText, 10) - 1)].text, 10) + 'px';
                Iif (this.textArea.style.fontFamily === 'georgia') {
                    this.textArea.style.width = parseFloat(this.textArea.style.width) + parseFloat(this.textArea.style.fontSize) + 'px';
                }
            }
            else {
                this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
                    value: { obj: this.activeObj, isTextArea: null } });
                var fontSize = this.activeObj.textSettings.fontSize = parseInt(this.fontSizeColl[(parseInt(itemText, 10) - 1)].text, 10);
                this.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
                    value: { textSettings: null, fontFamily: null, fontSize: fontSize } });
                this.upperContext.font = this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
                var rows = this.activeObj.keyHistory.split('\n');
                var obj = { maxText: '' };
                this.notify('shape', { prop: 'getMaxText', onPropertyChange: false,
                    value: { isTextBox: null, text: null, obj: obj } });
                var text_2 = obj['maxText'];
                var width = this.upperContext.measureText(text_2).width +
                    this.activeObj.textSettings.fontSize * 0.5;
                var height = rows.length * (this.activeObj.textSettings.fontSize +
                    this.activeObj.textSettings.fontSize * 0.25);
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
                        value: { width: width, height: height } });
                    this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: this.activeObj.activePoint, obj: this.activeObj,
                            isMouseMove: null, x: null, y: null } });
                    this.notify('shape', { prop: 'redraw-text' });
                }
                this.objColl.push(this.activeObj);
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                }
                this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            }
            var shapeChangedArgs = { action: 'font-size', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.fontSize = this.activeObj.textSettings.fontSize;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updateFontColor = function (value, color) {
            this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
            var isObjPushed = false;
            var collLength = this.objColl.length;
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            Eif (collLength !== this.objColl.length) {
                isObjPushed = true;
            }
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            Eif (isObjPushed) {
                this.objColl.pop();
            }
            if (this.textArea.style.display === 'none') {
                if (color === 'Text') {
                    this.activeObj.strokeSettings.strokeColor = value;
                    this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null,
                            strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
                }
                else {
                    this.activeObj.strokeSettings.fillColor = value;
                    this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null,
                            strokeColor: null, fillColor: this.activeObj.strokeSettings.fillColor, strokeWidth: null } });
                }
                Eif (!this.togglePen) {
                    Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                        this.objColl.push(this.activeObj);
                        this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                            value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                                previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                                previousCropObj: prevCropObj, previousText: null,
                                currentText: null, previousFilter: null, isCircleCrop: null } });
                        this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                    }
                }
            }
            else Eif (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
                this.textArea.style[color === 'Text' ? 'color' : 'backgroundColor'] = value;
                var temp = color === 'Text' ? this.activeObj.strokeSettings.strokeColor : this.activeObj.strokeSettings.fillColor;
                this.activeObj.strokeSettings[color === 'Text' ? 'strokeColor' : 'fillColor'] = value;
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.objColl.push(this.activeObj);
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                    this.objColl.pop();
                }
                this.activeObj.strokeSettings[color === 'Text' ? 'strokeColor' : 'fillColor'] = temp;
            }
            else if (!this.togglePen) {
                if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.objColl.push(this.activeObj);
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                    this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                }
            }
            var shapeChangedArgs = { action: 'font-color', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.fillColor = value;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updateStrokeTextColor = function (value) {
            this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
            var isObjPushed = false;
            var collLength = this.objColl.length;
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            Eif (collLength !== this.objColl.length) {
                isObjPushed = true;
            }
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            Eif (isObjPushed) {
                this.objColl.pop();
            }
            if (this.textArea.style.display === 'none') {
                this.activeObj.strokeSettings.outlineColor = value;
                this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null,
                        strokeColor: null, fillColor: null, strokeWidth: null, outlineColor: this.activeObj.strokeSettings.outlineColor } });
                Eif (!this.togglePen) {
                    Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                        this.objColl.push(this.activeObj);
                        this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                            value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                                previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                                previousCropObj: prevCropObj, previousText: null,
                                currentText: null, previousFilter: null, isCircleCrop: null } });
                        this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                    }
                }
            }
            else Eif (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
                this.textArea.style.textShadow = "-1px -1px 0 " + value + ", 1px -1px 0 " + value + ", -1px 1px 0 " + value + ", 1px 1px 0 " + value;
                var temp = this.activeObj.strokeSettings.outlineColor;
                this.activeObj.strokeSettings.outlineColor = value;
                Eif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.objColl.push(this.activeObj);
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                    this.objColl.pop();
                }
                this.activeObj.strokeSettings.outlineColor = temp;
            }
            else if (!this.togglePen) {
                if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.objColl.push(this.activeObj);
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                    this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                }
            }
            var shapeChangedArgs = { action: 'font-color', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.fillColor = value;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updatePenStrokeWidth = function (id) {
            var temp = ej2_base_1.extend([], this.pointColl, [], true);
            this.updateFreehandDrawColorChange();
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            this.pointColl = temp;
            this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: true } });
            this.setPenStroke(id);
            var obj = { bool: false };
            this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
            Iif (obj['bool']) {
                var obj_6 = { penStrokeWidth: null };
                this.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: obj_6 } });
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
                this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
                    value: { strokeColor: null, strokeWidth: obj_6['penStrokeWidth'] } });
                var indexObj = { freehandSelectedIndex: null };
                this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
                this.pointColl[indexObj['freehandSelectedIndex']].strokeWidth = obj_6['penStrokeWidth'];
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
                this.notify('draw', { prop: 'redrawDownScale' });
                this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
                    value: { strokeColor: null, strokeWidth: obj_6['penStrokeWidth'] } });
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'freehanddrawCustomized', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                        previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
            }
            shapeSettings.type = index_1.ShapeType.FreehandDraw;
            var shapeChangedArgs = { action: 'stroke-width', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.strokeWidth = this.activeObj.strokeSettings.strokeWidth;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updatePenStrokeColor = function (value) {
            var temp = ej2_base_1.extend([], this.pointColl, [], true);
            this.updateFreehandDrawColorChange();
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            this.pointColl = temp;
            this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: true } });
            this.activeObj.strokeSettings.strokeColor = value;
            var indexObj = { freehandSelectedIndex: null };
            this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
            if (indexObj['freehandSelectedIndex'] !== null && indexObj['freehandSelectedIndex'] !== undefined) {
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
                this.notify('draw', { prop: 'redrawDownScale' });
                this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
                    value: { strokeColor: null, strokeWidth: null } });
            }
            var obj = { bool: false };
            this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
            if (obj['bool']) {
                var indexObj_1 = { freehandSelectedIndex: null };
                this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj_1 } });
                this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
                this.pointColl[indexObj_1['freehandSelectedIndex']].strokeColor = value;
                this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
                    value: { strokeColor: value } });
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'freehanddrawCustomized', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                        previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
            }
            else Iif (!this.togglePen) {
                this.notify('selection', { prop: 'redrawShape', value: { obj: this.activeObj } });
            }
            shapeSettings.type = index_1.ShapeType.FreehandDraw;
            var shapeChangedArgs = { action: 'stroke-color', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.strokeColor = value;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updateStrokeWidth = function (id, type, shapeType) {
            Eif (this.activeObj.shape && (this.activeObj.shape !== 'path' || (this.activeObj.shape === 'path' &&
                this.activeObj.pointColl.length > 0))) {
                var obj = { shapeSettingsObj: {} };
                this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
                var shapeSettings = obj['shapeSettingsObj'];
                var isObjPushed = false;
                var collLength = this.objColl.length;
                this.notify('shape', { prop: 'pushActItemIntoObj' });
                if (collLength !== this.objColl.length) {
                    isObjPushed = true;
                }
                var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                var object = { currObj: {} };
                this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                var prevObj = object['currObj'];
                prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
                prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
                prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                if (isObjPushed) {
                    this.objColl.pop();
                }
                this.activeObj.strokeSettings[type === 'width' ? (shapeType === 'text' ? 'outlineWidth' : 'strokeWidth') : 'radius'] = parseInt(id, 10);
                Eif (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse') {
                    this.activeObj.strokeSettings[type === 'width' ? (shapeType === 'text' ? 'outlineWidth' : 'strokeWidth') : 'radius'] = parseInt(id, 10) - 1;
                }
                this.activeObj.strokeSettings[type === 'width' ? (shapeType === 'text' ? 'outlineWidth' : 'strokeWidth') : 'radius'] *= 2;
                if (type === 'width') {
                    Iif (shapeType === 'text') {
                        this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                                strokeWidth: null, radius: null, outlineWidth: this.activeObj.strokeSettings.outlineWidth } });
                    }
                    else {
                        this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                                strokeWidth: this.activeObj.strokeSettings.strokeWidth, radius: null, outlineWidth: null } });
                    }
                }
                else {
                    this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                            strokeWidth: null, radius: this.activeObj.strokeSettings.radius } });
                }
                this.objColl.push(this.activeObj);
                if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                    this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                        value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                            previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                            previousCropObj: prevCropObj, previousText: null,
                            currentText: null, previousFilter: null, isCircleCrop: null } });
                }
                this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                var shapeChangedArgs = { action: 'stroke-width', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
                shapeChangedArgs.currentShapeSettings[type === 'width' ? (shapeType === 'text' ? 'outlineWidth' : 'strokeWidth') : 'radius'] = this.activeObj.strokeSettings[type === 'width' ? (shapeType === 'text' ? 'outlineWidth' : 'strokeWidth') : 'radius'];
                this.trigger('shapeChange', shapeChangedArgs);
                this.editCompleteArgs = shapeChangedArgs;
            }
            else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
                this.activeObj.pointColl.length === 0)) {
                this.activeObj.strokeSettings.strokeWidth = parseInt(id, 10);
                this.activeObj.strokeSettings.strokeWidth *= 2;
                if (type === 'width') {
                    if (shapeType === 'text') {
                        this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                                strokeWidth: null, radius: null, outlineWidth: this.activeObj.strokeSettings.outlineWidth } });
                    }
                    else {
                        this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                                strokeWidth: this.activeObj.strokeSettings.strokeWidth, radius: null, outlineWidth: null } });
                    }
                }
                else {
                    this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                            strokeWidth: null, radius: this.activeObj.strokeSettings.radius } });
                }
            }
        };
        ImageEditor.prototype.updateStrokeColor = function (value) {
            var objt = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: objt } });
            var shapeSettings = objt['shapeSettingsObj'];
            Eif (this.activeObj.shape && (this.activeObj.shape !== 'path' || (this.activeObj.shape === 'path' &&
                this.activeObj.pointColl.length > 0))) {
                var isObjPushed = false;
                var collLength = this.objColl.length;
                this.notify('shape', { prop: 'pushActItemIntoObj' });
                Iif (collLength !== this.objColl.length) {
                    isObjPushed = true;
                }
                var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                var object = { currObj: {} };
                this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                var prevObj = object['currObj'];
                prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
                prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
                prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                Iif (isObjPushed) {
                    this.objColl.pop();
                }
                this.activeObj.strokeSettings.strokeColor = value;
                this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
                Eif (!this.togglePen) {
                    this.objColl.push(this.activeObj);
                    Iif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                        this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                            value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                                previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                                previousCropObj: prevCropObj, previousText: null,
                                currentText: null, previousFilter: null, isCircleCrop: null } });
                    }
                    this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                }
            }
            else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
                this.activeObj.pointColl.length === 0)) {
                this.activeObj.strokeSettings.strokeColor = value;
                this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
            }
            var shapeChangedArgs = { action: 'stroke-color', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            shapeChangedArgs.currentShapeSettings.strokeColor = value;
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.updateFillColor = function (value) {
            var obj = { shapeSettingsObj: {} };
            this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
            var shapeSettings = obj['shapeSettingsObj'];
            var isObjPushed = false;
            var collLength = this.objColl.length;
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            Iif (collLength !== this.objColl.length) {
                isObjPushed = true;
            }
            var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            var prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            Iif (isObjPushed) {
                this.objColl.pop();
            }
            this.activeObj.strokeSettings.fillColor = value;
            this.notify('shape', { prop: 'setStrokeSettings',
                value: { strokeSettings: null, strokeColor: null, fillColor: this.activeObj.strokeSettings.fillColor,
                    strokeWidth: null } });
            this.objColl.push(this.activeObj);
            Iif (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                        previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
            }
            this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            var shapeChangedArgs = { action: 'fill-color', currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
            this.trigger('shapeChange', shapeChangedArgs);
            this.editCompleteArgs = shapeChangedArgs;
        };
        ImageEditor.prototype.horizontalFlip = function (ctx, isPreventURC) {
            var prevCropObj;
            var prevObj;
            if (ej2_base_2.isNullOrUndefined(isPreventURC)) {
                Iif (ej2_base_2.isNullOrUndefined(this.activeObj.imageRatio)) {
                    this.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
                }
                this.notify('shape', { prop: 'pushActItemIntoObj' });
                prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                var object = { currObj: {} };
                this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                prevObj = object['currObj'];
                prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
                prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
                prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                this.objColl.pop();
            }
            this.notify('toolbar', { prop: 'refreshSlider' });
            ctx.clearRect(0, 0, this.activeObj.imageCanvas.width, this.activeObj.imageCanvas.height);
            var activePoint = this.duplicateImage();
            this.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
                value: { ctx: this.activeObj.imageCanvas.getContext('2d'), isImgAnnotation: true, isHFlip: true, isVFlip: null } });
            this.activeObj.activePoint = activePoint;
            this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
            if (ej2_base_2.isNullOrUndefined(isPreventURC)) {
                this.objColl.push(this.activeObj);
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'imageHFlip', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                        previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
                this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            }
        };
        ImageEditor.prototype.verticalFlip = function (ctx, isPreventURC) {
            var prevCropObj;
            var prevObj;
            if (ej2_base_2.isNullOrUndefined(isPreventURC)) {
                Iif (ej2_base_2.isNullOrUndefined(this.activeObj.imageRatio)) {
                    this.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
                }
                this.notify('shape', { prop: 'pushActItemIntoObj' });
                prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                var object = { currObj: {} };
                this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                prevObj = object['currObj'];
                prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
                prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
                prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                this.objColl.pop();
            }
            this.notify('toolbar', { prop: 'refreshSlider' });
            ctx.clearRect(0, 0, this.activeObj.imageCanvas.width, this.activeObj.imageCanvas.height);
            var activePoint = this.duplicateImage();
            this.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
                value: { ctx: this.activeObj.imageCanvas.getContext('2d'), isImgAnnotation: true, isHFlip: null, isVFlip: true } });
            this.activeObj.activePoint = activePoint;
            this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
            if (ej2_base_2.isNullOrUndefined(isPreventURC)) {
                this.objColl.push(this.activeObj);
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'imageVFlip', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                        previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
                this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            }
        };
        ImageEditor.prototype.rotateImage = function (rotate) {
            var prevCropObj;
            var prevObj;
            Iif (ej2_base_2.isNullOrUndefined(this.activeObj.imageRatio)) {
                this.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
            }
            this.notify('shape', { prop: 'pushActItemIntoObj' });
            prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            prevObj = object['currObj'];
            prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
            prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            this.objColl.pop();
            this.notify('toolbar', { prop: 'refreshSlider' });
            Eif (rotate === 'rotleft') {
                this.activeObj.rotatedAngle -= (90 * (Math.PI / 180));
            }
            else {
                this.activeObj.rotatedAngle += (90 * (Math.PI / 180));
            }
            this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.activeObj } });
            this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
            this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
            this.objColl.push(this.activeObj);
            this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                value: { operation: 'imageRotate', previousObj: prevObj, previousObjColl: prevObj.objColl,
                    previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                    previousCropObj: prevCropObj, previousText: null,
                    currentText: null, previousFilter: null, isCircleCrop: null } });
            this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
            this.notify('toolbar', { prop: 'destroy-qa-toolbar' });
            this.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
        };
        ImageEditor.prototype.pascalToSplitWords = function (str) {
            str = str.charAt(0).toUpperCase() + str.slice(1);
            var splitStr = str.match(/[A-Z][a-z]+/g);
            Iif (ej2_base_2.isNullOrUndefined(splitStr)) {
                return str;
            }
            else {
                return splitStr.map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1); }).join(' ');
            }
        };
        ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
            var value = 100;
            var indexObj = { freehandSelectedIndex: null };
            this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
            Iif (type === 'transparency' && this.togglePen) {
                var obj = { penOpacity: 1 };
                this.notify('freehand-draw', { prop: 'getPenOpacity', onPropertyChange: false, value: { obj: obj } });
                value = obj['penOpacity'] * 100;
            }
            else Iif (type === 'transparency' && indexObj['freehandSelectedIndex'] !== null && indexObj['freehandSelectedIndex'] !== undefined) {
                value = this.pointColl[indexObj['freehandSelectedIndex']].opacity * 100;
            }
            else {
                var obj = { adjustmentLevel: null };
                this.notify('filter', { prop: 'getAdjustmentLevel', onPropertyChange: false,
                    value: { obj: obj } });
                var typeToAdjustmentLevel = { 'brightness': obj['adjustmentLevel'].brightness,
                    'contrast': obj['adjustmentLevel'].contrast, 'hue': obj['adjustmentLevel'].hue,
                    'saturation': obj['adjustmentLevel'].saturation, 'opacity': obj['adjustmentLevel'].opacity,
                    'blur': obj['adjustmentLevel'].blur, 'exposure': obj['adjustmentLevel'].exposure,
                    'transparency': obj['adjustmentLevel'].transparency, 'straighten': this.transform.straighten };
                value = typeToAdjustmentLevel["" + type];
            }
            return value;
        };
        ImageEditor.prototype.transformSelect = function (type) {
            Iif (this.transform.straighten === 0 && (type === 'rotateleft' || type === 'rotateright') &&
                this.activeObj.shape && (['crop-2:3', 'crop-3:2', 'crop-3:4', 'crop-4:3', 'crop-4:5', 'crop-5:4', 'crop-5:7', 'crop-7:5',
                'crop-9:16', 'crop-16:9'].indexOf(this.activeObj.shape) !== -1 || (this.activeObj.shape.indexOf('crop-') !== -1 &&
                this.activeObj.shape !== 'crop-custom' && this.activeObj.shape !== 'crop-square' && this.activeObj.shape !== 'crop-circle'))) {
                this.activeObj.shape = 'crop-' + this.activeObj.shape.split('-')[1].split(':')[1] + ':' + this.activeObj.shape.split('-')[1].split(':')[0];
                this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: this.activeObj.shape, isTransform: true } });
            }
            this.isCropToolbar = true;
            this.allowDownScale = false;
            var straighten = this.transform.straighten;
            var straightenObj = ej2_base_1.extend({}, this.activeObj, {}, true);
            var zoomFactor = this.transform.zoomFactor;
            this.prevEventSelectionPoint = ej2_base_1.extend({}, this.activeObj, {}, true);
            var object = { currObj: {} };
            this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
            this.prevEventObjPoint = object['currObj'];
            this.prevEventObjPoint.objColl = ej2_base_1.extend([], this.objColl, [], true);
            this.prevEventObjPoint.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
            this.prevEventObjPoint.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
            var selPointCollObj = { selPointColl: null };
            this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                value: { obj: selPointCollObj } });
            this.prevEventObjPoint.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
            if (this.transform.straighten !== 0) {
                this.transform.straighten = 0;
                this.straightenBaseImageCanvas();
                for (var i = 0, len = this.objColl.length; i < len; i++) {
                    var shape = this.objColl[i].shape;
                    if (shape !== 'line' && shape !== 'arrow' && shape !== 'path') {
                        this.objColl[i].rotatedAngle -= (straighten * (Math.PI / 180));
                        this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.objColl[i] } });
                    }
                }
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
            }
            this.setInitialZoomState();
            var activeObj = ej2_base_1.extend({}, this.activeObj, {}, true);
            this.notify('crop', { prop: 'setTransformCrop', onPropertyChange: false, value: { bool: true } });
            this.cropSelectedState();
            this.notify('crop', { prop: 'setTransformCrop', onPropertyChange: false, value: { bool: false } });
            this.notify('draw', { prop: 'resetCurrentSelectionPoint' });
            this.updateImageTransformColl(type);
            this.notify('transform', { prop: 'performTransformation', value: { text: type } });
            this.isCropTab = true;
            this.notify('draw', { prop: 'moveToSelectionRange', value: { type: type, activeObj: activeObj } });
            if (this.isStraightening && (type === 'horizontalflip' || type === 'verticalflip')) {
                this.notify('draw', { prop: 'resetStraightenDestPoints' });
                this.notify('draw', { prop: 'setDestForStraighten' });
            }
            if (straighten !== 0) {
                this.transform.straighten = straighten;
                this.straightenBaseImageCanvas();
                for (var i = 0, len = this.objColl.length; i < len; i++) {
                    var shape = this.objColl[i].shape;
                    if (shape !== 'line' && shape !== 'arrow' && shape !== 'path') {
                        this.objColl[i].rotatedAngle += (straighten * (Math.PI / 180));
                        this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.objColl[i] } });
                    }
                }
                this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
                    value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
                this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: straightenObj } });
                this.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
                this.notify('draw', { prop: 'setStraightenInitZoom', value: { zoomFactor: zoomFactor } });
                Iif ((this.isStraightening && (type === 'horizontalflip' || type === 'verticalflip')) &&
                    ej2_base_2.isNullOrUndefined(this.transform.zoomFactor) || this.transform.zoomFactor === 0) {
                    if (this.transform.degree === 0) {
                        this.transform.zoomFactor += 0.025;
                    }
                    else if (this.transform.zoomFactor === 0) {
                        this.transform.zoomFactor = null;
                    }
                }
                this.notify('draw', { prop: 'zoomToSel', value: { activeObj: straightenObj, isToolbar: false } });
            }
            this.isCropToolbar = false;
            var stValPan = this.element.querySelector('.e-ie-straighten-value-span');
            if (stValPan) {
                stValPan.innerHTML = this.transform.straighten.toString() + '&#176';
            }
        };
        ImageEditor.prototype.getDefaultFilter = function () {
            return 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
                'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' +
                'grayscale(0%) ' + 'invert(0%)';
        };
        ImageEditor.prototype.setStraighten = function (value) {
            var straightenEventArgs = { cancel: false, previousDegree: this.transform.straighten, currentDegree: value };
            this.trigger('rotating', straightenEventArgs);
            this.editCompleteArgs = straightenEventArgs;
            Eif (!straightenEventArgs.cancel) {
                this.performStraighten(straightenEventArgs);
                var actionArgs = { action: 'straighten', actionEventArgs: this.editCompleteArgs };
                this.triggerEditCompleteEvent(actionArgs);
            }
        };
        ImageEditor.prototype.duplicateImage = function () {
            var activePoint = ej2_base_1.extend({}, this.activeObj.activePoint, {}, true);
            var dimObj = { width: 0, height: 0 };
            this.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
                value: { width: this.activeObj.imageElement.width, height: this.activeObj.imageElement.height, obj: dimObj, isImgShape: null } });
            this.activeObj.activePoint.width = dimObj['width'];
            this.activeObj.activePoint.height = dimObj['height'];
            return activePoint;
        };
        ImageEditor.prototype.performStraighten = function (straightenEventArgs) {
            var value = straightenEventArgs.currentDegree;
            var stValPan = this.element.querySelector('.e-ie-straighten-value-span');
            if (stValPan) {
                stValPan.innerHTML = value.toString() + '&#176';
            }
            var obj = ej2_base_1.extend({}, this.activeObj, null, true);
            this.notify('freehand-draw', { prop: 'setCenterSelPoints' });
            this.transform.straighten = value;
            this.straightenPoint = { x: this.activeObj.activePoint.startX + (this.activeObj.activePoint.width / 2),
                y: this.activeObj.activePoint.startY + (this.activeObj.activePoint.height / 2) };
            this.straightenBaseImageCanvas();
            for (var i = 0, len = this.objColl.length; i < len; i++) {
                var shape = this.objColl[i].shape;
                if (shape !== 'line' && shape !== 'arrow' && shape !== 'path') {
                    this.objColl[i].rotatedAngle += ((this.transform.straighten - this.prevStraightenedDegree) * (Math.PI / 180));
                    this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.objColl[i] } });
                }
            }
            if (this.transform.degree % 90 === 0 && this.transform.degree % 180 !== 0) {
                Iif (this.transform.straighten === 0) {
                    this.transform.straighten = 360;
                }
                this.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
                    value: { x: this.activeObj.activePoint.startX + (this.activeObj.activePoint.width / 2),
                        y: this.activeObj.activePoint.startY + (this.activeObj.activePoint.height / 2), type: 'zoomIn', isResize: true } });
                this.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
                    value: { x: this.activeObj.activePoint.startX + (this.activeObj.activePoint.width / 2),
                        y: this.activeObj.activePoint.startY + (this.activeObj.activePoint.height / 2), type: 'zoomOut', isResize: true } });
                Iif (this.transform.straighten === 360) {
                    this.transform.straighten = 0;
                }
            }
            else {
                this.notify('draw', { prop: 'render-image', value: { isMouseWheel: true, isPreventClearRect: null, isFrame: null, isStraighten: true } });
            }
            this.notify('draw', { prop: 'drawObject', onPropertyChange: false,
                value: { canvas: 'duplicate', obj: obj } });
            this.notify('draw', { prop: 'zoomToSel', value: { activeObj: obj, isToolbar: true } });
            this.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
            this.prevStraightenedDegree = this.transform.straighten;
        };
        ImageEditor.prototype.straightenBaseImageCanvas = function () {
            if (this.isImageLoaded) {
                var flipState = this.getStraightenFlipState();
                var straighten = flipState === 'horizontal' || flipState === 'vertical' ?
                    -this.transform.straighten : this.transform.straighten;
                var ctx = this.baseImgCanvas.getContext('2d');
                Eif (ctx.canvas.width !== this.lowerContext.canvas.width &&
                    ctx.canvas.height !== this.lowerContext.canvas.height) {
                    var obj_7 = { width: 0, height: 0 };
                    this.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
                        value: { obj: obj_7, dimension: { width: ctx.canvas.width, height: ctx.canvas.height } } });
                }
                var width = this.baseImg.width;
                var height = this.baseImg.height;
                Iif (!this.aspectRatioBaseDimension && this.imageSettings.width && this.imageSettings.height) {
                    var widthRatio = this.baseImg.width / this.imageSettings.width;
                    var heightRatio = this.baseImg.height / this.imageSettings.height;
                    var ratio = (widthRatio + heightRatio) / 2;
                    ratio = ratio < 1 ? 1 : ratio;
                    width = this.imageSettings.width * ratio;
                    height = this.imageSettings.height * ratio;
                }
                var dimension = this.getRotatedCanvasDim(width, height, this.transform.straighten);
                this.img.srcWidth = ctx.canvas.width = dimension.width;
                this.img.srcHeight = ctx.canvas.height = dimension.height;
                var x = ctx.canvas.width / 2;
                var y = ctx.canvas.height / 2;
                ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
                ctx.translate(x, y);
                ctx.rotate(straighten * Math.PI / 180);
                ctx.drawImage(this.baseImg, -width / 2, -height / 2, width, height);
                ctx.setTransform(1, 0, 0, 1, 0, 0);
                var obj = { width: 0, height: 0 };
                this.notify('crop', { prop: 'calcRatio', onPropertyChange: false, value: { obj: obj, dimension: { width: ctx.canvas.width, height: ctx.canvas.height } } });
            }
        };
        ImageEditor.prototype.getRotatedCanvasDim = function (width, height, angle) {
            var angleRad = angle * Math.PI / 180;
            var cosAngle = Math.cos(angleRad);
            var sinAngle = Math.sin(angleRad);
            var minX = Math.min(0, width * cosAngle, height * Math.cos(Math.PI / 2 - angleRad), width * cosAngle + height * Math.cos(Math.PI / 2 - angleRad));
            var maxX = Math.max(0, width * cosAngle, height * Math.cos(Math.PI / 2 - angleRad), width * cosAngle + height * Math.cos(Math.PI / 2 - angleRad));
            var minY = Math.min(0, width * sinAngle, height * Math.sin(Math.PI / 2 - angleRad), width * sinAngle + height * Math.sin(Math.PI / 2 - angleRad));
            var maxY = Math.max(0, width * sinAngle, height * Math.sin(Math.PI / 2 - angleRad), width * sinAngle + height * Math.sin(Math.PI / 2 - angleRad));
            return { width: Math.ceil(maxX - minX), height: Math.ceil(maxY - minY) };
        };
        ImageEditor.prototype.updateShapeOrder = function (id, value) {
            var shapeObj = this.getObjFromId(id);
            Eif ((shapeObj.shape && (shapeObj.shape !== 'path' ||
                (shapeObj.shape === 'path' && shapeObj.pointColl.length > 0))) ||
                (shapeObj && shapeObj['id'] && shapeObj['id'].indexOf('pen') > -1)) {
                var obj = { shapeSettingsObj: {} };
                this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
                var shapeSettings = obj['shapeSettingsObj'];
                Eif (shapeObj.shape) {
                    this.notify('shape', { prop: 'pushActItemIntoObj' });
                }
                var prevCropObj = ej2_base_1.extend({}, this.cropObj, {}, true);
                var object = { currObj: {} };
                this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
                var prevObj = object['currObj'];
                prevObj.objColl = ej2_base_1.extend([], this.objColl, [], true);
                prevObj.pointColl = ej2_base_1.extend([], this.pointColl, [], true);
                prevObj.afterCropActions = ej2_base_1.extend([], this.afterCropActions, [], true);
                var selPointCollObj = { selPointColl: null };
                this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
                    value: { obj: selPointCollObj } });
                prevObj.selPointColl = ej2_base_1.extend([], selPointCollObj['selPointColl'], [], true);
                Eif (shapeObj.shape) {
                    this.objColl.pop();
                }
                this.notify('shape', { prop: 'z-order', onPropertyChange: false, value: { obj: shapeObj, value: value } });
                Eif (shapeObj.shape) {
                    this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                            strokeWidth: shapeObj.strokeSettings.strokeWidth } });
                    this.objColl.push(shapeObj);
                }
                this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
                    value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
                        previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
                        previousCropObj: prevCropObj, previousText: null,
                        currentText: null, previousFilter: null, isCircleCrop: null } });
                Eif (shapeObj.shape) {
                    this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
                    this.activeObj.order = shapeObj.order;
                }
                var shapeChangedArgs = { action: 'stroke-width', previousShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true),
                    currentShapeSettings: ej2_base_1.extend({}, shapeSettings, {}, true) };
                shapeChangedArgs.currentShapeSettings.strokeWidth = this.activeObj.strokeSettings.strokeWidth;
            }
            else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
                this.activeObj.pointColl.length === 0)) {
                this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
                        strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
            }
        };
        ImageEditor.prototype.getStraightenFlipState = function () {
            var flipState = '';
            if (this.rotateFlipColl.length > 0) {
                for (var i = 0, len = this.rotateFlipColl.length; i < len; i++) {
                    var curFlip = this.rotateFlipColl[i];
                    if (curFlip === 'horizontal') {
                        flipState += 'horizontal';
                    }
                    else if (curFlip === 'vertical') {
                        flipState += 'vertical';
                    }
                    if (flipState === 'horizontalvertical' || flipState === 'verticalhorizontal') {
                        flipState = '';
                    }
                }
            }
            return flipState;
        };
        ImageEditor.prototype.initializeZoomSettings = function () {
            this.theme = ej2_base_2.isNullOrUndefined(this.theme) ? 'Bootstrap5' : this.theme;
            Eif (ej2_base_2.isNullOrUndefined(this.zoomSettings.zoomTrigger) || this.zoomSettings.zoomTrigger === 0) {
                this.zoomSettings.zoomTrigger = (index_2.ZoomTrigger.MouseWheel | index_2.ZoomTrigger.Pinch | index_2.ZoomTrigger.Toolbar | index_2.ZoomTrigger.Commands);
            }
            Eif (ej2_base_2.isNullOrUndefined(this.selectionSettings.strokeColor)) {
                this.selectionSettings.strokeColor = this.themeColl[this.theme]['primaryColor'];
            }
            Eif (ej2_base_2.isNullOrUndefined(this.selectionSettings.fillColor)) {
                this.selectionSettings.fillColor = this.themeColl[this.theme]['secondaryColor'];
            }
        };
        ImageEditor.prototype.initializeThemeColl = function () {
            this.themeColl = {
                Bootstrap5: { primaryColor: '#0d6efd', secondaryColor: '#fff' },
                Bootstrap5Dark: { primaryColor: '#0d6efd', secondaryColor: '#fff' },
                Tailwind: { primaryColor: '#4f46e5', secondaryColor: '#fff' },
                TailwindDark: { primaryColor: '#22d3ee', secondaryColor: '#fff' },
                Fluent: { primaryColor: '#0078d4', secondaryColor: '#fff' },
                FluentDark: { primaryColor: '#0078d4', secondaryColor: '#fff' },
                Bootstrap4: { primaryColor: '#007bff', secondaryColor: '#fff' },
                Bootstrap: { primaryColor: '#317ab9', secondaryColor: '#fff' },
                BootstrapDark: { primaryColor: '#317ab9', secondaryColor: '#fff' },
                Material: { primaryColor: '#e3165b', secondaryColor: '#fff' },
                MaterialDark: { primaryColor: '#00b0ff', secondaryColor: '#fff' },
                Fabric: { primaryColor: '#0078d6', secondaryColor: '#fff' },
                FabricDark: { primaryColor: '#0074cc', secondaryColor: '#fff' },
                Highcontrast: { primaryColor: '#000000', secondaryColor: '#fff' },
                Material3: { primaryColor: '#6750a4', secondaryColor: '#fff' },
                Material3Dark: { primaryColor: '#d0bcff', secondaryColor: '#fff' },
                Fluent2: { primaryColor: '#0f6cbd', secondaryColor: '#fff' },
                Fluent2Dark: { primaryColor: '#115ea3', secondaryColor: '#fff' },
                Fluent2Highcontrast: { primaryColor: '#1aebff', secondaryColor: '#fff' },
                'Bootstrap5.3': { primaryColor: '#0d6efd', secondaryColor: '#fff' },
                'Bootstrap5.3Dark': { primaryColor: '#0d6efd', secondaryColor: '#fff' },
                Tailwind3: { primaryColor: '#4f46e5', secondaryColor: '#ffffff' },
                Tailwind3Dark: { primaryColor: '#6366f1', secondaryColor: '#ffffff03' }
            };
        };
        ImageEditor.prototype.drawRedact = function (type, x, y, width, height, value) {
            var isRedact = false;
            var isPointsInRange = this.allowShape(x, y);
            Eif (!this.disabled && this.isImageLoaded && (isPointsInRange || (ej2_base_2.isNullOrUndefined(x) && ej2_base_2.isNullOrUndefined(y)))) {
                isRedact = true;
                this.manageActiveAction();
                this.notify('shape', {
                    prop: 'drawRedact', onPropertyChange: false, value: {
                        x: x, y: y, width: width, height: height, type: type, value: value
                    }
                });
                this.notify('draw', { prop: 'redrawDownScale' });
            }
            return isRedact;
        };
        ImageEditor.prototype.handlePenActiveState = function () {
            var freehandDrawObj = { freehandDrawSelectedId: null };
            this.notify('freehand-draw', { prop: 'getFreehandDrawSelectedId', onPropertyChange: false, value: { obj: freehandDrawObj } });
            Eif (ej2_base_2.isNullOrUndefined(freehandDrawObj['freehandDrawSelectedId'])) {
                this.manageActiveAction();
            }
        };
        var ImageEditor_1;
        __decorate([
            ej2_base_1.Property('')
        ], ImageEditor.prototype, "cssClass", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ImageEditor.prototype, "disabled", void 0);
        __decorate([
            ej2_base_1.Property('100%')
        ], ImageEditor.prototype, "height", void 0);
        __decorate([
            ej2_base_1.Property('Bootstrap5')
        ], ImageEditor.prototype, "theme", void 0);
        __decorate([
            ej2_base_1.Property()
        ], ImageEditor.prototype, "toolbar", void 0);
        __decorate([
            ej2_base_1.Property()
        ], ImageEditor.prototype, "toolbarTemplate", void 0);
        __decorate([
            ej2_base_1.Property('100%')
        ], ImageEditor.prototype, "width", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], ImageEditor.prototype, "allowUndoRedo", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], ImageEditor.prototype, "showQuickAccessToolbar", void 0);
        __decorate([
            ej2_base_1.Property()
        ], ImageEditor.prototype, "quickAccessToolbarTemplate", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ImageEditor.prototype, "imageSmoothingEnabled", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ImageEditor.prototype, "isReadOnly", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ImageEditor.prototype, "enableRtl", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ImageEditor.prototype, "enablePersistence", void 0);
        __decorate([
            ej2_base_3.Complex({}, FinetuneSettings)
        ], ImageEditor.prototype, "finetuneSettings", void 0);
        __decorate([
            ej2_base_3.Complex({}, ZoomSettings)
        ], ImageEditor.prototype, "zoomSettings", void 0);
        __decorate([
            ej2_base_3.Complex({}, SelectionSettings)
        ], ImageEditor.prototype, "selectionSettings", void 0);
        __decorate([
            ej2_base_3.Complex({}, FontFamily)
        ], ImageEditor.prototype, "fontFamily", void 0);
        __decorate([
            ej2_base_3.Complex({}, UploadSettings)
        ], ImageEditor.prototype, "uploadSettings", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "beforeSave", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "created", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "destroyed", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "zooming", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "panning", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "cropping", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "rotating", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "flipping", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "shapeChanging", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "selectionChanging", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "fileOpened", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "saved", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "toolbarCreated", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "toolbarUpdating", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "toolbarItemClicked", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "imageFiltering", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "finetuneValueChanging", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "click", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "shapeChange", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "quickAccessToolbarOpen", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "resizing", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "quickAccessToolbarItemClick", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "frameChange", void 0);
        __decorate([
            ej2_base_2.Event()
        ], ImageEditor.prototype, "editComplete", void 0);
        ImageEditor = ImageEditor_1 = __decorate([
            ej2_base_1.NotifyPropertyChanges
        ], ImageEditor);
        return ImageEditor;
    }(ej2_base_1.Component));
    exports.ImageEditor = ImageEditor;
});