@wix/bookings 1.0.1740 → 1.0.1742
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/_sdk-exports/context-booking-checkout-context/runtime.d.ts +2784 -0
- package/_sdk-exports/context-booking-checkout-context/runtime.js +2 -0
- package/_sdk-exports/context-categories-context/runtime.d.ts +144 -0
- package/_sdk-exports/context-categories-context/runtime.js +1 -0
- package/_sdk-exports/context-locations-context/runtime.d.ts +282 -0
- package/_sdk-exports/context-locations-context/runtime.js +1 -0
- package/_sdk-exports/context-service-addons-context/runtime.d.ts +264 -0
- package/_sdk-exports/context-service-addons-context/runtime.js +1 -0
- package/_sdk-exports/context-service-context/runtime.d.ts +3667 -0
- package/_sdk-exports/context-service-context/runtime.js +2 -0
- package/_sdk-exports/context-services-context/runtime.d.ts +2863 -0
- package/_sdk-exports/context-services-context/runtime.js +2 -0
- package/_sdk-exports/context-time-slots-context/runtime.d.ts +660 -0
- package/_sdk-exports/context-time-slots-context/runtime.js +2 -0
- package/build/cjs/context-booking-checkout-context.d.ts +2784 -0
- package/build/cjs/context-booking-checkout-context.js +3940 -0
- package/build/cjs/context-booking-checkout-context.js.map +1 -0
- package/build/cjs/context-categories-context.d.ts +144 -0
- package/build/cjs/context-categories-context.js +1188 -0
- package/build/cjs/context-categories-context.js.map +1 -0
- package/build/cjs/context-locations-context.d.ts +282 -0
- package/build/cjs/context-locations-context.js +1252 -0
- package/build/cjs/context-locations-context.js.map +1 -0
- package/build/cjs/context-service-addons-context.d.ts +264 -0
- package/build/cjs/context-service-addons-context.js +1324 -0
- package/build/cjs/context-service-addons-context.js.map +1 -0
- package/build/cjs/context-service-context.d.ts +3667 -0
- package/build/cjs/context-service-context.js +5330 -0
- package/build/cjs/context-service-context.js.map +1 -0
- package/build/cjs/context-services-context.d.ts +2863 -0
- package/build/cjs/context-services-context.js +2203 -0
- package/build/cjs/context-services-context.js.map +1 -0
- package/build/cjs/context-time-slots-context.d.ts +660 -0
- package/build/cjs/context-time-slots-context.js +2822 -0
- package/build/cjs/context-time-slots-context.js.map +1 -0
- package/build/es/context-booking-checkout-context.d.mts +2784 -0
- package/build/es/context-booking-checkout-context.mjs +3898 -0
- package/build/es/context-booking-checkout-context.mjs.map +1 -0
- package/build/es/context-categories-context.d.mts +144 -0
- package/build/es/context-categories-context.mjs +1157 -0
- package/build/es/context-categories-context.mjs.map +1 -0
- package/build/es/context-locations-context.d.mts +282 -0
- package/build/es/context-locations-context.mjs +1221 -0
- package/build/es/context-locations-context.mjs.map +1 -0
- package/build/es/context-service-addons-context.d.mts +264 -0
- package/build/es/context-service-addons-context.mjs +1294 -0
- package/build/es/context-service-addons-context.mjs.map +1 -0
- package/build/es/context-service-context.d.mts +3667 -0
- package/build/es/context-service-context.mjs +5298 -0
- package/build/es/context-service-context.mjs.map +1 -0
- package/build/es/context-services-context.d.mts +2863 -0
- package/build/es/context-services-context.mjs +2172 -0
- package/build/es/context-services-context.mjs.map +1 -0
- package/build/es/context-time-slots-context.d.mts +660 -0
- package/build/es/context-time-slots-context.mjs +2792 -0
- package/build/es/context-time-slots-context.mjs.map +1 -0
- package/build/internal/cjs/context-booking-checkout-context.d.ts +2784 -0
- package/build/internal/cjs/context-categories-context.d.ts +144 -0
- package/build/internal/cjs/context-locations-context.d.ts +282 -0
- package/build/internal/cjs/context-service-addons-context.d.ts +264 -0
- package/build/internal/cjs/context-service-context.d.ts +3667 -0
- package/build/internal/cjs/context-services-context.d.ts +2863 -0
- package/build/internal/cjs/context-time-slots-context.d.ts +660 -0
- package/build/internal/es/context-booking-checkout-context.d.mts +2784 -0
- package/build/internal/es/context-categories-context.d.mts +144 -0
- package/build/internal/es/context-locations-context.d.mts +282 -0
- package/build/internal/es/context-service-addons-context.d.mts +264 -0
- package/build/internal/es/context-service-context.d.mts +3667 -0
- package/build/internal/es/context-services-context.d.mts +2863 -0
- package/build/internal/es/context-time-slots-context.d.mts +660 -0
- package/context/booking-checkout-context/package.json +3 -0
- package/context/categories-context/package.json +3 -0
- package/context/locations-context/package.json +3 -0
- package/context/service-addons-context/package.json +3 -0
- package/context/service-context/package.json +3 -0
- package/context/services-context/package.json +3 -0
- package/context/time-slots-context/package.json +3 -0
- package/package.json +69 -8
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/type-fest/source/observable-like.d.ts
|
|
4
|
+
declare global {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
6
|
+
interface SymbolConstructor {
|
|
7
|
+
readonly observable: symbol;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
@remarks
|
|
12
|
+
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
13
|
+
As well, some guidance on making an `Observable` to not include `closed` property.
|
|
14
|
+
@see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
|
|
15
|
+
@see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
|
|
16
|
+
@see https://github.com/benlesh/symbol-observable#making-an-object-observable
|
|
17
|
+
|
|
18
|
+
@category Observable
|
|
19
|
+
*/
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../../node_modules/@wix/sdk-types/internal/build/index.d.ts
|
|
22
|
+
declare global {
|
|
23
|
+
interface ContextualClient {}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates concrete types from SDK descriptors when a contextual client is
|
|
27
|
+
* available.
|
|
28
|
+
*
|
|
29
|
+
* For a REST descriptor the built (bound) API is intersected with the original
|
|
30
|
+
* descriptor, matching what `contextualizeRESTModuleV2` returns at runtime — a
|
|
31
|
+
* value callable as the bound API and still usable as a descriptor. Keeping the
|
|
32
|
+
* descriptor half lets contextual modules be passed to descriptor-constrained
|
|
33
|
+
* helpers such as `elevate` from `@wix/sdk/context` (FEDINF-14092).
|
|
34
|
+
*
|
|
35
|
+
* The `& T` is scoped to REST descriptors — the only shape codegen wraps in
|
|
36
|
+
* `MaybeContext` — so `BuildDescriptors` (used by `createClient().use`) is left
|
|
37
|
+
* unchanged and stays bound-only. The fix lives here rather than in `elevate`,
|
|
38
|
+
* which is kept strict on purpose (see #941) so it still rejects bound-only
|
|
39
|
+
* functions that are unsafe through `createRESTModule`.
|
|
40
|
+
*/
|
|
41
|
+
declare global {
|
|
42
|
+
/**
|
|
43
|
+
* A global interface to set the exposure toggle for the SDK.
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* declare global {
|
|
47
|
+
* interface SDKExposureToggle {
|
|
48
|
+
* alpha: true;
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
interface SDKExposureToggle {}
|
|
53
|
+
}
|
|
54
|
+
declare global {
|
|
55
|
+
/**
|
|
56
|
+
* A global interface to set the type mode for the SDK.
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* declare global {
|
|
60
|
+
* interface SDKTypeMode {
|
|
61
|
+
* strict: true;
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
65
|
+
interface SDKTypeMode {}
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-Bf4TC5aj.d.mts
|
|
69
|
+
/**
|
|
70
|
+
* Money.
|
|
71
|
+
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
72
|
+
*/
|
|
73
|
+
interface Money {
|
|
74
|
+
/**
|
|
75
|
+
* Monetary amount. Decimal string with a period as a decimal separator. For example `25.05`.
|
|
76
|
+
* @format DECIMAL_VALUE
|
|
77
|
+
* @decimalValue options { gt:0, maxScale:2 }
|
|
78
|
+
*/
|
|
79
|
+
value?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Currency code in [ISO 4217 format](https://en.wikipedia.org/wiki/ISO_4217). For example, `USD`.
|
|
82
|
+
* @format CURRENCY
|
|
83
|
+
* @readonly
|
|
84
|
+
*/
|
|
85
|
+
currency?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Monetary amount. Decimal string in local format. For example, `1 000,30`.
|
|
88
|
+
* @maxLength 50
|
|
89
|
+
*/
|
|
90
|
+
formattedValue?: string | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A deposit expressed as exactly one of a fixed monetary amount or a percentage of the full service price.
|
|
94
|
+
* Structurally exclusive: at most one of `amount` or `percentage` may be set.
|
|
95
|
+
*/
|
|
96
|
+
interface BookedAddOn {
|
|
97
|
+
/**
|
|
98
|
+
* The ID of the add-on.
|
|
99
|
+
* @format GUID
|
|
100
|
+
*/
|
|
101
|
+
_id?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The ID of the add-on group.
|
|
104
|
+
* @format GUID
|
|
105
|
+
*/
|
|
106
|
+
groupId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The add-on duration in minutes at the time of booking.
|
|
109
|
+
* Populated for duration-based add-ons.
|
|
110
|
+
* @min 1
|
|
111
|
+
* @max 1440
|
|
112
|
+
* @readonly
|
|
113
|
+
*/
|
|
114
|
+
durationInMinutes?: number | null;
|
|
115
|
+
/**
|
|
116
|
+
* The quantity of booked add-ons.
|
|
117
|
+
* For duration-based add-ons, `quantity` is not applicable.
|
|
118
|
+
* If `quantity` is provided as `1` for a duration-based add-on, it will be accepted but the value will be cleared.
|
|
119
|
+
* If any other value is provided, an `INVALID_ARGUMENT` error will be returned with the message: "Invalid AddOn details: either duration or quantity must be set correctly".
|
|
120
|
+
* @min 1
|
|
121
|
+
* @max 1000
|
|
122
|
+
*/
|
|
123
|
+
quantity?: number | null;
|
|
124
|
+
/**
|
|
125
|
+
* Add-on `name` at the time of booking.
|
|
126
|
+
* @maxLength 100
|
|
127
|
+
* @readonly
|
|
128
|
+
*/
|
|
129
|
+
name?: string | null;
|
|
130
|
+
/**
|
|
131
|
+
* Add-on name translated to the language the customer used during booking.
|
|
132
|
+
* @maxLength 100
|
|
133
|
+
* @readonly
|
|
134
|
+
*/
|
|
135
|
+
nameTranslated?: string | null;
|
|
136
|
+
}
|
|
137
|
+
/** Server-computed datetime adjusted to a requested timezone. */
|
|
138
|
+
interface AddOn$2 extends AddOnAddOnInfoOneOf {
|
|
139
|
+
/** Duration in minutes for duration-based add-ons that extend booking service time. */
|
|
140
|
+
durationInMinutes?: number;
|
|
141
|
+
/** Maximum quantity customers can purchase for quantity-based add-ons. */
|
|
142
|
+
maxQuantity?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Add-on ID.
|
|
145
|
+
* @format GUID
|
|
146
|
+
*/
|
|
147
|
+
addOnId?: string | null;
|
|
148
|
+
/**
|
|
149
|
+
* Add-on name displayed to customers.
|
|
150
|
+
* @maxLength 100
|
|
151
|
+
*/
|
|
152
|
+
name?: string | null;
|
|
153
|
+
/** Add-on price. */
|
|
154
|
+
price?: Money;
|
|
155
|
+
/**
|
|
156
|
+
* Translated add-on name.
|
|
157
|
+
* @maxLength 100
|
|
158
|
+
*/
|
|
159
|
+
nameTranslated?: string | null;
|
|
160
|
+
}
|
|
161
|
+
/** @oneof */
|
|
162
|
+
interface AddOnAddOnInfoOneOf {
|
|
163
|
+
/** Duration in minutes for duration-based add-ons that extend booking service time. */
|
|
164
|
+
durationInMinutes?: number;
|
|
165
|
+
/** Maximum quantity customers can purchase for quantity-based add-ons. */
|
|
166
|
+
maxQuantity?: number;
|
|
167
|
+
}
|
|
168
|
+
interface AddOnGroupDetail$1 {
|
|
169
|
+
/**
|
|
170
|
+
* Group ID.
|
|
171
|
+
* @format GUID
|
|
172
|
+
*/
|
|
173
|
+
groupId?: string | null;
|
|
174
|
+
/** Maximum number of add-ons customers can select from this group. */
|
|
175
|
+
maxNumberOfAddOns?: number | null;
|
|
176
|
+
/**
|
|
177
|
+
* Group name displayed to customers.
|
|
178
|
+
* @maxLength 100
|
|
179
|
+
*/
|
|
180
|
+
groupName?: string | null;
|
|
181
|
+
/**
|
|
182
|
+
* Add-ons linked to this group in display order.
|
|
183
|
+
* @maxSize 7
|
|
184
|
+
*/
|
|
185
|
+
addOns?: AddOn$2[];
|
|
186
|
+
/**
|
|
187
|
+
* Instructional prompt displayed to customers. For example, `Choose up to 2 relaxing spa treatments to enhance your experience`. You can also use this field as a group description. For example, `Beginner-friendly rental equipment`.
|
|
188
|
+
* @maxLength 200
|
|
189
|
+
*/
|
|
190
|
+
prompt?: string | null;
|
|
191
|
+
/**
|
|
192
|
+
* Translated group name.
|
|
193
|
+
* @maxLength 100
|
|
194
|
+
*/
|
|
195
|
+
groupNameTranslated?: string | null;
|
|
196
|
+
/**
|
|
197
|
+
* Instructional translated prompt displayed to customers. For example, `Choose up to 2 relaxing spa treatments to enhance your experience`. You can also use this field as a group description. For example, `Beginner-friendly rental equipment`.
|
|
198
|
+
* @maxLength 200
|
|
199
|
+
*/
|
|
200
|
+
promptTranslated?: string | null;
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region ../bookings-flow-data/dist/types.d.ts
|
|
204
|
+
/** A chosen add-on with its quantity — maps SDK `BookedAddOn` fields to flow names (`id` ↔ `_id`). */
|
|
205
|
+
type AddOn$1 = {
|
|
206
|
+
id: NonNullable<BookedAddOn['_id']>;
|
|
207
|
+
quantity: NonNullable<BookedAddOn['quantity']>;
|
|
208
|
+
};
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/api/adapters/service-addons/service-addons.d.ts
|
|
211
|
+
type AddOnGroupDetail = AddOnGroupDetail$1;
|
|
212
|
+
type AddOn = AddOn$2;
|
|
213
|
+
interface AddOnItem {
|
|
214
|
+
addOnId: NonNullable<AddOn['addOnId']> | null;
|
|
215
|
+
addOnName: NonNullable<AddOn['name']> | null;
|
|
216
|
+
addOnPrice: string | null;
|
|
217
|
+
/** Same currency as the service. */
|
|
218
|
+
addOnPriceValue?: number | null;
|
|
219
|
+
/** A free service has none of its own to price its add-ons in. */
|
|
220
|
+
addOnCurrency?: string | null;
|
|
221
|
+
durationInMinutes: NonNullable<AddOn['durationInMinutes']> | null;
|
|
222
|
+
maxQuantity: NonNullable<AddOn['maxQuantity']> | null;
|
|
223
|
+
isSelected: boolean;
|
|
224
|
+
selectedQuantity: number;
|
|
225
|
+
}
|
|
226
|
+
interface AddOnGroupItem {
|
|
227
|
+
groupId: NonNullable<AddOnGroupDetail['groupId']> | null;
|
|
228
|
+
groupName: NonNullable<AddOnGroupDetail['groupName']> | null;
|
|
229
|
+
prompt: NonNullable<AddOnGroupDetail['prompt']> | null;
|
|
230
|
+
/** Max distinct add-ons, not units. */
|
|
231
|
+
maxNumberOfAddOns: NonNullable<AddOnGroupDetail['maxNumberOfAddOns']> | null;
|
|
232
|
+
addOns: AddOnItem[];
|
|
233
|
+
selectedCount: number;
|
|
234
|
+
canSelectMore: boolean;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/extensions/contexts/service-addons-context/service-addons-context.types.d.ts
|
|
238
|
+
/** The add-ons offered for the current service, the visitor's picks, and the actions to change them. */
|
|
239
|
+
interface ServiceAddOnsContextValue {
|
|
240
|
+
addOnGroups: AddOnGroupItem[];
|
|
241
|
+
/** Only picks the catalog offers. */
|
|
242
|
+
selected: AddOn$1[];
|
|
243
|
+
isLoading: boolean;
|
|
244
|
+
hasError: boolean;
|
|
245
|
+
/** No-op turning on when its group (the first offering it) is at maxNumberOfAddOns. */
|
|
246
|
+
toggleAddOn: (addOnId: string) => void;
|
|
247
|
+
/** Clamped to [0, maxQuantity]; 0 removes it. */
|
|
248
|
+
setAddOnQuantity: (addOnId: string, quantity: number) => void;
|
|
249
|
+
}
|
|
250
|
+
/** Props accepted by {@link ServiceAddOnsContextProvider}. */
|
|
251
|
+
interface ServiceAddOnsContextProviderProps {
|
|
252
|
+
children: ReactNode;
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/extensions/contexts/service-addons-context/service-addons-context.d.ts
|
|
256
|
+
declare const serviceAddOnsContext: React.Context<ServiceAddOnsContextValue | null>;
|
|
257
|
+
/** Reads the service add-ons state; throws when no ServiceAddOnsContextProvider is above. */
|
|
258
|
+
declare function useServiceAddOnsContext(): ServiceAddOnsContextValue;
|
|
259
|
+
/** Loads the add-ons offered for the service in the surrounding ServiceContextProvider, and reads and changes the visitor's picks stored there. */
|
|
260
|
+
declare function ServiceAddOnsContextProvider({
|
|
261
|
+
children
|
|
262
|
+
}: ServiceAddOnsContextProviderProps): React.JSX.Element;
|
|
263
|
+
//#endregion
|
|
264
|
+
export { type AddOnGroupItem, type AddOnItem, type ServiceAddOnsContextProviderProps, type ServiceAddOnsContextValue, ServiceAddOnsContextProvider as default, serviceAddOnsContext, useServiceAddOnsContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Component as e,Suspense as t,createContext as n,useCallback as r,useContext as i,useEffect as a,useMemo as o,useRef as s,useSyncExternalStore as c}from"react";import{useServiceContext as l}from"@wix/bookings/context/service-context";import{useGetService as u,useService as d}from"@wix/services-manager-react";import{jsx as f}from"react/jsx-runtime";var p={};function m(e,t=!1,n=e=>e){return()=>({__type:`event-definition`,type:e,isDomainEvent:t,transformations:n})}var h=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 Error(`Unknown method: ${e}`)}},g=e=>t=>async n=>{let r,i=t=>{if(r=e(n)(t),r.url===void 0)throw Error(`Url was not successfully created for this request, please reach out to support channels for assistance.`);let{method:i,url:a,params:o}=r;return{...r,method:h(i),url:a,data:r.data,params:o}};try{let e=await t.request(i);if(r===void 0)throw Error(`Request options were not created for this request, please reach out to support channels for assistance.`);let n=Array.isArray(r.transformResponse)?r.transformResponse:[r.transformResponse],a=e.data;return n.forEach(t=>{t&&(a=t(e.data,e.headers))}),a}catch(e){throw typeof e==`object`&&e&&`response`in e&&typeof e.response==`object`&&e.response!==null&&`data`in e.response?e.response.data:e}},_=e=>e.__isAmbassador?!0:!!e().__isAmbassador,v=`__metadata`,y=`edge.wixapis.com`,ee=class extends Error{message;response;constructor(e,t){super(e),this.message=e,this.response=t}async details(){let e=await this.response.json();return te(this.response.status,e?.message,e?.details,{requestId:this.response.headers.get(`X-Wix-Request-Id`),details:e})}},te=(e,t,n,r)=>({details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:r}},...n},message:t,requestId:r?.requestId}),ne=e=>e?.method&&[`post`,`put`,`patch`].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":`application/json`}:{},re=e=>e&&typeof e==`object`&&!Array.isArray(e),ie=e=>e.__type===`host`;function ae(e,t){return e.create(t)}var oe=`x-wix-bi-gateway`;function se(e,t,n){return{[oe]:ce({environment:`js-sdk${n?`-${n}`:``}`,"package-name":e.packageName??t?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function ce(e){return Object.entries(e).filter(([e,t])=>!!t).map(([e,t])=>`${e}=${t}`).join(`,`)}function le(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}var ue={id:`_id`,createdDate:`_createdDate`,updatedDate:`_updatedDate`};function b(e){return he(e).map(e=>e.toLocaleUpperCase()).join(`_`)}var de=/([\p{Ll}\d])(\p{Lu})/gu,fe=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,pe=`$1\0$2`,me=/[^\p{L}\d]+/giu;function he(e){let t=e.trim();t=t.replace(de,pe).replace(fe,pe),t=t.replace(me,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}var ge=e=>`validationError`in(e.response?.data?.details??{}),_e=e=>`applicationError`in(e.response?.data?.details??{}),ve=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function ye(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},n=[]){if(typeof e!=`object`||!e)throw e;if(ge(e))return be(e,t,n);if(_e(e))return xe(e);if(ve(e)){let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i={applicationError:{description:n,code:b(n),data:{}},requestId:e.requestId};return x(e,{message:JSON.stringify({message:r,details:i},null,2),extraProperties:{details:i,status:t}})}return Se(e)}var be=(e,t,n)=>{let r=e.response?.data,i=e.requestId,{fieldViolations:a}=r.details.validationError,o=Ce(t,a,n)?.sort((e,t)=>e.field<t.field?-1:1),s=`INVALID_ARGUMENT: ${o?.map(({field:e,description:t})=>`"${e}" ${t}`)?.join(`, `)}`,c={validationError:{fieldViolations:o},requestId:i};return x(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:i}})},x=(e,{message:t,extraProperties:n})=>Object.assign(e,{...n,message:t}),xe=e=>{let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i=e.response?.data?.details?.applicationError?.description??n,a=e.response?.data?.details?.applicationError?.code??b(n),o=e.response?.data?.details?.applicationError?.data??{},s=r===i?r:`${r}: ${i}`,c={applicationError:{description:i,code:a,data:o},requestId:e.requestId};return x(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},Se=e=>x(e,{message:e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`,extraProperties:{requestId:e.requestId,status:e.response?.status,code:b(e.response?.statusText??`UNKNOWN`),...!e.response&&{runtimeError:e}}}),Ce=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:n},r,i)=>{let a={...e,...t},o=Object.keys(a);return r?.filter(e=>!r.some(t=>t.field.length>e.field.length&&t.field.startsWith(e.field)&&o.includes(t.field))).map(e=>{let r=t[e.field];if(r)return{...e,field:S(r,i)};let s=o?.sort((e,t)=>t.length-e.length)?.find(t=>e.field.startsWith(t));if(s){let t=a[s];if(t)return{...e,field:e.field.replace(s,S(t,i))}}return n?{...e,field:`${i[0]}.${e.field}`}:e})},S=(e,t)=>{let n=we(e);return n==null?e:e.replace(`$[${n}]`,t[n])},we=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function Te(e,t,n,r,i,a,o,s,c,l,u){return le(()=>e({request:async e=>{let i=e({host:s?.HTTPHost||`www.wixapis.com`}),a=i;a.method===`GET`&&a.fallback?.length&&(a.params?.toString().length??0)>4e3&&(a=i.fallback[0]);let o=s?.HTTPHost??`www.wixapis.com`,u=`https://${l?y:o}${a.url}`;a.params&&a.params.toString()&&(u+=`?${a.params.toString()}`);try{let e=se(i,t,c),o={method:a.method,...a.data&&{body:JSON.stringify(a.data)},headers:{...e}},s=await n(u,o);if(s.status!==200){let e=null;try{e=await s.json()}catch{}let t=De(s.status,e?.message??s.statusText,e?.details,{requestId:s.headers.get(`X-Wix-Request-Id`),details:e}),n=ye(t);throw r?.handleError(n,{requestOptions:{url:a.url,method:a.method,entityFqdn:i.entityFqdn,methodFqn:i.methodFqn}}),t}let l=await s.json();return{data:a.migrationOptions?.optInTransformResponse&&a.transformResponse?Array.isArray(a.transformResponse)?a.transformResponse[0](l):a.transformResponse(l):l,headers:s.headers,status:s.status,statusText:s.statusText}}catch(e){throw e.message?.includes(`fetch is not defined`)&&console.error(`Node.js v18+ is required`),e}},fetchWithAuth:n,wixAPIFetch:i,getActiveToken:a,getAuthHeaders:o},{validateRequestSchema:u}))}var Ee=class extends Error{response;requestId;constructor(e){super(),this.response=e.response,this.requestId=e.requestId}},De=(e,t,n,r)=>new Ee({response:{data:{details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:r}},...n},message:t},status:e},requestId:r?.requestId}),Oe=`.`;function ke(e,t,n){if(e==null)throw Error(`Cannot set value on null or undefined`);let r=C(t),i=e;for(let e=0;e<r.length;e++){let t=r[e];if(e===r.length-1){i[t]=n;break}let a=r[e+1];(!(t in i)||i[t]==null||typeof i[t]!=`object`||i[t]===null)&&(i[t]=typeof a==`number`?[]:{}),i=i[t]}return e}function C(e){return Array.isArray(e)?e:e.split(Oe).map(e=>Ae(e)?Number(e):e)}function Ae(e){return/^\d+$/.test(e)}function je(e){let t={};for(let[n,r]of Object.entries(e))Me(n)||ke(t,C(n),r);return t}function Me(e){return e===`__proto__`||e===`constructor`||e===`prototype`}var Ne=class{BRACKET_PATTERN=/\[(\d+)\]/g;NUMERIC_PATTERN=/^\d+$/;ESCAPED_DOT_PATTERN=/\\\./g;ESCAPED_LEFT_BRACKET_PATTERN=/\\\[/g;ESCAPED_RIGHT_BRACKET_PATTERN=/\\\]/g;SPLIT_PATTERN=/\.|\[(\d+)\]/g;DOT_BEFORE_BRACKET_PATTERN=/\.\[/g;ESCAPED_DOT_PLACEHOLDER=`__DOT__`;ESCAPED_RIGHT_BRACKET_PLACEHOLDER=`__RB__`;ESCAPED_LEFT_BRACKET_PLACEHOLDER=`__LB__`;modifiedFields;cleanedModifiedFields;constructor(e){this.modifiedFields=e}replaceEscapedCharacters(e){return e.replace(this.ESCAPED_DOT_PATTERN,this.ESCAPED_DOT_PLACEHOLDER).replace(this.ESCAPED_LEFT_BRACKET_PATTERN,this.ESCAPED_LEFT_BRACKET_PLACEHOLDER).replace(this.ESCAPED_RIGHT_BRACKET_PATTERN,this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER)}restoreEscapedCharacters(e){return e.replace(this.ESCAPED_DOT_PLACEHOLDER,`\\.`).replace(this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER,`\\]`).replace(this.ESCAPED_LEFT_BRACKET_PLACEHOLDER,`\\[`)}unflatten(){return this.cleanedModifiedFields=Object.fromEntries(Object.entries(this.modifiedFields).map(([e,t])=>[this.replaceEscapedCharacters(this.bracketToDotNotation(e)),t])),je(this.cleanedModifiedFields)}flatten(e){let t={};for(let n of Object.keys(this.cleanedModifiedFields)){let r=this.splitPath(n),i=this.navigatePath(e,r);t={...t,...i}}return Object.fromEntries(Object.entries(t).map(([e,t])=>[this.restoreEscapedCharacters(e),t]))}splitPath(e){let t=[],n=0,r=Array.from(e.matchAll(this.SPLIT_PATTERN));for(let i of r)i.index>n&&t.push(e.substring(n,i.index)),i[1]&&t.push(i[1]),n=i.index+i[0].length;return n<e.length&&t.push(e.substring(n)),t}navigatePath(e,t){let n=e,r=[],i=e=>{if(!Array.isArray(n))throw Error(`Expected array at path ${this.buildPathString(r)}, but got ${typeof n}`);r.push(`[${e}]`),n=n[parseInt(e,10)]},a=(e,t)=>{let i=e in ue?ue[e]:void 0;if(i&&i in t){r.push(i),n=t[i];return}let a=Le(e);if(a&&a in t){r.push(a),n=t[a];return}throw Error(`Cannot find key '${e}' or its transformations at path ${this.buildPathString(r)}`)},o=(e,t)=>{r.push(e),n=t[e]};for(let e of t){if(this.NUMERIC_PATTERN.test(e)){i(e);continue}if(typeof n!=`object`||!n)throw Error(`Cannot access property '${e}' on ${typeof n} at path ${this.buildPathString(r)}`);let t=n;if(e in n){o(e,t);continue}a(e,t)}return{[this.buildPathString(r)]:n}}buildPathString(e){return e.join(`.`).replace(this.DOT_BEFORE_BRACKET_PATTERN,`[`)}bracketToDotNotation(e){return e.replace(this.BRACKET_PATTERN,(t,n,r)=>r>0&&e[r-1]===`\\`?t:`.`+n)}};function Pe(e,t){let n=e?.modifiedFields;if(!n)return null;let r=Fe(n);if(!r)return null;let{unflattenedModifiedFields:i,modifiedFieldsManipulator:a}=r;e={...e,modifiedFields:i};let o=t(e),s=o?.modifiedFields;if(!s)return null;let c=Ie(s,a);return c===null?null:(o.modifiedFields=c,o)}function Fe(e){if(typeof e==`object`&&e&&!Array.isArray(e))try{let t=new Ne(e);return{unflattenedModifiedFields:t.unflatten(),modifiedFieldsManipulator:t}}catch{return null}return null}function Ie(e,t){if(typeof e==`object`&&e&&!Array.isArray(e))try{return t.flatten(e)}catch{return null}return null}function Le(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^./,e=>e.toLowerCase())}function w(){return{emit(e,...t){for(let n=0,r=this.events[e]||[],i=r.length;n<i;n++)r[n](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(e=>t!==e)}}}}var Re=e=>e.__type===`event-definition`;function T(e,t,n,r){let i;if(e.isDomainEvent){let{deletedEvent:e,actionEvent:t,createdEvent:a,updatedEvent:o,...s}=n,c={...r,...s};i=e?e?.deletedEntity?{entity:e?.deletedEntity,metadata:c}:{metadata:c}:t?{data:t.body,metadata:c}:o?{entity:o.currentEntity,metadata:c,...o.modifiedFields?{modifiedFields:o.modifiedFields}:{}}:{entity:a?.entity,metadata:c}}else i={data:n,metadata:r};let a=e.transformations??(e=>e),o=i,s=i;if(s.modifiedFields){let e=s.modifiedFields;if(typeof e==`object`&&e&&!Array.isArray(e)){o=structuredClone(i);let e=Pe(s,a);if(e)return t(e)}}return t(a(o))}function ze(e){let t=new Map,n=w();return{initModule(e){return r=>{let i=t.get(e.type)??[];i.push({eventDefinition:e,handler:r}),t.set(e.type,i),n.emit(`registered`,e)}},client:{...n,getRegisteredEvents:()=>t,async process(e,n={expectedEvents:[]}){let{eventType:r,identity:i,instanceId:a,payload:o,accountInfo:s}=await this.parseJWT(e),c=[...n.expectedEvents,...Array.from(t.keys()).map(e=>({type:e}))];if(c.length>0&&!c.some(({type:e})=>e===r))throw Error(`Unexpected event type: ${r}. Expected one of: ${c.map(e=>e.type).join(`, `)}`);let l=t.get(r)??[];return await Promise.all(l.map(({eventDefinition:e,handler:t})=>T(e,t,o,{instanceId:a,identity:i,accountInfo:s}))),{instanceId:a,eventType:r,payload:o,identity:i,accountInfo:s}},async processRequest(e,t){let n=await e.text();return this.process(n,t)},async parseJWT(t){let n=e();if(!n.decodeJWT)throw Error(`decodeJWT is not supported by the authentication strategy`);let{decoded:r,valid:i}=await n.decodeJWT(t);if(!i)throw Error(`JWT is not valid`);if(typeof r.data!=`string`)throw Error(`Unexpected type of JWT data: expected string, got ${typeof r.data}`);let a=JSON.parse(r.data),o=a.eventType,s=a.accountInfo,c=a.instanceId,l=a.identity?JSON.parse(a.identity):void 0;return{instanceId:c,eventType:o,payload:JSON.parse(a.data),identity:l,accountInfo:s}},async parseRequest(e){let t=await e.text();return this.parseJWT(t)},async executeHandlers(e){let n=Array.from(t.keys()).map(e=>({type:e}));if(n.length>0&&!n.some(({type:t})=>t===e.eventType))throw Error(`Unexpected event type: ${e.eventType}. Expected one of: ${n.map(e=>e.type).join(`, `)}`);let r=t.get(e.eventType)??[];await Promise.all(r.map(({eventDefinition:t,handler:n})=>T(t,n,e.payload,{instanceId:e.instanceId,identity:e.identity})))},apps:{AppInstalled:m(`AppInstalled`)(),AppRemoved:m(`AppRemoved`)()}}}}var Be=e=>e.__type===`service-plugin-definition`;function Ve(e){let t=new Map,n=w();return{initModule(e){return r=>{let i=t.get(e.componentType.toLowerCase())??[];i.push({servicePluginDefinition:e,implementation:r}),t.set(e.componentType.toLowerCase(),i),n.emit(`registered`,e)}},client:{...n,getRegisteredServicePlugins:()=>t,async parseJWT(t){let n=e();if(!n.decodeJWT)throw Error(`decodeJWT is not supported by the authentication strategy`);let{decoded:r,valid:i}=await n.decodeJWT(t,!0);if(!i)throw Error(`JWT is not valid`);if(typeof r.data!=`object`||r.data===null||!(`metadata`in r.data)||typeof r.data.metadata!=`object`||r.data.metadata===null||!(`appExtensionType`in r.data.metadata)||typeof r.data.metadata.appExtensionType!=`string`)throw Error(`Unexpected JWT data: expected object with metadata.appExtensionType string`);return r.data},async process(e){let t=await this.parseJWT(e.body);return this.executeHandler(t,e.url)},async parseRequest(e){let t=await e.text();return this.parseJWT(t)},async processRequest(e){let t=await this.parseRequest(e);return this.processParsedRequest(t,e.url)},async processParsedRequest(e,t){try{let n=await this.executeHandler(e,t);return Response.json(n)}catch(e){if(e.errorType===`SPI`&&e.applicationCode&&e.httpCode)return Response.json({applicationError:{code:e.applicationCode,data:e.data}},{status:e.httpCode});throw e}},async executeHandler(e,n){let r=e.metadata.appExtensionType.toLowerCase(),i=t.get(r)??[];if(i.length===0)throw Error(`No service plugin implementations found for component type ${r}`);if(i.length>1)throw Error(`Multiple service plugin implementations found for component type ${r}. This is currently not supported`);let{implementation:a,servicePluginDefinition:o}=i[0],s=o.methods.find(e=>n.endsWith(e.primaryHttpMappingPath));if(!s)throw Error(`Unexpect request: request url did not match any method: `+n);let c=a[s.name];if(!c)throw Error(`Got request for service plugin method ${s.name} but no implementation was provided. Available methods: ${Object.keys(a).join(`, `)}`);return s.transformations.toREST(await c(s.transformations.fromREST(e)))}}}}var E=`X-Wix-Consistent`;function He(e){let t=e.headers||{Authorization:``},n={getAuthHeaders:e=>Promise.resolve({headers:{}})},r=e.auth,i=typeof r==`function`?r:()=>r??n,a=()=>i().getAuthHeaders(e.host),o=()=>e.fetch??fetch,s=async(n,r)=>{let i=o(),s=await a(),c={...r?.headers??{},...s.headers,...e.host?.essentials?.passThroughHeaders,...t[`X-Wix-Consistent`]?{[E]:t[E]}:{}},l=e.host?.getErrorHandler?.();try{if(typeof n==`string`||n instanceof URL){let e=await i(n,{...r,headers:c});l?.handleError(e,{requestOptions:{url:n.toString(),method:r?.method}});let a=D(e);return a&&(t[E]=a),e}{for(let[e,t]of Object.entries(c))typeof t==`string`&&n.headers.set(e,t);let e=await i(n,r);l?.handleError(e,{requestOptions:{url:n.url,method:r?.method}});let a=D(e);return a&&(t[E]=a),e}}catch(e){throw l?.handleError(e,{requestOptions:{url:typeof n==`string`||n instanceof URL?n.toString():n.url,method:r?.method}}),e}},{client:c,initModule:l}=Ve(i),{client:u,initModule:d}=ze(i),f=async(n,r)=>{let i=o(),s=await a(),c=ne(r),l=await i(n,{...r,headers:{...c,...t,...s?.headers,...r?.headers,...e.host?.essentials?.passThroughHeaders,...t[`X-Wix-Consistent`]?{[E]:t[E]}:{}}}),u=D(l);return u&&(t[E]=u),l},m=(t,n)=>{if(Re(t))return d(t);if(Be(t))return l(t);if(ie(t)&&e.host)return ae(t,e.host);if(typeof t==`function`){if(`__type`in t&&t.__type===`wix_spi_error`)return t;let r=e.host?.apiBaseUrl??`www.wixapis.com`,o=e.useCDN===void 0?i().shouldUseCDN:e.useCDN;return Te(le(()=>_(t))?g(t):t,n??{},f,e.host?.getErrorHandler?.(),(e,t)=>{let n=new URL(e,`https://${r}`);return n.host=r,n.protocol=`https`,f(n.toString(),t)},i().getActiveToken,async()=>a(),{HTTPHost:r},e.host?.name,o,e.validateRequestSchema)}return re(t)?Object.fromEntries(Object.entries(t).map(([e,n])=>[e,m(n,t[v])])):t},h=e=>{for(let n in e)t[n]=e[n]};return{...e.modules?m(e.modules):{},get auth(){let t=i();return t.getAuthHeaders=t.getAuthHeaders.bind(void 0,e.host),t},setHeaders:h,use:m,enableContext(e,t={elevated:!1}){e===`global`?globalThis.__wix_context__==null?t.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:t.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:t.elevated?p.elevatedClient=this:p.client=this},fetch:(t,n)=>{let r=e.host?.apiBaseUrl??`www.wixapis.com`,i=new URL(t,`https://${r}`);return i.host=r,i.protocol=`https`,f(i.toString(),n)},fetchWithAuth:s,async graphql(t,n,r={apiVersion:`alpha`}){let i=e?.host?.apiBaseUrl??`www.wixapis.com`,a=await f(`https://${i}/graphql/${r.apiVersion}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({query:t,variables:n})});if(a.status!==200)throw new ee(`GraphQL request failed with status ${a.status}`,a);let{data:o,errors:s}=await a.json();return{data:o??{},errors:s}},webhooks:u,servicePlugins:c}}function D(e){return e.headers?.get(`X-Wix-Consistent`)??e.headers?.get(`x-wix-consistent`)}var Ue={_id:`id`,_createdDate:`createdDate`,_updatedDate:`updatedDate`},We={id:`_id`,createdDate:`_createdDate`,updatedDate:`_updatedDate`};function Ge(e,t){return e?.split(`.`).map(e=>t?.[e]??e).join(`.`)}var Ke=`sort.fieldName`;function qe(e,t,n){return(e===Ke||e.endsWith(`.${Ke}`))&&typeof t==`string`?Ge(t,n):t}function Je(e,t,n){let r=e=>n.includes(e),i=(e,n)=>{if(Array.isArray(e))e.forEach(e=>{i(e,n)});else if(typeof e==`object`&&e){let a=e;Object.keys(a).forEach(e=>{let o=n===``?e:`${n}.${e}`;if(r(o))return;let s=Ye(e,t);s!==e&&!(s in a)&&(a[s]=a[e],delete a[e]),a[s]=qe(o,a[s],t),i(a[s],o)})}};return i(e,``),e}function Ye(e,t){let n;return n=e.includes(`.`)?e.split(`.`).map(e=>t[e]??e).join(`.`):t[e]??e,n}function Xe(e,t=[]){return Je(e,Ue,t)}function Ze(e,t=[]){return Je(e,We,t)}function Qe(e){return e?new Date(e):void 0}var $e=new WeakMap;function O(){return{leaves:void 0,fields:void 0,mapFields:void 0,anyField:void 0}}function k(e,t){let n=e.get(t);return n||(n=O(),e.set(t,n)),n}function et(e,t){return t===`*`?(e.anyField??=O(),e.anyField):t.endsWith(`{}`)?(e.mapFields??=new Map,k(e.mapFields,t.slice(0,-2))):(e.fields??=new Map,k(e.fields,t))}function tt(e){let t=O();for(let n of e){let e=n.path.split(`.`).reduce(et,t);e.leaves??=[],e.leaves.push(n)}return t}function nt(e){let t=$e.get(e);return t||(t=tt(e),$e.set(e,t)),t}function A(e){return typeof e==`object`&&!!e}function rt(e,{isRepeated:t,isMap:n},r){return t?Array.isArray(e)?e.map(r):e:n?A(e)?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,r(t)])):e:r(e)}function j(e,t,n){A(e)&&M(e,t,n)}function it(e,t,n){for(let[r,i]of t){if(!(r in e))continue;if(i.leaves)for(let t of i.leaves)e[r]=rt(e[r],t,n);let t=e[r];Array.isArray(t)?t.forEach(e=>j(e,i,n)):j(t,i,n)}}function at(e,t,n){for(let[r,i]of t){let t=e[r];A(t)&&Object.values(t).forEach(e=>j(e,i,n))}}function M(e,{fields:t,mapFields:n,anyField:r},i){t&&it(e,t,i),n&&at(e,n,i),r&&Object.values(e).forEach(e=>j(e,r,i))}function ot(e,t){if(!A(e))return e;for(let{paths:n,transformFn:r}of t)M(e,nt(n),r);return e}function N(e){return dt(e).map(e=>e.toLocaleUpperCase()).join(`_`)}var st=/([\p{Ll}\d])(\p{Lu})/gu,ct=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,lt=`$1\0$2`,ut=/[^\p{L}\d]+/giu;function dt(e){let t=e.trim();t=t.replace(st,lt).replace(ct,lt),t=t.replace(ut,`\0`);let n=0,r=t.length;for(;t.charAt(n)===`\0`;)n++;if(n===r)return[];for(;t.charAt(r-1)===`\0`;)r--;return t.slice(n,r).split(/\0/g)}var ft=e=>`validationError`in(e.response?.data?.details??{}),pt=e=>`applicationError`in(e.response?.data?.details??{}),mt=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function ht(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},n=[]){if(typeof e!=`object`||!e)throw e;if(ft(e))return gt(e,t,n);if(pt(e))return _t(e);if(mt(e)){let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i={applicationError:{description:n,code:N(n),data:{}},requestId:e.requestId};return P(e,{message:JSON.stringify({message:r,details:i},null,2),extraProperties:{details:i,status:t}})}return vt(e)}var gt=(e,t,n)=>{let r=e.response?.data,i=e.requestId,{fieldViolations:a}=r.details.validationError,o=yt(t,a,n)?.sort((e,t)=>e.field<t.field?-1:1),s=`INVALID_ARGUMENT: ${o?.map(({field:e,description:t})=>`"${e}" ${t}`)?.join(`, `)}`,c={validationError:{fieldViolations:o},requestId:i};return P(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:i}})},P=(e,{message:t,extraProperties:n})=>Object.assign(e,{...n,message:t}),_t=e=>{let t=e.response?.status,n=e.response?.statusText??`UNKNOWN`,r=e.response?.data?.message??n,i=e.response?.data?.details?.applicationError?.description??n,a=e.response?.data?.details?.applicationError?.code??N(n),o=e.response?.data?.details?.applicationError?.data??{},s=r===i?r:`${r}: ${i}`,c={applicationError:{description:i,code:a,data:o},requestId:e.requestId};return P(e,{message:JSON.stringify({message:s,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},vt=e=>P(e,{message:e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`,extraProperties:{requestId:e.requestId,status:e.response?.status,code:N(e.response?.statusText??`UNKNOWN`),...!e.response&&{runtimeError:e}}}),yt=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:n},r,i)=>{let a={...e,...t},o=Object.keys(a);return r?.filter(e=>!r.some(t=>t.field.length>e.field.length&&t.field.startsWith(e.field)&&o.includes(t.field))).map(e=>{let r=t[e.field];if(r)return{...e,field:bt(r,i)};let s=o?.sort((e,t)=>t.length-e.length)?.find(t=>e.field.startsWith(t));if(s){let t=a[s];if(t)return{...e,field:e.field.replace(s,bt(t,i))}}return n?{...e,field:`${i[0]}.${e.field}`}:e})},bt=(e,t)=>{let n=xt(e);return n==null?e:e.replace(`$[${n}]`,t[n])},xt=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function St(){let e=typeof $wixContext<`u`&&$wixContext.initWixModules?$wixContext.initWixModules:globalThis.__wix_context__!==void 0&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(t,n){return F(()=>e(t,n))},fetchWithAuth(){throw Error(`fetchWithAuth is not available in this context`)},graphql(){throw Error(`graphql is not available in this context`)}};let t=typeof $wixContext<`u`?$wixContext.client:p.client===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.client:p.client,n=typeof $wixContext<`u`?$wixContext.elevatedClient:p.elevatedClient===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.elevatedClient:p.elevatedClient;if(t||n)return{initWixModules(e,r){if(r){if(!n)throw 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 F(()=>n.use(e))}if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return F(()=>t.use(e))},fetchWithAuth:(e,n)=>{if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.fetchWithAuth(e,n)},getAuth(){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.auth},async graphql(e,n,r){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.graphql(e,n,r)}}}function F(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}function Ct(e,t){return((...n)=>{let r=St();return r?r.initWixModules(e,t).apply(void 0,n):e.apply(void 0,n)})}function wt(e,t=!1){return Ct(e,t)}function Tt(e){let t=Rt(It(e.host),e.domainToMappings);return qt(Wt(e.protoPath,e.data||{}),t)}var Et=[`wix.com`,`editorx.com`],Dt=`_`,Ot=`*.`,kt=RegExp(`\\.(${Et.join(`|`)})$`),At=[`42.wixprod.net`,`uw2-edt-1.wixprod.net`,`virginia-edt.wixprod.net`],jt={"payments.base44.com":`manage.wix.com`,"create.editorx.com":`editor.editorx.com`},Mt=`dev.wix-code.com`,Nt=/{(.*)}/,Pt=RegExp(`\\.(${At.join(`|`)})$`),Ft=RegExp(`.*\\.${Mt}$`);function It(e){return Lt(e).replace(kt,`._base_domain_`).replace(Pt,`._api_base_domain_`).replace(Ft,`*.dev.wix-code.com`)}function Lt(e){return jt[e]??e}function Rt(e,t){let n=t[e];if(n)return n;let r=zt(e,t)??Bt(e,t);if(!r){if(Ht(e)){let e=t[Ut];if(e)return e}let n=t[Dt];if(n)return n}return r??[]}function zt(e,t){return Object.entries(t).find(([t])=>{let[,...n]=e.split(`.`);return n.join(`.`)===t})?.[1]}function Bt(e,t){let[n]=Object.entries(t).filter(([t])=>Vt(e,t)).sort(([e],[t])=>t.length-e.length);if(!n)return;let[,r]=n;return r}function Vt(e,t){if(!t.startsWith(Ot))return!1;let n=t.slice(1);return e.length>n.length&&e.endsWith(n)}function Ht(e){return!!e.match(/\._base_domain_$/)}var Ut=`www._base_domain_`;function Wt(e,t){return e.split(`/`).map(e=>Gt(e,t)).join(`/`)}function Gt(e,t){let n=e.match(Nt)||[],r=n[1];return r?Kt(t,r,e,e.replace(n[0],``)):e}function Kt(e,t,n,r){let i=e;for(let e of t.split(`.`)){if(!i)return n;i=i[e]}return`${i}${r}`}function qt(e,t){let n=t?.find(t=>e.startsWith(t.destPath));return n?n.srcPath+e.slice(n.destPath.length):e}var Jt=`x-wix-linguist`,Yt=`00000000-0000-0000-0000-000000000000`,Xt=`false`,Zt=()=>{let e=I(`language`),t=I(`locale`);if(e)return{[Jt]:[e,t||e,Xt,Yt].join(`|`)}};function Qt(){let e=null,t=null;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var I=e=>typeof window<`u`?window.commonConfig?.[e]:void 0,$t=({createHost:e})=>({__type:`host`,create:e=>({}),host:t=>{let{applicationId:n,componentId:r}=t??{},i=typeof window<`u`?window.wixEmbedsAPI:void 0,a=e(t),o=tn();return{...a,apiBaseUrl:o,getMonitoringClient:i?.getMonitoringClientFunction?.(n,r),essentials:{language:I(`language`),locale:I(`locale`),get passThroughHeaders(){return Zt()}}}},auth:e=>{let t=typeof window<`u`?window.wixEmbedsAPI:void 0;!e&&en()&&(e=t?.getAccessTokenFunction?.());let n=!1,{resolve:r,promise:i}=Qt();return{getAuthHeaders:async()=>{if(!e&&n&&(e=await i),!e)throw Error(`Failed to resolve auth token`);return{headers:{Authorization:await e()}}},getAccessTokenInjector:()=>(n=!0,e=>{r(e)})}}});function en(){return typeof document<`u`&&document.currentScript?.tagName===`SCRIPT`}function tn(){let e=(typeof window<`u`?window.wixEmbedsAPI:void 0)?.getExternalBaseUrl?.();if(!e)return;let t=new URL(e);return t?.pathname&&t.pathname!==`/`?`${t.hostname}${t.pathname}`:t.hostname}var nn=({clientSdk:e,applicationId:t})=>({invoke:async({namespace:n,method:r,args:i})=>{if(!e)throw Error(`Wix Site SDK only works in a Wix site environment. Learn more: https://dev.wix.com/docs/sdk/host-modules/site/introduction`);return e.invoke({namespace:n,method:r,args:i,applicationId:t,accessToken:`accessToken`})},getAccessToken:()=>{throw Error(`Not implemented`)},observeState:()=>({disconnect:()=>{}})}),L=$t({createHost:function(e){let t=(typeof $wixContext<`u`?$wixContext.clientSdk:void 0)??e?.clientSdk??(typeof window<`u`?window?.clientSdk:void 0),{applicationId:n}=e||{};if(!n)throw Error(`"createHost" was called without a required field "applicationId"`);return{channel:nn({clientSdk:t,applicationId:n}),close:()=>{}}}}),rn=((e,t)=>{let n=L.host({applicationId:e,componentId:t}),r=L.auth();return He({auth:r,host:n}).enableContext(`module`),r.getAccessTokenInjector()})(`13d21c63-b5ec-5912-8397-c3a5ddb27a97`);function R(e,t){for(let n of e){let e=n.addOns.find(e=>e.addOnId===t);if(e)return{group:n,addOn:e}}return null}function an(e,t){return R(e,t)?.addOn??null}function z(e,t){return t.filter(t=>R(e,t.id)!==null)}function B(e,t,n){return n.filter(n=>R(e,n.id)?.group===t).length}function V(e,t){return!e.maxNumberOfAddOns||t<e.maxNumberOfAddOns}function on(e,t){return e.map(n=>{let r=B(e,n,t);return{...n,addOns:n.addOns.map(e=>{let n=t.find(t=>t.id===e.addOnId)?.quantity??0;return{...e,isSelected:n>0,selectedQuantity:n}}),selectedCount:r,canSelectMore:V(n,r)}})}function H(e,t,n){let r=R(e,n);return r?t.some(e=>e.id===n)?!0:V(r.group,B(e,r.group,t)):!1}function sn(e,t){let n=e.maxQuantity??1;return Number.isFinite(t)?Math.min(Math.max(Math.trunc(t),0),n):0}var cn={category:`category`,location:`location`,page:`page`,blob:`b`,resource:`resource`,referral:`referral`,timezone:`timezone`,bookingId:`bookingId`,token:`token`,rescheduleRedirectUrl:`rescheduleRedirectUrl`};function U(e){return e.addOns??[]}function W(e,t){let n={...e};return t.length?n.addOns=t:delete n.addOns,n}function ln(e,t){let n=U(e);return W(e,n.some(e=>e.id===t)?n.filter(e=>e.id!==t):[...n,{id:t,quantity:1}])}function un(e,t,n){let r=U(e);return n<=0?W(e,r.filter(e=>e.id!==t)):W(e,r.some(e=>e.id===t)?r.map(e=>e.id===t?{...e,quantity:n}:e):[...r,{id:t,quantity:n}])}function dn(){let e=typeof $wixContext<`u`&&$wixContext.initWixModules?$wixContext.initWixModules:globalThis.__wix_context__!==void 0&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(t,n){return G(()=>e(t,n))},fetchWithAuth(){throw Error(`fetchWithAuth is not available in this context`)},graphql(){throw Error(`graphql is not available in this context`)}};let t=typeof $wixContext<`u`?$wixContext.client:p.client===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.client:p.client,n=typeof $wixContext<`u`?$wixContext.elevatedClient:p.elevatedClient===void 0?globalThis.__wix_context__===void 0?void 0:globalThis.__wix_context__.elevatedClient:p.elevatedClient;if(t||n)return{initWixModules(e,r){if(r){if(!n)throw 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 G(()=>n.use(e))}if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return G(()=>t.use(e))},fetchWithAuth:(e,n)=>{if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.fetchWithAuth(e,n)},getAuth(){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.auth},async graphql(e,n,r){if(!t)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return t.graphql(e,n,r)}}}function G(e){let t=globalThis.__wix_context__,n={client:p.client,elevatedClient:p.elevatedClient},r;globalThis.__wix_context__=void 0,p.client=void 0,p.elevatedClient=void 0,typeof $wixContext<`u`&&(r={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,p.client=n.client,p.elevatedClient=n.elevatedClient,typeof $wixContext<`u`&&($wixContext.client=r.client,$wixContext.elevatedClient=r.elevatedClient)}}function fn(e,t){return{...e,...Object.fromEntries(t.map(t=>[t,(...n)=>{let r=dn();if(!r)throw Error(`Wix context is not available. Make sure to initialize the Wix context before using SDK modules`);return r.initWixModules(e)[t].apply(void 0,n)}]))}}function pn(e){return fn({__type:`host`,create:t=>Object.entries(e).reduce((e,[n,r])=>({...e,[n]:r(t)}),{})},Object.keys(e))}var mn=class{constructor(e){this.message=e,this.captureException=()=>{console.error(this.message)},this.captureMessage=()=>{console.error(this.message)},this.startSpan=(e,t)=>(console.error(this.message),t(void 0)),this.startSpanManual=()=>(console.error(this.message),{end:()=>{},fail:()=>{}}),this.endSpanManual=()=>{console.error(this.message)},this.addBreadcrumb=()=>{console.error(this.message)}}},hn=e=>new mn(e),gn=pn({getMonitoringClient:e=>()=>e.getMonitoringClient?e.getMonitoringClient():hn(`Host monitoring client is not available on the current host. Make sure to use an updated version of the host initialization package.`)}),K={service:`service`,services:`services`,categories:`categories`,locations:`locations`,sessions:`sessions`,timeSlots:`time-slots`,serviceAddOns:`service-addons`,bookingsSettings:`bookings-settings`,serviceCta:`service-cta`,preferences:`preferences`,bookingSummary:`booking-summary`,bookingCheckout:`booking-checkout`,formValues:`form-values`,paymentOptions:`payment-options`,seo:`seo`,warmup:`warmup`,reschedule:`reschedule`};function _n(e){try{let t=gn.getMonitoringClient?.();return t&&typeof t[e]==`function`?t:null}catch{return null}}function q(e,{feature:t,action:n,level:r=`error`,contexts:i}){let a=_n(`captureException`);if(!a)return;let o=e instanceof Error?e:Error(String(e));a.captureException(o,{level:r,tags:{feature:t,action:n},...i?{contexts:i}:{}})}function vn(e,{feature:t,tags:n},r){let i=_n(`startSpanManual`);if(!i)return r;let a=i.startSpanManual({name:e,tags:{feature:t,...n}});return r.then(()=>a.end(),e=>a.fail(e)),r}var yn=class extends e{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){q(e,{feature:this.props.feature??`service`,action:`render`,contexts:{react:{componentStack:t.componentStack}}})}render(){return this.state.hasError?this.props.fallback:this.props.children}};function bn(e){let t=e;if(t.__state||(t.__state={status:`pending`},t.then(e=>{t.__state={status:`fulfilled`,value:e}},e=>{t.__state={status:`rejected`,reason:e}})),t.__state.status===`fulfilled`)return t.__state.value;throw t.__state.status===`rejected`?t.__state.reason:t}function J(e){let t=Promise.resolve(e);return t.__state={status:`fulfilled`,value:e},t}var xn=new WeakMap;function Sn(e,t,n){let r=xn.get(e);r||(r=new WeakMap,xn.set(e,r));let i=r.get(t);i||(i=new WeakMap,r.set(t,i));let a=i.get(n);if(!a){let r=e;a=r.__state?.status===`fulfilled`?J(t(r.__state.value)):r.__state?.status===`rejected`?J(n(r.__state.reason)):e.then(t,n),i.set(n,a)}return a}function Cn(e){return e}var wn=Cn(`@wix/site-service-warmup-data`);function Tn(){try{return u()}catch{return null}}function En(e){try{return e?e(wn):null}catch{return null}}function Dn(){let e=En(Tn()),t=typeof window>`u`;return{scope:e??void 0,get:async n=>{if(t||!e)return null;try{return await e.get(n)}catch(e){return q(e,{feature:K.warmup,action:`read`,level:`warning`,contexts:{warmup:{key:n}}}),null}},set:(n,r)=>{if(t&&e)try{e.set(n,r)}catch{}}}}var Y=[],On=[],kn=`useServiceAddOnsContext must be used within ServiceAddOnsContextProvider`;function An({isLoading:e,hasError:t,children:n}){let r={addOnGroups:Y,selected:On,isLoading:e,hasError:t,toggleAddOn:()=>{},setAddOnQuantity:()=>{}};return f($.Provider,{value:r,children:n})}function jn({children:e}){return f(An,{isLoading:!0,hasError:!1,children:e})}function Mn({children:e}){return f(An,{isLoading:!1,hasError:!0,children:e})}function Nn(e){if(!e)return;let t=``;return(e.filename||e.altText)&&(t=`/${encodeURIComponent(e.filename||e.altText)}`),e.id?`wix:image://v1/${e.id}${t}#originWidth=${e.width}&originHeight=${e.height}`:e.url}var Pn=[{path:`addOnGroupsDetails.addOns.mainMedia.image.urlExpirationDate`}];function Fn(e){return Tt(Object.assign(e,{domainToMappings:{"*.dev.wix-code.com":[{srcPath:`/_api/services-2`,destPath:``},{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"www.wixapis.com":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`},{srcPath:`/bookings/services/v2/bulk/services`,destPath:`/v2/bulk/services`}],"manage._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"editor._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"blocks._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],"create.editorx":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`},{srcPath:`/_api/bookings/v2/bulk/services`,destPath:`/v2/bulk/services`}],_:[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"www._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"bo._base_domain_":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"wixbo.ai":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"wix-bo.com":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"editor.wixapps.net":[{srcPath:`/_api/bookings/v2/services`,destPath:`/v2/services`}],"api._api_base_domain_":[{srcPath:`/services-2`,destPath:``}]}}))}var In=`@wix/auto_sdk_bookings_services`;function Ln(e){function t({host:t}){return{entityFqdn:`wix.bookings.services.v2.service`,method:`POST`,methodFqn:`wix.bookings.services.v2.AddOnGroupsService.ListAddOnGroupsByServiceId`,packageName:In,migrationOptions:{optInTransformResponse:!0},url:Fn({protoPath:`/v2/services/add-on-groups/list-add-on-groups-by-service-id`,data:e,host:t}),data:e,transformResponse:e=>ot(e,[{transformFn:Qe,paths:Pn}])}}return t}var Rn=[{path:`addOnGroupsDetails.addOns.mainMedia.image`}];async function zn(e,t){let{httpClient:n,sideEffects:r}=arguments[2],i=Ln(Xe({serviceId:e,groupIds:t?.groupIds}));r?.onSiteCall?.();try{let e=await n.request(i);return r?.onSuccess?.(e),Ze(ot(e.data,[{transformFn:Nn,paths:Rn}]))}catch(e){let t=ht(e,{spreadPathsToArguments:{},explicitPathsToArguments:{serviceId:`$[0]`,groupIds:`$[1].groupIds`},singleArgumentUnchanged:!1},[`serviceId`,`options`]);throw r?.onError?.(e),t}}function Bn(e){return(t,n)=>zn(t,n,{httpClient:e})}var Vn=wt(Bn);function Hn(e,t){let n=e?.value,r=e?.currency;if(n==null||!r)return null;let i=Number(n);if(!Number.isFinite(i))return null;let a=i%1==0?0:2;return new Intl.NumberFormat(t,{style:`currency`,currency:r,currencyDisplay:`symbol`,maximumFractionDigits:a,minimumFractionDigits:a}).format(i).replace(/\p{Zs}/gu,`\xA0`)}async function Un(e){return(await Vn(e)).addOnGroupsDetails??[]}function Wn(e,t){let n=e.price?.value==null?null:Number(e.price.value);return{addOnId:e.addOnId??null,addOnName:e.nameTranslated??e.name??null,addOnPrice:Hn(e.price,t),addOnPriceValue:n!=null&&Number.isFinite(n)?n:null,addOnCurrency:e.price?.currency??null,durationInMinutes:e.durationInMinutes??null,maxQuantity:e.maxQuantity??null,isSelected:!1,selectedQuantity:0}}function Gn(e,t){return e.map(e=>({groupId:e.groupId??null,groupName:e.groupNameTranslated??e.groupName??null,prompt:e.promptTranslated??e.prompt??null,maxNumberOfAddOns:e.maxNumberOfAddOns??null,addOns:(e.addOns??[]).map(e=>Wn(e,t)),selectedCount:0,canSelectMore:!0}))}var Kn=`bookings-uou`;function qn(e,t){return`${Kn}:addons:${e}:${t}`}var Jn=5e3,Yn=100,Xn=`wix-warmup-data`,X=null;function Zn(e){if(typeof document<`u`)try{let t=document.getElementById(Xn)?.textContent;return t?(X?.text!==t&&(X={text:t,data:JSON.parse(t).builderComponentsWarmupData??{}}),X.data[e]??void 0):void 0}catch{return}}var Qn=()=>({promises:new Map,invalidatedWarmup:new Set}),$n=Qn(),er=new WeakMap,tr=new WeakMap;function nr(e){if(!e)return $n;let t=er.get(e);return t||(t=Qn(),er.set(e,t)),t}function rr({key:e,warmupData:t,fetchData:n,refresh:r=!1}){if(e===null)return n();if(typeof window>`u`){let r=()=>n().then(n=>(t.set(e,n),n)),{scope:i}=t;if(!i)return r();let a=tr.get(i);a||(a=new Map,tr.set(i,a));let o=a.get(e);if(o)return o;let s=r();return a.set(e,s),s.catch(()=>a.delete(e)),s}let i=nr(t.scope),a=Date.now();for(let[e,t]of i.promises)t.expiresAt<=a&&i.promises.delete(e);let o=i.promises.get(e);if(o&&!r)return o.promise;r&&i.invalidatedWarmup.add(e);let s=!i.invalidatedWarmup.has(e);if(s){let t=Zn(e);if(t!==void 0){let n=J(t);return i.promises.set(e,{promise:n,expiresAt:a+Jn}),n}}let c=(async()=>{if(s){let n=await t.get(e);if(n!=null)return n}return n()})();i.promises.size>=Yn&&i.promises.delete(i.promises.keys().next().value);let l={promise:c,expiresAt:1/0};return i.promises.set(e,l),c.then(()=>{l.expiresAt=Date.now()+Jn},()=>{i.promises.get(e)===l&&i.promises.delete(e)}),c}function ir(e,t){return vn(`service-addons-context-load`,{feature:K.serviceAddOns,tags:{serviceId:e}},Un(e)).then(e=>Gn(e,t),t=>{throw q(t,{feature:K.serviceAddOns,action:`fetch-add-on-groups`,level:`warning`,contexts:{service:{serviceId:e}}}),t})}function ar({serviceId:e,locale:t,warmupData:n}){return rr({key:qn(e,t),warmupData:n,fetchData:()=>ir(e,t)})}function or(e){return e}var sr=or(`@wix/viewer-service-business-logger`);function cr(e){return{evid:32,src:16,endpoint:``,params:e}}function lr(e){return e}var ur=lr(`@wix/site-service-url`),dr=`appSectionParams`;function Z(e){let t=e.searchParams.get(dr);if(t===null)return e;let n=new URL(e);n.searchParams.delete(dr);for(let[e,r]of Object.entries(fr(t)))typeof r==`string`&&!n.searchParams.has(e)&&n.searchParams.set(e,r);return n}function fr(e){try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}var Q=`bookings-uou:url-change`,pr=e=>{let t=new URL(e);return t.searchParams.sort(),t.href};function mr(e,{disableScrollToTop:t,skipHistory:n}={}){let r=globalThis.window;if(!r?.history)return;let i=new URL(r.location.href);if(pr(i)===pr(e))return;let a={scrollY:r.scrollY};if(n)r.history.replaceState(a,``,e.href);else{r.history.replaceState(a,``,i.href);try{r.history.pushState(t?a:null,``,e.href)}catch{return}}r.dispatchEvent(new Event(Q))}function hr(e){let t=globalThis.window;return t?(t.addEventListener(Q,e),t.addEventListener(`popstate`,e),()=>{t.removeEventListener(Q,e),t.removeEventListener(`popstate`,e)}):()=>{}}var gr=e=>{try{return decodeURIComponent(e)}catch{return e}};function _r(e,t){let n=t?new URL(t).pathname:`/`;return`./${gr(new URL(e).pathname.replace(n,``).replace(/^\/|\/$/g,``))}`}function vr(){let e=d(ur),t=r(()=>e.currentUrl,[e]),n=c(hr,t,t),i=o(()=>Z(new URL(n)),[n]),a=e.siteUrl.replace(/\/$/,``);return{pathname:i.pathname,search:i.search,searchParams:i.searchParams,href:i.href,getParsedUrl:()=>Z(new URL(e.currentUrl)),getRelativeUrl:()=>_r(e.currentUrl,a),getExternalBaseUrl:()=>a,pushUrl:mr}}var yr=function(e){return e.BOOK_ONLINE=`bookingsBookOnline`,e.SERVICE_PAGE=`bookingsServicePage`,e.CALENDAR_PAGE=`bookingsCalendar`,e.FORM_PAGE=`bookingsForm`,e}({}),br={SERVICES:`services_context`,SERVICE:`service_context`,TIME_SLOTS:`time_slots_context`,BOOKING_CHECKOUT:`booking_checkout_context`,CATEGORIES:`categories_context`,LOCATIONS:`locations_context`,SERVICE_ADD_ONS:`service_addons_context`,PREFERENCES:`preferences_context`};yr.BOOK_ONLINE;var xr=`new_bookings_server`,Sr=e=>{let t=d(sr);return r(n=>{t.reportBi({widget_name:e,bookingsPlatform:xr,is_over_editor:!1,...n.params,src:n.src,evid:n.evid},{endpoint:n.endpoint})},[t,e])},Cr=(e,t=!0)=>{let n=Sr(e),{getParsedUrl:r}=vr(),i=s(!1);a(()=>{t&&!i.current&&(i.current=!0,n(cr({referralInfo:r().searchParams.get(cn.referral)??void 0})))},[t,n,r])},wr=J({addOnGroups:Y,hasError:!1}),Tr=e=>({addOnGroups:e,hasError:!1}),Er=()=>({addOnGroups:Y,hasError:!0}),$=n(null);function Dr(){let e=i($);if(!e)throw Error(kn);return e}function Or({addOnsPromise:e,isLoading:t,pickedAddOns:n,forwardToggleAddOn:i,forwardSetAddOnQuantity:a,children:c}){let{addOnGroups:l,hasError:u}=bn(e),d=o(()=>z(l,n),[l,n]),p=o(()=>on(l,d),[l,d]),m=s({source:n,picks:n});m.current.source!==n&&(m.current={source:n,picks:n});let h=e=>{let t=m.current;t.picks=U(e({serviceId:``,addOns:t.picks}))},g=r(()=>{let e=m.current,t=z(l,e.picks);return e.picks.filter(e=>!t.includes(e)).forEach(e=>a(e.id,0)),e.picks=t,t},[l,a]),_=r(e=>{let n=z(l,m.current.picks);!t&&H(l,n,e)&&(g(),i(e),h(t=>ln(t,e)))},[t,l,g,i]),v=r((e,n)=>{let r=t?null:an(l,e);if(!r)return;let i=z(l,m.current.picks),o=i.find(t=>t.id===e)?.quantity??0,s=sn(r,n);s===o||o===0&&!H(l,i,e)||(g(),a(e,s),h(t=>un(t,e,s)))},[t,l,g,a]),y=o(()=>({addOnGroups:p,selected:d,isLoading:t,hasError:u,toggleAddOn:_,setAddOnQuantity:v}),[p,d,t,u,_,v]);return f($.Provider,{value:y,children:c})}function kr({children:e}){let{service:n,serviceId:r,hasAddOns:i,locale:a,isLoading:s,bookingsSettingsLoading:c,selection:u,toggleAddOn:d,setAddOnQuantity:p}=l();Cr(br.SERVICE_ADD_ONS,!s&&!c);let m=o(()=>U(u),[u]),h=Dn(),g=n&&i&&r?r:null,_=o(()=>g?Sn(ar({serviceId:g,locale:a,warmupData:h}),Tr,Er):wr,[g,a]),v=!g&&!!s;return f(yn,{fallback:f(Mn,{children:e}),feature:K.serviceAddOns,children:f(t,{fallback:f(jn,{children:e}),children:f(Or,{addOnsPromise:_,isLoading:v,pickedAddOns:m,forwardToggleAddOn:d,forwardSetAddOnQuantity:p,children:e})})})}var Ar=rn;export{kr as default,Ar as injectAccessTokenGetter,$ as serviceAddOnsContext,Dr as useServiceAddOnsContext};
|