@wix/cli-app 1.1.60 → 1.1.61

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 (92) hide show
  1. package/build/{CreateVersionCommand-Z6F5IKH5.js → CreateVersionCommand-27X5XRUT.js} +14 -14
  2. package/build/{DevCommand-YFEZ4QV5.js → DevCommand-6HTMGZ2M.js} +12 -12
  3. package/build/{GenerateCommand-KCV4YDNN.js → GenerateCommand-7IAUS6BH.js} +105 -41
  4. package/build/{GenerateCommand-KCV4YDNN.js.map → GenerateCommand-7IAUS6BH.js.map} +1 -1
  5. package/build/{LogsCommand-VBMGVYNU.js → LogsCommand-WPUUN3JU.js} +4 -4
  6. package/build/PreviewCommand-CU46IAJE.js +23 -0
  7. package/build/{ReleaseCommand-5F3FPBXT.js → ReleaseCommand-KTVVW67B.js} +14 -14
  8. package/build/{ServeCommand-G4FF4PT3.js → ServeCommand-LXJK73IU.js} +13 -13
  9. package/build/{build-XZI3USNB.js → build-KOJIDD4M.js} +38 -9
  10. package/build/build-KOJIDD4M.js.map +1 -0
  11. package/build/{chunk-HUWYF2ET.js → chunk-2GCKBITG.js} +8 -8
  12. package/build/{chunk-O42QDBJU.js → chunk-63EMUDZG.js} +3 -3
  13. package/build/{chunk-5QZS3HT7.js → chunk-A3UPTTKJ.js} +3 -3
  14. package/build/{chunk-WRWNJYKZ.js → chunk-EL6CIFIN.js} +3 -3
  15. package/build/{chunk-QVGYU6D4.js → chunk-ELYFHAX6.js} +5 -2
  16. package/build/chunk-ELYFHAX6.js.map +1 -0
  17. package/build/{chunk-4VTDNX5T.js → chunk-IL6O6OIL.js} +2 -2
  18. package/build/{chunk-VXE3IWKR.js → chunk-KJF6LWGQ.js} +2 -2
  19. package/build/{chunk-WRPV7SLY.js → chunk-KJRYBTZB.js} +192 -19
  20. package/build/chunk-KJRYBTZB.js.map +1 -0
  21. package/build/{chunk-PKSGXFYA.js → chunk-LOLULZLU.js} +3 -3
  22. package/build/{chunk-IG6IV6VM.js → chunk-MEDHLZDL.js} +3 -3
  23. package/build/{chunk-DGTJGIY2.js → chunk-MKPZBVQD.js} +213 -27
  24. package/build/{chunk-DGTJGIY2.js.map → chunk-MKPZBVQD.js.map} +1 -1
  25. package/build/{chunk-2PTCXTKF.js → chunk-OHF42SKC.js} +5 -5
  26. package/build/{chunk-CNZ3Q5PF.js → chunk-PBUNWOQL.js} +7 -7
  27. package/build/chunk-PBUNWOQL.js.map +1 -0
  28. package/build/{chunk-7CGRTCDC.js → chunk-S7UPYDTK.js} +3 -3
  29. package/build/chunk-SJY44CC7.js +19161 -0
  30. package/build/chunk-SJY44CC7.js.map +1 -0
  31. package/build/{chunk-VZJZSWRE.js → chunk-XBBIROHO.js} +3 -3
  32. package/build/{chunk-36W5H7IG.js → chunk-XCKLCHGL.js} +188 -174
  33. package/build/chunk-XCKLCHGL.js.map +1 -0
  34. package/build/{chunk-USAOCISL.js → chunk-Z7MEHVBF.js} +3 -3
  35. package/build/cloudflare-runtime/entry.js +7158 -53
  36. package/build/cloudflare-runtime/getRegisteredExtensions.js +7096 -16
  37. package/build/index.js +20 -20
  38. package/build/platform-sdk/chunk-BGTZ3RNN.js +2 -0
  39. package/build/platform-sdk/chunk-BGTZ3RNN.js.map +1 -0
  40. package/build/platform-sdk/{chunk-QV4VBCJB.js → chunk-FWUYJ3UR.js} +2 -2
  41. package/build/platform-sdk/chunk-NAPHVUFM.js +2 -0
  42. package/build/platform-sdk/{chunk-42XIZ4MH.js.map → chunk-NAPHVUFM.js.map} +1 -1
  43. package/build/platform-sdk/{chunk-EERHWVVD.js → chunk-XYIDODIB.js} +2 -2
  44. package/build/platform-sdk/dashboard.js +1 -1
  45. package/build/platform-sdk/dashboard.js.map +1 -1
  46. package/build/platform-sdk/editor.js +2 -2
  47. package/build/platform-sdk/editor.js.map +1 -1
  48. package/build/platform-sdk/sdk-context.js +1 -1
  49. package/build/platform-sdk/sdk-context.js.map +1 -1
  50. package/build/platform-sdk/site.js +1 -1
  51. package/build/platform-sdk/site.js.map +1 -1
  52. package/build/platform-sdk/web-methods.js +1 -1
  53. package/build/platform-sdk/web-methods.js.map +1 -1
  54. package/build/{preview-VAHHFTRZ.js → preview-YEREVN42.js} +12 -12
  55. package/build/{render-command-3AYSQXHN.js → render-command-H5DHMFOD.js} +6 -6
  56. package/package.json +7 -5
  57. package/schemas/custom-element.json +1 -1
  58. package/templates/custom-element/files/element.module.css.ejs +18 -5
  59. package/templates/custom-element/files/element.tsx.ejs +8 -5
  60. package/templates/custom-element/files/panel.tsx.ejs +25 -12
  61. package/templates/web-method/files/placeholder.ts.ejs +1 -1
  62. package/build/PreviewCommand-3OMHWDW6.js +0 -23
  63. package/build/build-XZI3USNB.js.map +0 -1
  64. package/build/chunk-36W5H7IG.js.map +0 -1
  65. package/build/chunk-CNZ3Q5PF.js.map +0 -1
  66. package/build/chunk-FTC5AK3Y.js +0 -1367
  67. package/build/chunk-FTC5AK3Y.js.map +0 -1
  68. package/build/chunk-QVGYU6D4.js.map +0 -1
  69. package/build/chunk-WRPV7SLY.js.map +0 -1
  70. package/build/platform-sdk/chunk-42XIZ4MH.js +0 -2
  71. /package/build/{CreateVersionCommand-Z6F5IKH5.js.map → CreateVersionCommand-27X5XRUT.js.map} +0 -0
  72. /package/build/{DevCommand-YFEZ4QV5.js.map → DevCommand-6HTMGZ2M.js.map} +0 -0
  73. /package/build/{LogsCommand-VBMGVYNU.js.map → LogsCommand-WPUUN3JU.js.map} +0 -0
  74. /package/build/{PreviewCommand-3OMHWDW6.js.map → PreviewCommand-CU46IAJE.js.map} +0 -0
  75. /package/build/{ReleaseCommand-5F3FPBXT.js.map → ReleaseCommand-KTVVW67B.js.map} +0 -0
  76. /package/build/{ServeCommand-G4FF4PT3.js.map → ServeCommand-LXJK73IU.js.map} +0 -0
  77. /package/build/{chunk-HUWYF2ET.js.map → chunk-2GCKBITG.js.map} +0 -0
  78. /package/build/{chunk-O42QDBJU.js.map → chunk-63EMUDZG.js.map} +0 -0
  79. /package/build/{chunk-5QZS3HT7.js.map → chunk-A3UPTTKJ.js.map} +0 -0
  80. /package/build/{chunk-WRWNJYKZ.js.map → chunk-EL6CIFIN.js.map} +0 -0
  81. /package/build/{chunk-4VTDNX5T.js.map → chunk-IL6O6OIL.js.map} +0 -0
  82. /package/build/{chunk-VXE3IWKR.js.map → chunk-KJF6LWGQ.js.map} +0 -0
  83. /package/build/{chunk-PKSGXFYA.js.map → chunk-LOLULZLU.js.map} +0 -0
  84. /package/build/{chunk-IG6IV6VM.js.map → chunk-MEDHLZDL.js.map} +0 -0
  85. /package/build/{chunk-2PTCXTKF.js.map → chunk-OHF42SKC.js.map} +0 -0
  86. /package/build/{chunk-7CGRTCDC.js.map → chunk-S7UPYDTK.js.map} +0 -0
  87. /package/build/{chunk-VZJZSWRE.js.map → chunk-XBBIROHO.js.map} +0 -0
  88. /package/build/{chunk-USAOCISL.js.map → chunk-Z7MEHVBF.js.map} +0 -0
  89. /package/build/platform-sdk/{chunk-QV4VBCJB.js.map → chunk-FWUYJ3UR.js.map} +0 -0
  90. /package/build/platform-sdk/{chunk-EERHWVVD.js.map → chunk-XYIDODIB.js.map} +0 -0
  91. /package/build/{preview-VAHHFTRZ.js.map → preview-YEREVN42.js.map} +0 -0
  92. /package/build/{render-command-3AYSQXHN.js.map → render-command-H5DHMFOD.js.map} +0 -0
package/build/index.js CHANGED
@@ -2,13 +2,13 @@ import { createRequire as _createRequire } from 'node:module';
2
2
  const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  createI18nT
5
- } from "./chunk-O42QDBJU.js";
6
- import "./chunk-QVGYU6D4.js";
5
+ } from "./chunk-63EMUDZG.js";
6
+ import "./chunk-ELYFHAX6.js";
7
7
  import {
8
8
  require_react,
9
9
  version,
10
10
  z
11
- } from "./chunk-36W5H7IG.js";
11
+ } from "./chunk-XCKLCHGL.js";
12
12
  import {
13
13
  __commonJS,
14
14
  __require,
@@ -3356,8 +3356,8 @@ var {
3356
3356
  // src/commands/build.ts
3357
3357
  init_esm_shims();
3358
3358
  var buildCommand = (services) => createCommand("build").action(async (_, command) => {
3359
- const { runCommand } = await import("./render-command-3AYSQXHN.js");
3360
- const { build } = await import("./build-XZI3USNB.js");
3359
+ const { runCommand } = await import("./render-command-H5DHMFOD.js");
3360
+ const { build } = await import("./build-KOJIDD4M.js");
3361
3361
  await runCommand(command, services, build);
3362
3362
  });
3363
3363
 
@@ -3367,8 +3367,8 @@ var import_react = __toESM(require_react(), 1);
3367
3367
  var devCommand = (services) => {
3368
3368
  const t = createI18nT();
3369
3369
  return createCommand("dev").option("-s, --https", t("dev_command_def.option.https")).action(async (options, command) => {
3370
- const { DevCommand } = await import("./DevCommand-YFEZ4QV5.js");
3371
- const { renderCommand } = await import("./render-command-3AYSQXHN.js");
3370
+ const { DevCommand } = await import("./DevCommand-6HTMGZ2M.js");
3371
+ const { renderCommand } = await import("./render-command-H5DHMFOD.js");
3372
3372
  const { https = false } = options;
3373
3373
  await renderCommand(command, services, /* @__PURE__ */ import_react.default.createElement(DevCommand, { https }), {
3374
3374
  watchForModelChanges: true
@@ -3419,10 +3419,10 @@ var previewCommand = (services) => {
3419
3419
  validateBase
3420
3420
  ).option("--no-input", t("app_preview_command_def.option.no_input")).action(async (options, command) => {
3421
3421
  const { site, baseUrl, input } = options;
3422
- const { renderCommand, runCommand } = await import("./render-command-3AYSQXHN.js");
3422
+ const { renderCommand, runCommand } = await import("./render-command-H5DHMFOD.js");
3423
3423
  if (!input) {
3424
3424
  return runCommand(command, services, async (model) => {
3425
- const { nonInteractivePreview } = await import("./preview-VAHHFTRZ.js");
3425
+ const { nonInteractivePreview } = await import("./preview-YEREVN42.js");
3426
3426
  return nonInteractivePreview(
3427
3427
  { siteId: site, baseUrl },
3428
3428
  model,
@@ -3430,7 +3430,7 @@ var previewCommand = (services) => {
3430
3430
  );
3431
3431
  });
3432
3432
  }
3433
- const { PreviewCommand } = await import("./PreviewCommand-3OMHWDW6.js");
3433
+ const { PreviewCommand } = await import("./PreviewCommand-CU46IAJE.js");
3434
3434
  await renderCommand(
3435
3435
  command,
3436
3436
  services,
@@ -3462,8 +3462,8 @@ var createVersionCommand = (services) => {
3462
3462
  validateBase
3463
3463
  ).action(async (options, command) => {
3464
3464
  const { VersionType } = await import("./types.impl-CD4WWRUK.js");
3465
- const { renderCommand } = await import("./render-command-3AYSQXHN.js");
3466
- const { CreateVersionCommand } = await import("./CreateVersionCommand-Z6F5IKH5.js");
3465
+ const { renderCommand } = await import("./render-command-H5DHMFOD.js");
3466
+ const { CreateVersionCommand } = await import("./CreateVersionCommand-27X5XRUT.js");
3467
3467
  const {
3468
3468
  approvePreview = false,
3469
3469
  versionType: versionTypeString,
@@ -3495,8 +3495,8 @@ var createVersionCommand = (services) => {
3495
3495
  init_esm_shims();
3496
3496
  var import_react4 = __toESM(require_react(), 1);
3497
3497
  var serveCommand = (services) => createCommand("serve").action(async (_, command) => {
3498
- const { renderCommand } = await import("./render-command-3AYSQXHN.js");
3499
- const { ServeCommand } = await import("./ServeCommand-G4FF4PT3.js");
3498
+ const { renderCommand } = await import("./render-command-H5DHMFOD.js");
3499
+ const { ServeCommand } = await import("./ServeCommand-LXJK73IU.js");
3500
3500
  await renderCommand(command, services, /* @__PURE__ */ import_react4.default.createElement(ServeCommand, null));
3501
3501
  });
3502
3502
 
@@ -3506,8 +3506,8 @@ var import_react5 = __toESM(require_react(), 1);
3506
3506
  var generateCommand = (services) => {
3507
3507
  const t = createI18nT();
3508
3508
  return createCommand("generate").description(t("generate_command.description")).action(async (options, command) => {
3509
- const { GenerateCommand } = await import("./GenerateCommand-KCV4YDNN.js");
3510
- const { renderCommand } = await import("./render-command-3AYSQXHN.js");
3509
+ const { GenerateCommand } = await import("./GenerateCommand-7IAUS6BH.js");
3510
+ const { renderCommand } = await import("./render-command-H5DHMFOD.js");
3511
3511
  await renderCommand(command, services, /* @__PURE__ */ import_react5.default.createElement(GenerateCommand, null), {
3512
3512
  skipProjectValidation: true
3513
3513
  });
@@ -3525,8 +3525,8 @@ var logsCommand = (services) => {
3525
3525
  validateVersion
3526
3526
  ).action(async (options, command) => {
3527
3527
  const { version: version2 } = options;
3528
- const { renderCommand } = await import("./render-command-3AYSQXHN.js");
3529
- const { LogsCommand } = await import("./LogsCommand-VBMGVYNU.js");
3528
+ const { renderCommand } = await import("./render-command-H5DHMFOD.js");
3529
+ const { LogsCommand } = await import("./LogsCommand-WPUUN3JU.js");
3530
3530
  await renderCommand(command, services, /* @__PURE__ */ import_react6.default.createElement(LogsCommand, { version: version2 }));
3531
3531
  });
3532
3532
  };
@@ -3545,8 +3545,8 @@ var releaseCommand = (services) => {
3545
3545
  t("release_command_def.option.base_url"),
3546
3546
  validateBase
3547
3547
  ).action(async (options, command) => {
3548
- const { renderCommand } = await import("./render-command-3AYSQXHN.js");
3549
- const { ReleaseCommand } = await import("./ReleaseCommand-5F3FPBXT.js");
3548
+ const { renderCommand } = await import("./render-command-H5DHMFOD.js");
3549
+ const { ReleaseCommand } = await import("./ReleaseCommand-KTVVW67B.js");
3550
3550
  const { baseUrl, site } = options;
3551
3551
  await renderCommand(
3552
3552
  command,
@@ -0,0 +1,2 @@
1
+ import{wixContext as n}from"@wix/sdk-context";function d(o,t){return(...i)=>{let e=x();return e?e.initWixModules(o,t).apply(void 0,i):o.apply(void 0,i)}}function x(){let o=typeof $wixContext<"u"&&$wixContext.initWixModules?$wixContext.initWixModules:typeof globalThis.__wix_context__<"u"&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(o)return{initWixModules(e,l){return r(()=>o(e,l))},fetchWithAuth(){throw new Error("fetchWithAuth is not available in this context")},graphql(){throw new Error("graphql is not available in this context")}};let t=typeof $wixContext<"u"?$wixContext.client:typeof n.client<"u"?n.client:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.client:void 0,i=typeof $wixContext<"u"?$wixContext.elevatedClient:typeof n.elevatedClient<"u"?n.elevatedClient:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.elevatedClient:void 0;if(!(!t&&!i))return{initWixModules(e,l){if(l){if(!i)throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");return r(()=>i.use(e))}if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return r(()=>t.use(e))},fetchWithAuth:(e,l)=>{if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.fetchWithAuth(e,l)},async graphql(e,l,u){if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.graphql(e,l,u)}}}function r(o){let t=globalThis.__wix_context__,i={client:n.client,elevatedClient:n.elevatedClient},e;globalThis.__wix_context__=void 0,n.client=void 0,n.elevatedClient=void 0,typeof $wixContext<"u"&&(e={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return o()}finally{globalThis.__wix_context__=t,n.client=i.client,n.elevatedClient=i.elevatedClient,typeof $wixContext<"u"&&($wixContext.client=e.client,$wixContext.elevatedClient=e.elevatedClient)}}export{d as a,r as b};
2
+ //# sourceMappingURL=chunk-BGTZ3RNN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context-v2.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,mBCmBpB,SAASC,EAA0BC,EAAYC,EAAU,CAC5D,MAAQ,IAAIC,IAAS,CACjB,IAAMC,EAAUC,EAAe,EAC/B,OAAKD,EAIGA,EACH,eAAeH,EAAYC,CAAQ,EAEnC,MAAM,OAAWC,CAAI,EALfF,EAAW,MAAM,OAAWE,CAAI,CAM/C,CACJ,CD9BO,SAASG,GAAiB,CAC7B,IAAMC,EAAa,OAAO,YAAgB,KAAe,YAAY,eAC/D,YAAY,eACZ,OAAO,WAAW,gBAAoB,KACpC,WAAW,gBAAgB,eACzB,WAAW,gBAAgB,eAC3B,OACV,GAAIA,EACA,MAAO,CAEH,eAAeC,EAASC,EAAU,CAC9B,OAAOC,EAAkB,IAAMH,EAAWC,EAASC,CAAQ,CAAC,CAChE,EACA,eAAgB,CACZ,MAAM,IAAI,MAAM,gDAAgD,CACpE,EACA,SAAU,CACN,MAAM,IAAI,MAAM,0CAA0C,CAC9D,CACJ,EAEJ,IAAME,EAAmB,OAAO,YAAgB,IAC1C,YAAY,OACZ,OAAOC,EAAW,OAAW,IACzBA,EAAW,OACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,OAC3B,OACRC,EAAiB,OAAO,YAAgB,IACxC,YAAY,eACZ,OAAOD,EAAW,eAAmB,IACjCA,EAAW,eACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,eAC3B,OACd,GAAI,GAACD,GAAoB,CAACE,GAG1B,MAAO,CACH,eAAeC,EAAYL,EAAU,CACjC,GAAIA,EAAU,CACV,GAAI,CAACI,EACD,MAAM,IAAI,MAAM,2JAA2J,EAE/K,OAAOH,EAAkB,IAAMG,EAAe,IAAIC,CAAU,CAAC,CACjE,CACA,GAAI,CAACH,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOD,EAAkB,IAAMC,EAAiB,IAAIG,CAAU,CAAC,CACnE,EACA,cAAe,CAACC,EAAcC,IAAgB,CAC1C,GAAI,CAACL,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,cAAcI,EAAcC,CAAW,CACnE,EACA,MAAM,QAAQC,EAAOC,EAAWC,EAAM,CAClC,GAAI,CAACR,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,QAAQM,EAAOC,EAAWC,CAAI,CAC1D,CACJ,CACJ,CAwCO,SAASC,EAAkBC,EAAI,CAClC,IAAMC,EAAgB,WAAW,gBAC3BC,EAAgB,CAClB,OAAQC,EAAW,OACnB,eAAgBA,EAAW,cAC/B,EACIC,EACJ,WAAW,gBAAkB,OAC7BD,EAAW,OAAS,OACpBA,EAAW,eAAiB,OACxB,OAAO,YAAgB,MACvBC,EAAiB,CACb,OAAQ,aAAa,OACrB,eAAgB,aAAa,cACjC,EACA,OAAO,YAAY,OACnB,OAAO,YAAY,gBAEvB,GAAI,CACA,OAAOJ,EAAG,CACd,QACA,CACI,WAAW,gBAAkBC,EAC7BE,EAAW,OAASD,EAAc,OAClCC,EAAW,eAAiBD,EAAc,eACtC,OAAO,YAAgB,MACvB,YAAY,OAASE,EAAe,OACpC,YAAY,eAAiBA,EAAe,eAEpD,CACJ","names":["wixContext","contextualizeRESTModuleV2","restModule","elevated","args","context","resolveContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","wixContext","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext"]}
@@ -1,2 +1,2 @@
1
- import{a as t}from"./chunk-42XIZ4MH.js";function i(e){return t({__type:"host",create:r=>Object.entries(e).reduce((o,[c,n])=>({...o,[c]:n(r)}),{})},Object.keys(e))}export{i as a};
2
- //# sourceMappingURL=chunk-QV4VBCJB.js.map
1
+ import{a as t}from"./chunk-NAPHVUFM.js";function i(e){return t({__type:"host",create:r=>Object.entries(e).reduce((o,[c,n])=>({...o,[c]:n(r)}),{})},Object.keys(e))}export{i as a};
2
+ //# sourceMappingURL=chunk-FWUYJ3UR.js.map
@@ -0,0 +1,2 @@
1
+ import{wixContext as l}from"@wix/sdk-context";function x(){let i=typeof $wixContext<"u"&&$wixContext.initWixModules?$wixContext.initWixModules:typeof globalThis.__wix_context__<"u"&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(i)return{initWixModules(e,o){return r(()=>i(e,o))},fetchWithAuth(){throw new Error("fetchWithAuth is not available in this context")},graphql(){throw new Error("graphql is not available in this context")}};let t=typeof $wixContext<"u"?$wixContext.client:typeof l.client<"u"?l.client:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.client:void 0,n=typeof $wixContext<"u"?$wixContext.elevatedClient:typeof l.elevatedClient<"u"?l.elevatedClient:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.elevatedClient:void 0;if(!(!t&&!n))return{initWixModules(e,o){if(o){if(!n)throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");return r(()=>n.use(e))}if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return r(()=>t.use(e))},fetchWithAuth:(e,o)=>{if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.fetchWithAuth(e,o)},async graphql(e,o,u){if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.graphql(e,o,u)}}}function r(i){let t=globalThis.__wix_context__,n={client:l.client,elevatedClient:l.elevatedClient},e;globalThis.__wix_context__=void 0,l.client=void 0,l.elevatedClient=void 0,typeof $wixContext<"u"&&(e={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return i()}finally{globalThis.__wix_context__=t,l.client=n.client,l.elevatedClient=n.elevatedClient,typeof $wixContext<"u"&&($wixContext.client=e.client,$wixContext.elevatedClient=e.elevatedClient)}}function f(i,t){return{...i,...Object.fromEntries(t.map(n=>[n,(...e)=>{let o=x();if(!o)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return o.initWixModules(i)[n].apply(void 0,e)}]))}}function p(i,t){return(...n)=>{let e=x();return e?e.initWixModules(i,t).apply(void 0,n):i.apply(void 0,n)}}export{f as a,p as b};
2
+ //# sourceMappingURL=chunk-NAPHVUFM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/sdk-runtime/build/context-v2.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,mBCGpB,SAASC,EAA0BC,EAAYC,EAAO,CACzD,MAAO,CACH,GAAGD,EACH,GAAG,OAAO,YAAYC,EAAM,IAAKC,GAAS,CACtCA,EACA,IAAIC,IAAS,CACT,IAAMC,EAAUC,EAAe,EAC/B,GAAI,CAACD,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EACF,eAAeJ,CAAU,EAAEE,CAAI,EAAE,MAAM,OAAWC,CAAI,CAC/D,CACJ,CAAC,CAAC,CACN,CACJ,CACO,SAASG,EAA0BC,EAAYC,EAAU,CAC5D,MAAQ,IAAIL,IAAS,CACjB,IAAMC,EAAUC,EAAe,EAC/B,OAAKD,EAIGA,EACH,eAAeG,EAAYC,CAAQ,EAEnC,MAAM,OAAWL,CAAI,EALfI,EAAW,MAAM,OAAWJ,CAAI,CAM/C,CACJ,CD9BO,SAASM,GAAiB,CAC7B,IAAMC,EAAa,OAAO,YAAgB,KAAe,YAAY,eAC/D,YAAY,eACZ,OAAO,WAAW,gBAAoB,KACpC,WAAW,gBAAgB,eACzB,WAAW,gBAAgB,eAC3B,OACV,GAAIA,EACA,MAAO,CAEH,eAAeC,EAASC,EAAU,CAC9B,OAAOC,EAAkB,IAAMH,EAAWC,EAASC,CAAQ,CAAC,CAChE,EACA,eAAgB,CACZ,MAAM,IAAI,MAAM,gDAAgD,CACpE,EACA,SAAU,CACN,MAAM,IAAI,MAAM,0CAA0C,CAC9D,CACJ,EAEJ,IAAME,EAAmB,OAAO,YAAgB,IAC1C,YAAY,OACZ,OAAOC,EAAW,OAAW,IACzBA,EAAW,OACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,OAC3B,OACRC,EAAiB,OAAO,YAAgB,IACxC,YAAY,eACZ,OAAOD,EAAW,eAAmB,IACjCA,EAAW,eACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,eAC3B,OACd,GAAI,GAACD,GAAoB,CAACE,GAG1B,MAAO,CACH,eAAeC,EAAYL,EAAU,CACjC,GAAIA,EAAU,CACV,GAAI,CAACI,EACD,MAAM,IAAI,MAAM,2JAA2J,EAE/K,OAAOH,EAAkB,IAAMG,EAAe,IAAIC,CAAU,CAAC,CACjE,CACA,GAAI,CAACH,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOD,EAAkB,IAAMC,EAAiB,IAAIG,CAAU,CAAC,CACnE,EACA,cAAe,CAACC,EAAcC,IAAgB,CAC1C,GAAI,CAACL,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,cAAcI,EAAcC,CAAW,CACnE,EACA,MAAM,QAAQC,EAAOC,EAAWC,EAAM,CAClC,GAAI,CAACR,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,QAAQM,EAAOC,EAAWC,CAAI,CAC1D,CACJ,CACJ,CAwCO,SAASC,EAAkBC,EAAI,CAClC,IAAMC,EAAgB,WAAW,gBAC3BC,EAAgB,CAClB,OAAQC,EAAW,OACnB,eAAgBA,EAAW,cAC/B,EACIC,EACJ,WAAW,gBAAkB,OAC7BD,EAAW,OAAS,OACpBA,EAAW,eAAiB,OACxB,OAAO,YAAgB,MACvBC,EAAiB,CACb,OAAQ,aAAa,OACrB,eAAgB,aAAa,cACjC,EACA,OAAO,YAAY,OACnB,OAAO,YAAY,gBAEvB,GAAI,CACA,OAAOJ,EAAG,CACd,QACA,CACI,WAAW,gBAAkBC,EAC7BE,EAAW,OAASD,EAAc,OAClCC,EAAW,eAAiBD,EAAc,eACtC,OAAO,YAAgB,MACvB,YAAY,OAASE,EAAe,OACpC,YAAY,eAAiBA,EAAe,eAEpD,CACJ","names":["wixContext","contextualizeHostModuleV2","hostModule","props","prop","args","context","resolveContext","contextualizeRESTModuleV2","restModule","elevated","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","wixContext","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext"]}
1
+ {"version":3,"sources":["../../../node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/sdk-runtime/build/context-v2.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,mBACpB,SAASC,GAAiB,CAC7B,IAAMC,EAAa,OAAO,YAAgB,KAAe,YAAY,eAC/D,YAAY,eACZ,OAAO,WAAW,gBAAoB,KACpC,WAAW,gBAAgB,eACzB,WAAW,gBAAgB,eAC3B,OACV,GAAIA,EACA,MAAO,CAEH,eAAeC,EAASC,EAAU,CAC9B,OAAOC,EAAkB,IAAMH,EAAWC,EAASC,CAAQ,CAAC,CAChE,EACA,eAAgB,CACZ,MAAM,IAAI,MAAM,gDAAgD,CACpE,EACA,SAAU,CACN,MAAM,IAAI,MAAM,0CAA0C,CAC9D,CACJ,EAEJ,IAAME,EAAmB,OAAO,YAAgB,IAC1C,YAAY,OACZ,OAAON,EAAW,OAAW,IACzBA,EAAW,OACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,OAC3B,OACRO,EAAiB,OAAO,YAAgB,IACxC,YAAY,eACZ,OAAOP,EAAW,eAAmB,IACjCA,EAAW,eACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,eAC3B,OACd,GAAI,GAACM,GAAoB,CAACC,GAG1B,MAAO,CACH,eAAeC,EAAYJ,EAAU,CACjC,GAAIA,EAAU,CACV,GAAI,CAACG,EACD,MAAM,IAAI,MAAM,2JAA2J,EAE/K,OAAOF,EAAkB,IAAME,EAAe,IAAIC,CAAU,CAAC,CACjE,CACA,GAAI,CAACF,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOD,EAAkB,IAAMC,EAAiB,IAAIE,CAAU,CAAC,CACnE,EACA,cAAe,CAACC,EAAcC,IAAgB,CAC1C,GAAI,CAACJ,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,cAAcG,EAAcC,CAAW,CACnE,EACA,MAAM,QAAQC,EAAOC,EAAWC,EAAM,CAClC,GAAI,CAACP,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,QAAQK,EAAOC,EAAWC,CAAI,CAC1D,CACJ,CACJ,CAwCO,SAASC,EAAkBC,EAAI,CAClC,IAAMC,EAAgB,WAAW,gBAC3BC,EAAgB,CAClB,OAAQC,EAAW,OACnB,eAAgBA,EAAW,cAC/B,EACIC,EACJ,WAAW,gBAAkB,OAC7BD,EAAW,OAAS,OACpBA,EAAW,eAAiB,OACxB,OAAO,YAAgB,MACvBC,EAAiB,CACb,OAAQ,aAAa,OACrB,eAAgB,aAAa,cACjC,EACA,OAAO,YAAY,OACnB,OAAO,YAAY,gBAEvB,GAAI,CACA,OAAOJ,EAAG,CACd,QACA,CACI,WAAW,gBAAkBC,EAC7BE,EAAW,OAASD,EAAc,OAClCC,EAAW,eAAiBD,EAAc,eACtC,OAAO,YAAgB,MACvB,YAAY,OAASE,EAAe,OACpC,YAAY,eAAiBA,EAAe,eAEpD,CACJ,CCpIO,SAASC,EAA0BC,EAAYC,EAAO,CACzD,MAAO,CACH,GAAGD,EACH,GAAG,OAAO,YAAYC,EAAM,IAAKC,GAAS,CACtCA,EACA,IAAIC,IAAS,CACT,IAAMC,EAAUC,EAAe,EAC/B,GAAI,CAACD,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EACF,eAAeJ,CAAU,EAAEE,CAAI,EAAE,MAAM,OAAWC,CAAI,CAC/D,CACJ,CAAC,CAAC,CACN,CACJ,CACO,SAASG,EAA0BC,EAAYC,EAAU,CAC5D,MAAQ,IAAIL,IAAS,CACjB,IAAMC,EAAUC,EAAe,EAC/B,OAAKD,EAIGA,EACH,eAAeG,EAAYC,CAAQ,EAEnC,MAAM,OAAWL,CAAI,EALfI,EAAW,MAAM,OAAWJ,CAAI,CAM/C,CACJ","names":["wixContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext","contextualizeHostModuleV2","hostModule","props","prop","args","context","resolveContext","contextualizeRESTModuleV2","restModule","elevated"]}
@@ -1,2 +1,2 @@
1
- import{c as x}from"./chunk-42XIZ4MH.js";import{a as b,b as A,d as H}from"./chunk-7EYXEF6M.js";import{f as v}from"./chunk-SBZEOPXX.js";H();import{wixContext as N}from"@wix/sdk-context";var B=e=>{switch(e){case"get":case"GET":return"GET";case"post":case"POST":return"POST";case"put":case"PUT":return"PUT";case"delete":case"DELETE":return"DELETE";case"patch":case"PATCH":return"PATCH";case"head":case"HEAD":return"HEAD";case"options":case"OPTIONS":return"OPTIONS";default:throw new Error(`Unknown method: ${e}`)}},P=e=>a=>async s=>{let d,r=t=>{if(d=e(s)(t),d.url===void 0)throw new Error("Url was not successfully created for this request, please reach out to support channels for assistance.");let{method:i,url:o,params:p}=d;return{...d,method:B(i),url:o,data:d.data,params:p}};try{let t=await a.request(r);if(d===void 0)throw new Error("Request options were not created for this request, please reach out to support channels for assistance.");let i=Array.isArray(d.transformResponse)?d.transformResponse:[d.transformResponse],o=t.data;return i.forEach(p=>{p&&(o=p(t.data,t.headers))}),o}catch(t){throw typeof t=="object"&&t!==null&&"response"in t&&typeof t.response=="object"&&t.response!==null&&"data"in t.response?t.response.data:t}},M=e=>e.__isAmbassador?!0:!!e().__isAmbassador;var R="__metadata",w="www.wixapis.com";var g=class extends Error{constructor(s,d){super(s);v(this,"message");v(this,"response");this.message=s,this.response=d}async details(){let s=await this.response.json();return D(this.response.status,s?.message,s?.details,{requestId:this.response.headers.get("X-Wix-Request-Id"),details:s})}},D=(e,a,s,d)=>({details:{...!s?.validationError&&{applicationError:{description:a,code:e,data:d}},...s},message:a});var C=e=>e?.method&&["post","put","patch"].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":"application/json"}:{},U=e=>e&&typeof e=="object"&&!Array.isArray(e);var j=e=>e.__type==="host";function S(e,a){return e.create(a)}var G="x-wix-bi-gateway";function W(e,a,s){return{[G]:F({environment:`js-sdk${s?`-${s}`:""}`,"package-name":e.packageName??a?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function F(e){return Object.entries(e).filter(([a,s])=>!!s).map(([a,s])=>`${a}=${s}`).join(",")}function I(e,a,s,d,r,t,i){return x(()=>e({request:async o=>{let p=o({host:t?.HTTPHost||w}),c=p;c.method==="GET"&&c.fallback?.length&&c.params.toString().length>4e3&&(c=p.fallback[0]);let y=`https://${t?.HTTPHost??w}${c.url}`;c.params&&c.params.toString()&&(y+=`?${c.params.toString()}`);try{let u=W(p,a,i),n=await s(y,{method:c.method,...c.data&&{body:JSON.stringify(c.data)},headers:{...u}});if(n.status!==200){let h=null;try{h=await n.json()}catch{}throw V(n.status,h?.message,h?.details,{requestId:n.headers.get("X-Wix-Request-Id"),details:h})}return{data:await n.json(),headers:n.headers,status:n.status,statusText:n.statusText}}catch(u){throw u.message?.includes("fetch is not defined")&&console.error("Node.js v18+ is required"),u}},fetchWithAuth:s,wixAPIFetch:d,getActiveToken:r}))}var V=(e,a,s,d)=>({response:{data:{details:{...!s?.validationError&&{applicationError:{description:a,code:e,data:d}},...s},message:a},status:e}});H();function _(){return{emit(e,...a){for(let s=0,d=this.events[e]||[],r=d.length;s<r;s++)d[s](...a)},events:{},on(e,a){return(this.events[e]||=[]).push(a),()=>{this.events[e]=this.events[e]?.filter(s=>a!==s)}}}}var J=e=>e.__type==="event-definition";function $(e,a,s,d){let r;if(e.isDomainEvent){let i=s,{deletedEvent:o,actionEvent:p,createdEvent:c,updatedEvent:f,...y}=i,u={...d,...y};o?o?.deletedEntity?r={entity:o?.deletedEntity,metadata:u}:r={metadata:u}:p?r={data:p.body,metadata:u}:r={entity:c?.entity??f?.currentEntity,metadata:u}}else r={data:s,metadata:d};let t=e.transformations??(i=>i);return a(t(r))}function L(e){let a=new Map,s=_(),d={...s,getRegisteredEvents:()=>a,async process(r,t={expectedEvents:[]}){let{eventType:i,identity:o,instanceId:p,payload:c}=await this.parseJWT(r),f=[...t.expectedEvents,...Array.from(a.keys()).map(u=>({type:u}))];if(f.length>0&&!f.some(({type:u})=>u===i))throw new Error(`Unexpected event type: ${i}. Expected one of: ${f.map(u=>u.type).join(", ")}`);let y=a.get(i)??[];return await Promise.all(y.map(({eventDefinition:u,handler:n})=>$(u,n,c,{instanceId:p,identity:o}))),{instanceId:p,eventType:i,payload:c,identity:o}},async processRequest(r,t){let i=await r.text();return this.process(i,t)},async parseJWT(r){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:t,valid:i}=await e.decodeJWT(r);if(!i)throw new Error("JWT is not valid");if(typeof t.data!="string")throw new Error(`Unexpected type of JWT data: expected string, got ${typeof t.data}`);let o=JSON.parse(t.data),p=o.eventType,c=o.instanceId,f=o.identity?JSON.parse(o.identity):void 0,y=JSON.parse(o.data);return{instanceId:c,eventType:p,payload:y,identity:f}},async parseRequest(r){let t=await r.text();return this.parseJWT(t)},async executeHandlers(r){let t=Array.from(a.keys()).map(o=>({type:o}));if(t.length>0&&!t.some(({type:o})=>o===r.eventType))throw new Error(`Unexpected event type: ${r.eventType}. Expected one of: ${t.map(o=>o.type).join(", ")}`);let i=a.get(r.eventType)??[];await Promise.all(i.map(({eventDefinition:o,handler:p})=>$(o,p,r.payload,{instanceId:r.instanceId,identity:r.identity})))},apps:{AppInstalled:b("AppInstalled")(),AppRemoved:b("AppRemoved")()}};return{initModule(r){return t=>{let i=a.get(r.type)??[];i.push({eventDefinition:r,handler:t}),a.set(r.type,i),s.emit("registered",r)}},client:d}}var O=e=>e.__type==="service-plugin-definition";function q(e){let a=new Map,s=_(),d={...s,getRegisteredServicePlugins:()=>a,async parseJWT(r){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:t,valid:i}=await e.decodeJWT(r,!0);if(!i)throw new Error("JWT is not valid");if(typeof t.data!="object"||t.data===null||!("metadata"in t.data)||typeof t.data.metadata!="object"||t.data.metadata===null||!("appExtensionType"in t.data.metadata)||typeof t.data.metadata.appExtensionType!="string")throw new Error("Unexpected JWT data: expected object with metadata.appExtensionType string");return t.data},async process(r){let t=await this.parseJWT(r.body);return this.executeHandler(t,r.url)},async parseRequest(r){let t=await r.text();return this.parseJWT(t)},async processRequest(r){let t=r.url,i=await r.text();try{let o=await this.process({url:t,body:i});return Response.json(o)}catch(o){if(o.errorType==="SPI"&&o.applicationCode&&o.httpCode)return Response.json({applicationError:{code:o.applicationCode,data:o.data}},{status:o.httpCode});throw o}},async executeHandler(r,t){let i=r.metadata.appExtensionType.toLowerCase(),o=a.get(i)??[];if(o.length===0)throw new Error(`No service plugin implementations found for component type ${i}`);if(o.length>1)throw new Error(`Multiple service plugin implementations found for component type ${i}. This is currently not supported`);let{implementation:p,servicePluginDefinition:c}=o[0],f=c.methods.find(u=>t.endsWith(u.primaryHttpMappingPath));if(!f)throw new Error("Unexpect request: request url did not match any method: "+t);let y=p[f.name];if(!y)throw new Error(`Got request for service plugin method ${f.name} but no implementation was provided. Available methods: ${Object.keys(p).join(", ")}`);return f.transformations.toREST(await y(f.transformations.fromREST(r)))}};return{initModule(r){return t=>{let i=a.get(r.componentType.toLowerCase())??[];i.push({servicePluginDefinition:r,implementation:t}),a.set(r.componentType.toLowerCase(),i),s.emit("registered",r)}},client:d}}function _e(e){let a=e.headers||{Authorization:""},s=e.auth||{getAuthHeaders:n=>Promise.resolve({headers:{}})},d=s.getAuthHeaders.bind(void 0,e.host);s.getAuthHeaders=d;let r=async(n,l)=>{if(typeof n=="string"||n instanceof URL)return fetch(n,{...l,headers:{...l?.headers,...(await d()).headers}});for(let[h,m]of Object.entries((await d()).headers))n.headers.set(h,m);return fetch(n,l)},{client:t,initModule:i}=q(s),{client:o,initModule:p}=L(s),c=async(n,l)=>{let h=await d(),m=C(l);return fetch(n,{...l,headers:{...m,...a,...h?.headers,...l?.headers,...e.host?.essentials?.passThroughHeaders}})},f=(n,l)=>{if(J(n))return p(n);if(O(n))return i(n);if(j(n)&&e.host)return S(n,e.host);if(typeof n=="function"){if("__type"in n&&n.__type===A)return n;let h=e.host?.apiBaseUrl??w;return I(x(()=>M(n))?P(n):n,l??{},c,(m,E)=>{let T=new URL(m,`https://${h}`);return T.host=h,T.protocol="https",c(T.toString(),E)},s.getActiveToken,{HTTPHost:h},e.host?.name)}else return U(n)?Object.fromEntries(Object.entries(n).map(([h,m])=>[h,f(m,n[R])])):n},y=n=>{for(let l in n)a[l]=n[l]};return{...e.modules?f(e.modules):{},auth:s,setHeaders:y,use:f,enableContext(n,l={elevated:!1}){n==="global"?globalThis.__wix_context__!=null?l.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:l.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:l.elevated?N.elevatedClient=this:N.client=this},fetch:(n,l)=>{let h=e.host?.apiBaseUrl??w,m=new URL(n,`https://${h}`);return m.host=h,m.protocol="https",c(m.toString(),l)},fetchWithAuth:r,async graphql(n,l,h={apiVersion:"alpha"}){let m=e?.host?.apiBaseUrl??w,E=await c(`https://${m}/graphql/${h.apiVersion}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n,variables:l})});if(E.status!==200)throw new g(`GraphQL request failed with status ${E.status}`,E);let{data:T,errors:k}=await E.json();return{data:T??{},errors:k}},webhooks:o,servicePlugins:t}}export{_e as a};
2
- //# sourceMappingURL=chunk-EERHWVVD.js.map
1
+ import{b as x}from"./chunk-BGTZ3RNN.js";import{a as b,b as A,d as H}from"./chunk-7EYXEF6M.js";import{f as v}from"./chunk-SBZEOPXX.js";H();import{wixContext as N}from"@wix/sdk-context";var B=e=>{switch(e){case"get":case"GET":return"GET";case"post":case"POST":return"POST";case"put":case"PUT":return"PUT";case"delete":case"DELETE":return"DELETE";case"patch":case"PATCH":return"PATCH";case"head":case"HEAD":return"HEAD";case"options":case"OPTIONS":return"OPTIONS";default:throw new Error(`Unknown method: ${e}`)}},P=e=>a=>async s=>{let d,r=t=>{if(d=e(s)(t),d.url===void 0)throw new Error("Url was not successfully created for this request, please reach out to support channels for assistance.");let{method:i,url:o,params:p}=d;return{...d,method:B(i),url:o,data:d.data,params:p}};try{let t=await a.request(r);if(d===void 0)throw new Error("Request options were not created for this request, please reach out to support channels for assistance.");let i=Array.isArray(d.transformResponse)?d.transformResponse:[d.transformResponse],o=t.data;return i.forEach(p=>{p&&(o=p(t.data,t.headers))}),o}catch(t){throw typeof t=="object"&&t!==null&&"response"in t&&typeof t.response=="object"&&t.response!==null&&"data"in t.response?t.response.data:t}},M=e=>e.__isAmbassador?!0:!!e().__isAmbassador;var R="__metadata",w="www.wixapis.com";var g=class extends Error{constructor(s,d){super(s);v(this,"message");v(this,"response");this.message=s,this.response=d}async details(){let s=await this.response.json();return D(this.response.status,s?.message,s?.details,{requestId:this.response.headers.get("X-Wix-Request-Id"),details:s})}},D=(e,a,s,d)=>({details:{...!s?.validationError&&{applicationError:{description:a,code:e,data:d}},...s},message:a});var C=e=>e?.method&&["post","put","patch"].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":"application/json"}:{},U=e=>e&&typeof e=="object"&&!Array.isArray(e);var j=e=>e.__type==="host";function S(e,a){return e.create(a)}var G="x-wix-bi-gateway";function W(e,a,s){return{[G]:F({environment:`js-sdk${s?`-${s}`:""}`,"package-name":e.packageName??a?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function F(e){return Object.entries(e).filter(([a,s])=>!!s).map(([a,s])=>`${a}=${s}`).join(",")}function I(e,a,s,d,r,t,i){return x(()=>e({request:async o=>{let p=o({host:t?.HTTPHost||w}),c=p;c.method==="GET"&&c.fallback?.length&&c.params.toString().length>4e3&&(c=p.fallback[0]);let y=`https://${t?.HTTPHost??w}${c.url}`;c.params&&c.params.toString()&&(y+=`?${c.params.toString()}`);try{let u=W(p,a,i),n=await s(y,{method:c.method,...c.data&&{body:JSON.stringify(c.data)},headers:{...u}});if(n.status!==200){let h=null;try{h=await n.json()}catch{}throw V(n.status,h?.message,h?.details,{requestId:n.headers.get("X-Wix-Request-Id"),details:h})}return{data:await n.json(),headers:n.headers,status:n.status,statusText:n.statusText}}catch(u){throw u.message?.includes("fetch is not defined")&&console.error("Node.js v18+ is required"),u}},fetchWithAuth:s,wixAPIFetch:d,getActiveToken:r}))}var V=(e,a,s,d)=>({response:{data:{details:{...!s?.validationError&&{applicationError:{description:a,code:e,data:d}},...s},message:a},status:e}});H();function _(){return{emit(e,...a){for(let s=0,d=this.events[e]||[],r=d.length;s<r;s++)d[s](...a)},events:{},on(e,a){return(this.events[e]||=[]).push(a),()=>{this.events[e]=this.events[e]?.filter(s=>a!==s)}}}}var J=e=>e.__type==="event-definition";function $(e,a,s,d){let r;if(e.isDomainEvent){let i=s,{deletedEvent:o,actionEvent:p,createdEvent:c,updatedEvent:f,...y}=i,u={...d,...y};o?o?.deletedEntity?r={entity:o?.deletedEntity,metadata:u}:r={metadata:u}:p?r={data:p.body,metadata:u}:r={entity:c?.entity??f?.currentEntity,metadata:u}}else r={data:s,metadata:d};let t=e.transformations??(i=>i);return a(t(r))}function L(e){let a=new Map,s=_(),d={...s,getRegisteredEvents:()=>a,async process(r,t={expectedEvents:[]}){let{eventType:i,identity:o,instanceId:p,payload:c}=await this.parseJWT(r),f=[...t.expectedEvents,...Array.from(a.keys()).map(u=>({type:u}))];if(f.length>0&&!f.some(({type:u})=>u===i))throw new Error(`Unexpected event type: ${i}. Expected one of: ${f.map(u=>u.type).join(", ")}`);let y=a.get(i)??[];return await Promise.all(y.map(({eventDefinition:u,handler:n})=>$(u,n,c,{instanceId:p,identity:o}))),{instanceId:p,eventType:i,payload:c,identity:o}},async processRequest(r,t){let i=await r.text();return this.process(i,t)},async parseJWT(r){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:t,valid:i}=await e.decodeJWT(r);if(!i)throw new Error("JWT is not valid");if(typeof t.data!="string")throw new Error(`Unexpected type of JWT data: expected string, got ${typeof t.data}`);let o=JSON.parse(t.data),p=o.eventType,c=o.instanceId,f=o.identity?JSON.parse(o.identity):void 0,y=JSON.parse(o.data);return{instanceId:c,eventType:p,payload:y,identity:f}},async parseRequest(r){let t=await r.text();return this.parseJWT(t)},async executeHandlers(r){let t=Array.from(a.keys()).map(o=>({type:o}));if(t.length>0&&!t.some(({type:o})=>o===r.eventType))throw new Error(`Unexpected event type: ${r.eventType}. Expected one of: ${t.map(o=>o.type).join(", ")}`);let i=a.get(r.eventType)??[];await Promise.all(i.map(({eventDefinition:o,handler:p})=>$(o,p,r.payload,{instanceId:r.instanceId,identity:r.identity})))},apps:{AppInstalled:b("AppInstalled")(),AppRemoved:b("AppRemoved")()}};return{initModule(r){return t=>{let i=a.get(r.type)??[];i.push({eventDefinition:r,handler:t}),a.set(r.type,i),s.emit("registered",r)}},client:d}}var O=e=>e.__type==="service-plugin-definition";function q(e){let a=new Map,s=_(),d={...s,getRegisteredServicePlugins:()=>a,async parseJWT(r){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:t,valid:i}=await e.decodeJWT(r,!0);if(!i)throw new Error("JWT is not valid");if(typeof t.data!="object"||t.data===null||!("metadata"in t.data)||typeof t.data.metadata!="object"||t.data.metadata===null||!("appExtensionType"in t.data.metadata)||typeof t.data.metadata.appExtensionType!="string")throw new Error("Unexpected JWT data: expected object with metadata.appExtensionType string");return t.data},async process(r){let t=await this.parseJWT(r.body);return this.executeHandler(t,r.url)},async parseRequest(r){let t=await r.text();return this.parseJWT(t)},async processRequest(r){let t=r.url,i=await r.text();try{let o=await this.process({url:t,body:i});return Response.json(o)}catch(o){if(o.errorType==="SPI"&&o.applicationCode&&o.httpCode)return Response.json({applicationError:{code:o.applicationCode,data:o.data}},{status:o.httpCode});throw o}},async executeHandler(r,t){let i=r.metadata.appExtensionType.toLowerCase(),o=a.get(i)??[];if(o.length===0)throw new Error(`No service plugin implementations found for component type ${i}`);if(o.length>1)throw new Error(`Multiple service plugin implementations found for component type ${i}. This is currently not supported`);let{implementation:p,servicePluginDefinition:c}=o[0],f=c.methods.find(u=>t.endsWith(u.primaryHttpMappingPath));if(!f)throw new Error("Unexpect request: request url did not match any method: "+t);let y=p[f.name];if(!y)throw new Error(`Got request for service plugin method ${f.name} but no implementation was provided. Available methods: ${Object.keys(p).join(", ")}`);return f.transformations.toREST(await y(f.transformations.fromREST(r)))}};return{initModule(r){return t=>{let i=a.get(r.componentType.toLowerCase())??[];i.push({servicePluginDefinition:r,implementation:t}),a.set(r.componentType.toLowerCase(),i),s.emit("registered",r)}},client:d}}function _e(e){let a=e.headers||{Authorization:""},s=e.auth||{getAuthHeaders:n=>Promise.resolve({headers:{}})},d=s.getAuthHeaders.bind(void 0,e.host);s.getAuthHeaders=d;let r=async(n,l)=>{if(typeof n=="string"||n instanceof URL)return fetch(n,{...l,headers:{...l?.headers,...(await d()).headers}});for(let[h,m]of Object.entries((await d()).headers))n.headers.set(h,m);return fetch(n,l)},{client:t,initModule:i}=q(s),{client:o,initModule:p}=L(s),c=async(n,l)=>{let h=await d(),m=C(l);return fetch(n,{...l,headers:{...m,...a,...h?.headers,...l?.headers,...e.host?.essentials?.passThroughHeaders}})},f=(n,l)=>{if(J(n))return p(n);if(O(n))return i(n);if(j(n)&&e.host)return S(n,e.host);if(typeof n=="function"){if("__type"in n&&n.__type===A)return n;let h=e.host?.apiBaseUrl??w;return I(x(()=>M(n))?P(n):n,l??{},c,(m,E)=>{let T=new URL(m,`https://${h}`);return T.host=h,T.protocol="https",c(T.toString(),E)},s.getActiveToken,{HTTPHost:h},e.host?.name)}else return U(n)?Object.fromEntries(Object.entries(n).map(([h,m])=>[h,f(m,n[R])])):n},y=n=>{for(let l in n)a[l]=n[l]};return{...e.modules?f(e.modules):{},auth:s,setHeaders:y,use:f,enableContext(n,l={elevated:!1}){n==="global"?globalThis.__wix_context__!=null?l.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:l.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:l.elevated?N.elevatedClient=this:N.client=this},fetch:(n,l)=>{let h=e.host?.apiBaseUrl??w,m=new URL(n,`https://${h}`);return m.host=h,m.protocol="https",c(m.toString(),l)},fetchWithAuth:r,async graphql(n,l,h={apiVersion:"alpha"}){let m=e?.host?.apiBaseUrl??w,E=await c(`https://${m}/graphql/${h.apiVersion}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n,variables:l})});if(E.status!==200)throw new g(`GraphQL request failed with status ${E.status}`,E);let{data:T,errors:k}=await E.json();return{data:T??{},errors:k}},webhooks:o,servicePlugins:t}}export{_e as a};
2
+ //# sourceMappingURL=chunk-XYIDODIB.js.map
@@ -1,2 +1,2 @@
1
- import{a as V}from"./chunk-QV4VBCJB.js";import{a as D}from"./chunk-EERHWVVD.js";import"./chunk-42XIZ4MH.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},S.apply(null,arguments)}import Ee,{useEffect as le,useState as T}from"react";function w(e){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(e)}function N(e,t){if(w(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(w(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function K(e){var t=N(e,"string");return w(t)=="symbol"?t:t+""}function q(e,t,r){return(t=K(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var v=class extends Error{constructor(t){let{message:r,code:n}=t;super(r),q(this,"code",void 0),this.message=r,this.code=n}};var F=()=>{let e=l=>{let{channel:c}=l;return function(){let p=c.showToast(...arguments);return{remove:()=>Promise.resolve(p).then(g=>g.remove())}}},t=l=>{let{channel:c}=l;return function(){let p=c.observeState(...arguments);return{disconnect:()=>Promise.resolve(p).then(g=>g.disconnect())}}};return{showToast:e,observeState:t,navigate:l=>{let{channel:c}=l;return function(){return c.navigate(...arguments)}},navigateBack:l=>{let{channel:c}=l;return()=>c.navigateBack()},openModal:l=>{let{channel:c}=l;return function(){let p=c.openModal(...arguments);return{modalClosed:Promise.resolve(p).then(h=>h.modalClosed)}}},closeModal:l=>{let{channel:c}=l;return p=>{if(p===void 0)return c.closeModal();let h=JSON.parse(JSON.stringify(p));return c.closeModal(h)}},getAccessToken:l=>{let{channel:c}=l;return()=>c.getAccessToken()},getPageUrl:l=>{let{channel:c}=l;return function(){return c.getPageUrl(...arguments)}},openMediaManager:l=>{let{channel:c}=l;return function(){return c.openMediaManager(...arguments)}},addSitePlugin:l=>{let{channel:c}=l;return(p,h)=>{let g="802c76e4-b381-4bb3-9152-96acabbf3194",j=h?.placement||{},H=c.openModal(g,{...j,pluginId:p,action:"populate"});return Promise.resolve(H).then(b=>b.modalClosed).then(b=>{if(b?.type===void 0)throw new v({message:"Aborted by user",code:3006});if(b?.type==="ERROR")throw new v(b.data.error)})}},onBeforeUnload:l=>{let{channel:c}=l;return function(){return c.onBeforeUnload(...arguments)}},setPageTitle:l=>{let{channel:c}=l;return p=>c.setPageTitle(p)},getLanguage:l=>{let c=null;return async()=>{var p;if(c)return c;let h=null;return c=await new Promise(g=>{h=t(l)((j,H)=>{g(H.language)})}),(p=h)==null||p.disconnect(),c}},requestFeedback:l=>{let{channel:c}=l;return function(){return c.requestFeedback(...arguments)}},onLayerStateChange:l=>{let{channel:c}=l;return function(){let p=c.onLayerStateChange(...arguments);return{remove:()=>Promise.resolve(p).then(g=>g.remove())}}}}};var G=e=>{let{createHost:t}=e,r=F();return{...V(r),host:t,auth:()=>({getAuthHeaders:async n=>({headers:{Authorization:await r.getAccessToken(n)()}})})}};var J=(e,t)=>{let r=()=>e.updateHeight(t.offsetHeight),n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()};var X=Symbol("Comlink.proxy"),de=Symbol("Comlink.endpoint"),U=Symbol("Comlink.releaseProxy"),O=Symbol("Comlink.thrown"),Q=e=>typeof e=="object"&&e!==null||typeof e=="function",fe={canHandle:e=>Q(e)&&e[X],serialize(e){let{port1:t,port2:r}=new MessageChannel;return L(e,t),[r,[r]]},deserialize(e){return e.start(),R(e)}},me={canHandle:e=>Q(e)&&O in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},Y=new Map([["proxy",fe],["throw",me]]);function L(e,t=self){t.addEventListener("message",function r(n){if(!n||!n.data)return;let{id:s,type:a,path:o}=Object.assign({path:[]},n.data),i=(n.data.argumentList||[]).map(x),u;try{let d=o.slice(0,-1).reduce((m,y)=>m[y],e),f=o.reduce((m,y)=>m[y],e);switch(a){case 0:u=f;break;case 1:d[o.slice(-1)[0]]=x(n.data.value),u=!0;break;case 2:u=f.apply(d,i);break;case 3:{let m=new f(...i);u=M(m)}break;case 4:{let{port1:m,port2:y}=new MessageChannel;L(e,y),u=ge(m,[m])}break;case 5:u=void 0;break}}catch(d){u={value:d,[O]:0}}Promise.resolve(u).catch(d=>({value:d,[O]:0})).then(d=>{let[f,m]=_(d);t.postMessage(Object.assign(Object.assign({},f),{id:s}),m),a===5&&(t.removeEventListener("message",r),Z(t))})}),t.start&&t.start()}function pe(e){return e.constructor.name==="MessagePort"}function Z(e){pe(e)&&e.close()}function R(e,t){return C(e,[],t)}function E(e){if(e)throw new Error("Proxy has been released and is not useable")}function C(e,t=[],r=function(){}){let n=!1,s=new Proxy(r,{get(a,o){if(E(n),o===U)return()=>P(e,{type:5,path:t.map(i=>i.toString())}).then(()=>{Z(e),n=!0});if(o==="then"){if(t.length===0)return{then:()=>s};let i=P(e,{type:0,path:t.map(u=>u.toString())}).then(x);return i.then.bind(i)}return C(e,[...t,o])},set(a,o,i){E(n);let[u,d]=_(i);return P(e,{type:1,path:[...t,o].map(f=>f.toString()),value:u},d).then(x)},apply(a,o,i){E(n);let u=t[t.length-1];if(u===de)return P(e,{type:4}).then(x);if(u==="bind")return C(e,t.slice(0,-1));let[d,f]=$(i);return P(e,{type:2,path:t.map(m=>m.toString()),argumentList:d},f).then(x)},construct(a,o){E(n);let[i,u]=$(o);return P(e,{type:3,path:t.map(d=>d.toString()),argumentList:i},u).then(x)}});return s}function he(e){return Array.prototype.concat.apply([],e)}function $(e){let t=e.map(_);return[t.map(r=>r[0]),he(t.map(r=>r[1]))]}var ee=new WeakMap;function ge(e,t){return ee.set(e,t),e}function M(e){return Object.assign(e,{[X]:!0})}function _(e){for(let[t,r]of Y)if(r.canHandle(e)){let[n,s]=r.serialize(e);return[{type:3,name:t,value:n},s]}return[{type:0,value:e},ee.get(e)||[]]}function x(e){switch(e.type){case 3:return Y.get(e.name).deserialize(e.value);case 0:return e.value}}function P(e,t,r){return new Promise(n=>{let s=ye();e.addEventListener("message",function a(o){!o.data||!o.data.id||o.data.id!==s||(e.removeEventListener("message",a),n(o.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:s},t),r)})}function ye(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var B="__proxyCallbackId__wixSDK__",I="__proxyPromiseId__wixSDK__",re=e=>we(e,t=>async function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];let[a,o]=W(n),i=await t(M(a),o);return ne(i)});var be=async e=>{let[t,r]=W(await e);return M({proxies:t,clonables:r})},ne=async e=>A(e?.proxies,await e?.clonables),W=e=>{let t=(s,a)=>{if(oe(a)){let o=te();return s.promises[o]=a,{[I]:o}}if(xe(a)){let o=te();return s.callbacks[o]=(i,u)=>{let d=A(i,u),f=a(...d);return be(f)},{[B]:o}}return Array.isArray(a)?a.map(o=>t(s,o)):k(a)?se(a,o=>t(s,o)):a},r={promises:{},callbacks:{}},n=t(r,e);return[r,n]},A=(e,t)=>{if(Array.isArray(t))return t.map(r=>A(e,r));if(k(t)&&t.hasOwnProperty(I)){let r=t[I];return e.promises[r]}if(k(t)&&t.hasOwnProperty(B)){let r=t[B];return async function(){for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];let[o,i]=W(s),u=await e.callbacks[r](M(o),i);return ne(u)}}return k(t)?se(t,r=>A(e,r)):t},we=(e,t)=>new Proxy(e,{get(r,n){return r[n]?t(r[n]):()=>{throw new Error(`Serialization error occurred while accessing ${n} property of ${r}`)}}}),oe=e=>e instanceof Promise,k=e=>e&&typeof e=="object"&&!oe(e),xe=e=>typeof e=="function",se=(e,t)=>{let r=n=>{let[s,a]=n;return[s,t(a)]};return Object.fromEntries(Object.entries(e).map(r))},te=(()=>{let e=0;return()=>++e})();var Pe="wix-sdk-bo-hello-handshake",ae=e=>{let{postMessage:t,origin:r}=e,{port1:n,port2:s}=new MessageChannel;t({code:Pe,version:"1.0.0",port:s},r,[s]);let i=re(R(n));return{channel:i,close:()=>i[U]()}};var ve=["https://manage.wix.com","https://manage.editorx.com"],Me=new Set(ve),ie=e=>Me.has(e);var ce=e=>{let t=new EventTarget,r=typeof window>"u",n=i=>{t.dispatchEvent(new CustomEvent("beforeunload",{cancelable:!0}))||(i.preventDefault(),i.returnValue=!0)},s=e.onBeforeUnload(n),a=()=>{r||window.removeEventListener("beforeunload",n),s.then(i=>{let{remove:u}=i;return u()})};return r||(window.addEventListener("beforeunload",n),window.addEventListener("unload",a)),{onBeforeUnload:i=>(t.addEventListener("beforeunload",i),{remove:()=>{t.removeEventListener("beforeunload",i)}}),clearBeforeUnloadHandler:a}};var ue=function(e){e===void 0&&(e={});let t=new URLSearchParams(typeof window<"u"?window.location.search:"?"),r=e.origin||t.get("origin")||"",n=e.postMessage||window.parent.postMessage.bind(window.parent);if(!ie(r))throw new Error("Wix Dashboard SDK: Unable to establish a connection with the Wix dashboard. Please ensure that you are running your app within the Wix dashboard.");let{channel:s,close:a}=ae({postMessage:n,origin:r}),o=[a];if(e.autoHeightUpdate===void 0||e.autoHeightUpdate){let f=e.autoHeightElement||document.documentElement,m=J(s,f);o.push(()=>m())}let{onBeforeUnload:i,clearBeforeUnloadHandler:u}=ce(s);return o.push(u),{channel:new Proxy(s,{get(f,m,y){return m==="onBeforeUnload"?i:Reflect.get(f,m,y)}}),close:()=>o.forEach(f=>f()),essentials:t.has("essentials")?Se(t.get("essentials")):void 0}};function Se(e){if(e)try{return JSON.parse(decodeURIComponent(e))}catch(t){console.warn('Failed to parse "essentials" query parameter. Make sure to run the code inside a supported Wix App extension.',t);return}}var z=G({createHost:ue});var ke=e=>t=>{let{host:r,...n}=t,[s,a]=T(!1),{host:o,props:i}=Ae(r);return le(()=>{o&&(D({auth:z.auth(),host:o}).enableContext("module"),a(!0))},[o]),!o||!i||!s?null:Ee.createElement(e,S({host:o},i,n))},Ae=e=>{let[t,r]=T(),[n,s]=T();return le(()=>{if(e)return;let a=z.host();r(a);let o=a.channel.observeState,i=o(d=>{s(d)}),u=async()=>{r(void 0),s(void 0),(await i).disconnect(),a.close()};return()=>{u()}},[e]),e?{host:e,props:{}}:{host:t,props:n}};export{ke as withContextualWixClient};
1
+ import{a as V}from"./chunk-FWUYJ3UR.js";import{a as D}from"./chunk-XYIDODIB.js";import"./chunk-NAPHVUFM.js";import"./chunk-BGTZ3RNN.js";import"./chunk-7EYXEF6M.js";import"./chunk-SBZEOPXX.js";function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},S.apply(null,arguments)}import Ee,{useEffect as le,useState as T}from"react";function w(e){"@babel/helpers - typeof";return w=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(e)}function N(e,t){if(w(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(w(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function K(e){var t=N(e,"string");return w(t)=="symbol"?t:t+""}function q(e,t,r){return(t=K(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var v=class extends Error{constructor(t){let{message:r,code:n}=t;super(r),q(this,"code",void 0),this.message=r,this.code=n}};var F=()=>{let e=u=>{let{channel:c}=u;return function(){let p=c.showToast(...arguments);return{remove:()=>Promise.resolve(p).then(g=>g.remove())}}},t=u=>{let{channel:c}=u;return function(){let p=c.observeState(...arguments);return{disconnect:()=>Promise.resolve(p).then(g=>g.disconnect())}}};return{showToast:e,observeState:t,navigate:u=>{let{channel:c}=u;return function(){return c.navigate(...arguments)}},navigateBack:u=>{let{channel:c}=u;return()=>c.navigateBack()},openModal:u=>{let{channel:c}=u;return function(){let p=c.openModal(...arguments);return{modalClosed:Promise.resolve(p).then(h=>h.modalClosed)}}},closeModal:u=>{let{channel:c}=u;return p=>{if(p===void 0)return c.closeModal();let h=JSON.parse(JSON.stringify(p));return c.closeModal(h)}},getAccessToken:u=>{let{channel:c}=u;return()=>c.getAccessToken()},getPageUrl:u=>{let{channel:c}=u;return function(){return c.getPageUrl(...arguments)}},openMediaManager:u=>{let{channel:c}=u;return function(){return c.openMediaManager(...arguments)}},addSitePlugin:u=>{let{channel:c}=u;return(p,h)=>{let g="802c76e4-b381-4bb3-9152-96acabbf3194",j=h?.placement||{},H=c.openModal(g,{...j,pluginId:p,action:"populate"});return Promise.resolve(H).then(b=>b.modalClosed).then(b=>{if(b?.type===void 0)throw new v({message:"Aborted by user",code:3006});if(b?.type==="ERROR")throw new v(b.data.error)})}},onBeforeUnload:u=>{let{channel:c}=u;return function(){return c.onBeforeUnload(...arguments)}},setPageTitle:u=>{let{channel:c}=u;return p=>c.setPageTitle(p)},getLanguage:u=>{let c=null;return async()=>{var p;if(c)return c;let h=null;return c=await new Promise(g=>{h=t(u)((j,H)=>{g(H.language)})}),(p=h)==null||p.disconnect(),c}},requestFeedback:u=>{let{channel:c}=u;return function(){return c.requestFeedback(...arguments)}},onLayerStateChange:u=>{let{channel:c}=u;return function(){let p=c.onLayerStateChange(...arguments);return{remove:()=>Promise.resolve(p).then(g=>g.remove())}}},installApp:u=>{let{channel:c}=u;return c.installApp}}};var G=e=>{let{createHost:t}=e,r=F();return{...V(r),host:t,auth:()=>({getAuthHeaders:async n=>({headers:{Authorization:await r.getAccessToken(n)()}})})}};var J=(e,t)=>{let r=()=>e.updateHeight(t.offsetHeight),n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()};var X=Symbol("Comlink.proxy"),de=Symbol("Comlink.endpoint"),U=Symbol("Comlink.releaseProxy"),O=Symbol("Comlink.thrown"),Q=e=>typeof e=="object"&&e!==null||typeof e=="function",fe={canHandle:e=>Q(e)&&e[X],serialize(e){let{port1:t,port2:r}=new MessageChannel;return L(e,t),[r,[r]]},deserialize(e){return e.start(),R(e)}},me={canHandle:e=>Q(e)&&O in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},Y=new Map([["proxy",fe],["throw",me]]);function L(e,t=self){t.addEventListener("message",function r(n){if(!n||!n.data)return;let{id:s,type:a,path:o}=Object.assign({path:[]},n.data),i=(n.data.argumentList||[]).map(x),l;try{let d=o.slice(0,-1).reduce((m,y)=>m[y],e),f=o.reduce((m,y)=>m[y],e);switch(a){case 0:l=f;break;case 1:d[o.slice(-1)[0]]=x(n.data.value),l=!0;break;case 2:l=f.apply(d,i);break;case 3:{let m=new f(...i);l=M(m)}break;case 4:{let{port1:m,port2:y}=new MessageChannel;L(e,y),l=ge(m,[m])}break;case 5:l=void 0;break}}catch(d){l={value:d,[O]:0}}Promise.resolve(l).catch(d=>({value:d,[O]:0})).then(d=>{let[f,m]=_(d);t.postMessage(Object.assign(Object.assign({},f),{id:s}),m),a===5&&(t.removeEventListener("message",r),Z(t))})}),t.start&&t.start()}function pe(e){return e.constructor.name==="MessagePort"}function Z(e){pe(e)&&e.close()}function R(e,t){return C(e,[],t)}function E(e){if(e)throw new Error("Proxy has been released and is not useable")}function C(e,t=[],r=function(){}){let n=!1,s=new Proxy(r,{get(a,o){if(E(n),o===U)return()=>P(e,{type:5,path:t.map(i=>i.toString())}).then(()=>{Z(e),n=!0});if(o==="then"){if(t.length===0)return{then:()=>s};let i=P(e,{type:0,path:t.map(l=>l.toString())}).then(x);return i.then.bind(i)}return C(e,[...t,o])},set(a,o,i){E(n);let[l,d]=_(i);return P(e,{type:1,path:[...t,o].map(f=>f.toString()),value:l},d).then(x)},apply(a,o,i){E(n);let l=t[t.length-1];if(l===de)return P(e,{type:4}).then(x);if(l==="bind")return C(e,t.slice(0,-1));let[d,f]=$(i);return P(e,{type:2,path:t.map(m=>m.toString()),argumentList:d},f).then(x)},construct(a,o){E(n);let[i,l]=$(o);return P(e,{type:3,path:t.map(d=>d.toString()),argumentList:i},l).then(x)}});return s}function he(e){return Array.prototype.concat.apply([],e)}function $(e){let t=e.map(_);return[t.map(r=>r[0]),he(t.map(r=>r[1]))]}var ee=new WeakMap;function ge(e,t){return ee.set(e,t),e}function M(e){return Object.assign(e,{[X]:!0})}function _(e){for(let[t,r]of Y)if(r.canHandle(e)){let[n,s]=r.serialize(e);return[{type:3,name:t,value:n},s]}return[{type:0,value:e},ee.get(e)||[]]}function x(e){switch(e.type){case 3:return Y.get(e.name).deserialize(e.value);case 0:return e.value}}function P(e,t,r){return new Promise(n=>{let s=ye();e.addEventListener("message",function a(o){!o.data||!o.data.id||o.data.id!==s||(e.removeEventListener("message",a),n(o.data))}),e.start&&e.start(),e.postMessage(Object.assign({id:s},t),r)})}function ye(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var B="__proxyCallbackId__wixSDK__",I="__proxyPromiseId__wixSDK__",re=e=>we(e,t=>async function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];let[a,o]=W(n),i=await t(M(a),o);return ne(i)});var be=async e=>{let[t,r]=W(await e);return M({proxies:t,clonables:r})},ne=async e=>A(e?.proxies,await e?.clonables),W=e=>{let t=(s,a)=>{if(oe(a)){let o=te();return s.promises[o]=a,{[I]:o}}if(xe(a)){let o=te();return s.callbacks[o]=(i,l)=>{let d=A(i,l),f=a(...d);return be(f)},{[B]:o}}return Array.isArray(a)?a.map(o=>t(s,o)):k(a)?se(a,o=>t(s,o)):a},r={promises:{},callbacks:{}},n=t(r,e);return[r,n]},A=(e,t)=>{if(Array.isArray(t))return t.map(r=>A(e,r));if(k(t)&&t.hasOwnProperty(I)){let r=t[I];return e.promises[r]}if(k(t)&&t.hasOwnProperty(B)){let r=t[B];return async function(){for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];let[o,i]=W(s),l=await e.callbacks[r](M(o),i);return ne(l)}}return k(t)?se(t,r=>A(e,r)):t},we=(e,t)=>new Proxy(e,{get(r,n){return r[n]?t(r[n]):()=>{throw new Error(`Serialization error occurred while accessing ${n} property of ${r}`)}}}),oe=e=>e instanceof Promise,k=e=>e&&typeof e=="object"&&!oe(e),xe=e=>typeof e=="function",se=(e,t)=>{let r=n=>{let[s,a]=n;return[s,t(a)]};return Object.fromEntries(Object.entries(e).map(r))},te=(()=>{let e=0;return()=>++e})();var Pe="wix-sdk-bo-hello-handshake",ae=e=>{let{postMessage:t,origin:r}=e,{port1:n,port2:s}=new MessageChannel;t({code:Pe,version:"1.0.0",port:s},r,[s]);let i=re(R(n));return{channel:i,close:()=>i[U]()}};var ve=["https://manage.wix.com","https://manage.editorx.com"],Me=new Set(ve),ie=e=>Me.has(e);var ce=e=>{let t=new EventTarget,r=typeof window>"u",n=i=>{t.dispatchEvent(new CustomEvent("beforeunload",{cancelable:!0}))||(i.preventDefault(),i.returnValue=!0)},s=e.onBeforeUnload(n),a=()=>{r||window.removeEventListener("beforeunload",n),s.then(i=>{let{remove:l}=i;return l()})};return r||(window.addEventListener("beforeunload",n),window.addEventListener("unload",a)),{onBeforeUnload:i=>(t.addEventListener("beforeunload",i),{remove:()=>{t.removeEventListener("beforeunload",i)}}),clearBeforeUnloadHandler:a}};var ue=function(e){e===void 0&&(e={});let t=new URLSearchParams(typeof window<"u"?window.location.search:"?"),r=e.origin||t.get("origin")||"",n=e.postMessage||window.parent.postMessage.bind(window.parent);if(!ie(r))throw new Error("Wix Dashboard SDK: Unable to establish a connection with the Wix dashboard. Please ensure that you are running your app within the Wix dashboard.");let{channel:s,close:a}=ae({postMessage:n,origin:r}),o=[a];if(e.autoHeightUpdate===void 0||e.autoHeightUpdate){let f=e.autoHeightElement||document.documentElement,m=J(s,f);o.push(()=>m())}let{onBeforeUnload:i,clearBeforeUnloadHandler:l}=ce(s);return o.push(l),{channel:new Proxy(s,{get(f,m,y){return m==="onBeforeUnload"?i:Reflect.get(f,m,y)}}),close:()=>o.forEach(f=>f()),essentials:t.has("essentials")?Se(t.get("essentials")):void 0}};function Se(e){if(e)try{return JSON.parse(decodeURIComponent(e))}catch(t){console.warn('Failed to parse "essentials" query parameter. Make sure to run the code inside a supported Wix App extension.',t);return}}var z=G({createHost:ue});var ke=e=>t=>{let{host:r,...n}=t,[s,a]=T(!1),{host:o,props:i}=Ae(r);return le(()=>{o&&(D({auth:z.auth(),host:o}).enableContext("module"),a(!0))},[o]),!o||!i||!s?null:Ee.createElement(e,S({host:o},i,n))},Ae=e=>{let[t,r]=T(),[n,s]=T();return le(()=>{if(e)return;let a=z.host();r(a);let o=a.channel.observeState,i=o(d=>{s(d)}),l=async()=>{r(void 0),s(void 0),(await i).disconnect(),a.close()};return()=>{l()}},[e]),e?{host:e,props:{}}:{host:t,props:n}};export{ke as withContextualWixClient};
2
2
  //# sourceMappingURL=dashboard.js.map