@micro-lc/preview 0.5.0-rc1 → 0.5.0-rc10

Sign up to get free protection for your applications and to get access to all the features.
@@ -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(;|$)/;
@@ -3379,12 +3402,12 @@ function isSubscriber(value) {
3379
3402
  function hasLift(source) {
3380
3403
  return isFunction(source === null || source === void 0 ? void 0 : source.lift);
3381
3404
  }
3382
- function operate(init2) {
3405
+ function operate(init) {
3383
3406
  return function(source) {
3384
3407
  if (hasLift(source)) {
3385
3408
  return source.lift(function(liftedSource) {
3386
3409
  try {
3387
- return init2(liftedSource, this);
3410
+ return init(liftedSource, this);
3388
3411
  } catch (err) {
3389
3412
  this.error(err);
3390
3413
  }
@@ -4275,6 +4298,26 @@ function lastValueFrom(source, config2) {
4275
4298
  });
4276
4299
  });
4277
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
+ }
4278
4321
  function isValidDate(value) {
4279
4322
  return value instanceof Date && !isNaN(value);
4280
4323
  }
@@ -4413,6 +4456,62 @@ function mergeMap(project, resultSelector, concurrent) {
4413
4456
  return mergeInternals(source, subscriber, project, concurrent);
4414
4457
  });
4415
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
+ }
4416
4515
  function timer(dueTime, intervalOrScheduler, scheduler) {
4417
4516
  if (dueTime === void 0) {
4418
4517
  dueTime = 0;
@@ -4620,27 +4719,145 @@ function tap(observerOrNext, error2, complete) {
4620
4719
  }));
4621
4720
  }) : identity;
4622
4721
  }
4623
- var __defProp$5 = Object.defineProperty;
4624
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4625
- var __publicField$5 = (obj, key, value) => {
4626
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
4722
+ const DEFAULT_LANGUAGE = "en";
4723
+ const localizeText = (input, lang = DEFAULT_LANGUAGE) => {
4724
+ if (typeof input === "string") {
4725
+ return input;
4726
+ }
4727
+ return input == null ? void 0 : input[lang];
4728
+ };
4729
+ function translateObject(obj) {
4730
+ return Object.entries(obj).reduce((out, [key, value]) => {
4731
+ out[key] = localizeText(value);
4732
+ return out;
4733
+ }, {});
4734
+ }
4735
+ const noop = (..._args) => {
4736
+ };
4737
+ const toArray$1 = (input) => Array.isArray(input) ? input : [input];
4738
+ const urlMakerFactory = ({ document: { baseURI }, location: { href } }) => (input) => new URL(input, new URL(baseURI, href));
4739
+ const toURL = (urlMaker, info) => {
4740
+ let url = info;
4741
+ if (!(info instanceof URL)) {
4742
+ url = urlMaker(typeof info === "string" ? info : info.url);
4743
+ }
4744
+ return url;
4745
+ };
4746
+ const trimLocationOrigin = (origin, url) => {
4747
+ const { href, origin: linkOrigin } = url;
4748
+ if (origin === linkOrigin) {
4749
+ return href.substring(origin.length);
4750
+ }
4751
+ return href;
4752
+ };
4753
+ const getElement = (document2, context, nth = 0) => {
4754
+ const { selectors } = context;
4755
+ return document2.querySelector(selectors[nth]);
4756
+ };
4757
+ function getElementBySelector(selector) {
4758
+ return document.querySelector(selector);
4759
+ }
4760
+ const unfocus = (element, mapping) => {
4761
+ const originalStyle = mapping.get(element);
4762
+ if (originalStyle) {
4763
+ const { css, rest, subscription } = originalStyle;
4764
+ rest.forEach((el) => {
4765
+ var _a2;
4766
+ return (_a2 = el.__unfocus_handler) == null ? void 0 : _a2.call(el);
4767
+ });
4768
+ subscription.unsubscribe();
4769
+ originalStyle.elementToFocus.forEach((el, idx) => {
4770
+ Object.assign(el.style, css[idx]);
4771
+ });
4772
+ }
4773
+ mapping.delete(element);
4774
+ };
4775
+ const noUndefined = (input) => input !== void 0;
4776
+ function focus(document2, obs$, mode$) {
4777
+ const stylesMap = /* @__PURE__ */ new Map();
4778
+ const getBySelector = getElementBySelector.bind(document2);
4779
+ const subscription = obs$.pipe(
4780
+ pairwise(),
4781
+ tap(([current]) => {
4782
+ var _a2;
4783
+ if (current !== void 0) {
4784
+ const prev = getElement(document2, current);
4785
+ if (prev !== null) {
4786
+ (_a2 = prev.__unfocus_handler) == null ? void 0 : _a2.call(prev);
4787
+ unfocus(prev, stylesMap);
4788
+ }
4789
+ }
4790
+ }),
4791
+ map(([, next]) => next),
4792
+ filter(noUndefined),
4793
+ map((next) => {
4794
+ const [first, ...rest] = next.selectors;
4795
+ const otherElements = rest.reduce((arr, selector) => {
4796
+ var _a2;
4797
+ const el = getBySelector(selector);
4798
+ if (el) {
4799
+ arr.push(el);
4800
+ const result = (_a2 = el.__focus_handler) == null ? void 0 : _a2.call(el);
4801
+ if (result && "then" in result) {
4802
+ result.catch(noop);
4803
+ }
4804
+ }
4805
+ return arr;
4806
+ }, []);
4807
+ return { first, next, otherElements };
4808
+ }),
4809
+ map((next) => ({ ...next, firstElement: getBySelector(next.first) })),
4810
+ filter((next) => next.firstElement !== null),
4811
+ map((next) => {
4812
+ var _a2, _b;
4813
+ return { ...next, focus: (_b = (_a2 = next.firstElement).__focus_handler) == null ? void 0 : _b.call(_a2) };
4814
+ }),
4815
+ concatMap(({ focus: focusPromise, ...rest }) => {
4816
+ const promise = focusPromise && "then" in focusPromise ? focusPromise : Promise.resolve(focusPromise != null ? focusPromise : rest.firstElement);
4817
+ return promise.then((focusElement) => ({ focus: focusElement, ...rest })).catch(() => ({ focus: void 0, ...rest }));
4818
+ })
4819
+ ).subscribe(({ otherElements, next, firstElement, focus: focusContext }) => {
4820
+ const cssKeys = Object.keys(next.style);
4821
+ const stylePendingChanges = new Subscription();
4822
+ const elementToFocus = toArray$1(focusContext != null ? focusContext : firstElement).filter(Boolean);
4823
+ const initialStyles = { css: [], elementToFocus, rest: otherElements, subscription: stylePendingChanges };
4824
+ const styles = cssKeys.reduce((acc, key) => {
4825
+ elementToFocus.forEach((el, idx) => {
4826
+ var _a2;
4827
+ acc.css[idx] = Object.assign((_a2 = acc.css[idx]) != null ? _a2 : {}, { [key]: el.style[key] });
4828
+ });
4829
+ return acc;
4830
+ }, initialStyles);
4831
+ stylePendingChanges.add(mode$.pipe(filter((val) => val === "select"), take(1)).subscribe(() => {
4832
+ elementToFocus.forEach((el) => {
4833
+ Object.assign(el.style, next.style);
4834
+ });
4835
+ }));
4836
+ stylesMap.set(firstElement, styles);
4837
+ });
4838
+ return () => subscription.unsubscribe();
4839
+ }
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);
4627
4844
  return value;
4628
4845
  };
4629
4846
  let Lexer$1 = class Lexer {
4630
4847
  constructor(input) {
4631
- __publicField$5(this, "_input");
4632
- __publicField$5(this, "_length");
4633
- __publicField$5(this, "_idx", 0);
4634
- __publicField$5(
4848
+ __publicField$3(this, "_input");
4849
+ __publicField$3(this, "_length");
4850
+ __publicField$3(this, "_idx", 0);
4851
+ __publicField$3(
4635
4852
  this,
4636
4853
  "_mode",
4637
4854
  0
4638
4855
  /* Literal */
4639
4856
  );
4640
- __publicField$5(this, "_literals", []);
4641
- __publicField$5(this, "_variables", []);
4642
- __publicField$5(this, "_braketCount", 0);
4643
- __publicField$5(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);
4644
4861
  this._input = input;
4645
4862
  this._length = input.length;
4646
4863
  }
@@ -4741,429 +4958,96 @@ function parse(input, context, preserveUnknown = false) {
4741
4958
  return acc;
4742
4959
  }
4743
4960
  const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));
4744
- var __defProp$4 = Object.defineProperty;
4745
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4746
- var __publicField$4 = (obj, key, value) => {
4747
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
4748
- return value;
4749
- };
4961
+ var DebugMessage = /* @__PURE__ */ ((DebugMessage2) => {
4962
+ DebugMessage2[DebugMessage2["Default"] = 0] = "Default";
4963
+ DebugMessage2[DebugMessage2["Skip"] = 1] = "Skip";
4964
+ return DebugMessage2;
4965
+ })(DebugMessage || {});
4750
4966
  const MIA_PREVIEW_ID = "__mia_preview_id";
4751
4967
  const OVERLAY_Z_INDEX = 1e6;
4752
4968
  const keys = {
4753
- "click-element": 1,
4754
- "ctrl-space": 1,
4969
+ "click-element": 0,
4970
+ "ctrl-space": 0,
4755
4971
  "focus-element": 0,
4756
- mousedown: 1,
4972
+ mousedown: 0,
4757
4973
  mousemove: 1,
4758
4974
  "new-configuration": 0,
4759
- notification: 1,
4760
- options: 1,
4761
- "request-resource": 1,
4762
- "service-worker": 1,
4975
+ notification: 0,
4976
+ options: 0,
4977
+ "request-resource": 0,
4763
4978
  "set-source-map": 0,
4764
- "tag-info": 1,
4765
- update: 1,
4766
- updated: 1
4767
- /* Skip */
4979
+ "tag-info": 0,
4980
+ update: 0,
4981
+ updated: 0
4982
+ /* Default */
4768
4983
  };
4769
- const isValidKey = (type) => Object.keys(keys).includes(type);
4770
- function isInstanceMessage(input, signature) {
4771
- if (input === null) {
4772
- return false;
4773
- }
4774
- if (typeof input !== "object") {
4775
- return false;
4776
- }
4777
- if (!("type" in input) || typeof input.type !== "string") {
4778
- return false;
4779
- }
4780
- const { type: signedType } = input;
4781
- if (!signedType.startsWith(signature)) {
4782
- return false;
4783
- }
4784
- const type = signedType.substring(signature.length);
4785
- if (!isValidKey(type)) {
4786
- return false;
4787
- }
4788
- return true;
4789
- }
4790
- const sign = (signature, message) => ({ ...message, type: `${signature}${message.type}` });
4791
- const unsign = (signature, message) => {
4792
- let { type } = message;
4793
- if (type.startsWith(signature)) {
4794
- type = type.substring(signature.length);
4984
+ var t;
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}*(?:[^
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) => {
4987
+ const s2 = t2.length - 1, l2 = [];
4988
+ let r2, d2 = 2 === i2 ? "<svg>" : "", u2 = f;
4989
+ for (let i3 = 0; i3 < s2; i3++) {
4990
+ const s3 = t2[i3];
4991
+ let e2, c3, v2 = -1, a2 = 0;
4992
+ for (; a2 < s3.length && (u2.lastIndex = a2, c3 = u2.exec(s3), null !== c3); )
4993
+ a2 = u2.lastIndex, u2 === f ? "!--" === c3[1] ? u2 = _ : void 0 !== c3[1] ? u2 = m : void 0 !== c3[2] ? (y.test(c3[2]) && (r2 = RegExp("</" + c3[2], "g")), u2 = p) : void 0 !== c3[3] && (u2 = p) : u2 === p ? ">" === c3[0] ? (u2 = null != r2 ? r2 : f, v2 = -1) : void 0 === c3[1] ? v2 = -2 : (v2 = u2.lastIndex - c3[2].length, e2 = c3[1], u2 = void 0 === c3[3] ? p : '"' === c3[3] ? $ : g) : u2 === $ || u2 === g ? u2 = p : u2 === _ || u2 === m ? u2 = f : (u2 = p, r2 = void 0);
4994
+ const w2 = u2 === p && t2[i3 + 1].startsWith("/>") ? " " : "";
4995
+ d2 += u2 === f ? s3 + h : v2 >= 0 ? (l2.push(e2), s3.slice(0, v2) + o + s3.slice(v2) + n + w2) : s3 + n + (-2 === v2 ? (l2.push(void 0), i3) : w2);
4795
4996
  }
4796
- return { ...message, type };
4997
+ const c2 = d2 + (t2[s2] || "<?>") + (2 === i2 ? "</svg>" : "");
4998
+ if (!Array.isArray(t2) || !t2.hasOwnProperty("raw"))
4999
+ throw Error("invalid template strings array");
5000
+ return [void 0 !== e ? e.createHTML(c2) : c2, l2];
4797
5001
  };
4798
- const generateDarkColorHex = () => {
4799
- let color = "#";
4800
- for (let i2 = 0; i2 < 3; i2++) {
4801
- color += `0${Math.floor(Math.random() * Math.pow(16, 2) / 2).toString(16)}`.slice(-2);
5002
+ class V {
5003
+ constructor({ strings: t2, _$litType$: i2 }, e2) {
5004
+ let h2;
5005
+ this.parts = [];
5006
+ let r2 = 0, u2 = 0;
5007
+ const c2 = t2.length - 1, v2 = this.parts, [a2, f2] = P(t2, i2);
5008
+ if (this.el = V.createElement(a2, e2), C.currentNode = this.el.content, 2 === i2) {
5009
+ const t3 = this.el.content, i3 = t3.firstChild;
5010
+ i3.remove(), t3.append(...i3.childNodes);
5011
+ }
5012
+ for (; null !== (h2 = C.nextNode()) && v2.length < c2; ) {
5013
+ if (1 === h2.nodeType) {
5014
+ if (h2.hasAttributes()) {
5015
+ const t3 = [];
5016
+ for (const i3 of h2.getAttributeNames())
5017
+ if (i3.endsWith(o) || i3.startsWith(n)) {
5018
+ const s2 = f2[u2++];
5019
+ if (t3.push(i3), void 0 !== s2) {
5020
+ const t4 = h2.getAttribute(s2.toLowerCase() + o).split(n), i4 = /([.?@])?(.*)/.exec(s2);
5021
+ v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? k : "?" === i4[1] ? I : "@" === i4[1] ? L : R });
5022
+ } else
5023
+ v2.push({ type: 6, index: r2 });
5024
+ }
5025
+ for (const i3 of t3)
5026
+ h2.removeAttribute(i3);
5027
+ }
5028
+ if (y.test(h2.tagName)) {
5029
+ const t3 = h2.textContent.split(n), i3 = t3.length - 1;
5030
+ if (i3 > 0) {
5031
+ h2.textContent = s ? s.emptyScript : "";
5032
+ for (let s2 = 0; s2 < i3; s2++)
5033
+ h2.append(t3[s2], d()), C.nextNode(), v2.push({ type: 2, index: ++r2 });
5034
+ h2.append(t3[i3], d());
5035
+ }
5036
+ }
5037
+ } else if (8 === h2.nodeType)
5038
+ if (h2.data === l)
5039
+ v2.push({ type: 2, index: r2 });
5040
+ else {
5041
+ let t3 = -1;
5042
+ for (; -1 !== (t3 = h2.data.indexOf(n, t3 + 1)); )
5043
+ v2.push({ type: 7, index: r2 }), t3 += n.length - 1;
5044
+ }
5045
+ r2++;
5046
+ }
4802
5047
  }
4803
- return color;
4804
- };
4805
- class PostChannel {
4806
- constructor(handler2) {
4807
- __publicField$4(this, "__instance");
4808
- __publicField$4(this, "__handler");
4809
- __publicField$4(this, "__window");
4810
- __publicField$4(this, "__randomColor");
4811
- this.__instance = "";
4812
- this.__handler = handler2;
4813
- this.__window = window;
4814
- this.__randomColor = generateDarkColorHex();
4815
- }
4816
- postMessage(to, message, origin) {
4817
- {
4818
- console.assert(to !== this.__window);
4819
- }
4820
- if (keys[message.type] !== 1) {
4821
- const color = this.__randomColor;
4822
- const background = `${color}22`;
4823
- const style = { background, color };
4824
- const hasTop = this.__window.top !== this.__window;
4825
- console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? "(inner)" : "(top)"} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
4826
- console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
4827
- console.log("to", to.document);
4828
- console.log(message.content);
4829
- console.groupEnd();
4830
- }
4831
- to.postMessage(sign(this.__instance, message), origin);
4832
- }
4833
- set instance(str) {
4834
- this.__instance = str;
4835
- }
4836
- get window() {
4837
- return this.__window;
4838
- }
4839
- set window(win) {
4840
- this.__window = win;
4841
- }
4842
- send(to, message, origin = "*") {
4843
- this.__window !== to && this.postMessage(to, message, origin);
4844
- }
4845
- recv(window2, from2 = null) {
4846
- const listener = ({ data, source }) => {
4847
- if ((from2 === null || source === from2) && isInstanceMessage(data, this.__instance)) {
4848
- const message = unsign(this.__instance, data);
4849
- this.__handler(message);
4850
- }
4851
- };
4852
- window2.addEventListener("message", listener);
4853
- return () => window2.removeEventListener("message", listener);
4854
- }
4855
- }
4856
- var __defProp$3 = Object.defineProperty;
4857
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4858
- var __publicField$3 = (obj, key, value) => {
4859
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
4860
- return value;
4861
- };
4862
- function registerChannels() {
4863
- return {
4864
- configuration: new ReplaySubject(),
4865
- focus: new BehaviorSubject(void 0),
4866
- infos: new ReplaySubject(),
4867
- mocks: new ReplaySubject(),
4868
- mode: new BehaviorSubject("select"),
4869
- notification: new ReplaySubject(),
4870
- setSourceMap: new ReplaySubject(),
4871
- swReady: new ReplaySubject(1),
4872
- updated: new Subject(),
4873
- uppercaseTags: /* @__PURE__ */ new Set()
4874
- };
4875
- }
4876
- const nextMode = (mode) => {
4877
- let next = 0;
4878
- const currentValue = mode.getValue();
4879
- if (currentValue === "interact") {
4880
- next = "select";
4881
- } else if (currentValue === "select") {
4882
- next = "interact";
4883
- }
4884
- mode.next(next);
4885
- return next;
4886
- };
4887
- const subjects = registerChannels();
4888
- function parentListener(message) {
4889
- switch (message.type) {
4890
- case "options": {
4891
- const { content: { disableOverlay, redirectTo, timeout } } = message;
4892
- if (disableOverlay) {
4893
- Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
4894
- subjects.mode.next("interact");
4895
- }
4896
- if (timeout !== void 0) {
4897
- Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
4898
- }
4899
- const { window: { history } } = this;
4900
- this.window.navigator.serviceWorker.ready.then(() => redirectTo && history.pushState(history.state, "", redirectTo)).catch(() => {
4901
- });
4902
- break;
4903
- }
4904
- case "ctrl-space":
4905
- nextMode(subjects.mode);
4906
- break;
4907
- case "new-configuration":
4908
- subjects.configuration.next({ ...message.content, type: "reset" });
4909
- break;
4910
- case "update":
4911
- subjects.configuration.next({ ...message.content, type: "update" });
4912
- break;
4913
- case "focus-element":
4914
- subjects.focus.next(message.content);
4915
- break;
4916
- case "set-source-map": {
4917
- const { content: { dictionary } } = message;
4918
- subjects.setSourceMap.next({
4919
- ...message.content,
4920
- dictionary: Object.entries(dictionary).reduce((acc, [from2, to]) => {
4921
- try {
4922
- const { href: fromUrl } = new URL(from2, this.window.location.href);
4923
- const obj = typeof to === "string" ? { headers: {}, query: {}, to } : to;
4924
- acc[fromUrl] = {
4925
- originalFrom: from2,
4926
- ...obj
4927
- };
4928
- } catch (e2) {
4929
- }
4930
- return acc;
4931
- }, {})
4932
- });
4933
- break;
4934
- }
4935
- }
4936
- }
4937
- class ServiceWorkerChannel {
4938
- constructor(handler2) {
4939
- __publicField$3(this, "__handler");
4940
- __publicField$3(this, "__window");
4941
- __publicField$3(this, "__randomColor");
4942
- this.__handler = handler2;
4943
- this.__window = window;
4944
- this.__randomColor = generateDarkColorHex();
4945
- }
4946
- send(to, message) {
4947
- {
4948
- const color = this.__randomColor;
4949
- const background = `${color}22`;
4950
- const style = { background, color };
4951
- console.groupCollapsed(`%c Msg to Service Worker `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
4952
- console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
4953
- console.log(message.content);
4954
- console.groupEnd();
4955
- }
4956
- to.postMessage(message);
4957
- }
4958
- get window() {
4959
- return this.__window;
4960
- }
4961
- set window(win) {
4962
- this.__window = win;
4963
- }
4964
- recv() {
4965
- const swListener2 = ({ data }) => {
4966
- this.__handler(data);
4967
- };
4968
- const { __window: { navigator: navigator2 } } = this;
4969
- navigator2.serviceWorker.addEventListener("message", swListener2);
4970
- return () => navigator2.serviceWorker.removeEventListener("message", swListener2);
4971
- }
4972
- }
4973
- const swListener = (message) => {
4974
- switch (message.type) {
4975
- case "source-map-ack":
4976
- subjects.swReady.next(0);
4977
- break;
4978
- }
4979
- };
4980
- const postChannel = new PostChannel(parentListener);
4981
- const serviceWorkerChannel = new ServiceWorkerChannel(swListener);
4982
- const DEFAULT_LANGUAGE = "en";
4983
- const localizeText = (input, lang = DEFAULT_LANGUAGE) => {
4984
- if (typeof input === "string") {
4985
- return input;
4986
- }
4987
- return input == null ? void 0 : input[lang];
4988
- };
4989
- function translateObject(obj) {
4990
- return Object.entries(obj).reduce((out, [key, value]) => {
4991
- out[key] = localizeText(value);
4992
- return out;
4993
- }, {});
4994
- }
4995
- const noop = (..._args) => {
4996
- };
4997
- const toArray$1 = (input) => Array.isArray(input) ? input : [input];
4998
- const urlMakerFactory = ({ document: { baseURI }, location: { href } }) => (input) => new URL(input, new URL(baseURI, href));
4999
- const toURL = (urlMaker, info) => {
5000
- let url = info;
5001
- if (!(info instanceof URL)) {
5002
- url = urlMaker(typeof info === "string" ? info : info.url);
5003
- }
5004
- return url;
5005
- };
5006
- const trimLocationOrigin = (origin, url) => {
5007
- const { href, origin: linkOrigin } = url;
5008
- if (origin === linkOrigin) {
5009
- return href.substring(origin.length);
5010
- }
5011
- return href;
5012
- };
5013
- const getElement = (document2, context, nth = 0) => {
5014
- const { selectors } = context;
5015
- return document2.querySelector(selectors[nth]);
5016
- };
5017
- function getElementBySelector(selector) {
5018
- return document.querySelector(selector);
5019
- }
5020
- const unfocus = (element, mapping) => {
5021
- const originalStyle = mapping.get(element.getAttribute("__mia_preview_id"));
5022
- if (originalStyle) {
5023
- const { css, rest, subscription } = originalStyle;
5024
- rest.forEach((el) => {
5025
- var _a2;
5026
- return (_a2 = el.__unfocus_handler) == null ? void 0 : _a2.call(el);
5027
- });
5028
- subscription.unsubscribe();
5029
- originalStyle.elementToFocus.forEach((el, idx) => {
5030
- Object.assign(el.style, css[idx]);
5031
- });
5032
- }
5033
- mapping.delete(element.getAttribute("__mia_preview_id"));
5034
- };
5035
- const noUndefined = (input) => input !== void 0;
5036
- function focus(document2, obs$, mode$) {
5037
- const stylesMap = /* @__PURE__ */ new Map();
5038
- const getBySelector = getElementBySelector.bind(document2);
5039
- const subscription = obs$.pipe(
5040
- pairwise(),
5041
- tap(([current]) => {
5042
- var _a2;
5043
- if (current !== void 0) {
5044
- const prev = getElement(document2, current);
5045
- if (prev !== null) {
5046
- (_a2 = prev.__unfocus_handler) == null ? void 0 : _a2.call(prev);
5047
- unfocus(prev, stylesMap);
5048
- }
5049
- }
5050
- }),
5051
- map(([, next]) => next),
5052
- filter(noUndefined),
5053
- map((next) => {
5054
- const [first, ...rest] = next.selectors;
5055
- const otherElements = rest.reduce((arr, selector) => {
5056
- var _a2;
5057
- const el = getBySelector(selector);
5058
- if (el) {
5059
- arr.push(el);
5060
- const result = (_a2 = el.__focus_handler) == null ? void 0 : _a2.call(el);
5061
- if (result && "then" in result) {
5062
- result.catch(noop);
5063
- }
5064
- }
5065
- return arr;
5066
- }, []);
5067
- return { first, next, otherElements };
5068
- }),
5069
- map((next) => ({ ...next, firstElement: getBySelector(next.first) })),
5070
- filter((next) => next.firstElement !== null),
5071
- map((next) => {
5072
- var _a2, _b;
5073
- return { ...next, focus: (_b = (_a2 = next.firstElement).__focus_handler) == null ? void 0 : _b.call(_a2) };
5074
- }),
5075
- concatMap(({ focus: focusPromise, ...rest }) => {
5076
- const promise = focusPromise && "then" in focusPromise ? focusPromise : Promise.resolve(focusPromise != null ? focusPromise : rest.firstElement);
5077
- return promise.then((focusElement) => ({ focus: focusElement, ...rest })).catch(() => ({ focus: void 0, ...rest }));
5078
- })
5079
- ).subscribe(({ otherElements, next, firstElement, focus: focusContext }) => {
5080
- const cssKeys = Object.keys(next.style);
5081
- const stylePendingChanges = new Subscription();
5082
- const elementToFocus = toArray$1(focusContext != null ? focusContext : firstElement).filter(Boolean);
5083
- const initialStyles = { css: [], elementToFocus, rest: otherElements, subscription: stylePendingChanges };
5084
- const styles = cssKeys.reduce((acc, key) => {
5085
- elementToFocus.forEach((el, idx) => {
5086
- var _a2;
5087
- acc.css[idx] = Object.assign((_a2 = acc.css[idx]) != null ? _a2 : {}, { [key]: el.style[key] });
5088
- });
5089
- return acc;
5090
- }, initialStyles);
5091
- stylePendingChanges.add(mode$.pipe(filter((val) => val === "select"), take(1)).subscribe(() => {
5092
- elementToFocus.forEach((el) => {
5093
- Object.assign(el.style, next.style);
5094
- });
5095
- }));
5096
- stylesMap.set(firstElement.getAttribute("__mia_preview_id"), styles);
5097
- });
5098
- return () => subscription.unsubscribe();
5099
- }
5100
- var t;
5101
- 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}*(?:[^
5102
- \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) => {
5103
- const s2 = t2.length - 1, l2 = [];
5104
- let r2, d2 = 2 === i2 ? "<svg>" : "", u2 = f;
5105
- for (let i3 = 0; i3 < s2; i3++) {
5106
- const s3 = t2[i3];
5107
- let e2, c3, v2 = -1, a2 = 0;
5108
- for (; a2 < s3.length && (u2.lastIndex = a2, c3 = u2.exec(s3), null !== c3); )
5109
- a2 = u2.lastIndex, u2 === f ? "!--" === c3[1] ? u2 = _ : void 0 !== c3[1] ? u2 = m : void 0 !== c3[2] ? (y.test(c3[2]) && (r2 = RegExp("</" + c3[2], "g")), u2 = p) : void 0 !== c3[3] && (u2 = p) : u2 === p ? ">" === c3[0] ? (u2 = null != r2 ? r2 : f, v2 = -1) : void 0 === c3[1] ? v2 = -2 : (v2 = u2.lastIndex - c3[2].length, e2 = c3[1], u2 = void 0 === c3[3] ? p : '"' === c3[3] ? $ : g) : u2 === $ || u2 === g ? u2 = p : u2 === _ || u2 === m ? u2 = f : (u2 = p, r2 = void 0);
5110
- const w2 = u2 === p && t2[i3 + 1].startsWith("/>") ? " " : "";
5111
- d2 += u2 === f ? s3 + h : v2 >= 0 ? (l2.push(e2), s3.slice(0, v2) + o + s3.slice(v2) + n + w2) : s3 + n + (-2 === v2 ? (l2.push(void 0), i3) : w2);
5112
- }
5113
- const c2 = d2 + (t2[s2] || "<?>") + (2 === i2 ? "</svg>" : "");
5114
- if (!Array.isArray(t2) || !t2.hasOwnProperty("raw"))
5115
- throw Error("invalid template strings array");
5116
- return [void 0 !== e ? e.createHTML(c2) : c2, l2];
5117
- };
5118
- class V {
5119
- constructor({ strings: t2, _$litType$: i2 }, e2) {
5120
- let h2;
5121
- this.parts = [];
5122
- let r2 = 0, u2 = 0;
5123
- const c2 = t2.length - 1, v2 = this.parts, [a2, f2] = P(t2, i2);
5124
- if (this.el = V.createElement(a2, e2), C.currentNode = this.el.content, 2 === i2) {
5125
- const t3 = this.el.content, i3 = t3.firstChild;
5126
- i3.remove(), t3.append(...i3.childNodes);
5127
- }
5128
- for (; null !== (h2 = C.nextNode()) && v2.length < c2; ) {
5129
- if (1 === h2.nodeType) {
5130
- if (h2.hasAttributes()) {
5131
- const t3 = [];
5132
- for (const i3 of h2.getAttributeNames())
5133
- if (i3.endsWith(o) || i3.startsWith(n)) {
5134
- const s2 = f2[u2++];
5135
- if (t3.push(i3), void 0 !== s2) {
5136
- const t4 = h2.getAttribute(s2.toLowerCase() + o).split(n), i4 = /([.?@])?(.*)/.exec(s2);
5137
- v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? k : "?" === i4[1] ? I : "@" === i4[1] ? L : R });
5138
- } else
5139
- v2.push({ type: 6, index: r2 });
5140
- }
5141
- for (const i3 of t3)
5142
- h2.removeAttribute(i3);
5143
- }
5144
- if (y.test(h2.tagName)) {
5145
- const t3 = h2.textContent.split(n), i3 = t3.length - 1;
5146
- if (i3 > 0) {
5147
- h2.textContent = s ? s.emptyScript : "";
5148
- for (let s2 = 0; s2 < i3; s2++)
5149
- h2.append(t3[s2], d()), C.nextNode(), v2.push({ type: 2, index: ++r2 });
5150
- h2.append(t3[i3], d());
5151
- }
5152
- }
5153
- } else if (8 === h2.nodeType)
5154
- if (h2.data === l)
5155
- v2.push({ type: 2, index: r2 });
5156
- else {
5157
- let t3 = -1;
5158
- for (; -1 !== (t3 = h2.data.indexOf(n, t3 + 1)); )
5159
- v2.push({ type: 7, index: r2 }), t3 += n.length - 1;
5160
- }
5161
- r2++;
5162
- }
5163
- }
5164
- static createElement(t2, i2) {
5165
- const s2 = r.createElement("template");
5166
- return s2.innerHTML = t2, s2;
5048
+ static createElement(t2, i2) {
5049
+ const s2 = r.createElement("template");
5050
+ return s2.innerHTML = t2, s2;
5167
5051
  }
5168
5052
  }
5169
5053
  function N(t2, i2, s2 = t2, e2) {
@@ -5176,7 +5060,7 @@ function N(t2, i2, s2 = t2, e2) {
5176
5060
  }
5177
5061
  class S {
5178
5062
  constructor(t2, i2) {
5179
- 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;
5180
5064
  }
5181
5065
  get parentNode() {
5182
5066
  return this._$AM.parentNode;
@@ -5184,7 +5068,7 @@ class S {
5184
5068
  get _$AU() {
5185
5069
  return this._$AM._$AU;
5186
5070
  }
5187
- v(t2) {
5071
+ u(t2) {
5188
5072
  var i2;
5189
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);
5190
5074
  C.currentNode = o2;
@@ -5192,26 +5076,26 @@ class S {
5192
5076
  for (; void 0 !== d2; ) {
5193
5077
  if (l2 === d2.index) {
5194
5078
  let i3;
5195
- 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];
5196
5080
  }
5197
5081
  l2 !== (null == d2 ? void 0 : d2.index) && (n2 = C.nextNode(), l2++);
5198
5082
  }
5199
- return o2;
5083
+ return C.currentNode = r, o2;
5200
5084
  }
5201
- p(t2) {
5085
+ v(t2) {
5202
5086
  let i2 = 0;
5203
- for (const s2 of this.u)
5087
+ for (const s2 of this._$AV)
5204
5088
  void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++;
5205
5089
  }
5206
5090
  }
5207
5091
  class M {
5208
5092
  constructor(t2, i2, s2, e2) {
5209
5093
  var o2;
5210
- 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;
5211
5095
  }
5212
5096
  get _$AU() {
5213
5097
  var t2, i2;
5214
- 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;
5215
5099
  }
5216
5100
  get parentNode() {
5217
5101
  let t2 = this._$AA.parentNode;
@@ -5225,37 +5109,37 @@ class M {
5225
5109
  return this._$AB;
5226
5110
  }
5227
5111
  _$AI(t2, i2 = this) {
5228
- 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);
5229
5113
  }
5230
- S(t2) {
5114
+ k(t2) {
5231
5115
  return this._$AA.parentNode.insertBefore(t2, this._$AB);
5232
5116
  }
5233
- T(t2) {
5234
- this._$AH !== t2 && (this._$AR(), this._$AH = this.S(t2));
5117
+ $(t2) {
5118
+ this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2));
5235
5119
  }
5236
- g(t2) {
5237
- 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;
5238
5122
  }
5239
- $(t2) {
5123
+ g(t2) {
5240
5124
  var i2;
5241
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);
5242
5126
  if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o2)
5243
- this._$AH.p(s2);
5127
+ this._$AH.v(s2);
5244
5128
  else {
5245
- const t3 = new S(o2, this), i3 = t3.v(this.options);
5246
- 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;
5247
5131
  }
5248
5132
  }
5249
5133
  _$AC(t2) {
5250
5134
  let i2 = E.get(t2.strings);
5251
5135
  return void 0 === i2 && E.set(t2.strings, i2 = new V(t2)), i2;
5252
5136
  }
5253
- k(t2) {
5137
+ T(t2) {
5254
5138
  c(this._$AH) || (this._$AH = [], this._$AR());
5255
5139
  const i2 = this._$AH;
5256
5140
  let s2, e2 = 0;
5257
5141
  for (const o2 of t2)
5258
- 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++;
5259
5143
  e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2);
5260
5144
  }
5261
5145
  _$AR(t2 = this._$AA.nextSibling, i2) {
@@ -5267,7 +5151,7 @@ class M {
5267
5151
  }
5268
5152
  setConnected(t2) {
5269
5153
  var i2;
5270
- 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));
5271
5155
  }
5272
5156
  }
5273
5157
  class R {
@@ -5342,7 +5226,7 @@ class z {
5342
5226
  }
5343
5227
  }
5344
5228
  const j = i.litHtmlPolyfillSupport;
5345
- 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");
5346
5230
  const B = (t2, i2, s2) => {
5347
5231
  var e2, o2;
5348
5232
  const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2;
@@ -5550,7 +5434,7 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
5550
5434
  })).then(() => baseModule());
5551
5435
  };
5552
5436
  function error(message, ...args) {
5553
- __vitePreload(() => import("./assets/errors-5a0ccde7.js"), true ? [] : void 0, import.meta.url).then(({ default: errorMap }) => {
5437
+ __vitePreload(() => import("./errors-5a0ccde7.js"), true ? [] : void 0, import.meta.url).then(({ default: errorMap }) => {
5554
5438
  const handler2 = errorMap[message];
5555
5439
  handler2 ? console.error(handler2(...args)) : console.error(...args);
5556
5440
  }).catch((err) => {
@@ -5564,12 +5448,12 @@ function dynamicImportError(name) {
5564
5448
  error("0", name, err.message);
5565
5449
  };
5566
5450
  }
5567
- const logger$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5451
+ const logger = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5568
5452
  __proto__: null,
5569
5453
  dynamicImportError,
5570
5454
  error
5571
5455
  }, Symbol.toStringTag, { value: "Module" }));
5572
- var logger_default = logger$1;
5456
+ var logger_default = logger;
5573
5457
  var __defProp$2 = Object.defineProperty;
5574
5458
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5575
5459
  var __publicField$2 = (obj, key, value) => {
@@ -5804,17 +5688,17 @@ const fromErrorToNotification = (error2) => {
5804
5688
  status: "error"
5805
5689
  };
5806
5690
  };
5807
- const errorHandler = (self2, error2) => postChannel.send(self2.parent, {
5691
+ const errorHandler = (channel, error2) => channel.send({
5808
5692
  content: fromErrorToNotification(error2),
5809
5693
  type: "notification"
5810
5694
  });
5811
5695
  const isRealMouseEvent = (event) => "clientX" in event && "clientY" in event;
5812
- function mouseEventFactory(self2, type) {
5696
+ function mouseEventFactory(channel, type) {
5813
5697
  return (event) => {
5814
5698
  if (!isRealMouseEvent(event)) {
5815
5699
  return;
5816
5700
  }
5817
- postChannel.send(self2.parent, {
5701
+ channel.send({
5818
5702
  content: {
5819
5703
  bubbles: true,
5820
5704
  cancelable: false,
@@ -5826,7 +5710,7 @@ function mouseEventFactory(self2, type) {
5826
5710
  };
5827
5711
  }
5828
5712
  const isControlledElement = (tags, element) => tags.has(element.tagName) && element.hasAttribute(MIA_PREVIEW_ID);
5829
- const mouseOnElementFactory = (self2, channels) => {
5713
+ const mouseOnElementFactory = (self2, postChannel, channels) => {
5830
5714
  const { document: document2 } = self2;
5831
5715
  return (event) => {
5832
5716
  let content;
@@ -5842,13 +5726,305 @@ const mouseOnElementFactory = (self2, channels) => {
5842
5726
  }, { ids: [], selectors: [] });
5843
5727
  }
5844
5728
  if (channels.mode.getValue() === "select" || content === void 0) {
5845
- postChannel.send(self2.parent, {
5729
+ postChannel.send({
5846
5730
  content: content && (content.ids.length > 0 ? content : void 0),
5847
5731
  type: "click-element"
5848
5732
  });
5849
5733
  }
5850
5734
  };
5851
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
+ );
5852
6028
  const ctrlSpaceFactory = (channels) => {
5853
6029
  return (evt) => {
5854
6030
  if (evt.ctrlKey && evt.key === " ") {
@@ -5879,49 +6055,42 @@ const requireInfo = (registry, tags) => from(tags.map((tag) => [tag, registry.wh
5879
6055
  mergeMap(extractManifest)
5880
6056
  );
5881
6057
  const BUFFER_TIME = 500;
5882
- function reporter(err) {
6058
+ const reporter = (postChannel, err) => {
5883
6059
  if (err instanceof Error) {
5884
- errorHandler(this, err);
6060
+ errorHandler(postChannel, err);
5885
6061
  }
5886
- }
5887
- function collectInfos(info$, addInfo) {
5888
- const boundReporter = reporter.bind(this);
5889
- return info$.pipe(
5890
- mergeMap(([, { __manifest: { label, description, ...rest }, tag }]) => {
5891
- delete rest.mocks;
5892
- return of({ info: { ...translateObject({ description, label }), ...rest }, tag });
5893
- }),
5894
- bufferTime(BUFFER_TIME),
5895
- filter((newInfos) => newInfos.length > 0)
5896
- ).subscribe({
5897
- error: boundReporter,
5898
- next: (extras) => addInfo(extras)
5899
- });
5900
- }
5901
- function collectMocks(info$) {
5902
- const boundReporter = reporter.bind(this);
5903
- return info$.pipe(
5904
- map(
5905
- ([, { __manifest: { mocks = {} }, tag }]) => [tag, mocks]
5906
- )
5907
- ).subscribe({
5908
- error: boundReporter,
5909
- next: (mockPair) => {
5910
- subjects.mocks.next(mockPair);
5911
- }
5912
- });
5913
- }
5914
- 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, {
5915
6085
  addInfo,
5916
6086
  tags
5917
6087
  }) {
5918
6088
  const { subscription } = this;
5919
- const boundReporter = reporter.bind(this);
5920
6089
  if (config2) {
5921
6090
  const info$ = requireInfo(this.customElements, tags);
5922
- return premount(config2, this, boundReporter).then(() => {
5923
- subscription.add(collectInfos.call(this, info$, addInfo));
5924
- 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$));
5925
6094
  });
5926
6095
  }
5927
6096
  }
@@ -5930,9 +6099,7 @@ const getPreviewContainer = (frame, root) => {
5930
6099
  let container = root.firstElementChild;
5931
6100
  if (container === null) {
5932
6101
  container = document2.createElement("div");
5933
- container.style.height = "100%";
5934
- container.style.width = "100%";
5935
- container.style.overflow = "auto";
6102
+ container.style.height = "inherit";
5936
6103
  container.style.display = "flex";
5937
6104
  root.appendChild(container);
5938
6105
  }
@@ -5963,7 +6130,7 @@ function fetchMockFactory(instance, fetchFactory, windowHref) {
5963
6130
  var _a2;
5964
6131
  const info = compileObject({ ...url, method }, context);
5965
6132
  const matcher = new URL(info.pathname, (_a2 = info.origin) != null ? _a2 : windowHref);
5966
- return [matcher.href, method, (injectedInfo, init2) => fetchHandler(injectedInfo, init2).finally(() => {
6133
+ return [matcher.href, method, (injectedInfo, init) => fetchHandler(injectedInfo, init).finally(() => {
5967
6134
  if (notify) {
5968
6135
  this.notify(fetchNotification(method, matcher));
5969
6136
  }
@@ -6040,12 +6207,12 @@ const printHeaders = (headers) => {
6040
6207
  });
6041
6208
  return JSON.stringify(obj);
6042
6209
  };
6043
- const fetchPrint = (window2, url, init2, resHeaders = new Headers()) => {
6210
+ const fetchPrint = (window2, url, init, resHeaders = new Headers()) => {
6044
6211
  var _a2;
6045
6212
  const style = window2.origin === "null" ? { background: "antiquewhite", color: "brown" } : { background: "cyan", color: "blue" };
6046
6213
  console.groupCollapsed(`%c Fetching from ${window2.origin} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
6047
6214
  console.info(
6048
- `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)}`,
6049
6216
  "background: lightgreen; color: darkgreen"
6050
6217
  );
6051
6218
  console.groupEnd();
@@ -6057,7 +6224,7 @@ const notFoundTagNotification = (tag) => ({
6057
6224
  message: "preview.notifications.no-webcomponent-definition.message",
6058
6225
  status: "warning"
6059
6226
  });
6060
- async function mock(contexts, tags = []) {
6227
+ async function mock(postChannel, subjects, contexts, tags = []) {
6061
6228
  const { location: { href }, fetch: originalFetch } = this;
6062
6229
  const urlMaker = urlMakerFactory(this);
6063
6230
  const store = new FetchMockStore(this.notify.bind(this));
@@ -6081,21 +6248,21 @@ async function mock(contexts, tags = []) {
6081
6248
  const instancesCarryingMocks = (_a2 = contexts.get(tag)) != null ? _a2 : [];
6082
6249
  return handler(store, instancesCarryingMocks, fetchFactory, href);
6083
6250
  })).catch(
6084
- (error2) => error2 instanceof Error && errorHandler(this, error2)
6251
+ (error2) => error2 instanceof Error && errorHandler(postChannel, error2)
6085
6252
  );
6086
- const mockedFetch = async (info, init2) => {
6253
+ const mockedFetch = async (info, init) => {
6087
6254
  var _a2;
6088
6255
  const url = toURL(urlMaker, info);
6089
- 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 });
6090
6257
  if (mockImplementation !== void 0) {
6091
- return mockImplementation(url, init2).then((res) => {
6258
+ return mockImplementation(url, init).then((res) => {
6092
6259
  {
6093
- fetchPrint(this, url, init2, res.headers);
6260
+ fetchPrint(this, url, init, res.headers);
6094
6261
  }
6095
6262
  return res;
6096
6263
  });
6097
6264
  }
6098
- return originalFetch(info, init2);
6265
+ return originalFetch(info, init);
6099
6266
  };
6100
6267
  if (this.proxyWindow) {
6101
6268
  const newFetch = Object.assign(
@@ -6279,10 +6446,10 @@ function wrap(frame, notification) {
6279
6446
  const unpatch = domPatch(sandbox);
6280
6447
  return { sandbox, unpatch };
6281
6448
  }
6282
- var __defProp = Object.defineProperty;
6283
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6284
- var __publicField = (obj, key, value) => {
6285
- __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);
6286
6453
  return value;
6287
6454
  };
6288
6455
  function appendOverlay(self2, mode$) {
@@ -6324,8 +6491,9 @@ function appendOverlay(self2, mode$) {
6324
6491
  }
6325
6492
  const appendRenderRoot = (document2) => {
6326
6493
  const renderRoot = document2.createElement("div");
6494
+ renderRoot.style.display = "flex";
6495
+ renderRoot.style.flexDirection = "column";
6327
6496
  renderRoot.style.height = "inherit";
6328
- renderRoot.style.width = "inherit";
6329
6497
  document2.body.appendChild(renderRoot);
6330
6498
  return renderRoot;
6331
6499
  };
@@ -6341,8 +6509,8 @@ function createLifecycle(frame) {
6341
6509
  }
6342
6510
  class Queue {
6343
6511
  constructor() {
6344
- __publicField(this, "_results", /* @__PURE__ */ new Map());
6345
- __publicField(this, "_queue", Promise.resolve());
6512
+ __publicField2(this, "_results", /* @__PURE__ */ new Map());
6513
+ __publicField2(this, "_queue", Promise.resolve());
6346
6514
  }
6347
6515
  add(args) {
6348
6516
  const fns = [...args];
@@ -6380,12 +6548,9 @@ const addInfoFactory = (channels) => (info) => {
6380
6548
  channels.infos.next(info);
6381
6549
  info.forEach(({ tag }) => channels.uppercaseTags.add(tag.toUpperCase()));
6382
6550
  };
6383
- const run = (frame, renderRoot, channels) => {
6551
+ const run = (frame, renderRoot, postChannel, channels) => {
6384
6552
  const queue = new Queue();
6385
- const subscription = channels.configuration.pipe(
6386
- combineLatestWith(subjects.swReady.pipe(take(1))),
6387
- map(([next]) => next)
6388
- ).subscribe((next) => {
6553
+ const subscription = channels.configuration.pipe(combineLatestWith(channels.swSourceMapAck)).subscribe(([next]) => {
6389
6554
  const { configuration } = next;
6390
6555
  const { content } = configuration;
6391
6556
  let done;
@@ -6393,8 +6558,8 @@ const run = (frame, renderRoot, channels) => {
6393
6558
  const { contexts, tags } = next;
6394
6559
  done = queue.add([
6395
6560
  () => unmount.call(frame, renderRoot),
6396
- () => bootstrap.call(frame, configuration, { addInfo: addInfoFactory(channels), tags }),
6397
- () => 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),
6398
6563
  () => update.call(frame, content, renderRoot).finally(() => channels.updated.next(0))
6399
6564
  ]);
6400
6565
  } else {
@@ -6443,16 +6608,16 @@ const interceptCORSFetch = (self2, notification) => {
6443
6608
  return;
6444
6609
  }
6445
6610
  const originalFetch = self2.fetch.bind(self2);
6446
- self2.fetch = (input, init2) => {
6611
+ self2.fetch = (input, init) => {
6447
6612
  var _a2;
6448
6613
  const url = toURL(urlMaker, input);
6449
6614
  if (isSameDocumentOriginRequest(document2, url)) {
6450
- 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));
6451
6616
  }
6452
- return originalFetch(input, init2);
6617
+ return originalFetch(input, init);
6453
6618
  };
6454
6619
  };
6455
- function createComposerApplication(self2, channels) {
6620
+ const createComposerApplication = (self2, postChannel, channels) => {
6456
6621
  applyBodyStyle(self2.document);
6457
6622
  interceptCORSFetch(self2, channels.notification);
6458
6623
  const { cleanup: overlayDisplaySubscriptionCleanup } = appendOverlay(self2, channels.mode.asObservable());
@@ -6460,7 +6625,7 @@ function createComposerApplication(self2, channels) {
6460
6625
  const renderRoot = appendRenderRoot(self2.document);
6461
6626
  const frame = createLifecycle(self2);
6462
6627
  const { sandbox: sandboxedWindow, unpatch } = wrap(frame, channels.notification);
6463
- const updateSubscriptionsCleanup = run(sandboxedWindow, renderRoot, channels);
6628
+ const updateSubscriptionsCleanup = run(sandboxedWindow, renderRoot, postChannel, channels);
6464
6629
  return {
6465
6630
  cleanup: () => {
6466
6631
  updateSubscriptionsCleanup();
@@ -6470,87 +6635,41 @@ function createComposerApplication(self2, channels) {
6470
6635
  },
6471
6636
  sandboxedWindow
6472
6637
  };
6473
- }
6474
- function logger(type, ...args) {
6475
- {
6476
- const color = generateDarkColorHex();
6477
- const background = `${color}22`;
6478
- const style = { background, color };
6479
- console.groupCollapsed(`%c Preview ${this.location.href}`, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
6480
- console[type](...args);
6481
- console.groupEnd();
6482
- }
6483
- }
6484
- function logServiceWorkerStatus(registration) {
6485
- const log = logger.bind(this);
6486
- if (registration.installing) {
6487
- log("info", "Service worker installing");
6488
- } else if (registration.waiting) {
6489
- log("info", "Service worker installed");
6490
- } else if (registration.active) {
6491
- log("info", "Service worker active");
6492
- }
6493
- }
6494
- const registerServiceWorker = async (self2) => {
6495
- const { navigator: navigator2 } = self2;
6496
- if ("serviceWorker" in navigator2) {
6497
- navigator2.serviceWorker.register("./service-worker.js", { scope: "./" }).then((reg) => logServiceWorkerStatus.call(self2, reg)).catch((error2) => console.error(error2));
6498
- return navigator2.serviceWorker.ready.then((reg) => {
6499
- var _a2;
6500
- return (_a2 = reg.active) != null ? _a2 : Promise.reject(new TypeError("serviceWorker not active"));
6501
- });
6502
- }
6503
- logger.call(self2, "error", "serviceWorker is not available");
6504
- };
6505
- const init = async (self2) => {
6506
- postChannel.window = self2;
6507
- serviceWorkerChannel.window = self2;
6508
- return registerServiceWorker(self2);
6509
6638
  };
6510
- function registerSenders(chs, sw) {
6639
+ function registerParentWindowSenders(chs) {
6511
6640
  const subscription = new Subscription();
6512
- if (sw) {
6513
- subscription.add(
6514
- chs.setSourceMap.subscribe(
6515
- (next) => serviceWorkerChannel.send(sw, { content: next, type: "set-source-map" })
6516
- )
6517
- );
6518
- }
6519
6641
  subscription.add(
6520
- chs.updated.subscribe(() => {
6521
- postChannel.send(window.parent, {
6522
- content: {},
6523
- type: "updated"
6524
- });
6525
- })
6642
+ chs.updated.subscribe(() => this.send({
6643
+ content: {},
6644
+ type: "updated"
6645
+ }))
6526
6646
  );
6527
6647
  subscription.add(
6528
- chs.infos.subscribe(
6529
- (entries) => {
6530
- postChannel.send(window.parent, {
6531
- content: entries,
6532
- type: "tag-info"
6533
- });
6534
- }
6535
- )
6648
+ chs.infos.subscribe((entries) => this.send({
6649
+ content: entries,
6650
+ type: "tag-info"
6651
+ }))
6536
6652
  );
6537
6653
  subscription.add(
6538
- chs.notification.subscribe(
6539
- (content) => {
6540
- postChannel.send(window.parent, {
6541
- content,
6542
- type: "notification"
6543
- });
6544
- }
6545
- )
6654
+ chs.notification.subscribe((content) => this.send({
6655
+ content,
6656
+ type: "notification"
6657
+ }))
6546
6658
  );
6547
6659
  subscription.add(
6548
- chs.mode.subscribe(
6549
- (mode) => {
6550
- postChannel.send(window.parent, {
6551
- content: { mode },
6552
- type: "ctrl-space"
6553
- });
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);
6554
6673
  }
6555
6674
  )
6556
6675
  );
@@ -6572,40 +6691,35 @@ function registerCleanups(window2, fns) {
6572
6691
  });
6573
6692
  }
6574
6693
  (async (self2) => {
6575
- const sw = await init(self2);
6576
- let serviceWorkerChannelCleanup = noop;
6577
- const postChannelCleanup = postChannel.recv(self2, self2.top);
6578
- if (sw) {
6579
- const swCleanup = serviceWorkerChannel.recv();
6580
- const subscription = interval(100).subscribe(() => postChannel.send(self2.parent, { content: { status: "ready" }, type: "service-worker" }));
6581
- serviceWorkerChannelCleanup = () => {
6582
- swCleanup();
6583
- subscription.unsubscribe();
6584
- serviceWorkerChannel.send(sw, { content: {}, type: "unload-client" });
6585
- };
6586
- }
6587
- const senderCleanup = registerSenders(subjects, sw);
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);
6588
6699
  const listenerCleanup = registerEventListeners(
6589
6700
  self2,
6590
- { handler: ctrlSpaceFactory(subjects), type: "keydown" },
6591
- { handler: mouseEventFactory(self2, "mousemove"), type: "mousemove" },
6592
- { handler: mouseEventFactory(self2, "mousedown"), type: "mousedown" },
6593
- { 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" }
6594
6705
  );
6595
6706
  const {
6596
6707
  cleanup: composerApplicationCleanup,
6597
6708
  sandboxedWindow
6598
- } = createComposerApplication(self2, subjects);
6709
+ } = createComposerApplication(self2, parentWindowRegistration, channels);
6599
6710
  registerCleanups(
6600
6711
  sandboxedWindow,
6601
6712
  [
6602
6713
  composerApplicationCleanup,
6603
6714
  listenerCleanup,
6604
- senderCleanup,
6605
- serviceWorkerChannelCleanup,
6606
- postChannelCleanup
6715
+ parentWindowSenderCleanup,
6716
+ serviceWorkerSenderCleanup,
6717
+ () => parentWindowRegistration.disconnect(),
6718
+ () => swRegistration.send({ content: {}, type: "unload-client" }),
6719
+ () => swRegistration.disconnect()
6607
6720
  ]
6608
6721
  );
6609
- })(window).catch((error2) => {
6610
- throw error2;
6722
+ })(window).catch((err) => {
6723
+ console.error(`[preview] Error Boundary: ${String(err)}`);
6724
+ throw err;
6611
6725
  });