@blotoutio/providers-pinterest-sdk 1.68.2 → 1.69.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.
Files changed (4) hide show
  1. package/index.cjs.js +731 -3
  2. package/index.js +731 -3
  3. package/index.mjs +731 -3
  4. package/package.json +1 -1
package/index.js CHANGED
@@ -4,6 +4,719 @@ var ProvidersPinterestSdk = (function () {
4
4
  const packageName = 'pinterest';
5
5
  const sdkUrl = 'https://s.pinimg.com/ct/core.js';
6
6
 
7
+ const keyPrefix = `_worker`;
8
+
9
+ const initKey = `${keyPrefix}StoreMultiple`;
10
+ const getData = (destination, persistType, key = initKey) => {
11
+ let data;
12
+ if (persistType === 'session') {
13
+ data = getSession(key);
14
+ }
15
+ else {
16
+ data = getLocal(key);
17
+ }
18
+ return (data === null || data === void 0 ? void 0 : data[destination]) || {};
19
+ };
20
+ const getLocal = (key) => {
21
+ try {
22
+ if (!localStorage) {
23
+ return {};
24
+ }
25
+ const data = localStorage.getItem(key);
26
+ if (!data) {
27
+ return {};
28
+ }
29
+ return JSON.parse(data) || {};
30
+ }
31
+ catch {
32
+ return {};
33
+ }
34
+ };
35
+ const getSession = (key) => {
36
+ try {
37
+ if (!sessionStorage) {
38
+ return {};
39
+ }
40
+ const data = sessionStorage.getItem(key);
41
+ if (!data) {
42
+ return {};
43
+ }
44
+ return JSON.parse(data) || {};
45
+ }
46
+ catch {
47
+ return {};
48
+ }
49
+ };
50
+
51
+ /**
52
+ * Known ad-network click ID query parameters and the human-readable provider
53
+ * label each one maps to. Used by the CDN worker to resolve `inSessionTouch`
54
+ * and by the analytics API to classify paid-media touch sessions.
55
+ *
56
+ * Keep this list in sync with `defaultParams` in queryParams.ts when new
57
+ * click ID providers are added.
58
+ */
59
+ const CLICK_IDS = [
60
+ { param: 'fbclid', label: 'Facebook' }, // Facebook Ads
61
+ { param: 'gclid', label: 'Google' }, // Google Ads (click)
62
+ { param: 'gbraid', label: 'Google' }, // Google Ads (iOS app)
63
+ { param: 'wbraid', label: 'Google' }, // Google Ads (iOS web)
64
+ { param: 'msclkid', label: 'Bing' }, // Microsoft Bing Ads
65
+ { param: 'ttclid', label: 'TikTok' }, // TikTok Ads
66
+ { param: 'ScCid', label: 'Snapchat' }, // Snapchat Ads
67
+ { param: 'epik', label: 'Pinterest' }, // Pinterest Ads
68
+ { param: 'li_fat_id', label: 'LinkedIn' }, // LinkedIn Ads
69
+ { param: 'twclid', label: 'Twitter' }, // X (Twitter) Ads
70
+ { param: 'rdt_cid', label: 'Reddit' }, // Reddit Ads
71
+ { param: 'aleid', label: 'AppLovin' }, // AppLovin
72
+ { param: 'tabclid', label: 'Taboola' }, // Taboola
73
+ { param: 'obclid', label: 'Outbrain' }, // Outbrain
74
+ { param: 'trybe', label: 'Trybe' }, // Trybe
75
+ { param: '_kx', label: 'Klaviyo' }, // Klaviyo email campaigns
76
+ { param: 'mc_eid', label: 'Mailchimp' }, // Mailchimp email campaigns
77
+ { param: 'ttd_id', label: 'The Trade Desk' }, // The Trade Desk programmatic
78
+ { param: 'evsclid', label: 'EvoSearch' }, // EvoSearch
79
+ { param: 'li_did', label: 'Live Intent' }, // LiveIntent device-level ad
80
+ { param: '_raclid', label: 'Rumble' }, // Rumble Ads
81
+ { param: 'ref_id', label: 'StackAdapt' }, // StackAdapt programmatic
82
+ { param: 'duel_a', label: 'Duel' }, // Duel referral/advocacy
83
+ ];
84
+
85
+ const expand = (str) => str.split(',').flatMap((entry) => {
86
+ if (!entry.includes('-')) {
87
+ return entry;
88
+ }
89
+ const result = [];
90
+ const [start, end] = entry.split('-').map(Number);
91
+ for (let i = start; i <= end; i++) {
92
+ result.push(i.toString());
93
+ }
94
+ return result;
95
+ });
96
+ /**
97
+ * Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
98
+ *
99
+ * In Dev Tools, select the `tbody` element containing the area codes and run the following code,
100
+ * replacing the emdash character with a simple endash:
101
+ *
102
+ * ```ts
103
+ * [...$0.querySelectorAll('td:first-child')]
104
+ * .filter(cell => cell.firstChild.nodeName != 'A')
105
+ * .map(cell => cell.textContent.trim()).join(',')
106
+ * ```
107
+ */
108
+ const invalidNANPAreaCodes = new Set([
109
+ ...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'),
110
+ ...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'),
111
+ ...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'),
112
+ ...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'),
113
+ ...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'),
114
+ ...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'),
115
+ ...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
116
+ ...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'),
117
+ ]);
118
+ const isValidZone1AreaCode = (num) => {
119
+ if (!/^[2-9]\d{2}$/.test(num)) {
120
+ return false;
121
+ }
122
+ return !invalidNANPAreaCodes.has(num);
123
+ };
124
+
125
+ // North America; assume local numbers as NANP
126
+ const ZONE_1 = /^[+]1([2-9][0-8][0-9])[2-9][0-9]{6}$/;
127
+ // Africa
128
+ const ZONE_2 = /^[+]2([07][0-9]{4,13}|(1[12368]|[234][0-9]|5[0-8]|6[0-9]|9[01789])[0-9]{4,12})$/;
129
+ // Europe
130
+ const EU_TWO_DIGIT = `(3[0-469]|4[013-9])[0-9]{4,15}`;
131
+ const EU_THREE_DIGIT = `((3[578]|42)[0-9])[0-9]{4,12}`;
132
+ const ZONE_3_4 = new RegExp(`^[+](${EU_TWO_DIGIT}|${EU_THREE_DIGIT})$`);
133
+ // South America
134
+ const ZONE_5 = /^[+]5([1-8][0-9]{4,13}|[09][0-9][0-9]{4,12})$/;
135
+ // Southeast Asia & Oceania
136
+ const ZONE_6 = /^[+]6([0-6][0-9]{4,13}|(7[02-9]|8[0-35-9]|9[0-2])[0-9]{4,12})$/;
137
+ // Russia & Kazakhstan
138
+ const ZONE_7 = /^[+]7([1-9])[0-9]{4,13}$/;
139
+ // East & South Asia
140
+ const ZONE_8 = /^[+]8([1246][0-9]{4,13}|(0[08]|5[02356]|70|8[0-36])[0-9]{4,12})$/;
141
+ // Middle East, West & Central Asia, South Asia, Eastern Europe
142
+ const ZONE_9 = /^[+]9([0123458][0-9]{4,13}|(6[0-8]|7[0-79]|9[2-8])[0-9]{4,12})$/;
143
+ const checkers = [
144
+ (num) => {
145
+ const match = num.match(ZONE_1);
146
+ if (!match) {
147
+ return false;
148
+ }
149
+ return isValidZone1AreaCode(match[1]);
150
+ },
151
+ (num) => ZONE_2.test(num),
152
+ (num) => ZONE_3_4.test(num),
153
+ (num) => ZONE_5.test(num),
154
+ (num) => ZONE_6.test(num),
155
+ (num) => ZONE_7.test(num),
156
+ (num) => ZONE_8.test(num),
157
+ (num) => ZONE_9.test(num),
158
+ ];
159
+ /**
160
+ * Returns a boolean indicating whether or not a phone number conforms to a
161
+ * plausible E.164 phone number. It does not guarantee validity as each national
162
+ * operator may have various phone number lengths per area code or national
163
+ * scheme. It only validates currently active country codes and length
164
+ * restrictions.
165
+ *
166
+ * > *NOTE:* `E.164` format requires a leading plus sign, so you must set
167
+ * > `keepPlus` to `true` when normalising numbers:
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const number = isPlausibleE164Number(normalizePhoneNumber(str, true))
172
+ * ```
173
+ */
174
+ const isPlausibleE164Number = (str) => str.startsWith('+') && checkers.some((check) => check(str));
175
+ const INTL_PREFIX = /^00|[+]+/;
176
+ /**
177
+ * Attempts to convert a given phone number string into an E.164 formatted
178
+ * number. In order to check whether the number is plausibly a real number, it
179
+ * must be checked with `isPlausibleE164Number` after normalising.
180
+ */
181
+ const normalizePhoneNumber = (str, keepPlus = false) => {
182
+ if (!str) {
183
+ return '';
184
+ }
185
+ let normalized = str;
186
+ // assume non-international numbers are US numbers
187
+ if (!INTL_PREFIX.test(normalized)) {
188
+ normalized = `+1${normalized}`;
189
+ }
190
+ normalized = normalized.replace(/[^+0-9]/g, '').replace(INTL_PREFIX, '+');
191
+ return keepPlus ? normalized : normalized.slice(1);
192
+ };
193
+
194
+ /**
195
+ * ISO-3166 2-leter country codes and their names
196
+ * @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
197
+ */
198
+ const isoCountries = new Map([
199
+ ['AD', 'Andorra'],
200
+ ['AE', 'United Arab Emirates'],
201
+ ['AF', 'Afghanistan'],
202
+ ['AG', 'Antigua and Barbuda'],
203
+ ['AI', 'Anguilla'],
204
+ ['AL', 'Albania'],
205
+ ['AM', 'Armenia'],
206
+ ['AO', 'Angola'],
207
+ ['AQ', 'Antarctica'],
208
+ ['AR', 'Argentina'],
209
+ ['AS', 'American Samoa'],
210
+ ['AT', 'Austria'],
211
+ ['AU', 'Australia'],
212
+ ['AW', 'Aruba'],
213
+ ['AX', 'Åland Islands'],
214
+ ['AZ', 'Azerbaijan'],
215
+ ['BA', 'Bosnia and Herzegovina'],
216
+ ['BB', 'Barbados'],
217
+ ['BD', 'Bangladesh'],
218
+ ['BE', 'Belgium'],
219
+ ['BF', 'Burkina Faso'],
220
+ ['BG', 'Bulgaria'],
221
+ ['BH', 'Bahrain'],
222
+ ['BI', 'Burundi'],
223
+ ['BJ', 'Benin'],
224
+ ['BL', 'Saint Barthélemy'],
225
+ ['BM', 'Bermuda'],
226
+ ['BN', 'Brunei Darussalam'],
227
+ ['BO', 'Bolivia, Plurinational State of'],
228
+ ['BQ', 'Bonaire, Sint Eustatius and Saba'],
229
+ ['BR', 'Brazil'],
230
+ ['BS', 'Bahamas'],
231
+ ['BT', 'Bhutan'],
232
+ ['BV', 'Bouvet Island'],
233
+ ['BW', 'Botswana'],
234
+ ['BY', 'Belarus'],
235
+ ['BZ', 'Belize'],
236
+ ['CA', 'Canada'],
237
+ ['CC', 'Cocos (Keeling) Islands'],
238
+ ['CD', 'Congo, Democratic Republic of the'],
239
+ ['CF', 'Central African Republic'],
240
+ ['CG', 'Congo'],
241
+ ['CH', 'Switzerland'],
242
+ ['CI', "Côte d'Ivoire"],
243
+ ['CK', 'Cook Islands'],
244
+ ['CL', 'Chile'],
245
+ ['CM', 'Cameroon'],
246
+ ['CN', 'China'],
247
+ ['CO', 'Colombia'],
248
+ ['CR', 'Costa Rica'],
249
+ ['CU', 'Cuba'],
250
+ ['CV', 'Cabo Verde'],
251
+ ['CW', 'Curaçao'],
252
+ ['CX', 'Christmas Island'],
253
+ ['CY', 'Cyprus'],
254
+ ['CZ', 'Czechia'],
255
+ ['DE', 'Germany'],
256
+ ['DJ', 'Djibouti'],
257
+ ['DK', 'Denmark'],
258
+ ['DM', 'Dominica'],
259
+ ['DO', 'Dominican Republic'],
260
+ ['DZ', 'Algeria'],
261
+ ['EC', 'Ecuador'],
262
+ ['EE', 'Estonia'],
263
+ ['EG', 'Egypt'],
264
+ ['EH', 'Western Sahara'],
265
+ ['ER', 'Eritrea'],
266
+ ['ES', 'Spain'],
267
+ ['ET', 'Ethiopia'],
268
+ ['EU', 'European Union'],
269
+ ['FI', 'Finland'],
270
+ ['FJ', 'Fiji'],
271
+ ['FK', 'Falkland Islands (Malvinas)'],
272
+ ['FM', 'Micronesia, Federated States of'],
273
+ ['FO', 'Faroe Islands'],
274
+ ['FR', 'France'],
275
+ ['GA', 'Gabon'],
276
+ ['GB', 'Great Britain'],
277
+ ['GD', 'Grenada'],
278
+ ['GE', 'Georgia'],
279
+ ['GF', 'French Guiana'],
280
+ ['GG', 'Guernsey'],
281
+ ['GH', 'Ghana'],
282
+ ['GI', 'Gibraltar'],
283
+ ['GL', 'Greenland'],
284
+ ['GM', 'Gambia'],
285
+ ['GN', 'Guinea'],
286
+ ['GP', 'Guadeloupe'],
287
+ ['GQ', 'Equatorial Guinea'],
288
+ ['GR', 'Greece'],
289
+ ['GS', 'South Georgia and the South Sandwich Islands'],
290
+ ['GT', 'Guatemala'],
291
+ ['GU', 'Guam'],
292
+ ['GW', 'Guinea-Bissau'],
293
+ ['GY', 'Guyana'],
294
+ ['HK', 'Hong Kong'],
295
+ ['HM', 'Heard Island and McDonald Islands'],
296
+ ['HN', 'Honduras'],
297
+ ['HR', 'Croatia'],
298
+ ['HT', 'Haiti'],
299
+ ['HU', 'Hungary'],
300
+ ['ID', 'Indonesia'],
301
+ ['IE', 'Ireland'],
302
+ ['IL', 'Israel'],
303
+ ['IM', 'Isle of Man'],
304
+ ['IN', 'India'],
305
+ ['IO', 'British Indian Ocean Territory'],
306
+ ['IQ', 'Iraq'],
307
+ ['IR', 'Iran, Islamic Republic of'],
308
+ ['IS', 'Iceland'],
309
+ ['IT', 'Italy'],
310
+ ['JE', 'Jersey'],
311
+ ['JM', 'Jamaica'],
312
+ ['JO', 'Jordan'],
313
+ ['JP', 'Japan'],
314
+ ['KE', 'Kenya'],
315
+ ['KG', 'Kyrgyzstan'],
316
+ ['KH', 'Cambodia'],
317
+ ['KI', 'Kiribati'],
318
+ ['KM', 'Comoros'],
319
+ ['KN', 'Saint Kitts and Nevis'],
320
+ ['KP', "Korea, Democratic People's Republic of"],
321
+ ['KR', 'Korea, Republic of'],
322
+ ['KW', 'Kuwait'],
323
+ ['KY', 'Cayman Islands'],
324
+ ['KZ', 'Kazakhstan'],
325
+ ['LA', "Lao People's Democratic Republic"],
326
+ ['LB', 'Lebanon'],
327
+ ['LC', 'Saint Lucia'],
328
+ ['LI', 'Liechtenstein'],
329
+ ['LK', 'Sri Lanka'],
330
+ ['LR', 'Liberia'],
331
+ ['LS', 'Lesotho'],
332
+ ['LT', 'Lithuania'],
333
+ ['LU', 'Luxembourg'],
334
+ ['LV', 'Latvia'],
335
+ ['LY', 'Libya'],
336
+ ['MA', 'Morocco'],
337
+ ['MC', 'Monaco'],
338
+ ['MD', 'Moldova, Republic of'],
339
+ ['ME', 'Montenegro'],
340
+ ['MF', 'Saint Martin (French part)'],
341
+ ['MG', 'Madagascar'],
342
+ ['MH', 'Marshall Islands'],
343
+ ['MK', 'North Macedonia'],
344
+ ['ML', 'Mali'],
345
+ ['MM', 'Myanmar'],
346
+ ['MN', 'Mongolia'],
347
+ ['MO', 'Macao'],
348
+ ['MP', 'Northern Mariana Islands'],
349
+ ['MQ', 'Martinique'],
350
+ ['MR', 'Mauritania'],
351
+ ['MS', 'Montserrat'],
352
+ ['MT', 'Malta'],
353
+ ['MU', 'Mauritius'],
354
+ ['MV', 'Maldives'],
355
+ ['MW', 'Malawi'],
356
+ ['MX', 'Mexico'],
357
+ ['MY', 'Malaysia'],
358
+ ['MZ', 'Mozambique'],
359
+ ['NA', 'Namibia'],
360
+ ['NC', 'New Caledonia'],
361
+ ['NE', 'Niger'],
362
+ ['NF', 'Norfolk Island'],
363
+ ['NG', 'Nigeria'],
364
+ ['NI', 'Nicaragua'],
365
+ ['NL', 'Netherlands, Kingdom of the'],
366
+ ['NO', 'Norway'],
367
+ ['NP', 'Nepal'],
368
+ ['NR', 'Nauru'],
369
+ ['NU', 'Niue'],
370
+ ['NZ', 'New Zealand'],
371
+ ['OM', 'Oman'],
372
+ ['PA', 'Panama'],
373
+ ['PE', 'Peru'],
374
+ ['PF', 'French Polynesia'],
375
+ ['PG', 'Papua New Guinea'],
376
+ ['PH', 'Philippines'],
377
+ ['PK', 'Pakistan'],
378
+ ['PL', 'Poland'],
379
+ ['PM', 'Saint Pierre and Miquelon'],
380
+ ['PN', 'Pitcairn'],
381
+ ['PR', 'Puerto Rico'],
382
+ ['PS', 'Palestine, State of'],
383
+ ['PT', 'Portugal'],
384
+ ['PW', 'Palau'],
385
+ ['PY', 'Paraguay'],
386
+ ['QA', 'Qatar'],
387
+ ['RE', 'Réunion'],
388
+ ['RO', 'Romania'],
389
+ ['RS', 'Serbia'],
390
+ ['RU', 'Russian Federation'],
391
+ ['RW', 'Rwanda'],
392
+ ['SA', 'Saudi Arabia'],
393
+ ['SB', 'Solomon Islands'],
394
+ ['SC', 'Seychelles'],
395
+ ['SD', 'Sudan'],
396
+ ['SE', 'Sweden'],
397
+ ['SG', 'Singapore'],
398
+ ['SH', 'Saint Helena, Ascension and Tristan da Cunha'],
399
+ ['SI', 'Slovenia'],
400
+ ['SJ', 'Svalbard and Jan Mayen'],
401
+ ['SK', 'Slovakia'],
402
+ ['SL', 'Sierra Leone'],
403
+ ['SM', 'San Marino'],
404
+ ['SN', 'Senegal'],
405
+ ['SO', 'Somalia'],
406
+ ['SR', 'Suriname'],
407
+ ['SS', 'South Sudan'],
408
+ ['ST', 'Sao Tome and Principe'],
409
+ ['SV', 'El Salvador'],
410
+ ['SX', 'Sint Maarten (Dutch part)'],
411
+ ['SY', 'Syrian Arab Republic'],
412
+ ['SZ', 'Eswatini'],
413
+ ['TC', 'Turks and Caicos Islands'],
414
+ ['TD', 'Chad'],
415
+ ['TF', 'French Southern Territories'],
416
+ ['TG', 'Togo'],
417
+ ['TH', 'Thailand'],
418
+ ['TJ', 'Tajikistan'],
419
+ ['TK', 'Tokelau'],
420
+ ['TL', 'Timor-Leste'],
421
+ ['TM', 'Turkmenistan'],
422
+ ['TN', 'Tunisia'],
423
+ ['TO', 'Tonga'],
424
+ ['TR', 'Türkiye'],
425
+ ['TT', 'Trinidad and Tobago'],
426
+ ['TV', 'Tuvalu'],
427
+ ['TW', 'Taiwan, Province of China'],
428
+ ['TZ', 'Tanzania, United Republic of'],
429
+ ['UA', 'Ukraine'],
430
+ ['UG', 'Uganda'],
431
+ ['UK', 'United Kingdom of Great Britain and Northern Ireland'],
432
+ ['UM', 'United States Minor Outlying Islands'],
433
+ ['US', 'United States of America'],
434
+ ['UY', 'Uruguay'],
435
+ ['UZ', 'Uzbekistan'],
436
+ ['VA', 'Holy See'],
437
+ ['VC', 'Saint Vincent and the Grenadines'],
438
+ ['VE', 'Venezuela, Bolivarian Republic of'],
439
+ ['VG', 'Virgin Islands (British)'],
440
+ ['VI', 'Virgin Islands (U.S.)'],
441
+ ['VN', 'Viet Nam'],
442
+ ['VU', 'Vanuatu'],
443
+ ['WF', 'Wallis and Futuna'],
444
+ ['WS', 'Samoa'],
445
+ ['YE', 'Yemen'],
446
+ ['YT', 'Mayotte'],
447
+ ['ZA', 'South Africa'],
448
+ ['ZM', 'Zambia'],
449
+ ['ZW', 'Zimbabwe'],
450
+ ]);
451
+ /**
452
+ * ISO-3166 US state ISO codes
453
+ * @see https://en.wikipedia.org/wiki/ISO_3166-2:US
454
+ * */
455
+ const usStates = new Map([
456
+ ['US-AL', 'Alabama'],
457
+ ['US-AK', 'Alaska'],
458
+ ['US-AZ', 'Arizona'],
459
+ ['US-AR', 'Arkansas'],
460
+ ['US-CA', 'California'],
461
+ ['US-CO', 'Colorado'],
462
+ ['US-CT', 'Connecticut'],
463
+ ['US-DE', 'Delaware'],
464
+ ['US-FL', 'Florida'],
465
+ ['US-GA', 'Georgia'],
466
+ ['US-HI', 'Hawaii'],
467
+ ['US-ID', 'Idaho'],
468
+ ['US-IL', 'Illinois'],
469
+ ['US-IN', 'Indiana'],
470
+ ['US-IA', 'Iowa'],
471
+ ['US-KS', 'Kansas'],
472
+ ['US-KY', 'Kentucky'],
473
+ ['US-LA', 'Louisiana'],
474
+ ['US-ME', 'Maine'],
475
+ ['US-MD', 'Maryland'],
476
+ ['US-MA', 'Massachusetts'],
477
+ ['US-MI', 'Michigan'],
478
+ ['US-MN', 'Minnesota'],
479
+ ['US-MS', 'Mississippi'],
480
+ ['US-MO', 'Missouri'],
481
+ ['US-MT', 'Montana'],
482
+ ['US-NE', 'Nebraska'],
483
+ ['US-NV', 'Nevada'],
484
+ ['US-NH', 'New Hampshire'],
485
+ ['US-NJ', 'New Jersey'],
486
+ ['US-NM', 'New Mexico'],
487
+ ['US-NY', 'New York'],
488
+ ['US-NC', 'North Carolina'],
489
+ ['US-ND', 'North Dakota'],
490
+ ['US-OH', 'Ohio'],
491
+ ['US-OK', 'Oklahoma'],
492
+ ['US-OR', 'Oregon'],
493
+ ['US-PA', 'Pennsylvania'],
494
+ ['US-RI', 'Rhode Island'],
495
+ ['US-SC', 'South Carolina'],
496
+ ['US-SD', 'South Dakota'],
497
+ ['US-TN', 'Tennessee'],
498
+ ['US-TX', 'Texas'],
499
+ ['US-UT', 'Utah'],
500
+ ['US-VT', 'Vermont'],
501
+ ['US-VA', 'Virginia'],
502
+ ['US-WA', 'Washington'],
503
+ ['US-WV', 'West Virginia'],
504
+ ['US-WI', 'Wisconsin'],
505
+ ['US-WY', 'Wyoming'],
506
+ ['US-DC', 'District of Columbia'],
507
+ ['US-AS', 'American Samoa'],
508
+ ['US-GU', 'Guam'],
509
+ ['US-MP', 'Northern Mariana Islands'],
510
+ ['US-PR', 'Puerto Rico'],
511
+ ['US-UM', 'United States Minor Outlying Islands'],
512
+ ['US-VI', 'Virgin Islands, U.S.'],
513
+ ]);
514
+ /**
515
+ * ISO 3166-2:CA province and territory codes, keyed `CA-XX` to mirror
516
+ * `usStates`. Used by the consent banner's Canada region to offer province
517
+ * selection (Québec is treated specially by the regional consent config).
518
+ */
519
+ const caProvinces = new Map([
520
+ ['CA-AB', 'Alberta'],
521
+ ['CA-BC', 'British Columbia'],
522
+ ['CA-MB', 'Manitoba'],
523
+ ['CA-NB', 'New Brunswick'],
524
+ ['CA-NL', 'Newfoundland and Labrador'],
525
+ ['CA-NS', 'Nova Scotia'],
526
+ ['CA-NT', 'Northwest Territories'],
527
+ ['CA-NU', 'Nunavut'],
528
+ ['CA-ON', 'Ontario'],
529
+ ['CA-PE', 'Prince Edward Island'],
530
+ ['CA-QC', 'Quebec'],
531
+ ['CA-SK', 'Saskatchewan'],
532
+ ['CA-YT', 'Yukon'],
533
+ ]);
534
+ new Set([
535
+ ...isoCountries.keys(),
536
+ ...usStates.keys(),
537
+ ...caProvinces.keys(),
538
+ ]);
539
+
540
+ /**
541
+ * Exact utm_source normalization (lowercase key → canonical name).
542
+ *
543
+ * Use exact match when the key is short, generic, or must not accidentally
544
+ * absorb variant spellings (e.g. "impact" must not match "impact_radius").
545
+ *
546
+ * Ordering: Paid (search/social → ad networks → affiliates) →
547
+ * Organic (AI/discovery) → Retention (email → SMS → push → post-purchase)
548
+ */
549
+ const UTM_SOURCE_EXACT = {
550
+ // ── Paid – Search & Social ────────────────────────────────────────────────
551
+ google: 'Google',
552
+ adwords: 'Google',
553
+ youtube: 'Google',
554
+ yt: 'Google',
555
+ meta: 'Facebook',
556
+ facebook: 'Facebook',
557
+ instagram: 'Facebook',
558
+ ig: 'Facebook',
559
+ igshopping: 'Facebook',
560
+ threads: 'Facebook',
561
+ twitter: 'Twitter',
562
+ snapchat: 'Snapchat',
563
+ pinterest: 'Pinterest',
564
+ bing: 'Bing',
565
+ microsoft: 'Bing',
566
+ tiktok: 'TikTok',
567
+ // ── Paid – Ad Networks ───────────────────────────────────────────────────
568
+ rtbhouse: 'RTB House',
569
+ applovin: 'AppLovin',
570
+ ttd: 'The Trade Desk',
571
+ amazondsp: 'Amazon DSP',
572
+ axon: 'Axon',
573
+ duel: 'Duel',
574
+ // ── Paid – Affiliates ────────────────────────────────────────────────────
575
+ awin: 'Awin',
576
+ 'affiliate-cj': 'CJ Affiliate',
577
+ impact: 'Impact',
578
+ rakuten: 'Rakuten',
579
+ superfiliate: 'Superfiliate',
580
+ // ── Organic – AI & Discovery ─────────────────────────────────────────────
581
+ perplexity: 'Perplexity',
582
+ chatgpt: 'ChatGPT',
583
+ 'chatgpt.com': 'ChatGPT',
584
+ openai: 'ChatGPT',
585
+ 'copilot.com': 'Microsoft Copilot',
586
+ copilot: 'Microsoft Copilot',
587
+ applenews: 'Apple News',
588
+ whatsapp: 'WhatsApp',
589
+ podcast: 'Podcast',
590
+ // ── Retention – Email ────────────────────────────────────────────────────
591
+ mailchimp: 'Mailchimp',
592
+ omnisend: 'Omnisend',
593
+ iterable: 'Iterable',
594
+ listrak: 'Listrak',
595
+ sailthru: 'Sailthru',
596
+ // ── Retention – Push ─────────────────────────────────────────────────────
597
+ pushowl: 'PushOwl',
598
+ // ── Retention – Post-purchase / Payment ──────────────────────────────────
599
+ narvar: 'Narvar',
600
+ shop_app: 'Shop App',
601
+ salesforce: 'Salesforce',
602
+ yotpo: 'Yotpo',
603
+ };
604
+ /**
605
+ * Partial utm_source normalization (startsWith prefix check, lowercase).
606
+ *
607
+ * Checked after exact match so short exact keys (e.g. "ig", "yt") win first.
608
+ */
609
+ const UTM_SOURCE_PARTIAL = [
610
+ // ── Paid – Social ─────────────────────────────────────────────────────────
611
+ { prefix: 'tiktok', name: 'TikTok' },
612
+ // ── Paid – Ad Networks ───────────────────────────────────────────────────
613
+ { prefix: 'criteo', name: 'Criteo' },
614
+ // ── Retention – Email ────────────────────────────────────────────────────
615
+ { prefix: 'klaviyo', name: 'Klaviyo' },
616
+ // ── Retention – SMS ──────────────────────────────────────────────────────
617
+ { prefix: 'attentive', name: 'Attentive' },
618
+ { prefix: 'postscript', name: 'Postscript' },
619
+ // ── Retention – Post-purchase / Payment ──────────────────────────────────
620
+ { prefix: 'afterpay', name: 'Afterpay' },
621
+ { prefix: 'klarna', name: 'Klarna' },
622
+ ];
623
+ const ORGANIC_SEARCH_ENGINES = [
624
+ { match: 'google', name: 'Google' },
625
+ { match: 'bing', name: 'Bing' },
626
+ { match: 'yahoo', name: 'Yahoo' },
627
+ { match: 'duckduckgo', name: 'DuckDuckGo' },
628
+ { match: 'baidu', name: 'Baidu' },
629
+ { match: 'yandex', name: 'Yandex' },
630
+ { match: 'brave', name: 'Brave' },
631
+ ];
632
+ const KNOWN_REFERRAL_PLATFORMS = [
633
+ { match: 'facebook', name: 'Facebook' },
634
+ { match: 'instagram', name: 'Facebook' },
635
+ { match: 'twitter', name: 'Twitter' },
636
+ { match: 'x.com', name: 'Twitter' },
637
+ { match: 'tiktok', name: 'TikTok' },
638
+ { match: 'pinterest', name: 'Pinterest' },
639
+ { match: 'linkedin', name: 'LinkedIn' },
640
+ { match: 'youtube', name: 'YouTube' },
641
+ { match: 'chatgpt', name: 'ChatGPT' },
642
+ { match: 'claude', name: 'Claude' },
643
+ { match: 'perplexity', name: 'Perplexity' },
644
+ { match: 'shop.app', name: 'Shop App' },
645
+ { match: 'amazon', name: 'Amazon' },
646
+ { match: 'attentive', name: 'Attentive' },
647
+ ];
648
+ const OFFLINE_TOUCH = 'Blotout_Offline';
649
+ new Set([
650
+ ...CLICK_IDS.map((c) => c.label),
651
+ ...Object.values(UTM_SOURCE_EXACT),
652
+ ...UTM_SOURCE_PARTIAL.map((e) => e.name),
653
+ ...ORGANIC_SEARCH_ENGINES.map((e) => `Organic Search - ${e.name}`),
654
+ ...KNOWN_REFERRAL_PLATFORMS.map((e) => `Referral - ${e.name}`),
655
+ 'Referral - Other',
656
+ 'Direct Traffic',
657
+ 'Other',
658
+ OFFLINE_TOUCH,
659
+ ]);
660
+
661
+ const getString = (kv, key) => {
662
+ const value = kv === null || kv === void 0 ? void 0 : kv[key];
663
+ return typeof value === 'string' && value ? value : undefined;
664
+ };
665
+ /**
666
+ * Maps session KV onto the fields Pinterest's tag accepts on `load` and `set`.
667
+ * The tag hashes, lowercases and trims everything itself, so values go across
668
+ * raw. Phone is the exception: Pinterest hashes the string verbatim, so it has
669
+ * to be normalized here to match what the CDN sends for the same visitor.
670
+ */
671
+ const buildIdentity = (kv, userId) => {
672
+ const identity = {};
673
+ const email = getString(kv, 'email');
674
+ if (email) {
675
+ identity['em'] = email;
676
+ }
677
+ const phone = getString(kv, 'phone');
678
+ if (phone && isPlausibleE164Number(normalizePhoneNumber(phone, true))) {
679
+ // The CDN hashes the no-plus form, so assign that and validate the E.164 one.
680
+ identity['ph'] = normalizePhoneNumber(phone);
681
+ }
682
+ const firstName = getString(kv, 'firstName');
683
+ if (firstName) {
684
+ identity['fn'] = firstName;
685
+ }
686
+ const lastName = getString(kv, 'lastName');
687
+ if (lastName) {
688
+ identity['ln'] = lastName;
689
+ }
690
+ const city = getString(kv, 'city');
691
+ if (city) {
692
+ identity['ct'] = city;
693
+ }
694
+ const state = getString(kv, 'state');
695
+ if (state) {
696
+ identity['st'] = state;
697
+ }
698
+ const zip = getString(kv, 'zip');
699
+ if (zip) {
700
+ identity['zp'] = zip;
701
+ }
702
+ const country = getString(kv, 'country');
703
+ if (country) {
704
+ identity['country'] = country;
705
+ }
706
+ const gender = getString(kv, 'gender');
707
+ if (gender) {
708
+ identity['ge'] = gender;
709
+ }
710
+ const dateOfBirth = getString(kv, 'dateOfBirth');
711
+ if (dateOfBirth) {
712
+ identity['db'] = dateOfBirth;
713
+ }
714
+ if (userId) {
715
+ identity['external_id'] = userId;
716
+ }
717
+ return identity;
718
+ };
719
+
7
720
  // eslint-disable-next-line @nx/enforce-module-boundaries
8
721
  const snippet = () => {
9
722
  if (!window || !document || window.pintrk) {
@@ -27,7 +740,7 @@ var ProvidersPinterestSdk = (function () {
27
740
  script.parentNode.insertBefore(element, script);
28
741
  }
29
742
  };
30
- const init = ({ manifest }) => {
743
+ const init = ({ manifest, userId, destination }) => {
31
744
  if (!manifest.variables || !manifest.variables['pixelId']) {
32
745
  return;
33
746
  }
@@ -35,7 +748,8 @@ var ProvidersPinterestSdk = (function () {
35
748
  if (!window.pintrk) {
36
749
  return;
37
750
  }
38
- window.pintrk('load', manifest.variables['pixelId']);
751
+ const identity = buildIdentity(getData(destination, 'session')['kv'], userId);
752
+ window.pintrk('load', manifest.variables['pixelId'], identity);
39
753
  window.pintrk('page');
40
754
  };
41
755
 
@@ -136,7 +850,7 @@ var ProvidersPinterestSdk = (function () {
136
850
  return payload;
137
851
  };
138
852
  const tag = ({ data, eventName, manifestVariables, eventId, executionContext, }) => {
139
- const result = { sdkVersion: "1.68.2" };
853
+ const result = { sdkVersion: "1.69.1" };
140
854
  if (executionContext.get('pixelFired')) {
141
855
  return result;
142
856
  }
@@ -157,11 +871,25 @@ var ProvidersPinterestSdk = (function () {
157
871
  return result;
158
872
  };
159
873
 
874
+ const user = ({ userId, manifestVariables, destination }) => {
875
+ if (!window || !window.pintrk || !manifestVariables['pixelId']) {
876
+ return;
877
+ }
878
+ // KV is read rather than `data` because `data` carries only what just
879
+ // changed, and saveKV has already merged it in by the time this runs.
880
+ const identity = buildIdentity(getData(destination, 'session')['kv'], userId);
881
+ if (!Object.keys(identity).length) {
882
+ return;
883
+ }
884
+ window.pintrk('set', identity);
885
+ };
886
+
160
887
  // eslint-disable-next-line @nx/enforce-module-boundaries
161
888
  const data = {
162
889
  name: packageName,
163
890
  tag,
164
891
  init,
892
+ user,
165
893
  };
166
894
  try {
167
895
  if (window) {