@clickaroo/checkout-ui 0.1.3-beta → 0.1.4-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/index.mjs +1 -1
  3. package/dist/storybook/storybook-static/assets/APIs.en-Bf5J1Ifk.js +372 -0
  4. package/dist/storybook/storybook-static/assets/APIs.en-DSVQkUt3.js +372 -0
  5. package/dist/storybook/storybook-static/assets/APIs.en-m6cq4XTv.js +372 -0
  6. package/dist/storybook/storybook-static/assets/CheckoutPage-BsnzMxJk.js +3 -0
  7. package/dist/storybook/storybook-static/assets/CheckoutPage-CrHN6Fcv.js +3 -0
  8. package/dist/storybook/storybook-static/assets/CheckoutPage-DYMMhAMX.js +3 -0
  9. package/dist/storybook/storybook-static/assets/CheckoutPage.en-BeknEgWZ.js +147 -0
  10. package/dist/storybook/storybook-static/assets/CheckoutPage.en-C5I1UUQc.js +147 -0
  11. package/dist/storybook/storybook-static/assets/CheckoutPage.en-DiHMI_iH.js +147 -0
  12. package/dist/storybook/storybook-static/assets/CheckoutPage.stories-DAo0u2QI.js +44 -0
  13. package/dist/storybook/storybook-static/assets/CheckoutPage.stories-DLD3oWo_.js +44 -0
  14. package/dist/storybook/storybook-static/assets/CheckoutPage.stories-DeC6lyzr.js +44 -0
  15. package/dist/storybook/storybook-static/assets/Color-YHDXOIA2-B_hoSOu5.js +1 -0
  16. package/dist/storybook/storybook-static/assets/Color-YHDXOIA2-Bly_OAJP.js +1 -0
  17. package/dist/storybook/storybook-static/assets/Color-YHDXOIA2-DI94E3AI.js +1 -0
  18. package/dist/storybook/storybook-static/assets/CustomCheckout.en-Bg4oz9hS.js +211 -0
  19. package/dist/storybook/storybook-static/assets/CustomCheckout.en-CckpRGsp.js +211 -0
  20. package/dist/storybook/storybook-static/assets/CustomCheckout.en-D80ZpldF.js +211 -0
  21. package/dist/storybook/storybook-static/assets/CustomCheckout.stories-CKQKzMq0.js +6 -0
  22. package/dist/storybook/storybook-static/assets/CustomCheckout.stories-F2GZKkIG.js +6 -0
  23. package/dist/storybook/storybook-static/assets/CustomCheckout.stories-V2NHLbZo.js +6 -0
  24. package/dist/storybook/storybook-static/assets/CustomerInfo-CTx1dFS3.js +1 -0
  25. package/dist/storybook/storybook-static/assets/CustomerInfo-Cp0u57C5.js +1 -0
  26. package/dist/storybook/storybook-static/assets/CustomerInfo-D3WHpN32.js +1 -0
  27. package/dist/storybook/storybook-static/assets/CustomerInfo.stories-BeF8Yh1A.js +9 -0
  28. package/dist/storybook/storybook-static/assets/CustomerInfo.stories-CYx1hKNg.js +9 -0
  29. package/dist/storybook/storybook-static/assets/CustomerInfo.stories-DB2C3zqQ.js +9 -0
  30. package/dist/storybook/storybook-static/assets/DeliveryAddress-CD42v0od.js +2 -0
  31. package/dist/storybook/storybook-static/assets/DeliveryAddress-Lfanl1PO.js +2 -0
  32. package/dist/storybook/storybook-static/assets/DeliveryAddress-X81XGbKD.js +2 -0
  33. package/dist/storybook/storybook-static/assets/DeliveryAddress.stories-BvAXTiNm.js +9 -0
  34. package/dist/storybook/storybook-static/assets/DeliveryAddress.stories-CTyS3zFt.js +9 -0
  35. package/dist/storybook/storybook-static/assets/DeliveryAddress.stories-DHyw5QNl.js +9 -0
  36. package/dist/storybook/storybook-static/assets/DocsRenderer-CFRXHY34-4VFo0TRH.js +2 -0
  37. package/dist/storybook/storybook-static/assets/DocsRenderer-CFRXHY34-BKek9MhZ.js +2 -0
  38. package/dist/storybook/storybook-static/assets/DocsRenderer-CFRXHY34-sE6BxCwu.js +2 -0
  39. package/dist/storybook/storybook-static/assets/Guide.en-BJ4qiYIc.js +107 -0
  40. package/dist/storybook/storybook-static/assets/Guide.en-CiR7CrYZ.js +107 -0
  41. package/dist/storybook/storybook-static/assets/Guide.en-DPJzC5RR.js +107 -0
  42. package/dist/storybook/storybook-static/assets/PaymentMethods-BNEEARzu.js +2 -0
  43. package/dist/storybook/storybook-static/assets/PaymentMethods-BnPZRrAs.js +2 -0
  44. package/dist/storybook/storybook-static/assets/PaymentMethods-e9HqQtxN.js +2 -0
  45. package/dist/storybook/storybook-static/assets/PaymentMethods.stories-Bc4jYrum.js +9 -0
  46. package/dist/storybook/storybook-static/assets/PaymentMethods.stories-ChiL9TJn.js +9 -0
  47. package/dist/storybook/storybook-static/assets/PaymentMethods.stories-pOuLDPwE.js +9 -0
  48. package/dist/storybook/storybook-static/assets/QuickStart.en-B2goyY4Q.js +136 -0
  49. package/dist/storybook/storybook-static/assets/QuickStart.en-Ct2dMZNT.js +136 -0
  50. package/dist/storybook/storybook-static/assets/QuickStart.en-D6K1vnx2.js +136 -0
  51. package/dist/storybook/storybook-static/assets/ValidateInput-Cl2O4HCX.js +2 -0
  52. package/dist/storybook/storybook-static/assets/ValidateInput-DcnOO9py.js +2 -0
  53. package/dist/storybook/storybook-static/assets/ValidateInput-sZgX3GCF.js +2 -0
  54. package/dist/storybook/storybook-static/assets/entry-preview-Bnn64O7J.js +2 -0
  55. package/dist/storybook/storybook-static/assets/entry-preview-Dbi49YCK.js +2 -0
  56. package/dist/storybook/storybook-static/assets/entry-preview-hHv11-z5.js +2 -0
  57. package/dist/storybook/storybook-static/assets/iframe-Ce3kgeV4.js +211 -0
  58. package/dist/storybook/storybook-static/assets/iframe-DsSsblW_.js +211 -0
  59. package/dist/storybook/storybook-static/assets/iframe-PThBYPHV.js +211 -0
  60. package/dist/storybook/storybook-static/assets/index-CZFGp9Su.js +575 -0
  61. package/dist/storybook/storybook-static/assets/index-CkNSuRJg.js +575 -0
  62. package/dist/storybook/storybook-static/assets/index-LRKEu_dQ.js +575 -0
  63. package/dist/storybook/storybook-static/assets/preview-884UjfA3.js +2 -0
  64. package/dist/storybook/storybook-static/assets/preview-DNROAajq.js +2 -0
  65. package/dist/storybook/storybook-static/assets/preview-EmPtksy2.js +2 -0
  66. package/dist/storybook/storybook-static/assets/useCheckoutContext-B8tsk5b5.js +27 -0
  67. package/dist/storybook/storybook-static/assets/useCheckoutContext-C6u4Rp5U.js +27 -0
  68. package/dist/storybook/storybook-static/assets/useCheckoutContext-DuJ1Ep0-.js +27 -0
  69. package/dist/storybook/storybook-static/iframe.html +1 -1
  70. package/dist/storybook/storybook-static/project.json +1 -1
  71. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import{j as t}from"./jsx-runtime-DiklIkkE.js";import{F as W}from"./ValidateInput-DcnOO9py.js";import{r as a,R as O}from"./index-DRjF_FHU.js";import{Z as F,d as P,e as j,s as x,b as z,A as M}from"./useCheckoutContext-DuJ1Ep0-.js";const R=({label:h,value:u,onChange:l,onBlur:b,onFocus:n,placeholder:C,selectClass:v="",error:y,options:A,schema:g,validateOnChange:T=!1,validateOnBlur:f=!0,onValidationChange:S,...e})=>{const[,s]=a.useState(!1),[i,r]=a.useState(null),d=y||i,m=a.useCallback(o=>{var w;if(!g)return null;try{return g.parse(o),null}catch(L){return L instanceof F&&((w=L.issues[0])==null?void 0:w.message)||"Validation failed"}},[g]),N=a.useCallback(o=>{r(o),S&&S(o)},[S]);return a.useEffect(()=>{if(g&&T){const o=m(u);N(o)}},[u,g,T,m,N]),t.jsxs("div",{className:"relative w-full",children:[t.jsx("label",{className:`text-sm text-[#2A2B35] bg-white px-1 pointer-events-none
2
+ transition-all duration-200 z-10`,children:h}),t.jsx("div",{className:"relative",children:t.jsxs("select",{value:u,onFocus:o=>{s(!0),n&&n(o)},onBlur:o=>{if(s(!1),g&&f){const w=m(u);N(w)}b&&b(o)},onChange:o=>l(o.target.value),className:`w-full border border-[#e6e6e6] shadow-sm rounded-md p-[0.64rem] pl-3 text-base bg-white transition pr-12 appearance-none cursor-pointer outline-none font-[inherit] ${d?"!border-2 !border-[#df1b41] focus:!border-[#df1b41] !text-[#df1b41] focus:!ring-0 focus:!outline-none":"border-secondary focus:border-[#8AA3D4] focus:shadow-focus focus:!outline-none"} ${v}`,...e,children:[C&&!u&&t.jsx("option",{value:"",disabled:!0,children:C||h}),A.map(o=>t.jsx("option",{value:o.value,children:o.label},o.value))]})}),d&&t.jsx("p",{className:"mt-1 text-sm text-[#df1b41] px-2",children:d})]})};R.__docgenInfo={description:"",methods:[],displayName:"FloatingLabelSelect",props:{label:{required:!0,tsType:{name:"string"},description:""},value:{required:!0,tsType:{name:"string"},description:""},onChange:{required:!0,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"(e: React.FocusEvent<HTMLSelectElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLSelectElement>",elements:[{name:"HTMLSelectElement"}]},name:"e"}],return:{name:"void"}}},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"(e: React.FocusEvent<HTMLSelectElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLSelectElement>",elements:[{name:"HTMLSelectElement"}]},name:"e"}],return:{name:"void"}}},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},icon:{required:!1,tsType:{name:"ReactReactNode",raw:"React.ReactNode"},description:""},selectClass:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'""',computed:!1}},error:{required:!1,tsType:{name:"string"},description:""},options:{required:!0,tsType:{name:"Array",elements:[{name:"SelectOption"}],raw:"SelectOption[]"},description:""},schema:{required:!1,tsType:{name:"z.ZodSchema",elements:[{name:"string"}],raw:"z.ZodSchema<string>"},description:""},validateOnChange:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},validateOnBlur:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},onValidationChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(error: string | null) => void",signature:{arguments:[{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"void"}}},description:""}},composes:["Omit"]};const q="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20116%2015'%20aria-label='Powered%20by%20Google'%20class='wbodi'%20fill='%236c757d'%3e%3cpath%20d='M4.025%203.572c1.612%200%202.655%201.283%202.655%203.27%200%201.974-1.05%203.27-2.655%203.27-.902%200-1.63-.393-1.974-1.06h-.09v3.057H.95V3.68h.96v1.054h.094c.404-.726%201.16-1.166%202.02-1.166zm-.24%205.63c1.16%200%201.852-.884%201.852-2.36%200-1.477-.692-2.362-1.846-2.362-1.14%200-1.86.91-1.86%202.362%200%201.447.72%202.36%201.858%202.36zm7.072.91c-1.798%200-2.912-1.243-2.912-3.27%200-2.033%201.114-3.27%202.912-3.27%201.8%200%202.913%201.237%202.913%203.27%200%202.027-1.114%203.27-2.913%203.27m0-.91c1.196%200%201.87-.866%201.87-2.36%200-1.5-.674-2.362-1.87-2.362-1.195%200-1.87.862-1.87%202.362%200%201.494.675%202.36%201.87%202.36m12.206-5.518H22.05l-1.244%205.05h-.094L19.3%203.684h-.966l-1.412%205.05h-.094l-1.242-5.05h-1.02L16.336%2010h1.02l1.406-4.887h.093L20.268%2010h1.025zm3.632.78c-1.008%200-1.71.737-1.787%201.856h3.48c-.023-1.12-.69-1.857-1.693-1.857zm1.664%203.9h1.004c-.305%201.085-1.277%201.747-2.66%201.747-1.752%200-2.848-1.26-2.848-3.26%200-1.986%201.113-3.275%202.847-3.275%201.705%200%202.742%201.213%202.742%203.176v.387h-4.542v.047c.053%201.248.75%202.04%201.822%202.04.815%200%201.366-.3%201.63-.857zM31.03%2010h1.01V6.086c0-.89.696-1.535%201.657-1.535.2%200%20.563.04.645.06V3.6c-.13-.018-.34-.03-.504-.03-.838%200-1.565.434-1.752%201.05h-.094v-.938h-.96V10zm6.915-5.537c-1.008%200-1.71.738-1.787%201.857h3.48c-.023-1.12-.69-1.857-1.693-1.857m1.664%203.902h1.004c-.304%201.084-1.277%201.746-2.66%201.746-1.752%200-2.848-1.26-2.848-3.26%200-1.986%201.113-3.275%202.847-3.275%201.705%200%202.742%201.213%202.742%203.176v.387h-4.542v.047c.053%201.248.75%202.04%201.822%202.04.815%200%201.366-.3%201.63-.857zm5.01%201.746c-1.62%200-2.658-1.28-2.658-3.265%200-1.98%201.05-3.27%202.654-3.27.878%200%201.622.416%201.98%201.108h.087V1.177h1.008V10h-.96V8.992h-.093c-.4.703-1.15%201.12-2.02%201.12zm.23-5.63c-1.15%200-1.845.89-1.845%202.365s.69%202.36%201.846%202.36c1.15%200%201.858-.9%201.858-2.36%200-1.447-.715-2.362-1.857-2.362zm7.876-3.114h1.024V4.49q.346-.45.827-.69.48-.239%201.043-.237%201.172.001%201.9.806c.49.536.73%201.33.73%202.375q0%201.489-.72%202.473t-1.997.984q-.715%200-1.207-.344-.293-.206-.627-.657v.8h-.97V1.364zm4.02%207.225q.426-.679.426-1.793%200-.99-.425-1.64t-1.25-.65q-.719%200-1.264.532-.541.532-.542%201.757.001.885.224%201.435.416%201.04%201.553%201.04.856%200%201.28-.68zM63.4%203.727h1.167q-.222.603-.99%202.754a145%20145%200%200%201-.96%202.635q-.915%202.402-1.29%202.93-.375.526-1.29.527-.221%200-.342-.017a3%203%200%200%201-.296-.065v-.96q.273.074.4.093.119.018.214.018.292%200%20.43-.093a.9.9%200%200%200%20.232-.237q.03-.05.21-.48.183-.436.264-.646l-2.32-6.457h1.196l1.68%205.11%201.694-5.11zm10.594%201.556V6.87h3.814c-.117.89-.416%201.54-.87%201.998-.557.555-1.427%201.16-2.944%201.16-2.35%200-4.184-1.882-4.184-4.217%200-2.33%201.835-4.214%204.184-4.214a4.07%204.07%200%200%201%202.873%201.135l1.122-1.116C77.04.697%2075.77%200%2073.99%200c-3.218%200-5.923%202.606-5.923%205.805%200%203.2%202.705%205.804%205.923%205.804%201.738%200%203.048-.57%204.073-1.63%201.05-1.044%201.382-2.52%201.382-3.71%200-.365-.028-.707-.087-.99h-5.37zm10.222-1.29c-2.082%200-3.78%201.574-3.78%203.748%200%202.154%201.698%203.747%203.78%203.747S87.998%209.9%2087.998%207.74c0-2.174-1.7-3.748-3.782-3.748zm0%206.018c-1.14%200-2.127-.935-2.127-2.27%200-1.348.982-2.27%202.123-2.27s2.128.922%202.128%202.27c0%201.335-.985%202.27-2.127%202.27zm18.54-5.18h-.06c-.37-.438-1.083-.838-1.985-.838-1.88%200-3.52%201.632-3.52%203.748%200%202.102%201.64%203.747%203.52%203.747.906%200%201.62-.4%201.99-.852h.06v.523c0%201.432-.774%202.2-2.013%202.2-1.012%200-1.64-.723-1.9-1.336l-1.44.593c.414.994%201.51%202.213%203.34%202.213%201.94%200%203.58-1.135%203.58-3.902v-6.74h-1.57v.645zm-1.9%205.18c-1.144%200-2.013-.968-2.013-2.27%200-1.323.87-2.27%202.01-2.27%201.13%200%202.012.967%202.012%202.282.006%201.31-.882%202.258-2.01%202.258zM92.65%203.992c-2.084%200-3.783%201.574-3.783%203.748%200%202.154%201.7%203.747%203.782%203.747%202.08%200%203.78-1.587%203.78-3.747%200-2.174-1.7-3.748-3.78-3.748zm0%206.018c-1.143%200-2.13-.935-2.13-2.27%200-1.348.987-2.27%202.13-2.27%201.14%200%202.126.922%202.126%202.27%200%201.335-.986%202.27-2.127%202.27zM105.622.155h1.628v11.332h-1.628m6.655-1.477c-.843%200-1.44-.38-1.83-1.135l5.04-2.07-.168-.426c-.315-.84-1.275-2.39-3.228-2.39-1.94%200-3.554%201.515-3.554%203.75%200%202.1%201.595%203.744%203.736%203.744%201.725%200%202.724-1.05%203.14-1.658l-1.285-.852c-.428.62-1.01%201.032-1.855%201.032zm-.117-4.612c.668%200%201.24.342%201.427.826l-3.405%201.4c0-1.574%201.122-2.226%201.978-2.226'%3e%3c/path%3e%3c/svg%3e",D=({value:h,onChange:u,onAddressSelect:l,label:b="Address",placeholder:n="Address",apiKey:C,region:v,schema:y,error:A,inputClass:g="w-full",autoComplete:T="shipping address-line1"})=>{const[f,S]=a.useState([]),[e,s]=a.useState(!1),[i,r]=a.useState(),d=a.useRef(null),m=a.useRef(null);a.useEffect(()=>{const c=p=>{m.current&&!m.current.contains(p.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]);const N=a.useCallback(async c=>{if(!c.trim()||!C){S([]),s(!1);return}try{const p=await P(c,C,v,i);S(p.suggestions),r(p.sessionToken),s(!0)}catch(p){console.error("Failed to fetch suggestions:",p),S([])}},[C,v,i]),o=a.useCallback(c=>{const p=c.target.value;u(p),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{N(p)},300)},[u,N]),w=a.useCallback(async(c,p)=>{p.preventDefault(),p.stopPropagation();try{const B=await j(c.place,v||"US");u(c.address),l&&l(B),s(!1),S([]),r(void 0)}catch(B){console.error("Failed to get address detail:",B),u(c.address),s(!1)}},[u,l,v]),L=a.useCallback(()=>{f.length>0?s(!0):h.trim()&&N(h)},[f.length,h,N]),I=a.useCallback(()=>{s(!1)},[]);return a.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),t.jsxs("div",{className:"relative",ref:m,id:"google-address-suggestion",children:[t.jsx(W,{label:b,placeholder:n,value:h,onChange:o,onFocus:L,inputClass:g,autoComplete:T,schema:y,error:A,...C&&{icon:t.jsxs("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[t.jsx("circle",{cx:"11",cy:"11",r:"7"}),t.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}}),e&&f.length>0&&t.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white border border-[#e6e6e6] rounded-md shadow-lg max-h-80 overflow-y-auto",children:t.jsxs("ul",{className:"m-0 p-0 list-none",children:[t.jsxs("li",{className:"px-4 py-3 flex items-center justify-between ml-0",children:[t.jsx("span",{className:"text-[#212529A6] text-sm uppercase",children:"Suggestions"}),t.jsx("button",{type:"button",onClick:I,className:"bg-transparent border-none outline-none text-gray-400 hover:text-gray-600 focus:outline-none","aria-label":"Close suggestions",children:t.jsxs("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),f.map(c=>t.jsx("li",{className:"px-4 py-2 hover:bg-gray-100 cursor-pointer transition-colors text-[#212529A6]",onClick:p=>w(c,p),children:c.address},c.id)),t.jsx("li",{className:"px-4 py-2 border-t border-[#e6e6e6] bg-[#f8f9fa] ml-0",children:t.jsx("div",{className:"flex items-center",children:t.jsx("img",{src:q,alt:"Powered by Google",className:"h-5 w-[8rem] fill-[#6c757d] text-md"})})})]})})]})};D.__docgenInfo={description:"",methods:[],displayName:"GoogleSuggestionInput",props:{apiKey:{required:!0,tsType:{name:"string"},description:""},value:{required:!0,tsType:{name:"string"},description:""},onChange:{required:!0,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onAddressSelect:{required:!1,tsType:{name:"signature",type:"function",raw:"(addressData: DeliveryAddress) => void",signature:{arguments:[{type:{name:"z.infer",elements:[{name:"AddressSchema"}],raw:"z.infer<typeof AddressSchema>"},name:"addressData"}],return:{name:"void"}}},description:""},label:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"Address"',computed:!1}},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"Address"',computed:!1}},region:{required:!1,tsType:{name:"string"},description:""},schema:{required:!1,tsType:{name:"z.ZodSchema",elements:[{name:"string"}],raw:"z.ZodSchema<string>"},description:""},error:{required:!1,tsType:{name:"string"},description:""},inputClass:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"w-full"',computed:!1}},autoComplete:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"shipping address-line1"',computed:!1}}}};const E={US:{name:"United States",state:{AL:"Alabama",AK:"Alaska",AS:"American Samoa",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",DC:"District of Columbia",FM:"Federated States of Micronesia",FL:"Florida",GA:"Georgia",GU:"Guam",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MH:"Marshall Islands",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",MP:"Northern Mariana Islands",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PW:"Palau",PA:"Pennsylvania",PR:"Puerto Rico",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VI:"Virgin Islands",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",AA:"Armed Forces Americas",AE:"Armed Forces Europe",AP:"Armed Forces Pacific"}},AU:{name:"Australia",state:{ACT:"Australian Capital Territory",NSW:"New South Wales",NT:"Northern Territory",QLD:"Queensland",SA:"South Australia",TAS:"Tasmania",VIC:"Victoria",WA:"Western Australia"}},CA:{name:"Canada",state:{AB:"Alberta",BC:"British Columbia",MB:"Manitoba",NB:"New Brunswick",NL:"Newfoundland and Labrador",NT:"Northwest Territories",NS:"Nova Scotia",NU:"Nunavut",ON:"Ontario",PE:"Prince Edward Island",QC:"Quebec",SK:"Saskatchewan",YT:"Yukon"}},NZ:{name:"New Zealand",state:{AUK:"Auckland",BOP:"Bay of Plenty",CAN:"Canterbury",CIT:"Chatham Islands",GIS:"Gisborne",HKB:"Hawke’s Bay",MWT:"Manawatū-Whanganui",MBH:"Marlborough",NSN:"Nelson",NTL:"Northland",OTA:"Otago",STL:"Southland",TKI:"Taranaki",TAS:"Tasman",WKO:"Waikato",WGN:"Wellington",WTC:"West Coast"}},GB:{name:"United Kingdom",state:{BD:"Barking and Dagenham",BE:"Barnet",BNS:"Barnsley",BNES:"Bath and North East Somerset",BDF:"Bedfordshire",BX:"Bexley",BIR:"Birmingham",BBD:"Blackburn with Darwen",BPL:"Blackpool",BOL:"Bolton",BMH:"Bournemouth",BRC:"Bracknell Forest",BRD:"Bradford",BEN:"Brent",BNH:"Brighton and Hove",BRY:"Bromley",BKM:"Buckinghamshire",BUR:"Bury",CLD:"Calderdale",CAM:"Cambridgeshire",CMD:"Camden",CHS:"Cheshire",BST:"City of Bristol",KHL:"City of Kingston upon Hull",LND:"City of London",CON:"Cornwall",COV:"Coventry",CRY:"Croydon",CMA:"Cumbria",DAL:"Darlington",DER:"Derby",DBY:"Derbyshire",DEV:"Devon",DNC:"Doncaster",DOR:"Dorset",DUD:"Dudley",DUR:"Durham",EAL:"Ealing",ERY:"East Riding of Yorkshire",ESX:"East Sussex",ENF:"Enfield",ESS:"Essex",GAT:"Gateshead",GLS:"Gloucestershire",GRE:"Greenwich",HCK:"Hackney",HAL:"Halton",HMF:"Hammersmith and Fulham",HAM:"Hampshire",HRY:"Haringey",HRW:"Harrow",HPL:"Hartlepool",HAV:"Havering",HEF:"Herefordshire",HRT:"Hertfordshire",HIL:"Hillingdon",HNS:"Hounslow",IOW:"Isle of Wight",ISL:"Islington",KEC:"Kensington and Chelsea",KEN:"Kent",KTT:"Kingston upon Thames",KIR:"Kirklees",KWL:"Knowsley",LBH:"Lambeth",LAN:"Lancashire",LDS:"Leeds",LCE:"Leicester",LEC:"Leicestershire",LEW:"Lewisham",LIN:"Lincolnshire",LIV:"Liverpool",LUT:"Luton",MAN:"Manchester",MDW:"Medway",MRT:"Merton",MDB:"Middlesbrough",MIK:"Milton Keynes",NET:"Newcastle upon Tyne",NWM:"Newham",NFK:"Norfolk",NEL:"North East Lincolnshire",NLN:"North Lincolnshire",NSM:"North Somerset",NTY:"North Tyneside",NYK:"North Yorkshire",NTH:"Northamptonshire",NBL:"Northumberland",NGM:"Nottingham",NTT:"Nottinghamshire",OLD:"Oldham",OXF:"Oxfordshire",PTE:"Peterborough",PLY:"Plymouth",POL:"Poole",POR:"Portsmouth",RDG:"Reading",RDB:"Redbridge",RCC:"Redcar and Cleveland",RIC:"Richmond upon Thames",RCH:"Rochdale",ROT:"Rotherham",RUT:"Rutland",SLF:"Salford",SAW:"Sandwell",SFT:"Sefton",SHF:"Sheffield",SHR:"Shropshire",SLG:"Slough",SOL:"Solihull",SOM:"Somerset",SGC:"South Gloucestershire",STY:"South Tyneside",STH:"Southampton",SOS:"Southend-on-Sea",SWK:"Southwark",SHN:"St. Helens",STS:"Staffordshire",SKP:"Stockport",STT:"Stockton-on-Tees",STE:"Stoke-on-Trent",SFK:"Suffolk",SND:"Sunderland",SRY:"Surrey",SUT:"Sutton",SWD:"Swindon",TAM:"Tameside",TFW:"Telford and Wrekin",THR:"Thurrock",TOB:"Torbay",TWH:"Tower Hamlets",TRF:"Trafford",WKF:"Wakefield",WLL:"Walsall",WFT:"Waltham Forest",WND:"Wandsworth",WRT:"Warrington",WAR:"Warwickshire",WBK:"West Berkshire",WSX:"West Sussex",WSM:"Westminster",WGN:"Wigan",WIL:"Wiltshire",WNM:"Windsor and Maidenhead",WRL:"Wirral",WOK:"Wokingham",WLV:"Wolverhampton",WOR:"Worcestershire",YOR:"York"}}},k={US:x().trim().min(1,"Zip code is required").regex(/^\d{5}(-\d{4})?$/,"Invalid US ZIP code"),CA:x().trim().min(1,"Postal code is required").regex(/^[A-Z]\d[A-Z] \d[A-Z]\d$/,"Invalid CA postcode"),AU:x().trim().min(1,"Postcode is required").regex(/^\d{4}$/,"Invalid AU postcode"),NZ:x().trim().min(1,"Postal code is required").regex(/^\d{4}$/,"Invalid NZ postal code"),GB:x().trim().min(1,"Postcode is required").regex(/^[A-Z]{1,2}\d[A-Z\d]? \d[A-Z]{2}$/,"Invalid UK postcode")},H={US:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"State",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Zip Code",placeholder:"Zip Code",autoComplete:"shipping postal-code",validation:k.US}],layout:[{row:["city"]},{row:["state","zipCode"]}]},CA:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"Province",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.CA}],layout:[{row:["city"]},{row:["state","zipCode"]}]},AU:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"State / territory",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.AU}],layout:[{row:["city"]},{row:["state","zipCode"]}]},NZ:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"Region",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.NZ}],layout:[{row:["city"]},{row:["state","zipCode"]}]},GB:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.GB}],layout:[{row:["city"]},{row:["zipCode"]}]}};function K(h){return H[h]||H.US}const V=({showTitle:h=!0})=>{const{deliveryAddress:u,updateDeliveryAddress:l,googleApiKey:b}=z(),{country:n,address:C,address2:v}=u,y=a.useMemo(()=>K(n||"US"),[n]),A=a.useMemo(()=>{const s=E[n||"US"];return Object.entries(s.state).map(([,i])=>({value:i,label:i}))},[n]),g=a.useMemo(()=>Object.entries(E).map(([e,s])=>({value:e,label:s.name})),[]),T=O.useRef(n);a.useEffect(()=>{n||l({country:"US"})},[n,l]),a.useEffect(()=>{const e=T.current,s=n||"US";e&&s&&e!==s&&l({city:"",state:"",zipCode:""}),T.current=s},[n,l]);const f=e=>{const s=u[e.key],i=e.key,r=e.validation||M.shape[i];return e.type==="select"&&e.useStateOptions?t.jsx(R,{label:e.label,placeholder:e.placeholder,value:s,onChange:d=>l({[i]:d}),options:A,autoComplete:e.autoComplete,schema:r},i):t.jsx(W,{label:e.label,placeholder:e.placeholder,value:s,onChange:d=>l({[i]:d.target.value}),inputClass:"w-full",autoComplete:e.autoComplete,schema:r},i)},S=()=>{const e=new Map(y.fields.map(r=>[r.key,r]));if(!y.layout||y.layout.length===0)return y.fields.map(r=>t.jsx("div",{className:"flex-1",children:f(r)},r.key));const s=new Set,i=[];return y.layout.forEach(r=>{const d=r.row.map(m=>e.get(m)).filter(Boolean);d.length>0&&i.push(t.jsx("div",{className:"flex flex-col md:flex-row gap-3",children:d.map(m=>(s.add(m.key),t.jsx("div",{className:"flex-1",children:f(m)},m.key)))},`row-${r.row.join("-")}`))}),y.fields.forEach(r=>{s.has(r.key)||i.push(t.jsx("div",{className:"flex-1",children:f(r)},r.key))}),i};return t.jsxs("div",{className:"w-full",children:[h&&t.jsx("div",{className:"text-lg md:text-2xl mb-5 font-medium",children:"Delivery Address"}),t.jsxs("div",{className:"flex flex-col gap-2 border border-solid border-[#e6e6e6] shadow-sm rounded-md p-4 bg-white",children:[t.jsx(R,{label:"Country",placeholder:"Country",value:n||"US",onChange:e=>l({country:e}),options:g,autoComplete:"shipping country",schema:M.shape.country}),t.jsx(D,{value:C,onChange:e=>l({address:e}),onAddressSelect:e=>{l({address:e.address,address2:e.address2||"",city:e.city||"",state:e.state||"",zipCode:e.zipCode||"",country:e.country||n||"US"})},apiKey:b||"",region:n,schema:M.shape.address,autoComplete:"shipping address-line1"}),t.jsx(W,{label:"Address Line 2",placeholder:"Address Line 2",value:v||"",onChange:e=>l({address2:e.target.value}),inputClass:"w-full",autoComplete:"shipping address-line2",schema:M.shape.address2}),S()]})]})};V.__docgenInfo={description:"",methods:[],displayName:"DeliveryAddress",props:{showTitle:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}}};export{V as D};
@@ -0,0 +1,2 @@
1
+ import{j as t}from"./jsx-runtime-DiklIkkE.js";import{F as W}from"./ValidateInput-Cl2O4HCX.js";import{r as a,R as O}from"./index-DRjF_FHU.js";import{Z as F,d as P,e as j,s as x,b as z,A as M}from"./useCheckoutContext-B8tsk5b5.js";const R=({label:h,value:u,onChange:l,onBlur:b,onFocus:n,placeholder:C,selectClass:v="",error:y,options:A,schema:g,validateOnChange:T=!1,validateOnBlur:f=!0,onValidationChange:S,...e})=>{const[,s]=a.useState(!1),[i,r]=a.useState(null),d=y||i,m=a.useCallback(o=>{var w;if(!g)return null;try{return g.parse(o),null}catch(L){return L instanceof F&&((w=L.issues[0])==null?void 0:w.message)||"Validation failed"}},[g]),N=a.useCallback(o=>{r(o),S&&S(o)},[S]);return a.useEffect(()=>{if(g&&T){const o=m(u);N(o)}},[u,g,T,m,N]),t.jsxs("div",{className:"relative w-full",children:[t.jsx("label",{className:`text-sm text-[#2A2B35] bg-white px-1 pointer-events-none
2
+ transition-all duration-200 z-10`,children:h}),t.jsx("div",{className:"relative",children:t.jsxs("select",{value:u,onFocus:o=>{s(!0),n&&n(o)},onBlur:o=>{if(s(!1),g&&f){const w=m(u);N(w)}b&&b(o)},onChange:o=>l(o.target.value),className:`w-full border border-[#e6e6e6] shadow-sm rounded-md p-[0.64rem] pl-3 text-base bg-white transition pr-12 appearance-none cursor-pointer outline-none font-[inherit] ${d?"!border-2 !border-[#df1b41] focus:!border-[#df1b41] !text-[#df1b41] focus:!ring-0 focus:!outline-none":"border-secondary focus:border-[#8AA3D4] focus:shadow-focus focus:!outline-none"} ${v}`,...e,children:[C&&!u&&t.jsx("option",{value:"",disabled:!0,children:C||h}),A.map(o=>t.jsx("option",{value:o.value,children:o.label},o.value))]})}),d&&t.jsx("p",{className:"mt-1 text-sm text-[#df1b41] px-2",children:d})]})};R.__docgenInfo={description:"",methods:[],displayName:"FloatingLabelSelect",props:{label:{required:!0,tsType:{name:"string"},description:""},value:{required:!0,tsType:{name:"string"},description:""},onChange:{required:!0,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onBlur:{required:!1,tsType:{name:"signature",type:"function",raw:"(e: React.FocusEvent<HTMLSelectElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLSelectElement>",elements:[{name:"HTMLSelectElement"}]},name:"e"}],return:{name:"void"}}},description:""},onFocus:{required:!1,tsType:{name:"signature",type:"function",raw:"(e: React.FocusEvent<HTMLSelectElement>) => void",signature:{arguments:[{type:{name:"ReactFocusEvent",raw:"React.FocusEvent<HTMLSelectElement>",elements:[{name:"HTMLSelectElement"}]},name:"e"}],return:{name:"void"}}},description:""},placeholder:{required:!1,tsType:{name:"string"},description:""},icon:{required:!1,tsType:{name:"ReactReactNode",raw:"React.ReactNode"},description:""},selectClass:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'""',computed:!1}},error:{required:!1,tsType:{name:"string"},description:""},options:{required:!0,tsType:{name:"Array",elements:[{name:"SelectOption"}],raw:"SelectOption[]"},description:""},schema:{required:!1,tsType:{name:"z.ZodSchema",elements:[{name:"string"}],raw:"z.ZodSchema<string>"},description:""},validateOnChange:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"false",computed:!1}},validateOnBlur:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}},onValidationChange:{required:!1,tsType:{name:"signature",type:"function",raw:"(error: string | null) => void",signature:{arguments:[{type:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},name:"error"}],return:{name:"void"}}},description:""}},composes:["Omit"]};const q="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20116%2015'%20aria-label='Powered%20by%20Google'%20class='wbodi'%20fill='%236c757d'%3e%3cpath%20d='M4.025%203.572c1.612%200%202.655%201.283%202.655%203.27%200%201.974-1.05%203.27-2.655%203.27-.902%200-1.63-.393-1.974-1.06h-.09v3.057H.95V3.68h.96v1.054h.094c.404-.726%201.16-1.166%202.02-1.166zm-.24%205.63c1.16%200%201.852-.884%201.852-2.36%200-1.477-.692-2.362-1.846-2.362-1.14%200-1.86.91-1.86%202.362%200%201.447.72%202.36%201.858%202.36zm7.072.91c-1.798%200-2.912-1.243-2.912-3.27%200-2.033%201.114-3.27%202.912-3.27%201.8%200%202.913%201.237%202.913%203.27%200%202.027-1.114%203.27-2.913%203.27m0-.91c1.196%200%201.87-.866%201.87-2.36%200-1.5-.674-2.362-1.87-2.362-1.195%200-1.87.862-1.87%202.362%200%201.494.675%202.36%201.87%202.36m12.206-5.518H22.05l-1.244%205.05h-.094L19.3%203.684h-.966l-1.412%205.05h-.094l-1.242-5.05h-1.02L16.336%2010h1.02l1.406-4.887h.093L20.268%2010h1.025zm3.632.78c-1.008%200-1.71.737-1.787%201.856h3.48c-.023-1.12-.69-1.857-1.693-1.857zm1.664%203.9h1.004c-.305%201.085-1.277%201.747-2.66%201.747-1.752%200-2.848-1.26-2.848-3.26%200-1.986%201.113-3.275%202.847-3.275%201.705%200%202.742%201.213%202.742%203.176v.387h-4.542v.047c.053%201.248.75%202.04%201.822%202.04.815%200%201.366-.3%201.63-.857zM31.03%2010h1.01V6.086c0-.89.696-1.535%201.657-1.535.2%200%20.563.04.645.06V3.6c-.13-.018-.34-.03-.504-.03-.838%200-1.565.434-1.752%201.05h-.094v-.938h-.96V10zm6.915-5.537c-1.008%200-1.71.738-1.787%201.857h3.48c-.023-1.12-.69-1.857-1.693-1.857m1.664%203.902h1.004c-.304%201.084-1.277%201.746-2.66%201.746-1.752%200-2.848-1.26-2.848-3.26%200-1.986%201.113-3.275%202.847-3.275%201.705%200%202.742%201.213%202.742%203.176v.387h-4.542v.047c.053%201.248.75%202.04%201.822%202.04.815%200%201.366-.3%201.63-.857zm5.01%201.746c-1.62%200-2.658-1.28-2.658-3.265%200-1.98%201.05-3.27%202.654-3.27.878%200%201.622.416%201.98%201.108h.087V1.177h1.008V10h-.96V8.992h-.093c-.4.703-1.15%201.12-2.02%201.12zm.23-5.63c-1.15%200-1.845.89-1.845%202.365s.69%202.36%201.846%202.36c1.15%200%201.858-.9%201.858-2.36%200-1.447-.715-2.362-1.857-2.362zm7.876-3.114h1.024V4.49q.346-.45.827-.69.48-.239%201.043-.237%201.172.001%201.9.806c.49.536.73%201.33.73%202.375q0%201.489-.72%202.473t-1.997.984q-.715%200-1.207-.344-.293-.206-.627-.657v.8h-.97V1.364zm4.02%207.225q.426-.679.426-1.793%200-.99-.425-1.64t-1.25-.65q-.719%200-1.264.532-.541.532-.542%201.757.001.885.224%201.435.416%201.04%201.553%201.04.856%200%201.28-.68zM63.4%203.727h1.167q-.222.603-.99%202.754a145%20145%200%200%201-.96%202.635q-.915%202.402-1.29%202.93-.375.526-1.29.527-.221%200-.342-.017a3%203%200%200%201-.296-.065v-.96q.273.074.4.093.119.018.214.018.292%200%20.43-.093a.9.9%200%200%200%20.232-.237q.03-.05.21-.48.183-.436.264-.646l-2.32-6.457h1.196l1.68%205.11%201.694-5.11zm10.594%201.556V6.87h3.814c-.117.89-.416%201.54-.87%201.998-.557.555-1.427%201.16-2.944%201.16-2.35%200-4.184-1.882-4.184-4.217%200-2.33%201.835-4.214%204.184-4.214a4.07%204.07%200%200%201%202.873%201.135l1.122-1.116C77.04.697%2075.77%200%2073.99%200c-3.218%200-5.923%202.606-5.923%205.805%200%203.2%202.705%205.804%205.923%205.804%201.738%200%203.048-.57%204.073-1.63%201.05-1.044%201.382-2.52%201.382-3.71%200-.365-.028-.707-.087-.99h-5.37zm10.222-1.29c-2.082%200-3.78%201.574-3.78%203.748%200%202.154%201.698%203.747%203.78%203.747S87.998%209.9%2087.998%207.74c0-2.174-1.7-3.748-3.782-3.748zm0%206.018c-1.14%200-2.127-.935-2.127-2.27%200-1.348.982-2.27%202.123-2.27s2.128.922%202.128%202.27c0%201.335-.985%202.27-2.127%202.27zm18.54-5.18h-.06c-.37-.438-1.083-.838-1.985-.838-1.88%200-3.52%201.632-3.52%203.748%200%202.102%201.64%203.747%203.52%203.747.906%200%201.62-.4%201.99-.852h.06v.523c0%201.432-.774%202.2-2.013%202.2-1.012%200-1.64-.723-1.9-1.336l-1.44.593c.414.994%201.51%202.213%203.34%202.213%201.94%200%203.58-1.135%203.58-3.902v-6.74h-1.57v.645zm-1.9%205.18c-1.144%200-2.013-.968-2.013-2.27%200-1.323.87-2.27%202.01-2.27%201.13%200%202.012.967%202.012%202.282.006%201.31-.882%202.258-2.01%202.258zM92.65%203.992c-2.084%200-3.783%201.574-3.783%203.748%200%202.154%201.7%203.747%203.782%203.747%202.08%200%203.78-1.587%203.78-3.747%200-2.174-1.7-3.748-3.78-3.748zm0%206.018c-1.143%200-2.13-.935-2.13-2.27%200-1.348.987-2.27%202.13-2.27%201.14%200%202.126.922%202.126%202.27%200%201.335-.986%202.27-2.127%202.27zM105.622.155h1.628v11.332h-1.628m6.655-1.477c-.843%200-1.44-.38-1.83-1.135l5.04-2.07-.168-.426c-.315-.84-1.275-2.39-3.228-2.39-1.94%200-3.554%201.515-3.554%203.75%200%202.1%201.595%203.744%203.736%203.744%201.725%200%202.724-1.05%203.14-1.658l-1.285-.852c-.428.62-1.01%201.032-1.855%201.032zm-.117-4.612c.668%200%201.24.342%201.427.826l-3.405%201.4c0-1.574%201.122-2.226%201.978-2.226'%3e%3c/path%3e%3c/svg%3e",D=({value:h,onChange:u,onAddressSelect:l,label:b="Address",placeholder:n="Address",apiKey:C,region:v,schema:y,error:A,inputClass:g="w-full",autoComplete:T="shipping address-line1"})=>{const[f,S]=a.useState([]),[e,s]=a.useState(!1),[i,r]=a.useState(),d=a.useRef(null),m=a.useRef(null);a.useEffect(()=>{const c=p=>{m.current&&!m.current.contains(p.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[]);const N=a.useCallback(async c=>{if(!c.trim()||!C){S([]),s(!1);return}try{const p=await P(c,C,v,i);S(p.suggestions),r(p.sessionToken),s(!0)}catch(p){console.error("Failed to fetch suggestions:",p),S([])}},[C,v,i]),o=a.useCallback(c=>{const p=c.target.value;u(p),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{N(p)},300)},[u,N]),w=a.useCallback(async(c,p)=>{p.preventDefault(),p.stopPropagation();try{const B=await j(c.place,v||"US");u(c.address),l&&l(B),s(!1),S([]),r(void 0)}catch(B){console.error("Failed to get address detail:",B),u(c.address),s(!1)}},[u,l,v]),L=a.useCallback(()=>{f.length>0?s(!0):h.trim()&&N(h)},[f.length,h,N]),I=a.useCallback(()=>{s(!1)},[]);return a.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),t.jsxs("div",{className:"relative",ref:m,id:"google-address-suggestion",children:[t.jsx(W,{label:b,placeholder:n,value:h,onChange:o,onFocus:L,inputClass:g,autoComplete:T,schema:y,error:A,...C&&{icon:t.jsxs("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[t.jsx("circle",{cx:"11",cy:"11",r:"7"}),t.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}}),e&&f.length>0&&t.jsx("div",{className:"absolute z-50 w-full mt-1 bg-white border border-[#e6e6e6] rounded-md shadow-lg max-h-80 overflow-y-auto",children:t.jsxs("ul",{className:"m-0 p-0 list-none",children:[t.jsxs("li",{className:"px-4 py-3 flex items-center justify-between ml-0",children:[t.jsx("span",{className:"text-[#212529A6] text-sm uppercase",children:"Suggestions"}),t.jsx("button",{type:"button",onClick:I,className:"bg-transparent border-none outline-none text-gray-400 hover:text-gray-600 focus:outline-none","aria-label":"Close suggestions",children:t.jsxs("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),f.map(c=>t.jsx("li",{className:"px-4 py-2 hover:bg-gray-100 cursor-pointer transition-colors text-[#212529A6]",onClick:p=>w(c,p),children:c.address},c.id)),t.jsx("li",{className:"px-4 py-2 border-t border-[#e6e6e6] bg-[#f8f9fa] ml-0",children:t.jsx("div",{className:"flex items-center",children:t.jsx("img",{src:q,alt:"Powered by Google",className:"h-5 w-[8rem] fill-[#6c757d] text-md"})})})]})})]})};D.__docgenInfo={description:"",methods:[],displayName:"GoogleSuggestionInput",props:{apiKey:{required:!0,tsType:{name:"string"},description:""},value:{required:!0,tsType:{name:"string"},description:""},onChange:{required:!0,tsType:{name:"signature",type:"function",raw:"(value: string) => void",signature:{arguments:[{type:{name:"string"},name:"value"}],return:{name:"void"}}},description:""},onAddressSelect:{required:!1,tsType:{name:"signature",type:"function",raw:"(addressData: DeliveryAddress) => void",signature:{arguments:[{type:{name:"z.infer",elements:[{name:"AddressSchema"}],raw:"z.infer<typeof AddressSchema>"},name:"addressData"}],return:{name:"void"}}},description:""},label:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"Address"',computed:!1}},placeholder:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"Address"',computed:!1}},region:{required:!1,tsType:{name:"string"},description:""},schema:{required:!1,tsType:{name:"z.ZodSchema",elements:[{name:"string"}],raw:"z.ZodSchema<string>"},description:""},error:{required:!1,tsType:{name:"string"},description:""},inputClass:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"w-full"',computed:!1}},autoComplete:{required:!1,tsType:{name:"string"},description:"",defaultValue:{value:'"shipping address-line1"',computed:!1}}}};const E={US:{name:"United States",state:{AL:"Alabama",AK:"Alaska",AS:"American Samoa",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",DC:"District of Columbia",FM:"Federated States of Micronesia",FL:"Florida",GA:"Georgia",GU:"Guam",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MH:"Marshall Islands",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",MP:"Northern Mariana Islands",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PW:"Palau",PA:"Pennsylvania",PR:"Puerto Rico",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VI:"Virgin Islands",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",AA:"Armed Forces Americas",AE:"Armed Forces Europe",AP:"Armed Forces Pacific"}},AU:{name:"Australia",state:{ACT:"Australian Capital Territory",NSW:"New South Wales",NT:"Northern Territory",QLD:"Queensland",SA:"South Australia",TAS:"Tasmania",VIC:"Victoria",WA:"Western Australia"}},CA:{name:"Canada",state:{AB:"Alberta",BC:"British Columbia",MB:"Manitoba",NB:"New Brunswick",NL:"Newfoundland and Labrador",NT:"Northwest Territories",NS:"Nova Scotia",NU:"Nunavut",ON:"Ontario",PE:"Prince Edward Island",QC:"Quebec",SK:"Saskatchewan",YT:"Yukon"}},NZ:{name:"New Zealand",state:{AUK:"Auckland",BOP:"Bay of Plenty",CAN:"Canterbury",CIT:"Chatham Islands",GIS:"Gisborne",HKB:"Hawke’s Bay",MWT:"Manawatū-Whanganui",MBH:"Marlborough",NSN:"Nelson",NTL:"Northland",OTA:"Otago",STL:"Southland",TKI:"Taranaki",TAS:"Tasman",WKO:"Waikato",WGN:"Wellington",WTC:"West Coast"}},GB:{name:"United Kingdom",state:{BD:"Barking and Dagenham",BE:"Barnet",BNS:"Barnsley",BNES:"Bath and North East Somerset",BDF:"Bedfordshire",BX:"Bexley",BIR:"Birmingham",BBD:"Blackburn with Darwen",BPL:"Blackpool",BOL:"Bolton",BMH:"Bournemouth",BRC:"Bracknell Forest",BRD:"Bradford",BEN:"Brent",BNH:"Brighton and Hove",BRY:"Bromley",BKM:"Buckinghamshire",BUR:"Bury",CLD:"Calderdale",CAM:"Cambridgeshire",CMD:"Camden",CHS:"Cheshire",BST:"City of Bristol",KHL:"City of Kingston upon Hull",LND:"City of London",CON:"Cornwall",COV:"Coventry",CRY:"Croydon",CMA:"Cumbria",DAL:"Darlington",DER:"Derby",DBY:"Derbyshire",DEV:"Devon",DNC:"Doncaster",DOR:"Dorset",DUD:"Dudley",DUR:"Durham",EAL:"Ealing",ERY:"East Riding of Yorkshire",ESX:"East Sussex",ENF:"Enfield",ESS:"Essex",GAT:"Gateshead",GLS:"Gloucestershire",GRE:"Greenwich",HCK:"Hackney",HAL:"Halton",HMF:"Hammersmith and Fulham",HAM:"Hampshire",HRY:"Haringey",HRW:"Harrow",HPL:"Hartlepool",HAV:"Havering",HEF:"Herefordshire",HRT:"Hertfordshire",HIL:"Hillingdon",HNS:"Hounslow",IOW:"Isle of Wight",ISL:"Islington",KEC:"Kensington and Chelsea",KEN:"Kent",KTT:"Kingston upon Thames",KIR:"Kirklees",KWL:"Knowsley",LBH:"Lambeth",LAN:"Lancashire",LDS:"Leeds",LCE:"Leicester",LEC:"Leicestershire",LEW:"Lewisham",LIN:"Lincolnshire",LIV:"Liverpool",LUT:"Luton",MAN:"Manchester",MDW:"Medway",MRT:"Merton",MDB:"Middlesbrough",MIK:"Milton Keynes",NET:"Newcastle upon Tyne",NWM:"Newham",NFK:"Norfolk",NEL:"North East Lincolnshire",NLN:"North Lincolnshire",NSM:"North Somerset",NTY:"North Tyneside",NYK:"North Yorkshire",NTH:"Northamptonshire",NBL:"Northumberland",NGM:"Nottingham",NTT:"Nottinghamshire",OLD:"Oldham",OXF:"Oxfordshire",PTE:"Peterborough",PLY:"Plymouth",POL:"Poole",POR:"Portsmouth",RDG:"Reading",RDB:"Redbridge",RCC:"Redcar and Cleveland",RIC:"Richmond upon Thames",RCH:"Rochdale",ROT:"Rotherham",RUT:"Rutland",SLF:"Salford",SAW:"Sandwell",SFT:"Sefton",SHF:"Sheffield",SHR:"Shropshire",SLG:"Slough",SOL:"Solihull",SOM:"Somerset",SGC:"South Gloucestershire",STY:"South Tyneside",STH:"Southampton",SOS:"Southend-on-Sea",SWK:"Southwark",SHN:"St. Helens",STS:"Staffordshire",SKP:"Stockport",STT:"Stockton-on-Tees",STE:"Stoke-on-Trent",SFK:"Suffolk",SND:"Sunderland",SRY:"Surrey",SUT:"Sutton",SWD:"Swindon",TAM:"Tameside",TFW:"Telford and Wrekin",THR:"Thurrock",TOB:"Torbay",TWH:"Tower Hamlets",TRF:"Trafford",WKF:"Wakefield",WLL:"Walsall",WFT:"Waltham Forest",WND:"Wandsworth",WRT:"Warrington",WAR:"Warwickshire",WBK:"West Berkshire",WSX:"West Sussex",WSM:"Westminster",WGN:"Wigan",WIL:"Wiltshire",WNM:"Windsor and Maidenhead",WRL:"Wirral",WOK:"Wokingham",WLV:"Wolverhampton",WOR:"Worcestershire",YOR:"York"}}},k={US:x().trim().min(1,"Zip code is required").regex(/^\d{5}(-\d{4})?$/,"Invalid US ZIP code"),CA:x().trim().min(1,"Postal code is required").regex(/^[A-Z]\d[A-Z] \d[A-Z]\d$/,"Invalid CA postcode"),AU:x().trim().min(1,"Postcode is required").regex(/^\d{4}$/,"Invalid AU postcode"),NZ:x().trim().min(1,"Postal code is required").regex(/^\d{4}$/,"Invalid NZ postal code"),GB:x().trim().min(1,"Postcode is required").regex(/^[A-Z]{1,2}\d[A-Z\d]? \d[A-Z]{2}$/,"Invalid UK postcode")},H={US:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"State",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Zip Code",placeholder:"Zip Code",autoComplete:"shipping postal-code",validation:k.US}],layout:[{row:["city"]},{row:["state","zipCode"]}]},CA:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"Province",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.CA}],layout:[{row:["city"]},{row:["state","zipCode"]}]},AU:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"State / territory",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.AU}],layout:[{row:["city"]},{row:["state","zipCode"]}]},NZ:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"state",type:"select",label:"Region",placeholder:"-- Select --",useStateOptions:!0,autoComplete:"shipping address-level1"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.NZ}],layout:[{row:["city"]},{row:["state","zipCode"]}]},GB:{fields:[{key:"city",type:"input",label:"City",placeholder:"City",autoComplete:"shipping address-level2"},{key:"zipCode",type:"input",label:"Postcode",placeholder:"Postcode",autoComplete:"shipping postal-code",validation:k.GB}],layout:[{row:["city"]},{row:["zipCode"]}]}};function K(h){return H[h]||H.US}const V=({showTitle:h=!0})=>{const{deliveryAddress:u,updateDeliveryAddress:l,googleApiKey:b}=z(),{country:n,address:C,address2:v}=u,y=a.useMemo(()=>K(n||"US"),[n]),A=a.useMemo(()=>{const s=E[n||"US"];return Object.entries(s.state).map(([,i])=>({value:i,label:i}))},[n]),g=a.useMemo(()=>Object.entries(E).map(([e,s])=>({value:e,label:s.name})),[]),T=O.useRef(n);a.useEffect(()=>{n||l({country:"US"})},[n,l]),a.useEffect(()=>{const e=T.current,s=n||"US";e&&s&&e!==s&&l({city:"",state:"",zipCode:""}),T.current=s},[n,l]);const f=e=>{const s=u[e.key],i=e.key,r=e.validation||M.shape[i];return e.type==="select"&&e.useStateOptions?t.jsx(R,{label:e.label,placeholder:e.placeholder,value:s,onChange:d=>l({[i]:d}),options:A,autoComplete:e.autoComplete,schema:r},i):t.jsx(W,{label:e.label,placeholder:e.placeholder,value:s,onChange:d=>l({[i]:d.target.value}),inputClass:"w-full",autoComplete:e.autoComplete,schema:r},i)},S=()=>{const e=new Map(y.fields.map(r=>[r.key,r]));if(!y.layout||y.layout.length===0)return y.fields.map(r=>t.jsx("div",{className:"flex-1",children:f(r)},r.key));const s=new Set,i=[];return y.layout.forEach(r=>{const d=r.row.map(m=>e.get(m)).filter(Boolean);d.length>0&&i.push(t.jsx("div",{className:"flex flex-col md:flex-row gap-3",children:d.map(m=>(s.add(m.key),t.jsx("div",{className:"flex-1",children:f(m)},m.key)))},`row-${r.row.join("-")}`))}),y.fields.forEach(r=>{s.has(r.key)||i.push(t.jsx("div",{className:"flex-1",children:f(r)},r.key))}),i};return t.jsxs("div",{className:"w-full",children:[h&&t.jsx("div",{className:"text-lg md:text-2xl mb-5 font-medium",children:"Delivery Address"}),t.jsxs("div",{className:"flex flex-col gap-2 border border-solid border-[#e6e6e6] shadow-sm rounded-md p-4 bg-white",children:[t.jsx(R,{label:"Country",placeholder:"Country",value:n||"US",onChange:e=>l({country:e}),options:g,autoComplete:"shipping country",schema:M.shape.country}),t.jsx(D,{value:C,onChange:e=>l({address:e}),onAddressSelect:e=>{l({address:e.address,address2:e.address2||"",city:e.city||"",state:e.state||"",zipCode:e.zipCode||"",country:e.country||n||"US"})},apiKey:b||"",region:n,schema:M.shape.address,autoComplete:"shipping address-line1"}),t.jsx(W,{label:"Address Line 2",placeholder:"Address Line 2",value:v||"",onChange:e=>l({address2:e.target.value}),inputClass:"w-full",autoComplete:"shipping address-line2",schema:M.shape.address2}),S()]})]})};V.__docgenInfo={description:"",methods:[],displayName:"DeliveryAddress",props:{showTitle:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}}};export{V as D};
@@ -0,0 +1,9 @@
1
+ import{j as o}from"./jsx-runtime-DiklIkkE.js";import{D as c}from"./DeliveryAddress-X81XGbKD.js";import{C as m,S as d,c as u,D as f}from"./useCheckoutContext-B8tsk5b5.js";import"./index-DRjF_FHU.js";import"./ValidateInput-Cl2O4HCX.js";u(f);const g=[{sku:"TEST001",offerPricePoint:d.SINGLE}],D={component:c,title:"Components/DeliveryAddress",parameters:{docs:{description:{component:"Delivery address form component for collecting shipping address information. Supports Google Places autocomplete when googleApiKey is provided. Requires CheckoutProvider wrapper."}}},decorators:[p=>o.jsx(m,{cart:g,googleApiKey:"AIzaSyCtZ0TqBCGRf1OtLwTmJANQ4_sOpTs5x1w",children:o.jsx(p,{})})],argTypes:{showTitle:{description:'Whether to display the title "Delivery Address"',control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"true"}}}}},e={args:{showTitle:!0}},r={args:{showTitle:!1}};var s,t,a;e.parameters={...e.parameters,docs:{...(s=e.parameters)==null?void 0:s.docs,source:{originalSource:`{
2
+ args: {
3
+ showTitle: true
4
+ }
5
+ }`,...(a=(t=e.parameters)==null?void 0:t.docs)==null?void 0:a.source}}};var i,n,l;r.parameters={...r.parameters,docs:{...(i=r.parameters)==null?void 0:i.docs,source:{originalSource:`{
6
+ args: {
7
+ showTitle: false
8
+ }
9
+ }`,...(l=(n=r.parameters)==null?void 0:n.docs)==null?void 0:l.source}}};const P=["Default","WithoutTitle"];export{e as Default,r as WithoutTitle,P as __namedExportsOrder,D as default};
@@ -0,0 +1,9 @@
1
+ import{j as o}from"./jsx-runtime-DiklIkkE.js";import{D as c}from"./DeliveryAddress-CD42v0od.js";import{C as m,S as d,c as u,D as f}from"./useCheckoutContext-C6u4Rp5U.js";import"./index-DRjF_FHU.js";import"./ValidateInput-sZgX3GCF.js";u(f);const g=[{sku:"TEST001",offerPricePoint:d.SINGLE}],D={component:c,title:"Components/DeliveryAddress",parameters:{docs:{description:{component:"Delivery address form component for collecting shipping address information. Supports Google Places autocomplete when googleApiKey is provided. Requires CheckoutProvider wrapper."}}},decorators:[p=>o.jsx(m,{cart:g,googleApiKey:"AIzaSyCtZ0TqBCGRf1OtLwTmJANQ4_sOpTs5x1w",children:o.jsx(p,{})})],argTypes:{showTitle:{description:'Whether to display the title "Delivery Address"',control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"true"}}}}},e={args:{showTitle:!0}},r={args:{showTitle:!1}};var s,t,a;e.parameters={...e.parameters,docs:{...(s=e.parameters)==null?void 0:s.docs,source:{originalSource:`{
2
+ args: {
3
+ showTitle: true
4
+ }
5
+ }`,...(a=(t=e.parameters)==null?void 0:t.docs)==null?void 0:a.source}}};var i,n,l;r.parameters={...r.parameters,docs:{...(i=r.parameters)==null?void 0:i.docs,source:{originalSource:`{
6
+ args: {
7
+ showTitle: false
8
+ }
9
+ }`,...(l=(n=r.parameters)==null?void 0:n.docs)==null?void 0:l.source}}};const P=["Default","WithoutTitle"];export{e as Default,r as WithoutTitle,P as __namedExportsOrder,D as default};
@@ -0,0 +1,9 @@
1
+ import{j as o}from"./jsx-runtime-DiklIkkE.js";import{D as c}from"./DeliveryAddress-Lfanl1PO.js";import{C as m,S as d,c as u,D as f}from"./useCheckoutContext-DuJ1Ep0-.js";import"./index-DRjF_FHU.js";import"./ValidateInput-DcnOO9py.js";u(f);const g=[{sku:"TEST001",offerPricePoint:d.SINGLE}],D={component:c,title:"Components/DeliveryAddress",parameters:{docs:{description:{component:"Delivery address form component for collecting shipping address information. Supports Google Places autocomplete when googleApiKey is provided. Requires CheckoutProvider wrapper."}}},decorators:[p=>o.jsx(m,{cart:g,googleApiKey:"AIzaSyCtZ0TqBCGRf1OtLwTmJANQ4_sOpTs5x1w",children:o.jsx(p,{})})],argTypes:{showTitle:{description:'Whether to display the title "Delivery Address"',control:"boolean",table:{type:{summary:"boolean"},defaultValue:{summary:"true"}}}}},e={args:{showTitle:!0}},r={args:{showTitle:!1}};var s,t,a;e.parameters={...e.parameters,docs:{...(s=e.parameters)==null?void 0:s.docs,source:{originalSource:`{
2
+ args: {
3
+ showTitle: true
4
+ }
5
+ }`,...(a=(t=e.parameters)==null?void 0:t.docs)==null?void 0:a.source}}};var i,n,l;r.parameters={...r.parameters,docs:{...(i=r.parameters)==null?void 0:i.docs,source:{originalSource:`{
6
+ args: {
7
+ showTitle: false
8
+ }
9
+ }`,...(l=(n=r.parameters)==null?void 0:n.docs)==null?void 0:l.source}}};const P=["Default","WithoutTitle"];export{e as Default,r as WithoutTitle,P as __namedExportsOrder,D as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-ChEI-nsM.js","./index-DRjF_FHU.js"])))=>i.map(i=>d[i]);
2
+ import{_ as c}from"./iframe-DsSsblW_.js";import{R as e,r as p}from"./index-DRjF_FHU.js";import{H as l,A as u,b as h,D as E}from"./index-CkNSuRJg.js";import{renderElement as d,unmountElement as x}from"./react-18-2zMCfgG4.js";import"./jsx-runtime-DiklIkkE.js";import"./index-B7ki2Uzk.js";import"./index-D-Mha1DF.js";import"./index-DrFu-skq.js";var D={code:h,a:u,...l},_=class extends p.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){let{showException:r}=this.props;r(t)}render(){let{hasError:t}=this.state,{children:r}=this.props;return t?null:e.createElement(e.Fragment,null,r)}},A=class{constructor(){this.render=async(t,r,n)=>{let s={...D,...r==null?void 0:r.components},a=E;return new Promise((m,i)=>{c(async()=>{const{MDXProvider:o}=await import("./index-ChEI-nsM.js");return{MDXProvider:o}},__vite__mapDeps([0,1]),import.meta.url).then(({MDXProvider:o})=>d(e.createElement(_,{showException:i,key:Math.random()},e.createElement(o,{components:s},e.createElement(a,{context:t,docsParameter:r}))),n)).then(()=>m())})},this.unmount=t=>{x(t)}}};export{A as DocsRenderer,D as defaultComponents};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-ChEI-nsM.js","./index-DRjF_FHU.js"])))=>i.map(i=>d[i]);
2
+ import{_ as c}from"./iframe-PThBYPHV.js";import{R as e,r as p}from"./index-DRjF_FHU.js";import{H as l,A as u,b as h,D as E}from"./index-CZFGp9Su.js";import{renderElement as d,unmountElement as x}from"./react-18-2zMCfgG4.js";import"./jsx-runtime-DiklIkkE.js";import"./index-B7ki2Uzk.js";import"./index-D-Mha1DF.js";import"./index-DrFu-skq.js";var D={code:h,a:u,...l},_=class extends p.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){let{showException:r}=this.props;r(t)}render(){let{hasError:t}=this.state,{children:r}=this.props;return t?null:e.createElement(e.Fragment,null,r)}},A=class{constructor(){this.render=async(t,r,n)=>{let s={...D,...r==null?void 0:r.components},a=E;return new Promise((m,i)=>{c(async()=>{const{MDXProvider:o}=await import("./index-ChEI-nsM.js");return{MDXProvider:o}},__vite__mapDeps([0,1]),import.meta.url).then(({MDXProvider:o})=>d(e.createElement(_,{showException:i,key:Math.random()},e.createElement(o,{components:s},e.createElement(a,{context:t,docsParameter:r}))),n)).then(()=>m())})},this.unmount=t=>{x(t)}}};export{A as DocsRenderer,D as defaultComponents};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-ChEI-nsM.js","./index-DRjF_FHU.js"])))=>i.map(i=>d[i]);
2
+ import{_ as c}from"./iframe-Ce3kgeV4.js";import{R as e,r as p}from"./index-DRjF_FHU.js";import{H as l,A as u,b as h,D as E}from"./index-LRKEu_dQ.js";import{renderElement as d,unmountElement as x}from"./react-18-2zMCfgG4.js";import"./jsx-runtime-DiklIkkE.js";import"./index-B7ki2Uzk.js";import"./index-D-Mha1DF.js";import"./index-DrFu-skq.js";var D={code:h,a:u,...l},_=class extends p.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){let{showException:r}=this.props;r(t)}render(){let{hasError:t}=this.state,{children:r}=this.props;return t?null:e.createElement(e.Fragment,null,r)}},A=class{constructor(){this.render=async(t,r,n)=>{let s={...D,...r==null?void 0:r.components},a=E;return new Promise((m,i)=>{c(async()=>{const{MDXProvider:o}=await import("./index-ChEI-nsM.js");return{MDXProvider:o}},__vite__mapDeps([0,1]),import.meta.url).then(({MDXProvider:o})=>d(e.createElement(_,{showException:i,key:Math.random()},e.createElement(o,{components:s},e.createElement(a,{context:t,docsParameter:r}))),n)).then(()=>m())})},this.unmount=t=>{x(t)}}};export{A as DocsRenderer,D as defaultComponents};
@@ -0,0 +1,107 @@
1
+ import{j as e}from"./jsx-runtime-DiklIkkE.js";import{useMDXComponents as r}from"./index-ChEI-nsM.js";import{M as c,C as t,a as d}from"./index-CZFGp9Su.js";import{Default as s}from"./PaymentMethods.stories-Bc4jYrum.js";import{D as a}from"./CustomCheckout.stories-F2GZKkIG.js";import"./index-DRjF_FHU.js";import"./iframe-PThBYPHV.js";import"./index-B7ki2Uzk.js";import"./index-D-Mha1DF.js";import"./index-DrFu-skq.js";import"./PaymentMethods-e9HqQtxN.js";import"./useCheckoutContext-DuJ1Ep0-.js";/* empty css */import"./CheckoutPage-CrHN6Fcv.js";import"./CustomerInfo-D3WHpN32.js";import"./ValidateInput-DcnOO9py.js";import"./DeliveryAddress-Lfanl1PO.js";function i(o){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...o.components};return e.jsxs(e.Fragment,{children:[e.jsx(c,{title:"Documentation/Guide"}),`
2
+ `,e.jsx(n.h1,{id:"getting-started-guide",children:"Getting Started Guide"}),`
3
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"@clickaroo/checkout-ui"})," is a comprehensive checkout page component library designed for React applications, providing a complete checkout flow solution. The library includes core features such as customer information collection, delivery address management, payment method selection, and integrates seamlessly with payment systems."]}),`
4
+ `,e.jsx(n.p,{children:"This guide will walk you through different ways to integrate the checkout components into your React application, from the simplest all-in-one solution to fully customized implementations."}),`
5
+ `,e.jsxs(n.blockquote,{children:[`
6
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Note"}),": If you're new to this library, we recommend starting with the ",e.jsx(n.a,{href:"./?path=/docs/documentation-quickstart--docs",children:"Quick Start Guide"})," which covers installation, basic usage with ",e.jsx(n.code,{children:"CheckoutPage"}),", and event callbacks."]}),`
7
+ `]}),`
8
+ `,e.jsx(n.h3,{id:"quick-integration-with-checkoutpage",children:"Quick Integration with CheckoutPage"}),`
9
+ `,e.jsxs(n.p,{children:["The simplest way to integrate is using the ",e.jsx(n.code,{children:"CheckoutPage"})," component, which includes the complete checkout flow. With this single component, you can quickly integrate a full-featured checkout experience."]}),`
10
+ `,e.jsxs(n.p,{children:["👉 See the ",e.jsx(n.a,{href:"./?path=/docs/documentation-quickstart--docs#use-checkout-all-in-one",children:"Use Checkout All in One"})," section in the Quick Start Guide for detailed instructions and examples."]}),`
11
+ `,e.jsx(n.h3,{id:"payment-only-integration",children:"Payment-Only Integration"}),`
12
+ `,e.jsxs(n.p,{children:["If you only need payment functionality and have already collected customer and address information elsewhere in your application, you can use the ",e.jsx(n.code,{children:"PaymentMethods"})," component independently."]}),`
13
+ `,e.jsx(t,{of:s}),`
14
+ `,e.jsx(n.h4,{id:"props",children:"Props"}),`
15
+ `,e.jsx(d,{of:s}),`
16
+ `,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { CheckoutProvider, PaymentMethods } from '@clickaroo/checkout-ui';
17
+
18
+ function PaymentOnly() {
19
+ const cart = [
20
+ {
21
+ sku: "TEST001",
22
+ offerPricePoint: "OPP-TEST001",
23
+ },
24
+ {
25
+ sku: "TEST002",
26
+ offerPricePoint: "OPP-TEST002",
27
+ },
28
+ ];
29
+
30
+ return (
31
+ <CheckoutProvider cart={cart}>
32
+ <PaymentMethods />
33
+ </CheckoutProvider>
34
+ );
35
+ }
36
+ `})}),`
37
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Important Notes:"}),`
38
+ The `,e.jsx(n.code,{children:"PaymentMethods"})," component must be wrapped in a ",e.jsx(n.code,{children:"CheckoutProvider"}),". See ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english#using-checkoutprovider",children:"CheckoutProvider Props"})," for all available configuration options."]}),`
39
+ `,e.jsx(n.p,{children:"To complete the full payment flow (including order submission), you'll need to use the APIs and hooks provided by the library:"}),`
40
+ `,e.jsxs(n.ol,{children:[`
41
+ `,e.jsxs(n.li,{children:["Update customer and address information using ",e.jsx(n.code,{children:"updateCustomerInfo"})," and ",e.jsx(n.code,{children:"updateDeliveryAddress"})," from ",e.jsx(n.code,{children:"useCheckoutContext"})," hook"]}),`
42
+ `,e.jsxs(n.li,{children:["Use the ",e.jsx(n.code,{children:"useOrderSubmission"})," hook to handle order submission"]}),`
43
+ `,e.jsxs(n.li,{children:["Create a custom submit button that calls ",e.jsx(n.code,{children:"submitOrder()"})," from the ",e.jsx(n.code,{children:"useOrderSubmission"})," hook when clicked"]}),`
44
+ `]}),`
45
+ `,e.jsxs(n.p,{children:["For a complete implementation example, see the ",e.jsx(n.a,{href:"./?path=/docs/documentation-apis--docs",children:"APIs documentation"})," section on ",e.jsx(n.code,{children:"useOrderSubmission"}),"."]}),`
46
+ `,e.jsx(n.h3,{id:"custom-checkout",children:"Custom Checkout"}),`
47
+ `,e.jsx(n.p,{children:"You can build a custom checkout page by mixing and matching the library's built-in components with your own custom components. This gives you full control over the layout, styling, and user experience while leveraging the library's functionality."}),`
48
+ `,e.jsx(t,{of:a}),`
49
+ `,e.jsxs(n.p,{children:["You can replace some built-in components with your own custom implementations, but ",e.jsxs(n.strong,{children:[e.jsx(n.code,{children:"PaymentMethods"})," must always be used from the library"]})," as it contains critical payment logic that cannot be customized."]}),`
50
+ `,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import {
51
+ CheckoutProvider,
52
+ PaymentMethods,
53
+ useCheckoutContext,
54
+ useOrderSubmission
55
+ } from '@clickaroo/checkout-ui';
56
+
57
+ function CustomCheckout() {
58
+ const cart = [{ sku: "TEST001", offerPricePoint: "OPP-TEST001" }];
59
+
60
+ return (
61
+ // All components must be wrapped in CheckoutProvider
62
+ <CheckoutProvider cart={cart}>
63
+ <MyCustomCustomerInfo />
64
+ <MyCustomDeliveryAddress />
65
+ <PaymentMethods /> {/* Required - cannot be customized */}
66
+ <MyCustomSubmitButton />
67
+ </CheckoutProvider>
68
+ );
69
+ }
70
+
71
+ // Use hooks to build custom components
72
+ function MyCustomCustomerInfo() {
73
+ const { customerInfo, updateCustomerInfo } = useCheckoutContext();
74
+ // use hook to update form data
75
+ updateCustomerInfo({ firstName: 'xxx', lastName: 'xxx', ...})
76
+ }
77
+
78
+ function MyCustomDeliveryAddress() {
79
+ const { deliveryAddress, updateDeliveryAddress } = useCheckoutContext();
80
+ // Your custom form implementation
81
+ }
82
+
83
+ function MyCustomSubmitButton() {
84
+ const { isFormValid } = useCheckoutContext();
85
+ // use hook to handle order submission
86
+ const { isSubmitting, submitOrder } = useOrderSubmission();
87
+ // Your custom button implementation
88
+ }
89
+ `})}),`
90
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Important Notes:"})," All components must be wrapped in CheckoutProvider. See ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english#using-checkoutprovider",children:"CheckoutProvider Props"})," for all available configuration options."]}),`
91
+ `,e.jsxs(n.p,{children:["For a complete implementation example, see the ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english",children:"CustomCheckout documentation"}),"."]}),`
92
+ `,e.jsx(n.h3,{id:"apis-and-hooks",children:"APIs and Hooks"}),`
93
+ `,e.jsx(n.p,{children:"As mentioned above, the component library provides HTTP APIs and React Hooks for more granular control and advanced use cases."}),`
94
+ `,e.jsx(n.h4,{id:"http-apis",children:"HTTP APIs"}),`
95
+ `,e.jsxs(n.ul,{children:[`
96
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"getPricePointInfo"})})," - Get price point information (supports single or multiple price points)"]}),`
97
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"createOrder"})})," - Create an order with the provided order data"]}),`
98
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"getOrderDetail"})})," - Get detailed information about an order by order code"]}),`
99
+ `]}),`
100
+ `,e.jsx(n.h4,{id:"react-hooks",children:"React Hooks"}),`
101
+ `,e.jsxs(n.ul,{children:[`
102
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useCheckoutContext"})})," - Access checkout state and update functions (customer info, delivery address, form validation)"]}),`
103
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useOrderSubmission"})})," - Handle order submission with loading states and error handling"]}),`
104
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useOrderDetail"})})," - Fetch order details"]}),`
105
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"usePricePointInfo"})})," - Get price point information"]}),`
106
+ `]}),`
107
+ `,e.jsxs(n.p,{children:["For detailed API documentation and hook usage examples, see the ",e.jsx(n.a,{href:"./?path=/docs/documentation-apis--docs",children:"APIs Documentation"}),"."]})]})}function I(o={}){const{wrapper:n}={...r(),...o.components};return n?e.jsx(n,{...o,children:e.jsx(i,{...o})}):i(o)}export{I as default};
@@ -0,0 +1,107 @@
1
+ import{j as e}from"./jsx-runtime-DiklIkkE.js";import{useMDXComponents as r}from"./index-ChEI-nsM.js";import{M as c,C as t,a as d}from"./index-LRKEu_dQ.js";import{Default as s}from"./PaymentMethods.stories-pOuLDPwE.js";import{D as a}from"./CustomCheckout.stories-CKQKzMq0.js";import"./index-DRjF_FHU.js";import"./iframe-Ce3kgeV4.js";import"./index-B7ki2Uzk.js";import"./index-D-Mha1DF.js";import"./index-DrFu-skq.js";import"./PaymentMethods-BNEEARzu.js";import"./useCheckoutContext-B8tsk5b5.js";/* empty css */import"./CheckoutPage-BsnzMxJk.js";import"./CustomerInfo-CTx1dFS3.js";import"./ValidateInput-Cl2O4HCX.js";import"./DeliveryAddress-X81XGbKD.js";function i(o){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...o.components};return e.jsxs(e.Fragment,{children:[e.jsx(c,{title:"Documentation/Guide"}),`
2
+ `,e.jsx(n.h1,{id:"getting-started-guide",children:"Getting Started Guide"}),`
3
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"@clickaroo/checkout-ui"})," is a comprehensive checkout page component library designed for React applications, providing a complete checkout flow solution. The library includes core features such as customer information collection, delivery address management, payment method selection, and integrates seamlessly with payment systems."]}),`
4
+ `,e.jsx(n.p,{children:"This guide will walk you through different ways to integrate the checkout components into your React application, from the simplest all-in-one solution to fully customized implementations."}),`
5
+ `,e.jsxs(n.blockquote,{children:[`
6
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Note"}),": If you're new to this library, we recommend starting with the ",e.jsx(n.a,{href:"./?path=/docs/documentation-quickstart--docs",children:"Quick Start Guide"})," which covers installation, basic usage with ",e.jsx(n.code,{children:"CheckoutPage"}),", and event callbacks."]}),`
7
+ `]}),`
8
+ `,e.jsx(n.h3,{id:"quick-integration-with-checkoutpage",children:"Quick Integration with CheckoutPage"}),`
9
+ `,e.jsxs(n.p,{children:["The simplest way to integrate is using the ",e.jsx(n.code,{children:"CheckoutPage"})," component, which includes the complete checkout flow. With this single component, you can quickly integrate a full-featured checkout experience."]}),`
10
+ `,e.jsxs(n.p,{children:["👉 See the ",e.jsx(n.a,{href:"./?path=/docs/documentation-quickstart--docs#use-checkout-all-in-one",children:"Use Checkout All in One"})," section in the Quick Start Guide for detailed instructions and examples."]}),`
11
+ `,e.jsx(n.h3,{id:"payment-only-integration",children:"Payment-Only Integration"}),`
12
+ `,e.jsxs(n.p,{children:["If you only need payment functionality and have already collected customer and address information elsewhere in your application, you can use the ",e.jsx(n.code,{children:"PaymentMethods"})," component independently."]}),`
13
+ `,e.jsx(t,{of:s}),`
14
+ `,e.jsx(n.h4,{id:"props",children:"Props"}),`
15
+ `,e.jsx(d,{of:s}),`
16
+ `,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { CheckoutProvider, PaymentMethods } from '@clickaroo/checkout-ui';
17
+
18
+ function PaymentOnly() {
19
+ const cart = [
20
+ {
21
+ sku: "TEST001",
22
+ offerPricePoint: "OPP-TEST001",
23
+ },
24
+ {
25
+ sku: "TEST002",
26
+ offerPricePoint: "OPP-TEST002",
27
+ },
28
+ ];
29
+
30
+ return (
31
+ <CheckoutProvider cart={cart}>
32
+ <PaymentMethods />
33
+ </CheckoutProvider>
34
+ );
35
+ }
36
+ `})}),`
37
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Important Notes:"}),`
38
+ The `,e.jsx(n.code,{children:"PaymentMethods"})," component must be wrapped in a ",e.jsx(n.code,{children:"CheckoutProvider"}),". See ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english#using-checkoutprovider",children:"CheckoutProvider Props"})," for all available configuration options."]}),`
39
+ `,e.jsx(n.p,{children:"To complete the full payment flow (including order submission), you'll need to use the APIs and hooks provided by the library:"}),`
40
+ `,e.jsxs(n.ol,{children:[`
41
+ `,e.jsxs(n.li,{children:["Update customer and address information using ",e.jsx(n.code,{children:"updateCustomerInfo"})," and ",e.jsx(n.code,{children:"updateDeliveryAddress"})," from ",e.jsx(n.code,{children:"useCheckoutContext"})," hook"]}),`
42
+ `,e.jsxs(n.li,{children:["Use the ",e.jsx(n.code,{children:"useOrderSubmission"})," hook to handle order submission"]}),`
43
+ `,e.jsxs(n.li,{children:["Create a custom submit button that calls ",e.jsx(n.code,{children:"submitOrder()"})," from the ",e.jsx(n.code,{children:"useOrderSubmission"})," hook when clicked"]}),`
44
+ `]}),`
45
+ `,e.jsxs(n.p,{children:["For a complete implementation example, see the ",e.jsx(n.a,{href:"./?path=/docs/documentation-apis--docs",children:"APIs documentation"})," section on ",e.jsx(n.code,{children:"useOrderSubmission"}),"."]}),`
46
+ `,e.jsx(n.h3,{id:"custom-checkout",children:"Custom Checkout"}),`
47
+ `,e.jsx(n.p,{children:"You can build a custom checkout page by mixing and matching the library's built-in components with your own custom components. This gives you full control over the layout, styling, and user experience while leveraging the library's functionality."}),`
48
+ `,e.jsx(t,{of:a}),`
49
+ `,e.jsxs(n.p,{children:["You can replace some built-in components with your own custom implementations, but ",e.jsxs(n.strong,{children:[e.jsx(n.code,{children:"PaymentMethods"})," must always be used from the library"]})," as it contains critical payment logic that cannot be customized."]}),`
50
+ `,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import {
51
+ CheckoutProvider,
52
+ PaymentMethods,
53
+ useCheckoutContext,
54
+ useOrderSubmission
55
+ } from '@clickaroo/checkout-ui';
56
+
57
+ function CustomCheckout() {
58
+ const cart = [{ sku: "TEST001", offerPricePoint: "OPP-TEST001" }];
59
+
60
+ return (
61
+ // All components must be wrapped in CheckoutProvider
62
+ <CheckoutProvider cart={cart}>
63
+ <MyCustomCustomerInfo />
64
+ <MyCustomDeliveryAddress />
65
+ <PaymentMethods /> {/* Required - cannot be customized */}
66
+ <MyCustomSubmitButton />
67
+ </CheckoutProvider>
68
+ );
69
+ }
70
+
71
+ // Use hooks to build custom components
72
+ function MyCustomCustomerInfo() {
73
+ const { customerInfo, updateCustomerInfo } = useCheckoutContext();
74
+ // use hook to update form data
75
+ updateCustomerInfo({ firstName: 'xxx', lastName: 'xxx', ...})
76
+ }
77
+
78
+ function MyCustomDeliveryAddress() {
79
+ const { deliveryAddress, updateDeliveryAddress } = useCheckoutContext();
80
+ // Your custom form implementation
81
+ }
82
+
83
+ function MyCustomSubmitButton() {
84
+ const { isFormValid } = useCheckoutContext();
85
+ // use hook to handle order submission
86
+ const { isSubmitting, submitOrder } = useOrderSubmission();
87
+ // Your custom button implementation
88
+ }
89
+ `})}),`
90
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Important Notes:"})," All components must be wrapped in CheckoutProvider. See ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english#using-checkoutprovider",children:"CheckoutProvider Props"})," for all available configuration options."]}),`
91
+ `,e.jsxs(n.p,{children:["For a complete implementation example, see the ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english",children:"CustomCheckout documentation"}),"."]}),`
92
+ `,e.jsx(n.h3,{id:"apis-and-hooks",children:"APIs and Hooks"}),`
93
+ `,e.jsx(n.p,{children:"As mentioned above, the component library provides HTTP APIs and React Hooks for more granular control and advanced use cases."}),`
94
+ `,e.jsx(n.h4,{id:"http-apis",children:"HTTP APIs"}),`
95
+ `,e.jsxs(n.ul,{children:[`
96
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"getPricePointInfo"})})," - Get price point information (supports single or multiple price points)"]}),`
97
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"createOrder"})})," - Create an order with the provided order data"]}),`
98
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"getOrderDetail"})})," - Get detailed information about an order by order code"]}),`
99
+ `]}),`
100
+ `,e.jsx(n.h4,{id:"react-hooks",children:"React Hooks"}),`
101
+ `,e.jsxs(n.ul,{children:[`
102
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useCheckoutContext"})})," - Access checkout state and update functions (customer info, delivery address, form validation)"]}),`
103
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useOrderSubmission"})})," - Handle order submission with loading states and error handling"]}),`
104
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useOrderDetail"})})," - Fetch order details"]}),`
105
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"usePricePointInfo"})})," - Get price point information"]}),`
106
+ `]}),`
107
+ `,e.jsxs(n.p,{children:["For detailed API documentation and hook usage examples, see the ",e.jsx(n.a,{href:"./?path=/docs/documentation-apis--docs",children:"APIs Documentation"}),"."]})]})}function I(o={}){const{wrapper:n}={...r(),...o.components};return n?e.jsx(n,{...o,children:e.jsx(i,{...o})}):i(o)}export{I as default};
@@ -0,0 +1,107 @@
1
+ import{j as e}from"./jsx-runtime-DiklIkkE.js";import{useMDXComponents as r}from"./index-ChEI-nsM.js";import{M as c,C as t,a as d}from"./index-CkNSuRJg.js";import{Default as s}from"./PaymentMethods.stories-ChiL9TJn.js";import{D as a}from"./CustomCheckout.stories-V2NHLbZo.js";import"./index-DRjF_FHU.js";import"./iframe-DsSsblW_.js";import"./index-B7ki2Uzk.js";import"./index-D-Mha1DF.js";import"./index-DrFu-skq.js";import"./PaymentMethods-BnPZRrAs.js";import"./useCheckoutContext-C6u4Rp5U.js";/* empty css */import"./CheckoutPage-DYMMhAMX.js";import"./CustomerInfo-Cp0u57C5.js";import"./ValidateInput-sZgX3GCF.js";import"./DeliveryAddress-CD42v0od.js";function i(o){const n={a:"a",blockquote:"blockquote",code:"code",h1:"h1",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...r(),...o.components};return e.jsxs(e.Fragment,{children:[e.jsx(c,{title:"Documentation/Guide"}),`
2
+ `,e.jsx(n.h1,{id:"getting-started-guide",children:"Getting Started Guide"}),`
3
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"@clickaroo/checkout-ui"})," is a comprehensive checkout page component library designed for React applications, providing a complete checkout flow solution. The library includes core features such as customer information collection, delivery address management, payment method selection, and integrates seamlessly with payment systems."]}),`
4
+ `,e.jsx(n.p,{children:"This guide will walk you through different ways to integrate the checkout components into your React application, from the simplest all-in-one solution to fully customized implementations."}),`
5
+ `,e.jsxs(n.blockquote,{children:[`
6
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Note"}),": If you're new to this library, we recommend starting with the ",e.jsx(n.a,{href:"./?path=/docs/documentation-quickstart--docs",children:"Quick Start Guide"})," which covers installation, basic usage with ",e.jsx(n.code,{children:"CheckoutPage"}),", and event callbacks."]}),`
7
+ `]}),`
8
+ `,e.jsx(n.h3,{id:"quick-integration-with-checkoutpage",children:"Quick Integration with CheckoutPage"}),`
9
+ `,e.jsxs(n.p,{children:["The simplest way to integrate is using the ",e.jsx(n.code,{children:"CheckoutPage"})," component, which includes the complete checkout flow. With this single component, you can quickly integrate a full-featured checkout experience."]}),`
10
+ `,e.jsxs(n.p,{children:["👉 See the ",e.jsx(n.a,{href:"./?path=/docs/documentation-quickstart--docs#use-checkout-all-in-one",children:"Use Checkout All in One"})," section in the Quick Start Guide for detailed instructions and examples."]}),`
11
+ `,e.jsx(n.h3,{id:"payment-only-integration",children:"Payment-Only Integration"}),`
12
+ `,e.jsxs(n.p,{children:["If you only need payment functionality and have already collected customer and address information elsewhere in your application, you can use the ",e.jsx(n.code,{children:"PaymentMethods"})," component independently."]}),`
13
+ `,e.jsx(t,{of:s}),`
14
+ `,e.jsx(n.h4,{id:"props",children:"Props"}),`
15
+ `,e.jsx(d,{of:s}),`
16
+ `,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import { CheckoutProvider, PaymentMethods } from '@clickaroo/checkout-ui';
17
+
18
+ function PaymentOnly() {
19
+ const cart = [
20
+ {
21
+ sku: "TEST001",
22
+ offerPricePoint: "OPP-TEST001",
23
+ },
24
+ {
25
+ sku: "TEST002",
26
+ offerPricePoint: "OPP-TEST002",
27
+ },
28
+ ];
29
+
30
+ return (
31
+ <CheckoutProvider cart={cart}>
32
+ <PaymentMethods />
33
+ </CheckoutProvider>
34
+ );
35
+ }
36
+ `})}),`
37
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Important Notes:"}),`
38
+ The `,e.jsx(n.code,{children:"PaymentMethods"})," component must be wrapped in a ",e.jsx(n.code,{children:"CheckoutProvider"}),". See ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english#using-checkoutprovider",children:"CheckoutProvider Props"})," for all available configuration options."]}),`
39
+ `,e.jsx(n.p,{children:"To complete the full payment flow (including order submission), you'll need to use the APIs and hooks provided by the library:"}),`
40
+ `,e.jsxs(n.ol,{children:[`
41
+ `,e.jsxs(n.li,{children:["Update customer and address information using ",e.jsx(n.code,{children:"updateCustomerInfo"})," and ",e.jsx(n.code,{children:"updateDeliveryAddress"})," from ",e.jsx(n.code,{children:"useCheckoutContext"})," hook"]}),`
42
+ `,e.jsxs(n.li,{children:["Use the ",e.jsx(n.code,{children:"useOrderSubmission"})," hook to handle order submission"]}),`
43
+ `,e.jsxs(n.li,{children:["Create a custom submit button that calls ",e.jsx(n.code,{children:"submitOrder()"})," from the ",e.jsx(n.code,{children:"useOrderSubmission"})," hook when clicked"]}),`
44
+ `]}),`
45
+ `,e.jsxs(n.p,{children:["For a complete implementation example, see the ",e.jsx(n.a,{href:"./?path=/docs/documentation-apis--docs",children:"APIs documentation"})," section on ",e.jsx(n.code,{children:"useOrderSubmission"}),"."]}),`
46
+ `,e.jsx(n.h3,{id:"custom-checkout",children:"Custom Checkout"}),`
47
+ `,e.jsx(n.p,{children:"You can build a custom checkout page by mixing and matching the library's built-in components with your own custom components. This gives you full control over the layout, styling, and user experience while leveraging the library's functionality."}),`
48
+ `,e.jsx(t,{of:a}),`
49
+ `,e.jsxs(n.p,{children:["You can replace some built-in components with your own custom implementations, but ",e.jsxs(n.strong,{children:[e.jsx(n.code,{children:"PaymentMethods"})," must always be used from the library"]})," as it contains critical payment logic that cannot be customized."]}),`
50
+ `,e.jsx(n.pre,{children:e.jsx(n.code,{className:"language-tsx",children:`import {
51
+ CheckoutProvider,
52
+ PaymentMethods,
53
+ useCheckoutContext,
54
+ useOrderSubmission
55
+ } from '@clickaroo/checkout-ui';
56
+
57
+ function CustomCheckout() {
58
+ const cart = [{ sku: "TEST001", offerPricePoint: "OPP-TEST001" }];
59
+
60
+ return (
61
+ // All components must be wrapped in CheckoutProvider
62
+ <CheckoutProvider cart={cart}>
63
+ <MyCustomCustomerInfo />
64
+ <MyCustomDeliveryAddress />
65
+ <PaymentMethods /> {/* Required - cannot be customized */}
66
+ <MyCustomSubmitButton />
67
+ </CheckoutProvider>
68
+ );
69
+ }
70
+
71
+ // Use hooks to build custom components
72
+ function MyCustomCustomerInfo() {
73
+ const { customerInfo, updateCustomerInfo } = useCheckoutContext();
74
+ // use hook to update form data
75
+ updateCustomerInfo({ firstName: 'xxx', lastName: 'xxx', ...})
76
+ }
77
+
78
+ function MyCustomDeliveryAddress() {
79
+ const { deliveryAddress, updateDeliveryAddress } = useCheckoutContext();
80
+ // Your custom form implementation
81
+ }
82
+
83
+ function MyCustomSubmitButton() {
84
+ const { isFormValid } = useCheckoutContext();
85
+ // use hook to handle order submission
86
+ const { isSubmitting, submitOrder } = useOrderSubmission();
87
+ // Your custom button implementation
88
+ }
89
+ `})}),`
90
+ `,e.jsxs(n.p,{children:[e.jsx(n.strong,{children:"Important Notes:"})," All components must be wrapped in CheckoutProvider. See ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english#using-checkoutprovider",children:"CheckoutProvider Props"})," for all available configuration options."]}),`
91
+ `,e.jsxs(n.p,{children:["For a complete implementation example, see the ",e.jsx(n.a,{href:"./?path=/docs/components-customcheckout--customcheckout-english",children:"CustomCheckout documentation"}),"."]}),`
92
+ `,e.jsx(n.h3,{id:"apis-and-hooks",children:"APIs and Hooks"}),`
93
+ `,e.jsx(n.p,{children:"As mentioned above, the component library provides HTTP APIs and React Hooks for more granular control and advanced use cases."}),`
94
+ `,e.jsx(n.h4,{id:"http-apis",children:"HTTP APIs"}),`
95
+ `,e.jsxs(n.ul,{children:[`
96
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"getPricePointInfo"})})," - Get price point information (supports single or multiple price points)"]}),`
97
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"createOrder"})})," - Create an order with the provided order data"]}),`
98
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"getOrderDetail"})})," - Get detailed information about an order by order code"]}),`
99
+ `]}),`
100
+ `,e.jsx(n.h4,{id:"react-hooks",children:"React Hooks"}),`
101
+ `,e.jsxs(n.ul,{children:[`
102
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useCheckoutContext"})})," - Access checkout state and update functions (customer info, delivery address, form validation)"]}),`
103
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useOrderSubmission"})})," - Handle order submission with loading states and error handling"]}),`
104
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"useOrderDetail"})})," - Fetch order details"]}),`
105
+ `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:e.jsx(n.code,{children:"usePricePointInfo"})})," - Get price point information"]}),`
106
+ `]}),`
107
+ `,e.jsxs(n.p,{children:["For detailed API documentation and hook usage examples, see the ",e.jsx(n.a,{href:"./?path=/docs/documentation-apis--docs",children:"APIs Documentation"}),"."]})]})}function I(o={}){const{wrapper:n}={...r(),...o.components};return n?e.jsx(n,{...o,children:e.jsx(i,{...o})}):i(o)}export{I as default};
@@ -0,0 +1,2 @@
1
+ import{j as f}from"./jsx-runtime-DiklIkkE.js";import{b as q,t as _}from"./useCheckoutContext-B8tsk5b5.js";import{r as k,g as Re,R as u}from"./index-DRjF_FHU.js";const W=()=>f.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:f.jsxs("svg",{className:"animate-spin h-6 w-6 text-black",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:[f.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),f.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})});W.__docgenInfo={description:"",methods:[],displayName:"Loading"};var V=(r=>(r.OneTime="one-time",r.Subscription="subscription",r))(V||{});const Ie=()=>{const{cart:r,clickarooInfoMap:e,offerPricePoints:t}=q(),n=k.useMemo(()=>r.reduce((o,i)=>{const c=e[i.offerPricePoint];if(!c)return o;const s=H(c);return s&&s.priceInCents>0&&o.push({...i,priceInCents:s.priceInCents,currency:s.currency,quantity:s.quantity,paymentType:c.type==="one_off"?V.OneTime:V.Subscription}),o},[]),[r,e]),a=k.useMemo(()=>{let o=0;return t.forEach(i=>{const c=e[i];if(!c)return;const s=H(c);s&&(o+=s.priceInCents*s.quantity)}),o},[t,e]);return{checkoutProducts:n,totalAmount:a}},H=r=>{if(console.log(r),r.type==="one_off"&&r.one_off)return{priceInCents:r.one_off.price_in_cents||0,currency:r.one_off.currency||"usd",quantity:r.one_off.quantity||1};if(r.type==="subscription_schedules"&&r.subscription_schedules){const e=r.subscription_schedules.find(t=>t.phase===1);if(e)return{priceInCents:e.price_in_cents||0,currency:e.currency||"usd",quantity:e.quantity||1}}return null};var ne={exports:{}},Ae="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Te=Ae,Ne=Te;function oe(){}function ae(){}ae.resetWarningCache=oe;var Le=function(){function r(n,a,o,i,c,s){if(s!==Ne){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function e(){return r}var t={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:e,element:r,elementType:r,instanceOf:e,node:r,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:ae,resetWarningCache:oe};return t.PropTypes=t,t};ne.exports=Le();var Me=ne.exports;const l=Re(Me);function X(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(r,a).enumerable})),t.push.apply(t,n)}return t}function Q(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?X(Object(t),!0).forEach(function(n){se(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):X(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function U(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?U=function(e){return typeof e}:U=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(r)}function se(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Ue(r,e){if(r==null)return{};var t={},n=Object.keys(r),a,o;for(o=0;o<n.length;o++)a=n[o],!(e.indexOf(a)>=0)&&(t[a]=r[a]);return t}function We(r,e){if(r==null)return{};var t=Ue(r,e),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(a=0;a<o.length;a++)n=o[a],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}function ie(r,e){return qe(r)||Be(r,e)||Fe(r,e)||De()}function qe(r){if(Array.isArray(r))return r}function Be(r,e){var t=r&&(typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"]);if(t!=null){var n=[],a=!0,o=!1,i,c;try{for(t=t.call(r);!(a=(i=t.next()).done)&&(n.push(i.value),!(e&&n.length===e));a=!0);}catch(s){o=!0,c=s}finally{try{!a&&t.return!=null&&t.return()}finally{if(o)throw c}}return n}}function Fe(r,e){if(r){if(typeof r=="string")return Z(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Z(r,e)}}function Z(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function De(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var C=function(e,t,n){var a=!!n,o=u.useRef(n);u.useEffect(function(){o.current=n},[n]),u.useEffect(function(){if(!a||!e)return function(){};var i=function(){o.current&&o.current.apply(o,arguments)};return e.on(t,i),function(){e.off(t,i)}},[a,t,e,o])},$=function(e){var t=u.useRef(e);return u.useEffect(function(){t.current=e},[e]),t.current},w=function(e){return e!==null&&U(e)==="object"},Ve=function(e){return w(e)&&typeof e.then=="function"},$e=function(e){return w(e)&&typeof e.elements=="function"&&typeof e.createToken=="function"&&typeof e.createPaymentMethod=="function"&&typeof e.confirmCardPayment=="function"},ee="[object Object]",ze=function r(e,t){if(!w(e)||!w(t))return e===t;var n=Array.isArray(e),a=Array.isArray(t);if(n!==a)return!1;var o=Object.prototype.toString.call(e)===ee,i=Object.prototype.toString.call(t)===ee;if(o!==i)return!1;if(!o&&!n)return e===t;var c=Object.keys(e),s=Object.keys(t);if(c.length!==s.length)return!1;for(var h={},v=0;v<c.length;v+=1)h[c[v]]=!0;for(var E=0;E<s.length;E+=1)h[s[E]]=!0;var p=Object.keys(h);if(p.length!==c.length)return!1;var x=e,b=t,y=function(A){return r(x[A],b[A])};return p.every(y)},ce=function(e,t,n){return w(e)?Object.keys(e).reduce(function(a,o){var i=!w(t)||!ze(e[o],t[o]);return n.includes(o)?(i&&console.warn("Unsupported prop change: options.".concat(o," is not a mutable property.")),a):i?Q(Q({},a||{}),{},se({},o,e[o])):a},null):null},ue="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",te=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ue;if(e===null||$e(e))return e;throw new Error(t)},Je=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ue;if(Ve(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(a){return te(a,t)})};var n=te(e,t);return n===null?{tag:"empty"}:{tag:"sync",stripe:n}},Ye=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},B=u.createContext(null);B.displayName="ElementsContext";var le=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},pe=function(e){var t=e.stripe,n=e.options,a=e.children,o=u.useMemo(function(){return Je(t)},[t]),i=u.useState(function(){return{stripe:o.tag==="sync"?o.stripe:null,elements:o.tag==="sync"?o.stripe.elements(n):null}}),c=ie(i,2),s=c[0],h=c[1];u.useEffect(function(){var p=!0,x=function(y){h(function(O){return O.stripe?O:{stripe:y,elements:y.elements(n)}})};return o.tag==="async"&&!s.stripe?o.stripePromise.then(function(b){b&&p&&x(b)}):o.tag==="sync"&&!s.stripe&&x(o.stripe),function(){p=!1}},[o,s,n]);var v=$(t);u.useEffect(function(){v!==null&&v!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[v,t]);var E=$(n);return u.useEffect(function(){if(s.elements){var p=ce(n,E,["clientSecret","fonts"]);p&&s.elements.update(p)}},[n,E,s.elements]),u.useEffect(function(){Ye(s.stripe)},[s.stripe]),u.createElement(B.Provider,{value:s},a)};pe.propTypes={stripe:l.any,options:l.object};var Ke=function(e){var t=u.useContext(B);return le(t,e)},Ge=function(){var e=Ke("calls useElements()"),t=e.elements;return t};l.func.isRequired;var fe=u.createContext(null);fe.displayName="CheckoutSdkContext";var He=function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e},Xe=u.createContext(null);Xe.displayName="CheckoutContext";l.any,l.shape({fetchClientSecret:l.func.isRequired,elementsOptions:l.object}).isRequired;var z=function(e){var t=u.useContext(fe),n=u.useContext(B);if(t&&n)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return t?He(t,e):le(n,e)},Qe=["mode"],Ze=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},d=function(e,t){var n="".concat(Ze(e),"Element"),a=function(s){var h=s.id,v=s.className,E=s.options,p=E===void 0?{}:E,x=s.onBlur,b=s.onFocus,y=s.onReady,O=s.onChange,A=s.onEscape,ge=s.onClick,Se=s.onLoadError,Ce=s.onLoaderStart,Ee=s.onNetworksChange,be=s.onConfirm,xe=s.onCancel,Pe=s.onShippingAddressChange,je=s.onShippingRateChange,ke=s.onSavedPaymentMethodRemove,_e=s.onSavedPaymentMethodUpdate,T=z("mounts <".concat(n,">")),N="elements"in T?T.elements:null,P="checkoutSdk"in T?T.checkoutSdk:null,we=u.useState(null),J=ie(we,2),g=J[0],Oe=J[1],j=u.useRef(null),F=u.useRef(null);C(g,"blur",x),C(g,"focus",b),C(g,"escape",A),C(g,"click",ge),C(g,"loaderror",Se),C(g,"loaderstart",Ce),C(g,"networkschange",Ee),C(g,"confirm",be),C(g,"cancel",xe),C(g,"shippingaddresschange",Pe),C(g,"shippingratechange",je),C(g,"savedpaymentmethodremove",ke),C(g,"savedpaymentmethodupdate",_e),C(g,"change",O);var D;y&&(e==="expressCheckout"?D=y:D=function(){y(g)}),C(g,"ready",D),u.useLayoutEffect(function(){if(j.current===null&&F.current!==null&&(N||P)){var S=null;if(P)switch(e){case"payment":S=P.createPaymentElement(p);break;case"address":if("mode"in p){var K=p.mode,G=We(p,Qe);if(K==="shipping")S=P.createShippingAddressElement(G);else if(K==="billing")S=P.createBillingAddressElement(G);else throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.")}else throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");break;case"expressCheckout":S=P.createExpressCheckoutElement(p);break;case"currencySelector":S=P.createCurrencySelectorElement();break;case"taxId":S=P.createTaxIdElement(p);break;default:throw new Error("Invalid Element type ".concat(n,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else N&&(S=N.create(e,p));j.current=S,Oe(S),S&&S.mount(F.current)}},[N,P,p]);var Y=$(p);return u.useEffect(function(){if(j.current){var S=ce(p,Y,["paymentRequest"]);S&&"update"in j.current&&j.current.update(S)}},[p,Y]),u.useLayoutEffect(function(){return function(){if(j.current&&typeof j.current.destroy=="function")try{j.current.destroy(),j.current=null}catch{}}},[]),u.createElement("div",{id:h,className:v,ref:F})},o=function(s){z("mounts <".concat(n,">"));var h=s.id,v=s.className;return u.createElement("div",{id:h,className:v})},i=t?o:a;return i.propTypes={id:l.string,className:l.string,onChange:l.func,onBlur:l.func,onFocus:l.func,onReady:l.func,onEscape:l.func,onClick:l.func,onLoadError:l.func,onLoaderStart:l.func,onNetworksChange:l.func,onConfirm:l.func,onCancel:l.func,onShippingAddressChange:l.func,onShippingRateChange:l.func,onSavedPaymentMethodRemove:l.func,onSavedPaymentMethodUpdate:l.func,options:l.object},i.displayName=n,i.__elementType=e,i},m=typeof window>"u",et=u.createContext(null);et.displayName="EmbeddedCheckoutProviderContext";var tt=function(){var e=z("calls useStripe()"),t=e.stripe;return t};d("auBankAccount",m);d("card",m);d("cardNumber",m);d("cardExpiry",m);d("cardCvc",m);d("fpxBank",m);d("iban",m);d("idealBank",m);d("p24Bank",m);d("epsBank",m);var rt=d("payment",m);d("expressCheckout",m);d("currencySelector",m);d("paymentRequestButton",m);d("linkAuthentication",m);d("address",m);d("shippingAddress",m);d("paymentMethodMessaging",m);d("affirmMessage",m);d("afterpayClearpayMessage",m);d("taxId",m);var de="basil",nt=function(e){return e===3?"v3":e},me="https://js.stripe.com",ot="".concat(me,"/").concat(de,"/stripe.js"),at=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,st=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;var it=function(e){return at.test(e)||st.test(e)},ct=function(){for(var e=document.querySelectorAll('script[src^="'.concat(me,'"]')),t=0;t<e.length;t++){var n=e[t];if(it(n.src))return n}return null},re=function(e){var t="",n=document.createElement("script");n.src="".concat(ot).concat(t);var a=document.head||document.body;if(!a)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return a.appendChild(n),n},ut=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:"stripe-js",version:"7.9.0",startTime:t})},R=null,L=null,M=null,lt=function(e){return function(t){e(new Error("Failed to load Stripe.js",{cause:t}))}},pt=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}},ft=function(e){return R!==null?R:(R=new Promise(function(t,n){if(typeof window>"u"||typeof document>"u"){t(null);return}if(window.Stripe){t(window.Stripe);return}try{var a=ct();if(!(a&&e)){if(!a)a=re(e);else if(a&&M!==null&&L!==null){var o;a.removeEventListener("load",M),a.removeEventListener("error",L),(o=a.parentNode)===null||o===void 0||o.removeChild(a),a=re(e)}}M=pt(t,n),L=lt(n),a.addEventListener("load",M),a.addEventListener("error",L)}catch(i){n(i);return}}),R.catch(function(t){return R=null,Promise.reject(t)}))},dt=function(e,t,n){if(e===null)return null;var a=t[0],o=a.match(/^pk_test/),i=nt(e.version),c=de;o&&i!==c&&console.warn("Stripe.js@".concat(i," was loaded on the page, but @stripe/stripe-js@").concat("7.9.0"," expected Stripe.js@").concat(c,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var s=e.apply(void 0,t);return ut(s,n),s},I,ve=!1,he=function(){return I||(I=ft(null).catch(function(e){return I=null,Promise.reject(e)}),I)};Promise.resolve().then(function(){return he()}).catch(function(r){ve||console.warn(r)});var mt=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];ve=!0;var a=Date.now();return he().then(function(o){return dt(o,t,a)})};const vt=({onStripeReady:r,checkoutProducts:e,totalAmount:t})=>{const n=tt(),a=Ge(),{setStripeComplete:o,setStripeLoading:i,onPaymentInfoComplete:c}=q(),[s,h]=k.useState(!1);return k.useEffect(()=>{n&&a&&r(n,a)},[n,a,r]),f.jsx(rt,{onLoaderStart:()=>{_("stripe_form_loader_start")},onReady:()=>{i(!1),_("stripe_form_loaded",{success:!0})},onLoadError:v=>{var E;console.error("Payment element load error:",v),i(!1),_("stripe_form_loaded",{success:!1,error:((E=v.error)==null?void 0:E.message)||"Unknown error"})},onChange:({complete:v})=>{o(v),v&&!s&&c&&(h(!0),c(e,t))}})},ye=()=>{var x;const{stripeState:r,clickarooInfoMap:e,offerPricePoints:t,setStripe:n,setStripeElements:a}=q(),o=t[0]?e[t[0]]:null,{checkoutProducts:i,totalAmount:c}=Ie(),s=k.useCallback((b,y)=>{b&&n(b),y&&a(y)},[n,a]),[h]=k.useState(()=>{if(!o)return null;const b=mt(o.payment.data.publishable_key,{stripeAccount:o.payment.data.account_id});return b.then(y=>{y&&_("stripe_sdk_loaded",{success:!0})}).catch(y=>{_("stripe_sdk_loaded",{success:!1,error:(y==null?void 0:y.message)||"Failed to load Stripe SDK"})}),b});if(!o||t.length===0||!h)return f.jsx("div",{className:"flex items-center justify-center h-20",children:f.jsx(W,{})});const v=o.type==="one_off"?"payment":"subscription",E=(x=i[0])==null?void 0:x.currency.toLowerCase(),p=c<=0;return k.useEffect(()=>{p&&_("stripe_form_loaded",{success:!1,error:"Invalid payment amount",totalAmount:c})},[p,c]),p?f.jsx("div",{className:"flex items-center justify-center h-20",children:f.jsx("div",{className:"text-[#df1b41]",children:"Invalid payment amount"})}):f.jsxs("div",{className:"relative",children:[r.isLoading&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:f.jsx(W,{})}),f.jsx(pe,{stripe:h,options:{mode:v,currency:E,amount:c,payment_method_types:["card"],locale:"en",appearance:{theme:"stripe",variables:{colorPrimary:"#8AA3D4"}}},children:f.jsx(vt,{onStripeReady:s,checkoutProducts:i,totalAmount:c})})]})};ye.__docgenInfo={description:"",methods:[],displayName:"StripePayment"};const ht=({showText:r=!0})=>{const{clickarooInfoMap:e,offerPricePoints:t}=q(),n=t.length>0&&Object.keys(e).length>0&&t.every(a=>e[a]);return f.jsxs("div",{className:"w-full",children:[r&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"text-lg md:text-2xl mb-2 font-medium",children:"Payment Methods"}),f.jsx("div",{className:"text-grey text-md mb-5",children:"All transactions are secure encrypted."})]}),n?f.jsx("div",{id:"stripe-payment-element",className:"relative min-h-8",children:f.jsx(ye,{})}):f.jsx("div",{className:"relative flex items-center justify-center h-20",children:f.jsx(W,{})})]})};ht.__docgenInfo={description:"",methods:[],displayName:"PaymentMethods",props:{showText:{required:!1,tsType:{name:"boolean"},description:"",defaultValue:{value:"true",computed:!1}}}};export{ht as P,Ie as u};