@oslokommune/punkt-elements 12.42.3 → 12.42.5

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.
@@ -1,10 +1,16 @@
1
1
  import { classMap } from 'lit/directives/class-map.js'
2
2
  import { customElement, property, state } from 'lit/decorators.js'
3
- import { formatISODate, newDate, newDateYMD, formatReadableDate } from '@/utils/dateutils'
3
+ import {
4
+ formatISODate,
5
+ newDate,
6
+ newDateYMD,
7
+ formatReadableDate,
8
+ parseISODateString,
9
+ todayInTz,
10
+ } from '@/utils/dateutils'
4
11
  import { getWeek, eachDayOfInterval, getISODay, addDays } from 'date-fns'
5
12
  import { html, nothing, PropertyValues } from 'lit'
6
13
  import { PktElement } from '@/base-elements/element'
7
- import { TZDate } from '@date-fns/tz'
8
14
  import converters from '../../helpers/converters'
9
15
  import specs from 'componentSpecs/calendar.json'
10
16
  import '@/components/icon'
@@ -116,11 +122,11 @@ export class PktCalendar extends PktElement {
116
122
  if (this.selected.length === 1 && this.selected[0] === '') {
117
123
  this.selected = []
118
124
  }
119
- this._selected = this.selected.map((d: string) => newDate(d))
125
+ this._selected = this.selected.map((d: string) => parseISODateString(d))
120
126
  if (this.range && this.selected.length === 2) {
121
127
  const days = eachDayOfInterval({
122
- start: newDate(this.selected[0]),
123
- end: newDate(this.selected[1]),
128
+ start: this._selected[0],
129
+ end: this._selected[1],
124
130
  })
125
131
 
126
132
  this.inRange = {}
@@ -141,9 +147,14 @@ export class PktCalendar extends PktElement {
141
147
  return
142
148
  }
143
149
  if (this.selected.length && this.selected[0] !== '') {
144
- this.currentmonth = newDate(this.selected[this.selected.length - 1])
150
+ const d = parseISODateString(this.selected[this.selected.length - 1])
151
+ this.currentmonth = isNaN(d.getTime()) ? new Date() : d
145
152
  } else if (this.currentmonth === null) {
146
- this.currentmonth = newDate()
153
+ this.currentmonth = new Date()
154
+ }
155
+ // fallback to today if invalid
156
+ if (!this.currentmonth || isNaN(this.currentmonth.getTime())) {
157
+ this.currentmonth = new Date()
147
158
  }
148
159
  this.year = this.currentmonth.getFullYear()
149
160
  this.month = this.currentmonth.getMonth()
@@ -414,7 +425,7 @@ export class PktCalendar extends PktElement {
414
425
  }
415
426
 
416
427
  private renderCalendarBody() {
417
- const today = newDate()
428
+ const today = todayInTz()
418
429
  const firstDayOfMonth = newDateYMD(this.year, this.month, 1)
419
430
  const lastDayOfMonth = newDateYMD(this.year, this.month + 1, 0)
420
431
  const startingDay = (firstDayOfMonth.getDay() + 6) % 7
@@ -475,11 +486,11 @@ export class PktCalendar extends PktElement {
475
486
  return rows
476
487
  }
477
488
 
478
- private isExcluded(weekday: number, date: TZDate) {
489
+ private isExcluded(weekday: number, date: Date) {
479
490
  if (this.excludeweekdays.includes(weekday.toString())) return true
480
491
  if (this.earliest && newDate(date, 'end') < newDate(this.earliest, 'start')) return true
481
492
  if (this.latest && newDate(date, 'start') > newDate(this.latest, 'end')) return true
482
- return this.excludedates.some((x: TZDate | Date | string) => {
493
+ return this.excludedates.some((x: Date | string) => {
483
494
  if (typeof x === 'string') {
484
495
  return x === formatISODate(date)
485
496
  } else {
@@ -524,7 +535,7 @@ export class PktCalendar extends PktElement {
524
535
  this.selectableDates = []
525
536
  }
526
537
 
527
- private isInRange(date: TZDate | Date) {
538
+ private isInRange(date: Date) {
528
539
  if (this.range && this.selected.length === 2) {
529
540
  if (date > newDate(this.selected[0]) && date < newDate(this.selected[1])) return true
530
541
  } else if (this.range && this.selected.length === 1 && this.rangeHovered) {
@@ -533,7 +544,7 @@ export class PktCalendar extends PktElement {
533
544
  return false
534
545
  }
535
546
 
536
- private isRangeAllowed(date: TZDate) {
547
+ private isRangeAllowed(date: Date) {
537
548
  let allowed = true
538
549
  if (this._selected.length === 1) {
539
550
  const days = eachDayOfInterval({
@@ -543,7 +554,7 @@ export class PktCalendar extends PktElement {
543
554
 
544
555
  if (Array.isArray(days) && days.length) {
545
556
  for (let i = 0; i < days.length; i++) {
546
- this.excludedates.forEach((d: TZDate | Date) => {
557
+ this.excludedates.forEach((d: Date) => {
547
558
  if (d > this._selected[0] && d < date) {
548
559
  allowed = false
549
560
  }
@@ -563,7 +574,7 @@ export class PktCalendar extends PktElement {
563
574
  this.inRange = {}
564
575
  }
565
576
 
566
- public addToSelected(selectedDate: TZDate) {
577
+ public addToSelected(selectedDate: Date) {
567
578
  if (this.selected.includes(formatISODate(selectedDate))) return
568
579
  this.selected = [...this.selected, formatISODate(selectedDate)]
569
580
  this._selected = [...this._selected, selectedDate]
@@ -572,7 +583,7 @@ export class PktCalendar extends PktElement {
572
583
  }
573
584
  }
574
585
 
575
- public removeFromSelected(selectedDate: TZDate) {
586
+ public removeFromSelected(selectedDate: Date) {
576
587
  if (this.selected.length === 1) {
577
588
  this.emptySelected()
578
589
  } else {
@@ -586,7 +597,7 @@ export class PktCalendar extends PktElement {
586
597
  }
587
598
  }
588
599
 
589
- public toggleSelected(selectedDate: TZDate) {
600
+ public toggleSelected(selectedDate: Date) {
590
601
  const selectedDateISO = formatISODate(selectedDate)
591
602
  this.selected.includes(selectedDateISO)
592
603
  ? this.removeFromSelected(selectedDate)
@@ -595,7 +606,7 @@ export class PktCalendar extends PktElement {
595
606
  : null
596
607
  }
597
608
 
598
- private handleRangeSelect(selectedDate: TZDate) {
609
+ private handleRangeSelect(selectedDate: Date) {
599
610
  const selectedDateISO = formatISODate(selectedDate)
600
611
  if (this.selected.includes(selectedDateISO)) {
601
612
  if (this.selected.indexOf(selectedDateISO) === 0) {
@@ -620,7 +631,7 @@ export class PktCalendar extends PktElement {
620
631
  return Promise.resolve()
621
632
  }
622
633
 
623
- private handleRangeHover(date: TZDate) {
634
+ private handleRangeHover(date: Date) {
624
635
  if (
625
636
  this.range &&
626
637
  this._selected.length === 1 &&
@@ -645,7 +656,7 @@ export class PktCalendar extends PktElement {
645
656
  }
646
657
  }
647
658
 
648
- public handleDateSelect(selectedDate: TZDate | null) {
659
+ public handleDateSelect(selectedDate: Date | null) {
649
660
  if (!selectedDate) return
650
661
  if (this.range) {
651
662
  this.handleRangeSelect(selectedDate)
@@ -124,7 +124,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
124
124
  // Deep clone defaultOptions into options, preserving userAdded options
125
125
  if (this.defaultOptions && this.defaultOptions.length) {
126
126
  const userAdded = this.options?.filter((opt) => opt.userAdded) || []
127
- this.options = [...userAdded, ...structuredClone(this.defaultOptions)]
127
+ this.options = [...userAdded, ...JSON.parse(JSON.stringify(this.defaultOptions))]
128
128
  this._options = [...this.options]
129
129
  }
130
130
 
@@ -171,7 +171,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
171
171
  // If defaultOptions changed, update options (preserving userAdded)
172
172
  if (changedProperties.has('defaultOptions') && this.defaultOptions.length) {
173
173
  const userAdded = this.options?.filter((opt) => opt.userAdded) || []
174
- this.options = [...userAdded, ...structuredClone(this.defaultOptions)]
174
+ this.options = [...userAdded, ...JSON.parse(JSON.stringify(this.defaultOptions))]
175
175
  this._options = [...this.options]
176
176
  }
177
177
 
@@ -2,30 +2,74 @@ import { customElement, property } from 'lit/decorators.js'
2
2
  import { html, PropertyValues } from 'lit'
3
3
  import { PktElement } from '@/base-elements/element'
4
4
  import { consentStrings } from './strings'
5
- import { CookieEvents } from '@oslokommune/cookie-manager'
6
5
  import '../button'
7
6
  import '../icon'
8
7
 
8
+ let consentScriptPromise: Promise<void> | null = null
9
+
10
+ function loadConsentScript(): Promise<void> {
11
+ if (consentScriptPromise) return consentScriptPromise
12
+
13
+ consentScriptPromise = new Promise((resolve, reject) => {
14
+ if (document.querySelector('#oslo-consent-script')) {
15
+ resolve()
16
+ return
17
+ }
18
+ const script = document.createElement('script')
19
+ script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js'
20
+ script.id = 'oslo-consent-script'
21
+ script.onload = () => resolve()
22
+ script.onerror = reject
23
+ document.head.appendChild(script)
24
+
25
+ const styles = document.createElement('link')
26
+ styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css'
27
+ styles.type = 'text/css'
28
+ styles.rel = 'stylesheet'
29
+ styles.id = 'oslo-consent-styles'
30
+ document.head.appendChild(styles)
31
+ })
32
+
33
+ return consentScriptPromise
34
+ }
9
35
  // Extend the Window interface to include googleAnalyticsId
10
36
  declare global {
11
37
  interface Window {
12
- googleAnalyticsId?: string | null
13
- hotjarId?: string | null
38
+ cookieBanner_devMode?: boolean
39
+ cookieBanner_cookieDomain?: string | null
40
+ cookieBanner_cookieSecure?: string | null
41
+ cookieBanner_cookieExpiryDays?: string | null
42
+ cookieBanner_googleAnalyticsId?: string | null
43
+ cookieBanner_hotjarId?: string | null
14
44
  cookieBanner?: any
45
+ __cookieEvents?: any
15
46
  }
16
47
  }
17
48
 
18
49
  export interface IPktConsent {
50
+ devMode?: boolean
51
+ cookieDomain?: string | null
52
+ cookieSecure?: string | null
53
+ cookieExpiryDays?: string | null
19
54
  hotjarId?: string | null
20
55
  googleAnalyticsId?: string | null
56
+ i18nLanguage?: string
21
57
  triggerType?: 'button' | 'link' | 'footerlink' | 'icon' | null
22
58
  triggerText?: string | null
23
59
  }
24
60
 
25
61
  @customElement('pkt-consent')
26
62
  export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
63
+ private _cookieEventHandler?: (consent: any) => void
64
+
65
+ @property({ type: Boolean }) devMode: boolean = false
66
+
27
67
  @property({ type: String }) hotjarId: string | null = null
28
68
  @property({ type: String }) googleAnalyticsId: string | null = null
69
+ @property({ type: String }) cookieDomain: string | null = null
70
+ @property({ type: String }) cookieSecure: string | null = null
71
+ @property({ type: String }) cookieExpiryDays: string | null = null
72
+
29
73
  @property({ type: String }) triggerType: 'button' | 'link' | 'footerlink' | 'icon' | null =
30
74
  'button'
31
75
  @property({ type: String }) triggerText: string | null = null
@@ -41,17 +85,13 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
41
85
  this.triggerText ||
42
86
  consentStrings.i18n[this.i18nLanguage as keyof typeof consentStrings.i18n].contentPresentation
43
87
  .buttons.settings
88
+ }
44
89
 
45
- if (this.googleAnalyticsId) {
46
- window.googleAnalyticsId = this.googleAnalyticsId
90
+ disconnectedCallback() {
91
+ super.disconnectedCallback()
92
+ if (this._cookieEventHandler) {
93
+ window.__cookieEvents?.off('CookieManager.setCookie', this._cookieEventHandler)
47
94
  }
48
- if (this.hotjarId) {
49
- window.hotjarId = this.hotjarId
50
- }
51
-
52
- CookieEvents.on('CookieManager.setCookie', (consent: any) => {
53
- this.emitCookieConsents(consent)
54
- })
55
95
  }
56
96
 
57
97
  returnJsonOrObject(obj: any) {
@@ -71,44 +111,31 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
71
111
  acc[item.name] = item.consent
72
112
  return acc
73
113
  }, {})
114
+
74
115
  this.dispatchEvent(
75
116
  new CustomEvent('toggle-consent', {
76
117
  detail: consentDetails,
77
118
  bubbles: true,
78
- composed: true,
119
+ cancelable: false,
79
120
  }),
80
121
  )
81
122
  }
82
123
 
83
- protected firstUpdated(_changedProperties: PropertyValues): void {
84
- if (
85
- !document.querySelector('#oslo-consent-script') &&
86
- window.location.hostname.toLowerCase().includes('oslo.kommune.no')
87
- ) {
88
- window.googleAnalyticsId = this.googleAnalyticsId
89
- window.hotjarId = this.hotjarId
90
-
91
- const script = document.createElement('script')
92
- script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js'
93
- script.id = 'oslo-consent-script'
94
- script.onload = () => {
95
- this.triggerInit()
96
- }
97
- document.head.appendChild(script)
98
-
99
- const styles = document.createElement('link')
100
- styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css'
101
- styles.type = 'text/css'
102
- styles.rel = 'stylesheet'
103
- styles.id = 'oslo-consent-styles'
104
- document.head.appendChild(styles)
105
- }
124
+ protected async firstUpdated(_changedProperties: PropertyValues): Promise<void> {
125
+ window.cookieBanner_googleAnalyticsId = this.googleAnalyticsId
126
+ window.cookieBanner_hotjarId = this.hotjarId
127
+ if (this.cookieDomain) window.cookieBanner_cookieDomain = this.cookieDomain
128
+ if (this.cookieSecure) window.cookieBanner_cookieSecure = this.cookieSecure
129
+ if (this.cookieExpiryDays) window.cookieBanner_cookieExpiryDays = this.cookieExpiryDays
130
+ if (this.devMode) window.cookieBanner_devMode = this.devMode
131
+
132
+ await loadConsentScript()
133
+ this.triggerInit()
106
134
  }
107
135
 
108
136
  triggerInit() {
109
- // Slight hack since we can't access the right methods to do this “properly”
110
137
  window.document.dispatchEvent(
111
- new Event('DOMContentLoaded', {
138
+ new Event('CookieBannerReady', {
112
139
  bubbles: true,
113
140
  cancelable: true,
114
141
  }),
@@ -118,14 +145,22 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
118
145
  if (response) {
119
146
  const cookie = window.cookieBanner.cookieConsent.getConsentCookie()
120
147
  const consents = { value: cookie }
121
- this.emitCookieConsents(consents)
148
+ window.setTimeout(() => this.emitCookieConsents(consents), 0)
149
+
150
+ if (this._cookieEventHandler) {
151
+ window.__cookieEvents.off('CookieManager.setCookie', this._cookieEventHandler)
152
+ }
153
+ this._cookieEventHandler = (consent: any) => {
154
+ this.emitCookieConsents(consent)
155
+ }
156
+ window.__cookieEvents.on('CookieManager.setCookie', this._cookieEventHandler)
122
157
  }
123
158
  })
124
159
  }
125
160
 
126
161
  openModal(e: Event) {
127
162
  e.preventDefault()
128
- if (!window.cookieBanner.cookieConsent) {
163
+ if (!window.cookieBanner?.cookieConsent) {
129
164
  this.triggerInit()
130
165
  }
131
166
  setTimeout(() => window.cookieBanner.openCookieModal())
@@ -1,108 +0,0 @@
1
- "use strict";const lt=require("./class-map-DWDPOqjO.cjs"),o=require("./element-90YeMNbV.cjs"),A=require("./state-D-Recv7U.cjs");require("./icon-B1_BRNqf.cjs");const tt=6048e5,ut=864e5,ht=36e5,j=Symbol.for("constructDateFrom");function D(n,t){return typeof n=="function"?n(t):n&&typeof n=="object"&&j in n?n[j](t):n instanceof Date?new n.constructor(t):new Date(t)}function k(n,t){return D(t||n,n)}function q(n,t,e){const r=k(n,e==null?void 0:e.in);return isNaN(t)?D(n,NaN):(t&&r.setDate(r.getDate()+t),r)}function dt(n,t,e){return D(n,+k(n)+t)}function et(n,t,e){return dt(n,t*ht)}let ft={};function _(){return ft}function Y(n,t){var c,l,u,f;const e=_(),r=(t==null?void 0:t.weekStartsOn)??((l=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:l.weekStartsOn)??e.weekStartsOn??((f=(u=e.locale)==null?void 0:u.options)==null?void 0:f.weekStartsOn)??0,a=k(n,t==null?void 0:t.in),s=a.getDay(),i=(s<r?7:0)+s-r;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function F(n,t){return Y(n,{...t,weekStartsOn:1})}function nt(n,t){const e=k(n,t==null?void 0:t.in),r=e.getFullYear(),a=D(e,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const s=F(a),i=D(e,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const c=F(i);return e.getTime()>=s.getTime()?r+1:e.getTime()>=c.getTime()?r:r-1}function Q(n){const t=k(n),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+n-+e}function rt(n,...t){const e=D.bind(null,t.find(r=>typeof r=="object"));return t.map(e)}function z(n,t){const e=k(n,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}function mt(n,t,e){const[r,a]=rt(e==null?void 0:e.in,n,t),s=z(r),i=z(a),c=+s-Q(s),l=+i-Q(i);return Math.round((c-l)/ut)}function gt(n,t){const e=nt(n,t),r=D(n,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),F(r)}function yt(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function wt(n){return!(!yt(n)&&typeof n!="number"||isNaN(+k(n)))}function pt(n,t){const e=k(n,t==null?void 0:t.in);return e.setHours(23,59,59,999),e}function bt(n,t){const[e,r]=rt(n,t.start,t.end);return{start:e,end:r}}function L(n,t){const{start:e,end:r}=bt(t==null?void 0:t.in,n);let a=+e>+r;const s=a?+e:+r,i=a?r:e;i.setHours(0,0,0,0);let c=1;const l=[];for(;+i<=s;)l.push(D(e,i)),i.setDate(i.getDate()+c),i.setHours(0,0,0,0);return a?l.reverse():l}function kt(n,t){const e=k(n,t==null?void 0:t.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}const vt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Dt=(n,t,e)=>{let r;const a=vt[n];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+r:r+" ago":r};function R(n){return(t={})=>{const e=t.width?String(t.width):n.defaultWidth;return n.formats[e]||n.formats[n.defaultWidth]}}const St={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Mt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},xt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Pt={date:R({formats:St,defaultWidth:"full"}),time:R({formats:Mt,defaultWidth:"full"}),dateTime:R({formats:xt,defaultWidth:"full"})},Tt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ot=(n,t,e,r)=>Tt[n];function $(n){return(t,e)=>{const r=e!=null&&e.context?String(e.context):"standalone";let a;if(r==="formatting"&&n.formattingValues){const i=n.defaultFormattingWidth||n.defaultWidth,c=e!=null&&e.width?String(e.width):i;a=n.formattingValues[c]||n.formattingValues[i]}else{const i=n.defaultWidth,c=e!=null&&e.width?String(e.width):n.defaultWidth;a=n.values[c]||n.values[i]}const s=n.argumentCallback?n.argumentCallback(t):t;return a[s]}}const Ct={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},$t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Et={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Wt={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Nt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Yt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},At=(n,t)=>{const e=Number(n),r=e%100;if(r>20||r<10)switch(r%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},Ht={ordinalNumber:At,era:$({values:Ct,defaultWidth:"wide"}),quarter:$({values:$t,defaultWidth:"wide",argumentCallback:n=>n-1}),month:$({values:Et,defaultWidth:"wide"}),day:$({values:Wt,defaultWidth:"wide"}),dayPeriod:$({values:Nt,defaultWidth:"wide",formattingValues:Yt,defaultFormattingWidth:"wide"})};function E(n){return(t,e={})=>{const r=e.width,a=r&&n.matchPatterns[r]||n.matchPatterns[n.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],c=r&&n.parsePatterns[r]||n.parsePatterns[n.defaultParseWidth],l=Array.isArray(c)?_t(c,p=>p.test(i)):Ft(c,p=>p.test(i));let u;u=n.valueCallback?n.valueCallback(l):l,u=e.valueCallback?e.valueCallback(u):u;const f=t.slice(i.length);return{value:u,rest:f}}}function Ft(n,t){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&t(n[e]))return e}function _t(n,t){for(let e=0;e<n.length;e++)if(t(n[e]))return e}function It(n){return(t,e={})=>{const r=t.match(n.matchPattern);if(!r)return null;const a=r[0],s=t.match(n.parsePattern);if(!s)return null;let i=n.valueCallback?n.valueCallback(s[0]):s[0];i=e.valueCallback?e.valueCallback(i):i;const c=t.slice(a.length);return{value:i,rest:c}}}const qt=/^(\d+)(th|st|nd|rd)?/i,Lt=/\d+/i,Rt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Ut={any:[/^b/i,/^(a|c)/i]},zt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Bt={any:[/1/i,/2/i,/3/i,/4/i]},jt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Qt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Gt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Xt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Vt={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Jt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Kt={ordinalNumber:It({matchPattern:qt,parsePattern:Lt,valueCallback:n=>parseInt(n,10)}),era:E({matchPatterns:Rt,defaultMatchWidth:"wide",parsePatterns:Ut,defaultParseWidth:"any"}),quarter:E({matchPatterns:zt,defaultMatchWidth:"wide",parsePatterns:Bt,defaultParseWidth:"any",valueCallback:n=>n+1}),month:E({matchPatterns:jt,defaultMatchWidth:"wide",parsePatterns:Qt,defaultParseWidth:"any"}),day:E({matchPatterns:Gt,defaultMatchWidth:"wide",parsePatterns:Xt,defaultParseWidth:"any"}),dayPeriod:E({matchPatterns:Vt,defaultMatchWidth:"any",parsePatterns:Jt,defaultParseWidth:"any"})},Zt={code:"en-US",formatDistance:Dt,formatLong:Pt,formatRelative:Ot,localize:Ht,match:Kt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function te(n,t){const e=k(n,t==null?void 0:t.in);return mt(e,kt(e))+1}function ee(n,t){const e=k(n,t==null?void 0:t.in),r=+F(e)-+gt(e);return Math.round(r/tt)+1}function at(n,t){var f,p,b,m;const e=k(n,t==null?void 0:t.in),r=e.getFullYear(),a=_(),s=(t==null?void 0:t.firstWeekContainsDate)??((p=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??a.firstWeekContainsDate??((m=(b=a.locale)==null?void 0:b.options)==null?void 0:m.firstWeekContainsDate)??1,i=D((t==null?void 0:t.in)||n,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const c=Y(i,t),l=D((t==null?void 0:t.in)||n,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const u=Y(l,t);return+e>=+c?r+1:+e>=+u?r:r-1}function ne(n,t){var c,l,u,f;const e=_(),r=(t==null?void 0:t.firstWeekContainsDate)??((l=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:l.firstWeekContainsDate)??e.firstWeekContainsDate??((f=(u=e.locale)==null?void 0:u.options)==null?void 0:f.firstWeekContainsDate)??1,a=at(n,t),s=D((t==null?void 0:t.in)||n,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),Y(s,t)}function st(n,t){const e=k(n,t==null?void 0:t.in),r=+Y(e,t)-+ne(e,t);return Math.round(r/tt)+1}function h(n,t){const e=n<0?"-":"",r=Math.abs(n).toString().padStart(t,"0");return e+r}const x={y(n,t){const e=n.getFullYear(),r=e>0?e:1-e;return h(t==="yy"?r%100:r,t.length)},M(n,t){const e=n.getMonth();return t==="M"?String(e+1):h(e+1,2)},d(n,t){return h(n.getDate(),t.length)},a(n,t){const e=n.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(n,t){return h(n.getHours()%12||12,t.length)},H(n,t){return h(n.getHours(),t.length)},m(n,t){return h(n.getMinutes(),t.length)},s(n,t){return h(n.getSeconds(),t.length)},S(n,t){const e=t.length,r=n.getMilliseconds(),a=Math.trunc(r*Math.pow(10,e-3));return h(a,t.length)}},C={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},G={G:function(n,t,e){const r=n.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(r,{width:"abbreviated"});case"GGGGG":return e.era(r,{width:"narrow"});case"GGGG":default:return e.era(r,{width:"wide"})}},y:function(n,t,e){if(t==="yo"){const r=n.getFullYear(),a=r>0?r:1-r;return e.ordinalNumber(a,{unit:"year"})}return x.y(n,t)},Y:function(n,t,e,r){const a=at(n,r),s=a>0?a:1-a;if(t==="YY"){const i=s%100;return h(i,2)}return t==="Yo"?e.ordinalNumber(s,{unit:"year"}):h(s,t.length)},R:function(n,t){const e=nt(n);return h(e,t.length)},u:function(n,t){const e=n.getFullYear();return h(e,t.length)},Q:function(n,t,e){const r=Math.ceil((n.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return h(r,2);case"Qo":return e.ordinalNumber(r,{unit:"quarter"});case"QQQ":return e.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(r,{width:"wide",context:"formatting"})}},q:function(n,t,e){const r=Math.ceil((n.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return h(r,2);case"qo":return e.ordinalNumber(r,{unit:"quarter"});case"qqq":return e.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(r,{width:"wide",context:"standalone"})}},M:function(n,t,e){const r=n.getMonth();switch(t){case"M":case"MM":return x.M(n,t);case"Mo":return e.ordinalNumber(r+1,{unit:"month"});case"MMM":return e.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(r,{width:"wide",context:"formatting"})}},L:function(n,t,e){const r=n.getMonth();switch(t){case"L":return String(r+1);case"LL":return h(r+1,2);case"Lo":return e.ordinalNumber(r+1,{unit:"month"});case"LLL":return e.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(r,{width:"wide",context:"standalone"})}},w:function(n,t,e,r){const a=st(n,r);return t==="wo"?e.ordinalNumber(a,{unit:"week"}):h(a,t.length)},I:function(n,t,e){const r=ee(n);return t==="Io"?e.ordinalNumber(r,{unit:"week"}):h(r,t.length)},d:function(n,t,e){return t==="do"?e.ordinalNumber(n.getDate(),{unit:"date"}):x.d(n,t)},D:function(n,t,e){const r=te(n);return t==="Do"?e.ordinalNumber(r,{unit:"dayOfYear"}):h(r,t.length)},E:function(n,t,e){const r=n.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(r,{width:"short",context:"formatting"});case"EEEE":default:return e.day(r,{width:"wide",context:"formatting"})}},e:function(n,t,e,r){const a=n.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return h(s,2);case"eo":return e.ordinalNumber(s,{unit:"day"});case"eee":return e.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(a,{width:"short",context:"formatting"});case"eeee":default:return e.day(a,{width:"wide",context:"formatting"})}},c:function(n,t,e,r){const a=n.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return h(s,t.length);case"co":return e.ordinalNumber(s,{unit:"day"});case"ccc":return e.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(a,{width:"narrow",context:"standalone"});case"cccccc":return e.day(a,{width:"short",context:"standalone"});case"cccc":default:return e.day(a,{width:"wide",context:"standalone"})}},i:function(n,t,e){const r=n.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return h(a,t.length);case"io":return e.ordinalNumber(a,{unit:"day"});case"iii":return e.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(r,{width:"short",context:"formatting"});case"iiii":default:return e.day(r,{width:"wide",context:"formatting"})}},a:function(n,t,e){const a=n.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(n,t,e){const r=n.getHours();let a;switch(r===12?a=C.noon:r===0?a=C.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(n,t,e){const r=n.getHours();let a;switch(r>=17?a=C.evening:r>=12?a=C.afternoon:r>=4?a=C.morning:a=C.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(n,t,e){if(t==="ho"){let r=n.getHours()%12;return r===0&&(r=12),e.ordinalNumber(r,{unit:"hour"})}return x.h(n,t)},H:function(n,t,e){return t==="Ho"?e.ordinalNumber(n.getHours(),{unit:"hour"}):x.H(n,t)},K:function(n,t,e){const r=n.getHours()%12;return t==="Ko"?e.ordinalNumber(r,{unit:"hour"}):h(r,t.length)},k:function(n,t,e){let r=n.getHours();return r===0&&(r=24),t==="ko"?e.ordinalNumber(r,{unit:"hour"}):h(r,t.length)},m:function(n,t,e){return t==="mo"?e.ordinalNumber(n.getMinutes(),{unit:"minute"}):x.m(n,t)},s:function(n,t,e){return t==="so"?e.ordinalNumber(n.getSeconds(),{unit:"second"}):x.s(n,t)},S:function(n,t){return x.S(n,t)},X:function(n,t,e){const r=n.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return V(r);case"XXXX":case"XX":return O(r);case"XXXXX":case"XXX":default:return O(r,":")}},x:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"x":return V(r);case"xxxx":case"xx":return O(r);case"xxxxx":case"xxx":default:return O(r,":")}},O:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+X(r,":");case"OOOO":default:return"GMT"+O(r,":")}},z:function(n,t,e){const r=n.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+X(r,":");case"zzzz":default:return"GMT"+O(r,":")}},t:function(n,t,e){const r=Math.trunc(+n/1e3);return h(r,t.length)},T:function(n,t,e){return h(+n,t.length)}};function X(n,t=""){const e=n>0?"-":"+",r=Math.abs(n),a=Math.trunc(r/60),s=r%60;return s===0?e+String(a):e+String(a)+t+h(s,2)}function V(n,t){return n%60===0?(n>0?"-":"+")+h(Math.abs(n)/60,2):O(n,t)}function O(n,t=""){const e=n>0?"-":"+",r=Math.abs(n),a=h(Math.trunc(r/60),2),s=h(r%60,2);return e+a+t+s}const J=(n,t)=>{switch(n){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},it=(n,t)=>{switch(n){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},re=(n,t)=>{const e=n.match(/(P+)(p+)?/)||[],r=e[1],a=e[2];if(!a)return J(n,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",J(r,t)).replace("{{time}}",it(a,t))},ae={p:it,P:re},se=/^D+$/,ie=/^Y+$/,oe=["D","DD","YY","YYYY"];function ce(n){return se.test(n)}function le(n){return ie.test(n)}function ue(n,t,e){const r=he(n,t,e);if(console.warn(r),oe.includes(n))throw new RangeError(r)}function he(n,t,e){const r=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${t}\`) for formatting ${r} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const de=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,fe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,me=/^'([^]*?)'?$/,ge=/''/g,ye=/[a-zA-Z]/;function we(n,t,e){var f,p,b,m;const r=_(),a=r.locale??Zt,s=r.firstWeekContainsDate??((p=(f=r.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,i=r.weekStartsOn??((m=(b=r.locale)==null?void 0:b.options)==null?void 0:m.weekStartsOn)??0,c=k(n,e==null?void 0:e.in);if(!wt(c))throw new RangeError("Invalid time value");let l=t.match(fe).map(g=>{const v=g[0];if(v==="p"||v==="P"){const I=ae[v];return I(g,a.formatLong)}return g}).join("").match(de).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const v=g[0];if(v==="'")return{isToken:!1,value:pe(g)};if(G[v])return{isToken:!0,value:g};if(v.match(ye))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");return{isToken:!1,value:g}});a.localize.preprocessor&&(l=a.localize.preprocessor(c,l));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return l.map(g=>{if(!g.isToken)return g.value;const v=g.value;(le(v)||ce(v))&&ue(v,t,String(n));const I=G[v[0]];return I(c,v,a.localize,u)}).join("")}function pe(n){const t=n.match(me);return t?t[1].replace(ge,"'"):n}function be(n,t){const e=k(n,t==null?void 0:t.in).getDay();return e===0?7:e}function ke(n,t,e){const r=k(n,e==null?void 0:e.in);return r.setHours(t),r}const U={},W={};function N(n,t){try{const r=(U[n]||(U[n]=new Intl.DateTimeFormat("en-GB",{timeZone:n,hour:"numeric",timeZoneName:"longOffset"}).format))(t).split("GMT")[1]||"";return r in W?W[r]:K(r,r.split(":"))}catch{if(n in W)return W[n];const e=n==null?void 0:n.match(ve);return e?K(n,e.slice(1)):NaN}}const ve=/([+-]\d\d):?(\d\d)?/;function K(n,t){const e=+t[0],r=+(t[1]||0);return W[n]=e>0?e*60+r:e*60-r}class S extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(N(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),ot(this),B(this)):this.setTime(Date.now())}static tz(t,...e){return e.length?new S(...e,t):new S(Date.now(),t)}withTimeZone(t){return new S(+this,t)}getTimezoneOffset(){return-N(this.timeZone,this)}setTime(t){return Date.prototype.setTime.apply(this,arguments),B(this),+this}[Symbol.for("constructDateFrom")](t){return new S(+new Date(t),this.timeZone)}}const Z=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(n=>{if(!Z.test(n))return;const t=n.replace(Z,"$1UTC");S.prototype[t]&&(n.startsWith("get")?S.prototype[n]=function(){return this.internal[t]()}:(S.prototype[n]=function(){return Date.prototype[t].apply(this.internal,arguments),De(this),+this},S.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),B(this),+this}))});function B(n){n.internal.setTime(+n),n.internal.setUTCMinutes(n.internal.getUTCMinutes()-n.getTimezoneOffset())}function De(n){Date.prototype.setFullYear.call(n,n.internal.getUTCFullYear(),n.internal.getUTCMonth(),n.internal.getUTCDate()),Date.prototype.setHours.call(n,n.internal.getUTCHours(),n.internal.getUTCMinutes(),n.internal.getUTCSeconds(),n.internal.getUTCMilliseconds()),ot(n)}function ot(n){const t=N(n.timeZone,n),e=new Date(+n);e.setUTCHours(e.getUTCHours()-1);const r=-new Date(+n).getTimezoneOffset(),a=-new Date(+e).getTimezoneOffset(),s=r-a,i=Date.prototype.getHours.apply(n)!==n.internal.getUTCHours();s&&i&&n.internal.setUTCMinutes(n.internal.getUTCMinutes()+s);const c=r-t;c&&Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+c);const l=N(n.timeZone,n),f=-new Date(+n).getTimezoneOffset()-l,p=l!==t,b=f-c;if(p&&b){Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+b);const m=N(n.timeZone,n),g=l-m;g&&(n.internal.setUTCMinutes(n.internal.getUTCMinutes()+g),Date.prototype.setUTCMinutes.call(n,Date.prototype.getUTCMinutes.call(n)+g))}}class M extends S{static tz(t,...e){return e.length?new M(...e,t):new M(Date.now(),t)}toISOString(){const[t,e,r]=this.tzComponents(),a=`${t}${e}:${r}`;return this.internal.toISOString().slice(0,-1)+a}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,e,r,a]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${e} ${a}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[e,r,a]=this.tzComponents();return`${t} GMT${e}${r}${a} (${Se(this.timeZone,this)})`}toLocaleString(t,e){return Date.prototype.toLocaleString.call(this,t,{...e,timeZone:(e==null?void 0:e.timeZone)||this.timeZone})}toLocaleDateString(t,e){return Date.prototype.toLocaleDateString.call(this,t,{...e,timeZone:(e==null?void 0:e.timeZone)||this.timeZone})}toLocaleTimeString(t,e){return Date.prototype.toLocaleTimeString.call(this,t,{...e,timeZone:(e==null?void 0:e.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),e=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),a=String(Math.abs(t)%60).padStart(2,"0");return[e,r,a]}withTimeZone(t){return new M(+this,t)}[Symbol.for("constructDateFrom")](t){return new M(+new Date(t),this.timeZone)}}function Se(n,t){return new Intl.DateTimeFormat("en-GB",{timeZone:n,timeZoneName:"long"}).format(t).slice(12)}window.pktTz=window.pktTz===void 0?"Europe/Oslo":window.pktTz;const w=n=>n.toISOString().split("T")[0],Me=n=>{if(!n)return null;const t=et(new M(n,window.pktTz),12);return isNaN(t.getTime())?null:t},xe=(n,t)=>{const e=y(n);return isNaN(e.getTime())?"":we(e,t)},y=(n="",t)=>{const e=n===""||!n?new Date:n;return t?new M(t==="end"?pt(e):z(e),window.pktTz):ke(new M(e.toString(),window.pktTz),12)},P=(n,t,e=1)=>et(new M(n,t,e,window.pktTz),12),Pe=n=>new Intl.DateTimeFormat("no",{dateStyle:"full",timeZone:window.pktTz}).format(n),ct=n=>{if(Array.isArray(n))return n;if(typeof n=="string")return n.split(",")},Te=n=>n?new Date(n):null,Oe=n=>{if(typeof n=="string")return n.split(",").map(t=>new Date(t));if(Array.isArray(n))return n.map(t=>new Date(t))},H={csvToArray:ct,stringToDate:Te,stringsToDate:Oe},Ce={earliest:{default:null},latest:{default:null},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},maxMultiple:{default:4},range:{default:!1}},T={props:Ce};var $e=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,d=(n,t,e,r)=>{for(var a=r>1?void 0:r?Ee(t,e):t,s=n.length-1,i;s>=0;s--)(i=n[s])&&(a=(r?i(t,e,a):i(a))||a);return r&&a&&$e(t,e,a),a};exports.PktCalendar=class extends o.PktElement{constructor(){super(...arguments),this.multiple=T.props.multiple.default,this.maxMultiple=T.props.maxMultiple.default,this.range=T.props.range.default,this.weeknumbers=T.props.weeknumbers.default,this.withcontrols=T.props.withcontrols.default,this.selected=[],this.earliest=T.props.earliest.default,this.latest=T.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.dayStringsLong=this.strings.dates.days,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1,this.tabIndexSet=0}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(t,e,r){t==="selected"&&r&&this.convertSelected(),super.attributeChangedCallback(t,e,r)}updated(t){super.updated(t),t.has("selected")&&this.convertSelected()}firstUpdated(t){this.addEventListener("keydown",this.handleKeydown)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(t=>y(t)),this.range&&this.selected.length===2){const t=L({start:y(this.selected[0]),end:y(this.selected[1])});if(this.inRange={},Array.isArray(t)&&t.length){const e={};for(let r=0;r<t.length;r++)e[w(t[r])]=this.isInRange(t[r]);this.inRange=e}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched){this.currentmonthtouched=!0;return}this.selected.length&&this.selected[0]!==""?this.currentmonth=y(this.selected[this.selected.length-1]):this.currentmonth===null&&(this.currentmonth=y()),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(t){switch(t.key){case"ArrowLeft":this.handleArrowKey(t,-1);break;case"ArrowRight":this.handleArrowKey(t,1);break;case"ArrowUp":this.handleArrowKey(t,-7);break;case"ArrowDown":this.handleArrowKey(t,7);break}}handleArrowKey(t,e){var s,i,c;if(((s=t.target)==null?void 0:s.nodeName)==="INPUT"||((i=t.target)==null?void 0:i.nodeName)==="SELECT"||((c=t.target)==null?void 0:c.nodeName)==="BUTTON")return;t.preventDefault(),this.focusedDate||this.focusOnCurrentDate();const r=this.focusedDate?y(this.focusedDate):P(this.year,this.month,1);let a=q(r,e);if(a){let l=this.querySelector(`div[data-date="${w(a)}"]`);if(l instanceof HTMLDivElement){if(l.dataset.disabled){a=q(a,e);let u=this.querySelector(`div[data-date="${w(a)}"]`);for(;u&&u instanceof HTMLDivElement&&u.dataset.disabled;)a=q(a,e),u=this.querySelector(`div[data-date="${w(a)}"]`);l=u}l instanceof HTMLDivElement&&!l.dataset.disabled&&(this.focusedDate=w(a),l.focus())}}}render(){return o.x`
2
- <div
3
- class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":o.E}"
4
- @focusout=${this.closeEvent}
5
- @keydown=${t=>{t.key==="Escape"&&(t.preventDefault(),this.close())}}
6
- >
7
- <nav class="pkt-cal-month-nav">
8
- <div>
9
- <button
10
- type="button"
11
- @click=${this.isPrevMonthAllowed()&&this.prevMonth}
12
- @keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.prevMonth())}}
13
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed()?"":"pkt-hide"}"
14
- .data-disabled=${this.isPrevMonthAllowed()?o.E:"disabled"}
15
- ?aria-disabled=${!this.isPrevMonthAllowed()}
16
- tabindex=${this.isPrevMonthAllowed()?"0":"-1"}
17
- >
18
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
19
- <span class="pkt-btn__text">${this.prevMonthString}</span>
20
- </button>
21
- </div>
22
- ${this.renderMonthNav()}
23
- <div>
24
- <button
25
- type="button"
26
- @click=${this.isNextMonthAllowed()&&this.nextMonth}
27
- @keydown=${t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
28
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed()?"":"pkt-hide"}"
29
- .data-disabled=${this.isNextMonthAllowed()?o.E:"disabled"}
30
- ?aria-disabled=${!this.isNextMonthAllowed()}
31
- tabindex=${this.isNextMonthAllowed()?"0":"-1"}
32
- >
33
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
34
- <span class="pkt-btn__text">${this.nextMonthString}</span>
35
- </button>
36
- </div>
37
- </nav>
38
- <table
39
- class="pkt-cal-days pkt-txt-12-medium"
40
- role="grid"
41
- ?aria-multiselectable=${this.range||this.multiple}
42
- >
43
- <thead>
44
- ${this.renderDayNames()}
45
- </thead>
46
- <tbody>
47
- ${this.renderCalendarBody()}
48
- </tbody>
49
- </table>
50
- </div>
51
- `}renderDayNames(){const t=[];this.weeknumbers&&t.push(o.x`<th><div>${this.weekString}</div></th>`);for(let e=0;e<this.dayStrings.length;e++)t.push(o.x`<th><div aria-label="${this.dayStringsLong[e]}">${this.dayStrings[e]}</div></th>`);return o.x`<tr class="pkt-cal-week-row">
52
- ${t}
53
- </tr>`}renderMonthNav(){let t=[];return this.withcontrols?t.push(o.x`<div class="pkt-cal-month-picker">
54
- <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
55
- <select
56
- aria-label="${this.strings.dates.month}"
57
- class="pkt-input pkt-input-compact"
58
- id="${this.id}-monthnav"
59
- @change=${e=>{e.stopImmediatePropagation(),this.changeMonth(this.year,e.target.value)}}
60
- >
61
- ${this.monthStrings.map((e,r)=>o.x`<option value=${r} ?selected=${this.month===r}>${e}</option>`)}
62
- </select>
63
- <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
64
- <input
65
- aria-label="${this.strings.dates.year}"
66
- class="pkt-input pkt-cal-input-year pkt-input-compact"
67
- id="${this.id}-yearnav"
68
- type="number"
69
- size="4"
70
- placeholder="0000"
71
- @change=${e=>{e.stopImmediatePropagation(),this.changeMonth(e.target.value,this.month)}}
72
- .value=${this.year}
73
- />
74
- </div> `):t.push(o.x`<div class="pkt-txt-16-medium" aria-live="polite">
75
- ${this.monthStrings[this.month]} ${this.year}
76
- </div>`),t}renderDayView(t,e,r){var b;const a=P(this.year,this.month,t),s=w(a),i=s===w(e),c=this.selected.includes(s),l=Pe(a),u=this.isExcluded(r,a)||!c&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,f=this.focusedDate?this.focusedDate===s&&!u?"0":"-1":!u&&this.tabIndexSet===0||this.tabIndexSet===t?"0":"-1";f==="0"&&(this.tabIndexSet=t),this.selectableDates.push({currentDateISO:s,isDisabled:u,tabindex:f});const p={"pkt-cal-today":i,"pkt-cal-selected":c,"pkt-cal-in-range":this.inRange[s],"pkt-cal-excluded":this.isExcluded(r,a),"pkt-cal-in-range-first":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&s===this.selected[0],"pkt-cal-in-range-last":this.range&&this.selected.length===2&&s===this.selected[1],"pkt-cal-range-hover":this.rangeHovered!==null&&s===w(this.rangeHovered)};return o.x`<td class=${lt.e(p)}>
77
- <div
78
- ?aria-selected=${c}
79
- role="gridcell"
80
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
81
- @mouseover=${()=>this.range&&!this.isExcluded(r,a)&&this.handleRangeHover(a)}
82
- @focus=${()=>{this.range&&!this.isExcluded(r,a)&&this.handleRangeHover(a),this.focusedDate=s}}
83
- aria-label="${l}"
84
- tabindex=${(b=this.selectableDates.find(m=>m.currentDateISO===s))==null?void 0:b.tabindex}
85
- data-disabled=${u?"disabled":o.E}
86
- data-date=${s}
87
- @keydown=${m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),this.handleDateSelect(a))}}
88
- @click=${m=>{u||(m.preventDefault(),this.handleDateSelect(a))}}
89
- >
90
- <span class="pkt-btn__text pkt-txt-14-light">${t}</span>
91
- </div>
92
- </td>`}renderCalendarBody(){const t=y(),e=P(this.year,this.month,1),r=P(this.year,this.month+1,0),a=(e.getDay()+6)%7,s=r.getDate(),i=Math.ceil((s+a)/7),l=P(this.year,this.month,0).getDate();let u=1;this.week=st(P(this.year,this.month,1));const f=[];for(let p=0;p<i;p++){const b=[];this.weeknumbers&&b.push(o.x`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let m=1;m<8;m++)if(p===0&&m<a+1){const g=l-(a-m);b.push(o.x`<td class="pkt-cal-other">
93
- <div
94
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
95
- data-disabled="disabled"
96
- >
97
- <span class="pkt-btn__text pkt-txt-14-light">${g}</span>
98
- </div>
99
- </td>`)}else u>s?(b.push(o.x`<td class="pkt-cal-other">
100
- <div
101
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
102
- data-disabled="disabled"
103
- >
104
- <span class="pkt-btn__text pkt-txt-14-light">${u-s}</span>
105
- </div>
106
- </td>`),u++):(b.push(this.renderDayView(u,t,m)),u++);f.push(o.x`<tr class="pkt-cal-week-row" role="row">
107
- ${b}
108
- </tr>`)}return f}isExcluded(t,e){return this.excludeweekdays.includes(t.toString())||this.earliest&&y(e,"end")<y(this.earliest,"start")||this.latest&&y(e,"start")>y(this.latest,"end")?!0:this.excludedates.some(r=>typeof r=="string"?r===w(e):r.toDateString()===e.toDateString())}isPrevMonthAllowed(){const t=P(this.year,this.month,0);return!(this.earliest&&y(this.earliest)>t)}prevMonth(){const t=this.month===0?11:this.month-1,e=this.month===0?this.year-1:this.year;this.changeMonth(e,t)}isNextMonthAllowed(){const t=P(this.month===11?this.year+1:this.year,this.month===11?0:this.month+1,1);return!(this.latest&&y(this.latest)<t)}nextMonth(){const t=this.month===11?0:this.month+1,e=this.month===11?this.year+1:this.year;this.changeMonth(e,t)}changeMonth(t,e){this.year=typeof t=="string"?parseInt(t):t,this.month=typeof e=="string"?parseInt(e):e,this.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[]}isInRange(t){if(this.range&&this.selected.length===2){if(t>y(this.selected[0])&&t<y(this.selected[1]))return!0}else if(this.range&&this.selected.length===1&&this.rangeHovered&&t>y(this.selected[0])&&t<this.rangeHovered)return!0;return!1}isRangeAllowed(t){let e=!0;if(this._selected.length===1){const r=L({start:this._selected[0],end:t});if(Array.isArray(r)&&r.length)for(let a=0;a<r.length;a++)this.excludedates.forEach(s=>{s>this._selected[0]&&s<t&&(e=!1)}),this.excludeweekdays.includes(be(r[a]).toString())&&(e=!1)}return e}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}addToSelected(t){this.selected.includes(w(t))||(this.selected=[...this.selected,w(t)],this._selected=[...this._selected,t],this.range&&this.selected.length===2&&this.close())}removeFromSelected(t){if(this.selected.length===1)this.emptySelected();else{const e=this.selected.indexOf(w(t)),r=[...this.selected],a=[...this._selected];r.splice(e,1),a.splice(e,1),this.selected=r,this._selected=a}}toggleSelected(t){const e=w(t);this.selected.includes(e)?this.removeFromSelected(t):this.maxMultiple&&this.selected.length>=this.maxMultiple||this.addToSelected(t)}handleRangeSelect(t){const e=w(t);return this.selected.includes(e)?this.selected.indexOf(e)===0?this.emptySelected():this.removeFromSelected(t):this.selected.length>1?(this.emptySelected(),this.addToSelected(t)):(this.selected.length===1&&!this.isRangeAllowed(t)&&this.emptySelected(),this.selected.length===1&&this._selected[0]>t&&this.emptySelected(),this.addToSelected(t)),Promise.resolve()}handleRangeHover(t){if(this.range&&this._selected.length===1&&this.isRangeAllowed(t)&&this._selected[0]<t){this.rangeHovered=t,this.inRange={};const e=L({start:this._selected[0],end:t});if(Array.isArray(e)&&e.length)for(let r=0;r<e.length;r++)this.inRange[w(e[r])]=this.isInRange(e[r])}else this.rangeHovered=null}handleDateSelect(t){if(t)return this.range?this.handleRangeSelect(t):this.multiple?this.toggleSelected(t):(this.selected.includes(w(t))?this.emptySelected():(this.emptySelected(),this.addToSelected(t)),this.close()),this.dispatchEvent(new CustomEvent("date-selected",{detail:this.selected,bubbles:!0,composed:!0})),Promise.resolve()}focusOnCurrentDate(){const t=w(y()),e=this.querySelector(`div[data-date="${t}"]`);if(e instanceof HTMLDivElement)this.focusedDate=t,e.focus();else{const r=this.selectableDates.find(a=>!a.isDisabled);if(r){const a=this.querySelector(`div[data-date="${r.currentDateISO}"]`);a instanceof HTMLDivElement&&(this.focusedDate=r.currentDateISO,a.focus())}}}closeEvent(t){!this.contains(t.relatedTarget)&&!t.target.classList.contains("pkt-hide")&&this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};d([o.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);d([o.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);d([o.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);d([o.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);d([o.n({converter:H.csvToArray})],exports.PktCalendar.prototype,"selected",2);d([o.n({type:String})],exports.PktCalendar.prototype,"earliest",2);d([o.n({type:String})],exports.PktCalendar.prototype,"latest",2);d([o.n({converter:H.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);d([o.n({converter:H.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);d([o.n({converter:H.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"dayStringsLong",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);d([o.n({type:String})],exports.PktCalendar.prototype,"weekString",2);d([o.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);d([o.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);d([o.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"year",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"month",2);d([o.n({type:Number})],exports.PktCalendar.prototype,"week",2);d([o.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);d([A.r()],exports.PktCalendar.prototype,"inRange",2);d([A.r()],exports.PktCalendar.prototype,"focusedDate",2);d([A.r()],exports.PktCalendar.prototype,"selectableDates",2);d([A.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);d([A.r()],exports.PktCalendar.prototype,"tabIndexSet",2);exports.PktCalendar=d([o.t("pkt-calendar")],exports.PktCalendar);exports.converters=H;exports.csvToArray=ct;exports.formatISODate=w;exports.fromISOToDate=Me;exports.fromISOtoLocal=xe;exports.newDate=y;
@@ -1,11 +0,0 @@
1
- "use strict";const s=require("./element-90YeMNbV.cjs");require("./button-KzBZ-Bff.cjs");require("./icon-B1_BRNqf.cjs");const g={i18n:{nb:{contentPresentation:{title:"Oslo kommune bruker informasjonskapsler",description:["For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.","Godtar du alle informasjonskapsler, tillater du også at vi samler inn data om statistikk og brukeradferd. Da hjelper du oss med å lage et bedre nettsted uten at du trenger å dele noe personlig informasjon med oss."],buttons:{accept:"Godta alle",reject:"Kun nødvendige",settings:"Innstillinger for informasjonskapsler"}},contentSettings:{title:"Innstillinger for informasjonskapsler",description:["Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.","Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler»."],buttons:{back:"Tilbake",save:"Lagre innstillinger"}}},en:{contentPresentation:{title:"Before you visit Oslo kommune ...",description:["This website uses cookies to make improvements. In this context, we need your consent to measure the traffic on the website in relation to statistics and feedback.","To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites."],buttons:{accept:"Yes, I accept",reject:"Only necessary",settings:"Go to settings"}},contentSettings:{title:"Her kan du aktivt velge mellom ulike informasjonskapsler",description:["For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider"],buttons:{back:"Back",save:"Save settings"}}}}},c=globalThis,d=c.__cookieEvents||{events:{},on(n,e){this.events[n]||(this.events[n]=[]),this.events[n].push(e)},off(n,e){this.events[n]&&(this.events[n]=this.events[n].filter(t=>t!==e))},once(n,e){const t=o=>{this.off(n,t),e(o)};this.on(n,t)},emit(n,e){this.events[n]&&this.events[n].forEach(t=>t(e))}};c.__cookieEvents=d;const k=d;var u=Object.defineProperty,p=Object.getOwnPropertyDescriptor,a=(n,e,t,o)=>{for(var i=o>1?void 0:o?p(e,t):e,r=n.length-1,l;r>=0;r--)(l=n[r])&&(i=(o?l(e,t,i):l(i))||i);return o&&i&&u(e,t,i),i};exports.PktConsent=class extends s.PktElement{constructor(){super(),this.hotjarId=null,this.googleAnalyticsId=null,this.triggerType="button",this.triggerText=null,this.i18nLanguage="nb"}connectedCallback(){super.connectedCallback(),this.triggerText=this.triggerText||g.i18n[this.i18nLanguage].contentPresentation.buttons.settings,this.googleAnalyticsId&&(window.googleAnalyticsId=this.googleAnalyticsId),this.hotjarId&&(window.hotjarId=this.hotjarId),k.on("CookieManager.setCookie",e=>{this.emitCookieConsents(e)})}returnJsonOrObject(e){let t;try{t=JSON.parse(e)}catch{t=e}return t}emitCookieConsents(e){const o=this.returnJsonOrObject(e.value).items.reduce((i,r)=>(i[r.name]=r.consent,i),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:o,bubbles:!0,composed:!0}))}firstUpdated(e){if(!document.querySelector("#oslo-consent-script")&&window.location.hostname.toLowerCase().includes("oslo.kommune.no")){window.googleAnalyticsId=this.googleAnalyticsId,window.hotjarId=this.hotjarId;const t=document.createElement("script");t.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js",t.id="oslo-consent-script",t.onload=()=>{this.triggerInit()},document.head.appendChild(t);const o=document.createElement("link");o.href="https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css",o.type="text/css",o.rel="stylesheet",o.id="oslo-consent-styles",document.head.appendChild(o)}}triggerInit(){window.document.dispatchEvent(new Event("DOMContentLoaded",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(e=>{if(e){const o={value:window.cookieBanner.cookieConsent.getConsentCookie()};this.emitCookieConsents(o)}})}openModal(e){e.preventDefault(),window.cookieBanner.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?s.x`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?s.x`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
2
- <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
3
- ${this.triggerText}
4
- </a>`:this.triggerType==="icon"?s.x`<pkt-button
5
- skin="tertiary"
6
- variant="icon-only"
7
- iconName="cookie"
8
- @click=${this.openModal}
9
- >
10
- >${this.triggerText}</pkt-button
11
- >`:s.x`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`}};a([s.n({type:String})],exports.PktConsent.prototype,"hotjarId",2);a([s.n({type:String})],exports.PktConsent.prototype,"googleAnalyticsId",2);a([s.n({type:String})],exports.PktConsent.prototype,"triggerType",2);a([s.n({type:String})],exports.PktConsent.prototype,"triggerText",2);a([s.n({type:String})],exports.PktConsent.prototype,"i18nLanguage",2);exports.PktConsent=a([s.t("pkt-consent")],exports.PktConsent);