@roomle/embedding-lib 5.17.0-alpha.1 → 5.17.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/md/web/embedding/CHANGELOG.md +18 -13
- package/package.json +2 -2
- package/packages/common/src/utils/init-data.d.ts +1 -29
- package/packages/common/src/utils/json.d.ts +1 -0
- package/packages/embedding-lib/src/connector.d.ts +5 -1
- package/packages/embedding-lib/src/examples/activate-deactivate-rd.d.ts +8 -0
- package/roomle-embedding-lib.es.js +30 -28
- package/roomle-embedding-lib.es.min.js +1 -1
- package/roomle-embedding-lib.umd.js +4 -4
- package/roomle-embedding-lib.umd.min.js +1 -1
- package/src/common/components/inputs/BaseInput.vue.d.ts +74 -2
- package/src/common/components/inputs/GenericInput.vue.d.ts +33 -0
- package/src/common/components/inputs/SelectDropdown.vue.d.ts +2 -0
- package/src/common/components/utils/QRCode.vue.d.ts +2 -2
- package/src/common/composables/use-wall-dimensions-cache.d.ts +8 -0
- package/src/common/store/common-ui-state.d.ts +1 -1
- package/src/common/utils/helper.d.ts +1 -1
- package/src/common/utils/types.d.ts +1 -0
- package/src/configurator/embedding/exposed-api.d.ts +6 -1
- package/src/configurator/embedding/exposed-callbacks.d.ts +2 -2
- package/src/configurator/embedding/types.d.ts +5 -5
- package/src/planner/business-logic/sdk-connector-planner.d.ts +3 -3
- package/src/planner/components/overlays/rooms/RoomFloorAndWallSettings.vue.d.ts +17 -0
- package/src/planner/store/planner-ui-state.d.ts +4 -0
- package/src/viewer/components/ViewerMain.vue.d.ts +1 -0
- package/src/planner/components/overlays/rooms/FloorColor.vue.d.ts +0 -3853
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
## [5.17.0-alpha.
|
|
1
|
+
## [5.17.0-alpha.10](https://github.com/roomle-dev/roomle-ui/compare/embedding-lib-v5.17.0-alpha.9...embedding-lib-v5.17.0-alpha.10) (2025-05-13)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
* **
|
|
7
|
-
* **SDK:** upgrade to version 2.
|
|
8
|
-
* **SDK:** upgrade to version 2.
|
|
9
|
-
* **SDK:** upgrade to version 2.
|
|
10
|
-
* **SDK:** upgrade to version 2.
|
|
11
|
-
* **SDK:** upgrade to version 2.
|
|
12
|
-
* **SDK:** upgrade to version 2.99.0-alpha.5 ([#1639](https://github.com/roomle-dev/roomle-ui/issues/1639)) ([d886afd](https://github.com/roomle-dev/roomle-ui/commit/d886afde345283a9fa421e8340b4c85d76aae2cb))
|
|
13
|
-
* **SDK:** upgrade to version 2.99.0-alpha.6 ([#1644](https://github.com/roomle-dev/roomle-ui/issues/1644)) ([66dece8](https://github.com/roomle-dev/roomle-ui/commit/66dece8fc68ccc45e0d88a737dd8b243db06c652))
|
|
6
|
+
* **SDK:** upgrade to version 2.101.0-alpha.10 ([#1686](https://github.com/roomle-dev/roomle-ui/issues/1686)) ([0413422](https://github.com/roomle-dev/roomle-ui/commit/041342250743414792188ae9d0364a5f2ea2f0df))
|
|
7
|
+
* **SDK:** upgrade to version 2.101.0-alpha.11 ([#1687](https://github.com/roomle-dev/roomle-ui/issues/1687)) ([9c5fbae](https://github.com/roomle-dev/roomle-ui/commit/9c5fbae066f908663cbe757cd85868553cbc3b2d))
|
|
8
|
+
* **SDK:** upgrade to version 2.101.0-alpha.6 ([#1682](https://github.com/roomle-dev/roomle-ui/issues/1682)) ([24ef79e](https://github.com/roomle-dev/roomle-ui/commit/24ef79ea6372b7ebde44d965a229273991068451))
|
|
9
|
+
* **SDK:** upgrade to version 2.101.0-alpha.7 ([#1683](https://github.com/roomle-dev/roomle-ui/issues/1683)) ([1afef1a](https://github.com/roomle-dev/roomle-ui/commit/1afef1a2621ae6c49da0ca4c64500df3cfc693b3))
|
|
10
|
+
* **SDK:** upgrade to version 2.101.0-alpha.8 ([#1684](https://github.com/roomle-dev/roomle-ui/issues/1684)) ([8cbfb3e](https://github.com/roomle-dev/roomle-ui/commit/8cbfb3e63213c5b042929bda10eac6ef14c7d2da))
|
|
11
|
+
* **SDK:** upgrade to version 2.101.0-alpha.9 ([#1685](https://github.com/roomle-dev/roomle-ui/issues/1685)) ([44e3efa](https://github.com/roomle-dev/roomle-ui/commit/44e3efafd3faa286c177f1df43327c391b2ad58b))
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
### Bug Fixes
|
|
17
15
|
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
16
|
+
* **UX feedback:** add some UX improvements to Room labels ([b83b6be](https://github.com/roomle-dev/roomle-ui/commit/b83b6be1f186c09514cbe6124e5a2eb3eb00c4aa))
|
|
17
|
+
* add test case ([85198f0](https://github.com/roomle-dev/roomle-ui/commit/85198f037e1bed54dedb17494da4ea5aad8d86c7))
|
|
18
|
+
* call movecamera twice to make sure the top view angle is correct ([1b57961](https://github.com/roomle-dev/roomle-ui/commit/1b57961f3d942e9e663d1a4e9852875e7af14603))
|
|
19
|
+
* **planner:** check if we are in planner edit mode ([871c00c](https://github.com/roomle-dev/roomle-ui/commit/871c00c76fe1e1df257c1d646355e2a3bd52ddc2))
|
|
20
|
+
* choose the most common wall height as the base, or just return the largest wall height as the initial value ([428dc13](https://github.com/roomle-dev/roomle-ui/commit/428dc13873cfe5f33b6cd0f152216ec30ebd1dd6))
|
|
21
|
+
* desktop hanging div, use consistent class names ([0c1fe26](https://github.com/roomle-dev/roomle-ui/commit/0c1fe260ee084ab91c4e5634a253e1de2e78e1ce))
|
|
22
|
+
* dont pause input during wall drawing ([c50c208](https://github.com/roomle-dev/roomle-ui/commit/c50c2083a548b54dfdcf837b559472e5bfddd1ac))
|
|
23
|
+
* merge master ([3c850e9](https://github.com/roomle-dev/roomle-ui/commit/3c850e90b1df5cafe35b7fcd8731fb10cebd73ce))
|
|
24
|
+
* merge master ([b2f7b9c](https://github.com/roomle-dev/roomle-ui/commit/b2f7b9c97cbd418392f3b258a1806ae0d5c56309))
|
|
25
|
+
* Parameter Group Navigation issues closes #RML-14170 #RML-14171 ([66f62d6](https://github.com/roomle-dev/roomle-ui/commit/66f62d62be3c93a9d148c39187a79dddb66d6b32)), closes [#RML-14170](https://github.com/roomle-dev/roomle-ui/issues/RML-14170) [#RML-14171](https://github.com/roomle-dev/roomle-ui/issues/RML-14171)
|
|
26
|
+
* thumbnails=big is not used in "parameters visible in planner" ([66ec51b](https://github.com/roomle-dev/roomle-ui/commit/66ec51b7d24e8416879bdc4bc464eacdbfe19714))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roomle/embedding-lib",
|
|
3
|
-
"version": "5.17.0-alpha.
|
|
3
|
+
"version": "5.17.0-alpha.10",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"npm": "8.3.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@roomle/web-sdk": "2.
|
|
32
|
+
"@roomle/web-sdk": "2.101.0-alpha.11"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -5,35 +5,7 @@ import { Nullable } from '../../../../src/common/utils/types';
|
|
|
5
5
|
import { RoomleSdkWrapper } from '../../../../src/configurator/business-logic/roomle-sdk-wrapper';
|
|
6
6
|
|
|
7
7
|
export declare const cleanUpInitData: (key: keyof UiInitData, initData: UiInitData) => void;
|
|
8
|
-
export declare const FALLBACK_INIT_DATA:
|
|
9
|
-
mobileLandscape: boolean;
|
|
10
|
-
floorMaterialRootTag: string;
|
|
11
|
-
buttons: {
|
|
12
|
-
renderimage: boolean;
|
|
13
|
-
requestproduct: boolean;
|
|
14
|
-
requestplan: boolean;
|
|
15
|
-
load_product: boolean;
|
|
16
|
-
partlist_print: boolean;
|
|
17
|
-
};
|
|
18
|
-
elements: {
|
|
19
|
-
interaction_notes: boolean;
|
|
20
|
-
};
|
|
21
|
-
helpcenter: {
|
|
22
|
-
roomdesigner: boolean;
|
|
23
|
-
configurator: boolean;
|
|
24
|
-
disable: boolean;
|
|
25
|
-
};
|
|
26
|
-
firstPersonView: boolean;
|
|
27
|
-
saveToIdb: boolean;
|
|
28
|
-
featureFlags: {
|
|
29
|
-
mocAr: boolean;
|
|
30
|
-
wallAutoHeight: boolean;
|
|
31
|
-
openCloseAnimation: boolean;
|
|
32
|
-
showWallVisibilityToggle: boolean;
|
|
33
|
-
};
|
|
34
|
-
rotationSnapDegrees: number;
|
|
35
|
-
interactionsCollapsed: boolean;
|
|
36
|
-
};
|
|
8
|
+
export declare const FALLBACK_INIT_DATA: UiInitData;
|
|
37
9
|
export declare const CONFIGURATOR_IDLE = "(idle)";
|
|
38
10
|
export declare const getInitData: (useFallbackId?: boolean) => UiInitData;
|
|
39
11
|
export declare const castAndFixInitData: (initData: UiInitData) => UiInitData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deepCopy: <T>(o: T) => T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nullable } from '../../../src/common/utils/types';
|
|
1
|
+
import { Nullable, RapiCallbacks } from '../../../src/common/utils/types';
|
|
2
2
|
import { ExposedAnalyticsCallbacks } from '../../../src/configurator/embedding/exposed-analytics-callbacks';
|
|
3
3
|
import { ExposedApi } from '../../../src/configurator/embedding/exposed-api';
|
|
4
4
|
import { GlobalCallback } from '@roomle/web-sdk/lib/definitions/common-core/src/services/global-callback';
|
|
@@ -14,6 +14,7 @@ export interface RoomleEmbeddingApiKeys {
|
|
|
14
14
|
ui: any;
|
|
15
15
|
analytics: any;
|
|
16
16
|
global: any;
|
|
17
|
+
rapi: any;
|
|
17
18
|
}
|
|
18
19
|
export declare class Connector<SdkType, SdkCallbacks> implements RoomleEmbeddingApiKeys {
|
|
19
20
|
protected _messageHandler: Nullable<MessageHandler>;
|
|
@@ -27,6 +28,9 @@ export declare class Connector<SdkType, SdkCallbacks> implements RoomleEmbedding
|
|
|
27
28
|
analytics: {
|
|
28
29
|
callbacks: ExposedAnalyticsCallbacks;
|
|
29
30
|
};
|
|
31
|
+
rapi: {
|
|
32
|
+
callbacks: RapiCallbacks;
|
|
33
|
+
};
|
|
30
34
|
global: {
|
|
31
35
|
callbacks: GlobalCallback;
|
|
32
36
|
};
|
|
@@ -183,8 +183,10 @@ const p = ".", E = {
|
|
|
183
183
|
}
|
|
184
184
|
return e;
|
|
185
185
|
};
|
|
186
|
-
var v = /* @__PURE__ */ ((e) => (e.BOTTOM_BAR = "bottom_bar", e.PARTLIST_BOUNDS = "partlist_bounds", e.INTERACTION_NOTES = "interaction_notes", e.PARAMETER_GROUPS = "parameter_groups", e))(v || {})
|
|
187
|
-
const
|
|
186
|
+
var v = /* @__PURE__ */ ((e) => (e.BOTTOM_BAR = "bottom_bar", e.PARTLIST_BOUNDS = "partlist_bounds", e.INTERACTION_NOTES = "interaction_notes", e.PARAMETER_GROUPS = "parameter_groups", e))(v || {});
|
|
187
|
+
const $ = (e) => JSON.parse(JSON.stringify(e));
|
|
188
|
+
var z = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
189
|
+
const Y = {
|
|
188
190
|
mobileLandscape: !0,
|
|
189
191
|
floorMaterialRootTag: "materials_root",
|
|
190
192
|
buttons: {
|
|
@@ -207,14 +209,13 @@ const z = {
|
|
|
207
209
|
featureFlags: {
|
|
208
210
|
mocAr: !0,
|
|
209
211
|
wallAutoHeight: !1,
|
|
210
|
-
openCloseAnimation: !1
|
|
211
|
-
showWallVisibilityToggle: !1
|
|
212
|
+
openCloseAnimation: !1
|
|
212
213
|
},
|
|
213
214
|
rotationSnapDegrees: 10,
|
|
214
215
|
interactionsCollapsed: !1
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
}, q = "(idle)", K = (e) => (O(e), e != null && e.customApiUrl && (e.customApiUrl = decodeURIComponent(e.customApiUrl)), e.shareUrl && (e.deeplink = e.shareUrl.replace(
|
|
217
|
+
Z,
|
|
218
|
+
j
|
|
218
219
|
)), e), O = (e) => {
|
|
219
220
|
if (!e)
|
|
220
221
|
return;
|
|
@@ -226,21 +227,19 @@ const z = {
|
|
|
226
227
|
O(r);
|
|
227
228
|
(o === "true" || o === "false") && (e[s] = o === "true");
|
|
228
229
|
}
|
|
229
|
-
},
|
|
230
|
+
}, Q = (e, t) => {
|
|
230
231
|
t.configuratorId = e.id;
|
|
231
232
|
const s = e.settings || {};
|
|
232
233
|
return !t.overrideTenant && e.tenant && (t.overrideTenant = e.tenant), J(s, t);
|
|
233
|
-
},
|
|
234
|
-
const e =
|
|
235
|
-
|
|
236
|
-
};
|
|
237
|
-
e.locale || (e.locale = V()), e.id === Y && delete e.id;
|
|
234
|
+
}, X = () => {
|
|
235
|
+
const e = $(Y);
|
|
236
|
+
e.locale || (e.locale = V()), e.id === q && delete e.id;
|
|
238
237
|
const t = k();
|
|
239
|
-
return t && G(t) && (e.configuratorId = "demoConfigurator"), e.customApiUrl =
|
|
240
|
-
},
|
|
238
|
+
return t && G(t) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = z.VITE_RAPI_URL, e.emails = !1, e;
|
|
239
|
+
}, Z = "<CONF_ID>", j = "#CONFIGURATIONID#", ee = (e) => {
|
|
241
240
|
e.featureFlags || (e.featureFlags = {}), typeof e.featureFlags.realPartList != "boolean" && (e.featureFlags.realPartList = !0), typeof e.featureFlags.globalCallbacks != "boolean" && (e.featureFlags.globalCallbacks = !0), typeof e.featureFlags.mocAr != "boolean" && (e.featureFlags.mocAr = !1);
|
|
242
|
-
},
|
|
243
|
-
class
|
|
241
|
+
}, y = () => /(android)/i.test(navigator.userAgent);
|
|
242
|
+
class M {
|
|
244
243
|
constructor() {
|
|
245
244
|
c(this, "_messageHandler", null);
|
|
246
245
|
c(this, "isSetupDone", !1);
|
|
@@ -259,6 +258,9 @@ class y {
|
|
|
259
258
|
c(this, "analytics", {
|
|
260
259
|
callbacks: {}
|
|
261
260
|
});
|
|
261
|
+
c(this, "rapi", {
|
|
262
|
+
callbacks: {}
|
|
263
|
+
});
|
|
262
264
|
c(this, "global", {
|
|
263
265
|
callbacks: {}
|
|
264
266
|
});
|
|
@@ -358,7 +360,7 @@ const I = () => {
|
|
|
358
360
|
() => e.style.setProperty(S, H()),
|
|
359
361
|
0
|
|
360
362
|
);
|
|
361
|
-
}, b = "rml-styles",
|
|
363
|
+
}, b = "rml-styles", se = 450, S = "--rml-full-height", u = {
|
|
362
364
|
CONTAINER: "rml-container",
|
|
363
365
|
FILL: "rml-fill",
|
|
364
366
|
POSITION: "rml-pos",
|
|
@@ -366,7 +368,7 @@ const I = () => {
|
|
|
366
368
|
ANDROID_HEIGHT: "rml-android-height",
|
|
367
369
|
OVERFLOW_HIDDEN: "rml-overflow-hidden"
|
|
368
370
|
}, w = /* @__PURE__ */ new Map();
|
|
369
|
-
class
|
|
371
|
+
class re extends M {
|
|
370
372
|
constructor(s, o, r, n, a) {
|
|
371
373
|
super();
|
|
372
374
|
c(this, "_waitForIframe");
|
|
@@ -383,7 +385,7 @@ class te extends y {
|
|
|
383
385
|
if (!!!document.getElementById(b)) {
|
|
384
386
|
const g = r.zIndex || 9999999, h = document.createElement("style");
|
|
385
387
|
h.type = "text/css", h.id = b;
|
|
386
|
-
const m = "transition:all ease-in-out " +
|
|
388
|
+
const m = "transition:all ease-in-out " + se + "ms;", f = ["-webkit-", "-o-"].reduce(
|
|
387
389
|
(C, D) => C += D + m,
|
|
388
390
|
""
|
|
389
391
|
) + m, P = H();
|
|
@@ -403,7 +405,7 @@ class te extends y {
|
|
|
403
405
|
null,
|
|
404
406
|
this._executeMessage
|
|
405
407
|
);
|
|
406
|
-
this.setMessageHandler(l), this._onResize = this._onResize.bind(this),
|
|
408
|
+
this.setMessageHandler(l), this._onResize = this._onResize.bind(this), y() && window.addEventListener("resize", this._onResize), this._container = o, this._initData = r, this._configuratorSettings = s;
|
|
407
409
|
const d = this._createIframe();
|
|
408
410
|
this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = a, this._container.appendChild(d), this._iframe = d, this.setupPlugins(n, this._iframe), w.set(o, !0);
|
|
409
411
|
}
|
|
@@ -416,7 +418,7 @@ class te extends y {
|
|
|
416
418
|
);
|
|
417
419
|
}
|
|
418
420
|
static async connect(s, o = []) {
|
|
419
|
-
const r = new
|
|
421
|
+
const r = new M();
|
|
420
422
|
r.viewName = s;
|
|
421
423
|
const { resolve: n, promise: a } = I(), { resolve: i, promise: l } = I(), d = ({
|
|
422
424
|
message: m,
|
|
@@ -497,15 +499,15 @@ class te extends y {
|
|
|
497
499
|
return new Promise(async (a, i) => {
|
|
498
500
|
try {
|
|
499
501
|
const l = R(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
+
X(),
|
|
503
|
+
K(r)
|
|
502
504
|
);
|
|
503
|
-
|
|
505
|
+
ee(l);
|
|
504
506
|
const d = await U(
|
|
505
507
|
s,
|
|
506
508
|
l
|
|
507
509
|
);
|
|
508
|
-
r =
|
|
510
|
+
r = Q(d, l);
|
|
509
511
|
const g = new this(
|
|
510
512
|
d,
|
|
511
513
|
o,
|
|
@@ -534,7 +536,7 @@ class te extends y {
|
|
|
534
536
|
L(this._iframe);
|
|
535
537
|
}
|
|
536
538
|
_onUseFullPage() {
|
|
537
|
-
this._iframe.classList.add(u.POSITION), document.documentElement.classList.add(u.OVERFLOW_HIDDEN), window.document.body.classList.add(u.OVERFLOW_HIDDEN),
|
|
539
|
+
this._iframe.classList.add(u.POSITION), document.documentElement.classList.add(u.OVERFLOW_HIDDEN), window.document.body.classList.add(u.OVERFLOW_HIDDEN), y() && (L(this._iframe), this._iframe.classList.add(u.ANDROID_HEIGHT));
|
|
538
540
|
}
|
|
539
541
|
_onBackToWebsite() {
|
|
540
542
|
this._iframe.classList.remove(u.POSITION), this._iframe.classList.remove(u.ANDROID_HEIGHT), document.documentElement.classList.remove(u.OVERFLOW_HIDDEN), window.document.body.classList.remove(u.OVERFLOW_HIDDEN);
|
|
@@ -560,5 +562,5 @@ class te extends y {
|
|
|
560
562
|
}
|
|
561
563
|
}
|
|
562
564
|
export {
|
|
563
|
-
|
|
565
|
+
re as default
|
|
564
566
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,s,r)=>((t,s,r)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r)(t,"symbol"!=typeof s?s+"":s,r);class s{constructor(e,s,r,i){t(this,"_side"),t(this,"_incomingMessageBus",null),t(this,"_outgoingMessageBus",null),t(this,"_execMessage",null),this._side=e,this._incomingMessageBus=s,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise(((s,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 n="";try{n=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(n,"*",[i.port2])}))}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const r=this._execMessage(s,e);if(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 r=["127.0.0.1","localhost","0.0.0.0"],i=["language","browserLanguage","userLanguage","systemLanguage"],n=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=n(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var a=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(a||{}),o={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const l={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[a.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!1,showWallVisibilityToggle:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},c=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&&c(t),Array.isArray(t))for(const e of t)c(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},u=()=>/(android)/i.test(navigator.userAgent);class g{constructor(){t(this,"_messageHandler",null),t(this,"isSetupDone",!1),t(this,"viewName","main"),t(this,"plugins",{}),t(this,"pluginsLoaded",[]),t(this,"ui",{callbacks:null}),t(this,"extended",{callbacks:null}),t(this,"configurator",{callbacks:null}),t(this,"analytics",{callbacks:{}}),t(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach((e=>{const t=e.split("."),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("."),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("."),r=s[0],i=s[1],n=3===s.length?s[2]:null;if(n&&this[r][i][n]){const e=this[r][i][n](...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("./drag-in-DNbVoUkq.mjs").then((e=>e.l)).then((({DragIn:i})=>{const n=new i(this.ui,t,s,this.viewName);n.init().then((()=>{this.plugins.dragIn=n,e()}),r)}))}catch(e){r(e)}}))):r.name&&r.loader&&this.pluginsLoaded.push(new Promise(((e,i)=>{try{r.loader().then((n=>{const a=new n(this.ui,t,s,this.viewName);a.init().then((()=>{this.plugins[r.name]=a,e()}),i)}))}catch(e){i(e)}})))}}const h=()=>{let e,t;return{promise:new Promise(((s,r)=>{e=s,t=r})),resolve:e,reject:t}},d=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=null!=e&&e.mute?e.value:e}})},m=()=>.01*window.innerHeight+"px",p=e=>{e&&setTimeout((()=>e.style.setProperty(_,m())),0)},f="rml-styles",_="--rml-full-height",w="rml-container",b="rml-fill",y="rml-pos",v="rml-android-height",M="rml-overflow-hidden",S=new Map;class P extends g{constructor(e,r,i,n,a){if(super(),t(this,"_waitForIframe"),t(this,"_container"),t(this,"_configuratorSettings"),t(this,"_initData",{}),t(this,"_iframe"),!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(S.has(r))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(f)){const e=i.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=f;const s="transition:all ease-in-out 450ms;",r=["-webkit-","-o-"].reduce(((e,t)=>e+(t+s)),"")+s,n=m();t.innerHTML=`\n .${w}{${_}:${n};}\n .${y}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${r}}\n .${b}{width:100%;height:100%;opacity:1}\n .${v}{height:calc(var(${_},1vh)*100)}\n .${M}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const o=new s("website",window,null,this._executeMessage);this.setMessageHandler(o),this._onResize=this._onResize.bind(this),u()&&window.addEventListener("resize",this._onResize),this._container=r,this._initData=i,this._configuratorSettings=e;const l=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=a,this._container.appendChild(l),this._iframe=l,this.setupPlugins(n,this._iframe),S.set(r,!0)}static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(e,t=[]){const r=new g;r.viewName=e;const{resolve:i,promise:n}=h(),{resolve:a,promise:o}=h(),l=new s("custom-view-"+e,window,window.parent,(({message:e,args:t})=>{switch(e){case"registerCustomViewDone":i();break;case"returnMethods":r.handleSetup(t[0]),a();break;default:if(r.isSetupDone)return r.executeMessage({message:e,args:t})}}));r.setMessageHandler(l);const c=[e];return l.sendMessage("registerCustomView",c),await n,l.sendMessage("getMethods",c),await o,r.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(r.pluginsLoaded),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,a){return new Promise((async(u,g)=>{try{const g=n((()=>{const e={...l};e.locale||(e.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,s=i.length;e<s;e++){const s=t[i[e]];if(s)return s.substr(0,2)}return"en"})()),"(idle)"===e.id&&delete e.id;const t=(()=>{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 t&&(e=>!!(r.includes(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com")))(t)&&(e.configuratorId="demoConfigurator"),e.customApiUrl=o.VITE_RAPI_URL,e.emails=!1,e})(),(c(h=s),null!=h&&h.customApiUrl&&(h.customApiUrl=decodeURIComponent(h.customApiUrl)),h.shareUrl&&(h.deeplink=h.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),h));(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)})(g);const d=await(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,n="roomle_portal_v2",a="03-"+window.btoa((new Date).toISOString()+";anonymous;"+n),o=new Request(i,{method:"GET",headers:new Headers({apiKey:n,currentTenant:r,locale:"en",language:"en",device:1,token:a,platform:"web"}),mode:"cors",cache:"default"}),l=await fetch(o),{configurator:c}=await l.json();return c})(e,g);s=((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 n(s,t)})(s,t)})(d,g);const m=new this(d,t,s,a,u);return await Promise.allSettled(m.pluginsLoaded),m}catch(e){return g(e)}var h}))}teardown(){this._container&&S.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=(null==(e=this._configuratorSettings)?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(w),t.classList.add(b),t}_onResize(){p(this._iframe)}_onUseFullPage(){this._iframe.classList.add(y),document.documentElement.classList.add(M),window.document.body.classList.add(M),u()&&(p(this._iframe),this._iframe.classList.add(v))}_onBackToWebsite(){this._iframe.classList.remove(y),this._iframe.classList.remove(v),document.documentElement.classList.remove(M),window.document.body.classList.remove(M)}_executeMessage({message:e,args:t},s){var r;if(s.source&&s.source===(null==(r=this._iframe)?void 0:r.contentWindow))return"requestBoot"===e?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):Promise.resolve({error:"MessageHandler not set"}):"setup"===e?(this.handleSetup(t[0]),d(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),d(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout((()=>{this._messageHandler&&this._messageHandler.sendMessage("websiteReady")}),0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{P as default};
|
|
1
|
+
var e=Object.defineProperty,t=(t,s,r)=>((t,s,r)=>s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r)(t,"symbol"!=typeof s?s+"":s,r);class s{constructor(e,s,r,i){t(this,"_side"),t(this,"_incomingMessageBus",null),t(this,"_outgoingMessageBus",null),t(this,"_execMessage",null),this._side=e,this._incomingMessageBus=s,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise(((s,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 n="";try{n=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(n,"*",[i.port2])}))}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const r=this._execMessage(s,e);if(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 r=["127.0.0.1","localhost","0.0.0.0"],i=["language","browserLanguage","userLanguage","systemLanguage"],n=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=n(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var a=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(a||{}),o={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const l={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[a.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},c=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&&c(t),Array.isArray(t))for(const e of t)c(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},u=()=>/(android)/i.test(navigator.userAgent);class g{constructor(){t(this,"_messageHandler",null),t(this,"isSetupDone",!1),t(this,"viewName","main"),t(this,"plugins",{}),t(this,"pluginsLoaded",[]),t(this,"ui",{callbacks:null}),t(this,"extended",{callbacks:null}),t(this,"configurator",{callbacks:null}),t(this,"analytics",{callbacks:{}}),t(this,"rapi",{callbacks:{}}),t(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach((e=>{const t=e.split("."),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("."),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("."),r=s[0],i=s[1],n=3===s.length?s[2]:null;if(n&&this[r][i][n]){const e=this[r][i][n](...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("./drag-in-DNbVoUkq.mjs").then((e=>e.l)).then((({DragIn:i})=>{const n=new i(this.ui,t,s,this.viewName);n.init().then((()=>{this.plugins.dragIn=n,e()}),r)}))}catch(e){r(e)}}))):r.name&&r.loader&&this.pluginsLoaded.push(new Promise(((e,i)=>{try{r.loader().then((n=>{const a=new n(this.ui,t,s,this.viewName);a.init().then((()=>{this.plugins[r.name]=a,e()}),i)}))}catch(e){i(e)}})))}}const h=()=>{let e,t;return{promise:new Promise(((s,r)=>{e=s,t=r})),resolve:e,reject:t}},d=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=null!=e&&e.mute?e.value:e}})},m=()=>.01*window.innerHeight+"px",p=e=>{e&&setTimeout((()=>e.style.setProperty(_,m())),0)},f="rml-styles",_="--rml-full-height",w="rml-container",b="rml-fill",y="rml-pos",v="rml-android-height",M="rml-overflow-hidden",S=new Map;class P extends g{constructor(e,r,i,n,a){if(super(),t(this,"_waitForIframe"),t(this,"_container"),t(this,"_configuratorSettings"),t(this,"_initData",{}),t(this,"_iframe"),!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(S.has(r))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(f)){const e=i.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=f;const s="transition:all ease-in-out 450ms;",r=["-webkit-","-o-"].reduce(((e,t)=>e+(t+s)),"")+s,n=m();t.innerHTML=`\n .${w}{${_}:${n};}\n .${y}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${r}}\n .${b}{width:100%;height:100%;opacity:1}\n .${v}{height:calc(var(${_},1vh)*100)}\n .${M}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const o=new s("website",window,null,this._executeMessage);this.setMessageHandler(o),this._onResize=this._onResize.bind(this),u()&&window.addEventListener("resize",this._onResize),this._container=r,this._initData=i,this._configuratorSettings=e;const l=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=a,this._container.appendChild(l),this._iframe=l,this.setupPlugins(n,this._iframe),S.set(r,!0)}static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(e,t=[]){const r=new g;r.viewName=e;const{resolve:i,promise:n}=h(),{resolve:a,promise:o}=h(),l=new s("custom-view-"+e,window,window.parent,(({message:e,args:t})=>{switch(e){case"registerCustomViewDone":i();break;case"returnMethods":r.handleSetup(t[0]),a();break;default:if(r.isSetupDone)return r.executeMessage({message:e,args:t})}}));r.setMessageHandler(l);const c=[e];return l.sendMessage("registerCustomView",c),await n,l.sendMessage("getMethods",c),await o,r.setupPlugins(t,document.body,"custom-view"),await Promise.allSettled(r.pluginsLoaded),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,a){return new Promise((async(u,g)=>{try{const g=n((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(l);e.locale||(e.locale=((e=null)=>{const t=window.navigator;if(e)return e.substr(0,2);if(Array.isArray(t.languages)&&t.languages.length>0)return t.languages[0].substr(0,2);for(let e=0,s=i.length;e<s;e++){const s=t[i[e]];if(s)return s.substr(0,2)}return"en"})()),"(idle)"===e.id&&delete e.id;const t=(()=>{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 t&&(e=>!!(r.includes(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com")))(t)&&(e.configuratorId="demoConfigurator"),e.customApiUrl=o.VITE_RAPI_URL,e.emails=!1,e})(),(c(h=s),null!=h&&h.customApiUrl&&(h.customApiUrl=decodeURIComponent(h.customApiUrl)),h.shareUrl&&(h.deeplink=h.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),h));(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)})(g);const d=await(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,n="roomle_portal_v2",a="03-"+window.btoa((new Date).toISOString()+";anonymous;"+n),o=new Request(i,{method:"GET",headers:new Headers({apiKey:n,currentTenant:r,locale:"en",language:"en",device:1,token:a,platform:"web"}),mode:"cors",cache:"default"}),l=await fetch(o),{configurator:c}=await l.json();return c})(e,g);s=((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 n(s,t)})(s,t)})(d,g);const m=new this(d,t,s,a,u);return await Promise.allSettled(m.pluginsLoaded),m}catch(e){return g(e)}var h}))}teardown(){this._container&&S.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=(null==(e=this._configuratorSettings)?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(w),t.classList.add(b),t}_onResize(){p(this._iframe)}_onUseFullPage(){this._iframe.classList.add(y),document.documentElement.classList.add(M),window.document.body.classList.add(M),u()&&(p(this._iframe),this._iframe.classList.add(v))}_onBackToWebsite(){this._iframe.classList.remove(y),this._iframe.classList.remove(v),document.documentElement.classList.remove(M),window.document.body.classList.remove(M)}_executeMessage({message:e,args:t},s){var r;if(s.source&&s.source===(null==(r=this._iframe)?void 0:r.contentWindow))return"requestBoot"===e?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(s.source),Promise.resolve({result:this._initData})):Promise.resolve({error:"MessageHandler not set"}):"setup"===e?(this.handleSetup(t[0]),d(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),d(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout((()=>{this._messageHandler&&this._messageHandler.sendMessage("websiteReady")}),0),Promise.resolve({result:null})):this.executeMessage({message:e,args:t})}}export{P as default};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
(function(_,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(_=typeof globalThis<"u"?globalThis:_||self,_["roomle-embedding-lib"]=_["roomle-embedding-lib"]||{},_["roomle-embedding-lib"].umd=_["roomle-embedding-lib"].umd||{},_["roomle-embedding-lib"].umd.js=p())})(this,function(){"use strict";var
|
|
1
|
+
(function(_,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(_=typeof globalThis<"u"?globalThis:_||self,_["roomle-embedding-lib"]=_["roomle-embedding-lib"]||{},_["roomle-embedding-lib"].umd=_["roomle-embedding-lib"].umd||{},_["roomle-embedding-lib"].umd.js=p())})(this,function(){"use strict";var ee=Object.defineProperty;var se=(_,p,D)=>p in _?ee(_,p,{enumerable:!0,configurable:!0,writable:!0,value:D}):_[p]=D;var a=(_,p,D)=>se(_,typeof p!="symbol"?p+"":p,D);class _{constructor(e,t,s,n){a(this,"_side");a(this,"_incomingMessageBus",null);a(this,"_outgoingMessageBus",null);a(this,"_execMessage",null);this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=n,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,n)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=c=>{if(!c||!c.data)return i.port1.close(),i.port2.close(),n(new Error(this._side+" received message but response can not be interpreted"));let l;try{l=JSON.parse(c.data)}catch(u){return i.port1.close(),i.port2.close(),this._prepareError(u),n(u)}l.error?n(l.error):l.result!==void 0?s(l.result):s(void 0),i.port1.close(),i.port2.close()};let o="";try{o=JSON.stringify({message:e,args:t})}catch{return 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(o,"*",[i.port2])})}_handleMessage(e){const t=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&t)try{const s=JSON.parse(e.data);if(!this._execMessage)return t.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(s.args)||(s.args=[s.args]);const n=this._execMessage(s,e);if(n===void 0)return;n.then((i={})=>{let o,c;typeof i=="object"&&i!==null&&(o=i.error,c=i.result),o?t.postMessage(JSON.stringify({error:o})):c!==void 0?t.postMessage(JSON.stringify({result:c})):t.postMessage(JSON.stringify({result:i}))},i=>{t.postMessage(JSON.stringify({error:this._prepareError(i)}))})}catch(s){t.postMessage(JSON.stringify({error:this._prepareError(s)}))}}_prepareError(e){if(typeof e=="string"){const t=this._side+": "+e;return console.error(t),t}return e.message=this._side+": "+e.message,console.error(e),e.message}}const p=".",D={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},w={GET_METHODS:"getMethods",RETURN_METHODS:"returnMethods",REGISTER_CUSTOM_VIEW:"registerCustomView",REGISTER_CUSTOM_VIEW_DONE:"registerCustomViewDone"},pt=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,i="roomle_portal_v2",o="03-"+window.btoa(new Date().toISOString()+";anonymous;"+i),c=()=>{const d={apiKey:i,currentTenant:s,locale:"en",language:"en",device:1,token:o,platform:"web"};return new Headers(d)},l=new Request(n,{method:"GET",headers:c(),mode:"cors",cache:"default"}),u=await fetch(l),{configurator:h}=await u.json();return h},yt=()=>{try{return window.self!==window.top}catch{return!0}},Dt=["127.0.0.1","localhost","0.0.0.0"],Et=()=>{const r=yt();let e=window.location.href;if(r){if(!document.referrer)return null;e=document.referrer}const{hostname:t}=new URL(e);return t},Tt=r=>!!(Dt.includes(r)||r.endsWith("roomle.com")||r.endsWith("gitlab.io")||r.endsWith("gitlab.com")),k=["language","browserLanguage","userLanguage","systemLanguage"],St=(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=k.length;t<s;t++){const n=e[k[t]];if(n)return n.substr(0,2)}return"en"},It=(r,e)=>{const t=JSON.parse(JSON.stringify(r));return C(t,e)},C=(r,e)=>{for(const t in e)try{e[t].constructor===Object?r[t]=C(r[t],e[t]):r[t]=e[t]}catch{r[t]=e[t]}return r};var z=(r=>(r.BOTTOM_BAR="bottom_bar",r.PARTLIST_BOUNDS="partlist_bounds",r.INTERACTION_NOTES="interaction_notes",r.PARAMETER_GROUPS="parameter_groups",r))(z||{});const wt=r=>JSON.parse(JSON.stringify(r));var At={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const bt={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[z.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},Ot="(idle)",vt=r=>(L(r),r!=null&&r.customApiUrl&&(r.customApiUrl=decodeURIComponent(r.customApiUrl)),r.shareUrl&&(r.deeplink=r.shareUrl.replace(Ct,Lt)),r),L=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&&L(s),Array.isArray(s))for(const n of s)L(n);(s==="true"||s==="false")&&(r[t]=s==="true")}},Rt=(r,e)=>{e.configuratorId=r.id;const t=r.settings||{};return!e.overrideTenant&&r.tenant&&(e.overrideTenant=r.tenant),It(t,e)},Mt=()=>{const r=wt(bt);r.locale||(r.locale=St()),r.id===Ot&&delete r.id;const e=Et();return e&&Tt(e)&&(r.configuratorId="demoConfigurator"),r.customApiUrl=At.VITE_RAPI_URL,r.emails=!1,r},Ct="<CONF_ID>",Lt="#CONFIGURATIONID#",Nt=r=>{r.featureFlags||(r.featureFlags={}),typeof r.featureFlags.realPartList!="boolean"&&(r.featureFlags.realPartList=!0),typeof r.featureFlags.globalCallbacks!="boolean"&&(r.featureFlags.globalCallbacks=!0),typeof r.featureFlags.mocAr!="boolean"&&(r.featureFlags.mocAr=!1)},V=()=>/(android)/i.test(navigator.userAgent);class q{constructor(){a(this,"_messageHandler",null);a(this,"isSetupDone",!1);a(this,"viewName","main");a(this,"plugins",{});a(this,"pluginsLoaded",[]);a(this,"ui",{callbacks:null});a(this,"extended",{callbacks:null});a(this,"configurator",{callbacks:null});a(this,"analytics",{callbacks:{}});a(this,"rapi",{callbacks:{}});a(this,"global",{callbacks:{}})}setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(n=>{const i=n.split(p),o=i[0],c=i[1];this[o]||(this[o]={}),this[o][c]=(function(){if(!this._messageHandler){console.error("MessageHandler not set");return}return this._messageHandler.sendMessage(n,[...arguments])}).bind(this)}),s.forEach(n=>{const i=n.split(p),o=i[0],c=i[1],l=i[2];this[o]||(this[o]={}),this[o][c]||(this[o][c]={}),this[o][c][l]=()=>{}}),this.isSetupDone=!0}executeMessage({message:e,args:t}){const s=e.split(p),n=s[0],i=s[1],o=s.length===3?s[2]:null;if(o&&this[n][i][o]){const c=this[n][i][o](...t);return c instanceof Promise?c.then(l=>({result:l})):c!==void 0?Promise.resolve({result:c}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}setupPlugins(e,t,s="website"){for(const n of e)typeof n=="string"&&n==="dragIn"?this.pluginsLoaded.push(new Promise((i,o)=>{try{Promise.resolve().then(()=>Ht).then(({DragIn:c})=>{const l=new c(this.ui,t,s,this.viewName);l.init().then(()=>{this.plugins.dragIn=l,i()},o)})}catch(c){o(c)}})):n.name&&n.loader&&this.pluginsLoaded.push(new Promise((i,o)=>{try{n.loader().then(c=>{const l=new c(this.ui,t,s,this.viewName);l.init().then(()=>{this.plugins[n.name]=l,i()},o)})}catch(c){o(c)}}))}}const K=()=>{let r,e;return{promise:new Promise((s,n)=>{r=s,e=n}),resolve:r,reject:e}},J=(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)}})},j=()=>window.innerHeight*.01+"px",Q=r=>{r&&setTimeout(()=>r.style.setProperty(N,j()),0)},Z="rml-styles",xt=450,N="--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"},x=new Map;class Gt extends q{constructor(t,s,n,i,o){super();a(this,"_waitForIframe");a(this,"_container");a(this,"_configuratorSettings");a(this,"_initData",{});a(this,"_iframe");if(!t||typeof t.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(x.has(s))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(Z)){const h=n.zIndex||9999999,d=document.createElement("style");d.type="text/css",d.id=Z;const g="transition:all ease-in-out "+xt+"ms;",f=["-webkit-","-o-"].reduce((E,y)=>E+=y+g,"")+g,S=j();d.innerHTML=`
|
|
2
2
|
.${m.CONTAINER}{${N}:${S};}
|
|
3
3
|
.${m.POSITION}{position:fixed;top:0;left:0;z-index:${h};opacity:0}
|
|
4
4
|
.${m.TRANSITION}{${f}}
|
|
5
5
|
.${m.FILL}{width:100%;height:100%;opacity:1}
|
|
6
6
|
.${m.ANDROID_HEIGHT}{height:calc(var(${N},1vh)*100)}
|
|
7
7
|
.${m.OVERFLOW_HIDDEN}{overflow:hidden}
|
|
8
|
-
`,document.head.appendChild(d)}this._executeMessage=this._executeMessage.bind(this);const l=new _("website",window,null,this._executeMessage);this.setMessageHandler(l),this._onResize=this._onResize.bind(this),
|
|
8
|
+
`,document.head.appendChild(d)}this._executeMessage=this._executeMessage.bind(this);const l=new _("website",window,null,this._executeMessage);this.setMessageHandler(l),this._onResize=this._onResize.bind(this),V()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=n,this._configuratorSettings=t;const u=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=o,this._container.appendChild(u),this._iframe=u,this.setupPlugins(i,this._iframe),x.set(s,!0)}static createPlanner(t,s,n,i=[]){return this._create(t,s,n,i)}static async connect(t,s=[]){const n=new q;n.viewName=t;const{resolve:i,promise:o}=K(),{resolve:c,promise:l}=K(),u=({message:g,args:f})=>{switch(g){case w.REGISTER_CUSTOM_VIEW_DONE:i();break;case w.RETURN_METHODS:n.handleSetup(f[0]),c();break;default:if(n.isSetupDone)return n.executeMessage({message:g,args:f})}},h=new _("custom-view-"+t,window,window.parent,u);n.setMessageHandler(h);const d=[t];return h.sendMessage(w.REGISTER_CUSTOM_VIEW,d),await o,h.sendMessage(w.GET_METHODS,d),await l,n.setupPlugins(s,document.body,"custom-view"),await Promise.allSettled(n.pluginsLoaded),n}static createConfigurator(t,s,n,i=[]){return this._create(t,s,n,i)}static create(t,s,n,i){return this._create(t,s,n,i)}static createViewer(t,s,n,i=[]){return this._create(t,s,n,i)}static async _create(t,s,n,i){return new Promise(async(o,c)=>{try{const l=C(Mt(),vt(n));Nt(l);const u=await pt(t,l);n=Rt(u,l);const h=new this(u,s,n,i,o);return await Promise.allSettled(h.pluginsLoaded),h}catch(l){return c(l)}})}teardown(){this._container&&x.delete(this._container);const t=this._container.querySelector("iframe");t&&this._container.removeChild(t),window.removeEventListener("resize",this._onResize)}_createIframe(){var n;const t=document.createElement("iframe");let s=((n=this._configuratorSettings)==null?void 0:n.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(){Q(this._iframe)}_onUseFullPage(){this._iframe.classList.add(m.POSITION),document.documentElement.classList.add(m.OVERFLOW_HIDDEN),window.document.body.classList.add(m.OVERFLOW_HIDDEN),V()&&(Q(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:t,args:s},n){var i;if(n.source&&n.source===((i=this._iframe)==null?void 0:i.contentWindow))return t===D.REQUEST_BOOT?this._messageHandler?(this._messageHandler.setOutgoingMessageBus(n.source),Promise.resolve({result:this._initData})):(console.error("MessageHandler not set"),Promise.resolve({error:"MessageHandler not set"})):t===D.SETUP?(this.handleSetup(s[0]),J(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),J(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>{if(!this._messageHandler){console.error("MessageHandler not set");return}this._messageHandler.sendMessage(D.WEBSITE_READY)},0),Promise.resolve({result:null})):this.executeMessage({message:t,args:s})}}class Ft{constructor(e,t,s,n){a(this,"_mainDomElement");a(this,"_instance");a(this,"_mode","website");a(this,"_viewName","main");this._instance=e,this._mainDomElement=t,this._mode=s,this._viewName=n}async init(){return Promise.resolve()}}const A="rml-drag-in-styles",b="rml-drag-in-drag-element",O="rml-drag-in-overlay",v="rml-drag-in-drag-ghost",tt="rml-drag-in-fade-in",et="rml-drag-in-fade-out",G={DISPLAY_NONE:"rml-display-none"},st=.5,rt="250ms",nt="forwards",it=`@keyframes ${tt} {from{opacity: 0;}to {opacity: ${st};}}`,ot=`@keyframes ${et} {from{opacity: ${st};}to {opacity: 0;}}`,at=`${tt} ${rt} ${nt}`,ct=`${et} ${rt} ${nt}`,R="https://res.cloudinary.com/roomle/image/upload/v1729679975/fallback_afpyqr.jpg",F=112,P=112;class Pt extends Ft{constructor(t,s,n,i){super(t,s,n,i);a(this,"options",{});a(this,"_customDragSignal",new AbortController);this._mainDomElement=s,this._injectStyles(),this._initializeDragGhost()}_injectStyles(){if(!!!document.getElementById(A)){const s=document.createElement("style");s.type="text/css",s.id=A,s.innerHTML=`
|
|
9
9
|
.${G.DISPLAY_NONE}{display:none}
|
|
10
10
|
.${O}{position:absolute;top:0;left:0;width:100%;height:100%;z-index:999;}
|
|
11
11
|
.${v}{position:absolute;top:0;left:0;width:1px;height:1px;z-index:999;pointer-events:none;background-color:transparent;}
|
|
12
12
|
${it}
|
|
13
13
|
${ot}
|
|
14
|
-
`,document.head.appendChild(s)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let s=t.querySelector("."+v);s||(s=document.createElement("div"),s.classList.add(v),s.innerText=" ",t.appendChild(s))}async init(){if(await super.init(),this._mode==="website")try{const{DragInFromWebsiteStrategy:t}=await Promise.resolve().then(()=>Vt);this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw console.error('Could not load Dragin strategy "FromWebsite"'),t}else if(this._mode==="custom-view")try{const{DragInFromCustomViewStrategy:t}=await Promise.resolve().then(()=>
|
|
14
|
+
`,document.head.appendChild(s)}}_initializeDragGhost(){const t=this._mainDomElement.parentNode;let s=t.querySelector("."+v);s||(s=document.createElement("div"),s.classList.add(v),s.innerText=" ",t.appendChild(s))}async init(){if(await super.init(),this._mode==="website")try{const{DragInFromWebsiteStrategy:t}=await Promise.resolve().then(()=>Vt);this._strategy=new t(this._instance,this._mainDomElement,{settings:this.options,mode:"website"})}catch(t){throw console.error('Could not load Dragin strategy "FromWebsite"'),t}else if(this._mode==="custom-view")try{const{DragInFromCustomViewStrategy:t}=await Promise.resolve().then(()=>te);this._strategy=new t(this._instance,this.options,this._viewName)}catch(t){throw console.error('Could not load Dragin strategy "FromCustomView"'),t}else throw new Error("Unsupported mode")}get isDragging(){return this._strategy.isDragging}dragStart(t,s,n="rml_id"){this._strategy.dragStart(t,s,n)}dragUpdate(t){this._strategy.dragUpdate(t)}dragEnd(){this._strategy.dragEnd()}touchStart(t,s,n="rml_id"){this._strategy.touchStart(t,s,n)}touchMove(t){this._strategy.touchMove(t)}touchEnd(){this._strategy.touchEnd()}dispose(){this._strategy.dispose()}beforeUpdateGhost(t){this._strategy.beforeUpdateGhost(t)}registerCustomDrag({customDragStart:t,customDragEnd:s,customDragUpdate:n,beforeUpdateGhost:i}){i&&this._strategy.beforeUpdateGhost(i);const o=this._customDragSignal.signal,c=h=>{h.target.getAttribute("data-rml-draggable")==="true"&&t(h)},l=h=>{this._strategy.releaseInput(h),this._strategy.isDragging&&s(h)},u=h=>{n(h)};document.querySelectorAll('[data-rml-draggable="true"]').forEach(h=>{h.draggable=!1}),document.addEventListener("mousedown",c,{signal:o}),document.addEventListener("mouseup",l,{signal:o}),document.addEventListener("mousemove",u,{signal:o}),document.addEventListener("mouseleave",l,{signal:o}),document.addEventListener("touchstart",c,{signal:o}),document.addEventListener("touchend",l,{signal:o}),document.addEventListener("touchmove",u,{signal:o})}unregisterCustomDrag(){this._customDragSignal.abort(),this._customDragSignal=new AbortController}releaseInput(t){this._strategy.releaseInput(t)}}const Ht=Object.freeze(Object.defineProperty({__proto__:null,DragIn:Pt},Symbol.toStringTag,{value:"Module"}));class Ut{constructor(e=16){a(this,"_computedStyleCache",new Map);a(this,"_maxLifetime",16);a(this,"_cacheCleanInterval",null);this._maxLifetime=e}get(e){const t=this._computedStyleCache.get(e),s=Date.now();if(t&&s-t.updated<this._maxLifetime)return t.style;const 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 T=r=>window.TouchEvent&&r instanceof window.TouchEvent;let H;const M=r=>(H||(H=new Ut),H.get(r)),lt=(r,e,t)=>{const s=parseFloat(r),n=window.devicePixelRatio||1;if(e==="px")return s;if(e==="%"){const o=t===document.documentElement?window.innerWidth:t.offsetWidth;return s/100*o}if(e==="rem"){const o=parseFloat(M(document.documentElement).fontSize);return s*o}if(e==="em"){const o=parseFloat(M(t).fontSize);return s*o}if(e==="vh"||e==="vw"||e==="vmin"||e==="vmax"){const o={vh:window.innerHeight,vw:window.innerWidth,vmin:Math.min(window.innerWidth,window.innerHeight),vmax:Math.max(window.innerWidth,window.innerHeight)};return s/100*o[e]}const i={cm:37.7952755906,mm:3.77952755906,in:96};return e in i?s*i[e]*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)},ht=(r,e,t={x:0,y:0})=>{const s=r.getBoundingClientRect(),i=M(r).transform;let o=0,c=0;if(i!=="none"){const g=/translate\(\s*([-+]?\d*\.?\d+|\d+)(px|%)?,?\s*([-+]?\d*\.?\d+|\d+)?(px|%)?\s*\)/,f=i.match(g);f&&(o=lt(f[1],f[2],r),c=lt(f[3],f[4],r))}const{clientX:l,clientY:u}=I(e,t),h=l-s.left-o+r.scrollLeft,d=u-s.top-c+r.scrollTop;return{x:h,y:d}},I=(r,e=null)=>{const{clientX:t,clientY:s}=T(r)?Bt(r):r,n=t>0?t:e?e.x:t,i=s>0?s:e?e.y:s;return{clientX:n,clientY:i}},Bt=r=>{if(r.touches.length){let{clientX:t,clientY:s}=r.touches[0];if(r.touches.length>1){const n=r.touches[1],i=n.clientX,o=n.clientY;t=(t+i)/2,s=(s+o)/2}return{clientX:t,clientY:s}}const e=r.changedTouches[0];return{clientX:e.clientX,clientY:e.clientY}},U=500,B=10,Yt=100,ut=15,Y=(r,e=0)=>T(r)?{clientX:r.touches[e].clientX,clientY:r.touches[e].clientY}:{clientX:r.clientX,clientY:r.clientY},dt=r=>r&&T(r)?r.touches.length>0:!0;class gt{constructor(e,{onTouchDragStart:t},s={}){a(this,"_touchDragTimeOut");a(this,"_onTouchDragStart");a(this,"_payload",null);a(this,"_delay",U);a(this,"_firstTouch",null);a(this,"_lastTouch",null);a(this,"_epsilon",B);this._payload=e,this._onTouchDragStart=t,this._delay=typeof s.delay=="number"?s.delay:U,this._epsilon=typeof s.epsilon=="number"?s.epsilon:B}onStart(e){dt(e)&&(this._touchDragTimeOut||(this._firstTouch=Y(e,T(e)?e.touches.length-1:0),this._touchDragTimeOut=setTimeout(()=>{this._clearTimeout(),this._lastTouch||(this._lastTouch=Y(e)),this._checkXDistance(e)()},this._delay)))}onEnd(){this._resetTouches()}onMove(e){dt(e)&&(this._lastTouch=Y(e))}_clearTimeout(){this._touchDragTimeOut&&(clearTimeout(this._touchDragTimeOut),this._touchDragTimeOut=null)}_resetTouches(){this._clearTimeout(),this._lastTouch=null,this._firstTouch=null,this._payload=null}_checkXDistance(e){return()=>{if(!this._firstTouch||!this._lastTouch)return;let t=!1;t=Math.abs(this._firstTouch.clientX-this._lastTouch.clientX)<this._epsilon,t&&(this._onTouchDragStart(this._payload,e),this._resetTouches())}}}const _t=(r,e,t=0,s=0)=>{const n=e.x+e.width+t,i=e.x-t,o=e.y+e.height+s,c=e.y-s,{x:l,y:u}=r;return l>=i&&l<=n&&u>=c&&u<=o},mt=(r,e,t,s=0,n=0)=>{if(!(!t||!t.hiddenIn&&!t.visibleIn))return t.visibleIn?_t({x:r,y:e},t.visibleIn,s,n):t.hiddenIn?!_t({x:r,y:e},t.hiddenIn,-s,-n):!1},Xt=()=>{if(!!!document.getElementById(A)){const e=document.createElement("style");e.type="text/css",e.id=A,e.innerHTML=`
|
|
15
15
|
${it}
|
|
16
16
|
${ot}
|
|
17
|
-
`,document.head.appendChild(e)}},Xt=({x:r,y:e},t)=>{var n,i,o,a,l,u;let s=document.getElementById(b);if(!s){if(s=document.createElement("div"),(n=t.ghost)!=null&&n.element)s.appendChild(t.ghost.element);else{const h=document.createElement("img");h.src=((i=t.ghost)==null?void 0:i.url)||R,h.width=((o=t.ghost)==null?void 0:o.width)||F,h.height=((a=t.ghost)==null?void 0:a.height)||P,s.appendChild(h)}s.id=b,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.willChange="transform",s.style.transform="translate3d(0, 0, 0)",s.style.zIndex="9999",s.style.opacity="0.5",mt(r,e,t.ghost||{},(l=t.settings)==null?void 0:l.dragInOverlapX,(u=t.settings)==null?void 0:u.dragInOverlapY)||(s.style.display="none"),s.style.pointerEvents="none",document.body.appendChild(s)}},Wt=({x:r,y:e},t)=>{var l,u,h,d;const s=document.getElementById(b);if(!s)return;let n=(l=t.ghost)==null?void 0:l.width,i=(u=t.ghost)==null?void 0:u.height;typeof n>"u"&&(n=s.getBoundingClientRect().width||F),typeof i>"u"&&(i=s.getBoundingClientRect().height||P);const o=r-n/2,a=e-i/2;s.style.transform=`translate3d(${o}px, ${a}px, 0)`,t.ghost&&(mt(r,e,t.ghost,(h=t.settings)==null?void 0:h.dragInOverlapX,(d=t.settings)==null?void 0:d.dragInOverlapY)?s.style.animation!=at&&(s.style.animation=at):s.style.animation!=ct&&(s.style.animation=ct))};class $t{constructor(e=null){c(this,"_dragGhostAnimationFrameId",null);c(this,"_dragGhostRemoveAnimationFrameId",null);c(this,"_dragGhostElement",null);this._dragGhostElement=e}updateDragGhost(e,t,s){var n;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((n=s.ghost)!=null&&n.external)&&s.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{Yt();const i={x:e,y:t};!s.ghost&&this._dragGhostElement&&(s.ghost={}),s.ghost&&!s.ghost.element&&this._dragGhostElement&&(s.ghost.element=this._dragGhostElement),Xt(i,s),Wt(i,s),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const e=document.getElementById(b);e&&document.body.removeChild(e),this._dragGhostRemoveAnimationFrameId=null}))}}class kt{constructor(e,t,s){c(this,"_options",{});c(this,"_instance");c(this,"_mainDomElement");c(this,"_currentDrag",{});c(this,"_currentTouch",null);c(this,"_firefoxDragPosition",{x:0,y:0});c(this,"_onBeforeUpdateDrag",()=>({}));c(this,"isDragging",!1);c(this,"_firefoxFallback",e=>{if(!this._currentDrag.event)return;e.preventDefault();const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});this._instance=e,this._mainDomElement=t,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}dragStart(e,t,s="rml_id"){const n=this._mainDomElement.parentNode;if(M(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._mainDomElement.style.pointerEvents="none";let o=n.querySelector("."+O);o||(o=document.createElement("div"),o.classList.add(O),n.appendChild(o)),o.classList.remove(G.DISPLAY_NONE),t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const l=n.querySelector("."+v);this._currentDrag.event=t;const u=t.target,h=u.cloneNode(!0),d=u.getBoundingClientRect();h.style.width=`${d.width}px`,h.style.height=`${d.height}px`,this._currentDrag.ghost=new $t(h),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:g,clientY:f}=I(t,this._firefoxDragPosition);this._currentDrag.offset.x=g-d.left,this._currentDrag.offset.y=f-d.top,t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(l,0,0);const{x:S,y:E}=ht(n,this._currentDrag.event||t,this._firefoxDragPosition),y=Math.max(1,S),$=Math.max(1,E);this.isDragging=!0,this._instance.dragInObject(e,y,$,s)}dragUpdate(e){var E;const t=this._mainDomElement.parentNode,{x:s,y:n}=ht(t,e,this._firefoxDragPosition);if(s===0&&n===0)return;const i=Math.max(1,s),o=Math.max(1,n);if(i===1&&o===1)return;let a=i,l=o;if(T(e)){const y=((E=this._options.settings)==null?void 0:E.fingerSize)||0;a=Math.max(2,i+y),l=Math.max(2,o-y)}const{x:u,y:h,options:d}=this._onBeforeUpdateDrag(a,l,{}),g=d||{settings:{},ghost:{}};g.ghost||(g.ghost={}),g.ghost.visibleIn&&g.ghost.hiddenIn||(g.ghost.hiddenIn=this._mainDomElement.getBoundingClientRect());const f=typeof u=="number"?u:a,S=typeof h=="number"?h:l;if(this._currentDrag.ghost){const{clientX:y,clientY:$}=I(e,this._firefoxDragPosition);this._currentDrag.ghost.updateDragGhost(y,$,g)}this._instance.updateDrag(f,S,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const e=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+O);t&&t.classList.add(G.DISPLAY_NONE)}touchStart(e,t,s="rml_id"){var o,a,l,u;t.preventDefault();const n=(h,d)=>{this.dragStart(e,d,s)},i={};typeof((a=(o=this._options)==null?void 0:o.settings)==null?void 0:a.touchDragDelay)=="number"&&(i.delay=this._options.settings.touchDragDelay),(u=(l=this._options)==null?void 0:l.settings)!=null&&u.touchDragEpsilon&&(i.epsilon=this._options.settings.touchDragEpsilon),this._currentTouch=new gt(void 0,{onTouchDragStart:n},i),this._currentTouch.onStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(e){}}const Vt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromWebsiteStrategy:kt},Symbol.toStringTag,{value:"Module"})),zt=r=>`[data-rml-custom-view="${r}"]`,X=r=>{r.preventDefault(),r.stopPropagation()},qt=(r,e,t,s)=>{const n=t-r,i=s-e;return Math.sqrt(n*n+i*i)};class Kt{constructor({onCustomDragStart:e},t={}){c(this,"_startX",0);c(this,"_startY",0);c(this,"_lastX",0);c(this,"_lastY",0);c(this,"_epsilon");c(this,"_isWaiting",!1);c(this,"_onCustomDragStart");this._epsilon=typeof t.epsilon=="number"?t.epsilon:ut,this._onCustomDragStart=e}onMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._isWaiting&&qt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(e),this._isWaiting=!1)}onStart(e){this._startX=e.clientX,this._startY=e.clientY,this.onMove(e),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const W="data-rml-old-draggable",Jt=void 0,ft=(r,e)=>{const t=T(r),s={delay:t?U:Bt,epsilon:t?B:ut};if(!e)return s;if(!t&&!(r instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:n,epsilonKey:i}=t?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof e[n]=="number"&&(s.delay=e.touchDragDelay),typeof e[i]=="number"&&(s.epsilon=e.touchDragEpsilon),s},jt=r=>{let e="",t=F,s=P;if(!r)return{url:R,width:t,height:s};const n=r;if(n instanceof HTMLElement){const i=n.getBoundingClientRect(),o=n.getAttribute("data-rml-ghost-url"),a=n.getAttribute("data-rml-ghost-width"),l=n.getAttribute("data-rml-ghost-height");o?e=o:!o&&n instanceof HTMLImageElement&&n.src&&(e=n.src),e?(t=i.width,s=i.height):e=R,t=a?parseInt(a,10):t,s=l?parseInt(l,10):s}return{url:e||R,width:t,height:s}};class Qt{constructor(e,t,s){c(this,"_options",{});c(this,"_instance");c(this,"_viewName");c(this,"_currentCustomDrag",null);c(this,"_currentBb",null);c(this,"_startTarget",null);c(this,"_onBeforeUpdateDrag",()=>({}));c(this,"isDragging",!1);this._instance=e,this._options=t||{},this._viewName=s}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}async _dragStart(e,t,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(W,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",X),this._startTarget.addEventListener("dragstart",X)),this._currentBb=await this._instance.getBoundingClientRect(zt(this._viewName));const{clientX:n,clientY:i}=I(t),o=this._currentBb.x+n,a=this._currentBb.y+i;this.isDragging=!0,this._instance.dragInObject(e,o,a,s)}_dragUpdate(e){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(e),!this._currentBb||!this.isDragging)return;const{clientX:t,clientY:s}=I(e),{url:n,width:i,height:o}=jt(this._startTarget),a=this._currentBb.x+t,l=this._currentBb.y+s,u=this._options||{},h={ghost:{visibleIn:{x:this._currentBb.x-(u.dragInOverlapX||0),y:this._currentBb.y+(u.dragInOverlapY||0),width:this._currentBb.width+(u.dragInOverlapX||0),height:this._currentBb.height+(u.dragInOverlapY||0)},url:n,width:i,height:o},mode:"custom-view"},{x:d,y:g,options:f}=this._onBeforeUpdateDrag(a,l,h),S=typeof d=="number"?d:a,E=typeof g=="number"?g:l,y=f||h;this._instance.updateDrag(S,E,y)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(e,t,s){this._instance.disableEvents(),this._startTarget=t.target;const n=(i,o)=>{this._dragStart(e,o,s)};this._currentCustomDrag=T(t)?new gt(Jt,{onTouchDragStart:n},ft(t,this._options)):new Kt({onCustomDragStart:i=>this._dragStart(e,i,s)},ft(t,this._options)),this._currentCustomDrag.onStart(t)}dragEnd(){this._dragEnd()}dragUpdate(e){this._dragUpdate(e)}touchStart(e,t,s="rml_id"){this.dragStart(e,t,s)}touchMove(e){this.dragUpdate(e)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(W)==="true",this._startTarget.removeAttribute(W),this._startTarget.removeEventListener("dragstart",X))}releaseInput(e){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}const Zt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromCustomViewStrategy:Qt},Symbol.toStringTag,{value:"Module"}));return xt});
|
|
17
|
+
`,document.head.appendChild(e)}},Wt=({x:r,y:e},t)=>{var n,i,o,c,l,u;let s=document.getElementById(b);if(!s){if(s=document.createElement("div"),(n=t.ghost)!=null&&n.element)s.appendChild(t.ghost.element);else{const h=document.createElement("img");h.src=((i=t.ghost)==null?void 0:i.url)||R,h.width=((o=t.ghost)==null?void 0:o.width)||F,h.height=((c=t.ghost)==null?void 0:c.height)||P,s.appendChild(h)}s.id=b,s.style.position="fixed",s.style.top="0",s.style.left="0",s.style.willChange="transform",s.style.transform="translate3d(0, 0, 0)",s.style.zIndex="9999",s.style.opacity="0.5",mt(r,e,t.ghost||{},(l=t.settings)==null?void 0:l.dragInOverlapX,(u=t.settings)==null?void 0:u.dragInOverlapY)||(s.style.display="none"),s.style.pointerEvents="none",document.body.appendChild(s)}},$t=({x:r,y:e},t)=>{var l,u,h,d;const s=document.getElementById(b);if(!s)return;let n=(l=t.ghost)==null?void 0:l.width,i=(u=t.ghost)==null?void 0:u.height;typeof n>"u"&&(n=s.getBoundingClientRect().width||F),typeof i>"u"&&(i=s.getBoundingClientRect().height||P);const o=r-n/2,c=e-i/2;s.style.transform=`translate3d(${o}px, ${c}px, 0)`,t.ghost&&(mt(r,e,t.ghost,(h=t.settings)==null?void 0:h.dragInOverlapX,(d=t.settings)==null?void 0:d.dragInOverlapY)?s.style.animation!=at&&(s.style.animation=at):s.style.animation!=ct&&(s.style.animation=ct))};class kt{constructor(e=null){a(this,"_dragGhostAnimationFrameId",null);a(this,"_dragGhostRemoveAnimationFrameId",null);a(this,"_dragGhostElement",null);this._dragGhostElement=e}updateDragGhost(e,t,s){var n;this._dragGhostRemoveAnimationFrameId&&(cancelAnimationFrame(this._dragGhostRemoveAnimationFrameId),this._dragGhostRemoveAnimationFrameId=null),!((n=s.ghost)!=null&&n.external)&&s.ghost&&(this._dragGhostAnimationFrameId||(this._dragGhostAnimationFrameId=requestAnimationFrame(()=>{Xt();const i={x:e,y:t};!s.ghost&&this._dragGhostElement&&(s.ghost={}),s.ghost&&!s.ghost.element&&this._dragGhostElement&&(s.ghost.element=this._dragGhostElement),Wt(i,s),$t(i,s),this._dragGhostAnimationFrameId=null})))}removeDragGhost(){this._dragGhostAnimationFrameId&&(cancelAnimationFrame(this._dragGhostAnimationFrameId),this._dragGhostAnimationFrameId=null),this._dragGhostRemoveAnimationFrameId||(this._dragGhostRemoveAnimationFrameId=requestAnimationFrame(()=>{const e=document.getElementById(b);e&&document.body.removeChild(e),this._dragGhostRemoveAnimationFrameId=null}))}}class zt{constructor(e,t,s){a(this,"_options",{});a(this,"_instance");a(this,"_mainDomElement");a(this,"_currentDrag",{});a(this,"_currentTouch",null);a(this,"_firefoxDragPosition",{x:0,y:0});a(this,"_onBeforeUpdateDrag",()=>({}));a(this,"isDragging",!1);a(this,"_firefoxFallback",e=>{if(!this._currentDrag.event)return;e.preventDefault();const t=e||window.event;this._firefoxDragPosition.x=t.pageX||0,this._firefoxDragPosition.y=t.pageY||0});this._instance=e,this._mainDomElement=t,this._options=s||{},this._firefoxFallback=this._firefoxFallback.bind(this),document.addEventListener("dragover",this._firefoxFallback)}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}dragStart(e,t,s="rml_id"){const n=this._mainDomElement.parentNode;if(M(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._mainDomElement.style.pointerEvents="none";let o=n.querySelector("."+O);o||(o=document.createElement("div"),o.classList.add(O),n.appendChild(o)),o.classList.remove(G.DISPLAY_NONE),t.target.getAttribute("draggable")||console.warn(`Draggable not detected correctly! Did you add draggable="true" to the element? In Sarafi only 'draggable' is too less`);const l=n.querySelector("."+v);this._currentDrag.event=t;const u=t.target,h=u.cloneNode(!0),d=u.getBoundingClientRect();h.style.width=`${d.width}px`,h.style.height=`${d.height}px`,this._currentDrag.ghost=new kt(h),this._currentDrag.offset||(this._currentDrag.offset={x:0,y:0});const{clientX:g,clientY:f}=I(t,this._firefoxDragPosition);this._currentDrag.offset.x=g-d.left,this._currentDrag.offset.y=f-d.top,t instanceof DragEvent&&t.dataTransfer&&t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(l,0,0);const{x:S,y:E}=ht(n,this._currentDrag.event||t,this._firefoxDragPosition),y=Math.max(1,S),$=Math.max(1,E);this.isDragging=!0,this._instance.dragInObject(e,y,$,s)}dragUpdate(e){var E;const t=this._mainDomElement.parentNode,{x:s,y:n}=ht(t,e,this._firefoxDragPosition);if(s===0&&n===0)return;const i=Math.max(1,s),o=Math.max(1,n);if(i===1&&o===1)return;let c=i,l=o;if(T(e)){const y=((E=this._options.settings)==null?void 0:E.fingerSize)||0;c=Math.max(2,i+y),l=Math.max(2,o-y)}const{x:u,y:h,options:d}=this._onBeforeUpdateDrag(c,l,{}),g=d||{settings:{},ghost:{}};g.ghost||(g.ghost={}),g.ghost.visibleIn&&g.ghost.hiddenIn||(g.ghost.hiddenIn=this._mainDomElement.getBoundingClientRect());const f=typeof u=="number"?u:c,S=typeof h=="number"?h:l;if(this._currentDrag.ghost){const{clientX:y,clientY:$}=I(e,this._firefoxDragPosition);this._currentDrag.ghost.updateDragGhost(y,$,g)}this._instance.updateDrag(f,S,{})}dragEnd(){this._mainDomElement.style.pointerEvents="all";const e=this._mainDomElement.parentNode;this.isDragging=!1,this._instance.dragInObjectEnd(),this._currentDrag.ghost&&(this._currentDrag.ghost.removeDragGhost(),this._currentDrag.ghost=null),this._currentDrag={},this._firefoxDragPosition={x:0,y:0};const t=e.querySelector("."+O);t&&t.classList.add(G.DISPLAY_NONE)}touchStart(e,t,s="rml_id"){var o,c,l,u;t.preventDefault();const n=(h,d)=>{this.dragStart(e,d,s)},i={};typeof((c=(o=this._options)==null?void 0:o.settings)==null?void 0:c.touchDragDelay)=="number"&&(i.delay=this._options.settings.touchDragDelay),(u=(l=this._options)==null?void 0:l.settings)!=null&&u.touchDragEpsilon&&(i.epsilon=this._options.settings.touchDragEpsilon),this._currentTouch=new gt(void 0,{onTouchDragStart:n},i),this._currentTouch.onStart(t)}touchMove(e){this._currentTouch&&this._currentTouch.onMove(e),this._currentDrag.event&&this.dragUpdate(e)}touchEnd(){this._currentTouch&&this._currentTouch.onEnd(),this._currentTouch=null,this.dragEnd()}dispose(){document.removeEventListener("dragover",this._firefoxFallback)}releaseInput(e){}}const Vt=Object.freeze(Object.defineProperty({__proto__:null,DragInFromWebsiteStrategy:zt},Symbol.toStringTag,{value:"Module"})),qt=r=>`[data-rml-custom-view="${r}"]`,X=r=>{r.preventDefault(),r.stopPropagation()},Kt=(r,e,t,s)=>{const n=t-r,i=s-e;return Math.sqrt(n*n+i*i)};class Jt{constructor({onCustomDragStart:e},t={}){a(this,"_startX",0);a(this,"_startY",0);a(this,"_lastX",0);a(this,"_lastY",0);a(this,"_epsilon");a(this,"_isWaiting",!1);a(this,"_onCustomDragStart");this._epsilon=typeof t.epsilon=="number"?t.epsilon:ut,this._onCustomDragStart=e}onMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._isWaiting&&Kt(this._startX,this._startY,this._lastX,this._lastY)>this._epsilon&&(this._onCustomDragStart(e),this._isWaiting=!1)}onStart(e){this._startX=e.clientX,this._startY=e.clientY,this.onMove(e),this._isWaiting=!0}onEnd(){this._reset()}_reset(){this._startX=0,this._startY=0,this._lastX=0,this._lastY=0,this._isWaiting=!1}}const W="data-rml-old-draggable",jt=void 0,ft=(r,e)=>{const t=T(r),s={delay:t?U:Yt,epsilon:t?B:ut};if(!e)return s;if(!t&&!(r instanceof MouseEvent))return console.warn("Unsupported event! It is not TouchEvent and also not MouseEvent"),s;const{delayKey:n,epsilonKey:i}=t?{delayKey:"touchDragDelay",epsilonKey:"touchDragEpsilon"}:{delayKey:"customDragDelay",epsilonKey:"customDragEpsilon"};return typeof e[n]=="number"&&(s.delay=e.touchDragDelay),typeof e[i]=="number"&&(s.epsilon=e.touchDragEpsilon),s},Qt=r=>{let e="",t=F,s=P;if(!r)return{url:R,width:t,height:s};const n=r;if(n instanceof HTMLElement){const i=n.getBoundingClientRect(),o=n.getAttribute("data-rml-ghost-url"),c=n.getAttribute("data-rml-ghost-width"),l=n.getAttribute("data-rml-ghost-height");o?e=o:!o&&n instanceof HTMLImageElement&&n.src&&(e=n.src),e?(t=i.width,s=i.height):e=R,t=c?parseInt(c,10):t,s=l?parseInt(l,10):s}return{url:e||R,width:t,height:s}};class Zt{constructor(e,t,s){a(this,"_options",{});a(this,"_instance");a(this,"_viewName");a(this,"_currentCustomDrag",null);a(this,"_currentBb",null);a(this,"_startTarget",null);a(this,"_onBeforeUpdateDrag",()=>({}));a(this,"isDragging",!1);this._instance=e,this._options=t||{},this._viewName=s}beforeUpdateGhost(e){this._onBeforeUpdateDrag=e}async _dragStart(e,t,s="rml_id"){this._startTarget&&(this._startTarget.style.pointerEvents="none",this._startTarget.style.userSelect="none",this._startTarget.setAttribute(W,this._startTarget.draggable.toString()),this._startTarget.draggable=!1,this._startTarget.removeEventListener("dragstart",X),this._startTarget.addEventListener("dragstart",X)),this._currentBb=await this._instance.getBoundingClientRect(qt(this._viewName));const{clientX:n,clientY:i}=I(t),o=this._currentBb.x+n,c=this._currentBb.y+i;this.isDragging=!0,this._instance.dragInObject(e,o,c,s)}_dragUpdate(e){if(document.body.focus(),this._currentCustomDrag&&this._currentCustomDrag.onMove(e),!this._currentBb||!this.isDragging)return;const{clientX:t,clientY:s}=I(e),{url:n,width:i,height:o}=Qt(this._startTarget),c=this._currentBb.x+t,l=this._currentBb.y+s,u=this._options||{},h={ghost:{visibleIn:{x:this._currentBb.x-(u.dragInOverlapX||0),y:this._currentBb.y+(u.dragInOverlapY||0),width:this._currentBb.width+(u.dragInOverlapX||0),height:this._currentBb.height+(u.dragInOverlapY||0)},url:n,width:i,height:o},mode:"custom-view"},{x:d,y:g,options:f}=this._onBeforeUpdateDrag(c,l,h),S=typeof d=="number"?d:c,E=typeof g=="number"?g:l,y=f||h;this._instance.updateDrag(S,E,y)}_dragEnd(){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._currentCustomDrag=null,this.isDragging=!1,this._currentBb=null,this._resetStartTarget(),this._instance.enableEvents(),this._instance.dragInObjectEnd()}dragStart(e,t,s){this._instance.disableEvents(),this._startTarget=t.target;const n=(i,o)=>{this._dragStart(e,o,s)};this._currentCustomDrag=T(t)?new gt(jt,{onTouchDragStart:n},ft(t,this._options)):new Jt({onCustomDragStart:i=>this._dragStart(e,i,s)},ft(t,this._options)),this._currentCustomDrag.onStart(t)}dragEnd(){this._dragEnd()}dragUpdate(e){this._dragUpdate(e)}touchStart(e,t,s="rml_id"){this.dragStart(e,t,s)}touchMove(e){this.dragUpdate(e)}touchEnd(){this.dragEnd()}dispose(){}_resetStartTarget(){this._startTarget&&(this._startTarget.style.pointerEvents="",this._startTarget.style.userSelect="",this._startTarget.draggable=this._startTarget.getAttribute(W)==="true",this._startTarget.removeAttribute(W),this._startTarget.removeEventListener("dragstart",X))}releaseInput(e){this._currentCustomDrag&&this._currentCustomDrag.onEnd(),this._resetStartTarget()}}const te=Object.freeze(Object.defineProperty({__proto__:null,DragInFromCustomViewStrategy:Zt},Symbol.toStringTag,{value:"Module"}));return Gt});
|