File: index.d.ts

package info (click to toggle)
tiled-qt 1.11.90-1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 40,304 kB
  • sloc: cpp: 125,078; java: 4,174; python: 1,634; xml: 1,524; sh: 427; makefile: 67; ruby: 15
file content (5228 lines) | stat: -rw-r--r-- 147,329 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
/**
 * Tiled can be extended with the use of JavaScript.
 *
 * Scripts can be used to implement {@link tiled.registerMapFormat | custom map formats},
 * {@link tiled.registerAction | custom actions}, and {@link tiled.registerTool | new tools}.
 * Scripts can also {@link Signal | automate actions based on signals}.
 *
 * See the [Tiled Manual](https://doc.mapeditor.org/en/stable/manual/scripting) for more information on writing or installing extensions.
 *
 * ### Type Definitions
 *
 * TypeScript type definitions for this API are available by installing the
 * [`@mapeditor/tiled-api`](https://www.npmjs.com/package/@mapeditor/tiled-api)
 * package, which allows you to write scripts using TypeScript and can provide
 * auto-completion in your editor (also when using plain JavaScript).
 *
 * This documentation is also generated based on these type definitions.
 *
 * @packageDocumentation
 */

/**
 * The file path of the current file being evaluated. Only available during
 * initial evaluation of the file and not when later functions in that file
 * get called. If you need it there, copy the value to local scope.
 */
// declare const __filename: string; // collides with nodejs types

/**
 * A value with `x`, `y`, `width` and `height` attributes.
 *
 * {@link Qt.rect} can be used to create a rectangle.
 */
interface rect {
  /**
   * X coordinate of the rectangle.
   */
  x: number;

  /**
   * Y coordinate of the rectangle.
   */
  y: number;

  /**
   * Width of the rectangle.
   */
  width: number;

  /**
   * Height of the rectangle.
   */
  height: number;
}

/**
 * Holds a discrete region, usually of a {@link TileLayer}.
 *
 * @note When iterating all the locations within a region, don't use
 * {@link boundingRect} in combination with {@link contains}! It is much faster
 * to iterate over {@link rects} instead.
 */
interface region {
  /**
   * Bounding rectangle of this region.
   */
  readonly boundingRect: rect;

  /**
   * Array of rectangles making up this region.
   *
   * @since 1.8
   */
  readonly rects : rect[];

  /**
   * Returns whether this region contains the given point.
   *
   * @since 1.8
   */
  contains(x : number, y : number) : boolean;

  /**
   * Returns whether this region contains the given point.
   *
   * @since 1.8
   */
  contains(point : point) : boolean;

  /**
   * Adds the given rectangle to this region.
   *
   * @since 1.8
   */
  add(rect : rect) : void;

  /**
   * Adds the given region to this region.
   *
   * @since 1.8
   */
  add(region : region) : void;

  /**
   * Subtracts the given rectangle from this region.
   *
   * @since 1.8
   */
  subtract(rect : rect) : void;

  /**
   * Subtracts the given region from this region.
   *
   * @since 1.8
   */
  subtract(region : region) : void;

  /**
   * Sets the selected area to the intersection of the current selected area and the given rectangle.
   *
   * @since 1.8
   */
  intersect(rect : rect) : void;

  /**
   * Sets the selected area to the intersection of the current selected area and the given region.
   *
   * @since 1.8
   */
  intersect(region : region) : void;

  /**
   * Returns this region as an array of contiguous regions, based on 8-way
   * connectivity (regions touching each other diagonally are considered
   * one contiguous region).
   *
   * The returned regions are guaranteed not to touch each other.
   *
   * @since 1.10
   */
  contiguousRegions() : region[];
}

/**
 * A value with `x` and `y` attributes.
 *
 * {@link Qt.point} can be used to create a point object.
 */
interface point {
  /**
   * X coordinate of the point.
   */
  x: number;

  /**
   * Y coordinate of the point.
   */
  y: number;
}

/**
 * A value with `width` and `height` attributes.
 *
 * {@link Qt.size} can be used to create a size object.
 */
interface size {
  /**
   * Width.
   */
  width: number;

  /**
   * Height.
   */
  height: number;
}

/**
 * A polygon is not strictly a custom type. It is an array of objects that each
 * have an `x` and `y` property, representing the points of the polygon.
 *
 * To modify the polygon of a {@link MapObject}, change or set up the
 * polygon array and then assign it to {@link MapObject.polygon}.
 */
type Polygon = point[];

/**
 * A string used to show only certain types of files when prompting the user to select a file path.
 *
 * Used in {@link FileEdit} and in {@link tiled.promptOpenFile} and related methods.
 * The filter is given in a format like `"Images (*.png *.xpm *.jpg)"`.
 *
 * If you want multiple filters, separate them with ';;', for example:
 * ```
 * "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
 * ```
 */
type FileFilter = string;

/**
 * The value of a property of type 'object', which refers to a
 * {@link MapObject} by its ID.
 *
 * Generally only used as a fallback when an object property cannot be resolved
 * to an actual object.
 *
 * Can be created with {@link tiled.objectRef}.
 */
interface ObjectRef {
  /**
   * The ID of the referenced object.
   */
  id: number;
}

/**
 * A property value with a user-defined type.
 *
 * Can be created using {@link tiled.propertyValue}.
 *
 * @since 1.8
 */
interface PropertyValue {
  /**
   * The actual value. A number for enum property values, or an object for
   * class property values.
   */
  value: object | number;

  /**
   * The ID of the type of this value.
   */
  typeId: number;

  /**
   * The name of the type of this value.
   */
  readonly typeName: string;
}

/**
 * Defines an entry in a menu. Used with {@link tiled.extendMenu}.
 *
 * Before an action can be added to a menu, it needs to be registered using
 * {@link tiled.registerAction}.
 */
interface MenuAction {
  /**
   * ID of a registered action that the menu item will represent.
   */
  action: string;

  /**
   * ID of the action before which this menu item should be added
   * (optional).
   */
  before?: string;
}

/**
 * Defines a separator in a menu. Used with {@link tiled.extendMenu}.
 */
interface MenuSeparator {
  /**
   * Set to `true` if this item is a menu separator (optional).
   */
  separator: boolean;
}

/**
 * An item in a menu, which is either an action or a separator. Used with
 * {@link tiled.extendMenu}.
 */
type MenuItem = MenuAction|MenuSeparator

/**
 * Used as the value for custom 'file' properties.
 *
 * Can be created with {@link tiled.filePath}.
 */
interface FilePath {
  /**
   * The URL of the file.
   *
   * If you need a local file path, use {@link localFile}.
   */
  url: Qt.QUrl;

  /**
   * The local file path, or empty if the current URL value doesn't refer
   * to a local file.
   *
   * @since 1.11
   */
  localFile: string;
}

/**
 * An object representing an event.
 *
 * Functions can be connected to the signal object, after which they will get
 * called when the signal is emitted. The {@link tiled} module provides several
 * useful signals, like {@link tiled.assetAboutToBeSaved}.
 *
 * Properties usually will have related signals which can be used to detect
 * changes to that property, but most of those are currently not implemented.
 *
 * To connect to a signal, call its {@link Signal.connect | connect} function and
 * pass in a function object. In the following example, newly created maps
 * automatically get their first tile layer removed:
 *
 * ```js
 * tiled.assetCreated.connect(function(asset) {
 *     if (asset.layerCount > 0) {
 *         asset.removeLayerAt(0)
 *         tiled.log("assetCreated: Removed automatically added tile layer.")
 *     }
 * })
 * ```
 *
 * In some cases it will be necessary to later disconnect the function from
 * the signal again. This can be done by defining the function separately
 * and passing it into the {@link Signal.disconnect | disconnect} function:
 *
 * ```js
 * function onAssetCreated(asset) {
 *     // Do something...
 * }
 *
 * tiled.assetCreated.connect(onAssetCreated)
 * // ...
 * tiled.assetCreated.disconnect(onAssetCreated)
 * ```
 */
interface Signal<Arg> {
  connect(callback: (arg: Arg) => void): void;
  disconnect(callback: (arg: Arg) => void): void;
}

/**
 * A global object with useful enums and functions from Qt.
 *
 * Only a small subset of available members in the `Qt` object are documented here.
 * See the [Qt QML Type reference](https://doc.qt.io/qt-6/qml-qtqml-qt.html) for the full documentation
 * (keep in mind, that the QtQuick module is not currently loaded).
 */
declare namespace Qt {
  /**
   * Returns a point with the specified `x` and `y` coordinates.
   */
  export function point(x: number, y: number): point;

  /**
   * Returns a rect with the top-left corner at `x`, `y` and the specified `width` and `height`.
   */
  export function rect(
    x: number,
    y: number,
    width: number,
    height: number
  ): rect;

  /**
   * Returns a size with the specified `width` and `height`.
   */
  export function size(width: number, height: number): size;

  /**
   * Alignment is given by a set of flags.
   * To align to the top while horizontally centering, the value can be set to `Qt.AlignTop | Qt.AlignHCenter`.
   */
  type Alignment = number;

  const AlignLeft: Alignment;
  const AlignRight: Alignment;
  const AlignVCenter: Alignment;
  const AlignHCenter: Alignment;
  const AlignJustify: Alignment;
  const AlignTop: Alignment;
  const AlignBottom: Alignment;
  const AlignCenter: Alignment;

  /**
   * Cursor shape. Can be used with {@link tiled.cursor} to create a system
   * cursor.
   */
  type CursorShape = number;

  const ArrowCursor: CursorShape;
  const UpArrowCursor: CursorShape;
  const CrossCursor: CursorShape;
  const WaitCursor: CursorShape;
  const IBeamCursor: CursorShape;
  const SizeVerCursor: CursorShape;
  const SizeHorCursor: CursorShape;
  const SizeBDiagCursor: CursorShape;
  const SizeFDiagCursor: CursorShape;
  const SizeAllCursor: CursorShape;
  const BlankCursor: CursorShape;
  const SplitVCursor: CursorShape;
  const SplitHCursor: CursorShape;
  const PointingHandCursor: CursorShape;
  const ForbiddenCursor: CursorShape;
  const WhatsThisCursor: CursorShape;
  const BusyCursor: CursorShape;
  const OpenHandCursor: CursorShape;
  const ClosedHandCursor: CursorShape;
  const DragCopyCursor: CursorShape;
  const DragMoveCursor: CursorShape;
  const DragLinkCursor: CursorShape;

  /**
   * A mouse cursor.
   *
   * Can be created with {@link tiled.cursor} and assigned to {@link
   * Tool.cursor}.
   */
  class QCursor {}

  /**
   * The base type from which all Qt widgets derive.
   * Qt documentation: [QWidget](https://doc.qt.io/qt-6/qwidget.html)
   */
  class QWidget {
    /**
     * The toolTip displayed when the user mouses over this widget
     */
    toolTip: string;

    /**
     * Controls whether this widget is visible.
     * When toggling this property, the dialog layout will automatically adjust itself
     * based on the visible widgets.
     * Qt documentation: [QWidget::visible](https://doc.qt.io/qt-6/qwidget.html#visible-prop);
     */
    visible: boolean;

    /**
     * If false, the widget cannot be interacted with.
     * Qt documentation: [QWidget::enabled](https://doc.qt.io/qt-6/qwidget.html#enabled-prop)
     */
    enabled: boolean;

    /**
     * Set this property to override the style sheet for this widget.
     *
     * See https://doc.qt.io/qt-6/stylesheet.html and https://doc.qt.io/qt-6/stylesheet-examples.html for more information.
     */
    styleSheet: string;

    /**
     * You can use this property to prevent the widget from being resized to a width
     * below this amount.
     */
    minimumWidth: number;

    /**
     * You can use this property to prevent the widget from being resized to a height
     * below this amount.
     */
    minimumHeight: number;
  }

  /**
   * The abstract base class of {@link Qt.QPushButton} and {@link Qt.QCheckBox}.
   *
   * Qt documentation: [QAbstractButton](https://doc.qt.io/qt-6/qabstractbutton.html)
   */
  class QAbstractButton extends QWidget {
    /**
     * This property holds whether the button is checkable.
     */
    checkable: boolean;

    /**
     * This property holds whether the button is checked.
     */
    checked: boolean;

    /**
     * The text displayed on the surface of the button.
     */
    text: string;

    /**
     * Signal emitted when the button is pressed.
     */
    clicked: Signal<void>;
  }

  /**
   * Used in {@link FileEdit} as the URL of the currently selected file.
   */
  class QUrl {
    /**
     * Get a string representation of the URL.
     *
     * Note that this representation will generally start with "file://". In
     * case you need a local file path, you can use the following code:
     *
     * ```js
     * var path = url.toString().replace(/^file:\/{3}/, (tiled.platform == 'windows') ? '' : '/');;
     * ```
     *
     * Or have a look at whether an alternative property is available that
     * gives you a local file path in the first place.
     */
    toString(): string;
  }

  /**
   * A widget containing a single line of text that the user can edit.
   *
   * Qt documentation: [QLineEdit](https://doc.qt.io/qt-6/qlineedit.html)
   */
  class QLineEdit extends QWidget {
    /**
     * This signal is emitted when the Return or Enter key is pressed or the line edit loses focus.
     */
    editingFinished: Signal<void>;

    /**
     * Signal emitted when the {@link text} inside the QLineEdit is changed.
     */
    textChanged: Signal<string>;

    /**
     * Setting this property makes the line edit display a grayed-out placeholder text as long as the line edit is empty.
     */
    placeholderText: string;

    /**
     * This property holds the line edit's text.
     */
    text: string;
  }

  /**
   * A widget containing multiple lines of text that the user can edit.
   * Qt documentation: [QTextEdit](https://doc.qt.io/qt-6/qtextedit.html)
   */
  class QTextEdit extends QWidget {
    /**
     * This property holds whether the user can change the contents of the widget.
     * If true, the user cannot change the text. Defaults to false.
     */
    readOnly: boolean;

    /**
     * This property holds the text editor's contents as plain text.
     */
    plainText: string;

    /**
     * Signal emitted when the text inside the QTextEdit is changed.
     * Check the text with {@link plainText}, {@link html} or {@link markdown} when this is emitted.
     */
    textChanged: Signal<void>;

    /**
     * This property holds the text editor's contents as HTML
     * See the supported HTML subset here:
     * https://doc.qt.io/qt-6/richtext-html-subset.html
     */
    html: string;

    /**
     * This property provides a Markdown interface to the text of the text edit.
     *
     * See [QTextEdit::markdown](https://doc.qt.io/qt-6/qtextedit.html#markdown-prop) for details.
     */
    markdown: string;
  }

  type CheckState = number;

  /**
   * The item is unchecked.
   * Value = 0
   */
  const Unchecked: CheckState;

  /**
   * The item is partially checked.
   * Value = 1.
   */
  const PartiallyChecked: CheckState;

  /**
   * Value = 2
   */
  const Checked: CheckState;

  /**
   * A check box widget which allows the user to toggle a value on and off.
   *
   * Qt documentation: [QCheckBox](https://doc.qt.io/qt-6/qcheckbox.html)
   */
  class QCheckBox extends QAbstractButton {
    /**
     * Signal emitted when the state of the checkbox changes.
     */
    stateChanged: Signal<CheckState>;

    /**
     * Whether the checkbox is a tri-state checkbox.
     *
     * The default is false, to have only two states, checked and unchecked.
     * Setting this to true allows the checkbox to be partially checked.
     */
    tristate: boolean;
  }

  /**
   * A combo box/ dropdown widget which allows the user to select
   * one of multiple preset values.
   * Qt documentation: [QComboBox](https://doc.qt.io/qt-6/qcombobox.html)
   */
  class QComboBox extends QWidget {
    /**
     * Index into the list of possible values that the user has selected.
     */
    currentIndex : number;

    /**
     * Signal emitted when the user selects a different option. Provides the index
     * into the list of values for the new selection.
     * @warning When Tiled is compiled against Qt 5, the `index` parameter is the chosen text rather than the actual index.
     *          Use {@link QComboBox.currentIndex} to get the selected index.
     */
    currentIndexChanged: Signal<number>;

    /**
     * Signal emitted when the user selects a different option.
     * Provides the string value of the selected option.
     */
    currentTextChanged: Signal<string>;

    /**
     * Removes all items from the combo box.
     */
    clear() : void;

    /**
     * Adds the given items to the combo box.
     *
     * @since 1.10
     */
    addItems(texts : string[]) : void;
  }
  /**
   * A label  widget which displays text to the user
   */
   class QLabel extends QWidget {
    /**
     * The text currently being displayed on the label.
     */
    text: string;
  }

  /**
   * A slider for allowing the user to set an integer value.
   * Qt documentation: [QSlider](https://doc.qt.io/qt-6/qslider.html)
   */
  class QSlider extends QWidget {

    /**
     * The minimum value that can be set by the slider.
     */
    minimum: number;
    /**
     * The maximum value that can be set by the slider.
     */
    maximum: number;
    /**
     * The amount that each tick left or right on the slider will
     * change the value.
     */
    tickInterval: number;

    /**
     * The integer value set in the slider
     */
    value: number;

    /**
     * Signal emitted when the value in the slider is changed.
     */
    valueChanged: Signal<number>;
  }

  /**
   * An input widget which allows the user to set a floating point or integer
   * value by incrementing and decrementing it.
   * Qt documentation: [QDoubleSpinBox](https://doc.qt.io/qt-6/qdoublespinbox.html)
   */
  class QDoubleSpinBox extends QWidget {
    /**
     * This property holds the minimum value of the spin box.
     */
    minimum: number;

    /**
     * This property holds the maximum value of the spin box.
     */
    maximum: number;

    /**
     * This property holds the step value.
     */
    singleStep: number;

    /**
     * This property holds the precision of the spin box, in decimals.
     *
     * Sets how many decimals the spinbox will use for displaying and
     * interpreting doubles. Specify 0 for integer values.
     */
    decimals: number;

    /**
     * This property holds the value of the spin box.
     */
    value: number;

    /**
     * Signal emitted when the value in the slider is changed.
     * In Qt 5 builds, the value passed as a argument to functions connected to this signal is
     * of type string, and will contain {@link prefix} and {@link suffix},
     * if any are set. In Qt 6 it is of number type.
     *
     * For compatibility between Qt 5 and 6, It's recommended to use the {@link value} property
     * rather than using the parameter passed to your signal handler.
     */
    valueChanged: Signal<number>;

    /**
     * This property holds the spin box's prefix.
     *
     * The prefix is prepended to the start of the displayed value. Typical use
     * is to display a unit of measurement or a currency symbol.
     */
    prefix: string;

    /**
     * This property holds the suffix of the spin box.
     *
     * The suffix is appended to the end of the displayed value. Typical use is
     * to display a unit of measurement or a currency symbol.
     */
    suffix: string;
  }

  /**
   * A button which the user can push.
   */
  class QPushButton extends QAbstractButton {
  }

  /**
   * This type is returned in mainWidget when calling {@link Dialog.addSeparator}.
   * Qt documentation [QFrame](https://doc.qt.io/qt-6/qframe.html)
   */
  class QFrame extends QWidget {
  }
}

/**
 * The `TextFile` object is used to read and write files in text mode.
 *
 * When using {@link TextFile.WriteOnly}, you need to call {@link commit} when you’re
 * done writing otherwise the operation will be aborted without effect.
 *
 * To read and write files in binary mode, use {@link BinaryFile} instead.
 */
declare class TextFile {
  static readonly ReadOnly: unique symbol;
  static readonly WriteOnly: unique symbol;
  static readonly ReadWrite: unique symbol;
  static readonly Append: unique symbol;

  /**
   * The path of the file.
   */
  public readonly filePath: string;

  /**
   * True if no more data can be read.
   */
  public readonly atEof: boolean;

  /**
   * The text codec. The codec is used for reading and writing from and to the file, respectively. Common codecs are supported, for example: “UTF-8”, “UTF-16”, and “ISO 8859-1”.
   */
  public codec: string;

  /**
   * Opens a text file in the given mode.
   */
  constructor(filePath: string, mode?: typeof TextFile.ReadOnly | typeof TextFile.WriteOnly | typeof TextFile.ReadWrite | typeof TextFile.Append);

  /**
   * Reads one line of text from the file and returns it. The returned string does not contain the
   * newline characters.
   */
  public readLine(): string;

  /**
   * Reads all data from the file and returns it.
   */
  public readAll(): string;

  /**
   * Truncates the file, that is, gives it the size of zero, removing all content.
   */
  public truncate(): void;

  /**
   * Writes a string to the file.
   */
  public write(text: string): void;

  /**
   * Writes a string to the file and appends a newline character.
   */
  public writeLine(text: string): void;

  /**
    * Commits all written text to disk and closes the file. Should be called when writing to files in WriteOnly mode. Failing to call this function will result in cancelling the operation, unless safe writing to files is disabled.
    */
  public commit(): void;

  /**
    * Closes the file. It is recommended to always call this function as soon as you are finished with the file.
    */
  public close(): void;
}

/**
 * The `BinaryFile` object is used to read and write files in binary mode.
 *
 * When using {@link BinaryFile.WriteOnly}, you need to call {@link commit} when you’re
 * done writing otherwise the operation will be aborted without effect.
 *
 * To read and write files in text mode, use {@link TextFile} instead.
 */
declare class BinaryFile {
  static readonly ReadOnly: unique symbol;
  static readonly WriteOnly: unique symbol;
  static readonly ReadWrite: unique symbol;

  /**
   * The path of the file.
   */
  public readonly filePath: string;
  /**
   * True if no more data can be read.
   */
  public readonly atEof: boolean;
  /**
   * The size of the file (in bytes).
   */
  public size: number;
  /**
   * The position that data is written to or read from.
   */
  public pos: number;

  /**
   * Opens a binary file in the given mode.
   */
  constructor(filePath: string, mode?: typeof BinaryFile.ReadOnly | typeof BinaryFile.WriteOnly | typeof BinaryFile.ReadWrite);

  /**
   * Sets the file size (in bytes). If `size` is larger than the file currently is, the new bytes
   * will be set to 0; if `size` is smaller, the file is truncated.
   */
  public resize(size: number): void;

  /**
   * Sets the current position to `pos`.
   */
  public seek(pos: number): void;

  /**
   * Reads at most `size` bytes of data from the file and returns it as an `ArrayBuffer`.
   */
  public read(size: number): ArrayBuffer;

  /**
   * Reads all data from the file and returns it as an `ArrayBuffer`.
   */
  public readAll(): ArrayBuffer;

  /**
   * Writes data into the file at the current position.
   */
  public write(data: ArrayBuffer): void;

  /**
   * Commits all written data to disk and closes the file. Should be called when writing to files
   * in WriteOnly mode. Failing to call this function will result in cancelling the operation,
   * unless safe writing to files is disabled.
   */
  public commit(): void;

  /**
   * Closes the file. It is recommended to always call this function as soon as you are finished
   * with the file.
   */
  public close(): void;
}

/**
 * An action that was registered with {@link tiled.registerAction}.
 *
 * This class is used to change the properties of the action.
 * It can be added to a menu using {@link tiled.extendMenu}.
 */
interface Action {
  /**
   * The ID this action was registered with.
   */
  readonly id: string;

  /**
   * The text used when the action is part of a menu.
   */
  text: string;

  /**
   * Whether the action is checked.
   */
  checked: boolean;

  /**
   * Whether the action can be checked.
   */
  checkable: boolean;

  /**
   * Whether the action is enabled.
   */
  enabled: boolean;

  /**
   * File name of an icon.
   */
  icon: string;

  /**
   * Whether the action should show an icon
   * in a menu.
   */
  iconVisibleInMenu: boolean;

  /**
   * The shortcut (can be assigned a string like "Ctrl+K").
   */
  shortcut: string;

  /**
   * Whether the action is visible.
   */
  visible: boolean;

  /**
   * Triggers the action.
   */
  trigger(): void;

  /**
   * Changes the checked state to its opposite state.
   */
  toggle(): void;
}

/**
 * The "ObjectGroup" is a type of layer that can contain objects. It will
 * henceforth be referred to as a layer.
 */
declare class ObjectGroup extends Layer {
  static readonly UnknownOrder: unique symbol
  static readonly TopDownOrder: unique symbol
  static readonly IndexOrder: unique symbol

  /**
   * Array of all objects on this layer.
   */
  readonly objects : MapObject[]

  /**
   * Number of objects on this layer.
   */
  readonly objectCount : number

  /**
   * Color of shape and point objects on this layer (when not set by object type).
   */
  color : color

  /**
   * The objects can either be drawn top down (sorted by their y-coordinate) or
   * by index (manual stacking order).
   *
   * The default is top down.
   *
   * @since 1.8
   */
  drawOrder : typeof ObjectGroup.TopDownOrder | typeof ObjectGroup.IndexOrder | typeof ObjectGroup.UnknownOrder;

  /**
   * Constructs a new object layer, which can be added to a TileMap.
   */
  constructor(name? : string)

  /**
   * Returns a reference to the object at the given index. When the object is removed, the reference turns into a standalone copy of the object.
   */
  objectAt(index : number) : MapObject

  /**
   * Removes the object at the given index.
   */
  removeObjectAt(index : number) : void

  /**
   * Removes the given object from this layer. The object reference turns into a standalone copy of the object.
   */
  removeObject(object : MapObject) : void

  /**
   * Inserts the object at the given index. The object can’t already be part of a layer.
   */
  insertObjectAt(index : number, object : MapObject) : void

  /**
   * Adds the given object to the layer. The object can’t already be part of a layer.
   */
  addObject(object : MapObject) : void

}

/**
 * A type alias used to describe the possible values in object properties.
 */
type TiledObjectPropertyValue = number | string | boolean | color | ObjectRef | FilePath | MapObject | PropertyValue | undefined

/**
 * An interface used to describe object properties.
 */
interface TiledObjectProperties {
  [name: string]: TiledObjectPropertyValue
}

/**
 * The base of most data types in Tiled. Provides the ability to associate
 * custom properties with the data.
 */
declare class TiledObject {
  /**
   * The asset this object is part of, or `null`.
   */
  readonly asset: Asset | null;

  /**
   * Whether the object is read-only.
   */
  readonly readOnly: boolean;

  /**
   * Class name of the object.
   *
   * Replaced the "type" of {@link MapObject} and {@link Tile} in Tiled 1.9.
   *
   * @since 1.9
   */
  className: string;

  /**
   * Returns the value of the custom property with the given name, or
   * `undefined` if no such property is set on the object. Does not
   * include inherited values (see {@link resolvedProperty}).
   *
   * `file` properties are returned as {@link FilePath}.
   *
   * `object` properties are returned as {@link MapObject} when possible,
   * or {@link ObjectRef} when the object could not be found.
   */
  property(name: string): TiledObjectPropertyValue;

  /**
   * Sets the value of the custom property with the given name.
   *
   * Supported types are `bool`, `number`, `string`, {@link color},
   * {@link FilePath}, {@link ObjectRef}, {@link MapObject} and
   * {@link PropertyValue}.
   *
   * @note When setting a `number`, the property type will be set to either
   * `int` or `float`, depending on whether it is a whole number. To force
   * the property to be `float`, use {@link setFloatProperty}.
   */
  setProperty(name: string, value: TiledObjectPropertyValue): void;

  /**
   * Sets the value of an object's property identified by the given path
   * to the given value.
   *
   * The path is a list of property names, where each name identifies
   * a member of the previous member's value. The last name in the list
   * identifies the property to set.
   *
   * Supported types are `bool`, `number`, `string`, {@link color},
   * {@link FilePath}, {@link ObjectRef}, {@link MapObject} and
   * {@link PropertyValue}.
   *
   * @note When setting a `number`, the property type will be set to either
   * `int` or `float`, depending on whether it is a whole number. To force
   * the property to be `float`, use {@link setFloatProperty}.
   *
   * @since 1.11
   */
  setProperty(path: string[], value: TiledObjectPropertyValue): void;

  /**
   * Sets the value of the custom property with the given name to the given
   * color value.
   *
   * The color is specified as a string "#RGB", "#RRGGBB" or "#AARRGGBB".
   *
   * @since 1.10
   * @deprecated Use {@link setProperty} with a value created by {@link tiled.color} instead.
   */
  setColorProperty(name: string, value: color): void;

  /**
   * Sets the value of the custom property with the given name to the given
   * color value.
   *
   * The color is specified by its red, green, blue and alpha components.
   * Each component takes a value from 0 to 255. When not provided, the alpha
   * defaults to 255.
   *
   * @since 1.10
   * @deprecated Use {@link setProperty} with a value created by {@link tiled.color} instead.
   */
  setColorProperty(name: string, red: number, green: number, blue: number, alpha?: number): void;

  /**
   * Sets the value of the custom property with the given name to the given
   * float value.
   *
   * This function is provided as alternative to {@link setProperty}, since
   * that function will set whole numbers as `int` properties.
   *
   * @since 1.10
   */
  setFloatProperty(name: string, value: number): void;

  /**
   * Returns all custom properties set on this object.
   *
   * Modifications to the properties will not affect the original object.
   * Does not include inherited values (see {@link resolvedProperties}).
   */
  properties(): TiledObjectProperties;

  /**
   * Replaces all currently set custom properties with a new set of
   * properties.
   */
  setProperties(properties: TiledObjectProperties): void;

  /**
   * Removes the custom property with the given name.
   */
  removeProperty(name: string): void;

  /**
   * Returns the value of the custom property with the given name, or
   * `undefined` if no such property is set. Includes values inherited
   * from object types, templates and tiles where applicable.
   */
  resolvedProperty(name: string): TiledObjectPropertyValue;

  /**
   * Returns all custom properties set on this object. Modifications to
   * the properties will not affect the original object. Includes values
   * inherited from object types, templates and tiles where applicable.
   */
  resolvedProperties(): TiledObjectProperties;
}

/**
 * A Tiled project file primarily defines the list of folders containing
 * the assets belonging to that project.
 *
 * @since 1.10.1
 */
declare class Project extends TiledObject {
  /**
   * A project-specific directory where you can put Tiled extensions.
   *
   * It defaults to "extensions", so when you have a directory called
   * “extensions” alongside your project file it will be picked up
   * automatically. The directory is loaded in addition to the global
   * extensions.
   */
  readonly extensionsPath: string;

  /**
   * Path to the file where automapping rules are stored for this project.
   */
  readonly automappingRulesFile: string;

  /**
   * An array of folders containing the assets belonging to the project
   */
  readonly folders: string[];

  /**
   * The path to the .tiled-project file.
   */
  readonly fileName: string;
}

/**
 * Details of a map that is added to a {@link World}.
 *
 * @since 1.11
 */
declare class WorldMapEntry {
  /**
   * File name of the map.
   */
  fileName : string;

  /**
   * A rect describing the location and dimensions of the map within the World.
   */
  rect : rect;
} 

/**
 * Patterns added to a {@link World}, which are used to automatically match
 * maps. See the [Using Pattern
 * Matching](https://doc.mapeditor.org/en/stable/manual/worlds/#using-pattern-matching)
 * section in the manual for more information.
 *
 * @since 1.11
 */
declare class WorldPattern {
  /** 
   * The regular expression pattern used to match maps in the world.
   */
  regExp: RegExp;

  /**
   * Multiplied by the first number (x) in the regular expression to determine
   * the map's position in the world.
   */
  multiplierX: number;

  /**
   * Multiplied by the second number (y) in the regular expression to determine
   * the map's position in the world.
   */
  multiplierY: number;

  /**
   * After calculating the map's position in the world using x and y in its 
   * regular expression and the associated multipliers, this offset is added
   * to determine the final position.
   */
  offset: point;

  /**
   * The size of the map in pixels.
   *
   * Used to support showing only directly neighboring maps when a world is
   * loaded. For more information, see the [Showing Only Direct
   * Neighbors](https://doc.mapeditor.org/en/stable/manual/worlds/#showing-only-direct-neighbors)
   * section in the manual.
   */
  mapSize: size;
}

/**
 * A world defined in a .world file, which is a JSON file that tells
 * Tiled which maps are part of the world and at what location.
 *
 * See the [Working with
 * Worlds](https://doc.mapeditor.org/en/stable/manual/worlds/) page in the
 * manual for more information.
 *
 * @since 1.11
 */
declare class World extends Asset {
  /**
   * The maps that are explicitly added to this world. It does not include
   * those maps which match due to patterns defined on the world.
   */
  readonly maps : WorldMapEntry[];

  /**
   * The patterns that are configured for this map. These patterns will be used
   * to automatically match maps in your project.
   */
  readonly patterns : WorldPattern[];

  /**
   * Returns all maps that are part of this world, either directly referenced
   * or matched by one of the patterns.
   */
  allMaps() : WorldMapEntry[];

  /**
   * Returns any maps that intersect with the given {@link rect}. This is a
   * filtered version of the results from {@link allMaps}.
   */
  mapsInRect(rect : rect) : WorldMapEntry[];

  /**
   * Returns true if this world contains a map with the given fileName.
   */
  containsMap(fileName : string) : boolean;

  /**
   * Returns true if this world contains the given map.
   */
  containsMap(map : TileMap) : boolean;

  /**
   * Change the position and size (in pixels) of the map with the given
   * fileName within this world.
   */
  setMapRect(fileName: string, rect : rect): void;

  /**
   * Change the position (in pixels) of the given map within this world.
   */
  setMapPos(map: TileMap, x: number, y: number): void;

  /**
   * Add a map to this world by its file name. The position and size is
   * specified in pixels by the given rect.
   */
  addMap(fileName: string, rect: rect): void;

  /**
   * Add the given map to this world. The position is given in pixels. The map
   * size will be set automatically.
   */
  addMap(map: TileMap, x: number, y: number): void;

  /**
   * Remove the map with the given file name from this world.
   */
  removeMap(fileName: string): void;

  /**
   * Remove the given map from this world.
   */
  removeMap(map: TileMap): void;
}

/**
 * Defines the font used to render objects which have {@link MapObject.shape}
 * set to {@link MapObject.Text}.
 */
interface Font {
  /**
   * The font family.
   */
  family : string

  /**
   * Font size in pixels.
   */
  pixelSize : number

  /**
   * Whether the font is bold.
   */
  bold : boolean

  /**
   * Whether the font is italic.
   */
  italic : boolean

  /**
   * Whether the text is underlined.
   */
  underline : boolean

  /**
   * Whether the text is striked through.
   */
  strikeOut : boolean

  /**
   * Whether to use kerning when rendering the text.
   */
  kerning : boolean
}

/**
 * The various possible shapes for {@link MapObject} instances.
 *
 * Accessible like `MapObject.Rectangle`, `MapObject.Polygon`, etc.
 */
type MapObjectShape = typeof MapObject.Rectangle | typeof MapObject.Polygon | typeof MapObject.Polyline | typeof MapObject.Ellipse | typeof MapObject.Text | typeof MapObject.Point;

/**
 * An object that can be part of an {@link ObjectGroup}.
 */
declare class MapObject extends TiledObject {
  static readonly Rectangle: unique symbol
  static readonly Polygon: unique symbol
  static readonly Polyline: unique symbol
  static readonly Ellipse: unique symbol
  static readonly Text: unique symbol
  static readonly Point: unique symbol

  /**
   * Unique (map-wide) ID of the object.
   */
  readonly id: number;

  /**
   * Shape of the object.
   */
  shape: MapObjectShape;

  /**
   * Name of the object.
   */
  name: string;

  /**
   * Type of the object.
   *
   * @deprecated Use {@link TiledObject.className} instead.
   */
  type: string;

  /**
   * X coordinate of the object in pixels.
   */
  x: number;

  /**
   * Y coordinate of the object in pixels.
   */
  y: number;

  /**
   * Position of the object in pixels.
   */
  pos: point;

  /**
   * Width of the object in pixels.
   */
  width: number;

  /**
   * Height of the object in pixels.
   */
  height: number;

  /**
   * Size of the object in pixels.
   */
  size: size;

  /**
   * Rotation of the object in degrees clockwise.
   */
  rotation: number;

  /**
   *
   */
  visible: boolean;

  /**
   * Polygon of the object.
   */
  polygon: Polygon;

  /**
   * The text of a text object.
   */
  text: string;

  /**
   * The font of a text object.
   */
  font: Font;

  /**
   * The alignment of a text object. Can be set using a combination of {@link Qt.Alignment} flags.
   */
  textAlignment: Qt.Alignment;

  /**
   * Whether the text of a text object wraps based on the width of the object.
   */
  wordWrap: boolean;

  /**
   * Color of a text object.
   */
  textColor: color;

  /**
   * Tile of the object.
   */
  tile: Tile | null;

  /**
   * Whether the tile is flipped horizontally.
   */
  tileFlippedHorizontally: boolean;

  /**
   * Whether the tile is flipped vertically.
   */
  tileFlippedVertically: boolean;

  /**
   * Whether the object is selected.
   */
  selected: boolean;

  /**
   * Layer this object is part of (or `null` in case of a standalone
   * object).
   */
  layer: ObjectGroup | null;

  /**
   * Map this object is part of (or `null` in case of a
   * standalone object).
   */
  readonly map: TileMap | null;

  /**
   * Constructs a new map object, which can be added to an {@link ObjectGroup}.
   */
  constructor(name? : string)

  /**
   * Constructs a new map object of the given shape, which can be added to an {@link ObjectGroup}.
   */
  constructor(shape: MapObjectShape, name? : string)
}

/**
 * The top-level assets supported by Tiled. Not all of these assets have
 * associated editors.
 *
 * @since 1.11
 */
declare enum AssetType {
  TileMap = 1,
  Tileset,
  Project,
  World,
}

/**
 * Represents any top-level data type that can be saved to a file.
 *
 * Currently either a {@link TileMap} or a {@link Tileset}.
 *
 * For assets that are loaded in the editor, all modifications and
 * modifications to their contained parts create undo commands. This
 * includes both modifying functions that are called as well as simply
 * assigning to a writable property.
 */
declare class Asset extends TiledObject {
  /**
   * File name of the asset.
   */
  readonly fileName: string;

  /**
   * The signal emitted when {@link fileName} changes.
   *
   * Its first parameter is the new file name, the second parameter is the old
   * file name.
   */
  readonly fileNameChanged: Signal<string>;

  /**
   * Whether the asset was modified after it was saved or loaded.
   */
  readonly modified: boolean;

  /**
   * The signal emitted when {@link modified} changes.
   */
  readonly modifiedChanged: Signal<void>;

  /**
   * Whether the asset is a {@link TileMap}.
   */
  readonly isTileMap: boolean;

  /**
   * Whether the asset is a {@link Tileset}.
   */
  readonly isTileset: boolean;

  /**
   * The type of this asset.
   *
   * @since 1.11
   */
  readonly assetType: AssetType;

  /**
   * Creates a single undo command that wraps all changes applied to this
   * asset by the given callback. Recommended to avoid spamming the undo
   * stack with small steps that the user does not care about.
   *
   * Example function that changes visibility of multiple layers in one
   * step:
   *
   * ```js
   * tileMap.macro((visible ? "Show" : "Hide") + " Selected Layers", function() {
   *     tileMap.selectedLayers.forEach(function(layer) {
   *         layer.visible = visible
   *     })
   * })
   * ```
   *
   * The returned value is whatever the callback function returned.
   */
  macro<T>(text: string, callback: () => T): T;

  /**
   * Undoes the last applied change.
   *
   * @note The undo system is only enabled for assets loaded in the editor!
   */
  undo(): void;

  /**
   * Redoes the last change that was undone.
   *
   * @note The undo system is only enabled for assets loaded in the editor!
   */
  redo(): void;

  /**
   * Save this asset to disk. Returns true if the asset was saved successfully.
   *
   * Errors are reported by the UI. When an editor is open for this asset, this
   * editor is activated when an error is reported.
   *
   * Only supported with the editor running, not when running scripts on the
   * CLI. Also, the asset should already have an associated file.
   *
   * To save assets to a specific file or in a different format, use {@link
   * tiled.mapFormat} or {@link tiled.tilesetFormat}. This is currently not
   * supported for worlds.
   *
   * @since 1.11
   */
  save(): boolean;
}

/**
 * Common functionality for file format readers and writers.
 *
 * @since 1.4
 */
interface FileFormat {
  /**
   * Whether this format supports reading files.
   */
  readonly canRead: boolean;

  /**
   * Whether this format supports writing files.
   */
  readonly canWrite: boolean;

  /**
   * The file name filter used by this format (used in file dialogs).
   *
   * @since 1.11.1
   */
  readonly nameFilter: FileFilter;

  /**
   * Returns whether the given file is readable by this format.
   */
  supportsFile(fileName: string): boolean;
}

/**
 * An object that can read or write map files.
 *
 * Implementations of this interface are returned from {@link tiled.mapFormat} and {@link tiled.mapFormatForFile}.
 *
 * @since 1.4
 */
interface MapFormat extends FileFormat {
  /**
   * Reads the given file as a map.
   *
   * This function will throw an error if reading is not supported.
   */
  read(fileName : string) : TileMap

  /**
   * Writes the given map to a file.
   *
   * This function will throw an error if writing is not supported.
   *
   * If there is an error writing the file, it will return a description of the error; otherwise, it will return "".
   */
  write(map : TileMap, fileName : string) : string
}

/**
 * An object that can read or write tileset files.
 *
 * Implementations of this interface are returned from {@link tiled.tilesetFormat} and {@link tiled.tilesetFormatForFile}.
 *
 * @since 1.4
 */
interface TilesetFormat extends FileFormat {
  /**
   * Reads the given file as a tileset.
   *
   * This function will throw an error if reading is not supported.
   */
  read(fileName : string) : Tileset

  /**
   * Writes the given tileset to a file.
   *
   * This function will throw an error if writing is not supported.
   *
   * If there is an error writing the file, it will return a description of the error; otherwise, it will return "".
   */
  write(tileset : Tileset, fileName : string) : string
}

/**
 * Provides functions to encode and decode data using Base64.
 *
 * @since 1.10
 */
declare namespace Base64 {
  /**
   * Encodes the given data using Base64, with the result converted to a
   * string for convenience.
   *
   * @example
   * ```js
   * let buffer = new ArrayBuffer(byteLength);
   * // [Fill the buffer with data, for example using a DataView]
   * json.data = Base64.encode(buffer);
   * file.write(JSON.stringify(json));
   * ```
   */
  export function encode(data: ArrayBuffer | string): string;

  /**
   * Encodes the given data using Base64, keeping the result in binary form.
   */
  export function encodeAsBytes(data: ArrayBuffer | string): ArrayBuffer;

  /**
   * Decodes the given data using Base64.
   */
  export function decode(data: ArrayBuffer | string): ArrayBuffer;
}

/**
 * Provides functions to rasterize lines and ellipses.
 *
 * @since 1.10.2
 */
declare namespace Geometry {
  /**
   * Returns the lists of points on a line from `a` to `b`.
   *
   * When the `manhattan` option (named after "Manhattan distance") is set to
   * `true`, the points on the line can't take diagonal steps.
   */
  export function pointsOnLine(a: point, b: point, manhattan?: boolean): point[];

  /**
   * Returns a lists of points on an ellipse, with `center` as the midpoint
   * and with the given radii.
   *
   * May return duplicate points.
   */
  export function pointsOnEllipse(center: point, radiusX: number, radiusY: number): point[];

  /**
   * Returns an elliptical region based on the given bounding rectangle.
   */
  export function ellipseRegion(rect: rect): region

  /**
   * Returns an elliptical region based on a bounding rectangle given by x0,y0
   * (top-left) and x1,y1 (bottom-right), inclusive.
   */
  export function ellipseRegion(x0: number, y0: number, x1: number, y1: number): region
}

/**
 * Offers various operations on file paths, such as turning absolute paths
 * into relative ones, splitting a path into its components, and so on.
 */
declare namespace FileInfo {
  /**
   * Returns the file name of `filePath` up to (but not including) the
   * first '.' character.
   */
  export function baseName(filePath: string): string;

  /**
   * Returns a canonicalized `filePath`, i.e. an absolute path without
   * symbolic links or redundant "." or ".." elements. On Windows,
   * drive substitutions are also resolved.
   *
   * It is recommended to use `canonicalPath` in only those cases where
   * canonical paths are really necessary. In most cases, `cleanPath`
   * should be enough.
   */
  export function canonicalPath(filePath: string): string;

  /**
   * Returns `filePath` without redundant separators and with resolved
   * occurrences of `.` and `..` components. For
   * instance, `/usr/local//../bin/` becomes `/usr/bin`.
   */
  export function cleanPath(filePath: string): string;

  /**
   * Returns the file name of `filePath` up to (but not including) the
   * last `.` character.
   */
  export function completeBaseName(filePath: string): string;

  /**
   * Returns the file suffix of `filePath` from (but not including) the
   * last `.` character.
   */
  export function completeSuffix(filePath: string): string;

  /**
   * Returns the last component of `filePath`, that is, everything after
   * the last `/` character.
   */
  export function fileName(filePath: string): string;

  /**
   * On Windows, returns `filePath` with all `\` characters replaced
   * by `/`. On other operating systems, it returns the input
   * unmodified.
   */
  export function fromNativeSeparators(filePath: string): string;

  /**
   * Returns true if `filePath` is an absolute path and false
   * if it is a relative one.
   */
  export function isAbsolutePath(filePath: string): boolean;

  /**
   * Concatenates the given paths using the `/` character.
   */
  export function joinPaths(...paths:string[]) : string;

  /**
   * Returns the part of `filePath` that is not the file name, that is,
   * everything up to (but not including) the last `/` character. If
   * `filePath` is just a file name, then `.` is returned. If
   * `filePath` ends with a `/` character, then the file name is
   * assumed to be empty for the purpose of the above definition.
   */
  export function path(filePath: string): string;

  /**
   * Returns the path to `filePath` relative to the directory `dirPath`.
   * If necessary, `..` components are inserted.
   */
  export function relativePath(dirPath: string, filePath: string): string;

  /**
   * Returns the file suffix of `filePath` from (but not including) the
   * first `.` character.
   */
  export function suffix(filePath: string): string;

  /**
   * On Windows, returns `filePath` with all `/` characters replaced by
   * `\`. On other operating systems, it returns the input unmodified.
   */
  export function toNativeSeparators(filePath: string): string;
}

/**
 * Offers various file system operations.
 *
 * @since 1.8
 */
declare namespace File {
  export const Dirs: 0x001
  export const Files: 0x002
  export const Drives: 0x004
  export const NoSymLinks: 0x008
  export const AllEntries: 0x007
  export const TypeMask: 0x00f
  export const Readable: 0x010
  export const Writable: 0x020
  export const Executable: 0x040
  export const PermissionMask: 0x070
  export const Modified: 0x080
  export const Hidden: 0x100
  export const System: 0x200
  export const AccessMask: 0x3F0
  export const AllDirs: 0x400
  export const CaseSensitive: 0x800
  export const NoDot: 0x2000
  export const NoDotDot: 0x4000
  export const NoDotAndDotDot: 0x6000
  export const NoFilter: -1
  export const Name: 0x00
  export const Time: 0x01
  export const Size: 0x02
  export const Unsorted: 0x03
  export const SortByMask: 0x03
  export const DirsFirst: 0x04
  export const Reversed: 0x08
  export const IgnoreCase: 0x10
  export const DirsLast: 0x20
  export const LocaleAware: 0x40
  export const Type: 0x80
  export const NoSort: -1

  /**
   * Copies `sourceFilePath` to `targetFilePath`. Any directory components
   * in `targetFilePath` that do not yet exist will be created. If `sourceFilePath`
   * is a directory, a recursive copy will be made. If an error occurs, a
   * JavaScript exception will be thrown.
   *
   * @note `targetFilePath` must be the counterpart of `sourceFilePath` at the new
   * location, not the new parent directory. This allows the copy to have a
   * different name and is true even if `sourceFilePath` is a directory.
   *
   * @note The file is not copied if the source file timestamp is older than the
   * destination file timestamp. If you want to replace the newer file, you need to
   * remove it first via {@link File.remove}.
   */
   export function copy(sourceFilePath: string, targetFilePath: string): boolean;

  /**
   * Returns true if and only if there is a file at `filePath`.
   */
  export function exists(filePath: string): boolean;

  /**
   * Returns a list of the directory `path`'s contents non-recursively, filtered by
   * the given `filters` and sorted by the given `sortFlags` (defaults to sorting by
   * name).
   *
   * The values for `filters` are equivalent to Qt's `QDir::Filter`. The `sortFlags`
   * are equivalent to `QDir::SortFlags`.
   */
  export function directoryEntries(path: string, filters?: number, sortFlags?: number): string[];

  /**
   * Returns the time of last modification for the file at `filePath`. The
   * concrete semantics of the returned value are platform-specific. You should
   * only rely on the property that a smaller value indicates an older timestamp.
   */
  export function lastModified(filePath: string): Date;

  /**
   * Makes the directory at `path`, creating intermediate directories if necessary.
   * Conceptually equivalent to `mkdir -p`.
   */
  export function makePath(path: string): boolean;

  /**
   * Renames the file `sourceFile` to `targetFile`. Returns `true` if successful;
   * otherwise returns `false`.
   *
   * The `overwrite` parameter is `true` by default.
   *
   * If a file with the name `targetFile` already exists, and overwrite is `false`,
   * `move()` returns `false` (that is, the file will not be overwritten).
   */
  export function move(sourceFile: string, targetFile: string, overwrite?: boolean): boolean;

  /**
   * Removes the file at `filePath`. In case of a directory, it will be removed
   * recursively.
   */
  export function remove(filePath: string): boolean;
}

/**
 * A layer that groups several other layers.
 */
declare class GroupLayer extends Layer {
  /**
   * Number of child layers the group layer has.
   */
  readonly layerCount: number;

  /**
   * The child layers of this group layer.
   *
   * @since 1.8
   */
  readonly layers: Layer[]

  /**
   * Constructs a new group layer.
   */
  constructor(name? : string)

  /**
   * Returns a reference to the child layer at the given index.
   */
  layerAt(index: number): Layer;

  /**
   * Removes the child layer at the given index. When a reference to the
   * layer still exists and this group layer isn't already standalone,
   * that reference becomes a standalone copy of the layer.
   */
  removeLayerAt(index: number): void

  /**
   * Removes the given layer from the group. If this group wasn't
   * standalone, the reference to the layer becomes a standalone copy.
   */
  removeLayer(layer: Layer): void;

  /**
   * Inserts the layer at the given index. The layer can't already be
   * part of a map.
   *
   * When adding a {@link TileLayer} to a map, the layer's width and height
   * are automatically initialized to the size of the map (since Tiled 1.4.2).
   */
  insertLayerAt(index: number, layer: Layer): void;

  /**
   * Adds the layer to the group, above all existing layers. The layer
   * can't already be part of a map.
   *
   * When adding a {@link TileLayer} to a map, the layer's width and height
   * are automatically initialized to the size of the map (since Tiled 1.4.2).
   */
  addLayer(layer: Layer): void;
}

/**
 * Can be used to create, load, save and modify images.
 *
 * Also useful when writing an importer, where the image can be set on a
 * tileset ({@link Tileset.loadFromImage}), its tiles ({@link Tile.setImage})
 * or an image layer ({@link ImageLayer.setImage}).
 *
 * @since 1.5
 */
declare class Image {
  static readonly Format_Invalid: unique symbol
  static readonly Format_Mono: unique symbol
  static readonly Format_MonoLSB: unique symbol
  static readonly Format_Indexed8: unique symbol
  static readonly Format_RGB32: unique symbol
  static readonly Format_ARGB32: unique symbol
  static readonly Format_ARGB32_Premultiplied: unique symbol
  static readonly Format_RGB16: unique symbol
  static readonly Format_ARGB8565_Premultiplied: unique symbol
  static readonly Format_RGB666: unique symbol
  static readonly Format_ARGB6666_Premultiplied: unique symbol
  static readonly Format_RGB555: unique symbol
  static readonly Format_ARGB8555_Premultiplied: unique symbol
  static readonly Format_RGB888: unique symbol
  static readonly Format_RGB444: unique symbol
  static readonly Format_ARGB4444_Premultiplied: unique symbol
  static readonly Format_RGBX8888: unique symbol
  static readonly Format_RGBA8888: unique symbol
  static readonly Format_RGBA8888_Premultiplied: unique symbol
  static readonly Format_BGR30: unique symbol
  static readonly Format_A2BGR30_Premultiplied: unique symbol
  static readonly Format_RGB30: unique symbol
  static readonly Format_A2RGB30_Premultiplied: unique symbol
  static readonly Format_Alpha8: unique symbol
  static readonly Format_Grayscale8: unique symbol
  static readonly Format_RGBX64: unique symbol
  static readonly Format_RGBA64: unique symbol
  static readonly Format_RGBA64_Premultiplied: unique symbol
  static readonly Format_Grayscale16: unique symbol
  static readonly Format_BGR888: unique symbol

  static readonly IgnoreAspectRatio: unique symbol
  static readonly KeepAspectRatio: unique symbol
  static readonly KeepAspectRatioByExpanding: unique symbol

  static readonly FastTransformation: unique symbol
  static readonly SmoothTransformation: unique symbol

  /**
   * Width of the image in pixels.
   */
  readonly width: number;

  /**
   * Height of the image in pixels.
   */
  readonly height: number;

  /**
   * Number of bits used to store a single pixel.
   */
  readonly depth: number;

  /**
   * Size of the image in pixels.
   */
  readonly size: size;

  /**
   * Format of the image. The format is defined by one of the `Image.Format_` values.
   */
  readonly format: number;

  /**
   * Constructs an empty image.
   */
  constructor();

  /**
   * Constructs an image of the given size using the given format. The format is defined by one of the `Image.Format_` values.
   */
  constructor(width: number, height: number, format: number);

  /**
   * Constructs an image from the given data, interpreting it in the
   * specified format and size. The format is defined by one of the `Image.Format_` values.
   */
  constructor(
    data: ArrayBuffer,
    width: number,
    height: number,
    format: number
    );

  /**
   * Constructs an image from the given data, interpreting it in the
   * specified format and size. The `bytesPerLine` argument
   * specifies the stride and can be useful for referencing a sub-image.
   * The format is defined by one of the `Image.Format_` values.
   */
  constructor(
    data: ArrayBuffer,
    width: number,
    height: number,
    bytesPerLine: number,
    format: number
    );

  /**
   * Construct an image by loading it from the given file name. When no
   * format is given it will be auto-detected (can be "bmp", "png",
   * etc.).
   */
  constructor(fileName: string, format?: string);

  /**
   * Returns the 32-bit unsigned color value (in ARGB order).
   */
  pixel(x: number, y: number): number;

  /**
   * Returns the color at the given position as string like "#rrggbb".
   */
  pixelColor(x: number, y: number): string;

  /**
   * Sets the color at the specified location to the given 32-bit unsigned
   * color value (ARGB) or color table index.
   */
  setPixel(x: number, y: number, index_or_rgb: number): void;

  /**
   * Sets the color at the specified location to the given color (supports
   * values like "#rrggbb" or those created by {@link tiled.color}).
   */
  setPixelColor(x: number, y: number, color: color): void;

  /**
   * Fills the image with the given 32-bit unsigned color value (ARGB) or color
   * table index.
   */
  fill(index_or_rgb: number): void;

  /**
   * Fills the image with the given color (supports values like
   * "#rrggbb" or those created by {@link tiled.color}).
   */
  fill(color: color): void;

  /**
   * Loads the image from the given file name. When no format is given it
   * will be auto-detected (can be "bmp", "png", etc.).
   */
  load(fileName: string, format?: string): void;

  /**
   * Loads the image from the given data interpreted with the given
   * format (can be "bmp", "png", etc.).
   */
  loadFromData(data: ArrayBuffer, format: string): void;

  /**
   * Saves the image to the given file.
   *
   * When no format is given it will be auto-detected based on the file extension.
   */
  save(fileName : string, format? : string, quality? : number) : boolean

  /**
   * Saves the image to an ArrayBuffer in the given format (can be "bmp", png", etc.).
   */
  saveToData(format : string, quality? : number) : ArrayBuffer

  /**
   * Returns the 32-bit color value at the given index in the color
   * table.
   */
  color(index: number): number;

  /**
   * Returns the color table as an array of 32-bit color values.
   */
  colorTable(): number[];

  /**
   * Sets the color at the given index in the color table to a given
   * 32-bit color value.
   */
  setColor(index: number, rgb: number): void;

  /**
   * Sets the color at the given index in the color table to a color (supports
   * values like "#rrggbb" or those created by {@link tiled.color}).
   */
  setColor(index: number, color: color) : void;

  /**
   * Sets the color table given by an array of either 32-bit color values
    or strings (supports values like "#rrggbb").
   */
  setColorTable(colors: number[] | string[]): void;

  /**
   * Copies the given rectangle to a new image object.
   *
   * When no rectangle is given, the entire image is copied.
   *
   * @since 1.11
   */
  copy(rect?: rect) : Image;

  /**
   * Copies the given rectangle to a new image object.
   */
  copy(x: number, y: number, width: number, height: number) : Image;

  /**
   * Returns a scaled copy of this image. Default `aspectRatioMode`
   * behavior is to ignore the aspect ratio. Default `mode` is a fast
   * transformation.
   */
  scaled(width: number, height: number,
         aspectRatioMode?: typeof Image.IgnoreAspectRatio  | typeof Image.KeepAspectRatio  | typeof Image.KeepAspectRatioByExpanding,
         transformationMode?: typeof Image.FastTransformation  | typeof Image.SmoothTransformation): Image;

  /**
   * Returns a mirrored copy of this image.
   */
  mirrored(horizontal: boolean, vertical: boolean) : Image;
}

/**
 * A layer that renders a single referenced image.
 */
declare class ImageLayer extends Layer {
  /**
   * Color used as transparent color when rendering the image.
   */
  transparentColor: color;

  /**
   * Reference to the image rendered by this layer.
   *
   * If you need a plain string, you'll want to use {@link imageFileName}
   * instead.
   */
  imageSource: Qt.QUrl;

  /**
   * Reference to the image rendered by this layer.
   *
   * @since 1.11
   */
  imageFileName: string;

  /**
   * Returns a copy of this layer's image.
   *
   * When assigning an image to this property, the {@link imageFileName}
   * property is cleared. Use {@link setImage} when you want to also set the
   * imageSource.
   *
   * @warning This property is writable but has no undo!
   *
   * @since 1.9
   */
  image: Image;

  /**
   * Whether the image rendered by this layer repeats along the X axis.
   *
   * @since 1.8
   */
  repeatX: boolean;

  /**
   * Whether the image rendered by this layer repeats along the Y axis.
   *
   * @since 1.8
   */
  repeatY: boolean;

  /**
   * Constructs a new image layer.
   */
  constructor(name? : string);

  /**
   * Sets the image for this layer to the given image, optionally also setting
   * its file name. The existing image file name is cleared.
   *
   * @warning This function has no undo!
   */
  setImage(image: Image, source?: string) : void;
}

/**
 * The interface that should be implemented for objects passed to {@link tiled.registerMapFormat}.
 */
interface ScriptedMapFormat {
  /**
   * Name of the format as shown in the file dialog.
   */
  readonly name: string;

  /**
   * The file extension used by the format.
   */
  readonly extension: string;

  /**
   * A function that reads a map from the given file. Can use
   * {@link TextFile} or {@link BinaryFile} to read the file.
   */
  read?(fileName: string): TileMap;

  /**
   * A function that writes a map to the given
   * file. Can use {@link TextFile} or {@link BinaryFile} to write the file. * When a non-empty string is returned, it is shown as error message.
   */
  write?(map: TileMap, fileName: string): string | undefined;

  /**
   * A function that returns the list of files that will
   * be written when exporting the given map (optional).
   */
  outputFiles?(map: TileMap, fileName: string): string[];
}

/**
 * The map editor.
 *
 * Accessible through {@link tiled.mapEditor}.
 */
interface MapEditor {
  /**
   * Get or set the currently used tile brush.
   */
  currentBrush : TileMap

  /**
   * Signal emitted when the current brush has changed.
   *
   * This signal is also emitted when assigning to {@link currentBrush}, so be
   * careful not to cause an infinite loop.
   *
   * @since 1.11.1
   */
  currentBrushChanged : Signal<void>;

  /**
   * Gets the currently selected {@link WangSet} in the "Terrain Sets" view.
   *
   * See also {@link TileLayerWangEdit}.
   *
   * @since 1.8
   */
  readonly currentWangSet: WangSet

  /**
   * The signal emitted when {@link currentWangSet} changes.
   *
   * @since 1.8
   */
  readonly currentWangSetChanged: Signal<void>;

  /**
   * Gets the currently selected Wang color index in the "Terrain Sets" view.
   * The value 0 is used to represent the eraser mode, and the first Wang color
   * has index 1.
   *
   * See also {@link TileLayerWangEdit}.
   *
   * @since 1.8
   */
  readonly currentWangColorIndex: number

  /**
   * The signal emitted when {@link currentWangColorIndex} changes.
   *
   * @since 1.8
   */
  readonly currentWangColorIndexChanged: Signal<number>;

  /**
   * Access the current map view.
   */
  readonly currentMapView : MapView

  /**
   * Access the Tilesets view.
   */
  readonly tilesetsView: TilesetsView
}

/**
 * The view displaying the tilesets in the map editor.
 *
 * Accessible through {@link MapEditor.tilesetsView}.
 */
interface TilesetsView {
  /**
   * Access or change the currently displayed tileset.
   */
  currentTileset: Tileset

  /**
   * The signal emitted when {@link currentTileset} changes.
   *
   * @since 1.9.1
   */
  readonly currentTilesetChanged: Signal<void>;

  /**
   * A list of the tiles that are selected in the current tileset.
   *
   * See {@link MapEditor.currentBrush} for the current tile brush, which is
   * usually more useful than the list of selected tiles.
   */
  selectedTiles: Tile[]
}

/**
 * A single frame in a tile animation.
 *
 * See {@link Tile.frames}.
 */
interface frame {
  /**
   * The local tile ID used to represent the frame.
   */
  tileId : number

  /**
   * Duration of the frame in milliseconds.
   */
  duration : number
}

/**
 * A single tile in a tileset.
 */
declare class Tile extends TiledObject {
  static readonly FlippedHorizontally: 0x01
  static readonly FlippedVertically: 0x02
  static readonly FlippedAntiDiagonally: 0x04
  static readonly RotatedHexagonal120: 0x08

  /**
   * ID of this tile within its tileset.
   */
  readonly id : number

  /**
   * Width of the tile in pixels.
   */
  readonly width : number

  /**
   * Height of the tile in pixels.
   */
  readonly height : number

  /**
   * Size of the tile in pixels.
   */
  readonly size : size

  /**
   * Type of the tile.
   *
   * @deprecated Use {@link TiledObject.className} instead.
   */
  type: string;

  /**
   * File name of the tile image (when the tile is part of an image collection tileset).
   */
  imageFileName : string

  /**
   * Returns the image of this tile, or the image of its tileset if it doesn't
   * have an individual one.
   *
   * Note that a tile represents a sub-rectangle of its image (or its tileset's
   * image), even if is part of an image collection tileset. The {@link
   * imageRect} property provides access to this sub-rectangle. If you need a
   * copy of the tile's image that is already cropped to this sub-rectangle,
   * you can use the following snippet:
   *
   * ```js
   * let image = tile.image.copy(tile.imageRect);
   * ```
   *
   * You can assign an {@link Image} to this property to change the tile's
   * image. See {@link setImage} for more information.
   *
   * @since 1.11
   */
  image: Image;

  /**
   * The source rectangle (in pixels) for this tile.
   *
   * This can be either a sub-rectangle of the tile image when the tile is part
   * of an image collection tileset or the sub-rectangle of the tileset image.
   *
   * This property can currently only be modified when the tile is part of an
   * image collection. For tileset image based tiles, it is read-only.
   *
   * @since 1.9
   */
  imageRect: rect

  /**
   * Probability that the tile gets chosen relative to other tiles.
   */
  probability : number

  /**
   * The ObjectGroup associated with the tile in case collision shapes were defined. Returns null if no collision shapes were defined for this tile.
   */
  objectGroup : ObjectGroup

  /**
   * This tile’s animation as an array of frames.
   */
  frames : frame[]

  /**
   * Indicates whether this tile is animated.
   *
   * @see {@link frames} for the animation frames.
   */
  readonly animated : boolean

  /**
   * The tileset of the tile.
   */
  readonly tileset : Tileset

  /**
   * Sets the image of this tile, optionally also setting its file name. The
   * existing image file name is cleared.
   *
   * You should prefer to just set the {@link imageFileName} when possible.
   * This function is mostly useful when the image data is loaded from a custom
   * format.
   *
   * If an image is set directly on a tile, without specifying its file name,
   * when saving the tileset the image data will be embedded for formats that
   * support this (currently only TMX/TSX).
   *
   * @note Before Tiled 1.11, this function did not change the image file
   * name. For compatibility, set {@link imageFileName} before calling this
   * function, if necessary.
   *
   * @warning This function has no undo!
   */
  setImage(image : Image, source?: string) : void
}

/**
 * The base class of the various supported layer types.
 */
declare class Layer extends TiledObject {
  static readonly TileLayerType: number
  static readonly ObjectGroupType: number
  static readonly ImageLayerType: number
  static readonly GroupLayerType: number

  /**
   * Unique (map-wide) ID of the layer
   *
   * @since 1.5
   */
  readonly id: number;

  /**
   * Name of the layer.
   */
  name: string;

  /**
   * Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).
   */
  opacity: any;

  /**
   * Tint color of the layer. Will be used to tint any images rendered by this
   * layer or by any child layers. Affects tile layers, image layers and tile
   * objects.
   *
   * Since Tiled 1.8.5, this property is #ffffff when no tint color has been
   * set on this layer (before it was #000000 in that case).
   *
   * @since 1.8
   */
  tintColor: color;

  /**
   * Whether the layer is visible (affects child layer visibility for group layers).
   */
  visible: boolean;

  /**
   * Whether the layer is locked (affects whether child layers are locked for group layers).
   */
  locked: boolean;

  /**
   * Offset in pixels that is applied when this layer is rendered.
   */
  offset: point;

  /**
   * The parallax factor of this layer.
   */
  parallaxFactor: point;

  /**
   * Map that this layer is part of, or `null` in case of a standalone layer.
   */
  readonly map: TileMap | null;

  /**
   * The group layer this layer is part of, or `null` in case the layer is not
   * grouped.
   */
  readonly parentLayer: GroupLayer | null;

  /**
   * Whether the layer is selected.
   */
  selected: boolean;

  /**
   * Whether this layer is a {@link TileLayer}.
   */
  readonly isTileLayer: boolean;

  /**
   * Whether this layer is an {@link ObjectGroup}.
   */
  readonly isObjectLayer: boolean;

  /**
   * Whether this layer is a {@link GroupLayer}.
   */
  readonly isGroupLayer: boolean;

  /**
   * Whether this layer is an {@link ImageLayer}.
   */
  readonly isImageLayer: boolean;
}

/**
 * An interface through which the currently selected area can be modified.
 *
 * Can be accessed through {@link TileMap.selectedArea}.
 *
 * Instead of directly modifying the selected area, it could be preferable to
 * get the {@link region} of this area, modify that region, and then assign it
 * back. The necessary methods have been added to the {@link region} type with
 * Tiled 1.8.
 */
interface SelectedArea {
  /**
   * Bounding rectangle of the selected area.
   */
  readonly boundingRect: rect;

  /**
   * Returns the selected region.
   */
  get() : region

  /**
   * Sets the selected area to the given rectangle.
   */
  set(rect : rect) : void

  /**
   * Sets the selected area to the given region.
   */
  set(region : region) : void

  /**
   * Adds the given rectangle to the selected area.
   */
  add(rect : rect) : void

  /**
   * Adds the given region to the selected area.
   */
  add(region : region) : void

  /**
   * Subtracts the given rectangle from the selected area.
   */
  subtract(rect : rect) : void

  /**
   * Subtracts the given region from the selected area.
   */
  subtract(region : region) : void

  /**
   * Sets the selected area to the intersection of the current selected area and the given rectangle.
   */
  intersect(rect : rect) : void

  /**
   * Sets the selected area to the intersection of the current selected area and the given region.
   */
  intersect(region : region) : void
}

/**
 * A tile-map asset.
 *
 * Usually this asset defines a specific level or area in a game.
 *
 * Contrary to the name, this is not necessary a tile-map. The contents are
 * defined by the layers that are added to it, which could also include only
 * image and object layers. Yet, this class has many properties that affect how
 * the tile layers are rendered.
 */
declare class TileMap extends Asset {
  static readonly Unknown: unique symbol
  static readonly Orthogonal: unique symbol
  static readonly Isometric: unique symbol
  static readonly Staggered: unique symbol
  static readonly Hexagonal: unique symbol

  static readonly XML: unique symbol
  static readonly Base64: unique symbol
  static readonly Base64Gzip: unique symbol
  static readonly Base64Zlib: unique symbol
  static readonly Base64Zstandard: unique symbol
  static readonly CSV: unique symbol

  static readonly RightDown: unique symbol
  static readonly RightUp: unique symbol
  static readonly LeftDown: unique symbol
  static readonly LeftUp: unique symbol

  static readonly StaggerX: unique symbol
  static readonly StaggerY: unique symbol

  static readonly StaggerOdd: unique symbol
  static readonly StaggerEven: unique symbol


  /**
   * Width of the map in tiles (only relevant for non-infinite maps).
   */
  width : number

  /**
   * Height of the map in tiles (only relevant for non-infinite maps).
   */
  height : number

  /**
   * Size of the map in tiles (only relevant for non-infinite maps).
   */
  readonly size : size

  /**
   * Tile width (used by tile layers).
   */
  tileWidth : number

  /**
   * Tile height (used by tile layers).
   */
  tileHeight : number

  /**
   * Whether this map is infinite.
   */
  infinite : boolean

  /**
   * Length of the side of a hexagonal tile (used by tile layers on hexagonal maps).
   */
  hexSideLength : number

  /**
   * For staggered and hexagonal maps, determines which axis (X or Y) is staggered.
   */
  staggerAxis : typeof TileMap.StaggerX | typeof TileMap.StaggerY

  /**
   * The parallax origin used for reference when applying the respective parallax factor.
   *
   * @since 1.8
   */
  parallaxOrigin : point

  /**
   * General map orientation
   */
  orientation : typeof TileMap.Orthogonal | typeof TileMap.Isometric | typeof TileMap.Staggered | typeof TileMap.Hexagonal | typeof TileMap.Unknown

  /**
   * Tile rendering order (only implemented for orthogonal maps)
   */
  renderOrder : typeof TileMap.RightDown | typeof TileMap.RightUp | typeof TileMap.LeftDown | typeof TileMap.LeftUp

  /**
   * For staggered and hexagonal maps, determines whether the even or odd indexes along the staggered axis are shifted.
   */
  staggerIndex : typeof TileMap.StaggerOdd | typeof TileMap.StaggerEven

  /**
   * Background color of the map.
   */
  backgroundColor : color

  /**
   * The format in which the layer data is stored, taken into account by TMX, JSON and Lua map formats.
   */
  layerDataFormat : typeof TileMap.XML | typeof TileMap.Base64 | typeof TileMap.Base64Gzip | typeof TileMap.Base64Zlib | typeof TileMap.Base64Zstandard | typeof TileMap.CSV

  /**
   * Number of top-level layers the map has.
   */
  readonly layerCount : number

  /**
   * The list of tilesets referenced by this map. To determine which tilesets are actually used, call {@link usedTilesets}.
   */
  readonly tilesets : Tileset[]

  /**
   * The top-level layers of this map. To access nested layers, use {@link GroupLayer.layers}.
   *
   * @since 1.8
   */
  readonly layers: Layer[]

  /**
   * The selected area of tiles.
   */
  readonly selectedArea : SelectedArea

  /**
   * The current layer.
   */
  currentLayer : Layer

  /**
   * The signal emitted when {@link currentLayer} changes.
   */
  readonly currentLayerChanged: Signal<void>;

  /**
   * Selected layers.
   *
   * The order of the layers is always bottom to top, with selected group
   * layers coming after any of their selected children.
   */
  selectedLayers : Layer[]

  /**
   * The signal emitted when {@link selectedLayers} changes.
   */
  readonly selectedLayersChanged: Signal<void>;

  /**
   * Selected objects.
   *
   * The order of the objects is their display order (when {@link
   * ObjectGroup.IndexOrder} is used).
   */
  selectedObjects : MapObject[]

  /**
   * The signal emitted when {@link selectedObjects} changes.
   */
  readonly selectedObjectsChanged: Signal<void>;

  /**
   * Constructs a new map.
   */
  constructor();

  /**
   * Applies [Automapping](https://doc.mapeditor.org/en/stable/manual/automapping/) using the given rules file or rule map file.
   *
   * When no rules file nor rule map file is given, Automapping is applied using the default rules file.
   *
   * @note This operation can only be applied to maps loaded from a file.
   */
  public autoMap(rulesOrMapFile?: string): void;

  /**
   * Applies [Automapping](https://doc.mapeditor.org/en/stable/manual/automapping/) in the given region using the given rules file or rule map file.
   *
   * When no rules file nor rule map file is given, Automapping is applied using the default rules file.
   *
   * @note This operation can only be applied to maps loaded from a file.
   */
  public autoMap(region: region | rect, rulesOrMapFile?: string): void;

  /**
   * Sets the size of the map in tiles. This does not affect the contents of the map.
   *
   * See also {@link resize}.
   */
  public setSize(width: number, height: number): void;

  /**
   * Sets the tile size of the map in pixels. This affects the rendering of all tile layers.
   */
  public setTileSize(width: number, height: number): void;

  /**
   * Returns a reference to the top-level layer at the given index. When the layer gets removed from the map, the reference changes to a standalone copy of the layer.
   */
  public layerAt(index: number): Layer;

  /**
   * Removes the top-level layer at the given index. When a reference to the layer still exists, that reference becomes a standalone copy of the layer.
   */
  public removeLayerAt(index: number): void;

  /**
   * Removes the given layer from the map. The reference to the layer becomes a standalone copy.
   */
  public removeLayer(layer: Layer): void;

  /**
   * Inserts the layer at the given index. The layer can’t already be part of a map.
   */
  public insertLayerAt(index: number, layer: Layer): void;

  /**
   * Adds the layer to the map, above all existing layers. The layer can’t already be part of a map.
   */
  public addLayer(layer: Layer): void;

  /**
   * Adds the given tileset to the list of tilesets referenced by this map. Returns true if the tileset was added, or false if the tileset was already referenced by this map.
   */
  public addTileset(tileset: Tileset): boolean;

  /**
   * Replaces all occurrences of oldTileset with newTileset. Returns true on success, or false when either the old tileset was not referenced by the map, or when the new tileset was already referenced by the map.
   */
  public replaceTileset(oldTileset: Tileset, newTileset: Tileset): boolean;

  /**
   * Removes the given tileset from the list of tilesets referenced by this map. Returns true on success, or false when the given tileset was not referenced by this map or when the tileset was still in use by a tile layer or tile object.
   */
  public removeTileset(tileset: Tileset): boolean;

  /**
   * Returns the list of tilesets actually used by this map. This is generally a subset of the tilesets referenced by the map (the {@link tilesets} property).
   */
  public usedTilesets(): Tileset[];

  /**
   * Removes the given objects from this map. The object references turn into a standalone copy of the object.
   *
   * @since 1.8
   */
  public removeObjects(objects : MapObject[]): void;

  /**
   * Merges the tile layers in the given map with this one. If only a single
   * tile layer exists in the given map, it will be merged with the
   * {@link currentLayer}.
   *
   * Normally, merging tile layers will ignore empty areas in the source map.
   * However, when edits to tile layers in the source map have previously been
   * made through {@link TileLayerEdit.setTile}, these edits are applied
   * regardless of whether the tiles are empty or not. This enables erasing of
   * tiles, for example when merging the {@link Tool.preview}.
   *
   * This operation can currently only be applied to maps open in the editor.
   *
   * If `canJoin` is true, the operation joins with the previous one on the
   * undo stack when possible. Useful for reducing the amount of undo commands.
   */
  public merge(map: TileMap, canJoin?: boolean): void;

  /**
   * Resizes the map to the given size, optionally applying an offset (in tiles).
   *
   * This operation can currently only be applied to maps loaded from a file.
   *
   * See also {@link setSize}.
   */
  public resize(size: size, offset?: point, removeObjects?: boolean): void;

  /**
   * Renders the map to an image. When no size is given, creates an image the
   * size of the map.
   *
   * @warning A tile map can easily be way too large to render to an image
   * unscaled, so be careful when calling this function.
   *
   * @since 1.10
   */
  public toImage(size?: size): Image;

  /**
   * Converts the given position from screen to tile coordinates.
   */
  public screenToTile(x: number, y: number): point;

  /**
   * Converts the given position from screen to tile coordinates.
   */
  public screenToTile(position: point): point;

  /**
   * Converts the given position from tile to screen coordinates.
   */
  public tileToScreen(x: number, y: number): point;

  /**
   * Converts the given position from tile to screen coordinates.
   */
  public tileToScreen(position: point): point;

  /**
   * Converts the given position from screen to pixel coordinates.
   */
  public screenToPixel(x: number, y: number): point;

  /**
   * Converts the given position from screen to pixel coordinates.
   */
  public screenToPixel(position: point): point;

  /**
   * Converts the given position from pixel to screen coordinates.
   */
  public pixelToScreen(x: number, y: number): point;

  /**
   * Converts the given position from pixel to screen coordinates.
   */
  public pixelToScreen(position: point): point;

  /**
   * Converts the given position from pixel to tile coordinates.
   */
  public pixelToTile(x: number, y: number): point;

  /**
   * Converts the given position from pixel to tile coordinates.
   */
  public pixelToTile(position: point): point;

  /**
   * Converts the given position from tile to pixel coordinates.
   */
  public tileToPixel(x: number, y: number): point;

  /**
   * Converts the given position from tile to pixel coordinates.
   */
  public tileToPixel(position: point): point;

  /**
   * The signal emitted after a region of a {@link TileLayer} was edited.
   *
   * This signal is not emitted on undo/redo, nor after changes made in
   * scripts. It receives the affected {@link TileLayer} as a second parameter.
   */
  readonly regionEdited : Signal<region>;
}

/**
 * A cell on a {@link TileLayer}.
 */
interface cell {
  /**
   * The local tile ID of the tile, or -1 if the cell is empty.
   */
  tileId : number

  /**
   * Whether the cell is empty.
   */
  empty : boolean

  /**
   * Whether the tile is flipped horizontally.
   */
  flippedHorizontally : boolean

  /**
   * Whether the tile is flipped vertically.
   */
  flippedVertically : boolean

  /**
   * Whether the tile is flipped anti-diagonally.
   */
  flippedAntiDiagonally : boolean

  /**
   * Whether the tile is rotated by 120 degrees (for hexagonal maps, the anti-diagonal flip is interpreted as a 60-degree rotation).
   */
  rotatedHexagonal120 : boolean
}

/**
 * A tile layer.
 *
 * Note that while tile layers have a size, the size is generally ignored on
 * infinite maps. Even for fixed size maps, nothing in the scripting API stops
 * you from changing the layer outside of its boundaries and changing the size
 * of the layer has no effect on its contents. If you want to change the size
 * while affecting the contents, use the {@link resize} function.
 */
declare class TileLayer extends Layer {
  /**
   * Width of the layer in tiles (only relevant for non-infinite maps).
   */
  width : number

  /**
   * Height of the layer in tiles (only relevant for non-infinite maps).
   */
  height : number

  /**
   * Size of the layer in tiles (only relevant for non-infinite maps).
   */
  size : size

  /**
   * Constructs a new tile layer, which can be added to a {@link TileMap}.
   */
  constructor(name? : string)

  /**
   * Returns the region of the layer that is covered with tiles.
   */
  region() : region

  /**
   * Resizes the layer, erasing the part of the contents that falls outside of the layer’s new size.
   * The offset parameter can be used to shift the contents by a certain distance in tiles before applying the resize.
   */
  resize(size : size, offset : point) : void

  /**
   * Returns the value of the cell at the given position. Can be used to query the flags and the tile ID, but does not currently allow getting a tile reference (see {@link tileAt}).
   */
  cellAt(x : number, y : number) : cell

  /**
   * Returns the flags used for the tile at the given position.
   *
   * The returned number is a combination of {@link Tile.FlippedHorizontally},
   * {@link Tile.FlippedVertically}, {@link Tile.FlippedAntiDiagonally} and
   * {@link Tile.RotatedHexagonal120}.
   */
  flagsAt(x : number, y : number) : number

  /**
   * Returns the tile used at the given position, or null for empty spaces.
   */
  tileAt(x : number, y : number) : Tile | null

  /**
   * Returns an object that enables making modifications to the tile layer.
   */
  edit() : TileLayerEdit

  /**
   * Returns an object that enables making modifications to the tile layer
   * using the given {@link WangSet}.
   *
   * @since 1.10.2
   */
  wangEdit(wangSet: WangSet) : TileLayerWangEdit
}

/**
 * This object enables modifying the tiles on a tile layer. Tile layers can't be
 * modified directly for reasons of efficiency. The {@link apply}
 * function needs to be called when you're done making changes.
 *
 * An instance of this object is created by calling {@link TileLayer.edit}.
 */
interface TileLayerEdit {
  /**
   * The target layer of this edit object.
   */
  readonly target : TileLayer

  /**
   * Whether applied edits are mergeable with previous edits. Starts out as
   * `false` and is automatically set to `true` by {@link apply}.
   */
  mergeable : boolean

  /**
   * Sets the tile at the given location, optionally specifying tile flags (any
   * combination of {@link Tile.FlippedHorizontally}, {@link Tile.FlippedVertically},
   * {@link Tile.FlippedAntiDiagonally} and {@link Tile.RotatedHexagonal120}).
   *
   * To remove a tile, set it to `null`.
   *
   * When the modifications are applied to the target layer, using {@link
   * apply}, all locations which have been set retain a special flag. This flag
   * is taken into account by {@link TileMap.merge} and {@link Tool.preview},
   * to enable erasing tiles and highlighting the erased area, respectively
   * (since Tiled 1.10.2).
   */
  setTile(x : number, y : number, tile : Tile | null, flags? : number) : void

  /**
   * Applies the changes made through this object to the target layer. This
   * object can be reused to make further changes.
   *
   * By default, the first time this method is called on a {@link TileLayerEdit}
   * instance, it triggers a new undoable edit. Subsequent edits made through
   * the same instance will merge with the previous step. To manually control
   * whether the edit will be merged or not, set the {@link mergeable} property
   * before calling {@link apply}.
   */
  apply() : void
}

/**
 * The Wang indexes are arranged as follows:
 *
 * ```
 * 7 0 1
 * 6 - 2
 * 5 4 3
 * ```
 *
 * These indexes are used by the {@link TileLayerWangEdit}.
 *
 * @since 1.10.2
 */
declare enum WangIndex {
  Top         = 0,
  TopRight    = 1,
  Right       = 2,
  BottomRight = 3,
  Bottom      = 4,
  BottomLeft  = 5,
  Left        = 6,
  TopLeft     = 7,
  NumCorners  = 4,
  NumEdges    = 4,
  NumIndexes  = 8,
}

/**
 * This object enables modifying the tiles on a tile layer using a
 * {@link WangSet}. For performance reasons, the changes are not applied
 * directly. Call either the {@link apply} or {@link generate} function when
 * you're done making changes.
 *
 * Note that the result may vary since the changes are applied by looking for
 * tiles matching the desired Wang colors, which includes a random factor in
 * case of multiple matches.
 *
 * Colors in a {@link WangSet} are numbered starting from 1. To request no Wang
 * color, usually for Wang-aware erasing, use 0. The currently selected {@link
 * WangSet} and color are available through {@link MapEditor.currentWangSet}
 * and {@link MapEditor.currentWangColorIndex}.
 *
 * An instance of this object is created by calling {@link TileLayer.wangEdit}.
 *
 * @since 1.10.2
 */
interface TileLayerWangEdit {
  /**
   * The target layer of this edit object.
   */
  readonly target : TileLayer

  /**
   * The Wang set that will be used when {@link apply} or {@link generate} is
   * called.
   */
  readonly wangSet : WangSet

  /**
   * Whether applied edits are mergeable with previous edits. Starts out as
   * `false` and is automatically set to `true` by {@link apply}.
   */
  mergeable : boolean

  /**
   * Whether neighboring tiles will be corrected to match up with any marked
   * changes once {@link apply} is called. This can cause a larger area to get
   * modified. Defaults to `false`.
   */
  correctionsEnabled : boolean

  /**
   * Whether the empty tile is considered when looking for matching tiles.
   * Defaults to `true`.
   */
  erasingEnabled : boolean

  /**
   * Sets the desired color for the given Wang index at the given location.
   *
   * This is a low-level function, which only affects the given location and
   * does not automatically adjust any neighboring tiles. Use {@link setCorner}
   * or {@link setEdge} when that is desired or set {@link correctionsEnabled}
   * to `true`.
   */
  setWangIndex(x : number, y : number, wangIndex: WangIndex, color : number) : void

  /**
   * Sets the desired color for the given Wang index at the given location.
   *
   * This is a low-level function, which only affects the given location and
   * does not automatically adjust any neighboring tiles. Use {@link setCorner}
   * or {@link setEdge} when that is desired or set {@link correctionsEnabled}
   * to `true`.
   */
  setWangIndex(pos : point, wangIndex: WangIndex, color : number) : void

  /**
   * Sets the desired color for the given corner at the given vertex location.
   *
   * The vertex location refers to a point in between the tiles, where (0, 0) is
   * the top-left corner of the map and (mapWidth, mapHeight) is the bottom-right
   * corner.
   *
   * Changing the color of a corner affects all 4 tiles meeting at that corner.
   */
  setCorner(x : number, y : number, color : number) : void

  /**
   * Sets the desired color for the given corner at the given vertex location.
   *
   * The vertex location refers to a point in between the tiles, where (0, 0) is
   * the top-left corner of the map and (mapWidth, mapHeight) is the bottom-right
   * corner.
   *
   * Changing the color of a corner affects all 4 tiles meeting at that corner.
   */
  setCorner(pos : point, color : number) : void

  /**
   * Sets the desired color for the given edge at the given location. Only the
   * values {@link WangIndex.Top}, {@link WangIndex.Left}, {@link
   * WangIndex.Right} and {@link WangIndex.Bottom} are supported.
   *
   * Changing the color of an edge affects the 2 tiles connected by that edge.
   */
  setEdge(x : number, y : number, edge: WangIndex, color : number) : void

  /**
   * Sets the desired color for the given edge at the given location. Only the
   * values {@link WangIndex.Top}, {@link WangIndex.Left}, {@link
   * WangIndex.Right} and {@link WangIndex.Bottom} are supported.
   *
   * Changing the color of an edge affects the 2 tiles connected by that edge.
   */
  setEdge(pos : point, edge: WangIndex, color : number) : void

  /**
   * Applies the changes made through this object to the target layer. This
   * object can be reused to make further changes.
   *
   * Alternatively, get a copy of the modifications using {@link generate}.
   */
  apply() : void

  /**
   * Applies the changes made through this object to a new layer and returns
   * that layer. This object can be reused to make further changes.
   *
   * @example
   * Making a change and use the result for {@link Tool.preview}:
   * ```js
   * let wangSet = tiled.mapEditor.currentWangSet
   * let wangEdit = tiled.activeAsset.currentLayer.wangEdit(wangSet)
   * wangEdit.correctionsEnabled = true
   * wangEdit.setCorner(this.tilePosition, tiled.mapEditor.currentWangColorIndex)
   * let map = new TileMap()
   * map.addLayer(wangEdit.generate())
   * this.preview = map
   * ```
   *
   * Alternatively, you can apply the changes directly to the target layer
   * using {@link apply}.
   */
  generate() : TileLayer
}

/**
 * Defines a "Terrain Set".
 *
 * To create and add a new Wang set to a {@link Tileset}, use {@link
 * Tileset.addWangSet}.
 *
 * @since 1.5
 */
declare class WangSet extends TiledObject {
  static readonly Edge: unique symbol;
  static readonly Corner: unique symbol;
  static readonly Mixed: unique symbol;

  /**
   * Name of the Wang set.
   */
  name : string

  /**
   * Type of the Wang set.
   */
  type : typeof WangSet.Edge | typeof WangSet.Corner | typeof WangSet.Mixed;

  /**
   * The tile used to represent the Wang set.
   */
  imageTile : Tile

  /**
   * The number of colors used by this Wang set.
   */
  colorCount : number

  /**
   * The tileset to which this Wang set belongs.
   */
  readonly tileset : Tileset

  /**
   * Returns the current Wang ID associated with the given tile.
   *
   * The Wang ID is given by an array of 8 numbers, indicating the colors associated with each index in the following order: [Top, TopRight, Right, BottomRight, Bottom, BottomLeft, Left, TopLeft] (see {@link WangIndex}).
   * A value of 0 indicates that no color is associated with a given index.
   */
  public wangId(tile : Tile) : number[]

  /**
   * Sets the Wang ID associated with the given tile.
   *
   * The Wang ID is given by an array of 8 numbers, indicating the colors associated with each index in the following order: [Top, TopRight, Right, BottomRight, Bottom, BottomLeft, Left, TopLeft] (see {@link WangIndex}).
   * A value of 0 indicates that no color is associated with a given index.
   *
   * Make sure the Wang set color count is set before calling this function, because it will raise an error when the Wang ID refers to non-existing colors.
   */
  public setWangId(tile : Tile, wangId : number[]) : void

  /**
   * Returns the name of the Wang color at the given index.
   *
   * @since 1.8
   */
  public colorName(colorIndex: number) : string

  /**
   * Sets the name of the Wang color at the given index.
   *
   * @since 1.8
   */
  public setColorName(colorIndex: number, name: string) : void

  /**
   * Returns the effective WangSet type for the given color.
   *
   * Always equals the {@link type} of the WangSet in case of corner or edge
   * sets. In case of a mixed set, it could also be {@link WangSet.Corner} or
   * {@link WangSet.Edge}, when the given color is only used in that context.
   *
   * @since 1.10.2
   */
  public effectiveTypeForColor(color : number) : typeof WangSet.Edge | typeof WangSet.Corner | typeof WangSet.Mixed
}

/**
 * A color value.
 *
 * A color value can be converted to a string and can also be assigned using a
 * string. The string is a hexadecimal triplet or quad in the form "#RRGGBB"
 * and "#AARRGGBB" respectively. For example, the color red corresponds to a
 * triplet of "#FF0000" and a slightly transparent blue to a quad of
 * "#800000FF".
 *
 * Use {@link tiled.color} to create a color value.
 */
interface color {}

/**
 * A container for tiles that can be used by a map.
 *
 * Can contain either tiles cut from a single image, by setting {@link image}
 * or calling {@link loadFromImage}, or individual tiles using {@link addTile}
 * and then setting the image on each tile using {@link Tile.imageFileName} or
 * {@link Tile.setImage}.
 */
declare class Tileset extends Asset {
  static readonly Unspecified: unique symbol
  static readonly TopLeft: unique symbol
  static readonly Top: unique symbol
  static readonly TopRight: unique symbol
  static readonly Left: unique symbol
  static readonly Center: unique symbol
  static readonly Right: unique symbol
  static readonly BottomLeft: unique symbol
  static readonly Bottom: unique symbol
  static readonly BottomRight: unique symbol

  static readonly Orthogonal: unique symbol
  static readonly Isometric: unique symbol

  static readonly TileSize: unique symbol
  static readonly GridSize: unique symbol

  static readonly Stretch: unique symbol
  static readonly PreserveAspectFit: unique symbol

  /**
   * Name of the tileset.
   */
  name : string

  /**
   * The file name of the image used by this tileset. Empty in case of image collection tilesets.
   *
   * @note You'll want to set up the tile size, tile spacing, margin and
   * transparent color as appropriate before setting this property, to avoid
   * repeatedly setting up the tiles in response to changing parameters.
   *
   * @note Map files are supported tileset image source as well.
   *
   * @since 1.11
   */
  imageFileName : string

  /**
   * @deprecated Use {@link imageFileName} instead.
   */
  image : string

  /**
   * Array of all tiles in this tileset. Note that the index of a tile in this array does not always match with its ID.
   */
  readonly tiles : Tile[]

  /**
   * Array of all Wang sets in this tileset.
   */
  readonly wangSets : WangSet[]

  /**
   * The number of tiles in this tileset.
   */
  readonly tileCount : number

  /**
   * The number of tile columns in this tileset.
   *
   * Can be changed in case of image-collection tilesets, in which case it
   * determines the number of columns used in the tileset view when dynamic
   * wrapping is disabled.
   *
   * @since 1.9
   */
  columnCount : number

  /**
   * The ID of the next tile that would be added to this tileset. All existing tiles have IDs that are lower than this ID.
   */
  readonly nextTileId : number

  /**
   * Tile width for tiles in this tileset in pixels.
   *
   * @note Changing this property will cause an image-based tileset to update
   * all its tiles. When setting up a tileset, you'll want to set this property
   * before setting the {@link image} property.
   */
  tileWidth : number

  /**
   * Tile Height for tiles in this tileset in pixels.
   *
   * @note Changing this property will cause an image-based tileset to update
   * all its tiles. When setting up a tileset, you'll want to set this property
   * before setting the {@link image} property.
   */
  tileHeight : number

  /**
   * Tile size for tiles in this tileset in pixels.
   *
   * @note Changing this property will cause an image-based tileset to update
   * all its tiles. When setting up a tileset, you'll want to set this property
   * before setting the {@link image} property.
   */
  tileSize : size

  /**
   * Width of the tileset image in pixels.
   */
  readonly imageWidth : number

  /**
   * Height of the tileset image in pixels.
   */
  readonly imageHeight : number

  /**
   * Size of the tileset image in pixels.
   */
  readonly imageSize : size

  /**
   * Spacing between tiles in this tileset in pixels.
   *
   * @note Changing this property will cause an image-based tileset to update
   * all its tiles. When setting up a tileset, you'll want to set this property
   * before setting the {@link image} property.
   */
  tileSpacing : number

  /**
   * Margin around the tileset in pixels (only used at the top and left sides of the tileset image).
   *
   * @note Changing this property will cause an image-based tileset to update
   * all its tiles. When setting up a tileset, you'll want to set this property
   * before setting the {@link image} property.
   */
  margin : number

  /**
   * The alignment to use for tile objects (when Unspecified, uses Bottom alignment on isometric maps and BottomLeft alignment for all other maps).
   */
  objectAlignment : typeof Tileset.Unspecified | typeof Tileset.TopLeft | typeof Tileset.Top | typeof Tileset.TopRight | typeof Tileset.Left | typeof Tileset.Center | typeof Tileset.Right | typeof Tileset.BottomLeft | typeof Tileset.Bottom | typeof Tileset.BottomRight

  /**
   * The size to use when rendering tiles from this tileset on a tile layer.
   *
   * @since 1.9
   */
  tileRenderSize: typeof Tileset.GridSize | typeof Tileset.TileSize

  /**
   * The fill mode to use when rendering tiles from this tileset. Only relevant
   * when the tiles are not rendered at their native size.
   *
   * @since 1.9
   */
  fillMode : typeof Tileset.Stretch | typeof Tileset.PreserveAspectFit

  /**
   * Offset in pixels that is applied when tiles from this tileset are rendered.
   */
  tileOffset : point

  /**
   * The orientation of this tileset (used when rendering overlays and in the tile collision editor).
   */
  orientation : typeof Tileset.Orthogonal | typeof Tileset.Isometric

  /**
   * Color used as transparent color when rendering tiles from this tileset.
   *
   * This property is currently not supported for image collection tilesets.
   *
   * @note Changing this property will cause an image-based tileset to update
   * all its tiles. When setting up a tileset, you'll want to set this property
   * before setting the {@link image} property.
   */
  transparentColor: color;

  /**
   * Background color for this tileset in the Tilesets view.
   */
  backgroundColor : color

  /**
   * Whether this tileset is a collection of images (same as checking whether image is an empty string).
   *
   * @deprecated Use {@link isCollection} instead.
   */
  readonly collection : boolean

  /**
   * Whether this tileset is a collection of images (same as checking whether image is an empty string).
   *
   * @since 1.10
   */
  readonly isCollection : boolean

  /**
   * Selected tiles in the tileset editor.
   *
   * See {@link TilesetsView.selectedTiles} for getting the selected tiles in
   * the Tilesets view.
   */
  selectedTiles : Tile[]

  /**
   * Constructs a new Tileset.
   */
  constructor(name? : string)

  /**
   * Returns a reference to the tile with the given ID. Raises an error if no such tile exists. When the tile gets removed from the tileset, the reference changes to a standalone copy of the tile.
   *
   * Note that the tiles in a tileset are only guaranteed to have consecutive IDs for tileset-image based tilesets. For image collection tilesets there will be gaps when tiles have been removed from the tileset.
   */
  public tile(id : number) : Tile

  /**
   * Returns a reference to the tile with the given ID, or `null` if no such tile exists. When the tile gets removed from the tileset, the reference changes to a standalone copy of the tile.
   *
   * Note that the tiles in a tileset are only guaranteed to have consecutive IDs for tileset-image based tilesets. For image collection tilesets there will be gaps when tiles have been removed from the tileset.
   *
   * @since 1.9.2
   */
  public findTile(id : number) : Tile | null

  /**
   * Sets the tile size for this tileset. If an image has been specified as well, the tileset will be (re)loaded. Can’t be used on image collection tilesets.
   */
  public setTileSize(width : number, height : number) : void

  /**
   * Creates the tiles in this tileset by cutting them out of the given image, using the current tile size, tile spacing and margin parameters. These values should be set before calling this function.
   *
   * Optionally sets the source file of the image. This may be useful, but be careful since Tiled will try to reload the tileset from that source when the tileset parameters are changed.
   *
   * @note Usually you'll just want to assign the image file name to the {@link imageFileName} property!
   *
   * @warning This function has no undo!
   */
  public loadFromImage(image : Image, source?: string) : void

  /**
   * Adds a new tile to this tileset and returns it. Only works for image collection tilesets.
   */
  public addTile() : Tile

  /**
   * Removes the given tiles from this tileset. Only works for image collection tilesets.
   */
  public removeTiles(tiles : Tile[]) : void

  /**
   * Add a new Wang set to this tileset with the given name and type.
   */
  public addWangSet(name : string, type : typeof WangSet.Edge | typeof WangSet.Corner | typeof WangSet.Mixed) : WangSet

  /**
   * Removes the given Wang set from this tileset.
   */
  public removeWangSet(wangSet : WangSet) : void
}

/**
 * The interface that should be implemented for objects passed to {@link
 * tiled.registerTilesetFormat}.
 */
interface ScriptedTilesetFormat {
  /**
   * Name of the format as shown in the file dialog.
   */
  readonly name: string;

  /**
   * The file extension used by the format.
   */
  readonly extension: string;

  /**
   * A function that reads a tileset from the given file.
   *
   * Can use {@link TextFile} or {@link BinaryFile} to read the file.
   */
  read?(fileName: string): Tileset;

  /**
   * A function that writes a tileset to the given file.
   *
   * Can use {@link TextFile} or {@link BinaryFile} to write the file.
   * When a non-empty string is returned, it is shown as error message.
   */
  write?(tileset: Tileset, fileName: string) : string | undefined;
}

/**
 * A view displaying a map.
 */
interface MapView {
  /**
   * The scale of the view.
   */
  scale : number

  /**
   * The center of the view.
   */
  center : point

  /**
   * Centers the view at the given location in screen coordinates. Same as
   * assigning to the center property.
   */
  centerOn(x : number, y : number) : void
}

/**
 * The tile collision editor, accessible through
 * {@link TilesetEditor.collisionEditor}.
 */
interface TileCollisionEditor {
  /**
   * Selected objects.
   */
  selectedObjects : MapObject[]

  /**
   * The map view used by the Collision Editor.
   */
  view : MapView

  /**
   * Focuses the given object in the collision editor view and makes sure it is
   * visible in its objects list. Does not automatically select the object.
   */
  focusObject(object : MapObject) : void
}

/**
 * The tileset editor, accessible through {@link tiled.tilesetEditor}.
 */
interface TilesetEditor {
  /**
   * Access the collision editor within the tileset editor.
   */
  readonly collisionEditor : TileCollisionEditor

  /**
   * Gets the currently selected {@link WangSet} in the "Terrain Sets" view.
   *
   * @since 1.9
   */
  readonly currentWangSet: WangSet

  /**
   * The signal emitted when {@link currentWangSet} changes.
   *
   * @since 1.9
   */
  readonly currentWangSetChanged: Signal<void>;

  /**
   * Gets the currently selected Wang color index in the "Terrain Sets" view.
   * The value 0 is used to represent the eraser mode, and the first Wang color
   * has index 1.
   *
   * @since 1.9
   */
  readonly currentWangColorIndex: number

  /**
   * The signal emitted when {@link currentWangColorIndex} changes.
   *
   * @since 1.9
   */
  readonly currentWangColorIndexChanged: Signal<number>;
}

/**
 * This interface can be implemented to define a custom tool. See
 * {@link tiled.registerTool} for an example.
 *
 * The mouse button parameters are numbers from the
 * [Qt::MouseButton](https://doc.qt.io/qt-6/qt.html#MouseButton-enum) enum.
 * They can be accessed like `Qt.LeftButton`.
 *
 * Whenever there is a keyboard modifiers parameter, they are given as flags
 * from the [Qt::KeyboarModifiers](https://doc.qt.io/qt-6/qt.html#KeyboardModifier-enum)
 * enum, available similarly like `Qt.ShiftModifier`.
 */
interface ToolDefinition {
  /**
   * Name of the tool as shown on the tool bar.
   */
  name: string;

  /**
   * File name of an icon. If set, the icon is shown on the tool bar and the name becomes the tool tip.
   */
  icon?: string;

  /**
   * List of action IDs, specifying the actions that should be added to the
   * tool-specific tool bar.
   *
   * Separators can be added to this tool bar by adding "-" in the list of
   * actions.
   *
   * The actions need to be registered using
   * {@link registerAction | tiled.registerAction()}.
   *
   * @since 1.9
   */
  toolBarActions?: string[];

  /**
   * Whether this tool uses the currently selected tiles. This defaults to
   * `false`.
   *
   * When set to `false` and the currently selected tiles change while this
   * tool is active, the Stamp Brush is automatically activated. Set this
   * property to `true` to keep this tool active.
   *
   * @since 1.8
   */
  usesSelectedTiles?: boolean;

  /**
   * Whether this tool works with Wang sets. This defaults to `false`.
   *
   * When set to `false` and a Wang color is clicked while this tool is active,
   * the Terrain Brush is automatically activated. Set this property to `true`
   * to keep this tool active.
   *
   * @since 1.8
   */
  usesWangSets?: boolean;

  /**
   * The target layer type for which this tool should be enabled. A convenient
   * alternative to overriding {@link updateEnabledState}.
   *
   * The value can be any combination of the layer types
   * {@link Layer.TileLayerType}, {@link Layer.ObjectGroupType},
   * {@link Layer.ImageLayerType} and {@link Layer.GroupLayerType}.
   *
   * @since 1.10
   */
  targetLayerType?: number;

  /**
   * Called when the tool was activated.
   */
  activated?(this: Tool): void;

  /**
   * Called when the tool was deactivated.
   */
  deactivated?(this: Tool): void;

  /**
   * Called when a key was pressed while the tool was active.
   *
   * The keys are defined by numbers from the
   * [Qt::Key](https://doc.qt.io/qt-6/qt.html#Key-enum) enum. They can
   * be accessed like `Qt.Key_Return`.
   */
  keyPressed?(this: Tool, key: number, modifiers: number): void;

  /**
   * Called when the mouse entered the map view.
   */
  mouseEntered?(this: Tool): void;

  /**
   * Called when the mouse left the map view.
   */
  mouseLeft?(this: Tool): void;

  /**
   * Called when the mouse position in the map scene changed.
   */
  mouseMoved?(this: Tool, x: number, y: number, modifiers: number): void;

  /**
   * Called when a mouse button was pressed.
   */
  mousePressed?(this: Tool, button: number, x: number, y: number, modifiers: number): void;

  /**
   * Called when a mouse button was released.
   */
  mouseReleased?(this: Tool, button: number, x: number, y: number, modifiers: number): void;

  /**
   * Called when a mouse button was double-clicked.
   */
  mouseDoubleClicked?(this: Tool, button: number, x: number, y: number, modifiers: number): void;

  /**
   * Called when the active modifier keys changed.
   */
  modifiersChanged?(this: Tool, modifiers: number): void;

  /**
   * Called when the language was changed.
   */
  languageChanged?(this: Tool): void;

  /**
   * Called when the active map was changed.
   */
  mapChanged?(this: Tool, oldMap: TileMap | null, newMap: TileMap | null): void;

  /**
   * Called when the hovered tile position changed.
   */
  tilePositionChanged?(this: Tool): void;

  /**
   * Defining this function is necessary to suppress the default updating of
   * the status bar text.
   *
   * This function is called automatically when the hovered tile position
   * changed, but {@link statusInfo} can be changed in any other function as
   * well.
   */
  updateStatusInfo?(this: Tool): void;

  /**
   * Called when the map or the current layer changed.
   */
  updateEnabledState?(this: Tool): void;
}

/**
 * Once a tool is registered using {@link tiled.registerTool}, it returns a
 * tool instance. This interface extends the {@link ToolDefinition} interface
 * with the additional properties that are available on the tool instance.
 *
 * Not all properties in the {@link ToolDefinition} interface can be changed
 * after the tool has been registered.
 */
interface Tool extends ToolDefinition {
  /**
   * File name of the icon, or empty string when not set.
   */
  icon: string;

  /**
   * @see ToolDefinition.toolBarActions
   */
  toolBarActions: string[];

  /**
   * Currently active tile map.
   */
  readonly map: TileMap | null;

  /**
   * The last clicked tile for the active map. See also the {@link MapEditor.currentBrush} property.
   */
  readonly selectedTile: Tile | null;

  /**
   * Get or set the preview for tile layer edits.
   *
   * When getting or setting this property, a copy is made. To modify the
   * preview, you need to assign a changed {@link TileMap} instance to this
   * property.
   *
   * To highlight areas that will be erased, use {@link TileLayerEdit.setTile}
   * to set tiles to `null`, before assigning the map to the preview.
   */
  preview: TileMap;

  /**
   * Mouse cursor position in tile coordinates.
   */
  readonly tilePosition: point;

  /**
   * Text shown in the status bar while the tool is active.
   */
  statusInfo: string;

  /**
   * The cursor used by this tool. This will be the cursor set on the viewport
   * of the {@link MapView} while the tool is active.
   *
   * A {@link Qt.QCursor} value can be created with {@link tiled.cursor}.
   */
  cursor: Qt.QCursor;

  /**
   * Whether this tool is enabled.
   */
  enabled: boolean;
}

declare namespace Tiled {
  /**
   * Compression methods used for the {@link tiled.compress} and
   * {@link tiled.decompress} functions.
   */
  type CompressionMethod = number;

  const Gzip: CompressionMethod;
  const Zlib: CompressionMethod;
  const Zstandard: CompressionMethod;
}

/**
 * The `tiled` module is the main entry point and provides properties,
 * functions and signals which are documented below.
 */
declare namespace tiled {
  /**
   * Currently used version of Tiled.
   */
  export const version: string;

  /**
   * When given two versions, returns whether the first version comes before
   * the second version. When given one version, it returns whether Tiled's
   * current {@link version} comes before the given version.
   *
   * @since 1.10
   */
  export function versionLessThan(a: string, b?: string): boolean;

  /**
   * The version of Qt which Tiled is running against.
   *
   * @since 1.8.5
   */
  export const qtVersion: string;

  /**
   * Operating system. One of `windows`, `macos`, `linux` or
   * `unix` (for any other UNIX-like system).
   */
  export const platform: string;

  /**
   * Processor architecture. One of `x64`, `x86` or `unknown`.
   */
  export const arch: string;

  /**
   * The directory containing the Tiled executable.
   *
   * @since 1.8
   */
  export const applicationDirPath: string;

  /**
   * The system- and user-specific path where global extensions are installed.
   *
   * Note that normally it is not necessary to use this path, since the "ext:"
   * prefix can be used to refer to files shipping with extensions. Also, there
   * is a `__filename` property containing the full file path of the currently
   * evaluated file.
   *
   * Also note that a Tiled project can have its own additional extensions
   * directory, to make it easier to share extensions with a team or keep them
   * under version control.
   *
   * @since 1.8
   */
  export const extensionsPath: string;

  /**
   * The file path of the currently loaded project, or empty if no project is
   * currently loaded.
   *
   * @since 1.10
   */
  export const projectFilePath: string;

  /**
   * A list of arguments passed to a script that is evaluated from the
   * command-line.
   *
   * Scripts can be executed on the command-line using
   * `tiled --evaluate <script-file> [args]`.
   *
   * @since 1.9
   */
  export const scriptArguments: string[];

  /**
   * Available actions for {@link trigger | tiled.trigger()}.
   */
  export const actions: string[];

  /**
   * Available menus for {@link extendMenu | tiled.extendMenu()}.
   */
  export const menus: string[];

  /**
   * Currently selected asset, or `null` if no file is open.
   * Can be assigned any open asset in order to change the active asset, or
   * a newly created asset to open it in the editor.
   */
  export let activeAsset: Asset | null;

  /**
   * Currently opened project. If no project is open, the properties of the
   * project will be blank.
   *
   * @since 1.10.1
   */
  export const project: Project;

  /**
   * List of currently opened {@link Asset | assets}.
   */
  export const openAssets: Asset[];

  /**
   * List of supported tileset format names. Use {@link tilesetFormat}
   * to get the corresponding format object to read and write files.
   *
   * @since 1.4
   */
  export const tilesetFormats: string[];

  /**
   * List of supported map format names. Use {@link mapFormat} to get
   * the corresponding format object to read and write files.
   *
   * @since 1.4
   */
  export const mapFormats: string[];

  /**
   * Access the editor used when editing maps.
   */
  export const mapEditor: MapEditor;

  /**
   * Access the editor used when editing tilesets.
   */
  export const tilesetEditor: TilesetEditor;

  /**
   * This function can be used to trigger any registered action. This
   * includes most actions you would normally trigger through the menu or
   * by using their shortcut.
   *
   * Use the {@link actions | tiled.actions} property to get a list
   * of all available actions.
   *
   * Actions that are checkable will toggle when triggered.
   */
  export function trigger(action: string): void;

  /**
   * Executes the first custom command with the given name, as if it was
   * triggered manually. Works also with commands that are not currently
   * enabled.
   *
   * Raises a script error if the command is not found.
   *
   * For more control over the executed binary, use {@link Process} instead.
   */
  export function executeCommand(name: string, inTerminal: boolean): void;

  /**
   * Requests to open the asset with the given file name. Returns a
   * reference to the opened asset, or `null` in case there was a
   * problem.
   */
  export function open(fileName: string): Asset | null;

  /**
   * Closes the given asset without checking for unsaved changes (to
   * confirm the loss of any unsaved changes, set {@link activeAsset} and
   * trigger the "Close" action instead).
   */
  export function close(asset: Asset): boolean;

  /**
   * Reloads the given asset from disk, without checking for unsaved
   * changes. This invalidates the previous script reference to the
   * asset, hence the new reference is returned for convenience. Returns
   * `null` if reloading failed.
   */
  export function reload(asset: Asset): Asset | null;

  /**
   * Shows a modal warning dialog to the user with the given text and
   * optional title.
   */
  export function alert(text: string, title?: string): void;

  /**
   * Shows a yes/no dialog to the user with the given text and optional
    title. Returns `true` or `false`.
   */
  export function confirm(text: string, title?: string): boolean;

  /**
   * Shows a dialog that asks the user to enter some text, along with the
   * given label and optional title. The optional `text` parameter
   * provides the initial value of the text. Returns the entered text.
   *
   * For more complex input requirements, consider creating a custom
   * {@link Dialog}.
   */
  export function prompt(label: string, text?: string, title?: string): string;

  /**
   * Shows a dialog which asks the user to choose an existing directory.
   * Optionally override the starting directory of the dialog or its title.
   *
   * Returns the absolute path of the chosen directory, or an empty string if
   * the user cancels the dialog.
   *
   * @since 1.10.2
   */
  export function promptDirectory(defaultDir?: string, title?: string): string;

  /**
   * Shows a dialog which asks the user to choose one or more existing files.
   * Optionally override the starting directory of the dialog or its title.
   * You can also restrict to only certain file types by specifying {@link FileFilter|filters}.
   *
   * Returns an array of the absolute paths of the chosen files, or an empty
   * array if the user cancels the dialog.
   *
   * @since 1.10.2
   */
  export function promptOpenFiles(defaultDir?: string, filters?: FileFilter, title?: string): string[];

  /**
   * Shows a dialog which asks the user to choose an existing file.
   * Optionally override the starting directory of the dialog or its title.
   * You can also restrict to only certain file types by specifying {@link FileFilter|filters}.
   *
   * Returns the absolute path of the chosen file, or an empty string if the
   * user cancels the dialog.
   *
   * @since 1.10.2
   */
  export function promptOpenFile(defaultDir?: string, filters?: FileFilter, title?: string): string;

  /**
   * Shows a dialog which asks the user to choose a destination for saving a file.
   * If the user chooses a file path which already exists, they will be asked to confirm that they want to overwrite the file.
   * Optionally override the starting directory of the dialog or its title.
   * You can also restrict to only certain file types by specifying {@link FileFilter|filters}.
   *
   * Returns the absolute path of the chosen file, or an empty string if the
   * user cancels the dialog.
   *
   * @since 1.10.2
   */
  export function promptSaveFile(defaultDir?: string, filters?: string, title?: string): string;

  /**
   * Outputs the given text in the Console window as regular text.
   */
  export function log(text: string): void;

  /**
   * Outputs the given text in the Console window as warning message and
   * creates an issue in the Issues window.
   *
   * When the issue is activated (with double-click or Enter key) the
   * given callback function is invoked.
   */
  export function warn(text: string, activated: () => void): void;

  /**
   * Outputs the given text in the Console window as error message and
   * creates an issue in the Issues window.
   *
   * When the issue is activated (with double-click or Enter key) the
   * given callback function is invoked.
   */
  export function error(text: string, activated: () => void): void;

  /**
   * Extends the menu with the given ID. Supports both a list of items or
   * a single item. Available menu IDs can be obtained using the
   * {@link tiled.menus} property.
   *
   * If a menu item does not include a `before` property, the value is
   * inherited from the previous item. When this property is not set at
   * all, the items are appended to the end of the menu.
   *
   * Example that adds a custom action to the "Edit" menu, before the
   * "Select All" action and separated by a separator:
   *
   * ```js
   * tiled.extendMenu("Edit", [
   *     { action: "CustomAction", before: "SelectAll" },
   *     { separator: true }
   * ]);
   * ```
   *
   * The "CustomAction" will need to have been registered before using
   * {@link registerAction | tiled.registerAction()}.
   */
  export function extendMenu(
    shortName: string,
    menu: MenuItem[]
  ): void;

  /**
   * Registers a new action with the given `id` and `callback` (which is
   * called when the action is triggered). The returned action object can
   * be used to set (and update) various properties of the action.
   *
   * The shortcut will currently only work when the action is added to a
   * menu using {@link extendMenu | tiled.extendMenu()}.
   *
   * @example
   * ```js
   * var action = tiled.registerAction("CustomAction", function(action) {
   *     tiled.log(action.text + " was " + (action.checked ? "checked" : "unchecked"))
   * })
   *
   * action.text = "My Custom Action"
   * action.checkable = true
   * action.shortcut = "Ctrl+K"
   * ```
   */
  export function registerAction(
    id: string,
    callback: (action: Action) => void
  ): Action;

  /**
   * Registers a custom tool that will become available on the Tools tool
   * bar of the Map Editor.
   *
   * If a tool is already registered with the same `shortName` the
   * existing tool is replaced.
   *
   * @example
   * Here is an example tool that places a rectangle each time the mouse
   * has moved by 32 pixels:
   *
   * ```js
   * var tool = tiled.registerTool("PlaceRectangles", {
   *     name: "Place Rectangles",
   *
   *     mouseMoved: function(x, y, modifiers) {
   *         if (!this.pressed)
   *             return
   *
   *         var dx = Math.abs(this.x - x)
   *         var dy = Math.abs(this.y - y)
   *
   *         this.distance += Math.sqrt(dx*dx + dy*dy)
   *         this.x = x
   *         this.y = y
   *
   *         if (this.distance > 32) {
   *             var objectLayer = this.map.currentLayer
   *
   *             if (objectLayer && objectLayer.isObjectLayer) {
   *                 var object = new MapObject(MapObject.Rectangle, ++this.counter)
   *                 object.x = Math.min(this.lastX, x)
   *                 object.y = Math.min(this.lastY, y)
   *                 object.width = Math.abs(this.lastX - x)
   *                 object.height = Math.abs(this.lastY - y)
   *                 objectLayer.addObject(object)
   *             }
   *
   *             this.distance = 0
   *             this.lastX = x
   *             this.lastY = y
   *         }
   *     },
   *
   *     mousePressed: function(button, x, y, modifiers) {
   *         this.pressed = true
   *         this.x = x
   *         this.y = y
   *         this.distance = 0
   *         this.counter = 0
   *         this.lastX = x
   *         this.lastY = y
   *     },
   *
   *     mouseReleased: function(button, x, y, modifiers) {
   *         this.pressed = false
   *     },
   * })
   * ```
   */
  export function registerTool(shortName: string, tool: ToolDefinition): Tool;

  /**
   * Returns the tileset format object with the given name, or
    `undefined` if no object was found. See the
    {@link tilesetFormats} property for more info.
   */
  export function tilesetFormat(shortName: string): TilesetFormat | undefined;

  /**
   * Returns the tileset format object that can read the given file, or
    `undefined` if no object was found.
   */
  export function tilesetFormatForFile(fileName: string): TilesetFormat | undefined;

  /**
   * Returns the map format object with the given name, or
   * `undefined` if no object was found. See the
   * {@link mapFormats} property for more info.
   */
  export function mapFormat(shortName: string): MapFormat | undefined;

  /**
   * Returns the map format object that can read the given file, or
   * `undefined` if no object was found.
   */
  export function mapFormatForFile(fileName: string): MapFormat | undefined;

  /**
   * Creates a {@link color} based on the given color name (i.e. red or #ff0000).
   *
   * See [QColor::fromString](https://doc.qt.io/qt-6/qcolor.html#fromString)
   * for the accepted color names.
   *
   * @since 1.11
   */
  export function color(name: string): color;

  /**
   * Creates a {@link color} with the RGB value r, g, b, and the alpha-channel
   * (transparency) value of a (which defaults to 1.0).
   *
   * @since 1.11
   */
  export function color(r: number, g: number, b: number, a?: number): color;

  /**
   * Creates a {@link FilePath} object with the given URL.
   */
  export function filePath(path: string): FilePath;

  /**
   * Creates an {@link ObjectRef} object with the given ID.
   */
  export function objectRef(id: number): ObjectRef;

  /**
   * Creates a {@link PropertyValue} object with the given type and value.
   *
   * When creating an enum value, the name of the value can be used (or string
   * with comma-separated names, in case of using flags). However, the created
   * {@link PropertyValue} object will always use numbers for enum values.
   *
   * @example
   * Creating a value of a custom enum:
   * ```js
   * var bodyType = tiled.propertyValue("BodyType", "Dynamic")
   * ```
   *
   * @example
   * Creating a value of a custom class:
   * ```js
   * var body = tiled.propertyValue("Body", { type: bodyType, bullet: true })
   * ```
   *
   * @since 1.8
   */
  export function propertyValue(type: string, value: object | number | string): PropertyValue;

  /**
   * Creates a cursor with the given shape.
   *
   * @since 1.11.1
   */
  export function cursor(shape: Qt.CursorShape): Qt.QCursor;

  /**
   * Creates a cursor with the given image and the optional hotspot.
   *
   * @since 1.11.1
   */
  export function cursor(image: Image, hotX?: number, hotY?: number): Qt.QCursor;

  /**
   * Registers a new map format that can then be used to open and/or save
   * maps in that format.
   *
   * If a map format is already registered with the same `shortName`, the
   * existing format is replaced. The short name can also be used to
   * specify the format when using `--export-map` on the command-line, in
   * case the file extension is ambiguous or a different one should be
   * used.
   *
   * @example
   * Example that produces a simple JSON representation of a map:
   * ```js
   * var customMapFormat = {
   *     name: "Custom map format",
   *     extension: "custom",
   *
   *     write: function(map, fileName) {
   *         var m = {
   *             width: map.width,
   *             height: map.height,
   *             layers: []
   *         };
   *
   *         for (var i = 0; i < map.layerCount; ++i) {
   *             var layer = map.layerAt(i);
   *             if (layer.isTileLayer) {
   *                 var rows = [];
   *                 for (y = 0; y < layer.height; ++y) {
   *                     var row = [];
   *                     for (x = 0; x < layer.width; ++x)
   *                         row.push(layer.cellAt(x, y).tileId);
   *                     rows.push(row);
   *                 }
   *                 m.layers.push(rows);
   *             }
   *         }
   *
   *         var file = new TextFile(fileName, TextFile.WriteOnly);
   *         file.write(JSON.stringify(m));
   *         file.commit();
   *     },
   * }
   *
   * tiled.registerMapFormat("custom", customMapFormat)
   * ```
   */
  export function registerMapFormat(
    shortName: string,
    mapFormat: ScriptedMapFormat
  ): void;

  /**
   * Like {@link registerMapFormat}, but registers a custom tileset
   * format instead.
   */
  export function registerTilesetFormat(
    shortName: string,
    tilesetFormat: ScriptedTilesetFormat
  ): void;

  /**
   * Compresses the given data using the given compression method and
   * compression level.
   *
   * When no compression method is given, defaults to Zlib compression. The
   * compression level defaults to the default for the respective method.
   *
   * @example
   * Example that compresses data using Gzip compression:
   * ```js
   * buffer = tiled.compress(buffer, Tiled.Gzip);
   * ```
   *
   * @since 1.10
   */
  export function compress(data: ArrayBuffer | string, method?: Tiled.CompressionMethod, compressionLevel?: number): ArrayBuffer;

  /**
   * Decompresses the given data using the given compression method.
   *
   * When no compression method is given, defaults to Zlib compression.
   *
   * @since 1.10
   */
  export function decompress(data: ArrayBuffer | string, method?: Tiled.CompressionMethod): ArrayBuffer;

  /**
   * A new asset has been created.
   */
  export const assetCreated: Signal<Asset>;

  /**
   * An asset has been opened.
   */
  export const assetOpened: Signal<Asset>;

  /**
   * An asset has been reloaded.
   *
   * @since 1.11
   */
  export const assetReloaded: Signal<Asset>;

  /**
   * An asset is about to be saved. Can be used to make last-minute
   * changes.
   */
  export const assetAboutToBeSaved: Signal<Asset>;

  /**
   * An asset has been saved.
   */
  export const assetSaved: Signal<Asset>;

  /**
   * An asset is about to be closed.
   */
  export const assetAboutToBeClosed: Signal<Asset>;

  /**
   * The {@link activeAsset} has changed.
   */
  export const activeAssetChanged: Signal<Asset>;

  /**
   * A list of all currently loaded {@link World|worlds}.
   * @since 1.11
   */
  export const worlds : World[];

  /**
   * Load a world contained in a .world file in the path fileName.
   * @since 1.11
   */
  export function loadWorld(fileName : string) : void;

  /**
   * Unload a world contained in a .world file in the path fileName.
   * @since 1.11
   */
  export function unloadWorld(fileName : string) : void;

  /**
   * Unload all currently loaded worlds.
   * @since 1.11
   */
  export function unloadAllWorlds() : void;

  /**
   * Signal emitted when any world is loaded, unloaded, reloaded or changed.
   * @since 1.11
   */
  export const worldsChanged : Signal<void>;
}

/**
 * The Process class allows you to start processes, track their output, and so on.
 *
 * @since 1.5
 */
declare class Process {
  /**
   * The directory the process will be started in. This only has an effect if set before the process is started.
   */
  workingDirectory : string

  /**
   * True if there is no more data to be read from the process output, otherwise false.
   */
  readonly atEnd : boolean

  /**
   * The exit code of the process. This is needed for retrieving the exit code from processes started via start(), rather than exec().
   */
  readonly exitCode : number

  /**
   * The text codec. The codec is used for reading and writing from and to the process, respectively. Common codecs are supported, for example: “UTF-8”, “UTF-16”, and “ISO 8859-1”.
   */
  codec: string

  /**
   * Allocates and returns a new Process object.
   */
  constructor()

  /**
   * Frees the resources associated with the process. It is recommended to always call this function as soon as you are finished with the process.
   */
  close() : void

  /**
   * Schedules the stdin channel of process to be closed. The channel will close once all data has been written to the process. After calling this function, any attempts to write to the process will do nothing.
   */
  closeWriteChannel() : void

  /**
   * Executes the program at filePath with the given argument list and blocks until the process is finished. If an error occurs (for example, there is no executable file at filePath) and throwOnError is true (the default), then a JavaScript exception will be thrown. Otherwise, -1 will be returned in case of an error. The normal return code is the exit code of the process.
   */
  exec(filePath : string, arguments : string[] , throwOnError? : boolean) : number

  /**
   * Returns the value of the variable varName in the process’ environment.
   */
  getEnv(name : string) : string

  /**
   * Kills the process, causing it to exit immediately.
   */
  kill() : void

  /**
   * Reads and returns one line of text from the process output, without the newline character(s).
   */
  readLine() : string

  /**
   * Reads and returns all data from the process’ standard error channel.
   */
  readStdErr() : string

  /**
   * Reads and returns all data from the process’ standard output channel.
   */
  readStdOut() : string

  /**
   * Sets the value of variable varName to varValue in the process environment. This only has an effect if called before the process is started.
   */
  setEnv(varName : string, varValue : string) : string

  /**
   * Starts the program at filePath with the given list of arguments. Returns true if the process could be started and false otherwise.
   *
   * Note: This call returns right after starting the process and should be used only if you need to interact with the process while it is running. Most of the time, you want to use exec() instead.
   */
  start(filePath : string, arguments : string[]) : boolean

  /**
   * Tries to terminate the process. This is not guaranteed to make the process exit immediately; if you need that, use kill().
   */
  terminate() : void

  /**
   * Blocks until the process has finished or timeout milliseconds have passed (default is 30000). Returns true if the process has finished and false if the operation has timed out. Calling this function only makes sense for processes started via start() (as opposed to exec()).
   */
  waitForFinished( msecs?:number ) : boolean

  /**
   * Writes text into the process’ input channel.
   */
  write(text : string) : void

  /**
   * Writes text, followed by a newline character, into the process’ input channel.
   */
  writeLine(text : string) : void
}

/**
 * A widget which allows the user to select a color.
 * When the color button is clicked, a color picker dialog will pop up.
 */
declare class ColorButton extends Qt.QWidget {
  /**
   * The currently selected color of the button.
   */
  color: color;

  /**
   * Signal emitted when the color is changed by the user.
   */
  colorChanged: Signal<color>;
}

/**
 * Widget with a button which opens a file picker dialog
 * and displays the path in the dialog.
 */
declare class FileEdit extends Qt.QWidget {
  /**
   * The current file path.
   *
   * @since 1.11
   */
  fileName: string;

  /**
   * The {@link Qt.QUrl} of the currently selected file.
   *
   * If you need the file path as a string, use the {@link fileName} property.
   */
  fileUrl: Qt.QUrl;

  /**
   * Signal emitted when the selected file changes.
   */
  fileUrlChanged: Signal<Qt.QUrl>;

  /**
   * If `true`, the user will be prompted for a directory rather than a file.
   * Defaults to `false`.
   */
  isDirectory: boolean;

  /**
   * When specified, only files that match the {@link FileFilter|filter} are shown.
   */
  filter: FileFilter;
}

/**
 * A widget that displays an {@link Image} on your dialog.
 */
declare class ImageWidget extends Qt.QWidget {
  /**
   * The image to be displayed in the widget
   */
  image: Image;
}

/**
 * The `Dialog` object is used to display a dialog to the user
 * which can be filled with a variety of widgets.
 *
 * The left-hand column of the dialog can only contain headings. If you call
 * {@link addHeading} without specifying maxWidth = true, your heading will be
 * placed in the left-hand column of the dialog.
 *
 * All other widgets will be placed in the right-hand side column. When you add
 * multiple instances of the same type of widget sequentially, they will be
 * grouped into the same row unless you call {@link addNewRow} in between
 * adding the widgets or change the {@link newRowMode} property.
 *
 * This type is an extension of the [QDialog](https://doc.qt.io/qt-6/qdialog.html) type from Qt.
 *
 * @since 1.9
 */
declare class Dialog extends Qt.QWidget {
  /**
   * The dialog was rejected. Value is 0.
   */
  static readonly Rejected: unique symbol

  /**
   * The dialog was accepted. Value is 1.
   */
  static readonly Accepted: unique symbol

  /**
   * Create a new dialog with the given window title.
   *
   * When not given the title defaults to "Script".
   */
  constructor(windowTitle?: string);


  /**
   * The default row layout mode.
   *
   * In this mode, if you add multiple of the same type of widget in a row,
   * (for instance by calling {@link addButton} twice in a row), the Dialog
   * will automatically group them into the same row.
   *
   * As soon as a differently typed widget is added, a new row will be added to
   * the dialog. The exception to this rule is the widget created by {@link
   * addLabel}, which will be mixed with any other widget types when using this
   * mode.
   */
  static readonly SameWidgetRows: unique symbol;

  /**
   * In this mode, the dialog will not add a new row unless you call
   * {@link addNewRow}, {@link addHeading} or {@link addSeparator}.
   */
  static readonly ManualRows: unique symbol;

  /**
   * In this mode, only one widget will be allowed in the right column.
   * A new row will be added after each time you place a widget in the right
   * column.
   */
  static readonly SingleWidgetRows: unique symbol;

  /**
   * Controls the automatic widget placement behavior of the dialog.
   * Defaults to {@link SameWidgetRows}.
   */
  newRowMode: typeof Dialog.SingleWidgetRows | typeof Dialog.SameWidgetRows | typeof Dialog.ManualRows;

  /**
   * Call this to force the next widget to go on a new row,
   * even if it is the same type widget as the last one you added.
   */
  addNewRow(): void;

  /**
   * Add a heading to the dialog with the given labelText. A heading will
   * always be the first widget in a row.
   *
   * If the optional maxWidth parameter is true, the heading will be expanded
   * to the full width of the dialog. Otherwise, it will be confined to the
   * left-hand column of the dialog.
   */
  addHeading(labelText:string, maxWidth?: boolean): Qt.QLabel;

  /**
   * Add a label to the dialog with the given test. A label will always be the
   * first widget in a row.
   */
  addLabel(labelText:string): Qt.QLabel;

  /**
   * Adds a separator line with optional label to the dialog.
   * Used to visually split up sections of the dialog.
   */
  addSeparator(labelText?:string): Qt.QFrame;

  /**
   * Adds an image widget that can display an image in a dialog.
   */
  addImage(labelText: string, image: Image): ImageWidget;

  /**
   * Add a {@link Qt.QSlider} widget to the dialog to allow a user to type a
   * numerical value or use up and down controls on the widget to manipulate
   * the value.
   *
   * This can be used to enter integer or decimal values.
   */
  addNumberInput(labelText?: string): Qt.QDoubleSpinBox;

  /**
   * Add a {@link Qt.QSlider} widget to the dialog to allow a user to
   * slide a handle within a number range.
   *
   * This can only be used to enter integer-type values.
   */
  addSlider(labelText?: string): Qt.QSlider;

  /**
   * Add a {@link Qt.QCheckBox} widget with the given text to the dialog.
   * Allows a user to toggle a boolean value.
   *
   * If the defaultValue parameter is true the checkbox is checked by default.
   */
  addCheckBox(text?: string, defaultValue?: boolean): Qt.QCheckBox;

  /**
   * Add a {@link Qt.QPushButton} widget with the given text to the dialog.
   * Allows the user to press a button that you can respond to the clicked
   * signal of.
   */
  addButton(text?: string): Qt.QPushButton;

  /**
   * Add a {@link Qt.QLineEdit} widget to the dialog to allow the user to enter
   * a single line of text. The initial text on the widget can be given by
   * defaultValue parameter.
   *
   * If the labelText is non-empty, a label widget will be added to the left of
   * the widget.
   */
  addTextInput(labelText?: string, defaultValue?: string): Qt.QLineEdit;

  /**
   * Add a {@link Qt.QTextEdit} widget to the dialog to allow the user to edit
   * multiple lines of text. Also allows display of rendered HTML by setting
   * the {@link Qt.QTextEdit.html} property. The initial text on the widget can
   * be given by defaultValue parameter.
   *
   * If the labelText is non-empty, a label widget will be added to the left of
   * the widget.
   */
  addTextEdit(labelText?: string, defaultValue?: string): Qt.QTextEdit;

  /**
   * Add a {@link Qt.QComboBox} widget (also known as a dropdown) allowing the
   * user to select one of the given values.
   *
   * If the labelText is non-empty, a label widget will be added to the left of
   * the widget.
   */
  addComboBox(labelText: string, values: string[]): Qt.QComboBox;

  /**
   * Add a {@link ColorButton} widget that allows the user to pick a color.
   *
   * If the labelText is non-empty, a label widget will be added to the left of
   * the widget.
   */
  addColorButton(labelText?: string): ColorButton;

  /**
   * Add a {@link FileEdit} widget with a button which opens a file picker
   * dialog and displays the path in the dialog.
   *
   * If the labelText is non-empty, a label widget will be added to the left of
   * the widget.
   */
  addFilePicker(labelText?: string): FileEdit;

  /**
   * Erase all of the widgets that you have added to the dialog.
   * Call this if you want to re-draw your dialog with a new configuration of widgets.
   */
  clear(): void;

  /**
   * Show the dialog. Call this after you have added all of your desired widgets.
   * This will not block your script until the dialog opens.
   *
   * To respond to the dialog closing, it is recommended to connect to the {@link finished}
   * signal.
   */
  show(): void;

  /**
   * Open the dialog, blocking your script until the Dialog has been
   * accepted or rejected.
   */
  exec(): typeof Dialog.Rejected | typeof Dialog.Accepted;

  /**
   * Close this dialog, setting its result code to {@link Dialog.Accepted}.
   */
  accept(): void;

  /**
   * Close this dialog, setting its result code to {@link Dialog.Rejected}.
   */
  reject(): void;

  /**
   * Close this dialog, setting its result code to {@link Dialog.Accepted} or
   * {@link Dialog.Rejected}.
   */
  done(resultCode: typeof Dialog.Rejected | typeof Dialog.Accepted): void;

  /**
   * Called when the dialog is closed via {@link accept} or the {@link done}
   * method is called with {@link Dialog.Accepted} as its argument.
   */
  accepted: Signal<void>;

  /**
   * Called when the dialog is closed via the X button, {@link reject}, or the
   * {@link done} method is called with {@link Dialog.Rejected} as its
   * argument.
   */
  rejected: Signal<void>;

  /**
   * Called when the dialog is closed or the {@link done} method is called.
   * The number value it provides is either {@link Dialog.Accepted} or
   * {@link Dialog.Rejected}.
   */
  finished: Signal<number>;

  /**
   * The title of your dialog.
   */
  windowTitle: string;
}