-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
2759 lines (2555 loc) · 160 KB
/
test.html
File metadata and controls
2759 lines (2555 loc) · 160 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Skedaddle Mobile Map Maker</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, interactive-widget=resizes-content"/>
<meta name="theme-color" content="#0f172a">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://unpkg.com/lucide@latest"></script>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<script src="https://apis.google.com/js/api.js"></script>
<script src="https://www.google.com/jsapi?autoload={'modules':[{'name':'picker','version':'1.0','callback':'pickerLoaded'}]}"></script>
<style>
:root {
--bg: #0f172a;
--panel: #1e293b;
--panel-hover: #334155;
--text: #f1f5f9;
--text-muted: #94a3b8;
--accent: #3b82f6;
--accent-hover: #2563eb;
--border: #334155;
--border-highlight: #475569;
--danger: #ef4444;
--success: #22c55e;
--warning: #eab308;
--font-main: 'Inter', system-ui, -apple-system, sans-serif;
--festive-gold: #fbbf24;
--festive-red: #ef4444;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; height: 100dvh; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font-main); margin: 0; }
body.blurred #app { filter: blur(12px); pointer-events: none; transition: filter 0.3s ease; }
#gate {
position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 999;
background: radial-gradient(circle at center, rgba(15, 23, 42, 0.9), #0f172a);
backdrop-filter: blur(10px);
transition: opacity 0.3s, visibility 0.3s;
padding: 16px;
}
#gate.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.gcard {
background: rgba(30, 41, 59, 0.8);
border: 1px solid var(--border-highlight);
border-radius: 24px;
padding: 40px;
width: min(480px, 100%);
text-align: center;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
position: relative;
overflow: hidden;
}
.gcard::before {
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
background: linear-gradient(90deg, var(--festive-red), var(--festive-gold), var(--success));
}
.gcard h2 {
margin: 16px 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.gcard p { margin: 0 0 32px; color: var(--text-muted); font-size: 15px; line-height: 1.5; }
.close-btn {
position: absolute; top: 16px; right: 16px; background: transparent; border: none;
color: var(--text-muted); cursor: pointer; padding: 8px; border-radius: 50%;
transition: all 0.2s; display: none;
}
.close-btn:hover { background: var(--panel-hover); color: var(--text); }
.grow { display: flex; flex-direction: column; gap: 12px; }
.gbtn {
background: var(--panel); border: 1px solid var(--border); color: var(--text);
padding: 16px; border-radius: 12px; cursor: pointer; font-size: 15px; font-weight: 600;
display: flex; align-items: center; justify-content: center; gap: 12px;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.gbtn:hover { background: var(--panel-hover); border-color: var(--border-highlight); transform: translateY(-1px); }
.gbtn:active { transform: translateY(0); }
.gbtn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.grow input[type=file] { position: absolute; width: 0; height: 0; opacity: 0; }
#app { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
header {
flex: 0 0 64px; display: flex; align-items: center; gap: 8px; padding: 0 16px;
background: var(--panel); border-bottom: 1px solid var(--border);
overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none;
z-index: 30; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
header::-webkit-scrollbar { display: none; }
#logoBtn { background: none; border: none; padding: 0; cursor: pointer; margin-right: 12px; }
#logo { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); }
h1 { margin: 0 16px 0 0; font-size: 18px; font-weight: 600; color: var(--text); display: inline-block; vertical-align: middle; }
.btn {
background: transparent; border: 1px solid transparent; color: var(--text-muted);
border-radius: 8px; height: 40px; padding: 0 12px; cursor: pointer;
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
font-size: 13px; font-weight: 500; transition: all 0.2s; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-hover); color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.toggled { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); color: var(--accent); }
/* Night Mode Glow Style */
.tool.night-glow {
box-shadow: 0 0 15px rgba(168, 85, 247, 0.5), inset 0 0 5px rgba(168, 85, 247, 0.5);
border-color: #a855f7 !important;
color: #a855f7 !important;
}
#btnComplete.selectable {
color: var(--success);
background: rgba(34, 197, 94, 0.1);
border-color: rgba(34, 197, 94, 0.3);
opacity: 1;
}
#selectionQuickEdit {
display: none;
align-items: center;
gap: 8px;
background: var(--bg);
padding: 4px 12px;
border-radius: 12px;
border: 1px solid var(--border-highlight);
margin: 0 8px;
}
.pill {
background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.2);
color: var(--accent); border-radius: 20px; padding: 6px 16px; font-size: 12px; font-weight: 600;
cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center;
margin-right: 8px;
}
.pill:hover { background: rgba(59, 130, 246, 0.2); }
.wrap { flex: 1; display: flex; position: relative; overflow: hidden; }
main { flex: 1; display: flex; flex-direction: column; position: relative; background: #050505; }
.canvasWrap {
flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
background: #0f172a;
background-image: radial-gradient(#1e293b 1px, transparent 1px);
background-size: 20px 20px;
}
canvas {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
background: transparent; touch-action: none; display: block;
box-shadow: 0 0 0 1px var(--border);
}
body.white-bg .canvasWrap { background: #ffffff; background-image: none; }
/* Scissor cursor for Splice Mode */
body.splice-cursor .canvasWrap {
cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='6' cy='6' r='3'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Cline x1='20' y1='4' x2='8.12' y2='15.88'/%3E%3Cline x1='14.47' y1='14.48' x2='20' y2='20'/%3E%3Cline x1='8.12' y1='8.12' x2='12' y2='12'/%3E%3C/svg%3E") 6 6, auto;
}
aside {
width: 320px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
display: flex; flex-direction: column; overflow-y: auto; padding: 16px;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
z-index: 20;
}
aside.closed { margin-left: -320px; }
.overlay {
position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px);
z-index: 19; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.group { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.group h3 {
margin: 0 0 12px; font-size: 11px; font-weight: 700; color: var(--text-muted);
text-transform: uppercase; letter-spacing: 0.05em;
}
.input {
width: 100%; background: var(--panel); border: 1px solid var(--border); color: var(--text);
border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit;
transition: border-color 0.2s;
}
.input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 80px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lbl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; font-size: 11px; color: var(--text-muted); padding-left: 2px; }
.acc { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); margin-bottom: 8px; overflow: hidden; }
.accHead {
display: flex; align-items: center; justify-content: space-between; cursor: pointer;
padding: 12px 14px; font-size: 14px; font-weight: 500; color: var(--text);
transition: background 0.2s;
}
.accHead:hover { background: var(--panel-hover); }
.accHead svg { transition: transform 0.2s; width: 16px; height: 16px; color: var(--text-muted); }
.acc.open .accHead svg { transform: rotate(90deg); color: var(--accent); }
.accBody { display: none; padding: 10px; border-top: 1px solid var(--border); background: var(--bg); }
.acc.open .accBody { display: block; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)); gap: 8px; }
.tool {
background: var(--panel); border: 1px solid var(--border); color: var(--text-muted);
border-radius: 8px; padding: 10px 4px; text-align: center; font-size: 11px;
cursor: pointer; min-height: 60px; display: flex; flex-direction: column;
align-items: center; justify-content: center; gap: 6px;
transition: all 0.2s;
}
.tool svg { width: 20px; height: 20px; margin-bottom: 2px; }
.tool:hover { background: var(--panel-hover); color: var(--text); border-color: var(--border-highlight); }
.tool.active {
background: rgba(59, 130, 246, 0.1); border-color: var(--accent); color: var(--accent);
box-shadow: 0 0 0 1px var(--accent);
}
/* Visibility UI Styles - Matched to Toolbox Accordion */
.vis-acc { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); margin-bottom: 8px; overflow: hidden; }
.vis-accHead {
display: flex; align-items: center; gap: 10px; cursor: pointer;
padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--text);
transition: background 0.2s;
}
.vis-accHead:hover { background: var(--panel-hover); }
.vis-accHead input[type="checkbox"] {
width: 16px; height: 16px; accent-color: var(--accent);
cursor: pointer; position: relative; z-index: 5;
}
.vis-accHead span { flex: 1; }
.vis-accHead i { transition: transform 0.2s; width: 14px; height: 14px; color: var(--text-muted); }
.vis-acc.open .vis-accHead i { transform: rotate(90deg); color: var(--accent); }
.vis-accBody { display: none; padding: 4px 0; border-top: 1px solid var(--border); background: var(--bg); }
.vis-acc.open .vis-accBody { display: block; }
.vis-row {
display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 40px;
font-size: 12px; transition: background 0.1s;
}
.vis-row:hover { background: var(--panel-hover); }
.vis-row input { accent-color: var(--accent); cursor: pointer; }
.slider-container { padding: 4px 0 12px; position: relative; }
input[type=range].input {
-webkit-appearance: none; appearance: none; height: 6px; background: var(--border);
border-radius: 3px; border: none; padding: 0;
}
input[type=range].input::-webkit-slider-thumb {
-webkit-appearance: none; appearance: none; width: 18px; height: 18px;
background: var(--accent); border: 4px solid var(--bg); border-radius: 50%;
cursor: pointer; box-shadow: 0 0 0 1px var(--border-highlight); transition: transform 0.1s;
}
input[type=range].input::-webkit-slider-thumb:hover { transform: scale(1.1); }
/* Eye icon in table */
.vis-toggle { cursor: pointer; color: var(--accent); transition: all 0.2s; padding: 4px; border-radius: 4px; }
.vis-toggle:hover { background: var(--panel-hover); }
.vis-toggle.faded { color: var(--text-muted); opacity: 0.4; }
.pop {
position: fixed; background: var(--panel); border: 1px solid var(--accent);
padding: 8px; border-radius: 12px; display: none; gap: 4px; z-index: 9999;
box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.pop button {
background: var(--bg); border: 1px solid var(--border); color: white;
padding: 10px 14px; border-radius: 8px; cursor: pointer; font-weight: 600;
transition: all 0.2s; min-width: 50px;
}
.pop button:hover { background: var(--accent); border-color: white; }
#modalBack, #modalAlert, #modalGallery {
position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 10000;
display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.card {
background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
padding: 24px; width: 90%; max-width: 450px; text-align: center;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
max-height: 80vh; display: flex; flex-direction: column;
}
/* Enhanced Gallery Styling */
.gallery-card { max-width: 900px; width: 95%; height: 85vh; }
.gallery-list {
overflow-y: auto; flex: 1; text-align: left; margin: 16px 0;
border: 1px solid var(--border); border-radius: 16px; background: rgba(0,0,0,0.1);
display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 16px;
}
.gallery-item {
background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
padding: 10px; cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
display: flex; flex-direction: column; gap: 10px;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.gallery-item:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3); }
.gallery-item .thumb {
width: 100%; aspect-ratio: 16/9; background: #050a15; border-radius: 10px; overflow: hidden;
display: flex; align-items: center; justify-content: center;
border: 1px solid rgba(255,255,255,0.05);
}
.gallery-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item .info { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.gallery-item span { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.gallery-item i { color: var(--accent); width: 18px; }
#lblEditor { position: fixed; z-index: 5000; transform: translate(-50%, -120%); }
#lblInput {
background: var(--panel); color: white; border: 1px solid var(--accent);
padding: 6px 12px; border-radius: 8px; font-size: 13px; min-width: 100px; text-align: center;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
@media (max-width: 900px) {
aside {
position: absolute; top: 0; bottom: 0; left: 0;
margin-left: 0 !important;
transform: translateX(-105%);
box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}
aside.open { transform: translateX(0); }
h1 { display: none; }
header { justify-content: space-between; }
header .btn { padding: 0 8px; }
.btn span { display: none; }
.btn i { margin: 0; }
#selectionQuickEdit span { display: none; }
.gallery-list { grid-template-columns: 1fr; }
.gallery-card { height: 95vh; }
}
#lenWrap {
background: var(--panel); border-top: 1px solid var(--border);
position: absolute; bottom: 0; left: 0; right: 0; max-height: 60%;
display: flex; flex-direction: column; z-index: 25;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform: translateY(calc(100% - 48px));
box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
}
#lenWrap.open { transform: translateY(0); }
#lenHead {
display: flex; justify-content: space-between; align-items: center; padding: 0 16px;
background: var(--panel); cursor: pointer; height: 48px; flex: 0 0 48px;
border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600;
}
#lenBody { overflow-y: auto; flex: 1; background: var(--bg); padding-bottom: 30px; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 12px 8px; font-size: 13px; text-align: left; vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; z-index: 2; font-size: 12px; text-transform: uppercase; }
td .edit { background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 6px 8px; width: 100%; }
</style>
</head>
<body class="blurred">
<div id="gate">
<div class="gcard">
<button class="close-btn" id="closeGateBtn" title="Continue Editing"><i data-lucide="x"></i></button>
<div style="margin-bottom: 20px;">
<img src="https://i.imgur.com/zdJfkpg.png" alt="logo" style="width:80px; height:80px; border-radius:16px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); border: 2px solid var(--border);">
</div>
<h2>Christmas Map Maker</h2>
<p>Design stunning holiday light displays.<br>Upload a photo or start from scratch.</p>
<div class="grow">
<div style="display:flex; gap:8px;">
<button id="gPickImg" class="gbtn" style="flex:1"><i data-lucide="image-plus"></i> Upload Property Photo</button>
<a href="https://earth.google.com/web/" target="_blank" class="gbtn" style="width:60px; padding:16px 0;" title="Google Earth"><i data-lucide="globe"></i></a>
</div>
<button id="gPickBlank" class="gbtn"><i data-lucide="file-plus"></i> Start Blank Map</button>
<button id="gPickMap" class="gbtn"><i data-lucide="folder-open"></i> Load Existing Map</button>
<button id="gOpenGallery" class="gbtn"><i data-lucide="layout-grid"></i> Map Gallery (Cloud)</button>
<button id="gLoadDrive" class="gbtn" disabled><i data-lucide="cloud"></i> Load from Drive</button>
<input id="gImg" type="file" accept="image/*"/>
<input id="gMap" type="file" accept=".skmap,.json,application/json"/>
</div>
</div>
</div>
<div id="modalBack">
<div class="card">
<h3>Unsaved Changes</h3>
<p>You have unsaved work. Are you sure you want to leave?</p>
<div class="row"><button id="btnStay" class="btn-stay">Stay</button><button id="btnLeave" class="btn-leave">Leave</button></div>
</div>
</div>
<div id="modalAlert">
<div class="card">
<h3>Notice</h3>
<p id="alertMsg">Message</p>
<div class="row"><button onclick="document.getElementById('modalAlert').style.display='none'" class="btn-ok">OK</button></div>
</div>
</div>
<div id="modalGallery">
<div class="card gallery-card">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom:16px;">
<h3 style="margin:0">Cloud Storage</h3>
<span id="galleryCount" style="font-size:12px; color:var(--text-muted); font-weight:600">0 Maps</span>
</div>
<div style="margin-bottom:12px;">
<input type="text" id="gallerySearch" class="input" placeholder="Search by project name..." style="background:var(--bg); border-color:var(--border-highlight)"/>
</div>
<div id="galleryList" class="gallery-list">
<div style="padding:40px; text-align:center; color:var(--text-muted); grid-column: 1 / -1;">
<i data-lucide="loader-2" style="width:32px; height:32px; animation: spin 1.5s linear infinite;"></i>
<div style="margin-top:12px">Syncing cloud library...</div>
</div>
</div>
<div class="row"><button onclick="document.getElementById('modalGallery').style.display='none'" class="btn-stay" style="background:var(--panel-hover)">Return to Main</button></div>
</div>
</div>
<div id="lblEditor"><input id="lblInput" placeholder="Note/Ft"></div>
<div id="app">
<header>
<button id="logoBtn" title="Menu"><img id="logo" src="https://i.imgur.com/zdJfkpg.png" alt=""></button>
<h1>Skedaddle</h1>
<span id="modeTag" class="pill" onclick="toggleMenu()">Draw</span>
<div style="flex:1"></div>
<!-- Dynamic Selection Area -->
<div id="selectionQuickEdit">
<span id="editLabelPrefix" style="font-size:12px; color:var(--text-muted); font-weight:600">ID:</span>
<input id="quickEditPrefix" class="input" style="width:70px; height:32px; padding:4px 8px; font-size:13px" placeholder="F1"/>
<!-- Individual Item Scale Slider -->
<div id="itemScaleWrap" style="display:none; align-items:center; gap:8px; margin-left:8px; border-left:1px solid var(--border); padding-left:8px;">
<span style="font-size:11px; color:var(--text-muted); font-weight:600">SCALE:</span>
<input id="itemScaleSlider" type="range" class="input" min="0.2" max="5" step="0.1" value="1.0" style="width:80px; height:24px; padding:0"/>
</div>
<button id="moveLabelToggleBtn" class="btn" title="Move Label"><i data-lucide="move-diagonal"></i></button>
<button id="quickDeleteBtn" class="btn" style="color:var(--danger); height:32px" title="Delete Selected"><i data-lucide="trash-2"></i></button>
</div>
<button id="btnDraw" class="btn" title="Draw Mode"><i data-lucide="pencil"></i><span>Draw</span></button>
<button id="btnSelect" class="btn" title="Select Mode"><i data-lucide="mouse-pointer-2"></i><span>Select</span></button>
<button id="btnMoveCanvas" class="btn" title="Pan Canvas"><i data-lucide="move"></i><span>Pan</span></button>
<div style="width:1px; height:24px; background:var(--border); margin:0 4px"></div>
<button id="btnUndo" class="btn" title="Undo"><i data-lucide="undo-2"></i></button>
<button id="btnComplete" class="btn" disabled title="Finish Line"><i data-lucide="check-circle"></i></button>
<button id="btnRedo" class="btn" disabled title="Redo"><i data-lucide="redo-2"></i></button>
<div style="width:1px; height:24px; background:var(--border); margin:0 4px"></div>
<button id="btnSwag" class="btn" style="display:none" title="Garland Swag"><i data-lucide="waves"></i><span>Swag</span></button>
<button id="btnPillar" class="btn" style="display:none" title="Pillar Mode"><i data-lucide="columns-2"></i><span>Pillar</span></button>
<button id="btnSnap" class="btn toggled" title="Snap to Points"><i data-lucide="magnet"></i></button>
<button id="btnFit" class="btn" title="Reset View"><i data-lucide="maximize"></i></button>
<div style="width:1px; height:24px; background:var(--border); margin:0 4px"></div>
<button id="btnSaveAll" class="btn" title="Save All"><i data-lucide="save"></i><span>Save</span></button>
<button id="btnSaveImageOnly" class="btn" title="Export PDF"><i data-lucide="file-down"></i></button>
<button id="btnSaveMapOnly" class="btn" title="Save File"><i data-lucide="download"></i></button>
</header>
<div class="wrap">
<div id="overlay" class="overlay"></div>
<aside id="side">
<div class="group">
<h3>Toolbox</h3>
<div id="accWrap"></div>
</div>
<div class="group">
<h3>Visibility Settings</h3>
<div id="visibilityMenu">
<!-- Populated by JS -->
</div>
</div>
<div class="group">
<h3>Display Settings</h3>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted); font-weight:700; text-transform:uppercase;">General Style</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Line Thickness</div>
<div class="slider-container">
<input id="lineScaleInput" type="range" class="input" min="0.5" max="3" step="0.1" value="1.0"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Thin</span><span id="lineScaleValue" style="color:var(--text)">1.0x</span><span>Thick</span>
</div>
</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Label Size</div>
<div class="slider-container">
<input id="labelScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="3.0"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Small</span><span id="labelScaleValue" style="color:var(--text)">3.0x</span><span>Large</span>
</div>
</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Background Blur</div>
<div class="slider-container">
<input id="bgBlurInput" type="range" class="input" min="0" max="100" step="1" value="0"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Clear</span><span id="bgBlurValue" style="color:var(--text)">0%</span><span>Blurry</span>
</div>
</div>
<div style="height:1px; background:var(--border); margin:12px 0;"></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted); font-weight:700; text-transform:uppercase;">Flow Arrows</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Frequency</div>
<div class="slider-container">
<input id="arrowFreqInput" type="range" class="input" min="0.2" max="1.5" step="0.1" value="1.0"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Few</span><span id="arrowFreqValue" style="color:var(--text)">1.0x</span><span>Many</span>
</div>
</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Arrow Size</div>
<div class="slider-container">
<input id="arrowScaleInput" type="range" class="input" min="0.5" max="3" step="0.1" value="1.0"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Small</span><span id="arrowScaleValue" style="color:var(--text)">1.0x</span><span>Large</span>
</div>
</div>
<div style="height:1px; background:var(--border); margin:12px 0;"></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted); font-weight:700; text-transform:uppercase;">Advanced Scaling</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Global Decor Scale</div>
<div class="slider-container">
<input id="iconScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="1.5"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Small</span><span id="iconScaleValue" style="color:var(--text)">1.5x</span><span>Huge</span>
</div>
</div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">C9 Tree Scale</div>
<div class="slider-container"><input id="c9TreeScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="1.0"/></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Mini Tree Scale</div>
<div class="slider-container"><input id="miniTreeScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="1.0"/></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">ToL Scale</div>
<div class="slider-container"><input id="tolScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="1.0"/></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Wreath Scale</div>
<div class="slider-container"><input id="wreathScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="1.0"/></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Bow Scale</div>
<div class="slider-container"><input id="bowScaleInput" type="range" class="input" min="0.5" max="5" step="0.1" value="1.0"/></div>
<div style="font-size:11px; margin-bottom:4px; color:var(--text-muted);">Power/Junction Scale</div>
<div class="slider-container">
<input id="junctionScaleInput" type="range" class="input" min="0.5" max="3" step="0.1" value="1.0"/>
<div style="font-size:10px; color:var(--text-muted); display:flex; justify-content:space-between; margin-top:4px;">
<span>Small</span><span id="junctionScaleValue" style="color:var(--text)">1.0x</span><span>Large</span>
</div>
</div>
</div>
<div class="group">
<h3>Project Details</h3>
<div class="grow" style="gap:8px">
<input id="customer" class="input" placeholder="Customer Name"/>
<input id="address" class="input" placeholder="Property Address"/>
<textarea id="jobNotes" class="input" placeholder="Installation notes..."></textarea>
</div>
<div style="font-size:11px; color:var(--text-muted); margin-top:12px; font-weight:600; text-transform:uppercase">Bulk Colour</div>
<input id="inputAllCol" class="input" placeholder="Set color for all items..." style="margin-top:6px">
</div>
<div class="group">
<h3>Timers</h3>
<button id="btnCustomerControlled" class="btn" style="width:100%; margin-bottom:12px; justify-content:center;">Customer Controlled</button>
<div id="timerInputs">
<div class="lbl-row"><span>On</span><span>Off</span></div>
<div class="row2"><input id="on1" type="time" class="input"/><input id="off1" type="time" class="input"/></div>
<div class="lbl-row" style="margin-top:8px"><span>On</span><span>Off</span></div>
<div class="row2"><input id="on2" type="time" class="input"/><input id="off2" type="time" class="input"/></div>
<button id="btnStd" class="btn" style="width:100%; margin-top:12px; justify-content:center; font-size:12px;">Set Standard Times</button>
</div>
</div>
<div class="group">
<h3>Legend</h3>
<dl class="clip-legend">
<dt><div class="leg-sq"></div> PS</dt><dd>Power Source</dd>
<dt><div class="leg-tri"></div> 3W</dt><dd>3-Way Adapter</dd>
<dt>ST</dt><dd>Shingle Tab (Eaves/Ridges)</dd>
<dt>T</dt><dd>Tuff Clip (Fascia)</dd>
<dt>Mag</dt><dd>Magnetic Clip</dd>
<dt>FRA</dt><dd>Flat Roof Adapter</dd>
<dt>GG</dt><dd>Gutter Guard</dd>
</dl>
</div>
</aside>
<main>
<div class="canvasWrap"><canvas id="cv"></canvas></div>
<div id="lenWrap">
<div id="lenHead">
<div style="display:flex; align-items:center; gap:8px"><i data-lucide="ruler"></i> Line Information <span style="font-weight:400; color:var(--text-muted); font-size:12px">(Tap to view)</span></div>
<i data-lucide="chevron-up" id="lenChevron"></i>
</div>
<div id="lenBody">
<div style="padding:12px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:16px; flex-wrap:wrap">
<label style="display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text); cursor:pointer;">
<input id="chkAutoCalc" type="checkbox" checked style="accent-color:var(--accent)"/> Auto-calculate bulbs/feet
</label>
<button id="btnLineSplice" class="btn" style="height:32px; font-size:12px; margin-left:auto"><i data-lucide="scissors"></i> Line Splice</button>
<button id="btnMergeLines" class="btn" style="height:32px; font-size:12px;"><i data-lucide="merge"></i> Merge Lines</button>
<button id="btnRelabelIDs" class="btn" style="height:32px; font-size:12px;"><i data-lucide="list-ordered"></i> Relabel IDs</button>
</div>
<div style="overflow-x:auto">
<table id="matTable">
<thead><tr><th style="width:30px"></th><th>Type</th><th style="width:60px">ID</th><th>Ft</th><th>Bulbs</th><th>Clip</th><th>Colour</th><th>Notes</th><th style="width:70px"></th></tr></thead>
<tbody id="lenRows"></tbody>
</table>
</div>
</div>
</div>
</main>
</div>
</div>
<div id="wreathPop" class="pop">
<button data-bow="none">No Bow</button><button data-bow="bottom">Bot Bow</button><button data-bow="top">Top Bow</button>
</div>
<div id="tolPop" class="pop">
<button data-size="3">3'</button><button data-size="6">6'</button><button data-size="9">9'</button><button data-size="12">12'</button><button data-size="15">15'</button>
</div>
<div id="imgUploadPop" class="pop" style="flex-direction: column; padding: 12px; min-width: 200px;">
<label for="iconFile" class="btn" style="margin-bottom: 8px; justify-content:center"><i data-lucide="upload"></i> Upload Image</label>
<input type="file" id="iconFile" accept="image/*" style="display:none;"/>
<button id="cancelIconUpload" class="btn" style="justify-content:center">Cancel</button>
</div>
<script>
(()=>{
const iconMap = {
'ridges': 'home',
'fascia': 'minus',
'peaks': 'triangle',
'groundstakes': 'map-pin',
'shrub': 'cloud',
'windows': 'layout-grid',
'garland': 'waves',
'wreath': 'circle-dashed',
'wreath32': 'circle',
'wreath42': 'circle-dot',
'bow': 'gift',
'tree': 'tree-pine',
'tree:Trunk + Branch (Minis)': 'tree-deciduous',
'tree:Trunk + Canopy (Minis)': 'tree-pine',
'tree:C9 Tree': 'triangle',
'tree:ToL': 'sprout',
'cords': 'plug',
'powersource': 'zap',
'threeway': 'git-fork',
'label': 'type',
'custom_icon': 'image',
'night_mode': 'moon',
'ai_detect': 'bot'
};
const tp1 = "ghp_xSeuggnKkttH6z";
const tp2 = "TSfiTENK2bjTv7ya1TsWF7";
const githubConfig = {
token: (tp1 + tp2).trim(),
owner: "rollert2",
repo: "SkedaddleMapMaker",
path: "maps/",
};
async function saveToGitHub(filename, content, isBase64 = false) {
if (!githubConfig.token || !githubConfig.owner || !githubConfig.repo) return;
const url = `https://api.github.com/repos/${githubConfig.owner}/${githubConfig.repo}/contents/${githubConfig.path}${filename}`;
try {
let sha = null;
const checkRes = await fetch(url, { headers: { "Authorization": `Bearer ${githubConfig.token}` } });
if (checkRes.ok) {
const data = await checkRes.json();
sha = data.sha;
}
const body = {
message: `Save map: ${filename}`,
content: isBase64 ? content : btoa(unescape(encodeURIComponent(content))),
sha: sha
};
const saveRes = await fetch(url, {
method: "PUT",
headers: {
"Authorization": `Bearer ${githubConfig.token}`,
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
if (!saveRes.ok) console.error("GitHub Save Error:", await saveRes.text());
} catch (err) { console.error("GitHub Connection Failed:", err); }
}
let allGalleryMaps = [];
async function openGallery() {
if (!githubConfig.token) { showAlert("GitHub token not configured."); return; }
const modal = document.getElementById('modalGallery');
const list = document.getElementById('galleryList');
const search = document.getElementById('gallerySearch');
const countLabel = document.getElementById('galleryCount');
modal.style.display = 'flex';
list.innerHTML = '<div style="padding:40px; text-align:center; color:var(--text-muted); grid-column: 1 / -1;"><i data-lucide="loader-2" style="width:32px; height:32px; animation: spin 1.5s linear infinite;"></i><div style="margin-top:12px">Syncing cloud library...</div></div>';
if(window.lucide) lucide.createIcons();
search.value = "";
try {
const url = `https://api.github.com/repos/${githubConfig.owner}/${githubConfig.repo}/contents/${githubConfig.path}`;
const res = await fetch(url, { headers: { "Authorization": `Bearer ${githubConfig.token}` } });
if (res.status === 404) {
list.innerHTML = '<div style="padding:40px; text-align:center; color:var(--text-muted); grid-column: 1 / -1;">No maps found in cloud folder.</div>';
countLabel.textContent = "0 Maps";
return;
}
if (res.ok) {
const files = await res.json();
const mapFiles = Array.isArray(files) ? files.filter(f => f.name.endsWith('.skmap')) : [];
mapFiles.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
allGalleryMaps = mapFiles;
countLabel.textContent = `${mapFiles.length} Maps`;
renderGalleryItems(mapFiles);
} else {
list.innerHTML = `<div style="padding:20px; text-align:center; color:var(--danger); grid-column: 1 / -1;">Error ${res.status}. Token likely revoked.</div>`;
}
} catch (err) { list.innerHTML = '<div style="padding:20px; text-align:center; color:var(--danger); grid-column: 1 / -1;">Connection failed.</div>'; }
}
async function renderGalleryItems(maps) {
const list = document.getElementById('galleryList');
list.innerHTML = '';
if (maps.length === 0) {
list.innerHTML = '<div style="padding:40px; text-align:center; color:var(--text-muted); grid-column: 1 / -1;">No projects match your search.</div>';
return;
}
maps.forEach(f => {
const item = document.createElement('div');
item.className = 'gallery-item';
item.innerHTML = `
<div class="thumb" id="thumb-${f.sha}">
<div style="color:var(--text-muted); font-size:10px; display:flex; flex-direction:column; align-items:center; gap:8px">
<i data-lucide="image" style="width:20px; height:20px"></i>
<span>Rendering...</span>
</div>
</div>
<div class="info">
<span>${f.name.replace('.skmap', '')}</span>
<i data-lucide="chevron-right" style="width:16px; height:16px"></i>
</div>
`;
item.onclick = () => loadFromGitHub(f.download_url);
list.appendChild(item);
fetchThumbnail(f);
});
if(window.lucide) lucide.createIcons();
}
async function fetchThumbnail(fileMetadata) {
try {
const res = await fetch(fileMetadata.download_url);
const data = await res.json();
const thumbContainer = document.getElementById(`thumb-${fileMetadata.sha}`);
if (thumbContainer && data.thumbnail) {
thumbContainer.innerHTML = `<img src="${data.thumbnail}" alt="Preview">`;
} else if (thumbContainer) {
thumbContainer.innerHTML = `<div style="display:flex; flex-direction:column; align-items:center; gap:4px"><i data-lucide="image-off" style="width:24px; color:var(--text-muted)"></i><span style="font-size:9px; color:var(--text-muted)">No Preview</span></div>`;
lucide.createIcons();
}
} catch (e) { }
}
document.getElementById('gallerySearch').oninput = (e) => {
const term = e.target.value.toLowerCase();
const filtered = allGalleryMaps.filter(m => m.name.toLowerCase().includes(term));
renderGalleryItems(filtered);
};
async function loadFromGitHub(downloadUrl) {
try {
const res = await fetch(downloadUrl);
const json = await res.json();
const blob = new Blob([JSON.stringify(json)], { type: "application/json" });
const file = new File([blob], "cloud_map.skmap");
handleMap(file);
document.getElementById('modalGallery').style.display = 'none';
} catch (err) { showAlert("Error loading map content."); }
}
const CLIENT_ID = '746571343552-88ogvei1lvtq9ojq3te7fn06d1rlgut4.apps.googleusercontent.com';
const API_KEY = 'AIzaSyCBB6UWp5-FCB7VMpRKsjQh7sR42qd4SN0';
const APP_ID = '746571343552';
const GDRIVE_SCOPES = 'https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.appdata';
const MAP_MIME_TYPE = 'application/json';
const MAP_FILE_EXTENSION = '.skmap';
let accessToken = null;
let tokenClient = null;
let gapiReady = false;
let gisReady = false;
const gLoadDriveBtn = document.getElementById('gLoadDrive');
gapi.load('client:picker', async () => {
try {
await gapi.client.setApiKey(API_KEY);
await gapi.client.load('drive', 'v3');
gapiReady = true;
const checkGis = setInterval(() => {
if (window.google && window.google.accounts) {
clearInterval(checkGis);
initGis();
}
}, 100);
} catch (err) { console.error("Error loading GAPI:", err); }
});
function initGis() {
try {
tokenClient = google.accounts.oauth2.initTokenClient({
client_id: CLIENT_ID, scope: GDRIVE_SCOPES,
callback: (response) => {
if (response.error !== undefined) showAlert('Authorization Failed: ' + response.error);
else { accessToken = response.access_token; updateDriveUI(true); }
},
});
gisReady = true; checkApiReadiness();
} catch (err) { console.error("Error initializing GIS:", err); }
}
function checkApiReadiness() {
if (gapiReady && gisReady) {
gLoadDriveBtn.disabled = false;
const authClickHandler = () => tokenClient.requestAccessToken({ prompt: '' });
gLoadDriveBtn.onclick = authClickHandler;
}
}
function updateDriveUI(isAuthenticated) {
if (isAuthenticated) {
gLoadDriveBtn.innerHTML = '<i data-lucide="cloud"></i> Load from Drive';
gLoadDriveBtn.onclick = () => createPicker('load');
lucide.createIcons();
}
}
async function createPicker(pickerType) {
if (!accessToken || !gapiReady || !gisReady) { showAlert('Please sign in to Google Drive first.'); return; }
let view = new google.picker.View(google.picker.ViewId.DOCS);
view.setMimeTypes(MAP_MIME_TYPE + ',text/plain,application/octet-stream');
view.setQuery(MAP_FILE_EXTENSION);
const picker = new google.picker.PickerBuilder()
.setAppId(APP_ID).setOAuthToken(accessToken).setDeveloperKey(API_KEY)
.addView(view).setCallback(pickerCallback).build();
picker.setVisible(true);
}
function pickerCallback(data) {
if (data.action === google.picker.Action.PICKED) {
const file = data.docs[0];
loadFromDrive(file[google.picker.Document.ID]);
}
}
async function loadFromDrive(fileId) {
showAlert('Loading map from Google Drive...');
try {
const response = await gapi.client.drive.files.get({ fileId: fileId, alt: 'media' });
const mapDataString = response.body;
const file = new File([mapDataString], 'downloaded_map.skmap', { type: MAP_MIME_TYPE });
handleMap(file);
document.getElementById('modalAlert').style.display = 'none';
} catch (error) { showAlert('Error loading map content from Drive.'); }
}
const cats=[
{name:"C9's",key:'c9',list:['fascia','peaks','ridges','groundstakes']},
{name:'Minis',key:'min',list:['shrub','windows']},
{name:'Greenery',key:'grn',list:['wreath32','wreath42','garland','bow']},
{name:'Trees',key:'tre',list:['tree:Trunk + Branch (Minis)','tree:Trunk + Canopy (Minis)','tree:C9 Tree','tree:ToL']},
{name:'Power',key:'pwr',list:['powersource','cords','threeway']},
{name:'Specials', key:'spec', list:['label', 'custom_icon', 'night_mode', 'ai_detect']}
];
const pretty={ridges:'Ridges',fascia:'Fascia',peaks:'Peaks',groundstakes:'Stakes',shrub:'Shrub',windows:'Windows',garland:'Garland',wreath:'Wreath',bow:'Bow',cords:'Cord',powersource:'Source',threeway:'3-Way',tree:'Tree', label: 'Label', custom_icon: 'Image', night_mode: 'Night', ai_detect: 'Ai Detect'};
const pfx={ridges:'R',fascia:'F',peaks:'P',groundstakes:'GS',shrub:'S',windows:'W',garland:'GA',wreath:'WR',bow:'B',cords:'C',powersource:'PS',tree:'T', label:'LBL', custom_icon: 'CI'};
const data={ridges:[],fascia:[],peaks:[],groundstakes:[],shrub:[],windows:[],garland:[],wreath:[],bow:[],cords:[],powersource:[],threeway:[],tree:[], label:[], custom_icon:[]};
const visibilityGroups = [
{ label: 'House Lights', sub: ['fascia', 'peaks', 'ridges'] },
{ label: 'Windows', sub: ['windows'] },
{ label: 'Greenery', sub: ['garland', 'wreath', 'wreath32', 'wreath42', 'bow'] },
{ label: 'Shrubs', sub: ['shrub'] },
{ label: 'Trees', sub: ['tree:Trunk + Branch (Minis)', 'tree:Trunk + Canopy (Minis)', 'tree:C9 Tree', 'tree:ToL'] },
{ label: 'Ground Stakes', sub: ['groundstakes'] }
];
const openVisGroups = new Set();
let selectedForMerge = new Set();
function getColorCode(colorName) {
if (!colorName) return '#ddd';
const lowerName = colorName.toLowerCase();
if (lowerName.includes('multi') || lowerName === 'm' || lowerName.includes('multiple')) return 'Red/Blue/Green/Orange/Yellow';
if (colorName.includes(' ') || colorName.includes('/') || colorName.includes(',')) return colorName;
const cleanName = lowerName.replace(/[^a-z0-9#]/g, '');
switch (cleanName) {
case 'warmwhite': case 'softwhite': case 'white': case 'ww': case 'sw': case '#fffdf0': return '#fffdf0';
case 'red': return '#ef4444';
case 'blue': return '#3b82f6';
case 'green': return '#22c55e';
case 'yellow': return '#eab308';
case 'orange': return '#f97316';
case 'purple': case 'violet': return '#a855f7';
case 'pink': return '#ec4899';
case 'black': return '#000000';
default: if(colorName.startsWith('#') && colorName.length >= 4) return colorName; return '#ddd';
}
}
const colorOf=L=>({ridges:'#fffdf0',fascia:'#fffdf0',peaks:'#fffdf0',groundstakes:'#fffdf0',shrub:'#22c55e',windows:'#7dd3fc',garland:'#22c55e',wreath:'#22c55e',bow:'#ef4444',cords:'#000000',powersource:'#ef4444',threeway:'#eab308',tree:'#22c55e'}[L]||'#ddd');
let settings = {
iconScale: 1.5, junctionScale: 1.0, lineScale: 1.0, labelScale: 3.0, lineThickness: 3, arrowScale: 1.0, arrowFreqFactor: 1.0, bgBlur: 0,
c9TreeScale: 1.0, miniTreeScale: 1.0, tolScale: 1.0, wreathScale: 1.0, bowScale: 1.0
};
let isNightMode = false;
const aside=document.getElementById('side'), overlay=document.getElementById('overlay');
function toggleMenu(){
const isMobile = matchMedia('(max-width:900px)').matches;
if (isMobile) {
const isOpen = aside.classList.toggle('open');
overlay.classList.toggle('show', isOpen);
} else {
aside.classList.toggle('closed');
overlay.classList.remove('show');
setTimeout(initializeAndSizeContext, 350);
}
}
document.getElementById('logoBtn').onclick=toggleMenu;
overlay.onclick=toggleMenu;
document.getElementById('modeTag').onclick=toggleMenu;
const closeGateBtn = document.getElementById('closeGateBtn');
function openGate(fromCanvas = false) {
document.body.classList.add('blurred');
document.getElementById('gate').classList.remove('hide');
closeGateBtn.style.display = fromCanvas ? 'block' : 'none';
}
function unlock(){
document.body.classList.remove('blurred');
document.getElementById('gate').classList.add('hide');
history.pushState(null, null, location.href);
}
const lenWrap = document.getElementById('lenWrap');
const lenChevron = document.getElementById('lenChevron');
document.getElementById('lenHead').onclick=()=>{
lenWrap.classList.toggle('open');
if (lenWrap.classList.contains('open')) {
lenChevron.setAttribute('data-lucide', 'chevron-down');
} else {
lenChevron.setAttribute('data-lucide', 'chevron-up');
}
lucide.createIcons();
};
function showAlert(msg) {
document.getElementById('alertMsg').textContent = msg;
document.getElementById('modalAlert').style.display = 'flex';
}
const lineScaleInput = document.getElementById('lineScaleInput');
const lineScaleValue = document.getElementById('lineScaleValue');
const iconScaleInput = document.getElementById('iconScaleInput');
const iconScaleValue = document.getElementById('iconScaleValue');
const bgBlurInput = document.getElementById('bgBlurInput');
const bgBlurValue = document.getElementById('bgBlurValue');
const junctionScaleInput = document.getElementById('junctionScaleInput');
const junctionScaleValue = document.getElementById('junctionScaleValue');
const labelScaleInput = document.getElementById('labelScaleInput');
const labelScaleValue = document.getElementById('labelScaleValue');
const arrowFreqInput = document.getElementById('arrowFreqInput');
const arrowFreqValue = document.getElementById('arrowFreqValue');
const arrowScaleInput = document.getElementById('arrowScaleInput');
const arrowScaleValue = document.getElementById('arrowScaleValue');
const c9TreeScaleInput = document.getElementById('c9TreeScaleInput');
const miniTreeScaleInput = document.getElementById('miniTreeScaleInput');
const tolScaleInput = document.getElementById('tolScaleInput');
const wreathScaleInput = document.getElementById('wreathScaleInput');
const bowScaleInput = document.getElementById('bowScaleInput');
const itemScaleSlider = document.getElementById('itemScaleSlider');
const itemScaleWrap = document.getElementById('itemScaleWrap');