@sensiblestats/widget-react 0.154.1 → 0.156.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/CHANGELOG.md +17 -0
- package/README.md +4 -2
- package/dist/index.cjs +193 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -36
- package/dist/index.d.ts +42 -36
- package/dist/index.js +194 -62
- package/dist/index.js.map +1 -1
- package/dist/styles.css +13 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.156.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ebf1a14: Web parity with the mobile wrappers. widget-sdk exports `UnavailableReason`, `Teaser`, `TeaserPrice`, `PriceResult` and `observingFetch` (the mobile bridge types now come from it; `MobileTeaser`, `MobileTeaserPrice` and `MobilePriceResult` are removed from widget-react). widget-react adds `launcher: false` (hides the built-in launcher), `onTeaser(teaser | null)` and `onUnavailable(reason)` (`widget_disabled`, `auth_failed`) to `StatsWidgetConfig`, and `tapAsk`, `tapPrice` (resolves `PriceResult | null`), `tapCta`, `tapTeaser`, `dismissTeaser`, `teaserShown` to the `WidgetHost` from `createWidgetHost()`. A mounted `<StatsWidget>` now rebuilds its client, starts a fresh thread, and drops the previous visitor's pins and slip marks when `userContext.operatorUserId` or `anonymousUserId` changes. The teaser methods act only when the widget has `launcher: false`, and `onTeaser(null)` is delivered when the widget unmounts. widget-embed adds `data-launcher="false"`, the `sensiblestats:teaser` (`detail.teaser`) and `sensiblestats:unavailable` (`detail.reason`) window events, and the six teaser actions on the `init()` handle and the `window.SensibleStatsWidget` global.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [ebf1a14]
|
|
12
|
+
- @sensiblestats/widget-sdk@0.114.0
|
|
13
|
+
|
|
14
|
+
## 0.155.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- Brand colours now come in a light and a dark group. `colors: { light, dark }` replaces the flat `accent`, `cta`, `surface` and `ink` config keys (breaking). Each group takes `accent`, `cta`, `surface` and `ink`. The dark theme reads only `colors.dark`; a dark colour left out shows the built-in dark colour, never the light one. On the script tag, `data-accent`, `data-cta`, `data-surface` and `data-ink` fill the light group and `data-accent-dark`, `data-cta-dark`, `data-surface-dark` and `data-ink-dark` fill the dark group; the mobile fragment uses `accentDark`, `ctaDark`, `surfaceDark` and `inkDark`. Blank values are ignored. Brand colours no longer lock the theme: the visitor's theme choice always wins and Settings always shows the theme row.
|
|
19
|
+
|
|
3
20
|
## 0.154.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -57,8 +57,10 @@ Common `config` fields:
|
|
|
57
57
|
over this `defaultLanguage`. `operatorUserId` travels from the browser, so make it a random,
|
|
58
58
|
non-guessable value you map to the user on your side (a UUID works): never an
|
|
59
59
|
account number, email, username or sequential id.
|
|
60
|
-
- White-label branding — `logoUrl`, `headerTitle`, `
|
|
61
|
-
`ink`.
|
|
60
|
+
- White-label branding — `logoUrl`, `headerTitle`, and `colors: { light, dark }`, each group
|
|
61
|
+
taking `accent`, `cta`, `surface` and `ink`. The dark theme reads only `colors.dark`; a dark
|
|
62
|
+
colour left out shows the built-in dark colour, never the light one. Absent → the default
|
|
63
|
+
SensibleStats look.
|
|
62
64
|
- `page` — the page the widget sits on, `{ sport, kind?, matchId?, competitionId? }`, so the
|
|
63
65
|
first greeting can lead with it. Football ids are bare (`'4820113'`); NBA ids are
|
|
64
66
|
`'nba:game:{id}'` or digits. `sport` is `'football'` or `'nba'`; the server answers any other
|
package/dist/index.cjs
CHANGED
|
@@ -1422,9 +1422,19 @@ function parseCustomTotal(text2, format2) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
|
|
1424
1424
|
// src/version.generated.ts
|
|
1425
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1425
|
+
var WIDGET_REACT_VERSION = "0.156.0";
|
|
1426
1426
|
|
|
1427
1427
|
// src/config.ts
|
|
1428
|
+
var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
|
|
1429
|
+
function themeColors(group) {
|
|
1430
|
+
const out = {};
|
|
1431
|
+
if (!group || typeof group !== "object") return out;
|
|
1432
|
+
for (const k of COLOR_KEYS) {
|
|
1433
|
+
const v = group[k];
|
|
1434
|
+
if (typeof v === "string" && v.trim() !== "") out[k] = v.trim();
|
|
1435
|
+
}
|
|
1436
|
+
return out;
|
|
1437
|
+
}
|
|
1428
1438
|
function hostTag(cfg) {
|
|
1429
1439
|
const pick = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
|
|
1430
1440
|
return pick(cfg?.locale) ?? pick(cfg?.userContext?.defaultLanguage);
|
|
@@ -1436,7 +1446,7 @@ function normalizeUi(cfg, loaded) {
|
|
|
1436
1446
|
return {
|
|
1437
1447
|
theme: cfg.theme ?? "auto",
|
|
1438
1448
|
oddsFormat: parseOddsFormat(cfg.oddsFormat) ?? "decimal",
|
|
1439
|
-
|
|
1449
|
+
colors: { light: themeColors(cfg.colors?.light), dark: themeColors(cfg.colors?.dark) },
|
|
1440
1450
|
logoUrl: cfg.logoUrl,
|
|
1441
1451
|
headerTitle: cfg.headerTitle,
|
|
1442
1452
|
locale: loaded.tag,
|
|
@@ -1444,9 +1454,6 @@ function normalizeUi(cfg, loaded) {
|
|
|
1444
1454
|
timeZone,
|
|
1445
1455
|
hostTag: hostTag(cfg),
|
|
1446
1456
|
rawBettingLabels: isBundledFamily(loaded.tag),
|
|
1447
|
-
cta: cfg.cta,
|
|
1448
|
-
surface: cfg.surface,
|
|
1449
|
-
ink: cfg.ink,
|
|
1450
1457
|
pinIcon: cfg.pinIcon ?? "pin",
|
|
1451
1458
|
position: cfg.position ?? "right",
|
|
1452
1459
|
offset: { x: cfg.offset?.x ?? 20, y: cfg.offset?.y ?? 20 },
|
|
@@ -2834,7 +2841,7 @@ function isValidId(value) {
|
|
|
2834
2841
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
2835
2842
|
}
|
|
2836
2843
|
function createWidgetHost() {
|
|
2837
|
-
const state = { queue: [], sink: null };
|
|
2844
|
+
const state = { queue: [], sink: null, teaser: null };
|
|
2838
2845
|
const dispatch = (command) => {
|
|
2839
2846
|
if (state.sink) {
|
|
2840
2847
|
state.sink(command);
|
|
@@ -2880,11 +2887,49 @@ function createWidgetHost() {
|
|
|
2880
2887
|
if (isValidId(id)) dispatch({ kind: "matchOpened", matchId: id });
|
|
2881
2888
|
} catch {
|
|
2882
2889
|
}
|
|
2890
|
+
},
|
|
2891
|
+
// A teaser tap is about what is on screen now, so it is never queued for a widget that is not there.
|
|
2892
|
+
tapAsk(index) {
|
|
2893
|
+
teaser(state, (t) => t.tapAsk(index));
|
|
2894
|
+
},
|
|
2895
|
+
tapPrice() {
|
|
2896
|
+
try {
|
|
2897
|
+
return state.teaser ? state.teaser.tapPrice().catch(() => null) : Promise.resolve(null);
|
|
2898
|
+
} catch {
|
|
2899
|
+
return Promise.resolve(null);
|
|
2900
|
+
}
|
|
2901
|
+
},
|
|
2902
|
+
tapCta() {
|
|
2903
|
+
teaser(state, (t) => t.tapCta());
|
|
2904
|
+
},
|
|
2905
|
+
tapTeaser() {
|
|
2906
|
+
teaser(state, (t) => t.tapTeaser());
|
|
2907
|
+
},
|
|
2908
|
+
dismissTeaser() {
|
|
2909
|
+
teaser(state, (t) => t.dismissTeaser());
|
|
2910
|
+
},
|
|
2911
|
+
teaserShown() {
|
|
2912
|
+
teaser(state, (t) => t.teaserShown());
|
|
2883
2913
|
}
|
|
2884
2914
|
};
|
|
2885
2915
|
STATES.set(host, state);
|
|
2886
2916
|
return host;
|
|
2887
2917
|
}
|
|
2918
|
+
function teaser(state, call) {
|
|
2919
|
+
try {
|
|
2920
|
+
if (state.teaser) call(state.teaser);
|
|
2921
|
+
} catch {
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
function attachTeaser(host, control) {
|
|
2925
|
+
const state = STATES.get(host);
|
|
2926
|
+
if (!state) return () => {
|
|
2927
|
+
};
|
|
2928
|
+
state.teaser = control;
|
|
2929
|
+
return () => {
|
|
2930
|
+
if (state.teaser === control) state.teaser = null;
|
|
2931
|
+
};
|
|
2932
|
+
}
|
|
2888
2933
|
function attachHost(host, sink) {
|
|
2889
2934
|
const state = STATES.get(host);
|
|
2890
2935
|
if (!state) return () => {
|
|
@@ -3120,6 +3165,12 @@ function useHostEvents(opts) {
|
|
|
3120
3165
|
const { host, operatorId, currentUser, logger, isOpen, closePanel } = opts;
|
|
3121
3166
|
const [added, setAdded] = (0, import_react2.useState)({});
|
|
3122
3167
|
const [settled, setSettled] = (0, import_react2.useState)({});
|
|
3168
|
+
const [marksUser, setMarksUser] = (0, import_react2.useState)(currentUser);
|
|
3169
|
+
if (marksUser !== currentUser) {
|
|
3170
|
+
setMarksUser(currentUser);
|
|
3171
|
+
setAdded({});
|
|
3172
|
+
setSettled({});
|
|
3173
|
+
}
|
|
3123
3174
|
const markAdded = (0, import_react2.useCallback)((key) => {
|
|
3124
3175
|
setAdded((prev) => prev[key] ? prev : { ...prev, [key]: true });
|
|
3125
3176
|
}, []);
|
|
@@ -3282,32 +3333,33 @@ function pillFor(accent, panel, theme) {
|
|
|
3282
3333
|
}
|
|
3283
3334
|
return { pill: lightPanel ? "#000000" : "#ffffff", ink };
|
|
3284
3335
|
}
|
|
3336
|
+
var PANEL = { light: LIGHT_PANEL, dark: DARK_PANEL };
|
|
3337
|
+
function brandVars(style, c, theme) {
|
|
3338
|
+
for (const k of ["accent", "cta", "surface", "ink"]) {
|
|
3339
|
+
const v = c[k];
|
|
3340
|
+
if (v) style[`--ss-w-brand-${k}-${theme}`] = v;
|
|
3341
|
+
}
|
|
3342
|
+
if (c.surface && c.ink) {
|
|
3343
|
+
style[`--ss-w-brand-bubble-${theme}`] = `color-mix(in srgb, ${c.ink} 5%, ${c.surface})`;
|
|
3344
|
+
style[`--ss-w-brand-line-${theme}`] = `color-mix(in srgb, ${c.ink} 12%, ${c.surface})`;
|
|
3345
|
+
style[`--ss-w-brand-faint-${theme}`] = `color-mix(in srgb, ${c.ink} 55%, ${c.surface})`;
|
|
3346
|
+
}
|
|
3347
|
+
if (c.accent || c.surface) {
|
|
3348
|
+
const panel = c.surface && rgb(c.surface) ? c.surface : PANEL[theme];
|
|
3349
|
+
const { pill, ink } = pillFor(c.accent, panel, theme);
|
|
3350
|
+
style[`--ss-w-pill-${theme}`] = pill;
|
|
3351
|
+
style[`--ss-w-on-pill-${theme}`] = ink;
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3285
3354
|
function themeAttrs(ui, userTheme) {
|
|
3286
3355
|
const style = {
|
|
3287
3356
|
"--ss-w-offset-x": `${ui.offset.x}px`,
|
|
3288
3357
|
"--ss-w-offset-y": `${ui.offset.y}px`,
|
|
3289
3358
|
"--ss-w-radius": `${ui.radius}px`
|
|
3290
3359
|
};
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
if (ui.ink) style["--ss-w-ink"] = ui.ink;
|
|
3295
|
-
if (ui.surface && ui.ink) {
|
|
3296
|
-
style["--ss-w-bubble"] = "color-mix(in srgb, var(--ss-w-ink) 5%, var(--ss-w-panel))";
|
|
3297
|
-
style["--ss-w-line"] = "color-mix(in srgb, var(--ss-w-ink) 12%, var(--ss-w-panel))";
|
|
3298
|
-
style["--ss-w-faint"] = "color-mix(in srgb, var(--ss-w-ink) 55%, var(--ss-w-panel))";
|
|
3299
|
-
}
|
|
3300
|
-
if (ui.accent || ui.surface) {
|
|
3301
|
-
const surface = ui.surface && rgb(ui.surface) ? ui.surface : void 0;
|
|
3302
|
-
const light = pillFor(ui.accent, surface ?? LIGHT_PANEL, "light");
|
|
3303
|
-
const dark = pillFor(ui.accent, surface ?? DARK_PANEL, "dark");
|
|
3304
|
-
style["--ss-w-pill-light"] = light.pill;
|
|
3305
|
-
style["--ss-w-on-pill-light"] = light.ink;
|
|
3306
|
-
style["--ss-w-pill-dark"] = dark.pill;
|
|
3307
|
-
style["--ss-w-on-pill-dark"] = dark.ink;
|
|
3308
|
-
}
|
|
3309
|
-
const theme = ui.surface || ui.ink ? ui.theme : userTheme ?? ui.theme;
|
|
3310
|
-
return { "data-ss-w-theme": theme, "data-ss-w-pos": ui.position, style };
|
|
3360
|
+
brandVars(style, ui.colors.light, "light");
|
|
3361
|
+
brandVars(style, ui.colors.dark, "dark");
|
|
3362
|
+
return { "data-ss-w-theme": userTheme ?? ui.theme, "data-ss-w-pos": ui.position, style };
|
|
3311
3363
|
}
|
|
3312
3364
|
|
|
3313
3365
|
// src/oddsSettingsContext.ts
|
|
@@ -3371,7 +3423,6 @@ function writeOddsOffered(operatorKey, value) {
|
|
|
3371
3423
|
var OddsSettingsContext = (0, import_react3.createContext)({
|
|
3372
3424
|
oddsFormat: "decimal",
|
|
3373
3425
|
theme: "auto",
|
|
3374
|
-
themeLocked: false,
|
|
3375
3426
|
oddsOffered: true,
|
|
3376
3427
|
setOddsFormat: () => {
|
|
3377
3428
|
},
|
|
@@ -3403,11 +3454,10 @@ function useOddsSettingsState(ui, conversation, operatorKey) {
|
|
|
3403
3454
|
userOddsFormat: stored.oddsFormat,
|
|
3404
3455
|
theme: stored.theme ?? ui.theme,
|
|
3405
3456
|
userTheme: stored.theme,
|
|
3406
|
-
themeLocked: !!(ui.surface || ui.ink),
|
|
3407
3457
|
oddsOffered,
|
|
3408
3458
|
setOddsFormat: (f) => setStored(writeSettings({ oddsFormat: f })),
|
|
3409
3459
|
setTheme: (t) => setStored(writeSettings({ theme: t }))
|
|
3410
|
-
}), [stored, ui.oddsFormat, ui.theme,
|
|
3460
|
+
}), [stored, ui.oddsFormat, ui.theme, oddsOffered]);
|
|
3411
3461
|
}
|
|
3412
3462
|
|
|
3413
3463
|
// src/useChatStream.ts
|
|
@@ -4736,7 +4786,13 @@ function phaseForPin(snapshot, pin) {
|
|
|
4736
4786
|
function useLiveMonitor(opts) {
|
|
4737
4787
|
const sessionIdRef = (0, import_react8.useRef)(crypto.randomUUID());
|
|
4738
4788
|
const [pins, setPins] = (0, import_react8.useState)([]);
|
|
4739
|
-
const [
|
|
4789
|
+
const [owned, setOwned] = (0, import_react8.useState)(() => ({ key: opts.storageKey, store: createPinStore(opts.storageKey, sessionIdRef.current, setPins) }));
|
|
4790
|
+
let current = owned;
|
|
4791
|
+
if (owned.key !== opts.storageKey) {
|
|
4792
|
+
current = { key: opts.storageKey, store: createPinStore(opts.storageKey, sessionIdRef.current, setPins) };
|
|
4793
|
+
setOwned(current);
|
|
4794
|
+
}
|
|
4795
|
+
const store = current.store;
|
|
4740
4796
|
const [enabled, setEnabled] = (0, import_react8.useState)(true);
|
|
4741
4797
|
const [snapshot, setSnapshotState] = (0, import_react8.useState)(null);
|
|
4742
4798
|
const { activeTab, setActiveTab: setActiveTabState } = useTabs("chat");
|
|
@@ -8391,8 +8447,9 @@ function useMobileBinding(args) {
|
|
|
8391
8447
|
tapTeaser: () => latest.current.onTeaserTap(),
|
|
8392
8448
|
tapPrice: (matchOddsId) => {
|
|
8393
8449
|
const { panelOpen: open, popupText: text2, price: shown2 } = latest.current;
|
|
8394
|
-
if (open || !text2 || shown2?.matchOddsId !== matchOddsId) return;
|
|
8395
|
-
priceRef.current
|
|
8450
|
+
if (open || !text2 || shown2?.matchOddsId !== matchOddsId || !priceRef.current) return false;
|
|
8451
|
+
priceRef.current();
|
|
8452
|
+
return true;
|
|
8396
8453
|
},
|
|
8397
8454
|
dismissTeaser: () => latest.current.dismissPopup(),
|
|
8398
8455
|
teaserShown: () => setConfirmedShown(latest.current.popupText),
|
|
@@ -8412,6 +8469,69 @@ function useMobileBinding(args) {
|
|
|
8412
8469
|
return { confirmedShown, onCloseRequested, onRegisterBack, onRegisterPrice, onPriceResult, priceInFlight };
|
|
8413
8470
|
}
|
|
8414
8471
|
|
|
8472
|
+
// src/webTeaser.ts
|
|
8473
|
+
function webTeaserBinding(host, deliver, drawsLauncher) {
|
|
8474
|
+
let price;
|
|
8475
|
+
let delivered = null;
|
|
8476
|
+
let detach = () => {
|
|
8477
|
+
};
|
|
8478
|
+
const waiting = /* @__PURE__ */ new Set();
|
|
8479
|
+
const emit = (teaser2) => {
|
|
8480
|
+
delivered = teaser2;
|
|
8481
|
+
try {
|
|
8482
|
+
deliver(teaser2);
|
|
8483
|
+
} catch {
|
|
8484
|
+
}
|
|
8485
|
+
};
|
|
8486
|
+
return {
|
|
8487
|
+
onTeaser: (teaser2) => {
|
|
8488
|
+
price = teaser2.price;
|
|
8489
|
+
emit(teaser2.text === null && teaser2.asks.length === 0 ? null : teaser2);
|
|
8490
|
+
},
|
|
8491
|
+
onCloseRequested: () => {
|
|
8492
|
+
},
|
|
8493
|
+
onPriceResult: (result) => {
|
|
8494
|
+
for (const w of [...waiting]) {
|
|
8495
|
+
if (w.matchOddsId !== result.matchOddsId) continue;
|
|
8496
|
+
waiting.delete(w);
|
|
8497
|
+
w.resolve(result);
|
|
8498
|
+
}
|
|
8499
|
+
},
|
|
8500
|
+
onHandle: (handle) => {
|
|
8501
|
+
detach();
|
|
8502
|
+
detach = () => {
|
|
8503
|
+
};
|
|
8504
|
+
if (!handle) {
|
|
8505
|
+
price = void 0;
|
|
8506
|
+
for (const w of [...waiting]) w.resolve(null);
|
|
8507
|
+
waiting.clear();
|
|
8508
|
+
if (delivered !== null) emit(null);
|
|
8509
|
+
return;
|
|
8510
|
+
}
|
|
8511
|
+
if (!host || !drawsLauncher) return;
|
|
8512
|
+
detach = attachTeaser(host, {
|
|
8513
|
+
tapAsk: handle.tapAsk,
|
|
8514
|
+
tapCta: handle.tapCta,
|
|
8515
|
+
tapTeaser: handle.tapTeaser,
|
|
8516
|
+
dismissTeaser: handle.dismissTeaser,
|
|
8517
|
+
teaserShown: handle.teaserShown,
|
|
8518
|
+
tapPrice: () => {
|
|
8519
|
+
if (!price) return Promise.resolve(null);
|
|
8520
|
+
const matchOddsId = price.matchOddsId;
|
|
8521
|
+
return new Promise((resolve) => {
|
|
8522
|
+
const w = { matchOddsId, resolve };
|
|
8523
|
+
waiting.add(w);
|
|
8524
|
+
if (!handle.tapPrice(matchOddsId)) {
|
|
8525
|
+
waiting.delete(w);
|
|
8526
|
+
resolve(null);
|
|
8527
|
+
}
|
|
8528
|
+
});
|
|
8529
|
+
}
|
|
8530
|
+
});
|
|
8531
|
+
}
|
|
8532
|
+
};
|
|
8533
|
+
}
|
|
8534
|
+
|
|
8415
8535
|
// src/openTelemetry.ts
|
|
8416
8536
|
var import_react57 = require("react");
|
|
8417
8537
|
function useOpenTelemetry(log, isOpen) {
|
|
@@ -19017,7 +19137,7 @@ function SettingsSheet({ ui, onClose }) {
|
|
|
19017
19137
|
] }),
|
|
19018
19138
|
/* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "ss-w-set-seg", role: "group", "aria-labelledby": "ss-w-set-odds", children: ODDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("button", { type: "button", "aria-pressed": s.oddsFormat === f, onClick: () => s.setOddsFormat(f), children: t[f] }, f)) })
|
|
19019
19139
|
] }),
|
|
19020
|
-
|
|
19140
|
+
/* @__PURE__ */ (0, import_jsx_runtime161.jsxs)("div", { className: "ss-w-set-row", children: [
|
|
19021
19141
|
/* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "ss-w-tool-label", id: "ss-w-set-theme", children: t.themeLabel }),
|
|
19022
19142
|
/* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "ss-w-set-seg", role: "group", "aria-labelledby": "ss-w-set-theme", children: THEMES2.map((m) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("button", { type: "button", "aria-pressed": s.theme === m, onClick: () => s.setTheme(m), children: t[m] }, m)) })
|
|
19023
19143
|
] })
|
|
@@ -19126,9 +19246,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19126
19246
|
const focusAfterCloseRef = (0, import_react122.useRef)(null);
|
|
19127
19247
|
const [tool, setTool] = (0, import_react122.useState)(null);
|
|
19128
19248
|
const panelRef = (0, import_react122.useRef)(null);
|
|
19129
|
-
const settings = useOddsSettings();
|
|
19130
19249
|
const [settingsOpen, setSettingsOpen] = (0, import_react122.useState)(false);
|
|
19131
|
-
const hasSettings = settings.oddsOffered || !settings.themeLocked;
|
|
19132
19250
|
const openSettings = (0, import_react122.useCallback)(() => {
|
|
19133
19251
|
setTool(null);
|
|
19134
19252
|
setFavouritesOpen?.(false);
|
|
@@ -19195,7 +19313,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19195
19313
|
closeFavourites();
|
|
19196
19314
|
return true;
|
|
19197
19315
|
}
|
|
19198
|
-
if (settingsOpen
|
|
19316
|
+
if (settingsOpen) {
|
|
19199
19317
|
closeSettings();
|
|
19200
19318
|
return true;
|
|
19201
19319
|
}
|
|
@@ -19230,7 +19348,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19230
19348
|
canReset: state.messages.length > 0,
|
|
19231
19349
|
newConversationLabel: ui.newConversation,
|
|
19232
19350
|
moreOptionsLabel: ui.moreOptions,
|
|
19233
|
-
onOpenSettings:
|
|
19351
|
+
onOpenSettings: openSettings,
|
|
19234
19352
|
settingsLabel: ui.settings.title,
|
|
19235
19353
|
onOpenFavourites: favouritesOffered ? openFavourites : void 0,
|
|
19236
19354
|
favouritesLabel: ui.tabFavourites
|
|
@@ -19357,7 +19475,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19357
19475
|
}
|
|
19358
19476
|
)
|
|
19359
19477
|
] }),
|
|
19360
|
-
settingsOpen
|
|
19478
|
+
settingsOpen ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(SettingsSheet, { ui, onClose: closeSettings }) : null,
|
|
19361
19479
|
favouritesOpen && favourites ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(FavouritesSheet, { ui, controller: favourites.controller, sport: favourites.sport, sports: favourites.sports, onSportChange: favourites.onSportChange, onClose: closeFavourites }) : null
|
|
19362
19480
|
] });
|
|
19363
19481
|
}
|
|
@@ -19372,11 +19490,11 @@ function HostEventsProvider({ value, children }) {
|
|
|
19372
19490
|
var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
19373
19491
|
.ss-w-root, .ss-w-root * { box-sizing: border-box; margin: 0; padding: 0; }
|
|
19374
19492
|
.ss-w-root {
|
|
19375
|
-
--ss-w-accent: #17936a;
|
|
19493
|
+
--ss-w-accent: var(--ss-w-brand-accent-light, #17936a);
|
|
19376
19494
|
--ss-w-pill: var(--ss-w-pill-light, color-mix(in srgb, var(--ss-w-accent) 72%, #000)); --ss-w-on-accent: var(--ss-w-on-pill-light, #fff);
|
|
19377
|
-
--ss-w-cta: #f5a623; --ss-w-cta-ink: #1b1300;
|
|
19378
|
-
--ss-w-ink: #14181d; --ss-w-faint: #6b7580; --ss-w-line: #e4e8ec;
|
|
19379
|
-
--ss-w-panel: #ffffff; --ss-w-bubble: #f3f5f7; --ss-w-nav: #0e1622;
|
|
19495
|
+
--ss-w-cta: var(--ss-w-brand-cta-light, #f5a623); --ss-w-cta-ink: #1b1300;
|
|
19496
|
+
--ss-w-ink: var(--ss-w-brand-ink-light, #14181d); --ss-w-faint: var(--ss-w-brand-faint-light, #6b7580); --ss-w-line: var(--ss-w-brand-line-light, #e4e8ec);
|
|
19497
|
+
--ss-w-panel: var(--ss-w-brand-surface-light, #ffffff); --ss-w-bubble: var(--ss-w-brand-bubble-light, #f3f5f7); --ss-w-nav: #0e1622;
|
|
19380
19498
|
--ss-w-pos: #1aa563; --ss-w-neg: #e0524b; --ss-w-warn: #c07a00;
|
|
19381
19499
|
--ss-w-home: #3a63a8; --ss-w-away: #c8102e; --ss-w-track: #e9edf1;
|
|
19382
19500
|
--ss-w-correct: #1f9d55; --ss-w-wrong: #b9bbc2;
|
|
@@ -19386,29 +19504,29 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
19386
19504
|
}
|
|
19387
19505
|
@media (prefers-color-scheme: dark) {
|
|
19388
19506
|
.ss-w-root[data-ss-w-theme="auto"] {
|
|
19389
|
-
--ss-w-accent: #37c891; --ss-w-cta: #ffb638; --ss-w-cta-ink: #1b1300;
|
|
19507
|
+
--ss-w-accent: var(--ss-w-brand-accent-dark, #37c891); --ss-w-cta: var(--ss-w-brand-cta-dark, #ffb638); --ss-w-cta-ink: #1b1300;
|
|
19390
19508
|
--ss-w-pill: var(--ss-w-pill-dark, var(--ss-w-accent)); --ss-w-on-accent: var(--ss-w-on-pill-dark, #06231a);
|
|
19391
|
-
--ss-w-ink: #e8edf2; --ss-w-faint: #8b95a1;
|
|
19392
|
-
--ss-w-line: #2a3441; --ss-w-panel: #141b24; --ss-w-bubble: #1e2732; --ss-w-nav: #0a0f16;
|
|
19509
|
+
--ss-w-ink: var(--ss-w-brand-ink-dark, #e8edf2); --ss-w-faint: var(--ss-w-brand-faint-dark, #8b95a1);
|
|
19510
|
+
--ss-w-line: var(--ss-w-brand-line-dark, #2a3441); --ss-w-panel: var(--ss-w-brand-surface-dark, #141b24); --ss-w-bubble: var(--ss-w-brand-bubble-dark, #1e2732); --ss-w-nav: #0a0f16;
|
|
19393
19511
|
--ss-w-pos: #37c891; --ss-w-neg: #f0655d; --ss-w-warn: #e0a030;
|
|
19394
19512
|
--ss-w-home: #5b83c8; --ss-w-away: #e8384f; --ss-w-track: #232d3a;
|
|
19395
19513
|
--ss-w-correct: #37c86b; --ss-w-wrong: #3a3a41;
|
|
19396
19514
|
}
|
|
19397
19515
|
}
|
|
19398
19516
|
.ss-w-root[data-ss-w-theme="dark"] {
|
|
19399
|
-
--ss-w-accent: #37c891; --ss-w-cta: #ffb638; --ss-w-cta-ink: #1b1300;
|
|
19517
|
+
--ss-w-accent: var(--ss-w-brand-accent-dark, #37c891); --ss-w-cta: var(--ss-w-brand-cta-dark, #ffb638); --ss-w-cta-ink: #1b1300;
|
|
19400
19518
|
--ss-w-pill: var(--ss-w-pill-dark, var(--ss-w-accent)); --ss-w-on-accent: var(--ss-w-on-pill-dark, #06231a);
|
|
19401
|
-
--ss-w-ink: #e8edf2; --ss-w-faint: #8b95a1;
|
|
19402
|
-
--ss-w-line: #2a3441; --ss-w-panel: #141b24; --ss-w-bubble: #1e2732; --ss-w-nav: #0a0f16;
|
|
19519
|
+
--ss-w-ink: var(--ss-w-brand-ink-dark, #e8edf2); --ss-w-faint: var(--ss-w-brand-faint-dark, #8b95a1);
|
|
19520
|
+
--ss-w-line: var(--ss-w-brand-line-dark, #2a3441); --ss-w-panel: var(--ss-w-brand-surface-dark, #141b24); --ss-w-bubble: var(--ss-w-brand-bubble-dark, #1e2732); --ss-w-nav: #0a0f16;
|
|
19403
19521
|
--ss-w-pos: #37c891; --ss-w-neg: #f0655d; --ss-w-warn: #e0a030;
|
|
19404
19522
|
--ss-w-home: #5b83c8; --ss-w-away: #e8384f; --ss-w-track: #232d3a;
|
|
19405
19523
|
--ss-w-correct: #37c86b; --ss-w-wrong: #3a3a41;
|
|
19406
19524
|
}
|
|
19407
19525
|
.ss-w-root[data-ss-w-theme="light"] {
|
|
19408
|
-
--ss-w-accent: #17936a; --ss-w-cta: #f5a623; --ss-w-cta-ink: #1b1300;
|
|
19526
|
+
--ss-w-accent: var(--ss-w-brand-accent-light, #17936a); --ss-w-cta: var(--ss-w-brand-cta-light, #f5a623); --ss-w-cta-ink: #1b1300;
|
|
19409
19527
|
--ss-w-pill: var(--ss-w-pill-light, color-mix(in srgb, var(--ss-w-accent) 72%, #000)); --ss-w-on-accent: var(--ss-w-on-pill-light, #fff);
|
|
19410
|
-
--ss-w-ink: #14181d; --ss-w-faint: #6b7580;
|
|
19411
|
-
--ss-w-line: #e4e8ec; --ss-w-panel: #ffffff; --ss-w-bubble: #f3f5f7; --ss-w-nav: #0e1622;
|
|
19528
|
+
--ss-w-ink: var(--ss-w-brand-ink-light, #14181d); --ss-w-faint: var(--ss-w-brand-faint-light, #6b7580);
|
|
19529
|
+
--ss-w-line: var(--ss-w-brand-line-light, #e4e8ec); --ss-w-panel: var(--ss-w-brand-surface-light, #ffffff); --ss-w-bubble: var(--ss-w-brand-bubble-light, #f3f5f7); --ss-w-nav: #0e1622;
|
|
19412
19530
|
--ss-w-home: #3a63a8; --ss-w-away: #c8102e; --ss-w-track: #e9edf1;
|
|
19413
19531
|
--ss-w-correct: #1f9d55; --ss-w-wrong: #b9bbc2;
|
|
19414
19532
|
}
|
|
@@ -22292,13 +22410,15 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
22292
22410
|
// src/StatsWidget.tsx
|
|
22293
22411
|
var import_jsx_runtime164 = require("react/jsx-runtime");
|
|
22294
22412
|
var NO_OWNER = {};
|
|
22295
|
-
function buildClient(props) {
|
|
22413
|
+
function buildClient(props, onUnavailable) {
|
|
22296
22414
|
try {
|
|
22297
22415
|
if ("client" in props && props.client) {
|
|
22298
22416
|
return { client: props.client, conversation: props.client.conversation() };
|
|
22299
22417
|
}
|
|
22300
22418
|
const cfg = props.config;
|
|
22301
|
-
const
|
|
22419
|
+
const options = toClientOptions(cfg);
|
|
22420
|
+
const base = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
22421
|
+
const client = new import_widget_sdk39.StatsWidgetClient({ ...options, fetch: (0, import_widget_sdk39.observingFetch)(base, onUnavailable) });
|
|
22302
22422
|
return { client, conversation: client.conversation(toUserContext(cfg)) };
|
|
22303
22423
|
} catch (err) {
|
|
22304
22424
|
console.error("[StatsWidget] failed to initialize:", err instanceof Error ? err.message : err);
|
|
@@ -22316,7 +22436,14 @@ function injectStyles(root) {
|
|
|
22316
22436
|
function StatsWidget(props) {
|
|
22317
22437
|
const injectedClient = "client" in props ? props.client : void 0;
|
|
22318
22438
|
const cfg = props.config;
|
|
22319
|
-
const
|
|
22439
|
+
const onUnavailableRef = (0, import_react123.useRef)(cfg?.onUnavailable);
|
|
22440
|
+
onUnavailableRef.current = cfg?.onUnavailable;
|
|
22441
|
+
const built = (0, import_react123.useMemo)(() => buildClient(props, (reason) => {
|
|
22442
|
+
try {
|
|
22443
|
+
onUnavailableRef.current?.(reason);
|
|
22444
|
+
} catch {
|
|
22445
|
+
}
|
|
22446
|
+
}), [injectedClient, cfg?.operatorId, cfg?.publicKey, cfg?.baseUrl, cfg?.userContext?.operatorUserId, cfg?.userContext?.anonymousUserId]);
|
|
22320
22447
|
const trackingRef = (0, import_react123.useRef)({ envelope: { operatorId: "", widgetVersion: WIDGET_REACT_VERSION } });
|
|
22321
22448
|
const track = (0, import_react123.useMemo)(() => createTracker(() => trackingRef.current), []);
|
|
22322
22449
|
const eventTextRef = (0, import_react123.useRef)(false);
|
|
@@ -22343,7 +22470,7 @@ function StatsWidget(props) {
|
|
|
22343
22470
|
}, []);
|
|
22344
22471
|
const language = injectedClient ? void 0 : hostTag(cfg);
|
|
22345
22472
|
const threadLanguage = familyOf(language);
|
|
22346
|
-
const convStorageKey = `ss-w-conv:${cfg?.operatorId ?? ""}:${cfg?.userContext?.operatorUserId ?? "anon"}${threadLanguage ? `:lang=${threadLanguage}` : ""}`;
|
|
22473
|
+
const convStorageKey = `ss-w-conv:${cfg?.operatorId ?? ""}:${cfg?.userContext?.operatorUserId ?? "anon"}${cfg?.userContext?.anonymousUserId ? `:a=${cfg.userContext.anonymousUserId}` : ""}${threadLanguage ? `:lang=${threadLanguage}` : ""}`;
|
|
22347
22474
|
const sportScope = (0, import_react123.useMemo)(
|
|
22348
22475
|
() => ({ operatorId: cfg?.operatorId ?? "", operatorUserId: cfg?.userContext?.operatorUserId, anonymousUserId: cfg?.userContext?.anonymousUserId }),
|
|
22349
22476
|
[cfg?.operatorId, cfg?.userContext?.operatorUserId, cfg?.userContext?.anonymousUserId]
|
|
@@ -22585,8 +22712,13 @@ function StatsWidget(props) {
|
|
|
22585
22712
|
const bubblePrice = !stringsPending && controller.state.popupText && bubble?.price && bubble.matchId ? { matchId: bubble.matchId, price: bubble.price, sport: bubble.sport } : null;
|
|
22586
22713
|
const bubbleGame = !stringsPending && controller.state.popupText && bubble?.game ? instantMs(bubble.startsAtUtc) === null ? bubble.game : ui.v2GameLine(bubble.game, bubble.startsAtUtc) : void 0;
|
|
22587
22714
|
const bubbleCta = controller.state.popupText ? controller.state.greetingBubble?.cta ?? null : null;
|
|
22715
|
+
const onTeaserRef = (0, import_react123.useRef)(cfg?.onTeaser);
|
|
22716
|
+
onTeaserRef.current = cfg?.onTeaser;
|
|
22717
|
+
const wantsTeaser = cfg?.launcher === false || cfg?.onTeaser !== void 0;
|
|
22718
|
+
const webBinding = (0, import_react123.useMemo)(() => wantsTeaser ? webTeaserBinding(props.host, (teaser2) => onTeaserRef.current?.(teaser2), cfg?.launcher === false) : void 0, [wantsTeaser, props.host, cfg?.launcher]);
|
|
22719
|
+
const hostDrawsLauncher = props.mobile !== void 0 || cfg?.launcher === false;
|
|
22588
22720
|
const mobile = useMobileBinding({
|
|
22589
|
-
binding: props.mobile,
|
|
22721
|
+
binding: props.mobile ?? webBinding,
|
|
22590
22722
|
panelOpen,
|
|
22591
22723
|
popupText: controller.state.popupText,
|
|
22592
22724
|
cta: bubbleCta,
|
|
@@ -22603,10 +22735,10 @@ function StatsWidget(props) {
|
|
|
22603
22735
|
close: controller.close,
|
|
22604
22736
|
dismissPopup: () => dismissPopupRef.current()
|
|
22605
22737
|
});
|
|
22606
|
-
const dismissPopup = usePopupTelemetry(logger, panelOpen, controller.state.popupText, controller.dismissPopup, mobile.confirmedShown);
|
|
22738
|
+
const dismissPopup = usePopupTelemetry(logger, panelOpen, controller.state.popupText, controller.dismissPopup, hostDrawsLauncher ? mobile.confirmedShown : void 0);
|
|
22607
22739
|
dismissPopupRef.current = dismissPopup;
|
|
22608
22740
|
const greetingMeta = latestGreetingMeta(controller.state.messages);
|
|
22609
|
-
useBubbleGreetingShown(logger, logger ?? NO_OWNER, controller.state.popupText, greetingMeta, mobile.confirmedShown);
|
|
22741
|
+
useBubbleGreetingShown(logger, logger ?? NO_OWNER, controller.state.popupText, greetingMeta, hostDrawsLauncher ? mobile.confirmedShown : void 0);
|
|
22610
22742
|
const [highlight, setHighlight] = (0, import_react123.useState)(null);
|
|
22611
22743
|
const clearHighlight = (0, import_react123.useCallback)(() => setHighlight(null), []);
|
|
22612
22744
|
(0, import_react123.useEffect)(() => {
|
|
@@ -22732,10 +22864,10 @@ function StatsWidget(props) {
|
|
|
22732
22864
|
favouritesEnabled: favouritesEnabled && clubFixturesResult.tabReady && !clubFixturesResult.enabled,
|
|
22733
22865
|
favourites: { controller: favourites, sport: favSport, sports: favSports, onSportChange: setFavSportPick, open: favouritesOpen, onOpenChange: setFavouritesOpen },
|
|
22734
22866
|
builder: { options: builderOptions, sport: builderSport, onSportChange: setBuilderSportPick, onCoolOff: onBuilderCoolOff, tabs: monitor },
|
|
22735
|
-
onCloseRequested: mobile.onCloseRequested,
|
|
22736
|
-
onRegisterBack: mobile.onRegisterBack
|
|
22867
|
+
onCloseRequested: props.mobile ? mobile.onCloseRequested : void 0,
|
|
22868
|
+
onRegisterBack: props.mobile ? mobile.onRegisterBack : void 0
|
|
22737
22869
|
}
|
|
22738
|
-
) }) }) :
|
|
22870
|
+
) }) }) : hostDrawsLauncher ? bubblePrice && mobile.onRegisterPrice && mobile.onPriceResult && mobile.priceInFlight ? /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
|
|
22739
22871
|
MobileBubblePrice,
|
|
22740
22872
|
{
|
|
22741
22873
|
matchId: bubblePrice.matchId,
|