@roomle/embedding-lib 5.34.0-debug.1 → 5.34.0-debug.2

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.
Files changed (75) hide show
  1. package/comlink-BAiXCcU9.mjs +258 -0
  2. package/comlink-CmT64Qi3.mjs +1 -0
  3. package/docs/md/web/embedding/CHANGELOG.md +28 -332
  4. package/{drag-in-BEjBh6zz.mjs → embedding-plugins-CjNos83d.mjs} +15 -14
  5. package/embedding-plugins-DePKqSKW.mjs +1 -0
  6. package/embedding-plugins.d.ts +2 -0
  7. package/embedding-plugins.js +13 -0
  8. package/embedding-plugins.min.js +1 -0
  9. package/{from-custom-view-CobBUshK.mjs → from-custom-view-BAiOXktb.mjs} +9 -8
  10. package/from-custom-view-Ch3rb-JF.mjs +1 -0
  11. package/from-website-B-Vh-DVX.mjs +1 -0
  12. package/{from-website-C2cG-X9g.mjs → from-website-BicmMNsE.mjs} +11 -10
  13. package/hi.d.ts +2 -0
  14. package/hi.js +106 -0
  15. package/hi.min.js +1 -0
  16. package/package.json +19 -9
  17. package/packages/embedding-lib/src/connector.d.ts +1 -1
  18. package/packages/embedding-lib/src/embedding-plugins.d.ts +9 -0
  19. package/packages/embedding-lib/src/hi.d.ts +16 -0
  20. package/packages/embedding-lib/src/homag-intelligence/hi-callbacks.d.ts +1 -1
  21. package/packages/embedding-lib/src/homag-intelligence/hi-order-manager.d.ts +3 -0
  22. package/packages/embedding-lib/src/homag-intelligence/hi-requests.d.ts +1 -4
  23. package/packages/embedding-lib/src/homag-intelligence/hi-setup.d.ts +4 -0
  24. package/packages/embedding-lib/src/homag-intelligence/hi-utils.d.ts +1 -0
  25. package/packages/embedding-lib/src/plugins/drag-in.d.ts +1 -1
  26. package/packages/embedding-lib/src/plugins/strategy/from-custom-view.d.ts +1 -1
  27. package/packages/embedding-lib/src/plugins/strategy/from-website.d.ts +1 -1
  28. package/packages/embedding-lib/src/plugins/strategy/types.d.ts +1 -1
  29. package/packages/embedding-lib/src/{embedding-lib.d.ts → roomle-embedding-lib.d.ts} +23 -3
  30. package/packages/embedding-lib/src/utils.d.ts +1 -0
  31. package/roomle-embedding-lib.d.ts +6 -0
  32. package/roomle-embedding-lib.js +587 -0
  33. package/roomle-embedding-lib.min.js +1 -0
  34. package/touch-drag-BzREygxc.mjs +1 -0
  35. package/touch-drag-DWISKgWm.mjs +57 -0
  36. package/utils-D--vltCL.mjs +113 -0
  37. package/utils-uEcN1DUR.mjs +1 -0
  38. package/drag-in-BmoiEqfA.mjs +0 -1
  39. package/from-custom-view-fYea37BE.mjs +0 -1
  40. package/from-website-CDEUbvDF.mjs +0 -1
  41. package/index.d.ts +0 -4
  42. package/packages/embedding-lib/src/example.d.ts +0 -5
  43. package/packages/embedding-lib/src/examples/activate-deactivate-rd.d.ts +0 -7
  44. package/packages/embedding-lib/src/examples/api-false.d.ts +0 -7
  45. package/packages/embedding-lib/src/examples/configurator-only.d.ts +0 -6
  46. package/packages/embedding-lib/src/examples/download-partlist.d.ts +0 -6
  47. package/packages/embedding-lib/src/examples/drag-in.d.ts +0 -7
  48. package/packages/embedding-lib/src/examples/ext-catalog/ext-catalog-connection.d.ts +0 -1
  49. package/packages/embedding-lib/src/examples/ext-catalog.d.ts +0 -6
  50. package/packages/embedding-lib/src/examples/ext-selection-overlay.d.ts +0 -7
  51. package/packages/embedding-lib/src/examples/hi-single-object-configurator.d.ts +0 -11
  52. package/packages/embedding-lib/src/examples/homag-intelligence-catalog-example.d.ts +0 -11
  53. package/packages/embedding-lib/src/examples/homag-intelligence-catalog-load-async.d.ts +0 -13
  54. package/packages/embedding-lib/src/examples/homag-intelligence-example.d.ts +0 -19
  55. package/packages/embedding-lib/src/examples/planner-and-configurator.d.ts +0 -6
  56. package/packages/embedding-lib/src/examples/start-and-end-configurator.d.ts +0 -6
  57. package/packages/embedding-lib/src/examples/utils/api-false/helpers.d.ts +0 -2
  58. package/packages/embedding-lib/src/examples/utils/drag-listeners.d.ts +0 -3
  59. package/packages/embedding-lib/src/examples/utils/homag-intelligence/create-catalog.d.ts +0 -3
  60. package/packages/embedding-lib/src/examples/utils/homag-intelligence/default-api-options.d.ts +0 -21
  61. package/packages/embedding-lib/src/examples/utils/homag-intelligence/dom-helper.d.ts +0 -12
  62. package/packages/embedding-lib/src/examples/utils/homag-intelligence/drag-in.d.ts +0 -3
  63. package/packages/embedding-lib/src/examples/utils/homag-intelligence/nobilia-api-options.d.ts +0 -38
  64. package/packages/embedding-lib/src/examples/utils/homag-intelligence/overlay.d.ts +0 -2
  65. package/packages/embedding-lib/src/examples/utils/homag-intelligence/state.d.ts +0 -20
  66. package/packages/embedding-lib/src/examples/utils/homag-intelligence/utils.d.ts +0 -18
  67. package/packages/embedding-lib/src/examples/utils/query-params.d.ts +0 -1
  68. package/packages/embedding-lib/src/examples/utils/server-url.d.ts +0 -1
  69. package/packages/embedding-lib/src/overview.d.ts +0 -1
  70. package/roomle-embedding-lib.es.js +0 -833
  71. package/roomle-embedding-lib.es.min.js +0 -1
  72. package/roomle-embedding-lib.umd.js +0 -21
  73. package/roomle-embedding-lib.umd.min.js +0 -1
  74. package/touch-drag-B5zCf87J.mjs +0 -1
  75. package/touch-drag-DXJTOrk5.mjs +0 -146
@@ -1,833 +0,0 @@
1
- class H {
2
- _side;
3
- // for better debugging (who handles message? iframe or website?)
4
- _incomingMessageBus = null;
5
- _outgoingMessageBus = null;
6
- _execMessage = null;
7
- constructor(t, s, r, n) {
8
- this._side = t, this._incomingMessageBus = s, this._outgoingMessageBus = r, this._execMessage = n, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
9
- "message",
10
- this._handleMessage.bind(this)
11
- );
12
- }
13
- setOutgoingMessageBus(t) {
14
- this._outgoingMessageBus = t;
15
- }
16
- setMessageExecution(t) {
17
- this._execMessage = t;
18
- }
19
- sendMessage(t, s = []) {
20
- return new Promise((r, n) => {
21
- if (this._incomingMessageBus === this._outgoingMessageBus)
22
- return r(void 0);
23
- const o = new MessageChannel();
24
- o.port1.onmessage = (i) => {
25
- if (!i || !i.data)
26
- return o.port1.close(), o.port2.close(), n(
27
- new Error(
28
- this._side + " received message but response can not be interpreted"
29
- )
30
- );
31
- let c;
32
- try {
33
- c = JSON.parse(i.data);
34
- } catch (l) {
35
- return o.port1.close(), o.port2.close(), this._prepareError(l), n(l);
36
- }
37
- c.error ? n(c.error) : c.result !== void 0 ? r(c.result) : r(void 0), o.port1.close(), o.port2.close();
38
- };
39
- let a = "";
40
- try {
41
- a = JSON.stringify({ message: t, args: s });
42
- } catch {
43
- return n(
44
- new Error(
45
- this._side + ": can not create command because it is not JSON.stringify able"
46
- )
47
- );
48
- }
49
- if (!this._outgoingMessageBus)
50
- return n(new Error(this._side + ": outgoing bus not set yet"));
51
- this._outgoingMessageBus.postMessage(a, "*", [
52
- o.port2
53
- ]);
54
- });
55
- }
56
- _handleMessage(t) {
57
- const s = t.ports && Array.isArray(t.ports) && t.ports.length > 0 ? t.ports[0] : null;
58
- if (t.data && (typeof t.data == "string" || t.data.type !== "connect_hi") && s)
59
- try {
60
- const r = JSON.parse(t.data);
61
- if (!this._execMessage)
62
- return s.postMessage(
63
- JSON.stringify({
64
- error: this._side + " is not ready to handle messages"
65
- })
66
- );
67
- Array.isArray(r.args) || (r.args = [r.args]);
68
- const n = this._execMessage(r, t);
69
- if (n === void 0)
70
- return;
71
- n.then(
72
- (o = {}) => {
73
- let a, i;
74
- typeof o == "object" && o !== null && (a = o.error, i = o.result), a ? s.postMessage(
75
- JSON.stringify({ error: a })
76
- ) : i !== void 0 ? s.postMessage(
77
- JSON.stringify({ result: i })
78
- ) : s.postMessage(
79
- JSON.stringify({ result: o })
80
- );
81
- },
82
- (o) => {
83
- s.postMessage(
84
- JSON.stringify({
85
- error: this._prepareError(o)
86
- })
87
- );
88
- }
89
- );
90
- } catch (r) {
91
- s.postMessage(
92
- JSON.stringify({
93
- error: this._prepareError(r)
94
- })
95
- );
96
- }
97
- }
98
- _prepareError(t) {
99
- if (typeof t == "string") {
100
- const s = this._side + ": " + t;
101
- return console.error(s), s;
102
- }
103
- return t.message = this._side + ": " + t.message, console.error(t), t.message;
104
- }
105
- }
106
- /**
107
- * @license
108
- * Copyright 2019 Google LLC
109
- * SPDX-License-Identifier: Apache-2.0
110
- */
111
- const W = Symbol("Comlink.proxy"), X = Symbol("Comlink.endpoint"), j = Symbol("Comlink.releaseProxy"), S = Symbol("Comlink.finalizer"), w = Symbol("Comlink.thrown"), G = (e) => typeof e == "object" && e !== null || typeof e == "function", Z = {
112
- canHandle: (e) => G(e) && e[W],
113
- serialize(e) {
114
- const { port1: t, port2: s } = new MessageChannel();
115
- return P(e, t), [s, [s]];
116
- },
117
- deserialize(e) {
118
- return e.start(), re(e);
119
- }
120
- }, ee = {
121
- canHandle: (e) => G(e) && w in e,
122
- serialize({ value: e }) {
123
- let t;
124
- return e instanceof Error ? t = {
125
- isError: !0,
126
- value: {
127
- message: e.message,
128
- name: e.name,
129
- stack: e.stack
130
- }
131
- } : t = { isError: !1, value: e }, [t, []];
132
- },
133
- deserialize(e) {
134
- throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
135
- }
136
- }, z = /* @__PURE__ */ new Map([
137
- ["proxy", Z],
138
- ["throw", ee]
139
- ]);
140
- function te(e, t) {
141
- for (const s of e)
142
- if (t === s || s === "*" || s instanceof RegExp && s.test(t))
143
- return !0;
144
- return !1;
145
- }
146
- function P(e, t = globalThis, s = ["*"]) {
147
- t.addEventListener("message", function r(n) {
148
- if (!n || !n.data)
149
- return;
150
- if (!te(s, n.origin)) {
151
- console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
152
- return;
153
- }
154
- const { id: o, type: a, path: i } = Object.assign({ path: [] }, n.data), c = (n.data.argumentList || []).map(m);
155
- let l;
156
- try {
157
- const u = i.slice(0, -1).reduce((d, h) => d[h], e), g = i.reduce((d, h) => d[h], e);
158
- switch (a) {
159
- case "GET":
160
- l = g;
161
- break;
162
- case "SET":
163
- u[i.slice(-1)[0]] = m(n.data.value), l = !0;
164
- break;
165
- case "APPLY":
166
- l = g.apply(u, c);
167
- break;
168
- case "CONSTRUCT":
169
- {
170
- const d = new g(...c);
171
- l = ce(d);
172
- }
173
- break;
174
- case "ENDPOINT":
175
- {
176
- const { port1: d, port2: h } = new MessageChannel();
177
- P(e, h), l = ae(d, [d]);
178
- }
179
- break;
180
- case "RELEASE":
181
- l = void 0;
182
- break;
183
- default:
184
- return;
185
- }
186
- } catch (u) {
187
- l = { value: u, [w]: 0 };
188
- }
189
- Promise.resolve(l).catch((u) => ({ value: u, [w]: 0 })).then((u) => {
190
- const [g, d] = M(u);
191
- t.postMessage(Object.assign(Object.assign({}, g), { id: o }), d), a === "RELEASE" && (t.removeEventListener("message", r), V(t), S in e && typeof e[S] == "function" && e[S]());
192
- }).catch((u) => {
193
- const [g, d] = M({
194
- value: new TypeError("Unserializable return value"),
195
- [w]: 0
196
- });
197
- t.postMessage(Object.assign(Object.assign({}, g), { id: o }), d);
198
- });
199
- }), t.start && t.start();
200
- }
201
- function se(e) {
202
- return e.constructor.name === "MessagePort";
203
- }
204
- function V(e) {
205
- se(e) && e.close();
206
- }
207
- function re(e, t) {
208
- const s = /* @__PURE__ */ new Map();
209
- return e.addEventListener("message", function(n) {
210
- const { data: o } = n;
211
- if (!o || !o.id)
212
- return;
213
- const a = s.get(o.id);
214
- if (a)
215
- try {
216
- a(o);
217
- } finally {
218
- s.delete(o.id);
219
- }
220
- }), A(e, s, [], t);
221
- }
222
- function _(e) {
223
- if (e)
224
- throw new Error("Proxy has been released and is not useable");
225
- }
226
- function J(e) {
227
- return p(e, /* @__PURE__ */ new Map(), {
228
- type: "RELEASE"
229
- }).then(() => {
230
- V(e);
231
- });
232
- }
233
- const y = /* @__PURE__ */ new WeakMap(), O = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
234
- const t = (y.get(e) || 0) - 1;
235
- y.set(e, t), t === 0 && J(e);
236
- });
237
- function ne(e, t) {
238
- const s = (y.get(t) || 0) + 1;
239
- y.set(t, s), O && O.register(e, t, e);
240
- }
241
- function oe(e) {
242
- O && O.unregister(e);
243
- }
244
- function A(e, t, s = [], r = function() {
245
- }) {
246
- let n = !1;
247
- const o = new Proxy(r, {
248
- get(a, i) {
249
- if (_(n), i === j)
250
- return () => {
251
- oe(o), J(e), t.clear(), n = !0;
252
- };
253
- if (i === "then") {
254
- if (s.length === 0)
255
- return { then: () => o };
256
- const c = p(e, t, {
257
- type: "GET",
258
- path: s.map((l) => l.toString())
259
- }).then(m);
260
- return c.then.bind(c);
261
- }
262
- return A(e, t, [...s, i]);
263
- },
264
- set(a, i, c) {
265
- _(n);
266
- const [l, u] = M(c);
267
- return p(e, t, {
268
- type: "SET",
269
- path: [...s, i].map((g) => g.toString()),
270
- value: l
271
- }, u).then(m);
272
- },
273
- apply(a, i, c) {
274
- _(n);
275
- const l = s[s.length - 1];
276
- if (l === X)
277
- return p(e, t, {
278
- type: "ENDPOINT"
279
- }).then(m);
280
- if (l === "bind")
281
- return A(e, t, s.slice(0, -1));
282
- const [u, g] = v(c);
283
- return p(e, t, {
284
- type: "APPLY",
285
- path: s.map((d) => d.toString()),
286
- argumentList: u
287
- }, g).then(m);
288
- },
289
- construct(a, i) {
290
- _(n);
291
- const [c, l] = v(i);
292
- return p(e, t, {
293
- type: "CONSTRUCT",
294
- path: s.map((u) => u.toString()),
295
- argumentList: c
296
- }, l).then(m);
297
- }
298
- });
299
- return ne(o, e), o;
300
- }
301
- function ie(e) {
302
- return Array.prototype.concat.apply([], e);
303
- }
304
- function v(e) {
305
- const t = e.map(M);
306
- return [t.map((s) => s[0]), ie(t.map((s) => s[1]))];
307
- }
308
- const $ = /* @__PURE__ */ new WeakMap();
309
- function ae(e, t) {
310
- return $.set(e, t), e;
311
- }
312
- function ce(e) {
313
- return Object.assign(e, { [W]: !0 });
314
- }
315
- function M(e) {
316
- for (const [t, s] of z)
317
- if (s.canHandle(e)) {
318
- const [r, n] = s.serialize(e);
319
- return [
320
- {
321
- type: "HANDLER",
322
- name: t,
323
- value: r
324
- },
325
- n
326
- ];
327
- }
328
- return [
329
- {
330
- type: "RAW",
331
- value: e
332
- },
333
- $.get(e) || []
334
- ];
335
- }
336
- function m(e) {
337
- switch (e.type) {
338
- case "HANDLER":
339
- return z.get(e.name).deserialize(e.value);
340
- case "RAW":
341
- return e.value;
342
- }
343
- }
344
- function p(e, t, s, r) {
345
- return new Promise((n) => {
346
- const o = le();
347
- t.set(o, n), e.start && e.start(), e.postMessage(Object.assign({ id: o }, s), r);
348
- });
349
- }
350
- function le() {
351
- return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
352
- }
353
- const T = ".", R = {
354
- REQUEST_BOOT: "requestBoot",
355
- SETUP: "setup",
356
- WEBSITE_READY: "websiteReady"
357
- }, E = {
358
- GET_METHODS: "getMethods",
359
- RETURN_METHODS: "returnMethods",
360
- REGISTER_CUSTOM_VIEW: "registerCustomView",
361
- REGISTER_CUSTOM_VIEW_DONE: "registerCustomViewDone"
362
- }, ue = async (e, t) => {
363
- if (typeof e != "string")
364
- throw new Error(
365
- 'Configurator ID is not a string type: "' + typeof e + '"'
366
- );
367
- const s = t.customApiUrl ? t.customApiUrl : "https://api.roomle.com/v2", r = t.overrideTenant || 9, n = s + "/configurators/" + e, o = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + o), i = () => {
368
- const g = {
369
- apiKey: o,
370
- currentTenant: r,
371
- locale: "en",
372
- language: "en",
373
- device: 1,
374
- token: a,
375
- platform: "web"
376
- };
377
- return new Headers(g);
378
- }, c = new Request(n, {
379
- method: "GET",
380
- headers: i(),
381
- mode: "cors",
382
- cache: "default"
383
- }), l = await fetch(c), { configurator: u } = await l.json();
384
- return u;
385
- }, ge = () => {
386
- try {
387
- return window.self !== window.top;
388
- } catch {
389
- return !0;
390
- }
391
- }, de = ["127.0.0.1", "localhost", "0.0.0.0"], fe = () => {
392
- const e = ge();
393
- let t = window.location.href;
394
- if (e) {
395
- if (!document.referrer)
396
- return null;
397
- t = document.referrer;
398
- }
399
- const { hostname: s } = new URL(t);
400
- return s;
401
- }, he = (e) => !!(de.includes(e) || e.endsWith("roomle.com") || e.endsWith("gitlab.io") || e.endsWith("gitlab.com")), C = [
402
- "language",
403
- "browserLanguage",
404
- "userLanguage",
405
- "systemLanguage"
406
- ], me = (e = null) => {
407
- const t = window.navigator;
408
- if (e)
409
- return e.substr(0, 2);
410
- if (Array.isArray(t.languages) && t.languages.length > 0)
411
- return t.languages[0].substr(0, 2);
412
- for (let s = 0, r = C.length; s < r; s++) {
413
- const n = t[C[s]];
414
- if (n)
415
- return n.substr(0, 2);
416
- }
417
- return "en";
418
- }, pe = (e, t) => {
419
- const s = JSON.parse(JSON.stringify(e));
420
- return L(s, t);
421
- }, L = (e, t) => {
422
- for (const s in t)
423
- try {
424
- t[s].constructor === Object ? e[s] = L(e[s], t[s]) : e[s] = t[s];
425
- } catch {
426
- e[s] = t[s];
427
- }
428
- return e;
429
- };
430
- var Y = /* @__PURE__ */ ((e) => (e.BOTTOM_BAR = "bottom_bar", e.PARTLIST_BOUNDS = "partlist_bounds", e.INTERACTION_NOTES = "interaction_notes", e.PARAMETER_GROUPS = "parameter_groups", e))(Y || {});
431
- const _e = (e) => JSON.parse(JSON.stringify(e)), Ee = {
432
- mobileLandscape: !0,
433
- floorMaterialRootTag: "materials_root",
434
- buttons: {
435
- renderimage: !0,
436
- requestproduct: !0,
437
- requestplan: !0,
438
- load_product: !0,
439
- partlist_print: !0
440
- },
441
- elements: {
442
- [Y.INTERACTION_NOTES]: !0
443
- },
444
- helpcenter: {
445
- roomdesigner: !0,
446
- configurator: !1,
447
- disable: !1
448
- },
449
- firstPersonView: !0,
450
- saveToIdb: !0,
451
- featureFlags: {
452
- mocAr: !0,
453
- wallAutoHeight: !1,
454
- openCloseAnimation: !0,
455
- enableTwoLevelCatalog: !1,
456
- webGpu: !1
457
- },
458
- rotationSnapDegrees: 10,
459
- interactionsCollapsed: !1
460
- }, we = "(idle)", ye = (e) => (I(e), e?.customApiUrl && (e.customApiUrl = decodeURIComponent(e.customApiUrl)), e.shareUrl && (e.deeplink = e.shareUrl.replace(
461
- Se,
462
- Te
463
- )), e), I = (e) => {
464
- if (!e)
465
- return;
466
- const t = Object.keys(e);
467
- for (const s of t) {
468
- const r = e[s];
469
- if (!Array.isArray(r) && typeof r == "object" && r !== null && I(r), Array.isArray(r))
470
- for (const n of r)
471
- I(n);
472
- (r === "true" || r === "false") && (e[s] = r === "true");
473
- }
474
- }, Oe = (e, t) => {
475
- t.configuratorId = e.id;
476
- const s = e.settings || {};
477
- return !t.overrideTenant && e.tenant && (t.overrideTenant = e.tenant), pe(s, t);
478
- }, Me = () => {
479
- const e = _e(Ee);
480
- e.locale || (e.locale = me()), e.id === we && delete e.id;
481
- const t = fe();
482
- return t && he(t) && (e.configuratorId = "demoConfigurator"), e.customApiUrl = void 0, e.emails = !1, e;
483
- }, Se = "<CONF_ID>", Te = "#CONFIGURATIONID#", Re = (e) => {
484
- 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);
485
- }, x = () => /(android)/i.test(navigator.userAgent);
486
- class D {
487
- _messageHandler = null;
488
- isSetupDone = !1;
489
- viewName = "main";
490
- plugins = {};
491
- pluginsLoaded = [];
492
- ui = {
493
- callbacks: null
494
- };
495
- extended = {
496
- callbacks: null
497
- };
498
- configurator = {
499
- callbacks: null
500
- };
501
- analytics = {
502
- callbacks: {}
503
- };
504
- rapi = {
505
- callbacks: {}
506
- };
507
- global = {
508
- callbacks: {}
509
- };
510
- setMessageHandler(t) {
511
- this._messageHandler = t;
512
- }
513
- handleSetup(t) {
514
- const { methods: s, callbacks: r } = t;
515
- s.forEach((n) => {
516
- const o = n.split(T), a = o[0], i = o[1];
517
- this[a] || (this[a] = {}), this[a][i] = (function() {
518
- if (!this._messageHandler) {
519
- console.error("MessageHandler not set");
520
- return;
521
- }
522
- return this._messageHandler.sendMessage(n, [...arguments]);
523
- }).bind(this);
524
- }), r.forEach((n) => {
525
- const o = n.split(T), a = o[0], i = o[1], c = o[2];
526
- this[a] || (this[a] = {}), this[a][i] || (this[a][i] = {}), this[a][i][c] = () => {
527
- };
528
- }), this.isSetupDone = !0;
529
- }
530
- executeMessage({ message: t, args: s }) {
531
- const r = t.split(T), n = r[0], o = r[1], a = r.length === 3 ? r[2] : null;
532
- if (a && this[n][o][a]) {
533
- const i = this[n][o][a](
534
- ...s
535
- );
536
- return i instanceof Promise ? i.then((c) => ({ result: c })) : i !== void 0 ? Promise.resolve({ result: i }) : Promise.resolve({ result: null });
537
- }
538
- return Promise.reject('Message "' + t + '" is unkown');
539
- }
540
- setupPlugins(t, s, r = "website") {
541
- for (const n of t)
542
- typeof n == "string" && n === "dragIn" ? this.pluginsLoaded.push(
543
- new Promise((o, a) => {
544
- try {
545
- import("./drag-in-BEjBh6zz.mjs").then((i) => i.l).then(
546
- ({ DragIn: i }) => {
547
- const c = new i(
548
- this.ui,
549
- s,
550
- r,
551
- this.viewName
552
- );
553
- c.init().then(() => {
554
- this.plugins.dragIn = c, o();
555
- }, a);
556
- }
557
- );
558
- } catch (i) {
559
- a(i);
560
- }
561
- })
562
- ) : n.name && n.loader && this.pluginsLoaded.push(
563
- new Promise((o, a) => {
564
- try {
565
- n.loader().then((i) => {
566
- const c = new i(
567
- this.ui,
568
- s,
569
- r,
570
- this.viewName
571
- );
572
- c.init().then(() => {
573
- this.plugins[n.name] = c, o();
574
- }, a);
575
- });
576
- } catch (i) {
577
- a(i);
578
- }
579
- })
580
- );
581
- }
582
- }
583
- const k = () => {
584
- let e, t;
585
- return { promise: new Promise((r, n) => {
586
- e = r, t = n;
587
- }), resolve: e, reject: t };
588
- }, F = (e, t, s) => {
589
- let r = null;
590
- Object.defineProperty(e, t, {
591
- get() {
592
- return r || s;
593
- },
594
- set(n) {
595
- n?.mute ? r = n.value : (console.warn(
596
- "You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"
597
- ), console.warn("{ mute: true, value: () => void }"), r = n);
598
- }
599
- });
600
- }, q = () => window.innerHeight * 0.01 + "px", U = (e) => {
601
- e && setTimeout(
602
- () => e.style.setProperty(N, q()),
603
- 0
604
- );
605
- }, B = "rml-styles", be = 450, N = "--rml-full-height", f = {
606
- CONTAINER: "rml-container",
607
- FILL: "rml-fill",
608
- POSITION: "rml-pos",
609
- TRANSITION: "rml-transition",
610
- ANDROID_HEIGHT: "rml-android-height",
611
- OVERFLOW_HIDDEN: "rml-overflow-hidden"
612
- }, b = /* @__PURE__ */ new Map(), Ae = (e) => {
613
- const t = {
614
- /**
615
- * The 'get' trap is fired when a property is accessed on the proxy.
616
- * @param target The original object.
617
- * @param prop The name of the property being accessed.
618
- * @param receiver The proxy or an object that inherits from it.
619
- */
620
- get(s, r, n) {
621
- const o = Reflect.get(s, r, n);
622
- return o !== void 0 ? o : (console.warn(
623
- `[Homag Intelligence Callbacks] Method '${String(
624
- r
625
- )}' is not implemented. Executing a no-op.`
626
- ), (...a) => {
627
- });
628
- }
629
- };
630
- return new Proxy(e, t);
631
- };
632
- class Ie extends D {
633
- static createPlanner(t, s, r, n = []) {
634
- return this._create(
635
- t,
636
- s,
637
- r,
638
- n
639
- );
640
- }
641
- static async connect(t, s = []) {
642
- const r = new D();
643
- r.viewName = t;
644
- const { resolve: n, promise: o } = k(), { resolve: a, promise: i } = k(), c = ({
645
- message: g,
646
- args: d
647
- }) => {
648
- switch (g) {
649
- case E.REGISTER_CUSTOM_VIEW_DONE:
650
- n();
651
- break;
652
- case E.RETURN_METHODS:
653
- r.handleSetup(d[0]), a();
654
- break;
655
- default:
656
- if (r.isSetupDone)
657
- return r.executeMessage({ message: g, args: d });
658
- }
659
- }, l = new H(
660
- "custom-view-" + t,
661
- window,
662
- window.parent,
663
- c
664
- );
665
- r.setMessageHandler(l);
666
- const u = [t];
667
- return l.sendMessage(
668
- E.REGISTER_CUSTOM_VIEW,
669
- u
670
- ), await o, l.sendMessage(E.GET_METHODS, u), await i, r.setupPlugins(
671
- s,
672
- document.body,
673
- "custom-view"
674
- ), await Promise.allSettled(r.pluginsLoaded), r;
675
- }
676
- /**
677
- * Method to create a new instance of a Roomle Configurator
678
- * @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
679
- * @param container DOM container in which the configurator should be placed
680
- * @param initData settings with which the configurator should be started
681
- */
682
- static createConfigurator(t, s, r, n = []) {
683
- return this._create(
684
- t,
685
- s,
686
- r,
687
- n
688
- );
689
- }
690
- /**
691
- * Method to create a new instance of a Roomle Configurator
692
- * @deprecated please use "createConfigurator"
693
- * @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
694
- * @param container DOM container in which the configurator should be placed
695
- * @param initData settings with which the configurator should be started
696
- */
697
- static create(t, s, r, n) {
698
- return this._create(
699
- t,
700
- s,
701
- r,
702
- n
703
- );
704
- }
705
- /**
706
- * Method to create a new instance of a Roomle Viewer
707
- * @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
708
- * @param container DOM container in which the configurator should be placed
709
- * @param initData settings with which the configurator should be started
710
- */
711
- static createViewer(t, s, r, n = []) {
712
- return this._create(
713
- t,
714
- s,
715
- r,
716
- n
717
- );
718
- }
719
- static hiMessageHandler = null;
720
- static setupHi(t) {
721
- this.hiMessageHandler && window.removeEventListener("message", this.hiMessageHandler), this.hiMessageHandler = (s) => {
722
- if (s.data.type === "connect_hi" && s.data.port) {
723
- const r = s.data.port;
724
- r.start?.(), P(Ae(t), r);
725
- }
726
- }, window.addEventListener("message", this.hiMessageHandler);
727
- }
728
- static async _create(t, s, r, n) {
729
- return new Promise(async (o, a) => {
730
- try {
731
- const i = L(
732
- Me(),
733
- ye(r)
734
- );
735
- Re(i);
736
- const c = await ue(
737
- t,
738
- i
739
- );
740
- r = Oe(c, i);
741
- const l = new this(
742
- c,
743
- s,
744
- r,
745
- n,
746
- o
747
- );
748
- return await Promise.allSettled(l.pluginsLoaded), l;
749
- } catch (i) {
750
- return a(i);
751
- }
752
- });
753
- }
754
- _waitForIframe;
755
- _container;
756
- _configuratorSettings;
757
- _initData = {};
758
- _iframe;
759
- constructor(t, s, r, n, o) {
760
- if (super(), !t || typeof t.id != "string")
761
- throw new Error(
762
- "Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person"
763
- );
764
- if (b.has(s))
765
- throw new Error("There is already an instance on this DOM element");
766
- if (!!!document.getElementById(B)) {
767
- const l = r.zIndex || 9999999, u = document.createElement("style");
768
- u.type = "text/css", u.id = B;
769
- const g = "transition:all ease-in-out " + be + "ms;", d = ["-webkit-", "-o-"].reduce(
770
- (K, Q) => K += Q + g,
771
- ""
772
- ) + g, h = q();
773
- u.innerHTML = `
774
- .${f.CONTAINER}{${N}:${h};}
775
- .${f.POSITION}{position:fixed;top:0;left:0;z-index:${l};opacity:0}
776
- .${f.TRANSITION}{${d}}
777
- .${f.FILL}{width:100%;height:100%;opacity:1}
778
- .${f.ANDROID_HEIGHT}{height:calc(var(${N},1vh)*100)}
779
- .${f.OVERFLOW_HIDDEN}{overflow:hidden}
780
- `, document.head.appendChild(u);
781
- }
782
- this._executeMessage = this._executeMessage.bind(this);
783
- const i = new H(
784
- "website",
785
- window,
786
- null,
787
- this._executeMessage
788
- );
789
- this.setMessageHandler(i), this._onResize = this._onResize.bind(this), x() && window.addEventListener("resize", this._onResize), this._container = s, this._initData = r, this._configuratorSettings = t;
790
- const c = this._createIframe();
791
- this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = o, this._container.appendChild(c), this._iframe = c, this.setupPlugins(n, this._iframe), b.set(s, !0);
792
- }
793
- teardown() {
794
- this._container && b.delete(this._container);
795
- const t = this._container.querySelector("iframe");
796
- t && this._container.removeChild(t), window.removeEventListener("resize", this._onResize);
797
- }
798
- _createIframe() {
799
- const t = document.createElement("iframe");
800
- let s = this._configuratorSettings?.url || "https://www.roomle.com/t/cp/";
801
- 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(f.CONTAINER), t.classList.add(f.FILL), t;
802
- }
803
- _onResize() {
804
- U(this._iframe);
805
- }
806
- _onUseFullPage() {
807
- this._iframe.classList.add(f.POSITION), document.documentElement.classList.add(f.OVERFLOW_HIDDEN), window.document.body.classList.add(f.OVERFLOW_HIDDEN), x() && (U(this._iframe), this._iframe.classList.add(f.ANDROID_HEIGHT));
808
- }
809
- _onBackToWebsite() {
810
- this._iframe.classList.remove(f.POSITION), this._iframe.classList.remove(f.ANDROID_HEIGHT), document.documentElement.classList.remove(f.OVERFLOW_HIDDEN), window.document.body.classList.remove(f.OVERFLOW_HIDDEN);
811
- }
812
- _executeMessage({ message: t, args: s }, r) {
813
- if (r.source && r.source === this._iframe?.contentWindow)
814
- return t === R.REQUEST_BOOT ? this._messageHandler ? (this._messageHandler.setOutgoingMessageBus(r.source), Promise.resolve({ result: this._initData })) : (console.error("MessageHandler not set"), Promise.resolve({ error: "MessageHandler not set" })) : t === R.SETUP ? (this.handleSetup(s[0]), F(
815
- this.ui.callbacks,
816
- "onUseFullPage",
817
- this._onUseFullPage
818
- ), F(
819
- this.ui.callbacks,
820
- "onBackToWebsite",
821
- this._onBackToWebsite
822
- ), this._waitForIframe(this), setTimeout(() => {
823
- if (!this._messageHandler) {
824
- console.error("MessageHandler not set");
825
- return;
826
- }
827
- this._messageHandler.sendMessage(R.WEBSITE_READY);
828
- }, 0), Promise.resolve({ result: null })) : this.executeMessage({ message: t, args: s });
829
- }
830
- }
831
- export {
832
- Ie as default
833
- };