@lockerverse/react 0.2.69 → 0.2.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contact-validation.js +1 -1
- package/dist/contact-validation.js.map +1 -1
- package/dist/form-ui.css +269 -0
- package/dist/lockerverse-payment.d.ts.map +1 -1
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/dist/signup.css +13 -68
- package/dist/signup.d.ts +3 -1
- package/dist/signup.d.ts.map +1 -1
- package/dist/signup.js +1 -1
- package/dist/signup.js.map +1 -1
- package/dist/styles.css +5 -204
- package/package.json +2 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{array as e,email as t,minLength as n,nonEmpty as r,pipe as i,regex as a,safeParse as o,string as s,transform as c,trim as l}from"valibot";import{jsx as u,jsxs as d}from"react/jsx-runtime";const f=/^#([\da-f]{3}|[\da-f]{6})$/i,p=/^([\da-f]{3}|[\da-f]{6})$/i;function m(e){let t=e.trim();return p.test(t)?`#${t}`:t}function h(e){let t=f.exec(m(e));if(!t)return;let[,n]=t;if(!n)return;let r=n.length===3?Array.from(n,e=>`${e}${e}`).join(``):n;return[0,2,4].map(e=>Number.parseInt(r.slice(e,e+2),16))}function g([e,t,n]){let[r=0,i=0,a=0]=[e,t,n].map((e=0)=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function _(e){let t=h(e);if(!t)return;let n=g(t);return(n+.05)/.05>=1.05/(n+.05)?`#000`:`#fff`}function v(e){return Object.fromEntries(e.map(e=>[e.id,e.type===`checkboxes`||e.type===`multi_select`?[]:``]))}function y(e,t){return e.map(e=>{let n=t[e.id];return e.type===`checkboxes`||e.type===`multi_select`?{fieldId:e.id,value:Array.isArray(n)?n:[]}:{fieldId:e.id,value:typeof n==`string`?n:``}})}function b(t,a){let c={};for(let u of t){if(!u.required)continue;let t=`${u.label} is required.`,d=a[u.id],f=u.type===`checkboxes`||u.type===`multi_select`?o(i(e(s()),n(1,t)),d??[]):o(i(s(),l(),r(t)),typeof d==`string`?d:``);f.success||(c[u.id]=f.issues[0]?.message??t)}return c}function x({choiceClassName:e,errorClassName:t,errors:n,fields:r,idPrefix:i,onChange:a,values:o}){return r.map(r=>u(S,{choiceClassName:e,error:n[r.id],errorClassName:t,field:r,idPrefix:i,onChange:e=>a({...o,[r.id]:e}),value:o[r.id]},r.id))}function S(e){let{field:t,idPrefix:n}=e,r=`${n}-custom-${t.id}`,i=`${r}-error`,a={...e,controlId:r,errorId:i};switch(t.type){case`text`:case`textarea`:return u(w,{...a,field:t});case`select`:case`multi_select`:return u(T,{...a,field:t});case`radio`:case`checkboxes`:return u(E,{...a,field:t});default:return null}}function C({className:e,error:t,id:n}){return t?u(`span`,{className:e,id:n,role:`alert`,children:t}):null}function w({controlId:e,error:t,errorClassName:n,errorId:r,field:i,onChange:a,value:o}){let s={"aria-describedby":t?r:void 0,"aria-invalid":t?`true`:void 0,id:e,name:`custom:${i.id}`,onChange:e=>a(e.currentTarget.value),required:i.required,value:typeof o==`string`?o:``};return d(`label`,{htmlFor:e,children:[u(`span`,{children:i.label}),i.type===`textarea`?u(`textarea`,{...s}):u(`input`,{...s}),u(C,{className:n,error:t,id:r})]})}function T({controlId:e,error:t,errorClassName:n,errorId:r,field:i,onChange:a,value:o}){return d(`label`,{htmlFor:e,children:[u(`span`,{children:i.label}),d(`select`,{"aria-describedby":t?r:void 0,"aria-invalid":t?`true`:void 0,id:e,multiple:i.type===`multi_select`,name:`custom:${i.id}`,onChange:e=>a(i.type===`multi_select`?[...e.currentTarget.selectedOptions].map(e=>e.value):e.currentTarget.value),required:i.required,value:o??(i.type===`multi_select`?[]:``),children:[i.type===`select`?u(`option`,{value:``,children:`Select…`}):null,i.options.map(e=>u(`option`,{value:e.id,children:e.label},e.id))]}),u(C,{className:n,error:t,id:r})]})}function E({choiceClassName:e,controlId:t,error:n,errorClassName:r,errorId:i,field:a,onChange:o,value:s}){let c=Array.isArray(s)?s:[];return d(`fieldset`,{"aria-describedby":n?i:void 0,"aria-invalid":n?`true`:void 0,children:[u(`legend`,{children:a.label}),a.options.map((n,r)=>d(`label`,{className:e,children:[u(`input`,{checked:Array.isArray(s)?s.includes(n.id):s===n.id,id:`${t}-${r}`,name:`custom:${a.id}`,onChange:e=>{if(a.type===`radio`){o(n.id);return}o(e.currentTarget.checked?[...c,n.id]:c.filter(e=>e!==n.id))},required:a.required&&a.type===`radio`,type:a.type===`radio`?`radio`:`checkbox`,value:n.id}),u(`span`,{children:n.label})]},n.id)),u(C,{className:r,error:n,id:i})]})}const
|
|
1
|
+
import{array as e,email as t,minLength as n,nonEmpty as r,pipe as i,regex as a,safeParse as o,string as s,transform as c,trim as l}from"valibot";import{jsx as u,jsxs as d}from"react/jsx-runtime";const f=/^#([\da-f]{3}|[\da-f]{6})$/i,p=/^([\da-f]{3}|[\da-f]{6})$/i;function m(e){let t=e.trim();return p.test(t)?`#${t}`:t}function h(e){let t=f.exec(m(e));if(!t)return;let[,n]=t;if(!n)return;let r=n.length===3?Array.from(n,e=>`${e}${e}`).join(``):n;return[0,2,4].map(e=>Number.parseInt(r.slice(e,e+2),16))}function g([e,t,n]){let[r=0,i=0,a=0]=[e,t,n].map((e=0)=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function _(e){let t=h(e);if(!t)return;let n=g(t);return(n+.05)/.05>=1.05/(n+.05)?`#000`:`#fff`}function v(e){return Object.fromEntries(e.map(e=>[e.id,e.type===`checkboxes`||e.type===`multi_select`?[]:``]))}function y(e,t){return e.map(e=>{let n=t[e.id];return e.type===`checkboxes`||e.type===`multi_select`?{fieldId:e.id,value:Array.isArray(n)?n:[]}:{fieldId:e.id,value:typeof n==`string`?n:``}})}function b(t,a){let c={};for(let u of t){if(!u.required)continue;let t=`${u.label} is required.`,d=a[u.id],f=u.type===`checkboxes`||u.type===`multi_select`?o(i(e(s()),n(1,t)),d??[]):o(i(s(),l(),r(t)),typeof d==`string`?d:``);f.success||(c[u.id]=f.issues[0]?.message??t)}return c}function x({choiceClassName:e,errorClassName:t,errors:n,fields:r,idPrefix:i,onChange:a,values:o}){return r.map(r=>u(S,{choiceClassName:e,error:n[r.id],errorClassName:t,field:r,idPrefix:i,onChange:e=>a({...o,[r.id]:e}),value:o[r.id]},r.id))}function S(e){let{field:t,idPrefix:n}=e,r=`${n}-custom-${t.id}`,i=`${r}-error`,a={...e,controlId:r,errorId:i};switch(t.type){case`text`:case`textarea`:return u(w,{...a,field:t});case`select`:case`multi_select`:return u(T,{...a,field:t});case`radio`:case`checkboxes`:return u(E,{...a,field:t});default:return null}}function C({className:e,error:t,id:n}){return t?u(`span`,{className:e,id:n,role:`alert`,children:t}):null}function w({controlId:e,error:t,errorClassName:n,errorId:r,field:i,onChange:a,value:o}){let s={"aria-describedby":t?r:void 0,"aria-invalid":t?`true`:void 0,id:e,name:`custom:${i.id}`,onChange:e=>a(e.currentTarget.value),required:i.required,value:typeof o==`string`?o:``};return d(`label`,{htmlFor:e,children:[u(`span`,{children:i.label}),i.type===`textarea`?u(`textarea`,{...s}):u(`input`,{...s}),u(C,{className:n,error:t,id:r})]})}function T({controlId:e,error:t,errorClassName:n,errorId:r,field:i,onChange:a,value:o}){return d(`label`,{htmlFor:e,children:[u(`span`,{children:i.label}),d(`select`,{"aria-describedby":t?r:void 0,"aria-invalid":t?`true`:void 0,id:e,multiple:i.type===`multi_select`,name:`custom:${i.id}`,onChange:e=>a(i.type===`multi_select`?[...e.currentTarget.selectedOptions].map(e=>e.value):e.currentTarget.value),required:i.required,value:o??(i.type===`multi_select`?[]:``),children:[i.type===`select`?u(`option`,{value:``,children:`Select…`}):null,i.options.map(e=>u(`option`,{value:e.id,children:e.label},e.id))]}),u(C,{className:n,error:t,id:r})]})}function E({choiceClassName:e,controlId:t,error:n,errorClassName:r,errorId:i,field:a,onChange:o,value:s}){let c=Array.isArray(s)?s:[];return d(`fieldset`,{"aria-describedby":n?i:void 0,"aria-invalid":n?`true`:void 0,children:[u(`legend`,{children:a.label}),a.options.map((n,r)=>d(`label`,{className:e,children:[u(`input`,{checked:Array.isArray(s)?s.includes(n.id):s===n.id,id:`${t}-${r}`,name:`custom:${a.id}`,onChange:e=>{if(a.type===`radio`){o(n.id);return}o(e.currentTarget.checked?[...c,n.id]:c.filter(e=>e!==n.id))},required:a.required&&a.type===`radio`,type:a.type===`radio`?`radio`:`checkbox`,value:n.id}),u(`span`,{children:n.label})]},n.id)),u(C,{className:r,error:n,id:i})]})}function D({fieldCount:e,label:t,sectionCount:n=0,showCheckbox:r=!1}){return d(`div`,{className:`lockerverse-form-skeleton__loading`,children:[u(`span`,{className:`lockerverse-form-skeleton__sr-only`,role:`status`,children:t}),d(`div`,{"aria-hidden":`true`,className:`lockerverse-form-skeleton`,children:[d(`div`,{className:`lockerverse-form-skeleton__branding`,children:[u(`span`,{className:`lockerverse-form-skeleton__avatar`}),u(`span`,{className:`lockerverse-form-skeleton__community`})]}),u(`div`,{className:`lockerverse-form-skeleton__fields`,children:Array.from({length:e},(e,t)=>d(`div`,{className:`lockerverse-form-skeleton__field`,children:[u(`span`,{className:`lockerverse-form-skeleton__label`}),u(`span`,{className:`lockerverse-form-skeleton__input`})]},t))}),Array.from({length:n},(e,t)=>d(`div`,{className:`lockerverse-form-skeleton__section`,children:[u(`span`,{className:`lockerverse-form-skeleton__section-label`}),d(`div`,{className:`lockerverse-form-skeleton__section-content`,children:[u(`span`,{className:`lockerverse-form-skeleton__section-full`}),d(`div`,{className:`lockerverse-form-skeleton__section-grid`,children:[u(`span`,{className:`lockerverse-form-skeleton__section-half`}),u(`span`,{className:`lockerverse-form-skeleton__section-half`})]})]})]},t)),d(`div`,{className:`lockerverse-form-skeleton__actions`,children:[r?u(`span`,{className:`lockerverse-form-skeleton__check-line`}):null,u(`span`,{className:`lockerverse-form-skeleton__button`})]})]})]})}const O=`Enter a valid email address.`,k=`Enter a valid phone number.`,A=/^(?:$|[^\s@]+@[^\s@]+\.[^\s@]+)$/,j=/^\+[1-9]\d{6,14}$/,M=/^(?:$|\+[1-9]\d{6,14})$/;function N(e){return e.trim().replace(/[().\s-]/g,``)}const P=i(s(),l(),a(A,O)),F=i(s(),l(),r(`Email is required.`),t(O)),I=i(s(),l(),c(N),a(M,k)),L=i(s(),l(),r(`Phone is required.`),c(N),a(j,k));export{L as a,y as c,_ as d,m as f,F as i,v as l,P as n,D as o,I as r,x as s,N as t,b as u};
|
|
2
2
|
//# sourceMappingURL=contact-validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact-validation.js","names":[],"sources":["../src/accent-contrast.ts","../src/custom-fields.tsx","../src/contact-validation.ts"],"sourcesContent":["const HEX_COLOR = /^#([\\da-f]{3}|[\\da-f]{6})$/i;\nconst UNPREFIXED_HEX_COLOR = /^([\\da-f]{3}|[\\da-f]{6})$/i;\n\nexport function normalizeAccentColor(color: string) {\n const trimmedColor = color.trim();\n return UNPREFIXED_HEX_COLOR.test(trimmedColor)\n ? `#${trimmedColor}`\n : trimmedColor;\n}\n\nfunction parseHexColor(color: string) {\n const match = HEX_COLOR.exec(normalizeAccentColor(color));\n if (!match) {\n return;\n }\n const [, value] = match;\n if (!value) {\n return;\n }\n const expanded =\n value.length === 3\n ? Array.from(value, (character) => `${character}${character}`).join(\"\")\n : value;\n return [0, 2, 4].map((offset) =>\n Number.parseInt(expanded.slice(offset, offset + 2), 16)\n );\n}\n\nfunction relativeLuminance([red, green, blue]: number[]) {\n const [linearRed = 0, linearGreen = 0, linearBlue = 0] = [\n red,\n green,\n blue,\n ].map((channel = 0) => {\n const normalized = channel / 255;\n return normalized <= 0.040_45\n ? normalized / 12.92\n : ((normalized + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * linearRed + 0.7152 * linearGreen + 0.0722 * linearBlue;\n}\n\nexport function getAccentContrast(color: string) {\n const parsed = parseHexColor(color);\n if (!parsed) {\n return;\n }\n const luminance = relativeLuminance(parsed);\n const blackContrast = (luminance + 0.05) / 0.05;\n const whiteContrast = 1.05 / (luminance + 0.05);\n return blackContrast >= whiteContrast ? \"#000\" : \"#fff\";\n}\n","import type {\n LockerverseCustomField,\n LockerverseCustomFieldAnswer,\n LockerverseMultiOptionCustomField,\n LockerverseSingleOptionCustomField,\n} from \"@lockerverse/sdk/checkout\";\nimport {\n array,\n minLength,\n nonEmpty,\n pipe,\n safeParse,\n string,\n trim,\n} from \"valibot\";\n\nexport type CustomFieldValues = Record<string, string | string[]>;\n\nexport function createCustomFieldValues(fields: LockerverseCustomField[]) {\n return Object.fromEntries(\n fields.map((field) => [\n field.id,\n field.type === \"checkboxes\" || field.type === \"multi_select\" ? [] : \"\",\n ])\n ) as CustomFieldValues;\n}\n\nexport function buildCustomFieldAnswers(\n fields: LockerverseCustomField[],\n values: CustomFieldValues\n): LockerverseCustomFieldAnswer[] {\n return fields.map((field): LockerverseCustomFieldAnswer => {\n const value = values[field.id];\n return field.type === \"checkboxes\" || field.type === \"multi_select\"\n ? { fieldId: field.id, value: Array.isArray(value) ? value : [] }\n : {\n fieldId: field.id,\n value: typeof value === \"string\" ? value : \"\",\n };\n });\n}\n\nexport function validateCustomFields(\n fields: LockerverseCustomField[],\n values: CustomFieldValues\n) {\n const errors: Record<string, string> = {};\n for (const field of fields) {\n if (!field.required) {\n continue;\n }\n const message = `${field.label} is required.`;\n const value = values[field.id];\n const result =\n field.type === \"checkboxes\" || field.type === \"multi_select\"\n ? safeParse(pipe(array(string()), minLength(1, message)), value ?? [])\n : safeParse(\n pipe(string(), trim(), nonEmpty(message)),\n typeof value === \"string\" ? value : \"\"\n );\n if (!result.success) {\n errors[field.id] = result.issues[0]?.message ?? message;\n }\n }\n return errors;\n}\n\nexport function CustomFields({\n choiceClassName,\n errorClassName,\n errors,\n fields,\n idPrefix,\n onChange,\n values,\n}: {\n choiceClassName: string;\n errorClassName: string;\n errors: Record<string, string>;\n fields: LockerverseCustomField[];\n idPrefix: string;\n onChange: (values: CustomFieldValues) => void;\n values: CustomFieldValues;\n}) {\n return fields.map((field) => (\n <CustomField\n choiceClassName={choiceClassName}\n error={errors[field.id]}\n errorClassName={errorClassName}\n field={field}\n idPrefix={idPrefix}\n key={field.id}\n onChange={(value) => onChange({ ...values, [field.id]: value })}\n value={values[field.id]}\n />\n ));\n}\n\ntype CustomFieldProps = {\n choiceClassName: string;\n error: string | undefined;\n errorClassName: string;\n field: LockerverseCustomField;\n idPrefix: string;\n onChange: (value: string | string[]) => void;\n value: string | string[] | undefined;\n};\n\nfunction CustomField(props: CustomFieldProps) {\n const { field, idPrefix } = props;\n const controlId = `${idPrefix}-custom-${field.id}`;\n const errorId = `${controlId}-error`;\n const controlProps = { ...props, controlId, errorId };\n switch (field.type) {\n case \"text\":\n case \"textarea\":\n return <TextCustomField {...controlProps} field={field} />;\n case \"select\":\n case \"multi_select\":\n return <SelectCustomField {...controlProps} field={field} />;\n case \"radio\":\n case \"checkboxes\":\n return <ChoiceCustomField {...controlProps} field={field} />;\n default:\n return null;\n }\n}\n\ntype ControlProps = CustomFieldProps & {\n controlId: string;\n errorId: string;\n};\n\nfunction FieldError({\n className,\n error,\n id,\n}: {\n className: string;\n error: string | undefined;\n id: string;\n}) {\n return error ? (\n <span className={className} id={id} role=\"alert\">\n {error}\n </span>\n ) : null;\n}\n\nfunction TextCustomField({\n controlId,\n error,\n errorClassName,\n errorId,\n field,\n onChange,\n value,\n}: ControlProps & {\n field: Extract<LockerverseCustomField, { type: \"text\" | \"textarea\" }>;\n}) {\n const commonProps = {\n \"aria-describedby\": error ? errorId : undefined,\n \"aria-invalid\": error ? (\"true\" as const) : undefined,\n id: controlId,\n name: `custom:${field.id}`,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>\n ) => onChange(event.currentTarget.value),\n required: field.required,\n value: typeof value === \"string\" ? value : \"\",\n };\n return (\n <label htmlFor={controlId}>\n <span>{field.label}</span>\n {field.type === \"textarea\" ? (\n <textarea {...commonProps} />\n ) : (\n <input {...commonProps} />\n )}\n <FieldError className={errorClassName} error={error} id={errorId} />\n </label>\n );\n}\n\nfunction SelectCustomField({\n controlId,\n error,\n errorClassName,\n errorId,\n field,\n onChange,\n value,\n}: ControlProps & {\n field: LockerverseMultiOptionCustomField | LockerverseSingleOptionCustomField;\n}) {\n return (\n <label htmlFor={controlId}>\n <span>{field.label}</span>\n <select\n aria-describedby={error ? errorId : undefined}\n aria-invalid={error ? \"true\" : undefined}\n id={controlId}\n multiple={field.type === \"multi_select\"}\n name={`custom:${field.id}`}\n onChange={(event) =>\n onChange(\n field.type === \"multi_select\"\n ? [...event.currentTarget.selectedOptions].map(\n (option) => option.value\n )\n : event.currentTarget.value\n )\n }\n required={field.required}\n value={value ?? (field.type === \"multi_select\" ? [] : \"\")}\n >\n {field.type === \"select\" ? <option value=\"\">Select…</option> : null}\n {field.options.map((option) => (\n <option key={option.id} value={option.id}>\n {option.label}\n </option>\n ))}\n </select>\n <FieldError className={errorClassName} error={error} id={errorId} />\n </label>\n );\n}\n\nfunction ChoiceCustomField({\n choiceClassName,\n controlId,\n error,\n errorClassName,\n errorId,\n field,\n onChange,\n value,\n}: ControlProps & {\n field: LockerverseMultiOptionCustomField | LockerverseSingleOptionCustomField;\n}) {\n const selectedValues = Array.isArray(value) ? value : [];\n return (\n <fieldset\n aria-describedby={error ? errorId : undefined}\n aria-invalid={error ? \"true\" : undefined}\n >\n <legend>{field.label}</legend>\n {field.options.map((option, index) => (\n <label className={choiceClassName} key={option.id}>\n <input\n checked={\n Array.isArray(value)\n ? value.includes(option.id)\n : value === option.id\n }\n id={`${controlId}-${index}`}\n name={`custom:${field.id}`}\n onChange={(event) => {\n if (field.type === \"radio\") {\n onChange(option.id);\n return;\n }\n onChange(\n event.currentTarget.checked\n ? [...selectedValues, option.id]\n : selectedValues.filter((id) => id !== option.id)\n );\n }}\n required={field.required && field.type === \"radio\"}\n type={field.type === \"radio\" ? \"radio\" : \"checkbox\"}\n value={option.id}\n />\n <span>{option.label}</span>\n </label>\n ))}\n <FieldError className={errorClassName} error={error} id={errorId} />\n </fieldset>\n );\n}\n","import { email, nonEmpty, pipe, regex, string, transform, trim } from \"valibot\";\n\nexport const EMAIL_REQUIRED_MESSAGE = \"Email is required.\";\nexport const EMAIL_INVALID_MESSAGE = \"Enter a valid email address.\";\nexport const PHONE_REQUIRED_MESSAGE = \"Phone is required.\";\nexport const PHONE_INVALID_MESSAGE = \"Enter a valid phone number.\";\n\nconst OPTIONAL_EMAIL_PATTERN = /^(?:$|[^\\s@]+@[^\\s@]+\\.[^\\s@]+)$/;\nconst INTERNATIONAL_PHONE_PATTERN = /^\\+[1-9]\\d{6,14}$/;\nconst OPTIONAL_INTERNATIONAL_PHONE_PATTERN = /^(?:$|\\+[1-9]\\d{6,14})$/;\n\nexport function normalizePhone(input: string) {\n return input.trim().replace(/[().\\s-]/g, \"\");\n}\n\nexport const optionalEmailSchema = pipe(\n string(),\n trim(),\n regex(OPTIONAL_EMAIL_PATTERN, EMAIL_INVALID_MESSAGE)\n);\n\nexport const requiredEmailSchema = pipe(\n string(),\n trim(),\n nonEmpty(EMAIL_REQUIRED_MESSAGE),\n email(EMAIL_INVALID_MESSAGE)\n);\n\nexport const optionalPhoneSchema = pipe(\n string(),\n trim(),\n transform(normalizePhone),\n regex(OPTIONAL_INTERNATIONAL_PHONE_PATTERN, PHONE_INVALID_MESSAGE)\n);\n\nexport const requiredPhoneSchema = pipe(\n string(),\n trim(),\n nonEmpty(PHONE_REQUIRED_MESSAGE),\n transform(normalizePhone),\n regex(INTERNATIONAL_PHONE_PATTERN, PHONE_INVALID_MESSAGE)\n);\n"],"mappings":"mMAAA,MAAM,EAAY,8BACZ,EAAuB,6BAE7B,SAAgB,EAAqB,EAAe,CAClD,IAAM,EAAe,EAAM,KAAK,EAChC,OAAO,EAAqB,KAAK,CAAY,EACzC,IAAI,IACJ,CACN,CAEA,SAAS,EAAc,EAAe,CACpC,IAAM,EAAQ,EAAU,KAAK,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EAAyB,mCACzB,EAA8B,oBAC9B,EAAuC,0BAE7C,SAAgB,EAAe,EAAe,CAC5C,OAAO,EAAM,KAAK,CAAC,CAAC,QAAQ,YAAa,EAAE,CAC7C,CAEA,MAAa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAM,EAAwB,CAAqB,CACrD,EAEa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAS,oBAAsB,EAC/B,EAAM,CAAqB,CAC7B,EAEa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAU,CAAc,EACxB,EAAM,EAAsC,CAAqB,CACnE,EAEa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAS,oBAAsB,EAC/B,EAAU,CAAc,EACxB,EAAM,EAA6B,CAAqB,CAC1D"}
|
|
1
|
+
{"version":3,"file":"contact-validation.js","names":[],"sources":["../src/accent-contrast.ts","../src/custom-fields.tsx","../src/form-skeleton.tsx","../src/contact-validation.ts"],"sourcesContent":["const HEX_COLOR = /^#([\\da-f]{3}|[\\da-f]{6})$/i;\nconst UNPREFIXED_HEX_COLOR = /^([\\da-f]{3}|[\\da-f]{6})$/i;\n\nexport function normalizeAccentColor(color: string) {\n const trimmedColor = color.trim();\n return UNPREFIXED_HEX_COLOR.test(trimmedColor)\n ? `#${trimmedColor}`\n : trimmedColor;\n}\n\nfunction parseHexColor(color: string) {\n const match = HEX_COLOR.exec(normalizeAccentColor(color));\n if (!match) {\n return;\n }\n const [, value] = match;\n if (!value) {\n return;\n }\n const expanded =\n value.length === 3\n ? Array.from(value, (character) => `${character}${character}`).join(\"\")\n : value;\n return [0, 2, 4].map((offset) =>\n Number.parseInt(expanded.slice(offset, offset + 2), 16)\n );\n}\n\nfunction relativeLuminance([red, green, blue]: number[]) {\n const [linearRed = 0, linearGreen = 0, linearBlue = 0] = [\n red,\n green,\n blue,\n ].map((channel = 0) => {\n const normalized = channel / 255;\n return normalized <= 0.040_45\n ? normalized / 12.92\n : ((normalized + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * linearRed + 0.7152 * linearGreen + 0.0722 * linearBlue;\n}\n\nexport function getAccentContrast(color: string) {\n const parsed = parseHexColor(color);\n if (!parsed) {\n return;\n }\n const luminance = relativeLuminance(parsed);\n const blackContrast = (luminance + 0.05) / 0.05;\n const whiteContrast = 1.05 / (luminance + 0.05);\n return blackContrast >= whiteContrast ? \"#000\" : \"#fff\";\n}\n","import type {\n LockerverseCustomField,\n LockerverseCustomFieldAnswer,\n LockerverseMultiOptionCustomField,\n LockerverseSingleOptionCustomField,\n} from \"@lockerverse/sdk/checkout\";\nimport {\n array,\n minLength,\n nonEmpty,\n pipe,\n safeParse,\n string,\n trim,\n} from \"valibot\";\n\nexport type CustomFieldValues = Record<string, string | string[]>;\n\nexport function createCustomFieldValues(fields: LockerverseCustomField[]) {\n return Object.fromEntries(\n fields.map((field) => [\n field.id,\n field.type === \"checkboxes\" || field.type === \"multi_select\" ? [] : \"\",\n ])\n ) as CustomFieldValues;\n}\n\nexport function buildCustomFieldAnswers(\n fields: LockerverseCustomField[],\n values: CustomFieldValues\n): LockerverseCustomFieldAnswer[] {\n return fields.map((field): LockerverseCustomFieldAnswer => {\n const value = values[field.id];\n return field.type === \"checkboxes\" || field.type === \"multi_select\"\n ? { fieldId: field.id, value: Array.isArray(value) ? value : [] }\n : {\n fieldId: field.id,\n value: typeof value === \"string\" ? value : \"\",\n };\n });\n}\n\nexport function validateCustomFields(\n fields: LockerverseCustomField[],\n values: CustomFieldValues\n) {\n const errors: Record<string, string> = {};\n for (const field of fields) {\n if (!field.required) {\n continue;\n }\n const message = `${field.label} is required.`;\n const value = values[field.id];\n const result =\n field.type === \"checkboxes\" || field.type === \"multi_select\"\n ? safeParse(pipe(array(string()), minLength(1, message)), value ?? [])\n : safeParse(\n pipe(string(), trim(), nonEmpty(message)),\n typeof value === \"string\" ? value : \"\"\n );\n if (!result.success) {\n errors[field.id] = result.issues[0]?.message ?? message;\n }\n }\n return errors;\n}\n\nexport function CustomFields({\n choiceClassName,\n errorClassName,\n errors,\n fields,\n idPrefix,\n onChange,\n values,\n}: {\n choiceClassName: string;\n errorClassName: string;\n errors: Record<string, string>;\n fields: LockerverseCustomField[];\n idPrefix: string;\n onChange: (values: CustomFieldValues) => void;\n values: CustomFieldValues;\n}) {\n return fields.map((field) => (\n <CustomField\n choiceClassName={choiceClassName}\n error={errors[field.id]}\n errorClassName={errorClassName}\n field={field}\n idPrefix={idPrefix}\n key={field.id}\n onChange={(value) => onChange({ ...values, [field.id]: value })}\n value={values[field.id]}\n />\n ));\n}\n\ntype CustomFieldProps = {\n choiceClassName: string;\n error: string | undefined;\n errorClassName: string;\n field: LockerverseCustomField;\n idPrefix: string;\n onChange: (value: string | string[]) => void;\n value: string | string[] | undefined;\n};\n\nfunction CustomField(props: CustomFieldProps) {\n const { field, idPrefix } = props;\n const controlId = `${idPrefix}-custom-${field.id}`;\n const errorId = `${controlId}-error`;\n const controlProps = { ...props, controlId, errorId };\n switch (field.type) {\n case \"text\":\n case \"textarea\":\n return <TextCustomField {...controlProps} field={field} />;\n case \"select\":\n case \"multi_select\":\n return <SelectCustomField {...controlProps} field={field} />;\n case \"radio\":\n case \"checkboxes\":\n return <ChoiceCustomField {...controlProps} field={field} />;\n default:\n return null;\n }\n}\n\ntype ControlProps = CustomFieldProps & {\n controlId: string;\n errorId: string;\n};\n\nfunction FieldError({\n className,\n error,\n id,\n}: {\n className: string;\n error: string | undefined;\n id: string;\n}) {\n return error ? (\n <span className={className} id={id} role=\"alert\">\n {error}\n </span>\n ) : null;\n}\n\nfunction TextCustomField({\n controlId,\n error,\n errorClassName,\n errorId,\n field,\n onChange,\n value,\n}: ControlProps & {\n field: Extract<LockerverseCustomField, { type: \"text\" | \"textarea\" }>;\n}) {\n const commonProps = {\n \"aria-describedby\": error ? errorId : undefined,\n \"aria-invalid\": error ? (\"true\" as const) : undefined,\n id: controlId,\n name: `custom:${field.id}`,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>\n ) => onChange(event.currentTarget.value),\n required: field.required,\n value: typeof value === \"string\" ? value : \"\",\n };\n return (\n <label htmlFor={controlId}>\n <span>{field.label}</span>\n {field.type === \"textarea\" ? (\n <textarea {...commonProps} />\n ) : (\n <input {...commonProps} />\n )}\n <FieldError className={errorClassName} error={error} id={errorId} />\n </label>\n );\n}\n\nfunction SelectCustomField({\n controlId,\n error,\n errorClassName,\n errorId,\n field,\n onChange,\n value,\n}: ControlProps & {\n field: LockerverseMultiOptionCustomField | LockerverseSingleOptionCustomField;\n}) {\n return (\n <label htmlFor={controlId}>\n <span>{field.label}</span>\n <select\n aria-describedby={error ? errorId : undefined}\n aria-invalid={error ? \"true\" : undefined}\n id={controlId}\n multiple={field.type === \"multi_select\"}\n name={`custom:${field.id}`}\n onChange={(event) =>\n onChange(\n field.type === \"multi_select\"\n ? [...event.currentTarget.selectedOptions].map(\n (option) => option.value\n )\n : event.currentTarget.value\n )\n }\n required={field.required}\n value={value ?? (field.type === \"multi_select\" ? [] : \"\")}\n >\n {field.type === \"select\" ? <option value=\"\">Select…</option> : null}\n {field.options.map((option) => (\n <option key={option.id} value={option.id}>\n {option.label}\n </option>\n ))}\n </select>\n <FieldError className={errorClassName} error={error} id={errorId} />\n </label>\n );\n}\n\nfunction ChoiceCustomField({\n choiceClassName,\n controlId,\n error,\n errorClassName,\n errorId,\n field,\n onChange,\n value,\n}: ControlProps & {\n field: LockerverseMultiOptionCustomField | LockerverseSingleOptionCustomField;\n}) {\n const selectedValues = Array.isArray(value) ? value : [];\n return (\n <fieldset\n aria-describedby={error ? errorId : undefined}\n aria-invalid={error ? \"true\" : undefined}\n >\n <legend>{field.label}</legend>\n {field.options.map((option, index) => (\n <label className={choiceClassName} key={option.id}>\n <input\n checked={\n Array.isArray(value)\n ? value.includes(option.id)\n : value === option.id\n }\n id={`${controlId}-${index}`}\n name={`custom:${field.id}`}\n onChange={(event) => {\n if (field.type === \"radio\") {\n onChange(option.id);\n return;\n }\n onChange(\n event.currentTarget.checked\n ? [...selectedValues, option.id]\n : selectedValues.filter((id) => id !== option.id)\n );\n }}\n required={field.required && field.type === \"radio\"}\n type={field.type === \"radio\" ? \"radio\" : \"checkbox\"}\n value={option.id}\n />\n <span>{option.label}</span>\n </label>\n ))}\n <FieldError className={errorClassName} error={error} id={errorId} />\n </fieldset>\n );\n}\n","export function FormSkeleton({\n fieldCount,\n label,\n sectionCount = 0,\n showCheckbox = false,\n}: {\n fieldCount: number;\n label: string;\n sectionCount?: number;\n showCheckbox?: boolean;\n}) {\n return (\n <div className=\"lockerverse-form-skeleton__loading\">\n <span className=\"lockerverse-form-skeleton__sr-only\" role=\"status\">\n {label}\n </span>\n <div aria-hidden=\"true\" className=\"lockerverse-form-skeleton\">\n <div className=\"lockerverse-form-skeleton__branding\">\n <span className=\"lockerverse-form-skeleton__avatar\" />\n <span className=\"lockerverse-form-skeleton__community\" />\n </div>\n <div className=\"lockerverse-form-skeleton__fields\">\n {Array.from({ length: fieldCount }, (_, index) => (\n <div className=\"lockerverse-form-skeleton__field\" key={index}>\n <span className=\"lockerverse-form-skeleton__label\" />\n <span className=\"lockerverse-form-skeleton__input\" />\n </div>\n ))}\n </div>\n {Array.from({ length: sectionCount }, (_, index) => (\n <div className=\"lockerverse-form-skeleton__section\" key={index}>\n <span className=\"lockerverse-form-skeleton__section-label\" />\n <div className=\"lockerverse-form-skeleton__section-content\">\n <span className=\"lockerverse-form-skeleton__section-full\" />\n <div className=\"lockerverse-form-skeleton__section-grid\">\n <span className=\"lockerverse-form-skeleton__section-half\" />\n <span className=\"lockerverse-form-skeleton__section-half\" />\n </div>\n </div>\n </div>\n ))}\n <div className=\"lockerverse-form-skeleton__actions\">\n {showCheckbox ? (\n <span className=\"lockerverse-form-skeleton__check-line\" />\n ) : null}\n <span className=\"lockerverse-form-skeleton__button\" />\n </div>\n </div>\n </div>\n );\n}\n","import { email, nonEmpty, pipe, regex, string, transform, trim } from \"valibot\";\n\nexport const EMAIL_REQUIRED_MESSAGE = \"Email is required.\";\nexport const EMAIL_INVALID_MESSAGE = \"Enter a valid email address.\";\nexport const PHONE_REQUIRED_MESSAGE = \"Phone is required.\";\nexport const PHONE_INVALID_MESSAGE = \"Enter a valid phone number.\";\n\nconst OPTIONAL_EMAIL_PATTERN = /^(?:$|[^\\s@]+@[^\\s@]+\\.[^\\s@]+)$/;\nconst INTERNATIONAL_PHONE_PATTERN = /^\\+[1-9]\\d{6,14}$/;\nconst OPTIONAL_INTERNATIONAL_PHONE_PATTERN = /^(?:$|\\+[1-9]\\d{6,14})$/;\n\nexport function normalizePhone(input: string) {\n return input.trim().replace(/[().\\s-]/g, \"\");\n}\n\nexport const optionalEmailSchema = pipe(\n string(),\n trim(),\n regex(OPTIONAL_EMAIL_PATTERN, EMAIL_INVALID_MESSAGE)\n);\n\nexport const requiredEmailSchema = pipe(\n string(),\n trim(),\n nonEmpty(EMAIL_REQUIRED_MESSAGE),\n email(EMAIL_INVALID_MESSAGE)\n);\n\nexport const optionalPhoneSchema = pipe(\n string(),\n trim(),\n transform(normalizePhone),\n regex(OPTIONAL_INTERNATIONAL_PHONE_PATTERN, PHONE_INVALID_MESSAGE)\n);\n\nexport const requiredPhoneSchema = pipe(\n string(),\n trim(),\n nonEmpty(PHONE_REQUIRED_MESSAGE),\n transform(normalizePhone),\n regex(INTERNATIONAL_PHONE_PATTERN, PHONE_INVALID_MESSAGE)\n);\n"],"mappings":"mMAAA,MAAM,EAAY,8BACZ,EAAuB,6BAE7B,SAAgB,EAAqB,EAAe,CAClD,IAAM,EAAe,EAAM,KAAK,EAChC,OAAO,EAAqB,KAAK,CAAY,EACzC,IAAI,IACJ,CACN,CAEA,SAAS,EAAc,EAAe,CACpC,IAAM,EAAQ,EAAU,KAAK,EAAqB,CAAK,CAAC,EACxD,GAAI,CAAC,EACH,OAEF,GAAM,EAAG,GAAS,EAClB,GAAI,CAAC,EACH,OAEF,IAAM,EACJ,EAAM,SAAW,EACb,MAAM,KAAK,EAAQ,GAAc,GAAG,IAAY,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AM,EAAwB,CAAqB,CACrD,EAEa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAS,oBAAsB,EAC/B,EAAM,CAAqB,CAC7B,EAEa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAU,CAAc,EACxB,EAAM,EAAsC,CAAqB,CACnE,EAEa,EAAsB,EACjC,EAAO,EACP,EAAK,EACL,EAAS,oBAAsB,EAC/B,EAAU,CAAc,EACxB,EAAM,EAA6B,CAAqB,CAC1D"}
|
package/dist/form-ui.css
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
.lockerverse-payment,
|
|
2
|
+
.lockerverse-signup {
|
|
3
|
+
--lockerverse-form-accent: var(--lockerverse-accent);
|
|
4
|
+
--lockerverse-form-border: var(--lockerverse-border);
|
|
5
|
+
--lockerverse-form-control: var(--lockerverse-control);
|
|
6
|
+
--lockerverse-form-muted: var(--lockerverse-muted);
|
|
7
|
+
--lockerverse-form-placeholder: var(--lockerverse-placeholder);
|
|
8
|
+
--lockerverse-form-radius: var(--lockerverse-radius);
|
|
9
|
+
--lockerverse-form-subtle: var(--lockerverse-subtle);
|
|
10
|
+
--lockerverse-form-text: var(--lockerverse-text);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.lockerverse-signup {
|
|
14
|
+
--lockerverse-form-accent: var(--lockerverse-signup-accent);
|
|
15
|
+
--lockerverse-form-border: var(--lockerverse-signup-border);
|
|
16
|
+
--lockerverse-form-control: var(--lockerverse-signup-control);
|
|
17
|
+
--lockerverse-form-muted: var(--lockerverse-signup-muted);
|
|
18
|
+
--lockerverse-form-placeholder: var(--lockerverse-signup-placeholder);
|
|
19
|
+
--lockerverse-form-radius: var(--lockerverse-signup-radius);
|
|
20
|
+
--lockerverse-form-subtle: var(--lockerverse-signup-subtle);
|
|
21
|
+
--lockerverse-form-text: var(--lockerverse-signup-text);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:is(.lockerverse-payment, .lockerverse-signup)
|
|
25
|
+
label:not(.lockerverse-payment__check-row),
|
|
26
|
+
:is(.lockerverse-payment, .lockerverse-signup) .lockerverse-payment__field,
|
|
27
|
+
:is(.lockerverse-payment, .lockerverse-signup) fieldset {
|
|
28
|
+
display: grid;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:is(.lockerverse-payment, .lockerverse-signup) label > span,
|
|
33
|
+
:is(.lockerverse-payment, .lockerverse-signup)
|
|
34
|
+
.lockerverse-payment__field
|
|
35
|
+
> span,
|
|
36
|
+
:is(.lockerverse-payment, .lockerverse-signup) legend {
|
|
37
|
+
font-size: 14px;
|
|
38
|
+
font-weight: 500;
|
|
39
|
+
line-height: 1.45;
|
|
40
|
+
color: color-mix(in srgb, var(--lockerverse-form-text) 82%, transparent);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:is(.lockerverse-payment, .lockerverse-signup) fieldset {
|
|
44
|
+
min-width: 0;
|
|
45
|
+
padding: 0;
|
|
46
|
+
margin: 0;
|
|
47
|
+
border: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:is(.lockerverse-payment, .lockerverse-signup)
|
|
51
|
+
input:not([type="checkbox"]):not([type="radio"]),
|
|
52
|
+
:is(.lockerverse-payment, .lockerverse-signup) select,
|
|
53
|
+
:is(.lockerverse-payment, .lockerverse-signup) textarea {
|
|
54
|
+
width: 100%;
|
|
55
|
+
min-height: 48px;
|
|
56
|
+
padding: 11px 13px;
|
|
57
|
+
font: inherit;
|
|
58
|
+
font-size: 16px;
|
|
59
|
+
line-height: 1.5;
|
|
60
|
+
color: var(--lockerverse-form-text);
|
|
61
|
+
appearance: none;
|
|
62
|
+
outline: none;
|
|
63
|
+
background-color: var(--lockerverse-form-control);
|
|
64
|
+
border: 1px solid var(--lockerverse-form-border);
|
|
65
|
+
border-radius: var(--lockerverse-form-radius);
|
|
66
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%);
|
|
67
|
+
transition:
|
|
68
|
+
border-color 140ms ease,
|
|
69
|
+
box-shadow 140ms ease;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:is(.lockerverse-payment, .lockerverse-signup) select {
|
|
73
|
+
padding-right: 38px;
|
|
74
|
+
background-image:
|
|
75
|
+
linear-gradient(45deg, transparent 50%, currentcolor 50%),
|
|
76
|
+
linear-gradient(135deg, currentcolor 50%, transparent 50%);
|
|
77
|
+
background-repeat: no-repeat;
|
|
78
|
+
background-position:
|
|
79
|
+
calc(100% - 17px) calc(50% - 2px),
|
|
80
|
+
calc(100% - 12px) calc(50% - 2px);
|
|
81
|
+
background-size:
|
|
82
|
+
5px 5px,
|
|
83
|
+
5px 5px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:is(.lockerverse-payment, .lockerverse-signup) textarea {
|
|
87
|
+
min-height: 112px;
|
|
88
|
+
padding-top: 12px;
|
|
89
|
+
resize: vertical;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:is(.lockerverse-payment, .lockerverse-signup) input::placeholder,
|
|
93
|
+
:is(.lockerverse-payment, .lockerverse-signup) textarea::placeholder {
|
|
94
|
+
color: var(--lockerverse-form-placeholder);
|
|
95
|
+
opacity: 1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:is(.lockerverse-payment, .lockerverse-signup)
|
|
99
|
+
input:not([type="checkbox"]):not([type="radio"]):focus,
|
|
100
|
+
:is(.lockerverse-payment, .lockerverse-signup) select:focus,
|
|
101
|
+
:is(.lockerverse-payment, .lockerverse-signup) textarea:focus,
|
|
102
|
+
:is(.lockerverse-payment, .lockerverse-signup) button:focus {
|
|
103
|
+
outline: none;
|
|
104
|
+
border-color: var(--lockerverse-form-accent);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:is(.lockerverse-payment, .lockerverse-signup)
|
|
108
|
+
input:not([type="checkbox"]):not([type="radio"]):focus,
|
|
109
|
+
:is(.lockerverse-payment, .lockerverse-signup) select:focus,
|
|
110
|
+
:is(.lockerverse-payment, .lockerverse-signup) textarea:focus {
|
|
111
|
+
box-shadow: 0 0 0 1px var(--lockerverse-form-accent);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:is(.lockerverse-payment, .lockerverse-signup)
|
|
115
|
+
input:not([type="checkbox"]):not([type="radio"]):focus-visible,
|
|
116
|
+
:is(.lockerverse-payment, .lockerverse-signup) select:focus-visible,
|
|
117
|
+
:is(.lockerverse-payment, .lockerverse-signup) textarea:focus-visible,
|
|
118
|
+
:is(.lockerverse-payment, .lockerverse-signup) button:focus-visible {
|
|
119
|
+
box-shadow: 0 0 0 2px
|
|
120
|
+
color-mix(in srgb, var(--lockerverse-form-accent) 24%, transparent);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.lockerverse-form-skeleton__sr-only {
|
|
124
|
+
position: absolute;
|
|
125
|
+
width: 1px;
|
|
126
|
+
height: 1px;
|
|
127
|
+
padding: 0;
|
|
128
|
+
margin: -1px;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
white-space: nowrap;
|
|
131
|
+
border: 0;
|
|
132
|
+
clip: rect(0, 0, 0, 0);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.lockerverse-form-skeleton {
|
|
136
|
+
display: grid;
|
|
137
|
+
gap: 16px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.lockerverse-form-skeleton__branding {
|
|
141
|
+
display: flex;
|
|
142
|
+
gap: 14px;
|
|
143
|
+
align-items: center;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.lockerverse-form-skeleton__avatar,
|
|
147
|
+
.lockerverse-form-skeleton__community,
|
|
148
|
+
.lockerverse-form-skeleton__label,
|
|
149
|
+
.lockerverse-form-skeleton__input,
|
|
150
|
+
.lockerverse-form-skeleton__section-label,
|
|
151
|
+
.lockerverse-form-skeleton__section-full,
|
|
152
|
+
.lockerverse-form-skeleton__section-half,
|
|
153
|
+
.lockerverse-form-skeleton__check-line,
|
|
154
|
+
.lockerverse-form-skeleton__button {
|
|
155
|
+
display: block;
|
|
156
|
+
background: color-mix(in srgb, var(--lockerverse-form-text) 8%, transparent);
|
|
157
|
+
animation: lockerverse-form-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.lockerverse-form-skeleton__avatar {
|
|
161
|
+
flex: none;
|
|
162
|
+
width: 48px;
|
|
163
|
+
height: 48px;
|
|
164
|
+
border-radius: var(--lockerverse-form-radius);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.lockerverse-form-skeleton__community {
|
|
168
|
+
width: 176px;
|
|
169
|
+
height: 20px;
|
|
170
|
+
border-radius: 4px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.lockerverse-form-skeleton__fields {
|
|
174
|
+
display: grid;
|
|
175
|
+
gap: 12px;
|
|
176
|
+
padding-top: 14px;
|
|
177
|
+
border-top: 1px solid var(--lockerverse-form-subtle);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.lockerverse-form-skeleton__field {
|
|
181
|
+
display: grid;
|
|
182
|
+
gap: 8px;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.lockerverse-form-skeleton__label {
|
|
186
|
+
width: 48px;
|
|
187
|
+
height: 16px;
|
|
188
|
+
border-radius: 4px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.lockerverse-form-skeleton__input {
|
|
192
|
+
width: 100%;
|
|
193
|
+
height: 48px;
|
|
194
|
+
background: var(--lockerverse-form-control);
|
|
195
|
+
border: 1px solid var(--lockerverse-form-subtle);
|
|
196
|
+
border-radius: var(--lockerverse-form-radius);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.lockerverse-form-skeleton__section {
|
|
200
|
+
padding: 12px;
|
|
201
|
+
background: color-mix(
|
|
202
|
+
in srgb,
|
|
203
|
+
var(--lockerverse-form-text) 2.5%,
|
|
204
|
+
transparent
|
|
205
|
+
);
|
|
206
|
+
border: 1px solid var(--lockerverse-form-subtle);
|
|
207
|
+
border-radius: var(--lockerverse-form-radius);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.lockerverse-form-skeleton__section-label {
|
|
211
|
+
width: 144px;
|
|
212
|
+
height: 16px;
|
|
213
|
+
border-radius: 4px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.lockerverse-form-skeleton__section-content {
|
|
217
|
+
display: grid;
|
|
218
|
+
gap: 8px;
|
|
219
|
+
margin-top: 12px;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.lockerverse-form-skeleton__section-full,
|
|
223
|
+
.lockerverse-form-skeleton__section-half {
|
|
224
|
+
height: 36px;
|
|
225
|
+
border-radius: 6px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.lockerverse-form-skeleton__section-full {
|
|
229
|
+
background: color-mix(in srgb, var(--lockerverse-form-text) 6%, transparent);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.lockerverse-form-skeleton__section-grid {
|
|
233
|
+
display: grid;
|
|
234
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
235
|
+
gap: 8px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.lockerverse-form-skeleton__section-half {
|
|
239
|
+
background: color-mix(
|
|
240
|
+
in srgb,
|
|
241
|
+
var(--lockerverse-form-text) 4.5%,
|
|
242
|
+
transparent
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.lockerverse-form-skeleton__actions {
|
|
247
|
+
display: grid;
|
|
248
|
+
gap: 16px;
|
|
249
|
+
padding: 20px 0 4px;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.lockerverse-form-skeleton__check-line {
|
|
253
|
+
width: min(256px, 70%);
|
|
254
|
+
height: 20px;
|
|
255
|
+
border-radius: 4px;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.lockerverse-form-skeleton__button {
|
|
259
|
+
width: 100%;
|
|
260
|
+
height: 48px;
|
|
261
|
+
background: color-mix(in srgb, var(--lockerverse-form-text) 12%, transparent);
|
|
262
|
+
border-radius: var(--lockerverse-form-radius);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@keyframes lockerverse-form-pulse {
|
|
266
|
+
50% {
|
|
267
|
+
opacity: 0.55;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lockerverse-payment.d.ts","names":[],"sources":["../src/lockerverse-payment.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"lockerverse-payment.d.ts","names":[],"sources":["../src/lockerverse-payment.tsx"],"mappings":";;iBAggCgB,qBACd,YACA,UACA,WACA,eACA,aACA,OACA,UACA,SACA,mBACA,yBACA,oBACA,kBACA,eACA,WACA,WACA,OACA,cACA,OACA,eACG,gBACF,0CAAuB,IAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,i as r,l as i,o as a,s as o,t as s,u as c}from"./contact-validation.js";import{LockerverseSdkError as l,createLockerverseCheckoutClient as u}from"@lockerverse/sdk/checkout";import{createContext as d,useCallback as f,useContext as p,useEffect as m,useId as h,useLayoutEffect as g,useMemo as _,useReducer as v,useRef as y,useState as b}from"react";import{AddressElement as x,Elements as S,PaymentElement as C,useElements as w,useStripe as ee}from"@stripe/react-stripe-js";import{loadStripe as T}from"@stripe/stripe-js";import{array as E,minLength as D,minValue as O,nonEmpty as k,number as A,object as j,pipe as M,regex as N,safeInteger as P,safeParse as F,strictObject as I,string as te,trim as L,union as ne}from"valibot";import{Fragment as R,jsx as z,jsxs as B}from"react/jsx-runtime";import{Select as V}from"@base-ui/react/select";const H=d(void 0);function U({children:e,container:t}){return z(H.Provider,{value:t,children:e})}function W(){return z(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:z(`path`,{d:`m4 6 4 4 4-4`})})}function G(){return z(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:z(`path`,{d:`m3 8 3 3 7-7`})})}function K({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:c,value:l}){let u=p(H),d=[`lockerverse-payment__select`,r].filter(Boolean).join(` `);return z(`div`,{className:d,children:B(V.Root,{id:i,items:c,name:o,onValueChange:e=>{e!==null&&s(e)},value:l,children:[B(V.Trigger,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:`lockerverse-payment__select-trigger`,children:[z(V.Value,{}),z(V.Icon,{"aria-hidden":`true`,className:`lockerverse-payment__select-icon`,children:z(W,{})})]}),z(V.Portal,{container:u,children:z(V.Positioner,{alignItemWithTrigger:!1,className:`lockerverse-payment__select-positioner`,sideOffset:6,children:z(V.Popup,{className:`lockerverse-payment__select-popup`,children:z(V.List,{className:`lockerverse-payment__select-list`,children:c.map(e=>B(V.Item,{className:`lockerverse-payment__select-item`,value:e.value,children:[z(V.ItemText,{children:e.label}),z(V.ItemIndicator,{"aria-hidden":`true`,className:`lockerverse-payment__select-item-indicator`,children:z(G,{})})]},e.value))})})})})]})})}const q=[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`],J=[`15`,`12`,`10`,`5`],Y=[...J,`custom`];function re({enabled:e,error:t,errorId:n,onChange:r,values:i}){if(!e)return null;let a=e=>r({...i,...e}),o=(e,t)=>{let n=Y.indexOf(t),r;switch(e.key){case`ArrowDown`:case`ArrowRight`:r=(n+1)%Y.length;break;case`ArrowLeft`:case`ArrowUp`:r=(n-1+Y.length)%Y.length;break;case`Home`:r=0;break;case`End`:r=Y.length-1;break;default:return}e.preventDefault();let i=Y[r];i&&((e.currentTarget.closest(`[role="radiogroup"]`)?.querySelectorAll(`input[type="radio"]`))?.[r]?.focus(),a({tipPercent:i}))};return B(`div`,{className:`lockerverse-payment__tip-box`,children:[z(`p`,{children:`Add a tip to support the Lockerverse platform`}),B(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:[J.map(e=>B(`label`,{className:`lockerverse-payment__tip-choice`,children:[z(`input`,{checked:i.tipPercent===e,name:`tipPercent`,onChange:()=>a({tipPercent:e}),onKeyDown:t=>o(t,e),tabIndex:i.tipPercent===e?0:-1,type:`radio`,value:e}),B(`span`,{children:[e,`%`]})]},e)),B(`label`,{className:`lockerverse-payment__tip-choice`,children:[z(`input`,{checked:i.tipPercent===`custom`,name:`tipPercent`,onChange:()=>a({tipPercent:`custom`}),onKeyDown:e=>o(e,`custom`),tabIndex:i.tipPercent===`custom`?0:-1,type:`radio`,value:`custom`}),z(`span`,{children:`Other`})]})]}),i.tipPercent===`custom`?B(`label`,{children:[z(`span`,{children:`Custom tip`}),B(`span`,{className:`lockerverse-payment__money-input`,children:[z(`span`,{"aria-hidden":`true`,children:`$`}),z(`input`,{"aria-describedby":t?n:void 0,"aria-invalid":t?`true`:void 0,inputMode:`decimal`,name:`tip`,onChange:e=>a({customTip:e.currentTarget.value}),placeholder:`0.00`,value:i.customTip})]}),t?z(`span`,{className:`lockerverse-payment__field-message`,id:n,children:t}):null]}):z(`input`,{name:`tip`,type:`hidden`,value:i.tipPercent})]})}function ie({checked:e,children:t,name:n,onChange:r}){return B(`label`,{className:`lockerverse-payment__check-row`,children:[z(`input`,{checked:e,name:n,onChange:e=>r(e.currentTarget.checked),type:`checkbox`}),z(`span`,{children:t})]})}function ae({customFields:e,errors:t,fields:n,idPrefix:r,isPromoApplying:i,onChange:o,onApplyPromo:s,promoError:c,values:l}){let u=e=>o({...l,...e});return B(`div`,{className:`lockerverse-payment__additional-fields`,children:[n.memberId?B(`label`,{children:[z(`span`,{children:`Member ID`}),z(`input`,{name:`memberId`,onChange:e=>u({memberId:e.currentTarget.value}),placeholder:`Optional`,value:l.memberId})]}):null,n.merchSize?B(`div`,{className:`lockerverse-payment__field`,children:[z(`span`,{id:`${r}-merch-size-label`,children:`Size`}),z(K,{ariaLabelledBy:`${r}-merch-size-label`,name:`merchSize`,onValueChange:e=>u({merchSize:e}),options:q.map(e=>({label:e,value:e})),value:l.merchSize})]}):null,n.promoCode?B(`div`,{className:`lockerverse-payment__field`,children:[z(`span`,{id:`${r}-promo-code-label`,children:`Promo code`}),B(`div`,{className:`lockerverse-payment__promo-control`,children:[z(`input`,{"aria-describedby":c?`${r}-promo-code-error`:void 0,"aria-invalid":c?`true`:void 0,"aria-labelledby":`${r}-promo-code-label`,name:`promoCode`,onChange:e=>u({promoCode:e.currentTarget.value}),placeholder:`Optional`,value:l.promoCode}),z(`button`,{disabled:!l.promoCode.trim()||i,onClick:s,type:`button`,children:i?`Applying…`:`Apply`})]}),c?z(`p`,{className:`lockerverse-payment__field-message`,id:`${r}-promo-code-error`,role:`alert`,children:c}):null]}):null,z(a,{choiceClassName:`lockerverse-payment__check-row`,errorClassName:`lockerverse-payment__field-message`,errors:t,fields:e,idPrefix:r,onChange:e=>u({customFields:e}),values:l.customFields})]})}function oe({amountCents:e,enabled:t,onChange:n,values:r}){return t?B(ie,{checked:r.includeServiceFee,name:`includeServiceFee`,onChange:e=>n({...r,includeServiceFee:e}),children:[`Add `,se(e),` to help cover processing fees`]}):null}function se(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function ce(e){return s(e)}function le(t,n){let i=n?{...t,phone:ce(t.phone)}:t,a=j(n?{email:r,phone:e}:{email:r}),o=F(a,i);if(o.success)return{errors:{},value:o.output};let s={};for(let e of o.issues){let t=e.path?.[0]?.key;(t===`email`||t===`phone`)&&!s[t]&&(s[t]=e.message)}return{errors:s,value:null}}const ue=M(te(),L(),k()),de=M(A(),P(),O(1)),fe=M(E(ne([I({amountCents:de,productSlug:ue}),I({productSlug:ue,quantity:de}),I({productSlug:ue})])),D(1)),pe=M(te(),L(),N(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,`Enter a valid tip amount.`));function me(e){let t=F(pe,e);if(!t.success)return{message:t.issues[0]?.message??`Enter a valid tip amount.`,success:!1};let[n=`0`,r=``]=t.output.split(`.`),i=BigInt(n)*100n+BigInt(r.padEnd(2,`0`));return i>BigInt(2**53-1)?{message:`Enter a valid tip amount.`,success:!1}:{cents:Number(i),success:!0}}function he(e){let t=F(fe,e);return t.success?{success:!0,value:t.output}:{message:`Lockerverse payment configuration is invalid.`,success:!1}}function ge(e,t){switch(t.type){case`loading`:return{configuration:t.configuration,phase:`loading`,revision:e.revision,selectionKey:t.selectionKey};case`ready`:return{catalog:t.catalog,checkoutItems:t.checkoutItems,client:t.client,configuration:t.configuration,phase:`ready`,preparedCheckout:t.preparedCheckout,revision:e.revision+1,selectionKey:t.selectionKey};case`error`:return{configuration:t.configuration,failure:t.failure,phase:`error`,revision:e.revision,selectionKey:t.selectionKey};case`checkout`:return e.phase===`ready`?{...e,preparedCheckout:t.preparedCheckout}:e;case`retry`:return{phase:`idle`,revision:e.revision+1};default:return e}}function _e(e,t){let{apiBaseUrl:n,communitySlug:r,environment:i,fetch:a,requestTimeoutMs:o,sentryDsn:s,widgetSlug:c}=e,l={communitySlug:r,widgetSlug:c,...a?{fetch:a}:{},...t?{onError:t}:{},...o===void 0?{}:{requestTimeoutMs:o},...s===void 0?{}:{sentryDsn:s}};if(n===void 0){if(i===`development`)throw TypeError(`Lockerverse development checkout requires an API base URL.`);return{...l,...i===`production`?{environment:i}:{}}}return{...l,apiBaseUrl:n,...i===void 0?{}:{environment:i}}}function X(e,t,n){return e?.configuration===t&&e.selectionKey===n}function ve({apiBaseUrl:e,communitySlug:t,environment:n,fetch:r,onError:i,paymentState:a,requestTimeoutMs:o,selection:s,sentryDsn:c,widgetSlug:l}){let d=_(()=>({apiBaseUrl:e,communitySlug:t,environment:n,fetch:r,requestTimeoutMs:o,sentryDsn:c,widgetSlug:l}),[e,t,n,r,o,c,l]),f=he(s),p=f.success?JSON.stringify(f.value):`invalid-selection`,h=_(()=>f.success?JSON.parse(p):[],[f.success,p]),[g,b]=v(ge,{phase:`idle`,revision:0}),x=y(void 0),S=y(void 0),C=y(i);return C.current=i,m(()=>{if(!f.success||a===`submitting`||a===`success`||a===`unresolved`||X(S.current,d,p)||X(x.current,d,p))return;let e=!0,t={configuration:d,selectionKey:p};x.current=t,b({configuration:d,selectionKey:p,type:`loading`});async function n(){try{let n=u(_e(d,e=>C.current?.(e))),{catalog:r,checkout:i}=await n.bootstrapCheckout({items:h}),a=[...i.items];e&&(x.current=void 0,S.current=t,b({catalog:r,checkoutItems:a,client:n,configuration:d,preparedCheckout:i,selectionKey:p,type:`ready`}))}catch(n){e&&(x.current=void 0,S.current=t,b({configuration:d,failure:n instanceof Error?n.message:`Lockerverse payment could not load.`,selectionKey:p,type:`error`}))}}return n(),()=>{e=!1,X(x.current,d,p)&&(x.current=void 0)}},[d,f.success,a,p,g.revision,h]),{retryCheckout:()=>{x.current=void 0,S.current=void 0,b({type:`retry`})},selectionError:f.success?void 0:f.message,session:g,updateCheckout:e=>b({preparedCheckout:e,type:`checkout`})}}const ye=[`amountCents`,`discountableSubtotalCents`,`discountCents`,`serviceFeeCents`,`subtotalCents`,`tipCents`,`totalCents`],be=[`discountableSubtotalCents`,`discountCents`,`subtotalCents`];function xe(e,t,n){return(n===t.totalCents?be:ye).some(n=>e[n]!==t[n])||e.payment.connectedAccountId!==t.payment.connectedAccountId||e.payment.currency!==t.payment.currency||JSON.stringify(e.appliedDiscount)!==JSON.stringify(t.appliedDiscount)||JSON.stringify(e.lineItems)!==JSON.stringify(t.lineItems)}function Se(e){return e.checkoutStatus===`success`?{kind:`success`,payment:e}:e.checkoutStatus===`failed`?{kind:`failed`,payment:e}:{kind:`unresolved`,paymentReference:e.paymentReference,reason:e.checkoutStatus===`action_required`?`action_required`:`pending`}}async function Ce(e,t,n){if(t.checkoutStatus!==`action_required`)return Se(t);if(!n)return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`};if(t.clientSecret)try{await n.handleNextAction({clientSecret:t.clientSecret})}catch{}try{return Se(await e.getPaymentStatus(t.paymentReference))}catch{return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`}}}async function we(e,t,n){let r;try{r=await e.submitPayment(t)}catch(n){if(!(n instanceof l&&n.recoveryRecommended))throw n;try{r=await e.getPaymentStatus(t.checkout.paymentReference)}catch{return{kind:`unresolved`,paymentReference:t.checkout.paymentReference,reason:`recovery_failed`}}}return Ce(e,r,n)}async function Te(e,t,n){try{return Ce(e,await e.getPaymentStatus(t),n)}catch{return{kind:`unresolved`,paymentReference:t,reason:`recovery_failed`}}}function Ee(e){throw Error(`Unexpected payment workflow value: ${String(e)}`)}function De(e,t){return t===void 0?{phase:e}:{error:t,phase:e}}function Oe(e){return e?{phase:`recovering`}:{phase:`editing`}}function ke(e){return e.phase===`editing`||e.phase===`invalid`?e.error:e.phase===`refreshing_quote`?e.previousError:void 0}function Ae(e){return e.phase===`succeeded`?`success`:e.phase===`unresolved`?`unresolved`:e.phase===`submitting`||e.phase===`recovering`?`submitting`:e.phase===`invalid`?`invalid`:ke(e)?`error`:`idle`}function je(e){return e.phase===`submitting`}function Me(e,t){if(e.phase===`succeeded`||e.phase===`unresolved`)return e;switch(t.type){case`field_changed`:return e.phase===`invalid`?De(`editing`,e.error):e;case`validation_failed`:return e.phase===`submitting`||e.phase===`recovering`?e:De(`invalid`,ke(e));case`quote_refresh_started`:{if(e.phase===`submitting`||e.phase===`recovering`)return e;let n=ke(e);return{...n===void 0?{}:{previousError:n},phase:`refreshing_quote`,validatePromo:t.validatePromo}}case`quote_refresh_succeeded`:return e.phase===`refreshing_quote`?{phase:`editing`}:e;case`quote_refresh_failed`:return e.phase===`refreshing_quote`?De(`editing`,t.error??e.previousError):e;case`submission_started`:return e.phase===`recovering`?e:{phase:`submitting`};case`quote_changed`:return e.phase===`submitting`?{phase:`editing`}:e;case`retryable_failure`:return De(`editing`,t.error);case`recovery_failed`:return e.phase===`recovering`?De(`editing`,t.error):e;case`succeeded`:return e.phase===`submitting`||e.phase===`recovering`?{message:t.message,phase:`succeeded`}:e;case`unresolved`:return e.phase===`submitting`||e.phase===`recovering`?{message:t.message,paymentReference:t.paymentReference,phase:`unresolved`,reason:t.reason}:e;default:return Ee(t)}}function Ne(e,t){return t.tipPercent===`custom`?t.customTip.trim()?me(t.customTip):{cents:0,success:!0}:{cents:Math.round(e*Number(t.tipPercent)/100),success:!0}}function Pe(e,t,n,r){return{...n?{email:n}:{},...e.widget.fields.serviceFee?{includeServiceFee:t.includeServiceFee}:{},...e.widget.fields.promoCode&&t.promoCode.trim()?{promoCode:t.promoCode.trim()}:{},...e.widget.fields.tipping?{tipCents:r}:{}}}function Fe(e,t){if(!e?.complete)throw Error(`${t} address is required.`);return e.value}function Ie(e,t,n,r){if(e.widget.fields.shipping)return t.shippingMatchesBilling?n:Fe(r.shipping,`Shipping`)}function Le({billingAddress:e,catalog:t,email:n,phone:r,shippingAddress:i}){return{payment_method_data:{billing_details:{address:e.address,email:n,name:e.name,...t.widget.fields.phone?{phone:r}:{}}},...i?{shipping:{address:i.address,name:i.name,phone:t.widget.fields.phone?r:i.phone??null}}:{}}}function Re({catalog:e,confirmationToken:t,email:n,fieldValues:r,metadata:i,phone:a,shippingAddress:s}){return{...t?{confirmationToken:t}:{},customFieldAnswers:o(e.widget.customFields,r.customFields),email:n,...i?{metadata:i}:{},...e.widget.fields.memberId&&r.memberId.trim()?{memberId:r.memberId.trim()}:{},...e.widget.fields.merchSize?{merchSize:r.merchSize}:{},...e.widget.fields.phone?{phone:a}:{},...s?{shipping:{address:{city:s.address.city??``,country:s.address.country,line1:s.address.line1??``,...s.address.line2?{line2:s.address.line2}:{},postal_code:s.address.postal_code??``,state:s.address.state??``},name:s.name}}:{}}}function Z(e,t){try{e?.(t)}catch{}}function Q(e){if(!e())throw Error(`Payment component is no longer active.`)}async function ze({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:s,locallyPreviewedTotalCents:c,metadata:l,onPaymentRecoveryChange:u,phone:d,quote:f,stripe:p}){let m=a.trim().toLowerCase(),h=ce(d),g=Ne(f.subtotalCents,o);if(!g.success)throw Error(g.message);let _=Pe(t,o,m,g.cents),v=await r.calculateTotal({..._,items:n});if(Q(s),v.totalCents>0&&xe(f,v,c))return{kind:`quote_changed`,quote:v};if(v.totalCents===0){let n;t.widget.fields.shipping&&(n=Ie(t,o,Fe(e.billing,`Billing`),e)),Q(s),Z(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let i=await we(r,{checkout:v,submission:Re({catalog:t,email:m,fieldValues:o,metadata:l,phone:h,...n?{shippingAddress:n}:{}})},p);return Q(s),i.kind===`failed`?{kind:`payment_failed`,message:`Order could not be completed. Review the details and try again.`}:i.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:i.paymentReference,reason:i.reason}:{kind:`payment`,payment:i.payment,quote:v}}if(!(i&&p))throw Error(`Payment form is still loading.`);await i.update({amount:v.totalCents}),Q(s);let y=await i.submit();if(Q(s),y.error)throw Error(y.error.message);let b=Fe(e.billing,`Billing`),x=Ie(t,o,b,e),S=await p.createConfirmationToken({elements:i,params:Le({billingAddress:b,catalog:t,email:m,phone:h,shippingAddress:x})});if(Q(s),S.error)throw Error(S.error.message);Z(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let C=await we(r,{checkout:v,submission:Re({catalog:t,confirmationToken:S.confirmationToken.id,email:m,fieldValues:o,metadata:l,phone:h,...x?{shippingAddress:x}:{}})},p);return Q(s),C.kind===`failed`?{kind:`payment_failed`,message:`Payment was declined. Check your payment details and try again.`}:C.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:C.paymentReference,reason:C.reason}:{kind:`payment`,payment:C.payment,quote:v}}function Be(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function Ve(e,t){if(!t)return e instanceof Error?e.message:`The order total could not be updated.`}function He({nextQuote:e,onQuoteChange:t,setDisplayedTotalCents:n,setPromoError:r,updateWorkflow:i,validatePromo:a}){i({type:`quote_refresh_succeeded`}),n(e.totalCents),t(e),a&&r(e.appliedDiscount?.source===`promo_code`?void 0:`This promo code is invalid or cannot be applied.`)}function Ue({error:e,setPromoError:t,updateWorkflow:n,validatePromo:r}){r&&t(`This promo code is invalid or cannot be applied.`);let i=Ve(e,r);n(i===void 0?{type:`quote_refresh_failed`}:{error:i,type:`quote_refresh_failed`})}function We({onPaymentComplete:e,onPaymentRecoveryChange:t,onPaymentUncertain:n,onQuoteChange:r,result:i,setDisplayedTotalCents:a,transitionWorkflow:o}){if(i.kind===`quote_changed`){let e=`The total changed to ${Be(i.quote.totalCents)}. Review it and pay again.`;r(i.quote,e),a(i.quote.totalCents),o({type:`quote_changed`});return}if(i.kind===`payment_failed`){Z(t,null),o({error:i.message,type:`retryable_failure`});return}if(i.kind===`payment_unresolved`){o({message:`Payment is still processing. Do not submit it again.`,paymentReference:i.paymentReference,reason:i.reason,type:`unresolved`});try{n?.({paymentReference:i.paymentReference,reason:i.reason})}catch{}return}r(i.quote),Z(t,null),o({message:i.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`});try{e?.(i.payment)}catch{}}function Ge(e){let{catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,metadata:s,onPaymentComplete:c,onPaymentRecoveryChange:l,onPaymentUncertain:u,onQuoteChange:d,onStateChange:p,quote:h,resumePayment:g,stripe:_}=e,[x,S]=v(Me,g,Oe),[C,w]=b(h.totalCents),[ee,T]=b(),E=y(!1),D=y(0),O=y(0),k=y(x);k.current=x;let A=f((e,t=!1)=>{let n=k.current,r=Me(n,e);r!==n&&(k.current=r,S(e),t&&p(Ae(r)))},[p]),j=f(e=>A(e,!0),[A]),M=f(()=>{let e=O.current+1;return O.current=e,()=>O.current===e},[]);m(()=>()=>{O.current+=1},[]);let N=t.widget.fields.tipping?Ne(h.subtotalCents,o):{cents:0,success:!0},P=N.success?N.cents:null;m(()=>{if(P===null)return;let e=t.widget.fields.serviceFee&&o.includeServiceFee?h.serviceFeeCents||Math.round(h.subtotalCents*t.pricingPolicy.serviceFeeRateBasisPoints/1e4):0,n=h.totalCents-h.serviceFeeCents-h.tipCents+e+P;w(n),n>0&&i?.update({amount:n})},[t.pricingPolicy.serviceFeeRateBasisPoints,t.widget.fields.serviceFee,i,o.includeServiceFee,P,h.serviceFeeCents,h.tipCents,h.totalCents,h.subtotalCents]),m(()=>{if(!(g&&_)||E.current)return;E.current=!0;let e=M();return p(Ae(k.current)),Te(r,g.paymentReference,_).then(t=>{if(e()){if(t.kind===`failed`){Z(l,null),j({error:`The previous payment failed. Check your details and try again.`,type:`recovery_failed`});return}if(t.kind===`unresolved`){j({message:`Payment is still processing. Do not submit it again.`,paymentReference:t.paymentReference,reason:t.reason,type:`unresolved`});try{u?.({paymentReference:t.paymentReference,reason:t.reason})}catch{}return}Z(l,null),j({message:t.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`});try{c?.(t.payment)}catch{}}}),()=>{e()&&(O.current+=1),E.current=!1}},[r,c,l,u,p,g,_,M,j]);let F=f((e=!1)=>{e&&T(void 0),A({type:`field_changed`})},[A]);async function I(e=!1,i=!1){let s=le({email:a.trim().toLowerCase(),phone:``},!1);if(!(N.success&&(s.value||e)))return;D.current+=1;let c=D.current;A({type:`quote_refresh_started`,validatePromo:i});try{let e=await r.calculateTotal({...Pe(t,o,s.value?.email??``,N.cents),items:n});if(c!==D.current)return;He({nextQuote:e,onQuoteChange:d,setDisplayedTotalCents:w,setPromoError:T,updateWorkflow:A,validatePromo:i})}catch(e){if(c!==D.current)return;Ue({error:e,setPromoError:T,updateWorkflow:A,validatePromo:i})}}async function te(){T(void 0),await I(!0,!0)}async function L({addresses:e,phone:f}){j({type:`submission_started`});let p=M();try{let m=await ze({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:p,locallyPreviewedTotalCents:C,metadata:s,onPaymentRecoveryChange:l,phone:f,quote:h,stripe:_});if(!p())return;We({onPaymentComplete:c,onPaymentRecoveryChange:l,onPaymentUncertain:u,onQuoteChange:d,result:m,setDisplayedTotalCents:w,transitionWorkflow:j})}catch(e){if(!p())return;Z(l,null),j({error:e instanceof Error?e.message:`Payment could not be completed.`,type:`retryable_failure`})}}let ne=x.phase===`succeeded`||x.phase===`unresolved`?x.message:void 0;return{commands:{applyPromo:te,fieldChanged:F,refreshAuthoritativeTotal:I,reportStripeLoadError:e=>j({error:e,type:`retryable_failure`}),reportValidationFailure:()=>j({type:`validation_failed`}),submit:L},state:{displayedTotalCents:C,isRecovering:x.phase===`recovering`,isRefreshingQuote:x.phase===`refreshing_quote`,isSubmitting:je(x),parsedTip:N,paymentError:ke(x),promoError:ee,terminalMessage:ne}}}function $(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function Ke(e){return e===`monthly`?{interval:`month`,label:`Monthly`}:e===`annually`?{interval:`year`,label:`Annual`}:null}const qe=[{callingCode:`+1`,label:`🇺🇸 +1`,value:`US`},{callingCode:`+52`,label:`🇲🇽 +52`,value:`MX`},{callingCode:`+380`,label:`🇺🇦 +380`,value:`UA`},{callingCode:`+48`,label:`🇵🇱 +48`,value:`PL`},{callingCode:`+1`,label:`🇨🇦 +1`,value:`CA`},{callingCode:`+49`,label:`🇩🇪 +49`,value:`DE`},{callingCode:`+44`,label:`🇬🇧 +44`,value:`GB`},{callingCode:`+46`,label:`🇸🇪 +46`,value:`SE`},{callingCode:`+358`,label:`🇫🇮 +358`,value:`FI`},{callingCode:`+1`,label:`🇵🇷 +1`,value:`PR`}];function Je(e,t){return e.trim().startsWith(`+`)?e:`${qe.find(e=>e.value===t)?.callingCode??`+1`}${e}`}function Ye({accentColor:e,catalog:t,checkoutItems:n,client:r,fontFamily:i,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,onQuoteChange:l,quote:u,resumePayment:d,onStateChange:f,stripeLoader:p,theme:m,visualStyle:h}){let g=d?d.connectedAccountId:u.payment.connectedAccountId,v=_(()=>p(t.payment.publishableKey,g?{stripeAccount:g}:void 0).catch(()=>null),[t.payment.publishableKey,g,p]);return z(S,{options:{amount:Math.max(u.totalCents,100),appearance:{rules:{".Input:focus":{borderColor:e,boxShadow:`0 0 0 1px ${e}`,outline:`none`}},theme:m===`light`?`stripe`:`night`,variables:{borderRadius:h?.[`--lockerverse-radius`]??`10px`,colorBackground:h?.[`--lockerverse-control`]??(m===`light`?`#f5f6f7`:`#121212`),colorDanger:h?.[`--lockerverse-danger`]??(m===`light`?`#c52b3e`:`#f08a98`),colorPrimary:e,colorText:h?.[`--lockerverse-text`]??(m===`light`?`#121416`:`#ffffff`),colorTextPlaceholder:h?.[`--lockerverse-placeholder`]??(m===`light`?`#72767d`:`#6b6b6b`),colorTextSecondary:h?.[`--lockerverse-muted`]??(m===`light`?`#62666d`:`#a1a1aa`),focusBoxShadow:`none`,focusOutline:`none`,fontFamily:i,fontSizeBase:`16px`}},currency:u.payment.currency,excludedPaymentMethodTypes:[`us_bank_account`],mode:u.paymentOption===`one-time`?`payment`:`subscription`,syncAddressCheckbox:`none`},stripe:v,children:z(ot,{catalog:t,checkoutItems:n,client:r,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,onQuoteChange:l,onStateChange:f,quote:u,resumePayment:d})},`${t.payment.publishableKey}:${g??`platform`}:${u.paymentOption}`)}function Xe({label:e}){return B(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[z(`p`,{children:e}),B(`div`,{"aria-hidden":`true`,children:[z(`span`,{}),z(`span`,{}),z(`span`,{})]})]})}function Ze({onError:e,onReady:t,ready:n}){return B(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":n,children:[n?null:z(Xe,{label:`Loading payment form...`}),z(`div`,{className:`lockerverse-payment__stripe-mount`,children:z(C,{onLoadError:({error:t})=>e(t.message??`Payment form failed to load.`),onReady:t,options:{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,terms:{applePay:`auto`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:`auto`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`never`}}})})]})}function Qe({label:e,mode:t,onChange:n,onError:r,onReady:i,ready:a}){return B(`div`,{className:`lockerverse-payment__address`,children:[z(`h2`,{children:e}),B(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":a,children:[a?null:z(Xe,{label:`Loading ${e.toLowerCase()}...`}),z(`div`,{className:`lockerverse-payment__stripe-mount`,children:z(x,{onChange:n,onLoadError:({error:t})=>r(t.message??`${e} failed to load.`),onReady:i,options:{autocomplete:{mode:`automatic`},mode:t}})})]})]})}function $e({message:e}){return e?z(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}):null}function et({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isShippingAddressReady:a,onAddressChange:o,onFieldValuesChange:s,onStripeLoadError:c,setIsBillingAddressReady:l,setIsPaymentReady:u,setIsShippingAddressReady:d}){let f=t>0;return B(R,{children:[f?z(Ze,{onError:c,onReady:()=>u(!0),ready:i}):null,f||e.widget.fields.shipping?z(Qe,{label:f?`Billing address`:`Shipping address`,mode:`billing`,onChange:e=>o(`billing`,e),onError:c,onReady:()=>l(!0),ready:r}):null,e.widget.fields.shipping?B(`div`,{className:`lockerverse-payment__shipping`,children:[z(ie,{checked:n.shippingMatchesBilling,name:`shippingMatchesBilling`,onChange:e=>{s({...n,shippingMatchesBilling:e}),e?o(`shipping`,null):d(!1)},children:`Shipping is same as billing information`}),n.shippingMatchesBilling?null:z(Qe,{label:`Shipping address`,mode:`shipping`,onChange:e=>o(`shipping`,e),onError:c,onReady:()=>d(!0),ready:a})]}):null]})}function tt({displayedBaseCents:e,displayedTipCents:t,displayedTotalCents:n,quote:r}){let i=Ke(r.paymentOption),a=Math.max(0,e-r.subtotalCents+r.discountCents);return B(`section`,{"aria-label":`Payment summary`,className:`lockerverse-payment__payment-summary`,children:[z(`h2`,{children:`Order summary`}),z(`div`,{className:`lockerverse-payment__payment-summary-items`,children:r.lineItems.map(e=>B(`div`,{className:`lockerverse-payment__payment-summary-row`,children:[B(`span`,{children:[e.productName,e.quantity>1?B(R,{children:[` `,B(`small`,{children:[`× `,e.quantity]})]}):null,e.paymentOption===`monthly`?z(`small`,{children:` · Monthly`}):null,e.paymentOption===`annually`?z(`small`,{children:` · Annual`}):null]}),z(`strong`,{children:$(e.subtotalCents)})]},e.listingId))}),B(`div`,{className:`lockerverse-payment__payment-summary-totals`,children:[a>0?B(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail`,children:[z(`span`,{children:`Service fee`}),z(`strong`,{children:$(a)})]}):null,r.discountCents>0&&r.appliedDiscount?B(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-discount`,children:[B(`span`,{children:[r.appliedDiscount.source===`email_list`?`Email discount`:`Promo code discount`,` `,`(`,r.appliedDiscount.percentageOff,`% off)`]}),B(`strong`,{children:[`-`,$(r.discountCents)]})]}):null,t>0?B(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail lockerverse-payment__payment-summary-tip`,children:[z(`span`,{children:`Tip`}),z(`strong`,{children:$(t)})]}):null,B(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-total`,children:[z(`span`,{children:i?`${i.label} total`:`Total`}),z(`strong`,{children:$(n)})]})]})]})}function nt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isRequiredShippingReady:a,isSubmitting:o,onFieldValuesChange:s,quote:c}){let l=t===0,u=l?!e.widget.fields.shipping||r&&a:i&&r&&a,d=Ke(c.paymentOption),f=l?`Complete order`:`Pay ${$(t)}`;!l&&d&&(f=`Subscribe for ${$(t)}/${d.interval}`),o&&(f=l?`Completing…`:`Processing…`);let p=`Process payment for ${$(t)} total`;return l?p=`Complete order`:d&&(p=`Start ${d.label.toLowerCase()} subscription for ${$(t)}`),B(`div`,{className:`lockerverse-payment__actions`,children:[z(oe,{amountCents:c.serviceFeeCents||Math.round(c.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4),enabled:e.widget.fields.serviceFee,onChange:s,values:n}),z(`button`,{"aria-busy":o,"aria-label":p,disabled:o||!u,type:`submit`,children:f})]})}function rt(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement){n.focus();return}n instanceof RadioNodeList&&Array.from(n).find(e=>e instanceof HTMLElement)?.focus()}function it({customFieldErrors:e,emailRef:t,form:n,parsedTipSuccess:r,phoneRef:i,validationErrors:a}){if(a.email){t.current?.focus();return}if(a.phone){i.current?.focus();return}if(!r){n.querySelector(`[name="tip"]`)?.focus();return}let[o]=Object.keys(e);o&&rt(n,`custom:${o}`)}function at({email:e,emailDiscountPercentOff:t,emailErrorId:n,emailId:r,emailRef:i,errors:a,onEmailBlur:o,onEmailChange:s,onPhoneChange:c,onPhoneCountryChange:l,phone:u,phoneCountry:d,phoneEnabled:f,phoneErrorId:p,phoneId:m,phoneRef:h}){return B(`div`,{className:`lockerverse-payment__contact`,children:[z(`label`,{htmlFor:r,children:`Email`}),z(`input`,{"aria-describedby":a.email?n:void 0,"aria-invalid":a.email?`true`:void 0,autoComplete:`email`,id:r,name:`email`,onBlur:o,onChange:e=>s(e.currentTarget.value),placeholder:`name@example.com`,ref:i,type:`email`,value:e}),a.email?z(`p`,{className:`lockerverse-payment__field-message`,id:n,children:a.email}):null,t===void 0?null:B(`p`,{className:`lockerverse-payment__discount-message`,role:`status`,children:[`Your email qualifies for `,t,`% off.`]}),f?B(R,{children:[z(`label`,{htmlFor:m,children:`Phone`}),B(`div`,{className:`lockerverse-payment__phone-control`,children:[z(K,{ariaLabel:`Phone number country`,className:`lockerverse-payment__select--phone-country`,name:`phoneCountry`,onValueChange:l,options:qe,value:d}),z(`input`,{"aria-describedby":a.phone?p:void 0,"aria-invalid":a.phone?`true`:void 0,autoComplete:`tel`,id:m,inputMode:`tel`,name:`phone`,onChange:e=>c(e.currentTarget.value),placeholder:`(201) 555-0123`,ref:h,type:`tel`,value:u})]}),a.phone?z(`p`,{className:`lockerverse-payment__field-message`,id:p,children:a.phone}):null]}):null]})}function ot({catalog:e,checkoutItems:n,client:r,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,onQuoteChange:l,onStateChange:u,quote:d,resumePayment:f}){let[p,g]=b(``),[_,v]=b(``),[x,S]=b(`US`),[C,T]=b({}),[E,D]=b({}),[O,k]=b(),[A,j]=b(!1),[M,N]=b(!1),[P,F]=b(!1),[I,te]=b({customFields:t(e.widget.customFields),customTip:``,includeServiceFee:e.widget.fields.serviceFee,memberId:``,merchSize:`M`,promoCode:``,shippingMatchesBilling:!0,tipPercent:`10`}),L=y({billing:null,shipping:null}),ne=y(null),R=y(null),V=y(null),H=y(d.totalCents>0),U=Ge({catalog:e,checkoutItems:n,client:r,elements:w(),email:p,fieldValues:I,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,onQuoteChange:l,onStateChange:u,quote:d,resumePayment:f,stripe:ee()}),{displayedTotalCents:W,isRecovering:G,isRefreshingQuote:K,isSubmitting:q,parsedTip:J,paymentError:Y,promoError:ie,terminalMessage:oe}=U.state,se=`lockerverse-${h()}`,ce=`${se}-email`,ue=`${ce}-error`,de=`${se}-phone`,fe=`${de}-error`,pe=`${se}-tip-error`,me=(J.success?J.cents:null)??0,he=W-me,ge=!e.widget.fields.shipping||I.shippingMatchesBilling||P;m(()=>{q&&V.current?.focus()},[q]),m(()=>{let e=W>0;e&&!H.current&&(j(!1),N(!1)),H.current=e},[W]);function _e(e){U.commands.fieldChanged(),T(t=>{let n={...t};return delete n[e],n})}function X(e){U.commands.fieldChanged(e.promoCode!==I.promoCode),te(e),D({}),k(void 0)}async function ve(t){t.preventDefault();let n=le({email:p,phone:Je(_,x)},e.widget.fields.phone),r=i(e.widget.customFields,I.customFields);if(!(n.value&&J.success)||Object.keys(r).length>0){T(n.errors),D(r),k(J.success?void 0:J.message),U.commands.reportValidationFailure();let e=t.currentTarget;queueMicrotask(()=>{it({customFieldErrors:r,emailRef:ne,form:e,parsedTipSuccess:J.success,phoneRef:R,validationErrors:n.errors})});return}T({}),D({}),await U.commands.submit({addresses:L.current,phone:Je(_,x)})}return oe?z(`p`,{className:`lockerverse-payment__payment-status`,ref:V,role:`status`,tabIndex:-1,children:oe}):G?z(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:`Recovering payment…`}):B(`form`,{"aria-busy":q,className:`lockerverse-payment__form`,noValidate:!0,onSubmit:ve,children:[z(`div`,{"data-lockerverse-input-region":``,inert:q?!0:void 0,children:B(`fieldset`,{className:`lockerverse-payment__input-fieldset`,disabled:q,children:[z(tt,{displayedBaseCents:he,displayedTipCents:me,displayedTotalCents:W,quote:d}),z(re,{enabled:e.widget.fields.tipping,error:O,errorId:pe,onChange:X,values:I}),z(at,{email:p,emailDiscountPercentOff:d.appliedDiscount?.source===`email_list`?d.appliedDiscount.percentageOff:void 0,emailErrorId:ue,emailId:ce,emailRef:ne,errors:C,onEmailBlur:()=>U.commands.refreshAuthoritativeTotal(),onEmailChange:e=>{g(e),_e(`email`)},onPhoneChange:e=>{v(e),_e(`phone`)},onPhoneCountryChange:e=>{S(e),U.commands.fieldChanged()},phone:_,phoneCountry:x,phoneEnabled:e.widget.fields.phone,phoneErrorId:fe,phoneId:de,phoneRef:R}),z(et,{catalog:e,displayedTotalCents:W,fieldValues:I,isBillingAddressReady:M,isPaymentReady:A,isShippingAddressReady:P,onAddressChange:(e,t)=>{L.current[e]=t},onFieldValuesChange:X,onStripeLoadError:U.commands.reportStripeLoadError,setIsBillingAddressReady:N,setIsPaymentReady:j,setIsShippingAddressReady:F}),z(ae,{customFields:e.widget.customFields,errors:E,fields:e.widget.fields,idPrefix:se,isPromoApplying:K,onApplyPromo:U.commands.applyPromo,onChange:X,promoError:ie,values:I}),z(nt,{catalog:e,displayedTotalCents:W,fieldValues:I,isBillingAddressReady:M,isPaymentReady:A,isRequiredShippingReady:ge,isSubmitting:q,onFieldValuesChange:X,quote:d})]})}),q?z(`p`,{className:`lockerverse-payment__sr-only`,ref:V,role:`status`,tabIndex:-1,children:W===0?`Completing order…`:`Processing payment…`}):null,z($e,{message:Y})]})}function st(){return B(`div`,{className:`lockerverse-payment__skeleton-loader-block`,children:[z(`span`,{className:`lockerverse-payment__skeleton-loader-label`}),B(`div`,{className:`lockerverse-payment__skeleton-loader-content`,children:[z(`span`,{className:`lockerverse-payment__skeleton-loader-full`}),B(`div`,{className:`lockerverse-payment__skeleton-loader-grid`,children:[z(`span`,{className:`lockerverse-payment__skeleton-loader-half`}),z(`span`,{className:`lockerverse-payment__skeleton-loader-half`})]})]})]})}function ct(){return B(`div`,{className:`lockerverse-payment__loading`,children:[z(`span`,{"aria-live":`polite`,className:`lockerverse-payment__sr-only`,role:`status`,children:`Loading payment…`}),B(`div`,{"aria-hidden":`true`,className:`lockerverse-payment__skeleton`,children:[B(`div`,{className:`lockerverse-payment__skeleton-branding`,children:[z(`span`,{className:`lockerverse-payment__skeleton-avatar`}),z(`span`,{className:`lockerverse-payment__skeleton-community`})]}),B(`div`,{className:`lockerverse-payment__skeleton-contact`,children:[B(`div`,{className:`lockerverse-payment__skeleton-field`,children:[z(`span`,{className:`lockerverse-payment__skeleton-label`}),z(`span`,{className:`lockerverse-payment__skeleton-input`})]}),B(`div`,{className:`lockerverse-payment__skeleton-field`,children:[z(`span`,{className:`lockerverse-payment__skeleton-label`}),z(`span`,{className:`lockerverse-payment__skeleton-input`})]})]}),z(st,{}),z(st,{}),B(`div`,{className:`lockerverse-payment__skeleton-actions`,children:[z(`span`,{className:`lockerverse-payment__skeleton-check-line`}),z(`span`,{className:`lockerverse-payment__skeleton-button`})]})]})]})}function lt({apiBaseUrl:e,branding:t,className:r,communitySlug:i,environment:a,fetch:o,metadata:s,onError:l,onPaymentComplete:u,onPaymentRecoveryChange:d,onPaymentUncertain:p,requestTimeoutMs:h,resumePayment:_,selection:v,sentryDsn:x,style:S,stripeLoader:C=T,theme:w=`dark`,widgetSlug:ee,...E}){let D=y(_).current,O=y(null),[k,A]=b(),[j,M]=b(`idle`),N=y(void 0),{retryCheckout:P,selectionError:F,session:I,updateCheckout:te}=ve({apiBaseUrl:e,communitySlug:i,environment:a,fetch:o,onError:l,paymentState:j,requestTimeoutMs:h,selection:v,sentryDsn:x,widgetSlug:ee}),L=I.phase===`ready`?I.revision:void 0,ne=f(e=>{L!==void 0&&(N.current=L),M(e)},[L]);m(()=>{I.phase===`loading`&&A(void 0)},[I.phase]),g(()=>{I.phase===`ready`&&N.current!==I.revision&&M(e=>e===`success`||e===`unresolved`?e:`idle`)},[I.phase,I.revision]);let R=[`lockerverse-payment`,r].filter(Boolean).join(` `),V=t??(I.phase===`ready`?I.catalog.community:null),H=n(S?.[`--lockerverse-accent`]??V?.accentColor??`#38d77a`),W=c(H),G={...S,...S?.[`--lockerverse-accent`]!==void 0||V?.accentColor?{"--lockerverse-accent":H}:{},...W&&S?.[`--lockerverse-accent-contrast`]===void 0?{"--lockerverse-accent-contrast":W}:{}};if(F)return z(`section`,{...E,className:R,"data-lockerverse-theme":w,role:`alert`,style:G,children:F});if(I.phase===`error`)return B(`section`,{...E,className:R,"data-lockerverse-theme":w,style:G,children:[z(`p`,{role:`alert`,children:I.failure}),z(`button`,{onClick:P,type:`button`,children:`Retry`})]});if(I.phase!==`ready`)return z(`section`,{...E,"aria-busy":`true`,"aria-label":`Payment`,className:R,"data-lockerverse-theme":w,style:G,children:z(ct,{})});let{catalog:K,checkoutItems:q,client:J,preparedCheckout:Y}=I;return B(`section`,{...E,"aria-label":`Payment`,className:R,"data-lockerverse-theme":w,"data-payment-state":j,ref:O,style:G,children:[B(`header`,{children:[K.widget.showCommunityBranding&&V?B(`div`,{className:`lockerverse-payment__branding`,children:[V.imageUrl?z(`img`,{alt:V.name,height:`48`,src:V.imageUrl,width:`48`}):null,z(`strong`,{children:V.name})]}):null,z(`h1`,{children:K.widget.title??K.widget.name}),K.widget.description?z(`p`,{children:K.widget.description}):null]}),k?z(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:k}):null,z(U,{container:O,children:z(Ye,{accentColor:H,catalog:K,checkoutItems:q,client:J,fontFamily:S?.[`--lockerverse-font-family`]??`ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,metadata:s,onPaymentComplete:u,onPaymentRecoveryChange:d,onPaymentUncertain:p,onQuoteChange:(e,t)=>{A(t),te(e)},onStateChange:ne,quote:Y,resumePayment:D,stripeLoader:C,theme:w,visualStyle:G})})]})}export{lt as t};
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,o,s,t as c,u as l}from"./contact-validation.js";import{LockerverseSdkError as u,createLockerverseCheckoutClient as d}from"@lockerverse/sdk/checkout";import{createContext as f,useCallback as p,useContext as m,useEffect as h,useId as g,useLayoutEffect as _,useMemo as v,useReducer as y,useRef as b,useState as x}from"react";import{AddressElement as S,Elements as C,PaymentElement as w,useElements as ee,useStripe as T}from"@stripe/react-stripe-js";import{loadStripe as E}from"@stripe/stripe-js";import{array as D,minLength as O,minValue as k,nonEmpty as A,number as j,object as M,pipe as N,regex as P,safeInteger as te,safeParse as F,strictObject as I,string as L,trim as R,union as z}from"valibot";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import{Select as U}from"@base-ui/react/select";const W=f(void 0);function G({children:e,container:t}){return V(W.Provider,{value:t,children:e})}function K(){return V(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:V(`path`,{d:`m4 6 4 4 4-4`})})}function q(){return V(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:V(`path`,{d:`m3 8 3 3 7-7`})})}function J({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:c,value:l}){let u=m(W),d=[`lockerverse-payment__select`,r].filter(Boolean).join(` `);return V(`div`,{className:d,children:H(U.Root,{id:i,items:c,name:o,onValueChange:e=>{e!==null&&s(e)},value:l,children:[H(U.Trigger,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:`lockerverse-payment__select-trigger`,children:[V(U.Value,{}),V(U.Icon,{"aria-hidden":`true`,className:`lockerverse-payment__select-icon`,children:V(K,{})})]}),V(U.Portal,{container:u,children:V(U.Positioner,{alignItemWithTrigger:!1,className:`lockerverse-payment__select-positioner`,sideOffset:6,children:V(U.Popup,{className:`lockerverse-payment__select-popup`,children:V(U.List,{className:`lockerverse-payment__select-list`,children:c.map(e=>H(U.Item,{className:`lockerverse-payment__select-item`,value:e.value,children:[V(U.ItemText,{children:e.label}),V(U.ItemIndicator,{"aria-hidden":`true`,className:`lockerverse-payment__select-item-indicator`,children:V(q,{})})]},e.value))})})})})]})})}const Y=[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`],ne=[`15`,`12`,`10`,`5`],X=[...ne,`custom`];function re({enabled:e,error:t,errorId:n,onChange:r,values:i}){if(!e)return null;let a=e=>r({...i,...e}),o=(e,t)=>{let n=X.indexOf(t),r;switch(e.key){case`ArrowDown`:case`ArrowRight`:r=(n+1)%X.length;break;case`ArrowLeft`:case`ArrowUp`:r=(n-1+X.length)%X.length;break;case`Home`:r=0;break;case`End`:r=X.length-1;break;default:return}e.preventDefault();let i=X[r];i&&((e.currentTarget.closest(`[role="radiogroup"]`)?.querySelectorAll(`input[type="radio"]`))?.[r]?.focus(),a({tipPercent:i}))};return H(`div`,{className:`lockerverse-payment__tip-box`,children:[V(`p`,{children:`Add a tip to support the Lockerverse platform`}),H(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:[ne.map(e=>H(`label`,{className:`lockerverse-payment__tip-choice`,children:[V(`input`,{checked:i.tipPercent===e,name:`tipPercent`,onChange:()=>a({tipPercent:e}),onKeyDown:t=>o(t,e),tabIndex:i.tipPercent===e?0:-1,type:`radio`,value:e}),H(`span`,{children:[e,`%`]})]},e)),H(`label`,{className:`lockerverse-payment__tip-choice`,children:[V(`input`,{checked:i.tipPercent===`custom`,name:`tipPercent`,onChange:()=>a({tipPercent:`custom`}),onKeyDown:e=>o(e,`custom`),tabIndex:i.tipPercent===`custom`?0:-1,type:`radio`,value:`custom`}),V(`span`,{children:`Other`})]})]}),i.tipPercent===`custom`?H(`label`,{children:[V(`span`,{children:`Custom tip`}),H(`span`,{className:`lockerverse-payment__money-input`,children:[V(`span`,{"aria-hidden":`true`,children:`$`}),V(`input`,{"aria-describedby":t?n:void 0,"aria-invalid":t?`true`:void 0,inputMode:`decimal`,name:`tip`,onChange:e=>a({customTip:e.currentTarget.value}),placeholder:`0.00`,value:i.customTip})]}),t?V(`span`,{className:`lockerverse-payment__field-message`,id:n,children:t}):null]}):V(`input`,{name:`tip`,type:`hidden`,value:i.tipPercent})]})}function ie({checked:e,children:t,name:n,onChange:r}){return H(`label`,{className:`lockerverse-payment__check-row`,children:[V(`input`,{checked:e,name:n,onChange:e=>r(e.currentTarget.checked),type:`checkbox`}),V(`span`,{children:t})]})}function ae({customFields:e,errors:t,fields:n,idPrefix:r,isPromoApplying:i,onChange:a,onApplyPromo:o,promoError:c,values:l}){let u=e=>a({...l,...e});return H(`div`,{className:`lockerverse-payment__additional-fields`,children:[n.memberId?H(`label`,{children:[V(`span`,{children:`Member ID`}),V(`input`,{name:`memberId`,onChange:e=>u({memberId:e.currentTarget.value}),placeholder:`Optional`,value:l.memberId})]}):null,n.merchSize?H(`div`,{className:`lockerverse-payment__field`,children:[V(`span`,{id:`${r}-merch-size-label`,children:`Size`}),V(J,{ariaLabelledBy:`${r}-merch-size-label`,name:`merchSize`,onValueChange:e=>u({merchSize:e}),options:Y.map(e=>({label:e,value:e})),value:l.merchSize})]}):null,n.promoCode?H(`div`,{className:`lockerverse-payment__field`,children:[V(`span`,{id:`${r}-promo-code-label`,children:`Promo code`}),H(`div`,{className:`lockerverse-payment__promo-control`,children:[V(`input`,{"aria-describedby":c?`${r}-promo-code-error`:void 0,"aria-invalid":c?`true`:void 0,"aria-labelledby":`${r}-promo-code-label`,name:`promoCode`,onChange:e=>u({promoCode:e.currentTarget.value}),placeholder:`Optional`,value:l.promoCode}),V(`button`,{disabled:!l.promoCode.trim()||i,onClick:o,type:`button`,children:i?`Applying…`:`Apply`})]}),c?V(`p`,{className:`lockerverse-payment__field-message`,id:`${r}-promo-code-error`,role:`alert`,children:c}):null]}):null,V(s,{choiceClassName:`lockerverse-payment__check-row`,errorClassName:`lockerverse-payment__field-message`,errors:t,fields:e,idPrefix:r,onChange:e=>u({customFields:e}),values:l.customFields})]})}function oe({amountCents:e,enabled:t,onChange:n,values:r}){return t?H(ie,{checked:r.includeServiceFee,name:`includeServiceFee`,onChange:e=>n({...r,includeServiceFee:e}),children:[`Add `,se(e),` to help cover processing fees`]}):null}function se(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function ce(e){return c(e)}function le(t,n){let r=n?{...t,phone:ce(t.phone)}:t,a=M(n?{email:i,phone:e}:{email:i}),o=F(a,r);if(o.success)return{errors:{},value:o.output};let s={};for(let e of o.issues){let t=e.path?.[0]?.key;(t===`email`||t===`phone`)&&!s[t]&&(s[t]=e.message)}return{errors:s,value:null}}const ue=N(L(),R(),A()),de=N(j(),te(),k(1)),fe=N(D(z([I({amountCents:de,productSlug:ue}),I({productSlug:ue,quantity:de}),I({productSlug:ue})])),O(1)),pe=N(L(),R(),P(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,`Enter a valid tip amount.`));function me(e){let t=F(pe,e);if(!t.success)return{message:t.issues[0]?.message??`Enter a valid tip amount.`,success:!1};let[n=`0`,r=``]=t.output.split(`.`),i=BigInt(n)*100n+BigInt(r.padEnd(2,`0`));return i>BigInt(2**53-1)?{message:`Enter a valid tip amount.`,success:!1}:{cents:Number(i),success:!0}}function he(e){let t=F(fe,e);return t.success?{success:!0,value:t.output}:{message:`Lockerverse payment configuration is invalid.`,success:!1}}function ge(e,t){switch(t.type){case`loading`:return{configuration:t.configuration,phase:`loading`,revision:e.revision,selectionKey:t.selectionKey};case`ready`:return{catalog:t.catalog,checkoutItems:t.checkoutItems,client:t.client,configuration:t.configuration,phase:`ready`,preparedCheckout:t.preparedCheckout,revision:e.revision+1,selectionKey:t.selectionKey};case`error`:return{configuration:t.configuration,failure:t.failure,phase:`error`,revision:e.revision,selectionKey:t.selectionKey};case`checkout`:return e.phase===`ready`?{...e,preparedCheckout:t.preparedCheckout}:e;case`retry`:return{phase:`idle`,revision:e.revision+1};default:return e}}function _e(e,t){let{apiBaseUrl:n,communitySlug:r,environment:i,fetch:a,requestTimeoutMs:o,sentryDsn:s,widgetSlug:c}=e,l={communitySlug:r,widgetSlug:c,...a?{fetch:a}:{},...t?{onError:t}:{},...o===void 0?{}:{requestTimeoutMs:o},...s===void 0?{}:{sentryDsn:s}};if(n===void 0){if(i===`development`)throw TypeError(`Lockerverse development checkout requires an API base URL.`);return{...l,...i===`production`?{environment:i}:{}}}return{...l,apiBaseUrl:n,...i===void 0?{}:{environment:i}}}function ve(e,t,n){return e?.configuration===t&&e.selectionKey===n}function ye({apiBaseUrl:e,communitySlug:t,environment:n,fetch:r,onError:i,paymentState:a,requestTimeoutMs:o,selection:s,sentryDsn:c,widgetSlug:l}){let u=v(()=>({apiBaseUrl:e,communitySlug:t,environment:n,fetch:r,requestTimeoutMs:o,sentryDsn:c,widgetSlug:l}),[e,t,n,r,o,c,l]),f=he(s),p=f.success?JSON.stringify(f.value):`invalid-selection`,m=v(()=>f.success?JSON.parse(p):[],[f.success,p]),[g,_]=y(ge,{phase:`idle`,revision:0}),x=b(void 0),S=b(void 0),C=b(i);return C.current=i,h(()=>{if(!f.success||a===`submitting`||a===`success`||a===`unresolved`||ve(S.current,u,p)||ve(x.current,u,p))return;let e=!0,t={configuration:u,selectionKey:p};x.current=t,_({configuration:u,selectionKey:p,type:`loading`});async function n(){try{let n=d(_e(u,e=>C.current?.(e))),{catalog:r,checkout:i}=await n.bootstrapCheckout({items:m}),a=[...i.items];e&&(x.current=void 0,S.current=t,_({catalog:r,checkoutItems:a,client:n,configuration:u,preparedCheckout:i,selectionKey:p,type:`ready`}))}catch(n){e&&(x.current=void 0,S.current=t,_({configuration:u,failure:n instanceof Error?n.message:`Lockerverse payment could not load.`,selectionKey:p,type:`error`}))}}return n(),()=>{e=!1,ve(x.current,u,p)&&(x.current=void 0)}},[u,f.success,a,p,g.revision,m]),{retryCheckout:()=>{x.current=void 0,S.current=void 0,_({type:`retry`})},selectionError:f.success?void 0:f.message,session:g,updateCheckout:e=>_({preparedCheckout:e,type:`checkout`})}}const be=[`amountCents`,`discountableSubtotalCents`,`discountCents`,`serviceFeeCents`,`subtotalCents`,`tipCents`,`totalCents`],xe=[`discountableSubtotalCents`,`discountCents`,`subtotalCents`];function Se(e,t,n){return(n===t.totalCents?xe:be).some(n=>e[n]!==t[n])||e.payment.connectedAccountId!==t.payment.connectedAccountId||e.payment.currency!==t.payment.currency||JSON.stringify(e.appliedDiscount)!==JSON.stringify(t.appliedDiscount)||JSON.stringify(e.lineItems)!==JSON.stringify(t.lineItems)}function Ce(e){return e.checkoutStatus===`success`?{kind:`success`,payment:e}:e.checkoutStatus===`failed`?{kind:`failed`,payment:e}:{kind:`unresolved`,paymentReference:e.paymentReference,reason:e.checkoutStatus===`action_required`?`action_required`:`pending`}}async function we(e,t,n){if(t.checkoutStatus!==`action_required`)return Ce(t);if(!n)return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`};if(t.clientSecret)try{await n.handleNextAction({clientSecret:t.clientSecret})}catch{}try{return Ce(await e.getPaymentStatus(t.paymentReference))}catch{return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`}}}async function Te(e,t,n){let r;try{r=await e.submitPayment(t)}catch(n){if(!(n instanceof u&&n.recoveryRecommended))throw n;try{r=await e.getPaymentStatus(t.checkout.paymentReference)}catch{return{kind:`unresolved`,paymentReference:t.checkout.paymentReference,reason:`recovery_failed`}}}return we(e,r,n)}async function Ee(e,t,n){try{return we(e,await e.getPaymentStatus(t),n)}catch{return{kind:`unresolved`,paymentReference:t,reason:`recovery_failed`}}}function De(e){throw Error(`Unexpected payment workflow value: ${String(e)}`)}function Oe(e,t){return t===void 0?{phase:e}:{error:t,phase:e}}function ke(e){return e?{phase:`recovering`}:{phase:`editing`}}function Ae(e){return e.phase===`editing`||e.phase===`invalid`?e.error:e.phase===`refreshing_quote`?e.previousError:void 0}function je(e){return e.phase===`succeeded`?`success`:e.phase===`unresolved`?`unresolved`:e.phase===`submitting`||e.phase===`recovering`?`submitting`:e.phase===`invalid`?`invalid`:Ae(e)?`error`:`idle`}function Me(e){return e.phase===`submitting`}function Ne(e,t){if(e.phase===`succeeded`||e.phase===`unresolved`)return e;switch(t.type){case`field_changed`:return e.phase===`invalid`?Oe(`editing`,e.error):e;case`validation_failed`:return e.phase===`submitting`||e.phase===`recovering`?e:Oe(`invalid`,Ae(e));case`quote_refresh_started`:{if(e.phase===`submitting`||e.phase===`recovering`)return e;let n=Ae(e);return{...n===void 0?{}:{previousError:n},phase:`refreshing_quote`,validatePromo:t.validatePromo}}case`quote_refresh_succeeded`:return e.phase===`refreshing_quote`?{phase:`editing`}:e;case`quote_refresh_failed`:return e.phase===`refreshing_quote`?Oe(`editing`,t.error??e.previousError):e;case`submission_started`:return e.phase===`recovering`?e:{phase:`submitting`};case`quote_changed`:return e.phase===`submitting`?{phase:`editing`}:e;case`retryable_failure`:return Oe(`editing`,t.error);case`recovery_failed`:return e.phase===`recovering`?Oe(`editing`,t.error):e;case`succeeded`:return e.phase===`submitting`||e.phase===`recovering`?{message:t.message,phase:`succeeded`}:e;case`unresolved`:return e.phase===`submitting`||e.phase===`recovering`?{message:t.message,paymentReference:t.paymentReference,phase:`unresolved`,reason:t.reason}:e;default:return De(t)}}function Pe(e,t){return t.tipPercent===`custom`?t.customTip.trim()?me(t.customTip):{cents:0,success:!0}:{cents:Math.round(e*Number(t.tipPercent)/100),success:!0}}function Fe(e,t,n,r){return{...n?{email:n}:{},...e.widget.fields.serviceFee?{includeServiceFee:t.includeServiceFee}:{},...e.widget.fields.promoCode&&t.promoCode.trim()?{promoCode:t.promoCode.trim()}:{},...e.widget.fields.tipping?{tipCents:r}:{}}}function Ie(e,t){if(!e?.complete)throw Error(`${t} address is required.`);return e.value}function Le(e,t,n,r){if(e.widget.fields.shipping)return t.shippingMatchesBilling?n:Ie(r.shipping,`Shipping`)}function Re({billingAddress:e,catalog:t,email:n,phone:r,shippingAddress:i}){return{payment_method_data:{billing_details:{address:e.address,email:n,name:e.name,...t.widget.fields.phone?{phone:r}:{}}},...i?{shipping:{address:i.address,name:i.name,phone:t.widget.fields.phone?r:i.phone??null}}:{}}}function ze({catalog:e,confirmationToken:n,email:r,fieldValues:i,metadata:a,phone:o,shippingAddress:s}){return{...n?{confirmationToken:n}:{},customFieldAnswers:t(e.widget.customFields,i.customFields),email:r,...a?{metadata:a}:{},...e.widget.fields.memberId&&i.memberId.trim()?{memberId:i.memberId.trim()}:{},...e.widget.fields.merchSize?{merchSize:i.merchSize}:{},...e.widget.fields.phone?{phone:o}:{},...s?{shipping:{address:{city:s.address.city??``,country:s.address.country,line1:s.address.line1??``,...s.address.line2?{line2:s.address.line2}:{},postal_code:s.address.postal_code??``,state:s.address.state??``},name:s.name}}:{}}}function Z(e,t){try{e?.(t)}catch{}}function Q(e){if(!e())throw Error(`Payment component is no longer active.`)}async function Be({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:s,locallyPreviewedTotalCents:c,metadata:l,onPaymentRecoveryChange:u,phone:d,quote:f,stripe:p}){let m=a.trim().toLowerCase(),h=ce(d),g=Pe(f.subtotalCents,o);if(!g.success)throw Error(g.message);let _=Fe(t,o,m,g.cents),v=await r.calculateTotal({..._,items:n});if(Q(s),v.totalCents>0&&Se(f,v,c))return{kind:`quote_changed`,quote:v};if(v.totalCents===0){let n;t.widget.fields.shipping&&(n=Le(t,o,Ie(e.billing,`Billing`),e)),Q(s),Z(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let i=await Te(r,{checkout:v,submission:ze({catalog:t,email:m,fieldValues:o,metadata:l,phone:h,...n?{shippingAddress:n}:{}})},p);return Q(s),i.kind===`failed`?{kind:`payment_failed`,message:`Order could not be completed. Review the details and try again.`}:i.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:i.paymentReference,reason:i.reason}:{kind:`payment`,payment:i.payment,quote:v}}if(!(i&&p))throw Error(`Payment form is still loading.`);await i.update({amount:v.totalCents}),Q(s);let y=await i.submit();if(Q(s),y.error)throw Error(y.error.message);let b=Ie(e.billing,`Billing`),x=Le(t,o,b,e),S=await p.createConfirmationToken({elements:i,params:Re({billingAddress:b,catalog:t,email:m,phone:h,shippingAddress:x})});if(Q(s),S.error)throw Error(S.error.message);Z(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let C=await Te(r,{checkout:v,submission:ze({catalog:t,confirmationToken:S.confirmationToken.id,email:m,fieldValues:o,metadata:l,phone:h,...x?{shippingAddress:x}:{}})},p);return Q(s),C.kind===`failed`?{kind:`payment_failed`,message:`Payment was declined. Check your payment details and try again.`}:C.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:C.paymentReference,reason:C.reason}:{kind:`payment`,payment:C.payment,quote:v}}function Ve(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function He(e,t){if(!t)return e instanceof Error?e.message:`The order total could not be updated.`}function Ue({nextQuote:e,onQuoteChange:t,setDisplayedTotalCents:n,setPromoError:r,updateWorkflow:i,validatePromo:a}){i({type:`quote_refresh_succeeded`}),n(e.totalCents),t(e),a&&r(e.appliedDiscount?.source===`promo_code`?void 0:`This promo code is invalid or cannot be applied.`)}function We({error:e,setPromoError:t,updateWorkflow:n,validatePromo:r}){r&&t(`This promo code is invalid or cannot be applied.`);let i=He(e,r);n(i===void 0?{type:`quote_refresh_failed`}:{error:i,type:`quote_refresh_failed`})}function Ge({onPaymentComplete:e,onPaymentRecoveryChange:t,onPaymentUncertain:n,onQuoteChange:r,result:i,setDisplayedTotalCents:a,transitionWorkflow:o}){if(i.kind===`quote_changed`){let e=`The total changed to ${Ve(i.quote.totalCents)}. Review it and pay again.`;r(i.quote,e),a(i.quote.totalCents),o({type:`quote_changed`});return}if(i.kind===`payment_failed`){Z(t,null),o({error:i.message,type:`retryable_failure`});return}if(i.kind===`payment_unresolved`){o({message:`Payment is still processing. Do not submit it again.`,paymentReference:i.paymentReference,reason:i.reason,type:`unresolved`});try{n?.({paymentReference:i.paymentReference,reason:i.reason})}catch{}return}r(i.quote),Z(t,null),o({message:i.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`});try{e?.(i.payment)}catch{}}function Ke(e){let{catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,metadata:s,onPaymentComplete:c,onPaymentRecoveryChange:l,onPaymentUncertain:u,onQuoteChange:d,onStateChange:f,quote:m,resumePayment:g,stripe:_}=e,[v,S]=y(Ne,g,ke),[C,w]=x(m.totalCents),[ee,T]=x(),E=b(!1),D=b(0),O=b(0),k=b(v);k.current=v;let A=p((e,t=!1)=>{let n=k.current,r=Ne(n,e);r!==n&&(k.current=r,S(e),t&&f(je(r)))},[f]),j=p(e=>A(e,!0),[A]),M=p(()=>{let e=O.current+1;return O.current=e,()=>O.current===e},[]);h(()=>()=>{O.current+=1},[]);let N=t.widget.fields.tipping?Pe(m.subtotalCents,o):{cents:0,success:!0},P=N.success?N.cents:null;h(()=>{if(P===null)return;let e=t.widget.fields.serviceFee&&o.includeServiceFee?m.serviceFeeCents||Math.round(m.subtotalCents*t.pricingPolicy.serviceFeeRateBasisPoints/1e4):0,n=m.totalCents-m.serviceFeeCents-m.tipCents+e+P;w(n),n>0&&i?.update({amount:n})},[t.pricingPolicy.serviceFeeRateBasisPoints,t.widget.fields.serviceFee,i,o.includeServiceFee,P,m.serviceFeeCents,m.tipCents,m.totalCents,m.subtotalCents]),h(()=>{if(!(g&&_)||E.current)return;E.current=!0;let e=M();return f(je(k.current)),Ee(r,g.paymentReference,_).then(t=>{if(e()){if(t.kind===`failed`){Z(l,null),j({error:`The previous payment failed. Check your details and try again.`,type:`recovery_failed`});return}if(t.kind===`unresolved`){j({message:`Payment is still processing. Do not submit it again.`,paymentReference:t.paymentReference,reason:t.reason,type:`unresolved`});try{u?.({paymentReference:t.paymentReference,reason:t.reason})}catch{}return}Z(l,null),j({message:t.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`});try{c?.(t.payment)}catch{}}}),()=>{e()&&(O.current+=1),E.current=!1}},[r,c,l,u,f,g,_,M,j]);let te=p((e=!1)=>{e&&T(void 0),A({type:`field_changed`})},[A]);async function F(e=!1,i=!1){let s=le({email:a.trim().toLowerCase(),phone:``},!1);if(!(N.success&&(s.value||e)))return;D.current+=1;let c=D.current;A({type:`quote_refresh_started`,validatePromo:i});try{let e=await r.calculateTotal({...Fe(t,o,s.value?.email??``,N.cents),items:n});if(c!==D.current)return;Ue({nextQuote:e,onQuoteChange:d,setDisplayedTotalCents:w,setPromoError:T,updateWorkflow:A,validatePromo:i})}catch(e){if(c!==D.current)return;We({error:e,setPromoError:T,updateWorkflow:A,validatePromo:i})}}async function I(){T(void 0),await F(!0,!0)}async function L({addresses:e,phone:f}){j({type:`submission_started`});let p=M();try{let h=await Be({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:p,locallyPreviewedTotalCents:C,metadata:s,onPaymentRecoveryChange:l,phone:f,quote:m,stripe:_});if(!p())return;Ge({onPaymentComplete:c,onPaymentRecoveryChange:l,onPaymentUncertain:u,onQuoteChange:d,result:h,setDisplayedTotalCents:w,transitionWorkflow:j})}catch(e){if(!p())return;Z(l,null),j({error:e instanceof Error?e.message:`Payment could not be completed.`,type:`retryable_failure`})}}let R=v.phase===`succeeded`||v.phase===`unresolved`?v.message:void 0;return{commands:{applyPromo:I,fieldChanged:te,refreshAuthoritativeTotal:F,reportStripeLoadError:e=>j({error:e,type:`retryable_failure`}),reportValidationFailure:()=>j({type:`validation_failed`}),submit:L},state:{displayedTotalCents:C,isRecovering:v.phase===`recovering`,isRefreshingQuote:v.phase===`refreshing_quote`,isSubmitting:Me(v),parsedTip:N,paymentError:Ae(v),promoError:ee,terminalMessage:R}}}function $(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function qe(e){return e===`monthly`?{interval:`month`,label:`Monthly`}:e===`annually`?{interval:`year`,label:`Annual`}:null}const Je=[{callingCode:`+1`,label:`🇺🇸 +1`,value:`US`},{callingCode:`+52`,label:`🇲🇽 +52`,value:`MX`},{callingCode:`+380`,label:`🇺🇦 +380`,value:`UA`},{callingCode:`+48`,label:`🇵🇱 +48`,value:`PL`},{callingCode:`+1`,label:`🇨🇦 +1`,value:`CA`},{callingCode:`+49`,label:`🇩🇪 +49`,value:`DE`},{callingCode:`+44`,label:`🇬🇧 +44`,value:`GB`},{callingCode:`+46`,label:`🇸🇪 +46`,value:`SE`},{callingCode:`+358`,label:`🇫🇮 +358`,value:`FI`},{callingCode:`+1`,label:`🇵🇷 +1`,value:`PR`}];function Ye(e,t){return e.trim().startsWith(`+`)?e:`${Je.find(e=>e.value===t)?.callingCode??`+1`}${e}`}function Xe({accentColor:e,catalog:t,checkoutItems:n,client:r,fontFamily:i,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,onQuoteChange:l,quote:u,resumePayment:d,onStateChange:f,stripeLoader:p,theme:m,visualStyle:h}){let g=d?d.connectedAccountId:u.payment.connectedAccountId,_=v(()=>p(t.payment.publishableKey,g?{stripeAccount:g}:void 0).catch(()=>null),[t.payment.publishableKey,g,p]);return V(C,{options:{amount:Math.max(u.totalCents,100),appearance:{rules:{".Input:focus":{borderColor:e,boxShadow:`0 0 0 1px ${e}`,outline:`none`}},theme:m===`light`?`stripe`:`night`,variables:{borderRadius:h?.[`--lockerverse-radius`]??`10px`,colorBackground:h?.[`--lockerverse-control`]??(m===`light`?`#f5f6f7`:`#121212`),colorDanger:h?.[`--lockerverse-danger`]??(m===`light`?`#c52b3e`:`#f08a98`),colorPrimary:e,colorText:h?.[`--lockerverse-text`]??(m===`light`?`#121416`:`#ffffff`),colorTextPlaceholder:h?.[`--lockerverse-placeholder`]??(m===`light`?`#72767d`:`#6b6b6b`),colorTextSecondary:h?.[`--lockerverse-muted`]??(m===`light`?`#62666d`:`#a1a1aa`),focusBoxShadow:`none`,focusOutline:`none`,fontFamily:i,fontSizeBase:`16px`}},currency:u.payment.currency,excludedPaymentMethodTypes:[`us_bank_account`],mode:u.paymentOption===`one-time`?`payment`:`subscription`,syncAddressCheckbox:`none`},stripe:_,children:V(st,{catalog:t,checkoutItems:n,client:r,metadata:a,onPaymentComplete:o,onPaymentRecoveryChange:s,onPaymentUncertain:c,onQuoteChange:l,onStateChange:f,quote:u,resumePayment:d})},`${t.payment.publishableKey}:${g??`platform`}:${u.paymentOption}`)}function Ze({label:e}){return H(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[V(`p`,{children:e}),H(`div`,{"aria-hidden":`true`,children:[V(`span`,{}),V(`span`,{}),V(`span`,{})]})]})}function Qe({onError:e,onReady:t,ready:n}){return H(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":n,children:[n?null:V(Ze,{label:`Loading payment form...`}),V(`div`,{className:`lockerverse-payment__stripe-mount`,children:V(w,{onLoadError:({error:t})=>e(t.message??`Payment form failed to load.`),onReady:t,options:{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,terms:{applePay:`auto`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:`auto`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`never`}}})})]})}function $e({label:e,mode:t,onChange:n,onError:r,onReady:i,ready:a}){return H(`div`,{className:`lockerverse-payment__address`,children:[V(`h2`,{children:e}),H(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":a,children:[a?null:V(Ze,{label:`Loading ${e.toLowerCase()}...`}),V(`div`,{className:`lockerverse-payment__stripe-mount`,children:V(S,{onChange:n,onLoadError:({error:t})=>r(t.message??`${e} failed to load.`),onReady:i,options:{autocomplete:{mode:`automatic`},mode:t}})})]})]})}function et({message:e}){return e?V(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}):null}function tt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isShippingAddressReady:a,onAddressChange:o,onFieldValuesChange:s,onStripeLoadError:c,setIsBillingAddressReady:l,setIsPaymentReady:u,setIsShippingAddressReady:d}){let f=t>0;return H(B,{children:[f?V(Qe,{onError:c,onReady:()=>u(!0),ready:i}):null,f||e.widget.fields.shipping?V($e,{label:f?`Billing address`:`Shipping address`,mode:`billing`,onChange:e=>o(`billing`,e),onError:c,onReady:()=>l(!0),ready:r}):null,e.widget.fields.shipping?H(`div`,{className:`lockerverse-payment__shipping`,children:[V(ie,{checked:n.shippingMatchesBilling,name:`shippingMatchesBilling`,onChange:e=>{s({...n,shippingMatchesBilling:e}),e?o(`shipping`,null):d(!1)},children:`Shipping is same as billing information`}),n.shippingMatchesBilling?null:V($e,{label:`Shipping address`,mode:`shipping`,onChange:e=>o(`shipping`,e),onError:c,onReady:()=>d(!0),ready:a})]}):null]})}function nt({displayedBaseCents:e,displayedTipCents:t,displayedTotalCents:n,quote:r}){let i=qe(r.paymentOption),a=Math.max(0,e-r.subtotalCents+r.discountCents);return H(`section`,{"aria-label":`Payment summary`,className:`lockerverse-payment__payment-summary`,children:[V(`h2`,{children:`Order summary`}),V(`div`,{className:`lockerverse-payment__payment-summary-items`,children:r.lineItems.map(e=>H(`div`,{className:`lockerverse-payment__payment-summary-row`,children:[H(`span`,{children:[e.productName,e.quantity>1?H(B,{children:[` `,H(`small`,{children:[`× `,e.quantity]})]}):null,e.paymentOption===`monthly`?V(`small`,{children:` · Monthly`}):null,e.paymentOption===`annually`?V(`small`,{children:` · Annual`}):null]}),V(`strong`,{children:$(e.subtotalCents)})]},e.listingId))}),H(`div`,{className:`lockerverse-payment__payment-summary-totals`,children:[a>0?H(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail`,children:[V(`span`,{children:`Service fee`}),V(`strong`,{children:$(a)})]}):null,r.discountCents>0&&r.appliedDiscount?H(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-discount`,children:[H(`span`,{children:[r.appliedDiscount.source===`email_list`?`Email discount`:`Promo code discount`,` `,`(`,r.appliedDiscount.percentageOff,`% off)`]}),H(`strong`,{children:[`-`,$(r.discountCents)]})]}):null,t>0?H(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-detail lockerverse-payment__payment-summary-tip`,children:[V(`span`,{children:`Tip`}),V(`strong`,{children:$(t)})]}):null,H(`div`,{className:`lockerverse-payment__payment-summary-row lockerverse-payment__payment-summary-total`,children:[V(`span`,{children:i?`${i.label} total`:`Total`}),V(`strong`,{children:$(n)})]})]})]})}function rt({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isRequiredShippingReady:a,isSubmitting:o,onFieldValuesChange:s,quote:c}){let l=t===0,u=l?!e.widget.fields.shipping||r&&a:i&&r&&a,d=qe(c.paymentOption),f=l?`Complete order`:`Pay ${$(t)}`;!l&&d&&(f=`Subscribe for ${$(t)}/${d.interval}`),o&&(f=l?`Completing…`:`Processing…`);let p=`Process payment for ${$(t)} total`;return l?p=`Complete order`:d&&(p=`Start ${d.label.toLowerCase()} subscription for ${$(t)}`),H(`div`,{className:`lockerverse-payment__actions`,children:[V(oe,{amountCents:c.serviceFeeCents||Math.round(c.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4),enabled:e.widget.fields.serviceFee,onChange:s,values:n}),V(`button`,{"aria-busy":o,"aria-label":p,disabled:o||!u,type:`submit`,children:f})]})}function it(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement){n.focus();return}n instanceof RadioNodeList&&Array.from(n).find(e=>e instanceof HTMLElement)?.focus()}function at({customFieldErrors:e,emailRef:t,form:n,parsedTipSuccess:r,phoneRef:i,validationErrors:a}){if(a.email){t.current?.focus();return}if(a.phone){i.current?.focus();return}if(!r){n.querySelector(`[name="tip"]`)?.focus();return}let[o]=Object.keys(e);o&&it(n,`custom:${o}`)}function ot({email:e,emailDiscountPercentOff:t,emailErrorId:n,emailId:r,emailRef:i,errors:a,onEmailBlur:o,onEmailChange:s,onPhoneChange:c,onPhoneCountryChange:l,phone:u,phoneCountry:d,phoneEnabled:f,phoneErrorId:p,phoneId:m,phoneRef:h}){return H(`div`,{className:`lockerverse-payment__contact`,children:[V(`label`,{htmlFor:r,children:`Email`}),V(`input`,{"aria-describedby":a.email?n:void 0,"aria-invalid":a.email?`true`:void 0,autoComplete:`email`,id:r,name:`email`,onBlur:o,onChange:e=>s(e.currentTarget.value),placeholder:`name@example.com`,ref:i,type:`email`,value:e}),a.email?V(`p`,{className:`lockerverse-payment__field-message`,id:n,children:a.email}):null,t===void 0?null:H(`p`,{className:`lockerverse-payment__discount-message`,role:`status`,children:[`Your email qualifies for `,t,`% off.`]}),f?H(B,{children:[V(`label`,{htmlFor:m,children:`Phone`}),H(`div`,{className:`lockerverse-payment__phone-control`,children:[V(J,{ariaLabel:`Phone number country`,className:`lockerverse-payment__select--phone-country`,name:`phoneCountry`,onValueChange:l,options:Je,value:d}),V(`input`,{"aria-describedby":a.phone?p:void 0,"aria-invalid":a.phone?`true`:void 0,autoComplete:`tel`,id:m,inputMode:`tel`,name:`phone`,onChange:e=>c(e.currentTarget.value),placeholder:`(201) 555-0123`,ref:h,type:`tel`,value:u})]}),a.phone?V(`p`,{className:`lockerverse-payment__field-message`,id:p,children:a.phone}):null]}):null]})}function st({catalog:e,checkoutItems:t,client:n,metadata:r,onPaymentComplete:i,onPaymentRecoveryChange:o,onPaymentUncertain:s,onQuoteChange:c,onStateChange:u,quote:d,resumePayment:f}){let[p,m]=x(``),[_,v]=x(``),[y,S]=x(`US`),[C,w]=x({}),[E,D]=x({}),[O,k]=x(),[A,j]=x(!1),[M,N]=x(!1),[P,te]=x(!1),[F,I]=x({customFields:a(e.widget.customFields),customTip:``,includeServiceFee:e.widget.fields.serviceFee,memberId:``,merchSize:`M`,promoCode:``,shippingMatchesBilling:!0,tipPercent:`10`}),L=b({billing:null,shipping:null}),R=b(null),z=b(null),B=b(null),U=b(d.totalCents>0),W=Ke({catalog:e,checkoutItems:t,client:n,elements:ee(),email:p,fieldValues:F,metadata:r,onPaymentComplete:i,onPaymentRecoveryChange:o,onPaymentUncertain:s,onQuoteChange:c,onStateChange:u,quote:d,resumePayment:f,stripe:T()}),{displayedTotalCents:G,isRecovering:K,isRefreshingQuote:q,isSubmitting:J,parsedTip:Y,paymentError:ne,promoError:X,terminalMessage:ie}=W.state,oe=`lockerverse-${g()}`,se=`${oe}-email`,ce=`${se}-error`,ue=`${oe}-phone`,de=`${ue}-error`,fe=`${oe}-tip-error`,pe=(Y.success?Y.cents:null)??0,me=G-pe,he=!e.widget.fields.shipping||F.shippingMatchesBilling||P;h(()=>{J&&B.current?.focus()},[J]),h(()=>{let e=G>0;e&&!U.current&&(j(!1),N(!1)),U.current=e},[G]);function ge(e){W.commands.fieldChanged(),w(t=>{let n={...t};return delete n[e],n})}function _e(e){W.commands.fieldChanged(e.promoCode!==F.promoCode),I(e),D({}),k(void 0)}async function ve(t){t.preventDefault();let n=le({email:p,phone:Ye(_,y)},e.widget.fields.phone),r=l(e.widget.customFields,F.customFields);if(!(n.value&&Y.success)||Object.keys(r).length>0){w(n.errors),D(r),k(Y.success?void 0:Y.message),W.commands.reportValidationFailure();let e=t.currentTarget;queueMicrotask(()=>{at({customFieldErrors:r,emailRef:R,form:e,parsedTipSuccess:Y.success,phoneRef:z,validationErrors:n.errors})});return}w({}),D({}),await W.commands.submit({addresses:L.current,phone:Ye(_,y)})}return ie?V(`p`,{className:`lockerverse-payment__payment-status`,ref:B,role:`status`,tabIndex:-1,children:ie}):K?V(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:`Recovering payment…`}):H(`form`,{"aria-busy":J,className:`lockerverse-payment__form`,noValidate:!0,onSubmit:ve,children:[V(`div`,{"data-lockerverse-input-region":``,inert:J?!0:void 0,children:H(`fieldset`,{className:`lockerverse-payment__input-fieldset`,disabled:J,children:[V(nt,{displayedBaseCents:me,displayedTipCents:pe,displayedTotalCents:G,quote:d}),V(re,{enabled:e.widget.fields.tipping,error:O,errorId:fe,onChange:_e,values:F}),V(ot,{email:p,emailDiscountPercentOff:d.appliedDiscount?.source===`email_list`?d.appliedDiscount.percentageOff:void 0,emailErrorId:ce,emailId:se,emailRef:R,errors:C,onEmailBlur:()=>W.commands.refreshAuthoritativeTotal(),onEmailChange:e=>{m(e),ge(`email`)},onPhoneChange:e=>{v(e),ge(`phone`)},onPhoneCountryChange:e=>{S(e),W.commands.fieldChanged()},phone:_,phoneCountry:y,phoneEnabled:e.widget.fields.phone,phoneErrorId:de,phoneId:ue,phoneRef:z}),V(tt,{catalog:e,displayedTotalCents:G,fieldValues:F,isBillingAddressReady:M,isPaymentReady:A,isShippingAddressReady:P,onAddressChange:(e,t)=>{L.current[e]=t},onFieldValuesChange:_e,onStripeLoadError:W.commands.reportStripeLoadError,setIsBillingAddressReady:N,setIsPaymentReady:j,setIsShippingAddressReady:te}),V(ae,{customFields:e.widget.customFields,errors:E,fields:e.widget.fields,idPrefix:oe,isPromoApplying:q,onApplyPromo:W.commands.applyPromo,onChange:_e,promoError:X,values:F}),V(rt,{catalog:e,displayedTotalCents:G,fieldValues:F,isBillingAddressReady:M,isPaymentReady:A,isRequiredShippingReady:he,isSubmitting:J,onFieldValuesChange:_e,quote:d})]})}),J?V(`p`,{className:`lockerverse-payment__sr-only`,ref:B,role:`status`,tabIndex:-1,children:G===0?`Completing order…`:`Processing payment…`}):null,V(et,{message:ne})]})}function ct(){return V(o,{fieldCount:2,label:`Loading payment…`,sectionCount:2,showCheckbox:!0})}function lt({apiBaseUrl:e,branding:t,className:i,communitySlug:a,environment:o,fetch:s,metadata:c,onError:l,onPaymentComplete:u,onPaymentRecoveryChange:d,onPaymentUncertain:f,requestTimeoutMs:m,resumePayment:g,selection:v,sentryDsn:y,style:S,stripeLoader:C=E,theme:w=`dark`,widgetSlug:ee,...T}){let D=b(g).current,O=b(null),[k,A]=x(),[j,M]=x(`idle`),N=b(void 0),{retryCheckout:P,selectionError:te,session:F,updateCheckout:I}=ye({apiBaseUrl:e,communitySlug:a,environment:o,fetch:s,onError:l,paymentState:j,requestTimeoutMs:m,selection:v,sentryDsn:y,widgetSlug:ee}),L=F.phase===`ready`?F.revision:void 0,R=p(e=>{L!==void 0&&(N.current=L),M(e)},[L]);h(()=>{F.phase===`loading`&&A(void 0)},[F.phase]),_(()=>{F.phase===`ready`&&N.current!==F.revision&&M(e=>e===`success`||e===`unresolved`?e:`idle`)},[F.phase,F.revision]);let z=[`lockerverse-payment`,i].filter(Boolean).join(` `),B=t??(F.phase===`ready`?F.catalog.community:null),U=r(S?.[`--lockerverse-accent`]??B?.accentColor??`#38d77a`),W=n(U),K={...S,...S?.[`--lockerverse-accent`]!==void 0||B?.accentColor?{"--lockerverse-accent":U}:{},...W&&S?.[`--lockerverse-accent-contrast`]===void 0?{"--lockerverse-accent-contrast":W}:{}};if(te)return V(`section`,{...T,className:z,"data-lockerverse-theme":w,role:`alert`,style:K,children:te});if(F.phase===`error`)return H(`section`,{...T,className:z,"data-lockerverse-theme":w,style:K,children:[V(`p`,{role:`alert`,children:F.failure}),V(`button`,{onClick:P,type:`button`,children:`Retry`})]});if(F.phase!==`ready`)return V(`section`,{...T,"aria-busy":`true`,"aria-label":`Payment`,className:z,"data-lockerverse-theme":w,style:K,children:V(ct,{})});let{catalog:q,checkoutItems:J,client:Y,preparedCheckout:ne}=F;return H(`section`,{...T,"aria-label":`Payment`,className:z,"data-lockerverse-theme":w,"data-payment-state":j,ref:O,style:K,children:[H(`header`,{children:[q.widget.showCommunityBranding&&B?H(`div`,{className:`lockerverse-payment__branding`,children:[B.imageUrl?V(`img`,{alt:B.name,height:`48`,src:B.imageUrl,width:`48`}):null,V(`strong`,{children:B.name})]}):null,V(`h1`,{children:q.widget.title??q.widget.name}),q.widget.description?V(`p`,{children:q.widget.description}):null]}),k?V(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:k}):null,V(G,{container:O,children:V(Xe,{accentColor:U,catalog:q,checkoutItems:J,client:Y,fontFamily:S?.[`--lockerverse-font-family`]??`ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,metadata:c,onPaymentComplete:u,onPaymentRecoveryChange:d,onPaymentUncertain:f,onQuoteChange:(e,t)=>{A(t),I(e)},onStateChange:R,quote:ne,resumePayment:D,stripeLoader:C,theme:w,visualStyle:K})})]})}export{lt as t};
|
|
2
2
|
//# sourceMappingURL=lockerverse-payment.js.map
|