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B,EAAMgB,KAAI,CAACwB,EAAMC,IAChB/D,EAAAA,cAACgE,EAAAA,GAAW,CAACC,IAAG,GAAAC,OAAKJ,EAAKtB,KAAI,KAAA0B,OAAIH,IACjB,iBAAdD,EAAKtB,MACJxC,EAAAA,cAACb,EAAkB,CAACI,KAAMuE,IAEb,YAAdA,EAAKtB,MAAsBxC,EAAAA,cAACY,EAAa,CAACG,QAAS+C,SAM9D9D,EAAAA,cAAA,SAAOS,UAAU,sBAAqB,0BACrC,EAID0D,EAAYC,SAASC,qBAAqB,0BAEvCC,EAAI,EAAGA,EAAIH,EAAUtB,OAAQyB,IAAK,CACzC,IAAMC,EAAUJ,EAAUL,KAAKQ,GACzBE,GAAOC,EAAAA,EAAAA,GAAWF,GAElBlD,EAAekD,EAAQG,QAAQrD,aAErCmD,EAAKG,OAAO3E,EAAAA,cAACmB,EAAoB,CAACE,aAAcA,IAClD,C,gEC3KayB,GAAgB8B,EAAAA,EAAAA,IAAOC,EAAAA,GAAPD,CAAcE,I,EAAA,0iD,kBAAAA,E,yTC4BpC,SAASxE,EACdkC,EACAuC,EACAC,EACAC,GAEAC,OAAOC,UAAYD,OAAOC,WAAa,GAEvC,IAEMC,E,ytBAAU7C,CAAA,CACd6C,MAAO5C,GA6BX,SAAuBuC,GACrB,OAAOA,EACHM,OAAOC,YACLD,OAAOE,QAAQR,GAAYzC,KAAIlD,IAAA,IAAE6E,EAAKuB,GAAMpG,EAAA,MAAK,CAAC,OAAD8E,OAAQD,GAAOuB,EAAM,KAExE,CAAC,CACP,CAtC0BC,CAAcV,IAOlCC,IACFI,EAAMM,UAAYV,GAGhBC,IACFG,EAAMO,cAAgBV,GAGxBC,OAAOC,UAAUS,KAAKR,EACxB,C,0FCvDO,IAAMzE,EAAakF,GACpBA,GAASA,EAAMhD,OAAS,IACnBgD,EAAMC,UAAU,EAAG,KAAO,MAE5BD,C","sources":["webpack://voresby.web/./Scripts/components/carousel/business-plus-carousel.tsx","webpack://voresby.web/./Scripts/components/carousel/wrapped-swiper.tsx","webpack://voresby.web/./Scripts/util/gtm.ts","webpack://voresby.web/./Scripts/util/helpers.ts"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\r\nimport { SwiperSlide } from \"swiper/react\";\r\nimport { apiConfiguration } from \"../../api-configuration\";\r\nimport {\r\n FacebookApi,\r\n FacebookPostDto,\r\n ArticleRecommendationDto,\r\n ContentApi,\r\n} from \"../../lib-api\";\r\nimport { Navigation, Pagination, Autoplay, Lazy } from \"swiper\";\r\nimport { trackGaEvent } from \"../../util/gtm\";\r\nimport { createRoot } from \"react-dom/client\";\r\nimport { WrappedSwiper } from \"./wrapped-swiper\";\r\nimport { ellipsize } from \"../../util/helpers\";\r\n\r\nconst facebookApi = new FacebookApi(apiConfiguration);\r\nconst contentApi = new ContentApi(apiConfiguration);\r\n\r\ntype Post =\r\n | ({ type: \"facebookpost\" } & FacebookPostDto)\r\n | ({ type: \"article\" } & ArticleRecommendationDto);\r\n\r\ntype Posts = Post[] | undefined;\r\n\r\nconst RenderFacebookPost = ({ post }: { post: FacebookPostDto }) => {\r\n const containsOffer = useMemo(() => {\r\n return [\"tilbud\", \"ja tak\"].some((x) =>\r\n post.message?.toLocaleLowerCase().includes(x)\r\n );\r\n }, [post.message]);\r\n\r\n return (\r\n trackGaEvent(\"on_facebook_carousel_clicked\")}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n {post.name}\r\n {ellipsize(post.message ?? \"\")}\r\n \r\n {containsOffer ? \"Læs mere om tilbuddet\" : \"Åbn opslaget\"}\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nconst RenderArticle = ({ article }: { article: ArticleRecommendationDto }) => (\r\n trackGaEvent(\"on_facebook_carousel_clicked\")}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n {article.articleTitle}\r\n {/* {ellipsize(post.message ?? \"\")} */}\r\n \r\n Åbn artiklen\r\n \r\n \r\n);\r\n\r\nconst BusinessPlusCarousel: React.FC<{ hasProductId: string }> = ({\r\n hasProductId,\r\n}) => {\r\n const [items, setItems] = useState(undefined);\r\n\r\n useEffect(() => {\r\n (async () => {\r\n try {\r\n const [facebookPosts, businessArticles] = await Promise.all([\r\n facebookApi.getFacebookPosts({\r\n getFacebookPostsForm: {\r\n hasProductId: hasProductId,\r\n maxAgeInDays: 1,\r\n postsCountPerCustomer: 2,\r\n },\r\n }),\r\n contentApi.getLatestContentFromCustomersWithProduct({\r\n productId: hasProductId,\r\n }),\r\n ]);\r\n\r\n const mappedFacebookPosts: Post[] = facebookPosts.map((x) => ({\r\n type: \"facebookpost\",\r\n ...x,\r\n }));\r\n const mappedBusinessArticles: Post[] = businessArticles.map((x) => ({\r\n type: \"article\",\r\n ...x,\r\n }));\r\n\r\n setItems([...mappedFacebookPosts, ...mappedBusinessArticles]);\r\n } catch (e) {\r\n console.error(e);\r\n }\r\n })();\r\n }, []);\r\n\r\n if (items !== undefined && items.length == 0) {\r\n return null;\r\n }\r\n\r\n return (\r\n <>\r\n {items !== undefined && items.length > 0 && (\r\n \r\n <>\r\n {items.map((item, index) => (\r\n \r\n {item.type === \"facebookpost\" && (\r\n \r\n )}\r\n {item.type === \"article\" && }\r\n \r\n ))}\r\n >\r\n \r\n )}\r\n Annoncørbetalt indhold\r\n >\r\n );\r\n};\r\n\r\nconst carousels = document.getElementsByTagName(\"business-plus-carousel\");\r\n\r\nfor (let i = 0; i < carousels.length; i++) {\r\n const element = carousels.item(i) as HTMLElement;\r\n const root = createRoot(element);\r\n\r\n const hasProductId = element.dataset.hasProductId!;\r\n\r\n root.render();\r\n}\r\n","import { styled } from \"styled-components\";\r\nimport { Swiper } from \"swiper/react\";\r\n\r\nexport const WrappedSwiper = styled(Swiper)`\r\n width: 100%;\r\n height: 100%;\r\n\r\n .swiper-button-prev,\r\n .swiper-button-next {\r\n color: #a43424 !important;\r\n top: 25% !important;\r\n &::after {\r\n font-size: 30px;\r\n font-weight: 900;\r\n }\r\n }\r\n\r\n .swiper-pagination {\r\n background-color: #fcfcfc;\r\n }\r\n\r\n .swiper-pagination-bullet-active {\r\n opacity: 1;\r\n background: #a43424;\r\n }\r\n\r\n .swiper-slide {\r\n //min-height: 355px;\r\n padding-bottom: 35px;\r\n\r\n /* Center slide text vertically */\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: -webkit-flex;\r\n display: flex;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n -webkit-justify-content: center;\r\n justify-content: center;\r\n -webkit-box-align: start;\r\n -ms-flex-align: start;\r\n -webkit-align-items: start;\r\n align-items: start;\r\n\r\n a {\r\n display: flex;\r\n flex-direction: column;\r\n color: #000;\r\n text-decoration: none;\r\n > div {\r\n &:first-child {\r\n height: 200px;\r\n }\r\n &:last-child {\r\n min-height: 160px;\r\n }\r\n position: relative;\r\n width: 200px;\r\n align-self: center;\r\n img {\r\n display: block;\r\n width: 200px;\r\n height: 200px;\r\n object-fit: cover;\r\n }\r\n }\r\n b {\r\n font-size: 16px;\r\n word-wrap: break-word;\r\n }\r\n p {\r\n font-size: 13px;\r\n max-height: 200px;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n /*white-space: nowrap;*/\r\n }\r\n }\r\n }\r\n`;\r\n","declare const window: {\r\n dataLayer: any[];\r\n};\r\n\r\n/* If you add new ones here. Remeber to add them in Google Tag Manager GA4 Event Tag */\r\ntype validEvents =\r\n | \"on_cookie_consent\"\r\n | \"on_company_contact\"\r\n | \"on_facebook_carousel_clicked\"\r\n | \"on_shared_with_friend\"\r\n | \"on_content_task_feedback\"\r\n | \"on_newsletter_subscribe\"\r\n | \"on_external_link_clicked\"\r\n | \"on_questionnaire_submitted\"\r\n | \"on_one_tap\"\r\n | \"on_kpi\"\r\n | \"lead_generated\";\r\n\r\n/* If you add new ones here. Remeber to add them in Google Tag Manager GA4 Event Tag, And in CustomDefinitions IN GA4 */\r\ntype validParameters =\r\n | \"in_section\"\r\n | \"action\"\r\n | \"href\"\r\n | \"variant\"\r\n | \"lead_type\"\r\n | \"customer_id\"\r\n | \"customer_name\"\r\n | \"user_data\";\r\n\r\ntype validUserData = \"email\" | \"phone\" | \"zip\" | \"city\" | \"country\";\r\n\r\nexport function trackGaEvent(\r\n type: validEvents,\r\n parameters?: { [key in validParameters]?: string | number },\r\n userData?: { [key in validUserData]?: string | number },\r\n callback?: (id: string) => void\r\n) {\r\n window.dataLayer = window.dataLayer || [];\r\n //convert parameter keys to dlv_* for Tag Manager.\r\n const convertedParams = convertParams(parameters);\r\n\r\n const event: any = {\r\n event: type,\r\n ...convertedParams,\r\n };\r\n\r\n if (userData) {\r\n event.user_data = userData;\r\n }\r\n\r\n if (callback) {\r\n event.eventCallback = callback;\r\n }\r\n\r\n window.dataLayer.push(event);\r\n}\r\n\r\n/* If you add new ones here. Remeber to add them in Google Tag Manager GA4 DLV */\r\ntype validDataLayerVariables = \"page_type\" | \"category\";\r\n\r\nexport function setDataLayerVariables(parameters: {\r\n [key in validDataLayerVariables]?: string | number;\r\n}) {\r\n window.dataLayer = window.dataLayer || [];\r\n //convert parameter keys to dlv_* for Tag Manager.\r\n const convertedParams = convertParams(parameters);\r\n window.dataLayer.push({\r\n ...convertedParams,\r\n });\r\n}\r\n\r\nfunction convertParams(parameters?: { [key: string]: string | number }) {\r\n return parameters\r\n ? Object.fromEntries(\r\n Object.entries(parameters).map(([key, value]) => [`dlv_${key}`, value])\r\n )\r\n : {};\r\n}\r\n\r\nexport function trackVirtualPageView(url: string) {\r\n window.dataLayer = window.dataLayer || [];\r\n window.dataLayer.push({\r\n event: \"GAVirtualPageView\",\r\n virtualPageUrl: url,\r\n });\r\n}\r\n","export const ellipsize = (input?: string) => {\r\n if (input && input.length > 125) {\r\n return input.substring(0, 125) + \"...\";\r\n }\r\n return input;\r\n};\r\n"],"names":["facebookApi","FacebookApi","apiConfiguration","contentApi","ContentApi","RenderFacebookPost","_ref","_post$permalink","_post$message2","post","containsOffer","useMemo","some","x","_post$message","message","toLocaleLowerCase","includes","React","href","permalink","target","rel","onClick","trackGaEvent","alt","imageUrl","className","name","ellipsize","RenderArticle","_ref2","_article$articleUrl","article","articleUrl","assetRetinaSrc","articleTitle","BusinessPlusCarousel","_ref3","hasProductId","items","setItems","useState","undefined","useEffect","facebookPosts","businessArticles","Promise","all","getFacebookPosts","getFacebookPostsForm","maxAgeInDays","postsCountPerCustomer","getLatestContentFromCustomersWithProduct","productId","mappedFacebookPosts","map","_objectSpread","type","mappedBusinessArticles","e","console","error","length","WrappedSwiper","modules","Navigation","Pagination","Lazy","Autoplay","slidesPerView","breakpoints","navigation","pagination","clickable","preloadImages","lazy","enabled","checkInView","loadPrevNext","item","index","SwiperSlide","key","concat","carousels","document","getElementsByTagName","i","element","root","createRoot","dataset","render","styled","Swiper","_templateObject","parameters","userData","callback","window","dataLayer","event","Object","fromEntries","entries","value","convertParams","user_data","eventCallback","push","input","substring"],"sourceRoot":""}
{ellipsize(post.message ?? \"\")}