@banou/ripple 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,27 +1,3 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
-
10
- ## Expanding the ESLint configuration
11
-
12
- If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13
-
14
- - Configure the top-level `parserOptions` property like this:
15
-
16
- ```js
17
- parserOptions: {
18
- ecmaVersion: 'latest',
19
- sourceType: 'module',
20
- project: ['./tsconfig.json', './tsconfig.node.json'],
21
- tsconfigRootDir: __dirname,
22
- },
23
- ```
24
-
25
- - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
26
- - Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
27
- - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
1
+ # Ripple, the torrent app that respect your privacy
2
+
3
+ THE app that allows you to download torrents and stream video files from the safety of your browser!
@@ -0,0 +1,65 @@
1
+ {
2
+ "short_name": "Ripple",
3
+ "name": "Ripple - A torrent web app",
4
+ "description": "A torrent app on the web",
5
+ "icons": [
6
+ {
7
+ "src": "./assets/logo.png",
8
+ "sizes": "512x512",
9
+ "type": "image/png"
10
+ }
11
+ ],
12
+ "id": "/?source=pwa",
13
+ "start_url": "/?source=pwa",
14
+ "background_color": "#3367D6",
15
+ "display": "standalone",
16
+ "scope": "/",
17
+ "theme_color": "#3367D6",
18
+ "shortcuts": [
19
+ {
20
+ "name": "Pause all torrents",
21
+ "short_name": "Pause all",
22
+ "description": "Pause all currently downloading torrents",
23
+ "url": "/?source=pwa&pauseAll=true"
24
+ }
25
+ ],
26
+ "protocol_handlers": [
27
+ {
28
+ "protocol": "magnet",
29
+ "url": "/protocol-handler?magnet=%s"
30
+ }
31
+ ],
32
+ "file_handlers": [
33
+ {
34
+ "action": "/file-handler",
35
+ "accept": {
36
+ "application/x-bittorrent": [".torrent"],
37
+ "x-scheme-handler/magnet": ["magnet:?xt=urn:btih:"]
38
+ },
39
+ "icons": [
40
+ {
41
+ "src": "csv-icon.png",
42
+ "sizes": "256x256",
43
+ "type": "image/png"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "share_target": {
49
+ "action": "/share-target",
50
+ "method": "POST",
51
+ "enctype": "multipart/form-data",
52
+ "params": {
53
+ "files": [
54
+ {
55
+ "name": "file",
56
+ "accept": [
57
+ "application/vnd.ripple+json",
58
+ "application/json",
59
+ ".ripple"
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ }
65
+ }
Binary file
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" id="svg" version="1.1" style="display: block;" viewBox="241.53 221.86 553.59 561.02"><path d="M0 0 C1.43601562 -0.00128906 2.87203125 -0.00257813 4.3515625 -0.00390625 C5.83398438 -0.00003906 7.31640625 0.00382813 8.84375 0.0078125 C11.02097656 0.00201172 11.02097656 0.00201172 13.2421875 -0.00390625 C27.29281243 0.00861659 41.14648003 0.67007405 55.03125 2.8828125 C56.13992432 3.0576416 57.24859863 3.2324707 58.39086914 3.41259766 C75.46869905 6.20116454 91.97294829 10.56313709 108.34375 16.1328125 C109.61863281 16.55949219 110.89351562 16.98617187 112.20703125 17.42578125 C137.69101805 26.44970596 161.98509673 39.59333948 183.34375 56.1328125 C184.60792228 57.0965518 185.8722465 58.06009181 187.13671875 59.0234375 C192.64229068 63.2510968 197.99884551 67.48581326 202.78125 72.53125 C204.51038216 74.30361047 206.33738284 75.89836169 208.21875 77.5078125 C238.30076306 103.64083543 238.30076306 103.64083543 224.34375 121.1328125 C206.05686882 133.84064519 195.03523391 118.23194141 183.47460938 104.9921875 C178.14548643 98.83312564 178.14548643 98.83312564 172.34375 93.1328125 C173.21662021 96.76660217 173.21662021 96.76660217 174.71875 99.76953125 C179.4749104 111.35025596 179.89685106 123.91385955 179.84375 136.2578125 C179.84231995 137.02017212 179.84088989 137.78253174 179.8394165 138.56799316 C179.7803597 151.33427198 178.49577199 163.04066878 174.34375 175.1328125 C173.89773438 176.47601563 173.45171875 177.81921875 172.9921875 179.203125 C167.72952654 193.52109086 155.47390264 222.83108454 136.34375 219.1328125 C127.46487844 213.10786394 127.54721907 206.22681683 132.90625 197.2578125 C136.07208719 191.69013464 138.79984729 186.09050991 141.15625 180.1328125 C141.69894531 178.7715625 142.24164062 177.4103125 142.80078125 176.0078125 C146.74802784 164.41269739 147.85851071 152.73374827 147.78979492 140.55419922 C147.78127929 138.26568522 147.81019905 135.97967672 147.84179688 133.69140625 C148.02322413 95.46322561 126.50816515 65.55443712 92.59375 49.1953125 C91.79952637 48.81020508 91.00530273 48.42509766 90.18701172 48.02832031 C87.98722152 46.96946463 87.98722152 46.96946463 85.34375 46.1328125 C86.91471159 47.96621708 88.55673462 49.51384329 90.34375 51.1328125 C150.30130282 108.26143754 134.20465706 188.23756054 83.34375 245.1328125 C82.62058594 245.96554687 81.89742187 246.79828125 81.15234375 247.65625 C72.20849353 257.83543865 62.68530347 267.59097976 52.04296875 275.99609375 C49.14641619 278.2890232 46.34310724 280.67447641 43.53125 283.0703125 C30.93540433 293.55341069 17.14015193 302.33712486 3.34375 311.1328125 C2.17714844 311.87660156 1.01054687 312.62039063 -0.19140625 313.38671875 C-9.14799031 318.99166074 -18.36719617 324.10520407 -27.65625 329.1328125 C-28.95199951 329.83712402 -28.95199951 329.83712402 -30.27392578 330.55566406 C-55.51660513 344.21146491 -81.77646525 355.13851043 -108.65625 365.1328125 C-110.03796387 365.64908203 -111.41967773 366.16535156 -112.84326172 366.69726562 C-132.81777655 374.13055692 -152.90473899 380.20850234 -173.65625 385.1328125 C-176.36079099 385.78989593 -179.06521708 386.44745245 -181.76953125 387.10546875 C-184.41880683 387.74151913 -187.06853266 388.37569762 -189.71875 389.0078125 C-190.91274414 389.29438721 -192.10673828 389.58096191 -193.33691406 389.8762207 C-204.77803978 392.54383653 -216.26364705 394.48121697 -228.03125 394.6328125 C-229.26681641 394.6946875 -229.26681641 394.6946875 -230.52734375 394.7578125 C-246.14911781 394.95586986 -252.79748741 379.93739576 -251.65625 366.1328125 C-248.45567512 355.93098006 -239.79425366 352.12975964 -229.96484375 351.05859375 C-228.94310562 350.92261276 -227.92136749 350.78663177 -226.8686676 350.64653015 C-223.61318875 350.21869356 -220.35451122 349.83059814 -217.09375 349.4453125 C-212.84126738 348.90885542 -208.59068395 348.35789307 -204.33984375 347.80859375 C-203.28933838 347.67528656 -202.23883301 347.54197937 -201.15649414 347.40463257 C-193.81356963 346.45954905 -186.51093347 345.35395908 -179.21484375 344.09765625 C-177.84724159 343.86530022 -177.84724159 343.86530022 -176.45201111 343.62825012 C-168.51894396 342.22390466 -160.77647159 340.22063971 -153.0859375 337.82421875 C-152.20647461 337.55109863 -151.32701172 337.27797852 -150.42089844 336.99658203 C-149.50856445 336.71153809 -148.59623047 336.42649414 -147.65625 336.1328125 C-146.68461914 335.83358887 -145.71298828 335.53436523 -144.71191406 335.22607422 C-120.81891649 327.84994376 -97.37905215 319.60427756 -74.65625 309.1328125 C-73.47256836 308.58882812 -72.28888672 308.04484375 -71.06933594 307.484375 C-40.19229595 293.18577145 -10.47579429 276.18471286 16.34375 255.1328125 C17.55611328 254.19115234 17.55611328 254.19115234 18.79296875 253.23046875 C21.33596935 251.22800934 23.84402174 249.18904058 26.34375 247.1328125 C27.36726563 246.29621094 28.39078125 245.45960938 29.4453125 244.59765625 C44.26324246 232.21531707 57.93657376 218.7493461 69.34375 203.1328125 C70.19195313 202.01777344 71.04015625 200.90273438 71.9140625 199.75390625 C91.74557337 173.09962788 103.85727978 136.66798992 91.34375 104.1328125 C91.03179688 103.30523437 90.71984375 102.47765625 90.3984375 101.625 C89.47505231 99.39801218 88.44641178 97.27623224 87.34375 95.1328125 C86.92480469 94.27429688 86.50585938 93.41578125 86.07421875 92.53125 C44.53828339 11.29016431 -60.94046877 38.47935798 -120.84375 80.0078125 C-152.28814738 103.05983349 -250.74078961 225.23053485 -215.65625 267.1328125 C-211.75992551 268.1154834 -207.63855881 267.43086472 -203.65625 267.1328125 C-202.33367187 267.060625 -201.01109375 266.9884375 -199.6484375 266.9140625 C-168.21182612 264.7595826 -137.10330292 255.93462537 -107.65625 245.1328125 C-106.3882959 244.67285889 -106.3882959 244.67285889 -105.09472656 244.20361328 C-81.80918674 235.72535614 -59.55359541 225.44223583 -38.50390625 212.32421875 C-37.46806396 211.6806543 -36.43222168 211.03708984 -35.36499023 210.37402344 C-33.34948481 209.11343498 -31.34204319 207.83983598 -29.34399414 206.55175781 C-28.4286792 205.97651367 -27.51336426 205.40126953 -26.5703125 204.80859375 C-25.7654541 204.29208252 -24.9605957 203.77557129 -24.13134766 203.2434082 C-18.30228049 200.62786011 -11.67353426 202.09824399 -8.65625 208.1328125 C-4.44264301 259.53881774 -195.55638476 308.9581157 -233.71875 309.5078125 C-234.80736328 309.53399658 -235.89597656 309.56018066 -237.01757812 309.5871582 C-245.32523128 309.60475916 -250.94599756 307.72690496 -256.46875 301.1953125 C-257.03207031 300.54691406 -257.59539062 299.89851563 -258.17578125 299.23046875 C-263.21104559 292.09607047 -262.00904408 283.67644131 -261.96875 275.3203125 C-261.96626251 274.50914978 -261.96377502 273.69798706 -261.96121216 272.86224365 C-261.7725011 233.09371678 -252.03867801 194.84781247 -234.65625 159.1328125 C-234.18590332 158.16085937 -233.71555664 157.18890625 -233.23095703 156.1875 C-221.92753451 133.06104148 -208.10585124 112.46790288 -190.75390625 93.44921875 C-188.95033387 91.45756433 -187.20518904 89.43259393 -185.46875 87.3828125 C-176.73131399 77.38848314 -167.14108028 68.26604513 -156.65625 60.1328125 C-155.73328125 59.38128906 -154.8103125 58.62976563 -153.859375 57.85546875 C-125.39585792 35.10677699 -91.0671881 17.70973319 -55.65625 9.1328125 C-54.48707031 8.79121094 -53.31789063 8.44960937 -52.11328125 8.09765625 C-35.65141633 3.29247259 -17.17071957 0.01512268 0 0 Z " transform="translate(503.65625,221.8671875)" style="fill: rgb(67, 99, 120); --darkreader-inline-fill: #8aa9be;" data-darkreader-inline-fill=""/><path d="M0 0 C1.7838126 -0.01748915 3.56757262 -0.0417563 5.35119629 -0.07305908 C7.88448281 -0.11525186 10.41666077 -0.13063401 12.95025635 -0.13967896 C14.41865967 -0.15426147 15.88706299 -0.16884399 17.39996338 -0.18386841 C34.50748672 1.74536313 41.65017191 17.5270379 37.56744385 33.03610229 C34.36207375 41.57864365 26.09000367 46.5635684 17.25201416 46.48141479 C15.96836975 46.47480835 14.68472534 46.4682019 13.36218262 46.46139526 C11.2749588 46.43650024 11.2749588 46.43650024 9.14556885 46.41110229 C6.93286639 46.39951956 4.72016379 46.38795004 2.50745773 46.3770752 C-2.16029331 46.35090509 -6.8279124 46.30722798 -11.49554443 46.26535034 C-35.97766822 46.04904033 -60.02419772 46.32763942 -84.18255615 50.72360229 C-85.59407959 50.98036743 -87.00560303 51.23713257 -88.4598999 51.50167847 C-135.94266012 60.375063 -182.0006626 75.44538199 -226.43255615 94.28610229 C-227.61881592 94.78448608 -228.80507568 95.28286987 -230.02728271 95.7963562 C-238.19047011 99.22942155 -246.32300338 102.7282679 -254.43255615 106.28610229 C-255.43818604 106.72696167 -256.44381592 107.16782104 -257.47991943 107.62203979 C-269.65282434 112.98616414 -281.50723961 118.77331752 -293.20941162 125.09664917 C-295.34689872 126.24027284 -297.49685608 127.35433541 -299.6552124 128.45797729 C-323.78380245 140.84795164 -350.7547414 155.72600479 -365.43255615 179.28610229 C-366.09513428 180.33282104 -366.7577124 181.37953979 -367.44036865 182.45797729 C-371.80103192 190.1200334 -373.22315678 196.47590506 -373.08270264 205.15744019 C-373.01929385 215.52304759 -379.72637926 219.39992587 -389.43255615 218.28610229 C-398.55383372 215.26176335 -405.4162195 208.58835025 -412.43255615 202.28610229 C-413.47025146 201.35926636 -414.50794678 200.43243042 -415.5770874 199.47750854 C-422.06355558 193.60721321 -428.29565728 187.51872403 -434.43255615 181.28610229 C-436.87893146 178.82046419 -439.33407094 176.3788874 -441.86224365 173.99703979 C-451.10055254 165.171946 -463.62324756 152.59586284 -452.43255615 140.28610229 C-445.92717364 135.502954 -439.84062515 133.88248816 -431.99505615 132.28610229 C-429.6427677 131.77117833 -427.29119948 131.25295296 -424.94036865 130.73141479 C-423.24509033 130.3587146 -423.24509033 130.3587146 -421.51556396 129.97848511 C-393.63311409 123.71663621 -366.44280265 111.88153544 -340.43255615 100.28610229 C-339.54922607 99.89358276 -338.665896 99.50106323 -337.75579834 99.09664917 C-332.87351682 96.92291252 -328.00381248 94.72217273 -323.13763428 92.51266479 C-256.22829054 62.17398764 -256.22829054 62.17398764 -223.43255615 49.28610229 C-222.18683838 48.79368042 -220.94112061 48.30125854 -219.65765381 47.79391479 C-148.30611842 19.69023595 -77.14156188 0.64535074 0 0 Z " transform="translate(756.4325561523438,520.7138977050781)" style="fill: rgb(50, 78, 96); --darkreader-inline-fill: #9ab8cb;" data-darkreader-inline-fill=""/><path d="M0 0 C0.49275041 5.82972322 -0.74941785 9.34391259 -3.4375 14.5 C-3.79875977 15.19359619 -4.16001953 15.88719238 -4.53222656 16.60180664 C-13.37944072 33.36625049 -23.91592478 48.88907657 -35.8125 63.625 C-36.3271582 64.2636499 -36.84181641 64.9022998 -37.37207031 65.56030273 C-40.51046018 69.38162959 -43.82377517 72.9205398 -47.375 76.36181641 C-49.08273787 78.08340912 -50.63597427 79.88730899 -52.1875 81.75 C-78.22966722 111.70136671 -115.49094788 130.44024054 -152 144 C-153.13614746 144.43151367 -154.27229492 144.86302734 -155.44287109 145.30761719 C-163.84202805 148.42558441 -172.25380083 150.70449587 -181 152.625 C-182.34489502 152.92422363 -183.68979004 153.22344727 -185.07543945 153.53173828 C-219.04810129 160.90680973 -252.56897496 161.58154769 -287 157 C-287.95390625 156.8772168 -288.9078125 156.75443359 -289.890625 156.62792969 C-311.13622079 153.84174787 -338.88130756 145.85684704 -332.37890625 118.375 C-326.02767485 98.50270264 -307.27360767 84.69220404 -291 73 C-289.82050781 72.14792969 -288.64101563 71.29585937 -287.42578125 70.41796875 C-269.69948574 58.13064857 -250.14967691 48.85996728 -230.49658203 40.11914062 C-227.39303872 38.727918 -224.32194261 37.27196699 -221.25 35.8125 C-203.32418448 27.57694863 -184.67003111 21.3030949 -166 15 C-164.21212312 14.3909668 -162.42434932 13.7816308 -160.63671875 13.171875 C-117.87870608 -1.34604411 -117.87870608 -1.34604411 -114.55078125 17.55078125 C-113.06893013 41.3591893 -152.73262472 50.45809803 -169.98803711 57.49023438 C-193.1313717 66.93512193 -215.44068794 77.67169467 -236 92 C-236.70511719 92.48984375 -237.41023437 92.9796875 -238.13671875 93.484375 C-253.94490313 104.0310714 -253.94490313 104.0310714 -258 120 C-255.51167205 120.88904502 -255.51167205 120.88904502 -252.40234375 120.69140625 C-250.62923828 120.68620972 -250.62923828 120.68620972 -248.8203125 120.6809082 C-247.53898438 120.6418335 -246.25765625 120.60275879 -244.9375 120.5625 C-243.62652344 120.53953857 -242.31554687 120.51657715 -240.96484375 120.49291992 C-185.76296035 119.09214539 -131.58227067 98.33616746 -90 62 C-89.22527344 61.33742188 -88.45054687 60.67484375 -87.65234375 59.9921875 C-80.50497717 53.85013453 -74.06952811 47.20339599 -68 40 C-67.30729004 39.18595703 -67.30729004 39.18595703 -66.60058594 38.35546875 C-58.17015161 28.40723671 -50.86453373 18.07679643 -44 7 C-34.05421622 -8.86726198 -7.98356282 -31.93425128 0 0 Z " transform="translate(763,623)" style="fill: rgb(44, 70, 88); --darkreader-inline-fill: #9fbccf;" data-darkreader-inline-fill=""/><path d="M0 0 C3.32953685 9.43897273 5.1435664 18.49524204 5.25 28.5 C5.28867187 30.68109375 5.28867187 30.68109375 5.328125 32.90625 C4.21023295 46.85328418 -7.37198516 49.91069454 -19.46728516 50.23852539 C-60.10841883 51.45559037 -101.58029394 66.78075702 -135.0703125 89.56640625 C-142.15343271 93.03241307 -147.50020783 90.99958433 -151 84 C-151.76294162 72.36514032 -145.57994536 68.6070717 -137 62 C-135.89269531 61.14019531 -134.78539062 60.28039062 -133.64453125 59.39453125 C-109.44204723 41.10410439 -81.94843337 27.97227423 -54.29101562 15.80859375 C-51.68657956 14.65907572 -49.09291974 13.48771733 -46.5 12.3125 C-45.34322754 11.81423706 -45.34322754 11.81423706 -44.16308594 11.3059082 C-38.74480245 8.82403536 -35.50699984 5.78545588 -32 1 C-31.27554688 0.01515625 -30.55109375 -0.9696875 -29.8046875 -1.984375 C-28.51163512 -3.83757557 -27.21998181 -5.69175306 -25.9296875 -7.546875 C-16.59851078 -19.40918063 -5.33426337 -10.65350064 0 0 Z " transform="translate(787,422)" style="fill: rgb(59, 91, 111); --darkreader-inline-fill: #90b0c4;" data-darkreader-inline-fill=""/><path d="M0 0 C0.31196979 27.359751 -18.78808196 42.31141916 -45.3359375 39.73828125 C-66.89269446 32.9487515 -77.74393183 9.06378054 -67.9375 -11.5078125 C-51.43494208 -39.8841621 -3.68108366 -35.7407541 0 0 Z " transform="translate(517.3359375,347.26171875)" style="fill: rgb(71, 107, 129); --darkreader-inline-fill: #84a6bb;" data-darkreader-inline-fill=""/><path d="M0 0 C0.97915512 19.93054459 -13.40775624 31.0989125 -32.37890625 29.58984375 C-48.64083377 24.25806424 -58.80402322 7.04293413 -50.37890625 -9.41015625 C-36.66668542 -30.01744266 -4.08007942 -25.95267011 0 0 Z " transform="translate(410.37890625,404.41015625)" style="fill: rgb(65, 96, 117); --darkreader-inline-fill: #8cabbf;" data-darkreader-inline-fill=""/><path d="M0 0 C2.74085811 17.54714315 -12.19632854 22.71109327 -26 28 C-26.78375 28.32226562 -27.5675 28.64453125 -28.375 28.9765625 C-37.11043427 32.31474631 -48.0611068 33.87778639 -53 24 C-54.66610087 10.25466781 -43.16839929 4.29033914 -33 -3 C-32.39607422 -3.43618652 -31.79214844 -3.87237305 -31.16992188 -4.32177734 C-29.35976758 -5.6141277 -27.52373233 -6.86997855 -25.6875 -8.125 C-24.59824219 -8.87007813 -23.50898437 -9.61515625 -22.38671875 -10.3828125 C-12.24165505 -15.22716818 -3.99480526 -9.74732483 0 0 Z " transform="translate(765,368)" style="fill: rgb(64, 97, 118); --darkreader-inline-fill: #8bacc0;" data-darkreader-inline-fill=""/></svg>
package/build/index.html CHANGED
@@ -4,6 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Ripple Torrent</title>
7
+ <link rel="shortcut icon" type="image/png" href="/assets/logo.png"/>
8
+ <link rel="manifest" href="/app.webmanifest">
7
9
  </head>
8
10
  <body>
9
11
  <script type="module" src="/index.js"></script>
package/build/index.js CHANGED
@@ -1 +1 @@
1
- import{__tla as __tla_0}from"./shared-worker-05e72720.js";import{__tla as __tla_1}from"./settings-bc96f65e.js";import"./index-9a320571.js";import"./index-8227e1be.js";Promise.all([(()=>{try{return __tla_0}catch{}})(),(()=>{try{return __tla_1}catch{}})()]).then(async()=>{});
1
+ import{__tla as __tla_0}from"./shared-worker-c85a5375.js";import{__tla as __tla_1}from"./settings-b282903e.js";import"./index-9a320571.js";import"./index-8227e1be.js";Promise.all([(()=>{try{return __tla_0}catch{}})(),(()=>{try{return __tla_1}catch{}})()]).then(async()=>{});
@@ -0,0 +1,3 @@
1
+ import{R as z,D as H}from"./index-9a320571.js";import{o as lt,k as ht,E as ge,m as zt,n as it,q as me,O as ve,s as Jt,v as xt,w as Ee,d as Dt,p as Se,b as we,x as _e,y as rt,z as et,A as It,t as Te,__tla as __tla_0}from"./settings-b282903e.js";import{v as be,P as Re}from"./index-8227e1be.js";let le,zn,Vn;let __tla=Promise.all([(()=>{try{return __tla_0}catch{}})()]).then(async()=>{function xe(t){return lt(function(e,n){var s=!1;e.subscribe(ht(n,function(i){s=!0,n.next(i)},function(){s||n.next(t),n.complete()}))})}function De(t){return t<=0?function(){return ge}:lt(function(e,n){var s=0;e.subscribe(ht(n,function(i){++s<=t&&(n.next(i),t<=s&&n.complete())}))})}function Ie(t){return t===void 0&&(t=Ae),lt(function(e,n){var s=!1;e.subscribe(ht(n,function(i){s=!0,n.next(i)},function(){return s?n.complete():n.error(t())}))})}function Ae(){return new zt}function At(t,e){var n=arguments.length>=2;return function(s){return s.pipe(t?it(function(i,r){return t(i,r,s)}):me,De(1),n?xe(e):Ie(function(){return new zt}))}}function ke(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function Oe(){const t=ke();if(t.__xstate__)return t.__xstate__}const $e=t=>{if(typeof window>"u")return;const e=Oe();e&&e.register(t)};class kt{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){const n={value:e,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){const e=this._current;this._process(e.value),this._current=e.next}this._last=null}}const q=".",Me="",Gt="",Le="#",Fe="*",Kt="xstate.init",Ce="xstate.error",C="xstate.stop";function Ne(t,e){const n=e?`#${e}`:"";return{type:`xstate.after(${t})${n}`}}function ot(t,e){return{type:`xstate.done.state.${t}`,output:e}}function je(t,e){return{type:`xstate.done.actor.${t}`,output:e}}function k(t,e){return{type:`xstate.error.actor.${t}`,data:e}}function Vt(t){return{type:Kt,input:t}}function x(t){setTimeout(()=>{throw t})}const Pe=(()=>typeof Symbol=="function"&&Symbol.observable||"@@observable")();let Ue=0;function He(t){const e=new Map,n=new Map,s=new WeakMap,i=new Set,r={_bookId:()=>`x:${Ue++}`,_register:(o,a)=>(e.set(o,a),o),_unregister:o=>{e.delete(o.sessionId);const a=s.get(o);a!==void 0&&(n.delete(a),s.delete(o))},get:o=>n.get(o),_set:(o,a)=>{const c=n.get(o);if(c&&c!==a)throw new Error(`Actor with system ID '${o}' already exists.`);n.set(o,a),s.set(a,o)},inspect:o=>{i.add(o)},_sendInspectionEvent:o=>{const a={...o,rootId:t.sessionId};i.forEach(c=>c.next?.(a))},_relay:(o,a,c)=>{r._sendInspectionEvent({type:"@xstate.event",sourceRef:o,actorRef:a,event:c}),a._send(c)}};return r}function qt(t,e){const n=Ot(t),s=Ot(e);return typeof s=="string"?typeof n=="string"?s===n:!1:typeof n=="string"?n in s:Object.keys(n).every(i=>i in s?qt(n[i],s[i]):!1)}function Yt(t){try{return Qt(t)?t:t.split(q)}catch{throw new Error(`'${t}' is not a valid state path.`)}}function Ot(t){if(wn(t))return t.value;if(typeof t!="string")return t;const e=Yt(t);return Be(e)}function Be(t){if(t.length===1)return t[0];const e={};let n=e;for(let s=0;s<t.length-1;s++)if(s===t.length-2)n[t[s]]=t[s+1];else{const i=n;n={},i[t[s]]=n}return e}function $t(t,e){const n={},s=Object.keys(t);for(let i=0;i<s.length;i++){const r=s[i];n[r]=e(t[r],r,t,i)}return n}function Xt(t){return[].concat(...t)}function Zt(t){return Qt(t)?t:[t]}function S(t){return t===void 0?[]:Zt(t)}function at(t,e,n,s){return typeof t=="function"?t({context:e,event:n,self:s}):t}function Qt(t){return Array.isArray(t)}function We(t){return t.type.startsWith("xstate.error.actor")}function I(t){return Zt(t).map(e=>typeof e>"u"||typeof e=="string"?{target:e}:e)}function te(t){if(!(t===void 0||t===Me))return S(t)}function Mt(t,e,n){const s=typeof t=="object",i=s?t:void 0;return{next:(s?t.next:t)?.bind(i),error:(s?t.error:e)?.bind(i),complete:(s?t.complete:n)?.bind(i)}}function Lt(t,e){return`${t}[${e}]`}function pt(t,e){if(e.startsWith("xstate#")){const[,n]=e.match(/\[(\d+)\]$/),i=t.getStateNodeById(e.slice(7,-(n.length+2))).config.invoke;return(Array.isArray(i)?i[n]:i).src}return t.implementations.actors[e]}function ze(t){return[...new Set(Xt([...t._nodes.map(e=>e.ownEvents)]))]}const yt=1;let m=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({});const Je={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class Ge{constructor(e,n){this.logic=e,this._state=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new kt(this._process.bind(this)),this.delayedEventsMap={},this.observers=new Set,this.logger=void 0,this._processingStatus=m.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const s={...Je,...n},{clock:i,logger:r,parent:o,syncSnapshot:a,id:c,systemId:u,inspect:l}=s;this.system=o?.system??He(this),l&&!o&&this.system.inspect(Mt(l)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=r,this.clock=i,this._parent=o,this._syncSnapshot=a,this.options=s,this.src=s.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:f=>{this._deferred.push(f)},system:this.system,stopChild:f=>{if(f._parent!==this)throw new Error(`Cannot stop child actor ${f.id} of ${this.id} because it is not a child`);f._stop()}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),u&&(this._systemId=u,this.system._set(u,this)),this._initState(n?.state),u&&this._state.status!=="active"&&this.system._unregister(this)}_initState(e){this._state=e?this.logic.restoreState?this.logic.restoreState(e,this._actorScope):e:this.logic.getInitialState(this._actorScope,this.options?.input)}update(e,n){this._state=e;let s;for(;s=this._deferred.shift();)s();for(const i of this.observers)try{i.next?.(e)}catch(r){x(r)}switch(this._state.status){case"done":this._stopProcedure(),this._complete(),this._doneEvent=je(this.id,this._state.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._stopProcedure(),this._error(this._state.error),this._parent&&this.system._relay(this,this._parent,k(this.id,this._state.error));break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:e})}subscribe(e,n,s){const i=Mt(e,n,s);if(this._processingStatus!==m.Stopped)this.observers.add(i);else try{i.complete?.()}catch(r){x(r)}return{unsubscribe:()=>{this.observers.delete(i)}}}start(){if(this._processingStatus===m.Running)return this;this._syncSnapshot&&this.subscribe({next:s=>{s.status==="active"&&this._parent.send({type:`xstate.snapshot.${this.id}`,snapshot:s})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=m.Running;const e=Vt(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:e}),this._state.status){case"done":this.update(this._state,e);case"error":return this}if(this.logic.start)try{this.logic.start(this._state,this._actorScope)}catch(s){return this._stopProcedure(),this._error(s),this._parent?.send(k(this.id,s)),this}return this.update(this._state,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let n,s;try{n=this.logic.transition(this._state,e,this._actorScope)}catch(i){s={err:i}}if(s){const{err:i}=s;this._stopProcedure(),this._error(i),this._parent?.send(k(this.id,i));return}this.update(n,e),e.type===C&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===m.Stopped?this:(this.mailbox.clear(),this._processingStatus===m.NotStarted?(this._processingStatus=m.Stopped,this):(this.mailbox.enqueue({type:C}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const e of this.observers)try{e.complete?.()}catch(n){x(n)}this.observers.clear()}_error(e){if(!this.observers.size){this._parent||x(e);return}let n=!1;for(const s of this.observers){const i=s.error;n||=!i;try{i?.(e)}catch(r){x(r)}}this.observers.clear(),n&&x(e)}_stopProcedure(){if(this._processingStatus!==m.Running)return this;for(const e of Object.keys(this.delayedEventsMap))this.clock.clearTimeout(this.delayedEventsMap[e]);return this.mailbox.clear(),this.mailbox=new kt(this._process.bind(this)),this._processingStatus=m.Stopped,this.system._unregister(this),this}_send(e){this._processingStatus!==m.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}delaySend(e){const{event:n,id:s,delay:i}=e,r=this.clock.setTimeout(()=>{this.system._relay(this,e.to??this,n)},i);s&&(this.delayedEventsMap[s]=r)}cancel(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]}attachDevTools(){const{devTools:e}=this.options;e&&(typeof e=="function"?e:$e)(this)}toJSON(){return{xstate$$type:yt,id:this.id}}getPersistedState(e){return this.logic.getPersistedState(this._state,e)}[Pe](){return this}getSnapshot(){return this._state}}function N(t,e){return new Ge(t,e)}function Ke(t,e,n,s,{sendId:i}){const r=typeof i=="function"?i(n,s):i;return[e,r]}function Ve(t,e){t.self.cancel(e)}function qe(t){function e(n,s){}return e.type="xstate.cancel",e.sendId=t,e.resolve=Ke,e.execute=Ve,e}function Ye(t,e,n,s,{id:i,systemId:r,src:o,input:a,syncSnapshot:c}){const u=typeof o=="string"?pt(e.machine,o):o,l=typeof i=="function"?i(n):i;let f;return u&&(f=N(u,{id:l,src:o,parent:t?.self,syncSnapshot:c,systemId:r,input:typeof a=="function"?a({context:e.context,event:n.event,self:t?.self}):a})),[b(e,{children:{...e.children,[l]:f}}),{id:i,actorRef:f}]}function Xe(t,{id:e,actorRef:n}){n&&t.defer(()=>{if(n._processingStatus!==m.Stopped)try{n.start?.()}catch(s){t.self.send(k(e,s));return}})}function Ze(...[t,{id:e,systemId:n,input:s,syncSnapshot:i=!1}={}]){function r(o,a){}return r.type="xstate.spawnChild",r.id=e,r.systemId=n,r.src=t,r.input=s,r.syncSnapshot=i,r.resolve=Ye,r.execute=Xe,r}function Qe(t,e,n,s,{actorRef:i}){const r=typeof i=="function"?i(n,s):i,o=typeof r=="string"?e.children[r]:r;let a=e.children;return o&&(a={...a},delete a[o.id]),[b(e,{children:a}),o]}function tn(t,e){if(e){if(t.system._unregister(e),e._processingStatus!==m.Running){t.stopChild(e);return}t.defer(()=>{t.stopChild(e)})}}function ee(t){function e(n,s){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=Qe,e.execute=tn,e}function en(t,{context:e,event:n},{guards:s}){return s.some(i=>Y(i,e,n,t))}function Ft(t){function e(n,s){return!1}return e.check=en,e.guards=t,e}function Y(t,e,n,s){const{machine:i}=s,r=typeof t=="function",o=r?t:i.implementations.guards[typeof t=="string"?t:t.type];if(!r&&!o)throw new Error(`Guard '${typeof t=="string"?t:t.type}' is not implemented.'.`);if(typeof o!="function")return Y(o,e,n,s);const a={context:e,event:n},c=r||typeof t=="string"?void 0:"params"in t?typeof t.params=="function"?t.params({context:e,event:n}):t.params:void 0;return"check"in o?o.check(s,a,o):o(a,c)}const gt=t=>t.type==="atomic"||t.type==="final";function O(t){return Object.values(t.states).filter(e=>e.type!=="history")}function P(t,e){const n=[];if(e===t)return n;let s=t.parent;for(;s&&s!==e;)n.push(s),s=s.parent;return n}function J(t){const e=new Set(t),n=se(e);for(const s of e)if(s.type==="compound"&&(!n.get(s)||!n.get(s).length))Ct(s).forEach(i=>e.add(i));else if(s.type==="parallel"){for(const i of O(s))if(i.type!=="history"&&!e.has(i)){const r=Ct(i);for(const o of r)e.add(o)}}for(const s of e){let i=s.parent;for(;i;)e.add(i),i=i.parent}return e}function ne(t,e){const n=e.get(t);if(!n)return{};if(t.type==="compound"){const i=n[0];if(i){if(gt(i))return i.key}else return{}}const s={};for(const i of n)s[i.key]=ne(i,e);return s}function se(t){const e=new Map;for(const n of t)e.has(n)||e.set(n,[]),n.parent&&(e.has(n.parent)||e.set(n.parent,[]),e.get(n.parent).push(n));return e}function ie(t,e){const n=J(e);return ne(t,se(n))}function mt(t,e){return e.type==="compound"?O(e).some(n=>n.type==="final"&&t.has(n)):e.type==="parallel"?O(e).every(n=>mt(t,n)):e.type==="final"}const X=t=>t[0]===Le;function nn(t,e){return t.transitions.get(e)||[...t.transitions.keys()].filter(s=>{if(s===Fe)return!0;if(!s.endsWith(".*"))return!1;const i=s.split("."),r=e.split(".");for(let o=0;o<i.length;o++){const a=i[o],c=r[o];if(a==="*")return o===i.length-1;if(a!==c)return!1}return!0}).sort((s,i)=>i.length-s.length).flatMap(s=>t.transitions.get(s))}function sn(t){const e=t.config.after;if(!e)return[];const n=(i,r)=>{const o=typeof i=="function"?`${t.id}:delay[${r}]`:i,a=Ne(o,t.id),c=a.type;return t.entry.push(kn(a,{id:c,delay:i})),t.exit.push(qe(c)),c};return Object.keys(e).flatMap((i,r)=>{const o=e[i],a=typeof o=="string"?{target:o}:o,c=isNaN(+i)?i:+i,u=n(c,r);return S(a).map(l=>({...l,event:u,delay:c}))}).map(i=>{const{delay:r}=i;return{..._(t,i.event,i),delay:r}})}function _(t,e,n){const s=te(n.target),i=n.reenter??!1,r=an(t,s),o={...n,actions:S(n.actions),guard:n.guard,target:r,source:t,reenter:i,eventType:e,toJSON:()=>({...o,source:`#${t.id}`,target:r?r.map(a=>`#${a.id}`):void 0})};return o}function rn(t){const e=new Map;if(t.config.on)for(const n of Object.keys(t.config.on)){if(n===Gt)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const s=t.config.on[n];e.set(n,I(s).map(i=>_(t,n,i)))}if(t.config.onDone){const n=`xstate.done.state.${t.id}`;e.set(n,I(t.config.onDone).map(s=>_(t,n,s)))}for(const n of t.invoke){if(n.onDone){const s=`xstate.done.actor.${n.id}`;e.set(s,I(n.onDone).map(i=>_(t,s,i)))}if(n.onError){const s=`xstate.error.actor.${n.id}`;e.set(s,I(n.onError).map(i=>_(t,s,i)))}if(n.onSnapshot){const s=`xstate.snapshot.${n.id}`;e.set(s,I(n.onSnapshot).map(i=>_(t,s,i)))}}for(const n of t.after){let s=e.get(n.eventType);s||(s=[],e.set(n.eventType,s)),s.push(n)}return e}function on(t,e){const n=typeof e=="string"?t.states[e]:e?t.states[e.target]:void 0;if(!n&&e)throw new Error(`Initial state node "${e}" not found on parent state node #${t.id}`);const s={source:t,actions:!e||typeof e=="string"?[]:S(e.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...s,source:`#${t.id}`,target:n?[`#${n.id}`]:[]})};return s}function an(t,e){if(e!==void 0)return e.map(n=>{if(typeof n!="string")return n;if(X(n))return t.machine.getStateNodeById(n);const s=n[0]===q;if(s&&!t.parent)return G(t,n.slice(1));const i=s?t.key+n:n;if(t.parent)try{return G(t.parent,i)}catch(r){throw new Error(`Invalid transition definition for state node '${t.id}':
2
+ ${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function re(t){const e=te(t.config.target);return e?{target:e.map(n=>typeof n=="string"?G(t.parent,n):n)}:t.parent.initial}function T(t){return t.type==="history"}function Ct(t){const e=oe(t);for(const n of e)for(const s of P(n,t))e.add(s);return e}function oe(t){const e=new Set;function n(s){if(!e.has(s)){if(e.add(s),s.type==="compound")n(s.initial.target[0]);else if(s.type==="parallel")for(const i of O(s))n(i)}}return n(t),e}function $(t,e){if(X(e))return t.machine.getStateNodeById(e);if(!t.states)throw new Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);const n=t.states[e];if(!n)throw new Error(`Child state '${e}' does not exist on '${t.id}'`);return n}function G(t,e){if(typeof e=="string"&&X(e))try{return t.machine.getStateNodeById(e)}catch{}const n=Yt(e).slice();let s=t;for(;n.length;){const i=n.shift();if(!i.length)break;s=$(s,i)}return s}function K(t,e){if(typeof e=="string")return[t,t.states[e]];const n=Object.keys(e),s=n.map(i=>$(t,i)).filter(Boolean);return[t.machine.root,t].concat(s,n.reduce((i,r)=>{const o=$(t,r);if(!o)return i;const a=K(o,e[r]);return i.concat(a)},[]))}function cn(t,e,n,s){const r=$(t,e).next(n,s);return!r||!r.length?t.next(n,s):r}function dn(t,e,n,s){const i=Object.keys(e),r=$(t,i[0]),o=vt(r,e[i[0]],n,s);return!o||!o.length?t.next(n,s):o}function un(t,e,n,s){const i=[];for(const r of Object.keys(e)){const o=e[r];if(!o)continue;const a=$(t,r),c=vt(a,o,n,s);c&&i.push(...c)}return i.length?i:t.next(n,s)}function vt(t,e,n,s){return typeof e=="string"?cn(t,e,n,s):Object.keys(e).length===1?dn(t,e,n,s):un(t,e,n,s)}function fn(t){return Object.keys(t.states).map(e=>t.states[e]).filter(e=>e.type==="history")}function w(t,e){let n=t;for(;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function ln(t,e){const n=new Set(t),s=new Set(e);for(const i of n)if(s.has(i))return!0;for(const i of s)if(n.has(i))return!0;return!1}function ae(t,e,n){const s=new Set;for(const i of t){let r=!1;const o=new Set;for(const a of s)if(ln(ct([i],e,n),ct([a],e,n)))if(w(i.source,a.source))o.add(a);else{r=!0;break}if(!r){for(const a of o)s.delete(a);s.add(i)}}return Array.from(s)}function hn(t){const[e,...n]=t;for(const s of P(e,void 0))if(n.every(i=>w(i,s)))return s}function Et(t,e){if(!t.target)return[];const n=new Set;for(const s of t.target)if(T(s))if(e[s.id])for(const i of e[s.id])n.add(i);else for(const i of Et(re(s),e))n.add(i);else n.add(s);return[...n]}function ce(t,e){const n=Et(t,e);if(!n)return;if(!t.reenter&&n.every(i=>i===t.source||w(i,t.source)))return t.source;const s=hn(n.concat(t.source));if(s)return s;if(!t.reenter)return t.source.machine.root}function ct(t,e,n){const s=new Set;for(const i of t)if(i.target?.length){const r=ce(i,n);i.reenter&&i.source===r&&s.add(r);for(const o of e)w(o,r)&&s.add(o)}return[...s]}function pn(t,e){if(t.length!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function dt(t,e,n,s,i,r){if(!t.length)return e;const o=new Set(e._nodes);let a=e.historyValue;const c=ae(t,o,a);let u=e;i||([u,a]=vn(u,s,n,c,o,a,r)),u=M(u,s,n,c.flatMap(f=>f.actions),r),u=gn(u,s,n,c,o,r,a,i);const l=[...o];u.status==="done"&&(u=M(u,s,n,l.sort((f,d)=>d.order-f.order).flatMap(f=>f.exit),r));try{return a===e.historyValue&&pn(e._nodes,o)?u:b(u,{_nodes:l,historyValue:a})}catch(f){throw f}}function yn(t,e,n,s,i){if(!s.output)return;const r=ot(i.id,i.output&&i.parent?at(i.output,t.context,e,n.self):void 0);return at(s.output,t.context,r,n.self)}function gn(t,e,n,s,i,r,o,a){let c=t;const u=new Set,l=new Set;mn(s,o,l,u),a&&l.add(t.machine.root);const f=new Set;for(const d of[...u].sort((h,p)=>h.order-p.order)){i.add(d);const h=[];h.push(...d.entry);for(const p of d.invoke)h.push(Ze(p.src,{...p,syncSnapshot:!!p.onSnapshot}));if(l.has(d)){const p=d.initial.actions;h.push(...p)}if(c=M(c,e,n,h,r,d.invoke.map(p=>p.id)),d.type==="final"){const p=d.parent;let g=p?.type==="parallel"?p:p?.parent,v=g||d;for(p?.type==="compound"&&r.push(ot(p.id,d.output?at(d.output,c.context,e,n.self):void 0));g?.type==="parallel"&&!f.has(g)&&mt(i,g);)f.add(g),r.push(ot(g.id)),v=g,g=g.parent;if(g)continue;c=b(c,{status:"done",output:yn(c,e,n,c.machine.root,v)})}}return c}function mn(t,e,n,s){for(const i of t){const r=ce(i,e);for(const a of i.target||[])!T(a)&&(i.source!==a||i.source!==r||i.reenter)&&(s.add(a),n.add(a)),A(a,e,n,s);const o=Et(i,e);for(const a of o){const c=P(a,r);r?.type==="parallel"&&c.push(r),de(s,e,n,c,!i.source.parent&&i.reenter?void 0:r)}}}function A(t,e,n,s){if(T(t))if(e[t.id]){const i=e[t.id];for(const r of i)s.add(r),A(r,e,n,s);for(const r of i)nt(r,t.parent,s,e,n)}else{const i=re(t);for(const r of i.target)s.add(r),i===t.parent?.initial&&n.add(t.parent),A(r,e,n,s);for(const r of i.target)nt(r,t,s,e,n)}else if(t.type==="compound"){const[i]=t.initial.target;T(i)||(s.add(i),n.add(i)),A(i,e,n,s),nt(i,t,s,e,n)}else if(t.type==="parallel")for(const i of O(t).filter(r=>!T(r)))[...s].some(r=>w(r,i))||(T(i)||(s.add(i),n.add(i)),A(i,e,n,s))}function de(t,e,n,s,i){for(const r of s)if((!i||w(r,i))&&t.add(r),r.type==="parallel")for(const o of O(r).filter(a=>!T(a)))[...t].some(a=>w(a,o))||(t.add(o),A(o,e,n,t))}function nt(t,e,n,s,i){de(n,s,i,P(t,e))}function vn(t,e,n,s,i,r,o){let a=t;const c=ct(s,i,r);c.sort((l,f)=>f.order-l.order);let u;for(const l of c)for(const f of fn(l)){let d;f.history==="deep"?d=h=>gt(h)&&w(h,l):d=h=>h.parent===l,u??={...r},u[f.id]=Array.from(i).filter(d)}for(const l of c)a=M(a,e,n,[...l.exit,...l.invoke.map(f=>ee(f.id))],o),i.delete(l);return[a,u||r]}function ue(t,e,n,s,i,r){const{machine:o}=t;let a=t;for(const c of s){const u=typeof c=="function",l=u?c:(o.implementations.actions[typeof c=="string"?c:c.type]);if(!l)continue;const f={context:a.context,event:e,self:n?.self,system:n?.system},d=u||typeof c=="string"?void 0:"params"in c?typeof c.params=="function"?c.params({context:a.context,event:e}):c.params:void 0;if(!("resolve"in l)){n?.self._processingStatus===m.Running?l(f,d):n?.defer(()=>{l(f,d)});continue}const h=l,[p,g,v]=h.resolve(n,a,f,d,l,i);a=p,"retryResolve"in h&&r?.push([h,g]),"execute"in h&&(n?.self._processingStatus===m.Running?h.execute(n,g):n?.defer(h.execute.bind(null,n,g))),v&&(a=ue(a,e,n,v,i,r))}return a}function M(t,e,n,s,i,r){const o=r?[]:void 0,a=ue(t,e,n,s,{internalQueue:i,deferredActorIds:r},o);return o?.forEach(([c,u])=>{c.retryResolve(n,a,u)}),a}function st(t,e,n,s=[]){let i=t;const r=[];if(e.type===C)return i=b(Nt(i,e,n),{status:"stopped"}),r.push(i),{state:i,microstates:r};let o=e;if(o.type!==Kt){const c=jt(o,i);i=dt(c,t,n,o,!1,s),r.push(i)}let a=!0;for(;i.status==="active";){let c=a?En(i,o):[];const u=c.length?i:void 0;if(!c.length){if(!s.length)break;o=s.shift(),c=jt(o,i)}i=dt(c,i,n,o,!1,s),a=i!==u,r.push(i)}return i.status!=="active"&&Nt(i,o,n),{state:i,microstates:r}}function Nt(t,e,n){return M(t,e,n,Object.values(t.children).map(s=>ee(s)),[])}function jt(t,e){return e.machine.getTransitionData(e,t)}function En(t,e){const n=new Set,s=t._nodes.filter(gt);for(const i of s)t:for(const r of[i].concat(P(i,void 0)))if(r.always){for(const o of r.always)if(o.guard===void 0||Y(o.guard,t.context,e,t)){n.add(o);break t}}return ae(Array.from(n),new Set(t._nodes),t.historyValue)}function Sn(t,e){const n=J(K(t,e));return ie(t,[...n])}function wn(t){return!!t&&typeof t=="object"&&"machine"in t&&"value"in t}const _n=function(e){return qt(e,this.value)},Tn=function(e){return this.tags.has(e)},bn=function(e){const n=this.machine.getTransitionData(this,e);return!!n?.length&&n.some(s=>s.target!==void 0||s.actions.length)},Rn=function(){const{_nodes:e,tags:n,machine:s,getMeta:i,toJSON:r,can:o,hasTag:a,matches:c,...u}=this;return{...u,tags:Array.from(n)}},xn=function(){return this._nodes.reduce((e,n)=>(n.meta!==void 0&&(e[n.id]=n.meta),e),{})};function B(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:ie(e.root,t._nodes),tags:new Set(Xt(t._nodes.map(n=>n.tags))),children:t.children,historyValue:t.historyValue||{},matches:_n,hasTag:Tn,can:bn,getMeta:xn,toJSON:Rn}}function b(t,e={}){return B({...t,...e},t.machine)}function Dn(t,e){const{_nodes:n,tags:s,machine:i,children:r,context:o,can:a,hasTag:c,matches:u,getMeta:l,toJSON:f,...d}=t,h={};for(const g in r){const v=r[g];h[g]={state:v.getPersistedState(e),src:v.src,systemId:v._systemId,syncSnapshot:v._syncSnapshot}}return{...d,context:fe(o),children:h}}function fe(t){let e;for(const n in t){const s=t[n];if(s&&typeof s=="object")if("sessionId"in s&&"send"in s&&"ref"in s)e??=Array.isArray(t)?t.slice():{...t},e[n]={xstate$$type:yt,id:s.id};else{const i=fe(s);i!==s&&(e??=Array.isArray(t)?t.slice():{...t},e[n]=i)}}return e??t}function In(t,e,n,s,{event:i,id:r,delay:o},{internalQueue:a}){const c=e.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);const u=typeof i=="function"?i(n,s):i;let l;if(typeof o=="string"){const f=c&&c[o];l=typeof f=="function"?f(n,s):f}else l=typeof o=="function"?o(n,s):o;return typeof l!="number"&&a.push(u),[e,{event:u,id:r,delay:l}]}function An(t,e){if(typeof e.delay=="number"){t.self.delaySend(e);return}}function kn(t,e){function n(s,i){}return n.type="xstate.raise",n.event=t,n.id=e?.id,n.delay=e?.delay,n.resolve=In,n.execute=An,n}function j(t){const e="$$xstate.next",n="$$xstate.error",s="$$xstate.complete";return{config:t,transition:(r,o,{self:a,id:c,defer:u,system:l})=>{if(r.status!=="active")return r;switch(o.type){case e:return{...r,context:o.data};case n:return{...r,status:"error",error:o.data,input:void 0,_subscription:void 0};case s:return{...r,status:"done",input:void 0,_subscription:void 0};case C:return r._subscription.unsubscribe(),{...r,status:"stopped",input:void 0,_subscription:void 0};default:return r}},getInitialState:(r,o)=>({status:"active",output:void 0,error:void 0,context:void 0,input:o,_subscription:void 0}),start:(r,{self:o,system:a})=>{r.status!=="done"&&(r._subscription=t({input:r.input,system:a,self:o}).subscribe({next:c=>{a._relay(o,o,{type:e,data:c})},error:c=>{a._relay(o,o,{type:n,data:c})},complete:()=>{a._relay(o,o,{type:s})}}))},getPersistedState:({_subscription:r,...o})=>o,restoreState:r=>({...r,_subscription:void 0})}}const Pt="$$xstate.resolve",Ut="$$xstate.reject";function W(t){return{config:t,transition:(n,s)=>{if(n.status!=="active")return n;switch(s.type){case Pt:{const i=s.data;return{...n,status:"done",output:i,input:void 0}}case Ut:return{...n,status:"error",error:s.data,input:void 0};case C:return{...n,status:"stopped",input:void 0};default:return n}},start:(n,{self:s,system:i})=>{if(n.status!=="active")return;Promise.resolve(t({input:n.input,system:i,self:s})).then(o=>{s.getSnapshot().status==="active"&&i._relay(s,s,{type:Pt,data:o})},o=>{s.getSnapshot().status==="active"&&i._relay(s,s,{type:Ut,data:o})})},getInitialState:(n,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedState:n=>n,restoreState:n=>n}}function On(t,{machine:e,context:n},s,i){const r=(o,a={})=>{const{systemId:c,input:u}=a;if(typeof o=="string"){const l=pt(e,o);if(!l)throw new Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);const f=N(l,{id:a.id,parent:t.self,syncSnapshot:a.syncSnapshot,input:typeof u=="function"?u({context:n,event:s,self:t.self}):u,src:o,systemId:c});return i[f.id]=f,f}else return N(o,{id:a.id,parent:t.self,syncSnapshot:a.syncSnapshot,input:a.input,src:o,systemId:c})};return(o,a)=>{const c=r(o,a);return i[c.id]=c,t.defer(()=>{if(c._processingStatus!==m.Stopped)try{c.start?.()}catch(u){t.self.send(k(c.id,u));return}}),c}}function $n(t,e,n,s,{assignment:i}){if(!e.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const r={},o={context:e.context,event:n.event,spawn:On(t,e,n.event,r),self:t?.self,system:t?.system};let a={};if(typeof i=="function")a=i(o,s);else for(const u of Object.keys(i)){const l=i[u];a[u]=typeof l=="function"?l(o,s):l}const c=Object.assign({},e.context,a);return[b(e,{context:c,children:Object.keys(r).length?{...e.children,...r}:e.children})]}function y(t){function e(n,s){}return e.type="xstate.assign",e.assignment=t,e.resolve=$n,e}let ut=function(t){return t.Parent="#_parent",t.Internal="#_internal",t}({});function Mn(t,e,n,s,{to:i,event:r,id:o,delay:a},c){const u=e.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${r}" }) instead`);const l=typeof r=="function"?r(n,s):r;let f;if(typeof a=="string"){const p=u&&u[a];f=typeof p=="function"?p(n,s):p}else f=typeof a=="function"?a(n,s):a;const d=typeof i=="function"?i(n,s):i;let h;if(typeof d=="string"){if(d===ut.Parent?h=t?.self._parent:d===ut.Internal?h=t?.self:d.startsWith("#_")?h=e.children[d.slice(2)]:h=c.deferredActorIds?.includes(d)?d:e.children[d],!h)throw new Error(`Unable to send event to actor '${d}' from machine '${e.machine.id}'.`)}else h=d||t?.self;return[e,{to:h,event:l,id:o,delay:f}]}function Ln(t,e,n){typeof n.to=="string"&&(n.to=e.children[n.to])}function Fn(t,e){if(typeof e.delay=="number"){t.self.delaySend(e);return}t.defer(()=>{const{to:n,event:s}=e;t?.system._relay(t.self,n,s.type===Ce?k(t.self.id,s.data):s)})}function Cn(t,e,n){function s(i,r){}return s.type="xstate.sendTo",s.to=t,s.event=e,s.id=n?.id,s.delay=n?.delay,s.resolve=Mn,s.retryResolve=Ln,s.execute=Fn,s}function F(t,e){return Cn(ut.Parent,t,e)}const Ht=new WeakMap;function D(t,e,n){let s=Ht.get(t);return s?e in s||(s[e]=n()):(s={[e]:n()},Ht.set(t,s)),s[e]}const Nn={},L=t=>typeof t=="string"?{type:t}:typeof t=="function"?"resolve"in t?{type:t.type}:{type:t.name}:t;class St{constructor(e,n){if(this.config=e,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(q),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?$t(this.config.states,(s,i)=>new St(s,{_parent:this,_key:i,_machine:this.machine})):Nn,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=S(this.config.entry).slice(),this.exit=S(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=S(e.tags).slice()}_initialize(){this.transitions=rn(this),this.config.always&&(this.always=I(this.config.always).map(e=>_(this,Gt,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(L),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(L),eventType:null})}:void 0,history:this.history,states:$t(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(L)})),entry:this.entry.map(L),exit:this.exit.map(L),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return D(this,"invoke",()=>S(this.config.invoke).map((e,n)=>{const{src:s,systemId:i}=e,r=e.id||Lt(this.id,n),o=typeof s=="string"?s:`xstate#${Lt(this.id,n)}`;return{...e,src:o,id:r,systemId:i,toJSON(){const{onDone:a,onError:c,...u}=e;return{...u,type:"xstate.invoke",src:o,id:r}}}}))}get on(){return D(this,"on",()=>[...this.transitions].flatMap(([n,s])=>s.map(i=>[n,i])).reduce((n,[s,i])=>(n[s]=n[s]||[],n[s].push(i),n),{}))}get after(){return D(this,"delayedTransitions",()=>sn(this))}get initial(){return D(this,"initial",()=>on(this,this.config.initial))}next(e,n){const s=n.type,i=[];let r;const o=D(this,`candidates-${s}`,()=>nn(this,s));for(const a of o){const{guard:c}=a,u=e.context;let l=!1;try{l=!c||Y(c,u,n,e)}catch(f){const d=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${d?`'${d}' `:""}in transition for event '${s}' in state node '${this.id}':
3
+ ${f.message}`)}if(l){i.push(...a.actions),r=a;break}}return r?[r]:void 0}get events(){return D(this,"events",()=>{const{states:e}=this,n=new Set(this.ownEvents);if(e)for(const s of Object.keys(e)){const i=e[s];if(i.states)for(const r of i.events)n.add(`${r}`)}return Array.from(n)})}get ownEvents(){const e=new Set([...this.transitions.keys()].filter(n=>this.transitions.get(n).some(s=>!(!s.target&&!s.actions.length&&!s.reenter))));return Array.from(e)}}const jn="#";class wt{constructor(e,n){this.config=e,this.version=void 0,this.implementations=void 0,this.types=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.__TResolvedTypesMeta=void 0,this.id=e.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.types=this.config.types??{},this.transition=this.transition.bind(this),this.getInitialState=this.getInitialState.bind(this),this.restoreState=this.restoreState.bind(this),this.start=this.start.bind(this),this.root=new St(e,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(e){const{actions:n,guards:s,actors:i,delays:r}=this.implementations;return new wt(this.config,{actions:{...n,...e.actions},guards:{...s,...e.guards},actors:{...i,...e.actors},delays:{...r,...e.delays}})}resolveState(e){const n=Sn(this.root,e.value),s=J(K(this.root,n));return B({_nodes:[...s],context:e.context||{},children:{},status:mt(s,this.root)?"done":e.status||"active",output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,n,s){if(We(n)&&!ze(e).some(r=>r===n.type))return b(e,{status:"error",error:n.data});const{state:i}=st(e,n,s);return i}microstep(e,n,s){return st(e,n,s).microstates}getTransitionData(e,n){return vt(this.root,e.value,e,n)||[]}getPreInitialState(e,n,s){const{context:i}=this.config,r=B({context:typeof i!="function"&&i?i:{},_nodes:[this.root],children:{},status:"active"},this);return typeof i=="function"?M(r,n,e,[y(({spawn:a,event:c})=>i({spawn:a,input:c.input}))],s):r}getInitialState(e,n){const s=Vt(n),i=[],r=this.getPreInitialState(e,s,i),o=dt([{target:[...oe(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],r,e,s,!0,i),{state:a}=st(o,s,e,i);return a}start(e){Object.values(e.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(e){const n=e.split(q),s=n.slice(1),i=X(n[0])?n[0].slice(jn.length):n[0],r=this.idMap.get(i);if(!r)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return G(r,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedState(e,n){return Dn(e,n)}restoreState(e,n){const s={},i=e.children;Object.keys(i).forEach(c=>{const u=i[c],l=u.state,f=u.src,d=typeof f=="string"?pt(this,f):f;if(!d)return;const h=N(d,{id:c,parent:n?.self,syncSnapshot:u.syncSnapshot,state:l,src:f,systemId:u.systemId});s[c]=h});const r=B({...e,children:s,_nodes:Array.from(J(K(this.root,e.value)))},this);let o=new Set;function a(c,u){if(!o.has(c)){o.add(c);for(let l in c){const f=c[l];if(f&&typeof f=="object"){if("xstate$$type"in f&&f.xstate$$type===yt){c[l]=u[f.id];continue}a(f,u)}}}}return a(r.context,s),r}}function _t(t,e){return new wt(t,e)}const Pn=(t,e)=>new ReadableStream({start(){this.reader=t.getReader()},async pull(n){const s=Date.now(),{done:i,value:r}=await this.reader.read();if(i){n.close();return}n.enqueue(r);const a=Date.now()-s,u=r.length/(e()??Number.MAX_VALUE)*1e3-a;u>0&&await new Promise(l=>setTimeout(l,u))},cancel(){this.reader?.cancel()}}),Un=t=>{if(t.length===0)return[];const e=t.sort((s,i)=>s.start-i.start),n=[e[0]];for(let s=1;s<e.length;s++){const i=e[s],r=n[n.length-1];i.start<=r.end+1?r.end=Math.max(r.end,i.end):n.push(i)}return n},Bt=5e3,Hn=_t({initial:"checkingFile",context:({input:t})=>({settingsDbDocument:t.settingsDbDocument,document:t.document,file:t.file,downloadedRanges:t.file.downloadedRanges??[],downloaded:t.file.downloaded??0,progress:t.file.progress??0,selected:t.file.selected??!1,priority:t.file.priority??0,length:t.file.length??0,offset:t.file.offset??0,path:t.file.path??"",pathArray:t.file.pathArray,name:t.file.name??"",index:t.file.index,status:t.file.status??"checking",streamBandwithLogs:t.file.streamBandwithLogs??[],downloadSpeed:t.file.downloadSpeed??0}),on:{"FILE.PAUSE":{target:".paused"},"FILE.RESUME":{target:".downloading"}},states:{checkingFile:{entry:F({type:"FILE.CHECKING_FILE"}),always:{target:"downloading",guard:({context:t})=>t?.selected===!0}},downloading:{entry:F({type:"FILE.DOWNLOADING"}),invoke:{input:t=>t,src:j(t=>new ve(e=>{const n={input:t.input.context},s=n.input.document;if(n.input.file.selected===!1)return e.complete();const r=n.input.file.downloadedRanges.sort((f,d)=>f.start-d.start).at(0)?.end||0;if(r===n.input.file.length){e.complete();return}let o=[...n.input.streamBandwithLogs],a=[...n.input.file.downloadedRanges.map(f=>({...f}))],c=!1,u,l=new Promise((f,d)=>{u=f});return be({magnet:s.state.magnet,path:n.input.file.pathArray.join("/"),offset:r}).then(async f=>{const d=await n.input.settingsDbDocument.getLatest();let h=d.downloadSpeedLimitEnabled,p=d.downloadSpeedLimit;d.$.subscribe(U=>{h=U.downloadSpeedLimitEnabled,p=U.downloadSpeedLimit});const v=Pn(f.body,()=>h?p:Number.MAX_VALUE).getReader(),{write:he,close:Z}=await z(le(),{key:"io-worker"})("openWriteStream",{filePath:`${n.input.document.infoHash}/${n.input.file.path}`,offset:r,size:n.input.file.length});u(Z);const Tt=async()=>{if(t.self.getSnapshot().status!=="active")return;if(c)return await v.cancel(),await Z(),e.error(err);const{done:U,value:bt}=await v.read();if(U)return await Z(),e.complete();const Q=bt.byteLength;try{await he(bt.buffer)}catch(E){return e.error(E)}const tt=a?.find(E=>E.start<=r&&E.end>=r);tt?tt.end=tt.end+Q:a=[...a,{start:r,end:r+Q}],a=Un(a),o=[...o,{timestamp:Date.now(),byteLength:Q}];const pe=o.filter(E=>E.timestamp>Date.now()-Bt).sort((E,R)=>E.timestamp-R.timestamp),Rt=a.reduce((E,R)=>E+(R.end-R.start),0),ye=pe.reduce((E,R)=>E+R.byteLength,0)/Bt*1e3;e.next({type:"FILE.DOWNLOADING_UPDATE",value:{downloadedRanges:a,downloaded:Rt,progress:Rt/n.input.file.length,status:"downloading",streamBandwithLogs:[...o],downloadSpeed:ye}}),c||Tt()};Tt()}).catch(f=>{u(void 0),console.log("downloadFile err",f),e.error(f)}),()=>{c=!0,l.then(f=>f?.())}})),onSnapshot:{guard:({event:t})=>t.snapshot.context?.type==="FILE.DOWNLOADING_UPDATE",actions:y(({event:t})=>({downloadedRanges:t.snapshot.context.value.downloadedRanges,downloaded:t.snapshot.context.value.downloaded,progress:t.snapshot.context.value.progress,status:t.snapshot.context.value.status,streamBandwithLogs:t.snapshot.context.value.streamBandwithLogs,downloadSpeed:t.snapshot.context.value.downloadSpeed}))},onDone:{target:"finished"}},on:{"FILE.PAUSE":{target:"paused",actions:y({status:"paused"})}}},paused:{entry:[F({type:"FILE.PAUSED"}),y({status:"paused"})],on:{"FILE.RESUME":{target:"downloading",actions:y({status:"downloading"})}}},finished:{entry:[F({type:"FILE.FINISHED"}),y({status:"finished",downloaded:({context:t})=>t.length,progress:1,downloadedRanges:({context:t})=>[{start:0,end:t.length}]})]}}}),Wt=_t({initial:"init",context:({input:t})=>({settingsDbDocument:t.settingsDbDocument,infoHash:t.infoHash,magnet:t.magnet,torrentFile:t.torrentFile,shouldRemoveFiles:!1,lastEvent:null,document:t.document,dbDocument:t.dbDocument,files:[]}),types:{events:{}},always:[{actions:[async({context:t,event:e,self:n})=>{const s=t.files.map(d=>d.getSnapshot().context);if(!t.document||!t.dbDocument||e.type==="TORRENT.REMOVE-AND-KEEP-FILES"||e.type==="TORRENT.REMOVE-AND-DELETE-FILES")return;const i={...t.document,state:{...t.document.state,torrentFile:t.document.state.torrentFile&&Jt(t.document.state.torrentFile)}},r=n.getSnapshot().value,o=s.reduce((d,h)=>d+h.length,0),a=s.reduce((d,h)=>d+h.downloaded,0),c=r==="downloading"?s.reduce((d,h)=>d+h.downloadSpeed,0):0,u=(o-a)/c,{infoHash:l,...f}=xt({state:{name:i.state.name,status:r,progress:s.filter(d=>d.selected).reduce((d,h)=>d+h.progress,0)/s.filter(d=>d.selected).length,size:i.state.size,peers:i.state.peers,proxy:i.state.proxy,p2p:i.state.p2p,addedAt:i.state.addedAt,remainingTime:u,peersCount:i.state.peersCount,seedersCount:i.state.seedersCount,leechersCount:i.state.leechersCount,downloaded:a,uploaded:s.reduce((d,h)=>d+h.uploaded,0),downloadSpeed:c,uploadSpeed:s.reduce((d,h)=>d+h.uploadSpeed,0),ratio:i.state.ratio,files:s.map((d,h)=>({index:h,name:d.name,path:d.path,pathArray:d.pathArray,offset:d.offset,length:d.length,downloaded:d.downloaded,progress:d.progress,selected:d.selected,priority:d.priority,downloadedRanges:d.downloadedRanges.map(p=>({start:p.start,end:p.end})),downloadSpeed:d.downloadSpeed,streamBandwithLogs:d.streamBandwithLogs.map(p=>({byteLength:p.byteLength,timestamp:p.timestamp}))})),streamBandwithLogs:s.reduce((d,h)=>d.concat(h.streamBandwithLogs),[]).sort((d,h)=>d.timestamp-h.timestamp),magnet:i.state.magnet,torrentFile:Ee(i.state.torrentFile)},options:i.options&&{paused:i.options.paused}});await t.dbDocument.incrementalUpdate({$set:{...f}})},y(({event:t})=>({lastEvent:t}))],guard:({context:t,event:e})=>t.lastEvent!==e}],on:{"FILE.CHECKING":".checkingFiles","FILE.FINISHED":{guard:({context:t})=>t.files.every(e=>e.getSnapshot().value==="finished"),target:".finished"},"TORRENT.PAUSE":{actions:y({files:({context:t})=>(t.files.forEach(e=>e.send({type:"FILE.PAUSE"})),t.files)})},"TORRENT.RESUME":{actions:y({files:({context:t})=>(t.files.forEach(e=>e.send({type:"FILE.RESUME"})),t.files)})},"TORRENT.REMOVE-AND-DELETE-FILES":{actions:[y({shouldRemoveFiles:()=>!0})],target:".removing"},"TORRENT.REMOVE-AND-KEEP-FILES":{actions:[y({shouldRemoveFiles:()=>!1})],target:".removing"}},states:{init:{invoke:{input:({context:t,event:e})=>({context:t,data:e}),src:W(async({input:t})=>{const{context:e,data:{input:n}}=t;if(e.dbDocument)return e.dbDocument;const s=await Dt.torrents.findOne(n.infoHash).exec();if(s)return s;const i=n.torrentFile?.infoBuffer?n.torrentFile:await Re({magnet:n.magnet}).then(o=>o.arrayBuffer()).then(o=>Se(we.Buffer.from(o))),r=xt({infoHash:i.infoHash,state:{magnet:n.magnet?n.magnet:_e(n.torrentFile),torrentFile:i}});return Dt.torrents.insert(r)}),onDone:{target:"checkingFiles",actions:[y({document:({event:t})=>t.output.toJSON(),dbDocument:({event:t})=>t.output,files:({spawn:t,event:e,context:n})=>e.output.state.files.filter(s=>s.selected).map(s=>t(Hn,{id:`torrent-${e.output.infoHash}-${s.path}`,input:{settingsDbDocument:n.settingsDbDocument,document:e.output.toJSON(),file:s},syncSnapshot:!0}))})]}}},checkingFiles:{invoke:{src:W(async()=>{}),onDone:[{target:"downloadingMetadata",guard:({context:t})=>!t.torrentFile},{guard:Ft([({context:t})=>t.document.state.stats==="finished",({context:t})=>t.torrent&&t.files.every(e=>e.getSnapshot().value==="finished")]),target:"finished"},{target:"downloading",guard:Ft([({context:t})=>t.document.state.status==="downloading",({context:t})=>t.torrentFile])}]}},downloadingMetadata:{invoke:{input:({context:t})=>t,src:j(t=>t.input.document.$),onSnapshot:{target:"downloading",guard:({event:t})=>t.snapshot.context?.state?.torrentFile!==void 0}}},downloading:{invoke:{input:({context:t})=>t,src:j(({input:t,...e})=>rt([]))},on:{"FILES.FINISHED":"finished","TORRENT.PAUSE":{target:"paused",actions:y({files:({context:t,event:e})=>(t.files.forEach(n=>n.send({type:"FILE.PAUSE"})),t.files)})}}},paused:{on:{"TORRENT.RESUME":{target:"downloading",actions:y({files:({context:t,event:e})=>(t.files.forEach(n=>n.send({type:"FILE.RESUME"})),t.files)})}}},finished:{},removing:{invoke:{input:({context:t,self:e})=>({context:t,self:e}),src:W(async({input:t})=>{if(t.context.dbDocument){const n=async()=>{try{await (await t.context.dbDocument.getLatest()).remove()}catch{await new Promise(i=>setTimeout(i,100)),await n()}};n()}return t.context.files.forEach(n=>t.self._actorScope.stopChild(n)),await (await (await navigator.storage.getDirectory()).getDirectoryHandle("torrents")).removeEntry(t.context.infoHash,{recursive:!0}),t.context.document}),onDone:{actions:[y({document:()=>{},dbDocument:()=>{},files:[]}),F(({context:t})=>({type:"TORRENT.REMOVED",input:{infoHash:t.infoHash}}))]}}}}}),Bn=()=>Te.find().exec(),Wn=_t({id:"torrentManager",initial:"init",context:{settingsDbDocument:void 0,torrents:[],workerReady:!1},types:{events:{}},on:{"WORKER.DISCONNECTED":{actions:y({workerReady:!1})},"WORKER.READY":{actions:y({workerReady:!0})}},states:{init:{invoke:{src:W(async()=>{const[t,e]=await Promise.all([et(),Bn()]);return{settingsDbDocument:t,torrentDbDocuments:e}}),onDone:{target:"waitingForDocuments",actions:y({settingsDbDocument:({event:t})=>t.output.settingsDbDocument,torrents:({spawn:t,event:e})=>e.output.torrentDbDocuments.map(n=>t(Wt,{id:`torrent-${n.infoHash}`,input:{settingsDbDocument:e.output.settingsDbDocument,infoHash:n.infoHash,magnet:n.state.magnet,torrentFile:n.state.torrentFile,document:n.toJSON(),dbDocument:n},syncSnapshot:!0}))})}}},waitingForDocuments:{always:{target:"idle",guard:({context:t})=>t.workerReady}},idle:{invoke:{input:({context:t})=>t,src:j(({input:t})=>(t.torrents.filter(e=>e.getSnapshot().value!=="finished").forEach(e=>e.send({type:"TORRENT.RESUME"})),rt(et()).pipe(It(e=>e?.$),it(e=>e?.paused),At()))),onDone:{target:"paused"}},on:{"TORRENT.ADD":{actions:y({torrents:({spawn:t,context:e,event:n})=>[...e.torrents,t(Wt,{id:`torrent-${n.input.infoHash}`,input:{settingsDbDocument:e.settingsDbDocument,...n.input},syncSnapshot:!0})]})},"TORRENT.PAUSE":{actions:y({torrents:({context:t,event:e})=>(t.torrents.find(s=>s.id===`torrent-${e.output.infoHash}`)?.send({type:"TORRENT.PAUSE"}),t.torrents)})},"TORRENT.RESUME":{actions:y({torrents:({context:t,event:e})=>(t.torrents.find(s=>s.id===`torrent-${e.output.infoHash}`)?.send({type:"TORRENT.RESUME"}),t.torrents)})},"TORRENT.REMOVE-AND-DELETE-FILES":{actions:({context:t,event:e})=>{t.torrents.find(s=>s.id===`torrent-${e.input.infoHash}`)?.send({type:"TORRENT.REMOVE-AND-DELETE-FILES"})}},"TORRENT.REMOVE-AND-KEEP-FILES":{actions:({context:t,event:e})=>{t.torrents.find(s=>s.id===`torrent-${e.input.infoHash}`)?.send({type:"TORRENT.REMOVE-AND-KEEP-FILES"})}},"TORRENT.REMOVED":{actions:y({torrents:({context:t,event:e})=>t.torrents.filter(n=>n.id!==`torrent-${e.input.infoHash}`)})},PAUSE:{actions:y({torrents:({context:t})=>(t.torrents.filter(e=>e.getSnapshot().value!=="finished").forEach(e=>e.send({type:"TORRENT.PAUSE"})),t.torrents)}),target:"paused"}}},paused:{invoke:{id:"paused status watch",input:({context:t})=>t,src:j(({input:t})=>(t.torrents.filter(e=>e.getSnapshot().value!=="finished").forEach(e=>e.send({type:"TORRENT.PAUSE"})),rt(et()).pipe(It(e=>e?.$),it(e=>!e?.paused),At()))),onDone:{target:"idle"}},on:{RESUME:{actions:y({torrents:({context:t})=>(t.torrents.filter(e=>e.getSnapshot().value!=="finished").forEach(e=>e.send({type:"TORRENT.RESUME"})),t.torrents)}),target:"idle"}}}}}),V=N(Wn).start();let ft;le=()=>ft;zn=H(async({workerPort:t})=>{ft&&V.send({type:"WORKER.DISCONNECTED"}),ft=t,await new Promise((e,n)=>{const s=setInterval(()=>{z(t,{key:"torrent-manager"})("ping").then(i=>{clearInterval(s),e(void 0)})},100);z(t,{key:"torrent-manager"})("ping").then(i=>{clearInterval(s),e(void 0)}),setTimeout(()=>{clearInterval(s),n()},1e3)}),V.send({type:"WORKER.READY"})});Vn={newLeader:zn,addTorrent:H(async({infoHash:t,magnet:e,torrentFile:n})=>{V.send({type:"TORRENT.ADD",input:{infoHash:t,magnet:e,torrentFile:n&&Jt(n)}})}),removeTorrent:H(async({infoHash:t,removeFiles:e})=>{V.send({type:e?"TORRENT.REMOVE-AND-DELETE-FILES":"TORRENT.REMOVE-AND-KEEP-FILES",input:{infoHash:t}})}),readTorrentFile:H(({infoHash:t,filePath:e,offset:n,size:s})=>z(le(),{key:"io-worker"})("readTorrentFile",{infoHash:t,filePath:e,offset:n,size:s}))}});export{le as getIoWorkerPort,zn as newLeader,Vn as resolvers,__tla};
@@ -1466,7 +1466,7 @@ return ret;
1466
1466
  }, zr = function() {
1467
1467
  return (zr = a.asm.Ka).apply(null, arguments);
1468
1468
  };
1469
- a._ff_h264_cabac_tables = 145668;
1469
+ a._ff_h264_cabac_tables = 145636;
1470
1470
  var Oe;
1471
1471
  pe = function e() {
1472
1472
  Oe || xr(), Oe || (pe = e);
package/build/libav.wasm CHANGED
Binary file