@3dsource/metabox-modular-configurator-api 3.0.32 → 3.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -999,6 +999,12 @@ api.addEventListener('screenshotReady', (imageData: string | null) => {
999
999
  **Implementation Note:**
1000
1000
  Creates a temporary anchor element with `download` attribute to trigger browser download.
1001
1001
 
1002
+ **Accepted input:** only a base64 data URL of type `image/png`, `image/jpeg` or
1003
+ `image/webp` — the formats `GetScreenshot` produces. Anything else (a remote
1004
+ `https://` image, an `svg+xml` or `text/html` data URL) is ignored with a console
1005
+ warning instead of being downloaded, since this function is fed event payloads
1006
+ straight off the postMessage channel.
1007
+
1002
1008
  #### `fromCommunicatorEvent(target: Communicator, eventName: string): Observable`
1003
1009
 
1004
1010
  RxJS wrapper for Communicator events. Works like RxJS `fromEvent` — creates a typed Observable that emits each time the specified event fires. Alternative to `api.addEventListener()`.
@@ -1340,9 +1346,9 @@ If you're still experiencing issues:
1340
1346
  Run commands from the repository root:
1341
1347
 
1342
1348
  ```bash
1343
- pnpm --filter @3dsource/metabox-modular-configurator-api build
1344
- pnpm --filter @3dsource/metabox-modular-configurator-api generate:docs
1345
- pnpm release:package -- metabox-modular-configurator-api patch latest
1349
+ pnpm metabox-modular-configurator-api:build
1350
+ pnpm metabox-modular-configurator-api:docs
1351
+ pnpm metabox-modular-configurator-api:release:patch
1346
1352
  ```
1347
1353
 
1348
1354
  `generate:docs` writes HTML and Markdown API documentation into the demo build
@@ -1171,7 +1171,89 @@ const MetaboxDomain = 'metabox.3dsource.com';
1171
1171
  */
1172
1172
  const BasicRouteUrl = 'metabox-configurator/modular';
1173
1173
 
1174
- const VERSION = '3.0.32';
1174
+ const VERSION = '3.0.33';
1175
+
1176
+ /**
1177
+ * Sender checks for the host↔iframe `postMessage` channel.
1178
+ *
1179
+ * Deliberately not re-exported from `./index` — `public-api.ts` does
1180
+ * `export * from './lib/helpers'`, and these are internal plumbing.
1181
+ */
1182
+ /** Id of the iframe `integrateMetabox` creates; also the hand-rolled-embed contract. */
1183
+ const EmbeddedContentId = 'embeddedContent';
1184
+ /** `postMessage` targetOrigin meaning "any origin, deliver to that window". */
1185
+ const AnyOrigin = '*';
1186
+ /**
1187
+ * True iff `origin` can be used as a `postMessage` targetOrigin: a parseable
1188
+ * http/https origin *and nothing more*. Excludes `''` and the opaque `'null'`
1189
+ * origin (sandboxed frames, `file:`, `data:`), which are not valid targets, and
1190
+ * anything carrying a path, query or credentials — every real source here
1191
+ * (`URL#origin`, `MessageEvent#origin`) yields a bare origin, so a decorated
1192
+ * string means the value did not come from where we think it did.
1193
+ *
1194
+ * `postMessage` throws a `SyntaxError` on a malformed targetOrigin and silently
1195
+ * drops the message on a mismatched one, so this has to be checked up front.
1196
+ */
1197
+ function isTargetableOrigin(origin) {
1198
+ if (!origin || origin === AnyOrigin || origin === 'null') {
1199
+ return false;
1200
+ }
1201
+ let url;
1202
+ try {
1203
+ url = new URL(origin);
1204
+ }
1205
+ catch {
1206
+ return false;
1207
+ }
1208
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
1209
+ return false;
1210
+ }
1211
+ // `URL#origin` drops path/query/hash/credentials and normalises the default
1212
+ // port away, so this holds exactly for bare origins.
1213
+ return url.origin === origin;
1214
+ }
1215
+ /**
1216
+ * Decides whether an inbound `message` event may drive this Communicator.
1217
+ *
1218
+ * Before this gate the only check was `event.data.host === 'metabox'`, a string
1219
+ * anyone can write. That matters most inside the configurator itself, which runs
1220
+ * a Communicator in its own window for the embedded menu: without a sender check
1221
+ * the embedding page could forge configurator *events* (screenshots handed to
1222
+ * `saveImage`, catalogue/CTA data) that its own inbound guard is built to reject.
1223
+ *
1224
+ * The discriminator is `environment`, not the DOM: inside the configurator there
1225
+ * is no `#embeddedContent` element (it does not embed itself), so a purely
1226
+ * DOM-based check would fall through to "accept anything" and leave that exact
1227
+ * vector open.
1228
+ *
1229
+ * - `'metabox'` — the peer is the same document, so only this window qualifies.
1230
+ * Nothing here reads the DOM, so renaming an element cannot weaken it.
1231
+ * - `'host'` — the peer is our iframe. When we have no handle on one, fall back
1232
+ * to the same-window channel, mirroring `sendCommandToMetabox`, which posts to
1233
+ * this window when it finds no iframe. Accepting that case keeps hand-rolled
1234
+ * embeds working; a hard refusal would silently kill the API on those sites,
1235
+ * which is how a domain allowlist broke this channel once already.
1236
+ */
1237
+ function acceptsMessageFrom(event, environment, iframe) {
1238
+ const sameWindow = event.source === window && event.origin === window.location.origin;
1239
+ if (environment === 'metabox') {
1240
+ return sameWindow;
1241
+ }
1242
+ const own = resolveIframe(iframe)?.contentWindow;
1243
+ return own ? event.source === own : sameWindow;
1244
+ }
1245
+ /**
1246
+ * The iframe this Communicator talks to: the one the integration created while
1247
+ * it is still in the document, else whatever currently holds the contract id.
1248
+ * `isConnected` matters because a superseding `integrateMetabox` call removes the
1249
+ * previous iframe, and a detached one would otherwise shadow the live element.
1250
+ */
1251
+ function resolveIframe(iframe) {
1252
+ if (iframe?.isConnected) {
1253
+ return iframe;
1254
+ }
1255
+ return document.getElementById(EmbeddedContentId);
1256
+ }
1175
1257
 
1176
1258
  const communicatorMap = new Map();
1177
1259
  /**
@@ -1198,12 +1280,24 @@ class Communicator extends EventDispatcher {
1198
1280
  * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
1199
1281
  * @internal
1200
1282
  */
1201
- constructor(data, environment, config) {
1283
+ constructor(data, environment, config, connection) {
1202
1284
  super();
1203
1285
  /**
1204
1286
  * Bound handler for incoming postMessage events.
1205
1287
  */
1206
1288
  this.binder = this.handleMessageReceived.bind(this);
1289
+ /** Keeps the "rejected an inbound message" warning to one per instance. */
1290
+ this.senderRejectionReported = false;
1291
+ /** Keeps the "unknown configurator origin" warning to one per instance. */
1292
+ this.wildcardTargetReported = false;
1293
+ /** Keeps the "our iframe left the document" warning to one per instance. */
1294
+ this.staleFrameReported = false;
1295
+ // Assigned before the listener goes up: the gate reads all three.
1296
+ this.environment = environment;
1297
+ this.iframe = connection?.iframe ?? null;
1298
+ this.targetOrigin = isTargetableOrigin(connection?.origin)
1299
+ ? connection.origin
1300
+ : null;
1207
1301
  const { appId = 'unknown', version = VERSION } = data ?? {};
1208
1302
  const key = `${version}_${environment}_${appId}`;
1209
1303
  communicatorMap.get(key)?.instance.destroy(key);
@@ -1220,22 +1314,65 @@ class Communicator extends EventDispatcher {
1220
1314
  * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
1221
1315
  * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
1222
1316
  * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
1317
+ * @param {CommunicatorConnection} connection - the iframe and origin `integrateMetabox`
1318
+ * built, so the handshake can be attributed and later messages addressed precisely.
1319
+ * Omitted by hand-rolled embeds, which are then identified through the
1320
+ * `embeddedContent` id and the handshake's own origin.
1223
1321
  * @returns A cancel function that removes the handshake `message` listener.
1224
1322
  * `integrateMetabox` (the public entry point) calls this automatically when
1225
1323
  * a new integration supersedes a still-pending one, so direct internal
1226
1324
  * callers only need it for explicit early teardown. Idempotent.
1227
1325
  */
1228
- static createInstance(apiReadyCallback, environment, config) {
1326
+ static createInstance(apiReadyCallback, environment, config, connection) {
1327
+ const iframe = connection?.iframe ?? null;
1328
+ // The handshake listener outlives every rejected message, so the report is
1329
+ // kept to one: a page that keeps announcing itself must not flood the
1330
+ // console of the site embedding us.
1331
+ let rejectionReported = false;
1229
1332
  const startHandler = (event) => {
1230
1333
  const message = event.data;
1231
- if (message?.envelope?.action === AppLoaded && message.host === Metabox) {
1232
- apiReadyCallback(new Communicator(message.envelope.payload, environment, config));
1233
- window.removeEventListener('message', startHandler);
1334
+ if (message?.envelope?.action !== AppLoaded || message.host !== Metabox) {
1335
+ return;
1234
1336
  }
1337
+ // The handshake decides who we hand the API to and which appId keys the
1338
+ // registry, so it is gated exactly like every later message.
1339
+ if (!acceptsMessageFrom(event, environment, iframe)) {
1340
+ if (!rejectionReported) {
1341
+ rejectionReported = true;
1342
+ console.warn(`Metabox: ignored an "${AppLoaded}" handshake from an unexpected sender.`);
1343
+ }
1344
+ return;
1345
+ }
1346
+ apiReadyCallback(new Communicator(message.envelope.payload, environment, config, {
1347
+ iframe,
1348
+ origin: Communicator.resolveHandshakeOrigin(event, connection),
1349
+ }));
1350
+ window.removeEventListener('message', startHandler);
1235
1351
  };
1236
1352
  window.addEventListener('message', startHandler);
1237
1353
  return () => window.removeEventListener('message', startHandler);
1238
1354
  }
1355
+ /**
1356
+ * The origin to address the configurator by, decided once from the handshake.
1357
+ *
1358
+ * Prefers what `integrateMetabox` computed from the iframe URL, but yields to
1359
+ * the origin the handshake actually came from when the two disagree: a redirect
1360
+ * (a `config.domain` override pointing at a host that 30x's elsewhere) would
1361
+ * otherwise pin an origin nothing answers on, and every command would be
1362
+ * dropped silently. The sender already passed the window gate, so this cannot
1363
+ * be steered by an unrelated page.
1364
+ */
1365
+ static resolveHandshakeOrigin(event, connection) {
1366
+ const expected = isTargetableOrigin(connection?.origin)
1367
+ ? connection.origin
1368
+ : null;
1369
+ const actual = isTargetableOrigin(event.origin) ? event.origin : null;
1370
+ if (expected && actual && expected !== actual) {
1371
+ console.warn(`Metabox: the configurator answered from ${actual} but was embedded from ${expected}; using ${actual}.`);
1372
+ return actual;
1373
+ }
1374
+ return expected ?? actual;
1375
+ }
1239
1376
  /**
1240
1377
  * Cleans up resources and stops listening for messages.
1241
1378
  */
@@ -1264,7 +1401,8 @@ class Communicator extends EventDispatcher {
1264
1401
  */
1265
1402
  sendCommandToMetabox(command) {
1266
1403
  const { data } = command;
1267
- const iframe = document.getElementById('embeddedContent');
1404
+ const iframe = resolveIframe(this.iframe);
1405
+ this.reportStaleFrame();
1268
1406
  const toMetaboxMessage = {
1269
1407
  host: MetaboxHost,
1270
1408
  envelope: { ...data },
@@ -1276,10 +1414,54 @@ class Communicator extends EventDispatcher {
1276
1414
  };
1277
1415
  if (!iframe?.contentWindow) {
1278
1416
  console.warn('Metabox IFrame not found or not ready. Message sends to the same window');
1279
- window.postMessage(toMetaboxMessage, '*');
1417
+ // Same-window channel. '/' means "only deliver if the receiver's origin
1418
+ // equals mine", which is exactly the intent and, unlike
1419
+ // `window.location.origin`, also holds for an opaque origin: a page under
1420
+ // `sandbox="allow-scripts"` reports the origin as the string "null",
1421
+ // which is not a valid targetOrigin and makes postMessage throw.
1422
+ window.postMessage(toMetaboxMessage, '/');
1423
+ return;
1424
+ }
1425
+ iframe.contentWindow.postMessage(toMetaboxMessage, this.resolveTarget());
1426
+ }
1427
+ /**
1428
+ * A superseding `integrateMetabox` call removes the iframe this handle was
1429
+ * built for. Commands then fall through to whatever now holds the contract id,
1430
+ * addressed by the origin pinned for the *old* integration — so if the new one
1431
+ * points at a different origin, the browser drops them without a word. The
1432
+ * handle is stale at that point and should be replaced by the one from the new
1433
+ * integration; say so rather than letting it fail quietly.
1434
+ */
1435
+ reportStaleFrame() {
1436
+ if (!this.iframe || this.iframe.isConnected || this.staleFrameReported) {
1280
1437
  return;
1281
1438
  }
1282
- iframe.contentWindow.postMessage(toMetaboxMessage, '*');
1439
+ this.staleFrameReported = true;
1440
+ console.warn('Metabox: the iframe this API handle was created for has left the document. ' +
1441
+ 'Commands are being sent to the current #embeddedContent instead — use the handle ' +
1442
+ 'from the latest integrateMetabox() call.');
1443
+ }
1444
+ /**
1445
+ * `targetOrigin` for the iframe. The very first command is `metaboxConfig`,
1446
+ * which carries `hostUrl: location.href` — on a shop page that routinely holds
1447
+ * order ids and session parameters — so it must not be broadcast to whatever
1448
+ * document currently occupies the frame.
1449
+ *
1450
+ * Falls back to a wildcard rather than refusing to send: this leg carries
1451
+ * commands, and a configurator that silently stops responding on a customer
1452
+ * site is worse than the status quo. The fallback is reported once so it does
1453
+ * not pass unnoticed.
1454
+ */
1455
+ resolveTarget() {
1456
+ if (this.targetOrigin) {
1457
+ return this.targetOrigin;
1458
+ }
1459
+ if (!this.wildcardTargetReported) {
1460
+ this.wildcardTargetReported = true;
1461
+ console.warn('Metabox: the configurator origin is unknown, so commands are broadcast. ' +
1462
+ 'Use integrateMetabox() to have it pinned.');
1463
+ }
1464
+ return AnyOrigin;
1283
1465
  }
1284
1466
  /**
1285
1467
  * Registers an event listener for messages dispatched by the Metabox.
@@ -1316,6 +1498,18 @@ class Communicator extends EventDispatcher {
1316
1498
  if (event.data?.host !== Metabox) {
1317
1499
  return;
1318
1500
  }
1501
+ // `host` is a string anyone can write, so it says nothing about who sent
1502
+ // this. Everything below dispatches configurator events to application
1503
+ // listeners — screenshots, catalogue and CTA data — so the sender is checked
1504
+ // before any of it runs.
1505
+ if (!acceptsMessageFrom(event, this.environment, this.iframe)) {
1506
+ if (!this.senderRejectionReported) {
1507
+ this.senderRejectionReported = true;
1508
+ console.warn(`Metabox: ignored a "${Metabox}" message from an unexpected sender ` +
1509
+ `(environment: ${this.environment}). Events are only accepted from the configurator.`);
1510
+ }
1511
+ return;
1512
+ }
1319
1513
  const data = event.data?.envelope;
1320
1514
  this.dispatchEvent(data?.eventType, data?.payload);
1321
1515
  }
@@ -1485,9 +1679,17 @@ function integrateMetabox(configuratorId, containerId, apiReadyCallback, config)
1485
1679
  if (existingIframe) {
1486
1680
  existingIframe.remove();
1487
1681
  }
1682
+ // Built before the handshake listener goes up so the Communicator can be told
1683
+ // which frame is ours and which origin to address it by. The element is still
1684
+ // detached here — `contentWindow` only exists once it is in the document, and
1685
+ // by then the handshake it is compared against has not happened yet.
1686
+ const iframe = document.createElement('iframe');
1488
1687
  // Supersede a prior integration still waiting for its handshake.
1489
1688
  cancelPendingHandshake?.();
1490
- const cancel = Communicator.createInstance(apiReadyCallback, 'host', config);
1689
+ const cancel = Communicator.createInstance(apiReadyCallback, 'host', config, {
1690
+ iframe,
1691
+ origin: parsedUrl.origin,
1692
+ });
1491
1693
  cancelPendingHandshake = cancel ?? null;
1492
1694
  // Inject the container rules once per containerId — repeated integrations
1493
1695
  // were appending identical <style> tags, forcing CSSOM reparses.
@@ -1505,7 +1707,6 @@ function integrateMetabox(configuratorId, containerId, apiReadyCallback, config)
1505
1707
  `;
1506
1708
  document.head.appendChild(style);
1507
1709
  }
1508
- const iframe = document.createElement('iframe');
1509
1710
  iframe.setAttribute('allow', 'autoplay; fullscreen; encrypted-media');
1510
1711
  iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');
1511
1712
  iframe.setAttribute('id', 'embeddedContent');
@@ -1537,10 +1738,22 @@ function integrateMetabox(configuratorId, containerId, apiReadyCallback, config)
1537
1738
  * Filename extension should match the MimeType passed to GetScreenshot.
1538
1739
  * Import: `import { saveImage } from '@3dsource/metabox-modular-configurator-api'`.
1539
1740
  *
1741
+ * Only the three data-URL formats the configurator actually produces are
1742
+ * accepted (`image/png`, `image/jpeg`, `image/webp`). The documented usage above
1743
+ * feeds this an event payload straight off the wire, and the body below sets
1744
+ * `href` on an anchor and clicks it — so without the check any `data:` URL that
1745
+ * reached a `screenshotReady` listener would land in the user's downloads.
1746
+ * Anything else is reported and ignored.
1747
+ *
1540
1748
  * @param {string} imageUrl - The URL of the image to save.
1541
1749
  * @param {string} filename - The name of the file to save.
1542
1750
  */
1543
1751
  function saveImage(imageUrl, filename) {
1752
+ if (!isScreenshotDataUrl(imageUrl)) {
1753
+ console.warn('Metabox: saveImage ignored a value that is not a configurator screenshot ' +
1754
+ '(expected a base64 data URL of type image/png, image/jpeg or image/webp).');
1755
+ return;
1756
+ }
1544
1757
  const a = document.createElement('a');
1545
1758
  a.href = imageUrl;
1546
1759
  a.download = filename;
@@ -1548,6 +1761,15 @@ function saveImage(imageUrl, filename) {
1548
1761
  a.click();
1549
1762
  document.body.removeChild(a);
1550
1763
  }
1764
+ /**
1765
+ * A base64 data URL in one of the formats `GetScreenshot` can ask for. Matched
1766
+ * as a whole string rather than parsed: `new URL()` accepts a `data:` URL but
1767
+ * exposes nothing useful about its media type, and a prefix check would let
1768
+ * anything trail behind the payload.
1769
+ */
1770
+ function isScreenshotDataUrl(value) {
1771
+ return /^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/i.test(value);
1772
+ }
1551
1773
 
1552
1774
  /**
1553
1775
  * Generated bundle index. Do not edit.
@@ -1 +1 @@
1
- {"version":3,"file":"3dsource-metabox-modular-configurator-api.mjs","sources":["../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/CommandBase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/fromCommunicatorEvent.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/interfaces/ToMetaboxMessagePayloads.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/MetaboxConfig.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetPdf.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetCallToActionInformation.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetCamera.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetCamera.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResetCamera.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResetConfiguration.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ApplyZoom.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/InitShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/PlayShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/UnrealCommand.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/PauseShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/StopShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetScreenshot.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetComponent.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetComponentMaterial.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetEnvironment.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetEnvironmentMaterial.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ShowEmbeddedMenu.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ShowOverlayInterface.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ShowMeasurement.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/HideMeasurement.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResumeStream.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/StopStream.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResetUserInactivityTimer.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/event-dispatcher.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/constants/common.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/constants/version.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/communicator.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/prepare-iframe-src.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/integrate-metabox.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/save-image.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/3dsource-metabox-modular-configurator-api.ts"],"sourcesContent":["import type { ToMetaBoxMessageEnvelope } from '../interfaces';\n\n/**\n * Base class for commands sent to the Metabox API.\n *\n * ### What does it unlock?\n * Base class that all other commands inherit from in a class hierarchy. Provides common properties\n * and methods that are automatically available to all command subclasses.\n *\n * ### Practical Application\n * Base class all commands inherit from. Never instantiate directly — use specific subclasses like\n * SetProduct, SetCamera, etc. All commands are sent via `api.sendCommandToMetabox(new CommandName(...))`.\n *\n * ### AI Coding Best Practices\n * Never construct a generic CommandBase. Always use the specific typed command class. When generating\n * dynamic command dispatch, use a switch/map pattern matching command names to their constructors.\n *\n * @internal\n * @hidden\n */\n\nexport class CommandBase {\n /** The message envelope populated by subclass constructors and sent via {@link Communicator.sendCommandToMetabox}. */\n data!: ToMetaBoxMessageEnvelope;\n}\n","import type { Communicator } from '../helpers';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaboxMessagePayloads,\n} from '../interfaces';\nimport type { Observable } from 'rxjs';\nimport { fromEvent } from 'rxjs';\n\n/**\n * Wrapper helper function to use with RxJS the same way as `fromEvent`, to listen to events from the Communicator.\n *\n * ### What does it unlock?\n * Function that creates an event listener subscription. Allows developers to subscribe to specific events from the Communicator.\n *\n * ### Practical Application\n * Function that creates event listener subscriptions. Alternative to api.addEventListener() — both subscribe\n * to configurator events. Use to react to state changes, screenshot readiness, viewport loading, showcase status, etc.\n *\n * ### AI Coding Best Practices\n * Prefer api.addEventListener() directly from the Communicator object. If using fromCommunicatorEvent, pass the\n * event name and handler. Key events: configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged,\n * getCameraResult. Always subscribe BEFORE sending commands that trigger responses.\n *\n * @param {Communicator} target - The Communicator instance to listen on.\n * @param {T} eventName - The event name from {@link FromMetaBoxApiEvents} to subscribe to.\n * @returns An Observable that emits the typed payload each time the event fires.\n * @internal\n */\nexport function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(\n target: Communicator,\n eventName: T,\n) {\n return fromEvent(target, eventName) as Observable<\n FromMetaboxMessagePayloads[T]\n >;\n}\n","import type { MimeType } from '../actions';\nimport type { MetaboxHost } from '../constants';\nimport type { MetaboxCommandConfig } from './metabox-config';\n\n/**\n * Registry of all action identifiers that can be sent from the host application to the Metabox Modular Configurator.\n * Each key maps to a string used as the `action` field in the postMessage envelope.\n *\n * ### What does it unlock?\n * Variable containing all available action names. Interface listing all actions that the modular configurator supports.\n *\n * ### Practical Application\n * Master action registry object — all supported configurator action names. Invaluable reference for building\n * admin dashboards, permission systems, or feature-availability displays.\n *\n * ### AI Coding Best Practices\n * Iterate this object to dynamically build action dropdowns, command palettes, or feature checklists in admin tools.\n * Each key is an action name, value is its description. Excellent reference for AI coding agents to understand\n * the full command vocabulary available.\n */\nexport const MetaboxModularConfiguratorActions = {\n metaboxConfig: 'metaboxConfig',\n resumeStream: 'resumeStream',\n stopStream: 'stopStream',\n setEnvironment: 'setEnvironment',\n setEnvironmentMaterialById: 'setEnvironmentMaterialById',\n setComponent: 'setComponent',\n setComponentMaterialById: 'setComponentMaterialById',\n getPdf: 'getPdf',\n getCallToActionInformation: 'getCallToActionInformation',\n getScreenshot: 'getScreenshot',\n showEmbeddedMenu: 'showEmbeddedMenu',\n showOverlayInterface: 'showOverlayInterface',\n getCamera: 'getCamera',\n setCamera: 'setCamera',\n resetCamera: 'resetCamera',\n resetConfiguration: 'resetConfiguration',\n applyZoom: 'applyZoom',\n initShowcase: 'initShowcase',\n playShowcase: 'playShowcase',\n pauseShowcase: 'pauseShowcase',\n stopShowcase: 'stopShowcase',\n sendCommandToUnreal: 'sendCommandToUnreal',\n showMeasurement: 'showMeasurement',\n hideMeasurement: 'hideMeasurement',\n resetUserInactivityTimer: 'resetUserInactivityTimer',\n} as const;\n\n/**\n * Union of all action string literals from {@link MetaboxModularConfiguratorActions}.\n *\n * ### What does it unlock?\n * Type alias for all actions that can be sent to MetaBox. Defines the complete set of command types available.\n *\n * ### Practical Application\n * Type alias enumerating all available outgoing command types. Master list of everything your app can tell MetaBox to do.\n * Use as a checklist when planning which features to implement.\n *\n * ### AI Coding Best Practices\n * Reference for building command dispatchers or admin tools. Full command set includes all values of\n * MetaboxModularConfiguratorActions like: \"metaboxConfig\" | \"setEnvironment\" | \"setEnvironmentMaterialById\" | ...\n */\nexport type ToMetaBoxActions =\n (typeof MetaboxModularConfiguratorActions)[keyof typeof MetaboxModularConfiguratorActions];\n\n/**\n * @internal\n * @hidden\n */\nexport type ToMetaboxMessagePayload =\n ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];\n\n/**\n * Interface for messages sent from the application to the Metabox Modular Configurator.\n *\n * ### What does it unlock?\n * Defines payload structures for different types of outgoing messages to MetaBox. Contains data models for various command parameters.\n *\n * ### Practical Application\n * Payload type definitions for all outgoing command types. Defines required and optional fields per command.\n * Essential TypeScript reference for type-safe command construction.\n *\n * ### AI Coding Best Practices\n * Use as TypeScript type reference for proper typing when building dynamic command dispatchers.\n * Each key corresponds to a command name and its value defines the expected payload structure.\n */\nexport interface ToMetaboxMessagePayloads {\n [MetaboxModularConfiguratorActions.metaboxConfig]: {\n appId: string;\n config: MetaboxCommandConfig;\n };\n [MetaboxModularConfiguratorActions.setEnvironment]: { id: string };\n [MetaboxModularConfiguratorActions.setEnvironmentMaterialById]: {\n slotId: string;\n materialId: string;\n };\n [MetaboxModularConfiguratorActions.setComponent]: {\n id: string;\n typeId: string;\n };\n [MetaboxModularConfiguratorActions.setComponentMaterialById]: {\n componentId: string;\n slotId: string;\n materialId: string;\n };\n [MetaboxModularConfiguratorActions.getScreenshot]: {\n format: MimeType;\n size?: { x: number; y: number };\n };\n [MetaboxModularConfiguratorActions.getCallToActionInformation]: void;\n [MetaboxModularConfiguratorActions.getPdf]: void;\n [MetaboxModularConfiguratorActions.showEmbeddedMenu]: { visible: boolean };\n [MetaboxModularConfiguratorActions.showOverlayInterface]: {\n visible: boolean;\n };\n [MetaboxModularConfiguratorActions.getCamera]: void;\n [MetaboxModularConfiguratorActions.setCamera]: {\n camera: CameraCommandPayload;\n };\n [MetaboxModularConfiguratorActions.resetCamera]: void;\n [MetaboxModularConfiguratorActions.resetConfiguration]: void;\n [MetaboxModularConfiguratorActions.applyZoom]: { zoom: number };\n [MetaboxModularConfiguratorActions.initShowcase]: void;\n [MetaboxModularConfiguratorActions.playShowcase]: void;\n [MetaboxModularConfiguratorActions.pauseShowcase]: void;\n [MetaboxModularConfiguratorActions.stopShowcase]: void;\n [MetaboxModularConfiguratorActions.sendCommandToUnreal]: object;\n [MetaboxModularConfiguratorActions.showMeasurement]: void;\n [MetaboxModularConfiguratorActions.hideMeasurement]: void;\n [MetaboxModularConfiguratorActions.resetUserInactivityTimer]: void;\n [MetaboxModularConfiguratorActions.stopStream]: void;\n}\n\n/**\n * Payload for the {@link SetCamera} command describing the desired camera state in the Unreal scene.\n * All fields are optional — only the provided values will be applied.\n *\n * ### What does it unlock?\n * Defines the payload structure for camera commands. Contains camera-related parameters passed to SetCamera command.\n *\n * ### Practical Application\n * Read-only interface defining camera parameters: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),\n * rotation ({horizontal: yaw, vertical: pitch}), and restrictions (distance/FOV/rotation limits).\n * Both returned by getCameraResult event and accepted by SetCamera.\n *\n * ### AI Coding Best Practices\n * This interface is bidirectional — returned from GetCamera and accepted by SetCamera.\n * Capture a camera state via getCameraResult and replay it with SetCamera(payload).\n * Only include restriction fields you want to enforce; omitted values keep current settings.\n * In orbit mode, distance limits are relative to the orbit pivot.\n */\nexport interface CameraCommandPayload {\n /** Field of view angle in degrees. */\n fov?: number;\n /** Camera control mode: `'fps'` for first-person or `'orbit'` for orbital rotation around pivot. */\n mode?: 'fps' | 'orbit';\n /** Camera position in 3D world space. */\n position?: { x: number; y: number; z: number };\n /** Camera rotation angles in degrees. */\n rotation?: {\n horizontal: number;\n vertical: number;\n };\n /** Min/max constraints applied to camera movement, zoom, and rotation. */\n restrictions?: {\n maxDistanceToPivot?: number;\n maxFov?: number;\n maxHorizontalRotation?: number;\n maxVerticalRotation?: number;\n minDistanceToPivot?: number;\n minFov?: number;\n minHorizontalRotation?: number;\n minVerticalRotation?: number;\n };\n}\n\n/**\n * @internal\n * @hidden\n * Envelope wrapping an action and its payload for host-to-Metabox postMessage communication.\n *\n * ### What does it unlock?\n * Envelope structure for outgoing MetaBox messages. Encapsulates messages with protocol headers for transmission.\n *\n * ### Practical Application\n * Protocol envelope for outgoing messages — adds headers for transmission to MetaBox iframe.\n * Internal to the communication layer, handled automatically by the Communicator.\n *\n * ### AI Coding Best Practices\n * Do not construct manually. The Communicator handles all message wrapping. Only reference this interface\n * if debugging raw postMessage traffic in browser devtools to diagnose why commands aren't being received.\n */\nexport interface ToMetaBoxMessageEnvelope {\n action: ToMetaBoxActions;\n payload?: ToMetaboxMessagePayload | never;\n}\n\n/**\n * @internal\n * @hidden\n */\nexport type ToMetaboxTarget = 'metabox' | 'child';\n\n/**\n * @internal\n * @hidden\n * Top-level postMessage structure sent from the host to the Metabox iframe.\n *\n * ### What does it unlock?\n * Message interface for sending data to MetaBox. Wraps outgoing commands with necessary protocol information.\n *\n * ### Practical Application\n * Outgoing message format for commands to MetaBox. Wraps commands with protocol information for postMessage delivery.\n * Handled automatically by Communicator.sendCommandToMetabox() — never construct manually.\n *\n * ### AI Coding Best Practices\n * Do not construct ToMetaBoxMessage objects. Always use `api.sendCommandToMetabox(new CommandName(...))`.\n * The Communicator wraps your command in the correct message format automatically.\n */\nexport interface ToMetaBoxMessage {\n host: typeof MetaboxHost;\n envelope: ToMetaBoxMessageEnvelope;\n /**\n * @deprecated, use envelope instead of payload\n */\n payload: ToMetaBoxMessageEnvelope;\n target: ToMetaboxTarget;\n apiVersion: string;\n}\n","import { CommandBase } from './CommandBase';\nimport type { MetaboxCommandConfig } from '../interfaces';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to send Metabox Config to Metabox Modular Configurator.\n *\n * ### What does it unlock?\n * Configuration object passed to MetaBox during initialization. Specifies domain, host, standalone mode,\n * and other parameters that control how the configurator behaves.\n *\n * ### Practical Application\n * Internal configuration object auto-sent during initialization. Contains appId and config.\n * DO NOT call directly — integrateMetabox() handles this automatically as part of its setup sequence.\n *\n * ### AI Coding Best Practices\n * NEVER instantiate or send MetaboxConfig manually. It is auto-sent by integrateMetabox().\n * Use the IntegrateMetaboxConfig parameter of integrateMetabox() instead for setting domain, standalone,\n * loadingImage, introImage, state, etc.\n *\n * @internal\n * Automatically sent when the Communicator instance is ready.\n *\n * @param {string} appId - The unique identifier for the Communicator Instance\n * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\n */\n\nexport class MetaboxConfig extends CommandBase {\n constructor(appId: string, config: MetaboxCommandConfig) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.metaboxConfig,\n payload: { appId, config },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a PDF from Metabox Modular Configurator.\n * This class sends a message to the Metabox API to generate a PDF based on the current configuration.\n * **Important**: No need to listen to any events to see changes. Pdf will be downloaded automatically once it's ready.\n *\n * ### What does it unlock?\n * Generates a native MetaBox PDF document. No subscription required — it executes independently.\n *\n * ### Practical Application\n * Generates a branded PDF from the current configurator state server-side. No event subscription needed.\n * Use for B2B quote workflows, downloadable spec sheets, or emailing configured product summaries to prospects.\n *\n * ### AI Coding Best Practices\n * Simply call `api.sendCommandToMetabox(new GetPdf())`. No parameters or event subscription required.\n * The PDF generates inside MetaBox application.\n *\n * @example\n * import { GetPdf, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new GetPdf());\n * };\n */\nexport class GetPdf extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.getPdf };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a Call To Action Information from Metabox Modular Configurator.\n * This class sends a message to the Metabox API to generate Call To Action information based on the current\n * configuration and sends it to the endpoint URL from the CTA information.\n *\n * To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Retrieves information about call-to-action that were added to the configurator. Requires subscription to receive data.\n *\n * ### Practical Application\n * Triggers the CTA (Call-to-Action) workflow configured in MetaBox admin. The CTA label and callback URL are set in admin.\n * When invoked, MetaBox POSTs the full configuration JSON (including BOM) to your callback URL endpoint, which returns a { redirectUrl }.\n *\n * ### AI Coding Best Practices\n * Call only after user completes configuration. Subscribe to ecomConfiguratorDataUpdated to get CTA label/URL for building\n * custom CTA buttons in your UI. The POST payload includes the full bill of materials — your backend endpoint processes it\n * and returns a redirect URL.\n *\n * @example\n * import { Communicator, EcomConfigurator, GetCallToActionInformation } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('ecomConfiguratorDataUpdated', (data:EcomConfigurator) => {\n * console.log('Ecom configurator params:', data);\n * });\n *\n * // Send the command to get Call To Action information from Metabox Modular Configurator\n * api.sendCommandToMetabox(new GetCallToActionInformation());\n * };\n */\nexport class GetCallToActionInformation extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.getCallToActionInformation,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get the camera configuration from Unreal.\n * This class sends a message to the Metabox API to get the camera from a scene.\n * To listen for changes after sending this command, listen to the 'getCameraResult' event.\n *\n * ### What does it unlock?\n * Retrieves camera presets for the configurator; allowing extraction and application of saved camera positions.\n *\n * ### Practical Application\n * Requests current camera state — returns asynchronously via the getCameraResult event. Returns a CameraCommandPayload\n * with fov, mode, position, rotation, and restrictions. Use to save camera positions, create shareable view links,\n * or build 'save this angle' features.\n *\n * ### AI Coding Best Practices\n * ALWAYS subscribe to getCameraResult BEFORE calling GetCamera(). Pattern: `api.addEventListener('getCameraResult', handler);`\n * then `api.sendCommandToMetabox(new GetCamera())`. The returned CameraCommandPayload can be fed directly back into\n * SetCamera to restore the view.\n *\n * @example\n * import { Communicator, CameraCommandPayload, GetCamera } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('getCameraResult', (data:CameraCommandPayload) => {\n * console.log('Camera params after get camera command:', data);\n * });\n *\n * api.sendCommandToMetabox(new GetCamera());\n * };\n */\nexport class GetCamera extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.getCamera };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport type { CameraCommandPayload } from '../interfaces';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set the camera configuration.\n * This class sends a message to the Metabox API to set the camera on a scene.\n * **Important**: No need to listen to any events to see changes.\n *\n * ### What does it unlock?\n * Sets camera presets with restriction parameters (FOV, rotation, position).\n *\n * ### Practical Application\n * Sets camera with precise control: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),\n * rotation ({horizontal,vertical}), and restrictions (min/max distance, FOV, rotation bounds).\n * Use for guided tours, preset view buttons, or restricting camera to prevent users seeing behind the product.\n *\n * ### AI Coding Best Practices\n * Only include fields you want to change — omitted values keep current settings. Use orbit mode for typical product viewing,\n * fps for walkthrough/room scenes. Apply restrictions to prevent bad angles. Full interface:\n * `{fov?, mode?, position?, rotation?, restrictions?}`.\n *\n * @example\n * import { SetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new SetCamera({\n * fov: 45,\n * mode: 'orbit',\n * position: { x: 100, y: 100, z: 100 },\n * rotation: { horizontal: 0, vertical: 0 },\n * restrictions: {\n * maxDistanceToPivot: 0,\n * maxFov: 0,\n * maxHorizontalRotation: 0,\n * maxVerticalRotation: 0,\n * minDistanceToPivot: 0,\n * minFov: 0,\n * minHorizontalRotation: 0,\n * minVerticalRotation: 0,\n * },\n * }));\n * };\n *\n * @param {CameraCommandPayload} camera - The camera configuration.\n */\nexport class SetCamera extends CommandBase {\n constructor(camera: CameraCommandPayload) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.setCamera,\n payload: { camera },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to reset the camera to its initial position.\n * This class sends a message to the Metabox API to reset the camera on a scene.\n *\n * ### What does it unlock?\n * Resets the camera to its default state and position. Used to return camera to initial configuration after user manipulation.\n *\n * ### Practical Application\n * Resets camera to the default position defined in the component/environment template. Essential for 'Reset View' buttons.\n * Also, useful after programmatic camera moves to return to a known starting state.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResetCamera())`. No parameters. Restores template defaults — not the last user position.\n * Good practice to call after SetComponent changes that may shift the focal point of the assembly.\n *\n * @example\n * import { ResetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ResetCamera());\n * };\n */\n\nexport class ResetCamera extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.resetCamera };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to reset the modular configurator state to its defaults.\n * This class sends a message to the Metabox API to restore the component tree, component materials,\n * environment, and environment materials to the values defined by the configurator template.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Resets the entire modular configurator state to defaults — root and child components, all component\n * material selections, environment, and environment materials all return to the template-defined initial\n * values. Used to give users a clean 'Start Over' affordance without reloading the iframe.\n *\n * ### Practical Application\n * Powers 'Reset to Defaults' / 'Start Over' buttons in modular configurators where users have built up\n * an assembly with multiple SetComponent / SetComponentMaterial calls. Unlike ResetCamera (which only\n * touches viewport state), ResetConfiguration wipes all user-applied selections back to template\n * defaults. The configurator responds with a full ModularConfiguratorEnvelope via configuratorDataUpdated,\n * so UI state derived from the envelope (configurationTree, componentsByComponentType, material chips)\n * will re-sync automatically.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResetConfiguration())`. No parameters. Subscribe to\n * configuratorDataUpdated BEFORE sending so you capture the reset envelope. If your UI maintains local\n * selection state separate from the envelope, clear it in the same handler. After reset, the root\n * component is back to the template default — no need to re-issue SetComponent for the root unless you\n * want a different starting assembly. Pair with ResetCamera if you also want the viewport returned to\n * its default framing.\n *\n * @example\n * import { ResetConfiguration, Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data: ModularConfiguratorEnvelope) => {\n * console.log('Configurator reset to default state:', data);\n * });\n *\n * api.sendCommandToMetabox(new ResetConfiguration());\n * };\n */\n\nexport class ResetConfiguration extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.resetConfiguration,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to apply zoom and change the camera zoom on a scene.\n * This class sends a command to the Metabox API to change zoom on a scene.\n *\n * ### What does it unlock?\n * Controls zoom functionality for the configurator; allowing users to adjust the zoom level of 3D objects and camera presets.\n *\n * ### Practical Application\n * Implements programmatic zoom on the pixel-streamed viewport. Use to build zoom slider controls, pinch-to-zoom on mobile,\n * or 'zoom to detail' buttons. Takes a numeric delta: positive zooms in, negative zooms out\n * (e.g., ApplyZoom(50) zooms in, ApplyZoom(-50) zooms out).\n *\n * ### AI Coding Best Practices\n * Always use numeric delta values, not absolute zoom levels. Pair with a UI slider that sends incremental values.\n * Debounce zoom input to ~100ms intervals to prevent overwhelming the Unreal stream.\n * Pattern: `api.sendCommandToMetabox(new ApplyZoom(50))`.\n *\n * @example\n * import { ApplyZoom, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ApplyZoom(50));\n * };\n *\n * @param {number} zoom - The zoom value to apply.\n */\n\nexport class ApplyZoom extends CommandBase {\n constructor(zoom: number) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.applyZoom,\n payload: { zoom },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to initialize Showcase for a component scene and start a sequence for the component.\n * This class sends a command to the Metabox API to initialize showcase if the component has a sequence.\n * To check this, find the showcase property in the current component and listen to the 'configuratorDataUpdated' event.\n * If this property exists, you can send the init showcase command.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Initializes and displays the showcase/demo view for the configurator. Used when transitioning into presentation or demo mode.\n *\n * ### Practical Application\n * Loads the showcase/animation sequence attached to the current component. Must be called BEFORE PlayShowcase.\n * Use to initialize auto-playing product demos, trade show presentations, or hero section animations on landing pages.\n *\n * ### AI Coding Best Practices\n * ALWAYS call InitShowcase() before PlayShowcase(). Required sequence: InitShowcase → PlayShowcase → PauseShowcase/StopShowcase.\n * Subscribe to showcaseStatusChanged to track playback state ('playing'/'paused'/'stopped').\n *\n * @example\n * import { Communicator, ShowCaseStatus, InitShowcase } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new InitShowcase());\n * };\n */\n\nexport class InitShowcase extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.initShowcase,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to play Showcase for a component when it is already initialized and paused.\n * This class sends a command to the Metabox API to play showcase for a component if it is already initialized and paused.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Starts or resumes the showcase/timeline playback. Executes the internal MetaBox play command internally.\n *\n * ### Practical Application\n * Starts or resumes showcase playback. Use for 'Play Demo' buttons on landing pages, auto-play on page load,\n * or resuming demos after inactivity timeout on kiosk displays.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new PlayShowcase())`. Must call InitShowcase() first or it won't play.\n * Subscribe to showcaseStatusChanged to track state. Auto-play pattern: wait for viewportReady → InitShowcase →\n * PlayShowcase.\n *\n * @example\n * import { Communicator, PlayShowcase } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new PlayShowcase());\n * };\n */\n\nexport class PlayShowcase extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.playShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * @internal\n * @hidden\n * Represents a command to send Unreal command.\n */\n\nexport class UnrealCommand extends CommandBase {\n constructor(payload: object) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.sendCommandToUnreal,\n payload,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to pause Showcase for a component when it is already initialized and playing.\n * This class sends a command to the Metabox API to pause showcase for a component if it is already initialized and playing.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Pauses the showcase/timeline playback. Can be called independently without requiring any flag parameters.\n *\n * ### Practical Application\n * Pauses showcase animation playback. The showcase remains initialized and can be resumed with\n * PlayShowcase. Use when you need to temporarily freeze the animation (e.g., on a \"Pause\" button click).\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new PauseShowcase())`. No parameters. Subscribe to showcaseStatusChanged\n * to confirm 'pause' state. Use PlayShowcase to resume or StopShowcase to reset.\n *\n * @example\n * import { Communicator, ShowCaseStatus, PauseShowcase } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new PauseShowcase());\n * };\n */\n\nexport class PauseShowcase extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.pauseShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to stop Showcase for a component when it is already initialized, and you want to destroy it.\n * This class sends a command to the Metabox API to stop showcase for a component if it is already initialized.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Stops the showcase/timeline playback and closes the showcase mode. Returns to normal configurator view.\n *\n * ### Practical Application\n * Stops showcase playback and exits showcase mode entirely. Returns to normal interactive configurator view.\n * Use for 'Exit Demo' buttons or auto-trigger when the user starts actively configuring the product.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new StopShowcase())`. Fully resets the showcase state. Subscribe to\n * showcaseStatusChanged to confirm 'stopped' status. After stopping, the configurator returns to full\n * interactive mode — re-enable configuration controls.\n *\n * @example\n * import { Communicator, ShowCaseStatus } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new StopShowcase());\n * };\n */\n\nexport class StopShowcase extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.stopShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Image format.\n * This type represents the allowed image formats.\n *\n * ### What does it unlock?\n * Type alias for MIME types used in file/media handling. Defines supported file formats and media types.\n *\n * ### Practical Application\n * Type alias: 'image/png' | 'image/jpeg' | 'image/webp'. Used as the format parameter in GetScreenshot.\n * PNG for quality/transparency, JPEG for smaller files, WebP for modern browser optimization.\n *\n * ### AI Coding Best Practices\n * Pass as first param to GetScreenshot: `new GetScreenshot('image/png', {x:2048, y:2048})`.\n * Use PNG for highest quality and transparency. JPEG for smaller file size. WebP for modern browser optimization.\n * Match the saveImage filename extension to the format.\n */\nexport type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';\n\n/**\n * Represents a command to get a screenshot.\n *\n * To listen for changes after sending this command, listen to the 'screenshot' event before command is sent.\n *\n * ### What does it unlock?\n * Takes a screenshot on the server side (Unreal Engine) of the 3D scene. Returns high-quality image.\n * Requires subscription to the screenshotReady event to receive the rendered image.\n *\n * ### Practical Application\n * Renders a high-res screenshot on the Unreal Engine server. Takes format ('image/png'|'image/jpeg'|'image/webp')\n * and optional size ({x, y}). Returns base64 data via screenshotReady event. Use for thumbnails, social sharing,\n * saving config snapshots, or attaching images to quotes.\n *\n * ### AI Coding Best Practices\n * Subscribe to screenshotReady BEFORE sending GetScreenshot. Pattern:\n * `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'name.png'); })`.\n * Specify size for consistent outputs: `new GetScreenshot('image/png', {x:2048, y:2048})`.\n * Use saveImage() helper to convert base64 to downloadable file.\n *\n * @example\n * import { Communicator, saveImage, GetScreenshot } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('screenshot', (data:string) => {\n * // The data is a base64 string of the image. You can use it to display the image or save it as a file.\n * console.log('Get screenshot here:', data);\n * saveImage(data, 'Render.png');\n * });\n *\n * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));\n * };\n *\n * @param {MimeType} mimeType - The output format.\n * @param {{ x: number; y: number }} [size] - Optional size in pixels.\n */\nexport class GetScreenshot extends CommandBase {\n constructor(mimeType: MimeType, size?: { x: number; y: number }) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.getScreenshot,\n payload: { format: mimeType, size },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set a component by its data (ID, typeId).\n * This action sends a message to the Metabox API to set a component using the provided data.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets a component during initialization, which triggers the reconstruction of the component tree structure.\n * Simulates clicking a component in the menu.\n *\n * ### Practical Application\n * Selects a component in the modular assembly. Takes componentId (UUID), typeId (category string).\n * CRITICAL: Always set root component (isRoot:true) FIRST — nothing renders without it. Then add children (isRoot:false).\n * Simulates clicking a component in the menu.\n *\n * ### AI Coding Best Practices\n * ALWAYS set root first: `new SetComponent('id', 'type', true)`. Then children: `new SetComponent('childId', 'childType', false)`.\n * Get valid IDs from configuratorDataUpdated event data — the configurator definition contains all available components and types.\n * Wrong order = blank viewport. The typeId must match componentType values from the configurator.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope, SetComponent } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new component:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetComponent(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'typeId'\n * ));\n * };\n *\n * @param {string} id - The component ID.\n * @param {string} typeId - The component type ID.\n */\nexport class SetComponent extends CommandBase {\n constructor(id: string, typeId: string) {\n super();\n this.data = {\n payload: { id, typeId },\n action: MetaboxModularConfiguratorActions.setComponent,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set component material by its slot ID and Material ID.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets a material variant for a component. Simulates selecting a different material from the menu for a specific component.\n *\n * ### Practical Application\n * Applies a material to a specific slot on a component. Takes componentId (UUID), slotId (string), and materialId (UUID).\n * Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external\n * PIM/ERP system via externalId mapping.\n *\n * ### AI Coding Best Practices\n * Get valid slotId and materialId values from the configuratorDataUpdated envelope —\n * check component slot definitions and material lists. Pattern:\n * `new SetComponentMaterial('component-uuid', 'slot-name', 'material-uuid')`. The referenced component must already be set in the tree.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope, SetComponentMaterial } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new material:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetComponentMaterial(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n *\n * @param {string} componentId - The component ID.\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\nexport class SetComponentMaterial extends CommandBase {\n constructor(componentId: string, slotId: string, materialId: string) {\n super();\n this.data = {\n payload: { componentId, slotId, materialId },\n action: MetaboxModularConfiguratorActions.setComponentMaterialById,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set the environment by its ID.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets environmental/lighting settings for the scene. Controls factors like lighting conditions and environmental appearance.\n *\n * ### Practical Application\n * Changes the 3D scene/environment (studio, showroom, outdoor, etc.). Takes an environmentId UUID.\n * Environments include lighting, backdrop, and optionally dynamic sky (udsEnabled) with time-of-day (udsHour) control.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new SetEnvironment('env-uuid'))`. Get valid environment IDs from the configurator\n * definition in configuratorDataUpdated. Set environment after root component during initialization. Each environment has\n * its own material slots, thumbnails, and lighting properties.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new environment:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'))\n * };\n *\n * @param {string} environmentId - The environment ID.\n */\nexport class SetEnvironment extends CommandBase {\n constructor(environmentId: string) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.setEnvironment,\n payload: { id: environmentId },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set an environment material by its slot ID and Material ID.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets environmental material properties such as textures and appearance attributes for the scene environment.\n *\n * ### Practical Application\n * Applies materials to environment slots (floor, walls, backdrop textures). Takes slotId and materialId.\n * Use for scene-based configurators where the environment is also customizable — kitchen visualizers,\n * room planners, trade show booth designers.\n *\n * ### AI Coding Best Practices\n * Pattern: `new SetEnvironmentMaterial('floor-slot-id', 'material-uuid')`. Get valid slot and material IDs from\n * the environment definition's slots array in configuratorDataUpdated. Only useful when the active environment\n * has configurable material slots.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new environment material:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetEnvironmentMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n *\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\n\nexport class SetEnvironmentMaterial extends CommandBase {\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.setEnvironmentMaterialById,\n payload: { slotId, materialId },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the embedded Metabox menu.\n * This command can only be used when using the metabox menu.\n *\n * ### What does it unlock?\n * Shows the embedded menu interface. Only works when using the MetaBox native menu (not in standalone/custom menu\n * mode).\n *\n * ### Practical Application\n * Toggles the native MetaBox right sidebar menu. Takes a boolean parameter. Pass false to hide when building custom UI.\n * In standalone mode, the menu is already hidden — this is only relevant in default (non-standalone) mode.\n *\n * ### AI Coding Best Practices\n * In standalone mode (`{standalone:true}`), this is unnecessary (menu already hidden). In default mode,\n * call `new ShowEmbeddedMenu(false)` early in initialization to hide built-in UI before rendering custom controls.\n * Pattern for custom UI: `ShowEmbeddedMenu(false)` + `ShowOverlayInterface(false)`.\n *\n * @example\n * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ShowEmbeddedMenu(true));\n * };\n *\n * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.\n */\n\nexport class ShowEmbeddedMenu extends CommandBase {\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.showEmbeddedMenu,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the Unreal Overlay Interface Menu.\n * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.\n *\n * ### What does it unlock?\n * Shows the overlay interface elements. Displays UI controls and buttons overlaid on the 3D scene.\n *\n * ### Practical Application\n * Toggles viewport overlay controls (buttons overlaid on the 3D scene). Takes a boolean.\n * Use `ShowOverlayInterface(false)` alongside `ShowEmbeddedMenu(false)` when building fully custom UI\n * that replaces all native MetaBox controls.\n *\n * ### AI Coding Best Practices\n * In standalone mode, overlays are already hidden. In default mode, call `new ShowOverlayInterface(false)`\n * early in initialization to prevent flash of native UI. Always pair with `ShowEmbeddedMenu(false)` for clean custom UI.\n * Pass true to restore if entering a mode that uses native controls.\n *\n * @example\n * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ShowOverlayInterface(true));\n * };\n *\n * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.\n */\n\nexport class ShowOverlayInterface extends CommandBase {\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.showOverlayInterface,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to show measurement for a product when it is already loaded.\n * This class sends a command to the Metabox API to show measurement for a product if it is already initialized.\n *\n * ### What does it unlock?\n * Shows the measurement overlay. Works as a toggle with HideMeasurement to control visibility.\n *\n * ### Practical Application\n * Shows the measurement/dimension overlay tools on the 3D viewport. Use for B2B or technical applications\n * where buyers need to verify product dimensions, check fit specifications, or confirm measurements during procurement.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ShowMeasurement())`. No parameters. Pair with HideMeasurement for toggle behavior.\n * Track visibility state in your app to keep toggle buttons in sync.\n *\n * @example\n * import { ShowMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ShowMeasurement());\n * };\n */\n\nexport class ShowMeasurement extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.showMeasurement };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to hide measurement for a product when it is already loaded.\n * This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.\n *\n * ### What does it unlock?\n * Hides the measurement overlay. Executes unconditionally to hide the UI controls.\n *\n * ### Practical Application\n * Hides the measurement/dimension overlay. Use when transitioning from a technical spec view back to a clean\n * product presentation, or to keep consumer-facing configurators visually clean.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new HideMeasurement())`. No parameters. Pair with ShowMeasurement as a toggle.\n * Track visibility state in your app state to keep toggle buttons in sync.\n *\n * @example\n * import { HideMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new HideMeasurement());\n * };\n */\n\nexport class HideMeasurement extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.hideMeasurement };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to resume the pixel streaming session.\n * This class sends a message to the Metabox API to resume a paused or disconnected stream.\n *\n * ### What does it unlock?\n * Resumes the Unreal Engine pixel streaming connection after it has been paused, disconnected, or stopped due to inactivity (AFK timeout).\n *\n * ### Practical Application\n * Used to reconnect the 3D streaming session without a full page reload. Essential for 'Reconnect' or 'Resume' buttons\n * shown when the stream is interrupted, e.g., after an idle timeout or network disruption.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResumeStream())`. No parameters. Resumes the existing streaming session —\n * does not reinitialize the configurator or reset component/environment state.\n *\n * @example\n * import { ResumeStream, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ResumeStream());\n * };\n */\n\nexport class ResumeStream extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.resumeStream };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to stop the pixel streaming session.\n * This class sends a message to the Metabox API to stop the active stream and release its resources.\n *\n * ### What does it unlock?\n * Stops the Unreal Engine pixel streaming connection, terminating the active session and freeing server-side resources.\n *\n * ### Practical Application\n * Used to explicitly end the 3D streaming session — e.g., when the user closes a modal, navigates away, or a\n * custom \"Stop\"/\"Disconnect\" button is pressed. Pair with {@link ResumeStream} to restart the session later\n * without a full page reload.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new StopStream())`. No parameters. Stops the existing streaming session —\n * does not reset component/environment state. Use `ResumeStream` to reconnect afterwards.\n *\n * @example\n * import { StopStream, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new StopStream());\n * };\n */\n\nexport class StopStream extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.stopStream };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to reset the user inactivity (AFK) timer.\n * This class sends a message to the Metabox API to restart the inactivity countdown,\n * keeping the session alive when activity is detected programmatically.\n *\n * ### What does it unlock?\n * Resets the AFK inactivity timer, preventing an imminent disconnect when the countdown is active.\n *\n * ### Practical Application\n * Used to programmatically signal user activity and reset the inactivity countdown.\n * Pair with the `userInactivityDetected` event to show a custom \"Stay connected?\" prompt\n * and call this command when the user confirms, dismissing the countdown.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResetUserInactivityTimer())`. No parameters.\n * Typically triggered from a \"Stay connected\" or \"I'm still here\" button rendered when\n * `userInactivityDetected.countdownVisible` is `true`.\n *\n * @example\n * import { ResetUserInactivityTimer, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.addEventListener('userInactivityDetected', ({ countdownVisible }) => {\n * if (countdownVisible) {\n * // show custom UI, then on user confirmation:\n * api.sendCommandToMetabox(new ResetUserInactivityTimer());\n * }\n * });\n * };\n */\n\nexport class ResetUserInactivityTimer extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.resetUserInactivityTimer,\n };\n }\n}\n","/**\n * Represents a callback listener for specific message types.\n * Used internally by EventDispatcher to store event listeners.\n *\n * ### What does it unlock?\n * Event listener interface. Allows subscription to specific events from the configurator to receive real-time data updates.\n *\n * ### Practical Application\n * Event listener interface. addEventListener() and removeEventListener() on Communicator. Subscribe to real-time\n * configurator events: state changes, viewport readiness, screenshots, showcase status, camera results, resolution changes.\n *\n * ### AI Coding Best Practices\n * Set up listeners BEFORE sending commands that trigger them. Always clean up with removeEventListener on component unmount.\n * Key events: configuratorDataUpdated (every state change), viewportReady (init complete), screenshotReady (captures),\n * getCameraResult (camera queries), showcaseStatusChanged (demo playback).\n *\n * @public\n */\nexport interface Listener {\n /** The message type this listener is registered for */\n messageType: string;\n /** The callback function to execute when a message of the specified type is received */\n callback: (data: unknown) => void;\n}\n\n/**\n * EventDispatcher is a class that manages event listeners and dispatches events to them.\n *\n * ### What does it unlock?\n * Parent class of Communicator that dispatches commands. Acts as an event dispatcher that routes command messages internally.\n *\n * ### Practical Application\n * Internal event routing layer — parent class of Communicator. Routes postMessage commands between your app\n * and the Unreal Engine pixel stream. Not used directly but understanding it helps debug message delivery issues.\n *\n * ### AI Coding Best Practices\n * Do not reference or extend EventDispatcher in application code. Use only the Communicator interface methods.\n * If debugging communication failures, check browser console for postMessage errors related to this layer.\n */\nexport class EventDispatcher {\n /**\n * Storage for callback listeners by message type.\n */\n listeners: Listener[] = [];\n\n /**\n * Removes all registered listeners. Subclasses override this to perform additional cleanup.\n * @param key - Instance key (used by subclass overrides for registry cleanup).\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n destroy(key: string) {\n this.listeners = [];\n }\n\n /**\n * Adds an event listener for receiving specific types of messages.\n *\n * @param {string} messageType - The message type to listen for.\n * @param callback - The callback function to execute when a message is received.\n */\n addEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners.push({ messageType, callback });\n return this;\n }\n\n /**\n * Dispatches an event to all listeners of a specific message type.\n *\n * @param {string} messageType - The message type.\n * @param data - The data associated with the event.\n */\n dispatchEvent(messageType: string, data: unknown): this {\n // Allocation-free dispatch on the hot message path. The length snapshot\n // keeps the previous filter-snapshot semantics: listeners added during\n // dispatch are not invoked for this event, and removeEventListener\n // reassigns the array so the in-flight loop is unaffected.\n const listeners = this.listeners;\n const len = listeners.length;\n for (let i = 0; i < len; i++) {\n const listener = listeners[i];\n if (listener.messageType === messageType) {\n listener.callback(data);\n }\n }\n return this;\n }\n\n /**\n * Removes an event listener for a specific type of message.\n *\n * @param {string} messageType - The message type.\n * @param callback - The callback function to remove.\n */\n removeEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners = this.listeners.filter(\n (listener) =>\n !(\n listener.messageType === messageType && listener.callback === callback\n ),\n );\n return this;\n }\n}\n","/**\n * @internal\n * @hidden\n * Core constants used for host-to-iframe communication and URL construction.\n */\n\n/**\n * Storage key for the Metabox Communicator instance registry.\n *\n * ### What does it unlock?\n * Constant string identifier for MetaBox version. Used internally to reference the MetaBox system and versioning.\n *\n * ### Practical Application\n * Internal system reference for versioning.\n * Not needed in front-end application code.\n *\n * ### AI Coding Best Practices\n * Skip in application code. This constant is for internal MetaBox system identification only.\n *\n * @internal\n */\nexport const Metabox = 'metabox';\n\n/**\n * Identifier used as the `host` field in postMessage envelopes sent to the iframe.\n *\n * ### What does it unlock?\n * Constant for the MetaBox host connection point. Specifies endpoint for MetaBox connections.\n *\n * ### Practical Application\n * MetaBox endpoint constant. The host the configurator iframe connects to for Unreal Engine pixel streaming.\n * Not needed in front-end application code.\n *\n * ### AI Coding Best Practices\n * Skip in application code. This constant is for internal MetaBox system identification only.\n *\n * @internal\n */\nexport const MetaboxHost = 'metaboxHost';\n\n/**\n * Action string dispatched by the iframe when the configurator app has loaded.\n *\n * ### What does it unlock?\n * App initialization flag variable. Signals when MetaBox has completed loading.\n *\n * ### Practical Application\n * Use the viewportReady event (more reliable) to gate your UI rendering — don't show controls until MetaBox confirms it's ready.\n *\n * ### AI Coding Best Practices\n * Prefer the viewportReady event over this variable: `api.addEventListener('viewportReady', (ready) => { if(ready) enableUI(); })`.\n * viewportReady is the reliable signal that MetaBox is ready to accept commands.\n *\n * @internal\n */\nexport const AppLoaded = 'appLoaded';\n\n/**\n * Default MetaBox domain for production environments.\n *\n * ### What does it unlock?\n * Constant for the standard default MetaBox domain. Used as the primary domain for connecting to MetaBox server.\n *\n * ### Practical Application\n * Default MetaBox domain constant (HTTPS). The base domain used when no override is specified.\n * Override only via IntegrateMetaboxConfig.domain if connecting to a custom or self-hosted MetaBox instance.\n *\n * ### AI Coding Best Practices\n * Let integrateMetabox() use the default. Override only if needed:\n * `integrateMetabox(id, container, callback, { domain: 'https://custom.domain.com' })`. HTTPS is mandatory.\n *\n * @internal\n */\n\n/**\n * @deprecated\n */\nexport const Metabox_V3 = 'metabox_v3';\n/**\n * @deprecated\n */\nexport const MetaboxHost_V3 = 'metaboxHost_v3';\n/**\n * @deprecated\n */\nexport const AppLoaded_V3 = 'appLoaded_v3';\n\nexport const MetaboxDomain = 'metabox.3dsource.com';\n\n/**\n * Base route URL segment for the Modular Configurator.\n *\n * ### What does it unlock?\n * Base route URL constant used for loading the configurator. Standard path endpoint for accessing the modular configurator.\n *\n * ### Practical Application\n * The modular configurator URL format is: `https://{domain}/metabox-configurator/modular/{configuratorId}`.\n * Automatically constructed by integrateMetabox().\n *\n * ### AI Coding Best Practices\n * Let integrateMetabox() handle URL construction. Only reference if building URLs manually\n * (e.g., QR codes, email links, server-side rendering). The modular path is `/modular/{id}`.\n *\n * @internal\n */\nexport const BasicRouteUrl = 'metabox-configurator/modular';\n","export const VERSION = '3.0.32';\n","import { EventDispatcher } from './event-dispatcher';\nimport type { CommandBase } from '../actions';\nimport { MetaboxConfig } from '../actions';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n MCAppLoaded,\n MetaboxCommandConfig,\n MetaboxEnvironment,\n ToMetaBoxMessage,\n} from '../interfaces';\nimport { AppLoaded, Metabox, MetaboxHost, VERSION } from '../constants';\n\nconst communicatorMap = new Map<string, { instance: Communicator }>();\n\n/**\n * Handles messaging between the host page and embedded Metabox content.\n *\n * ### What does it unlock?\n * Internal class that creates a proxy/communication layer between the API and MetaBox.\n * Handles reading and sending commands through the established connection.\n *\n * ### Practical Application\n * The API handle returned in the integrateMetabox callback. Provides sendCommandToMetabox() to send commands,\n * and addEventListener()/removeEventListener() for event subscriptions. This is your entire interface to\n * the MetaBox Unreal Engine stream.\n *\n * ### AI Coding Best Practices\n * Store the Communicator reference from the apiReadyCallback in a module-scoped variable or state store.\n * NEVER send commands before this callback fires. All commands and event listeners go through this single\n * api object. Clean up listeners with removeEventListener on component unmount.\n *\n * @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.\n */\nexport class Communicator extends EventDispatcher {\n /**\n * Bound handler for incoming postMessage events.\n */\n private binder = this.handleMessageReceived.bind(this);\n\n /**\n * Constructs a Communicator, replacing any existing instance, and begins listening for messages.\n * @internal\n */\n constructor(\n data: MCAppLoaded['payload'],\n environment: MetaboxEnvironment,\n config?: Partial<MetaboxCommandConfig>,\n ) {\n super();\n const { appId = 'unknown', version = VERSION } = data ?? {};\n const key = `${version}_${environment}_${appId}`;\n communicatorMap.get(key)?.instance.destroy(key);\n communicatorMap.set(key, { instance: this });\n window.addEventListener('message', this.binder);\n this.sendCommandToMetabox(\n new MetaboxConfig(appId, {\n ...config,\n hostUrl: location.href,\n apiVersion: VERSION,\n }),\n );\n }\n\n /**\n * Listens for Metabox to signal readiness, then initializes communicator.\n * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.\n * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.\n * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\n * @returns A cancel function that removes the handshake `message` listener.\n * `integrateMetabox` (the public entry point) calls this automatically when\n * a new integration supersedes a still-pending one, so direct internal\n * callers only need it for explicit early teardown. Idempotent.\n */\n static createInstance(\n apiReadyCallback: (api: Communicator) => void,\n environment: MetaboxEnvironment,\n config?: Partial<MetaboxCommandConfig>,\n ): () => void {\n const startHandler = (event: MessageEvent) => {\n const message = event.data as FromMetaBoxMessage;\n if (message?.envelope?.action === AppLoaded && message.host === Metabox) {\n apiReadyCallback(\n new Communicator(message.envelope.payload, environment, config),\n );\n window.removeEventListener('message', startHandler);\n }\n };\n\n window.addEventListener('message', startHandler);\n return () => window.removeEventListener('message', startHandler);\n }\n\n /**\n * Cleans up resources and stops listening for messages.\n */\n public override destroy(key: string) {\n super.destroy(key);\n window.removeEventListener('message', this.binder);\n }\n\n /** Destroys all active Communicator instances and clears the internal registry. */\n static clearAll() {\n if (communicatorMap.size === 0) {\n return;\n }\n\n communicatorMap.forEach((value, key) => value.instance.destroy(key));\n communicatorMap.clear();\n }\n\n /**\n * Retrieves a registered Communicator instance by its key.\n * @param key - The composite key (`version_environment_appId`) identifying the instance.\n */\n static getCommunicator(key: string) {\n return communicatorMap.get(key);\n }\n\n /**\n * Posts a command to the Metabox iframe.\n * @param command - An action command containing data to send.\n */\n public sendCommandToMetabox<T extends CommandBase>(command: T) {\n const { data } = command;\n const iframe = document.getElementById(\n 'embeddedContent',\n ) as HTMLIFrameElement;\n\n const toMetaboxMessage = {\n host: MetaboxHost,\n envelope: { ...data },\n // Deprecated mirror of `envelope`. Kept as an independent clone so a\n // receiver mutating one cannot observably change the other.\n payload: { ...data },\n target: iframe?.contentWindow ? 'child' : 'metabox',\n apiVersion: VERSION,\n } satisfies ToMetaBoxMessage;\n\n if (!iframe?.contentWindow) {\n console.warn(\n 'Metabox IFrame not found or not ready. Message sends to the same window',\n );\n window.postMessage(toMetaboxMessage, '*');\n return;\n }\n\n iframe.contentWindow.postMessage(toMetaboxMessage, '*');\n }\n\n /**\n * Registers an event listener for messages dispatched by the Metabox.\n * @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`).\n * @param callback - Handler invoked with the typed payload when the event fires.\n * @override\n */\n override addEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.addEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Dispatches a typed event to all registered listeners.\n * @param messageType - The event name to dispatch.\n * @param data - The payload to pass to each listener.\n * @override\n */\n override dispatchEvent<T extends FromMetaBoxApiEvents>(\n messageType: T,\n data: FromMetaboxMessagePayloads[T],\n ) {\n return super.dispatchEvent(messageType, data);\n }\n\n /**\n * Removes a previously registered event listener.\n * @param messageType - The event name the listener was registered for.\n * @param callback - The same function reference that was passed to {@link addEventListener}.\n * @override\n */\n override removeEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.removeEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Filters and dispatches incoming messages from the Metabox.\n * @param event - The postMessage event received on a window.\n */\n private handleMessageReceived<T extends FromMetaBoxApiEvents>(\n event: MessageEvent,\n ) {\n if (event.data?.host !== Metabox) {\n return;\n }\n const data = event.data?.envelope;\n this.dispatchEvent(data?.eventType as T, data?.payload);\n }\n}\n","import type { IntegrateMetaboxConfig } from '../interfaces';\nimport { BasicRouteUrl, MetaboxDomain } from '../constants';\n\n/**\n * Constructs the iframe source URL for the Metabox Modular Configurator.\n *\n * ### What does it unlock?\n * Utility function that prepares the iframe source URL. Constructs the proper URL with parameters\n * for loading the MetaBox configurator.\n *\n * ### Practical Application\n * Utility function that constructs the iframe source URL with proper parameters.\n * URL format: `https://{domain}/metabox-configurator/modular/{configuratorId}`.\n * Called internally by integrateMetabox() — use directly only for manual URL construction.\n *\n * ### AI Coding Best Practices\n * Usually called internally. Use directly only for pre-constructing embed URLs (QR codes, email links,\n * preview URLs). Verify output is HTTPS. Remember modular configurators use `/modular/` path.\n *\n * @internal\n * @hidden\n *\n * @param {string} configuratorId - An string identifier for the configurator.\n * @param {IntegrateMetaboxConfig} config - An object containing the configuration options.\n */\nexport const prepareIframeSrc = (\n configuratorId: string,\n config?: IntegrateMetaboxConfig,\n) => {\n const base = `https://${config?.domain || MetaboxDomain}/${BasicRouteUrl}/${configuratorId}`;\n const params = new URLSearchParams();\n\n if (config?.introImage) {\n params.set('introImage', config.introImage);\n }\n if (config?.introVideo) {\n params.set('introVideo', config.introVideo);\n }\n if (config?.loadingImage) {\n params.set('loadingImage', config.loadingImage);\n }\n if (config?.state) {\n params.set('state', decodeURIComponent(config.state));\n }\n if (config?.showLoadingProgress !== undefined) {\n params.set('showLoadingProgress', String(config.showLoadingProgress));\n }\n if (config?.showResumeStreamPopup !== undefined) {\n params.set('showResumeStreamPopup', String(config.showResumeStreamPopup));\n }\n if (config?.showUserInactivityTimer !== undefined) {\n params.set(\n 'showUserInactivityTimer',\n String(config.showUserInactivityTimer),\n );\n }\n if (config?.userInactivityTimeout !== undefined) {\n params.set('userInactivityTimeout', String(config.userInactivityTimeout));\n }\n if (config?.autoStartStream !== undefined) {\n params.set('autoStartStream', String(config.autoStartStream));\n }\n\n const query = params.toString();\n return query ? `${base}?${query}` : base;\n};\n","import { Communicator } from './communicator';\nimport type { IntegrateMetaboxConfig } from '../interfaces';\nimport { prepareIframeSrc } from './prepare-iframe-src';\n\n// Cancel for the previous integration's handshake listener while it is still\n// waiting for the iframe to load. A new integrateMetabox call supersedes it —\n// it already replaces the single embedded iframe — so a never-completed\n// handshake (failed load, SPA remount, retry) can't leak a window 'message'\n// listener for the page lifetime. Idempotent, so a completed handshake's\n// cancel is a harmless no-op here.\nlet cancelPendingHandshake: (() => void) | null = null;\n\n/**\n * Integrates the Metabox Modular Configurator into the page by injecting an iframe and\n * initializing a Communicator instance for host-to-iframe messaging.\n *\n * - Builds a secure iframe URL using the provided configuratorId and config options.\n * - Ensures the resulting URL uses HTTPS and that the target container exists.\n * - Removes any previously embedded iframe with id \"embeddedContent\" before inserting a new one.\n *\n * ### What does it unlock?\n * Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle,\n * and sets up all configurations.\n *\n * ### Practical Application\n * is THE entry point function. Creates the configurator iframe, establishes postMessage communication, and returns\n * the Communicator api handle via callback. Call ONCE per configurator. Params: configuratorId (modular UUID),\n * containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig).\n *\n * ### AI Coding Best Practices\n * Pattern: `integrateMetabox('uuid', 'div-id', (api) => {\n * set up listeners, then set a root component, then environment, then children\n * }, { standalone: true })`.\n * Ensure a container div exists in DOM with non-zero dimensions. HTTPS required.\n * Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetComponent root, 3) SetEnvironment,\n * 4) SetComponent children, 5) SetComponentMaterial.\n *\n * @param {string} configuratorId - The Modular Configurator ID (not a full URL). It is appended to\n * `https://{domain}/metabox-configurator/modular/{configuratorId}` to form the iframe src.\n *\n * @param {string} containerId - The id of the container element where the iframe will be injected.\n *\n * @param {(api: Communicator) => void} apiReadyCallback - Called when the Communicator instance is created on the host side.\n *\n * @param {IntegrateMetaboxConfig} config - Optional configuration used to build the iframe URL and initialize the communicator.\n * Supported fields:\n * - standalone?: boolean — if true, disables Metabox custom template and related logic.\n * - introImage?: string — URL to an image shown on the intro screen (added as ?introImage=...).\n * - introVideo?: string — URL to a video shown on the intro screen (added as ?introVideo=...).\n * - loadingImage?: string — URL to an image displayed while loading (added as ?loadingImage=...).\n * - state?: string — Predefined state for configurator for initial loading (added as ?state=...).\n * - domain?: string — custom domain for testing (defaults to metabox.3dsource.com). HTTPS is enforced.\n * - showLoadingProgress?: boolean — if true, shows the loading progress bar (added as ?showLoadingProgress=true).\n * - showResumeStreamPopup?: boolean — if true, shows the resume stream popup (added as ?showResumeStreamPopup=true).\n * - showUserInactivityTimer?: boolean — if true, shows the AFK countdown popup (added as ?showUserInactivityTimer=true).\n * - userInactivityTimeout?: number — inactivity timeout in seconds before disconnect (added as ?userInactivityTimeout=...).\n * - autoStartStream?: boolean — controls whether the pixel stream starts automatically on load (added as ?autoStartStream=...); set false to start it manually via ResumeStream.\n *\n * @throws Error If configuratorId or containerId are empty strings.\n * @throws Error If the computed iframe URL is invalid or does not use HTTPS.\n * @throws Error If the container element with the provided id cannot be found.\n *\n * @returns A cancel function that stops waiting for the Metabox to load.\n * Calling it is optional — a later `integrateMetabox` call automatically\n * supersedes a still-pending handshake — but it lets you remove the handshake\n * listener immediately on teardown (e.g. SPA route change before\n * `apiReadyCallback` fires). Idempotent.\n *\n * @example\n * import { integrateMetabox } from '@3dsource/metabox-modular-configurator-api';\n *\n * integrateMetabox('configurator-id',\n * 'embed3DSource',\n * (api) => {\n * // Communicator is ready to use\n * },\n * {\n * standalone: false,\n * introImage: 'https://example.com/intro.png',\n * loadingImage: 'https://example.com/loading.png',\n * showLoadingProgress: true,\n * showResumeStreamPopup: true,\n * showUserInactivityTimer: true,\n * userInactivityTimeout: 20,\n * },\n * );\n */\nexport function integrateMetabox(\n configuratorId: string,\n containerId: string,\n apiReadyCallback: (api: Communicator) => void,\n config?: IntegrateMetaboxConfig,\n): () => void {\n if (!configuratorId.trim()) {\n throw new Error(\n 'integrateMetabox: configuratorId must be a non-empty string',\n );\n }\n const iframeSrc = prepareIframeSrc(configuratorId, config);\n let parsedUrl: URL;\n try {\n parsedUrl = new URL(iframeSrc);\n } catch {\n throw new Error('integrateMetabox: Provided iframeSrc is not a valid URL');\n }\n if (parsedUrl.protocol !== 'https:') {\n throw new Error('integrateMetabox: iframeSrc must use HTTPS protocol');\n }\n if (!containerId.trim()) {\n throw new Error('integrateMetabox: containerId must be a non-empty string');\n }\n\n const container = document.getElementById(containerId);\n if (!container) {\n throw new Error(`Container element with id ${containerId} not found`);\n }\n\n const existingIframe = document.getElementById('embeddedContent');\n if (existingIframe) {\n existingIframe.remove();\n }\n\n // Supersede a prior integration still waiting for its handshake.\n cancelPendingHandshake?.();\n const cancel = Communicator.createInstance(apiReadyCallback, 'host', config);\n cancelPendingHandshake = cancel ?? null;\n\n // Inject the container rules once per containerId — repeated integrations\n // were appending identical <style> tags, forcing CSSOM reparses.\n const styleId = `metabox-integration-style-${containerId}`;\n if (!document.getElementById(styleId)) {\n const style = document.createElement('style');\n style.id = styleId;\n style.innerHTML = `\n #${containerId} {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n `;\n document.head.appendChild(style);\n }\n\n const iframe = document.createElement('iframe');\n iframe.setAttribute('allow', 'autoplay; fullscreen; encrypted-media');\n iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');\n iframe.setAttribute('id', 'embeddedContent');\n iframe.style.border = '0';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.overflow = 'hidden';\n iframe.src = iframeSrc;\n container.appendChild(iframe);\n\n return cancel;\n}\n","/**\n * Saves an image by triggering a download.\n *\n * This function creates an anchor element, sets its `href` attribute to the provided image URL,\n * and triggers a click event to initiate a download with the specified filename.\n *\n * ### What does it unlock?\n * Main exported function to save images from the configurator. Converts base64 image data to actual image\n * files and saves them to the local filesystem.\n *\n * ### Practical Application\n * Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable\n * image file. Handles the base64 → blob → browser download flow. Import directly from the API package.\n *\n * ### AI Coding Best Practices\n * Pattern: `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); })`.\n * Filename extension should match the MimeType passed to GetScreenshot.\n * Import: `import { saveImage } from '@3dsource/metabox-modular-configurator-api'`.\n *\n * @param {string} imageUrl - The URL of the image to save.\n * @param {string} filename - The name of the file to save.\n */\nexport function saveImage(imageUrl: string, filename: string): void {\n const a = document.createElement('a');\n a.href = imageUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;AAiBG;MAEU,WAAW,CAAA;AAGvB;;AChBD;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,qBAAqB,CACnC,MAAoB,EACpB,SAAY,EAAA;AAEZ,IAAA,OAAO,SAAS,CAAC,MAAM,EAAE,SAAS,CAEjC;AACH;;AC/BA;;;;;;;;;;;;;;;AAeG;AACI,MAAM,iCAAiC,GAAG;AAC/C,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,UAAU,EAAE,YAAY;AACxB,IAAA,cAAc,EAAE,gBAAgB;AAChC,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,wBAAwB,EAAE,0BAA0B;AACpD,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,0BAA0B,EAAE,4BAA4B;AACxD,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,gBAAgB,EAAE,kBAAkB;AACpC,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,kBAAkB,EAAE,oBAAoB;AACxC,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,aAAa,EAAE,eAAe;AAC9B,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,wBAAwB,EAAE,0BAA0B;;;ACzCtD;;;;;;;;;;;;;;;;;;;;;AAqBG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AM,GAAG,MAAM;AAC5B,IAAA,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ;AAChC,IAAA,MAAM,CAAC,GAAG,GAAG,SAAS;AACtB,IAAA,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;AAE7B,IAAA,OAAO,MAAM;AACf;;AC5JA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,SAAU,SAAS,CAAC,QAAgB,EAAE,QAAgB,EAAA;IAC1D,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;AACrC,IAAA,CAAC,CAAC,IAAI,GAAG,QAAQ;AACjB,IAAA,CAAC,CAAC,QAAQ,GAAG,QAAQ;AACrB,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5B,CAAC,CAAC,KAAK,EAAE;AACT,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9B;;AC7BA;;AAEG;;;;"}
1
+ {"version":3,"file":"3dsource-metabox-modular-configurator-api.mjs","sources":["../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/CommandBase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/fromCommunicatorEvent.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/interfaces/ToMetaboxMessagePayloads.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/MetaboxConfig.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetPdf.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetCallToActionInformation.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetCamera.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetCamera.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResetCamera.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResetConfiguration.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ApplyZoom.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/InitShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/PlayShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/UnrealCommand.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/PauseShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/StopShowcase.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/GetScreenshot.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetComponent.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetComponentMaterial.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetEnvironment.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/SetEnvironmentMaterial.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ShowEmbeddedMenu.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ShowOverlayInterface.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ShowMeasurement.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/HideMeasurement.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResumeStream.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/StopStream.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/actions/ResetUserInactivityTimer.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/event-dispatcher.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/constants/common.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/constants/version.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/message-source.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/communicator.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/prepare-iframe-src.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/integrate-metabox.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/lib/helpers/save-image.ts","../../../../projects/3dsource/metabox-modular-configurator-api/src/3dsource-metabox-modular-configurator-api.ts"],"sourcesContent":["import type { ToMetaBoxMessageEnvelope } from '../interfaces';\n\n/**\n * Base class for commands sent to the Metabox API.\n *\n * ### What does it unlock?\n * Base class that all other commands inherit from in a class hierarchy. Provides common properties\n * and methods that are automatically available to all command subclasses.\n *\n * ### Practical Application\n * Base class all commands inherit from. Never instantiate directly — use specific subclasses like\n * SetProduct, SetCamera, etc. All commands are sent via `api.sendCommandToMetabox(new CommandName(...))`.\n *\n * ### AI Coding Best Practices\n * Never construct a generic CommandBase. Always use the specific typed command class. When generating\n * dynamic command dispatch, use a switch/map pattern matching command names to their constructors.\n *\n * @internal\n * @hidden\n */\n\nexport class CommandBase {\n /** The message envelope populated by subclass constructors and sent via {@link Communicator.sendCommandToMetabox}. */\n data!: ToMetaBoxMessageEnvelope;\n}\n","import type { Communicator } from '../helpers';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaboxMessagePayloads,\n} from '../interfaces';\nimport type { Observable } from 'rxjs';\nimport { fromEvent } from 'rxjs';\n\n/**\n * Wrapper helper function to use with RxJS the same way as `fromEvent`, to listen to events from the Communicator.\n *\n * ### What does it unlock?\n * Function that creates an event listener subscription. Allows developers to subscribe to specific events from the Communicator.\n *\n * ### Practical Application\n * Function that creates event listener subscriptions. Alternative to api.addEventListener() — both subscribe\n * to configurator events. Use to react to state changes, screenshot readiness, viewport loading, showcase status, etc.\n *\n * ### AI Coding Best Practices\n * Prefer api.addEventListener() directly from the Communicator object. If using fromCommunicatorEvent, pass the\n * event name and handler. Key events: configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged,\n * getCameraResult. Always subscribe BEFORE sending commands that trigger responses.\n *\n * @param {Communicator} target - The Communicator instance to listen on.\n * @param {T} eventName - The event name from {@link FromMetaBoxApiEvents} to subscribe to.\n * @returns An Observable that emits the typed payload each time the event fires.\n * @internal\n */\nexport function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(\n target: Communicator,\n eventName: T,\n) {\n return fromEvent(target, eventName) as Observable<\n FromMetaboxMessagePayloads[T]\n >;\n}\n","import type { MimeType } from '../actions';\nimport type { MetaboxHost } from '../constants';\nimport type { MetaboxCommandConfig } from './metabox-config';\n\n/**\n * Registry of all action identifiers that can be sent from the host application to the Metabox Modular Configurator.\n * Each key maps to a string used as the `action` field in the postMessage envelope.\n *\n * ### What does it unlock?\n * Variable containing all available action names. Interface listing all actions that the modular configurator supports.\n *\n * ### Practical Application\n * Master action registry object — all supported configurator action names. Invaluable reference for building\n * admin dashboards, permission systems, or feature-availability displays.\n *\n * ### AI Coding Best Practices\n * Iterate this object to dynamically build action dropdowns, command palettes, or feature checklists in admin tools.\n * Each key is an action name, value is its description. Excellent reference for AI coding agents to understand\n * the full command vocabulary available.\n */\nexport const MetaboxModularConfiguratorActions = {\n metaboxConfig: 'metaboxConfig',\n resumeStream: 'resumeStream',\n stopStream: 'stopStream',\n setEnvironment: 'setEnvironment',\n setEnvironmentMaterialById: 'setEnvironmentMaterialById',\n setComponent: 'setComponent',\n setComponentMaterialById: 'setComponentMaterialById',\n getPdf: 'getPdf',\n getCallToActionInformation: 'getCallToActionInformation',\n getScreenshot: 'getScreenshot',\n showEmbeddedMenu: 'showEmbeddedMenu',\n showOverlayInterface: 'showOverlayInterface',\n getCamera: 'getCamera',\n setCamera: 'setCamera',\n resetCamera: 'resetCamera',\n resetConfiguration: 'resetConfiguration',\n applyZoom: 'applyZoom',\n initShowcase: 'initShowcase',\n playShowcase: 'playShowcase',\n pauseShowcase: 'pauseShowcase',\n stopShowcase: 'stopShowcase',\n sendCommandToUnreal: 'sendCommandToUnreal',\n showMeasurement: 'showMeasurement',\n hideMeasurement: 'hideMeasurement',\n resetUserInactivityTimer: 'resetUserInactivityTimer',\n} as const;\n\n/**\n * Union of all action string literals from {@link MetaboxModularConfiguratorActions}.\n *\n * ### What does it unlock?\n * Type alias for all actions that can be sent to MetaBox. Defines the complete set of command types available.\n *\n * ### Practical Application\n * Type alias enumerating all available outgoing command types. Master list of everything your app can tell MetaBox to do.\n * Use as a checklist when planning which features to implement.\n *\n * ### AI Coding Best Practices\n * Reference for building command dispatchers or admin tools. Full command set includes all values of\n * MetaboxModularConfiguratorActions like: \"metaboxConfig\" | \"setEnvironment\" | \"setEnvironmentMaterialById\" | ...\n */\nexport type ToMetaBoxActions =\n (typeof MetaboxModularConfiguratorActions)[keyof typeof MetaboxModularConfiguratorActions];\n\n/**\n * @internal\n * @hidden\n */\nexport type ToMetaboxMessagePayload =\n ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];\n\n/**\n * Interface for messages sent from the application to the Metabox Modular Configurator.\n *\n * ### What does it unlock?\n * Defines payload structures for different types of outgoing messages to MetaBox. Contains data models for various command parameters.\n *\n * ### Practical Application\n * Payload type definitions for all outgoing command types. Defines required and optional fields per command.\n * Essential TypeScript reference for type-safe command construction.\n *\n * ### AI Coding Best Practices\n * Use as TypeScript type reference for proper typing when building dynamic command dispatchers.\n * Each key corresponds to a command name and its value defines the expected payload structure.\n */\nexport interface ToMetaboxMessagePayloads {\n [MetaboxModularConfiguratorActions.metaboxConfig]: {\n appId: string;\n config: MetaboxCommandConfig;\n };\n [MetaboxModularConfiguratorActions.setEnvironment]: { id: string };\n [MetaboxModularConfiguratorActions.setEnvironmentMaterialById]: {\n slotId: string;\n materialId: string;\n };\n [MetaboxModularConfiguratorActions.setComponent]: {\n id: string;\n typeId: string;\n };\n [MetaboxModularConfiguratorActions.setComponentMaterialById]: {\n componentId: string;\n slotId: string;\n materialId: string;\n };\n [MetaboxModularConfiguratorActions.getScreenshot]: {\n format: MimeType;\n size?: { x: number; y: number };\n };\n [MetaboxModularConfiguratorActions.getCallToActionInformation]: void;\n [MetaboxModularConfiguratorActions.getPdf]: void;\n [MetaboxModularConfiguratorActions.showEmbeddedMenu]: { visible: boolean };\n [MetaboxModularConfiguratorActions.showOverlayInterface]: {\n visible: boolean;\n };\n [MetaboxModularConfiguratorActions.getCamera]: void;\n [MetaboxModularConfiguratorActions.setCamera]: {\n camera: CameraCommandPayload;\n };\n [MetaboxModularConfiguratorActions.resetCamera]: void;\n [MetaboxModularConfiguratorActions.resetConfiguration]: void;\n [MetaboxModularConfiguratorActions.applyZoom]: { zoom: number };\n [MetaboxModularConfiguratorActions.initShowcase]: void;\n [MetaboxModularConfiguratorActions.playShowcase]: void;\n [MetaboxModularConfiguratorActions.pauseShowcase]: void;\n [MetaboxModularConfiguratorActions.stopShowcase]: void;\n [MetaboxModularConfiguratorActions.sendCommandToUnreal]: object;\n [MetaboxModularConfiguratorActions.showMeasurement]: void;\n [MetaboxModularConfiguratorActions.hideMeasurement]: void;\n [MetaboxModularConfiguratorActions.resetUserInactivityTimer]: void;\n [MetaboxModularConfiguratorActions.stopStream]: void;\n}\n\n/**\n * Payload for the {@link SetCamera} command describing the desired camera state in the Unreal scene.\n * All fields are optional — only the provided values will be applied.\n *\n * ### What does it unlock?\n * Defines the payload structure for camera commands. Contains camera-related parameters passed to SetCamera command.\n *\n * ### Practical Application\n * Read-only interface defining camera parameters: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),\n * rotation ({horizontal: yaw, vertical: pitch}), and restrictions (distance/FOV/rotation limits).\n * Both returned by getCameraResult event and accepted by SetCamera.\n *\n * ### AI Coding Best Practices\n * This interface is bidirectional — returned from GetCamera and accepted by SetCamera.\n * Capture a camera state via getCameraResult and replay it with SetCamera(payload).\n * Only include restriction fields you want to enforce; omitted values keep current settings.\n * In orbit mode, distance limits are relative to the orbit pivot.\n */\nexport interface CameraCommandPayload {\n /** Field of view angle in degrees. */\n fov?: number;\n /** Camera control mode: `'fps'` for first-person or `'orbit'` for orbital rotation around pivot. */\n mode?: 'fps' | 'orbit';\n /** Camera position in 3D world space. */\n position?: { x: number; y: number; z: number };\n /** Camera rotation angles in degrees. */\n rotation?: {\n horizontal: number;\n vertical: number;\n };\n /** Min/max constraints applied to camera movement, zoom, and rotation. */\n restrictions?: {\n maxDistanceToPivot?: number;\n maxFov?: number;\n maxHorizontalRotation?: number;\n maxVerticalRotation?: number;\n minDistanceToPivot?: number;\n minFov?: number;\n minHorizontalRotation?: number;\n minVerticalRotation?: number;\n };\n}\n\n/**\n * @internal\n * @hidden\n * Envelope wrapping an action and its payload for host-to-Metabox postMessage communication.\n *\n * ### What does it unlock?\n * Envelope structure for outgoing MetaBox messages. Encapsulates messages with protocol headers for transmission.\n *\n * ### Practical Application\n * Protocol envelope for outgoing messages — adds headers for transmission to MetaBox iframe.\n * Internal to the communication layer, handled automatically by the Communicator.\n *\n * ### AI Coding Best Practices\n * Do not construct manually. The Communicator handles all message wrapping. Only reference this interface\n * if debugging raw postMessage traffic in browser devtools to diagnose why commands aren't being received.\n */\nexport interface ToMetaBoxMessageEnvelope {\n action: ToMetaBoxActions;\n payload?: ToMetaboxMessagePayload | never;\n}\n\n/**\n * @internal\n * @hidden\n */\nexport type ToMetaboxTarget = 'metabox' | 'child';\n\n/**\n * @internal\n * @hidden\n * Top-level postMessage structure sent from the host to the Metabox iframe.\n *\n * ### What does it unlock?\n * Message interface for sending data to MetaBox. Wraps outgoing commands with necessary protocol information.\n *\n * ### Practical Application\n * Outgoing message format for commands to MetaBox. Wraps commands with protocol information for postMessage delivery.\n * Handled automatically by Communicator.sendCommandToMetabox() — never construct manually.\n *\n * ### AI Coding Best Practices\n * Do not construct ToMetaBoxMessage objects. Always use `api.sendCommandToMetabox(new CommandName(...))`.\n * The Communicator wraps your command in the correct message format automatically.\n */\nexport interface ToMetaBoxMessage {\n host: typeof MetaboxHost;\n envelope: ToMetaBoxMessageEnvelope;\n /**\n * @deprecated, use envelope instead of payload\n */\n payload: ToMetaBoxMessageEnvelope;\n target: ToMetaboxTarget;\n apiVersion: string;\n}\n","import { CommandBase } from './CommandBase';\nimport type { MetaboxCommandConfig } from '../interfaces';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to send Metabox Config to Metabox Modular Configurator.\n *\n * ### What does it unlock?\n * Configuration object passed to MetaBox during initialization. Specifies domain, host, standalone mode,\n * and other parameters that control how the configurator behaves.\n *\n * ### Practical Application\n * Internal configuration object auto-sent during initialization. Contains appId and config.\n * DO NOT call directly — integrateMetabox() handles this automatically as part of its setup sequence.\n *\n * ### AI Coding Best Practices\n * NEVER instantiate or send MetaboxConfig manually. It is auto-sent by integrateMetabox().\n * Use the IntegrateMetaboxConfig parameter of integrateMetabox() instead for setting domain, standalone,\n * loadingImage, introImage, state, etc.\n *\n * @internal\n * Automatically sent when the Communicator instance is ready.\n *\n * @param {string} appId - The unique identifier for the Communicator Instance\n * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\n */\n\nexport class MetaboxConfig extends CommandBase {\n constructor(appId: string, config: MetaboxCommandConfig) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.metaboxConfig,\n payload: { appId, config },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a PDF from Metabox Modular Configurator.\n * This class sends a message to the Metabox API to generate a PDF based on the current configuration.\n * **Important**: No need to listen to any events to see changes. Pdf will be downloaded automatically once it's ready.\n *\n * ### What does it unlock?\n * Generates a native MetaBox PDF document. No subscription required — it executes independently.\n *\n * ### Practical Application\n * Generates a branded PDF from the current configurator state server-side. No event subscription needed.\n * Use for B2B quote workflows, downloadable spec sheets, or emailing configured product summaries to prospects.\n *\n * ### AI Coding Best Practices\n * Simply call `api.sendCommandToMetabox(new GetPdf())`. No parameters or event subscription required.\n * The PDF generates inside MetaBox application.\n *\n * @example\n * import { GetPdf, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new GetPdf());\n * };\n */\nexport class GetPdf extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.getPdf };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get a Call To Action Information from Metabox Modular Configurator.\n * This class sends a message to the Metabox API to generate Call To Action information based on the current\n * configuration and sends it to the endpoint URL from the CTA information.\n *\n * To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Retrieves information about call-to-action that were added to the configurator. Requires subscription to receive data.\n *\n * ### Practical Application\n * Triggers the CTA (Call-to-Action) workflow configured in MetaBox admin. The CTA label and callback URL are set in admin.\n * When invoked, MetaBox POSTs the full configuration JSON (including BOM) to your callback URL endpoint, which returns a { redirectUrl }.\n *\n * ### AI Coding Best Practices\n * Call only after user completes configuration. Subscribe to ecomConfiguratorDataUpdated to get CTA label/URL for building\n * custom CTA buttons in your UI. The POST payload includes the full bill of materials — your backend endpoint processes it\n * and returns a redirect URL.\n *\n * @example\n * import { Communicator, EcomConfigurator, GetCallToActionInformation } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('ecomConfiguratorDataUpdated', (data:EcomConfigurator) => {\n * console.log('Ecom configurator params:', data);\n * });\n *\n * // Send the command to get Call To Action information from Metabox Modular Configurator\n * api.sendCommandToMetabox(new GetCallToActionInformation());\n * };\n */\nexport class GetCallToActionInformation extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.getCallToActionInformation,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to get the camera configuration from Unreal.\n * This class sends a message to the Metabox API to get the camera from a scene.\n * To listen for changes after sending this command, listen to the 'getCameraResult' event.\n *\n * ### What does it unlock?\n * Retrieves camera presets for the configurator; allowing extraction and application of saved camera positions.\n *\n * ### Practical Application\n * Requests current camera state — returns asynchronously via the getCameraResult event. Returns a CameraCommandPayload\n * with fov, mode, position, rotation, and restrictions. Use to save camera positions, create shareable view links,\n * or build 'save this angle' features.\n *\n * ### AI Coding Best Practices\n * ALWAYS subscribe to getCameraResult BEFORE calling GetCamera(). Pattern: `api.addEventListener('getCameraResult', handler);`\n * then `api.sendCommandToMetabox(new GetCamera())`. The returned CameraCommandPayload can be fed directly back into\n * SetCamera to restore the view.\n *\n * @example\n * import { Communicator, CameraCommandPayload, GetCamera } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('getCameraResult', (data:CameraCommandPayload) => {\n * console.log('Camera params after get camera command:', data);\n * });\n *\n * api.sendCommandToMetabox(new GetCamera());\n * };\n */\nexport class GetCamera extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.getCamera };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport type { CameraCommandPayload } from '../interfaces';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set the camera configuration.\n * This class sends a message to the Metabox API to set the camera on a scene.\n * **Important**: No need to listen to any events to see changes.\n *\n * ### What does it unlock?\n * Sets camera presets with restriction parameters (FOV, rotation, position).\n *\n * ### Practical Application\n * Sets camera with precise control: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}),\n * rotation ({horizontal,vertical}), and restrictions (min/max distance, FOV, rotation bounds).\n * Use for guided tours, preset view buttons, or restricting camera to prevent users seeing behind the product.\n *\n * ### AI Coding Best Practices\n * Only include fields you want to change — omitted values keep current settings. Use orbit mode for typical product viewing,\n * fps for walkthrough/room scenes. Apply restrictions to prevent bad angles. Full interface:\n * `{fov?, mode?, position?, rotation?, restrictions?}`.\n *\n * @example\n * import { SetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new SetCamera({\n * fov: 45,\n * mode: 'orbit',\n * position: { x: 100, y: 100, z: 100 },\n * rotation: { horizontal: 0, vertical: 0 },\n * restrictions: {\n * maxDistanceToPivot: 0,\n * maxFov: 0,\n * maxHorizontalRotation: 0,\n * maxVerticalRotation: 0,\n * minDistanceToPivot: 0,\n * minFov: 0,\n * minHorizontalRotation: 0,\n * minVerticalRotation: 0,\n * },\n * }));\n * };\n *\n * @param {CameraCommandPayload} camera - The camera configuration.\n */\nexport class SetCamera extends CommandBase {\n constructor(camera: CameraCommandPayload) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.setCamera,\n payload: { camera },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to reset the camera to its initial position.\n * This class sends a message to the Metabox API to reset the camera on a scene.\n *\n * ### What does it unlock?\n * Resets the camera to its default state and position. Used to return camera to initial configuration after user manipulation.\n *\n * ### Practical Application\n * Resets camera to the default position defined in the component/environment template. Essential for 'Reset View' buttons.\n * Also, useful after programmatic camera moves to return to a known starting state.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResetCamera())`. No parameters. Restores template defaults — not the last user position.\n * Good practice to call after SetComponent changes that may shift the focal point of the assembly.\n *\n * @example\n * import { ResetCamera, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ResetCamera());\n * };\n */\n\nexport class ResetCamera extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.resetCamera };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to reset the modular configurator state to its defaults.\n * This class sends a message to the Metabox API to restore the component tree, component materials,\n * environment, and environment materials to the values defined by the configurator template.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Resets the entire modular configurator state to defaults — root and child components, all component\n * material selections, environment, and environment materials all return to the template-defined initial\n * values. Used to give users a clean 'Start Over' affordance without reloading the iframe.\n *\n * ### Practical Application\n * Powers 'Reset to Defaults' / 'Start Over' buttons in modular configurators where users have built up\n * an assembly with multiple SetComponent / SetComponentMaterial calls. Unlike ResetCamera (which only\n * touches viewport state), ResetConfiguration wipes all user-applied selections back to template\n * defaults. The configurator responds with a full ModularConfiguratorEnvelope via configuratorDataUpdated,\n * so UI state derived from the envelope (configurationTree, componentsByComponentType, material chips)\n * will re-sync automatically.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResetConfiguration())`. No parameters. Subscribe to\n * configuratorDataUpdated BEFORE sending so you capture the reset envelope. If your UI maintains local\n * selection state separate from the envelope, clear it in the same handler. After reset, the root\n * component is back to the template default — no need to re-issue SetComponent for the root unless you\n * want a different starting assembly. Pair with ResetCamera if you also want the viewport returned to\n * its default framing.\n *\n * @example\n * import { ResetConfiguration, Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data: ModularConfiguratorEnvelope) => {\n * console.log('Configurator reset to default state:', data);\n * });\n *\n * api.sendCommandToMetabox(new ResetConfiguration());\n * };\n */\n\nexport class ResetConfiguration extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.resetConfiguration,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to apply zoom and change the camera zoom on a scene.\n * This class sends a command to the Metabox API to change zoom on a scene.\n *\n * ### What does it unlock?\n * Controls zoom functionality for the configurator; allowing users to adjust the zoom level of 3D objects and camera presets.\n *\n * ### Practical Application\n * Implements programmatic zoom on the pixel-streamed viewport. Use to build zoom slider controls, pinch-to-zoom on mobile,\n * or 'zoom to detail' buttons. Takes a numeric delta: positive zooms in, negative zooms out\n * (e.g., ApplyZoom(50) zooms in, ApplyZoom(-50) zooms out).\n *\n * ### AI Coding Best Practices\n * Always use numeric delta values, not absolute zoom levels. Pair with a UI slider that sends incremental values.\n * Debounce zoom input to ~100ms intervals to prevent overwhelming the Unreal stream.\n * Pattern: `api.sendCommandToMetabox(new ApplyZoom(50))`.\n *\n * @example\n * import { ApplyZoom, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ApplyZoom(50));\n * };\n *\n * @param {number} zoom - The zoom value to apply.\n */\n\nexport class ApplyZoom extends CommandBase {\n constructor(zoom: number) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.applyZoom,\n payload: { zoom },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to initialize Showcase for a component scene and start a sequence for the component.\n * This class sends a command to the Metabox API to initialize showcase if the component has a sequence.\n * To check this, find the showcase property in the current component and listen to the 'configuratorDataUpdated' event.\n * If this property exists, you can send the init showcase command.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Initializes and displays the showcase/demo view for the configurator. Used when transitioning into presentation or demo mode.\n *\n * ### Practical Application\n * Loads the showcase/animation sequence attached to the current component. Must be called BEFORE PlayShowcase.\n * Use to initialize auto-playing product demos, trade show presentations, or hero section animations on landing pages.\n *\n * ### AI Coding Best Practices\n * ALWAYS call InitShowcase() before PlayShowcase(). Required sequence: InitShowcase → PlayShowcase → PauseShowcase/StopShowcase.\n * Subscribe to showcaseStatusChanged to track playback state ('playing'/'paused'/'stopped').\n *\n * @example\n * import { Communicator, ShowCaseStatus, InitShowcase } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new InitShowcase());\n * };\n */\n\nexport class InitShowcase extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.initShowcase,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to play Showcase for a component when it is already initialized and paused.\n * This class sends a command to the Metabox API to play showcase for a component if it is already initialized and paused.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Starts or resumes the showcase/timeline playback. Executes the internal MetaBox play command internally.\n *\n * ### Practical Application\n * Starts or resumes showcase playback. Use for 'Play Demo' buttons on landing pages, auto-play on page load,\n * or resuming demos after inactivity timeout on kiosk displays.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new PlayShowcase())`. Must call InitShowcase() first or it won't play.\n * Subscribe to showcaseStatusChanged to track state. Auto-play pattern: wait for viewportReady → InitShowcase →\n * PlayShowcase.\n *\n * @example\n * import { Communicator, PlayShowcase } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new PlayShowcase());\n * };\n */\n\nexport class PlayShowcase extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.playShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * @internal\n * @hidden\n * Represents a command to send Unreal command.\n */\n\nexport class UnrealCommand extends CommandBase {\n constructor(payload: object) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.sendCommandToUnreal,\n payload,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to pause Showcase for a component when it is already initialized and playing.\n * This class sends a command to the Metabox API to pause showcase for a component if it is already initialized and playing.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Pauses the showcase/timeline playback. Can be called independently without requiring any flag parameters.\n *\n * ### Practical Application\n * Pauses showcase animation playback. The showcase remains initialized and can be resumed with\n * PlayShowcase. Use when you need to temporarily freeze the animation (e.g., on a \"Pause\" button click).\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new PauseShowcase())`. No parameters. Subscribe to showcaseStatusChanged\n * to confirm 'pause' state. Use PlayShowcase to resume or StopShowcase to reset.\n *\n * @example\n * import { Communicator, ShowCaseStatus, PauseShowcase } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new PauseShowcase());\n * };\n */\n\nexport class PauseShowcase extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.pauseShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to stop Showcase for a component when it is already initialized, and you want to destroy it.\n * This class sends a command to the Metabox API to stop showcase for a component if it is already initialized.\n *\n * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event.\n *\n * ### What does it unlock?\n * Stops the showcase/timeline playback and closes the showcase mode. Returns to normal configurator view.\n *\n * ### Practical Application\n * Stops showcase playback and exits showcase mode entirely. Returns to normal interactive configurator view.\n * Use for 'Exit Demo' buttons or auto-trigger when the user starts actively configuring the product.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new StopShowcase())`. Fully resets the showcase state. Subscribe to\n * showcaseStatusChanged to confirm 'stopped' status. After stopping, the configurator returns to full\n * interactive mode — re-enable configuration controls.\n *\n * @example\n * import { Communicator, ShowCaseStatus } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('showcaseStatusChanged', (data:ShowCaseStatus) => {\n * console.log('Showcase status value after changed:', data);\n * });\n *\n * api.sendCommandToMetabox(new StopShowcase());\n * };\n */\n\nexport class StopShowcase extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.stopShowcase };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Image format.\n * This type represents the allowed image formats.\n *\n * ### What does it unlock?\n * Type alias for MIME types used in file/media handling. Defines supported file formats and media types.\n *\n * ### Practical Application\n * Type alias: 'image/png' | 'image/jpeg' | 'image/webp'. Used as the format parameter in GetScreenshot.\n * PNG for quality/transparency, JPEG for smaller files, WebP for modern browser optimization.\n *\n * ### AI Coding Best Practices\n * Pass as first param to GetScreenshot: `new GetScreenshot('image/png', {x:2048, y:2048})`.\n * Use PNG for highest quality and transparency. JPEG for smaller file size. WebP for modern browser optimization.\n * Match the saveImage filename extension to the format.\n */\nexport type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';\n\n/**\n * Represents a command to get a screenshot.\n *\n * To listen for changes after sending this command, listen to the 'screenshot' event before command is sent.\n *\n * ### What does it unlock?\n * Takes a screenshot on the server side (Unreal Engine) of the 3D scene. Returns high-quality image.\n * Requires subscription to the screenshotReady event to receive the rendered image.\n *\n * ### Practical Application\n * Renders a high-res screenshot on the Unreal Engine server. Takes format ('image/png'|'image/jpeg'|'image/webp')\n * and optional size ({x, y}). Returns base64 data via screenshotReady event. Use for thumbnails, social sharing,\n * saving config snapshots, or attaching images to quotes.\n *\n * ### AI Coding Best Practices\n * Subscribe to screenshotReady BEFORE sending GetScreenshot. Pattern:\n * `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'name.png'); })`.\n * Specify size for consistent outputs: `new GetScreenshot('image/png', {x:2048, y:2048})`.\n * Use saveImage() helper to convert base64 to downloadable file.\n *\n * @example\n * import { Communicator, saveImage, GetScreenshot } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('screenshot', (data:string) => {\n * // The data is a base64 string of the image. You can use it to display the image or save it as a file.\n * console.log('Get screenshot here:', data);\n * saveImage(data, 'Render.png');\n * });\n *\n * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));\n * };\n *\n * @param {MimeType} mimeType - The output format.\n * @param {{ x: number; y: number }} [size] - Optional size in pixels.\n */\nexport class GetScreenshot extends CommandBase {\n constructor(mimeType: MimeType, size?: { x: number; y: number }) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.getScreenshot,\n payload: { format: mimeType, size },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set a component by its data (ID, typeId).\n * This action sends a message to the Metabox API to set a component using the provided data.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets a component during initialization, which triggers the reconstruction of the component tree structure.\n * Simulates clicking a component in the menu.\n *\n * ### Practical Application\n * Selects a component in the modular assembly. Takes componentId (UUID), typeId (category string).\n * CRITICAL: Always set root component (isRoot:true) FIRST — nothing renders without it. Then add children (isRoot:false).\n * Simulates clicking a component in the menu.\n *\n * ### AI Coding Best Practices\n * ALWAYS set root first: `new SetComponent('id', 'type', true)`. Then children: `new SetComponent('childId', 'childType', false)`.\n * Get valid IDs from configuratorDataUpdated event data — the configurator definition contains all available components and types.\n * Wrong order = blank viewport. The typeId must match componentType values from the configurator.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope, SetComponent } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new component:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetComponent(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'typeId'\n * ));\n * };\n *\n * @param {string} id - The component ID.\n * @param {string} typeId - The component type ID.\n */\nexport class SetComponent extends CommandBase {\n constructor(id: string, typeId: string) {\n super();\n this.data = {\n payload: { id, typeId },\n action: MetaboxModularConfiguratorActions.setComponent,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set component material by its slot ID and Material ID.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets a material variant for a component. Simulates selecting a different material from the menu for a specific component.\n *\n * ### Practical Application\n * Applies a material to a specific slot on a component. Takes componentId (UUID), slotId (string), and materialId (UUID).\n * Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external\n * PIM/ERP system via externalId mapping.\n *\n * ### AI Coding Best Practices\n * Get valid slotId and materialId values from the configuratorDataUpdated envelope —\n * check component slot definitions and material lists. Pattern:\n * `new SetComponentMaterial('component-uuid', 'slot-name', 'material-uuid')`. The referenced component must already be set in the tree.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope, SetComponentMaterial } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new material:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetComponentMaterial(\n * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n *\n * @param {string} componentId - The component ID.\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\nexport class SetComponentMaterial extends CommandBase {\n constructor(componentId: string, slotId: string, materialId: string) {\n super();\n this.data = {\n payload: { componentId, slotId, materialId },\n action: MetaboxModularConfiguratorActions.setComponentMaterialById,\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set the environment by its ID.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets environmental/lighting settings for the scene. Controls factors like lighting conditions and environmental appearance.\n *\n * ### Practical Application\n * Changes the 3D scene/environment (studio, showroom, outdoor, etc.). Takes an environmentId UUID.\n * Environments include lighting, backdrop, and optionally dynamic sky (udsEnabled) with time-of-day (udsHour) control.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new SetEnvironment('env-uuid'))`. Get valid environment IDs from the configurator\n * definition in configuratorDataUpdated. Set environment after root component during initialization. Each environment has\n * its own material slots, thumbnails, and lighting properties.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new environment:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'))\n * };\n *\n * @param {string} environmentId - The environment ID.\n */\nexport class SetEnvironment extends CommandBase {\n constructor(environmentId: string) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.setEnvironment,\n payload: { id: environmentId },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to set an environment material by its slot ID and Material ID.\n * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.\n *\n * ### What does it unlock?\n * Sets environmental material properties such as textures and appearance attributes for the scene environment.\n *\n * ### Practical Application\n * Applies materials to environment slots (floor, walls, backdrop textures). Takes slotId and materialId.\n * Use for scene-based configurators where the environment is also customizable — kitchen visualizers,\n * room planners, trade show booth designers.\n *\n * ### AI Coding Best Practices\n * Pattern: `new SetEnvironmentMaterial('floor-slot-id', 'material-uuid')`. Get valid slot and material IDs from\n * the environment definition's slots array in configuratorDataUpdated. Only useful when the active environment\n * has configurable material slots.\n *\n * @example\n * import { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n *\n * //Subscribe to the event before sending the command to ensure you capture the response\n * api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {\n * console.log('State updated after applied new environment material:', data);\n * });\n *\n * api.sendCommandToMetabox(new SetEnvironmentMaterial(\n * 'carpaint',\n * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',\n * ));\n * };\n *\n * @param {string} slotId - The slot ID.\n * @param {string} materialId - The material ID.\n */\n\nexport class SetEnvironmentMaterial extends CommandBase {\n constructor(slotId: string, materialId: string) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.setEnvironmentMaterialById,\n payload: { slotId, materialId },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the embedded Metabox menu.\n * This command can only be used when using the metabox menu.\n *\n * ### What does it unlock?\n * Shows the embedded menu interface. Only works when using the MetaBox native menu (not in standalone/custom menu\n * mode).\n *\n * ### Practical Application\n * Toggles the native MetaBox right sidebar menu. Takes a boolean parameter. Pass false to hide when building custom UI.\n * In standalone mode, the menu is already hidden — this is only relevant in default (non-standalone) mode.\n *\n * ### AI Coding Best Practices\n * In standalone mode (`{standalone:true}`), this is unnecessary (menu already hidden). In default mode,\n * call `new ShowEmbeddedMenu(false)` early in initialization to hide built-in UI before rendering custom controls.\n * Pattern for custom UI: `ShowEmbeddedMenu(false)` + `ShowOverlayInterface(false)`.\n *\n * @example\n * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ShowEmbeddedMenu(true));\n * };\n *\n * @param {boolean} visible - A flag indicating whether the embedded menu should be visible.\n */\n\nexport class ShowEmbeddedMenu extends CommandBase {\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.showEmbeddedMenu,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to toggle the Unreal Overlay Interface Menu.\n * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.\n *\n * ### What does it unlock?\n * Shows the overlay interface elements. Displays UI controls and buttons overlaid on the 3D scene.\n *\n * ### Practical Application\n * Toggles viewport overlay controls (buttons overlaid on the 3D scene). Takes a boolean.\n * Use `ShowOverlayInterface(false)` alongside `ShowEmbeddedMenu(false)` when building fully custom UI\n * that replaces all native MetaBox controls.\n *\n * ### AI Coding Best Practices\n * In standalone mode, overlays are already hidden. In default mode, call `new ShowOverlayInterface(false)`\n * early in initialization to prevent flash of native UI. Always pair with `ShowEmbeddedMenu(false)` for clean custom UI.\n * Pass true to restore if entering a mode that uses native controls.\n *\n * @example\n * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ShowOverlayInterface(true));\n * };\n *\n * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.\n */\n\nexport class ShowOverlayInterface extends CommandBase {\n constructor(visible: boolean) {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.showOverlayInterface,\n payload: { visible },\n };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to show measurement for a product when it is already loaded.\n * This class sends a command to the Metabox API to show measurement for a product if it is already initialized.\n *\n * ### What does it unlock?\n * Shows the measurement overlay. Works as a toggle with HideMeasurement to control visibility.\n *\n * ### Practical Application\n * Shows the measurement/dimension overlay tools on the 3D viewport. Use for B2B or technical applications\n * where buyers need to verify product dimensions, check fit specifications, or confirm measurements during procurement.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ShowMeasurement())`. No parameters. Pair with HideMeasurement for toggle behavior.\n * Track visibility state in your app to keep toggle buttons in sync.\n *\n * @example\n * import { ShowMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ShowMeasurement());\n * };\n */\n\nexport class ShowMeasurement extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.showMeasurement };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to hide measurement for a product when it is already loaded.\n * This class sends a command to the Metabox API to hide measurement for a product if it is already initialized.\n *\n * ### What does it unlock?\n * Hides the measurement overlay. Executes unconditionally to hide the UI controls.\n *\n * ### Practical Application\n * Hides the measurement/dimension overlay. Use when transitioning from a technical spec view back to a clean\n * product presentation, or to keep consumer-facing configurators visually clean.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new HideMeasurement())`. No parameters. Pair with ShowMeasurement as a toggle.\n * Track visibility state in your app state to keep toggle buttons in sync.\n *\n * @example\n * import { HideMeasurement, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new HideMeasurement());\n * };\n */\n\nexport class HideMeasurement extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.hideMeasurement };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to resume the pixel streaming session.\n * This class sends a message to the Metabox API to resume a paused or disconnected stream.\n *\n * ### What does it unlock?\n * Resumes the Unreal Engine pixel streaming connection after it has been paused, disconnected, or stopped due to inactivity (AFK timeout).\n *\n * ### Practical Application\n * Used to reconnect the 3D streaming session without a full page reload. Essential for 'Reconnect' or 'Resume' buttons\n * shown when the stream is interrupted, e.g., after an idle timeout or network disruption.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResumeStream())`. No parameters. Resumes the existing streaming session —\n * does not reinitialize the configurator or reset component/environment state.\n *\n * @example\n * import { ResumeStream, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new ResumeStream());\n * };\n */\n\nexport class ResumeStream extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.resumeStream };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to stop the pixel streaming session.\n * This class sends a message to the Metabox API to stop the active stream and release its resources.\n *\n * ### What does it unlock?\n * Stops the Unreal Engine pixel streaming connection, terminating the active session and freeing server-side resources.\n *\n * ### Practical Application\n * Used to explicitly end the 3D streaming session — e.g., when the user closes a modal, navigates away, or a\n * custom \"Stop\"/\"Disconnect\" button is pressed. Pair with {@link ResumeStream} to restart the session later\n * without a full page reload.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new StopStream())`. No parameters. Stops the existing streaming session —\n * does not reset component/environment state. Use `ResumeStream` to reconnect afterwards.\n *\n * @example\n * import { StopStream, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.sendCommandToMetabox(new StopStream());\n * };\n */\n\nexport class StopStream extends CommandBase {\n constructor() {\n super();\n this.data = { action: MetaboxModularConfiguratorActions.stopStream };\n }\n}\n","import { CommandBase } from './CommandBase';\nimport { MetaboxModularConfiguratorActions } from '../interfaces';\n\n/**\n * Represents a command to reset the user inactivity (AFK) timer.\n * This class sends a message to the Metabox API to restart the inactivity countdown,\n * keeping the session alive when activity is detected programmatically.\n *\n * ### What does it unlock?\n * Resets the AFK inactivity timer, preventing an imminent disconnect when the countdown is active.\n *\n * ### Practical Application\n * Used to programmatically signal user activity and reset the inactivity countdown.\n * Pair with the `userInactivityDetected` event to show a custom \"Stay connected?\" prompt\n * and call this command when the user confirms, dismissing the countdown.\n *\n * ### AI Coding Best Practices\n * Call `api.sendCommandToMetabox(new ResetUserInactivityTimer())`. No parameters.\n * Typically triggered from a \"Stay connected\" or \"I'm still here\" button rendered when\n * `userInactivityDetected.countdownVisible` is `true`.\n *\n * @example\n * import { ResetUserInactivityTimer, Communicator } from '@3dsource/metabox-modular-configurator-api';\n * window.env3DSource.apiReady = (api: Communicator) => {\n * api.addEventListener('userInactivityDetected', ({ countdownVisible }) => {\n * if (countdownVisible) {\n * // show custom UI, then on user confirmation:\n * api.sendCommandToMetabox(new ResetUserInactivityTimer());\n * }\n * });\n * };\n */\n\nexport class ResetUserInactivityTimer extends CommandBase {\n constructor() {\n super();\n this.data = {\n action: MetaboxModularConfiguratorActions.resetUserInactivityTimer,\n };\n }\n}\n","/**\n * Represents a callback listener for specific message types.\n * Used internally by EventDispatcher to store event listeners.\n *\n * ### What does it unlock?\n * Event listener interface. Allows subscription to specific events from the configurator to receive real-time data updates.\n *\n * ### Practical Application\n * Event listener interface. addEventListener() and removeEventListener() on Communicator. Subscribe to real-time\n * configurator events: state changes, viewport readiness, screenshots, showcase status, camera results, resolution changes.\n *\n * ### AI Coding Best Practices\n * Set up listeners BEFORE sending commands that trigger them. Always clean up with removeEventListener on component unmount.\n * Key events: configuratorDataUpdated (every state change), viewportReady (init complete), screenshotReady (captures),\n * getCameraResult (camera queries), showcaseStatusChanged (demo playback).\n *\n * @public\n */\nexport interface Listener {\n /** The message type this listener is registered for */\n messageType: string;\n /** The callback function to execute when a message of the specified type is received */\n callback: (data: unknown) => void;\n}\n\n/**\n * EventDispatcher is a class that manages event listeners and dispatches events to them.\n *\n * ### What does it unlock?\n * Parent class of Communicator that dispatches commands. Acts as an event dispatcher that routes command messages internally.\n *\n * ### Practical Application\n * Internal event routing layer — parent class of Communicator. Routes postMessage commands between your app\n * and the Unreal Engine pixel stream. Not used directly but understanding it helps debug message delivery issues.\n *\n * ### AI Coding Best Practices\n * Do not reference or extend EventDispatcher in application code. Use only the Communicator interface methods.\n * If debugging communication failures, check browser console for postMessage errors related to this layer.\n */\nexport class EventDispatcher {\n /**\n * Storage for callback listeners by message type.\n */\n listeners: Listener[] = [];\n\n /**\n * Removes all registered listeners. Subclasses override this to perform additional cleanup.\n * @param key - Instance key (used by subclass overrides for registry cleanup).\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n destroy(key: string) {\n this.listeners = [];\n }\n\n /**\n * Adds an event listener for receiving specific types of messages.\n *\n * @param {string} messageType - The message type to listen for.\n * @param callback - The callback function to execute when a message is received.\n */\n addEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners.push({ messageType, callback });\n return this;\n }\n\n /**\n * Dispatches an event to all listeners of a specific message type.\n *\n * @param {string} messageType - The message type.\n * @param data - The data associated with the event.\n */\n dispatchEvent(messageType: string, data: unknown): this {\n // Allocation-free dispatch on the hot message path. The length snapshot\n // keeps the previous filter-snapshot semantics: listeners added during\n // dispatch are not invoked for this event, and removeEventListener\n // reassigns the array so the in-flight loop is unaffected.\n const listeners = this.listeners;\n const len = listeners.length;\n for (let i = 0; i < len; i++) {\n const listener = listeners[i];\n if (listener.messageType === messageType) {\n listener.callback(data);\n }\n }\n return this;\n }\n\n /**\n * Removes an event listener for a specific type of message.\n *\n * @param {string} messageType - The message type.\n * @param callback - The callback function to remove.\n */\n removeEventListener(\n messageType: string,\n callback: (data: unknown) => void,\n ): this {\n this.listeners = this.listeners.filter(\n (listener) =>\n !(\n listener.messageType === messageType && listener.callback === callback\n ),\n );\n return this;\n }\n}\n","/**\n * @internal\n * @hidden\n * Core constants used for host-to-iframe communication and URL construction.\n */\n\n/**\n * Storage key for the Metabox Communicator instance registry.\n *\n * ### What does it unlock?\n * Constant string identifier for MetaBox version. Used internally to reference the MetaBox system and versioning.\n *\n * ### Practical Application\n * Internal system reference for versioning.\n * Not needed in front-end application code.\n *\n * ### AI Coding Best Practices\n * Skip in application code. This constant is for internal MetaBox system identification only.\n *\n * @internal\n */\nexport const Metabox = 'metabox';\n\n/**\n * Identifier used as the `host` field in postMessage envelopes sent to the iframe.\n *\n * ### What does it unlock?\n * Constant for the MetaBox host connection point. Specifies endpoint for MetaBox connections.\n *\n * ### Practical Application\n * MetaBox endpoint constant. The host the configurator iframe connects to for Unreal Engine pixel streaming.\n * Not needed in front-end application code.\n *\n * ### AI Coding Best Practices\n * Skip in application code. This constant is for internal MetaBox system identification only.\n *\n * @internal\n */\nexport const MetaboxHost = 'metaboxHost';\n\n/**\n * Action string dispatched by the iframe when the configurator app has loaded.\n *\n * ### What does it unlock?\n * App initialization flag variable. Signals when MetaBox has completed loading.\n *\n * ### Practical Application\n * Use the viewportReady event (more reliable) to gate your UI rendering — don't show controls until MetaBox confirms it's ready.\n *\n * ### AI Coding Best Practices\n * Prefer the viewportReady event over this variable: `api.addEventListener('viewportReady', (ready) => { if(ready) enableUI(); })`.\n * viewportReady is the reliable signal that MetaBox is ready to accept commands.\n *\n * @internal\n */\nexport const AppLoaded = 'appLoaded';\n\n/**\n * Default MetaBox domain for production environments.\n *\n * ### What does it unlock?\n * Constant for the standard default MetaBox domain. Used as the primary domain for connecting to MetaBox server.\n *\n * ### Practical Application\n * Default MetaBox domain constant (HTTPS). The base domain used when no override is specified.\n * Override only via IntegrateMetaboxConfig.domain if connecting to a custom or self-hosted MetaBox instance.\n *\n * ### AI Coding Best Practices\n * Let integrateMetabox() use the default. Override only if needed:\n * `integrateMetabox(id, container, callback, { domain: 'https://custom.domain.com' })`. HTTPS is mandatory.\n *\n * @internal\n */\n\n/**\n * @deprecated\n */\nexport const Metabox_V3 = 'metabox_v3';\n/**\n * @deprecated\n */\nexport const MetaboxHost_V3 = 'metaboxHost_v3';\n/**\n * @deprecated\n */\nexport const AppLoaded_V3 = 'appLoaded_v3';\n\nexport const MetaboxDomain = 'metabox.3dsource.com';\n\n/**\n * Base route URL segment for the Modular Configurator.\n *\n * ### What does it unlock?\n * Base route URL constant used for loading the configurator. Standard path endpoint for accessing the modular configurator.\n *\n * ### Practical Application\n * The modular configurator URL format is: `https://{domain}/metabox-configurator/modular/{configuratorId}`.\n * Automatically constructed by integrateMetabox().\n *\n * ### AI Coding Best Practices\n * Let integrateMetabox() handle URL construction. Only reference if building URLs manually\n * (e.g., QR codes, email links, server-side rendering). The modular path is `/modular/{id}`.\n *\n * @internal\n */\nexport const BasicRouteUrl = 'metabox-configurator/modular';\n","export const VERSION = '3.0.33';\n","/**\n * Sender checks for the host↔iframe `postMessage` channel.\n *\n * Deliberately not re-exported from `./index` — `public-api.ts` does\n * `export * from './lib/helpers'`, and these are internal plumbing.\n */\n\nimport type { MetaboxEnvironment } from '../interfaces';\n\n/** Id of the iframe `integrateMetabox` creates; also the hand-rolled-embed contract. */\nexport const EmbeddedContentId = 'embeddedContent';\n\n/** `postMessage` targetOrigin meaning \"any origin, deliver to that window\". */\nexport const AnyOrigin = '*';\n\n/**\n * True iff `origin` can be used as a `postMessage` targetOrigin: a parseable\n * http/https origin *and nothing more*. Excludes `''` and the opaque `'null'`\n * origin (sandboxed frames, `file:`, `data:`), which are not valid targets, and\n * anything carrying a path, query or credentials — every real source here\n * (`URL#origin`, `MessageEvent#origin`) yields a bare origin, so a decorated\n * string means the value did not come from where we think it did.\n *\n * `postMessage` throws a `SyntaxError` on a malformed targetOrigin and silently\n * drops the message on a mismatched one, so this has to be checked up front.\n */\nexport function isTargetableOrigin(\n origin: string | null | undefined,\n): origin is string {\n if (!origin || origin === AnyOrigin || origin === 'null') {\n return false;\n }\n let url: URL;\n try {\n url = new URL(origin);\n } catch {\n return false;\n }\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n return false;\n }\n // `URL#origin` drops path/query/hash/credentials and normalises the default\n // port away, so this holds exactly for bare origins.\n return url.origin === origin;\n}\n\n/**\n * Decides whether an inbound `message` event may drive this Communicator.\n *\n * Before this gate the only check was `event.data.host === 'metabox'`, a string\n * anyone can write. That matters most inside the configurator itself, which runs\n * a Communicator in its own window for the embedded menu: without a sender check\n * the embedding page could forge configurator *events* (screenshots handed to\n * `saveImage`, catalogue/CTA data) that its own inbound guard is built to reject.\n *\n * The discriminator is `environment`, not the DOM: inside the configurator there\n * is no `#embeddedContent` element (it does not embed itself), so a purely\n * DOM-based check would fall through to \"accept anything\" and leave that exact\n * vector open.\n *\n * - `'metabox'` — the peer is the same document, so only this window qualifies.\n * Nothing here reads the DOM, so renaming an element cannot weaken it.\n * - `'host'` — the peer is our iframe. When we have no handle on one, fall back\n * to the same-window channel, mirroring `sendCommandToMetabox`, which posts to\n * this window when it finds no iframe. Accepting that case keeps hand-rolled\n * embeds working; a hard refusal would silently kill the API on those sites,\n * which is how a domain allowlist broke this channel once already.\n */\nexport function acceptsMessageFrom(\n event: Pick<MessageEvent, 'source' | 'origin'>,\n environment: MetaboxEnvironment,\n iframe: HTMLIFrameElement | null,\n): boolean {\n const sameWindow =\n event.source === window && event.origin === window.location.origin;\n\n if (environment === 'metabox') {\n return sameWindow;\n }\n\n const own = resolveIframe(iframe)?.contentWindow;\n\n return own ? event.source === own : sameWindow;\n}\n\n/**\n * The iframe this Communicator talks to: the one the integration created while\n * it is still in the document, else whatever currently holds the contract id.\n * `isConnected` matters because a superseding `integrateMetabox` call removes the\n * previous iframe, and a detached one would otherwise shadow the live element.\n */\nexport function resolveIframe(\n iframe: HTMLIFrameElement | null,\n): HTMLIFrameElement | null {\n if (iframe?.isConnected) {\n return iframe;\n }\n return document.getElementById(EmbeddedContentId) as HTMLIFrameElement | null;\n}\n","import { EventDispatcher } from './event-dispatcher';\nimport type { CommandBase } from '../actions';\nimport { MetaboxConfig } from '../actions';\nimport type {\n FromMetaBoxApiEvents,\n FromMetaBoxMessage,\n FromMetaboxMessagePayloads,\n MCAppLoaded,\n MetaboxCommandConfig,\n MetaboxEnvironment,\n ToMetaBoxMessage,\n} from '../interfaces';\nimport { AppLoaded, Metabox, MetaboxHost, VERSION } from '../constants';\nimport {\n acceptsMessageFrom,\n AnyOrigin,\n isTargetableOrigin,\n resolveIframe,\n} from './message-source';\n\nconst communicatorMap = new Map<string, { instance: Communicator }>();\n\n/**\n * What `integrateMetabox` knows about the iframe it created and the origin it\n * pointed that iframe at. Lets the Communicator check who is talking to it and\n * address the configurator by its exact origin instead of broadcasting.\n *\n * @internal\n */\nexport interface CommunicatorConnection {\n /** The embedded iframe, when we created it ourselves. */\n iframe: HTMLIFrameElement | null;\n /** Origin of the configurator document, or `null` when it is not known yet. */\n origin: string | null;\n}\n\n/**\n * Handles messaging between the host page and embedded Metabox content.\n *\n * ### What does it unlock?\n * Internal class that creates a proxy/communication layer between the API and MetaBox.\n * Handles reading and sending commands through the established connection.\n *\n * ### Practical Application\n * The API handle returned in the integrateMetabox callback. Provides sendCommandToMetabox() to send commands,\n * and addEventListener()/removeEventListener() for event subscriptions. This is your entire interface to\n * the MetaBox Unreal Engine stream.\n *\n * ### AI Coding Best Practices\n * Store the Communicator reference from the apiReadyCallback in a module-scoped variable or state store.\n * NEVER send commands before this callback fires. All commands and event listeners go through this single\n * api object. Clean up listeners with removeEventListener on component unmount.\n *\n * @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.\n */\nexport class Communicator extends EventDispatcher {\n /**\n * Bound handler for incoming postMessage events.\n */\n private binder = this.handleMessageReceived.bind(this);\n\n /** Which side of the iframe boundary this instance runs on — see `acceptsMessageFrom`. */\n private readonly environment: MetaboxEnvironment;\n\n /** The iframe we drive, when the integration created it. */\n private readonly iframe: HTMLIFrameElement | null;\n\n /** Pinned configurator origin; `null` until we learn it. */\n private readonly targetOrigin: string | null;\n\n /** Keeps the \"rejected an inbound message\" warning to one per instance. */\n private senderRejectionReported = false;\n\n /** Keeps the \"unknown configurator origin\" warning to one per instance. */\n private wildcardTargetReported = false;\n\n /** Keeps the \"our iframe left the document\" warning to one per instance. */\n private staleFrameReported = false;\n\n /**\n * Constructs a Communicator, replacing any existing instance, and begins listening for messages.\n * @internal\n */\n constructor(\n data: MCAppLoaded['payload'],\n environment: MetaboxEnvironment,\n config?: Partial<MetaboxCommandConfig>,\n connection?: CommunicatorConnection,\n ) {\n super();\n // Assigned before the listener goes up: the gate reads all three.\n this.environment = environment;\n this.iframe = connection?.iframe ?? null;\n this.targetOrigin = isTargetableOrigin(connection?.origin)\n ? connection.origin\n : null;\n const { appId = 'unknown', version = VERSION } = data ?? {};\n const key = `${version}_${environment}_${appId}`;\n communicatorMap.get(key)?.instance.destroy(key);\n communicatorMap.set(key, { instance: this });\n window.addEventListener('message', this.binder);\n this.sendCommandToMetabox(\n new MetaboxConfig(appId, {\n ...config,\n hostUrl: location.href,\n apiVersion: VERSION,\n }),\n );\n }\n\n /**\n * Listens for Metabox to signal readiness, then initializes communicator.\n * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.\n * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.\n * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic\n * @param {CommunicatorConnection} connection - the iframe and origin `integrateMetabox`\n * built, so the handshake can be attributed and later messages addressed precisely.\n * Omitted by hand-rolled embeds, which are then identified through the\n * `embeddedContent` id and the handshake's own origin.\n * @returns A cancel function that removes the handshake `message` listener.\n * `integrateMetabox` (the public entry point) calls this automatically when\n * a new integration supersedes a still-pending one, so direct internal\n * callers only need it for explicit early teardown. Idempotent.\n */\n static createInstance(\n apiReadyCallback: (api: Communicator) => void,\n environment: MetaboxEnvironment,\n config?: Partial<MetaboxCommandConfig>,\n connection?: CommunicatorConnection,\n ): () => void {\n const iframe = connection?.iframe ?? null;\n // The handshake listener outlives every rejected message, so the report is\n // kept to one: a page that keeps announcing itself must not flood the\n // console of the site embedding us.\n let rejectionReported = false;\n\n const startHandler = (event: MessageEvent) => {\n const message = event.data as FromMetaBoxMessage;\n if (message?.envelope?.action !== AppLoaded || message.host !== Metabox) {\n return;\n }\n // The handshake decides who we hand the API to and which appId keys the\n // registry, so it is gated exactly like every later message.\n if (!acceptsMessageFrom(event, environment, iframe)) {\n if (!rejectionReported) {\n rejectionReported = true;\n console.warn(\n `Metabox: ignored an \"${AppLoaded}\" handshake from an unexpected sender.`,\n );\n }\n return;\n }\n apiReadyCallback(\n new Communicator(message.envelope.payload, environment, config, {\n iframe,\n origin: Communicator.resolveHandshakeOrigin(event, connection),\n }),\n );\n window.removeEventListener('message', startHandler);\n };\n\n window.addEventListener('message', startHandler);\n return () => window.removeEventListener('message', startHandler);\n }\n\n /**\n * The origin to address the configurator by, decided once from the handshake.\n *\n * Prefers what `integrateMetabox` computed from the iframe URL, but yields to\n * the origin the handshake actually came from when the two disagree: a redirect\n * (a `config.domain` override pointing at a host that 30x's elsewhere) would\n * otherwise pin an origin nothing answers on, and every command would be\n * dropped silently. The sender already passed the window gate, so this cannot\n * be steered by an unrelated page.\n */\n private static resolveHandshakeOrigin(\n event: MessageEvent,\n connection?: CommunicatorConnection,\n ): string | null {\n const expected = isTargetableOrigin(connection?.origin)\n ? connection.origin\n : null;\n const actual = isTargetableOrigin(event.origin) ? event.origin : null;\n\n if (expected && actual && expected !== actual) {\n console.warn(\n `Metabox: the configurator answered from ${actual} but was embedded from ${expected}; using ${actual}.`,\n );\n return actual;\n }\n return expected ?? actual;\n }\n\n /**\n * Cleans up resources and stops listening for messages.\n */\n public override destroy(key: string) {\n super.destroy(key);\n window.removeEventListener('message', this.binder);\n }\n\n /** Destroys all active Communicator instances and clears the internal registry. */\n static clearAll() {\n if (communicatorMap.size === 0) {\n return;\n }\n\n communicatorMap.forEach((value, key) => value.instance.destroy(key));\n communicatorMap.clear();\n }\n\n /**\n * Retrieves a registered Communicator instance by its key.\n * @param key - The composite key (`version_environment_appId`) identifying the instance.\n */\n static getCommunicator(key: string) {\n return communicatorMap.get(key);\n }\n\n /**\n * Posts a command to the Metabox iframe.\n * @param command - An action command containing data to send.\n */\n public sendCommandToMetabox<T extends CommandBase>(command: T) {\n const { data } = command;\n const iframe = resolveIframe(this.iframe);\n this.reportStaleFrame();\n\n const toMetaboxMessage = {\n host: MetaboxHost,\n envelope: { ...data },\n // Deprecated mirror of `envelope`. Kept as an independent clone so a\n // receiver mutating one cannot observably change the other.\n payload: { ...data },\n target: iframe?.contentWindow ? 'child' : 'metabox',\n apiVersion: VERSION,\n } satisfies ToMetaBoxMessage;\n\n if (!iframe?.contentWindow) {\n console.warn(\n 'Metabox IFrame not found or not ready. Message sends to the same window',\n );\n // Same-window channel. '/' means \"only deliver if the receiver's origin\n // equals mine\", which is exactly the intent and, unlike\n // `window.location.origin`, also holds for an opaque origin: a page under\n // `sandbox=\"allow-scripts\"` reports the origin as the string \"null\",\n // which is not a valid targetOrigin and makes postMessage throw.\n window.postMessage(toMetaboxMessage, '/');\n return;\n }\n\n iframe.contentWindow.postMessage(toMetaboxMessage, this.resolveTarget());\n }\n\n /**\n * A superseding `integrateMetabox` call removes the iframe this handle was\n * built for. Commands then fall through to whatever now holds the contract id,\n * addressed by the origin pinned for the *old* integration — so if the new one\n * points at a different origin, the browser drops them without a word. The\n * handle is stale at that point and should be replaced by the one from the new\n * integration; say so rather than letting it fail quietly.\n */\n private reportStaleFrame(): void {\n if (!this.iframe || this.iframe.isConnected || this.staleFrameReported) {\n return;\n }\n this.staleFrameReported = true;\n console.warn(\n 'Metabox: the iframe this API handle was created for has left the document. ' +\n 'Commands are being sent to the current #embeddedContent instead — use the handle ' +\n 'from the latest integrateMetabox() call.',\n );\n }\n\n /**\n * `targetOrigin` for the iframe. The very first command is `metaboxConfig`,\n * which carries `hostUrl: location.href` — on a shop page that routinely holds\n * order ids and session parameters — so it must not be broadcast to whatever\n * document currently occupies the frame.\n *\n * Falls back to a wildcard rather than refusing to send: this leg carries\n * commands, and a configurator that silently stops responding on a customer\n * site is worse than the status quo. The fallback is reported once so it does\n * not pass unnoticed.\n */\n private resolveTarget(): string {\n if (this.targetOrigin) {\n return this.targetOrigin;\n }\n if (!this.wildcardTargetReported) {\n this.wildcardTargetReported = true;\n console.warn(\n 'Metabox: the configurator origin is unknown, so commands are broadcast. ' +\n 'Use integrateMetabox() to have it pinned.',\n );\n }\n return AnyOrigin;\n }\n\n /**\n * Registers an event listener for messages dispatched by the Metabox.\n * @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`).\n * @param callback - Handler invoked with the typed payload when the event fires.\n * @override\n */\n override addEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.addEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Dispatches a typed event to all registered listeners.\n * @param messageType - The event name to dispatch.\n * @param data - The payload to pass to each listener.\n * @override\n */\n override dispatchEvent<T extends FromMetaBoxApiEvents>(\n messageType: T,\n data: FromMetaboxMessagePayloads[T],\n ) {\n return super.dispatchEvent(messageType, data);\n }\n\n /**\n * Removes a previously registered event listener.\n * @param messageType - The event name the listener was registered for.\n * @param callback - The same function reference that was passed to {@link addEventListener}.\n * @override\n */\n override removeEventListener<T extends FromMetaBoxApiEvents>(\n messageType: T,\n callback: (data: FromMetaboxMessagePayloads[T]) => void,\n ) {\n return super.removeEventListener(\n messageType,\n callback as (data: unknown) => void,\n );\n }\n\n /**\n * Filters and dispatches incoming messages from the Metabox.\n * @param event - The postMessage event received on a window.\n */\n private handleMessageReceived<T extends FromMetaBoxApiEvents>(\n event: MessageEvent,\n ) {\n if (event.data?.host !== Metabox) {\n return;\n }\n // `host` is a string anyone can write, so it says nothing about who sent\n // this. Everything below dispatches configurator events to application\n // listeners — screenshots, catalogue and CTA data — so the sender is checked\n // before any of it runs.\n if (!acceptsMessageFrom(event, this.environment, this.iframe)) {\n if (!this.senderRejectionReported) {\n this.senderRejectionReported = true;\n console.warn(\n `Metabox: ignored a \"${Metabox}\" message from an unexpected sender ` +\n `(environment: ${this.environment}). Events are only accepted from the configurator.`,\n );\n }\n return;\n }\n const data = event.data?.envelope;\n this.dispatchEvent(data?.eventType as T, data?.payload);\n }\n}\n","import type { IntegrateMetaboxConfig } from '../interfaces';\nimport { BasicRouteUrl, MetaboxDomain } from '../constants';\n\n/**\n * Constructs the iframe source URL for the Metabox Modular Configurator.\n *\n * ### What does it unlock?\n * Utility function that prepares the iframe source URL. Constructs the proper URL with parameters\n * for loading the MetaBox configurator.\n *\n * ### Practical Application\n * Utility function that constructs the iframe source URL with proper parameters.\n * URL format: `https://{domain}/metabox-configurator/modular/{configuratorId}`.\n * Called internally by integrateMetabox() — use directly only for manual URL construction.\n *\n * ### AI Coding Best Practices\n * Usually called internally. Use directly only for pre-constructing embed URLs (QR codes, email links,\n * preview URLs). Verify output is HTTPS. Remember modular configurators use `/modular/` path.\n *\n * @internal\n * @hidden\n *\n * @param {string} configuratorId - An string identifier for the configurator.\n * @param {IntegrateMetaboxConfig} config - An object containing the configuration options.\n */\nexport const prepareIframeSrc = (\n configuratorId: string,\n config?: IntegrateMetaboxConfig,\n) => {\n const base = `https://${config?.domain || MetaboxDomain}/${BasicRouteUrl}/${configuratorId}`;\n const params = new URLSearchParams();\n\n if (config?.introImage) {\n params.set('introImage', config.introImage);\n }\n if (config?.introVideo) {\n params.set('introVideo', config.introVideo);\n }\n if (config?.loadingImage) {\n params.set('loadingImage', config.loadingImage);\n }\n if (config?.state) {\n params.set('state', decodeURIComponent(config.state));\n }\n if (config?.showLoadingProgress !== undefined) {\n params.set('showLoadingProgress', String(config.showLoadingProgress));\n }\n if (config?.showResumeStreamPopup !== undefined) {\n params.set('showResumeStreamPopup', String(config.showResumeStreamPopup));\n }\n if (config?.showUserInactivityTimer !== undefined) {\n params.set(\n 'showUserInactivityTimer',\n String(config.showUserInactivityTimer),\n );\n }\n if (config?.userInactivityTimeout !== undefined) {\n params.set('userInactivityTimeout', String(config.userInactivityTimeout));\n }\n if (config?.autoStartStream !== undefined) {\n params.set('autoStartStream', String(config.autoStartStream));\n }\n\n const query = params.toString();\n return query ? `${base}?${query}` : base;\n};\n","import { Communicator } from './communicator';\nimport type { IntegrateMetaboxConfig } from '../interfaces';\nimport { prepareIframeSrc } from './prepare-iframe-src';\n\n// Cancel for the previous integration's handshake listener while it is still\n// waiting for the iframe to load. A new integrateMetabox call supersedes it —\n// it already replaces the single embedded iframe — so a never-completed\n// handshake (failed load, SPA remount, retry) can't leak a window 'message'\n// listener for the page lifetime. Idempotent, so a completed handshake's\n// cancel is a harmless no-op here.\nlet cancelPendingHandshake: (() => void) | null = null;\n\n/**\n * Integrates the Metabox Modular Configurator into the page by injecting an iframe and\n * initializing a Communicator instance for host-to-iframe messaging.\n *\n * - Builds a secure iframe URL using the provided configuratorId and config options.\n * - Ensures the resulting URL uses HTTPS and that the target container exists.\n * - Removes any previously embedded iframe with id \"embeddedContent\" before inserting a new one.\n *\n * ### What does it unlock?\n * Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle,\n * and sets up all configurations.\n *\n * ### Practical Application\n * is THE entry point function. Creates the configurator iframe, establishes postMessage communication, and returns\n * the Communicator api handle via callback. Call ONCE per configurator. Params: configuratorId (modular UUID),\n * containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig).\n *\n * ### AI Coding Best Practices\n * Pattern: `integrateMetabox('uuid', 'div-id', (api) => {\n * set up listeners, then set a root component, then environment, then children\n * }, { standalone: true })`.\n * Ensure a container div exists in DOM with non-zero dimensions. HTTPS required.\n * Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetComponent root, 3) SetEnvironment,\n * 4) SetComponent children, 5) SetComponentMaterial.\n *\n * @param {string} configuratorId - The Modular Configurator ID (not a full URL). It is appended to\n * `https://{domain}/metabox-configurator/modular/{configuratorId}` to form the iframe src.\n *\n * @param {string} containerId - The id of the container element where the iframe will be injected.\n *\n * @param {(api: Communicator) => void} apiReadyCallback - Called when the Communicator instance is created on the host side.\n *\n * @param {IntegrateMetaboxConfig} config - Optional configuration used to build the iframe URL and initialize the communicator.\n * Supported fields:\n * - standalone?: boolean — if true, disables Metabox custom template and related logic.\n * - introImage?: string — URL to an image shown on the intro screen (added as ?introImage=...).\n * - introVideo?: string — URL to a video shown on the intro screen (added as ?introVideo=...).\n * - loadingImage?: string — URL to an image displayed while loading (added as ?loadingImage=...).\n * - state?: string — Predefined state for configurator for initial loading (added as ?state=...).\n * - domain?: string — custom domain for testing (defaults to metabox.3dsource.com). HTTPS is enforced.\n * - showLoadingProgress?: boolean — if true, shows the loading progress bar (added as ?showLoadingProgress=true).\n * - showResumeStreamPopup?: boolean — if true, shows the resume stream popup (added as ?showResumeStreamPopup=true).\n * - showUserInactivityTimer?: boolean — if true, shows the AFK countdown popup (added as ?showUserInactivityTimer=true).\n * - userInactivityTimeout?: number — inactivity timeout in seconds before disconnect (added as ?userInactivityTimeout=...).\n * - autoStartStream?: boolean — controls whether the pixel stream starts automatically on load (added as ?autoStartStream=...); set false to start it manually via ResumeStream.\n *\n * @throws Error If configuratorId or containerId are empty strings.\n * @throws Error If the computed iframe URL is invalid or does not use HTTPS.\n * @throws Error If the container element with the provided id cannot be found.\n *\n * @returns A cancel function that stops waiting for the Metabox to load.\n * Calling it is optional — a later `integrateMetabox` call automatically\n * supersedes a still-pending handshake — but it lets you remove the handshake\n * listener immediately on teardown (e.g. SPA route change before\n * `apiReadyCallback` fires). Idempotent.\n *\n * @example\n * import { integrateMetabox } from '@3dsource/metabox-modular-configurator-api';\n *\n * integrateMetabox('configurator-id',\n * 'embed3DSource',\n * (api) => {\n * // Communicator is ready to use\n * },\n * {\n * standalone: false,\n * introImage: 'https://example.com/intro.png',\n * loadingImage: 'https://example.com/loading.png',\n * showLoadingProgress: true,\n * showResumeStreamPopup: true,\n * showUserInactivityTimer: true,\n * userInactivityTimeout: 20,\n * },\n * );\n */\nexport function integrateMetabox(\n configuratorId: string,\n containerId: string,\n apiReadyCallback: (api: Communicator) => void,\n config?: IntegrateMetaboxConfig,\n): () => void {\n if (!configuratorId.trim()) {\n throw new Error(\n 'integrateMetabox: configuratorId must be a non-empty string',\n );\n }\n const iframeSrc = prepareIframeSrc(configuratorId, config);\n let parsedUrl: URL;\n try {\n parsedUrl = new URL(iframeSrc);\n } catch {\n throw new Error('integrateMetabox: Provided iframeSrc is not a valid URL');\n }\n if (parsedUrl.protocol !== 'https:') {\n throw new Error('integrateMetabox: iframeSrc must use HTTPS protocol');\n }\n if (!containerId.trim()) {\n throw new Error('integrateMetabox: containerId must be a non-empty string');\n }\n\n const container = document.getElementById(containerId);\n if (!container) {\n throw new Error(`Container element with id ${containerId} not found`);\n }\n\n const existingIframe = document.getElementById('embeddedContent');\n if (existingIframe) {\n existingIframe.remove();\n }\n\n // Built before the handshake listener goes up so the Communicator can be told\n // which frame is ours and which origin to address it by. The element is still\n // detached here — `contentWindow` only exists once it is in the document, and\n // by then the handshake it is compared against has not happened yet.\n const iframe = document.createElement('iframe');\n\n // Supersede a prior integration still waiting for its handshake.\n cancelPendingHandshake?.();\n const cancel = Communicator.createInstance(apiReadyCallback, 'host', config, {\n iframe,\n origin: parsedUrl.origin,\n });\n cancelPendingHandshake = cancel ?? null;\n\n // Inject the container rules once per containerId — repeated integrations\n // were appending identical <style> tags, forcing CSSOM reparses.\n const styleId = `metabox-integration-style-${containerId}`;\n if (!document.getElementById(styleId)) {\n const style = document.createElement('style');\n style.id = styleId;\n style.innerHTML = `\n #${containerId} {\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n }\n `;\n document.head.appendChild(style);\n }\n\n iframe.setAttribute('allow', 'autoplay; fullscreen; encrypted-media');\n iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');\n iframe.setAttribute('id', 'embeddedContent');\n iframe.style.border = '0';\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.overflow = 'hidden';\n iframe.src = iframeSrc;\n container.appendChild(iframe);\n\n return cancel;\n}\n","/**\n * Saves an image by triggering a download.\n *\n * This function creates an anchor element, sets its `href` attribute to the provided image URL,\n * and triggers a click event to initiate a download with the specified filename.\n *\n * ### What does it unlock?\n * Main exported function to save images from the configurator. Converts base64 image data to actual image\n * files and saves them to the local filesystem.\n *\n * ### Practical Application\n * Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable\n * image file. Handles the base64 → blob → browser download flow. Import directly from the API package.\n *\n * ### AI Coding Best Practices\n * Pattern: `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); })`.\n * Filename extension should match the MimeType passed to GetScreenshot.\n * Import: `import { saveImage } from '@3dsource/metabox-modular-configurator-api'`.\n *\n * Only the three data-URL formats the configurator actually produces are\n * accepted (`image/png`, `image/jpeg`, `image/webp`). The documented usage above\n * feeds this an event payload straight off the wire, and the body below sets\n * `href` on an anchor and clicks it — so without the check any `data:` URL that\n * reached a `screenshotReady` listener would land in the user's downloads.\n * Anything else is reported and ignored.\n *\n * @param {string} imageUrl - The URL of the image to save.\n * @param {string} filename - The name of the file to save.\n */\nexport function saveImage(imageUrl: string, filename: string): void {\n if (!isScreenshotDataUrl(imageUrl)) {\n console.warn(\n 'Metabox: saveImage ignored a value that is not a configurator screenshot ' +\n '(expected a base64 data URL of type image/png, image/jpeg or image/webp).',\n );\n return;\n }\n\n const a = document.createElement('a');\n a.href = imageUrl;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n}\n\n/**\n * A base64 data URL in one of the formats `GetScreenshot` can ask for. Matched\n * as a whole string rather than parsed: `new URL()` accepts a `data:` URL but\n * exposes nothing useful about its media type, and a prefix check would let\n * anything trail behind the payload.\n */\nfunction isScreenshotDataUrl(value: string): boolean {\n return /^data:image\\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/i.test(\n value,\n );\n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G,GAAG,SAAS;AACtB,IAAA,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;AAE7B,IAAA,OAAO,MAAM;AACf;;ACpKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,SAAU,SAAS,CAAC,QAAgB,EAAE,QAAgB,EAAA;AAC1D,IAAA,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE;QAClC,OAAO,CAAC,IAAI,CACV,2EAA2E;AACzE,YAAA,2EAA2E,CAC9E;QACD;IACF;IAEA,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;AACrC,IAAA,CAAC,CAAC,IAAI,GAAG,QAAQ;AACjB,IAAA,CAAC,CAAC,QAAQ,GAAG,QAAQ;AACrB,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5B,CAAC,CAAC,KAAK,EAAE;AACT,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9B;AAEA;;;;;AAKG;AACH,SAAS,mBAAmB,CAAC,KAAa,EAAA;AACxC,IAAA,OAAO,8DAA8D,CAAC,IAAI,CACxE,KAAK,CACN;AACH;;ACxDA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@3dsource/metabox-modular-configurator-api",
3
- "version": "3.0.32",
4
- "description": "API for Metabox MODULAR configurator",
3
+ "version": "3.0.33",
4
+ "description": "Client API for the Metabox Modular configurator",
5
5
  "keywords": [
6
6
  "metabox",
7
7
  "api",
@@ -100,7 +100,7 @@ declare const MetaboxDomain = "metabox.3dsource.com";
100
100
  */
101
101
  declare const BasicRouteUrl = "metabox-configurator/modular";
102
102
 
103
- declare const VERSION = "3.0.32";
103
+ declare const VERSION = "3.0.33";
104
104
 
105
105
  /**
106
106
  * Configuration options for integrating the Metabox Modular Configurator iframe into a host page.
@@ -1344,6 +1344,19 @@ declare class EventDispatcher {
1344
1344
  removeEventListener(messageType: string, callback: (data: unknown) => void): this;
1345
1345
  }
1346
1346
 
1347
+ /**
1348
+ * What `integrateMetabox` knows about the iframe it created and the origin it
1349
+ * pointed that iframe at. Lets the Communicator check who is talking to it and
1350
+ * address the configurator by its exact origin instead of broadcasting.
1351
+ *
1352
+ * @internal
1353
+ */
1354
+ interface CommunicatorConnection {
1355
+ /** The embedded iframe, when we created it ourselves. */
1356
+ iframe: HTMLIFrameElement | null;
1357
+ /** Origin of the configurator document, or `null` when it is not known yet. */
1358
+ origin: string | null;
1359
+ }
1347
1360
  /**
1348
1361
  * Handles messaging between the host page and embedded Metabox content.
1349
1362
  *
@@ -1368,22 +1381,49 @@ declare class Communicator extends EventDispatcher {
1368
1381
  * Bound handler for incoming postMessage events.
1369
1382
  */
1370
1383
  private binder;
1384
+ /** Which side of the iframe boundary this instance runs on — see `acceptsMessageFrom`. */
1385
+ private readonly environment;
1386
+ /** The iframe we drive, when the integration created it. */
1387
+ private readonly iframe;
1388
+ /** Pinned configurator origin; `null` until we learn it. */
1389
+ private readonly targetOrigin;
1390
+ /** Keeps the "rejected an inbound message" warning to one per instance. */
1391
+ private senderRejectionReported;
1392
+ /** Keeps the "unknown configurator origin" warning to one per instance. */
1393
+ private wildcardTargetReported;
1394
+ /** Keeps the "our iframe left the document" warning to one per instance. */
1395
+ private staleFrameReported;
1371
1396
  /**
1372
1397
  * Constructs a Communicator, replacing any existing instance, and begins listening for messages.
1373
1398
  * @internal
1374
1399
  */
1375
- constructor(data: MCAppLoaded['payload'], environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>);
1400
+ constructor(data: MCAppLoaded['payload'], environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>, connection?: CommunicatorConnection);
1376
1401
  /**
1377
1402
  * Listens for Metabox to signal readiness, then initializes communicator.
1378
1403
  * @param apiReadyCallback - Called with the new Communicator once the Metabox is loaded.
1379
1404
  * @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
1380
1405
  * @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
1406
+ * @param {CommunicatorConnection} connection - the iframe and origin `integrateMetabox`
1407
+ * built, so the handshake can be attributed and later messages addressed precisely.
1408
+ * Omitted by hand-rolled embeds, which are then identified through the
1409
+ * `embeddedContent` id and the handshake's own origin.
1381
1410
  * @returns A cancel function that removes the handshake `message` listener.
1382
1411
  * `integrateMetabox` (the public entry point) calls this automatically when
1383
1412
  * a new integration supersedes a still-pending one, so direct internal
1384
1413
  * callers only need it for explicit early teardown. Idempotent.
1385
1414
  */
1386
- static createInstance(apiReadyCallback: (api: Communicator) => void, environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>): () => void;
1415
+ static createInstance(apiReadyCallback: (api: Communicator) => void, environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>, connection?: CommunicatorConnection): () => void;
1416
+ /**
1417
+ * The origin to address the configurator by, decided once from the handshake.
1418
+ *
1419
+ * Prefers what `integrateMetabox` computed from the iframe URL, but yields to
1420
+ * the origin the handshake actually came from when the two disagree: a redirect
1421
+ * (a `config.domain` override pointing at a host that 30x's elsewhere) would
1422
+ * otherwise pin an origin nothing answers on, and every command would be
1423
+ * dropped silently. The sender already passed the window gate, so this cannot
1424
+ * be steered by an unrelated page.
1425
+ */
1426
+ private static resolveHandshakeOrigin;
1387
1427
  /**
1388
1428
  * Cleans up resources and stops listening for messages.
1389
1429
  */
@@ -1402,6 +1442,27 @@ declare class Communicator extends EventDispatcher {
1402
1442
  * @param command - An action command containing data to send.
1403
1443
  */
1404
1444
  sendCommandToMetabox<T extends CommandBase>(command: T): void;
1445
+ /**
1446
+ * A superseding `integrateMetabox` call removes the iframe this handle was
1447
+ * built for. Commands then fall through to whatever now holds the contract id,
1448
+ * addressed by the origin pinned for the *old* integration — so if the new one
1449
+ * points at a different origin, the browser drops them without a word. The
1450
+ * handle is stale at that point and should be replaced by the one from the new
1451
+ * integration; say so rather than letting it fail quietly.
1452
+ */
1453
+ private reportStaleFrame;
1454
+ /**
1455
+ * `targetOrigin` for the iframe. The very first command is `metaboxConfig`,
1456
+ * which carries `hostUrl: location.href` — on a shop page that routinely holds
1457
+ * order ids and session parameters — so it must not be broadcast to whatever
1458
+ * document currently occupies the frame.
1459
+ *
1460
+ * Falls back to a wildcard rather than refusing to send: this leg carries
1461
+ * commands, and a configurator that silently stops responding on a customer
1462
+ * site is worse than the status quo. The fallback is reported once so it does
1463
+ * not pass unnoticed.
1464
+ */
1465
+ private resolveTarget;
1405
1466
  /**
1406
1467
  * Registers an event listener for messages dispatched by the Metabox.
1407
1468
  * @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`).
@@ -1526,6 +1587,13 @@ declare function integrateMetabox(configuratorId: string, containerId: string, a
1526
1587
  * Filename extension should match the MimeType passed to GetScreenshot.
1527
1588
  * Import: `import { saveImage } from '@3dsource/metabox-modular-configurator-api'`.
1528
1589
  *
1590
+ * Only the three data-URL formats the configurator actually produces are
1591
+ * accepted (`image/png`, `image/jpeg`, `image/webp`). The documented usage above
1592
+ * feeds this an event payload straight off the wire, and the body below sets
1593
+ * `href` on an anchor and clicks it — so without the check any `data:` URL that
1594
+ * reached a `screenshotReady` listener would land in the user's downloads.
1595
+ * Anything else is reported and ignored.
1596
+ *
1529
1597
  * @param {string} imageUrl - The URL of the image to save.
1530
1598
  * @param {string} filename - The name of the file to save.
1531
1599
  */
@@ -2392,4 +2460,4 @@ declare class ResetUserInactivityTimer extends CommandBase {
2392
2460
  }
2393
2461
 
2394
2462
  export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, MetaboxModularConfiguratorActions, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, ResetConfiguration, ResetUserInactivityTimer, ResumeStream, SetCamera, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, StopStream, UnrealCommand, VERSION, fromCommunicatorEvent, integrateMetabox, prepareIframeSrc, saveImage };
2395
- export type { CameraCommandPayload, ComponentWithParent, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxMessagePayloads, FromMetaboxTarget, InitialModularConfigurator, IntegrateMetaboxConfig, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Model, ModularConfiguratorComponent, ModularConfiguratorComponentType, ModularConfiguratorConnector, ModularConfiguratorEnvelope, ModularConfiguratorEnvironment, ModularConfiguratorVirtualSocketToConnector, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, ToMetaboxTarget, VideoResolution, VideoStats, VirtualSocket };
2463
+ export type { CameraCommandPayload, CommunicatorConnection, ComponentWithParent, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxMessagePayloads, FromMetaboxTarget, InitialModularConfigurator, IntegrateMetaboxConfig, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Model, ModularConfiguratorComponent, ModularConfiguratorComponentType, ModularConfiguratorConnector, ModularConfiguratorEnvelope, ModularConfiguratorEnvironment, ModularConfiguratorVirtualSocketToConnector, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, ToMetaboxTarget, VideoResolution, VideoStats, VirtualSocket };