-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2907 lines (2699 loc) · 151 KB
/
Copy pathindex.html
File metadata and controls
2907 lines (2699 loc) · 151 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="it">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link rel="preconnect" href="https://unpkg.com" crossorigin>
<link rel="preconnect" href="https://a.basemaps.cartocdn.com" crossorigin>
<link rel="preconnect" href="https://b.basemaps.cartocdn.com" crossorigin>
<link rel="preconnect" href="https://c.basemaps.cartocdn.com" crossorigin>
<link rel="preconnect" href="https://d.basemaps.cartocdn.com" crossorigin>
<title>Osservatorio Nazionale Sovranità Digitale — Posta elettronica della PA italiana</title>
<meta name="description" content="Osservatorio Nazionale Sovranità Digitale: la sovranità digitale della posta elettronica della Pubblica Amministrazione Italiana. Mappa interattiva di ~23.000 enti pubblici italiani (comuni, province, regioni, ministeri, scuole, ASL, università, ordini professionali) con il provider email reale classificato via analisi DNS (MX, SPF, CNAME, DKIM). Espone la dipendenza della PA italiana da hyperscaler statunitensi soggetti al CLOUD Act.">
<meta name="keywords" content="Osservatorio Nazionale Sovranità Digitale, MxMap Italia, MXMap Italia, MxMap.it, sovranità digitale, sovranità digitale Italia, posta elettronica PA, provider email pubblica amministrazione, email PA italiana, CLOUD Act, IndicePA, analisi DNS, record MX, mappa PA italiana, dati aperti PA">
<meta name="application-name" content="Osservatorio Nazionale Sovranità Digitale">
<meta name="author" content="Osservatorio Nazionale Sovranità Digitale">
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
<link rel="canonical" href="https://mxmap.it/">
<link rel="sitemap" type="application/xml" href="/sitemap.xml">
<link rel="icon" type="image/svg+xml" href="brand/favicon.svg">
<link rel="icon" type="image/png" sizes="32x32" href="brand/favicon-32.png">
<link rel="icon" type="image/png" sizes="16x16" href="brand/favicon-16.png">
<link rel="apple-touch-icon" href="brand/apple-touch-icon.png">
<link rel="manifest" href="/site.webmanifest">
<meta name="theme-color" content="#0066CC">
<meta property="og:type" content="website">
<meta property="og:locale" content="it_IT">
<meta property="og:site_name" content="Osservatorio Nazionale Sovranità Digitale">
<meta property="og:title" content="Osservatorio Nazionale Sovranità Digitale — Posta elettronica della PA italiana">
<meta property="og:description" content="Mappa di ~23.000 enti pubblici italiani con il provider email reale (analisi DNS). Quota di PA su provider USA soggetti al CLOUD Act. Dati aperti CC BY-SA 4.0.">
<meta property="og:image" content="https://mxmap.it/brand/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:type" content="image/png">
<meta name="twitter:image" content="https://mxmap.it/brand/og-image.png">
<meta property="og:url" content="https://mxmap.it/">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebSite",
"@id": "https://mxmap.it/#website",
"name": "Osservatorio Nazionale Sovranità Digitale",
"alternateName": ["MxMap Italia", "MXMap Italia", "MxMap.it", "MX Map Italia"],
"url": "https://mxmap.it/",
"inLanguage": "it-IT",
"description": "Osservatorio sulla sovranità digitale della posta elettronica della Pubblica Amministrazione italiana: il provider email reale di ~23.000 enti pubblici, classificato via analisi DNS.",
"publisher": {"@id": "https://mxmap.it/#org"}
},
{
"@type": "Organization",
"@id": "https://mxmap.it/#org",
"name": "Osservatorio Nazionale Sovranità Digitale",
"alternateName": ["MxMap Italia", "MxMap.it"],
"url": "https://mxmap.it/",
"logo": "https://mxmap.it/brand/icon-512.png",
"sameAs": [
"https://github.com/mxmap-it/mxmap.it",
"https://osservatorio.mxmap.it/",
"https://t.me/+Ot-M_g0dkh1kMGI0"
]
},
{
"@type": "Dataset",
"@id": "https://mxmap.it/#dataset",
"name": "Sovranità digitale della posta elettronica della PA italiana — Osservatorio Nazionale Sovranità Digitale",
"alternateName": "MxMap Italia dataset",
"description": "Classificazione del provider email reale di ~23.000 enti della Pubblica Amministrazione italiana (comuni, province, regioni, ministeri, scuole, ASL, università, ordini professionali) tramite analisi DNS (MX, SPF, CNAME, DKIM). Espone la quota di PA su provider statunitensi soggetti al CLOUD Act e l'Indice di Sovranità Digitale.",
"url": "https://mxmap.it/",
"inLanguage": "it-IT",
"license": "https://creativecommons.org/licenses/by-sa/4.0/",
"isAccessibleForFree": true,
"creator": {"@id": "https://mxmap.it/#org"},
"publisher": {"@id": "https://mxmap.it/#org"},
"keywords": ["sovranità digitale", "Pubblica Amministrazione", "posta elettronica", "CLOUD Act", "IndicePA", "DNS", "record MX", "Italia"],
"spatialCoverage": {"@type": "Place", "name": "Italia"},
"distribution": [
{"@type": "DataDownload", "name": "Dataset CSV", "encodingFormat": "text/csv", "contentUrl": "https://mxmap.it/dist/mxmap_it_dataset.csv"},
{"@type": "DataDownload", "name": "Dataset JSON", "encodingFormat": "application/json", "contentUrl": "https://mxmap.it/dist/mxmap_it_dataset.json"},
{"@type": "DataDownload", "name": "Dataset XLSX", "encodingFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "contentUrl": "https://mxmap.it/dist/mxmap_it_dataset.xlsx"}
]
}
]
}
</script>
<link rel="preload" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"></noscript>
<script defer src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script defer src="https://unpkg.com/topojson-client@3/dist/topojson-client.min.js"></script>
<!-- markercluster — only loaded for the Scuole point-marker view -->
<link rel="preload" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="preload" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css"></noscript>
<noscript><link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css"></noscript>
<script defer src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
/* Italy-only branding: desaturate + lighten the world tile layer so
surrounding countries (France, Slovenia, Austria, Tunisia, Malta, …)
fade into the background. Italian polygons stay vivid on top. */
.leaflet-tile.foreign-faded {
filter: saturate(0) brightness(1.08) contrast(0.85) opacity(0.55);
}
.leaflet-container { background: #f4f4f4; }
#header {
background: #1a1a2e; color: #fff; height: 44px; padding: 0 16px;
display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { font-size: 15px; font-weight: 700; white-space: nowrap; margin: 0; overflow: hidden; text-overflow: ellipsis; line-height: 1.15; }
@media (max-width: 560px) { .brand { font-size: 12.5px; white-space: normal; } }
.separator { color: #555; font-size: 15px; }
.tagline { color: #a0a0b0; font-size: 13px; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.beta-wrap { position: relative; display: inline-flex; align-self: center; }
.beta-badge { background:#E8A33D; color:#fff; font-size:10px; font-weight:700; letter-spacing:.5px; padding:2px 6px; border-radius:4px; cursor:help; }
.beta-wrap:focus { outline:2px solid #fff; outline-offset:1px; border-radius:4px; }
.beta-tip { position:absolute; top:calc(100% + 9px); left:-4px; width:300px; max-width:calc(100vw - 28px); background:#fff; color:#222; border:1px solid #d0d7de; border-radius:8px; box-shadow:0 10px 28px rgba(0,0,0,.22); padding:12px 14px; font-size:12.5px; font-weight:400; line-height:1.55; letter-spacing:normal; white-space:normal; z-index:3000; opacity:0; visibility:hidden; transform:translateY(-4px); transition:opacity .15s, transform .15s; }
.beta-wrap:hover .beta-tip, .beta-wrap:focus-within .beta-tip, .beta-wrap.open .beta-tip { opacity:1; visibility:visible; transform:translateY(0); }
.beta-tip a { color:#0066CC; font-weight:600; text-decoration:none; }
.beta-tip a:hover { text-decoration:underline; }
.beta-tip .arr { position:absolute; top:-6px; left:14px; width:11px; height:11px; background:#fff; border-left:1px solid #d0d7de; border-top:1px solid #d0d7de; transform:rotate(45deg); }
/* mobile: riquadro ancorato ai bordi schermo, mai fuori viewport */
@media (max-width:560px){
.beta-tip { position:fixed; top:48px; left:10px; right:10px; width:auto; max-width:none; font-size:13px; }
.beta-tip .arr { display:none; }
}
.updated { font-size: 11px; color: #888; }
.toggle-info {
background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
color: #ccc; font-size: 13px; font-weight: 500; padding: 5px 14px; border-radius: 4px; cursor: pointer;
white-space: nowrap;
}
.toggle-info:hover { background: rgba(255,255,255,0.25); color: #fff; }
.gateway-icon { background: none !important; border: none !important; }
.dominance-label { background: none !important; border: none !important; text-align: center; }
#info-bar, #stats-bar {
background: #f8f9fb; border-bottom: 1px solid #e2e4e8; overflow: hidden; flex-shrink: 0;
max-height: 2000px; padding: 16px 20px;
}
#info-bar:not(.collapsed), #stats-bar:not(.collapsed) { max-height: 80vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#info-bar.collapsed, #stats-bar.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; }
.info-grid {
display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 10px;
}
.info-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 2px; color: #1a1a2e; }
.info-card p { font-size: 12px; color: #444; line-height: 1.4; margin: 0; }
.info-card a { color: #2563eb; text-decoration: none; }
.info-card a:hover { text-decoration: underline; }
.info-title { display: none; font-size: 16px; font-weight: 600; color: #1a1a2e; margin-bottom: 12px; }
.stats-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 13px; }
.stats-label { width: 90px; text-align: right; color: #555; flex-shrink: 0; }
.stats-bar-bg { flex: 1; background: #e8e8e8; border-radius: 3px; height: 16px; overflow: hidden; }
.stats-bar { height: 100%; border-radius: 3px; min-width: 2px; }
.stats-value { width: 70px; font-size: 12px; color: #666; flex-shrink: 0; }
.stats-columns { display: flex; gap: 32px; flex-wrap: wrap; }
.stats-column { flex: 1; min-width: 280px; }
.stats-countries { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 24px; }
.stats-mode-btn { padding: 3px 10px; font-size: 11px; border: 1px solid #ccc; background: #f5f5f5; cursor: pointer; border-radius: 3px; }
.stats-mode-btn.active { background: #444; color: #fff; border-color: #444; }
.stats-mode-btn:hover { background: #ddd; }
.stats-mode-btn.active:hover { background: #555; }
.popup-load-btn { padding: 4px 12px; font-size: 11px; cursor: pointer; background: #4a90d9; color: #fff; border: none; border-radius: 3px; margin-top: 4px; }
.popup-load-btn:hover { background: #3a7bc0; }
.popup-load-btn:disabled { background: #aaa; cursor: wait; }
.popup-muni-list { max-height: 200px; overflow-y: auto; font-size: 11px; }
.popup-muni-row { padding: 3px 0; border-bottom: 1px solid #f0f0f0; }
.popup-muni-row:last-child { border-bottom: none; }
.popup-muni-detail { display: none; padding: 4px 4px 4px 16px; font-size: 10px; background: #fafafa; border-radius: 3px; margin-top: 2px; }
.popup-muni-row.expanded .popup-muni-detail { display: block; }
.popup-muni-summary:hover { background: #f0f0f0; border-radius: 3px; }
.popup-search { padding: 4px 8px; font-size: 11px; border: 1px solid #ddd; border-radius: 3px; box-sizing: border-box; }
.popup-filter-chip { padding: 1px 6px; font-size: 9px; border-radius: 10px; background: #fff; cursor: pointer; white-space: nowrap; }
.popup-filter-chip.active { color: #fff !important; }
.popup-filter-chip:hover { opacity: 0.8; }
.stats-countries .stats-label { width: 75px; font-size: 12px; }
.stats-countries .stats-value { width: 60px; }
.stats-countries .stats-row { margin: 3px 0; }
@media (max-width: 1100px) { .stats-countries { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .stats-countries { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .stats-countries { grid-template-columns: 1fr; } }
#map { flex: 1; position: relative; width: 100%; will-change: transform; }
.legend {
background: white; padding: 10px 14px; border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,0.2); font-size: 13px; line-height: 1.8;
}
.legend i {
width: 14px; height: 14px; display: inline-block; margin-right: 6px;
border-radius: 3px; vertical-align: middle;
}
.legend-group { margin-top: 8px; }
.legend-group:first-child { margin-top: 4px; }
.legend-group-label {
font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 0.3px;
font-weight: 600; display: block; margin-bottom: 2px;
}
.legend-toggle {
display: none; background: none; border: none; font-size: 13px;
font-weight: 600; cursor: pointer; padding: 0; color: #333;
}
.map-controls {
position: absolute; top: 10px; right: 10px; z-index: 1000;
display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.country-toggle {
background: rgba(255,255,255,0.92); border: 1.5px solid #ccc; border-radius: 4px;
padding: 4px 12px; cursor: pointer; font-size: 11px; font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1); white-space: nowrap;
}
.country-toggle:hover { border-color: #999; }
.country-filters {
display: none; flex-wrap: wrap; justify-content: flex-end; gap: 2px;
max-width: 520px;
background: rgba(255,255,255,0.95); border-radius: 6px;
padding: 6px 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.country-filters.expanded { display: flex; }
.region-group {
display: flex; align-items: center; gap: 2px;
}
.region-label {
font-size: 9px; color: #888; font-weight: 700; text-transform: uppercase;
letter-spacing: 0.3px; cursor: pointer; user-select: none;
background: none; border: none; padding: 1px 3px;
white-space: nowrap;
}
.region-label:hover { color: #333; }
.country-btn {
background: white; border: 1.5px solid #ccc; border-radius: 3px;
padding: 1px 5px; cursor: pointer; font-size: 10px; font-weight: 600;
transition: all 0.15s; line-height: 1.4;
}
.country-btn.active { border-color: #333; background: #333; color: white; }
.country-btn:hover { border-color: #999; }
.level-toggle {
display: flex; background: white; border-radius: 5px;
box-shadow: 0 1px 4px rgba(0,0,0,0.1); overflow: hidden;
}
.level-btn {
background: white; border: none; border-right: 1px solid #e0e0e0;
padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600;
color: #666; transition: all 0.15s;
}
.level-btn:last-child { border-right: none; }
.level-btn.active { background: #333; color: white; }
.level-btn:hover:not(.active) { background: #f0f0f0; }
.juris-toggle {
display: flex; align-items: center; gap: 4px; background: white;
border-radius: 5px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); padding: 3px 6px;
}
.juris-label { color: #888; font-weight: 600; font-size: 10px; padding: 0 2px; }
.juris-btn {
background: #f5f5f5; border: 1px solid #e0e0e0; border-radius: 4px;
padding: 3px 8px; cursor: pointer; font-size: 11px; font-weight: 600;
color: #555; transition: all 0.15s; white-space: nowrap;
}
.juris-btn.active { background: #455a64; color: white; border-color: #455a64; }
.juris-btn:hover:not(.active) { background: #eaeaea; }
@media (max-width: 640px) { .juris-btn { padding: 2px 6px; font-size: 10px; } .juris-label { display: none; } }
.info-popup { font-size: 13px; line-height: 1.6; }
.info-popup strong { font-size: 14px; }
.info-popup .provider-badge {
display: inline-block; padding: 1px 8px; margin-left: 5px; border-radius: 3px;
color: #fff; font-size: 12px; font-weight: 600;
}
.popup-section { margin-top: 10px; }
.popup-section-title {
font-size: 11px; color: #999; text-transform: uppercase;
letter-spacing: 0.5px; margin-bottom: 2px; font-weight: 600;
}
.popup-section-hint { font-weight: 400; opacity: 0.7; }
.popup-confidence {
margin-top: 6px; padding: 5px 8px; background: #f3f6f9;
border-left: 3px solid #607d8b; font-size: 11px; color: #37474f;
}
.popup-confidence a { color: #607d8b; }
.report-err { margin-top: 10px; font-size: 12px; border-top: 1px solid #eee; padding-top: 8px; }
.report-err > summary { cursor: pointer; color: #a15c00; font-weight: 600; list-style: none; }
.report-err > summary::-webkit-details-marker { display: none; }
.report-choice { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.report-choice .rc-q { color: #666; }
.report-choice a { color: #0066CC; text-decoration: none; font-weight: 600; padding: 2px 9px; border: 1px solid #cfe0f5; border-radius: 6px; white-space: nowrap; }
.report-choice a:hover { background: #eef5ff; }
.dns-table { border-collapse: collapse; }
.dns-table td {
padding: 1px 8px 1px 0; vertical-align: baseline; font-size: 12px; white-space: nowrap;
}
.dns-table .pri { color: #999; font-size: 11px; }
.dns-table .host {
font-family: ui-monospace, monospace; font-size: 11px; color: #555;
max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.provider-bar {
display: flex; height: 16px; border-radius: 3px; overflow: hidden; margin: 6px 0;
}
.provider-bar-seg { min-width: 2px; }
@media (max-width: 600px) {
.separator, .tagline { display: none; }
.info-title { display: block; }
.info-grid { grid-template-columns: 1fr; }
.legend-toggle { display: block; }
.legend.legend-collapsed .legend-content { display: none; }
.legend.legend-collapsed { padding: 8px 12px; }
.map-controls { top: 6px; right: 6px; }
.country-filters { max-width: 280px; }
.country-btn { padding: 1px 4px; font-size: 9px; }
.region-label { font-size: 8px; }
.country-toggle { font-size: 10px; padding: 3px 8px; }
.level-btn { padding: 4px 10px; font-size: 11px; }
/* header compatto: niente data, Telegram solo-icona → niente overflow su 375px */
.updated { display: none; }
.tg-label { display: none; }
.header-right { gap: 8px; }
}
</style>
</head>
<body>
<header id="header">
<div class="header-left">
<img src="brand/favicon.svg" width="26" height="26" alt="" aria-hidden="true" style="flex-shrink:0">
<h1 class="brand">Osservatorio Nazionale <span style="color:#0066CC">Sovranità Digitale</span></h1>
<span class="beta-wrap" tabindex="0" role="button" aria-expanded="false" aria-label="Stato del progetto: versione beta — tocca per i dettagli">
<span class="beta-badge">BETA</span>
<span class="beta-tip" role="tooltip">
<span class="arr"></span>
<strong>Progetto in evoluzione.</strong> L'Osservatorio Nazionale Sovranità Digitale è un <em>work in progress</em> in costante sviluppo. La <strong>prima scansione ufficiale</strong> — da cui partirà la misurazione quotidiana — <strong>non è ancora partita</strong>.<br><br>
Aiutaci a completare la roadmap: <a href="https://github.com/mxmap-it/mxmap.it/issues" target="_blank" rel="noopener">collabora su GitHub Issues</a> e <a href="https://t.me/+Ot-M_g0dkh1kMGI0" target="_blank" rel="noopener">unisciti al canale Telegram</a>.
</span>
</span>
<span class="separator">|</span>
<span class="tagline">Sovranità digitale della posta elettronica della PA italiana</span>
</div>
<div class="header-right">
<span class="updated" id="generated"></span>
<a href="https://t.me/+Ot-M_g0dkh1kMGI0" target="_blank" rel="noopener" title="Unisciti al canale Telegram" style="display:inline-flex;align-items:center;gap:5px;background:#229ED9;color:#fff;font-size:12px;font-weight:600;padding:4px 10px;border-radius:6px;text-decoration:none;flex-shrink:0">
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.81c-.19.91-.74 1.13-1.5.71L12.6 16.3l-1.99 1.93c-.23.23-.42.42-.83.42z"/></svg><span class="tg-label">Telegram</span></a>
<button class="toggle-info" id="toggle-stats" title="Apri la pagina Statistiche">Statistiche</button>
<button class="toggle-info" id="toggle-info" aria-expanded="false" aria-controls="info-bar">Informazioni ▾</button>
</div>
</header>
<script>
(function(){
var w = document.querySelector('.beta-wrap'); if(!w) return;
function set(o){ w.classList.toggle('open', o); w.setAttribute('aria-expanded', o ? 'true':'false'); }
w.addEventListener('click', function(e){ if(e.target.closest('a')) return; e.stopPropagation(); set(!w.classList.contains('open')); });
document.addEventListener('click', function(e){ if(!w.contains(e.target)) set(false); });
w.addEventListener('keydown', function(e){
if(e.key==='Escape'){ set(false); }
else if(e.key==='Enter'||e.key===' '){ e.preventDefault(); set(!w.classList.contains('open')); }
});
})();
</script>
<section id="info-bar" class="collapsed" aria-label="About this project">
<h2 class="info-title">Osservatorio sulla Sovranità Digitale della Posta Elettronica della Pubblica Amministrazione Italiana</h2>
<div class="info-grid">
<div class="info-card">
<h3>Cos'è questa mappa?</h3>
<p>Una mappa interattiva che mostra quale provider gestisce la posta elettronica ufficiale di <strong>regioni, province e comuni italiani</strong> (~8.000 enti, fonte: <a href="https://indicepa.gov.it/" target="_blank" rel="noopener">IndicePA</a>) — basata su analisi pubblica dei record DNS. I provider statunitensi (Microsoft 365, Google Workspace, AWS) sono soggetti al <strong>CLOUD Act</strong>, che consente alle autorità USA di richiedere dati archiviati indipendentemente dalla loro localizzazione fisica. Questo solleva preoccupazioni concrete di sovranità digitale per la PA italiana.</p>
</div>
<div class="info-card">
<h3>Come funziona?</h3>
<p>Per ogni dominio di un ente pubblico italiano interroghiamo i record DNS pubblici (MX, SPF, CNAME, DKIM, autodiscover, TXT) e classifichiamo in ordine di priorità: <strong>MX o CNAME</strong> che matchano un provider noto; <strong>look-through dei gateway</strong> via SPF/autodiscover/DKIM/TXT quando l'MX punta a un'appliance di sicurezza email; <strong>controllo DKIM</strong> per individuare il backend reale dietro server self-hosted; <strong>ASN locali</strong> per ISP italiani noti; oppure <strong>self-hosted</strong>. Quando il dominio del sito non ha MX, recuperiamo via le email IndicePA non-PEC, via Wikidata P856, via scraping della homepage, o via motore di ricerca. ASMEL/ASMECAL/ASMECAM/Lepida/ARIA/CSI Piemonte/Insiel/Sogei e simili sono classificati come <em>infrastruttura pubblica regionale</em> (in-house consortile o di proprietà regionale).</p>
</div>
<div class="info-card">
<h3>Open source & dati aperti</h3>
<p>Ispirato da <a href="https://mxmap.ch" target="_blank" rel="noopener">mxmap.ch</a> di <strong>David Huser</strong>; modello di classificazione e confidence dal paper <a href="https://github.com/mxmap/esorics2026" target="_blank" rel="noopener">ESORICS 2026</a> (Huser, Bischof, Petrlic, Ochsner). Codice e dati su <a href="https://github.com/mxmap-it/mxmap.it" target="_blank" rel="noopener">GitHub</a>. Fonti: <a href="https://indicepa.gov.it/ipa-dati/dataset/enti" target="_blank" rel="noopener">IndicePA (AgID)</a>, <a href="https://www.wikidata.org/" target="_blank" rel="noopener">Wikidata</a>, <a href="https://www.openstreetmap.org/" target="_blank" rel="noopener">OpenStreetMap</a>.</p>
<h4 style="margin-top:14px;font-size:13px;color:#444">Scarica il dataset completo</h4>
<p style="font-size:12px;color:#555">Una riga per ente IndicePA, con codice IPA, codice ISTAT, dominio, provider email classificato, sovranità, gateway, motivazione DNS. Aggiornato a ogni run della pipeline.</p>
<p style="font-size:12px">
<a href="dist/mxmap_it_dataset.csv" download style="margin-right:14px">📊 CSV (Excel-friendly)</a>
<a href="dist/mxmap_it_dataset.xlsx" download style="margin-right:14px">📑 XLSX (multi-sheet)</a>
<a href="dist/mxmap_it_dataset.json" download style="margin-right:14px">{ } JSON (API)</a>
<a href="kpi.json" target="_blank" rel="noopener" style="margin-right:14px">📈 KPI (aggregati)</a>
<a href="report.json" target="_blank" rel="noopener">📄 Report (JSON)</a>
</p>
<p style="font-size:11px;color:#888">Licenza dati: ODbL-1.0 + CC-BY-4.0 (ereditate da OSM/IndicePA/Wikidata). Codice: MIT.</p>
<h4 style="margin-top:14px;font-size:13px;color:#444">Trasparenza dataset</h4>
<p style="font-size:12px;color:#555;margin-bottom:6px">
📖 <a href="methodology.html" target="_blank" rel="noopener"><strong>Metodologia di scoperta MX</strong></a>
— come abbiamo determinato il fornitore di posta di ciascun ente, regole del validatore <code>is_legit_email_domain</code> e statistiche per metodo.
</p>
<p style="font-size:12px;color:#555;margin-bottom:6px">
📄 <a href="report.html" target="_blank" rel="noopener"><strong>Report</strong></a>
— il documento di sintesi (stile consulting) sullo stato della sovranità digitale della posta PA, con raccomandazioni di policy.
</p>
<p style="font-size:12px;color:#555;margin-bottom:6px">
📊 <a href="statistiche.html" target="_blank" rel="noopener"><strong>Statistiche</strong></a>
— la fotografia attuale: Indice di Sovranità Digitale, quota CLOUD Act, sovranità per tipo di ente e per provider.
</p>
<p style="font-size:12px;color:#555;margin-bottom:6px">
⚠️ <a href="anomalie.html" target="_blank" rel="noopener"><strong>Anomalie</strong></a>
— enti con posta non individuabile o classificazione a bassa confidenza (~767, 3,3% del dataset).
</p>
<p style="font-size:12px;color:#555;margin-bottom:6px">
📈 <a href="storia.html" target="_blank" rel="noopener"><strong>Storia</strong></a>
— andamento nel tempo della sovranità della posta PA e diario dei cambiamenti misurati a ogni run.
</p>
<h4 style="margin-top:14px;font-size:13px;color:#444">Esplora tutti gli enti</h4>
<p style="font-size:12px;color:#555;margin-bottom:6px">
🗺️ <a href="/aree/"><strong>Sovranità per area</strong></a>
— regione per regione, provincia e comune: ogni ente pubblico ha la sua <strong>scheda</strong> con provider email, stato di sovranità e affidabilità del dato.
</p>
<p style="font-size:12px;color:#555;margin-bottom:6px">
🏛️ <a href="/categoria/"><strong>Sovranità per categoria</strong></a>
— comuni, scuole, sanità, ministeri, ordini professionali e le altre tipologie di ente pubblico.
</p>
<p id="funnel-sentence" style="margin-bottom:8px"><em>Caricamento…</em></p>
<table id="funnel-table" style="border-collapse:collapse;font-size:12px;width:100%;max-width:560px"></table>
</div>
</div>
</section>
<section id="stats-bar" class="collapsed" aria-label="Statistics">
<div id="stats-content"></div>
</section>
<main id="map" role="application" aria-label="Interactive map of municipal email providers">
<div id="map-loading" style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;z-index:1000;background:rgba(255,255,255,0.85);font-size:15px;color:#555;">Caricamento dati mappa…</div>
<div class="map-controls">
<button class="country-toggle" id="country-toggle" style="display:none">Countries ▾</button>
<div class="country-filters" id="country-filters">
<button class="country-btn active" data-country="IT">IT</button>
</div>
<div class="level-toggle">
<a class="level-btn" href="templates/it_search_template.html" style="text-decoration:none" title="Cerca tra tutti gli enti pubblici italiani analizzati + scarica il dataset">Ricerca Ente</a>
<a class="level-btn" href="templates/it_table_template.html" style="text-decoration:none">PA Centrale</a>
<button class="level-btn active" data-level="region">Regioni</button>
<button class="level-btn" data-level="district">Province</button>
<button class="level-btn" data-level="municipality">Comuni</button>
<button class="level-btn" data-level="istruzione" title="Choropleth comuni colorato per provider email dominante delle scuole statali (~8.000 scuole IPA L33)">Scuole</button>
</div>
<div class="juris-toggle" id="juris-toggle" title="Filtra le aree per sovranità dell'infrastruttura di posta in entrata — il paese dell'IP del server MX (Team Cymru ASN). Più intenso = più enti in quella giurisdizione.">
<span class="juris-label">Sovranità MX</span>
<button class="juris-btn active" data-jur="">Tutte</button>
<button class="juris-btn" data-jur="domestic">🇮🇹 Sovrana</button>
<button class="juris-btn" data-jur="foreign">🌍 Estera</button>
<button class="juris-btn" data-jur="mixed">Mista</button>
</div>
</div>
</main>
<script>
document.addEventListener('DOMContentLoaded', function () {
if (!CSS.supports('height', '100dvh')) {
document.body.style.height = window.innerHeight + 'px';
}
const COLORS = {
// USA hyperscalers (CLOUD Act) — rosso/arancione, contrasto vs verde italiano
'Microsoft 365': '#D42E2E',
'Google Workspace': '#FF6B6B',
'AWS': '#FF8C42',
// ITALIA — palette verde, gradata per grado di sovranità
'Cloud Italiano': '#009246', // verde bandiera — Lepida/ARIA/CSI/Insiel/Sogei...
'Provider Italiano': '#2E7D32', // Aruba/Register.it/Seeweb/InfoCert/Namirial/ISP
// Scuole statali sul tenant centrale MIM (istruzione.it / miuristruzione.onmicrosoft.com).
// Colore "ibrido": rosso CLOUD-Act perché è MS365, ma sfumato per indicare
// dipendenza da un tenant centrale che la scuola non controlla.
'Tenant centrale MIM (istruzione.it)': '#B85C5C',
'Infrastruttura autonoma': '#558B2F', // ex-Self-hosted/independent
'Mail provinciale condivisa': '#7CB342',
'Contractor PA privato': '#AED581',
// Foreign minor senders
'Zoho': '#7C3AED',
'Yandex': '#FFCC00',
// Provider europei non italiani (eu_non_it) — blu UE
'Provider europeo': '#1E5FB4',
// Backwards-compatible aliases (in case some old code references the original keys)
'Microsoft': '#D42E2E',
'Google': '#FF6B6B',
'Local Provider': '#2E7D32',
'Self-hosted': '#558B2F',
'IT pubblico (sovrano)': '#009246',
'Aruba': '#2E7D32',
'Register.it': '#2E7D32',
'Seeweb': '#2E7D32',
'InfoCert': '#2E7D32',
'Namirial': '#2E7D32',
'ISP italiano': '#2E7D32',
'ISP locale': '#2E7D32',
'Sconosciuto': '#BFBFBF',
'Unknown': '#BFBFBF',
};
const DARK_TEXT = new Set(['Google Workspace', 'Google', 'AWS', 'Sconosciuto', 'Unknown', 'Yandex', 'Mail provinciale condivisa', 'Contractor PA privato']);
const TIERS = {
'USA (CLOUD Act)': ['Microsoft 365', 'Google Workspace', 'AWS', 'Tenant centrale MIM (istruzione.it)'],
'Cloud Italiano (sovrano)': ['Cloud Italiano'],
'Provider Italiano': ['Provider Italiano', 'Contractor PA privato'],
'Infrastruttura autonoma': ['Infrastruttura autonoma', 'Mail provinciale condivisa'],
'Europeo (non IT)': ['Provider europeo'],
'Altro': ['Zoho', 'Yandex', 'Sconosciuto'],
};
const FLAGS = { EE: '\u{1F1EA}\u{1F1EA}', LV: '\u{1F1F1}\u{1F1FB}', LT: '\u{1F1F1}\u{1F1F9}', FI: '\u{1F1EB}\u{1F1EE}', NO: '\u{1F1F3}\u{1F1F4}', IS: '\u{1F1EE}\u{1F1F8}', SE: '\u{1F1F8}\u{1F1EA}', DE: '\u{1F1E9}\u{1F1EA}', DK: '\u{1F1E9}\u{1F1F0}', AD: '\u{1F1E6}\u{1F1E9}', LU: '\u{1F1F1}\u{1F1FA}', BE: '\u{1F1E7}\u{1F1EA}', AT: '\u{1F1E6}\u{1F1F9}', CZ: '\u{1F1E8}\u{1F1FF}', SK: '\u{1F1F8}\u{1F1F0}', SI: '\u{1F1F8}\u{1F1EE}', ES: '\u{1F1EA}\u{1F1F8}', FR: '\u{1F1EB}\u{1F1F7}', PL: '\u{1F1F5}\u{1F1F1}', PT: '\u{1F1F5}\u{1F1F9}', IT: '\u{1F1EE}\u{1F1F9}', IE: '\u{1F1EE}\u{1F1EA}', NL: '\u{1F1F3}\u{1F1F1}', BG: '\u{1F1E7}\u{1F1EC}', GB: '\u{1F1EC}\u{1F1E7}', HR: '\u{1F1ED}\u{1F1F7}', CY: '\u{1F1E8}\u{1F1FE}', GR: '\u{1F1EC}\u{1F1F7}', HU: '\u{1F1ED}\u{1F1FA}', MT: '\u{1F1F2}\u{1F1F9}', RO: '\u{1F1F7}\u{1F1F4}', AL: '\u{1F1E6}\u{1F1F1}', XK: '\u{1F1FD}\u{1F1F0}', ME: '\u{1F1F2}\u{1F1EA}', BA: '\u{1F1E7}\u{1F1E6}', RS: '\u{1F1F7}\u{1F1F8}', MK: '\u{1F1F2}\u{1F1F0}', UA: '\u{1F1FA}\u{1F1E6}', MD: '\u{1F1F2}\u{1F1E9}', LI: '\u{1F1F1}\u{1F1EE}', SM: '\u{1F1F8}\u{1F1F2}', GE: '\u{1F1EC}\u{1F1EA}', AM: '\u{1F1E6}\u{1F1F2}', AZ: '\u{1F1E6}\u{1F1FF}', BY: '\u{1F1E7}\u{1F1FE}', TR: '\u{1F1F9}\u{1F1F7}', MC: '\u{1F1F2}\u{1F1E8}', GL: '\u{1F1EC}\u{1F1F1}', AU: '\u{1F1E6}\u{1F1FA}', NZ: '\u{1F1F3}\u{1F1FF}', FJ: '\u{1F1EB}\u{1F1EF}', WS: '\u{1F1FC}\u{1F1F8}', VU: '\u{1F1FB}\u{1F1FA}', TO: '\u{1F1F9}\u{1F1F4}', NR: '\u{1F1F3}\u{1F1F7}', PW: '\u{1F1F5}\u{1F1FC}', ID: '\u{1F1EE}\u{1F1E9}', PG: '\u{1F1F5}\u{1F1EC}', MY: '\u{1F1F2}\u{1F1FE}', TH: '\u{1F1F9}\u{1F1ED}', KH: '\u{1F1F0}\u{1F1ED}', PH: '\u{1F1F5}\u{1F1ED}', VN: '\u{1F1FB}\u{1F1F3}', MM: '\u{1F1F2}\u{1F1F2}', JP: '\u{1F1EF}\u{1F1F5}', TW: '\u{1F1F9}\u{1F1FC}', KR: '\u{1F1F0}\u{1F1F7}', KP: '\u{1F1F0}\u{1F1F5}', CN: '\u{1F1E8}\u{1F1F3}', MN: '\u{1F1F2}\u{1F1F3}', IN: '\u{1F1EE}\u{1F1F3}', BD: '\u{1F1E7}\u{1F1E9}', PK: '\u{1F1F5}\u{1F1F0}', LK: '\u{1F1F1}\u{1F1F0}', NP: '\u{1F1F3}\u{1F1F5}', LA: '\u{1F1F1}\u{1F1E6}', BN: '\u{1F1E7}\u{1F1F3}', TL: '\u{1F1F9}\u{1F1F1}', KZ: '\u{1F1F0}\u{1F1FF}', UZ: '\u{1F1FA}\u{1F1FF}', KG: '\u{1F1F0}\u{1F1EC}', RU: '\u{1F1F7}\u{1F1FA}', SA: '\u{1F1F8}\u{1F1E6}', IQ: '\u{1F1EE}\u{1F1F6}', JO: '\u{1F1EF}\u{1F1F4}', LB: '\u{1F1F1}\u{1F1E7}', KW: '\u{1F1F0}\u{1F1FC}', IR: '\u{1F1EE}\u{1F1F7}', IL: '\u{1F1EE}\u{1F1F1}', OM: '\u{1F1F4}\u{1F1F2}', AE: '\u{1F1E6}\u{1F1EA}', QA: '\u{1F1F6}\u{1F1E6}', BH: '\u{1F1E7}\u{1F1ED}', AR: '\u{1F1E6}\u{1F1F7}', BO: '\u{1F1E7}\u{1F1F4}', BR: '\u{1F1E7}\u{1F1F7}', CL: '\u{1F1E8}\u{1F1F1}', CO: '\u{1F1E8}\u{1F1F4}', EC: '\u{1F1EA}\u{1F1E8}', GY: '\u{1F1EC}\u{1F1FE}', PE: '\u{1F1F5}\u{1F1EA}', PY: '\u{1F1F5}\u{1F1FE}', SR: '\u{1F1F8}\u{1F1F7}', UY: '\u{1F1FA}\u{1F1FE}', VE: '\u{1F1FB}\u{1F1EA}', DZ: '\u{1F1E9}\u{1F1FF}', EG: '\u{1F1EA}\u{1F1EC}', LY: '\u{1F1F1}\u{1F1FE}', MA: '\u{1F1F2}\u{1F1E6}', TN: '\u{1F1F9}\u{1F1F3}', SD: '\u{1F1F8}\u{1F1E9}', BJ: '\u{1F1E7}\u{1F1EF}', BF: '\u{1F1E7}\u{1F1EB}', CV: '\u{1F1E8}\u{1F1FB}', CI: '\u{1F1E8}\u{1F1EE}', GM: '\u{1F1EC}\u{1F1F2}', GH: '\u{1F1EC}\u{1F1ED}', GN: '\u{1F1EC}\u{1F1F3}', GW: '\u{1F1EC}\u{1F1FC}', LR: '\u{1F1F1}\u{1F1F7}', ML: '\u{1F1F2}\u{1F1F1}', MR: '\u{1F1F2}\u{1F1F7}', NE: '\u{1F1F3}\u{1F1EA}', NG: '\u{1F1F3}\u{1F1EC}', SN: '\u{1F1F8}\u{1F1F3}', SL: '\u{1F1F8}\u{1F1F1}', TG: '\u{1F1F9}\u{1F1EC}', CM: '\u{1F1E8}\u{1F1F2}', CF: '\u{1F1E8}\u{1F1EB}', TD: '\u{1F1F9}\u{1F1E9}', CG: '\u{1F1E8}\u{1F1EC}', CD: '\u{1F1E8}\u{1F1E9}', GQ: '\u{1F1EC}\u{1F1F6}', GA: '\u{1F1EC}\u{1F1E6}', ST: '\u{1F1F8}\u{1F1F9}', BI: '\u{1F1E7}\u{1F1EE}', KM: '\u{1F1F0}\u{1F1F2}', DJ: '\u{1F1E9}\u{1F1EF}', ER: '\u{1F1EA}\u{1F1F7}', ET: '\u{1F1EA}\u{1F1F9}', KE: '\u{1F1F0}\u{1F1EA}', MG: '\u{1F1F2}\u{1F1EC}', MW: '\u{1F1F2}\u{1F1FC}', MU: '\u{1F1F2}\u{1F1FA}', MZ: '\u{1F1F2}\u{1F1FF}', RW: '\u{1F1F7}\u{1F1FC}', SC: '\u{1F1F8}\u{1F1E8}', SO: '\u{1F1F8}\u{1F1F4}', SS: '\u{1F1F8}\u{1F1F8}', TZ: '\u{1F1F9}\u{1F1FF}', UG: '\u{1F1FA}\u{1F1EC}', AO: '\u{1F1E6}\u{1F1F4}', BW: '\u{1F1E7}\u{1F1FC}', SZ: '\u{1F1F8}\u{1F1FF}', LS: '\u{1F1F1}\u{1F1F8}', NA: '\u{1F1F3}\u{1F1E6}', ZA: '\u{1F1FF}\u{1F1E6}', ZM: '\u{1F1FF}\u{1F1F2}', ZW: '\u{1F1FF}\u{1F1FC}', CA: '\u{1F1E8}\u{1F1E6}', BZ: '\u{1F1E7}\u{1F1FF}', GT: '\u{1F1EC}\u{1F1F9}', HN: '\u{1F1ED}\u{1F1F3}', SV: '\u{1F1F8}\u{1F1FB}', NI: '\u{1F1F3}\u{1F1EE}', CR: '\u{1F1E8}\u{1F1F7}', PA: '\u{1F1F5}\u{1F1E6}', CU: '\u{1F1E8}\u{1F1FA}', HT: '\u{1F1ED}\u{1F1F9}', DO: '\u{1F1E9}\u{1F1F4}', JM: '\u{1F1EF}\u{1F1F2}', TT: '\u{1F1F9}\u{1F1F9}', BS: '\u{1F1E7}\u{1F1F8}', BB: '\u{1F1E7}\u{1F1E7}', AG: '\u{1F1E6}\u{1F1EC}', DM: '\u{1F1E9}\u{1F1F2}', GD: '\u{1F1EC}\u{1F1E9}', KN: '\u{1F1F0}\u{1F1F3}', LC: '\u{1F1F1}\u{1F1E8}', VC: '\u{1F1FB}\u{1F1E8}', AF: '\u{1F1E6}\u{1F1EB}', SG: '\u{1F1F8}\u{1F1EC}', YE: '\u{1F1FE}\u{1F1EA}', SY: '\u{1F1F8}\u{1F1FE}', PS: '\u{1F1F5}\u{1F1F8}', TJ: '\u{1F1F9}\u{1F1EF}', TM: '\u{1F1F9}\u{1F1F2}', MV: '\u{1F1F2}\u{1F1FB}', BT: '\u{1F1E7}\u{1F1F9}', SB: '\u{1F1F8}\u{1F1E7}', MH: '\u{1F1F2}\u{1F1ED}', FM: '\u{1F1EB}\u{1F1F2}', KI: '\u{1F1F0}\u{1F1EE}', TV: '\u{1F1F9}\u{1F1FB}', MX: '\u{1F1F2}\u{1F1FD}' };
const COUNTRY_LIST = ['IT'];
window.filterMuniList = function(input) {
var query = input.value.toLowerCase();
var container = input.closest('.popup-section');
var rows = container.querySelectorAll('.popup-muni-row');
var activeFilter = container.querySelector('.popup-filter-chip.active');
var provFilter = activeFilter ? activeFilter.dataset.provider : null;
for (var i = 0; i < rows.length; i++) {
var nameMatch = rows[i].dataset.name.indexOf(query) >= 0;
var provMatch = !provFilter || rows[i].dataset.prov === provFilter;
rows[i].style.display = (nameMatch && provMatch) ? '' : 'none';
}
};
window.toggleProviderFilter = function(chip) {
var wasActive = chip.classList.contains('active');
// Deactivate all chips in this group
var chips = chip.parentElement.querySelectorAll('.popup-filter-chip');
for (var i = 0; i < chips.length; i++) {
chips[i].classList.remove('active');
chips[i].style.background = '#fff';
}
if (!wasActive) {
chip.classList.add('active');
chip.style.background = chip.style.borderColor;
}
// Apply filter
var container = chip.closest('.popup-section');
var provFilter = !wasActive ? chip.dataset.provider : null;
var searchInput = container.querySelector('.popup-search');
var query = searchInput ? searchInput.value.toLowerCase() : '';
var rows = container.querySelectorAll('.popup-muni-row');
for (var i = 0; i < rows.length; i++) {
var nameMatch = !query || rows[i].dataset.name.indexOf(query) >= 0;
var provMatch = !provFilter || rows[i].dataset.prov === provFilter;
rows[i].style.display = (nameMatch && provMatch) ? '' : 'none';
}
};
const US_PROVIDERS = new Set(['Microsoft', 'Google', 'AWS']);
function hasLocalGateway(m) {
return m.gateway && (m.mx_countries || []).includes(m.country) && US_PROVIDERS.has(m.classification.provider);
}
// World region hierarchy for stats panel
const WORLD_REGIONS = {
'Europe': ['nordic','baltic','western','central','southern','eastern'],
'Africa': ['nafrica','wafrica','cafrica','eafrica','safrica'],
'Americas': ['namerica','camerica','caribbean','samerica'],
'Asia': ['sasia','seasia','easia','casia'],
'Middle East': ['mideast'],
'Oceania': ['oceania'],
};
// Map sub-region codes to display names
const SUB_REGION_NAMES = {
nordic:'Nordic', baltic:'Baltic', western:'Western', central:'Central',
southern:'Southern', eastern:'Eastern', nafrica:'North', wafrica:'West',
cafrica:'Central', eafrica:'East', safrica:'Southern', namerica:'North America',
camerica:'Central America', caribbean:'Caribbean', samerica:'South America',
sasia:'South', seasia:'Southeast', easia:'East', casia:'Central',
mideast:'Middle East', oceania:'Oceania',
};
let statsMode = 'count'; // 'count' or 'pop'
// Build sub-region → countries mapping from DOM
function getSubRegionCountries() {
const map = {};
document.querySelectorAll('.region-group').forEach(function(group) {
group.querySelectorAll('.region-label').forEach(function(label) {
var region = label.dataset.region;
var countries = [];
var sibling = label.nextElementSibling;
while (sibling && sibling.classList.contains('country-btn')) {
countries.push(sibling.dataset.country);
sibling = sibling.nextElementSibling;
}
if (countries.length) map[region] = countries;
});
});
return map;
}
var _subRegionCountries = null;
function subRegionCountries() {
if (!_subRegionCountries) _subRegionCountries = getSubRegionCountries();
return _subRegionCountries;
}
const INACTIVE_STYLE = { fillColor: '#f0f0f0', weight: 0.5, color: '#ccc', fillOpacity: 0.3 };
function hexToRgb(hex) {
var n = parseInt(hex.slice(1), 16);
return [(n >> 16) & 255, (n >> 8) & 255, n & 255];
}
function rgbToHex(r, g, b) {
return '#' + ((1 << 24) + (Math.round(r) << 16) + (Math.round(g) << 8) + Math.round(b)).toString(16).slice(1);
}
function blendProviderColors(providers, total) {
// Weighted blend of all provider colors by their share
var r = 0, g = 0, b = 0;
for (var p in providers) {
var color = COLORS[p] || COLORS['Unknown'];
var rgb = hexToRgb(color);
var weight = providers[p] / total;
r += rgb[0] * weight;
g += rgb[1] * weight;
b += rgb[2] * weight;
}
return rgbToHex(r, g, b);
}
// --- State ---
let dnsData = null;
let manifest = null;
let regionData = null; // data-regions.json (lightweight)
let summaryLoaded = false; // true once data-summary.json loaded
let summaryLoadPromise = null; // dedup in-flight loads
const countryData = {}; // cc -> [municipality, ...] (per-country on-demand)
let currentLevel = 'region';
// Filtro sovranità MX (null = tutte). Colora le aree per quota di giurisdizione.
let activeJurisdiction = null;
const JURIS_FILL = { domestic: '#009246', foreign: '#D42E2E', mixed: '#E8A33D' };
const topoCache = {}; // cacheKey -> parsed TopoJSON
const countryLayers = new Map(); // "EE" -> L.geoJSON layer
let gatewayMarkers = L.layerGroup();
let dominanceMarkers = L.layerGroup();
let updateLegend = function () {};
let activeCountries = new Set(COUNTRY_LIST);
let muniByOsm = {}; // "relation/12345" -> municipality
let muniByName = {}; // lowercase name -> municipality
// --- Map ---
// REVERTED 2026-05-06: removed maxBounds + maxBoundsViscosity entirely.
// They were introduced for "Italy-only viewport" branding but caused a
// regression where popups opened near the bbox edge had their top
// clipped behind the brand bar — Leaflet's autoPan was trying to shift
// the map past the hard bound and could not. The map now pans freely.
// Italy-only branding is preserved by:
// - tile layer .foreign-faded CSS filter (saturate 0)
// - center+zoom defaults pointing at Italy on initial load
// - region/province/comune boundary layers cover only Italy
const map = L.map('map', {
center: [42.5, 12.5],
zoom: 6,
minZoom: 5,
maxZoom: 14,
renderer: L.canvas()
});
window._map = map; // expose for debugging
// Use grayscale, label-free tiles so foreign countries fade into the
// background; the Italian polygons stay vivid on top. CSS filter (further
// down in <style>) desaturates them.
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OSM</a> © <a href="https://carto.com/">CARTO</a>',
subdomains: 'abcd',
maxZoom: 19,
className: 'foreign-faded',
}).addTo(map);
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}{r}.png', {
subdomains: 'abcd',
maxZoom: 19,
pane: 'shadowPane',
className: 'foreign-faded',
}).addTo(map);
var resizeTimer;
window.addEventListener('resize', function () {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () { map.invalidateSize({ animate: false }); }, 100);
});
// --- Info bar toggle ---
function collapsePanel(id, btnId, label) {
document.getElementById(id).classList.add('collapsed');
const b = document.getElementById(btnId);
b.innerHTML = label + ' \u25be';
b.setAttribute('aria-expanded', 'false');
}
function toggleInfo() {
const bar = document.getElementById('info-bar');
const btn = document.getElementById('toggle-info');
const wasCollapsed = bar.classList.contains('collapsed');
bar.classList.toggle('collapsed');
const collapsed = bar.classList.contains('collapsed');
btn.innerHTML = collapsed ? 'Informazioni \u25be' : 'Informazioni \u25b4';
btn.setAttribute('aria-expanded', String(!collapsed));
map.invalidateSize({ animate: false });
}
document.getElementById('toggle-info').addEventListener('click', toggleInfo);
// Il tab "Statistiche" naviga alla pagina dedicata (statistiche.html), non pi\u00f9
// un pannello inline. La pagina ha il link "\u2190 Torna alla mappa".
document.getElementById('toggle-stats').addEventListener('click', function () {
window.location.href = 'statistiche.html';
});
// --- Legend ---
function toggleLegend() {
const legend = document.querySelector('.legend');
const btn = legend.querySelector('.legend-toggle');
legend.classList.toggle('legend-collapsed');
const collapsed = legend.classList.contains('legend-collapsed');
btn.textContent = collapsed ? 'Legenda \u25B8' : '\u2715';
btn.setAttribute('aria-expanded', String(!collapsed));
}
function legendItemHtml(key, counts, total) {
const bg = key === 'Unknown'
? "background:#BFBFBF"
: `background:${COLORS[key]}`;
const n = counts[key] || 0;
const pct = total > 0 ? (n / total * 100) : 0;
// 1 decimal under 10%, integer otherwise — readable + tabular alignment
const pctStr = pct >= 10 ? Math.round(pct) + '%' : pct.toFixed(1) + '%';
return `<i style="${bg}"></i>${key} (${n.toLocaleString('it-IT')}) - (${pctStr})`;
}
function legendGroupHtml(label, keys, counts) {
const visible = keys.filter(k => (counts[k] || 0) > 0);
if (visible.length === 0) return '';
// Total = sum of ALL counts in this updateLegend call (passed as
// counts[__total__] from updateLegend) so percentages are over the
// whole denominator (regions / province / scuole / enti) shown in
// the footer, not just over the items in this group.
const total = counts.__total__ || Object.values(counts).reduce((a, b) => a + (b || 0), 0);
const heading = label ? `<span class="legend-group-label">${label}</span>` : '';
const items = visible.map(k => legendItemHtml(k, counts, total)).join('<br>');
return `<div class="legend-group">${heading}${items}</div>`;
}
// --- Stats panel (always municipality-level) ---
function buildStats(muniList) {
const content = document.getElementById('stats-content');
if (!content) return;
const filtered = muniList.filter(m => activeCountries.has(m.country));
const total = filtered.length;
if (total === 0) { content.innerHTML = '<p style="color:#999">Nessun ente selezionato.</p>'; return; }
const withMx = filtered.filter(m => m.has_mx || (m.mx || []).length > 0).length;
const usProviders = new Set(['Microsoft', 'Google', 'AWS']);
const countryColors = { US: '#E83838', EE: '#2EDBA8', LV: '#34D5A0', LT: '#78FFD6', DE: '#6BA3D6', DK: '#4FC3D6', NL: '#6BA3D6', FI: '#6BA3D6', SE: '#56E8B0', IE: '#6BA3D6', NO: '#10B898', IS: '#20C8A0', AD: '#56C8B0', LU: '#4DB8A8', BE: '#3DA898', AT: '#5DBCA0', CZ: '#4EB8A8', SK: '#45B0A0', SI: '#52C498', ES: '#E8A040', FR: '#4088E8', PT: '#40A8E8', IT: '#50B868', BG: '#58A878', GB: '#4090D0', HR: '#48B890', CY: '#60C870', GR: '#3880D0', HU: '#55A8B0', MT: '#68C890', RO: '#4898C0', AL: '#50B0A0', XK: '#58B8A8', ME: '#45A898', BA: '#4CA0A0', RS: '#52A8A0', MK: '#48B0A8', UA: '#3090D8', MD: '#4898B0', LI: '#60C0A0', SM: '#58B890', GE: '#40A0C0', AM: '#5098B0', AZ: '#48A8B8', BY: '#3888C0', TR: '#D88040', MC: '#60B8A0', GL: '#58C8E0', AU: '#E8C840', NZ: '#48D898', FJ: '#4080C0', WS: '#30A878', VU: '#48B8A0', TO: '#C84040', NR: '#3878A0', PW: '#58C0D0', ID: '#D06840', PG: '#60A068', MY: '#4090C8', TH: '#D8A830', KH: '#3878B8', PH: '#5088D0', VN: '#D04848', MM: '#48A870', JP: '#E84060', TW: '#4080C0', KR: '#3070B0', KP: '#C04040', CN: '#D05050', MN: '#4890A0', IN: '#E89030', BD: '#30A050', PK: '#20803E', LK: '#8B4513', NP: '#DC143C', LA: '#002868', BN: '#D0B020', TL: '#BE0027', KZ: '#00AFCA', UZ: '#1EB53A', KG: '#E8112D', RU: '#0039A6', SA: '#006C35', IQ: '#A06830', JO: '#B87840', LB: '#C04848', KW: '#007A3D', IR: '#C8A030', IL: '#0038B8', OM: '#C09050', AE: '#4098D0', QA: '#8040A0', BH: '#D07050', AR: '#75AADB', BO: '#D52B1E', BR: '#009B3A', CL: '#D52B1E', CO: '#FCD116', EC: '#FFD100', GY: '#009E49', PE: '#D91023', PY: '#0038A8', SR: '#377E3F', UY: '#5089C6', VE: '#CF142B', DZ: '#006633', EG: '#C8102E', LY: '#000000', MA: '#C1272D', TN: '#E70013', SD: '#007229', BJ: '#E8D71E', BF: '#009E49', CV: '#003893', CI: '#F77F00', GM: '#3A7728', GH: '#006B3F', GN: '#CE1126', GW: '#CE1126', LR: '#002868', ML: '#14B53A', MR: '#006233', NE: '#E05206', NG: '#008751', SN: '#00853F', SL: '#1EB53A', TG: '#006A4E', CM: '#007A5E', CF: '#003082', TD: '#002664', CG: '#009543', CD: '#007FFF', GQ: '#3E9A00', GA: '#009E60', ST: '#12AD2B', BI: '#CE1126', KM: '#3A75C4', DJ: '#6AB2E7', ER: '#4189DD', ET: '#FCDD09', KE: '#BB0000', MG: '#FC3D32', MW: '#CE1126', MU: '#00A551', MZ: '#FFD100', RW: '#00A1DE', SC: '#003DA5', SO: '#4189DD', SS: '#078930', TZ: '#1EB53A', UG: '#D90000', AO: '#CC092F', BW: '#75AADB', SZ: '#3E5EB9', LS: '#00209F', NA: '#003580', ZA: '#007749', ZM: '#198A00', ZW: '#FFD200', CA: '#FF0000', BZ: '#003DA5', GT: '#4997D0', HN: '#0038A8', SV: '#0F47AF', NI: '#003893', CR: '#002B7F', PA: '#003DA5', CU: '#002A8F', HT: '#00209F', DO: '#002D62', JM: '#009B3A', TT: '#CE1126', BS: '#00778B', BB: '#00267F', AG: '#CE1126', DM: '#006B3F', GD: '#CE1126', KN: '#009E49', LC: '#65CFFF', VC: '#0072C6', AF: '#009900', SG: '#EF3340', YE: '#CE1126', SY: '#CE1126', PS: '#009736', TJ: '#006600', TM: '#28AE66', MV: '#D21034', BT: '#FF4E12', SB: '#0051A5', MH: '#003DA5', FM: '#75B2DD', KI: '#CE1126', TV: '#009FCA', MX: '#006847' };
const sectionTitle = '<div style="font-size:12px;color:#777;text-transform:uppercase;letter-spacing:0.3px;font-weight:600;margin-bottom:4px">';
function barHtml(label, value, max, color, base) {
base = base || total;
const pct = max > 0 ? (value / max * 100) : 0;
const pctLabel = (value / base * 100).toFixed(0);
return `<div class="stats-row">` +
`<span class="stats-label">${escapeHtml(label)}</span>` +
`<div class="stats-bar-bg"><div class="stats-bar" style="width:${pct}%;background:${color}"></div></div>` +
`<span class="stats-value">${value} (${pctLabel}%)</span></div>`;
}
function computeStats(list) {
const t = list.length;
let us = 0, usLocalGw = 0, sameCountry = 0, otherRegion = 0, unk = 0;
const providers = {};
const mxCountries = {};
const ispNames = {};
let mxUs = 0, mxLocal = 0;
for (const m of list) {
const p = m.classification.provider;
providers[p] = (providers[p] || 0) + 1;
if (m.isp_name && (p === 'Local Provider')) {
ispNames[m.isp_name] = (ispNames[m.isp_name] || 0) + 1;
}
if (usProviders.has(p)) {
us++;
if (hasLocalGateway(m)) usLocalGw++;
}
else if (p === 'Unknown') unk++;
else {
const cc = m.mx_countries || [];
if (cc.includes(m.country)) sameCountry++;
else otherRegion++;
}
for (const cc of (m.mx_countries || [])) {
mxCountries[cc] = (mxCountries[cc] || 0) + 1;
}
const cc = m.mx_countries || [];
if (cc.includes('US')) mxUs++;
if (cc.some(c => COUNTRY_LIST.includes(c))) mxLocal++;
}
return { total: t, us, usLocalGw, sameCountry, otherRegion, unk, providers, mxCountries, ispNames, mxUs, mxLocal };
}
function jurisdictionHtml(stats, max) {
let h = '';
h += barHtml('USA', stats.us, max, '#E83838', stats.total);
if (stats.usLocalGw > 0) {
h += `<div style="margin:-2px 0 4px 100px;font-size:11px;color:#795548">\u{1F6E1}\uFE0F ${stats.usLocalGw} via local gateway</div>`;
}
h += barHtml('Italia', stats.sameCountry, max, '#0E9680', stats.total);
if (stats.otherRegion > 0) h += barHtml('Altra regione', stats.otherRegion, max, '#2EDBA8', stats.total);
if (stats.unk > 0) h += barHtml('Sconosciuto', stats.unk, max, '#BFBFBF', stats.total);
return h;
}
function mxLocationHtml(stats, max) {
const entries = Object.entries(stats.mxCountries).sort((a, b) => b[1] - a[1]);
let h = '';
for (const [cc, count] of entries.slice(0, 6)) {
h += barHtml(cc, count, max, countryColors[cc] || '#888', stats.total);
}
return h;
}
function providerHtml(stats, max) {
const entries = Object.entries(stats.providers).sort((a, b) => b[1] - a[1]);
let h = '';
for (const [p, count] of entries) {
const color = COLORS[p] || '#888';
h += barHtml(p, count, max, color, stats.total);
}
return h;
}
// Overall stats
const allStats = computeStats(filtered);
let html = '<h3 style="margin:0 0 8px;font-size:14px;color:#555">Overall</h3>';
html += '<div class="stats-columns"><div class="stats-column">';
html += sectionTitle + 'Giurisdizione del provider</div>';
html += jurisdictionHtml(allStats, total);
html += '</div><div class="stats-column">';
html += sectionTitle + 'Localizzazione server MX (per IP)</div>';
html += mxLocationHtml(allStats, Math.max(...Object.values(allStats.mxCountries), 1));
html += '</div><div class="stats-column">';
html += sectionTitle + 'Provider</div>';
html += providerHtml(allStats, Math.max(...Object.values(allStats.providers), 1));
html += '</div></div>';
const mxInUs = allStats.mxUs;
html += `<p style="font-size:12px;color:#777;margin-top:8px"><strong>${mxInUs}</strong> of ${withMx} municipalities with MX records route mail through servers registered in the US.</p>`;
// Per-country breakdown
const countryNames = { EE: 'Estonia', LV: 'Latvia', LT: 'Lithuania', FI: 'Finland', NO: 'Norway', IS: 'Iceland', SE: 'Sweden', DE: 'Germany', DK: 'Denmark', AD: 'Andorra', LU: 'Luxembourg', BE: 'Belgium', AT: 'Austria', CZ: 'Czechia', SK: 'Slovakia', SI: 'Slovenia', ES: 'Spain', FR: 'France', PL: 'Poland', PT: 'Portugal', IT: 'Italy', IE: 'Ireland', NL: 'Netherlands', BG: 'Bulgaria', GB: 'United Kingdom', HR: 'Croatia', CY: 'Cyprus', GR: 'Greece', HU: 'Hungary', MT: 'Malta', RO: 'Romania', AL: 'Albania', XK: 'Kosovo', ME: 'Montenegro', BA: 'Bosnia and Herzegovina', RS: 'Serbia', MK: 'North Macedonia', UA: 'Ukraine', MD: 'Moldova', LI: 'Liechtenstein', SM: 'San Marino', GE: 'Georgia', AM: 'Armenia', AZ: 'Azerbaijan', BY: 'Belarus', TR: 'Turkey', MC: 'Monaco', GL: 'Greenland', AU: 'Australia', NZ: 'New Zealand', FJ: 'Fiji', WS: 'Samoa', VU: 'Vanuatu', TO: 'Tonga', NR: 'Nauru', PW: 'Palau', ID: 'Indonesia', PG: 'Papua New Guinea', MY: 'Malaysia', TH: 'Thailand', KH: 'Cambodia', PH: 'Philippines', VN: 'Vietnam', MM: 'Myanmar', JP: 'Japan', TW: 'Taiwan', KR: 'South Korea', KP: 'North Korea', CN: 'China', MN: 'Mongolia', IN: 'India', BD: 'Bangladesh', PK: 'Pakistan', LK: 'Sri Lanka', NP: 'Nepal', LA: 'Laos', BN: 'Brunei', TL: 'Timor-Leste', KZ: 'Kazakhstan', UZ: 'Uzbekistan', KG: 'Kyrgyzstan', RU: 'Russia', SA: 'Saudi Arabia', IQ: 'Iraq', JO: 'Jordan', LB: 'Lebanon', KW: 'Kuwait', IR: 'Iran', IL: 'Israel', OM: 'Oman', AE: 'UAE', QA: 'Qatar', BH: 'Bahrain', AR: 'Argentina', BO: 'Bolivia', BR: 'Brazil', CL: 'Chile', CO: 'Colombia', EC: 'Ecuador', GY: 'Guyana', PE: 'Peru', PY: 'Paraguay', SR: 'Suriname', UY: 'Uruguay', VE: 'Venezuela', DZ: 'Algeria', EG: 'Egypt', LY: 'Libya', MA: 'Morocco', TN: 'Tunisia', SD: 'Sudan', BJ: 'Benin', BF: 'Burkina Faso', CV: 'Cape Verde', CI: "Côte d'Ivoire", GM: 'Gambia', GH: 'Ghana', GN: 'Guinea', GW: 'Guinea-Bissau', LR: 'Liberia', ML: 'Mali', MR: 'Mauritania', NE: 'Niger', NG: 'Nigeria', SN: 'Senegal', SL: 'Sierra Leone', TG: 'Togo', CM: 'Cameroon', CF: 'Central African Republic', TD: 'Chad', CG: 'Congo', CD: 'DR Congo', GQ: 'Equatorial Guinea', GA: 'Gabon', ST: 'São Tomé and Príncipe', BI: 'Burundi', KM: 'Comoros', DJ: 'Djibouti', ER: 'Eritrea', ET: 'Ethiopia', KE: 'Kenya', MG: 'Madagascar', MW: 'Malawi', MU: 'Mauritius', MZ: 'Mozambique', RW: 'Rwanda', SC: 'Seychelles', SO: 'Somalia', SS: 'South Sudan', TZ: 'Tanzania', UG: 'Uganda', AO: 'Angola', BW: 'Botswana', SZ: 'Eswatini', LS: 'Lesotho', NA: 'Namibia', ZA: 'South Africa', ZM: 'Zambia', ZW: 'Zimbabwe', CA: 'Canada', BZ: 'Belize', GT: 'Guatemala', HN: 'Honduras', SV: 'El Salvador', NI: 'Nicaragua', CR: 'Costa Rica', PA: 'Panama', CU: 'Cuba', HT: 'Haiti', DO: 'Dominican Republic', JM: 'Jamaica', TT: 'Trinidad and Tobago', BS: 'Bahamas', BB: 'Barbados', AG: 'Antigua and Barbuda', DM: 'Dominica', GD: 'Grenada', KN: 'Saint Kitts and Nevis', LC: 'Saint Lucia', VC: 'Saint Vincent and the Grenadines', AF: 'Afghanistan', SG: 'Singapore', YE: 'Yemen', SY: 'Syria', PS: 'Palestine', TJ: 'Tajikistan', TM: 'Turkmenistan', MV: 'Maldives', BT: 'Bhutan', SB: 'Solomon Islands', MH: 'Marshall Islands', FM: 'Micronesia', KI: 'Kiribati', TV: 'Tuvalu', MX: 'Mexico' };
const activeList = COUNTRY_LIST.filter(cc => activeCountries.has(cc));
const countryStats = {};
for (const cc of activeList) {
const list = filtered.filter(m => m.country === cc);
if (list.length > 0) countryStats[cc] = computeStats(list);
}
if (Object.keys(countryStats).length > 0) {
html += '<div style="border-top:1px solid #ddd;margin-top:12px;padding-top:12px">';
html += sectionTitle + 'Per regione</div>';
html += '<div class="stats-countries">';
for (const cc of activeList) {
const stats = countryStats[cc];
if (!stats) continue;
const topProviders = Object.entries(stats.providers).sort((a, b) => b[1] - a[1]).slice(0, 4);
const topMx = Object.entries(stats.mxCountries).sort((a, b) => b[1] - a[1]).slice(0, 3);
html += `<div class="stats-column">`;
html += `<div style="font-size:13px;font-weight:600;color:#444;margin-bottom:8px">${FLAGS[cc] || ''} ${countryNames[cc]} (${stats.total})</div>`;
html += barHtml('USA', stats.us, stats.total, '#E83838', stats.total);
html += barHtml('Italia', stats.sameCountry, stats.total, '#0E9680', stats.total);
if (stats.otherRegion > 0) html += barHtml('Altra regione', stats.otherRegion, stats.total, '#2EDBA8', stats.total);
html += `<div style="margin-top:12px;font-size:11px;color:#999;font-weight:600">TOP PROVIDERS</div>`;
for (const [p, count] of topProviders) {
html += barHtml(p, count, topProviders[0][1], COLORS[p] || '#888', stats.total);
}
html += `<div style="margin-top:12px;font-size:11px;color:#999;font-weight:600">MX SERVERS</div>`;
for (const [loc, count] of topMx) {
html += barHtml(loc, count, topMx[0][1], countryColors[loc] || '#888', stats.total);
}
const topIsps = Object.entries(stats.ispNames).sort((a, b) => b[1] - a[1]).slice(0, 4);
if (topIsps.length > 0) {
html += `<div style="margin-top:12px;font-size:11px;color:#999;font-weight:600">LOCAL PROVIDERS</div>`;
for (const [name, count] of topIsps) {
html += barHtml(name, count, topIsps[0][1], '#10B898', stats.total);
}
}
html += '</div>';
}
html += '</div></div>';
}
content.innerHTML = html;
}
// --- Feature matching ---
// Namespace prefix consentiti nella vista 'municipality' per ogni paese.
// Per IT: solo IT-COM-* (veri comuni). Le entry IT-CONS-*, IT-C*-*, IT-L*-*
// (consorzi, enti centrali, scuole, ASL, ordini professionali, ecc.) NON
// devono mai apparire nella vista comuni anche se per qualche motivo
// fossero entrate in muniByOsm (es. bug futuro che dimentica di strippare
// osm_relation_id). Requisito stringente: la vista comuni mostra SOLO comuni.
const MUNICIPALITY_VIEW_ALLOWED_PREFIX = {
'IT': 'IT-COM-',
};
function isAllowedInMunicipalityView(m) {
if (!m) return false;
const allowedPrefix = MUNICIPALITY_VIEW_ALLOWED_PREFIX[m.country];
if (!allowedPrefix) return true; // paesi senza filtro esplicito (tutti i Baltic)
const id = m.bfs || m.id || '';
return id.startsWith(allowedPrefix);
}
function matchFeature(feature) {
const props = feature.properties || {};
const osmId = feature.id || props.id || '';
let candidate = null;
if (osmId && muniByOsm[osmId]) candidate = muniByOsm[osmId];
if (!candidate) {
for (const key of ['name', 'name_en', 'name:en']) {
const name = (props[key] || '').toLowerCase();
if (name && muniByName[name]) { candidate = muniByName[name]; break; }
}
}
if (!candidate) return null;
// Guard finale: nella vista 'municipality' rifiutiamo entry che non
// corrispondono al namespace dei veri comuni per quel paese.
if (currentLevel === 'municipality' && !isAllowedInMunicipalityView(candidate)) {
return null;
}
return candidate;
}
function escapeHtml(str) {
const el = document.createElement('span');
el.textContent = str;
return el.innerHTML;
}
// --- Aggregation ---
function getGroupKey(m, fileLevelName) {
if (fileLevelName === 'region') return m.regione || m.region || m.canton || '';
if (fileLevelName === 'district') {
if (m.country === 'AT') return m.id.substring(0, 6);
if (m.country === 'BE') return m.id.substring(0, 5);
if (m.country === 'DE') return m.id.substring(0, 8); // "DE-01001" (5-digit Kreis)
if (m.country === 'GB') return m.district || m.name;
// IT: raggruppa per la sigla provincia pulita (enrich_geo, 100%); il vecchio
// `district` del seed era al 34%. I poligoni si matchano per sigla in
// matchGroupFeature (ISO3166-2 / short_name).
if (m.country === 'IT') return m.provincia || m.district || m.region || '';
return m.region || '';
}
// Countries with province-only topo: always group by region
if (['PG', 'KH', 'OM', 'PH'].includes(m.country)) return m.region || '';
return m.id;
}
function computeAggregation(cc, fileLevelName) {
// Fast path: use pre-computed region/district/istruzione data
if ((!summaryLoaded || fileLevelName === 'istruzione') && regionData) {
const cd = regionData.countries[cc];
if (!cd) return {};
const result = {};
// ISTRUZIONE branch: keyed by topo feature id "relation/<osm>" instead
// of region/district name. Built by aggregate_istruzione_per_comune.py.
if (fileLevelName === 'istruzione' && cd.istruzione_by_osm) {
for (const featId of Object.keys(cd.istruzione_by_osm)) {
const r = cd.istruzione_by_osm[featId];
const sorted = Object.entries(r.providers || {}).sort((a,b) => b[1]-a[1]);
result[featId] = {
name: r.name || featId,
municipalities: [],
providers: r.providers || {},
popProviders: r.popProviders || r.providers || {},
dominant: r.dominant,
dominance: r.dominance,
second: sorted.length > 1 ? sorted[1][0] : null,
blendedColor: r.blendedColor,
popTotal: r.school_count || 0,
count: r.school_count || 0,
hasGateway: false,
isIstruzione: true,
};
}
return result;
}
// Pick which slice of pre-computed data to use, based on the level
// we're rendering. Districts may be absent for countries that didn't
// emit a district-level aggregation -> fall back to regions.
var groupSet = (fileLevelName === 'district' && cd.districts && Object.keys(cd.districts).length > 0)
? cd.districts
: cd.regions;
for (const gname of Object.keys(groupSet)) {
const r = groupSet[gname];
const sorted = Object.entries(r.providers).sort((a,b) => b[1]-a[1]);
result[gname] = {
name: gname,