@thg-agentic/hyper-personalisation-web 3.17.1 → 3.18.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @thg-agentic/hyper-personalisation-web
2
2
 
3
3
  The browser SDK for THG Hyper-Personalisation, a customer data platform. It implements the event
4
- specification (spec 1.6, stamped on every event as `context.spec.version`) for any storefront: it
4
+ specification (spec 1.10, stamped on every event as `context.spec.version`) for any storefront: it
5
5
  sends events in the Segment wire format, applies consent strictly whichever CMP the site uses, reads
6
6
  the GA4 `dataLayer` the site already pushes to, and has no runtime dependencies.
7
7
 
@@ -37,8 +37,8 @@ const hp = await bootstrap(
37
37
  organisation, the property and test or live, so there is no host, property or switch to set per
38
38
  environment, as with Stripe's or LaunchDarkly's keys. `apiHost` is optional, only for a first-party
39
39
  proxy (a bare host or an `https://` origin); without it the SDK uses the HP API
40
- (`DEFAULT_API_HOST`; in 3.17 an interim nonprod host for test keys only, see
41
- [Default host](#default-host-until-production-is-live)). Everything tenant-level comes from
40
+ (`DEFAULT_API_HOST`, `https://hp.thgingenuity.com` since 3.18, for test and live keys alike; see
41
+ [Default host](#default-host-by-release)). Everything tenant-level comes from
42
42
  `GET {apiHost}/v1/projects/{writeKey}/settings`, so switching a site on or off, or changing what it
43
43
  collects, is a settings change and never a deploy:
44
44
 
@@ -51,7 +51,9 @@ collects, is a settings change and never a deploy:
51
51
  | `queryParamAllowlist` | Query parameters kept on page URLs (plus campaign parameters). |
52
52
  | `anonymousId` | Where device ids come from, chosen per source in the console (since 3.6): `{ source: 'site_cookie', cookie }` or `{ source: 'hp_cookie' }`. See [Device ids](#device-ids). |
53
53
  | `apiHost` | Where events go, when not the host the settings came from. |
54
- | `plan.track` | Segment's tracking plan: an event with `enabled: false` is dropped at the source. |
54
+ | `plan.track` | Segment's tracking plan: an event with `enabled: false` is dropped at the source. The console's blocked events arrive here. |
55
+ | `sampleRate` | The share of visitors events are sent for, by a hash of the anonymous id (since 3.18). Absent: 1. |
56
+ | `debug` | `{ enabled, tokenSha256 }`: console logging for everyone, or for a session opened with `?hp_debug=<token>` whose SHA-256 is `tokenSha256` (since 3.18). `?hp_debug=` ends it. |
55
57
 
56
58
  **The page configures only what the page knows** (the second argument):
57
59
 
@@ -68,7 +70,7 @@ collects, is a settings change and never a deploy:
68
70
  | `propertyId` | Only for a key scoped to several properties, whose settings name none. |
69
71
  | `consentCookieDomain` | `Domain` for the consent cookie, e.g. `.acme.com` to share it with checkout. |
70
72
  | `storageNames` | Rename what the SDK stores; see [Storage](#storage). |
71
- | `debug` | Log every event and delivery problem. |
73
+ | `debug` | Log every event and delivery problem. Also on when the settings' `debug` says so. |
72
74
  | `settings` | Development and tests only: use this settings response, never fetch or cache one. |
73
75
  | `extend` | `createAnalytics` options that are functions, such as `getRecommendations` or `getExtensions`. |
74
76
 
@@ -79,14 +81,15 @@ What `bootstrap` does:
79
81
  every problem. It never rejects, and a second call on the same page returns the first client.
80
82
  - **Settings.** The last good answer is cached in `localStorage`, only once analytics is granted,
81
83
  and forgotten on a refusal. A page with a cache starts from it at once and asks the API again for
82
- the next page; a first visit waits for the API (which answers `Cache-Control: max-age=60,
83
- stale-while-revalidate=600`). A key the API switches off clears the cache, so the next page is
84
+ the next page; a first visit waits for the API (which answers `Cache-Control: max-age=10`
85
+ and an `ETag`, so the browser revalidates for a `304`). A key the API switches off clears the cache, so the next page is
84
86
  off too.
85
87
  - **Consent**, identity, one page view, the dataLayer bridge and a once-per-session `identify`, as
86
88
  configured.
87
89
  - **Never waited for.** Call `hp` (`@thg-agentic/hyper-personalisation-web/hp`) from anywhere, at
88
90
  any time, and never await or flush it: calls made before the client starts wait, each with the
89
- messageId and time it was made at, and are sent in order once it has. A page that navigates
91
+ messageId and time it was made at, and are sent in order once it has. The page view is stamped
92
+ when the page was navigated to, so none of them precedes it (3.18). A page that navigates
90
93
  first (a sign-in that redirects at once) carries them in sessionStorage, and the next page's
91
94
  `bootstrap` sends them once, before its own page view (since 3.9). So does a page whose settings
92
95
  request never answered: the API down, or the request cancelled by the navigation (3.9.1). The carry is a device write,
@@ -193,10 +196,11 @@ and `productAdded` (your search engine's id for the result set, such as Algolia'
193
196
  | `onConsentStatus` | none | Called with the gate's status: `granted`, `denied` or `unknown` (timed out). |
194
197
  | `storageNames` | `thg_hp_*` | Rename what the SDK stores; see [Storage](#storage). |
195
198
  | `plan` | none | A Segment tracking plan, `{ track: { [event]: { enabled } } }`; `__default` covers unlisted events. |
199
+ | `sampleRate` | `1` | The share of visitors to send for, by a hash of the anonymous id salted `hp_sample`; a visitor with no anonymous id is sent for. A consent withdrawal is always sent. Since 3.18. |
196
200
  | `queryParamAllowlist` | none | Keep only these query params (plus campaign params) in `context.page`. Patterns are anchored and case-insensitive. |
197
201
  | `queryParamBlocklist` | `[]` | Strip these params. Ignored when an allowlist is given. |
198
202
  | `sensitiveParamAllowlist` | `[]` | Whatever else is configured, a param is always dropped from every reported URL when its name contains `email`, `token`, `password`, `secret`, `auth`, `session`, `phone`, `address`, `card`, `customerid` and the like (see `SENSITIVE_PARAM_FRAGMENTS` in `src/context.js`), or when its value is an email address or a card-length number — campaign params and the referrer included. This exempts names from the first rule, for a false positive such as an `author` filter; nothing exempts a value. |
199
- | `getAnonymousId`, `getUserId`, `getSessionId`, `getRenderId` | none | Identity accessors. Without `getSessionId` the SDK keeps its own session (see [Session ids](#session-ids)); without `hp_cookie` it never mints a device id. |
203
+ | `getAnonymousId`, `getUserId`, `getSessionId`, `getRenderId` | none | Identity accessors. Without `getSessionId` the SDK keeps its own session (see [Session ids](#session-ids)); a missing or empty device id gives way to the SDK's own (see [Device ids](#device-ids)). |
200
204
  | `getExperiments`, `getAudiences`, `getDecisions`, `getRecommendations`, `getExtensions` | none | Read per event into the matching `context` field. Without `getDecisions`, `context.decisions` is what `recordExposure` last recorded per slot. |
201
205
  | `pageType` | `null` | `context.page.type` before the first `page()` call. |
202
206
  | `onEvent` | none | Observer for every event that will be sent. |
@@ -361,6 +365,19 @@ and put nothing in force: the trader is not a shopper, so must neither train a s
361
365
  readout. Every other event is sent as usual. `?hp_preview=` with no value ends the preview. The
362
366
  SDK never checks the token: serving does, and ignores one that has expired.
363
367
 
368
+ ### Visit traits
369
+
370
+ A session audience's rules name fields the SDK keeps for the visit, from the events it sends:
371
+ `productViews`, `listViews`, `cartAdds`, `searches`, `browseViews.<path>`, `browseShare.<path>`,
372
+ `categoryViews.<path>`, `categoryShare.<path>` and, since 3.18, `basketValue`. A field this build
373
+ does not know fails its rule closed.
374
+
375
+ `basketValue` is the `value` of the last `cartUpdated` (Cart Updated), in that event's currency:
376
+ the basket as your platform priced it. It is never summed from `productAdded` lines, whose prices
377
+ can include tax where `value` does not. It is `null`, so every rule on it fails, until the visit
378
+ sends a Cart Updated, and again after one without a `value`. Send `cartUpdated` after every confirmed basket change, as the spec asks, or
379
+ a basket audience goes stale.
380
+
364
381
  ### Audiences only some integrations may target
365
382
 
366
383
  Since 3.8, only audiences marked Targetable in the console are membership. Pass the membership
@@ -378,7 +395,8 @@ them, so `context.audiences` and exposures carry targetable audiences only. Befo
378
395
  audience matches nobody, and a shipped untargetable visit audience the visitor meets may be reported
379
396
  as membership. Every other audience resolves as it did.
380
397
 
381
- Social proof has a client of its own, which batches, caches and never throws:
398
+ Social proof has a client of its own, which batches and caches, and never throws once created
399
+ (creating it without a `writeKey` or with an invalid `apiHost` throws):
382
400
 
383
401
  ```js
384
402
  const proof = createSocialProof({ writeKey, getConsent: () => hp.consent });
@@ -482,6 +500,22 @@ cookie with `storageNames.consent` gets the same name read back by `"forwarded"`
482
500
  pass the same `storageNames`, or passes `forwardedConsent({ name })` directly. No cookie, or no analytics answer in it,
483
501
  means not answered, and strict mode then drops the events.
484
502
 
503
+ A checkout on **another registrable domain** never receives that cookie. Carry it in the checkout
504
+ handoff your servers already make:
505
+
506
+ 1. The storefront's server reads `thg_hp_consent` from the shopper's request and puts it on the
507
+ checkout session it creates.
508
+ 2. On every page it renders, checkout's server sets `thg_hp_consent_handoff` on its own host
509
+ from the session. The value is `formatConsentCookie(parseConsentCookie(value))` (from
510
+ `@thg-agentic/hyper-personalisation-web/consent`), so an unreadable value is unknown, never a
511
+ grant. The cookie is not `HttpOnly`. With no value it deletes the cookie.
512
+ 3. The checkout page boots with `storageNames: { consent: 'thg_hp_consent_handoff' }` and
513
+ `"forwarded"`. Use a name of its own: a checkout host that also serves a storefront on its
514
+ own domain sees that storefront's `thg_hp_consent` first, and a delete cannot remove it.
515
+
516
+ Hand the device cookie over the same way if checkout's events should land on the storefront's
517
+ visitor. Never put the value on the checkout URL: it would end up in access logs and referrers.
518
+
485
519
  ## GA4 dataLayer
486
520
 
487
521
  ```js
@@ -630,8 +664,11 @@ delivery differs.
630
664
  removed when the ingest accepts it (or rejects it for good), so an outage costs a delay, not the
631
665
  events. The buffer is per tenant and capped at 20 batches and 1 MB, oldest dropped first.
632
666
  - On page unload, sends by `sendBeacon` in chunks that fit.
633
- - Size: the CDN script, which is `bootstrap` with every consent adapter and the dataLayer bridge,
634
- is 13.4 KB gzip (38.4 KB minified). A test fails it past 15 KB.
667
+ - Never throws into the page. An event JSON cannot serialise (a BigInt, a circular object, a
668
+ throwing `toJSON`) is dropped on its own, logged under `debug`, and the queue behind it carries
669
+ on. A `Date` in properties is sent as its ISO string.
670
+ - Size: the CDN script is `bootstrap` with every consent adapter and the dataLayer bridge. A test
671
+ fails it past 90 KB gzip, and the inline snippet past 1 KB; the budget catches a runaway bundle.
635
672
 
636
673
  **analytics-next plugins** (`cdpPlugins` from `./segment`)
637
674
  - For sites already using `@segment/analytics-next`: keep it, and add the spec on top of it.
@@ -687,7 +724,7 @@ to Segment.io after a withdrawal.
687
724
 
688
725
  ## CDN script
689
726
 
690
- For a site without a bundler, `dist/hp.min.js` is `bootstrap` as one script (13.4 KB gzip), and
727
+ For a site without a bundler, `dist/hp.min.js` is `bootstrap` as one script, and
691
728
  `dist/snippet.min.js` is the loader to paste inline in `<head>`, Segment-style: it puts a stub on
692
729
  `window.hp` that queues every call, loads the script asynchronously, and the script drains the
693
730
  queue into the client once the settings have answered.
@@ -732,6 +769,7 @@ SDK per page.
732
769
  | `anonymousId` | `thg_hp_anonymous_id` | cookie, one per browser | Hyper-Personalisation's device id, for a source set to `hp_cookie`; only under a grant (see [Device ids](#device-ids)) |
733
770
  | `session` | `thg_hp_session` | cookie, one per browser | the session id the SDK keeps when you name none, 30 minutes from the last event; only under a grant (3.15, see [Session ids](#session-ids)) |
734
771
  | `preview` | `thg_hp_preview` | session cookie | a trader's preview token from `?hp_preview=` (3.15, see [Preview](#preview)) |
772
+ | `debug` | `thg_hp_debug` | sessionStorage | a developer's debug token from `?hp_debug=` (3.18), checked against the settings on every page |
735
773
  | — | `thg_hp_conformance_page_type` | sessionStorage | the previous page's type, only while the development-only conformance checker runs |
736
774
 
737
775
  Keys are scoped by property because one origin can serve several tenants. The names the SDK used
@@ -742,12 +780,12 @@ moved to the new names once, on the first page that loads 3.x, and deleted. A ba
742
780
  ### Device ids
743
781
 
744
782
  Each web source takes its device ids (`anonymousId`) from one place, chosen in the console and
745
- served in the settings as `hp.anonymousId`. There is never a fallback from one to the other: one
746
- browser with ids from two places would split into two visitors, and nothing could say why.
783
+ served in the settings as `hp.anonymousId`. Since 3.18 an event never leaves without one: when the
784
+ site's id is missing, empty or a placeholder, the SDK's own cookie stands in, as analytics.js does.
747
785
 
748
786
  | `hp.anonymousId` | The device id | |
749
787
  |---|---|---|
750
- | `{ source: 'site_cookie', cookie: 'site_visitor_id' }` | your own first-party cookie, by the name the console gives | read only, never minted; a visitor without it is sent with no `anonymousId` and `identity_trust: 'none'` |
788
+ | `{ source: 'site_cookie', cookie: 'site_visitor_id' }` | your own first-party cookie, by the name the console gives | read only; a visitor without it gets the SDK's `thg_hp_anonymous_id` (3.18; before, no `anonymousId`) |
751
789
  | `{ source: 'site_cookie', cookie: null }` | the cookie you name in `identityCookies.anonymousId` (or return from `getAnonymousId`) | as above. Every web source that existed before the setting is set to this |
752
790
  | `{ source: 'hp_cookie' }` | Hyper-Personalisation's first-party cookie, `thg_hp_anonymous_id` | minted by the SDK; your own device cookie is ignored. The default for a new source |
753
791
  | absent (settings from before 3.6) | as `site_cookie` with `cookie: null` | |
@@ -757,8 +795,9 @@ The `hp_cookie` cookie is one per browser, not per property. It is written with
757
795
  `Max-Age` is 400 days, and it is written again on every page under a grant, so it lasts 400 days
758
796
  from the last visit. With a consent adapter it is never written before analytics is granted: until
759
797
  then the id lives in memory, and in the held store with `holdAcrossPages`, so a redirect keeps it.
760
- A refusal or withdrawal deletes it. Without a consent adapter you have decided the lawful basis
761
- yourself, so it is written at once.
798
+ A refusal or withdrawal deletes it, and the id with it: a later grant, on the same page or another,
799
+ starts a new device, as `analytics.reset()` does in analytics.js (3.18). Without a consent adapter
800
+ you have decided the lawful basis yourself, so it is written at once.
762
801
 
763
802
  Changing a source's choice gives every returning visitor a new device id. A device id 3.5 minted
764
803
  into localStorage (`thg_hp_anonymous_id:<property>`) becomes the cookie's value under a grant, and
@@ -769,9 +808,8 @@ handed the same one.
769
808
  ### Session ids
770
809
 
771
810
  Every event carries `context.session_id`. Name your own session cookie in
772
- `identityCookies.sessionId`, or pass `getSessionId`, and the SDK only reads it: it is then the
773
- only source, even for a visitor who lacks the cookie. Without either, since 3.15, the SDK keeps
774
- its own, as Amplitude and GA4 do: a random UUID in the `thg_hp_session` cookie, ended by 30 minutes
811
+ `identityCookies.sessionId`, or pass `getSessionId`, and the SDK reads it. Without either (since
812
+ 3.15), or while it is missing or empty (since 3.18), the SDK keeps its own, as Amplitude and GA4 do: a random UUID in the `thg_hp_session` cookie, ended by 30 minutes
775
813
  without an event. Its `Max-Age` is 30 minutes and every event writes it again, so it is shared by
776
814
  the site's tabs and ends on its own. It is written with the attributes of the device cookie. With a
777
815
  consent adapter it is never written before analytics is granted (until then the session lives in
@@ -781,24 +819,21 @@ memory), and a refusal deletes it. Before 3.15 such a site sent `session_id: nul
781
819
 
782
820
  The SDK makes requests only to `apiHost` (the settings, and the events unless the settings name
783
821
  another host), so allow it in `connect-src`: `resolveApiHost(apiHost)` is that origin, the HP API
784
- (`DEFAULT_API_HOST`) when you set none. Since 3.17 that is `https://hp.uat.thgingenuity.com`
785
- (`connect-src https://hp.uat.thgingenuity.com`); 3.16 and earlier used a staging host that is
786
- being retired. Allow the CDN host in `script-src` too if you use the script. Call the API host directly rather than through a CDN proxy route: behind a proxy the ingest
822
+ (`DEFAULT_API_HOST`) when you set none. Since 3.18 that is `https://hp.thgingenuity.com`
823
+ (`connect-src https://hp.thgingenuity.com`); 3.17 used HP's nonprod host and 3.16 and earlier a
824
+ staging host that is being retired. Allow the CDN host in `script-src` too if you use the script. Call the API host directly rather than through a CDN proxy route: behind a proxy the ingest
787
825
  would see the CDN's IP and country instead of the shopper's.
788
826
 
789
- ### Default host until production is live
827
+ ### Default host by release
790
828
 
791
829
  | Release | `DEFAULT_API_HOST` | For |
792
830
  |---|---|---|
793
831
  | 3.12 to 3.16 | A staging host | Being retired. Upgrade. |
794
- | 3.17 | `https://hp.uat.thgingenuity.com` | Interim: HP's nonprod stack. Test keys, UAT and previews only. |
795
- | A later release | `https://hp.thgingenuity.com` | Production, for test and live keys alike. |
796
-
797
- `hp.uat.thgingenuity.com` is the interim nonprod host, for test keys only, and is not open to
798
- shoppers on the internet: where it cannot be reached the SDK starts, its settings request fails
799
- and it sends nothing, which never breaks the page. Use it for UAT and preview builds with a
800
- `hp_pk_test_…` key. **Do not ship a live key to production on 3.17**: go
801
- live on the release that moves the default to `hp.thgingenuity.com`, whose notes will say so.
832
+ | 3.17 | `https://hp.uat.thgingenuity.com` | Interim: HP's nonprod stack. Test keys only. |
833
+ | 3.18 | `https://hp.thgingenuity.com` | Production, for test and live keys alike. Go live on this. |
834
+
835
+ The key, not the host, keeps test traffic out of live results, so UAT and preview builds use the
836
+ same host with a `hp_pk_test_…` key. Upgrade from 3.17 before shipping a live key.
802
837
 
803
838
  The SDK loads no scripts and sets no cookie except `thg_hp_consent`, once the CMP has answered,
804
839
  and `thg_hp_anonymous_id` for a source set to `hp_cookie`, once analytics is granted.
package/dist/hp.min.js CHANGED
@@ -1,3 +1,3 @@
1
- (()=>{var xt=e=>{throw TypeError(e)};var Xn=(e,t,n)=>t.has(e)||xt("Cannot "+n);var It=(e,t,n)=>t.has(e)?xt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var O=(e,t,n)=>(Xn(e,t,"access private method"),n);var pe=[];for(let e=2;pe.length<64;e++)pe.every(t=>e%t!==0)&&pe.push(e);var At=e=>(e-Math.floor(e))*2**32>>>0,Ho=pe.slice(0,8).map(e=>At(Math.sqrt(e))),Ko=pe.map(e=>At(Math.cbrt(e)));var Ve=(e,t)=>e<<t|e>>>32-t;function vt(e){let t=new Uint32Array((e.length+8>>6)*16+16);e.forEach((s,i)=>{t[i>>2]|=s<<24-i%4*8}),t[e.length>>2]|=128<<24-e.length%4*8,t[t.length-2]=Math.floor(e.length/2**29),t[t.length-1]=e.length*8;let n=Uint32Array.of(1732584193,4023233417,2562383102,271733878,3285377520),r=new Uint32Array(80);for(let s=0;s<t.length;s+=16){for(let f=0;f<80;f++)r[f]=f<16?t[s+f]:Ve(r[f-3]^r[f-8]^r[f-14]^r[f-16],1);let[i,c,l,d,m]=n;for(let f=0;f<80;f++){let g,b;f<20?(g=c&l|~c&d,b=1518500249):f<40?(g=c^l^d,b=1859775393):f<60?(g=c&l|c&d|l&d,b=2400959708):(g=c^l^d,b=3395469782);let A=Ve(i,5)+g+m+b+r[f]|0;[m,d,l,c,i]=[d,l,Ve(c,30),i,A]}[i,c,l,d,m].forEach((f,g)=>{n[g]+=f})}let o=new Uint8Array(20);return n.forEach((s,i)=>{o[i*4]=s>>>24,o[i*4+1]=s>>>16,o[i*4+2]=s>>>8,o[i*4+3]=s}),o}var Yn="e28e8ada-5b76-4209-bba9-79b823a0af75",Zn=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function kt(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),c=>Number.parseInt(c,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let s=vt(o).slice(0,16);s[6]=s[6]&15|80,s[8]=s[8]&63|128;let i=Zn(s);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}var J=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function we(e,t){return J(e,64)??J(t,256)}function Et({sessionId:e,slot:t,arm:n}={}){let r=J(e,256);return!r||!J(t,256)||!J(n,256)?null:kt(Yn,`${r}:${t}:${n}`)}var Qn="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function Ct({sessionId:e,surface:t}={}){let n=J(e,256);return!n||!J(t,64)?null:kt(Qn,`${n}:${t}`)}var er=Array.from({length:11},(e,t)=>t/10);function tr(e,t){if(!e.isIntersecting)return!1;let{intersectionRect:n,boundingClientRect:r,rootBounds:o}=e;if(!n||!r)return!0;let s=n.width*n.height,i=r.width*r.height,c=o?Math.min(i,o.width*o.height):i;return c>0&&s/c>=t}function z(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=e,i=new Map,c=new WeakSet,l=new Set,d=h=>{i.has(h)||i.set(h,setTimeout(()=>{i.delete(h),n(h)&&(f?.unobserve(h),l.delete(h))},o))},m=h=>{clearTimeout(i.get(h)),i.delete(h)},f=typeof IntersectionObserver>"u"?null:new IntersectionObserver(h=>{for(let x of h){let p=x.target;if(!tr(x,r)){l.delete(p),m(p);continue}l.add(p),g()&&d(p)}},{threshold:er}),g=()=>typeof document>"u"||document.visibilityState!=="hidden",b=()=>{if(g())for(let h of l)d(h);else for(let h of l)m(h)};document.addEventListener("visibilitychange",b);let A=()=>{for(let h of s.querySelectorAll(t))c.has(h)||(c.add(h),f?.observe(h))},k=typeof MutationObserver>"u"?null:new MutationObserver(()=>A()),w=()=>{A(),k?.observe(s===document?document.body:s,{childList:!0,subtree:!0})},L=s===document&&!document.body;return L?document.addEventListener("DOMContentLoaded",w,{once:!0}):w(),()=>{L&&document.removeEventListener("DOMContentLoaded",w),document.removeEventListener("visibilitychange",b),f?.disconnect(),k?.disconnect();for(let h of i.values())clearTimeout(h);i.clear(),l.clear()}}function je(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-exposure]",visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=t;return z({selector:n,root:s,visibleRatio:r,dwellMs:o,onViewable(i){let c=i.dataset?.hpExposure?.trim();return c&&e.surfaceViewed({surface:c}),!0}})}var Pt=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function qe(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-list]",tileSelector:r="[data-hp-product]",visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,c=new Set,l=A=>A.closest?.(n)??null,d=A=>{let k=A.dataset.hpList?.trim();return k?{list_id:k,category:A.dataset.hpListCategory?.trim()||null}:null},m=A=>Array.from(A.querySelectorAll(r)).filter(k=>l(k)===A),f=(A,k)=>{try{let w=JSON.parse(A.dataset.hpProduct??"");return!w||typeof w!="object"||!w.product_id?null:{...w,position:w.position??k+1,...w.url?{url:Pt(w.url)}:{},...w.image_url?{image_url:Pt(w.image_url)}:{}}}catch{return null}},g=z({selector:`${n} ${r}`,root:i,visibleRatio:o,dwellMs:s,onViewable(A){let k=l(A);if(!k||k.dataset.hpListView==="manual")return!0;let w=d(k);if(!w||c.has(w.list_id))return!0;let L=new Set,h=m(k).map(f).filter(x=>!x||L.has(x.product_id)?!1:(L.add(x.product_id),!0));return h.length===0||(c.add(w.list_id),e.productListViewed({...w,products:h})),!0}}),b=A=>{let w=A.target?.closest?.("a[href]")?.closest(r);if(!w)return;let L=l(w),h=f(w,L?m(L).indexOf(w):0);h&&e.productClicked({list_id:L?d(L)?.list_id??null:null,products:[h]})};return document.addEventListener("click",b,!0),()=>{document.removeEventListener("click",b,!0),g()}}function T(e,...t){let n=e.dataset??{};for(let r of t){let o=n[r];if(typeof o=="string"&&o.trim()!=="")return o.trim()}return null}function Se(e,...t){let n=T(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function nr(e,t){let n=T(e,"hpPromotion");return n?{promotion_id:n,name:T(e,"hpPromotionName"),creative:T(e,"hpPromotionCreative"),position:T(e,"hpPromotionSlot")??String(t+1)}:null}function Be(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=nr,visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,c=new Set,l=f=>{let g=Array.from(i.querySelectorAll(n)),b=g.indexOf(f);try{return r(f,b<0?g.length:b)}catch{return null}},d=z({selector:n,root:i,visibleRatio:o,dwellMs:s,onViewable(f){let g=l(f);return!g||c.has(g.promotion_id)?!1:(c.add(g.promotion_id),e.promotionViewed(g),!0)}}),m=f=>{let g=f.target;if(!g||typeof g.closest!="function")return;let b=g.closest(n),A=g.closest("a[href]");if(!b||!A||!b.contains(A)&&!A.contains(b))return;let k=l(b);k&&e.promotionClicked({...k,href:A.getAttribute("href")})};return document.addEventListener("click",m,!0),()=>{document.removeEventListener("click",m,!0),d()}}function rr(e){let t=T(e,"hpRecoRequest"),n=T(e,"hpRecoPlacement"),r=T(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=T(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:T(e,"hpRecoRecipe"),algorithm_version:T(e,"hpRecoAlgorithmVersion"),experiment:T(e,"hpRecoExperiment"),variant:T(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:Se(e,"hpRecoBucket"),assignment_unit_kind:T(e,"hpRecoUnitKind"),candidate_set_fingerprint:T(e,"hpRecoFingerprint"),candidate_set_size:Se(e,"hpRecoCandidates"),ranked_by:T(e,"hpRecoRankedBy"),served_at:T(e,"hpRecoServedAt")}}function or(e,t){let n=T(e,"hpRecoProduct");if(!n)return null;let r=T(e,"hpRecoPrice");return{product_id:n,sku:T(e,"hpRecoSku"),name:T(e,"hpRecoName"),brand:T(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:Se(e,"hpRecoPosition")??t+1}}function Fe(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-reco-request]",tileSelector:r="[data-hp-reco-product]",resolveRail:o=rr,resolveTile:s=or,visibleRatio:i=.5,dwellMs:c=1e3,root:l=document}=t,d=new Set,m=new Map,f=new Map,g=(h,...x)=>{try{return h(...x)}catch{return null}},b=h=>typeof h.closest=="function"?h.closest(n):null,A=h=>Array.from(h.querySelectorAll(r)),k=(h,x)=>{if(f.delete(x.recommendation_request_id),d.has(x.recommendation_request_id))return;let p=A(h).map((S,P)=>g(s,S,P)).filter(S=>S?.product_id);if(p.length===0)return;d.add(x.recommendation_request_id);let _=[...m.get(x.recommendation_request_id)?.values()??[]].sort((S,P)=>S.position-P.position);e.recommendationsViewed({...x,products:p,viewable:_})},w=z({selector:`${n} ${r}`,root:l,visibleRatio:i,dwellMs:c,onViewable(h){let x=b(h);if(!x)return!0;let p=g(o,x);if(!p)return!0;let _=p.recommendation_request_id,S=g(s,h,A(x).indexOf(h));if(S?.product_id){m.has(_)||m.set(_,new Map);let P=m.get(_);P.has(S.position)||P.set(S.position,{position:S.position,product_id:S.product_id,viewable_at:new Date().toISOString()})}return!d.has(_)&&!f.has(_)&&f.set(_,setTimeout(()=>k(x,p),0)),!0}}),L=h=>{let x=h.target;if(!x||typeof x.closest!="function")return;let p=x.closest(r);if(!p)return;let _=x.closest("[data-hp-reco-interaction]"),S=x.closest("a[href]"),P=S&&(p.contains(S)||S.contains(p));if(!(_&&p.contains(_))&&!P)return;let M=b(p);if(!M)return;let B=g(o,M);if(!B)return;let y=g(s,p,A(M).indexOf(p));if(!y?.product_id)return;let V=B.recommendation_request_id;d.has(V)||(clearTimeout(f.get(V)),k(M,B)),e.productClicked({recommendation_request_id:B.recommendation_request_id,interaction:T(_??p,"hpRecoInteraction")??"navigate",products:[y]})};return document.addEventListener("click",L,!0),()=>{document.removeEventListener("click",L,!0);for(let h of f.values())clearTimeout(h);f.clear(),w()}}var ne=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),sr=new Set(["products"]),Lt=e=>e==null;function He(e){if(Array.isArray(e))return e.map(He);if(e===null||typeof e!="object")return e;let t={};for(let[n,r]of Object.entries(e))Lt(r)||(t[n]=He(r));return t}function Ke(e){if(!e)return e;let t=He(e);for(let n of sr)n in e&&Lt(e[n])&&(t[n]=e[n]);return t}function Ot(){try{let e=performance.getEntriesByType("navigation")[0];return e?["navigate","reload","back_forward","prerender"].includes(e.type)?e.type:"navigate":null}catch{return null}}var ir=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function q(e){if(e==null)return null;let t=String(e).trim();return ir.has(t.toLowerCase())?null:t}function re(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function R(e){if(typeof document>"u")return null;try{let t=document.cookie.split(";").map(n=>n.trim()).find(n=>n.startsWith(`${e}=`));return t&&decodeURIComponent(t.slice(e.length+1))||null}catch{return null}}var ar={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},cr=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,ur=/\d(?:[ -]?\d){12,}/,lr=new Set(["gclid","fbclid","ttclid","msclkid"]);function Tt(e,t=""){if(typeof e!="string"||e==="")return!1;let n=[e];try{let o=decodeURIComponent(e.replace(/\+/g," "));o!==e&&n.push(o)}catch{}let r=!lr.has(String(t).toLowerCase());return n.some(o=>cr.test(o)||r&&ur.test(o))}function dr(e){if(!e)return null;let t=new URLSearchParams(e),n={},r={utm_source:"source",utm_medium:"medium",utm_campaign:"name",utm_term:"term",utm_content:"content"};for(let[o,s]of[...Object.entries(r),...Object.entries(ar)]){let i=t.get(o);i&&!Tt(i,o)&&(n[s]=i)}return Object.keys(n).length?n:null}var fr=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],pr=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],mr=["tel","uid","dob"],hr=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],gr=new Set(fr.map(e=>e.toLowerCase()));function yr(e){let t=String(e).toLowerCase();if(gr.has(t))return!0;let n=t.replace(/[-_.]/g,"");return pr.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>mr.includes(o))}function Ge(e){return(e??[]).map(t=>{try{return new RegExp(`^${t}$`,"i")}catch{return{test:n=>n.toLowerCase()===String(t).toLowerCase()}}})}function Rt(e,t={}){if(!e)return null;try{let n=new URLSearchParams(e),r=t.queryParamAllowlist?Ge([...t.queryParamAllowlist,...hr]):null,o=Ge(t.queryParamBlocklist),s=Ge(t.sensitiveParamAllowlist);for(let c of new Set(n.keys()))(yr(c)&&!s.some(d=>d.test(c))||n.getAll(c).some(d=>Tt(d,c))||(r?!r.some(d=>d.test(c)):o.some(d=>d.test(c))))&&n.delete(c);let i=n.toString();return i?`?${i}`:""}catch{return""}}function wr(e,t,n={}){if(!e)return null;try{let r=new URL(e);return t&&r.origin===t?r.origin+r.pathname+(Rt(r.search,n)??""):r.origin+r.pathname}catch{return null}}function ze(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Nt(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function Sr(e){if(typeof e!="string")return null;let t=e.trim().replace(/_/g,"-");if(!/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(t))return null;try{return Intl.getCanonicalLocales(t)[0]}catch{return null}}function $(e,t){if(typeof e=="function")try{let n=e();if(n!=null)return n}catch{}return t}function _r(e){return{property_id:String(e.propertyId),channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function br(e){let t=typeof window<"u"?window.location:null,n=t?Rt(t.search,e):null;return{url:t?t.origin+t.pathname+(n??""):e.pageUrl??null,path:t?t.pathname:e.pagePath??null,search:n??null,referrer:typeof document<"u"?wr(document.referrer,t?.origin,e):null,title:typeof document<"u"&&document.title||null,type:e.pageType??null}}function Dt(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:"1.8"},source:_r(e),session_id:$(e.getSessionId,null),render_id:$(e.getRenderId,null),identity_trust:q($(e.getAnonymousId,null))?"device":"none",page:br(e),campaign:n?dr(n.search):null,device:{user_agent:typeof navigator<"u"?navigator.userAgent:null,type:null,viewport_width:typeof window<"u"?window.innerWidth:null,viewport_height:typeof window<"u"?window.innerHeight:null},currency:ze($(e.getCurrency,e.currency)),locale:Sr($(e.getLocale,e.locale)),timezone:(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return null}})(),country:Nt(e.country),ship_to_country:Nt($(e.getShipToCountry,e.shipToCountry)),ip:null,bot:null,consent:e.getConsent?.()??null,experiments:$(e.getExperiments,null),audiences:$(e.getAudiences,null),decisions:$(e.getDecisions,null),recommendations:$(e.getRecommendations,null),extensions:$(e.getExtensions,null)};return Mt(r,t)}function Mt(e,t){if(!t)return e;let n={...e};for(let[r,o]of Object.entries(t))o&&typeof o=="object"&&!Array.isArray(o)&&e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?n[r]=Mt(e[r],o):o!==void 0&&(n[r]=o);return n}var Z=Object.freeze({consent:"thg_hp_consent",retry:"thg_hp_retry",sessionSignals:"thg_hp_session_signals",identified:"thg_hp_identified",previousPage:"thg_hp_prev_page",decisions:"thg_hp_decisions",settings:"thg_hp_settings",held:"thg_hp_held",carried:"thg_hp_carried",recommendationContext:"thg_hp_recommendation_context",anonymousId:"thg_hp_anonymous_id",session:"thg_hp_session",preview:"thg_hp_preview"}),xr={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},We={...Z},$t=!1;function _e(e){let t={...Z};for(let[n,r]of Object.entries(e??{})){if(!(n in Z))throw new Error(`storageNames: unknown kind "${n}"`);if(typeof r!="string"||!/^[\w.-]+$/.test(r))throw new Error(`storageNames.${n} must be a non-empty cookie-safe name`);t[n]=r}We=t}function N(e){return We[e]}var Ir="_",Ut=e=>e==null||e===""?Ir:String(e);function j(e,t,n){let r=`${e}:${Ut(t)}`;return n==null||n===""?r:`${r}:${n}`}function Vt(e,t){return`${e}:${Ut(t)}:`}function be(){if(!$t){$t=!0;for(let e of[()=>localStorage,()=>sessionStorage]){let t;try{if(t=e(),!t)continue;for(let n of Object.keys(t))for(let[r,o]of Object.entries(xr)){if(n!==o&&!n.startsWith(`${o}:`))continue;let s=We[r]+n.slice(o.length);t.getItem(s)===null&&t.setItem(s,t.getItem(n)),t.removeItem(n)}}catch{}}}}var Xe=1800*1e3,xe=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},Je=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function jt(e,t=()=>Date.now()){return{read(){try{let n=xe()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>Xe?(r&&xe()?.removeItem(e),{items:[],anonymousId:null}):{items:Array.isArray(r.items)?r.items:[],anonymousId:typeof r.anonymousId=="string"?r.anonymousId:null}}catch{return{items:[],anonymousId:null}}},write(n,r=null){try{n.length===0?xe()?.removeItem(e):xe()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var Ar=400*24*60*60;function W(e,t,n,r){if(typeof document>"u")return!1;try{let o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",s=r?`; Domain=${r}`:"",i=n===null?"":`; Max-Age=${n}`;return document.cookie=`${e}=${encodeURIComponent(t)}; Path=/${i}; SameSite=Lax`+s+o,!0}catch{return!1}}function vr({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:s,carried:i=null}){let c=null;try{c=Je()?.getItem(n)||null}catch{c=null}let l=r(e)??c??i,d=!1,m=()=>{if(!(d||l===null||!s())&&(d=W(e,l,Ar,t),!(!d||c===null)))try{Je()?.removeItem(n),c=null}catch{}};return{get(){return l??(l=o()),m(),l},peek:()=>l,persist:m,forget(){W(e,"",0,t),d=!1;try{Je()?.removeItem(n)}catch{}c=null}}}function qt(e,{carried:t,mayStore:n}){let r=e.anonymousIdSource;if(r?.source==="site_cookie"&&r.cookie){let i=r.cookie;return e.getAnonymousId=()=>R(i),null}if(r?.source!=="hp_cookie")return null;let o=N("anonymousId"),s=vr({name:o,domain:e.consentCookieDomain??null,legacyKey:j(o,e.propertyId),read:R,mint:re,mayStore:n,carried:t});return e.getAnonymousId=()=>s.get(),s}var kr=200;function Bt(e,t,n=()=>Date.now()){let r=()=>j(N("carried"),e),o=!1;function s(){try{let i=JSON.parse(sessionStorage.getItem(r())??"null");return!i||!(n()-i.savedAt<=Xe)?[]:Array.isArray(i.calls)?i.calls:[]}catch{return[]}}return{take(){let i=s();try{sessionStorage.removeItem(r())}catch{}return i},save(i){try{return o||!t()?!1:(sessionStorage.setItem(r(),JSON.stringify({savedAt:n(),calls:[...s(),...i].slice(-kr)})),!0)}catch{return!1}},close(){o=!0}}}var ks=Z.consent,Ie=Object.freeze({visitor:"visitor",host:"host"}),Ft=()=>({basis:Ie.host}),Er="hp-consent",Q=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],Ht={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},K=()=>typeof window<"u",Kt=()=>K()&&typeof window.cookieStore?.addEventListener=="function",Cr=e=>e===!0?!0:e===!1?!1:null;function oe(e){if(!e||typeof e!="object")return null;let t={};for(let n of Q)t[n]=Cr(e[n]);return t}function Ze(e,t){return!e||!t?e===t:Q.every(n=>e[n]===t[n])}function Qe(e){if(!e)return"";let t=[];for(let n of Q){let r=e[n];(r===!0||r===!1)&&t.push(`${Ht[n]}=${r?1:0}`)}return t.join("&")}function Gt(e){return{[Er]:Qe(oe(e))}}function me(e){let t=oe({});if(e==null)return t;let n=String(e).trim();if(n.length>=2&&n.startsWith('"')&&n.endsWith('"')&&(n=n.slice(1,-1)),n.includes("%"))try{n=decodeURIComponent(n.replace(/\+/g," "))}catch{return t}let r=Object.fromEntries(Object.entries(Ht).map(([s,i])=>[i,s])),o=new Set;for(let s of n.split("&")){let i=s.indexOf("=");if(i<=0)continue;let c=r[s.slice(0,i).trim()],l={1:!0,0:!1}[s.slice(i+1).trim()]??null;!c||l===null||o.has(c)||(t[c]===null?t[c]=l:t[c]!==l&&(t[c]=null,o.add(c)))}return t}function et(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let s of Q)s!=="analytics"&&t[s]!==!0&&(o[s]=null);return o};return{name:e.name,basis:e.basis,read:()=>n(e.read()),subscribe:r=>e.subscribe(o=>r(n(o))),get observesChanges(){return e.observesChanges}}}function tt(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function Ae(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var Pr={analytics:["analytics","measure_content_performance","audience_measurement"],marketing:["marketing","targeting","advertising","select_personalized_ads","create_ads_profile"],personalisation:["personalisation","personalization","select_personalized_content","create_content_profile"]};function Lr(e,t){if(!t?.length)return null;let n=!1;for(let[r,o]of Object.entries(e)){let s=String(o?.id??r).toLowerCase();if(t.some(c=>{let l=String(c).toLowerCase();return s===l||s.startsWith(`${l}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function zt(e={}){let t={...Pr,...e.purposes};function n(){let r=K()?window.Didomi:void 0;if(!r?.getCurrentUserStatus||r.shouldUserStatusBeCollected?.()!==!1||r.isUserStatusPartial?.()===!0)return null;let o=r.getCurrentUserStatus()?.purposes;if(!o||typeof o!="object")return null;let s=i=>Lr(o,t[i]);return tt({analytics:s("analytics"),marketing:s("marketing"),personalisation:s("personalisation")},{ad_user_data:s("ad_user_data"),ad_personalization:s("ad_personalization")})}return{name:"didomi",read:n,observesChanges:!0,subscribe(r){if(!K())return()=>{};let o=Ae(n,r),s={event:"consent.changed",listener:o.notify};return window.didomiEventListeners=window.didomiEventListeners||[],window.didomiEventListeners.push(s),window.didomiOnReady=window.didomiOnReady||[],window.didomiOnReady.push(i=>{o.notify(),(i??window.Didomi)?.on?.("consent.changed",o.notify)}),window.Didomi?.on?.("consent.changed",o.notify),o.stop}}}function Ye(e){let t={};if(!e)return t;for(let n of String(e).split("&")){let r=n.indexOf("=");if(r<=0)continue;let o=n.slice(r+1).replace(/\+/g," ");try{o=decodeURIComponent(o)}catch{}t[n.slice(0,r)]=o}return t}function Wt(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let i=K()?window.OnetrustActiveGroups:void 0;if(typeof i=="string"&&i.length){let d=new Set(i.split(",").map(m=>m.trim()).filter(Boolean));return m=>d.has(m)}let c=Ye(R("OptanonConsent"));if(!c.groups)return null;let l={};for(let d of c.groups.split(",")){let[m,f]=d.split(":");m?.trim()&&(l[m.trim()]=f==="1"?!0:f==="0"?!1:null)}return d=>l[d]??null}function o(){if(R("OptanonAlertBoxClosed"))return!0;try{if(K()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return Number.parseInt(Ye(R("OptanonConsent")).interactionCount,10)>0?!0:n&&K()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function s(){if(!o())return null;let i=r();if(!i)return null;let c=f=>t[f]?i(t[f]):null,l=tt({analytics:c("analytics"),marketing:c("marketing"),personalisation:c("personalisation")},{ad_user_data:c("ad_user_data"),ad_personalization:c("ad_personalization")}),d=Ye(R("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||d.isGpcEnabled==="1")&&(l.marketing=!1,l.ad_user_data=!1,l.ad_personalization=!1),l}return{name:"onetrust",read:s,observesChanges:!0,subscribe(i){if(!K())return()=>{};let c=Ae(s,i),l=!1,d=()=>{l||!window.OneTrust?.OnConsentChanged||(l=!0,window.OneTrust.OnConsentChanged(c.notify))};window.addEventListener("OneTrustGroupsUpdated",c.notify);let m=window.OptanonWrapper;return window.OptanonWrapper=function(...g){try{typeof m=="function"&&m.apply(this,g)}finally{d(),c.notify()}},d(),()=>{c.stop(),window.removeEventListener("OneTrustGroupsUpdated",c.notify)}}}}function Or(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function Jt(e){let{name:t,categories:n,parse:r=Or,refusedValue:o,source:s="native",changeEvent:i="thg_hp_consent_change"}=e??{};if(typeof t!="string"||t==="")throw new Error("cookieConsent: `name` (the cookie your banner writes) is required");if(!n||typeof n.analytics!="string")throw new Error("cookieConsent: `categories.analytics` (the category id that grants analytics) is required");function c(){let l=R(t);if(l==null)return null;let d;if(o!==void 0&&l===o)d=new Set;else try{d=r(l)}catch{d=null}if(!(d instanceof Set))return null;let m=f=>n[f]?d.has(n[f]):null;return tt({analytics:m("analytics"),marketing:m("marketing"),personalisation:m("personalisation")},{ad_user_data:m("ad_user_data"),ad_personalization:m("ad_personalization")})}return{name:s,read:c,get observesChanges(){return Kt()},subscribe(l){if(!K())return()=>{};let d=Ae(c,l),m=f=>{[...f.changed??[],...f.deleted??[]].some(b=>b?.name===t)&&d.notify()};return window.addEventListener(i,d.notify),window.cookieStore?.addEventListener?.("change",m),()=>{d.stop(),window.removeEventListener(i,d.notify),window.cookieStore?.removeEventListener?.("change",m)}}}}function Xt(e={}){let t=e.name??N("consent"),n=()=>{let r=R(t);if(r==null)return null;let o=me(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return Kt()},subscribe(r){if(!K())return()=>{};let o=Ae(n,r),s=i=>{[...i.changed??[],...i.deleted??[]].some(l=>l?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",s),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",s)}}}}function Yt(e){let t=oe(e);return{name:"static",basis:Ie.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function Zt(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function Nr(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return Zt(t);let n=[t,e.item_category2,e.item_category3,e.item_category4,e.item_category5].map(r=>r==null?"":String(r).trim()).filter(Boolean);return Zt(n.join("/"))}var Tr=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function Rr(...e){for(let t of e){if(typeof t=="number"&&Number.isFinite(t))return String(t);if(typeof t=="string"&&t.trim()!=="")return t.trim()}return null}var ve=e=>Rr(e.item_group_id,e.item_id);function Dr(e,t=ve){if(!e)return null;let n=c=>c==null||c===""||Number.isNaN(Number(c))?null:Number(c),r=c=>{let l=n(c);return l==null?null:Math.round(l*1e6)/1e6},o=c=>{let l=r(c);return l!=null&&l>=0?l:null},s=c=>{let l=n(c);return Number.isInteger(l)&&l>=0?l:null},i=Tr;return{product_id:i(t(e)),sku:i(e.item_id),name:i(e.item_name),brand:i(e.item_brand),variant:i(e.item_variant)??i(e.variant),category:Nr(e),price:r(e.price),discount:o(e.discount),quantity:s(e.quantity),coupon:i(e.coupon),position:s(e.index)!=null?s(e.index)+1:null,url:i(e.url)??i(e.item_url)??null,image_url:i(e.image_url)??i(e.image_link)??null,displayed_sku:i(e.displayed_sku)??i(e.displayed_variant_sku)}}function nt(e,t=ve){return(e??[]).map(n=>Dr(n,t)).filter(n=>n?.product_id)}var Mr=1e3,$r={shipping:2,payment:3},Ur=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),D=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},Vr=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},ke=e=>e!==null&&typeof e=="object";function jr(e){return Array.isArray(e.items)?e.items.filter(ke):null}function Qt(e){let t=D(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?Ur.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function qr({ecommerce:e,items:t}){let n=s=>({promotion_id:D(s.promotion_id),name:D(s.promotion_name),creative:D(s.creative_name),position:D(s.creative_slot)}),r=new Set,o=[];for(let s of[n(e),...t.map(n)])!s.promotion_id||r.has(s.promotion_id)||(r.add(s.promotion_id),o.push(s));return o}var en=({ecommerce:e,items:t})=>D(e.item_list_id)??D(e.item_list_name)??D(t[0]?.item_list_id)??D(t[0]?.item_list_name),ee=(e,t)=>t.products?.length?{event:e,properties:t}:null,Br=new Set(["product","products","item","items"]);function Fr({ecommerce:e}){let t=D(e.item_id),n=D(e.content_type)?.toLowerCase();return!t||n&&!Br.has(n)?null:{event:"Product Shared",properties:{share_via:D(e.method),products:[{product_id:t}]}}}function Hr(e){let t=o=>ee("Product List Viewed",{list_id:en(o),products:o.products}),n=o=>{let s=D(o.ecommerce.search_term);return s?{event:"Products Searched",properties:{query:s,...o.products.length?{products:o.products}:{}}}:null},r=o=>s=>s.promotions.map(i=>({event:o,properties:i}));return{view_item:o=>ee("Product Viewed",{currency:o.currency,value:o.value,products:o.products.slice(0,1)}),view_item_list:t,view_search_results:o=>n(o)??t(o),search:n,select_item:o=>ee("Product Clicked",{list_id:en(o),products:o.products.slice(0,1)}),add_to_cart:o=>ee("Product Added",{cart_id:D(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>ee("Product Removed",{cart_id:D(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:D(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:D(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>ee("Checkout Started",{value:o.value,currency:o.currency,coupon:D(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:D(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:D(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>ee("Product Added to Wishlist",{products:o.products}),share:Fr,login:o=>({event:"Signed In",properties:{method:Qt(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:Qt(o.ecommerce.method)}})}}var Kr=e=>e.event;function Gr(e,t){if(!ke(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=ke(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=D(t(e));return n?{name:n,entry:e,ecommerce:ke(e.ecommerce)?e.ecommerce:e}:null}function rt(e){return Array.isArray(e)?`[${e.map(rt).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${rt(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function tn(e,t={}){if(!e||typeof e.track!="function")throw new Error("connectDataLayer: analytics must have a track(event, properties, options) method");let n=t.dataLayer??(typeof window<"u"?window.dataLayer=window.dataLayer||[]:null);if(!Array.isArray(n))return()=>{};let r=Hr({...$r,...t.steps}),o=t.map??{},s=t.eventName??Kr,i=t.productId??ve,c=new Set(["purchase","refund",...t.ignore??[]]),l=t.dedupeMs??Mr,d=new Map,m=!0;function f(p,_,S){if(l<=0)return!1;let P=`${p}|${S??""}|${rt(_)}`,M=Date.now();for(let[B,y]of d)M-y>l&&d.delete(B);return d.has(P)?!0:(d.set(P,M),!1)}let g=null,b=new Set;function A(p,_){if(p!=="Product Viewed")return!1;let S=typeof location>"u"?"":location.pathname;S!==g&&(g=S,b.clear());let P=_.products?.[0]?.product_id;return P?b.has(P)?!0:(b.add(P),!1):!1}function k({event:p,properties:_={}},S){if(!p||f(p,_,S)||A(p,_))return;let P=S?{context:{currency:S}}:void 0;if(p==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(P);return}e.track(p,_,P)}function w(p){let _=t.transform?t.transform(p):p,S=Gr(_,s);if(!S||c.has(S.name))return;let P=Object.hasOwn(o,S.name),M=P?o[S.name]:r[S.name];if(typeof M!="function")return;let B=jr(S.ecommerce),y=B??[],V={...S,items:y,itemsListed:B!==null,products:nt(y,i),currency:ze(S.ecommerce.currency),value:Vr(S.ecommerce.value)};V.promotions=qr(V);let le=P?M(_,{...V,toProducts:F=>nt(F,i)}):M(V);for(let F of[le].flat())F&&k(F,V.currency)}function L(p){if(m)try{w(p)}catch(_){try{t.onError?.(_,p)}catch{}}}for(let p of n.slice())L(p);let h=n.push;function x(...p){let _=h.apply(this,p);for(let S of p)L(S);return _}return n.push=x,()=>{m=!1,n.push===x&&(n.push=h)}}var zr=4320*60*60,Wr=100,Jr=1e3,Xr=2e3,nn=500,Ee=e=>(e?.unref?.(),e);function Yr(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=Q.map(r=>e[r]).filter(r=>r!==null);return n.length&&n.every(Boolean)?"accept_all":n.length&&n.every(r=>!r)?"reject_all":"custom"}function Zr(e,t,n=N("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${Qe(e)}; Path=/; Max-Age=${zr}; SameSite=Lax`+o+r}catch{}}function Qr(e){let t=me(R(e));return Q.some(n=>t[n]!==null)?t:null}function rn(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=N("consent"),release:s,announce:i}=e,c=e.discard??(()=>{}),l="pending",d=null,m=null,f=null,g=null,b=!1,A=null,k=[],w=a=>{l=a,e.onStatus?.(a)};function L(){try{return oe(t.read())}catch{return null}}function h(){m&&clearInterval(m),f&&clearTimeout(f),m=null,f=null}let x=()=>typeof window<"u"&&typeof document<"u",p=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function _(){g&&clearInterval(g),g=null}function S(){b||g||d===null||p()||x()&&document.visibilityState==="hidden"||(g=Ee(setInterval(()=>V(L()),Xr)))}let P=()=>l==="pending"||l==="unknown",M=e.store??null,B=()=>{let a=k.splice(0);M?.write([]);for(let u of a)s(u)},y=()=>{let a=k.splice(0);M?.write([]);for(let u of a)c(u)};function V(a){let u=oe(a);if(!u||u.analytics===null)return;let v=d===null,C=v?Qr(o):d;if(!v&&Ze(C,u))return;h(),d=u,S(),Zr(u,r,o);let E=!Ze(C,u);if(u.analytics){w("granted"),B(),E&&i({action:Yr(u,C),state:u,withdrawal:!1});return}y(),C?.analytics===!0&&i({action:"withdrawn",state:u,withdrawal:!0}),w("denied")}function le(){f=null,l==="pending"&&(w("unknown"),m&&clearInterval(m),m=Ee(setInterval(()=>V(L()),Jr)))}function F(a){P()&&(M||a?.type!=="visibilitychange"&&!a?.persisted&&y())}let de=a=>{document.visibilityState==="hidden"?(_(),F(a)):S()},ge=a=>{_(),F(a)},fe=()=>S();return{get status(){return l},get state(){return d?{...d}:null},stamp(){return d?{...d,source:t.name??null,basis:t.basis??Ie.visitor}:null},admits(){return l==="granted"},hold(a){return!P()||k.length>=nn?(c(a),!1):(k.push(a),M?.write(k),!0)},onHidden:F,start(){b=!1;try{A=t.subscribe?.(a=>V(a))??null}catch(a){e.debug&&console.warn("[hp] consent adapter subscribe failed",a)}x()&&(window.addEventListener("pagehide",ge),window.addEventListener("pageshow",fe),document.addEventListener("visibilitychange",de)),M&&k.length===0&&k.push(...M.read().slice(-nn)),V(L()),!d&&(m=Ee(setInterval(()=>V(L()),Wr)),f=Ee(setTimeout(le,n)))},stop(){b=!0,h(),_(),typeof A=="function"&&A(),x()&&(window.removeEventListener("pagehide",ge),window.removeEventListener("pageshow",fe),document.removeEventListener("visibilitychange",de))}}}var eo=["recommendation","search_rank","banner","offer","layout","copy","price","other"],Ce=e=>typeof e=="string"&&e!=="";function on(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>Ce(t?.slot)&&Ce(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...Ce(r)&&{arm:r},...eo.includes(o)&&{kind:o}}))}function sn({key:e,mayStore:t}){let n,r=()=>{if(n)return n;try{let s=JSON.parse(sessionStorage.getItem(e));n=Array.isArray(s)?s.filter(i=>Ce(i?.slot)):[]}catch{n=[]}return n},o=()=>{try{n?.length&&t()&&sessionStorage.setItem(e,JSON.stringify(n))}catch{}};return{persist:o,current:()=>r().length?n.map(s=>({...s})):null,remember(s){if(!s.length)return;let i=new Set(s.map(c=>c.slot));n=[...r().filter(c=>!i.has(c.slot)),...s],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function to(e){let t=2166136261,n=String(e);for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t^=t>>>16,t=Math.imul(t,2246822507)>>>0,t^=t>>>13,t=Math.imul(t,3266489909)>>>0,t^=t>>>16,t>>>0}function an(e,t,n=1e4){return to(`${t}\0${e}`)%n}function ot(e){let t=o=>Math.min(Math.max(Number(o)||0,0),1),n=t(e.share),r=1-n;return{holdout_share:n,personalised_share:e.ramp==null?r:Math.min(t(e.ramp),r)}}function st(e,t){if(!e||typeof e.salt!="string")return{holdout:!1,bucket:null,group:"personalised"};let n=e.ramp!=null;if(t==null||t==="")return{holdout:!1,bucket:null,group:n?"excluded":"personalised"};let{holdout_share:r,personalised_share:o}=ot(e),s=an(t,e.salt),i=l=>Math.round(l*1e4),c=r>0&&s<i(r)?"holdout":!n||s<i(r+o)?"personalised":"excluded";return{holdout:c==="holdout",bucket:s,group:c}}function cn(e,t){return typeof e!="string"||e===""||t==null||t===""?null:an(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var no="hp_preview",ro=256;function un(e,t=null){if(typeof location>"u")return R(e);let n=null;try{n=new URLSearchParams(location.search).get(no)}catch{n=null}if(n===null)return R(e);let r=n.trim();return r===""||r.length>ro?(W(e,"",0,t),null):(W(e,r,null,t),r)}var oo=40,so=128,io=5,ao=60,dn=e=>typeof e=="string"&&e!==""&&e.length<=so&&!e.includes(","),ln=e=>Array.isArray(e)?e.filter(dn).slice(0,oo):[],co=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,io):[],uo=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>dn(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,ao).map(([t,n])=>`${t}:${Math.floor(n)}`);function it(e){let t={},n={viewed:ln(e?.recentProducts),basket:ln(e?.basketProducts),q:co(e?.recentSearches),impressed:uo(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var lo=1800*1e3;function fn(e,t=Date.now()){try{localStorage.setItem(N("recommendationContext"),JSON.stringify({context:e,until:t+lo}))}catch{}}function pn(){try{localStorage.removeItem(N("recommendationContext"))}catch{}}function at(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var fo=2,po=12;function mo(e,t=fo){return e.split("/").slice(0,t).join("/")}function se(e,t){if(typeof t!="string"||!t.trim())return null;let n=mo(at(t));return n?(e.unshift(n),e.length=Math.min(e.length,po),n):null}var te=()=>N("sessionSignals"),ie=null,ct=()=>ie??te();function mn(){try{return ie?localStorage:sessionStorage}catch{return}}function hn(e,t){let n=t==null?null:String(t),r=e?j(te(),n,e):null;if(r===ie)return;let o=ie===null?ho():null;if(ie=r,!!ie)try{let s=ct(),i=Vt(te(),n);for(let c of Object.keys(localStorage))c.startsWith(i)&&c!==s&&localStorage.removeItem(c);o&&!localStorage.getItem(s)&&(localStorage.setItem(s,JSON.stringify(o)),sessionStorage.removeItem(te()))}catch{}}function ho(){try{let e=sessionStorage.getItem(te());if(!e)return null;let t=JSON.parse(e);return t&&(t.productViews>0||t.listViews>0||t.recentProducts?.length||t.recentBrowse?.length)?t:null}catch{return null}}function Pe(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],recentSearches:[],impressions:{},browsingCategory:null,startedAt:0}}function ut(){let e=mn();if(!e)return Pe();try{let t=e.getItem(ct());return t?{...Pe(),...JSON.parse(t)}:{...Pe(),startedAt:Date.now()}}catch{return{...Pe(),startedAt:Date.now()}}}function gn(e){let t=mn();if(t)try{t.setItem(ct(),JSON.stringify(e))}catch{}}function yn(){return ut()}function wn(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(te());for(let n of Object.keys(t))n.startsWith(`${te()}:`)&&t.removeItem(n)}catch{}}var Sn=20,_n=200,go=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),yo=new Set(["Product Clicked","Product Added to Wishlist"]);function bn(e,t){let n=ut();n.startedAt||(n.startedAt=Date.now());let r=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":n.productViews+=1,se(n.recentBrowse,n.browsingCategory);break;case"Product List Viewed":n.listViews+=1;{let i=t?.list_id;typeof i=="string"&&i.includes("/")&&!i.startsWith("cdp-")&&(n.browsingCategory=se(n.recentBrowse,i)??n.browsingCategory)}break;case"Product List Filtered":{let i=t?.change,c=typeof t?.list_id=="string"?t.list_id:"",l=typeof i?.value=="string"?i.value:"";l&&i?.action!=="removed"&&(n.browsingCategory=se(n.recentBrowse,`${c}/${l}`)??n.browsingCategory);break}case"Product Added":{n.cartAdds+=1,se(n.recentBrowse,n.browsingCategory);for(let i of r){let c=i.product_id;typeof c!="string"||!c||(n.basketProducts=[c,...n.basketProducts.filter(l=>l!==c)].slice(0,Sn))}break}case"Product Removed":{for(let i of r){let c=i.product_id;typeof c=="string"&&c&&(n.basketProducts=n.basketProducts.filter(l=>l!==c))}break}case"Products Searched":{n.searches+=1;let i=t?.query;if(typeof i=="string"&&i.trim()){let c=i.trim().toLowerCase().slice(0,64);n.recentSearches=[c,...n.recentSearches.filter(l=>l!==c)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;default:return n}let o=go.has(e);if(o)for(let i of r)typeof i.product_id=="string"&&i.product_id&&delete n.impressions[i.product_id];else{for(let c of r){let l=c.product_id;typeof l!="string"||!l||(n.impressions[l]=(n.impressions[l]??0)+1)}let i=Object.keys(n.impressions);if(i.length>_n){let c={};for(let l of i.sort((d,m)=>n.impressions[m]-n.impressions[d]).slice(0,_n))c[l]=n.impressions[l];n.impressions=c}}let s=new Set;for(let i of r){let c=i.product_id;if(o&&typeof c=="string"&&c&&(n.recentProducts=[c,...n.recentProducts.filter(l=>l!==c)].slice(0,Sn)),!yo.has(e)&&typeof i.category=="string"&&i.category){let l=at(i.category);l&&!s.has(l)&&(s.add(l),se(n.recentCategories,l))}}return gn(n),n}var xn=1800*1e3;function In({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=re}){let s=null,i=0,c=()=>{s!==null&&n()&&W(e,s,xn/1e3,t)};return{get(){let l=r(),d=R(e);return d?s=d:(s===null||l-i>=xn)&&(s=o()),i=l,c(),s},persist:c,forget(){W(e,"",0,t),s=null}}}var G=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),vn=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),lt=Object.freeze({enabled:!1});function kn(e,t){let n=e?.track;return G(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function wo(e,t){return`${ae(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var So="https://hp.uat.thgingenuity.com";function ae(e){return e==null||e===""?So:En(e)}function En(e){if(typeof e!="string")return null;let t=e.trim().replace(/\/+$/,"");return/^https?:\/\/[^/\s]+$/i.test(t)?t:/^[a-z0-9.-]+(:\d+)?$/i.test(t)?`https://${t}`:null}function _o(e){if(!G(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>typeof n=="boolean"));return Object.keys(t).length?t:null}var An=e=>typeof e=="number"&&e>=0&&e<=1;function bo(e){if(!G(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>G(n)&&An(n.share)&&(n.ramp==null||An(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...vn(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var xo=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function Io(e){return G(e)?e.source==="hp_cookie"?{source:"hp_cookie"}:e.source!=="site_cookie"?null:e.cookie==null?{source:"site_cookie",cookie:null}:typeof e.cookie=="string"&&xo.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function dt(e){let t=G(e)?e.hp:null;return!G(t)||t.enabled!==!0?lt:{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:_o(t.consent?.purposes),queryParamAllowlist:vn(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:Io(t.anonymousId),apiHost:En(t.apiHost),holdouts:bo(t.holdouts),plan:G(e.plan)&&G(e.plan.track)?{track:e.plan.track}:null}}async function Cn(e,t,n=globalThis.fetch){try{let r=await n(wo(e,t),{credentials:"omit",headers:{accept:"application/json"}});return r.ok?dt(await r.json()):null}catch{return null}}var Le=e=>j(N("settings"),e);function Pn(e){try{let t=localStorage.getItem(Le(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function Ln(e,t){try{t?.enabled===!0?localStorage.setItem(Le(e),JSON.stringify(t)):localStorage.removeItem(Le(e))}catch{}}function ft(e){try{localStorage.removeItem(Le(e))}catch{}}var Ao={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:Z.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},pt=()=>Date.now(),ce=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),mt=()=>typeof window<"u"&&typeof document<"u";function vo(){try{return!mt()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var I,ht,On,Oe,gt,yt,Nn,he,wt,Ne,Tn,St,Rn,Te,Re=class{constructor(t){It(this,I);this.o={...Ao,...t},this.queue=[],this.timer=null,this.storage=vo(),this.inflight=null,this.sending=new Set,this.replayAllowed=!this.o.deferReplay,this.draining=null,mt()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),O(this,I,Te).call(this))}replayPersisted(){return this.replayAllowed=!0,O(this,I,Te).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{this.storage.removeItem(this.o.storageKey)}catch{}}enqueue(t){this.queue.push(t),this.queue.length>this.o.maxQueue&&this.queue.splice(0,this.queue.length-this.o.maxQueue),this.queue.length>=this.o.flushAt?this.flush():O(this,I,ht).call(this)}flush(t={}){if(O(this,I,On).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&mt()&&typeof navigator<"u"&&navigator.sendBeacon)return O(this,I,Nn).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=O(this,I,yt).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(r=>{let o=O(this,I,St).call(this,r);return o&&this.sending.add(o),{batch:r,id:o}});return this.queue=[],this.inflight=(async()=>{for(let{batch:r,id:o}of n)await O(this,I,he).call(this,r,0,o)})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&O(this,I,ht).call(this)}),this.inflight}};I=new WeakSet,ht=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},On=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},Oe=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},gt=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},yt=function(t,n,r){let o=ce(O(this,I,Oe).call(this,[])),s=[],i=[],c=o;for(let l of t){let d=ce(JSON.stringify(l))+1;i.length&&(i.length>=n||c+d>r)&&(s.push(i),i=[],c=o),i.push(l),c+=d}return i.length&&s.push(i),s},Nn=function(){let t=this.queue;this.queue=[];let n=O(this,I,gt).call(this);for(let r of O(this,I,yt).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=O(this,I,Oe).call(this,r);if(ce(o)<=this.o.beaconSafeBytes){let s=!1;try{s=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{s=!1}if(s)continue}O(this,I,he).call(this,r,0,O(this,I,St).call(this,r))}},he=async function(t,n,r=null){r&&this.sending.add(r);let o=O(this,I,Oe).call(this,t);try{let s=await fetch(O(this,I,gt).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:o,keepalive:ce(o)<=this.o.beaconSafeBytes});if(s.ok)return O(this,I,wt).call(this,r),O(this,I,Te).call(this),!0;if(!(s.status===429||s.status>=500))return O(this,I,wt).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${s.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${s.status}`)}catch(s){if(n>=this.o.maxRetries){r&&this.sending.delete(r);let c=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${c}: ${t.length} events`,s),!1}let i=Math.min(1e3*2**n,3e4)*(.5+Math.random());return await new Promise(c=>setTimeout(c,i)),O(this,I,he).call(this,t,n+1,r)}},wt=function(t){t&&(this.sending.delete(t),O(this,I,Rn).call(this,t))},Ne=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},Tn=function(t,n){let r=i=>ce(JSON.stringify(i))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),s=o.reduce((i,c)=>i+r(c),2);for(;o.length>1&&s>this.o.maxPersistedBytes;)s-=r(o[0]),o=o.slice(1);for(;o.length;)try{return this.storage.setItem(this.o.storageKey,JSON.stringify(o)),!0}catch{o=o.slice(1)}return!1},St=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:pt(),id:`${pt()}-${Math.random().toString(36).slice(2)}`,batch:t};return ce(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:O(this,I,Tn).call(this,O(this,I,Ne).call(this),n)?n.id:null}catch{return null}},Rn=function(t){if(!(!t||!this.storage))try{let n=O(this,I,Ne).call(this).filter(r=>r.id!==t);n.length?this.storage.setItem(this.o.storageKey,JSON.stringify(n)):this.storage.removeItem(this.o.storageKey)}catch{}},Te=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=O(this,I,Ne).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&pt()-o.at<this.o.maxRetryAgeMs).map(o=>o.id?o:{...o,id:`${o.at}-${Math.random().toString(36).slice(2)}`}),(t.length!==r.length||t.some((o,s)=>o!==r[s]))&&(t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey))}catch{return Promise.resolve()}let n=t.filter(r=>!this.sending.has(r.id));return n.length?(this.draining=(async()=>{for(let r of n)if(!this.replayAllowed||!await O(this,I,he).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var Dn="3.17.1",Mn="@thg-agentic/hyper-personalisation-web";var ko=new Set(["audiences","decisions","recommendations"]);var Eo=Symbol.for("@thg-agentic/hyper-personalisation-web.replay");function Co(e){let t={...e??{}},n=Array.isArray(t.products)?t.products:null;if(t.item_count==null&&n){let r=n.map(o=>o?.quantity);r.every(Number.isInteger)&&(t.item_count=r.reduce((o,s)=>o+s,0))}return t}var Po="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function Lo(e){if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(!/^[A-Za-z0-9+/_-]{43}=?$/.test(e))return null;try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(44,"="));return t.length!==32?null:Array.from(t,n=>n.charCodeAt(0).toString(16).padStart(2,"0")).join("")}catch{return null}}function De(e){if(typeof e!="string")return null;let t=Lo(e.trim());return t===Po?null:t}var $n=!1;function Oo(e){!e||$n||($n=!0,console.warn("[hp] mintAnonymousId is ignored since 3.6: where device ids come from is set per source in the console (the site\u2019s own cookie, or Hyper-Personalisation\u2019s)."))}function Un(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function Vn(e){let t=ae(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(!e?.propertyId)throw new Error("createAnalytics: propertyId is required");let n={libraryName:Mn,libraryVersion:Dn,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};_e(n.storageNames),be();let r=!!n.consent,o=null;n.getConsent=()=>o?o.stamp():Ft();let s=()=>!r||o?.status==="granted",i=r&&n.holdAcrossPages?jt(j(N("held"),n.propertyId)):null,c=i?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&Oo(n.debug);let l=qt(n,{carried:c.anonymousId,mayStore:s}),d=n.getSessionId==null?In({name:N("session"),domain:n.consentCookieDomain??null,mayStore:s}):null;d&&(n.getSessionId=()=>d.get());let m=un(N("preview"),n.consentCookieDomain??null),f=n.transport??new Re({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:j(N("retry"),n.propertyId),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:(a,u)=>n.debug&&console.warn("[hp]",a,u??"")}),g=j(N("previousPage"),n.propertyId),b=null,A=()=>{if(b)return b;try{return sessionStorage.getItem(g)||null}catch{return null}},k=a=>{if(b=a||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(g,a)}catch{}},w=sn({key:j(N("decisions"),n.propertyId),mayStore:s});n.getDecisions??(n.getDecisions=w.current);let L=q($(n.getUserId,null)),h=null;function x(a,u,v=!1){let C=h;h=null;let E={messageId:C?.messageId??re(),timestamp:C?.timestamp??new Date().toISOString(),anonymousId:q($(n.getAnonymousId,null)),userId:L??null,...a,context:Dt(n,Un(u))};if(E.properties&&(E.properties=Ke(E.properties)),n.beforeSend){let H;try{H=n.beforeSend(E)}catch(Jn){return console.warn("[hp] beforeSend failed; the event was not sent",Jn),null}if(!H)return null;let{type:ye,event:bt,messageId:zn,timestamp:Wn}=E;E={...H,type:ye,messageId:zn,timestamp:Wn,...bt?{event:bt}:{}}}if(n.validate){let H=n.validate(E,{producer:"web"});if(!H.valid){let ye=`[hp] invalid ${E.event??E.type}:
2
- ${H.errors.join(`
3
- `)}`;if(n.throwOnInvalid)throw new Error(ye);console.error(ye)}}return n.debug&&console.debug("[hp]",E.event??E.type,E),B(E,v),E}function p(a){if(a.type==="track"&&M(a),n.onEvent)try{n.onEvent(a)}catch(u){console.warn("[hp] onEvent observer failed",u)}}let _=()=>r&&o?.state?.personalisation===!0,S=()=>hn($(n.getSessionId,null),n.propertyId),P=!1;function M(a){try{_()?(S(),fn(it(bn(a.event,a.properties))),P=!0):(pn(),P&&wn(),P=!1)}catch(u){n.debug&&console.warn("[hp] the visit was not recorded",u)}}function B(a,u){!r||u||o.admits()?(p(a),f.enqueue(a)):o.hold(a)}let y=(a,u,v)=>kn(n.plan,a)?x({type:"track",event:a,properties:u??{}},v):null,V=new Set,le=(a,u,v)=>a==="audiences"?{audiences:u?null:v.audiences??[]}:a==="decisions"?{decisions:(v.decisions??[]).map(C=>({slot:C.slot,decision_id:C.decision_id??null,arm:C.arm??null,...C.variant&&{variant:C.variant}}))}:{recommendation_request_id:v.recommendation_request_id??null};r&&(o=rn({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:i&&{read:()=>c.items,write:a=>i.write(a,l?.peek()??null)},release(a){a.context&&(a.context.consent=o.stamp()),p(a),f.enqueue(a)},onStatus(a){if(a==="granted"&&(l?.persist(),d?.persist(),b&&k(b),w.persist(),f.replayPersisted?.()),a==="denied"){f.clearPersisted?.(),l?.forget(),d?.forget();try{sessionStorage.removeItem(g)}catch{}w.forget()}try{n.onConsentStatus?.(a)}catch(u){console.warn("[hp] onConsentStatus observer failed",u)}},announce({action:a,state:u,withdrawal:v}){x({type:"track",event:"Consent Updated",properties:{action:a,state:u}},void 0,v),v&&f.flush()}}),o.start());let F=()=>n.holdout?ot(n.holdout):null,de=()=>st(n.holdout,q($(n.getAnonymousId,null))).group;function ge(a,u){if(!Array.isArray(a?.decisions))return a;let v=n.holdout?.readoutSlots??[],C=q($(n.getAnonymousId,null));return{...a,decisions:a.decisions.map(E=>{let H=E?.variant==="bandit"||E?.variant==="default"?E.variant:!u&&E?.holdout!==!0&&v.includes(E?.slot)?cn(E.slot,C):null;return H?H==="default"?{...E,variant:H,decision_id:null}:{...E,variant:H}:E})}}function fe(a,u){if(m)return null;let v=a?.exposure,C=v?.holdout===!0,E=ge(a,C);return w.remember(on(E)),!v?.token||V.has(v.token)?null:(V.add(v.token),y("Personalisation Exposed",{exposure_token:v.token,surface:v.surface,holdout:C,holdout_share:v.holdout_share??F()?.holdout_share??null,personalised_share:v.personalised_share??F()?.personalised_share??null,...le(v.surface,C,E)},u))}return{track:y,page(a={},u){let v=n.pageType??null;a.type&&(ne.has(a.type)?(v=a.type,n.pageType=a.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${a.type}". Allowed: ${[...ne].join(", ")}`));let C=x({type:"page",properties:{name:a.name??null,navigation_trigger:a.navigation_trigger??Ot(),previous_message_id:A()}},{page:{type:v},...Un(u)??{}});return C&&k(C.messageId),C},identify(a,u){let{userId:v,...C}=a&&typeof a=="object"?a:{};if(v!==void 0&&(L=q(v)),typeof C.email_sha256=="string"){let E=De(C.email_sha256);E?C.email_sha256=E:delete C.email_sha256}return x({type:"identify",traits:C},u)},reset(){L=null,k("")},productViewed:(a,u)=>y("Product Viewed",a,u),productListViewed:(a,u)=>y("Product List Viewed",a,u),recommendationsViewed:(a,u)=>y("Recommendations Viewed",a,u),personalisationExposed:(a,u)=>y("Personalisation Exposed",a,u),recordExposure:fe,surfaceViewed({surface:a}={},u){if(!ko.has(a)||!n.holdout||a!=="decisions"&&!_())return null;let v=q($(n.getAnonymousId,null)),C=st(n.holdout,v).group;if(C==="excluded")return null;let E=Ct({sessionId:we($(n.getSessionId,null),v),surface:a});return E?fe({exposure:{token:E,surface:a,holdout:C==="holdout"}},u):null},inHoldout:()=>de()!=="personalised",personalisationGroup:de,productClicked:(a,u)=>y("Product Clicked",a,u),productListFiltered:(a,u)=>y("Product List Filtered",a,u),productsSearched:(a,u)=>y("Products Searched",a,u),productAdded:(a,u)=>y("Product Added",a,u),productRemoved:(a,u)=>y("Product Removed",a,u),cartUpdated:(a,u)=>y("Cart Updated",Co(a),u),identityLinked:(a,u)=>y("Identity Linked",a,u),slotEngaged:(a,u)=>m?null:y("Slot Engaged",a,u),productVariantSelected:(a,u)=>y("Product Variant Selected",a,u),cartViewed:(a,u)=>y("Cart Viewed",a,u),productAddedToWishlist:(a,u)=>y("Product Added to Wishlist",a,u),productRemovedFromWishlist:(a,u)=>y("Product Removed from Wishlist",a,u),wishlistProductAddedToCart:(a,u)=>y("Wishlist Product Added to Cart",a,u),productShared:(a,u)=>y("Product Shared",a,u),cartShared:(a,u)=>y("Cart Shared",a,u),couponEntered:(a,u)=>y("Coupon Entered",a,u),couponApplied:(a,u)=>y("Coupon Applied",a,u),couponDenied:(a,u)=>y("Coupon Denied",a,u),couponRemoved:(a,u)=>y("Coupon Removed",a,u),checkoutStarted:(a,u)=>y("Checkout Started",a,u),promotionViewed:(a,u)=>y("Promotion Viewed",a,u),promotionClicked:(a,u)=>y("Promotion Clicked",a,u),checkoutStepViewed:(a,u)=>y("Checkout Step Viewed",a,u),checkoutStepCompleted:(a,u)=>y("Checkout Step Completed",a,u),paymentInfoEntered:(a,u)=>y("Payment Info Entered",a,u),checkoutFailed:(a,u)=>y("Checkout Failed",a,u),signedIn:(a,u)=>y("Signed In",a,u),signedUp:(a,u)=>y("Signed Up",a,u),signedOut(a){let u=y("Signed Out",{},a);return L=null,u},newsletterSubscribed:(a,u)=>y("Newsletter Subscribed",a,u),newsletterUnsubscribed:(a,u)=>y("Newsletter Unsubscribed",a,u),backInStockSubscribed:(a,u)=>y("Back In Stock Subscribed",a,u),productReviewed:(a,u)=>y("Product Reviewed",a,u),consentUpdated:(a,u)=>y("Consent Updated",a,u),flush:a=>f.flush(a),recommendationContext(){if(!_())return{};try{return S(),it(yn())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>Gt(o?.state??null),get lastPageMessageId(){return A()},get anonymousId(){return q($(n.getAnonymousId,null))},[Eo](a,u,v){if(typeof this[a]=="function"){h=typeof v?.messageId=="string"&&typeof v?.timestamp=="string"?{messageId:v.messageId,timestamp:v.timestamp}:null;try{this[a](...Array.isArray(u)?u:[])}finally{h=null}}}}}var _t=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),No=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),To=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),Ro=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Do=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),Mo=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),Ue=e=>e?()=>R(e):()=>null,Bn={didomi:e=>zt({purposes:e.purposes}),onetrust:e=>Wt({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>Jt({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>Xt({name:e.name}),static:e=>{if(!e.state||typeof e.state!="object")throw new Error('consent.state is required for provider "static"');return Yt(e.state)}},jn=Object.keys(Bn),ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Me=e=>typeof e=="string"&&e!=="",$o=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Fn=e=>ue(e)&&typeof e.read=="function";function Uo(e,t={}){let n=[];if(!ue(e))return["config must be { writeKey, apiHost? }"];Me(e.writeKey)||n.push("writeKey is required"),ae(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!Me(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!Fn(r)&&!(ue(r)&&jn.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${jn.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!ue(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.beforeSend!==void 0&&typeof t.beforeSend!="function"&&n.push("beforeSend must be a function"),t.identityCookies!==void 0)if(!ue(t.identityCookies))n.push("identityCookies must be an object");else for(let o of["anonymousId","sessionId"]){let s=t.identityCookies[o];s!==void 0&&!Me(s)&&n.push(`identityCookies.${o} must be a cookie name`)}for(let o of["getCurrency","getShipToCountry","getLocale"])t[o]!==void 0&&typeof t[o]!="function"&&n.push(`${o} must be a function`);return t.dataLayer!==void 0&&(ue(t.dataLayer)?(t.dataLayer.name!==void 0&&!Me(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!$o(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function Vo(e,t,n){if(Fn(e))return et(e,t.consentPurposes);let{provider:r,...o}=e,s=n?.consent?.[r]??Bn[r];return et(s(o),t.consentPurposes)}var Hn=(e,t)=>`${e??""}|${t??""}`;function jo(e,t){let n=q(t?.userId),r=De(t?.emailSha256);if(!n&&!r)return null;try{let o=j(N("identified"),e);if(sessionStorage.getItem(o)===Hn(n,r))return null}catch{}return{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function qo({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:dt(n.settings),revalidated:null};let r=Cn(t,e),o=Pn(e);if(o)return{settings:o,revalidated:r};let s=await r,i=s??lt;return{settings:i,revalidated:Promise.resolve(i),unreachable:s===null}}function Kn(e,t={}){let n=typeof window<"u"?window:null;if(n?.[_t])return n[_t];let r=Bt(e?.writeKey,()=>{let{analytics:s}=me(R(N("consent")));return s===!0||s===null&&t.holdAcrossPages===!0}),o=Bo(e,t,r);if(n){let s=t.extend?.getSessionId??Ue(t.identityCookies?.sessionId),i=Ue(t.identityCookies?.anonymousId);n[Do]=({slot:c,arm:l}={})=>Et({sessionId:we(s(),i()),slot:c,arm:l}),n[_t]=o,n[To]=r,n[No]?.(o)}return o}function qn(e,t){if(t===!1)return()=>{};let n={promotions:!0,productLists:!0,recommendations:!0,exposures:!0,...t},r=s=>s&&typeof s=="object"?s:{},o=[];try{n.promotions&&o.push(Be(e,r(n.promotions))),n.productLists&&o.push(qe(e,r(n.productLists))),n.recommendations&&o.push(Fe(e,r(n.recommendations))),n.exposures&&o.push(je(e,r(n.exposures)))}catch(s){console.warn("[hp] autocapture not started:",s?.message??s)}return()=>{for(let s of o)s()}}function $e(e){return e.close(),null}async function Bo(e,t,n){try{let r=Uo(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),$e(n);_e(t.storageNames),be();let{writeKey:o}=e,[{settings:s,revalidated:i,unreachable:c},l]=await Promise.all([qo(e,t),Promise.resolve(t.identity).catch(()=>null)]),d=i?s:null,m=!1,f=()=>m&&d&&Ln(o,d);if(i?.then(p=>{p&&(d=p,p.enabled?f():ft(o))}),c)return null;if(!s.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),$e(n);let g=s.propertyId??t.propertyId;if(!g)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),$e(n);let{preset:b}=t,A=jo(g,l),k=q(l?.userId),w=Vn({apiHost:s.apiHost??ae(e.apiHost),writeKey:o,propertyId:g,pageType:ne.has(t.pageType)?t.pageType:void 0,environment:s.environment,queryParamAllowlist:s.queryParamAllowlist??void 0,plan:s.plan,holdout:s.holdouts?.[g],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:Vo(t.consent,s,b),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:t.debug===!0,anonymousIdSource:s.anonymousId??void 0,getAnonymousId:Ue(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?Ue(t.identityCookies.sessionId):void 0,getUserId:()=>k,beforeSend:t.beforeSend,...t.extend,onConsentStatus(p){if(p==="granted"&&(m=!0,f()),p==="denied"){ft(o);try{sessionStorage.removeItem(j(N("identified"),g))}catch{}}t.extend?.onConsentStatus?.(p)},onEvent(p){if(p.type==="identify"){let _=Hn(q(p.userId),De(p.traits?.email_sha256));try{sessionStorage.setItem(j(N("identified"),g),_)}catch{}}t.extend?.onEvent?.(p)}});typeof window<"u"&&(window[Mo]=()=>w.recommendationContext());for(let[p,_,S]of n.take())try{w[Ro](p,_,S)}catch(P){console.warn(`[hp] carried ${p} failed`,P)}w.page(t.pageType?{type:t.pageType}:{});let L=qn(w,t.autocapture),h=w.page;w.page=(...p)=>{let _=h(...p);return L(),L=qn(w,t.autocapture),_};let x=typeof window<"u"?window:null;if(t.dataLayer&&x){let p=t.dataLayer.name??"dataLayer";x[p]=x[p]||[],tn(w,{...b,dataLayer:x[p],ignore:[...b?.ignore??[],...t.dataLayer.ignore??[]],onError:_=>t.debug&&console.warn("[hp] dataLayer mapping failed",_)})}return A&&w.identify(A),w}catch(r){return console.warn("[hp] not started:",r?.message??r),$e(n)}}function Gn(e){e.initialized=!0,Kn(e._config,e._options).then(t=>{let n=e.splice(0);if(!t){for(let r of e.methods??[])e[r]=()=>e;return}e.client=t;for(let[r,o]of Object.entries(t))typeof o=="function"&&(e[r]=o);for(let[r,...o]of n)try{t[r]?.(...o)}catch(s){console.warn(`[hp] queued ${r} failed`,s)}})}var U=window.hp=window.hp||[];U.servingHeaders??(U.servingHeaders=()=>({}));U.inHoldout??(U.inHoldout=()=>!0);U.personalisationGroup??(U.personalisationGroup=()=>"excluded");U.recommendationContext??(U.recommendationContext=()=>({}));U.initialized||(U._config?Gn(U):U.load=(e,t)=>{U._config=e,U._options=t??{},Gn(U)});})();
1
+ (()=>{var Pt=e=>{throw TypeError(e)};var ir=(e,t,n)=>t.has(e)||Pt("Cannot "+n);var Lt=(e,t,n)=>t.has(e)?Pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n);var N=(e,t,n)=>(ir(e,t,"access private method"),n);var ge=[];for(let e=2;ge.length<64;e++)ge.every(t=>e%t!==0)&&ge.push(e);var Ot=e=>(e-Math.floor(e))*2**32>>>0,ar=ge.slice(0,8).map(e=>Ot(Math.sqrt(e))),cr=ge.map(e=>Ot(Math.cbrt(e))),z=(e,t)=>e>>>t|e<<32-t;function Nt(e){let t=new TextEncoder().encode(String(e)),n=new Uint32Array((t.length+8>>6)*16+16);t.forEach((s,i)=>{n[i>>2]|=s<<24-i%4*8}),n[t.length>>2]|=128<<24-t.length%4*8,n[n.length-2]=Math.floor(t.length/2**29),n[n.length-1]=t.length*8;let r=Uint32Array.from(ar),o=new Uint32Array(64);for(let s=0;s<n.length;s+=16){for(let g=0;g<64;g++){if(g<16){o[g]=n[s+g];continue}let _=o[g-15],x=o[g-2],v=z(_,7)^z(_,18)^_>>>3,h=z(x,17)^z(x,19)^x>>>10;o[g]=o[g-16]+v+o[g-7]+h}let[i,a,u,d,p,f,m,b]=r;for(let g=0;g<64;g++){let _=z(p,6)^z(p,11)^z(p,25),x=b+_+(p&f^~p&m)+cr[g]+o[g]|0,h=(z(i,2)^z(i,13)^z(i,22))+(i&a^i&u^a&u)|0;[b,m,f,p,d,u,a,i]=[m,f,p,d+x|0,u,a,i,x+h|0]}[i,a,u,d,p,f,m,b].forEach((g,_)=>{r[_]+=g})}return Array.from(r,s=>s.toString(16).padStart(8,"0")).join("")}var He=(e,t)=>e<<t|e>>>32-t;function Tt(e){let t=new Uint32Array((e.length+8>>6)*16+16);e.forEach((s,i)=>{t[i>>2]|=s<<24-i%4*8}),t[e.length>>2]|=128<<24-e.length%4*8,t[t.length-2]=Math.floor(e.length/2**29),t[t.length-1]=e.length*8;let n=Uint32Array.of(1732584193,4023233417,2562383102,271733878,3285377520),r=new Uint32Array(80);for(let s=0;s<t.length;s+=16){for(let f=0;f<80;f++)r[f]=f<16?t[s+f]:He(r[f-3]^r[f-8]^r[f-14]^r[f-16],1);let[i,a,u,d,p]=n;for(let f=0;f<80;f++){let m,b;f<20?(m=a&u|~a&d,b=1518500249):f<40?(m=a^u^d,b=1859775393):f<60?(m=a&u|a&d|u&d,b=2400959708):(m=a^u^d,b=3395469782);let g=He(i,5)+m+p+b+r[f]|0;[p,d,u,a,i]=[d,u,He(a,30),i,g]}[i,a,u,d,p].forEach((f,m)=>{n[m]+=f})}let o=new Uint8Array(20);return n.forEach((s,i)=>{o[i*4]=s>>>24,o[i*4+1]=s>>>16,o[i*4+2]=s>>>8,o[i*4+3]=s}),o}var ur="e28e8ada-5b76-4209-bba9-79b823a0af75",lr=e=>Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");function Rt(e,t){let n=Uint8Array.from(e.replace(/-/g,"").match(/../g),a=>Number.parseInt(a,16)),r=new TextEncoder().encode(t),o=new Uint8Array(16+r.length);o.set(n),o.set(r,16);let s=Tt(o).slice(0,16);s[6]=s[6]&15|80,s[8]=s[8]&63|128;let i=lr(s);return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}var ee=(e,t)=>typeof e=="string"&&e!==""&&e.length<=t?e:null;function be(e,t){return ee(e,64)??ee(t,256)}function Dt({sessionId:e,slot:t,arm:n}={}){let r=ee(e,256);return!r||!ee(t,256)||!ee(n,256)?null:Rt(ur,`${r}:${t}:${n}`)}var dr="4b1f2c7e-9a3d-4e58-b6c1-2d7f0a9e8c53";function Mt({sessionId:e,surface:t}={}){let n=ee(e,256);return!n||!ee(t,64)?null:Rt(dr,`${n}:${t}`)}var fr=Array.from({length:11},(e,t)=>t/10);function pr(e,t){if(!e.isIntersecting)return!1;let{intersectionRect:n,boundingClientRect:r,rootBounds:o}=e;if(!n||!r)return!0;let s=n.width*n.height,i=r.width*r.height,a=o?Math.min(i,o.width*o.height):i;return a>0&&s/a>=t}function Y(e){let{selector:t,onViewable:n,visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=e,i=new Map,a=new WeakSet,u=new Set,d=h=>{i.has(h)||i.set(h,setTimeout(()=>{i.delete(h),n(h)&&(f?.unobserve(h),u.delete(h))},o))},p=h=>{clearTimeout(i.get(h)),i.delete(h)},f=typeof IntersectionObserver>"u"?null:new IntersectionObserver(h=>{for(let E of h){let S=E.target;if(!pr(E,r)){u.delete(S),p(S);continue}u.add(S),m()&&d(S)}},{threshold:fr}),m=()=>typeof document>"u"||document.visibilityState!=="hidden",b=()=>{if(m())for(let h of u)d(h);else for(let h of u)p(h)};document.addEventListener("visibilitychange",b);let g=()=>{for(let h of s.querySelectorAll(t))a.has(h)||(a.add(h),f?.observe(h))},_=typeof MutationObserver>"u"?null:new MutationObserver(()=>g()),x=()=>{g(),_?.observe(s===document?document.body:s,{childList:!0,subtree:!0})},v=s===document&&!document.body;return v?document.addEventListener("DOMContentLoaded",x,{once:!0}):x(),()=>{v&&document.removeEventListener("DOMContentLoaded",x),document.removeEventListener("visibilitychange",b),f?.disconnect(),_?.disconnect();for(let h of i.values())clearTimeout(h);i.clear(),u.clear()}}function Ke(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-exposure]",visibleRatio:r=.5,dwellMs:o=1e3,root:s=document}=t;return Y({selector:n,root:s,visibleRatio:r,dwellMs:o,onViewable(i){let a=i.dataset?.hpExposure?.trim();return a&&e.surfaceViewed({surface:a}),!0}})}var Ut=e=>{try{return new URL(e,document.baseURI).toString()}catch{return e}};function Ge(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-list]",tileSelector:r="[data-hp-product]",visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,a=new Set,u=g=>g.closest?.(n)??null,d=g=>{let _=g.dataset.hpList?.trim();return _?{list_id:_,category:g.dataset.hpListCategory?.trim()||null}:null},p=g=>Array.from(g.querySelectorAll(r)).filter(_=>u(_)===g),f=(g,_)=>{try{let x=JSON.parse(g.dataset.hpProduct??"");return!x||typeof x!="object"||!x.product_id?null:{...x,position:x.position??_+1,...x.url?{url:Ut(x.url)}:{},...x.image_url?{image_url:Ut(x.image_url)}:{}}}catch{return null}},m=Y({selector:`${n} ${r}`,root:i,visibleRatio:o,dwellMs:s,onViewable(g){let _=u(g);if(!_||_.dataset.hpListView==="manual")return!0;let x=d(_);if(!x||a.has(x.list_id))return!0;let v=new Set,h=p(_).map(f).filter(E=>!E||v.has(E.product_id)?!1:(v.add(E.product_id),!0));return h.length===0||(a.add(x.list_id),e.productListViewed({...x,products:h})),!0}}),b=g=>{let x=g.target?.closest?.("a[href]")?.closest(r);if(!x)return;let v=u(x),h=f(x,v?p(v).indexOf(x):0);h&&e.productClicked({list_id:v?d(v)?.list_id??null:null,products:[h]})};return document.addEventListener("click",b,!0),()=>{document.removeEventListener("click",b,!0),m()}}function T(e,...t){let n=e.dataset??{};for(let r of t){let o=n[r];if(typeof o=="string"&&o.trim()!=="")return o.trim()}return null}function xe(e,...t){let n=T(e,...t);if(n===null)return null;let r=Number(n);return Number.isFinite(r)?Math.trunc(r):null}function mr(e,t){let n=T(e,"hpPromotion");return n?{promotion_id:n,name:T(e,"hpPromotionName"),creative:T(e,"hpPromotionCreative"),position:T(e,"hpPromotionSlot")??String(t+1)}:null}function We(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-promotion]",resolve:r=mr,visibleRatio:o=.5,dwellMs:s=1e3,root:i=document}=t,a=new Set,u=f=>{let m=Array.from(i.querySelectorAll(n)),b=m.indexOf(f);try{return r(f,b<0?m.length:b)}catch{return null}},d=Y({selector:n,root:i,visibleRatio:o,dwellMs:s,onViewable(f){let m=u(f);return!m||a.has(m.promotion_id)?!1:(a.add(m.promotion_id),e.promotionViewed(m),!0)}}),p=f=>{let m=f.target;if(!m||typeof m.closest!="function")return;let b=m.closest(n),g=m.closest("a[href]");if(!b||!g||!b.contains(g)&&!g.contains(b))return;let _=u(b);_&&e.promotionClicked({..._,href:g.getAttribute("href")})};return document.addEventListener("click",p,!0),()=>{document.removeEventListener("click",p,!0),d()}}function hr(e){let t=T(e,"hpRecoRequest"),n=T(e,"hpRecoPlacement"),r=T(e,"hpRecoStrategy");if(!t||!n||!r)return null;let o=T(e,"hpRecoHoldout");return{recommendation_request_id:t,placement:n,strategy:r,recipe:T(e,"hpRecoRecipe"),algorithm_version:T(e,"hpRecoAlgorithmVersion"),experiment:T(e,"hpRecoExperiment"),variant:T(e,"hpRecoVariant"),holdout:o===null?null:o==="true",assignment_bucket:xe(e,"hpRecoBucket"),assignment_unit_kind:T(e,"hpRecoUnitKind"),candidate_set_fingerprint:T(e,"hpRecoFingerprint"),candidate_set_size:xe(e,"hpRecoCandidates"),ranked_by:T(e,"hpRecoRankedBy"),served_at:T(e,"hpRecoServedAt")}}function gr(e,t){let n=T(e,"hpRecoProduct");if(!n)return null;let r=T(e,"hpRecoPrice");return{product_id:n,sku:T(e,"hpRecoSku"),name:T(e,"hpRecoName"),brand:T(e,"hpRecoBrand"),price:r===null||Number.isNaN(Number(r))?null:Number(r),position:xe(e,"hpRecoPosition")??t+1}}function ze(e,t={}){if(typeof window>"u"||typeof document>"u")return()=>{};let{selector:n="[data-hp-reco-request]",tileSelector:r="[data-hp-reco-product]",resolveRail:o=hr,resolveTile:s=gr,visibleRatio:i=.5,dwellMs:a=1e3,root:u=document}=t,d=new Set,p=new Map,f=new Map,m=(h,...E)=>{try{return h(...E)}catch{return null}},b=h=>typeof h.closest=="function"?h.closest(n):null,g=h=>Array.from(h.querySelectorAll(r)),_=(h,E)=>{if(f.delete(E.recommendation_request_id),d.has(E.recommendation_request_id))return;let S=g(h).map((w,L)=>m(s,w,L)).filter(w=>w?.product_id);if(S.length===0)return;d.add(E.recommendation_request_id);let y=[...p.get(E.recommendation_request_id)?.values()??[]].sort((w,L)=>w.position-L.position);e.recommendationsViewed({...E,products:S,viewable:y})},x=Y({selector:`${n} ${r}`,root:u,visibleRatio:i,dwellMs:a,onViewable(h){let E=b(h);if(!E)return!0;let S=m(o,E);if(!S)return!0;let y=S.recommendation_request_id,w=m(s,h,g(E).indexOf(h));if(w?.product_id){p.has(y)||p.set(y,new Map);let L=p.get(y);L.has(w.position)||L.set(w.position,{position:w.position,product_id:w.product_id,viewable_at:new Date().toISOString()})}return!d.has(y)&&!f.has(y)&&f.set(y,setTimeout(()=>_(E,S),0)),!0}}),v=h=>{let E=h.target;if(!E||typeof E.closest!="function")return;let S=E.closest(r);if(!S)return;let y=E.closest("[data-hp-reco-interaction]"),w=E.closest("a[href]"),L=w&&(S.contains(w)||w.contains(S));if(!(y&&S.contains(y))&&!L)return;let D=b(S);if(!D)return;let H=m(o,D);if(!H)return;let K=m(s,S,g(D).indexOf(S));if(!K?.product_id)return;let F=H.recommendation_request_id;d.has(F)||(clearTimeout(f.get(F)),_(D,H)),e.productClicked({recommendation_request_id:H.recommendation_request_id,interaction:T(y??S,"hpRecoInteraction")??"navigate",products:[K]})};return document.addEventListener("click",v,!0),()=>{document.removeEventListener("click",v,!0);for(let h of f.values())clearTimeout(h);f.clear(),x()}}var ae=new Set(["home","list","product","search","basket","checkout","order_confirmation","login","register","account","info","blog","other"]),yr=new Set(["products"]),$t=e=>e==null;function Je(e,t=new WeakSet){if(e instanceof Date)return e.toJSON();if(e===null||typeof e!="object"||t.has(e))return e;t.add(e);let n=Array.isArray(e)?e.map(r=>Je(r,t)):Object.fromEntries(Object.entries(e).filter(([,r])=>!$t(r)).map(([r,o])=>[r,Je(o,t)]));return t.delete(e),n}function Xe(e){if(!e)return e;let t=Je(e);for(let n of yr)n in e&&$t(e[n])&&(t[n]=e[n]);return t}function Vt(){try{let e=performance.getEntriesByType("navigation")[0];return e?["navigate","reload","back_forward","prerender"].includes(e.type)?e.type:"navigate":null}catch{return null}}var Sr=new Set(["","unknown","undefined","null","none","nil","nan","anonymous","guest","0","-1"]);function B(e){if(e==null)return null;let t=String(e).trim();return Sr.has(t.toLowerCase())?null:t}function Z(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var jt="1.10";function U(e){if(typeof document>"u")return null;try{let t=document.cookie.split(";").map(n=>n.trim()).find(n=>n.startsWith(`${e}=`));return t&&decodeURIComponent(t.slice(e.length+1))||null}catch{return null}}var wr={gclid:"gclid",fbclid:"fbclid",ttclid:"ttclid"},_r=/[a-z0-9._%+-]+@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}/i,br=/\d(?:[ -]?\d){12,}/,xr=new Set(["gclid","fbclid","ttclid","msclkid"]);function qt(e,t=""){if(typeof e!="string"||e==="")return!1;let n=[e];try{let o=decodeURIComponent(e.replace(/\+/g," "));o!==e&&n.push(o)}catch{}let r=!xr.has(String(t).toLowerCase());return n.some(o=>_r.test(o)||r&&br.test(o))}function Ir(e){if(!e)return null;let t=new URLSearchParams(e),n={},r={utm_source:"source",utm_medium:"medium",utm_campaign:"name",utm_term:"term",utm_content:"content"};for(let[o,s]of[...Object.entries(r),...Object.entries(wr)]){let i=t.get(o);i&&!qt(i,o)&&(n[s]=i)}return Object.keys(n).length?n:null}var Ar=["email","e-mail","password","pass","pwd","token","auth","code","uid","customer_id","postcode","zip","phone","applyCode"],kr=["email","password","passwd","pwd","token","secret","auth","session","phone","postcode","zip","address","birth","card","cvv","iban","ssn","customerid","userid"],vr=["tel","uid","dob"],Er=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","gclid","fbclid","ttclid","msclkid"],Cr=new Set(Ar.map(e=>e.toLowerCase()));function Pr(e){let t=String(e).toLowerCase();if(Cr.has(t))return!0;let n=t.replace(/[-_.]/g,"");return kr.some(o=>n.includes(o))?!0:String(e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).some(o=>vr.includes(o))}function Ye(e){return(e??[]).map(t=>{try{return new RegExp(`^${t}$`,"i")}catch{return{test:n=>n.toLowerCase()===String(t).toLowerCase()}}})}function Ft(e,t={}){if(!e)return null;try{let n=new URLSearchParams(e),r=t.queryParamAllowlist?Ye([...t.queryParamAllowlist,...Er]):null,o=Ye(t.queryParamBlocklist),s=Ye(t.sensitiveParamAllowlist);for(let a of new Set(n.keys()))(Pr(a)&&!s.some(d=>d.test(a))||n.getAll(a).some(d=>qt(d,a))||(r?!r.some(d=>d.test(a)):o.some(d=>d.test(a))))&&n.delete(a);let i=n.toString();return i?`?${i}`:""}catch{return""}}function Lr(e,t,n={}){if(!e)return null;try{let r=new URL(e);return t&&r.origin===t?r.origin+r.pathname+(Ft(r.search,n)??""):r.origin+r.pathname}catch{return null}}function Ze(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function Bt(e){if(typeof e!="string")return null;let t=e.trim().toUpperCase();return/^[A-Z]{2}$/.test(t)?t:null}function Or(e){if(typeof e!="string")return null;let t=e.trim().replace(/_/g,"-");if(!/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(t))return null;try{return Intl.getCanonicalLocales(t)[0]}catch{return null}}function M(e,t){if(typeof e=="function")try{let n=e();if(n!=null)return n}catch{}return t}function Nr(e){return{property_id:String(e.propertyId),channel:e.channel??null,market:e.market??null,environment:e.environment??null}}function Tr(e){let t=typeof window<"u"?window.location:null,n=t?Ft(t.search,e):null;return{url:t?t.origin+t.pathname+(n??""):e.pageUrl??null,path:t?t.pathname:e.pagePath??null,search:n??null,referrer:typeof document<"u"?Lr(document.referrer,t?.origin,e):null,title:typeof document<"u"&&document.title||null,type:e.pageType??null}}function Ht(e,t={}){let n=typeof window<"u"?window.location:null,r={library:{name:e.libraryName,version:e.libraryVersion},spec:{version:jt},source:Nr(e),session_id:M(e.getSessionId,null),render_id:M(e.getRenderId,null),identity_trust:B(M(e.getAnonymousId,null))?"device":"none",page:Tr(e),campaign:n?Ir(n.search):null,device:{user_agent:typeof navigator<"u"?navigator.userAgent:null,type:null,viewport_width:typeof window<"u"?window.innerWidth:null,viewport_height:typeof window<"u"?window.innerHeight:null},currency:Ze(M(e.getCurrency,e.currency)),locale:Or(M(e.getLocale,e.locale)),timezone:(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return null}})(),country:Bt(e.country),ship_to_country:Bt(M(e.getShipToCountry,e.shipToCountry)),ip:null,bot:null,consent:e.getConsent?.()??null,experiments:M(e.getExperiments,null),audiences:M(e.getAudiences,null),decisions:M(e.getDecisions,null),recommendations:M(e.getRecommendations,null),extensions:M(e.getExtensions,null)};return Kt(r,t)}function Kt(e,t){if(!t)return e;let n={...e};for(let[r,o]of Object.entries(t))o&&typeof o=="object"&&!Array.isArray(o)&&e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?n[r]=Kt(e[r],o):o!==void 0&&(n[r]=o);return n}var re=Object.freeze({consent:"thg_hp_consent",retry:"thg_hp_retry",sessionSignals:"thg_hp_session_signals",identified:"thg_hp_identified",previousPage:"thg_hp_prev_page",decisions:"thg_hp_decisions",settings:"thg_hp_settings",held:"thg_hp_held",carried:"thg_hp_carried",recommendationContext:"thg_hp_recommendation_context",anonymousId:"thg_hp_anonymous_id",session:"thg_hp_session",preview:"thg_hp_preview",debug:"thg_hp_debug"}),Rr={retry:"cdp.retry",sessionSignals:"cdp_session_signals",identified:"cdp_identified",previousPage:"cdp_prev_page_message_id"},Qe={...re},Gt=!1;function Ie(e){let t={...re};for(let[n,r]of Object.entries(e??{})){if(!(n in re))throw new Error(`storageNames: unknown kind "${n}"`);if(typeof r!="string"||!/^[\w.-]+$/.test(r))throw new Error(`storageNames.${n} must be a non-empty cookie-safe name`);t[n]=r}Qe=t}function O(e){return Qe[e]}var Dr="_",Wt=e=>e==null||e===""?Dr:String(e);function q(e,t,n){let r=`${e}:${Wt(t)}`;return n==null||n===""?r:`${r}:${n}`}function zt(e,t){return`${e}:${Wt(t)}:`}function Ae(){if(!Gt){Gt=!0;for(let e of[()=>localStorage,()=>sessionStorage]){let t;try{if(t=e(),!t)continue;for(let n of Object.keys(t))for(let[r,o]of Object.entries(Rr)){if(n!==o&&!n.startsWith(`${o}:`))continue;let s=Qe[r]+n.slice(o.length);t.getItem(s)===null&&t.setItem(s,t.getItem(n)),t.removeItem(n)}}catch{}}}}var tt=1800*1e3,ke=()=>{try{return typeof sessionStorage>"u"?null:sessionStorage}catch{return null}},et=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}};function Jt(e,t=()=>Date.now()){return{read(){try{let n=ke()?.getItem(e),r=n?JSON.parse(n):null;return!r||t()-r.savedAt>tt?(r&&ke()?.removeItem(e),{items:[],anonymousId:null}):{items:Array.isArray(r.items)?r.items:[],anonymousId:typeof r.anonymousId=="string"?r.anonymousId:null}}catch{return{items:[],anonymousId:null}}},write(n,r=null){try{n.length===0?ke()?.removeItem(e):ke()?.setItem(e,JSON.stringify({savedAt:t(),items:n,anonymousId:r}))}catch{}}}}var Mr=400*24*60*60;function Q(e,t,n,r){if(typeof document>"u")return!1;try{let o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",s=r?`; Domain=${r}`:"",i=n===null?"":`; Max-Age=${n}`;return document.cookie=`${e}=${encodeURIComponent(t)}; Path=/${i}; SameSite=Lax`+s+o,!0}catch{return!1}}function Ur({name:e,domain:t=null,legacyKey:n,read:r,mint:o,mayStore:s,carried:i=null}){let a=null;try{a=et()?.getItem(n)||null}catch{a=null}let u=r(e)??a??i,d=!1,p=()=>{if(!(d||u===null||!s())&&(d=Q(e,u,Mr,t),!(!d||a===null)))try{et()?.removeItem(n),a=null}catch{}};return{get(){return u??(u=o()),p(),u},peek:()=>u,persist:p,forget(){Q(e,"",0,t),u=null,d=!1;try{et()?.removeItem(n)}catch{}a=null}}}function Xt(e,{carried:t=null,mayStore:n,orOwn:r=!1}){let o=e.anonymousIdSource,s=()=>Ur({name:O("anonymousId"),domain:e.consentCookieDomain??null,legacyKey:q(O("anonymousId"),e.propertyId),read:U,mint:Z,mayStore:n,carried:t});if(o?.source==="hp_cookie"){let u=s();return e.getAnonymousId=()=>u.get(),u}if(o?.source==="site_cookie"&&o.cookie){let u=o.cookie;e.getAnonymousId=()=>U(u)}if(!r)return null;let i=e.getAnonymousId,a=s();return e.getAnonymousId=()=>B(M(i,null))??a.get(),a}var $r=200;function Yt(e,t,n=()=>Date.now()){let r=()=>q(O("carried"),e),o=!1;function s(){try{let i=JSON.parse(sessionStorage.getItem(r())??"null");return!i||!(n()-i.savedAt<=tt)?[]:Array.isArray(i.calls)?i.calls:[]}catch{return[]}}return{take(){let i=s();try{sessionStorage.removeItem(r())}catch{}return i},save(i){try{return o||!t()?!1:(sessionStorage.setItem(r(),JSON.stringify({savedAt:n(),calls:[...s(),...i].slice(-$r)})),!0)}catch{return!1}},close(){o=!0}}}var Fs=re.consent,ve=Object.freeze({visitor:"visitor",host:"host"}),Zt=()=>({basis:ve.host}),Vr="hp-consent",oe=["analytics","marketing","personalisation","ad_user_data","ad_personalization"],Qt={analytics:"a",marketing:"m",personalisation:"p",ad_user_data:"aud",ad_personalization:"adp"},X=()=>typeof window<"u",en=()=>X()&&typeof window.cookieStore?.addEventListener=="function",jr=e=>e===!0?!0:e===!1?!1:null;function ce(e){if(!e||typeof e!="object")return null;let t={};for(let n of oe)t[n]=jr(e[n]);return t}function rt(e,t){return!e||!t?e===t:oe.every(n=>e[n]===t[n])}function ot(e){if(!e)return"";let t=[];for(let n of oe){let r=e[n];(r===!0||r===!1)&&t.push(`${Qt[n]}=${r?1:0}`)}return t.join("&")}function tn(e){return{[Vr]:ot(ce(e))}}function ye(e){let t=ce({});if(e==null)return t;let n=String(e).trim();if(n.length>=2&&n.startsWith('"')&&n.endsWith('"')&&(n=n.slice(1,-1)),n.includes("%"))try{n=decodeURIComponent(n.replace(/\+/g," "))}catch{return t}let r=Object.fromEntries(Object.entries(Qt).map(([s,i])=>[i,s])),o=new Set;for(let s of n.split("&")){let i=s.indexOf("=");if(i<=0)continue;let a=r[s.slice(0,i).trim()],u={1:!0,0:!1}[s.slice(i+1).trim()]??null;!a||u===null||o.has(a)||(t[a]===null?t[a]=u:t[a]!==u&&(t[a]=null,o.add(a)))}return t}function st(e,t){if(!t)return e;let n=r=>{if(!r)return r;let o={...r};for(let s of oe)s!=="analytics"&&t[s]!==!0&&(o[s]=null);return o};return{name:e.name,basis:e.basis,read:()=>n(e.read()),subscribe:r=>e.subscribe(o=>r(n(o))),get observesChanges(){return e.observesChanges}}}function it(e,t={}){return{...e,ad_user_data:t.ad_user_data??e.marketing,ad_personalization:t.ad_personalization??e.marketing}}function Ee(e,t){let n=!0;return{notify:()=>{if(n)try{let o=e();o&&t(o)}catch{}},stop:()=>n=!1}}var Br={analytics:["analytics","measure_content_performance","audience_measurement"],marketing:["marketing","targeting","advertising","select_personalized_ads","create_ads_profile"],personalisation:["personalisation","personalization","select_personalized_content","create_content_profile"]};function qr(e,t){if(!t?.length)return null;let n=!1;for(let[r,o]of Object.entries(e)){let s=String(o?.id??r).toLowerCase();if(t.some(a=>{let u=String(a).toLowerCase();return s===u||s.startsWith(`${u}-`)})&&(n=!0,o?.enabled===!0))return!0}return n?!1:null}function nn(e={}){let t={...Br,...e.purposes};function n(){let r=X()?window.Didomi:void 0;if(!r?.getCurrentUserStatus||r.shouldUserStatusBeCollected?.()!==!1||r.isUserStatusPartial?.()===!0)return null;let o=r.getCurrentUserStatus()?.purposes;if(!o||typeof o!="object")return null;let s=i=>qr(o,t[i]);return it({analytics:s("analytics"),marketing:s("marketing"),personalisation:s("personalisation")},{ad_user_data:s("ad_user_data"),ad_personalization:s("ad_personalization")})}return{name:"didomi",read:n,observesChanges:!0,subscribe(r){if(!X())return()=>{};let o=Ee(n,r),s={event:"consent.changed",listener:o.notify};return window.didomiEventListeners=window.didomiEventListeners||[],window.didomiEventListeners.push(s),window.didomiOnReady=window.didomiOnReady||[],window.didomiOnReady.push(i=>{o.notify(),(i??window.Didomi)?.on?.("consent.changed",o.notify)}),window.Didomi?.on?.("consent.changed",o.notify),o.stop}}}function nt(e){let t={};if(!e)return t;for(let n of String(e).split("&")){let r=n.indexOf("=");if(r<=0)continue;let o=n.slice(r+1).replace(/\+/g," ");try{o=decodeURIComponent(o)}catch{}t[n.slice(0,r)]=o}return t}function rn(e={}){let t={analytics:"C0002",personalisation:"C0003",marketing:"C0004",...e.groups},n=e.impliedConsent===!0;function r(){let i=X()?window.OnetrustActiveGroups:void 0;if(typeof i=="string"&&i.length){let d=new Set(i.split(",").map(p=>p.trim()).filter(Boolean));return p=>d.has(p)}let a=nt(U("OptanonConsent"));if(!a.groups)return null;let u={};for(let d of a.groups.split(",")){let[p,f]=d.split(":");p?.trim()&&(u[p.trim()]=f==="1"?!0:f==="0"?!1:null)}return d=>u[d]??null}function o(){if(U("OptanonAlertBoxClosed"))return!0;try{if(X()&&window.OneTrust?.IsAlertBoxClosed?.()===!0)return!0}catch{}return Number.parseInt(nt(U("OptanonConsent")).interactionCount,10)>0?!0:n&&X()&&(!!window.OneTrust||typeof window.OnetrustActiveGroups=="string")}function s(){if(!o())return null;let i=r();if(!i)return null;let a=f=>t[f]?i(t[f]):null,u=it({analytics:a("analytics"),marketing:a("marketing"),personalisation:a("personalisation")},{ad_user_data:a("ad_user_data"),ad_personalization:a("ad_personalization")}),d=nt(U("OptanonConsent"));return(typeof navigator<"u"&&navigator.globalPrivacyControl===!0||d.isGpcEnabled==="1")&&(u.marketing=!1,u.ad_user_data=!1,u.ad_personalization=!1),u}return{name:"onetrust",read:s,observesChanges:!0,subscribe(i){if(!X())return()=>{};let a=Ee(s,i),u=!1,d=()=>{u||!window.OneTrust?.OnConsentChanged||(u=!0,window.OneTrust.OnConsentChanged(a.notify))};window.addEventListener("OneTrustGroupsUpdated",a.notify);let p=window.OptanonWrapper;return window.OptanonWrapper=function(...m){try{typeof p=="function"&&p.apply(this,m)}finally{d(),a.notify()}},d(),()=>{a.stop(),window.removeEventListener("OneTrustGroupsUpdated",a.notify)}}}}function Fr(e){let t=String(e).split(",").map(n=>n.trim()).filter(Boolean);return t.length?new Set(t):null}function on(e){let{name:t,categories:n,parse:r=Fr,refusedValue:o,source:s="native",changeEvent:i="thg_hp_consent_change"}=e??{};if(typeof t!="string"||t==="")throw new Error("cookieConsent: `name` (the cookie your banner writes) is required");if(!n||typeof n.analytics!="string")throw new Error("cookieConsent: `categories.analytics` (the category id that grants analytics) is required");function a(){let u=U(t);if(u==null)return null;let d;if(o!==void 0&&u===o)d=new Set;else try{d=r(u)}catch{d=null}if(!(d instanceof Set))return null;let p=f=>n[f]?d.has(n[f]):null;return it({analytics:p("analytics"),marketing:p("marketing"),personalisation:p("personalisation")},{ad_user_data:p("ad_user_data"),ad_personalization:p("ad_personalization")})}return{name:s,read:a,get observesChanges(){return en()},subscribe(u){if(!X())return()=>{};let d=Ee(a,u),p=f=>{[...f.changed??[],...f.deleted??[]].some(b=>b?.name===t)&&d.notify()};return window.addEventListener(i,d.notify),window.cookieStore?.addEventListener?.("change",p),()=>{d.stop(),window.removeEventListener(i,d.notify),window.cookieStore?.removeEventListener?.("change",p)}}}}function sn(e={}){let t=e.name??O("consent"),n=()=>{let r=U(t);if(r==null)return null;let o=ye(r);return o.analytics==null?null:o};return{name:"forwarded",read:n,get observesChanges(){return en()},subscribe(r){if(!X())return()=>{};let o=Ee(n,r),s=i=>{[...i.changed??[],...i.deleted??[]].some(u=>u?.name===t)&&o.notify()};return window.cookieStore?.addEventListener?.("change",s),()=>{o.stop(),window.cookieStore?.removeEventListener?.("change",s)}}}}function an(e){let t=ce(e);return{name:"static",basis:ve.host,read:()=>t?{...t}:null,observesChanges:!0,subscribe:()=>()=>{}}}function cn(e){if(e==null)return null;let t=String(e).split("/").map(n=>n.trim()).filter(Boolean).join("/");return t===""?null:t}function Hr(e){let t=e.item_category;if(t!=null&&String(t).includes("/"))return cn(t);let n=[t,e.item_category2,e.item_category3,e.item_category4,e.item_category5].map(r=>r==null?"":String(r).trim()).filter(Boolean);return cn(n.join("/"))}var Kr=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t};function Gr(...e){for(let t of e){if(typeof t=="number"&&Number.isFinite(t))return String(t);if(typeof t=="string"&&t.trim()!=="")return t.trim()}return null}var Ce=e=>Gr(e.item_group_id,e.item_id);function Wr(e,t=Ce){if(!e)return null;let n=a=>a==null||a===""||Number.isNaN(Number(a))?null:Number(a),r=a=>{let u=n(a);return u==null?null:Math.round(u*1e6)/1e6},o=a=>{let u=r(a);return u!=null&&u>=0?u:null},s=a=>{let u=n(a);return Number.isInteger(u)&&u>=0?u:null},i=Kr;return{product_id:i(t(e)),sku:i(e.item_id),name:i(e.item_name),brand:i(e.item_brand),variant:i(e.item_variant)??i(e.variant),category:Hr(e),price:r(e.price),discount:o(e.discount),quantity:s(e.quantity),coupon:i(e.coupon),position:s(e.index)!=null?s(e.index)+1:null,url:i(e.url)??i(e.item_url)??null,image_url:i(e.image_url)??i(e.image_link)??null,displayed_sku:i(e.displayed_sku)??i(e.displayed_variant_sku)}}function at(e,t=Ce){return(e??[]).map(n=>Wr(n,t)).filter(n=>n?.product_id)}var zr=1e3,Jr={shipping:2,payment:3},Xr=new Set(["password","google","apple","facebook","magic_link","sso","passkey","other"]),$=e=>{if(e==null||typeof e=="object")return null;let t=String(e).trim();return t===""?null:t},Yr=e=>{if(e==null||e===""||typeof e=="object")return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null},Pe=e=>e!==null&&typeof e=="object";function Zr(e){return Array.isArray(e.items)?e.items.filter(Pe):null}function un(e){let t=$(e)?.toLowerCase().replace(/[\s-]+/g,"_");return t?Xr.has(t)?t:t==="email"||t==="email_password"?"password":"other":null}function Qr({ecommerce:e,items:t}){let n=s=>({promotion_id:$(s.promotion_id),name:$(s.promotion_name),creative:$(s.creative_name),position:$(s.creative_slot)}),r=new Set,o=[];for(let s of[n(e),...t.map(n)])!s.promotion_id||r.has(s.promotion_id)||(r.add(s.promotion_id),o.push(s));return o}var ln=({ecommerce:e,items:t})=>$(e.item_list_id)??$(e.item_list_name)??$(t[0]?.item_list_id)??$(t[0]?.item_list_name),se=(e,t)=>t.products?.length?{event:e,properties:t}:null,eo=new Set(["product","products","item","items"]);function to({ecommerce:e}){let t=$(e.item_id),n=$(e.content_type)?.toLowerCase();return!t||n&&!eo.has(n)?null:{event:"Product Shared",properties:{share_via:$(e.method),products:[{product_id:t}]}}}function no(e){let t=o=>se("Product List Viewed",{list_id:ln(o),products:o.products}),n=o=>{let s=$(o.ecommerce.search_term);return s?{event:"Products Searched",properties:{query:s,...o.products.length?{products:o.products}:{}}}:null},r=o=>s=>s.promotions.map(i=>({event:o,properties:i}));return{view_item:o=>se("Product Viewed",{currency:o.currency,value:o.value,products:o.products.slice(0,1)}),view_item_list:t,view_search_results:o=>n(o)??t(o),search:n,select_item:o=>se("Product Clicked",{list_id:ln(o),products:o.products.slice(0,1)}),add_to_cart:o=>se("Product Added",{cart_id:$(o.ecommerce.cart_id),products:o.products}),remove_from_cart:o=>se("Product Removed",{cart_id:$(o.ecommerce.cart_id),products:o.products}),view_cart:o=>({event:"Cart Viewed",properties:{cart_id:$(o.ecommerce.cart_id),value:o.value,currency:o.currency,coupon:$(o.ecommerce.coupon),...o.itemsListed?{products:o.products}:{}}}),begin_checkout:o=>se("Checkout Started",{value:o.value,currency:o.currency,coupon:$(o.ecommerce.coupon),products:o.products}),add_shipping_info:o=>({event:"Checkout Step Completed",properties:{step:e.shipping,step_name:"shipping",shipping_method:$(o.ecommerce.shipping_tier)}}),add_payment_info:o=>({event:"Payment Info Entered",properties:{step:e.payment,step_name:"payment",payment_method:$(o.ecommerce.payment_type)}}),view_promotion:r("Promotion Viewed"),select_promotion:r("Promotion Clicked"),add_to_wishlist:o=>se("Product Added to Wishlist",{products:o.products}),share:to,login:o=>({event:"Signed In",properties:{method:un(o.ecommerce.method)}}),sign_up:o=>({event:"Signed Up",properties:{method:un(o.ecommerce.method)}})}}var ro=e=>e.event;function oo(e,t){if(!Pe(e))return null;if(typeof e.length=="number"&&e[0]==="event"&&typeof e[1]=="string"){let r=Pe(e[2])?e[2]:{};return{name:e[1],entry:r,ecommerce:r}}let n=$(t(e));return n?{name:n,entry:e,ecommerce:Pe(e.ecommerce)?e.ecommerce:e}:null}function ct(e){return Array.isArray(e)?`[${e.map(ct).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${ct(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function dn(e,t={}){if(!e||typeof e.track!="function")throw new Error("connectDataLayer: analytics must have a track(event, properties, options) method");let n=t.dataLayer??(typeof window<"u"?window.dataLayer=window.dataLayer||[]:null);if(!Array.isArray(n))return()=>{};let r=no({...Jr,...t.steps}),o=t.map??{},s=t.eventName??ro,i=t.productId??Ce,a=new Set(["purchase","refund",...t.ignore??[]]),u=t.dedupeMs??zr,d=new Map,p=!0;function f(S,y,w){if(u<=0)return!1;let L=`${S}|${w??""}|${ct(y)}`,D=Date.now();for(let[H,K]of d)D-K>u&&d.delete(H);return d.has(L)?!0:(d.set(L,D),!1)}let m=null,b=new Set;function g(S,y){if(S!=="Product Viewed")return!1;let w=typeof location>"u"?"":location.pathname;w!==m&&(m=w,b.clear());let L=y.products?.[0]?.product_id;return L?b.has(L)?!0:(b.add(L),!1):!1}function _({event:S,properties:y={}},w){if(!S||f(S,y,w)||g(S,y))return;let L=w?{context:{currency:w}}:void 0;if(S==="Signed Out"&&typeof e.signedOut=="function"){e.signedOut(L);return}e.track(S,y,L)}function x(S){let y=t.transform?t.transform(S):S,w=oo(y,s);if(!w||a.has(w.name))return;let L=Object.hasOwn(o,w.name),D=L?o[w.name]:r[w.name];if(typeof D!="function")return;let H=Zr(w.ecommerce),K=H??[],F={...w,items:K,itemsListed:H!==null,products:at(K,i),currency:Ze(w.ecommerce.currency),value:Yr(w.ecommerce.value)};F.promotions=Qr(F);let I=L?D(y,{...F,toProducts:G=>at(G,i)}):D(F);for(let G of[I].flat())G&&_(G,F.currency)}function v(S){if(p)try{x(S)}catch(y){try{t.onError?.(y,S)}catch{}}}for(let S of n.slice())v(S);let h=n.push;function E(...S){let y=h.apply(this,S);for(let w of S)v(w);return y}return n.push=E,()=>{p=!1,n.push===E&&(n.push=h)}}var so="hp_debug",io=256;function ao(){try{return new URLSearchParams(location.search).get(so)}catch{return null}}function fn(e,t){if(typeof location>"u")return!1;try{let n=ao();if(n!==null){let o=n.trim();o===""||o.length>io?sessionStorage.removeItem(t):sessionStorage.setItem(t,o)}let r=sessionStorage.getItem(t);return!!(e&&r&&Nt(r)===e)}catch{return!1}}var co=4320*60*60,uo=100,lo=1e3,fo=2e3,pn=500,Le=e=>(e?.unref?.(),e);function po(e,t){if(t?.analytics===!0&&e.analytics===!1)return"withdrawn";let n=oe.map(r=>e[r]).filter(r=>r!==null);return n.length&&n.every(Boolean)?"accept_all":n.length&&n.every(r=>!r)?"reject_all":"custom"}function mo(e,t,n=O("consent")){if(!(typeof document>"u"))try{let r=typeof location<"u"&&location.protocol==="https:"?"; Secure":"",o=t?`; Domain=${t}`:"";document.cookie=`${n}=${ot(e)}; Path=/; Max-Age=${co}; SameSite=Lax`+o+r}catch{}}function ho(e){let t=ye(U(e));return oe.some(n=>t[n]!==null)?t:null}function mn(e){let{adapter:t,timeoutMs:n=5e3,cookieDomain:r=null,cookieName:o=O("consent"),release:s,announce:i}=e,a=e.discard??(()=>{}),u="pending",d=null,p=null,f=null,m=null,b=!1,g=null,_=[],x=R=>{u=R,e.onStatus?.(R)};function v(){try{return ce(t.read())}catch{return null}}function h(){p&&clearInterval(p),f&&clearTimeout(f),p=null,f=null}let E=()=>typeof window<"u"&&typeof document<"u",S=()=>{try{return typeof t.subscribe=="function"&&t.observesChanges===!0}catch{return!1}};function y(){m&&clearInterval(m),m=null}function w(){b||m||d===null||S()||E()&&document.visibilityState==="hidden"||(m=Le(setInterval(()=>F(v()),fo)))}let L=()=>u==="pending"||u==="unknown",D=e.store??null,H=()=>{let R=_.splice(0);D?.write([]);for(let j of R)s(j)},K=()=>{let R=_.splice(0);D?.write([]);for(let j of R)a(j)};function F(R){let j=ce(R);if(!j||j.analytics===null)return;let c=d===null,l=c?ho(o):d;if(!c&&rt(l,j))return;h(),d=j,w(),mo(j,r,o);let k=!rt(l,j);if(j.analytics){x("granted"),H(),k&&i({action:po(j,l),state:j,withdrawal:!1});return}K(),l?.analytics===!0&&i({action:"withdrawn",state:j,withdrawal:!0}),x("denied")}function I(){f=null,u==="pending"&&(x("unknown"),p&&clearInterval(p),p=Le(setInterval(()=>F(v()),lo)))}function G(R){L()&&(D||R?.type!=="visibilitychange"&&!R?.persisted&&K())}let we=R=>{document.visibilityState==="hidden"?(y(),G(R)):w()},me=R=>{y(),G(R)},he=()=>w();return{get status(){return u},get state(){return d?{...d}:null},stamp(){return d?{...d,source:t.name??null,basis:t.basis??ve.visitor}:null},admits(){return u==="granted"},hold(R){return!L()||_.length>=pn?(a(R),!1):(_.push(R),D?.write(_),!0)},onHidden:G,start(){b=!1;try{g=t.subscribe?.(R=>F(R))??null}catch(R){e.debug&&console.warn("[hp] consent adapter subscribe failed",R)}E()&&(window.addEventListener("pagehide",me),window.addEventListener("pageshow",he),document.addEventListener("visibilitychange",we)),D&&_.length===0&&_.push(...D.read().slice(-pn)),F(v()),!d&&(p=Le(setInterval(()=>F(v()),uo)),f=Le(setTimeout(I,n)))},stop(){b=!0,h(),y(),typeof g=="function"&&g(),E()&&(window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",he),document.removeEventListener("visibilitychange",we))}}}var go=["recommendation","search_rank","banner","offer","layout","copy","price","other"],Oe=e=>typeof e=="string"&&e!=="";function hn(e){return(Array.isArray(e?.decisions)?e.decisions:[]).filter(t=>Oe(t?.slot)&&Oe(t.decision_id)&&t.holdout!==!0).map(({decision_id:t,slot:n,arm:r,kind:o})=>({decision_id:t,slot:n,...Oe(r)&&{arm:r},...go.includes(o)&&{kind:o}}))}function gn({key:e,mayStore:t}){let n,r=()=>{if(n)return n;try{let s=JSON.parse(sessionStorage.getItem(e));n=Array.isArray(s)?s.filter(i=>Oe(i?.slot)):[]}catch{n=[]}return n},o=()=>{try{n?.length&&t()&&sessionStorage.setItem(e,JSON.stringify(n))}catch{}};return{persist:o,current:()=>r().length?n.map(s=>({...s})):null,remember(s){if(!s.length)return;let i=new Set(s.map(a=>a.slot));n=[...r().filter(a=>!i.has(a.slot)),...s],o()},forget(){n=[];try{sessionStorage.removeItem(e)}catch{}}}}function yo(e){let t=2166136261,n=String(e);for(let r=0;r<n.length;r+=1)t^=n.charCodeAt(r),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t^=t>>>16,t=Math.imul(t,2246822507)>>>0,t^=t>>>13,t=Math.imul(t,3266489909)>>>0,t^=t>>>16,t>>>0}function Ne(e,t,n=1e4){return yo(`${t}\0${e}`)%n}function ut(e){let t=o=>Math.min(Math.max(Number(o)||0,0),1),n=t(e.share),r=1-n;return{holdout_share:n,personalised_share:e.ramp==null?r:Math.min(t(e.ramp),r)}}function lt(e,t){if(!e||typeof e.salt!="string")return{holdout:!1,bucket:null,group:"personalised"};let n=e.ramp!=null;if(t==null||t==="")return{holdout:!1,bucket:null,group:n?"excluded":"personalised"};let{holdout_share:r,personalised_share:o}=ut(e),s=Ne(t,e.salt),i=u=>Math.round(u*1e4),a=r>0&&s<i(r)?"holdout":!n||s<i(r+o)?"personalised":"excluded";return{holdout:a==="holdout",bucket:s,group:a}}function yn(e,t){return typeof e!="string"||e===""||t==null||t===""?null:Ne(t,`bandit-vs-default:${e}`)<1e4/2?"default":"bandit"}var So="hp_preview",wo=256;function Sn(e,t=null){if(typeof location>"u")return U(e);let n=null;try{n=new URLSearchParams(location.search).get(So)}catch{n=null}if(n===null)return U(e);let r=n.trim();return r===""||r.length>wo?(Q(e,"",0,t),null):(Q(e,r,null,t),r)}var _o=40,bo=128,xo=5,Io=60,_n=e=>typeof e=="string"&&e!==""&&e.length<=bo&&!e.includes(","),wn=e=>Array.isArray(e)?e.filter(_n).slice(0,_o):[],Ao=e=>Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.replaceAll(","," ").trim()).filter(t=>t!=="").slice(0,xo):[],ko=e=>Object.entries(e&&typeof e=="object"?e:{}).filter(([t,n])=>_n(t)&&Number.isFinite(n)&&n>=1).sort(([,t],[,n])=>n-t).slice(0,Io).map(([t,n])=>`${t}:${Math.floor(n)}`);function dt(e){let t={},n={viewed:wn(e?.recentProducts),basket:wn(e?.basketProducts),q:Ao(e?.recentSearches),impressed:ko(e?.impressions)};for(let[r,o]of Object.entries(n))o.length>0&&(t[r]=o.join(","));return t}var vo=1800*1e3;function bn(e,t=Date.now()){try{localStorage.setItem(O("recommendationContext"),JSON.stringify({context:e,until:t+vo}))}catch{}}function xn(){try{localStorage.removeItem(O("recommendationContext"))}catch{}}var Eo="hp_sample",In=1e4;function An(e,t){return!(typeof t=="number"&&t<1)||e==null||e===""?!0:Ne(e,Eo,In)<Math.round(t*In)}function ft(e){return e.trim().toLowerCase().replace(/\s*\/\s*/g,"/").replace(/^\/+|\/+$/g,"")}var Co=2,Po=12;function Lo(e,t=Co){return e.split("/").slice(0,t).join("/")}function ue(e,t){if(typeof t!="string"||!t.trim())return null;let n=Lo(ft(t));return n?(e.unshift(n),e.length=Math.min(e.length,Po),n):null}var ie=()=>O("sessionSignals"),le=null,pt=()=>le??ie();function kn(){try{return le?localStorage:sessionStorage}catch{return}}function vn(e,t){let n=t==null?null:String(t),r=e?q(ie(),n,e):null;if(r===le)return;let o=le===null?Oo():null;if(le=r,!!le)try{let s=pt(),i=zt(ie(),n);for(let a of Object.keys(localStorage))a.startsWith(i)&&a!==s&&localStorage.removeItem(a);o&&!localStorage.getItem(s)&&(localStorage.setItem(s,JSON.stringify(o)),sessionStorage.removeItem(ie()))}catch{}}function Oo(){try{let e=sessionStorage.getItem(ie());if(!e)return null;let t=JSON.parse(e);return t&&(t.productViews>0||t.listViews>0||t.basketValue!=null||t.recentProducts?.length||t.recentBrowse?.length)?t:null}catch{return null}}function Te(){return{productViews:0,listViews:0,cartAdds:0,searches:0,recentProducts:[],recentCategories:[],recentBrowse:[],basketProducts:[],basketValue:null,recentSearches:[],impressions:{},browsingCategory:null,startedAt:0}}function mt(){let e=kn();if(!e)return Te();try{let t=e.getItem(pt());return t?{...Te(),...JSON.parse(t)}:{...Te(),startedAt:Date.now()}}catch{return{...Te(),startedAt:Date.now()}}}function ht(e){let t=kn();if(t)try{t.setItem(pt(),JSON.stringify(e))}catch{}}function En(){return mt()}function Cn(){for(let e of[()=>sessionStorage,()=>localStorage])try{let t=e();t.removeItem(ie());for(let n of Object.keys(t))n.startsWith(`${ie()}:`)&&t.removeItem(n)}catch{}}var Pn=20,Ln=200,No=new Set(["Product Viewed","Product Clicked","Product Added","Product Added to Wishlist"]),To=new Set(["Product Clicked","Product Added to Wishlist"]);function On(e,t){let n=mt();n.startedAt||(n.startedAt=Date.now());let r=Array.isArray(t?.products)?t.products:[];switch(e){case"Product Viewed":n.productViews+=1,ue(n.recentBrowse,n.browsingCategory);break;case"Product List Viewed":n.listViews+=1;{let i=t?.list_id;typeof i=="string"&&i.includes("/")&&!i.startsWith("cdp-")&&(n.browsingCategory=ue(n.recentBrowse,i)??n.browsingCategory)}break;case"Product List Filtered":{let i=t?.change,a=typeof t?.list_id=="string"?t.list_id:"",u=typeof i?.value=="string"?i.value:"";u&&i?.action!=="removed"&&(n.browsingCategory=ue(n.recentBrowse,`${a}/${u}`)??n.browsingCategory);break}case"Product Added":{n.cartAdds+=1,ue(n.recentBrowse,n.browsingCategory);for(let i of r){let a=i.product_id;typeof a!="string"||!a||(n.basketProducts=[a,...n.basketProducts.filter(u=>u!==a)].slice(0,Pn))}break}case"Product Removed":{for(let i of r){let a=i.product_id;typeof a=="string"&&a&&(n.basketProducts=n.basketProducts.filter(u=>u!==a))}break}case"Products Searched":{n.searches+=1;let i=t?.query;if(typeof i=="string"&&i.trim()){let a=i.trim().toLowerCase().slice(0,64);n.recentSearches=[a,...n.recentSearches.filter(u=>u!==a)].slice(0,5)}break}case"Product Clicked":case"Product Added to Wishlist":break;case"Cart Updated":{let i=t?.value;return n.basketValue=typeof i=="number"&&Number.isFinite(i)&&i>=0?i:null,ht(n),n}default:return n}let o=No.has(e);if(o)for(let i of r)typeof i.product_id=="string"&&i.product_id&&delete n.impressions[i.product_id];else{for(let a of r){let u=a.product_id;typeof u!="string"||!u||(n.impressions[u]=(n.impressions[u]??0)+1)}let i=Object.keys(n.impressions);if(i.length>Ln){let a={};for(let u of i.sort((d,p)=>n.impressions[p]-n.impressions[d]).slice(0,Ln))a[u]=n.impressions[u];n.impressions=a}}let s=new Set;for(let i of r){let a=i.product_id;if(o&&typeof a=="string"&&a&&(n.recentProducts=[a,...n.recentProducts.filter(u=>u!==a)].slice(0,Pn)),!To.has(e)&&typeof i.category=="string"&&i.category){let u=ft(i.category);u&&!s.has(u)&&(s.add(u),ue(n.recentCategories,u))}}return ht(n),n}var Nn=1800*1e3;function Tn({name:e,domain:t=null,mayStore:n,now:r=()=>Date.now(),mint:o=Z}){let s=null,i=0,a=()=>{s!==null&&n()&&Q(e,s,Nn/1e3,t)};return{get(){let u=r(),d=U(e);return d?s=d:(s===null||u-i>=Nn)&&(s=o()),i=u,a(),s},persist:a,forget(){Q(e,"",0,t),s=null}}}var J=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Rn=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),yt=Object.freeze({enabled:!1});function Dn(e,t){let n=e?.track;return J(n)?(Object.hasOwn(n,t)?n[t]:n.__default)?.enabled!==!1:!0}function Ro(e,t){return`${de(e)}/v1/projects/${encodeURIComponent(t)}/settings`}var Do="https://hp.thgingenuity.com";function de(e){return e==null||e===""?Do:Mn(e)}function Mn(e){if(typeof e!="string")return null;let t=e.trim().replace(/\/+$/,"");return/^https?:\/\/[^/\s]+$/i.test(t)?t:/^[a-z0-9.-]+(:\d+)?$/i.test(t)?`https://${t}`:null}function Mo(e){if(!J(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>typeof n=="boolean"));return Object.keys(t).length?t:null}var gt=e=>typeof e=="number"&&e>=0&&e<=1,Uo=/^[0-9a-f]{64}$/;function $o(e){return J(e)?{enabled:e.enabled===!0,tokenSha256:typeof e.tokenSha256=="string"&&Uo.test(e.tokenSha256)?e.tokenSha256:null}:{enabled:!1,tokenSha256:null}}function Vo(e){if(!J(e))return null;let t=Object.fromEntries(Object.entries(e).filter(([,n])=>J(n)&&gt(n.share)&&(n.ramp==null||gt(n.ramp))&&typeof n.salt=="string"&&n.salt!=="").map(([n,r])=>[n,{share:r.share,ramp:r.ramp??null,salt:r.salt,...Rn(r.readoutSlots)&&r.readoutSlots.length>0&&{readoutSlots:r.readoutSlots}}]));return Object.keys(t).length?t:null}var jo=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;function Bo(e){return J(e)?e.source==="hp_cookie"?{source:"hp_cookie"}:e.source!=="site_cookie"?null:e.cookie==null?{source:"site_cookie",cookie:null}:typeof e.cookie=="string"&&jo.test(e.cookie)?{source:"site_cookie",cookie:e.cookie}:null:null}function St(e){let t=J(e)?e.hp:null;return!J(t)||t.enabled!==!0?yt:{enabled:!0,propertyId:typeof t.propertyId=="string"&&t.propertyId!==""?t.propertyId:null,environment:typeof t.environment=="string"?t.environment:null,consentPurposes:Mo(t.consent?.purposes),queryParamAllowlist:Rn(t.queryParamAllowlist)?t.queryParamAllowlist:null,anonymousId:Bo(t.anonymousId),apiHost:Mn(t.apiHost),holdouts:Vo(t.holdouts),sampleRate:gt(t.sampleRate)?t.sampleRate:1,debug:$o(t.debug),plan:J(e.plan)&&J(e.plan.track)?{track:e.plan.track}:null}}async function Un(e,t,n=globalThis.fetch){try{let r=await n(Ro(e,t),{credentials:"omit",headers:{accept:"application/json"}});return r.ok?St(await r.json()):null}catch{return null}}var Re=e=>q(O("settings"),e);function $n(e){try{let t=localStorage.getItem(Re(e));if(!t)return null;let n=JSON.parse(t);return n?.enabled===!0?n:null}catch{return null}}function Vn(e,t){try{t?.enabled===!0?localStorage.setItem(Re(e),JSON.stringify(t)):localStorage.removeItem(Re(e))}catch{}}function wt(e){try{localStorage.removeItem(Re(e))}catch{}}var qo={flushAt:20,flushIntervalMs:1e4,maxQueue:500,maxRetryAgeMs:1440*60*1e3,maxRetries:5,maxPersistedBatches:20,maxPersistedBytes:1024*1024,storageKey:re.retry,beaconSafeBytes:56*1024,maxBatchEvents:100,maxBatchBytes:500*1024},_t=()=>Date.now(),fe=e=>typeof TextEncoder<"u"?new TextEncoder().encode(e).length:Buffer.byteLength(e),bt=()=>typeof window<"u"&&typeof document<"u";function Fo(){try{return!bt()||!window.localStorage?null:(window.localStorage.getItem("thg_hp_probe"),window.localStorage)}catch{return null}}var A,xt,jn,De,It,At,Bn,Se,kt,Me,qn,vt,Fn,Ue,$e=class{constructor(t){Lt(this,A);this.o={...qo,...t},this.queue=[],this.timer=null,this.storage=Fo(),this.inflight=null,this.sending=new Set,this.replayAllowed=!this.o.deferReplay,this.draining=null,bt()&&(window.addEventListener("pagehide",()=>this.flush({beacon:!0})),document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flush()}),N(this,A,Ue).call(this))}replayPersisted(){return this.replayAllowed=!0,N(this,A,Ue).call(this)}clearPersisted(){if(this.replayAllowed=!1,!!this.storage)try{this.storage.removeItem(this.o.storageKey)}catch{}}enqueue(t){let n;try{n=JSON.parse(JSON.stringify(t))}catch(r){this.o.onError?.(`event ${t?.messageId??""} cannot be serialised; dropped`,r);return}this.queue.push(n),this.queue.length>this.o.maxQueue&&this.queue.splice(0,this.queue.length-this.o.maxQueue),this.queue.length>=this.o.flushAt?this.flush():N(this,A,xt).call(this)}flush(t={}){if(N(this,A,jn).call(this),this.queue.length===0)return Promise.resolve();if(t.beacon&&bt()&&typeof navigator<"u"&&navigator.sendBeacon)return N(this,A,Bn).call(this),Promise.resolve();if(this.inflight)return this.inflight;let n=N(this,A,At).call(this,this.queue,this.o.maxBatchEvents,this.o.maxBatchBytes).map(r=>{let o=N(this,A,vt).call(this,r);return o&&this.sending.add(o),{batch:r,id:o}});return this.queue=[],this.inflight=(async()=>{for(let{batch:r,id:o}of n)await N(this,A,Se).call(this,r,0,o)})().finally(()=>{this.inflight=null,this.queue.length>=this.o.flushAt?this.flush():this.queue.length&&N(this,A,xt).call(this)}),this.inflight}};A=new WeakSet,xt=function(){this.timer||(this.timer=setTimeout(()=>this.flush(),this.o.flushIntervalMs),this.timer?.unref?.())},jn=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},De=function(t){return JSON.stringify({batch:t,writeKey:this.o.writeKey,sentAt:new Date().toISOString()})},It=function(){return`${this.o.apiHost.replace(/\/$/,"")}/v1/batch`},At=function(t,n,r){let o=fe(N(this,A,De).call(this,[])),s=[],i=[],a=o;for(let u of t){let d=fe(JSON.stringify(u))+1;i.length&&(i.length>=n||a+d>r)&&(s.push(i),i=[],a=o),i.push(u),a+=d}return i.length&&s.push(i),s},Bn=function(){let t=this.queue;this.queue=[];let n=N(this,A,It).call(this);for(let r of N(this,A,At).call(this,t,this.o.maxBatchEvents,this.o.beaconSafeBytes)){let o=N(this,A,De).call(this,r);if(fe(o)<=this.o.beaconSafeBytes){let s=!1;try{s=navigator.sendBeacon(n,new Blob([o],{type:"text/plain"}))}catch{s=!1}if(s)continue}N(this,A,Se).call(this,r,0,N(this,A,vt).call(this,r))}},Se=async function(t,n,r=null){r&&this.sending.add(r);let o=N(this,A,De).call(this,t);try{let s=await fetch(N(this,A,It).call(this),{method:"POST",headers:{"Content-Type":"text/plain"},body:o,keepalive:fe(o)<=this.o.beaconSafeBytes});if(s.ok)return N(this,A,kt).call(this,r),N(this,A,Ue).call(this),!0;if(!(s.status===429||s.status>=500))return N(this,A,kt).call(this,r),this.o.onError?.(`CDP ingest rejected batch (${s.status}); dropping ${t.length} events`),!0;throw new Error(`retryable ${s.status}`)}catch(s){if(n>=this.o.maxRetries){r&&this.sending.delete(r);let a=r?"kept for the next page":"dropped";return this.o.onError?.(`CDP ingest unreachable after ${n} attempts; ${a}: ${t.length} events`,s),!1}let i=Math.min(1e3*2**n,3e4)*(.5+Math.random());return await new Promise(a=>setTimeout(a,i)),N(this,A,Se).call(this,t,n+1,r)}},kt=function(t){t&&(this.sending.delete(t),N(this,A,Fn).call(this,t))},Me=function(){let t=JSON.parse(this.storage.getItem(this.o.storageKey)||"[]");return Array.isArray(t)?t:[]},qn=function(t,n){let r=i=>fe(JSON.stringify(i))+1,o=[...t,n].slice(-this.o.maxPersistedBatches),s=o.reduce((i,a)=>i+r(a),2);for(;o.length>1&&s>this.o.maxPersistedBytes;)s-=r(o[0]),o=o.slice(1);for(;o.length;)try{return this.storage.setItem(this.o.storageKey,JSON.stringify(o)),!0}catch{o=o.slice(1)}return!1},vt=function(t){if(!this.storage||this.o.mayPersist&&!this.o.mayPersist())return null;try{let n={at:_t(),id:`${_t()}-${Math.random().toString(36).slice(2)}`,batch:t};return fe(JSON.stringify(n))+3>this.o.maxPersistedBytes?null:N(this,A,qn).call(this,N(this,A,Me).call(this),n)?n.id:null}catch{return null}},Fn=function(t){if(!(!t||!this.storage))try{let n=N(this,A,Me).call(this).filter(r=>r.id!==t);n.length?this.storage.setItem(this.o.storageKey,JSON.stringify(n)):this.storage.removeItem(this.o.storageKey)}catch{}},Ue=function(){if(!this.storage||!this.replayAllowed)return this.draining??Promise.resolve();if(this.draining)return this.draining;let t;try{let r=N(this,A,Me).call(this);t=r.filter(o=>Array.isArray(o?.batch)&&_t()-o.at<this.o.maxRetryAgeMs).map(o=>o.id?o:{...o,id:`${o.at}-${Math.random().toString(36).slice(2)}`}),(t.length!==r.length||t.some((o,s)=>o!==r[s]))&&(t.length?this.storage.setItem(this.o.storageKey,JSON.stringify(t)):this.storage.removeItem(this.o.storageKey))}catch{return Promise.resolve()}let n=t.filter(r=>!this.sending.has(r.id));return n.length?(this.draining=(async()=>{for(let r of n)if(!this.replayAllowed||!await N(this,A,Se).call(this,r.batch,0,r.id))return})().finally(()=>{this.draining=null}),this.draining):Promise.resolve()};var Hn="3.18.0",Kn="@thg-agentic/hyper-personalisation-web";var Ho=new Set(["audiences","decisions","recommendations"]);var Ko=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Ve=class extends Error{};function Go(e){let t={...e??{}},n=Array.isArray(t.products)?t.products:null;if(t.item_count==null&&n){let r=n.map(o=>o?.quantity);r.every(Number.isInteger)&&(t.item_count=r.reduce((o,s)=>o+s,0))}return t}var Wo="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";function zo(e){if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(!/^[A-Za-z0-9+/_-]{43}=?$/.test(e))return null;try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(44,"="));return t.length!==32?null:Array.from(t,n=>n.charCodeAt(0).toString(16).padStart(2,"0")).join("")}catch{return null}}function je(e){if(typeof e!="string")return null;let t=zo(e.trim());return t===Wo?null:t}var Gn=!1;function Jo(e){!e||Gn||(Gn=!0,console.warn("[hp] mintAnonymousId is ignored since 3.6: where device ids come from is set per source in the console (the site\u2019s own cookie, or Hyper-Personalisation\u2019s)."))}function Wn(e){return e&&typeof e.context=="object"&&e.context!==null?e.context:e}function zn(e){let t=de(e?.apiHost);if(!t)throw new Error("createAnalytics: apiHost, when given, must be a host or an http(s) origin");if(!e?.propertyId)throw new Error("createAnalytics: propertyId is required");let n={libraryName:Kn,libraryVersion:Hn,writeKey:"web",queryParamBlocklist:[],debug:!1,validate:null,consentTimeoutMs:5e3,...e,apiHost:t};Ie(n.storageNames),Ae();let r=!!n.consent,o=null;n.getConsent=()=>o?o.stamp():Zt();let s=()=>!r||o?.status==="granted",i=r&&n.holdAcrossPages?Jt(q(O("held"),n.propertyId)):null,a=i?.read()??{items:[],anonymousId:null};n.mintAnonymousId!==void 0&&Jo(n.debug);let u=Xt(n,{carried:a.anonymousId,mayStore:s,orOwn:!0}),d=Tn({name:O("session"),domain:n.consentCookieDomain??null,mayStore:s}),p=n.getSessionId;n.getSessionId=()=>B(M(p,null))??d.get();let f=Sn(O("preview"),n.consentCookieDomain??null),m=n.transport??new $e({apiHost:n.apiHost,writeKey:n.writeKey,storageKey:q(O("retry"),n.propertyId),mayPersist:r?()=>o?.status==="granted":void 0,deferReplay:r,onError:(c,l)=>n.debug&&console.warn("[hp]",c,l??"")}),b=q(O("previousPage"),n.propertyId),g=null,_=()=>{if(g)return g;try{return sessionStorage.getItem(b)||null}catch{return null}},x=c=>{if(g=c||null,!(r&&o.status!=="granted"))try{sessionStorage.setItem(b,c)}catch{}},v=gn({key:q(O("decisions"),n.propertyId),mayStore:s});n.getDecisions??(n.getDecisions=v.current);let h=B(M(n.getUserId,null)),E=null;function S(c,l,k=!1){try{return y(c,l,k)}catch(P){if(P instanceof Ve)throw P;return console.warn("[hp] the event was not sent",P),null}}function y(c,l,k){let P=E;E=null;let C={messageId:P?.messageId??Z(),timestamp:P?.timestamp??new Date().toISOString(),anonymousId:B(M(n.getAnonymousId,null)),userId:h??null,...c,context:Ht(n,Wn(l))};if(C.properties&&(C.properties=Xe(C.properties)),!k&&!An(C.anonymousId,n.sampleRate))return n.debug&&console.debug("[hp] not sent: outside the sample",C),null;if(n.beforeSend){let W;try{W=n.beforeSend(C)}catch(sr){return console.warn("[hp] beforeSend failed; the event was not sent",sr),null}if(!W)return null;let{type:_e,event:Ct,messageId:rr,timestamp:or}=C;C={...W,type:_e,messageId:rr,timestamp:or,...Ct?{event:Ct}:{}}}if(n.validate){let W=n.validate(C,{producer:"web"});if(!W.valid){let _e=`[hp] invalid ${C.event??C.type}:
2
+ ${W.errors.join(`
3
+ `)}`;if(n.throwOnInvalid)throw new Ve(_e);console.error(_e)}}return n.debug&&console.debug("[hp]",C.event??C.type,C),F(C,k),C}function w(c){if(c.type==="track"&&K(c),n.onEvent)try{n.onEvent(c)}catch(l){console.warn("[hp] onEvent observer failed",l)}}let L=()=>r&&o?.state?.personalisation===!0,D=()=>vn(M(n.getSessionId,null),n.propertyId),H=!1;function K(c){try{L()?(D(),bn(dt(On(c.event,c.properties))),H=!0):(xn(),H&&Cn(),H=!1)}catch(l){n.debug&&console.warn("[hp] the visit was not recorded",l)}}function F(c,l){!r||l||o.admits()?(w(c),m.enqueue(c)):o.hold(c)}let I=(c,l,k)=>Dn(n.plan,c)?S({type:"track",event:c,properties:l??{}},k):null,G=new Set,we=(c,l,k)=>c==="audiences"?{audiences:l?null:k.audiences??[]}:c==="decisions"?{decisions:(k.decisions??[]).map(P=>({slot:P.slot,decision_id:P.decision_id??null,arm:P.arm??null,...P.variant&&{variant:P.variant}}))}:{recommendation_request_id:k.recommendation_request_id??null};r&&(o=mn({adapter:n.consent,timeoutMs:n.consentTimeoutMs,cookieDomain:n.consentCookieDomain,debug:n.debug,store:i&&{read:()=>a.items,write:c=>i.write(c,u?.peek()??null)},release(c){c.context&&(c.context.consent=o.stamp()),w(c),m.enqueue(c)},onStatus(c){if(c==="granted"&&(u?.persist(),d.persist(),g&&x(g),v.persist(),m.replayPersisted?.()),c==="denied"){m.clearPersisted?.(),u?.forget(),d.forget();try{sessionStorage.removeItem(b)}catch{}v.forget()}try{n.onConsentStatus?.(c)}catch(l){console.warn("[hp] onConsentStatus observer failed",l)}},announce({action:c,state:l,withdrawal:k}){S({type:"track",event:"Consent Updated",properties:{action:c,state:l}},void 0,k),k&&m.flush()}}),o.start());let me=()=>n.holdout?ut(n.holdout):null,he=()=>lt(n.holdout,B(M(n.getAnonymousId,null))).group;function R(c,l){if(!Array.isArray(c?.decisions))return c;let k=n.holdout?.readoutSlots??[],P=B(M(n.getAnonymousId,null));return{...c,decisions:c.decisions.map(C=>{let W=C?.variant==="bandit"||C?.variant==="default"?C.variant:!l&&C?.holdout!==!0&&k.includes(C?.slot)?yn(C.slot,P):null;return W?W==="default"?{...C,variant:W,decision_id:null}:{...C,variant:W}:C})}}function j(c,l){if(f)return null;let k=c?.exposure,P=k?.holdout===!0,C=R(c,P);return v.remember(hn(C)),!k?.token||G.has(k.token)?null:(G.add(k.token),I("Personalisation Exposed",{exposure_token:k.token,surface:k.surface,holdout:P,holdout_share:k.holdout_share??me()?.holdout_share??null,personalised_share:k.personalised_share??me()?.personalised_share??null,...we(k.surface,P,C)},l))}return{track:I,page(c={},l){let k=n.pageType??null;c.type&&(ae.has(c.type)?(k=c.type,n.pageType=c.type):n.debug&&console.warn(`[hp] ignoring unknown page.type "${c.type}". Allowed: ${[...ae].join(", ")}`));let P=S({type:"page",properties:{name:c.name??null,navigation_trigger:c.navigation_trigger??Vt(),previous_message_id:_()}},{page:{type:k},...Wn(l)??{}});return P&&x(P.messageId),P},identify(c,l){let{userId:k,...P}=c&&typeof c=="object"?c:{};if(k!==void 0&&(h=B(k)),typeof P.email_sha256=="string"){let C=je(P.email_sha256);C?P.email_sha256=C:delete P.email_sha256}return S({type:"identify",traits:P},l)},reset(){h=null,x("")},productViewed:(c,l)=>I("Product Viewed",c,l),productListViewed:(c,l)=>I("Product List Viewed",c,l),recommendationsViewed:(c,l)=>I("Recommendations Viewed",c,l),personalisationExposed:(c,l)=>I("Personalisation Exposed",c,l),recordExposure:j,surfaceViewed({surface:c}={},l){if(!Ho.has(c)||!n.holdout||c!=="decisions"&&!L())return null;let k=B(M(n.getAnonymousId,null)),P=lt(n.holdout,k).group;if(P==="excluded")return null;let C=Mt({sessionId:be(M(n.getSessionId,null),k),surface:c});return C?j({exposure:{token:C,surface:c,holdout:P==="holdout"}},l):null},inHoldout:()=>he()!=="personalised",personalisationGroup:he,productClicked:(c,l)=>I("Product Clicked",c,l),productListFiltered:(c,l)=>I("Product List Filtered",c,l),productsSearched:(c,l)=>I("Products Searched",c,l),productAdded:(c,l)=>I("Product Added",c,l),productRemoved:(c,l)=>I("Product Removed",c,l),cartUpdated:(c,l)=>I("Cart Updated",Go(c),l),identityLinked:(c,l)=>I("Identity Linked",c,l),slotEngaged:(c,l)=>f?null:I("Slot Engaged",c,l),productVariantSelected:(c,l)=>I("Product Variant Selected",c,l),cartViewed:(c,l)=>I("Cart Viewed",c,l),productAddedToWishlist:(c,l)=>I("Product Added to Wishlist",c,l),productRemovedFromWishlist:(c,l)=>I("Product Removed from Wishlist",c,l),wishlistProductAddedToCart:(c,l)=>I("Wishlist Product Added to Cart",c,l),productShared:(c,l)=>I("Product Shared",c,l),cartShared:(c,l)=>I("Cart Shared",c,l),couponEntered:(c,l)=>I("Coupon Entered",c,l),couponApplied:(c,l)=>I("Coupon Applied",c,l),couponDenied:(c,l)=>I("Coupon Denied",c,l),couponRemoved:(c,l)=>I("Coupon Removed",c,l),checkoutStarted:(c,l)=>I("Checkout Started",c,l),promotionViewed:(c,l)=>I("Promotion Viewed",c,l),promotionClicked:(c,l)=>I("Promotion Clicked",c,l),checkoutStepViewed:(c,l)=>I("Checkout Step Viewed",c,l),checkoutStepCompleted:(c,l)=>I("Checkout Step Completed",c,l),paymentInfoEntered:(c,l)=>I("Payment Info Entered",c,l),checkoutFailed:(c,l)=>I("Checkout Failed",c,l),signedIn:(c,l)=>I("Signed In",c,l),signedUp:(c,l)=>I("Signed Up",c,l),signedOut(c){let l=I("Signed Out",{},c);return h=null,l},newsletterSubscribed:(c,l)=>I("Newsletter Subscribed",c,l),newsletterUnsubscribed:(c,l)=>I("Newsletter Unsubscribed",c,l),backInStockSubscribed:(c,l)=>I("Back In Stock Subscribed",c,l),productReviewed:(c,l)=>I("Product Reviewed",c,l),consentUpdated:(c,l)=>I("Consent Updated",c,l),flush:c=>m.flush(c),recommendationContext(){if(!L())return{};try{return D(),dt(En())}catch{return{}}},get consent(){return o?o.state:null},servingHeaders:()=>tn(o?.state??null),get lastPageMessageId(){return _()},get anonymousId(){return B(M(n.getAnonymousId,null))},[Ko](c,l,k){if(typeof this[c]=="function"){E=typeof k?.messageId=="string"&&typeof k?.timestamp=="string"?{messageId:k.messageId,timestamp:k.timestamp}:null;try{this[c](...Array.isArray(l)?l:[])}finally{E=null}}}}}var Et=Symbol.for("@thg-agentic/hyper-personalisation-web.bootstrap"),Xo=Symbol.for("@thg-agentic/hyper-personalisation-web.drain"),Yo=Symbol.for("@thg-agentic/hyper-personalisation-web.carry"),Jn=Symbol.for("@thg-agentic/hyper-personalisation-web.replay"),Zo=Symbol.for("@thg-agentic/hyper-personalisation-web.assignment"),Qo=Symbol.for("@thg-agentic/hyper-personalisation-web.recommendation-context"),Fe=e=>e?()=>U(e):()=>null,Zn={didomi:e=>nn({purposes:e.purposes}),onetrust:e=>rn({groups:e.groups,impliedConsent:e.impliedConsent}),cookie:e=>on({name:e.name,categories:e.categories,refusedValue:e.refusedValue,source:e.source,changeEvent:e.changeEvent}),forwarded:e=>sn({name:e.name}),static:e=>{if(!e.state||typeof e.state!="object")throw new Error('consent.state is required for provider "static"');return an(e.state)}},Xn=Object.keys(Zn),pe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Be=e=>typeof e=="string"&&e!=="",es=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"),Qn=e=>pe(e)&&typeof e.read=="function";function ts(e,t={}){let n=[];if(!pe(e))return["config must be { writeKey, apiHost? }"];Be(e.writeKey)||n.push("writeKey is required"),de(e.apiHost)||n.push("apiHost, when given, must be a host or an http(s) origin"),t.propertyId!==void 0&&!Be(t.propertyId)&&n.push("propertyId must be a string");let{consent:r}=t;if(!Qn(r)&&!(pe(r)&&Xn.includes(r.provider))&&n.push(`consent must be a consent adapter or { provider: ${Xn.join(" | ")} }`),t.autocapture!==void 0&&t.autocapture!==!1&&!pe(t.autocapture)&&n.push("autocapture must be false or { promotions, productLists, recommendations }"),t.beforeSend!==void 0&&typeof t.beforeSend!="function"&&n.push("beforeSend must be a function"),t.identityCookies!==void 0)if(!pe(t.identityCookies))n.push("identityCookies must be an object");else for(let o of["anonymousId","sessionId"]){let s=t.identityCookies[o];s!==void 0&&!Be(s)&&n.push(`identityCookies.${o} must be a cookie name`)}for(let o of["getCurrency","getShipToCountry","getLocale"])t[o]!==void 0&&typeof t[o]!="function"&&n.push(`${o} must be a function`);return t.dataLayer!==void 0&&(pe(t.dataLayer)?(t.dataLayer.name!==void 0&&!Be(t.dataLayer.name)&&n.push("dataLayer.name must be a string"),t.dataLayer.ignore!==void 0&&!es(t.dataLayer.ignore)&&n.push("dataLayer.ignore must be an array of strings")):n.push("dataLayer must be an object")),n}function ns(e,t,n){if(Qn(e))return st(e,t.consentPurposes);let{provider:r,...o}=e,s=n?.consent?.[r]??Zn[r];return st(s(o),t.consentPurposes)}var er=(e,t)=>`${e??""}|${t??""}`;function rs(e,t){let n=B(t?.userId),r=je(t?.emailSha256);if(!n&&!r)return null;try{let o=q(O("identified"),e);if(sessionStorage.getItem(o)===er(n,r))return null}catch{}return{...n?{userId:n}:{},...r?{email_sha256:r}:{}}}async function os({writeKey:e,apiHost:t},n){if(n.settings!==void 0)return{settings:St(n.settings),revalidated:null};let r=Un(t,e),o=$n(e);if(o)return{settings:o,revalidated:r};let s=await r,i=s??yt;return{settings:i,revalidated:Promise.resolve(i),unreachable:s===null}}function tr(e,t={}){let n=typeof window<"u"?window:null;if(n?.[Et])return n[Et];let r=Yt(e?.writeKey,()=>{let{analytics:s}=ye(U(O("consent")));return s===!0||s===null&&t.holdAcrossPages===!0}),o=is(e,t,r);if(n){let s=t.extend?.getSessionId??Fe(t.identityCookies?.sessionId),i=Fe(t.identityCookies?.anonymousId);n[Zo]=({slot:a,arm:u}={})=>Dt({sessionId:be(s(),i()),slot:a,arm:u}),n[Et]=o,n[Yo]=r,n[Xo]?.(o)}return o}function ss(){let e=globalThis.performance?.now?.();return new Date(Date.now()-(Number.isFinite(e)?e:0)).toISOString()}function Yn(e,t){if(t===!1)return()=>{};let n={promotions:!0,productLists:!0,recommendations:!0,exposures:!0,...t},r=s=>s&&typeof s=="object"?s:{},o=[];try{n.promotions&&o.push(We(e,r(n.promotions))),n.productLists&&o.push(Ge(e,r(n.productLists))),n.recommendations&&o.push(ze(e,r(n.recommendations))),n.exposures&&o.push(Ke(e,r(n.exposures)))}catch(s){console.warn("[hp] autocapture not started:",s?.message??s)}return()=>{for(let s of o)s()}}function qe(e){return e.close(),null}async function is(e,t,n){try{let r=ts(e,t);if(r.length)return console.warn(`[hp] not started, the configuration is invalid: ${r.join("; ")}`),qe(n);Ie(t.storageNames),Ae();let{writeKey:o}=e,[{settings:s,revalidated:i,unreachable:a},u]=await Promise.all([os(e,t),Promise.resolve(t.identity).catch(()=>null)]),d=i?s:null,p=!1,f=()=>p&&d&&Vn(o,d);if(i?.then(y=>{y&&(d=y,y.enabled?f():wt(o))}),a)return null;if(!s.enabled)return t.debug&&console.info("[hp] off: the settings for this write key do not enable it"),qe(n);let m=s.propertyId??t.propertyId;if(!m)return console.warn("[hp] not started: this write key covers several properties, so propertyId is required"),qe(n);let{preset:b}=t,g=rs(m,u),_=t.debug===!0||s.debug?.enabled===!0||fn(s.debug?.tokenSha256??null,O("debug")),x=B(u?.userId),v=zn({apiHost:s.apiHost??de(e.apiHost),writeKey:o,propertyId:m,pageType:ae.has(t.pageType)?t.pageType:void 0,environment:s.environment,queryParamAllowlist:s.queryParamAllowlist??void 0,plan:s.plan,sampleRate:s.sampleRate??1,holdout:s.holdouts?.[m],getCurrency:t.getCurrency,getShipToCountry:t.getShipToCountry,getLocale:t.getLocale,consent:ns(t.consent,s,b),consentCookieDomain:t.consentCookieDomain,storageNames:t.storageNames,holdAcrossPages:t.holdAcrossPages===!0,mintAnonymousId:t.mintAnonymousId,debug:_,anonymousIdSource:s.anonymousId??void 0,getAnonymousId:Fe(t.identityCookies?.anonymousId),getSessionId:t.identityCookies?.sessionId?Fe(t.identityCookies.sessionId):void 0,getUserId:()=>x,beforeSend:t.beforeSend,...t.extend,onConsentStatus(y){if(y==="granted"&&(p=!0,f()),y==="denied"){wt(o);try{sessionStorage.removeItem(q(O("identified"),m))}catch{}}t.extend?.onConsentStatus?.(y)},onEvent(y){if(y.type==="identify"){let w=er(B(y.userId),je(y.traits?.email_sha256));try{sessionStorage.setItem(q(O("identified"),m),w)}catch{}}t.extend?.onEvent?.(y)}});typeof window<"u"&&(window[Qo]=()=>v.recommendationContext());for(let[y,w,L]of n.take())try{v[Jn](y,w,L)}catch(D){console.warn(`[hp] carried ${y} failed`,D)}v[Jn]("page",[t.pageType?{type:t.pageType}:{}],{messageId:Z(),timestamp:ss()});let h=Yn(v,t.autocapture),E=v.page;v.page=(...y)=>{let w=E(...y);return h(),h=Yn(v,t.autocapture),w};let S=typeof window<"u"?window:null;if(t.dataLayer&&S){let y=t.dataLayer.name??"dataLayer";S[y]=S[y]||[],dn(v,{...b,dataLayer:S[y],ignore:[...b?.ignore??[],...t.dataLayer.ignore??[]],onError:w=>_&&console.warn("[hp] dataLayer mapping failed",w)})}return g&&v.identify(g),v}catch(r){return console.warn("[hp] not started:",r?.message??r),qe(n)}}function nr(e){e.initialized=!0,tr(e._config,e._options).then(t=>{let n=e.splice(0);if(!t){for(let r of e.methods??[])e[r]=()=>e;return}e.client=t;for(let[r,o]of Object.entries(t))typeof o=="function"&&(e[r]=o);for(let[r,...o]of n)try{t[r]?.(...o)}catch(s){console.warn(`[hp] queued ${r} failed`,s)}})}var V=window.hp=window.hp||[];V.servingHeaders??(V.servingHeaders=()=>({}));V.inHoldout??(V.inHoldout=()=>!0);V.personalisationGroup??(V.personalisationGroup=()=>"excluded");V.recommendationContext??(V.recommendationContext=()=>({}));V.initialized||(V._config?nr(V):V.load=(e,t)=>{V._config=e,V._options=t??{},nr(V)});})();