@roomle/embedding-lib 5.26.0-alpha.2 → 5.26.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/docs/md/web/embedding/CHANGELOG.md +10 -5
  2. package/{drag-in-DuufO5eB.mjs → drag-in-BEjBh6zz.mjs} +2 -2
  3. package/{drag-in-DTA1FCDc.mjs → drag-in-BmoiEqfA.mjs} +1 -1
  4. package/{from-custom-view-BdnViEhf.mjs → from-custom-view-CobBUshK.mjs} +3 -3
  5. package/from-custom-view-fYea37BE.mjs +1 -0
  6. package/{from-website-CktA6Icy.mjs → from-website-C2cG-X9g.mjs} +1 -1
  7. package/{from-website-CcDHgCCy.mjs → from-website-CDEUbvDF.mjs} +1 -1
  8. package/package.json +1 -1
  9. package/packages/embedding-lib/src/examples/utils/homag-intelligence/nobilia-api-options.d.ts +45 -0
  10. package/packages/embedding-lib/src/examples/utils/homag-intelligence/state.d.ts +11 -5
  11. package/packages/embedding-lib/src/plugins/strategy/from-custom-view.d.ts +1 -1
  12. package/packages/web-sdk/packages/common-core/mock/mock-draco-loader.d.ts +1 -1
  13. package/packages/web-sdk/packages/common-core/mock/mock-idb-manager.d.ts +2 -2
  14. package/packages/web-sdk/packages/common-core/mock/mock-image-renderer.d.ts +2 -2
  15. package/packages/web-sdk/packages/common-core/mock/mock-input-event-dispatcher.d.ts +1 -1
  16. package/packages/web-sdk/packages/common-core/src/configurator-kernel-access.d.ts +2 -2
  17. package/packages/web-sdk/packages/common-core/src/main.d.ts +1 -2
  18. package/packages/web-sdk/packages/common-core/src/rapi-access.d.ts +6 -5
  19. package/packages/web-sdk/packages/common-core/src/services/hdr-environment-loader.d.ts +1 -1
  20. package/packages/web-sdk/packages/common-core/src/utils/enumerable.d.ts +1 -1
  21. package/packages/web-sdk/packages/common-core/src/utils/threejs-utils.d.ts +1 -1
  22. package/packages/web-sdk/packages/common-core/src/utils/ui-callback.d.ts +1 -1
  23. package/packages/web-sdk/packages/common-core/src/view-model/configurator-view-model.d.ts +1 -1
  24. package/packages/web-sdk/packages/common-core/src/webgl/renderer/pass/ao-pass.d.ts +1 -1
  25. package/packages/web-sdk/packages/common-core/src/webgl/renderer/render-pass-manager.d.ts +1 -1
  26. package/packages/web-sdk/packages/common-core/src/webgl/scene-manager.d.ts +1 -1
  27. package/packages/web-sdk/packages/configurator-core/src/roomle-configurator.d.ts +10 -10
  28. package/packages/web-sdk/packages/homag-intelligence/src/emulator.d.ts +2 -2
  29. package/packages/web-sdk/packages/homag-intelligence/src/model/oc-scripts-domain.model.d.ts +3 -3
  30. package/packages/web-sdk/packages/homag-intelligence/src/orders.d.ts +1 -1
  31. package/packages/web-sdk/packages/material-viewer/src/roomle-material-viewer.d.ts +1 -1
  32. package/packages/web-sdk/packages/planner-core/src/roomle-planner.d.ts +2 -2
  33. package/packages/web-sdk/packages/planner-core/src/services/planner-kernel-access.d.ts +4 -4
  34. package/packages/web-sdk/packages/planner-core/src/webgl/planner-scene-manager.d.ts +2 -2
  35. package/packages/web-sdk/packages/typings/kernel.d.ts +1 -0
  36. package/packages/web-sdk/packages/typings/rapi-types.d.ts +11 -10
  37. package/roomle-embedding-lib.es.js +80 -79
  38. package/roomle-embedding-lib.es.min.js +1 -1
  39. package/roomle-embedding-lib.umd.js +2 -2
  40. package/roomle-embedding-lib.umd.min.js +1 -1
  41. package/src/common/components/overlays/part-list/partlist-setup.d.ts +2 -1
  42. package/src/common/utils/helper.d.ts +2 -2
  43. package/src/common/utils/ui-actions.d.ts +2 -1
  44. package/src/configurator/business-logic/sdk-connector-configurator.d.ts +2 -1
  45. package/src/configurator/business-logic/sdk-connector.d.ts +2 -2
  46. package/src/configurator/components/grid-view/-utils/CollapsedView.vue.d.ts +14 -14
  47. package/src/configurator/embedding/exposed-api.d.ts +1 -1
  48. package/src/configurator/embedding/exposed-callbacks.d.ts +1 -1
  49. package/src/configurator/embedding/types.d.ts +1 -0
  50. package/src/planner/business-logic/sdk-connector-planner.d.ts +2 -2
  51. package/src/planner/components/catalog/CatalogBreadcrumb.vue.d.ts +18 -0
  52. package/src/planner/components/catalog/CatalogEmptyState.vue.d.ts +10 -0
  53. package/src/planner/components/catalog/CatalogLevels.vue.d.ts +20 -0
  54. package/src/planner/components/catalog/CatalogNavigation.vue.d.ts +42 -0
  55. package/src/planner/components/catalog/CatalogProducts.vue.d.ts +24 -0
  56. package/src/planner/components/catalog/ProductCard.vue.d.ts +14 -0
  57. package/src/planner/components/catalog/ProductGrid.vue.d.ts +14 -0
  58. package/src/planner/components/overlays/RoomSidebar.vue.d.ts +2 -0
  59. package/src/planner/components/overlays/rooms/DoorParametersSetting.vue.d.ts +2 -0
  60. package/src/planner/components/overlays/rooms/WindowParametersSetting.vue.d.ts +2 -0
  61. package/from-custom-view-DIYHP31u.mjs +0 -1
  62. package/packages/web-sdk/packages/configurator-core/src/utils/test-helpers/async-test-helper.d.ts +0 -1
  63. package/src/common/store/common-ui-state.d.ts +0 -1
@@ -48,7 +48,7 @@ export default class PlannerSceneManager extends ConfiguratorSceneManager implem
48
48
  private _configurableItemGuard;
49
49
  private _planCompletelyLoadedGuard;
50
50
  private _dragStartBounds;
51
- currentSelection: SelectionPayload;
51
+ currentSelection: SelectionPayload | null;
52
52
  private _paperBackground;
53
53
  private _cameraState;
54
54
  private _planElementHighlighter;
@@ -122,7 +122,7 @@ export default class PlannerSceneManager extends ConfiguratorSceneManager implem
122
122
  highlightPlanElementById(runtimeId: number | null): void;
123
123
  destroy(): void;
124
124
  planObjectConfigurationLoaded(plan: Plan, element: PlanElement, success: boolean): void;
125
- planObjectConfigurationChanged(plan: Plan, element: PlanElementViewModel): Promise<void>;
125
+ planObjectConfigurationChanged(_plan: Plan, element: PlanElementViewModel): Promise<void>;
126
126
  addMesh(_planElement: PlanElement, _material: any, _vertices: Float32Array, _indices: Int32Array, _uvCoords: Float32Array, _normals: Float32Array): void;
127
127
  updateCameraOnDrawWalls(): void;
128
128
  getBounds(): Box3;
@@ -147,6 +147,7 @@ export interface UiPossibleChild extends RapiElement {
147
147
  isComponent: boolean;
148
148
  group: string;
149
149
  possible: boolean;
150
+ subTags: UiPossibleChild[];
150
151
  }
151
152
  export interface UiPossibleChildTag extends RapiTag {
152
153
  possibleChildren: UiPossibleChild[];
@@ -1,5 +1,6 @@
1
1
  import { Enumify } from '../common-core/src/types';
2
2
  import { InitDataDefinition } from '../common-core/src/utils/shims';
3
+ import { UiPossibleChild } from './kernel';
3
4
 
4
5
  export type RapiId = string;
5
6
  export type AssetUrl = string;
@@ -19,7 +20,7 @@ export interface RoomleSortable {
19
20
  }
20
21
  export interface RapiJsonBox {
21
22
  meta?: RapiMeta;
22
- [key: string]: RapiMeta | RapiJson | RapiJson[];
23
+ [key: string]: RapiMeta | RapiJson | RapiJson[] | undefined;
23
24
  }
24
25
  export interface RapiMeta {
25
26
  serverTime: string;
@@ -30,8 +31,8 @@ export interface RapiJson {
30
31
  id?: RapiId | number;
31
32
  isLocally?: boolean;
32
33
  __rapi_path__?: string;
33
- [key: string]: any;
34
34
  links?: LinksCollection;
35
+ [key: string]: any;
35
36
  }
36
37
  export interface RapiPackage extends RapiJson {
37
38
  components: RapiComponent[];
@@ -82,7 +83,7 @@ export interface RapiMaterialShading {
82
83
  thicknessFactor?: number;
83
84
  attenuationColor?: RapiBaseColor;
84
85
  attenuationDistance?: number;
85
- [key: string]: number | boolean | string | RapiBaseColor;
86
+ [key: string]: number | boolean | string | RapiBaseColor | undefined;
86
87
  }
87
88
  export interface RapiMaterial extends RapiJson {
88
89
  id: RapiId;
@@ -100,7 +101,7 @@ export interface RapiMaterial extends RapiJson {
100
101
  additionalInfos?: AdditionalInfo[];
101
102
  properties?: Record<string, string>;
102
103
  sort?: number;
103
- [key: string]: string | RapiMaterialShading | AssetUrl | RapiId | number[] | AdditionalInfo[] | boolean | number | LinksCollection | RapiId[] | Record<string, string>;
104
+ [key: string]: string | RapiMaterialShading | AssetUrl | RapiId | number[] | AdditionalInfo[] | boolean | number | LinksCollection | RapiId[] | Record<string, string> | undefined;
104
105
  }
105
106
  export interface RapiMaterialGroup extends RapiJson {
106
107
  id: RapiId;
@@ -108,7 +109,7 @@ export interface RapiMaterialGroup extends RapiJson {
108
109
  materials: RapiMaterial[];
109
110
  legacyId?: RapiId;
110
111
  sort?: number;
111
- [key: string]: string | RapiMaterial[] | RapiId | boolean | LinksCollection | number;
112
+ [key: string]: string | RapiMaterial[] | RapiId | boolean | LinksCollection | number | undefined;
112
113
  }
113
114
  export declare const enum RAPI_TEXTURE_TYPE {
114
115
  RGB = "RGB",// diffuse color texture
@@ -132,7 +133,7 @@ export interface RapiTexture extends RapiJson {
132
133
  mmWidth: number;
133
134
  tileable: boolean;
134
135
  material: RapiId;
135
- [key: string]: string | number | boolean | AssetUrl | RapiId | LinksCollection;
136
+ [key: string]: string | number | boolean | AssetUrl | RapiId | LinksCollection | undefined;
136
137
  }
137
138
  export interface RapiCatalog extends RapiJson {
138
139
  id: RapiId;
@@ -165,7 +166,7 @@ export interface RapiCatalog extends RapiJson {
165
166
  allTags: RapiTag[];
166
167
  rootTags: RapiTag[];
167
168
  retailers: RapiRetailer[];
168
- [key: string]: string | number | boolean | RapiRetailer | RapiTag | RapiMaterial | RapiComponent | RapiItem | RapiTenant;
169
+ [key: string]: string | number | boolean | RapiRetailer[] | RapiTag[] | RapiMaterial[] | RapiComponent[] | RapiItem[] | RapiId[] | RapiTenant | LinksCollection | undefined;
169
170
  }
170
171
  export interface RapiTenant extends RapiJson {
171
172
  name: string;
@@ -342,7 +343,7 @@ export interface RapiConfiguration extends RapiJson {
342
343
  depth: number;
343
344
  catalog?: RapiId;
344
345
  assets?: AssetItem;
345
- [key: string]: string | number | boolean | AssetUrl | RapiId | LinksCollection | AssetItem;
346
+ [key: string]: string | number | boolean | AssetUrl | RapiId | LinksCollection | AssetItem | undefined;
346
347
  }
347
348
  export interface RapiConfigurationEnhanced extends RapiConfiguration {
348
349
  label: string;
@@ -357,7 +358,7 @@ export interface RapiElement extends RapiJson, RoomleSortable, Element {
357
358
  configuration?: ConfigurationString;
358
359
  externalIdentifier: string;
359
360
  tags: RapiId[];
360
- [key: string]: string | number | boolean | AssetUrl | RapiId | RapiId[] | LinksCollection | AdditionalInfo[] | AssetItem;
361
+ [key: string]: string | number | boolean | AssetUrl | RapiId | RapiId[] | LinksCollection | AdditionalInfo[] | UiPossibleChild[] | AssetItem | undefined;
361
362
  }
362
363
  export declare const CATALOG_INFOS_TYPES: {
363
364
  readonly PARAMETER: "parameter";
@@ -457,7 +458,7 @@ export interface RapiTagGeneric extends RapiJson {
457
458
  catalog: RapiId;
458
459
  tags: RapiId[];
459
460
  parents: RapiId[];
460
- [key: string]: string | number | boolean | AssetUrl | RapiId | RapiId[] | RapiElement[] | RapiMaterial[] | LinksCollection;
461
+ [key: string]: string | number | boolean | AssetUrl | RapiId | RapiId[] | RapiElement[] | RapiMaterial[] | LinksCollection | undefined;
461
462
  }
462
463
  export interface RapiTag extends RapiTagGeneric {
463
464
  id: RapiId;
@@ -4,8 +4,8 @@ class S {
4
4
  _incomingMessageBus = null;
5
5
  _outgoingMessageBus = null;
6
6
  _execMessage = null;
7
- constructor(e, t, r, n) {
8
- this._side = e, this._incomingMessageBus = t, this._outgoingMessageBus = r, this._execMessage = n, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
7
+ constructor(e, t, r, o) {
8
+ this._side = e, this._incomingMessageBus = t, this._outgoingMessageBus = r, this._execMessage = o, this._incomingMessageBus && this._incomingMessageBus.addEventListener(
9
9
  "message",
10
10
  this._handleMessage.bind(this)
11
11
  );
@@ -17,37 +17,37 @@ class S {
17
17
  this._execMessage = e;
18
18
  }
19
19
  sendMessage(e, t = []) {
20
- return new Promise((r, n) => {
20
+ return new Promise((r, o) => {
21
21
  if (this._incomingMessageBus === this._outgoingMessageBus)
22
22
  return r(void 0);
23
23
  const i = new MessageChannel();
24
- i.port1.onmessage = (o) => {
25
- if (!o || !o.data)
26
- return i.port1.close(), i.port2.close(), n(
24
+ i.port1.onmessage = (n) => {
25
+ if (!n || !n.data)
26
+ return i.port1.close(), i.port2.close(), o(
27
27
  new Error(
28
28
  this._side + " received message but response can not be interpreted"
29
29
  )
30
30
  );
31
31
  let l;
32
32
  try {
33
- l = JSON.parse(o.data);
33
+ l = JSON.parse(n.data);
34
34
  } catch (u) {
35
- return i.port1.close(), i.port2.close(), this._prepareError(u), n(u);
35
+ return i.port1.close(), i.port2.close(), this._prepareError(u), o(u);
36
36
  }
37
- l.error ? n(l.error) : l.result !== void 0 ? r(l.result) : r(void 0), i.port1.close(), i.port2.close();
37
+ l.error ? o(l.error) : l.result !== void 0 ? r(l.result) : r(void 0), i.port1.close(), i.port2.close();
38
38
  };
39
39
  let a = "";
40
40
  try {
41
41
  a = JSON.stringify({ message: e, args: t });
42
42
  } catch {
43
- return n(
43
+ return o(
44
44
  new Error(
45
45
  this._side + ": can not create command because it is not JSON.stringify able"
46
46
  )
47
47
  );
48
48
  }
49
49
  if (!this._outgoingMessageBus)
50
- return n(new Error(this._side + ": outgoing bus not set yet"));
50
+ return o(new Error(this._side + ": outgoing bus not set yet"));
51
51
  this._outgoingMessageBus.postMessage(a, "*", [
52
52
  i.port2
53
53
  ]);
@@ -65,16 +65,16 @@ class S {
65
65
  })
66
66
  );
67
67
  Array.isArray(r.args) || (r.args = [r.args]);
68
- const n = this._execMessage(r, e);
69
- if (n === void 0)
68
+ const o = this._execMessage(r, e);
69
+ if (o === void 0)
70
70
  return;
71
- n.then(
71
+ o.then(
72
72
  (i = {}) => {
73
- let a, o;
74
- typeof i == "object" && i !== null && (a = i.error, o = i.result), a ? t.postMessage(
73
+ let a, n;
74
+ typeof i == "object" && i !== null && (a = i.error, n = i.result), a ? t.postMessage(
75
75
  JSON.stringify({ error: a })
76
- ) : o !== void 0 ? t.postMessage(
77
- JSON.stringify({ result: o })
76
+ ) : n !== void 0 ? t.postMessage(
77
+ JSON.stringify({ result: n })
78
78
  ) : t.postMessage(
79
79
  JSON.stringify({ result: i })
80
80
  );
@@ -117,7 +117,7 @@ const f = ".", _ = {
117
117
  throw new Error(
118
118
  'Configurator ID is not a string type: "' + typeof s + '"'
119
119
  );
120
- const t = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, n = t + "/configurators/" + s, i = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), o = () => {
120
+ const t = e.customApiUrl ? e.customApiUrl : "https://api.roomle.com/v2", r = e.overrideTenant || 9, o = t + "/configurators/" + s, i = "roomle_portal_v2", a = "03-" + window.btoa((/* @__PURE__ */ new Date()).toISOString() + ";anonymous;" + i), n = () => {
121
121
  const g = {
122
122
  apiKey: i,
123
123
  currentTenant: r,
@@ -128,9 +128,9 @@ const f = ".", _ = {
128
128
  platform: "web"
129
129
  };
130
130
  return new Headers(g);
131
- }, l = new Request(n, {
131
+ }, l = new Request(o, {
132
132
  method: "GET",
133
- headers: o(),
133
+ headers: n(),
134
134
  mode: "cors",
135
135
  cache: "default"
136
136
  }), u = await fetch(l), { configurator: d } = await u.json();
@@ -163,9 +163,9 @@ const f = ".", _ = {
163
163
  if (Array.isArray(e.languages) && e.languages.length > 0)
164
164
  return e.languages[0].substr(0, 2);
165
165
  for (let t = 0, r = T.length; t < r; t++) {
166
- const n = e[T[t]];
167
- if (n)
168
- return n.substr(0, 2);
166
+ const o = e[T[t]];
167
+ if (o)
168
+ return o.substr(0, 2);
169
169
  }
170
170
  return "en";
171
171
  }, x = (s, e) => {
@@ -204,7 +204,8 @@ const k = (s) => JSON.parse(JSON.stringify(s)), G = {
204
204
  featureFlags: {
205
205
  mocAr: !0,
206
206
  wallAutoHeight: !1,
207
- openCloseAnimation: !1
207
+ openCloseAnimation: !1,
208
+ enableTwoLevelCatalog: !1
208
209
  },
209
210
  rotationSnapDegrees: 10,
210
211
  interactionsCollapsed: !1
@@ -218,8 +219,8 @@ const k = (s) => JSON.parse(JSON.stringify(s)), G = {
218
219
  for (const t of e) {
219
220
  const r = s[t];
220
221
  if (!Array.isArray(r) && typeof r == "object" && r !== null && E(r), Array.isArray(r))
221
- for (const n of r)
222
- E(n);
222
+ for (const o of r)
223
+ E(o);
223
224
  (r === "true" || r === "false") && (s[t] = r === "true");
224
225
  }
225
226
  }, $ = (s, e) => {
@@ -263,39 +264,39 @@ class A {
263
264
  }
264
265
  handleSetup(e) {
265
266
  const { methods: t, callbacks: r } = e;
266
- t.forEach((n) => {
267
- const i = n.split(f), a = i[0], o = i[1];
268
- this[a] || (this[a] = {}), this[a][o] = (function() {
267
+ t.forEach((o) => {
268
+ const i = o.split(f), a = i[0], n = i[1];
269
+ this[a] || (this[a] = {}), this[a][n] = (function() {
269
270
  if (!this._messageHandler) {
270
271
  console.error("MessageHandler not set");
271
272
  return;
272
273
  }
273
- return this._messageHandler.sendMessage(n, [...arguments]);
274
+ return this._messageHandler.sendMessage(o, [...arguments]);
274
275
  }).bind(this);
275
- }), r.forEach((n) => {
276
- const i = n.split(f), a = i[0], o = i[1], l = i[2];
277
- this[a] || (this[a] = {}), this[a][o] || (this[a][o] = {}), this[a][o][l] = () => {
276
+ }), r.forEach((o) => {
277
+ const i = o.split(f), a = i[0], n = i[1], l = i[2];
278
+ this[a] || (this[a] = {}), this[a][n] || (this[a][n] = {}), this[a][n][l] = () => {
278
279
  };
279
280
  }), this.isSetupDone = !0;
280
281
  }
281
282
  executeMessage({ message: e, args: t }) {
282
- const r = e.split(f), n = r[0], i = r[1], a = r.length === 3 ? r[2] : null;
283
- if (a && this[n][i][a]) {
284
- const o = this[n][i][a](
283
+ const r = e.split(f), o = r[0], i = r[1], a = r.length === 3 ? r[2] : null;
284
+ if (a && this[o][i][a]) {
285
+ const n = this[o][i][a](
285
286
  ...t
286
287
  );
287
- return o instanceof Promise ? o.then((l) => ({ result: l })) : o !== void 0 ? Promise.resolve({ result: o }) : Promise.resolve({ result: null });
288
+ return n instanceof Promise ? n.then((l) => ({ result: l })) : n !== void 0 ? Promise.resolve({ result: n }) : Promise.resolve({ result: null });
288
289
  }
289
290
  return Promise.reject('Message "' + e + '" is unkown');
290
291
  }
291
292
  setupPlugins(e, t, r = "website") {
292
- for (const n of e)
293
- typeof n == "string" && n === "dragIn" ? this.pluginsLoaded.push(
293
+ for (const o of e)
294
+ typeof o == "string" && o === "dragIn" ? this.pluginsLoaded.push(
294
295
  new Promise((i, a) => {
295
296
  try {
296
- import("./drag-in-DuufO5eB.mjs").then((o) => o.l).then(
297
- ({ DragIn: o }) => {
298
- const l = new o(
297
+ import("./drag-in-BEjBh6zz.mjs").then((n) => n.l).then(
298
+ ({ DragIn: n }) => {
299
+ const l = new n(
299
300
  this.ui,
300
301
  t,
301
302
  r,
@@ -306,26 +307,26 @@ class A {
306
307
  }, a);
307
308
  }
308
309
  );
309
- } catch (o) {
310
- a(o);
310
+ } catch (n) {
311
+ a(n);
311
312
  }
312
313
  })
313
- ) : n.name && n.loader && this.pluginsLoaded.push(
314
+ ) : o.name && o.loader && this.pluginsLoaded.push(
314
315
  new Promise((i, a) => {
315
316
  try {
316
- n.loader().then((o) => {
317
- const l = new o(
317
+ o.loader().then((n) => {
318
+ const l = new n(
318
319
  this.ui,
319
320
  t,
320
321
  r,
321
322
  this.viewName
322
323
  );
323
324
  l.init().then(() => {
324
- this.plugins[n.name] = l, i();
325
+ this.plugins[o.name] = l, i();
325
326
  }, a);
326
327
  });
327
- } catch (o) {
328
- a(o);
328
+ } catch (n) {
329
+ a(n);
329
330
  }
330
331
  })
331
332
  );
@@ -333,8 +334,8 @@ class A {
333
334
  }
334
335
  const M = () => {
335
336
  let s, e;
336
- return { promise: new Promise((r, n) => {
337
- s = r, e = n;
337
+ return { promise: new Promise((r, o) => {
338
+ s = r, e = o;
338
339
  }), resolve: s, reject: e };
339
340
  }, R = (s, e, t) => {
340
341
  let r = null;
@@ -342,10 +343,10 @@ const M = () => {
342
343
  get() {
343
344
  return r || t;
344
345
  },
345
- set(n) {
346
- n?.mute ? r = n.value : (console.warn(
346
+ set(o) {
347
+ o?.mute ? r = o.value : (console.warn(
347
348
  "You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"
348
- ), console.warn("{ mute: true, value: () => void }"), r = n);
349
+ ), console.warn("{ mute: true, value: () => void }"), r = o);
349
350
  }
350
351
  });
351
352
  }, L = () => window.innerHeight * 0.01 + "px", I = (s) => {
@@ -362,24 +363,24 @@ const M = () => {
362
363
  OVERFLOW_HIDDEN: "rml-overflow-hidden"
363
364
  }, p = /* @__PURE__ */ new Map();
364
365
  class X extends A {
365
- static createPlanner(e, t, r, n = []) {
366
+ static createPlanner(e, t, r, o = []) {
366
367
  return this._create(
367
368
  e,
368
369
  t,
369
370
  r,
370
- n
371
+ o
371
372
  );
372
373
  }
373
374
  static async connect(e, t = []) {
374
375
  const r = new A();
375
376
  r.viewName = e;
376
- const { resolve: n, promise: i } = M(), { resolve: a, promise: o } = M(), l = ({
377
+ const { resolve: o, promise: i } = M(), { resolve: a, promise: n } = M(), l = ({
377
378
  message: g,
378
379
  args: h
379
380
  }) => {
380
381
  switch (g) {
381
382
  case m.REGISTER_CUSTOM_VIEW_DONE:
382
- n();
383
+ o();
383
384
  break;
384
385
  case m.RETURN_METHODS:
385
386
  r.handleSetup(h[0]), a();
@@ -399,7 +400,7 @@ class X extends A {
399
400
  return u.sendMessage(
400
401
  m.REGISTER_CUSTOM_VIEW,
401
402
  d
402
- ), await i, u.sendMessage(m.GET_METHODS, d), await o, r.setupPlugins(
403
+ ), await i, u.sendMessage(m.GET_METHODS, d), await n, r.setupPlugins(
403
404
  t,
404
405
  document.body,
405
406
  "custom-view"
@@ -411,12 +412,12 @@ class X extends A {
411
412
  * @param container DOM container in which the configurator should be placed
412
413
  * @param initData settings with which the configurator should be started
413
414
  */
414
- static createConfigurator(e, t, r, n = []) {
415
+ static createConfigurator(e, t, r, o = []) {
415
416
  return this._create(
416
417
  e,
417
418
  t,
418
419
  r,
419
- n
420
+ o
420
421
  );
421
422
  }
422
423
  /**
@@ -426,12 +427,12 @@ class X extends A {
426
427
  * @param container DOM container in which the configurator should be placed
427
428
  * @param initData settings with which the configurator should be started
428
429
  */
429
- static create(e, t, r, n) {
430
+ static create(e, t, r, o) {
430
431
  return this._create(
431
432
  e,
432
433
  t,
433
434
  r,
434
- n
435
+ o
435
436
  );
436
437
  }
437
438
  /**
@@ -440,37 +441,37 @@ class X extends A {
440
441
  * @param container DOM container in which the configurator should be placed
441
442
  * @param initData settings with which the configurator should be started
442
443
  */
443
- static createViewer(e, t, r, n = []) {
444
+ static createViewer(e, t, r, o = []) {
444
445
  return this._create(
445
446
  e,
446
447
  t,
447
448
  r,
448
- n
449
+ o
449
450
  );
450
451
  }
451
- static async _create(e, t, r, n) {
452
+ static async _create(e, t, r, o) {
452
453
  return new Promise(async (i, a) => {
453
454
  try {
454
- const o = O(
455
+ const n = O(
455
456
  z(),
456
457
  V(r)
457
458
  );
458
- K(o);
459
+ K(n);
459
460
  const l = await C(
460
461
  e,
461
- o
462
+ n
462
463
  );
463
- r = $(l, o);
464
+ r = $(l, n);
464
465
  const u = new this(
465
466
  l,
466
467
  t,
467
468
  r,
468
- n,
469
+ o,
469
470
  i
470
471
  );
471
472
  return await Promise.allSettled(u.pluginsLoaded), u;
472
- } catch (o) {
473
- return a(o);
473
+ } catch (n) {
474
+ return a(n);
474
475
  }
475
476
  });
476
477
  }
@@ -479,7 +480,7 @@ class X extends A {
479
480
  _configuratorSettings;
480
481
  _initData = {};
481
482
  _iframe;
482
- constructor(e, t, r, n, i) {
483
+ constructor(e, t, r, o, i) {
483
484
  if (super(), !e || typeof e.id != "string")
484
485
  throw new Error(
485
486
  "Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person"
@@ -503,15 +504,15 @@ class X extends A {
503
504
  `, document.head.appendChild(d);
504
505
  }
505
506
  this._executeMessage = this._executeMessage.bind(this);
506
- const o = new S(
507
+ const n = new S(
507
508
  "website",
508
509
  window,
509
510
  null,
510
511
  this._executeMessage
511
512
  );
512
- this.setMessageHandler(o), this._onResize = this._onResize.bind(this), y() && window.addEventListener("resize", this._onResize), this._container = t, this._initData = r, this._configuratorSettings = e;
513
+ this.setMessageHandler(n), this._onResize = this._onResize.bind(this), y() && window.addEventListener("resize", this._onResize), this._container = t, this._initData = r, this._configuratorSettings = e;
513
514
  const l = this._createIframe();
514
- this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = i, this._container.appendChild(l), this._iframe = l, this.setupPlugins(n, this._iframe), p.set(t, !0);
515
+ this._onUseFullPage = this._onUseFullPage.bind(this), this._onBackToWebsite = this._onBackToWebsite.bind(this), this._waitForIframe = i, this._container.appendChild(l), this._iframe = l, this.setupPlugins(o, this._iframe), p.set(t, !0);
515
516
  }
516
517
  teardown() {
517
518
  this._container && p.delete(this._container);
@@ -1 +1 @@
1
- class e{_side;_incomingMessageBus=null;_outgoingMessageBus=null;_execMessage=null;constructor(e,t,s,r){this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=e=>{if(!e||!e.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let t;try{t=JSON.parse(e.data)}catch(e){return i.port1.close(),i.port2.close(),this._prepareError(e),r(e)}t.error?r(t.error):void 0!==t.result?s(t.result):s(void 0),i.port1.close(),i.port2.close()};let 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 t=["127.0.0.1","localhost","0.0.0.0"],s=["language","browserLanguage","userLanguage","systemLanguage"],r=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=r(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var i=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(i||{});const n={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[i.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},a=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&&a(t),Array.isArray(t))for(const e of t)a(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},o=()=>/(android)/i.test(navigator.userAgent);class l{_messageHandler=null;isSetupDone=!1;viewName="main";plugins={};pluginsLoaded=[];ui={callbacks:null};extended={callbacks:null};configurator={callbacks:null};analytics={callbacks:{}};rapi={callbacks:{}};global={callbacks:{}};setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(e=>{const t=e.split("."),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-DTA1FCDc.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 c=()=>{let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}},u=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=e?.mute?e.value:e}})},g=()=>.01*window.innerHeight+"px",d=e=>{e&&setTimeout(()=>e.style.setProperty(m,g()),0)},h="rml-styles",m="--rml-full-height",p="rml-container",f="rml-fill",_="rml-pos",w="rml-android-height",y="rml-overflow-hidden",b=new Map;class M extends l{static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(t,s=[]){const r=new l;r.viewName=t;const{resolve:i,promise:n}=c(),{resolve:a,promise:o}=c(),u=new e("custom-view-"+t,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(u);const g=[t];return u.sendMessage("registerCustomView",g),await n,u.sendMessage("getMethods",g),await o,r.setupPlugins(s,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,i,o,l){return new Promise(async(c,u)=>{try{const u=r((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(n);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,r=s.length;e<r;e++){const r=t[s[e]];if(r)return r.substr(0,2)}return"en"})()),"(idle)"===e.id&&delete e.id;const r=(()=>{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 r&&(e=>!!(t.includes(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com")))(r)&&(e.configuratorId="demoConfigurator"),e.customApiUrl=void 0,e.emails=!1,e})(),(a(g=o),g?.customApiUrl&&(g.customApiUrl=decodeURIComponent(g.customApiUrl)),g.shareUrl&&(g.deeplink=g.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),g));(e=>{e.featureFlags||(e.featureFlags={}),"boolean"!=typeof e.featureFlags.realPartList&&(e.featureFlags.realPartList=!0),"boolean"!=typeof e.featureFlags.globalCallbacks&&(e.featureFlags.globalCallbacks=!0),"boolean"!=typeof e.featureFlags.mocAr&&(e.featureFlags.mocAr=!1)})(u);const 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,u);o=((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 r(s,t)})(s,t)})(d,u);const h=new this(d,i,o,l,c);return await Promise.allSettled(h.pluginsLoaded),h}catch(e){return u(e)}var g})}_waitForIframe;_container;_configuratorSettings;_initData={};_iframe;constructor(t,s,r,i,n){if(super(),!t||"string"!=typeof t.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(b.has(s))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(h)){const e=r.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=h;const s="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((e,t)=>e+(t+s),"")+s,n=g();t.innerHTML=`\n .${p}{${m}:${n};}\n .${_}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${i}}\n .${f}{width:100%;height:100%;opacity:1}\n .${w}{height:calc(var(${m},1vh)*100)}\n .${y}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const a=new e("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),o()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=t;const l=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=n,this._container.appendChild(l),this._iframe=l,this.setupPlugins(i,this._iframe),b.set(s,!0)}teardown(){this._container&&b.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){const e=document.createElement("iframe");let t=this._configuratorSettings?.url||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(t=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(t=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(t=this._initData.overrideServerUrl),e.src=t,e.classList.add(p),e.classList.add(f),e}_onResize(){d(this._iframe)}_onUseFullPage(){this._iframe.classList.add(_),document.documentElement.classList.add(y),window.document.body.classList.add(y),o()&&(d(this._iframe),this._iframe.classList.add(w))}_onBackToWebsite(){this._iframe.classList.remove(_),this._iframe.classList.remove(w),document.documentElement.classList.remove(y),window.document.body.classList.remove(y)}_executeMessage({message:e,args:t},s){if(s.source&&s.source===this._iframe?.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]),u(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),u(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{M as default};
1
+ class e{_side;_incomingMessageBus=null;_outgoingMessageBus=null;_execMessage=null;constructor(e,t,s,r){this._side=e,this._incomingMessageBus=t,this._outgoingMessageBus=s,this._execMessage=r,this._incomingMessageBus&&this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,t=[]){return new Promise((s,r)=>{if(this._incomingMessageBus===this._outgoingMessageBus)return s(void 0);const i=new MessageChannel;i.port1.onmessage=e=>{if(!e||!e.data)return i.port1.close(),i.port2.close(),r(new Error(this._side+" received message but response can not be interpreted"));let t;try{t=JSON.parse(e.data)}catch(e){return i.port1.close(),i.port2.close(),this._prepareError(e),r(e)}t.error?r(t.error):void 0!==t.result?s(t.result):s(void 0),i.port1.close(),i.port2.close()};let 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 t=["127.0.0.1","localhost","0.0.0.0"],s=["language","browserLanguage","userLanguage","systemLanguage"],r=(e,t)=>{for(const s in t)try{t[s].constructor===Object?e[s]=r(e[s],t[s]):e[s]=t[s]}catch{e[s]=t[s]}return e};var i=(e=>(e.BOTTOM_BAR="bottom_bar",e.PARTLIST_BOUNDS="partlist_bounds",e.INTERACTION_NOTES="interaction_notes",e.PARAMETER_GROUPS="parameter_groups",e))(i||{});const n={mobileLandscape:!0,floorMaterialRootTag:"materials_root",buttons:{renderimage:!0,requestproduct:!0,requestplan:!0,load_product:!0,partlist_print:!0},elements:{[i.INTERACTION_NOTES]:!0},helpcenter:{roomdesigner:!0,configurator:!1,disable:!1},firstPersonView:!0,saveToIdb:!0,featureFlags:{mocAr:!0,wallAutoHeight:!1,openCloseAnimation:!1,enableTwoLevelCatalog:!1},rotationSnapDegrees:10,interactionsCollapsed:!1},a=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&&a(t),Array.isArray(t))for(const e of t)a(e);("true"===t||"false"===t)&&(e[s]="true"===t)}},o=()=>/(android)/i.test(navigator.userAgent);class l{_messageHandler=null;isSetupDone=!1;viewName="main";plugins={};pluginsLoaded=[];ui={callbacks:null};extended={callbacks:null};configurator={callbacks:null};analytics={callbacks:{}};rapi={callbacks:{}};global={callbacks:{}};setMessageHandler(e){this._messageHandler=e}handleSetup(e){const{methods:t,callbacks:s}=e;t.forEach(e=>{const t=e.split("."),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-BmoiEqfA.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 c=()=>{let e,t;return{promise:new Promise((s,r)=>{e=s,t=r}),resolve:e,reject:t}},u=(e,t,s)=>{let r=null;Object.defineProperty(e,t,{get:()=>r||s,set(e){r=e?.mute?e.value:e}})},g=()=>.01*window.innerHeight+"px",d=e=>{e&&setTimeout(()=>e.style.setProperty(m,g()),0)},h="rml-styles",m="--rml-full-height",p="rml-container",f="rml-fill",_="rml-pos",w="rml-android-height",y="rml-overflow-hidden",b=new Map;class M extends l{static createPlanner(e,t,s,r=[]){return this._create(e,t,s,r)}static async connect(t,s=[]){const r=new l;r.viewName=t;const{resolve:i,promise:n}=c(),{resolve:a,promise:o}=c(),u=new e("custom-view-"+t,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(u);const g=[t];return u.sendMessage("registerCustomView",g),await n,u.sendMessage("getMethods",g),await o,r.setupPlugins(s,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,i,o,l){return new Promise(async(c,u)=>{try{const u=r((()=>{const e=(e=>JSON.parse(JSON.stringify(e)))(n);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,r=s.length;e<r;e++){const r=t[s[e]];if(r)return r.substr(0,2)}return"en"})()),"(idle)"===e.id&&delete e.id;const r=(()=>{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 r&&(e=>!!(t.includes(e)||e.endsWith("roomle.com")||e.endsWith("gitlab.io")||e.endsWith("gitlab.com")))(r)&&(e.configuratorId="demoConfigurator"),e.customApiUrl=void 0,e.emails=!1,e})(),(a(g=o),g?.customApiUrl&&(g.customApiUrl=decodeURIComponent(g.customApiUrl)),g.shareUrl&&(g.deeplink=g.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),g));(e=>{e.featureFlags||(e.featureFlags={}),"boolean"!=typeof e.featureFlags.realPartList&&(e.featureFlags.realPartList=!0),"boolean"!=typeof e.featureFlags.globalCallbacks&&(e.featureFlags.globalCallbacks=!0),"boolean"!=typeof e.featureFlags.mocAr&&(e.featureFlags.mocAr=!1)})(u);const 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,u);o=((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 r(s,t)})(s,t)})(d,u);const h=new this(d,i,o,l,c);return await Promise.allSettled(h.pluginsLoaded),h}catch(e){return u(e)}var g})}_waitForIframe;_container;_configuratorSettings;_initData={};_iframe;constructor(t,s,r,i,n){if(super(),!t||"string"!=typeof t.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(b.has(s))throw new Error("There is already an instance on this DOM element");if(!document.getElementById(h)){const e=r.zIndex||9999999,t=document.createElement("style");t.type="text/css",t.id=h;const s="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((e,t)=>e+(t+s),"")+s,n=g();t.innerHTML=`\n .${p}{${m}:${n};}\n .${_}{position:fixed;top:0;left:0;z-index:${e};opacity:0}\n .rml-transition{${i}}\n .${f}{width:100%;height:100%;opacity:1}\n .${w}{height:calc(var(${m},1vh)*100)}\n .${y}{overflow:hidden}\n `,document.head.appendChild(t)}this._executeMessage=this._executeMessage.bind(this);const a=new e("website",window,null,this._executeMessage);this.setMessageHandler(a),this._onResize=this._onResize.bind(this),o()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=t;const l=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._waitForIframe=n,this._container.appendChild(l),this._iframe=l,this.setupPlugins(i,this._iframe),b.set(s,!0)}teardown(){this._container&&b.delete(this._container);const e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){const e=document.createElement("iframe");let t=this._configuratorSettings?.url||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(t=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(t=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(t=this._initData.overrideServerUrl),e.src=t,e.classList.add(p),e.classList.add(f),e}_onResize(){d(this._iframe)}_onUseFullPage(){this._iframe.classList.add(_),document.documentElement.classList.add(y),window.document.body.classList.add(y),o()&&(d(this._iframe),this._iframe.classList.add(w))}_onBackToWebsite(){this._iframe.classList.remove(_),this._iframe.classList.remove(w),document.documentElement.classList.remove(y),window.document.body.classList.remove(y)}_executeMessage({message:e,args:t},s){if(s.source&&s.source===this._iframe?.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]),u(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),u(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{M as default};