@blotoutio/providers-onescreen-ai-sdk 1.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/index.cjs.js +484 -0
- package/index.js +487 -0
- package/index.mjs +482 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# providers-onescreen-ai-sdk
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build providers-onescreen-ai-sdk` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test providers-onescreen-ai-sdk` to execute the unit tests via [Jest](https://jestjs.io).
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const packageName = 'onescreenAI';
|
|
4
|
+
|
|
5
|
+
const canLog = () => {
|
|
6
|
+
try {
|
|
7
|
+
return localStorage.getItem('edgeTagDebug') === '1';
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const prefix = `[EdgeTag]`;
|
|
14
|
+
const logger = {
|
|
15
|
+
log: (...args) => {
|
|
16
|
+
if (canLog()) {
|
|
17
|
+
console.log(prefix, ...args);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
error: (...args) => {
|
|
21
|
+
if (canLog()) {
|
|
22
|
+
console.error(prefix, ...args);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
info: (...args) => {
|
|
26
|
+
if (canLog()) {
|
|
27
|
+
console.info(prefix, ...args);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
trace: (...args) => {
|
|
31
|
+
if (canLog()) {
|
|
32
|
+
console.trace(prefix, ...args);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const expand = (str) => str.split(',').flatMap((entry) => {
|
|
38
|
+
if (!entry.includes('-')) {
|
|
39
|
+
return entry;
|
|
40
|
+
}
|
|
41
|
+
const result = [];
|
|
42
|
+
const [start, end] = entry.split('-').map(Number);
|
|
43
|
+
for (let i = start; i <= end; i++) {
|
|
44
|
+
result.push(i.toString());
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
|
|
50
|
+
*
|
|
51
|
+
* In Dev Tools, select the `tbody` element containing the area codes and run the following code,
|
|
52
|
+
* replacing the emdash character with a simple endash:
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* [...$0.querySelectorAll('td:first-child')]
|
|
56
|
+
* .filter(cell => cell.firstChild.nodeName != 'A')
|
|
57
|
+
* .map(cell => cell.textContent.trim()).join(',')
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
new Set([
|
|
61
|
+
...expand('200,211,221,222,230,232,233,235,237-238,241,243,244,245,247,255,257,258-259,261,265,266,271,273,274,275,277,278,280,282,283,285-287,288,290-299'),
|
|
62
|
+
...expand('300,311,322,324,327,328,333,335,338,342,344,348-349,353,355,356,357-359,362,366,369,370-379,381,382,383-384,387,388,389,390-399'),
|
|
63
|
+
...expand('400,411,420,421-422,426-427,428,429,433,439,444,446,449,451-454,455,456,457,459,460,461-462,465,466,467,471,476,477,481-483,485-486,487,488,489,490-499'),
|
|
64
|
+
...expand('511,532,535,536,537,538,542-543,545-547,549-550,552-554,555,556,558,560,565,568,569,576,578,583,589,590-599'),
|
|
65
|
+
...expand('611,621,624,625,627,632,633,634-635,637-638,642-643,644,648,652-654,655,663,665,666,668,673-676,677,679,685,686,687,688,690-699'),
|
|
66
|
+
...expand('711,722,723,729,733,735-736,739,741,744,745-746,748,749-751,752,755,756,759,761,764,766,768,776,777,783,788,789,790-799'),
|
|
67
|
+
...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
|
|
68
|
+
...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
function tryParse(json, fallbackValue) {
|
|
72
|
+
try {
|
|
73
|
+
if (json) {
|
|
74
|
+
return JSON.parse(json);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
/* do nothing */
|
|
79
|
+
}
|
|
80
|
+
return fallbackValue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* ISO-3166 2-leter country codes and their names
|
|
85
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
86
|
+
*/
|
|
87
|
+
const isoCountries = new Map([
|
|
88
|
+
['AD', 'Andorra'],
|
|
89
|
+
['AE', 'United Arab Emirates'],
|
|
90
|
+
['AF', 'Afghanistan'],
|
|
91
|
+
['AG', 'Antigua and Barbuda'],
|
|
92
|
+
['AI', 'Anguilla'],
|
|
93
|
+
['AL', 'Albania'],
|
|
94
|
+
['AM', 'Armenia'],
|
|
95
|
+
['AO', 'Angola'],
|
|
96
|
+
['AQ', 'Antarctica'],
|
|
97
|
+
['AR', 'Argentina'],
|
|
98
|
+
['AS', 'American Samoa'],
|
|
99
|
+
['AT', 'Austria'],
|
|
100
|
+
['AU', 'Australia'],
|
|
101
|
+
['AW', 'Aruba'],
|
|
102
|
+
['AX', 'Åland Islands'],
|
|
103
|
+
['AZ', 'Azerbaijan'],
|
|
104
|
+
['BA', 'Bosnia and Herzegovina'],
|
|
105
|
+
['BB', 'Barbados'],
|
|
106
|
+
['BD', 'Bangladesh'],
|
|
107
|
+
['BE', 'Belgium'],
|
|
108
|
+
['BF', 'Burkina Faso'],
|
|
109
|
+
['BG', 'Bulgaria'],
|
|
110
|
+
['BH', 'Bahrain'],
|
|
111
|
+
['BI', 'Burundi'],
|
|
112
|
+
['BJ', 'Benin'],
|
|
113
|
+
['BL', 'Saint Barthélemy'],
|
|
114
|
+
['BM', 'Bermuda'],
|
|
115
|
+
['BN', 'Brunei Darussalam'],
|
|
116
|
+
['BO', 'Bolivia, Plurinational State of'],
|
|
117
|
+
['BQ', 'Bonaire, Sint Eustatius and Saba'],
|
|
118
|
+
['BR', 'Brazil'],
|
|
119
|
+
['BS', 'Bahamas'],
|
|
120
|
+
['BT', 'Bhutan'],
|
|
121
|
+
['BV', 'Bouvet Island'],
|
|
122
|
+
['BW', 'Botswana'],
|
|
123
|
+
['BY', 'Belarus'],
|
|
124
|
+
['BZ', 'Belize'],
|
|
125
|
+
['CA', 'Canada'],
|
|
126
|
+
['CC', 'Cocos (Keeling) Islands'],
|
|
127
|
+
['CD', 'Congo, Democratic Republic of the'],
|
|
128
|
+
['CF', 'Central African Republic'],
|
|
129
|
+
['CG', 'Congo'],
|
|
130
|
+
['CH', 'Switzerland'],
|
|
131
|
+
['CI', "Côte d'Ivoire"],
|
|
132
|
+
['CK', 'Cook Islands'],
|
|
133
|
+
['CL', 'Chile'],
|
|
134
|
+
['CM', 'Cameroon'],
|
|
135
|
+
['CN', 'China'],
|
|
136
|
+
['CO', 'Colombia'],
|
|
137
|
+
['CR', 'Costa Rica'],
|
|
138
|
+
['CU', 'Cuba'],
|
|
139
|
+
['CV', 'Cabo Verde'],
|
|
140
|
+
['CW', 'Curaçao'],
|
|
141
|
+
['CX', 'Christmas Island'],
|
|
142
|
+
['CY', 'Cyprus'],
|
|
143
|
+
['CZ', 'Czechia'],
|
|
144
|
+
['DE', 'Germany'],
|
|
145
|
+
['DJ', 'Djibouti'],
|
|
146
|
+
['DK', 'Denmark'],
|
|
147
|
+
['DM', 'Dominica'],
|
|
148
|
+
['DO', 'Dominican Republic'],
|
|
149
|
+
['DZ', 'Algeria'],
|
|
150
|
+
['EC', 'Ecuador'],
|
|
151
|
+
['EE', 'Estonia'],
|
|
152
|
+
['EG', 'Egypt'],
|
|
153
|
+
['EH', 'Western Sahara'],
|
|
154
|
+
['ER', 'Eritrea'],
|
|
155
|
+
['ES', 'Spain'],
|
|
156
|
+
['ET', 'Ethiopia'],
|
|
157
|
+
['EU', 'European Union'],
|
|
158
|
+
['FI', 'Finland'],
|
|
159
|
+
['FJ', 'Fiji'],
|
|
160
|
+
['FK', 'Falkland Islands (Malvinas)'],
|
|
161
|
+
['FM', 'Micronesia, Federated States of'],
|
|
162
|
+
['FO', 'Faroe Islands'],
|
|
163
|
+
['FR', 'France'],
|
|
164
|
+
['GA', 'Gabon'],
|
|
165
|
+
['GB', 'Great Britain'],
|
|
166
|
+
['GD', 'Grenada'],
|
|
167
|
+
['GE', 'Georgia'],
|
|
168
|
+
['GF', 'French Guiana'],
|
|
169
|
+
['GG', 'Guernsey'],
|
|
170
|
+
['GH', 'Ghana'],
|
|
171
|
+
['GI', 'Gibraltar'],
|
|
172
|
+
['GL', 'Greenland'],
|
|
173
|
+
['GM', 'Gambia'],
|
|
174
|
+
['GN', 'Guinea'],
|
|
175
|
+
['GP', 'Guadeloupe'],
|
|
176
|
+
['GQ', 'Equatorial Guinea'],
|
|
177
|
+
['GR', 'Greece'],
|
|
178
|
+
['GS', 'South Georgia and the South Sandwich Islands'],
|
|
179
|
+
['GT', 'Guatemala'],
|
|
180
|
+
['GU', 'Guam'],
|
|
181
|
+
['GW', 'Guinea-Bissau'],
|
|
182
|
+
['GY', 'Guyana'],
|
|
183
|
+
['HK', 'Hong Kong'],
|
|
184
|
+
['HM', 'Heard Island and McDonald Islands'],
|
|
185
|
+
['HN', 'Honduras'],
|
|
186
|
+
['HR', 'Croatia'],
|
|
187
|
+
['HT', 'Haiti'],
|
|
188
|
+
['HU', 'Hungary'],
|
|
189
|
+
['ID', 'Indonesia'],
|
|
190
|
+
['IE', 'Ireland'],
|
|
191
|
+
['IL', 'Israel'],
|
|
192
|
+
['IM', 'Isle of Man'],
|
|
193
|
+
['IN', 'India'],
|
|
194
|
+
['IO', 'British Indian Ocean Territory'],
|
|
195
|
+
['IQ', 'Iraq'],
|
|
196
|
+
['IR', 'Iran, Islamic Republic of'],
|
|
197
|
+
['IS', 'Iceland'],
|
|
198
|
+
['IT', 'Italy'],
|
|
199
|
+
['JE', 'Jersey'],
|
|
200
|
+
['JM', 'Jamaica'],
|
|
201
|
+
['JO', 'Jordan'],
|
|
202
|
+
['JP', 'Japan'],
|
|
203
|
+
['KE', 'Kenya'],
|
|
204
|
+
['KG', 'Kyrgyzstan'],
|
|
205
|
+
['KH', 'Cambodia'],
|
|
206
|
+
['KI', 'Kiribati'],
|
|
207
|
+
['KM', 'Comoros'],
|
|
208
|
+
['KN', 'Saint Kitts and Nevis'],
|
|
209
|
+
['KP', "Korea, Democratic People's Republic of"],
|
|
210
|
+
['KR', 'Korea, Republic of'],
|
|
211
|
+
['KW', 'Kuwait'],
|
|
212
|
+
['KY', 'Cayman Islands'],
|
|
213
|
+
['KZ', 'Kazakhstan'],
|
|
214
|
+
['LA', "Lao People's Democratic Republic"],
|
|
215
|
+
['LB', 'Lebanon'],
|
|
216
|
+
['LC', 'Saint Lucia'],
|
|
217
|
+
['LI', 'Liechtenstein'],
|
|
218
|
+
['LK', 'Sri Lanka'],
|
|
219
|
+
['LR', 'Liberia'],
|
|
220
|
+
['LS', 'Lesotho'],
|
|
221
|
+
['LT', 'Lithuania'],
|
|
222
|
+
['LU', 'Luxembourg'],
|
|
223
|
+
['LV', 'Latvia'],
|
|
224
|
+
['LY', 'Libya'],
|
|
225
|
+
['MA', 'Morocco'],
|
|
226
|
+
['MC', 'Monaco'],
|
|
227
|
+
['MD', 'Moldova, Republic of'],
|
|
228
|
+
['ME', 'Montenegro'],
|
|
229
|
+
['MF', 'Saint Martin (French part)'],
|
|
230
|
+
['MG', 'Madagascar'],
|
|
231
|
+
['MH', 'Marshall Islands'],
|
|
232
|
+
['MK', 'North Macedonia'],
|
|
233
|
+
['ML', 'Mali'],
|
|
234
|
+
['MM', 'Myanmar'],
|
|
235
|
+
['MN', 'Mongolia'],
|
|
236
|
+
['MO', 'Macao'],
|
|
237
|
+
['MP', 'Northern Mariana Islands'],
|
|
238
|
+
['MQ', 'Martinique'],
|
|
239
|
+
['MR', 'Mauritania'],
|
|
240
|
+
['MS', 'Montserrat'],
|
|
241
|
+
['MT', 'Malta'],
|
|
242
|
+
['MU', 'Mauritius'],
|
|
243
|
+
['MV', 'Maldives'],
|
|
244
|
+
['MW', 'Malawi'],
|
|
245
|
+
['MX', 'Mexico'],
|
|
246
|
+
['MY', 'Malaysia'],
|
|
247
|
+
['MZ', 'Mozambique'],
|
|
248
|
+
['NA', 'Namibia'],
|
|
249
|
+
['NC', 'New Caledonia'],
|
|
250
|
+
['NE', 'Niger'],
|
|
251
|
+
['NF', 'Norfolk Island'],
|
|
252
|
+
['NG', 'Nigeria'],
|
|
253
|
+
['NI', 'Nicaragua'],
|
|
254
|
+
['NL', 'Netherlands, Kingdom of the'],
|
|
255
|
+
['NO', 'Norway'],
|
|
256
|
+
['NP', 'Nepal'],
|
|
257
|
+
['NR', 'Nauru'],
|
|
258
|
+
['NU', 'Niue'],
|
|
259
|
+
['NZ', 'New Zealand'],
|
|
260
|
+
['OM', 'Oman'],
|
|
261
|
+
['PA', 'Panama'],
|
|
262
|
+
['PE', 'Peru'],
|
|
263
|
+
['PF', 'French Polynesia'],
|
|
264
|
+
['PG', 'Papua New Guinea'],
|
|
265
|
+
['PH', 'Philippines'],
|
|
266
|
+
['PK', 'Pakistan'],
|
|
267
|
+
['PL', 'Poland'],
|
|
268
|
+
['PM', 'Saint Pierre and Miquelon'],
|
|
269
|
+
['PN', 'Pitcairn'],
|
|
270
|
+
['PR', 'Puerto Rico'],
|
|
271
|
+
['PS', 'Palestine, State of'],
|
|
272
|
+
['PT', 'Portugal'],
|
|
273
|
+
['PW', 'Palau'],
|
|
274
|
+
['PY', 'Paraguay'],
|
|
275
|
+
['QA', 'Qatar'],
|
|
276
|
+
['RE', 'Réunion'],
|
|
277
|
+
['RO', 'Romania'],
|
|
278
|
+
['RS', 'Serbia'],
|
|
279
|
+
['RU', 'Russian Federation'],
|
|
280
|
+
['RW', 'Rwanda'],
|
|
281
|
+
['SA', 'Saudi Arabia'],
|
|
282
|
+
['SB', 'Solomon Islands'],
|
|
283
|
+
['SC', 'Seychelles'],
|
|
284
|
+
['SD', 'Sudan'],
|
|
285
|
+
['SE', 'Sweden'],
|
|
286
|
+
['SG', 'Singapore'],
|
|
287
|
+
['SH', 'Saint Helena, Ascension and Tristan da Cunha'],
|
|
288
|
+
['SI', 'Slovenia'],
|
|
289
|
+
['SJ', 'Svalbard and Jan Mayen'],
|
|
290
|
+
['SK', 'Slovakia'],
|
|
291
|
+
['SL', 'Sierra Leone'],
|
|
292
|
+
['SM', 'San Marino'],
|
|
293
|
+
['SN', 'Senegal'],
|
|
294
|
+
['SO', 'Somalia'],
|
|
295
|
+
['SR', 'Suriname'],
|
|
296
|
+
['SS', 'South Sudan'],
|
|
297
|
+
['ST', 'Sao Tome and Principe'],
|
|
298
|
+
['SV', 'El Salvador'],
|
|
299
|
+
['SX', 'Sint Maarten (Dutch part)'],
|
|
300
|
+
['SY', 'Syrian Arab Republic'],
|
|
301
|
+
['SZ', 'Eswatini'],
|
|
302
|
+
['TC', 'Turks and Caicos Islands'],
|
|
303
|
+
['TD', 'Chad'],
|
|
304
|
+
['TF', 'French Southern Territories'],
|
|
305
|
+
['TG', 'Togo'],
|
|
306
|
+
['TH', 'Thailand'],
|
|
307
|
+
['TJ', 'Tajikistan'],
|
|
308
|
+
['TK', 'Tokelau'],
|
|
309
|
+
['TL', 'Timor-Leste'],
|
|
310
|
+
['TM', 'Turkmenistan'],
|
|
311
|
+
['TN', 'Tunisia'],
|
|
312
|
+
['TO', 'Tonga'],
|
|
313
|
+
['TR', 'Türkiye'],
|
|
314
|
+
['TT', 'Trinidad and Tobago'],
|
|
315
|
+
['TV', 'Tuvalu'],
|
|
316
|
+
['TW', 'Taiwan, Province of China'],
|
|
317
|
+
['TZ', 'Tanzania, United Republic of'],
|
|
318
|
+
['UA', 'Ukraine'],
|
|
319
|
+
['UG', 'Uganda'],
|
|
320
|
+
['UK', 'United Kingdom of Great Britain and Northern Ireland'],
|
|
321
|
+
['UM', 'United States Minor Outlying Islands'],
|
|
322
|
+
['US', 'United States of America'],
|
|
323
|
+
['UY', 'Uruguay'],
|
|
324
|
+
['UZ', 'Uzbekistan'],
|
|
325
|
+
['VA', 'Holy See'],
|
|
326
|
+
['VC', 'Saint Vincent and the Grenadines'],
|
|
327
|
+
['VE', 'Venezuela, Bolivarian Republic of'],
|
|
328
|
+
['VG', 'Virgin Islands (British)'],
|
|
329
|
+
['VI', 'Virgin Islands (U.S.)'],
|
|
330
|
+
['VN', 'Viet Nam'],
|
|
331
|
+
['VU', 'Vanuatu'],
|
|
332
|
+
['WF', 'Wallis and Futuna'],
|
|
333
|
+
['WS', 'Samoa'],
|
|
334
|
+
['YE', 'Yemen'],
|
|
335
|
+
['YT', 'Mayotte'],
|
|
336
|
+
['ZA', 'South Africa'],
|
|
337
|
+
['ZM', 'Zambia'],
|
|
338
|
+
['ZW', 'Zimbabwe'],
|
|
339
|
+
]);
|
|
340
|
+
/**
|
|
341
|
+
* ISO-3166 US state ISO codes
|
|
342
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-2:US
|
|
343
|
+
* */
|
|
344
|
+
const usStates = new Map([
|
|
345
|
+
['US-AL', 'Alabama'],
|
|
346
|
+
['US-AK', 'Alaska'],
|
|
347
|
+
['US-AZ', 'Arizona'],
|
|
348
|
+
['US-AR', 'Arkansas'],
|
|
349
|
+
['US-CA', 'California'],
|
|
350
|
+
['US-CO', 'Colorado'],
|
|
351
|
+
['US-CT', 'Connecticut'],
|
|
352
|
+
['US-DE', 'Delaware'],
|
|
353
|
+
['US-FL', 'Florida'],
|
|
354
|
+
['US-GA', 'Georgia'],
|
|
355
|
+
['US-HI', 'Hawaii'],
|
|
356
|
+
['US-ID', 'Idaho'],
|
|
357
|
+
['US-IL', 'Illinois'],
|
|
358
|
+
['US-IN', 'Indiana'],
|
|
359
|
+
['US-IA', 'Iowa'],
|
|
360
|
+
['US-KS', 'Kansas'],
|
|
361
|
+
['US-KY', 'Kentucky'],
|
|
362
|
+
['US-LA', 'Louisiana'],
|
|
363
|
+
['US-ME', 'Maine'],
|
|
364
|
+
['US-MD', 'Maryland'],
|
|
365
|
+
['US-MA', 'Massachusetts'],
|
|
366
|
+
['US-MI', 'Michigan'],
|
|
367
|
+
['US-MN', 'Minnesota'],
|
|
368
|
+
['US-MS', 'Mississippi'],
|
|
369
|
+
['US-MO', 'Missouri'],
|
|
370
|
+
['US-MT', 'Montana'],
|
|
371
|
+
['US-NE', 'Nebraska'],
|
|
372
|
+
['US-NV', 'Nevada'],
|
|
373
|
+
['US-NH', 'New Hampshire'],
|
|
374
|
+
['US-NJ', 'New Jersey'],
|
|
375
|
+
['US-NM', 'New Mexico'],
|
|
376
|
+
['US-NY', 'New York'],
|
|
377
|
+
['US-NC', 'North Carolina'],
|
|
378
|
+
['US-ND', 'North Dakota'],
|
|
379
|
+
['US-OH', 'Ohio'],
|
|
380
|
+
['US-OK', 'Oklahoma'],
|
|
381
|
+
['US-OR', 'Oregon'],
|
|
382
|
+
['US-PA', 'Pennsylvania'],
|
|
383
|
+
['US-RI', 'Rhode Island'],
|
|
384
|
+
['US-SC', 'South Carolina'],
|
|
385
|
+
['US-SD', 'South Dakota'],
|
|
386
|
+
['US-TN', 'Tennessee'],
|
|
387
|
+
['US-TX', 'Texas'],
|
|
388
|
+
['US-UT', 'Utah'],
|
|
389
|
+
['US-VT', 'Vermont'],
|
|
390
|
+
['US-VA', 'Virginia'],
|
|
391
|
+
['US-WA', 'Washington'],
|
|
392
|
+
['US-WV', 'West Virginia'],
|
|
393
|
+
['US-WI', 'Wisconsin'],
|
|
394
|
+
['US-WY', 'Wyoming'],
|
|
395
|
+
['US-DC', 'District of Columbia'],
|
|
396
|
+
['US-AS', 'American Samoa'],
|
|
397
|
+
['US-GU', 'Guam'],
|
|
398
|
+
['US-MP', 'Northern Mariana Islands'],
|
|
399
|
+
['US-PR', 'Puerto Rico'],
|
|
400
|
+
['US-UM', 'United States Minor Outlying Islands'],
|
|
401
|
+
['US-VI', 'Virgin Islands, U.S.'],
|
|
402
|
+
]);
|
|
403
|
+
new Set([...isoCountries.keys(), ...usStates.keys()]);
|
|
404
|
+
|
|
405
|
+
const normalize = (urlString) => {
|
|
406
|
+
try {
|
|
407
|
+
const cleanUrl = urlString.replace(/\t/g, '');
|
|
408
|
+
const urlObj = new URL(cleanUrl);
|
|
409
|
+
const pathname = urlObj.pathname.replace(/\/+$/, ''); // Remove trailing slash
|
|
410
|
+
return `${urlObj.origin}${pathname}`.toLowerCase();
|
|
411
|
+
}
|
|
412
|
+
catch (e) {
|
|
413
|
+
// Fallback for non-URL values
|
|
414
|
+
return urlString.replace(/\t/g, '').toLowerCase().replace(/\/+$/, '');
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const getSourceName = (sourceMapping, url) => {
|
|
418
|
+
const mapping = tryParse(sourceMapping, []);
|
|
419
|
+
if (!mapping.length) {
|
|
420
|
+
logger.log('Invalid sourceMapping JSON:', sourceMapping);
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const normalizedUrl = normalize(url);
|
|
424
|
+
const match = mapping.find((item) => normalize(item.url) === normalizedUrl);
|
|
425
|
+
return match ? match.source : null;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const initOneScreen = (offerId, affId, sourceMapping) => {
|
|
429
|
+
var _a;
|
|
430
|
+
if (typeof document == 'undefined') {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const url = window.location.origin + window.location.pathname;
|
|
434
|
+
try {
|
|
435
|
+
const source = getSourceName(sourceMapping, url);
|
|
436
|
+
if (source) {
|
|
437
|
+
const pixel = document.createElement('img');
|
|
438
|
+
pixel.src = `https://accretivemedia.go2cloud.org/aff_i?offer_id=${offerId}&aff_id=${affId}&source=${source}`;
|
|
439
|
+
pixel.width = 0;
|
|
440
|
+
pixel.height = 0;
|
|
441
|
+
pixel.style.position = 'absolute';
|
|
442
|
+
pixel.style.visibility = 'hidden';
|
|
443
|
+
pixel.setAttribute('border', '0');
|
|
444
|
+
const firstScript = document.getElementsByTagName('script')[0];
|
|
445
|
+
(_a = firstScript.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(pixel, firstScript);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
logger.log('Source is not mapped for this URL');
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
logger.log('Not able to parse the Source and URL form Array');
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
const init = ({ manifest }) => {
|
|
456
|
+
if (typeof window == 'undefined' ||
|
|
457
|
+
!manifest.variables ||
|
|
458
|
+
manifest.variables['enableBrowser'] !== '1' ||
|
|
459
|
+
!manifest.variables['offerId'] ||
|
|
460
|
+
!manifest.variables['affId'] ||
|
|
461
|
+
!manifest.variables['sourceMapping']) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
initOneScreen(manifest.variables['offerId'], manifest.variables['affId'], manifest.variables['sourceMapping']);
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
468
|
+
const data = {
|
|
469
|
+
name: packageName,
|
|
470
|
+
init,
|
|
471
|
+
};
|
|
472
|
+
try {
|
|
473
|
+
if (window) {
|
|
474
|
+
if (!window.edgetagProviders) {
|
|
475
|
+
window.edgetagProviders = [];
|
|
476
|
+
}
|
|
477
|
+
window.edgetagProviders.push(data);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
catch {
|
|
481
|
+
// No window
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
module.exports = data;
|