Repository navigation
Expand file tree
/
Copy pathlua-worker.js
More file actions
7024 lines (6741 loc) · 389 KB
/
Copy pathlua-worker.js
File metadata and controls
7024 lines (6741 loc) · 389 KB
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
(()=>{var po=Object.defineProperty;var st=(t,e,o)=>()=>{if(o)throw o[0];try{return t&&(e=t(t=0)),e}catch(n){throw o=[n],n}};var ho=(t,e)=>{for(var o in e)po(t,o,{get:e[o],enumerable:!0})};var ut,he,Be=st(()=>{ut=Object.defineProperty,he=(t,e)=>{let o={};for(var n in t)ut(o,n,{get:t[n],enumerable:!0});return e||ut(o,Symbol.toStringTag,{value:"Module"}),o}});var vt={};ho(vt,{WasmLua:()=>Ue,compileWorker:()=>So,dumpWorker:()=>To,start:()=>Ao,version:()=>Eo,workerMemoryBytes:()=>Ro});function So(t,e,o,n){let a=c.compileWorker(t,e,o,n);if(a[2])throw d(a[1]);return d(a[0])}function To(t,e,o,n,a){let r=c.dumpWorker(t,e,o,n,a);if(r[2])throw d(r[1]);return d(r[0])}function Ao(){c.start()}function Eo(){let t,e;try{let o=c.version();return t=o[0],e=o[1],D(o[0],o[1])}finally{c.__wbindgen_free(t,e,1)}}function Ro(){return c.workerMemoryBytes()>>>0}function ko(t,e){return Error(D(t,e))}function Do(t,e){let o=e,n=typeof o=="bigint"?o:void 0;I().setBigInt64(t+8,R(n)?BigInt(0):n,!0),I().setInt32(t+0,!R(n),!0)}function Wo(t){let e=t,o=typeof e=="boolean"?e:void 0;return R(o)?16777215:o?1:0}function Po(t,e){let o=T($e(e),c.__wbindgen_malloc,c.__wbindgen_realloc),n=S;I().setInt32(t+4,n,!0),I().setInt32(t+0,o,!0)}function Oo(t){return typeof t=="bigint"}function Io(t){return typeof t=="function"}function Mo(t){return t===null}function Fo(t){let e=t;return typeof e=="object"&&e!==null}function Lo(t){return t===void 0}function jo(t,e){return t===e}function No(t,e){let o=e,n=typeof o=="number"?o:void 0;I().setFloat64(t+8,R(n)?0:n,!0),I().setInt32(t+0,!R(n),!0)}function Bo(t){throw t}function Vo(t,e){let o=e,n=typeof o=="string"?o:void 0;var a=R(n)?0:T(n,c.__wbindgen_malloc,c.__wbindgen_realloc),r=S;I().setInt32(t+4,r,!0),I().setInt32(t+0,a,!0)}function zo(t,e){throw new Error(D(t,e))}function Uo(t){t._wbg_cb_unref()}function $o(){return G(function(t,e,o){return t.apply(e,o)},arguments)}function qo(){return G(function(t,e){return t.call(e)},arguments)}function Go(){return G(function(t,e,o){return t.call(e,o)},arguments)}function Ho(){return G(function(t,e,o,n){return t.call(e,o,n)},arguments)}function Jo(){return G(function(t,e,o,n,a){return t.call(e,o,n,a)},arguments)}function Xo(t,e){let o,n;try{o=t,n=e,console.error(D(t,e))}finally{c.__wbindgen_free(o,n,1)}}function Yo(t){return Array.from(t)}function Qo(){return G(function(t,e){return Reflect.get(t,e)},arguments)}function Zo(t,e){return t[e>>>0]}function Ko(t,e){return t[e>>>0]}function en(t){let e;try{e=t instanceof Promise}catch{e=!1}return e}function tn(t){let e;try{e=t instanceof Uint8Array}catch{e=!1}return e}function on(t){return Array.isArray(t)}function nn(t,e){return Object.is(t,e)}function rn(t){return Object.keys(t)}function an(t){return t.length}function sn(t){return t.length}function cn(){return new Error}function ln(t,e){return new Intl.DateTimeFormat(t,e)}function un(){return new Map}function dn(t,e){return new Error(D(t,e))}function fn(){return new Object}function mn(){return new Array}function pn(t,e){return new Uint8Array(bt(t,e))}function hn(t,e){try{var o={a:t,b:e},n=(a,r)=>{let s=o.a;o.a=0;try{return $n(s,o.b,a,r)}finally{o.a=s}};return new Promise(n)}finally{o.a=0}}function bn(t){return new Uint8Array(t>>>0)}function gn(t){return new Array(t>>>0)}function _n(){return Date.now()}function vn(t,e,o){Uint8Array.prototype.set.call(bt(t,e),o)}function wn(t,e){return t.push(e)}function yn(t){return t.queueMicrotask}function Cn(t){queueMicrotask(t)}function xn(t){return Promise.resolve(t)}function Sn(t){return t.resolvedOptions()}function Tn(t,e,o){t[e>>>0]=o}function An(){return G(function(t,e,o){return Reflect.set(t,e,o)},arguments)}function En(t,e,o){return t.set(e,o)}function Rn(t,e){let o=e.stack,n=T(o,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S;I().setInt32(t+4,a,!0),I().setInt32(t+0,n,!0)}function kn(){let t=typeof global>"u"?null:global;return R(t)?0:q(t)}function Dn(){let t=typeof globalThis>"u"?null:globalThis;return R(t)?0:q(t)}function Wn(){let t=typeof self>"u"?null:self;return R(t)?0:q(t)}function Pn(){let t=typeof window>"u"?null:window;return R(t)?0:q(t)}function On(t,e,o){return t.then(e,o)}function In(t,e){return t.then(e)}function Mn(t,e){return gt(t,e,Un)}function Fn(t,e){return gt(t,e,zn)}function Ln(t){return t}function jn(t){return t}function Nn(t,e){return D(t,e)}function Bn(){let t=c.__wbindgen_externrefs,e=t.grow(4);t.set(0,void 0),t.set(e+0,void 0),t.set(e+1,null),t.set(e+2,!0),t.set(e+3,!1)}function zn(t,e){c.wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke_______true_(t,e)}function Un(t,e,o){let n=c.wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke___wasm_bindgen_88f4e4fb1e9bfc9___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_88f4e4fb1e9bfc9___JsError___true_(t,e,o);if(n[1])throw d(n[0])}function $n(t,e,o,n){c.wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke___js_sys_9c4f85dd2a4a6892___Function_fn_wasm_bindgen_88f4e4fb1e9bfc9___JsValue_____wasm_bindgen_88f4e4fb1e9bfc9___sys__Undefined___js_sys_9c4f85dd2a4a6892___Function_fn_wasm_bindgen_88f4e4fb1e9bfc9___JsValue_____wasm_bindgen_88f4e4fb1e9bfc9___sys__Undefined_______true_(t,e,o,n)}function q(t){let e=c.__externref_table_alloc();return c.__wbindgen_externrefs.set(e,t),e}function $e(t){let e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){let a=t.description;return a==null?"Symbol":`Symbol(${a})`}if(e=="function"){let a=t.name;return typeof a=="string"&&a.length>0?`Function(${a})`:"Function"}if(Array.isArray(t)){let a=t.length,r="[";a>0&&(r+=$e(t[0]));for(let s=1;s<a;s++)r+=", "+$e(t[s]);return r+="]",r}let o=/\[object ([^\]]+)\]/.exec(toString.call(t)),n;if(o&&o.length>1)n=o[1];else return toString.call(t);if(n=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}
${t.stack}`:n}function bt(t,e){return t=t>>>0,se().subarray(t/1,t/1+e)}function I(){return(Z===null||Z.buffer.detached===!0||Z.buffer.detached===void 0&&Z.buffer!==c.memory.buffer)&&(Z=new DataView(c.memory.buffer)),Z}function D(t,e){return Gn(t>>>0,e)}function se(){return(ge===null||ge.byteLength===0)&&(ge=new Uint8Array(c.memory.buffer)),ge}function G(t,e){try{return t.apply(this,e)}catch(o){let n=q(o);c.__wbindgen_exn_store(n)}}function R(t){return t==null}function gt(t,e,o){let n={a:t,b:e,cnt:1},a=(...r)=>{n.cnt++;let s=n.a;n.a=0;try{return o(s,n.b,...r)}finally{n.a=s,a._wbg_cb_unref()}};return a._wbg_cb_unref=()=>{--n.cnt===0&&(c.__wbindgen_destroy_closure(n.a,n.b),n.a=0,ht.unregister(n))},ht.register(a,n,n),a}function T(t,e,o){if(o===void 0){let i=ce.encode(t),l=e(i.length,1)>>>0;return se().subarray(l,l+i.length).set(i),S=i.length,l}let n=t.length,a=e(n,1)>>>0,r=se(),s=0;for(;s<n;s++){let i=t.charCodeAt(s);if(i>127)break;r[a+s]=i}if(s!==n){s!==0&&(t=t.slice(s)),a=o(a,n,n=s+t.length*3,1)>>>0;let i=se().subarray(a+s,a+n),l=ce.encodeInto(t,i);s+=l.written,a=o(a,n,s,1)>>>0}return S=s,a}function d(t){let e=c.__wbindgen_externrefs.get(t);return c.__externref_table_dealloc(t),e}function Gn(t,e){return ze+=e,ze>=qn&&(_e=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),_e.decode(),ze=e),_e.decode(se().subarray(t,t+e))}function Hn(t){c=t}function Xn(t){let e=globalThis.__cobraLuauWasm;if(!e)throw new Error("o WebAssembly do Luau ainda n\xE3o foi carregado");return new WebAssembly.Instance(e,t)}var Ue,Vn,pt,ht,Z,ge,_e,qn,ze,ce,S,c,Jn,h,Yn,Qn,Zn,Kn,er,tr,or,nr,rr,ar,ir,sr,cr,lr,ur,dr,fr,mr,pr,hr,br,gr,_r,vr,wr,yr,Cr,xr,Sr,Tr,Ar,Er,Rr,kr,Dr,Wr,Pr,Or,Ir,Mr,Fr,Lr,jr,Nr,Br,Vr,zr,Ur,$r,qr,Gr,Hr,Jr,Xr,Yr,Qr,Zr,Kr,ea,ta,oa,na,ra,aa,ia,sa,ca,la,ua,da,fa,ma,pa,ha,ba,ga,_a,va,wa,ya,Ca,xa,Sa,Ta,Aa,Ea,Ra,ka,Da,Wa,Pa,Oa,Ia,Ma,Fa,La,ja,Na,Ba,Va,za,Ua,$a,qa,Ga,Ha,Ja,Xa,Ya,Qa,Za,Ka,ei,ti,oi,ni,ri,ai,ii,si,ci,li,ui,di,fi,mi,pi,hi,bi,gi,_i,vi,wi,yi,Ci,xi,Si,Ti,_t,wt=st(()=>{Be();Ue=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,pt.unregister(this),t}free(){let t=this.__destroy_into_raw();c.__wbg_wasmlua_free(t,0)}bufferBytes(t){let e=c.wasmlua_bufferBytes(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}bufferWrite(t,e,o){let n=c.wasmlua_bufferWrite(this.__wbg_ptr,t,e,o);if(n[1])throw d(n[0])}callAsync(t,e,o){return c.wasmlua_callAsync(this.__wbg_ptr,t,e,o)}callFunctionAsync(t,e,o,n){let a=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),r=S;return c.wasmlua_callFunctionAsync(this.__wbg_ptr,t,a,r,o,n)}callFunction(t,e,o){let n=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S,r=c.wasmlua_callFunction(this.__wbg_ptr,t,n,a,o);if(r[2])throw d(r[1]);return d(r[0])}callMethodAsync(t,e,o,n){let a=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),r=S;return c.wasmlua_callMethodAsync(this.__wbg_ptr,t,a,r,o,n)}callMethod(t,e,o){let n=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S,r=c.wasmlua_callMethod(this.__wbg_ptr,t,n,a,o);if(r[2])throw d(r[1]);return d(r[0])}call(t,e){let o=c.wasmlua_call(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}coerceInteger(t){let e=c.wasmlua_coerceInteger(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}coerceNumber(t){let e=c.wasmlua_coerceNumber(this.__wbg_ptr,t);if(e[3])throw d(e[2]);return e[0]===0?void 0:e[1]}coerceString(t){let e=c.wasmlua_coerceString(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}compile(t,e){let o=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S,a=c.wasmlua_compile(this.__wbg_ptr,o,n,e);if(a[2])throw d(a[1]);return d(a[0])}configureModules(t,e,o,n){let a=c.wasmlua_configureModules(this.__wbg_ptr,t,R(e)?0:q(e),o,n);if(a[1])throw d(a[0])}configureOutput(t){let e=c.wasmlua_configureOutput(this.__wbg_ptr,t);if(e[1])throw d(e[0])}configureWorker(t,e,o,n,a,r){let s=c.wasmlua_configureWorker(this.__wbg_ptr,t,R(e)?0:q(e),o,n,a,r);if(s[1])throw d(s[0])}createAsyncFunction(t){let e=c.wasmlua_createAsyncFunction(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}createBufferWithCapacity(t){let e=c.wasmlua_createBufferWithCapacity(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}createBuffer(t){let e=c.wasmlua_createBuffer(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}createTableWithCapacity(t,e){let o=c.wasmlua_createTableWithCapacity(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}createTable(t){let e=c.wasmlua_createTable(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}createThread(t){let e=c.wasmlua_createThread(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}createUserdata(t,e,o){let n=c.wasmlua_createUserdata(this.__wbg_ptr,t,e,o);if(n[2])throw d(n[1]);return d(n[0])}currentThread(){let t=c.wasmlua_currentThread(this.__wbg_ptr);if(t[2])throw d(t[1]);return d(t[0])}dispose(){let t=c.wasmlua_dispose(this.__wbg_ptr);if(t[1])throw d(t[0])}dump(t,e,o){let n=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S,r=c.wasmlua_dump(this.__wbg_ptr,n,a,e,o);if(r[2])throw d(r[1]);return d(r[0])}executeAsync(t,e,o,n){let a=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),r=S;return c.wasmlua_executeAsync(this.__wbg_ptr,a,r,e,o,n)}executeBytecodeAsync(t,e,o,n){return c.wasmlua_executeBytecodeAsync(this.__wbg_ptr,t,e,o,n)}executeBytecodeWorker(t,e,o,n,a){return c.wasmlua_executeBytecodeWorker(this.__wbg_ptr,t,e,o,n,a)}executeBytecode(t,e,o){let n=c.wasmlua_executeBytecode(this.__wbg_ptr,t,e,o);if(n[2])throw d(n[1]);return d(n[0])}executeWorker(t,e,o,n,a){return c.wasmlua_executeWorker(this.__wbg_ptr,t,e,o,n,a)}execute(t,e,o){let n=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S,r=c.wasmlua_execute(this.__wbg_ptr,n,a,e,o);if(r[2])throw d(r[1]);return d(r[0])}functionBind(t,e){let o=c.wasmlua_functionBind(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}functionCoverage(t){let e=c.wasmlua_functionCoverage(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}functionDeepClone(t){let e=c.wasmlua_functionDeepClone(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}functionEnvironment(t){let e=c.wasmlua_functionEnvironment(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}functionIdentity(t){let e=c.wasmlua_functionIdentity(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return e[0]>>>0}functionInfo(t){let e=c.wasmlua_functionInfo(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}functionSetEnvironment(t,e){let o=c.wasmlua_functionSetEnvironment(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return o[0]!==0}gcCollect(){let t=c.wasmlua_gcCollect(this.__wbg_ptr);if(t[1])throw d(t[0])}gcIsRunning(){let t=c.wasmlua_gcIsRunning(this.__wbg_ptr);if(t[2])throw d(t[1]);return t[0]!==0}gcRestart(){let t=c.wasmlua_gcRestart(this.__wbg_ptr);if(t[1])throw d(t[0])}gcStep(){let t=c.wasmlua_gcStep(this.__wbg_ptr);if(t[2])throw d(t[1]);return t[0]!==0}gcStop(){let t=c.wasmlua_gcStop(this.__wbg_ptr);if(t[1])throw d(t[0])}get(t,e){let o=c.wasmlua_get(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}globals(){let t=c.wasmlua_globals(this.__wbg_ptr);if(t[2])throw d(t[1]);return d(t[0])}inspectStack(t){let e=c.wasmlua_inspectStack(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}invokeFunction(t,e,o){return c.wasmlua_invokeFunction(this.__wbg_ptr,t,e,o)}isYieldable(){let t=c.wasmlua_isYieldable(this.__wbg_ptr);if(t[2])throw d(t[1]);return t[0]!==0}loadBytecode(t,e){let o=c.wasmlua_loadBytecode(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}loadLibraries(t){let e=c.wasmlua_loadLibraries(this.__wbg_ptr,t);if(e[1])throw d(e[0])}load(t,e){let o=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S,a=c.wasmlua_load(this.__wbg_ptr,o,n,e);if(a[2])throw d(a[1]);return d(a[0])}mainThread(){let t=c.wasmlua_mainThread(this.__wbg_ptr);if(t[2])throw d(t[1]);return d(t[0])}namecallMethod(){let t=c.wasmlua_namecallMethod(this.__wbg_ptr);if(t[3])throw d(t[2]);let e;return t[0]!==0&&(e=D(t[0],t[1]),c.__wbindgen_free(t[0],t[1]*1,1)),e}namedRegistryValue(t){let e=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),o=S,n=c.wasmlua_namedRegistryValue(this.__wbg_ptr,e,o);if(n[2])throw d(n[1]);return d(n[0])}constructor(t){let e=c.wasmlua_new(t);if(e[2])throw d(e[1]);return this.__wbg_ptr=e[0],pt.register(this,this.__wbg_ptr,this),this}objectClass(t){let e=c.wasmlua_objectClass(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}peakMemory(){let t=c.wasmlua_peakMemory(this.__wbg_ptr);if(t[2])throw d(t[1]);return t[0]>>>0}rawGet(t,e){let o=c.wasmlua_rawGet(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}rawSet(t,e,o){let n=c.wasmlua_rawSet(this.__wbg_ptr,t,e,o);if(n[1])throw d(n[0])}release(t){let e=c.wasmlua_release(this.__wbg_ptr,t);if(e[1])throw d(e[0])}removeDebugHooks(){let t=c.wasmlua_removeDebugHooks(this.__wbg_ptr);if(t[1])throw d(t[0])}removeInterruptHooks(){let t=c.wasmlua_removeInterruptHooks(this.__wbg_ptr);if(t[1])throw d(t[0])}requestInterrupt(){let t=c.wasmlua_requestInterrupt(this.__wbg_ptr);if(t[1])throw d(t[0])}sandbox(t){let e=c.wasmlua_sandbox(this.__wbg_ptr,t);if(e[1])throw d(e[0])}setCompiler(t){let e=c.wasmlua_setCompiler(this.__wbg_ptr,t);if(e[1])throw d(e[0])}setDebugHooks(t){let e=c.wasmlua_setDebugHooks(this.__wbg_ptr,t);if(e[1])throw d(e[0])}setInterruptHooks(t){let e=c.wasmlua_setInterruptHooks(this.__wbg_ptr,t);if(e[1])throw d(e[0])}setMemoryLimit(t){let e=c.wasmlua_setMemoryLimit(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return e[0]>>>0}setNamedRegistryValue(t,e){let o=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S,a=c.wasmlua_setNamedRegistryValue(this.__wbg_ptr,o,n,e);if(a[1])throw d(a[0])}setTypeMetatable(t,e){let o=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S,a=c.wasmlua_setTypeMetatable(this.__wbg_ptr,o,n,e);if(a[1])throw d(a[0])}set(t,e,o){let n=c.wasmlua_set(this.__wbg_ptr,t,e,o);if(n[1])throw d(n[0])}get stateId(){return c.wasmlua_stateId(this.__wbg_ptr)>>>0}tableClear(t){let e=c.wasmlua_tableClear(this.__wbg_ptr,t);if(e[1])throw d(e[0])}tableContainsKey(t,e){let o=c.wasmlua_tableContainsKey(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return o[0]!==0}tableEntries(t){let e=c.wasmlua_tableEntries(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}tableIsReadonly(t){let e=c.wasmlua_tableIsReadonly(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return e[0]!==0}tableLength(t,e){let o=c.wasmlua_tableLength(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return o[0]}tableMetatable(t){let e=c.wasmlua_tableMetatable(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}tablePop(t){let e=c.wasmlua_tablePop(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}tablePush(t,e){let o=c.wasmlua_tablePush(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}tableRawInsert(t,e,o){let n=c.wasmlua_tableRawInsert(this.__wbg_ptr,t,e,o);if(n[1])throw d(n[0])}tableRawPop(t){let e=c.wasmlua_tableRawPop(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}tableRawPush(t,e){let o=c.wasmlua_tableRawPush(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}tableRawRemove(t,e){let o=c.wasmlua_tableRawRemove(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}tableRawSetIndex(t,e,o){let n=c.wasmlua_tableRawSetIndex(this.__wbg_ptr,t,e,o);if(n[1])throw d(n[0])}tableRemove(t,e){let o=c.wasmlua_tableRemove(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}tableSetMetatable(t,e){let o=c.wasmlua_tableSetMetatable(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}tableSetReadonly(t,e){let o=c.wasmlua_tableSetReadonly(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}tableSetSafeEnvironment(t,e){let o=c.wasmlua_tableSetSafeEnvironment(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}threadInspectStack(t,e){let o=c.wasmlua_threadInspectStack(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}threadIsYieldable(t){let e=c.wasmlua_threadIsYieldable(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return e[0]!==0}threadNamecallMethod(t){let e=c.wasmlua_threadNamecallMethod(this.__wbg_ptr,t);if(e[3])throw d(e[2]);let o;return e[0]!==0&&(o=D(e[0],e[1]),c.__wbindgen_free(e[0],e[1]*1,1)),o}threadReset(t,e){let o=c.wasmlua_threadReset(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}threadResumeAsync(t,e,o){return c.wasmlua_threadResumeAsync(this.__wbg_ptr,t,e,o)}threadResumeErrorAsync(t,e,o){return c.wasmlua_threadResumeErrorAsync(this.__wbg_ptr,t,e,o)}threadResumeError(t,e){let o=c.wasmlua_threadResumeError(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}threadResume(t,e){let o=c.wasmlua_threadResume(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return d(o[0])}threadSetSingleStep(t,e){let o=c.wasmlua_threadSetSingleStep(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}threadStatus(t){let e,o;try{let r=c.wasmlua_threadStatus(this.__wbg_ptr,t);var n=r[0],a=r[1];if(r[3])throw n=0,a=0,d(r[2]);return e=n,o=a,D(n,a)}finally{c.__wbindgen_free(e,o,1)}}threadTraceback(t,e,o){var n=R(e)?0:T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S;let r=c.wasmlua_threadTraceback(this.__wbg_ptr,t,n,a,o);if(r[2])throw d(r[1]);return d(r[0])}traceback(t,e){var o=R(t)?0:T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S;let a=c.wasmlua_traceback(this.__wbg_ptr,o,n,e);if(a[2])throw d(a[1]);return d(a[0])}typeMetatable(t){let e=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),o=S,n=c.wasmlua_typeMetatable(this.__wbg_ptr,e,o);if(n[2])throw d(n[1]);return d(n[0])}unsetNamedRegistryValue(t){let e=T(t,c.__wbindgen_malloc,c.__wbindgen_realloc),o=S,n=c.wasmlua_unsetNamedRegistryValue(this.__wbg_ptr,e,o);if(n[1])throw d(n[0])}usedMemory(){let t=c.wasmlua_usedMemory(this.__wbg_ptr);if(t[2])throw d(t[1]);return t[0]>>>0}userdataDestroy(t){let e=c.wasmlua_userdataDestroy(this.__wbg_ptr,t);if(e[1])throw d(e[0])}userdataMetatableEntries(t){let e=c.wasmlua_userdataMetatableEntries(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}userdataMetatableGet(t,e){let o=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S,a=c.wasmlua_userdataMetatableGet(this.__wbg_ptr,t,o,n);if(a[2])throw d(a[1]);return d(a[0])}userdataMetatableHas(t,e){let o=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),n=S,a=c.wasmlua_userdataMetatableHas(this.__wbg_ptr,t,o,n);if(a[2])throw d(a[1]);return a[0]!==0}userdataMetatableSet(t,e,o){let n=T(e,c.__wbindgen_malloc,c.__wbindgen_realloc),a=S,r=c.wasmlua_userdataMetatableSet(this.__wbg_ptr,t,n,a,o);if(r[1])throw d(r[0])}userdataMetatable(t){let e=c.wasmlua_userdataMetatable(this.__wbg_ptr,t);if(e[1])throw d(e[0])}userdataSetUserValue(t,e){let o=c.wasmlua_userdataSetUserValue(this.__wbg_ptr,t,e);if(o[1])throw d(o[0])}userdataTake(t){let e=c.wasmlua_userdataTake(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}userdataTypeName(t){let e,o;try{let r=c.wasmlua_userdataTypeName(this.__wbg_ptr,t);var n=r[0],a=r[1];if(r[3])throw n=0,a=0,d(r[2]);return e=n,o=a,D(n,a)}finally{c.__wbindgen_free(e,o,1)}}userdataUserValue(t){let e=c.wasmlua_userdataUserValue(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}userdataValue(t){let e=c.wasmlua_userdataValue(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return d(e[0])}valueEquals(t,e){let o=c.wasmlua_valueEquals(this.__wbg_ptr,t,e);if(o[2])throw d(o[1]);return o[0]!==0}valueIdentity(t){let e=c.wasmlua_valueIdentity(this.__wbg_ptr,t);if(e[2])throw d(e[1]);return e[0]>>>0}valueToString(t){let e,o;try{let r=c.wasmlua_valueToString(this.__wbg_ptr,t);var n=r[0],a=r[1];if(r[3])throw n=0,a=0,d(r[2]);return e=n,o=a,D(n,a)}finally{c.__wbindgen_free(e,o,1)}}};Symbol.dispose&&(Ue.prototype[Symbol.dispose]=Ue.prototype.free);Vn=new WebAssembly.Memory({initial:32});pt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>c.__wbg_wasmlua_free(t,1));ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>c.__wbindgen_destroy_closure(t.a,t.b));Z=null;ge=null;_e=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});_e.decode();qn=2146435072,ze=0;ce=new TextEncoder;"encodeInto"in ce||(ce.encodeInto=function(t,e){let o=ce.encode(t);return e.set(o),{read:t.length,written:o.length}});S=0;Jn=he({__abort_handler:()=>fi,__externref_table_alloc:()=>yi,__externref_table_dealloc:()=>Ti,__instance_terminated:()=>mi,__wbg_wasmlua_free:()=>Yn,__wbindgen_destroy_closure:()=>Si,__wbindgen_exn_store:()=>wi,__wbindgen_externrefs:()=>Ci,__wbindgen_free:()=>xi,__wbindgen_malloc:()=>_i,__wbindgen_realloc:()=>vi,__wbindgen_start:()=>_t,compileWorker:()=>Qn,dumpWorker:()=>Zn,memory:()=>gi,start:()=>Kn,version:()=>er,wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke_______true_:()=>bi,wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke___js_sys_9c4f85dd2a4a6892___Function_fn_wasm_bindgen_88f4e4fb1e9bfc9___JsValue_____wasm_bindgen_88f4e4fb1e9bfc9___sys__Undefined___js_sys_9c4f85dd2a4a6892___Function_fn_wasm_bindgen_88f4e4fb1e9bfc9___JsValue_____wasm_bindgen_88f4e4fb1e9bfc9___sys__Undefined_______true_:()=>pi,wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke___wasm_bindgen_88f4e4fb1e9bfc9___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_88f4e4fb1e9bfc9___JsError___true_:()=>hi,wasmlua_bufferBytes:()=>tr,wasmlua_bufferWrite:()=>or,wasmlua_call:()=>nr,wasmlua_callAsync:()=>rr,wasmlua_callFunction:()=>ar,wasmlua_callFunctionAsync:()=>ir,wasmlua_callMethod:()=>sr,wasmlua_callMethodAsync:()=>cr,wasmlua_coerceInteger:()=>lr,wasmlua_coerceNumber:()=>ur,wasmlua_coerceString:()=>dr,wasmlua_compile:()=>fr,wasmlua_configureModules:()=>mr,wasmlua_configureOutput:()=>pr,wasmlua_configureWorker:()=>hr,wasmlua_createAsyncFunction:()=>br,wasmlua_createBuffer:()=>gr,wasmlua_createBufferWithCapacity:()=>_r,wasmlua_createTable:()=>vr,wasmlua_createTableWithCapacity:()=>wr,wasmlua_createThread:()=>yr,wasmlua_createUserdata:()=>Cr,wasmlua_currentThread:()=>xr,wasmlua_dispose:()=>Sr,wasmlua_dump:()=>Tr,wasmlua_execute:()=>Ar,wasmlua_executeAsync:()=>Er,wasmlua_executeBytecode:()=>Rr,wasmlua_executeBytecodeAsync:()=>kr,wasmlua_executeBytecodeWorker:()=>Dr,wasmlua_executeWorker:()=>Wr,wasmlua_functionBind:()=>Pr,wasmlua_functionCoverage:()=>Or,wasmlua_functionDeepClone:()=>Ir,wasmlua_functionEnvironment:()=>Mr,wasmlua_functionIdentity:()=>Fr,wasmlua_functionInfo:()=>Lr,wasmlua_functionSetEnvironment:()=>jr,wasmlua_gcCollect:()=>Nr,wasmlua_gcIsRunning:()=>Br,wasmlua_gcRestart:()=>Vr,wasmlua_gcStep:()=>zr,wasmlua_gcStop:()=>Ur,wasmlua_get:()=>$r,wasmlua_globals:()=>qr,wasmlua_inspectStack:()=>Gr,wasmlua_invokeFunction:()=>Hr,wasmlua_isYieldable:()=>Jr,wasmlua_load:()=>Xr,wasmlua_loadBytecode:()=>Yr,wasmlua_loadLibraries:()=>Qr,wasmlua_mainThread:()=>Zr,wasmlua_namecallMethod:()=>Kr,wasmlua_namedRegistryValue:()=>ea,wasmlua_new:()=>ta,wasmlua_objectClass:()=>oa,wasmlua_peakMemory:()=>na,wasmlua_rawGet:()=>ra,wasmlua_rawSet:()=>aa,wasmlua_release:()=>ia,wasmlua_removeDebugHooks:()=>sa,wasmlua_removeInterruptHooks:()=>ca,wasmlua_requestInterrupt:()=>la,wasmlua_sandbox:()=>ua,wasmlua_set:()=>da,wasmlua_setCompiler:()=>fa,wasmlua_setDebugHooks:()=>ma,wasmlua_setInterruptHooks:()=>pa,wasmlua_setMemoryLimit:()=>ha,wasmlua_setNamedRegistryValue:()=>ba,wasmlua_setTypeMetatable:()=>ga,wasmlua_stateId:()=>_a,wasmlua_tableClear:()=>va,wasmlua_tableContainsKey:()=>wa,wasmlua_tableEntries:()=>ya,wasmlua_tableIsReadonly:()=>Ca,wasmlua_tableLength:()=>xa,wasmlua_tableMetatable:()=>Sa,wasmlua_tablePop:()=>Ta,wasmlua_tablePush:()=>Aa,wasmlua_tableRawInsert:()=>Ea,wasmlua_tableRawPop:()=>Ra,wasmlua_tableRawPush:()=>ka,wasmlua_tableRawRemove:()=>Da,wasmlua_tableRawSetIndex:()=>Wa,wasmlua_tableRemove:()=>Pa,wasmlua_tableSetMetatable:()=>Oa,wasmlua_tableSetReadonly:()=>Ia,wasmlua_tableSetSafeEnvironment:()=>Ma,wasmlua_threadInspectStack:()=>Fa,wasmlua_threadIsYieldable:()=>La,wasmlua_threadNamecallMethod:()=>ja,wasmlua_threadReset:()=>Na,wasmlua_threadResume:()=>Ba,wasmlua_threadResumeAsync:()=>Va,wasmlua_threadResumeError:()=>za,wasmlua_threadResumeErrorAsync:()=>Ua,wasmlua_threadSetSingleStep:()=>$a,wasmlua_threadStatus:()=>qa,wasmlua_threadTraceback:()=>Ga,wasmlua_traceback:()=>Ha,wasmlua_typeMetatable:()=>Ja,wasmlua_unsetNamedRegistryValue:()=>Xa,wasmlua_usedMemory:()=>Ya,wasmlua_userdataDestroy:()=>Qa,wasmlua_userdataMetatable:()=>Za,wasmlua_userdataMetatableEntries:()=>Ka,wasmlua_userdataMetatableGet:()=>ei,wasmlua_userdataMetatableHas:()=>ti,wasmlua_userdataMetatableSet:()=>oi,wasmlua_userdataSetUserValue:()=>ni,wasmlua_userdataTake:()=>ri,wasmlua_userdataTypeName:()=>ai,wasmlua_userdataUserValue:()=>ii,wasmlua_userdataValue:()=>si,wasmlua_valueEquals:()=>ci,wasmlua_valueIdentity:()=>li,wasmlua_valueToString:()=>ui,workerMemoryBytes:()=>di});h=Xn({"./luau_wasm_bg.js":{__wbg_push_bfdf956ba476f65b:wn,__wbg_call_6bcf8d3e20937e46:Go,__wbg_call_269c5566fbede3eb:qo,__wbg_length_4e1adc0d42e23620:sn,__wbg_get_unchecked_363572bdd397d473:Ko,__wbg_keys_6efc298980178da1:rn,__wbg_then_7a850dae4493f353:On,__wbg_new_typed_6f8b0d724fe26c07:hn,__wbg_call_7bbd9cceba9949ad:Ho,__wbg_instanceof_Promise_f6320f682f582ddf:en,__wbg_get_b1f0ab13c737f856:Zo,__wbg_set_13d25b81ab403f5e:Tn,__wbg_apply_5d9aa7604c2490a8:$o,__wbg_call_c1ad1cb1b78e8130:Jo,__wbg_set_bf6dde4923b9b059:En,__wbg_new_227d7c05414eb861:cn,__wbg_stack_3b0d974bbf31e44f:Rn,__wbg_error_757e9472f8410341:Xo,__wbg_then_b830475380919203:In,__wbg_resolve_35ec7e0c6af4c82c:xn,__wbg_new_bebc3f4757acf305:fn,__wbg_new_ffa92086ea89f79c:mn,__wbg_new_with_length_6a9fc3631737ef8c:gn,__wbg_isArray_5674713bb7b79043:on,__wbg_from_a39669ce566077da:Yo,__wbg_new_a32a1ab6c6655abe:dn,__wbg_new_8d36e20aa758e411:un,__wbg_now_d1fb6650485d7f3e:_n,__wbg_is_61443cc073056436:nn,__wbg_length_31bdaf014f5fbde2:an,__wbg_prototypesetcall_ae9f5e7459250748:vn,__wbg_new_with_length_5ffeddb9d9fbb96f:bn,__wbg_new_from_slice_4ee02165f9de919e:pn,__wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db:Dn,__wbg_static_accessor_SELF_d8b50611246a6d92:Wn,__wbg_static_accessor_GLOBAL_8eb4cd83130a11a0:kn,__wbg_static_accessor_WINDOW_fd0bc376bf0f8b42:Pn,__wbg_instanceof_Uint8Array_598adc0fef426aa8:tn,__wbg_new_8bacbcd413da85bb:ln,__wbg_resolvedOptions_a8a5a3f370c62607:Sn,__wbg_get_989d0a1309644f2b:Qo,__wbg_set_a377297433dfea63:An,__wbg_queueMicrotask_85c90f6987555d65:yn,__wbg_queueMicrotask_f6a1fa10b81d1fc0:Cn,__wbg___wbindgen_number_get_1dc732b810cb937c:No,__wbg___wbindgen_throw_5d9e815e6fdf150f:zo,__wbg___wbindgen_is_null_5160b3e381865372:Mo,__wbg___wbindgen_rethrow_dba7bb2caa14ba21:Bo,__wbg___wbindgen_jsval_eq_9fdcd3c0a860dd3b:jo,__wbg_Error_67e7344beaa85059:ko,__wbg___wbindgen_is_bigint_60fc0336cb14f5d7:Oo,__wbg___wbindgen_is_object_edb6b15aa3afe12e:Fo,__wbg___wbindgen_string_get_92ab86bb19cbc12f:Vo,__wbg___wbindgen_boolean_get_7a12af2b3f899c5a:Wo,__wbg___wbindgen_is_function_fcda5e3902d732fe:Io,__wbg___wbindgen_is_undefined_8c687d0b90d5b524:Lo,__wbg___wbindgen_bigint_get_as_i64_b482365c149396c8:Do,__wbg__wbg_cb_unref_997e73d32238e655:Uo,__wbg___wbindgen_debug_string_0e68cf47c9cbd9b0:Po,__wbindgen_init_externref_table:Bn,__wbindgen_generic_0000000000000001:Mn,__wbindgen_generic_0000000000000002:Fn,__wbindgen_generic_0000000000000003:Ln,__wbindgen_generic_0000000000000004:jn,__wbindgen_generic_0000000000000005:Nn,memory:Vn}}),Yn=h.exports.__wbg_wasmlua_free,Qn=h.exports.compileWorker,Zn=h.exports.dumpWorker,Kn=h.exports.start,er=h.exports.version,tr=h.exports.wasmlua_bufferBytes,or=h.exports.wasmlua_bufferWrite,nr=h.exports.wasmlua_call,rr=h.exports.wasmlua_callAsync,ar=h.exports.wasmlua_callFunction,ir=h.exports.wasmlua_callFunctionAsync,sr=h.exports.wasmlua_callMethod,cr=h.exports.wasmlua_callMethodAsync,lr=h.exports.wasmlua_coerceInteger,ur=h.exports.wasmlua_coerceNumber,dr=h.exports.wasmlua_coerceString,fr=h.exports.wasmlua_compile,mr=h.exports.wasmlua_configureModules,pr=h.exports.wasmlua_configureOutput,hr=h.exports.wasmlua_configureWorker,br=h.exports.wasmlua_createAsyncFunction,gr=h.exports.wasmlua_createBuffer,_r=h.exports.wasmlua_createBufferWithCapacity,vr=h.exports.wasmlua_createTable,wr=h.exports.wasmlua_createTableWithCapacity,yr=h.exports.wasmlua_createThread,Cr=h.exports.wasmlua_createUserdata,xr=h.exports.wasmlua_currentThread,Sr=h.exports.wasmlua_dispose,Tr=h.exports.wasmlua_dump,Ar=h.exports.wasmlua_execute,Er=h.exports.wasmlua_executeAsync,Rr=h.exports.wasmlua_executeBytecode,kr=h.exports.wasmlua_executeBytecodeAsync,Dr=h.exports.wasmlua_executeBytecodeWorker,Wr=h.exports.wasmlua_executeWorker,Pr=h.exports.wasmlua_functionBind,Or=h.exports.wasmlua_functionCoverage,Ir=h.exports.wasmlua_functionDeepClone,Mr=h.exports.wasmlua_functionEnvironment,Fr=h.exports.wasmlua_functionIdentity,Lr=h.exports.wasmlua_functionInfo,jr=h.exports.wasmlua_functionSetEnvironment,Nr=h.exports.wasmlua_gcCollect,Br=h.exports.wasmlua_gcIsRunning,Vr=h.exports.wasmlua_gcRestart,zr=h.exports.wasmlua_gcStep,Ur=h.exports.wasmlua_gcStop,$r=h.exports.wasmlua_get,qr=h.exports.wasmlua_globals,Gr=h.exports.wasmlua_inspectStack,Hr=h.exports.wasmlua_invokeFunction,Jr=h.exports.wasmlua_isYieldable,Xr=h.exports.wasmlua_load,Yr=h.exports.wasmlua_loadBytecode,Qr=h.exports.wasmlua_loadLibraries,Zr=h.exports.wasmlua_mainThread,Kr=h.exports.wasmlua_namecallMethod,ea=h.exports.wasmlua_namedRegistryValue,ta=h.exports.wasmlua_new,oa=h.exports.wasmlua_objectClass,na=h.exports.wasmlua_peakMemory,ra=h.exports.wasmlua_rawGet,aa=h.exports.wasmlua_rawSet,ia=h.exports.wasmlua_release,sa=h.exports.wasmlua_removeDebugHooks,ca=h.exports.wasmlua_removeInterruptHooks,la=h.exports.wasmlua_requestInterrupt,ua=h.exports.wasmlua_sandbox,da=h.exports.wasmlua_set,fa=h.exports.wasmlua_setCompiler,ma=h.exports.wasmlua_setDebugHooks,pa=h.exports.wasmlua_setInterruptHooks,ha=h.exports.wasmlua_setMemoryLimit,ba=h.exports.wasmlua_setNamedRegistryValue,ga=h.exports.wasmlua_setTypeMetatable,_a=h.exports.wasmlua_stateId,va=h.exports.wasmlua_tableClear,wa=h.exports.wasmlua_tableContainsKey,ya=h.exports.wasmlua_tableEntries,Ca=h.exports.wasmlua_tableIsReadonly,xa=h.exports.wasmlua_tableLength,Sa=h.exports.wasmlua_tableMetatable,Ta=h.exports.wasmlua_tablePop,Aa=h.exports.wasmlua_tablePush,Ea=h.exports.wasmlua_tableRawInsert,Ra=h.exports.wasmlua_tableRawPop,ka=h.exports.wasmlua_tableRawPush,Da=h.exports.wasmlua_tableRawRemove,Wa=h.exports.wasmlua_tableRawSetIndex,Pa=h.exports.wasmlua_tableRemove,Oa=h.exports.wasmlua_tableSetMetatable,Ia=h.exports.wasmlua_tableSetReadonly,Ma=h.exports.wasmlua_tableSetSafeEnvironment,Fa=h.exports.wasmlua_threadInspectStack,La=h.exports.wasmlua_threadIsYieldable,ja=h.exports.wasmlua_threadNamecallMethod,Na=h.exports.wasmlua_threadReset,Ba=h.exports.wasmlua_threadResume,Va=h.exports.wasmlua_threadResumeAsync,za=h.exports.wasmlua_threadResumeError,Ua=h.exports.wasmlua_threadResumeErrorAsync,$a=h.exports.wasmlua_threadSetSingleStep,qa=h.exports.wasmlua_threadStatus,Ga=h.exports.wasmlua_threadTraceback,Ha=h.exports.wasmlua_traceback,Ja=h.exports.wasmlua_typeMetatable,Xa=h.exports.wasmlua_unsetNamedRegistryValue,Ya=h.exports.wasmlua_usedMemory,Qa=h.exports.wasmlua_userdataDestroy,Za=h.exports.wasmlua_userdataMetatable,Ka=h.exports.wasmlua_userdataMetatableEntries,ei=h.exports.wasmlua_userdataMetatableGet,ti=h.exports.wasmlua_userdataMetatableHas,oi=h.exports.wasmlua_userdataMetatableSet,ni=h.exports.wasmlua_userdataSetUserValue,ri=h.exports.wasmlua_userdataTake,ai=h.exports.wasmlua_userdataTypeName,ii=h.exports.wasmlua_userdataUserValue,si=h.exports.wasmlua_userdataValue,ci=h.exports.wasmlua_valueEquals,li=h.exports.wasmlua_valueIdentity,ui=h.exports.wasmlua_valueToString,di=h.exports.workerMemoryBytes,fi=h.exports.__abort_handler,mi=h.exports.__instance_terminated,pi=h.exports.wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke___js_sys_9c4f85dd2a4a6892___Function_fn_wasm_bindgen_88f4e4fb1e9bfc9___JsValue_____wasm_bindgen_88f4e4fb1e9bfc9___sys__Undefined___js_sys_9c4f85dd2a4a6892___Function_fn_wasm_bindgen_88f4e4fb1e9bfc9___JsValue_____wasm_bindgen_88f4e4fb1e9bfc9___sys__Undefined_______true_,hi=h.exports.wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke___wasm_bindgen_88f4e4fb1e9bfc9___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_88f4e4fb1e9bfc9___JsError___true_,bi=h.exports.wasm_bindgen_88f4e4fb1e9bfc9___convert__closures_____invoke_______true_,gi=h.exports.memory,_i=h.exports.__wbindgen_malloc,vi=h.exports.__wbindgen_realloc,wi=h.exports.__wbindgen_exn_store,yi=h.exports.__externref_table_alloc,Ci=h.exports.__wbindgen_externrefs,xi=h.exports.__wbindgen_free,Si=h.exports.__wbindgen_destroy_closure,Ti=h.exports.__externref_table_dealloc,_t=h.exports.__wbindgen_start;Hn(Jn);_t()});var bo=Symbol("FromLua");var go=Symbol("FromLua.rest"),je=Symbol("IntoLua"),Ne=Symbol("IntoLua.multiple");function L(t){if(!(typeof t!="object"||t===null))return t[bo]}function re(t){if(!(typeof t!="object"||t===null))return t[go]}function ct(t){if(!(typeof t!="object"||t===null))return t[je]}function lt(t){if(!(typeof t!="object"||t===null))return t[Ne]}Be();function Q(t,e){if(!Array.isArray(t))throw new TypeError(`${e} must be an array`);if(t.length>0&&Array.isArray(t[0]))return t.map((o,n)=>{if(!Array.isArray(o))throw new TypeError(`${e} cannot mix arguments and overloads`);return dt(o,`${e}[${n}]`)});if(t.some(Array.isArray))throw new TypeError(`${e} cannot mix arguments and overloads`);return dt(t,e)}function ft(t){return _o(t)?t:[t]}function mt(t,e){let o=re(t.at(-1))!==void 0,n=o?t.length-1:t.length,a=n;for(;a>0&&ae(t[a-1]);)a--;return e>=a&&(o||e<=n)}function be(t){return L(t)!==void 0||vo(t)}function ae(t){return L(t)?.kind==="option"}function dt(t,e){let o=!1,n=!1;return t.map((a,r)=>{let s=re(a);if(s){if(r!==t.length-1)throw new TypeError(`${e}[${r}] rest argument must be last`);if(o)throw new TypeError(`${e}[${r}] cannot follow an optional argument`);if(!be(s.value))throw new TypeError(`${e}[${r}] has an invalid rest decoder`);return n=!0,a}if(n||!be(a))throw new TypeError(`${e}[${r}] must be a FromLua decoder`);if(ae(a))o=!0;else if(o)throw new TypeError(`${e}[${r}] cannot follow an optional argument`);return a})}function _o(t){return t.length>0&&Array.isArray(t[0])}function vo(t){if(t===BigInt)return!0;if(typeof t!="function")return!1;try{return Reflect.construct(Object,[],t),!0}catch{return!1}}var ie=he({buffer:()=>wo,callback:()=>Co,multiple:()=>xo,userdata:()=>yo});function wo(t){if(!(t instanceof Uint8Array))throw new TypeError("buffer value must be a Uint8Array");return Ve({kind:"buffer",bytes:t.slice()})}function yo(t){if((typeof t!="object"||t===null)&&typeof t!="function")throw new TypeError("userdata value must be an object or function");return Ve({kind:"userdata",value:t})}function Co(t,e){if(typeof t!="function")throw new TypeError("callback value must be a function");return Ve({kind:"callback",callback:t,args:e===void 0?void 0:Q(e,"callback arguments")})}function xo(...t){return Object.freeze({[Ne]:Object.freeze(t.slice())})}function Ve(t){return Object.freeze({[je]:Object.freeze(t)})}Object.freeze({optimizationLevel:1,debugLevel:1,memoryLimitBytes:33554432,interruptLimit:25e4,outputLimitBytes:65536,outputLimitEvents:1024,resultLimitBytes:1048576,resultLimitEntries:16384});var yt=2048,Ct=262144,xt=1048576;function Ai(t){for(let e=0;e<t.length;e+=1){let o=t.charCodeAt(e);if(o>=55296&&o<=56319){let n=t.charCodeAt(e+1);if(!(n>=56320&&n<=57343))return!1;e+=1}else if(o>=56320&&o<=57343)return!1}return!0}function ye(t){if(!Ai(t))throw new TypeError("JavaScript string contains an unpaired surrogate")}function St(t){ye(t);let e=0;for(let o=0;o<t.length;o+=1){let n=t.charCodeAt(o);n<128?e+=1:n<2048?e+=2:n>=55296&&n<=56319?(e+=4,o+=1):e+=3}return e}var Ei=class extends Event{text;constructor(t,e){super(t),this.text=e}},Ce=class{x;y;z;constructor(t,e,o){this.x=t,this.y=e,this.z=o}toString(){return`vector(${this.x}, ${this.y}, ${this.z})`}},Ri=new Set(["__add","__sub","__mul","__div","__idiv","__mod","__pow","__eq","__lt","__le","__concat"]),Tt=new WeakMap,ki=new Set(["__add","__sub","__mul","__div","__idiv","__mod","__pow","__unm","__eq","__lt","__le","__len","__concat","__index","__newindex","__namecall","__call","__tostring","__todebugstring","__iter"]);function Di(t){let e=[],o=t;for(;typeof o=="function"&&o!==Function.prototype;){let f=Tt.get(o);f&&e.unshift(f),o=Object.getPrototypeOf(o)}let n=new Map,a=new Map,r=new Map,s=new Map,i=new Map,l=new Map;for(let f of e){for(let m of f.fields)n.set(...m);for(let m of f.methods)a.set(...m);for(let m of f.metamethods)r.set(...m);for(let m of f.proxyFields)s.set(...m);for(let m of f.proxyMethods)i.set(...m);for(let m of f.proxyMetamethods)l.set(...m)}let u=Tt.get(t)?.constructorArguments;if(u!==void 0&&l.has("__call"))throw new TypeError("userdata constructor conflicts with proxy metamethod __call");if(!(u===void 0&&n.size===0&&a.size===0&&r.size===0&&s.size===0&&i.size===0&&l.size===0))return{...u===void 0?{}:{constructor:u},fields:n.size>0?Object.fromEntries(n):void 0,methods:a.size>0?Object.fromEntries(a):void 0,metamethods:r.size>0?Object.fromEntries(r):void 0,proxy:s.size>0||i.size>0||l.size>0?{fields:s.size>0?Object.fromEntries(s):void 0,methods:i.size>0?Object.fromEntries(i):void 0,metamethods:l.size>0?Object.fromEntries(l):void 0}:void 0}}function Wi(t){return Ri.has(t)}function xe(t,e="userdata definition"){if(typeof t!="object"||t===null)throw new TypeError(`${e} must be an object`);let o=t;if(o.fields!==void 0){if(typeof o.fields!="object"||o.fields===null)throw new TypeError(`${e}.fields must be an object`);for(let[n,a]of Object.entries(o.fields)){if(typeof a!="object"||a===null)throw new TypeError(`${e}.fields.${n} must be an object`);if(a.get!==void 0&&typeof a.get!="function")throw new TypeError(`${e}.fields.${n}.get must be a function`);if(a.set!==void 0&&typeof a.set!="function")throw new TypeError(`${e}.fields.${n}.set must be a function`);a.type!==void 0&&Oi(a.type,`${e}.fields.${n}.type`)}}if(o.methods!==void 0){if(typeof o.methods!="object"||o.methods===null)throw new TypeError(`${e}.methods must be an object`);for(let[n,a]of Object.entries(o.methods))Se(a,`${e}.methods.${n}`)}if(o.metamethods!==void 0){if(typeof o.metamethods!="object"||o.metamethods===null)throw new TypeError(`${e}.metamethods must be an object`);for(let[n,a]of Object.entries(o.metamethods)){if(!ki.has(n))throw new TypeError(`unknown Lua userdata metamethod ${n}`);if(n==="__call")Se(a,`${e}.metamethods.${n}`);else if(typeof a!="function")throw new TypeError(`${e}.metamethods.${n} must be a function`)}}}function Pi(t,e="userdata definition"){xe(t,e);let o=t,n=Object.hasOwn(o,"constructor");if(n&&Q(o.constructor,`${e}.constructor`),o.proxy!==void 0&&xe(o.proxy,`${e}.proxy`),n&&o.proxy?.metamethods?.__call!==void 0)throw new TypeError(`${e}.constructor conflicts with ${e}.proxy.metamethods.__call`)}function Se(t,e="userdata method"){if(typeof t=="function")return{callback:t};if(typeof t!="object"||t===null)throw new TypeError(`${e} must be a function or method options`);if(typeof t.callback!="function")throw new TypeError(`${e}.callback must be a function`);return{callback:t.callback,args:Q(t.args,`${e}.args`)}}function Oi(t,e){if(be(t))return t;throw new TypeError(`${e} must be a FromLua decoder`)}var Ye="__luauRsState",fe="__luauRsRef",Qe="__luauRsType",kt="__luauRsVector",Ii="__luauRsBuffer",qe="__luauRsUserdata",K="__luauRsTable",Mi="__luauRsCallbackResult",_=Symbol("LuaValue.state"),W=Symbol("LuaValue"),Dt=Symbol("LuaValue.identity"),N=Symbol("Lua.userdataValue"),Fi=Symbol("Lua.createUserdataIdentity"),Li=Symbol("Lua.release"),ji=Symbol("LuaFunction.invoke"),Ni=Symbol("LuaFunction.identity"),Je=new TextDecoder,At=new TextEncoder,Te=Array.isArray,Bi;function Vi(){return Bi??=Promise.resolve().then(()=>(wt(),vt)).then(t=>{let e=t.initializeWorkerBindings;return e===void 0?t:e()})}var Wt=new FinalizationRegistry(({state:t,handle:e})=>{try{t.deref()?.release(e)}catch{}});function j(t){let e=t.deref();if(!e)throw new Error("Lua state is unavailable");return e}function le(t){if(typeof t!="string")throw new TypeError("Luau source must be a string");return ye(t),t}var zi=class{#e=new WeakMap;bridge(t){let e=new WeakRef(t),o=(...n)=>{let a=e.deref();if(!a)throw new Error("Lua host callback is unavailable");return a(...n)};return this.#e.set(o,t),o}},B=class{lua;type;handle;[_];constructor(t,e,o,n,a,r){if(this.lua=t,this.type=o,this.handle=n,r!==W)throw new TypeError("Lua values are created by a Lua state");this[_]=e,a&&Wt.register(this,{state:new WeakRef(this[_]),handle:n},t)}equals(t){if(t.lua!==this.lua)throw new Error("Lua value belongs to another state");return this[_].valueEquals(this.handle,t.handle)}[Dt](){return this[_].valueIdentity(this.handle)}toString(){return this[_].valueToString(this.handle)}reference(t){if(this.lua!==t)throw new Error("Lua value belongs to another state");return{[Ye]:this[_].stateId,[fe]:this.handle,[Qe]:this.type}}},Ae=class extends B{get(t){return this.lua.decode(this[_].get(this.handle,this.lua.encode(t)))}set(t,e){this[_].set(this.handle,this.lua.encode(t),this.lua.encode(e))}call(...t){return this.lua.decodeArray(this[_].call(this.handle,this.lua.encodeArray(t)))}async callAsync(t=[],e={}){let[o,n]=F(e);try{return this.lua.decodeArray(await this[_].callAsync(this.handle,this.lua.encodeArray(t),o))}finally{n()}}callMethod(t,...e){return this.lua.decodeArray(this[_].callMethod(this.handle,t,this.lua.encodeArray(e)))}async callMethodAsync(t,e=[],o={}){let[n,a]=F(o);try{return this.lua.decodeArray(await this[_].callMethodAsync(this.handle,t,this.lua.encodeArray(e),n))}finally{a()}}callFunction(t,...e){return this.lua.decodeArray(this[_].callFunction(this.handle,t,this.lua.encodeArray(e)))}async callFunctionAsync(t,e=[],o={}){let[n,a]=F(o);try{return this.lua.decodeArray(await this[_].callFunctionAsync(this.handle,t,this.lua.encodeArray(e),n))}finally{a()}}},Pt=class extends Ae{},Ui=class extends Ae{get class(){let t=this.lua.decode(this[_].objectClass(this.handle));if(!(t instanceof Pt))throw new Error("Lua returned an invalid object class");return t}},P=class Ot extends Ae{rawGet(e){return this.lua.decode(this[_].rawGet(this.handle,this.lua.encode(e)))}rawSet(e,o){this[_].rawSet(this.handle,this.lua.encode(e),this.lua.encode(o))}entries(){return this[_].tableEntries(this.handle).map(e=>{if(!Te(e)||e.length!==2)throw new Error("Lua returned an invalid table entry");return[this.lua.decode(e[0]),this.lua.decode(e[1])]})}toArray(){let e=this.entries(),o=new Array(e.length);for(let[n,a]of e){let r=Mt(n);if(r===void 0||r>e.length||r-1 in o)throw new TypeError("table must be a contiguous sequence");o[r-1]=a}return o}toObject(){let e=Object.create(null);for(let[o,n]of this.entries()){if(typeof o!="string")throw new TypeError("table must have only string keys");e[o]=n}return e}toMap(){return new Map(this.entries())}length(e={}){return this[_].tableLength(this.handle,e.raw??!1)}clear(){this[_].tableClear(this.handle)}containsKey(e){return this[_].tableContainsKey(this.handle,this.lua.encode(e))}push(e){this[_].tablePush(this.handle,this.lua.encode(e))}pop(){return this.lua.decode(this[_].tablePop(this.handle))}remove(e){this[_].tableRemove(this.handle,this.lua.encode(e))}rawSetIndex(e,o){this[_].tableRawSetIndex(this.handle,k(e,"index"),this.lua.encode(o))}rawPush(e){this[_].tableRawPush(this.handle,this.lua.encode(e))}rawPop(){return this.lua.decode(this[_].tableRawPop(this.handle))}rawInsert(e,o){this[_].tableRawInsert(this.handle,k(e,"index"),this.lua.encode(o))}rawRemove(e){this[_].tableRawRemove(this.handle,this.lua.encode(e))}setSafeEnvironment(e){this[_].tableSetSafeEnvironment(this.handle,e)}get readonly(){return this[_].tableIsReadonly(this.handle)}set readonly(e){this[_].tableSetReadonly(this.handle,e)}get metatable(){let e=this.lua.decode(this[_].tableMetatable(this.handle));if(e===null)return null;if(!(e instanceof Ot))throw new Error("Lua returned a non-table metatable");return e}set metatable(e){this[_].tableSetMetatable(this.handle,this.lua.encode(e))}},de=class Xe extends B{get environment(){let e=this.lua.decode(this[_].functionEnvironment(this.handle));if(e===null)return null;if(!(e instanceof P))throw new Error("Lua returned a non-table function environment");return e}setEnvironment(e){if(!(e instanceof P))throw new TypeError("function environment must be a Lua table");return this[_].functionSetEnvironment(this.handle,e.reference(this.lua)[fe])}deepClone(){let e=this.lua.decode(this[_].functionDeepClone(this.handle));if(!(e instanceof Xe))throw new Error("Lua returned a non-function clone");return e}bind(...e){let o=this.lua.decode(this[_].functionBind(this.handle,this.lua.encodeArray(e)));if(!(o instanceof Xe))throw new Error("Lua returned a non-function binding");return o}info(){return this[_].functionInfo(this.handle)}coverage(){return this[_].functionCoverage(this.handle)}call(...e){return this.lua.decodeArray(this[_].call(this.handle,this.lua.encodeArray(e)))}async callAsync(e=[],o={}){let[n,a]=F(o);try{return this.lua.decodeArray(await this[_].callAsync(this.handle,this.lua.encodeArray(e),n))}finally{a()}}[ji](e,o={}){let[n,a]=F(o),r;try{r=this[_].invokeFunction(this.handle,this.lua.encodeArray(e),n)}catch(s){throw a(),s}return r instanceof Promise?r.then(s=>this.lua.decodeArray(s)).finally(a):(a(),this.lua.decodeArray(r))}[Ni](){return this[_].functionIdentity(this.handle)}createThread(){let e=this.lua.decode(this[_].createThread(this.handle));if(!(e instanceof ve))throw new Error("Lua returned a non-thread value");return e}},ve=class extends B{get status(){return this[_].threadStatus(this.handle)}get yieldable(){return this[_].threadIsYieldable(this.handle)}get namecallMethod(){return this[_].threadNamecallMethod(this.handle)??null}setSingleStep(t){if(typeof t!="boolean")throw new TypeError("single-step state must be a boolean");this[_].threadSetSingleStep(this.handle,t)}inspectStack(t=0){let e=this[_].threadInspectStack(this.handle,k(t,"stack level"));return e===null?null:Object.freeze(e)}traceback(t,e=0){return Je.decode(this[_].threadTraceback(this.handle,t,k(e,"traceback level")))}resume(...t){return this.lua.decodeArray(this[_].threadResume(this.handle,this.lua.encodeArray(t)))}reset(t){if(!(t instanceof de))throw new TypeError("thread reset requires a Lua function");this[_].threadReset(this.handle,t.reference(this.lua)[fe])}resumeError(t){return this.lua.decodeArray(this[_].threadResumeError(this.handle,this.lua.encode(t)))}async resumeAsync(t=[],e={}){let[o,n]=F(e);try{let a=await this[_].threadResumeAsync(this.handle,this.lua.encodeArray(t),o);return this.decodeResult(a)}finally{n()}}async resumeErrorAsync(t,e={}){let[o,n]=F(e);try{return this.decodeResult(await this[_].threadResumeErrorAsync(this.handle,this.lua.encode(t),o))}finally{n()}}[Symbol.asyncIterator](){let t=!1,e=Promise.resolve(),o=this,n=a=>{let r=e.then(a);return e=r.then(()=>{},()=>{}),r};return{next(a=[]){return n(async()=>{if(t)return{done:!0,value:[]};try{let r=await o.resumeAsync(a);return t=r.done,r}catch(r){throw t=o.status!=="resumable",r}})},throw(a){return n(async()=>{if(t)throw a;try{let r=await o.resumeErrorAsync(a);return t=r.done,r}catch(r){throw t=o.status!=="resumable",r}})},return(a=[]){return n(async()=>(t=!0,{done:!0,value:await a}))},[Symbol.asyncIterator](){return this},async[Symbol.asyncDispose](){t=!0,await e}}}decodeResult(t){if(typeof t!="object"||t===null)throw new Error("Lua returned an invalid coroutine result");let e=t;if(typeof e.done!="boolean"||!Te(e.value))throw new Error("Lua returned an invalid coroutine result");let o=this.lua.decodeArray(e.value);return e.done?{done:!0,value:o}:{done:!1,value:o}}},Et=class extends B{get bytes(){return this[_].bufferBytes(this.handle)}write(t,e){this[_].bufferWrite(this.handle,k(t,"offset"),e)}},ee=class extends Ae{get value(){return this.lua[N](this[_].userdataValue(this.handle))}destroy(){this[_].userdataDestroy(this.handle)}take(){return this.lua[N](this[_].userdataTake(this.handle))}get userValue(){return this.lua.decode(this[_].userdataUserValue(this.handle))}set userValue(t){this[_].userdataSetUserValue(this.handle,this.lua.encode(t))}get typeName(){return this[_].userdataTypeName(this.handle)}get metatable(){return this[_].userdataMetatable(this.handle),$i.create(this,this.lua,this[_],this.handle,W)}isProxy(t){return Object.is(this.value,t)}},$i=class It{owner;lua;handle;constructor(e,o,n,a,r){if(this.owner=e,this.lua=o,this.handle=a,r!==W)throw new TypeError("userdata metatables are created by Lua userdata");this.state=n}state;static create(e,o,n,a,r){return new It(e,o,n,a,r)}get(e){return this.lua.decode(this.state.userdataMetatableGet(this.handle,e))}set(e,o){this.state.userdataMetatableSet(this.handle,e,this.lua.encode(o))}has(e){return this.state.userdataMetatableHas(this.handle,e)}entries(){return this.state.userdataMetatableEntries(this.handle).map(e=>{if(!Te(e)||e.length!==2||typeof e[0]!="string")throw new Error("Lua returned an invalid userdata metatable entry");return[e[0],this.lua.decode(e[1])]})}};function ue(t,e,o="argument"){if(e===void 0)return[...t];let n=ft(e).filter(r=>mt(r,t.length));if(n.length===0)throw new TypeError(`${o} count does not match the declared arguments`);let a;for(let r of n)try{return qi(t,r,s=>s,o)}catch(s){a??=s}throw n.length===1&&a instanceof Error?a:new TypeError(`${o}s do not match any declared overload`)}function qi(t,e,o,n){let a={tables:new Map,leaf:o},r=e?re(e.at(-1)):void 0,s=e?e.length-(r?1:0):t.length,i=r?Math.max(s,t.length):s;return Array.from({length:i},(l,u)=>H(t[u]??null,u<s?e?.[u]:r?.value,a,0,`${n} ${u+1}`))}function H(t,e,o,n,a){if(n>64)throw new TypeError("Lua table nesting is too deep");let r=L(e);if(r?.kind==="option")return t===null?void 0:H(t,r.value,o,n,a);if(r?.kind==="bytes"){if(t instanceof Uint8Array)return t;if(typeof t=="string")return At.encode(t);throw new TypeError(`${a} must be a string`)}if(r?.kind==="array"||r?.kind==="tuple"||r?.kind==="map"||r?.kind==="record"||r?.kind==="object"){if(!(t instanceof P))throw new TypeError(`${a} must be a table`);return Ge(t,e,o,n,a)}if(e===void 0)return t instanceof P?Ge(t,void 0,o,n,a):o.leaf(t);if(e===Number){if(typeof t=="number")return t;if(typeof t=="bigint"&&t>=BigInt(Number.MIN_SAFE_INTEGER)&&t<=BigInt(Number.MAX_SAFE_INTEGER))return Number(t);throw new TypeError(`${a} must be a number`)}if(e===BigInt){if(typeof t=="bigint")return t;if(typeof t=="number"&&Number.isSafeInteger(t))return BigInt(t);throw new TypeError(`${a} must be an integer`)}if(e===String){if(typeof t=="string")return t;throw new TypeError(`${a} must be a valid UTF-8 string`)}if(e===Boolean){if(typeof t=="boolean")return t;throw new TypeError(`${a} must be a boolean`)}if(e===Uint8Array){if(t instanceof Uint8Array)return t;if(typeof t=="string")return At.encode(t);throw new TypeError(`${a} must be a string`)}if(e===Array||e===Object||e===Map){if(!(t instanceof P))throw new TypeError(`${a} must be a table`);return Ge(t,e,o,n,a)}if(e===Ce){if(t instanceof Ce)return t;throw new TypeError(`${a} must be a vector`)}let s=e;if(s===B||s.prototype instanceof B){if(t instanceof s)return t;throw new TypeError(`${a} must be ${s.name}`)}if(t instanceof ee){let i=t.value;if(i instanceof s)return i}throw new TypeError(`${a} must be ${s.name||"registered userdata"}`)}function Ge(t,e,o,n,a){let r=t[Dt](),s=o.tables.get(r);if(s){if(e!==void 0&&(s.decoder===void 0||!te(e,s.decoder)))throw new TypeError(`${a} was already converted with a different table decoder`);return s.value}let i=t.entries(),l=i.map(([g])=>Mt(g)),u=i.length>0&&l.every(g=>g!==void 0)&&new Set(l).size===i.length&&l.reduce((g,v)=>Math.max(g,v),0)===i.length,f=L(e),m=(e===Array||f?.kind==="array"||f?.kind==="tuple"?"array":e===Object||f?.kind==="record"||f?.kind==="object"?"object":e===Map||f?.kind==="map"?"map":void 0)??(u?"array":i.every(([g])=>typeof g=="string")?"object":"map");if(m==="array"){if(!u&&i.length!==0)throw new TypeError(`${a} must be a contiguous sequence table`);if(f?.kind==="tuple"&&!Gi(f.values,i.length))throw new TypeError(`${a} length does not match the declared tuple`);let g=new Array(f?.kind==="tuple"?f.values.length:i.length);o.tables.set(r,{decoder:e,value:g});for(let v=0;v<i.length;v+=1)g[l[v]-1]=H(i[v][1],f?.kind==="array"?f.value:f?.kind==="tuple"?f.values[v]:void 0,o,n+1,`${a}[${v}]`);if(f?.kind==="tuple")for(let v=i.length;v<f.values.length;v+=1)g[v]=H(null,f.values[v],o,n+1,`${a}[${v}]`);return g}if(m==="object"){if(!i.every(([C])=>typeof C=="string"))throw new TypeError(`${a} must be a table with string keys`);let g=Object.create(null);o.tables.set(r,{decoder:e,value:g});let v=f?.kind==="object"?f.fields:void 0,w=new Set;for(let[C,b]of i){let y=C;w.add(y),g[y]=H(b,f?.kind==="record"?f.value:v?.[y],o,n+1,`${a}.${y}`)}if(v){for(let[C,b]of Object.entries(v))if(!w.has(C)&&!ae(b))throw new TypeError(`${a}.${C} is required`)}return g}let p=new Map;o.tables.set(r,{decoder:e,value:p});for(let[g,v]of i)p.set(H(g,f?.kind==="map"?f.key:void 0,o,n+1,`${a} key`),H(v,f?.kind==="map"?f.value:void 0,o,n+1,`${a} value`));return p}function Gi(t,e){let o=t.length;for(;o>0&&ae(t[o-1]);)o--;return e>=o&&e<=t.length}function te(t,e){if(t===e)return!0;let o=L(t),n=L(e);if(!o||!n||o.kind!==n.kind)return!1;switch(o.kind){case"bytes":return!0;case"array":case"record":case"option":return te(o.value,n.value);case"tuple":{let a=n.values;return o.values.length===a.length&&o.values.every((r,s)=>te(r,a[s]))}case"map":{let a=n;return te(o.key,a.key)&&te(o.value,a.value)}case"object":{let a=n.fields,r=Object.keys(o.fields);return r.length===Object.keys(a).length&&r.every(s=>Object.hasOwn(a,s)&&te(o.fields[s],a[s]))}}}function Rt(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"then"in t&&typeof t.then=="function"}function Mt(t){return typeof t=="bigint"?t<1n||t>BigInt(Number.MAX_SAFE_INTEGER)?void 0:Number(t):typeof t=="number"&&Number.isSafeInteger(t)&&t>=1?t:void 0}var Ee=class we extends EventTarget{version;appData=new Map;#e;#t;#r=new Map;#n=new Map;#a=new WeakMap;#i=new WeakMap;#o;constructor(e,o,n,a){super(),this.version=o,this.#e=e,this.#o=n,this.#t=a}[Li](){Wt.unregister(this),this.#e.dispose(),this.#e.free()}static async create(e={}){return we.createState(e,!0)}static async createWorkerState(e={}){return we.createState(e,!1)}static async createState(e,o){if(typeof e!="object"||e===null)throw new TypeError("Lua options must be an object");let{resolveModule:n,...a}=e;if(n!==void 0&&typeof n!="function")throw new TypeError("resolveModule must be a function");let r=await Vi(),s=new zi,i=a.memory?.onAllocation,l=i?{...a,memory:{...a.memory,onAllocation:s.bridge(i)}}:a,u=new we(new r.WasmLua(l),r.version(),o,s),f=new WeakRef(u);return u.#e.configureOutput(s.bridge((m,p)=>{f.deref()?.dispatchEvent(new Ei(m,p))})),n&&u.#e.configureModules([],u.moduleResolver(n),a.sandbox===!0,{maxModules:32,maxModuleNameBytes:yt,maxModuleSourceBytes:Ct,maxTotalModuleSourceBytes:xt}),u}addEventListener(e,o,n){super.addEventListener(e,o,n)}removeEventListener(e,o,n){super.removeEventListener(e,o,n)}get globals(){let e=this.decode(this.#e.globals());if(!(e instanceof P))throw new Error("Lua returned invalid globals");return e}get mainThread(){let e=this.decode(this.#e.mainThread());if(!(e instanceof ve))throw new Error("Lua returned an invalid main thread");return e}get currentThread(){let e=this.decode(this.#e.currentThread());if(!(e instanceof ve))throw new Error("Lua returned an invalid current thread");return e}get yieldable(){return this.#e.isYieldable()}get namecallMethod(){return this.#e.namecallMethod()??null}coerceString(e){let o=this.decode(this.#e.coerceString(this.encode(e)));if(o!==null&&typeof o!="string"&&!(o instanceof Uint8Array))throw new Error("Lua returned a non-string coercion result");return o}coerceInteger(e){let o=this.#e.coerceInteger(this.encode(e));if(o!==null&&typeof o!="bigint")throw new Error("Lua returned a non-integer coercion result");return o}coerceNumber(e){let o=this.#e.coerceNumber(this.encode(e));if(o===void 0)return null;if(typeof o!="number")throw new Error("Lua returned a non-number coercion result");return o}typeMetatable(e){let o=this.decode(this.#e.typeMetatable(e));if(o===null)return null;if(!(o instanceof P))throw new Error("Lua returned a non-table type metatable");return o}setTypeMetatable(e,o){if(o!==null&&!(o instanceof P))throw new TypeError("type metatable must be a Lua table or null");this.#e.setTypeMetatable(e,this.encode(o))}inspectStack(e=0){let o=this.#e.inspectStack(k(e,"stack level"));return o===null?null:Object.freeze(o)}get usedMemory(){return this.#e.usedMemory()}get peakMemory(){return this.#e.peakMemory()}configureWorker(e,o,n,a,r){this.#e.configureWorker([...e],o?this.moduleResolver(o):void 0,this.#t.bridge(n),a,r,{maxModules:32,maxModuleNameBytes:yt,maxModuleSourceBytes:Ct,maxTotalModuleSourceBytes:xt})}moduleResolver(e){let o=this.#t.bridge(e),n=new WeakRef(this),a=r=>{let s=j(n);if(r==null)return r;if(typeof r!="object"||Array.isArray(r))throw new TypeError("module resolver must return a module object");if(typeof r.name!="string")throw new TypeError("resolved module name must be a string");if(!r.name||r.name.includes("\0")||St(r.name)>2048)throw new TypeError("resolved module name is invalid");let i=Object.hasOwn(r,"source");if(i===Object.hasOwn(r,"value"))throw new TypeError("module resolver must return exactly one of source or value");if(i){if(typeof r.source!="string")throw new TypeError("resolved module source must be a string");let u=r.source;if(St(u)>262144)throw new RangeError("resolved module source exceeds the per-file limit");return{name:r.name,source:u}}let l=r.value;if(l===void 0)throw new TypeError("resolved module value is required");return{name:r.name,value:s.encode(l)}};return(r,s)=>{let i=j(n),l=o(r,{from:s,lua:i});return Rt(l)?Promise.resolve(l).then(a):a(l)}}executeWorker(e,o,n,a,r){return this.#e.executeWorker(e,o,n,a,r)}executeBytecodeWorker(e,o,n,a,r){return this.#e.executeBytecodeWorker(e,o,n,a,r)}get gcRunning(){return this.#e.gcIsRunning()}createTable(e){let o=this.decode(this.#e.createTable(this.encode(e??null)));if(!(o instanceof P))throw new Error("Lua returned a non-table value");return o}createTableWithCapacity(e,o){let n=this.decode(this.#e.createTableWithCapacity(k(e,"array capacity"),k(o,"record capacity")));if(!(n instanceof P))throw new Error("Lua returned a non-table value");return n}createBuffer(e){let o=this.decode(typeof e=="number"?this.#e.createBufferWithCapacity(k(e,"buffer size")):this.#e.createBuffer(e));if(!(o instanceof Et))throw new Error("Lua returned a non-buffer value");return o}loadLibraries(e){this.#e.loadLibraries(e)}createFunction(e,o){if(typeof e!="function")throw new TypeError("callback must be a function");let n;if(o!==void 0){if(typeof o!="object"||o===null)throw new TypeError("function options must be an object");n=Q(o.args,"function options.args")}let a=new WeakRef(this),r=this.#t.bridge(e),s=(...l)=>{let u=j(a);return u.encodeCallbackReturn(r(...ue(l.map(f=>u.decode(f)),n,"function argument")))},i=this.decode(this.#e.createAsyncFunction(s));if(!(i instanceof de))throw new Error("Lua returned a non-function value");return i}createUserdata(e){let o=this.userdataBridge(e)??this.bridgeUserdataDefinition({}),n=this.decode(this.#e.createUserdata(this.storeUserdata(e),o,0));if(!(n instanceof ee))throw new Error("Lua returned a non-userdata value");return n}createProxy(e,o){o!==void 0&&xe(o,"userdata proxy definition");let n=o||this.userdataProxyDefinition(e,this.userdataDefinition(e)),a=this.bridgeUserdataDefinition(n),r=this.decode(this.#e.createUserdata(this.storeUserdata(e),a,0));if(!(r instanceof ee))throw new Error("Lua returned a non-userdata proxy");return r}registerUserdata(e,o){Pi(o);let n=Object.hasOwn(o,"constructor")?{...o,constructor:Q(o.constructor,"userdata definition.constructor")}:o;this.#r.set(e,n),this.#n.clear()}[Fi](e,o,n){let a=n?this.bridgeUserdataDefinition(n):this.userdataBridge(e)??this.bridgeUserdataDefinition({}),r=this.decode(this.#e.createUserdata(this.storeUserdata(e),a,k(o,"userdata identity")));if(!(r instanceof ee))throw new Error("Lua returned a non-userdata value");return r}load(e,o={}){let n={...o,environment:o.environment?this.encode(o.environment):void 0},a=this.decode(this.#e.load(le(e),n));if(!(a instanceof de))throw new Error("Lua returned a non-function value");return a}loadBytecode(e,o={}){let n={...o,environment:o.environment?this.encode(o.environment):void 0},a=this.decode(this.#e.loadBytecode(e,n));if(!(a instanceof de))throw new Error("Lua returned a non-function value");return a}execute(e,o={},...n){let a={...o,environment:o.environment?this.encode(o.environment):void 0};return this.decodeArray(this.#e.execute(le(e),a,this.encodeArray(n)))}async executeAsync(e,o={},...n){let[a,r]=F(o),{signal:s,...i}=o,l={...i,environment:o.environment?this.encode(o.environment):void 0};try{return this.decodeArray(await this.#e.executeAsync(le(e),l,this.encodeArray(n),a))}finally{r()}}executeBytecode(e,o={},...n){let a={...o,environment:o.environment?this.encode(o.environment):void 0};return this.decodeArray(this.#e.executeBytecode(e,a,this.encodeArray(n)))}async executeBytecodeAsync(e,o={},...n){let[a,r]=F(o),{signal:s,...i}=o,l={...i,environment:o.environment?this.encode(o.environment):void 0};try{return this.decodeArray(await this.#e.executeBytecodeAsync(e,l,this.encodeArray(n),a))}finally{r()}}compile(e,o={}){return this.#e.compile(le(e),this.encodeCompilerOptions(o))}dump(e,o={}){return Je.decode(this.#e.dump(le(e),this.encodeCompilerOptions(o),o))}setCompiler(e){this.#e.setCompiler(this.encodeCompilerOptions(e))}sandbox(e=!0){this.#e.sandbox(e)}setMemoryLimit(e){return this.#e.setMemoryLimit(k(e,"memory limit"))}gcStop(){this.#e.gcStop()}gcRestart(){this.#e.gcRestart()}gcCollect(){this.#e.gcCollect()}gcStep(){return this.#e.gcStep()}traceback(e,o=0){return Je.decode(this.#e.traceback(e,k(o,"traceback level")))}setNamedRegistryValue(e,o){this.#e.setNamedRegistryValue(e,this.encode(o))}namedRegistryValue(e){return this.decode(this.#e.namedRegistryValue(e))}unsetNamedRegistryValue(e){this.#e.unsetNamedRegistryValue(e)}setInterruptHooks(e){let o=e.execution?this.#t.bridge(e.execution):void 0,n=e.pattern?this.#t.bridge(e.pattern):void 0,a=e.garbageCollection?this.#t.bridge(e.garbageCollection):void 0;this.#e.setInterruptHooks({mode:e.mode,execution:o,pattern:n,garbageCollection:a})}removeInterruptHooks(){this.#e.removeInterruptHooks()}requestInterrupt(){this.#e.requestInterrupt()}setDebugHooks(e){let o=e.step?this.#t.bridge(e.step):void 0,n=e.breakpoint?this.#t.bridge(e.breakpoint):void 0,a=e.interrupt?this.#t.bridge(e.interrupt):void 0,r=e.protectedError?this.#t.bridge(e.protectedError):void 0;this.#e.setDebugHooks({singleStep:e.singleStep,step:o,breakpoint:n,interrupt:a,protectedError:r})}removeDebugHooks(){this.#e.removeDebugHooks()}encode(e,o=0,n={tables:new WeakMap,nextTableId:1}){if(o>64)throw new TypeError("value nesting is too deep");if(e==null)return null;let a=ct(e);if(a)switch(a.kind){case"buffer":return{[Ii]:!0,bytes:a.bytes};case"userdata":return{[qe]:!0,value:this.storeUserdata(a.value),definition:this.bridgeUserdataDefinition({})};case"callback":return(a.args?this.createFunction(a.callback,{args:a.args}):this.createFunction(a.callback)).reference(this)}if(e instanceof B)return e.reference(this);if(e instanceof Ce)return{[kt]:!0,x:e.x,y:e.y,z:e.z};if(typeof e=="string")return ye(e),e;if(typeof e=="boolean"||typeof e=="number"||typeof e=="bigint"||e instanceof Uint8Array)return e;if(typeof e=="function")return{[qe]:!0,value:this.storeUserdata(e),definition:this.userdataBridge(e)??this.bridgeUserdataDefinition({})};if(Te(e)){let r=n.tables.get(e);if(r!==void 0)return{[K]:!0,reference:r};let s=He(n);return n.tables.set(e,s),{[K]:!0,id:s,array:e.map(i=>this.encode(i,o+1,n))}}if(typeof e=="object"){if(e instanceof Map){let l=n.tables.get(e);if(l!==void 0)return{[K]:!0,reference:l};let u=He(n);return n.tables.set(e,u),{[K]:!0,id:u,entries:[...e].map(([f,m])=>[this.encode(f,o+1,n),this.encode(m,o+1,n)])}}let r=this.userdataBridge(e);if(r)return{[qe]:!0,value:this.storeUserdata(e),definition:r};let s=n.tables.get(e);if(s!==void 0)return{[K]:!0,reference:s};let i=He(n);return n.tables.set(e,i),{[K]:!0,id:i,entries:Object.entries(e).map(([l,u])=>(ye(l),[l,this.encode(u,o+1,n)]))}}throw new TypeError(`unsupported JavaScript value of type ${typeof e}`)}encodeArray(e){let o={tables:new WeakMap,nextTableId:1};return e.map(n=>this.encode(n,0,o))}decode(e){if(Hi(e)){if(e[Ye]!==this.#e.stateId)throw new Error("Lua value belongs to another state");return this.wrapReference(e[fe],e[Qe])}if(Ji(e))return new Ce(e.x,e.y,e.z);if(e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="bigint"||typeof e=="string"||e instanceof Uint8Array)return e;throw new Error("Lua returned a value that cannot cross into JavaScript")}decodeArray(e){return e.map(o=>this.decode(o))}wrapReference(e,o){switch(o){case"table":return new P(this,this.#e,o,e,this.#o,W);case"function":return new de(this,this.#e,o,e,this.#o,W);case"thread":return new ve(this,this.#e,o,e,this.#o,W);case"buffer":return new Et(this,this.#e,o,e,this.#o,W);case"userdata":return new ee(this,this.#e,o,e,this.#o,W);case"class":return new Pt(this,this.#e,o,e,this.#o,W);case"object":return new Ui(this,this.#e,o,e,this.#o,W);default:return new B(this,this.#e,o,e,this.#o,W)}}encodeCallbackResult(e){let o=lt(e),n=e===void 0?[]:o||[e];return{[Mi]:!0,values:this.encodeArray(n)}}encodeCallbackReturn(e){return Rt(e)?Promise.resolve(e).then(o=>this.encodeCallbackResult(o)):this.encodeCallbackResult(e)}encodeCompilerOptions(e){return{...e,libraryConstants:e.libraryConstants?Object.fromEntries(Object.entries(e.libraryConstants).map(([o,n])=>[o,this.encode(n)])):void 0}}userdataBridge(e){let o=Object.getPrototypeOf(e);if(o===null||o===Object.prototype)return;let n=o?Reflect.get(o,"constructor"):void 0;if(typeof n=="function"){let s=this.#n.get(n);if(s)return s}let a=typeof n=="function"?this.userdataDefinition(n):void 0,r=this.bridgeUserdataDefinition(a??{});return a&&typeof n=="function"&&this.#n.set(n,r),r}userdataDefinition(e){let o=e;for(;typeof o=="function"&&o!==Function.prototype;){let n=this.#r.get(o);if(n){if(o!==e&&Object.hasOwn(n,"constructor")){let{constructor:a,...r}=n;return r}return n}o=Object.getPrototypeOf(o)}return Di(e)}userdataProxyDefinition(e,o){let n=o?.proxy??{};return!o||!Object.hasOwn(o,"constructor")?n:{...n,metamethods:{...n.metamethods,__call:{args:o.constructor,callback:(a,...r)=>Reflect.construct(e,r)}}}}storeUserdata(e){let o=Object.create(null);return this.#a.set(o,e),o}[N](e){if(typeof e!="object"||e===null)throw new Error("Lua returned an invalid userdata token");let o=this.#a.get(e);if(!o)throw new Error("Lua userdata value is unavailable");return o}bridgeUserdataDefinition(e){xe(e);let o=new WeakRef(this);return{fields:e.fields?Object.fromEntries(Object.entries(e.fields).map(([n,a])=>{let r=a.get?this.#t.bridge(a.get):void 0,s=a.set?this.#t.bridge(a.set):void 0;return[n,{get:r?i=>{let l=j(o);return l.encode(r(l[N](i)))}:void 0,set:s?(i,l)=>{let u=j(o),[f]=ue([u.decode(l)],a.type?[a.type]:void 0,`userdata field ${n}`);s(u[N](i),f)}:void 0}]})):void 0,methods:e.methods?Object.fromEntries(Object.entries(e.methods).map(([n,a])=>{let r=Se(a),s=this.#t.bridge(r.callback);return[n,(i,...l)=>{let u=j(o);return u.encodeCallbackReturn(s(u[N](i),...ue(l.map(f=>u.decode(f)),r.args,`userdata method ${n} argument`)))}]})):void 0,metamethods:e.metamethods?Object.fromEntries(Object.entries(e.metamethods).map(([n,a])=>{if(!a)throw new TypeError(`userdata metamethod ${n} is undefined`);if(Wi(n)){let i=a,l=this.#i.get(i);if(!l){let u=this.#t.bridge(i);l=(f,m,p)=>{let g=j(o),v=g[N](f),[w]=ue([g.decode(m)]),C=w instanceof ee?w.value:w;return g.encodeCallbackResult(p?u(C,v):u(v,C))},this.#i.set(i,l)}return[n,l]}let r=n==="__call"?Se(a):{callback:a},s=this.#t.bridge(r.callback);return[n,(i,...l)=>{let u=j(o),f=s(u[N](i),...ue(l.map(m=>u.decode(m)),r.args,`userdata metamethod ${n} argument`));return n==="__call"||n==="__namecall"?u.encodeCallbackReturn(f):u.encodeCallbackResult(f)}]})):void 0}}};function Hi(t){return typeof t=="object"&&t!==null&&typeof t[Ye]=="number"&&typeof t[fe]=="number"&&typeof t[Qe]=="string"}function Ji(t){return typeof t=="object"&&t!==null&&t[kt]===!0&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}function He(t){let e=t.nextTableId;if(e>4294967295)throw new RangeError("too many tables in one value");return t.nextTableId+=1,e}function k(t,e){if(!Number.isInteger(t)||t<0||t>4294967295)throw new RangeError(`${e} must be an integer between 0 and 4294967295`);return t}function F(t){if(typeof t!="object"||t===null)throw new TypeError("options must be an object");let{signal:e}=t;if(e===void 0)return[null,()=>{}];if(typeof e!="object"||e===null||typeof e.addEventListener!="function"||typeof e.removeEventListener!="function"||typeof e.aborted!="boolean")throw new TypeError("signal must be an AbortSignal");if(e.aborted)throw e.reason;let o,n=new Promise(a=>{o=()=>a(e.reason),e.addEventListener("abort",o,{once:!0})});return e.aborted&&o(),[n,()=>{try{e.removeEventListener("abort",o)}catch{}}]}var Xs=Function.prototype[Symbol.hasInstance];var A="script.lua",Xi=new Set(["and","break","do","else","elseif","end","false","for","function","if","in","local","nil","not","or","repeat","return","then","true","until","while"]),Yi=["...","..=","//=","==","~=","<=",">=","+=","-=","*=","/=","%=","^=","..","//","->","::","!=","&&","||","++","+","-","*","/","%","^","#","=","<",">","(",")","{","}","[","]",";",":",",",".","?","|","&","@","!","~"],Ze=t=>t>="a"&&t<="z"||t>="A"&&t<="Z"||t==="_",V=t=>t>="0"&&t<="9";function ke(t){t=String(t??"");let e=[],o=t.length,n=0,a=1,r=0,s=[],i=(m,p,g,v,w,C)=>{let b={t:m,v:t.slice(p,g),i:p,f:g,l:v,c:w,lf:a};return C&&Object.assign(b,C),e.push(b),b},l=(m,p)=>{for(let g=m;g<p;g++)t.charCodeAt(g)===10&&(a++,r=g+1)},u=m=>{let p=m+1,g=0;for(;t[p]==="=";)g++,p++;if(t[p]!=="[")return-1;let v="]"+"=".repeat(g)+"]",w=t.indexOf(v,p+1);return w<0?o:w+v.length},f=m=>{let p=m;for(;p<o;){let g=t[p];if(g==="\\"){p+=2;continue}if(g==="`")return[p+1,!1];if(g==="{")return[p+1,!0];if(g===`
`)return[p,!1];p++}return[o,!1]};for(;n<o;){let m=t[n],p=a,g=n-r;if(m===`
`){a++,r=n+1,n++;continue}if(m===" "||m===" "||m==="\r"||m==="\f"||m==="\v"){n++;continue}if(m==="-"&&t[n+1]==="-"){let b;t[n+2]==="["&&u(n+2)>=0?b=u(n+2):(b=t.indexOf(`
`,n),b<0&&(b=o));let y=n;l(n,b),i("com",y,b,p,g,{bloco:t[n+2]==="["&&b!==t.indexOf(`
`,n)}),n=b;continue}if(Ze(m)){let b=n+1;for(;b<o&&(Ze(t[b])||V(t[b]));)b++;let y=t.slice(n,b);i(Xi.has(y)?"palavra":"nome",n,b,p,g),n=b;continue}if(V(m)||m==="."&&V(t[n+1]||"")){let b=n;if(m==="0"&&(t[n+1]==="x"||t[n+1]==="X"||t[n+1]==="b"||t[n+1]==="B"))for(b=n+2;b<o&&/[0-9a-fA-F_]/.test(t[b]);)b++;else{for(;b<o&&(V(t[b])||t[b]==="_");)b++;if(t[b]==="."&&t[b+1]!==".")for(b++;b<o&&(V(t[b])||t[b]==="_");)b++;if(t[b]==="e"||t[b]==="E"){let y=b+1;if((t[y]==="+"||t[y]==="-")&&y++,V(t[y]||""))for(b=y;b<o&&(V(t[b])||t[b]==="_");)b++}}for(;b<o&&(Ze(t[b])||V(t[b]));)b++;i("num",n,b,p,g),n=b;continue}if(m==='"'||m==="'"){let b=n+1;for(;b<o&&t[b]!==m&&t[b]!==`
`;){if(t[b]==="\\"){if(t[b+1]==="z"){for(b+=2;b<o&&/\s/.test(t[b]);)t[b]===`
`&&(a++,r=b+1),b++;continue}t[b+1]===`
`&&(a++,r=b+2),b+=2;continue}b++}let y=t[b]===m;i("str",n,y?b+1:b,p,g,{aspas:m,aberto:!y}),n=y?b+1:b;continue}if(m==="["&&u(n)>=0){let b=u(n);l(n,b),i("str",n,b,p,g,{aspas:"[["}),n=b;continue}if(m==="`"){let[b,y]=f(n+1);y?(i("istr",n,b,p,g,{parte:"ini"}),s.push(0)):i("str",n,b,p,g,{aspas:"`",aberto:t[b-1]!=="`"||b===n+1}),n=b;continue}if(s.length&&(m==="{"||m==="}")){let b=s.length-1;if(m==="{"){s[b]++,i("op",n,n+1,p,g),n++;continue}if(s[b]>0){s[b]--,i("op",n,n+1,p,g),n++;continue}let[y,x]=f(n+1);x?i("istr",n,y,p,g,{parte:"meio"}):(i("istr",n,y,p,g,{parte:"fim"}),s.pop()),n=y;continue}let v=null;for(let b of Yi)if(t.startsWith(b,n)){v=b;break}if(v){i("op",n,n+v.length,p,g),n+=v.length;continue}let C=t.codePointAt(n)>65535?2:1;i("erro",n,n+C,p,g),n+=C}return e}var Ke=t=>t.filter(e=>e.t!=="com");function Qi(t,e){let o=t[e];if(o.t!=="nome"||o.v!=="continue")return!1;let n=t[e-1],a=t[e+1];return!(n&&n.t==="op"&&(n.v==="."||n.v===":")||a&&a.t==="op"&&["=","(",".",":","[",",","+=","-="].includes(a.v))}var Zi=new Set(["=","(","[","{",",","+","-","*","/","//","%","^","..","==","~=","<","<=",">",">=","+=","-=","*=","/=","//=","%=","^=","..=","#","and","or","not","return","in","until","while","if","elseif","::","->"]);function Re(t){return!t||t.t==="nome"||t.t==="num"||t.t==="str"?!0:t.t==="istr"?t.parte==="fim":t.t==="palavra"?["end","true","false","nil","break"].includes(t.v):t.t==="op"?[")","]","}","...",";"].includes(t.v):!1}function et(t){let e=[],o=[],n=[],a=[],r=new Set,s=[],i=new Set,l=new Set,u=null,f=!1,m=p=>{let g=t[p-1];if(!g)return!1;if(Zi.has(g.v)&&(g.t==="op"||g.t==="palavra"))return!0;if(g.t==="palavra"&&g.v==="then"){let v=e[e.length-1];return!!(v&&v.k==="ifexpr")}return g.t==="palavra"&&g.v==="else"?f:!1};for(let p=0;p<t.length;p++){let g=t[p],v=e[e.length-1],w=g.v,C=e.length===0,b=!1;if(C){let y=t[p-1],x=!1;g.t==="palavra"&&["local","return","for","while","repeat"].includes(w)?x=!0:g.t==="palavra"&&(w==="function"||w==="if")?x=!m(p)&&Re(y):g.t==="nome"&&(!y||y.lf<g.l)&&Re(y)&&(x=!0),x&&n.push(p),g.t==="palavra"&&w==="local"&&a.push({k:p,nomes:tt(t,p)})}if(g.t==="palavra")switch(w){case"function":{let y=m(p);y&&l.add(p);let x=p+1,Fe=[];for(;x<t.length&&(t[x].t==="nome"||t[x].t==="op"&&(t[x].v==="."||t[x].v===":"));)t[x].t==="nome"&&r.add(x),Fe.push(t[x].v),x++;if(t[x]&&t[x].t==="op"&&t[x].v==="<"){let O=0;for(;x<t.length;x++)if(t[x].v==="<")O++;else if(t[x].v===">"&&(O--,O===0)){x++;break}}let M={k:"function",tok:g,nome:Fe.join(""),expr:y,inicioCorpo:null};if(t[x]&&t[x].v==="("){let O=0,E=x;for(;E<t.length;E++)if(t[E].t==="op"){if(t[E].v==="(")O++;else if(t[E].v===")"&&(O--,O===0))break}let it=t[E];it&&!(t[E+1]&&t[E+1].t==="op"&&t[E+1].v===":")&&o.push({pos:it.f,linha:g.l}),M.inicioCorpo=E+1,M.parametros=[];let Le=0;for(let X=x+1;X<E;X++){let Y=t[X];Y.t==="op"&&["(","{","[","<"].includes(Y.v)?Le++:Y.t==="op"&&[")","}","]",">"].includes(Y.v)?Le--:Y.t==="nome"&&Le===0&&(X===x+1||t[X-1].t==="op"&&t[X-1].v===",")&&M.parametros.push(Y.v)}}if(!M.nome&&t[p-1]&&t[p-1].v==="local"&&t[p+1]&&t[p+1].t==="nome"&&(M.nome=t[p+1].v),!M.nome&&y){let O=t[p-1],E=t[p-2];O&&O.v==="="&&E&&E.t==="nome"&&(M.nome=E.v)}e.push(M),s.push(M);break}case"do":e.push({k:"do"}),o.push({pos:g.f,linha:u?u.l:g.l}),u=null;break;case"while":case"for":u=g;break;case"repeat":e.push({k:"repeat"}),o.push({pos:g.f,linha:g.l});break;case"until":v&&v.k==="repeat"&&e.pop();break;case"if":m(p)?(i.add(p),e.push({k:"ifexpr"})):e.push({k:"if"});break;case"else":v&&v.k==="ifexpr"&&(e.pop(),b=!0);break;case"end":{for(;e.length;){let y=e.pop();if(y.k==="function"||y.k==="do"||y.k==="if"){y.k==="function"&&(y.fimCorpo=p);break}}break}default:break}else if(g.t==="op"){if(w==="("||w==="["||w==="{")e.push({k:w});else if(w===")"||w==="]"||w==="}")for(;e.length;){let y=e.pop();if(y.k==="("||y.k==="["||y.k==="{")break}}f=b}return{checagens:o,comandosTopo:n,locaisTopo:a,definicoes:r,funcoes:s,ifExpr:i,funcExpr:l}}function tt(t,e){let o=[],n=e+1;if(t[n]&&t[n].t==="palavra"&&t[n].v==="function")return t[n+1]&&t[n+1].t==="nome"&&o.push(t[n+1].v),o;for(;;){let a=t[n];if(!a||a.t!=="nome")break;if(o.push(a.v),n++,t[n]&&t[n].t==="op"&&t[n].v===":"){let r=0;for(n++;n<t.length;n++){let s=t[n];if(s.t==="op"&&["(","{","[","<"].includes(s.v))r++;else if(s.t==="op"&&[")","}","]",">"].includes(s.v))r--;else{if(r<=0&&s.t==="op"&&(s.v===","||s.v==="="))break;if(r<=0&&s.t==="palavra"&&s.v!=="nil")break}if(r<0)break}}if(t[n]&&t[n].t==="op"&&t[n].v===","){n++;continue}break}return o}var Ki=t=>` __cobra_k-=1 if __cobra_k<0 then __cobra_k=__cobra_chk(${t}) end `,Ft=t=>`__cobra_exp("${t}",function()return ${t} end,function(__cobra_v)${t}=__cobra_v end);`;function Lt(t,e={}){t=String(t??"").replace(/\r\n?/g,`
`);let o=ke(t),n=Ke(o),a=et(n),r=[];for(let u of a.checagens)r.push({pos:u.pos,texto:Ki(u.linha),ordem:1});let s=[];if(e.exportar!==!1){let u=[],f=0,m=!1;for(let p of a.comandosTopo){for(;f<a.locaisTopo.length&&a.locaisTopo[f].k<p;)u.push(...a.locaisTopo[f].nomes),f++;u.length&&(r.push({pos:n[p].i,texto:u.map(Ft).join(""),ordem:0}),u=[]),m=n[p].t==="palavra"&&n[p].v==="return"}for(;f<a.locaisTopo.length;)u.push(...a.locaisTopo[f].nomes),f++;u.length&&!m&&r.push({pos:t.length,texto:`
`+u.map(Ft).join(""),ordem:2});for(let p of a.locaisTopo)for(let g of p.nomes)s.includes(g)||s.push(g)}r.sort((u,f)=>u.pos-f.pos||u.ordem-f.ordem);let i="local __cobra_k,__cobra_chk=4000,__cobra_chk;",l=0;for(let u of r)i+=t.slice(l,u.pos)+u.texto,l=u.pos;return i+=t.slice(l),{fonte:i,nomesTopo:s}}var es=new Set(["+","-","*","/","//","%","^","..","==","~=","<","<=",">",">="]);function jt(t){t=String(t??"").replace(/\r\n?/g,`
`);let e=ke(t),o=Ke(e),n=et(o),a={},r=[],s={},i=0,l=(u,f)=>{u[f]=(u[f]||0)+1};for(let u=0;u<o.length;u++){let f=o[u],m=o[u-1];if(f.t==="palavra"){if(l(a,f.v),(f.v==="and"||f.v==="or"||f.v==="not")&&l(s,f.v),f.v==="for"){let p=o[u+2]&&o[u+2].t==="op"&&o[u+2].v==="="?"for numerico":"for in";l(a,p)}f.v==="if"&&n.ifExpr.has(u)&&l(a,"if expressao"),f.v==="function"&&(n.funcExpr.has(u)&&l(a,"function anonima"),m&&m.v==="local"&&l(a,"local function"));continue}if(Qi(o,u)){l(a,"continue");continue}if(f.t==="istr"&&f.parte==="ini"){i++;continue}if(f.t==="op"){let p=f.v;es.has(p)?p==="-"&&!Re(m)?l(s,"-unario"):l(s,p):p.length>=2&&p.endsWith("=")&&!["==","~=","<=",">="].includes(p)?(l(s,p),l(s,p.slice(0,-1))):(p==="#"||p==="=")&&l(s,p);continue}if(f.t==="nome"&&!n.definicoes.has(u)){let p=o[u+1];if(!(p&&(p.t==="op"&&(p.v==="("||p.v==="{")||p.t==="str"||p.t==="istr"&&p.parte==="ini")))continue;let v=[f.v],w=u-1;for(;w>=1&&o[w].t==="op"&&(o[w].v==="."||o[w].v===":")&&o[w-1].t==="nome";)v.unshift(o[w-1].v,o[w].v),w-=2;let C=v.join("");r.push({nome:f.v,caminho:C,linha:f.l,metodo:m&&m.t==="op"&&m.v===":"})}}return{palavras:a,chamadas:r,operadores:s,interpolacoes:i,funcoes:n.funcoes.map(u=>({nome:u.nome,linha:u.tok.l,expr:u.expr,parametros:u.parametros||[],recursiva:u.nome?ts(o,u):!1})),globais:as(o,n),comentarios:e.filter(u=>u.t==="com").map(u=>({texto:u.v.replace(/^--(\[(=*)\[)?/,"").replace(/\](=*)\]$/,"").trim(),linha:u.l})),limpo:is(t,e)}}function ts(t,e){if(e.inicioCorpo==null)return!1;let o=e.fimCorpo!=null?e.fimCorpo:t.length,n=e.nome.split(/[.:]/).pop();for(let a=e.inicioCorpo;a<o;a++){let r=t[a];if(r.t==="nome"&&r.v===n){let s=t[a+1];if(s&&s.t==="op"&&s.v==="(")return!0}}return!1}var os=new Set(["game","workspace","script","print","warn","error","Instance","Vector3","Vector2","Color3","BrickColor","CFrame","UDim","UDim2","Enum","task","wait","spawn","delay","tick","time","typeof","math","string","table","os","coroutine","shared","_G"]),ns=new Set(["do","then","else","repeat"]);function rs(t,e){let o=t[e-1];return!o||o.t==="palavra"&&ns.has(o.v)||o.t==="op"&&o.v===";"?!0:Re(o)}function as(t,e){let o=new Set,n=[],a=r=>{!o.has(r)&&!os.has(r)&&!n.includes(r)&&n.push(r)};for(let r=0;r<t.length;r++){let s=t[r];if(s.t==="palavra"&&s.v==="local")for(let i of tt(t,r))o.add(i);else if(s.t==="palavra"&&s.v==="for")for(let i=r+1;i<t.length&&!(t[i].t==="palavra"&&(t[i].v==="in"||t[i].v==="do"))&&t[i].v!=="=";i++)t[i].t==="nome"&&o.add(t[i].v)}for(let r of e.funcoes)for(let s of r.parametros||[])o.add(s);for(let r=0;r<t.length;r++){let s=t[r];if(s.t==="palavra"&&s.v==="function"&&!e.funcExpr.has(r)&&!(t[r-1]&&t[r-1].v==="local")){let f=t[r+1],m=t[r+2];f&&f.t==="nome"&&!(m&&m.t==="op"&&(m.v==="."||m.v===":"))&&a(f.v);continue}if(s.t!=="nome"||!rs(t,r))continue;let i=[s.v],l=r+1;for(;t[l]&&t[l].t==="op"&&t[l].v===","&&t[l+1]&&t[l+1].t==="nome";)i.push(t[l+1].v),l+=2;let u=t[l];if(!(!u||u.t!=="op")&&(u.v==="="||i.length===1&&["+=","-=","*=","/=","//=","%=","^=","..="].includes(u.v)))for(let f of i)a(f)}return n}function is(t,e){e=e||ke(t);let o="",n=0,a=r=>r.replace(/[^\n]/g," ");for(let r of e)if(!(r.t!=="com"&&r.t!=="str"&&r.t!=="istr")){if(o+=t.slice(n,r.i),r.t==="com")o+=a(r.v);else if(r.t==="str"){let s=r.aspas==="[["?r.v.match(/^\[=*\[/)[0]:r.v[0],i=r.aspas==="[["?s.replace(/\[/g,"]"):r.aberto?"":r.v[r.v.length-1];o+=s+a(r.v.slice(s.length,r.v.length-i.length))+i}else{let s=r.v[0],i=r.v[r.v.length-1];o+=s+a(r.v.slice(1,r.v.length-1))+(r.v.length>1?i:"")}n=r.f}return o+t.slice(n)}function Nt(t){let e=Ke(ke(t)),o=et(e),n=new Set;for(let a=0;a<e.length;a++){let r=e[a];if(r.t==="palavra"&&r.v==="local")for(let s of tt(e,a))n.add(s);if(r.t==="palavra"&&r.v==="for")for(let s=a+1;s<e.length&&!(e[s].t==="palavra"&&(e[s].v==="in"||e[s].v==="do"))&&e[s].v!=="=";s++)e[s].t==="nome"&&n.add(e[s].v);r.t==="palavra"&&r.v==="function"&&e[a+1]&&e[a+1].t==="nome"&&n.add(e[a+1].v)}for(let a of o.funcoes)for(let r of a.parametros||[])n.add(r);return n}var J=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ss=new RegExp(`(?:^|\\n|\\s)${J(A)}:(\\d+)`);function Pe(t,e){let o=String(t||"").split(`
`);return e>=1&&e<=o.length?o[e-1]:null}function zt(t,e){let o=Pe(t,e);return o==null?`${A}:${e}`:`${A}:${e}
${o.replace(/\t/g," ")}`}var ot={function:"a fun\xE7\xE3o (function)",then:"o if (then)",else:"o else",do:"o bloco do (do for/while)",repeat:"o repeat","(":"o par\xEAntese (","{":"a chave { (tabela)","[":"o colchete ["};function De(t){return t==="<eof>"?"o fim do c\xF3digo":t}function Ut(t,e){let o=String(e||"").replace(/^syntax error:\s*/,""),n=null,a=new RegExp(`^${J(A)}:(\\d+):\\s*`).exec(o);a&&(n=Number(a[1]),o=o.slice(a[0].length));let r=cs(t,o,n),s=r.linha||n;return{tipo:"erro de sintaxe",texto:`${s?zt(t,s)+`
`:""}${A}:${n??"?"}: ${o}`,linha:s,dica:r.dica}}function cs(t,e,o){let n,a=Pe(t,o)||"";if(n=/^Expected '(end|until)' \(to close '([^']+)' at line (\d+)\), got (.+)$/.exec(e)){let[,r,s,i,l]=n,u=ot[s]||`o ${s}`;if(r==="until")return{linha:l==="<eof>"?Number(i):null,dica:`O repeat da linha ${i} n\xE3o tem o seu until. Um repeat termina com until condi\xE7\xE3o: repeat ... until vida <= 0`};if(s==="else"&&/\belse\s+if\b/.test(t))return{linha:l==="<eof>"?Number(i):null,dica:'Em Lua, "sen\xE3o se" se escreve junto: elseif (sem espa\xE7o). Com else if separado, o Luau entende um if novo dentro do else, que precisaria de outro end.'};let f=`Faltou um end para fechar ${u} que come\xE7a na linha ${i}. Todo function, if, for, while e do termina com end.`;return l!=="<eof>"&&(f+=` O Luau chegou em ${De(l)} e o bloco ainda estava aberto.`),s==="do"&&/^'(print|local|[A-Za-z_])/.test(l)&&/\bbreak\b|\breturn\b/.test(t)&&(f="Depois de break (ou return) o bloco precisa terminar: eles t\xEAm que ser o \xFAltimo comando antes do end. Mova o break para o fim do bloco (ou ponha o c\xF3digo antes dele)."),{linha:l==="<eof>"?Number(i):null,dica:f}}if(n=/^Expected '([)\]}])' \(to close '([([{])' at (line|column) (\d+)\), got (.+)$/.exec(e)){let[,r,s,i,l,u]=n,f=i==="line"?`na linha ${l}`:`na coluna ${l}`,m=i==="line"?Number(l):null;return u==="'x'"&&/\d\s*x\s*[\d(]/.test(a)?{dica:"Em programa\xE7\xE3o, a multiplica\xE7\xE3o \xE9 o asterisco *, n\xE3o a letra x: 3 * 4."}:r===")"&&u!=="<eof>"&&/^['"`]|^[A-Za-z_]/.test(u)?{dica:'Faltou alguma coisa entre dois valores dentro dos par\xEAnteses: uma v\xEDrgula (para separar argumentos: print(a, b)) ou .. para juntar textos ("Vida: " .. vida).'}:u==="<eof>"?{linha:m,dica:`O c\xF3digo terminou sem fechar ${ot[s]} aberto ${f}. Falta um ${r}.`}:{linha:m&&u==="<eof>"?m:null,dica:`Faltou fechar ${ot[s]} aberto ${f} com ${r} antes de ${De(u)}.`}}if(n=/^Expected identifier when parsing expression, got (.+)$/.exec(e)){let r=n[1];return/Unicode character U\+201[cdCD89]|did you mean '"'|did you mean '''/.test(r)?{dica:`Aspas curvas (\u201C \u201D \u2018 \u2019) n\xE3o funcionam em c\xF3digo \u2014 elas aparecem quando o texto vem de um editor de documentos. Troque por aspas retas: " ou '.`}:/Unicode character/.test(r)?{dica:"Acentos e \xE7 s\xF3 podem aparecer dentro de textos (entre aspas) e de coment\xE1rios. Nomes de vari\xE1veis n\xE3o podem ter acento: escreva pocao em vez de po\xE7\xE3o."}:r==="'='"?{dica:"Depois de = precisa vir um valor (local vida = 100). Para comparar, use == dentro de um if."}:r==="<eof>"?{linha:ls(t),dica:"O c\xF3digo terminou antes da hora: faltou um valor depois de um operador (como +, .. ou =)."}:r==="')'"?{dica:"Tem um ) sobrando, ou faltou um valor antes dele (por exemplo, depois de um operador ou de uma v\xEDrgula)."}:r==="','"?{dica:"Tem uma v\xEDrgula sobrando (ou faltou o valor entre duas v\xEDrgulas)."}:r==="';'"?{dica:"Tem um ; sobrando aqui. Em Lua o ponto e v\xEDrgula \xE9 opcional: pode tirar."}:r==="'elseif'"?{dica:"O else tem que ser o \xFAltimo caso do if: os elseif v\xEAm antes dele."}:r==="'then'"?{dica:"Faltou a condi\xE7\xE3o antes do then: if vida > 0 then ... end"}:r==="'['"?{dica:"Em Lua, listas s\xE3o escritas com chaves: local lista = {1, 2, 3} (colchetes servem para pegar um item: lista[1])."}:r==="'!'"?{dica:'Em Lua, "diferente" se escreve ~= (e n\xE3o !=), e "n\xE3o" se escreve not.'}:/^'[-+*/.]+='$/.test(r)&&/^\s*local\s+\w+\s*\S+=/.test(a)?{dica:`${r.slice(1,-1)} s\xF3 funciona numa vari\xE1vel que j\xE1 existe. Crie com local e um = (local moedas = 10) e, nas linhas de baixo, atualize (moedas ${r.slice(1,-1)} 5).`}:/=[-+*/]\s/.test(a.replace(/[-+*/<>~=]=/g," "))&&/^'[-+*/]'$/.test(r)?{dica:`O operador se escreve com o sinal antes do igual: ${r.slice(1,-1)}= (por exemplo moedas ${r.slice(1,-1)}= 10).`}:r==="'+='"||r==="'-='"?{dica:`${r.slice(1,-1)} \xE9 um comando sozinho: x += 1 (soma 1 em x). Ele n\xE3o pode aparecer no meio de uma conta.`}:r==="'+'"&&/\+\+/.test(a)?{dica:"Em Lua n\xE3o existe ++. Para somar 1, escreva x += 1 (ou x = x + 1)."}:r==="'...'"?{dica:'Para juntar textos use dois pontos: "a" .. "b" (tr\xEAs pontos ... \xE9 outra coisa).'}:r==="'return'"?{dica:"Depois de return vem o valor que a fun\xE7\xE3o devolve (ou nada)."}:r==="'<'"&&/^\s*local\s+\w+\s*</.test(a)?{dica:"O Luau (a Lua do Roblox) n\xE3o tem <const> nem <close>. Escreva s\xF3 local nome = valor."}:{dica:`O Luau esperava um valor aqui (um n\xFAmero, um texto, uma vari\xE1vel...), mas encontrou ${De(r)}. Confira se n\xE3o falta um valor depois de um operador ou se n\xE3o sobrou um s\xEDmbolo.`}}if(n=/^Unexpected '([^']+)'; did you mean '([^']+)'\?$/.exec(e))return n[1]==="!="?{dica:'Em Lua, "diferente" se escreve ~= (e n\xE3o !=).'}:n[1]==="&&"||n[1]==="||"?{dica:`Em Lua os operadores l\xF3gicos s\xE3o palavras: and, or e not (e n\xE3o ${n[1]}).`}:{dica:`Em Lua escreva ${n[2]} em vez de ${n[1]}.`};if(/^Malformed string/.test(e))return{dica:`Um texto come\xE7ou com aspas e n\xE3o terminou na mesma linha. Feche com o mesmo tipo de aspas que abriu: "..." ou '...'. Para um texto de v\xE1rias linhas, use [[ ... ]].`};if(/^Malformed interpolated string/.test(e))return{dica:"Num texto com interpola\xE7\xE3o (entre crases), cada { precisa do seu }: `Vida: {vida}`. Para mostrar uma chave de verdade, escreva \\{."};if(/^Malformed number/.test(e))return{dica:"Esse n\xFAmero est\xE1 mal escrito. Decimais usam ponto (3.5) e n\xFAmeros n\xE3o podem ter letras grudadas. (Para juntar textos e n\xFAmeros use .. com espa\xE7os: 1 .. 2.)"};if(n=/^Expected 'do' when parsing (for|while) loop, got (.+)$/.exec(e))return n[1]==="for"?{dica:"O for termina a primeira linha com do: for i = 1, 10 do ... end"}:{dica:"Depois da condi\xE7\xE3o do while vem do: while vida > 0 do ... end"};if(n=/^Expected ',' when parsing (index range|for loop), got 'to'$/.exec(e))return{dica:"Em Lua o for num\xE9rico usa v\xEDrgula, n\xE3o to: for i = 1, 10 do ... end"};if(n=/^Expected 'then' when parsing (if statement|elseif statement|if-then-else expression), got (.+)$/.exec(e))return n[2]==="'='"?{dica:"Para comparar use == (dois sinais de igual). Um = sozinho serve para guardar um valor numa vari\xE1vel."}:{dica:"Depois da condi\xE7\xE3o do if (ou do elseif) vem then: if vida > 0 then ... end"};if(/^Expected 'else' when parsing if-then-else expression/.test(e))return{dica:'Um if usado como valor precisa do else: local texto = if vivo then "vivo" else "morto"'};if(/^Incomplete statement: expected assignment or a function call/.test(e)){let r=/^\s*(Local|If|For|While|Function|Return|End|Then|Else|Elseif|Repeat|Until|Do|Print)\b/.exec(a);return r?{dica:`Palavras do Lua s\xE3o escritas em min\xFAsculas: ${r[1].toLowerCase()} (e n\xE3o ${r[1]}).`}:/\+\+|--\s*$/.test(a)&&/\w\+\+/.test(a)?{dica:"Em Lua n\xE3o existe ++. Para somar 1, escreva x += 1 (ou x = x + 1)."}:/^\s*goto\b/.test(a)?{dica:"O Luau (a Lua do Roblox) n\xE3o tem goto. Use la\xE7os com break e continue."}:/==/.test(a)&&!/\bif\b|\bwhile\b|\buntil\b|\breturn\b|=\s*[^=]/.test(a.replace(/==/g,""))?{dica:"== compara dois valores, mas uma compara\xE7\xE3o sozinha n\xE3o \xE9 um comando. Para guardar um valor use um =; para decidir algo, use if ... then."}:/\.\s*\d/.test(a)?{dica:"Para usar um n\xFAmero como chave escreva entre colchetes: t[1] = 2 (t.1 n\xE3o funciona)."}:/^\s*export\b/.test(a)?{dica:"export s\xF3 serve para tipos (export type ...). Para um valor, use local."}:/^\s*\w+(\s*\.\s*\w+)*\s+[\w"'(]/.test(a)?{dica:"Esta linha n\xE3o \xE9 um comando completo. Para chamar uma fun\xE7\xE3o, use par\xEAnteses: print(x). Para guardar um valor, use =: vida = 100."}:{dica:"Esta linha n\xE3o faz nada sozinha. Em Lua cada comando \xE9 uma atribui\xE7\xE3o (vida = 100), uma chamada de fun\xE7\xE3o com par\xEAnteses (print(vida)) ou um bloco (if, for, while, local...)."}}if(n=/^Expected <eof>, got (.+)$/.exec(e)){let r=n[1];return r==="'end'"?{dica:"Este end est\xE1 sobrando: n\xE3o h\xE1 nenhum bloco aberto (function, if, for, while, do) para ele fechar. Confira se n\xE3o tem um end a mais."}:r==="'elseif'"||r==="'else'"?{dica:`Este ${r.slice(1,-1)} n\xE3o tem um if aberto antes dele. Confira se n\xE3o sobrou um end antes dele.`}:r==="'until'"?{dica:"Este until n\xE3o tem um repeat antes dele."}:/\breturn\b/.test(t)?{dica:"Depois de um return o bloco precisa terminar: o return tem que ser o \xFAltimo comando (do script, da fun\xE7\xE3o ou do bloco)."}:{dica:`O Luau n\xE3o esperava ${De(r)} aqui. Confira se n\xE3o sobrou um end ou um par\xEAntese.`}}return/^Expected ',' after table constructor element/.test(e)?{dica:'Separe os itens da tabela com v\xEDrgulas: {vida = 100, nivel = 1} ou {"espada", "escudo"}.'}:(n=/^Expected identifier when parsing variable name, got (.+)$/.exec(e))?n[1]==="'('"?{dica:"local function precisa de um nome: local function atacar() ... end"}:/^'\d/.test(n[1])?{dica:"Nomes de vari\xE1veis n\xE3o podem come\xE7ar com n\xFAmero: use pontos1 em vez de 1pontos."}:n[1]==="'='"?{dica:"Faltou o nome da vari\xE1vel antes do = (ou sobrou uma v\xEDrgula)."}:/Unicode character/.test(n[1])?{dica:"Nomes de vari\xE1veis n\xE3o podem ter acento nem \xE7: escreva pocao em vez de po\xE7\xE3o."}:{dica:"Nome de vari\xE1vel inv\xE1lido. Nomes come\xE7am com letra ou _, e s\xF3 t\xEAm letras sem acento, n\xFAmeros e _ (sem espa\xE7os)."}:(n=/^Expected '\(' when parsing function, got (.+)$/.exec(e))?n[1]==="'.'"?{dica:"Depois de : vem s\xF3 o nome do m\xE9todo: function Classe:metodo(...) ... end"}:{dica:"Depois de function (e do nome) v\xEAm os par\xEAnteses com os par\xE2metros: local function atacar(alvo) ... end"}:/^Expected '\(', '\{' or <string> when parsing function call/.test(e)?{dica:"Depois de obj:metodo vem uma chamada com par\xEAnteses: obj:metodo(...). Para guardar um valor num campo use ponto: obj.campo = valor."}:/^Ambiguous syntax/.test(e)?{dica:"Uma linha que come\xE7a com ( logo depois de outra parece continua\xE7\xE3o da linha de cima. Junte as duas linhas ou ponha um ; no fim da linha de cima."}:/^Expected type, got/.test(e)?{dica:"Depois de : numa declara\xE7\xE3o vem um tipo (local vida: number = 100). Se n\xE3o quer usar tipos, apague os dois-pontos."}:/^Assigned expression must be a variable or a field/.test(e)?{dica:"Do lado esquerdo do = precisa ficar uma vari\xE1vel ou um campo (vida = 100, jogador.vida = 100)."}:/^Cannot (use|have) '\.\.\.' outside a vararg function/.test(e)?{dica:"... s\xF3 funciona dentro de uma fun\xE7\xE3o declarada com ... nos par\xE2metros."}:/^Unknown escape sequence|^Invalid escape/i.test(e)?{dica:"Dentro de textos, a barra \\ come\xE7a um c\xF3digo especial (\\n \xE9 quebra de linha). Para uma barra de verdade escreva \\\\."}:/^Expected 'in' when parsing for loop/.test(e)?{dica:"O for gen\xE9rico \xE9 for chave, valor in pairs(tabela) do ... end (com in)."}:/^Expected '=' when parsing for loop|^Expected '=' or 'in'/.test(e)?{dica:"O for num\xE9rico \xE9 for i = 1, 10 do ... end; o de tabelas \xE9 for i, v in ipairs(lista) do ... end."}:/^Expected 'end'/.test(e)?{dica:"Faltou um end para fechar um bloco (function, if, for, while ou do)."}:{dica:"O Luau n\xE3o entendeu o c\xF3digo neste ponto. Confira se cada function/if/for/while tem o seu end, se cada ( tem o seu ) e se os textos est\xE3o entre aspas \u2014 \xE0s vezes o erro de verdade est\xE1 um pouco antes."}}function ls(t){let e=String(t||"").split(`
`);for(let o=e.length-1;o>=0;o--)if(e[o].trim())return o+1;return null}var z={nil:"nil (nada)",number:"um n\xFAmero",string:"um texto (string)",boolean:"um boolean (true/false)",table:"uma tabela",function:"uma fun\xE7\xE3o",vector:"um Vector3",userdata:"um objeto",thread:"uma thread"};function us(t){let e=new RegExp(`^${J(A)}:(\\d+):`).exec(t.mensagem||"");if(e)return Number(e[1]);let o=ss.exec(t.pilha||"");return o?Number(o[1]):null}function ds(t){let e=[];for(let o of String(t||"").split(`
`)){let n=new RegExp(`^${J(A)}:(\\d+)(?: function (\\S+))?`).exec(o.trim());n&&e.push({linha:Number(n[1]),funcao:n[2]||""})}return e}function fs(t){if(t.length<=1)return"";let e=[],o=0;for(;o<t.length;){let a=t[o],r=o+1;for(;r<t.length&&t[r].linha===a.linha&&t[r].funcao===a.funcao;)r++;let s=` ${A}:${a.linha}${a.funcao?` (na fun\xE7\xE3o ${a.funcao})`:""}`;if(r-o>3)e.push(s,` ... (a mesma chamada se repete mais ${r-o-1} vezes)`);else for(let i=o;i<r;i++)e.push(s);o=r}return`
Pilha de chamadas:
`+(e.length>10?[...e.slice(0,9),` ... (mais ${e.length-9} linhas)`]:e).join(`
`)}function ms(t,e){if(!t||!e)return null;let n=new RegExp(`([A-Za-z_][\\w]*(?:\\s*[.:]\\s*[A-Za-z_]\\w*|\\[[^\\]]*\\])*)\\s*[.:]\\s*${J(e)}\\b`).exec(t.replace(/--.*$/,""));return n?n[1].replace(/\s+/g,""):null}function ps(t){if(!t)return null;let e=t.replace(/--.*$/,"").replace(/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/g,'""'),o=/([A-Za-z_][\w]*(?:\s*[.:]\s*[A-Za-z_]\w*)*)\s*\(/g,n=[],a;for(;a=o.exec(e);){let r=a[1].replace(/\s+/g,"");/^(if|while|until|return|and|or|not|function|local|elseif|in|do|then)$/.test(r)||n.push(r)}return n}var Bt=["print","warn","game","workspace","script","Instance","Vector3","Color3","BrickColor","CFrame","Enum","task","tostring","tonumber","typeof","pairs","ipairs","table","string","math","pcall","error","wait"];function hs(t,e){let o=Array.from({length:t.length+1},(n,a)=>[a]);for(let n=1;n<=e.length;n++)o[0][n]=n;for(let n=1;n<=t.length;n++)for(let a=1;a<=e.length;a++)o[n][a]=Math.min(o[n-1][a]+1,o[n][a-1]+1,o[n-1][a-1]+(t[n-1]===e[a-1]?0:1)),n>1&&a>1&&t[n-1]===e[a-2]&&t[n-2]===e[a-1]&&(o[n][a]=Math.min(o[n][a],o[n-2][a-2]+1));return o[t.length][e.length]}function We(t,e){let o=t.toLowerCase(),n=[...new Set(e)].filter(i=>i&&i!==t);for(let i of n)if(i.toLowerCase()===o)return i;let a=t.length<=3?0:t.length<=7?1:2,r=null,s=1/0;for(let i of n){if(!a||Math.abs(i.length-t.length)>a)continue;let l=hs(i.toLowerCase(),o);l<=a&&l<s&&(r=i,s=l)}return r}var bs=["Workspace","Players","Lighting","ReplicatedStorage","ReplicatedFirst","ServerStorage","ServerScriptService","StarterGui","StarterPack","StarterPlayer","Teams","SoundService","RunService","TweenService","Debris","DataStoreService","CollectionService","HttpService","UserInputService","ContextActionService","MarketplaceService","PathfindingService"],gs={Vector3:"Vector3.new(0, 5, 0)",Color3:"Color3.fromRGB(255, 0, 0)",BrickColor:'BrickColor.new("Bright red")',CFrame:"CFrame.new(0, 5, 0)",bool:"true ou false",boolean:"true ou false",number:"um n\xFAmero, como 10",int:"um n\xFAmero inteiro, como 10",string:"um texto entre aspas",UDim2:"UDim2.new(0, 100, 0, 50)"},Vt={True:"Em Lua os valores l\xF3gicos s\xE3o escritos em min\xFAsculas: true e false.",False:"Em Lua os valores l\xF3gicos s\xE3o escritos em min\xFAsculas: true e false.",None:"Em Lua a aus\xEAncia de valor se chama nil.",null:"Em Lua a aus\xEAncia de valor se chama nil.",len:"Em Lua o tamanho de um texto ou de uma lista \xE9 #: #lista, #texto.",str:"Para transformar em texto use tostring(valor).",int:"Para transformar um texto em n\xFAmero use tonumber(texto).",console:"Em Lua, para mostrar algo use print(...).",self:"self s\xF3 existe dentro de m\xE9todos declarados com dois-pontos: function Classe:metodo() ... end."};function _s(t,e,o,n,a){let r,s=Pe(o,n)||"",i=t;if(r=/^attempt to index nil with '([^']+)'$/.exec(i)){let l=r[1],u=ms(s,l),f=u?`\`${u}\` \xE9 nil (n\xE3o existe), ent\xE3o n\xE3o d\xE1 para usar \`${u}.${l}\`. `:`Voc\xEA tentou usar .${l} (um campo, propriedade ou filho) de algo que \xE9 nil (n\xE3o existe). `;return/FindFirstChild|FindFirstAncestor|FindFirstChildOfClass|FindFirstChildWhichIsA/.test(s)||u&&/FindFirst/.test(o)?f+="FindFirstChild devolve nil quando n\xE3o acha o filho: confira o nome (mai\xFAsculas contam) ou teste antes com if objeto then ... end.":u&&/Parent$/.test(u)?f+="O Parent \xE9 nil quando o objeto n\xE3o est\xE1 em lugar nenhum (ou j\xE1 foi destru\xEDdo).":u&&/^[A-Za-z_]\w*$/.test(u)?f+=`Confira se a vari\xE1vel ${u} recebeu um valor antes desta linha e se o nome est\xE1 escrito igual (mai\xFAsculas contam).`:f+="Confira se o objeto existe (FindFirstChild devolve nil quando n\xE3o acha) e se os nomes est\xE3o escritos certo.",f}if(r=/^attempt to index nil with number$/.exec(i))return"Voc\xEA usou [ ] (pegar um item) numa vari\xE1vel que \xE9 nil. Confira se a lista (tabela) foi criada: local lista = {}.";if(r=/^attempt to index (number|string|boolean|function|thread) with (?:'([^']+)'|number)$/.exec(i)){let l=r[2];return r[1]==="string"&&l?`Textos n\xE3o t\xEAm o campo .${l}. Para m\xE9todos de texto use dois-pontos (texto:upper()) ou a biblioteca string (string.upper(texto)). Se era para ser um objeto do jogo, confira: a vari\xE1vel guarda s\xF3 o nome (um texto)?`:`Voc\xEA usou ${l?"."+l:"[ ]"} em ${z[r[1]]||r[1]}, mas s\xF3 tabelas e objetos do Roblox t\xEAm campos. Confira o que essa vari\xE1vel guarda (print(typeof(x)) ajuda).`}if(r=/^attempt to index vector with '([^']+)'$/.exec(i))return`Um Vector3 n\xE3o muda por partes (${r[1]} \xE9 s\xF3 de leitura). Crie um novo: parte.Position = Vector3.new(x, y, z) \u2014 ou some: parte.Position += Vector3.new(0, 5, 0).`;if(/^attempt to call a nil value$/.test(i)){let l=ps(s)||[],u=o?Nt(o):new Set;for(let f of l){let m=f.split(/[.:]/).pop();if(!f.includes(".")&&!f.includes(":")&&!u.has(f)&&!Bt.includes(f)){if(Vt[f])return Vt[f];let p=We(f,[...u,...Bt]);return`A fun\xE7\xE3o \`${f}\` n\xE3o existe (\xE9 nil).`+(p?` Talvez voc\xEA quis escrever \`${p}\`?`:" Confira o nome (mai\xFAsculas contam) e se a fun\xE7\xE3o foi criada ANTES desta linha (em Lua, a fun\xE7\xE3o precisa existir antes de ser chamada).")}if(m&&f.includes("."))return`\`${f}\` n\xE3o \xE9 uma fun\xE7\xE3o (\xE9 nil). Confira o nome (mai\xFAsculas contam: FindFirstChild, GetService...) e se a fun\xE7\xE3o foi criada antes desta linha.`}return"Voc\xEA chamou com () algo que \xE9 nil: a fun\xE7\xE3o n\xE3o existe com esse nome, ou s\xF3 \xE9 criada depois desta linha. Confira o nome (mai\xFAsculas contam)."}if(r=/^attempt to call missing method '([^']+)' of (\w+)$/.exec(i))return r[2]==="string"?`Textos n\xE3o t\xEAm o m\xE9todo ${r[1]}. Alguns que existem: upper, lower, sub, find, gsub, split, rep, len, format.`:`O m\xE9todo ${r[1]} n\xE3o existe nessa tabela. Confira o nome (mai\xFAsculas contam) e se ele foi criado com function Tabela:${r[1]}(...) ou function Tabela.${r[1]}(...).`;if(r=/^attempt to call a (\w+) value$/.exec(i))return`Voc\xEA colocou () depois de algo que \xE9 ${z[r[1]]||r[1]}, n\xE3o uma fun\xE7\xE3o. Confira se uma vari\xE1vel n\xE3o est\xE1 com o mesmo nome de uma fun\xE7\xE3o.`;if(r=/^attempt to perform arithmetic \((\w+)\) on (\w+)(?: and (\w+))?$/.exec(i)){let l=[r[2],r[3]].filter(Boolean);return l.includes("nil")?"Uma conta (+, -, *, /...) recebeu nil. Uma das vari\xE1veis n\xE3o tem valor: confira se ela foi criada, se o nome est\xE1 igual e se a fun\xE7\xE3o devolveu algo com return.":l.includes("string")?"Uma conta recebeu um texto que n\xE3o \xE9 n\xFAmero. Para somar n\xFAmeros que vieram como texto use tonumber(texto); para juntar textos use .. (dois pontos).":l.includes("table")||l.includes("userdata")?"Uma conta recebeu uma tabela (ou um objeto do jogo) em vez de um n\xFAmero. Pegue o n\xFAmero que est\xE1 dentro dele (por exemplo, jogador.leaderstats.Moedas.Value).":l.includes("boolean")?"Uma conta recebeu true/false em vez de um n\xFAmero.":"Uma conta recebeu um valor que n\xE3o \xE9 n\xFAmero."}if(r=/^attempt to concatenate (\w+) with (\w+)$/.exec(i)){let l=[r[1],r[2]].find(u=>u!=="string"&&u!=="number")||r[1];return l==="nil"?"O .. junta textos, mas um dos lados \xE9 nil (uma vari\xE1vel sem valor). Confira se a vari\xE1vel existe e tem valor.":l==="boolean"?'O .. n\xE3o junta true/false direto. Use tostring(valor): "Vivo: " .. tostring(vivo).':l==="table"||l==="userdata"?"O .. n\xE3o junta tabelas nem objetos. Para um objeto do jogo use .Name (parte.Name); para outros valores use tostring(valor).":`O .. s\xF3 junta textos e n\xFAmeros, e um dos lados \xE9 ${z[l]||l}. Use tostring(valor).`}if(r=/^attempt to compare (\w+) ([<>=]+) (\w+)$/.exec(i))return r[1]===r[3]?`N\xE3o d\xE1 para comparar dois valores do tipo ${r[1]} com ${r[2]}. Compare n\xFAmeros (ou textos).`:`Voc\xEA comparou ${z[r[1]]||r[1]} com ${z[r[3]]||r[3]} usando ${r[2]}. Compare valores do mesmo tipo (tonumber(texto) transforma texto em n\xFAmero).`;if(/^attempt to modify a readonly table$/.test(i))return"Esse valor \xE9 s\xF3 de leitura. Vector3, Color3, CFrame e as bibliotecas (math, string...) n\xE3o mudam: crie um valor novo (parte.Position = Vector3.new(...)) em vez de mudar uma parte dele.";if(r=/^attempt to get length of an? (\w+) value$/.exec(i))return`O # (tamanho) s\xF3 funciona em textos e tabelas, mas o valor \xE9 ${z[r[1]]||r[1]}.`;if(r=/^attempt to iterate over an? (\w+) value/.exec(i))return r[1]==="Instance"?"Um objeto do jogo n\xE3o \xE9 uma lista. Para percorrer os filhos use :GetChildren(): for _, filho in pasta:GetChildren() do ... end":`O for ... in precisa de uma tabela (use ipairs(lista) ou pairs(tabela)), mas recebeu ${z[r[1]]||r[1]}.`;if(/^table index is (nil|NaN)$/.test(i))return"Voc\xEA usou nil como chave de uma tabela (tabela[nil] = ...). Confira se a vari\xE1vel usada como chave tem valor.";if(/stack overflow/.test(i)&&!/^C stack overflow/.test(i))return"Uma fun\xE7\xE3o chamou a si mesma sem parar (recurs\xE3o infinita). Falta um caso que pare as chamadas? (Ou um evento que dispara a si mesmo sem parar.)";if(/not enough memory/.test(i))return"Acabou a mem\xF3ria: provavelmente uma tabela ou um texto crescendo sem parar dentro de um la\xE7o.";if(/resulting string too large/.test(i))return"O texto ficou grande demais (string.rep ou .. dentro de um la\xE7o sem fim?).";if(r=/^(.+) is not a valid member of (\w+) "(.*)"$/.exec(i)){let[,l,u,f]=r,m=a&&a.filhos?We(l,a.filhos):null,p=`\`${l}\` n\xE3o existe dentro de ${f||u} (um ${u}). `;return m&&(p+=`Talvez voc\xEA quis escrever \`${m}\`? `),p+=`Confira o nome (mai\xFAsculas contam). Para procurar sem dar erro use :FindFirstChild("${l}") \u2014 que devolve nil quando n\xE3o acha \u2014, e se o objeto ainda vai ser criado use :WaitForChild("${l}").`,p}if(r=/^(.+) is not a valid member of (\w+)$/.exec(i))return`\`${r[1]}\` n\xE3o existe em ${r[2]}. Confira o nome (mai\xFAsculas contam: Position, Magnitude, Name...).`;if(r=/^(\S+) cannot be assigned to$/.exec(i))return`${r[1]} \xE9 s\xF3 de leitura nesse valor. Crie um valor novo em vez de mudar uma parte dele.`;if(r=/^Unable to assign property (\w+)\. (.+) expected, got (\w+)$/.exec(i)){let l=r[2].replace(/^Enum\./,""),u=gs[l]||(r[2].startsWith("Enum.")?`um Enum.${l}.Algo`:null);return`A propriedade ${r[1]} s\xF3 aceita ${r[2]}${u?` (por exemplo ${u})`:""}, mas recebeu ${r[3]}.`}if(r=/^Unable to assign property (\w+)\. Property is read only$/.exec(i))return`A propriedade ${r[1]} s\xF3 pode ser lida: o pr\xF3prio jogo cuida dela.`;if(r=/^invalid argument #(\d+) to '([^']+)' \((.+) expected, got (\w+)\)$/.exec(i))return`A fun\xE7\xE3o ${r[2]} recebeu no argumento ${r[1]} ${z[r[4]]||r[4]}, mas precisava de ${r[3]}.`;if(r=/^missing argument #(\d+)(?: to '([^']+)')?/.exec(i))return`Faltou passar o argumento ${r[1]}${r[2]?` para ${r[2]}`:""}.`;if(r=/^Argument (\d+) missing or nil$/.exec(i))return`Faltou o argumento ${r[1]} (ou ele \xE9 nil).`;if(r=/^wrong number of arguments to '([^']+)'$/.exec(i))return`A fun\xE7\xE3o ${r[1]} recebeu argumentos de menos (ou demais).`;if(r=/^Expected ':' not '\.' calling member function (\w+)$/.exec(i))return`M\xE9todos do Roblox s\xE3o chamados com dois-pontos: objeto:${r[1]}(...) \u2014 e n\xE3o objeto.${r[1]}(...).`;if(/^Attempt to connect failed: Passed value is not a function$/.test(i))return":Connect precisa receber uma fun\xE7\xE3o: evento:Connect(minhaFuncao) \u2014 sem () depois do nome \u2014 ou evento:Connect(function(...) ... end).";if(r=/^invalid 'for' (initial value|limit|step)/.exec(i))return`No for num\xE9rico (for i = in\xEDcio, fim, passo do), ${{"initial value":"o in\xEDcio",limit:"o fim",step:"o passo"}[r[1]]} precisa ser um n\xFAmero.`;if(/^'for' step is zero/.test(i))return"O passo do for n\xE3o pode ser 0 (o la\xE7o nunca terminaria).";if(r=/^Unable to create an Instance of type "(.*)"$/.exec(i)){let l=a&&a.classes?We(r[1],a.classes):null;return`N\xE3o existe a classe "${r[1]}" para Instance.new.`+(l?` Talvez voc\xEA quis escrever "${l}"?`:' Confira o nome (mai\xFAsculas contam): "Part", "Folder", "IntValue", "Model"...')}if(/^The Parent property of .* is locked/.test(i))return"Esse objeto foi destru\xEDdo com :Destroy() e n\xE3o pode mais voltar para o jogo. Para usar de novo, crie (ou clone) outro.";if(/circular reference|as its own parent/.test(i))return"Um objeto n\xE3o pode ficar dentro dele mesmo (nem dentro de um filho dele).";if(/attempt to yield across metamethod\/C-call boundary/.test(i))return"task.wait (ou :Wait()) n\xE3o pode ser usado dentro desse tipo de fun\xE7\xE3o (por exemplo, na fun\xE7\xE3o de compara\xE7\xE3o do table.sort). Mova a espera para fora.";if(/^Requested module was required recursively/.test(i))return"Dois ModuleScripts est\xE3o usando require um no outro (um ciclo). Um deles n\xE3o pode depender do outro.";if(/^Module code did not return exactly one value/.test(i))return"Um ModuleScript precisa terminar com return e um valor s\xF3 (normalmente a tabela do m\xF3dulo: return Modulo).";if(/^Attempted to call require with invalid argument/.test(i))return"require precisa receber um ModuleScript (por exemplo require(game.ReplicatedStorage.MeuModulo)).";if(/DataStore|API Services|\b50[0-9]\b/.test(i))return"O DataStore falhou \u2014 no Roblox isso acontece de verdade de vez em quando. Por isso GetAsync/SetAsync sempre v\xE3o dentro de pcall: local ok, erro = pcall(function() ... end).";if(r=/^'(.*)' is not a valid Service name$/.exec(i)){let l=We(r[1],bs);return"GetService recebe o nome do servi\xE7o em ingl\xEAs, exatamente como aparece no Explorer"+(l?`: talvez voc\xEA quis escrever "${l}"?`:' ("Players", "ReplicatedStorage", "ServerStorage", "RunService", "TweenService"...).')}return(r=/^(FireServer|InvokeServer) can only be called from the client$/.exec(i))?`${r[1]} \xE9 o cliente (LocalScript) falando com o servidor. No servidor, para falar com um jogador use ${r[1]==="FireServer"?"FireClient(jogador, ...)":"InvokeClient(jogador, ...)"}.`:(r=/^(FireClient|FireAllClients|InvokeClient) can only be called from the server$/.exec(i))?`${r[1]} \xE9 o servidor (Script) falando com os jogadores. No cliente (LocalScript), use FireServer(...) para falar com o servidor.`:(r=/can only be (?:used|called|fired|invoked) (?:on|from) the (server|client)/i.exec(i))?r[1]==="server"?"Isso s\xF3 funciona no servidor (num Script). No cliente (LocalScript), pe\xE7a ao servidor com um RemoteEvent.":"Isso s\xF3 funciona no cliente (num LocalScript).":/player argument must be a Player object/.test(i)?"O primeiro argumento de FireClient/InvokeClient \xE9 o jogador (um Player): evento:FireClient(jogador, ...).":/DataStores can only be accessed from the server/.test(i)?"S\xF3 o servidor (Script) pode usar DataStores \u2014 o cliente nunca acessa os dados salvos direto.":/^10[0-9]: /.test(i)?"O DataStore s\xF3 guarda n\xFAmeros, textos, true/false e tabelas simples (listas ou dicion\xE1rios com chaves de texto). Instances, Vector3 e Color3 precisam virar n\xFAmeros ou textos antes de salvar.":/^TweenService:Create no property named/.test(i)?"Uma das propriedades da tabela de objetivos n\xE3o existe nesse objeto. Confira o nome (Position, Size, Transparency, Color...).":/cannot be tweened due to type mismatch/.test(i)?"O valor final do tween precisa ser do mesmo tipo da propriedade (Position \u2192 Vector3, Transparency \u2192 n\xFAmero, Color \u2192 Color3).":(r=/^(\w+) is a callback member of (\w+)/.exec(i))?`${r[1]} n\xE3o \xE9 um evento: \xE9 uma fun\xE7\xE3o que voc\xEA define com =, por exemplo ${r[2]==="RemoteFunction"?"remote":"objeto"}.${r[1]} = function(jogador, ...) ... end.`:/^Attribute names? /.test(i)?"Nomes de atributos s\xF3 podem ter letras sem acento, n\xFAmeros e _ (at\xE9 100 caracteres), sem come\xE7ar com RBX.":/is not a supported attribute type/.test(i)?"Atributos guardam n\xFAmeros, textos, true/false, Vector3, Color3, CFrame e alguns outros \u2014 n\xE3o tabelas nem Instances.":/is not a valid property name\.$/.test(i)?"Esse nome de propriedade n\xE3o existe nesse objeto. Confira o nome (mai\xFAsculas contam).":/^Http requests are not enabled|^Teleport is not supported/.test(i)?"Aqui o jogo roda simulado, sem internet e com um servidor s\xF3: isso n\xE3o funciona no curso.":(r=/^attempt to perform arithmetic on (\w+) and (\w+)$/.exec(i))?`N\xE3o d\xE1 para fazer essa conta entre ${r[1]} e ${r[2]}. Vector3 soma com Vector3 (pos + Vector3.new(0, 5, 0)) e multiplica por n\xFAmero (pos * 2).`:/^invalid order function for sorting/.test(i)?'A fun\xE7\xE3o de compara\xE7\xE3o do table.sort precisa responder "a vem antes de b?" sempre do mesmo jeito: use a < b (ou a > b para a ordem contr\xE1ria) \u2014 nunca <= nem um valor fixo como true.':/cannot change a protected metatable/.test(i)?"Objetos do Roblox (e alguns valores do jogo) n\xE3o deixam trocar a metatabela. Use setmetatable s\xF3 nas suas pr\xF3prias tabelas.":/^C stack overflow/.test(i)?"Uma fun\xE7\xE3o chamou a si mesma sem parar \u2014 por exemplo, um evento Changed que muda a pr\xF3pria propriedade e dispara de novo. Falta uma condi\xE7\xE3o que pare?":/^assertion failed!?$/.test(i)?"Um assert(condi\xE7\xE3o) recebeu uma condi\xE7\xE3o falsa.":/^Infinite yield/.test(i)?"WaitForChild ficou esperando um filho que nunca apareceu. Confira o nome (mai\xFAsculas contam) e se ele \xE9 mesmo criado.":/^Can't parse JSON/.test(i)?"JSONDecode recebeu um texto que n\xE3o \xE9 JSON v\xE1lido.":e&&e.doUsuario?"Esse erro foi lan\xE7ado pelo pr\xF3prio c\xF3digo com error(...). Leia a mensagem: ela diz o que deu errado.":null}function nt(t,e,o={}){t=t||{};let n=String(t.mensagem??""),a=us(t),r=n.replace(new RegExp(`^${J(A)}:\\d+:\\s*`),"");r=r.replace(/^[\w.]+:\d+:\s*/,"");let s=Pe(e,a)||"",i=!!(a&&/\berror\s*\(/.test(s))||!!t.naoTexto,l=_s(r,{...t,doUsuario:i},e,a,o);l||(l=i?"Esse erro foi lan\xE7ado pelo pr\xF3prio c\xF3digo com error(...). Leia a mensagem: ela diz o que deu errado.":"Aconteceu um erro enquanto o script rodava. Leia a mensagem (em ingl\xEAs, como no Output do Roblox Studio) e confira a linha indicada."),t.naoTexto&&!/^table|^\{/.test(r)&&(n=n||"(erro sem mensagem)"),t.acao?l+=` (O erro aconteceu ${t.acao}.)`:t.origem==="evento"&&(l+=" (O erro aconteceu dentro de uma fun\xE7\xE3o ligada a um evento.)");let f=a&&!new RegExp(`^${J(A)}:\\d+:`).test(n)?`${A}:${a}: ${n}`:n,m=fs(ds(t.pilha));return m&&(f+=m),a&&(f=`${zt(e,a)}
${f}`),{tipo:"erro",texto:f,linha:a||null,dica:l}}function rt(t){let e=String(t).replace(/\r\n/g,`
`).split(`
`).map(o=>o.replace(/\s+$/,""));for(;e.length&&e[e.length-1]==="";)e.pop();return e}function $(t,e=120){let o='"'+String(t).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\t/g,"\\t")+'"';return o.length<=e?o:o.slice(0,e-4)+'..."'}var U=t=>t.normalize("NFD").replace(/[̀-ͯ]/g,""),oe=t=>[...t].filter(e=>/[\p{L}\p{N}]/u.test(e)).join("");function at(t,e){if(t.toLowerCase()===e.toLowerCase())return"A diferen\xE7a est\xE1 nas letras mai\xFAsculas/min\xFAsculas.";if(t.replace(/ /g,"")===e.replace(/ /g,""))return"A diferen\xE7a est\xE1 nos espa\xE7os.";if(U(t)===U(e))return"A diferen\xE7a est\xE1 nos acentos.";if(oe(t)&&t.replace(/-/g,"")===e.replace(/-/g,""))return"A diferen\xE7a est\xE1 no sinal de menos (-).";if(oe(t)&&oe(t)===oe(e))return"A diferen\xE7a est\xE1 na pontua\xE7\xE3o ou nos s\xEDmbolos (v\xEDrgulas, pontos, dois-pontos, exclama\xE7\xE3o...).";let o=oe(U(t)).toLowerCase(),n=oe(U(e)).toLowerCase();return o&&o===n?"Est\xE1 quase: confira mai\xFAsculas, acentos e pontua\xE7\xE3o.":null}var $t=/-?\d+(?:\.\d+)?/g;function qt(t,e){let o=U(String(t)),n=o.match($t)||[],a=(o.replace($t," ").match(/\p{L}+/gu)||[]).join("");return{nums:n,letras:e?a:a.toLowerCase()}}function vs(t,e,o){if(Math.abs(t.length-e.length)>o)return o+1;let n=Array.from({length:e.length+1},(a,r)=>r);for(let a=1;a<=t.length;a++){let r=[a],s=a;for(let i=1;i<=e.length;i++)r[i]=Math.min(n[i]+1,r[i-1]+1,n[i-1]+(t[a-1]===e[i-1]?0:1)),r[i]<s&&(s=r[i]);if(s>o)return o+1;n=r}return n[e.length]}function Oe(t,e,o={}){if(o.espacos){let s=U(String(t)),i=U(String(e));return o.caixa?s===i:s.toLowerCase()===i.toLowerCase()}let n=qt(t,o.caixa),a=qt(e,o.caixa);if(n.nums.length!==a.nums.length||n.nums.some((s,i)=>s!==a.nums[i]))return!1;if(n.letras===a.letras)return!0;let r=Math.min(Math.floor(Math.max(n.letras.length,a.letras.length)/8),3);return vs(n.letras,a.letras,r)<=r}function Ht(t,e,o={}){let n=t.filter(r=>r.trim()),a=e.filter(r=>r.trim());return a.length?n.length===a.length&&n.every((r,s)=>Oe(r,a[s],o))?!0:!o.espacos&&Oe(n.join(" "),a.join(" "),o):!1}function Jt(t,e){let o=t.filter(a=>a.trim()),n=e.filter(a=>a.trim());for(let a=0;a<Math.min(o.length,n.length);a++)if(o[a]!==n[a]){let r=at(o[a],n[a]);return`Passou! S\xF3 um detalhe: o esperado era ${$(o[a])} e saiu ${$(n[a])}.${r?" "+r:""}`}return"Passou! S\xF3 um detalhe: as linhas em branco (ou as quebras de linha) ficaram um pouco diferentes do esperado."}var Gt=(t,e)=>{let n=U(String(t)).match(/-?\d+(?:\.\d+)?|\p{L}+/gu)||[];return" "+(e?n:n.map(a=>a.toLowerCase())).join(" ")+" "};function Xt(t,e,o={}){let n=Gt(e,o.caixa);return n.trim()!==""&&Gt(t,o.caixa).includes(n)}function Yt(t){let e=/^[A-Za-z_À-ÿ][\wÀ-ÿ]*/.exec(t);if(!e||!/^[a-zà-ÿ]/.test(t))return t;let o=t.slice(e[0].length,e[0].length+1);return e[0].includes("_")||"(.[_:".includes(o)&&o?t:t[0].toUpperCase()+t.slice(1)}var ws=["saida","contem","nao_contem","ultima_linha","codigo"],ys=["usa","nao_usa","regex","nao_regex","conta","comentario","comentarios","codigo_regex","recursiva"],uc=new Set([...ws,...ys,"cpp","entradas","eof","semente","msg","min","max"]);var Qt=["base","tipos","agenda","instancias","classes","servicos","mundo","ajudantes"],Cs="0.739",xs=5,Ss=8,Ts=96*1024*1024,Zt={optimizationLevel:1,debugLevel:1},Kt=Object.getOwnPropertySymbols(Ee.prototype).find(t=>t.description==="Lua.release");function Ie(t){try{Kt&&t&&t[Kt]()}catch{}}var ne=t=>String(t||"").replace(/^(syntax|runtime) error:\s*/,""),me=t=>t?t+": ":"";function As(t,e,o="",n=null){let a=Array.isArray(e)?e.map(String):rt(e),r=rt(t);if(a.length===r.length&&a.every((m,p)=>m===r[p]))return null;if(n&&Ht(a,r,n))return{quase:!0,msg:Jt(a,r)};let s=a.join(`
`),i=r.join(`
`),l=m=>({msg:Yt(m),esperado:s,recebido:i});if(!r.length)return l(`${me(o)}seu script n\xE3o mostrou nada no Output. Faltou um print()?`);if(!a.length){let m=r.length>1?` (e mais ${r.length-1} linha${r.length>2?"s":""})`:"";return l(`${me(o)}nada deveria aparecer no Output, mas apareceu ${$(r[0])}${m}.`)}let u=n?a.filter(m=>m.trim()):a,f=r.map((m,p)=>[m,p]).filter(([m])=>!n||m.trim());for(let m=0;m<Math.min(u.length,f.length);m++){let p=u[m],[g,v]=f[m];if(p!==g&&!(n&&Oe(p,g,n))){let w=`${me(o)}a linha ${v+1} da sa\xEDda est\xE1 diferente.
esperado: ${$(p)}
recebido: ${$(g)}`,C=at(p,g);return C&&(w+=`
`+C),l(w)}}if(f.length<u.length){let m=u.length-f.length;return l(`${me(o)}faltou ${m===1?"uma linha":`${m} linhas`} na sa\xEDda. A pr\xF3xima esperada era: ${$(u[f.length])}`)}return l(`${me(o)}sua sa\xEDda tem linhas a mais. A primeira que sobrou foi: ${$(f[u.length][0])}`)}function Es(t){return String(t??"").replace(/\r\n?/g,`
`).replace(/^/,"")}function Rs(t,e,o){let n=to(t);switch(e){case"palavra":return n.palavras[o]||0;case"operador":return n.operadores[o]||0;case"interpolacao":return n.interpolacoes;case"chamada":{if(/[.:]/.test(o)){let r=o.replace(/:/g,".");return n.chamadas.filter(s=>s.caminho.replace(/:/g,".")===r||s.caminho.replace(/:/g,".").endsWith("."+r)).length}return n.chamadas.filter(r=>r.nome===o).length}case"funcao":return n.funcoes.some(a=>a.nome===o||a.nome.endsWith("."+o)||a.nome.endsWith(":"+o))?1:0;case"recursiva":{let a=n.funcoes.find(r=>r.nome===o||r.nome.endsWith("."+o)||r.nome.endsWith(":"+o));return a?a.recursiva?1:0:-1}default:return 0}}function to(t){return t._estrutura||(t._estrutura=jt(t.codigo)),t._estrutura}function ks(t,e){let o=()=>to(t);switch(e){case"globais":return JSON.stringify(o().globais);case"limpo":return o().limpo;case"codigo":return t.codigo;case"comentarios":return JSON.stringify(o().comentarios);case"nomesTopo":return JSON.stringify(t.nomesTopo||[]);default:return""}}function eo(t){return typeof t=="string"?{mundo:t,roteiro:""}:t&&typeof t=="object"?{mundo:String(t.mundo||t.antes||""),roteiro:String(t.roteiro||t.depois||"")}:{mundo:"",roteiro:""}}var Me=class t{constructor({fontes:e}){this.fontes=e,this.bytecodes=null,this.lua0=null,this.cache={codigo:null,an:null}}async iniciar(){if(this.bytecodes)return this;this.lua0=await Ee.create({sandbox:!0});let e=[];for(let n of Qt){let a=this.fontes[n];if(typeof a!="string")throw new Error(`prel\xFAdio: falta o peda\xE7o ${n}.luau`);try{e.push(this.lua0.compile(a,Zt))}catch(r){let s=ne(r&&r.message);try{this.lua0.load(a,{name:`=${n}.luau`})}catch(i){s=ne(i.message)}throw new Error(`prel\xFAdio ${n}.luau n\xE3o compila: ${s}`)}}this.bytecodes=e;let{lua:o}=await this._novoEstado(null);return Ie(o),this}info(){return{motor:"Luau",versao:Cs,linguagem:"lua",arquivo:A}}analisar(e){if(e=Es(e),this.cache.codigo===e)return this.cache.an;let o={codigo:e,erro:null,bytecode:null,nomesTopo:[],_estrutura:null,instrumentado:!1};try{this.lua0.load(e,{name:"="+A})}catch(n){o.erro=Ut(e,n&&n.message)}if(!o.erro){let n=e;try{let a=Lt(e);o.nomesTopo=a.nomesTopo,this.lua0.load(a.fonte,{name:"="+A}),n=a.fonte,o.instrumentado=!0}catch(a){console.warn("[motor lua] a instrumenta\xE7\xE3o falhou; rodando sem ela:",a&&a.message),o.nomesTopo=[]}o.bytecode=this.lua0.compile(n,Zt)}return this.cache={codigo:e,an:o},o}async _novoEstado(e){let o=await Ee.create({sandbox:!0,memory:{limitBytes:Ts}});try{let n=o.createTable(),a=o.createTable(),r=(s,i)=>a.set(s,o.createFunction(i));return r("carregar",(s,i,l)=>{try{return o.load(String(s??""),{name:"="+String(i||"codigo.lua"),environment:l})}catch(u){return ie.multiple(null,ne(u&&u.message))}}),r("carregarAluno",s=>{if(!e||!e.bytecode)return ie.multiple(null,"nenhum c\xF3digo do aluno");try{return o.loadBytecode(e.bytecode,{name:"="+A,environment:s})}catch(i){return ie.multiple(null,ne(i&&i.message))}}),r("formatarErro",s=>{let i={};try{i=JSON.parse(String(s))}catch{i={mensagem:String(s)}}return JSON.stringify(nt(i,e?e.codigo:"",{}))}),r("estrutura",(s,i)=>e?Rs(e,String(s),String(i??"")):0),r("consulta",s=>e?ks(e,String(s)):""),r("compararSaida",(s,i,l,u)=>{let f=JSON.parse(String(i)),m=JSON.parse(String(u))||null;typeof f!="string"&&!Array.isArray(f)&&(f=String(f??""));let p=As(String(s??""),f,String(l??""),m);return p?JSON.stringify(p):""}),r("contemParecido",(s,i,l)=>Xt(String(s??""),String(i??""),JSON.parse(String(l))||{})),Qt.forEach((s,i)=>{o.loadBytecode(this.bytecodes[i],{name:`=${s}.luau`}).call(n,a),s==="tipos"&&o.setTypeMetatable("vector",n.get("V3MT"))}),{lua:o,C:n}}catch(n){throw Ie(o),n}}static erroInterno(e){let o=ne(e&&e.message||e);return/not enough memory|out of memory|memory limit/i.test(o)?{tipo:"erro",texto:"not enough memory",linha:null,dica:"Acabou a mem\xF3ria: provavelmente uma tabela ou um texto crescendo sem parar dentro de um la\xE7o."}:/stack|recursion/i.test(o)?{tipo:"erro",texto:"stack overflow",linha:null,dica:"Uma fun\xE7\xE3o chamou a si mesma vezes demais (recurs\xE3o infinita?). Falta um caso que pare as chamadas?"}:{tipo:"erro",texto:`O motor do Luau teve um problema interno (${o.slice(0,200)}).`,linha:null,dica:"Tente de novo. Se continuar, simplifique o c\xF3digo perto da \xFAltima mudan\xE7a."}}async executar(e={}){await this.iniciar();let o=this.analisar(e.code);if(o.erro)return{saida:"",fim:"erro",erro:o.erro,linha:o.erro.linha};let n=Number(e.tempo)>0?Number(e.tempo):xs,a=e.seed!=null&&Number.isFinite(Number(e.seed))?Number(e.seed):Math.floor(Math.random()*2**30),r=eo(e.cena),s;try{s=await this._novoEstado(o)}catch(u){return{saida:"",fim:"erro",erro:t.erroInterno(u)}}let{lua:i,C:l}=s;try{let u={tempo:n,semente:a,mundo:r.mundo,cenario:r.roteiro,tempoVirtual:Number(e.tempoVirtual)>0?Number(e.tempoVirtual):60,mundoVazio:e.mundoVazio===!0},[f]=l.get("controle").get("executar").call(JSON.stringify(u)),m=JSON.parse(String(f)),p={saida:m.saida||"",fim:m.fim||"ok",tempoVirtual:m.tempoVirtual||0};return m.cena&&(p.cena=m.cena),m.cortado&&p.fim==="ok"&&(p.cortado=!0),m.fim==="tempo"&&(p.linha=m.linha||null),m.fim==="erro"&&(m.erro?p.erro=nt(m.erro,o.codigo,{}):m.erroMundo?p.erro={tipo:"erro",texto:`O mundo desta aula deu erro: ${m.erroMundo}`,linha:null,dica:"Isso n\xE3o \xE9 culpa do seu c\xF3digo: avise quem escreveu a aula."}:m.erroCarregar?p.erro={tipo:"erro",texto:String(m.erroCarregar),linha:null,dica:"N\xE3o consegui carregar o seu script."}:p.erro={tipo:"erro",texto:"O script terminou com erro.",linha:null,dica:""},p.linha=p.erro.linha),p}catch(u){return{saida:"",fim:"erro",erro:t.erroInterno(u)}}finally{Ie(i)}}async testar(e={}){await this.iniciar();let o=this.analisar(e.code),n={ok:!1,sintaxe:null,testes:[]};if(o.erro)return n.sintaxe=o.erro,n;let a=Number(e.tempo)>0?Number(e.tempo):Ss,r=Date.now()+a*1e3,s=e.leniente&&typeof e.leniente=="object"?e.leniente:null,i=eo(e.cena),l=!1;for(let m of e.tests||[]){let p=String(m[0]),g=String(m[1]??""),v;l?v={nome:p,ok:!1,msg:"N\xE3o rodou: um teste anterior estourou o tempo."}:(v=await this._umTeste(o,p,g,r,s,i),!v.ok&&v.tempo&&(l=Date.now()>r-50),delete v.tempo),n.testes.push(v)}let u=n.testes.reduce((m,p)=>m+(p.execucoes||0),0),f=!0;for(let m of n.testes)delete m.execucoes,m.estrutura&&(!u&&m.ok?Object.assign(m,{ok:!1,msg:m.estrutura[0]}):m.ok&&(m.dicas=(m.dicas||[]).concat(m.estrutura.map(p=>`Sugest\xE3o da aula: ${p}`))),delete m.estrutura),m.ok||delete m.dicas,f=f&&m.ok;return n.ok=f&&n.testes.length>0,n}async _umTeste(e,o,n,a,r,s){let i=Math.max(.05,(a-Date.now())/1e3),l;try{l=await this._novoEstado(e)}catch(m){let p=t.erroInterno(m);return{nome:o,ok:!1,msg:`Seu c\xF3digo deu erro:
${p.texto}
\u2192 ${p.dica}`}}let{lua:u,C:f}=l;try{let m=f.get("ambienteTeste").call()[0],p;try{p=u.load(n.replace(/^\s*\n/,""),{name:"=teste.lua",environment:m})}catch(b){return{nome:o,ok:!1,msg:`O teste tem um erro de sintaxe (${ne(b.message)}). Avise quem escreveu a aula.`}}let g={tempo:i,leniente:r,mundo:s.mundo},[v]=f.get("controle").get("testar").call(p,JSON.stringify(g)),w=JSON.parse(String(v)),C={nome:o,ok:!!w.ok,execucoes:w.execucoes||0};return w.ok?(w.dicas&&w.dicas.length&&(C.dicas=w.dicas),w.estrutura&&w.estrutura.length&&(C.estrutura=w.estrutura)):(C.msg=w.msg||"O teste falhou.",w.esperado!=null&&(C.esperado=String(w.esperado)),w.recebido!=null&&(C.recebido=String(w.recebido)),w.tempo&&(C.tempo=!0)),C}catch(m){let p=t.erroInterno(m);return{nome:o,ok:!1,msg:`Seu c\xF3digo deu erro:
${p.texto}
\u2192 ${p.dica}`}}finally{Ie(u)}}};var oo=`--!nolint
-- Cobra Code \u2014 ambiente Luau (1/8): utilidades, formata\xE7\xE3o do print, JSON e o registro de tipos do Roblox.
-- Cada arquivo de web/lua/luau/ \xE9 um peda\xE7o do "prel\xFAdio" que o motor roda num estado Luau novo antes do c\xF3digo do
-- aluno. Todos recebem C (a tabela compartilhada entre os peda\xE7os) e host (fun\xE7\xF5es do JavaScript).
local C, host = ...
C.host = host
-- fun\xE7\xF5es originais (antes de qualquer troca): o rel\xF3gio REAL serve s\xF3 para o limite de tempo
C.real = {
clock = os.clock,
type = type,
typeof = typeof,
tostring = tostring,
pairs = pairs,
ipairs = ipairs,
random = math.random,
randomseed = math.randomseed,
resume = coroutine.resume,
status = coroutine.status,
running = coroutine.running,
yield = coroutine.yield,
create = coroutine.create,
traceback = debug.traceback,
}
C.prazo = math.huge -- os.clock() real a partir do qual o c\xF3digo \xE9 interrompido (o JavaScript define)
-- marcadores (erros especiais que atravessam o c\xF3digo do aluno)
C.MARCA_TEMPO = setmetatable({}, { __tostring = function() return "o c\xF3digo demorou demais e foi interrompido" end })
C.MARCA_LIMITE = setmetatable({}, { __tostring = function() return "o c\xF3digo mostrou texto demais" end })
C.MARCA_PARAR = setmetatable({}, { __tostring = function() return "a simula\xE7\xE3o parou" end })
function C.eMarca(v)
return v == C.MARCA_TEMPO or v == C.MARCA_LIMITE or v == C.MARCA_PARAR
end
-- ============================================================================================
-- Registro de tipos do Roblox: tabela fraca objeto \u2192 nome do tipo ("Instance", "Color3", "EnumItem"...)
-- ============================================================================================
C.TIPO = setmetatable({}, { __mode = "k" })
function C.typeof(v)
local t = C.real.type(v)
if t == "table" then
local n = C.TIPO[v]
if n then return n end
return "table"
end
if t == "vector" then return "Vector3" end
if t == "userdata" then return "userdata" end
return t
end
-- type() como no Roblox: objetos do Roblox s\xE3o "userdata" (o Vector3 \xE9 "vector")
function C.type(v)
local t = C.real.type(v)
if t == "table" and C.TIPO[v] then return "userdata" end
return t
end
-- ============================================================================================
-- N\xFAmeros
-- ============================================================================================
local function numeroTexto(x: number): string
local s = C.real.tostring(x)
if s == "-nan" or s == "nan" or s == "-nan(ind)" or s == "nan(ind)" then return "nan" end
return s
end
C.numeroTexto = numeroTexto
-- n\xFAmero de 32 bits (Vector3 e CFrame do Roblox): o texto mais curto que volta ao mesmo float
local function f32(x: number): number
return vector.create(x, 0, 0).x
end
C.f32 = f32
local function numero32(x: number): string
if x ~= x then return "nan" end
if x == math.huge then return "inf" end
if x == -math.huge then return "-inf" end
if x == 0 then return "0" end
if x == math.floor(x) and math.abs(x) < 1e15 then return string.format("%d", x) end
for p = 1, 9 do
local s = string.format("%." .. p .. "g", x)
if f32(tonumber(s) :: number) == x then return s end
end
return string.format("%.9g", x)
end
C.numero32 = numero32
-- Color3: como no Roblox, at\xE9 6 algarismos significativos
local function numero6(x: number): string
if x ~= x then return "nan" end
if x == math.floor(x) and math.abs(x) < 1e15 then return string.format("%d", x) end
local s = string.format("%.6g", x)
return s
end
C.numero6 = numero6
-- ============================================================================================
-- Texto de um valor (print, mensagens dos testes)
-- ============================================================================================
local IDENT = "^[%a_][%w_]*$"
local PALAVRAS = {}
for _, p in { "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "if", "in", "local", "nil", "not",
"or", "repeat", "return", "then", "true", "until", "while", "continue" } do
PALAVRAS[p] = true
end
local function aspas(s: string): string
s = string.gsub(s, "\\\\", "\\\\\\\\")
s = string.gsub(s, '"', '\\\\"')
s = string.gsub(s, "\\n", "\\\\n")
s = string.gsub(s, "\\t", "\\\\t")
s = string.gsub(s, "\\r", "\\\\r")
return '"' .. s .. '"'
end
C.aspas = aspas
local enderecos = setmetatable({}, { __mode = "k" })
local proximoEndereco = 0
function C.endereco(v): string
local e = enderecos[v]
if not e then
proximoEndereco += 1
e = string.format("0x%016x", 0x5a5a0000 + proximoEndereco * 16)
enderecos[v] = e
end
return e
end
-- texto "de m\xE1quina" de valores do Roblox (Vector3, Color3, Instance...), ou nil
function C.textoRoblox(v): string?
local t = C.real.type(v)
if t == "vector" then
return numero32(v.x) .. ", " .. numero32(v.y) .. ", " .. numero32(v.z)
end
if t == "table" and C.TIPO[v] then
local ok, s = pcall(C.real.tostring, v)
if ok then return s end
return C.TIPO[v]
end
return nil
end
local function chaveOrdem(a, b)
local ta, tb = C.real.type(a), C.real.type(b)
if ta ~= tb then
if ta == "number" then return true end
if tb == "number" then return false end
if ta == "string" then return true end
if tb == "string" then return false end
return ta < tb
end
if ta == "number" or ta == "string" then return a < b end
return C.real.tostring(a) < C.real.tostring(b)
end
-- opcoes: {aspas = true (textos com aspas), largura = 80 (quebra em v\xE1rias linhas acima disso), profundidade = 4}
local mostrar
local function mostrarTabela(t, prof: number, vistos, indent: string, opcoes)
if vistos[t] then return "{...}" end
if prof > (opcoes.profundidade or 4) then return "{...}" end
local mt = getmetatable(t)
if mt ~= nil and C.real.type(mt) == "table" and rawget(mt, "__tostring") then
local ok, s = pcall(C.real.tostring, t)
if ok then return s end
end
vistos[t] = true
local n = 0
while rawget(t, n + 1) ~= nil do n += 1 end
local partes = {}
for i = 1, n do
table.insert(partes, mostrar(rawget(t, i), prof + 1, vistos, indent .. " ", opcoes))
end
local resto = {}
for k in C.real.pairs(t) do
if not (C.real.type(k) == "number" and k >= 1 and k <= n and k == math.floor(k)) then table.insert(resto, k) end
end
table.sort(resto, chaveOrdem)
for _, k in resto do
local kt
if C.real.type(k) == "string" and string.match(k, IDENT) and not PALAVRAS[k] then
kt = k
else
kt = "[" .. mostrar(k, prof + 1, vistos, indent .. " ", { aspas = true, profundidade = 1 }) .. "]"
end
table.insert(partes, kt .. " = " .. mostrar(rawget(t, k), prof + 1, vistos, indent .. " ", opcoes))
end
vistos[t] = nil
if #partes == 0 then return "{}" end
local linha = "{" .. table.concat(partes, ", ") .. "}"
if #linha + #indent <= (opcoes.largura or 80) and not string.find(linha, "\\n", 1, true) then return linha end
return "{\\n" .. indent .. " " .. table.concat(partes, ",\\n" .. indent .. " ") .. "\\n" .. indent .. "}"
end
mostrar = function(v, prof: number?, vistos, indent: string?, opcoes)
opcoes = opcoes or { aspas = true }
local t = C.real.type(v)
if t == "string" then
if opcoes.aspas then return aspas(v) end
return v
end
if t == "number" then return numeroTexto(v) end
if t == "nil" or t == "boolean" then return C.real.tostring(v) end
local r = C.textoRoblox(v)
if r then
-- dentro de uma tabela, os tipos "de n\xFAmeros" levam o nome ({Vector3(1, 2, 3)} e n\xE3o {1, 2, 3})
if (prof or 1) > 1 then
local tp = C.typeof(v)
if tp == "Vector3" or tp == "Vector2" or tp == "Color3" or tp == "CFrame" or tp == "UDim" or tp == "UDim2" then
return tp .. "(" .. r .. ")"
end
end
return r
end
if t == "table" then return mostrarTabela(v, prof or 1, vistos or {}, indent or "", opcoes) end
if t == "function" then
local nome = debug.info(v, "n")
return "function: " .. C.endereco(v)
end
if t == "thread" then return "thread: " .. C.endereco(v) end
return C.real.tostring(v)
end
-- valor como o print mostra: textos sem aspas no n\xEDvel de cima; dentro de tabelas, com aspas
function C.textoPrint(v): string
if C.real.type(v) == "string" then return v end
return mostrar(v, 1, {}, "", { aspas = true })
end
-- valor para mensagens dos testes (textos sempre com aspas)
function C.mostrar(v, largura: number?): string
return mostrar(v, 1, {}, "", { aspas = true, largura = largura or 80 })
end
-- tostring como no Roblox: Instance \u2192 Name, Vector3 \u2192 "1, 2, 3", tabela \u2192 "table: 0x..."
function C.tostring(v): string
local t = C.real.type(v)
if t == "number" then return numeroTexto(v) end
if t == "vector" then return C.textoRoblox(v) :: string end
if t == "table" then
local mt = getmetatable(v)
if C.TIPO[v] or (mt ~= nil and C.real.type(mt) == "table" and rawget(mt, "__tostring")) then
return C.real.tostring(v)
end
if C.real.type(mt) == "string" then return C.real.tostring(v) end
return "table: " .. C.endereco(v)
end
if t == "function" then return "function: " .. C.endereco(v) end
if t == "thread" then return "thread: " .. C.endereco(v) end
return C.real.tostring(v)
end
-- ============================================================================================
-- Tabelas
-- ============================================================================================
-- congela uma tabela da API (somente leitura, como as do Roblox)
function C.congelar(t)
if not table.isfrozen(t) then table.freeze(t) end
return t
end
function C.copiaProfunda(v, vistos)
if C.real.type(v) ~= "table" or C.TIPO[v] then return v end
vistos = vistos or {}
if vistos[v] then return vistos[v] end
local r = {}
vistos[v] = r
for k, x in C.real.pairs(v) do
r[C.copiaProfunda(k, vistos)] = C.copiaProfunda(x, vistos)
end
return r
end
-- ============================================================================================
-- JSON (HttpService:JSONEncode/JSONDecode e a cena para a interface)
-- ============================================================================================
local json = {}
C.json = json
local function jsonTexto(s: string): string
s = string.gsub(s, '[%c"\\\\]', function(ch)
if ch == '"' then return '\\\\"' end
if ch == "\\\\" then return "\\\\\\\\" end
if ch == "\\n" then return "\\\\n" end
if ch == "\\r" then return "\\\\r" end
if ch == "\\t" then return "\\\\t" end
return string.format("\\\\u%04x", string.byte(ch))
end)
return '"' .. s .. '"'
end
local function jsonValor(v, partes, vistos, estrito: boolean)
local t = C.real.type(v)
if v == nil then
table.insert(partes, "null")
elseif t == "boolean" then
table.insert(partes, if v then "true" else "false")
elseif t == "number" then
if v ~= v or v == math.huge or v == -math.huge then
table.insert(partes, "null")
elseif v == math.floor(v) and math.abs(v) < 1e15 then
table.insert(partes, string.format("%d", v))
else
table.insert(partes, string.format("%.17g", v))
end
elseif t == "string" then
table.insert(partes, jsonTexto(v))
elseif t == "table" and not C.TIPO[v] then
if vistos[v] then error("Cannot convert circular table to JSON", 0) end
vistos[v] = true
local n = #v
local temOutras = false
for k in C.real.pairs(v) do
if not (C.real.type(k) == "number" and k >= 1 and k <= n and k == math.floor(k)) then temOutras = true break end
end
if n > 0 and not temOutras then
table.insert(partes, "[")
for i = 1, n do
if i > 1 then table.insert(partes, ",") end
jsonValor(v[i], partes, vistos, estrito)
end
table.insert(partes, "]")
elseif n == 0 and not temOutras then
table.insert(partes, "[]")
else
table.insert(partes, "{")
local chaves = {}
for k in C.real.pairs(v) do table.insert(chaves, k) end
table.sort(chaves, chaveOrdem)
local primeiro = true
for _, k in chaves do
if not primeiro then table.insert(partes, ",") end
primeiro = false
table.insert(partes, jsonTexto(C.real.tostring(k)))
table.insert(partes, ":")
jsonValor(v[k], partes, vistos, estrito)
end
table.insert(partes, "}")
end
vistos[v] = nil
else
if estrito then error("Can't convert to JSON", 0) end
table.insert(partes, jsonTexto(C.textoPrint(v)))
end
end
function json.encode(v, estrito: boolean?): string
local partes = {}
jsonValor(v, partes, {}, estrito == true)
return table.concat(partes)
end
function json.decode(s: string)
if C.real.type(s) ~= "string" then error("Can't parse JSON", 0) end
local i = 1
local n = #s
local valor
local function espacos()
i = string.find(s, "[^ \\t\\r\\n]", i) or n + 1
end
local function falha()
error("Can't parse JSON", 0)
end
local function texto()
local partes = {}
i += 1
while true do
local c = string.sub(s, i, i)
if c == "" then falha() end
if c == '"' then i += 1 break end
if c == "\\\\" then
local e = string.sub(s, i + 1, i + 1)
local mapa = { n = "\\n", t = "\\t", r = "\\r", b = "\\b", f = "\\f", ['"'] = '"', ["\\\\"] = "\\\\", ["/"] = "/" }
if mapa[e] then
table.insert(partes, mapa[e])
i += 2
elseif e == "u" then
local hex = string.sub(s, i + 2, i + 5)
local cp = tonumber(hex, 16)
if not cp then falha() end
table.insert(partes, utf8.char(cp :: number))
i += 6
else
falha()
end
else
table.insert(partes, c)
i += 1
end
end
return table.concat(partes)
end
valor = function()
espacos()
local c = string.sub(s, i, i)
if c == "{" then
local r = {}
i += 1
espacos()
if string.sub(s, i, i) == "}" then i += 1 return r end
while true do
espacos()
if string.sub(s, i, i) ~= '"' then falha() end
local k = texto()
espacos()
if string.sub(s, i, i) ~= ":" then falha() end
i += 1
r[k] = valor()
espacos()
local d = string.sub(s, i, i)
i += 1
if d == "}" then break end
if d ~= "," then falha() end
end
return r
elseif c == "[" then
local r = {}
i += 1
espacos()
if string.sub(s, i, i) == "]" then i += 1 return r end
while true do
table.insert(r, valor())
espacos()
local d = string.sub(s, i, i)
i += 1
if d == "]" then break end
if d ~= "," then falha() end
end
return r
elseif c == '"' then
return texto()
elseif string.sub(s, i, i + 3) == "true" then
i += 4
return true
elseif string.sub(s, i, i + 4) == "false" then
i += 5
return false
elseif string.sub(s, i, i + 3) == "null" then
i += 4
return nil
else
local num = string.match(s, "^-?%d+%.?%d*[eE]?[-+]?%d*", i)
if not num or num == "" or num == "-" then falha() end
i += #(num :: string)
return tonumber(num)
end
end
local r = valor()
espacos()
if i <= n then falha() end
return r
end
-- ============================================================================================
-- Erros dos objetos do Roblox: sem posi\xE7\xE3o (como os erros do motor do Roblox); o motor acha a linha pela pilha
-- ============================================================================================
function C.erro(msg: string)
error(msg, 0)
end
-- nome do tipo de um valor para mensagens ("number", "Vector3", "Instance"...)
function C.nomeTipo(v): string
return C.typeof(v)
end
`;var no=`--!nolint
-- Cobra Code \u2014 ambiente Luau (2/8): os tipos de dados do Roblox \u2014 Vector3 (o vetor nativo do Luau, como no Roblox),
-- Vector2, Color3, BrickColor, CFrame, UDim, UDim2, TweenInfo, NumberRange, Enum, Random, RaycastParams...
local C, host = ...
local TIPO = C.TIPO
local erro = C.erro
local numero32 = C.numero32
local numero6 = C.numero6
local rtype = C.real.type
local function registrar(obj, nome: string)
TIPO[obj] = nome
return obj
end
C.registrarTipo = registrar
-- confere um argumento num\xE9rico de um construtor ("invalid argument #1 to 'new' (number expected, got string)")
local function num(v, i: number, funcao: string, padrao: number?): number
if v == nil and padrao ~= nil then return padrao end
local t = rtype(v)
if t == "number" then return v end
if t == "string" and tonumber(v) then return tonumber(v) :: number end
erro(string.format("invalid argument #%d to '%s' (number expected, got %s)", i, funcao, C.typeof(v)))
return 0
end
C.argNumero = num
-- tipo de dado imut\xE1vel: os campos ficam na pr\xF3pria tabela (congelada); m\xE9todos e campos calculados no __index
local function novoTipo(nome: string, metodos, calculados, extras)
local mt = {}
mt.__index = function(self, k)
local f = calculados and calculados[k]
if f then return f(self) end
local m = metodos[k]
if m ~= nil then return m end
erro(C.real.tostring(k) .. " is not a valid member of " .. nome)
end
mt.__newindex = function(self, k)
erro(C.real.tostring(k) .. " cannot be assigned to")
end
-- sem __metatable: o Luau n\xE3o congela (table.freeze) tabelas com metatabela protegida, e congelar \xE9 o que deixa
-- estes valores imut\xE1veis de verdade (cor.R = 1 d\xE1 erro, como no Roblox)
mt.__iter = function()
erro("attempt to iterate over a " .. nome .. " value")
end
if extras then
for k, v in extras do mt[k] = v end
end
return mt
end
local function criar(mt, nome: string, campos)
local obj = setmetatable(campos, mt)
TIPO[obj] = nome
table.freeze(obj)
return obj
end
-- ============================================================================================
-- Vector3: o vetor nativo do Luau (32 bits, imut\xE1vel, == por valor), com X/Y/Z, Magnitude, Unit e m\xE9todos
-- ============================================================================================
local V3 = {}
local vcreate = vector.create
local function v3(x: number, y: number, z: number)
return vcreate(x, y, z)
end
C.v3 = v3
local function eV3(v): boolean
return rtype(v) == "vector"
end
C.eV3 = eV3
local function argV3(v, i: number, funcao: string)
if rtype(v) ~= "vector" then
erro(string.format("invalid argument #%d to '%s' (Vector3 expected, got %s)", i, funcao, C.typeof(v)))
end
return v
end
local function magnitude(v): number
return math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
end
C.magnitude = magnitude
local V3METODOS = {}
function V3METODOS.Dot(a, b)
argV3(a, 1, "Dot")
argV3(b, 1, "Dot")
return a.x * b.x + a.y * b.y + a.z * b.z
end
function V3METODOS.Cross(a, b)
argV3(b, 1, "Cross")
return v3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x)
end
function V3METODOS.Lerp(a, b, t)
argV3(b, 1, "Lerp")
t = num(t, 2, "Lerp")
return a + (b - a) * t
end
function V3METODOS.FuzzyEq(a, b, eps)
argV3(b, 1, "FuzzyEq")
eps = eps or 1e-5
return math.abs(a.x - b.x) <= eps and math.abs(a.y - b.y) <= eps and math.abs(a.z - b.z) <= eps
end
function V3METODOS.Abs(a) return v3(math.abs(a.x), math.abs(a.y), math.abs(a.z)) end
function V3METODOS.Ceil(a) return v3(math.ceil(a.x), math.ceil(a.y), math.ceil(a.z)) end
function V3METODOS.Floor(a) return v3(math.floor(a.x), math.floor(a.y), math.floor(a.z)) end
function V3METODOS.Sign(a) return v3(math.sign(a.x), math.sign(a.y), math.sign(a.z)) end
function V3METODOS.Min(a, ...)
local r = a
for _, b in { ... } do r = v3(math.min(r.x, b.x), math.min(r.y, b.y), math.min(r.z, b.z)) end
return r
end
function V3METODOS.Max(a, ...)
local r = a
for _, b in { ... } do r = v3(math.max(r.x, b.x), math.max(r.y, b.y), math.max(r.z, b.z)) end
return r
end
function V3METODOS.Angle(a, b)
argV3(b, 1, "Angle")
local d = magnitude(a) * magnitude(b)
if d == 0 then return 0 end
return math.acos(math.clamp(V3METODOS.Dot(a, b) / d, -1, 1))
end
C.V3MT = {
__index = function(v, k)
if k == "Magnitude" then return magnitude(v) end
if k == "Unit" then
local m = magnitude(v)
return v3(v.x / m, v.y / m, v.z / m)
end
local m = V3METODOS[k]
if m then return m end
erro(C.real.tostring(k) .. " is not a valid member of Vector3")
end,
__newindex = function(v, k)
erro(C.real.tostring(k) .. " cannot be assigned to")
end,
__tostring = function(v)
return numero32(v.x) .. ", " .. numero32(v.y) .. ", " .. numero32(v.z)
end,
__iter = function()
erro("attempt to iterate over a Vector3 value")
end,
}
function V3.new(x, y, z)
return v3(num(x, 1, "new", 0), num(y, 2, "new", 0), num(z, 3, "new", 0))
end
V3.zero = v3(0, 0, 0)
V3.one = v3(1, 1, 1)
V3.xAxis = v3(1, 0, 0)
V3.yAxis = v3(0, 1, 0)
V3.zAxis = v3(0, 0, 1)
function V3.FromNormalId(id)
local n = id and id.Name
local m = { Right = v3(1, 0, 0), Left = v3(-1, 0, 0), Top = v3(0, 1, 0), Bottom = v3(0, -1, 0), Back = v3(0, 0, 1), Front = v3(0, 0, -1) }
return m[n] or V3.zero
end
function V3.FromAxis(eixo)
local n = eixo and eixo.Name
return if n == "X" then V3.xAxis elseif n == "Y" then V3.yAxis else V3.zAxis
end
C.Vector3 = table.freeze(V3)
-- ============================================================================================
-- Vector2
-- ============================================================================================
local V2 = {}
local V2MT
local function v2(x: number, y: number)
return criar(V2MT, "Vector2", { X = x, Y = y })
end
local V2METODOS = {
Dot = function(a, b) return a.X * b.X + a.Y * b.Y end,
Cross = function(a, b) return a.X * b.Y - a.Y * b.X end,
Lerp = function(a, b, t) return v2(a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t) end,
Abs = function(a) return v2(math.abs(a.X), math.abs(a.Y)) end,
Floor = function(a) return v2(math.floor(a.X), math.floor(a.Y)) end,
Ceil = function(a) return v2(math.ceil(a.X), math.ceil(a.Y)) end,
FuzzyEq = function(a, b, eps) eps = eps or 1e-5 return math.abs(a.X - b.X) <= eps and math.abs(a.Y - b.Y) <= eps end,
}
local function opV2(f)
return function(a, b)
local ta, tb = C.typeof(a), C.typeof(b)
if ta == "Vector2" and tb == "Vector2" then return v2(f(a.X, b.X), f(a.Y, b.Y)) end
if ta == "Vector2" and tb == "number" then return v2(f(a.X, b), f(a.Y, b)) end
if ta == "number" and tb == "Vector2" then return v2(f(a, b.X), f(a, b.Y)) end
erro("attempt to perform arithmetic on " .. ta .. " and " .. tb)
end
end
V2MT = novoTipo("Vector2", V2METODOS, {
Magnitude = function(a) return math.sqrt(a.X * a.X + a.Y * a.Y) end,
Unit = function(a) local m = math.sqrt(a.X * a.X + a.Y * a.Y) return v2(a.X / m, a.Y / m) end,
x = function(a) return a.X end,
y = function(a) return a.Y end,
}, {
__add = opV2(function(a, b) return a + b end),
__sub = opV2(function(a, b) return a - b end),
__mul = opV2(function(a, b) return a * b end),
__div = opV2(function(a, b) return a / b end),
__unm = function(a) return v2(-a.X, -a.Y) end,
__eq = function(a, b) return a.X == b.X and a.Y == b.Y end,
__tostring = function(a) return numero32(a.X) .. ", " .. numero32(a.Y) end,
})
function V2.new(x, y) return v2(num(x, 1, "new", 0), num(y, 2, "new", 0)) end
V2.zero = v2(0, 0)
V2.one = v2(1, 1)
V2.xAxis = v2(1, 0)
V2.yAxis = v2(0, 1)
C.Vector2 = table.freeze(V2)
-- ============================================================================================
-- Color3 (componentes de 0 a 1)
-- ============================================================================================
local C3 = {}
local C3MT
local function c3(r: number, g: number, b: number)
return criar(C3MT, "Color3", { R = r, G = g, B = b })
end
C.c3 = c3
local function paraHSV(c)
local r, g, b = c.R, c.G, c.B
local mx, mn = math.max(r, g, b), math.min(r, g, b)
local d = mx - mn
local h = 0
if d > 0 then
if mx == r then h = ((g - b) / d) % 6
elseif mx == g then h = (b - r) / d + 2
else h = (r - g) / d + 4 end
h /= 6
end
local s = if mx == 0 then 0 else d / mx
return h, s, mx
end
local function deHSV(h: number, s: number, v: number)
h = (h % 1) * 6
local i = math.floor(h)
local f = h - i
local p, q, t = v * (1 - s), v * (1 - s * f), v * (1 - s * (1 - f))
if i == 0 then return c3(v, t, p) end
if i == 1 then return c3(q, v, p) end
if i == 2 then return c3(p, v, t) end
if i == 3 then return c3(p, q, v) end
if i == 4 then return c3(t, p, v) end
return c3(v, p, q)
end
local function byte(x: number): number
return math.clamp(math.floor(x * 255 + 0.5), 0, 255)
end
C.byteCor = byte
C3MT = novoTipo("Color3", {
Lerp = function(a, b, t)
if C.typeof(b) ~= "Color3" then erro("invalid argument #1 to 'Lerp' (Color3 expected, got " .. C.typeof(b) .. ")") end
return c3(a.R + (b.R - a.R) * t, a.G + (b.G - a.G) * t, a.B + (b.B - a.B) * t)
end,
ToHSV = function(a) return paraHSV(a) end,
ToHex = function(a) return string.format("%02X%02X%02X", byte(a.R), byte(a.G), byte(a.B)) end,
}, {
r = function(a) return a.R end,
g = function(a) return a.G end,
b = function(a) return a.B end,
}, {
__eq = function(a, b) return a.R == b.R and a.G == b.G and a.B == b.B end,
__tostring = function(a) return numero6(a.R) .. ", " .. numero6(a.G) .. ", " .. numero6(a.B) end,
})
function C3.new(r, g, b) return c3(num(r, 1, "new", 0), num(g, 2, "new", 0), num(b, 3, "new", 0)) end
function C3.fromRGB(r, g, b)
return c3(num(r, 1, "fromRGB", 0) / 255, num(g, 2, "fromRGB", 0) / 255, num(b, 3, "fromRGB", 0) / 255)
end
function C3.fromHSV(h, s, v) return deHSV(num(h, 1, "fromHSV"), num(s, 2, "fromHSV"), num(v, 3, "fromHSV")) end
function C3.toHSV(c) return paraHSV(c) end
function C3.fromHex(hex)
if rtype(hex) ~= "string" then erro("invalid argument #1 to 'fromHex' (string expected, got " .. C.typeof(hex) .. ")") end
local h = string.gsub(hex, "^#", "")
if #h == 3 then h = string.gsub(h, ".", "%0%0") end
if not string.match(h, "^%x%x%x%x%x%x$") then erro("Unable to convert characters to hex value") end
return c3(tonumber(string.sub(h, 1, 2), 16) / 255, tonumber(string.sub(h, 3, 4), 16) / 255, tonumber(string.sub(h, 5, 6), 16) / 255)
end
C.Color3 = table.freeze(C3)
-- ============================================================================================
-- BrickColor (paleta reduzida com os nomes mais usados)
-- ============================================================================================
local PALETA = {
{ 1, "White", 242, 243, 243 }, { 2, "Grey", 161, 165, 162 }, { 3, "Light yellow", 249, 233, 153 },
{ 5, "Brick yellow", 215, 197, 154 }, { 9, "Light reddish violet", 232, 186, 200 }, { 11, "Pastel Blue", 128, 187, 219 },
{ 12, "Light orange brown", 203, 132, 66 }, { 18, "Nougat", 204, 142, 105 }, { 21, "Bright red", 196, 40, 28 },
{ 22, "Med. reddish violet", 196, 112, 160 }, { 23, "Bright blue", 13, 105, 172 }, { 24, "Bright yellow", 245, 205, 48 },
{ 25, "Earth orange", 98, 71, 50 }, { 26, "Black", 27, 42, 53 }, { 27, "Dark grey", 109, 110, 108 },
{ 28, "Dark green", 40, 127, 71 }, { 29, "Medium green", 161, 196, 140 }, { 37, "Bright green", 75, 151, 75 },
{ 38, "Dark orange", 160, 95, 53 }, { 104, "Bright violet", 107, 50, 124 }, { 105, "Br. yellowish orange", 226, 155, 64 },
{ 106, "Bright orange", 218, 133, 65 }, { 107, "Bright bluish green", 0, 143, 156 }, { 119, "Br. yellowish green", 164, 189, 71 },
{ 192, "Reddish brown", 105, 64, 40 }, { 194, "Medium stone grey", 163, 162, 165 }, { 199, "Dark stone grey", 99, 95, 98 },
{ 208, "Light stone grey", 229, 228, 223 }, { 217, "Brown", 124, 92, 70 }, { 1001, "Institutional white", 248, 248, 248 },
{ 1003, "Really black", 17, 17, 17 }, { 1004, "Really red", 255, 0, 0 }, { 1005, "Deep orange", 255, 176, 0 },
{ 1006, "Alder", 180, 128, 255 }, { 1007, "Dusty Rose", 163, 75, 75 }, { 1008, "Olive", 193, 190, 66 },
{ 1009, "New Yeller", 255, 255, 0 }, { 1010, "Really blue", 0, 0, 255 }, { 1011, "Navy blue", 0, 32, 96 },
{ 1012, "Deep blue", 33, 84, 185 }, { 1013, "Cyan", 4, 175, 236 }, { 1014, "CGA brown", 170, 85, 0 },
{ 1015, "Magenta", 170, 0, 170 }, { 1016, "Pink", 255, 102, 204 }, { 1018, "Teal", 18, 238, 212 },
{ 1019, "Toothpaste", 0, 255, 255 }, { 1020, "Lime green", 0, 255, 0 }, { 1021, "Camo", 58, 125, 21 },
{ 1022, "Grime", 127, 142, 100 }, { 1023, "Lavender", 140, 91, 159 }, { 1024, "Pastel light blue", 175, 221, 255 },
{ 1025, "Pastel orange", 255, 201, 201 }, { 1026, "Pastel violet", 177, 167, 255 }, { 1027, "Pastel blue-green", 159, 243, 233 },
{ 1028, "Pastel green", 204, 255, 204 }, { 1029, "Pastel yellow", 255, 255, 204 }, { 1030, "Pastel brown", 255, 204, 153 },
{ 1031, "Royal purple", 98, 37, 209 }, { 1032, "Hot pink", 255, 0, 191 },
}
local BC = {}
local BCMT
local porNome, porNumero = {}, {}
local function bcDe(item)
return criar(BCMT, "BrickColor", {
Name = item[2], Number = item[1], Color = c3(item[3] / 255, item[4] / 255, item[5] / 255),
})
end
BCMT = novoTipo("BrickColor", {}, {
r = function(a) return a.Color.R end,
g = function(a) return a.Color.G end,
b = function(a) return a.Color.B end,
}, {
__eq = function(a, b) return a.Number == b.Number end,
__tostring = function(a) return a.Name end,
})
for _, item in PALETA do
local b = bcDe(item)
porNome[item[2]] = b
porNumero[item[1]] = b
end
local function maisProxima(r: number, g: number, b: number)
local melhor, dist = porNumero[194], math.huge
for _, item in PALETA do
local d = (item[3] - r) ^ 2 + (item[4] - g) ^ 2 + (item[5] - b) ^ 2
if d < dist then melhor, dist = porNumero[item[1]], d end
end
return melhor
end
C.brickDeCor = function(cor)
return maisProxima(cor.R * 255, cor.G * 255, cor.B * 255)
end
function BC.new(a, b, c)
local t = C.typeof(a)
if t == "string" then return porNome[a] or porNumero[194] end
if t == "number" and b == nil then return porNumero[a] or porNumero[194] end
if t == "number" then return maisProxima(a * 255, num(b, 2, "new") * 255, num(c, 3, "new") * 255) end
if t == "Color3" then return C.brickDeCor(a) end
return porNumero[194]
end
function BC.palette(i) return porNumero[PALETA[(i or 0) + 1] and PALETA[(i or 0) + 1][1] or 194] end
function BC.random() return porNumero[PALETA[C.real.random(1, #PALETA)][1]] end
function BC.White() return porNome["White"] end
function BC.Gray() return porNome["Medium stone grey"] end
function BC.DarkGray() return porNome["Dark stone grey"] end
function BC.Black() return porNome["Black"] end
function BC.Red() return porNome["Bright red"] end
function BC.Yellow() return porNome["Bright yellow"] end
function BC.Green() return porNome["Dark green"] end
function BC.Blue() return porNome["Bright blue"] end
C.BrickColor = table.freeze(BC)
-- ============================================================================================
-- CFrame: posi\xE7\xE3o + rota\xE7\xE3o (matriz 3x3)
-- ============================================================================================
local CF = {}
local CFMT
local function cf(x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22)
return criar(CFMT, "CFrame", {
X = x, Y = y, Z = z,
R00 = r00, R01 = r01, R02 = r02, R10 = r10, R11 = r11, R12 = r12, R20 = r20, R21 = r21, R22 = r22,
})
end
C.cf = cf
local function eCF(v) return TIPO[v] == "CFrame" end
C.eCF = eCF
local function argCF(v, i, funcao)
if not eCF(v) then erro(string.format("invalid argument #%d to '%s' (CFrame expected, got %s)", i, funcao, C.typeof(v))) end
return v
end
local function mul(a, b)
return cf(
a.R00 * b.X + a.R01 * b.Y + a.R02 * b.Z + a.X,
a.R10 * b.X + a.R11 * b.Y + a.R12 * b.Z + a.Y,
a.R20 * b.X + a.R21 * b.Y + a.R22 * b.Z + a.Z,
a.R00 * b.R00 + a.R01 * b.R10 + a.R02 * b.R20, a.R00 * b.R01 + a.R01 * b.R11 + a.R02 * b.R21, a.R00 * b.R02 + a.R01 * b.R12 + a.R02 * b.R22,
a.R10 * b.R00 + a.R11 * b.R10 + a.R12 * b.R20, a.R10 * b.R01 + a.R11 * b.R11 + a.R12 * b.R21, a.R10 * b.R02 + a.R11 * b.R12 + a.R12 * b.R22,
a.R20 * b.R00 + a.R21 * b.R10 + a.R22 * b.R20, a.R20 * b.R01 + a.R21 * b.R11 + a.R22 * b.R21, a.R20 * b.R02 + a.R21 * b.R12 + a.R22 * b.R22
)
end
local function aplicar(a, v)
return v3(a.R00 * v.x + a.R01 * v.y + a.R02 * v.z + a.X, a.R10 * v.x + a.R11 * v.y + a.R12 * v.z + a.Y, a.R20 * v.x + a.R21 * v.y + a.R22 * v.z + a.Z)
end
local function girar(a, v)
return v3(a.R00 * v.x + a.R01 * v.y + a.R02 * v.z, a.R10 * v.x + a.R11 * v.y + a.R12 * v.z, a.R20 * v.x + a.R21 * v.y + a.R22 * v.z)
end
local function inversa(a)
local x, y, z = a.X, a.Y, a.Z
return cf(
-(a.R00 * x + a.R10 * y + a.R20 * z), -(a.R01 * x + a.R11 * y + a.R21 * z), -(a.R02 * x + a.R12 * y + a.R22 * z),
a.R00, a.R10, a.R20, a.R01, a.R11, a.R21, a.R02, a.R12, a.R22
)
end
local function rotX(t) local c, s = math.cos(t), math.sin(t) return cf(0, 0, 0, 1, 0, 0, 0, c, -s, 0, s, c) end
local function rotY(t) local c, s = math.cos(t), math.sin(t) return cf(0, 0, 0, c, 0, s, 0, 1, 0, -s, 0, c) end
local function rotZ(t) local c, s = math.cos(t), math.sin(t) return cf(0, 0, 0, c, -s, 0, s, c, 0, 0, 0, 1) end
-- quat\xE9rnios (para Lerp e para CFrame.new com 7 n\xFAmeros)
local function paraQuat(a)
local tr = a.R00 + a.R11 + a.R22
local w, x, y, z
if tr > 0 then
local s = math.sqrt(tr + 1) * 2
w = 0.25 * s
x = (a.R21 - a.R12) / s
y = (a.R02 - a.R20) / s
z = (a.R10 - a.R01) / s
elseif a.R00 > a.R11 and a.R00 > a.R22 then
local s = math.sqrt(1 + a.R00 - a.R11 - a.R22) * 2
w = (a.R21 - a.R12) / s
x = 0.25 * s
y = (a.R01 + a.R10) / s
z = (a.R02 + a.R20) / s
elseif a.R11 > a.R22 then
local s = math.sqrt(1 + a.R11 - a.R00 - a.R22) * 2
w = (a.R02 - a.R20) / s
x = (a.R01 + a.R10) / s
y = 0.25 * s
z = (a.R12 + a.R21) / s
else
local s = math.sqrt(1 + a.R22 - a.R00 - a.R11) * 2
w = (a.R10 - a.R01) / s
x = (a.R02 + a.R20) / s
y = (a.R12 + a.R21) / s
z = 0.25 * s
end
return x, y, z, w
end
local function deQuat(px, py, pz, x, y, z, w)
local n = math.sqrt(x * x + y * y + z * z + w * w)
if n == 0 then return cf(px, py, pz, 1, 0, 0, 0, 1, 0, 0, 0, 1) end
x, y, z, w = x / n, y / n, z / n, w / n
return cf(px, py, pz,
1 - 2 * (y * y + z * z), 2 * (x * y - z * w), 2 * (x * z + y * w),
2 * (x * y + z * w), 1 - 2 * (x * x + z * z), 2 * (y * z - x * w),
2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y))
end
local function olharPara(pos, alvo, cima)
local frente = alvo - pos
local m = magnitude(frente)
if m < 1e-9 then return cf(pos.x, pos.y, pos.z, 1, 0, 0, 0, 1, 0, 0, 0, 1) end
frente = frente / m
cima = cima or v3(0, 1, 0)
local dir = V3METODOS.Cross(frente, cima)
if magnitude(dir) < 1e-6 then dir = V3METODOS.Cross(frente, v3(0, 0, if frente.y > 0 then 1 else -1)) end
dir = dir / magnitude(dir)
local up = V3METODOS.Cross(dir, frente)
return cf(pos.x, pos.y, pos.z, dir.x, up.x, -frente.x, dir.y, up.y, -frente.y, dir.z, up.z, -frente.z)
end
local CFMETODOS = {}
function CFMETODOS.Inverse(a) return inversa(a) end
function CFMETODOS.Lerp(a, b, t)
argCF(b, 1, "Lerp")
t = num(t, 2, "Lerp")
local ax, ay, az, aw = paraQuat(a)
local bx, by, bz, bw = paraQuat(b)
local d = ax * bx + ay * by + az * bz + aw * bw
if d < 0 then bx, by, bz, bw, d = -bx, -by, -bz, -bw, -d end
local x, y, z, w
if d > 0.9995 then
x, y, z, w = ax + (bx - ax) * t, ay + (by - ay) * t, az + (bz - az) * t, aw + (bw - aw) * t
else
local th = math.acos(d)
local s = math.sin(th)
local ka, kb = math.sin((1 - t) * th) / s, math.sin(t * th) / s
x, y, z, w = ax * ka + bx * kb, ay * ka + by * kb, az * ka + bz * kb, aw * ka + bw * kb
end
return deQuat(a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t, a.Z + (b.Z - a.Z) * t, x, y, z, w)
end
function CFMETODOS.ToWorldSpace(a, b) return mul(a, argCF(b, 1, "ToWorldSpace")) end
function CFMETODOS.ToObjectSpace(a, b) return mul(inversa(a), argCF(b, 1, "ToObjectSpace")) end
function CFMETODOS.PointToWorldSpace(a, v) return aplicar(a, argV3(v, 1, "PointToWorldSpace")) end
function CFMETODOS.PointToObjectSpace(a, v) return aplicar(inversa(a), argV3(v, 1, "PointToObjectSpace")) end
function CFMETODOS.VectorToWorldSpace(a, v) return girar(a, argV3(v, 1, "VectorToWorldSpace")) end
function CFMETODOS.VectorToObjectSpace(a, v) return girar(inversa(a), argV3(v, 1, "VectorToObjectSpace")) end
function CFMETODOS.GetComponents(a)
return a.X, a.Y, a.Z, a.R00, a.R01, a.R02, a.R10, a.R11, a.R12, a.R20, a.R21, a.R22
end
CFMETODOS.components = CFMETODOS.GetComponents
function CFMETODOS.ToEulerAnglesXYZ(a)
local ry = math.asin(math.clamp(a.R02, -1, 1))
return math.atan2(-a.R12, a.R22), ry, math.atan2(-a.R01, a.R00)
end
function CFMETODOS.ToEulerAnglesYXZ(a)
local rx = math.asin(math.clamp(-a.R12, -1, 1))
return rx, math.atan2(a.R02, a.R22), math.atan2(a.R10, a.R11)
end
CFMETODOS.ToOrientation = CFMETODOS.ToEulerAnglesYXZ
function CFMETODOS.ToAxisAngle(a)
local x, y, z, w = paraQuat(a)
local ang = 2 * math.acos(math.clamp(w, -1, 1))
local s = math.sqrt(1 - w * w)
if s < 1e-9 then return v3(1, 0, 0), 0 end
return v3(x / s, y / s, z / s), ang
end