@roomle/embedding-lib 5.1.0-debug.1 → 5.1.0-debug.3

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,14 +1,14 @@
1
- (function(f,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(f=typeof globalThis<"u"?globalThis:f||self,f["roomle-embedding-lib"]=f["roomle-embedding-lib"]||{},f["roomle-embedding-lib"].umd=f["roomle-embedding-lib"].umd||{},f["roomle-embedding-lib"].umd.min=f["roomle-embedding-lib"].umd.min||{},f["roomle-embedding-lib"].umd.min.js=y())})(this,function(){"use strict";var f=Object.defineProperty,y=(i,e,t)=>e in i?f(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,l=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);class j{constructor(e,t,s,n){l(this,"_side"),l(this,"_incomingMessageBus"),l(this,"_outgoingMessageBus",null),l(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=n,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,n)=>{const r=new MessageChannel;r.port1.onmessage=o=>{if(!o||!o.data)return r.port1.close(),r.port2.close(),n(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(o.data)}catch(h){return r.port1.close(),r.port2.close(),this._prepareError(h),n(h)}c.error?n(c.error):c.result!==void 0?s(c.result):s(void 0),r.port1.close(),r.port2.close()};let a="";try{a=JSON.stringify({message:e,args:t})}catch{return n(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return n(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(a,"*",[r.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const n=this._execMessage(s,e);if(n===void 0)return;n.then((r={})=>{let a,o;typeof r=="object"&&r!==null&&(a=r.error,o=r.result),a?t.postMessage(JSON.stringify({error:a})):o!==void 0?t.postMessage(JSON.stringify({result:o})):t.postMessage(JSON.stringify({result:r}))},r=>{t.postMessage(JSON.stringify({error:this._prepareError(r)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const T=".",D={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},J=async(i,e)=>{if(typeof i!="string")throw new Error('Configurator ID is not a string type: "'+typeof i+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,n=t+"/configurators/"+i,r="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+r),o=()=>{const _={apiKey:r,currentTenant:s,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(_)},c=new Request(n,{method:"GET",headers:o(),mode:"cors",cache:"default"}),h=await fetch(c),{configurator:u}=await h.json();return u},V=()=>{try{return window.self!==window.top}catch{return!0}},q=["127.0.0.1","localhost","0.0.0.0"],G=()=>{const i=V();let e=window.location.href;if(i){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},Q=i=>!!(q.includes(i)||i.endsWith("roomle.com")||i.endsWith("gitlab.io")||i.endsWith("gitlab.com")),C=["language","browserLanguage","userLanguage","systemLanguage"],K=(i=null)=>{const e=window.navigator;if(i)return i.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=C.length;t<s;t++){const n=e[C[t]];if(n)return n.substr(0,2)}return"en"},Z=(i,e)=>{const t=JSON.parse(JSON.stringify(i));return I(t,e)},I=(i,e)=>{for(const t in e)try{e[t].constructor===Object?i[t]=I(i[t],e[t]):i[t]=e[t]}catch{i[t]=e[t]}return i};var ee={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const te={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0}},se="(idle)",ie=i=>(E(i),i!=null&&i.customApiUrl&&(i.customApiUrl=decodeURIComponent(i.customApiUrl)),i.shareUrl&&(i.deeplink=i.shareUrl.replace(oe,ae)),i),E=i=>{if(!i)return;const e=Object.keys(i);for(const t of e){const s=i[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&E(s),Array.isArray(s))for(const n of s)E(n);(s==="true"||s==="false")&&(i[t]=s==="true")}},ne=(i,e)=>{e.configuratorId=i.id;const t=i.settings||{};return!e.overrideTenant&&i.tenant&&(e.overrideTenant=i.tenant),Z(t,e)},re=()=>{const i={...te};i.locale||(i.locale=K()),i.id===se&&delete i.id;const e=G();return e&&Q(e)&&(i.configuratorId="demoConfigurator"),i.customApiUrl=ee.VITE_RAPI_URL,i.emails=!1,i},oe="<CONF_ID>",ae="#CONFIGURATIONID#",F=()=>/(android)/i.test(navigator.userAgent),k=(i,e,t)=>{let s=null;Object.defineProperty(i,e,{get(){return s||t},set(n){n!=null&&n.mute?s=n.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),s=n)}})},$=()=>window.innerHeight*.01+"px",U=i=>{i&&setTimeout(()=>i.style.setProperty(O,$()),0)},H="rml-styles",le=450,O="--rml-full-height",g={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},x=new Map;class ce{constructor(e,t,s,n,r){if(l(this,"ui",{callbacks:null}),l(this,"extended",{callbacks:null}),l(this,"analytics",{callbacks:{}}),l(this,"global",{callbacks:{}}),l(this,"plugins",{}),l(this,"_waitForIframe"),l(this,"_container"),l(this,"_messageHandler"),l(this,"_configuratorSettings"),l(this,"_initData",{}),l(this,"_iframe"),l(this,"pluginsLoaded",[]),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(x.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(H)){const o=s.zIndex||9999999,c=document.createElement("style");c.type="text/css",c.id=H;const h="transition:all ease-in-out "+le+"ms;",u=["-webkit-","-o-"].reduce((d,m)=>d+=m+h,"")+h,_=$();c.innerHTML=`
2
- .${g.CONTAINER}{${O}:${_};}
3
- .${g.POSITION}{position:fixed;top:0;left:0;z-index:${o};opacity:0}
4
- .${g.TRANSITION}{${u}}
5
- .${g.FILL}{width:100%;height:100%;opacity:1}
6
- .${g.ANDROID_HEIGHT}{height:calc(var(${O},1vh)*100)}
7
- .${g.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(c)}this._onResize=this._onResize.bind(this),F()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const a=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new j("website",window,null,this._executeMessage),this._waitForIframe=r,this._container.appendChild(a),this._iframe=a,n.includes("dragIn")&&this.pluginsLoaded.push(new Promise((o,c)=>{try{Promise.resolve().then(()=>pe).then(({DragIn:h})=>{const u=new h(this._iframe);u.setInstance(this.ui),o(),this.plugins.dragIn=u})}catch(h){c(h)}})),x.set(t,!0)}static createPlanner(e,t,s,n=[]){return this._create(e,t,s,n)}static createConfigurator(e,t,s,n=[]){return this._create(e,t,s,n)}static create(e,t,s,n){return this._create(e,t,s,n)}static createViewer(e,t,s,n=[]){return this._create(e,t,s,n)}static async _create(e,t,s,n){return new Promise(async(r,a)=>{try{const o=I(re(),ie(s));o.featureFlags||(o.featureFlags={}),typeof o.featureFlags.realPartList!="boolean"&&(o.featureFlags.realPartList=!0),typeof o.featureFlags.globalCallbacks!="boolean"&&(o.featureFlags.globalCallbacks=!0),typeof o.featureFlags.mocAr!="boolean"&&(o.featureFlags.mocAr=!1);const c=await J(e,o);s=ne(c,o);const h=new this(c,t,s,n,r);return await Promise.allSettled(h.pluginsLoaded),h}catch(o){return a(o)}})}teardown(){this._container&&x.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;const t=document.createElement("iframe");let s=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(s=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(s=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(s=this._initData.overrideServerUrl),t.src=s,t.classList.add(g.CONTAINER),t.classList.add(g.FILL),t}_onResize(){U(this._iframe)}_onUseFullPage(){this._iframe.classList.add(g.POSITION),document.documentElement.classList.add(g.OVERFLOW_HIDDEN),window.document.body.classList.add(g.OVERFLOW_HIDDEN),F()&&(U(this._iframe),this._iframe.classList.add(g.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(g.POSITION),this._iframe.classList.remove(g.ANDROID_HEIGHT),document.documentElement.classList.remove(g.OVERFLOW_HIDDEN),window.document.body.classList.remove(g.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},s){var n;if(!s.source||s.source!==((n=this._iframe)==null?void 0:n.contentWindow))return;if(e===D.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData});if(e===D.SETUP){const{methods:h,callbacks:u}=t[0];return h.forEach(_=>{const d=_.split(T),m=d[0],p=d[1];this[m]||(this[m]={}),this[m][p]=function(){return this._messageHandler.sendMessage(_,[...arguments])}.bind(this)}),u.forEach(_=>{const d=_.split(T),m=d[0],p=d[1],ye=d[2];this[m]||(this[m]={}),this[m][p]||(this[m][p]={}),this[m][p][ye]=()=>{}}),k(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),k(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(D.WEBSITE_READY),0),Promise.resolve({result:null})}const r=e.split(T),a=r[0],o=r[1],c=r.length===3?r[2]:null;if(c&&this[a][o][c]){const h=this[a][o][c](...t);return h instanceof Promise?h.then(u=>({result:u})):h!==void 0?Promise.resolve({result:h}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}class he{constructor(e=16){l(this,"_computedStyleCache",new Map),l(this,"_maxLifetime",16),l(this,"_cacheCleanInterval",null),this._maxLifetime=e}get(e){const t=this._computedStyleCache.get(e),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const n=getComputedStyle(e);return this._computedStyleCache.set(e,{style:n,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),n}_cleanUpCache(){const e=Date.now();for(const[t,{updated:s}]of this._computedStyleCache.entries())e-s>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}let S;const v=i=>(S||(S=new he),S.get(i)),B=(i,e,t)=>{const s=parseFloat(i),n=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const a=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*a}if(e==="rem"){const a=parseFloat(v(document.documentElement).fontSize);return s*a}if(e==="em"){const a=parseFloat(v(t).fontSize);return s*a}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const a={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*a[e]}const r={cm:37.7952755906,mm:3.77952755906,in:96};return e in r?s*r[e]*n:0},W=(i,e,t={x:0,y:0})=>{const s=i.getBoundingClientRect(),n=v(i).transform;let r=0,a=0;if(n!=="none"){const _=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,d=n.match(_);d&&(r=B(d[1],d[2],i),a=B(d[3],d[4],i))}const{clientX:o,clientY:c}=L(e,t),h=o-s.left-r+i.scrollLeft,u=c-s.top-a+i.scrollTop;return{x:h,y:u}},L=(i,e)=>{const{clientX:t,clientY:s}=window.TouchEvent&&i instanceof TouchEvent?ue(i):i,n=t||e.x,r=s||e.y;return{clientX:n,clientY:r}},ue=i=>{if(i.touches.length){let{clientX:t,clientY:s}=i.touches[0];if(i.touches.length>1){const n=i.touches[1],r=n.clientX,a=n.clientY;t=(t+r)/2,s=(s+a)/2}return{clientX:t,clientY:s}}const e=i.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},de=500,ge=10;class me{constructor(e,{onTouchDragStart:t},s={}){l(this,"_touchDragTimeOut"),l(this,"_onTouchDragStart"),l(this,"_payload",null),l(this,"_delay"),l(this,"_firstTouch",null),l(this,"_lastTouch",null),this._payload=e,this._onTouchDragStart=t,this._delay=s.delay||de}onTouchStart(e){var t;!e||!((t=e?.touches)!=null&&t.length)||this._touchDragTimeOut||(this._firstTouch=e.touches[e.touches.length-1],this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=e.touches[0]),this._checkXDistance(e)()},this._delay))}onTouchEnd(){this._resetTouches()}onTouchMove(e){var t;!e||!((t=e?.touches)!=null&&t.length)||(this._lastTouch=e.touches[0])}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(e){return()=>{if(!this._firstTouch||!this._lastTouch)return;let t=!1;t=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<ge,t&&(this._onTouchDragStart(this._payload,e),this._resetTouches())}}}const Y="rml-drag-in-styles",_e="rml-drag-in-drag-element",w="rml-drag-in-overlay",b="rml-drag-in-drag-ghost",M="rml-drag-in-fade-in",z="rml-drag-in-fade-out",N={DISPLAY_NONE:"rml-display-none"},X=.5,P="250ms",R="forwards",A=i=>i?!0:(console.warn("No instance set, cancel drag-in"),!1);class fe{constructor(e){if(l(this,"_iframe"),l(this,"_currentDrag",{}),l(this,"_currentTouch",null),l(this,"_firefoxDragPosition",{x:0,y:0}),l(this,"_instance",null),l(this,"options",{}),l(this,"_firefoxFallback",n=>{if(!this._currentDrag.event)return;const r=n||window.event;this._firefoxDragPosition.x=r.pageX||0,this._firefoxDragPosition.y=r.pageY||0}),this._iframe=e,!document.getElementById(Y)){const n=document.createElement("style");n.type="text/css",n.id=Y,n.innerHTML=`
1
+ (function(_,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(_=typeof globalThis<"u"?globalThis:_||self,_["roomle-embedding-lib"]=_["roomle-embedding-lib"]||{},_["roomle-embedding-lib"].umd=_["roomle-embedding-lib"].umd||{},_["roomle-embedding-lib"].umd.min=_["roomle-embedding-lib"].umd.min||{},_["roomle-embedding-lib"].umd.min.js=y())})(this,function(){"use strict";var _=Object.defineProperty,y=(i,e,t)=>e in i?_(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,c=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);class q{constructor(e,t,s,n){c(this,"_side"),c(this,"_incomingMessageBus"),c(this,"_outgoingMessageBus",null),c(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=n,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,n)=>{const o=new MessageChannel;o.port1.onmessage=a=>{if(!a||!a.data)return o.port1.close(),o.port2.close(),n(new Error(this._side+" received message but response can not be interpreted"));let l;try{l=JSON.parse(a.data)}catch(h){return o.port1.close(),o.port2.close(),this._prepareError(h),n(h)}l.error?n(l.error):l.result!==void 0?s(l.result):s(void 0),o.port1.close(),o.port2.close()};let r="";try{r=JSON.stringify({message:e,args:t})}catch{return n(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return n(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(r,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const n=this._execMessage(s,e);if(n===void 0)return;n.then((o={})=>{let r,a;typeof o=="object"&&o!==null&&(r=o.error,a=o.result),r?t.postMessage(JSON.stringify({error:r})):a!==void 0?t.postMessage(JSON.stringify({result:a})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const D=".",T={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},G=async(i,e)=>{if(typeof i!="string")throw new Error('Configurator ID is not a string type: "'+typeof i+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,n=t+"/configurators/"+i,o="roomle_portal_v2",r="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),a=()=>{const d={apiKey:o,currentTenant:s,locale:"en",language:"en",device:1,token:r,platform:"web"};return new Headers(d)},l=new Request(n,{method:"GET",headers:a(),mode:"cors",cache:"default"}),h=await fetch(l),{configurator:u}=await h.json();return u},Q=()=>{try{return window.self!==window.top}catch{return!0}},K=["127.0.0.1","localhost","0.0.0.0"],Z=()=>{const i=Q();let e=window.location.href;if(i){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},ee=i=>!!(K.includes(i)||i.endsWith("roomle.com")||i.endsWith("gitlab.io")||i.endsWith("gitlab.com")),A=["language","browserLanguage","userLanguage","systemLanguage"],te=(i=null)=>{const e=window.navigator;if(i)return i.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=A.length;t<s;t++){const n=e[A[t]];if(n)return n.substr(0,2)}return"en"},se=(i,e)=>{const t=JSON.parse(JSON.stringify(i));return E(t,e)},E=(i,e)=>{for(const t in e)try{e[t].constructor===Object?i[t]=E(i[t],e[t]):i[t]=e[t]}catch{i[t]=e[t]}return i};var ie={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const ne={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0}},re="(idle)",oe=i=>(I(i),i!=null&&i.customApiUrl&&(i.customApiUrl=decodeURIComponent(i.customApiUrl)),i.shareUrl&&(i.deeplink=i.shareUrl.replace(ce,he)),i),I=i=>{if(!i)return;const e=Object.keys(i);for(const t of e){const s=i[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&I(s),Array.isArray(s))for(const n of s)I(n);(s==="true"||s==="false")&&(i[t]=s==="true")}},ae=(i,e)=>{e.configuratorId=i.id;const t=i.settings||{};return!e.overrideTenant&&i.tenant&&(e.overrideTenant=i.tenant),se(t,e)},le=()=>{const i={...ne};i.locale||(i.locale=te()),i.id===re&&delete i.id;const e=Z();return e&&ee(e)&&(i.configuratorId="demoConfigurator"),i.customApiUrl=ie.VITE_RAPI_URL,i.emails=!1,i},ce="<CONF_ID>",he="#CONFIGURATIONID#",F=()=>/(android)/i.test(navigator.userAgent),k=(i,e,t)=>{let s=null;Object.defineProperty(i,e,{get(){return s||t},set(n){n!=null&&n.mute?s=n.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),s=n)}})},U=()=>window.innerHeight*.01+"px",$=i=>{i&&setTimeout(()=>i.style.setProperty(x,U()),0)},H="rml-styles",ue=450,x="--rml-full-height",m={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},O=new Map;class de{constructor(e,t,s,n,o){if(c(this,"ui",{callbacks:null}),c(this,"extended",{callbacks:null}),c(this,"analytics",{callbacks:{}}),c(this,"global",{callbacks:{}}),c(this,"plugins",{}),c(this,"_waitForIframe"),c(this,"_container"),c(this,"_messageHandler"),c(this,"_configuratorSettings"),c(this,"_initData",{}),c(this,"_iframe"),c(this,"pluginsLoaded",[]),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(O.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(H)){const a=s.zIndex||9999999,l=document.createElement("style");l.type="text/css",l.id=H;const h="transition:all ease-in-out "+ue+"ms;",u=["-webkit-","-o-"].reduce((g,f)=>g+=f+h,"")+h,d=U();l.innerHTML=`
2
+ .${m.CONTAINER}{${x}:${d};}
3
+ .${m.POSITION}{position:fixed;top:0;left:0;z-index:${a};opacity:0}
4
+ .${m.TRANSITION}{${u}}
5
+ .${m.FILL}{width:100%;height:100%;opacity:1}
6
+ .${m.ANDROID_HEIGHT}{height:calc(var(${x},1vh)*100)}
7
+ .${m.OVERFLOW_HIDDEN}{overflow:hidden}
8
+ `,document.head.appendChild(l)}this._onResize=this._onResize.bind(this),F()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const r=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new q("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(r),this._iframe=r;for(const a of n)typeof a=="string"&&a==="dragIn"?this.pluginsLoaded.push(new Promise((l,h)=>{try{Promise.resolve().then(()=>ye).then(({DragIn:u})=>{const d=new u(this._iframe);d.setInstance(this.ui),this.plugins.dragIn=d,l()})}catch(u){h(u)}})):a.name&&a.loader&&this.pluginsLoaded.push(new Promise((l,h)=>{try{a.loader().then(u=>{const d=new u(this._iframe);d.setInstance(this.ui),this.plugins[a.name]=d,l()})}catch(u){h(u)}}));O.set(t,!0)}static createPlanner(e,t,s,n=[]){return this._create(e,t,s,n)}static createConfigurator(e,t,s,n=[]){return this._create(e,t,s,n)}static create(e,t,s,n){return this._create(e,t,s,n)}static createViewer(e,t,s,n=[]){return this._create(e,t,s,n)}static async _create(e,t,s,n){return new Promise(async(o,r)=>{try{const a=E(le(),oe(s));a.featureFlags||(a.featureFlags={}),typeof a.featureFlags.realPartList!="boolean"&&(a.featureFlags.realPartList=!0),typeof a.featureFlags.globalCallbacks!="boolean"&&(a.featureFlags.globalCallbacks=!0),typeof a.featureFlags.mocAr!="boolean"&&(a.featureFlags.mocAr=!1);const l=await G(e,a);s=ae(l,a);const h=new this(l,t,s,n,o);return await Promise.allSettled(h.pluginsLoaded),h}catch(a){return r(a)}})}teardown(){this._container&&O.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;const t=document.createElement("iframe");let s=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(s=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(s=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(s=this._initData.overrideServerUrl),t.src=s,t.classList.add(m.CONTAINER),t.classList.add(m.FILL),t}_onResize(){$(this._iframe)}_onUseFullPage(){this._iframe.classList.add(m.POSITION),document.documentElement.classList.add(m.OVERFLOW_HIDDEN),window.document.body.classList.add(m.OVERFLOW_HIDDEN),F()&&($(this._iframe),this._iframe.classList.add(m.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(m.POSITION),this._iframe.classList.remove(m.ANDROID_HEIGHT),document.documentElement.classList.remove(m.OVERFLOW_HIDDEN),window.document.body.classList.remove(m.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},s){var n;if(!s.source||s.source!==((n=this._iframe)==null?void 0:n.contentWindow))return;if(e===T.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData});if(e===T.SETUP){const{methods:h,callbacks:u}=t[0];return h.forEach(d=>{const g=d.split(D),f=g[0],p=g[1];this[f]||(this[f]={}),this[f][p]=function(){return this._messageHandler.sendMessage(d,[...arguments])}.bind(this)}),u.forEach(d=>{const g=d.split(D),f=g[0],p=g[1],ve=g[2];this[f]||(this[f]={}),this[f][p]||(this[f][p]={}),this[f][p][ve]=()=>{}}),k(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),k(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(T.WEBSITE_READY),0),Promise.resolve({result:null})}const o=e.split(D),r=o[0],a=o[1],l=o.length===3?o[2]:null;if(l&&this[r][a][l]){const h=this[r][a][l](...t);return h instanceof Promise?h.then(u=>({result:u})):h!==void 0?Promise.resolve({result:h}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}class ge{constructor(e=16){c(this,"_computedStyleCache",new Map),c(this,"_maxLifetime",16),c(this,"_cacheCleanInterval",null),this._maxLifetime=e}get(e){const t=this._computedStyleCache.get(e),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const n=getComputedStyle(e);return this._computedStyleCache.set(e,{style:n,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),n}_cleanUpCache(){const e=Date.now();for(const[t,{updated:s}]of this._computedStyleCache.entries())e-s>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const B=i=>window.TouchEvent&&i instanceof window.TouchEvent;let S;const v=i=>(S||(S=new ge),S.get(i)),W=(i,e,t)=>{const s=parseFloat(i),n=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const r=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*r}if(e==="rem"){const r=parseFloat(v(document.documentElement).fontSize);return s*r}if(e==="em"){const r=parseFloat(v(t).fontSize);return s*r}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const r={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*r[e]}const o={cm:37.7952755906,mm:3.77952755906,in:96};return e in o?s*o[e]*n:(console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"),0)},z=(i,e,t={x:0,y:0})=>{const s=i.getBoundingClientRect(),n=v(i).transform;let o=0,r=0;if(n!=="none"){const d=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,g=n.match(d);g&&(o=W(g[1],g[2],i),r=W(g[3],g[4],i))}const{clientX:a,clientY:l}=L(e,t),h=a-s.left-o+i.scrollLeft,u=l-s.top-r+i.scrollTop;return{x:h,y:u}},L=(i,e)=>{const{clientX:t,clientY:s}=B(i)?me(i):i,n=t||e.x,o=s||e.y;return{clientX:n,clientY:o}},me=i=>{if(i.touches.length){let{clientX:t,clientY:s}=i.touches[0];if(i.touches.length>1){const n=i.touches[1],o=n.clientX,r=n.clientY;t=(t+o)/2,s=(s+r)/2}return{clientX:t,clientY:s}}const e=i.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},Y=500,j=10;class fe{constructor(e,{onTouchDragStart:t},s={}){c(this,"_touchDragTimeOut"),c(this,"_onTouchDragStart"),c(this,"_payload",null),c(this,"_delay",Y),c(this,"_firstTouch",null),c(this,"_lastTouch",null),c(this,"_epsilon",j),this._payload=e,this._onTouchDragStart=t,this._delay=s.delay||Y,this._epsilon=s.epsilon||j}onTouchStart(e){var t;!e||!((t=e?.touches)!=null&&t.length)||this._touchDragTimeOut||(this._firstTouch=e.touches[e.touches.length-1],this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=e.touches[0]),this._checkXDistance(e)()},this._delay))}onTouchEnd(){this._resetTouches()}onTouchMove(e){var t;!e||!((t=e?.touches)!=null&&t.length)||(this._lastTouch=e.touches[0])}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(e){return()=>{if(!this._firstTouch||!this._lastTouch)return;let t=!1;t=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<this._epsilon,t&&(this._onTouchDragStart(this._payload,e),this._resetTouches())}}}const X="rml-drag-in-styles",_e="rml-drag-in-drag-element",w="rml-drag-in-overlay",b="rml-drag-in-drag-ghost",M="rml-drag-in-fade-in",J="rml-drag-in-fade-out",N={DISPLAY_NONE:"rml-display-none"},V=.5,P="250ms",R="forwards",C=i=>i?!0:(console.warn("No instance set, cancel drag-in"),!1);class pe{constructor(e){c(this,"_iframe"),c(this,"_currentDrag",{}),c(this,"_currentTouch",null),c(this,"_firefoxDragPosition",{x:0,y:0}),c(this,"_instance",null),c(this,"options",{}),c(this,"_firefoxFallback",t=>{if(!this._currentDrag.event)return;const s=t||window.event;this._firefoxDragPosition.x=s.pageX||0,this._firefoxDragPosition.y=s.pageY||0}),this._iframe=e,this._injectStyles(),this._initializeDragGhost(),this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}_injectStyles(){if(!document.getElementById(X)){const e=document.createElement("style");e.type="text/css",e.id=X,e.innerHTML=`
9
9
  .${N.DISPLAY_NONE}{display:none}
10
10
  .${w}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
11
11
  .${b}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
12
- @keyframes ${M} {from{opacity: 0;}to {opacity: ${X};}}
13
- @keyframes ${z} {from{opacity: ${X};}to {opacity: 0;}}
14
- `,document.head.appendChild(n)}const t=this._iframe.parentNode;let s=t.querySelector("."+b);s||(s=document.createElement("div"),s.classList.add(b),s.innerText=" ",t.appendChild(s)),this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}setInstance(e){this._instance=e}dragStart(e,t){const s=this._iframe.parentNode;if(v(s).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._iframe.style.pointerEvents="none";let n=s.querySelector("."+w);if(n||(n=document.createElement("div"),n.classList.add(w),s.appendChild(n)),n.classList.remove(N.DISPLAY_NONE),t instanceof DragEvent){t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const h=s.querySelector("."+b);this._currentDrag.event=t;const u=t.target.cloneNode();u.style.position="fixed",u.style.pointerEvents="none",u.style.opacity="0",u.style.animation=`${M} ${P} ${R}`,u.id=_e,u.style.zIndex="9999",document.body.appendChild(u),this._currentDrag.element=u;const _=t.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:d,clientY:m}=L(t,this._firefoxDragPosition);this._currentDrag.offset.x=d-_.left,this._currentDrag.offset.y=m-_.top,u.style.top=m+"px",u.style.left=d+"px",t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(h,0,0)}const{x:r,y:a}=W(s,this._currentDrag.event||t,this._firefoxDragPosition),o=Math.max(1,r),c=Math.max(1,a);A(this._instance)&&this._instance.dragInObject(e,o,c)}dragUpdate(e){var t,s;const n=this._iframe.parentNode,{x:r,y:a}=W(n,e,this._firefoxDragPosition);if(r===0&&a===0)return;const o=Math.max(1,r),c=Math.max(1,a);if(this._currentDrag.element){const{clientX:h,clientY:u}=L(e,this._firefoxDragPosition),_=((t=this._currentDrag.offset)==null?void 0:t.x)||0,d=((s=this._currentDrag.offset)==null?void 0:s.y)||0;this._currentDrag.element.style.left=`${h-_}px`,this._currentDrag.element.style.top=`${u-d}px`;const m=(this.options.dragInOverlapX||0)+1,p=(this.options.dragInOverlapY||0)+1;o>m&&c>p?this._currentDrag.element.style.animation=`${z} ${P} ${R}`:this._currentDrag.element.style.animation=`${M} ${P} ${R}`}o===1&&c===1||A(this._instance)&&this._instance.updateDrag(o,c)}dragEnd(){this._iframe.style.pointerEvents="all";const e=this._iframe.parentNode;A(this._instance)&&this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+w);t&&t.classList.add(N.DISPLAY_NONE)}touchStart(e,t){t.preventDefault();const s=(n,r)=>{this.dragStart(e,r)};this._currentTouch=new me(void 0,{onTouchDragStart:s}),this._currentTouch.onTouchStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onTouchMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onTouchEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}}const pe=Object.freeze(Object.defineProperty({__proto__:null,DragIn:fe},Symbol.toStringTag,{value:"Module"}));return ce});
12
+ @keyframes ${M} {from{opacity: 0;}to {opacity: ${V};}}
13
+ @keyframes ${J} {from{opacity: ${V};}to {opacity: 0;}}
14
+ `,document.head.appendChild(e)}}_initializeDragGhost(){const e=this._iframe.parentNode;let t=e.querySelector("."+b);t||(t=document.createElement("div"),t.classList.add(b),t.innerText=" ",e.appendChild(t))}setInstance(e){this._instance=e}dragStart(e,t){const s=this._iframe.parentNode;if(v(s).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._iframe.style.pointerEvents="none";let n=s.querySelector("."+w);n||(n=document.createElement("div"),n.classList.add(w),s.appendChild(n)),n.classList.remove(N.DISPLAY_NONE),t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const o=s.querySelector("."+b);this._currentDrag.event=t;const r=t.target.cloneNode();r.style.position="fixed",r.style.pointerEvents="none",r.style.opacity="0",r.style.animation=`${M} ${P} ${R}`,r.id=_e,r.style.zIndex="9999",document.body.appendChild(r),this._currentDrag.element=r;const a=t.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:l,clientY:h}=L(t,this._firefoxDragPosition);this._currentDrag.offset.x=l-a.left,this._currentDrag.offset.y=h-a.top,r.style.top=h+"px",r.style.left=l+"px",t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(o,0,0);const{x:u,y:d}=z(s,this._currentDrag.event||t,this._firefoxDragPosition),g=Math.max(1,u),f=Math.max(1,d);C(this._instance)&&this._instance.dragInObject(e,g,f)}dragUpdate(e){var t,s;const n=this._iframe.parentNode,{x:o,y:r}=z(n,e,this._firefoxDragPosition);if(o===0&&r===0)return;const a=Math.max(1,o),l=Math.max(1,r);if(this._currentDrag.element){const{clientX:h,clientY:u}=L(e,this._firefoxDragPosition),d=((t=this._currentDrag.offset)==null?void 0:t.x)||0,g=((s=this._currentDrag.offset)==null?void 0:s.y)||0;this._currentDrag.element.style.left=`${h-d}px`,this._currentDrag.element.style.top=`${u-g}px`;const f=(this.options.dragInOverlapX||0)+1,p=(this.options.dragInOverlapY||0)+1;a>f&&l>p?this._currentDrag.element.style.animation=`${J} ${P} ${R}`:this._currentDrag.element.style.animation=`${M} ${P} ${R}`}if(!(a===1&&l===1)&&C(this._instance)){let h=a,u=l;if(B(e)){const d=this.options.fingerSize||0;h=Math.max(2,a+d),u=Math.max(2,l-d)}this._instance.updateDrag(h,u)}}dragEnd(){this._iframe.style.pointerEvents="all";const e=this._iframe.parentNode;C(this._instance)&&this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+w);t&&t.classList.add(N.DISPLAY_NONE)}touchStart(e,t){var s,n;t.preventDefault();const o=(a,l)=>{this.dragStart(e,l)},r={};(s=this.options)!=null&&s.touchDragDelay&&(r.delay=this.options.touchDragDelay),(n=this.options)!=null&&n.touchDragEpsilon&&(r.epsilon=this.options.touchDragEpsilon),this._currentTouch=new fe(void 0,{onTouchDragStart:o},r),this._currentTouch.onTouchStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onTouchMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onTouchEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}}const ye=Object.freeze(Object.defineProperty({__proto__:null,DragIn:pe},Symbol.toStringTag,{value:"Module"}));return de});
@@ -1,7 +0,0 @@
1
- var X=Object.defineProperty,Y=(i,t,e)=>t in i?X(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,a=(i,t,e)=>Y(i,typeof t!="symbol"?t+"":t,e);class O{constructor(t=16){a(this,"_computedStyleCache",new Map),a(this,"_maxLifetime",16),a(this,"_cacheCleanInterval",null),this._maxLifetime=t}get(t){const e=this._computedStyleCache.get(t),n=Date.now();if(e&&n-e.updated<this._maxLifetime)return e.style;const r=getComputedStyle(t);return this._computedStyleCache.set(t,{style:r,updated:n}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_cleanUpCache(){const t=Date.now();for(const[e,{updated:n}]of this._computedStyleCache.entries())t-n>=this._maxLifetime&&this._computedStyleCache.delete(e);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}let y;const g=i=>(y||(y=new O),y.get(i)),b=(i,t,e)=>{const n=parseFloat(i),r=window.devicePixelRatio||1;if(t==="px")return n;if(t==="%"){const o=e===document.documentElement?window.innerWidth:e.offsetWidth;return n/100*o}if(t==="rem"){const o=parseFloat(g(document.documentElement).fontSize);return n*o}if(t==="em"){const o=parseFloat(g(e).fontSize);return n*o}if(t==="vh"||t==="vw"||t==="vmin"||t==="vmax"){const o={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return n/100*o[t]}const s={cm:37.7952755906,mm:3.77952755906,in:96};return t in s?n*s[t]*r:0},E=(i,t,e={x:0,y:0})=>{const n=i.getBoundingClientRect(),r=g(i).transform;let s=0,o=0;if(r!=="none"){const d=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,h=r.match(d);h&&(s=b(h[1],h[2],i),o=b(h[3],h[4],i))}const{clientX:l,clientY:u}=v(t,e),_=l-n.left-s+i.scrollLeft,c=u-n.top-o+i.scrollTop;return{x:_,y:c}},v=(i,t)=>{const{clientX:e,clientY:n}=window.TouchEvent&&i instanceof TouchEvent?P(i):i,r=e||t.x,s=n||t.y;return{clientX:r,clientY:s}},P=i=>{if(i.touches.length){let{clientX:e,clientY:n}=i.touches[0];if(i.touches.length>1){const r=i.touches[1],s=r.clientX,o=r.clientY;e=(e+s)/2,n=(n+o)/2}return{clientX:e,clientY:n}}const t=i.changedTouches[0];return{clientX:t.clientX,clientY:t.clientY}},N=500,M=10;class k{constructor(t,{onTouchDragStart:e},n={}){a(this,"_touchDragTimeOut"),a(this,"_onTouchDragStart"),a(this,"_payload",null),a(this,"_delay"),a(this,"_firstTouch",null),a(this,"_lastTouch",null),this._payload=t,this._onTouchDragStart=e,this._delay=n.delay||N}onTouchStart(t){var e;!t||!((e=t?.touches)!=null&&e.length)||this._touchDragTimeOut||(this._firstTouch=t.touches[t.touches.length-1],this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=t.touches[0]),this._checkXDistance(t)()},this._delay))}onTouchEnd(){this._resetTouches()}onTouchMove(t){var e;!t||!((e=t?.touches)!=null&&e.length)||(this._lastTouch=t.touches[0])}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(t){return()=>{if(!this._firstTouch||!this._lastTouch)return;let e=!1;e=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<M,e&&(this._onTouchDragStart(this._payload,t),this._resetTouches())}}}const I="rml-drag-in-styles",F="rml-drag-in-drag-element",m="rml-drag-in-overlay",p="rml-drag-in-drag-ghost",x="rml-drag-in-fade-in",C="rml-drag-in-fade-out",D={DISPLAY_NONE:"rml-display-none"},$=.5,T="250ms",w="forwards",S=i=>i?!0:(console.warn("No instance set, cancel drag-in"),!1);class z{constructor(t){if(a(this,"_iframe"),a(this,"_currentDrag",{}),a(this,"_currentTouch",null),a(this,"_firefoxDragPosition",{x:0,y:0}),a(this,"_instance",null),a(this,"options",{}),a(this,"_firefoxFallback",r=>{if(!this._currentDrag.event)return;const s=r||window.event;this._firefoxDragPosition.x=s.pageX||0,this._firefoxDragPosition.y=s.pageY||0}),this._iframe=t,!document.getElementById(I)){const r=document.createElement("style");r.type="text/css",r.id=I,r.innerHTML=`
2
- .${D.DISPLAY_NONE}{display:none}
3
- .${m}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
4
- .${p}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
5
- @keyframes ${x} {from{opacity: 0;}to {opacity: ${$};}}
6
- @keyframes ${C} {from{opacity: ${$};}to {opacity: 0;}}
7
- `,document.head.appendChild(r)}const e=this._iframe.parentNode;let n=e.querySelector("."+p);n||(n=document.createElement("div"),n.classList.add(p),n.innerText=" ",e.appendChild(n)),this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}setInstance(t){this._instance=t}dragStart(t,e){const n=this._iframe.parentNode;if(g(n).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._iframe.style.pointerEvents="none";let r=n.querySelector("."+m);if(r||(r=document.createElement("div"),r.classList.add(m),n.appendChild(r)),r.classList.remove(D.DISPLAY_NONE),e instanceof DragEvent){e.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const _=n.querySelector("."+p);this._currentDrag.event=e;const c=e.target.cloneNode();c.style.position="fixed",c.style.pointerEvents="none",c.style.opacity="0",c.style.animation=`${x} ${T} ${w}`,c.id=F,c.style.zIndex="9999",document.body.appendChild(c),this._currentDrag.element=c;const d=e.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:h,clientY:f}=v(e,this._firefoxDragPosition);this._currentDrag.offset.x=h-d.left,this._currentDrag.offset.y=f-d.top,c.style.top=f+"px",c.style.left=h+"px",e.dataTransfer&&e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(_,0,0)}const{x:s,y:o}=E(n,this._currentDrag.event||e,this._firefoxDragPosition),l=Math.max(1,s),u=Math.max(1,o);S(this._instance)&&this._instance.dragInObject(t,l,u)}dragUpdate(t){var e,n;const r=this._iframe.parentNode,{x:s,y:o}=E(r,t,this._firefoxDragPosition);if(s===0&&o===0)return;const l=Math.max(1,s),u=Math.max(1,o);if(this._currentDrag.element){const{clientX:_,clientY:c}=v(t,this._firefoxDragPosition),d=((e=this._currentDrag.offset)==null?void 0:e.x)||0,h=((n=this._currentDrag.offset)==null?void 0:n.y)||0;this._currentDrag.element.style.left=`${_-d}px`,this._currentDrag.element.style.top=`${c-h}px`;const f=(this.options.dragInOverlapX||0)+1,L=(this.options.dragInOverlapY||0)+1;l>f&&u>L?this._currentDrag.element.style.animation=`${C} ${T} ${w}`:this._currentDrag.element.style.animation=`${x} ${T} ${w}`}l===1&&u===1||S(this._instance)&&this._instance.updateDrag(l,u)}dragEnd(){this._iframe.style.pointerEvents="all";const t=this._iframe.parentNode;S(this._instance)&&this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const e=t.querySelector("."+m);e&&e.classList.add(D.DISPLAY_NONE)}touchStart(t,e){e.preventDefault();const n=(r,s)=>{this.dragStart(t,s)};this._currentTouch=new k(void 0,{onTouchDragStart:n}),this._currentTouch.onTouchStart(e)}touchMove(t){this._currentTouch&&this._currentTouch.onTouchMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this._currentTouch&&this._currentTouch.onTouchEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}}export{z as DragIn};
@@ -1,250 +0,0 @@
1
- var M = Object.defineProperty;
2
- var X = (i, t, e) => t in i ? M(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var a = (i, t, e) => X(i, typeof t != "symbol" ? t + "" : t, e);
4
- class b {
5
- constructor(t = 16) {
6
- a(this, "_computedStyleCache", /* @__PURE__ */ new Map());
7
- a(this, "_maxLifetime", 16);
8
- a(this, "_cacheCleanInterval", null);
9
- this._maxLifetime = t;
10
- }
11
- get(t) {
12
- const e = this._computedStyleCache.get(t), n = Date.now();
13
- if (e && n - e.updated < this._maxLifetime)
14
- return e.style;
15
- const s = getComputedStyle(t);
16
- return this._computedStyleCache.set(t, { style: s, updated: n }), this._cacheCleanInterval || (this._cacheCleanInterval = setInterval(
17
- () => this._cleanUpCache,
18
- Math.max(this._maxLifetime * 1e3, 5e3)
19
- )), s;
20
- }
21
- _cleanUpCache() {
22
- const t = Date.now();
23
- for (const [e, { updated: n }] of this._computedStyleCache.entries())
24
- t - n >= this._maxLifetime && this._computedStyleCache.delete(e);
25
- this._computedStyleCache.size === 0 && this._cacheCleanInterval && (clearInterval(this._cacheCleanInterval), this._cacheCleanInterval = null);
26
- }
27
- }
28
- let T;
29
- const y = (i) => (T || (T = new b()), T.get(i)), A = (i, t, e) => {
30
- const n = parseFloat(i), s = window.devicePixelRatio || 1;
31
- if (t === "px")
32
- return n;
33
- if (t === "%") {
34
- const o = e === document.documentElement ? window.innerWidth : e.offsetWidth;
35
- return n / 100 * o;
36
- }
37
- if (t === "rem") {
38
- const o = parseFloat(
39
- y(document.documentElement).fontSize
40
- );
41
- return n * o;
42
- }
43
- if (t === "em") {
44
- const o = parseFloat(
45
- y(e).fontSize
46
- );
47
- return n * o;
48
- }
49
- if (t === "vh" || t === "vw" || t === "vmin" || t === "vmax") {
50
- const o = {
51
- vh: window.innerHeight,
52
- vw: window.innerWidth,
53
- vmin: Math.min(window.innerWidth, window.innerHeight),
54
- vmax: Math.max(window.innerWidth, window.innerHeight)
55
- };
56
- return n / 100 * o[t];
57
- }
58
- const r = {
59
- cm: 37.7952755906,
60
- mm: 3.77952755906,
61
- in: 96
62
- };
63
- return t in r ? n * r[t] * s : 0;
64
- }, N = (i, t, e = { x: 0, y: 0 }) => {
65
- const n = i.getBoundingClientRect(), r = y(i).transform;
66
- let o = 0, h = 0;
67
- if (r !== "none") {
68
- const c = /translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/, l = r.match(c);
69
- l && (o = A(l[1], l[2], i), h = A(l[3], l[4], i));
70
- }
71
- const { clientX: u, clientY: d } = E(t, e), f = u - n.left - o + i.scrollLeft, _ = d - n.top - h + i.scrollTop;
72
- return { x: f, y: _ };
73
- }, E = (i, t) => {
74
- const { clientX: e, clientY: n } = window.TouchEvent && i instanceof TouchEvent ? R(i) : i, s = e || t.x, r = n || t.y;
75
- return { clientX: s, clientY: r };
76
- }, R = (i) => {
77
- if (i.touches.length) {
78
- let { clientX: e, clientY: n } = i.touches[0];
79
- if (i.touches.length > 1) {
80
- const s = i.touches[1], r = s.clientX, o = s.clientY;
81
- e = (e + r) / 2, n = (n + o) / 2;
82
- }
83
- return { clientX: e, clientY: n };
84
- }
85
- const t = i.changedTouches[0];
86
- return { clientX: t.clientX, clientY: t.clientY };
87
- }, v = 500, P = 10;
88
- class $ {
89
- constructor(t, { onTouchDragStart: e }, n = {}) {
90
- a(this, "_touchDragTimeOut");
91
- a(this, "_onTouchDragStart");
92
- a(this, "_payload", null);
93
- a(this, "_delay");
94
- a(this, "_firstTouch", null);
95
- a(this, "_lastTouch", null);
96
- this._payload = t, this._onTouchDragStart = e, this._delay = n.delay || v;
97
- }
98
- onTouchStart(t) {
99
- var e;
100
- !t || !((e = t == null ? void 0 : t.touches) != null && e.length) || this._touchDragTimeOut || (this._firstTouch = t.touches[t.touches.length - 1], this._touchDragTimeOut = setTimeout(() => {
101
- this._clearTimeout(), this._lastTouch || (this._lastTouch = t.touches[0]), this._checkXDistance(t)();
102
- }, this._delay));
103
- }
104
- onTouchEnd() {
105
- this._resetTouches();
106
- }
107
- onTouchMove(t) {
108
- var e;
109
- !t || !((e = t == null ? void 0 : t.touches) != null && e.length) || (this._lastTouch = t.touches[0]);
110
- }
111
- _clearTimeout() {
112
- this._touchDragTimeOut && (clearTimeout(this._touchDragTimeOut), this._touchDragTimeOut = null);
113
- }
114
- _resetTouches() {
115
- this._clearTimeout(), this._lastTouch = null, this._firstTouch = null, this._payload = null;
116
- }
117
- _checkXDistance(t) {
118
- return () => {
119
- if (!this._firstTouch || !this._lastTouch)
120
- return;
121
- let e = !1;
122
- e = Math.abs(
123
- this._firstTouch.clientX - this._lastTouch.clientX
124
- ) < P, e && (this._onTouchDragStart(this._payload, t), this._resetTouches());
125
- };
126
- }
127
- }
128
- const L = "rml-drag-in-styles", G = "rml-drag-in-drag-element", m = "rml-drag-in-overlay", p = "rml-drag-in-drag-ghost", D = "rml-drag-in-fade-in", O = "rml-drag-in-fade-out", x = {
129
- DISPLAY_NONE: "rml-display-none"
130
- }, Y = 0.5, S = "250ms", I = "forwards", C = (i) => i ? !0 : (console.warn("No instance set, cancel drag-in"), !1);
131
- class U {
132
- constructor(t) {
133
- a(this, "_iframe");
134
- a(this, "_currentDrag", {});
135
- a(this, "_currentTouch", null);
136
- a(this, "_firefoxDragPosition", { x: 0, y: 0 });
137
- a(this, "_instance", null);
138
- a(this, "options", {});
139
- a(this, "_firefoxFallback", (t) => {
140
- if (!this._currentDrag.event)
141
- return;
142
- const e = t || window.event;
143
- this._firefoxDragPosition.x = e.pageX || 0, this._firefoxDragPosition.y = e.pageY || 0;
144
- });
145
- if (this._iframe = t, !!!document.getElementById(L)) {
146
- const r = document.createElement("style");
147
- r.type = "text/css", r.id = L, r.innerHTML = `
148
- .${x.DISPLAY_NONE}{display:none}
149
- .${m}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
150
- .${p}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
151
- @keyframes ${D} {from{opacity: 0;}to {opacity: ${Y};}}
152
- @keyframes ${O} {from{opacity: ${Y};}to {opacity: 0;}}
153
- `, document.head.appendChild(r);
154
- }
155
- const n = this._iframe.parentNode;
156
- let s = n.querySelector(
157
- "." + p
158
- );
159
- s || (s = document.createElement("div"), s.classList.add(p), s.innerText = " ", n.appendChild(s)), this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback);
160
- }
161
- setInstance(t) {
162
- this._instance = t;
163
- }
164
- dragStart(t, e) {
165
- const n = this._iframe.parentNode;
166
- if (y(n).position !== "relative") {
167
- console.warn(
168
- "Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly"
169
- );
170
- return;
171
- }
172
- this._iframe.style.pointerEvents = "none";
173
- let r = n.querySelector(
174
- "." + m
175
- );
176
- if (r || (r = document.createElement("div"), r.classList.add(m), n.appendChild(r)), r.classList.remove(x.DISPLAY_NONE), e instanceof DragEvent) {
177
- e.target.getAttribute(
178
- "draggable"
179
- ) || console.warn(
180
- `Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`
181
- );
182
- const _ = n.querySelector(
183
- "." + p
184
- );
185
- this._currentDrag.event = e;
186
- const c = e.target.cloneNode();
187
- c.style.position = "fixed", c.style.pointerEvents = "none", c.style.opacity = "0", c.style.animation = `${D} ${S} ${I}`, c.id = G, c.style.zIndex = "9999", document.body.appendChild(c), this._currentDrag.element = c;
188
- const l = e.target.getBoundingClientRect();
189
- this._currentDrag.offset || (this._currentDrag.offset = { x: 0, y: 0 });
190
- const { clientX: g, clientY: w } = E(
191
- e,
192
- this._firefoxDragPosition
193
- );
194
- this._currentDrag.offset.x = g - l.left, this._currentDrag.offset.y = w - l.top, c.style.top = w + "px", c.style.left = g + "px", e.dataTransfer && e.dataTransfer.setDragImage && e.dataTransfer.setDragImage(_, 0, 0);
195
- }
196
- const { x: o, y: h } = N(
197
- n,
198
- this._currentDrag.event || e,
199
- this._firefoxDragPosition
200
- ), u = Math.max(1, o), d = Math.max(1, h);
201
- C(this._instance) && this._instance.dragInObject(t, u, d);
202
- }
203
- dragUpdate(t) {
204
- var h, u;
205
- const e = this._iframe.parentNode, { x: n, y: s } = N(e, t, this._firefoxDragPosition);
206
- if (n === 0 && s === 0)
207
- return;
208
- const r = Math.max(1, n), o = Math.max(1, s);
209
- if (this._currentDrag.element) {
210
- const { clientX: d, clientY: f } = E(
211
- t,
212
- this._firefoxDragPosition
213
- ), _ = ((h = this._currentDrag.offset) == null ? void 0 : h.x) || 0, c = ((u = this._currentDrag.offset) == null ? void 0 : u.y) || 0;
214
- this._currentDrag.element.style.left = `${d - _}px`, this._currentDrag.element.style.top = `${f - c}px`;
215
- const l = (this.options.dragInOverlapX || 0) + 1, g = (this.options.dragInOverlapY || 0) + 1;
216
- r > l && o > g ? this._currentDrag.element.style.animation = `${O} ${S} ${I}` : this._currentDrag.element.style.animation = `${D} ${S} ${I}`;
217
- }
218
- r === 1 && o === 1 || C(this._instance) && this._instance.updateDrag(r, o);
219
- }
220
- dragEnd() {
221
- this._iframe.style.pointerEvents = "all";
222
- const t = this._iframe.parentNode;
223
- C(this._instance) && this._instance.dragInObjectEnd(), this._currentDrag.element && document.body.removeChild(this._currentDrag.element), this._currentDrag = {}, this._firefoxDragPosition = { x: 0, y: 0 };
224
- const e = t.querySelector(
225
- "." + m
226
- );
227
- e && e.classList.add(x.DISPLAY_NONE);
228
- }
229
- touchStart(t, e) {
230
- e.preventDefault();
231
- const n = (s, r) => {
232
- this.dragStart(t, r);
233
- };
234
- this._currentTouch = new $(void 0, {
235
- onTouchDragStart: n
236
- }), this._currentTouch.onTouchStart(e);
237
- }
238
- touchMove(t) {
239
- this._currentTouch && this._currentTouch.onTouchMove(t), this._currentDrag.event && this.dragUpdate(t);
240
- }
241
- touchEnd() {
242
- this._currentTouch && this._currentTouch.onTouchEnd(), this._currentTouch = null, this.dragEnd();
243
- }
244
- dispose() {
245
- document.removeEventListener("dragover", this._firefoxFallback);
246
- }
247
- }
248
- export {
249
- U as DragIn
250
- };