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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,9 +37,9 @@ class P {
37
37
  }
38
38
  c.error ? o(c.error) : c.result !== void 0 ? r(c.result) : r(void 0), i.port1.close(), i.port2.close();
39
39
  };
40
- let d = "";
40
+ let g = "";
41
41
  try {
42
- d = JSON.stringify({ message: e, args: s });
42
+ g = JSON.stringify({ message: e, args: s });
43
43
  } catch {
44
44
  return o(
45
45
  new Error(
@@ -49,7 +49,7 @@ class P {
49
49
  }
50
50
  if (!this._outgoingMessageBus)
51
51
  return o(new Error(this._side + ": outgoing bus not set yet"));
52
- this._outgoingMessageBus.postMessage(d, "*", [
52
+ this._outgoingMessageBus.postMessage(g, "*", [
53
53
  i.port2
54
54
  ]);
55
55
  });
@@ -71,9 +71,9 @@ class P {
71
71
  return;
72
72
  o.then(
73
73
  (i = {}) => {
74
- let d, n;
75
- typeof i == "object" && i !== null && (d = i.error, n = i.result), d ? s.postMessage(
76
- JSON.stringify({ error: d })
74
+ let g, n;
75
+ typeof i == "object" && i !== null && (g = i.error, n = i.result), g ? s.postMessage(
76
+ JSON.stringify({ error: g })
77
77
  ) : n !== void 0 ? s.postMessage(
78
78
  JSON.stringify({ result: n })
79
79
  ) : s.postMessage(
@@ -113,24 +113,24 @@ const p = ".", E = {
113
113
  throw new Error(
114
114
  'Configurator ID is not a string type: "' + typeof t + '"'
115
115
  );
116
- const s = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = s + "/configurators/" + t, i = "roomle_portal_v2", d = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), n = () => {
117
- const h = {
116
+ const s = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = s + "/configurators/" + t, i = "roomle_portal_v2", g = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), n = () => {
117
+ const u = {
118
118
  apiKey: i,
119
119
  currentTenant: r,
120
120
  locale: "en",
121
121
  language: "en",
122
122
  device: 1,
123
- token: d,
123
+ token: g,
124
124
  platform: "web"
125
125
  };
126
- return new Headers(h);
126
+ return new Headers(u);
127
127
  }, c = new Request(o, {
128
128
  method: "GET",
129
129
  headers: n(),
130
130
  mode: "cors",
131
131
  cache: "default"
132
- }), a = await fetch(c), { configurator: g } = await a.json();
133
- return g;
132
+ }), a = await fetch(c), { configurator: f } = await a.json();
133
+ return f;
134
134
  }, H = () => {
135
135
  try {
136
136
  return window.self !== window.top;
@@ -166,11 +166,11 @@ const p = ".", E = {
166
166
  return "en";
167
167
  }, k = (t, e) => {
168
168
  const s = JSON.parse(JSON.stringify(t));
169
- return y(s, e);
170
- }, y = (t, e) => {
169
+ return O(s, e);
170
+ }, O = (t, e) => {
171
171
  for (const s in e)
172
172
  try {
173
- e[s].constructor === Object ? t[s] = y(t[s], e[s]) : t[s] = e[s];
173
+ e[s].constructor === Object ? t[s] = O(t[s], e[s]) : t[s] = e[s];
174
174
  } catch {
175
175
  t[s] = e[s];
176
176
  }
@@ -197,18 +197,18 @@ const W = {
197
197
  featureFlags: {
198
198
  mocAr: !0
199
199
  }
200
- }, G = "(idle)", J = (t) => (O(t), t != null && t.customApiUrl && (t.customApiUrl = decodeURIComponent(t.customApiUrl)), t.shareUrl && (t.deeplink = t.shareUrl.replace(
200
+ }, G = "(idle)", J = (t) => (w(t), t != null && t.customApiUrl && (t.customApiUrl = decodeURIComponent(t.customApiUrl)), t.shareUrl && (t.deeplink = t.shareUrl.replace(
201
201
  z,
202
202
  Y
203
- )), t), O = (t) => {
203
+ )), t), w = (t) => {
204
204
  if (!t)
205
205
  return;
206
206
  const e = Object.keys(t);
207
207
  for (const s of e) {
208
208
  const r = t[s];
209
- if (!Array.isArray(r) && typeof r == "object" && r !== null && O(r), Array.isArray(r))
209
+ if (!Array.isArray(r) && typeof r == "object" && r !== null && w(r), Array.isArray(r))
210
210
  for (const o of r)
211
- O(o);
211
+ w(o);
212
212
  (r === "true" || r === "false") && (t[s] = r === "true");
213
213
  }
214
214
  }, V = (t, e) => {
@@ -222,7 +222,7 @@ const W = {
222
222
  t.locale || (t.locale = U()), t.id === G && delete t.id;
223
223
  const e = C();
224
224
  return e && B(e) && (t.configuratorId = "demoConfigurator"), t.customApiUrl = x.VITE_RAPI_URL, t.emails = !1, t;
225
- }, z = "<CONF_ID>", Y = "#CONFIGURATIONID#", R = () => /(android)/i.test(navigator.userAgent), L = (t, e, s) => {
225
+ }, z = "<CONF_ID>", Y = "#CONFIGURATIONID#", L = () => /(android)/i.test(navigator.userAgent), R = (t, e, s) => {
226
226
  let r = null;
227
227
  Object.defineProperty(t, e, {
228
228
  get() {
@@ -236,10 +236,10 @@ const W = {
236
236
  });
237
237
  }, T = () => window.innerHeight * 0.01 + "px", b = (t) => {
238
238
  t && setTimeout(
239
- () => t.style.setProperty(w, T()),
239
+ () => t.style.setProperty(y, T()),
240
240
  0
241
241
  );
242
- }, S = "rml-styles", q = 450, w = "--rml-full-height", u = {
242
+ }, S = "rml-styles", q = 450, y = "--rml-full-height", d = {
243
243
  CONTAINER: "rml-container",
244
244
  FILL: "rml-fill",
245
245
  POSITION: "rml-pos",
@@ -278,38 +278,54 @@ class Q {
278
278
  if (!!!document.getElementById(S)) {
279
279
  const c = r.zIndex || 9999999, a = document.createElement("style");
280
280
  a.type = "text/css", a.id = S;
281
- const g = "transition:all ease-in-out " + q + "ms;", h = ["-webkit-", "-o-"].reduce(
282
- (f, _) => f += _ + g,
281
+ const f = "transition:all ease-in-out " + q + "ms;", u = ["-webkit-", "-o-"].reduce(
282
+ (m, _) => m += _ + f,
283
283
  ""
284
- ) + g, m = T();
284
+ ) + f, h = T();
285
285
  a.innerHTML = `
286
- .${u.CONTAINER}{${w}:${m};}
287
- .${u.POSITION}{position:fixed;top:0;left:0;z-index:${c};opacity:0}
288
- .${u.TRANSITION}{${h}}
289
- .${u.FILL}{width:100%;height:100%;opacity:1}
290
- .${u.ANDROID_HEIGHT}{height:calc(var(${w},1vh)*100)}
291
- .${u.OVERFLOW_HIDDEN}{overflow:hidden}
286
+ .${d.CONTAINER}{${y}:${h};}
287
+ .${d.POSITION}{position:fixed;top:0;left:0;z-index:${c};opacity:0}
288
+ .${d.TRANSITION}{${u}}
289
+ .${d.FILL}{width:100%;height:100%;opacity:1}
290
+ .${d.ANDROID_HEIGHT}{height:calc(var(${y},1vh)*100)}
291
+ .${d.OVERFLOW_HIDDEN}{overflow:hidden}
292
292
  `, document.head.appendChild(a);
293
293
  }
294
- this._onResize = this._onResize.bind(this), R() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = e;
294
+ this._onResize = this._onResize.bind(this), L() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = e;
295
295
  const n = this._createIframe();
296
296
  this._onUseFullPage = this._onUseFullPage.bind(this), this._executeMessage = this._executeMessage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._messageHandler = new P(
297
297
  "website",
298
298
  window,
299
299
  null,
300
300
  this._executeMessage
301
- ), this._waitForIframe = i, this._container.appendChild(n), this._iframe = n, o.includes("dragIn") && this.pluginsLoaded.push(
302
- new Promise((c, a) => {
303
- try {
304
- import("./drag-in-CAakt8yw.mjs").then(({ DragIn: g }) => {
305
- const h = new g(this._iframe);
306
- h.setInstance(this.ui), c(), this.plugins.dragIn = h;
307
- });
308
- } catch (g) {
309
- a(g);
310
- }
311
- })
312
- ), I.set(s, !0);
301
+ ), this._waitForIframe = i, this._container.appendChild(n), this._iframe = n;
302
+ for (const c of o)
303
+ typeof c == "string" && c === "dragIn" ? this.pluginsLoaded.push(
304
+ new Promise((a, f) => {
305
+ try {
306
+ import("./drag-in-DySSXLqX.mjs").then(
307
+ ({ DragIn: u }) => {
308
+ const h = new u(this._iframe);
309
+ h.setInstance(this.ui), this.plugins.dragIn = h, a();
310
+ }
311
+ );
312
+ } catch (u) {
313
+ f(u);
314
+ }
315
+ })
316
+ ) : c.name && c.loader && this.pluginsLoaded.push(
317
+ new Promise((a, f) => {
318
+ try {
319
+ c.loader().then((u) => {
320
+ const h = new u(this._iframe);
321
+ h.setInstance(this.ui), this.plugins[c.name] = h, a();
322
+ });
323
+ } catch (u) {
324
+ f(u);
325
+ }
326
+ })
327
+ );
328
+ I.set(s, !0);
313
329
  }
314
330
  static createPlanner(e, s, r, o = []) {
315
331
  return this._create(
@@ -363,9 +379,9 @@ class Q {
363
379
  );
364
380
  }
365
381
  static async _create(e, s, r, o) {
366
- return new Promise(async (i, d) => {
382
+ return new Promise(async (i, g) => {
367
383
  try {
368
- const n = y(
384
+ const n = O(
369
385
  $(),
370
386
  J(r)
371
387
  );
@@ -384,7 +400,7 @@ class Q {
384
400
  );
385
401
  return await Promise.allSettled(a.pluginsLoaded), a;
386
402
  } catch (n) {
387
- return d(n);
403
+ return g(n);
388
404
  }
389
405
  });
390
406
  }
@@ -397,16 +413,16 @@ class Q {
397
413
  var r;
398
414
  const e = document.createElement("iframe");
399
415
  let s = ((r = this._configuratorSettings) == null ? void 0 : r.url) || "https://www.roomle.com/t/cp/";
400
- 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(u.CONTAINER), e.classList.add(u.FILL), e;
416
+ 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(d.CONTAINER), e.classList.add(d.FILL), e;
401
417
  }
402
418
  _onResize() {
403
419
  b(this._iframe);
404
420
  }
405
421
  _onUseFullPage() {
406
- this._iframe.classList.add(u.POSITION), document.documentElement.classList.add(u.OVERFLOW_HIDDEN), window.document.body.classList.add(u.OVERFLOW_HIDDEN), R() && (b(this._iframe), this._iframe.classList.add(u.ANDROID_HEIGHT));
422
+ this._iframe.classList.add(d.POSITION), document.documentElement.classList.add(d.OVERFLOW_HIDDEN), window.document.body.classList.add(d.OVERFLOW_HIDDEN), L() && (b(this._iframe), this._iframe.classList.add(d.ANDROID_HEIGHT));
407
423
  }
408
424
  _onBackToWebsite() {
409
- this._iframe.classList.remove(u.POSITION), this._iframe.classList.remove(u.ANDROID_HEIGHT), document.documentElement.classList.remove(u.OVERFLOW_HIDDEN), window.document.body.classList.remove(u.OVERFLOW_HIDDEN);
425
+ this._iframe.classList.remove(d.POSITION), this._iframe.classList.remove(d.ANDROID_HEIGHT), document.documentElement.classList.remove(d.OVERFLOW_HIDDEN), window.document.body.classList.remove(d.OVERFLOW_HIDDEN);
410
426
  }
411
427
  _executeMessage({ message: e, args: s }, r) {
412
428
  var c;
@@ -415,21 +431,21 @@ class Q {
415
431
  if (e === E.REQUEST_BOOT)
416
432
  return this._messageHandler.setOutgoingMessageBus(r.source), Promise.resolve({ result: this._initData });
417
433
  if (e === E.SETUP) {
418
- const { methods: a, callbacks: g } = s[0];
419
- return a.forEach((h) => {
420
- const m = h.split(p), f = m[0], _ = m[1];
421
- this[f] || (this[f] = {}), this[f][_] = (function() {
422
- return this._messageHandler.sendMessage(h, [...arguments]);
434
+ const { methods: a, callbacks: f } = s[0];
435
+ return a.forEach((u) => {
436
+ const h = u.split(p), m = h[0], _ = h[1];
437
+ this[m] || (this[m] = {}), this[m][_] = (function() {
438
+ return this._messageHandler.sendMessage(u, [...arguments]);
423
439
  }).bind(this);
424
- }), g.forEach((h) => {
425
- const m = h.split(p), f = m[0], _ = m[1], N = m[2];
426
- this[f] || (this[f] = {}), this[f][_] || (this[f][_] = {}), this[f][_][N] = () => {
440
+ }), f.forEach((u) => {
441
+ const h = u.split(p), m = h[0], _ = h[1], N = h[2];
442
+ this[m] || (this[m] = {}), this[m][_] || (this[m][_] = {}), this[m][_][N] = () => {
427
443
  };
428
- }), L(
444
+ }), R(
429
445
  this.ui.callbacks,
430
446
  "onUseFullPage",
431
447
  this._onUseFullPage
432
- ), L(
448
+ ), R(
433
449
  this.ui.callbacks,
434
450
  "onBackToWebsite",
435
451
  this._onBackToWebsite
@@ -438,12 +454,12 @@ class Q {
438
454
  0
439
455
  ), Promise.resolve({ result: null });
440
456
  }
441
- const o = e.split(p), i = o[0], d = o[1], n = o.length === 3 ? o[2] : null;
442
- if (n && this[i][d][n]) {
443
- const a = this[i][d][n](
457
+ const o = e.split(p), i = o[0], g = o[1], n = o.length === 3 ? o[2] : null;
458
+ if (n && this[i][g][n]) {
459
+ const a = this[i][g][n](
444
460
  ...s
445
461
  );
446
- return a instanceof Promise ? a.then((g) => ({ result: g })) : a !== void 0 ? Promise.resolve({ result: a }) : Promise.resolve({ result: null });
462
+ return a instanceof Promise ? a.then((f) => ({ result: f })) : a !== void 0 ? Promise.resolve({ result: a }) : Promise.resolve({ result: null });
447
463
  }
448
464
  return Promise.reject('Message "' + e + '" is unkown');
449
465
  }
@@ -1,8 +1,8 @@
1
- var R=Object.defineProperty,S=(s,e,t)=>e in s?R(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,u=(s,e,t)=>S(s,typeof e!="symbol"?e+"":e,t);class A{constructor(e,t,r,i){u(this,"_side"),u(this,"_incomingMessageBus"),u(this,"_outgoingMessageBus",null),u(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((r,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 a;try{a=JSON.parse(o.data)}catch(l){return n.port1.close(),n.port2.close(),this._prepareError(l),i(l)}a.error?i(a.error):a.result!==void 0?r(a.result):r(void 0),n.port1.close(),n.port2.close()};let c="";try{c=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(c,"*",[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 r=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);const i=this._execMessage(r,e);if(i===void 0)return;i.then((n={})=>{let c,o;typeof n=="object"&&n!==null&&(c=n.error,o=n.result),c?t.postMessage(JSON.stringify({error:c})):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(r){t.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_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=".",w={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},P=async(s,e)=>{if(typeof s!="string")throw new Error('Configurator ID is not a string type: "'+typeof s+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=t+"/configurators/"+s,n="roomle_portal_v2",c="03-"+window.btoa(new Date().toISOString()+";anonymous;"+n),o=()=>{const m={apiKey:n,currentTenant:r,locale:"en",language:"en",device:1,token:c,platform:"web"};return new Headers(m)},a=new Request(i,{method:"GET",headers:o(),mode:"cors",cache:"default"}),l=await fetch(a),{configurator:g}=await l.json();return g},F=()=>{try{return window.self!==window.top}catch{return!0}},U=["127.0.0.1","localhost","0.0.0.0"],B=()=>{const s=F();let e=window.location.href;if(s){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},H=s=>!!(U.includes(s)||s.endsWith("roomle.com")||s.endsWith("gitlab.io")||s.endsWith("gitlab.com")),E=["language","browserLanguage","userLanguage","systemLanguage"],k=(s=null)=>{const e=window.navigator;if(s)return s.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,r=E.length;t<r;t++){const i=e[E[t]];if(i)return i.substr(0,2)}return"en"},x=(s,e)=>{const t=JSON.parse(JSON.stringify(s));return y(t,e)},y=(s,e)=>{for(const t in e)try{e[t].constructor===Object?s[t]=y(s[t],e[t]):s[t]=e[t]}catch{s[t]=e[t]}return s};var W={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const C={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}},J="(idle)",$=s=>(b(s),s!=null&&s.customApiUrl&&(s.customApiUrl=decodeURIComponent(s.customApiUrl)),s.shareUrl&&(s.deeplink=s.shareUrl.replace(j,G)),s),b=s=>{if(!s)return;const e=Object.keys(s);for(const t of e){const r=s[t];if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&b(r),Array.isArray(r))for(const i of r)b(i);(r==="true"||r==="false")&&(s[t]=r==="true")}},V=(s,e)=>{e.configuratorId=s.id;const t=s.settings||{};return!e.overrideTenant&&s.tenant&&(e.overrideTenant=s.tenant),x(t,e)},z=()=>{const s={...C};s.locale||(s.locale=k()),s.id===J&&delete s.id;const e=B();return e&&H(e)&&(s.configuratorId="demoConfigurator"),s.customApiUrl=W.VITE_RAPI_URL,s.emails=!1,s},j="<CONF_ID>",G="#CONFIGURATIONID#",v=()=>/(android)/i.test(navigator.userAgent),T=(s,e,t)=>{let r=null;Object.defineProperty(s,e,{get(){return r||t},set(i){i!=null&&i.mute?r=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 }"),r=i)}})},L=()=>window.innerHeight*.01+"px",M=s=>{s&&setTimeout(()=>s.style.setProperty(I,L()),0)},N="rml-styles",q=450,I="--rml-full-height",h={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 Y{constructor(e,t,r,i,n){if(u(this,"ui",{callbacks:null}),u(this,"extended",{callbacks:null}),u(this,"analytics",{callbacks:{}}),u(this,"global",{callbacks:{}}),u(this,"plugins",{}),u(this,"_waitForIframe"),u(this,"_container"),u(this,"_messageHandler"),u(this,"_configuratorSettings"),u(this,"_initData",{}),u(this,"_iframe"),u(this,"pluginsLoaded",[]),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(O.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(N)){const o=r.zIndex||9999999,a=document.createElement("style");a.type="text/css",a.id=N;const l="transition:all ease-in-out "+q+"ms;",g=["-webkit-","-o-"].reduce((f,d)=>f+=d+l,"")+l,m=L();a.innerHTML=`
2
- .${h.CONTAINER}{${I}:${m};}
3
- .${h.POSITION}{position:fixed;top:0;left:0;z-index:${o};opacity:0}
1
+ var R=Object.defineProperty,S=(s,e,t)=>e in s?R(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,u=(s,e,t)=>S(s,typeof e!="symbol"?e+"":e,t);class A{constructor(e,t,r,i){u(this,"_side"),u(this,"_incomingMessageBus"),u(this,"_outgoingMessageBus",null),u(this,"_execMessage",null),this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((r,i)=>{const o=new MessageChannel;o.port1.onmessage=n=>{if(!n||!n.data)return o.port1.close(),o.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let a;try{a=JSON.parse(n.data)}catch(l){return o.port1.close(),o.port2.close(),this._prepareError(l),i(l)}a.error?i(a.error):a.result!==void 0?r(a.result):r(void 0),o.port1.close(),o.port2.close()};let c="";try{c=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(c,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const r=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);const i=this._execMessage(r,e);if(i===void 0)return;i.then((o={})=>{let c,n;typeof o=="object"&&o!==null&&(c=o.error,n=o.result),c?t.postMessage(JSON.stringify({error:c})):n!==void 0?t.postMessage(JSON.stringify({result:n})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(r){t.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_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=".",w={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},P=async(s,e)=>{if(typeof s!="string")throw new Error('Configurator ID is not a string type: "'+typeof s+'"');const t=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=t+"/configurators/"+s,o="roomle_portal_v2",c="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),n=()=>{const d={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:c,platform:"web"};return new Headers(d)},a=new Request(i,{method:"GET",headers:n(),mode:"cors",cache:"default"}),l=await fetch(a),{configurator:g}=await l.json();return g},F=()=>{try{return window.self!==window.top}catch{return!0}},U=["127.0.0.1","localhost","0.0.0.0"],B=()=>{const s=F();let e=window.location.href;if(s){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},H=s=>!!(U.includes(s)||s.endsWith("roomle.com")||s.endsWith("gitlab.io")||s.endsWith("gitlab.com")),E=["language","browserLanguage","userLanguage","systemLanguage"],k=(s=null)=>{const e=window.navigator;if(s)return s.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,r=E.length;t<r;t++){const i=e[E[t]];if(i)return i.substr(0,2)}return"en"},x=(s,e)=>{const t=JSON.parse(JSON.stringify(s));return y(t,e)},y=(s,e)=>{for(const t in e)try{e[t].constructor===Object?s[t]=y(s[t],e[t]):s[t]=e[t]}catch{s[t]=e[t]}return s};var W={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const C={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}},J="(idle)",$=s=>(b(s),s!=null&&s.customApiUrl&&(s.customApiUrl=decodeURIComponent(s.customApiUrl)),s.shareUrl&&(s.deeplink=s.shareUrl.replace(j,G)),s),b=s=>{if(!s)return;const e=Object.keys(s);for(const t of e){const r=s[t];if(!Array.isArray(r)&&typeof r=="object"&&r!==null&&b(r),Array.isArray(r))for(const i of r)b(i);(r==="true"||r==="false")&&(s[t]=r==="true")}},V=(s,e)=>{e.configuratorId=s.id;const t=s.settings||{};return!e.overrideTenant&&s.tenant&&(e.overrideTenant=s.tenant),x(t,e)},z=()=>{const s={...C};s.locale||(s.locale=k()),s.id===J&&delete s.id;const e=B();return e&&H(e)&&(s.configuratorId="demoConfigurator"),s.customApiUrl=W.VITE_RAPI_URL,s.emails=!1,s},j="<CONF_ID>",G="#CONFIGURATIONID#",v=()=>/(android)/i.test(navigator.userAgent),T=(s,e,t)=>{let r=null;Object.defineProperty(s,e,{get(){return r||t},set(i){i!=null&&i.mute?r=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 }"),r=i)}})},L=()=>window.innerHeight*.01+"px",M=s=>{s&&setTimeout(()=>s.style.setProperty(I,L()),0)},N="rml-styles",q=450,I="--rml-full-height",h={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 Y{constructor(e,t,r,i,o){if(u(this,"ui",{callbacks:null}),u(this,"extended",{callbacks:null}),u(this,"analytics",{callbacks:{}}),u(this,"global",{callbacks:{}}),u(this,"plugins",{}),u(this,"_waitForIframe"),u(this,"_container"),u(this,"_messageHandler"),u(this,"_configuratorSettings"),u(this,"_initData",{}),u(this,"_iframe"),u(this,"pluginsLoaded",[]),!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(O.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(N)){const n=r.zIndex||9999999,a=document.createElement("style");a.type="text/css",a.id=N;const l="transition:all ease-in-out "+q+"ms;",g=["-webkit-","-o-"].reduce((f,m)=>f+=m+l,"")+l,d=L();a.innerHTML=`
2
+ .${h.CONTAINER}{${I}:${d};}
3
+ .${h.POSITION}{position:fixed;top:0;left:0;z-index:${n};opacity:0}
4
4
  .${h.TRANSITION}{${g}}
5
5
  .${h.FILL}{width:100%;height:100%;opacity:1}
6
6
  .${h.ANDROID_HEIGHT}{height:calc(var(${I},1vh)*100)}
7
7
  .${h.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(a)}this._onResize=this._onResize.bind(this),v()&&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 A("website",window,null,this._executeMessage),this._waitForIframe=n,this._container.appendChild(c),this._iframe=c,i.includes("dragIn")&&this.pluginsLoaded.push(new Promise((o,a)=>{try{import("./drag-in-C2fEQF9W.mjs").then(({DragIn:l})=>{const g=new l(this._iframe);g.setInstance(this.ui),o(),this.plugins.dragIn=g})}catch(l){a(l)}})),O.set(t,!0)}static createPlanner(e,t,r,i=[]){return this._create(e,t,r,i)}static createConfigurator(e,t,r,i=[]){return this._create(e,t,r,i)}static create(e,t,r,i){return this._create(e,t,r,i)}static createViewer(e,t,r,i=[]){return this._create(e,t,r,i)}static async _create(e,t,r,i){return new Promise(async(n,c)=>{try{const o=y(z(),$(r));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 a=await P(e,o);r=V(a,o);const l=new this(a,t,r,i,n);return await Promise.allSettled(l.pluginsLoaded),l}catch(o){return c(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 r=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),t.src=r,t.classList.add(h.CONTAINER),t.classList.add(h.FILL),t}_onResize(){M(this._iframe)}_onUseFullPage(){this._iframe.classList.add(h.POSITION),document.documentElement.classList.add(h.OVERFLOW_HIDDEN),window.document.body.classList.add(h.OVERFLOW_HIDDEN),v()&&(M(this._iframe),this._iframe.classList.add(h.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(h.POSITION),this._iframe.classList.remove(h.ANDROID_HEIGHT),document.documentElement.classList.remove(h.OVERFLOW_HIDDEN),window.document.body.classList.remove(h.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var i;if(!r.source||r.source!==((i=this._iframe)==null?void 0:i.contentWindow))return;if(e===w.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===w.SETUP){const{methods:l,callbacks:g}=t[0];return l.forEach(m=>{const f=m.split(p),d=f[0],_=f[1];this[d]||(this[d]={}),this[d][_]=function(){return this._messageHandler.sendMessage(m,[...arguments])}.bind(this)}),g.forEach(m=>{const f=m.split(p),d=f[0],_=f[1],D=f[2];this[d]||(this[d]={}),this[d][_]||(this[d][_]={}),this[d][_][D]=()=>{}}),T(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),T(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(w.WEBSITE_READY),0),Promise.resolve({result:null})}const n=e.split(p),c=n[0],o=n[1],a=n.length===3?n[2]:null;if(a&&this[c][o][a]){const l=this[c][o][a](...t);return l instanceof Promise?l.then(g=>({result:g})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}export{Y as default};
8
+ `,document.head.appendChild(a)}this._onResize=this._onResize.bind(this),v()&&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 A("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(c),this._iframe=c;for(const n of i)typeof n=="string"&&n==="dragIn"?this.pluginsLoaded.push(new Promise((a,l)=>{try{import("./drag-in-CzvP9xkx.mjs").then(({DragIn:g})=>{const d=new g(this._iframe);d.setInstance(this.ui),this.plugins.dragIn=d,a()})}catch(g){l(g)}})):n.name&&n.loader&&this.pluginsLoaded.push(new Promise((a,l)=>{try{n.loader().then(g=>{const d=new g(this._iframe);d.setInstance(this.ui),this.plugins[n.name]=d,a()})}catch(g){l(g)}}));O.set(t,!0)}static createPlanner(e,t,r,i=[]){return this._create(e,t,r,i)}static createConfigurator(e,t,r,i=[]){return this._create(e,t,r,i)}static create(e,t,r,i){return this._create(e,t,r,i)}static createViewer(e,t,r,i=[]){return this._create(e,t,r,i)}static async _create(e,t,r,i){return new Promise(async(o,c)=>{try{const n=y(z(),$(r));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 a=await P(e,n);r=V(a,n);const l=new this(a,t,r,i,o);return await Promise.allSettled(l.pluginsLoaded),l}catch(n){return c(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 r=((e=this._configuratorSettings)==null?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),t.src=r,t.classList.add(h.CONTAINER),t.classList.add(h.FILL),t}_onResize(){M(this._iframe)}_onUseFullPage(){this._iframe.classList.add(h.POSITION),document.documentElement.classList.add(h.OVERFLOW_HIDDEN),window.document.body.classList.add(h.OVERFLOW_HIDDEN),v()&&(M(this._iframe),this._iframe.classList.add(h.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(h.POSITION),this._iframe.classList.remove(h.ANDROID_HEIGHT),document.documentElement.classList.remove(h.OVERFLOW_HIDDEN),window.document.body.classList.remove(h.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:t},r){var i;if(!r.source||r.source!==((i=this._iframe)==null?void 0:i.contentWindow))return;if(e===w.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===w.SETUP){const{methods:l,callbacks:g}=t[0];return l.forEach(d=>{const f=d.split(p),m=f[0],_=f[1];this[m]||(this[m]={}),this[m][_]=function(){return this._messageHandler.sendMessage(d,[...arguments])}.bind(this)}),g.forEach(d=>{const f=d.split(p),m=f[0],_=f[1],D=f[2];this[m]||(this[m]={}),this[m][_]||(this[m][_]={}),this[m][_][D]=()=>{}}),T(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),T(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(w.WEBSITE_READY),0),Promise.resolve({result:null})}const o=e.split(p),c=o[0],n=o[1],a=o.length===3?o[2]:null;if(a&&this[c][n][a]){const l=this[c][n][a](...t);return l instanceof Promise?l.then(g=>({result:g})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}export{Y as default};
@@ -1,14 +1,14 @@
1
- (function(m,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(m=typeof globalThis<"u"?globalThis:m||self,m["roomle-embedding-lib"]=m["roomle-embedding-lib"]||{},m["roomle-embedding-lib"].umd=m["roomle-embedding-lib"].umd||{},m["roomle-embedding-lib"].umd.js=p())})(this,function(){"use strict";var pe=Object.defineProperty;var ye=(m,p,T)=>p in m?pe(m,p,{enumerable:!0,configurable:!0,writable:!0,value:T}):m[p]=T;var c=(m,p,T)=>ye(m,typeof p!="symbol"?p+"":p,T);class m{constructor(e,t,s,n){c(this,"_side");c(this,"_incomingMessageBus");c(this,"_outgoingMessageBus",null);c(this,"_execMessage",null);this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=n,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,n)=>{const o=new MessageChannel;o.port1.onmessage=i=>{if(!i||!i.data)return o.port1.close(),o.port2.close(),n(new Error(this._side+" received message but response can not be interpreted"));let u;try{u=JSON.parse(i.data)}catch(l){return o.port1.close(),o.port2.close(),this._prepareError(l),n(l)}u.error?n(u.error):u.result!==void 0?s(u.result):s(void 0),o.port1.close(),o.port2.close()};let a="";try{a=JSON.stringify({message:e,args:t})}catch{return n(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return n(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(a,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const n=this._execMessage(s,e);if(n===void 0)return;n.then((o={})=>{let a,i;typeof o=="object"&&o!==null&&(a=o.error,i=o.result),a?t.postMessage(JSON.stringify({error:a})):i!==void 0?t.postMessage(JSON.stringify({result:i})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const p=".",T={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},z=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,n=t+"/configurators/"+r,o="roomle_portal_v2",a="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),i=()=>{const _={apiKey:o,currentTenant:s,locale:"en",language:"en",device:1,token:a,platform:"web"};return new Headers(_)},u=new Request(n,{method:"GET",headers:i(),mode:"cors",cache:"default"}),l=await fetch(u),{configurator:f}=await l.json();return f},V=()=>{try{return window.self!==window.top}catch{return!0}},J=["127.0.0.1","localhost","0.0.0.0"],q=()=>{const r=V();let e=window.location.href;if(r){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},K=r=>!!(J.includes(r)||r.endsWith("roomle.com")||r.endsWith("gitlab.io")||r.endsWith("gitlab.com")),P=["language","browserLanguage","userLanguage","systemLanguage"],j=(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=P.length;t<s;t++){const n=e[P[t]];if(n)return n.substr(0,2)}return"en"},Q=(r,e)=>{const t=JSON.parse(JSON.stringify(r));return D(t,e)},D=(r,e)=>{for(const t in e)try{e[t].constructor===Object?r[t]=D(r[t],e[t]):r[t]=e[t]}catch{r[t]=e[t]}return r};var Z={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const ee={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}},te="(idle)",se=r=>(A(r),r!=null&&r.customApiUrl&&(r.customApiUrl=decodeURIComponent(r.customApiUrl)),r.shareUrl&&(r.deeplink=r.shareUrl.replace(oe,ie)),r),A=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&&A(s),Array.isArray(s))for(const n of s)A(n);(s==="true"||s==="false")&&(r[t]=s==="true")}},re=(r,e)=>{e.configuratorId=r.id;const t=r.settings||{};return!e.overrideTenant&&r.tenant&&(e.overrideTenant=r.tenant),Q(t,e)},ne=()=>{const r={...ee};r.locale||(r.locale=j()),r.id===te&&delete r.id;const e=q();return e&&K(e)&&(r.configuratorId="demoConfigurator"),r.customApiUrl=Z.VITE_RAPI_URL,r.emails=!1,r},oe="<CONF_ID>",ie="#CONFIGURATIONID#",F=()=>/(android)/i.test(navigator.userAgent),H=(r,e,t)=>{let s=null;Object.defineProperty(r,e,{get(){return s||t},set(n){n!=null&&n.mute?s=n.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),s=n)}})},U=()=>window.innerHeight*.01+"px",Y=r=>{r&&setTimeout(()=>r.style.setProperty(O,U()),0)},k="rml-styles",ae=450,O="--rml-full-height",g={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},b=new Map;class ce{constructor(e,t,s,n,o){c(this,"ui",{callbacks:null});c(this,"extended",{callbacks:null});c(this,"analytics",{callbacks:{}});c(this,"global",{callbacks:{}});c(this,"plugins",{});c(this,"_waitForIframe");c(this,"_container");c(this,"_messageHandler");c(this,"_configuratorSettings");c(this,"_initData",{});c(this,"_iframe");c(this,"pluginsLoaded",[]);if(!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(b.has(t))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(k)){const u=s.zIndex||9999999,l=document.createElement("style");l.type="text/css",l.id=k;const f="transition:all ease-in-out "+ae+"ms;",_=["-webkit-","-o-"].reduce((d,y)=>d+=y+f,"")+f,h=U();l.innerHTML=`
2
- .${g.CONTAINER}{${O}:${h};}
3
- .${g.POSITION}{position:fixed;top:0;left:0;z-index:${u};opacity:0}
4
- .${g.TRANSITION}{${_}}
5
- .${g.FILL}{width:100%;height:100%;opacity:1}
6
- .${g.ANDROID_HEIGHT}{height:calc(var(${O},1vh)*100)}
7
- .${g.OVERFLOW_HIDDEN}{overflow:hidden}
8
- `,document.head.appendChild(l)}this._onResize=this._onResize.bind(this),F()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const i=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(i),this._iframe=i,n.includes("dragIn")&&this.pluginsLoaded.push(new Promise((u,l)=>{try{Promise.resolve().then(()=>me).then(({DragIn:f})=>{const _=new f(this._iframe);_.setInstance(this.ui),u(),this.plugins.dragIn=_})}catch(f){l(f)}})),b.set(t,!0)}static createPlanner(e,t,s,n=[]){return this._create(e,t,s,n)}static createConfigurator(e,t,s,n=[]){return this._create(e,t,s,n)}static create(e,t,s,n){return this._create(e,t,s,n)}static createViewer(e,t,s,n=[]){return this._create(e,t,s,n)}static async _create(e,t,s,n){return new Promise(async(o,a)=>{try{const i=D(ne(),se(s));i.featureFlags||(i.featureFlags={}),typeof i.featureFlags.realPartList!="boolean"&&(i.featureFlags.realPartList=!0),typeof i.featureFlags.globalCallbacks!="boolean"&&(i.featureFlags.globalCallbacks=!0),typeof i.featureFlags.mocAr!="boolean"&&(i.featureFlags.mocAr=!1);const u=await z(e,i);s=re(u,i);const l=new this(u,t,s,n,o);return await Promise.allSettled(l.pluginsLoaded),l}catch(i){return a(i)}})}teardown(){this._container&&b.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var s;const e=document.createElement("iframe");let t=((s=this._configuratorSettings)==null?void 0:s.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(g.CONTAINER),e.classList.add(g.FILL),e}_onResize(){Y(this._iframe)}_onUseFullPage(){this._iframe.classList.add(g.POSITION),document.documentElement.classList.add(g.OVERFLOW_HIDDEN),window.document.body.classList.add(g.OVERFLOW_HIDDEN),F()&&(Y(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 u;if(!s.source||s.source!==((u=this._iframe)==null?void 0:u.contentWindow))return;if(e===T.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData});if(e===T.SETUP){const{methods:l,callbacks:f}=t[0];return l.forEach(_=>{const h=_.split(p),d=h[0],y=h[1];this[d]||(this[d]={}),this[d][y]=(function(){return this._messageHandler.sendMessage(_,[...arguments])}).bind(this)}),f.forEach(_=>{const h=_.split(p),d=h[0],y=h[1],w=h[2];this[d]||(this[d]={}),this[d][y]||(this[d][y]={}),this[d][y][w]=()=>{}}),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],i=n.length===3?n[2]:null;if(i&&this[o][a][i]){const l=this[o][a][i](...t);return l instanceof Promise?l.then(f=>({result:f})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}}class le{constructor(e=16){c(this,"_computedStyleCache",new Map);c(this,"_maxLifetime",16);c(this,"_cacheCleanInterval",null);this._maxLifetime=e}get(e){const t=this._computedStyleCache.get(e),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const n=getComputedStyle(e);return this._computedStyleCache.set(e,{style:n,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),n}_cleanUpCache(){const e=Date.now();for(const[t,{updated:s}]of this._computedStyleCache.entries())e-s>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}let L;const I=r=>(L||(L=new le),L.get(r)),B=(r,e,t)=>{const s=parseFloat(r),n=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const a=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*a}if(e==="rem"){const a=parseFloat(I(document.documentElement).fontSize);return s*a}if(e==="em"){const a=parseFloat(I(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]*n:0},$=(r,e,t={x:0,y:0})=>{const s=r.getBoundingClientRect(),o=I(r).transform;let a=0,i=0;if(o!=="none"){const h=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,d=o.match(h);d&&(a=B(d[1],d[2],r),i=B(d[3],d[4],r))}const{clientX:u,clientY:l}=N(e,t),f=u-s.left-a+r.scrollLeft,_=l-s.top-i+r.scrollTop;return{x:f,y:_}},N=(r,e)=>{const{clientX:t,clientY:s}=window.TouchEvent&&r instanceof TouchEvent?ue(r):r,n=t||e.x,o=s||e.y;return{clientX:n,clientY:o}},ue=r=>{if(r.touches.length){let{clientX:t,clientY:s}=r.touches[0];if(r.touches.length>1){const n=r.touches[1],o=n.clientX,a=n.clientY;t=(t+o)/2,s=(s+a)/2}return{clientX:t,clientY:s}}const e=r.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},he=500,de=10;class fe{constructor(e,{onTouchDragStart:t},s={}){c(this,"_touchDragTimeOut");c(this,"_onTouchDragStart");c(this,"_payload",null);c(this,"_delay");c(this,"_firstTouch",null);c(this,"_lastTouch",null);this._payload=e,this._onTouchDragStart=t,this._delay=s.delay||he}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)<de,t&&(this._onTouchDragStart(this._payload,e),this._resetTouches())}}}const G="rml-drag-in-styles",_e="rml-drag-in-drag-element",E="rml-drag-in-overlay",S="rml-drag-in-drag-ghost",R="rml-drag-in-fade-in",X="rml-drag-in-fade-out",x={DISPLAY_NONE:"rml-display-none"},W=.5,M="250ms",v="forwards",C=r=>r?!0:(console.warn("No instance set, cancel drag-in"),!1);class ge{constructor(e){c(this,"_iframe");c(this,"_currentDrag",{});c(this,"_currentTouch",null);c(this,"_firefoxDragPosition",{x:0,y:0});c(this,"_instance",null);c(this,"options",{});c(this,"_firefoxFallback",e=>{if(!this._currentDrag.event)return;const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});if(this._iframe=e,!!!document.getElementById(G)){const o=document.createElement("style");o.type="text/css",o.id=G,o.innerHTML=`
9
- .${x.DISPLAY_NONE}{display:none}
10
- .${E}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
11
- .${S}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
12
- @keyframes ${R} {from{opacity: 0;}to {opacity: ${W};}}
13
- @keyframes ${X} {from{opacity: ${W};}to {opacity: 0;}}
14
- `,document.head.appendChild(o)}const s=this._iframe.parentNode;let n=s.querySelector("."+S);n||(n=document.createElement("div"),n.classList.add(S),n.innerText=" ",s.appendChild(n)),this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}setInstance(e){this._instance=e}dragStart(e,t){const s=this._iframe.parentNode;if(I(s).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._iframe.style.pointerEvents="none";let o=s.querySelector("."+E);if(o||(o=document.createElement("div"),o.classList.add(E),s.appendChild(o)),o.classList.remove(x.DISPLAY_NONE),t instanceof DragEvent){t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const _=s.querySelector("."+S);this._currentDrag.event=t;const h=t.target.cloneNode();h.style.position="fixed",h.style.pointerEvents="none",h.style.opacity="0",h.style.animation=`${R} ${M} ${v}`,h.id=_e,h.style.zIndex="9999",document.body.appendChild(h),this._currentDrag.element=h;const d=t.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:y,clientY:w}=N(t,this._firefoxDragPosition);this._currentDrag.offset.x=y-d.left,this._currentDrag.offset.y=w-d.top,h.style.top=w+"px",h.style.left=y+"px",t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(_,0,0)}const{x:a,y:i}=$(s,this._currentDrag.event||t,this._firefoxDragPosition),u=Math.max(1,a),l=Math.max(1,i);C(this._instance)&&this._instance.dragInObject(e,u,l)}dragUpdate(e){var i,u;const t=this._iframe.parentNode,{x:s,y:n}=$(t,e,this._firefoxDragPosition);if(s===0&&n===0)return;const o=Math.max(1,s),a=Math.max(1,n);if(this._currentDrag.element){const{clientX:l,clientY:f}=N(e,this._firefoxDragPosition),_=((i=this._currentDrag.offset)==null?void 0:i.x)||0,h=((u=this._currentDrag.offset)==null?void 0:u.y)||0;this._currentDrag.element.style.left=`${l-_}px`,this._currentDrag.element.style.top=`${f-h}px`;const d=(this.options.dragInOverlapX||0)+1,y=(this.options.dragInOverlapY||0)+1;o>d&&a>y?this._currentDrag.element.style.animation=`${X} ${M} ${v}`:this._currentDrag.element.style.animation=`${R} ${M} ${v}`}o===1&&a===1||C(this._instance)&&this._instance.updateDrag(o,a)}dragEnd(){this._iframe.style.pointerEvents="all";const e=this._iframe.parentNode;C(this._instance)&&this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+E);t&&t.classList.add(x.DISPLAY_NONE)}touchStart(e,t){t.preventDefault();const s=(n,o)=>{this.dragStart(e,o)};this._currentTouch=new fe(void 0,{onTouchDragStart:s}),this._currentTouch.onTouchStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onTouchMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onTouchEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}}const me=Object.freeze(Object.defineProperty({__proto__:null,DragIn:ge},Symbol.toStringTag,{value:"Module"}));return ce});
1
+ (function(m,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(m=typeof globalThis<"u"?globalThis:m||self,m["roomle-embedding-lib"]=m["roomle-embedding-lib"]||{},m["roomle-embedding-lib"].umd=m["roomle-embedding-lib"].umd||{},m["roomle-embedding-lib"].umd.js=p())})(this,function(){"use strict";var ye=Object.defineProperty;var Te=(m,p,T)=>p in m?ye(m,p,{enumerable:!0,configurable:!0,writable:!0,value:T}):m[p]=T;var l=(m,p,T)=>Te(m,typeof p!="symbol"?p+"":p,T);class m{constructor(e,t,s,n){l(this,"_side");l(this,"_incomingMessageBus");l(this,"_outgoingMessageBus",null);l(this,"_execMessage",null);this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=n,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,n)=>{const o=new MessageChannel;o.port1.onmessage=a=>{if(!a||!a.data)return o.port1.close(),o.port2.close(),n(new Error(this._side+" received message but response can not be interpreted"));let i;try{i=JSON.parse(a.data)}catch(u){return o.port1.close(),o.port2.close(),this._prepareError(u),n(u)}i.error?n(i.error):i.result!==void 0?s(i.result):s(void 0),o.port1.close(),o.port2.close()};let c="";try{c=JSON.stringify({message:e,args:t})}catch{return n(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return n(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(c,"*",[o.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const n=this._execMessage(s,e);if(n===void 0)return;n.then((o={})=>{let c,a;typeof o=="object"&&o!==null&&(c=o.error,a=o.result),c?t.postMessage(JSON.stringify({error:c})):a!==void 0?t.postMessage(JSON.stringify({result:a})):t.postMessage(JSON.stringify({result:o}))},o=>{t.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const p=".",T={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},q=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,n=t+"/configurators/"+r,o="roomle_portal_v2",c="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),a=()=>{const h={apiKey:o,currentTenant:s,locale:"en",language:"en",device:1,token:c,platform:"web"};return new Headers(h)},i=new Request(n,{method:"GET",headers:a(),mode:"cors",cache:"default"}),u=await fetch(i),{configurator:d}=await u.json();return d},K=()=>{try{return window.self!==window.top}catch{return!0}},j=["127.0.0.1","localhost","0.0.0.0"],Q=()=>{const r=K();let e=window.location.href;if(r){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},Z=r=>!!(j.includes(r)||r.endsWith("roomle.com")||r.endsWith("gitlab.io")||r.endsWith("gitlab.com")),P=["language","browserLanguage","userLanguage","systemLanguage"],ee=(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=P.length;t<s;t++){const n=e[P[t]];if(n)return n.substr(0,2)}return"en"},te=(r,e)=>{const t=JSON.parse(JSON.stringify(r));return S(t,e)},S=(r,e)=>{for(const t in e)try{e[t].constructor===Object?r[t]=S(r[t],e[t]):r[t]=e[t]}catch{r[t]=e[t]}return r};var se={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const re={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}},ne="(idle)",oe=r=>(w(r),r!=null&&r.customApiUrl&&(r.customApiUrl=decodeURIComponent(r.customApiUrl)),r.shareUrl&&(r.deeplink=r.shareUrl.replace(ce,le)),r),w=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&&w(s),Array.isArray(s))for(const n of s)w(n);(s==="true"||s==="false")&&(r[t]=s==="true")}},ie=(r,e)=>{e.configuratorId=r.id;const t=r.settings||{};return!e.overrideTenant&&r.tenant&&(e.overrideTenant=r.tenant),te(t,e)},ae=()=>{const r={...re};r.locale||(r.locale=ee()),r.id===ne&&delete r.id;const e=Q();return e&&Z(e)&&(r.configuratorId="demoConfigurator"),r.customApiUrl=se.VITE_RAPI_URL,r.emails=!1,r},ce="<CONF_ID>",le="#CONFIGURATIONID#",F=()=>/(android)/i.test(navigator.userAgent),H=(r,e,t)=>{let s=null;Object.defineProperty(r,e,{get(){return s||t},set(n){n!=null&&n.mute?s=n.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),s=n)}})},U=()=>window.innerHeight*.01+"px",Y=r=>{r&&setTimeout(()=>r.style.setProperty(A,U()),0)},k="rml-styles",ue=450,A="--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"},O=new Map;class he{constructor(e,t,s,n,o){l(this,"ui",{callbacks:null});l(this,"extended",{callbacks:null});l(this,"analytics",{callbacks:{}});l(this,"global",{callbacks:{}});l(this,"plugins",{});l(this,"_waitForIframe");l(this,"_container");l(this,"_messageHandler");l(this,"_configuratorSettings");l(this,"_initData",{});l(this,"_iframe");l(this,"pluginsLoaded",[]);if(!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(k)){const i=s.zIndex||9999999,u=document.createElement("style");u.type="text/css",u.id=k;const d="transition:all ease-in-out "+ue+"ms;",h=["-webkit-","-o-"].reduce((f,y)=>f+=y+d,"")+d,g=U();u.innerHTML=`
2
+ .${_.CONTAINER}{${A}:${g};}
3
+ .${_.POSITION}{position:fixed;top:0;left:0;z-index:${i};opacity:0}
4
+ .${_.TRANSITION}{${h}}
5
+ .${_.FILL}{width:100%;height:100%;opacity:1}
6
+ .${_.ANDROID_HEIGHT}{height:calc(var(${A},1vh)*100)}
7
+ .${_.OVERFLOW_HIDDEN}{overflow:hidden}
8
+ `,document.head.appendChild(u)}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 m("website",window,null,this._executeMessage),this._waitForIframe=o,this._container.appendChild(a),this._iframe=a;for(const i of n)typeof i=="string"&&i==="dragIn"?this.pluginsLoaded.push(new Promise((u,d)=>{try{Promise.resolve().then(()=>pe).then(({DragIn:h})=>{const g=new h(this._iframe);g.setInstance(this.ui),this.plugins.dragIn=g,u()})}catch(h){d(h)}})):i.name&&i.loader&&this.pluginsLoaded.push(new Promise((u,d)=>{try{i.loader().then(h=>{const g=new h(this._iframe);g.setInstance(this.ui),this.plugins[i.name]=g,u()})}catch(h){d(h)}}));O.set(t,!0)}static createPlanner(e,t,s,n=[]){return this._create(e,t,s,n)}static createConfigurator(e,t,s,n=[]){return this._create(e,t,s,n)}static create(e,t,s,n){return this._create(e,t,s,n)}static createViewer(e,t,s,n=[]){return this._create(e,t,s,n)}static async _create(e,t,s,n){return new Promise(async(o,c)=>{try{const a=S(ae(),oe(s));a.featureFlags||(a.featureFlags={}),typeof a.featureFlags.realPartList!="boolean"&&(a.featureFlags.realPartList=!0),typeof a.featureFlags.globalCallbacks!="boolean"&&(a.featureFlags.globalCallbacks=!0),typeof a.featureFlags.mocAr!="boolean"&&(a.featureFlags.mocAr=!1);const i=await q(e,a);s=ie(i,a);const u=new this(i,t,s,n,o);return await Promise.allSettled(u.pluginsLoaded),u}catch(a){return c(a)}})}teardown(){this._container&&O.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var s;const e=document.createElement("iframe");let t=((s=this._configuratorSettings)==null?void 0:s.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},s){var i;if(!s.source||s.source!==((i=this._iframe)==null?void 0:i.contentWindow))return;if(e===T.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData});if(e===T.SETUP){const{methods:u,callbacks:d}=t[0];return u.forEach(h=>{const g=h.split(p),f=g[0],y=g[1];this[f]||(this[f]={}),this[f][y]=(function(){return this._messageHandler.sendMessage(h,[...arguments])}).bind(this)}),d.forEach(h=>{const g=h.split(p),f=g[0],y=g[1],v=g[2];this[f]||(this[f]={}),this[f][y]||(this[f][y]={}),this[f][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],c=n[1],a=n.length===3?n[2]:null;if(a&&this[o][c][a]){const u=this[o][c][a](...t);return u instanceof Promise?u.then(d=>({result:d})):u!==void 0?Promise.resolve({result:u}):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),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const n=getComputedStyle(e);return this._computedStyleCache.set(e,{style:n,updated:s}),this._cacheCleanInterval||(this._cacheCleanInterval=setInterval(()=>this._cleanUpCache,Math.max(this._maxLifetime*1e3,5e3))),n}_cleanUpCache(){const e=Date.now();for(const[t,{updated:s}]of this._computedStyleCache.entries())e-s>=this._maxLifetime&&this._computedStyleCache.delete(t);this._computedStyleCache.size===0&&this._cacheCleanInterval&&(clearInterval(this._cacheCleanInterval),this._cacheCleanInterval=null)}}const B=r=>window.TouchEvent&&r instanceof window.TouchEvent;let b;const E=r=>(b||(b=new de),b.get(r)),$=(r,e,t)=>{const s=parseFloat(r),n=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const c=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*c}if(e==="rem"){const c=parseFloat(E(document.documentElement).fontSize);return s*c}if(e==="em"){const c=parseFloat(E(t).fontSize);return s*c}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const c={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*c[e]}const o={cm:37.7952755906,mm:3.77952755906,in:96};return e in o?s*o[e]*n:(console.warn("Unable to determine coordinates for drag-in. Therefore drag-in is not possible. Check the CSS that positions the iframe of Roomle"),0)},G=(r,e,t={x:0,y:0})=>{const s=r.getBoundingClientRect(),o=E(r).transform;let c=0,a=0;if(o!=="none"){const g=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,f=o.match(g);f&&(c=$(f[1],f[2],r),a=$(f[3],f[4],r))}const{clientX:i,clientY:u}=L(e,t),d=i-s.left-c+r.scrollLeft,h=u-s.top-a+r.scrollTop;return{x:d,y:h}},L=(r,e)=>{const{clientX:t,clientY:s}=B(r)?fe(r):r,n=t||e.x,o=s||e.y;return{clientX:n,clientY:o}},fe=r=>{if(r.touches.length){let{clientX:t,clientY:s}=r.touches[0];if(r.touches.length>1){const n=r.touches[1],o=n.clientX,c=n.clientY;t=(t+o)/2,s=(s+c)/2}return{clientX:t,clientY:s}}const e=r.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},X=500,z=10;class ge{constructor(e,{onTouchDragStart:t},s={}){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=s.delay||X,this._epsilon=s.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=r=>r?!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
+ .${R.DISPLAY_NONE}{display:none}
10
+ .${I}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
11
+ .${D}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
12
+ @keyframes ${N} {from{opacity: 0;}to {opacity: ${J};}}
13
+ @keyframes ${V} {from{opacity: ${J};}to {opacity: 0;}}
14
+ `,document.head.appendChild(t)}}_initializeDragGhost(){const e=this._iframe.parentNode;let t=e.querySelector("."+D);t||(t=document.createElement("div"),t.classList.add(D),t.innerText=" ",e.appendChild(t))}setInstance(e){this._instance=e}dragStart(e,t){const s=this._iframe.parentNode;if(E(s).position!=="relative"){console.warn("Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly");return}this._iframe.style.pointerEvents="none";let o=s.querySelector("."+I);o||(o=document.createElement("div"),o.classList.add(I),s.appendChild(o)),o.classList.remove(R.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 a=s.querySelector("."+D);this._currentDrag.event=t;const i=t.target.cloneNode();i.style.position="fixed",i.style.pointerEvents="none",i.style.opacity="0",i.style.animation=`${N} ${x} ${M}`,i.id=_e,i.style.zIndex="9999",document.body.appendChild(i),this._currentDrag.element=i;const u=t.target.getBoundingClientRect();this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:d,clientY:h}=L(t,this._firefoxDragPosition);this._currentDrag.offset.x=d-u.left,this._currentDrag.offset.y=h-u.top,i.style.top=h+"px",i.style.left=d+"px",t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(a,0,0);const{x:g,y:f}=G(s,this._currentDrag.event||t,this._firefoxDragPosition),y=Math.max(1,g),v=Math.max(1,f);C(this._instance)&&this._instance.dragInObject(e,y,v)}dragUpdate(e){var a,i;const t=this._iframe.parentNode,{x:s,y:n}=G(t,e,this._firefoxDragPosition);if(s===0&&n===0)return;const o=Math.max(1,s),c=Math.max(1,n);if(this._currentDrag.element){const{clientX:u,clientY:d}=L(e,this._firefoxDragPosition),h=((a=this._currentDrag.offset)==null?void 0:a.x)||0,g=((i=this._currentDrag.offset)==null?void 0:i.y)||0;this._currentDrag.element.style.left=`${u-h}px`,this._currentDrag.element.style.top=`${d-g}px`;const f=(this.options.dragInOverlapX||0)+1,y=(this.options.dragInOverlapY||0)+1;o>f&&c>y?this._currentDrag.element.style.animation=`${V} ${x} ${M}`:this._currentDrag.element.style.animation=`${N} ${x} ${M}`}if(!(o===1&&c===1)&&C(this._instance)){let u=o,d=c;if(B(e)){const h=this.options.fingerSize||0;u=Math.max(2,o+h),d=Math.max(2,c-h)}this._instance.updateDrag(u,d)}}dragEnd(){this._iframe.style.pointerEvents="all";const e=this._iframe.parentNode;C(this._instance)&&this._instance.dragInObjectEnd(),this._currentDrag.element&&document.body.removeChild(this._currentDrag.element),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+I);t&&t.classList.add(R.DISPLAY_NONE)}touchStart(e,t){var o,c;t.preventDefault();const s=(a,i)=>{this.dragStart(e,i)},n={};(o=this.options)!=null&&o.touchDragDelay&&(n.delay=this.options.touchDragDelay),(c=this.options)!=null&&c.touchDragEpsilon&&(n.epsilon=this.options.touchDragEpsilon),this._currentTouch=new ge(void 0,{onTouchDragStart:s},n),this._currentTouch.onTouchStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onTouchMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onTouchEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}}const pe=Object.freeze(Object.defineProperty({__proto__:null,DragIn:me},Symbol.toStringTag,{value:"Module"}));return he});