import{j as e}from"./components-CM65SDfl.js";import{F as x,y as w,j as c,k as d}from"./TileGroup-D-B3hNTU.js";import{useRef as j,useEffect as u,useState as v}from"https://assets.finn.no/npm/react/v18/react.production.min.js";import{Button as g}from"https://assets.finn.no/pkg/@warp-ds/react/v1/warp-react-18.js";const y=r=>r.includes("vimeo")?"vimeo":r.includes("youtube")?"youtube":r.includes("phyron")?"phyron":r.includes("matterport")?"matterport":r.includes("h5property")?"h5property":r.includes("youriguide")?"youriguide":null,L=r=>{const o=y(r),t=new URL(r);switch(o){case"vimeo":return t.searchParams.append("api","1"),t.searchParams.append("loop","1"),t;case"youtube":return t;case"phyron":return t;case"matterport":return t.searchParams.append("play","1"),t.searchParams.append("qs","1"),t.searchParams.append("vr","0"),t;case"h5property":return t.searchParams.append("initvars.design","finn"),t;case"youriguide":return t.searchParams.append("mute","1"),t.searchParams.append("unbranded","1"),t.searchParams.append("nomenu","1"),t.searchParams.append("nox","1"),t.searchParams.append("bgcolor","000000"),t;default:return t}},f=["player.vimeo.com","www.youtube.com","www.youtube-nocookie.com","my.matterport.com","tours.h5property.com","youriguide.com","tours.stormcam.no","kuula.co","www.inviso.no","leveranse.inviso.no","my360.inviso.no","innhold.inviso.no","fastout.com","cdn.diakrit.com","360.imageday.no","imagedesktours.com","superohshots.com","panomaxstudio.no"],h=r=>{try{const o=new URL(r).host;return f.includes(o)}catch{return!1}},p=({url:r,buttonText:o,closeCallback:t})=>{const i=j(null);return u(()=>{var a,l;window.scrollTo(0,0);const s=k=>{k.code==="Escape"&&t()},n=(l=(a=i.current)==null?void 0:a.contentWindow)==null?void 0:l.document;return document.addEventListener("keydown",s),n==null||n.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s),n==null||n.removeEventListener("keydown",s)}},[i,t]),e.jsx(x,{children:e.jsxs("div",{className:"fixed top-0 bottom-0 left-0 right-0 w-full h-screen z-40",style:{background:"rgba(0,0,0,.9)"},"data-testid":"360-modal",children:[e.jsx("button",{className:"absolute top-20 right-20 s-icon-inverted p-16",style:{background:"#000",opacity:".44"},onClick:t,children:e.jsx(w,{})}),e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("iframe",{ref:i,src:L(r).toString(),frameBorder:"0",title:o,allowFullScreen:!0,allow:"xr-spatial-tracking",style:{height:"100%",width:"100%"}})})]})})},m=({url:r,icon:o,buttonText:t,tracking:i})=>{const[s,n]=v(!1);return u(()=>{["overflow-hidden","relative","h-full"].map(a=>document.body.classList.toggle(a,s))},[s]),r&&h(r)?e.jsxs(e.Fragment,{children:[e.jsxs(g,{quiet:!0,utility:!0,onClick:()=>{n(!0),i()},className:"flex items-center font-bold","aria-label":t,"data-preview-dont-disable":"true",children:[o,e.jsx("span",{className:"hidden md:block pl-4",children:t})]}),s?e.jsx(p,{url:r,buttonText:t,closeCallback:()=>n(!1)}):null]}):null},b=r=>e.jsxs("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[e.jsx("path",{d:"M22.037 6.307a.75.75 0 1 1-1.285.774l1.285-.774Zm-.625 9.513a.75.75 0 1 1 1.387.572l-1.387-.572ZM12.394 2.356c-5.385 0-9.75 4.365-9.75 9.75h-1.5c0-6.214 5.037-11.25 11.25-11.25v1.5Zm-9.75 9.75c0 5.384 4.365 9.75 9.75 9.75v1.5c-6.213 0-11.25-5.037-11.25-11.25h1.5ZM20.752 7.08a9.745 9.745 0 0 0-8.358-4.725v-1.5c4.093 0 7.675 2.186 9.643 5.451l-1.285.774Zm-8.358 14.775a9.753 9.753 0 0 0 9.018-6.036l1.387.572c-1.685 4.085-5.708 6.964-10.405 6.964v-1.5Z",fill:"currentColor"}),e.jsx("path",{d:"M21.895 4.106v3l-2.899-.484M16 9.5V17H9V9.5",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"m7 10.5 5.5-3 5.5 3",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})]}),C=r=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M14.2628 4.46273C13.0379 2.42989 10.8092 1.07031 8.26283 1.07031C4.39683 1.07031 1.26283 4.20432 1.26283 8.07031C1.26283 11.9363 4.39683 15.0703 8.26283 15.0703C11.1846 15.0703 13.6883 13.2802 14.737 10.737",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M14.5962 2.73697L14.5962 4.73697L12.6637 4.4149",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M11 6.25V11H6V9.34074V6.25",stroke:"currentColor",strokeWidth:"1.03333",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M4.75 6.75L8.5 4.75L12.25 6.75",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),V=r=>e.jsxs("svg",{width:24,height:24,fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[e.jsx("circle",{cx:12,cy:12,r:11,stroke:"currentColor",strokeWidth:1.5}),e.jsx("path",{d:"M9 17V7l8 5-8 5Z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})]}),M=r=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"7.99967",cy:"8.00008",r:"7.33333",stroke:"currentColor"}),e.jsx("path",{d:"M5.99968 11.3334V4.66675L11.333 8.00008L5.99968 11.3334Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})]}),P=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsxs("g",{clipPath:"url(#clip0_809_5159)",children:[e.jsx("path",{d:"M14.4168 4.20834L8.87512 4.20834C8.39187 4.20834 8.00012 4.60009 8.00012 5.08334L8.00012 8.29168",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12.1187 6.79363L14.4167 4.20833L12.1187 1.62303",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M14.4166 8.58334V12.4167C14.4166 13.5212 13.5212 14.4167 12.4166 14.4167H3.58325C2.47868 14.4167 1.58325 13.5212 1.58325 12.4167V3.58334C1.58325 2.47877 2.47868 1.58334 3.58325 1.58334H6.24992",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("defs",{children:e.jsx("clipPath",{id:"clip0_809_5159",children:e.jsx("rect",{width:"16",height:"16",fill:"white"})})})]}),W=({url:r,trackerVertical:o})=>r?e.jsx(m,{url:r,icon:e.jsx(V,{}),buttonText:"Video",tracking:()=>c({name:"Video viewing",objectId:"video-viewing",elementType:d.Icon,intent:"View",trackerVertical:o})}):null,Z=({url:r,trackerVertical:o})=>r?e.jsx(m,{url:r,icon:e.jsx(b,{}),buttonText:"360\xB0 Visning",tracking:()=>c({name:"360 viewing",objectId:"virtual-viewing",elementType:d.Icon,intent:"View",trackerVertical:o})}):null,E=({videoUrl:r,virtualViewingUrl:o,trackerVertical:t})=>r||o?e.jsxs("div",{className:"sm:ml-auto flex justify-items md:gap-16","data-testid":"video-and-virtual-viewing",children:[e.jsx(W,{url:r,trackerVertical:t}),e.jsx(Z,{url:o,trackerVertical:t})]}):null;export{p as E,P as S,E as V,M as a,C as b,h as i};
