all files / pdfviewer/drawing/ drawing.js

3.54% Statements 91/2572
0.04% Branches 1/2785
4.6% Functions 4/87
3.54% Lines 91/2569
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 37631×   1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1×   1× 1× 1× 1×           1×             1×                                         1×                                                       1×                                           1×                                                                                           1×                                                                                                                                   1×                                     1×                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1×                 1×                                   1×                           1×                                                                                                                                                                                                         1×                               1×                                                                                                                                                         1×       1×                                                                                                                                                                                           1×                         1×                 1×               1×                           1×                               1×                                                                                                                                                                                                                                                       1×                                 1×                                     1×               1×                   1×                                                                                                                                                                                                                 1×                                                                                         1×                                                                                                                                                                                   1×                                                                                                     1×                                                                                                                     1×                                                                                                                     1×                                                                                                                                               1×                                                                     1×                                                                                                                           1×                   1×                                                                                                                                                                                                                   1×                                                         1×                                                                               1×       1×                                                                                                       1×         1×                                         1×                                         1×                     1×       1×                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     1×                                     1×                                                     1×                                   1×       1×                                         1×                                                                                       1×                                                   1×                                                                                 1×                                                                                                                                       1×             1×                                                                         1×                                                                                             1×                                                                                                                                                                                     1×             1×                                       1×                                             1×                                                                               1×                   1×         1×                                                                                                                                                                                                                                                                                                                                                                                   1×                                                               1×                                                                                                                           1×                     1×                                                 1×             1×   1×    
define(["require", "exports", "../index", "./pdf-annotation", "@syncfusion/ej2-drawings", "@syncfusion/ej2-drawings", "@syncfusion/ej2-drawings", "@syncfusion/ej2-drawings", "@syncfusion/ej2-drawings", "@syncfusion/ej2-drawings", "@syncfusion/ej2-drawings", "./selector", "@syncfusion/ej2-drawings", "./drawing-util", "./connector-util", "@syncfusion/ej2-base", "./html-element"], function (require, exports, index_1, pdf_annotation_1, ej2_drawings_1, ej2_drawings_2, ej2_drawings_3, ej2_drawings_4, ej2_drawings_5, ej2_drawings_6, ej2_drawings_7, selector_1, ej2_drawings_8, drawing_util_1, connector_util_1, ej2_base_1, html_element_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Drawing = (function () {
        function Drawing(viewer) {
            this.isDynamicStamps = false;
            this.isDragAnnotation = false;
            this.copiedElementID = '';
            this.isPasted = false;
            this.isLineInHorizontalBounds = true;
            this.isLineInVerticalBounds = true;
            this.pdfViewer = viewer;
            this.renderer = new ej2_drawings_7.DrawingRenderer('this.pdfViewer.element.id', false);
            this.svgRenderer = new ej2_drawings_8.SvgRenderer();
        }
        Drawing.prototype.renderLabels = function (viewer) {
            var annotations = viewer.annotations;
            Eif (annotations) {
                for (var i = 0; i < annotations.length; i++) {
                    var annotation = annotations[parseInt(i.toString(), 10)];
                    this.initObject(annotation);
                }
            }
        };
        Drawing.prototype.createNewZindexTable = function (pageId) {
            var zIndexTable = new pdf_annotation_1.ZOrderPageTable();
            this.pdfViewer.zIndex++;
            zIndexTable.pageId = this.pdfViewer.zIndex;
            this.pdfViewer.zIndexTable.push(zIndexTable);
            return zIndexTable;
        };
        Drawing.prototype.getPageTable = function (pageId) {
            var zIndexTable;
            if (this.pdfViewer.zIndexTable.length !== undefined) {
                var notFound = true;
                for (var i = 0; i < this.pdfViewer.zIndexTable.length; i++) {
                    if (this.pdfViewer.zIndexTable[parseInt(i.toString(), 10)].pageId === pageId) {
                        notFound = false;
                        zIndexTable = this.pdfViewer.zIndexTable[parseInt(i.toString(), 10)];
                        break;
                    }
                }
                if (notFound) {
                    zIndexTable = this.createNewZindexTable(pageId);
                    zIndexTable.pageId = pageId;
                }
            }
            else {
                zIndexTable = this.createNewZindexTable(pageId);
            }
            return zIndexTable;
        };
        Drawing.prototype.setZIndex = function (index, obj) {
            if (obj.pageIndex !== undefined) {
                var pageTable = this.getPageTable(obj.pageIndex);
                var ispageobject = false;
                if (obj.shapeAnnotationType !== 'Polygon') {
                    for (var i = 0; i < pageTable.objects.length; i++) {
                        if (obj.id === pageTable.objects[parseInt(i.toString(), 10)].id) {
                            pageTable.objects.splice(parseInt(i.toString(), 10), 1);
                            pageTable.objects.splice(parseInt(i.toString(), 10), 0, obj);
                            ispageobject = true;
                            break;
                        }
                    }
                }
                if (!ispageobject) {
                    if (obj.zIndex === -1) {
                        pageTable.zIndex++;
                        obj.zIndex = pageTable.zIndex;
                        pageTable.objects.push(obj);
                    }
                    else {
                        var tabelLength = pageTable.objects.length;
                        obj.zIndex = tabelLength++;
                        pageTable.objects.push(obj);
                    }
                }
            }
        };
        Drawing.prototype.initObject = function (obj) {
            this.setZIndex(this.pdfViewer.zIndex, obj);
            ej2_drawings_4.createMeasureElements();
            if (!drawing_util_1.isLineShapes(obj)) {
                this.initNode(obj);
            }
            else {
                this.initLine(obj);
                if (obj.wrapper.children[1] instanceof ej2_drawings_6.TextElement) {
                    obj.wrapper.children[1].isEJ2 = true;
                    if (obj.shapeAnnotationType === 'FreeText') {
                        obj.wrapper.children[1].isFreeText = true;
                    }
                }
                obj.wrapper.measure(new ej2_drawings_6.Size(undefined, undefined));
                obj.wrapper.arrange(obj.wrapper.desiredSize);
            }
            if (obj.wrapper === null) {
            }
            this.pdfViewer.nameTable[obj.id] = obj;
            return obj;
        };
        Drawing.prototype.initNode = function (obj) {
            if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationModule) && this.pdfViewer.annotationModule.isUndoRedoAction && obj.shapeAnnotationType === 'Stamp') {
                var id = obj.id;
                var stampObject = this.pdfViewer.nameTable["" + id].wrapper.children;
                this.stampPreviousSize = JSON.parse(JSON.stringify(stampObject));
                this.stampPreviousWidth = !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize) && !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize.width) ?
                    obj.wrapper.actualSize.width : null;
                this.stampPerviousHeight = !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize) && !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize.height) ?
                    obj.wrapper.actualSize.height : null;
            }
            if (this.isPasted && obj.shapeAnnotationType === 'Stamp') {
                this.stampOriginalWidth = !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize) && !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize.width) ?
                    obj.wrapper.actualSize.width : null;
                this.stampOriginalHeight = !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize) && !ej2_base_1.isNullOrUndefined(obj.wrapper.actualSize.height) ?
                    obj.wrapper.actualSize.height : null;
            }
            var canvas = this.initContainer(obj);
            var content;
            if (!canvas.children) {
                canvas.children = [];
            }
            if (!content) {
                content = this.init(obj, canvas);
            }
            canvas.rotateAngle = obj.rotateAngle;
            if (obj.wrapper.children[1] instanceof ej2_drawings_6.TextElement) {
                obj.wrapper.children[1].isEJ2 = true;
                if (obj.shapeAnnotationType === 'FreeText') {
                    obj.wrapper.children[1].isFreeText = true;
                }
            }
            canvas.measure(new ej2_drawings_6.Size(obj.wrapper.width, obj.wrapper.height));
            canvas.arrange(canvas.desiredSize);
            if (this.isDynamicStamps) {
                this.pdfViewer.annotation.stampAnnotationModule.updateSessionStorage(obj, null, 'dynamicStamp');
                this.isDynamicStamps = false;
            }
            if (obj.wrapper instanceof ej2_drawings_2.DrawingElement) {
                if (obj.shapeAnnotationType === 'Stamp') {
                    obj.bounds.width = obj.wrapper.bounds.width;
                    obj.bounds.height = obj.wrapper.bounds.height;
                    obj.bounds.x = obj.wrapper.bounds.x;
                    obj.bounds.y = obj.wrapper.bounds.y;
                }
            }
        };
        Drawing.prototype.init = function (obj, canvas) {
            var content;
            content = new ej2_drawings_2.DrawingElement();
            var pathContent;
            var basicElement;
            var isStamp = false;
            var annotationSettings = this.pdfViewer.annotationModule ? this.pdfViewer.annotationModule.findAnnotationSettings(obj) : {};
            var annotationMaxHeight = 0;
            var annotationMaxWidth = 0;
            var annotationMinHeight = 0;
            var annotationMinWidth = 0;
            if (annotationSettings.minWidth || annotationSettings.maxWidth || annotationSettings.minHeight || annotationSettings.maxHeight) {
                annotationMaxHeight = annotationSettings.maxHeight ? annotationSettings.maxHeight : 2000;
                annotationMaxWidth = annotationSettings.maxWidth ? annotationSettings.maxWidth : 2000;
                annotationMinHeight = annotationSettings.minHeight ? annotationSettings.minHeight : 0;
                annotationMinWidth = annotationSettings.minWidth ? annotationSettings.minWidth : 0;
            }
            var isAnnotationSet = false;
            if (annotationMinHeight || annotationMinWidth || annotationMaxHeight || annotationMaxWidth) {
                isAnnotationSet = true;
            }
            if (obj.formFieldAnnotationType) {
                content = this.initFormFields(obj, content, canvas);
            }
            else {
                content = this.initAnnotationObject(obj, pathContent, content, canvas, isStamp, basicElement, isAnnotationSet, annotationMaxHeight, annotationMaxWidth, annotationMinWidth, annotationMinHeight);
            }
            content.id = obj.id + '_content';
            content.relativeMode = 'Object';
            if (obj.shapeAnnotationType !== 'Stamp') {
                if (obj.bounds.width !== undefined) {
                    content.width = obj.bounds.width;
                    if (isAnnotationSet) {
                        if ((content.width < annotationMinWidth) || (content.width > annotationMaxWidth)) {
                            if (content.width < annotationMinWidth) {
                                content.width = annotationMinWidth;
                            }
                            if (content.width > annotationMaxWidth) {
                                content.width = annotationMaxWidth;
                            }
                        }
                    }
                }
                content.horizontalAlignment = 'Stretch';
                if (obj.bounds.height !== undefined) {
                    content.height = obj.bounds.height;
                    if (isAnnotationSet) {
                        if ((content.height < annotationMinHeight) || (content.width > annotationMaxHeight)) {
                            if (content.height < annotationMinHeight) {
                                content.height = annotationMinHeight;
                            }
                            if (content.height > annotationMaxHeight) {
                                content.height = annotationMaxHeight;
                            }
                        }
                    }
                }
                drawing_util_1.setElementStype(obj, content);
                if (this.pdfViewer.viewerBase.drawSignatureWithTool && obj.shapeAnnotationType === 'SignatureText') {
                    content.style.strokeWidth = 0;
                }
            }
            content.isRectElement = true;
            content.verticalAlignment = 'Stretch';
            return content;
        };
        Drawing.prototype.initFormFields = function (obj, content, canvas) {
            switch (obj.formFieldAnnotationType) {
                case 'Textbox':
                case 'PasswordField':
                case 'Checkbox':
                case 'RadioButton':
                case 'DropdownList':
                case 'ListBox':
                case 'SignatureField':
                case 'InitialField': {
                    var htmlContent = new html_element_1.DiagramHtmlElement();
                    content = htmlContent;
                    content.id = obj.id + '_content';
                    canvas.children.push(content);
                    break;
                }
            }
            return content;
        };
        Drawing.prototype.initAnnotationObject = function (obj, pathContent, content, canvas, isStamp, basicElement, isAnnotationSet, annotationMaxHeight, annotationMaxWidth, annotationMinWidth, annotationMinHeight) {
            switch (obj.shapeAnnotationType) {
                case 'Ellipse':
                    pathContent = new ej2_drawings_3.PathElement();
                    pathContent.data = 'M80.5,12.5 C80.5,19.127417 62.59139,24.5 40.5,24.5 C18.40861,24.5 0.5,19.127417 0.5,12.5' +
                        'C0.5,5.872583 18.40861,0.5 40.5,0.5 C62.59139,0.5 80.5,5.872583 80.5,12.5 z';
                    content = pathContent;
                    canvas.children.push(content);
                    if (obj.enableShapeLabel) {
                        var textLabel = this.textElement(obj);
                        textLabel.content = obj.labelContent;
                        textLabel.style.color = obj.fontColor;
                        textLabel.style.strokeColor = obj.labelBorderColor;
                        textLabel.style.fill = obj.labelFillColor;
                        textLabel.style.fontSize = obj.fontSize;
                        textLabel.style.fontFamily = obj.fontFamily;
                        textLabel.style.opacity = obj.labelOpacity;
                        canvas.children.push(textLabel);
                    }
                    break;
                case 'Path':
                    pathContent = new ej2_drawings_3.PathElement();
                    pathContent.data = obj.data;
                    content = pathContent;
                    canvas.children.push(content);
                    break;
                case 'HandWrittenSignature':
                case 'Ink':
                    pathContent = new ej2_drawings_3.PathElement();
                    pathContent.data = obj.data;
                    pathContent.style.strokeColor = obj.strokeColor;
                    pathContent.style.strokeWidth = obj.thickness;
                    pathContent.style.opacity = obj.opacity;
                    content = pathContent;
                    canvas.children.push(content);
                    break;
                case 'Polygon':
                    pathContent = new ej2_drawings_3.PathElement();
                    pathContent.data = connector_util_1.getPolygonPath(obj.vertexPoints);
                    content = pathContent;
                    canvas.children.push(content);
                    break;
                case 'Stamp': {
                    isStamp = true;
                    this.isDynamicStamps = true;
                    var copiedObject = void 0;
                    if (this.isPasted) {
                        var id = this.pdfViewer.clipboardData.clipObject[0].id;
                        copiedObject = this.pdfViewer.nameTable["" + id];
                    }
                    if (obj && obj.annotationAddMode && obj.id === 'diagram_helper' && obj.icon !== 'Accepted' && obj.icon !== 'Rejected') {
                        obj.bounds.width = obj.bounds.width - 20;
                        obj.bounds.height = obj.bounds.height - 20;
                    }
                    if (obj.isDynamicStamp) {
                        canvas.horizontalAlignment = 'Left';
                        basicElement = new ej2_drawings_2.DrawingElement();
                        content = basicElement;
                        content.cornerRadius = 10;
                        content.style.fill = obj.stampFillColor;
                        content.style.strokeColor = obj.stampStrokeColor;
                        canvas.children.push(content);
                        var textele = new ej2_drawings_6.TextElement();
                        textele.style.fontFamily = 'Helvetica';
                        textele.style.fontSize = 14;
                        textele.style.italic = true;
                        textele.style.bold = true;
                        textele.style.color = obj.fillColor;
                        textele.rotateValue = undefined;
                        textele.content = obj.dynamicText;
                        textele.style.textAlign = 'Left';
                        textele.relativeMode = 'Point';
                        textele.margin.left = 5;
                        textele.margin.bottom = 3;
                        textele.setOffsetWithRespectToBounds(0, 0.75, null);
                        if (obj.annotationAddMode === 'Existing Annotation' || obj.annotationAddMode === 'Imported Annotation') {
                            var targetWidth = obj.bounds.width + 20;
                            var targetHeight = obj.bounds.height + 20;
                            var iconPadding = targetWidth * 0.02;
                            var iconInnerWidth = Math.max(0, targetWidth - 2 * iconPadding);
                            textele.style.fontSize = this.fontSizeCalculation(obj, textele, iconInnerWidth, textele.content);
                            var metrics = this.measureTextMetrics(obj, textele.content, textele.style.fontSize, textele.style.fontFamily);
                            var bottomOffset = (targetHeight * 0.25 - metrics.height) / 8;
                            textele.margin.bottom = Math.max(0, bottomOffset);
                            if (textele.margin.bottom < 1) {
                                textele.margin.bottom = 5;
                            }
                            textele.margin.left = (targetWidth - metrics.width) / 2;
                        }
                        if (this.isPasted) {
                            textele.style.fontSize = copiedObject.wrapper.children[1].style.fontSize;
                            textele.margin.left = copiedObject.wrapper.children[1].margin.left;
                        }
                        if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationModule) && this.pdfViewer.annotationModule.isUndoRedoAction) {
                            textele.style.fontSize = this.stampPreviousSize[1].style.fontSize;
                        }
                        if (obj.id !== 'diagram_helper') {
                            canvas.children.push(textele);
                        }
                        if (isAnnotationSet && (obj.bounds.width > annotationMaxWidth)) {
                            obj.bounds.width = annotationMaxWidth;
                        }
                        if (isAnnotationSet && (obj.bounds.height > annotationMaxHeight)) {
                            obj.bounds.height = annotationMaxHeight / 2;
                        }
                        var textele1 = new ej2_drawings_6.TextElement();
                        textele1.style.fontFamily = 'Helvetica';
                        textele1.style.fontSize = obj.fontSize;
                        textele1.style.italic = true;
                        textele1.style.bold = true;
                        textele1.style.color = obj.fillColor;
                        textele1.rotateValue = undefined;
                        textele1.content = obj.icon.toUpperCase();
                        textele1.style.textAlign = 'Left';
                        textele1.relativeMode = 'Point';
                        textele1.margin.left = 5;
                        textele1.margin.top = 4;
                        textele1.setOffsetWithRespectToBounds(0, 0.1, null);
                        if (obj.annotationAddMode === 'Existing Annotation' || obj.annotationAddMode === 'Imported Annotation') {
                            var targetWidth = obj.bounds.width + 20;
                            var targetHeight = obj.bounds.height + 20;
                            var iconWidth = targetWidth;
                            if (textele1.content === 'REVISED' || textele1.content === 'REVIEWED' ||
                                textele1.content === 'RECEIVED' || textele1.content === 'APPROVED') {
                                iconWidth = iconWidth / 2;
                            }
                            else if (textele1.content === 'CONFIDENTIAL' || textele1.content === 'NOT APPROVED') {
                                iconWidth = iconWidth * (3 / 4);
                            }
                            var iconPadding = iconWidth * 0.02;
                            var iconInnerWidth = Math.max(0, iconWidth - 2 * iconPadding);
                            textele1.style.fontSize = this.fontSizeCalculation(obj, textele1, iconInnerWidth, textele1.content);
                            var metrics = this.measureTextMetrics(obj, textele1.content, textele1.style.fontSize, textele1.style.fontFamily);
                            var topOffset = (targetHeight * 0.75 - metrics.height) / 10;
                            textele1.margin.top = Math.max(0, topOffset);
                            if (textele1.content === 'CONFIDENTIAL' || textele1.content === 'NOT APPROVED') {
                                textele1.margin.left = (targetWidth - (metrics.width * (4 / 3))) / 2;
                            }
                            else {
                                textele1.margin.left = (targetWidth - (metrics.width * 2)) / 2;
                            }
                        }
                        if (this.isPasted) {
                            textele1.style.fontSize = copiedObject.wrapper.children[2].style.fontSize;
                            textele1.margin.left = copiedObject.wrapper.children[2].margin.left;
                            textele1.margin.top = copiedObject.wrapper.children[2].margin.top -
                                (copiedObject.wrapper.children[2].margin.top * 0.5);
                            content.width = this.stampOriginalWidth;
                            content.height = this.stampOriginalHeight;
                        }
                        else if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationModule) && this.pdfViewer.annotationModule.isUndoRedoAction) {
                            textele1.style.fontSize = this.stampPreviousSize[2].style.fontSize;
                            content.width = this.stampPreviousWidth;
                            content.height = this.stampPerviousHeight;
                        }
                        else {
                            content.width = obj.bounds.width + 20;
                            content.height = obj.bounds.height + 20;
                        }
                        content.style.opacity = obj.opacity;
                        textele1.id = ej2_drawings_5.randomId() + '_stamp';
                        if (obj.id !== 'diagram_helper') {
                            canvas.children.push(textele1);
                        }
                    }
                    else {
                        canvas.horizontalAlignment = 'Left';
                        basicElement = new ej2_drawings_2.DrawingElement();
                        content = basicElement;
                        content.cornerRadius = 10;
                        content.style.fill = obj.stampFillColor;
                        content.style.strokeColor = obj.stampStrokeColor;
                        canvas.children.push(content);
                        if (obj.icon === 'Accepted' || obj.icon === 'Rejected') {
                            content.style.fill = 'transparent';
                            content.style.strokeColor = 'transparent';
                            var pathContent1 = new ej2_drawings_3.PathElement();
                            pathContent1.id = ej2_drawings_5.randomId() + '_stamp';
                            pathContent1.data = obj.data;
                            pathContent1.width = obj.bounds.width;
                            if (isAnnotationSet && (obj.bounds.width > annotationMaxWidth)) {
                                pathContent1.width = annotationMaxWidth;
                                obj.bounds.width = annotationMaxWidth;
                            }
                            pathContent1.height = obj.bounds.height;
                            if (isAnnotationSet && (obj.bounds.height > annotationMaxHeight)) {
                                pathContent1.height = annotationMaxHeight;
                                obj.bounds.height = annotationMaxHeight;
                            }
                            var content1 = pathContent1;
                            pathContent1.style.fill = obj.fillColor;
                            pathContent1.style.strokeColor = obj.strokeColor;
                            pathContent1.style.opacity = obj.opacity;
                            content.width = obj.bounds.width;
                            content.height = obj.bounds.height;
                            content.style.opacity = obj.opacity;
                            canvas.children.push(content1);
                        }
                        else {
                            if (isAnnotationSet && (obj.bounds.width > annotationMaxWidth)) {
                                obj.bounds.width = annotationMaxWidth;
                            }
                            if (isAnnotationSet && (obj.bounds.height > annotationMaxHeight)) {
                                obj.bounds.height = annotationMaxHeight / 2;
                            }
                            var textele1 = new ej2_drawings_6.TextElement();
                            textele1.style.fontFamily = 'Helvetica';
                            textele1.style.fontSize = obj.fontSize;
                            textele1.style.italic = true;
                            textele1.style.bold = true;
                            textele1.style.color = obj.fillColor;
                            textele1.rotateValue = undefined;
                            textele1.style.textAlign = 'Left';
                            textele1.content = obj.icon.toUpperCase();
                            textele1.relativeMode = 'Point';
                            textele1.setOffsetWithRespectToBounds(0, 0.1, null);
                            var metrics = this.measureTextMetrics(obj, textele1.content, textele1.style.fontSize, textele1.style.fontFamily);
                            textele1.margin.top = 5;
                            textele1.margin.left = ((obj.bounds.width + 20) - metrics.width) / 2;
                            if (obj.annotationAddMode === 'Existing Annotation' || obj.annotationAddMode === 'Imported Annotation') {
                                var targetWidth = obj.bounds.width + 20;
                                var targetHeight = obj.bounds.height + 20;
                                var paddingX = targetWidth * 0.05;
                                var innerWidth_1 = Math.max(0, targetWidth - 2 * paddingX);
                                textele1.style.fontSize = this.fontSizeCalculation(obj, textele1, innerWidth_1, textele1.content);
                                var metrics_1 = this.measureTextMetrics(obj, textele1.content, textele1.style.fontSize, textele1.style.fontFamily);
                                var leftOffset = (targetWidth - metrics_1.width) / 2;
                                textele1.margin.left = Math.max(0, leftOffset);
                            }
                            if (this.isPasted) {
                                textele1.style.fontSize = copiedObject.wrapper.children[1].style.fontSize;
                                textele1.margin.left = copiedObject.wrapper.children[1].margin.left;
                                textele1.margin.top = copiedObject.wrapper.children[1].margin.top -
                                    (copiedObject.wrapper.children[1].margin.top * 0.5);
                                content.width = this.stampOriginalWidth;
                                content.height = this.stampOriginalHeight;
                            }
                            else if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationModule) && this.pdfViewer.annotationModule.isUndoRedoAction) {
                                textele1.style.fontSize = this.stampPreviousSize[1].style.fontSize;
                                textele1.margin.top = this.stampPreviousSize[1].margin.top -
                                    (this.stampPreviousSize[1].margin.top * 0.5);
                                textele1.margin.left = this.stampPreviousSize[1].margin.left;
                                content.width = this.stampPreviousWidth;
                                content.height = this.stampPerviousHeight;
                            }
                            else {
                                content.width = obj.bounds.width + 20;
                                content.height = obj.bounds.height + 20;
                            }
                            content.style.opacity = obj.opacity;
                            textele1.id = ej2_drawings_5.randomId() + '_stamp';
                            if (obj.id !== 'diagram_helper') {
                                canvas.children.push(textele1);
                            }
                        }
                    }
                    break;
                }
                case 'Image':
                case 'SignatureImage': {
                    var pathContent11 = new ej2_drawings_1.ImageElement();
                    pathContent11.source = obj.data;
                    content = pathContent11;
                    content.style.strokeWidth = 0;
                    canvas.children.push(content);
                    break;
                }
                case 'Rectangle':
                case 'Redaction':
                    basicElement = new ej2_drawings_2.DrawingElement();
                    content = basicElement;
                    canvas.children.push(content);
                    if (obj.enableShapeLabel) {
                        var textLabel = this.textElement(obj);
                        textLabel.content = obj.labelContent;
                        textLabel.style.color = obj.fontColor;
                        textLabel.style.strokeColor = obj.labelBorderColor;
                        textLabel.style.fill = obj.labelFillColor;
                        textLabel.style.fontSize = obj.fontSize;
                        textLabel.style.fontFamily = obj.fontFamily;
                        textLabel.style.opacity = obj.labelOpacity;
                        canvas.children.push(textLabel);
                    }
                    break;
                case 'Perimeter': {
                    pathContent = new ej2_drawings_3.PathElement();
                    pathContent.data = 'M80.5,12.5 C80.5,19.127417 62.59139,24.5 40.5,24.5 C18.40861,24.5 0.5,19.127417 0.5,12.5' +
                        'C0.5,5.872583 18.40861,0.5 40.5,0.5 C62.59139,0.5 80.5,5.872583 80.5,12.5 z';
                    content = pathContent;
                    drawing_util_1.setElementStype(obj, pathContent);
                    canvas.children.push(content);
                    basicElement = new ej2_drawings_2.DrawingElement();
                    basicElement.id = 'perimeter_' + ej2_drawings_5.randomId();
                    basicElement.height = .2;
                    basicElement.width = .2;
                    basicElement.transform = ej2_drawings_6.RotateTransform.Self;
                    basicElement.horizontalAlignment = 'Stretch';
                    this.setNodePosition(basicElement, obj);
                    basicElement.rotateAngle = obj.rotateAngle;
                    drawing_util_1.setElementStype(obj, basicElement);
                    canvas.children.push(basicElement);
                    var textele = this.textElement(obj);
                    textele = new ej2_drawings_6.TextElement();
                    textele.content = textele.content = drawing_util_1.findPointsLength([
                        { x: obj.bounds.x, y: obj.bounds.y },
                        { x: obj.bounds.x + obj.bounds.width, y: obj.bounds.y + obj.bounds.height }
                    ]).toString();
                    textele.rotateValue = { y: -10, angle: obj.rotateAngle };
                    canvas.children.push(textele);
                    break;
                }
                case 'Radius': {
                    pathContent = new ej2_drawings_3.PathElement();
                    pathContent.data = 'M80.5,12.5 C80.5,19.127417 62.59139,24.5 40.5,24.5 C18.40861,24.5 0.5,19.127417 0.5,12.5' +
                        'C0.5,5.872583 18.40861,0.5 40.5,0.5 C62.59139,0.5 80.5,5.872583 80.5,12.5 z';
                    content = pathContent;
                    drawing_util_1.setElementStype(obj, pathContent);
                    canvas.children.push(content);
                    basicElement = new ej2_drawings_2.DrawingElement();
                    basicElement.id = 'radius_' + ej2_drawings_5.randomId();
                    basicElement.height = .2;
                    basicElement.width = obj.bounds.width / 2;
                    basicElement.transform = ej2_drawings_6.RotateTransform.Self;
                    this.setNodePosition(basicElement, obj);
                    basicElement.rotateAngle = obj.rotateAngle;
                    drawing_util_1.setElementStype(obj, basicElement);
                    canvas.children.push(basicElement);
                    var radiusTextEle = this.textElement(obj);
                    if (obj.enableShapeLabel) {
                        radiusTextEle.style.color = obj.fontColor;
                        radiusTextEle.style.strokeColor = obj.labelBorderColor;
                        radiusTextEle.style.fill = obj.labelFillColor;
                        radiusTextEle.style.fontSize = obj.fontSize;
                        radiusTextEle.style.fontFamily = obj.fontFamily;
                        radiusTextEle.style.opacity = obj.labelOpacity;
                    }
                    var length_1 = drawing_util_1.findPointsLength([
                        { x: obj.bounds.x, y: obj.bounds.y },
                        { x: obj.bounds.x + obj.bounds.width, y: obj.bounds.y + obj.bounds.height }
                    ]);
                    if (!this.pdfViewer.enableImportAnnotationMeasurement && obj.notes && obj.notes !== '') {
                        radiusTextEle.content = obj.notes;
                    }
                    else {
                        radiusTextEle.content = this.pdfViewer.annotation.measureAnnotationModule.setConversion((obj.bounds.width / 2) *
                            this.pdfViewer.annotation.measureAnnotationModule.pixelToPointFactor, obj);
                    }
                    radiusTextEle.rotateValue = { y: -10, x: obj.bounds.width / 4, angle: obj.rotateAngle };
                    canvas.children.push(radiusTextEle);
                    break;
                }
                case 'StickyNotes': {
                    var pathContent2 = new ej2_drawings_1.ImageElement();
                    pathContent2.source = obj.data;
                    pathContent2.width = obj.bounds.width;
                    pathContent2.height = obj.bounds.height;
                    pathContent2.style.strokeColor = obj.strokeColor;
                    pathContent2.style.strokeWidth = 0;
                    content = pathContent2;
                    canvas.children.push(content);
                    break;
                }
                case 'SignatureText': {
                    var rectElements = new ej2_drawings_2.DrawingElement();
                    rectElements.style.strokeWidth = 0;
                    content = rectElements;
                    content.style.strokeWidth = 0;
                    canvas.style.strokeWidth = 0;
                    canvas.children.push(content);
                    var signatureText = this.textElement(obj);
                    signatureText.style.fontFamily = obj.fontFamily;
                    signatureText.style.fontSize = obj.fontSize;
                    signatureText.style.textAlign = 'Left';
                    signatureText.rotateValue = undefined;
                    signatureText.content = obj.data;
                    signatureText.style.strokeWidth = 0;
                    canvas.children.push(signatureText);
                    break;
                }
                case 'FreeText': {
                    var rectElement = new ej2_drawings_2.DrawingElement();
                    content = rectElement;
                    canvas.children.push(content);
                    var freeTextEle = this.textElement(obj);
                    freeTextEle = new ej2_drawings_6.TextElement();
                    freeTextEle.style.fontFamily = obj.fontFamily;
                    freeTextEle.style.fontSize = obj.fontSize;
                    freeTextEle.style.textAlign = 'Left';
                    if (obj.textAlign.toLowerCase() === 'center') {
                        freeTextEle.style.textAlign = 'Center';
                    }
                    else if (obj.textAlign.toLowerCase() === 'right') {
                        freeTextEle.style.textAlign = 'Right';
                    }
                    else if (obj.textAlign.toLowerCase() === 'justify') {
                        freeTextEle.style.textAlign = 'Justify';
                    }
                    freeTextEle.style.color = obj.fontColor;
                    freeTextEle.style.bold = obj.font.isBold;
                    freeTextEle.style.italic = obj.font.isItalic;
                    if (obj.font.isUnderline !== undefined) {
                        if (obj.font.isUnderline === true) {
                            if (obj.font.isStrikeout) {
                                freeTextEle.style.textDecoration = 'Underline LineThrough';
                            }
                            else {
                                freeTextEle.style.textDecoration = 'Underline';
                            }
                        }
                        else {
                            if (obj.font.isStrikeout) {
                                if (freeTextEle.style.textDecoration === 'Underline LineThrough') {
                                    freeTextEle.style.textDecoration = 'LineThrough';
                                }
                                else {
                                    freeTextEle.style.textDecoration = 'None';
                                }
                            }
                        }
                    }
                    if (obj.font.isStrikeout !== undefined) {
                        if (obj.font.isStrikeout === true) {
                            if (obj.font.isUnderline) {
                                freeTextEle.style.textDecoration = 'Underline LineThrough';
                            }
                            else {
                                freeTextEle.style.textDecoration = 'LineThrough';
                            }
                        }
                        else {
                            if (!obj.font.isUnderline) {
                                if (freeTextEle.style.textDecoration === 'Underline LineThrough') {
                                    freeTextEle.style.textDecoration = 'Underline';
                                }
                                else {
                                    freeTextEle.style.textDecoration = 'None';
                                }
                            }
                        }
                    }
                    freeTextEle.rotateValue = undefined;
                    freeTextEle.content = obj.dynamicText;
                    freeTextEle.style.opacity = obj.opacity;
                    freeTextEle.style.strokeWidth = obj.thickness;
                    if (obj.isSignatureText) {
                        freeTextEle.margin.left = 4;
                        freeTextEle.margin.right = 5;
                        freeTextEle.margin.top = 5 * (obj.fontSize / 16);
                    }
                    else {
                        freeTextEle.margin.left = 0;
                        freeTextEle.margin.right = 0;
                        freeTextEle.margin.top = 0;
                    }
                    this.isPasted = false;
                    if (this.pdfViewer.freeTextSettings.enableAutoFit) {
                        freeTextEle.style.textWrapping = 'Wrap';
                    }
                    else {
                        freeTextEle.style.textWrapping = 'WrapWithOverflow';
                    }
                    freeTextEle.relativeMode = 'Point';
                    freeTextEle.setOffsetWithRespectToBounds(0, 0, null);
                    freeTextEle.relativeMode = 'Point';
                    canvas.children.push(freeTextEle);
                    break;
                }
            }
            content.id = obj.id + '_content';
            content.relativeMode = 'Object';
            if (!isStamp) {
                if (obj.bounds.width !== undefined) {
                    content.width = obj.bounds.width;
                    if (isAnnotationSet) {
                        if ((content.width < annotationMinWidth) || (content.width > annotationMaxWidth)) {
                            if (content.width < annotationMinWidth) {
                                content.width = annotationMinWidth;
                            }
                            if (content.width > annotationMaxWidth) {
                                content.width = annotationMaxWidth;
                            }
                        }
                    }
                }
                content.horizontalAlignment = 'Stretch';
                if (obj.bounds.height !== undefined) {
                    content.height = obj.bounds.height;
                    if (isAnnotationSet) {
                        if ((content.height < annotationMinHeight) || (content.width > annotationMaxHeight)) {
                            if (content.height < annotationMinHeight) {
                                content.height = annotationMinHeight;
                            }
                            if (content.height > annotationMaxHeight) {
                                content.height = annotationMaxHeight;
                            }
                        }
                    }
                }
                drawing_util_1.setElementStype(obj, content);
            }
            content.isRectElement = true;
            content.verticalAlignment = 'Stretch';
            return content;
        };
        Drawing.prototype.textElement = function (obj) {
            var textele = new ej2_drawings_6.TextElement();
            drawing_util_1.setElementStype(obj, textele);
            textele.horizontalAlignment = 'Center';
            textele.verticalAlignment = obj.shapeAnnotationType === 'SignatureText' ? 'Center' : 'Top';
            textele.relativeMode = 'Object';
            textele.setOffsetWithRespectToBounds(.5, .5, 'Absolute');
            return textele;
        };
        Drawing.prototype.setNodePosition = function (obj, node) {
            if (node.shapeAnnotationType === 'Perimeter') {
                obj.offsetX = node.bounds.x + node.bounds.width / 2;
                obj.offsetY = node.bounds.y + node.bounds.height / 2;
            }
            else if (node.shapeAnnotationType === 'Radius') {
                var trasPoint = { x: node.bounds.x + (node.bounds.width / 2) +
                        (node.bounds.width / 4), y: node.bounds.y + (node.bounds.height / 2) };
                var center = { x: (node.bounds.x + (node.bounds.width / 2)), y: (node.bounds.y + (node.bounds.height / 2)) };
                var matrix = ej2_drawings_1.identityMatrix();
                ej2_drawings_1.rotateMatrix(matrix, node.rotateAngle, center.x, center.y);
                var rotatedPoint = ej2_drawings_6.transformPointByMatrix(matrix, trasPoint);
                var newPoint1 = { x: rotatedPoint.x, y: rotatedPoint.y };
                obj.offsetX = newPoint1.x;
                obj.offsetY = newPoint1.y;
                obj.width = node.bounds.width / 2;
            }
        };
        Drawing.prototype.initContainer = function (obj) {
            if (!obj.id) {
                obj.id = ej2_drawings_5.randomId();
            }
            var canvas = new ej2_drawings_7.Canvas();
            canvas.id = obj.id;
            canvas.offsetX = obj.bounds.x + (obj.bounds.width * 0.5);
            canvas.offsetY = obj.bounds.y + (obj.bounds.height * 0.5);
            canvas.style.fill = 'transparent';
            canvas.style.strokeColor = 'transparent';
            canvas.rotateAngle = obj.rotateAngle;
            obj.wrapper = canvas;
            return canvas;
        };
        Drawing.prototype.initLine = function (obj) {
            if (!obj.id) {
                obj.id = ej2_drawings_5.randomId();
            }
            var container = new ej2_drawings_7.Canvas();
            var segment = new ej2_drawings_3.PathElement();
            segment.id = obj.id + '_path';
            var srcDecorator = new ej2_drawings_3.PathElement();
            var targetDecorator = new ej2_drawings_3.PathElement();
            if (obj.vertexPoints.length) {
                obj.sourcePoint = obj.vertexPoints[0];
                obj.targetPoint = obj.vertexPoints[obj.vertexPoints.length - 1];
                for (var i = 0; i < obj.vertexPoints.length; i++) {
                    if (i !== 0 && i !== obj.vertexPoints.length - 1) {
                        obj.segments.push(obj.vertexPoints[parseInt(i.toString(), 10)]);
                    }
                }
            }
            segment = connector_util_1.getSegmentElement(obj, segment);
            var points = [];
            points = connector_util_1.getConnectorPoints(obj);
            var leaders = [];
            var labels = [];
            if (obj.shapeAnnotationType === 'Distance') {
                leaders = connector_util_1.initLeaders(obj, points);
                labels = connector_util_1.initDistanceLabel(obj, points, this.pdfViewer.annotation.measureAnnotationModule, this.pdfViewer);
            }
            if ((obj.shapeAnnotationType === 'Line' || obj.shapeAnnotationType === 'LineWidthArrowHead') && obj.measureType === 'Perimeter') {
                labels = connector_util_1.initPerimeterLabel(obj, points, this.pdfViewer.annotation.measureAnnotationModule, this.pdfViewer);
            }
            if (obj.enableShapeLabel === true && !(obj.shapeAnnotationType === 'Distance') && !(obj.measureType === 'Perimeter')) {
                var angle = ej2_drawings_1.Point.findAngle(points[0], points[1]);
                var textele = this.textElement(obj);
                textele.id = ej2_drawings_5.randomId();
                if (!this.pdfViewer.enableImportAnnotationMeasurement && obj.notes && obj.notes !== '') {
                    textele.content = obj.notes;
                }
                else {
                    textele.content = obj.labelContent;
                }
                textele.style.strokeColor = obj.labelBorderColor;
                textele.style.fill = obj.labelFillColor;
                textele.style.fontSize = obj.fontSize;
                textele.style.color = obj.fontColor;
                textele.style.fontFamily = obj.fontFamily;
                textele.style.opacity = obj.labelOpacity;
                textele.rotateValue = { y: -10, angle: angle };
                labels.push(textele);
            }
            points = connector_util_1.clipDecorators(obj, points);
            var bounds = ej2_drawings_1.Rect.toBounds(points);
            container.width = bounds.width;
            container.height = bounds.height;
            container.offsetX = bounds.x + container.pivot.x * bounds.width;
            container.offsetY = bounds.y + container.pivot.y * bounds.height;
            var anglePoints = obj.vertexPoints;
            if (obj.shapeAnnotationType === 'Line' || obj.shapeAnnotationType === 'LineWidthArrowHead' || obj.shapeAnnotationType === 'Distance') {
                srcDecorator = connector_util_1.getDecoratorElement(obj, points[0], anglePoints[1], true);
                targetDecorator = connector_util_1.getDecoratorElement(obj, points[points.length - 1], anglePoints[anglePoints.length - 2], false);
            }
            srcDecorator.id = obj.id + '_srcDec';
            targetDecorator.id = obj.id + '_tarDec';
            segment.style['fill'] = 'transparent';
            container.style.strokeColor = 'transparent';
            container.style.fill = 'transparent';
            container.style.strokeWidth = 0;
            container.children = [];
            drawing_util_1.setElementStype(obj, segment);
            container.children.push(segment);
            if (leaders.length > 0) {
                for (var i = 0; i < leaders.length; i++) {
                    container.children.push(leaders[parseInt(i.toString(), 10)]);
                }
            }
            if (labels.length > 0) {
                for (var i = 0; i < labels.length; i++) {
                    container.children.push(labels[parseInt(i.toString(), 10)]);
                }
            }
            container.children.push(srcDecorator);
            container.children.push(targetDecorator);
            if (obj.shapeAnnotationType === 'LineWidthArrowHead') {
                for (var i = 0; i < container.children.length; i++) {
                    var child = container.children[parseInt(i.toString(), 10)];
                    if (child.id.includes('srcDec') || child.id.includes('tarDec')) {
                        if (!(obj.sourceDecoraterShapes === 'Butt' || obj.taregetDecoraterShapes === 'Butt')) {
                            child.width = 12 * obj.thickness;
                        }
                        child.height = 12 * obj.thickness;
                    }
                }
            }
            container.id = obj.id;
            container.offsetX = segment.offsetX;
            container.offsetY = segment.offsetY;
            container.width = segment.width;
            container.height = segment.height;
            points = connector_util_1.getConnectorPoints(obj);
            obj.wrapper = container;
            return container;
        };
        Drawing.prototype.add = function (obj) {
            var allowServerDataBind = this.pdfViewer.allowServerDataBinding;
            this.pdfViewer.enableServerDataBinding(false);
            if (obj.formFieldAnnotationType && this.pdfViewer.formDesignerModule) {
                obj = new pdf_annotation_1.PdfFormFieldBase(this.pdfViewer, 'formFields', obj, true);
                obj = this.initObject(obj);
                this.pdfViewer.formFields.push(obj);
            }
            else {
                obj = new pdf_annotation_1.PdfAnnotationBase(this.pdfViewer, 'annotations', obj, true);
                obj = this.initObject(obj);
                this.pdfViewer.annotations.push(obj);
            }
            this.pdfViewer.enableServerDataBinding(allowServerDataBind, true);
            return obj;
        };
        Drawing.prototype.remove = function (obj) {
            var allowServerDataBind = this.pdfViewer.allowServerDataBinding;
            this.pdfViewer.enableServerDataBinding(false);
            var index = obj.pageIndex;
            for (var i = 0; i < this.pdfViewer.annotations.length; i++) {
                var annotation = this.pdfViewer.annotations[parseInt(i.toString(), 10)];
                if ((annotation.id && (annotation.id === obj.id || annotation.id.split('_')[0] === obj.id)) || (annotation.wrapper && annotation.wrapper.id === obj.id)) {
                    this.pdfViewer.annotations.splice(i, 1);
                    var objects = this.getPageObjects(obj.pageIndex);
                    for (var j = 0; j < objects.length; j++) {
                        if (objects[parseInt(j.toString(), 10)].id === obj.id) {
                            objects.splice(j, 1);
                            if (obj.shapeAnnotationType === 'Path' || obj.shapeAnnotationType === 'SignatureImage' || obj.shapeAnnotationType === 'SignatureText') {
                                this.refreshCanvasDiagramLayer(undefined, index, obj.id);
                            }
                            else {
                                this.pdfViewer.renderDrawing(undefined, index);
                            }
                        }
                    }
                }
            }
            for (var i = 0; i < this.pdfViewer.formFields.length; i++) {
                var element = this.pdfViewer.formFields[parseInt(i.toString(), 10)];
                if (element.id === obj.id || element.wrapper.id === obj.id) {
                    this.pdfViewer.formFields.splice(i, 1);
                    if (this.pdfViewer.formDesignerModule && obj.formFieldAnnotationType) {
                        this.pdfViewer.formFieldCollection.splice(i, 1);
                    }
                    var objects = this.getPageObjects(obj.pageIndex);
                    for (var j = 0; j < objects.length; j++) {
                        if (objects[parseInt(j.toString(), 10)].id === obj.id) {
                            objects.splice(j, 1);
                            break;
                        }
                        if (objects[parseInt(j.toString(), 10)] && objects[parseInt(j.toString(), 10)].id &&
                            objects[parseInt(j.toString(), 10)].id.indexOf(obj.id) !== -1) {
                            objects.splice(j, 1);
                        }
                    }
                }
            }
            if (obj.formFieldAnnotationType === 'Textbox' || obj.formFieldAnnotationType === 'Checkbox' || obj.formFieldAnnotationType === 'RadioButton'
                || obj.formFieldAnnotationType === 'PasswordField' || obj.formFieldAnnotationType === 'DropdownList' || obj.formFieldAnnotationType === 'ListBox' || obj.formFieldAnnotationType === 'SignatureField' || obj.formFieldAnnotationType === 'InitialField') {
                var inputField = document.getElementById('form_field_' + obj.id + '_content_html_element');
                if (inputField) {
                    inputField.remove();
                    this.pdfViewer.renderDrawing(undefined, index);
                }
                for (var i = 0; i < this.pdfViewer.formFieldCollections.length; i++) {
                    var element = this.pdfViewer.formFieldCollections[parseInt(i.toString(), 10)];
                    if (element.id === obj.id) {
                        this.pdfViewer.formFieldCollections.splice(i, 1);
                    }
                }
                for (var i = 0; i < this.pdfViewer.viewerBase.formFieldCollection.length; i++) {
                    if (obj.id == this.pdfViewer.viewerBase.formFieldCollection[parseInt(i.toString(), 10)]) {
                        this.pdfViewer.viewerBase.formFieldCollection.splice(i, 1);
                    }
                }
                var field = {
                    name: obj.name, id: obj.id, value: obj.value, fontFamily: obj.fontFamily, fontSize: obj.fontSize, fontStyle: obj.fontStyle,
                    color: obj.color, backgroundColor: obj.backgroundColor, alignment: obj.alignment, isReadonly: obj.isReadonly, visibility: obj.visibility,
                    maxLength: obj.maxLength, isRequired: obj.isRequired, isPrint: obj.isPrint, rotation: obj.rotateAngle, tooltip: obj.tooltip,
                    options: obj.options, isChecked: obj.isChecked, isSelected: obj.isSelected,
                    customData: obj.customData, lineBound: obj.bounds,
                    pageNumber: obj.pageIndex, insertSpaces: obj.insertSpaces,
                    formFieldAnnotationType: obj.formFieldAnnotationType,
                    borderColor: obj.borderColor, thickness: obj.thickness, isTransparent: obj.isTransparent
                };
                if (!ej2_base_1.isNullOrUndefined(field) && field.id !== 'diagram_helper') {
                    this.pdfViewer.fireFormFieldRemoveEvent('formFieldRemove', field, obj.pageIndex);
                    this.pdfViewer.formDesignerModule.removeFieldsFromAnnotationCollections(obj.id, field.name);
                }
            }
            this.pdfViewer.enableServerDataBinding(allowServerDataBind, true);
        };
        Drawing.prototype.getPageObjects = function (pageIndex) {
            var pageTable = this.getPageTable(pageIndex);
            return pageTable.objects;
        };
        Drawing.prototype.refreshCanvasDiagramLayer = function (diagramLayer, pageIndex, objectId) {
            var _this = this;
            if (!diagramLayer) {
                diagramLayer = this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', pageIndex);
            }
            if (diagramLayer) {
                var zoom = void 0;
                if (diagramLayer.id === this.pdfViewer.element.id + '_print_annotation_layer_' + pageIndex) {
                    zoom = 1;
                }
                else {
                    zoom = this.pdfViewer.viewerBase.getZoomFactor();
                }
                var width = diagramLayer.width / zoom;
                var height = diagramLayer.height / zoom;
                var ctx = diagramLayer.getContext('2d');
                ctx.lineCap = 'round';
                ctx.lineJoin = 'round';
                if (zoom < 1) {
                    ctx.lineWidth = ctx.lineWidth / zoom;
                }
                var devicePixelRatio_1 = this.pdfViewer.viewerBase.getWindowDevicePixelRatio();
                var zoomRatio = zoom * devicePixelRatio_1;
                if (!ej2_base_1.Browser.isDevice || (ej2_base_1.Browser.isDevice && zoom <= 0.7)) {
                    ctx.setTransform(zoomRatio, 0, 0, zoomRatio, 0, 0);
                }
                else {
                    ctx.setTransform(zoom, 0, 0, zoom, 0, 0);
                }
                ctx.clearRect(0, 0, width, height);
                var objects = this.getPageObjects(pageIndex);
                var uniqueObjects = objects.filter(function (obj, index, self) {
                    if (obj.id.split('_')[0] === 'free') {
                        return true;
                    }
                    else if (!ej2_base_1.isNullOrUndefined(_this.pdfViewer.formDesignerModule)) {
                        return index === self.findIndex(function (t) { return t.id.split('_')[0] === obj.id.split('_')[0]; });
                    }
                    return index === self.findIndex(function (t) { return t.id === obj.id; });
                });
                for (var i = 0; i < uniqueObjects.length; i++) {
                    var renderElement = void 0;
                    if (diagramLayer.id === this.pdfViewer.element.id + '_print_annotation_layer_' + pageIndex) {
                        if (uniqueObjects[parseInt(i.toString(), 10)].isPrint) {
                            renderElement = this.pdfViewer.nameTable[uniqueObjects[parseInt(i.toString(), 10)].id].wrapper;
                            if (!ej2_base_1.isNullOrUndefined(renderElement)) {
                                ej2_drawings_7.refreshDiagramElements(diagramLayer, [renderElement], this.renderer);
                            }
                        }
                    }
                    else {
                        renderElement = this.pdfViewer.nameTable[uniqueObjects[parseInt(i.toString(), 10)].id].wrapper;
                        var uniqueObjectId = uniqueObjects[parseInt(i.toString(), 10)].id;
                        var uniqueObject = this.pdfViewer.nameTable["" + uniqueObjectId];
                        if ((renderElement && this.shouldRefreshElement(uniqueObject)) ||
                            ej2_base_1.isNullOrUndefined(this.pdfViewer.formDesignerModule)) {
                            if (!ej2_base_1.isNullOrUndefined(uniqueObject.properties.data) && uniqueObject.properties.data.includes('base64')) {
                                var image = new Image();
                                image.src = uniqueObject.properties.data;
                                if (window.customStampCollection == null && window.customStampCollection === undefined) {
                                    window.customStampCollection = new Map();
                                }
                                if (window.customStampCollection && !window.customStampCollection.get(renderElement.id)) {
                                    window.customStampCollection.set(renderElement.id, image);
                                }
                            }
                            else if (!ej2_base_1.isNullOrUndefined(uniqueObject.properties.value) && uniqueObject.properties.value.includes('base64')) {
                                var image = new Image();
                                image.src = uniqueObject.properties.value;
                                if (window.signatureCollection == null && window.signatureCollection === undefined) {
                                    window.signatureCollection = new Map();
                                }
                                if (window.signatureCollection && !window.signatureCollection.get(renderElement.id)) {
                                    window.signatureCollection.set(renderElement.id, image);
                                }
                            }
                            if (renderElement.children[1] instanceof ej2_drawings_6.TextElement) {
                                renderElement.children[1].isEJ2 = true;
                            }
                            if (uniqueObject.shapeAnnotationType === 'FreeText' && !uniqueObject.isSignatureText) {
                                renderElement.children[0].isEJ2 = true;
                                renderElement.children[1].isEJ2 = true;
                            }
                            if (uniqueObject.shapeAnnotationType === 'FreeText' && !uniqueObject.isSignatureText) {
                                ej2_drawings_7.refreshDiagramElements(diagramLayer, [renderElement], this.renderer, null, uniqueObject.shapeAnnotationType);
                            }
                            else {
                                ej2_drawings_7.refreshDiagramElements(diagramLayer, [renderElement], this.renderer);
                            }
                        }
                    }
                }
            }
        };
        Drawing.prototype.shouldRefreshElement = function (uniqueObject) {
            var parentObject = this.pdfViewer.nameTable[uniqueObject.id.split('_')[0]];
            return ((!ej2_base_1.isNullOrUndefined(parentObject) && uniqueObject.visibility === 'visible') ||
                (!ej2_base_1.isNullOrUndefined(uniqueObject.subject) && uniqueObject.annotName !== 'SignatureField' && ej2_base_1.isNullOrUndefined(uniqueObject.visibility)) ||
                (uniqueObject.propName === 'annotations' &&
                    uniqueObject.shapeAnnotationType !== 'Path' &&
                    uniqueObject.shapeAnnotationType !== 'SignatureText' &&
                    uniqueObject.shapeAnnotationType !== 'SignatureImage') ||
                (uniqueObject.shapeAnnotationType === 'SignatureImage' &&
                    uniqueObject.propName !== 'formFields') ||
                (uniqueObject.shapeAnnotationType === 'SignatureText' &&
                    uniqueObject.propName !== 'formFields') || (ej2_base_1.isNullOrUndefined(parentObject) && uniqueObject.id === 'diagram_helper'));
        };
        Drawing.prototype.clearHighlighter = function (index) {
            var adornerSvg = this.getAdornerLayerSvg(this.pdfViewer.element.id + index + '_diagramAdornerLayer', index);
            if (adornerSvg) {
                var highlighter = adornerSvg.getElementById(adornerSvg.id + '_highlighter');
                if (highlighter) {
                    highlighter.parentNode.removeChild(highlighter);
                }
            }
        };
        Drawing.prototype.getSelectorElement = function (diagramId, index) {
            var adornerLayer = null;
            var adornerSvg = this.getAdornerLayerSvg(diagramId, index);
            if (adornerSvg) {
                adornerLayer = adornerSvg.getElementById(diagramId + index + '_SelectorElement');
            }
            return adornerLayer;
        };
        Drawing.prototype.getAdornerLayerSvg = function (diagramId, index) {
            var adornerLayerSvg = null;
            var diagramElement = ej2_drawings_1.getDiagramElement(diagramId + index + '_diagramAdornerLayer');
            if (ej2_base_1.isNullOrUndefined(diagramElement)) {
                this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', index);
                diagramElement = ej2_drawings_1.getDiagramElement(diagramId + index + '_diagramAdornerLayer');
            }
            var elementcoll;
            if (diagramElement) {
                elementcoll = diagramElement.getElementsByClassName('e-adorner-layer' + index);
                adornerLayerSvg = elementcoll[0];
            }
            return adornerLayerSvg;
        };
        Drawing.prototype.clearSelectorLayer = function (index) {
            var adornerSvg = this.getAdornerLayerSvg(this.pdfViewer.element.id, index);
            if (adornerSvg) {
                var selectionRect = adornerSvg.getElementById(this.pdfViewer.adornerSvgLayer.id + '_selected_region');
                if (selectionRect) {
                    selectionRect.parentNode.removeChild(selectionRect);
                }
                this.clearHighlighter(index);
                var childNodes = this.getSelectorElement(this.pdfViewer.element.id, index).childNodes;
                var child = void 0;
                for (var i = childNodes.length; i > 0; i--) {
                    child = childNodes[i - 1];
                    child.parentNode.removeChild(child);
                }
            }
        };
        Drawing.prototype.renderSelector = function (select, currentSelector, helper, isSelect) {
            if (!helper || isSelect) {
                var size = new ej2_drawings_6.Size();
                var selectorModel = this.pdfViewer.selectedItems;
                this.clearSelectorLayer(select);
                if (this.pdfViewer.toolbarModule && this.pdfViewer.toolbarModule.annotationToolbarModule) {
                    this.pdfViewer.toolbarModule.annotationToolbarModule.isRedactAnnotSelected = false;
                }
                if (selectorModel.wrapper) {
                    if (selectorModel.wrapper.children[1] instanceof ej2_drawings_6.TextElement) {
                        selectorModel.wrapper.children[1].isEJ2 = true;
                        if (selectorModel.annotations[0].shapeAnnotationType === 'FreeText') {
                            selectorModel.wrapper.children[1].isFreeText = true;
                        }
                    }
                    selectorModel.wrapper.measure(size);
                    var zoom = this.pdfViewer.viewerBase.getZoomFactor();
                    selectorModel.wrapper.arrange(selectorModel.wrapper.desiredSize);
                    selectorModel.width = selectorModel.wrapper.actualSize.width;
                    selectorModel.height = selectorModel.wrapper.actualSize.height;
                    selectorModel.offsetX = selectorModel.wrapper.offsetX;
                    selectorModel.offsetY = selectorModel.wrapper.offsetY;
                    if (selectorModel.annotations.length === 1) {
                        selectorModel.rotateAngle = selectorModel.annotations[0].rotateAngle;
                        selectorModel.wrapper.rotateAngle = selectorModel.annotations[0].rotateAngle;
                    }
                    var selectorElement = void 0;
                    if (selectorModel.formFields.length) {
                        for (var i = 0; i < selectorModel.formFields.length; i++) {
                            var node = selectorModel.formFields[parseInt(i.toString(), 10)];
                            selectorElement = this.getSelectorElement(this.pdfViewer.element.id, select);
                            if (selectorElement && node.pageIndex === select && this.pdfViewer.designerMode) {
                                this.renderResizeHandle(node.wrapper.children[0], selectorElement, selectorModel.thumbsConstraints, zoom, undefined, undefined, undefined, false, true, null, null, currentSelector);
                            }
                            if (this.pdfViewer.formDesignerModule && node.formFieldAnnotationType) {
                                if (!this.pdfViewer.viewerBase.isFormFieldSelect && !this.pdfViewer.viewerBase.isFormFieldMouseDown &&
                                    !this.pdfViewer.viewerBase.isFormFieldMouseMove) {
                                    this.pdfViewer.viewerBase.isFormFieldSelect = true;
                                    var field = {
                                        name: node.name, id: node.id, value: node.value,
                                        fontFamily: node.fontFamily, fontSize: node.fontSize, fontStyle: node.fontStyle,
                                        color: node.color,
                                        backgroundColor: node.backgroundColor,
                                        alignment: node.alignment, isReadonly: node.isReadonly,
                                        visibility: node.visibility,
                                        maxLength: node.maxLength, isRequired: node.isRequired,
                                        isPrint: node.isPrint, rotation: node.rotateAngle, tooltip: node.tooltip,
                                        options: node.options, isChecked: node.isChecked,
                                        isSelected: node.isSelected, bounds: node.bounds,
                                        pageNumber: node.pageIndex, insertSpaces: node.insertSpaces,
                                        formFieldAnnotationType: node.formFieldAnnotationType,
                                        customData: node.customData, borderColor: node.borderColor,
                                        thickness: node.thickness, isTransparent: node.isTransparent
                                    };
                                    if (!this.pdfViewer.formDesignerModule.isFormFieldSizeUpdated) {
                                        this.pdfViewer.fireFormFieldSelectEvent('formFieldSelect', field, node.pageIndex, this.pdfViewer.formDesignerModule.isProgrammaticSelection);
                                    }
                                    this.pdfViewer.formDesignerModule.isFormFieldSizeUpdated = false;
                                }
                            }
                        }
                    }
                    if (selectorModel.annotations.length) {
                        for (var j = 0; j < selectorModel.annotations.length; j++) {
                            var node = selectorModel.annotations[parseInt(j.toString(), 10)];
                            selectorElement = this.getSelectorElement(this.pdfViewer.element.id, select);
                            if (selectorElement && node.pageIndex === select) {
                                if (node.shapeAnnotationType === 'Distance' || node.shapeAnnotationType === 'Line' ||
                                    node.shapeAnnotationType === 'LineWidthArrowHead' || node.shapeAnnotationType === 'Polygon') {
                                    this.renderEndPointHandle(node, selectorElement, selectorModel.thumbsConstraints, { scale: zoom, tx: 0, ty: 0 }, undefined, undefined, true, currentSelector);
                                }
                                else {
                                    if (node.shapeAnnotationType === 'StickyNotes') {
                                        this.renderResizeHandle(node.wrapper.children[0], selectorElement, selectorModel.thumbsConstraints, zoom, undefined, undefined, undefined, false, true, null, null, currentSelector);
                                    }
                                    else {
                                        if (this.pdfViewer.tool !== 'Stamp') {
                                            var isSignature = node.shapeAnnotationType === 'Path' || node.formFieldAnnotationType === 'SignatureField' || node.formFieldAnnotationType === 'InitialField';
                                            this.renderResizeHandle(node.wrapper.children[0], selectorElement, selectorModel.thumbsConstraints, zoom, undefined, undefined, undefined, node.shapeAnnotationType === 'Stamp', false, isSignature, (node.shapeAnnotationType === 'FreeText' || node.shapeAnnotationType === 'HandWrittenSignature' || node.shapeAnnotationType === 'SignatureImage' || node.shapeAnnotationType === 'Image' || node.shapeAnnotationType === 'SignatureText'), currentSelector);
                                        }
                                    }
                                }
                                if (!this.pdfViewer.viewerBase.isNewSignatureAdded && (node.shapeAnnotationType === 'HandWrittenSignature' || node.shapeAnnotationType === 'SignatureText' || node.shapeAnnotationType === 'SignatureImage')) {
                                    this.pdfViewer.annotationModule.selectSignature(node.signatureName, node.pageIndex, node);
                                }
                                if (this.pdfViewer.formDesignerModule && node.formFieldAnnotationType) {
                                    if (!this.pdfViewer.viewerBase.isFormFieldSelect && !this.pdfViewer.viewerBase.isFormFieldMouseDown &&
                                        !this.pdfViewer.viewerBase.isFormFieldMouseMove) {
                                        this.pdfViewer.viewerBase.isFormFieldSelect = true;
                                        var field = {
                                            value: node.value, fontFamily: node.fontFamily, fontSize: node.fontSize,
                                            fontStyle: node.fontStyle,
                                            color: node.color,
                                            backgroundColor: node.backgroundColor,
                                            alignment: node.alignment, isReadonly: node.isReadonly,
                                            visibility: node.visibility,
                                            maxLength: node.maxLength, isRequired: node.isRequired,
                                            isPrint: node.isPrint, rotation: node.rotateAngle, tooltip: node.tooltip,
                                            options: node.options, isChecked: node.isChecked,
                                            isSelected: node.isSelected, bounds: node.bounds
                                        };
                                        if (!this.pdfViewer.formDesignerModule.isFormFieldSizeUpdated) {
                                            this.pdfViewer.fireFormFieldSelectEvent('formFieldSelect', field, node.pageIndex, this.pdfViewer.formDesignerModule.isProgrammaticSelection);
                                        }
                                        this.pdfViewer.formDesignerModule.isFormFieldSizeUpdated = false;
                                    }
                                }
                                if ((node.annotName !== '' || node.signatureName === 'ink') && node.annotName !== 'SignatureText') {
                                    if (helper && (node === helper) && !node.formFieldAnnotationType) {
                                        if (!this.pdfViewer.viewerBase.isAddComment && !this.pdfViewer.viewerBase.isAnnotationSelect &&
                                            !this.pdfViewer.viewerBase.isAnnotationMouseDown &&
                                            !this.pdfViewer.viewerBase.isAnnotationMouseMove && !this.pdfViewer.viewerBase.isInkAdded &&
                                            !this.pdfViewer.viewerBase.isNewStamp) {
                                            this.pdfViewer.viewerBase.isAnnotationSelect = true;
                                            this.pdfViewer.annotationModule.annotationSelect(node.annotName, node.pageIndex, node);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        };
        Drawing.prototype.rotate = function (obj, angle, pivot, currentSelector) {
            var checkBoundaryConstraints;
            if (obj) {
                pivot = pivot || { x: obj.wrapper.offsetX, y: obj.wrapper.offsetY };
                if (obj instanceof selector_1.Selector) {
                    obj.rotateAngle += angle;
                    obj.wrapper.rotateAngle += angle;
                    var objects = [];
                    objects = objects.concat(obj.annotations);
                    this.rotateObjects(obj, objects, angle, pivot, null, currentSelector);
                }
                else {
                    this.rotateObjects(obj, [obj], angle, pivot);
                }
            }
            return checkBoundaryConstraints;
        };
        Drawing.prototype.rotateObjects = function (parent, objects, angle, pivot, includeParent, currentSelector) {
            pivot = pivot || {};
            var matrix = ej2_drawings_1.identityMatrix();
            ej2_drawings_1.rotateMatrix(matrix, angle, pivot.x, pivot.y);
            for (var _i = 0, objects_1 = objects; _i < objects_1.length; _i++) {
                var obj = objects_1[_i];
                if (obj instanceof pdf_annotation_1.PdfAnnotationBase) {
                    if (includeParent !== false || parent !== obj) {
                        obj.rotateAngle += angle;
                        obj.rotateAngle = (obj.rotateAngle + 360) % 360;
                        var newOffset = ej2_drawings_6.transformPointByMatrix(matrix, { x: obj.wrapper.offsetX, y: obj.wrapper.offsetY });
                        obj.wrapper.offsetX = newOffset.x;
                        obj.wrapper.offsetY = newOffset.y;
                        this.nodePropertyChange(obj, { rotateAngle: obj.rotateAngle });
                    }
                    this.renderSelector(obj.pageIndex, currentSelector);
                }
            }
        };
        Drawing.prototype.getParentSvg = function (element, targetElement, canvas) {
            if (element && element.id) {
                if (targetElement && targetElement === 'selector') {
                    return this.pdfViewer.adornerSvgLayer;
                }
            }
            return canvas;
        };
        Drawing.prototype.shownBorder = function () {
            var isSelectInAllowed = false;
            if (this.pdfViewer.annotationModule) {
                var annotation = this.pdfViewer.selectedItems.annotations[0];
                var allowedInteraction = this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
                var isLock = this.pdfViewer.annotationModule.checkIsLockSettings(annotation);
                isSelectInAllowed = !ej2_base_1.isNullOrUndefined(allowedInteraction) && (!(allowedInteraction.length === 1 && allowedInteraction[0] === 'None') || !isLock);
            }
            return isSelectInAllowed;
        };
        Drawing.prototype.renderBorder = function (selector, canvas, currentSelector, transform, enableNode, isBorderTickness, isSwimlane, isSticky) {
            var wrapper = selector;
            var options = drawing_util_1.getBaseShapeAttributes(wrapper, transform);
            transform = transform || { scale: 1, tx: 0, ty: 0 };
            if (!isSticky) {
                options.x *= transform.scale;
                options.y *= transform.scale;
                options.width *= transform.scale;
                options.height *= transform.scale;
                options.fill = 'transparent';
                var shapeType = this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType;
                if (currentSelector && (typeof (currentSelector) !== 'object') && currentSelector !== '') {
                    var annotationSelector = JSON.parse(currentSelector);
                    var borderColor = annotationSelector.selectionBorderColor === '' ? 'black' : annotationSelector.selectionBorderColor;
                    options.stroke = borderColor;
                    options.strokeWidth = currentSelector.selectionBorderThickness === 1 ? 1 : annotationSelector.selectionBorderThickness;
                    var lineDash = annotationSelector.selectorLineDashArray.length === 0 ?
                        [6, 3] : annotationSelector.selectorLineDashArray;
                    if (lineDash.length > 2) {
                        lineDash = [lineDash[0], lineDash[1]];
                    }
                    options.dashArray = lineDash.toString();
                }
                else if (currentSelector && currentSelector !== '') {
                    var borderColor = currentSelector.selectionBorderColor === '' ? 'black' : currentSelector.selectionBorderColor;
                    options.stroke = borderColor;
                    options.strokeWidth = currentSelector.selectionBorderThickness === 1 ? 1 : currentSelector.selectionBorderThickness;
                    var lineDash = (!ej2_base_1.isNullOrUndefined(currentSelector.selectorLineDashArray) &&
                        (currentSelector.selectorLineDashArray.length === 0)) ? [6, 3] : currentSelector.selectorLineDashArray;
                    if (!ej2_base_1.isNullOrUndefined(lineDash) && lineDash.length > 2) {
                        lineDash = [lineDash[0], lineDash[1]];
                    }
                    if (!ej2_base_1.isNullOrUndefined(lineDash)) {
                        options.dashArray = lineDash.toString();
                    }
                }
                else {
                    if (!this.pdfViewer.designerMode) {
                        if ((shapeType === 'HandWrittenSignature' || shapeType === 'SignatureText' || shapeType === 'SignatureImage') || shapeType === 'Ink') {
                            var formField = this.pdfViewer.nameTable[selector.id.split('_')[0]];
                            var isFormFieldSign = this.pdfViewer.viewerBase.checkSignatureFormField(selector.id);
                            this.getSignBorder(shapeType, options, isFormFieldSign);
                        }
                        else {
                            this.getBorderSelector(shapeType, options);
                        }
                    }
                }
                options.class = 'e-pv-diagram-border';
                if (isSwimlane) {
                    options.class += ' e-diagram-lane';
                }
                options.id = 'borderRect';
                options.id = 'borderRect';
                if (!enableNode) {
                    options.class += ' e-disabled';
                }
                if (isBorderTickness) {
                    options.class += ' e-thick-border';
                }
                options.cornerRadius = 0;
            }
            else {
                options.x *= transform.scale;
                options.y *= transform.scale;
                options.width *= transform.scale;
                options.height *= transform.scale;
                var shapeType = this.pdfViewer.selectedItems.annotations.length > 0 ?
                    this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType
                    : this.pdfViewer.selectedItems.formFields[0].formFieldAnnotationType;
                if (currentSelector && (typeof (currentSelector) !== 'object') && currentSelector !== '') {
                    var annotationSelector = JSON.parse(currentSelector);
                    var borderColor = annotationSelector.selectionBorderColor === '' ? 'black' : annotationSelector.selectionBorderColor;
                    options.stroke = borderColor;
                    options.strokeWidth = currentSelector.selectionBorderThickness === 1 ? 1 : annotationSelector.selectionBorderThickness;
                    var lineDash = annotationSelector.selectorLineDashArray.length === 0 ?
                        [6, 3] : annotationSelector.selectorLineDashArray;
                    if (lineDash.length > 2) {
                        lineDash = [lineDash[0], lineDash[1]];
                    }
                    options.dashArray = lineDash.toString();
                }
                else if (currentSelector && currentSelector !== '') {
                    var borderColor = currentSelector.selectionBorderColor === '' ? 'black' : currentSelector.selectionBorderColor;
                    options.stroke = borderColor;
                    options.strokeWidth = currentSelector.selectionBorderThickness === 1 ? 1 : currentSelector.selectionBorderThickness;
                    var lineDash = (!ej2_base_1.isNullOrUndefined(currentSelector.selectorLineDashArray) &&
                        (currentSelector.selectorLineDashArray.length === 0)) ? [6, 3] : currentSelector.selectorLineDashArray;
                    if (!ej2_base_1.isNullOrUndefined(lineDash) && lineDash.length > 2) {
                        lineDash = [lineDash[0], lineDash[1]];
                    }
                    if (!ej2_base_1.isNullOrUndefined(lineDash)) {
                        options.dashArray = lineDash.toString();
                    }
                }
                else {
                    this.getBorderSelector(shapeType, options);
                }
            }
            var checkBorder = this.shownBorder();
            if (checkBorder) {
                var parentSvg = this.getParentSvg(selector, 'selector');
                this.svgRenderer.drawRectangle(canvas, options, this.pdfViewer.element.id, undefined, true, parentSvg);
            }
        };
        Drawing.prototype.getSignBorder = function (type, options, isFormFieldSign) {
            if (!isFormFieldSign && (type === 'HandWrittenSignature' || type === 'SignatureText' || type === 'SignatureImage') && this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) {
                var borderColor = ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.selectionBorderColor === '' ? '#0000ff' : this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.selectionBorderColor;
                options.stroke = borderColor;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.
                    annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.handWrittenSignatureSettings.
                    annotationSelectorSettings.selectionBorderThickness;
                options.strokeWidth = thickness;
                var lineDash = ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.
                    annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.handWrittenSignatureSettings.
                    annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.handWrittenSignatureSettings.
                    annotationSelectorSettings.selectorLineDashArray;
                if (lineDash.length > 2) {
                    lineDash = [lineDash[0], lineDash[1]];
                }
                options.dashArray = lineDash.toString();
            }
            else if (type === 'Ink' && this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) {
                var borderColor = ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.selectionBorderColor === '' ? '#0000ff' : this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.selectionBorderColor;
                options.stroke = borderColor;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.
                    selectionBorderThickness) ? 1 : this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.selectionBorderThickness;
                options.strokeWidth = thickness;
                var lineDash = ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.
                    selectorLineDashArray) || this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.
                    selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.
                    selectorLineDashArray;
                if (lineDash.length > 2) {
                    lineDash = [lineDash[0], lineDash[1]];
                }
                options.dashArray = lineDash.toString();
            }
            else {
                var annotationSelector = this.pdfViewer.annotationSelectorSettings;
                var borderColor = annotationSelector.selectionBorderColor === '' ? 'black' : annotationSelector.selectionBorderColor;
                options.stroke = borderColor;
                options.strokeWidth = annotationSelector.selectionBorderThickness === 1 ? 1 : annotationSelector.selectionBorderThickness;
                var lineDash = annotationSelector.selectorLineDashArray.length === 0 ?
                    [6, 3] : annotationSelector.selectorLineDashArray;
                if (lineDash.length > 2) {
                    lineDash = [lineDash[0], lineDash[1]];
                }
                options.dashArray = lineDash.toString();
            }
        };
        Drawing.prototype.getBorderSelector = function (type, options) {
            var annotationSelector = this.pdfViewer.annotationSelectorSettings;
            var borderColor = ej2_base_1.isNullOrUndefined(annotationSelector.selectionBorderColor) || annotationSelector.selectionBorderColor === '' ? 'black' : annotationSelector.selectionBorderColor;
            options.stroke = borderColor;
            options.strokeWidth = ej2_base_1.isNullOrUndefined(annotationSelector.selectionBorderThickness) ||
                annotationSelector.selectionBorderThickness === 1 ? 1 : annotationSelector.selectionBorderThickness;
            var lineDash = ej2_base_1.isNullOrUndefined(annotationSelector.selectorLineDashArray) ||
                annotationSelector.selectorLineDashArray.length === 0 ? [6, 3] : annotationSelector.selectorLineDashArray;
            if (lineDash.length > 2) {
                lineDash = [lineDash[0], lineDash[1]];
            }
            options.dashArray = lineDash.toString();
            if (type === 'Rectangle' && this.pdfViewer.rectangleSettings.annotationSelectorSettings) {
                var borderColor_1 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? 'black' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectionBorderColor;
                options.stroke = borderColor_1;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectionBorderThickness;
                options.strokeWidth = thickness;
                var lineDash_1 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectorLineDashArray;
                if (lineDash_1.length > 2) {
                    lineDash_1 = [lineDash_1[0], lineDash_1[1]];
                }
                options.dashArray = lineDash_1.toString();
            }
            else if ((type === 'Textbox' || type === 'Checkbox' || type === 'RadioButton' || type === 'SignatureField' || type === 'InitialField' || type === 'DropdownList' || type === 'ListBox' || type === 'PasswordField') && this.pdfViewer.rectangleSettings.annotationSelectorSettings) {
                var borderColor_2 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? 'black' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectionBorderColor)) ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectionBorderColor : 'black';
                options.stroke = borderColor_2;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectionBorderThickness)) ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectionBorderThickness : 1;
                options.strokeWidth = thickness;
                var lineDash_2 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectorLineDashArray)) ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.selectorLineDashArray : [4];
                if (lineDash_2.length > 2) {
                    lineDash_2 = [lineDash_2[0], lineDash_2[1]];
                }
                options.dashArray = lineDash_2.toString();
            }
            else if (type === 'Ellipse' && this.pdfViewer.circleSettings.annotationSelectorSettings) {
                var borderColor_3 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? 'black' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.selectionBorderColor)) ? this.pdfViewer.circleSettings.annotationSelectorSettings.selectionBorderColor : 'black';
                options.stroke = borderColor_3;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.selectionBorderThickness)) ? this.pdfViewer.circleSettings.annotationSelectorSettings.selectionBorderThickness : 1;
                options.strokeWidth = thickness;
                var lineDash_3 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.selectorLineDashArray)) ? this.pdfViewer.circleSettings.annotationSelectorSettings.selectorLineDashArray : [4];
                if (lineDash_3.length > 2) {
                    lineDash_3 = [lineDash_3[0], lineDash_3[1]];
                }
                options.dashArray = lineDash_3.toString();
            }
            else if (type === 'Radius' && this.pdfViewer.radiusSettings.annotationSelectorSettings) {
                var borderColor_4 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? 'black' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.selectionBorderColor)) ? this.pdfViewer.radiusSettings.annotationSelectorSettings.selectionBorderColor : 'black';
                options.stroke = borderColor_4;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.selectionBorderThickness)) ? this.pdfViewer.radiusSettings.annotationSelectorSettings.selectionBorderThickness : 1;
                options.strokeWidth = thickness;
                var lineDash_4 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.selectorLineDashArray)) ? this.pdfViewer.radiusSettings.annotationSelectorSettings.selectorLineDashArray : [4];
                if (lineDash_4.length > 2) {
                    lineDash_4 = [lineDash_4[0], lineDash_4[1]];
                }
                options.dashArray = lineDash_4.toString();
            }
            else if (type === 'FreeText' && this.pdfViewer.freeTextSettings.annotationSelectorSettings) {
                var borderColor_5 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? 'black' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.selectionBorderColor)) ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.selectionBorderColor : 'black';
                options.stroke = borderColor_5;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.selectionBorderThickness)) ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.selectionBorderThickness : 1;
                options.strokeWidth = thickness;
                var lineDash_5 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.selectorLineDashArray)) ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.selectorLineDashArray : [4];
                if (lineDash_5.length > 2) {
                    lineDash_5 = [lineDash_5[0], lineDash_5[1]];
                }
                options.dashArray = lineDash_5.toString();
            }
            else if (type === 'StickyNotes' && this.pdfViewer.stickyNotesSettings.annotationSelectorSettings) {
                var borderColor_6 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? 'black' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stickyNotesSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stickyNotesSettings.annotationSelectorSettings.selectionBorderColor)) ? this.pdfViewer.stickyNotesSettings.annotationSelectorSettings.selectionBorderColor : 'black';
                options.stroke = borderColor_6;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stickyNotesSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stickyNotesSettings.annotationSelectorSettings.selectionBorderThickness)) ? this.pdfViewer.stickyNotesSettings.annotationSelectorSettings.selectionBorderThickness : 1;
                options.strokeWidth = thickness;
                var lineDash_6 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [6, 3] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stickyNotesSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stickyNotesSettings.annotationSelectorSettings.selectorLineDashArray)) ? this.pdfViewer.stickyNotesSettings.annotationSelectorSettings.selectorLineDashArray : [4];
                if (lineDash_6.length > 2) {
                    lineDash_6 = [lineDash_6[0], lineDash_6[1]];
                }
                options.dashArray = lineDash_6.toString();
            }
            else if ((type === 'Stamp' || type === 'Image') && this.pdfViewer.stampSettings.annotationSelectorSettings) {
                var borderColor_7 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderColor) || this.pdfViewer.annotationSelectorSettings.selectionBorderColor === '' ? '#0000ff' : this.pdfViewer.annotationSelectorSettings.selectionBorderColor ? this.pdfViewer.annotationSelectorSettings.selectionBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.selectionBorderColor)) ? this.pdfViewer.stampSettings.annotationSelectorSettings.selectionBorderColor : '#0000ff';
                options.stroke = borderColor_7;
                var thickness = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectionBorderThickness) ? 1 : this.pdfViewer.annotationSelectorSettings.selectionBorderThickness ? this.pdfViewer.annotationSelectorSettings.selectionBorderThickness : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.selectionBorderThickness)) ? this.pdfViewer.stampSettings.annotationSelectorSettings.selectionBorderThickness : 1;
                options.strokeWidth = thickness;
                var lineDash_7 = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.selectorLineDashArray) || this.pdfViewer.annotationSelectorSettings.selectorLineDashArray.length === 0 ? [4] : this.pdfViewer.annotationSelectorSettings.selectorLineDashArray ? this.pdfViewer.annotationSelectorSettings.selectorLineDashArray : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.selectorLineDashArray)) ? this.pdfViewer.stampSettings.annotationSelectorSettings.selectorLineDashArray : [4];
                if (lineDash_7.length > 2) {
                    lineDash_7 = [lineDash_7[0], lineDash_7[1]];
                }
                options.dashArray = lineDash_7.toString();
            }
        };
        Drawing.prototype.renderCircularHandle = function (id, selector, cx, cy, canvas, visible, enableSelector, t, connected, canMask, ariaLabel, count, className, currentSelector) {
            var wrapper = selector;
            var radius = 7;
            var newPoint = { x: cx, y: cy };
            t = t || { scale: 1, tx: 0, ty: 0 };
            if (wrapper.rotateAngle !== 0 || wrapper.parentTransform !== 0) {
                var matrix = ej2_drawings_1.identityMatrix();
                ej2_drawings_1.rotateMatrix(matrix, wrapper.rotateAngle + wrapper.parentTransform, wrapper.offsetX, wrapper.offsetY);
                newPoint = ej2_drawings_6.transformPointByMatrix(matrix, newPoint);
            }
            var options = drawing_util_1.getBaseShapeAttributes(wrapper);
            var shapeType;
            if (this.pdfViewer.selectedItems.annotations.length > 0 && this.pdfViewer.selectedItems.annotations[0].measureType) {
                shapeType = this.pdfViewer.selectedItems.annotations[0].measureType;
            }
            else if (this.pdfViewer.selectedItems.formFields.length > 0) {
                shapeType = this.pdfViewer.selectedItems.formFields[0].formFieldAnnotationType;
            }
            else {
                shapeType = this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType;
            }
            this.getResizerColors(shapeType, options, currentSelector, t);
            this.getShapeSize(shapeType, options, currentSelector, t);
            options.strokeWidth = 1;
            if (count !== undefined) {
                radius = 5;
                options.id = 'segmentEnd_' + count;
            }
            options.centerX = (newPoint.x + t.tx) * t.scale;
            options.centerY = (newPoint.y + t.ty) * t.scale;
            options.angle = 0;
            options.id = id;
            options.visible = visible;
            options.class = className;
            options.opacity = 1;
            if (connected) {
                options.class += ' e-connected';
            }
            if (canMask) {
                options.visible = false;
            }
            options.x = (newPoint.x * t.scale) - (options.width / 2);
            options.y = (newPoint.y * t.scale) - (options.height / 2);
            var parentSvg = this.getParentSvg(selector, 'selector');
            if (this.getShape(shapeType, currentSelector) === 'Square') {
                this.svgRenderer.drawRectangle(canvas, options, id, undefined, true, parentSvg);
            }
            else if (this.getShape(shapeType, currentSelector) === 'Circle') {
                this.svgRenderer.drawCircle(canvas, options, 1);
            }
        };
        Drawing.prototype.getShapeSize = function (type, options, currentSelector, t) {
            if (currentSelector && typeof (currentSelector) !== 'object' && currentSelector !== '') {
                var annotationSelector = JSON.parse(currentSelector);
                options.radius = (ej2_base_1.isNullOrUndefined(annotationSelector.resizerSize) || annotationSelector.resizerSize ===
                    8 ? 8 : annotationSelector.resizerSize) / 2;
                options.width = (ej2_base_1.isNullOrUndefined(annotationSelector.resizerSize) || annotationSelector.resizerSize ===
                    8 ? 8 : annotationSelector.resizerSize) * t.scale;
                options.height = (ej2_base_1.isNullOrUndefined(annotationSelector.resizerSize) || annotationSelector.resizerSize ===
                    8 ? 8 : annotationSelector.resizerSize) * t.scale;
            }
            else if (currentSelector && currentSelector !== '') {
                options.radius = (ej2_base_1.isNullOrUndefined(currentSelector.resizerSize) || currentSelector.resizerSize ===
                    8 ? 8 : currentSelector.resizerSize) / 2;
                options.width = (ej2_base_1.isNullOrUndefined(currentSelector.resizerSize) || currentSelector.resizerSize ===
                    8 ? 8 : currentSelector.resizerSize) * t.scale;
                options.height = (ej2_base_1.isNullOrUndefined(currentSelector.resizerSize) || currentSelector.resizerSize ===
                    8 ? 8 : currentSelector.resizerSize) * t.scale;
            }
            else {
                var annotationSelector = this.pdfViewer.annotationSelectorSettings;
                options.radius = (ej2_base_1.isNullOrUndefined(annotationSelector.resizerSize) || annotationSelector.resizerSize ===
                    8 ? 8 : annotationSelector.resizerSize) / 2;
                options.width = (ej2_base_1.isNullOrUndefined(annotationSelector.resizerSize) || annotationSelector.resizerSize ===
                    8 ? 8 : annotationSelector.resizerSize) * t.scale;
                options.height = (ej2_base_1.isNullOrUndefined(annotationSelector.resizerSize) || annotationSelector.resizerSize ===
                    8 ? 8 : annotationSelector.resizerSize) * t.scale;
                var currentType = typeof (type) === 'string' ? type : type.shapeAnnotationType;
                var settingsMap = {
                    'Line': this.pdfViewer.lineSettings,
                    'LineWidthArrowHead': this.pdfViewer.arrowSettings,
                    'Rectangle': this.pdfViewer.rectangleSettings,
                    'Ellipse': this.pdfViewer.circleSettings,
                    'Distance': this.pdfViewer.distanceSettings,
                    'Polygon': this.pdfViewer.polygonSettings,
                    'Radius': this.pdfViewer.radiusSettings,
                    'Area': this.pdfViewer.areaSettings,
                    'Volume': this.pdfViewer.volumeSettings,
                    'Ink': this.pdfViewer.inkAnnotationSettings,
                    'Stamp': this.pdfViewer.stampSettings,
                    'Image': this.pdfViewer.stampSettings,
                    'FreeText': this.pdfViewer.freeTextSettings,
                    'HandWrittenSignature': this.pdfViewer.handWrittenSignatureSettings,
                    'SignatureText': this.pdfViewer.handWrittenSignatureSettings,
                    'SignatureImage': this.pdfViewer.handWrittenSignatureSettings,
                    'Perimeter': this.pdfViewer.perimeterSettings
                };
                var settings = settingsMap["" + currentType];
                if (settings && settings.annotationSelectorSettings) {
                    var resizerSize = this.pdfViewer.annotationSelectorSettings.resizerSize || 8;
                    var annotationResizerSize = settings.annotationSelectorSettings.resizerSize;
                    options.radius = (annotationResizerSize && annotationResizerSize !== 8)
                        ? annotationResizerSize / 2 : resizerSize / 2;
                    var resizerValue = (annotationResizerSize && annotationResizerSize !== 8)
                        ? annotationResizerSize * t.scale : resizerSize * t.scale;
                    options.width = resizerValue;
                    options.height = resizerValue;
                }
            }
        };
        Drawing.prototype.getShape = function (type, currentSelector) {
            var shapeType;
            {
                if (currentSelector && typeof (currentSelector) !== 'object' && currentSelector !== '') {
                    var annotationSelector = JSON.parse(currentSelector);
                    shapeType = ej2_base_1.isNullOrUndefined(annotationSelector.resizerShape) || annotationSelector.resizerShape === 'Square' ? 'Square' : annotationSelector.resizerShape;
                }
                else if (currentSelector && currentSelector !== '') {
                    shapeType = ej2_base_1.isNullOrUndefined(currentSelector.resizerShape) || currentSelector.resizerShape === 'Square' ? 'Square' : currentSelector.resizerShape;
                }
                else {
                    var annotationSelector = this.pdfViewer.annotationSelectorSettings;
                    shapeType = ej2_base_1.isNullOrUndefined(annotationSelector.resizerShape) || annotationSelector.resizerShape === 'Square' ? 'Square' : annotationSelector.resizerShape;
                    if (type === 'Line' && this.pdfViewer.lineSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.lineSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'LineWidthArrowHead' && this.pdfViewer.arrowSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Rectangle' && this.pdfViewer.rectangleSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Ellipse' && this.pdfViewer.circleSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.circleSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Polygon' && this.pdfViewer.polygonSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Distance' && this.pdfViewer.distanceSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Radius' && this.pdfViewer.radiusSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if ((type === 'Stamp' || type === 'Image') && this.pdfViewer.stampSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.stampSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'FreeText' && this.pdfViewer.freeTextSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if ((type === 'HandWrittenSignature' || type === 'SignatureText' || type === 'SignatureImage') && this.pdfViewer.handWrittenSignatureSettings && this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Perimeter' && this.pdfViewer.perimeterSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.perimeterSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.perimeterSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.perimeterSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Area' && this.pdfViewer.areaSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.areaSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.areaSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.areaSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Volume' && this.pdfViewer.volumeSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.volumeSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.volumeSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.volumeSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                    else if (type === 'Ink' && this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) {
                        shapeType = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerShape) || this.pdfViewer.annotationSelectorSettings.resizerShape !== 'Square' ? this.pdfViewer.annotationSelectorSettings.resizerShape : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerShape)) ? this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerShape : 'Square';
                    }
                }
                return shapeType;
            }
        };
        Drawing.prototype.getResizerColors = function (type, options, currentSelector, t) {
            if (currentSelector && typeof (currentSelector) !== 'object' && currentSelector !== '') {
                var annotationSelector = JSON.parse(currentSelector);
                options.stroke = ej2_base_1.isNullOrUndefined(annotationSelector.resizerBorderColor) || annotationSelector.resizerBorderColor === 'black' ? 'black' : annotationSelector.resizerBorderColor;
                options.fill = ej2_base_1.isNullOrUndefined(annotationSelector.resizerFillColor) || annotationSelector.resizerFillColor === '#FF4081' ? '#FF4081' : annotationSelector.resizerFillColor;
            }
            else if (currentSelector && currentSelector !== '') {
                options.stroke = !ej2_base_1.isNullOrUndefined(currentSelector.resizerBorderColor) ? currentSelector.resizerBorderColor : 'black';
                options.fill = !ej2_base_1.isNullOrUndefined(currentSelector.resizerFillColor) ? currentSelector.resizerFillColor : '#FF4081';
            }
            else {
                var annotationSelector = this.pdfViewer.annotationSelectorSettings;
                options.stroke = ej2_base_1.isNullOrUndefined(annotationSelector.resizerBorderColor) || annotationSelector.resizerBorderColor === 'black' ? 'black' : annotationSelector.resizerBorderColor;
                options.fill = ej2_base_1.isNullOrUndefined(annotationSelector.resizerFillColor) || annotationSelector.resizerFillColor === '#FF4081' ? '#FF4081' : annotationSelector.resizerFillColor;
                if (type === 'Line' && this.pdfViewer.lineSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.lineSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.lineSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'LineWidthArrowHead' && this.pdfViewer.arrowSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Rectangle' && this.pdfViewer.rectangleSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Ellipse' && this.pdfViewer.circleSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.circleSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.circleSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Distance' && this.pdfViewer.distanceSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Polygon' && this.pdfViewer.polygonSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Radius' && this.pdfViewer.radiusSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if ((type === 'Stamp' || type === 'Image') && this.pdfViewer.stampSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.stampSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.stampSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'FreeText' && this.pdfViewer.freeTextSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if ((type === 'HandWrittenSignature' || type === 'SignatureText' || type === 'SignatureImage') && this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Perimeter' && this.pdfViewer.perimeterSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.perimeterSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.perimeterSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.perimeterSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.perimeterSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.perimeterSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.perimeterSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Area' && this.pdfViewer.areaSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.areaSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.areaSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.areaSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.areaSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.areaSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.areaSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Volume' && this.pdfViewer.volumeSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.volumeSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.volumeSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.volumeSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.volumeSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.volumeSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.volumeSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
                else if (type === 'Ink' && this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) {
                    options.stroke = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerBorderColor) || this.pdfViewer.annotationSelectorSettings.resizerBorderColor !== 'black' ? this.pdfViewer.annotationSelectorSettings.resizerBorderColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerBorderColor)) ? this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerBorderColor : 'black';
                    options.fill = ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationSelectorSettings.resizerFillColor) || this.pdfViewer.annotationSelectorSettings.resizerFillColor !== '#FF4081' ? this.pdfViewer.annotationSelectorSettings.resizerFillColor : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) && !ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerFillColor)) ? this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerFillColor : 'FF4081';
                }
            }
        };
        Drawing.prototype.renderRotateThumb = function (wrapper, canvas, transform, selectorConstraints, canMask) {
            var newPoint;
            var top = wrapper.offsetY - wrapper.actualSize.height * wrapper.pivot.y;
            var left = wrapper.offsetX - wrapper.actualSize.width * wrapper.pivot.x;
            var pivotX = left + wrapper.pivot.x * wrapper.actualSize.width;
            var pivotY = top;
            pivotX = (pivotX + transform.tx) * transform.scale;
            pivotY = (pivotY + transform.ty) * transform.scale;
            newPoint = { x: pivotX, y: pivotY - 25 };
            if (wrapper.rotateAngle !== 0 || wrapper.parentTransform !== 0) {
                var matrix = ej2_drawings_1.identityMatrix();
                ej2_drawings_1.rotateMatrix(matrix, wrapper.rotateAngle + wrapper.parentTransform, (transform.tx + wrapper.offsetX) * transform.scale, (transform.ty + wrapper.offsetY) * transform.scale);
                newPoint = ej2_drawings_6.transformPointByMatrix(matrix, newPoint);
            }
            var options = drawing_util_1.getBaseShapeAttributes(wrapper);
            options.stroke = 'black';
            options.strokeWidth = 1;
            options.opacity = 1;
            options.fill = '#FF4081';
            options.centerX = newPoint.x;
            options.centerY = newPoint.y;
            options.radius = 4;
            options.angle = 0;
            options.visible = true;
            options.class = 'e-diagram-rotate-handle';
            options.id = 'rotateThumb';
            var checkBorder = this.shownBorder();
            if (checkBorder) {
                this.svgRenderer.drawCircle(canvas, options, ej2_drawings_1.ThumbsConstraints.Rotate, { 'aria-label': 'Thumb to rotate the selected object' });
            }
            var circleHandle = canvas.querySelector('#' + options.id);
            if (circleHandle) {
                circleHandle.setAttribute('role', 'separator');
            }
        };
        Drawing.prototype.renderResizeHandle = function (element, canvas, constraints, currentZoom, canMask, enableNode, nodeConstraints, isStamp, isSticky, isPath, isFreeText, currentSelector) {
            var left = element.offsetX - element.actualSize.width * element.pivot.x;
            var top = element.offsetY - element.actualSize.height * element.pivot.y;
            var height = element.actualSize.height;
            var width = element.actualSize.width;
            var transform = { scale: currentZoom, tx: 0, ty: 0 };
            if (isStamp) {
                this.renderPivotLine(element, canvas, transform);
                this.renderRotateThumb(element, canvas, transform);
            }
            if (isFreeText) {
                isStamp = true;
            }
            this.renderBorder(element, canvas, currentSelector, transform, enableNode, nodeConstraints, true, isSticky);
            var nodeWidth = element.actualSize.width * currentZoom;
            var nodeHeight = element.actualSize.height * currentZoom;
            var shapeType = this.pdfViewer.selectedItems.annotations.length > 0 ?
                this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType :
                this.pdfViewer.selectedItems.formFields[0].formFieldAnnotationType;
            var allowPermission = false;
            if (!(this.pdfViewer.formDesignerModule && this.pdfViewer.designerMode)) {
                var annotation = this.pdfViewer.selectedItems.annotations[0];
                var allowedInteraction = this.pdfViewer.annotationModule.updateAnnotationAllowedInteractions(annotation);
                var isLock = this.pdfViewer.annotationModule.checkIsLockSettings(annotation);
                if ((isLock || annotation.annotationSettings.isLock) && this.getAllowedInteractions(allowedInteraction)) {
                    allowPermission = true;
                }
            }
            var resizerLocation = this.getResizerLocation(shapeType, currentSelector);
            if (resizerLocation < 1 || resizerLocation > 3) {
                resizerLocation = 3;
            }
            var isNodeShape = false;
            if (this.pdfViewer.selectedItems.annotations[0] && (this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType === 'Ellipse' || this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType === 'Radius' || this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType === 'Rectangle' || this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType === 'Redaction' || this.pdfViewer.selectedItems.annotations[0].shapeAnnotationType === 'Ink')) {
                isNodeShape = true;
            }
            if (!this.pdfViewer.viewerBase.checkSignatureFormField(element.id) && !nodeConstraints && !isSticky &&
                !isPath && !allowPermission) {
                if (isStamp || (isNodeShape && (nodeWidth >= 40 && nodeHeight >= 40) &&
                    (resizerLocation === 1 || resizerLocation === 3))) {
                    this.renderCircularHandle('resizeNorthWest', element, left, top, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeNorthWest, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on top left side direction' }, undefined, 'e-pv-diagram-resize-handle e-northwest', currentSelector);
                    this.renderCircularHandle('resizeNorthEast', element, left + width, top, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeNorthEast, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on top right side direction' }, undefined, 'e-pv-diagram-resize-handle e-northeast', currentSelector);
                    this.renderCircularHandle('resizeSouthWest', element, left, top + height, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeSouthWest, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on bottom left side direction' }, undefined, 'e-pv-diagram-resize-handle e-southwest', currentSelector);
                    this.renderCircularHandle('resizeSouthEast', element, left + width, top + height, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeSouthEast, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on bottom right side direction' }, undefined, 'e-pv-diagram-resize-handle e-southeast', currentSelector);
                }
                if ((!isStamp && !isNodeShape) || (isNodeShape && (resizerLocation === 2 ||
                    resizerLocation === 3 ||
                    (!(nodeWidth >= 40 && nodeHeight >= 40) && resizerLocation === 1)))) {
                    this.renderCircularHandle('resizeNorth', element, left + width / 2, top, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeNorth, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on top side direction' }, undefined, 'e-pv-diagram-resize-handle e-north', currentSelector);
                    this.renderCircularHandle('resizeSouth', element, left + width / 2, top + height, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeSouth, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on bottom side direction' }, undefined, 'e-pv-diagram-resize-handle e-south', currentSelector);
                    this.renderCircularHandle('resizeWest', element, left, top + height / 2, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeWest, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on left side direction' }, undefined, 'e-pv-diagram-resize-handle e-west', currentSelector);
                    this.renderCircularHandle('resizeEast', element, left + width, top + height / 2, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeEast, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on right side direction' }, undefined, 'e-pv-diagram-resize-handle e-east', currentSelector);
                }
            }
            if ((shapeType === 'Textbox' || shapeType === 'Checkbox' || shapeType === 'RadioButton' || shapeType === 'SignatureField' || shapeType === 'InitialField' || shapeType === 'DropdownList' ||
                shapeType === 'ListBox' || shapeType === 'PasswordField')) {
                this.renderCircularHandle('resizeNorth', element, left + width / 2, top, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeNorth, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on top side direction' }, undefined, 'e-pv-diagram-resize-handle e-north', currentSelector);
                this.renderCircularHandle('resizeSouth', element, left + width / 2, top + height, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeSouth, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on bottom side direction' }, undefined, 'e-pv-diagram-resize-handle e-south', currentSelector);
                this.renderCircularHandle('resizeWest', element, left, top + height / 2, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeWest, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on left side direction' }, undefined, 'e-pv-diagram-resize-handle e-west', currentSelector);
                this.renderCircularHandle('resizeEast', element, left + width, top + height / 2, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ResizeEast, transform, undefined, canMask, { 'aria-label': 'Thumb to resize the selected object on right side direction' }, undefined, 'e-pv-diagram-resize-handle e-east', currentSelector);
            }
        };
        Drawing.prototype.getAllowedInteractions = function (allowedInteraction) {
            if (allowedInteraction && allowedInteraction.length > 0) {
                for (var i = 0; i < allowedInteraction.length; i++) {
                    if (allowedInteraction[0] !== 'None' && allowedInteraction[parseInt(i.toString(), 10)] === 'Resize') {
                        return false;
                    }
                }
            }
            return true;
        };
        Drawing.prototype.getResizerLocation = function (type, currentSelector) {
            var resizerLocation;
            {
                if (currentSelector && typeof (currentSelector) !== 'object' && currentSelector !== '') {
                    var annotationSelector = JSON.parse(currentSelector);
                    resizerLocation = ej2_base_1.isNullOrUndefined(annotationSelector.resizerLocation) ||
                        annotationSelector.resizerLocation === 3 ? 3 : annotationSelector.resizerLocation;
                }
                else if (currentSelector && currentSelector !== '') {
                    resizerLocation = ej2_base_1.isNullOrUndefined(currentSelector.resizerLocation) ||
                        currentSelector.resizerLocation === 3 ? 3 : currentSelector.resizerLocation;
                }
                else {
                    var annotationSelector = this.pdfViewer.annotationSelectorSettings;
                    resizerLocation = ej2_base_1.isNullOrUndefined(annotationSelector.resizerLocation) ||
                        annotationSelector.resizerLocation === 3 ? 3 : annotationSelector.resizerLocation;
                    if (type === 'Line' && this.pdfViewer.lineSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.lineSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.lineSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.lineSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'LineWidthArrowHead' && this.pdfViewer.arrowSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.arrowSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Rectangle' && this.pdfViewer.rectangleSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.rectangleSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Redaction' && this.pdfViewer.redactionSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.redactionSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.redactionSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.redactionSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.redactionSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.redactionSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Ellipse' && this.pdfViewer.circleSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.circleSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.circleSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.circleSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Polygon' && this.pdfViewer.polygonSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.polygonSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Distance') {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.distanceSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Radius' && this.pdfViewer.radiusSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.radiusSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Stamp' && this.pdfViewer.stampSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.stampSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.stampSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.stampSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'FreeText' && this.pdfViewer.freeTextSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerLocation) ||
                            this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.freeTextSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if ((type === 'HandWrittenSignature' || type === 'SignatureText' || type === 'SignatureImage') && this.pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.
                            annotationSelectorSettings.resizerLocation) || this.pdfViewer.handWrittenSignatureSettings.
                            annotationSelectorSettings.resizerLocation === 3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.
                            pdfViewer.handWrittenSignatureSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.handWrittenSignatureSettings.
                                annotationSelectorSettings.resizerLocation)) ? this.pdfViewer.
                            handWrittenSignatureSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                    else if (type === 'Ink' && this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings) {
                        resizerLocation = ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerLocation)
                            || this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerLocation ===
                                3 ? 3 : (!ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings)
                            && !ej2_base_1.isNullOrUndefined(this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerLocation))
                            ? this.pdfViewer.inkAnnotationSettings.annotationSelectorSettings.resizerLocation : 3;
                    }
                }
                return resizerLocation;
            }
        };
        Drawing.prototype.renderPivotLine = function (element, canvas, transform, selectorConstraints, canMask) {
            var wrapper = element;
            var dashArray = '2,3';
            var visible = true;
            if (canMask) {
                visible = false;
            }
            var options = drawing_util_1.getBaseShapeAttributes(wrapper, transform);
            options.fill = 'None';
            options.stroke = 'black';
            options.strokeWidth = 1;
            options.dashArray = dashArray;
            options.visible = visible;
            var scale = transform.scale;
            options.x *= scale;
            options.y *= scale;
            options.width *= scale;
            options.height *= scale;
            options.id = 'pivotLine';
            options.class = 'e-diagram-pivot-line';
            var startPoint = { x: wrapper.actualSize.width * wrapper.pivot.x * scale, y: -20 };
            var endPoint = { x: wrapper.actualSize.width * wrapper.pivot.x * scale, y: 0 };
            options.startPoint = startPoint;
            options.endPoint = endPoint;
            var checkBorder = this.shownBorder();
            if (checkBorder) {
                this.svgRenderer.drawLine(canvas, options);
            }
        };
        Drawing.prototype.renderEndPointHandle = function (selector, canvas, constraints, transform, connectedSource, connectedTarget, isSegmentEditing, currentSelector) {
            transform = transform || { tx: 0, ty: 0, scale: 1 };
            var sourcePoint = selector.sourcePoint;
            var targetPoint = selector.targetPoint;
            var wrapper = selector.wrapper;
            var i;
            var checkBorder = this.shownBorder();
            if (checkBorder) {
                for (i = 0; i < selector.vertexPoints.length; i++) {
                    var segment = selector.vertexPoints[parseInt(i.toString(), 10)];
                    this.renderCircularHandle(('segementThumb_' + (i + 1)), wrapper, segment.x, segment.y, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ConnectorSource, transform, connectedSource, null, null, i, 'e-pv-diagram-resize-handle', currentSelector);
                }
            }
            var leaderCount = 0;
            if (selector.shapeAnnotationType === 'Distance') {
                for (i = 0; i < selector.wrapper.children.length; i++) {
                    var segment = selector.wrapper.children[parseInt(i.toString(), 10)];
                    var newPoint1 = void 0;
                    var angle = ej2_drawings_1.Point.findAngle(selector.sourcePoint, selector.targetPoint);
                    if (segment.id.indexOf('leader') > -1) {
                        var center = selector.wrapper.children[0].bounds.center;
                        if (leaderCount === 0) {
                            newPoint1 = { x: selector.sourcePoint.x, y: selector.sourcePoint.y - selector.leaderHeight };
                            center = sourcePoint;
                        }
                        else {
                            newPoint1 = { x: selector.targetPoint.x, y: selector.targetPoint.y - selector.leaderHeight };
                            center = targetPoint;
                        }
                        var matrix = ej2_drawings_1.identityMatrix();
                        ej2_drawings_1.rotateMatrix(matrix, angle, center.x, center.y);
                        if (checkBorder) {
                            var rotatedPoint = ej2_drawings_6.transformPointByMatrix(matrix, { x: newPoint1.x, y: newPoint1.y });
                            this.renderCircularHandle(('leaderThumb_' + (i + 1)), wrapper, rotatedPoint.x, rotatedPoint.y, canvas, true, constraints & ej2_drawings_1.ThumbsConstraints.ConnectorSource, transform, connectedSource, null, null, i, 'e-pv-diagram-resize-handle', currentSelector);
                        }
                        leaderCount++;
                    }
                }
            }
        };
        Drawing.prototype.initSelectorWrapper = function () {
            var selectorModel = this.pdfViewer.selectedItems;
            selectorModel.init(this);
        };
        Drawing.prototype.select = function (objArray, currentSelector, multipleSelection, preventUpdate) {
            var selectorModel = this.pdfViewer.selectedItems;
            var _loop_1 = function (i) {
                var obj = this_1.pdfViewer.nameTable[objArray[parseInt(i.toString(), 10)]];
                if (obj.formFieldAnnotationType && this_1.pdfViewer.designerMode) {
                    selectorModel.formFields.push(obj);
                    this_1.initSelectorWrapper();
                    selectorModel.wrapper.children.push(obj.wrapper);
                    this_1.renderSelector(obj.pageIndex, currentSelector, obj, true);
                }
                else if (obj && !obj.formFieldAnnotationType) {
                    if (!(obj instanceof selector_1.Selector) && obj.wrapper.visible && this_1.pdfViewer.annotationModule) {
                        var annotationSettings = void 0;
                        if (obj.annotationSettings) {
                            annotationSettings = obj.annotationSettings;
                            if (!ej2_base_1.isNullOrUndefined(annotationSettings) && !ej2_base_1.isNullOrUndefined(annotationSettings.isLock)) {
                                annotationSettings.isLock = JSON.parse(annotationSettings.isLock);
                            }
                        }
                        else if (!obj.formFieldAnnotationType) {
                            annotationSettings = this_1.pdfViewer.annotationModule.findAnnotationSettings(obj, true);
                            obj.annotationSettings = annotationSettings;
                        }
                        var isLock = !obj.formFieldAnnotationType ? (annotationSettings ? annotationSettings.isLock : false) : false;
                        if (annotationSettings && annotationSettings.isLock && this_1.pdfViewer.annotationModule.checkAllowedInteractions('Select', obj)) {
                            isLock = false;
                        }
                        var isSign = obj.shapeAnnotationType === 'Path' || obj.shapeAnnotationType === 'SignatureText'
                            || obj.shapeAnnotationType === 'SignatureImage';
                        var isReadOnly_1 = false;
                        this_1.pdfViewer.formFieldCollection.filter(function (field) { return field.id === obj.id.split('_')[0]; })
                            .forEach(function (field) { return isReadOnly_1 = field.isReadonly; });
                        if (!(isReadOnly_1 && isSign)) {
                            selectorModel.annotations.push(obj);
                            var checkBorder = this_1.shownBorder();
                            if (checkBorder && !isLock) {
                                this_1.initSelectorWrapper();
                                selectorModel.wrapper.rotateAngle = selectorModel.rotateAngle = 0;
                                selectorModel.wrapper.children.push(obj.wrapper);
                                if (!preventUpdate) {
                                    this_1.renderSelector(obj.pageIndex, currentSelector, obj, true);
                                }
                            }
                        }
                    }
                }
            };
            var this_1 = this;
            for (var i = 0; i < objArray.length; i++) {
                _loop_1(i);
            }
        };
        Drawing.prototype.dragSelectedObjects = function (tx, ty, pageIndex, currentSelector, helper) {
            var obj = this.pdfViewer.selectedItems;
            this.drag(obj, tx, ty, currentSelector, helper);
            return true;
        };
        Drawing.prototype.drag = function (obj, tx, ty, currentSelector, helper) {
            if (obj instanceof selector_1.Selector) {
                if (obj.annotations.length) {
                    for (var _i = 0, _a = obj.annotations; _i < _a.length; _i++) {
                        var node = _a[_i];
                        this.drag(node, tx, ty, currentSelector, helper);
                        this.renderSelector(node.pageIndex, currentSelector, helper);
                    }
                }
                else if (obj.formFields.length) {
                    for (var _b = 0, _c = obj.formFields; _b < _c.length; _b++) {
                        var node = _c[_b];
                        this.drag(node, tx, ty, currentSelector, helper);
                        this.renderSelector(node.pageIndex, currentSelector, helper);
                    }
                }
            }
            else {
                this.dragAnnotation(obj, tx, ty);
            }
        };
        Drawing.prototype.dragAnnotation = function (obj, tx, ty) {
            var newDiff = this.moveInsideViewer(obj, tx, ty);
            obj.wrapper.offsetX += newDiff.tx;
            obj.wrapper.offsetY += newDiff.ty;
            if (drawing_util_1.isLineShapes(obj) || obj.shapeAnnotationType === 'Polygon') {
                if (obj.wrapper.children.length) {
                    var nodes = obj.wrapper.children;
                    for (var i = 0; i < nodes.length; i++) {
                        nodes[parseInt(i.toString(), 10)].offsetX += tx;
                        nodes[parseInt(i.toString(), 10)].offsetY += ty;
                    }
                }
                this.dragControlPoint(obj, tx, ty, true);
            }
            this.isDragAnnotation = true;
            this.nodePropertyChange(obj, { bounds: { x: obj.wrapper.offsetX, y: obj.wrapper.offsetY } });
            obj.wrapper.measureChildren = false;
            var canvas = this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', obj.pageIndex);
            this.pdfViewer.renderDrawing(canvas, obj.pageIndex);
            this.isDragAnnotation = false;
        };
        Drawing.prototype.dragControlPoint = function (obj, tx, ty, preventUpdate, segmentNumber) {
            var connector = this.pdfViewer.nameTable[obj.id];
            for (var i = 0; i < connector.vertexPoints.length; i++) {
                (connector.vertexPoints[parseInt(i.toString(), 10)]).x += tx;
                (connector.vertexPoints[parseInt(i.toString(), 10)]).y += ty;
            }
            if (!preventUpdate) {
                this.updateEndPoint(connector);
            }
            return true;
        };
        Drawing.prototype.updateEndPoint = function (connector) {
            this.nodePropertyChange(connector, { vertexPoints: connector.vertexPoints });
            this.renderSelector(connector.pageIndex);
        };
        Drawing.prototype.nodePropertyChange = function (actualObject, node, isNeedToRender) {
            var updateConnector = false;
            var i;
            var update;
            if (node.bounds) {
                if (node.bounds.width !== undefined) {
                    actualObject.bounds.width = actualObject.wrapper.width = node.bounds.width;
                }
                if (node.bounds.height !== undefined) {
                    actualObject.bounds.height = actualObject.wrapper.height = node.bounds.height;
                }
                if (node.bounds.x !== undefined) {
                    actualObject.bounds.x = node.bounds.x - (actualObject.bounds.width * 0.5);
                    actualObject.wrapper.offsetX = node.bounds.x;
                    update = true;
                    updateConnector = true;
                }
                if (node.bounds.y !== undefined) {
                    actualObject.bounds.y = node.bounds.y - (actualObject.bounds.height * 0.5);
                    actualObject.wrapper.offsetY = node.bounds.y;
                    update = true;
                    updateConnector = true;
                }
                if (node.leaderHeight !== undefined) {
                    actualObject.leaderHeight = node.leaderHeight;
                    this.updateConnector(actualObject, actualObject.vertexPoints);
                }
                if (actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    for (var i_1 = 0; i_1 < children.length; i_1++) {
                        if (children[parseInt(i_1.toString(), 10)].id) {
                            var names = children[parseInt(i_1.toString(), 10)].id.split('_');
                            if (names.length && (names.indexOf('perimeter') > -1 || names.indexOf('radius') > -1)) {
                                this.setNodePosition(children[parseInt(i_1.toString(), 10)], actualObject);
                            }
                            else if (names.length && (names.indexOf('srcDec') > -1)) {
                                children[parseInt(i_1.toString(), 10)].offsetX = actualObject.vertexPoints[0].x;
                                children[parseInt(i_1.toString(), 10)].offsetY = actualObject.vertexPoints[0].y;
                            }
                            else if (names.length && names.indexOf('tarDec') > -1) {
                                children[parseInt(i_1.toString(), 10)].offsetX =
                                    actualObject.vertexPoints[actualObject.vertexPoints.length - 1].x;
                                children[parseInt(i_1.toString(), 10)].offsetY =
                                    actualObject.vertexPoints[actualObject.vertexPoints.length - 1].y;
                            }
                            else if (names.length && (names.indexOf('stamp') > -1)) {
                                var ratio = 0;
                                var heightRatio = 2;
                                if (actualObject.wrapper.width !== undefined && actualObject.wrapper.height !== undefined) {
                                    ratio = 20;
                                    heightRatio = 2.9;
                                }
                                if (actualObject.isDynamicStamp) {
                                    var element = children[1];
                                    var iconElement = children[parseInt(i_1.toString(), 10)];
                                    var annotationSettings = this.pdfViewer.stampSettings ?
                                        this.pdfViewer.stampSettings : this.pdfViewer.annotationSettings;
                                    if (annotationSettings && (annotationSettings.maxHeight ||
                                        annotationSettings.maxWidth) && (actualObject.bounds.height > 60)) {
                                        if (ratio !== 0) {
                                            element.style.fontSize = (actualObject.bounds.width / ratio);
                                            iconElement.style.fontSize = (actualObject.bounds.width / ratio);
                                        }
                                        else {
                                            element.style.fontSize = (actualObject.wrapper.bounds.width / 20);
                                            iconElement.style.fontSize = (actualObject.wrapper.bounds.width / 20);
                                        }
                                    }
                                    else {
                                        var targetWidth = void 0;
                                        var targetHeight = void 0;
                                        if (actualObject.rotateAngle === 0 || (actualObject.rotateAngle > 0 && ratio !== 0)) {
                                            if (ratio !== 0) {
                                                targetWidth = actualObject.bounds.width;
                                                targetHeight = actualObject.bounds.height;
                                            }
                                            else {
                                                targetWidth = actualObject.wrapper.bounds.width;
                                                targetHeight = actualObject.wrapper.bounds.height;
                                            }
                                            var iconWidth = targetWidth;
                                            if (iconElement.content === 'REVISED' || iconElement.content === 'REVIEWED' || iconElement.content === 'RECEIVED' || iconElement.content === 'APPROVED') {
                                                iconWidth = iconWidth / 2;
                                            }
                                            else if (iconElement.content === 'CONFIDENTIAL' || iconElement.content === 'NOT APPROVED') {
                                                iconWidth = iconWidth * (3 / 4);
                                            }
                                            var elementPpadding = targetWidth * 0.02;
                                            var elementInnerWidth = Math.max(0, targetWidth - 2 * elementPpadding);
                                            var iconPadding = iconWidth * 0.02;
                                            var iconInnerWidth = Math.max(0, iconWidth - 2 * iconPadding);
                                            element.style.fontSize = this.
                                                fontSizeCalculation(actualObject, element, elementInnerWidth, element.content);
                                            iconElement.style.fontSize = this.
                                                fontSizeCalculation(actualObject, iconElement, iconInnerWidth, iconElement.content);
                                            var metrics = this.measureTextMetrics(actualObject, iconElement.content, iconElement.style.fontSize, iconElement.style.fontFamily);
                                            var topOffset = (targetHeight * 0.75 - metrics.height) / 4;
                                            iconElement.margin.top = Math.max(0, topOffset);
                                            if (iconElement.content === 'CONFIDENTIAL' || iconElement.content === 'NOT APPROVED') {
                                                iconElement.margin.left = (targetWidth - (metrics.width * (4 / 3))) / 2;
                                            }
                                            else {
                                                iconElement.margin.left = (targetWidth - (metrics.width * 2)) / 2;
                                            }
                                            iconElement.desiredSize.width = metrics.width;
                                            iconElement.desiredSize.height = metrics.height;
                                            var elementMetrics = this.measureTextMetrics(actualObject, element.content, element.style.fontSize, element.style.fontFamily);
                                            var bottomOffset = (targetHeight * 0.25 - elementMetrics.height) / 8;
                                            element.margin.bottom = Math.max(0, bottomOffset);
                                            if (element.margin.bottom < 1) {
                                                element.margin.bottom = 4;
                                            }
                                            element.margin.left = (targetWidth - elementMetrics.width) / 2;
                                            element.desiredSize.height = elementMetrics.height;
                                        }
                                    }
                                }
                                else {
                                    var element = children[parseInt(i_1.toString(), 10)];
                                    var annotationSettings = this.pdfViewer.stampSettings ?
                                        this.pdfViewer.stampSettings : this.pdfViewer.annotationSettings;
                                    if (annotationSettings && (annotationSettings.maxHeight ||
                                        annotationSettings.maxWidth) && (actualObject.bounds.height > 60)) {
                                        if (ratio !== 0) {
                                            element.style.fontSize = (actualObject.bounds.width / ratio);
                                        }
                                        else {
                                            element.style.fontSize = (actualObject.wrapper.bounds.width / 20);
                                        }
                                    }
                                    else if (ej2_base_1.isNullOrUndefined(element.content)) {
                                        children[parseInt(i_1.toString(), 10)].width = actualObject.bounds.width;
                                        children[parseInt(i_1.toString(), 10)].height = actualObject.bounds.height;
                                        children[parseInt(i_1.toString(), 10)].offsetX = actualObject.wrapper.offsetX;
                                        children[parseInt(i_1.toString(), 10)].offsetY = actualObject.wrapper.offsetX;
                                        children[parseInt(i_1.toString(), 10)].isDirt = true;
                                    }
                                    else {
                                        var targetWidth = void 0;
                                        var targetHeight = void 0;
                                        if (actualObject.rotateAngle === 0 || (actualObject.rotateAngle > 0 && ratio !== 0)) {
                                            if (ratio !== 0) {
                                                targetWidth = actualObject.bounds.width;
                                                targetHeight = actualObject.bounds.height;
                                            }
                                            else {
                                                targetWidth = actualObject.wrapper.bounds.width;
                                                targetHeight = actualObject.wrapper.bounds.height;
                                            }
                                            var paddingX = targetWidth * 0.04;
                                            if (element.content === 'DRAFT') {
                                                paddingX = targetWidth * 0.06;
                                            }
                                            var innerWidth_2 = Math.max(0, targetWidth - 2 * paddingX);
                                            element.style.fontSize = this.
                                                fontSizeCalculation(actualObject, element, innerWidth_2, element.content);
                                            var metrics = this.measureTextMetrics(actualObject, element.content, element.style.fontSize, element.style.fontFamily);
                                            var topOffset = (targetHeight - metrics.height) / 2;
                                            element.margin.top = Math.max(0, topOffset);
                                            var leftOffset = (targetWidth - metrics.width) / 2;
                                            element.margin.left = Math.max(0, leftOffset);
                                            element.desiredSize.width = metrics.width;
                                            element.desiredSize.height = metrics.height;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (node.sourceDecoraterShapes !== undefined) {
                actualObject.sourceDecoraterShapes = node.sourceDecoraterShapes;
                this.updateConnector(actualObject, actualObject.vertexPoints);
            }
            if (node.isReadonly !== undefined && actualObject.shapeAnnotationType === 'FreeText') {
                actualObject.isReadonly = node.isReadonly;
            }
            if (node.annotationSelectorSettings !== undefined) {
                actualObject.annotationSelectorSettings = node.annotationSelectorSettings;
            }
            if (node.taregetDecoraterShapes !== undefined) {
                actualObject.taregetDecoraterShapes = node.taregetDecoraterShapes;
                update = true;
                this.updateConnector(actualObject, actualObject.vertexPoints);
            }
            if (node.fillColor !== undefined) {
                actualObject.fillColor = node.fillColor;
                actualObject.wrapper.children[0].style.fill = node.fillColor;
                if ((actualObject.enableShapeLabel || actualObject.measureType) && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_2 = 0; i_2 < children.length; i_2++) {
                        if (children[parseInt(i_2.toString(), 10)].textNodes) {
                            if (actualObject.enableShapeLabel) {
                                actualObject.labelFillColor = node.fillColor;
                                children[parseInt(i_2.toString(), 10)].style.fill = node.fillColor;
                            }
                            if (actualObject.measureType) {
                                children[parseInt(i_2.toString(), 10)].style.fill = node.fillColor;
                            }
                        }
                    }
                }
                update = true;
            }
            if (node.markerFillColor !== undefined) {
                actualObject.markerFillColor = node.markerFillColor;
                var fillColor = drawing_util_1.updateColorWithOpacity(node.markerFillColor, actualObject.markerOpacity);
                actualObject.wrapper.children[0].style.fill = fillColor;
            }
            if (node.markerBorderColor !== undefined) {
                actualObject.markerBorderColor = node.markerBorderColor;
                actualObject.wrapper.children[0].style.strokeColor = actualObject.markerBorderColor;
            }
            if (node.markerOpacity !== undefined) {
                actualObject.markerOpacity = node.markerOpacity;
                var fillColor = drawing_util_1.updateColorWithOpacity(actualObject.markerFillColor, actualObject.markerOpacity);
                actualObject.wrapper.children[0].style.fill = fillColor;
            }
            if (node.overlayText !== undefined) {
                actualObject.overlayText = node.overlayText;
            }
            if (actualObject.enableShapeLabel && node.labelFillColor !== undefined) {
                if (actualObject.enableShapeLabel && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_3 = 0; i_3 < children.length; i_3++) {
                        if (children[parseInt(i_3.toString(), 10)].textNodes) {
                            actualObject.labelFillColor = node.labelFillColor;
                            children[parseInt(i_3.toString(), 10)].style.fill = node.labelFillColor;
                        }
                    }
                }
            }
            if (node.opacity !== undefined) {
                if (actualObject.shapeAnnotationType === 'Stamp' || actualObject.shapeAnnotationType === 'FreeText') {
                    actualObject.wrapper.children[1].style.opacity = node.opacity;
                    if (actualObject.wrapper.children[2]) {
                        actualObject.wrapper.children[2].style.opacity = node.opacity;
                    }
                }
                else {
                    if (actualObject.shapeAnnotationType === 'StickyNotes') {
                        this.pdfViewer.nameTable[actualObject.annotName].wrapper.children[0].style.opacity = node.opacity;
                    }
                }
                actualObject.opacity = node.opacity;
                actualObject.wrapper.children[0].style.opacity = node.opacity;
                if (actualObject.enableShapeLabel && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_4 = 0; i_4 < children.length; i_4++) {
                        if (children[parseInt(i_4.toString(), 10)].textNodes) {
                            children[parseInt(i_4.toString(), 10)].style.opacity = node.labelOpacity;
                        }
                    }
                }
                update = true;
                updateConnector = true;
            }
            if (actualObject.enableShapeLabel && node.labelOpacity !== undefined) {
                if (actualObject.enableShapeLabel && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_5 = 0; i_5 < children.length; i_5++) {
                        if (children[parseInt(i_5.toString(), 10)].textNodes) {
                            children[parseInt(i_5.toString(), 10)].style.opacity = node.labelOpacity;
                        }
                    }
                }
            }
            if (node.rotateAngle !== undefined) {
                actualObject.rotateAngle = node.rotateAngle;
                actualObject.wrapper.rotateAngle = node.rotateAngle;
                update = true;
                updateConnector = true;
            }
            if (node.strokeColor !== undefined) {
                actualObject.strokeColor = node.strokeColor;
                actualObject.wrapper.children[0].style.strokeColor = node.strokeColor;
                update = true;
                if (actualObject.shapeAnnotationType === 'Radius' && actualObject.wrapper.children[1]) {
                    actualObject.wrapper.children[1].style.strokeColor = node.strokeColor;
                }
                updateConnector = true;
            }
            if (node.fontColor !== undefined) {
                actualObject.fontColor = node.fontColor;
                if (actualObject.shapeAnnotationType === 'FreeText' && actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    children[1].style.color = node.fontColor;
                    if (actualObject.textAlign === 'Justify') {
                        children[1].horizontalAlignment = 'Center';
                    }
                    else {
                        children[1].horizontalAlignment = 'Auto';
                    }
                }
                if (actualObject.enableShapeLabel && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_6 = 0; i_6 < children.length; i_6++) {
                        if (children[parseInt(i_6.toString(), 10)].textNodes) {
                            children[parseInt(i_6.toString(), 10)].style.color = node.fontColor;
                        }
                    }
                }
                update = true;
                updateConnector = true;
            }
            if (node.fontFamily !== undefined) {
                actualObject.fontFamily = node.fontFamily;
                if (actualObject.shapeAnnotationType === 'FreeText' && actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    children[1].style.fontFamily = node.fontFamily;
                }
                if (actualObject.enableShapeLabel && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_7 = 0; i_7 < children.length; i_7++) {
                        if (children[parseInt(i_7.toString(), 10)].textNodes) {
                            children[parseInt(i_7.toString(), 10)].style.fontFamily = node.fontFamily;
                        }
                    }
                }
                update = true;
                updateConnector = true;
            }
            if (node.fontSize !== undefined) {
                if ((actualObject.shapeAnnotationType === 'FreeText' || actualObject.shapeAnnotationType === 'SignatureText') && actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    children[1].style.fontSize = node.fontSize;
                    if (actualObject.shapeAnnotationType === 'SignatureText') {
                        actualObject.wrapper.children[1].bounds.width = actualObject.bounds.width;
                        actualObject.wrapper.children[1].desiredSize.width = actualObject.bounds.width;
                        actualObject.wrapper.children[1].actualSize.width = actualObject.bounds.width;
                        children[1].horizontalAlignment = 'Center';
                        children[1].verticalAlignment = 'Center';
                        children[1].setOffsetWithRespectToBounds(0, 0, 'Absolute');
                    }
                }
                if (actualObject.enableShapeLabel && actualObject.wrapper && actualObject.wrapper.children) {
                    var children = actualObject.wrapper.children;
                    for (var i_8 = 0; i_8 < children.length; i_8++) {
                        if (children[parseInt(i_8.toString(), 10)].textNodes) {
                            children[parseInt(i_8.toString(), 10)].style.fontSize = node.fontSize;
                        }
                    }
                }
                if (this.pdfViewer.enableToolbar && this.pdfViewer.toolbarModule) {
                    this.pdfViewer.toolbarModule.annotationToolbarModule.updateFontSizeInIcon(node.fontSize);
                }
                else if (this.pdfViewer.annotationModule && actualObject.fontSize !== node.fontSize) {
                    this.pdfViewer.annotationModule.handleFontSizeUpdate(node.fontSize);
                }
                update = true;
                updateConnector = true;
            }
            if (node.font !== undefined) {
                if (actualObject.shapeAnnotationType === 'FreeText' && actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    if (node.font.isBold !== undefined) {
                        children[1].style.bold = node.font.isBold;
                        actualObject.font.isBold = node.font.isBold;
                    }
                    if (node.font.isItalic !== undefined) {
                        children[1].style.italic = node.font.isItalic;
                        actualObject.font.isItalic = node.font.isItalic;
                    }
                    if (node.font.isUnderline !== undefined) {
                        if (node.font.isUnderline === true) {
                            if (actualObject.font.isStrikeout) {
                                children[1].style.textDecoration = 'Underline LineThrough';
                            }
                            else {
                                children[1].style.textDecoration = 'Underline';
                            }
                        }
                        else {
                            if (!node.font.isStrikeout) {
                                if (children[1].style.textDecoration === 'Underline LineThrough') {
                                    children[1].style.textDecoration = 'LineThrough';
                                }
                                else {
                                    children[1].style.textDecoration = 'None';
                                }
                            }
                        }
                        actualObject.font.isUnderline = node.font.isUnderline;
                    }
                    if (node.font.isStrikeout !== undefined) {
                        if (node.font.isStrikeout === true) {
                            if (actualObject.font.isUnderline) {
                                children[1].style.textDecoration = 'Underline LineThrough';
                            }
                            else {
                                children[1].style.textDecoration = 'LineThrough';
                            }
                        }
                        else {
                            if (!node.font.isUnderline) {
                                if (children[1].style.textDecoration === 'Underline LineThrough') {
                                    children[1].style.textDecoration = 'Underline';
                                }
                                else {
                                    children[1].style.textDecoration = 'None';
                                }
                            }
                        }
                        actualObject.font.isStrikeout = node.font.isStrikeout;
                    }
                    if (!ej2_base_1.isNullOrUndefined(node.font.isStrikeout) && !ej2_base_1.isNullOrUndefined(node.font.isUnderline)) {
                        if (node.font.isStrikeout && node.font.isUnderline) {
                            children[1].style.textDecoration = 'Underline LineThrough';
                        }
                        else if (node.font.isStrikeout) {
                            children[1].style.textDecoration = 'LineThrough';
                        }
                        else if (node.font.isUnderline) {
                            children[1].style.textDecoration = 'Underline';
                        }
                    }
                }
                update = true;
                updateConnector = true;
            }
            if (node.textAlign !== undefined) {
                var currentAnnotation = (!ej2_base_1.isNullOrUndefined(this.pdfViewer.selectedItems.annotations) && this.pdfViewer.selectedItems.annotations.length > 0) ?
                    this.pdfViewer.selectedItems.annotations[0] : actualObject;
                var clonedObject = drawing_util_1.cloneObject(currentAnnotation);
                var redoClonedObject = drawing_util_1.cloneObject(currentAnnotation);
                if (actualObject.textAlign !== node.textAlign) {
                    actualObject.textAlign = node.textAlign;
                    redoClonedObject.textAlign = node.textAlign;
                    if (actualObject.shapeAnnotationType === 'FreeText' && actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                        var children = actualObject.wrapper.children;
                        children[1].style.textAlign = node.textAlign;
                        if (children[1].childNodes.length >= 1) {
                            if (actualObject.textAlign === 'Justify') {
                                children[1].horizontalAlignment = 'Left';
                                children[1].setOffsetWithRespectToBounds(0, 0, null);
                            }
                            else if (actualObject.textAlign === 'Right') {
                                children[1].horizontalAlignment = 'Right';
                                children[1].setOffsetWithRespectToBounds(1, 0, null);
                            }
                            else if (actualObject.textAlign === 'Left') {
                                children[1].horizontalAlignment = 'Left';
                                children[1].setOffsetWithRespectToBounds(0, 0, null);
                            }
                            else if (actualObject.textAlign === 'Center') {
                                children[1].horizontalAlignment = 'Center';
                                children[1].setOffsetWithRespectToBounds(0.51, 0, null);
                            }
                        }
                        else {
                            children[1].horizontalAlignment = 'Auto';
                        }
                        if (!this.pdfViewer.annotation.isUndoRedoAction) {
                            this.pdfViewer.annotation.addAction(this.pdfViewer.viewerBase.getActivePage(false), null, currentAnnotation, 'textAlign', '', clonedObject, redoClonedObject);
                        }
                    }
                    update = true;
                    updateConnector = true;
                }
            }
            if (node.thickness !== undefined) {
                actualObject.thickness = node.thickness;
                actualObject.wrapper.children[0].style.strokeWidth = node.thickness;
                if (actualObject.wrapper.children[1] && actualObject.wrapper.children[0].style.strokeColor !== '#ffffff00'
                    && actualObject.wrapper.children[0].style.strokeColor !== 'transparent') {
                    actualObject.wrapper.children[1].style.strokeWidth = node.thickness;
                }
                if (actualObject.shapeAnnotationType === 'Line' || actualObject.shapeAnnotationType === 'LineWidthArrowHead') {
                    for (var i_9 = 0; i_9 < actualObject.wrapper.children.length; i_9++) {
                        var child = actualObject.wrapper.children[parseInt(i_9.toString(), 10)];
                        if (child.id.includes('srcDec') || child.id.includes('tarDec')) {
                            child.width = 12 * node.thickness;
                            child.height = 12 * node.thickness;
                        }
                    }
                }
                if (actualObject.shapeAnnotationType === 'Radius' && actualObject.wrapper.children[1]) {
                    actualObject.wrapper.children[1].style.strokeWidth = node.thickness;
                }
                update = true;
                updateConnector = true;
            }
            if (node.borderDashArray !== undefined) {
                actualObject.borderDashArray = node.borderDashArray;
                actualObject.wrapper.children[0].style.strokeDashArray = node.borderDashArray;
            }
            if (node.borderStyle !== undefined) {
                actualObject.borderStyle = node.borderStyle;
            }
            if (node.author !== undefined) {
                actualObject.author = node.author;
            }
            if (node.modifiedDate !== undefined) {
                actualObject.modifiedDate = node.modifiedDate;
            }
            if (node.subject !== undefined) {
                actualObject.subject = node.subject;
            }
            if (node.vertexPoints !== undefined) {
                actualObject.vertexPoints = node.vertexPoints;
                this.pdfViewer.nameTable[actualObject.id].vertexPoints = node.vertexPoints;
                this.updateConnector(actualObject, node.vertexPoints);
            }
            if (node.leaderHeight !== undefined && actualObject.shapeAnnotationType !== 'Polygon') {
                actualObject.leaderHeight = node.leaderHeight;
                this.updateConnector(actualObject, actualObject.vertexPoints);
            }
            if (node.notes !== undefined) {
                actualObject.notes = node.notes;
            }
            if (node.annotName !== undefined) {
                actualObject.annotName = node.annotName;
            }
            if (actualObject.shapeAnnotationType === 'Distance') {
                for (i = 0; i < actualObject.wrapper.children.length; i++) {
                    var segment = actualObject.wrapper.children[parseInt(i.toString(), 10)];
                    var points = connector_util_1.getConnectorPoints(actualObject);
                    if (segment.id.indexOf('leader1') > -1) {
                        this.setLineDistance(actualObject, points, segment, false);
                    }
                    if (segment.id.indexOf('leader2') > -1) {
                        this.setLineDistance(actualObject, points, segment, true);
                    }
                }
                this.updateConnector(actualObject, actualObject.vertexPoints);
            }
            if (actualObject.shapeAnnotationType === 'Polygon' && node.vertexPoints) {
                actualObject.data = connector_util_1.getPolygonPath(actualObject.vertexPoints);
                var path = actualObject.wrapper.children[0];
                path.data = actualObject.data;
                path.canMeasurePath = true;
            }
            if (drawing_util_1.isLineShapes(actualObject)) {
                for (var i_10 = 0; i_10 < actualObject.wrapper.children.length; i_10++) {
                    var childElement = actualObject.wrapper.children[parseInt(i_10.toString(), 10)];
                    if (!childElement.textNodes) {
                        drawing_util_1.setElementStype(actualObject, actualObject.wrapper.children[parseInt(i_10.toString(), 10)]);
                    }
                    if (actualObject.enableShapeLabel === true) {
                        if (actualObject.wrapper.children[parseInt(i_10.toString(), 10)] instanceof ej2_drawings_6.TextElement) {
                            actualObject.wrapper.children[parseInt(i_10.toString(), 10)].style.fill = actualObject.labelFillColor;
                        }
                        if ((actualObject.wrapper.children[parseInt(i_10.toString(), 10)] instanceof ej2_drawings_3.PathElement && actualObject.measureType === 'Perimeter')) {
                            actualObject.wrapper.children[parseInt(i_10.toString(), 10)].style.fill = 'transparent';
                        }
                    }
                    else {
                        if ((actualObject.wrapper.children[parseInt(i_10.toString(), 10)] instanceof ej2_drawings_3.PathElement && actualObject.measureType === 'Perimeter') || actualObject.wrapper.children[parseInt(i_10.toString(), 10)] instanceof ej2_drawings_6.TextElement) {
                            actualObject.wrapper.children[parseInt(i_10.toString(), 10)].style.fill = 'transparent';
                        }
                    }
                }
            }
            if (actualObject && (actualObject.shapeAnnotationType === 'FreeText' || actualObject.enableShapeLabel === true)) {
                if (actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    for (var i_11 = 0; i_11 < children.length; i_11++) {
                        if (children[parseInt(i_11.toString(), 10)].textNodes) {
                            if (actualObject.shapeAnnotationType === 'FreeText') {
                                if (node.dynamicText) {
                                    children[parseInt(i_11.toString(), 10)].content = node.dynamicText;
                                    actualObject.dynamicText = node.dynamicText;
                                }
                                else {
                                    children[parseInt(i_11.toString(), 10)].content = actualObject.dynamicText;
                                }
                                children[parseInt(i_11.toString(), 10)].width = actualObject.bounds.width;
                            }
                            else if (actualObject.enableShapeLabel === true && actualObject.measureType) {
                                if (node.labelContent) {
                                    children[parseInt(i_11.toString(), 10)].content = node.labelContent;
                                    actualObject.labelContent = node.labelContent;
                                }
                                else {
                                    children[parseInt(i_11.toString(), 10)].content = actualObject.labelContent;
                                }
                                actualObject.notes = children[parseInt(i_11.toString(), 10)].content;
                            }
                            else if (actualObject.enableShapeLabel === true) {
                                if (node.labelContent) {
                                    children[parseInt(i_11.toString(), 10)].content = node.labelContent;
                                    actualObject.labelContent = node.labelContent;
                                }
                                else {
                                    children[parseInt(i_11.toString(), 10)].content = actualObject.labelContent;
                                }
                                actualObject.notes = children[parseInt(i_11.toString(), 10)].content;
                            }
                            children[parseInt(i_11.toString(), 10)].isDirt = true;
                        }
                        else if (actualObject.shapeAnnotationType === 'FreeText') {
                            if (actualObject.dynamicText === '' && !this.isDragAnnotation) {
                                children[parseInt(i_11.toString(), 10)].style.fill = 'transparent';
                                children[parseInt(i_11.toString(), 10)].style.color = 'transparent';
                                children[parseInt(i_11.toString(), 10)].style.strokeColor = 'transparent';
                            }
                        }
                    }
                }
            }
            if (actualObject && actualObject.shapeAnnotationType === 'SignatureText' && actualObject.wrapper) {
                if (actualObject.wrapper.children && actualObject.wrapper.children.length > 1) {
                    actualObject.wrapper.children[1].isDirt = true;
                }
            }
            if (actualObject.wrapper.children[1] instanceof ej2_drawings_6.TextElement) {
                actualObject.wrapper.children[1].isEJ2 = true;
                if (actualObject.shapeAnnotationType === 'FreeText') {
                    actualObject.wrapper.children[1].isFreeText = true;
                }
            }
            if (actualObject && actualObject.shapeAnnotationType === 'FreeText' && this.pdfViewer.annotationModule.stickyNotesAnnotationModule.textFromCommentPanel) {
                actualObject.wrapper.width = undefined;
                actualObject.wrapper.height = undefined;
                actualObject.wrapper.measure(new ej2_drawings_6.Size(actualObject.bounds.width, actualObject.bounds.height));
                this.pdfViewer.annotationModule.stickyNotesAnnotationModule.textFromCommentPanel = false;
            }
            else {
                actualObject.wrapper.measure(new ej2_drawings_6.Size(actualObject.wrapper.bounds.width, actualObject.wrapper.bounds.height));
            }
            actualObject.wrapper.arrange(actualObject.wrapper.desiredSize);
            if (actualObject && actualObject.formFieldAnnotationType) {
                if (actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children[0];
                    children.actualSize.width = actualObject.wrapper.desiredSize.width;
                    children.actualSize.height = actualObject.wrapper.desiredSize.height;
                }
            }
            if (actualObject && actualObject.shapeAnnotationType === 'FreeText' && actualObject.subject === 'Text Box') {
                if (actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    if (children[1].childNodes.length >= 1) {
                        if (actualObject.textAlign === 'Justify') {
                            children[1].horizontalAlignment = 'Left';
                            children[1].setOffsetWithRespectToBounds(0, 0, null);
                        }
                        else if (actualObject.textAlign === 'Right') {
                            children[1].horizontalAlignment = 'Right';
                            children[1].setOffsetWithRespectToBounds(1, 0, null);
                        }
                        else if (actualObject.textAlign === 'Left') {
                            children[1].horizontalAlignment = 'Left';
                            children[1].setOffsetWithRespectToBounds(0, 0, null);
                        }
                        else if (actualObject.textAlign === 'Center') {
                            children[1].horizontalAlignment = 'Center';
                            children[1].setOffsetWithRespectToBounds(0.51, 0, null);
                        }
                    }
                    else {
                        children[1].horizontalAlignment = 'Auto';
                    }
                    for (var i_12 = 0; i_12 < children.length; i_12++) {
                        if (children[i_12].textNodes && children[i_12].textNodes.length > 0) {
                            children[i_12].isDirt = true;
                            var childNodeHeight = children[i_12].textNodes.length * children[i_12].textNodes[0].dy;
                            var heightDiff = actualObject.bounds.height - childNodeHeight;
                            if (heightDiff > 0 && heightDiff < children[i_12].textNodes[0].dy) {
                                childNodeHeight = childNodeHeight + children[i_12].textNodes[0].dy;
                            }
                            if (childNodeHeight > actualObject.bounds.height) {
                                var contString = '';
                                for (var index = 0; index < children[i_12].textNodes.length; index++) {
                                    var childHeight = children[i_12].textNodes[0].dy * (index + 1);
                                    contString = contString + children[i_12].textNodes[index].text;
                                }
                                if (heightDiff < 0) {
                                    children[i_12].content = contString;
                                }
                            }
                        }
                        children[i_12].width = actualObject.bounds.width;
                    }
                }
                actualObject.wrapper.measure(new ej2_drawings_6.Size(actualObject.bounds.width, actualObject.bounds.height));
                actualObject.wrapper.arrange(actualObject.wrapper.desiredSize);
            }
            if (isNeedToRender || ej2_base_1.isNullOrUndefined(isNeedToRender)) {
                this.pdfViewer.renderDrawing(undefined, actualObject.pageIndex);
            }
            if (actualObject && actualObject.shapeAnnotationType === 'FreeText') {
                if (actualObject.wrapper && actualObject.wrapper.children && actualObject.wrapper.children.length) {
                    var children = actualObject.wrapper.children;
                    if (children[1].childNodes.length >= 1 && actualObject.textAlign === 'Justify') {
                        children[1].horizontalAlignment = 'Left';
                        children[1].setOffsetWithRespectToBounds(0, 0, null);
                    }
                }
            }
        };
        Drawing.prototype.measureTextMetrics = function (actualObject, text, fontSize, fontFamily) {
            var canvas = this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', actualObject.pageIndex);
            if (ej2_base_1.isNullOrUndefined(canvas)) {
                canvas = document.createElement('canvas');
            }
            var ctx = canvas.getContext('2d');
            ctx.font = 'bold' + " " + fontSize + "px " + fontFamily;
            var metrics = ctx.measureText(text);
            var width = metrics.width;
            var ascent = (metrics.actualBoundingBoxAscent !== null && metrics.actualBoundingBoxAscent !== undefined)
                ? metrics.actualBoundingBoxAscent
                : fontSize * 0.8;
            var descent = (metrics.actualBoundingBoxDescent !== null && metrics.actualBoundingBoxDescent !== undefined)
                ? metrics.actualBoundingBoxDescent
                : fontSize * 0.2;
            var height = ascent + descent;
            canvas = null;
            return { width: width, height: height, ascent: ascent, descent: descent };
        };
        Drawing.prototype.fontSizeCalculation = function (actualObject, element, boundsWidth, text) {
            var canvas = this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', actualObject.pageIndex);
            if (ej2_base_1.isNullOrUndefined(canvas)) {
                canvas = document.createElement('canvas');
            }
            var context = canvas.getContext('2d');
            var textwidth = 0;
            var newsize = 0;
            var fontStyle = '';
            if (element.style.italic && element.style.bold) {
                fontStyle = 'bold italic ';
            }
            else if (element.style.bold) {
                fontStyle = 'bold ';
            }
            else if (element.style.italic) {
                fontStyle = 'italic ';
            }
            while (boundsWidth > textwidth) {
                context.font = fontStyle + newsize + 'px ' + element.style.fontFamily;
                textwidth = context.measureText(text).width;
                newsize += 0.1;
            }
            newsize -= 0.1;
            canvas = null;
            return newsize;
        };
        Drawing.prototype.setLineDistance = function (actualObject, points, segment, leader) {
            var node1;
            if (leader) {
                node1 = connector_util_1.initLeader(actualObject, points[1], points[0], leader);
            }
            else {
                node1 = connector_util_1.initLeader(actualObject, points[0], points[1], leader);
            }
            segment.data = node1.data;
            segment.offsetX = node1.offsetX;
            segment.offsetY = node1.offsetY;
            segment.rotateAngle = node1.rotateAngle;
            segment.width = node1.width;
            segment.height = node1.height;
            segment.pivot = node1.pivot;
            segment.canMeasurePath = true;
            segment.isDirt = true;
        };
        Drawing.prototype.scaleSelectedItems = function (sx, sy, pivot) {
            var obj = this.pdfViewer.selectedItems;
            return this.scale(obj, sx, sy, pivot);
        };
        Drawing.prototype.scale = function (obj, sx, sy, pivot) {
            var checkBoundaryConstraints = true;
            if (obj instanceof selector_1.Selector) {
                if (obj.annotations && obj.annotations.length) {
                    for (var _i = 0, _a = obj.annotations; _i < _a.length; _i++) {
                        var node = _a[_i];
                        checkBoundaryConstraints = this.scaleAnnotation(node, sx, sy, pivot, obj);
                    }
                }
                else if (obj.formFields && obj.formFields.length) {
                    for (var _b = 0, _c = obj.formFields; _b < _c.length; _b++) {
                        var node = _c[_b];
                        checkBoundaryConstraints = this.scaleAnnotation(node, sx, sy, pivot, obj);
                    }
                }
            }
            else {
                checkBoundaryConstraints = this.scaleAnnotation(obj, sx, sy, pivot, undefined);
            }
            return checkBoundaryConstraints;
        };
        Drawing.prototype.scaleObject = function (sw, sh, pivot, obj, element, refObject) {
            sw = sw < 0 ? 1 : sw;
            sh = sh < 0 ? 1 : sh;
            if (sw !== 1 || sh !== 1) {
                var width = void 0;
                var height = void 0;
                if (!drawing_util_1.isLineShapes(obj)) {
                    var node = obj;
                    var isResize = void 0;
                    var bound = void 0;
                    width = node.wrapper.actualSize.width * sw;
                    height = node.wrapper.actualSize.height * sh;
                    if (isResize) {
                        width = Math.max(width, (bound.right - node.wrapper.bounds.x));
                        height = Math.max(height, (bound.bottom - node.wrapper.bounds.y));
                    }
                    sw = width / node.wrapper.actualSize.width;
                    sh = height / node.wrapper.actualSize.height;
                }
                var matrix = ej2_drawings_1.identityMatrix();
                if (!refObject) {
                    refObject = obj;
                }
                var refWrapper = refObject.wrapper;
                ej2_drawings_1.rotateMatrix(matrix, -refWrapper.rotateAngle, pivot.x, pivot.y);
                ej2_drawings_1.scaleMatrix(matrix, sw, sh, pivot.x, pivot.y);
                ej2_drawings_1.rotateMatrix(matrix, refWrapper.rotateAngle, pivot.x, pivot.y);
                if (!drawing_util_1.isLineShapes(obj)) {
                    var node = obj;
                    var newPosition = ej2_drawings_6.transformPointByMatrix(matrix, { x: node.wrapper.offsetX, y: node.wrapper.offsetY });
                    if (width > 0) {
                        node.wrapper.width = width;
                        node.wrapper.offsetX = newPosition.x;
                    }
                    if (height > 0) {
                        node.wrapper.height = height;
                        node.wrapper.offsetY = newPosition.y;
                    }
                    this.nodePropertyChange(obj, {
                        bounds: { width: node.wrapper.width, height: node.wrapper.height, x: node.wrapper.offsetX, y: node.wrapper.offsetY }
                    });
                }
            }
        };
        Drawing.prototype.scaleAnnotation = function (obj, sw, sh, pivot, refObject) {
            var node = this.pdfViewer.nameTable[obj.id];
            var element = node.wrapper;
            if (!refObject) {
                refObject = obj;
            }
            var refWrapper = refObject.wrapper;
            var x = refWrapper.offsetX - refWrapper.actualSize.width * refWrapper.pivot.x;
            var y = refWrapper.offsetY - refWrapper.actualSize.height * refWrapper.pivot.y;
            var refPoint = this.getShapePoint(x, y, refWrapper.actualSize.width, refWrapper.actualSize.height, refWrapper.rotateAngle, refWrapper.offsetX, refWrapper.offsetY, pivot);
            if (element.actualSize.width !== undefined && element.actualSize.height !== undefined) {
                this.scaleObject(sw, sh, refPoint, node, element, refObject);
            }
            var constraints = this.checkBoundaryConstraints(undefined, undefined, obj.pageIndex, obj.wrapper.bounds);
            if (!constraints) {
                this.scaleObject(1 / sw, 1 / sh, refPoint, node, element, refObject);
                if (obj.shapeAnnotationType === 'FreeText' && (obj.id.slice(0, 9) === 'free_text' || obj.id.slice(0, 8) === 'freetext')) {
                    var newDiff = this.moveInsideViewer(obj);
                    this.nodePropertyChange(obj, {
                        bounds: { width: obj.wrapper.width, height: obj.wrapper.height, x: obj.wrapper.offsetX + newDiff.tx,
                            y: obj.wrapper.offsetY + newDiff.ty }
                    });
                }
            }
            return constraints;
        };
        Drawing.prototype.moveInsideViewer = function (obj, tx, ty) {
            tx = tx || 0;
            ty = ty || 0;
            if (!obj || obj.shapeAnnotationType !== 'FreeText') {
                return {
                    tx: tx,
                    ty: ty
                };
            }
            var canvas = this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', obj.pageIndex);
            if (!canvas) {
                return {
                    tx: tx,
                    ty: ty
                };
            }
            var zoom = this.pdfViewer.viewerBase.getZoomFactor();
            var pageW = canvas.clientWidth / zoom;
            var pageH = canvas.clientHeight / zoom;
            var b = obj.wrapper.bounds;
            var maxTxRight = (pageW - 3) - b.right;
            var maxTxLeft = 1 - b.left;
            var maxTyDown = (pageH - 3) - b.bottom;
            var maxTyUp = 1 - b.top;
            if (tx > maxTxRight) {
                tx = maxTxRight;
            }
            if (tx < maxTxLeft) {
                tx = maxTxLeft;
            }
            if (ty > maxTyDown) {
                ty = maxTyDown;
            }
            if (ty < maxTyUp) {
                ty = maxTyUp;
            }
            return {
                tx: tx,
                ty: ty
            };
        };
        Drawing.prototype.checkBoundaryConstraints = function (tx, ty, pageIndex, nodeBounds, isStamp, isSkip, obj) {
            var selectorBounds = !nodeBounds ? this.pdfViewer.selectedItems.wrapper.bounds : undefined;
            var bounds = nodeBounds;
            var canvas = this.pdfViewer.viewerBase.getAnnotationCanvas('_annotationCanvas_', pageIndex);
            var heightDifference = 1;
            if (canvas) {
                var width = canvas.clientWidth / this.pdfViewer.viewerBase.getZoomFactor();
                var height = canvas.clientHeight / this.pdfViewer.viewerBase.getZoomFactor();
                var lineAnnotation = obj;
                if (lineAnnotation && (lineAnnotation.shapeAnnotationType === 'Line' || lineAnnotation.shapeAnnotationType === 'Distance' ||
                    lineAnnotation.shapeAnnotationType === 'Polygon' || lineAnnotation.measureType === 'Perimeter' ||
                    lineAnnotation.shapeAnnotationType === 'LineWidthArrowHead')) {
                    if (lineAnnotation.vertexPoints) {
                        for (var i = 0; i < lineAnnotation.vertexPoints.length; i++) {
                            var point = lineAnnotation.vertexPoints[i];
                            var x = point.x + (tx || 0);
                            var y = point.y + (ty || 0);
                            if (x > width - 3 || x < 1 || y > height - 3 || y < 1) {
                                return false;
                            }
                        }
                    }
                    return true;
                }
                var right = (nodeBounds ? bounds.right : selectorBounds.right) + (tx || 0);
                var left = (nodeBounds ? bounds.left : selectorBounds.left) + (tx || 0);
                var top_1 = (nodeBounds ? bounds.top : selectorBounds.top) + (ty || 0);
                var bottom = (nodeBounds ? bounds.bottom : selectorBounds.bottom) + (ty || 0);
                if (isStamp) {
                    heightDifference = 50;
                    if (this.pdfViewer.viewerBase.eventArgs && this.pdfViewer.viewerBase.eventArgs.source) {
                        if (this.RestrictStamp(this.pdfViewer.viewerBase.eventArgs.source)) {
                            return false;
                        }
                    }
                }
                if (right <= width - 3 && left >= 1 && bottom <= height - 3 && top_1 >= heightDifference) {
                    this.isLineInHorizontalBounds = true;
                    this.isLineInVerticalBounds = true;
                    return true;
                }
                if (isSkip) {
                    heightDifference = 10;
                    if (right <= width - 10 && left >= 10 && bottom <= height - 10 && top_1 >= heightDifference) {
                        this.isLineInHorizontalBounds = true;
                        this.isLineInVerticalBounds = true;
                        return true;
                    }
                }
                if (isSkip) {
                    if (!(right <= width - 10 && left >= 10)) {
                        this.isLineInHorizontalBounds = false;
                    }
                    if (!(bottom <= height - 10 && top_1 >= heightDifference)) {
                        this.isLineInVerticalBounds = false;
                    }
                }
                else {
                    if (!(right <= width - 3 && left >= 1)) {
                        this.isLineInHorizontalBounds = false;
                    }
                    if (!(bottom <= height - 3 && top_1 >= heightDifference)) {
                        this.isLineInVerticalBounds = false;
                    }
                }
            }
            return false;
        };
        Drawing.prototype.RestrictStamp = function (source) {
            if (source && source.pageIndex !== undefined && this.pdfViewer.viewerBase.activeElements &&
                source.pageIndex !== this.pdfViewer.viewerBase.activeElements.activePageID) {
                return true;
            }
            return false;
        };
        Drawing.prototype.getShapeBounds = function (shapeElement) {
            var shapeBounds = new ej2_drawings_1.Rect();
            var shapeCorners = ej2_drawings_1.cornersPointsBeforeRotation(shapeElement);
            var shapeMiddleLeft = shapeCorners.middleLeft;
            var shapeTopCenter = shapeCorners.topCenter;
            var shapeBottomCenter = shapeCorners.bottomCenter;
            var shapeMiddleRight = shapeCorners.middleRight;
            var shapeTopLeft = shapeCorners.topLeft;
            var shapeTopRight = shapeCorners.topRight;
            var shapeBottomLeft = shapeCorners.bottomLeft;
            var shapeBottomRight = shapeCorners.bottomRight;
            shapeElement.corners = {
                topLeft: shapeTopLeft, topCenter: shapeTopCenter, topRight: shapeTopRight, middleLeft: shapeMiddleLeft,
                middleRight: shapeMiddleRight, bottomLeft: shapeBottomLeft, bottomCenter: shapeBottomCenter, bottomRight: shapeBottomRight
            };
            if (shapeElement.rotateAngle !== 0 || shapeElement.parentTransform !== 0) {
                var matrix = ej2_drawings_1.identityMatrix();
                ej2_drawings_1.rotateMatrix(matrix, shapeElement.rotateAngle + shapeElement.parentTransform, shapeElement.offsetX, shapeElement.offsetY);
                shapeElement.corners.topLeft = shapeTopLeft = ej2_drawings_6.transformPointByMatrix(matrix, shapeTopLeft);
                shapeElement.corners.topCenter = shapeTopCenter = ej2_drawings_6.transformPointByMatrix(matrix, shapeTopCenter);
                shapeElement.corners.topRight = shapeTopRight = ej2_drawings_6.transformPointByMatrix(matrix, shapeTopRight);
                shapeElement.corners.middleLeft = shapeMiddleLeft = ej2_drawings_6.transformPointByMatrix(matrix, shapeMiddleLeft);
                shapeElement.corners.middleRight = shapeMiddleRight = ej2_drawings_6.transformPointByMatrix(matrix, shapeMiddleRight);
                shapeElement.corners.bottomLeft = shapeBottomLeft = ej2_drawings_6.transformPointByMatrix(matrix, shapeBottomLeft);
                shapeElement.corners.bottomCenter = shapeBottomCenter = ej2_drawings_6.transformPointByMatrix(matrix, shapeBottomCenter);
                shapeElement.corners.bottomRight = shapeBottomRight = ej2_drawings_6.transformPointByMatrix(matrix, shapeBottomRight);
            }
            shapeBounds = ej2_drawings_1.Rect.toBounds([shapeTopLeft, shapeTopRight, shapeBottomLeft, shapeBottomRight]);
            shapeElement.corners.left = shapeBounds.left;
            shapeElement.corners.right = shapeBounds.right;
            shapeElement.corners.top = shapeBounds.top;
            shapeElement.corners.bottom = shapeBounds.bottom;
            shapeElement.corners.center = shapeBounds.center;
            shapeElement.corners.width = shapeBounds.width;
            shapeElement.corners.height = shapeBounds.height;
            return shapeBounds;
        };
        Drawing.prototype.getShapePoint = function (x, y, w, h, angle, offsetX, offsetY, cornerPoint) {
            var pivotPoint = { x: 0, y: 0 };
            var transformMatrix = ej2_drawings_1.identityMatrix();
            ej2_drawings_1.rotateMatrix(transformMatrix, angle, offsetX, offsetY);
            switch (cornerPoint.x) {
                case 1:
                    switch (cornerPoint.y) {
                        case 1:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x + w, y: y + h }));
                            break;
                        case 0:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x + w, y: y }));
                            break;
                        case 0.5:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x + w, y: y + h / 2 }));
                            break;
                    }
                    break;
                case 0:
                    switch (cornerPoint.y) {
                        case 0.5:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x, y: y + h / 2 }));
                            break;
                        case 1:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x, y: y + h }));
                            break;
                        case 0:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x, y: y }));
                            break;
                    }
                    break;
                case 0.5:
                    switch (cornerPoint.y) {
                        case 0:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x + w / 2, y: y }));
                            break;
                        case 0.5:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x + w / 2, y: y + h / 2 }));
                            break;
                        case 1:
                            pivotPoint = ej2_drawings_6.transformPointByMatrix(transformMatrix, ({ x: x + w / 2, y: y + h }));
                            break;
                    }
                    break;
            }
            return { x: pivotPoint.x, y: pivotPoint.y };
        };
        Drawing.prototype.dragConnectorEnds = function (endPoint, obj, point, segment, target, targetPortId, currentSelector) {
            var selectorModel;
            var connector;
            var tx;
            var ty;
            if (obj instanceof selector_1.Selector) {
                selectorModel = obj;
                connector = selectorModel.annotations[0];
            }
            else {
                connector = obj;
            }
            point = { x: point.x / this.pdfViewer.viewerBase.getZoomFactor(), y: point.y / this.pdfViewer.viewerBase.getZoomFactor() };
            if (this.checkBoundaryConstraints(undefined, undefined, connector.pageIndex, connector.wrapper.bounds, null, null, obj)) {
                if (connector.shapeAnnotationType === 'Distance') {
                    var leader = drawing_util_1.isLeader(connector, endPoint);
                    if (endPoint === 'Leader0') {
                        if (this.pdfViewer.viewerBase.tool instanceof index_1.LineTool) {
                            connector.vertexPoints[0].x = point.x;
                            connector.vertexPoints[0].y = point.y;
                        }
                        else {
                            tx = point.x - leader.point.x;
                            ty = point.y - leader.point.y;
                            connector.vertexPoints[0].x += tx;
                            connector.vertexPoints[0].y += ty;
                        }
                    }
                    else if (endPoint === 'Leader1') {
                        var length_2 = connector.vertexPoints.length - 1;
                        if (this.pdfViewer.viewerBase.tool instanceof index_1.LineTool) {
                            connector.vertexPoints[parseInt(length_2.toString(), 10)].x = point.x;
                            connector.vertexPoints[parseInt(length_2.toString(), 10)].y = point.y;
                        }
                        else {
                            tx = point.x - leader.point.x;
                            ty = point.y - leader.point.y;
                            connector.vertexPoints[parseInt(length_2.toString(), 10)].x += tx;
                            connector.vertexPoints[parseInt(length_2.toString(), 10)].y += ty;
                        }
                    }
                    else {
                        var angle = ej2_drawings_1.Point.findAngle(connector.sourcePoint, connector.targetPoint);
                        var center = obj.wrapper.children[0].bounds.center;
                        var matrix = ej2_drawings_1.identityMatrix();
                        ej2_drawings_1.rotateMatrix(matrix, -angle, center.x, center.y);
                        var rotatedPoint = ej2_drawings_6.transformPointByMatrix(matrix, { x: point.x, y: point.y });
                        if (endPoint.split('_')[0] === 'ConnectorSegmentPoint') {
                            var matrix_1 = ej2_drawings_1.identityMatrix();
                            ej2_drawings_1.rotateMatrix(matrix_1, -angle, center.x, center.y);
                            var rotatedPoint1 = ej2_drawings_6.transformPointByMatrix(matrix_1, connector.vertexPoints[0]);
                            var rotatedPoint2 = ej2_drawings_6.transformPointByMatrix(matrix_1, connector.vertexPoints[connector.vertexPoints.length - 1]);
                            ty = rotatedPoint.y - rotatedPoint1.y;
                            if (connector.leaderHeight === 0 && connector.leaderHeight != null) {
                                connector.leaderHeight = this.pdfViewer.distanceSettings.leaderLength;
                            }
                            else {
                                connector.leaderHeight += ty;
                                rotatedPoint1.y += ty;
                                rotatedPoint2.y += ty;
                                var matrix_2 = ej2_drawings_1.identityMatrix();
                                ej2_drawings_1.rotateMatrix(matrix_2, angle, center.x, center.y);
                                connector.vertexPoints[0] = ej2_drawings_6.transformPointByMatrix(matrix_2, rotatedPoint1);
                                connector.vertexPoints[connector.vertexPoints.length - 1] = ej2_drawings_6.transformPointByMatrix(matrix_2, rotatedPoint2);
                            }
                        }
                    }
                }
                else if (endPoint.split('_')[0] === 'ConnectorSegmentPoint') {
                    var i = Number(endPoint.split('_')[1]);
                    tx = point.x - connector.vertexPoints[parseInt(i.toString(), 10)].x;
                    ty = point.y - connector.vertexPoints[parseInt(i.toString(), 10)].y;
                    connector.vertexPoints[parseInt(i.toString(), 10)].x += tx;
                    connector.vertexPoints[parseInt(i.toString(), 10)].y += ty;
                    if (connector.vertexPoints.length > 2 && obj.measureType !== 'Perimeter') {
                        if (parseFloat(endPoint.split('_')[1]) === 0) {
                            connector.vertexPoints[connector.vertexPoints.length - 1].x += tx;
                            connector.vertexPoints[connector.vertexPoints.length - 1].y += ty;
                        }
                        else if (parseFloat(endPoint.split('_')[1]) === connector.vertexPoints.length - 1) {
                            connector.vertexPoints[0].x += tx;
                            connector.vertexPoints[0].y += ty;
                        }
                    }
                }
                this.nodePropertyChange(connector, { vertexPoints: connector.vertexPoints });
                this.renderSelector(connector.pageIndex, currentSelector);
            }
            this.pdfViewer.renderDrawing();
            return true;
        };
        Drawing.prototype.dragSourceEnd = function (obj, tx, ty, i) {
            var connector = this.pdfViewer.nameTable[obj.id];
            connector.vertexPoints[parseInt(i.toString(), 10)].x += tx;
            connector.vertexPoints[parseInt(i.toString(), 10)].y += ty;
            this.pdfViewer.renderDrawing();
            return true;
        };
        Drawing.prototype.updateConnector = function (connector, points) {
            var targetPoint;
            connector.vertexPoints = points;
            connector_util_1.updateSegmentElement(connector, points, connector.wrapper.children[0]);
            var anglePoint = connector.vertexPoints;
            var element = connector.wrapper.children[0];
            element.canMeasurePath = true;
            for (var i = 0; i < connector.wrapper.children.length; i++) {
                element = connector.wrapper.children[parseInt(i.toString(), 10)];
                if (connector.shapeAnnotationType !== 'Polygon') {
                    if (element.id.indexOf('srcDec') > -1) {
                        connector_util_1.updateDecoratorElement(connector, element, points[0], anglePoint[1], true);
                    }
                    targetPoint = connector.targetPoint;
                    if (element.id.indexOf('tarDec') > -1) {
                        connector_util_1.updateDecoratorElement(connector, element, points[points.length - 1], anglePoint[anglePoint.length - 2], false);
                    }
                }
            }
        };
        Drawing.prototype.copy = function () {
            var annotationSettings;
            if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.annotationModule)) {
                annotationSettings = this.pdfViewer.annotationModule.findAnnotationSettings(this.pdfViewer.selectedItems.annotations[0]);
            }
            if (((this.pdfViewer.formDesignerModule && !this.pdfViewer.formDesigner.isPropertyDialogOpen) ||
                this.pdfViewer.annotationModule) && (this.pdfViewer.designerMode || this.pdfViewer.enableAnnotation) &&
                (this.pdfViewer.selectedItems.formFields.length !== 0 || (this.pdfViewer.selectedItems.annotations.length !== 0 &&
                    !ej2_base_1.isNullOrUndefined(annotationSettings) && !annotationSettings.isLock))) {
                this.pdfViewer.clipboardData.pasteIndex = 1;
                this.pdfViewer.clipboardData.clipObject = this.copyObjects();
                this.copiedElementID = this.pdfViewer.clipboardData.clipObject[0].id;
            }
            var isSearchboxDialogOpen;
            var searchBoxId = document.getElementById(this.pdfViewer.element.id + '_search_box');
            if (searchBoxId) {
                isSearchboxDialogOpen = searchBoxId.style.display !== 'none';
            }
            if (this.pdfViewer.formDesigner && this.pdfViewer.formDesigner.isPropertyDialogOpen || isSearchboxDialogOpen) {
                this.pdfViewer.clipboardData.clipObject = {};
            }
            return this.pdfViewer.clipboardData.clipObject;
        };
        Drawing.prototype.copyObjects = function () {
            var selectedItems = [];
            var obj = [];
            this.pdfViewer.clipboardData.childTable = {};
            if (this.pdfViewer.selectedItems.annotations.length > 0) {
                selectedItems = this.pdfViewer.selectedItems.annotations;
                for (var j = 0; j < selectedItems.length; j++) {
                    var element = drawing_util_1.cloneObject((selectedItems[parseInt(j.toString(), 10)]));
                    obj.push(element);
                }
            }
            if (this.pdfViewer.selectedItems.formFields.length > 0) {
                selectedItems = this.pdfViewer.selectedItems.formFields;
                for (var j = 0; j < selectedItems.length; j++) {
                    var element = drawing_util_1.cloneObject((selectedItems[parseInt(j.toString(), 10)]));
                    obj.push(element);
                }
            }
            if (this.pdfViewer.clipboardData.pasteIndex === 0) {
                for (var _i = 0, selectedItems_1 = selectedItems; _i < selectedItems_1.length; _i++) {
                    var item = selectedItems_1[_i];
                    if (this.pdfViewer.nameTable[item.id]) {
                        if (!item.formFieldAnnotationType) {
                            if (item.annotName) {
                                this.pdfViewer.annotationModule.deleteAnnotationById(item.annotName);
                            }
                            else {
                                this.pdfViewer.annotationModule.deleteAnnotation();
                            }
                        }
                        else {
                            this.pdfViewer.clearSelection(item.pageIndex);
                            this.pdfViewer.formDesignerModule.deleteFormField(item.id);
                        }
                    }
                }
            }
            this.sortByZIndex(obj, 'zIndex');
            return obj;
        };
        Drawing.prototype.getNewObject = function (obj) {
            var newObj;
            var newobjs = [];
            this.pdfViewer.clipboardData.pasteIndex = 1;
            for (var i = 0; i < obj.length; i++) {
                newObj = drawing_util_1.cloneObject(obj[parseInt(i.toString(), 10)]);
                newobjs.push(newObj);
            }
            return newobjs;
        };
        Drawing.prototype.isWithinBounds = function (pageCurrentRect, events) {
            var clientX = events.clientX, clientY = events.clientY;
            var left = pageCurrentRect.left, right = pageCurrentRect.right, top = pageCurrentRect.top, bottom = pageCurrentRect.bottom;
            return left < clientX && clientX < right && top < clientY && clientY < bottom;
        };
        Drawing.prototype.paste = function (obj, index) {
            var zoomfactor = this.pdfViewer.viewerBase.getZoomFactor();
            var allowServerDataBind = this.pdfViewer.allowServerDataBinding;
            this.pdfViewer.enableServerDataBinding(false);
            var fieldId;
            this.isPasted = true;
            if (obj || this.pdfViewer.clipboardData.clipObject) {
                var clippedData = this.pdfViewer.clipboardData.clipObject;
                var copiedItems = obj ? this.getNewObject(obj) :
                    this.getNewObject(clippedData);
                if (copiedItems) {
                    var objectTable = {};
                    if (this.pdfViewer.clipboardData.pasteIndex !== 0) {
                        this.pdfViewer.clearSelection(index);
                    }
                    if (!ej2_base_1.isNullOrUndefined(copiedItems[0])) {
                        if (this.pdfViewer.currentPageNumber === copiedItems[0].pageIndex + 1) {
                            for (var _i = 0, copiedItems_1 = copiedItems; _i < copiedItems_1.length; _i++) {
                                var copy = copiedItems_1[_i];
                                fieldId = copy.id;
                                copy.id += ej2_drawings_5.randomId();
                                var fieldName = this.splitFormFieldName(copy);
                                var maxNumber = 0;
                                if (this.pdfViewer.formDesigner) {
                                    this.pdfViewer.formDesigner.setFormFieldIndex();
                                    maxNumber = this.pdfViewer.formDesigner.formFieldIndex;
                                    copy.name = fieldName + maxNumber;
                                }
                                objectTable[copy.id] = copy;
                            }
                            var _loop_2 = function (j) {
                                var copy = copiedItems[parseInt(j.toString(), 10)];
                                var pageDiv = this_2.pdfViewer.viewerBase.getElement('_pageDiv_' + copy.pageIndex);
                                var events = window.event;
                                var pageCurrentRect = pageDiv.getBoundingClientRect();
                                if (events && !events.clientX && !events.clientY) {
                                    events = { clientX: this_2.pdfViewer.viewerBase.mouseLeft, clientY: this_2.pdfViewer.viewerBase.mouseTop };
                                }
                                if (ej2_base_1.isBlazor()) {
                                    events = this_2.pdfViewer.viewerBase.mouseDownEvent;
                                }
                                if (drawing_util_1.isLineShapes(copy)) {
                                    this_2.calculateCopyPosition(copy, pageDiv, events);
                                }
                                else {
                                    if (pageDiv) {
                                        if ((pageCurrentRect.right - events.clientX) < copy.bounds.width * zoomfactor) {
                                            copy.bounds.x = (pageDiv.clientWidth - copy.bounds.width * zoomfactor) / zoomfactor;
                                        }
                                        else {
                                            copy.bounds.x = (events.clientX - pageCurrentRect.left) / zoomfactor;
                                        }
                                        if ((pageCurrentRect.bottom - events.clientY) > copy.bounds.height * zoomfactor) {
                                            copy.bounds.y = (events.clientY - pageCurrentRect.top) / zoomfactor;
                                        }
                                        else {
                                            copy.bounds.y = (pageDiv.clientHeight - copy.bounds.height * zoomfactor) / zoomfactor;
                                        }
                                    }
                                }
                                if (this_2.isWithinBounds(pageCurrentRect, events)) {
                                    var newNode_1 = drawing_util_1.cloneObject(copy);
                                    if (this_2.pdfViewer.viewerBase.contextMenuModule.previousAction !== 'Cut') {
                                        newNode_1.id += ej2_drawings_5.randomId();
                                        if (this_2.pdfViewer.annotationModule && newNode_1.shapeAnnotationType !== 'HandWrittenSignature' &&
                                            newNode_1.shapeAnnotationType !== 'SignatureText' && newNode_1.shapeAnnotationType !== 'SignatureImage') {
                                            newNode_1.annotName = newNode_1.id;
                                            this_2.pdfViewer.annotationModule.stickyNotesAnnotationModule.
                                                updateAnnotationCollection(newNode_1, copiedItems[0], false);
                                        }
                                        if (newNode_1.shapeAnnotationType === 'SignatureText' || newNode_1.shapeAnnotationType === 'HandWrittenSignature' || newNode_1.shapeAnnotationType === 'SignatureImage') {
                                            newNode_1.signatureName = newNode_1.id;
                                            this_2.pdfViewer.viewerBase.signatureModule.storeSignatureData(newNode_1.pageIndex, newNode_1);
                                        }
                                        if (!newNode_1.formFieldAnnotationType && newNode_1.shapeAnnotationType !== 'SignatureText' && newNode_1.shapeAnnotationType !== 'HandWrittenSignature' && newNode_1.shapeAnnotationType !== 'SignatureImage') {
                                            this_2.pdfViewer.annotation.addAction(this_2.pdfViewer.viewerBase.getActivePage(false), null, newNode_1, 'Addition', '', newNode_1, newNode_1);
                                            if (newNode_1.measureType === 'Distance' || newNode_1.measureType === 'Perimeter' || newNode_1.measureType === 'Area' ||
                                                newNode_1.measureType === 'Radius' || newNode_1.measureType === 'Volume') {
                                                var matchedRatioObject = this_2.pdfViewer.annotationModule.measureAnnotationModule.
                                                    scaleRatioCollection.find(function (item) { return newNode_1.id.startsWith(item.id); });
                                                if (matchedRatioObject) {
                                                    var clonedItem = JSON.parse(JSON.stringify(matchedRatioObject));
                                                    clonedItem.annotName = newNode_1.id;
                                                    this_2.pdfViewer.annotationModule.measureAnnotationModule.
                                                        scaleRatioCollection.push(clonedItem);
                                                }
                                            }
                                        }
                                    }
                                    else {
                                        if (this_2.pdfViewer.annotationModule) {
                                            this_2.pdfViewer.annotationModule.stickyNotesAnnotationModule.
                                                updateAnnotationCollection(newNode_1, copiedItems[0], true);
                                        }
                                        if (newNode_1.shapeAnnotationType === 'SignatureText' || newNode_1.shapeAnnotationType === 'HandWrittenSignature' || newNode_1.shapeAnnotationType === 'SignatureImage') {
                                            this_2.pdfViewer.viewerBase.signatureModule.storeSignatureData(newNode_1.pageIndex, newNode_1);
                                        }
                                        if (!newNode_1.formFieldAnnotationType && newNode_1.shapeAnnotationType !== 'SignatureText' && newNode_1.shapeAnnotationType !== 'HandWrittenSignature' && newNode_1.shapeAnnotationType !== 'SignatureImage') {
                                            this_2.pdfViewer.annotation.addAction(this_2.pdfViewer.viewerBase.getActivePage(false), null, newNode_1, 'Addition', '', newNode_1, newNode_1);
                                        }
                                    }
                                    var addedAnnot = this_2.add(newNode_1);
                                    if (this_2.pdfViewer.formDesigner && addedAnnot.formFieldAnnotationType && this_2.pdfViewer.annotation) {
                                        this_2.pdfViewer.annotation.addAction(this_2.pdfViewer.viewerBase.getActivePage(true), null, addedAnnot, 'Addition', '', addedAnnot, addedAnnot);
                                    }
                                    if ((newNode_1.shapeAnnotationType === 'FreeText' || newNode_1.enableShapeLabel) && addedAnnot) {
                                        if (newNode_1.textAlign !== null) {
                                            if (newNode_1.textAlign === 'Justify') {
                                                addedAnnot.wrapper.children[1].horizontalAlignment = 'Left';
                                                addedAnnot.wrapper.children[1].setOffsetWithRespectToBounds(0, 0, null);
                                            }
                                            else if (newNode_1.textAlign === 'Right') {
                                                addedAnnot.wrapper.children[1].horizontalAlignment = 'Right';
                                                addedAnnot.wrapper.children[1].setOffsetWithRespectToBounds(1, 0, null);
                                            }
                                            else if (newNode_1.textAlign === 'Left') {
                                                addedAnnot.wrapper.children[1].horizontalAlignment = 'Left';
                                                addedAnnot.wrapper.children[1].setOffsetWithRespectToBounds(0, 0, null);
                                            }
                                            else if (newNode_1.textAlign === 'Center') {
                                                addedAnnot.wrapper.children[1].horizontalAlignment = 'Center';
                                                addedAnnot.wrapper.children[1].setOffsetWithRespectToBounds(0.51, 0, null);
                                            }
                                        }
                                        else {
                                            addedAnnot.wrapper.children[1].horizontalAlignment = 'Auto';
                                        }
                                        this_2.nodePropertyChange(addedAnnot, {});
                                    }
                                    if (addedAnnot.formFieldAnnotationType && addedAnnot.pageIndex === index) {
                                        this_2.pdfViewer.formFieldCollection.push(addedAnnot);
                                        var formField = {
                                            id: addedAnnot.id, name: addedAnnot.name,
                                            value: addedAnnot.value,
                                            type: addedAnnot.formFieldAnnotationType,
                                            isReadOnly: addedAnnot.isReadonly, fontFamily: addedAnnot.fontFamily,
                                            fontSize: addedAnnot.fontSize, fontStyle: addedAnnot.fontStyle,
                                            color: addedAnnot.color,
                                            backgroundColor: addedAnnot.backgroundColor,
                                            alignment: addedAnnot.alignment,
                                            visibility: addedAnnot.visibility,
                                            maxLength: addedAnnot.maxLength,
                                            isRequired: addedAnnot.isRequired,
                                            isPrint: addedAnnot.isPrint, isSelected: addedAnnot.isSelected,
                                            isChecked: addedAnnot.isChecked,
                                            tooltip: addedAnnot.tooltip,
                                            bounds: addedAnnot.bounds,
                                            thickness: addedAnnot.thickness, borderColor: addedAnnot.borderColor,
                                            signatureIndicatorSettings: addedAnnot.signatureIndicatorSettings,
                                            insertSpaces: addedAnnot.insertSpaces,
                                            isMultiline: addedAnnot.isMultiline,
                                            isTransparent: addedAnnot.isTransparent,
                                            options: addedAnnot.options, pageIndex: addedAnnot.pageIndex,
                                            pageNumber: addedAnnot.pageNumber,
                                            rotateAngle: addedAnnot.rotateAngle,
                                            signatureType: addedAnnot.signatureType,
                                            zIndex: addedAnnot.zIndex,
                                            selectedIndex: addedAnnot.selectedIndex
                                        };
                                        if (addedAnnot.options &&
                                            addedAnnot.options.length > 0) {
                                            formField.options = addedAnnot.options;
                                        }
                                        this_2.pdfViewer.formFieldCollections.push(formField);
                                        this_2.pdfViewer.formDesigner.drawHTMLContent(addedAnnot.formFieldAnnotationType, addedAnnot.wrapper.children[0], addedAnnot, addedAnnot.pageIndex, this_2.pdfViewer, fieldId);
                                    }
                                    this_2.pdfViewer.select([newNode_1.id], this_2.pdfViewer.annotationSelectorSettings);
                                    if (!addedAnnot.formFieldAnnotationType) {
                                        this_2.pdfViewer.annotationModule.triggerAnnotationAddEvent(newNode_1);
                                    }
                                }
                            };
                            var this_2 = this;
                            for (var j = 0; j < copiedItems.length; j++) {
                                _loop_2(j);
                            }
                        }
                    }
                }
                this.pdfViewer.renderDrawing(undefined, index);
                this.pdfViewer.viewerBase.showAnnotationPropertiesToolbar(true);
                this.pdfViewer.clipboardData.pasteIndex++;
            }
            this.pdfViewer.enableServerDataBinding(allowServerDataBind, true);
            this.isPasted = false;
        };
        Drawing.prototype.splitFormFieldName = function (obj) {
            var field = null;
            if (obj) {
                switch (obj.formFieldAnnotationType) {
                    case 'Textbox':
                        field = 'Textbox';
                        break;
                    case 'PasswordField':
                        field = 'Password';
                        break;
                    case 'Checkbox':
                        field = 'Check Box';
                        break;
                    case 'RadioButton':
                        field = 'Radio Button';
                        break;
                    case 'DropdownList':
                        field = 'Dropdown';
                        break;
                    case 'ListBox':
                        field = 'List Box';
                        break;
                    case 'SignatureField':
                        field = 'Signature';
                        break;
                    case 'InitialField':
                        field = 'Initial';
                        break;
                }
            }
            return field;
        };
        Drawing.prototype.calculateCopyPosition = function (copy, pageDiv, events) {
            var zoomfactor = this.pdfViewer.viewerBase.getZoomFactor();
            var x1;
            var y1;
            var x2;
            var y2;
            for (var i = 0; i < copy.vertexPoints.length; i++) {
                if (pageDiv) {
                    if (i === 0) {
                        var pageCurrentRect = pageDiv.getBoundingClientRect();
                        x1 = copy.vertexPoints[parseInt(i.toString(), 10)].x;
                        y1 = copy.vertexPoints[parseInt(i.toString(), 10)].y;
                        copy.vertexPoints[parseInt(i.toString(), 10)].x = (events.clientX - pageCurrentRect.left) / zoomfactor;
                        copy.vertexPoints[parseInt(i.toString(), 10)].y = (events.clientY - pageCurrentRect.top) / zoomfactor;
                        x2 = copy.vertexPoints[parseInt(i.toString(), 10)].x;
                        y2 = copy.vertexPoints[parseInt(i.toString(), 10)].y;
                    }
                    else {
                        copy.vertexPoints[parseInt(i.toString(), 10)].x += x2 - x1;
                        copy.vertexPoints[parseInt(i.toString(), 10)].y += y2 - y1;
                    }
                }
            }
            if (pageDiv) {
                var pageWidth = pageDiv.offsetWidth / zoomfactor;
                var pageHeight = pageDiv.offsetHeight / zoomfactor;
                var modifiedPoints = copy.vertexPoints.slice();
                if (copy.shapeAnnotationType === 'Distance' && !ej2_base_1.isNullOrUndefined(copy.leaderHeight)) {
                    this.calculateLeaderEndPoint(modifiedPoints, copy.leaderHeight);
                }
                var minLeft_1 = Infinity;
                var minTop_1 = Infinity;
                var maxRight_1 = -Infinity;
                var maxBottom_1 = -Infinity;
                modifiedPoints.forEach(function (point) {
                    minLeft_1 = Math.min(minLeft_1, point.x);
                    minTop_1 = Math.min(minTop_1, point.y);
                    maxRight_1 = Math.max(maxRight_1, point.x);
                    maxBottom_1 = Math.max(maxBottom_1, point.y);
                });
                var shiftX_1 = 0;
                var shiftY_1 = 0;
                if (minLeft_1 < 0) {
                    shiftX_1 = -minLeft_1;
                }
                else if (maxRight_1 > pageWidth) {
                    shiftX_1 = pageWidth - maxRight_1;
                }
                if (minTop_1 < 0) {
                    shiftY_1 = -minTop_1;
                }
                else if (maxBottom_1 > pageHeight) {
                    shiftY_1 = pageHeight - maxBottom_1;
                }
                if (shiftX_1 !== 0 || shiftY_1 !== 0) {
                    copy.vertexPoints.forEach(function (point) {
                        point.x = Math.floor(point.x + shiftX_1);
                        point.y = Math.floor(point.y + shiftY_1);
                    });
                }
            }
        };
        Drawing.prototype.calculateLeaderEndPoint = function (vertexPoints, leaderHeight) {
            var angle = ej2_drawings_1.Point.findAngle(vertexPoints[0], vertexPoints[1]);
            for (var i = 0; i < 2; i++) {
                var point = vertexPoints[parseInt(i.toString(), 10)];
                var newPoint = { x: point.x, y: point.y - leaderHeight };
                var matrix = ej2_drawings_1.identityMatrix();
                ej2_drawings_1.rotateMatrix(matrix, angle, point.x, point.y);
                var rotatedPoint = ej2_drawings_6.transformPointByMatrix(matrix, { x: newPoint.x, y: newPoint.y });
                vertexPoints.push(rotatedPoint);
            }
        };
        Drawing.prototype.cut = function (index) {
            var allowServerDataBind = this.pdfViewer.allowServerDataBinding;
            this.pdfViewer.enableServerDataBinding(false);
            if (this.pdfViewer.annotationModule) {
                this.pdfViewer.annotationModule.removedAnnotationCollection = [];
            }
            if (((this.pdfViewer.formDesignerModule && !this.pdfViewer.formDesigner.isPropertyDialogOpen) ||
                this.pdfViewer.selectedItems.annotations.length > 0) && (this.pdfViewer.designerMode ||
                this.pdfViewer.selectedItems.annotations.length > 0) && (this.pdfViewer.selectedItems.formFields.length !== 0 ||
                this.pdfViewer.selectedItems.annotations.length !== 0)) {
                this.pdfViewer.clipboardData.pasteIndex = 0;
                this.pdfViewer.clipboardData.clipObject = this.copyObjects();
                this.pdfViewer.renderDrawing(undefined, index);
                this.pdfViewer.enableServerDataBinding(allowServerDataBind, true);
                this.copiedElementID = this.pdfViewer.clipboardData.clipObject[0].id;
            }
            var isSearchboxDialogOpen;
            var searchBoxId = document.getElementById(this.pdfViewer.element.id + '_search_box');
            if (searchBoxId) {
                isSearchboxDialogOpen = searchBoxId.style.display !== 'none';
            }
            if (this.pdfViewer.formDesigner && this.pdfViewer.formDesigner.isPropertyDialogOpen || isSearchboxDialogOpen) {
                this.pdfViewer.clipboardData.clipObject = {};
            }
        };
        Drawing.prototype.sortByZIndex = function (nodeArray, sortID) {
            var id = sortID ? sortID : 'zIndex';
            nodeArray = nodeArray.sort(function (a, b) {
                return a["" + id] - b["" + id];
            });
            return nodeArray;
        };
        return Drawing;
    }());
    exports.Drawing = Drawing;
});