@aifeatures/react 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,68 +1,2 @@
1
1
  "use client";
2
- "use strict";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/index.ts
22
- var index_exports = {};
23
- __export(index_exports, {
24
- AifeaturesCaptcha: () => AifeaturesCaptcha
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/AifeaturesCaptcha.tsx
29
- var import_react = require("react");
30
- var import_react_turnstile = require("@marsidev/react-turnstile");
31
- var import_jsx_runtime = require("react/jsx-runtime");
32
- function AifeaturesCaptcha({
33
- formId,
34
- apiUrl = "https://aifeatures.dev",
35
- onVerify,
36
- onError,
37
- className
38
- }) {
39
- const [sitekey, setSitekey] = (0, import_react.useState)(null);
40
- const [isLoading, setIsLoading] = (0, import_react.useState)(true);
41
- (0, import_react.useEffect)(() => {
42
- setIsLoading(true);
43
- fetch(`${apiUrl}/f/${formId}/config`).then((r) => r.json()).then((config) => {
44
- setSitekey(config.turnstile_sitekey);
45
- setIsLoading(false);
46
- }).catch(() => {
47
- setIsLoading(false);
48
- });
49
- }, [formId, apiUrl]);
50
- if (isLoading || !sitekey) {
51
- return null;
52
- }
53
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
- import_react_turnstile.Turnstile,
55
- {
56
- siteKey: sitekey,
57
- onSuccess: onVerify,
58
- onError,
59
- onExpire: onError,
60
- options: { theme: "light" }
61
- }
62
- ) });
63
- }
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- AifeaturesCaptcha
67
- });
68
- //# sourceMappingURL=index.cjs.map
2
+ "use strict";var Ue=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var vt=Object.prototype.hasOwnProperty;var kt=(e,t)=>{for(var r in t)Ue(e,r,{get:t[r],enumerable:!0})},_t=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of St(t))!vt.call(e,i)&&i!==r&&Ue(e,i,{get:()=>t[i],enumerable:!(n=bt(t,i))||n.enumerable});return e};var wt=e=>_t(Ue({},"__esModule",{value:!0}),e);var Yt={};kt(Yt,{AddToCartButton:()=>mt,AifeaturesCaptcha:()=>Qe,BuyButton:()=>ft,CartCheckoutButton:()=>ht,MARKET_COUNTRIES:()=>Ae,MAX_CART_LINES:()=>Ke,OrderConfirmation:()=>Ct,ProductPrice:()=>ut,VariantPicker:()=>ct,ZERO_DECIMAL_CURRENCIES:()=>Me,applySelectionToUrl:()=>Re,formatPrice:()=>F,getOptions:()=>le,getVariants:()=>ne,isMultiVariant:()=>pe,isValueAvailable:()=>ke,isValueInCatalog:()=>_e,reanchorSelection:()=>we,resolveVariant:()=>ae,searchFromSelection:()=>Ce,selectedImages:()=>fe,selectedValues:()=>Ne,selectionFromSearch:()=>xe,useCart:()=>ee,useCartCheckout:()=>Ee,useCartItems:()=>Le,useCartSummary:()=>it,useCheckout:()=>Oe,useMarket:()=>st,useProduct:()=>oe,valueSlug:()=>Z,variantPriceRange:()=>Pe});module.exports=wt(Yt);var he=require("react"),Ge=require("@marsidev/react-turnstile"),Ve=require("react/jsx-runtime");function Qe({formId:e,apiUrl:t="https://aifeatures.dev",onVerify:r,onError:n,className:i}){let[o,g]=(0,he.useState)(null),[p,y]=(0,he.useState)(!0);return(0,he.useEffect)(()=>{y(!0),fetch(`${t}/f/${e}/config`).then(l=>l.json()).then(l=>{g(l.turnstile_sitekey),y(!1)}).catch(()=>{y(!1)})},[e,t]),p||!o?null:(0,Ve.jsx)("div",{className:i,children:(0,Ve.jsx)(Ge.Turnstile,{siteKey:o,onSuccess:r,onError:n,onExpire:n,options:{theme:"light"}})})}var Q=require("react"),Se=[1e3,3e3];function oe(e,t={}){let r=t.apiUrl??"https://aifeatures.dev",n=t.country??null,[i,o]=(0,Q.useState)(null),[g,p]=(0,Q.useState)(!0),[y,l]=(0,Q.useState)(null),[f,a]=(0,Q.useState)(0),h=(0,Q.useRef)(e);(0,Q.useEffect)(()=>{let c=!1,v;p(!0),l(null),h.current!==e&&(h.current=e,o(null));let w=I=>{fetch(`${r}/v1/p/${encodeURIComponent(e)}${n?`?country=${encodeURIComponent(n)}`:""}`).then(async S=>{let O=await S.json().catch(()=>null);if(!c)if(!S.ok||!O){if(S.status>=500&&I<Se.length){v=setTimeout(()=>w(I+1),Se[I]);return}l(O?.error??`Request failed (${S.status})`),o(null),p(!1)}else o(O),p(!1)}).catch(S=>{if(!c){if(I<Se.length){v=setTimeout(()=>w(I+1),Se[I]);return}l(S instanceof Error?S.message:"Failed to load product"),p(!1)}})};return w(0),()=>{c=!0,v&&clearTimeout(v)}},[e,r,n,f]);let m=(0,Q.useCallback)(()=>a(c=>c+1),[]);return{product:i,loading:g,error:y,refresh:m}}var Me=new Set(["bif","clp","djf","gnf","jpy","kmf","krw","mga","pyg","rwf","vnd","vuv","xaf","xof","xpf"]);function F(e,t,r){let n=Me.has(t.toLowerCase())?e:e/100;try{return new Intl.NumberFormat(r,{style:"currency",currency:t.toUpperCase()}).format(n)}catch{return`${n} ${t.toUpperCase()}`}}function ne(e){return e.variants??[]}function le(e){return e.options??[]}function pe(e){return le(e).length>0}function ve(e){let t={};for(let r of e.option_values)t[r.option_id]=r.value_id;return t}function ae(e,t){let r=Object.keys(t);return e.find(n=>{let i=n.option_values;return i.length!==r.length?!1:i.every(o=>t[o.option_id]===o.value_id)})??null}function ke(e,t,r,n){return e.some(i=>{let o=ve(i);if(o[r]!==n)return!1;for(let[g,p]of Object.entries(t))if(g!==r&&o[g]!==p)return!1;return!0})}function _e(e,t,r){return e.some(n=>ve(n)[t]===r)}function we(e,t,r,n){let i={[r]:n};for(let[g,p]of Object.entries(t)){if(g===r)continue;e.some(l=>{let f=ve(l);return f[r]===n&&f[g]===p})&&(i[g]=p)}return e.some(g=>{let p=ve(g);return Object.entries(i).every(([y,l])=>p[y]===l)})?i:{[r]:n}}function Pe(e){let t=e.map(r=>r.unit_amount).filter(r=>r!==null);return t.length===0?null:{min:Math.min(...t),max:Math.max(...t)}}function Ne(e,t){let r={};for(let n of le(e)){let i=t[n.id];if(!i)continue;let o=n.values.find(g=>g.id===i);o&&(r[n.title]=o.value)}return r}function Z(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function xe(e,t){let r=t instanceof URLSearchParams?t:new URLSearchParams(t),n=new Map;r.forEach((o,g)=>{n.has(Z(g))||n.set(Z(g),o)});let i={};for(let o of le(e)){let g=Z(o.title);if(g.length===0)continue;let p=n.get(g);if(p===void 0)continue;let y=Z(p);if(y.length===0)continue;let l=o.values.find(f=>Z(f.value)===y);l&&(i[o.id]=l.id)}return i}function Ce(e,t){let r={};for(let[n,i]of Object.entries(Ne(e,t))){let o=Z(n),g=Z(i);o.length===0||g.length===0||(r[o]=g)}return r}function fe(e,t){let r=[];for(let n of le(e)){let i=t[n.id];if(!i)continue;let o=n.values.find(g=>g.id===i);o?.images?.length&&r.push(...o.images)}return r.length>0?r:e.images??[]}function Re(e,t){if(typeof window>"u")return;let r=new URL(window.location.href);for(let n of le(e)){let i=Z(n.title);i.length!==0&&r.searchParams.delete(i)}for(let[n,i]of Object.entries(Ce(e,t)))r.searchParams.set(n,i);window.history.replaceState(window.history.state,"",r.toString())}var Y=require("react");var Be="aifeatures_cart",De="aifeatures_market",Ze="aifeatures_cart_cleared";var qe="aifeatures:cart-storage",be=new Map;function $e(e){if(be.has(e))return be.get(e)??null;if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Fe(e,t){if(typeof window>"u"){be.set(e,t);return}try{t===null?window.localStorage.removeItem(e):window.localStorage.setItem(e,t),be.delete(e)}catch{be.set(e,t)}Pt(e)}function Pt(e){if(!(typeof window>"u"))try{window.dispatchEvent(new CustomEvent(qe,{detail:{key:e}}))}catch{}}function He(e,t){if(typeof window>"u")return()=>{};let r=i=>{(i.key===e||i.key===null)&&t()},n=i=>{i.detail?.key===e&&t()};return window.addEventListener("storage",r),window.addEventListener(qe,n),()=>{window.removeEventListener("storage",r),window.removeEventListener(qe,n)}}function xt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.productId!="string"||t.productId.length===0||typeof t.variantId!="string"||t.variantId.length===0)return null;let r=typeof t.quantity=="number"&&Number.isFinite(t.quantity)?Math.max(1,Math.floor(t.quantity)):1,n={};if(typeof t.selection=="object"&&t.selection!==null)for(let[g,p]of Object.entries(t.selection))typeof p=="string"&&(n[g]=p);let i=typeof t.display=="object"&&t.display!==null?t.display:{},o={name:typeof i.name=="string"?i.name:"",variantTitle:typeof i.variantTitle=="string"?i.variantTitle:null,image:typeof i.image=="string"?i.image:null};return{productId:t.productId,variantId:t.variantId,quantity:r,selection:n,display:o}}function se(){let e=$e(Be);if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let r=[],n=new Set;for(let i of t){let o=xt(i);o&&!n.has(o.variantId)&&(n.add(o.variantId),r.push(o))}return r}function H(e){Fe(Be,JSON.stringify(e))}function Xe(e){return He(Be,e)}function et(e){let t=new Map;for(let n of e)!n.variantId||!(n.quantity>0)||t.set(n.variantId,(t.get(n.variantId)??0)+n.quantity);if(t.size===0)return;let r=[];for(let n of se()){let i=t.get(n.variantId);if(i===void 0){r.push(n);continue}let o=n.quantity-i;o>0&&r.push({...n,quantity:o})}H(r)}function j(){let e=$e(De);return typeof e!="string"||!/^[A-Za-z]{2}$/.test(e)?null:e.toUpperCase()}function tt(e){Fe(De,e!==null&&/^[A-Za-z]{2}$/.test(e)?e.toUpperCase():null)}function me(e){return He(De,e)}function nt(e){let t=[],r=$e(Ze);if(r)try{let i=JSON.parse(r);Array.isArray(i)&&(t=i.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.ts=="number"))}catch{}let n=Date.now()-6048e5;return t=t.filter(i=>i.ts>n),t.some(i=>i.id===e)?!1:(t.push({id:e,ts:Date.now()}),t.length>200&&(t=t.slice(-200)),Fe(Ze,JSON.stringify(t)),!0)}var Rt=1500;function je(){try{if(typeof crypto<"u"&&"randomUUID"in crypto)return crypto.randomUUID()}catch{}return`req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}function Ie(e,t){return!("requestId"in e)||e.requestId===t}function ze(e,t){return typeof window>"u"||window.self===window.top?Promise.resolve(!1):new Promise(r=>{let n=!1,i=p=>{n||(n=!0,window.removeEventListener("message",o),clearTimeout(g),r(p))},o=p=>{if(p.source!==window.parent)return;let y=p.data;y?.type==="aifeatures:test-checkout-ack"&&Ie(y,t)&&i(y.status==="accepted")},g=setTimeout(()=>i(!1),Rt);window.addEventListener("message",o);try{window.parent.postMessage({type:"aifeatures:test-checkout",requestId:t,...e},"*")}catch{i(!1)}})}function Oe(e={}){let t=e.apiUrl??"https://aifeatures.dev",[r,n]=(0,Y.useState)(!1),[i,o]=(0,Y.useState)(null),[g,p]=(0,Y.useState)(null),y=(0,Y.useRef)(!1),l=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let a=h=>{h.persisted&&(y.current=!1,n(!1))};return window.addEventListener("pageshow",a),()=>window.removeEventListener("pageshow",a)},[]),(0,Y.useEffect)(()=>{if(typeof window>"u"||window.self===window.top)return;let a=h=>{if(h.source!==window.parent)return;let m=h.data;if(m?.type!=="aifeatures:test-checkout-ack"||m.status!=="failed")return;let c=l.current;c===null||!Ie(m,c)||(l.current=null,o(typeof m.error=="string"&&m.error?m.error:"The test purchase could not be created."),y.current=!1,n(!1))};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[]),{startCheckout:(0,Y.useCallback)(async({productId:a,variantId:h,quantity:m,amount:c,metadata:v,successUrl:w,cancelUrl:I,customerEmail:S,expectedUnitAmount:O,expectedCurrency:b})=>{if(!y.current){y.current=!0,n(!0),o(null),p(null);try{let s=j(),u=await fetch(`${t}/v1/p/${a}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...h!==void 0?{variant_id:h}:{},...m!==void 0?{quantity:m}:{},...c!==void 0?{amount:c}:{},...v!==void 0?{metadata:v}:{},...S!==void 0?{customer_email:S}:{},...O!==void 0&&b!==void 0?{expected_unit_amount:O,expected_currency:b}:{},...s!==null?{country:s}:{},success_url:w??`${window.location.origin}/order/confirmation`,cancel_url:I??window.location.href})}),d=await u.json().catch(()=>null);if(!u.ok){if(d?.error==="price_changed"&&typeof d.current_unit_amount=="number"&&typeof d.currency=="string"){p({currentUnitAmount:d.current_unit_amount,currency:d.currency}),o(`The price has changed to ${F(d.current_unit_amount,d.currency)} \u2014 please review and try again.`),y.current=!1,n(!1);return}if(d?.code==="preview_domain"){let C=je();if(l.current=C,await ze({productId:a,...h!==void 0?{variantId:h}:{},...m!==void 0?{quantity:m}:{},...c!==void 0?{amount:c}:{},...S!==void 0?{customerEmail:S}:{}},C))return;l.current=null}o(d?.error??`Checkout failed (${u.status})`),y.current=!1,n(!1);return}if(!d?.url){o("Checkout failed: no redirect URL returned"),y.current=!1,n(!1);return}if(window.self!==window.top)try{window.top.location.href=d.url;return}catch{if(window.open(d.url,"_blank")){y.current=!1,n(!1);return}}window.location.href=d.url}catch(s){o(s instanceof Error?s.message:"Checkout failed"),y.current=!1,n(!1)}}},[t]),loading:r,error:i,priceChange:g}}var X=require("react");var Ke=20;function rt(e){return typeof e!="number"||!Number.isFinite(e)?1:Math.max(1,Math.floor(e))}function ee(){let[e,t]=(0,X.useState)([]),[r,n]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let l=()=>t(se());return l(),n(!0),Xe(l)},[]);let i=(0,X.useCallback)(l=>{let f=se(),a=rt(l.quantity);return f.find(m=>m.variantId===l.variantId)?(H(f.map(m=>m.variantId===l.variantId?{...m,quantity:m.quantity+a,selection:l.selection??m.selection,display:l.display}:m)),{ok:!0}):f.length>=Ke?{ok:!1,reason:"cart_full"}:(H([...f,{productId:l.productId,variantId:l.variantId,quantity:a,selection:l.selection??{},display:l.display}]),{ok:!0})},[]),o=(0,X.useCallback)(l=>{H(se().filter(f=>f.variantId!==l))},[]),g=(0,X.useCallback)((l,f)=>{let a=se();if(f<=0){H(a.filter(m=>m.variantId!==l));return}let h=rt(f);H(a.map(m=>m.variantId===l?{...m,quantity:h}:m))},[]),p=(0,X.useCallback)(()=>{H([])},[]),y=e.reduce((l,f)=>l+f.quantity,0);return{items:e,count:y,hydrated:r,add:i,remove:o,setQuantity:g,clear:p}}var M=require("react");var Te={image:null,unitAmount:null,currency:null,baseCurrency:null,inStock:!1,available:null,maxQuantity:null,pdpSearch:{},status:"unavailable"},It={...Te,inStock:!0,status:"error"};function Ot(e){let t={};for(let r of e.option_values)t[r.option_id]=r.value_id;return t}function Le(e={}){let t=e.apiUrl??"https://aifeatures.dev",{items:r,hydrated:n}=ee(),[i,o]=(0,M.useState)({}),[g,p]=(0,M.useState)({shippingRates:null,freeShippingOver:null,shippingCountries:null}),[y,l]=(0,M.useState)(!0),[f,a]=(0,M.useState)(null),[h,m]=(0,M.useState)(0),c=(0,M.useRef)(new Set),v=(0,M.useMemo)(()=>JSON.stringify(r.map(b=>[b.productId,b.variantId,b.selection])),[r]),w=(0,M.useCallback)(()=>m(b=>b+1),[]);(0,M.useEffect)(()=>me(w),[w]),(0,M.useEffect)(()=>{if(!n)return;if(r.length===0){o({}),p({shippingRates:null,freeShippingOver:null,shippingCountries:null}),a(null),l(!1);return}let b=!1;l(!0);let s=r,u=[...new Set(s.map(C=>C.productId))],d=async C=>{let R=new Map;return await Promise.all(u.map(async T=>{try{let P=await fetch(`${t}/v1/p/${encodeURIComponent(T)}${C?`?country=${encodeURIComponent(C)}`:""}`);if(P.status===404){R.set(T,{kind:"not_found"});return}if(!P.ok){R.set(T,{kind:"error",message:`Request failed (${P.status})`});return}let x=await P.json();R.set(T,{kind:"ok",product:x})}catch(P){R.set(T,{kind:"error",message:P instanceof Error?P.message:"Failed to load product"})}})),R};return(async()=>{let C=j(),R=await d(C);if(C){let k=[...R.values()].filter(A=>A.kind==="ok"),L=k.filter(A=>A.product.base_currency);L.length>0&&L.length<k.length&&(R=await d(null))}if(b)return;let T=null,P=null,x=null;for(let k of u){let L=R.get(k);!L||L.kind!=="ok"||(T===null&&L.product.shipping_rates&&(T=L.product.shipping_rates),P===null&&L.product.free_shipping_over!=null&&(P=L.product.free_shipping_over),x===null&&L.product.shipping_countries&&(x=L.product.shipping_countries))}let E={},B=new Map,ue=null;for(let k of s){let L=R.get(k.productId);if(!L||L.kind==="error"){E[k.variantId]=It,L&&ue===null&&(ue=L.message);continue}if(L.kind==="not_found"){E[k.variantId]=Te;continue}let{product:A}=L;if(!A.active||A.purchasable===!1){E[k.variantId]=Te;continue}let K=A.variants??[],G=K.find(ie=>ie.id===k.variantId)??null,W=k.variantId;if(!G){let ie=ae(K,k.selection);if(!ie){E[k.variantId]=Te;continue}let Je=B.get(k.variantId)??{};Je.reanchorTo={variantId:ie.id,selection:Ot(ie)},B.set(k.variantId,Je),c.current.add(ie.id),G=ie,W=ie.id}let D=fe(A,k.selection)[0]??null,ye={image:D,unitAmount:G.unit_amount,currency:G.currency,baseCurrency:A.base_currency??null,inStock:G.in_stock,available:G.available,maxQuantity:A.max_quantity,pdpSearch:Ce(A,k.selection),status:c.current.has(W)?"reanchored":"ok"};E[k.variantId]=ye,E[W]=ye;let Ye=B.get(k.variantId)??{};Ye.display={name:A.name,variantTitle:G.title,image:D},B.set(k.variantId,Ye)}let $=new Set(s.map(k=>k.variantId));for(let k of[...c.current])!$.has(k)&&!(k in E)&&c.current.delete(k);if(B.size>0){let k=se(),L=[],A=new Map,K=!1;for(let G of k){let W=B.get(G.variantId),D={...G};W?.reanchorTo&&(D.variantId=W.reanchorTo.variantId,D.selection=W.reanchorTo.selection,K=!0),W?.display&&(D.display.name!==W.display.name||D.display.variantTitle!==W.display.variantTitle||D.display.image!==W.display.image)&&(D.display=W.display,K=!0);let ye=A.get(D.variantId);if(ye){ye.quantity+=D.quantity,K=!0;continue}L.push(D),A.set(D.variantId,D)}K&&H(L)}b||(o(E),p({shippingRates:T,freeShippingOver:P,shippingCountries:x}),a(ue),l(!1))})(),()=>{b=!0}},[n,v,t,h]);let I=(0,M.useMemo)(()=>r.map(b=>{let s=i[b.variantId];return s?{...b,...s,image:s.image??b.display.image}:{...b,image:b.display.image,unitAmount:null,currency:null,baseCurrency:null,inStock:!0,available:null,maxQuantity:null,pdpSearch:{},status:"ok"}}),[r,i]),{subtotal:S,currency:O}=(0,M.useMemo)(()=>{let b=0,s=null;for(let u of I)u.unitAmount===null||u.currency===null||(b+=u.unitAmount*u.quantity,s=s??u.currency);return{subtotal:b,currency:s}},[I]);return{lines:I,subtotal:S,currency:O,shippingRates:g.shippingRates,freeShippingOver:g.freeShippingOver,shippingCountries:g.shippingCountries,loading:y,error:f,refresh:w}}var N=require("react");var Tt=2e3;function it(e={}){let t=e.apiUrl??"https://aifeatures.dev",r=e.debounceMs??250,n=e.shippingOption??null,{items:i,hydrated:o}=ee(),[g,p]=(0,N.useState)(null),[y,l]=(0,N.useState)(!1),[f,a]=(0,N.useState)(null),[h,m]=(0,N.useState)(null),[c,v]=(0,N.useState)(0);(0,N.useEffect)(()=>(m(j()),me(()=>m(j()))),[]);let w=(0,N.useMemo)(()=>i.map(s=>`${s.variantId}:${s.quantity}`).sort().join(","),[i]),I=(0,N.useCallback)(()=>v(s=>s+1),[]),S=(0,N.useRef)(0),O=(0,N.useRef)(!1),b=(0,N.useRef)("idle");return(0,N.useEffect)(()=>{if(!o)return;if(i.length===0){p(null),a(null),l(!1);return}let s=++S.current,u=new AbortController,d=!1,C,R=O.current?r:0;O.current=!0,b.current=b.current==="pending"?"spent":"idle";let T=setTimeout(async()=>{l(!0);try{let P=await fetch(`${t}/v1/p/checkout/summary`,{method:"POST",headers:{"Content-Type":"application/json"},signal:u.signal,body:JSON.stringify({items:i.map(E=>({variant_id:E.variantId,quantity:E.quantity})),...h?{country:h}:{},...n?{shipping_option:n}:{}})});if(d||s!==S.current)return;if(!P.ok){if(P.status===429){let E=b.current==="idle";E&&(C=setTimeout(()=>{d||s!==S.current||(b.current="pending",v(B=>B+1))},Tt)),a(E?"Too many updates \u2014 retrying shortly":"Too many updates \u2014 the total will refresh on the next cart change")}else a(`Could not price this cart (${P.status})`);return}let x=await P.json();if(d||s!==S.current)return;p({currency:x.currency,subtotal:x.subtotal,shipping:x.shipping?{options:x.shipping.options.map(E=>({label:E.label,amount:E.amount,undiscountedAmount:E.undiscounted_amount})),selectedAmount:x.shipping.selected_amount,selectedLabel:x.shipping.selected_label,freeShippingOver:x.shipping.free_shipping_over,freeShippingCurrency:x.shipping.free_shipping_currency,thresholdMet:x.shipping.threshold_met,collectsAddress:x.shipping.collects_address}:null,total:x.total,totalIsFinal:x.total_is_final,tax:x.tax??null,unavailableVariantIds:x.unavailable_variant_ids}),a(null)}catch(P){if(d||u.signal.aborted||s!==S.current)return;a(P instanceof Error?P.message:"Could not price this cart")}finally{!d&&s===S.current&&l(!1)}},R);return()=>{d=!0,clearTimeout(T),C!==void 0&&clearTimeout(C),u.abort()}},[o,w,h,t,r,n,c]),{summary:g,loading:y,error:f,refresh:I}}var z=require("react");function Ee(e={}){let t=e.apiUrl??"https://aifeatures.dev",[r,n]=(0,z.useState)(!1),[i,o]=(0,z.useState)(null),[g,p]=(0,z.useState)(null),[y,l]=(0,z.useState)(null),f=(0,z.useRef)(!1),a=(0,z.useRef)(null);return(0,z.useEffect)(()=>{let m=c=>{c.persisted&&(f.current=!1,n(!1))};return window.addEventListener("pageshow",m),()=>window.removeEventListener("pageshow",m)},[]),(0,z.useEffect)(()=>{if(typeof window>"u"||window.self===window.top)return;let m=c=>{if(c.source!==window.parent)return;let v=c.data;if(v?.type!=="aifeatures:test-checkout-ack"||v.status!=="failed")return;let w=a.current;w===null||!Ie(v,w)||(a.current=null,o(typeof v.error=="string"&&v.error?v.error:"The test purchase could not be created."),f.current=!1,n(!1))};return window.addEventListener("message",m),()=>window.removeEventListener("message",m)},[]),{startCheckout:(0,z.useCallback)(async(m,{successUrl:c,cancelUrl:v,customerEmail:w,metadata:I,shippingOption:S}={})=>{if(!f.current){f.current=!0,n(!0),o(null),p(null),l(null);try{let O=j(),b=await fetch(`${t}/v1/p/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:m.map(u=>({variant_id:u.variantId,quantity:u.quantity,...typeof u.unitAmount=="number"&&typeof u.currency=="string"?{expected_unit_amount:u.unitAmount,expected_currency:u.currency}:{}})),...O!==null?{country:O}:{},...S?{shipping_option:S}:{},...I!==void 0?{metadata:I}:{},...w!==void 0?{customer_email:w}:{},success_url:c??`${window.location.origin}/order/confirmation`,cancel_url:v??window.location.href})}),s=await b.json().catch(()=>null);if(!b.ok){if(s?.code==="shipping_option_unavailable"&&typeof s.requested=="string"&&Array.isArray(s.available)){l({requested:s.requested,available:s.available,currency:typeof s.currency=="string"?s.currency:""}),f.current=!1,n(!1);return}if(s?.error==="cart_conflict"&&Array.isArray(s.items)){let u={};for(let d of s.items)d&&typeof d.variant_id=="string"&&(u[d.variant_id]=d);p(u),f.current=!1,n(!1);return}if(s?.code==="preview_domain"){let u=je();if(a.current=u,await ze({items:m.map(C=>({productId:C.productId,variantId:C.variantId,quantity:C.quantity})),...w!==void 0?{customerEmail:w}:{}},u))return;a.current=null}o(s?.error??`Checkout failed (${b.status})`),f.current=!1,n(!1);return}if(!s?.url){o("Checkout failed: no redirect URL returned"),f.current=!1,n(!1);return}if(window.self!==window.top)try{window.top.location.href=s.url;return}catch{if(window.open(s.url,"_blank")){f.current=!1,n(!1);return}}window.location.href=s.url}catch(O){o(O instanceof Error?O.message:"Checkout failed"),f.current=!1,n(!1)}}},[t]),loading:r,error:i,conflicts:g,shippingConflict:y}}var re=require("react");var Ae=[{country:"US",currency:"usd"},{country:"GB",currency:"gbp"},{country:"CA",currency:"cad"},{country:"AU",currency:"aud"},{country:"NZ",currency:"nzd"},{country:"JP",currency:"jpy"},{country:"CH",currency:"chf"},{country:"SE",currency:"sek"},{country:"NO",currency:"nok"},{country:"DK",currency:"dkk"},{country:"PL",currency:"pln"},{country:"CZ",currency:"czk"},{country:"SG",currency:"sgd"},{country:"HK",currency:"hkd"},{country:"MX",currency:"mxn"},{country:"BR",currency:"brl"},{country:"IN",currency:"inr"},{country:"ZA",currency:"zar"},{country:"AE",currency:"aed"},{country:"IL",currency:"ils"},{country:"AT",currency:"eur"},{country:"BE",currency:"eur"},{country:"HR",currency:"eur"},{country:"CY",currency:"eur"},{country:"EE",currency:"eur"},{country:"FI",currency:"eur"},{country:"FR",currency:"eur"},{country:"DE",currency:"eur"},{country:"GR",currency:"eur"},{country:"IE",currency:"eur"},{country:"IT",currency:"eur"},{country:"LV",currency:"eur"},{country:"LT",currency:"eur"},{country:"LU",currency:"eur"},{country:"MT",currency:"eur"},{country:"NL",currency:"eur"},{country:"PT",currency:"eur"},{country:"SK",currency:"eur"},{country:"SI",currency:"eur"},{country:"ES",currency:"eur"}];function ot(e){return e?Ae.find(t=>t.country===e.toUpperCase())?.currency??null:null}var at=new Map;function Lt(e){let t=at.get(e);return t||(t=fetch(`${e}/v1/geo`).then(async r=>{if(!r.ok)return null;let n=await r.json().catch(()=>null);return typeof n?.country=="string"&&/^[A-Za-z]{2}$/.test(n.country)?n.country.toUpperCase():null}).catch(()=>null),at.set(e,t)),t}function st(e={}){let t=e.apiUrl??"https://aifeatures.dev",[r,n]=(0,re.useState)(null),[i,o]=(0,re.useState)(!1),[g,p]=(0,re.useState)(null);(0,re.useEffect)(()=>{let a=()=>n(j());return a(),o(!0),me(a)},[]),(0,re.useEffect)(()=>{let a=!1;return Lt(t).then(h=>{a||p(h)}),()=>{a=!0}},[t]);let y=(0,re.useCallback)(a=>{tt(a)},[]),l=ot(g),f=i&&l!==null&&l!==ot(r);return{market:r,suggestedCountry:g,setMarket:y,markets:Ae,shouldPrompt:f}}var ge=require("react/jsx-runtime"),Et={textDecoration:"line-through",opacity:.6,marginRight:"0.4em"};function ut({productId:e,variantId:t,apiUrl:r,locale:n,className:i,style:o,compareAtClassName:g}){let{product:p,loading:y}=oe(e,{apiUrl:r});if(y||!p)return null;let l=ne(p),f=t!==void 0?l.find(h=>h.id===t)??null:p.options.length===0?l[0]??null:null;if(f){if(f.unit_amount===null)return null;let h=f.compare_at_amount!==null&&f.compare_at_amount>f.unit_amount;return(0,ge.jsxs)("span",{className:i,style:o,children:[h&&(0,ge.jsx)("span",{className:g,style:g?void 0:Et,children:F(f.compare_at_amount,f.currency,n)}),F(f.unit_amount,f.currency,n)]})}let a=Pe(l);return a?(0,ge.jsx)("span",{className:i,style:o,children:a.min===a.max?F(a.min,p.currency,n):`${F(a.min,p.currency,n)} \u2013 ${F(a.max,p.currency,n)}`}):p.unit_amount===null?null:(0,ge.jsx)("span",{className:i,style:o,children:F(p.unit_amount,p.currency,n)})}var te=require("react");var ce=require("react/jsx-runtime"),At={marginBottom:"0.75rem"},Ut={display:"block",fontSize:"0.875rem",fontWeight:600,marginBottom:"0.375rem"},Vt={display:"flex",flexWrap:"wrap",gap:"0.5rem"},Mt={padding:"0.375rem 0.75rem",border:"1px solid #d1d5db",borderRadius:6,background:"white",cursor:"pointer",fontSize:"0.875rem"},Nt={borderColor:"#111827",boxShadow:"inset 0 0 0 1px #111827",fontWeight:600},lt={opacity:.4,textDecoration:"line-through",cursor:"not-allowed"},qt={...lt,cursor:"pointer"};function ct({options:e,variants:t,value:r,syncUrl:n=!0,onChange:i,onVariantChange:o,className:g,style:p,optionClassName:y,optionLabelClassName:l,valueClassName:f,selectedValueClassName:a,unavailableValueClassName:h}){let m=r!==void 0,[c,v]=(0,te.useState)(r??{}),w=m?r:c,I=(0,te.useRef)(!1);(0,te.useEffect)(()=>{if(!n||m||I.current||e.length===0||typeof window>"u"||(I.current=!0,Object.keys(c).length>0))return;let s=xe({options:e},window.location.search);Object.keys(s).length!==0&&(v(s),i?.(s))},[n,m,e]);let S=(0,te.useMemo)(()=>e.length>0?t.filter(s=>s.option_values.length===e.length):t,[t,e]),O=(0,te.useRef)(void 0);if((0,te.useEffect)(()=>{let s=ae(S,w),u=s?.id??null;O.current!==u&&(O.current=u,o?.(s))},[S,w]),e.length===0)return null;let b=(s,u)=>{let d=we(S,w,s,u);m||(v(d),n&&Re({options:e},d)),i?.(d)};return(0,ce.jsx)("div",{className:g,style:p,children:e.map(s=>(0,ce.jsxs)("div",{className:y,style:y?void 0:At,children:[(0,ce.jsx)("span",{className:l,style:l?void 0:Ut,children:s.title}),(0,ce.jsx)("div",{style:Vt,children:s.values.map(u=>{let d=w[s.id]===u.id,C=ke(S,w,s.id,u.id),R=C||_e(S,s.id,u.id),T=[f,d?a:void 0,C?void 0:h].filter(Boolean).join(" ")||void 0,P=f?void 0:{...Mt,...d?Nt:{},...C?{}:R?qt:lt};return(0,ce.jsx)("button",{type:"button",className:T,style:P,disabled:!R,"aria-pressed":d,"data-selected":d?"true":void 0,"data-available":C?"true":"false",onClick:()=>b(s.id,u.id),children:u.value},u.id)})})]},s.id))})}var pt=require("react");var U=require("react/jsx-runtime"),Bt={color:"#b91c1c",fontSize:"0.875rem",marginTop:"0.5rem"},Dt={background:"none",border:"none",padding:0,marginLeft:"0.35em",font:"inherit",color:"inherit",textDecoration:"underline",cursor:"pointer"};function dt(){return(0,U.jsxs)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",style:{display:"inline-block",marginRight:"0.5em",verticalAlign:"-0.125em",flexShrink:0},children:[(0,U.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"3"}),(0,U.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:(0,U.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.8s",repeatCount:"indefinite"})})]})}function ft({productId:e,variantId:t,quantity:r,amount:n,metadata:i,successUrl:o,cancelUrl:g,customerEmail:p,apiUrl:y,disabled:l,className:f,style:a,errorClassName:h,spinner:m=!0,children:c}){let{product:v,loading:w,error:I,refresh:S}=oe(e,{apiUrl:y}),{startCheckout:O,loading:b,error:s,priceChange:u}=Oe({apiUrl:y});(0,pt.useEffect)(()=>{u&&S()},[u,S]);let d=v!==null&&!v.payments_ready,C=v!==null&&!v.active,R=v!==null&&v.purchasable===!1,T=v!==null&&pe(v),P=v!==null?ne(v):[],x=t!==void 0?P.find(A=>A.id===t)??null:!T&&P.length===1?P[0]:null,E=T&&!x,B=x!==null&&!x.in_stock,ue=!!l||w||!v||d||C||R||E||B||b,$;b?$=(0,U.jsxs)(U.Fragment,{children:[m&&(0,U.jsx)(dt,{}),"Processing\u2026"]}):w?$=(0,U.jsxs)(U.Fragment,{children:[m&&(0,U.jsx)(dt,{}),c??"Buy now"]}):d?$="Payments not set up":C||R?$="Unavailable":E?$="Select options":B?$="Out of stock":c!==void 0?$=c:$="Buy now";let k=s??I;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)("button",{type:"button",className:f,style:a,disabled:ue,onClick:()=>{let A=n===void 0&&j()===null&&x!==null&&!x.allow_custom_amount&&typeof x.unit_amount=="number"?{expectedUnitAmount:x.unit_amount,expectedCurrency:x.currency}:{};O({productId:e,variantId:t,quantity:r,amount:n,metadata:i,successUrl:o,cancelUrl:g,customerEmail:p,...A})},children:$}),k&&(0,U.jsxs)("div",{role:"alert",className:h,style:h?void 0:Bt,children:[k,v===null&&!w&&I!==null&&(0,U.jsx)("button",{type:"button",onClick:S,style:Dt,children:"Tap to retry"})]})]})}var de=require("react");var q=require("react/jsx-runtime"),$t={color:"#b91c1c",fontSize:"0.875rem",marginTop:"0.5rem"},Ft={background:"none",border:"none",padding:0,marginLeft:"0.35em",font:"inherit",color:"inherit",textDecoration:"underline",cursor:"pointer"},jt=1500;function zt(){return(0,q.jsxs)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",style:{display:"inline-block",marginRight:"0.5em",verticalAlign:"-0.125em",flexShrink:0},children:[(0,q.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"3"}),(0,q.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:(0,q.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.8s",repeatCount:"indefinite"})})]})}function Kt(e){let t={};for(let r of e.option_values)t[r.option_id]=r.value_id;return t}function mt({productId:e,variantId:t,selection:r,quantity:n,apiUrl:i,disabled:o,className:g,style:p,errorClassName:y,spinner:l=!0,children:f}){let{product:a,loading:h,error:m,refresh:c}=oe(e,{apiUrl:i}),{add:v}=ee(),[w,I]=(0,de.useState)(!1),[S,O]=(0,de.useState)(!1),b=(0,de.useRef)(void 0);(0,de.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let s=a!==null&&!a.payments_ready,u=a!==null&&!a.active,d=a!==null&&a.purchasable===!1,C=a!==null&&!h&&ne(a).length===0,R=a!==null&&a.allow_custom_amount,T=a!==null&&pe(a),P=a!==null?ne(a):[],x=t!==void 0?P.find(K=>K.id===t)??null:r!==void 0&&T?ae(P,r):!T&&P.length===1?P[0]:null,E=a!==null&&!C&&!x,B=x!==null&&!x.in_stock,ue=!!o||h||!a||s||u||d||C||R||E||B,$=()=>{if(!a||!x)return;let K=r??Kt(x);if(!v({productId:e,variantId:x.id,quantity:n,selection:K,display:{name:a.name,variantTitle:x.title,image:fe(a,K)[0]??null}}).ok){I(!0);return}I(!1),O(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>O(!1),jt)},k;h?k=(0,q.jsxs)(q.Fragment,{children:[l&&(0,q.jsx)(zt,{}),f??"Add to cart"]}):s?k="Payments not set up":u||d||C||R?k="Unavailable":E?k="Select options":B?k="Out of stock":S?k="Added to cart":f!==void 0?k=f:k="Add to cart";let L=w?"Your cart is full \u2014 remove an item before adding another.":m;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)("button",{type:"button",className:g,style:p,disabled:ue,"data-added":S?"true":void 0,onClick:$,children:k}),L&&(0,q.jsxs)("div",{role:"alert",className:y,style:y?void 0:$t,children:[L,a===null&&!h&&m!==null&&!w&&(0,q.jsx)("button",{type:"button",onClick:c,style:Ft,children:"Tap to retry"})]})]})}var V=require("react/jsx-runtime"),gt={color:"#b91c1c",fontSize:"0.875rem",marginTop:"0.5rem"};function yt(){return(0,V.jsxs)("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",style:{display:"inline-block",marginRight:"0.5em",verticalAlign:"-0.125em",flexShrink:0},children:[(0,V.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"3"}),(0,V.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:(0,V.jsx)("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.8s",repeatCount:"indefinite"})})]})}function ht({apiUrl:e,successUrl:t,cancelUrl:r,customerEmail:n,metadata:i,shippingOption:o,disabled:g,className:p,style:y,errorClassName:l,spinner:f=!0,children:a}){let{items:h,hydrated:m}=ee(),{lines:c}=Le({apiUrl:e}),{startCheckout:v,loading:w,error:I,conflicts:S}=Ee({apiUrl:e}),O=m&&h.length===0,b=c.some(C=>C.status==="unavailable"),s=!!g||!m||O||b||w,u;w?u=(0,V.jsxs)(V.Fragment,{children:[f&&(0,V.jsx)(yt,{}),"Processing\u2026"]}):m?O?u="Cart is empty":b?u="Remove unavailable items":a!==void 0?u=a:u="Checkout":u=(0,V.jsxs)(V.Fragment,{children:[f&&(0,V.jsx)(yt,{}),a??"Checkout"]});let d=S?Object.keys(S).length:0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)("button",{type:"button",className:p,style:y,disabled:s,onClick:()=>v(c,{successUrl:t,cancelUrl:r,customerEmail:n,metadata:i,shippingOption:o}),children:u}),d>0&&(0,V.jsx)("div",{role:"alert",className:l,style:l?void 0:gt,children:d===1?"An item in your cart changed \u2014 please review your cart and try again.":`${d} items in your cart changed \u2014 please review your cart and try again.`}),I&&(0,V.jsx)("div",{role:"alert",className:l,style:l?void 0:gt,children:I})]})}var J=require("react");var _=require("react/jsx-runtime"),We="af_order_confirmation_session",Wt=1800*1e3;function Ct({apiUrl:e="https://aifeatures.dev",className:t,style:r,sessionId:n,pollIntervalMs:i=2e3,pollTimeoutMs:o=6e4,followRedirect:g=!0,redirectDelayMs:p=1500,renderNoSession:y,renderPending:l,renderPaid:f,renderFailed:a}){let[h,m]=(0,J.useState)(n),[c,v]=(0,J.useState)(null),[w,I]=(0,J.useState)(!1),S=(0,J.useRef)(void 0);(0,J.useEffect)(()=>{if(n!==void 0){m(n);return}if(S.current!==void 0){m(S.current);return}let u=new URL(window.location.href),d=u.searchParams.get("session_id");if(d){u.searchParams.delete("session_id"),window.history.replaceState(window.history.state,"",u.toString());try{sessionStorage.setItem(We,JSON.stringify({id:d,ts:Date.now()}))}catch{}}else try{let C=sessionStorage.getItem(We);if(C){let R=JSON.parse(C);typeof R.id=="string"&&typeof R.ts=="number"&&Date.now()-R.ts<=Wt?d=R.id:sessionStorage.removeItem(We)}}catch{}S.current=d,m(d)},[n]),(0,J.useEffect)(()=>{if(!h)return;let u=!1,d,C=Date.now(),R=async()=>{try{let T=await fetch(`${e}/v1/o/session/${encodeURIComponent(h)}`);if(T.ok){let P=await T.json();if(u||(v(P),P.status!=="pending"))return}}catch{}if(!u){if(Date.now()-C>=o){I(!0);return}d=setTimeout(R,i)}};return R(),()=>{u=!0,d&&clearTimeout(d)}},[h,e,i,o]);let O=c!==null&&(c.status==="paid"||c.status==="partially_refunded"),b=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(!h||c===null||b.current||!(c.status==="paid"||c.status==="partially_refunded"||c.is_test===!0)||(b.current=!0,!nt(h)))return;let d=(c.line_items??[]).filter(C=>typeof C.variant_id=="string"&&C.variant_id.length>0).map(C=>({variantId:C.variant_id,quantity:C.quantity}));d.length>0&&et(d)},[h,c]);let s=O&&c.fulfillment.type==="redirect"?c.fulfillment.redirect_url:void 0;if((0,J.useEffect)(()=>{if(!s||!g)return;let u=setTimeout(()=>{window.location.href=s},p);return()=>clearTimeout(u)},[s,g,p]),h===void 0)return null;if(h===null)return y?(0,_.jsx)(_.Fragment,{children:y()}):(0,_.jsxs)("div",{className:t,style:r,children:[(0,_.jsx)("h2",{children:"Thank you for your order!"}),(0,_.jsx)("p",{children:"If you completed a payment, a confirmation email with your receipt and any download links is on its way to you. This page can only show live order details right after checkout."})]});if(!c||c.status==="pending")return l?(0,_.jsx)(_.Fragment,{children:l({timedOut:w})}):(0,_.jsx)("div",{className:t,style:r,role:"status",children:(0,_.jsx)("p",{children:w?"This is taking longer than expected. You will receive an email confirmation once your payment is processed.":"Confirming your payment\u2026"})});if(O){if(f)return(0,_.jsx)(_.Fragment,{children:f(c)});let{fulfillment:u}=c,d=c.amount_total!==void 0&&c.currency?F(c.amount_total,c.currency):null,C=u.files??[],R=C.length===0?u.download_url:void 0;return(0,_.jsxs)("div",{className:t,style:r,children:[(0,_.jsx)("h2",{children:"Thank you for your purchase!"}),c.is_test&&(0,_.jsxs)("p",{children:[(0,_.jsx)("strong",{children:"Test purchase"})," \u2014 no payment was collected."]}),c.line_items&&c.line_items.length>0&&(0,_.jsx)("ul",{children:c.line_items.map((T,P)=>(0,_.jsxs)("li",{children:[T.quantity>1?`${T.quantity} \xD7 `:"",T.name,T.refunded&&(0,_.jsx)("em",{children:T.refund_reason==="oversold"?" \u2014 sold out and refunded; check your email for details":" \u2014 refunded"})]},P))}),d&&(0,_.jsxs)("p",{children:["Total paid: ",d]}),C.length>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:"Your downloads:"}),(0,_.jsx)("ul",{children:C.map((T,P)=>(0,_.jsx)("li",{children:(0,_.jsx)("a",{href:T.download_url,children:T.name})},P))})]}),R&&(0,_.jsx)("p",{children:(0,_.jsx)("a",{href:R,children:"Download your file"})}),s?(0,_.jsxs)("p",{children:["Taking you to your content\u2026"," ",(0,_.jsx)("a",{href:s,children:"Continue if you are not redirected"})]}):u.redirect_url?(0,_.jsx)("p",{children:(0,_.jsx)("a",{href:u.redirect_url,children:"Continue to your content"})}):null,C.length===0&&!R&&!u.redirect_url&&(0,_.jsx)("p",{children:"A confirmation email is on its way to you."}),c.order_id&&(0,_.jsxs)("p",{children:["Order reference: ",(0,_.jsx)("code",{children:c.order_id})," \u2014 keep this if you ever need help with your order."]})]})}return a?(0,_.jsx)(_.Fragment,{children:a(c)}):(0,_.jsx)("div",{className:t,style:r,children:(0,_.jsx)("p",{children:"We couldn't confirm your payment. If you were charged, you'll receive an email confirmation \u2014 otherwise you can safely try again."})})}0&&(module.exports={AddToCartButton,AifeaturesCaptcha,BuyButton,CartCheckoutButton,MARKET_COUNTRIES,MAX_CART_LINES,OrderConfirmation,ProductPrice,VariantPicker,ZERO_DECIMAL_CURRENCIES,applySelectionToUrl,formatPrice,getOptions,getVariants,isMultiVariant,isValueAvailable,isValueInCatalog,reanchorSelection,resolveVariant,searchFromSelection,selectedImages,selectedValues,selectionFromSearch,useCart,useCartCheckout,useCartItems,useCartSummary,useCheckout,useMarket,useProduct,valueSlug,variantPriceRange});