@wix/form-public 0.222.0 → 0.223.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5110,446 +5110,9 @@ var init_browser = __esm({
5110
5110
  }
5111
5111
  });
5112
5112
 
5113
- // ../../node_modules/@wix/sdk-runtime/build/context-v2.js
5114
- function contextualizeRESTModuleV2(restModule, elevated) {
5115
- return ((...args) => {
5116
- const context = resolveContext();
5117
- if (!context) {
5118
- return restModule.apply(void 0, args);
5119
- }
5120
- return context.initWixModules(restModule, elevated).apply(void 0, args);
5121
- });
5122
- }
5123
- var init_context_v2 = __esm({
5124
- "../../node_modules/@wix/sdk-runtime/build/context-v2.js"() {
5125
- init_context();
5126
- }
5127
- });
5128
-
5129
- // ../../node_modules/@wix/sdk-runtime/build/context.js
5130
- function resolveContext() {
5131
- const oldContext = typeof $wixContext !== "undefined" && $wixContext.initWixModules ? $wixContext.initWixModules : typeof globalThis.__wix_context__ !== "undefined" && globalThis.__wix_context__.initWixModules ? globalThis.__wix_context__.initWixModules : void 0;
5132
- if (oldContext) {
5133
- return {
5134
- // @ts-expect-error
5135
- initWixModules(modules, elevated) {
5136
- return runWithoutContext(() => oldContext(modules, elevated));
5137
- },
5138
- fetchWithAuth() {
5139
- throw new Error("fetchWithAuth is not available in this context");
5140
- },
5141
- graphql() {
5142
- throw new Error("graphql is not available in this context");
5143
- }
5144
- };
5145
- }
5146
- const contextualClient = typeof $wixContext !== "undefined" ? $wixContext.client : typeof wixContext.client !== "undefined" ? wixContext.client : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.client : void 0;
5147
- const elevatedClient = typeof $wixContext !== "undefined" ? $wixContext.elevatedClient : typeof wixContext.elevatedClient !== "undefined" ? wixContext.elevatedClient : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.elevatedClient : void 0;
5148
- if (!contextualClient && !elevatedClient) {
5149
- return;
5150
- }
5151
- return {
5152
- initWixModules(wixModules, elevated) {
5153
- if (elevated) {
5154
- if (!elevatedClient) {
5155
- 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");
5156
- }
5157
- return runWithoutContext(() => elevatedClient.use(wixModules));
5158
- }
5159
- if (!contextualClient) {
5160
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
5161
- }
5162
- return runWithoutContext(() => contextualClient.use(wixModules));
5163
- },
5164
- fetchWithAuth: (urlOrRequest, requestInit) => {
5165
- if (!contextualClient) {
5166
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
5167
- }
5168
- return contextualClient.fetchWithAuth(urlOrRequest, requestInit);
5169
- },
5170
- getAuth() {
5171
- if (!contextualClient) {
5172
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
5173
- }
5174
- return contextualClient.auth;
5175
- },
5176
- async graphql(query, variables, opts) {
5177
- if (!contextualClient) {
5178
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
5179
- }
5180
- return contextualClient.graphql(query, variables, opts);
5181
- }
5182
- };
5183
- }
5184
- function runWithoutContext(fn) {
5185
- const globalContext = globalThis.__wix_context__;
5186
- const moduleContext = {
5187
- client: wixContext.client,
5188
- elevatedClient: wixContext.elevatedClient
5189
- };
5190
- let closureContext;
5191
- globalThis.__wix_context__ = void 0;
5192
- wixContext.client = void 0;
5193
- wixContext.elevatedClient = void 0;
5194
- if (typeof $wixContext !== "undefined") {
5195
- closureContext = {
5196
- client: $wixContext?.client,
5197
- elevatedClient: $wixContext?.elevatedClient
5198
- };
5199
- delete $wixContext.client;
5200
- delete $wixContext.elevatedClient;
5201
- }
5202
- try {
5203
- return fn();
5204
- } finally {
5205
- globalThis.__wix_context__ = globalContext;
5206
- wixContext.client = moduleContext.client;
5207
- wixContext.elevatedClient = moduleContext.elevatedClient;
5208
- if (typeof $wixContext !== "undefined") {
5209
- $wixContext.client = closureContext.client;
5210
- $wixContext.elevatedClient = closureContext.elevatedClient;
5211
- }
5212
- }
5213
- }
5214
- var init_context = __esm({
5215
- "../../node_modules/@wix/sdk-runtime/build/context.js"() {
5216
- init_browser();
5217
- init_context_v2();
5218
- }
5219
- });
5220
-
5221
- // ../../node_modules/@wix/sdk-runtime/build/constants.js
5222
- var SDKRequestToRESTRequestRenameMap, RESTResponseToSDKResponseRenameMap;
5223
- var init_constants = __esm({
5224
- "../../node_modules/@wix/sdk-runtime/build/constants.js"() {
5225
- SDKRequestToRESTRequestRenameMap = {
5226
- _id: "id",
5227
- _createdDate: "createdDate",
5228
- _updatedDate: "updatedDate"
5229
- };
5230
- RESTResponseToSDKResponseRenameMap = {
5231
- id: "_id",
5232
- createdDate: "_createdDate",
5233
- updatedDate: "_updatedDate"
5234
- };
5235
- }
5236
- });
5237
-
5238
- // ../../node_modules/@wix/sdk-runtime/build/utils.js
5239
- function removeUndefinedKeys(obj) {
5240
- return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
5241
- }
5242
- function constantCase(input) {
5243
- return split(input).map((part) => part.toLocaleUpperCase()).join("_");
5244
- }
5245
- function split(value) {
5246
- let result2 = value.trim();
5247
- result2 = result2.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
5248
- result2 = result2.replace(DEFAULT_STRIP_REGEXP, "\0");
5249
- let start = 0;
5250
- let end = result2.length;
5251
- while (result2.charAt(start) === "\0") {
5252
- start++;
5253
- }
5254
- if (start === end) {
5255
- return [];
5256
- }
5257
- while (result2.charAt(end - 1) === "\0") {
5258
- end--;
5259
- }
5260
- return result2.slice(start, end).split(/\0/g);
5261
- }
5262
- var SPLIT_LOWER_UPPER_RE, SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE, DEFAULT_STRIP_REGEXP;
5263
- var init_utils2 = __esm({
5264
- "../../node_modules/@wix/sdk-runtime/build/utils.js"() {
5265
- SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
5266
- SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
5267
- SPLIT_REPLACE_VALUE = "$1\0$2";
5268
- DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
5269
- }
5270
- });
5271
-
5272
- // ../../node_modules/@wix/sdk-runtime/build/transform-error.js
5273
- function transformError(httpClientError, pathsToArguments = {
5274
- explicitPathsToArguments: {},
5275
- spreadPathsToArguments: {},
5276
- singleArgumentUnchanged: false
5277
- }, argumentNames = []) {
5278
- if (typeof httpClientError !== "object" || httpClientError === null) {
5279
- throw httpClientError;
5280
- }
5281
- if (isValidationError(httpClientError)) {
5282
- return buildValidationError(httpClientError, pathsToArguments, argumentNames);
5283
- }
5284
- if (isApplicationError(httpClientError)) {
5285
- return buildApplicationError(httpClientError);
5286
- }
5287
- if (isClientError(httpClientError)) {
5288
- const status = httpClientError.response?.status;
5289
- const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
5290
- const message = httpClientError.response?.data?.message ?? statusText;
5291
- const details = {
5292
- applicationError: {
5293
- description: statusText,
5294
- code: constantCase(statusText),
5295
- data: {}
5296
- },
5297
- requestId: httpClientError.requestId
5298
- };
5299
- return wrapError(httpClientError, {
5300
- message: JSON.stringify({
5301
- message,
5302
- details
5303
- }, null, 2),
5304
- extraProperties: {
5305
- details,
5306
- status
5307
- }
5308
- });
5309
- }
5310
- return buildSystemError(httpClientError);
5311
- }
5312
- var isValidationError, isApplicationError, isClientError, buildValidationError, wrapError, buildApplicationError, buildSystemError, violationsWithRenamedFields, withRenamedArgument, getArgumentIndex;
5313
- var init_transform_error = __esm({
5314
- "../../node_modules/@wix/sdk-runtime/build/transform-error.js"() {
5315
- init_utils2();
5316
- isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
5317
- isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
5318
- isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
5319
- buildValidationError = (httpClientError, pathsToArguments, argumentNames) => {
5320
- const validationErrorResponse = httpClientError.response?.data;
5321
- const requestId = httpClientError.requestId;
5322
- const { fieldViolations } = validationErrorResponse.details.validationError;
5323
- const transformedFieldViolations = violationsWithRenamedFields(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
5324
- const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
5325
- const details = {
5326
- validationError: { fieldViolations: transformedFieldViolations },
5327
- requestId
5328
- };
5329
- return wrapError(httpClientError, {
5330
- message: JSON.stringify({ message, details }, null, 2),
5331
- extraProperties: {
5332
- details,
5333
- status: httpClientError.response?.status,
5334
- requestId
5335
- }
5336
- });
5337
- };
5338
- wrapError = (baseError, { message, extraProperties }) => {
5339
- return Object.assign(baseError, {
5340
- ...extraProperties,
5341
- message
5342
- });
5343
- };
5344
- buildApplicationError = (httpClientError) => {
5345
- const status = httpClientError.response?.status;
5346
- const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
5347
- const message = httpClientError.response?.data?.message ?? statusText;
5348
- const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
5349
- const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase(statusText);
5350
- const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
5351
- const combinedMessage = message === description ? message : `${message}: ${description}`;
5352
- const details = {
5353
- applicationError: {
5354
- description,
5355
- code,
5356
- data
5357
- },
5358
- requestId: httpClientError.requestId
5359
- };
5360
- return wrapError(httpClientError, {
5361
- message: JSON.stringify({ message: combinedMessage, details }, null, 2),
5362
- extraProperties: {
5363
- details,
5364
- status,
5365
- requestId: httpClientError.requestId
5366
- }
5367
- });
5368
- };
5369
- buildSystemError = (httpClientError) => {
5370
- const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
5371
- return wrapError(httpClientError, {
5372
- message,
5373
- extraProperties: {
5374
- requestId: httpClientError.requestId,
5375
- status: httpClientError.response?.status,
5376
- code: constantCase(httpClientError.response?.statusText ?? "UNKNOWN"),
5377
- ...!httpClientError.response && {
5378
- runtimeError: httpClientError
5379
- }
5380
- }
5381
- });
5382
- };
5383
- violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
5384
- const allPathsToArguments = {
5385
- ...spreadPathsToArguments,
5386
- ...explicitPathsToArguments
5387
- };
5388
- const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
5389
- return fieldViolations?.filter((fieldViolation) => {
5390
- const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
5391
- return !containedInAMoreSpecificViolationField;
5392
- }).map((fieldViolation) => {
5393
- const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
5394
- if (exactMatchArgumentExpression) {
5395
- return {
5396
- ...fieldViolation,
5397
- field: withRenamedArgument(exactMatchArgumentExpression, argumentNames)
5398
- };
5399
- }
5400
- const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
5401
- if (longestPartialPathMatch) {
5402
- const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
5403
- if (partialMatchArgumentExpression) {
5404
- return {
5405
- ...fieldViolation,
5406
- field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument(partialMatchArgumentExpression, argumentNames))
5407
- };
5408
- }
5409
- }
5410
- if (singleArgumentUnchanged) {
5411
- return {
5412
- ...fieldViolation,
5413
- field: `${argumentNames[0]}.${fieldViolation.field}`
5414
- };
5415
- }
5416
- return fieldViolation;
5417
- });
5418
- };
5419
- withRenamedArgument = (fieldValue, argumentNames) => {
5420
- const argIndex = getArgumentIndex(fieldValue);
5421
- if (argIndex !== null && typeof argIndex !== "undefined") {
5422
- return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
5423
- }
5424
- return fieldValue;
5425
- };
5426
- getArgumentIndex = (s) => {
5427
- const match = s.match(/\$\[(?<argIndex>\d+)\]/);
5428
- return match && match.groups && Number(match.groups.argIndex);
5429
- };
5430
- }
5431
- });
5432
-
5433
- // ../../node_modules/@wix/sdk-runtime/build/rest-modules.js
5434
- function createRESTModule(descriptor, elevated = false) {
5435
- return contextualizeRESTModuleV2(descriptor, elevated);
5436
- }
5437
- function toURLSearchParams(params, isComplexRequest) {
5438
- const flatten = flattenParams(params);
5439
- Object.entries(flatten).some(([key, value]) => key.includes(".") || Array.isArray(value) && value.some((v) => typeof v === "object"));
5440
- {
5441
- return Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {
5442
- const keyParams = Array.isArray(value) ? value : [value];
5443
- keyParams.forEach((param) => {
5444
- if (param === void 0 || param === null || Array.isArray(value) && typeof param === "object") {
5445
- return;
5446
- }
5447
- urlSearchParams.append(key, param);
5448
- });
5449
- return urlSearchParams;
5450
- }, new URLSearchParams());
5451
- }
5452
- }
5453
- function resolveUrl(opts) {
5454
- const domain = resolveDomain(opts.host);
5455
- const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);
5456
- const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
5457
- return resolvePathFromMappings(path, mappings);
5458
- }
5459
- function flattenParams(data, path = "") {
5460
- const params = {};
5461
- Object.entries(data).forEach(([key, value]) => {
5462
- const isObject5 = value !== null && typeof value === "object" && !Array.isArray(value);
5463
- const fieldPath = resolvePath(path, key);
5464
- if (isObject5) {
5465
- const serializedObject = flattenParams(value, fieldPath);
5466
- Object.assign(params, serializedObject);
5467
- } else {
5468
- params[fieldPath] = value;
5469
- }
5470
- });
5471
- return params;
5472
- }
5473
- function resolvePath(path, key) {
5474
- return `${path}${path ? "." : ""}${key}`;
5475
- }
5476
- function resolveDomain(host) {
5477
- const resolvedHost = fixHostExceptions(host);
5478
- return resolvedHost.replace(REGEX_CAPTURE_DOMAINS, "._base_domain_").replace(REGEX_CAPTURE_API_DOMAINS, "._api_base_domain_").replace(REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, "*.dev.wix-code.com");
5479
- }
5480
- function fixHostExceptions(host) {
5481
- return host.replace("create.editorx.com", "editor.editorx.com");
5482
- }
5483
- function resolveMappingsByDomain(domain, domainToMappings) {
5484
- const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];
5485
- if (mappings) {
5486
- return mappings;
5487
- }
5488
- const rootDomainMappings = resolveRootDomain(domain, domainToMappings);
5489
- if (!rootDomainMappings) {
5490
- if (isBaseDomain(domain)) {
5491
- return domainToMappings[wwwBaseDomain];
5492
- }
5493
- }
5494
- return rootDomainMappings ?? [];
5495
- }
5496
- function resolveRootDomain(domain, domainToMappings) {
5497
- return Object.entries(domainToMappings).find(([entryDomain]) => {
5498
- const [, ...rooDomainSegments] = domain.split(".");
5499
- return rooDomainSegments.join(".") === entryDomain;
5500
- })?.[1];
5501
- }
5502
- function isBaseDomain(domain) {
5503
- return !!domain.match(/\._base_domain_$/);
5504
- }
5505
- function injectDataIntoProtoPath(protoPath, data) {
5506
- return protoPath.split("/").map((path) => maybeProtoPathToData(path, data)).join("/");
5507
- }
5508
- function maybeProtoPathToData(protoPath, data) {
5509
- const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];
5510
- const field = protoRegExpMatch[1];
5511
- if (field) {
5512
- const suffix = protoPath.replace(protoRegExpMatch[0], "");
5513
- return findByPath(data, field, protoPath, suffix);
5514
- }
5515
- return protoPath;
5516
- }
5517
- function findByPath(obj, path, defaultValue, suffix) {
5518
- let result2 = obj;
5519
- for (const field of path.split(".")) {
5520
- if (!result2) {
5521
- return defaultValue;
5522
- }
5523
- result2 = result2[field];
5524
- }
5525
- return `${result2}${suffix}`;
5526
- }
5527
- function resolvePathFromMappings(protoPath, mappings) {
5528
- const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));
5529
- if (!mapping) {
5530
- return protoPath;
5531
- }
5532
- return mapping.srcPath + protoPath.slice(mapping.destPath.length);
5533
- }
5534
- var DOMAINS, USER_DOMAIN, REGEX_CAPTURE_DOMAINS, WIX_API_DOMAINS, DEV_WIX_CODE_DOMAIN, REGEX_CAPTURE_PROTO_FIELD, REGEX_CAPTURE_API_DOMAINS, REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, wwwBaseDomain;
5535
- var init_rest_modules = __esm({
5536
- "../../node_modules/@wix/sdk-runtime/build/rest-modules.js"() {
5537
- init_context_v2();
5538
- DOMAINS = ["wix.com", "editorx.com"];
5539
- USER_DOMAIN = "_";
5540
- REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
5541
- WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
5542
- DEV_WIX_CODE_DOMAIN = "dev.wix-code.com";
5543
- REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;
5544
- REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\.(${WIX_API_DOMAINS.join("|")})$`);
5545
- REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\.${DEV_WIX_CODE_DOMAIN}$`);
5546
- wwwBaseDomain = "www._base_domain_";
5547
- }
5548
- });
5549
-
5550
5113
  // ../form-multiline-address/dist/esm/lib/constants.js
5551
5114
  var ADDRESS_FORM_ID_BY_COUNTRY, DEFAULT_COUNTRY;
5552
- var init_constants2 = __esm({
5115
+ var init_constants = __esm({
5553
5116
  "../form-multiline-address/dist/esm/lib/constants.js"() {
5554
5117
  ADDRESS_FORM_ID_BY_COUNTRY = {
5555
5118
  COMMON: "0d5dcb6d-1403-4b80-b73e-6d90a2245561",
@@ -6293,7 +5856,7 @@ var init_multiline_address_toolkit = __esm({
6293
5856
  init_defineProperty();
6294
5857
  init_types_impl();
6295
5858
  import_locale_dataset_javascript = __toESM(require_index_bundle());
6296
- init_constants2();
5859
+ init_constants();
6297
5860
  init_apply_validation_properties();
6298
5861
  init_apply_view_properties();
6299
5862
  init_get_country_field();
@@ -6503,7 +6066,7 @@ __export(esm_exports, {
6503
6066
  });
6504
6067
  var init_esm2 = __esm({
6505
6068
  "../form-multiline-address/dist/esm/index.js"() {
6506
- init_constants2();
6069
+ init_constants();
6507
6070
  init_multiline_address_toolkit();
6508
6071
  init_get_country_field();
6509
6072
  init_country_codes();
@@ -7314,7 +6877,7 @@ var init_getPossibleCountriesForNumber = __esm({
7314
6877
 
7315
6878
  // ../../node_modules/libphonenumber-js/es6/constants.js
7316
6879
  var MIN_LENGTH_FOR_NSN, MAX_LENGTH_FOR_NSN, MAX_LENGTH_COUNTRY_CODE, VALID_DIGITS, DASHES, SLASHES, DOTS, WHITESPACE, BRACKETS, TILDES, VALID_PUNCTUATION, PLUS_CHARS;
7317
- var init_constants3 = __esm({
6880
+ var init_constants2 = __esm({
7318
6881
  "../../node_modules/libphonenumber-js/es6/constants.js"() {
7319
6882
  MIN_LENGTH_FOR_NSN = 2;
7320
6883
  MAX_LENGTH_FOR_NSN = 17;
@@ -7355,7 +6918,7 @@ var CAPTURING_DIGIT_PATTERN;
7355
6918
  var init_stripIddPrefix = __esm({
7356
6919
  "../../node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js"() {
7357
6920
  init_metadata();
7358
- init_constants3();
6921
+ init_constants2();
7359
6922
  CAPTURING_DIGIT_PATTERN = new RegExp("([" + VALID_DIGITS + "])");
7360
6923
  }
7361
6924
  });
@@ -7628,7 +7191,7 @@ var init_extractCountryCallingCode = __esm({
7628
7191
  init_stripIddPrefix();
7629
7192
  init_extractCountryCallingCodeFromInternationalNumberWithoutPlusSign();
7630
7193
  init_metadata();
7631
- init_constants3();
7194
+ init_constants2();
7632
7195
  }
7633
7196
  });
7634
7197
 
@@ -7638,7 +7201,7 @@ function applyInternationalSeparatorStyle(formattedNumber) {
7638
7201
  }
7639
7202
  var init_applyInternationalSeparatorStyle = __esm({
7640
7203
  "../../node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js"() {
7641
- init_constants3();
7204
+ init_constants2();
7642
7205
  }
7643
7206
  });
7644
7207
 
@@ -7718,7 +7281,7 @@ function createExtensionPattern(purpose) {
7718
7281
  var RFC3966_EXTN_PREFIX, getExtensionDigitsPattern;
7719
7282
  var init_createExtensionPattern = __esm({
7720
7283
  "../../node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js"() {
7721
- init_constants3();
7284
+ init_constants2();
7722
7285
  RFC3966_EXTN_PREFIX = ";ext=";
7723
7286
  getExtensionDigitsPattern = function getExtensionDigitsPattern2(maxLength) {
7724
7287
  return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
@@ -7736,7 +7299,7 @@ function isViablePhoneNumberStart(number) {
7736
7299
  var MIN_LENGTH_PHONE_NUMBER_PATTERN, VALID_PHONE_NUMBER, VALID_PHONE_NUMBER_START_REG_EXP, VALID_PHONE_NUMBER_WITH_EXTENSION, VALID_PHONE_NUMBER_PATTERN;
7737
7300
  var init_isViablePhoneNumber = __esm({
7738
7301
  "../../node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js"() {
7739
- init_constants3();
7302
+ init_constants2();
7740
7303
  init_createExtensionPattern();
7741
7304
  MIN_LENGTH_PHONE_NUMBER_PATTERN = "[" + VALID_DIGITS + "]{" + MIN_LENGTH_FOR_NSN + "}";
7742
7305
  VALID_PHONE_NUMBER = "[" + PLUS_CHARS + "]{0,1}(?:[" + VALID_PUNCTUATION + "]*[" + VALID_DIGITS + "]){3,}[" + VALID_PUNCTUATION + VALID_DIGITS + "]*";
@@ -8448,7 +8011,7 @@ function isPhoneContextValid(phoneContext) {
8448
8011
  var PLUS_SIGN, RFC3966_VISUAL_SEPARATOR_, RFC3966_PHONE_DIGIT_, RFC3966_GLOBAL_NUMBER_DIGITS_, RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_, ALPHANUM_, RFC3966_DOMAINLABEL_, VALID_ALPHA_, RFC3966_TOPLABEL_, RFC3966_DOMAINNAME_, RFC3966_DOMAINNAME_PATTERN_, RFC3966_PREFIX_, RFC3966_PHONE_CONTEXT_, RFC3966_ISDN_SUBADDRESS_;
8449
8012
  var init_extractPhoneContext = __esm({
8450
8013
  "../../node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js"() {
8451
- init_constants3();
8014
+ init_constants2();
8452
8015
  PLUS_SIGN = "+";
8453
8016
  RFC3966_VISUAL_SEPARATOR_ = "[\\-\\.\\(\\)]?";
8454
8017
  RFC3966_PHONE_DIGIT_ = "([" + VALID_DIGITS + "]|" + RFC3966_VISUAL_SEPARATOR_ + ")";
@@ -8673,7 +8236,7 @@ function parsePhoneNumber(formattedPhoneNumber, defaultCountry, defaultCallingCo
8673
8236
  var MAX_INPUT_STRING_LENGTH, PHONE_NUMBER_START_PATTERN, AFTER_PHONE_NUMBER_END_PATTERN, USE_NON_GEOGRAPHIC_COUNTRY_CODE3;
8674
8237
  var init_parse = __esm({
8675
8238
  "../../node_modules/libphonenumber-js/es6/parse.js"() {
8676
- init_constants3();
8239
+ init_constants2();
8677
8240
  init_ParseError();
8678
8241
  init_metadata();
8679
8242
  init_isViablePhoneNumber();
@@ -9824,7 +9387,7 @@ var init_AsYouTypeFormatter = __esm({
9824
9387
  init_parseDigits();
9825
9388
  init_AsYouTypeFormatter_util();
9826
9389
  init_formatNationalNumberUsingFormat();
9827
- init_constants3();
9390
+ init_constants2();
9828
9391
  init_applyInternationalSeparatorStyle();
9829
9392
  DUMMY_DIGIT = "9";
9830
9393
  LONGEST_NATIONAL_PHONE_NUMBER_LENGTH = 15;
@@ -10268,7 +9831,7 @@ var init_AsYouTypeParser = __esm({
10268
9831
  init_extractNationalNumberFromPossiblyIncompleteNumber();
10269
9832
  init_stripIddPrefix();
10270
9833
  init_parseDigits();
10271
- init_constants3();
9834
+ init_constants2();
10272
9835
  VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART = "[" + VALID_PUNCTUATION + VALID_DIGITS + "]+";
10273
9836
  VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART_PATTERN = new RegExp("^" + VALID_FORMATTED_PHONE_NUMBER_DIGITS_PART + "$", "i");
10274
9837
  VALID_FORMATTED_PHONE_NUMBER_PART = "(?:[" + PLUS_CHARS + "][" + VALID_PUNCTUATION + VALID_DIGITS + "]*|[" + VALID_PUNCTUATION + VALID_DIGITS + "]+)";
@@ -24757,7 +24320,7 @@ function isCI() {
24757
24320
  function isNode() {
24758
24321
  return typeof process !== "undefined" && process.versions?.node != null;
24759
24322
  }
24760
- var init_utils3 = __esm({
24323
+ var init_utils2 = __esm({
24761
24324
  "../../node_modules/@wix/headers/dist/esm/utils.js"() {
24762
24325
  }
24763
24326
  });
@@ -24771,7 +24334,7 @@ function artifactId(override) {
24771
24334
  }
24772
24335
  var init_artifact_id = __esm({
24773
24336
  "../../node_modules/@wix/headers/dist/esm/headers/artifact-id.js"() {
24774
- init_utils3();
24337
+ init_utils2();
24775
24338
  }
24776
24339
  });
24777
24340
 
@@ -26102,550 +25665,954 @@ var FormStatusProvider = (_ref) => {
26102
25665
  value: contextValue
26103
25666
  }, children);
26104
25667
  };
26105
- function useFormStatus() {
26106
- const context = React42.useContext(FormStatusContext);
25668
+ function useFormStatus() {
25669
+ const context = React42.useContext(FormStatusContext);
25670
+ if (context === void 0) {
25671
+ throw new Error("useFormStatus must be used within a Form Status provider");
25672
+ }
25673
+ return context;
25674
+ }
25675
+ var WixRicosViewerContext = /* @__PURE__ */ React42.createContext(void 0);
25676
+
25677
+ // ../../node_modules/@wix/ricos/dist/es/index.js
25678
+ init_v1();
25679
+ var DEFAULT_CONFIG = {
25680
+ language: "en",
25681
+ accountLanguage: "en",
25682
+ regionalFormat: "en"
25683
+ };
25684
+ var ConfigContext = /* @__PURE__ */ React42.createContext(null);
25685
+ function ConfigContextProvider(_ref) {
25686
+ let {
25687
+ value: configInput,
25688
+ children
25689
+ } = _ref;
25690
+ const config = {
25691
+ ...configInput,
25692
+ language: configInput.language ?? DEFAULT_CONFIG.language,
25693
+ accountLanguage: configInput.accountLanguage ?? DEFAULT_CONFIG.accountLanguage,
25694
+ regionalFormat: configInput.regionalFormat ?? DEFAULT_CONFIG.regionalFormat
25695
+ };
25696
+ return /* @__PURE__ */ React42__namespace.default.createElement(ConfigContext.Provider, {
25697
+ value: config
25698
+ }, children);
25699
+ }
25700
+ function useConfig() {
25701
+ const context = React42.useContext(ConfigContext);
25702
+ if (context === void 0) {
25703
+ throw new Error("useConfig must be used within a ConfigContext.Provider");
25704
+ }
25705
+ return context || DEFAULT_CONFIG;
25706
+ }
25707
+ var htmlAttributesPlugin = (_) => ({
25708
+ config: {},
25709
+ type: "",
25710
+ nodeViewDecorators: [htmlAttributesDecorator],
25711
+ nodeViewRenderers: {
25712
+ [Node_Type.EXTERNAL]: (__) => /* @__PURE__ */ React42__namespace.default.createElement(React42__namespace.default.Fragment, null)
25713
+ }
25714
+ });
25715
+ var htmlAttributesDecorator = {
25716
+ rule: (node) => node.type === Node_Type.EXTERNAL,
25717
+ decorate: (_ref) => {
25718
+ var _node$textData, _node$externalData, _node$textData2;
25719
+ let {
25720
+ node
25721
+ } = _ref;
25722
+ if (((_node$textData = node.textData) == null ? void 0 : _node$textData.text) == null) {
25723
+ return /* @__PURE__ */ React42__namespace.default.createElement(React42__namespace.default.Fragment, null);
25724
+ }
25725
+ const props = Object.fromEntries(Object.entries(((_node$externalData = node.externalData) == null ? void 0 : _node$externalData.fields) ?? []).map((_ref2) => {
25726
+ let [k, v] = _ref2;
25727
+ return [k, v.stringValue];
25728
+ }));
25729
+ return /* @__PURE__ */ React42__namespace.default.createElement("span", props, (_node$textData2 = node.textData) == null ? void 0 : _node$textData2.text);
25730
+ }
25731
+ };
25732
+ var UniqueFieldSuffixContext = /* @__PURE__ */ React42.createContext(void 0);
25733
+ var UniqueFieldSuffixContextProvider = (_ref) => {
25734
+ let {
25735
+ parentId = "id",
25736
+ children
25737
+ } = _ref;
25738
+ const {
25739
+ compId = "comp"
25740
+ } = useConfig();
25741
+ const uniqueId = `${compId}-${parentId.split("-").at(0)}`;
25742
+ return /* @__PURE__ */ React42__namespace.default.createElement(UniqueFieldSuffixContext.Provider, {
25743
+ value: uniqueId
25744
+ }, children);
25745
+ };
25746
+ function useUniqueFieldSuffix() {
25747
+ const context = React42.useContext(UniqueFieldSuffixContext);
25748
+ if (context === void 0) {
25749
+ throw new Error("useUniqueFieldSuffix must be used within a UniqueFieldSuffixContextProvider");
25750
+ }
25751
+ return context;
25752
+ }
25753
+ var FocusedFieldContext = /* @__PURE__ */ React42.createContext(void 0);
25754
+ var FocusedFieldProvider = (_ref) => {
25755
+ let {
25756
+ children
25757
+ } = _ref;
25758
+ const [focusedFieldId, setFocusedFieldId] = React42__namespace.default.useState(void 0);
25759
+ const contextValue = React42.useMemo(() => {
25760
+ return {
25761
+ focusedFieldId,
25762
+ setFocusedFieldId
25763
+ };
25764
+ }, [focusedFieldId, setFocusedFieldId]);
25765
+ return /* @__PURE__ */ React42__namespace.default.createElement(FocusedFieldContext.Provider, {
25766
+ value: contextValue
25767
+ }, children);
25768
+ };
25769
+ function useFocusedField() {
25770
+ const context = React42.useContext(FocusedFieldContext);
25771
+ if (context === void 0) {
25772
+ throw new Error("useFocusedField must be used within a FocusedFieldProvider");
25773
+ }
25774
+ return context;
25775
+ }
25776
+
25777
+ // ../form-fields/dist/esm/contexts/events-context.js
25778
+ var EventsContext = /* @__PURE__ */ React42.createContext(void 0);
25779
+ var EventsProvider = (_ref) => {
25780
+ let {
25781
+ children
25782
+ } = _ref;
25783
+ const [submitSuccessCounter, setSubmitSuccessCounter] = React42.useState(0);
25784
+ const [submittedValues, setSubmittedValues] = React42.useState({});
25785
+ const value = React42.useMemo(() => ({
25786
+ submitSuccessCounter,
25787
+ submittedValues,
25788
+ fireSubmitSuccess: (values) => {
25789
+ setSubmitSuccessCounter((previous) => previous + 1);
25790
+ setSubmittedValues(values || {});
25791
+ }
25792
+ }), [submitSuccessCounter, submittedValues]);
25793
+ return /* @__PURE__ */ React42__namespace.default.createElement(EventsContext.Provider, {
25794
+ value
25795
+ }, children);
25796
+ };
25797
+ var useEvents = () => {
25798
+ const context = React42.useContext(EventsContext);
25799
+ if (context === void 0) {
25800
+ throw new Error("useEvents must be used within a EventsProvider");
25801
+ }
25802
+ return context;
25803
+ };
25804
+ var useSubmitSuccessTrigger = () => {
25805
+ const {
25806
+ fireSubmitSuccess
25807
+ } = useEvents();
25808
+ return fireSubmitSuccess;
25809
+ };
25810
+ var useSubmitSuccessEvent = (onSubmitSuccess) => {
25811
+ const {
25812
+ submitSuccessCounter,
25813
+ submittedValues = {}
25814
+ } = useEvents();
25815
+ const previousCounter = React42.useRef(submitSuccessCounter);
25816
+ React42.useEffect(() => {
25817
+ if (previousCounter.current !== submitSuccessCounter) {
25818
+ previousCounter.current = submitSuccessCounter;
25819
+ onSubmitSuccess(submittedValues);
25820
+ }
25821
+ }, [submitSuccessCounter, onSubmitSuccess, submittedValues]);
25822
+ };
25823
+ var useFocusGroupFieldEvent = (groupFieldId, getFocusedChildFieldId) => {
25824
+ const {
25825
+ focusedFieldId,
25826
+ setFocusedFieldId
25827
+ } = useFocusedField();
25828
+ React42.useEffect(() => {
25829
+ if (groupFieldId && focusedFieldId === groupFieldId) {
25830
+ const fieldId = getFocusedChildFieldId();
25831
+ if (fieldId) {
25832
+ setFocusedFieldId(fieldId);
25833
+ }
25834
+ }
25835
+ }, [groupFieldId, focusedFieldId, setFocusedFieldId]);
25836
+ };
25837
+ var useFocusFieldEvent = (onFocusField, fieldId) => {
25838
+ const {
25839
+ focusedFieldId,
25840
+ setFocusedFieldId
25841
+ } = useFocusedField();
25842
+ React42.useEffect(() => {
25843
+ if (fieldId && focusedFieldId && focusedFieldId === fieldId) {
25844
+ onFocusField();
25845
+ setFocusedFieldId(void 0);
25846
+ }
25847
+ }, [fieldId, focusedFieldId, setFocusedFieldId]);
25848
+ };
25849
+ var ScrollContext = /* @__PURE__ */ React42.createContext(void 0);
25850
+ var ScrollProvider = (_ref) => {
25851
+ let {
25852
+ children
25853
+ } = _ref;
25854
+ const scrollViewRef = React42.useRef(null);
25855
+ const value = React42.useMemo(() => ({
25856
+ scrollTo: (element) => {
25857
+ if (element && scrollViewRef.current) {
25858
+ const {
25859
+ top
25860
+ } = element.getBoundingClientRect();
25861
+ if (top < 0 || top > window.innerHeight) {
25862
+ const headerHeight = getSiteHeaderHeight(scrollViewRef.current);
25863
+ const wixAdHeight = getWixAdHeight();
25864
+ const newTop = top + window.scrollY - 20 - headerHeight - wixAdHeight;
25865
+ window.scrollTo({
25866
+ top: newTop,
25867
+ behavior: "smooth"
25868
+ });
25869
+ }
25870
+ }
25871
+ }
25872
+ }), []);
25873
+ return /* @__PURE__ */ React42__namespace.default.createElement("div", {
25874
+ ref: scrollViewRef
25875
+ }, /* @__PURE__ */ React42__namespace.default.createElement(ScrollContext.Provider, {
25876
+ value
25877
+ }, children));
25878
+ };
25879
+ function useScroll() {
25880
+ const context = React42.useContext(ScrollContext);
26107
25881
  if (context === void 0) {
26108
- throw new Error("useFormStatus must be used within a Form Status provider");
25882
+ throw new Error("useScroll must be used within a ScrollProvider");
26109
25883
  }
26110
25884
  return context;
26111
25885
  }
26112
- var WixRicosViewerContext = /* @__PURE__ */ React42.createContext(void 0);
26113
-
26114
- // ../../node_modules/@wix/ricos/dist/es/index.js
26115
- init_v1();
26116
- var DEFAULT_CONFIG = {
26117
- language: "en",
26118
- accountLanguage: "en",
26119
- regionalFormat: "en"
26120
- };
26121
- var ConfigContext = /* @__PURE__ */ React42.createContext(null);
26122
- function ConfigContextProvider(_ref) {
26123
- let {
26124
- value: configInput,
26125
- children
26126
- } = _ref;
26127
- const config = {
26128
- ...configInput,
26129
- language: configInput.language ?? DEFAULT_CONFIG.language,
26130
- accountLanguage: configInput.accountLanguage ?? DEFAULT_CONFIG.accountLanguage,
26131
- regionalFormat: configInput.regionalFormat ?? DEFAULT_CONFIG.regionalFormat
26132
- };
26133
- return /* @__PURE__ */ React42__namespace.default.createElement(ConfigContext.Provider, {
26134
- value: config
26135
- }, children);
25886
+ function getSiteHeaderHeight(formElement) {
25887
+ var _formElement$closest;
25888
+ const classicHeader = document.querySelector("#SITE_HEADER");
25889
+ const potentialHeader = (_formElement$closest = formElement.closest("main")) == null ? void 0 : _formElement$closest.previousElementSibling;
25890
+ const studioHeader = (potentialHeader == null ? void 0 : potentialHeader.tagName) === "HEADER" ? potentialHeader : void 0;
25891
+ const header = classicHeader || studioHeader;
25892
+ const headerPosition = header && window.getComputedStyle(header).position;
25893
+ return header && (headerPosition === "sticky" || headerPosition === "fixed") ? header.getBoundingClientRect().height : 0;
26136
25894
  }
26137
- function useConfig() {
26138
- const context = React42.useContext(ConfigContext);
25895
+ function getWixAdHeight() {
25896
+ const ad = document.querySelector("#WIX_ADS");
25897
+ return ad && window.getComputedStyle(ad).position === "fixed" ? ad.getBoundingClientRect().height : 0;
25898
+ }
25899
+ var TranslationContext = /* @__PURE__ */ React42.createContext(void 0);
25900
+ function useTranslation() {
25901
+ const context = React42.useContext(TranslationContext);
26139
25902
  if (context === void 0) {
26140
- throw new Error("useConfig must be used within a ConfigContext.Provider");
25903
+ throw new Error("useTranslation must be used within a TranslationProvider");
26141
25904
  }
26142
- return context || DEFAULT_CONFIG;
25905
+ return context;
26143
25906
  }
26144
- var htmlAttributesPlugin = (_) => ({
26145
- config: {},
26146
- type: "",
26147
- nodeViewDecorators: [htmlAttributesDecorator],
26148
- nodeViewRenderers: {
26149
- [Node_Type.EXTERNAL]: (__) => /* @__PURE__ */ React42__namespace.default.createElement(React42__namespace.default.Fragment, null)
26150
- }
26151
- });
26152
- var htmlAttributesDecorator = {
26153
- rule: (node) => node.type === Node_Type.EXTERNAL,
26154
- decorate: (_ref) => {
26155
- var _node$textData, _node$externalData, _node$textData2;
26156
- let {
26157
- node
26158
- } = _ref;
26159
- if (((_node$textData = node.textData) == null ? void 0 : _node$textData.text) == null) {
26160
- return /* @__PURE__ */ React42__namespace.default.createElement(React42__namespace.default.Fragment, null);
25907
+ var ExperimentsContext = /* @__PURE__ */ React42.createContext(void 0);
25908
+ var useExperiments = () => {
25909
+ const experiments = React42.useContext(ExperimentsContext) || {};
25910
+ return {
25911
+ experiments,
25912
+ isExperimentEnabled: (spec) => experiments[spec] === true || experiments[spec] === "true" || false
25913
+ };
25914
+ };
25915
+
25916
+ // ../form-schema/dist/esm/services/generate-uuid.js
25917
+ function generateUUID() {
25918
+ let uuid = "";
25919
+ const hexValues = "0123456789abcdef";
25920
+ for (let i = 0; i < 36; i++) {
25921
+ if (i === 8 || i === 13 || i === 18 || i === 23) {
25922
+ uuid += "-";
25923
+ } else if (i === 14) {
25924
+ uuid += "4";
25925
+ } else {
25926
+ uuid += hexValues.charAt(Math.floor(Math.random() * hexValues.length));
26161
25927
  }
26162
- const props = Object.fromEntries(Object.entries(((_node$externalData = node.externalData) == null ? void 0 : _node$externalData.fields) ?? []).map((_ref2) => {
26163
- let [k, v] = _ref2;
26164
- return [k, v.stringValue];
26165
- }));
26166
- return /* @__PURE__ */ React42__namespace.default.createElement("span", props, (_node$textData2 = node.textData) == null ? void 0 : _node$textData2.text);
26167
25928
  }
25929
+ return uuid;
25930
+ }
25931
+
25932
+ // ../form-schema/dist/esm/services/add-field-to-schema.js
25933
+ var addFieldToSchema = (form, field, layout) => {
25934
+ var _form$steps, _newSteps$0$layout;
25935
+ const newSteps = (_form$steps = form.steps) == null ? void 0 : _form$steps.map((step) => {
25936
+ var _step$layout, _step$layout2, _step$layout3;
25937
+ return {
25938
+ ...step,
25939
+ layout: {
25940
+ ...step.layout,
25941
+ large: {
25942
+ ...((_step$layout = step.layout) == null ? void 0 : _step$layout.large) || {},
25943
+ items: ((_step$layout2 = step.layout) == null || (_step$layout2 = _step$layout2.large) == null || (_step$layout2 = _step$layout2.items) == null ? void 0 : _step$layout2.map((item) => {
25944
+ return {
25945
+ ...item,
25946
+ row: layout.row <= item.row ? (item.row || 0) + 1 : item.row
25947
+ };
25948
+ })) || ((_step$layout3 = step.layout) == null || (_step$layout3 = _step$layout3.large) == null ? void 0 : _step$layout3.items)
25949
+ }
25950
+ }
25951
+ };
25952
+ });
25953
+ newSteps == null || (_newSteps$0$layout = newSteps[0].layout) == null || (_newSteps$0$layout = _newSteps$0$layout.large) == null || (_newSteps$0$layout = _newSteps$0$layout.items) == null || _newSteps$0$layout.unshift(layout);
25954
+ return {
25955
+ ...form,
25956
+ fields: [field, ...form.fields || []],
25957
+ steps: newSteps || form.steps
25958
+ };
26168
25959
  };
26169
- var UniqueFieldSuffixContext = /* @__PURE__ */ React42.createContext(void 0);
26170
- var UniqueFieldSuffixContextProvider = (_ref) => {
26171
- let {
26172
- parentId = "id",
26173
- children
26174
- } = _ref;
26175
- const {
26176
- compId = "comp"
26177
- } = useConfig();
26178
- const uniqueId = `${compId}-${parentId.split("-").at(0)}`;
26179
- return /* @__PURE__ */ React42__namespace.default.createElement(UniqueFieldSuffixContext.Provider, {
26180
- value: uniqueId
26181
- }, children);
26182
- };
26183
- function useUniqueFieldSuffix() {
26184
- const context = React42.useContext(UniqueFieldSuffixContext);
25960
+ var BiContext = /* @__PURE__ */ React42.createContext(void 0);
25961
+ function useBi() {
25962
+ const context = React42.useContext(BiContext);
26185
25963
  if (context === void 0) {
26186
- throw new Error("useUniqueFieldSuffix must be used within a UniqueFieldSuffixContextProvider");
25964
+ throw new Error("useBi must be used within a BiProvider");
26187
25965
  }
26188
25966
  return context;
26189
25967
  }
26190
- var FocusedFieldContext = /* @__PURE__ */ React42.createContext(void 0);
26191
- var FocusedFieldProvider = (_ref) => {
26192
- let {
26193
- children
26194
- } = _ref;
26195
- const [focusedFieldId, setFocusedFieldId] = React42__namespace.default.useState(void 0);
26196
- const contextValue = React42.useMemo(() => {
25968
+
25969
+ // ../form-fields/dist/esm/ui/shared/numeric-input-utils.js
25970
+ var getPattern = (multipleOf) => {
25971
+ const decimals = getNumberOfDecimals(multipleOf);
25972
+ const regex = `^-?\\d*(\\.\\d{0,${decimals}})?$`;
25973
+ return regex;
25974
+ };
25975
+ var getNumberOfDecimals = (multipleOf) => {
25976
+ var _String$split;
25977
+ return ((_String$split = String(multipleOf).split(".")) == null || (_String$split = _String$split[1]) == null ? void 0 : _String$split.length) || 0;
25978
+ };
25979
+ var getValidNumberInput = (input, multipleOf, previousValidValue, locale) => {
25980
+ if (input.trim() === "") {
26197
25981
  return {
26198
- focusedFieldId,
26199
- setFocusedFieldId
25982
+ validInput: "",
25983
+ validNumber: void 0
26200
25984
  };
26201
- }, [focusedFieldId, setFocusedFieldId]);
26202
- return /* @__PURE__ */ React42__namespace.default.createElement(FocusedFieldContext.Provider, {
26203
- value: contextValue
26204
- }, children);
25985
+ }
25986
+ const inputNumber = inputToNumber(input);
25987
+ if (isNumberInputValid(inputNumber, multipleOf) && inputNumber < Number.MAX_SAFE_INTEGER) {
25988
+ return {
25989
+ validInput: localizeNumberInput(input, locale),
25990
+ validNumber: inputNumber
25991
+ };
25992
+ }
25993
+ return previousValidValue ? {
25994
+ validInput: previousValidValue,
25995
+ validNumber: inputToNumber(previousValidValue)
25996
+ } : {
25997
+ validInput: "",
25998
+ validNumber: void 0
25999
+ };
26205
26000
  };
26206
- function useFocusedField() {
26207
- const context = React42.useContext(FocusedFieldContext);
26208
- if (context === void 0) {
26209
- throw new Error("useFocusedField must be used within a FocusedFieldProvider");
26001
+ var inputToNumber = (input) => Number(normalizeDecimalSeparator(input));
26002
+ var localizeNumberInput = (input, locale) => {
26003
+ var _Intl$NumberFormat$fo;
26004
+ const decimalSeparator = locale ? (_Intl$NumberFormat$fo = Intl.NumberFormat(locale).formatToParts(1.1).find((part) => part.type === "decimal")) == null ? void 0 : _Intl$NumberFormat$fo.value : void 0;
26005
+ return decimalSeparator ? input.replace(/[.,]/, decimalSeparator) : input;
26006
+ };
26007
+ var isNumberInputValid = (value, multipleOf) => {
26008
+ const multipleOfRegex = getPattern(multipleOf);
26009
+ const validator = new RegExp(multipleOfRegex);
26010
+ return validator.test(`${value}`);
26011
+ };
26012
+ var normalizeDecimalSeparator = function(value) {
26013
+ if (value === void 0) {
26014
+ value = "";
26015
+ }
26016
+ return value.replace(",", ".");
26017
+ };
26018
+
26019
+ // ../form-fields/dist/esm/date-localization/local-date.js
26020
+ function startOfDay(date) {
26021
+ const result2 = new Date(date);
26022
+ result2.setHours(0, 0, 0, 0);
26023
+ return result2;
26024
+ }
26025
+
26026
+ // ../form-fields/dist/esm/date-localization/get-first-day-of-the-week.js
26027
+ var DEFAULT_FIRST_DAY = 1;
26028
+ function getFirstDayOfTheWeek(locale) {
26029
+ try {
26030
+ const intlLocale = new Intl.Locale(locale);
26031
+ if (intlLocale.getWeekInfo) {
26032
+ const weekInfo = intlLocale.getWeekInfo();
26033
+ const firstDay = weekInfo.firstDay;
26034
+ if (firstDay !== void 0) {
26035
+ return firstDay === 7 ? 0 : firstDay;
26036
+ }
26037
+ }
26038
+ return getFirstDayManual(locale);
26039
+ } catch {
26040
+ return getFirstDayManual(locale);
26041
+ }
26042
+ }
26043
+ var REGIONS_STARTING_SATURDAY = ["AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY"];
26044
+ var REGIONS_STARTING_SUNDAY = ["AG", "AS", "BD", "BR", "BS", "BT", "BW", "BZ", "CA", "CO", "DM", "DO", "ET", "GT", "GU", "HK", "HN", "ID", "IL", "IN", "IS", "JM", "JP", "KE", "KH", "KR", "LA", "MH", "MM", "MO", "MT", "MX", "MZ", "NI", "NP", "PA", "PE", "PH", "PK", "PR", "PT", "PY", "SA", "SG", "SV", "TH", "TT", "TW", "UM", "US", "VE", "VI", "WS", "YE", "ZA", "ZW"];
26045
+ var LANGUAGES_STARTING_SATURDAY = ["ar"];
26046
+ var LANGUAGES_STARTING_SUNDAY = ["en", "he", "hi", "id", "ja", "ko", "pt", "tl", "th"];
26047
+ function getFirstDayManual(locale) {
26048
+ try {
26049
+ var _intlLocale$language, _intlLocale$region;
26050
+ const intlLocale = new Intl.Locale(locale);
26051
+ const language = (_intlLocale$language = intlLocale.language) == null ? void 0 : _intlLocale$language.toLowerCase();
26052
+ const region = (_intlLocale$region = intlLocale.region) == null ? void 0 : _intlLocale$region.toUpperCase();
26053
+ if (region) {
26054
+ if (REGIONS_STARTING_SUNDAY.includes(region)) {
26055
+ return 0;
26056
+ }
26057
+ if (REGIONS_STARTING_SATURDAY.includes(region)) {
26058
+ return 6;
26059
+ }
26060
+ return DEFAULT_FIRST_DAY;
26061
+ }
26062
+ if (language) {
26063
+ if (LANGUAGES_STARTING_SUNDAY.includes(language)) {
26064
+ return 0;
26065
+ }
26066
+ if (LANGUAGES_STARTING_SATURDAY.includes(language)) {
26067
+ return 6;
26068
+ }
26069
+ }
26070
+ return DEFAULT_FIRST_DAY;
26071
+ } catch {
26072
+ return DEFAULT_FIRST_DAY;
26210
26073
  }
26211
- return context;
26212
26074
  }
26213
26075
 
26214
- // ../form-fields/dist/esm/contexts/events-context.js
26215
- var EventsContext = /* @__PURE__ */ React42.createContext(void 0);
26216
- var EventsProvider = (_ref) => {
26217
- let {
26218
- children
26219
- } = _ref;
26220
- const [submitSuccessCounter, setSubmitSuccessCounter] = React42.useState(0);
26221
- const [submittedValues, setSubmittedValues] = React42.useState({});
26222
- const value = React42.useMemo(() => ({
26223
- submitSuccessCounter,
26224
- submittedValues,
26225
- fireSubmitSuccess: (values) => {
26226
- setSubmitSuccessCounter((previous) => previous + 1);
26227
- setSubmittedValues(values || {});
26228
- }
26229
- }), [submitSuccessCounter, submittedValues]);
26230
- return /* @__PURE__ */ React42__namespace.default.createElement(EventsContext.Provider, {
26231
- value
26232
- }, children);
26233
- };
26234
- var useEvents = () => {
26235
- const context = React42.useContext(EventsContext);
26236
- if (context === void 0) {
26237
- throw new Error("useEvents must be used within a EventsProvider");
26238
- }
26239
- return context;
26076
+ // ../form-fields/dist/esm/field-settings/settings-shared/availability/availability.js
26077
+ init_types_impl();
26078
+ var ALL_DAYS = [DayOfWeek.SUNDAY, DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY];
26079
+ var DEFAULT_AVAILABILITY = {
26080
+ availableDays: ALL_DAYS
26240
26081
  };
26241
- var useSubmitSuccessTrigger = () => {
26242
- const {
26243
- fireSubmitSuccess
26244
- } = useEvents();
26245
- return fireSubmitSuccess;
26082
+ var NUMERIC_DAY_TO_STRING = {
26083
+ 0: DayOfWeek.SUNDAY,
26084
+ 1: DayOfWeek.MONDAY,
26085
+ 2: DayOfWeek.TUESDAY,
26086
+ 3: DayOfWeek.WEDNESDAY,
26087
+ 4: DayOfWeek.THURSDAY,
26088
+ 5: DayOfWeek.FRIDAY,
26089
+ 6: DayOfWeek.SATURDAY
26246
26090
  };
26247
- var useSubmitSuccessEvent = (onSubmitSuccess) => {
26248
- const {
26249
- submitSuccessCounter,
26250
- submittedValues = {}
26251
- } = useEvents();
26252
- const previousCounter = React42.useRef(submitSuccessCounter);
26253
- React42.useEffect(() => {
26254
- if (previousCounter.current !== submitSuccessCounter) {
26255
- previousCounter.current = submitSuccessCounter;
26256
- onSubmitSuccess(submittedValues);
26091
+ function isDateAvailable(date, availability) {
26092
+ const d = date instanceof Date ? date : new Date(date);
26093
+ if (availability.availableDays) {
26094
+ const dayOfWeek = NUMERIC_DAY_TO_STRING[d.getDay()];
26095
+ if (!availability.availableDays.includes(dayOfWeek)) {
26096
+ return false;
26257
26097
  }
26258
- }, [submitSuccessCounter, onSubmitSuccess, submittedValues]);
26259
- };
26260
- var useFocusGroupFieldEvent = (groupFieldId, getFocusedChildFieldId) => {
26261
- const {
26262
- focusedFieldId,
26263
- setFocusedFieldId
26264
- } = useFocusedField();
26265
- React42.useEffect(() => {
26266
- if (groupFieldId && focusedFieldId === groupFieldId) {
26267
- const fieldId = getFocusedChildFieldId();
26268
- if (fieldId) {
26269
- setFocusedFieldId(fieldId);
26270
- }
26098
+ }
26099
+ if (availability.availableDates && availability.availableDates.length > 0) {
26100
+ const isInAvailableRange = availability.availableDates.some((range) => isDateInRange(d, range));
26101
+ if (!isInAvailableRange) {
26102
+ return false;
26271
26103
  }
26272
- }, [groupFieldId, focusedFieldId, setFocusedFieldId]);
26273
- };
26274
- var useFocusFieldEvent = (onFocusField, fieldId) => {
26275
- const {
26276
- focusedFieldId,
26277
- setFocusedFieldId
26278
- } = useFocusedField();
26279
- React42.useEffect(() => {
26280
- if (fieldId && focusedFieldId && focusedFieldId === fieldId) {
26281
- onFocusField();
26282
- setFocusedFieldId(void 0);
26104
+ }
26105
+ if (availability.unavailableDates && availability.unavailableDates.length > 0) {
26106
+ const isInUnavailableRange = availability.unavailableDates.some((range) => isDateInRange(d, range));
26107
+ if (isInUnavailableRange) {
26108
+ return false;
26283
26109
  }
26284
- }, [fieldId, focusedFieldId, setFocusedFieldId]);
26285
- };
26286
- var ScrollContext = /* @__PURE__ */ React42.createContext(void 0);
26287
- var ScrollProvider = (_ref) => {
26110
+ }
26111
+ return true;
26112
+ }
26113
+ function isDateInRange(date, range) {
26114
+ if (!range.start || !range.end) {
26115
+ return true;
26116
+ }
26117
+ const checkDate = startOfDay(date);
26118
+ const startDate = startOfDay(new Date(range.start));
26119
+ const endDate = startOfDay(new Date(range.end));
26120
+ return checkDate >= startDate && checkDate <= endDate;
26121
+ }
26122
+
26123
+ // ../form-fields/dist/esm/services/get-image-url.js
26124
+ init_max();
26125
+ function getImageURL(_ref, targetWidth, targetHeight, fit) {
26288
26126
  let {
26289
- children
26127
+ id,
26128
+ width,
26129
+ height
26290
26130
  } = _ref;
26291
- const scrollViewRef = React42.useRef(null);
26292
- const value = React42.useMemo(() => ({
26293
- scrollTo: (element) => {
26294
- if (element && scrollViewRef.current) {
26295
- const {
26296
- top
26297
- } = element.getBoundingClientRect();
26298
- if (top < 0 || top > window.innerHeight) {
26299
- const headerHeight = getSiteHeaderHeight(scrollViewRef.current);
26300
- const wixAdHeight = getWixAdHeight();
26301
- const newTop = top + window.scrollY - 20 - headerHeight - wixAdHeight;
26302
- window.scrollTo({
26303
- top: newTop,
26304
- behavior: "smooth"
26305
- });
26131
+ if (fit === void 0) {
26132
+ fit = "fill";
26133
+ }
26134
+ const urlFunction = fit === "fit" ? sdk.getScaleToFitImageURL : sdk.getScaleToFillImageURL;
26135
+ return urlFunction(id, width, height, targetWidth , targetHeight );
26136
+ }
26137
+
26138
+ // ../../node_modules/@wix/sdk-runtime/build/constants.js
26139
+ var SDKRequestToRESTRequestRenameMap = {
26140
+ _id: "id",
26141
+ _createdDate: "createdDate",
26142
+ _updatedDate: "updatedDate"
26143
+ };
26144
+ var RESTResponseToSDKResponseRenameMap = {
26145
+ id: "_id",
26146
+ createdDate: "_createdDate",
26147
+ updatedDate: "_updatedDate"
26148
+ };
26149
+
26150
+ // ../../node_modules/@wix/sdk-runtime/build/rename-all-nested-keys.js
26151
+ function renameAllNestedKeys(payload, renameMap, ignorePaths) {
26152
+ const isIgnored = (path) => ignorePaths.includes(path);
26153
+ const traverse = (obj, path) => {
26154
+ if (Array.isArray(obj)) {
26155
+ obj.forEach((item) => {
26156
+ traverse(item, path);
26157
+ });
26158
+ } else if (typeof obj === "object" && obj !== null) {
26159
+ const objAsRecord = obj;
26160
+ Object.keys(objAsRecord).forEach((key) => {
26161
+ const newPath = path === "" ? key : `${path}.${key}`;
26162
+ if (isIgnored(newPath)) {
26163
+ return;
26306
26164
  }
26307
- }
26165
+ const transformedKey = renameKey(key, renameMap);
26166
+ if (transformedKey !== key && !(transformedKey in objAsRecord)) {
26167
+ objAsRecord[transformedKey] = objAsRecord[key];
26168
+ delete objAsRecord[key];
26169
+ }
26170
+ traverse(objAsRecord[transformedKey], newPath);
26171
+ });
26308
26172
  }
26309
- }), []);
26310
- return /* @__PURE__ */ React42__namespace.default.createElement("div", {
26311
- ref: scrollViewRef
26312
- }, /* @__PURE__ */ React42__namespace.default.createElement(ScrollContext.Provider, {
26313
- value
26314
- }, children));
26315
- };
26316
- function useScroll() {
26317
- const context = React42.useContext(ScrollContext);
26318
- if (context === void 0) {
26319
- throw new Error("useScroll must be used within a ScrollProvider");
26320
- }
26321
- return context;
26173
+ };
26174
+ traverse(payload, "");
26175
+ return payload;
26322
26176
  }
26323
- function getSiteHeaderHeight(formElement) {
26324
- var _formElement$closest;
26325
- const classicHeader = document.querySelector("#SITE_HEADER");
26326
- const potentialHeader = (_formElement$closest = formElement.closest("main")) == null ? void 0 : _formElement$closest.previousElementSibling;
26327
- const studioHeader = (potentialHeader == null ? void 0 : potentialHeader.tagName) === "HEADER" ? potentialHeader : void 0;
26328
- const header = classicHeader || studioHeader;
26329
- const headerPosition = header && window.getComputedStyle(header).position;
26330
- return header && (headerPosition === "sticky" || headerPosition === "fixed") ? header.getBoundingClientRect().height : 0;
26177
+ function renameKey(key, renameMap) {
26178
+ let transformedKey;
26179
+ if (key.includes(".")) {
26180
+ const parts = key.split(".");
26181
+ const transformedParts = parts.map((part) => renameMap[part] ?? part);
26182
+ transformedKey = transformedParts.join(".");
26183
+ } else {
26184
+ transformedKey = renameMap[key] ?? key;
26185
+ }
26186
+ return transformedKey;
26331
26187
  }
26332
- function getWixAdHeight() {
26333
- const ad = document.querySelector("#WIX_ADS");
26334
- return ad && window.getComputedStyle(ad).position === "fixed" ? ad.getBoundingClientRect().height : 0;
26188
+ function renameKeysFromSDKRequestToRESTRequest(payload, ignorePaths = []) {
26189
+ return renameAllNestedKeys(payload, SDKRequestToRESTRequestRenameMap, ignorePaths);
26335
26190
  }
26336
- var TranslationContext = /* @__PURE__ */ React42.createContext(void 0);
26337
- function useTranslation() {
26338
- const context = React42.useContext(TranslationContext);
26339
- if (context === void 0) {
26340
- throw new Error("useTranslation must be used within a TranslationProvider");
26341
- }
26342
- return context;
26191
+ function renameKeysFromRESTResponseToSDKResponse(payload, ignorePaths = []) {
26192
+ return renameAllNestedKeys(payload, RESTResponseToSDKResponseRenameMap, ignorePaths);
26343
26193
  }
26344
- var ExperimentsContext = /* @__PURE__ */ React42.createContext(void 0);
26345
- var useExperiments = () => {
26346
- const experiments = React42.useContext(ExperimentsContext) || {};
26347
- return {
26348
- experiments,
26349
- isExperimentEnabled: (spec) => experiments[spec] === true || experiments[spec] === "true" || false
26350
- };
26351
- };
26352
26194
 
26353
- // ../form-schema/dist/esm/services/generate-uuid.js
26354
- function generateUUID() {
26355
- let uuid = "";
26356
- const hexValues = "0123456789abcdef";
26357
- for (let i = 0; i < 36; i++) {
26358
- if (i === 8 || i === 13 || i === 18 || i === 23) {
26359
- uuid += "-";
26360
- } else if (i === 14) {
26361
- uuid += "4";
26362
- } else {
26363
- uuid += hexValues.charAt(Math.floor(Math.random() * hexValues.length));
26364
- }
26195
+ // ../../node_modules/@wix/sdk-runtime/build/transformations/transform-paths.js
26196
+ function transformPath(obj, { path, isRepeated, isMap }, transformFn) {
26197
+ const pathParts = path.split(".");
26198
+ if (pathParts.length === 1 && path in obj) {
26199
+ obj[path] = isRepeated ? obj[path].map(transformFn) : isMap ? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) : transformFn(obj[path]);
26200
+ return obj;
26201
+ }
26202
+ const [first, ...rest] = pathParts;
26203
+ if (first.endsWith("{}")) {
26204
+ const cleanPath = first.slice(0, -2);
26205
+ obj[cleanPath] = Object.fromEntries(Object.entries(obj[cleanPath]).map(([key, value]) => [
26206
+ key,
26207
+ transformPath(value, { path: rest.join("."), isRepeated, isMap }, transformFn)
26208
+ ]));
26209
+ } else if (Array.isArray(obj[first])) {
26210
+ obj[first] = obj[first].map((item) => transformPath(item, { path: rest.join("."), isRepeated, isMap }, transformFn));
26211
+ } else if (first in obj && typeof obj[first] === "object" && obj[first] !== null) {
26212
+ obj[first] = transformPath(obj[first], { path: rest.join("."), isRepeated, isMap }, transformFn);
26213
+ } else if (first === "*") {
26214
+ Object.keys(obj).reduce((acc, curr) => {
26215
+ acc[curr] = transformPath(obj[curr], { path: rest.join("."), isRepeated, isMap }, transformFn);
26216
+ return acc;
26217
+ }, obj);
26365
26218
  }
26366
- return uuid;
26219
+ return obj;
26220
+ }
26221
+ function transformPaths(obj, transformations) {
26222
+ return transformations.reduce((acc, { paths, transformFn }) => paths.reduce((transformerAcc, path) => transformPath(transformerAcc, path, transformFn), acc), obj);
26367
26223
  }
26368
26224
 
26369
- // ../form-schema/dist/esm/services/add-field-to-schema.js
26370
- var addFieldToSchema = (form, field, layout) => {
26371
- var _form$steps, _newSteps$0$layout;
26372
- const newSteps = (_form$steps = form.steps) == null ? void 0 : _form$steps.map((step) => {
26373
- var _step$layout, _step$layout2, _step$layout3;
26374
- return {
26375
- ...step,
26376
- layout: {
26377
- ...step.layout,
26378
- large: {
26379
- ...((_step$layout = step.layout) == null ? void 0 : _step$layout.large) || {},
26380
- items: ((_step$layout2 = step.layout) == null || (_step$layout2 = _step$layout2.large) == null || (_step$layout2 = _step$layout2.items) == null ? void 0 : _step$layout2.map((item) => {
26381
- return {
26382
- ...item,
26383
- row: layout.row <= item.row ? (item.row || 0) + 1 : item.row
26384
- };
26385
- })) || ((_step$layout3 = step.layout) == null || (_step$layout3 = _step$layout3.large) == null ? void 0 : _step$layout3.items)
26386
- }
26387
- }
26388
- };
26389
- });
26390
- newSteps == null || (_newSteps$0$layout = newSteps[0].layout) == null || (_newSteps$0$layout = _newSteps$0$layout.large) == null || (_newSteps$0$layout = _newSteps$0$layout.items) == null || _newSteps$0$layout.unshift(layout);
26391
- return {
26392
- ...form,
26393
- fields: [field, ...form.fields || []],
26394
- steps: newSteps || form.steps
26395
- };
26396
- };
26397
- var BiContext = /* @__PURE__ */ React42.createContext(void 0);
26398
- function useBi() {
26399
- const context = React42.useContext(BiContext);
26400
- if (context === void 0) {
26401
- throw new Error("useBi must be used within a BiProvider");
26225
+ // ../../node_modules/@wix/sdk-runtime/build/utils.js
26226
+ function removeUndefinedKeys(obj) {
26227
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
26228
+ }
26229
+ function constantCase(input) {
26230
+ return split(input).map((part) => part.toLocaleUpperCase()).join("_");
26231
+ }
26232
+ var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
26233
+ var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
26234
+ var SPLIT_REPLACE_VALUE = "$1\0$2";
26235
+ var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
26236
+ function split(value) {
26237
+ let result2 = value.trim();
26238
+ result2 = result2.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
26239
+ result2 = result2.replace(DEFAULT_STRIP_REGEXP, "\0");
26240
+ let start = 0;
26241
+ let end = result2.length;
26242
+ while (result2.charAt(start) === "\0") {
26243
+ start++;
26402
26244
  }
26403
- return context;
26245
+ if (start === end) {
26246
+ return [];
26247
+ }
26248
+ while (result2.charAt(end - 1) === "\0") {
26249
+ end--;
26250
+ }
26251
+ return result2.slice(start, end).split(/\0/g);
26404
26252
  }
26405
26253
 
26406
- // ../form-fields/dist/esm/ui/shared/numeric-input-utils.js
26407
- var getPattern = (multipleOf) => {
26408
- const decimals = getNumberOfDecimals(multipleOf);
26409
- const regex = `^-?\\d*(\\.\\d{0,${decimals}})?$`;
26410
- return regex;
26411
- };
26412
- var getNumberOfDecimals = (multipleOf) => {
26413
- var _String$split;
26414
- return ((_String$split = String(multipleOf).split(".")) == null || (_String$split = _String$split[1]) == null ? void 0 : _String$split.length) || 0;
26415
- };
26416
- var getValidNumberInput = (input, multipleOf, previousValidValue, locale) => {
26417
- if (input.trim() === "") {
26418
- return {
26419
- validInput: "",
26420
- validNumber: void 0
26421
- };
26254
+ // ../../node_modules/@wix/sdk-runtime/build/transform-error.js
26255
+ var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
26256
+ var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
26257
+ var isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
26258
+ function transformError(httpClientError, pathsToArguments = {
26259
+ explicitPathsToArguments: {},
26260
+ spreadPathsToArguments: {},
26261
+ singleArgumentUnchanged: false
26262
+ }, argumentNames = []) {
26263
+ if (typeof httpClientError !== "object" || httpClientError === null) {
26264
+ throw httpClientError;
26422
26265
  }
26423
- const inputNumber = inputToNumber(input);
26424
- if (isNumberInputValid(inputNumber, multipleOf) && inputNumber < Number.MAX_SAFE_INTEGER) {
26425
- return {
26426
- validInput: localizeNumberInput(input, locale),
26427
- validNumber: inputNumber
26266
+ if (isValidationError(httpClientError)) {
26267
+ return buildValidationError(httpClientError, pathsToArguments, argumentNames);
26268
+ }
26269
+ if (isApplicationError(httpClientError)) {
26270
+ return buildApplicationError(httpClientError);
26271
+ }
26272
+ if (isClientError(httpClientError)) {
26273
+ const status = httpClientError.response?.status;
26274
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
26275
+ const message = httpClientError.response?.data?.message ?? statusText;
26276
+ const details = {
26277
+ applicationError: {
26278
+ description: statusText,
26279
+ code: constantCase(statusText),
26280
+ data: {}
26281
+ },
26282
+ requestId: httpClientError.requestId
26428
26283
  };
26284
+ return wrapError(httpClientError, {
26285
+ message: JSON.stringify({
26286
+ message,
26287
+ details
26288
+ }, null, 2),
26289
+ extraProperties: {
26290
+ details,
26291
+ status
26292
+ }
26293
+ });
26429
26294
  }
26430
- return previousValidValue ? {
26431
- validInput: previousValidValue,
26432
- validNumber: inputToNumber(previousValidValue)
26433
- } : {
26434
- validInput: "",
26435
- validNumber: void 0
26295
+ return buildSystemError(httpClientError);
26296
+ }
26297
+ var buildValidationError = (httpClientError, pathsToArguments, argumentNames) => {
26298
+ const validationErrorResponse = httpClientError.response?.data;
26299
+ const requestId = httpClientError.requestId;
26300
+ const { fieldViolations } = validationErrorResponse.details.validationError;
26301
+ const transformedFieldViolations = violationsWithRenamedFields(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
26302
+ const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
26303
+ const details = {
26304
+ validationError: { fieldViolations: transformedFieldViolations },
26305
+ requestId
26436
26306
  };
26307
+ return wrapError(httpClientError, {
26308
+ message: JSON.stringify({ message, details }, null, 2),
26309
+ extraProperties: {
26310
+ details,
26311
+ status: httpClientError.response?.status,
26312
+ requestId
26313
+ }
26314
+ });
26437
26315
  };
26438
- var inputToNumber = (input) => Number(normalizeDecimalSeparator(input));
26439
- var localizeNumberInput = (input, locale) => {
26440
- var _Intl$NumberFormat$fo;
26441
- const decimalSeparator = locale ? (_Intl$NumberFormat$fo = Intl.NumberFormat(locale).formatToParts(1.1).find((part) => part.type === "decimal")) == null ? void 0 : _Intl$NumberFormat$fo.value : void 0;
26442
- return decimalSeparator ? input.replace(/[.,]/, decimalSeparator) : input;
26316
+ var wrapError = (baseError, { message, extraProperties }) => {
26317
+ return Object.assign(baseError, {
26318
+ ...extraProperties,
26319
+ message
26320
+ });
26443
26321
  };
26444
- var isNumberInputValid = (value, multipleOf) => {
26445
- const multipleOfRegex = getPattern(multipleOf);
26446
- const validator = new RegExp(multipleOfRegex);
26447
- return validator.test(`${value}`);
26322
+ var buildApplicationError = (httpClientError) => {
26323
+ const status = httpClientError.response?.status;
26324
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
26325
+ const message = httpClientError.response?.data?.message ?? statusText;
26326
+ const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
26327
+ const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase(statusText);
26328
+ const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
26329
+ const combinedMessage = message === description ? message : `${message}: ${description}`;
26330
+ const details = {
26331
+ applicationError: {
26332
+ description,
26333
+ code,
26334
+ data
26335
+ },
26336
+ requestId: httpClientError.requestId
26337
+ };
26338
+ return wrapError(httpClientError, {
26339
+ message: JSON.stringify({ message: combinedMessage, details }, null, 2),
26340
+ extraProperties: {
26341
+ details,
26342
+ status,
26343
+ requestId: httpClientError.requestId
26344
+ }
26345
+ });
26448
26346
  };
26449
- var normalizeDecimalSeparator = function(value) {
26450
- if (value === void 0) {
26451
- value = "";
26347
+ var buildSystemError = (httpClientError) => {
26348
+ const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
26349
+ return wrapError(httpClientError, {
26350
+ message,
26351
+ extraProperties: {
26352
+ requestId: httpClientError.requestId,
26353
+ status: httpClientError.response?.status,
26354
+ code: constantCase(httpClientError.response?.statusText ?? "UNKNOWN"),
26355
+ ...!httpClientError.response && {
26356
+ runtimeError: httpClientError
26357
+ }
26358
+ }
26359
+ });
26360
+ };
26361
+ var violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
26362
+ const allPathsToArguments = {
26363
+ ...spreadPathsToArguments,
26364
+ ...explicitPathsToArguments
26365
+ };
26366
+ const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
26367
+ return fieldViolations?.filter((fieldViolation) => {
26368
+ const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
26369
+ return !containedInAMoreSpecificViolationField;
26370
+ }).map((fieldViolation) => {
26371
+ const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
26372
+ if (exactMatchArgumentExpression) {
26373
+ return {
26374
+ ...fieldViolation,
26375
+ field: withRenamedArgument(exactMatchArgumentExpression, argumentNames)
26376
+ };
26377
+ }
26378
+ const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
26379
+ if (longestPartialPathMatch) {
26380
+ const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
26381
+ if (partialMatchArgumentExpression) {
26382
+ return {
26383
+ ...fieldViolation,
26384
+ field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument(partialMatchArgumentExpression, argumentNames))
26385
+ };
26386
+ }
26387
+ }
26388
+ if (singleArgumentUnchanged) {
26389
+ return {
26390
+ ...fieldViolation,
26391
+ field: `${argumentNames[0]}.${fieldViolation.field}`
26392
+ };
26393
+ }
26394
+ return fieldViolation;
26395
+ });
26396
+ };
26397
+ var withRenamedArgument = (fieldValue, argumentNames) => {
26398
+ const argIndex = getArgumentIndex(fieldValue);
26399
+ if (argIndex !== null && typeof argIndex !== "undefined") {
26400
+ return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
26452
26401
  }
26453
- return value.replace(",", ".");
26402
+ return fieldValue;
26403
+ };
26404
+ var getArgumentIndex = (s) => {
26405
+ const match = s.match(/\$\[(?<argIndex>\d+)\]/);
26406
+ return match && match.groups && Number(match.groups.argIndex);
26454
26407
  };
26455
26408
 
26456
- // ../form-fields/dist/esm/date-localization/local-date.js
26457
- function startOfDay(date) {
26458
- const result2 = new Date(date);
26459
- result2.setHours(0, 0, 0, 0);
26460
- return result2;
26461
- }
26462
-
26463
- // ../form-fields/dist/esm/date-localization/get-first-day-of-the-week.js
26464
- var DEFAULT_FIRST_DAY = 1;
26465
- function getFirstDayOfTheWeek(locale) {
26466
- try {
26467
- const intlLocale = new Intl.Locale(locale);
26468
- if (intlLocale.getWeekInfo) {
26469
- const weekInfo = intlLocale.getWeekInfo();
26470
- const firstDay = weekInfo.firstDay;
26471
- if (firstDay !== void 0) {
26472
- return firstDay === 7 ? 0 : firstDay;
26409
+ // ../../node_modules/@wix/sdk-runtime/build/context.js
26410
+ init_browser();
26411
+ function resolveContext() {
26412
+ const oldContext = typeof $wixContext !== "undefined" && $wixContext.initWixModules ? $wixContext.initWixModules : typeof globalThis.__wix_context__ !== "undefined" && globalThis.__wix_context__.initWixModules ? globalThis.__wix_context__.initWixModules : void 0;
26413
+ if (oldContext) {
26414
+ return {
26415
+ // @ts-expect-error
26416
+ initWixModules(modules, elevated) {
26417
+ return runWithoutContext(() => oldContext(modules, elevated));
26418
+ },
26419
+ fetchWithAuth() {
26420
+ throw new Error("fetchWithAuth is not available in this context");
26421
+ },
26422
+ graphql() {
26423
+ throw new Error("graphql is not available in this context");
26473
26424
  }
26474
- }
26475
- return getFirstDayManual(locale);
26476
- } catch {
26477
- return getFirstDayManual(locale);
26425
+ };
26478
26426
  }
26479
- }
26480
- var REGIONS_STARTING_SATURDAY = ["AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY"];
26481
- var REGIONS_STARTING_SUNDAY = ["AG", "AS", "BD", "BR", "BS", "BT", "BW", "BZ", "CA", "CO", "DM", "DO", "ET", "GT", "GU", "HK", "HN", "ID", "IL", "IN", "IS", "JM", "JP", "KE", "KH", "KR", "LA", "MH", "MM", "MO", "MT", "MX", "MZ", "NI", "NP", "PA", "PE", "PH", "PK", "PR", "PT", "PY", "SA", "SG", "SV", "TH", "TT", "TW", "UM", "US", "VE", "VI", "WS", "YE", "ZA", "ZW"];
26482
- var LANGUAGES_STARTING_SATURDAY = ["ar"];
26483
- var LANGUAGES_STARTING_SUNDAY = ["en", "he", "hi", "id", "ja", "ko", "pt", "tl", "th"];
26484
- function getFirstDayManual(locale) {
26485
- try {
26486
- var _intlLocale$language, _intlLocale$region;
26487
- const intlLocale = new Intl.Locale(locale);
26488
- const language = (_intlLocale$language = intlLocale.language) == null ? void 0 : _intlLocale$language.toLowerCase();
26489
- const region = (_intlLocale$region = intlLocale.region) == null ? void 0 : _intlLocale$region.toUpperCase();
26490
- if (region) {
26491
- if (REGIONS_STARTING_SUNDAY.includes(region)) {
26492
- return 0;
26427
+ const contextualClient = typeof $wixContext !== "undefined" ? $wixContext.client : typeof wixContext.client !== "undefined" ? wixContext.client : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.client : void 0;
26428
+ const elevatedClient = typeof $wixContext !== "undefined" ? $wixContext.elevatedClient : typeof wixContext.elevatedClient !== "undefined" ? wixContext.elevatedClient : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.elevatedClient : void 0;
26429
+ if (!contextualClient && !elevatedClient) {
26430
+ return;
26431
+ }
26432
+ return {
26433
+ initWixModules(wixModules, elevated) {
26434
+ if (elevated) {
26435
+ if (!elevatedClient) {
26436
+ 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");
26437
+ }
26438
+ return runWithoutContext(() => elevatedClient.use(wixModules));
26493
26439
  }
26494
- if (REGIONS_STARTING_SATURDAY.includes(region)) {
26495
- return 6;
26440
+ if (!contextualClient) {
26441
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
26496
26442
  }
26497
- return DEFAULT_FIRST_DAY;
26498
- }
26499
- if (language) {
26500
- if (LANGUAGES_STARTING_SUNDAY.includes(language)) {
26501
- return 0;
26443
+ return runWithoutContext(() => contextualClient.use(wixModules));
26444
+ },
26445
+ fetchWithAuth: (urlOrRequest, requestInit) => {
26446
+ if (!contextualClient) {
26447
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
26448
+ }
26449
+ return contextualClient.fetchWithAuth(urlOrRequest, requestInit);
26450
+ },
26451
+ getAuth() {
26452
+ if (!contextualClient) {
26453
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
26502
26454
  }
26503
- if (LANGUAGES_STARTING_SATURDAY.includes(language)) {
26504
- return 6;
26455
+ return contextualClient.auth;
26456
+ },
26457
+ async graphql(query, variables, opts) {
26458
+ if (!contextualClient) {
26459
+ throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
26505
26460
  }
26461
+ return contextualClient.graphql(query, variables, opts);
26506
26462
  }
26507
- return DEFAULT_FIRST_DAY;
26508
- } catch {
26509
- return DEFAULT_FIRST_DAY;
26510
- }
26463
+ };
26511
26464
  }
26512
-
26513
- // ../form-fields/dist/esm/field-settings/settings-shared/availability/availability.js
26514
- init_types_impl();
26515
- var ALL_DAYS = [DayOfWeek.SUNDAY, DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY];
26516
- var DEFAULT_AVAILABILITY = {
26517
- availableDays: ALL_DAYS
26518
- };
26519
- var NUMERIC_DAY_TO_STRING = {
26520
- 0: DayOfWeek.SUNDAY,
26521
- 1: DayOfWeek.MONDAY,
26522
- 2: DayOfWeek.TUESDAY,
26523
- 3: DayOfWeek.WEDNESDAY,
26524
- 4: DayOfWeek.THURSDAY,
26525
- 5: DayOfWeek.FRIDAY,
26526
- 6: DayOfWeek.SATURDAY
26527
- };
26528
- function isDateAvailable(date, availability) {
26529
- const d = date instanceof Date ? date : new Date(date);
26530
- if (availability.availableDays) {
26531
- const dayOfWeek = NUMERIC_DAY_TO_STRING[d.getDay()];
26532
- if (!availability.availableDays.includes(dayOfWeek)) {
26533
- return false;
26534
- }
26535
- }
26536
- if (availability.availableDates && availability.availableDates.length > 0) {
26537
- const isInAvailableRange = availability.availableDates.some((range) => isDateInRange(d, range));
26538
- if (!isInAvailableRange) {
26539
- return false;
26540
- }
26465
+ function runWithoutContext(fn) {
26466
+ const globalContext = globalThis.__wix_context__;
26467
+ const moduleContext = {
26468
+ client: wixContext.client,
26469
+ elevatedClient: wixContext.elevatedClient
26470
+ };
26471
+ let closureContext;
26472
+ globalThis.__wix_context__ = void 0;
26473
+ wixContext.client = void 0;
26474
+ wixContext.elevatedClient = void 0;
26475
+ if (typeof $wixContext !== "undefined") {
26476
+ closureContext = {
26477
+ client: $wixContext?.client,
26478
+ elevatedClient: $wixContext?.elevatedClient
26479
+ };
26480
+ delete $wixContext.client;
26481
+ delete $wixContext.elevatedClient;
26541
26482
  }
26542
- if (availability.unavailableDates && availability.unavailableDates.length > 0) {
26543
- const isInUnavailableRange = availability.unavailableDates.some((range) => isDateInRange(d, range));
26544
- if (isInUnavailableRange) {
26545
- return false;
26483
+ try {
26484
+ return fn();
26485
+ } finally {
26486
+ globalThis.__wix_context__ = globalContext;
26487
+ wixContext.client = moduleContext.client;
26488
+ wixContext.elevatedClient = moduleContext.elevatedClient;
26489
+ if (typeof $wixContext !== "undefined") {
26490
+ $wixContext.client = closureContext.client;
26491
+ $wixContext.elevatedClient = closureContext.elevatedClient;
26546
26492
  }
26547
26493
  }
26548
- return true;
26549
- }
26550
- function isDateInRange(date, range) {
26551
- if (!range.start || !range.end) {
26552
- return true;
26553
- }
26554
- const checkDate = startOfDay(date);
26555
- const startDate = startOfDay(new Date(range.start));
26556
- const endDate = startOfDay(new Date(range.end));
26557
- return checkDate >= startDate && checkDate <= endDate;
26558
26494
  }
26559
26495
 
26560
- // ../form-fields/dist/esm/services/get-image-url.js
26561
- init_max();
26562
- function getImageURL(_ref, targetWidth, targetHeight, fit) {
26563
- let {
26564
- id,
26565
- width,
26566
- height
26567
- } = _ref;
26568
- if (fit === void 0) {
26569
- fit = "fill";
26570
- }
26571
- const urlFunction = fit === "fit" ? sdk.getScaleToFitImageURL : sdk.getScaleToFillImageURL;
26572
- return urlFunction(id, width, height, targetWidth , targetHeight );
26496
+ // ../../node_modules/@wix/sdk-runtime/build/context-v2.js
26497
+ function contextualizeRESTModuleV2(restModule, elevated) {
26498
+ return ((...args) => {
26499
+ const context = resolveContext();
26500
+ if (!context) {
26501
+ return restModule.apply(void 0, args);
26502
+ }
26503
+ return context.initWixModules(restModule, elevated).apply(void 0, args);
26504
+ });
26573
26505
  }
26574
26506
 
26575
- // ../../node_modules/@wix/sdk-runtime/build/rename-all-nested-keys.js
26576
- init_constants();
26577
- function renameAllNestedKeys(payload, renameMap, ignorePaths) {
26578
- const isIgnored = (path) => ignorePaths.includes(path);
26579
- const traverse = (obj, path) => {
26580
- if (Array.isArray(obj)) {
26581
- obj.forEach((item) => {
26582
- traverse(item, path);
26583
- });
26584
- } else if (typeof obj === "object" && obj !== null) {
26585
- const objAsRecord = obj;
26586
- Object.keys(objAsRecord).forEach((key) => {
26587
- const newPath = path === "" ? key : `${path}.${key}`;
26588
- if (isIgnored(newPath)) {
26507
+ // ../../node_modules/@wix/sdk-runtime/build/rest-modules.js
26508
+ function createRESTModule(descriptor, elevated = false) {
26509
+ return contextualizeRESTModuleV2(descriptor, elevated);
26510
+ }
26511
+ function toURLSearchParams(params, isComplexRequest) {
26512
+ const flatten = flattenParams(params);
26513
+ Object.entries(flatten).some(([key, value]) => key.includes(".") || Array.isArray(value) && value.some((v) => typeof v === "object"));
26514
+ {
26515
+ return Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {
26516
+ const keyParams = Array.isArray(value) ? value : [value];
26517
+ keyParams.forEach((param) => {
26518
+ if (param === void 0 || param === null || Array.isArray(value) && typeof param === "object") {
26589
26519
  return;
26590
26520
  }
26591
- const transformedKey = renameKey(key, renameMap);
26592
- if (transformedKey !== key && !(transformedKey in objAsRecord)) {
26593
- objAsRecord[transformedKey] = objAsRecord[key];
26594
- delete objAsRecord[key];
26595
- }
26596
- traverse(objAsRecord[transformedKey], newPath);
26521
+ urlSearchParams.append(key, param);
26597
26522
  });
26523
+ return urlSearchParams;
26524
+ }, new URLSearchParams());
26525
+ }
26526
+ }
26527
+ function resolveUrl(opts) {
26528
+ const domain = resolveDomain(opts.host);
26529
+ const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);
26530
+ const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
26531
+ return resolvePathFromMappings(path, mappings);
26532
+ }
26533
+ function flattenParams(data, path = "") {
26534
+ const params = {};
26535
+ Object.entries(data).forEach(([key, value]) => {
26536
+ const isObject5 = value !== null && typeof value === "object" && !Array.isArray(value);
26537
+ const fieldPath = resolvePath(path, key);
26538
+ if (isObject5) {
26539
+ const serializedObject = flattenParams(value, fieldPath);
26540
+ Object.assign(params, serializedObject);
26541
+ } else {
26542
+ params[fieldPath] = value;
26598
26543
  }
26599
- };
26600
- traverse(payload, "");
26601
- return payload;
26544
+ });
26545
+ return params;
26602
26546
  }
26603
- function renameKey(key, renameMap) {
26604
- let transformedKey;
26605
- if (key.includes(".")) {
26606
- const parts = key.split(".");
26607
- const transformedParts = parts.map((part) => renameMap[part] ?? part);
26608
- transformedKey = transformedParts.join(".");
26609
- } else {
26610
- transformedKey = renameMap[key] ?? key;
26547
+ function resolvePath(path, key) {
26548
+ return `${path}${path ? "." : ""}${key}`;
26549
+ }
26550
+ var DOMAINS = ["wix.com", "editorx.com"];
26551
+ var USER_DOMAIN = "_";
26552
+ var REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
26553
+ var WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
26554
+ var DEV_WIX_CODE_DOMAIN = "dev.wix-code.com";
26555
+ var REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;
26556
+ var REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\.(${WIX_API_DOMAINS.join("|")})$`);
26557
+ var REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\.${DEV_WIX_CODE_DOMAIN}$`);
26558
+ function resolveDomain(host) {
26559
+ const resolvedHost = fixHostExceptions(host);
26560
+ return resolvedHost.replace(REGEX_CAPTURE_DOMAINS, "._base_domain_").replace(REGEX_CAPTURE_API_DOMAINS, "._api_base_domain_").replace(REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, "*.dev.wix-code.com");
26561
+ }
26562
+ function fixHostExceptions(host) {
26563
+ return host.replace("create.editorx.com", "editor.editorx.com");
26564
+ }
26565
+ function resolveMappingsByDomain(domain, domainToMappings) {
26566
+ const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];
26567
+ if (mappings) {
26568
+ return mappings;
26611
26569
  }
26612
- return transformedKey;
26570
+ const rootDomainMappings = resolveRootDomain(domain, domainToMappings);
26571
+ if (!rootDomainMappings) {
26572
+ if (isBaseDomain(domain)) {
26573
+ return domainToMappings[wwwBaseDomain];
26574
+ }
26575
+ }
26576
+ return rootDomainMappings ?? [];
26613
26577
  }
26614
- function renameKeysFromSDKRequestToRESTRequest(payload, ignorePaths = []) {
26615
- return renameAllNestedKeys(payload, SDKRequestToRESTRequestRenameMap, ignorePaths);
26578
+ function resolveRootDomain(domain, domainToMappings) {
26579
+ return Object.entries(domainToMappings).find(([entryDomain]) => {
26580
+ const [, ...rooDomainSegments] = domain.split(".");
26581
+ return rooDomainSegments.join(".") === entryDomain;
26582
+ })?.[1];
26616
26583
  }
26617
- function renameKeysFromRESTResponseToSDKResponse(payload, ignorePaths = []) {
26618
- return renameAllNestedKeys(payload, RESTResponseToSDKResponseRenameMap, ignorePaths);
26584
+ function isBaseDomain(domain) {
26585
+ return !!domain.match(/\._base_domain_$/);
26619
26586
  }
26620
-
26621
- // ../../node_modules/@wix/sdk-runtime/build/transformations/transform-paths.js
26622
- function transformPath(obj, { path, isRepeated, isMap }, transformFn) {
26623
- const pathParts = path.split(".");
26624
- if (pathParts.length === 1 && path in obj) {
26625
- obj[path] = isRepeated ? obj[path].map(transformFn) : isMap ? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) : transformFn(obj[path]);
26626
- return obj;
26587
+ var wwwBaseDomain = "www._base_domain_";
26588
+ function injectDataIntoProtoPath(protoPath, data) {
26589
+ return protoPath.split("/").map((path) => maybeProtoPathToData(path, data)).join("/");
26590
+ }
26591
+ function maybeProtoPathToData(protoPath, data) {
26592
+ const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];
26593
+ const field = protoRegExpMatch[1];
26594
+ if (field) {
26595
+ const suffix = protoPath.replace(protoRegExpMatch[0], "");
26596
+ return findByPath(data, field, protoPath, suffix);
26627
26597
  }
26628
- const [first, ...rest] = pathParts;
26629
- if (first.endsWith("{}")) {
26630
- const cleanPath = first.slice(0, -2);
26631
- obj[cleanPath] = Object.fromEntries(Object.entries(obj[cleanPath]).map(([key, value]) => [
26632
- key,
26633
- transformPath(value, { path: rest.join("."), isRepeated, isMap }, transformFn)
26634
- ]));
26635
- } else if (Array.isArray(obj[first])) {
26636
- obj[first] = obj[first].map((item) => transformPath(item, { path: rest.join("."), isRepeated, isMap }, transformFn));
26637
- } else if (first in obj && typeof obj[first] === "object" && obj[first] !== null) {
26638
- obj[first] = transformPath(obj[first], { path: rest.join("."), isRepeated, isMap }, transformFn);
26639
- } else if (first === "*") {
26640
- Object.keys(obj).reduce((acc, curr) => {
26641
- acc[curr] = transformPath(obj[curr], { path: rest.join("."), isRepeated, isMap }, transformFn);
26642
- return acc;
26643
- }, obj);
26598
+ return protoPath;
26599
+ }
26600
+ function findByPath(obj, path, defaultValue, suffix) {
26601
+ let result2 = obj;
26602
+ for (const field of path.split(".")) {
26603
+ if (!result2) {
26604
+ return defaultValue;
26605
+ }
26606
+ result2 = result2[field];
26644
26607
  }
26645
- return obj;
26608
+ return `${result2}${suffix}`;
26646
26609
  }
26647
- function transformPaths(obj, transformations) {
26648
- return transformations.reduce((acc, { paths, transformFn }) => paths.reduce((transformerAcc, path) => transformPath(transformerAcc, path, transformFn), acc), obj);
26610
+ function resolvePathFromMappings(protoPath, mappings) {
26611
+ const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));
26612
+ if (!mapping) {
26613
+ return protoPath;
26614
+ }
26615
+ return mapping.srcPath + protoPath.slice(mapping.destPath.length);
26649
26616
  }
26650
26617
  var HttpClientContext = /* @__PURE__ */ React42.createContext(void 0);
26651
26618
 
@@ -37758,8 +37725,6 @@ __export(es_exports, {
37758
37725
  SubdivisionType: () => SubdivisionType,
37759
37726
  getPlace: () => getPlace4
37760
37727
  });
37761
- init_transform_error();
37762
- init_rest_modules();
37763
37728
 
37764
37729
  // ../../node_modules/@wix/sdk-runtime/build/transformations/float.js
37765
37730
  function transformSDKFloatToRESTFloat(val) {
@@ -37778,11 +37743,7 @@ function transformRESTFloatToSDKFloat(val) {
37778
37743
  return val;
37779
37744
  }
37780
37745
 
37781
- // ../../node_modules/@wix/auto_sdk_atlas_places/build/es/index.mjs
37782
- init_rest_modules();
37783
-
37784
37746
  // ../../node_modules/@wix/sdk-runtime/build/transformations/address.js
37785
- init_utils2();
37786
37747
  function transformRESTAddressToSDKAddress(payload) {
37787
37748
  return payload && removeUndefinedKeys({
37788
37749
  formatted: payload.formattedAddress,
@@ -37806,7 +37767,6 @@ function transformRESTAddressToSDKAddress(payload) {
37806
37767
  }
37807
37768
 
37808
37769
  // ../../node_modules/@wix/auto_sdk_atlas_places/build/es/index.mjs
37809
- init_rest_modules();
37810
37770
  function resolveComWixpressViAtlasServiceV2PlacesServiceV2Url(opts) {
37811
37771
  const domainToMappings = {
37812
37772
  "api._api_base_domain_": [
@@ -38017,9 +37977,6 @@ __export(es_exports2, {
38017
37977
  FilterType: () => FilterType2,
38018
37978
  predict: () => predict4
38019
37979
  });
38020
- init_transform_error();
38021
- init_rest_modules();
38022
- init_rest_modules();
38023
37980
  function resolveComWixpressViAtlasServiceV2AutocompleteServiceV2Url(opts) {
38024
37981
  const domainToMappings = {
38025
37982
  "api._api_base_domain_": [