@telia/teddy 0.0.61 → 0.0.62

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.
Files changed (41) hide show
  1. package/dist/components/index.cjs +2 -4
  2. package/dist/components/index.js +2 -4
  3. package/dist/components/modal/modal.cjs +0 -2
  4. package/dist/components/modal/modal.js +0 -2
  5. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.cjs +2 -3
  6. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop-simplified.js +2 -3
  7. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.cjs +2 -3
  8. package/dist/components/navigation-menu/global-navigation/global-navigation-desktop.js +1 -2
  9. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.cjs +2 -3
  10. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile-simplified.js +2 -3
  11. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.cjs +2 -3
  12. package/dist/components/navigation-menu/global-navigation/global-navigation-mobile.js +2 -3
  13. package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.cjs +12 -682
  14. package/dist/components/navigation-menu/global-navigation/global-navigation-my-pages.js +12 -682
  15. package/dist/components/navigation-menu/global-navigation/global-navigation-root.cjs +4 -5
  16. package/dist/components/navigation-menu/global-navigation/global-navigation-root.js +4 -5
  17. package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.cjs +2 -2
  18. package/dist/components/navigation-menu/global-navigation/global-navigation-search-field.js +2 -2
  19. package/dist/components/navigation-menu/global-navigation/global-navigation-search.cjs +2 -3
  20. package/dist/components/navigation-menu/global-navigation/global-navigation-search.js +2 -3
  21. package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.cjs +2 -3
  22. package/dist/components/navigation-menu/global-navigation/global-navigation-shopping-cart.js +2 -3
  23. package/dist/components/navigation-menu/global-navigation/index.cjs +2 -2
  24. package/dist/components/navigation-menu/global-navigation/index.js +1 -1
  25. package/dist/components/navigation-menu/index.cjs +3 -4
  26. package/dist/components/navigation-menu/index.js +2 -3
  27. package/dist/components/navigation-menu/navigation-menu.cjs +55 -436
  28. package/dist/components/navigation-menu/navigation-menu.d.ts +8 -0
  29. package/dist/components/navigation-menu/navigation-menu.js +55 -419
  30. package/dist/components/radio-card-group/radio-card-group-content.cjs +0 -2
  31. package/dist/components/radio-card-group/radio-card-group-content.js +0 -2
  32. package/dist/components/radio-card-group/radio-card-group-item-body.cjs +0 -2
  33. package/dist/components/radio-card-group/radio-card-group-item-body.js +0 -2
  34. package/dist/components/radio-card-group/radio-card-group-item-title.cjs +1134 -51
  35. package/dist/components/radio-card-group/radio-card-group-item-title.js +1145 -63
  36. package/dist/components/radio-card-group/radio-card-group-item.cjs +0 -2
  37. package/dist/components/radio-card-group/radio-card-group-item.js +0 -2
  38. package/dist/main.cjs +2 -4
  39. package/dist/main.js +2 -4
  40. package/dist/style.css +1161 -1143
  41. package/package.json +1 -1
@@ -1,42 +1,48 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import React__default, { useEffect } from "react";
3
- import * as DrawerPrimitive from "@radix-ui/react-dialog";
3
+ import clsx from "clsx";
4
+ import { MY_PAGE_LINKS, LOGGED_IN_LINKS_BUSINESS, PRIVATE_LINKS, BUSINESS_LINKS, MDU_LINKS, getActiveSubLink, LINKS } from "../navigation-menu/global-navigation/utils.js";
5
+ import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
6
+ import { useComposedRefs, composeRefs } from "../../utils/composeRefs.js";
7
+ import { VisuallyHidden } from "../visually-hidden/visually-hidden.js";
8
+ import { composeEventHandlers } from "../../utils/composeEventHandlers.js";
9
+ import { Slot } from "@radix-ui/react-slot";
10
+ import { useControllableState } from "@radix-ui/react-use-controllable-state";
11
+ import { mergeStyles } from "../../utils/generate-styling/index.js";
12
+ import { teddyMotionDuration300 } from "../../tokens/motion/variables.js";
4
13
  import "../toast/toast-root.js";
5
14
  import "sonner";
6
15
  import "../toggletip/index.js";
7
16
  import "../breadcrumbs/index.js";
8
- import { s as styles$1, rootClassName as rootClassName$1, Root as Root$1 } from "./radio-card-group-root.js";
17
+ import { s as styles$3, rootClassName as rootClassName$3, Root as Root$3 } from "./radio-card-group-root.js";
9
18
  import { GroupLabel } from "./radio-card-group-label.js";
10
- import clsx from "clsx";
11
- import { Slot } from "@radix-ui/react-slot";
12
19
  import "../ribbon/index.js";
13
20
  import "../expandable-card/index.js";
14
21
  import "../color-dot/color-dot-root.js";
15
22
  import "../progress-bar/progress-bar.js";
16
23
  import "../notabene/index.js";
17
24
  import "../tooltip/index.js";
18
- import "../list/index.js";
25
+ import { List as List$1 } from "../list/index.js";
19
26
  import "../scroll-area/index.js";
20
- import "../tabs/index.js";
21
- import "../drawer/index.js";
27
+ import { Tabs } from "../tabs/index.js";
28
+ import { Drawer } from "../drawer/index.js";
22
29
  import "../image/image.js";
23
30
  import "../chip/index.js";
24
31
  import "../../assets/sprite.269ba410-teddy.svg";
32
+ import * as DrawerPrimitive from "@radix-ui/react-dialog";
25
33
  import { Icon } from "../icon/icon.js";
26
34
  import "../notification/notification.js";
27
35
  import "../radio-group/index.js";
28
- import "../box/box.js";
36
+ import { Box } from "../box/box.js";
29
37
  import { Flex } from "../flex/flex.js";
30
38
  import "../card/index.js";
31
- import "../grid/grid.js";
32
- import "../navigation-menu/navigation-menu.js";
33
- import "../navigation-menu/global-navigation/global-navigation-my-pages.js";
39
+ import { Grid } from "../grid/grid.js";
34
40
  import "../toggle/toggle.js";
35
- import "../accordion/index.js";
36
- import "../link/link.js";
41
+ import { Accordion } from "../accordion/index.js";
42
+ import { Link as Link$1 } from "../link/link.js";
37
43
  import "../badge/badge.js";
38
44
  import "../badge/alert-badge.js";
39
- import "../badge/counter-badge.js";
45
+ import { CounterBadge } from "../badge/counter-badge.js";
40
46
  import { Button } from "../button/button.js";
41
47
  import "../field-error-text/field-error-text.js";
42
48
  import "../helper-text/helper-text.js";
@@ -44,65 +50,65 @@ import "../input/index.js";
44
50
  import "../label/label.js";
45
51
  import "../spinner/spinner.js";
46
52
  import { Text } from "../text/text.js";
47
- import "../text-field/index.js";
53
+ import { TextField } from "../text-field/index.js";
48
54
  import { Heading } from "../heading/heading.js";
49
- import "../visually-hidden/visually-hidden.js";
50
- import "../text-spacing/text-spacing.js";
55
+ import { TextSpacing } from "../text-spacing/text-spacing.js";
51
56
  import "../container/container.js";
52
- import { useComposedRefs, composeRefs } from "../../utils/composeRefs.js";
53
- import { Indicator } from "./radio-card-group-indicator.js";
57
+ import { Indicator as Indicator$1 } from "./radio-card-group-indicator.js";
54
58
  import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
59
+ import { useSize } from "../../utils/useSize.js";
60
+ import { useCallbackRef } from "../../utils/useCallbackRef.js";
55
61
  const Title$1 = React__default.forwardRef(
56
62
  ({ className, children, asChild, ...props }, forwardRef) => {
57
- const classes = clsx([styles$1[`${rootClassName$1}__title`]], className);
58
- return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: "150", className: styles$1[`${rootClassName$1}__title-wrapper`], children: [
63
+ const classes = clsx([styles$3[`${rootClassName$3}__title`]], className);
64
+ return /* @__PURE__ */ jsxs(Flex, { width: "100%", gap: "150", className: styles$3[`${rootClassName$3}__title-wrapper`], children: [
59
65
  asChild ? /* @__PURE__ */ jsx(Slot, { ...props, ref: forwardRef, className: classes, children }) : /* @__PURE__ */ jsx(Text, { variant: "paragraph-100-bold", ref: forwardRef, className: classes, children }),
60
- /* @__PURE__ */ jsx(Indicator, {})
66
+ /* @__PURE__ */ jsx(Indicator$1, {})
61
67
  ] });
62
68
  }
63
69
  );
64
70
  Title$1.displayName = "Title";
65
71
  const Body = React__default.forwardRef(
66
72
  ({ className, children, asChild, ...props }, forwardRef) => {
67
- const classes = clsx([styles$1[`${rootClassName$1}__body`]], className);
73
+ const classes = clsx([styles$3[`${rootClassName$3}__body`]], className);
68
74
  const Comp = asChild ? Slot : Text;
69
75
  return /* @__PURE__ */ jsx(Comp, { ref: forwardRef, className: classes, ...props, children });
70
76
  }
71
77
  );
72
78
  Body.displayName = "Body";
73
- const Content$1 = React__default.forwardRef(
79
+ const Content$2 = React__default.forwardRef(
74
80
  ({ className, children, ...props }, forwardRef) => {
75
- const classes = clsx([styles$1[`${rootClassName$1}__content-wrapper`]], className);
81
+ const classes = clsx([styles$3[`${rootClassName$3}__content-wrapper`]], className);
76
82
  return /* @__PURE__ */ jsx(Flex, { direction: "column", width: "100%", gap: "50", ...props, ref: forwardRef, className: classes, children });
77
83
  }
78
84
  );
79
- Content$1.displayName = "Content";
85
+ Content$2.displayName = "Content";
80
86
  const ItemContext = React__default.createContext(void 0);
81
- const Item = React__default.forwardRef(
87
+ const Item$1 = React__default.forwardRef(
82
88
  ({ className, children, value, ...props }, forwardedRef) => {
83
- const classes = clsx([styles$1[`${rootClassName$1}__card-item`]], className);
89
+ const classes = clsx([styles$3[`${rootClassName$3}__card-item`]], className);
84
90
  const context = React__default.useContext(ItemContext);
85
91
  const ref = useComposedRefs(forwardedRef, context == null ? void 0 : context.triggerRef);
86
92
  const id = props.id || (context == null ? void 0 : context.id);
87
93
  return /* @__PURE__ */ jsxs(RadioGroupPrimitive.Item, { value, id, ...props, asChild: false, ref, className: classes, children: [
88
- props.imageUrl ? /* @__PURE__ */ jsx(Flex, { className: clsx([styles$1[`${rootClassName$1}__illustration`]], className), justify: "center", align: "center", children: /* @__PURE__ */ jsx("img", { src: props.imageUrl, alt: value }) }) : null,
89
- /* @__PURE__ */ jsx(Content$1, { children })
94
+ props.imageUrl ? /* @__PURE__ */ jsx(Flex, { className: clsx([styles$3[`${rootClassName$3}__illustration`]], className), justify: "center", align: "center", children: /* @__PURE__ */ jsx("img", { src: props.imageUrl, alt: value }) }) : null,
95
+ /* @__PURE__ */ jsx(Content$2, { children })
90
96
  ] });
91
97
  }
92
98
  );
93
- Item.displayName = "Item";
94
- Root$1.displayName = "RadioCardGroup";
99
+ Item$1.displayName = "Item";
100
+ Root$3.displayName = "RadioCardGroup";
95
101
  GroupLabel.displayName = "RadioCardGroup.GroupLabel";
96
- Item.displayName = "RadioCardGroup.Item";
102
+ Item$1.displayName = "RadioCardGroup.Item";
97
103
  Title$1.displayName = "RadioCardGroup.Title";
98
104
  Body.displayName = "RadioCardGroup.Body";
99
- const RadioCardGroup = Object.assign(Root$1, {
105
+ const RadioCardGroup = Object.assign(Root$3, {
100
106
  GroupLabel,
101
- Item,
107
+ Item: Item$1,
102
108
  Title: Title$1,
103
109
  Body
104
110
  });
105
- const styles = {
111
+ const styles$2 = {
106
112
  "teddy-modal__overlay": "_teddy-modal__overlay_3n21u_25",
107
113
  "teddy-modal__content": "_teddy-modal__content_3n21u_37",
108
114
  "teddy-modal__scroll": "_teddy-modal__scroll_3n21u_55",
@@ -119,41 +125,41 @@ const styles = {
119
125
  "modal-content-hide": "_modal-content-hide_3n21u_1",
120
126
  "teddy-overlay-no-op": "_teddy-overlay-no-op_3n21u_1"
121
127
  };
122
- const rootClassName = "teddy-modal";
123
- const RootContext = React__default.createContext({
128
+ const rootClassName$2 = "teddy-modal";
129
+ const RootContext$1 = React__default.createContext({
124
130
  imageRef: null,
125
131
  actionGroupRef: null,
126
132
  scrollRef: null
127
133
  });
128
- const Root = (props) => {
134
+ const Root$2 = (props) => {
129
135
  const imageRef = React__default.useRef(null);
130
136
  const actionGroupRef = React__default.useRef(null);
131
137
  const scrollRef = React__default.useRef(null);
132
- return /* @__PURE__ */ jsx(RootContext.Provider, { value: { imageRef, actionGroupRef, scrollRef }, children: /* @__PURE__ */ jsx(DrawerPrimitive.Root, { ...props, modal: true }) });
138
+ return /* @__PURE__ */ jsx(RootContext$1.Provider, { value: { imageRef, actionGroupRef, scrollRef }, children: /* @__PURE__ */ jsx(DrawerPrimitive.Root, { ...props, modal: true }) });
133
139
  };
134
- Root.displayName = "Dialog.Root";
135
- const Trigger = React__default.forwardRef(
140
+ Root$2.displayName = "Dialog.Root";
141
+ const Trigger$1 = React__default.forwardRef(
136
142
  ({ children, ...props }, forwardedRef) => /* @__PURE__ */ jsx(DrawerPrimitive.Trigger, { ...props, ref: forwardedRef, asChild: true, children })
137
143
  );
138
- Trigger.displayName = "Dialog.Trigger";
144
+ Trigger$1.displayName = "Dialog.Trigger";
139
145
  const OverlayContext = React__default.createContext(false);
140
146
  const Overlay = React__default.forwardRef(
141
147
  ({ className, forceMount, container, ...rest }, forwardedRef) => {
142
- const classes = clsx([styles[`${rootClassName}__overlay`]], className);
148
+ const classes = clsx([styles$2[`${rootClassName$2}__overlay`]], className);
143
149
  return /* @__PURE__ */ jsx(OverlayContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DrawerPrimitive.Portal, { container, forceMount, children: /* @__PURE__ */ jsx(DrawerPrimitive.Overlay, { className: classes, ref: forwardedRef, ...rest }) }) });
144
150
  }
145
151
  );
146
152
  Overlay.displayName = "Dialog.Content";
147
153
  const InnerContent = React__default.forwardRef(
148
154
  function InnerContent2({ asChild, children, className, ...props }, forwardedRef) {
149
- const classes = clsx([styles[`${rootClassName}__scroll`]], className);
150
- const context = React__default.useContext(RootContext);
155
+ const classes = clsx([styles$2[`${rootClassName$2}__scroll`]], className);
156
+ const context = React__default.useContext(RootContext$1);
151
157
  return /* @__PURE__ */ jsx(
152
158
  DrawerPrimitive.Content,
153
159
  {
154
160
  ...props,
155
161
  ref: forwardedRef,
156
- className: clsx([styles[`${rootClassName}__content`]]),
162
+ className: clsx([styles$2[`${rootClassName$2}__content`]]),
157
163
  asChild: true,
158
164
  children: /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
159
165
  Flex,
@@ -171,7 +177,7 @@ const InnerContent = React__default.forwardRef(
171
177
  );
172
178
  }
173
179
  );
174
- const Content = React__default.forwardRef(
180
+ const Content$1 = React__default.forwardRef(
175
181
  ({ forceMount, ...contentProps }, forwardedRef) => {
176
182
  const hasOverlay = React__default.useContext(OverlayContext);
177
183
  if (!hasOverlay)
@@ -179,11 +185,11 @@ const Content = React__default.forwardRef(
179
185
  return /* @__PURE__ */ jsx(InnerContent, { ref: forwardedRef, ...contentProps });
180
186
  }
181
187
  );
182
- Content.displayName = "Dialog.Content";
188
+ Content$1.displayName = "Dialog.Content";
183
189
  const GroupContext = React__default.createContext(false);
184
190
  const Group = React__default.forwardRef(
185
191
  ({ className, variant, ...props }, forwardedRef) => {
186
- const strollerRef = React__default.useContext(RootContext).scrollRef;
192
+ const strollerRef = React__default.useContext(RootContext$1).scrollRef;
187
193
  const [isOverflowing, setIsOverflowing] = React__default.useState(false);
188
194
  useEffect(() => {
189
195
  if (strollerRef == null ? void 0 : strollerRef.current) {
@@ -192,11 +198,11 @@ const Group = React__default.forwardRef(
192
198
  }
193
199
  }, [strollerRef]);
194
200
  const classes = clsx(
195
- [styles[`${rootClassName}__group`]],
201
+ [styles$2[`${rootClassName$2}__group`]],
196
202
  {
197
- [styles[`${rootClassName}__group--action`]]: variant === "action",
198
- [styles[`${rootClassName}__group--title`]]: variant === "title",
199
- [styles[`${rootClassName}__group--scroll`]]: isOverflowing
203
+ [styles$2[`${rootClassName$2}__group--action`]]: variant === "action",
204
+ [styles$2[`${rootClassName$2}__group--title`]]: variant === "title",
205
+ [styles$2[`${rootClassName$2}__group--scroll`]]: isOverflowing
200
206
  },
201
207
  className
202
208
  );
@@ -233,19 +239,19 @@ Title.displayName = "Dialog.Title";
233
239
  const Description = React__default.forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(DrawerPrimitive.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { as: "p", variant: "paragraph-100", ...props, asChild: false, ref: forwardedRef }) }));
234
240
  Description.displayName = "Dialog.Description";
235
241
  const Image = React__default.forwardRef(({ asChild, ...props }, forwardedRef) => {
236
- const classes = clsx([styles[`${rootClassName}__image`]], props.className);
237
- const context = React__default.useContext(RootContext);
242
+ const classes = clsx([styles$2[`${rootClassName$2}__image`]], props.className);
243
+ const context = React__default.useContext(RootContext$1);
238
244
  const Comp = asChild ? Slot : "img";
239
245
  return /* @__PURE__ */ jsx(Comp, { ...props, className: classes, ref: composeRefs(context.imageRef, forwardedRef) });
240
246
  });
241
247
  Image.displayName = "Dialog.Image";
242
248
  const Close = React__default.forwardRef(
243
249
  ({ className, ...props }, forwardedRef) => {
244
- const classes = clsx([styles[`${rootClassName}__close`]], {
245
- [styles[`${rootClassName}__close--floating`]]: props.slot === "floating",
250
+ const classes = clsx([styles$2[`${rootClassName$2}__close`]], {
251
+ [styles$2[`${rootClassName$2}__close--floating`]]: props.slot === "floating",
246
252
  className
247
253
  });
248
- const imageRef = React__default.useContext(RootContext).imageRef;
254
+ const imageRef = React__default.useContext(RootContext$1).imageRef;
249
255
  const [hasImage, setHasImage] = React__default.useState(false);
250
256
  useEffect(() => {
251
257
  if (imageRef == null ? void 0 : imageRef.current) {
@@ -256,13 +262,1089 @@ const Close = React__default.forwardRef(
256
262
  }
257
263
  );
258
264
  Close.displayName = "Dialog.Close";
259
- const Modal = Object.assign(Root, { Trigger, Content, Title, Overlay, Description, Close, Image, Group });
265
+ const Modal = Object.assign(Root$2, { Trigger: Trigger$1, Content: Content$1, Title, Overlay, Description, Close, Image, Group });
266
+ const scaleIn = "_scaleIn_11898_1";
267
+ const scaleOut = "_scaleOut_11898_1";
268
+ const enterFromRight = "_enterFromRight_11898_1";
269
+ const enterFromLeft = "_enterFromLeft_11898_1";
270
+ const exitToRight = "_exitToRight_11898_1";
271
+ const exitToLeft = "_exitToLeft_11898_1";
272
+ const styles$1 = {
273
+ "teddy-navigation-menu": "_teddy-navigation-menu_11898_1",
274
+ "teddy-navigation-menu__viewport": "_teddy-navigation-menu__viewport_11898_34",
275
+ "teddy-navigation-menu__separator": "_teddy-navigation-menu__separator_11898_37",
276
+ "teddy-navigation-menu__list": "_teddy-navigation-menu__list_11898_40",
277
+ "teddy-navigation-menu__top-menu-list": "_teddy-navigation-menu__top-menu-list_11898_66",
278
+ "teddy-navigation-menu__top-menu-trigger": "_teddy-navigation-menu__top-menu-trigger_11898_87",
279
+ "teddy-navigation-menu__top-menu-trigger--small": "_teddy-navigation-menu__top-menu-trigger--small_11898_106",
280
+ "teddy-navigation-menu__top-menu-trigger--button": "_teddy-navigation-menu__top-menu-trigger--button_11898_112",
281
+ "teddy-navigation-menu__content": "_teddy-navigation-menu__content_11898_187",
282
+ "teddy-navigation-menu__trigger": "_teddy-navigation-menu__trigger_11898_227",
283
+ "teddy-navigation-menu__trigger--small": "_teddy-navigation-menu__trigger--small_11898_247",
284
+ "teddy-navigation-menu__trigger--button": "_teddy-navigation-menu__trigger--button_11898_253",
285
+ "teddy-navigation-menu__link": "_teddy-navigation-menu__link_11898_321",
286
+ "teddy-navigation-menu__link--small": "_teddy-navigation-menu__link--small_11898_341",
287
+ "teddy-navigation-menu__link--button": "_teddy-navigation-menu__link--button_11898_347",
288
+ scaleIn,
289
+ scaleOut,
290
+ enterFromRight,
291
+ enterFromLeft,
292
+ exitToRight,
293
+ exitToLeft
294
+ };
295
+ const rootClassName$1 = "teddy-navigation-menu";
296
+ const NavigationMenuContext = React__default.createContext({
297
+ selectedTopMenu: void 0,
298
+ setSelectedTopMenu: () => {
299
+ },
300
+ contentRef: { current: null },
301
+ focusProxyRef: { current: null },
302
+ topMenuRef: { current: null },
303
+ id: "",
304
+ dir: "ltr",
305
+ orientation: "horizontal",
306
+ onEntryKeyDown: () => {
307
+ },
308
+ onFocusProxyEnter: () => {
309
+ },
310
+ onContentFocusOutside: () => {
311
+ }
312
+ });
313
+ const Root$1 = React__default.forwardRef(
314
+ ({ className, defaultTopMenuValue, topMenuValue, onTopMenuValueChange, ...props }, forwardRef) => {
315
+ const [selectedTopMenu, setSelectedTopMenu] = useControllableState({
316
+ defaultProp: defaultTopMenuValue,
317
+ prop: topMenuValue,
318
+ onChange: onTopMenuValueChange
319
+ });
320
+ const contentRef = React__default.useRef(null);
321
+ const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
322
+ const timerRef = React__default.useRef(void 0);
323
+ const restoreContentTabOrderRef = React__default.useRef(() => {
324
+ });
325
+ const focusProxyRef = React__default.useRef(null);
326
+ const topMenuRef = React__default.useRef(null);
327
+ const id = React__default.useId();
328
+ const handleContentEntry = React__default.useCallback((side = "start") => {
329
+ if (contentRef.current) {
330
+ restoreContentTabOrderRef.current();
331
+ const candidates = getTabbableCandidates(contentRef.current);
332
+ if (candidates.length)
333
+ focusFirst(side === "start" ? candidates : candidates.reverse());
334
+ }
335
+ }, []);
336
+ const handleContentExit = React__default.useCallback(() => {
337
+ if (contentRef.current) {
338
+ const candidates = getTabbableCandidates(contentRef.current);
339
+ if (candidates.length)
340
+ restoreContentTabOrderRef.current = removeFromTabOrder(candidates);
341
+ }
342
+ }, []);
343
+ React__default.useEffect(() => {
344
+ timerRef.current = setTimeout(() => {
345
+ setAllowAnimationOfHeight(true);
346
+ }, 500);
347
+ return () => {
348
+ timerRef.current && clearTimeout(timerRef.current);
349
+ };
350
+ }, []);
351
+ const classes = clsx([styles$1[`${rootClassName$1}`]], className);
352
+ return /* @__PURE__ */ jsx(
353
+ NavigationMenuContext.Provider,
354
+ {
355
+ value: {
356
+ contentRef,
357
+ focusProxyRef,
358
+ topMenuRef,
359
+ id,
360
+ dir: props.dir || "ltr",
361
+ orientation: props.orientation || "horizontal",
362
+ onEntryKeyDown: handleContentEntry,
363
+ onFocusProxyEnter: handleContentEntry,
364
+ onContentFocusOutside: handleContentExit,
365
+ selectedTopMenu,
366
+ setSelectedTopMenu
367
+ },
368
+ children: /* @__PURE__ */ jsx(
369
+ NavigationMenuPrimitive.Root,
370
+ {
371
+ ...props,
372
+ style: allowAnimationOfHeight ? mergeStyles(props.style, { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 }) : props.style,
373
+ ref: forwardRef,
374
+ className: classes
375
+ }
376
+ )
377
+ }
378
+ );
379
+ }
380
+ );
381
+ Root$1.displayName = "NavigationMenu";
382
+ const TopMenuList = React__default.forwardRef(
383
+ ({ className, ...props }, forwardRef) => {
384
+ const classes = clsx([styles$1[`${rootClassName$1}__top-menu-list`]], className);
385
+ const context = React__default.useContext(NavigationMenuContext);
386
+ const ref = useComposedRefs(context.topMenuRef, forwardRef);
387
+ return /* @__PURE__ */ jsx("ul", { ...props, ref, className: classes });
388
+ }
389
+ );
390
+ TopMenuList.displayName = "NavigationMenu.TopMenuList";
391
+ const TopMenuItem = React__default.forwardRef(
392
+ ({ className, ...props }, forwardRef) => {
393
+ const classes = clsx([styles$1[`${rootClassName$1}__top-menu-item`]], className);
394
+ return /* @__PURE__ */ jsx("li", { ...props, ref: forwardRef, className: classes });
395
+ }
396
+ );
397
+ const TopMenuTrigger = React__default.forwardRef(
398
+ ({ className, asChild, active, ...props }, forwardRef) => {
399
+ const classes = clsx(
400
+ [styles$1[`${rootClassName$1}__top-menu-trigger`], styles$1[`${rootClassName$1}__top-menu-trigger--small`]],
401
+ className
402
+ );
403
+ const Comp = asChild ? Slot : "button";
404
+ const context = React__default.useContext(NavigationMenuContext);
405
+ const innerRef = React__default.useRef(null);
406
+ const ref = useComposedRefs(innerRef, forwardRef);
407
+ const isOpen = context.selectedTopMenu === props.value;
408
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
409
+ /* @__PURE__ */ jsx(
410
+ Comp,
411
+ {
412
+ ...props,
413
+ ref,
414
+ className: classes,
415
+ "data-state": isOpen ? "open" : "closed",
416
+ "data-active": active ? "true" : void 0,
417
+ "aria-expanded": isOpen,
418
+ "aria-controls": makeContentId({ value: props.value, baseId: context.id }),
419
+ ...{ [ITEM_DATA_ATTR]: "" },
420
+ onClick: composeEventHandlers(props.onClick, () => {
421
+ context.setSelectedTopMenu(props.value);
422
+ }),
423
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
424
+ var _a;
425
+ const verticalEntryKey = context.dir === "rtl" ? "ArrowLeft" : "ArrowRight";
426
+ const entryKey = { horizontal: "ArrowDown", vertical: verticalEntryKey }[context.orientation];
427
+ if (isOpen && event.key === entryKey) {
428
+ context.onEntryKeyDown();
429
+ return event.preventDefault();
430
+ }
431
+ const isFocusNavigationKey = ["Home", "End", ...ARROW_KEYS].includes(event.key);
432
+ if (isFocusNavigationKey) {
433
+ const triggers = (_a = context.topMenuRef.current) == null ? void 0 : _a.querySelectorAll(`[${ITEM_DATA_ATTR}]`);
434
+ if (!triggers)
435
+ return;
436
+ let candidateNodes = Array.from(triggers == null ? void 0 : triggers.values());
437
+ const prevItemKey = context.dir === "rtl" ? "ArrowRight" : "ArrowLeft";
438
+ const prevKeys = [prevItemKey, "ArrowUp", "End"];
439
+ if (prevKeys.includes(event.key))
440
+ candidateNodes.reverse();
441
+ if (ARROW_KEYS.includes(event.key)) {
442
+ const currentIndex = candidateNodes.indexOf(event.currentTarget);
443
+ candidateNodes = candidateNodes.slice(currentIndex + 1);
444
+ focusFirst(candidateNodes);
445
+ event.preventDefault();
446
+ }
447
+ }
448
+ })
449
+ }
450
+ ),
451
+ isOpen && /* @__PURE__ */ jsx(
452
+ VisuallyHidden,
453
+ {
454
+ "aria-hidden": true,
455
+ tabIndex: 0,
456
+ ref: context.focusProxyRef,
457
+ onFocus: (event) => {
458
+ const content = context.contentRef.current;
459
+ const prevFocusedElement = event.relatedTarget;
460
+ const wasTriggerFocused = prevFocusedElement === innerRef.current;
461
+ const wasFocusFromContent = content == null ? void 0 : content.contains(prevFocusedElement);
462
+ if (wasTriggerFocused || !wasFocusFromContent) {
463
+ context.onFocusProxyEnter(wasTriggerFocused ? "start" : "end");
464
+ }
465
+ }
466
+ }
467
+ )
468
+ ] });
469
+ }
470
+ );
471
+ const List = React__default.forwardRef(
472
+ ({ className, variant, value, ...props }, forwardRef) => {
473
+ const classes = clsx([styles$1[`${rootClassName$1}__list`]], [styles$1[`${rootClassName$1}__list--${variant}`]], className);
474
+ const context = React__default.useContext(NavigationMenuContext);
475
+ const refOnOpen = useComposedRefs(context.contentRef, forwardRef);
476
+ const hasTopMenu = context.selectedTopMenu !== void 0;
477
+ const isOpen = context.selectedTopMenu === value;
478
+ if (!isOpen)
479
+ return null;
480
+ return /* @__PURE__ */ jsx(
481
+ NavigationMenuPrimitive.List,
482
+ {
483
+ ref: hasTopMenu ? refOnOpen : forwardRef,
484
+ id: value && makeContentId({ value, baseId: context.id }),
485
+ ...props,
486
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
487
+ var _a;
488
+ if (!value)
489
+ return;
490
+ const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
491
+ const isTabKey = event.key === "Tab" && !isMetaKey;
492
+ if (isTabKey) {
493
+ const candidates = getTabbableCandidates(event.currentTarget);
494
+ const focusedElement = document.activeElement;
495
+ const index = candidates.findIndex((candidate) => candidate === focusedElement);
496
+ const isMovingBackwards = event.shiftKey;
497
+ const nextCandidates = isMovingBackwards ? candidates.slice(0, index).reverse() : candidates.slice(index + 1, candidates.length);
498
+ if (focusFirst(nextCandidates)) {
499
+ event.preventDefault();
500
+ } else {
501
+ (_a = context.focusProxyRef.current) == null ? void 0 : _a.focus();
502
+ context.onContentFocusOutside();
503
+ }
504
+ }
505
+ }),
506
+ className: classes
507
+ }
508
+ );
509
+ }
510
+ );
511
+ List.displayName = "NavigationMenu.List";
512
+ const Separator = React__default.forwardRef(({ className, ...props }, forwardRef) => {
513
+ const classes = clsx(
514
+ [styles$1[`${rootClassName$1}__separator`]],
515
+ className
516
+ );
517
+ return /* @__PURE__ */ jsx(Box, { width: "100%", p: "0", m: "0", ...props, ref: forwardRef, className: classes, asChild: true, children: /* @__PURE__ */ jsx("hr", {}) });
518
+ });
519
+ Separator.displayName = "NavigationMenu.Separator";
520
+ const Item = React__default.forwardRef(
521
+ ({ className, ...props }, forwardRef) => {
522
+ const classes = clsx([styles$1[`${rootClassName$1}__item`]], className);
523
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Item, { ...props, ref: forwardRef, className: classes });
524
+ }
525
+ );
526
+ Item.displayName = "NavigationMenu.Item";
527
+ const Trigger = React__default.forwardRef(
528
+ ({ className, active, variant = "default", ...props }, forwardRef) => {
529
+ const classes = clsx(
530
+ [styles$1[`${rootClassName$1}__trigger`]],
531
+ [styles$1[`${rootClassName$1}__trigger--${variant}`]],
532
+ className
533
+ );
534
+ const innerRef = React__default.useRef(null);
535
+ const ref = useComposedRefs(forwardRef, innerRef);
536
+ return /* @__PURE__ */ jsx(
537
+ NavigationMenuPrimitive.Trigger,
538
+ {
539
+ onPointerEnter: (e) => e.preventDefault(),
540
+ onPointerMove: (e) => e.preventDefault(),
541
+ onPointerLeave: (e) => e.preventDefault(),
542
+ ...props,
543
+ ref,
544
+ "data-active": active ? "true" : void 0,
545
+ className: classes,
546
+ "data-text": getLabelFromChildren(props.children)
547
+ }
548
+ );
549
+ }
550
+ );
551
+ Trigger.displayName = "NavigationMenu.Trigger";
552
+ const Content = React__default.forwardRef(
553
+ ({ className, variant = "default", ...props }, forwardRef) => {
554
+ const classes = clsx(
555
+ [styles$1[`${rootClassName$1}__content`]],
556
+ [styles$1[`${rootClassName$1}__content--${variant}`]],
557
+ className
558
+ );
559
+ return /* @__PURE__ */ jsx(
560
+ NavigationMenuPrimitive.Content,
561
+ {
562
+ onPointerEnter: (e) => e.preventDefault(),
563
+ onPointerLeave: (e) => e.preventDefault(),
564
+ ...props,
565
+ ref: forwardRef,
566
+ className: classes
567
+ }
568
+ );
569
+ }
570
+ );
571
+ const Link = React__default.forwardRef(
572
+ ({ className, variant = "default", ...props }, forwardRef) => {
573
+ const classes = clsx([styles$1[`${rootClassName$1}__link`]], [styles$1[`${rootClassName$1}__link--${variant}`]], className);
574
+ return /* @__PURE__ */ jsx(
575
+ NavigationMenuPrimitive.Link,
576
+ {
577
+ ...props,
578
+ ref: forwardRef,
579
+ className: classes,
580
+ "data-text": getLabelFromChildren(props.children)
581
+ }
582
+ );
583
+ }
584
+ );
585
+ Link.displayName = "NavigationMenu.Link";
586
+ const Indicator = React__default.forwardRef(
587
+ ({ className, ...props }, forwardRef) => {
588
+ const classes = clsx([styles$1[`${rootClassName$1}__indicator`]], className);
589
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Indicator, { ...props, ref: forwardRef, className: classes });
590
+ }
591
+ );
592
+ Indicator.displayName = "NavigationMenu.Indicator";
593
+ const Viewport = React__default.forwardRef(
594
+ ({ className, ...props }, forwardRef) => {
595
+ const classes = clsx([styles$1[`${rootClassName$1}__viewport`]], className);
596
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Viewport, { ...props, ref: forwardRef, className: classes });
597
+ }
598
+ );
599
+ Viewport.displayName = "NavigationMenu.Viewport";
600
+ const Sub = React__default.forwardRef(
601
+ ({ className, ...props }, forwardRef) => {
602
+ const classes = clsx([styles$1[`${rootClassName$1}__sub`]], className);
603
+ return /* @__PURE__ */ jsx(NavigationMenuPrimitive.Sub, { ...props, ref: forwardRef, className: classes });
604
+ }
605
+ );
606
+ Sub.displayName = "NavigationMenu.Sub";
607
+ function getLabelFromChildren(children) {
608
+ function findLabel(node) {
609
+ if (typeof node === "string") {
610
+ return node;
611
+ }
612
+ if (React__default.isValidElement(node) && node.props.children) {
613
+ return findLabel(node.props.children);
614
+ }
615
+ if (Array.isArray(node)) {
616
+ for (let i = node.length - 1; i >= 0; i--) {
617
+ const label = findLabel(node[i]);
618
+ if (label) {
619
+ return label;
620
+ }
621
+ }
622
+ }
623
+ return void 0;
624
+ }
625
+ return findLabel(children);
626
+ }
627
+ function getTabbableCandidates(container) {
628
+ const nodes = [];
629
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
630
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
631
+ acceptNode: (node) => {
632
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
633
+ if (node.disabled || node.hidden || isHiddenInput)
634
+ return NodeFilter.FILTER_SKIP;
635
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
636
+ }
637
+ });
638
+ while (walker.nextNode())
639
+ nodes.push(walker.currentNode);
640
+ return nodes;
641
+ }
642
+ function focusFirst(candidates) {
643
+ const previouslyFocusedElement = document.activeElement;
644
+ return candidates.some((candidate) => {
645
+ if (candidate === previouslyFocusedElement)
646
+ return true;
647
+ candidate.focus();
648
+ return document.activeElement !== previouslyFocusedElement;
649
+ });
650
+ }
651
+ function removeFromTabOrder(candidates) {
652
+ candidates.forEach((candidate) => {
653
+ candidate.dataset.tabindex = candidate.getAttribute("tabindex") || "";
654
+ candidate.setAttribute("tabindex", "-1");
655
+ });
656
+ return () => {
657
+ candidates.forEach((candidate) => {
658
+ const prevTabIndex = candidate.dataset.tabindex;
659
+ candidate.setAttribute("tabindex", prevTabIndex);
660
+ });
661
+ };
662
+ }
663
+ const ITEM_DATA_ATTR = "data-teddy-top-selector-trigger";
664
+ const ARROW_KEYS = ["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"];
665
+ function makeContentId(args) {
666
+ return `teddy-navigation-menu-${args.baseId}-${args.value}-content`;
667
+ }
668
+ const NavigationMenu = Object.assign(Root$1, {
669
+ List,
670
+ Separator,
671
+ Item,
672
+ Trigger,
673
+ Content,
674
+ Link,
675
+ Indicator,
676
+ Viewport,
677
+ Sub,
678
+ TopMenuList,
679
+ TopMenuItem,
680
+ TopMenuTrigger
681
+ });
682
+ const styles = {
683
+ "teddy-global-navigation": "_teddy-global-navigation_2fdb8_1",
684
+ "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_2fdb8_6",
685
+ "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_2fdb8_9",
686
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_2fdb8_6",
687
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_2fdb8_26",
688
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_2fdb8_29",
689
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_2fdb8_32",
690
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_2fdb8_36",
691
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_2fdb8_43",
692
+ "close-viewport": "_close-viewport_2fdb8_1",
693
+ "teddy-global-navigation__top-menu-color": "_teddy-global-navigation__top-menu-color_2fdb8_54",
694
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_2fdb8_57",
695
+ "teddy-global-navigation__accordion-look": "_teddy-global-navigation__accordion-look_2fdb8_74",
696
+ "teddy-global-navigation__mobile-link--accordion-look": "_teddy-global-navigation__mobile-link--accordion-look_2fdb8_90"
697
+ };
698
+ function MyPages(props) {
699
+ var _a, _b;
700
+ const rootContext = React__default.useContext(RootContext);
701
+ const isLoggedIn = (((_a = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _a.name.length) || 0) > 0;
702
+ return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
703
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: ((_b = rootContext == null ? void 0 : rootContext.loggedInUser) == null ? void 0 : _b.name.length) ? /* @__PURE__ */ jsxs("button", { "data-di-mask": true, children: [
704
+ /* @__PURE__ */ jsx(Icon, { name: "end-user", size: "sm" }),
705
+ rootContext.loggedInUser.name
706
+ ] }) : /* @__PURE__ */ jsxs("button", { children: [
707
+ /* @__PURE__ */ jsx(Icon, { name: "login", size: "sm" }),
708
+ "Logg inn"
709
+ ] }) }) }),
710
+ /* @__PURE__ */ jsxs(Drawer.Content, { asChild: true, size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
711
+ /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
712
+ isLoggedIn ? /* @__PURE__ */ jsx(LoggedInContent, {}) : /* @__PURE__ */ jsx(LoggedOutContent, {}),
713
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
714
+ ] })
715
+ ] });
716
+ }
717
+ function LoggedOutContent() {
718
+ return /* @__PURE__ */ jsxs(Grid, { gap: "400", children: [
719
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Logg inn" }),
720
+ /* @__PURE__ */ jsxs(TextSpacing, { children: [
721
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Privat" }),
722
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: MY_PAGE_LINKS.link, children: [
723
+ MY_PAGE_LINKS.name,
724
+ " ",
725
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
726
+ ] }) })
727
+ ] }),
728
+ /* @__PURE__ */ jsxs(TextSpacing, { children: [
729
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", children: "Bedrift" }),
730
+ /* @__PURE__ */ jsx(Grid, { gap: "150", children: LOGGED_IN_LINKS_BUSINESS.map((link) => /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsxs("a", { href: link.link, children: [
731
+ link.name,
732
+ " ",
733
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
734
+ ] }) })) })
735
+ ] })
736
+ ] });
737
+ }
738
+ function LoggedInContent() {
739
+ var _a;
740
+ const rootContext = React__default.useContext(RootContext);
741
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
742
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Dine sider" }),
743
+ /* @__PURE__ */ jsxs(Tabs, { defaultValue: "private", children: [
744
+ /* @__PURE__ */ jsxs(Tabs.List, { children: [
745
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "private", children: "Privat" }),
746
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "business", children: "Bedrift" })
747
+ ] }),
748
+ /* @__PURE__ */ jsxs(TextSpacing, { children: [
749
+ /* @__PURE__ */ jsxs(Tabs.Content, { value: "private", children: [
750
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Min Side" }),
751
+ (_a = MY_PAGE_LINKS.links) == null ? void 0 : _a.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link))
752
+ ] }),
753
+ /* @__PURE__ */ jsxs(Tabs.Content, { value: "business", children: [
754
+ /* @__PURE__ */ jsx(Heading, { variant: "title-100", as: "h3", mb: "100", mt: "400", children: "Bedriftsportaler" }),
755
+ LOGGED_IN_LINKS_BUSINESS.map((link) => /* @__PURE__ */ jsx(Button, { variant: "list-item", fullWidth: true, asChild: true, children: /* @__PURE__ */ jsx("a", { href: link.link, children: /* @__PURE__ */ jsx(Icon, { name: link.icon, children: link.name }) }) }, link.link))
756
+ ] }),
757
+ /* @__PURE__ */ jsx(Button, { mt: "200", onClick: () => rootContext == null ? void 0 : rootContext.onLogoutClick(), variant: "secondary", children: /* @__PURE__ */ jsx(Icon, { name: "logout", children: "Logg ut" }) })
758
+ ] })
759
+ ] })
760
+ ] });
761
+ }
762
+ MyPages.displayName = "MyPages";
763
+ const SearchField = React__default.forwardRef(
764
+ (props, forwardRef) => {
765
+ const ref = React__default.useRef(null);
766
+ const context = React__default.useContext(RootContext);
767
+ const composedRef = useComposedRefs(forwardRef, ref);
768
+ return /* @__PURE__ */ jsx(
769
+ "form",
770
+ {
771
+ onSubmit: (e) => {
772
+ var _a, _b;
773
+ console.log("Search submitted,111");
774
+ if (context == null ? void 0 : context.onSearchSubmit) {
775
+ context.onSearchSubmit(e, (_a = ref.current) == null ? void 0 : _a.value);
776
+ }
777
+ if (!window || e.isDefaultPrevented())
778
+ return;
779
+ e.preventDefault();
780
+ window.location.href = `/sok?q=${encodeURIComponent(((_b = ref.current) == null ? void 0 : _b.value) || "")}`;
781
+ },
782
+ children: /* @__PURE__ */ jsxs(TextField, { ...props, children: [
783
+ /* @__PURE__ */ jsx(TextField.Label, { children: "Søk i innhold" }),
784
+ /* @__PURE__ */ jsxs(TextField.InputGroup, { children: [
785
+ /* @__PURE__ */ jsx(Icon, { name: "search" }),
786
+ /* @__PURE__ */ jsx(TextField.Input, { ref: composedRef, placeholder: "Søk her" }),
787
+ /* @__PURE__ */ jsx(TextField.ClearButton, {})
788
+ ] }),
789
+ /* @__PURE__ */ jsx(TextField.Button, { variant: "separated", children: "Søk" })
790
+ ] })
791
+ }
792
+ );
793
+ }
794
+ );
795
+ SearchField.displayName = "SearchField";
796
+ function Search(props) {
797
+ const rootContext = React__default.useContext(RootContext);
798
+ const searchFieldRef = React__default.useRef(null);
799
+ return /* @__PURE__ */ jsxs(Drawer, { ...props, children: [
800
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
801
+ /* @__PURE__ */ jsx(Icon, { name: "search", size: "sm" }),
802
+ " Søk"
803
+ ] }) }) }),
804
+ /* @__PURE__ */ jsxs(
805
+ Drawer.Content,
806
+ {
807
+ size: rootContext == null ? void 0 : rootContext.drawerSize,
808
+ onOpenAutoFocus: (e) => {
809
+ var _a;
810
+ e.preventDefault();
811
+ (_a = searchFieldRef.current) == null ? void 0 : _a.focus();
812
+ },
813
+ children: [
814
+ /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
815
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Hva leter du etter?" }),
816
+ /* @__PURE__ */ jsx(SearchField, { ref: searchFieldRef }),
817
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
818
+ ]
819
+ }
820
+ )
821
+ ] });
822
+ }
823
+ Search.displayName = "Search";
824
+ const ShoppingCart = React__default.forwardRef(() => {
825
+ const rootContext = React__default.useContext(RootContext);
826
+ const shoppingCartContent = rootContext == null ? void 0 : rootContext.shoppingCart;
827
+ const numberOfItemsInCart = (rootContext == null ? void 0 : rootContext.shoppingCartNumberOfItems) || 0;
828
+ const titleSuffix = numberOfItemsInCart > 0 ? `(${numberOfItemsInCart})` : "";
829
+ if (!numberOfItemsInCart)
830
+ return null;
831
+ return /* @__PURE__ */ jsxs(Drawer, { open: rootContext == null ? void 0 : rootContext.isCartOpen, onOpenChange: rootContext == null ? void 0 : rootContext.onCartOpenChange, children: [
832
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
833
+ /* @__PURE__ */ jsxs("div", { className: clsx([styles[`${rootClassName}__item-wrapper`]]), children: [
834
+ /* @__PURE__ */ jsx(Icon, { name: "cart", size: "sm" }),
835
+ numberOfItemsInCart > 0 && /* @__PURE__ */ jsx("span", { className: clsx([styles[`${rootClassName}__item-count`]]), children: /* @__PURE__ */ jsx(CounterBadge, { variant: "attention", children: numberOfItemsInCart }) })
836
+ ] }),
837
+ "Handlekurv"
838
+ ] }) }) }),
839
+ /* @__PURE__ */ jsxs(Drawer.Content, { size: rootContext == null ? void 0 : rootContext.drawerSize, children: [
840
+ /* @__PURE__ */ jsx(Drawer.Close, { slot: "floating", "aria-label": "Lukk" }),
841
+ /* @__PURE__ */ jsxs(Drawer.Title, { children: [
842
+ "Handlekurv ",
843
+ titleSuffix
844
+ ] }),
845
+ shoppingCartContent ? shoppingCartContent : null,
846
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
847
+ ] })
848
+ ] });
849
+ });
850
+ ShoppingCart.displayName = "ShoppingCart";
851
+ const scrollDistanceDownThreshold = 200;
852
+ const scrollDistanceUpThreshold = 50;
853
+ const ANIMATION_DURATION = 300;
854
+ const Desktop = React__default.forwardRef(() => {
855
+ const rootContext = React__default.useContext(RootContext);
856
+ const [hideMenu, setHideMenu] = React__default.useState(null);
857
+ const lastScrollDirection = React__default.useRef();
858
+ const scrollStartPos = React__default.useRef(0);
859
+ const lastScrollPos = React__default.useRef(0);
860
+ const topMenuRef = React__default.useRef(null);
861
+ const viewPortRef = React__default.useRef(null);
862
+ const shouldShowViewport = [...PRIVATE_LINKS.links, ...BUSINESS_LINKS.links, ...MDU_LINKS.links].some(
863
+ (link) => !!getActiveSubLink((rootContext == null ? void 0 : rootContext.pathname) || "", link.links) || link.links.length && link.link === (rootContext == null ? void 0 : rootContext.pathname)
864
+ );
865
+ const viewPortSize = useSize(viewPortRef.current);
866
+ const topMenuSize = useSize(topMenuRef.current);
867
+ const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
868
+ const viewPortHeight = shouldShowViewport ? "47px" : void 0;
869
+ const animationTimer = React__default.useRef(0);
870
+ const [allowAnimationOfHeight, setAllowAnimationOfHeight] = React__default.useState(false);
871
+ const timerRef = React__default.useRef(void 0);
872
+ React__default.useEffect(() => {
873
+ timerRef.current = setTimeout(() => {
874
+ setAllowAnimationOfHeight(true);
875
+ }, 500);
876
+ return () => {
877
+ timerRef.current && clearTimeout(timerRef.current);
878
+ };
879
+ }, []);
880
+ const handleScroll = () => {
881
+ let compensateHight = 0;
882
+ if (animationTimer.current > 0) {
883
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
884
+ if (animationTimer.current + ANIMATION_DURATION > currentTime) {
885
+ compensateHight = ((topMenuSize == null ? void 0 : topMenuSize.height) || 0) + ((viewPortSize == null ? void 0 : viewPortSize.height) || 0);
886
+ } else {
887
+ animationTimer.current = 0;
888
+ }
889
+ }
890
+ const scrollY = window.scrollY;
891
+ const scrollDirection = scrollY > lastScrollPos.current ? "down" : "up";
892
+ const scrollDistance = Math.abs(scrollStartPos.current - scrollY);
893
+ if (scrollDirection !== lastScrollDirection.current) {
894
+ scrollStartPos.current = scrollY;
895
+ }
896
+ if (!hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "down" && scrollDistance > scrollDistanceDownThreshold + compensateHight) {
897
+ setHideMenu(true);
898
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
899
+ animationTimer.current = currentTime;
900
+ }
901
+ if (hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "up" && scrollDistance > scrollDistanceUpThreshold + compensateHight || scrollY === 0) {
902
+ setHideMenu(false);
903
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
904
+ animationTimer.current = currentTime;
905
+ }
906
+ lastScrollDirection.current = scrollDirection;
907
+ lastScrollPos.current = scrollY;
908
+ };
909
+ const throttledScrollHandler = useDebounceCallback(handleScroll, 5);
910
+ React__default.useEffect(() => {
911
+ window.addEventListener("scroll", throttledScrollHandler);
912
+ return () => {
913
+ window.removeEventListener("scroll", throttledScrollHandler);
914
+ };
915
+ }, [throttledScrollHandler]);
916
+ if (!rootContext)
917
+ return null;
918
+ function resetAndShowMenu() {
919
+ lastScrollDirection.current = null;
920
+ scrollStartPos.current = window.scrollY;
921
+ lastScrollPos.current = window.scrollY;
922
+ setHideMenu(false);
923
+ }
924
+ const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
925
+ const currentLocation = rootContext.pathname.endsWith("/") ? rootContext.pathname : `${rootContext.pathname}/`;
926
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
927
+ /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__top-menu-color`], children: /* @__PURE__ */ jsx(
928
+ "div",
929
+ {
930
+ style: mergeStyles(
931
+ { ["--teddy-top-menu-height"]: topMenuHeight },
932
+ allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
933
+ ),
934
+ className: styles[`${rootClassName}__top-menu-wrapper`],
935
+ "data-state": hideMenu ? "closed" : "open",
936
+ children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(
937
+ NavigationMenu.TopMenuTrigger,
938
+ {
939
+ value: link.name,
940
+ asChild: true,
941
+ onClick: () => rootContext.setPathname(link.link),
942
+ children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name })
943
+ }
944
+ ) }, link.name)) })
945
+ }
946
+ ) }),
947
+ LINKS.map((link) => {
948
+ var _a;
949
+ return /* @__PURE__ */ jsxs(NavigationMenu.List, { onFocus: resetAndShowMenu, value: link.name, children: [
950
+ (_a = link.links) == null ? void 0 : _a.map((subLink) => {
951
+ var _a2, _b;
952
+ return /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
953
+ subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
954
+ "img",
955
+ {
956
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
957
+ draggable: "false",
958
+ alt: "Telia logo"
959
+ }
960
+ ) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
961
+ "img",
962
+ {
963
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
964
+ draggable: "false",
965
+ alt: "Telia logo"
966
+ }
967
+ ) }) }) : ((_a2 = subLink.links) == null ? void 0 : _a2.length) ? /* @__PURE__ */ jsx(
968
+ NavigationMenu.Trigger,
969
+ {
970
+ asChild: true,
971
+ active: currentLocation === subLink.link,
972
+ onClick: () => {
973
+ rootContext.setPathname(subLink.link);
974
+ },
975
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name })
976
+ }
977
+ ) : /* @__PURE__ */ jsx(
978
+ NavigationMenu.Link,
979
+ {
980
+ asChild: true,
981
+ active: currentLocation === subLink.link,
982
+ onClick: () => {
983
+ rootContext.setPathname(subLink.link);
984
+ },
985
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name })
986
+ }
987
+ ),
988
+ /* @__PURE__ */ jsx(NavigationMenu.Content, { children: /* @__PURE__ */ jsx("ul", { children: (_b = subLink.links) == null ? void 0 : _b.map((subSubLink) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
989
+ NavigationMenu.Link,
990
+ {
991
+ asChild: true,
992
+ active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
993
+ onClick: () => {
994
+ rootContext.setPathname(subSubLink.link);
995
+ },
996
+ variant: "small",
997
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subSubLink.link, children: subSubLink.name }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: subSubLink.name })
998
+ }
999
+ ) }, subSubLink.name)) }) })
1000
+ ] }, subLink.name);
1001
+ }),
1002
+ /* @__PURE__ */ jsx(Box, { ml: "auto" }),
1003
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
1004
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(Search, {}) }),
1005
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
1006
+ ] }, link.name);
1007
+ }),
1008
+ /* @__PURE__ */ jsx(NavigationMenu.Separator, {}),
1009
+ /* @__PURE__ */ jsx(
1010
+ "div",
1011
+ {
1012
+ style: mergeStyles(
1013
+ { ["--teddy-viewport-wrapper-height"]: viewPortHeight },
1014
+ allowAnimationOfHeight ? { ["--teddy-motion-duration-controlled"]: teddyMotionDuration300 } : {}
1015
+ ),
1016
+ className: styles[`${rootClassName}__viewport-wrapper`],
1017
+ "data-state": hideMenu === null ? "" : hideMenu ? "closed" : "open",
1018
+ children: /* @__PURE__ */ jsx(
1019
+ NavigationMenu.Viewport,
1020
+ {
1021
+ onFocus: resetAndShowMenu,
1022
+ ref: viewPortRef,
1023
+ className: styles[`${rootClassName}__viewport`]
1024
+ }
1025
+ )
1026
+ }
1027
+ )
1028
+ ] });
1029
+ });
1030
+ Desktop.displayName = "Desktop";
1031
+ function useDebounceCallback(callback, delay) {
1032
+ const handleCallback = useCallbackRef(callback);
1033
+ const debounceTimerRef = React__default.useRef(0);
1034
+ React__default.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
1035
+ return React__default.useCallback(() => {
1036
+ window.clearTimeout(debounceTimerRef.current);
1037
+ debounceTimerRef.current = window.setTimeout(handleCallback, delay);
1038
+ }, [handleCallback, delay]);
1039
+ }
1040
+ function Mobile(props) {
1041
+ const rootContext = React__default.useContext(RootContext);
1042
+ const drawerRef = React__default.useRef(null);
1043
+ if (!rootContext)
1044
+ return null;
1045
+ const { linkComponent: NavLink } = rootContext;
1046
+ const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
1047
+ const linkClasses = clsx([styles[`${rootClassName}__link`]]);
1048
+ const currentLocation = rootContext.pathname;
1049
+ return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
1050
+ /* @__PURE__ */ jsx(Box, { flexShrink: "0", children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: rootContext.appKey === "open-pages" ? /* @__PURE__ */ jsx(NavLink, { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) : /* @__PURE__ */ jsx("a", { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) }) }),
1051
+ /* @__PURE__ */ jsxs(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: [
1052
+ /* @__PURE__ */ jsx(ShoppingCart, {}),
1053
+ /* @__PURE__ */ jsx(MyPages, {}),
1054
+ /* @__PURE__ */ jsxs(Drawer, { children: [
1055
+ /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: /* @__PURE__ */ jsx(Drawer.Trigger, { children: /* @__PURE__ */ jsxs("button", { children: [
1056
+ /* @__PURE__ */ jsx(Icon, { name: "menu", size: "sm" }),
1057
+ " Meny"
1058
+ ] }) }) }),
1059
+ /* @__PURE__ */ jsxs(Drawer.Content, { gap: "400", size: rootContext.drawerSize, children: [
1060
+ /* @__PURE__ */ jsx(Drawer.Close, { ref: drawerRef, slot: "floating", "aria-label": "Lukk" }),
1061
+ /* @__PURE__ */ jsx(Drawer.Title, { children: "Meny" }),
1062
+ /* @__PURE__ */ jsx(SearchField, {}),
1063
+ /* @__PURE__ */ jsxs(
1064
+ Tabs,
1065
+ {
1066
+ value: rootContext.selectedDomainItem,
1067
+ onValueChange: (v) => rootContext.setSelectedDomainItem(v, true),
1068
+ children: [
1069
+ /* @__PURE__ */ jsx(Tabs.List, { children: LINKS.map((link) => /* @__PURE__ */ jsx(Tabs.Trigger, { asChild: true, value: link.name, children: link.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: link.link, children: link.name }) : /* @__PURE__ */ jsx("a", { href: link.link, children: link.name }) }, link.name)) }),
1070
+ /* @__PURE__ */ jsx(Box, { mt: "400", children: LINKS.map((link) => {
1071
+ var _a;
1072
+ return /* @__PURE__ */ jsx(Tabs.Content, { value: link.name, children: /* @__PURE__ */ jsx(
1073
+ Accordion,
1074
+ {
1075
+ type: "single",
1076
+ collapsible: true,
1077
+ value: rootContext.selectedMenuItem,
1078
+ onValueChange: (v) => rootContext.setSelectedMenuItem(v, true),
1079
+ children: (_a = link.links) == null ? void 0 : _a.filter((l) => l.name !== "Logo").map(
1080
+ (subLink) => {
1081
+ var _a2;
1082
+ return subLink.links.length > 0 ? /* @__PURE__ */ jsxs(Accordion.Item, { value: subLink.name, children: [
1083
+ /* @__PURE__ */ jsxs(Accordion.Header, { className: styles[`${rootClassName}__mobile-header`], children: [
1084
+ /* @__PURE__ */ jsx(
1085
+ Link$1,
1086
+ {
1087
+ className: linkClasses,
1088
+ variant: "standalone",
1089
+ asChild: true,
1090
+ onClick: () => {
1091
+ var _a3;
1092
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
1093
+ rootContext.setSelectedMenuItem(subLink.name);
1094
+ rootContext.setPathname(subLink.link);
1095
+ },
1096
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subLink.link, children: subLink.name }) : /* @__PURE__ */ jsx("a", { href: subLink.link, children: subLink.name })
1097
+ }
1098
+ ),
1099
+ /* @__PURE__ */ jsx(Accordion.Trigger, { className: styles[`${rootClassName}__mobile-trigger`], children: /* @__PURE__ */ jsxs(VisuallyHidden, { children: [
1100
+ subLink.name,
1101
+ " linker"
1102
+ ] }) })
1103
+ ] }),
1104
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(List$1, { gap: "10", pl: "25", children: (_a2 = subLink.links) == null ? void 0 : _a2.map((subSubLink) => /* @__PURE__ */ jsx(List$1.Item, { children: /* @__PURE__ */ jsx(
1105
+ NavigationMenu.Link,
1106
+ {
1107
+ asChild: true,
1108
+ variant: "small",
1109
+ active: getActiveSubLink(currentLocation, subLink.links || []) === subSubLink.link,
1110
+ onClick: () => {
1111
+ var _a3;
1112
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
1113
+ rootContext.setPathname(subSubLink.link);
1114
+ },
1115
+ children: subSubLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(NavLink, { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", children: [
1116
+ subSubLink.name,
1117
+ " ",
1118
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1119
+ ] }) }) : /* @__PURE__ */ jsx("a", { href: subSubLink.link, children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: "100", children: [
1120
+ subSubLink.name,
1121
+ " ",
1122
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1123
+ ] }) })
1124
+ }
1125
+ ) }, subSubLink.name)) }) })
1126
+ ] }, subLink.name) : /* @__PURE__ */ jsx("div", { className: styles[`${rootClassName}__accordion-look`], children: /* @__PURE__ */ jsx(
1127
+ Link$1,
1128
+ {
1129
+ className: clsx([
1130
+ linkClasses,
1131
+ styles[`${rootClassName}__mobile-link--accordion-look`]
1132
+ ]),
1133
+ variant: "standalone",
1134
+ asChild: true,
1135
+ onClick: () => {
1136
+ var _a3;
1137
+ (_a3 = drawerRef.current) == null ? void 0 : _a3.click();
1138
+ rootContext.setSelectedMenuItem(subLink.name);
1139
+ rootContext.setPathname(subLink.link);
1140
+ },
1141
+ children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxs(NavLink, { href: subLink.link, children: [
1142
+ subLink.name,
1143
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1144
+ ] }) : /* @__PURE__ */ jsxs("a", { href: subLink.link, children: [
1145
+ subLink.name,
1146
+ " ",
1147
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-right" })
1148
+ ] })
1149
+ }
1150
+ ) }, subLink.name);
1151
+ }
1152
+ )
1153
+ }
1154
+ ) }, link.name);
1155
+ }) })
1156
+ ]
1157
+ }
1158
+ ),
1159
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsx(Drawer.Close, { slot: "content", children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: "Lukk" }) }) })
1160
+ ] })
1161
+ ] })
1162
+ ] })
1163
+ ] }) });
1164
+ }
1165
+ Mobile.displayName = "Mobile";
1166
+ const DesktopSimplified = React__default.forwardRef(() => {
1167
+ const rootContext = React__default.useContext(RootContext);
1168
+ if (!rootContext)
1169
+ return null;
1170
+ const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
1171
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1172
+ LINKS.map((link) => {
1173
+ var _a;
1174
+ return /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
1175
+ (_a = link.links) == null ? void 0 : _a.map((subLink) => /* @__PURE__ */ jsx(NavigationMenu.Item, { value: subLink.name, children: subLink.name === "Logo" && /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
1176
+ "img",
1177
+ {
1178
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
1179
+ draggable: "false",
1180
+ alt: "Telia logo"
1181
+ }
1182
+ ) }) : /* @__PURE__ */ jsx("a", { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
1183
+ "img",
1184
+ {
1185
+ src: "https://cdn.voca.teliacompany.com/logo/Telia-primary-default-v2.svg",
1186
+ draggable: "false",
1187
+ alt: "Telia logo"
1188
+ }
1189
+ ) }) }) }, subLink.name)),
1190
+ /* @__PURE__ */ jsx(Box, { ml: "auto" }),
1191
+ /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) })
1192
+ ] }, link.name);
1193
+ }),
1194
+ /* @__PURE__ */ jsx(NavigationMenu.Viewport, { className: styles[`${rootClassName}__viewport`] })
1195
+ ] });
1196
+ });
1197
+ DesktopSimplified.displayName = "DesktopSimplified";
1198
+ function MobileSimplified(props) {
1199
+ const rootContext = React__default.useContext(RootContext);
1200
+ if (!rootContext)
1201
+ return null;
1202
+ const { linkComponent: NavLink } = rootContext;
1203
+ const classes = clsx([styles[`${rootClassName}__mobile`]], props.className);
1204
+ return /* @__PURE__ */ jsx(Flex, { ...props, className: classes, children: /* @__PURE__ */ jsxs(Flex, { flexGrow: "1", justify: "between", align: "center", gap: "200", children: [
1205
+ /* @__PURE__ */ jsx(Box, { flexShrink: "0", children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: rootContext.appKey === "open-pages" ? /* @__PURE__ */ jsx(NavLink, { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) : /* @__PURE__ */ jsx("a", { href: "/", children: /* @__PURE__ */ jsx(Icon, { size: "lg", name: "telia-logo", "aria-label": "Telia logo" }) }) }) }),
1206
+ /* @__PURE__ */ jsx(Flex, { flexBasis: "0", gap: { sm: "100", md: "200" }, children: /* @__PURE__ */ jsx(ShoppingCart, {}) })
1207
+ ] }) });
1208
+ }
1209
+ MobileSimplified.displayName = "MobileSimplified";
1210
+ const rootClassName = "teddy-global-navigation";
1211
+ const RootContext = React__default.createContext(null);
1212
+ function Root({
1213
+ className,
1214
+ appKey,
1215
+ loggedInUser,
1216
+ linkComponent,
1217
+ onLogoutClick,
1218
+ shoppingCart,
1219
+ shoppingCartNumberOfItems,
1220
+ onSearchSubmit,
1221
+ isCartOpen,
1222
+ onCartOpenChange,
1223
+ drawerSize = "md",
1224
+ isSimplified,
1225
+ currentPath,
1226
+ ...props
1227
+ }) {
1228
+ const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath));
1229
+ const [selectedDomainItem, setSelectedDomainItem] = React__default.useState(getInitialDomain(currentPath));
1230
+ const [pathname, setPathname] = React__default.useState(currentPath || "");
1231
+ const classes = clsx([styles[`${rootClassName}`]], className);
1232
+ return /* @__PURE__ */ jsx(
1233
+ RootContext.Provider,
1234
+ {
1235
+ value: {
1236
+ appKey,
1237
+ loggedInUser,
1238
+ selectedMenuItem,
1239
+ setSelectedMenuItem(v, onlyStateChange) {
1240
+ if (appKey === "open-pages" && !onlyStateChange)
1241
+ return;
1242
+ setSelectedMenuItem(v);
1243
+ },
1244
+ linkComponent,
1245
+ selectedDomainItem,
1246
+ setSelectedDomainItem(v, onlyStateChange) {
1247
+ if (appKey === "open-pages" && !onlyStateChange)
1248
+ return;
1249
+ setSelectedDomainItem(v);
1250
+ },
1251
+ pathname,
1252
+ setPathname(v) {
1253
+ if (appKey === "open-pages")
1254
+ return;
1255
+ setPathname(v);
1256
+ },
1257
+ onLogoutClick,
1258
+ shoppingCart,
1259
+ shoppingCartNumberOfItems,
1260
+ onSearchSubmit,
1261
+ isCartOpen,
1262
+ onCartOpenChange,
1263
+ drawerSize
1264
+ },
1265
+ children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1266
+ NavigationMenu,
1267
+ {
1268
+ topMenuValue: selectedDomainItem,
1269
+ onTopMenuValueChange: setSelectedDomainItem,
1270
+ value: selectedMenuItem,
1271
+ onValueChange: (v) => {
1272
+ if (v === "" || appKey === "open-pages")
1273
+ return;
1274
+ setSelectedMenuItem(v);
1275
+ },
1276
+ children: [
1277
+ /* @__PURE__ */ jsxs(Box, { display: { sm: "none", lg: "block" }, children: [
1278
+ isSimplified && /* @__PURE__ */ jsx(DesktopSimplified, {}),
1279
+ !isSimplified && /* @__PURE__ */ jsx(Desktop, {})
1280
+ ] }),
1281
+ /* @__PURE__ */ jsxs(Box, { display: { lg: "none" }, children: [
1282
+ isSimplified && /* @__PURE__ */ jsx(MobileSimplified, {}),
1283
+ !isSimplified && /* @__PURE__ */ jsx(Mobile, {})
1284
+ ] })
1285
+ ]
1286
+ }
1287
+ ) })
1288
+ }
1289
+ );
1290
+ }
1291
+ Root.displayName = "Root";
1292
+ function getInitialDomain(currentPath) {
1293
+ if (!currentPath)
1294
+ return PRIVATE_LINKS.name;
1295
+ const locationArray = currentPath ? currentPath.split("/") : [];
1296
+ const domainPartOfLocation = `/${locationArray[1].toLowerCase()}/`;
1297
+ const initDomain = domainPartOfLocation === BUSINESS_LINKS.link ? BUSINESS_LINKS.name : domainPartOfLocation === MDU_LINKS.link ? MDU_LINKS.name : PRIVATE_LINKS.name;
1298
+ return initDomain;
1299
+ }
1300
+ function getInitialMenuItem(currentPath) {
1301
+ var _a, _b, _c, _d, _e, _f;
1302
+ if (!currentPath)
1303
+ return;
1304
+ const locationArray = currentPath ? currentPath.split("/") : [];
1305
+ const initialDomain = getInitialDomain(currentPath);
1306
+ if (initialDomain === "Bedrift") {
1307
+ const mainMenuPartOfLocation2 = locationArray[2];
1308
+ return (_b = (_a = BUSINESS_LINKS.links) == null ? void 0 : _a.find(
1309
+ (link) => {
1310
+ var _a2;
1311
+ return link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`));
1312
+ }
1313
+ )) == null ? void 0 : _b.name;
1314
+ }
1315
+ if (initialDomain === "Borettslag") {
1316
+ const mainMenuPartOfLocation2 = locationArray[2];
1317
+ return (_d = (_c = MDU_LINKS.links) == null ? void 0 : _c.find((link) => link.link === `/${initialDomain.toLowerCase()}/${mainMenuPartOfLocation2}/`)) == null ? void 0 : _d.name;
1318
+ }
1319
+ const mainMenuPartOfLocation = locationArray[1];
1320
+ return (_f = (_e = PRIVATE_LINKS.links) == null ? void 0 : _e.find((link) => {
1321
+ var _a2;
1322
+ return link.link === `/${mainMenuPartOfLocation}/` || ((_a2 = link.links) == null ? void 0 : _a2.some((link2) => link2.link === `/${mainMenuPartOfLocation}/`));
1323
+ })) == null ? void 0 : _f.name;
1324
+ }
1325
+ Root.displayName = "GlobalNavigation";
1326
+ const GlobalNavigation = Root;
260
1327
  export {
261
1328
  Body as B,
262
- Content$1 as C,
1329
+ Content$2 as C,
1330
+ Desktop as D,
1331
+ GlobalNavigation as G,
263
1332
  ItemContext as I,
264
1333
  Modal as M,
1334
+ NavigationMenu as N,
265
1335
  RadioCardGroup as R,
1336
+ Separator as S,
266
1337
  Title$1 as Title,
267
- Item as a
1338
+ Item$1 as a,
1339
+ MyPages as b,
1340
+ SearchField as c,
1341
+ Search as d,
1342
+ ShoppingCart as e,
1343
+ Mobile as f,
1344
+ DesktopSimplified as g,
1345
+ MobileSimplified as h,
1346
+ rootClassName as i,
1347
+ RootContext as j,
1348
+ Root as k,
1349
+ rootClassName$1 as r
268
1350
  };