@kystverket/styrbord-consent 2.0.0 → 2.1.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
@@ -87,7 +87,7 @@ La `cookieDomain` stå udefinert lokalt; da settes kapselen på gjeldende vertsn
87
87
 
88
88
  ### Tjenester
89
89
 
90
- `plausibleService`, `hotjarService`, `postHogService` og `consentCookieService` er ferdige
90
+ `plausibleService`, `hotjarService`, `postHogService`, `postHogReplayService` og `consentCookieService` er ferdige
91
91
  oppsett med riktig kategori og kapselliste. Andre tjenester defineres som vanlige
92
92
  `ConsentService`-objekter.
93
93
 
@@ -98,11 +98,14 @@ legger det bak statistikk-kategorien i stedet.
98
98
  PostHog ligger bak statistikk, fordi det alltid teller sidevisninger og klikk:
99
99
 
100
100
  ```tsx
101
- postHogService({
101
+ const postHog = {
102
102
  apiKey: 'phc_...',
103
103
  sessionReplay: true, // sesjonsopptak og varmekart
104
104
  capturePageview: false, // appen teller sidevisninger selv ved ruteendring
105
- });
105
+ initOptions: { session_recording: { maskTextSelector: '*' } },
106
+ };
107
+
108
+ services={[postHogService(postHog), postHogReplayService(postHog)]}
106
109
  ```
107
110
 
108
111
  Med `sessionReplay` gjør PostHog i tillegg det samme som Hotjar, og det hører hjemme under
@@ -110,6 +113,18 @@ brukeropplevelse. Siden en tjeneste bare kan stå i én kategori i dialogen, lø
110
113
  skriptet starter med opptak avslått og slår det på når brukeren gir brukeropplevelse — også uten
111
114
  at siden lastes på nytt. Varmekart settes ved oppstart og er først med ved neste sidelast.
112
115
 
116
+ `postHogReplayService` laster ingenting; den gjør bare brukeropplevelse til et valg i dialogen.
117
+ Uten den — og uten en annen tjeneste i den kategorien, som Hotjar — får brukeren aldri spørsmålet,
118
+ og opptaket slås aldri på. Biblioteket advarer i konsollet når det mangler.
119
+
120
+ `initOptions` flettes inn i `posthog.init`, for f.eks. `capture_exceptions`, `debug` eller
121
+ maskering. PostHog maskerer bare input-felt som standard, så bruk `session_recording` til å
122
+ maskere mer når teksten lover anonymiserte opptak. Valgene samtykket styrer
123
+ (`disable_session_recording`, `capture_heatmaps`, `cross_subdomain_cookie`) kan ikke overstyres.
124
+
125
+ Når samtykket trekkes tilbake, slettes både `ph_`-kapslene og PostHogs kopi i `localStorage` og
126
+ `sessionStorage`. Egne tjenester får det samme med `clearStoragePrefixes`.
127
+
113
128
  API-nøkkelen er offentlig og hører hjemme i klientkoden, men send den likevel inn som en prop
114
129
  framfor å lese den i biblioteket — se avsnittet om `cookieDomain` over. CSP må åpne for både
115
130
  `eu.i.posthog.com` og `eu-assets.i.posthog.com`.
@@ -10,9 +10,9 @@ export type { UseConsentResult } from './hooks/useConsent';
10
10
  export { useStoreValue } from './hooks/useStoreValue';
11
11
  export { useConsentStore } from './utility/consentContext';
12
12
  export type { ConsentContextValue } from './utility/consentContext';
13
- export { clearServiceCookies, createConsentStore, getSelectableCategories, hasGatedServices, DEFAULT_EXPIRY_DAYS, DEFAULT_STORAGE_KEY, } from './utility/consentStore';
13
+ export { clearServiceCookies, clearServiceStorage, createConsentStore, getSelectableCategories, hasGatedServices, DEFAULT_EXPIRY_DAYS, DEFAULT_STORAGE_KEY, } from './utility/consentStore';
14
14
  export type { ConsentStore } from './utility/consentStore';
15
- export { consentCookieService, hotjarService, plausibleService, postHogService } from './utility/services';
15
+ export { consentCookieService, hotjarService, plausibleService, postHogReplayService, postHogService, } from './utility/services';
16
16
  export type { HotjarOptions, PlausibleOptions, PostHogOptions } from './utility/services';
17
17
  export { consentTranslations, defaultConsentLanguage, formatCookieDuration, getConsentTranslations, } from './utility/translations';
18
18
  export type { ConsentLanguage, ConsentTranslations } from './utility/translations';
@@ -42,6 +42,14 @@ export type ConsentService = Script & {
42
42
  * tredjeparten allerede har satt.
43
43
  */
44
44
  clearCookiePrefixes?: string[];
45
+ /**
46
+ * Nøkler i `localStorage` og `sessionStorage` tjenesten skriver, og som skal slettes når
47
+ * samtykket trekkes tilbake. Prefiks-match, som `clearCookiePrefixes`.
48
+ *
49
+ * Mange skript speiler kapslene sine til nettleserlagringen (PostHog med
50
+ * `persistence: 'localStorage+cookie'`), og da er det ikke nok å slette kapslene.
51
+ */
52
+ clearStoragePrefixes?: string[];
45
53
  };
46
54
  /**
47
55
  * Konfigurasjon av samtykkeløsningen. Alt som varierer mellom miljøer og applikasjoner sendes
@@ -31,6 +31,11 @@ export declare function hasGatedServices(services: ConsentService[]): boolean;
31
31
  * blir ryddet bort.
32
32
  */
33
33
  export declare function clearServiceCookies(services: ConsentService[], consents: Partial<ConsentState>, cookieDomain?: string): void;
34
+ /**
35
+ * Sletter `localStorage`- og `sessionStorage`-nøkler skrevet av tjenester brukeren ikke har
36
+ * samtykket til. Kjøres sammen med `clearServiceCookies`, også ved oppstart.
37
+ */
38
+ export declare function clearServiceStorage(services: ConsentService[], consents: Partial<ConsentState>): void;
34
39
  /**
35
40
  * Setter opp samtykkelageret i offline-modus: ingen nettverkskall, ingen backend, alt lagres
36
41
  * i nettleseren. Informasjonskapselen er fasit, og c15t speiler den til localStorage — som
@@ -53,7 +53,8 @@ export interface PostHogOptions {
53
53
  * Om sesjonsopptak og varmekart skal brukes.
54
54
  *
55
55
  * Dette er en annen ting å samtykke til enn statistikk, og styres derfor av kategorien
56
- * `experience` — se kommentaren på funksjonen under.
56
+ * `experience` — se kommentaren på funksjonen under. Legg også `postHogReplayService` i
57
+ * tjenestelista, ellers får brukeren aldri valget, og opptaket blir aldri slått på.
57
58
  *
58
59
  * @default false
59
60
  */
@@ -80,6 +81,16 @@ export interface PostHogOptions {
80
81
  * @default '2026-05-30'
81
82
  */
82
83
  defaults?: string;
84
+ /**
85
+ * Flere valg til `posthog.init`, f.eks. `capture_exceptions`, `debug` eller maskering av
86
+ * opptak (`session_recording: { maskTextSelector: '*' }`). PostHog maskerer bare input-felt
87
+ * som standard, og «anonymiserte opptak» forutsetter i praksis mer enn det.
88
+ *
89
+ * Flettes inn etter standardverdiene over, men kan ikke overstyre det samtykket styrer:
90
+ * `disable_session_recording`, `capture_heatmaps` og `cross_subdomain_cookie` settes alltid
91
+ * av biblioteket.
92
+ */
93
+ initOptions?: Record<string, unknown>;
83
94
  }
84
95
  /**
85
96
  * PostHog: produktanalyse, og eventuelt sesjonsopptak og varmekart.
@@ -93,7 +104,8 @@ export interface PostHogOptions {
93
104
  * (`{ and: [...] }`), men dialogen filtrerer dem bort, så PostHog ville blitt usynlig for
94
105
  * brukeren — akkurat den stille underrapporteringen kapselmetadataen er til for å unngå.
95
106
  * Opptaket styres derfor i stedet i kjøretid: skriptet starter med opptak avslått, og slår det
96
- * på og av etter hvert som `experience` gis og trekkes tilbake.
107
+ * på og av etter hvert som `experience` gis og trekkes tilbake. For at brukeren skal få det
108
+ * valget, må `experience` finnes i dialogen — det er det `postHogReplayService` er til for.
97
109
  *
98
110
  * Merk at varmekart ikke lar seg skru på i kjøretid slik opptak gjør — de settes når skriptet
99
111
  * initialiseres. Gir brukeren `experience` etter at siden er lastet, starter opptaket med én
@@ -101,7 +113,31 @@ export interface PostHogOptions {
101
113
  *
102
114
  * CSP må åpne for både `apiHost` og assets-verten før dette virker.
103
115
  */
104
- export declare function postHogService({ apiKey, apiHost, assetHost, sessionReplay, capturePageview, personProfiles, defaults, }: PostHogOptions): ConsentService;
116
+ export declare function postHogService({ apiKey, apiHost, assetHost, sessionReplay, capturePageview, personProfiles, defaults, initOptions, }: PostHogOptions): ConsentService;
117
+ /**
118
+ * Gjør PostHogs sesjonsopptak og varmekart til noe brukeren kan samtykke til.
119
+ *
120
+ * `postHogService` står i `measurement`, og dialogen viser bare kategorier en tjeneste faktisk
121
+ * står i. Uten en tjeneste i `experience` får brukeren derfor aldri spørsmålet, og opptaket
122
+ * slås aldri på — med mindre svaret er gitt i en annen app via den delte kapselen, altså uten
123
+ * at brukeren har fått valget her. Denne oppføringen laster ingenting (`callbackOnly`); den
124
+ * gjør bare kategorien synlig. Selve av- og påslåingen skjer i `postHogService`.
125
+ *
126
+ * Den rydder bevisst ingen kapsler: de deles med statistikkdelen, og skal stå så lenge
127
+ * `measurement` er gitt.
128
+ *
129
+ * ```ts
130
+ * const postHog = { apiKey: 'phc_...', sessionReplay: true };
131
+ * services: [postHogService(postHog), postHogReplayService(postHog)]
132
+ * ```
133
+ */
134
+ export declare function postHogReplayService({ apiKey }: Pick<PostHogOptions, 'apiKey'>): ConsentService;
135
+ /**
136
+ * Advarer når PostHog er satt opp med `sessionReplay`, men ingen tjeneste står i `experience`.
137
+ * Da vises aldri kategorien i dialogen, og opptaket kan bare slås på av et svar gitt i en
138
+ * annen app.
139
+ */
140
+ export declare function warnIfReplayUnselectable(services: ConsentService[]): void;
105
141
  /**
106
142
  * Selve samtykke-informasjonskapselen, som metadata til dialogen.
107
143
  *
package/dist/style.js CHANGED
@@ -1,136 +1,259 @@
1
1
  'use client';
2
- import { jsx as o, jsxs as l, Fragment as V } from "react/jsx-runtime";
3
- import { createContext as B, useContext as T, useEffect as w, useRef as N, useState as F, useMemo as G, useSyncExternalStore as Z, useId as Q } from "react";
4
- import { deleteCookie as x, configureConsentManager as W, createConsentManagerStore as Y } from "c15t";
5
- const U = B(null);
6
- function C() {
7
- const e = T(U);
2
+ import { jsx as s, jsxs as d, Fragment as W } from "react/jsx-runtime";
3
+ import { createContext as O, useContext as P, useEffect as j, useRef as x, useState as Z, useMemo as Q, useSyncExternalStore as Y, useId as z } from "react";
4
+ import { deleteCookie as L, configureConsentManager as X, createConsentManagerStore as J } from "c15t";
5
+ const R = O(null);
6
+ function S() {
7
+ const e = P(R);
8
8
  if (!e)
9
9
  throw new Error("useConsentStore må brukes innenfor en <ConsentProvider>.");
10
10
  return e;
11
11
  }
12
- const O = "kystverket_consent", M = 182;
13
- function A(e) {
12
+ const M = "kystverket_consent", H = 182;
13
+ function T(e) {
14
14
  const n = e.filter((t) => !t.alwaysLoad).map((t) => t.category).filter((t) => typeof t == "string").filter((t) => t !== "necessary");
15
15
  return [...new Set(n)];
16
16
  }
17
- function z(e) {
18
- return A(e).length > 0;
17
+ function ee(e) {
18
+ return T(e).length > 0;
19
+ }
20
+ function E(e, n) {
21
+ return e.filter((t) => t.alwaysLoad || typeof t.category != "string" ? !1 : n[t.category] !== !0);
19
22
  }
20
- function X(e, n, t) {
23
+ function ne(e, n, t) {
21
24
  if (typeof document > "u")
22
25
  return;
23
- const r = e.filter((s) => s.alwaysLoad || typeof s.category != "string" ? !1 : n[s.category] !== !0).flatMap((s) => s.clearCookiePrefixes ?? []);
24
- if (r.length === 0)
26
+ const i = E(e, n).flatMap((r) => r.clearCookiePrefixes ?? []);
27
+ if (i.length === 0)
25
28
  return;
26
- const i = document.cookie.split(";").map((s) => {
27
- var d;
28
- return (d = s.split("=")[0]) == null ? void 0 : d.trim();
29
- }).filter((s) => !!s);
30
- for (const s of i)
31
- r.some((d) => s.startsWith(d)) && (x(s), x(s, { domain: window.location.hostname }), t && x(s, { domain: t }));
32
- }
33
- function J(e) {
29
+ const o = document.cookie.split(";").map((r) => {
30
+ var c;
31
+ return (c = r.split("=")[0]) == null ? void 0 : c.trim();
32
+ }).filter((r) => !!r);
33
+ for (const r of o)
34
+ i.some((c) => r.startsWith(c)) && (L(r), L(r, { domain: window.location.hostname }), t && L(r, { domain: t }));
35
+ }
36
+ function te(e, n) {
37
+ if (typeof window > "u")
38
+ return;
39
+ const t = E(e, n).flatMap((i) => i.clearStoragePrefixes ?? []);
40
+ if (t.length !== 0)
41
+ for (const i of ["localStorage", "sessionStorage"])
42
+ try {
43
+ const o = window[i], r = Array.from({ length: o.length }, (c, u) => o.key(u)).filter((c) => c !== null && t.some((u) => c.startsWith(u)));
44
+ for (const c of r)
45
+ o.removeItem(c);
46
+ } catch {
47
+ }
48
+ }
49
+ function se(e) {
34
50
  return {
35
- storageKey: e.storageKey ?? O,
36
- defaultExpiryDays: e.expiryDays ?? M,
51
+ storageKey: e.storageKey ?? M,
52
+ defaultExpiryDays: e.expiryDays ?? H,
37
53
  // Bevisst ikke `crossSubdomain: true` — se kommentaren på ConsentConfig.cookieDomain.
38
54
  ...e.cookieDomain ? { defaultDomain: e.cookieDomain } : {}
39
55
  };
40
56
  }
41
- function ee(e) {
42
- const n = J(e), t = W({
57
+ function oe(e) {
58
+ const n = se(e), t = X({
43
59
  mode: "offline",
44
60
  storageConfig: n
45
61
  });
46
- return Y(t, {
62
+ return J(t, {
47
63
  storageConfig: n,
48
64
  scripts: e.services,
49
- initialConsentCategories: A(e.services),
65
+ initialConsentCategories: T(e.services),
50
66
  debug: e.debug ?? !1,
51
67
  // Laster siden på nytt når samtykke trekkes tilbake. Nødvendig fordi et skript som
52
68
  // Hotjar ikke lar seg stoppe når det først kjører.
53
69
  reloadOnConsentRevoked: !0,
54
70
  callbacks: {
55
- onConsentSet: ({ preferences: r }) => X(e.services, r, e.cookieDomain)
71
+ onConsentSet: ({ preferences: i }) => {
72
+ ne(e.services, i, e.cookieDomain), te(e.services, i);
73
+ }
56
74
  }
57
75
  });
58
76
  }
59
- const $ = B(null), ne = $.Provider;
60
- function te() {
61
- return N({ count: 0 }).current;
77
+ const I = O(null), re = I.Provider;
78
+ function ie() {
79
+ return x({ count: 0 }).current;
62
80
  }
63
- function se() {
64
- const e = T($);
65
- w(() => {
81
+ function ae() {
82
+ const e = P(I);
83
+ j(() => {
66
84
  if (e)
67
85
  return e.count += 1, () => {
68
86
  e.count -= 1;
69
87
  };
70
88
  }, [e]);
71
89
  }
72
- const L = /* @__PURE__ */ new Set();
73
- function H(e, n) {
74
- const t = T($);
75
- w(() => {
76
- if (!n || !t || L.has(e))
90
+ const A = /* @__PURE__ */ new Set();
91
+ function K(e, n) {
92
+ const t = P(I);
93
+ j(() => {
94
+ if (!n || !t || A.has(e))
77
95
  return;
78
- const r = setTimeout(() => {
79
- t.count > 0 || L.has(e) || (L.add(e), console.warn(`<${e}> is shown without a <ConsentPreferencesDialog> mounted. Opening the consent settings will hide it with nothing to replace it, leaving the user unable to give or withdraw consent. Mount <ConsentPreferencesDialog> alongside it, or use <CookieConsent>, which mounts all three surfaces.`));
96
+ const i = setTimeout(() => {
97
+ t.count > 0 || A.has(e) || (A.add(e), console.warn(`<${e}> is shown without a <ConsentPreferencesDialog> mounted. Opening the consent settings will hide it with nothing to replace it, leaving the user unable to give or withdraw consent. Mount <ConsentPreferencesDialog> alongside it, or use <CookieConsent>, which mounts all three surfaces.`));
80
98
  }, 0);
81
- return () => clearTimeout(r);
99
+ return () => clearTimeout(i);
82
100
  }, [n, e, t]);
83
101
  }
84
- const oe = { heading: "Cookies", body: "We use cookies to understand how this service is used, so that we can improve it. You decide what you consent to.", acceptAll: "Accept all", rejectAll: "Necessary only", managePreferences: "Choose yourself" }, ie = { heading: "Cookie settings", body: "Necessary cookies are always on, because the service does not work without them. The rest is up to you.", savePreferences: "Save choices", acceptAll: "Accept all", rejectAll: "Necessary only", close: "Close", servicesLabel: "Services", showCookies: "Show cookies", noCookies: "Sets no cookies", alwaysOnHeading: "Always on", alwaysOnBody: "These store nothing on your device and cannot be used to recognise you. They therefore do not require consent, and are always on.", cookieName: "Name", cookieProvider: "Provided by", cookieDuration: "Duration" }, re = { session: "Until you close your browser", day: "{{count}} day", days: "{{count}} days", month: "{{count}} month", months: "{{count}} months", year: "{{count}} year", years: "{{count}} years" }, ae = { necessary: { title: "Necessary", description: "Required for the service to work, including sign-in and security. These cannot be turned off." }, functionality: { title: "Functionality", description: "Remembers your choices, such as language and other settings." }, measurement: { title: "Statistics", description: "Lets us count visits and see which pages are used, so we can prioritise correctly." }, experience: { title: "User experience", description: "Lets us see how the pages are actually used, through anonymised recordings and heatmaps, so we can fix what is difficult." }, marketing: { title: "Marketing", description: "Used to tailor advertising. Kystverket does not use this today." } }, ce = "Manage cookies", le = {
85
- banner: oe,
86
- dialog: ie,
87
- durations: re,
88
- categories: ae,
89
- manageLink: ce
90
- }, de = { heading: "Informasjonskapsler", body: "Vi bruker informasjonskapsler for å forstå hvordan tjenesten brukes, slik at vi kan gjøre den bedre. Du velger selv hva du samtykker til.", acceptAll: "Godta alle", rejectAll: "Kun nødvendige", managePreferences: "Velg selv" }, ue = { heading: "Innstillinger for informasjonskapsler", body: "Nødvendige informasjonskapsler er alltid på, fordi tjenesten ikke fungerer uten dem. De øvrige velger du selv.", savePreferences: "Lagre valg", acceptAll: "Godta alle", rejectAll: "Kun nødvendige", close: "Lukk", servicesLabel: "Tjenester", showCookies: "Vis informasjonskapsler", noCookies: "Setter ingen informasjonskapsler", alwaysOnHeading: "Alltid på", alwaysOnBody: "Disse lagrer ingenting på enheten din og kan ikke brukes til å kjenne deg igjen. De krever derfor ikke samtykke, og er alltid på.", cookieName: "Navn", cookieProvider: "Levert av", cookieDuration: "Varighet" }, ge = { session: "Til du lukker nettleseren", day: "{{count}} dag", days: "{{count}} dager", month: "{{count}} måned", months: "{{count}} måneder", year: "{{count}} år", years: "{{count}} år" }, he = { necessary: { title: "Nødvendige", description: "Kreves for at tjenesten skal fungere, blant annet for innlogging og sikkerhet. Disse kan ikke slås av." }, functionality: { title: "Funksjonalitet", description: "Husker valgene dine, som språk og andre innstillinger." }, measurement: { title: "Statistikk", description: "Lar oss telle besøk og se hvilke sider som brukes, slik at vi kan prioritere riktig." }, experience: { title: "Brukeropplevelse", description: "Lar oss se hvordan sidene faktisk brukes, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskelig." }, marketing: { title: "Markedsføring", description: "Brukes til å tilpasse annonser. Kystverket bruker ikke dette i dag." } }, ke = "Administrer informasjonskapsler", me = {
91
- banner: de,
92
- dialog: ue,
93
- durations: ge,
94
- categories: he,
95
- manageLink: ke
96
- }, ye = { heading: "Informasjonskapslar", body: "Vi brukar informasjonskapslar for å forstå korleis tenesta blir brukt, slik at vi kan gjere henne betre. Du vel sjølv kva du samtykkjer til.", acceptAll: "Godta alle", rejectAll: "Berre nødvendige", managePreferences: "Vel sjølv" }, pe = { heading: "Innstillingar for informasjonskapslar", body: "Nødvendige informasjonskapslar er alltid på, fordi tenesta ikkje fungerer utan dei. Dei andre vel du sjølv.", savePreferences: "Lagre val", acceptAll: "Godta alle", rejectAll: "Berre nødvendige", close: "Lukk", servicesLabel: "Tenester", showCookies: "Vis informasjonskapslar", noCookies: "Set ingen informasjonskapslar", alwaysOnHeading: "Alltid på", alwaysOnBody: "Desse lagrar ingenting på eininga di og kan ikkje brukast til å kjenne deg att. Dei krev difor ikkje samtykke, og er alltid på.", cookieName: "Namn", cookieProvider: "Levert av", cookieDuration: "Varigheit" }, fe = { session: "Til du lukkar nettlesaren", day: "{{count}} dag", days: "{{count}} dagar", month: "{{count}} månad", months: "{{count}} månader", year: "{{count}} år", years: "{{count}} år" }, ve = { necessary: { title: "Nødvendige", description: "Krevst for at tenesta skal fungere, mellom anna for innlogging og tryggleik. Desse kan ikkje slåast av." }, functionality: { title: "Funksjonalitet", description: "Hugsar vala dine, som språk og andre innstillingar." }, measurement: { title: "Statistikk", description: "Lèt oss telje besøk og sjå kva sider som blir brukte, slik at vi kan prioritere rett." }, experience: { title: "Brukaroppleving", description: "Lèt oss sjå korleis sidene faktisk blir brukte, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskeleg." }, marketing: { title: "Marknadsføring", description: "Blir brukt til å tilpasse annonsar. Kystverket brukar ikkje dette i dag." } }, be = "Administrer informasjonskapslar", _e = {
102
+ const V = Symbol("styrbord-consent.sessionReplay");
103
+ function fn({ domain: e, requireConsent: n = !1, scriptSrc: t = "https://plausible.io/js/script.js" }) {
104
+ return {
105
+ id: "plausible",
106
+ displayName: "Plausible",
107
+ src: t,
108
+ category: "measurement",
109
+ alwaysLoad: !n,
110
+ defer: !0,
111
+ attributes: { "data-domain": e },
112
+ // Tom liste, ikke utelatt: dialogen skiller mellom «setter ingen kapsler» og «vi har
113
+ // ikke oppgitt noe», og det kapselfrie er hele grunnen til at Plausible går usamtykket.
114
+ cookies: []
115
+ };
116
+ }
117
+ function vn({ siteId: e }) {
118
+ return {
119
+ id: "hotjar",
120
+ displayName: "Hotjar",
121
+ category: "experience",
122
+ clearCookiePrefixes: ["_hj"],
123
+ cookies: [
124
+ { name: "_hjSessionUser_*", duration: 365 },
125
+ { name: "_hjSession_*", duration: 1 },
126
+ { name: "_hjIncludedInSessionSample_*", duration: 1 }
127
+ ],
128
+ textContent: `
129
+ (function (h, o, t, j, a, r) {
130
+ h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments); };
131
+ h._hjSettings = { hjid: ${Number(e)}, hjsv: 6 };
132
+ a = o.getElementsByTagName('head')[0];
133
+ r = o.createElement('script');
134
+ r.async = 1;
135
+ r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
136
+ a.appendChild(r);
137
+ })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
138
+ `
139
+ };
140
+ }
141
+ function bn({ apiKey: e, apiHost: n = "https://eu.i.posthog.com", assetHost: t, sessionReplay: i = !1, capturePageview: o = !0, personProfiles: r = "identified_only", defaults: c = "2026-05-30", initOptions: u }) {
142
+ const h = n.replace(/\/$/, ""), _ = (t ?? h.replace(".i.posthog.com", "-assets.i.posthog.com")).replace(/\/$/, ""), y = () => window.posthog, m = (g) => {
143
+ if (!i)
144
+ return;
145
+ const p = y();
146
+ p && (g.experience === !0 ? p.startSessionRecording() : p.stopSessionRecording());
147
+ }, f = {
148
+ id: "posthog",
149
+ displayName: "PostHog",
150
+ category: "measurement",
151
+ clearCookiePrefixes: ["ph_"],
152
+ // PostHog (`persistence: 'localStorage+cookie'`) speiler kapselen til localStorage, og
153
+ // holder vinduets øktdata i sessionStorage. Begge må ryddes når samtykket trekkes tilbake.
154
+ clearStoragePrefixes: ["ph_"],
155
+ // Kapselen heter `ph_<nøkkel>_posthog`. Nøkkelen er kjent her, så brukeren får se det
156
+ // faktiske navnet framfor et jokertegn. PostHog speiler den samme verdien til localStorage,
157
+ // som dialogen foreløpig ikke har noen måte å vise.
158
+ cookies: [{ name: `ph_${e}_posthog`, duration: 365 }],
159
+ src: `${_}/static/array.js`,
160
+ onLoad: ({ consents: g }) => {
161
+ var p;
162
+ (p = y()) == null || p.init(e, {
163
+ api_host: h,
164
+ person_profiles: r,
165
+ capture_pageview: o,
166
+ defaults: c,
167
+ ...u,
168
+ // Alt under styres av samtykket, og skal ikke kunne overstyres via `initOptions`.
169
+ // PostHog setter denne til `true` selv, som legger kapselen på toppdomenet. Samme felle
170
+ // som c15t sin `crossSubdomain` — se kommentaren på `ConsentConfig.cookieDomain`.
171
+ cross_subdomain_cookie: !1,
172
+ disable_session_recording: !0,
173
+ capture_heatmaps: i && g.experience === !0
174
+ }), m(g);
175
+ },
176
+ onConsentChange: ({ consents: g }) => m(g)
177
+ };
178
+ return i && (f[V] = !0), f;
179
+ }
180
+ function _n({ apiKey: e }) {
181
+ return {
182
+ id: "posthog-replay",
183
+ displayName: "PostHog (opptak og varmekart)",
184
+ category: "experience",
185
+ callbackOnly: !0,
186
+ // Samme kapsel som under statistikk — opptaket lagres i den samme PostHog-økten.
187
+ cookies: [{ name: `ph_${e}_posthog`, duration: 365 }]
188
+ };
189
+ }
190
+ let $ = !1;
191
+ function ce(e) {
192
+ if ($)
193
+ return;
194
+ const n = e.some((i) => i[V]), t = e.some((i) => !i.alwaysLoad && i.category === "experience");
195
+ !n || t || ($ = !0, console.warn("postHogService({ sessionReplay: true }) is configured, but no service is in the 'experience' category, so the user is never asked and session replay never starts. Add postHogReplayService({ apiKey }) to services."));
196
+ }
197
+ function Cn(e = M, n = H) {
198
+ return {
199
+ id: "consent",
200
+ displayName: "Kystverket",
201
+ category: "necessary",
202
+ callbackOnly: !0,
203
+ alwaysLoad: !0,
204
+ cookies: [{ name: e, duration: n }]
205
+ };
206
+ }
207
+ const le = { heading: "Cookies", body: "We use cookies to understand how this service is used, so that we can improve it. You decide what you consent to.", acceptAll: "Accept all", rejectAll: "Necessary only", managePreferences: "Choose yourself" }, de = { heading: "Cookie settings", body: "Necessary cookies are always on, because the service does not work without them. The rest is up to you.", savePreferences: "Save choices", acceptAll: "Accept all", rejectAll: "Necessary only", close: "Close", servicesLabel: "Services", showCookies: "Show cookies", noCookies: "Sets no cookies", alwaysOnHeading: "Always on", alwaysOnBody: "These store nothing on your device and cannot be used to recognise you. They therefore do not require consent, and are always on.", cookieName: "Name", cookieProvider: "Provided by", cookieDuration: "Duration" }, ue = { session: "Until you close your browser", day: "{{count}} day", days: "{{count}} days", month: "{{count}} month", months: "{{count}} months", year: "{{count}} year", years: "{{count}} years" }, ge = { necessary: { title: "Necessary", description: "Required for the service to work, including sign-in and security. These cannot be turned off." }, functionality: { title: "Functionality", description: "Remembers your choices, such as language and other settings." }, measurement: { title: "Statistics", description: "Lets us count visits and see which pages are used, so we can prioritise correctly." }, experience: { title: "User experience", description: "Lets us see how the pages are actually used, through anonymised recordings and heatmaps, so we can fix what is difficult." }, marketing: { title: "Marketing", description: "Used to tailor advertising. Kystverket does not use this today." } }, he = "Manage cookies", ke = {
208
+ banner: le,
209
+ dialog: de,
210
+ durations: ue,
211
+ categories: ge,
212
+ manageLink: he
213
+ }, ye = { heading: "Informasjonskapsler", body: "Vi bruker informasjonskapsler for å forstå hvordan tjenesten brukes, slik at vi kan gjøre den bedre. Du velger selv hva du samtykker til.", acceptAll: "Godta alle", rejectAll: "Kun nødvendige", managePreferences: "Velg selv" }, me = { heading: "Innstillinger for informasjonskapsler", body: "Nødvendige informasjonskapsler er alltid på, fordi tjenesten ikke fungerer uten dem. De øvrige velger du selv.", savePreferences: "Lagre valg", acceptAll: "Godta alle", rejectAll: "Kun nødvendige", close: "Lukk", servicesLabel: "Tjenester", showCookies: "Vis informasjonskapsler", noCookies: "Setter ingen informasjonskapsler", alwaysOnHeading: "Alltid på", alwaysOnBody: "Disse lagrer ingenting på enheten din og kan ikke brukes til å kjenne deg igjen. De krever derfor ikke samtykke, og er alltid på.", cookieName: "Navn", cookieProvider: "Levert av", cookieDuration: "Varighet" }, pe = { session: "Til du lukker nettleseren", day: "{{count}} dag", days: "{{count}} dager", month: "{{count}} måned", months: "{{count}} måneder", year: "{{count}} år", years: "{{count}} år" }, fe = { necessary: { title: "Nødvendige", description: "Kreves for at tjenesten skal fungere, blant annet for innlogging og sikkerhet. Disse kan ikke slås av." }, functionality: { title: "Funksjonalitet", description: "Husker valgene dine, som språk og andre innstillinger." }, measurement: { title: "Statistikk", description: "Lar oss telle besøk og se hvilke sider som brukes, slik at vi kan prioritere riktig." }, experience: { title: "Brukeropplevelse", description: "Lar oss se hvordan sidene faktisk brukes, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskelig." }, marketing: { title: "Markedsføring", description: "Brukes til å tilpasse annonser. Kystverket bruker ikke dette i dag." } }, ve = "Administrer informasjonskapsler", be = {
97
214
  banner: ye,
98
- dialog: pe,
99
- durations: fe,
100
- categories: ve,
101
- manageLink: be
102
- }, _ = {
103
- "nb-NO": me,
104
- "nn-NO": _e,
105
- "en-US": le
106
- }, P = "nb-NO";
107
- function Ce(e) {
108
- var i;
215
+ dialog: me,
216
+ durations: pe,
217
+ categories: fe,
218
+ manageLink: ve
219
+ }, _e = { heading: "Informasjonskapslar", body: "Vi brukar informasjonskapslar for å forstå korleis tenesta blir brukt, slik at vi kan gjere henne betre. Du vel sjølv kva du samtykkjer til.", acceptAll: "Godta alle", rejectAll: "Berre nødvendige", managePreferences: "Vel sjølv" }, Ce = { heading: "Innstillingar for informasjonskapslar", body: "Nødvendige informasjonskapslar er alltid på, fordi tenesta ikkje fungerer utan dei. Dei andre vel du sjølv.", savePreferences: "Lagre val", acceptAll: "Godta alle", rejectAll: "Berre nødvendige", close: "Lukk", servicesLabel: "Tenester", showCookies: "Vis informasjonskapslar", noCookies: "Set ingen informasjonskapslar", alwaysOnHeading: "Alltid på", alwaysOnBody: "Desse lagrar ingenting på eininga di og kan ikkje brukast til å kjenne deg att. Dei krev difor ikkje samtykke, og er alltid på.", cookieName: "Namn", cookieProvider: "Levert av", cookieDuration: "Varigheit" }, we = { session: "Til du lukkar nettlesaren", day: "{{count}} dag", days: "{{count}} dagar", month: "{{count}} månad", months: "{{count}} månader", year: "{{count}} år", years: "{{count}} år" }, je = { necessary: { title: "Nødvendige", description: "Krevst for at tenesta skal fungere, mellom anna for innlogging og tryggleik. Desse kan ikkje slåast av." }, functionality: { title: "Funksjonalitet", description: "Hugsar vala dine, som språk og andre innstillingar." }, measurement: { title: "Statistikk", description: "Lèt oss telje besøk og sjå kva sider som blir brukte, slik at vi kan prioritere rett." }, experience: { title: "Brukaroppleving", description: "Lèt oss sjå korleis sidene faktisk blir brukte, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskeleg." }, marketing: { title: "Marknadsføring", description: "Blir brukt til å tilpasse annonsar. Kystverket brukar ikkje dette i dag." } }, Se = "Administrer informasjonskapslar", Ne = {
220
+ banner: _e,
221
+ dialog: Ce,
222
+ durations: we,
223
+ categories: je,
224
+ manageLink: Se
225
+ }, w = {
226
+ "nb-NO": be,
227
+ "nn-NO": Ne,
228
+ "en-US": ke
229
+ }, q = "nb-NO";
230
+ function xe(e) {
231
+ var o;
109
232
  if (!e)
110
- return _[P];
111
- const n = _[e];
233
+ return w[q];
234
+ const n = w[e];
112
235
  if (n)
113
236
  return n;
114
- const t = (i = e.split("-")[0]) == null ? void 0 : i.toLowerCase(), r = Object.keys(_).find((s) => s.split("-")[0].toLowerCase() === t);
115
- return r ? _[r] : _[P];
237
+ const t = (o = e.split("-")[0]) == null ? void 0 : o.toLowerCase(), i = Object.keys(w).find((r) => r.split("-")[0].toLowerCase() === t);
238
+ return i ? w[i] : w[q];
116
239
  }
117
- function je(e, n) {
240
+ function Le(e, n) {
118
241
  const { durations: t } = n;
119
242
  if (e === "session")
120
243
  return t.session;
121
- const r = (i, s) => i.replace("{{count}}", String(s));
244
+ const i = (o, r) => o.replace("{{count}}", String(r));
122
245
  if (e >= 365 && e % 365 === 0) {
123
- const i = e / 365;
124
- return r(i === 1 ? t.year : t.years, i);
246
+ const o = e / 365;
247
+ return i(o === 1 ? t.year : t.years, o);
125
248
  }
126
249
  if (e >= 28) {
127
- const i = Math.round(e / 30.4);
128
- if (i >= 1)
129
- return r(i === 1 ? t.month : t.months, i);
250
+ const o = Math.round(e / 30.4);
251
+ if (o >= 1)
252
+ return i(o === 1 ? t.month : t.months, o);
130
253
  }
131
- return r(e === 1 ? t.day : t.days, e);
254
+ return i(e === 1 ? t.day : t.days, e);
132
255
  }
133
- function we(e, n) {
256
+ function Ae(e, n) {
134
257
  return n ? {
135
258
  banner: { ...e.banner, ...n.banner },
136
259
  dialog: { ...e.dialog, ...n.dialog },
@@ -139,309 +262,229 @@ function we(e, n) {
139
262
  manageLink: n.manageLink ?? e.manageLink
140
263
  } : e;
141
264
  }
142
- function hn({ children: e, language: n, translations: t, ...r }) {
143
- const i = N(null);
144
- i.current ?? (i.current = ee(r));
145
- const s = i.current, { services: d } = r, g = d.map((h) => h.id).join(","), [m, p] = F(!1);
146
- w(() => p(!0), []);
147
- const y = te(), u = G(
265
+ function wn({ children: e, language: n, translations: t, ...i }) {
266
+ const o = x(null);
267
+ o.current ?? (o.current = oe(i));
268
+ const r = o.current, { services: c } = i, u = c.map((f) => f.id).join(","), [h, _] = Z(!1);
269
+ j(() => _(!0), []), j(() => ce(c), [u]);
270
+ const y = ie(), m = Q(
148
271
  () => ({
149
- store: s,
150
- translations: we(Ce(n), t),
151
- showsBanner: z(d),
152
- mounted: m
272
+ store: r,
273
+ translations: Ae(xe(n), t),
274
+ showsBanner: ee(c),
275
+ mounted: h
153
276
  }),
154
277
  // `serviceIds` står her med vilje i stedet for `services`: lista bygges som regel inline
155
278
  // hos kallstedet og har ny identitet ved hver render, mens innholdet er det samme.
156
- [s, n, t, g, m]
279
+ [r, n, t, u, h]
157
280
  );
158
- return /* @__PURE__ */ o(U.Provider, { value: u, children: /* @__PURE__ */ o(ne, { value: y, children: e }) });
281
+ return /* @__PURE__ */ s(R.Provider, { value: m, children: /* @__PURE__ */ s(re, { value: y, children: e }) });
159
282
  }
160
283
  function k(e, n) {
161
- const t = N(null);
162
- return Z(e.subscribe, () => n(e.getState()), () => (t.current ?? (t.current = { value: n(e.getState()) }), t.current.value));
284
+ const t = x(null);
285
+ return Y(e.subscribe, () => n(e.getState()), () => (t.current ?? (t.current = { value: n(e.getState()) }), t.current.value));
163
286
  }
164
- function Ne() {
165
- const { store: e } = C(), n = k(e, (s) => s.consents), t = k(e, (s) => s.activeUI), r = k(e, (s) => s.consentInfo), i = k(e, (s) => s.isLoadingConsentInfo);
287
+ function De() {
288
+ const { store: e } = S(), n = k(e, (r) => r.consents), t = k(e, (r) => r.activeUI), i = k(e, (r) => r.consentInfo), o = k(e, (r) => r.isLoadingConsentInfo);
166
289
  return {
167
- hasConsent: (s) => e.getState().has(s),
290
+ hasConsent: (r) => e.getState().has(r),
168
291
  consents: n,
169
- needsDecision: !i && r === null,
292
+ needsDecision: !o && i === null,
170
293
  showPreferences: () => e.getState().setActiveUI("dialog"),
171
294
  close: () => e.getState().setActiveUI("none"),
172
295
  activeUI: t
173
296
  };
174
297
  }
175
- const Se = "_button_ax4nf_2", xe = "_filled_ax4nf_29", Le = "_outline_ax4nf_42", De = "_ghost_ax4nf_48", q = {
176
- button: Se,
177
- filled: xe,
178
- outline: Le,
179
- ghost: De
298
+ const Pe = "_button_ax4nf_2", Te = "_filled_ax4nf_29", Ie = "_outline_ax4nf_42", $e = "_ghost_ax4nf_48", B = {
299
+ button: Pe,
300
+ filled: Te,
301
+ outline: Ie,
302
+ ghost: $e
180
303
  };
181
- function v({ variant: e = "filled", className: n, type: t = "button", ...r }) {
182
- return /* @__PURE__ */ o("button", { ...r, type: t, className: [q.button, q[e], n].filter(Boolean).join(" ") });
183
- }
184
- const Te = "_banner_rr9rr_2", Ae = "_inner_rr9rr_15", $e = "_text_rr9rr_23", Pe = "_heading_rr9rr_29", qe = "_body_rr9rr_38", Ie = "_actions_rr9rr_45", f = {
185
- banner: Te,
186
- inner: Ae,
187
- text: $e,
188
- heading: Pe,
189
- body: qe,
190
- actions: Ie
304
+ function b({ variant: e = "filled", className: n, type: t = "button", ...i }) {
305
+ return /* @__PURE__ */ s("button", { ...i, type: t, className: [B.button, B[e], n].filter(Boolean).join(" ") });
306
+ }
307
+ const qe = "_banner_rr9rr_2", Be = "_inner_rr9rr_15", Ue = "_text_rr9rr_23", Oe = "_heading_rr9rr_29", Re = "_body_rr9rr_38", Me = "_actions_rr9rr_45", v = {
308
+ banner: qe,
309
+ inner: Be,
310
+ text: Ue,
311
+ heading: Oe,
312
+ body: Re,
313
+ actions: Me
191
314
  };
192
- function Be() {
193
- const { store: e, translations: n, showsBanner: t, mounted: r } = C(), i = k(e, (m) => m.activeUI), s = r && t && i === "banner";
194
- if (H("ConsentBanner", s), !s)
315
+ function He() {
316
+ const { store: e, translations: n, showsBanner: t, mounted: i } = S(), o = k(e, (h) => h.activeUI), r = i && t && o === "banner";
317
+ if (K("ConsentBanner", r), !r)
195
318
  return null;
196
- const { saveConsents: d, setActiveUI: g } = e.getState();
197
- return /* @__PURE__ */ o("section", { className: f.banner, "data-color": "primary", "aria-labelledby": "styrbord-consent-banner-heading", children: /* @__PURE__ */ l("div", { className: f.inner, children: [
198
- /* @__PURE__ */ l("div", { className: f.text, children: [
199
- /* @__PURE__ */ o("h2", { id: "styrbord-consent-banner-heading", className: f.heading, children: n.banner.heading }),
200
- /* @__PURE__ */ o("p", { className: f.body, children: n.banner.body })
319
+ const { saveConsents: c, setActiveUI: u } = e.getState();
320
+ return /* @__PURE__ */ s("section", { className: v.banner, "data-color": "primary", "aria-labelledby": "styrbord-consent-banner-heading", children: /* @__PURE__ */ d("div", { className: v.inner, children: [
321
+ /* @__PURE__ */ d("div", { className: v.text, children: [
322
+ /* @__PURE__ */ s("h2", { id: "styrbord-consent-banner-heading", className: v.heading, children: n.banner.heading }),
323
+ /* @__PURE__ */ s("p", { className: v.body, children: n.banner.body })
201
324
  ] }),
202
- /* @__PURE__ */ l("div", { className: f.actions, children: [
203
- /* @__PURE__ */ o(v, { variant: "filled", onClick: () => d("all"), children: n.banner.acceptAll }),
204
- /* @__PURE__ */ o(v, { variant: "outline", onClick: () => d("necessary"), children: n.banner.rejectAll }),
205
- /* @__PURE__ */ o(v, { variant: "ghost", onClick: () => g("dialog"), children: n.banner.managePreferences })
325
+ /* @__PURE__ */ d("div", { className: v.actions, children: [
326
+ /* @__PURE__ */ s(b, { variant: "filled", onClick: () => c("all"), children: n.banner.acceptAll }),
327
+ /* @__PURE__ */ s(b, { variant: "outline", onClick: () => c("necessary"), children: n.banner.rejectAll }),
328
+ /* @__PURE__ */ s(b, { variant: "ghost", onClick: () => u("dialog"), children: n.banner.managePreferences })
206
329
  ] })
207
330
  ] }) });
208
331
  }
209
- const Ue = "_input_oxxbn_10", Oe = "_label_oxxbn_53", Me = "_description_oxxbn_62", j = {
332
+ const Ee = "_input_oxxbn_10", Ke = "_label_oxxbn_53", Ve = "_description_oxxbn_62", N = {
210
333
  switch: "_switch_oxxbn_2",
211
- input: Ue,
212
- label: Oe,
213
- description: Me
334
+ input: Ee,
335
+ label: Ke,
336
+ description: Ve
214
337
  };
215
- function He({ label: e, description: n, checked: t, onChange: r }) {
216
- const i = Q(), s = `${i}-description`;
217
- return /* @__PURE__ */ l("div", { className: j.switch, children: [
218
- /* @__PURE__ */ o("input", { id: i, type: "checkbox", role: "switch", className: j.input, checked: t, onChange: r, "aria-describedby": n ? s : void 0 }),
219
- /* @__PURE__ */ o("label", { className: j.label, htmlFor: i, children: e }),
220
- n && /* @__PURE__ */ o("p", { id: s, className: j.description, children: n })
338
+ function Fe({ label: e, description: n, checked: t, onChange: i }) {
339
+ const o = z(), r = `${o}-description`;
340
+ return /* @__PURE__ */ d("div", { className: N.switch, children: [
341
+ /* @__PURE__ */ s("input", { id: o, type: "checkbox", role: "switch", className: N.input, checked: t, onChange: i, "aria-describedby": n ? r : void 0 }),
342
+ /* @__PURE__ */ s("label", { className: N.label, htmlFor: o, children: e }),
343
+ n && /* @__PURE__ */ s("p", { id: r, className: N.description, children: n })
221
344
  ] });
222
345
  }
223
- const Re = "_dialog_1y45s_2", Ee = "_content_1y45s_26", Ke = "_header_1y45s_34", Ve = "_heading_1y45s_41", Fe = "_close_1y45s_50", Ge = "_summary_1y45s_75", Ze = "_body_1y45s_80", Qe = "_fineprint_1y45s_87", We = "_categories_1y45s_95", Ye = "_category_1y45s_101", ze = "_categoryHeading_1y45s_114", Xe = "_services_1y45s_122", Je = "_details_1y45s_129", en = "_table_1y45s_142", nn = "_buttons_1y45s_162", c = {
224
- dialog: Re,
225
- content: Ee,
226
- header: Ke,
227
- heading: Ve,
228
- close: Fe,
229
- summary: Ge,
230
- body: Ze,
231
- fineprint: Qe,
232
- categories: We,
233
- category: Ye,
234
- categoryHeading: ze,
235
- services: Xe,
236
- details: Je,
237
- table: en,
238
- buttons: nn
346
+ const Ge = "_dialog_1y45s_2", We = "_content_1y45s_26", Ze = "_header_1y45s_34", Qe = "_heading_1y45s_41", Ye = "_close_1y45s_50", ze = "_summary_1y45s_75", Xe = "_body_1y45s_80", Je = "_fineprint_1y45s_87", en = "_categories_1y45s_95", nn = "_category_1y45s_101", tn = "_categoryHeading_1y45s_114", sn = "_services_1y45s_122", on = "_details_1y45s_129", rn = "_table_1y45s_142", an = "_buttons_1y45s_162", l = {
347
+ dialog: Ge,
348
+ content: We,
349
+ header: Ze,
350
+ heading: Qe,
351
+ close: Ye,
352
+ summary: ze,
353
+ body: Xe,
354
+ fineprint: Je,
355
+ categories: en,
356
+ category: nn,
357
+ categoryHeading: tn,
358
+ services: sn,
359
+ details: on,
360
+ table: rn,
361
+ buttons: an
239
362
  };
240
363
  function D({ services: e, translations: n }) {
241
- if (!e.some((i) => i.cookies !== void 0))
364
+ if (!e.some((o) => o.cookies !== void 0))
242
365
  return null;
243
- const r = e.flatMap((i) => (i.cookies ?? []).map((s) => ({ ...s, provider: i.displayName ?? i.id })));
244
- return r.length === 0 ? /* @__PURE__ */ o("p", { className: c.fineprint, children: n.dialog.noCookies }) : /* @__PURE__ */ l("details", { className: c.details, children: [
245
- /* @__PURE__ */ o("summary", { className: c.summary, children: n.dialog.showCookies }),
246
- /* @__PURE__ */ l("table", { className: c.table, children: [
247
- /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ l("tr", { children: [
248
- /* @__PURE__ */ o("th", { scope: "col", children: n.dialog.cookieName }),
249
- /* @__PURE__ */ o("th", { scope: "col", children: n.dialog.cookieProvider }),
250
- /* @__PURE__ */ o("th", { scope: "col", children: n.dialog.cookieDuration })
366
+ const i = e.flatMap((o) => (o.cookies ?? []).map((r) => ({ ...r, provider: o.displayName ?? o.id })));
367
+ return i.length === 0 ? /* @__PURE__ */ s("p", { className: l.fineprint, children: n.dialog.noCookies }) : /* @__PURE__ */ d("details", { className: l.details, children: [
368
+ /* @__PURE__ */ s("summary", { className: l.summary, children: n.dialog.showCookies }),
369
+ /* @__PURE__ */ d("table", { className: l.table, children: [
370
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ d("tr", { children: [
371
+ /* @__PURE__ */ s("th", { scope: "col", children: n.dialog.cookieName }),
372
+ /* @__PURE__ */ s("th", { scope: "col", children: n.dialog.cookieProvider }),
373
+ /* @__PURE__ */ s("th", { scope: "col", children: n.dialog.cookieDuration })
251
374
  ] }) }),
252
- /* @__PURE__ */ o("tbody", { children: r.map((i) => /* @__PURE__ */ l("tr", { children: [
253
- /* @__PURE__ */ o("td", { children: /* @__PURE__ */ o("code", { children: i.name }) }),
254
- /* @__PURE__ */ o("td", { children: i.provider }),
255
- /* @__PURE__ */ o("td", { children: je(i.duration, n) })
256
- ] }, `${i.provider}-${i.name}`)) })
375
+ /* @__PURE__ */ s("tbody", { children: i.map((o) => /* @__PURE__ */ d("tr", { children: [
376
+ /* @__PURE__ */ s("td", { children: /* @__PURE__ */ s("code", { children: o.name }) }),
377
+ /* @__PURE__ */ s("td", { children: o.provider }),
378
+ /* @__PURE__ */ s("td", { children: Le(o.duration, n) })
379
+ ] }, `${o.provider}-${o.name}`)) })
257
380
  ] })
258
381
  ] });
259
382
  }
260
- function I({ services: e, translations: n }) {
261
- return e.length === 0 ? null : /* @__PURE__ */ l("p", { className: c.fineprint, children: [
383
+ function U({ services: e, translations: n }) {
384
+ return e.length === 0 ? null : /* @__PURE__ */ d("p", { className: l.fineprint, children: [
262
385
  n.dialog.servicesLabel,
263
386
  ": ",
264
387
  e.map((t) => t.displayName ?? t.id).join(", ")
265
388
  ] });
266
389
  }
267
- function tn() {
268
- const { store: e, translations: n, mounted: t } = C(), r = k(e, (a) => a.activeUI), i = k(e, (a) => a.selectedConsents), s = k(e, (a) => a.scripts), d = N(null), g = r === "dialog";
269
- se(), w(() => {
270
- const a = d.current;
271
- a && (g && !a.open ? a.showModal() : !g && a.open && a.close());
272
- }, [g]);
273
- const m = A(s), { setSelectedConsent: p, saveConsents: y, setActiveUI: u } = e.getState();
390
+ function cn() {
391
+ const { store: e, translations: n, mounted: t } = S(), i = k(e, (a) => a.activeUI), o = k(e, (a) => a.selectedConsents), r = k(e, (a) => a.scripts), c = x(null), u = i === "dialog";
392
+ ae(), j(() => {
393
+ const a = c.current;
394
+ a && (u && !a.open ? a.showModal() : !u && a.open && a.close());
395
+ }, [u]);
396
+ const h = T(r), { setSelectedConsent: _, saveConsents: y, setActiveUI: m } = e.getState();
274
397
  if (!t)
275
398
  return null;
276
- const h = s.filter((a) => a.category === "necessary"), S = s.filter((a) => a.alwaysLoad && a.category !== "necessary"), R = (a) => s.filter((b) => !b.alwaysLoad && b.category === a), E = (a) => {
277
- a.target === d.current && u("none");
399
+ const f = r.filter((a) => a.category === "necessary"), g = r.filter((a) => a.alwaysLoad && a.category !== "necessary"), p = (a) => r.filter((C) => !C.alwaysLoad && C.category === a), F = (a) => {
400
+ a.target === c.current && m("none");
278
401
  };
279
- return /* @__PURE__ */ l("dialog", { ref: d, className: c.dialog, "data-color": "primary", "aria-labelledby": "styrbord-consent-dialog-heading", onClose: () => u("none"), onClick: E, children: [
280
- /* @__PURE__ */ l("div", { className: c.content, children: [
281
- /* @__PURE__ */ l("div", { className: c.header, children: [
282
- /* @__PURE__ */ o("h2", { id: "styrbord-consent-dialog-heading", className: c.heading, children: n.dialog.heading }),
283
- /* @__PURE__ */ o("button", { type: "button", className: c.close, "aria-label": n.dialog.close, onClick: () => u("none"), children: /* @__PURE__ */ o("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": !0, focusable: "false", children: /* @__PURE__ */ o("path", { d: "m6 6 12 12M18 6 6 18", strokeLinecap: "round" }) }) })
402
+ return /* @__PURE__ */ d("dialog", { ref: c, className: l.dialog, "data-color": "primary", "aria-labelledby": "styrbord-consent-dialog-heading", onClose: () => m("none"), onClick: F, children: [
403
+ /* @__PURE__ */ d("div", { className: l.content, children: [
404
+ /* @__PURE__ */ d("div", { className: l.header, children: [
405
+ /* @__PURE__ */ s("h2", { id: "styrbord-consent-dialog-heading", className: l.heading, children: n.dialog.heading }),
406
+ /* @__PURE__ */ s("button", { type: "button", className: l.close, "aria-label": n.dialog.close, onClick: () => m("none"), children: /* @__PURE__ */ s("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": !0, focusable: "false", children: /* @__PURE__ */ s("path", { d: "m6 6 12 12M18 6 6 18", strokeLinecap: "round" }) }) })
284
407
  ] }),
285
- /* @__PURE__ */ o("p", { className: c.body, children: n.dialog.body }),
286
- /* @__PURE__ */ l("div", { className: c.categories, children: [
287
- /* @__PURE__ */ l("section", { className: c.category, children: [
288
- /* @__PURE__ */ o("h3", { className: c.categoryHeading, children: n.categories.necessary.title }),
289
- /* @__PURE__ */ o("p", { className: c.body, children: n.categories.necessary.description }),
290
- /* @__PURE__ */ o(D, { services: h, translations: n })
408
+ /* @__PURE__ */ s("p", { className: l.body, children: n.dialog.body }),
409
+ /* @__PURE__ */ d("div", { className: l.categories, children: [
410
+ /* @__PURE__ */ d("section", { className: l.category, children: [
411
+ /* @__PURE__ */ s("h3", { className: l.categoryHeading, children: n.categories.necessary.title }),
412
+ /* @__PURE__ */ s("p", { className: l.body, children: n.categories.necessary.description }),
413
+ /* @__PURE__ */ s(D, { services: f, translations: n })
291
414
  ] }),
292
- S.length > 0 && /* @__PURE__ */ l("section", { className: c.category, children: [
293
- /* @__PURE__ */ o("h3", { className: c.categoryHeading, children: n.dialog.alwaysOnHeading }),
294
- /* @__PURE__ */ o("p", { className: c.body, children: n.dialog.alwaysOnBody }),
295
- /* @__PURE__ */ o(I, { services: S, translations: n }),
296
- /* @__PURE__ */ o(D, { services: S, translations: n })
415
+ g.length > 0 && /* @__PURE__ */ d("section", { className: l.category, children: [
416
+ /* @__PURE__ */ s("h3", { className: l.categoryHeading, children: n.dialog.alwaysOnHeading }),
417
+ /* @__PURE__ */ s("p", { className: l.body, children: n.dialog.alwaysOnBody }),
418
+ /* @__PURE__ */ s(U, { services: g, translations: n }),
419
+ /* @__PURE__ */ s(D, { services: g, translations: n })
297
420
  ] }),
298
- m.map((a) => {
299
- const b = R(a);
300
- return /* @__PURE__ */ l("section", { className: c.category, children: [
301
- /* @__PURE__ */ o(He, { label: n.categories[a].title, description: n.categories[a].description, checked: i[a] === !0, onChange: (K) => p(a, K.target.checked) }),
302
- /* @__PURE__ */ l("div", { className: c.services, children: [
303
- /* @__PURE__ */ o(I, { services: b, translations: n }),
304
- /* @__PURE__ */ o(D, { services: b, translations: n })
421
+ h.map((a) => {
422
+ const C = p(a);
423
+ return /* @__PURE__ */ d("section", { className: l.category, children: [
424
+ /* @__PURE__ */ s(Fe, { label: n.categories[a].title, description: n.categories[a].description, checked: o[a] === !0, onChange: (G) => _(a, G.target.checked) }),
425
+ /* @__PURE__ */ d("div", { className: l.services, children: [
426
+ /* @__PURE__ */ s(U, { services: C, translations: n }),
427
+ /* @__PURE__ */ s(D, { services: C, translations: n })
305
428
  ] })
306
429
  ] }, a);
307
430
  })
308
431
  ] })
309
432
  ] }),
310
- /* @__PURE__ */ l("div", { className: c.buttons, children: [
311
- /* @__PURE__ */ o(v, { variant: "filled", onClick: () => y("custom"), children: n.dialog.savePreferences }),
312
- /* @__PURE__ */ o(v, { variant: "outline", onClick: () => y("all"), children: n.dialog.acceptAll }),
313
- /* @__PURE__ */ o(v, { variant: "ghost", onClick: () => y("necessary"), children: n.dialog.rejectAll })
433
+ /* @__PURE__ */ d("div", { className: l.buttons, children: [
434
+ /* @__PURE__ */ s(b, { variant: "filled", onClick: () => y("custom"), children: n.dialog.savePreferences }),
435
+ /* @__PURE__ */ s(b, { variant: "outline", onClick: () => y("all"), children: n.dialog.acceptAll }),
436
+ /* @__PURE__ */ s(b, { variant: "ghost", onClick: () => y("necessary"), children: n.dialog.rejectAll })
314
437
  ] })
315
438
  ] });
316
439
  }
317
- const sn = "_button_zo1st_2", on = {
318
- button: sn
440
+ const ln = "_button_zo1st_2", dn = {
441
+ button: ln
319
442
  };
320
- function rn() {
321
- return /* @__PURE__ */ o("svg", { xmlns: "http://www.w3.org/2000/svg", height: "20px", viewBox: "0 -960 960 960", width: "20px", children: /* @__PURE__ */ o("path", { color: "currentColor", d: "M480-96q-79.38 0-149.19-30T208.5-208.5Q156-261 126-330.81T96-480q0-81 31-151.5t82.5-123Q261-807 329-837.5T470-868q23 0 45 3t45 9q-8 45 5.5 82t42.03 60.96q28.53 23.96 68 33T759-681q-24 57 8.01 108.5 32.01 51.49 95.08 53.4.95 10.49 1.43 19.55T864-480q0 78-30.24 147.98-30.24 69.99-82.08 122.6t-121.92 83.01Q559.68-96 480-96Zm-60-456q25 0 42.5-17.5T480-612q0-25-17.5-42.5T420-672q-25 0-42.5 17.5T360-612q0 25 17.5 42.5T420-552Zm-96 192q25 0 42.5-17.5T384-420q0-25-17.5-42.5T324-480q-25 0-42.5 17.5T264-420q0 25 17.5 42.5T324-360Zm275.79 36q15.21 0 25.71-10.29t10.5-25.5q0-15.21-10.29-25.71t-25.5-10.5q-15.21 0-25.71 10.29t-10.5 25.5q0 15.21 10.29 25.71t25.5 10.5ZM480-168q125 0 214.5-84.5T792-462q-45-18-75-55.5T679-603q-76-11-129-63t-63-126q-63-4-120.5 19.5t-102 66.5Q220-663 194-604.5T168-480q0 129.67 91.16 220.84Q350.33-168 480-168Zm0-311Z" }) });
443
+ function un() {
444
+ return /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", height: "20px", viewBox: "0 -960 960 960", width: "20px", children: /* @__PURE__ */ s("path", { color: "currentColor", d: "M480-96q-79.38 0-149.19-30T208.5-208.5Q156-261 126-330.81T96-480q0-81 31-151.5t82.5-123Q261-807 329-837.5T470-868q23 0 45 3t45 9q-8 45 5.5 82t42.03 60.96q28.53 23.96 68 33T759-681q-24 57 8.01 108.5 32.01 51.49 95.08 53.4.95 10.49 1.43 19.55T864-480q0 78-30.24 147.98-30.24 69.99-82.08 122.6t-121.92 83.01Q559.68-96 480-96Zm-60-456q25 0 42.5-17.5T480-612q0-25-17.5-42.5T420-672q-25 0-42.5 17.5T360-612q0 25 17.5 42.5T420-552Zm-96 192q25 0 42.5-17.5T384-420q0-25-17.5-42.5T324-480q-25 0-42.5 17.5T264-420q0 25 17.5 42.5T324-360Zm275.79 36q15.21 0 25.71-10.29t10.5-25.5q0-15.21-10.29-25.71t-25.5-10.5q-15.21 0-25.71 10.29t-10.5 25.5q0 15.21 10.29 25.71t25.5 10.5ZM480-168q125 0 214.5-84.5T792-462q-45-18-75-55.5T679-603q-76-11-129-63t-63-126q-63-4-120.5 19.5t-102 66.5Q220-663 194-604.5T168-480q0 129.67 91.16 220.84Q350.33-168 480-168Zm0-311Z" }) });
322
445
  }
323
- function an() {
324
- const { store: e, translations: n, showsBanner: t, mounted: r } = C(), i = k(e, (d) => d.activeUI), s = r && t && i === "none";
325
- return H("ConsentSettingsButton", s), s ? /* @__PURE__ */ o("button", { type: "button", className: on.button, "data-color": "neutral", "aria-label": n.manageLink, title: n.manageLink, onClick: () => e.getState().setActiveUI("dialog"), children: /* @__PURE__ */ o(rn, {}) }) : null;
446
+ function gn() {
447
+ const { store: e, translations: n, showsBanner: t, mounted: i } = S(), o = k(e, (c) => c.activeUI), r = i && t && o === "none";
448
+ return K("ConsentSettingsButton", r), r ? /* @__PURE__ */ s("button", { type: "button", className: dn.button, "data-color": "neutral", "aria-label": n.manageLink, title: n.manageLink, onClick: () => e.getState().setActiveUI("dialog"), children: /* @__PURE__ */ s(un, {}) }) : null;
326
449
  }
327
- const cn = "_link_6z1zn_4", ln = {
328
- link: cn
450
+ const hn = "_link_6z1zn_4", kn = {
451
+ link: hn
329
452
  };
330
- function kn() {
331
- return /* @__PURE__ */ l(V, { children: [
332
- /* @__PURE__ */ o(Be, {}),
333
- /* @__PURE__ */ o(tn, {}),
334
- /* @__PURE__ */ o(an, {})
453
+ function jn() {
454
+ return /* @__PURE__ */ d(W, { children: [
455
+ /* @__PURE__ */ s(He, {}),
456
+ /* @__PURE__ */ s(cn, {}),
457
+ /* @__PURE__ */ s(gn, {})
335
458
  ] });
336
459
  }
337
- function mn({ className: e }) {
338
- const { translations: n } = C(), { showPreferences: t } = Ne();
339
- return /* @__PURE__ */ o("button", { type: "button", className: [ln.link, e].filter(Boolean).join(" "), onClick: t, children: n.manageLink });
340
- }
341
- function yn({ domain: e, requireConsent: n = !1, scriptSrc: t = "https://plausible.io/js/script.js" }) {
342
- return {
343
- id: "plausible",
344
- displayName: "Plausible",
345
- src: t,
346
- category: "measurement",
347
- alwaysLoad: !n,
348
- defer: !0,
349
- attributes: { "data-domain": e },
350
- // Tom liste, ikke utelatt: dialogen skiller mellom «setter ingen kapsler» og «vi har
351
- // ikke oppgitt noe», og det kapselfrie er hele grunnen til at Plausible går usamtykket.
352
- cookies: []
353
- };
354
- }
355
- function pn({ siteId: e }) {
356
- return {
357
- id: "hotjar",
358
- displayName: "Hotjar",
359
- category: "experience",
360
- clearCookiePrefixes: ["_hj"],
361
- cookies: [
362
- { name: "_hjSessionUser_*", duration: 365 },
363
- { name: "_hjSession_*", duration: 1 },
364
- { name: "_hjIncludedInSessionSample_*", duration: 1 }
365
- ],
366
- textContent: `
367
- (function (h, o, t, j, a, r) {
368
- h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments); };
369
- h._hjSettings = { hjid: ${Number(e)}, hjsv: 6 };
370
- a = o.getElementsByTagName('head')[0];
371
- r = o.createElement('script');
372
- r.async = 1;
373
- r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
374
- a.appendChild(r);
375
- })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
376
- `
377
- };
378
- }
379
- function fn({ apiKey: e, apiHost: n = "https://eu.i.posthog.com", assetHost: t, sessionReplay: r = !1, capturePageview: i = !0, personProfiles: s = "identified_only", defaults: d = "2026-05-30" }) {
380
- const g = n.replace(/\/$/, ""), m = (t ?? g.replace(".i.posthog.com", "-assets.i.posthog.com")).replace(/\/$/, ""), p = () => window.posthog, y = (u) => {
381
- if (!r)
382
- return;
383
- const h = p();
384
- h && (u.experience === !0 ? h.startSessionRecording() : h.stopSessionRecording());
385
- };
386
- return {
387
- id: "posthog",
388
- displayName: "PostHog",
389
- category: "measurement",
390
- clearCookiePrefixes: ["ph_"],
391
- // Kapselen heter `ph_<nøkkel>_posthog`. Nøkkelen er kjent her, så brukeren får se det
392
- // faktiske navnet framfor et jokertegn. PostHog speiler den samme verdien til localStorage,
393
- // som dialogen foreløpig ikke har noen måte å vise.
394
- cookies: [{ name: `ph_${e}_posthog`, duration: 365 }],
395
- src: `${m}/static/array.js`,
396
- onLoad: ({ consents: u }) => {
397
- var h;
398
- (h = p()) == null || h.init(e, {
399
- api_host: g,
400
- person_profiles: s,
401
- capture_pageview: i,
402
- defaults: d,
403
- // PostHog setter denne til `true` selv, som legger kapselen på toppdomenet. Samme felle
404
- // som c15t sin `crossSubdomain` — se kommentaren på `ConsentConfig.cookieDomain`.
405
- cross_subdomain_cookie: !1,
406
- disable_session_recording: !0,
407
- capture_heatmaps: r && u.experience === !0
408
- }), y(u);
409
- },
410
- onConsentChange: ({ consents: u }) => y(u)
411
- };
412
- }
413
- function vn(e = O, n = M) {
414
- return {
415
- id: "consent",
416
- displayName: "Kystverket",
417
- category: "necessary",
418
- callbackOnly: !0,
419
- alwaysLoad: !0,
420
- cookies: [{ name: e, duration: n }]
421
- };
460
+ function Sn({ className: e }) {
461
+ const { translations: n } = S(), { showPreferences: t } = De();
462
+ return /* @__PURE__ */ s("button", { type: "button", className: [kn.link, e].filter(Boolean).join(" "), onClick: t, children: n.manageLink });
422
463
  }
423
464
  export {
424
- Be as ConsentBanner,
425
- tn as ConsentPreferencesDialog,
426
- hn as ConsentProvider,
427
- an as ConsentSettingsButton,
428
- kn as CookieConsent,
429
- M as DEFAULT_EXPIRY_DAYS,
430
- O as DEFAULT_STORAGE_KEY,
431
- mn as ManageConsentLink,
432
- X as clearServiceCookies,
433
- vn as consentCookieService,
434
- _ as consentTranslations,
435
- ee as createConsentStore,
436
- P as defaultConsentLanguage,
437
- je as formatCookieDuration,
438
- Ce as getConsentTranslations,
439
- A as getSelectableCategories,
440
- z as hasGatedServices,
441
- pn as hotjarService,
442
- yn as plausibleService,
443
- fn as postHogService,
444
- Ne as useConsent,
445
- C as useConsentStore,
465
+ He as ConsentBanner,
466
+ cn as ConsentPreferencesDialog,
467
+ wn as ConsentProvider,
468
+ gn as ConsentSettingsButton,
469
+ jn as CookieConsent,
470
+ H as DEFAULT_EXPIRY_DAYS,
471
+ M as DEFAULT_STORAGE_KEY,
472
+ Sn as ManageConsentLink,
473
+ ne as clearServiceCookies,
474
+ te as clearServiceStorage,
475
+ Cn as consentCookieService,
476
+ w as consentTranslations,
477
+ oe as createConsentStore,
478
+ q as defaultConsentLanguage,
479
+ Le as formatCookieDuration,
480
+ xe as getConsentTranslations,
481
+ T as getSelectableCategories,
482
+ ee as hasGatedServices,
483
+ vn as hotjarService,
484
+ fn as plausibleService,
485
+ _n as postHogReplayService,
486
+ bn as postHogService,
487
+ De as useConsent,
488
+ S as useConsentStore,
446
489
  k as useStoreValue
447
490
  };
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- (function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react"),require("c15t")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","c15t"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.Styrbord={},i.jsxRuntime,i.React,i.c15t))})(this,(function(i,t,g,j){"use strict";const x=g.createContext(null);function b(){const e=g.useContext(x);if(!e)throw new Error("useConsentStore må brukes innenfor en <ConsentProvider>.");return e}const L="kystverket_consent",$=182;function w(e){const n=e.filter(s=>!s.alwaysLoad).map(s=>s.category).filter(s=>typeof s=="string").filter(s=>s!=="necessary");return[...new Set(n)]}function I(e){return w(e).length>0}function B(e,n,s){if(typeof document>"u")return;const r=e.filter(o=>o.alwaysLoad||typeof o.category!="string"?!1:n[o.category]!==!0).flatMap(o=>o.clearCookiePrefixes??[]);if(r.length===0)return;const a=document.cookie.split(";").map(o=>{var d;return(d=o.split("=")[0])==null?void 0:d.trim()}).filter(o=>!!o);for(const o of a)r.some(d=>o.startsWith(d))&&(j.deleteCookie(o),j.deleteCookie(o,{domain:window.location.hostname}),s&&j.deleteCookie(o,{domain:s}))}function Z(e){return{storageKey:e.storageKey??L,defaultExpiryDays:e.expiryDays??$,...e.cookieDomain?{defaultDomain:e.cookieDomain}:{}}}function U(e){const n=Z(e),s=j.configureConsentManager({mode:"offline",storageConfig:n});return j.createConsentManagerStore(s,{storageConfig:n,scripts:e.services,initialConsentCategories:w(e.services),debug:e.debug??!1,reloadOnConsentRevoked:!0,callbacks:{onConsentSet:({preferences:r})=>B(e.services,r,e.cookieDomain)}})}const T=g.createContext(null),Q=T.Provider;function W(){return g.useRef({count:0}).current}function z(){const e=g.useContext(T);g.useEffect(()=>{if(e)return e.count+=1,()=>{e.count-=1}},[e])}const D=new Set;function O(e,n){const s=g.useContext(T);g.useEffect(()=>{if(!n||!s||D.has(e))return;const r=setTimeout(()=>{s.count>0||D.has(e)||(D.add(e),console.warn(`<${e}> is shown without a <ConsentPreferencesDialog> mounted. Opening the consent settings will hide it with nothing to replace it, leaving the user unable to give or withdraw consent. Mount <ConsentPreferencesDialog> alongside it, or use <CookieConsent>, which mounts all three surfaces.`))},0);return()=>clearTimeout(r)},[n,e,s])}const v={"nb-NO":{banner:{heading:"Informasjonskapsler",body:"Vi bruker informasjonskapsler for å forstå hvordan tjenesten brukes, slik at vi kan gjøre den bedre. Du velger selv hva du samtykker til.",acceptAll:"Godta alle",rejectAll:"Kun nødvendige",managePreferences:"Velg selv"},dialog:{heading:"Innstillinger for informasjonskapsler",body:"Nødvendige informasjonskapsler er alltid på, fordi tjenesten ikke fungerer uten dem. De øvrige velger du selv.",savePreferences:"Lagre valg",acceptAll:"Godta alle",rejectAll:"Kun nødvendige",close:"Lukk",servicesLabel:"Tjenester",showCookies:"Vis informasjonskapsler",noCookies:"Setter ingen informasjonskapsler",alwaysOnHeading:"Alltid på",alwaysOnBody:"Disse lagrer ingenting på enheten din og kan ikke brukes til å kjenne deg igjen. De krever derfor ikke samtykke, og er alltid på.",cookieName:"Navn",cookieProvider:"Levert av",cookieDuration:"Varighet"},durations:{session:"Til du lukker nettleseren",day:"{{count}} dag",days:"{{count}} dager",month:"{{count}} måned",months:"{{count}} måneder",year:"{{count}} år",years:"{{count}} år"},categories:{necessary:{title:"Nødvendige",description:"Kreves for at tjenesten skal fungere, blant annet for innlogging og sikkerhet. Disse kan ikke slås av."},functionality:{title:"Funksjonalitet",description:"Husker valgene dine, som språk og andre innstillinger."},measurement:{title:"Statistikk",description:"Lar oss telle besøk og se hvilke sider som brukes, slik at vi kan prioritere riktig."},experience:{title:"Brukeropplevelse",description:"Lar oss se hvordan sidene faktisk brukes, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskelig."},marketing:{title:"Markedsføring",description:"Brukes til å tilpasse annonser. Kystverket bruker ikke dette i dag."}},manageLink:"Administrer informasjonskapsler"},"nn-NO":{banner:{heading:"Informasjonskapslar",body:"Vi brukar informasjonskapslar for å forstå korleis tenesta blir brukt, slik at vi kan gjere henne betre. Du vel sjølv kva du samtykkjer til.",acceptAll:"Godta alle",rejectAll:"Berre nødvendige",managePreferences:"Vel sjølv"},dialog:{heading:"Innstillingar for informasjonskapslar",body:"Nødvendige informasjonskapslar er alltid på, fordi tenesta ikkje fungerer utan dei. Dei andre vel du sjølv.",savePreferences:"Lagre val",acceptAll:"Godta alle",rejectAll:"Berre nødvendige",close:"Lukk",servicesLabel:"Tenester",showCookies:"Vis informasjonskapslar",noCookies:"Set ingen informasjonskapslar",alwaysOnHeading:"Alltid på",alwaysOnBody:"Desse lagrar ingenting på eininga di og kan ikkje brukast til å kjenne deg att. Dei krev difor ikkje samtykke, og er alltid på.",cookieName:"Namn",cookieProvider:"Levert av",cookieDuration:"Varigheit"},durations:{session:"Til du lukkar nettlesaren",day:"{{count}} dag",days:"{{count}} dagar",month:"{{count}} månad",months:"{{count}} månader",year:"{{count}} år",years:"{{count}} år"},categories:{necessary:{title:"Nødvendige",description:"Krevst for at tenesta skal fungere, mellom anna for innlogging og tryggleik. Desse kan ikkje slåast av."},functionality:{title:"Funksjonalitet",description:"Hugsar vala dine, som språk og andre innstillingar."},measurement:{title:"Statistikk",description:"Lèt oss telje besøk og sjå kva sider som blir brukte, slik at vi kan prioritere rett."},experience:{title:"Brukaroppleving",description:"Lèt oss sjå korleis sidene faktisk blir brukte, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskeleg."},marketing:{title:"Marknadsføring",description:"Blir brukt til å tilpasse annonsar. Kystverket brukar ikkje dette i dag."}},manageLink:"Administrer informasjonskapslar"},"en-US":{banner:{heading:"Cookies",body:"We use cookies to understand how this service is used, so that we can improve it. You decide what you consent to.",acceptAll:"Accept all",rejectAll:"Necessary only",managePreferences:"Choose yourself"},dialog:{heading:"Cookie settings",body:"Necessary cookies are always on, because the service does not work without them. The rest is up to you.",savePreferences:"Save choices",acceptAll:"Accept all",rejectAll:"Necessary only",close:"Close",servicesLabel:"Services",showCookies:"Show cookies",noCookies:"Sets no cookies",alwaysOnHeading:"Always on",alwaysOnBody:"These store nothing on your device and cannot be used to recognise you. They therefore do not require consent, and are always on.",cookieName:"Name",cookieProvider:"Provided by",cookieDuration:"Duration"},durations:{session:"Until you close your browser",day:"{{count}} day",days:"{{count}} days",month:"{{count}} month",months:"{{count}} months",year:"{{count}} year",years:"{{count}} years"},categories:{necessary:{title:"Necessary",description:"Required for the service to work, including sign-in and security. These cannot be turned off."},functionality:{title:"Functionality",description:"Remembers your choices, such as language and other settings."},measurement:{title:"Statistics",description:"Lets us count visits and see which pages are used, so we can prioritise correctly."},experience:{title:"User experience",description:"Lets us see how the pages are actually used, through anonymised recordings and heatmaps, so we can fix what is difficult."},marketing:{title:"Marketing",description:"Used to tailor advertising. Kystverket does not use this today."}},manageLink:"Manage cookies"}},A="nb-NO";function M(e){var a;if(!e)return v[A];const n=v[e];if(n)return n;const s=(a=e.split("-")[0])==null?void 0:a.toLowerCase(),r=Object.keys(v).find(o=>o.split("-")[0].toLowerCase()===s);return r?v[r]:v[A]}function E(e,n){const{durations:s}=n;if(e==="session")return s.session;const r=(a,o)=>a.replace("{{count}}",String(o));if(e>=365&&e%365===0){const a=e/365;return r(a===1?s.year:s.years,a)}if(e>=28){const a=Math.round(e/30.4);if(a>=1)return r(a===1?s.month:s.months,a)}return r(e===1?s.day:s.days,e)}function X(e,n){return n?{banner:{...e.banner,...n.banner},dialog:{...e.dialog,...n.dialog},durations:{...e.durations,...n.durations},categories:{...e.categories,...n.categories},manageLink:n.manageLink??e.manageLink}:e}function J({children:e,language:n,translations:s,...r}){const a=g.useRef(null);a.current??(a.current=U(r));const o=a.current,{services:d}=r,k=d.map(f=>f.id).join(","),[y,C]=g.useState(!1);g.useEffect(()=>C(!0),[]);const p=W(),u=g.useMemo(()=>({store:o,translations:X(M(n),s),showsBanner:I(d),mounted:y}),[o,n,s,k,y]);return t.jsx(x.Provider,{value:u,children:t.jsx(Q,{value:p,children:e})})}function h(e,n){const s=g.useRef(null);return g.useSyncExternalStore(e.subscribe,()=>n(e.getState()),()=>(s.current??(s.current={value:n(e.getState())}),s.current.value))}function H(){const{store:e}=b(),n=h(e,o=>o.consents),s=h(e,o=>o.activeUI),r=h(e,o=>o.consentInfo),a=h(e,o=>o.isLoadingConsentInfo);return{hasConsent:o=>e.getState().has(o),consents:n,needsDecision:!a&&r===null,showPreferences:()=>e.getState().setActiveUI("dialog"),close:()=>e.getState().setActiveUI("none"),activeUI:s}}const K={button:"_button_ax4nf_2",filled:"_filled_ax4nf_29",outline:"_outline_ax4nf_42",ghost:"_ghost_ax4nf_48"};function m({variant:e="filled",className:n,type:s="button",...r}){return t.jsx("button",{...r,type:s,className:[K.button,K[e],n].filter(Boolean).join(" ")})}const _={banner:"_banner_rr9rr_2",inner:"_inner_rr9rr_15",text:"_text_rr9rr_23",heading:"_heading_rr9rr_29",body:"_body_rr9rr_38",actions:"_actions_rr9rr_45"};function V(){const{store:e,translations:n,showsBanner:s,mounted:r}=b(),a=h(e,y=>y.activeUI),o=r&&s&&a==="banner";if(O("ConsentBanner",o),!o)return null;const{saveConsents:d,setActiveUI:k}=e.getState();return t.jsx("section",{className:_.banner,"data-color":"primary","aria-labelledby":"styrbord-consent-banner-heading",children:t.jsxs("div",{className:_.inner,children:[t.jsxs("div",{className:_.text,children:[t.jsx("h2",{id:"styrbord-consent-banner-heading",className:_.heading,children:n.banner.heading}),t.jsx("p",{className:_.body,children:n.banner.body})]}),t.jsxs("div",{className:_.actions,children:[t.jsx(m,{variant:"filled",onClick:()=>d("all"),children:n.banner.acceptAll}),t.jsx(m,{variant:"outline",onClick:()=>d("necessary"),children:n.banner.rejectAll}),t.jsx(m,{variant:"ghost",onClick:()=>k("dialog"),children:n.banner.managePreferences})]})]})})}const N={switch:"_switch_oxxbn_2",input:"_input_oxxbn_10",label:"_label_oxxbn_53",description:"_description_oxxbn_62"};function R({label:e,description:n,checked:s,onChange:r}){const a=g.useId(),o=`${a}-description`;return t.jsxs("div",{className:N.switch,children:[t.jsx("input",{id:a,type:"checkbox",role:"switch",className:N.input,checked:s,onChange:r,"aria-describedby":n?o:void 0}),t.jsx("label",{className:N.label,htmlFor:a,children:e}),n&&t.jsx("p",{id:o,className:N.description,children:n})]})}const l={dialog:"_dialog_1y45s_2",content:"_content_1y45s_26",header:"_header_1y45s_34",heading:"_heading_1y45s_41",close:"_close_1y45s_50",summary:"_summary_1y45s_75",body:"_body_1y45s_80",fineprint:"_fineprint_1y45s_87",categories:"_categories_1y45s_95",category:"_category_1y45s_101",categoryHeading:"_categoryHeading_1y45s_114",services:"_services_1y45s_122",details:"_details_1y45s_129",table:"_table_1y45s_142",buttons:"_buttons_1y45s_162"};function P({services:e,translations:n}){if(!e.some(a=>a.cookies!==void 0))return null;const r=e.flatMap(a=>(a.cookies??[]).map(o=>({...o,provider:a.displayName??a.id})));return r.length===0?t.jsx("p",{className:l.fineprint,children:n.dialog.noCookies}):t.jsxs("details",{className:l.details,children:[t.jsx("summary",{className:l.summary,children:n.dialog.showCookies}),t.jsxs("table",{className:l.table,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:n.dialog.cookieName}),t.jsx("th",{scope:"col",children:n.dialog.cookieProvider}),t.jsx("th",{scope:"col",children:n.dialog.cookieDuration})]})}),t.jsx("tbody",{children:r.map(a=>t.jsxs("tr",{children:[t.jsx("td",{children:t.jsx("code",{children:a.name})}),t.jsx("td",{children:a.provider}),t.jsx("td",{children:E(a.duration,n)})]},`${a.provider}-${a.name}`))})]})]})}function F({services:e,translations:n}){return e.length===0?null:t.jsxs("p",{className:l.fineprint,children:[n.dialog.servicesLabel,": ",e.map(s=>s.displayName??s.id).join(", ")]})}function G(){const{store:e,translations:n,mounted:s}=b(),r=h(e,c=>c.activeUI),a=h(e,c=>c.selectedConsents),o=h(e,c=>c.scripts),d=g.useRef(null),k=r==="dialog";z(),g.useEffect(()=>{const c=d.current;c&&(k&&!c.open?c.showModal():!k&&c.open&&c.close())},[k]);const y=w(o),{setSelectedConsent:C,saveConsents:p,setActiveUI:u}=e.getState();if(!s)return null;const f=o.filter(c=>c.category==="necessary"),q=o.filter(c=>c.alwaysLoad&&c.category!=="necessary"),le=c=>o.filter(S=>!S.alwaysLoad&&S.category===c),de=c=>{c.target===d.current&&u("none")};return t.jsxs("dialog",{ref:d,className:l.dialog,"data-color":"primary","aria-labelledby":"styrbord-consent-dialog-heading",onClose:()=>u("none"),onClick:de,children:[t.jsxs("div",{className:l.content,children:[t.jsxs("div",{className:l.header,children:[t.jsx("h2",{id:"styrbord-consent-dialog-heading",className:l.heading,children:n.dialog.heading}),t.jsx("button",{type:"button",className:l.close,"aria-label":n.dialog.close,onClick:()=>u("none"),children:t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,focusable:"false",children:t.jsx("path",{d:"m6 6 12 12M18 6 6 18",strokeLinecap:"round"})})})]}),t.jsx("p",{className:l.body,children:n.dialog.body}),t.jsxs("div",{className:l.categories,children:[t.jsxs("section",{className:l.category,children:[t.jsx("h3",{className:l.categoryHeading,children:n.categories.necessary.title}),t.jsx("p",{className:l.body,children:n.categories.necessary.description}),t.jsx(P,{services:f,translations:n})]}),q.length>0&&t.jsxs("section",{className:l.category,children:[t.jsx("h3",{className:l.categoryHeading,children:n.dialog.alwaysOnHeading}),t.jsx("p",{className:l.body,children:n.dialog.alwaysOnBody}),t.jsx(F,{services:q,translations:n}),t.jsx(P,{services:q,translations:n})]}),y.map(c=>{const S=le(c);return t.jsxs("section",{className:l.category,children:[t.jsx(R,{label:n.categories[c].title,description:n.categories[c].description,checked:a[c]===!0,onChange:ge=>C(c,ge.target.checked)}),t.jsxs("div",{className:l.services,children:[t.jsx(F,{services:S,translations:n}),t.jsx(P,{services:S,translations:n})]})]},c)})]})]}),t.jsxs("div",{className:l.buttons,children:[t.jsx(m,{variant:"filled",onClick:()=>p("custom"),children:n.dialog.savePreferences}),t.jsx(m,{variant:"outline",onClick:()=>p("all"),children:n.dialog.acceptAll}),t.jsx(m,{variant:"ghost",onClick:()=>p("necessary"),children:n.dialog.rejectAll})]})]})}const ee={button:"_button_zo1st_2"};function ne(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",children:t.jsx("path",{color:"currentColor",d:"M480-96q-79.38 0-149.19-30T208.5-208.5Q156-261 126-330.81T96-480q0-81 31-151.5t82.5-123Q261-807 329-837.5T470-868q23 0 45 3t45 9q-8 45 5.5 82t42.03 60.96q28.53 23.96 68 33T759-681q-24 57 8.01 108.5 32.01 51.49 95.08 53.4.95 10.49 1.43 19.55T864-480q0 78-30.24 147.98-30.24 69.99-82.08 122.6t-121.92 83.01Q559.68-96 480-96Zm-60-456q25 0 42.5-17.5T480-612q0-25-17.5-42.5T420-672q-25 0-42.5 17.5T360-612q0 25 17.5 42.5T420-552Zm-96 192q25 0 42.5-17.5T384-420q0-25-17.5-42.5T324-480q-25 0-42.5 17.5T264-420q0 25 17.5 42.5T324-360Zm275.79 36q15.21 0 25.71-10.29t10.5-25.5q0-15.21-10.29-25.71t-25.5-10.5q-15.21 0-25.71 10.29t-10.5 25.5q0 15.21 10.29 25.71t25.5 10.5ZM480-168q125 0 214.5-84.5T792-462q-45-18-75-55.5T679-603q-76-11-129-63t-63-126q-63-4-120.5 19.5t-102 66.5Q220-663 194-604.5T168-480q0 129.67 91.16 220.84Q350.33-168 480-168Zm0-311Z"})})}function Y(){const{store:e,translations:n,showsBanner:s,mounted:r}=b(),a=h(e,d=>d.activeUI),o=r&&s&&a==="none";return O("ConsentSettingsButton",o),o?t.jsx("button",{type:"button",className:ee.button,"data-color":"neutral","aria-label":n.manageLink,title:n.manageLink,onClick:()=>e.getState().setActiveUI("dialog"),children:t.jsx(ne,{})}):null}const te={link:"_link_6z1zn_4"};function se(){return t.jsxs(t.Fragment,{children:[t.jsx(V,{}),t.jsx(G,{}),t.jsx(Y,{})]})}function oe({className:e}){const{translations:n}=b(),{showPreferences:s}=H();return t.jsx("button",{type:"button",className:[te.link,e].filter(Boolean).join(" "),onClick:s,children:n.manageLink})}function ae({domain:e,requireConsent:n=!1,scriptSrc:s="https://plausible.io/js/script.js"}){return{id:"plausible",displayName:"Plausible",src:s,category:"measurement",alwaysLoad:!n,defer:!0,attributes:{"data-domain":e},cookies:[]}}function re({siteId:e}){return{id:"hotjar",displayName:"Hotjar",category:"experience",clearCookiePrefixes:["_hj"],cookies:[{name:"_hjSessionUser_*",duration:365},{name:"_hjSession_*",duration:1},{name:"_hjIncludedInSessionSample_*",duration:1}],textContent:`
2
+ (function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react"),require("c15t")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","c15t"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.Styrbord={},i.jsxRuntime,i.React,i.c15t))})(this,(function(i,t,g,j){"use strict";const q=g.createContext(null);function b(){const e=g.useContext(q);if(!e)throw new Error("useConsentStore må brukes innenfor en <ConsentProvider>.");return e}const T="kystverket_consent",A=182;function L(e){const n=e.filter(s=>!s.alwaysLoad).map(s=>s.category).filter(s=>typeof s=="string").filter(s=>s!=="necessary");return[...new Set(n)]}function B(e){return L(e).length>0}function U(e,n){return e.filter(s=>s.alwaysLoad||typeof s.category!="string"?!1:n[s.category]!==!0)}function O(e,n,s){if(typeof document>"u")return;const a=U(e,n).flatMap(r=>r.clearCookiePrefixes??[]);if(a.length===0)return;const o=document.cookie.split(";").map(r=>{var l;return(l=r.split("=")[0])==null?void 0:l.trim()}).filter(r=>!!r);for(const r of o)a.some(l=>r.startsWith(l))&&(j.deleteCookie(r),j.deleteCookie(r,{domain:window.location.hostname}),s&&j.deleteCookie(r,{domain:s}))}function E(e,n){if(typeof window>"u")return;const s=U(e,n).flatMap(a=>a.clearStoragePrefixes??[]);if(s.length!==0)for(const a of["localStorage","sessionStorage"])try{const o=window[a],r=Array.from({length:o.length},(l,u)=>o.key(u)).filter(l=>l!==null&&s.some(u=>l.startsWith(u)));for(const l of r)o.removeItem(l)}catch{}}function J(e){return{storageKey:e.storageKey??T,defaultExpiryDays:e.expiryDays??A,...e.cookieDomain?{defaultDomain:e.cookieDomain}:{}}}function H(e){const n=J(e),s=j.configureConsentManager({mode:"offline",storageConfig:n});return j.createConsentManagerStore(s,{storageConfig:n,scripts:e.services,initialConsentCategories:L(e.services),debug:e.debug??!1,reloadOnConsentRevoked:!0,callbacks:{onConsentSet:({preferences:a})=>{O(e.services,a,e.cookieDomain),E(e.services,a)}}})}const D=g.createContext(null),R=D.Provider;function ee(){return g.useRef({count:0}).current}function ne(){const e=g.useContext(D);g.useEffect(()=>{if(e)return e.count+=1,()=>{e.count-=1}},[e])}const P=new Set;function M(e,n){const s=g.useContext(D);g.useEffect(()=>{if(!n||!s||P.has(e))return;const a=setTimeout(()=>{s.count>0||P.has(e)||(P.add(e),console.warn(`<${e}> is shown without a <ConsentPreferencesDialog> mounted. Opening the consent settings will hide it with nothing to replace it, leaving the user unable to give or withdraw consent. Mount <ConsentPreferencesDialog> alongside it, or use <CookieConsent>, which mounts all three surfaces.`))},0);return()=>clearTimeout(a)},[n,e,s])}const K=Symbol("styrbord-consent.sessionReplay");function te({domain:e,requireConsent:n=!1,scriptSrc:s="https://plausible.io/js/script.js"}){return{id:"plausible",displayName:"Plausible",src:s,category:"measurement",alwaysLoad:!n,defer:!0,attributes:{"data-domain":e},cookies:[]}}function se({siteId:e}){return{id:"hotjar",displayName:"Hotjar",category:"experience",clearCookiePrefixes:["_hj"],cookies:[{name:"_hjSessionUser_*",duration:365},{name:"_hjSession_*",duration:1},{name:"_hjIncludedInSessionSample_*",duration:1}],textContent:`
3
3
  (function (h, o, t, j, a, r) {
4
4
  h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments); };
5
5
  h._hjSettings = { hjid: ${Number(e)}, hjsv: 6 };
@@ -9,4 +9,4 @@
9
9
  r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
10
10
  a.appendChild(r);
11
11
  })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
12
- `}}function ie({apiKey:e,apiHost:n="https://eu.i.posthog.com",assetHost:s,sessionReplay:r=!1,capturePageview:a=!0,personProfiles:o="identified_only",defaults:d="2026-05-30"}){const k=n.replace(/\/$/,""),y=(s??k.replace(".i.posthog.com","-assets.i.posthog.com")).replace(/\/$/,""),C=()=>window.posthog,p=u=>{if(!r)return;const f=C();f&&(u.experience===!0?f.startSessionRecording():f.stopSessionRecording())};return{id:"posthog",displayName:"PostHog",category:"measurement",clearCookiePrefixes:["ph_"],cookies:[{name:`ph_${e}_posthog`,duration:365}],src:`${y}/static/array.js`,onLoad:({consents:u})=>{var f;(f=C())==null||f.init(e,{api_host:k,person_profiles:o,capture_pageview:a,defaults:d,cross_subdomain_cookie:!1,disable_session_recording:!0,capture_heatmaps:r&&u.experience===!0}),p(u)},onConsentChange:({consents:u})=>p(u)}}function ce(e=L,n=$){return{id:"consent",displayName:"Kystverket",category:"necessary",callbackOnly:!0,alwaysLoad:!0,cookies:[{name:e,duration:n}]}}i.ConsentBanner=V,i.ConsentPreferencesDialog=G,i.ConsentProvider=J,i.ConsentSettingsButton=Y,i.CookieConsent=se,i.DEFAULT_EXPIRY_DAYS=$,i.DEFAULT_STORAGE_KEY=L,i.ManageConsentLink=oe,i.clearServiceCookies=B,i.consentCookieService=ce,i.consentTranslations=v,i.createConsentStore=U,i.defaultConsentLanguage=A,i.formatCookieDuration=E,i.getConsentTranslations=M,i.getSelectableCategories=w,i.hasGatedServices=I,i.hotjarService=re,i.plausibleService=ae,i.postHogService=ie,i.useConsent=H,i.useConsentStore=b,i.useStoreValue=h,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
12
+ `}}function oe({apiKey:e,apiHost:n="https://eu.i.posthog.com",assetHost:s,sessionReplay:a=!1,capturePageview:o=!0,personProfiles:r="identified_only",defaults:l="2026-05-30",initOptions:u}){const f=n.replace(/\/$/,""),w=(s??f.replace(".i.posthog.com","-assets.i.posthog.com")).replace(/\/$/,""),y=()=>window.posthog,p=k=>{if(!a)return;const v=y();v&&(k.experience===!0?v.startSessionRecording():v.stopSessionRecording())},S={id:"posthog",displayName:"PostHog",category:"measurement",clearCookiePrefixes:["ph_"],clearStoragePrefixes:["ph_"],cookies:[{name:`ph_${e}_posthog`,duration:365}],src:`${w}/static/array.js`,onLoad:({consents:k})=>{var v;(v=y())==null||v.init(e,{api_host:f,person_profiles:r,capture_pageview:o,defaults:l,...u,cross_subdomain_cookie:!1,disable_session_recording:!0,capture_heatmaps:a&&k.experience===!0}),p(k)},onConsentChange:({consents:k})=>p(k)};return a&&(S[K]=!0),S}function re({apiKey:e}){return{id:"posthog-replay",displayName:"PostHog (opptak og varmekart)",category:"experience",callbackOnly:!0,cookies:[{name:`ph_${e}_posthog`,duration:365}]}}let V=!1;function ae(e){if(V)return;const n=e.some(a=>a[K]),s=e.some(a=>!a.alwaysLoad&&a.category==="experience");!n||s||(V=!0,console.warn("postHogService({ sessionReplay: true }) is configured, but no service is in the 'experience' category, so the user is never asked and session replay never starts. Add postHogReplayService({ apiKey }) to services."))}function ie(e=T,n=A){return{id:"consent",displayName:"Kystverket",category:"necessary",callbackOnly:!0,alwaysLoad:!0,cookies:[{name:e,duration:n}]}}const m={"nb-NO":{banner:{heading:"Informasjonskapsler",body:"Vi bruker informasjonskapsler for å forstå hvordan tjenesten brukes, slik at vi kan gjøre den bedre. Du velger selv hva du samtykker til.",acceptAll:"Godta alle",rejectAll:"Kun nødvendige",managePreferences:"Velg selv"},dialog:{heading:"Innstillinger for informasjonskapsler",body:"Nødvendige informasjonskapsler er alltid på, fordi tjenesten ikke fungerer uten dem. De øvrige velger du selv.",savePreferences:"Lagre valg",acceptAll:"Godta alle",rejectAll:"Kun nødvendige",close:"Lukk",servicesLabel:"Tjenester",showCookies:"Vis informasjonskapsler",noCookies:"Setter ingen informasjonskapsler",alwaysOnHeading:"Alltid på",alwaysOnBody:"Disse lagrer ingenting på enheten din og kan ikke brukes til å kjenne deg igjen. De krever derfor ikke samtykke, og er alltid på.",cookieName:"Navn",cookieProvider:"Levert av",cookieDuration:"Varighet"},durations:{session:"Til du lukker nettleseren",day:"{{count}} dag",days:"{{count}} dager",month:"{{count}} måned",months:"{{count}} måneder",year:"{{count}} år",years:"{{count}} år"},categories:{necessary:{title:"Nødvendige",description:"Kreves for at tjenesten skal fungere, blant annet for innlogging og sikkerhet. Disse kan ikke slås av."},functionality:{title:"Funksjonalitet",description:"Husker valgene dine, som språk og andre innstillinger."},measurement:{title:"Statistikk",description:"Lar oss telle besøk og se hvilke sider som brukes, slik at vi kan prioritere riktig."},experience:{title:"Brukeropplevelse",description:"Lar oss se hvordan sidene faktisk brukes, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskelig."},marketing:{title:"Markedsføring",description:"Brukes til å tilpasse annonser. Kystverket bruker ikke dette i dag."}},manageLink:"Administrer informasjonskapsler"},"nn-NO":{banner:{heading:"Informasjonskapslar",body:"Vi brukar informasjonskapslar for å forstå korleis tenesta blir brukt, slik at vi kan gjere henne betre. Du vel sjølv kva du samtykkjer til.",acceptAll:"Godta alle",rejectAll:"Berre nødvendige",managePreferences:"Vel sjølv"},dialog:{heading:"Innstillingar for informasjonskapslar",body:"Nødvendige informasjonskapslar er alltid på, fordi tenesta ikkje fungerer utan dei. Dei andre vel du sjølv.",savePreferences:"Lagre val",acceptAll:"Godta alle",rejectAll:"Berre nødvendige",close:"Lukk",servicesLabel:"Tenester",showCookies:"Vis informasjonskapslar",noCookies:"Set ingen informasjonskapslar",alwaysOnHeading:"Alltid på",alwaysOnBody:"Desse lagrar ingenting på eininga di og kan ikkje brukast til å kjenne deg att. Dei krev difor ikkje samtykke, og er alltid på.",cookieName:"Namn",cookieProvider:"Levert av",cookieDuration:"Varigheit"},durations:{session:"Til du lukkar nettlesaren",day:"{{count}} dag",days:"{{count}} dagar",month:"{{count}} månad",months:"{{count}} månader",year:"{{count}} år",years:"{{count}} år"},categories:{necessary:{title:"Nødvendige",description:"Krevst for at tenesta skal fungere, mellom anna for innlogging og tryggleik. Desse kan ikkje slåast av."},functionality:{title:"Funksjonalitet",description:"Hugsar vala dine, som språk og andre innstillingar."},measurement:{title:"Statistikk",description:"Lèt oss telje besøk og sjå kva sider som blir brukte, slik at vi kan prioritere rett."},experience:{title:"Brukaroppleving",description:"Lèt oss sjå korleis sidene faktisk blir brukte, gjennom anonymiserte opptak og varmekart, slik at vi kan rette opp det som er vanskeleg."},marketing:{title:"Marknadsføring",description:"Blir brukt til å tilpasse annonsar. Kystverket brukar ikkje dette i dag."}},manageLink:"Administrer informasjonskapslar"},"en-US":{banner:{heading:"Cookies",body:"We use cookies to understand how this service is used, so that we can improve it. You decide what you consent to.",acceptAll:"Accept all",rejectAll:"Necessary only",managePreferences:"Choose yourself"},dialog:{heading:"Cookie settings",body:"Necessary cookies are always on, because the service does not work without them. The rest is up to you.",savePreferences:"Save choices",acceptAll:"Accept all",rejectAll:"Necessary only",close:"Close",servicesLabel:"Services",showCookies:"Show cookies",noCookies:"Sets no cookies",alwaysOnHeading:"Always on",alwaysOnBody:"These store nothing on your device and cannot be used to recognise you. They therefore do not require consent, and are always on.",cookieName:"Name",cookieProvider:"Provided by",cookieDuration:"Duration"},durations:{session:"Until you close your browser",day:"{{count}} day",days:"{{count}} days",month:"{{count}} month",months:"{{count}} months",year:"{{count}} year",years:"{{count}} years"},categories:{necessary:{title:"Necessary",description:"Required for the service to work, including sign-in and security. These cannot be turned off."},functionality:{title:"Functionality",description:"Remembers your choices, such as language and other settings."},measurement:{title:"Statistics",description:"Lets us count visits and see which pages are used, so we can prioritise correctly."},experience:{title:"User experience",description:"Lets us see how the pages are actually used, through anonymised recordings and heatmaps, so we can fix what is difficult."},marketing:{title:"Marketing",description:"Used to tailor advertising. Kystverket does not use this today."}},manageLink:"Manage cookies"}},x="nb-NO";function F(e){var o;if(!e)return m[x];const n=m[e];if(n)return n;const s=(o=e.split("-")[0])==null?void 0:o.toLowerCase(),a=Object.keys(m).find(r=>r.split("-")[0].toLowerCase()===s);return a?m[a]:m[x]}function G(e,n){const{durations:s}=n;if(e==="session")return s.session;const a=(o,r)=>o.replace("{{count}}",String(r));if(e>=365&&e%365===0){const o=e/365;return a(o===1?s.year:s.years,o)}if(e>=28){const o=Math.round(e/30.4);if(o>=1)return a(o===1?s.month:s.months,o)}return a(e===1?s.day:s.days,e)}function ce(e,n){return n?{banner:{...e.banner,...n.banner},dialog:{...e.dialog,...n.dialog},durations:{...e.durations,...n.durations},categories:{...e.categories,...n.categories},manageLink:n.manageLink??e.manageLink}:e}function le({children:e,language:n,translations:s,...a}){const o=g.useRef(null);o.current??(o.current=H(a));const r=o.current,{services:l}=a,u=l.map(S=>S.id).join(","),[f,w]=g.useState(!1);g.useEffect(()=>w(!0),[]),g.useEffect(()=>ae(l),[u]);const y=ee(),p=g.useMemo(()=>({store:r,translations:ce(F(n),s),showsBanner:B(l),mounted:f}),[r,n,s,u,f]);return t.jsx(q.Provider,{value:p,children:t.jsx(R,{value:y,children:e})})}function h(e,n){const s=g.useRef(null);return g.useSyncExternalStore(e.subscribe,()=>n(e.getState()),()=>(s.current??(s.current={value:n(e.getState())}),s.current.value))}function Y(){const{store:e}=b(),n=h(e,r=>r.consents),s=h(e,r=>r.activeUI),a=h(e,r=>r.consentInfo),o=h(e,r=>r.isLoadingConsentInfo);return{hasConsent:r=>e.getState().has(r),consents:n,needsDecision:!o&&a===null,showPreferences:()=>e.getState().setActiveUI("dialog"),close:()=>e.getState().setActiveUI("none"),activeUI:s}}const W={button:"_button_ax4nf_2",filled:"_filled_ax4nf_29",outline:"_outline_ax4nf_42",ghost:"_ghost_ax4nf_48"};function _({variant:e="filled",className:n,type:s="button",...a}){return t.jsx("button",{...a,type:s,className:[W.button,W[e],n].filter(Boolean).join(" ")})}const C={banner:"_banner_rr9rr_2",inner:"_inner_rr9rr_15",text:"_text_rr9rr_23",heading:"_heading_rr9rr_29",body:"_body_rr9rr_38",actions:"_actions_rr9rr_45"};function Z(){const{store:e,translations:n,showsBanner:s,mounted:a}=b(),o=h(e,f=>f.activeUI),r=a&&s&&o==="banner";if(M("ConsentBanner",r),!r)return null;const{saveConsents:l,setActiveUI:u}=e.getState();return t.jsx("section",{className:C.banner,"data-color":"primary","aria-labelledby":"styrbord-consent-banner-heading",children:t.jsxs("div",{className:C.inner,children:[t.jsxs("div",{className:C.text,children:[t.jsx("h2",{id:"styrbord-consent-banner-heading",className:C.heading,children:n.banner.heading}),t.jsx("p",{className:C.body,children:n.banner.body})]}),t.jsxs("div",{className:C.actions,children:[t.jsx(_,{variant:"filled",onClick:()=>l("all"),children:n.banner.acceptAll}),t.jsx(_,{variant:"outline",onClick:()=>l("necessary"),children:n.banner.rejectAll}),t.jsx(_,{variant:"ghost",onClick:()=>u("dialog"),children:n.banner.managePreferences})]})]})})}const $={switch:"_switch_oxxbn_2",input:"_input_oxxbn_10",label:"_label_oxxbn_53",description:"_description_oxxbn_62"};function de({label:e,description:n,checked:s,onChange:a}){const o=g.useId(),r=`${o}-description`;return t.jsxs("div",{className:$.switch,children:[t.jsx("input",{id:o,type:"checkbox",role:"switch",className:$.input,checked:s,onChange:a,"aria-describedby":n?r:void 0}),t.jsx("label",{className:$.label,htmlFor:o,children:e}),n&&t.jsx("p",{id:r,className:$.description,children:n})]})}const d={dialog:"_dialog_1y45s_2",content:"_content_1y45s_26",header:"_header_1y45s_34",heading:"_heading_1y45s_41",close:"_close_1y45s_50",summary:"_summary_1y45s_75",body:"_body_1y45s_80",fineprint:"_fineprint_1y45s_87",categories:"_categories_1y45s_95",category:"_category_1y45s_101",categoryHeading:"_categoryHeading_1y45s_114",services:"_services_1y45s_122",details:"_details_1y45s_129",table:"_table_1y45s_142",buttons:"_buttons_1y45s_162"};function I({services:e,translations:n}){if(!e.some(o=>o.cookies!==void 0))return null;const a=e.flatMap(o=>(o.cookies??[]).map(r=>({...r,provider:o.displayName??o.id})));return a.length===0?t.jsx("p",{className:d.fineprint,children:n.dialog.noCookies}):t.jsxs("details",{className:d.details,children:[t.jsx("summary",{className:d.summary,children:n.dialog.showCookies}),t.jsxs("table",{className:d.table,children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:n.dialog.cookieName}),t.jsx("th",{scope:"col",children:n.dialog.cookieProvider}),t.jsx("th",{scope:"col",children:n.dialog.cookieDuration})]})}),t.jsx("tbody",{children:a.map(o=>t.jsxs("tr",{children:[t.jsx("td",{children:t.jsx("code",{children:o.name})}),t.jsx("td",{children:o.provider}),t.jsx("td",{children:G(o.duration,n)})]},`${o.provider}-${o.name}`))})]})]})}function Q({services:e,translations:n}){return e.length===0?null:t.jsxs("p",{className:d.fineprint,children:[n.dialog.servicesLabel,": ",e.map(s=>s.displayName??s.id).join(", ")]})}function z(){const{store:e,translations:n,mounted:s}=b(),a=h(e,c=>c.activeUI),o=h(e,c=>c.selectedConsents),r=h(e,c=>c.scripts),l=g.useRef(null),u=a==="dialog";ne(),g.useEffect(()=>{const c=l.current;c&&(u&&!c.open?c.showModal():!u&&c.open&&c.close())},[u]);const f=L(r),{setSelectedConsent:w,saveConsents:y,setActiveUI:p}=e.getState();if(!s)return null;const S=r.filter(c=>c.category==="necessary"),k=r.filter(c=>c.alwaysLoad&&c.category!=="necessary"),v=c=>r.filter(N=>!N.alwaysLoad&&N.category===c),ye=c=>{c.target===l.current&&p("none")};return t.jsxs("dialog",{ref:l,className:d.dialog,"data-color":"primary","aria-labelledby":"styrbord-consent-dialog-heading",onClose:()=>p("none"),onClick:ye,children:[t.jsxs("div",{className:d.content,children:[t.jsxs("div",{className:d.header,children:[t.jsx("h2",{id:"styrbord-consent-dialog-heading",className:d.heading,children:n.dialog.heading}),t.jsx("button",{type:"button",className:d.close,"aria-label":n.dialog.close,onClick:()=>p("none"),children:t.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,focusable:"false",children:t.jsx("path",{d:"m6 6 12 12M18 6 6 18",strokeLinecap:"round"})})})]}),t.jsx("p",{className:d.body,children:n.dialog.body}),t.jsxs("div",{className:d.categories,children:[t.jsxs("section",{className:d.category,children:[t.jsx("h3",{className:d.categoryHeading,children:n.categories.necessary.title}),t.jsx("p",{className:d.body,children:n.categories.necessary.description}),t.jsx(I,{services:S,translations:n})]}),k.length>0&&t.jsxs("section",{className:d.category,children:[t.jsx("h3",{className:d.categoryHeading,children:n.dialog.alwaysOnHeading}),t.jsx("p",{className:d.body,children:n.dialog.alwaysOnBody}),t.jsx(Q,{services:k,translations:n}),t.jsx(I,{services:k,translations:n})]}),f.map(c=>{const N=v(c);return t.jsxs("section",{className:d.category,children:[t.jsx(de,{label:n.categories[c].title,description:n.categories[c].description,checked:o[c]===!0,onChange:pe=>w(c,pe.target.checked)}),t.jsxs("div",{className:d.services,children:[t.jsx(Q,{services:N,translations:n}),t.jsx(I,{services:N,translations:n})]})]},c)})]})]}),t.jsxs("div",{className:d.buttons,children:[t.jsx(_,{variant:"filled",onClick:()=>y("custom"),children:n.dialog.savePreferences}),t.jsx(_,{variant:"outline",onClick:()=>y("all"),children:n.dialog.acceptAll}),t.jsx(_,{variant:"ghost",onClick:()=>y("necessary"),children:n.dialog.rejectAll})]})]})}const ge={button:"_button_zo1st_2"};function ue(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"20px",viewBox:"0 -960 960 960",width:"20px",children:t.jsx("path",{color:"currentColor",d:"M480-96q-79.38 0-149.19-30T208.5-208.5Q156-261 126-330.81T96-480q0-81 31-151.5t82.5-123Q261-807 329-837.5T470-868q23 0 45 3t45 9q-8 45 5.5 82t42.03 60.96q28.53 23.96 68 33T759-681q-24 57 8.01 108.5 32.01 51.49 95.08 53.4.95 10.49 1.43 19.55T864-480q0 78-30.24 147.98-30.24 69.99-82.08 122.6t-121.92 83.01Q559.68-96 480-96Zm-60-456q25 0 42.5-17.5T480-612q0-25-17.5-42.5T420-672q-25 0-42.5 17.5T360-612q0 25 17.5 42.5T420-552Zm-96 192q25 0 42.5-17.5T384-420q0-25-17.5-42.5T324-480q-25 0-42.5 17.5T264-420q0 25 17.5 42.5T324-360Zm275.79 36q15.21 0 25.71-10.29t10.5-25.5q0-15.21-10.29-25.71t-25.5-10.5q-15.21 0-25.71 10.29t-10.5 25.5q0 15.21 10.29 25.71t25.5 10.5ZM480-168q125 0 214.5-84.5T792-462q-45-18-75-55.5T679-603q-76-11-129-63t-63-126q-63-4-120.5 19.5t-102 66.5Q220-663 194-604.5T168-480q0 129.67 91.16 220.84Q350.33-168 480-168Zm0-311Z"})})}function X(){const{store:e,translations:n,showsBanner:s,mounted:a}=b(),o=h(e,l=>l.activeUI),r=a&&s&&o==="none";return M("ConsentSettingsButton",r),r?t.jsx("button",{type:"button",className:ge.button,"data-color":"neutral","aria-label":n.manageLink,title:n.manageLink,onClick:()=>e.getState().setActiveUI("dialog"),children:t.jsx(ue,{})}):null}const he={link:"_link_6z1zn_4"};function ke(){return t.jsxs(t.Fragment,{children:[t.jsx(Z,{}),t.jsx(z,{}),t.jsx(X,{})]})}function fe({className:e}){const{translations:n}=b(),{showPreferences:s}=Y();return t.jsx("button",{type:"button",className:[he.link,e].filter(Boolean).join(" "),onClick:s,children:n.manageLink})}i.ConsentBanner=Z,i.ConsentPreferencesDialog=z,i.ConsentProvider=le,i.ConsentSettingsButton=X,i.CookieConsent=ke,i.DEFAULT_EXPIRY_DAYS=A,i.DEFAULT_STORAGE_KEY=T,i.ManageConsentLink=fe,i.clearServiceCookies=O,i.clearServiceStorage=E,i.consentCookieService=ie,i.consentTranslations=m,i.createConsentStore=H,i.defaultConsentLanguage=x,i.formatCookieDuration=G,i.getConsentTranslations=F,i.getSelectableCategories=L,i.hasGatedServices=B,i.hotjarService=se,i.plausibleService=te,i.postHogReplayService=re,i.postHogService=oe,i.useConsent=Y,i.useConsentStore=b,i.useStoreValue=h,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kystverket/styrbord-consent",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Samtykke-komponenter for Kystverkets applikasjoner",
5
5
  "type": "module",
6
6
  "repository": {