@roomle/embedding-lib 6.5.0-alpha.2 → 6.5.0

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.
@@ -0,0 +1,249 @@
1
+ import { i as o, e as X, b as A } from "./utils-Dav4kGNW.mjs";
2
+ import { i as Y, h as L, g as c } from "./embedding-plugins-DqMSzAJe.mjs";
3
+ import { E } from "./drag-ghost-DHrf_Evu.mjs";
4
+ const m = 500, f = 10, R = 100, I = 15, g = (i, t = 0) => o(i) ? {
5
+ clientX: i.touches[t].clientX,
6
+ clientY: i.touches[t].clientY
7
+ } : {
8
+ clientX: i.clientX,
9
+ clientY: i.clientY
10
+ }, b = (i) => i && o(i) ? i.touches.length > 0 : !0;
11
+ class M {
12
+ _touchDragTimeOut;
13
+ _onTouchDragStart;
14
+ _payload = null;
15
+ _delay = m;
16
+ _firstTouch = null;
17
+ _lastTouch = null;
18
+ _epsilon = f;
19
+ constructor(t, { onTouchDragStart: s }, e = {}) {
20
+ this._payload = t, this._onTouchDragStart = s, this._delay = typeof e.delay == "number" ? e.delay : m, this._epsilon = typeof e.epsilon == "number" ? e.epsilon : f;
21
+ }
22
+ onStart(t) {
23
+ b(t) && (this._touchDragTimeOut || (this._firstTouch = g(
24
+ t,
25
+ o(t) ? t.touches.length - 1 : 0
26
+ ), this._touchDragTimeOut = setTimeout(() => {
27
+ this._clearTimeout(), this._lastTouch || (this._lastTouch = g(t)), this._checkXDistance(t)();
28
+ }, this._delay)));
29
+ }
30
+ onEnd() {
31
+ this._resetTouches();
32
+ }
33
+ onMove(t) {
34
+ b(t) && (this._lastTouch = g(t));
35
+ }
36
+ _clearTimeout() {
37
+ this._touchDragTimeOut && (clearTimeout(this._touchDragTimeOut), this._touchDragTimeOut = null);
38
+ }
39
+ _resetTouches() {
40
+ this._clearTimeout(), this._lastTouch = null, this._firstTouch = null, this._payload = null;
41
+ }
42
+ _checkXDistance(t) {
43
+ return () => {
44
+ if (!this._firstTouch || !this._lastTouch)
45
+ return;
46
+ let s = !1;
47
+ s = Math.abs(
48
+ this._firstTouch.clientX - this._lastTouch.clientX
49
+ ) < this._epsilon, s && (this._onTouchDragStart(this._payload, t), this._resetTouches());
50
+ };
51
+ }
52
+ }
53
+ const U = (i) => `[data-rml-custom-view="${i}"]`, u = (i) => {
54
+ i.preventDefault(), i.stopPropagation();
55
+ }, x = (i, t, s, e) => {
56
+ const a = s - i, r = e - t;
57
+ return Math.sqrt(a * a + r * r);
58
+ };
59
+ class H {
60
+ _startX = 0;
61
+ _startY = 0;
62
+ _lastX = 0;
63
+ _lastY = 0;
64
+ _epsilon;
65
+ _isWaiting = !1;
66
+ _onCustomDragStart;
67
+ constructor({ onCustomDragStart: t }, s = {}) {
68
+ this._epsilon = typeof s.epsilon == "number" ? s.epsilon : I, this._onCustomDragStart = t;
69
+ }
70
+ onMove(t) {
71
+ this._lastX = t.clientX, this._lastY = t.clientY, this._isWaiting && x(
72
+ this._startX,
73
+ this._startY,
74
+ this._lastX,
75
+ this._lastY
76
+ ) > this._epsilon && (this._onCustomDragStart(t), this._isWaiting = !1);
77
+ }
78
+ onStart(t) {
79
+ this._startX = t.clientX, this._startY = t.clientY, this.onMove(t), this._isWaiting = !0;
80
+ }
81
+ onEnd() {
82
+ this._reset();
83
+ }
84
+ _reset() {
85
+ this._startX = 0, this._startY = 0, this._lastX = 0, this._lastY = 0, this._isWaiting = !1;
86
+ }
87
+ }
88
+ const d = "data-rml-old-draggable", K = void 0, y = (i, t) => {
89
+ const s = o(i), e = {
90
+ delay: s ? m : R,
91
+ epsilon: s ? f : I
92
+ };
93
+ if (!t)
94
+ return e;
95
+ if (!s && !(i instanceof MouseEvent))
96
+ return console.warn(
97
+ "Unsupported event! It is not TouchEvent and also not MouseEvent"
98
+ ), e;
99
+ const {
100
+ delayKey: a,
101
+ epsilonKey: r
102
+ } = s ? { delayKey: "touchDragDelay", epsilonKey: "touchDragEpsilon" } : { delayKey: "customDragDelay", epsilonKey: "customDragEpsilon" };
103
+ return typeof t[a] == "number" && (e.delay = t.touchDragDelay), typeof t[r] == "number" && (e.epsilon = t.touchDragEpsilon), e;
104
+ }, N = (i) => {
105
+ let t = "", s = L, e = Y;
106
+ if (!i)
107
+ return { url: c, width: s, height: e };
108
+ const a = i;
109
+ if (a instanceof HTMLElement) {
110
+ const r = a.getBoundingClientRect(), n = a.getAttribute("data-rml-ghost-url"), h = a.getAttribute("data-rml-ghost-width"), l = a.getAttribute("data-rml-ghost-height");
111
+ n ? t = n : !n && a instanceof HTMLImageElement && a.src && (t = a.src), t ? (s = r.width, e = r.height) : t = c, s = h ? parseInt(h, 10) : s, e = l ? parseInt(l, 10) : e;
112
+ }
113
+ return { url: t || c, width: s, height: e };
114
+ };
115
+ class P {
116
+ _options = {};
117
+ _instance;
118
+ _mainDomElement;
119
+ _viewName;
120
+ _currentCustomDrag = null;
121
+ _currentBb = null;
122
+ _startTarget = null;
123
+ _dragGhost = null;
124
+ _onBeforeUpdateDrag = () => ({});
125
+ isDragging = !1;
126
+ _hasEnteredIframe = !1;
127
+ _pendingDragIn = null;
128
+ _canvasBb = null;
129
+ _overlayBb = null;
130
+ _dragGeneration = 0;
131
+ _interactionContainerBb = null;
132
+ constructor(t, s, e, a) {
133
+ this._instance = t, this._options = e || {}, this._viewName = a, this._mainDomElement = s, this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
134
+ this._instance.cancelDragIn();
135
+ });
136
+ }
137
+ beforeUpdateGhost(t) {
138
+ this._onBeforeUpdateDrag = t;
139
+ }
140
+ async _dragStart(t, s, e = "rml_id") {
141
+ const a = ++this._dragGeneration;
142
+ if (this._startTarget && (this._startTarget.style.pointerEvents = "none", this._startTarget.style.userSelect = "none", this._startTarget.setAttribute(
143
+ d,
144
+ this._startTarget.draggable.toString()
145
+ ), this._startTarget.draggable = !1, this._startTarget.removeEventListener("dragstart", u), this._startTarget.addEventListener("dragstart", u)), this._startTarget) {
146
+ const r = this._startTarget.getBoundingClientRect(), n = this._startTarget.cloneNode(!0);
147
+ n.style.width = `${r.width}px`, n.style.height = `${r.height}px`, this._dragGhost = new E(n);
148
+ } else
149
+ this._dragGhost = new E();
150
+ this._currentBb = await this._instance.getBoundingClientRect(
151
+ U(this._viewName)
152
+ ), this._canvasBb = await this._instance.getBoundingClientRect("canvas"), this._overlayBb = (await this._instance.getDrawerBoundingClientRect()).final, this._interactionContainerBb = await this._instance.getBoundingClientRect(
153
+ ".interaction-container"
154
+ ), a === this._dragGeneration && (this._pendingDragIn = { id: t, type: e }, this._hasEnteredIframe = !1, this.isDragging = !0);
155
+ }
156
+ _dragUpdate(t) {
157
+ document.body.focus(), this._currentCustomDrag && this._currentCustomDrag.onMove(t);
158
+ const { clientX: s, clientY: e } = X(t);
159
+ if (this._dragGhost) {
160
+ const { width: v, height: w } = this._mainDomElement.getBoundingClientRect();
161
+ this._dragGhost.updateDragGhost(s, e, {
162
+ ghost: { visibleIn: { x: 0, y: 0, width: v, height: w } }
163
+ });
164
+ }
165
+ if (!this._currentBb || !this.isDragging)
166
+ return;
167
+ const a = this._currentBb.x + s, r = this._currentBb.y + e, n = A(
168
+ a,
169
+ r,
170
+ this._canvasBb,
171
+ this._overlayBb,
172
+ this._interactionContainerBb
173
+ );
174
+ if (n && !this._hasEnteredIframe && this._pendingDragIn && (this._instance.dragInObject(
175
+ this._pendingDragIn.id,
176
+ a,
177
+ r,
178
+ this._pendingDragIn.type
179
+ ), this._hasEnteredIframe = !0), !n && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1), !this._hasEnteredIframe)
180
+ return;
181
+ const { url: h, width: l, height: C } = N(this._startTarget), _ = this._options || {}, D = {
182
+ ghost: {
183
+ visibleIn: {
184
+ x: this._currentBb.x - (_.dragInOverlapX || 0),
185
+ y: this._currentBb.y + (_.dragInOverlapY || 0),
186
+ width: this._currentBb.width + (_.dragInOverlapX || 0),
187
+ height: this._currentBb.height + (_.dragInOverlapY || 0)
188
+ },
189
+ url: h,
190
+ width: l,
191
+ height: C
192
+ },
193
+ mode: "custom-view"
194
+ }, {
195
+ x: p,
196
+ y: T,
197
+ options: B
198
+ } = this._onBeforeUpdateDrag(a, r, D), G = typeof p == "number" ? p : a, S = typeof T == "number" ? T : r, O = B || D;
199
+ this._instance.updateDrag(G, S, O);
200
+ }
201
+ _dragEnd() {
202
+ this._currentCustomDrag && this._currentCustomDrag.onEnd(), this._currentCustomDrag = null, this.isDragging = !1, this._currentBb = null, this._canvasBb = null, this._overlayBb = null, this._interactionContainerBb = null, this._resetStartTarget(), this._instance.enableEvents(), this._dragGhost && (this._dragGhost.removeDragGhost(), this._dragGhost = null), this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._hasEnteredIframe = !1, this._pendingDragIn = null;
203
+ }
204
+ dragStart(t, s, e) {
205
+ this._instance.disableEvents(), this._startTarget = s.target;
206
+ const a = (r, n) => {
207
+ this._dragStart(t, n, e);
208
+ };
209
+ this._currentCustomDrag = o(s) ? new M(
210
+ K,
211
+ {
212
+ onTouchDragStart: a
213
+ },
214
+ // No long-press delay for custom-view — drag should start immediately on touch
215
+ { ...y(s, this._options), delay: 0 }
216
+ ) : new H(
217
+ {
218
+ onCustomDragStart: (r) => this._dragStart(t, r, e)
219
+ },
220
+ y(s, this._options)
221
+ ), this._currentCustomDrag.onStart(s);
222
+ }
223
+ dragEnd() {
224
+ this._dragEnd();
225
+ }
226
+ dragUpdate(t) {
227
+ this._dragUpdate(t);
228
+ }
229
+ touchStart(t, s, e = "rml_id") {
230
+ this.dragStart(t, s, e);
231
+ }
232
+ touchMove(t) {
233
+ this.dragUpdate(t);
234
+ }
235
+ touchEnd() {
236
+ this.dragEnd();
237
+ }
238
+ dispose() {
239
+ }
240
+ _resetStartTarget() {
241
+ this._startTarget && (this._startTarget.style.pointerEvents = "", this._startTarget.style.userSelect = "", this._startTarget.draggable = this._startTarget.getAttribute(d) === "true", this._startTarget.removeAttribute(d), this._startTarget.removeEventListener("dragstart", u));
242
+ }
243
+ releaseInput(t) {
244
+ this._dragGeneration++, this._dragEnd();
245
+ }
246
+ }
247
+ export {
248
+ P as DragInFromCustomViewStrategy
249
+ };
@@ -0,0 +1,134 @@
1
+ import { g as C, e as E, a as b, i as v } from "./utils-Dav4kGNW.mjs";
2
+ import { R as u, a as x, b as B } from "./embedding-plugins-DqMSzAJe.mjs";
3
+ import { E as L } from "./drag-ghost-DHrf_Evu.mjs";
4
+ class Y {
5
+ _options = {};
6
+ _instance;
7
+ _mainDomElement;
8
+ _currentDrag = {};
9
+ _firefoxDragPosition = { x: 0, y: 0 };
10
+ _onBeforeUpdateDrag = () => ({});
11
+ isDragging = !1;
12
+ _hasEnteredIframe = !1;
13
+ _pendingDragIn = null;
14
+ _canvasBb = null;
15
+ _overlayBb = null;
16
+ _interactionContainerBb = null;
17
+ _currentTouch = null;
18
+ _firefoxFallback = (e) => {
19
+ if (!this._currentDrag.event)
20
+ return;
21
+ e.preventDefault();
22
+ const t = e || window.event;
23
+ this._firefoxDragPosition.x = t.pageX || 0, this._firefoxDragPosition.y = t.pageY || 0;
24
+ };
25
+ constructor(e, t, s) {
26
+ this._instance = e, this._mainDomElement = t, this._options = s || {}, this._firefoxFallback = this._firefoxFallback.bind(this), document.addEventListener("dragover", this._firefoxFallback), this._mainDomElement.parentElement?.addEventListener("dragleave", () => {
27
+ this._instance.cancelDragIn();
28
+ });
29
+ }
30
+ beforeUpdateGhost(e) {
31
+ this._onBeforeUpdateDrag = e;
32
+ }
33
+ async dragStart(e, t, s = "rml_id") {
34
+ const o = this._mainDomElement.parentNode;
35
+ if (C(o).position !== "relative") {
36
+ console.warn(
37
+ "Parent of iframe should have position relative, otherwise drag-in can not detect the x/y coordinates correctly"
38
+ );
39
+ return;
40
+ }
41
+ this._mainDomElement.style.pointerEvents = "none";
42
+ let i = o.querySelector(
43
+ "." + u
44
+ );
45
+ i || (i = document.createElement("div"), i.classList.add(u), o.appendChild(i)), i.classList.remove(x.DISPLAY_NONE), t.target.getAttribute("draggable") || console.warn(
46
+ `Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`
47
+ );
48
+ const a = o.querySelector(
49
+ "." + B
50
+ );
51
+ this._currentDrag.event = t;
52
+ const r = t.target, h = r.cloneNode(!0), g = r.getBoundingClientRect();
53
+ h.style.width = `${g.width}px`, h.style.height = `${g.height}px`, this._currentDrag.ghost = new L(h), this._currentDrag.offset || (this._currentDrag.offset = { x: 0, y: 0 });
54
+ const { clientX: _, clientY: d } = E(
55
+ t,
56
+ this._firefoxDragPosition
57
+ );
58
+ this._currentDrag.offset.x = _ - g.left, this._currentDrag.offset.y = d - g.top, t instanceof DragEvent && t.dataTransfer && t.dataTransfer.setDragImage && t.dataTransfer.setDragImage(a, 0, 0), b(o, this._currentDrag.event || t, this._firefoxDragPosition), this._pendingDragIn = { id: e, type: s }, this._hasEnteredIframe = !1, this.isDragging = !0, this._interactionContainerBb = (await this._instance.getDrawerBoundingClientRect()).final;
59
+ }
60
+ dragUpdate(e) {
61
+ const t = this._mainDomElement.parentNode, { x: s, y: o } = b(t, e, this._firefoxDragPosition);
62
+ if (s === 0 && o === 0)
63
+ return;
64
+ const f = Math.max(1, s), i = Math.max(1, o);
65
+ if (f === 1 && i === 1)
66
+ return;
67
+ const n = this._mainDomElement.getBoundingClientRect(), { clientX: a, clientY: r } = E(
68
+ e,
69
+ this._firefoxDragPosition
70
+ ), h = a >= n.left && a <= n.right && r >= n.top && r <= n.bottom, g = () => {
71
+ if (!(a >= n.left && a <= n.right && r >= n.top && r <= n.bottom))
72
+ return !1;
73
+ if (this._interactionContainerBb) {
74
+ const m = {
75
+ left: this._interactionContainerBb.left + n.left,
76
+ top: this._interactionContainerBb.top + n.top,
77
+ right: this._interactionContainerBb.right + n.left,
78
+ bottom: this._interactionContainerBb.bottom + n.top
79
+ };
80
+ return !(a >= m.left && a <= m.right && r >= m.top && r <= m.bottom);
81
+ }
82
+ return !0;
83
+ };
84
+ if (h && this._pendingDragIn) {
85
+ const l = g();
86
+ l && !this._hasEnteredIframe ? (this._instance.dragInObject(
87
+ this._pendingDragIn.id,
88
+ f,
89
+ i,
90
+ this._pendingDragIn.type
91
+ ), this._hasEnteredIframe = !0) : !l && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
92
+ } else !h && this._hasEnteredIframe && (this._instance.cancelDragIn(), this._hasEnteredIframe = !1);
93
+ let _ = f, d = i;
94
+ if (v(e)) {
95
+ const l = this._options.settings?.fingerSize || 0;
96
+ _ = Math.max(2, f + l), d = Math.max(2, i - l);
97
+ }
98
+ const {
99
+ x: D,
100
+ y: p,
101
+ options: I
102
+ } = this._onBeforeUpdateDrag(_, d, {}), c = I || { settings: {}, ghost: {} };
103
+ if (c.ghost || (c.ghost = {}), c.ghost.visibleIn && c.ghost.hiddenIn || (c.ghost.hiddenIn = n), this._currentDrag.ghost && this._currentDrag.ghost.updateDragGhost(a, r, c), !this._hasEnteredIframe)
104
+ return;
105
+ const y = typeof D == "number" ? D : _, S = typeof p == "number" ? p : d;
106
+ this._instance.updateDrag(y, S, {});
107
+ }
108
+ dragEnd() {
109
+ this._mainDomElement.style.pointerEvents = "all";
110
+ const e = this._mainDomElement.parentNode;
111
+ this.isDragging = !1, this._hasEnteredIframe && this._instance.dragInObjectEnd(), this._currentDrag.ghost && (this._currentDrag.ghost.removeDragGhost(), this._currentDrag.ghost = null), this._currentDrag = {}, this._firefoxDragPosition = { x: 0, y: 0 }, this._hasEnteredIframe = !1, this._pendingDragIn = null, this._interactionContainerBb = null;
112
+ const t = e.querySelector(
113
+ "." + u
114
+ );
115
+ t && t.classList.add(x.DISPLAY_NONE);
116
+ }
117
+ touchStart(e, t, s = "rml_id") {
118
+ t.preventDefault(), this.dragStart(e, t, s);
119
+ }
120
+ touchMove(e) {
121
+ this._currentTouch && this._currentTouch.onMove(e), this._currentDrag.event && this.dragUpdate(e);
122
+ }
123
+ touchEnd() {
124
+ this.dragEnd();
125
+ }
126
+ dispose() {
127
+ document.removeEventListener("dragover", this._firefoxFallback);
128
+ }
129
+ releaseInput(e) {
130
+ }
131
+ }
132
+ export {
133
+ Y as DragInFromWebsiteStrategy
134
+ };
@@ -0,0 +1 @@
1
+ import{g as t,e,a as n,i}from"./utils-BqTPLNLs.mjs";import{R as r,a,b as s}from"./embedding-plugins-DLVs7ER4.mjs";import{E as o}from"./drag-ghost-B7UAYefM.mjs";class h{_options={};_instance;_mainDomElement;_currentDrag={};_firefoxDragPosition={x:0,y:0};_onBeforeUpdateDrag=()=>({});isDragging=!1;_hasEnteredIframe=!1;_pendingDragIn=null;_canvasBb=null;_overlayBb=null;_interactionContainerBb=null;_currentTouch=null;_firefoxFallback=t=>{if(!this._currentDrag.event)return;t.preventDefault();const e=t||window.event;this._firefoxDragPosition.x=e.pageX||0,this._firefoxDragPosition.y=e.pageY||0};constructor(t,e,n){this._instance=t,this._mainDomElement=e,this._options=n||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback),this._mainDomElement.parentElement?.addEventListener("dragleave",()=>{this._instance.cancelDragIn()})}beforeUpdateGhost(t){this._onBeforeUpdateDrag=t}async dragStart(i,h,g="rml_id"){const c=this._mainDomElement.parentNode;if("relative"!==t(c).position)return;this._mainDomElement.style.pointerEvents="none";let _=c.querySelector("."+r);_||(_=document.createElement("div"),_.classList.add(r),c.appendChild(_)),_.classList.remove(a.DISPLAY_NONE),h.target.getAttribute("draggable");const l=c.querySelector("."+s);this._currentDrag.event=h;const d=h.target,f=d.cloneNode(!0),m=d.getBoundingClientRect();f.style.width=`${m.width}px`,f.style.height=`${m.height}px`,this._currentDrag.ghost=new o(f),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:u,clientY:D}=e(h,this._firefoxDragPosition);this._currentDrag.offset.x=u-m.left,this._currentDrag.offset.y=D-m.top,h instanceof DragEvent&&h.dataTransfer&&h.dataTransfer.setDragImage&&h.dataTransfer.setDragImage(l,0,0),n(c,this._currentDrag.event||h,this._firefoxDragPosition),this._pendingDragIn={id:i,type:g},this._hasEnteredIframe=!1,this.isDragging=!0,this._interactionContainerBb=(await this._instance.getDrawerBoundingClientRect()).final}dragUpdate(t){const r=this._mainDomElement.parentNode,{x:a,y:s}=n(r,t,this._firefoxDragPosition);if(0===a&&0===s)return;const o=Math.max(1,a),h=Math.max(1,s);if(1===o&&1===h)return;const g=this._mainDomElement.getBoundingClientRect(),{clientX:c,clientY:_}=e(t,this._firefoxDragPosition),l=c>=g.left&&c<=g.right&&_>=g.top&&_<=g.bottom,d=()=>{if(!(c>=g.left&&c<=g.right&&_>=g.top&&_<=g.bottom))return!1;if(this._interactionContainerBb){const t={left:this._interactionContainerBb.left+g.left,top:this._interactionContainerBb.top+g.top,right:this._interactionContainerBb.right+g.left,bottom:this._interactionContainerBb.bottom+g.top};return!(c>=t.left&&c<=t.right&&_>=t.top&&_<=t.bottom)}return!0};if(l&&this._pendingDragIn){const t=d();t&&!this._hasEnteredIframe?(this._instance.dragInObject(this._pendingDragIn.id,o,h,this._pendingDragIn.type),this._hasEnteredIframe=!0):!t&&this._hasEnteredIframe&&(this._instance.cancelDragIn(),this._hasEnteredIframe=!1)}else!l&&this._hasEnteredIframe&&(this._instance.cancelDragIn(),this._hasEnteredIframe=!1);let f=o,m=h;if(i(t)){const t=this._options.settings?.fingerSize||0;f=Math.max(2,o+t),m=Math.max(2,h-t)}const{x:u,y:D,options:p}=this._onBeforeUpdateDrag(f,m,{}),E=p||{settings:{},ghost:{}};if(E.ghost||(E.ghost={}),E.ghost.visibleIn&&E.ghost.hiddenIn||(E.ghost.hiddenIn=g),this._currentDrag.ghost&&this._currentDrag.ghost.updateDragGhost(c,_,E),!this._hasEnteredIframe)return;const b="number"==typeof u?u:f,I="number"==typeof D?D:m;this._instance.updateDrag(b,I,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const t=this._mainDomElement.parentNode;this.isDragging=!1,this._hasEnteredIframe&&this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0},this._hasEnteredIframe=!1,this._pendingDragIn=null,this._interactionContainerBb=null;const e=t.querySelector("."+r);e&&e.classList.add(a.DISPLAY_NONE)}touchStart(t,e,n="rml_id"){e.preventDefault(),this.dragStart(t,e,n)}touchMove(t){this._currentTouch&&this._currentTouch.onMove(t),this._currentDrag.event&&this.dragUpdate(t)}touchEnd(){this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(t){}}export{h as DragInFromWebsiteStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roomle/embedding-lib",
3
- "version": "6.5.0-alpha.2",
3
+ "version": "6.5.0",
4
4
  "description": "This is a small library which can be used to communicate with the Roomle Configurator. ES modules only (browser-compatible).",
5
5
  "type": "module",
6
6
  "main": "./roomle-embedding-lib.js",
@@ -1,5 +1,5 @@
1
1
  import { DragInOptions } from './plugins/types';
2
- export { RML_DRAG_IN_STYLES_ID, RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, RML_DRAG_IN_DRAG_ELEMENT_ID, RML_DRAG_IN_FALLBACK_GHOST_URL, RML_DRAG_IN_FALLBACK_GHOST_WIDTH, RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, RML_DRAG_GHOST_FADE_IN, RML_DRAG_GHOST_FADE_OUT, } from './plugins/constants';
2
+ export { TARGET_OPACITY, RML_DRAG_IN_STYLES_ID, RML_DRAG_GHOST_FADE_IN_ANIMATION_CSS, RML_DRAG_GHOST_FADE_OUT_ANIMATION_CSS, RML_DRAG_IN_DRAG_ELEMENT_ID, RML_DRAG_IN_FALLBACK_GHOST_URL, RML_DRAG_IN_FALLBACK_GHOST_WIDTH, RML_DRAG_IN_FALLBACK_GHOST_HEIGHT, RML_DRAG_GHOST_FADE_IN, RML_DRAG_GHOST_FADE_OUT, } from './plugins/constants';
3
3
  export type { DragGhostOptions, DragInOptions } from './plugins/types';
4
4
  export type OnBeforeUpdateDragGhost = (x: number, y: number, options: DragInOptions) => {
5
5
  x?: number;
@@ -12,12 +12,14 @@ export declare class DragInFromCustomViewStrategy implements DragInStrategy {
12
12
  private _currentCustomDrag;
13
13
  private _currentBb;
14
14
  private _startTarget;
15
+ private _dragGhost;
15
16
  private _onBeforeUpdateDrag;
16
17
  isDragging: boolean;
17
18
  private _hasEnteredIframe;
18
19
  private _pendingDragIn;
19
20
  private _canvasBb;
20
21
  private _overlayBb;
22
+ private _dragGeneration;
21
23
  private _interactionContainerBb;
22
24
  constructor(instance: ExposedApi, mainDomElement: HTMLIFrameElement, options: DragInSettings, viewName: PossibleCustomViewsAndMain);
23
25
  beforeUpdateGhost(handler: OnBeforeUpdateDragGhost): void;
@@ -8,7 +8,6 @@ export declare class DragInFromWebsiteStrategy implements DragInStrategy {
8
8
  private _instance;
9
9
  private _mainDomElement;
10
10
  private _currentDrag;
11
- private _currentTouch;
12
11
  private _firefoxDragPosition;
13
12
  private _onBeforeUpdateDrag;
14
13
  isDragging: boolean;
@@ -17,6 +16,7 @@ export declare class DragInFromWebsiteStrategy implements DragInStrategy {
17
16
  private _canvasBb;
18
17
  private _overlayBb;
19
18
  private _interactionContainerBb;
19
+ private _currentTouch;
20
20
  private _firefoxFallback;
21
21
  constructor(instance: ExposedApi, mainDomElement: HTMLIFrameElement, options: DragInOptions);
22
22
  beforeUpdateGhost(handler: OnBeforeUpdateDragGhost): void;
@@ -192,7 +192,7 @@ const G = (s) => JSON.parse(JSON.stringify(s)), J = {
192
192
  const s = G(J);
193
193
  s.locale || (s.locale = P(null, !0)), s.id === V && delete s.id;
194
194
  const e = U();
195
- return e && k(e) && (s.configuratorId = "demoConfigurator"), s.customApiUrl = "https://rubens.alpha.roomle.com/api/v2", s.emails = !1, s;
195
+ return e && k(e) && (s.configuratorId = "demoConfigurator"), s.customApiUrl = void 0, s.emails = !1, s;
196
196
  }, Y = "<CONF_ID>", q = "#CONFIGURATIONID#", Q = (s) => {
197
197
  s.featureFlags || (s.featureFlags = {}), typeof s.featureFlags.realPartList != "boolean" && (s.featureFlags.realPartList = !0), typeof s.featureFlags.globalCallbacks != "boolean" && (s.featureFlags.globalCallbacks = !0), typeof s.featureFlags.mocAr != "boolean" && (s.featureFlags.mocAr = !1);
198
198
  }, M = () => /(android)/i.test(navigator.userAgent);
@@ -255,7 +255,7 @@ class T {
255
255
  typeof o == "string" && o === "dragIn" ? this.pluginsLoaded.push(
256
256
  new Promise((i, a) => {
257
257
  try {
258
- import("./embedding-plugins-Cm7O1pKC.mjs").then((n) => n.l).then(({ DragIn: n }) => {
258
+ import("./embedding-plugins-DqMSzAJe.mjs").then((n) => n.l).then(({ DragIn: n }) => {
259
259
  const l = new n(this.ui, t, r, this.viewName);
260
260
  l.init().then(() => {
261
261
  this.plugins.dragIn = l, i();
@@ -1 +1 @@
1
- import{expose as e}from"./comlink-CmT64Qi3.mjs";import{g as t}from"./browser-BhHw2H1M.mjs";import{c as s}from"./utils-BqTPLNLs.mjs";class r{_side;_incomingMessageBus=null;_outgoingMessageBus=null;_execMessage=null;constructor(e,t,s,r){this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=e=>{if(!e||!e.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let t;try{t=JSON.parse(e.data)}catch(e){return i.port1.close(),i.port2.close(),this._prepareError(e),r(e)}t.error?r(t.error):void 0!==t.result?s(t.result):s(void 0),i.port1.close(),i.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,"*",[i.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&("string"==typeof e.data||"connect_hi"!==e.data.type)&&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(void 0===r)return;r.then((e={})=>{let s,r;"object"==typeof e&&null!==e&&(s=e.error,r=e.result),s?t.postMessage(JSON.stringify({error:s})):void 0!==r?t.postMessage(JSON.stringify({result:r})):t.postMessage(JSON.stringify({result:e}))},e=>{t.postMessage(JSON.stringify({error:this._prepareError(e)}))})}catch(e){t.postMessage(JSON.stringify({error:this._prepareError(e)}))}}_prepareError(e){return"string"==typeof e?this._side+": "+e:(e.message=this._side+": "+e.message,e.message)}}const i=["127.0.0.1","localhost","0.0.0.0"],a=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=a(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var n=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(n||{});const o={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[n.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!0,enableTwoLevelCatalog:!1,webGpu:!1,localExport3d:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},l=e=>{if(!e)return;const t=Object.keys(e);for(const s of t){const t=e[s];if(!Array.isArray(t)&&"object"==typeof t&&null!==t&&l(t),Array.isArray(t))for(const e of t)l(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},c=()=>/(android)/i.test(navigator.userAgent);class u{_messageHandler=null;isSetupDone=!1;viewName="main";plugins={};pluginsLoaded=[];ui={callbacks:null};extended={callbacks:null};configurator={callbacks:null};analytics={callbacks:{}};rapi={callbacks:{}};global={callbacks:{}};setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(e=>{const t=e.split(h),s=t[0],r=t[1];this[s]||(this[s]={}),this[s][r]=function(){if(this._messageHandler)return this._messageHandler.sendMessage(e,[...arguments])}.bind(this)}),s.forEach(e=>{const t=e.split(h),s=t[0],r=t[1],i=t[2];this[s]||(this[s]={}),this[s][r]||(this[s][r]={}),this[s][r][i]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(h),r=s[0],i=s[1],a=3===s.length?s[2]:null;if(a&&this[r][i][a]){const e=this[r][i][a](...t);return e instanceof Promise?e.then(e=>({result:e})):void 0!==e?Promise.resolve({result:e}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)"string"==typeof r&&"dragIn"===r?this.pluginsLoaded.push(new Promise((e,r)=>{try{import("./embedding-plugins-Dzhuj1By.mjs").then(e=>e.l).then(({DragIn:i})=>{const a=new i(this.ui,t,s,this.viewName);a.init().then(()=>{this.plugins.dragIn=a,e()},r)})}catch(e){r(e)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((e,i)=>{try{r.loader().then(a=>{const n=new a(this.ui,t,s,this.viewName);n.init().then(()=>{this.plugins[r.name]=n,e()},i)})}catch(e){i(e)}}))}}const d=()=>{let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}},g={SDK:"extended",CONFIGURATOR_SDK:"configurator",CALLBACKS:"callbacks",UI:"ui",ANALYTICS:"analytics",GLOBAL:"global",RAPI:"rapi"},h=".",m=g.SDK+h+g.CALLBACKS,p={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},f=["constructor","callbacks"],w=e=>"_"!==e[0]&&!f.includes(e),E=(e,t,s=!1)=>{if(!e)return[];const r=Object.getOwnPropertyNames(e),i=s?g.CALLBACKS+h:"";return r.filter(w).map(e=>t+h+i+e)},S=async(e,t)=>{if("string"!=typeof e)throw new Error('Configurator ID is not a string type: "'+typeof e+'"');const s=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",r=t.overrideTenant||9,i=s+"/configurators/"+e,a="roomle_portal_v2",n="03-"+window.btoa((new Date).toISOString()+";anonymous;"+a),o=new Request(i,{method:"GET",headers:new Headers({apiKey:a,currentTenant:r,locale:"en",language:"en",device:1,token:n,platform:"web"}),mode:"cors",cache:"default"}),l=await fetch(o),{configurator:c}=await l.json();return c},M="data-rml-interaction-container",b=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=e?.mute?e.value:e}})},y=()=>.01*window.innerHeight+"px",T=e=>{e&&setTimeout(()=>e.style.setProperty(v,y()),0)},O="rml-styles",v="--rml-full-height",A="rml-container",N="rml-fill",R="rml-pos",I="rml-android-height",L="rml-overflow-hidden",C=new Map;class P extends u{static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(e,t=[]){const s=new u;s.viewName=e;const{resolve:i,promise:a}=d(),{resolve:n,promise:o}=d(),l=new r("custom-view-"+e,window,window.parent,({message:e,args:t})=>{switch(e){case _.REGISTER_CUSTOM_VIEW_DONE:i();break;case _.RETURN_METHODS:s.handleSetup(t[0]),n();break;default:if(s.isSetupDone)return s.executeMessage({message:e,args:t})}});s.setMessageHandler(l);const c=[e];return l.sendMessage(_.REGISTER_CUSTOM_VIEW,c),await a,l.sendMessage(_.GET_METHODS,c),await o,s.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}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 hiMessageHandler=null;static setupHi(t){this.hiMessageHandler&&window.removeEventListener("message",this.hiMessageHandler),this.hiMessageHandler=r=>{if("connect_hi"===r.data.type&&r.data.port){const i=r.data.port;i.start?.(),e(s(t),i)}},window.addEventListener("message",this.hiMessageHandler)}static async _create(e,s,r,n){return new Promise(async(c,u)=>{try{const u=a((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(o);e.locale||(e.locale=t(null,!0)),"(idle)"===e.id&&delete e.id;const s=(()=>{const e=(()=>{try{return window.self!==window.top}catch{return!0}})();let t=window.location.href;if(e){if(!document.referrer)return null;t=document.referrer}const{hostname:s}=new URL(t);return s})();return s&&(e=>{const t=new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);return!!(i.includes(e)||t.test(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com"))})(s)&&(e.configuratorId="demoConfigurator"),e.customApiUrl="https://rubens.alpha.roomle.com/api/v2",e.emails=!1,e})(),(l(d=r),d?.customApiUrl&&(d.customApiUrl=decodeURIComponent(d.customApiUrl)),d.shareUrl&&(d.deeplink=d.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),d));(e=>{e.featureFlags||(e.featureFlags={}),"boolean"!=typeof e.featureFlags.realPartList&&(e.featureFlags.realPartList=!0),"boolean"!=typeof e.featureFlags.globalCallbacks&&(e.featureFlags.globalCallbacks=!0),"boolean"!=typeof e.featureFlags.mocAr&&(e.featureFlags.mocAr=!1)})(u);const g=await S(e,u);r=((e,t)=>{t.configuratorId=e.id;const s=e.settings||{};return!t.overrideTenant&&e.tenant&&(t.overrideTenant=e.tenant),((e,t)=>{const s=JSON.parse(JSON.stringify(e));return a(s,t)})(s,t)})(g,u);const h=new this(g,s,r,n,c);return await Promise.allSettled(h.pluginsLoaded),h}catch(e){return u(e)}var d})}_waitForIframe;_container;_configuratorSettings;_initData={};_iframe;constructor(e,t,s,i,a){if(super(),!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(C.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(O)){const e=s.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=O;const r="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((e,t)=>e+(t+r),"")+r,a=y();t.innerHTML=`\n .${A}{${v}:${a};}\n .${R}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${i}}\n .${N}{width:100%;height:100%;opacity:1}\n .${I}{height:calc(var(${v},1vh)*100)}\n .${L}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const n=new r("website",window,null,this._executeMessage);this.setMessageHandler(n),this._onResize=this._onResize.bind(this),c()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=a,this._container.appendChild(o),this._iframe=o,this.setupPlugins(i,this._iframe),C.set(t,!0)}teardown(){this._container&&C.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){const e=document.createElement("iframe");let t=this._configuratorSettings?.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(A),e.classList.add(N),e}_onResize(){T(this._iframe)}_onUseFullPage(){this._iframe.classList.add(R),document.documentElement.classList.add(L),window.document.body.classList.add(L),c()&&(T(this._iframe),this._iframe.classList.add(I))}_onBackToWebsite(){this._iframe.classList.remove(R),this._iframe.classList.remove(I),document.documentElement.classList.remove(L),window.document.body.classList.remove(L)}_executeMessage({message:e,args:t},s){if(s.source&&s.source===this._iframe?.contentWindow)return e===p.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):Promise.resolve({error:"MessageHandler not set"}):e===p.SETUP?(this.handleSetup(t[0]),b(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),b(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{this._messageHandler&&this._messageHandler.sendMessage(p.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{p as HANDSHAKE_MESSAGES,M as INTERACTION_CONTAINER_SELECTOR,g as NAMESPACE,h as NAMESPACE_SEPARATOR,m as SDK_CALLBACK,_ as WELL_KNOWN_MESSAGES,P as default,S as getConfiguratorSettings,E as getMethodNames,w as isExposable};
1
+ import{expose as e}from"./comlink-CmT64Qi3.mjs";import{g as t}from"./browser-BhHw2H1M.mjs";import{c as s}from"./utils-BqTPLNLs.mjs";class r{_side;_incomingMessageBus=null;_outgoingMessageBus=null;_execMessage=null;constructor(e,t,s,r){this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=e=>{if(!e||!e.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let t;try{t=JSON.parse(e.data)}catch(e){return i.port1.close(),i.port2.close(),this._prepareError(e),r(e)}t.error?r(t.error):void 0!==t.result?s(t.result):s(void 0),i.port1.close(),i.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,"*",[i.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&("string"==typeof e.data||"connect_hi"!==e.data.type)&&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(void 0===r)return;r.then((e={})=>{let s,r;"object"==typeof e&&null!==e&&(s=e.error,r=e.result),s?t.postMessage(JSON.stringify({error:s})):void 0!==r?t.postMessage(JSON.stringify({result:r})):t.postMessage(JSON.stringify({result:e}))},e=>{t.postMessage(JSON.stringify({error:this._prepareError(e)}))})}catch(e){t.postMessage(JSON.stringify({error:this._prepareError(e)}))}}_prepareError(e){return"string"==typeof e?this._side+": "+e:(e.message=this._side+": "+e.message,e.message)}}const i=["127.0.0.1","localhost","0.0.0.0"],a=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=a(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var n=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(n||{});const o={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[n.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!0,enableTwoLevelCatalog:!1,webGpu:!1,localExport3d:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},l=e=>{if(!e)return;const t=Object.keys(e);for(const s of t){const t=e[s];if(!Array.isArray(t)&&"object"==typeof t&&null!==t&&l(t),Array.isArray(t))for(const e of t)l(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},c=()=>/(android)/i.test(navigator.userAgent);class u{_messageHandler=null;isSetupDone=!1;viewName="main";plugins={};pluginsLoaded=[];ui={callbacks:null};extended={callbacks:null};configurator={callbacks:null};analytics={callbacks:{}};rapi={callbacks:{}};global={callbacks:{}};setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(e=>{const t=e.split(h),s=t[0],r=t[1];this[s]||(this[s]={}),this[s][r]=function(){if(this._messageHandler)return this._messageHandler.sendMessage(e,[...arguments])}.bind(this)}),s.forEach(e=>{const t=e.split(h),s=t[0],r=t[1],i=t[2];this[s]||(this[s]={}),this[s][r]||(this[s][r]={}),this[s][r][i]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(h),r=s[0],i=s[1],a=3===s.length?s[2]:null;if(a&&this[r][i][a]){const e=this[r][i][a](...t);return e instanceof Promise?e.then(e=>({result:e})):void 0!==e?Promise.resolve({result:e}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const r of e)"string"==typeof r&&"dragIn"===r?this.pluginsLoaded.push(new Promise((e,r)=>{try{import("./embedding-plugins-DLVs7ER4.mjs").then(e=>e.l).then(({DragIn:i})=>{const a=new i(this.ui,t,s,this.viewName);a.init().then(()=>{this.plugins.dragIn=a,e()},r)})}catch(e){r(e)}})):r.name&&r.loader&&this.pluginsLoaded.push(new Promise((e,i)=>{try{r.loader().then(a=>{const n=new a(this.ui,t,s,this.viewName);n.init().then(()=>{this.plugins[r.name]=n,e()},i)})}catch(e){i(e)}}))}}const d=()=>{let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}},g={SDK:"extended",CONFIGURATOR_SDK:"configurator",CALLBACKS:"callbacks",UI:"ui",ANALYTICS:"analytics",GLOBAL:"global",RAPI:"rapi"},h=".",m=g.SDK+h+g.CALLBACKS,p={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},_={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},f=["constructor","callbacks"],w=e=>"_"!==e[0]&&!f.includes(e),E=(e,t,s=!1)=>{if(!e)return[];const r=Object.getOwnPropertyNames(e),i=s?g.CALLBACKS+h:"";return r.filter(w).map(e=>t+h+i+e)},S=async(e,t)=>{if("string"!=typeof e)throw new Error('Configurator ID is not a string type: "'+typeof e+'"');const s=t.customApiUrl?t.customApiUrl:"https://api.roomle.com/v2",r=t.overrideTenant||9,i=s+"/configurators/"+e,a="roomle_portal_v2",n="03-"+window.btoa((new Date).toISOString()+";anonymous;"+a),o=new Request(i,{method:"GET",headers:new Headers({apiKey:a,currentTenant:r,locale:"en",language:"en",device:1,token:n,platform:"web"}),mode:"cors",cache:"default"}),l=await fetch(o),{configurator:c}=await l.json();return c},M="data-rml-interaction-container",b=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=e?.mute?e.value:e}})},y=()=>.01*window.innerHeight+"px",T=e=>{e&&setTimeout(()=>e.style.setProperty(v,y()),0)},O="rml-styles",v="--rml-full-height",A="rml-container",N="rml-fill",R="rml-pos",I="rml-android-height",L="rml-overflow-hidden",C=new Map;class P extends u{static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(e,t=[]){const s=new u;s.viewName=e;const{resolve:i,promise:a}=d(),{resolve:n,promise:o}=d(),l=new r("custom-view-"+e,window,window.parent,({message:e,args:t})=>{switch(e){case _.REGISTER_CUSTOM_VIEW_DONE:i();break;case _.RETURN_METHODS:s.handleSetup(t[0]),n();break;default:if(s.isSetupDone)return s.executeMessage({message:e,args:t})}});s.setMessageHandler(l);const c=[e];return l.sendMessage(_.REGISTER_CUSTOM_VIEW,c),await a,l.sendMessage(_.GET_METHODS,c),await o,s.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(s.pluginsLoaded),s}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 hiMessageHandler=null;static setupHi(t){this.hiMessageHandler&&window.removeEventListener("message",this.hiMessageHandler),this.hiMessageHandler=r=>{if("connect_hi"===r.data.type&&r.data.port){const i=r.data.port;i.start?.(),e(s(t),i)}},window.addEventListener("message",this.hiMessageHandler)}static async _create(e,s,r,n){return new Promise(async(c,u)=>{try{const u=a((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(o);e.locale||(e.locale=t(null,!0)),"(idle)"===e.id&&delete e.id;const s=(()=>{const e=(()=>{try{return window.self!==window.top}catch{return!0}})();let t=window.location.href;if(e){if(!document.referrer)return null;t=document.referrer}const{hostname:s}=new URL(t);return s})();return s&&(e=>{const t=new RegExp(/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/);return!!(i.includes(e)||t.test(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com"))})(s)&&(e.configuratorId="demoConfigurator"),e.customApiUrl=void 0,e.emails=!1,e})(),(l(d=r),d?.customApiUrl&&(d.customApiUrl=decodeURIComponent(d.customApiUrl)),d.shareUrl&&(d.deeplink=d.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),d));(e=>{e.featureFlags||(e.featureFlags={}),"boolean"!=typeof e.featureFlags.realPartList&&(e.featureFlags.realPartList=!0),"boolean"!=typeof e.featureFlags.globalCallbacks&&(e.featureFlags.globalCallbacks=!0),"boolean"!=typeof e.featureFlags.mocAr&&(e.featureFlags.mocAr=!1)})(u);const g=await S(e,u);r=((e,t)=>{t.configuratorId=e.id;const s=e.settings||{};return!t.overrideTenant&&e.tenant&&(t.overrideTenant=e.tenant),((e,t)=>{const s=JSON.parse(JSON.stringify(e));return a(s,t)})(s,t)})(g,u);const h=new this(g,s,r,n,c);return await Promise.allSettled(h.pluginsLoaded),h}catch(e){return u(e)}var d})}_waitForIframe;_container;_configuratorSettings;_initData={};_iframe;constructor(e,t,s,i,a){if(super(),!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(C.has(t))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(O)){const e=s.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=O;const r="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((e,t)=>e+(t+r),"")+r,a=y();t.innerHTML=`\n .${A}{${v}:${a};}\n .${R}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${i}}\n .${N}{width:100%;height:100%;opacity:1}\n .${I}{height:calc(var(${v},1vh)*100)}\n .${L}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const n=new r("website",window,null,this._executeMessage);this.setMessageHandler(n),this._onResize=this._onResize.bind(this),c()&&window.addEventListener("resize",this._onResize),this._container=t,this._initData=s,this._configuratorSettings=e;const o=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=a,this._container.appendChild(o),this._iframe=o,this.setupPlugins(i,this._iframe),C.set(t,!0)}teardown(){this._container&&C.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){const e=document.createElement("iframe");let t=this._configuratorSettings?.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(A),e.classList.add(N),e}_onResize(){T(this._iframe)}_onUseFullPage(){this._iframe.classList.add(R),document.documentElement.classList.add(L),window.document.body.classList.add(L),c()&&(T(this._iframe),this._iframe.classList.add(I))}_onBackToWebsite(){this._iframe.classList.remove(R),this._iframe.classList.remove(I),document.documentElement.classList.remove(L),window.document.body.classList.remove(L)}_executeMessage({message:e,args:t},s){if(s.source&&s.source===this._iframe?.contentWindow)return e===p.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):Promise.resolve({error:"MessageHandler not set"}):e===p.SETUP?(this.handleSetup(t[0]),b(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),b(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{this._messageHandler&&this._messageHandler.sendMessage(p.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{p as HANDSHAKE_MESSAGES,M as INTERACTION_CONTAINER_SELECTOR,g as NAMESPACE,h as NAMESPACE_SEPARATOR,m as SDK_CALLBACK,_ as WELL_KNOWN_MESSAGES,P as default,S as getConfiguratorSettings,E as getMethodNames,w as isExposable};
@@ -1 +0,0 @@
1
- const t="rml-drag-in-styles",e="rml-drag-in-drag-element",s="rml-drag-in-overlay",a="rml-drag-in-drag-ghost",r="rml-drag-in-fade-in",i="rml-drag-in-fade-out",n={DISPLAY_NONE:"rml-display-none"},o="250ms",d="forwards",m=`@keyframes ${r} {from{opacity: 0;}to {opacity: 0.5;}}`,g=`@keyframes ${i} {from{opacity: 0.5;}to {opacity: 0;}}`,l=`${r} ${o} ${d}`,c=`${i} ${o} ${d}`,h="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",u=112,p=112;class _{_mainDomElement;_instance;_mode="website";_viewName="main";constructor(t,e,s,a){this._instance=t,this._mainDomElement=e,this._mode=s,this._viewName=a}async init(){return Promise.resolve()}}class y extends _{options={};_customDragSignal=new AbortController;_injectStyles(){if(!document.getElementById(t)){const e=document.createElement("style");e.type="text/css",e.id=t,e.innerHTML=`\n .${n.DISPLAY_NONE}{display:none}\n .${s}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}\n .${a}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}\n ${m}\n ${g}\n `,document.head.appendChild(e)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let e=t.querySelector("."+a);e||(e=document.createElement("div"),e.classList.add(a),e.innerText=" ",t.appendChild(e))}constructor(t,e,s,a){super(t,e,s,a),this._mainDomElement=e,this._injectStyles(),this._initializeDragGhost()}async init(){if(await super.init(),"website"===this._mode)try{const{DragInFromWebsiteStrategy:t}=await import("./from-website-ExTzmsnv.mjs");this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw t}else{if("custom-view"!==this._mode)throw new Error("Unsupported mode");try{const{DragInFromCustomViewStrategy:t}=await import("./from-custom-view-CfMGS1-t.mjs");this._strategy=new t(this._instance,this._mainDomElement,this.options,this._viewName)}catch(t){throw t}}}get isDragging(){return this._strategy.isDragging}dragStart(t,e,s="rml_id"){this._strategy.dragStart(t,e,s)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,e,s="rml_id"){this._strategy.touchStart(t,e,s)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:e,customDragUpdate:s,beforeUpdateGhost:a}){a&&this._strategy.beforeUpdateGhost(a);const r=this._customDragSignal.signal,i=e=>{"true"===e.target.getAttribute("data-rml-draggable")&&t(e)},n=t=>{this._strategy.releaseInput(t),this._strategy.isDragging&&e(t)},o=t=>{s(t)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(t=>{t.draggable=!1}),document.addEventListener("mousedown",i,{signal:r}),document.addEventListener("mouseup",n,{signal:r}),document.addEventListener("mousemove",o,{signal:r}),document.addEventListener("mouseleave",n,{signal:r}),document.addEventListener("touchstart",i,{signal:r}),document.addEventListener("touchend",n,{signal:r}),document.addEventListener("touchmove",o,{signal:r})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const D=Object.freeze(Object.defineProperty({__proto__:null,DragIn:y},Symbol.toStringTag,{value:"Module"}));export{y as D,e as R,t as a,m as b,g as c,h as d,u as e,p as f,l as g,c as h,s as i,n as j,a as k,D as l};