@washingtonpost/subs-de-inputs 1.0.0-react18.0 → 1.0.0-react18.10
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/dist/components/DEDisclosure/hooks/useOnetrustAlertBoxClosedPromise.d.ts +23 -0
- package/dist/components/DEDisclosure/index.d.ts +12 -0
- package/dist/components/DEDisclosure/utils/checkCookie.d.ts +1 -0
- package/dist/components/DEDisclosure/utils/getConfig.d.ts +2 -0
- package/dist/components/DEDisclosure/utils/hydrateLinks.d.ts +3 -0
- package/dist/components/DESelect/Dropdown.d.ts +17 -0
- package/dist/components/DESelect/index.d.ts +1 -6
- package/dist/index.d.ts +4 -1
- package/dist/interfaces/disclosure.d.ts +8 -0
- package/dist/interfaces/index.d.ts +10 -2
- package/dist/interfaces/twpdeu.d.ts +12 -0
- package/dist/services/getAttributes.d.ts +6 -0
- package/dist/services/ingest.d.ts +14 -0
- package/dist/services/sendToGA.d.ts +9 -0
- package/dist/subs-de-inputs.cjs.development.js +548 -480
- package/dist/subs-de-inputs.cjs.development.js.map +1 -1
- package/dist/subs-de-inputs.cjs.production.min.js +1 -1
- package/dist/subs-de-inputs.cjs.production.min.js.map +1 -1
- package/dist/subs-de-inputs.esm.js +548 -483
- package/dist/subs-de-inputs.esm.js.map +1 -1
- package/dist/utils/isAnonymousWebview.d.ts +1 -0
- package/dist/utils/push.d.ts +14 -0
- package/package.json +29 -8
- package/dist/services/dataEnrichment.d.ts +0 -3
|
@@ -5,540 +5,424 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var subsSdk = require('@washingtonpost/subs-sdk');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var wpdsUiKit = require('@washingtonpost/wpds-ui-kit');
|
|
8
|
+
var subsHooks = require('@washingtonpost/subs-hooks');
|
|
9
|
+
var wpdsAssets = require('@washingtonpost/wpds-assets');
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const CollectionBehaviors = {
|
|
10
12
|
COLLECT: 'COLLECT',
|
|
11
13
|
DO_NOT_COLLECT: 'DO_NOT_COLLECT'
|
|
12
14
|
};
|
|
13
|
-
|
|
15
|
+
const AttributesState = {
|
|
14
16
|
SUCCESS: '100'
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
const IngestType = {
|
|
19
|
+
EXPLICIT: 'explicit',
|
|
20
|
+
IMPLICIT: 'implicit'
|
|
21
|
+
};
|
|
22
|
+
const IngestResponseState = {
|
|
17
23
|
SUCCESS: '100',
|
|
18
24
|
SYSTEM_ERROR: '101',
|
|
19
25
|
INVALID_TYPE: '102',
|
|
20
26
|
INVALID_IDENTIFIER: '103',
|
|
21
27
|
INVALID_DATA: '104',
|
|
22
28
|
INVALID_ATTRIBUTE_DEFINITION: '105',
|
|
23
|
-
INVALID_META_DEFINITION: '106'
|
|
29
|
+
INVALID_META_DEFINITION: '106',
|
|
30
|
+
UNAUTHENTICATED: '107',
|
|
31
|
+
MISMATCHED_IDENTIFIER: '108',
|
|
32
|
+
DISABLED_ATTRIBUTE_DEFINITION: '109',
|
|
33
|
+
DO_NOT_COLLECT: '110'
|
|
24
34
|
};
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
const hasRequiredPrivacyCookies = () => {
|
|
27
37
|
var _WPGeo;
|
|
28
38
|
if (typeof window === 'undefined') {
|
|
29
39
|
return false;
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
const wp_usp = subsSdk.getCookie('wp_usp');
|
|
42
|
+
const countryCode = (_WPGeo = subsSdk.WPGeo()) === null || _WPGeo === void 0 ? void 0 : _WPGeo.country_code;
|
|
33
43
|
return !!(wp_usp && countryCode === 'US');
|
|
34
44
|
};
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
n = r.hasOwnProperty,
|
|
44
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
45
|
-
t[e] = r.value;
|
|
46
|
-
},
|
|
47
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
48
|
-
a = i.iterator || "@@iterator",
|
|
49
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
50
|
-
u = i.toStringTag || "@@toStringTag";
|
|
51
|
-
function define(t, e, r) {
|
|
52
|
-
return Object.defineProperty(t, e, {
|
|
53
|
-
value: r,
|
|
54
|
-
enumerable: !0,
|
|
55
|
-
configurable: !0,
|
|
56
|
-
writable: !0
|
|
57
|
-
}), t[e];
|
|
46
|
+
const base$1 = `${subsSdk.ENDPOINTS.base}/de/v1`;
|
|
47
|
+
const attributesCache = {};
|
|
48
|
+
const getAttributes = async ({
|
|
49
|
+
fieldName
|
|
50
|
+
}) => {
|
|
51
|
+
if (attributesCache[fieldName]) {
|
|
52
|
+
return attributesCache[fieldName];
|
|
58
53
|
}
|
|
54
|
+
const fieldNames = [fieldName];
|
|
59
55
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
function tryCatch(t, e, r) {
|
|
75
|
-
try {
|
|
76
|
-
return {
|
|
77
|
-
type: "normal",
|
|
78
|
-
arg: t.call(e, r)
|
|
79
|
-
};
|
|
80
|
-
} catch (t) {
|
|
81
|
-
return {
|
|
82
|
-
type: "throw",
|
|
83
|
-
arg: t
|
|
84
|
-
};
|
|
56
|
+
const url = new URL(`${base$1}/attributes`);
|
|
57
|
+
url.searchParams.set('attributes', fieldNames.join(','));
|
|
58
|
+
const data = await fetch(url.toString(), {
|
|
59
|
+
credentials: 'include',
|
|
60
|
+
headers: subsSdk.JSON_HEADERS
|
|
61
|
+
});
|
|
62
|
+
const json = await data.json();
|
|
63
|
+
if (data.ok && json.status === subsSdk.ResponseStatus.SUCCESS) {
|
|
64
|
+
const attributes = json.attributes || [];
|
|
65
|
+
attributesCache[fieldName] = attributes;
|
|
66
|
+
return attributes;
|
|
67
|
+
} else {
|
|
68
|
+
return [];
|
|
85
69
|
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.debug(e);
|
|
72
|
+
return [];
|
|
86
73
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
function Generator() {}
|
|
94
|
-
function GeneratorFunction() {}
|
|
95
|
-
function GeneratorFunctionPrototype() {}
|
|
96
|
-
var p = {};
|
|
97
|
-
define(p, a, function () {
|
|
98
|
-
return this;
|
|
99
|
-
});
|
|
100
|
-
var d = Object.getPrototypeOf,
|
|
101
|
-
v = d && d(d(values([])));
|
|
102
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
103
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
104
|
-
function defineIteratorMethods(t) {
|
|
105
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
106
|
-
define(t, e, function (t) {
|
|
107
|
-
return this._invoke(e, t);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const sendGAEvent = props => {
|
|
77
|
+
if (typeof window === 'undefined') {
|
|
78
|
+
console.warn('NO WINDOW');
|
|
79
|
+
return;
|
|
110
80
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
81
|
+
// Initialize dataLayer if needed
|
|
82
|
+
window.dataLayer = window.dataLayer || [];
|
|
83
|
+
const eventData = {
|
|
84
|
+
...props
|
|
85
|
+
};
|
|
86
|
+
window.dataLayer.push(eventData);
|
|
87
|
+
};
|
|
88
|
+
const sendToGA = async ({
|
|
89
|
+
submitData: {
|
|
90
|
+
fieldName,
|
|
91
|
+
value
|
|
92
|
+
},
|
|
93
|
+
source
|
|
94
|
+
}) => {
|
|
95
|
+
sendGAEvent({
|
|
96
|
+
event: 'site-onpage-click',
|
|
97
|
+
action: 'site-onpage-click',
|
|
98
|
+
category: 'profile',
|
|
99
|
+
label: fieldName,
|
|
100
|
+
'de-label': fieldName,
|
|
101
|
+
[fieldName]: value,
|
|
102
|
+
section: 'profile',
|
|
103
|
+
subsection: source
|
|
104
|
+
});
|
|
105
|
+
return true;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const base = `${subsSdk.ENDPOINTS.base}/de/v1`;
|
|
109
|
+
const ingest = async ({
|
|
110
|
+
submitData: {
|
|
111
|
+
fieldName,
|
|
112
|
+
value
|
|
113
|
+
},
|
|
114
|
+
source
|
|
115
|
+
}) => {
|
|
116
|
+
const url = `${base}/ingest`;
|
|
117
|
+
const wapo_login_id = subsSdk.getCookie('wapo_login_id');
|
|
118
|
+
const jucid = localStorage.getItem('uuid');
|
|
119
|
+
const ga = subsSdk.getCookie('_ga');
|
|
120
|
+
const payload = {
|
|
121
|
+
jucid,
|
|
122
|
+
ga,
|
|
123
|
+
type: IngestType.EXPLICIT,
|
|
124
|
+
wapo_login_id,
|
|
125
|
+
// TODO: move this to BE to read from cookie headers
|
|
126
|
+
data: {
|
|
127
|
+
[fieldName]: [value]
|
|
128
|
+
},
|
|
129
|
+
metadata: {
|
|
130
|
+
source
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
138
|
-
}
|
|
132
|
+
};
|
|
133
|
+
try {
|
|
134
|
+
const response = await fetch(url, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
credentials: 'include',
|
|
137
|
+
headers: subsSdk.JSON_HEADERS,
|
|
138
|
+
body: JSON.stringify(payload)
|
|
139
139
|
});
|
|
140
|
+
const json = await response.json();
|
|
141
|
+
return json;
|
|
142
|
+
} catch (e) {
|
|
143
|
+
console.debug(e);
|
|
144
|
+
return null;
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if ("throw" === i) throw a;
|
|
147
|
-
return {
|
|
148
|
-
value: t,
|
|
149
|
-
done: !0
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
for (n.method = i, n.arg = a;;) {
|
|
153
|
-
var c = n.delegate;
|
|
154
|
-
if (c) {
|
|
155
|
-
var u = maybeInvokeDelegate(c, n);
|
|
156
|
-
if (u) {
|
|
157
|
-
if (u === y) continue;
|
|
158
|
-
return u;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
162
|
-
if (o === h) throw o = s, n.arg;
|
|
163
|
-
n.dispatchException(n.arg);
|
|
164
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
165
|
-
o = f;
|
|
166
|
-
var p = tryCatch(e, r, n);
|
|
167
|
-
if ("normal" === p.type) {
|
|
168
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
169
|
-
return {
|
|
170
|
-
value: p.arg,
|
|
171
|
-
done: n.done
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function maybeInvokeDelegate(e, r) {
|
|
179
|
-
var n = r.method,
|
|
180
|
-
o = e.iterator[n];
|
|
181
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
182
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
183
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
184
|
-
var a = i.arg;
|
|
185
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const isAnonymousWebview = () => {
|
|
149
|
+
if (typeof window === 'undefined') {
|
|
150
|
+
return false;
|
|
186
151
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
152
|
+
const wp_wv = subsSdk.getCookie('wp_wv');
|
|
153
|
+
return !!(wp_wv && !subsSdk.isLoggedIn());
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const push = async ({
|
|
157
|
+
submitData,
|
|
158
|
+
source
|
|
159
|
+
}) => {
|
|
160
|
+
if (!hasRequiredPrivacyCookies()) {
|
|
161
|
+
throw new Error('does not satisfy cookie check');
|
|
192
162
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
163
|
+
if (isAnonymousWebview()) {
|
|
164
|
+
throw new Error('does not satisfy cookie check');
|
|
196
165
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
166
|
+
const {
|
|
167
|
+
fieldName
|
|
168
|
+
} = submitData;
|
|
169
|
+
const attributeInfo = await getAttributes({
|
|
170
|
+
fieldName
|
|
171
|
+
});
|
|
172
|
+
if (attributeInfo[0] && attributeInfo[0].name === fieldName && attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT) {
|
|
173
|
+
throw new Error('do not collect');
|
|
201
174
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (r) return r.call(e);
|
|
206
|
-
if ("function" == typeof e.next) return e;
|
|
207
|
-
if (!isNaN(e.length)) {
|
|
208
|
-
var o = -1,
|
|
209
|
-
i = function next() {
|
|
210
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
211
|
-
return next.value = t, next.done = !0, next;
|
|
212
|
-
};
|
|
213
|
-
return i.next = i;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
175
|
+
const type = attributeInfo[0] && attributeInfo[0].explicit === true ? IngestType.EXPLICIT : IngestType.IMPLICIT;
|
|
176
|
+
if (!attributeInfo[0] && "development" !== "production") {
|
|
177
|
+
console.warn(`no attribute info found for ${fieldName}, assuming implicit`);
|
|
217
178
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
value: GeneratorFunction,
|
|
223
|
-
configurable: !0
|
|
224
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
225
|
-
var e = "function" == typeof t && t.constructor;
|
|
226
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
227
|
-
}, e.mark = function (t) {
|
|
228
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
229
|
-
}, e.awrap = function (t) {
|
|
230
|
-
return {
|
|
231
|
-
__await: t
|
|
232
|
-
};
|
|
233
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
234
|
-
return this;
|
|
235
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
236
|
-
void 0 === i && (i = Promise);
|
|
237
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
238
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
239
|
-
return t.done ? t.value : a.next();
|
|
179
|
+
if (type === IngestType.EXPLICIT) {
|
|
180
|
+
return ingest({
|
|
181
|
+
submitData,
|
|
182
|
+
source
|
|
240
183
|
});
|
|
241
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
242
|
-
return this;
|
|
243
|
-
}), define(g, "toString", function () {
|
|
244
|
-
return "[object Generator]";
|
|
245
|
-
}), e.keys = function (t) {
|
|
246
|
-
var e = Object(t),
|
|
247
|
-
r = [];
|
|
248
|
-
for (var n in e) r.push(n);
|
|
249
|
-
return r.reverse(), function next() {
|
|
250
|
-
for (; r.length;) {
|
|
251
|
-
var t = r.pop();
|
|
252
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
253
|
-
}
|
|
254
|
-
return next.done = !0, next;
|
|
255
|
-
};
|
|
256
|
-
}, e.values = values, Context.prototype = {
|
|
257
|
-
constructor: Context,
|
|
258
|
-
reset: function (e) {
|
|
259
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
260
|
-
},
|
|
261
|
-
stop: function () {
|
|
262
|
-
this.done = !0;
|
|
263
|
-
var t = this.tryEntries[0].completion;
|
|
264
|
-
if ("throw" === t.type) throw t.arg;
|
|
265
|
-
return this.rval;
|
|
266
|
-
},
|
|
267
|
-
dispatchException: function (e) {
|
|
268
|
-
if (this.done) throw e;
|
|
269
|
-
var r = this;
|
|
270
|
-
function handle(n, o) {
|
|
271
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
272
|
-
}
|
|
273
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
274
|
-
var i = this.tryEntries[o],
|
|
275
|
-
a = i.completion;
|
|
276
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
277
|
-
if (i.tryLoc <= this.prev) {
|
|
278
|
-
var c = n.call(i, "catchLoc"),
|
|
279
|
-
u = n.call(i, "finallyLoc");
|
|
280
|
-
if (c && u) {
|
|
281
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
282
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
283
|
-
} else if (c) {
|
|
284
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
285
|
-
} else {
|
|
286
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
287
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
abrupt: function (t, e) {
|
|
293
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
294
|
-
var o = this.tryEntries[r];
|
|
295
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
296
|
-
var i = o;
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
301
|
-
var a = i ? i.completion : {};
|
|
302
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
303
|
-
},
|
|
304
|
-
complete: function (t, e) {
|
|
305
|
-
if ("throw" === t.type) throw t.arg;
|
|
306
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
307
|
-
},
|
|
308
|
-
finish: function (t) {
|
|
309
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
310
|
-
var r = this.tryEntries[e];
|
|
311
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
catch: function (t) {
|
|
315
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
316
|
-
var r = this.tryEntries[e];
|
|
317
|
-
if (r.tryLoc === t) {
|
|
318
|
-
var n = r.completion;
|
|
319
|
-
if ("throw" === n.type) {
|
|
320
|
-
var o = n.arg;
|
|
321
|
-
resetTryEntry(r);
|
|
322
|
-
}
|
|
323
|
-
return o;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
throw Error("illegal catch attempt");
|
|
327
|
-
},
|
|
328
|
-
delegateYield: function (e, r, n) {
|
|
329
|
-
return this.delegate = {
|
|
330
|
-
iterator: values(e),
|
|
331
|
-
resultName: r,
|
|
332
|
-
nextLoc: n
|
|
333
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
334
|
-
}
|
|
335
|
-
}, e;
|
|
336
|
-
}
|
|
337
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
338
|
-
try {
|
|
339
|
-
var info = gen[key](arg);
|
|
340
|
-
var value = info.value;
|
|
341
|
-
} catch (error) {
|
|
342
|
-
reject(error);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (info.done) {
|
|
346
|
-
resolve(value);
|
|
347
184
|
} else {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
function _asyncToGenerator(fn) {
|
|
352
|
-
return function () {
|
|
353
|
-
var self = this,
|
|
354
|
-
args = arguments;
|
|
355
|
-
return new Promise(function (resolve, reject) {
|
|
356
|
-
var gen = fn.apply(self, args);
|
|
357
|
-
function _next(value) {
|
|
358
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
359
|
-
}
|
|
360
|
-
function _throw(err) {
|
|
361
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
362
|
-
}
|
|
363
|
-
_next(undefined);
|
|
185
|
+
return sendToGA({
|
|
186
|
+
submitData,
|
|
187
|
+
source
|
|
364
188
|
});
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
function _extends() {
|
|
368
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
369
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
370
|
-
var source = arguments[i];
|
|
371
|
-
for (var key in source) {
|
|
372
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
373
|
-
target[key] = source[key];
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return target;
|
|
378
|
-
};
|
|
379
|
-
return _extends.apply(this, arguments);
|
|
380
|
-
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
381
191
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
192
|
+
const StyledMobileSelect = /*#__PURE__*/wpdsUiKit.styled('select', {
|
|
193
|
+
padding: '12px 16px 12px 6px',
|
|
194
|
+
display: 'flex',
|
|
195
|
+
justifyContent: 'space-between',
|
|
196
|
+
width: '100%',
|
|
197
|
+
backgroundColor: '$secondary',
|
|
198
|
+
color: '$primary',
|
|
199
|
+
fontFamily: '$meta',
|
|
200
|
+
fontSize: '$100',
|
|
201
|
+
fontWeight: '$light',
|
|
202
|
+
lineHeight: '$125',
|
|
203
|
+
paddingBlockRight: '$125',
|
|
204
|
+
textOverflow: 'ellipsis',
|
|
205
|
+
position: 'relative',
|
|
206
|
+
borderColor: 'transparent',
|
|
207
|
+
borderRightWidth: '10px',
|
|
208
|
+
borderRightColor: 'transparent',
|
|
209
|
+
appearance: 'none',
|
|
210
|
+
'-webkit-appearance': 'none',
|
|
211
|
+
'&:disabled': {
|
|
212
|
+
backgroundColor: wpdsUiKit.theme.colors.disabled,
|
|
213
|
+
borderColor: wpdsUiKit.theme.colors.disabled,
|
|
214
|
+
color: wpdsUiKit.theme.colors.onDisabled,
|
|
215
|
+
cursor: 'not-allowed'
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
const StyledSelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
219
|
+
width: '100%',
|
|
220
|
+
maxWidth: '380px',
|
|
221
|
+
borderRadius: '$012',
|
|
222
|
+
borderColor: '$subtle',
|
|
223
|
+
borderStyle: 'solid',
|
|
224
|
+
borderWidth: '1px',
|
|
225
|
+
backgroundColor: '$secondary',
|
|
226
|
+
position: 'relative'
|
|
227
|
+
});
|
|
228
|
+
const StyledMobileOption = /*#__PURE__*/wpdsUiKit.styled('option', {
|
|
229
|
+
fontFamily: 'inherit',
|
|
230
|
+
fontSize: 'inherit',
|
|
231
|
+
color: 'inherit'
|
|
232
|
+
});
|
|
233
|
+
/**
|
|
234
|
+
* Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.
|
|
235
|
+
* @param {IDropdownProps} props The props.
|
|
236
|
+
* @returns {React.ReactElement} The dropdown.
|
|
237
|
+
*/
|
|
238
|
+
const Dropdown = ({
|
|
239
|
+
id,
|
|
240
|
+
label,
|
|
241
|
+
values,
|
|
242
|
+
required = false,
|
|
243
|
+
defaultValue,
|
|
244
|
+
onChange = () => {},
|
|
245
|
+
disabled = false
|
|
246
|
+
}) => {
|
|
247
|
+
const [answer, setAnswer] = React.useState();
|
|
248
|
+
const {
|
|
249
|
+
isMobileSize
|
|
250
|
+
} = subsHooks.useWindowSize();
|
|
251
|
+
React.useEffect(() => {
|
|
252
|
+
if (answer) onChange(answer);
|
|
253
|
+
}, [answer]);
|
|
254
|
+
const disabledProp = disabled ? {
|
|
255
|
+
disabled: true
|
|
256
|
+
} : {};
|
|
257
|
+
// helps maintain state between WPDS and native dropdowns
|
|
258
|
+
const defaultValueProp = answer ? {
|
|
259
|
+
defaultValue: answer
|
|
260
|
+
} : defaultValue ? {
|
|
261
|
+
defaultValue
|
|
262
|
+
} : {};
|
|
263
|
+
const defaultValuePropMobile = value => {
|
|
264
|
+
if (answer) {
|
|
265
|
+
return value === answer ? {
|
|
266
|
+
selected: true
|
|
267
|
+
} : {};
|
|
268
|
+
}
|
|
269
|
+
return value === defaultValue ? {
|
|
270
|
+
selected: true
|
|
271
|
+
} : {};
|
|
437
272
|
};
|
|
438
|
-
|
|
273
|
+
return isMobileSize ? React.createElement(StyledSelectWrapper, null, React.createElement(StyledMobileSelect, {
|
|
274
|
+
id: "",
|
|
275
|
+
required: required,
|
|
276
|
+
onChange: e => setAnswer(e.target.value),
|
|
277
|
+
...disabledProp
|
|
278
|
+
}, React.createElement("label", null, label), React.createElement(StyledMobileOption, {
|
|
279
|
+
value: "",
|
|
280
|
+
disabled: true,
|
|
281
|
+
selected: true,
|
|
282
|
+
style: {
|
|
283
|
+
color: '#666666'
|
|
284
|
+
}
|
|
285
|
+
}, label), values.map(value => React.createElement(StyledMobileOption, {
|
|
286
|
+
value: value,
|
|
287
|
+
key: value,
|
|
288
|
+
...defaultValuePropMobile(value)
|
|
289
|
+
}, value))), React.createElement(wpdsUiKit.Icon, {
|
|
290
|
+
label: "",
|
|
291
|
+
size: "100",
|
|
292
|
+
fill: wpdsUiKit.theme.colors.gray80,
|
|
293
|
+
style: {
|
|
294
|
+
pointerEvents: 'none',
|
|
295
|
+
position: 'absolute',
|
|
296
|
+
right: '10px',
|
|
297
|
+
top: '50%',
|
|
298
|
+
transform: 'translateY(-50%)'
|
|
299
|
+
}
|
|
300
|
+
}, React.createElement(wpdsAssets.ChevronDown, {
|
|
301
|
+
style: {
|
|
302
|
+
position: 'absolute',
|
|
303
|
+
right: '10px'
|
|
304
|
+
}
|
|
305
|
+
}))) : React.createElement(wpdsUiKit.Select.Root, {
|
|
306
|
+
onValueChange: e => setAnswer(e),
|
|
307
|
+
required: required,
|
|
308
|
+
...defaultValueProp,
|
|
309
|
+
...disabledProp
|
|
310
|
+
}, React.createElement(wpdsUiKit.Select.Trigger, {
|
|
311
|
+
"data-test-id": `${id}-select-trigger`
|
|
312
|
+
}, React.createElement(wpdsUiKit.Select.Label, null, label), React.createElement(wpdsUiKit.Select.Value, null)), React.createElement(wpdsUiKit.Select.Content, {
|
|
313
|
+
css: {
|
|
314
|
+
zIndex: wpdsUiKit.theme.zIndices.page
|
|
315
|
+
},
|
|
316
|
+
"data-test-id": `${id}-select-content`
|
|
317
|
+
}, values.map(value => React.createElement(wpdsUiKit.Select.Item, {
|
|
318
|
+
value: value,
|
|
319
|
+
key: value
|
|
320
|
+
}, value))));
|
|
321
|
+
};
|
|
439
322
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
323
|
+
const scriptSrc = `${subsSdk.ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static' ? 'https://www.washingtonpost.com/subscribe/static/' : subsSdk.ENDPOINTS.staticAssets}/de-utils/twpdeu.min.js`;
|
|
324
|
+
const DESelect = ({
|
|
325
|
+
source,
|
|
326
|
+
fieldName,
|
|
327
|
+
label,
|
|
328
|
+
dataDictionaryConfig,
|
|
329
|
+
defaultValue,
|
|
330
|
+
disabled,
|
|
331
|
+
submit,
|
|
332
|
+
onChange = () => {},
|
|
333
|
+
onFinished = () => {},
|
|
334
|
+
valuesFilter = () => true,
|
|
335
|
+
children
|
|
336
|
+
}) => {
|
|
337
|
+
const [config, setConfig] = React.useState(dataDictionaryConfig);
|
|
338
|
+
const [selected, setSelected] = React.useState('');
|
|
339
|
+
const scriptStatus = subsHooks.useScript(scriptSrc);
|
|
340
|
+
React.useEffect(() => {
|
|
341
|
+
const fetchConfig = async () => {
|
|
342
|
+
try {
|
|
343
|
+
var _window;
|
|
344
|
+
const config = await ((_window = window) === null || _window === void 0 || (_window = _window.__twpdeu) === null || _window === void 0 ? void 0 : _window.getFieldConfigs({
|
|
345
|
+
fieldName
|
|
346
|
+
}));
|
|
347
|
+
if (config) {
|
|
348
|
+
setConfig(config[0]);
|
|
349
|
+
} else {
|
|
350
|
+
console.error('unable to get config', fieldName);
|
|
351
|
+
}
|
|
352
|
+
} catch (e) {
|
|
353
|
+
console.warn('unable to get config', fieldName, e);
|
|
467
354
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
472
|
-
var config;
|
|
473
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
474
|
-
while (1) switch (_context.prev = _context.next) {
|
|
475
|
-
case 0:
|
|
476
|
-
_context.next = 2;
|
|
477
|
-
return getAttributes({
|
|
478
|
-
fieldName: fieldName
|
|
479
|
-
});
|
|
480
|
-
case 2:
|
|
481
|
-
config = _context.sent;
|
|
482
|
-
{
|
|
483
|
-
console.debug('config from API', config);
|
|
484
|
-
}
|
|
485
|
-
setConfig(config[0]);
|
|
486
|
-
case 5:
|
|
487
|
-
case "end":
|
|
488
|
-
return _context.stop();
|
|
489
|
-
}
|
|
490
|
-
}, _callee);
|
|
491
|
-
}))();
|
|
355
|
+
};
|
|
356
|
+
if (scriptStatus === subsHooks.ScriptStatus.READY && !(children || config)) {
|
|
357
|
+
fetchConfig();
|
|
492
358
|
}
|
|
493
|
-
}, []);
|
|
494
|
-
React.useEffect(
|
|
495
|
-
|
|
496
|
-
{
|
|
497
|
-
|
|
359
|
+
}, [scriptStatus]);
|
|
360
|
+
React.useEffect(() => {
|
|
361
|
+
const submitSelected = async () => {
|
|
362
|
+
try {
|
|
363
|
+
var _window2;
|
|
364
|
+
const result = await ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.__twpdeu) === null || _window2 === void 0 ? void 0 : _window2.push({
|
|
365
|
+
submitData: {
|
|
366
|
+
fieldName,
|
|
367
|
+
value: selected
|
|
368
|
+
},
|
|
369
|
+
source
|
|
370
|
+
}));
|
|
371
|
+
const isError = result === true ? false : result ? result.status !== subsSdk.ResponseStatus.SUCCESS : true;
|
|
372
|
+
onFinished({
|
|
373
|
+
isFinished: true,
|
|
374
|
+
isError
|
|
375
|
+
});
|
|
376
|
+
} catch (e) {
|
|
377
|
+
onFinished({
|
|
378
|
+
isFinished: false,
|
|
379
|
+
isError: true
|
|
380
|
+
});
|
|
498
381
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
});
|
|
382
|
+
};
|
|
383
|
+
if (scriptStatus === subsHooks.ScriptStatus.READY && submit && selected) {
|
|
384
|
+
submitSelected();
|
|
503
385
|
}
|
|
504
|
-
}, [
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
var defaultValueProp = defaultValue ? {
|
|
509
|
-
defaultValue: defaultValue
|
|
386
|
+
}, [scriptStatus, submit]);
|
|
387
|
+
const defaultValueProp = defaultValue && config ? {
|
|
388
|
+
defaultValue
|
|
510
389
|
} : {};
|
|
511
|
-
|
|
390
|
+
const isLoading = !(children || config);
|
|
391
|
+
const disabledProp = disabled || isLoading ? {
|
|
512
392
|
disabled: true
|
|
513
393
|
} : {};
|
|
514
394
|
// sort and filter out archived values
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
return React.createElement(SelectWrapper, null, React.createElement(wpdsUiKit.Select.Root, _extends({
|
|
521
|
-
onValueChange: function onValueChange(e) {
|
|
395
|
+
// Note: config.values may be readonly
|
|
396
|
+
const values = config ? [...config.values].sort((a, b) => a.order - b.order).filter(value => value.archived !== true).filter(valuesFilter) : [];
|
|
397
|
+
return React.createElement(SelectWrapper, null, children && React.createElement(wpdsUiKit.Select.Root, {
|
|
398
|
+
onValueChange: e => {
|
|
399
|
+
setSelected(e);
|
|
522
400
|
onChange({
|
|
523
401
|
value: e
|
|
524
402
|
});
|
|
403
|
+
},
|
|
404
|
+
...defaultValueProp,
|
|
405
|
+
...disabledProp
|
|
406
|
+
}, children), !children && !config && React.createElement(Dropdown, {
|
|
407
|
+
id: 'loading',
|
|
408
|
+
label: 'Loading...',
|
|
409
|
+
values: [],
|
|
410
|
+
disabled: true
|
|
411
|
+
}), !children && config && React.createElement(Dropdown, {
|
|
412
|
+
id: config.name,
|
|
413
|
+
label: label || config.name,
|
|
414
|
+
onChange: e => {
|
|
525
415
|
setSelected(e);
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}, React.createElement(wpdsUiKit.Select.Label, null, label || config.name), React.createElement(wpdsUiKit.Select.Value, null)), React.createElement(wpdsUiKit.Select.Content, {
|
|
530
|
-
css: {
|
|
531
|
-
zIndex: wpdsUiKit.theme.zIndices.page
|
|
416
|
+
onChange({
|
|
417
|
+
value: e
|
|
418
|
+
});
|
|
532
419
|
},
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
key: value.name
|
|
538
|
-
}, value.name);
|
|
539
|
-
})))));
|
|
420
|
+
values: values.map(value => value.name),
|
|
421
|
+
defaultValue: defaultValue,
|
|
422
|
+
disabled: disabled
|
|
423
|
+
}));
|
|
540
424
|
};
|
|
541
|
-
|
|
425
|
+
const SelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
542
426
|
boxSizing: 'border-box',
|
|
543
427
|
display: 'flex',
|
|
544
428
|
marginBottom: '$100',
|
|
@@ -551,10 +435,194 @@ var SelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
|
551
435
|
}
|
|
552
436
|
});
|
|
553
437
|
|
|
438
|
+
const configSrc = `${subsSdk.ENDPOINTS.base === 'https://subscribe.washingtonpost.com' ? 'https://www.washingtonpost.com/subscribe' : subsSdk.ENDPOINTS.base}/config/de/disclosure.json`;
|
|
439
|
+
const getConfig = async () => {
|
|
440
|
+
let myConfig = undefined;
|
|
441
|
+
// step 1: fetch config
|
|
442
|
+
const response = await fetch(configSrc);
|
|
443
|
+
const remoteConfig = await response.json();
|
|
444
|
+
// step 2: figure out which part of the config to use
|
|
445
|
+
// if country- or region-specific config found, use that
|
|
446
|
+
const {
|
|
447
|
+
country_code,
|
|
448
|
+
intl_region
|
|
449
|
+
} = subsSdk.WPGeo();
|
|
450
|
+
Object.keys(remoteConfig).forEach(configKey => {
|
|
451
|
+
if (country_code && configKey.split('|').includes(country_code.toLowerCase())) {
|
|
452
|
+
myConfig = remoteConfig[configKey];
|
|
453
|
+
} else if (intl_region === 'EEA' && configKey === 'eea') {
|
|
454
|
+
myConfig = remoteConfig[configKey];
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
// TODO: Check for billing country also
|
|
458
|
+
// else if no country-specific config, use the default config
|
|
459
|
+
if (typeof myConfig === 'undefined' && remoteConfig['_']) {
|
|
460
|
+
myConfig = remoteConfig['_'];
|
|
461
|
+
}
|
|
462
|
+
return myConfig;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
const hydrateLinks = str => {
|
|
466
|
+
const array = str.split(/({{PRIVACY_POLICY}})/g);
|
|
467
|
+
const chunks = array.map(str => {
|
|
468
|
+
if (str === '{{PRIVACY_POLICY}}') {
|
|
469
|
+
return React.createElement("a", {
|
|
470
|
+
target: "_blank",
|
|
471
|
+
style: {
|
|
472
|
+
color: 'inherit'
|
|
473
|
+
},
|
|
474
|
+
className: "underline",
|
|
475
|
+
href: "https://www.washingtonpost.com/privacy-policy/"
|
|
476
|
+
}, "Privacy Policy");
|
|
477
|
+
}
|
|
478
|
+
return str;
|
|
479
|
+
});
|
|
480
|
+
const toReturn = chunks.reduce((prev, current) => React.createElement(React.Fragment, null, prev, current), React.createElement(React.Fragment, null));
|
|
481
|
+
return toReturn;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const COOKIE$1 = 'OptanonAlertBoxClosed';
|
|
485
|
+
const checkCookie = () => {
|
|
486
|
+
const value = subsSdk.getCookie(COOKIE$1) || '';
|
|
487
|
+
// Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)
|
|
488
|
+
// "Invalid date" is 12 characters long
|
|
489
|
+
return value.length > 12;
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const COOKIE = 'OptanonAlertBoxClosed';
|
|
493
|
+
const useOneTrustAlertBoxClosed = ({
|
|
494
|
+
allowCookieStore
|
|
495
|
+
}) => {
|
|
496
|
+
const [alertBoxClosed, setAlertBoxClosed] = React.useState();
|
|
497
|
+
const [listenToCookieStore, setListenToCookieStore] = React.useState(false);
|
|
498
|
+
const [listenToTcfApi, setListenToTcfApi] = React.useState(false);
|
|
499
|
+
React.useEffect(() => {
|
|
500
|
+
var _window;
|
|
501
|
+
if (checkCookie()) {
|
|
502
|
+
setAlertBoxClosed(true);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
if (!window.__tcfapi) {
|
|
506
|
+
console.warn('warning: __tcfapi not found');
|
|
507
|
+
}
|
|
508
|
+
if ((_window = window) !== null && _window !== void 0 && _window.cookieStore && allowCookieStore) {
|
|
509
|
+
setListenToCookieStore(true);
|
|
510
|
+
} else if (window.__tcfapi) {
|
|
511
|
+
setListenToTcfApi(true);
|
|
512
|
+
} else {
|
|
513
|
+
console.warn('warning: neither cookieStore nor __tcfapi found');
|
|
514
|
+
}
|
|
515
|
+
}, []);
|
|
516
|
+
React.useEffect(() => {
|
|
517
|
+
let cleanupFn = () => {};
|
|
518
|
+
if (listenToCookieStore && window.cookieStore) {
|
|
519
|
+
cleanupFn = subsSdk.listenToCookieStore(COOKIE, () => {
|
|
520
|
+
if (checkCookie()) {
|
|
521
|
+
setAlertBoxClosed(true);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
return cleanupFn || (() => {});
|
|
526
|
+
}, [listenToCookieStore]);
|
|
527
|
+
React.useEffect(() => {
|
|
528
|
+
let listenerId;
|
|
529
|
+
if (listenToTcfApi && window.__tcfapi) {
|
|
530
|
+
const callback = (_tcData, success) => {
|
|
531
|
+
if (success) {
|
|
532
|
+
listenerId = _tcData.listenerId;
|
|
533
|
+
// tcData.eventStatus can be:
|
|
534
|
+
// tcloaded means user has made a choice and we’re ready to check it
|
|
535
|
+
// cmpuishown means the banner is shown
|
|
536
|
+
// useractioncomplete means the user has interacted with the banner
|
|
537
|
+
// but actually if the result for any of these is true, we just use the value of the cookie
|
|
538
|
+
if (checkCookie()) {
|
|
539
|
+
setAlertBoxClosed(true);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
window.__tcfapi('addEventListener', 2, callback);
|
|
544
|
+
}
|
|
545
|
+
// cleanup fn
|
|
546
|
+
return () => {
|
|
547
|
+
if (window.__tcfapi && listenerId) window.__tcfapi('removeEventListener', 2, success => {
|
|
548
|
+
console.debug(success);
|
|
549
|
+
}, listenerId);
|
|
550
|
+
};
|
|
551
|
+
}, [listenToTcfApi]);
|
|
552
|
+
return {
|
|
553
|
+
alertBoxClosed,
|
|
554
|
+
listenToCookieStore,
|
|
555
|
+
listenToTcfApi
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
const DEDisclosure = ({
|
|
560
|
+
onFinished = () => {},
|
|
561
|
+
allowCookieStore = true
|
|
562
|
+
}) => {
|
|
563
|
+
const [disclosure, setDisclosure] = React.useState(null);
|
|
564
|
+
const [disclosureRendering, setDisclosureRendering] = React.useState(null);
|
|
565
|
+
const [myConfig, setMyConfig] = React.useState();
|
|
566
|
+
const {
|
|
567
|
+
alertBoxClosed
|
|
568
|
+
} = useOneTrustAlertBoxClosed({
|
|
569
|
+
allowCookieStore
|
|
570
|
+
});
|
|
571
|
+
React.useEffect(() => {
|
|
572
|
+
(async () => {
|
|
573
|
+
const config = await getConfig();
|
|
574
|
+
setMyConfig(config);
|
|
575
|
+
if (!config) {
|
|
576
|
+
console.error('No config found');
|
|
577
|
+
}
|
|
578
|
+
})();
|
|
579
|
+
}, []);
|
|
580
|
+
React.useEffect(() => {
|
|
581
|
+
if (myConfig) {
|
|
582
|
+
// step 3: set disclosure based on config
|
|
583
|
+
// if config says to check onetrust, check onetrust
|
|
584
|
+
if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {
|
|
585
|
+
// check if onetrust is closed
|
|
586
|
+
// if it is, show the after banner disclosure
|
|
587
|
+
// if it is not, show the before banner disclosure
|
|
588
|
+
if (alertBoxClosed) {
|
|
589
|
+
setDisclosure(myConfig.disclosure_afterbanner);
|
|
590
|
+
} else {
|
|
591
|
+
setDisclosure(myConfig.disclosure_beforebanner);
|
|
592
|
+
}
|
|
593
|
+
} else if ('disclosure' in myConfig) {
|
|
594
|
+
setDisclosure(myConfig.disclosure);
|
|
595
|
+
} else {
|
|
596
|
+
console.error('Invalid config');
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}, [myConfig, alertBoxClosed]);
|
|
600
|
+
React.useEffect(() => {
|
|
601
|
+
if (disclosure && Array.isArray(disclosure)) {
|
|
602
|
+
setDisclosureRendering(disclosure.reduce((prev, current) => {
|
|
603
|
+
return React.createElement(React.Fragment, null, prev, React.createElement("p", null, hydrateLinks(current)));
|
|
604
|
+
}, React.createElement(React.Fragment, null)));
|
|
605
|
+
// Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?
|
|
606
|
+
onFinished({
|
|
607
|
+
isFinished: true,
|
|
608
|
+
isError: false
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}, [disclosure]);
|
|
612
|
+
return disclosure === null ? React.createElement("div", {
|
|
613
|
+
"data-test-id": "de-disclosure-loading"
|
|
614
|
+
}) : React.createElement("div", {
|
|
615
|
+
"data-test-id": "de-disclosure"
|
|
616
|
+
}, disclosureRendering);
|
|
617
|
+
};
|
|
618
|
+
|
|
554
619
|
exports.AttributesState = AttributesState;
|
|
555
620
|
exports.CollectionBehaviors = CollectionBehaviors;
|
|
621
|
+
exports.DEDisclosure = DEDisclosure;
|
|
556
622
|
exports.DESelect = DESelect;
|
|
557
623
|
exports.IngestResponseState = IngestResponseState;
|
|
624
|
+
exports.IngestType = IngestType;
|
|
558
625
|
exports.getAttributes = getAttributes;
|
|
559
626
|
exports.hasRequiredPrivacyCookies = hasRequiredPrivacyCookies;
|
|
627
|
+
exports.push = push;
|
|
560
628
|
//# sourceMappingURL=subs-de-inputs.cjs.development.js.map
|