@micro-lc/preview 0.4.2 → 0.5.0-rc10

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.
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
1
7
  (function polyfill() {
2
8
  const relList = document.createElement("link").relList;
3
9
  if (relList && relList.supports && relList.supports("modulepreload")) {
@@ -2397,65 +2403,82 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
2397
2403
  const [imports, exports] = load.a;
2398
2404
  const source = load.S;
2399
2405
  let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : "";
2400
- if (!imports.length) {
2401
- resolvedSource += source;
2402
- } else {
2403
- let pushStringTo = function(originalIndex) {
2404
- while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
2405
- const dynamicImportEnd = dynamicImportEndStack.pop();
2406
- resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
2407
- lastIndex = dynamicImportEnd;
2408
- }
2409
- resolvedSource += source.slice(lastIndex, originalIndex);
2410
- lastIndex = originalIndex;
2411
- };
2412
- let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
2413
- for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
2414
- if (dynamicImportIndex === -1) {
2415
- let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
2416
- if (cycleShell) {
2417
- if (!(blobUrl = depLoad.s)) {
2418
- blobUrl = depLoad.s = createBlob(`export function u$_(m){${depLoad.a[1].map(({ s: s3, e: e3 }, i3) => {
2419
- const q = depLoad.S[s3] === '"' || depLoad.S[s3] === "'";
2420
- return `e$_${i3}=m${q ? `[` : "."}${depLoad.S.slice(s3, e3)}${q ? `]` : ""}`;
2421
- }).join(",")}}${depLoad.a[1].length ? `let ${depLoad.a[1].map((_2, i3) => `e$_${i3}`).join(",")};` : ""}export {${depLoad.a[1].map(({ s: s3, e: e3 }, i3) => `e$_${i3} as ${depLoad.S.slice(s3, e3)}`).join(",")}}
2406
+ let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
2407
+ function pushStringTo(originalIndex) {
2408
+ while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
2409
+ const dynamicImportEnd = dynamicImportEndStack.pop();
2410
+ resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
2411
+ lastIndex = dynamicImportEnd;
2412
+ }
2413
+ resolvedSource += source.slice(lastIndex, originalIndex);
2414
+ lastIndex = originalIndex;
2415
+ }
2416
+ for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
2417
+ if (dynamicImportIndex === -1) {
2418
+ let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
2419
+ if (cycleShell) {
2420
+ if (!(blobUrl = depLoad.s)) {
2421
+ blobUrl = depLoad.s = createBlob(`export function u$_(m){${depLoad.a[1].map(({ s: s3, e: e3 }, i3) => {
2422
+ const q = depLoad.S[s3] === '"' || depLoad.S[s3] === "'";
2423
+ return `e$_${i3}=m${q ? `[` : "."}${depLoad.S.slice(s3, e3)}${q ? `]` : ""}`;
2424
+ }).join(",")}}${depLoad.a[1].length ? `let ${depLoad.a[1].map((_2, i3) => `e$_${i3}`).join(",")};` : ""}export {${depLoad.a[1].map(({ s: s3, e: e3 }, i3) => `e$_${i3} as ${depLoad.S.slice(s3, e3)}`).join(",")}}
2422
2425
  //# sourceURL=${depLoad.r}?cycle`);
2423
- }
2424
- }
2425
- pushStringTo(start - 1);
2426
- resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
2427
- if (!cycleShell && depLoad.s) {
2428
- resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
2429
- depLoad.s = void 0;
2430
2426
  }
2431
- lastIndex = statementEnd;
2432
- } else if (dynamicImportIndex === -2) {
2433
- load.m = { url: load.r, resolve: metaResolve };
2434
- metaHook(load.m, load.u);
2435
- pushStringTo(start);
2436
- resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
2437
- lastIndex = statementEnd;
2438
- } else {
2439
- pushStringTo(statementStart + 6);
2440
- resolvedSource += `Shim(`;
2441
- dynamicImportEndStack.push(statementEnd - 1);
2442
- lastIndex = start;
2443
2427
  }
2428
+ pushStringTo(start - 1);
2429
+ resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
2430
+ if (!cycleShell && depLoad.s) {
2431
+ resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
2432
+ depLoad.s = void 0;
2433
+ }
2434
+ lastIndex = statementEnd;
2435
+ } else if (dynamicImportIndex === -2) {
2436
+ load.m = { url: load.r, resolve: metaResolve };
2437
+ metaHook(load.m, load.u);
2438
+ pushStringTo(start);
2439
+ resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
2440
+ lastIndex = statementEnd;
2441
+ } else {
2442
+ pushStringTo(statementStart + 6);
2443
+ resolvedSource += `Shim(`;
2444
+ dynamicImportEndStack.push(statementEnd - 1);
2445
+ lastIndex = start;
2444
2446
  }
2445
- if (load.s)
2446
- resolvedSource += `
2447
+ }
2448
+ if (load.s)
2449
+ resolvedSource += `
2447
2450
  ;import{u$_}from'${load.s}';try{u$_({${exports.filter((e3) => e3.ln).map(({ s: s3, e: e3, ln }) => `${source.slice(s3, e3)}:${ln}`).join(",")}})}catch(_){};
2448
2451
  `;
2449
- pushStringTo(source.length);
2450
- }
2451
- let hasSourceURL = false;
2452
- resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
2453
- if (!hasSourceURL)
2454
- resolvedSource += "\n//# sourceURL=" + load.r;
2452
+ function pushSourceURL(commentPrefix, commentStart) {
2453
+ const urlStart = commentStart + commentPrefix.length;
2454
+ const commentEnd = source.indexOf("\n", urlStart);
2455
+ const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
2456
+ pushStringTo(urlStart);
2457
+ resolvedSource += new URL(source.slice(urlStart, urlEnd), load.r).href;
2458
+ lastIndex = urlEnd;
2459
+ }
2460
+ let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
2461
+ let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
2462
+ if (sourceURLCommentStart < lastIndex)
2463
+ sourceURLCommentStart = -1;
2464
+ if (sourceMapURLCommentStart < lastIndex)
2465
+ sourceMapURLCommentStart = -1;
2466
+ if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) {
2467
+ pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
2468
+ }
2469
+ if (sourceMapURLCommentStart !== -1) {
2470
+ pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
2471
+ if (sourceURLCommentStart !== -1 && sourceURLCommentStart > sourceMapURLCommentStart)
2472
+ pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
2473
+ }
2474
+ pushStringTo(source.length);
2475
+ if (sourceURLCommentStart === -1)
2476
+ resolvedSource += sourceURLCommentPrefix + load.r;
2455
2477
  load.b = lastLoad = createBlob(resolvedSource);
2456
2478
  load.S = void 0;
2457
2479
  }
2458
- const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
2480
+ const sourceURLCommentPrefix = "\n//# sourceURL=";
2481
+ const sourceMapURLCommentPrefix = "\n//# sourceMappingURL=";
2459
2482
  const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
2460
2483
  const jsonContentType = /^(text|application)\/json(;|$)/;
2461
2484
  const cssContentType = /^(text|application)\/css(;|$)/;
@@ -3266,6 +3289,13 @@ var observable = function() {
3266
3289
  function identity(x2) {
3267
3290
  return x2;
3268
3291
  }
3292
+ function pipe() {
3293
+ var fns = [];
3294
+ for (var _i = 0; _i < arguments.length; _i++) {
3295
+ fns[_i] = arguments[_i];
3296
+ }
3297
+ return pipeFromArray(fns);
3298
+ }
3269
3299
  function pipeFromArray(fns) {
3270
3300
  if (fns.length === 0) {
3271
3301
  return identity;
@@ -3372,12 +3402,12 @@ function isSubscriber(value) {
3372
3402
  function hasLift(source) {
3373
3403
  return isFunction(source === null || source === void 0 ? void 0 : source.lift);
3374
3404
  }
3375
- function operate(init2) {
3405
+ function operate(init) {
3376
3406
  return function(source) {
3377
3407
  if (hasLift(source)) {
3378
3408
  return source.lift(function(liftedSource) {
3379
3409
  try {
3380
- return init2(liftedSource, this);
3410
+ return init(liftedSource, this);
3381
3411
  } catch (err) {
3382
3412
  this.error(err);
3383
3413
  }
@@ -3869,6 +3899,9 @@ function isScheduler(value) {
3869
3899
  function last(arr) {
3870
3900
  return arr[arr.length - 1];
3871
3901
  }
3902
+ function popResultSelector(args) {
3903
+ return isFunction(last(args)) ? args.pop() : void 0;
3904
+ }
3872
3905
  function popScheduler(args) {
3873
3906
  return isScheduler(last(args)) ? args.pop() : void 0;
3874
3907
  }
@@ -4265,6 +4298,26 @@ function lastValueFrom(source, config2) {
4265
4298
  });
4266
4299
  });
4267
4300
  }
4301
+ function firstValueFrom(source, config2) {
4302
+ var hasConfig = typeof config2 === "object";
4303
+ return new Promise(function(resolve, reject) {
4304
+ var subscriber = new SafeSubscriber({
4305
+ next: function(value) {
4306
+ resolve(value);
4307
+ subscriber.unsubscribe();
4308
+ },
4309
+ error: reject,
4310
+ complete: function() {
4311
+ if (hasConfig) {
4312
+ resolve(config2.defaultValue);
4313
+ } else {
4314
+ reject(new EmptyError());
4315
+ }
4316
+ }
4317
+ });
4318
+ source.subscribe(subscriber);
4319
+ });
4320
+ }
4268
4321
  function isValidDate(value) {
4269
4322
  return value instanceof Date && !isNaN(value);
4270
4323
  }
@@ -4276,6 +4329,58 @@ function map(project, thisArg) {
4276
4329
  }));
4277
4330
  });
4278
4331
  }
4332
+ var isArray$1 = Array.isArray;
4333
+ function callOrApply(fn, args) {
4334
+ return isArray$1(args) ? fn.apply(void 0, __spreadArray([], __read(args))) : fn(args);
4335
+ }
4336
+ function mapOneOrManyArgs(fn) {
4337
+ return map(function(args) {
4338
+ return callOrApply(fn, args);
4339
+ });
4340
+ }
4341
+ function combineLatestInit(observables, scheduler, valueTransform) {
4342
+ if (valueTransform === void 0) {
4343
+ valueTransform = identity;
4344
+ }
4345
+ return function(subscriber) {
4346
+ maybeSchedule(scheduler, function() {
4347
+ var length = observables.length;
4348
+ var values = new Array(length);
4349
+ var active = length;
4350
+ var remainingFirstValues = length;
4351
+ var _loop_1 = function(i3) {
4352
+ maybeSchedule(scheduler, function() {
4353
+ var source = from(observables[i3], scheduler);
4354
+ var hasFirstValue = false;
4355
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
4356
+ values[i3] = value;
4357
+ if (!hasFirstValue) {
4358
+ hasFirstValue = true;
4359
+ remainingFirstValues--;
4360
+ }
4361
+ if (!remainingFirstValues) {
4362
+ subscriber.next(valueTransform(values.slice()));
4363
+ }
4364
+ }, function() {
4365
+ if (!--active) {
4366
+ subscriber.complete();
4367
+ }
4368
+ }));
4369
+ }, subscriber);
4370
+ };
4371
+ for (var i2 = 0; i2 < length; i2++) {
4372
+ _loop_1(i2);
4373
+ }
4374
+ }, subscriber);
4375
+ };
4376
+ }
4377
+ function maybeSchedule(scheduler, execute, subscription) {
4378
+ if (scheduler) {
4379
+ executeSchedule(subscription, scheduler, execute);
4380
+ } else {
4381
+ execute();
4382
+ }
4383
+ }
4279
4384
  function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
4280
4385
  var buffer = [];
4281
4386
  var active = 0;
@@ -4351,6 +4456,62 @@ function mergeMap(project, resultSelector, concurrent) {
4351
4456
  return mergeInternals(source, subscriber, project, concurrent);
4352
4457
  });
4353
4458
  }
4459
+ var nodeEventEmitterMethods = ["addListener", "removeListener"];
4460
+ var eventTargetMethods = ["addEventListener", "removeEventListener"];
4461
+ var jqueryMethods = ["on", "off"];
4462
+ function fromEvent(target, eventName, options, resultSelector) {
4463
+ if (isFunction(options)) {
4464
+ resultSelector = options;
4465
+ options = void 0;
4466
+ }
4467
+ if (resultSelector) {
4468
+ return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));
4469
+ }
4470
+ var _a2 = __read(isEventTarget(target) ? eventTargetMethods.map(function(methodName) {
4471
+ return function(handler2) {
4472
+ return target[methodName](eventName, handler2, options);
4473
+ };
4474
+ }) : isNodeStyleEventEmitter(target) ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName)) : isJQueryStyleEventEmitter(target) ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName)) : [], 2), add = _a2[0], remove = _a2[1];
4475
+ if (!add) {
4476
+ if (isArrayLike(target)) {
4477
+ return mergeMap(function(subTarget) {
4478
+ return fromEvent(subTarget, eventName, options);
4479
+ })(innerFrom(target));
4480
+ }
4481
+ }
4482
+ if (!add) {
4483
+ throw new TypeError("Invalid event target");
4484
+ }
4485
+ return new Observable(function(subscriber) {
4486
+ var handler2 = function() {
4487
+ var args = [];
4488
+ for (var _i = 0; _i < arguments.length; _i++) {
4489
+ args[_i] = arguments[_i];
4490
+ }
4491
+ return subscriber.next(1 < args.length ? args : args[0]);
4492
+ };
4493
+ add(handler2);
4494
+ return function() {
4495
+ return remove(handler2);
4496
+ };
4497
+ });
4498
+ }
4499
+ function toCommonHandlerRegistry(target, eventName) {
4500
+ return function(methodName) {
4501
+ return function(handler2) {
4502
+ return target[methodName](eventName, handler2);
4503
+ };
4504
+ };
4505
+ }
4506
+ function isNodeStyleEventEmitter(target) {
4507
+ return isFunction(target.addListener) && isFunction(target.removeListener);
4508
+ }
4509
+ function isJQueryStyleEventEmitter(target) {
4510
+ return isFunction(target.on) && isFunction(target.off);
4511
+ }
4512
+ function isEventTarget(target) {
4513
+ return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
4514
+ }
4354
4515
  function timer(dueTime, intervalOrScheduler, scheduler) {
4355
4516
  if (dueTime === void 0) {
4356
4517
  dueTime = 0;
@@ -4384,6 +4545,22 @@ function timer(dueTime, intervalOrScheduler, scheduler) {
4384
4545
  }, due);
4385
4546
  });
4386
4547
  }
4548
+ function interval(period, scheduler) {
4549
+ if (period === void 0) {
4550
+ period = 0;
4551
+ }
4552
+ if (scheduler === void 0) {
4553
+ scheduler = asyncScheduler;
4554
+ }
4555
+ if (period < 0) {
4556
+ period = 0;
4557
+ }
4558
+ return timer(period, period, scheduler);
4559
+ }
4560
+ var isArray = Array.isArray;
4561
+ function argsOrArgArray(args) {
4562
+ return args.length === 1 && isArray(args[0]) ? args[0] : args;
4563
+ }
4387
4564
  function filter(predicate, thisArg) {
4388
4565
  return operate(function(source, subscriber) {
4389
4566
  var index = 0;
@@ -4466,6 +4643,23 @@ function bufferTime(bufferTimeSpan) {
4466
4643
  source.subscribe(bufferTimeSubscriber);
4467
4644
  });
4468
4645
  }
4646
+ function combineLatest() {
4647
+ var args = [];
4648
+ for (var _i = 0; _i < arguments.length; _i++) {
4649
+ args[_i] = arguments[_i];
4650
+ }
4651
+ var resultSelector = popResultSelector(args);
4652
+ return resultSelector ? pipe(combineLatest.apply(void 0, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector)) : operate(function(source, subscriber) {
4653
+ combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber);
4654
+ });
4655
+ }
4656
+ function combineLatestWith() {
4657
+ var otherSources = [];
4658
+ for (var _i = 0; _i < arguments.length; _i++) {
4659
+ otherSources[_i] = arguments[_i];
4660
+ }
4661
+ return combineLatest.apply(void 0, __spreadArray([], __read(otherSources)));
4662
+ }
4469
4663
  function concatMap(project, resultSelector) {
4470
4664
  return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
4471
4665
  }
@@ -4643,27 +4837,27 @@ function focus(document2, obs$, mode$) {
4643
4837
  });
4644
4838
  return () => subscription.unsubscribe();
4645
4839
  }
4646
- var __defProp$4 = Object.defineProperty;
4647
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4648
- var __publicField$4 = (obj, key, value) => {
4649
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
4840
+ var __defProp$3 = Object.defineProperty;
4841
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4842
+ var __publicField$3 = (obj, key, value) => {
4843
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4650
4844
  return value;
4651
4845
  };
4652
4846
  let Lexer$1 = class Lexer {
4653
4847
  constructor(input) {
4654
- __publicField$4(this, "_input");
4655
- __publicField$4(this, "_length");
4656
- __publicField$4(this, "_idx", 0);
4657
- __publicField$4(
4848
+ __publicField$3(this, "_input");
4849
+ __publicField$3(this, "_length");
4850
+ __publicField$3(this, "_idx", 0);
4851
+ __publicField$3(
4658
4852
  this,
4659
4853
  "_mode",
4660
4854
  0
4661
4855
  /* Literal */
4662
4856
  );
4663
- __publicField$4(this, "_literals", []);
4664
- __publicField$4(this, "_variables", []);
4665
- __publicField$4(this, "_braketCount", 0);
4666
- __publicField$4(this, "_done", false);
4857
+ __publicField$3(this, "_literals", []);
4858
+ __publicField$3(this, "_variables", []);
4859
+ __publicField$3(this, "_braketCount", 0);
4860
+ __publicField$3(this, "_done", false);
4667
4861
  this._input = input;
4668
4862
  this._length = input.length;
4669
4863
  }
@@ -4764,12 +4958,11 @@ function parse(input, context, preserveUnknown = false) {
4764
4958
  return acc;
4765
4959
  }
4766
4960
  const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));
4767
- var __defProp$3 = Object.defineProperty;
4768
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4769
- var __publicField$3 = (obj, key, value) => {
4770
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4771
- return value;
4772
- };
4961
+ var DebugMessage = /* @__PURE__ */ ((DebugMessage2) => {
4962
+ DebugMessage2[DebugMessage2["Default"] = 0] = "Default";
4963
+ DebugMessage2[DebugMessage2["Skip"] = 1] = "Skip";
4964
+ return DebugMessage2;
4965
+ })(DebugMessage || {});
4773
4966
  const MIA_PREVIEW_ID = "__mia_preview_id";
4774
4967
  const OVERLAY_Z_INDEX = 1e6;
4775
4968
  const keys = {
@@ -4782,97 +4975,12 @@ const keys = {
4782
4975
  notification: 0,
4783
4976
  options: 0,
4784
4977
  "request-resource": 0,
4978
+ "set-source-map": 0,
4785
4979
  "tag-info": 0,
4786
4980
  update: 0,
4787
4981
  updated: 0
4788
4982
  /* Default */
4789
4983
  };
4790
- const isValidKey = (type) => Object.keys(keys).includes(type);
4791
- function isInstanceMessage(input, signature) {
4792
- if (input === null) {
4793
- return false;
4794
- }
4795
- if (typeof input !== "object") {
4796
- return false;
4797
- }
4798
- if (!("type" in input) || typeof input.type !== "string") {
4799
- return false;
4800
- }
4801
- const { type: signedType } = input;
4802
- if (!signedType.startsWith(signature)) {
4803
- return false;
4804
- }
4805
- const type = signedType.substring(signature.length);
4806
- if (!isValidKey(type)) {
4807
- return false;
4808
- }
4809
- return true;
4810
- }
4811
- const sign = (signature, message) => ({ ...message, type: `${signature}${message.type}` });
4812
- const unsign = (signature, message) => {
4813
- let { type } = message;
4814
- if (type.startsWith(signature)) {
4815
- type = type.substring(signature.length);
4816
- }
4817
- return { ...message, type };
4818
- };
4819
- const generateDarkColorHex = () => {
4820
- let color = "#";
4821
- for (let i2 = 0; i2 < 3; i2++) {
4822
- color += `0${Math.floor(Math.random() * Math.pow(16, 2) / 2).toString(16)}`.slice(-2);
4823
- }
4824
- return color;
4825
- };
4826
- class PostChannel {
4827
- constructor(handler2) {
4828
- __publicField$3(this, "__instance");
4829
- __publicField$3(this, "__handler");
4830
- __publicField$3(this, "__window");
4831
- __publicField$3(this, "__randomColor");
4832
- this.__instance = "";
4833
- this.__handler = handler2;
4834
- this.__window = window;
4835
- this.__randomColor = generateDarkColorHex();
4836
- }
4837
- postMessage(to, message, origin) {
4838
- {
4839
- console.assert(to !== this.__window);
4840
- }
4841
- if (keys[message.type] !== 1) {
4842
- const color = this.__randomColor;
4843
- const background = `${color}22`;
4844
- const style = { background, color };
4845
- const hasTop = this.__window.top !== this.__window;
4846
- console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? "(inner)" : "(top)"} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
4847
- console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
4848
- console.log(message.content);
4849
- console.groupEnd();
4850
- }
4851
- to.postMessage(sign(this.__instance, message), origin);
4852
- }
4853
- set instance(str) {
4854
- this.__instance = str;
4855
- }
4856
- get window() {
4857
- return this.__window;
4858
- }
4859
- set window(win) {
4860
- this.__window = win;
4861
- }
4862
- send(to, message, origin = "*") {
4863
- this.__window !== to && this.postMessage(to, message, origin);
4864
- }
4865
- recv(window2, from2 = null) {
4866
- const listener2 = ({ data, source }) => {
4867
- if ((from2 === null || source === from2) && isInstanceMessage(data, this.__instance)) {
4868
- const message = unsign(this.__instance, data);
4869
- this.__handler(message);
4870
- }
4871
- };
4872
- window2.addEventListener("message", listener2);
4873
- return () => window2.removeEventListener("message", listener2);
4874
- }
4875
- }
4876
4984
  var t;
4877
4985
  const i = window, s = i.trustedTypes, e = s ? s.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o = "$lit$", n = `lit$${(Math.random() + "").slice(9)}$`, l = "?" + n, h = `<${l}>`, r = document, d = () => r.createComment(""), u = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _ = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^
4878
4986
  \f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false), P = (t2, i2) => {
@@ -4952,7 +5060,7 @@ function N(t2, i2, s2 = t2, e2) {
4952
5060
  }
4953
5061
  class S {
4954
5062
  constructor(t2, i2) {
4955
- this.u = [], this._$AN = void 0, this._$AD = t2, this._$AM = i2;
5063
+ this._$AV = [], this._$AN = void 0, this._$AD = t2, this._$AM = i2;
4956
5064
  }
4957
5065
  get parentNode() {
4958
5066
  return this._$AM.parentNode;
@@ -4960,7 +5068,7 @@ class S {
4960
5068
  get _$AU() {
4961
5069
  return this._$AM._$AU;
4962
5070
  }
4963
- v(t2) {
5071
+ u(t2) {
4964
5072
  var i2;
4965
5073
  const { el: { content: s2 }, parts: e2 } = this._$AD, o2 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true);
4966
5074
  C.currentNode = o2;
@@ -4968,26 +5076,26 @@ class S {
4968
5076
  for (; void 0 !== d2; ) {
4969
5077
  if (l2 === d2.index) {
4970
5078
  let i3;
4971
- 2 === d2.type ? i3 = new M(n2, n2.nextSibling, this, t2) : 1 === d2.type ? i3 = new d2.ctor(n2, d2.name, d2.strings, this, t2) : 6 === d2.type && (i3 = new z(n2, this, t2)), this.u.push(i3), d2 = e2[++h2];
5079
+ 2 === d2.type ? i3 = new M(n2, n2.nextSibling, this, t2) : 1 === d2.type ? i3 = new d2.ctor(n2, d2.name, d2.strings, this, t2) : 6 === d2.type && (i3 = new z(n2, this, t2)), this._$AV.push(i3), d2 = e2[++h2];
4972
5080
  }
4973
5081
  l2 !== (null == d2 ? void 0 : d2.index) && (n2 = C.nextNode(), l2++);
4974
5082
  }
4975
- return o2;
5083
+ return C.currentNode = r, o2;
4976
5084
  }
4977
- p(t2) {
5085
+ v(t2) {
4978
5086
  let i2 = 0;
4979
- for (const s2 of this.u)
5087
+ for (const s2 of this._$AV)
4980
5088
  void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++;
4981
5089
  }
4982
5090
  }
4983
5091
  class M {
4984
5092
  constructor(t2, i2, s2, e2) {
4985
5093
  var o2;
4986
- this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cm = null === (o2 = null == e2 ? void 0 : e2.isConnected) || void 0 === o2 || o2;
5094
+ this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o2 = null == e2 ? void 0 : e2.isConnected) || void 0 === o2 || o2;
4987
5095
  }
4988
5096
  get _$AU() {
4989
5097
  var t2, i2;
4990
- return null !== (i2 = null === (t2 = this._$AM) || void 0 === t2 ? void 0 : t2._$AU) && void 0 !== i2 ? i2 : this._$Cm;
5098
+ return null !== (i2 = null === (t2 = this._$AM) || void 0 === t2 ? void 0 : t2._$AU) && void 0 !== i2 ? i2 : this._$Cp;
4991
5099
  }
4992
5100
  get parentNode() {
4993
5101
  let t2 = this._$AA.parentNode;
@@ -5001,37 +5109,37 @@ class M {
5001
5109
  return this._$AB;
5002
5110
  }
5003
5111
  _$AI(t2, i2 = this) {
5004
- t2 = N(this, t2, i2), u(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this.g(t2) : void 0 !== t2._$litType$ ? this.$(t2) : void 0 !== t2.nodeType ? this.T(t2) : v(t2) ? this.k(t2) : this.g(t2);
5112
+ t2 = N(this, t2, i2), u(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2);
5005
5113
  }
5006
- S(t2) {
5114
+ k(t2) {
5007
5115
  return this._$AA.parentNode.insertBefore(t2, this._$AB);
5008
5116
  }
5009
- T(t2) {
5010
- this._$AH !== t2 && (this._$AR(), this._$AH = this.S(t2));
5117
+ $(t2) {
5118
+ this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2));
5011
5119
  }
5012
- g(t2) {
5013
- this._$AH !== A && u(this._$AH) ? this._$AA.nextSibling.data = t2 : this.T(r.createTextNode(t2)), this._$AH = t2;
5120
+ _(t2) {
5121
+ this._$AH !== A && u(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2;
5014
5122
  }
5015
- $(t2) {
5123
+ g(t2) {
5016
5124
  var i2;
5017
5125
  const { values: s2, _$litType$: e2 } = t2, o2 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = V.createElement(e2.h, this.options)), e2);
5018
5126
  if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o2)
5019
- this._$AH.p(s2);
5127
+ this._$AH.v(s2);
5020
5128
  else {
5021
- const t3 = new S(o2, this), i3 = t3.v(this.options);
5022
- t3.p(s2), this.T(i3), this._$AH = t3;
5129
+ const t3 = new S(o2, this), i3 = t3.u(this.options);
5130
+ t3.v(s2), this.$(i3), this._$AH = t3;
5023
5131
  }
5024
5132
  }
5025
5133
  _$AC(t2) {
5026
5134
  let i2 = E.get(t2.strings);
5027
5135
  return void 0 === i2 && E.set(t2.strings, i2 = new V(t2)), i2;
5028
5136
  }
5029
- k(t2) {
5137
+ T(t2) {
5030
5138
  c(this._$AH) || (this._$AH = [], this._$AR());
5031
5139
  const i2 = this._$AH;
5032
5140
  let s2, e2 = 0;
5033
5141
  for (const o2 of t2)
5034
- e2 === i2.length ? i2.push(s2 = new M(this.S(d()), this.S(d()), this, this.options)) : s2 = i2[e2], s2._$AI(o2), e2++;
5142
+ e2 === i2.length ? i2.push(s2 = new M(this.k(d()), this.k(d()), this, this.options)) : s2 = i2[e2], s2._$AI(o2), e2++;
5035
5143
  e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2);
5036
5144
  }
5037
5145
  _$AR(t2 = this._$AA.nextSibling, i2) {
@@ -5043,7 +5151,7 @@ class M {
5043
5151
  }
5044
5152
  setConnected(t2) {
5045
5153
  var i2;
5046
- void 0 === this._$AM && (this._$Cm = t2, null === (i2 = this._$AP) || void 0 === i2 || i2.call(this, t2));
5154
+ void 0 === this._$AM && (this._$Cp = t2, null === (i2 = this._$AP) || void 0 === i2 || i2.call(this, t2));
5047
5155
  }
5048
5156
  }
5049
5157
  class R {
@@ -5118,7 +5226,7 @@ class z {
5118
5226
  }
5119
5227
  }
5120
5228
  const j = i.litHtmlPolyfillSupport;
5121
- null == j || j(V, M), (null !== (t = i.litHtmlVersions) && void 0 !== t ? t : i.litHtmlVersions = []).push("2.7.0");
5229
+ null == j || j(V, M), (null !== (t = i.litHtmlVersions) && void 0 !== t ? t : i.litHtmlVersions = []).push("2.7.4");
5122
5230
  const B = (t2, i2, s2) => {
5123
5231
  var e2, o2;
5124
5232
  const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2;
@@ -5571,60 +5679,6 @@ async function render(config2, container, context = {}) {
5571
5679
  return null;
5572
5680
  });
5573
5681
  }
5574
- function registerChannels() {
5575
- return {
5576
- configuration: new ReplaySubject(),
5577
- focus: new BehaviorSubject(void 0),
5578
- infos: new ReplaySubject(),
5579
- mocks: new ReplaySubject(),
5580
- mode: new BehaviorSubject("select"),
5581
- notification: new ReplaySubject(),
5582
- updated: new Subject(),
5583
- uppercaseTags: /* @__PURE__ */ new Set()
5584
- };
5585
- }
5586
- const nextMode = (mode) => {
5587
- let next = 0;
5588
- const currentValue = mode.getValue();
5589
- if (currentValue === "interact") {
5590
- next = "select";
5591
- } else if (currentValue === "select") {
5592
- next = "interact";
5593
- }
5594
- mode.next(next);
5595
- return next;
5596
- };
5597
- const subjects = registerChannels();
5598
- function listener(message) {
5599
- switch (message.type) {
5600
- case "options": {
5601
- const { content: { disableOverlay, redirectTo, timeout } } = message;
5602
- if (disableOverlay) {
5603
- Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
5604
- subjects.mode.next("interact");
5605
- }
5606
- if (timeout !== void 0) {
5607
- Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
5608
- }
5609
- const { window: { history } } = this;
5610
- redirectTo && history.pushState(history.state, "", redirectTo);
5611
- break;
5612
- }
5613
- case "ctrl-space":
5614
- nextMode(subjects.mode);
5615
- break;
5616
- case "new-configuration":
5617
- subjects.configuration.next({ ...message.content, type: "reset" });
5618
- break;
5619
- case "update":
5620
- subjects.configuration.next({ ...message.content, type: "update" });
5621
- break;
5622
- case "focus-element":
5623
- subjects.focus.next(message.content);
5624
- break;
5625
- }
5626
- }
5627
- const postChannel = new PostChannel(listener);
5628
5682
  const fromErrorToNotification = (error2) => {
5629
5683
  var _a2;
5630
5684
  return {
@@ -5634,17 +5688,17 @@ const fromErrorToNotification = (error2) => {
5634
5688
  status: "error"
5635
5689
  };
5636
5690
  };
5637
- const errorHandler = (self2, error2) => postChannel.send(self2.parent, {
5691
+ const errorHandler = (channel, error2) => channel.send({
5638
5692
  content: fromErrorToNotification(error2),
5639
5693
  type: "notification"
5640
5694
  });
5641
5695
  const isRealMouseEvent = (event) => "clientX" in event && "clientY" in event;
5642
- function mouseEventFactory(self2, type) {
5696
+ function mouseEventFactory(channel, type) {
5643
5697
  return (event) => {
5644
5698
  if (!isRealMouseEvent(event)) {
5645
5699
  return;
5646
5700
  }
5647
- postChannel.send(self2.parent, {
5701
+ channel.send({
5648
5702
  content: {
5649
5703
  bubbles: true,
5650
5704
  cancelable: false,
@@ -5656,7 +5710,7 @@ function mouseEventFactory(self2, type) {
5656
5710
  };
5657
5711
  }
5658
5712
  const isControlledElement = (tags, element) => tags.has(element.tagName) && element.hasAttribute(MIA_PREVIEW_ID);
5659
- const mouseOnElementFactory = (self2, channels) => {
5713
+ const mouseOnElementFactory = (self2, postChannel, channels) => {
5660
5714
  const { document: document2 } = self2;
5661
5715
  return (event) => {
5662
5716
  let content;
@@ -5672,13 +5726,305 @@ const mouseOnElementFactory = (self2, channels) => {
5672
5726
  }, { ids: [], selectors: [] });
5673
5727
  }
5674
5728
  if (channels.mode.getValue() === "select" || content === void 0) {
5675
- postChannel.send(self2.parent, {
5729
+ postChannel.send({
5676
5730
  content: content && (content.ids.length > 0 ? content : void 0),
5677
5731
  type: "click-element"
5678
5732
  });
5679
5733
  }
5680
5734
  };
5681
5735
  };
5736
+ var fromWindowToReceiver = (self2, options) => {
5737
+ return {
5738
+ postMessage: (message) => {
5739
+ self2.postMessage(message, (options == null ? void 0 : options.targetOrigin) ?? "*", options == null ? void 0 : options.transfer);
5740
+ }
5741
+ };
5742
+ };
5743
+ var SynAck = /* @__PURE__ */ ((SynAck2) => {
5744
+ SynAck2["Ack"] = "ack";
5745
+ SynAck2["Syn"] = "syn";
5746
+ return SynAck2;
5747
+ })(SynAck || {});
5748
+ var synackKeys = Object.values(SynAck);
5749
+ var getData = (message) => message.data;
5750
+ var synackFilter = (type) => (data) => data.type === type.toString();
5751
+ var isPostChannelMessage = (message) => {
5752
+ const data = message.data;
5753
+ return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string" && "instance" in data && typeof data.instance === "string" && "content" in data;
5754
+ };
5755
+ var generateDarkColorHex = () => {
5756
+ let color = "#";
5757
+ for (let i2 = 0; i2 < 3; i2++) {
5758
+ color += `0${Math.floor(Math.random() * Math.pow(16, 2) / 2).toString(16)}`.slice(-2);
5759
+ }
5760
+ return color;
5761
+ };
5762
+ var PostChannel = class {
5763
+ constructor(listener, from2, to, opts) {
5764
+ __publicField(this, "__generateId");
5765
+ __publicField(this, "__instance");
5766
+ __publicField(this, "__colors");
5767
+ __publicField(this, "__listener");
5768
+ __publicField(this, "__log");
5769
+ __publicField(this, "__receiver");
5770
+ __publicField(this, "__subscription");
5771
+ __publicField(this, "__okToWrite");
5772
+ __publicField(this, "__write$");
5773
+ __publicField(this, "__recv$");
5774
+ this.__generateId = () => globalThis.crypto.randomUUID();
5775
+ const instance = this.__generateId();
5776
+ const messages = new ReplaySubject();
5777
+ const fromSubscription = fromEvent(from2, "message").pipe(filter(isPostChannelMessage)).subscribe(messages);
5778
+ this.__subscription = new Subscription();
5779
+ this.__subscription.add(fromSubscription);
5780
+ this.__okToWrite = new ReplaySubject(1);
5781
+ this.__write$ = this.__okToWrite.pipe(take(1));
5782
+ this.__recv$ = messages.asObservable();
5783
+ this.__listener = listener;
5784
+ this.__log = (opts == null ? void 0 : opts.log) && opts.log.bind(this);
5785
+ this.__instance = instance;
5786
+ const color = generateDarkColorHex();
5787
+ this.__colors = {
5788
+ bg: `${color}22`,
5789
+ fg: color
5790
+ };
5791
+ this.__receiver = to;
5792
+ this.__connect(
5793
+ instance,
5794
+ (opts == null ? void 0 : opts.period) ? opts.period : 10
5795
+ );
5796
+ }
5797
+ __connect(instance, period) {
5798
+ const synSubscription = interval(period).subscribe(() => this.__receiver.postMessage({
5799
+ content: instance,
5800
+ instance,
5801
+ type: "syn".toString()
5802
+ }));
5803
+ this.__subscription.add(synSubscription);
5804
+ this.__subscription.add(
5805
+ this.__recv$.pipe(
5806
+ map(getData),
5807
+ filter(synackFilter(
5808
+ "ack"
5809
+ /* Ack */
5810
+ )),
5811
+ filter(({ content }) => content === instance),
5812
+ take(1)
5813
+ ).subscribe(({ instance: foreignInstance }) => {
5814
+ this.__okToWrite.next(0);
5815
+ this.__subscription.add(
5816
+ this.__recv$.pipe(
5817
+ filter(
5818
+ ({ data: { type, instance: incomingInstance } }) => !synackKeys.includes(type) && incomingInstance === foreignInstance
5819
+ )
5820
+ ).subscribe((message) => {
5821
+ this.__listener(message);
5822
+ const { data } = message;
5823
+ if (data._id !== void 0) {
5824
+ this.__receiver.postMessage({
5825
+ ...data,
5826
+ content: data,
5827
+ instance,
5828
+ type: "ack"
5829
+ /* Ack */
5830
+ });
5831
+ }
5832
+ })
5833
+ );
5834
+ synSubscription.unsubscribe();
5835
+ })
5836
+ );
5837
+ this.__subscription.add(
5838
+ this.__recv$.pipe(
5839
+ map(getData),
5840
+ filter(synackFilter(
5841
+ "syn"
5842
+ /* Syn */
5843
+ )),
5844
+ // must check whether is not short-circuiting
5845
+ // in an infinite loop by syncing with itself
5846
+ filter(({ instance: foreignInstance }) => foreignInstance !== instance),
5847
+ take(1)
5848
+ ).subscribe(({ content }) => {
5849
+ this.__receiver.postMessage({
5850
+ content,
5851
+ instance,
5852
+ type: "ack"
5853
+ /* Ack */
5854
+ });
5855
+ })
5856
+ );
5857
+ }
5858
+ __write(message, messageId) {
5859
+ const extra = {};
5860
+ if (messageId !== void 0) {
5861
+ extra._id = messageId;
5862
+ }
5863
+ this.__subscription.add(
5864
+ this.__write$.subscribe(() => {
5865
+ var _a2;
5866
+ const outgoingMessage = Object.assign(
5867
+ message,
5868
+ {
5869
+ instance: this.__instance,
5870
+ ...extra
5871
+ }
5872
+ );
5873
+ this.__receiver.postMessage(outgoingMessage);
5874
+ (_a2 = this.__log) == null ? void 0 : _a2.call(this, outgoingMessage);
5875
+ })
5876
+ );
5877
+ }
5878
+ disconnect() {
5879
+ this.__subscription.unsubscribe();
5880
+ }
5881
+ send(message) {
5882
+ this.__write(message);
5883
+ }
5884
+ ackSend(message) {
5885
+ let done;
5886
+ const promise = new Promise((resolve) => {
5887
+ done = resolve;
5888
+ });
5889
+ const messageId = this.__generateId();
5890
+ this.__subscription.add(
5891
+ this.__recv$.pipe(
5892
+ map(getData),
5893
+ filter(synackFilter(
5894
+ "ack"
5895
+ /* Ack */
5896
+ )),
5897
+ filter(({ _id }) => _id === messageId),
5898
+ take(1)
5899
+ ).subscribe(() => done())
5900
+ );
5901
+ this.__write(message, messageId);
5902
+ return promise;
5903
+ }
5904
+ get instance() {
5905
+ return this.__instance;
5906
+ }
5907
+ get colors() {
5908
+ return this.__colors;
5909
+ }
5910
+ /**
5911
+ * signals readiness on listening and cannot fail but keeps hanging
5912
+ * if not resolved
5913
+ */
5914
+ get ready() {
5915
+ return firstValueFrom(this.__write$).then(() => {
5916
+ });
5917
+ }
5918
+ };
5919
+ var src_default = PostChannel;
5920
+ const registerChannels = () => ({
5921
+ configuration: new ReplaySubject(),
5922
+ focus: new BehaviorSubject(void 0),
5923
+ infos: new ReplaySubject(),
5924
+ mocks: new ReplaySubject(),
5925
+ mode: new BehaviorSubject("select"),
5926
+ notification: new ReplaySubject(),
5927
+ setSourceMap: new ReplaySubject(1),
5928
+ swSourceMapAck: new ReplaySubject(1),
5929
+ updated: new Subject(),
5930
+ uppercaseTags: /* @__PURE__ */ new Set()
5931
+ });
5932
+ const nextMode = (mode) => {
5933
+ let next = 0;
5934
+ const currentValue = mode.getValue();
5935
+ if (currentValue === "interact") {
5936
+ next = "select";
5937
+ } else if (currentValue === "select") {
5938
+ next = "interact";
5939
+ }
5940
+ mode.next(next);
5941
+ return next;
5942
+ };
5943
+ const swMakeListener = (_2) => (message) => {
5944
+ const { data } = message;
5945
+ switch (data.type) {
5946
+ }
5947
+ };
5948
+ const registerServiceWorker = async (self2, channels) => {
5949
+ const { navigator: { serviceWorker: sw } } = self2;
5950
+ return Promise.all([
5951
+ sw.register("./service-worker.js"),
5952
+ sw.ready.then((registration) => {
5953
+ if (!registration.active) {
5954
+ throw new TypeError("smth went wrong on sw activation");
5955
+ }
5956
+ return new src_default(swMakeListener(), window.navigator.serviceWorker, registration.active);
5957
+ })
5958
+ ]).then(([, channel]) => channel);
5959
+ };
5960
+ const parentMakeListener = (self2, channels) => (message) => {
5961
+ const { data } = message;
5962
+ switch (data.type) {
5963
+ case "options": {
5964
+ const { content: { disableOverlay, redirectTo, timeout, run: run2 } } = data;
5965
+ if (run2) {
5966
+ channels.swSourceMapAck.next(0);
5967
+ }
5968
+ if (disableOverlay) {
5969
+ Object.defineProperty(self2, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
5970
+ channels.mode.next("interact");
5971
+ }
5972
+ if (timeout !== void 0) {
5973
+ Object.defineProperty(self2, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
5974
+ }
5975
+ const { history } = self2;
5976
+ redirectTo && history.pushState(history.state, "", redirectTo);
5977
+ break;
5978
+ }
5979
+ case "ctrl-space":
5980
+ nextMode(channels.mode);
5981
+ break;
5982
+ case "new-configuration":
5983
+ channels.configuration.next({ ...data.content, type: "reset" });
5984
+ break;
5985
+ case "update":
5986
+ channels.configuration.next({ ...data.content, type: "update" });
5987
+ break;
5988
+ case "focus-element":
5989
+ channels.focus.next(data.content);
5990
+ break;
5991
+ case "set-source-map": {
5992
+ const { content } = data;
5993
+ channels.setSourceMap.next(Object.entries(content).reduce((acc, [from2, to]) => {
5994
+ try {
5995
+ const { href: fromUrl } = new URL(from2, self2.location.href);
5996
+ const obj = typeof to === "string" ? { headers: {}, query: {}, to } : to;
5997
+ acc[fromUrl] = {
5998
+ originalFrom: from2,
5999
+ ...obj
6000
+ };
6001
+ } catch (e2) {
6002
+ }
6003
+ return acc;
6004
+ }, {}));
6005
+ break;
6006
+ }
6007
+ }
6008
+ };
6009
+ const registerParent = (self2, channels) => new src_default(
6010
+ parentMakeListener(self2, channels),
6011
+ self2,
6012
+ fromWindowToReceiver(self2.parent),
6013
+ {
6014
+ log(message) {
6015
+ {
6016
+ console.assert(self2.parent !== self2);
6017
+ }
6018
+ if (keys[message.type] !== DebugMessage.Skip) {
6019
+ const style = { background: this.colors.bg, color: this.colors.fg };
6020
+ console.groupCollapsed(`%c Msg from ${self2.origin} (inner) `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
6021
+ console.info(`window '${self2.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
6022
+ console.log(message.content);
6023
+ console.groupEnd();
6024
+ }
6025
+ }
6026
+ }
6027
+ );
5682
6028
  const ctrlSpaceFactory = (channels) => {
5683
6029
  return (evt) => {
5684
6030
  if (evt.ctrlKey && evt.key === " ") {
@@ -5709,49 +6055,42 @@ const requireInfo = (registry, tags) => from(tags.map((tag) => [tag, registry.wh
5709
6055
  mergeMap(extractManifest)
5710
6056
  );
5711
6057
  const BUFFER_TIME = 500;
5712
- function reporter(err) {
6058
+ const reporter = (postChannel, err) => {
5713
6059
  if (err instanceof Error) {
5714
- errorHandler(this, err);
6060
+ errorHandler(postChannel, err);
5715
6061
  }
5716
- }
5717
- function collectInfos(info$, addInfo) {
5718
- const boundReporter = reporter.bind(this);
5719
- return info$.pipe(
5720
- mergeMap(([, { __manifest: { label, description, ...rest }, tag }]) => {
5721
- delete rest.mocks;
5722
- return of({ info: { ...translateObject({ description, label }), ...rest }, tag });
5723
- }),
5724
- bufferTime(BUFFER_TIME),
5725
- filter((newInfos) => newInfos.length > 0)
5726
- ).subscribe({
5727
- error: boundReporter,
5728
- next: (extras) => addInfo(extras)
5729
- });
5730
- }
5731
- function collectMocks(info$) {
5732
- const boundReporter = reporter.bind(this);
5733
- return info$.pipe(
5734
- map(
5735
- ([, { __manifest: { mocks = {} }, tag }]) => [tag, mocks]
5736
- )
5737
- ).subscribe({
5738
- error: boundReporter,
5739
- next: (mockPair) => {
5740
- subjects.mocks.next(mockPair);
5741
- }
5742
- });
5743
- }
5744
- async function bootstrap(config2, {
6062
+ };
6063
+ const collectInfos = (postChannel, info$, addInfo) => info$.pipe(
6064
+ mergeMap(([, { __manifest: { label, description, ...rest }, tag }]) => {
6065
+ delete rest.mocks;
6066
+ return of({ info: { ...translateObject({ description, label }), ...rest }, tag });
6067
+ }),
6068
+ bufferTime(BUFFER_TIME),
6069
+ filter((newInfos) => newInfos.length > 0)
6070
+ ).subscribe({
6071
+ error: (error2) => reporter(postChannel, error2),
6072
+ next: (extras) => addInfo(extras)
6073
+ });
6074
+ const collectMocks = (postChannel, subjects, info$) => info$.pipe(
6075
+ map(
6076
+ ([, { __manifest: { mocks = {} }, tag }]) => [tag, mocks]
6077
+ )
6078
+ ).subscribe({
6079
+ error: (error2) => reporter(postChannel, error2),
6080
+ next: (mockPair) => {
6081
+ subjects.mocks.next(mockPair);
6082
+ }
6083
+ });
6084
+ async function bootstrap(postChannel, channels, config2, {
5745
6085
  addInfo,
5746
6086
  tags
5747
6087
  }) {
5748
6088
  const { subscription } = this;
5749
- const boundReporter = reporter.bind(this);
5750
6089
  if (config2) {
5751
6090
  const info$ = requireInfo(this.customElements, tags);
5752
- return premount(config2, this, boundReporter).then(() => {
5753
- subscription.add(collectInfos.call(this, info$, addInfo));
5754
- subscription.add(collectMocks.call(this, info$));
6091
+ return premount(config2, this, (err) => reporter(postChannel, err)).then(() => {
6092
+ subscription.add(collectInfos(postChannel, info$, addInfo));
6093
+ subscription.add(collectMocks(postChannel, channels, info$));
5755
6094
  });
5756
6095
  }
5757
6096
  }
@@ -5791,7 +6130,7 @@ function fetchMockFactory(instance, fetchFactory, windowHref) {
5791
6130
  var _a2;
5792
6131
  const info = compileObject({ ...url, method }, context);
5793
6132
  const matcher = new URL(info.pathname, (_a2 = info.origin) != null ? _a2 : windowHref);
5794
- return [matcher.href, method, (injectedInfo, init2) => fetchHandler(injectedInfo, init2).finally(() => {
6133
+ return [matcher.href, method, (injectedInfo, init) => fetchHandler(injectedInfo, init).finally(() => {
5795
6134
  if (notify) {
5796
6135
  this.notify(fetchNotification(method, matcher));
5797
6136
  }
@@ -5868,12 +6207,12 @@ const printHeaders = (headers) => {
5868
6207
  });
5869
6208
  return JSON.stringify(obj);
5870
6209
  };
5871
- const fetchPrint = (window2, url, init2, resHeaders = new Headers()) => {
6210
+ const fetchPrint = (window2, url, init, resHeaders = new Headers()) => {
5872
6211
  var _a2;
5873
6212
  const style = window2.origin === "null" ? { background: "antiquewhite", color: "brown" } : { background: "cyan", color: "blue" };
5874
6213
  console.groupCollapsed(`%c Fetching from ${window2.origin} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
5875
6214
  console.info(
5876
- `a component fetched with method ${(_a2 = init2 == null ? void 0 : init2.method) != null ? _a2 : "GET"} resource at %c ${url.href} got a response with headers ${printHeaders(resHeaders)}`,
6215
+ `a component fetched with method ${(_a2 = init == null ? void 0 : init.method) != null ? _a2 : "GET"} resource at %c ${url.href} got a response with headers ${printHeaders(resHeaders)}`,
5877
6216
  "background: lightgreen; color: darkgreen"
5878
6217
  );
5879
6218
  console.groupEnd();
@@ -5885,7 +6224,7 @@ const notFoundTagNotification = (tag) => ({
5885
6224
  message: "preview.notifications.no-webcomponent-definition.message",
5886
6225
  status: "warning"
5887
6226
  });
5888
- async function mock(contexts, tags = []) {
6227
+ async function mock(postChannel, subjects, contexts, tags = []) {
5889
6228
  const { location: { href }, fetch: originalFetch } = this;
5890
6229
  const urlMaker = urlMakerFactory(this);
5891
6230
  const store = new FetchMockStore(this.notify.bind(this));
@@ -5909,21 +6248,21 @@ async function mock(contexts, tags = []) {
5909
6248
  const instancesCarryingMocks = (_a2 = contexts.get(tag)) != null ? _a2 : [];
5910
6249
  return handler(store, instancesCarryingMocks, fetchFactory, href);
5911
6250
  })).catch(
5912
- (error2) => error2 instanceof Error && errorHandler(this, error2)
6251
+ (error2) => error2 instanceof Error && errorHandler(postChannel, error2)
5913
6252
  );
5914
- const mockedFetch = async (info, init2) => {
6253
+ const mockedFetch = async (info, init) => {
5915
6254
  var _a2;
5916
6255
  const url = toURL(urlMaker, info);
5917
- const mockImplementation = store.match({ method: (_a2 = init2 == null ? void 0 : init2.method) != null ? _a2 : "GET", url });
6256
+ const mockImplementation = store.match({ method: (_a2 = init == null ? void 0 : init.method) != null ? _a2 : "GET", url });
5918
6257
  if (mockImplementation !== void 0) {
5919
- return mockImplementation(url, init2).then((res) => {
6258
+ return mockImplementation(url, init).then((res) => {
5920
6259
  {
5921
- fetchPrint(this, url, init2, res.headers);
6260
+ fetchPrint(this, url, init, res.headers);
5922
6261
  }
5923
6262
  return res;
5924
6263
  });
5925
6264
  }
5926
- return originalFetch(info, init2);
6265
+ return originalFetch(info, init);
5927
6266
  };
5928
6267
  if (this.proxyWindow) {
5929
6268
  const newFetch = Object.assign(
@@ -6107,10 +6446,10 @@ function wrap(frame, notification) {
6107
6446
  const unpatch = domPatch(sandbox);
6108
6447
  return { sandbox, unpatch };
6109
6448
  }
6110
- var __defProp = Object.defineProperty;
6111
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6112
- var __publicField = (obj, key, value) => {
6113
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6449
+ var __defProp2 = Object.defineProperty;
6450
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6451
+ var __publicField2 = (obj, key, value) => {
6452
+ __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
6114
6453
  return value;
6115
6454
  };
6116
6455
  function appendOverlay(self2, mode$) {
@@ -6170,8 +6509,8 @@ function createLifecycle(frame) {
6170
6509
  }
6171
6510
  class Queue {
6172
6511
  constructor() {
6173
- __publicField(this, "_results", /* @__PURE__ */ new Map());
6174
- __publicField(this, "_queue", Promise.resolve());
6512
+ __publicField2(this, "_results", /* @__PURE__ */ new Map());
6513
+ __publicField2(this, "_queue", Promise.resolve());
6175
6514
  }
6176
6515
  add(args) {
6177
6516
  const fns = [...args];
@@ -6209,9 +6548,9 @@ const addInfoFactory = (channels) => (info) => {
6209
6548
  channels.infos.next(info);
6210
6549
  info.forEach(({ tag }) => channels.uppercaseTags.add(tag.toUpperCase()));
6211
6550
  };
6212
- const run = (frame, renderRoot, channels) => {
6551
+ const run = (frame, renderRoot, postChannel, channels) => {
6213
6552
  const queue = new Queue();
6214
- const subscription = channels.configuration.subscribe((next) => {
6553
+ const subscription = channels.configuration.pipe(combineLatestWith(channels.swSourceMapAck)).subscribe(([next]) => {
6215
6554
  const { configuration } = next;
6216
6555
  const { content } = configuration;
6217
6556
  let done;
@@ -6219,8 +6558,8 @@ const run = (frame, renderRoot, channels) => {
6219
6558
  const { contexts, tags } = next;
6220
6559
  done = queue.add([
6221
6560
  () => unmount.call(frame, renderRoot),
6222
- () => bootstrap.call(frame, configuration, { addInfo: addInfoFactory(channels), tags }),
6223
- () => mock.call(frame, contexts, next.tags),
6561
+ () => bootstrap.call(frame, postChannel, channels, configuration, { addInfo: addInfoFactory(channels), tags }),
6562
+ () => mock.call(frame, postChannel, channels, contexts, next.tags),
6224
6563
  () => update.call(frame, content, renderRoot).finally(() => channels.updated.next(0))
6225
6564
  ]);
6226
6565
  } else {
@@ -6269,16 +6608,16 @@ const interceptCORSFetch = (self2, notification) => {
6269
6608
  return;
6270
6609
  }
6271
6610
  const originalFetch = self2.fetch.bind(self2);
6272
- self2.fetch = (input, init2) => {
6611
+ self2.fetch = (input, init) => {
6273
6612
  var _a2;
6274
6613
  const url = toURL(urlMaker, input);
6275
6614
  if (isSameDocumentOriginRequest(document2, url)) {
6276
- notification.next(fetchNotification((_a2 = init2 == null ? void 0 : init2.method) != null ? _a2 : "GET", url));
6615
+ notification.next(fetchNotification((_a2 = init == null ? void 0 : init.method) != null ? _a2 : "GET", url));
6277
6616
  }
6278
- return originalFetch(input, init2);
6617
+ return originalFetch(input, init);
6279
6618
  };
6280
6619
  };
6281
- function createComposerApplication(self2, channels) {
6620
+ const createComposerApplication = (self2, postChannel, channels) => {
6282
6621
  applyBodyStyle(self2.document);
6283
6622
  interceptCORSFetch(self2, channels.notification);
6284
6623
  const { cleanup: overlayDisplaySubscriptionCleanup } = appendOverlay(self2, channels.mode.asObservable());
@@ -6286,7 +6625,7 @@ function createComposerApplication(self2, channels) {
6286
6625
  const renderRoot = appendRenderRoot(self2.document);
6287
6626
  const frame = createLifecycle(self2);
6288
6627
  const { sandbox: sandboxedWindow, unpatch } = wrap(frame, channels.notification);
6289
- const updateSubscriptionsCleanup = run(sandboxedWindow, renderRoot, channels);
6628
+ const updateSubscriptionsCleanup = run(sandboxedWindow, renderRoot, postChannel, channels);
6290
6629
  return {
6291
6630
  cleanup: () => {
6292
6631
  updateSubscriptionsCleanup();
@@ -6296,47 +6635,41 @@ function createComposerApplication(self2, channels) {
6296
6635
  },
6297
6636
  sandboxedWindow
6298
6637
  };
6299
- }
6300
- const init = (self2) => {
6301
- postChannel.window = self2;
6302
6638
  };
6303
- function registerSenders(chs) {
6639
+ function registerParentWindowSenders(chs) {
6304
6640
  const subscription = new Subscription();
6305
6641
  subscription.add(
6306
- chs.updated.subscribe(() => {
6307
- postChannel.send(window.parent, {
6308
- content: {},
6309
- type: "updated"
6310
- });
6311
- })
6642
+ chs.updated.subscribe(() => this.send({
6643
+ content: {},
6644
+ type: "updated"
6645
+ }))
6312
6646
  );
6313
6647
  subscription.add(
6314
- chs.infos.subscribe(
6315
- (entries) => {
6316
- postChannel.send(window.parent, {
6317
- content: entries,
6318
- type: "tag-info"
6319
- });
6320
- }
6321
- )
6648
+ chs.infos.subscribe((entries) => this.send({
6649
+ content: entries,
6650
+ type: "tag-info"
6651
+ }))
6322
6652
  );
6323
6653
  subscription.add(
6324
- chs.notification.subscribe(
6325
- (content) => {
6326
- postChannel.send(window.parent, {
6327
- content,
6328
- type: "notification"
6329
- });
6330
- }
6331
- )
6654
+ chs.notification.subscribe((content) => this.send({
6655
+ content,
6656
+ type: "notification"
6657
+ }))
6332
6658
  );
6333
6659
  subscription.add(
6334
- chs.mode.subscribe(
6335
- (mode) => {
6336
- postChannel.send(window.parent, {
6337
- content: { mode },
6338
- type: "ctrl-space"
6339
- });
6660
+ chs.mode.subscribe((mode) => this.send({
6661
+ content: { mode },
6662
+ type: "ctrl-space"
6663
+ }))
6664
+ );
6665
+ return () => subscription.unsubscribe();
6666
+ }
6667
+ function registerServiceWorkerSenders(channels) {
6668
+ const subscription = new Subscription();
6669
+ subscription.add(
6670
+ channels.setSourceMap.subscribe(
6671
+ (message) => {
6672
+ this.ackSend({ content: message, type: "set-source-map" }).then(() => channels.swSourceMapAck.next(0)).catch(noop);
6340
6673
  }
6341
6674
  )
6342
6675
  );
@@ -6357,28 +6690,36 @@ function registerCleanups(window2, fns) {
6357
6690
  fns.forEach((fn) => fn());
6358
6691
  });
6359
6692
  }
6360
- ((self2) => {
6361
- init(self2);
6362
- const postChannelCleanup = postChannel.recv(self2, self2.top);
6363
- const senderCleanup = registerSenders(subjects);
6693
+ (async (self2) => {
6694
+ const channels = registerChannels();
6695
+ const swRegistration = await registerServiceWorker(self2);
6696
+ const parentWindowRegistration = registerParent(self2, channels);
6697
+ const serviceWorkerSenderCleanup = registerServiceWorkerSenders.call(swRegistration, channels);
6698
+ const parentWindowSenderCleanup = registerParentWindowSenders.call(parentWindowRegistration, channels);
6364
6699
  const listenerCleanup = registerEventListeners(
6365
6700
  self2,
6366
- { handler: ctrlSpaceFactory(subjects), type: "keydown" },
6367
- { handler: mouseEventFactory(self2, "mousemove"), type: "mousemove" },
6368
- { handler: mouseEventFactory(self2, "mousedown"), type: "mousedown" },
6369
- { handler: mouseOnElementFactory(self2, subjects), type: "mousedown" }
6701
+ { handler: ctrlSpaceFactory(channels), type: "keydown" },
6702
+ { handler: mouseEventFactory(parentWindowRegistration, "mousemove"), type: "mousemove" },
6703
+ { handler: mouseEventFactory(parentWindowRegistration, "mousedown"), type: "mousedown" },
6704
+ { handler: mouseOnElementFactory(self2, parentWindowRegistration, channels), type: "mousedown" }
6370
6705
  );
6371
6706
  const {
6372
6707
  cleanup: composerApplicationCleanup,
6373
6708
  sandboxedWindow
6374
- } = createComposerApplication(self2, subjects);
6709
+ } = createComposerApplication(self2, parentWindowRegistration, channels);
6375
6710
  registerCleanups(
6376
6711
  sandboxedWindow,
6377
6712
  [
6378
6713
  composerApplicationCleanup,
6379
6714
  listenerCleanup,
6380
- senderCleanup,
6381
- postChannelCleanup
6715
+ parentWindowSenderCleanup,
6716
+ serviceWorkerSenderCleanup,
6717
+ () => parentWindowRegistration.disconnect(),
6718
+ () => swRegistration.send({ content: {}, type: "unload-client" }),
6719
+ () => swRegistration.disconnect()
6382
6720
  ]
6383
6721
  );
6384
- })(window);
6722
+ })(window).catch((err) => {
6723
+ console.error(`[preview] Error Boundary: ${String(err)}`);
6724
+ throw err;
6725
+ });