@roomle/embedding-lib 5.6.0-alpha.1 → 5.6.0-debug.1
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.
- package/docs/md/web/embedding/CHANGELOG.md +26 -1
- package/drag-in-BZZo-kSu.mjs +513 -0
- package/drag-in-Buavf-ZW.mjs +7 -0
- package/index.d.ts +104 -40
- package/package.json +2 -2
- package/roomle-embedding-lib.es.js +353 -278
- package/roomle-embedding-lib.es.min.js +8 -8
- package/roomle-embedding-lib.umd.js +12 -12
- package/roomle-embedding-lib.umd.min.js +13 -13
- package/drag-in-BKrnFtmJ.mjs +0 -7
- package/drag-in-DC-05b4s.mjs +0 -265
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
.${
|
|
3
|
-
.${
|
|
4
|
-
.${
|
|
5
|
-
.${
|
|
6
|
-
.${
|
|
7
|
-
.${
|
|
8
|
-
`,document.head.appendChild(
|
|
1
|
+
var H=Object.defineProperty,A=(r,e,t)=>e in r?H(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c=(r,e,t)=>A(r,typeof e!="symbol"?e+"":e,t);class b{constructor(e,t,s,i){c(this,"_side"),c(this,"_incomingMessageBus",null),c(this,"_outgoingMessageBus",null),c(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=i,this._incomingMessageBus&&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,i)=>{const n=new MessageChannel;n.port1.onmessage=o=>{if(!o||!o.data)return n.port1.close(),n.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let l;try{l=JSON.parse(o.data)}catch(u){return n.port1.close(),n.port2.close(),this._prepareError(u),i(u)}l.error?i(l.error):l.result!==void 0?s(l.result):s(void 0),n.port1.close(),n.port2.close()};let a="";try{a=JSON.stringify({message:e,args:t})}catch{return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(a,"*",[n.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 i=this._execMessage(s,e);if(i===void 0)return;i.then((n={})=>{let a,o;typeof n=="object"&&n!==null&&(a=n.error,o=n.result),a?t.postMessage(JSON.stringify({error:a})):o!==void 0?t.postMessage(JSON.stringify({result:o})):t.postMessage(JSON.stringify({result:n}))},n=>{t.postMessage(JSON.stringify({error:this._prepareError(n)}))})}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 p=".",f={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},U=async(r,e)=>{if(typeof r!="string")throw new Error('Configurator ID is not a string type: "'+typeof r+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,i=t+"/configurators/"+r,n="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+n),o=()=>{const h={apiKey:n,currentTenant:s,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(h)},l=new Request(i,{method:"GET",headers:o(),mode:"cors",cache:"default"}),u=await fetch(l),{configurator:d}=await u.json();return d},F=()=>{try{return window.self!==window.top}catch{return!0}},B=["127.0.0.1","localhost","0.0.0.0"],x=()=>{const r=F();let e=window.location.href;if(r){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},C=r=>!!(B.includes(r)||r.endsWith("roomle.com")||r.endsWith("gitlab.io")||r.endsWith("gitlab.com")),I=["language","browserLanguage","userLanguage","systemLanguage"],W=(r=null)=>{const e=window.navigator;if(r)return r.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=I.length;t<s;t++){const i=e[I[t]];if(i)return i.substr(0,2)}return"en"},k=(r,e)=>{const t=JSON.parse(JSON.stringify(r));return w(t,e)},w=(r,e)=>{for(const t in e)try{e[t].constructor===Object?r[t]=w(r[t],e[t]):r[t]=e[t]}catch{r[t]=e[t]}return r};var V={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const G={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},rotationSnapDegrees:10},J="(idle)",$=r=>(E(r),r!=null&&r.customApiUrl&&(r.customApiUrl=decodeURIComponent(r.customApiUrl)),r.shareUrl&&(r.deeplink=r.shareUrl.replace(q,Y)),r),E=r=>{if(!r)return;const e=Object.keys(r);for(const t of e){const s=r[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&E(s),Array.isArray(s))for(const i of s)E(i);(s==="true"||s==="false")&&(r[t]=s==="true")}},j=(r,e)=>{e.configuratorId=r.id;const t=r.settings||{};return!e.overrideTenant&&r.tenant&&(e.overrideTenant=r.tenant),k(t,e)},z=()=>{const r={...G};r.locale||(r.locale=W()),r.id===J&&delete r.id;const e=x();return e&&C(e)&&(r.configuratorId="demoConfigurator"),r.customApiUrl=V.VITE_RAPI_URL,r.emails=!1,r},q="<CONF_ID>",Y="#CONFIGURATIONID#",M=()=>/(android)/i.test(navigator.userAgent);class v{constructor(){c(this,"_messageHandler",null),c(this,"isSetupDone",!1),c(this,"viewName","main"),c(this,"plugins",{}),c(this,"pluginsLoaded",[]),c(this,"ui",{callbacks:null}),c(this,"extended",{callbacks:null}),c(this,"configurator",{callbacks:null}),c(this,"analytics",{callbacks:{}}),c(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(i=>{const n=i.split(p),a=n[0],o=n[1];this[a]||(this[a]={}),this[a][o]=function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(i,[...arguments])}.bind(this)}),s.forEach(i=>{const n=i.split(p),a=n[0],o=n[1],l=n[2];this[a]||(this[a]={}),this[a][o]||(this[a][o]={}),this[a][o][l]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(p),i=s[0],n=s[1],a=s.length===3?s[2]:null;if(a&&this[i][n][a]){const o=this[i][n][a](...t);return o instanceof Promise?o.then(l=>({result:l})):o!==void 0?Promise.resolve({result:o}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const i of e)typeof i=="string"&&i==="dragIn"?this.pluginsLoaded.push(new Promise((n,a)=>{try{import("./drag-in-Buavf-ZW.mjs").then(({DragIn:o})=>{const l=new o(this.ui,t,s,this.viewName);this.plugins.dragIn=l,n()})}catch(o){a(o)}})):i.name&&i.loader&&this.pluginsLoaded.push(new Promise((n,a)=>{try{i.loader().then(o=>{const l=new o(this.ui,t,s,this.viewName);this.plugins[i.name]=l,n()})}catch(o){a(o)}}))}}const T=()=>{let r,e;return{promise:new Promise((t,s)=>{r=t,e=s}),resolve:r,reject:e}},S=(r,e,t)=>{let s=null;Object.defineProperty(r,e,{get(){return s||t},set(i){i!=null&&i.mute?s=i.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=i)}})},R=()=>window.innerHeight*.01+"px",D=r=>{r&&setTimeout(()=>r.style.setProperty(y,R()),0)},N="rml-styles",Q=450,y="--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"},O=new Map;class K extends v{constructor(e,t,s,i,n){if(super(),c(this,"_waitForIframe"),c(this,"_container"),c(this,"_configuratorSettings"),c(this,"_initData",{}),c(this,"_iframe"),!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(N)){const l=s.zIndex||9999999,u=document.createElement("style");u.type="text/css",u.id=N;const d="transition:all ease-in-out "+Q+"ms;",h=["-webkit-","-o-"].reduce((L,P)=>L+=P+d,"")+d,m=R();u.innerHTML=`
|
|
2
|
+
.${g.CONTAINER}{${y}:${m};}
|
|
3
|
+
.${g.POSITION}{position:fixed;top:0;left:0;z-index:${l};opacity:0}
|
|
4
|
+
.${g.TRANSITION}{${h}}
|
|
5
|
+
.${g.FILL}{width:100%;height:100%;opacity:1}
|
|
6
|
+
.${g.ANDROID_HEIGHT}{height:calc(var(${y},1vh)*100)}
|
|
7
|
+
.${g.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
8
|
+
`,document.head.appendChild(u)}this._executeMessage=this._executeMessage.bind(this);const a=new b("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),M()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=n,this._container.appendChild(o),this._iframe=o,this.setupPlugins(i,this._iframe),O.set(t,!0)}static createPlanner(e,t,s,i=[]){return this._create(e,t,s,i)}static async connect(e,t=[]){const s=new v;s.viewName=e;const{resolve:i,promise:n}=T(),{resolve:a,promise:o}=T(),l=({message:h,args:m})=>{if(h===_.REGISTER_CUSTOM_VIEW_DONE){i();return}if(h===_.RETURN_METHODS){s.handleSetup(m[0]),a();return}if(s.isSetupDone)return s.executeMessage({message:h,args:m})},u=new b("custom-view-"+e,window,window.parent,l);s.setMessageHandler(u);const d=[e];return u.sendMessage(_.REGISTER_CUSTOM_VIEW,d),await n,u.sendMessage(_.GET_METHODS,d),await o,s.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(e,t,s,i=[]){return this._create(e,t,s,i)}static create(e,t,s,i){return this._create(e,t,s,i)}static createViewer(e,t,s,i=[]){return this._create(e,t,s,i)}static async _create(e,t,s,i){return new Promise(async(n,a)=>{try{const o=w(z(),$(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 l=await U(e,o);s=j(l,o);const u=new this(l,t,s,i,n);return console.info(u),await Promise.allSettled(u.pluginsLoaded),u}catch(o){return a(o)}})}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(g.CONTAINER),t.classList.add(g.FILL),t}_onResize(){D(this._iframe)}_onUseFullPage(){this._iframe.classList.add(g.POSITION),document.documentElement.classList.add(g.OVERFLOW_HIDDEN),window.document.body.classList.add(g.OVERFLOW_HIDDEN),M()&&(D(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 i;if(s.source&&s.source===((i=this._iframe)==null?void 0:i.contentWindow))return e===f.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):e===f.SETUP?(this.handleSetup(t[0]),S(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),S(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(f.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{K as default};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
.${_.CONTAINER}{${
|
|
3
|
-
.${_.POSITION}{position:fixed;top:0;left:0;z-index:${
|
|
4
|
-
.${_.TRANSITION}{${
|
|
1
|
+
(function(g,f){typeof exports=="object"&&typeof module<"u"?module.exports=f():typeof define=="function"&&define.amd?define(f):(g=typeof globalThis<"u"?globalThis:g||self,g["roomle-embedding-lib"]=g["roomle-embedding-lib"]||{},g["roomle-embedding-lib"].umd=g["roomle-embedding-lib"].umd||{},g["roomle-embedding-lib"].umd.js=f())})(this,function(){"use strict";var Wt=Object.defineProperty;var kt=(g,f,y)=>f in g?Wt(g,f,{enumerable:!0,configurable:!0,writable:!0,value:y}):g[f]=y;var a=(g,f,y)=>kt(g,typeof f!="symbol"?f+"":f,y);class g{constructor(e,t,s,r){a(this,"_side");a(this,"_incomingMessageBus",null);a(this,"_outgoingMessageBus",null);a(this,"_execMessage",null);this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&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,r)=>{const i=new MessageChannel;i.port1.onmessage=c=>{if(!c||!c.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let l;try{l=JSON.parse(c.data)}catch(u){return i.port1.close(),i.port2.close(),this._prepareError(u),r(u)}l.error?r(l.error):l.result!==void 0?s(l.result):s(void 0),i.port1.close(),i.port2.close()};let o="";try{o=JSON.stringify({message:e,args:t})}catch{return r(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return r(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(o,"*",[i.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 r=this._execMessage(s,e);if(r===void 0)return;r.then((i={})=>{let o,c;typeof i=="object"&&i!==null&&(o=i.error,c=i.result),o?t.postMessage(JSON.stringify({error:o})):c!==void 0?t.postMessage(JSON.stringify({result:c})):t.postMessage(JSON.stringify({result:i}))},i=>{t.postMessage(JSON.stringify({error:this._prepareError(i)}))})}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 f=".",y={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},I={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},ct=async(n,e)=>{if(typeof n!="string")throw new Error('Configurator ID is not a string type: "'+typeof n+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,r=t+"/configurators/"+n,i="roomle_portal_v2",o="03-"+window.btoa(new Date().toISOString()+";anonymous;"+i),c=()=>{const d={apiKey:i,currentTenant:s,locale:"en",language:"en",device:1,token:o,platform:"web"};return new Headers(d)},l=new Request(r,{method:"GET",headers:c(),mode:"cors",cache:"default"}),u=await fetch(l),{configurator:h}=await u.json();return h},lt=()=>{try{return window.self!==window.top}catch{return!0}},ut=["127.0.0.1","localhost","0.0.0.0"],ht=()=>{const n=lt();let e=window.location.href;if(n){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},dt=n=>!!(ut.includes(n)||n.endsWith("roomle.com")||n.endsWith("gitlab.io")||n.endsWith("gitlab.com")),F=["language","browserLanguage","userLanguage","systemLanguage"],gt=(n=null)=>{const e=window.navigator;if(n)return n.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,s=F.length;t<s;t++){const r=e[F[t]];if(r)return r.substr(0,2)}return"en"},_t=(n,e)=>{const t=JSON.parse(JSON.stringify(n));return M(t,e)},M=(n,e)=>{for(const t in e)try{e[t].constructor===Object?n[t]=M(n[t],e[t]):n[t]=e[t]}catch{n[t]=e[t]}return n};var mt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const ft={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},rotationSnapDegrees:10},pt="(idle)",yt=n=>(L(n),n!=null&&n.customApiUrl&&(n.customApiUrl=decodeURIComponent(n.customApiUrl)),n.shareUrl&&(n.deeplink=n.shareUrl.replace(St,Tt)),n),L=n=>{if(!n)return;const e=Object.keys(n);for(const t of e){const s=n[t];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&L(s),Array.isArray(s))for(const r of s)L(r);(s==="true"||s==="false")&&(n[t]=s==="true")}},Dt=(n,e)=>{e.configuratorId=n.id;const t=n.settings||{};return!e.overrideTenant&&n.tenant&&(e.overrideTenant=n.tenant),_t(t,e)},Et=()=>{const n={...ft};n.locale||(n.locale=gt()),n.id===pt&&delete n.id;const e=ht();return e&&dt(e)&&(n.configuratorId="demoConfigurator"),n.customApiUrl=mt.VITE_RAPI_URL,n.emails=!1,n},St="<CONF_ID>",Tt="#CONFIGURATIONID#",B=()=>/(android)/i.test(navigator.userAgent);class X{constructor(){a(this,"_messageHandler",null);a(this,"isSetupDone",!1);a(this,"viewName","main");a(this,"plugins",{});a(this,"pluginsLoaded",[]);a(this,"ui",{callbacks:null});a(this,"extended",{callbacks:null});a(this,"configurator",{callbacks:null});a(this,"analytics",{callbacks:{}});a(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(r=>{const i=r.split(f),o=i[0],c=i[1];this[o]||(this[o]={}),this[o][c]=(function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(r,[...arguments])}).bind(this)}),s.forEach(r=>{const i=r.split(f),o=i[0],c=i[1],l=i[2];this[o]||(this[o]={}),this[o][c]||(this[o][c]={}),this[o][c][l]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(f),r=s[0],i=s[1],o=s.length===3?s[2]:null;if(o&&this[r][i][o]){const c=this[r][i][o](...t);return c instanceof Promise?c.then(l=>({result:l})):c!==void 0?Promise.resolve({result:c}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)typeof r=="string"&&r==="dragIn"?this.pluginsLoaded.push(new Promise((i,o)=>{try{Promise.resolve().then(()=>Xt).then(({DragIn:c})=>{const l=new c(this.ui,t,s,this.viewName);this.plugins.dragIn=l,i()})}catch(c){o(c)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((i,o)=>{try{r.loader().then(c=>{const l=new c(this.ui,t,s,this.viewName);this.plugins[r.name]=l,i()})}catch(c){o(c)}}))}}const W=()=>{let n,e;return{promise:new Promise((s,r)=>{n=s,e=r}),resolve:n,reject:e}},k=(n,e,t)=>{let s=null;Object.defineProperty(n,e,{get(){return s||t},set(r){r!=null&&r.mute?s=r.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=r)}})},$=()=>window.innerHeight*.01+"px",z=n=>{n&&setTimeout(()=>n.style.setProperty(R,$()),0)},V="rml-styles",wt=450,R="--rml-full-height",_={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},v=new Map;class It extends X{constructor(t,s,r,i,o){super();a(this,"_waitForIframe");a(this,"_container");a(this,"_configuratorSettings");a(this,"_initData",{});a(this,"_iframe");if(!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(v.has(s))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(V)){const h=r.zIndex||9999999,d=document.createElement("style");d.type="text/css",d.id=V;const p="transition:all ease-in-out "+wt+"ms;",m=["-webkit-","-o-"].reduce((S,w)=>S+=w+p,"")+p,E=$();d.innerHTML=`
|
|
2
|
+
.${_.CONTAINER}{${R}:${E};}
|
|
3
|
+
.${_.POSITION}{position:fixed;top:0;left:0;z-index:${h};opacity:0}
|
|
4
|
+
.${_.TRANSITION}{${m}}
|
|
5
5
|
.${_.FILL}{width:100%;height:100%;opacity:1}
|
|
6
|
-
.${_.ANDROID_HEIGHT}{height:calc(var(${
|
|
6
|
+
.${_.ANDROID_HEIGHT}{height:calc(var(${R},1vh)*100)}
|
|
7
7
|
.${_.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
8
|
-
`,document.head.appendChild(i)}this._onResize=this._onResize.bind(this),F()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=r,this._configuratorSettings=e;const c=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new m("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(c),this._iframe=c;for(const u of n)typeof u=="string"&&u==="dragIn"?this.pluginsLoaded.push(new Promise((i,d)=>{try{Promise.resolve().then(()=>pe).then(({DragIn:h})=>{const f=new h(this._iframe);f.setInstance(this.ui),this.plugins.dragIn=f,i()})}catch(h){d(h)}})):u.name&&u.loader&&this.pluginsLoaded.push(new Promise((i,d)=>{try{u.loader().then(h=>{const f=new h(this._iframe);f.setInstance(this.ui),this.plugins[u.name]=f,i()})}catch(h){d(h)}}));O.set(t,!0)}static createPlanner(e,t,r,n=[]){return this._create(e,t,r,n)}static createConfigurator(e,t,r,n=[]){return this._create(e,t,r,n)}static create(e,t,r,n){return this._create(e,t,r,n)}static createViewer(e,t,r,n=[]){return this._create(e,t,r,n)}static async _create(e,t,r,n){return new Promise(async(o,a)=>{try{const c=S(ae(),oe(r));c.featureFlags||(c.featureFlags={}),typeof c.featureFlags.realPartList!="boolean"&&(c.featureFlags.realPartList=!0),typeof c.featureFlags.globalCallbacks!="boolean"&&(c.featureFlags.globalCallbacks=!0),typeof c.featureFlags.mocAr!="boolean"&&(c.featureFlags.mocAr=!1);const u=await q(e,c);r=ie(u,c);const i=new this(u,t,r,n,o);return console.info(i),await Promise.allSettled(i.pluginsLoaded),i}catch(c){return a(c)}})}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 r;const e=document.createElement("iframe");let t=((r=this._configuratorSettings)==null?void 0:r.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(t=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(t=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(t=this._initData.overrideServerUrl),e.src=t,e.classList.add(_.CONTAINER),e.classList.add(_.FILL),e}_onResize(){Y(this._iframe)}_onUseFullPage(){this._iframe.classList.add(_.POSITION),document.documentElement.classList.add(_.OVERFLOW_HIDDEN),window.document.body.classList.add(_.OVERFLOW_HIDDEN),F()&&(Y(this._iframe),this._iframe.classList.add(_.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(_.POSITION),this._iframe.classList.remove(_.ANDROID_HEIGHT),document.documentElement.classList.remove(_.OVERFLOW_HIDDEN),window.document.body.classList.remove(_.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var u;if(!r.source||r.source!==((u=this._iframe)==null?void 0:u.contentWindow))return;if(e===T.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===T.SETUP){const{methods:i,callbacks:d}=t[0];return i.forEach(h=>{const f=h.split(p),g=f[0],y=f[1];this[g]||(this[g]={}),this[g][y]=(function(){return this._messageHandler.sendMessage(h,[...arguments])}).bind(this)}),d.forEach(h=>{const f=h.split(p),g=f[0],y=f[1],v=f[2];this[g]||(this[g]={}),this[g][y]||(this[g][y]={}),this[g][y][v]=()=>{}}),H(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),H(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(T.WEBSITE_READY),0),Promise.resolve({result:null})}const n=e.split(p),o=n[0],a=n[1],c=n.length===3?n[2]:null;if(c&&this[o][a][c]){const i=this[o][a][c](...t);return i instanceof Promise?i.then(d=>({result:d})):i!==void 0?Promise.resolve({result:i}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}class de{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),r=Date.now();if(t&&r-t.updated<this._maxLifetime)return t.style;const n=getComputedStyle(e);return this._computedStyleCache.set(e,{style:n,updated:r}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),n}_cleanUpCache(){const e=Date.now();for(const[t,{updated:r}]of this._computedStyleCache.entries())e-r>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const B=s=>window.TouchEvent&&s instanceof window.TouchEvent;let b;const E=s=>(b||(b=new de),b.get(s)),$=(s,e,t)=>{const r=parseFloat(s),n=window.devicePixelRatio||1;if(e==="px")return r;if(e==="%"){const a=t===document.documentElement?window.innerWidth:t.offsetWidth;return r/100*a}if(e==="rem"){const a=parseFloat(E(document.documentElement).fontSize);return r*a}if(e==="em"){const a=parseFloat(E(t).fontSize);return r*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 r/100*a[e]}const o={cm:37.7952755906,mm:3.77952755906,in:96};return e in o?r*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)},G=(s,e,t={x:0,y:0})=>{const r=s.getBoundingClientRect(),o=E(s).transform;let a=0,c=0;if(o!=="none"){const f=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,g=o.match(f);g&&(a=$(g[1],g[2],s),c=$(g[3],g[4],s))}const{clientX:u,clientY:i}=L(e,t),d=u-r.left-a+s.scrollLeft,h=i-r.top-c+s.scrollTop;return{x:d,y:h}},L=(s,e)=>{const{clientX:t,clientY:r}=B(s)?fe(s):s,n=t||e.x,o=r||e.y;return{clientX:n,clientY:o}},fe=s=>{if(s.touches.length){let{clientX:t,clientY:r}=s.touches[0];if(s.touches.length>1){const n=s.touches[1],o=n.clientX,a=n.clientY;t=(t+o)/2,r=(r+a)/2}return{clientX:t,clientY:r}}const e=s.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},X=500,z=10;class ge{constructor(e,{onTouchDragStart:t},r={}){l(this,"_touchDragTimeOut");l(this,"_onTouchDragStart");l(this,"_payload",null);l(this,"_delay",X);l(this,"_firstTouch",null);l(this,"_lastTouch",null);l(this,"_epsilon",z);this._payload=e,this._onTouchDragStart=t,this._delay=r.delay||X,this._epsilon=r.epsilon||z}onTouchStart(e){var t;!e||!((t=e==null?void 0: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==null?void 0: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 W="rml-drag-in-styles",_e="rml-drag-in-drag-element",I="rml-drag-in-overlay",D="rml-drag-in-drag-ghost",N="rml-drag-in-fade-in",V="rml-drag-in-fade-out",R={DISPLAY_NONE:"rml-display-none"},J=.5,x="250ms",M="forwards",C=s=>s?!0:(console.warn("No instance set, cancel drag-in"),!1);class me{constructor(e){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",e=>{if(!this._currentDrag.event)return;const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});this._iframe=e,this._injectStyles(),this._initializeDragGhost(),this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}_injectStyles(){if(!!!document.getElementById(W)){const t=document.createElement("style");t.type="text/css",t.id=W,t.innerHTML=`
|
|
9
|
-
.${
|
|
10
|
-
.${
|
|
11
|
-
.${
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`,document.head.appendChild(
|
|
8
|
+
`,document.head.appendChild(d)}this._executeMessage=this._executeMessage.bind(this);const l=new g("website",window,null,this._executeMessage);this.setMessageHandler(l),this._onResize=this._onResize.bind(this),B()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=t;const u=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=o,this._container.appendChild(u),this._iframe=u,this.setupPlugins(i,this._iframe),v.set(s,!0)}static createPlanner(t,s,r,i=[]){return this._create(t,s,r,i)}static async connect(t,s=[]){const r=new X;r.viewName=t;const{resolve:i,promise:o}=W(),{resolve:c,promise:l}=W(),u=({message:p,args:m})=>{if(p===I.REGISTER_CUSTOM_VIEW_DONE){i();return}if(p===I.RETURN_METHODS){r.handleSetup(m[0]),c();return}if(r.isSetupDone)return r.executeMessage({message:p,args:m})},h=new g("custom-view-"+t,window,window.parent,u);r.setMessageHandler(h);const d=[t];return h.sendMessage(I.REGISTER_CUSTOM_VIEW,d),await o,h.sendMessage(I.GET_METHODS,d),await l,r.setupPlugins(s,document.body,"custom-view"),await Promise.allSettled(r.pluginsLoaded),r}static createConfigurator(t,s,r,i=[]){return this._create(t,s,r,i)}static create(t,s,r,i){return this._create(t,s,r,i)}static createViewer(t,s,r,i=[]){return this._create(t,s,r,i)}static async _create(t,s,r,i){return new Promise(async(o,c)=>{try{const l=M(Et(),yt(r));l.featureFlags||(l.featureFlags={}),typeof l.featureFlags.realPartList!="boolean"&&(l.featureFlags.realPartList=!0),typeof l.featureFlags.globalCallbacks!="boolean"&&(l.featureFlags.globalCallbacks=!0),typeof l.featureFlags.mocAr!="boolean"&&(l.featureFlags.mocAr=!1);const u=await ct(t,l);r=Dt(u,l);const h=new this(u,s,r,i,o);return console.info(h),await Promise.allSettled(h.pluginsLoaded),h}catch(l){return c(l)}})}teardown(){this._container&&v.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var r;const t=document.createElement("iframe");let s=((r=this._configuratorSettings)==null?void 0:r.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(_.CONTAINER),t.classList.add(_.FILL),t}_onResize(){z(this._iframe)}_onUseFullPage(){this._iframe.classList.add(_.POSITION),document.documentElement.classList.add(_.OVERFLOW_HIDDEN),window.document.body.classList.add(_.OVERFLOW_HIDDEN),B()&&(z(this._iframe),this._iframe.classList.add(_.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(_.POSITION),this._iframe.classList.remove(_.ANDROID_HEIGHT),document.documentElement.classList.remove(_.OVERFLOW_HIDDEN),window.document.body.classList.remove(_.OVERFLOW_HIDDEN)}_executeMessage({message:t,args:s},r){var i;if(r.source&&r.source===((i=this._iframe)==null?void 0:i.contentWindow))return t===y.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):t===y.SETUP?(this.handleSetup(s[0]),k(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),k(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(y.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:s})}}class bt{constructor(e,t,s,r){a(this,"_mainDomElement");a(this,"_instance",null);a(this,"_mode","website");a(this,"_viewName","main");this._instance=e,this._mainDomElement=t,this._mode=s,this._viewName=r}}const K="rml-drag-in-styles",At="rml-drag-in-drag-element",b="rml-drag-in-overlay",A="rml-drag-in-drag-ghost",q="rml-drag-in-fade-in",J="rml-drag-in-fade-out",N={DISPLAY_NONE:"rml-display-none"},j=.5,Q="250ms",Z="forwards",Ot=`@keyframes ${q} {from{opacity: 0;}to {opacity: ${j};}}`,Mt=`@keyframes ${J} {from{opacity: ${j};}to {opacity: 0;}}`,tt=`${q} ${Q} ${Z}`,Lt=`${J} ${Q} ${Z}`,C="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",Rt=112,vt=112;class Nt{constructor(e=16){a(this,"_computedStyleCache",new Map);a(this,"_maxLifetime",16);a(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 r=getComputedStyle(e);return this._computedStyleCache.set(e,{style:r,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_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 D=n=>window.TouchEvent&&n instanceof window.TouchEvent;let x;const O=n=>(x||(x=new Nt),x.get(n)),et=(n,e,t)=>{const s=parseFloat(n),r=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const o=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*o}if(e==="rem"){const o=parseFloat(O(document.documentElement).fontSize);return s*o}if(e==="em"){const o=parseFloat(O(t).fontSize);return s*o}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const o={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*o[e]}const i={cm:37.7952755906,mm:3.77952755906,in:96};return e in i?s*i[e]*r:(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)},st=(n,e,t={x:0,y:0})=>{const s=n.getBoundingClientRect(),i=O(n).transform;let o=0,c=0;if(i!=="none"){const p=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,m=i.match(p);m&&(o=et(m[1],m[2],n),c=et(m[3],m[4],n))}const{clientX:l,clientY:u}=T(e,t),h=l-s.left-o+n.scrollLeft,d=u-s.top-c+n.scrollTop;return{x:h,y:d}},T=(n,e=null)=>{const{clientX:t,clientY:s}=D(n)?Ct(n):n,r=t>0?t:e?e.x:t,i=s>0?s:e?e.y:s;return{clientX:r,clientY:i}},Ct=n=>{if(n.touches.length){let{clientX:t,clientY:s}=n.touches[0];if(n.touches.length>1){const r=n.touches[1],i=r.clientX,o=r.clientY;t=(t+i)/2,s=(s+o)/2}return{clientX:t,clientY:s}}const e=n.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},H=500,P=10,rt=100,nt=15,U=(n,e=0)=>D(n)?{clientX:n.touches[e].clientX,clientY:n.touches[e].clientY}:{clientX:n.clientX,clientY:n.clientY},it=n=>n&&D(n)?n.touches.length>0:!0;class ot{constructor(e,{onTouchDragStart:t},s={}){a(this,"_touchDragTimeOut");a(this,"_onTouchDragStart");a(this,"_payload",null);a(this,"_delay",H);a(this,"_firstTouch",null);a(this,"_lastTouch",null);a(this,"_epsilon",P);this._payload=e,this._onTouchDragStart=t,this._delay=typeof s.delay=="number"?s.delay:H,this._epsilon=typeof s.epsilon=="number"?s.epsilon:P}onStart(e){it(e)&&(this._touchDragTimeOut||(this._firstTouch=U(e,D(e)?e.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=U(e)),this._checkXDistance(e)()},this._delay)))}onEnd(){this._resetTouches()}onMove(e){it(e)&&(this._lastTouch=U(e))}_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())}}}class xt{constructor(e,t,s){a(this,"_options",{});a(this,"_instance");a(this,"_mainDomElement");a(this,"_currentDrag",{});a(this,"_currentTouch",null);a(this,"_firefoxDragPosition",{x:0,y:0});a(this,"isDragging",!1);a(this,"_firefoxFallback",e=>{if(!this._currentDrag.event)return;const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});this._instance=e,this._mainDomElement=t,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(e){}dragStart(e,t,s="rml_id"){const r=this._mainDomElement.parentNode;if(O(r).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let o=r.querySelector("."+b);o||(o=document.createElement("div"),o.classList.add(b),r.appendChild(o)),o.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 l=r.querySelector("."+A);this._currentDrag.event=t;const u=t.target.cloneNode();u.style.position="fixed",u.style.pointerEvents="none",u.style.opacity="0",u.style.animation=tt,u.id=At,u.style.zIndex="9999",document.body.appendChild(u),this._currentDrag.element=u;const h=t.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:d,clientY:p}=T(t,this._firefoxDragPosition);this._currentDrag.offset.x=d-h.left,this._currentDrag.offset.y=p-h.top,u.style.top=p+"px",u.style.left=d+"px",t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(l,0,0);const{x:m,y:E}=st(r,this._currentDrag.event||t,this._firefoxDragPosition),S=Math.max(1,m),w=Math.max(1,E);this.isDragging=!0,this._instance.dragInObject(e,S,w,s)}dragUpdate(e){var u,h;const t=this._mainDomElement.parentNode,{x:s,y:r}=st(t,e,this._firefoxDragPosition);if(s===0&&r===0)return;const i=Math.max(1,s),o=Math.max(1,r);if(this._currentDrag.element){const{clientX:d,clientY:p}=T(e,this._firefoxDragPosition),m=((u=this._currentDrag.offset)==null?void 0:u.x)||0,E=((h=this._currentDrag.offset)==null?void 0:h.y)||0;this._currentDrag.element.style.left=`${d-m}px`,this._currentDrag.element.style.top=`${p-E}px`;const S=(this._options.dragInOverlapX||0)+1,w=(this._options.dragInOverlapY||0)+1;i>S&&o>w?this._currentDrag.element.style.animation=Lt:this._currentDrag.element.style.animation=tt}if(i===1&&o===1)return;let c=i,l=o;if(D(e)){const d=this._options.fingerSize||0;c=Math.max(2,i+d),l=Math.max(2,o-d)}this._instance.updateDrag(c,l)}dragEnd(){this._mainDomElement.style.pointerEvents="all";const e=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+b);t&&t.classList.add(N.DISPLAY_NONE)}touchStart(e,t,s="rml_id"){var o,c;t.preventDefault();const r=(l,u)=>{this.dragStart(e,u,s)},i={};typeof((o=this._options)==null?void 0:o.touchDragDelay)=="number"&&(i.delay=this._options.touchDragDelay),(c=this._options)!=null&&c.touchDragEpsilon&&(i.epsilon=this._options.touchDragEpsilon),this._currentTouch=new ot(void 0,{onTouchDragStart:r},i),this._currentTouch.onStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(e){}}const Ht=n=>`[data-rml-custom-view="${n}"]`,G=n=>{n.preventDefault(),n.stopPropagation()},Pt=(n,e,t,s)=>{const r=t-n,i=s-e;return Math.sqrt(r*r+i*i)};class Ut{constructor({onCustomDragStart:e},t={}){a(this,"_startX",0);a(this,"_startY",0);a(this,"_lastX",0);a(this,"_lastY",0);a(this,"_delay");a(this,"_epsilon");a(this,"_isStarted",!1);a(this,"_isEnded",!1);a(this,"_isWaiting",!1);a(this,"_onCustomDragStart");this._delay=typeof t.delay=="number"?t.delay:rt,this._epsilon=typeof t.epsilon=="number"?t.epsilon:nt,this._onCustomDragStart=e}onMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._isWaiting&&Pt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(e),this._isWaiting=!1)}onStart(e){this._startX=e.clientX,this._startY=e.clientY,this.onMove(e),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const Y="data-rml-old-draggable",Gt=void 0,at=(n,e)=>{const t=D(n),s={delay:t?H:rt,epsilon:t?P:nt};if(!e)return s;if(!t&&!(n instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:r,epsilonKey:i}=t?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof e[r]=="number"&&(s.delay=e.touchDragDelay),typeof e[i]=="number"&&(s.epsilon=e.touchDragEpsilon),s},Yt=n=>{let e="",t=Rt,s=vt;if(!n)return{url:C,width:t,height:s};const r=n;if(r instanceof HTMLElement){const i=r.getBoundingClientRect(),o=r.getAttribute("data-rml-ghost-url"),c=r.getAttribute("data-rml-ghost-width"),l=r.getAttribute("data-rml-ghost-height");o?e=o:!o&&r instanceof HTMLImageElement&&r.src&&(e=r.src),e?(t=i.width,s=i.height):e=C,t=c?parseInt(c,10):t,s=l?parseInt(l,10):s}return{url:e||C,width:t,height:s}};class Ft{constructor(e,t,s){a(this,"_options",{});a(this,"_instance");a(this,"_viewName");a(this,"_currentCustomDrag",null);a(this,"_currentBb",null);a(this,"_startTarget",null);a(this,"_onBeforeUpdateDrag",()=>({}));a(this,"isDragging",!1);this._instance=e,this._options=t||{},this._viewName=s}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}async _dragStart(e,t,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(Y,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",G),this._startTarget.addEventListener("dragstart",G)),this._currentBb=await this._instance.getBoundingClientRect(Ht(this._viewName));const{clientX:r,clientY:i}=T(t),o=this._currentBb.x+r,c=this._currentBb.y+i;this.isDragging=!0,this._instance.dragInObject(e,o,c,s)}_dragUpdate(e){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(e),!this._currentBb||!this.isDragging)return;const{clientX:t,clientY:s}=T(e),{url:r,width:i,height:o}=Yt(this._startTarget),c=this._currentBb.x+t,l=this._currentBb.y+s,u={ghost:{visibleIn:{x:this._currentBb.x-this._options.dragInOverlapX||0,y:this._currentBb.y+this._options.dragInOverlapY||0,width:this._currentBb.width+this._options.dragInOverlapX,height:this._currentBb.height+this._options.dragInOverlapY},url:r,width:i,height:o}},{x:h,y:d,options:p}=this._onBeforeUpdateDrag(c,l,u),m=typeof h=="number"?h:c,E=typeof d=="number"?d:l,S=p||u;this._instance.updateDrag(m,E,S)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.dragInObjectEnd()}dragStart(e,t,s){this._startTarget=t.target;const r=(i,o)=>{this._dragStart(e,o,s)};this._currentCustomDrag=D(t)?new ot(Gt,{onTouchDragStart:r},at(t,this._options)):new Ut({onCustomDragStart:i=>this._dragStart(e,i,s)},at(t,this._options)),this._currentCustomDrag.onStart(t)}dragEnd(){this._dragEnd()}dragUpdate(e){this._dragUpdate(e)}touchStart(e,t,s="rml_id"){this.dragStart(e,t,s)}touchMove(e){this.dragUpdate(e)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(Y)==="true",this._startTarget.removeAttribute(Y),this._startTarget.removeEventListener("dragstart",G))}releaseInput(e){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}class Bt extends bt{constructor(t,s,r,i){super(t,s,r,i);a(this,"options",{});a(this,"_strategy");a(this,"_customDragSignal",new AbortController);if(this._mainDomElement=s,r==="website")this._strategy=new xt(t,s,this.options);else if(r==="custom-view")this._strategy=new Ft(t,this.options,this._viewName);else throw new Error("Unsupported mode");this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!!!document.getElementById(K)){const s=document.createElement("style");s.type="text/css",s.id=K,s.innerHTML=`
|
|
9
|
+
.${N.DISPLAY_NONE}{display:none}
|
|
10
|
+
.${b}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
11
|
+
.${A}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
|
|
12
|
+
${Ot}
|
|
13
|
+
${Mt}
|
|
14
|
+
`,document.head.appendChild(s)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let s=t.querySelector("."+A);s||(s=document.createElement("div"),s.classList.add(A),s.innerText=" ",t.appendChild(s))}get isDragging(){return this._strategy.isDragging}dragStart(t,s,r="rml_id"){this._strategy.dragStart(t,s,r)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,s,r="rml_id"){this._strategy.touchStart(t,s,r)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:s,customDragUpdate:r,beforeUpdateGhost:i}){i&&this._strategy.beforeUpdateGhost(i);const o=this._customDragSignal.signal,c=h=>{h.target.getAttribute("data-rml-draggable")==="true"&&t(h)},l=h=>{this._strategy.releaseInput(h),this._strategy.isDragging&&s(h)},u=h=>{r(h)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(h=>{h.draggable=!1}),document.addEventListener("mousedown",c,{signal:o}),document.addEventListener("mouseup",l,{signal:o}),document.addEventListener("mousemove",u,{signal:o}),document.addEventListener("mouseleave",l,{signal:o}),document.addEventListener("touchstart",c,{signal:o}),document.addEventListener("touchend",l,{signal:o}),document.addEventListener("touchmove",u,{signal:o})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Xt=Object.freeze(Object.defineProperty({__proto__:null,DragIn:Bt},Symbol.toStringTag,{value:"Module"}));return It});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(_,
|
|
2
|
-
.${
|
|
3
|
-
.${
|
|
4
|
-
.${
|
|
5
|
-
.${
|
|
6
|
-
.${
|
|
7
|
-
.${
|
|
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 q("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(a),this._iframe=a;for(const n of r)typeof n=="string"&&n==="dragIn"?this.pluginsLoaded.push(new Promise((c,h)=>{try{Promise.resolve().then(()=>ye).then(({DragIn:u})=>{const d=new u(this._iframe);d.setInstance(this.ui),this.plugins.dragIn=d,c()})}catch(u){h(u)}})):n.name&&n.loader&&this.pluginsLoaded.push(new Promise((c,h)=>{try{n.loader().then(u=>{const d=new u(this._iframe);d.setInstance(this.ui),this.plugins[n.name]=d,c()})}catch(u){h(u)}}));O.set(t,!0)}static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static createConfigurator(e,t,s,r=[]){return this._create(e,t,s,r)}static create(e,t,s,r){return this._create(e,t,s,r)}static createViewer(e,t,s,r=[]){return this._create(e,t,s,r)}static async _create(e,t,s,r){return new Promise(async(o,a)=>{try{const n=E(le(),oe(s));n.featureFlags||(n.featureFlags={}),typeof n.featureFlags.realPartList!="boolean"&&(n.featureFlags.realPartList=!0),typeof n.featureFlags.globalCallbacks!="boolean"&&(n.featureFlags.globalCallbacks=!0),typeof n.featureFlags.mocAr!="boolean"&&(n.featureFlags.mocAr=!1);const c=await G(e,n);s=ae(c,n);const h=new this(c,t,s,r,o);return console.info(h),await Promise.allSettled(h.pluginsLoaded),h}catch(n){return a(n)}})}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 r;if(!s.source||s.source!==((r=this._iframe)==null?void 0:r.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),a=o[0],n=o[1],c=o.length===3?o[2]:null;if(c&&this[a][n][c]){const h=this[a][n][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 ge{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 r=getComputedStyle(e);return this._computedStyleCache.set(e,{style:r,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),r}_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),r=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 o={cm:37.7952755906,mm:3.77952755906,in:96};return e in o?s*o[e]*r:(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(),r=v(i).transform;let o=0,a=0;if(r!=="none"){const d=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,g=r.match(d);g&&(o=W(g[1],g[2],i),a=W(g[3],g[4],i))}const{clientX:n,clientY:c}=L(e,t),h=n-s.left-o+i.scrollLeft,u=c-s.top-a+i.scrollTop;return{x:h,y:u}},L=(i,e)=>{const{clientX:t,clientY:s}=B(i)?me(i):i,r=t||e.x,o=s||e.y;return{clientX:r,clientY:o}},me=i=>{if(i.touches.length){let{clientX:t,clientY:s}=i.touches[0];if(i.touches.length>1){const r=i.touches[1],o=r.clientX,a=r.clientY;t=(t+o)/2,s=(s+a)/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={}){l(this,"_touchDragTimeOut"),l(this,"_onTouchDragStart"),l(this,"_payload",null),l(this,"_delay",Y),l(this,"_firstTouch",null),l(this,"_lastTouch",null),l(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){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",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
|
-
.${
|
|
1
|
+
(function(_,D){typeof exports=="object"&&typeof module<"u"?module.exports=D():typeof define=="function"&&define.amd?define(D):(_=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=D())})(this,function(){"use strict";var _=Object.defineProperty,D=(r,t,e)=>t in r?_(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,l=(r,t,e)=>D(r,typeof t!="symbol"?t+"":t,e);class F{constructor(t,e,s,i){l(this,"_side"),l(this,"_incomingMessageBus",null),l(this,"_outgoingMessageBus",null),l(this,"_execMessage",null),this._side=t,this._incomingMessageBus=e,this._outgoingMessageBus=s,this._execMessage=i,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(t){this._outgoingMessageBus=t}setMessageExecution(t){this._execMessage=t}sendMessage(t,e=[]){return new Promise((s,i)=>{const n=new MessageChannel;n.port1.onmessage=o=>{if(!o||!o.data)return n.port1.close(),n.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(o.data)}catch(h){return n.port1.close(),n.port2.close(),this._prepareError(h),i(h)}c.error?i(c.error):c.result!==void 0?s(c.result):s(void 0),n.port1.close(),n.port2.close()};let a="";try{a=JSON.stringify({message:t,args:e})}catch{return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(a,"*",[n.port2])})}_handleMessage(t){const e=t.ports&&Array.isArray(t.ports)&&t.ports.length>0?t.ports[0]:null;if(t.data&&e)try{const s=JSON.parse(t.data);if(!this._execMessage)return e.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const i=this._execMessage(s,t);if(i===void 0)return;i.then((n={})=>{let a,o;typeof n=="object"&&n!==null&&(a=n.error,o=n.result),a?e.postMessage(JSON.stringify({error:a})):o!==void 0?e.postMessage(JSON.stringify({result:o})):e.postMessage(JSON.stringify({result:n}))},n=>{e.postMessage(JSON.stringify({error:this._prepareError(n)}))})}catch(s){e.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(t){if(typeof t=="string"){const e=this._side+": "+t;return console.error(e),e}return t.message=this._side+": "+t.message,console.error(t),t.message}}const S=".",I={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},b={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},ct=async(r,t)=>{if(typeof r!="string")throw new Error('Configurator ID is not a string type: "'+typeof r+'"');const e=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",s=t.overrideTenant||9,i=e+"/configurators/"+r,n="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+n),o=()=>{const u={apiKey:n,currentTenant:s,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(u)},c=new Request(i,{method:"GET",headers:o(),mode:"cors",cache:"default"}),h=await fetch(c),{configurator:d}=await h.json();return d},ht=()=>{try{return window.self!==window.top}catch{return!0}},ut=["127.0.0.1","localhost","0.0.0.0"],dt=()=>{const r=ht();let t=window.location.href;if(r){if(!document.referrer)return null;t=document.referrer}const{hostname:e}=new URL(t);return e},gt=r=>!!(ut.includes(r)||r.endsWith("roomle.com")||r.endsWith("gitlab.io")||r.endsWith("gitlab.com")),X=["language","browserLanguage","userLanguage","systemLanguage"],mt=(r=null)=>{const t=window.navigator;if(r)return r.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,s=X.length;e<s;e++){const i=t[X[e]];if(i)return i.substr(0,2)}return"en"},_t=(r,t)=>{const e=JSON.parse(JSON.stringify(r));return O(e,t)},O=(r,t)=>{for(const e in t)try{t[e].constructor===Object?r[e]=O(r[e],t[e]):r[e]=t[e]}catch{r[e]=t[e]}return r};var pt={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const ft={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},rotationSnapDegrees:10},yt="(idle)",Dt=r=>(M(r),r!=null&&r.customApiUrl&&(r.customApiUrl=decodeURIComponent(r.customApiUrl)),r.shareUrl&&(r.deeplink=r.shareUrl.replace(wt,Et)),r),M=r=>{if(!r)return;const t=Object.keys(r);for(const e of t){const s=r[e];if(!Array.isArray(s)&&typeof s=="object"&&s!==null&&M(s),Array.isArray(s))for(const i of s)M(i);(s==="true"||s==="false")&&(r[e]=s==="true")}},vt=(r,t)=>{t.configuratorId=r.id;const e=r.settings||{};return!t.overrideTenant&&r.tenant&&(t.overrideTenant=r.tenant),_t(e,t)},bt=()=>{const r={...ft};r.locale||(r.locale=mt()),r.id===yt&&delete r.id;const t=dt();return t&>(t)&&(r.configuratorId="demoConfigurator"),r.customApiUrl=pt.VITE_RAPI_URL,r.emails=!1,r},wt="<CONF_ID>",Et="#CONFIGURATIONID#",k=()=>/(android)/i.test(navigator.userAgent);class W{constructor(){l(this,"_messageHandler",null),l(this,"isSetupDone",!1),l(this,"viewName","main"),l(this,"plugins",{}),l(this,"pluginsLoaded",[]),l(this,"ui",{callbacks:null}),l(this,"extended",{callbacks:null}),l(this,"configurator",{callbacks:null}),l(this,"analytics",{callbacks:{}}),l(this,"global",{callbacks:{}})}setMessageHandler(t){this._messageHandler=t}handleSetup(t){const{methods:e,callbacks:s}=t;e.forEach(i=>{const n=i.split(S),a=n[0],o=n[1];this[a]||(this[a]={}),this[a][o]=function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(i,[...arguments])}.bind(this)}),s.forEach(i=>{const n=i.split(S),a=n[0],o=n[1],c=n[2];this[a]||(this[a]={}),this[a][o]||(this[a][o]={}),this[a][o][c]=()=>{}}),this.isSetupDone=!0}executeMessage({message:t,args:e}){const s=t.split(S),i=s[0],n=s[1],a=s.length===3?s[2]:null;if(a&&this[i][n][a]){const o=this[i][n][a](...e);return o instanceof Promise?o.then(c=>({result:c})):o!==void 0?Promise.resolve({result:o}):Promise.resolve({result:null})}return Promise.reject('Message "'+t+'" is unkown')}setupPlugins(t,e,s="website"){for(const i of t)typeof i=="string"&&i==="dragIn"?this.pluginsLoaded.push(new Promise((n,a)=>{try{Promise.resolve().then(()=>Wt).then(({DragIn:o})=>{const c=new o(this.ui,e,s,this.viewName);this.plugins.dragIn=c,n()})}catch(o){a(o)}})):i.name&&i.loader&&this.pluginsLoaded.push(new Promise((n,a)=>{try{i.loader().then(o=>{const c=new o(this.ui,e,s,this.viewName);this.plugins[i.name]=c,n()})}catch(o){a(o)}}))}}const $=()=>{let r,t;return{promise:new Promise((e,s)=>{r=e,t=s}),resolve:r,reject:t}},j=(r,t,e)=>{let s=null;Object.defineProperty(r,t,{get(){return s||e},set(i){i!=null&&i.mute?s=i.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=i)}})},G=()=>window.innerHeight*.01+"px",z=r=>{r&&setTimeout(()=>r.style.setProperty(x,G()),0)},V="rml-styles",Tt=450,x="--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"},L=new Map;class St extends W{constructor(t,e,s,i,n){if(super(),l(this,"_waitForIframe"),l(this,"_container"),l(this,"_configuratorSettings"),l(this,"_initData",{}),l(this,"_iframe"),!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(L.has(e))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(V)){const c=s.zIndex||9999999,h=document.createElement("style");h.type="text/css",h.id=V;const d="transition:all ease-in-out "+Tt+"ms;",u=["-webkit-","-o-"].reduce((f,y)=>f+=y+d,"")+d,m=G();h.innerHTML=`
|
|
2
|
+
.${g.CONTAINER}{${x}:${m};}
|
|
3
|
+
.${g.POSITION}{position:fixed;top:0;left:0;z-index:${c};opacity:0}
|
|
4
|
+
.${g.TRANSITION}{${u}}
|
|
5
|
+
.${g.FILL}{width:100%;height:100%;opacity:1}
|
|
6
|
+
.${g.ANDROID_HEIGHT}{height:calc(var(${x},1vh)*100)}
|
|
7
|
+
.${g.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
8
|
+
`,document.head.appendChild(h)}this._executeMessage=this._executeMessage.bind(this);const a=new F("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),k()&&window.addEventListener("resize",this._onResize),this._container=e,this._initData=s,this._configuratorSettings=t;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=n,this._container.appendChild(o),this._iframe=o,this.setupPlugins(i,this._iframe),L.set(e,!0)}static createPlanner(t,e,s,i=[]){return this._create(t,e,s,i)}static async connect(t,e=[]){const s=new W;s.viewName=t;const{resolve:i,promise:n}=$(),{resolve:a,promise:o}=$(),c=({message:u,args:m})=>{if(u===b.REGISTER_CUSTOM_VIEW_DONE){i();return}if(u===b.RETURN_METHODS){s.handleSetup(m[0]),a();return}if(s.isSetupDone)return s.executeMessage({message:u,args:m})},h=new F("custom-view-"+t,window,window.parent,c);s.setMessageHandler(h);const d=[t];return h.sendMessage(b.REGISTER_CUSTOM_VIEW,d),await n,h.sendMessage(b.GET_METHODS,d),await o,s.setupPlugins(e,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}static createConfigurator(t,e,s,i=[]){return this._create(t,e,s,i)}static create(t,e,s,i){return this._create(t,e,s,i)}static createViewer(t,e,s,i=[]){return this._create(t,e,s,i)}static async _create(t,e,s,i){return new Promise(async(n,a)=>{try{const o=O(bt(),Dt(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 ct(t,o);s=vt(c,o);const h=new this(c,e,s,i,n);return console.info(h),await Promise.allSettled(h.pluginsLoaded),h}catch(o){return a(o)}})}teardown(){this._container&&L.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var t;const e=document.createElement("iframe");let s=((t=this._configuratorSettings)==null?void 0:t.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),e.src=s,e.classList.add(g.CONTAINER),e.classList.add(g.FILL),e}_onResize(){z(this._iframe)}_onUseFullPage(){this._iframe.classList.add(g.POSITION),document.documentElement.classList.add(g.OVERFLOW_HIDDEN),window.document.body.classList.add(g.OVERFLOW_HIDDEN),k()&&(z(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:t,args:e},s){var i;if(s.source&&s.source===((i=this._iframe)==null?void 0:i.contentWindow))return t===I.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):t===I.SETUP?(this.handleSetup(e[0]),j(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),j(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(I.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:e})}}class It{constructor(t,e,s,i){l(this,"_mainDomElement"),l(this,"_instance",null),l(this,"_mode","website"),l(this,"_viewName","main"),this._instance=t,this._mainDomElement=e,this._mode=s,this._viewName=i}}const q="rml-drag-in-styles",Ot="rml-drag-in-drag-element",w="rml-drag-in-overlay",E="rml-drag-in-drag-ghost",J="rml-drag-in-fade-in",K="rml-drag-in-fade-out",C={DISPLAY_NONE:"rml-display-none"},Q=.5,Z="250ms",tt="forwards",Mt=`@keyframes ${J} {from{opacity: 0;}to {opacity: ${Q};}}`,xt=`@keyframes ${K} {from{opacity: ${Q};}to {opacity: 0;}}`,et=`${J} ${Z} ${tt}`,Lt=`${K} ${Z} ${tt}`,N="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",Ct=112,Nt=112;class Pt{constructor(t=16){l(this,"_computedStyleCache",new Map),l(this,"_maxLifetime",16),l(this,"_cacheCleanInterval",null),this._maxLifetime=t}get(t){const e=this._computedStyleCache.get(t),s=Date.now();if(e&&s-e.updated<this._maxLifetime)return e.style;const i=getComputedStyle(t);return this._computedStyleCache.set(t,{style:i,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),i}_cleanUpCache(){const t=Date.now();for(const[e,{updated:s}]of this._computedStyleCache.entries())t-s>=this._maxLifetime&&this._computedStyleCache.delete(e);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const p=r=>window.TouchEvent&&r instanceof window.TouchEvent;let P;const T=r=>(P||(P=new Pt),P.get(r)),st=(r,t,e)=>{const s=parseFloat(r),i=window.devicePixelRatio||1;if(t==="px")return s;if(t==="%"){const a=e===document.documentElement?window.innerWidth:e.offsetWidth;return s/100*a}if(t==="rem"){const a=parseFloat(T(document.documentElement).fontSize);return s*a}if(t==="em"){const a=parseFloat(T(e).fontSize);return s*a}if(t==="vh"||t==="vw"||t==="vmin"||t==="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[t]}const n={cm:37.7952755906,mm:3.77952755906,in:96};return t in n?s*n[t]*i:(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)},rt=(r,t,e={x:0,y:0})=>{const s=r.getBoundingClientRect(),i=T(r).transform;let n=0,a=0;if(i!=="none"){const u=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,m=i.match(u);m&&(n=st(m[1],m[2],r),a=st(m[3],m[4],r))}const{clientX:o,clientY:c}=v(t,e),h=o-s.left-n+r.scrollLeft,d=c-s.top-a+r.scrollTop;return{x:h,y:d}},v=(r,t=null)=>{const{clientX:e,clientY:s}=p(r)?Rt(r):r,i=e>0?e:t?t.x:e,n=s>0?s:t?t.y:s;return{clientX:i,clientY:n}},Rt=r=>{if(r.touches.length){let{clientX:e,clientY:s}=r.touches[0];if(r.touches.length>1){const i=r.touches[1],n=i.clientX,a=i.clientY;e=(e+n)/2,s=(s+a)/2}return{clientX:e,clientY:s}}const t=r.changedTouches[0];return{clientX:t.clientX,clientY:t.clientY}},R=500,U=10,it=100,nt=15,A=(r,t=0)=>p(r)?{clientX:r.touches[t].clientX,clientY:r.touches[t].clientY}:{clientX:r.clientX,clientY:r.clientY},ot=r=>r&&p(r)?r.touches.length>0:!0;class at{constructor(t,{onTouchDragStart:e},s={}){l(this,"_touchDragTimeOut"),l(this,"_onTouchDragStart"),l(this,"_payload",null),l(this,"_delay",R),l(this,"_firstTouch",null),l(this,"_lastTouch",null),l(this,"_epsilon",U),this._payload=t,this._onTouchDragStart=e,this._delay=typeof s.delay=="number"?s.delay:R,this._epsilon=typeof s.epsilon=="number"?s.epsilon:U}onStart(t){ot(t)&&(this._touchDragTimeOut||(this._firstTouch=A(t,p(t)?t.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=A(t)),this._checkXDistance(t)()},this._delay)))}onEnd(){this._resetTouches()}onMove(t){ot(t)&&(this._lastTouch=A(t))}_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)<this._epsilon,e&&(this._onTouchDragStart(this._payload,t),this._resetTouches())}}}class Ut{constructor(t,e,s){l(this,"_options",{}),l(this,"_instance"),l(this,"_mainDomElement"),l(this,"_currentDrag",{}),l(this,"_currentTouch",null),l(this,"_firefoxDragPosition",{x:0,y:0}),l(this,"isDragging",!1),l(this,"_firefoxFallback",i=>{if(!this._currentDrag.event)return;const n=i||window.event;this._firefoxDragPosition.x=n.pageX||0,this._firefoxDragPosition.y=n.pageY||0}),this._instance=t,this._mainDomElement=e,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(t){}dragStart(t,e,s="rml_id"){const i=this._mainDomElement.parentNode;if(T(i).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._mainDomElement.style.pointerEvents="none";let n=i.querySelector("."+w);n||(n=document.createElement("div"),n.classList.add(w),i.appendChild(n)),n.classList.remove(C.DISPLAY_NONE),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 a=i.querySelector("."+E);this._currentDrag.event=e;const o=e.target.cloneNode();o.style.position="fixed",o.style.pointerEvents="none",o.style.opacity="0",o.style.animation=et,o.id=Ot,o.style.zIndex="9999",document.body.appendChild(o),this._currentDrag.element=o;const c=e.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:h,clientY:d}=v(e,this._firefoxDragPosition);this._currentDrag.offset.x=h-c.left,this._currentDrag.offset.y=d-c.top,o.style.top=d+"px",o.style.left=h+"px",e instanceof DragEvent&&e.dataTransfer&&e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(a,0,0);const{x:u,y:m}=rt(i,this._currentDrag.event||e,this._firefoxDragPosition),f=Math.max(1,u),y=Math.max(1,m);this.isDragging=!0,this._instance.dragInObject(t,f,y,s)}dragUpdate(t){var e,s;const i=this._mainDomElement.parentNode,{x:n,y:a}=rt(i,t,this._firefoxDragPosition);if(n===0&&a===0)return;const o=Math.max(1,n),c=Math.max(1,a);if(this._currentDrag.element){const{clientX:u,clientY:m}=v(t,this._firefoxDragPosition),f=((e=this._currentDrag.offset)==null?void 0:e.x)||0,y=((s=this._currentDrag.offset)==null?void 0:s.y)||0;this._currentDrag.element.style.left=`${u-f}px`,this._currentDrag.element.style.top=`${m-y}px`;const Y=(this._options.dragInOverlapX||0)+1,$t=(this._options.dragInOverlapY||0)+1;o>Y&&c>$t?this._currentDrag.element.style.animation=Lt:this._currentDrag.element.style.animation=et}if(o===1&&c===1)return;let h=o,d=c;if(p(t)){const u=this._options.fingerSize||0;h=Math.max(2,o+u),d=Math.max(2,c-u)}this._instance.updateDrag(h,d)}dragEnd(){this._mainDomElement.style.pointerEvents="all";const t=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const e=t.querySelector("."+w);e&&e.classList.add(C.DISPLAY_NONE)}touchStart(t,e,s="rml_id"){var i,n;e.preventDefault();const a=(c,h)=>{this.dragStart(t,h,s)},o={};typeof((i=this._options)==null?void 0:i.touchDragDelay)=="number"&&(o.delay=this._options.touchDragDelay),(n=this._options)!=null&&n.touchDragEpsilon&&(o.epsilon=this._options.touchDragEpsilon),this._currentTouch=new at(void 0,{onTouchDragStart:a},o),this._currentTouch.onStart(e)}touchMove(t){this._currentTouch&&this._currentTouch.onMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(t){}}const At=r=>`[data-rml-custom-view="${r}"]`,B=r=>{r.preventDefault(),r.stopPropagation()},Bt=(r,t,e,s)=>{const i=e-r,n=s-t;return Math.sqrt(i*i+n*n)};class Ht{constructor({onCustomDragStart:t},e={}){l(this,"_startX",0),l(this,"_startY",0),l(this,"_lastX",0),l(this,"_lastY",0),l(this,"_delay"),l(this,"_epsilon"),l(this,"_isStarted",!1),l(this,"_isEnded",!1),l(this,"_isWaiting",!1),l(this,"_onCustomDragStart"),this._delay=typeof e.delay=="number"?e.delay:it,this._epsilon=typeof e.epsilon=="number"?e.epsilon:nt,this._onCustomDragStart=t}onMove(t){this._lastX=t.clientX,this._lastY=t.clientY,this._isWaiting&&Bt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(t),this._isWaiting=!1)}onStart(t){this._startX=t.clientX,this._startY=t.clientY,this.onMove(t),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const H="data-rml-old-draggable",Yt=void 0,lt=(r,t)=>{const e=p(r),s={delay:e?R:it,epsilon:e?U:nt};if(!t)return s;if(!e&&!(r instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:i,epsilonKey:n}=e?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof t[i]=="number"&&(s.delay=t.touchDragDelay),typeof t[n]=="number"&&(s.epsilon=t.touchDragEpsilon),s},Ft=r=>{let t="",e=Ct,s=Nt;if(!r)return{url:N,width:e,height:s};const i=r;if(i instanceof HTMLElement){const n=i.getBoundingClientRect(),a=i.getAttribute("data-rml-ghost-url"),o=i.getAttribute("data-rml-ghost-width"),c=i.getAttribute("data-rml-ghost-height");a?t=a:!a&&i instanceof HTMLImageElement&&i.src&&(t=i.src),t?(e=n.width,s=n.height):t=N,e=o?parseInt(o,10):e,s=c?parseInt(c,10):s}return{url:t||N,width:e,height:s}};class Xt{constructor(t,e,s){l(this,"_options",{}),l(this,"_instance"),l(this,"_viewName"),l(this,"_currentCustomDrag",null),l(this,"_currentBb",null),l(this,"_startTarget",null),l(this,"_onBeforeUpdateDrag",()=>({})),l(this,"isDragging",!1),this._instance=t,this._options=e||{},this._viewName=s}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}async _dragStart(t,e,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(H,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",B),this._startTarget.addEventListener("dragstart",B)),this._currentBb=await this._instance.getBoundingClientRect(At(this._viewName));const{clientX:i,clientY:n}=v(e),a=this._currentBb.x+i,o=this._currentBb.y+n;this.isDragging=!0,this._instance.dragInObject(t,a,o,s)}_dragUpdate(t){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(t),!this._currentBb||!this.isDragging)return;const{clientX:e,clientY:s}=v(t),{url:i,width:n,height:a}=Ft(this._startTarget),o=this._currentBb.x+e,c=this._currentBb.y+s,h={ghost:{visibleIn:{x:this._currentBb.x-this._options.dragInOverlapX||0,y:this._currentBb.y+this._options.dragInOverlapY||0,width:this._currentBb.width+this._options.dragInOverlapX,height:this._currentBb.height+this._options.dragInOverlapY},url:i,width:n,height:a}},{x:d,y:u,options:m}=this._onBeforeUpdateDrag(o,c,h),f=typeof d=="number"?d:o,y=typeof u=="number"?u:c,Y=m||h;this._instance.updateDrag(f,y,Y)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.dragInObjectEnd()}dragStart(t,e,s){this._startTarget=e.target;const i=(n,a)=>{this._dragStart(t,a,s)};this._currentCustomDrag=p(e)?new at(Yt,{onTouchDragStart:i},lt(e,this._options)):new Ht({onCustomDragStart:n=>this._dragStart(t,n,s)},lt(e,this._options)),this._currentCustomDrag.onStart(e)}dragEnd(){this._dragEnd()}dragUpdate(t){this._dragUpdate(t)}touchStart(t,e,s="rml_id"){this.dragStart(t,e,s)}touchMove(t){this.dragUpdate(t)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(H)==="true",this._startTarget.removeAttribute(H),this._startTarget.removeEventListener("dragstart",B))}releaseInput(t){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}class kt extends It{constructor(t,e,s,i){if(super(t,e,s,i),l(this,"options",{}),l(this,"_strategy"),l(this,"_customDragSignal",new AbortController),this._mainDomElement=e,s==="website")this._strategy=new Ut(t,e,this.options);else if(s==="custom-view")this._strategy=new Xt(t,this.options,this._viewName);else throw new Error("Unsupported mode");this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!document.getElementById(q)){const t=document.createElement("style");t.type="text/css",t.id=q,t.innerHTML=`
|
|
9
|
+
.${C.DISPLAY_NONE}{display:none}
|
|
10
10
|
.${w}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
11
|
-
.${
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`,document.head.appendChild(
|
|
11
|
+
.${E}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
|
|
12
|
+
${Mt}
|
|
13
|
+
${xt}
|
|
14
|
+
`,document.head.appendChild(t)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let e=t.querySelector("."+E);e||(e=document.createElement("div"),e.classList.add(E),e.innerText=" ",t.appendChild(e))}get isDragging(){return this._strategy.isDragging}dragStart(t,e,s="rml_id"){this._strategy.dragStart(t,e,s)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,e,s="rml_id"){this._strategy.touchStart(t,e,s)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:e,customDragUpdate:s,beforeUpdateGhost:i}){i&&this._strategy.beforeUpdateGhost(i);const n=this._customDragSignal.signal,a=h=>{h.target.getAttribute("data-rml-draggable")==="true"&&t(h)},o=h=>{this._strategy.releaseInput(h),this._strategy.isDragging&&e(h)},c=h=>{s(h)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(h=>{h.draggable=!1}),document.addEventListener("mousedown",a,{signal:n}),document.addEventListener("mouseup",o,{signal:n}),document.addEventListener("mousemove",c,{signal:n}),document.addEventListener("mouseleave",o,{signal:n}),document.addEventListener("touchstart",a,{signal:n}),document.addEventListener("touchend",o,{signal:n}),document.addEventListener("touchmove",c,{signal:n})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Wt=Object.freeze(Object.defineProperty({__proto__:null,DragIn:kt},Symbol.toStringTag,{value:"Module"}));return St});
|
package/drag-in-BKrnFtmJ.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
var O=Object.defineProperty,P=(i,t,e)=>t in i?O(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,c=(i,t,e)=>P(i,typeof t!="symbol"?t+"":t,e);class N{constructor(t=16){c(this,"_computedStyleCache",new Map),c(this,"_maxLifetime",16),c(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 o=getComputedStyle(t);return this._computedStyleCache.set(t,{style:o,updated:n}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),o}_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)}}const E=i=>window.TouchEvent&&i instanceof window.TouchEvent;let D;const f=i=>(D||(D=new N),D.get(i)),C=(i,t,e)=>{const n=parseFloat(i),o=window.devicePixelRatio||1;if(t==="px")return n;if(t==="%"){const a=e===document.documentElement?window.innerWidth:e.offsetWidth;return n/100*a}if(t==="rem"){const a=parseFloat(f(document.documentElement).fontSize);return n*a}if(t==="em"){const a=parseFloat(f(e).fontSize);return n*a}if(t==="vh"||t==="vw"||t==="vmin"||t==="vmax"){const a={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return n/100*a[t]}const s={cm:37.7952755906,mm:3.77952755906,in:96};return t in s?n*s[t]*o:(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)},I=(i,t,e={x:0,y:0})=>{const n=i.getBoundingClientRect(),o=f(i).transform;let s=0,a=0;if(o!=="none"){const _=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,d=o.match(_);d&&(s=C(d[1],d[2],i),a=C(d[3],d[4],i))}const{clientX:r,clientY:l}=v(t,e),h=r-n.left-s+i.scrollLeft,u=l-n.top-a+i.scrollTop;return{x:h,y:u}},v=(i,t)=>{const{clientX:e,clientY:n}=E(i)?k(i):i,o=e||t.x,s=n||t.y;return{clientX:o,clientY:s}},k=i=>{if(i.touches.length){let{clientX:e,clientY:n}=i.touches[0];if(i.touches.length>1){const o=i.touches[1],s=o.clientX,a=o.clientY;e=(e+s)/2,n=(n+a)/2}return{clientX:e,clientY:n}}const t=i.changedTouches[0];return{clientX:t.clientX,clientY:t.clientY}},$=500,L=10;class z{constructor(t,{onTouchDragStart:e},n={}){c(this,"_touchDragTimeOut"),c(this,"_onTouchDragStart"),c(this,"_payload",null),c(this,"_delay",$),c(this,"_firstTouch",null),c(this,"_lastTouch",null),c(this,"_epsilon",L),this._payload=t,this._onTouchDragStart=e,this._delay=n.delay||$,this._epsilon=n.epsilon||L}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)<this._epsilon,e&&(this._onTouchDragStart(this._payload,t),this._resetTouches())}}}const X="rml-drag-in-styles",F="rml-drag-in-drag-element",g="rml-drag-in-overlay",m="rml-drag-in-drag-ghost",x="rml-drag-in-fade-in",Y="rml-drag-in-fade-out",T={DISPLAY_NONE:"rml-display-none"},M=.5,w="250ms",S="forwards",b=i=>i?!0:(console.warn("No instance set, cancel drag-in"),!1);class A{constructor(t){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",e=>{if(!this._currentDrag.event)return;const n=e||window.event;this._firefoxDragPosition.x=n.pageX||0,this._firefoxDragPosition.y=n.pageY||0}),this._iframe=t,this._injectStyles(),this._initializeDragGhost(),this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}_injectStyles(){if(!document.getElementById(X)){const t=document.createElement("style");t.type="text/css",t.id=X,t.innerHTML=`
|
|
2
|
-
.${T.DISPLAY_NONE}{display:none}
|
|
3
|
-
.${g}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
4
|
-
.${m}{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: ${M};}}
|
|
6
|
-
@keyframes ${Y} {from{opacity: ${M};}to {opacity: 0;}}
|
|
7
|
-
`,document.head.appendChild(t)}}_initializeDragGhost(){const t=this._iframe.parentNode;let e=t.querySelector("."+m);e||(e=document.createElement("div"),e.classList.add(m),e.innerText=" ",t.appendChild(e))}setInstance(t){this._instance=t}dragStart(t,e,n="rml_id"){const o=this._iframe.parentNode;if(f(o).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 s=o.querySelector("."+g);s||(s=document.createElement("div"),s.classList.add(g),o.appendChild(s)),s.classList.remove(T.DISPLAY_NONE),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 a=o.querySelector("."+m);this._currentDrag.event=e;const r=e.target.cloneNode();r.style.position="fixed",r.style.pointerEvents="none",r.style.opacity="0",r.style.animation=`${x} ${w} ${S}`,r.id=F,r.style.zIndex="9999",document.body.appendChild(r),this._currentDrag.element=r;const l=e.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:h,clientY:u}=v(e,this._firefoxDragPosition);this._currentDrag.offset.x=h-l.left,this._currentDrag.offset.y=u-l.top,r.style.top=u+"px",r.style.left=h+"px",e instanceof DragEvent&&e.dataTransfer&&e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(a,0,0);const{x:_,y:d}=I(o,this._currentDrag.event||e,this._firefoxDragPosition),p=Math.max(1,_),y=Math.max(1,d);b(this._instance)&&this._instance.dragInObject(t,p,y,n)}dragUpdate(t){var e,n;const o=this._iframe.parentNode,{x:s,y:a}=I(o,t,this._firefoxDragPosition);if(s===0&&a===0)return;const r=Math.max(1,s),l=Math.max(1,a);if(this._currentDrag.element){const{clientX:h,clientY:u}=v(t,this._firefoxDragPosition),_=((e=this._currentDrag.offset)==null?void 0:e.x)||0,d=((n=this._currentDrag.offset)==null?void 0:n.y)||0;this._currentDrag.element.style.left=`${h-_}px`,this._currentDrag.element.style.top=`${u-d}px`;const p=(this.options.dragInOverlapX||0)+1,y=(this.options.dragInOverlapY||0)+1;r>p&&l>y?this._currentDrag.element.style.animation=`${Y} ${w} ${S}`:this._currentDrag.element.style.animation=`${x} ${w} ${S}`}if(!(r===1&&l===1)&&b(this._instance)){let h=r,u=l;if(E(t)){const _=this.options.fingerSize||0;h=Math.max(2,r+_),u=Math.max(2,l-_)}this._instance.updateDrag(h,u)}}dragEnd(){this._iframe.style.pointerEvents="all";const t=this._iframe.parentNode;b(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("."+g);e&&e.classList.add(T.DISPLAY_NONE)}touchStart(t,e,n="rml_id"){var o,s;e.preventDefault();const a=(l,h)=>{this.dragStart(t,h,n)},r={};typeof((o=this.options)==null?void 0:o.touchDragDelay)=="number"&&(r.delay=this.options.touchDragDelay),(s=this.options)!=null&&s.touchDragEpsilon&&(r.epsilon=this.options.touchDragEpsilon),this._currentTouch=new z(void 0,{onTouchDragStart:a},r),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{A as DragIn};
|