File size: 119,061 Bytes
cf07b75 7895d85 cf07b75 7895d85 cf07b75 9a6e6b1 cf07b75 7895d85 cf07b75 7895d85 cf07b75 |
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 |
import { H as HttpError, j as json, t as text, b as base, R as Redirect, S as SvelteKitError, o as override, r as reset, a as assets, A as ActionFailure } from './chunks/index-JNnR1J8_.js';
import { d as decode_pathname, h as has_data_suffix, s as strip_data_suffix, a as decode_params, n as normalize_path, b as disable_search, c as add_data_suffix, m as make_trackable, r as resolve } from './chunks/exports-mq_1S73-.js';
import { w as writable, r as readable } from './chunks/index2-KUnGpG6g.js';
import { p as public_env, s as safe_public_env, a as set_private_env, b as set_public_env, c as set_safe_public_env } from './chunks/shared-server-49TKSBDM.js';
import { c as create_ssr_component, s as setContext, v as validate_component, m as missing_component } from './chunks/ssr-IdY0EU5r.js';
/** @type {Record<string, string>} */
const escaped = {
'<': '\\u003C',
'\\': '\\\\',
'\b': '\\b',
'\f': '\\f',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t',
'\u2028': '\\u2028',
'\u2029': '\\u2029'
};
class DevalueError extends Error {
/**
* @param {string} message
* @param {string[]} keys
*/
constructor(message, keys) {
super(message);
this.name = 'DevalueError';
this.path = keys.join('');
}
}
/** @param {any} thing */
function is_primitive(thing) {
return Object(thing) !== thing;
}
const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
Object.prototype
)
.sort()
.join('\0');
/** @param {any} thing */
function is_plain_object(thing) {
const proto = Object.getPrototypeOf(thing);
return (
proto === Object.prototype ||
proto === null ||
Object.getOwnPropertyNames(proto).sort().join('\0') === object_proto_names
);
}
/** @param {any} thing */
function get_type(thing) {
return Object.prototype.toString.call(thing).slice(8, -1);
}
/** @param {string} char */
function get_escaped_char(char) {
switch (char) {
case '"':
return '\\"';
case '<':
return '\\u003C';
case '\\':
return '\\\\';
case '\n':
return '\\n';
case '\r':
return '\\r';
case '\t':
return '\\t';
case '\b':
return '\\b';
case '\f':
return '\\f';
case '\u2028':
return '\\u2028';
case '\u2029':
return '\\u2029';
default:
return char < ' '
? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`
: '';
}
}
/** @param {string} str */
function stringify_string(str) {
let result = '';
let last_pos = 0;
const len = str.length;
for (let i = 0; i < len; i += 1) {
const char = str[i];
const replacement = get_escaped_char(char);
if (replacement) {
result += str.slice(last_pos, i) + replacement;
last_pos = i + 1;
}
}
return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
}
const chars$1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
const reserved =
/^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
/**
* Turn a value into the JavaScript that creates an equivalent value
* @param {any} value
* @param {(value: any) => string | void} [replacer]
*/
function uneval(value, replacer) {
const counts = new Map();
/** @type {string[]} */
const keys = [];
const custom = new Map();
/** @param {any} thing */
function walk(thing) {
if (typeof thing === 'function') {
throw new DevalueError(`Cannot stringify a function`, keys);
}
if (!is_primitive(thing)) {
if (counts.has(thing)) {
counts.set(thing, counts.get(thing) + 1);
return;
}
counts.set(thing, 1);
if (replacer) {
const str = replacer(thing);
if (typeof str === 'string') {
custom.set(thing, str);
return;
}
}
const type = get_type(thing);
switch (type) {
case 'Number':
case 'BigInt':
case 'String':
case 'Boolean':
case 'Date':
case 'RegExp':
return;
case 'Array':
/** @type {any[]} */ (thing).forEach((value, i) => {
keys.push(`[${i}]`);
walk(value);
keys.pop();
});
break;
case 'Set':
Array.from(thing).forEach(walk);
break;
case 'Map':
for (const [key, value] of thing) {
keys.push(
`.get(${is_primitive(key) ? stringify_primitive$1(key) : '...'})`
);
walk(value);
keys.pop();
}
break;
default:
if (!is_plain_object(thing)) {
throw new DevalueError(
`Cannot stringify arbitrary non-POJOs`,
keys
);
}
if (Object.getOwnPropertySymbols(thing).length > 0) {
throw new DevalueError(
`Cannot stringify POJOs with symbolic keys`,
keys
);
}
for (const key in thing) {
keys.push(`.${key}`);
walk(thing[key]);
keys.pop();
}
}
}
}
walk(value);
const names = new Map();
Array.from(counts)
.filter((entry) => entry[1] > 1)
.sort((a, b) => b[1] - a[1])
.forEach((entry, i) => {
names.set(entry[0], get_name(i));
});
/**
* @param {any} thing
* @returns {string}
*/
function stringify(thing) {
if (names.has(thing)) {
return names.get(thing);
}
if (is_primitive(thing)) {
return stringify_primitive$1(thing);
}
if (custom.has(thing)) {
return custom.get(thing);
}
const type = get_type(thing);
switch (type) {
case 'Number':
case 'String':
case 'Boolean':
return `Object(${stringify(thing.valueOf())})`;
case 'RegExp':
return `new RegExp(${stringify_string(thing.source)}, "${
thing.flags
}")`;
case 'Date':
return `new Date(${thing.getTime()})`;
case 'Array':
const members = /** @type {any[]} */ (thing).map((v, i) =>
i in thing ? stringify(v) : ''
);
const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
return `[${members.join(',')}${tail}]`;
case 'Set':
case 'Map':
return `new ${type}([${Array.from(thing).map(stringify).join(',')}])`;
default:
const obj = `{${Object.keys(thing)
.map((key) => `${safe_key(key)}:${stringify(thing[key])}`)
.join(',')}}`;
const proto = Object.getPrototypeOf(thing);
if (proto === null) {
return Object.keys(thing).length > 0
? `Object.assign(Object.create(null),${obj})`
: `Object.create(null)`;
}
return obj;
}
}
const str = stringify(value);
if (names.size) {
/** @type {string[]} */
const params = [];
/** @type {string[]} */
const statements = [];
/** @type {string[]} */
const values = [];
names.forEach((name, thing) => {
params.push(name);
if (custom.has(thing)) {
values.push(/** @type {string} */ (custom.get(thing)));
return;
}
if (is_primitive(thing)) {
values.push(stringify_primitive$1(thing));
return;
}
const type = get_type(thing);
switch (type) {
case 'Number':
case 'String':
case 'Boolean':
values.push(`Object(${stringify(thing.valueOf())})`);
break;
case 'RegExp':
values.push(thing.toString());
break;
case 'Date':
values.push(`new Date(${thing.getTime()})`);
break;
case 'Array':
values.push(`Array(${thing.length})`);
/** @type {any[]} */ (thing).forEach((v, i) => {
statements.push(`${name}[${i}]=${stringify(v)}`);
});
break;
case 'Set':
values.push(`new Set`);
statements.push(
`${name}.${Array.from(thing)
.map((v) => `add(${stringify(v)})`)
.join('.')}`
);
break;
case 'Map':
values.push(`new Map`);
statements.push(
`${name}.${Array.from(thing)
.map(([k, v]) => `set(${stringify(k)}, ${stringify(v)})`)
.join('.')}`
);
break;
default:
values.push(
Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}'
);
Object.keys(thing).forEach((key) => {
statements.push(
`${name}${safe_prop(key)}=${stringify(thing[key])}`
);
});
}
});
statements.push(`return ${str}`);
return `(function(${params.join(',')}){${statements.join(
';'
)}}(${values.join(',')}))`;
} else {
return str;
}
}
/** @param {number} num */
function get_name(num) {
let name = '';
do {
name = chars$1[num % chars$1.length] + name;
num = ~~(num / chars$1.length) - 1;
} while (num >= 0);
return reserved.test(name) ? `${name}0` : name;
}
/** @param {string} c */
function escape_unsafe_char(c) {
return escaped[c] || c;
}
/** @param {string} str */
function escape_unsafe_chars(str) {
return str.replace(unsafe_chars, escape_unsafe_char);
}
/** @param {string} key */
function safe_key(key) {
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
? key
: escape_unsafe_chars(JSON.stringify(key));
}
/** @param {string} key */
function safe_prop(key) {
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key)
? `.${key}`
: `[${escape_unsafe_chars(JSON.stringify(key))}]`;
}
/** @param {any} thing */
function stringify_primitive$1(thing) {
if (typeof thing === 'string') return stringify_string(thing);
if (thing === void 0) return 'void 0';
if (thing === 0 && 1 / thing < 0) return '-0';
const str = String(thing);
if (typeof thing === 'number') return str.replace(/^(-)?0\./, '$1.');
if (typeof thing === 'bigint') return thing + 'n';
return str;
}
const UNDEFINED = -1;
const HOLE = -2;
const NAN = -3;
const POSITIVE_INFINITY = -4;
const NEGATIVE_INFINITY = -5;
const NEGATIVE_ZERO = -6;
/**
* Turn a value into a JSON string that can be parsed with `devalue.parse`
* @param {any} value
* @param {Record<string, (value: any) => any>} [reducers]
*/
function stringify(value, reducers) {
/** @type {any[]} */
const stringified = [];
/** @type {Map<any, number>} */
const indexes = new Map();
/** @type {Array<{ key: string, fn: (value: any) => any }>} */
const custom = [];
for (const key in reducers) {
custom.push({ key, fn: reducers[key] });
}
/** @type {string[]} */
const keys = [];
let p = 0;
/** @param {any} thing */
function flatten(thing) {
if (typeof thing === 'function') {
throw new DevalueError(`Cannot stringify a function`, keys);
}
if (indexes.has(thing)) return indexes.get(thing);
if (thing === undefined) return UNDEFINED;
if (Number.isNaN(thing)) return NAN;
if (thing === Infinity) return POSITIVE_INFINITY;
if (thing === -Infinity) return NEGATIVE_INFINITY;
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
const index = p++;
indexes.set(thing, index);
for (const { key, fn } of custom) {
const value = fn(thing);
if (value) {
stringified[index] = `["${key}",${flatten(value)}]`;
return index;
}
}
let str = '';
if (is_primitive(thing)) {
str = stringify_primitive(thing);
} else {
const type = get_type(thing);
switch (type) {
case 'Number':
case 'String':
case 'Boolean':
str = `["Object",${stringify_primitive(thing)}]`;
break;
case 'BigInt':
str = `["BigInt",${thing}]`;
break;
case 'Date':
str = `["Date","${thing.toISOString()}"]`;
break;
case 'RegExp':
const { source, flags } = thing;
str = flags
? `["RegExp",${stringify_string(source)},"${flags}"]`
: `["RegExp",${stringify_string(source)}]`;
break;
case 'Array':
str = '[';
for (let i = 0; i < thing.length; i += 1) {
if (i > 0) str += ',';
if (i in thing) {
keys.push(`[${i}]`);
str += flatten(thing[i]);
keys.pop();
} else {
str += HOLE;
}
}
str += ']';
break;
case 'Set':
str = '["Set"';
for (const value of thing) {
str += `,${flatten(value)}`;
}
str += ']';
break;
case 'Map':
str = '["Map"';
for (const [key, value] of thing) {
keys.push(
`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`
);
str += `,${flatten(key)},${flatten(value)}`;
}
str += ']';
break;
default:
if (!is_plain_object(thing)) {
throw new DevalueError(
`Cannot stringify arbitrary non-POJOs`,
keys
);
}
if (Object.getOwnPropertySymbols(thing).length > 0) {
throw new DevalueError(
`Cannot stringify POJOs with symbolic keys`,
keys
);
}
if (Object.getPrototypeOf(thing) === null) {
str = '["null"';
for (const key in thing) {
keys.push(`.${key}`);
str += `,${stringify_string(key)},${flatten(thing[key])}`;
keys.pop();
}
str += ']';
} else {
str = '{';
let started = false;
for (const key in thing) {
if (started) str += ',';
started = true;
keys.push(`.${key}`);
str += `${stringify_string(key)}:${flatten(thing[key])}`;
keys.pop();
}
str += '}';
}
}
}
stringified[index] = str;
return index;
}
const index = flatten(value);
// special case — value is represented as a negative index
if (index < 0) return `${index}`;
return `[${stringified.join(',')}]`;
}
/**
* @param {any} thing
* @returns {string}
*/
function stringify_primitive(thing) {
const type = typeof thing;
if (type === 'string') return stringify_string(thing);
if (thing instanceof String) return stringify_string(thing.toString());
if (thing === void 0) return UNDEFINED.toString();
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
if (type === 'bigint') return `["BigInt","${thing}"]`;
return String(thing);
}
var cookie = {};
/*!
* cookie
* Copyright(c) 2012-2014 Roman Shtylman
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
var hasRequiredCookie;
function requireCookie () {
if (hasRequiredCookie) return cookie;
hasRequiredCookie = 1;
/**
* Module exports.
* @public
*/
cookie.parse = parse;
cookie.serialize = serialize;
/**
* Module variables.
* @private
*/
var __toString = Object.prototype.toString;
/**
* RegExp to match field-content in RFC 7230 sec 3.2
*
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
* field-vchar = VCHAR / obs-text
* obs-text = %x80-FF
*/
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
/**
* Parse a cookie header.
*
* Parse the given cookie header string into an object
* The object has the various cookies as keys(names) => values
*
* @param {string} str
* @param {object} [options]
* @return {object}
* @public
*/
function parse(str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string');
}
var obj = {};
var opt = options || {};
var dec = opt.decode || decode;
var index = 0;
while (index < str.length) {
var eqIdx = str.indexOf('=', index);
// no more cookie pairs
if (eqIdx === -1) {
break
}
var endIdx = str.indexOf(';', index);
if (endIdx === -1) {
endIdx = str.length;
} else if (endIdx < eqIdx) {
// backtrack on prior semicolon
index = str.lastIndexOf(';', eqIdx - 1) + 1;
continue
}
var key = str.slice(index, eqIdx).trim();
// only assign once
if (undefined === obj[key]) {
var val = str.slice(eqIdx + 1, endIdx).trim();
// quoted values
if (val.charCodeAt(0) === 0x22) {
val = val.slice(1, -1);
}
obj[key] = tryDecode(val, dec);
}
index = endIdx + 1;
}
return obj;
}
/**
* Serialize data into a cookie header.
*
* Serialize the a name value pair into a cookie string suitable for
* http headers. An optional options object specified cookie parameters.
*
* serialize('foo', 'bar', { httpOnly: true })
* => "foo=bar; httpOnly"
*
* @param {string} name
* @param {string} val
* @param {object} [options]
* @return {string}
* @public
*/
function serialize(name, val, options) {
var opt = options || {};
var enc = opt.encode || encode;
if (typeof enc !== 'function') {
throw new TypeError('option encode is invalid');
}
if (!fieldContentRegExp.test(name)) {
throw new TypeError('argument name is invalid');
}
var value = enc(val);
if (value && !fieldContentRegExp.test(value)) {
throw new TypeError('argument val is invalid');
}
var str = name + '=' + value;
if (null != opt.maxAge) {
var maxAge = opt.maxAge - 0;
if (isNaN(maxAge) || !isFinite(maxAge)) {
throw new TypeError('option maxAge is invalid')
}
str += '; Max-Age=' + Math.floor(maxAge);
}
if (opt.domain) {
if (!fieldContentRegExp.test(opt.domain)) {
throw new TypeError('option domain is invalid');
}
str += '; Domain=' + opt.domain;
}
if (opt.path) {
if (!fieldContentRegExp.test(opt.path)) {
throw new TypeError('option path is invalid');
}
str += '; Path=' + opt.path;
}
if (opt.expires) {
var expires = opt.expires;
if (!isDate(expires) || isNaN(expires.valueOf())) {
throw new TypeError('option expires is invalid');
}
str += '; Expires=' + expires.toUTCString();
}
if (opt.httpOnly) {
str += '; HttpOnly';
}
if (opt.secure) {
str += '; Secure';
}
if (opt.partitioned) {
str += '; Partitioned';
}
if (opt.priority) {
var priority = typeof opt.priority === 'string'
? opt.priority.toLowerCase()
: opt.priority;
switch (priority) {
case 'low':
str += '; Priority=Low';
break
case 'medium':
str += '; Priority=Medium';
break
case 'high':
str += '; Priority=High';
break
default:
throw new TypeError('option priority is invalid')
}
}
if (opt.sameSite) {
var sameSite = typeof opt.sameSite === 'string'
? opt.sameSite.toLowerCase() : opt.sameSite;
switch (sameSite) {
case true:
str += '; SameSite=Strict';
break;
case 'lax':
str += '; SameSite=Lax';
break;
case 'strict':
str += '; SameSite=Strict';
break;
case 'none':
str += '; SameSite=None';
break;
default:
throw new TypeError('option sameSite is invalid');
}
}
return str;
}
/**
* URL-decode string value. Optimized to skip native call when no %.
*
* @param {string} str
* @returns {string}
*/
function decode (str) {
return str.indexOf('%') !== -1
? decodeURIComponent(str)
: str
}
/**
* URL-encode value.
*
* @param {string} val
* @returns {string}
*/
function encode (val) {
return encodeURIComponent(val)
}
/**
* Determine if value is a Date.
*
* @param {*} val
* @private
*/
function isDate (val) {
return __toString.call(val) === '[object Date]' ||
val instanceof Date
}
/**
* Try decoding a string using a decoding function.
*
* @param {string} str
* @param {function} decode
* @private
*/
function tryDecode(str, decode) {
try {
return decode(str);
} catch (e) {
return str;
}
}
return cookie;
}
var cookieExports = requireCookie();
var setCookie = {exports: {}};
var hasRequiredSetCookie;
function requireSetCookie () {
if (hasRequiredSetCookie) return setCookie.exports;
hasRequiredSetCookie = 1;
var defaultParseOptions = {
decodeValues: true,
map: false,
silent: false,
};
function isNonEmptyString(str) {
return typeof str === "string" && !!str.trim();
}
function parseString(setCookieValue, options) {
var parts = setCookieValue.split(";").filter(isNonEmptyString);
var nameValuePairStr = parts.shift();
var parsed = parseNameValuePair(nameValuePairStr);
var name = parsed.name;
var value = parsed.value;
options = options
? Object.assign({}, defaultParseOptions, options)
: defaultParseOptions;
try {
value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
} catch (e) {
console.error(
"set-cookie-parser encountered an error while decoding a cookie with value '" +
value +
"'. Set options.decodeValues to false to disable this feature.",
e
);
}
var cookie = {
name: name,
value: value,
};
parts.forEach(function (part) {
var sides = part.split("=");
var key = sides.shift().trimLeft().toLowerCase();
var value = sides.join("=");
if (key === "expires") {
cookie.expires = new Date(value);
} else if (key === "max-age") {
cookie.maxAge = parseInt(value, 10);
} else if (key === "secure") {
cookie.secure = true;
} else if (key === "httponly") {
cookie.httpOnly = true;
} else if (key === "samesite") {
cookie.sameSite = value;
} else {
cookie[key] = value;
}
});
return cookie;
}
function parseNameValuePair(nameValuePairStr) {
// Parses name-value-pair according to rfc6265bis draft
var name = "";
var value = "";
var nameValueArr = nameValuePairStr.split("=");
if (nameValueArr.length > 1) {
name = nameValueArr.shift();
value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
} else {
value = nameValuePairStr;
}
return { name: name, value: value };
}
function parse(input, options) {
options = options
? Object.assign({}, defaultParseOptions, options)
: defaultParseOptions;
if (!input) {
if (!options.map) {
return [];
} else {
return {};
}
}
if (input.headers) {
if (typeof input.headers.getSetCookie === "function") {
// for fetch responses - they combine headers of the same type in the headers array,
// but getSetCookie returns an uncombined array
input = input.headers.getSetCookie();
} else if (input.headers["set-cookie"]) {
// fast-path for node.js (which automatically normalizes header names to lower-case
input = input.headers["set-cookie"];
} else {
// slow-path for other environments - see #25
var sch =
input.headers[
Object.keys(input.headers).find(function (key) {
return key.toLowerCase() === "set-cookie";
})
];
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
if (!sch && input.headers.cookie && !options.silent) {
console.warn(
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
);
}
input = sch;
}
}
if (!Array.isArray(input)) {
input = [input];
}
options = options
? Object.assign({}, defaultParseOptions, options)
: defaultParseOptions;
if (!options.map) {
return input.filter(isNonEmptyString).map(function (str) {
return parseString(str, options);
});
} else {
var cookies = {};
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
var cookie = parseString(str, options);
cookies[cookie.name] = cookie;
return cookies;
}, cookies);
}
}
/*
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
that are within a single set-cookie field-value, such as in the Expires portion.
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
React Native's fetch does this for *every* header, including set-cookie.
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
*/
function splitCookiesString(cookiesString) {
if (Array.isArray(cookiesString)) {
return cookiesString;
}
if (typeof cookiesString !== "string") {
return [];
}
var cookiesStrings = [];
var pos = 0;
var start;
var ch;
var lastComma;
var nextStart;
var cookiesSeparatorFound;
function skipWhitespace() {
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
pos += 1;
}
return pos < cookiesString.length;
}
function notSpecialChar() {
ch = cookiesString.charAt(pos);
return ch !== "=" && ch !== ";" && ch !== ",";
}
while (pos < cookiesString.length) {
start = pos;
cookiesSeparatorFound = false;
while (skipWhitespace()) {
ch = cookiesString.charAt(pos);
if (ch === ",") {
// ',' is a cookie separator if we have later first '=', not ';' or ','
lastComma = pos;
pos += 1;
skipWhitespace();
nextStart = pos;
while (pos < cookiesString.length && notSpecialChar()) {
pos += 1;
}
// currently special character
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
// we found cookies separator
cookiesSeparatorFound = true;
// pos is inside the next cookie, so back up and return it.
pos = nextStart;
cookiesStrings.push(cookiesString.substring(start, lastComma));
start = pos;
} else {
// in param ',' or param separator ';',
// we continue from that comma
pos = lastComma + 1;
}
} else {
pos += 1;
}
}
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
}
}
return cookiesStrings;
}
setCookie.exports = parse;
setCookie.exports.parse = parse;
setCookie.exports.parseString = parseString;
setCookie.exports.splitCookiesString = splitCookiesString;
return setCookie.exports;
}
var setCookieExports = requireSetCookie();
function afterUpdate() {
}
const Root = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let { stores } = $$props;
let { page } = $$props;
let { constructors } = $$props;
let { components = [] } = $$props;
let { form } = $$props;
let { data_0 = null } = $$props;
let { data_1 = null } = $$props;
{
setContext("__svelte__", stores);
}
afterUpdate(stores.page.notify);
if ($$props.stores === void 0 && $$bindings.stores && stores !== void 0)
$$bindings.stores(stores);
if ($$props.page === void 0 && $$bindings.page && page !== void 0)
$$bindings.page(page);
if ($$props.constructors === void 0 && $$bindings.constructors && constructors !== void 0)
$$bindings.constructors(constructors);
if ($$props.components === void 0 && $$bindings.components && components !== void 0)
$$bindings.components(components);
if ($$props.form === void 0 && $$bindings.form && form !== void 0)
$$bindings.form(form);
if ($$props.data_0 === void 0 && $$bindings.data_0 && data_0 !== void 0)
$$bindings.data_0(data_0);
if ($$props.data_1 === void 0 && $$bindings.data_1 && data_1 !== void 0)
$$bindings.data_1(data_1);
let $$settled;
let $$rendered;
let previous_head = $$result.head;
do {
$$settled = true;
$$result.head = previous_head;
{
stores.page.set(page);
}
$$rendered = ` ${constructors[1] ? `${validate_component(constructors[0] || missing_component, "svelte:component").$$render(
$$result,
{ data: data_0, this: components[0] },
{
this: ($$value) => {
components[0] = $$value;
$$settled = false;
}
},
{
default: () => {
return `${validate_component(constructors[1] || missing_component, "svelte:component").$$render(
$$result,
{ data: data_1, form, this: components[1] },
{
this: ($$value) => {
components[1] = $$value;
$$settled = false;
}
},
{}
)}`;
}
}
)}` : `${validate_component(constructors[0] || missing_component, "svelte:component").$$render(
$$result,
{ data: data_0, form, this: components[0] },
{
this: ($$value) => {
components[0] = $$value;
$$settled = false;
}
},
{}
)}`} ${``}`;
} while (!$$settled);
return $$rendered;
});
const options = {
app_dir: "_app",
app_template_contains_nonce: false,
csp: { "mode": "auto", "directives": { "upgrade-insecure-requests": false, "block-all-mixed-content": false }, "reportOnly": { "upgrade-insecure-requests": false, "block-all-mixed-content": false } },
csrf_check_origin: true,
embedded: false,
env_public_prefix: "PUBLIC_",
env_private_prefix: "",
hooks: null,
// added lazily, via `get_hooks`
preload_strategy: "modulepreload",
root: Root,
service_worker: false,
templates: {
app: ({ head, body, assets, nonce, env }) => '<!doctype html>\r\n<html lang="en">\r\n <head>\r\n <meta charset="utf-8" />\r\n <link rel="icon" href="' + assets + '/favicon.png" />\r\n <meta name="viewport" content="width=device-width, initial-scale=1" />\r\n ' + head + '\r\n </head>\r\n <body data-sveltekit-preload-data="hover" data-theme="skeleton" style="overflow-x: hidden;">\r\n <div style="display: contents">' + body + "</div>\r\n </body>\r\n</html>\r\n",
error: ({ status, message }) => '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>' + message + `</title>
<style>
body {
--bg: white;
--fg: #222;
--divider: #ccc;
background: var(--bg);
color: var(--fg);
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Open Sans',
'Helvetica Neue',
sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.error {
display: flex;
align-items: center;
max-width: 32rem;
margin: 0 1rem;
}
.status {
font-weight: 200;
font-size: 3rem;
line-height: 1;
position: relative;
top: -0.05rem;
}
.message {
border-left: 1px solid var(--divider);
padding: 0 0 0 1rem;
margin: 0 0 0 1rem;
min-height: 2.5rem;
display: flex;
align-items: center;
}
.message h1 {
font-weight: 400;
font-size: 1em;
margin: 0;
}
@media (prefers-color-scheme: dark) {
body {
--bg: #222;
--fg: #ddd;
--divider: #666;
}
}
</style>
</head>
<body>
<div class="error">
<span class="status">` + status + '</span>\n <div class="message">\n <h1>' + message + "</h1>\n </div>\n </div>\n </body>\n</html>\n"
},
version_hash: "wweid4"
};
async function get_hooks() {
return {
...await import('./chunks/hooks.server-PjMICSnm.js')
};
}
const DEV = false;
const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
const PAGE_METHODS = ["GET", "POST", "HEAD"];
function negotiate(accept, types) {
const parts = [];
accept.split(",").forEach((str, i) => {
const match = /([^/]+)\/([^;]+)(?:;q=([0-9.]+))?/.exec(str);
if (match) {
const [, type, subtype, q = "1"] = match;
parts.push({ type, subtype, q: +q, i });
}
});
parts.sort((a, b) => {
if (a.q !== b.q) {
return b.q - a.q;
}
if (a.subtype === "*" !== (b.subtype === "*")) {
return a.subtype === "*" ? 1 : -1;
}
if (a.type === "*" !== (b.type === "*")) {
return a.type === "*" ? 1 : -1;
}
return a.i - b.i;
});
let accepted;
let min_priority = Infinity;
for (const mimetype of types) {
const [type, subtype] = mimetype.split("/");
const priority = parts.findIndex(
(part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*")
);
if (priority !== -1 && priority < min_priority) {
accepted = mimetype;
min_priority = priority;
}
}
return accepted;
}
function is_content_type(request, ...types) {
const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
return types.includes(type.toLowerCase());
}
function is_form_content_type(request) {
return is_content_type(
request,
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
);
}
function coalesce_to_error(err) {
return err instanceof Error || err && /** @type {any} */
err.name && /** @type {any} */
err.message ? (
/** @type {Error} */
err
) : new Error(JSON.stringify(err));
}
function normalize_error(error) {
return (
/** @type {import('../runtime/control.js').Redirect | HttpError | SvelteKitError | Error} */
error
);
}
function get_status(error) {
return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
}
function get_message(error) {
return error instanceof SvelteKitError ? error.text : "Internal Error";
}
function method_not_allowed(mod, method) {
return text(`${method} method not allowed`, {
status: 405,
headers: {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
// "The server must generate an Allow header field in a 405 status code response"
allow: allowed_methods(mod).join(", ")
}
});
}
function allowed_methods(mod) {
const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
if ("GET" in mod || "HEAD" in mod)
allowed.push("HEAD");
return allowed;
}
function static_error_page(options2, status, message) {
let page = options2.templates.error({ status, message });
return text(page, {
headers: { "content-type": "text/html; charset=utf-8" },
status
});
}
async function handle_fatal_error(event, options2, error) {
error = error instanceof HttpError ? error : coalesce_to_error(error);
const status = get_status(error);
const body2 = await handle_error_and_jsonify(event, options2, error);
const type = negotiate(event.request.headers.get("accept") || "text/html", [
"application/json",
"text/html"
]);
if (event.isDataRequest || type === "application/json") {
return json(body2, {
status
});
}
return static_error_page(options2, status, body2.message);
}
async function handle_error_and_jsonify(event, options2, error) {
if (error instanceof HttpError) {
return error.body;
}
const status = get_status(error);
const message = get_message(error);
return await options2.hooks.handleError({ error, event, status, message }) ?? { message };
}
function redirect_response(status, location) {
const response = new Response(void 0, {
status,
headers: { location }
});
return response;
}
function clarify_devalue_error(event, error) {
if (error.path) {
return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (data${error.path})`;
}
if (error.path === "") {
return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
}
return error.message;
}
function stringify_uses(node) {
const uses = [];
if (node.uses && node.uses.dependencies.size > 0) {
uses.push(`"dependencies":${JSON.stringify(Array.from(node.uses.dependencies))}`);
}
if (node.uses && node.uses.search_params.size > 0) {
uses.push(`"search_params":${JSON.stringify(Array.from(node.uses.search_params))}`);
}
if (node.uses && node.uses.params.size > 0) {
uses.push(`"params":${JSON.stringify(Array.from(node.uses.params))}`);
}
if (node.uses?.parent)
uses.push('"parent":1');
if (node.uses?.route)
uses.push('"route":1');
if (node.uses?.url)
uses.push('"url":1');
return `"uses":{${uses.join(",")}}`;
}
async function render_endpoint(event, mod, state) {
const method = (
/** @type {import('types').HttpMethod} */
event.request.method
);
let handler = mod[method] || mod.fallback;
if (method === "HEAD" && mod.GET && !mod.HEAD) {
handler = mod.GET;
}
if (!handler) {
return method_not_allowed(mod, method);
}
const prerender = mod.prerender ?? state.prerender_default;
if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {
throw new Error("Cannot prerender endpoints that have mutative methods");
}
if (state.prerendering && !prerender) {
if (state.depth > 0) {
throw new Error(`${event.route.id} is not prerenderable`);
} else {
return new Response(void 0, { status: 204 });
}
}
try {
let response = await handler(
/** @type {import('@sveltejs/kit').RequestEvent<Record<string, any>>} */
event
);
if (!(response instanceof Response)) {
throw new Error(
`Invalid response from route ${event.url.pathname}: handler should return a Response object`
);
}
if (state.prerendering) {
response = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: new Headers(response.headers)
});
response.headers.set("x-sveltekit-prerender", String(prerender));
}
return response;
} catch (e) {
if (e instanceof Redirect) {
return new Response(void 0, {
status: e.status,
headers: { location: e.location }
});
}
throw e;
}
}
function is_endpoint_request(event) {
const { method, headers: headers2 } = event.request;
if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) {
return true;
}
if (method === "POST" && headers2.get("x-sveltekit-action") === "true")
return false;
const accept = event.request.headers.get("accept") ?? "*/*";
return negotiate(accept, ["*", "text/html"]) !== "text/html";
}
function compact(arr) {
return arr.filter(
/** @returns {val is NonNullable<T>} */
(val) => val != null
);
}
function is_action_json_request(event) {
const accept = negotiate(event.request.headers.get("accept") ?? "*/*", [
"application/json",
"text/html"
]);
return accept === "application/json" && event.request.method === "POST";
}
async function handle_action_json_request(event, options2, server) {
const actions = server?.actions;
if (!actions) {
const no_actions_error = new SvelteKitError(
405,
"Method Not Allowed",
"POST method not allowed. No actions exist for this page"
);
return action_json(
{
type: "error",
error: await handle_error_and_jsonify(event, options2, no_actions_error)
},
{
status: no_actions_error.status,
headers: {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
// "The server must generate an Allow header field in a 405 status code response"
allow: "GET"
}
}
);
}
check_named_default_separate(actions);
try {
const data = await call_action(event, actions);
if (false)
;
if (data instanceof ActionFailure) {
return action_json({
type: "failure",
status: data.status,
// @ts-expect-error we assign a string to what is supposed to be an object. That's ok
// because we don't use the object outside, and this way we have better code navigation
// through knowing where the related interface is used.
data: stringify_action_response(
data.data,
/** @type {string} */
event.route.id
)
});
} else {
return action_json({
type: "success",
status: data ? 200 : 204,
// @ts-expect-error see comment above
data: stringify_action_response(
data,
/** @type {string} */
event.route.id
)
});
}
} catch (e) {
const err = normalize_error(e);
if (err instanceof Redirect) {
return action_json_redirect(err);
}
return action_json(
{
type: "error",
error: await handle_error_and_jsonify(event, options2, check_incorrect_fail_use(err))
},
{
status: get_status(err)
}
);
}
}
function check_incorrect_fail_use(error) {
return error instanceof ActionFailure ? new Error('Cannot "throw fail()". Use "return fail()"') : error;
}
function action_json_redirect(redirect) {
return action_json({
type: "redirect",
status: redirect.status,
location: redirect.location
});
}
function action_json(data, init2) {
return json(data, init2);
}
function is_action_request(event) {
return event.request.method === "POST";
}
async function handle_action_request(event, server) {
const actions = server?.actions;
if (!actions) {
event.setHeaders({
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
// "The server must generate an Allow header field in a 405 status code response"
allow: "GET"
});
return {
type: "error",
error: new SvelteKitError(
405,
"Method Not Allowed",
"POST method not allowed. No actions exist for this page"
)
};
}
check_named_default_separate(actions);
try {
const data = await call_action(event, actions);
if (false)
;
if (data instanceof ActionFailure) {
return {
type: "failure",
status: data.status,
data: data.data
};
} else {
return {
type: "success",
status: 200,
// @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission
data
};
}
} catch (e) {
const err = normalize_error(e);
if (err instanceof Redirect) {
return {
type: "redirect",
status: err.status,
location: err.location
};
}
return {
type: "error",
error: check_incorrect_fail_use(err)
};
}
}
function check_named_default_separate(actions) {
if (actions.default && Object.keys(actions).length > 1) {
throw new Error(
"When using named actions, the default action cannot be used. See the docs for more info: https://kit.svelte.dev/docs/form-actions#named-actions"
);
}
}
async function call_action(event, actions) {
const url = new URL(event.request.url);
let name = "default";
for (const param of url.searchParams) {
if (param[0].startsWith("/")) {
name = param[0].slice(1);
if (name === "default") {
throw new Error('Cannot use reserved action name "default"');
}
break;
}
}
const action = actions[name];
if (!action) {
throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
}
if (!is_form_content_type(event.request)) {
throw new SvelteKitError(
415,
"Unsupported Media Type",
`Form actions expect form-encoded data — received ${event.request.headers.get(
"content-type"
)}`
);
}
return action(event);
}
function uneval_action_response(data, route_id) {
return try_deserialize(data, uneval, route_id);
}
function stringify_action_response(data, route_id) {
return try_deserialize(data, stringify, route_id);
}
function try_deserialize(data, fn, route_id) {
try {
return fn(data);
} catch (e) {
const error = (
/** @type {any} */
e
);
if ("path" in error) {
let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
if (error.path !== "")
message += ` (data.${error.path})`;
throw new Error(message);
}
throw error;
}
}
const INVALIDATED_PARAM = "x-sveltekit-invalidated";
const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
async function load_server_data({ event, state, node, parent }) {
if (!node?.server)
return null;
let is_tracking = true;
const uses = {
dependencies: /* @__PURE__ */ new Set(),
params: /* @__PURE__ */ new Set(),
parent: false,
route: false,
url: false,
search_params: /* @__PURE__ */ new Set()
};
const url = make_trackable(
event.url,
() => {
if (is_tracking) {
uses.url = true;
}
},
(param) => {
if (is_tracking) {
uses.search_params.add(param);
}
}
);
if (state.prerendering) {
disable_search(url);
}
const result = await node.server.load?.call(null, {
...event,
fetch: (info, init2) => {
new URL(info instanceof Request ? info.url : info, event.url);
return event.fetch(info, init2);
},
/** @param {string[]} deps */
depends: (...deps) => {
for (const dep of deps) {
const { href } = new URL(dep, event.url);
uses.dependencies.add(href);
}
},
params: new Proxy(event.params, {
get: (target, key2) => {
if (is_tracking) {
uses.params.add(key2);
}
return target[
/** @type {string} */
key2
];
}
}),
parent: async () => {
if (is_tracking) {
uses.parent = true;
}
return parent();
},
route: new Proxy(event.route, {
get: (target, key2) => {
if (is_tracking) {
uses.route = true;
}
return target[
/** @type {'id'} */
key2
];
}
}),
url,
untrack(fn) {
is_tracking = false;
try {
return fn();
} finally {
is_tracking = true;
}
}
});
return {
type: "data",
data: result ?? null,
uses,
slash: node.server.trailingSlash
};
}
async function load_data({
event,
fetched,
node,
parent,
server_data_promise,
state,
resolve_opts,
csr
}) {
const server_data_node = await server_data_promise;
if (!node?.universal?.load) {
return server_data_node?.data ?? null;
}
const result = await node.universal.load.call(null, {
url: event.url,
params: event.params,
data: server_data_node?.data ?? null,
route: event.route,
fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
setHeaders: event.setHeaders,
depends: () => {
},
parent,
untrack: (fn) => fn()
});
return result ?? null;
}
function b64_encode(buffer) {
if (globalThis.Buffer) {
return Buffer.from(buffer).toString("base64");
}
const little_endian = new Uint8Array(new Uint16Array([1]).buffer)[0] > 0;
return btoa(
new TextDecoder(little_endian ? "utf-16le" : "utf-16be").decode(
new Uint16Array(new Uint8Array(buffer))
)
);
}
function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
const universal_fetch = async (input, init2) => {
const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init2?.headers;
let response = await event.fetch(input, init2);
const url = new URL(input instanceof Request ? input.url : input, event.url);
const same_origin = url.origin === event.url.origin;
let dependency;
if (same_origin) {
if (state.prerendering) {
dependency = { response, body: null };
state.prerendering.dependencies.set(url.pathname, dependency);
}
} else {
const mode = input instanceof Request ? input.mode : init2?.mode ?? "cors";
if (mode === "no-cors") {
response = new Response("", {
status: response.status,
statusText: response.statusText,
headers: response.headers
});
} else {
const acao = response.headers.get("access-control-allow-origin");
if (!acao || acao !== event.url.origin && acao !== "*") {
throw new Error(
`CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`
);
}
}
}
const proxy = new Proxy(response, {
get(response2, key2, _receiver) {
async function push_fetched(body2, is_b64) {
const status_number = Number(response2.status);
if (isNaN(status_number)) {
throw new Error(
`response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}`
);
}
fetched.push({
url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
method: event.request.method,
request_body: (
/** @type {string | ArrayBufferView | undefined} */
input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init2?.body
),
request_headers: cloned_headers,
response_body: body2,
response: response2,
is_b64
});
}
if (key2 === "arrayBuffer") {
return async () => {
const buffer = await response2.arrayBuffer();
if (dependency) {
dependency.body = new Uint8Array(buffer);
}
if (buffer instanceof ArrayBuffer) {
await push_fetched(b64_encode(buffer), true);
}
return buffer;
};
}
async function text2() {
const body2 = await response2.text();
if (!body2 || typeof body2 === "string") {
await push_fetched(body2, false);
}
if (dependency) {
dependency.body = body2;
}
return body2;
}
if (key2 === "text") {
return text2;
}
if (key2 === "json") {
return async () => {
return JSON.parse(await text2());
};
}
return Reflect.get(response2, key2, response2);
}
});
if (csr) {
const get = response.headers.get;
response.headers.get = (key2) => {
const lower = key2.toLowerCase();
const value = get.call(response.headers, lower);
if (value && !lower.startsWith("x-sveltekit-")) {
const included = resolve_opts.filterSerializedResponseHeaders(lower, value);
if (!included) {
throw new Error(
`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://kit.svelte.dev/docs/hooks#server-hooks-handle (at ${event.route.id})`
);
}
}
return value;
};
}
return proxy;
};
return (input, init2) => {
const response = universal_fetch(input, init2);
response.catch(() => {
});
return response;
};
}
async function stream_to_string(stream) {
let result = "";
const reader = stream.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
result += decoder.decode(value);
}
return result;
}
function hash(...values) {
let hash2 = 5381;
for (const value of values) {
if (typeof value === "string") {
let i = value.length;
while (i)
hash2 = hash2 * 33 ^ value.charCodeAt(--i);
} else if (ArrayBuffer.isView(value)) {
const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
let i = buffer.length;
while (i)
hash2 = hash2 * 33 ^ buffer[--i];
} else {
throw new TypeError("value must be a string or TypedArray");
}
}
return (hash2 >>> 0).toString(36);
}
const escape_html_attr_dict = {
"&": "&",
'"': """
};
const escape_html_attr_regex = new RegExp(
// special characters
`[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`,
"g"
);
function escape_html_attr(str) {
const escaped_str = str.replace(escape_html_attr_regex, (match) => {
if (match.length === 2) {
return match;
}
return escape_html_attr_dict[match] ?? `&#${match.charCodeAt(0)};`;
});
return `"${escaped_str}"`;
}
const replacements = {
"<": "\\u003C",
"\u2028": "\\u2028",
"\u2029": "\\u2029"
};
const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
function serialize_data(fetched, filter, prerendering2 = false) {
const headers2 = {};
let cache_control = null;
let age = null;
let varyAny = false;
for (const [key2, value] of fetched.response.headers) {
if (filter(key2, value)) {
headers2[key2] = value;
}
if (key2 === "cache-control")
cache_control = value;
else if (key2 === "age")
age = value;
else if (key2 === "vary" && value.trim() === "*")
varyAny = true;
}
const payload = {
status: fetched.response.status,
statusText: fetched.response.statusText,
headers: headers2,
body: fetched.response_body
};
const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
const attrs = [
'type="application/json"',
"data-sveltekit-fetched",
`data-url=${escape_html_attr(fetched.url)}`
];
if (fetched.is_b64) {
attrs.push("data-b64");
}
if (fetched.request_headers || fetched.request_body) {
const values = [];
if (fetched.request_headers) {
values.push([...new Headers(fetched.request_headers)].join(","));
}
if (fetched.request_body) {
values.push(fetched.request_body);
}
attrs.push(`data-hash="${hash(...values)}"`);
}
if (!prerendering2 && fetched.method === "GET" && cache_control && !varyAny) {
const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
if (match) {
const ttl = +match[1] - +(age ?? "0");
attrs.push(`data-ttl="${ttl}"`);
}
}
return `<script ${attrs.join(" ")}>${safe_payload}<\/script>`;
}
const s = JSON.stringify;
const encoder$2 = new TextEncoder();
function sha256(data) {
if (!key[0])
precompute();
const out = init.slice(0);
const array2 = encode(data);
for (let i = 0; i < array2.length; i += 16) {
const w = array2.subarray(i, i + 16);
let tmp;
let a;
let b;
let out0 = out[0];
let out1 = out[1];
let out2 = out[2];
let out3 = out[3];
let out4 = out[4];
let out5 = out[5];
let out6 = out[6];
let out7 = out[7];
for (let i2 = 0; i2 < 64; i2++) {
if (i2 < 16) {
tmp = w[i2];
} else {
a = w[i2 + 1 & 15];
b = w[i2 + 14 & 15];
tmp = w[i2 & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i2 & 15] + w[i2 + 9 & 15] | 0;
}
tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i2];
out7 = out6;
out6 = out5;
out5 = out4;
out4 = out3 + tmp | 0;
out3 = out2;
out2 = out1;
out1 = out0;
out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
}
out[0] = out[0] + out0 | 0;
out[1] = out[1] + out1 | 0;
out[2] = out[2] + out2 | 0;
out[3] = out[3] + out3 | 0;
out[4] = out[4] + out4 | 0;
out[5] = out[5] + out5 | 0;
out[6] = out[6] + out6 | 0;
out[7] = out[7] + out7 | 0;
}
const bytes = new Uint8Array(out.buffer);
reverse_endianness(bytes);
return base64(bytes);
}
const init = new Uint32Array(8);
const key = new Uint32Array(64);
function precompute() {
function frac(x) {
return (x - Math.floor(x)) * 4294967296;
}
let prime = 2;
for (let i = 0; i < 64; prime++) {
let is_prime = true;
for (let factor = 2; factor * factor <= prime; factor++) {
if (prime % factor === 0) {
is_prime = false;
break;
}
}
if (is_prime) {
if (i < 8) {
init[i] = frac(prime ** (1 / 2));
}
key[i] = frac(prime ** (1 / 3));
i++;
}
}
}
function reverse_endianness(bytes) {
for (let i = 0; i < bytes.length; i += 4) {
const a = bytes[i + 0];
const b = bytes[i + 1];
const c = bytes[i + 2];
const d = bytes[i + 3];
bytes[i + 0] = d;
bytes[i + 1] = c;
bytes[i + 2] = b;
bytes[i + 3] = a;
}
}
function encode(str) {
const encoded = encoder$2.encode(str);
const length = encoded.length * 8;
const size = 512 * Math.ceil((length + 65) / 512);
const bytes = new Uint8Array(size / 8);
bytes.set(encoded);
bytes[encoded.length] = 128;
reverse_endianness(bytes);
const words = new Uint32Array(bytes.buffer);
words[words.length - 2] = Math.floor(length / 4294967296);
words[words.length - 1] = length;
return words;
}
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
function base64(bytes) {
const l = bytes.length;
let result = "";
let i;
for (i = 2; i < l; i += 3) {
result += chars[bytes[i - 2] >> 2];
result += chars[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
result += chars[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
result += chars[bytes[i] & 63];
}
if (i === l + 1) {
result += chars[bytes[i - 2] >> 2];
result += chars[(bytes[i - 2] & 3) << 4];
result += "==";
}
if (i === l) {
result += chars[bytes[i - 2] >> 2];
result += chars[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
result += chars[(bytes[i - 1] & 15) << 2];
result += "=";
}
return result;
}
const array = new Uint8Array(16);
function generate_nonce() {
crypto.getRandomValues(array);
return base64(array);
}
const quoted = /* @__PURE__ */ new Set([
"self",
"unsafe-eval",
"unsafe-hashes",
"unsafe-inline",
"none",
"strict-dynamic",
"report-sample",
"wasm-unsafe-eval",
"script"
]);
const crypto_pattern = /^(nonce|sha\d\d\d)-/;
class BaseProvider {
/** @type {boolean} */
#use_hashes;
/** @type {boolean} */
#script_needs_csp;
/** @type {boolean} */
#style_needs_csp;
/** @type {import('types').CspDirectives} */
#directives;
/** @type {import('types').Csp.Source[]} */
#script_src;
/** @type {import('types').Csp.Source[]} */
#script_src_elem;
/** @type {import('types').Csp.Source[]} */
#style_src;
/** @type {import('types').Csp.Source[]} */
#style_src_attr;
/** @type {import('types').Csp.Source[]} */
#style_src_elem;
/** @type {string} */
#nonce;
/**
* @param {boolean} use_hashes
* @param {import('types').CspDirectives} directives
* @param {string} nonce
*/
constructor(use_hashes, directives, nonce) {
this.#use_hashes = use_hashes;
this.#directives = directives;
const d = this.#directives;
this.#script_src = [];
this.#script_src_elem = [];
this.#style_src = [];
this.#style_src_attr = [];
this.#style_src_elem = [];
const effective_script_src = d["script-src"] || d["default-src"];
const script_src_elem = d["script-src-elem"];
const effective_style_src = d["style-src"] || d["default-src"];
const style_src_attr = d["style-src-attr"];
const style_src_elem = d["style-src-elem"];
this.#script_needs_csp = !!effective_script_src && effective_script_src.filter((value) => value !== "unsafe-inline").length > 0 || !!script_src_elem && script_src_elem.filter((value) => value !== "unsafe-inline").length > 0;
this.#style_needs_csp = !!effective_style_src && effective_style_src.filter((value) => value !== "unsafe-inline").length > 0 || !!style_src_attr && style_src_attr.filter((value) => value !== "unsafe-inline").length > 0 || !!style_src_elem && style_src_elem.filter((value) => value !== "unsafe-inline").length > 0;
this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
this.#nonce = nonce;
}
/** @param {string} content */
add_script(content) {
if (this.#script_needs_csp) {
const d = this.#directives;
if (this.#use_hashes) {
const hash2 = sha256(content);
this.#script_src.push(`sha256-${hash2}`);
if (d["script-src-elem"]?.length) {
this.#script_src_elem.push(`sha256-${hash2}`);
}
} else {
if (this.#script_src.length === 0) {
this.#script_src.push(`nonce-${this.#nonce}`);
}
if (d["script-src-elem"]?.length) {
this.#script_src_elem.push(`nonce-${this.#nonce}`);
}
}
}
}
/** @param {string} content */
add_style(content) {
if (this.#style_needs_csp) {
const empty_comment_hash = "9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
const d = this.#directives;
if (this.#use_hashes) {
const hash2 = sha256(content);
this.#style_src.push(`sha256-${hash2}`);
if (d["style-src-attr"]?.length) {
this.#style_src_attr.push(`sha256-${hash2}`);
}
if (d["style-src-elem"]?.length) {
if (hash2 !== empty_comment_hash && !d["style-src-elem"].includes(`sha256-${empty_comment_hash}`)) {
this.#style_src_elem.push(`sha256-${empty_comment_hash}`);
}
this.#style_src_elem.push(`sha256-${hash2}`);
}
} else {
if (this.#style_src.length === 0 && !d["style-src"]?.includes("unsafe-inline")) {
this.#style_src.push(`nonce-${this.#nonce}`);
}
if (d["style-src-attr"]?.length) {
this.#style_src_attr.push(`nonce-${this.#nonce}`);
}
if (d["style-src-elem"]?.length) {
if (!d["style-src-elem"].includes(`sha256-${empty_comment_hash}`)) {
this.#style_src_elem.push(`sha256-${empty_comment_hash}`);
}
this.#style_src_elem.push(`nonce-${this.#nonce}`);
}
}
}
}
/**
* @param {boolean} [is_meta]
*/
get_header(is_meta = false) {
const header = [];
const directives = { ...this.#directives };
if (this.#style_src.length > 0) {
directives["style-src"] = [
...directives["style-src"] || directives["default-src"] || [],
...this.#style_src
];
}
if (this.#style_src_attr.length > 0) {
directives["style-src-attr"] = [
...directives["style-src-attr"] || [],
...this.#style_src_attr
];
}
if (this.#style_src_elem.length > 0) {
directives["style-src-elem"] = [
...directives["style-src-elem"] || [],
...this.#style_src_elem
];
}
if (this.#script_src.length > 0) {
directives["script-src"] = [
...directives["script-src"] || directives["default-src"] || [],
...this.#script_src
];
}
if (this.#script_src_elem.length > 0) {
directives["script-src-elem"] = [
...directives["script-src-elem"] || [],
...this.#script_src_elem
];
}
for (const key2 in directives) {
if (is_meta && (key2 === "frame-ancestors" || key2 === "report-uri" || key2 === "sandbox")) {
continue;
}
const value = (
/** @type {string[] | true} */
directives[key2]
);
if (!value)
continue;
const directive = [key2];
if (Array.isArray(value)) {
value.forEach((value2) => {
if (quoted.has(value2) || crypto_pattern.test(value2)) {
directive.push(`'${value2}'`);
} else {
directive.push(value2);
}
});
}
header.push(directive.join(" "));
}
return header.join("; ");
}
}
class CspProvider extends BaseProvider {
get_meta() {
const content = this.get_header(true);
if (!content) {
return;
}
return `<meta http-equiv="content-security-policy" content=${escape_html_attr(content)}>`;
}
}
class CspReportOnlyProvider extends BaseProvider {
/**
* @param {boolean} use_hashes
* @param {import('types').CspDirectives} directives
* @param {string} nonce
*/
constructor(use_hashes, directives, nonce) {
super(use_hashes, directives, nonce);
if (Object.values(directives).filter((v) => !!v).length > 0) {
const has_report_to = directives["report-to"]?.length ?? 0 > 0;
const has_report_uri = directives["report-uri"]?.length ?? 0 > 0;
if (!has_report_to && !has_report_uri) {
throw Error(
"`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both"
);
}
}
}
}
class Csp {
/** @readonly */
nonce = generate_nonce();
/** @type {CspProvider} */
csp_provider;
/** @type {CspReportOnlyProvider} */
report_only_provider;
/**
* @param {import('./types.js').CspConfig} config
* @param {import('./types.js').CspOpts} opts
*/
constructor({ mode, directives, reportOnly }, { prerender }) {
const use_hashes = mode === "hash" || mode === "auto" && prerender;
this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
}
get script_needs_nonce() {
return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
}
get style_needs_nonce() {
return this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;
}
/** @param {string} content */
add_script(content) {
this.csp_provider.add_script(content);
this.report_only_provider.add_script(content);
}
/** @param {string} content */
add_style(content) {
this.csp_provider.add_style(content);
this.report_only_provider.add_style(content);
}
}
function defer() {
let fulfil;
let reject;
const promise = new Promise((f, r) => {
fulfil = f;
reject = r;
});
return { promise, fulfil, reject };
}
function create_async_iterator() {
const deferred = [defer()];
return {
iterator: {
[Symbol.asyncIterator]() {
return {
next: async () => {
const next = await deferred[0].promise;
if (!next.done)
deferred.shift();
return next;
}
};
}
},
push: (value) => {
deferred[deferred.length - 1].fulfil({
value,
done: false
});
deferred.push(defer());
},
done: () => {
deferred[deferred.length - 1].fulfil({ done: true });
}
};
}
const updated = {
...readable(false),
check: () => false
};
const encoder$1 = new TextEncoder();
async function render_response({
branch,
fetched,
options: options2,
manifest,
state,
page_config,
status,
error = null,
event,
resolve_opts,
action_result
}) {
if (state.prerendering) {
if (options2.csp.mode === "nonce") {
throw new Error('Cannot use prerendering if config.kit.csp.mode === "nonce"');
}
if (options2.app_template_contains_nonce) {
throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
}
}
const { client } = manifest._;
const modulepreloads = new Set(client.imports);
const stylesheets = new Set(client.stylesheets);
const fonts = new Set(client.fonts);
const link_header_preloads = /* @__PURE__ */ new Set();
const inline_styles = /* @__PURE__ */ new Map();
let rendered;
const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
let base$1 = base;
let assets$1 = assets;
let base_expression = s(base);
if (!state.prerendering?.fallback) {
const segments = event.url.pathname.slice(base.length).split("/").slice(2);
base$1 = segments.map(() => "..").join("/") || ".";
base_expression = `new URL(${s(base$1)}, location).pathname.slice(0, -1)`;
if (!assets || assets[0] === "/" && assets !== SVELTE_KIT_ASSETS) {
assets$1 = base$1;
}
}
if (page_config.ssr) {
const props = {
stores: {
page: writable(null),
navigating: writable(null),
updated
},
constructors: await Promise.all(branch.map(({ node }) => node.component())),
form: form_value
};
let data2 = {};
for (let i = 0; i < branch.length; i += 1) {
data2 = { ...data2, ...branch[i].data };
props[`data_${i}`] = data2;
}
props.page = {
error,
params: (
/** @type {Record<string, any>} */
event.params
),
route: event.route,
status,
url: event.url,
data: data2,
form: form_value,
state: {}
};
override({ base: base$1, assets: assets$1 });
{
try {
rendered = options2.root.render(props);
} finally {
reset();
}
}
for (const { node } of branch) {
for (const url of node.imports)
modulepreloads.add(url);
for (const url of node.stylesheets)
stylesheets.add(url);
for (const url of node.fonts)
fonts.add(url);
if (node.inline_styles) {
Object.entries(await node.inline_styles()).forEach(([k, v]) => inline_styles.set(k, v));
}
}
} else {
rendered = { head: "", html: "", css: { code: "", map: null } };
}
let head = "";
let body2 = rendered.html;
const csp = new Csp(options2.csp, {
prerender: !!state.prerendering
});
const prefixed = (path) => {
if (path.startsWith("/")) {
return base + path;
}
return `${assets$1}/${path}`;
};
if (inline_styles.size > 0) {
const content = Array.from(inline_styles.values()).join("\n");
const attributes = [];
if (csp.style_needs_nonce)
attributes.push(` nonce="${csp.nonce}"`);
csp.add_style(content);
head += `
<style${attributes.join("")}>${content}</style>`;
}
for (const dep of stylesheets) {
const path = prefixed(dep);
const attributes = ['rel="stylesheet"'];
if (inline_styles.has(dep)) {
attributes.push("disabled", 'media="(max-width: 0)"');
} else {
if (resolve_opts.preload({ type: "css", path })) {
const preload_atts = ['rel="preload"', 'as="style"'];
link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(";")}; nopush`);
}
}
head += `
<link href="${path}" ${attributes.join(" ")}>`;
}
for (const dep of fonts) {
const path = prefixed(dep);
if (resolve_opts.preload({ type: "font", path })) {
const ext = dep.slice(dep.lastIndexOf(".") + 1);
const attributes = [
'rel="preload"',
'as="font"',
`type="font/${ext}"`,
`href="${path}"`,
"crossorigin"
];
head += `
<link ${attributes.join(" ")}>`;
}
}
const global = `__sveltekit_${options2.version_hash}`;
const { data, chunks } = get_data(
event,
options2,
branch.map((b) => b.server_data),
global
);
if (page_config.ssr && page_config.csr) {
body2 += `
${fetched.map(
(item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)
).join("\n ")}`;
}
if (page_config.csr) {
if (client.uses_env_dynamic_public && state.prerendering) {
modulepreloads.add(`${options2.app_dir}/env.js`);
}
const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter(
(path) => resolve_opts.preload({ type: "js", path })
);
for (const path of included_modulepreloads) {
link_header_preloads.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
if (options2.preload_strategy !== "modulepreload") {
head += `
<link rel="preload" as="script" crossorigin="anonymous" href="${path}">`;
} else if (state.prerendering) {
head += `
<link rel="modulepreload" href="${path}">`;
}
}
const blocks = [];
const load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;
const properties = [`base: ${base_expression}`];
if (assets) {
properties.push(`assets: ${s(assets)}`);
}
if (client.uses_env_dynamic_public) {
properties.push(`env: ${load_env_eagerly ? "null" : s(public_env)}`);
}
if (chunks) {
blocks.push("const deferred = new Map();");
properties.push(`defer: (id) => new Promise((fulfil, reject) => {
deferred.set(id, { fulfil, reject });
})`);
properties.push(`resolve: ({ id, data, error }) => {
const { fulfil, reject } = deferred.get(id);
deferred.delete(id);
if (error) reject(error);
else fulfil(data);
}`);
}
blocks.push(`${global} = {
${properties.join(",\n ")}
};`);
const args = ["app", "element"];
blocks.push("const element = document.currentScript.parentElement;");
if (page_config.ssr) {
const serialized = { form: "null", error: "null" };
blocks.push(`const data = ${data};`);
if (form_value) {
serialized.form = uneval_action_response(
form_value,
/** @type {string} */
event.route.id
);
}
if (error) {
serialized.error = uneval(error);
}
const hydrate = [
`node_ids: [${branch.map(({ node }) => node.index).join(", ")}]`,
"data",
`form: ${serialized.form}`,
`error: ${serialized.error}`
];
if (status !== 200) {
hydrate.push(`status: ${status}`);
}
if (options2.embedded) {
hydrate.push(`params: ${uneval(event.params)}`, `route: ${s(event.route)}`);
}
const indent = " ".repeat(load_env_eagerly ? 7 : 6);
args.push(`{
${indent} ${hydrate.join(`,
${indent} `)}
${indent}}`);
}
if (load_env_eagerly) {
blocks.push(`import(${s(`${base$1}/${options2.app_dir}/env.js`)}).then(({ env }) => {
${global}.env = env;
Promise.all([
import(${s(prefixed(client.start))}),
import(${s(prefixed(client.app))})
]).then(([kit, app]) => {
kit.start(${args.join(", ")});
});
});`);
} else {
blocks.push(`Promise.all([
import(${s(prefixed(client.start))}),
import(${s(prefixed(client.app))})
]).then(([kit, app]) => {
kit.start(${args.join(", ")});
});`);
}
if (options2.service_worker) {
const opts = "";
blocks.push(`if ('serviceWorker' in navigator) {
addEventListener('load', function () {
navigator.serviceWorker.register('${prefixed("service-worker.js")}'${opts});
});
}`);
}
const init_app = `
{
${blocks.join("\n\n ")}
}
`;
csp.add_script(init_app);
body2 += `
<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_app}<\/script>
`;
}
const headers2 = new Headers({
"x-sveltekit-page": "true",
"content-type": "text/html"
});
if (state.prerendering) {
const http_equiv = [];
const csp_headers = csp.csp_provider.get_meta();
if (csp_headers) {
http_equiv.push(csp_headers);
}
if (state.prerendering.cache) {
http_equiv.push(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
}
if (http_equiv.length > 0) {
head = http_equiv.join("\n") + head;
}
} else {
const csp_header = csp.csp_provider.get_header();
if (csp_header) {
headers2.set("content-security-policy", csp_header);
}
const report_only_header = csp.report_only_provider.get_header();
if (report_only_header) {
headers2.set("content-security-policy-report-only", report_only_header);
}
if (link_header_preloads.size) {
headers2.set("link", Array.from(link_header_preloads).join(", "));
}
}
head += rendered.head;
const html = options2.templates.app({
head,
body: body2,
assets: assets$1,
nonce: (
/** @type {string} */
csp.nonce
),
env: safe_public_env
});
const transformed = await resolve_opts.transformPageChunk({
html,
done: true
}) || "";
if (!chunks) {
headers2.set("etag", `"${hash(transformed)}"`);
}
return !chunks ? text(transformed, {
status,
headers: headers2
}) : new Response(
new ReadableStream({
async start(controller) {
controller.enqueue(encoder$1.encode(transformed + "\n"));
for await (const chunk of chunks) {
controller.enqueue(encoder$1.encode(chunk));
}
controller.close();
},
type: "bytes"
}),
{
headers: {
"content-type": "text/html"
}
}
);
}
function get_data(event, options2, nodes, global) {
let promise_id = 1;
let count = 0;
const { iterator, push, done } = create_async_iterator();
function replacer(thing) {
if (typeof thing?.then === "function") {
const id = promise_id++;
count += 1;
thing.then(
/** @param {any} data */
(data) => ({ data })
).catch(
/** @param {any} error */
async (error) => ({
error: await handle_error_and_jsonify(event, options2, error)
})
).then(
/**
* @param {{data: any; error: any}} result
*/
async ({ data, error }) => {
count -= 1;
let str;
try {
str = uneval({ id, data, error }, replacer);
} catch (e) {
error = await handle_error_and_jsonify(
event,
options2,
new Error(`Failed to serialize promise while rendering ${event.route.id}`)
);
data = void 0;
str = uneval({ id, data, error }, replacer);
}
push(`<script>${global}.resolve(${str})<\/script>
`);
if (count === 0)
done();
}
);
return `${global}.defer(${id})`;
}
}
try {
const strings = nodes.map((node) => {
if (!node)
return "null";
return `{"type":"data","data":${uneval(node.data, replacer)},${stringify_uses(node)}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
});
return {
data: `[${strings.join(",")}]`,
chunks: count > 0 ? iterator : null
};
} catch (e) {
throw new Error(clarify_devalue_error(
event,
/** @type {any} */
e
));
}
}
function get_option(nodes, option) {
return nodes.reduce(
(value, node) => {
return (
/** @type {Value} TypeScript's too dumb to understand this */
node?.universal?.[option] ?? node?.server?.[option] ?? value
);
},
/** @type {Value | undefined} */
void 0
);
}
async function respond_with_error({
event,
options: options2,
manifest,
state,
status,
error,
resolve_opts
}) {
if (event.request.headers.get("x-sveltekit-error")) {
return static_error_page(
options2,
status,
/** @type {Error} */
error.message
);
}
const fetched = [];
try {
const branch = [];
const default_layout = await manifest._.nodes[0]();
const ssr = get_option([default_layout], "ssr") ?? true;
const csr = get_option([default_layout], "csr") ?? true;
if (ssr) {
state.error = true;
const server_data_promise = load_server_data({
event,
state,
node: default_layout,
parent: async () => ({})
});
const server_data = await server_data_promise;
const data = await load_data({
event,
fetched,
node: default_layout,
parent: async () => ({}),
resolve_opts,
server_data_promise,
state,
csr
});
branch.push(
{
node: default_layout,
server_data,
data
},
{
node: await manifest._.nodes[1](),
// 1 is always the root error
data: null,
server_data: null
}
);
}
return await render_response({
options: options2,
manifest,
state,
page_config: {
ssr,
csr
},
status,
error: await handle_error_and_jsonify(event, options2, error),
branch,
fetched,
event,
resolve_opts
});
} catch (e) {
if (e instanceof Redirect) {
return redirect_response(e.status, e.location);
}
return static_error_page(
options2,
get_status(e),
(await handle_error_and_jsonify(event, options2, e)).message
);
}
}
function once(fn) {
let done = false;
let result;
return () => {
if (done)
return result;
done = true;
return result = fn();
};
}
const encoder = new TextEncoder();
async function render_data(event, route, options2, manifest, state, invalidated_data_nodes, trailing_slash) {
if (!route.page) {
return new Response(void 0, {
status: 404
});
}
try {
const node_ids = [...route.page.layouts, route.page.leaf];
const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
let aborted = false;
const url = new URL(event.url);
url.pathname = normalize_path(url.pathname, trailing_slash);
const new_event = { ...event, url };
const functions = node_ids.map((n, i) => {
return once(async () => {
try {
if (aborted) {
return (
/** @type {import('types').ServerDataSkippedNode} */
{
type: "skip"
}
);
}
const node = n == void 0 ? n : await manifest._.nodes[n]();
return load_server_data({
event: new_event,
state,
node,
parent: async () => {
const data2 = {};
for (let j = 0; j < i; j += 1) {
const parent = (
/** @type {import('types').ServerDataNode | null} */
await functions[j]()
);
if (parent) {
Object.assign(data2, parent.data);
}
}
return data2;
}
});
} catch (e) {
aborted = true;
throw e;
}
});
});
const promises = functions.map(async (fn, i) => {
if (!invalidated[i]) {
return (
/** @type {import('types').ServerDataSkippedNode} */
{
type: "skip"
}
);
}
return fn();
});
let length = promises.length;
const nodes = await Promise.all(
promises.map(
(p, i) => p.catch(async (error) => {
if (error instanceof Redirect) {
throw error;
}
length = Math.min(length, i + 1);
return (
/** @type {import('types').ServerErrorNode} */
{
type: "error",
error: await handle_error_and_jsonify(event, options2, error),
status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : void 0
}
);
})
)
);
const { data, chunks } = get_data_json(event, options2, nodes);
if (!chunks) {
return json_response(data);
}
return new Response(
new ReadableStream({
async start(controller) {
controller.enqueue(encoder.encode(data));
for await (const chunk of chunks) {
controller.enqueue(encoder.encode(chunk));
}
controller.close();
},
type: "bytes"
}),
{
headers: {
// we use a proprietary content type to prevent buffering.
// the `text` prefix makes it inspectable
"content-type": "text/sveltekit-data",
"cache-control": "private, no-store"
}
}
);
} catch (e) {
const error = normalize_error(e);
if (error instanceof Redirect) {
return redirect_json_response(error);
} else {
return json_response(await handle_error_and_jsonify(event, options2, error), 500);
}
}
}
function json_response(json2, status = 200) {
return text(typeof json2 === "string" ? json2 : JSON.stringify(json2), {
status,
headers: {
"content-type": "application/json",
"cache-control": "private, no-store"
}
});
}
function redirect_json_response(redirect) {
return json_response({
type: "redirect",
location: redirect.location
});
}
function get_data_json(event, options2, nodes) {
let promise_id = 1;
let count = 0;
const { iterator, push, done } = create_async_iterator();
const reducers = {
/** @param {any} thing */
Promise: (thing) => {
if (typeof thing?.then === "function") {
const id = promise_id++;
count += 1;
let key2 = "data";
thing.catch(
/** @param {any} e */
async (e) => {
key2 = "error";
return handle_error_and_jsonify(
event,
options2,
/** @type {any} */
e
);
}
).then(
/** @param {any} value */
async (value) => {
let str;
try {
str = stringify(value, reducers);
} catch (e) {
const error = await handle_error_and_jsonify(
event,
options2,
new Error(`Failed to serialize promise while rendering ${event.route.id}`)
);
key2 = "error";
str = stringify(error, reducers);
}
count -= 1;
push(`{"type":"chunk","id":${id},"${key2}":${str}}
`);
if (count === 0)
done();
}
);
return id;
}
}
};
try {
const strings = nodes.map((node) => {
if (!node)
return "null";
if (node.type === "error" || node.type === "skip") {
return JSON.stringify(node);
}
return `{"type":"data","data":${stringify(node.data, reducers)},${stringify_uses(
node
)}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
});
return {
data: `{"type":"data","nodes":[${strings.join(",")}]}
`,
chunks: count > 0 ? iterator : null
};
} catch (e) {
throw new Error(clarify_devalue_error(
event,
/** @type {any} */
e
));
}
}
const MAX_DEPTH = 10;
async function render_page(event, page, options2, manifest, state, resolve_opts) {
if (state.depth > MAX_DEPTH) {
return text(`Not found: ${event.url.pathname}`, {
status: 404
// TODO in some cases this should be 500. not sure how to differentiate
});
}
if (is_action_json_request(event)) {
const node = await manifest._.nodes[page.leaf]();
return handle_action_json_request(event, options2, node?.server);
}
try {
const nodes = await Promise.all([
// we use == here rather than === because [undefined] serializes as "[null]"
...page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()),
manifest._.nodes[page.leaf]()
]);
const leaf_node = (
/** @type {import('types').SSRNode} */
nodes.at(-1)
);
let status = 200;
let action_result = void 0;
if (is_action_request(event)) {
action_result = await handle_action_request(event, leaf_node.server);
if (action_result?.type === "redirect") {
return redirect_response(action_result.status, action_result.location);
}
if (action_result?.type === "error") {
status = get_status(action_result.error);
}
if (action_result?.type === "failure") {
status = action_result.status;
}
}
const should_prerender_data = nodes.some((node) => node?.server?.load);
const data_pathname = add_data_suffix(event.url.pathname);
const should_prerender = get_option(nodes, "prerender") ?? false;
if (should_prerender) {
const mod = leaf_node.server;
if (mod?.actions) {
throw new Error("Cannot prerender pages with actions");
}
} else if (state.prerendering) {
return new Response(void 0, {
status: 204
});
}
state.prerender_default = should_prerender;
const fetched = [];
if (get_option(nodes, "ssr") === false && !(state.prerendering && should_prerender_data)) {
return await render_response({
branch: [],
fetched,
page_config: {
ssr: false,
csr: get_option(nodes, "csr") ?? true
},
status,
error: null,
event,
options: options2,
manifest,
state,
resolve_opts
});
}
const branch = [];
let load_error = null;
const server_promises = nodes.map((node, i) => {
if (load_error) {
throw load_error;
}
return Promise.resolve().then(async () => {
try {
if (node === leaf_node && action_result?.type === "error") {
throw action_result.error;
}
return await load_server_data({
event,
state,
node,
parent: async () => {
const data = {};
for (let j = 0; j < i; j += 1) {
const parent = await server_promises[j];
if (parent)
Object.assign(data, await parent.data);
}
return data;
}
});
} catch (e) {
load_error = /** @type {Error} */
e;
throw load_error;
}
});
});
const csr = get_option(nodes, "csr") ?? true;
const load_promises = nodes.map((node, i) => {
if (load_error)
throw load_error;
return Promise.resolve().then(async () => {
try {
return await load_data({
event,
fetched,
node,
parent: async () => {
const data = {};
for (let j = 0; j < i; j += 1) {
Object.assign(data, await load_promises[j]);
}
return data;
},
resolve_opts,
server_data_promise: server_promises[i],
state,
csr
});
} catch (e) {
load_error = /** @type {Error} */
e;
throw load_error;
}
});
});
for (const p of server_promises)
p.catch(() => {
});
for (const p of load_promises)
p.catch(() => {
});
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
if (node) {
try {
const server_data = await server_promises[i];
const data = await load_promises[i];
branch.push({ node, server_data, data });
} catch (e) {
const err = normalize_error(e);
if (err instanceof Redirect) {
if (state.prerendering && should_prerender_data) {
const body2 = JSON.stringify({
type: "redirect",
location: err.location
});
state.prerendering.dependencies.set(data_pathname, {
response: text(body2),
body: body2
});
}
return redirect_response(err.status, err.location);
}
const status2 = get_status(err);
const error = await handle_error_and_jsonify(event, options2, err);
while (i--) {
if (page.errors[i]) {
const index = (
/** @type {number} */
page.errors[i]
);
const node2 = await manifest._.nodes[index]();
let j = i;
while (!branch[j])
j -= 1;
return await render_response({
event,
options: options2,
manifest,
state,
resolve_opts,
page_config: { ssr: true, csr: true },
status: status2,
error,
branch: compact(branch.slice(0, j + 1)).concat({
node: node2,
data: null,
server_data: null
}),
fetched
});
}
}
return static_error_page(options2, status2, error.message);
}
} else {
branch.push(null);
}
}
if (state.prerendering && should_prerender_data) {
let { data, chunks } = get_data_json(
event,
options2,
branch.map((node) => node?.server_data)
);
if (chunks) {
for await (const chunk of chunks) {
data += chunk;
}
}
state.prerendering.dependencies.set(data_pathname, {
response: text(data),
body: data
});
}
const ssr = get_option(nodes, "ssr") ?? true;
return await render_response({
event,
options: options2,
manifest,
state,
resolve_opts,
page_config: {
csr: get_option(nodes, "csr") ?? true,
ssr
},
status,
error: null,
branch: ssr === false ? [] : compact(branch),
action_result,
fetched
});
} catch (e) {
return await respond_with_error({
event,
options: options2,
manifest,
state,
status: 500,
error: e,
resolve_opts
});
}
}
function exec(match, params, matchers) {
const result = {};
const values = match.slice(1);
const values_needing_match = values.filter((value) => value !== void 0);
let buffered = 0;
for (let i = 0; i < params.length; i += 1) {
const param = params[i];
let value = values[i - buffered];
if (param.chained && param.rest && buffered) {
value = values.slice(i - buffered, i + 1).filter((s2) => s2).join("/");
buffered = 0;
}
if (value === void 0) {
if (param.rest)
result[param.name] = "";
continue;
}
if (!param.matcher || matchers[param.matcher](value)) {
result[param.name] = value;
const next_param = params[i + 1];
const next_value = values[i + 1];
if (next_param && !next_param.rest && next_param.optional && next_value && param.chained) {
buffered = 0;
}
if (!next_param && !next_value && Object.keys(result).length === values_needing_match.length) {
buffered = 0;
}
continue;
}
if (param.optional && param.chained) {
buffered++;
continue;
}
return;
}
if (buffered)
return;
return result;
}
function validate_options(options2) {
if (options2?.path === void 0) {
throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
}
}
function get_cookies(request, url, trailing_slash) {
const header = request.headers.get("cookie") ?? "";
const initial_cookies = cookieExports.parse(header, { decode: (value) => value });
const normalized_url = normalize_path(url.pathname, trailing_slash);
const new_cookies = {};
const defaults = {
httpOnly: true,
sameSite: "lax",
secure: url.hostname === "localhost" && url.protocol === "http:" ? false : true
};
const cookies = {
// The JSDoc param annotations appearing below for get, set and delete
// are necessary to expose the `cookie` library types to
// typescript users. `@type {import('@sveltejs/kit').Cookies}` above is not
// sufficient to do so.
/**
* @param {string} name
* @param {import('cookie').CookieParseOptions} opts
*/
get(name, opts) {
const c = new_cookies[name];
if (c && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
return c.value;
}
const decoder = opts?.decode || decodeURIComponent;
const req_cookies = cookieExports.parse(header, { decode: decoder });
const cookie = req_cookies[name];
return cookie;
},
/**
* @param {import('cookie').CookieParseOptions} opts
*/
getAll(opts) {
const decoder = opts?.decode || decodeURIComponent;
const cookies2 = cookieExports.parse(header, { decode: decoder });
for (const c of Object.values(new_cookies)) {
if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
cookies2[c.name] = c.value;
}
}
return Object.entries(cookies2).map(([name, value]) => ({ name, value }));
},
/**
* @param {string} name
* @param {string} value
* @param {import('./page/types.js').Cookie['options']} options
*/
set(name, value, options2) {
validate_options(options2);
set_internal(name, value, { ...defaults, ...options2 });
},
/**
* @param {string} name
* @param {import('./page/types.js').Cookie['options']} options
*/
delete(name, options2) {
validate_options(options2);
cookies.set(name, "", { ...options2, maxAge: 0 });
},
/**
* @param {string} name
* @param {string} value
* @param {import('./page/types.js').Cookie['options']} options
*/
serialize(name, value, options2) {
validate_options(options2);
let path = options2.path;
if (!options2.domain || options2.domain === url.hostname) {
path = resolve(normalized_url, path);
}
return cookieExports.serialize(name, value, { ...defaults, ...options2, path });
}
};
function get_cookie_header(destination, header2) {
const combined_cookies = {
// cookies sent by the user agent have lowest precedence
...initial_cookies
};
for (const key2 in new_cookies) {
const cookie = new_cookies[key2];
if (!domain_matches(destination.hostname, cookie.options.domain))
continue;
if (!path_matches(destination.pathname, cookie.options.path))
continue;
const encoder2 = cookie.options.encode || encodeURIComponent;
combined_cookies[cookie.name] = encoder2(cookie.value);
}
if (header2) {
const parsed = cookieExports.parse(header2, { decode: (value) => value });
for (const name in parsed) {
combined_cookies[name] = parsed[name];
}
}
return Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
}
function set_internal(name, value, options2) {
let path = options2.path;
if (!options2.domain || options2.domain === url.hostname) {
path = resolve(normalized_url, path);
}
new_cookies[name] = { name, value, options: { ...options2, path } };
}
return { cookies, new_cookies, get_cookie_header, set_internal };
}
function domain_matches(hostname, constraint) {
if (!constraint)
return true;
const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
if (hostname === normalized)
return true;
return hostname.endsWith("." + normalized);
}
function path_matches(path, constraint) {
if (!constraint)
return true;
const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
if (path === normalized)
return true;
return path.startsWith(normalized + "/");
}
function add_cookies_to_headers(headers2, cookies) {
for (const new_cookie of cookies) {
const { name, value, options: options2 } = new_cookie;
headers2.append("set-cookie", cookieExports.serialize(name, value, options2));
if (options2.path.endsWith(".html")) {
const path = add_data_suffix(options2.path);
headers2.append("set-cookie", cookieExports.serialize(name, value, { ...options2, path }));
}
}
}
function create_fetch({ event, options: options2, manifest, state, get_cookie_header, set_internal }) {
const server_fetch = async (info, init2) => {
const original_request = normalize_fetch_input(info, init2, event.url);
let mode = (info instanceof Request ? info.mode : init2?.mode) ?? "cors";
let credentials = (info instanceof Request ? info.credentials : init2?.credentials) ?? "same-origin";
return options2.hooks.handleFetch({
event,
request: original_request,
fetch: async (info2, init3) => {
const request = normalize_fetch_input(info2, init3, event.url);
const url = new URL(request.url);
if (!request.headers.has("origin")) {
request.headers.set("origin", event.url.origin);
}
if (info2 !== original_request) {
mode = (info2 instanceof Request ? info2.mode : init3?.mode) ?? "cors";
credentials = (info2 instanceof Request ? info2.credentials : init3?.credentials) ?? "same-origin";
}
if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) {
request.headers.delete("origin");
}
if (url.origin !== event.url.origin) {
if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
const cookie = get_cookie_header(url, request.headers.get("cookie"));
if (cookie)
request.headers.set("cookie", cookie);
}
return fetch(request);
}
const prefix = assets || base;
const decoded = decodeURIComponent(url.pathname);
const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
const filename_html = `${filename}/index.html`;
const is_asset = manifest.assets.has(filename);
const is_asset_html = manifest.assets.has(filename_html);
if (is_asset || is_asset_html) {
const file = is_asset ? filename : filename_html;
if (state.read) {
const type = is_asset ? manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
return new Response(state.read(file), {
headers: type ? { "content-type": type } : {}
});
}
return await fetch(request);
}
if (credentials !== "omit") {
const cookie = get_cookie_header(url, request.headers.get("cookie"));
if (cookie) {
request.headers.set("cookie", cookie);
}
const authorization = event.request.headers.get("authorization");
if (authorization && !request.headers.has("authorization")) {
request.headers.set("authorization", authorization);
}
}
if (!request.headers.has("accept")) {
request.headers.set("accept", "*/*");
}
if (!request.headers.has("accept-language")) {
request.headers.set(
"accept-language",
/** @type {string} */
event.request.headers.get("accept-language")
);
}
const response = await respond(request, options2, manifest, {
...state,
depth: state.depth + 1
});
const set_cookie = response.headers.get("set-cookie");
if (set_cookie) {
for (const str of setCookieExports.splitCookiesString(set_cookie)) {
const { name, value, ...options3 } = setCookieExports.parseString(str);
const path = options3.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/");
set_internal(name, value, {
path,
.../** @type {import('cookie').CookieSerializeOptions} */
options3
});
}
}
return response;
}
});
};
return (input, init2) => {
const response = server_fetch(input, init2);
response.catch(() => {
});
return response;
};
}
function normalize_fetch_input(info, init2, url) {
if (info instanceof Request) {
return info;
}
return new Request(typeof info === "string" ? new URL(info, url) : info, init2);
}
let body;
let etag;
let headers;
function get_public_env(request) {
body ??= `export const env=${JSON.stringify(public_env)}`;
etag ??= `W/${Date.now()}`;
headers ??= new Headers({
"content-type": "application/javascript; charset=utf-8",
etag
});
if (request.headers.get("if-none-match") === etag) {
return new Response(void 0, { status: 304, headers });
}
return new Response(body, { headers });
}
const default_transform = ({ html }) => html;
const default_filter = () => false;
const default_preload = ({ type }) => type === "js" || type === "css";
const page_methods = /* @__PURE__ */ new Set(["GET", "HEAD", "POST"]);
const allowed_page_methods = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
async function respond(request, options2, manifest, state) {
const url = new URL(request.url);
if (options2.csrf_check_origin) {
const forbidden = is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request.headers.get("origin") !== url.origin;
if (forbidden) {
const csrf_error = new HttpError(
403,
`Cross-site ${request.method} form submissions are forbidden`
);
if (request.headers.get("accept") === "application/json") {
return json(csrf_error.body, { status: csrf_error.status });
}
return text(csrf_error.body.message, { status: csrf_error.status });
}
}
let rerouted_path;
try {
rerouted_path = options2.hooks.reroute({ url: new URL(url) }) ?? url.pathname;
} catch (e) {
return text("Internal Server Error", {
status: 500
});
}
let decoded;
try {
decoded = decode_pathname(rerouted_path);
} catch {
return text("Malformed URI", { status: 400 });
}
let route = null;
let params = {};
if (base && !state.prerendering?.fallback) {
if (!decoded.startsWith(base)) {
return text("Not found", { status: 404 });
}
decoded = decoded.slice(base.length) || "/";
}
if (decoded === `/${options2.app_dir}/env.js`) {
return get_public_env(request);
}
if (decoded.startsWith(`/${options2.app_dir}`)) {
return text("Not found", { status: 404 });
}
const is_data_request = has_data_suffix(decoded);
let invalidated_data_nodes;
if (is_data_request) {
decoded = strip_data_suffix(decoded) || "/";
url.pathname = strip_data_suffix(url.pathname) + (url.searchParams.get(TRAILING_SLASH_PARAM) === "1" ? "/" : "") || "/";
url.searchParams.delete(TRAILING_SLASH_PARAM);
invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
url.searchParams.delete(INVALIDATED_PARAM);
}
if (!state.prerendering?.fallback) {
const matchers = await manifest._.matchers();
for (const candidate of manifest._.routes) {
const match = candidate.pattern.exec(decoded);
if (!match)
continue;
const matched = exec(match, candidate.params, matchers);
if (matched) {
route = candidate;
params = decode_params(matched);
break;
}
}
}
let trailing_slash = void 0;
const headers2 = {};
let cookies_to_add = {};
const event = {
// @ts-expect-error `cookies` and `fetch` need to be created after the `event` itself
cookies: null,
// @ts-expect-error
fetch: null,
getClientAddress: state.getClientAddress || (() => {
throw new Error(
`${"@sveltejs/adapter-node"} does not specify getClientAddress. Please raise an issue`
);
}),
locals: {},
params,
platform: state.platform,
request,
route: { id: route?.id ?? null },
setHeaders: (new_headers) => {
for (const key2 in new_headers) {
const lower = key2.toLowerCase();
const value = new_headers[key2];
if (lower === "set-cookie") {
throw new Error(
"Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies"
);
} else if (lower in headers2) {
throw new Error(`"${key2}" header is already set`);
} else {
headers2[lower] = value;
if (state.prerendering && lower === "cache-control") {
state.prerendering.cache = /** @type {string} */
value;
}
}
}
},
url,
isDataRequest: is_data_request,
isSubRequest: state.depth > 0
};
let resolve_opts = {
transformPageChunk: default_transform,
filterSerializedResponseHeaders: default_filter,
preload: default_preload
};
try {
if (route) {
if (url.pathname === base || url.pathname === base + "/") {
trailing_slash = "always";
} else if (route.page) {
const nodes = await Promise.all([
// we use == here rather than === because [undefined] serializes as "[null]"
...route.page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()),
manifest._.nodes[route.page.leaf]()
]);
if (DEV)
;
trailing_slash = get_option(nodes, "trailingSlash");
} else if (route.endpoint) {
const node = await route.endpoint();
trailing_slash = node.trailingSlash;
if (DEV)
;
}
if (!is_data_request) {
const normalized = normalize_path(url.pathname, trailing_slash ?? "never");
if (normalized !== url.pathname && !state.prerendering?.fallback) {
return new Response(void 0, {
status: 308,
headers: {
"x-sveltekit-normalize": "1",
location: (
// ensure paths starting with '//' are not treated as protocol-relative
(normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
)
}
});
}
}
}
const { cookies, new_cookies, get_cookie_header, set_internal } = get_cookies(
request,
url,
trailing_slash ?? "never"
);
cookies_to_add = new_cookies;
event.cookies = cookies;
event.fetch = create_fetch({
event,
options: options2,
manifest,
state,
get_cookie_header,
set_internal
});
if (state.prerendering && !state.prerendering.fallback)
disable_search(url);
const response = await options2.hooks.handle({
event,
resolve: (event2, opts) => resolve2(event2, opts).then((response2) => {
for (const key2 in headers2) {
const value = headers2[key2];
response2.headers.set(
key2,
/** @type {string} */
value
);
}
add_cookies_to_headers(response2.headers, Object.values(cookies_to_add));
if (state.prerendering && event2.route.id !== null) {
response2.headers.set("x-sveltekit-routeid", encodeURI(event2.route.id));
}
return response2;
})
});
if (response.status === 200 && response.headers.has("etag")) {
let if_none_match_value = request.headers.get("if-none-match");
if (if_none_match_value?.startsWith('W/"')) {
if_none_match_value = if_none_match_value.substring(2);
}
const etag2 = (
/** @type {string} */
response.headers.get("etag")
);
if (if_none_match_value === etag2) {
const headers22 = new Headers({ etag: etag2 });
for (const key2 of [
"cache-control",
"content-location",
"date",
"expires",
"vary",
"set-cookie"
]) {
const value = response.headers.get(key2);
if (value)
headers22.set(key2, value);
}
return new Response(void 0, {
status: 304,
headers: headers22
});
}
}
if (is_data_request && response.status >= 300 && response.status <= 308) {
const location = response.headers.get("location");
if (location) {
return redirect_json_response(new Redirect(
/** @type {any} */
response.status,
location
));
}
}
return response;
} catch (e) {
if (e instanceof Redirect) {
const response = is_data_request ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
add_cookies_to_headers(response.headers, Object.values(cookies_to_add));
return response;
}
return await handle_fatal_error(event, options2, e);
}
async function resolve2(event2, opts) {
try {
if (opts) {
resolve_opts = {
transformPageChunk: opts.transformPageChunk || default_transform,
filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,
preload: opts.preload || default_preload
};
}
if (state.prerendering?.fallback) {
return await render_response({
event: event2,
options: options2,
manifest,
state,
page_config: { ssr: false, csr: true },
status: 200,
error: null,
branch: [],
fetched: [],
resolve_opts
});
}
if (route) {
const method = (
/** @type {import('types').HttpMethod} */
event2.request.method
);
let response;
if (is_data_request) {
response = await render_data(
event2,
route,
options2,
manifest,
state,
invalidated_data_nodes,
trailing_slash ?? "never"
);
} else if (route.endpoint && (!route.page || is_endpoint_request(event2))) {
response = await render_endpoint(event2, await route.endpoint(), state);
} else if (route.page) {
if (page_methods.has(method)) {
response = await render_page(event2, route.page, options2, manifest, state, resolve_opts);
} else {
const allowed_methods2 = new Set(allowed_page_methods);
const node = await manifest._.nodes[route.page.leaf]();
if (node?.server?.actions) {
allowed_methods2.add("POST");
}
if (method === "OPTIONS") {
response = new Response(null, {
status: 204,
headers: {
allow: Array.from(allowed_methods2.values()).join(", ")
}
});
} else {
const mod = [...allowed_methods2].reduce(
(acc, curr) => {
acc[curr] = true;
return acc;
},
/** @type {Record<string, any>} */
{}
);
response = method_not_allowed(mod, method);
}
}
} else {
throw new Error("This should never happen");
}
if (request.method === "GET" && route.page && route.endpoint) {
const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
if (!(vary?.includes("accept") || vary?.includes("*"))) {
response = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: new Headers(response.headers)
});
response.headers.append("Vary", "Accept");
}
}
return response;
}
if (state.error && event2.isSubRequest) {
return await fetch(request, {
headers: {
"x-sveltekit-error": "true"
}
});
}
if (state.error) {
return text("Internal Server Error", {
status: 500
});
}
if (state.depth === 0) {
return await respond_with_error({
event: event2,
options: options2,
manifest,
state,
status: 404,
error: new SvelteKitError(404, "Not Found", `Not found: ${event2.url.pathname}`),
resolve_opts
});
}
if (state.prerendering) {
return text("not found", { status: 404 });
}
return await fetch(request);
} catch (e) {
return await handle_fatal_error(event2, options2, e);
} finally {
event2.cookies.set = () => {
throw new Error("Cannot use `cookies.set(...)` after the response has been generated");
};
event2.setHeaders = () => {
throw new Error("Cannot use `setHeaders(...)` after the response has been generated");
};
}
}
}
function filter_private_env(env, { public_prefix, private_prefix }) {
return Object.fromEntries(
Object.entries(env).filter(
([k]) => k.startsWith(private_prefix) && (public_prefix === "" || !k.startsWith(public_prefix))
)
);
}
function filter_public_env(env, { public_prefix, private_prefix }) {
return Object.fromEntries(
Object.entries(env).filter(
([k]) => k.startsWith(public_prefix) && (private_prefix === "" || !k.startsWith(private_prefix))
)
);
}
class Server {
/** @type {import('types').SSROptions} */
#options;
/** @type {import('@sveltejs/kit').SSRManifest} */
#manifest;
/** @param {import('@sveltejs/kit').SSRManifest} manifest */
constructor(manifest) {
this.#options = options;
this.#manifest = manifest;
}
/**
* @param {{
* env: Record<string, string>
* }} opts
*/
async init({ env }) {
const prefixes = {
public_prefix: this.#options.env_public_prefix,
private_prefix: this.#options.env_private_prefix
};
const private_env = filter_private_env(env, prefixes);
const public_env2 = filter_public_env(env, prefixes);
set_private_env(
private_env
);
set_public_env(
public_env2
);
set_safe_public_env(public_env2);
if (!this.#options.hooks) {
try {
const module = await get_hooks();
this.#options.hooks = {
handle: module.handle || (({ event, resolve: resolve2 }) => resolve2(event)),
handleError: module.handleError || (({ error }) => console.error(error)),
handleFetch: module.handleFetch || (({ request, fetch: fetch2 }) => fetch2(request)),
reroute: module.reroute || (() => {
})
};
} catch (error) {
{
throw error;
}
}
}
}
/**
* @param {Request} request
* @param {import('types').RequestOptions} options
*/
async respond(request, options2) {
return respond(request, this.#options, this.#manifest, {
...options2,
error: false,
depth: 0
});
}
}
export { Server };
//# sourceMappingURL=index.js.map
|