@wix/cli-app 1.1.96 → 1.1.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/build/{AddPermissionCommand-OSMYPJRQ.js → AddPermissionCommand-5WDEMAQT.js} +2 -2
  2. package/build/{CreateVersionCommand-2SHGYJBX.js → CreateVersionCommand-P5USV364.js} +3 -3
  3. package/build/{DevCommand-5JBBIYTN.js → DevCommand-IREOMDTX.js} +10 -10
  4. package/build/{GenerateCommand-XNXCRR5M.js → GenerateCommand-GE4M3AJ5.js} +7 -7
  5. package/build/{LogsCommand-IR3US32Z.js → LogsCommand-6YLQXT36.js} +3 -3
  6. package/build/PreviewCommand-K2K72XRF.js +19 -0
  7. package/build/ReleaseCommand-E2YTBK5B.js +23 -0
  8. package/build/{ServeCommand-25RAESBL.js → ServeCommand-DERBPIYF.js} +3 -3
  9. package/build/{build-WZPDIQUO.js → build-TKRTNJPW.js} +6 -6
  10. package/build/{chunk-D4GD3WIF.js → chunk-3DCNRTOG.js} +2 -2
  11. package/build/{chunk-P5TI5KKJ.js → chunk-6U232VOB.js} +27 -6
  12. package/build/{chunk-P5TI5KKJ.js.map → chunk-6U232VOB.js.map} +1 -1
  13. package/build/{chunk-UGSFGYTI.js → chunk-7TAGHLLP.js} +3 -3
  14. package/build/{chunk-UAA3DCJW.js → chunk-A3XZG5CV.js} +2 -2
  15. package/build/{chunk-Y3K3I3H6.js → chunk-FNPNJNSH.js} +6 -6
  16. package/build/{chunk-ZH2F3CQO.js → chunk-IN7IXPNO.js} +2 -2
  17. package/build/{chunk-K7MHL7B4.js → chunk-NIDWJY72.js} +2 -2
  18. package/build/{chunk-HZKLMNE6.js → chunk-OOHZARMV.js} +7 -7
  19. package/build/{chunk-XML6APOZ.js → chunk-QXIFG4RP.js} +31 -18
  20. package/build/{chunk-XML6APOZ.js.map → chunk-QXIFG4RP.js.map} +1 -1
  21. package/build/{chunk-TPHNWSDL.js → chunk-RMWMWFQH.js} +2 -2
  22. package/build/{chunk-BCCHS2DP.js → chunk-RYRMNBF7.js} +4 -4
  23. package/build/{chunk-DPNHTDEY.js → chunk-SONMTNBR.js} +2 -2
  24. package/build/{chunk-UMW4BAJ4.js → chunk-TQQIULI5.js} +2 -2
  25. package/build/{chunk-4U4CHXCF.js → chunk-VVQKEYFV.js} +20 -2
  26. package/build/{chunk-4U4CHXCF.js.map → chunk-VVQKEYFV.js.map} +1 -1
  27. package/build/{chunk-HDBHL76U.js → chunk-XQE6EJ45.js} +2 -2
  28. package/build/{chunk-HP5V6YH3.js → chunk-XR7UD5CN.js} +6 -6
  29. package/build/{chunk-JNAB66MG.js → chunk-Y7OW7ICG.js} +4 -4
  30. package/build/index.js +25 -25
  31. package/build/platform-sdk/editor.js +1 -1
  32. package/build/platform-sdk/editor.js.map +1 -1
  33. package/build/platform-sdk/site.js +1 -1
  34. package/build/platform-sdk/site.js.map +1 -1
  35. package/build/{preview-VLEJXGSK.js → preview-MJMZWFUW.js} +12 -12
  36. package/build/{release-ZTHOL4AK.js → release-LNE5ADW6.js} +14 -14
  37. package/build/{render-command-VVUDPRHR.js → render-command-3YMVNHZ2.js} +5 -5
  38. package/package.json +4 -4
  39. package/build/PreviewCommand-2O3ZZZY3.js +0 -19
  40. package/build/ReleaseCommand-X3OHX4QJ.js +0 -23
  41. /package/build/{AddPermissionCommand-OSMYPJRQ.js.map → AddPermissionCommand-5WDEMAQT.js.map} +0 -0
  42. /package/build/{CreateVersionCommand-2SHGYJBX.js.map → CreateVersionCommand-P5USV364.js.map} +0 -0
  43. /package/build/{DevCommand-5JBBIYTN.js.map → DevCommand-IREOMDTX.js.map} +0 -0
  44. /package/build/{GenerateCommand-XNXCRR5M.js.map → GenerateCommand-GE4M3AJ5.js.map} +0 -0
  45. /package/build/{LogsCommand-IR3US32Z.js.map → LogsCommand-6YLQXT36.js.map} +0 -0
  46. /package/build/{PreviewCommand-2O3ZZZY3.js.map → PreviewCommand-K2K72XRF.js.map} +0 -0
  47. /package/build/{ReleaseCommand-X3OHX4QJ.js.map → ReleaseCommand-E2YTBK5B.js.map} +0 -0
  48. /package/build/{ServeCommand-25RAESBL.js.map → ServeCommand-DERBPIYF.js.map} +0 -0
  49. /package/build/{build-WZPDIQUO.js.map → build-TKRTNJPW.js.map} +0 -0
  50. /package/build/{chunk-D4GD3WIF.js.map → chunk-3DCNRTOG.js.map} +0 -0
  51. /package/build/{chunk-UGSFGYTI.js.map → chunk-7TAGHLLP.js.map} +0 -0
  52. /package/build/{chunk-UAA3DCJW.js.map → chunk-A3XZG5CV.js.map} +0 -0
  53. /package/build/{chunk-Y3K3I3H6.js.map → chunk-FNPNJNSH.js.map} +0 -0
  54. /package/build/{chunk-ZH2F3CQO.js.map → chunk-IN7IXPNO.js.map} +0 -0
  55. /package/build/{chunk-K7MHL7B4.js.map → chunk-NIDWJY72.js.map} +0 -0
  56. /package/build/{chunk-HZKLMNE6.js.map → chunk-OOHZARMV.js.map} +0 -0
  57. /package/build/{chunk-TPHNWSDL.js.map → chunk-RMWMWFQH.js.map} +0 -0
  58. /package/build/{chunk-BCCHS2DP.js.map → chunk-RYRMNBF7.js.map} +0 -0
  59. /package/build/{chunk-DPNHTDEY.js.map → chunk-SONMTNBR.js.map} +0 -0
  60. /package/build/{chunk-UMW4BAJ4.js.map → chunk-TQQIULI5.js.map} +0 -0
  61. /package/build/{chunk-HDBHL76U.js.map → chunk-XQE6EJ45.js.map} +0 -0
  62. /package/build/{chunk-HP5V6YH3.js.map → chunk-XR7UD5CN.js.map} +0 -0
  63. /package/build/{chunk-JNAB66MG.js.map → chunk-Y7OW7ICG.js.map} +0 -0
  64. /package/build/{preview-VLEJXGSK.js.map → preview-MJMZWFUW.js.map} +0 -0
  65. /package/build/{release-ZTHOL4AK.js.map → release-LNE5ADW6.js.map} +0 -0
  66. /package/build/{render-command-VVUDPRHR.js.map → render-command-3YMVNHZ2.js.map} +0 -0
@@ -3,16 +3,16 @@ const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  PreviewCommand,
5
5
  assertBuildOutputExists
6
- } from "./chunk-Y3K3I3H6.js";
6
+ } from "./chunk-FNPNJNSH.js";
7
7
  import {
8
8
  useARMClient
9
- } from "./chunk-HZKLMNE6.js";
9
+ } from "./chunk-OOHZARMV.js";
10
10
  import {
11
11
  useWixCliAppBi
12
- } from "./chunk-HDBHL76U.js";
12
+ } from "./chunk-XQE6EJ45.js";
13
13
  import {
14
14
  useBackendComponents
15
- } from "./chunk-D4GD3WIF.js";
15
+ } from "./chunk-3DCNRTOG.js";
16
16
  import {
17
17
  Alert,
18
18
  Box_default,
@@ -38,7 +38,7 @@ import {
38
38
  useDevCenterClient,
39
39
  useProjectModel,
40
40
  useTranslation
41
- } from "./chunk-P5TI5KKJ.js";
41
+ } from "./chunk-6U232VOB.js";
42
42
  import {
43
43
  __toESM,
44
44
  init_esm_shims
@@ -423,4 +423,4 @@ export {
423
423
  ReleaseVersionType,
424
424
  ReleaseCommand
425
425
  };
426
- //# sourceMappingURL=chunk-HP5V6YH3.js.map
426
+ //# sourceMappingURL=chunk-XR7UD5CN.js.map
@@ -3,13 +3,13 @@ const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  addUserFields,
5
5
  reportCommandStartEvent
6
- } from "./chunk-K7MHL7B4.js";
6
+ } from "./chunk-NIDWJY72.js";
7
7
  import {
8
8
  messages_default
9
9
  } from "./chunk-LXXN3RII.js";
10
10
  import {
11
11
  DebugLogProvider
12
- } from "./chunk-UAA3DCJW.js";
12
+ } from "./chunk-A3XZG5CV.js";
13
13
  import {
14
14
  AccountAuthProvider,
15
15
  BiProvider,
@@ -23,7 +23,7 @@ import {
23
23
  package_default,
24
24
  render,
25
25
  require_react
26
- } from "./chunk-P5TI5KKJ.js";
26
+ } from "./chunk-6U232VOB.js";
27
27
  import {
28
28
  __toESM,
29
29
  init_esm_shims
@@ -113,4 +113,4 @@ export {
113
113
  renderCommand,
114
114
  runCommand
115
115
  };
116
- //# sourceMappingURL=chunk-JNAB66MG.js.map
116
+ //# sourceMappingURL=chunk-Y7OW7ICG.js.map
package/build/index.js CHANGED
@@ -2,18 +2,18 @@ import { createRequire as _createRequire } from 'node:module';
2
2
  const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  createI18nT
5
- } from "./chunk-ZH2F3CQO.js";
5
+ } from "./chunk-IN7IXPNO.js";
6
6
  import {
7
7
  runCommand
8
- } from "./chunk-JNAB66MG.js";
9
- import "./chunk-K7MHL7B4.js";
8
+ } from "./chunk-Y7OW7ICG.js";
9
+ import "./chunk-NIDWJY72.js";
10
10
  import "./chunk-LXXN3RII.js";
11
- import "./chunk-UAA3DCJW.js";
11
+ import "./chunk-A3XZG5CV.js";
12
12
  import {
13
13
  package_default,
14
14
  require_react,
15
15
  z
16
- } from "./chunk-P5TI5KKJ.js";
16
+ } from "./chunk-6U232VOB.js";
17
17
  import {
18
18
  __commonJS,
19
19
  __require,
@@ -3376,8 +3376,8 @@ var {
3376
3376
  // src/commands/build.ts
3377
3377
  init_esm_shims();
3378
3378
  var buildCommand = (services) => createCommand("build").action(async (_, command) => {
3379
- const { runCommand: runCommand2 } = await import("./render-command-VVUDPRHR.js");
3380
- const { build } = await import("./build-WZPDIQUO.js");
3379
+ const { runCommand: runCommand2 } = await import("./render-command-3YMVNHZ2.js");
3380
+ const { build } = await import("./build-TKRTNJPW.js");
3381
3381
  await runCommand2(command, services, build);
3382
3382
  });
3383
3383
 
@@ -3387,8 +3387,8 @@ var import_react = __toESM(require_react(), 1);
3387
3387
  var devCommand = (services) => {
3388
3388
  const t = createI18nT();
3389
3389
  return createCommand("dev").option("-s, --https", t("dev_command_def.option.https")).action(async (options, command) => {
3390
- const { DevCommand } = await import("./DevCommand-5JBBIYTN.js");
3391
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3390
+ const { DevCommand } = await import("./DevCommand-IREOMDTX.js");
3391
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3392
3392
  const { https = false } = options;
3393
3393
  await renderCommand(command, services, /* @__PURE__ */ import_react.default.createElement(DevCommand, { https }), {
3394
3394
  watchForModelChanges: true
@@ -3457,17 +3457,17 @@ var previewCommand = (services) => {
3457
3457
  ).hideHelp()
3458
3458
  ).action(async (options, command) => {
3459
3459
  const { site, baseUrl, json } = options;
3460
- const { renderCommand, runCommand: runCommand2 } = await import("./render-command-VVUDPRHR.js");
3460
+ const { renderCommand, runCommand: runCommand2 } = await import("./render-command-3YMVNHZ2.js");
3461
3461
  if (json) {
3462
3462
  return runCommand2(command, services, async (model) => {
3463
- const { nonInteractivePreview } = await import("./preview-VLEJXGSK.js");
3463
+ const { nonInteractivePreview } = await import("./preview-MJMZWFUW.js");
3464
3464
  return nonInteractivePreview(services, model, {
3465
3465
  baseUrl,
3466
3466
  siteId: site
3467
3467
  });
3468
3468
  });
3469
3469
  }
3470
- const { PreviewCommand } = await import("./PreviewCommand-2O3ZZZY3.js");
3470
+ const { PreviewCommand } = await import("./PreviewCommand-K2K72XRF.js");
3471
3471
  await renderCommand(
3472
3472
  command,
3473
3473
  services,
@@ -3498,8 +3498,8 @@ var createVersionCommand = (services) => {
3498
3498
  t("create_version_command_def.option.base_url"),
3499
3499
  validateBase
3500
3500
  ).action(async (options, command) => {
3501
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3502
- const { CreateVersionCommandDeprecated } = await import("./CreateVersionCommand-2SHGYJBX.js");
3501
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3502
+ const { CreateVersionCommandDeprecated } = await import("./CreateVersionCommand-P5USV364.js");
3503
3503
  await renderCommand(
3504
3504
  command,
3505
3505
  services,
@@ -3516,8 +3516,8 @@ var addPermissionCommand = (services) => {
3516
3516
  return createCommand("add-permission").description("adding a permission to the app").addOption(
3517
3517
  new Option("-p, --permission-id <id>", t("the permission id to add"))
3518
3518
  ).action(async (options, command) => {
3519
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3520
- const { AddPermissionCommand } = await import("./AddPermissionCommand-OSMYPJRQ.js");
3519
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3520
+ const { AddPermissionCommand } = await import("./AddPermissionCommand-5WDEMAQT.js");
3521
3521
  const { permissionId = "" } = options;
3522
3522
  await renderCommand(
3523
3523
  command,
@@ -3533,8 +3533,8 @@ var import_react5 = __toESM(require_react(), 1);
3533
3533
  var serveCommand = (services) => {
3534
3534
  const t = createI18nT();
3535
3535
  return createCommand("serve").description(t("serve_command_def.description")).action(async (_, command) => {
3536
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3537
- const { ServeCommandDeprecated } = await import("./ServeCommand-25RAESBL.js");
3536
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3537
+ const { ServeCommandDeprecated } = await import("./ServeCommand-DERBPIYF.js");
3538
3538
  await renderCommand(command, services, /* @__PURE__ */ import_react5.default.createElement(ServeCommandDeprecated, null));
3539
3539
  });
3540
3540
  };
@@ -3545,8 +3545,8 @@ var import_react6 = __toESM(require_react(), 1);
3545
3545
  var generateCommand = (services) => {
3546
3546
  const t = createI18nT();
3547
3547
  return createCommand("generate").description(t("generate_command.description")).action(async (options, command) => {
3548
- const { GenerateCommand } = await import("./GenerateCommand-XNXCRR5M.js");
3549
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3548
+ const { GenerateCommand } = await import("./GenerateCommand-GE4M3AJ5.js");
3549
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3550
3550
  await renderCommand(command, services, /* @__PURE__ */ import_react6.default.createElement(GenerateCommand, null), {
3551
3551
  skipProjectValidation: true
3552
3552
  });
@@ -3564,8 +3564,8 @@ var logsCommand = (services) => {
3564
3564
  validateVersion
3565
3565
  ).action(async (options, command) => {
3566
3566
  const { version } = options;
3567
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3568
- const { LogsCommand } = await import("./LogsCommand-IR3US32Z.js");
3567
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3568
+ const { LogsCommand } = await import("./LogsCommand-6YLQXT36.js");
3569
3569
  await renderCommand(command, services, /* @__PURE__ */ import_react7.default.createElement(LogsCommand, { version }));
3570
3570
  });
3571
3571
  };
@@ -3598,8 +3598,8 @@ var releaseCommand = (services) => {
3598
3598
  t("app_preview_command_def.option.json")
3599
3599
  ).hideHelp()
3600
3600
  ).action(async (options, command) => {
3601
- const { renderCommand } = await import("./render-command-VVUDPRHR.js");
3602
- const { ReleaseCommand, ReleaseVersionType } = await import("./ReleaseCommand-X3OHX4QJ.js");
3601
+ const { renderCommand } = await import("./render-command-3YMVNHZ2.js");
3602
+ const { ReleaseCommand, ReleaseVersionType } = await import("./ReleaseCommand-E2YTBK5B.js");
3603
3603
  const { baseUrl, site, comment, json } = options;
3604
3604
  const versionType = options.versionType ? {
3605
3605
  major: ReleaseVersionType.MAJOR,
@@ -3613,7 +3613,7 @@ var releaseCommand = (services) => {
3613
3613
  };
3614
3614
  if (json) {
3615
3615
  return runCommand(command, services, async (model) => {
3616
- const { nonInteractiveRelease } = await import("./release-ZTHOL4AK.js");
3616
+ const { nonInteractiveRelease } = await import("./release-LNE5ADW6.js");
3617
3617
  return nonInteractiveRelease(services, model, props);
3618
3618
  });
3619
3619
  }
@@ -4,5 +4,5 @@ import{a as Ee,b as be}from"./chunk-J7RIIVO6.js";import{a as ve}from"./chunk-ZBG
4
4
  `),i=this.messages.reduce((c,l)=>(c.push(` - ${l.join(" ")}`),c),[]).join(`
5
5
  `),s=this.parentError,r=s?["",s.getMessage(),""].join(`
6
6
  `):"",o=this.errorMessage?`${this.displayName}: ${this.errorMessage}`:this.displayName;return[r,o,e,i].filter(c=>c.trim().length).join(`
7
- `)}getBreadcrumbs(){let e=this.parentError;return e?[...e.getBreadcrumbs(),this.displayName]:[this.displayName]}withParentError(e){return this.parent=e,this}withMessage(...e){return this.messages.push(e),this}};function E(n){return function t(e,i=""){let s=new n(i,e);return Error.captureStackTrace&&Error.captureStackTrace(s,t),s}}var jt=class extends I{constructor(e,i){super(e,i,"Editor Platform Internal Error");p(this,"state",{})}withHost(e){return this.state={...this.state,host:e},this}},on=E(jt);var $=(n=>(n.IncorrectEnvironment="IncorrectEnvironment",n))($||{}),$t=class extends I{constructor(e,i){super(e,i,"EP Context Error");p(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},J=E($t);async function an(n,t){if(!n?.type)return n;switch(n.type){case"componentSelectionChanged":let e=n.componentRefs||[],i=await Promise.all(e.map(s=>t.components.getComponent(s)));return{type:n.type,components:i};default:return n}}var Wt=class{constructor(t,e,i){p(this,"events");p(this,"subscribe");p(this,"commit");p(this,"startTransaction");p(this,"silent");this.appDefinitionId=t,this.privateAPI=i,this.events=e,this.subscribe=e.subscribe.bind(e),this.commit=e.commit.bind(e),this.startTransaction=e.startTransaction.bind(e),this.silent=e.silent.bind(e)}notify(t){this.events.notify({type:t.type,payload:t.payload,meta:{appDefinitionId:this.appDefinitionId}})}notifyCustomEvent(t,e){this.notify({type:v.CustomEvent,payload:{...e,type:t}})}addEventListener(t,e){return this.events.subscribe(async i=>{let s=i.meta?.appDefinitionId===this.appDefinitionId||i.meta?.appDefinitionId===null,r=()=>an(i.payload,this.privateAPI);t==="*"?e(await r()):i.type===v.CustomEvent?t===i.payload?.type&&!s&&e(await r()):i.type===v.HostEvent&&t===i.payload?.type&&s&&e(await r())})}},cn=200,pn=50,O,qt,Re,ut=class{constructor(t){h(this,O);p(this,"injectionUUID");p(this,"injectionUUID_Deprecated");this.injectionUUID_Deprecated=`__${t}_CONTEXT_INJECTION_STATUS_KEY`,this.injectionUUID=`__${t}_CONTEXT_INJECTION_STATUS_KEY#0.1`,u(this,O,qt).call(this)||u(this,O,Re).call(this)}resolveInjected(){globalThis[this.injectionUUID]?.resolve()}waitInjected(){return new Promise((t,e)=>{let i=!1,s,r=0,o=()=>{i||(s=setTimeout(()=>{if(r++,r<pn){r%10===0&&console.log(J($.IncorrectEnvironment,"contexts are not resolved, still re-trying").withMessage(`try number ${r}`).message),o();return}if(!i){let c=J($.IncorrectEnvironment,"contexts are not resolved, threw by timeout");e(c)}},cn))};o(),u(this,O,qt).call(this)?.then(()=>{i=!0,clearTimeout(s),t()})})}};O=new WeakSet,qt=function(){return globalThis[this.injectionUUID]?.promise},Re=function(){let t,e=new Promise(i=>{t=i});globalThis[this.injectionUUID]={promise:e,resolve:t},globalThis[this.injectionUUID_Deprecated]=new Promise(i=>{e.then(i)})};var Ft="__ENVIRONMENT_CONTEXT_KEY",Pt=(n=>(n.Worker="Worker",n.Frame="Frame",n.ComponentPanel="ComponentPanel",n))(Pt||{}),dt=class dt{constructor(t){this.environmentContext=t}static async inject(t){if(globalThis[Ft])throw J($.IncorrectEnvironment,"Environment context already exists and should not be overridden");globalThis[Ft]=new dt(t),this.status.resolveInjected()}static async getInstance(){return await this.status.waitInjected(),globalThis[Ft]}getPrivateAPI(){return this.environmentContext.privateApi}getEvents(){return this.environmentContext.events}getApplicationAPIs(){return this.environmentContext.applicationAPIs??{}}getEnvironment(){return this.environmentContext.environment}};p(dt,"status",new ut("environment"));var N=dt,Y="__APPLICATION_CONTEXT_KEY",ft=class ft{constructor(t,e){p(this,"events");this.context=t,this.environment=e,this.events=new Wt(t.appDefinitionId?t.appDefinitionId:null,this.environment.getEvents(),this.environment.getPrivateAPI())}static async inject(t){if(globalThis[Y])throw J($.IncorrectEnvironment,"Application context already exists and should not be overridden");globalThis[Y]=new ft(t,await N.getInstance()),this.status.resolveInjected()}static async getInstance(){return typeof __APPLICATION_CONTEXT_KEY<"u"?__APPLICATION_CONTEXT_KEY:(await this.status.waitInjected(),globalThis[Y])}getContext(){return this.context}getAppDefinitionId(){return this.context.appDefinitionId}getManifestContextId(){return this.context.manifestContextId}getEvents(){return this.events}getEnvironmentContext(){return this.environment}getPrivateAPI(){return this.environment.getPrivateAPI()}getPrivateApplicationAPI(){let t=this.getAppDefinitionId();if(!t)throw J($.IncorrectEnvironment,"appDefinitionId is not available");return this.environment.getApplicationAPIs()[t]}};p(ft,"status",new ut("application"));var y=ft;var Ke=we(Ot());var tt=n=>`"editor-platform-transport": ${n}`,De=n=>tt(`[Internal Error] ${n}`),Se="\u0192",Ne="\u2202",Oe="_get_",ke="_set_",gt="+",Me="-",Ht="\xB7",Xt="\xD7",Qt="\xB0",Le=n=>n[0]===Xt?"":n,_e=n=>n===null||typeof n>"u"||typeof n=="symbol"||typeof n=="number"||typeof n=="boolean"||typeof n=="function"||typeof n=="string",ln=n=>!!n&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof Set)&&!(n instanceof Map),hn=n=>W(n.split(Ht)),W=n=>n.map(Le).filter(Boolean).join(".");function Ct(n,t){return{marker:n,...t}}var un=Ct("A",{shouldUse:n=>Array.isArray(n),serialize:(n,t)=>{n.length?n.forEach((e,i)=>{t(`${i}`,e)}):t("",Qt)},deserialize:{create:()=>[],has:(n,t)=>!(typeof n[t]>"u"),append:(n,t,e)=>{n.push(e)}}}),dn=Ct("M",{shouldUse:n=>n instanceof Map,serialize:(n,t)=>{n.forEach((e,i)=>{t(i,e)})},deserialize:{create:()=>new Map,has:(n,t)=>n.has(t),append:(n,t,e)=>{n.set(t,e)}}}),fn=Ct("S",{shouldUse:n=>n instanceof Set,serialize:(n,t)=>{let e=0;n.forEach(i=>{t(`${e++}`,i)})},deserialize:{create:()=>new Set,has:(n,t)=>n.has(t),append:(n,t,e)=>{n.add(e)}}}),zt=Ct("O",{shouldUse:n=>typeof n=="object",serialize:(n,t)=>{let e=i=>{let r=Reflect.ownKeys(i).filter(c=>c!=="constructor").filter(c=>typeof c!="symbol");r.length?r.filter(c=>c!=="constructor").filter(c=>typeof c!="symbol").forEach(c=>{let l=Reflect.get(n,c);t(c,l)}):t("",Qt);let o=Reflect.getPrototypeOf(i);!o||o?.hasOwnProperty("__proto__")||e(o)};e(n)},deserialize:{create:()=>({}),has:(n,t)=>!!n[t],append:(n,t,e)=>{n[t]=e}}}),Ue=[un,fn,dn];function Pn(n,t){let e=n;for(;e;){let i=Object.getOwnPropertyDescriptor(e,t);if(i)return i;e=Reflect.getPrototypeOf(e)}return null}function gn(n,t){let e=new WeakMap,i=r=>{let o=r.slice(1).map(Le).filter(Boolean);return o.slice(1).reduce((c,l)=>({context:c.context[c.pointer],pointer:l}),{context:n,pointer:o[0]})},s=(r,o=[])=>{if(e.has(r)&&e.get(r)?.some(d=>o.join(".").startsWith(d))){t(o,{...i(o),value:"[Circular]"});return}if(r&&!_e(r)&&(e.has(r)&&e.set(r,[]),e.set(r,[...e.get(r)??[],o.join(".")])),_e(r)){t(o,{...i(o),value:r});return}let c=Ue.find(l=>l.shouldUse(r))??zt;if(c){c.serialize(r,(l,d)=>{s(d,[...o,`${Xt}${c.marker}`,l])});return}};return s(n)}var mn=(n,t)=>{if(!ln(n))throw new Error(tt("only objects are serializable at the root level"));let e={data:[]},i=(r,o)=>{e.data.push([r,o])},s=(r,o)=>{t(hn(r),(...c)=>o.context[o.pointer](...c)),i(r,Se)};return gn(n,(r,{value:o,context:c,pointer:l})=>{let d=r.slice(1).join(Ht),f=Pn(c,l);if(f?.get||f?.set){f?.get&&t(W([...r,Oe]),()=>c[l]),f?.set&&t(W([...r,ke]),V=>{c[l]=V});let D=[f?.get?gt:Me,f?.set?gt:Me];i(d,`${Ne}${D.join("")}`)}else typeof o=="function"?s(d,{context:c,pointer:l}):i(d,o)}),e},An=(n,t)=>typeof n!="object"||n===null?n:n.data.reduce((e,[i,s])=>{let r=e,o=i.split(Ht),c=zt,l=null;for(let d=0;d<o.length;d++){let f=o[d];if(f[0]===Xt){let D=c.deserialize.has(r,l);if(c=[zt,...Ue].find(V=>V.marker===f[1]),!c)throw new Error(tt(`unknown marker "${f[1]}"`));D||(r[l]=c.deserialize.create()),r=r[l]}else l=f}if(s?.toString()===Qt)return e;if(s?.toString()===Se)c.deserialize.append(r,l,t(W(o)));else if(s?.toString()[0]===Ne){let d=s?.toString()[1]===gt,f=s?.toString()[2]===gt,D={};if(d){let V=t(W([...o,Oe]));D.get=()=>V()}f&&(D.set=t(W([...o,ke]))),Object.defineProperty(r,l,D)}else c.deserialize.append(r,l,s);return e},{[Symbol("transferred object")]:`${(JSON.stringify(n.data).length/1024).toFixed(2)}Kb`});function je(){let n=globalThis.performance;if(n&&n.now)return n.now();let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e.length,s=0,r=10;for(;s<r;)t+=e.charAt(Math.floor(Math.random()*i)),s+=1;return t}var X=(n=>(n.ExposeAPI="ExposeAPI",n.Call="Call",n.Response="Response",n.Cleanup="Cleanup",n))(X||{}),R=class n{constructor(t,e){p(this,"correlationId",`M-${je()}`);p(this,"parentCorrelationId");this.type=t,this.payload=e}withParentCorrelationId(t){return this.parentCorrelationId=t,this}serialize(t){return JSON.stringify({parentCorrelationId:this.parentCorrelationId,correlationId:this.correlationId,type:this.type,payload:mn(this.payload,(e,i)=>{t(this.correlationId,e,i)})})}static fromEvent(t,e){let i=JSON.parse(t);return new n(i.type,An(i.payload,s=>e(i.correlationId,s))).withParentCorrelationId(i.correlationId)}},Bt=class extends R{constructor(t){super("Cleanup",t)}},Vt=class extends R{constructor(t){super("Response",t)}},mt=class extends R{constructor(t){super("Response",t)}},Gt=class extends R{constructor(t){super("Call",t)}},Kt=(n,t)=>`${n}_${t}`,Et,bt,q,x,Yt=class{constructor(t){h(this,Et,new FinalizationRegistry(t=>{this.postMessage(new Bt(t))}));h(this,bt,{[X.Cleanup]:t=>{let e=t.payload.functionMarkerKey,i=t.payload.callId;delete a(this,q)[e],i&&delete a(this,x)[i]},[X.Response]:async t=>{let e=t.payload.callId,i=t.payload.errorMessage;if(i)if(t.payload.errorStack){let r=new Error(i);r.stack=t.payload.errorStack,a(this,x)[e]?.reject(r)}else a(this,x)[e]?.reject(i);else{let s=t.payload.response;a(this,x)[e]?.resolve(s)}delete a(this,x)[e]},[X.Call]:async t=>{let e=t.payload.functionMarkerKey,i=a(this,q)[e];if(!i){this.postMessage(new mt({callId:t.payload.callId,errorMessage:tt("function is not available")}));return}try{let s=await i.value(...t.payload.props??[]);this.postMessage(new Vt({callId:t.payload.callId,response:s}))}catch(s){this.postMessage(new mt({callId:t.payload.callId,errorMessage:s.message,errorStack:s.stack}))}}});h(this,q,{});h(this,x,{});p(this,"queue",[]);this.port=t,this.port.onmessage=e=>{this.onMessage(e)}}onMessage(t){let e=R.fromEvent(t.data,(i,s)=>{let r=this.replaceTransferredFunction(i,s);return a(this,Et).register(r,{functionMarkerKey:Kt(i,s)}),r});a(this,bt)[e.type]?.(e),this.messageEvents[e.type]?.(e)}postMessage(t){this.port.postMessage(t.serialize(this.registerTransferredFunction.bind(this)))}registerTransferredFunction(t,e,i){let s=Kt(t,e);a(this,q)[s]={path:e,value:i}}replaceTransferredFunction(t,e){return(...i)=>{let s=`CALL-${crypto.randomUUID()}`;return this.postMessage(new Gt({callId:s,functionMarkerKey:Kt(t,e),props:i})),new Promise((r,o)=>{a(this,x)[s]={resolve:r,reject:o}})}}flush(){this.queue.forEach(t=>{this.postMessage(t)}),this.queue=[]}};Et=new WeakMap,bt=new WeakMap,q=new WeakMap,x=new WeakMap;var At=class extends Yt{constructor(){super(...arguments);p(this,"messageEvents",{})}expose(e){if(!e.type)throw new Error(tt('wrong exposed API instance, "type" property is required'));this.queue.push(new R(X.ExposeAPI,e)),this.flush()}};var H=(n=>(n.Ping="EDITOR_PLATFORM_TRANSPORT_EVENT:__Ping",n.RequestPort="EDITOR_PLATFORM_TRANSPORT_EVENT:__RequestPort",n.Pong="EDITOR_PLATFORM_TRANSPORT_EVENT:__Pong",n.Port="EDITOR_PLATFORM_TRANSPORT_EVENT:__Port",n))(H||{});var K,T,xt,Fe,Jt=class{constructor(t,e){h(this,xt);h(this,K,new Set);h(this,T);this.postMessage=t,this.onMessage=e}setActivePort(t){this.dispose(),w(this,T,t),u(this,xt,Fe).call(this)}dispose(){a(this,T)&&(a(this,T).close(),a(this,T).onmessage=null)}onHandshake(t){return a(this,K).add(t),()=>{a(this,K).delete(t)}}};K=new WeakMap,T=new WeakMap,xt=new WeakSet,Fe=function(){let t=a(this,T);if(!t){console.warn(De("port is required no notify onHandshake listeners"));return}a(this,K).forEach(e=>e(t))};var Q,Z,M,$e,We,qe,It=class extends Jt{constructor(e,i){super(e,i);h(this,M);h(this,Q,!1);h(this,Z,`consumer-${je()}`);u(this,M,$e).call(this);let s={type:H.Ping};e(JSON.stringify(s))}};Q=new WeakMap,Z=new WeakMap,M=new WeakSet,$e=function(){this.onMessage(e=>{try{let i=JSON.parse(e.data);switch(i.type){case H.Pong:{u(this,M,We).call(this);break}case H.Port:{u(this,M,qe).call(this,i.targetMemberId,e.ports?.[0]);break}}}catch{}})},We=function(){if(a(this,Q))return;w(this,Q,!0);let e={type:H.RequestPort,memberId:a(this,Z)};this.postMessage(JSON.stringify(e))},qe=function(e,i){if(e===a(this,Z)){if(!i)throw new Error(De("no port at consumer handshake"));this.setActivePort(i)}};var yt=class{get onConnect(){return this.handshake.onHandshake.bind(this.handshake)}},wt=class n extends yt{constructor(){super(...arguments);p(this,"handshake",new It(e=>{globalThis.parent.postMessage(e,"*")},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new n().onConnect(s=>{new At(s).expose(e)})}};var vt=class n extends yt{constructor(){super(...arguments);p(this,"handshake",new It(e=>{globalThis.postMessage(e)},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new n().onConnect(s=>{new At(s).expose(e)})}};var Tt=class{constructor(t){this.platformAppEvents=t}notify(t){switch(t.type){case Ut.EditorReady:this.platformAppEvents.notify({...t,type:v.EditorReady});break;case ht.HostEvent:this.platformAppEvents.notify({...t,type:v.HostEvent});break}}subscribe(t){this.platformAppEvents.subscribe(e=>{t(e)})}},re=(n=>(n.Frame="PLATFORM_FRAME_API",n.Worker="PLATFORM_WORKER_API",n))(re||{}),Rt=class{constructor(t,e){this.type=t,this.envType=e}async injectEnvironmentContext({events:t,privateApi:e}){await N.inject({environment:this.envType,events:t,privateApi:e,applicationAPIs:{}})}async injectApplicationContext(t){await y.inject(t)}},In={classic:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css",studio:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css"},et,nt,_t,it,Dt,ze,te=class extends Rt{constructor(){super(re.Frame,Pt.Frame);h(this,Dt);h(this,et,new b);h(this,nt,new Tt(a(this,et)));h(this,_t);h(this,it);u(this,Dt,ze).call(this)}async initEnvironment(e){let{applicationPrivateAPI:i,privateAPI:s,context:r}=e,o=e.context?.appDefinitionId??e.appDefinitionId,c=e.context?e.context:{appDefinitionId:o};w(this,it,i),w(this,_t,s),await this.injectEnvironmentContext({privateApi:s,events:a(this,et),applicationAPIs:o?{[o]:a(this,it)}:{}}),await this.injectApplicationContext(c)}notify(e){a(this,nt).notify(e)}subscribe(e){a(this,nt).subscribe(e)}};et=new WeakMap,nt=new WeakMap,_t=new WeakMap,it=new WeakMap,Dt=new WeakSet,ze=function(){if(typeof globalThis?.document?.head?.prepend=="function"){let i=new URL(globalThis.location.href).searchParams.get("editorType")==="CLASSIC"?"classic":"studio",s=In[i],r=s&&!!document.querySelectorAll(`link[type="text/css"][href="${s}"]`)?.length;if(s&&!r){let o=document.createElement("link");o.setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href",s),globalThis.document.head.prepend(o)}}};var _=(n=>(n.ApplicationLoadError="ApplicationLoadError",n.ApplicationFetchError="ApplicationFetchError",n.ApplicationExecuteError="ApplicationExecuteError",n))(_||{}),ee=class extends I{constructor(e,i){super(e,i,"EP Application Container Error");p(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}withApiMethod(e){return this.state={...this.state,apiMethod:e},this}withApiType(e){return this.state={...this.state,apiType:e},this}},k=E(ee),yn="__APPLICATION_REGISTRY_KEY";async function wn(n,t,e){let i=new Function(Y,yn,e),s,r=o=>{if(s)throw k(_.ApplicationExecuteError,"Application registry called more than once").withAppDefinitionId(t.appDefinitionId);if(o.type!==t.type)throw k(_.ApplicationExecuteError,"Application has different type").withMessage("expected type",t.type).withMessage("received type",o.type);s=o};try{let o={...t};i.call(null,new y(o,await N.getInstance()),r)}catch(o){throw k(_.ApplicationExecuteError,o.message).withAppDefinitionId(t.appDefinitionId).withParentError(o)}return new Promise((o,c)=>{let l=n.subscribe(d=>{let f=setTimeout(()=>{clearTimeout(f),l(),s||c(k(_.ApplicationExecuteError,"Application registry was not called, threw by timeout").withAppDefinitionId(t.appDefinitionId))},5e3);d.type===v.ApplicationInit&&d.meta.appDefinitionId===t.appDefinitionId&&(clearTimeout(f),l(),s||c(k(_.ApplicationExecuteError,"Application registry was not called").withAppDefinitionId(t.appDefinitionId)),o({instance:s}))})})}var L,st,P,ne=class{constructor(t,e){h(this,L,{});h(this,st);h(this,P);w(this,st,t),w(this,P,e),a(this,P).subscribe(i=>{switch(i.type){case v.HostEvent:{i.payload.type===Ke.EventType.removeAppCompleted&&a(this,P).withEvent(a(this,P).factories.createApplicationRemovedEvent(i.payload.appDefinitionId),()=>this.removeApplication(i.payload.appDefinitionId));break}}})}async runApplication(t){let e=await this.loadApplication(t),i=await this.executeApplication(t,e);return this.setApplication(t.appDefinitionId,i),i}setApplication(t,e){a(this,L)[t]=e,a(this,P).withEvent(a(this,P).factories.createApplicationApiInitEvent(t,e?.api?.private?"private":"public"),()=>{a(this,st).applicationManager.setApplication(e)})}getApplication(t){return a(this,L)[t]}getAppDefinitionIds(){return Object.keys(a(this,L))}removeApplication(t){delete a(this,L)[t]}async loadApplication(t){let e=t.url;return a(this,P).withEvent(a(this,P).factories.createApplicationLoadEvent(t,e),async()=>{try{return await this.loadApplicationBundle(e)}catch(i){throw k(_.ApplicationLoadError).withUrl(e).withAppDefinitionId(t.appDefinitionId).withParentError(i)}})}async loadApplicationBundle(t){let e=await fetch(t,{method:"GET"});if(!(e.status>=200&&e.status<=299))throw k(_.ApplicationFetchError).withUrl(t);return e.text()}async executeApplication(t,e){return a(this,P).withEvent(a(this,P).factories.createApplicationExecuteEvent(t,t.url),async()=>{let{instance:i}=await wn(a(this,P),t,e);return i})}};L=new WeakMap,st=new WeakMap,P=new WeakMap;var z,rt,ot,U,at,ie=class extends Rt{constructor(){super(re.Worker,Pt.Worker);h(this,z,new b);h(this,rt,new Tt(a(this,z)));h(this,ot,null);h(this,U);h(this,at,[])}create(){}async initEnvironment(e){let{buildPrivateAPI:i}=e;w(this,U,await i({type:"EDITOR_ADDON"})),await this.injectEnvironmentContext({events:a(this,z),privateApi:a(this,U),applicationAPIs:{}}),w(this,ot,new ne(a(this,U),a(this,z))),a(this,at).forEach(s=>s(this))}async notify(e){await this.waitReady(),a(this,rt).notify(e)}subscribe(e){a(this,rt).subscribe(e)}async runApplication(e){await this.waitReady(),await a(this,ot).runApplication(e)}waitReady(){return new Promise(e=>{if(a(this,U))return e(this);a(this,at).push(e)})}};z=new WeakMap,rt=new WeakMap,ot=new WeakMap,U=new WeakMap,at=new WeakMap;var Zt="$_EP_TRANSPORT_ENV_CONTEXT_GUARD",B,Be,Ve,Mt=class{constructor(){h(this,B)}isEnvironmentApiExposed(){return!!globalThis[Zt]}async getContexts(){let[t,e]=await Promise.all([N.getInstance(),y.getInstance()]);return{environmentContext:t,applicationContext:e}}expose(){if(this.isEnvironmentApiExposed())return;let t=typeof importScripts=="function",e=globalThis.self&&globalThis.top&&globalThis.self!==globalThis.top;t?(u(this,B,Be).call(this),globalThis[Zt]=!0):e&&(u(this,B,Ve).call(this),globalThis[Zt]=!0)}};B=new WeakSet,Be=function(){vt.exposeAPI(new ie)},Ve=function(){wt.exposeAPI(new te)};var se=class extends I{constructor(e,i){super(e,i,"EP EnvironmentAPI Error");p(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Qn=E(se);new Mt().expose();var oe=class extends I{constructor(e,i){super(e,i,"Auth Strategy Error");p(this,"state",{})}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Ge=E(oe);function vn(n,t){let e=Date.now(),i=n?new Date(n).getTime():null;return i&&i-e>t}var En=30*60*1e3,bn=()=>{let n;return{getAuthHeaders:async()=>{let t=await y.getInstance(),e=t.getAppDefinitionId(),i=t.getPrivateAPI();if(!e)throw Ge("EmptyAppDefinitionId");return(!n||vn(n.expires,En))&&(n=await i.auth.getAccessToken(e,await i.info.getMetaSiteId())),n?.token?{headers:{Authorization:n.token}}:(console.error(Ge("EmptyAppAuthInstance").withAppDefinitionId(e)),{headers:{Authorization:""}})}}},g=class n{constructor(t,e=[]){this.ShapeConstructor=t,this.selectedMethods=e}withPublicMethod(t){return new n(this.ShapeConstructor,[...this.selectedMethods,t])}build(){if(!this.selectedMethods.length)throw new Error("methods are not defined for the SDK shape");let t=this.selectedMethods.reduce((e,i)=>({...e,[i]:s=>{let r=new this.ShapeConstructor(s?.applicationContext);return r[i]?r[i].bind(r):()=>{console.error(`"${i}" is not defined in the SDK shape`)}}}),{});return Ee(t)}},ae=class extends I{constructor(t,e){super(t,e,"Base SDK Error")}},xn=E(ae),m=class{constructor(t=null){this.overriddenApplicationContext=t}getApplicationContext(){return this.overriddenApplicationContext?this.overriddenApplicationContext:y.getInstance()}async getAppDefinitionId(){return(await this.getApplicationContext()).getAppDefinitionId()}async getManifestContextId(){return(await this.getApplicationContext()).getManifestContextId()}async getRequiredManifestContextId(){let t=await this.getManifestContextId();if(!t)throw xn("ManifestContextIdRequired");return t}async getEnvironmentContext(){return(await this.getApplicationContext()).getEnvironmentContext()}async getPlatformPrivateAPI(){return(await this.getApplicationContext()).getPrivateAPI()}},ce=class extends m{async getPrivateAPI(){return(await this.getApplicationContext()).getPrivateApplicationAPI()}async getPublicAPI(t){return(await this.getPlatformPrivateAPI()).applicationManager.getPublicApplicationAPI(t)}async getAppInstance(){return(await this.getPlatformPrivateAPI()).info.getAppInstance(await this.getAppDefinitionId())}},oi=new g(ce).withPublicMethod("getPrivateAPI").withPublicMethod("getPublicAPI").withPublicMethod("getAppInstance").build(),Nt=class extends m{async addEventListener(t,e){return(await this.getApplicationContext()).getEvents().addEventListener(t,e)}},ai=new g(Nt).withPublicMethod("addEventListener").build(),pe=class extends m{async getSelection(){let t=await this.getPlatformPrivateAPI(),e=await t.components.getSelectedComponents();return Promise.all(e.map(i=>t.components.getComponent(i)))}async onSelectionChange(t){new Nt(this.getApplicationContext()).addEventListener("componentSelectionChanged",i=>{t(i.components)})}},ci=new g(pe).withPublicMethod("onSelectionChange").withPublicMethod("getSelection").build(),le=class extends m{async getViewMode(){return(await this.getPlatformPrivateAPI()).info.getViewMode()}async getLanguageCode(){return(await this.getPlatformPrivateAPI()).info.getLanguageCode()}},pi=new g(le).withPublicMethod("getViewMode").withPublicMethod("getLanguageCode").build(),ct=(n=>(n.UndefinedCompRef="UndefinedCompRef",n.NotAvailableMethod="NotAvailableMethod",n))(ct||{}),he=class extends I{constructor(t,e){super(t,e,"Widget Error")}},St=E(he),Je="underline";function Cn(n){return n.map(t=>He({font:t}).family).filter(Boolean)}function He(n){let t={family:void 0,size:void 0};if(n?.font){let{variableName:e,fallbackValue:i}=Tn(n.font);t.cssVariableName=e;let s=i.match(/(?:(["']).*?\1|\S)+/g)||[];for(let r=0;r<s.length;r++){let o=s[r];switch(o){case"bold":t.bold=!0;break;case"italic":t.italic=!0;break;default:o?.endsWith("px")?t.size=parseInt(o,10):r===s.length-1?t.family=o:t.family=(t.family||"")+" "+o}}}return n?.textDecoration&&(t.underline=n.textDecoration===Je),t.family=t.family?.trim().replace(/['"]+/g,""),t}function Tn(n){let t=n.trim(),e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{variableName:e[1],fallbackValue:e[2]?.trim()??""}:{variableName:void 0,fallbackValue:t}}var F=class n{constructor(t,e){this.compRef=t,this.privateAPI=e}async getProp(t){return(await this.privateAPI.refComponents.getProps(this.compRef))?.[t]}async setProp(t,e){await this.privateAPI.refComponents.setProps(this.compRef,{[t]:e})}async getDesignPreset(){return this.privateAPI.designPresets.getDesignPresetName(this.compRef)}async setDesignPreset(t){await this.privateAPI.designPresets.setDesignPresetByName(this.compRef,t)}async getNestedWidget(t){let e=await this.privateAPI.refComponents.findComponentBySelector(this.compRef,t);return e?new n(e,this.privateAPI):null}},C,j,ue=class extends m{constructor(){super(...arguments);h(this,C)}async setPreloadFonts(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);if(await i.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");let r=Cn(e);await i.customElement.setPreloadFonts(s,r)}async getProp(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);return await i.refComponents.isRefComponent(s)?new F(s,i).getProp(e):i.customElement.getAttribute(s,e)}async setProp(e,i){let s=await this.getPlatformPrivateAPI(),r=await u(this,C,j).call(this);if(await s.refComponents.isRefComponent(r))return new F(r,s).setProp(e,i);await s.customElement.setAttribute(r,e,i)}async getDesignPreset(){let e=await this.getPlatformPrivateAPI(),i=await u(this,C,j).call(this);if(!await e.refComponents.isRefComponent(i))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(i,e).getDesignPreset()}async setDesignPreset(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);if(!await i.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(s,i).setDesignPreset(e)}async getNestedWidget(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);return new F(s,i).getNestedWidget(e)}};C=new WeakSet,j=async function(){let s=(await(await this.getPlatformPrivateAPI()).components.getSelectedComponents())[0];if(!s)throw St(ct.UndefinedCompRef);return s};var Rn=new g(ue).withPublicMethod("getNestedWidget").withPublicMethod("setDesignPreset").withPublicMethod("getDesignPreset").withPublicMethod("setProp").withPublicMethod("getProp").withPublicMethod("setPreloadFonts"),li=Rn.build();function Mn(n){return`${n.cssVariableName?`var(${n.cssVariableName}, `:""}${n.italic?"italic ":""}${n.bold?"bold ":""}${n.size||16}px ${n.family?.split(",").map(t=>`"${t.replace(/['"]+/g,"")}"`).join(",")||"serif"}${n.cssVariableName?")":""}`}function _n(n){if(!n)return null;let t=n,e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{cssVariableName:e[1],color:e[2]}:{color:t}}function Ye(n){return n?n.cssVariableName?`var(${n.cssVariableName}, ${n.color})`:n.color:""}var Dn={transformFontInternalValue:n=>{if(n){let{theme:t,cssVariableName:e,bold:i,italic:s,underline:r,...o}=n;return{...o,style:{bold:i,italic:s,underline:r},editorKey:e||t||""}}else return{editorKey:"font_7",family:"helvetica-w01-roman",size:16,style:{}}}},de=class extends m{async selectColor(t,e){let i=await this.getPlatformPrivateAPI(),s=_n(t),r=Ye(s);return await i.inputs.openColorPicker({color:s?.cssVariableName||s?.theme||s?.color},({color:o,theme:c,cssVariableTheme:l})=>{s={color:o,theme:c,cssVariableName:l},r=Ye(s),e?.onChange?.(r)}),r}async selectFont(t,e){let i=await this.getPlatformPrivateAPI(),s=He(t),r=t;return await i.inputs.openFontPickerV2({...e,panelSectionsDefinition:{htmlTag:"hidden"},componentStyle:Dn.transformFontInternalValue(s)},(o,c)=>{r={font:Mn(o),textDecoration:o.underline?Je:void 0},e?.onChange?.(r)}),r}},hi=new g(de).withPublicMethod("selectColor").withPublicMethod("selectFont").build(),fe=class extends m{async openLanguageSupportPanel(){return(await this.getPlatformPrivateAPI()).panels.openLanguageSupportPanel()}async openFontsUploadPanel(){return(await this.getPlatformPrivateAPI()).panels.openFontsUploadPanel()}},ui=new g(fe).withPublicMethod("openLanguageSupportPanel").withPublicMethod("openFontsUploadPanel").build(),Pe=class extends m{async openDashboardModal(t){return(await this.getPlatformPrivateAPI()).panels.openDashboardPanel(await this.getAppDefinitionId(),t)}},di=new g(Pe).withPublicMethod("openDashboardModal").build(),ge=class extends m{async getStyleDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyleDefinitions(e)}async getStyles(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyles(e)}async setStyles(t){let e=await this.getPlatformPrivateAPI(),i=await this.getRequiredManifestContextId();return e.builderComponent.setStyles(i,t)}async getDataDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getDataDefinitions(e)}async getData(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getData(e)}async setData(t){let e=await this.getPlatformPrivateAPI(),i=await this.getRequiredManifestContextId();return e.builderComponent.setData(i,t)}async getState(){return null}async setState(){return null}async getStateDefinitions(){return null}async onChange(t){let e=await this.getPlatformPrivateAPI(),i=await this.getRequiredManifestContextId();return e.builderComponent.onChange(i,t)}},fi=new g(ge).withPublicMethod("getDataDefinitions").withPublicMethod("getData").withPublicMethod("setData").withPublicMethod("getStyleDefinitions").withPublicMethod("getStyles").withPublicMethod("setStyles").withPublicMethod("getState").withPublicMethod("setState").withPublicMethod("onChange").withPublicMethod("getStateDefinitions").build(),me=class extends m{async get(t){return(await this.getPlatformPrivateAPI()).userPreferences.get(await this.getAppDefinitionId(),t)}async set(t){return(await this.getPlatformPrivateAPI()).userPreferences.set(await this.getAppDefinitionId(),t)}},Pi=new g(me).withPublicMethod("set").withPublicMethod("get").build(),Ae=class extends m{async getData(){return(await this.getPlatformPrivateAPI()).externalPanels.getData()}async setData(t){return(await this.getPlatformPrivateAPI()).externalPanels.setData(t)}async getStyle(){return(await this.getPlatformPrivateAPI()).externalPanels.getStyle()}async setStyle(t){return(await this.getPlatformPrivateAPI()).externalPanels.setStyle(t)}async getTheme(){return(await this.getPlatformPrivateAPI()).externalPanels.getTheme()}async selectMedia(){return(await this.getPlatformPrivateAPI()).externalPanels.selectMedia()}async selectLink(...t){return(await this.getPlatformPrivateAPI()).externalPanels.selectLink(...t)}async selectColor(...t){return async()=>(await this.getPlatformPrivateAPI()).externalPanels.selectColor(...t)}async translate(t,e){return(await this.getPlatformPrivateAPI()).externalPanels.translate(t,e)}},gi=new g(Ae).withPublicMethod("getTheme").withPublicMethod("getData").withPublicMethod("getStyle").withPublicMethod("selectColor").withPublicMethod("selectLink").withPublicMethod("selectMedia").withPublicMethod("setData").withPublicMethod("setStyle").withPublicMethod("translate").build(),Sn=()=>{let n=new URLSearchParams(window.location.search),t=n.has("essentials")?JSON.parse(n.get("essentials")):void 0,{monitoring:e,...i}=t||{},s=n.get("appDefinitionId"),{context:r,config:o}=e||{},c=be({hostContext:{appId:s,...r},monitoringConfig:o,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})},getMonitoringClient:c,essentials:i}},Nn=()=>({environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})}}),Ie={host:()=>typeof importScripts=="function"?Nn():Sn(),auth:bn};var wi=()=>{let n=Ie.host(),t=Ie.auth();ve({auth:t,host:n}).enableContext("module")};export{wi as enableClient};
7
+ `)}getBreadcrumbs(){let e=this.parentError;return e?[...e.getBreadcrumbs(),this.displayName]:[this.displayName]}withParentError(e){return this.parent=e,this}withMessage(...e){return this.messages.push(e),this}};function E(n){return function t(e,i=""){let s=new n(i,e);return Error.captureStackTrace&&Error.captureStackTrace(s,t),s}}var jt=class extends I{constructor(e,i){super(e,i,"Editor Platform Internal Error");p(this,"state",{})}withHost(e){return this.state={...this.state,host:e},this}},on=E(jt);var $=(n=>(n.IncorrectEnvironment="IncorrectEnvironment",n))($||{}),$t=class extends I{constructor(e,i){super(e,i,"EP Context Error");p(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},J=E($t);async function an(n,t){if(!n?.type)return n;switch(n.type){case"componentSelectionChanged":let e=n.componentRefs||[],i=await Promise.all(e.map(s=>t.components.getComponent(s)));return{type:n.type,components:i};default:return n}}var Wt=class{constructor(t,e,i){p(this,"events");p(this,"subscribe");p(this,"commit");p(this,"startTransaction");p(this,"silent");this.appDefinitionId=t,this.privateAPI=i,this.events=e,this.subscribe=e.subscribe.bind(e),this.commit=e.commit.bind(e),this.startTransaction=e.startTransaction.bind(e),this.silent=e.silent.bind(e)}notify(t){this.events.notify({type:t.type,payload:t.payload,meta:{appDefinitionId:this.appDefinitionId}})}notifyCustomEvent(t,e){this.notify({type:v.CustomEvent,payload:{...e,type:t}})}addEventListener(t,e){return this.events.subscribe(async i=>{let s=i.meta?.appDefinitionId===this.appDefinitionId||i.meta?.appDefinitionId===null,r=()=>an(i.payload,this.privateAPI);t==="*"?e(await r()):i.type===v.CustomEvent?t===i.payload?.type&&!s&&e(await r()):i.type===v.HostEvent&&t===i.payload?.type&&s&&e(await r())})}},cn=200,pn=50,O,qt,Re,ut=class{constructor(t){h(this,O);p(this,"injectionUUID");p(this,"injectionUUID_Deprecated");this.injectionUUID_Deprecated=`__${t}_CONTEXT_INJECTION_STATUS_KEY`,this.injectionUUID=`__${t}_CONTEXT_INJECTION_STATUS_KEY#0.1`,u(this,O,qt).call(this)||u(this,O,Re).call(this)}resolveInjected(){globalThis[this.injectionUUID]?.resolve()}waitInjected(){return new Promise((t,e)=>{let i=!1,s,r=0,o=()=>{i||(s=setTimeout(()=>{if(r++,r<pn){r%10===0&&console.log(J($.IncorrectEnvironment,"contexts are not resolved, still re-trying").withMessage(`try number ${r}`).message),o();return}if(!i){let c=J($.IncorrectEnvironment,"contexts are not resolved, threw by timeout");e(c)}},cn))};o(),u(this,O,qt).call(this)?.then(()=>{i=!0,clearTimeout(s),t()})})}};O=new WeakSet,qt=function(){return globalThis[this.injectionUUID]?.promise},Re=function(){let t,e=new Promise(i=>{t=i});globalThis[this.injectionUUID]={promise:e,resolve:t},globalThis[this.injectionUUID_Deprecated]=new Promise(i=>{e.then(i)})};var Ft="__ENVIRONMENT_CONTEXT_KEY",Pt=(n=>(n.Worker="Worker",n.Frame="Frame",n.ComponentPanel="ComponentPanel",n))(Pt||{}),dt=class dt{constructor(t){this.environmentContext=t}static async inject(t){if(globalThis[Ft])throw J($.IncorrectEnvironment,"Environment context already exists and should not be overridden");globalThis[Ft]=new dt(t),this.status.resolveInjected()}static async getInstance(){return await this.status.waitInjected(),globalThis[Ft]}getPrivateAPI(){return this.environmentContext.privateApi}getEvents(){return this.environmentContext.events}getApplicationAPIs(){return this.environmentContext.applicationAPIs??{}}getEnvironment(){return this.environmentContext.environment}};p(dt,"status",new ut("environment"));var N=dt,Y="__APPLICATION_CONTEXT_KEY",ft=class ft{constructor(t,e){p(this,"events");this.context=t,this.environment=e,this.events=new Wt(t.appDefinitionId?t.appDefinitionId:null,this.environment.getEvents(),this.environment.getPrivateAPI())}static async inject(t){if(globalThis[Y])throw J($.IncorrectEnvironment,"Application context already exists and should not be overridden");globalThis[Y]=new ft(t,await N.getInstance()),this.status.resolveInjected()}static async getInstance(){return typeof __APPLICATION_CONTEXT_KEY<"u"?__APPLICATION_CONTEXT_KEY:(await this.status.waitInjected(),globalThis[Y])}getContext(){return this.context}getAppDefinitionId(){return this.context.appDefinitionId}getManifestContextId(){return this.context.manifestContextId}getEvents(){return this.events}getEnvironmentContext(){return this.environment}getPrivateAPI(){return this.environment.getPrivateAPI()}getPrivateApplicationAPI(){let t=this.getAppDefinitionId();if(!t)throw J($.IncorrectEnvironment,"appDefinitionId is not available");return this.environment.getApplicationAPIs()[t]}};p(ft,"status",new ut("application"));var y=ft;var Ke=we(Ot());var tt=n=>`"editor-platform-transport": ${n}`,De=n=>tt(`[Internal Error] ${n}`),Se="\u0192",Ne="\u2202",Oe="_get_",ke="_set_",gt="+",Me="-",Ht="\xB7",Xt="\xD7",Qt="\xB0",Le=n=>n[0]===Xt?"":n,_e=n=>n===null||typeof n>"u"||typeof n=="symbol"||typeof n=="number"||typeof n=="boolean"||typeof n=="function"||typeof n=="string",ln=n=>!!n&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof Set)&&!(n instanceof Map),hn=n=>W(n.split(Ht)),W=n=>n.map(Le).filter(Boolean).join(".");function Ct(n,t){return{marker:n,...t}}var un=Ct("A",{shouldUse:n=>Array.isArray(n),serialize:(n,t)=>{n.length?n.forEach((e,i)=>{t(`${i}`,e)}):t("",Qt)},deserialize:{create:()=>[],has:(n,t)=>!(typeof n[t]>"u"),append:(n,t,e)=>{n.push(e)}}}),dn=Ct("M",{shouldUse:n=>n instanceof Map,serialize:(n,t)=>{n.forEach((e,i)=>{t(i,e)})},deserialize:{create:()=>new Map,has:(n,t)=>n.has(t),append:(n,t,e)=>{n.set(t,e)}}}),fn=Ct("S",{shouldUse:n=>n instanceof Set,serialize:(n,t)=>{let e=0;n.forEach(i=>{t(`${e++}`,i)})},deserialize:{create:()=>new Set,has:(n,t)=>n.has(t),append:(n,t,e)=>{n.add(e)}}}),zt=Ct("O",{shouldUse:n=>typeof n=="object",serialize:(n,t)=>{let e=i=>{let r=Reflect.ownKeys(i).filter(c=>c!=="constructor").filter(c=>typeof c!="symbol");r.length?r.filter(c=>c!=="constructor").filter(c=>typeof c!="symbol").forEach(c=>{let l=Reflect.get(n,c);t(c,l)}):t("",Qt);let o=Reflect.getPrototypeOf(i);!o||o?.hasOwnProperty("__proto__")||e(o)};e(n)},deserialize:{create:()=>({}),has:(n,t)=>!!n[t],append:(n,t,e)=>{n[t]=e}}}),Ue=[un,fn,dn];function Pn(n,t){let e=n;for(;e;){let i=Object.getOwnPropertyDescriptor(e,t);if(i)return i;e=Reflect.getPrototypeOf(e)}return null}function gn(n,t){let e=new WeakMap,i=r=>{let o=r.slice(1).map(Le).filter(Boolean);return o.slice(1).reduce((c,l)=>({context:c.context[c.pointer],pointer:l}),{context:n,pointer:o[0]})},s=(r,o=[])=>{if(e.has(r)&&e.get(r)?.some(d=>o.join(".").startsWith(d))){t(o,{...i(o),value:"[Circular]"});return}if(r&&!_e(r)&&(e.has(r)&&e.set(r,[]),e.set(r,[...e.get(r)??[],o.join(".")])),_e(r)){t(o,{...i(o),value:r});return}let c=Ue.find(l=>l.shouldUse(r))??zt;if(c){c.serialize(r,(l,d)=>{s(d,[...o,`${Xt}${c.marker}`,l])});return}};return s(n)}var mn=(n,t)=>{if(!ln(n))throw new Error(tt("only objects are serializable at the root level"));let e={data:[]},i=(r,o)=>{e.data.push([r,o])},s=(r,o)=>{t(hn(r),(...c)=>o.context[o.pointer](...c)),i(r,Se)};return gn(n,(r,{value:o,context:c,pointer:l})=>{let d=r.slice(1).join(Ht),f=Pn(c,l);if(f?.get||f?.set){f?.get&&t(W([...r,Oe]),()=>c[l]),f?.set&&t(W([...r,ke]),V=>{c[l]=V});let D=[f?.get?gt:Me,f?.set?gt:Me];i(d,`${Ne}${D.join("")}`)}else typeof o=="function"?s(d,{context:c,pointer:l}):i(d,o)}),e},An=(n,t)=>typeof n!="object"||n===null?n:n.data.reduce((e,[i,s])=>{let r=e,o=i.split(Ht),c=zt,l=null;for(let d=0;d<o.length;d++){let f=o[d];if(f[0]===Xt){let D=c.deserialize.has(r,l);if(c=[zt,...Ue].find(V=>V.marker===f[1]),!c)throw new Error(tt(`unknown marker "${f[1]}"`));D||(r[l]=c.deserialize.create()),r=r[l]}else l=f}if(s?.toString()===Qt)return e;if(s?.toString()===Se)c.deserialize.append(r,l,t(W(o)));else if(s?.toString()[0]===Ne){let d=s?.toString()[1]===gt,f=s?.toString()[2]===gt,D={};if(d){let V=t(W([...o,Oe]));D.get=()=>V()}f&&(D.set=t(W([...o,ke]))),Object.defineProperty(r,l,D)}else c.deserialize.append(r,l,s);return e},{[Symbol("transferred object")]:`${(JSON.stringify(n.data).length/1024).toFixed(2)}Kb`});function je(){let n=globalThis.performance;if(n&&n.now)return n.now();let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e.length,s=0,r=10;for(;s<r;)t+=e.charAt(Math.floor(Math.random()*i)),s+=1;return t}var X=(n=>(n.ExposeAPI="ExposeAPI",n.Call="Call",n.Response="Response",n.Cleanup="Cleanup",n))(X||{}),R=class n{constructor(t,e){p(this,"correlationId",`M-${je()}`);p(this,"parentCorrelationId");this.type=t,this.payload=e}withParentCorrelationId(t){return this.parentCorrelationId=t,this}serialize(t){return JSON.stringify({parentCorrelationId:this.parentCorrelationId,correlationId:this.correlationId,type:this.type,payload:mn(this.payload,(e,i)=>{t(this.correlationId,e,i)})})}static fromEvent(t,e){let i=JSON.parse(t);return new n(i.type,An(i.payload,s=>e(i.correlationId,s))).withParentCorrelationId(i.correlationId)}},Bt=class extends R{constructor(t){super("Cleanup",t)}},Vt=class extends R{constructor(t){super("Response",t)}},mt=class extends R{constructor(t){super("Response",t)}},Gt=class extends R{constructor(t){super("Call",t)}},Kt=(n,t)=>`${n}_${t}`,Et,bt,q,x,Yt=class{constructor(t){h(this,Et,new FinalizationRegistry(t=>{this.postMessage(new Bt(t))}));h(this,bt,{[X.Cleanup]:t=>{let e=t.payload.functionMarkerKey,i=t.payload.callId;delete a(this,q)[e],i&&delete a(this,x)[i]},[X.Response]:async t=>{let e=t.payload.callId,i=t.payload.errorMessage;if(i)if(t.payload.errorStack){let r=new Error(i);r.stack=t.payload.errorStack,a(this,x)[e]?.reject(r)}else a(this,x)[e]?.reject(i);else{let s=t.payload.response;a(this,x)[e]?.resolve(s)}delete a(this,x)[e]},[X.Call]:async t=>{let e=t.payload.functionMarkerKey,i=a(this,q)[e];if(!i){this.postMessage(new mt({callId:t.payload.callId,errorMessage:tt("function is not available")}));return}try{let s=await i.value(...t.payload.props??[]);this.postMessage(new Vt({callId:t.payload.callId,response:s}))}catch(s){this.postMessage(new mt({callId:t.payload.callId,errorMessage:s.message,errorStack:s.stack}))}}});h(this,q,{});h(this,x,{});p(this,"queue",[]);this.port=t,this.port.onmessage=e=>{this.onMessage(e)}}onMessage(t){let e=R.fromEvent(t.data,(i,s)=>{let r=this.replaceTransferredFunction(i,s);return a(this,Et).register(r,{functionMarkerKey:Kt(i,s)}),r});a(this,bt)[e.type]?.(e),this.messageEvents[e.type]?.(e)}postMessage(t){this.port.postMessage(t.serialize(this.registerTransferredFunction.bind(this)))}registerTransferredFunction(t,e,i){let s=Kt(t,e);a(this,q)[s]={path:e,value:i}}replaceTransferredFunction(t,e){return(...i)=>{let s=`CALL-${crypto.randomUUID()}`;return this.postMessage(new Gt({callId:s,functionMarkerKey:Kt(t,e),props:i})),new Promise((r,o)=>{a(this,x)[s]={resolve:r,reject:o}})}}flush(){this.queue.forEach(t=>{this.postMessage(t)}),this.queue=[]}};Et=new WeakMap,bt=new WeakMap,q=new WeakMap,x=new WeakMap;var At=class extends Yt{constructor(){super(...arguments);p(this,"messageEvents",{})}expose(e){if(!e.type)throw new Error(tt('wrong exposed API instance, "type" property is required'));this.queue.push(new R(X.ExposeAPI,e)),this.flush()}};var H=(n=>(n.Ping="EDITOR_PLATFORM_TRANSPORT_EVENT:__Ping",n.RequestPort="EDITOR_PLATFORM_TRANSPORT_EVENT:__RequestPort",n.Pong="EDITOR_PLATFORM_TRANSPORT_EVENT:__Pong",n.Port="EDITOR_PLATFORM_TRANSPORT_EVENT:__Port",n))(H||{});var K,T,xt,Fe,Jt=class{constructor(t,e){h(this,xt);h(this,K,new Set);h(this,T);this.postMessage=t,this.onMessage=e}setActivePort(t){this.dispose(),w(this,T,t),u(this,xt,Fe).call(this)}dispose(){a(this,T)&&(a(this,T).close(),a(this,T).onmessage=null)}onHandshake(t){return a(this,K).add(t),()=>{a(this,K).delete(t)}}};K=new WeakMap,T=new WeakMap,xt=new WeakSet,Fe=function(){let t=a(this,T);if(!t){console.warn(De("port is required no notify onHandshake listeners"));return}a(this,K).forEach(e=>e(t))};var Q,Z,M,$e,We,qe,It=class extends Jt{constructor(e,i){super(e,i);h(this,M);h(this,Q,!1);h(this,Z,`consumer-${je()}`);u(this,M,$e).call(this);let s={type:H.Ping};e(JSON.stringify(s))}};Q=new WeakMap,Z=new WeakMap,M=new WeakSet,$e=function(){this.onMessage(e=>{try{let i=JSON.parse(e.data);switch(i.type){case H.Pong:{u(this,M,We).call(this);break}case H.Port:{u(this,M,qe).call(this,i.targetMemberId,e.ports?.[0]);break}}}catch{}})},We=function(){if(a(this,Q))return;w(this,Q,!0);let e={type:H.RequestPort,memberId:a(this,Z)};this.postMessage(JSON.stringify(e))},qe=function(e,i){if(e===a(this,Z)){if(!i)throw new Error(De("no port at consumer handshake"));this.setActivePort(i)}};var yt=class{get onConnect(){return this.handshake.onHandshake.bind(this.handshake)}},wt=class n extends yt{constructor(){super(...arguments);p(this,"handshake",new It(e=>{globalThis.parent.postMessage(e,"*")},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new n().onConnect(s=>{new At(s).expose(e)})}};var vt=class n extends yt{constructor(){super(...arguments);p(this,"handshake",new It(e=>{globalThis.postMessage(e)},e=>{globalThis.addEventListener("message",e)}))}static exposeAPI(e){new n().onConnect(s=>{new At(s).expose(e)})}};var Tt=class{constructor(t){this.platformAppEvents=t}notify(t){switch(t.type){case Ut.EditorReady:this.platformAppEvents.notify({...t,type:v.EditorReady});break;case ht.HostEvent:this.platformAppEvents.notify({...t,type:v.HostEvent});break}}subscribe(t){this.platformAppEvents.subscribe(e=>{t(e)})}},re=(n=>(n.Frame="PLATFORM_FRAME_API",n.Worker="PLATFORM_WORKER_API",n))(re||{}),Rt=class{constructor(t,e){this.type=t,this.envType=e}async injectEnvironmentContext({events:t,privateApi:e}){await N.inject({environment:this.envType,events:t,privateApi:e,applicationAPIs:{}})}async injectApplicationContext(t){await y.inject(t)}},In={classic:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-default.global.css",studio:"https://www.unpkg.com/@wix/design-system/dist/statics/tokens-studio.global.css"},et,nt,_t,it,Dt,ze,te=class extends Rt{constructor(){super(re.Frame,Pt.Frame);h(this,Dt);h(this,et,new b);h(this,nt,new Tt(a(this,et)));h(this,_t);h(this,it);u(this,Dt,ze).call(this)}async initEnvironment(e){let{applicationPrivateAPI:i,privateAPI:s,context:r}=e,o=e.context?.appDefinitionId??e.appDefinitionId,c=e.context?e.context:{appDefinitionId:o};w(this,it,i),w(this,_t,s),await this.injectEnvironmentContext({privateApi:s,events:a(this,et),applicationAPIs:o?{[o]:a(this,it)}:{}}),await this.injectApplicationContext(c)}notify(e){a(this,nt).notify(e)}subscribe(e){a(this,nt).subscribe(e)}};et=new WeakMap,nt=new WeakMap,_t=new WeakMap,it=new WeakMap,Dt=new WeakSet,ze=function(){if(typeof globalThis?.document?.head?.prepend=="function"){let i=new URL(globalThis.location.href).searchParams.get("editorType")==="CLASSIC"?"classic":"studio",s=In[i],r=s&&!!document.querySelectorAll(`link[type="text/css"][href="${s}"]`)?.length;if(s&&!r){let o=document.createElement("link");o.setAttribute("rel","stylesheet"),o.setAttribute("type","text/css"),o.setAttribute("href",s),globalThis.document.head.prepend(o)}}};var _=(n=>(n.ApplicationLoadError="ApplicationLoadError",n.ApplicationFetchError="ApplicationFetchError",n.ApplicationExecuteError="ApplicationExecuteError",n))(_||{}),ee=class extends I{constructor(e,i){super(e,i,"EP Application Container Error");p(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}withApiMethod(e){return this.state={...this.state,apiMethod:e},this}withApiType(e){return this.state={...this.state,apiType:e},this}},k=E(ee),yn="__APPLICATION_REGISTRY_KEY";async function wn(n,t,e){let i=new Function(Y,yn,e),s,r=o=>{if(s)throw k(_.ApplicationExecuteError,"Application registry called more than once").withAppDefinitionId(t.appDefinitionId);if(o.type!==t.type)throw k(_.ApplicationExecuteError,"Application has different type").withMessage("expected type",t.type).withMessage("received type",o.type);s=o};try{let o={...t};i.call(null,new y(o,await N.getInstance()),r)}catch(o){throw k(_.ApplicationExecuteError,o.message).withAppDefinitionId(t.appDefinitionId).withParentError(o)}return new Promise((o,c)=>{let l=n.subscribe(d=>{let f=setTimeout(()=>{clearTimeout(f),l(),s||c(k(_.ApplicationExecuteError,"Application registry was not called, threw by timeout").withAppDefinitionId(t.appDefinitionId))},5e3);d.type===v.ApplicationInit&&d.meta.appDefinitionId===t.appDefinitionId&&(clearTimeout(f),l(),s||c(k(_.ApplicationExecuteError,"Application registry was not called").withAppDefinitionId(t.appDefinitionId)),o({instance:s}))})})}var L,st,P,ne=class{constructor(t,e){h(this,L,{});h(this,st);h(this,P);w(this,st,t),w(this,P,e),a(this,P).subscribe(i=>{switch(i.type){case v.HostEvent:{i.payload.type===Ke.EventType.removeAppCompleted&&a(this,P).withEvent(a(this,P).factories.createApplicationRemovedEvent(i.payload.appDefinitionId),()=>this.removeApplication(i.payload.appDefinitionId));break}}})}async runApplication(t){let e=await this.loadApplication(t),i=await this.executeApplication(t,e);return this.setApplication(t.appDefinitionId,i),i}setApplication(t,e){a(this,L)[t]=e,a(this,P).withEvent(a(this,P).factories.createApplicationApiInitEvent(t,e?.api?.private?"private":"public"),()=>{a(this,st).applicationManager.setApplication(e)})}getApplication(t){return a(this,L)[t]}getAppDefinitionIds(){return Object.keys(a(this,L))}removeApplication(t){delete a(this,L)[t]}async loadApplication(t){let e=t.url;return a(this,P).withEvent(a(this,P).factories.createApplicationLoadEvent(t,e),async()=>{try{return await this.loadApplicationBundle(e)}catch(i){throw k(_.ApplicationLoadError).withUrl(e).withAppDefinitionId(t.appDefinitionId).withParentError(i)}})}async loadApplicationBundle(t){let e=await fetch(t,{method:"GET"});if(!(e.status>=200&&e.status<=299))throw k(_.ApplicationFetchError).withUrl(t);return e.text()}async executeApplication(t,e){return a(this,P).withEvent(a(this,P).factories.createApplicationExecuteEvent(t,t.url),async()=>{let{instance:i}=await wn(a(this,P),t,e);return i})}};L=new WeakMap,st=new WeakMap,P=new WeakMap;var z,rt,ot,U,at,ie=class extends Rt{constructor(){super(re.Worker,Pt.Worker);h(this,z,new b);h(this,rt,new Tt(a(this,z)));h(this,ot,null);h(this,U);h(this,at,[])}create(){}async initEnvironment(e){let{buildPrivateAPI:i}=e;w(this,U,await i({type:"EDITOR_ADDON"})),await this.injectEnvironmentContext({events:a(this,z),privateApi:a(this,U),applicationAPIs:{}}),w(this,ot,new ne(a(this,U),a(this,z))),a(this,at).forEach(s=>s(this))}async notify(e){await this.waitReady(),a(this,rt).notify(e)}subscribe(e){a(this,rt).subscribe(e)}async runApplication(e){await this.waitReady(),await a(this,ot).runApplication(e)}waitReady(){return new Promise(e=>{if(a(this,U))return e(this);a(this,at).push(e)})}};z=new WeakMap,rt=new WeakMap,ot=new WeakMap,U=new WeakMap,at=new WeakMap;var Zt="$_EP_TRANSPORT_ENV_CONTEXT_GUARD",B,Be,Ve,Mt=class{constructor(){h(this,B)}isEnvironmentApiExposed(){return!!globalThis[Zt]}async getContexts(){let[t,e]=await Promise.all([N.getInstance(),y.getInstance()]);return{environmentContext:t,applicationContext:e}}expose(){if(this.isEnvironmentApiExposed())return;let t=typeof importScripts=="function",e=globalThis.self&&globalThis.top&&globalThis.self!==globalThis.top;t?(u(this,B,Be).call(this),globalThis[Zt]=!0):e&&(u(this,B,Ve).call(this),globalThis[Zt]=!0)}};B=new WeakSet,Be=function(){vt.exposeAPI(new ie)},Ve=function(){wt.exposeAPI(new te)};var se=class extends I{constructor(e,i){super(e,i,"EP EnvironmentAPI Error");p(this,"state",{})}withUrl(e){return this.state={...this.state,url:e},this}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Qn=E(se);new Mt().expose();var oe=class extends I{constructor(e,i){super(e,i,"Auth Strategy Error");p(this,"state",{})}withAppDefinitionId(e){return this.state={...this.state,appDefinitionId:e},this}},Ge=E(oe);function vn(n,t){let e=Date.now(),i=n?new Date(n).getTime():null;return i&&i-e>t}var En=30*60*1e3,bn=()=>{let n;return{getAuthHeaders:async()=>{let t=await y.getInstance(),e=t.getAppDefinitionId(),i=t.getPrivateAPI();if(!e)throw Ge("EmptyAppDefinitionId");return(!n||vn(n.expires,En))&&(n=await i.auth.getAccessToken(e,await i.info.getMetaSiteId())),n?.token?{headers:{Authorization:n.token}}:(console.error(Ge("EmptyAppAuthInstance").withAppDefinitionId(e)),{headers:{Authorization:""}})}}},g=class n{constructor(t,e=[]){this.ShapeConstructor=t,this.selectedMethods=e}withPublicMethod(t){return new n(this.ShapeConstructor,[...this.selectedMethods,t])}build(){if(!this.selectedMethods.length)throw new Error("methods are not defined for the SDK shape");let t=this.selectedMethods.reduce((e,i)=>({...e,[i]:s=>{let r=new this.ShapeConstructor(s?.applicationContext);return r[i]?r[i].bind(r):()=>{console.error(`"${i}" is not defined in the SDK shape`)}}}),{});return Ee(t)}},ae=class extends I{constructor(t,e){super(t,e,"Base SDK Error")}},xn=E(ae),m=class{constructor(t=null){this.overriddenApplicationContext=t}getApplicationContext(){return this.overriddenApplicationContext?this.overriddenApplicationContext:y.getInstance()}async getAppDefinitionId(){return(await this.getApplicationContext()).getAppDefinitionId()}async getManifestContextId(){return(await this.getApplicationContext()).getManifestContextId()}async getRequiredManifestContextId(){let t=await this.getManifestContextId();if(!t)throw xn("ManifestContextIdRequired");return t}async getEnvironmentContext(){return(await this.getApplicationContext()).getEnvironmentContext()}async getPlatformPrivateAPI(){return(await this.getApplicationContext()).getPrivateAPI()}},ce=class extends m{async getPrivateAPI(){return(await this.getApplicationContext()).getPrivateApplicationAPI()}async getPublicAPI(t){return(await this.getPlatformPrivateAPI()).applicationManager.getPublicApplicationAPI(t)}async getAppInstance(){return(await this.getPlatformPrivateAPI()).info.getAppInstance(await this.getAppDefinitionId())}},oi=new g(ce).withPublicMethod("getPrivateAPI").withPublicMethod("getPublicAPI").withPublicMethod("getAppInstance").build(),Nt=class extends m{async addEventListener(t,e){return(await this.getApplicationContext()).getEvents().addEventListener(t,e)}},ai=new g(Nt).withPublicMethod("addEventListener").build(),pe=class extends m{async getSelection(){let t=await this.getPlatformPrivateAPI(),e=await t.components.getSelectedComponents();return Promise.all(e.map(i=>t.components.getComponent(i)))}async onSelectionChange(t){new Nt(this.getApplicationContext()).addEventListener("componentSelectionChanged",i=>{t(i.components)})}},ci=new g(pe).withPublicMethod("onSelectionChange").withPublicMethod("getSelection").build(),le=class extends m{async getViewMode(){return(await this.getPlatformPrivateAPI()).info.getViewMode()}async getLanguageCode(){return(await this.getPlatformPrivateAPI()).info.getLanguageCode()}},pi=new g(le).withPublicMethod("getViewMode").withPublicMethod("getLanguageCode").build(),ct=(n=>(n.UndefinedCompRef="UndefinedCompRef",n.NotAvailableMethod="NotAvailableMethod",n))(ct||{}),he=class extends I{constructor(t,e){super(t,e,"Widget Error")}},St=E(he),Je="underline";function Cn(n){return n.map(t=>He({font:t}).family).filter(Boolean)}function He(n){let t={family:void 0,size:void 0};if(n?.font){let{variableName:e,fallbackValue:i}=Tn(n.font);t.cssVariableName=e;let s=i.match(/(?:(["']).*?\1|\S)+/g)||[];for(let r=0;r<s.length;r++){let o=s[r];switch(o){case"bold":t.bold=!0;break;case"italic":t.italic=!0;break;default:o?.endsWith("px")?t.size=parseInt(o,10):r===s.length-1?t.family=o:t.family=(t.family||"")+" "+o}}}return n?.textDecoration&&(t.underline=n.textDecoration===Je),t.family=t.family?.trim().replace(/['"]+/g,""),t}function Tn(n){let t=n.trim(),e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{variableName:e[1],fallbackValue:e[2]?.trim()??""}:{variableName:void 0,fallbackValue:t}}var F=class n{constructor(t,e){this.compRef=t,this.privateAPI=e}async getProp(t){return(await this.privateAPI.refComponents.getProps(this.compRef))?.[t]}async setProp(t,e){await this.privateAPI.refComponents.setProps(this.compRef,{[t]:e})}async getDesignPreset(){return this.privateAPI.designPresets.getDesignPresetName(this.compRef)}async setDesignPreset(t){await this.privateAPI.designPresets.setDesignPresetByName(this.compRef,t)}async getNestedWidget(t){let e=await this.privateAPI.refComponents.findComponentBySelector(this.compRef,t);return e?new n(e,this.privateAPI):null}},C,j,ue=class extends m{constructor(){super(...arguments);h(this,C)}async setPreloadFonts(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);if(await i.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");let r=Cn(e);await i.customElement.setPreloadFonts(s,r)}async getProp(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);return await i.refComponents.isRefComponent(s)?new F(s,i).getProp(e):i.customElement.getAttribute(s,e)}async setProp(e,i){let s=await this.getPlatformPrivateAPI(),r=await u(this,C,j).call(this);if(await s.refComponents.isRefComponent(r))return new F(r,s).setProp(e,i);await s.customElement.setAttribute(r,e,i)}async getDesignPreset(){let e=await this.getPlatformPrivateAPI(),i=await u(this,C,j).call(this);if(!await e.refComponents.isRefComponent(i))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(i,e).getDesignPreset()}async setDesignPreset(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);if(!await i.refComponents.isRefComponent(s))throw St(ct.NotAvailableMethod,"not available for the current component type");return new F(s,i).setDesignPreset(e)}async getNestedWidget(e){let i=await this.getPlatformPrivateAPI(),s=await u(this,C,j).call(this);return new F(s,i).getNestedWidget(e)}};C=new WeakSet,j=async function(){let s=(await(await this.getPlatformPrivateAPI()).components.getSelectedComponents())[0];if(!s)throw St(ct.UndefinedCompRef);return s};var Rn=new g(ue).withPublicMethod("getNestedWidget").withPublicMethod("setDesignPreset").withPublicMethod("getDesignPreset").withPublicMethod("setProp").withPublicMethod("getProp").withPublicMethod("setPreloadFonts"),li=Rn.build();function Mn(n){return`${n.cssVariableName?`var(${n.cssVariableName}, `:""}${n.italic?"italic ":""}${n.bold?"bold ":""}${n.size||16}px ${n.family?.split(",").map(t=>`"${t.replace(/['"]+/g,"")}"`).join(",")||"serif"}${n.cssVariableName?")":""}`}function _n(n){if(!n)return null;let t=n,e=t.match(/var\((--[\w-]+),\s*(.+)\)/);return e?{cssVariableName:e[1],color:e[2]}:{color:t}}function Ye(n){return n?n.cssVariableName?`var(${n.cssVariableName}, ${n.color})`:n.color:""}var Dn={transformFontInternalValue:n=>{if(n){let{theme:t,cssVariableName:e,bold:i,italic:s,underline:r,...o}=n;return{...o,style:{bold:i,italic:s,underline:r},editorKey:e||t||""}}else return{editorKey:"font_7",family:"helvetica-w01-roman",size:16,style:{}}}},de=class extends m{async selectColor(t,e){let i=await this.getPlatformPrivateAPI(),s=_n(t),r=Ye(s);return await i.inputs.openColorPicker({color:s?.cssVariableName||s?.theme||s?.color},({color:o,theme:c,cssVariableTheme:l})=>{s={color:o,theme:c,cssVariableName:l},r=Ye(s),e?.onChange?.(r)}),r}async selectFont(t,e){let i=await this.getPlatformPrivateAPI(),s=He(t),r=t;return await i.inputs.openFontPickerV2({...e,panelSectionsDefinition:{htmlTag:"hidden"},componentStyle:Dn.transformFontInternalValue(s)},(o,c)=>{r={font:Mn(o),textDecoration:o.underline?Je:void 0},e?.onChange?.(r)}),r}},hi=new g(de).withPublicMethod("selectColor").withPublicMethod("selectFont").build(),fe=class extends m{async openLanguageSupportPanel(){return(await this.getPlatformPrivateAPI()).panels.openLanguageSupportPanel()}async openFontsUploadPanel(){return(await this.getPlatformPrivateAPI()).panels.openFontsUploadPanel()}},ui=new g(fe).withPublicMethod("openLanguageSupportPanel").withPublicMethod("openFontsUploadPanel").build(),Pe=class extends m{async openDashboardModal(t){return(await this.getPlatformPrivateAPI()).panels.openDashboardPanel(await this.getAppDefinitionId(),t)}},di=new g(Pe).withPublicMethod("openDashboardModal").build(),ge=class extends m{async getStyleDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyleDefinitions(e)}async getStyles(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getStyles(e)}async setStyles(t){let e=await this.getPlatformPrivateAPI(),i=await this.getRequiredManifestContextId();return e.builderComponent.setStyles(i,t)}async getDataDefinitions(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getDataDefinitions(e)}async getData(){let t=await this.getPlatformPrivateAPI(),e=await this.getRequiredManifestContextId();return t.builderComponent.getData(e)}async setData(t){let e=await this.getPlatformPrivateAPI(),i=await this.getRequiredManifestContextId();return e.builderComponent.setData(i,t)}async getState(){return null}async setState(){return null}async getStateDefinitions(){return null}async onChange(t){let e=await this.getPlatformPrivateAPI(),i=await this.getRequiredManifestContextId();return e.builderComponent.onContextualManifestChange(i,t)}},fi=new g(ge).withPublicMethod("getDataDefinitions").withPublicMethod("getData").withPublicMethod("setData").withPublicMethod("getStyleDefinitions").withPublicMethod("getStyles").withPublicMethod("setStyles").withPublicMethod("getState").withPublicMethod("setState").withPublicMethod("onChange").withPublicMethod("getStateDefinitions").build(),me=class extends m{async get(t){return(await this.getPlatformPrivateAPI()).userPreferences.get(await this.getAppDefinitionId(),t)}async set(t){return(await this.getPlatformPrivateAPI()).userPreferences.set(await this.getAppDefinitionId(),t)}},Pi=new g(me).withPublicMethod("set").withPublicMethod("get").build(),Ae=class extends m{async getData(){return(await this.getPlatformPrivateAPI()).externalPanels.getData()}async setData(t){return(await this.getPlatformPrivateAPI()).externalPanels.setData(t)}async getStyle(){return(await this.getPlatformPrivateAPI()).externalPanels.getStyle()}async setStyle(t){return(await this.getPlatformPrivateAPI()).externalPanels.setStyle(t)}async getTheme(){return(await this.getPlatformPrivateAPI()).externalPanels.getTheme()}async selectMedia(){return(await this.getPlatformPrivateAPI()).externalPanels.selectMedia()}async selectLink(...t){return(await this.getPlatformPrivateAPI()).externalPanels.selectLink(...t)}async selectColor(...t){return async()=>(await this.getPlatformPrivateAPI()).externalPanels.selectColor(...t)}async translate(t,e){return(await this.getPlatformPrivateAPI()).externalPanels.translate(t,e)}},gi=new g(Ae).withPublicMethod("getTheme").withPublicMethod("getData").withPublicMethod("getStyle").withPublicMethod("selectColor").withPublicMethod("selectLink").withPublicMethod("selectMedia").withPublicMethod("setData").withPublicMethod("setStyle").withPublicMethod("translate").build(),Sn=()=>{let n=new URLSearchParams(window.location.search),t=n.has("essentials")?JSON.parse(n.get("essentials")):void 0,{monitoring:e,...i}=t||{},s=n.get("appDefinitionId"),{context:r,config:o}=e||{},c=be({hostContext:{appId:s,...r},monitoringConfig:o,sentrySDK:typeof window<"u"?window.Sentry:void 0});return{environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})},getMonitoringClient:c,essentials:i}},Nn=()=>({environment:{},applicationContext:y.getInstance(),channel:{observeState:async()=>({disconnect(){}})}}),Ie={host:()=>typeof importScripts=="function"?Nn():Sn(),auth:bn};var wi=()=>{let n=Ie.host(),t=Ie.auth();ve({auth:t,host:n}).enableContext("module")};export{wi as enableClient};
8
8
  //# sourceMappingURL=editor.js.map