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

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