@kotao/storefront 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/chunk-4OQYNUGM.js +29 -0
  2. package/dist/chunk-4OQYNUGM.js.map +1 -0
  3. package/dist/{chunk-U5677AEA.js → chunk-4TEFGD42.js} +343 -40
  4. package/dist/chunk-4TEFGD42.js.map +1 -0
  5. package/dist/chunk-7MTCGXIG.js +144 -0
  6. package/dist/chunk-7MTCGXIG.js.map +1 -0
  7. package/dist/{chunk-GCQI6OKH.js → chunk-H3D7BAOL.js} +3 -26
  8. package/dist/chunk-H3D7BAOL.js.map +1 -0
  9. package/dist/chunk-IIOHENCG.js +239 -0
  10. package/dist/chunk-IIOHENCG.js.map +1 -0
  11. package/dist/chunk-M7BPQ54D.js +26 -0
  12. package/dist/chunk-M7BPQ54D.js.map +1 -0
  13. package/dist/{chunk-ISAFEOR2.js → chunk-PXVDVUFX.js} +3 -2
  14. package/dist/chunk-PXVDVUFX.js.map +1 -0
  15. package/dist/chunk-VV653S52.js +246 -0
  16. package/dist/chunk-VV653S52.js.map +1 -0
  17. package/dist/chunk-WG7HYVHJ.js +38 -0
  18. package/dist/chunk-WG7HYVHJ.js.map +1 -0
  19. package/dist/{client-D9YYA2w6.d.ts → client-D51WdvYR.d.ts} +55 -8
  20. package/dist/client-bsiNPHBi.d.ts +159 -0
  21. package/dist/createCartHandler-C4RrPwSG.d.ts +58 -0
  22. package/dist/editor.d.ts +1 -1
  23. package/dist/events-react.d.ts +68 -0
  24. package/dist/events-react.js +557 -0
  25. package/dist/events-react.js.map +1 -0
  26. package/dist/events.d.ts +18 -0
  27. package/dist/events.js +5 -0
  28. package/dist/events.js.map +1 -0
  29. package/dist/fetch-M3Y-fQrW.d.ts +47 -0
  30. package/dist/forms.d.ts +58 -0
  31. package/dist/forms.js +3 -0
  32. package/dist/forms.js.map +1 -0
  33. package/dist/http-types-CGh8WGHB.d.ts +11 -0
  34. package/dist/index.d.ts +75 -12
  35. package/dist/index.js +55 -8
  36. package/dist/index.js.map +1 -1
  37. package/dist/offer-token-C-nk_nj8.d.ts +16 -0
  38. package/dist/{pagination-CPgH3fAa.d.ts → pagination-DCrQk02Q.d.ts} +1 -1
  39. package/dist/product.d.ts +1 -1
  40. package/dist/react-router.d.ts +12 -6
  41. package/dist/react-router.js +4 -2
  42. package/dist/react-router.js.map +1 -1
  43. package/dist/react.d.ts +30 -7
  44. package/dist/react.js +275 -156
  45. package/dist/react.js.map +1 -1
  46. package/dist/{routing-BfUp49o8.d.ts → routing-sEonP93J.d.ts} +26 -59
  47. package/dist/seo.d.ts +4 -1
  48. package/dist/seo.js +1 -1
  49. package/dist/settings.d.ts +6 -39
  50. package/dist/settings.js +2 -1
  51. package/dist/{shop-DkQmro-Y.d.ts → shop-BJSvtmnV.d.ts} +2 -2
  52. package/dist/{store-DQK1nhob.d.ts → store-CtCWHI8H.d.ts} +1 -1
  53. package/dist/types-CSNXbGFW.d.ts +108 -0
  54. package/dist/{types-Df3bGbKU.d.ts → types-bcbQzx87.d.ts} +1 -1
  55. package/package.json +13 -1
  56. package/dist/chunk-GCQI6OKH.js.map +0 -1
  57. package/dist/chunk-ISAFEOR2.js.map +0 -1
  58. package/dist/chunk-U5677AEA.js.map +0 -1
@@ -0,0 +1,246 @@
1
+ import { resolveFormText, isFormFieldVisible, formAnswerName, ADDRESS_PROPERTIES, formFields } from './chunk-IIOHENCG.js';
2
+ import { useState, useId } from 'react';
3
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
+
5
+ var ADDRESS_LABELS = {
6
+ line1: "Address",
7
+ line2: "Address line 2",
8
+ city: "City",
9
+ postalCode: "Postal code",
10
+ countryCode: "Country code",
11
+ provinceCode: "Province or state code"
12
+ };
13
+ function FieldErrors({ id, errors }) {
14
+ if (errors.length === 0) return null;
15
+ return /* @__PURE__ */ jsx("ul", { id, "data-kotao-form-errors": true, children: errors.map((error, index) => /* @__PURE__ */ jsx("li", { children: error }, `${error}-${index}`)) });
16
+ }
17
+ function StorefrontFormField({
18
+ field,
19
+ locale,
20
+ fallbackLocale,
21
+ value,
22
+ errors,
23
+ onChange,
24
+ idPrefix
25
+ }) {
26
+ const id = `${idPrefix}-form-${field.key}`;
27
+ const label = resolveFormText(field.label, locale, fallbackLocale);
28
+ const description = resolveFormText(field.description, locale, fallbackLocale);
29
+ const errorId = `${id}-errors`;
30
+ const descriptionId = `${id}-description`;
31
+ const describedBy = [description ? descriptionId : "", errors.length ? errorId : ""].filter(Boolean).join(" ");
32
+ const common = {
33
+ id,
34
+ name: formAnswerName(field.key),
35
+ required: field.required,
36
+ "aria-invalid": errors.length > 0 || void 0,
37
+ "aria-describedby": describedBy || void 0
38
+ };
39
+ let control;
40
+ if (field.kind === "textarea") {
41
+ control = /* @__PURE__ */ jsx(
42
+ "textarea",
43
+ {
44
+ ...common,
45
+ value: typeof value === "string" ? value : "",
46
+ minLength: field.validation?.minLength,
47
+ maxLength: field.validation?.maxLength,
48
+ onChange: (event) => onChange(event.currentTarget.value)
49
+ }
50
+ );
51
+ } else if (field.kind === "address") {
52
+ const address = typeof value === "object" && !Array.isArray(value) ? value : {};
53
+ control = /* @__PURE__ */ jsxs("fieldset", { "aria-describedby": describedBy || void 0, children: [
54
+ /* @__PURE__ */ jsxs("legend", { children: [
55
+ label,
56
+ field.required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " *" })
57
+ ] }),
58
+ ADDRESS_PROPERTIES.map((property) => /* @__PURE__ */ jsxs("label", { children: [
59
+ /* @__PURE__ */ jsx("span", { children: ADDRESS_LABELS[property] }),
60
+ /* @__PURE__ */ jsx(
61
+ "input",
62
+ {
63
+ name: formAnswerName(field.key, property),
64
+ value: address[property] ?? "",
65
+ required: field.required && ["line1", "postalCode", "city", "countryCode"].includes(property),
66
+ onChange: (event) => onChange({ ...address, [property]: event.currentTarget.value })
67
+ }
68
+ )
69
+ ] }, property))
70
+ ] });
71
+ } else if (field.kind === "select" || field.kind === "multi_select") {
72
+ const selected = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
73
+ control = /* @__PURE__ */ jsxs(
74
+ "select",
75
+ {
76
+ ...common,
77
+ multiple: field.kind === "multi_select",
78
+ value: field.kind === "multi_select" ? selected : selected[0] ?? "",
79
+ onChange: (event) => onChange(
80
+ field.kind === "multi_select" ? Array.from(event.currentTarget.selectedOptions, (option) => option.value) : event.currentTarget.value
81
+ ),
82
+ children: [
83
+ field.kind === "select" && /* @__PURE__ */ jsx("option", { value: "" }),
84
+ field.choices?.map((choice) => /* @__PURE__ */ jsx("option", { value: choice.value, children: resolveFormText(choice.label, locale, fallbackLocale) }, choice.value))
85
+ ]
86
+ }
87
+ );
88
+ } else if (field.kind === "radio") {
89
+ control = /* @__PURE__ */ jsx("div", { role: "radiogroup", "aria-describedby": describedBy || void 0, children: field.choices?.map((choice) => /* @__PURE__ */ jsxs("label", { children: [
90
+ /* @__PURE__ */ jsx(
91
+ "input",
92
+ {
93
+ type: "radio",
94
+ name: common.name,
95
+ value: choice.value,
96
+ required: field.required,
97
+ checked: value === choice.value,
98
+ onChange: (event) => {
99
+ if (event.currentTarget.checked) onChange(choice.value);
100
+ }
101
+ }
102
+ ),
103
+ /* @__PURE__ */ jsx("span", { children: resolveFormText(choice.label, locale, fallbackLocale) })
104
+ ] }, choice.value)) });
105
+ } else if (field.kind === "checkbox" || field.kind === "consent") {
106
+ control = /* @__PURE__ */ jsxs("label", { children: [
107
+ /* @__PURE__ */ jsx(
108
+ "input",
109
+ {
110
+ ...common,
111
+ type: "checkbox",
112
+ value: "true",
113
+ checked: value === true,
114
+ onChange: (event) => onChange(event.currentTarget.checked)
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx("span", { children: field.kind === "consent" ? resolveFormText(field.consentText, locale, fallbackLocale) : label })
118
+ ] });
119
+ } else {
120
+ control = /* @__PURE__ */ jsx(
121
+ "input",
122
+ {
123
+ ...common,
124
+ type: field.kind === "phone" ? "tel" : field.kind,
125
+ value: typeof value === "string" || typeof value === "number" ? value : "",
126
+ minLength: field.validation?.minLength,
127
+ maxLength: field.validation?.maxLength,
128
+ min: field.validation?.min,
129
+ max: field.validation?.max,
130
+ onChange: (event) => onChange(
131
+ field.kind === "number" && event.currentTarget.value !== "" ? event.currentTarget.valueAsNumber : event.currentTarget.value
132
+ )
133
+ }
134
+ );
135
+ }
136
+ const hasSeparateLabel = !["address", "checkbox", "consent"].includes(field.kind);
137
+ return /* @__PURE__ */ jsxs("div", { "data-kotao-form-field": field.key, children: [
138
+ hasSeparateLabel && /* @__PURE__ */ jsxs("label", { htmlFor: id, children: [
139
+ label,
140
+ field.required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " *" })
141
+ ] }),
142
+ control,
143
+ description && /* @__PURE__ */ jsx("p", { id: descriptionId, children: description }),
144
+ /* @__PURE__ */ jsx(FieldErrors, { id: errorId, errors })
145
+ ] });
146
+ }
147
+ function StorefrontFormFields({
148
+ form,
149
+ locale,
150
+ fallbackLocale,
151
+ answers: initialAnswers = {},
152
+ errors = {},
153
+ onAnswersChange,
154
+ idPrefix
155
+ }) {
156
+ const [answers, setAnswers] = useState(initialAnswers);
157
+ const generatedId = useId();
158
+ const instanceId = idPrefix ?? `kotao-${generatedId.replaceAll(":", "")}`;
159
+ const schema = form.version.schema;
160
+ function pruneHiddenAnswers(nextAnswers) {
161
+ let pruned = nextAnswers;
162
+ let removed = true;
163
+ while (removed) {
164
+ removed = false;
165
+ for (const field of formFields(schema)) {
166
+ if (Object.hasOwn(pruned, field.key) && !isFormFieldVisible(field, pruned)) {
167
+ if (pruned === nextAnswers) pruned = { ...nextAnswers };
168
+ delete pruned[field.key];
169
+ removed = true;
170
+ }
171
+ }
172
+ }
173
+ return pruned;
174
+ }
175
+ function updateAnswer(key, answer) {
176
+ setAnswers((current) => {
177
+ const next = pruneHiddenAnswers({ ...current, [key]: answer });
178
+ onAnswersChange?.(next);
179
+ return next;
180
+ });
181
+ }
182
+ return /* @__PURE__ */ jsx(Fragment, { children: schema.pages.map((page) => /* @__PURE__ */ jsxs("section", { "data-kotao-form-page": page.key, children: [
183
+ page.title && /* @__PURE__ */ jsx("h2", { children: resolveFormText(page.title, locale, fallbackLocale) }),
184
+ page.description && /* @__PURE__ */ jsx("p", { children: resolveFormText(page.description, locale, fallbackLocale) }),
185
+ page.blocks.map((block) => {
186
+ if (block.type === "section") {
187
+ return /* @__PURE__ */ jsxs("header", { children: [
188
+ /* @__PURE__ */ jsx("h3", { children: resolveFormText(block.title, locale, fallbackLocale) }),
189
+ block.description && /* @__PURE__ */ jsx("p", { children: resolveFormText(block.description, locale, fallbackLocale) })
190
+ ] }, block.key);
191
+ }
192
+ if (block.type === "content") {
193
+ return /* @__PURE__ */ jsx("div", { "data-kotao-form-content": true, children: resolveFormText(block.content, locale, fallbackLocale) }, block.key);
194
+ }
195
+ return isFormFieldVisible(block.field, answers) ? /* @__PURE__ */ jsx(
196
+ StorefrontFormField,
197
+ {
198
+ field: block.field,
199
+ locale,
200
+ fallbackLocale,
201
+ value: answers[block.field.key],
202
+ errors: errors[block.field.key] ?? [],
203
+ onChange: (answer) => updateAnswer(block.field.key, answer),
204
+ idPrefix: instanceId
205
+ },
206
+ block.field.key
207
+ ) : null;
208
+ })
209
+ ] }, page.key)) });
210
+ }
211
+ function StorefrontForm({
212
+ form,
213
+ locale,
214
+ fallbackLocale,
215
+ answers,
216
+ errors,
217
+ submitted = false,
218
+ submitLabel,
219
+ onAnswersChange,
220
+ action = "",
221
+ method = "post",
222
+ ...props
223
+ }) {
224
+ const schema = form.version.schema;
225
+ return /* @__PURE__ */ jsxs("form", { ...props, action, method, "data-kotao-form": form.definition.handle, children: [
226
+ /* @__PURE__ */ jsx("input", { type: "hidden", name: "versionId", value: form.version.id }),
227
+ /* @__PURE__ */ jsx("input", { type: "hidden", name: "locale", value: locale }),
228
+ submitted && /* @__PURE__ */ jsx("p", { role: "status", "data-kotao-form-success": true, children: resolveFormText(schema.successMessage, locale, fallbackLocale) }),
229
+ /* @__PURE__ */ jsx(
230
+ StorefrontFormFields,
231
+ {
232
+ form,
233
+ locale,
234
+ ...fallbackLocale === void 0 ? {} : { fallbackLocale },
235
+ ...answers === void 0 ? {} : { answers },
236
+ ...errors === void 0 ? {} : { errors },
237
+ ...onAnswersChange === void 0 ? {} : { onAnswersChange }
238
+ }
239
+ ),
240
+ /* @__PURE__ */ jsx("button", { type: "submit", children: submitLabel ?? (resolveFormText(schema.submitLabel, locale, fallbackLocale) || "Submit") })
241
+ ] });
242
+ }
243
+
244
+ export { StorefrontForm, StorefrontFormFields };
245
+ //# sourceMappingURL=chunk-VV653S52.js.map
246
+ //# sourceMappingURL=chunk-VV653S52.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/form.tsx"],"names":[],"mappings":";;;;AAgDA,IAAM,cAAA,GAAsE;AAAA,EAC1E,KAAA,EAAO,SAAA;AAAA,EACP,KAAA,EAAO,gBAAA;AAAA,EACP,IAAA,EAAM,MAAA;AAAA,EACN,UAAA,EAAY,aAAA;AAAA,EACZ,WAAA,EAAa,cAAA;AAAA,EACb,YAAA,EAAc;AAChB,CAAA;AAEA,SAAS,WAAA,CAAY,EAAE,EAAA,EAAI,MAAA,EAAO,EAAqC;AACrE,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,IAAA;AAChC,EAAA,2BACG,IAAA,EAAA,EAAG,EAAA,EAAQ,0BAAsB,IAAA,EAC/B,QAAA,EAAA,MAAA,CAAO,IAAI,CAAC,KAAA,EAAO,0BAClB,GAAA,CAAC,IAAA,EAAA,EAA8B,mBAAtB,CAAA,EAAG,KAAK,IAAI,KAAK,CAAA,CAAW,CACtC,CAAA,EACH,CAAA;AAEJ;AAEA,SAAS,mBAAA,CAAoB;AAAA,EAC3B,KAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA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AA,CAAW,MAAA,EAChF,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,OAAA,EAAA,EAAM,MAAK,QAAA,EAAS,IAAA,EAAK,aAAY,KAAA,EAAO,IAAA,CAAK,QAAQ,EAAA,EAAI,CAAA;AAAA,wBAC7D,OAAA,EAAA,EAAM,IAAA,EAAK,UAAS,IAAA,EAAK,QAAA,EAAS,OAAO,MAAA,EAAQ,CAAA;AAAA,IACjD,SAAA,oBACC,GAAA,CAAC,GAAA,EAAA,EAAE,IAAA,EAAK,QAAA,EAAS,yBAAA,EAAuB,IAAA,EACrC,QAAA,EAAA,eAAA,CAAgB,MAAA,CAAO,cAAA,EAAgB,MAAA,EAAQ,cAAc,CAAA,EAChE,CAAA;AAAA,oBAEF,GAAA;AAAA,MAAC,oBAAA;AAAA,MAAA;AAAA,QACC,IAAA;AAAA,QACA,MAAA;AAAA,QACC,GAAI,cAAA,KAAmB,MAAA,GAAY,EAAC,GAAI,EAAE,cAAA,EAAe;AAAA,QACzD,GAAI,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAQ;AAAA,QAC3C,GAAI,MAAA,KAAW,MAAA,GAAY,EAAC,GAAI,EAAE,MAAA,EAAO;AAAA,QACzC,GAAI,eAAA,KAAoB,MAAA,GAAY,EAAC,GAAI,EAAE,eAAA;AAAgB;AAAA,KAC9D;AAAA,oBACA,GAAA,CAAC,QAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EACV,QAAA,EAAA,WAAA,KAAgB,eAAA,CAAgB,MAAA,CAAO,WAAA,EAAa,MAAA,EAAQ,cAAc,CAAA,IAAK,QAAA,CAAA,EAClF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-VV653S52.js","sourcesContent":["import React, { useId, useState, type ComponentPropsWithoutRef, type ReactNode } from 'react'\nimport {\n ADDRESS_PROPERTIES,\n formAnswerName,\n formFields,\n isFormFieldVisible,\n resolveFormText,\n type FormAnswer,\n type FormAnswers,\n type FormField,\n type FormFieldErrors,\n type PublicForm,\n} from '../forms'\n\nexport interface StorefrontFormProps extends Omit<\n ComponentPropsWithoutRef<'form'>,\n 'children' | 'defaultValue'\n> {\n form: PublicForm\n locale: string\n fallbackLocale?: string\n answers?: FormAnswers\n errors?: FormFieldErrors\n submitted?: boolean\n submitLabel?: ReactNode\n onAnswersChange?: (answers: FormAnswers) => void\n}\n\nexport interface StorefrontFormFieldsProps {\n readonly form: PublicForm\n readonly locale: string\n readonly fallbackLocale?: string\n readonly answers?: FormAnswers\n readonly errors?: FormFieldErrors\n readonly onAnswersChange?: (answers: FormAnswers) => void\n readonly idPrefix?: string\n}\n\ninterface FieldProps {\n field: FormField\n locale: string\n fallbackLocale?: string | undefined\n value?: FormAnswer | undefined\n errors: string[]\n onChange: (value: FormAnswer) => void\n idPrefix: string\n}\n\nconst ADDRESS_LABELS: Record<(typeof ADDRESS_PROPERTIES)[number], string> = {\n line1: 'Address',\n line2: 'Address line 2',\n city: 'City',\n postalCode: 'Postal code',\n countryCode: 'Country code',\n provinceCode: 'Province or state code',\n}\n\nfunction FieldErrors({ id, errors }: { id: string; errors: string[] }) {\n if (errors.length === 0) return null\n return (\n <ul id={id} data-kotao-form-errors>\n {errors.map((error, index) => (\n <li key={`${error}-${index}`}>{error}</li>\n ))}\n </ul>\n )\n}\n\nfunction StorefrontFormField({\n field,\n locale,\n fallbackLocale,\n value,\n errors,\n onChange,\n idPrefix,\n}: FieldProps) {\n const id = `${idPrefix}-form-${field.key}`\n const label = resolveFormText(field.label, locale, fallbackLocale)\n const description = resolveFormText(field.description, locale, fallbackLocale)\n const errorId = `${id}-errors`\n const descriptionId = `${id}-description`\n const describedBy = [description ? descriptionId : '', errors.length ? errorId : '']\n .filter(Boolean)\n .join(' ')\n const common = {\n id,\n name: formAnswerName(field.key),\n required: field.required,\n 'aria-invalid': errors.length > 0 || undefined,\n 'aria-describedby': describedBy || undefined,\n }\n let control: ReactNode\n\n if (field.kind === 'textarea') {\n control = (\n <textarea\n {...common}\n value={typeof value === 'string' ? value : ''}\n minLength={field.validation?.minLength}\n maxLength={field.validation?.maxLength}\n onChange={(event) => onChange(event.currentTarget.value)}\n />\n )\n } else if (field.kind === 'address') {\n const address = typeof value === 'object' && !Array.isArray(value) ? value : {}\n control = (\n <fieldset aria-describedby={describedBy || undefined}>\n <legend>\n {label}\n {field.required && <span aria-hidden=\"true\"> *</span>}\n </legend>\n {ADDRESS_PROPERTIES.map((property) => (\n <label key={property}>\n <span>{ADDRESS_LABELS[property]}</span>\n <input\n name={formAnswerName(field.key, property)}\n value={address[property] ?? ''}\n required={\n field.required && ['line1', 'postalCode', 'city', 'countryCode'].includes(property)\n }\n onChange={(event) => onChange({ ...address, [property]: event.currentTarget.value })}\n />\n </label>\n ))}\n </fieldset>\n )\n } else if (field.kind === 'select' || field.kind === 'multi_select') {\n const selected = Array.isArray(value) ? value : typeof value === 'string' ? [value] : []\n control = (\n <select\n {...common}\n multiple={field.kind === 'multi_select'}\n value={field.kind === 'multi_select' ? selected : (selected[0] ?? '')}\n onChange={(event) =>\n onChange(\n field.kind === 'multi_select'\n ? Array.from(event.currentTarget.selectedOptions, (option) => option.value)\n : event.currentTarget.value,\n )\n }\n >\n {field.kind === 'select' && <option value=\"\" />}\n {field.choices?.map((choice) => (\n <option key={choice.value} value={choice.value}>\n {resolveFormText(choice.label, locale, fallbackLocale)}\n </option>\n ))}\n </select>\n )\n } else if (field.kind === 'radio') {\n control = (\n <div role=\"radiogroup\" aria-describedby={describedBy || undefined}>\n {field.choices?.map((choice) => (\n <label key={choice.value}>\n <input\n type=\"radio\"\n name={common.name}\n value={choice.value}\n required={field.required}\n checked={value === choice.value}\n onChange={(event) => {\n if (event.currentTarget.checked) onChange(choice.value)\n }}\n />\n <span>{resolveFormText(choice.label, locale, fallbackLocale)}</span>\n </label>\n ))}\n </div>\n )\n } else if (field.kind === 'checkbox' || field.kind === 'consent') {\n control = (\n <label>\n <input\n {...common}\n type=\"checkbox\"\n value=\"true\"\n checked={value === true}\n onChange={(event) => onChange(event.currentTarget.checked)}\n />\n <span>\n {field.kind === 'consent'\n ? resolveFormText(field.consentText, locale, fallbackLocale)\n : label}\n </span>\n </label>\n )\n } else {\n control = (\n <input\n {...common}\n type={field.kind === 'phone' ? 'tel' : field.kind}\n value={typeof value === 'string' || typeof value === 'number' ? value : ''}\n minLength={field.validation?.minLength}\n maxLength={field.validation?.maxLength}\n min={field.validation?.min}\n max={field.validation?.max}\n onChange={(event) =>\n onChange(\n field.kind === 'number' && event.currentTarget.value !== ''\n ? event.currentTarget.valueAsNumber\n : event.currentTarget.value,\n )\n }\n />\n )\n }\n\n const hasSeparateLabel = !['address', 'checkbox', 'consent'].includes(field.kind)\n return (\n <div data-kotao-form-field={field.key}>\n {hasSeparateLabel && (\n <label htmlFor={id}>\n {label}\n {field.required && <span aria-hidden=\"true\"> *</span>}\n </label>\n )}\n {control}\n {description && <p id={descriptionId}>{description}</p>}\n <FieldErrors id={errorId} errors={errors} />\n </div>\n )\n}\n\nexport function StorefrontFormFields({\n form,\n locale,\n fallbackLocale,\n answers: initialAnswers = {},\n errors = {},\n onAnswersChange,\n idPrefix,\n}: StorefrontFormFieldsProps) {\n const [answers, setAnswers] = useState<FormAnswers>(initialAnswers)\n const generatedId = useId()\n const instanceId = idPrefix ?? `kotao-${generatedId.replaceAll(':', '')}`\n const schema = form.version.schema\n\n function pruneHiddenAnswers(nextAnswers: FormAnswers): FormAnswers {\n let pruned = nextAnswers\n let removed = true\n while (removed) {\n removed = false\n for (const field of formFields(schema)) {\n if (Object.hasOwn(pruned, field.key) && !isFormFieldVisible(field, pruned)) {\n if (pruned === nextAnswers) pruned = { ...nextAnswers }\n delete pruned[field.key]\n removed = true\n }\n }\n }\n return pruned\n }\n\n function updateAnswer(key: string, answer: FormAnswer) {\n setAnswers((current) => {\n const next = pruneHiddenAnswers({ ...current, [key]: answer })\n onAnswersChange?.(next)\n return next\n })\n }\n\n return (\n <>\n {schema.pages.map((page) => (\n <section key={page.key} data-kotao-form-page={page.key}>\n {page.title && <h2>{resolveFormText(page.title, locale, fallbackLocale)}</h2>}\n {page.description && <p>{resolveFormText(page.description, locale, fallbackLocale)}</p>}\n {page.blocks.map((block) => {\n if (block.type === 'section') {\n return (\n <header key={block.key}>\n <h3>{resolveFormText(block.title, locale, fallbackLocale)}</h3>\n {block.description && (\n <p>{resolveFormText(block.description, locale, fallbackLocale)}</p>\n )}\n </header>\n )\n }\n if (block.type === 'content') {\n return (\n <div key={block.key} data-kotao-form-content>\n {resolveFormText(block.content, locale, fallbackLocale)}\n </div>\n )\n }\n return isFormFieldVisible(block.field, answers) ? (\n <StorefrontFormField\n key={block.field.key}\n field={block.field}\n locale={locale}\n fallbackLocale={fallbackLocale}\n value={answers[block.field.key]}\n errors={errors[block.field.key] ?? []}\n onChange={(answer) => updateAnswer(block.field.key, answer)}\n idPrefix={instanceId}\n />\n ) : null\n })}\n </section>\n ))}\n </>\n )\n}\n\nexport function StorefrontForm({\n form,\n locale,\n fallbackLocale,\n answers,\n errors,\n submitted = false,\n submitLabel,\n onAnswersChange,\n action = '',\n method = 'post',\n ...props\n}: StorefrontFormProps) {\n const schema = form.version.schema\n\n return (\n <form {...props} action={action} method={method} data-kotao-form={form.definition.handle}>\n <input type=\"hidden\" name=\"versionId\" value={form.version.id} />\n <input type=\"hidden\" name=\"locale\" value={locale} />\n {submitted && (\n <p role=\"status\" data-kotao-form-success>\n {resolveFormText(schema.successMessage, locale, fallbackLocale)}\n </p>\n )}\n <StorefrontFormFields\n form={form}\n locale={locale}\n {...(fallbackLocale === undefined ? {} : { fallbackLocale })}\n {...(answers === undefined ? {} : { answers })}\n {...(errors === undefined ? {} : { errors })}\n {...(onAnswersChange === undefined ? {} : { onAnswersChange })}\n />\n <button type=\"submit\">\n {submitLabel ?? (resolveFormText(schema.submitLabel, locale, fallbackLocale) || 'Submit')}\n </button>\n </form>\n )\n}\n"]}
@@ -0,0 +1,38 @@
1
+ // src/events/offer-token.ts
2
+ var CLAIM_TOKEN = /^[A-Za-z0-9_-]{43}$/u;
3
+ var consumedLocationMarkers = /* @__PURE__ */ new WeakMap();
4
+ function offerTokenHrefMarker(href) {
5
+ let left = 2166136261;
6
+ let right = 2246822507;
7
+ for (let index = 0; index < href.length; index += 1) {
8
+ const code = href.charCodeAt(index);
9
+ left = Math.imul(left ^ code, 16777619);
10
+ right = Math.imul(right ^ code, 3266489909);
11
+ }
12
+ return `${(left >>> 0).toString(16).padStart(8, "0")}${(right >>> 0).toString(16).padStart(8, "0")}`;
13
+ }
14
+ function consumeOfferTokenFragment(location, history) {
15
+ const marker = offerTokenHrefMarker(location.href);
16
+ const consumedMarkers = consumedLocationMarkers.get(location) ?? /* @__PURE__ */ new Set();
17
+ if (consumedMarkers.has(marker)) return null;
18
+ consumedMarkers.add(marker);
19
+ consumedLocationMarkers.set(location, consumedMarkers);
20
+ const url = new URL(location.href);
21
+ const queryHasToken = url.searchParams.has("token") || url.searchParams.has("claimToken");
22
+ const fragment = new URLSearchParams(url.hash.startsWith("#") ? url.hash.slice(1) : url.hash);
23
+ const fragmentToken = fragment.get("token");
24
+ const fragmentIsExact = fragment.size === 1 && fragment.has("token");
25
+ const shouldReplace = queryHasToken || url.hash !== "";
26
+ url.searchParams.delete("token");
27
+ url.searchParams.delete("claimToken");
28
+ url.hash = "";
29
+ if (shouldReplace) {
30
+ history.replaceState(history.state, "", `${url.pathname}${url.search}`);
31
+ }
32
+ if (queryHasToken || !fragmentIsExact || fragmentToken === null) return null;
33
+ return CLAIM_TOKEN.test(fragmentToken) ? fragmentToken : null;
34
+ }
35
+
36
+ export { consumeOfferTokenFragment, offerTokenHrefMarker };
37
+ //# sourceMappingURL=chunk-WG7HYVHJ.js.map
38
+ //# sourceMappingURL=chunk-WG7HYVHJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/events/offer-token.ts"],"names":[],"mappings":";AASA,IAAM,WAAA,GAAc,sBAAA;AACpB,IAAM,uBAAA,uBAA8B,OAAA,EAA6B;AAG1D,S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ACxF,EAAA,MAAM,QAAA,GAAW,IAAI,eAAA,CAAgB,GAAA,CAAI,KAAK,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA,GAAI,IAAI,IAAI,CAAA;AAC5F,EAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAC1C,EAAA,MAAM,kBAAkB,QAAA,CAAS,IAAA,KAAS,CAAA,IAAK,QAAA,CAAS,IAAI,OAAO,CAAA;AACnE,EAAA,MAAM,aAAA,GAAgB,aAAA,IAAiB,GAAA,CAAI,IAAA,KAAS,EAAA;AAEpD,EAAA,GAAA,CAAI,YAAA,CAAa,OAAO,OAAO,CAAA;AAC/B,EAAA,GAAA,CAAI,YAAA,CAAa,OAAO,YAAY,CAAA;AACpC,EAAA,GAAA,CAAI,IAAA,GAAO,EAAA;AACX,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,OAAA,CAAQ,YAAA,CAAa,OAAA,CAAQ,KAAA,EAAO,EAAA,EAAI,CAAA,EAAG,IAAI,QAAQ,CAAA,EAAG,GAAA,CAAI,MAAM,CAAA,CAAE,CAAA;AAAA,EACxE;AAEA,EAAA,IAAI,aAAA,IAAiB,CAAC,eAAA,IAAmB,aAAA,KAAkB,MAAM,OAAO,IAAA;AACxE,EAAA,OAAO,WAAA,CAAY,IAAA,CAAK,aAAa,CAAA,GAAI,aAAA,GAAgB,IAAA;AAC3D","file":"chunk-WG7HYVHJ.js","sourcesContent":["export interface OfferTokenLocation {\n readonly href: string\n}\n\nexport interface OfferTokenHistory {\n readonly state: unknown\n replaceState(data: unknown, unused: string, url?: string | URL | null): void\n}\n\nconst CLAIM_TOKEN = /^[A-Za-z0-9_-]{43}$/u\nconst consumedLocationMarkers = new WeakMap<object, Set<string>>()\n\n/** Lossy marker for replay detection. It never retains or reproduces the capability-bearing href. */\nexport function offerTokenHrefMarker(href: string): string {\n let left = 0x811c9dc5\n let right = 0x85ebca6b\n for (let index = 0; index < href.length; index += 1) {\n const code = href.charCodeAt(index)\n left = Math.imul(left ^ code, 0x01000193)\n right = Math.imul(right ^ code, 0xc2b2ae35)\n }\n return `${(left >>> 0).toString(16).padStart(8, '0')}${(right >>> 0)\n .toString(16)\n .padStart(8, '0')}`\n}\n\n/**\n * Consumes an offer capability from the fragment and removes capability-bearing URL state before\n * the caller can issue a request. Query-string capabilities are sanitized but never accepted.\n */\nexport function consumeOfferTokenFragment(\n location: OfferTokenLocation,\n history: OfferTokenHistory,\n): string | null {\n const marker = offerTokenHrefMarker(location.href)\n const consumedMarkers = consumedLocationMarkers.get(location) ?? new Set<string>()\n if (consumedMarkers.has(marker)) return null\n consumedMarkers.add(marker)\n consumedLocationMarkers.set(location, consumedMarkers)\n\n const url = new URL(location.href)\n const queryHasToken = url.searchParams.has('token') || url.searchParams.has('claimToken')\n const fragment = new URLSearchParams(url.hash.startsWith('#') ? url.hash.slice(1) : url.hash)\n const fragmentToken = fragment.get('token')\n const fragmentIsExact = fragment.size === 1 && fragment.has('token')\n const shouldReplace = queryHasToken || url.hash !== ''\n\n url.searchParams.delete('token')\n url.searchParams.delete('claimToken')\n url.hash = ''\n if (shouldReplace) {\n history.replaceState(history.state, '', `${url.pathname}${url.search}`)\n }\n\n if (queryHasToken || !fragmentIsExact || fragmentToken === null) return null\n return CLAIM_TOKEN.test(fragmentToken) ? fragmentToken : null\n}\n"]}
@@ -1,9 +1,13 @@
1
+ import { S as StorefrontHeadersInit } from './http-types-CGh8WGHB.js';
2
+
1
3
  interface CacheStrategy {
2
4
  readonly mode: 'none' | 'short' | 'long' | 'custom';
3
5
  /** seconds the value is considered fresh */
4
6
  readonly maxAge: number;
5
7
  /** extra seconds the stale value may be served while revalidating */
6
8
  readonly staleWhileRevalidate: number;
9
+ /** extra seconds the last value may be served only when revalidation fails */
10
+ readonly staleIfError?: number;
7
11
  }
8
12
  declare const CacheNone: () => CacheStrategy;
9
13
  declare const CacheShort: (o?: Partial<Omit<CacheStrategy, "mode">>) => CacheStrategy;
@@ -13,8 +17,32 @@ declare const CacheCustom: (s: Omit<CacheStrategy, "mode">) => CacheStrategy;
13
17
  declare const StorefrontDefaultCache: () => CacheStrategy;
14
18
  declare function generateCacheControlHeader(strategy: CacheStrategy): string;
15
19
  interface KotaoCache {
16
- run<T>(key: string, strategy: CacheStrategy, fn: () => Promise<T>): Promise<T>;
17
- readonly raw: Cache;
20
+ run<T>(key: string, strategy: CacheStrategy, fn: () => Promise<T>, onStaleIfError?: (fallback: StaleIfErrorFallback) => void): Promise<T>;
21
+ readonly raw: StorefrontCacheInput;
22
+ }
23
+ type StorefrontCacheRequest = Request | string | URL;
24
+ interface StorefrontCacheQueryOptions {
25
+ readonly cacheName?: string;
26
+ readonly ignoreMethod?: boolean;
27
+ readonly ignoreSearch?: boolean;
28
+ readonly ignoreVary?: boolean;
29
+ }
30
+ /** Worker-compatible Cache input required by the storefront cache implementation. */
31
+ interface StorefrontCacheInput {
32
+ delete(request: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<boolean>;
33
+ match(request: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<Response | undefined>;
34
+ put(request: StorefrontCacheRequest, response: Response): Promise<void>;
35
+ }
36
+ /** Full standard Cache surface retained by the public storefront client. */
37
+ interface StorefrontCache extends StorefrontCacheInput {
38
+ add(request: StorefrontCacheRequest): Promise<void>;
39
+ addAll(requests: StorefrontCacheRequest[]): Promise<void>;
40
+ keys(request?: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<readonly Request[]>;
41
+ matchAll(request?: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<readonly Response[]>;
42
+ }
43
+ interface StaleIfErrorFallback {
44
+ readonly ageSeconds: number;
45
+ readonly error: unknown;
18
46
  }
19
47
  /**
20
48
  * Stale-while-revalidate cache over an injected Cache (WFP untrusted mode disables
@@ -23,7 +51,7 @@ interface KotaoCache {
23
51
  * cross-request age is ever compared, which `Date.now()` reports correctly.
24
52
  */
25
53
  declare function createCache(opts: {
26
- cache: Cache;
54
+ cache: StorefrontCacheInput;
27
55
  waitUntil: (p: Promise<unknown>) => void;
28
56
  now?: () => number;
29
57
  }): KotaoCache;
@@ -32,6 +60,22 @@ interface StorefrontQueryOptions {
32
60
  variables?: Record<string, unknown>;
33
61
  cache?: CacheStrategy;
34
62
  storefrontApiVersion?: string;
63
+ /** Per-read upstream budget in milliseconds. Defaults to the client's 5,000 ms budget. */
64
+ timeoutMs?: number;
65
+ }
66
+ declare class StorefrontQueryTimeoutError extends Error {
67
+ readonly operationName: string;
68
+ readonly timeoutMs: number;
69
+ constructor(operationName: string, timeoutMs: number);
70
+ }
71
+ declare class StorefrontUpstreamError extends Error {
72
+ readonly operationName: string;
73
+ readonly status: number | undefined;
74
+ readonly cause: unknown;
75
+ constructor(operationName: string, message: string, options?: {
76
+ status?: number;
77
+ cause?: unknown;
78
+ });
35
79
  }
36
80
  interface StorefrontLooseConnection<T = any> {
37
81
  readonly nodes: T[];
@@ -87,7 +131,7 @@ interface StorefrontClient {
87
131
  CacheShort: typeof CacheShort;
88
132
  CacheLong: typeof CacheLong;
89
133
  CacheCustom: typeof CacheCustom;
90
- readonly cache: Cache;
134
+ readonly cache: StorefrontCache;
91
135
  readonly i18n: StorefrontI18n;
92
136
  }
93
137
  type Storefront<I18n = unknown> = StorefrontClient & {
@@ -111,6 +155,8 @@ interface StorefrontClientOptions {
111
155
  cache: KotaoCache;
112
156
  fetch?: typeof fetch | undefined;
113
157
  defaultStrategy?: CacheStrategy | undefined;
158
+ /** Default budget for each independent read query. Mutations are intentionally excluded. */
159
+ queryTimeoutMs?: number | undefined;
114
160
  /**
115
161
  * Pre-signed `x-kotao-shop` / `x-kotao-shop-signature` header pair, merged into every request.
116
162
  * In production the Gateway signs the shop-context; in local dev (no Gateway) the theme dev
@@ -121,7 +167,7 @@ interface StorefrontClientOptions {
121
167
  * Additional server request headers to forward to direct Storefront API calls. Used by
122
168
  * Hydrogen-compatible server adapters for `storefrontHeaders`.
123
169
  */
124
- extraHeaders?: HeadersInit | undefined;
170
+ extraHeaders?: StorefrontHeadersInit | undefined;
125
171
  /**
126
172
  * BCP 47 locale tag derived from the localization cookie (e.g. `'nl'`, `'es'`, `'de-de'`).
127
173
  * When set, `x-kotao-locale` is added to every request so storefront-api can overlay
@@ -136,17 +182,18 @@ interface StorefrontClientOptions {
136
182
  i18n?: Partial<StorefrontI18n> | undefined;
137
183
  }
138
184
  interface HydrogenStorefrontClientOptions<I18n extends object = StorefrontI18n> {
139
- cache: Cache;
185
+ cache: StorefrontCacheInput;
140
186
  waitUntil: (promise: Promise<unknown>) => void;
141
187
  i18n?: I18n | undefined;
142
188
  publicStorefrontToken: string;
143
189
  privateStorefrontToken?: string | undefined;
144
190
  storeDomain: string;
145
191
  storefrontId?: string | undefined;
146
- storefrontHeaders?: HeadersInit | undefined;
192
+ storefrontHeaders?: StorefrontHeadersInit | undefined;
147
193
  storefrontApiVersion?: string | undefined;
148
194
  fetch?: typeof fetch | undefined;
149
195
  defaultStrategy?: CacheStrategy | undefined;
196
+ queryTimeoutMs?: number | undefined;
150
197
  }
151
198
  /**
152
199
  * Typed GraphQL client mirroring Hydrogen's `createStorefrontClient`. Queries are SWR-cached
@@ -156,4 +203,4 @@ interface HydrogenStorefrontClientOptions<I18n extends object = StorefrontI18n>
156
203
  declare function createStorefrontClient(opts: StorefrontClientOptions): StorefrontClientResult;
157
204
  declare function createStorefrontClient<I18n extends object = StorefrontI18n>(opts: HydrogenStorefrontClientOptions<I18n>): StorefrontClientResult<StorefrontI18n & I18n>;
158
205
 
159
- export { type CacheStrategy as C, type HydrogenStorefrontClientOptions as H, type KotaoCache as K, type StorefrontClient as S, CacheCustom as a, CacheLong as b, CacheNone as c, CacheShort as d, type Storefront as e, type StorefrontAuthHeader as f, type StorefrontClientOptions as g, type StorefrontClientResult as h, StorefrontDefaultCache as i, type StorefrontQueryOptions as j, createCache as k, createStorefrontClient as l, generateCacheControlHeader as m };
206
+ export { type CacheStrategy as C, type HydrogenStorefrontClientOptions as H, type KotaoCache as K, type StorefrontClient as S, type StorefrontAuthHeader as a, type StorefrontCacheInput as b, CacheCustom as c, CacheLong as d, CacheNone as e, CacheShort as f, type StaleIfErrorFallback as g, type Storefront as h, type StorefrontCache as i, type StorefrontCacheQueryOptions as j, type StorefrontCacheRequest as k, type StorefrontClientOptions as l, type StorefrontClientResult as m, StorefrontDefaultCache as n, type StorefrontQueryOptions as o, StorefrontQueryTimeoutError as p, StorefrontUpstreamError as q, createCache as r, createStorefrontClient as s, generateCacheControlHeader as t };
@@ -0,0 +1,159 @@
1
+ import { F as FormVersionSchema } from './types-CSNXbGFW.js';
2
+ import { S as StorefrontHeadersInit } from './http-types-CGh8WGHB.js';
3
+
4
+ type EventRegistrationMode = 'instant' | 'approval_then_payment' | 'waitlist_only';
5
+ interface PublicEventVenue {
6
+ readonly name?: string | undefined;
7
+ readonly addressLine1?: string | undefined;
8
+ readonly addressLine2?: string | undefined;
9
+ readonly postalCode?: string | undefined;
10
+ readonly city?: string | undefined;
11
+ readonly countryCode?: string | undefined;
12
+ readonly notes?: string | undefined;
13
+ }
14
+ interface PublicEventForm {
15
+ readonly definitionId: string;
16
+ readonly versionId: string;
17
+ readonly title: string;
18
+ readonly schema: FormVersionSchema;
19
+ }
20
+ interface PublicEventTicketType {
21
+ readonly id: string;
22
+ readonly title: string;
23
+ readonly description: string | null;
24
+ readonly price: number;
25
+ readonly currency: string;
26
+ readonly availability: 'unlimited' | 'limited';
27
+ readonly available: number | null;
28
+ readonly minPerOrder: number;
29
+ readonly maxPerOrder: number;
30
+ readonly admissionMode: 'ticketed' | 'registration_only';
31
+ readonly salesState: 'upcoming' | 'on_sale' | 'paused' | 'sold_out' | 'ended';
32
+ readonly buyerForm: PublicEventForm | null;
33
+ readonly participantForm: PublicEventForm | null;
34
+ }
35
+ interface PublicEventOccurrence {
36
+ readonly id: string;
37
+ readonly startsAt: string;
38
+ readonly endsAt: string;
39
+ readonly timezone: string;
40
+ readonly venue: PublicEventVenue;
41
+ readonly ticketTypes: readonly PublicEventTicketType[];
42
+ }
43
+ interface PublicEvent {
44
+ readonly id: string;
45
+ readonly handle: string;
46
+ readonly title: string;
47
+ readonly description: string | null;
48
+ readonly registrationMode: EventRegistrationMode;
49
+ readonly venue: PublicEventVenue;
50
+ readonly occurrences: readonly PublicEventOccurrence[];
51
+ }
52
+ type EventFormAnswer = string | number | boolean | string[] | Record<string, string>;
53
+ interface EventFormSubmissionInput {
54
+ readonly versionId: string;
55
+ readonly answers: Readonly<Record<string, EventFormAnswer>>;
56
+ }
57
+ interface CreateEventCheckoutSession {
58
+ readonly ticketTypeId: string;
59
+ readonly quantity: number;
60
+ readonly cartToken: string;
61
+ readonly locale: string;
62
+ readonly buyer?: EventFormSubmissionInput;
63
+ readonly participants?: readonly EventFormSubmissionInput[];
64
+ readonly waitlistOffer?: {
65
+ readonly offerId: string;
66
+ readonly claimToken: string;
67
+ };
68
+ }
69
+ interface EventCheckoutSession {
70
+ readonly id: string;
71
+ readonly ticketTypeId: string;
72
+ readonly occurrenceId: string;
73
+ readonly quantity: number;
74
+ readonly state: 'draft' | 'ready' | 'cart_linked' | 'order_pending' | 'converted' | 'expired' | 'cancelled';
75
+ readonly expiresAt: string;
76
+ readonly createdAt: string;
77
+ readonly updatedAt: string;
78
+ }
79
+ interface CreateEventApprovalRequest {
80
+ readonly ticketTypeId: string;
81
+ readonly quantity: number;
82
+ readonly contactEmail: string;
83
+ readonly locale: string;
84
+ readonly buyer?: EventFormSubmissionInput;
85
+ readonly participants?: readonly EventFormSubmissionInput[];
86
+ }
87
+ interface EventApprovalRequestReceipt {
88
+ readonly id: string;
89
+ readonly state: 'awaiting_approval';
90
+ }
91
+ interface EventApprovalOfferResolution {
92
+ readonly offerId: string;
93
+ readonly state: 'active' | 'claimed';
94
+ readonly eventTitle: string;
95
+ readonly occurrenceStartsAt: string;
96
+ readonly ticketTypeTitle: string;
97
+ readonly quantity: number;
98
+ readonly expiresAt: string;
99
+ }
100
+ interface ClaimEventApprovalOffer {
101
+ readonly claimToken: string;
102
+ readonly cartToken: string;
103
+ readonly locale: string;
104
+ }
105
+ interface CreateEventWaitlistEntry {
106
+ readonly ticketTypeId: string;
107
+ readonly quantity: number;
108
+ readonly email: string;
109
+ }
110
+ interface EventWaitlistReceipt {
111
+ readonly id: string;
112
+ readonly state: 'waitlisted';
113
+ }
114
+ type EventRegistrationSubmission = {
115
+ readonly registrationMode: 'instant';
116
+ readonly handle: string;
117
+ readonly input: CreateEventCheckoutSession;
118
+ readonly idempotencyKey: string;
119
+ } | {
120
+ readonly registrationMode: 'approval_then_payment';
121
+ readonly handle: string;
122
+ readonly input: CreateEventApprovalRequest;
123
+ readonly idempotencyKey: string;
124
+ } | {
125
+ readonly registrationMode: 'waitlist_only';
126
+ readonly handle: string;
127
+ readonly input: CreateEventWaitlistEntry;
128
+ };
129
+ type EventRegistrationResult = {
130
+ readonly kind: 'checkout';
131
+ readonly checkoutSession: EventCheckoutSession;
132
+ } | {
133
+ readonly kind: 'approval';
134
+ readonly receipt: EventApprovalRequestReceipt;
135
+ } | {
136
+ readonly kind: 'waitlist';
137
+ readonly receipt: EventWaitlistReceipt;
138
+ };
139
+
140
+ interface EventsClient {
141
+ getEvent(handle: string): Promise<PublicEvent>;
142
+ createCheckoutSession(handle: string, input: CreateEventCheckoutSession, idempotencyKey: string): Promise<EventCheckoutSession>;
143
+ submitApplication(handle: string, input: CreateEventApprovalRequest, idempotencyKey: string): Promise<EventApprovalRequestReceipt>;
144
+ joinWaitlist(handle: string, input: CreateEventWaitlistEntry): Promise<EventWaitlistReceipt>;
145
+ submitRegistration(input: EventRegistrationSubmission): Promise<EventRegistrationResult>;
146
+ resolveOffer(offerId: string, claimToken: string, idempotencyKey?: string): Promise<EventApprovalOfferResolution>;
147
+ claimOffer(offerId: string, input: ClaimEventApprovalOffer, idempotencyKey: string): Promise<EventCheckoutSession>;
148
+ }
149
+ declare class StorefrontEventsRequestError extends Error {
150
+ readonly status: number;
151
+ constructor(status: number);
152
+ }
153
+ declare function createEventsClient(input: {
154
+ readonly baseUrl: string;
155
+ readonly fetch: typeof globalThis.fetch;
156
+ readonly defaultHeaders?: StorefrontHeadersInit;
157
+ }): EventsClient;
158
+
159
+ export { type ClaimEventApprovalOffer as C, type EventsClient as E, type PublicEvent as P, StorefrontEventsRequestError as S, type EventCheckoutSession as a, type EventApprovalOfferResolution as b, type EventRegistrationSubmission as c, type CreateEventApprovalRequest as d, type CreateEventCheckoutSession as e, type CreateEventWaitlistEntry as f, type EventApprovalRequestReceipt as g, type EventFormAnswer as h, type EventFormSubmissionInput as i, type EventRegistrationMode as j, type EventRegistrationResult as k, type EventWaitlistReceipt as l, type PublicEventForm as m, type PublicEventOccurrence as n, type PublicEventTicketType as o, type PublicEventVenue as p, createEventsClient as q };