@frak-labs/components 1.3.4 → 1.4.0
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/cdn/Ambassador.BDu4aVZ9.js +392 -0
- package/cdn/{Banner.RSZt2Kn_.js → Banner.BqfCxKs3.js} +2 -2
- package/cdn/ButtonShare.C7A2tEvB.js +1 -0
- package/cdn/{ButtonWallet.CIesaq0l.js → ButtonWallet.Cg2OK1di.js} +2 -2
- package/cdn/{GiftIcon.CX0gLPUJ.js → GiftIcon.CW1SwrXH.js} +1 -1
- package/cdn/{OpenInAppButton.BtXknsxK.js → OpenInAppButton.Djz_cb9Y.js} +1 -1
- package/cdn/{PostPurchase.Btgp2kLc.js → PostPurchase.DIZneqoT.js} +2 -2
- package/cdn/components.js +1 -1
- package/cdn/{jsxRuntime.module.CUZaa90V.js → jsxRuntime.module.DWH-kRVd.js} +1 -1
- package/cdn/loader.js +7 -7
- package/cdn/{rewards.F9iOJSNk.js → rewards.t-rH9M3s.js} +1 -1
- package/cdn/useGlobalComponents.DVgSWfOp.js +1 -0
- package/cdn/{useLightDomStyles.CpiH8nO2.js → useLightDomStyles.B72V1WPK.js} +1 -1
- package/cdn/usePlacement.DEOEf5_6.js +1 -0
- package/cdn/{useReward.B9ibElG0.js → useReward.D2kXQbtD.js} +1 -1
- package/dist/ambassador.js +94 -15
- package/dist/banner.js +2 -2
- package/dist/buttonShare.js +2 -2
- package/dist/buttonWallet.js +1 -1
- package/dist/postPurchase.js +1 -1
- package/dist/{rewards-CfGynCt6.js → rewards-BuNthAR2.js} +49 -46
- package/dist/{useReward-DmukZKoh.js → useReward-cQ54x8q-.js} +1 -1
- package/package.json +2 -2
- package/cdn/Ambassador.tWpfYThv.js +0 -392
- package/cdn/ButtonShare.Buy6qEfW.js +0 -1
- package/cdn/useGlobalComponents.CXuceSQ0.js +0 -1
- package/cdn/usePlacement.Cq64cZ9Q.js +0 -1
package/dist/ambassador.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w } from "./rewards-
|
|
2
|
+
import { i as w } from "./rewards-BuNthAR2.js";
|
|
3
3
|
import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
|
|
4
4
|
import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
|
|
5
|
-
import { t as useReward } from "./useReward-
|
|
5
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
6
6
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
7
7
|
import { t as cssSource$2 } from "./sharedBaseCss.css-nYy9vlzH.js";
|
|
8
8
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
9
9
|
import { getInstallUrl } from "@frak-labs/core-sdk/actions";
|
|
10
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
10
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
12
12
|
// src/hooks/useHostTheme.ts
|
|
13
13
|
const QUIET_BORDER_DISTANCE = 120;
|
|
@@ -17,6 +17,8 @@ const VISIBLE_CONTRAST = 1.5;
|
|
|
17
17
|
const VISIBLE_DISTANCE = 60;
|
|
18
18
|
const DEFAULT_ACCENT = "rgb(17, 17, 17)";
|
|
19
19
|
const DEFAULT_TAG_BG = "rgb(255, 255, 255)";
|
|
20
|
+
const WHITE = "rgb(255, 255, 255)";
|
|
21
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/i;
|
|
20
22
|
const TAG_TINT = .08;
|
|
21
23
|
const RESET_HEADING_RATIO = 1.25;
|
|
22
24
|
const WIDGET_WORDS = /cookie|consent|newsletter|popup|modal|sr-only|visually-hidden|skip-to/i;
|
|
@@ -35,6 +37,11 @@ const FONT_KNOBS = [
|
|
|
35
37
|
"h2-family",
|
|
36
38
|
"h2-transform"
|
|
37
39
|
];
|
|
40
|
+
const ACCENT_KNOBS = [
|
|
41
|
+
"accent",
|
|
42
|
+
"accent-ink",
|
|
43
|
+
"accent-text"
|
|
44
|
+
];
|
|
38
45
|
const REFERENCE_HEADINGS = "[data-frak-amb-ref]";
|
|
39
46
|
function alphaOf(value) {
|
|
40
47
|
const slash = /\/\s*([\d.]+)(%?)\s*\)/.exec(value);
|
|
@@ -265,7 +272,8 @@ function knobsFrom(source) {
|
|
|
265
272
|
...typographyOf(source.button, "cta", source.buttonBg, false)
|
|
266
273
|
];
|
|
267
274
|
if (source.radius) knobs.push(["radius", source.radius]);
|
|
268
|
-
knobs.push(...accentKnobs(source)
|
|
275
|
+
knobs.push(...accentKnobs(source));
|
|
276
|
+
knobs.push(...tagKnobs(source));
|
|
269
277
|
if (source.button) {
|
|
270
278
|
const from = getComputedStyle(source.button);
|
|
271
279
|
knobs.push(["cta-radius", from.borderRadius.split(" ")[0]], ["cta-transform", from.textTransform]);
|
|
@@ -275,16 +283,62 @@ function knobsFrom(source) {
|
|
|
275
283
|
function knobsSignature(knobs) {
|
|
276
284
|
return knobs.map(([name, value]) => `${name}=${value}`).sort().join("|");
|
|
277
285
|
}
|
|
278
|
-
|
|
286
|
+
/** The `--frak-amb-*` knobs among `names` that already resolve on the anchor: the merchant's own. */
|
|
287
|
+
function merchantKnobs(anchor, names) {
|
|
279
288
|
const current = getComputedStyle(anchor);
|
|
280
|
-
|
|
289
|
+
return new Set(names.filter((name) => current.getPropertyValue(`--frak-amb-${name}`).trim()));
|
|
290
|
+
}
|
|
291
|
+
function writeKnobs(anchor, knobs) {
|
|
292
|
+
const merchantSet = merchantKnobs(anchor, knobs.map(([name]) => name));
|
|
293
|
+
const written = [];
|
|
281
294
|
for (const [name, value] of knobs) {
|
|
282
295
|
if (!value || isTransparent(value)) continue;
|
|
283
296
|
if (merchantSet.has(name)) continue;
|
|
284
297
|
if (name === "accent-text" && merchantSet.has("accent")) continue;
|
|
285
298
|
anchor.style.setProperty(`--frak-amb-${name}`, value);
|
|
299
|
+
written.push(name);
|
|
286
300
|
}
|
|
287
301
|
markFontKnobs(anchor);
|
|
302
|
+
return written;
|
|
303
|
+
}
|
|
304
|
+
function rgbFromHex(hex) {
|
|
305
|
+
const channel = (at) => Number.parseInt(hex.slice(at, at + 2), 16);
|
|
306
|
+
return `rgb(${channel(1)}, ${channel(3)}, ${channel(5)})`;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The dashboard accent, its ink and the figures' text. A light accent on a
|
|
310
|
+
* light page (or a dark one on a dark page) sends the text to the page's own
|
|
311
|
+
* colour, the same rule the sampled accent follows.
|
|
312
|
+
*/
|
|
313
|
+
function dashboardKnobs(anchor, hex) {
|
|
314
|
+
const fill = rgbFromHex(hex);
|
|
315
|
+
const ink = contrastRatio(fill, WHITE) >= READABLE_CONTRAST ? "#fff" : "#000";
|
|
316
|
+
const knobs = [["accent", hex], ["accent-ink", ink]];
|
|
317
|
+
if (!(contrastRatio(fill, backdropOf(anchor)) >= READABLE_CONTRAST)) knobs.push(["accent-text", "currentColor"]);
|
|
318
|
+
return knobs;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Writes the dashboard accent synchronously, so it neither waits for the
|
|
322
|
+
* sampler nor depends on it. A merchant's CSS accent takes it over entirely.
|
|
323
|
+
*/
|
|
324
|
+
function writeDashboardAccent(anchor, hex) {
|
|
325
|
+
if (!HEX_COLOR.test(hex)) return [];
|
|
326
|
+
const knobs = dashboardKnobs(anchor, hex);
|
|
327
|
+
const merchantSet = merchantKnobs(anchor, knobs.map(([name]) => name));
|
|
328
|
+
if (merchantSet.has("accent")) return [];
|
|
329
|
+
const written = [];
|
|
330
|
+
for (const [name, value] of knobs) {
|
|
331
|
+
if (merchantSet.has(name)) continue;
|
|
332
|
+
anchor.style.setProperty(`--frak-amb-${name}`, value);
|
|
333
|
+
written.push(name);
|
|
334
|
+
}
|
|
335
|
+
return written;
|
|
336
|
+
}
|
|
337
|
+
/** The one place that decides who owns the accent: the dashboard, else the sample. */
|
|
338
|
+
function writeAccent(anchor, dashboardHex, sampled) {
|
|
339
|
+
const dashboard = dashboardHex ? writeDashboardAccent(anchor, dashboardHex) : [];
|
|
340
|
+
if (dashboard.includes("accent")) return dashboard;
|
|
341
|
+
return sampled ? writeKnobs(anchor, sampled) : [];
|
|
288
342
|
}
|
|
289
343
|
/**
|
|
290
344
|
* Heading font rules apply only behind this attribute: an unset `var()` in
|
|
@@ -305,28 +359,52 @@ async function settled() {
|
|
|
305
359
|
if (document.fonts?.ready) await document.fonts.ready;
|
|
306
360
|
await nextFrame();
|
|
307
361
|
}
|
|
308
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Themes the page from the host. `accentColor` (the dashboard setting) outranks
|
|
364
|
+
* the sampled button colour; the merchant's own `--frak-amb-accent` outranks both.
|
|
365
|
+
*/
|
|
366
|
+
function useHostTheme(target, accentColor) {
|
|
367
|
+
const [sampledAccent, setSampledAccent] = useState();
|
|
309
368
|
useEffect(() => {
|
|
310
369
|
let cancelled = false;
|
|
370
|
+
const anchor = target.current;
|
|
371
|
+
const written = [];
|
|
311
372
|
const run = async () => {
|
|
312
373
|
try {
|
|
313
374
|
await settled();
|
|
314
375
|
if (cancelled) return;
|
|
315
|
-
const
|
|
316
|
-
if (!
|
|
317
|
-
const first = knobsFrom(sampleTheme(
|
|
376
|
+
const current = target.current;
|
|
377
|
+
if (!current) return;
|
|
378
|
+
const first = knobsFrom(sampleTheme(current));
|
|
318
379
|
await nextFrame();
|
|
319
380
|
if (cancelled) return;
|
|
320
|
-
const second = knobsFrom(sampleTheme(
|
|
381
|
+
const second = knobsFrom(sampleTheme(current));
|
|
321
382
|
if (knobsSignature(first) !== knobsSignature(second)) return;
|
|
322
|
-
|
|
383
|
+
const isAccent = ([name]) => ACCENT_KNOBS.includes(name);
|
|
384
|
+
written.push(...writeKnobs(current, first.filter((k) => !isAccent(k))));
|
|
385
|
+
setSampledAccent(first.filter(isAccent));
|
|
323
386
|
} catch {}
|
|
324
387
|
};
|
|
325
388
|
run();
|
|
326
389
|
return () => {
|
|
327
390
|
cancelled = true;
|
|
391
|
+
if (!anchor) return;
|
|
392
|
+
for (const name of written) anchor.style.removeProperty(`--frak-amb-${name}`);
|
|
393
|
+
markFontKnobs(anchor);
|
|
328
394
|
};
|
|
329
395
|
}, [target]);
|
|
396
|
+
useLayoutEffect(() => {
|
|
397
|
+
const anchor = target.current;
|
|
398
|
+
if (!anchor) return;
|
|
399
|
+
const written = writeAccent(anchor, accentColor, sampledAccent);
|
|
400
|
+
return () => {
|
|
401
|
+
for (const name of written) anchor.style.removeProperty(`--frak-amb-${name}`);
|
|
402
|
+
};
|
|
403
|
+
}, [
|
|
404
|
+
target,
|
|
405
|
+
accentColor,
|
|
406
|
+
sampledAccent
|
|
407
|
+
]);
|
|
330
408
|
}
|
|
331
409
|
// \0ve-inline:src/components/Ambassador/Ambassador.css.ts.vanilla.js
|
|
332
410
|
const cssSource$1 = `.Ambassador_panel__awpcg00 {
|
|
@@ -1225,16 +1303,17 @@ function Ambassador(props) {
|
|
|
1225
1303
|
const dashboard = useGlobalComponents()?.ambassador;
|
|
1226
1304
|
const merged = {
|
|
1227
1305
|
...props,
|
|
1228
|
-
faq5Answer: dashboard?.faq5Answer
|
|
1306
|
+
faq5Answer: dashboard?.faq5Answer,
|
|
1307
|
+
accentColor: dashboard?.accentColor
|
|
1229
1308
|
};
|
|
1230
1309
|
for (const field of DASHBOARD_FIELDS) merged[field] = props[field] ?? dashboard?.[field];
|
|
1231
1310
|
return /* @__PURE__ */ jsx(AmbassadorPage, { ...merged });
|
|
1232
1311
|
}
|
|
1233
|
-
function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle: propHeroTitle, heroEyebrow: propHeroEyebrow, heroLede: propHeroLede, heroCtaLabel: propHeroCtaLabel, heroFacesCaption: propHeroFacesCaption, heroImageUrl, heroImageAlt: propHeroImageAlt, heroRewardCaption: propHeroRewardCaption, heroRewardRefereePill: propHeroRewardRefereePill, rewardEyebrow: propRewardEyebrow, rewardHeading: propRewardHeading, rewardEstimateCaption: propRewardEstimateCaption, rewardLede: propRewardLede, rewardCtaLabel: propRewardCtaLabel, rewardFooterCaption: propRewardFooterCaption, rewardNoBankDetails: propRewardNoBankDetails, rewardFallbackLabel: propRewardFallbackLabel, explainerTitle: propExplainerTitle, explainerLede: propExplainerLede, step1Title: propStep1Title, step1Description: propStep1Description, step1ImageUrl, step1ImageAlt: propStep1ImageAlt, step2Title: propStep2Title, step2Description: propStep2Description, step2ImageUrl, step2ImageAlt: propStep2ImageAlt, step3Title: propStep3Title, step3Description: propStep3Description, step3ImageUrl, step3ImageAlt: propStep3ImageAlt, winWinHeading: propWinWinHeading, winWinLede: propWinWinLede, winWinCard1Title: propWinWinCard1Title, winWinCard1Description: propWinWinCard1Description, winWinCard2Title: propWinWinCard2Title, winWinCard2Description: propWinWinCard2Description, referralHeading: propReferralHeading, referralLede: propReferralLede, referralCtaLabel: propReferralCtaLabel, storeHeading: propStoreHeading, storeLede: propStoreLede, storeAppBadgeAriaLabel: propStoreAppBadgeAriaLabel, storePlayBadgeAriaLabel: propStorePlayBadgeAriaLabel, storeQrLabel: propStoreQrLabel, storeQrCaption: propStoreQrCaption, faqHeading: propFaqHeading, faq1Question: propFaq1Question, faq1Answer: propFaq1Answer, faq2Question: propFaq2Question, faq2Answer: propFaq2Answer, faq3Question: propFaq3Question, faq3Answer: propFaq3Answer, faq4Question: propFaq4Question, faq4Answer: propFaq4Answer, faq5Question: propFaq5Question, faq5AnswerBeforeLink: propFaq5AnswerBeforeLink, faq5AnswerLinkText: propFaq5AnswerLinkText, faq5AnswerAfterLink: propFaq5AnswerAfterLink, attributionBeforeLink: propAttributionBeforeLink, attributionLinkText: propAttributionLinkText, faq5Answer: dashboardFaq5Answer }) {
|
|
1312
|
+
function AmbassadorPage({ merchantId: propMerchantId, classname = "", heroTitle: propHeroTitle, heroEyebrow: propHeroEyebrow, heroLede: propHeroLede, heroCtaLabel: propHeroCtaLabel, heroFacesCaption: propHeroFacesCaption, heroImageUrl, heroImageAlt: propHeroImageAlt, heroRewardCaption: propHeroRewardCaption, heroRewardRefereePill: propHeroRewardRefereePill, rewardEyebrow: propRewardEyebrow, rewardHeading: propRewardHeading, rewardEstimateCaption: propRewardEstimateCaption, rewardLede: propRewardLede, rewardCtaLabel: propRewardCtaLabel, rewardFooterCaption: propRewardFooterCaption, rewardNoBankDetails: propRewardNoBankDetails, rewardFallbackLabel: propRewardFallbackLabel, explainerTitle: propExplainerTitle, explainerLede: propExplainerLede, step1Title: propStep1Title, step1Description: propStep1Description, step1ImageUrl, step1ImageAlt: propStep1ImageAlt, step2Title: propStep2Title, step2Description: propStep2Description, step2ImageUrl, step2ImageAlt: propStep2ImageAlt, step3Title: propStep3Title, step3Description: propStep3Description, step3ImageUrl, step3ImageAlt: propStep3ImageAlt, winWinHeading: propWinWinHeading, winWinLede: propWinWinLede, winWinCard1Title: propWinWinCard1Title, winWinCard1Description: propWinWinCard1Description, winWinCard2Title: propWinWinCard2Title, winWinCard2Description: propWinWinCard2Description, referralHeading: propReferralHeading, referralLede: propReferralLede, referralCtaLabel: propReferralCtaLabel, storeHeading: propStoreHeading, storeLede: propStoreLede, storeAppBadgeAriaLabel: propStoreAppBadgeAriaLabel, storePlayBadgeAriaLabel: propStorePlayBadgeAriaLabel, storeQrLabel: propStoreQrLabel, storeQrCaption: propStoreQrCaption, faqHeading: propFaqHeading, faq1Question: propFaq1Question, faq1Answer: propFaq1Answer, faq2Question: propFaq2Question, faq2Answer: propFaq2Answer, faq3Question: propFaq3Question, faq3Answer: propFaq3Answer, faq4Question: propFaq4Question, faq4Answer: propFaq4Answer, faq5Question: propFaq5Question, faq5AnswerBeforeLink: propFaq5AnswerBeforeLink, faq5AnswerLinkText: propFaq5AnswerLinkText, faq5AnswerAfterLink: propFaq5AnswerAfterLink, attributionBeforeLink: propAttributionBeforeLink, attributionLinkText: propAttributionLinkText, faq5Answer: dashboardFaq5Answer, accentColor }) {
|
|
1234
1313
|
const { shouldRender, isHidden, isClientReady } = useClientReady();
|
|
1235
1314
|
const lang = useLang();
|
|
1236
1315
|
const rootRef = useRef(null);
|
|
1237
|
-
useHostTheme(rootRef);
|
|
1316
|
+
useHostTheme(rootRef, isHidden ? void 0 : accentColor);
|
|
1238
1317
|
useLightDomStyles("frak-ambassador", void 0, void 0, cssSource, cssSource$2);
|
|
1239
1318
|
const { reward: reward$1 } = useReward(isClientReady, void 0, "referrer");
|
|
1240
1319
|
const { reward: refereeReward, hasReward: hasRefereeReward } = useReward(isClientReady, void 0, "referee");
|
package/dist/banner.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w } from "./rewards-
|
|
2
|
+
import { i as w } from "./rewards-BuNthAR2.js";
|
|
3
3
|
import { a as CloseCircleIcon, i as ExternalLinkIcon, n as WarningIcon, r as LogoFrakWithName, t as GiftIcon } from "./GiftIcon-B9k_syq6.js";
|
|
4
4
|
import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
|
|
5
5
|
import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
|
|
6
6
|
import { t as usePlacement } from "./usePlacement-Dd7itnCf.js";
|
|
7
|
-
import { t as useReward } from "./useReward-
|
|
7
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
8
8
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
9
9
|
import { t as cssSource$4 } from "./sharedBaseCss.css-nYy9vlzH.js";
|
|
10
10
|
import { isInAppBrowser, redirectToExternalBrowser, sanitizeProductDetailsList, trackEvent } from "@frak-labs/core-sdk";
|
package/dist/buttonShare.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w } from "./rewards-
|
|
2
|
+
import { i as w } from "./rewards-BuNthAR2.js";
|
|
3
3
|
import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
|
|
4
4
|
import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
|
|
5
5
|
import { t as usePlacement } from "./usePlacement-Dd7itnCf.js";
|
|
6
|
-
import { t as useReward } from "./useReward-
|
|
6
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
7
7
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
8
8
|
import { sanitizeSharingProducts, trackEvent } from "@frak-labs/core-sdk";
|
|
9
9
|
import { useCallback, useEffect, useMemo, useRef } from "preact/hooks";
|
package/dist/buttonWallet.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage, t as buildStyleContent } from "./sharedCss-SKmJGZgN.js";
|
|
2
2
|
import { t as usePlacement } from "./usePlacement-Dd7itnCf.js";
|
|
3
|
-
import { t as useReward } from "./useReward-
|
|
3
|
+
import { t as useReward } from "./useReward-cQ54x8q-.js";
|
|
4
4
|
import { componentDefaults } from "./i18n/defaults.js";
|
|
5
5
|
import { trackEvent } from "@frak-labs/core-sdk";
|
|
6
6
|
import { useCallback, useEffect, useRef } from "preact/hooks";
|
package/dist/postPurchase.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as useClientReady, o as registerWebComponent, r as useLang, s as openSharingPage } from "./sharedCss-SKmJGZgN.js";
|
|
2
|
-
import { i as w, n as K, t as C } from "./rewards-
|
|
2
|
+
import { i as w, n as K, t as C } from "./rewards-BuNthAR2.js";
|
|
3
3
|
import { r as LogoFrakWithName, t as GiftIcon } from "./GiftIcon-B9k_syq6.js";
|
|
4
4
|
import { t as useGlobalComponents } from "./useGlobalComponents-BF47jsBt.js";
|
|
5
5
|
import { t as useLightDomStyles } from "./useLightDomStyles-wGaNXHqN.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../core/dist/getCurrencyAmountKey-
|
|
1
|
+
// ../core/dist/getCurrencyAmountKey-BDZ_Te1S.js
|
|
2
2
|
const e = {
|
|
3
3
|
eur: `fr-FR`,
|
|
4
4
|
usd: `en-US`,
|
|
@@ -10,51 +10,54 @@ function t(t) {
|
|
|
10
10
|
function n(t) {
|
|
11
11
|
return t ? e[t] ?? e.eur : e.eur;
|
|
12
12
|
}
|
|
13
|
-
function r(e
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function r(e) {
|
|
14
|
+
return e.replaceAll(` `, `\xA0`);
|
|
15
|
+
}
|
|
16
|
+
function i(e, i) {
|
|
17
|
+
let a = n(i), o = t(i);
|
|
18
|
+
return r(e.toLocaleString(a, {
|
|
16
19
|
style: `currency`,
|
|
17
|
-
currency:
|
|
20
|
+
currency: o,
|
|
18
21
|
minimumFractionDigits: 0,
|
|
19
22
|
maximumFractionDigits: 2
|
|
20
|
-
});
|
|
23
|
+
}));
|
|
21
24
|
}
|
|
22
|
-
function
|
|
25
|
+
function a$1(e) {
|
|
23
26
|
return e.formatToParts(1.1).find((e) => e.type === `decimal`)?.value ?? `.`;
|
|
24
27
|
}
|
|
25
|
-
function
|
|
26
|
-
let
|
|
28
|
+
function o$1(e, i) {
|
|
29
|
+
let o = n(i), s = t(i), c = new Intl.NumberFormat(o, {
|
|
27
30
|
style: `currency`,
|
|
28
|
-
currency:
|
|
31
|
+
currency: s,
|
|
29
32
|
minimumFractionDigits: 0,
|
|
30
33
|
maximumFractionDigits: 2
|
|
31
|
-
}),
|
|
32
|
-
for (let e of
|
|
34
|
+
}), l = c.formatToParts(e), u = ``, d = ``, f = ``, p = `suffix`, m = !1;
|
|
35
|
+
for (let e of l) switch (e.type) {
|
|
33
36
|
case `integer`:
|
|
34
37
|
case `group`:
|
|
35
|
-
|
|
38
|
+
u += r(e.value), m = !0;
|
|
36
39
|
break;
|
|
37
40
|
case `decimal`:
|
|
38
41
|
case `fraction`:
|
|
39
|
-
|
|
42
|
+
d += e.value;
|
|
40
43
|
break;
|
|
41
|
-
case `currency`:
|
|
44
|
+
case `currency`: f = e.value, p = m ? `suffix` : `prefix`;
|
|
42
45
|
}
|
|
43
46
|
return {
|
|
44
|
-
integer:
|
|
45
|
-
decimals:
|
|
46
|
-
unit:
|
|
47
|
-
unitPosition:
|
|
47
|
+
integer: u,
|
|
48
|
+
decimals: d || `${a$1(c)}00`,
|
|
49
|
+
unit: f,
|
|
50
|
+
unitPosition: p
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
|
-
function
|
|
53
|
+
function s$1(e) {
|
|
51
54
|
return {
|
|
52
55
|
integer: String(e),
|
|
53
56
|
unit: `%`,
|
|
54
57
|
unitPosition: `suffix`
|
|
55
58
|
};
|
|
56
59
|
}
|
|
57
|
-
function
|
|
60
|
+
function c$1(e) {
|
|
58
61
|
return e ? `${e}Amount` : `eurAmount`;
|
|
59
62
|
}
|
|
60
63
|
// ../core/dist/rewards.js
|
|
@@ -105,34 +108,34 @@ function y(e, t) {
|
|
|
105
108
|
let n = _(e, t);
|
|
106
109
|
return n > 0 ? n : v(e) * 1e-6;
|
|
107
110
|
}
|
|
108
|
-
function x(n, r
|
|
109
|
-
let a = t(r
|
|
111
|
+
function x(n, r) {
|
|
112
|
+
let a = t(r), o = c$1(a);
|
|
110
113
|
switch (n.payoutType) {
|
|
111
|
-
case `fixed`: return
|
|
114
|
+
case `fixed`: return i(Math.round(n.amount[o]), a);
|
|
112
115
|
case `percentage`: return `${n.percent} %`;
|
|
113
116
|
case `tiered`: {
|
|
114
117
|
let e = _(n, o);
|
|
115
|
-
if (e > 0) return
|
|
116
|
-
let r
|
|
117
|
-
return r
|
|
118
|
+
if (e > 0) return i(Math.round(e), a);
|
|
119
|
+
let r = v(n);
|
|
120
|
+
return r > 0 ? `${r} %` : i(0, a);
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
function S(t$1, a) {
|
|
122
|
-
let o = t(a), s =
|
|
125
|
+
let o = t(a), s = c$1(o);
|
|
123
126
|
switch (t$1.payoutType) {
|
|
124
|
-
case `fixed`: return
|
|
125
|
-
case `percentage`: return
|
|
127
|
+
case `fixed`: return o$1(Math.round(t$1.amount[s]), o);
|
|
128
|
+
case `percentage`: return s$1(t$1.percent);
|
|
126
129
|
case `tiered`: {
|
|
127
130
|
let e = _(t$1, s);
|
|
128
|
-
if (e > 0) return
|
|
131
|
+
if (e > 0) return o$1(Math.round(e), o);
|
|
129
132
|
let i = v(t$1);
|
|
130
|
-
return i > 0 ?
|
|
133
|
+
return i > 0 ? s$1(i) : o$1(0, o);
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
function C(t$2, n) {
|
|
135
|
-
if (!(!t$2 || y(t$2,
|
|
138
|
+
if (!(!t$2 || y(t$2, c$1(t(n))) <= 0)) return x(t$2, n);
|
|
136
139
|
}
|
|
137
140
|
function w(e, t) {
|
|
138
141
|
return t ? e.replaceAll(`{REWARD}`, t) : e.replaceAll(`{REWARD}`, ``);
|
|
@@ -231,7 +234,7 @@ function G(e, t) {
|
|
|
231
234
|
return !t || t.length === 0 || !e.productScope || t.some((t) => z(e.productScope, t));
|
|
232
235
|
}
|
|
233
236
|
function K(t$3, n = {}) {
|
|
234
|
-
let r = (n.now ?? /* @__PURE__ */ new Date()).getTime(), a = n.audience ?? `referrer`, o =
|
|
237
|
+
let r = (n.now ?? /* @__PURE__ */ new Date()).getTime(), a = n.audience ?? `referrer`, o = c$1(t(n.currency)), s = (n.targetInteraction ? t$3.filter((e) => e.interactionTypeKey === n.targetInteraction) : t$3).filter((e) => !B(e, r)), c = s.filter((e) => V(e, r));
|
|
235
238
|
if (c.length > 0) {
|
|
236
239
|
let e = c.reduce((e, t) => {
|
|
237
240
|
let r = G(e, n.products), i = G(t, n.products);
|
|
@@ -260,24 +263,24 @@ function K(t$3, n = {}) {
|
|
|
260
263
|
};
|
|
261
264
|
}
|
|
262
265
|
function q(e, n = {}) {
|
|
263
|
-
let r
|
|
264
|
-
if (!r
|
|
265
|
-
let i = H(r
|
|
266
|
-
if (!i) return;
|
|
267
|
-
let a = C(i, n.currency);
|
|
266
|
+
let r = K(e, n);
|
|
267
|
+
if (!r) return;
|
|
268
|
+
let i$1 = H(r.campaign, n.audience ?? `referrer`);
|
|
269
|
+
if (!i$1) return;
|
|
270
|
+
let a = C(i$1, n.currency);
|
|
268
271
|
if (!a) return;
|
|
269
|
-
let o = u(r
|
|
272
|
+
let o = u(r.campaign.conditions), s = o == null ? void 0 : i(o, n.currency), c = r.campaign.defaultLockupSeconds, l = c && c > 0 ? Math.round(c / 86400) : void 0;
|
|
270
273
|
return {
|
|
271
274
|
formatted: a,
|
|
272
|
-
parts: S(i, n.currency),
|
|
273
|
-
payoutType: i.payoutType,
|
|
275
|
+
parts: S(i$1, n.currency),
|
|
276
|
+
payoutType: i$1.payoutType,
|
|
274
277
|
minPurchaseAmount: s,
|
|
275
278
|
lockupDurationDays: l,
|
|
276
|
-
referrerReward: r
|
|
277
|
-
refereeReward: r
|
|
279
|
+
referrerReward: r.campaign.referrer,
|
|
280
|
+
refereeReward: r.campaign.referee,
|
|
278
281
|
minPurchaseValue: o ?? void 0,
|
|
279
|
-
isProductScoped: r
|
|
280
|
-
matchedProducts: r
|
|
282
|
+
isProductScoped: r.campaign.productScope != null,
|
|
283
|
+
matchedProducts: r.matchedProducts
|
|
281
284
|
};
|
|
282
285
|
}
|
|
283
286
|
export { w as i, K as n, q as r, C as t };
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.4.0",
|
|
15
15
|
"description": "Frak web components (share button, banner, post-purchase, ambassador page) for any merchant page; load the shim from https://sdk.frak.id/components.js.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"try:merchant": "bun scripts/tryOnMerchant.ts"
|
|
109
109
|
},
|
|
110
110
|
"dependencies": {
|
|
111
|
-
"@frak-labs/core-sdk": "1.5.
|
|
111
|
+
"@frak-labs/core-sdk": "1.5.5",
|
|
112
112
|
"@frak-labs/frame-connector": "1.5.2",
|
|
113
113
|
"preact": "^10.29.8",
|
|
114
114
|
"preact-custom-element": "^4.6.0",
|