kilfx 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2033 @@
1
+ // src/data/countries.json
2
+ var countries_default = [
3
+ {
4
+ name: "Afghanistan",
5
+ dial_code: "+93",
6
+ code: "AF"
7
+ },
8
+ {
9
+ name: "Aland Islands",
10
+ dial_code: "+358",
11
+ code: "AX"
12
+ },
13
+ {
14
+ name: "Albania",
15
+ dial_code: "+355",
16
+ code: "AL"
17
+ },
18
+ {
19
+ name: "Algeria",
20
+ dial_code: "+213",
21
+ code: "DZ"
22
+ },
23
+ {
24
+ name: "AmericanSamoa",
25
+ dial_code: "+1 684",
26
+ code: "AS"
27
+ },
28
+ {
29
+ name: "Andorra",
30
+ dial_code: "+376",
31
+ code: "AD"
32
+ },
33
+ {
34
+ name: "Angola",
35
+ dial_code: "+244",
36
+ code: "AO"
37
+ },
38
+ {
39
+ name: "Anguilla",
40
+ dial_code: "+1 264",
41
+ code: "AI"
42
+ },
43
+ {
44
+ name: "Antarctica",
45
+ dial_code: "+672",
46
+ code: "AQ"
47
+ },
48
+ {
49
+ name: "Antigua and Barbuda",
50
+ dial_code: "+1268",
51
+ code: "AG"
52
+ },
53
+ {
54
+ name: "Argentina",
55
+ dial_code: "+54",
56
+ code: "AR"
57
+ },
58
+ {
59
+ name: "Armenia",
60
+ dial_code: "+374",
61
+ code: "AM"
62
+ },
63
+ {
64
+ name: "Aruba",
65
+ dial_code: "+297",
66
+ code: "AW"
67
+ },
68
+ {
69
+ name: "Australia",
70
+ dial_code: "+61",
71
+ code: "AU"
72
+ },
73
+ {
74
+ name: "Austria",
75
+ dial_code: "+43",
76
+ code: "AT"
77
+ },
78
+ {
79
+ name: "Azerbaijan",
80
+ dial_code: "+994",
81
+ code: "AZ"
82
+ },
83
+ {
84
+ name: "Bahamas",
85
+ dial_code: "+1 242",
86
+ code: "BS"
87
+ },
88
+ {
89
+ name: "Bahrain",
90
+ dial_code: "+973",
91
+ code: "BH"
92
+ },
93
+ {
94
+ name: "Bangladesh",
95
+ dial_code: "+880",
96
+ code: "BD"
97
+ },
98
+ {
99
+ name: "Barbados",
100
+ dial_code: "+1 246",
101
+ code: "BB"
102
+ },
103
+ {
104
+ name: "Belarus",
105
+ dial_code: "+375",
106
+ code: "BY"
107
+ },
108
+ {
109
+ name: "Belgium",
110
+ dial_code: "+32",
111
+ code: "BE"
112
+ },
113
+ {
114
+ name: "Belize",
115
+ dial_code: "+501",
116
+ code: "BZ"
117
+ },
118
+ {
119
+ name: "Benin",
120
+ dial_code: "+229",
121
+ code: "BJ"
122
+ },
123
+ {
124
+ name: "Bermuda",
125
+ dial_code: "+1 441",
126
+ code: "BM"
127
+ },
128
+ {
129
+ name: "Bhutan",
130
+ dial_code: "+975",
131
+ code: "BT"
132
+ },
133
+ {
134
+ name: "Bolivia, Plurinational State of",
135
+ dial_code: "+591",
136
+ code: "BO"
137
+ },
138
+ {
139
+ name: "Bosnia and Herzegovina",
140
+ dial_code: "+387",
141
+ code: "BA"
142
+ },
143
+ {
144
+ name: "Botswana",
145
+ dial_code: "+267",
146
+ code: "BW"
147
+ },
148
+ {
149
+ name: "Brazil",
150
+ dial_code: "+55",
151
+ code: "BR"
152
+ },
153
+ {
154
+ name: "British Indian Ocean Territory",
155
+ dial_code: "+246",
156
+ code: "IO"
157
+ },
158
+ {
159
+ name: "Brunei Darussalam",
160
+ dial_code: "+673",
161
+ code: "BN"
162
+ },
163
+ {
164
+ name: "Bulgaria",
165
+ dial_code: "+359",
166
+ code: "BG"
167
+ },
168
+ {
169
+ name: "Burkina Faso",
170
+ dial_code: "+226",
171
+ code: "BF"
172
+ },
173
+ {
174
+ name: "Burundi",
175
+ dial_code: "+257",
176
+ code: "BI"
177
+ },
178
+ {
179
+ name: "Cambodia",
180
+ dial_code: "+855",
181
+ code: "KH"
182
+ },
183
+ {
184
+ name: "Cameroon",
185
+ dial_code: "+237",
186
+ code: "CM"
187
+ },
188
+ {
189
+ name: "Canada",
190
+ dial_code: "+1",
191
+ code: "CA"
192
+ },
193
+ {
194
+ name: "Cape Verde",
195
+ dial_code: "+238",
196
+ code: "CV"
197
+ },
198
+ {
199
+ name: "Cayman Islands",
200
+ dial_code: "+ 345",
201
+ code: "KY"
202
+ },
203
+ {
204
+ name: "Central African Republic",
205
+ dial_code: "+236",
206
+ code: "CF"
207
+ },
208
+ {
209
+ name: "Chad",
210
+ dial_code: "+235",
211
+ code: "TD"
212
+ },
213
+ {
214
+ name: "Chile",
215
+ dial_code: "+56",
216
+ code: "CL"
217
+ },
218
+ {
219
+ name: "China",
220
+ dial_code: "+86",
221
+ code: "CN"
222
+ },
223
+ {
224
+ name: "Christmas Island",
225
+ dial_code: "+61",
226
+ code: "CX"
227
+ },
228
+ {
229
+ name: "Cocos (Keeling) Islands",
230
+ dial_code: "+61",
231
+ code: "CC"
232
+ },
233
+ {
234
+ name: "Colombia",
235
+ dial_code: "+57",
236
+ code: "CO"
237
+ },
238
+ {
239
+ name: "Comoros",
240
+ dial_code: "+269",
241
+ code: "KM"
242
+ },
243
+ {
244
+ name: "Congo",
245
+ dial_code: "+242",
246
+ code: "CG"
247
+ },
248
+ {
249
+ name: "Congo, The Democratic Republic of the Congo",
250
+ dial_code: "+243",
251
+ code: "CD"
252
+ },
253
+ {
254
+ name: "Cook Islands",
255
+ dial_code: "+682",
256
+ code: "CK"
257
+ },
258
+ {
259
+ name: "Costa Rica",
260
+ dial_code: "+506",
261
+ code: "CR"
262
+ },
263
+ {
264
+ name: "Cote d'Ivoire",
265
+ dial_code: "+225",
266
+ code: "CI"
267
+ },
268
+ {
269
+ name: "Croatia",
270
+ dial_code: "+385",
271
+ code: "HR"
272
+ },
273
+ {
274
+ name: "Cuba",
275
+ dial_code: "+53",
276
+ code: "CU"
277
+ },
278
+ {
279
+ name: "Cyprus",
280
+ dial_code: "+357",
281
+ code: "CY"
282
+ },
283
+ {
284
+ name: "Czech Republic",
285
+ dial_code: "+420",
286
+ code: "CZ"
287
+ },
288
+ {
289
+ name: "Denmark",
290
+ dial_code: "+45",
291
+ code: "DK"
292
+ },
293
+ {
294
+ name: "Djibouti",
295
+ dial_code: "+253",
296
+ code: "DJ"
297
+ },
298
+ {
299
+ name: "Dominica",
300
+ dial_code: "+1 767",
301
+ code: "DM"
302
+ },
303
+ {
304
+ name: "Dominican Republic",
305
+ dial_code: "+1 849",
306
+ code: "DO"
307
+ },
308
+ {
309
+ name: "Ecuador",
310
+ dial_code: "+593",
311
+ code: "EC"
312
+ },
313
+ {
314
+ name: "Egypt",
315
+ dial_code: "+20",
316
+ code: "EG"
317
+ },
318
+ {
319
+ name: "El Salvador",
320
+ dial_code: "+503",
321
+ code: "SV"
322
+ },
323
+ {
324
+ name: "Equatorial Guinea",
325
+ dial_code: "+240",
326
+ code: "GQ"
327
+ },
328
+ {
329
+ name: "Eritrea",
330
+ dial_code: "+291",
331
+ code: "ER"
332
+ },
333
+ {
334
+ name: "Estonia",
335
+ dial_code: "+372",
336
+ code: "EE"
337
+ },
338
+ {
339
+ name: "Ethiopia",
340
+ dial_code: "+251",
341
+ code: "ET"
342
+ },
343
+ {
344
+ name: "Falkland Islands (Malvinas)",
345
+ dial_code: "+500",
346
+ code: "FK"
347
+ },
348
+ {
349
+ name: "Faroe Islands",
350
+ dial_code: "+298",
351
+ code: "FO"
352
+ },
353
+ {
354
+ name: "Fiji",
355
+ dial_code: "+679",
356
+ code: "FJ"
357
+ },
358
+ {
359
+ name: "Finland",
360
+ dial_code: "+358",
361
+ code: "FI"
362
+ },
363
+ {
364
+ name: "France",
365
+ dial_code: "+33",
366
+ code: "FR"
367
+ },
368
+ {
369
+ name: "French Guiana",
370
+ dial_code: "+594",
371
+ code: "GF"
372
+ },
373
+ {
374
+ name: "French Polynesia",
375
+ dial_code: "+689",
376
+ code: "PF"
377
+ },
378
+ {
379
+ name: "Gabon",
380
+ dial_code: "+241",
381
+ code: "GA"
382
+ },
383
+ {
384
+ name: "Gambia",
385
+ dial_code: "+220",
386
+ code: "GM"
387
+ },
388
+ {
389
+ name: "Georgia",
390
+ dial_code: "+995",
391
+ code: "GE"
392
+ },
393
+ {
394
+ name: "Germany",
395
+ dial_code: "+49",
396
+ code: "DE"
397
+ },
398
+ {
399
+ name: "Ghana",
400
+ dial_code: "+233",
401
+ code: "GH"
402
+ },
403
+ {
404
+ name: "Gibraltar",
405
+ dial_code: "+350",
406
+ code: "GI"
407
+ },
408
+ {
409
+ name: "Greece",
410
+ dial_code: "+30",
411
+ code: "GR"
412
+ },
413
+ {
414
+ name: "Greenland",
415
+ dial_code: "+299",
416
+ code: "GL"
417
+ },
418
+ {
419
+ name: "Grenada",
420
+ dial_code: "+1 473",
421
+ code: "GD"
422
+ },
423
+ {
424
+ name: "Guadeloupe",
425
+ dial_code: "+590",
426
+ code: "GP"
427
+ },
428
+ {
429
+ name: "Guam",
430
+ dial_code: "+1 671",
431
+ code: "GU"
432
+ },
433
+ {
434
+ name: "Guatemala",
435
+ dial_code: "+502",
436
+ code: "GT"
437
+ },
438
+ {
439
+ name: "Guernsey",
440
+ dial_code: "+44",
441
+ code: "GG"
442
+ },
443
+ {
444
+ name: "Guinea",
445
+ dial_code: "+224",
446
+ code: "GN"
447
+ },
448
+ {
449
+ name: "Guinea-Bissau",
450
+ dial_code: "+245",
451
+ code: "GW"
452
+ },
453
+ {
454
+ name: "Guyana",
455
+ dial_code: "+595",
456
+ code: "GY"
457
+ },
458
+ {
459
+ name: "Haiti",
460
+ dial_code: "+509",
461
+ code: "HT"
462
+ },
463
+ {
464
+ name: "Holy See (Vatican City State)",
465
+ dial_code: "+379",
466
+ code: "VA"
467
+ },
468
+ {
469
+ name: "Honduras",
470
+ dial_code: "+504",
471
+ code: "HN"
472
+ },
473
+ {
474
+ name: "Hong Kong",
475
+ dial_code: "+852",
476
+ code: "HK"
477
+ },
478
+ {
479
+ name: "Hungary",
480
+ dial_code: "+36",
481
+ code: "HU"
482
+ },
483
+ {
484
+ name: "Iceland",
485
+ dial_code: "+354",
486
+ code: "IS"
487
+ },
488
+ {
489
+ name: "India",
490
+ dial_code: "+91",
491
+ code: "IN"
492
+ },
493
+ {
494
+ name: "Indonesia",
495
+ dial_code: "+62",
496
+ code: "ID"
497
+ },
498
+ {
499
+ name: "Iran, Islamic Republic of Persian Gulf",
500
+ dial_code: "+98",
501
+ code: "IR"
502
+ },
503
+ {
504
+ name: "Iraq",
505
+ dial_code: "+964",
506
+ code: "IQ"
507
+ },
508
+ {
509
+ name: "Ireland",
510
+ dial_code: "+353",
511
+ code: "IE"
512
+ },
513
+ {
514
+ name: "Isle of Man",
515
+ dial_code: "+44",
516
+ code: "IM"
517
+ },
518
+ {
519
+ name: "Israel",
520
+ dial_code: "+972",
521
+ code: "IL"
522
+ },
523
+ {
524
+ name: "Italy",
525
+ dial_code: "+39",
526
+ code: "IT"
527
+ },
528
+ {
529
+ name: "Jamaica",
530
+ dial_code: "+1 876",
531
+ code: "JM"
532
+ },
533
+ {
534
+ name: "Japan",
535
+ dial_code: "+81",
536
+ code: "JP"
537
+ },
538
+ {
539
+ name: "Jersey",
540
+ dial_code: "+44",
541
+ code: "JE"
542
+ },
543
+ {
544
+ name: "Jordan",
545
+ dial_code: "+962",
546
+ code: "JO"
547
+ },
548
+ {
549
+ name: "Kazakhstan",
550
+ dial_code: "+7 7",
551
+ code: "KZ"
552
+ },
553
+ {
554
+ name: "Kenya",
555
+ dial_code: "+254",
556
+ code: "KE"
557
+ },
558
+ {
559
+ name: "Kiribati",
560
+ dial_code: "+686",
561
+ code: "KI"
562
+ },
563
+ {
564
+ name: "Korea, Democratic People's Republic of Korea",
565
+ dial_code: "+850",
566
+ code: "KP"
567
+ },
568
+ {
569
+ name: "Korea, Republic of South Korea",
570
+ dial_code: "+82",
571
+ code: "KR"
572
+ },
573
+ {
574
+ name: "Kuwait",
575
+ dial_code: "+965",
576
+ code: "KW"
577
+ },
578
+ {
579
+ name: "Kyrgyzstan",
580
+ dial_code: "+996",
581
+ code: "KG"
582
+ },
583
+ {
584
+ name: "Laos",
585
+ dial_code: "+856",
586
+ code: "LA"
587
+ },
588
+ {
589
+ name: "Latvia",
590
+ dial_code: "+371",
591
+ code: "LV"
592
+ },
593
+ {
594
+ name: "Lebanon",
595
+ dial_code: "+961",
596
+ code: "LB"
597
+ },
598
+ {
599
+ name: "Lesotho",
600
+ dial_code: "+266",
601
+ code: "LS"
602
+ },
603
+ {
604
+ name: "Liberia",
605
+ dial_code: "+231",
606
+ code: "LR"
607
+ },
608
+ {
609
+ name: "Libyan Arab Jamahiriya",
610
+ dial_code: "+218",
611
+ code: "LY"
612
+ },
613
+ {
614
+ name: "Liechtenstein",
615
+ dial_code: "+423",
616
+ code: "LI"
617
+ },
618
+ {
619
+ name: "Lithuania",
620
+ dial_code: "+370",
621
+ code: "LT"
622
+ },
623
+ {
624
+ name: "Luxembourg",
625
+ dial_code: "+352",
626
+ code: "LU"
627
+ },
628
+ {
629
+ name: "Macao",
630
+ dial_code: "+853",
631
+ code: "MO"
632
+ },
633
+ {
634
+ name: "Macedonia",
635
+ dial_code: "+389",
636
+ code: "MK"
637
+ },
638
+ {
639
+ name: "Madagascar",
640
+ dial_code: "+261",
641
+ code: "MG"
642
+ },
643
+ {
644
+ name: "Malawi",
645
+ dial_code: "+265",
646
+ code: "MW"
647
+ },
648
+ {
649
+ name: "Malaysia",
650
+ dial_code: "+60",
651
+ code: "MY"
652
+ },
653
+ {
654
+ name: "Maldives",
655
+ dial_code: "+960",
656
+ code: "MV"
657
+ },
658
+ {
659
+ name: "Mali",
660
+ dial_code: "+223",
661
+ code: "ML"
662
+ },
663
+ {
664
+ name: "Malta",
665
+ dial_code: "+356",
666
+ code: "MT"
667
+ },
668
+ {
669
+ name: "Marshall Islands",
670
+ dial_code: "+692",
671
+ code: "MH"
672
+ },
673
+ {
674
+ name: "Martinique",
675
+ dial_code: "+596",
676
+ code: "MQ"
677
+ },
678
+ {
679
+ name: "Mauritania",
680
+ dial_code: "+222",
681
+ code: "MR"
682
+ },
683
+ {
684
+ name: "Mauritius",
685
+ dial_code: "+230",
686
+ code: "MU"
687
+ },
688
+ {
689
+ name: "Mayotte",
690
+ dial_code: "+262",
691
+ code: "YT"
692
+ },
693
+ {
694
+ name: "Mexico",
695
+ dial_code: "+52",
696
+ code: "MX"
697
+ },
698
+ {
699
+ name: "Micronesia, Federated States of Micronesia",
700
+ dial_code: "+691",
701
+ code: "FM"
702
+ },
703
+ {
704
+ name: "Moldova",
705
+ dial_code: "+373",
706
+ code: "MD"
707
+ },
708
+ {
709
+ name: "Monaco",
710
+ dial_code: "+377",
711
+ code: "MC"
712
+ },
713
+ {
714
+ name: "Mongolia",
715
+ dial_code: "+976",
716
+ code: "MN"
717
+ },
718
+ {
719
+ name: "Montenegro",
720
+ dial_code: "+382",
721
+ code: "ME"
722
+ },
723
+ {
724
+ name: "Montserrat",
725
+ dial_code: "+1664",
726
+ code: "MS"
727
+ },
728
+ {
729
+ name: "Morocco",
730
+ dial_code: "+212",
731
+ code: "MA"
732
+ },
733
+ {
734
+ name: "Mozambique",
735
+ dial_code: "+258",
736
+ code: "MZ"
737
+ },
738
+ {
739
+ name: "Myanmar",
740
+ dial_code: "+95",
741
+ code: "MM"
742
+ },
743
+ {
744
+ name: "Namibia",
745
+ dial_code: "+264",
746
+ code: "NA"
747
+ },
748
+ {
749
+ name: "Nauru",
750
+ dial_code: "+674",
751
+ code: "NR"
752
+ },
753
+ {
754
+ name: "Nepal",
755
+ dial_code: "+977",
756
+ code: "NP"
757
+ },
758
+ {
759
+ name: "Netherlands",
760
+ dial_code: "+31",
761
+ code: "NL"
762
+ },
763
+ {
764
+ name: "Netherlands Antilles",
765
+ dial_code: "+599",
766
+ code: "AN"
767
+ },
768
+ {
769
+ name: "New Caledonia",
770
+ dial_code: "+687",
771
+ code: "NC"
772
+ },
773
+ {
774
+ name: "New Zealand",
775
+ dial_code: "+64",
776
+ code: "NZ"
777
+ },
778
+ {
779
+ name: "Nicaragua",
780
+ dial_code: "+505",
781
+ code: "NI"
782
+ },
783
+ {
784
+ name: "Niger",
785
+ dial_code: "+227",
786
+ code: "NE"
787
+ },
788
+ {
789
+ name: "Nigeria",
790
+ dial_code: "+234",
791
+ code: "NG"
792
+ },
793
+ {
794
+ name: "Niue",
795
+ dial_code: "+683",
796
+ code: "NU"
797
+ },
798
+ {
799
+ name: "Norfolk Island",
800
+ dial_code: "+672",
801
+ code: "NF"
802
+ },
803
+ {
804
+ name: "Northern Mariana Islands",
805
+ dial_code: "+1 670",
806
+ code: "MP"
807
+ },
808
+ {
809
+ name: "Norway",
810
+ dial_code: "+47",
811
+ code: "NO"
812
+ },
813
+ {
814
+ name: "Oman",
815
+ dial_code: "+968",
816
+ code: "OM"
817
+ },
818
+ {
819
+ name: "Pakistan",
820
+ dial_code: "+92",
821
+ code: "PK"
822
+ },
823
+ {
824
+ name: "Palau",
825
+ dial_code: "+680",
826
+ code: "PW"
827
+ },
828
+ {
829
+ name: "Palestinian Territory, Occupied",
830
+ dial_code: "+970",
831
+ code: "PS"
832
+ },
833
+ {
834
+ name: "Panama",
835
+ dial_code: "+507",
836
+ code: "PA"
837
+ },
838
+ {
839
+ name: "Papua New Guinea",
840
+ dial_code: "+675",
841
+ code: "PG"
842
+ },
843
+ {
844
+ name: "Paraguay",
845
+ dial_code: "+595",
846
+ code: "PY"
847
+ },
848
+ {
849
+ name: "Peru",
850
+ dial_code: "+51",
851
+ code: "PE"
852
+ },
853
+ {
854
+ name: "Philippines",
855
+ dial_code: "+63",
856
+ code: "PH"
857
+ },
858
+ {
859
+ name: "Pitcairn",
860
+ dial_code: "+872",
861
+ code: "PN"
862
+ },
863
+ {
864
+ name: "Poland",
865
+ dial_code: "+48",
866
+ code: "PL"
867
+ },
868
+ {
869
+ name: "Portugal",
870
+ dial_code: "+351",
871
+ code: "PT"
872
+ },
873
+ {
874
+ name: "Puerto Rico",
875
+ dial_code: "+1 939",
876
+ code: "PR"
877
+ },
878
+ {
879
+ name: "Qatar",
880
+ dial_code: "+974",
881
+ code: "QA"
882
+ },
883
+ {
884
+ name: "Romania",
885
+ dial_code: "+40",
886
+ code: "RO"
887
+ },
888
+ {
889
+ name: "Russia",
890
+ dial_code: "+7",
891
+ code: "RU"
892
+ },
893
+ {
894
+ name: "Rwanda",
895
+ dial_code: "+250",
896
+ code: "RW"
897
+ },
898
+ {
899
+ name: "Reunion",
900
+ dial_code: "+262",
901
+ code: "RE"
902
+ },
903
+ {
904
+ name: "Saint Barthelemy",
905
+ dial_code: "+590",
906
+ code: "BL"
907
+ },
908
+ {
909
+ name: "Saint Helena, Ascension and Tristan Da Cunha",
910
+ dial_code: "+290",
911
+ code: "SH"
912
+ },
913
+ {
914
+ name: "Saint Kitts and Nevis",
915
+ dial_code: "+1 869",
916
+ code: "KN"
917
+ },
918
+ {
919
+ name: "Saint Lucia",
920
+ dial_code: "+1 758",
921
+ code: "LC"
922
+ },
923
+ {
924
+ name: "Saint Martin",
925
+ dial_code: "+590",
926
+ code: "MF"
927
+ },
928
+ {
929
+ name: "Saint Pierre and Miquelon",
930
+ dial_code: "+508",
931
+ code: "PM"
932
+ },
933
+ {
934
+ name: "Saint Vincent and the Grenadines",
935
+ dial_code: "+1 784",
936
+ code: "VC"
937
+ },
938
+ {
939
+ name: "Samoa",
940
+ dial_code: "+685",
941
+ code: "WS"
942
+ },
943
+ {
944
+ name: "San Marino",
945
+ dial_code: "+378",
946
+ code: "SM"
947
+ },
948
+ {
949
+ name: "Sao Tome and Principe",
950
+ dial_code: "+239",
951
+ code: "ST"
952
+ },
953
+ {
954
+ name: "Saudi Arabia",
955
+ dial_code: "+966",
956
+ code: "SA"
957
+ },
958
+ {
959
+ name: "Senegal",
960
+ dial_code: "+221",
961
+ code: "SN"
962
+ },
963
+ {
964
+ name: "Serbia",
965
+ dial_code: "+381",
966
+ code: "RS"
967
+ },
968
+ {
969
+ name: "Seychelles",
970
+ dial_code: "+248",
971
+ code: "SC"
972
+ },
973
+ {
974
+ name: "Sierra Leone",
975
+ dial_code: "+232",
976
+ code: "SL"
977
+ },
978
+ {
979
+ name: "Singapore",
980
+ dial_code: "+65",
981
+ code: "SG"
982
+ },
983
+ {
984
+ name: "Slovakia",
985
+ dial_code: "+421",
986
+ code: "SK"
987
+ },
988
+ {
989
+ name: "Slovenia",
990
+ dial_code: "+386",
991
+ code: "SI"
992
+ },
993
+ {
994
+ name: "Solomon Islands",
995
+ dial_code: "+677",
996
+ code: "SB"
997
+ },
998
+ {
999
+ name: "Somalia",
1000
+ dial_code: "+252",
1001
+ code: "SO"
1002
+ },
1003
+ {
1004
+ name: "South Africa",
1005
+ dial_code: "+27",
1006
+ code: "ZA"
1007
+ },
1008
+ {
1009
+ name: "South Georgia and the South Sandwich Islands",
1010
+ dial_code: "+500",
1011
+ code: "GS"
1012
+ },
1013
+ {
1014
+ name: "Spain",
1015
+ dial_code: "+34",
1016
+ code: "ES"
1017
+ },
1018
+ {
1019
+ name: "Sri Lanka",
1020
+ dial_code: "+94",
1021
+ code: "LK"
1022
+ },
1023
+ {
1024
+ name: "Sudan",
1025
+ dial_code: "+249",
1026
+ code: "SD"
1027
+ },
1028
+ {
1029
+ name: "Suriname",
1030
+ dial_code: "+597",
1031
+ code: "SR"
1032
+ },
1033
+ {
1034
+ name: "Svalbard and Jan Mayen",
1035
+ dial_code: "+47",
1036
+ code: "SJ"
1037
+ },
1038
+ {
1039
+ name: "Swaziland",
1040
+ dial_code: "+268",
1041
+ code: "SZ"
1042
+ },
1043
+ {
1044
+ name: "Sweden",
1045
+ dial_code: "+46",
1046
+ code: "SE"
1047
+ },
1048
+ {
1049
+ name: "Switzerland",
1050
+ dial_code: "+41",
1051
+ code: "CH"
1052
+ },
1053
+ {
1054
+ name: "Syrian Arab Republic",
1055
+ dial_code: "+963",
1056
+ code: "SY"
1057
+ },
1058
+ {
1059
+ name: "Taiwan",
1060
+ dial_code: "+886",
1061
+ code: "TW"
1062
+ },
1063
+ {
1064
+ name: "Tajikistan",
1065
+ dial_code: "+992",
1066
+ code: "TJ"
1067
+ },
1068
+ {
1069
+ name: "Tanzania, United Republic of Tanzania",
1070
+ dial_code: "+255",
1071
+ code: "TZ"
1072
+ },
1073
+ {
1074
+ name: "Thailand",
1075
+ dial_code: "+66",
1076
+ code: "TH"
1077
+ },
1078
+ {
1079
+ name: "Timor-Leste",
1080
+ dial_code: "+670",
1081
+ code: "TL"
1082
+ },
1083
+ {
1084
+ name: "Togo",
1085
+ dial_code: "+228",
1086
+ code: "TG"
1087
+ },
1088
+ {
1089
+ name: "Tokelau",
1090
+ dial_code: "+690",
1091
+ code: "TK"
1092
+ },
1093
+ {
1094
+ name: "Tonga",
1095
+ dial_code: "+676",
1096
+ code: "TO"
1097
+ },
1098
+ {
1099
+ name: "Trinidad and Tobago",
1100
+ dial_code: "+1 868",
1101
+ code: "TT"
1102
+ },
1103
+ {
1104
+ name: "Tunisia",
1105
+ dial_code: "+216",
1106
+ code: "TN"
1107
+ },
1108
+ {
1109
+ name: "Turkey",
1110
+ dial_code: "+90",
1111
+ code: "TR"
1112
+ },
1113
+ {
1114
+ name: "Turkmenistan",
1115
+ dial_code: "+993",
1116
+ code: "TM"
1117
+ },
1118
+ {
1119
+ name: "Turks and Caicos Islands",
1120
+ dial_code: "+1 649",
1121
+ code: "TC"
1122
+ },
1123
+ {
1124
+ name: "Tuvalu",
1125
+ dial_code: "+688",
1126
+ code: "TV"
1127
+ },
1128
+ {
1129
+ name: "Uganda",
1130
+ dial_code: "+256",
1131
+ code: "UG"
1132
+ },
1133
+ {
1134
+ name: "Ukraine",
1135
+ dial_code: "+380",
1136
+ code: "UA"
1137
+ },
1138
+ {
1139
+ name: "United Arab Emirates",
1140
+ dial_code: "+971",
1141
+ code: "AE"
1142
+ },
1143
+ {
1144
+ name: "United Kingdom",
1145
+ dial_code: "+44",
1146
+ code: "GB"
1147
+ },
1148
+ {
1149
+ name: "United States",
1150
+ dial_code: "+1",
1151
+ code: "US"
1152
+ },
1153
+ {
1154
+ name: "Uruguay",
1155
+ dial_code: "+598",
1156
+ code: "UY"
1157
+ },
1158
+ {
1159
+ name: "Uzbekistan",
1160
+ dial_code: "+998",
1161
+ code: "UZ"
1162
+ },
1163
+ {
1164
+ name: "Vanuatu",
1165
+ dial_code: "+678",
1166
+ code: "VU"
1167
+ },
1168
+ {
1169
+ name: "Venezuela, Bolivarian Republic of Venezuela",
1170
+ dial_code: "+58",
1171
+ code: "VE"
1172
+ },
1173
+ {
1174
+ name: "Vietnam",
1175
+ dial_code: "+84",
1176
+ code: "VN"
1177
+ },
1178
+ {
1179
+ name: "Virgin Islands, British",
1180
+ dial_code: "+1 284",
1181
+ code: "VG"
1182
+ },
1183
+ {
1184
+ name: "Virgin Islands, U.S.",
1185
+ dial_code: "+1 340",
1186
+ code: "VI"
1187
+ },
1188
+ {
1189
+ name: "Wallis and Futuna",
1190
+ dial_code: "+681",
1191
+ code: "WF"
1192
+ },
1193
+ {
1194
+ name: "Yemen",
1195
+ dial_code: "+967",
1196
+ code: "YE"
1197
+ },
1198
+ {
1199
+ name: "Zambia",
1200
+ dial_code: "+260",
1201
+ code: "ZM"
1202
+ },
1203
+ {
1204
+ name: "Zimbabwe",
1205
+ dial_code: "+263",
1206
+ code: "ZW"
1207
+ }
1208
+ ];
1209
+
1210
+ // src/styles.js
1211
+ var STYLE_ID = "kilfx-styles";
1212
+ var KILFX_CSS = `
1213
+ .kilfx {
1214
+ --kilfx-bg: #fff;
1215
+ --kilfx-fg: #111;
1216
+ --kilfx-border: rgba(0, 0, 0, 0.15);
1217
+ --kilfx-radius: 10px;
1218
+ --kilfx-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
1219
+ --kilfx-focus: rgba(59, 130, 246, 0.4);
1220
+ --kilfx-item-hover: rgba(0, 0, 0, 0.06);
1221
+
1222
+ display: grid;
1223
+ gap: 0.625rem;
1224
+ }
1225
+
1226
+ .kilfx.kilfx--inline {
1227
+ display: inline-grid;
1228
+ }
1229
+
1230
+ .kilfx .kilfx__field {
1231
+ position: relative;
1232
+ width: 100%;
1233
+ }
1234
+
1235
+ .kilfx.kilfx--enhanced select.kilfx__native {
1236
+ position: absolute;
1237
+ width: 1px;
1238
+ height: 1px;
1239
+ opacity: 0;
1240
+ pointer-events: none;
1241
+ border: 0;
1242
+ padding: 0;
1243
+ margin: 0;
1244
+ }
1245
+
1246
+ .kilfx .kilfx__trigger {
1247
+ width: 100%;
1248
+ min-height: 2.4rem;
1249
+ display: flex;
1250
+ align-items: center;
1251
+ gap: 0.625rem;
1252
+ border: 1px solid var(--kilfx-border);
1253
+ border-radius: var(--kilfx-radius);
1254
+ background: var(--kilfx-bg);
1255
+ color: var(--kilfx-fg);
1256
+ padding: 0.5rem 0.625rem;
1257
+ font: inherit;
1258
+ line-height: 1.2;
1259
+ cursor: pointer;
1260
+ text-align: left;
1261
+ box-sizing: border-box;
1262
+ }
1263
+
1264
+ .kilfx .kilfx__trigger:focus-visible,
1265
+ .kilfx .kilfx__search:focus-visible {
1266
+ outline: 2px solid var(--kilfx-focus);
1267
+ outline-offset: 1px;
1268
+ }
1269
+
1270
+ .kilfx .kilfx__label {
1271
+ flex: 1;
1272
+ overflow: hidden;
1273
+ text-overflow: ellipsis;
1274
+ white-space: nowrap;
1275
+ }
1276
+
1277
+ .kilfx .kilfx__caret {
1278
+ width: 0.55rem;
1279
+ height: 0.55rem;
1280
+ border-right: 2px solid currentColor;
1281
+ border-bottom: 2px solid currentColor;
1282
+ transform: rotate(45deg);
1283
+ opacity: 0.75;
1284
+ margin-right: 0.125rem;
1285
+ }
1286
+
1287
+ .kilfx .kilfx__field.kilfx__field--open .kilfx__caret {
1288
+ transform: rotate(-135deg);
1289
+ margin-top: 0.25rem;
1290
+ }
1291
+
1292
+ .kilfx .kilfx__menu {
1293
+ position: absolute;
1294
+ top: calc(100% + 0.35rem);
1295
+ left: 0;
1296
+ right: 0;
1297
+ z-index: 999;
1298
+ border: 1px solid var(--kilfx-border);
1299
+ border-radius: var(--kilfx-radius);
1300
+ background: var(--kilfx-bg);
1301
+ color: var(--kilfx-fg);
1302
+ box-shadow: var(--kilfx-shadow);
1303
+ overflow: hidden;
1304
+ }
1305
+
1306
+ .kilfx .kilfx__field.kilfx__field--up .kilfx__menu {
1307
+ top: auto;
1308
+ bottom: calc(100% + 0.35rem);
1309
+ }
1310
+
1311
+ .kilfx .kilfx__search-wrap {
1312
+ padding: 0.45rem;
1313
+ border-bottom: 1px solid var(--kilfx-border);
1314
+ }
1315
+
1316
+ .kilfx .kilfx__search {
1317
+ width: 100%;
1318
+ min-height: 2.25rem;
1319
+ border: 1px solid var(--kilfx-border);
1320
+ border-radius: calc(var(--kilfx-radius) * 0.7);
1321
+ background: var(--kilfx-bg);
1322
+ color: var(--kilfx-fg);
1323
+ padding: 0.45rem 0.55rem;
1324
+ font: inherit;
1325
+ box-sizing: border-box;
1326
+ }
1327
+
1328
+ .kilfx .kilfx__list {
1329
+ max-height: 15rem;
1330
+ overflow: auto;
1331
+ }
1332
+
1333
+ .kilfx .kilfx__item {
1334
+ min-height: 2.35rem;
1335
+ display: flex;
1336
+ align-items: center;
1337
+ gap: 0.625rem;
1338
+ width: 100%;
1339
+ border: 0;
1340
+ background: transparent;
1341
+ color: inherit;
1342
+ text-align: left;
1343
+ padding: 0.5rem 0.625rem;
1344
+ cursor: pointer;
1345
+ font: inherit;
1346
+ }
1347
+
1348
+ .kilfx .kilfx__item:hover,
1349
+ .kilfx .kilfx__item.kilfx__item--active {
1350
+ background: var(--kilfx-item-hover);
1351
+ }
1352
+
1353
+ .kilfx .kilfx__item.kilfx__item--selected .kilfx__item-label::after {
1354
+ content: " \u2713";
1355
+ opacity: 0.75;
1356
+ }
1357
+
1358
+ .kilfx .kilfx__empty {
1359
+ padding: 0.75rem;
1360
+ opacity: 0.7;
1361
+ }
1362
+
1363
+ .kilfx .kilfx__flag {
1364
+ width: 1.1rem;
1365
+ height: 1.1rem;
1366
+ min-width: 1.1rem;
1367
+ border-radius: 50%;
1368
+ display: inline-flex;
1369
+ align-items: center;
1370
+ justify-content: center;
1371
+ overflow: hidden;
1372
+ border: 1px solid var(--kilfx-border);
1373
+ background: var(--kilfx-bg);
1374
+ font-size: 0.6rem;
1375
+ text-transform: uppercase;
1376
+ }
1377
+
1378
+ .kilfx .kilfx__flag-image {
1379
+ width: 100%;
1380
+ height: 100%;
1381
+ object-fit: cover;
1382
+ display: none;
1383
+ }
1384
+
1385
+ .kilfx .kilfx__flag.kilfx__flag--loaded .kilfx__flag-image {
1386
+ display: block;
1387
+ }
1388
+
1389
+ .kilfx .kilfx__flag.kilfx__flag--loaded .kilfx__flag-fallback {
1390
+ display: none;
1391
+ }
1392
+
1393
+ .kilfx .kilfx__rate[readonly] {
1394
+ cursor: default;
1395
+ }
1396
+
1397
+ @media (max-width: 640px) {
1398
+ .kilfx .kilfx__trigger,
1399
+ .kilfx .kilfx__item,
1400
+ .kilfx .kilfx__search {
1401
+ min-height: 2.35rem;
1402
+ }
1403
+ }
1404
+ `;
1405
+ function ensureStylesInjected() {
1406
+ if (typeof document === "undefined") return;
1407
+ if (document.getElementById(STYLE_ID)) return;
1408
+ const style = document.createElement("style");
1409
+ style.id = STYLE_ID;
1410
+ style.textContent = KILFX_CSS;
1411
+ document.head.appendChild(style);
1412
+ }
1413
+
1414
+ // src/dom.js
1415
+ var DEFAULTS = {
1416
+ rootSelector: ".kilfx",
1417
+ baseName: "kilfx_base",
1418
+ toName: "kilfx_to",
1419
+ rateName: "fx_rate",
1420
+ flagsPath: "/svg",
1421
+ fileCase: "auto",
1422
+ enableSearch: true,
1423
+ defaultBase: "JM",
1424
+ defaultTo: "JM",
1425
+ initCountry: null,
1426
+ only: null,
1427
+ onlyBase: null,
1428
+ onlyTo: null,
1429
+ data: null
1430
+ };
1431
+ var ROOT_INSTANCES = /* @__PURE__ */ new WeakMap();
1432
+ var OPEN_DROPDOWN = null;
1433
+ var GLOBAL_EVENTS_BOUND = false;
1434
+ var UID = 0;
1435
+ function nextUid(prefix) {
1436
+ UID += 1;
1437
+ return `${prefix}-${UID}`;
1438
+ }
1439
+ function normalizeCode(input) {
1440
+ if (!input) return "";
1441
+ return String(input).trim().toUpperCase();
1442
+ }
1443
+ function parseCodeList(input) {
1444
+ if (!input) return [];
1445
+ const raw = Array.isArray(input) ? input : String(input).split(/[,\s]+/);
1446
+ const seen = /* @__PURE__ */ new Set();
1447
+ const out = [];
1448
+ for (const token of raw) {
1449
+ const value = normalizeCode(String(token).replace(/['"]/g, ""));
1450
+ if (!value || seen.has(value)) continue;
1451
+ seen.add(value);
1452
+ out.push(value);
1453
+ }
1454
+ return out;
1455
+ }
1456
+ function pickFirst(...values) {
1457
+ for (const value of values) {
1458
+ if (value !== void 0 && value !== null && value !== "") return value;
1459
+ }
1460
+ return void 0;
1461
+ }
1462
+ function getAttr(el, ...names) {
1463
+ if (!el) return void 0;
1464
+ for (const name of names) {
1465
+ const value = el.getAttribute(name);
1466
+ if (value !== null && value !== "") return value;
1467
+ }
1468
+ return void 0;
1469
+ }
1470
+ function normalizeData(raw) {
1471
+ const source = Array.isArray(raw) ? raw : countries_default;
1472
+ const out = [];
1473
+ const seen = /* @__PURE__ */ new Set();
1474
+ for (const item of source) {
1475
+ if (!item || !item.code) continue;
1476
+ const code = normalizeCode(item.code);
1477
+ if (!code || seen.has(code)) continue;
1478
+ seen.add(code);
1479
+ out.push({
1480
+ name: String(item.name || code),
1481
+ dial_code: String(item.dial_code || ""),
1482
+ code
1483
+ });
1484
+ }
1485
+ return out;
1486
+ }
1487
+ function filterCountries(allCountries, onlyCodes) {
1488
+ const list = parseCodeList(onlyCodes);
1489
+ if (!list.length) return allCountries.slice();
1490
+ const allowed = new Set(list);
1491
+ return allCountries.filter((item) => allowed.has(item.code));
1492
+ }
1493
+ function normalizeFlagsBase(inputPath) {
1494
+ const raw = String(inputPath || "").trim();
1495
+ if (!raw) return "";
1496
+ const stripped = raw.replace(/\/+$/, "");
1497
+ if (typeof document === "undefined") return stripped;
1498
+ try {
1499
+ return new URL(stripped, document.baseURI).href.replace(/\/+$/, "");
1500
+ } catch (e) {
1501
+ return stripped;
1502
+ }
1503
+ }
1504
+ function buildFlagElement(code, config) {
1505
+ const wrap = document.createElement("span");
1506
+ wrap.className = "kilfx__flag";
1507
+ const fallback = document.createElement("span");
1508
+ fallback.className = "kilfx__flag-fallback";
1509
+ fallback.textContent = code;
1510
+ wrap.appendChild(fallback);
1511
+ const img = document.createElement("img");
1512
+ img.className = "kilfx__flag-image";
1513
+ img.alt = code;
1514
+ img.loading = "eager";
1515
+ wrap.appendChild(img);
1516
+ const normalizedPath = normalizeFlagsBase(config.flagsPath);
1517
+ const defaultCdnBase = "https://cdn.jsdelivr.net/npm/kilfx@latest/svg";
1518
+ const lower = code.toLowerCase();
1519
+ const upper = code.toUpperCase();
1520
+ const variants = config.fileCase === "upper" ? [upper] : config.fileCase === "lower" ? [lower] : [lower, upper];
1521
+ const baseCandidates = [];
1522
+ if (normalizedPath) baseCandidates.push(normalizedPath);
1523
+ if (!baseCandidates.includes(defaultCdnBase)) {
1524
+ baseCandidates.push(defaultCdnBase);
1525
+ }
1526
+ const srcCandidates = [];
1527
+ for (const base of baseCandidates) {
1528
+ for (const variant of variants) {
1529
+ srcCandidates.push(`${base}/${variant}.svg`);
1530
+ }
1531
+ }
1532
+ let index = 0;
1533
+ const loadNext = () => {
1534
+ if (index >= srcCandidates.length) {
1535
+ wrap.classList.remove("kilfx__flag--loaded");
1536
+ return;
1537
+ }
1538
+ img.src = srcCandidates[index];
1539
+ index += 1;
1540
+ };
1541
+ img.addEventListener("load", () => {
1542
+ wrap.classList.add("kilfx__flag--loaded");
1543
+ });
1544
+ img.addEventListener("error", () => {
1545
+ loadNext();
1546
+ });
1547
+ loadNext();
1548
+ return wrap;
1549
+ }
1550
+ function countryLabel(item) {
1551
+ return `${item.name} (${item.code})`;
1552
+ }
1553
+ function bindGlobalEvents() {
1554
+ if (GLOBAL_EVENTS_BOUND || typeof document === "undefined") return;
1555
+ GLOBAL_EVENTS_BOUND = true;
1556
+ document.addEventListener("pointerdown", (event) => {
1557
+ if (!OPEN_DROPDOWN) return;
1558
+ if (!OPEN_DROPDOWN.fieldEl.contains(event.target)) {
1559
+ OPEN_DROPDOWN.closeMenu();
1560
+ }
1561
+ });
1562
+ document.addEventListener("keydown", (event) => {
1563
+ if (!OPEN_DROPDOWN) return;
1564
+ if (event.key === "Escape") {
1565
+ OPEN_DROPDOWN.closeMenu(true);
1566
+ }
1567
+ });
1568
+ window.addEventListener("resize", () => {
1569
+ if (OPEN_DROPDOWN) OPEN_DROPDOWN.positionMenu();
1570
+ });
1571
+ }
1572
+ var KilFxSelect = class {
1573
+ constructor(args) {
1574
+ this.rootInstance = args.rootInstance;
1575
+ this.kind = args.kind;
1576
+ this.selectEl = args.selectEl;
1577
+ this.countries = args.countries;
1578
+ this.initialCode = args.initialCode;
1579
+ this.config = args.config;
1580
+ this.preselectedValue = normalizeCode(args.preselectedValue);
1581
+ this.filteredCountries = this.countries.slice();
1582
+ this.activeIndex = -1;
1583
+ this.selectedCode = "";
1584
+ this.selectedItem = null;
1585
+ this.silentNative = false;
1586
+ this.fieldEl = document.createElement("div");
1587
+ this.fieldEl.className = "kilfx__field";
1588
+ this.fieldEl.setAttribute("data-kilfx-kind", this.kind);
1589
+ this.triggerEl = document.createElement("button");
1590
+ this.triggerEl.type = "button";
1591
+ this.triggerEl.className = "kilfx__trigger";
1592
+ this.triggerEl.setAttribute("aria-haspopup", "listbox");
1593
+ this.triggerEl.setAttribute("aria-expanded", "false");
1594
+ this.labelEl = document.createElement("span");
1595
+ this.labelEl.className = "kilfx__label";
1596
+ this.caretEl = document.createElement("span");
1597
+ this.caretEl.className = "kilfx__caret";
1598
+ this.caretEl.setAttribute("aria-hidden", "true");
1599
+ this.menuEl = document.createElement("div");
1600
+ this.menuEl.className = "kilfx__menu";
1601
+ this.menuEl.hidden = true;
1602
+ this.menuEl.id = nextUid("kilfx-menu");
1603
+ this.triggerEl.setAttribute("aria-controls", this.menuEl.id);
1604
+ this.searchWrapEl = document.createElement("div");
1605
+ this.searchWrapEl.className = "kilfx__search-wrap";
1606
+ this.searchEl = document.createElement("input");
1607
+ this.searchEl.className = "kilfx__search";
1608
+ this.searchEl.type = "text";
1609
+ this.searchEl.placeholder = "Search country or ISO";
1610
+ this.searchEl.autocomplete = "off";
1611
+ this.listEl = document.createElement("div");
1612
+ this.listEl.className = "kilfx__list";
1613
+ this.listEl.setAttribute("role", "listbox");
1614
+ this.searchWrapEl.appendChild(this.searchEl);
1615
+ this.menuEl.appendChild(this.searchWrapEl);
1616
+ this.menuEl.appendChild(this.listEl);
1617
+ this.triggerEl.appendChild(this.labelEl);
1618
+ this.triggerEl.appendChild(this.caretEl);
1619
+ this.fieldEl.appendChild(this.triggerEl);
1620
+ this.fieldEl.appendChild(this.menuEl);
1621
+ this.selectEl.classList.add("kilfx__native");
1622
+ this.selectEl.insertAdjacentElement("afterend", this.fieldEl);
1623
+ this.selectEl.setAttribute("data-kilfx-role", this.kind);
1624
+ if (!this.config.enableSearch) {
1625
+ this.searchWrapEl.hidden = true;
1626
+ }
1627
+ this.syncNativeOptions();
1628
+ this.bindEvents();
1629
+ this.setSelectedCode(this.resolveStartingCode(), {
1630
+ emitNative: false,
1631
+ emitWidget: false
1632
+ });
1633
+ }
1634
+ bindEvents() {
1635
+ this.triggerEl.addEventListener("click", () => {
1636
+ if (this.menuEl.hidden) this.openMenu();
1637
+ else this.closeMenu();
1638
+ });
1639
+ this.triggerEl.addEventListener("keydown", (event) => {
1640
+ this.onKeyDown(event, true);
1641
+ });
1642
+ this.searchEl.addEventListener("input", () => {
1643
+ this.applyFilter(this.searchEl.value);
1644
+ });
1645
+ this.searchEl.addEventListener("keydown", (event) => {
1646
+ this.onKeyDown(event, false);
1647
+ });
1648
+ this.listEl.addEventListener("keydown", (event) => {
1649
+ this.onKeyDown(event, false);
1650
+ });
1651
+ this.selectEl.addEventListener("change", () => {
1652
+ if (this.silentNative) return;
1653
+ this.setSelectedCode(this.selectEl.value, {
1654
+ emitNative: false,
1655
+ emitWidget: true
1656
+ });
1657
+ });
1658
+ }
1659
+ syncNativeOptions() {
1660
+ const fragment = document.createDocumentFragment();
1661
+ for (const item of this.countries) {
1662
+ const option = document.createElement("option");
1663
+ option.value = item.code;
1664
+ option.textContent = countryLabel(item);
1665
+ fragment.appendChild(option);
1666
+ }
1667
+ this.selectEl.innerHTML = "";
1668
+ this.selectEl.appendChild(fragment);
1669
+ this.selectEl.disabled = this.countries.length === 0;
1670
+ this.triggerEl.disabled = this.countries.length === 0;
1671
+ }
1672
+ resolveStartingCode() {
1673
+ if (this.hasCode(this.preselectedValue)) return this.preselectedValue;
1674
+ const initFromSelect = pickFirst(
1675
+ getAttr(this.selectEl, "kilfx_int", "data-kilfx-int"),
1676
+ this.initialCode
1677
+ );
1678
+ const normalizedInit = normalizeCode(initFromSelect);
1679
+ if (this.hasCode(normalizedInit)) return normalizedInit;
1680
+ if (this.countries[0]) return this.countries[0].code;
1681
+ return "";
1682
+ }
1683
+ hasCode(code) {
1684
+ if (!code) return false;
1685
+ return this.countries.some((item) => item.code === code);
1686
+ }
1687
+ setSelectedCode(code, behavior) {
1688
+ const normalized = normalizeCode(code);
1689
+ let selected = this.countries.find((item) => item.code === normalized);
1690
+ if (!selected) selected = this.countries[0] || null;
1691
+ this.selectedItem = selected;
1692
+ this.selectedCode = selected ? selected.code : "";
1693
+ this.selectEl.value = this.selectedCode;
1694
+ this.renderTrigger();
1695
+ this.renderList();
1696
+ if (behavior.emitNative) {
1697
+ this.silentNative = true;
1698
+ this.selectEl.dispatchEvent(new Event("change", { bubbles: true }));
1699
+ this.silentNative = false;
1700
+ }
1701
+ if (behavior.emitWidget) {
1702
+ this.rootInstance.onSelectChanged();
1703
+ }
1704
+ }
1705
+ renderTrigger() {
1706
+ if (!this.selectedItem) {
1707
+ this.labelEl.textContent = "No country available";
1708
+ return;
1709
+ }
1710
+ this.labelEl.textContent = countryLabel(this.selectedItem);
1711
+ const oldFlag = this.triggerEl.querySelector(".kilfx__flag");
1712
+ if (oldFlag) oldFlag.remove();
1713
+ this.triggerEl.insertBefore(
1714
+ buildFlagElement(this.selectedItem.code, this.config),
1715
+ this.labelEl
1716
+ );
1717
+ }
1718
+ applyFilter(term) {
1719
+ const query = String(term || "").trim().toLowerCase();
1720
+ this.filteredCountries = this.countries.filter((item) => {
1721
+ if (!query) return true;
1722
+ return item.name.toLowerCase().includes(query) || item.code.toLowerCase().includes(query);
1723
+ });
1724
+ const selectedIndex = this.filteredCountries.findIndex(
1725
+ (item) => item.code === this.selectedCode
1726
+ );
1727
+ this.activeIndex = selectedIndex >= 0 ? selectedIndex : this.filteredCountries.length ? 0 : -1;
1728
+ this.renderList();
1729
+ }
1730
+ renderList() {
1731
+ this.listEl.innerHTML = "";
1732
+ if (!this.filteredCountries.length) {
1733
+ const empty = document.createElement("div");
1734
+ empty.className = "kilfx__empty";
1735
+ empty.textContent = "No countries found";
1736
+ this.listEl.appendChild(empty);
1737
+ return;
1738
+ }
1739
+ const fragment = document.createDocumentFragment();
1740
+ this.filteredCountries.forEach((item, index) => {
1741
+ const button = document.createElement("button");
1742
+ button.type = "button";
1743
+ button.className = "kilfx__item";
1744
+ button.setAttribute("role", "option");
1745
+ button.setAttribute("data-code", item.code);
1746
+ button.setAttribute("aria-selected", item.code === this.selectedCode ? "true" : "false");
1747
+ if (item.code === this.selectedCode) {
1748
+ button.classList.add("kilfx__item--selected");
1749
+ }
1750
+ if (index === this.activeIndex) {
1751
+ button.classList.add("kilfx__item--active");
1752
+ }
1753
+ const label = document.createElement("span");
1754
+ label.className = "kilfx__item-label";
1755
+ label.textContent = countryLabel(item);
1756
+ button.appendChild(buildFlagElement(item.code, this.config));
1757
+ button.appendChild(label);
1758
+ button.addEventListener("click", () => {
1759
+ this.setSelectedCode(item.code, { emitNative: true, emitWidget: true });
1760
+ this.closeMenu(true);
1761
+ });
1762
+ fragment.appendChild(button);
1763
+ });
1764
+ this.listEl.appendChild(fragment);
1765
+ }
1766
+ moveActive(step) {
1767
+ if (!this.filteredCountries.length) return;
1768
+ if (this.activeIndex < 0) {
1769
+ this.activeIndex = 0;
1770
+ } else {
1771
+ const total = this.filteredCountries.length;
1772
+ this.activeIndex = (this.activeIndex + step + total) % total;
1773
+ }
1774
+ this.renderList();
1775
+ const active = this.listEl.querySelector(".kilfx__item--active");
1776
+ if (active) active.scrollIntoView({ block: "nearest" });
1777
+ }
1778
+ onKeyDown(event, allowOpen) {
1779
+ const { key } = event;
1780
+ if (allowOpen && this.menuEl.hidden && (key === "ArrowDown" || key === "ArrowUp" || key === "Enter" || key === " ")) {
1781
+ event.preventDefault();
1782
+ this.openMenu();
1783
+ return;
1784
+ }
1785
+ if (this.menuEl.hidden) return;
1786
+ if (key === "ArrowDown") {
1787
+ event.preventDefault();
1788
+ this.moveActive(1);
1789
+ } else if (key === "ArrowUp") {
1790
+ event.preventDefault();
1791
+ this.moveActive(-1);
1792
+ } else if (key === "Enter") {
1793
+ event.preventDefault();
1794
+ const target = this.filteredCountries[this.activeIndex];
1795
+ if (target) {
1796
+ this.setSelectedCode(target.code, { emitNative: true, emitWidget: true });
1797
+ this.closeMenu(true);
1798
+ }
1799
+ } else if (key === "Escape") {
1800
+ event.preventDefault();
1801
+ this.closeMenu(true);
1802
+ }
1803
+ }
1804
+ positionMenu() {
1805
+ const rect = this.fieldEl.getBoundingClientRect();
1806
+ const downSpace = window.innerHeight - rect.bottom;
1807
+ const upSpace = rect.top;
1808
+ const openUp = downSpace < 280 && upSpace > downSpace;
1809
+ this.fieldEl.classList.toggle("kilfx__field--up", openUp);
1810
+ }
1811
+ openMenu() {
1812
+ if (!this.countries.length) return;
1813
+ if (OPEN_DROPDOWN && OPEN_DROPDOWN !== this) {
1814
+ OPEN_DROPDOWN.closeMenu();
1815
+ }
1816
+ OPEN_DROPDOWN = this;
1817
+ this.positionMenu();
1818
+ this.menuEl.hidden = false;
1819
+ this.fieldEl.classList.add("kilfx__field--open");
1820
+ this.triggerEl.setAttribute("aria-expanded", "true");
1821
+ if (this.config.enableSearch) {
1822
+ this.searchEl.value = "";
1823
+ }
1824
+ this.applyFilter("");
1825
+ if (this.config.enableSearch) {
1826
+ setTimeout(() => this.searchEl.focus(), 0);
1827
+ }
1828
+ }
1829
+ closeMenu(focusTrigger = false) {
1830
+ this.menuEl.hidden = true;
1831
+ this.fieldEl.classList.remove("kilfx__field--open");
1832
+ this.fieldEl.classList.remove("kilfx__field--up");
1833
+ this.triggerEl.setAttribute("aria-expanded", "false");
1834
+ if (OPEN_DROPDOWN === this) OPEN_DROPDOWN = null;
1835
+ if (focusTrigger) this.triggerEl.focus();
1836
+ }
1837
+ };
1838
+ var KilFxRoot = class {
1839
+ constructor(rootEl, config) {
1840
+ this.rootEl = rootEl;
1841
+ this.config = config;
1842
+ this.baseSelectEl = rootEl.querySelector(`select[name="${config.baseName}"]`);
1843
+ this.toSelectEl = rootEl.querySelector(`select[name="${config.toName}"]`);
1844
+ this.rateInputEl = rootEl.querySelector(`input[name="${config.rateName}"]`);
1845
+ this.baseControl = null;
1846
+ this.toControl = null;
1847
+ }
1848
+ mount() {
1849
+ if (!this.baseSelectEl || !this.toSelectEl) return false;
1850
+ this.rootEl.classList.add("kilfx", "kilfx--enhanced");
1851
+ const mergedData = normalizeData(this.config.data);
1852
+ const rootOnly = pickFirst(
1853
+ getAttr(this.rootEl, "kilfx_only", "data-kilfx-only"),
1854
+ this.config.only
1855
+ );
1856
+ const rootInt = pickFirst(
1857
+ getAttr(this.rootEl, "kilfx_int", "data-kilfx-int"),
1858
+ this.config.initCountry
1859
+ );
1860
+ const baseOnly = pickFirst(
1861
+ getAttr(
1862
+ this.baseSelectEl,
1863
+ "kilfx_only",
1864
+ "data-kilfx-only",
1865
+ "data-kilfx-base-only"
1866
+ ),
1867
+ getAttr(this.rootEl, "kilfx_base_only", "data-kilfx-base-only"),
1868
+ this.config.onlyBase,
1869
+ rootOnly
1870
+ );
1871
+ const toOnly = pickFirst(
1872
+ getAttr(
1873
+ this.toSelectEl,
1874
+ "kilfx_only",
1875
+ "data-kilfx-only",
1876
+ "data-kilfx-to-only"
1877
+ ),
1878
+ getAttr(this.rootEl, "kilfx_to_only", "data-kilfx-to-only"),
1879
+ this.config.onlyTo,
1880
+ rootOnly
1881
+ );
1882
+ const baseCountries = filterCountries(mergedData, baseOnly);
1883
+ const toCountries = filterCountries(mergedData, toOnly);
1884
+ const preselectedBase = normalizeCode(this.baseSelectEl.value);
1885
+ const preselectedTo = normalizeCode(this.toSelectEl.value);
1886
+ const baseInit = pickFirst(
1887
+ getAttr(this.baseSelectEl, "kilfx_int", "data-kilfx-int"),
1888
+ getAttr(this.rootEl, "kilfx_base_int", "data-kilfx-base-int"),
1889
+ rootInt,
1890
+ this.config.defaultBase,
1891
+ "JM"
1892
+ );
1893
+ const toInit = pickFirst(
1894
+ getAttr(this.toSelectEl, "kilfx_int", "data-kilfx-int"),
1895
+ getAttr(this.rootEl, "kilfx_to_int", "data-kilfx-to-int"),
1896
+ rootInt,
1897
+ this.config.defaultTo,
1898
+ "JM"
1899
+ );
1900
+ this.baseControl = new KilFxSelect({
1901
+ rootInstance: this,
1902
+ kind: "base",
1903
+ selectEl: this.baseSelectEl,
1904
+ countries: baseCountries,
1905
+ initialCode: baseInit,
1906
+ preselectedValue: preselectedBase,
1907
+ config: this.config
1908
+ });
1909
+ this.toControl = new KilFxSelect({
1910
+ rootInstance: this,
1911
+ kind: "to",
1912
+ selectEl: this.toSelectEl,
1913
+ countries: toCountries,
1914
+ initialCode: toInit,
1915
+ preselectedValue: preselectedTo,
1916
+ config: this.config
1917
+ });
1918
+ if (this.rateInputEl) {
1919
+ this.rateInputEl.classList.add("kilfx__rate");
1920
+ this.rateInputEl.readOnly = true;
1921
+ }
1922
+ return true;
1923
+ }
1924
+ onSelectChanged() {
1925
+ var _a, _b, _c, _d;
1926
+ if (this.rateInputEl) {
1927
+ this.rateInputEl.readOnly = true;
1928
+ this.rateInputEl.value = "";
1929
+ }
1930
+ const detail = {
1931
+ base: ((_a = this.baseControl) == null ? void 0 : _a.selectedCode) || "",
1932
+ to: ((_b = this.toControl) == null ? void 0 : _b.selectedCode) || "",
1933
+ rootEl: this.rootEl,
1934
+ baseSelectEl: this.baseSelectEl,
1935
+ toSelectEl: this.toSelectEl,
1936
+ baseItem: ((_c = this.baseControl) == null ? void 0 : _c.selectedItem) || null,
1937
+ toItem: ((_d = this.toControl) == null ? void 0 : _d.selectedItem) || null
1938
+ };
1939
+ document.dispatchEvent(new CustomEvent("kilfx:change", { detail }));
1940
+ }
1941
+ };
1942
+ function normalizeConfig(options = {}) {
1943
+ const config = { ...DEFAULTS, ...options };
1944
+ config.initCountry = pickFirst(options.initCountry, options.kilfx_int, config.initCountry);
1945
+ config.only = pickFirst(options.only, options.kilfx_only, config.only);
1946
+ config.onlyBase = pickFirst(options.onlyBase, options.kilfx_base_only, config.onlyBase);
1947
+ config.onlyTo = pickFirst(options.onlyTo, options.kilfx_to_only, config.onlyTo);
1948
+ const fileCase = String(config.fileCase || "auto").toLowerCase();
1949
+ config.fileCase = fileCase === "upper" || fileCase === "lower" ? fileCase : "auto";
1950
+ config.enableSearch = config.enableSearch !== false;
1951
+ config.defaultBase = normalizeCode(
1952
+ pickFirst(options.defaultBase, options.kilfx_base_int, config.initCountry, "JM")
1953
+ );
1954
+ config.defaultTo = normalizeCode(
1955
+ pickFirst(options.defaultTo, options.kilfx_to_int, config.initCountry, "JM")
1956
+ );
1957
+ return config;
1958
+ }
1959
+ function resolveRoots(config, options) {
1960
+ if (options.rootElements && Array.isArray(options.rootElements)) {
1961
+ return options.rootElements.filter(Boolean);
1962
+ }
1963
+ if (typeof document === "undefined") return [];
1964
+ return Array.from(document.querySelectorAll(config.rootSelector));
1965
+ }
1966
+ function init(options = {}) {
1967
+ if (typeof document === "undefined") return [];
1968
+ const config = normalizeConfig(options);
1969
+ ensureStylesInjected();
1970
+ bindGlobalEvents();
1971
+ const roots = resolveRoots(config, options);
1972
+ const instances = [];
1973
+ for (const rootEl of roots) {
1974
+ if (ROOT_INSTANCES.has(rootEl)) {
1975
+ instances.push(ROOT_INSTANCES.get(rootEl));
1976
+ continue;
1977
+ }
1978
+ const root = new KilFxRoot(rootEl, config);
1979
+ if (!root.mount()) continue;
1980
+ ROOT_INSTANCES.set(rootEl, root);
1981
+ instances.push(root);
1982
+ }
1983
+ return instances;
1984
+ }
1985
+ var defaults = { ...DEFAULTS };
1986
+
1987
+ // src/index.js
1988
+ var autoInitAttached = false;
1989
+ var manualInitCalled = false;
1990
+ function init2(options = {}) {
1991
+ manualInitCalled = true;
1992
+ return init(options);
1993
+ }
1994
+ function autoInit(options = {}) {
1995
+ if (typeof document === "undefined") return;
1996
+ if (document.readyState === "loading") {
1997
+ if (autoInitAttached) return;
1998
+ autoInitAttached = true;
1999
+ document.addEventListener(
2000
+ "DOMContentLoaded",
2001
+ () => {
2002
+ if (manualInitCalled) return;
2003
+ init2(options);
2004
+ },
2005
+ { once: true }
2006
+ );
2007
+ } else {
2008
+ if (manualInitCalled) return;
2009
+ init2(options);
2010
+ }
2011
+ }
2012
+ var api = {
2013
+ init: init2,
2014
+ autoInit,
2015
+ countriesData: countries_default,
2016
+ defaults,
2017
+ ensureStylesInjected
2018
+ };
2019
+ if (typeof window !== "undefined") {
2020
+ window.KILFX = api;
2021
+ autoInit();
2022
+ }
2023
+ var index_default = api;
2024
+ export {
2025
+ KILFX_CSS,
2026
+ STYLE_ID,
2027
+ autoInit,
2028
+ countries_default as countriesData,
2029
+ index_default as default,
2030
+ defaults,
2031
+ ensureStylesInjected,
2032
+ init2 as init
2033
+ };