@roomle/embedding-lib 4.44.0 → 5.1.0-debug.1

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 (234) hide show
  1. package/.releaserc.json +4 -7
  2. package/README.md +5 -6
  3. package/docs/md/web/embedding/CHANGELOG.md +6 -0
  4. package/drag-in-C2fEQF9W.mjs +7 -0
  5. package/drag-in-CAakt8yw.mjs +250 -0
  6. package/index.d.ts +102 -0
  7. package/package.json +27 -13
  8. package/roomle-embedding-lib.es.js +453 -0
  9. package/roomle-embedding-lib.es.min.js +8 -0
  10. package/roomle-embedding-lib.umd.js +14 -0
  11. package/roomle-embedding-lib.umd.min.js +14 -0
  12. package/docs/__sidebar__.json +0 -14
  13. package/docs/api/.nojekyll +0 -1
  14. package/docs/api/README.md +0 -9
  15. package/docs/api/classes/exposed_analytics_callbacks.ExposedAnalyticsCallbacks.md +0 -47
  16. package/docs/api/classes/exposed_api.ExposedApi.md +0 -255
  17. package/docs/api/classes/exposed_callbacks.ExposedCallbacks.md +0 -195
  18. package/docs/api/classes/roomle_configurator_api.default.md +0 -211
  19. package/docs/api/enums/types.UI_BUTTON.md +0 -263
  20. package/docs/api/interfaces/exposed_callbacks.Labels.md +0 -32
  21. package/docs/api/interfaces/exposed_callbacks.Price.md +0 -32
  22. package/docs/api/interfaces/roomle_configurator_api.RoomleEmbeddingApiKeys.md +0 -58
  23. package/docs/api/interfaces/types.ConfiguratorSettings.md +0 -150
  24. package/docs/api/interfaces/types.EmbeddingSkin.md +0 -65
  25. package/docs/api/interfaces/types.UiInitData.md +0 -1199
  26. package/docs/api/interfaces/types.VariantsMap.md +0 -9
  27. package/docs/api/modules/exposed_analytics_callbacks.md +0 -9
  28. package/docs/api/modules/exposed_api.md +0 -9
  29. package/docs/api/modules/exposed_callbacks.md +0 -14
  30. package/docs/api/modules/roomle_configurator_api.md +0 -49
  31. package/docs/api/modules/types.md +0 -16
  32. package/docs/api/modules.md +0 -13
  33. package/docs/examples/00_init.html +0 -38
  34. package/docs/examples/01_small_screen.html +0 -37
  35. package/docs/examples/02_resize_callback.html +0 -46
  36. package/docs/examples/03_instant_start.html +0 -38
  37. package/docs/examples/04_price.html +0 -48
  38. package/docs/examples/05_analytics.html +0 -38
  39. package/docs/examples/06_skinning.html +0 -39
  40. package/docs/examples/07_request_product.html +0 -41
  41. package/docs/examples/08_variants.html +0 -36
  42. package/docs/examples/09_different_products.html +0 -63
  43. package/docs/examples/10_landing_page.html +0 -38
  44. package/docs/examples/11_light_settings.html +0 -126
  45. package/docs/examples/12_email.html +0 -36
  46. package/docs/examples/13_parameters.html +0 -67
  47. package/docs/examples/14_ga_consent.html +0 -39
  48. package/docs/examples/roomle-configurator-api.es.min.js +0 -586
  49. package/docs/hsp.md +0 -61
  50. package/docs/images/parts.png +0 -0
  51. package/docs/images/usm-frames.png +0 -0
  52. package/docs/integration.md +0 -1101
  53. package/docs/md/web/ui/EMBEDDING-CHANGELOG.md +0 -17
  54. package/docs/migration-guides/v2-to-v3.md +0 -135
  55. package/docs/moc/index.md +0 -86
  56. package/docs/simple.md +0 -25
  57. package/roomle-configurator-api.cjs.js +0 -585
  58. package/roomle-configurator-api.cjs.min.js +0 -1
  59. package/roomle-configurator-api.es.js +0 -583
  60. package/roomle-configurator-api.es.min.js +0 -1
  61. package/roomle-configurator-api.js +0 -583
  62. package/types/index.d.ts +0 -1504
  63. package/types/src/common/business-logic/connector.d.ts +0 -8
  64. package/types/src/common/business-logic/event-bus.d.ts +0 -5
  65. package/types/src/common/components/collection-view/-utils/types.d.ts +0 -10
  66. package/types/src/common/plugins/analytics.d.ts +0 -11
  67. package/types/src/common/plugins/localize.d.ts +0 -8
  68. package/types/src/common/store/collection-view-state.d.ts +0 -40
  69. package/types/src/common/store/common-ui-state.d.ts +0 -16
  70. package/types/src/common/store/index.d.ts +0 -111
  71. package/types/src/common/translations/local-translation-source.d.ts +0 -8
  72. package/types/src/common/utils/access-restriction.d.ts +0 -7
  73. package/types/src/common/utils/ar-service.d.ts +0 -14
  74. package/types/src/common/utils/bezier.d.ts +0 -2
  75. package/types/src/common/utils/browser.d.ts +0 -3
  76. package/types/src/common/utils/color.d.ts +0 -2
  77. package/types/src/common/utils/compatibility.d.ts +0 -3
  78. package/types/src/common/utils/dom.d.ts +0 -15
  79. package/types/src/common/utils/font-size-detector.d.ts +0 -1
  80. package/types/src/common/utils/google-analytics.d.ts +0 -67
  81. package/types/src/common/utils/helper.d.ts +0 -43
  82. package/types/src/common/utils/iframe.d.ts +0 -3
  83. package/types/src/common/utils/init-data.d.ts +0 -34
  84. package/types/src/common/utils/merge.d.ts +0 -16
  85. package/types/src/common/utils/parameters.d.ts +0 -18
  86. package/types/src/common/utils/performance.d.ts +0 -2
  87. package/types/src/common/utils/plan.d.ts +0 -1
  88. package/types/src/common/utils/script-loader.d.ts +0 -5
  89. package/types/src/common/utils/share.d.ts +0 -1
  90. package/types/src/common/utils/touch-drag.d.ts +0 -24
  91. package/types/src/common/utils/types.d.ts +0 -19
  92. package/types/src/common/utils/user-agent.d.ts +0 -6
  93. package/types/src/common/utils/variants.d.ts +0 -3
  94. package/types/src/configurator/ar/main.d.ts +0 -1
  95. package/types/src/configurator/business-logic/roomle-sdk-wrapper.d.ts +0 -27
  96. package/types/src/configurator/business-logic/sdk-connector-configurator.d.ts +0 -29
  97. package/types/src/configurator/business-logic/sdk-connector.d.ts +0 -119
  98. package/types/src/configurator/business-logic/ui-callback.d.ts +0 -5
  99. package/types/src/configurator/components/-utils/overlays.d.ts +0 -43
  100. package/types/src/configurator/components/grid-view/-utils/GridViewHelper.d.ts +0 -16
  101. package/types/src/configurator/components/utils/-utils/SceneOffsetResizer.d.ts +0 -23
  102. package/types/src/configurator/embedding/example/main.d.ts +0 -1
  103. package/types/src/configurator/embedding/exposed-analytics-callbacks.d.ts +0 -10
  104. package/types/src/configurator/embedding/exposed-api.d.ts +0 -90
  105. package/types/src/configurator/embedding/exposed-callbacks.d.ts +0 -46
  106. package/types/src/configurator/embedding/helper.d.ts +0 -8
  107. package/types/src/configurator/embedding/message-handler.d.ts +0 -31
  108. package/types/src/configurator/embedding/roomle-configurator-api.d.ts +0 -64
  109. package/types/src/configurator/embedding/types.d.ts +0 -159
  110. package/types/src/configurator/embedding/utils.d.ts +0 -15
  111. package/types/src/configurator/plugins/embedding-callbacks-plugin.d.ts +0 -4
  112. package/types/src/configurator/plugins/libs-plugin.d.ts +0 -11
  113. package/types/src/configurator/plugins/sdk-connector-plugin.d.ts +0 -14
  114. package/types/src/configurator/store/core-data.d.ts +0 -34
  115. package/types/src/configurator/store/core-state.d.ts +0 -26
  116. package/types/src/configurator/store/ui-state.d.ts +0 -118
  117. package/types/src/main.d.ts +0 -14
  118. package/types/src/planner/business-logic/general-room-parameters.d.ts +0 -17
  119. package/types/src/planner/business-logic/pre-defined-rooms.d.ts +0 -2
  120. package/types/src/planner/business-logic/rooms.d.ts +0 -37
  121. package/types/src/planner/business-logic/sdk-connector-planner.d.ts +0 -28
  122. package/types/src/planner/store/planner-core-data.d.ts +0 -21
  123. package/types/src/planner/store/planner-ui-state.d.ts +0 -65
  124. package/types/src/planner/utils/interaction.d.ts +0 -3
  125. package/types/src/planner/utils/planner-sidebar.d.ts +0 -19
  126. package/types/src/viewer/business-logic/sdk-connector-viewer.d.ts +0 -18
  127. package/types/tests/helpers/data/base-64-images.d.ts +0 -1
  128. package/types/tests/helpers/data/configurator.d.ts +0 -7
  129. package/types/tests/helpers/data/items.d.ts +0 -208
  130. package/types/tests/helpers/data/materials.d.ts +0 -32
  131. package/types/tests/helpers/data/parameter-groups.d.ts +0 -242
  132. package/types/tests/helpers/data/parameters.d.ts +0 -399
  133. package/types/tests/helpers/data/part-list.d.ts +0 -126
  134. package/types/tests/helpers/data/plan.d.ts +0 -224
  135. package/types/tests/helpers/data/planObject.d.ts +0 -134
  136. package/types/tests/helpers/data/possible-children-tags.d.ts +0 -208
  137. package/types/tests/helpers/data/variants.d.ts +0 -60
  138. package/types/tests/helpers/data/wall-dimensions.d.ts +0 -41
  139. package/types/tests/helpers/dom.d.ts +0 -1
  140. package/types/tests/helpers/mocks/analytics.d.ts +0 -7
  141. package/types/tests/helpers/mocks/data/biohort-parameter.d.ts +0 -32
  142. package/types/tests/helpers/mocks/data/koinor-formia.d.ts +0 -289
  143. package/types/tests/helpers/mocks/embedding-callbacks.d.ts +0 -4
  144. package/types/tests/helpers/mocks/icon.d.ts +0 -3
  145. package/types/tests/helpers/mocks/localize.d.ts +0 -8
  146. package/types/tests/helpers/mocks/message.d.ts +0 -11
  147. package/types/tests/helpers/mocks/parameters.d.ts +0 -47
  148. package/types/tests/helpers/mocks/possible-children.d.ts +0 -596
  149. package/types/tests/helpers/mocks/roomle-sdk-wrapper.d.ts +0 -177
  150. package/types/tests/helpers/mocks/sdk-connector-configurator.d.ts +0 -13
  151. package/types/tests/helpers/mocks/sdk-connector-planner.d.ts +0 -13
  152. package/types/tests/helpers/mocks/sdk-connector.d.ts +0 -35
  153. package/types/tests/helpers/mocks/store.d.ts +0 -11
  154. package/types/tests/helpers/mocks/tag.d.ts +0 -148
  155. package/types/tests/helpers/utils.d.ts +0 -13
  156. package/types/tests/integration/common/components/ActionButtons.spec.d.ts +0 -1
  157. package/types/tests/integration/common/components/BottomBar.spec.d.ts +0 -1
  158. package/types/tests/integration/common/components/BottomButtons.spec.d.ts +0 -1
  159. package/types/tests/integration/common/components/IconButton.spec.d.ts +0 -1
  160. package/types/tests/integration/common/components/SelectionButtons.spec.d.ts +0 -1
  161. package/types/tests/integration/common/components/part-list/part-list/PartListPrint.spec.d.ts +0 -1
  162. package/types/tests/integration/common/components/part-list/part-list/PartListRow.spec.d.ts +0 -1
  163. package/types/tests/integration/configurator/App.spec.d.ts +0 -1
  164. package/types/tests/integration/configurator/components/ARButton.spec.d.ts +0 -1
  165. package/types/tests/integration/configurator/components/ConfiguratorMain.spec.d.ts +0 -9
  166. package/types/tests/integration/configurator/components/CookieBanner.spec.d.ts +0 -1
  167. package/types/tests/integration/configurator/components/Overlays.spec.d.ts +0 -1
  168. package/types/tests/integration/configurator/components/TopBar.spec.d.ts +0 -1
  169. package/types/tests/integration/configurator/components/ViewerMain.spec.d.ts +0 -1
  170. package/types/tests/integration/configurator/components/addons/AddonsTrigger.spec.d.ts +0 -1
  171. package/types/tests/integration/configurator/components/addons/PossibleChildren.spec.d.ts +0 -1
  172. package/types/tests/integration/configurator/components/collection-view/-utils/TabbedNav.spec.d.ts +0 -1
  173. package/types/tests/integration/configurator/components/collection-view/CollectionView.spec.d.ts +0 -1
  174. package/types/tests/integration/configurator/components/grid-view/-utils/CollapsedView.spec.d.ts +0 -1
  175. package/types/tests/integration/configurator/components/grid-view/-utils/ExpandedView.spec.d.ts +0 -1
  176. package/types/tests/integration/configurator/components/grid-view/-utils/GridViewElement.spec.d.ts +0 -1
  177. package/types/tests/integration/configurator/components/grid-view/-utils/GridViewHelper.spec.d.ts +0 -1
  178. package/types/tests/integration/configurator/components/grid-view/GridView.spec.d.ts +0 -1
  179. package/types/tests/integration/configurator/components/overlays/Export3D.spec.d.ts +0 -1
  180. package/types/tests/integration/configurator/components/overlays/NoDocking.spec.d.ts +0 -1
  181. package/types/tests/integration/configurator/components/overlays/PartList.spec.d.ts +0 -1
  182. package/types/tests/integration/configurator/components/overlays/SaveDraft.spec.d.ts +0 -1
  183. package/types/tests/integration/configurator/components/overlays/VariantWarning.spec.d.ts +0 -1
  184. package/types/tests/integration/configurator/components/overlays/ar/OpenARView.spec.d.ts +0 -1
  185. package/types/tests/integration/configurator/components/parameters/BackParameterGroupButton.spec.d.ts +0 -1
  186. package/types/tests/integration/configurator/components/parameters/NextParameterGroupButton.spec.d.ts +0 -1
  187. package/types/tests/integration/configurator/components/parameters/ParameterGroupButton.spec.d.ts +0 -1
  188. package/types/tests/integration/configurator/components/parameters/ParameterGroups.spec.d.ts +0 -1
  189. package/types/tests/integration/configurator/components/parameters/types/MaterialParameter.spec.d.ts +0 -1
  190. package/types/tests/integration/configurator/components/parameters/types/OptionsParameter.spec.d.ts +0 -1
  191. package/types/tests/integration/configurator/components/parameters/types/OptionsParameterValue.spec.d.ts +0 -1
  192. package/types/tests/integration/configurator/components/parameters/types/ProductVariant.spec.d.ts +0 -1
  193. package/types/tests/integration/configurator/components/parameters/types/RangeParameter.spec.d.ts +0 -1
  194. package/types/tests/integration/configurator/components/parameters/types/ThumbnailsParameter.spec.d.ts +0 -1
  195. package/types/tests/integration/configurator/components/utils/BackToWebsite.spec.d.ts +0 -1
  196. package/types/tests/integration/configurator/components/utils/CheckBox.spec.d.ts +0 -1
  197. package/types/tests/integration/configurator/components/utils/FullscreenContainer.spec.d.ts +0 -1
  198. package/types/tests/integration/configurator/components/utils/GdprEmailInput.spec.d.ts +0 -1
  199. package/types/tests/integration/configurator/components/utils/HeightToggle.spec.d.ts +0 -1
  200. package/types/tests/integration/configurator/components/utils/ImageWithFallback.spec.d.ts +0 -1
  201. package/types/tests/integration/configurator/components/utils/InteractionContainer.spec.d.ts +0 -1
  202. package/types/tests/integration/configurator/components/utils/PopUp.spec.d.ts +0 -1
  203. package/types/tests/integration/configurator/components/utils/ScrollHint.spec.d.ts +0 -1
  204. package/types/tests/integration/helper.spec.d.ts +0 -1
  205. package/types/tests/integration/planner/components/CatalogTrigger.spec.d.ts +0 -1
  206. package/types/tests/integration/planner/components/PlannerMain.spec.d.ts +0 -1
  207. package/types/tests/integration/planner/components/PlannerSidebar.spec.d.ts +0 -1
  208. package/types/tests/integration/planner/components/ProductListButton.spec.d.ts +0 -1
  209. package/types/tests/integration/planner/components/SampleRooms.spec.d.ts +0 -1
  210. package/types/tests/integration/planner/components/ShowWallMeasurements.spec.d.ts +0 -1
  211. package/types/tests/integration/planner/components/overlays/product-list/ProductListEntry.spec.d.ts +0 -1
  212. package/types/tests/integration/planner/components/overlays/rooms/RoomGeneralSettings.spec.d.ts +0 -1
  213. package/types/tests/integration/planner/components/overlays/rooms/RoomRangeParameter.spec.d.ts +0 -1
  214. package/types/tests/integration/planner/components/utils/InteractionHeader.spec.d.ts +0 -1
  215. package/types/tests/integration/planner/components/utils/sidebar-nav/SidebarNav.spec.d.ts +0 -1
  216. package/types/tests/unit/common/business-logic/event-bus.spec.d.ts +0 -1
  217. package/types/tests/unit/common/helper.spec.d.ts +0 -1
  218. package/types/tests/unit/common/translations/local-translation-source.spec.d.ts +0 -1
  219. package/types/tests/unit/common/utils/ar-service.spec.d.ts +0 -1
  220. package/types/tests/unit/common/utils/bezier.spec.d.ts +0 -1
  221. package/types/tests/unit/common/utils/color.spec.d.ts +0 -1
  222. package/types/tests/unit/common/utils/dom.spec.d.ts +0 -1
  223. package/types/tests/unit/common/utils/helper.spec.d.ts +0 -1
  224. package/types/tests/unit/common/utils/init-data.spec.d.ts +0 -1
  225. package/types/tests/unit/common/utils/parameters.spec.d.ts +0 -1
  226. package/types/tests/unit/common/utils/touch-drag.spec.d.ts +0 -1
  227. package/types/tests/unit/configurator/business-logic/sdk-connector-configurator.spec.d.ts +0 -1
  228. package/types/tests/unit/configurator/business-logic/sdk-connector.spec.d.ts +0 -1
  229. package/types/tests/unit/configurator/components/utils/-utils/ConfiguratorResizer.spec.d.ts +0 -1
  230. package/types/tests/unit/configurator/components/utils/WordWrap.spec.d.ts +0 -1
  231. package/types/tests/unit/configurator/embedding/exposed-api.spec.d.ts +0 -1
  232. package/types/tests/unit/configurator/embedding/utils.spec.d.ts +0 -1
  233. package/types/tests/unit/configurator/store/index.spec.d.ts +0 -1
  234. package/types/tests/unit/planner/business-logic/sdk-connector-planner.spec.d.ts +0 -1
@@ -1,583 +0,0 @@
1
- class MessageHandler {
2
- constructor(side, incomingMessageBus, outgoingMessageBus, messageExecution) {
3
- this._outgoingMessageBus = null;
4
- this._execMessage = null;
5
- this._side = side;
6
- this._incomingMessageBus = incomingMessageBus;
7
- this._outgoingMessageBus = outgoingMessageBus;
8
- this._execMessage = messageExecution;
9
- this._incomingMessageBus.addEventListener('message', this._handleMessage.bind(this));
10
- }
11
- setOutgoingMessageBus(outgoingMessageBus) {
12
- this._outgoingMessageBus = outgoingMessageBus;
13
- }
14
- setMessageExecution(fun) {
15
- this._execMessage = fun;
16
- }
17
- sendMessage(message, args = []) {
18
- return new Promise((resolve, reject) => {
19
- const messageChannel = new MessageChannel();
20
- messageChannel.port1.onmessage = (event) => {
21
- if (!event || !event.data) {
22
- messageChannel.port1.close();
23
- messageChannel.port2.close();
24
- return reject(new Error(this._side + ' received message but response can not be interpreted'));
25
- }
26
- let response;
27
- try {
28
- response = JSON.parse(event.data);
29
- }
30
- catch (e) {
31
- messageChannel.port1.close();
32
- messageChannel.port2.close();
33
- this._prepareError(e);
34
- return reject(e);
35
- }
36
- if (response.error) {
37
- reject(response.error);
38
- }
39
- else if (response.result !== undefined) {
40
- resolve(response.result);
41
- }
42
- else {
43
- resolve();
44
- }
45
- messageChannel.port1.close();
46
- messageChannel.port2.close();
47
- };
48
- let command = '';
49
- try {
50
- command = JSON.stringify({ message, args });
51
- }
52
- catch (e) {
53
- return reject(new Error(this._side + ': can not create command because it is not JSON.stringify able'));
54
- }
55
- if (!this._outgoingMessageBus) {
56
- return reject(new Error(this._side + ': outgoing bus not set yet'));
57
- }
58
- this._outgoingMessageBus.postMessage(command, '*', [messageChannel.port2]);
59
- });
60
- }
61
- _handleMessage(event) {
62
- // check if MessageEvent has a port set --> hope this clears confusion about https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API/Using_channel_messaging
63
- const receiver = (event.ports && Array.isArray(event.ports) && event.ports.length > 0) ? event.ports[0] : null;
64
- if (event.data && receiver) {
65
- try {
66
- const command = JSON.parse(event.data);
67
- if (!this._execMessage) {
68
- return receiver.postMessage(JSON.stringify({ error: this._side + ' is not ready to handle messages' }));
69
- }
70
- if (!Array.isArray(command.args)) {
71
- command.args = [command.args];
72
- }
73
- const execResult = this._execMessage(command, event);
74
- if (execResult === undefined) {
75
- return; // do nothing because execMessage did not know what to do. Probably a message from another iframe was intercepted
76
- }
77
- execResult.then((data = {}) => {
78
- // tslint:disable-next-line:no-unnecessary-initializer
79
- let error = undefined;
80
- // tslint:disable-next-line:no-unnecessary-initializer
81
- let result = undefined;
82
- if (typeof data === 'object' && data !== null) {
83
- error = data.error;
84
- result = data.result;
85
- }
86
- if (error) {
87
- receiver.postMessage(JSON.stringify({ error }));
88
- }
89
- else if (result !== undefined) {
90
- receiver.postMessage(JSON.stringify({ result }));
91
- }
92
- else {
93
- receiver.postMessage(JSON.stringify({ result: data }));
94
- }
95
- }, (error) => {
96
- receiver.postMessage(JSON.stringify({ error: this._prepareError(error) }));
97
- });
98
- }
99
- catch (error) {
100
- receiver.postMessage(JSON.stringify({ error: this._prepareError(error) }));
101
- }
102
- }
103
- }
104
- _prepareError(e) {
105
- if (typeof e === 'string') {
106
- const error = this._side + ': ' + e;
107
- console.error(error);
108
- return error;
109
- }
110
- e.message = this._side + ': ' + e.message;
111
- console.error(e);
112
- return e.message;
113
- }
114
- }
115
-
116
- const NAMESPACE_SEPARATOR = '.';
117
- const HANDSHAKE_MESSAGES = {
118
- REQUEST_BOOT: 'requestBoot',
119
- SETUP: 'setup',
120
- WEBSITE_READY: 'websiteReady',
121
- };
122
- const getConfiguratorSettings = async (configuratorId, initData) => {
123
- if (typeof configuratorId !== 'string') {
124
- throw new Error('Configurator ID is not a string type: "' + (typeof configuratorId) + '"');
125
- }
126
- const server = initData.customApiUrl ? initData.customApiUrl : 'https://api.roomle.com/v2';
127
- const currentTenant = initData.overrideTenant || 9;
128
- const url = server + '/configurators/' + configuratorId;
129
- const apiKey = 'roomle_portal_v2';
130
- const token = '03-' + window.btoa((new Date()).toISOString() + ';anonymous;' + apiKey);
131
- const createHeaders = () => {
132
- const headers = {
133
- apiKey,
134
- currentTenant,
135
- locale: 'en',
136
- language: 'en',
137
- device: 1,
138
- token,
139
- platform: 'web',
140
- };
141
- return new Headers(headers);
142
- };
143
- const request = new Request(url, {
144
- method: 'GET',
145
- headers: createHeaders(),
146
- mode: 'cors',
147
- cache: 'default',
148
- });
149
- const response = await fetch(request);
150
- const { configurator } = await response.json();
151
- return configurator;
152
- };
153
-
154
- const isInIframe = () => {
155
- try {
156
- return window.self !== window.top;
157
- }
158
- catch (e) {
159
- return true;
160
- }
161
- };
162
-
163
- const NAMES_FOR_LOCALHOST = [
164
- '127.0.0.1',
165
- 'localhost',
166
- '0.0.0.0',
167
- ];
168
- const getHostname = () => {
169
- const isIframe = isInIframe();
170
- let url = window.location.href;
171
- if (isIframe) {
172
- if (!document.referrer) {
173
- return null;
174
- }
175
- url = document.referrer;
176
- }
177
- const { hostname } = new URL(url);
178
- return hostname;
179
- };
180
- const isDemoHostname = (hostname) => {
181
- if (NAMES_FOR_LOCALHOST.includes(hostname)) {
182
- return true;
183
- }
184
- if (hostname.endsWith('roomle.com')) {
185
- return true;
186
- }
187
- // exception for CI builds
188
- if (hostname.endsWith('gitlab.io') || hostname.endsWith('gitlab.com')) {
189
- return true;
190
- }
191
- return false;
192
- };
193
-
194
- /**
195
- * Recursively merge properties of two objects.
196
- * If a property exists in both it, property of obj2 is used.
197
- * Returns a new object (copy)
198
- * @param obj1
199
- * @param obj2
200
- */
201
- const deepMergeCopy = (obj1, obj2) => {
202
- const result = JSON.parse(JSON.stringify(obj1));
203
- return deepMerge(result, obj2);
204
- };
205
- /**
206
- * Recursively merge properties of two objects.
207
- * If a property exists in both it, property of obj2 is used.
208
- * Warning: This returns obj1 and not a copy!
209
- * @param obj1
210
- * @param obj2
211
- */
212
- const deepMerge = (obj1, obj2) => {
213
- // tslint:disable-next-line
214
- for (const p in obj2) {
215
- try {
216
- // Property in destination object set; update its value.
217
- if (obj2[p].constructor === Object) {
218
- obj1[p] = deepMerge(obj1[p], obj2[p]);
219
- }
220
- else {
221
- obj1[p] = obj2[p];
222
- }
223
- }
224
- catch (e) {
225
- // Property in destination object not set; create it and set its value.
226
- obj1[p] = obj2[p];
227
- }
228
- }
229
- return obj1;
230
- };
231
-
232
- const BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN = ['language', 'browserLanguage', 'userLanguage', 'systemLanguage'];
233
- const getLanguage = (lang = null) => {
234
- const navigator = window.navigator;
235
- if (lang) {
236
- return lang.substr(0, 2);
237
- }
238
- if (Array.isArray(navigator.languages) && navigator.languages.length > 0) {
239
- return navigator.languages[0].substr(0, 2);
240
- }
241
- for (let i = 0, length = BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN.length; i < length; i++) {
242
- const language = navigator[BROWSER_LANGUAGE_PROPERTY_KEYS_KNOWN[i]];
243
- if (language) {
244
- return language.substr(0, 2);
245
- }
246
- }
247
- return 'en';
248
- };
249
-
250
- const CONFIGURATOR_IDLE = '(idle)';
251
- const castAndFixInitData = (initData) => {
252
- castInitData(initData);
253
- if (initData === null || initData === void 0 ? void 0 : initData.customApiUrl) {
254
- initData.customApiUrl = decodeURIComponent(initData.customApiUrl);
255
- }
256
- if (initData.shareUrl) {
257
- initData.deeplink = initData.shareUrl.replace(LEGACY_SHARE_PLACEHOLDER, SHARE_PLACEHOLDER);
258
- }
259
- return initData;
260
- };
261
- const castInitData = (obj) => {
262
- if (!obj) {
263
- return;
264
- }
265
- const keys = Object.keys(obj);
266
- for (const key of keys) {
267
- const value = obj[key];
268
- // need to type-check for null because typeof null evaluates to object
269
- // see here why this is like it is: https://2ality.com/2013/10/typeof-null.html
270
- if (!Array.isArray(value) && typeof value === 'object' && value !== null) {
271
- return castInitData(value);
272
- }
273
- if (Array.isArray(value)) {
274
- for (const entry of value) {
275
- castInitData(entry);
276
- }
277
- return;
278
- }
279
- if (value === 'true' || value === 'false') {
280
- obj[key] = value === 'true';
281
- }
282
- }
283
- };
284
- const mergeInitData = (configuratorSettings, currentInitData) => {
285
- currentInitData.configuratorId = configuratorSettings.id;
286
- const remoteInitData = configuratorSettings.settings || {};
287
- // This is a performance optimization so we do not need to fetch
288
- // configurator settings twice
289
- if (!currentInitData.overrideTenant && configuratorSettings.tenant) {
290
- // use as any because we send tenant id as string but SDK requires to send a number
291
- // casting to number could become a problem when we change tenant IDs to something
292
- // random instead of a integer which is incremented
293
- currentInitData.overrideTenant = configuratorSettings.tenant;
294
- }
295
- return deepMergeCopy(remoteInitData, currentInitData);
296
- };
297
- const getFallbackInitData = () => {
298
- const fallbackInitData = {};
299
- if (!fallbackInitData.locale) {
300
- fallbackInitData.locale = getLanguage();
301
- }
302
- if (fallbackInitData.id === CONFIGURATOR_IDLE) {
303
- delete fallbackInitData.id;
304
- }
305
- const hostname = getHostname();
306
- if (hostname && isDemoHostname(hostname)) {
307
- fallbackInitData.configuratorId = 'demoConfigurator';
308
- }
309
- fallbackInitData.customApiUrl = 'https://www.roomle.com/api/v2';
310
- fallbackInitData.emails = false;
311
- return fallbackInitData;
312
- };
313
- const LEGACY_SHARE_PLACEHOLDER = '<CONF_ID>';
314
- const SHARE_PLACEHOLDER = '#CONFIGURATIONID#';
315
-
316
- // see why: so#/58065241/10800831
317
- const isAndroid = () => /(android)/i.test(navigator.userAgent);
318
-
319
- const setDefaultBehaviour = (object, callbackName, defaultBehaviour) => {
320
- let customBehaviour = null;
321
- Object.defineProperty(object, callbackName, {
322
- get() {
323
- return customBehaviour || defaultBehaviour;
324
- },
325
- set(data) {
326
- if (!(data === null || data === void 0 ? void 0 : data.mute)) {
327
- console.warn('You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties');
328
- console.warn('{ mute: true, value: () => void }');
329
- customBehaviour = data;
330
- }
331
- else {
332
- customBehaviour = data.value;
333
- }
334
- },
335
- });
336
- };
337
- const calcVh = () => (window.innerHeight * 0.01) + 'px'; // needed because of URL bar in android, inspired by: https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
338
- const setCustomProp = (element) => {
339
- if (!element) {
340
- return;
341
- }
342
- // Needed to wait for the next run loop otherwise data is wrong
343
- setTimeout(() => element.style.setProperty(RML_CUSTOM_PROPERTY_HEIGHT, calcVh()), 0);
344
- };
345
- const RML_STYLES_ID = 'rml-styles';
346
- const RML_ANIMATION_DELAY = 450;
347
- const RML_CUSTOM_PROPERTY_HEIGHT = '--rml-full-height';
348
- const RML_CSS_CLASSES = {
349
- CONTAINER: 'rml-container',
350
- FILL: 'rml-fill',
351
- POSITION: 'rml-pos',
352
- TRANSITION: 'rml-transition',
353
- ANDROID_HEIGHT: 'rml-android-height',
354
- OVERFLOW_HIDDEN: 'rml-overflow-hidden',
355
- };
356
- const globalSetupDone = new Map();
357
- class RoomleEmbeddingApi {
358
- constructor(settings, container, initData, waitForIframe) {
359
- this.ui = {
360
- callbacks: null,
361
- };
362
- this.extended = {
363
- callbacks: null,
364
- };
365
- this.analytics = {
366
- callbacks: {},
367
- };
368
- this.global = {
369
- callbacks: {},
370
- };
371
- this._initData = {};
372
- if (!settings || typeof settings.id !== 'string') {
373
- throw new Error('Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person');
374
- }
375
- if (globalSetupDone.has(container)) {
376
- throw new Error('There is already an instance on this DOM element');
377
- }
378
- const stylesAlreadyAdded = !!document.getElementById(RML_STYLES_ID);
379
- if (!stylesAlreadyAdded) {
380
- const zIndex = initData.zIndex || 9999999;
381
- const styles = document.createElement('style');
382
- styles.type = 'text/css';
383
- styles.id = RML_STYLES_ID;
384
- const cssTransition = 'transition:all ease-in-out ' + RML_ANIMATION_DELAY + 'ms;';
385
- const cssTransitionForAllBrowsers = ['-webkit-', '-o-'].reduce((acc, browser) => acc += browser + cssTransition, '') + cssTransition;
386
- const vh = calcVh();
387
- styles.innerHTML = `
388
- .${RML_CSS_CLASSES.CONTAINER}{${RML_CUSTOM_PROPERTY_HEIGHT}:${vh};}
389
- .${RML_CSS_CLASSES.POSITION}{position:fixed;top:0;left:0;z-index:${zIndex};opacity:0}
390
- .${RML_CSS_CLASSES.TRANSITION}{${cssTransitionForAllBrowsers}}
391
- .${RML_CSS_CLASSES.FILL}{width:100%;height:100%;opacity:1}
392
- .${RML_CSS_CLASSES.ANDROID_HEIGHT}{height:calc(var(${RML_CUSTOM_PROPERTY_HEIGHT},1vh)*100)}
393
- .${RML_CSS_CLASSES.OVERFLOW_HIDDEN}{overflow:hidden}
394
- `;
395
- document.head.appendChild(styles);
396
- }
397
- this._onResize = this._onResize.bind(this);
398
- if (isAndroid()) {
399
- window.addEventListener('resize', this._onResize);
400
- }
401
- this._container = container;
402
- this._initData = initData;
403
- this._configuratorSettings = settings;
404
- const iframe = this._createIframe();
405
- this._onUseFullPage = this._onUseFullPage.bind(this);
406
- this._executeMessage = this._executeMessage.bind(this);
407
- this._onBackToWebsite = this._onBackToWebsite.bind(this);
408
- this._messageHandler = new MessageHandler('website', window, null, this._executeMessage);
409
- this._waitForIframe = waitForIframe;
410
- this._container.appendChild(iframe);
411
- this._iframe = iframe;
412
- globalSetupDone.set(container, true);
413
- }
414
- static createPlanner(configuratorId, container, initData) {
415
- return this._create(configuratorId, container, initData);
416
- }
417
- /**
418
- * Method to create a new instance of a Roomle Configurator
419
- * @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
420
- * @param container DOM container in which the configurator should be placed
421
- * @param initData settings with which the configurator should be started
422
- */
423
- static createConfigurator(configuratorId, container, initData) {
424
- return this._create(configuratorId, container, initData);
425
- }
426
- /**
427
- * Method to create a new instance of a Roomle Configurator
428
- * @deprecated please use "createConfigurator"
429
- * @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
430
- * @param container DOM container in which the configurator should be placed
431
- * @param initData settings with which the configurator should be started
432
- */
433
- static create(configuratorId, container, initData) {
434
- return this._create(configuratorId, container, initData);
435
- }
436
- /**
437
- * Method to create a new instance of a Roomle Viewer
438
- * @param configuratorId the id which identifies your configurator, you will get this ID from your Roomle Contact Person
439
- * @param container DOM container in which the configurator should be placed
440
- * @param initData settings with which the configurator should be started
441
- */
442
- static createViewer(configuratorId, container, initData) {
443
- return this._create(configuratorId, container, initData);
444
- }
445
- static _create(configuratorId, container, initData) {
446
- return new Promise(async (resolve, reject) => {
447
- try {
448
- const fallbackInitData = deepMerge(getFallbackInitData(), castAndFixInitData(initData));
449
- if (!fallbackInitData.featureFlags) {
450
- fallbackInitData.featureFlags = {};
451
- }
452
- if (typeof fallbackInitData.featureFlags.realPartList !== 'boolean') {
453
- fallbackInitData.featureFlags.realPartList = true;
454
- }
455
- if (typeof fallbackInitData.featureFlags.globalCallbacks !== 'boolean') {
456
- fallbackInitData.featureFlags.globalCallbacks = true;
457
- }
458
- const configuratorSettings = await getConfiguratorSettings(configuratorId, fallbackInitData);
459
- initData = mergeInitData(configuratorSettings, fallbackInitData);
460
- return new this(configuratorSettings, container, initData, resolve);
461
- }
462
- catch (e) {
463
- return reject(e);
464
- }
465
- });
466
- }
467
- teardown() {
468
- if (this._container) {
469
- globalSetupDone.delete(this._container);
470
- }
471
- const iframe = this._container.querySelector('iframe');
472
- if (iframe) {
473
- this._container.removeChild(iframe);
474
- }
475
- window.removeEventListener('resize', this._onResize);
476
- }
477
- _createIframe() {
478
- var _a;
479
- const iframe = document.createElement('iframe');
480
- let url = ((_a = this._configuratorSettings) === null || _a === void 0 ? void 0 : _a.url) || 'https://www.roomle.com/t/cp/';
481
- if (this._initData.useLocalRoomle) {
482
- url = location.href.replace('embedding.html', '');
483
- }
484
- if (location.href.includes('roomle.gitlab.io')) {
485
- url = location.href.replace('embedding.html', 'index.html');
486
- }
487
- if (this._initData.overrideServerUrl) {
488
- url = this._initData.overrideServerUrl;
489
- }
490
- iframe.src = url;
491
- iframe.classList.add(RML_CSS_CLASSES.CONTAINER);
492
- iframe.classList.add(RML_CSS_CLASSES.FILL);
493
- return iframe;
494
- }
495
- _onResize() {
496
- setCustomProp(this._iframe);
497
- }
498
- _onUseFullPage() {
499
- this._iframe.classList.add(RML_CSS_CLASSES.POSITION);
500
- document.documentElement.classList.add(RML_CSS_CLASSES.OVERFLOW_HIDDEN);
501
- window.document.body.classList.add(RML_CSS_CLASSES.OVERFLOW_HIDDEN);
502
- if (isAndroid()) {
503
- setCustomProp(this._iframe);
504
- this._iframe.classList.add(RML_CSS_CLASSES.ANDROID_HEIGHT);
505
- }
506
- }
507
- _onBackToWebsite() {
508
- this._iframe.classList.remove(RML_CSS_CLASSES.POSITION);
509
- this._iframe.classList.remove(RML_CSS_CLASSES.ANDROID_HEIGHT);
510
- document.documentElement.classList.remove(RML_CSS_CLASSES.OVERFLOW_HIDDEN);
511
- window.document.body.classList.remove(RML_CSS_CLASSES.OVERFLOW_HIDDEN);
512
- }
513
- _executeMessage({ message, args }, event) {
514
- var _a;
515
- if (!event.source) {
516
- // @ts-ignore
517
- return; // no source? just wait ;-)
518
- }
519
- if (event.source !== ((_a = this._iframe) === null || _a === void 0 ? void 0 : _a.contentWindow)) {
520
- // @ts-ignore
521
- return; // need to wait since response is not for the current iframe;
522
- }
523
- if (message === HANDSHAKE_MESSAGES.REQUEST_BOOT) {
524
- this._messageHandler.setOutgoingMessageBus(event.source);
525
- return Promise.resolve({ result: this._initData });
526
- }
527
- if (message === HANDSHAKE_MESSAGES.SETUP) {
528
- const { methods, callbacks } = args[0];
529
- methods.forEach((method) => {
530
- const namespaces = method.split(NAMESPACE_SEPARATOR);
531
- const object = namespaces[0];
532
- const methodName = namespaces[1];
533
- if (!this[object]) {
534
- this[object] = {};
535
- }
536
- this[object][methodName] = function () {
537
- // @todo -- this was the fix that values are passed to caller, e.g.: interface.extended.getParametersOfRootComponent
538
- // most of the things we need for a meaningful test are not available in JEST (since it runs in node). We should
539
- // write a Cypress test for it
540
- return this._messageHandler.sendMessage(method, [...arguments]);
541
- }.bind(this);
542
- });
543
- callbacks.forEach((callback) => {
544
- const namespaces = callback.split(NAMESPACE_SEPARATOR);
545
- const object = namespaces[0];
546
- const callbacksName = namespaces[1];
547
- const eventName = namespaces[2];
548
- if (!this[object]) {
549
- this[object] = {};
550
- }
551
- if (!this[object][callbacksName]) {
552
- this[object][callbacksName] = {};
553
- }
554
- // @ts-ignore
555
- this[object][callbacksName][eventName] = () => undefined;
556
- });
557
- setDefaultBehaviour(this.ui.callbacks, 'onUseFullPage', this._onUseFullPage);
558
- setDefaultBehaviour(this.ui.callbacks, 'onBackToWebsite', this._onBackToWebsite);
559
- this._waitForIframe(this);
560
- setTimeout(() => this._messageHandler.sendMessage(HANDSHAKE_MESSAGES.WEBSITE_READY), 0); // Run it after the promise is resolved so everyone can subscribe
561
- return Promise.resolve({ result: null });
562
- }
563
- const messageNamespaces = message.split(NAMESPACE_SEPARATOR);
564
- const namespace = messageNamespaces[0];
565
- const objectOfAction = messageNamespaces[1];
566
- const methodOfAction = (messageNamespaces.length === 3) ? messageNamespaces[2] : null;
567
- if (methodOfAction) {
568
- if (this[namespace][objectOfAction][methodOfAction]) {
569
- const result = this[namespace][objectOfAction][methodOfAction](...args);
570
- if (result instanceof Promise) {
571
- return result.then((data) => ({ result: data }));
572
- }
573
- else if (result !== undefined) {
574
- return Promise.resolve({ result });
575
- }
576
- return Promise.resolve({ result: null });
577
- }
578
- }
579
- return Promise.reject('Message "' + message + '" is unkown');
580
- }
581
- }
582
-
583
- export { RoomleEmbeddingApi as default };
@@ -1 +0,0 @@
1
- class t{constructor(t,e,r,s){this.t=null,this.s=null,this.i=t,this.o=e,this.t=r,this.s=s,this.o.addEventListener("message",this.l.bind(this))}setOutgoingMessageBus(t){this.t=t}setMessageExecution(t){this.s=t}sendMessage(t,e=[]){return new Promise((r,s)=>{const i=new MessageChannel;i.port1.onmessage=t=>{if(!t||!t.data)return i.port1.close(),i.port2.close(),s(new Error(this.i+" received message but response can not be interpreted"));let e;try{e=JSON.parse(t.data)}catch(t){return i.port1.close(),i.port2.close(),this.h(t),s(t)}e.error?s(e.error):void 0!==e.result?r(e.result):r(),i.port1.close(),i.port2.close()};let o="";try{o=JSON.stringify({message:t,args:e})}catch(t){return s(new Error(this.i+": can not create command because it is not JSON.stringify able"))}if(!this.t)return s(new Error(this.i+": outgoing bus not set yet"));this.t.postMessage(o,"*",[i.port2])})}l(t){const e=t.ports&&Array.isArray(t.ports)&&t.ports.length>0?t.ports[0]:null;if(t.data&&e)try{const r=JSON.parse(t.data);if(!this.s)return e.postMessage(JSON.stringify({error:this.i+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);const s=this.s(r,t);if(void 0===s)return;s.then((t={})=>{let r=void 0,s=void 0;"object"==typeof t&&null!==t&&(r=t.error,s=t.result),r?e.postMessage(JSON.stringify({error:r})):void 0!==s?e.postMessage(JSON.stringify({result:s})):e.postMessage(JSON.stringify({result:t}))},t=>{e.postMessage(JSON.stringify({error:this.h(t)}))})}catch(t){e.postMessage(JSON.stringify({error:this.h(t)}))}}h(t){if("string"==typeof t){const e=this.i+": "+t;return console.error(e),e}return t.message=this.i+": "+t.message,console.error(t),t.message}}const e=["127.0.0.1","localhost","0.0.0.0"],r=(t,e)=>{for(const s in e)try{e[s].constructor===Object?t[s]=r(t[s],e[s]):t[s]=e[s]}catch(r){t[s]=e[s]}return t},s=["language","browserLanguage","userLanguage","systemLanguage"],i=t=>{if(!t)return;const e=Object.keys(t);for(const r of e){const e=t[r];if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return i(e);if(Array.isArray(e)){for(const t of e)i(t);return}"true"!==e&&"false"!==e||(t[r]="true"===e)}},o=()=>/(android)/i.test(navigator.userAgent),n=(t,e,r)=>{let s=null;Object.defineProperty(t,e,{get:()=>s||r,set(t){(null==t?void 0:t.mute)?s=t.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=t)}})},a=()=>.01*window.innerHeight+"px",l=t=>{t&&setTimeout(()=>t.style.setProperty(h,a()),0)},h="--rml-full-height",c=new Map;class u{constructor(e,r,s,i){if(this.ui={callbacks:null},this.extended={callbacks:null},this.analytics={callbacks:{}},this.global={callbacks:{}},this.u={},!e||"string"!=typeof e.id)throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(c.has(r))throw new Error("There is already an instance on this DOM element");if(!document.getElementById("rml-styles")){const t=s.zIndex||9999999,e=document.createElement("style");e.type="text/css",e.id="rml-styles";const r="transition:all ease-in-out 450ms;",i=["-webkit-","-o-"].reduce((t,e)=>t+(e+r),"")+r,o=a();e.innerHTML=`\n .rml-container{${h}:${o};}\n .rml-pos{position:fixed;top:0;left:0;z-index:${t};opacity:0}\n .rml-transition{${i}}\n .rml-fill{width:100%;height:100%;opacity:1}\n .rml-android-height{height:calc(var(${h},1vh)*100)}\n .rml-overflow-hidden{overflow:hidden}\n `,document.head.appendChild(e)}this.m=this.m.bind(this),o()&&window.addEventListener("resize",this.m),this.g=r,this.u=s,this.p=e;const n=this.v();this.O=this.O.bind(this),this.N=this.N.bind(this),this.P=this.P.bind(this),this._=new t("website",window,null,this.N),this.J=i,this.g.appendChild(n),this.S=n,c.set(r,!0)}static createPlanner(t,e,r){return this.k(t,e,r)}static createConfigurator(t,e,r){return this.k(t,e,r)}static create(t,e,r){return this.k(t,e,r)}static createViewer(t,e,r){return this.k(t,e,r)}static k(t,o,n){return new Promise(async(a,l)=>{try{const l=r((()=>{const t={};t.locale||(t.locale=((t=null)=>{const e=window.navigator;if(t)return t.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let t=0,r=s.length;t<r;t++){const r=e[s[t]];if(r)return r.substr(0,2)}return"en"})()),"(idle)"===t.id&&delete t.id;const r=(()=>{const t=(()=>{try{return window.self!==window.top}catch(t){return!0}})();let e=window.location.href;if(t){if(!document.referrer)return null;e=document.referrer}const{hostname:r}=new URL(e);return r})();return r&&(t=>!!e.includes(t)||!!t.endsWith("roomle.com")||!(!t.endsWith("gitlab.io")&&!t.endsWith("gitlab.com")))(r)&&(t.configuratorId="demoConfigurator"),t.customApiUrl="https://www.roomle.com/api/v2",t.emails=!1,t})(),(t=>(i(t),(null==t?void 0:t.customApiUrl)&&(t.customApiUrl=decodeURIComponent(t.customApiUrl)),t.shareUrl&&(t.deeplink=t.shareUrl.replace("<CONF_ID>","#CONFIGURATIONID#")),t))(n));l.featureFlags||(l.featureFlags={}),"boolean"!=typeof l.featureFlags.realPartList&&(l.featureFlags.realPartList=!0),"boolean"!=typeof l.featureFlags.globalCallbacks&&(l.featureFlags.globalCallbacks=!0);const h=await(async(t,e)=>{if("string"!=typeof t)throw new Error('Configurator ID is not a string type: "'+typeof t+'"');const r=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",s=e.overrideTenant||9,i=r+"/configurators/"+t,o="03-"+window.btoa((new Date).toISOString()+";anonymous;roomle_portal_v2"),n=new Request(i,{method:"GET",headers:new Headers({apiKey:"roomle_portal_v2",currentTenant:s,locale:"en",language:"en",device:1,token:o,platform:"web"}),mode:"cors",cache:"default"}),a=await fetch(n),{configurator:l}=await a.json();return l})(t,l);return n=((t,e)=>{e.configuratorId=t.id;const s=t.settings||{};return!e.overrideTenant&&t.tenant&&(e.overrideTenant=t.tenant),((t,e)=>{const s=JSON.parse(JSON.stringify(t));return r(s,e)})(s,e)})(h,l),new this(h,o,n,a)}catch(t){return l(t)}})}teardown(){this.g&&c.delete(this.g);const t=this.g.querySelector("iframe");t&&this.g.removeChild(t),window.removeEventListener("resize",this.m)}v(){var t;const e=document.createElement("iframe");let r=(null===(t=this.p)||void 0===t?void 0:t.url)||"https://www.roomle.com/t/cp/";return this.u.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this.u.overrideServerUrl&&(r=this.u.overrideServerUrl),e.src=r,e.classList.add("rml-container"),e.classList.add("rml-fill"),e}m(){l(this.S)}O(){this.S.classList.add("rml-pos"),document.documentElement.classList.add("rml-overflow-hidden"),window.document.body.classList.add("rml-overflow-hidden"),o()&&(l(this.S),this.S.classList.add("rml-android-height"))}P(){this.S.classList.remove("rml-pos"),this.S.classList.remove("rml-android-height"),document.documentElement.classList.remove("rml-overflow-hidden"),window.document.body.classList.remove("rml-overflow-hidden")}N({message:t,args:e},r){var s;if(!r.source)return;if(r.source!==(null===(s=this.S)||void 0===s?void 0:s.contentWindow))return;if("requestBoot"===t)return this._.setOutgoingMessageBus(r.source),Promise.resolve({result:this.u});if("setup"===t){const{methods:t,callbacks:r}=e[0];return t.forEach(t=>{const e=t.split("."),r=e[0],s=e[1];this[r]||(this[r]={}),this[r][s]=function(){return this._.sendMessage(t,[...arguments])}.bind(this)}),r.forEach(t=>{const e=t.split("."),r=e[0],s=e[1],i=e[2];this[r]||(this[r]={}),this[r][s]||(this[r][s]={}),this[r][s][i]=()=>{}}),n(this.ui.callbacks,"onUseFullPage",this.O),n(this.ui.callbacks,"onBackToWebsite",this.P),this.J(this),setTimeout(()=>this._.sendMessage("websiteReady"),0),Promise.resolve({result:null})}const i=t.split("."),o=i[0],a=i[1],l=3===i.length?i[2]:null;if(l&&this[o][a][l]){const t=this[o][a][l](...e);return t instanceof Promise?t.then(t=>({result:t})):void 0!==t?Promise.resolve({result:t}):Promise.resolve({result:null})}return Promise.reject('Message "'+t+'" is unkown')}}export{u as default};