@quantaroute/checkout 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +27 -0
- package/dist/lib/index.d.ts +15 -0
- package/dist/lib/quantaroute-checkout.es.js +186 -186
- package/dist/lib/quantaroute-checkout.umd.js +86 -86
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CheckoutWidget.tsx +82 -3
- package/src/components/PaymentStep.tsx +15 -5
- package/src/core/types.ts +15 -0
- package/src/index.ts +2 -0
- package/src/styles/checkout.css +542 -0
|
@@ -28,7 +28,7 @@ if(r<i.minLon||r>i.maxLon)throw new Error(`Longitude ${r} out of range. Must be
|
|
|
28
28
|
let n=i.minLat,a=i.maxLat,o=i.minLon,l=i.maxLon,s=""
|
|
29
29
|
for(let i=1;i<=10;i++){const d=(a-n)/4,c=(l-o)/4
|
|
30
30
|
let u=3-Math.floor((e-n)/d),h=Math.floor((r-o)/c)
|
|
31
|
-
u=Math.max(0,Math.min(u,3)),h=Math.max(0,Math.min(h,3)),s+=t[u][h],3!==i&&6!==i||(s+="-"),a=n+d*(4-u),n+=d*(3-u),o+=c*h,l=o+c}return s}function
|
|
31
|
+
u=Math.max(0,Math.min(u,3)),h=Math.max(0,Math.min(h,3)),s+=t[u][h],3!==i&&6!==i||(s+="-"),a=n+d*(4-u),n+=d*(3-u),o+=c*h,l=o+c}return s}function y(e){const r=c(e)
|
|
32
32
|
if(10!==r.length)throw new Error("Invalid DIGIPIN: must be 10 characters (excluding separators)")
|
|
33
33
|
let n=i.minLat,a=i.maxLat,o=i.minLon,l=i.maxLon
|
|
34
34
|
for(let e=0;e<10;e++){const i=r[e]
|
|
@@ -36,7 +36,7 @@ let s=!1,d=-1,c=-1
|
|
|
36
36
|
for(let e=0;e<4;e++){for(let r=0;r<4;r++)if(t[e][r]===i){d=e,c=r,s=!0
|
|
37
37
|
break}if(s)break}if(!s)throw new Error(`Invalid character in DIGIPIN: '${i}'`)
|
|
38
38
|
const u=(a-n)/4,h=(l-o)/4,p=o+h*(c+1)
|
|
39
|
-
n=a-u*(d+1),a-=u*d,o+=h*c,l=p}return{latitude:((n+a)/2).toFixed(6),longitude:((o+l)/2).toFixed(6)}}function
|
|
39
|
+
n=a-u*(d+1),a-=u*d,o+=h*c,l=p}return{latitude:((n+a)/2).toFixed(6),longitude:((o+l)/2).toFixed(6)}}function f(e,r){return e>=i.minLat&&e<=i.maxLat&&r>=i.minLon&&r<=i.maxLon}const b="https://api.quantaroute.com"
|
|
40
40
|
function v(e){if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout)return AbortSignal.timeout(e)
|
|
41
41
|
const r=new AbortController
|
|
42
42
|
return setTimeout(()=>r.abort(),e),r.signal}async function _(e,r,n,a=b){const t=`${a.replace(/\/$/,"")}/v1/location/lookup`
|
|
@@ -73,61 +73,61 @@ throw new Error(`API error ${t.status}: ${e||t.statusText}`)}const i=await t.jso
|
|
|
73
73
|
if(!i.success)throw new Error(i.message??"Reverse geocoding failed")
|
|
74
74
|
return i}function x(){const[e,r]=n.useState({loading:!1,error:null})
|
|
75
75
|
return{...e,locate:n.useCallback(e=>{navigator.geolocation?(r({loading:!0,error:null}),navigator.geolocation.getCurrentPosition(({coords:n})=>{r({loading:!1,error:null}),e(n.latitude,n.longitude)},e=>{let n="Unable to get location."
|
|
76
|
-
e.code===e.PERMISSION_DENIED?n="Location permission denied. Please enable it in browser settings.":e.code===e.POSITION_UNAVAILABLE?n="Location unavailable. Try again or place the pin manually.":e.code===e.TIMEOUT&&(n="Location request timed out. Try again."),r({loading:!1,error:n})},{enableHighAccuracy:!0,timeout:12e3,maximumAge:0})):r({loading:!1,error:"Geolocation is not supported by your browser."})},[]),clearError:n.useCallback(()=>{r(e=>({...e,error:null}))},[])}}function E(e,r){if(!
|
|
77
|
-
try{return m(e,r)}catch{return null}}const S="#0ea5e9",L=({onLocationConfirm:e,defaultLat:t,defaultLng:i,mapHeight:o="380px",theme:l="light",indiaBoundaryUrl:s,enableSearch:d=!0,apiKey:c,apiBaseUrl:u,brandColor:p=S})=>{const m=n.useRef(null),
|
|
78
|
-
C(e),T(r),Z(e,r),
|
|
76
|
+
e.code===e.PERMISSION_DENIED?n="Location permission denied. Please enable it in browser settings.":e.code===e.POSITION_UNAVAILABLE?n="Location unavailable. Try again or place the pin manually.":e.code===e.TIMEOUT&&(n="Location request timed out. Try again."),r({loading:!1,error:n})},{enableHighAccuracy:!0,timeout:12e3,maximumAge:0})):r({loading:!1,error:"Geolocation is not supported by your browser."})},[]),clearError:n.useCallback(()=>{r(e=>({...e,error:null}))},[])}}function E(e,r){if(!f(e,r))return null
|
|
77
|
+
try{return m(e,r)}catch{return null}}const S="#0ea5e9",L=({onLocationConfirm:e,defaultLat:t,defaultLng:i,mapHeight:o="380px",theme:l="light",indiaBoundaryUrl:s,enableSearch:d=!0,apiKey:c,apiBaseUrl:u,brandColor:p=S})=>{const m=n.useRef(null),f=n.useRef(null),b=n.useRef(null),v=t??13.00427,_=i??77.589291,g=void 0!==t&&void 0!==i,[q,C]=n.useState(v),[L,T]=n.useState(_),[P,I]=n.useState(()=>E(v,_)),[B,A]=n.useState(!1),[O,$]=n.useState(""),[M,D]=n.useState([]),[U,F]=n.useState(!1),[R,j]=n.useState(null),[W,z]=n.useState(!1),V=n.useRef(null),J=n.useRef(null),H=n.useId(),{loading:G,error:K,locate:Y,clearError:Q}=x(),Z=n.useCallback((e,r)=>{I(E(e,r))},[]),X=n.useCallback((e,r)=>{var n
|
|
78
|
+
C(e),T(r),Z(e,r),f.current&&f.current.flyTo({center:[r,e],zoom:18,duration:900,essential:!0}),null==(n=b.current)||n.setLngLat([r,e])},[Z]),ee=n.useCallback(e=>{const r=e.target.value
|
|
79
79
|
$(r),j(null),V.current&&clearTimeout(V.current)
|
|
80
80
|
const n=r.trim()
|
|
81
|
-
if(!n)return D([]),z(!1),void
|
|
82
|
-
if(w(n))try{const e=
|
|
83
|
-
X(r,a),D([]),z(!1),$(h(n))}catch{j("Invalid DigiPin code")}else{if(N(n))return D([]),z(!1),void
|
|
81
|
+
if(!n)return D([]),z(!1),void F(!1)
|
|
82
|
+
if(w(n))try{const e=y(n),r=parseFloat(e.latitude),a=parseFloat(e.longitude)
|
|
83
|
+
X(r,a),D([]),z(!1),$(h(n))}catch{j("Invalid DigiPin code")}else{if(N(n))return D([]),z(!1),void F(!1)
|
|
84
84
|
if(n.length<3)return D([]),void z(!1)
|
|
85
|
-
|
|
86
|
-
D(r),z(r.length>0)}catch(e){j(e instanceof Error?e.message:"Search failed"),D([]),z(!1)}finally{
|
|
85
|
+
F(!0),V.current=setTimeout(async()=>{try{const e=c??"",r=await k(n,e,u,5,q,L)
|
|
86
|
+
D(r),z(r.length>0)}catch(e){j(e instanceof Error?e.message:"Search failed"),D([]),z(!1)}finally{F(!1)}},400)}},[c,u,X]),re=n.useCallback(e=>{var r
|
|
87
87
|
X(e.coordinates.latitude,e.coordinates.longitude),$(""),D([]),z(!1),null==(r=J.current)||r.blur()},[X]),ne=n.useCallback(e=>{"Escape"===e.key&&(D([]),z(!1),$(""))},[])
|
|
88
88
|
n.useEffect(()=>{if(!m.current)return
|
|
89
89
|
const e=s?fetch(s).then(e=>e.ok?e.json():null).catch(()=>null):Promise.resolve(null),r=g?18:9,n=new a.Map({container:m.current,style:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:[_,v],zoom:r,minZoom:6,attributionControl:!1,touchZoomRotate:!0})
|
|
90
|
-
return n.addControl(new a.AttributionControl({compact:!0,customAttribution:'© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions" target="_blank" rel="noopener">CARTO</a>'}),"bottom-right"),n.addControl(new a.NavigationControl({showCompass:!1}),"top-right"),n.on("load",()=>{
|
|
90
|
+
return n.addControl(new a.AttributionControl({compact:!0,customAttribution:'© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions" target="_blank" rel="noopener">CARTO</a>'}),"bottom-right"),n.addControl(new a.NavigationControl({showCompass:!1}),"top-right"),n.on("load",()=>{A(!0),e.then(e=>{if(e&&n.isStyleLoaded())try{n.addSource("india-boundary",{type:"geojson",data:e}),n.addLayer({id:"india-boundary-line",type:"line",source:"india-boundary",paint:{"line-color":"#94a3b8","line-width":1.5,"line-opacity":.65}})}catch{}})
|
|
91
91
|
const r=function(e=S){const r=document.createElement("div")
|
|
92
92
|
return r.className="qr-pin",r.setAttribute("aria-label","Drag to adjust your location"),r.style.width="40px",r.style.height="52px",r.innerHTML=`\n <svg\n class="qr-pin__svg"\n width="40"\n height="52"\n viewBox="0 0 40 52"\n overflow="visible"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n aria-hidden="true"\n >\n <defs>\n \x3c!--\n The filter region must be generous enough to contain the shadow blur.\n stdDeviation=3 → ~9px blur radius; our region extends 50% on each side.\n overflow="visible" on the <svg> lets it paint outside the viewport.\n --\x3e\n <filter id="qr-pin-shadow" x="-60%" y="-40%" width="220%" height="220%">\n <feDropShadow dx="0" dy="3" stdDeviation="3.5"\n flood-color="#000" flood-opacity="0.28"/>\n </filter>\n </defs>\n\n \x3c!-- Teardrop body — tip is at (20, 52) = bottom-center of the SVG --\x3e\n <path\n d="M20 0C9.402 0 0 9.402 0 20C0 34 20 52 20 52S40 34 40 20C40 9.402 30.598 0 20 0Z"\n fill="${e}"\n filter="url(#qr-pin-shadow)"\n />\n \x3c!-- Dot inside the pin --\x3e\n <circle cx="20" cy="20" r="9" fill="white"/>\n <circle cx="20" cy="20" r="5" fill="${e}"/>\n </svg>\n\n \x3c!--\n Pulse ring — position: absolute inside .qr-pin (position: relative).\n bottom: -(height/2) → bottom: -10px centres the 20×20 circle\n exactly at y = PIN_H = 52px = the pin tip coordinate.\n --\x3e\n <div class="qr-pin__pulse" aria-hidden="true"></div>\n `,r}(p),t=new a.Marker({element:r,draggable:!0,anchor:"bottom"}).setLngLat([_,v]).addTo(n)
|
|
93
93
|
t.on("drag",()=>{const e=t.getLngLat()
|
|
94
94
|
C(e.lat),T(e.lng),Z(e.lat,e.lng)}),t.on("dragend",()=>{const e=t.getLngLat()
|
|
95
95
|
n.easeTo({center:[e.lng,e.lat],duration:250})}),b.current=t}),n.on("click",e=>{var r
|
|
96
96
|
const a=e.lngLat
|
|
97
|
-
null==(r=b.current)||r.setLngLat([a.lng,a.lat]),C(a.lat),T(a.lng),Z(a.lat,a.lng),n.easeTo({center:[a.lng,a.lat],duration:200})}),
|
|
97
|
+
null==(r=b.current)||r.setLngLat([a.lng,a.lat]),C(a.lat),T(a.lng),Z(a.lat,a.lng),n.easeTo({center:[a.lng,a.lat],duration:200})}),f.current=n,()=>{n.remove(),f.current=null,b.current=null}},[])
|
|
98
98
|
const ae=n.useCallback(()=>{Q(),Y((e,r)=>{var n
|
|
99
|
-
C(e),T(r),Z(e,r),
|
|
100
|
-
return r.jsxs("div",{className:"qr-map-wrapper",children:[r.jsxs("div",{className:"qr-step-header",children:[r.jsx("div",{className:"qr-step-badge",children:"1"}),r.jsxs("div",{className:"qr-step-text",children:[r.jsx("span",{className:"qr-step-title",children:"Pin Your Location"}),r.jsx("span",{className:"qr-step-sub",children:"Tap the map or drag the pin to your exact home / office"})]})]}),d&&r.jsxs("div",{className:"qr-search-bar",role:"search",children:[r.jsxs("div",{className:"qr-search-bar__input-wrap",children:[r.jsxs("svg",{className:"qr-search-bar__icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:J,type:"search",className:"qr-search-bar__input",placeholder:"Search address, 'pharmacy near me', or DigiPin…",value:
|
|
99
|
+
C(e),T(r),Z(e,r),f.current&&f.current.flyTo({center:[r,e],zoom:18,duration:1400,essential:!0}),null==(n=b.current)||n.setLngLat([r,e])})},[Y,Q,Z]),te=n.useCallback(()=>{P&&e(q,L,P)},[q,L,P,e]),ie=null!==P,oe=ie&&B
|
|
100
|
+
return r.jsxs("div",{className:"qr-map-wrapper",children:[r.jsxs("div",{className:"qr-step-header",children:[r.jsx("div",{className:"qr-step-badge",children:"1"}),r.jsxs("div",{className:"qr-step-text",children:[r.jsx("span",{className:"qr-step-title",children:"Pin Your Location"}),r.jsx("span",{className:"qr-step-sub",children:"Tap the map or drag the pin to your exact home / office"})]})]}),d&&r.jsxs("div",{className:"qr-search-bar",role:"search",children:[r.jsxs("div",{className:"qr-search-bar__input-wrap",children:[r.jsxs("svg",{className:"qr-search-bar__icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:J,type:"search",className:"qr-search-bar__input",placeholder:"Search address, 'pharmacy near me', or DigiPin…",value:O,onChange:ee,onKeyDown:ne,autoComplete:"off",autoCorrect:"off",autoCapitalize:"characters",spellCheck:!1,"aria-label":"Search address or DigiPin","aria-autocomplete":"list","aria-controls":W?H:void 0,"aria-expanded":W}),U&&r.jsx("span",{className:"qr-search-bar__spinner qr-spinner qr-spinner--sm","aria-hidden":"true"}),O&&!U&&r.jsx("button",{type:"button",className:"qr-search-bar__clear",onClick:()=>{$(""),D([]),z(!1),j(null)},"aria-label":"Clear search",tabIndex:-1,children:"×"})]}),R&&r.jsx("p",{className:"qr-search-bar__error",role:"alert",children:R}),W&&M.length>0&&r.jsx("ul",{id:H,className:"qr-search-bar__dropdown",role:"listbox","aria-label":"Address suggestions",children:M.map((e,n)=>r.jsxs("li",{className:"qr-search-bar__suggestion",role:"option","aria-selected":"false",onMouseDown:r=>{r.preventDefault(),re(e)},children:[r.jsxs("svg",{className:"qr-search-bar__suggestion-icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r.jsx("circle",{cx:"12",cy:"9",r:"2.5"})]}),r.jsxs("div",{className:"qr-search-bar__suggestion-text",children:[r.jsx("span",{className:"qr-search-bar__suggestion-name",children:e.displayName}),e.address&&e.address!==e.displayName&&r.jsx("span",{className:"qr-search-bar__suggestion-sub",children:e.address})]})]},n))}),r.jsxs("p",{className:"qr-search-bar__hint",children:[r.jsx("span",{className:"qr-search-bar__hint-chip",children:"DigiPin"}),"Type your DigiPin code for instant offline lookup — no API call"]})]}),r.jsxs("div",{className:"qr-map-outer",style:{height:o},children:[r.jsx("div",{ref:m,className:"qr-map-canvas"}),P&&r.jsxs("div",{className:"qr-digipin-badge","aria-live":"polite","aria-label":`DigiPin: ${P}`,children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:P})]}),!ie&&B&&r.jsx("div",{className:"qr-map-notice",role:"status",children:"Move map to India to get a DigiPin"}),r.jsx("button",{className:"qr-locate-btn"+(G?" qr-locate-btn--loading":""),onClick:ae,disabled:G,title:"Use my current location","aria-label":"Use my current location",type:"button",children:G?r.jsx("span",{className:"qr-spinner","aria-hidden":"true"}):r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"}),r.jsx("circle",{cx:"12",cy:"12",r:"7"}),r.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]})}),K&&r.jsxs("div",{className:"qr-geo-error",role:"alert",children:[r.jsx("span",{children:K}),r.jsx("button",{type:"button",className:"qr-geo-error__dismiss",onClick:Q,"aria-label":"Dismiss error",children:"×"})]})]}),B&&r.jsxs("div",{className:"qr-coords-strip","aria-label":"Current pin coordinates",children:[r.jsxs("span",{children:[q.toFixed(5),"° N"]}),r.jsx("span",{className:"qr-coords-sep",children:"·"}),r.jsxs("span",{children:[L.toFixed(5),"° E"]})]}),r.jsxs("div",{className:"qr-map-actions",children:[r.jsxs("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:te,disabled:!oe,children:["Confirm Location",r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})]}),!ie&&B&&r.jsx("p",{className:"qr-map-hint",children:"Move the pin to a location in India to continue"})]})]})}
|
|
101
101
|
async function T(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"send",mobile:r,merchant_id:e.merchantId})}),a=await n.json().catch(()=>({}))
|
|
102
|
-
if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")}async function
|
|
102
|
+
if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")}async function P(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify",mobile:r,otp:n,merchant_id:e.merchantId,...a})}),i=await t.json().catch(()=>({}))
|
|
103
103
|
if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired OTP.")
|
|
104
|
-
return i}function
|
|
104
|
+
return i}function I(e){return{"Content-Type":"application/json","x-session-token":e}}async function B(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"list"})}),a=await n.json().catch(()=>({}))
|
|
105
105
|
if(!n.ok||!a.success)throw new Error(a.error??"Failed to load saved addresses.")
|
|
106
|
-
return a.data??[]}async function
|
|
106
|
+
return a.data??[]}async function A(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"create",address:n})}),t=await a.json().catch(()=>({}))
|
|
107
107
|
if(!a.ok||!t.success)throw new Error(t.error??"Failed to save address.")
|
|
108
|
-
return t.data}async function
|
|
109
|
-
if(!a.ok||!t.success)throw new Error(t.error??"Failed to delete address.")}async function $(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:
|
|
110
|
-
if(!a.ok||!t.success)throw new Error(t.error??"Failed to set default address.")}async function M(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:
|
|
111
|
-
if(!a.ok||!t.success)throw new Error(t.error??"Failed to select address.")}async function D(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:
|
|
108
|
+
return t.data}async function O(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"delete",address_id:n})}),t=await a.json().catch(()=>({}))
|
|
109
|
+
if(!a.ok||!t.success)throw new Error(t.error??"Failed to delete address.")}async function $(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"set_default",address_id:n})}),t=await a.json().catch(()=>({}))
|
|
110
|
+
if(!a.ok||!t.success)throw new Error(t.error??"Failed to set default address.")}async function M(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"select_address",address_id:n})}),t=await a.json().catch(()=>({}))
|
|
111
|
+
if(!a.ok||!t.success)throw new Error(t.error??"Failed to select address.")}async function D(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"verify_digipin",address_id:n,...a})}),i=await t.json().catch(()=>({}))
|
|
112
112
|
if(!t.ok||!i.success)throw new Error(i.error??"Failed to verify delivery pin.")
|
|
113
|
-
return i.data}async function
|
|
114
|
-
!a.ok||t.success}async function
|
|
113
|
+
return i.data}async function U(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"address_completed",data:n})}),t=await a.json().catch(()=>({}))
|
|
114
|
+
!a.ok||t.success}async function F(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-email-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"send",email:r,merchant_id:e.merchantId})}),a=await n.json().catch(()=>({}))
|
|
115
115
|
if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")
|
|
116
116
|
return{reused:Boolean(a.reused)}}async function R(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-email-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify",email:r,code:n,merchant_id:e.merchantId,...a})}),i=await t.json().catch(()=>({}))
|
|
117
117
|
if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired code.")
|
|
118
118
|
return i}async function j(e,r,n,a){const t={action:"cod_eligibility",pincode:n}
|
|
119
119
|
void 0!==a&&(t.cart_total_paise=a)
|
|
120
|
-
const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:
|
|
120
|
+
const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify(t)}),o=await i.json().catch(()=>({}))
|
|
121
121
|
if(!i.ok||!o.success)throw new Error(o.error??"Failed to check COD eligibility.")
|
|
122
|
-
return o.data}async function W(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:
|
|
122
|
+
return o.data}async function W(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"serviceability_check",pincode:n,...void 0!==(null==a?void 0:a.lat)?{lat:a.lat}:{},...void 0!==(null==a?void 0:a.lng)?{lng:a.lng}:{}})}),i=await t.json().catch(()=>({}))
|
|
123
123
|
if(!t.ok||!i.success)throw new Error(i.error??"Failed to check delivery serviceability.")
|
|
124
124
|
return i.data}async function z(e,r,n){try{const a={"Content-Type":"application/json"}
|
|
125
|
-
n&&(a["x-session-token"]=n),await fetch(`${e.functionBaseUrl}/checkout-funnel-events`,{method:"POST",headers:a,body:JSON.stringify({merchant_id:e.merchantId,...r})})}catch{}}async function V(e,r,n){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:
|
|
126
|
-
return n.ok&&a.success?a.data??null:null}async function H(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:
|
|
125
|
+
n&&(a["x-session-token"]=n),await fetch(`${e.functionBaseUrl}/checkout-funnel-events`,{method:"POST",headers:a,body:JSON.stringify({merchant_id:e.merchantId,...r})})}catch{}}async function V(e,r,n){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:I(r),body:JSON.stringify({action:"abandon",last_step:n})})}catch{}}async function J(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:I(r)}),a=await n.json().catch(()=>({}))
|
|
126
|
+
return n.ok&&a.success?a.data??null:null}async function H(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:I(r),body:JSON.stringify({action:"create_order",amount_paise:n})}),t=await a.json().catch(()=>({}))
|
|
127
127
|
if(!a.ok||!t.success)throw new Error(t.error??"Failed to create payment order.")
|
|
128
|
-
return t.data}async function G(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:
|
|
128
|
+
return t.data}async function G(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:I(r),body:JSON.stringify({action:"verify",...n})}),t=await a.json().catch(()=>({}))
|
|
129
129
|
if(!a.ok||!t.success)throw new Error(t.error??"Payment verification failed.")
|
|
130
|
-
return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function K(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:
|
|
130
|
+
return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function K(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:I(r),body:JSON.stringify({action:"record_cod"})}),a=await n.json().catch(()=>({}))
|
|
131
131
|
if(!n.ok||!a.success)throw new Error(a.error??"Failed to record COD selection.")
|
|
132
132
|
return{payment_method:a.payment_method}}const Y=/\s+(?:B\.?\s*O\.?|S\.?\s*O\.?|H\.?\s*O\.?|P\.?\s*O\.?|D\.?\s*S\.?\s*O\.?|S\.?\s*D\.?\s*O\.?|S\.?\s*B\.?\s*C\.?|C\.?\s*P\.?\s*C\.?|M\.?\s*D\.?\s*G\.?)\.?\s*$/i
|
|
133
133
|
function Q(e){return e.replace(Y,"").replace(/\s+/g," ").trim()}function Z(e){return Q(e).toLowerCase()}function X({label:e,className:n}){const a={className:n,"aria-hidden":!0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}
|
|
@@ -156,7 +156,7 @@ case"SET_LABEL":return"ready"!==e.status?e:{...e,selectedLabel:r.label,labelText
|
|
|
156
156
|
case"SET_LABEL_TEXT":return"ready"!==e.status?e:{...e,labelText:r.value.slice(0,64)}
|
|
157
157
|
case"SUBMIT_START":return"ready"!==e.status?e:{...e,submitting:!0}
|
|
158
158
|
case"SUBMIT_END":return"ready"!==e.status?e:{...e,submitting:!1}
|
|
159
|
-
default:return e}}const ne=({digipin:e,lat:a,lng:t,apiKey:i,apiBaseUrl:o,onAddressComplete:l,onBack:s,onError:d,checkoutConfig:c,serviceabilitySessionToken:u,enableServiceabilityCheck:h=!1,showIndiaPostDeliveryWarning:p=!1,serviceabilityBlockCheckout:m,onServiceabilityResult:
|
|
159
|
+
default:return e}}const ne=({digipin:e,lat:a,lng:t,apiKey:i,apiBaseUrl:o,onAddressComplete:l,onBack:s,onError:d,checkoutConfig:c,serviceabilitySessionToken:u,enableServiceabilityCheck:h=!1,showIndiaPostDeliveryWarning:p=!1,serviceabilityBlockCheckout:m,onServiceabilityResult:y,initialValues:f,submitLabel:b="Save Address"})=>{var v,w,N,k
|
|
160
160
|
const[x,E]=n.useReducer(re,{status:"loading"}),S=n.useCallback(async()=>{var r
|
|
161
161
|
E({type:"LOAD_START"})
|
|
162
162
|
try{const[n,l]=await Promise.all([_(a,t,i,o),C(e,i,o)]),s=(null==(r=n.data.administrative_info.pincode)?void 0:r.replace(/\D/g,"").slice(0,6))??""
|
|
@@ -165,8 +165,8 @@ const p=await g(s,i,o)
|
|
|
165
165
|
if(!p.isValid)return E({type:"LOAD_ERROR",message:"This location resolves to a pincode that is not in the India Post database. Please move the map pin to a valid address."}),void(null==d||d(new Error("Invalid pincode for location")))
|
|
166
166
|
const m=q(p.offices)
|
|
167
167
|
let b=null
|
|
168
|
-
if(h&&(null==c?void 0:c.functionBaseUrl)&&c.merchantId&&u)try{b=await W(c,u,s,{lat:a,lng:t}),null==
|
|
169
|
-
E({type:"LOAD_ERROR",message:r}),null==d||d(e instanceof Error?e:new Error(r))}},[e,a,t,i,o,d,c,u,h,f
|
|
168
|
+
if(h&&(null==c?void 0:c.functionBaseUrl)&&c.merchantId&&u)try{b=await W(c,u,s,{lat:a,lng:t}),null==y||y(b)}catch{}E({type:"LOAD_SUCCESS",adminInfo:n.data.administrative_info,alternatives:n.data.alternatives||[],addressComponents:l.data.addressComponents,pincodeHasDelivery:m,serviceabilityResult:b,initialValues:f})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch address data."
|
|
169
|
+
E({type:"LOAD_ERROR",message:r}),null==d||d(e instanceof Error?e:new Error(r))}},[e,a,t,i,o,d,c,u,h,y,f])
|
|
170
170
|
n.useEffect(()=>{S()},[S])
|
|
171
171
|
const L=n.useCallback(r=>{var n
|
|
172
172
|
if(r.preventDefault(),"ready"!==x.status)return
|
|
@@ -175,15 +175,15 @@ if("other"===s&&!d.trim())return
|
|
|
175
175
|
if((null==(n=x.serviceabilityResult)?void 0:n.checked)&&!1===x.serviceabilityResult.serviceable&&(m??x.serviceabilityResult.block_checkout))return
|
|
176
176
|
const u=[c.flatNumber,c.floorNumber?`Floor ${c.floorNumber}`:"",c.buildingName,c.streetName,o,i.district,i.state,i.pincode].filter(Boolean),h={digipin:e,lat:a,lng:t,state:i.state,district:i.district,division:i.division,locality:o,pincode:i.pincode,delivery:i.delivery,country:i.country??"India",...c,formattedAddress:u.join(", "),label:s,..."other"===s?{labelText:d.trim()}:{}}
|
|
177
177
|
E({type:"SUBMIT_START"})
|
|
178
|
-
try{l(h)}finally{E({type:"SUBMIT_END"})}},[x,e,a,t,l,m]),T="ready"===x.status&&(null==(v=x.serviceabilityResult)?void 0:v.checked)&&!1===x.serviceabilityResult.serviceable&&(m??x.serviceabilityResult.block_checkout),
|
|
179
|
-
return r.jsxs("div",{className:"qr-form-wrapper",children:[r.jsxs("div",{className:"qr-step-header",children:[r.jsx("button",{type:"button",className:"qr-back-btn",onClick:s,"aria-label":"Back to map",children:r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),r.jsx("div",{className:"qr-step-badge",children:"2"}),r.jsxs("div",{className:"qr-step-text",children:[r.jsx("span",{className:"qr-step-title",children:"Add Address Details"}),r.jsx("span",{className:"qr-step-sub",children:"Flat number and building info"})]})]}),r.jsxs("div",{className:"qr-form-digipin-strip",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r.jsx("circle",{cx:"12",cy:"10",r:"3"})]}),r.jsx("span",{className:"qr-form-digipin-strip__label",children:"DigiPin"}),r.jsx("span",{className:"qr-form-digipin-strip__code",children:e})]}),"loading"===x.status&&r.jsxs("div",{className:"qr-loading-state","aria-busy":"true","aria-label":"Fetching address details",children:[r.jsx("div",{className:"qr-spinner qr-spinner--lg","aria-hidden":"true"}),r.jsx("p",{className:"qr-loading-state__text",children:"Fetching address details…"})]}),"error"===x.status&&r.jsxs("div",{className:"qr-error-state",role:"alert",children:[r.jsx("div",{className:"qr-error-state__icon","aria-hidden":"true",children:"⚠"}),r.jsx("p",{className:"qr-error-state__msg",children:x.message}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--secondary qr-btn--sm",onClick:()=>{S()},children:"Retry"})]}),"ready"===x.status&&r.jsxs("form",{onSubmit:L,className:"qr-form",noValidate:!0,children:[r.jsxs("fieldset",{className:"qr-fieldset",children:[r.jsxs("legend",{className:"qr-fieldset__legend",children:[r.jsx("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"📍"}),"Auto-detected from your digipin"]}),r.jsxs("div",{className:"qr-auto-grid",children:[r.jsxs("div",{className:"qr-auto-row",children:[r.jsx("span",{className:"qr-auto-row__label",children:"State"}),r.jsx("span",{className:"qr-auto-row__value",children:x.adminInfo.state})]}),r.jsxs("div",{className:"qr-auto-row",children:[r.jsx("span",{className:"qr-auto-row__label",children:"District"}),r.jsx("span",{className:"qr-auto-row__value",children:x.adminInfo.district})]}),r.jsxs("div",{className:"qr-auto-row qr-auto-row--full",children:[r.jsx("span",{className:"qr-auto-row__label",children:"Locality"}),x.localityOptions.length>1?r.jsx("select",{className:"qr-auto-row__select",value:x.selectedLocality,onChange:e=>E({type:"SET_LOCALITY",locality:e.target.value}),"aria-label":"Select locality",children:x.localityOptions.map(e=>r.jsx("option",{value:e,children:e},e))}):r.jsx("span",{className:"qr-auto-row__value",children:x.selectedLocality})]}),r.jsxs("div",{className:"qr-auto-row",children:[r.jsx("span",{className:"qr-auto-row__label",children:"Pincode"}),r.jsx("span",{className:"qr-auto-row__value qr-auto-row__value--pin",children:x.adminInfo.pincode})]})]})]}),
|
|
178
|
+
try{l(h)}finally{E({type:"SUBMIT_END"})}},[x,e,a,t,l,m]),T="ready"===x.status&&(null==(v=x.serviceabilityResult)?void 0:v.checked)&&!1===x.serviceabilityResult.serviceable&&(m??x.serviceabilityResult.block_checkout),P="ready"===x.status&&(null==(w=x.serviceabilityResult)?void 0:w.checked)&&!1===x.serviceabilityResult.serviceable,I="ready"===x.status&&!x.pincodeHasDelivery&&!0!==(null==(N=x.serviceabilityResult)?void 0:N.serviceable)&&!P&&((null==(k=x.serviceabilityResult)?void 0:k.show_india_post_delivery_warning)??p)
|
|
179
|
+
return r.jsxs("div",{className:"qr-form-wrapper",children:[r.jsxs("div",{className:"qr-step-header",children:[r.jsx("button",{type:"button",className:"qr-back-btn",onClick:s,"aria-label":"Back to map",children:r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),r.jsx("div",{className:"qr-step-badge",children:"2"}),r.jsxs("div",{className:"qr-step-text",children:[r.jsx("span",{className:"qr-step-title",children:"Add Address Details"}),r.jsx("span",{className:"qr-step-sub",children:"Flat number and building info"})]})]}),r.jsxs("div",{className:"qr-form-digipin-strip",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r.jsx("circle",{cx:"12",cy:"10",r:"3"})]}),r.jsx("span",{className:"qr-form-digipin-strip__label",children:"DigiPin"}),r.jsx("span",{className:"qr-form-digipin-strip__code",children:e})]}),"loading"===x.status&&r.jsxs("div",{className:"qr-loading-state","aria-busy":"true","aria-label":"Fetching address details",children:[r.jsx("div",{className:"qr-spinner qr-spinner--lg","aria-hidden":"true"}),r.jsx("p",{className:"qr-loading-state__text",children:"Fetching address details…"})]}),"error"===x.status&&r.jsxs("div",{className:"qr-error-state",role:"alert",children:[r.jsx("div",{className:"qr-error-state__icon","aria-hidden":"true",children:"⚠"}),r.jsx("p",{className:"qr-error-state__msg",children:x.message}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--secondary qr-btn--sm",onClick:()=>{S()},children:"Retry"})]}),"ready"===x.status&&r.jsxs("form",{onSubmit:L,className:"qr-form",noValidate:!0,children:[r.jsxs("fieldset",{className:"qr-fieldset",children:[r.jsxs("legend",{className:"qr-fieldset__legend",children:[r.jsx("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"📍"}),"Auto-detected from your digipin"]}),r.jsxs("div",{className:"qr-auto-grid",children:[r.jsxs("div",{className:"qr-auto-row",children:[r.jsx("span",{className:"qr-auto-row__label",children:"State"}),r.jsx("span",{className:"qr-auto-row__value",children:x.adminInfo.state})]}),r.jsxs("div",{className:"qr-auto-row",children:[r.jsx("span",{className:"qr-auto-row__label",children:"District"}),r.jsx("span",{className:"qr-auto-row__value",children:x.adminInfo.district})]}),r.jsxs("div",{className:"qr-auto-row qr-auto-row--full",children:[r.jsx("span",{className:"qr-auto-row__label",children:"Locality"}),x.localityOptions.length>1?r.jsx("select",{className:"qr-auto-row__select",value:x.selectedLocality,onChange:e=>E({type:"SET_LOCALITY",locality:e.target.value}),"aria-label":"Select locality",children:x.localityOptions.map(e=>r.jsx("option",{value:e,children:e},e))}):r.jsx("span",{className:"qr-auto-row__value",children:x.selectedLocality})]}),r.jsxs("div",{className:"qr-auto-row",children:[r.jsx("span",{className:"qr-auto-row__label",children:"Pincode"}),r.jsx("span",{className:"qr-auto-row__value qr-auto-row__value--pin",children:x.adminInfo.pincode})]})]})]}),P&&x.serviceabilityResult&&r.jsxs("div",{className:"qr-pincode-banner "+(T?"qr-pincode-banner--error":"qr-pincode-banner--warning"),role:T?"alert":"status","aria-live":"polite",children:[r.jsx("span",{className:"qr-pincode-banner__icon","aria-hidden":"true",children:T?"!":"⚠"}),r.jsxs("div",{className:"qr-pincode-banner__text",children:[r.jsx("strong",{children:T?"Delivery unavailable":"Delivery may be limited"}),r.jsx("span",{children:x.serviceabilityResult.message??(T?"This seller does not currently deliver to this pincode.":"This seller recommends confirming delivery availability for this pincode.")})]})]}),I&&r.jsxs("div",{className:"qr-pincode-banner qr-pincode-banner--info",role:"status","aria-live":"polite",children:[r.jsx("span",{className:"qr-pincode-banner__icon","aria-hidden":"true",children:"i"}),r.jsxs("div",{className:"qr-pincode-banner__text",children:[r.jsx("strong",{children:"India Post: no home-delivery office"}),r.jsx("span",{children:"Courier partners may still deliver to this pincode."})]})]}),r.jsxs("fieldset",{className:"qr-fieldset",children:[r.jsx("legend",{className:"qr-fieldset__legend qr-fieldset__legend--compact",children:"Save as"}),r.jsx("div",{className:"qr-label-picker",role:"radiogroup","aria-label":"Address label",children:[{value:"home",title:"Home"},{value:"work",title:"Work"},{value:"other",title:"Other"}].map(({value:e,title:n})=>r.jsxs("button",{type:"button",role:"radio","aria-checked":x.selectedLabel===e,className:"qr-label-picker__option"+(x.selectedLabel===e?" qr-label-picker__option--active":""),onClick:()=>E({type:"SET_LABEL",label:e}),children:[r.jsx("span",{className:"qr-label-picker__icon",children:r.jsx(X,{label:e})}),r.jsx("span",{children:n})]},e))}),"other"===x.selectedLabel&&r.jsxs("div",{className:"qr-label-text-field",children:[r.jsxs("label",{className:"qr-field__label",htmlFor:"qr-labelText",children:["Label name",r.jsx("span",{className:"qr-required","aria-hidden":"true",children:"*"})]}),r.jsx("input",{id:"qr-labelText",type:"text",className:"qr-field__input",placeholder:"e.g. Friend's home, Gym",value:x.labelText,onChange:e=>E({type:"SET_LABEL_TEXT",value:e.target.value}),maxLength:64,required:!0,"aria-required":"true",autoComplete:"off"})]})]}),r.jsxs("fieldset",{className:"qr-fieldset",children:[r.jsxs("legend",{className:"qr-fieldset__legend",children:[r.jsx("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"🏠"}),"Your details"]}),r.jsxs("div",{className:"qr-fields-grid",children:[r.jsxs("div",{className:"qr-field qr-field--full",children:[r.jsxs("label",{className:"qr-field__label",htmlFor:"qr-flatNumber",children:["Flat / House Number",r.jsx("span",{className:"qr-required","aria-hidden":"true",children:"*"})]}),r.jsx("input",{id:"qr-flatNumber",type:"text",className:"qr-field__input",placeholder:"e.g. 4B, Flat 201, House No. 12",value:x.fields.flatNumber,onChange:e=>E({type:"SET_FIELD",key:"flatNumber",value:e.target.value}),autoComplete:"address-line1",required:!0,"aria-required":"true"})]}),r.jsxs("div",{className:"qr-field",children:[r.jsxs("label",{className:"qr-field__label",htmlFor:"qr-floorNumber",children:["Floor",r.jsx("span",{className:"qr-optional",children:"optional"})]}),r.jsx("input",{id:"qr-floorNumber",type:"text",className:"qr-field__input",placeholder:"e.g. 3rd, Ground",value:x.fields.floorNumber,onChange:e=>E({type:"SET_FIELD",key:"floorNumber",value:e.target.value})})]}),r.jsxs("div",{className:"qr-field",children:[r.jsxs("label",{className:"qr-field__label",htmlFor:"qr-buildingName",children:["Building / Society",r.jsx("span",{className:"qr-optional",children:"optional"})]}),r.jsx("input",{id:"qr-buildingName",type:"text",className:"qr-field__input",placeholder:"e.g. Sunshine Apts, DDA Colony",value:x.fields.buildingName,onChange:e=>E({type:"SET_FIELD",key:"buildingName",value:e.target.value}),autoComplete:"address-line2"})]}),r.jsxs("div",{className:"qr-field qr-field--full",children:[r.jsxs("label",{className:"qr-field__label",htmlFor:"qr-streetName",children:["Street / Area",r.jsx("span",{className:"qr-optional",children:"optional"})]}),r.jsx("input",{id:"qr-streetName",type:"text",className:"qr-field__input",placeholder:"e.g. MG Road, Sector 12",value:x.fields.streetName,onChange:e=>E({type:"SET_FIELD",key:"streetName",value:e.target.value}),autoComplete:"address-level3"})]})]})]}),r.jsxs("div",{className:"qr-form-actions",children:[r.jsxs("button",{type:"button",className:"qr-btn qr-btn--ghost",onClick:s,children:[r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),"Adjust Pin"]}),r.jsx("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--grow",disabled:x.submitting||!x.fields.flatNumber.trim()||"other"===x.selectedLabel&&!x.labelText.trim()||Boolean(T),children:x.submitting?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),"Saving…"]}):r.jsxs(r.Fragment,{children:[b,r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6L9 17l-5-5"})})]})})]})]})]})},ae=({onOtpSent:e,onSkip:a,functionBaseUrl:t,merchantId:i})=>{const[o,l]=n.useState(""),[s,d]=n.useState(!1),[c,u]=n.useState(null),h=n.useRef(null),p=n.useCallback(e=>{l(e.target.value.replace(/\D/g,"").slice(0,10)),u(null)},[]),m=n.useCallback(async r=>{var n
|
|
180
180
|
if(r.preventDefault(),10!==o.length)return u("Enter a valid 10-digit mobile number."),void(null==(n=h.current)||n.focus())
|
|
181
181
|
d(!0),u(null)
|
|
182
182
|
try{await T({functionBaseUrl:t,merchantId:i},`+91${o}`),e(`+91${o}`)}catch(e){u(e instanceof Error?e.message:"Failed to send OTP. Please try again.")}finally{d(!1)}},[o,t,i,e])
|
|
183
183
|
return r.jsxs("div",{className:"qr-auth-step",children:[r.jsx("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r.jsx("path",{d:"M16 14h4l2 5-2.5 1.5a11 11 0 005 5L26 23l5 2v4c0 1.1-.9 2-2 2A18 18 0 0114 16c0-1.1.9-2 2-2z",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),r.jsx("h3",{className:"qr-auth-step__title",children:"Faster checkout"}),r.jsx("p",{className:"qr-auth-step__sub",children:"Enter your mobile to load saved addresses"}),r.jsxs("form",{onSubmit:m,noValidate:!0,children:[r.jsxs("div",{className:"qr-phone-field"+(c?" qr-phone-field--error":""),children:[r.jsx("span",{className:"qr-phone-field__prefix","aria-hidden":"true",children:"+91"}),r.jsx("input",{ref:h,type:"tel",inputMode:"numeric",className:"qr-phone-field__input",placeholder:"98765 43210",value:o,onChange:p,maxLength:10,autoComplete:"tel-national","aria-label":"Mobile number","aria-describedby":c?"qr-phone-error":void 0,"aria-invalid":!!c,disabled:s})]}),c&&r.jsx("p",{id:"qr-phone-error",className:"qr-auth-step__error",role:"alert",children:c}),r.jsx("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--full",disabled:s||10!==o.length,children:s?r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):r.jsxs(r.Fragment,{children:["Send OTP",r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})})]}),r.jsx("button",{type:"button",className:"qr-auth-step__skip",onClick:a,disabled:s,children:"Skip, enter address manually"})]})}
|
|
184
184
|
function te(e){const r=e.replace(/\D/g,"")
|
|
185
|
-
return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const ie=({mobile:e,onVerified:a,onBack:t,functionBaseUrl:i,merchantId:o,sessionContext:l})=>{const[s,d]=n.useState(Array(6).fill("")),[c,u]=n.useState(!1),[h,p]=n.useState(null),[m,
|
|
186
|
-
n.useEffect(()=>(_.current=setInterval(()=>{
|
|
185
|
+
return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const ie=({mobile:e,onVerified:a,onBack:t,functionBaseUrl:i,merchantId:o,sessionContext:l})=>{const[s,d]=n.useState(Array(6).fill("")),[c,u]=n.useState(!1),[h,p]=n.useState(null),[m,y]=n.useState(30),[f,b]=n.useState(!1),v=n.useRef([]),_=n.useRef(null)
|
|
186
|
+
n.useEffect(()=>(_.current=setInterval(()=>{y(e=>e<=1?(clearInterval(_.current),0):e-1)},1e3),()=>{_.current&&clearInterval(_.current)}),[])
|
|
187
187
|
const g=e=>{var r
|
|
188
188
|
null==(r=v.current[e])||r.focus()},q=n.useCallback((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
|
|
189
189
|
p(null),d(r=>{const a=[...r]
|
|
@@ -194,24 +194,24 @@ const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6)
|
|
|
194
194
|
if(!r)return
|
|
195
195
|
const n=Array(6).fill("")
|
|
196
196
|
r.split("").forEach((e,r)=>{n[r]=e}),d(n),p(null),g(Math.min(r.length,5))},[]),k=s.join(""),C=6===k.length&&!s.includes(""),x=n.useCallback(async()=>{if(C){u(!0),p(null)
|
|
197
|
-
try{const r=await
|
|
197
|
+
try{const r=await P({functionBaseUrl:i,merchantId:o},e,k,l)
|
|
198
198
|
a(r.session_token,r.buyer_id,r.session_id)}catch(e){p(e instanceof Error?e.message:"Verification failed. Please try again."),d(Array(6).fill("")),g(0)}finally{u(!1)}}},[C,k,e,i,o,a,l])
|
|
199
199
|
n.useEffect(()=>{C&&!c&&x()},[C])
|
|
200
|
-
const E=n.useCallback(async()=>{if(!(m>0||
|
|
201
|
-
try{await T({functionBaseUrl:i,merchantId:o},e),
|
|
202
|
-
return r.jsxs("div",{className:"qr-auth-step",children:[r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:t,disabled:c,children:r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r.jsx("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r.jsx("rect",{x:"13",y:"16",width:"22",height:"16",rx:"2",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r.jsx("path",{d:"M13 22h22",stroke:"var(--qr-primary)",strokeWidth:"1.8"}),r.jsx("circle",{cx:"18",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r.jsx("circle",{cx:"24",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r.jsx("circle",{cx:"30",cy:"29",r:"1.5",fill:"var(--qr-primary)"})]})}),r.jsx("h3",{className:"qr-auth-step__title",children:"Enter OTP"}),r.jsxs("p",{className:"qr-auth-step__sub",children:["Sent to ",r.jsx("strong",{children:te(e)})]}),r.jsx("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter one-time password",children:s.map((e,n)=>r.jsx("input",{ref:e=>{v.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${h?" qr-otp-box--error":""}`,value:e,onChange:e=>q(n,e.target.value),onKeyDown:e=>w(n,e),onPaste:N,onFocus:e=>e.target.select(),"aria-label":`OTP digit ${n+1}`,disabled:c,autoComplete:0===n?"one-time-code":"off"},n))}),h&&r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:h}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:x,disabled:!C||c,children:c?r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify OTP"}),r.jsx("p",{className:"qr-auth-step__resend",children:m>0?r.jsxs("span",{children:["Resend OTP in ",m,"s"]}):r.jsx("button",{type:"button",className:"qr-link-btn",onClick:E,disabled:
|
|
200
|
+
const E=n.useCallback(async()=>{if(!(m>0||f)){b(!0),p(null),d(Array(6).fill(""))
|
|
201
|
+
try{await T({functionBaseUrl:i,merchantId:o},e),y(30),_.current=setInterval(()=>{y(e=>e<=1?(clearInterval(_.current),0):e-1)},1e3),g(0)}catch(e){p(e instanceof Error?e.message:"Failed to resend OTP.")}finally{b(!1)}}},[m,f,i,o,e])
|
|
202
|
+
return r.jsxs("div",{className:"qr-auth-step",children:[r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:t,disabled:c,children:r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r.jsx("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r.jsx("rect",{x:"13",y:"16",width:"22",height:"16",rx:"2",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r.jsx("path",{d:"M13 22h22",stroke:"var(--qr-primary)",strokeWidth:"1.8"}),r.jsx("circle",{cx:"18",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r.jsx("circle",{cx:"24",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r.jsx("circle",{cx:"30",cy:"29",r:"1.5",fill:"var(--qr-primary)"})]})}),r.jsx("h3",{className:"qr-auth-step__title",children:"Enter OTP"}),r.jsxs("p",{className:"qr-auth-step__sub",children:["Sent to ",r.jsx("strong",{children:te(e)})]}),r.jsx("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter one-time password",children:s.map((e,n)=>r.jsx("input",{ref:e=>{v.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${h?" qr-otp-box--error":""}`,value:e,onChange:e=>q(n,e.target.value),onKeyDown:e=>w(n,e),onPaste:N,onFocus:e=>e.target.select(),"aria-label":`OTP digit ${n+1}`,disabled:c,autoComplete:0===n?"one-time-code":"off"},n))}),h&&r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:h}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:x,disabled:!C||c,children:c?r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify OTP"}),r.jsx("p",{className:"qr-auth-step__resend",children:m>0?r.jsxs("span",{children:["Resend OTP in ",m,"s"]}):r.jsx("button",{type:"button",className:"qr-link-btn",onClick:E,disabled:f,children:f?"Sending…":"Resend OTP"})})]})},oe=()=>r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 9.5L12 3l9 6.5V20a1 1 0 01-1 1H4a1 1 0 01-1-1V9.5z"}),r.jsx("path",{d:"M9 21V12h6v9"})]}),le=()=>r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),r.jsx("path",{d:"M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"})]}),se=()=>r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r.jsx("circle",{cx:"12",cy:"9",r:"2.5"})]})
|
|
203
203
|
function de({label:e}){return"home"===e?r.jsx(oe,{}):"work"===e?r.jsx(le,{}):r.jsx(se,{})}function ce(e){var r
|
|
204
204
|
const n=null==(r=e.label_text)?void 0:r.trim()
|
|
205
205
|
return"other"===e.label&&n?n:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function ue({address:e,onUse:n,onDelete:a,onSetDefault:t,deleting:i}){const o=[e.flat_number,e.building_name,e.street_name,e.locality,e.district,e.state,e.pincode].filter(Boolean),l=[e.flat_number,e.building_name,e.street_name].filter(Boolean).join(", "),s=[e.locality,e.district].filter(Boolean).join(", "),d=[e.state,e.pincode].filter(Boolean).join(" – "),c=o.length>0?void 0:e.locality||e.district||e.state
|
|
206
|
-
return r.jsxs("div",{className:"qr-addr-card"+(e.is_default?" qr-addr-card--default":""),children:[r.jsxs("div",{className:"qr-addr-card__header",children:[r.jsx("div",{className:"qr-addr-card__label-icon",children:r.jsx(de,{label:e.label})}),r.jsx("span",{className:"qr-addr-card__label",children:ce(e)}),e.is_default&&r.jsx("span",{className:"qr-addr-card__default-badge",children:"Default"}),r.jsxs("div",{className:"qr-addr-card__actions",children:[!e.is_default&&r.jsx("button",{type:"button",className:"qr-icon-btn",title:"Set as default",onClick:t,"aria-label":"Set as default address",children:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),r.jsx("button",{type:"button",className:"qr-icon-btn qr-icon-btn--danger",title:"Delete address",onClick:a,disabled:i,"aria-label":"Delete address",children:i?r.jsx("span",{className:"qr-spinner qr-spinner--xs","aria-hidden":"true"}):r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),r.jsx("path",{d:"M10 11v6M14 11v6"}),r.jsx("path",{d:"M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"})]})})]})]}),r.jsxs("div",{className:"qr-addr-card__body",children:[c?r.jsx("p",{className:"qr-addr-card__line",children:c}):r.jsxs(r.Fragment,{children:[l&&r.jsx("p",{className:"qr-addr-card__line",children:l}),s&&r.jsx("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:s}),d&&r.jsx("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:d})]}),r.jsxs("div",{className:"qr-addr-card__meta",children:[e.digipin?r.jsxs("span",{className:"qr-digipin-badge qr-digipin-badge--inline qr-digipin-badge--sm",children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:e.digipin})]}):r.jsx("span",{className:"qr-addr-card__pending-pin",children:"Pin confirmation needed"}),e.saved_at_brand&&r.jsxs("span",{className:"qr-addr-card__brand-chip",title:`First saved at ${e.saved_at_brand}`,children:[r.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M1 1h4.5l5.5 5.5-4.5 4.5L1 5.5V1zm2 1.5a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),e.saved_at_brand]})]})]}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full qr-btn--sm",onClick:n,children:"Deliver here"})]})}const he=({sessionToken:e,functionBaseUrl:a,merchantId:t,onSelectAddress:i,onAddNew:o})=>{const[l,s]=n.useState([]),[d,c]=n.useState(!0),[u,h]=n.useState(null),[p,m]=n.useState(null),
|
|
207
|
-
try{const r=await B(
|
|
206
|
+
return r.jsxs("div",{className:"qr-addr-card"+(e.is_default?" qr-addr-card--default":""),children:[r.jsxs("div",{className:"qr-addr-card__header",children:[r.jsx("div",{className:"qr-addr-card__label-icon",children:r.jsx(de,{label:e.label})}),r.jsx("span",{className:"qr-addr-card__label",children:ce(e)}),e.is_default&&r.jsx("span",{className:"qr-addr-card__default-badge",children:"Default"}),r.jsxs("div",{className:"qr-addr-card__actions",children:[!e.is_default&&r.jsx("button",{type:"button",className:"qr-icon-btn",title:"Set as default",onClick:t,"aria-label":"Set as default address",children:r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),r.jsx("button",{type:"button",className:"qr-icon-btn qr-icon-btn--danger",title:"Delete address",onClick:a,disabled:i,"aria-label":"Delete address",children:i?r.jsx("span",{className:"qr-spinner qr-spinner--xs","aria-hidden":"true"}):r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),r.jsx("path",{d:"M10 11v6M14 11v6"}),r.jsx("path",{d:"M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"})]})})]})]}),r.jsxs("div",{className:"qr-addr-card__body",children:[c?r.jsx("p",{className:"qr-addr-card__line",children:c}):r.jsxs(r.Fragment,{children:[l&&r.jsx("p",{className:"qr-addr-card__line",children:l}),s&&r.jsx("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:s}),d&&r.jsx("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:d})]}),r.jsxs("div",{className:"qr-addr-card__meta",children:[e.digipin?r.jsxs("span",{className:"qr-digipin-badge qr-digipin-badge--inline qr-digipin-badge--sm",children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:e.digipin})]}):r.jsx("span",{className:"qr-addr-card__pending-pin",children:"Pin confirmation needed"}),e.saved_at_brand&&r.jsxs("span",{className:"qr-addr-card__brand-chip",title:`First saved at ${e.saved_at_brand}`,children:[r.jsx("svg",{viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M1 1h4.5l5.5 5.5-4.5 4.5L1 5.5V1zm2 1.5a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),e.saved_at_brand]})]})]}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full qr-btn--sm",onClick:n,children:"Deliver here"})]})}const he=({sessionToken:e,functionBaseUrl:a,merchantId:t,onSelectAddress:i,onAddNew:o})=>{const[l,s]=n.useState([]),[d,c]=n.useState(!0),[u,h]=n.useState(null),[p,m]=n.useState(null),y={functionBaseUrl:a,merchantId:t},f=n.useCallback(async()=>{c(!0),h(null)
|
|
207
|
+
try{const r=await B(y,e)
|
|
208
208
|
if(0===r.length)return void o()
|
|
209
209
|
s(r)}catch(e){h(e instanceof Error?e.message:"Failed to load addresses.")}finally{c(!1)}},[e])
|
|
210
|
-
n.useEffect(()=>{
|
|
210
|
+
n.useEffect(()=>{f()},[f])
|
|
211
211
|
const b=n.useCallback(async r=>{m(r)
|
|
212
|
-
try{await
|
|
213
|
-
return 0===n.length&&o(),n})}catch(e){h(e instanceof Error?e.message:"Failed to delete address.")}finally{m(null)}},[e,o]),v=n.useCallback(async r=>{try{await $(
|
|
214
|
-
return d?r.jsx("div",{className:"qr-saved-step",children:r.jsx("div",{className:"qr-saved-step__loading","aria-live":"polite",children:r.jsx("span",{className:"qr-spinner","aria-label":"Loading addresses"})})}):u&&0===l.length?r.jsxs("div",{className:"qr-saved-step",children:[r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:u}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:
|
|
212
|
+
try{await O(y,e,r),s(e=>{const n=e.filter(e=>e.id!==r)
|
|
213
|
+
return 0===n.length&&o(),n})}catch(e){h(e instanceof Error?e.message:"Failed to delete address.")}finally{m(null)}},[e,o]),v=n.useCallback(async r=>{try{await $(y,e,r),s(e=>e.map(e=>({...e,is_default:e.id===r})))}catch(e){h(e instanceof Error?e.message:"Failed to set default.")}},[e])
|
|
214
|
+
return d?r.jsx("div",{className:"qr-saved-step",children:r.jsx("div",{className:"qr-saved-step__loading","aria-live":"polite",children:r.jsx("span",{className:"qr-spinner","aria-label":"Loading addresses"})})}):u&&0===l.length?r.jsxs("div",{className:"qr-saved-step",children:[r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:u}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:f,children:"Retry"}),r.jsx("button",{type:"button",className:"qr-auth-step__skip",onClick:o,children:"Enter address manually"})]}):r.jsxs("div",{className:"qr-saved-step",children:[r.jsxs("div",{className:"qr-step-header",children:[r.jsx("div",{className:"qr-step-badge qr-step-badge--saved",children:r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r.jsx("circle",{cx:"12",cy:"9",r:"2.5"})]})}),r.jsxs("div",{className:"qr-step-text",children:[r.jsx("span",{className:"qr-step-title",children:"Saved Addresses"}),r.jsx("span",{className:"qr-step-sub",children:"Pick one or add a new location"})]})]}),u&&r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:u}),r.jsx("div",{className:"qr-saved-step__list",children:l.map(e=>r.jsx(ue,{address:e,onUse:()=>i(e),onDelete:()=>b(e.id),onSetDefault:()=>v(e.id),deleting:p===e.id},e.id))}),r.jsxs("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:o,children:[r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 5v14M5 12h14"})}),"Add new address"]})]})},pe=({checkoutConfig:e,sessionToken:a,pincode:t,cartTotalPaise:i,theme:o="light",onCodAllowedChange:l})=>{const[s,d]=n.useState("loading"),[c,u]=n.useState(!1),[h,p]=n.useState()
|
|
215
215
|
n.useEffect(()=>{let r=!1
|
|
216
216
|
return d("loading"),(async()=>{try{const n=await j(e,a,t,i)
|
|
217
217
|
if(r)return
|
|
@@ -222,28 +222,28 @@ case"invalid_pincode":return"Enter a valid pincode to check COD."
|
|
|
222
222
|
default:return"COD is not available."}}(n.reason):void 0),d("ready")}catch{r||(d("error"),u(!1),p("Could not verify COD. Try again."))}})(),()=>{r=!0}},[e,a,t,i])
|
|
223
223
|
const m="dark"===o
|
|
224
224
|
return r.jsxs("div",{className:"qr-cod-banner"+(m?" qr-cod-banner--dark":""),role:"status","aria-live":"polite",children:[r.jsx("div",{className:"qr-cod-banner__title",children:"Cash on Delivery"}),"loading"===s&&r.jsx("p",{className:"qr-cod-banner__text qr-cod-banner__text--muted",children:"Checking availability…"}),"error"===s&&r.jsx("p",{className:"qr-cod-banner__text qr-cod-banner__text--warn",children:h}),"ready"===s&&c&&r.jsx("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",children:"Available for this address."}),"ready"===s&&!c&&h&&r.jsx("p",{className:"qr-cod-banner__text qr-cod-banner__text--muted",children:h})]})},me=({copy:e,ctaUrl:n,theme:a="light"})=>{const t="dark"===a
|
|
225
|
-
return r.jsxs("div",{className:"qr-prepaid-nudge"+(t?" qr-prepaid-nudge--dark":""),role:"complementary","aria-label":"Prepaid offer",children:[r.jsx("p",{className:"qr-prepaid-nudge__copy",children:e}),n?r.jsx("a",{href:n,className:"qr-btn qr-btn--primary qr-btn--sm qr-prepaid-nudge__cta",target:"_blank",rel:"noopener noreferrer",children:"Pay online instead"}):null]})},
|
|
225
|
+
return r.jsxs("div",{className:"qr-prepaid-nudge"+(t?" qr-prepaid-nudge--dark":""),role:"complementary","aria-label":"Prepaid offer",children:[r.jsx("p",{className:"qr-prepaid-nudge__copy",children:e}),n?r.jsx("a",{href:n,className:"qr-btn qr-btn--primary qr-btn--sm qr-prepaid-nudge__cta",target:"_blank",rel:"noopener noreferrer",children:"Pay online instead"}):null]})},ye="https://checkout.razorpay.com/v1/checkout.js",fe=({checkoutConfig:e,sessionToken:a,sessionId:t,amountPaise:i,enableCod:o=!1,codAllowed:l=!1,theme:s="light",onComplete:d,onBack:c,onEvent:u,orderConfirmationUrl:h})=>{const[p,m]=n.useState(!1),[y,f]=n.useState(null),b="dark"===s
|
|
226
226
|
n.useEffect(()=>{null==u||u("payment_step_viewed")},[u])
|
|
227
227
|
const v=`₹${(i/100).toLocaleString("en-IN")}`
|
|
228
|
-
return r.jsxs("div",{className:"qr-payment-step"+(b?" qr-payment-step--dark":""),children:[c?r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:c,disabled:p,children:"← Back"}):null,r.jsx("h3",{className:"qr-auth-step__title",children:"Choose payment"}),r.jsxs("p",{className:"qr-auth-step__sub",children:["Order total: ",r.jsx("strong",{children:v})]}),
|
|
229
|
-
try{await(window.Razorpay?Promise.resolve():new Promise((e,r)=>{const n=document.querySelector(`script[src="${
|
|
228
|
+
return r.jsxs("div",{className:"qr-payment-step"+(b?" qr-payment-step--dark":""),children:[c?r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:c,disabled:p,children:"← Back"}):null,r.jsx("h3",{className:"qr-auth-step__title",children:"Choose payment"}),r.jsxs("p",{className:"qr-auth-step__sub",children:["Order total: ",r.jsx("strong",{children:v})]}),y?r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:y}):null,r.jsxs("button",{type:"button",className:"qr-payment-option qr-payment-option--primary",onClick:async()=>{m(!0),f(null)
|
|
229
|
+
try{await(window.Razorpay?Promise.resolve():new Promise((e,r)=>{const n=document.querySelector(`script[src="${ye}"]`)
|
|
230
230
|
if(n)return void n.addEventListener("load",()=>e())
|
|
231
231
|
const a=document.createElement("script")
|
|
232
|
-
a.src=
|
|
232
|
+
a.src=ye,a.async=!0,a.onload=()=>e(),a.onerror=()=>r(new Error("Failed to load Razorpay")),document.body.appendChild(a)}))
|
|
233
233
|
const r=await H(e,a,i)
|
|
234
234
|
await new Promise((n,i)=>{window.Razorpay?new window.Razorpay({key:r.razorpay_key_id,amount:r.amount_paise,currency:r.currency,order_id:r.razorpay_order_id,name:"Checkout",handler:async r=>{try{const i=await G(e,a,{razorpay_order_id:r.razorpay_order_id,razorpay_payment_id:r.razorpay_payment_id,razorpay_signature:r.razorpay_signature,payment_method:"prepaid"})
|
|
235
235
|
if(null==u||u("payment_method_selected",i.payment_method),d({paymentMethod:i.payment_method,razorpayOrderId:i.razorpay_order_id,razorpayPaymentId:i.razorpay_payment_id}),h){const e=h.replace("{{sessionId}}",t??"")
|
|
236
|
-
window.location.href=e}n()}catch(e){i(e)}},modal:{ondismiss:()=>i(new Error("Payment cancelled"))}}).open():i(new Error("Razorpay unavailable"))})}catch(e){
|
|
236
|
+
window.location.href=e}n()}catch(e){i(e)}},modal:{ondismiss:()=>i(new Error("Payment cancelled"))}}).open():i(new Error("Razorpay unavailable"))})}catch(e){f(e instanceof Error?e.message:"Payment failed")}finally{m(!1)}},disabled:p,children:[r.jsx("span",{className:"qr-payment-option__icon","aria-hidden":"true",children:"UPI"}),r.jsxs("span",{className:"qr-payment-option__copy",children:[r.jsx("span",{className:"qr-payment-option__title",children:p?"Processing...":"Pay online"}),r.jsx("span",{className:"qr-payment-option__sub",children:"UPI, cards, wallets"})]}),r.jsx("strong",{className:"qr-payment-option__amount",children:v})]}),o&&l?r.jsxs("button",{type:"button",className:"qr-payment-option qr-payment-option--secondary",onClick:async()=>{m(!0),f(null)
|
|
237
237
|
try{const r=await K(e,a)
|
|
238
|
-
null==u||u("payment_method_selected",r.payment_method),d({paymentMethod:r.payment_method})}catch(e){
|
|
238
|
+
null==u||u("payment_method_selected",r.payment_method),d({paymentMethod:r.payment_method})}catch(e){f(e instanceof Error?e.message:"Failed to select COD")}finally{m(!1)}},disabled:p,children:[r.jsx("span",{className:"qr-payment-option__icon","aria-hidden":"true",children:"₹"}),r.jsxs("span",{className:"qr-payment-option__copy",children:[r.jsx("span",{className:"qr-payment-option__title",children:"Cash on Delivery"}),r.jsx("span",{className:"qr-payment-option__sub",children:"Pay when the order arrives"})]})]}):null,t?r.jsxs("p",{className:"qr-payment-step__meta",children:["Session ",t.slice(0,8),"…"]}):null]})},be=({onOtpSent:e,onSkip:a,functionBaseUrl:t,merchantId:i})=>{const[o,l]=n.useState(""),[s,d]=n.useState(!1),[c,u]=n.useState(null),h=n.useRef(null),p=n.useCallback(e=>{l(e.target.value.trim()),u(null)},[]),m=n.useCallback(async r=>{var n
|
|
239
239
|
if(r.preventDefault(),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return u("Enter a valid email address."),void(null==(n=h.current)||n.focus())
|
|
240
240
|
d(!0),u(null)
|
|
241
|
-
try{const{reused:r}=await
|
|
241
|
+
try{const{reused:r}=await F({functionBaseUrl:t,merchantId:i},o)
|
|
242
242
|
e(o.toLowerCase(),{reused:r})}catch(e){u(e instanceof Error?e.message:"Failed to send code. Please try again.")}finally{d(!1)}},[o,t,i,e])
|
|
243
243
|
return r.jsxs("div",{className:"qr-auth-step",children:[r.jsx("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r.jsx("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r.jsx("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"qr-auth-step__title",children:"Faster checkout"}),r.jsx("p",{className:"qr-auth-step__sub",children:"Enter your email to load saved addresses"}),r.jsxs("form",{onSubmit:m,noValidate:!0,children:[r.jsx("div",{className:"qr-email-field"+(c?" qr-email-field--error":""),children:r.jsx("input",{ref:h,type:"email",inputMode:"email",className:"qr-email-field__input",placeholder:"you@example.com",value:o,onChange:p,autoComplete:"email","aria-label":"Email address","aria-describedby":c?"qr-email-error":void 0,"aria-invalid":!!c,disabled:s})}),c&&r.jsx("p",{id:"qr-email-error",className:"qr-auth-step__error",role:"alert",children:c}),r.jsx("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--full",disabled:s||o.length<5,children:s?r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):r.jsxs(r.Fragment,{children:["Send Code",r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})})]}),r.jsx("button",{type:"button",className:"qr-auth-step__skip",onClick:a,disabled:s,children:"Skip, enter address manually"})]})}
|
|
244
244
|
function ve(e){const[r,n]=e.split("@")
|
|
245
|
-
return!n||r.length<=1?e:`${r[0]}***@${n}`}const _e=({email:e,codeReused:a=!1,onVerified:t,onBack:i,functionBaseUrl:o,merchantId:l,sessionContext:s})=>{const[d,c]=n.useState(Array(6).fill("")),[u,h]=n.useState(!1),[p,m]=n.useState(null),[f
|
|
246
|
-
n.useEffect(()=>(g.current=setInterval(()=>{
|
|
245
|
+
return!n||r.length<=1?e:`${r[0]}***@${n}`}const _e=({email:e,codeReused:a=!1,onVerified:t,onBack:i,functionBaseUrl:o,merchantId:l,sessionContext:s})=>{const[d,c]=n.useState(Array(6).fill("")),[u,h]=n.useState(!1),[p,m]=n.useState(null),[y,f]=n.useState(60),[b,v]=n.useState(!1),_=n.useRef([]),g=n.useRef(null)
|
|
246
|
+
n.useEffect(()=>(g.current=setInterval(()=>{f(e=>e<=1?(clearInterval(g.current),0):e-1)},1e3),()=>{g.current&&clearInterval(g.current)}),[])
|
|
247
247
|
const q=e=>{var r
|
|
248
248
|
return null==(r=_.current[e])?void 0:r.focus()},w=n.useCallback((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
|
|
249
249
|
m(null),c(r=>{const a=[...r]
|
|
@@ -257,45 +257,45 @@ r.split("").forEach((e,r)=>{n[r]=e}),c(n),m(null),q(Math.min(r.length,5))},[]),C
|
|
|
257
257
|
try{const r=await R({functionBaseUrl:o,merchantId:l},e,C,s)
|
|
258
258
|
t(r.session_token,r.buyer_id,r.session_id)}catch(e){m(e instanceof Error?e.message:"Verification failed. Please try again."),c(Array(6).fill("")),q(0)}finally{h(!1)}}},[x,C,e,o,l,t,s])
|
|
259
259
|
n.useEffect(()=>{x&&!u&&E()},[x])
|
|
260
|
-
const S=n.useCallback(async()=>{if(!(
|
|
261
|
-
try{await
|
|
262
|
-
return r.jsxs("div",{className:"qr-auth-step",children:[r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:i,disabled:u,children:r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r.jsx("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r.jsx("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r.jsx("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"qr-auth-step__title",children:"Check your email"}),r.jsx("p",{className:"qr-auth-step__sub",children:a?r.jsx(r.Fragment,{children:"Use the code we sent earlier — it's still valid for your next checkout."}):r.jsxs(r.Fragment,{children:["6-digit code sent to ",r.jsx("strong",{children:ve(e)})]})}),r.jsx("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter verification code",children:d.map((e,n)=>r.jsx("input",{ref:e=>{_.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${p?" qr-otp-box--error":""}`,value:e,onChange:e=>w(n,e.target.value),onKeyDown:e=>N(n,e),onPaste:k,onFocus:e=>e.target.select(),"aria-label":`Code digit ${n+1}`,disabled:u,autoComplete:0===n?"one-time-code":"off"},n))}),p&&r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:p}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:E,disabled:!x||u,children:u?r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify Code"}),r.jsx("p",{className:"qr-auth-step__resend",children:
|
|
260
|
+
const S=n.useCallback(async()=>{if(!(y>0||b)){v(!0),m(null),c(Array(6).fill(""))
|
|
261
|
+
try{await F({functionBaseUrl:o,merchantId:l},e),f(60),g.current=setInterval(()=>{f(e=>e<=1?(clearInterval(g.current),0):e-1)},1e3),q(0)}catch(e){m(e instanceof Error?e.message:"Failed to resend code.")}finally{v(!1)}}},[y,b,o,l,e])
|
|
262
|
+
return r.jsxs("div",{className:"qr-auth-step",children:[r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:i,disabled:u,children:r.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r.jsx("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r.jsx("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r.jsx("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"qr-auth-step__title",children:"Check your email"}),r.jsx("p",{className:"qr-auth-step__sub",children:a?r.jsx(r.Fragment,{children:"Use the code we sent earlier — it's still valid for your next checkout."}):r.jsxs(r.Fragment,{children:["6-digit code sent to ",r.jsx("strong",{children:ve(e)})]})}),r.jsx("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter verification code",children:d.map((e,n)=>r.jsx("input",{ref:e=>{_.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${p?" qr-otp-box--error":""}`,value:e,onChange:e=>w(n,e.target.value),onKeyDown:e=>N(n,e),onPaste:k,onFocus:e=>e.target.select(),"aria-label":`Code digit ${n+1}`,disabled:u,autoComplete:0===n?"one-time-code":"off"},n))}),p&&r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:p}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:E,disabled:!x||u,children:u?r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify Code"}),r.jsx("p",{className:"qr-auth-step__resend",children:y>0?r.jsxs("span",{children:["Resend code in ",y,"s"]}):r.jsx("button",{type:"button",className:"qr-link-btn",onClick:S,disabled:b,children:b?"Sending…":"Resend Code"})})]})}
|
|
263
263
|
function ge(e){if("undefined"!=typeof window){const e=window.innerWidth
|
|
264
264
|
return e<768?"mobile":e<1024?"tablet":"desktop"}const r=(e??"").toLowerCase()
|
|
265
265
|
return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function qe(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
|
|
266
266
|
return{deviceType:ge(e),platform:"web",userAgent:e}}const we=["utm_source","utm_medium","utm_campaign"]
|
|
267
267
|
function Ne(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),n={}
|
|
268
268
|
for(const e of we){const a=r.searchParams.get(e)
|
|
269
|
-
a&&(n[e]=a.slice(0,256))}return n}catch{return{}}}const ke=({address:e,onEditAddress:n})=>r.jsxs("div",{className:"qr-success",children:[r.jsx("div",{className:"qr-success__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 52 52",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"26",cy:"26",r:"26",fill:"var(--qr-success, #10b981)",opacity:"0.12"}),r.jsx("circle",{cx:"26",cy:"26",r:"20",fill:"var(--qr-success, #10b981)"}),r.jsx("path",{d:"M15 26l8 8 14-16",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"qr-success__title",children:"Address Saved!"}),r.jsx("p",{className:"qr-success__address",children:e.formattedAddress}),r.jsx("div",{className:"qr-success__meta",children:r.jsxs("span",{className:"qr-digipin-badge qr-digipin-badge--inline",children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:e.digipin})]})}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--sm",onClick:n,children:"Change Address"})]}),Ce=({apiKey:e,apiBaseUrl:a="https://api.quantaroute.com",onComplete:t,onError:i,defaultLat:o,defaultLng:l,theme:s="light",className:d="",style:c,mapHeight:u="
|
|
270
|
-
const
|
|
271
|
-
n.useEffect(()=>{
|
|
272
|
-
const
|
|
273
|
-
if(
|
|
274
|
-
n.useEffect(()=>{if(!
|
|
275
|
-
const e=()=>{"done"!==
|
|
276
|
-
return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==
|
|
277
|
-
const
|
|
269
|
+
a&&(n[e]=a.slice(0,256))}return n}catch{return{}}}const ke=({address:e,onEditAddress:n})=>r.jsxs("div",{className:"qr-success",children:[r.jsx("div",{className:"qr-success__icon","aria-hidden":"true",children:r.jsxs("svg",{viewBox:"0 0 52 52",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"26",cy:"26",r:"26",fill:"var(--qr-success, #10b981)",opacity:"0.12"}),r.jsx("circle",{cx:"26",cy:"26",r:"20",fill:"var(--qr-success, #10b981)"}),r.jsx("path",{d:"M15 26l8 8 14-16",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r.jsx("h3",{className:"qr-success__title",children:"Address Saved!"}),r.jsx("p",{className:"qr-success__address",children:e.formattedAddress}),r.jsx("div",{className:"qr-success__meta",children:r.jsxs("span",{className:"qr-digipin-badge qr-digipin-badge--inline",children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:e.digipin})]})}),r.jsx("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--sm",onClick:n,children:"Change Address"})]}),Ce=({apiKey:e,apiBaseUrl:a="https://api.quantaroute.com",onComplete:t,onError:i,defaultLat:o,defaultLng:l,theme:s="light",className:d="",style:c,mapHeight:u="min(52dvh, 420px)",title:h="Add Delivery Address",mobilePresentation:p="auto",mobileStepLabels:m,indiaBoundaryUrl:y,enableSearch:f=!0,enablePhoneAuth:b=!1,merchantId:v="",supabaseFunctionBaseUrl:_="",brandColor:g,logoUrl:q,headerBanner:w,onCheckoutEvent:N,enableCod:k=!1,enableServiceabilityCheck:C=!1,showIndiaPostDeliveryWarning:x=!1,serviceabilityBlockCheckout:E,codCartTotalPaise:S,codSessionToken:T="",enableEmailAuth:P=!1,variant:I,utmParams:B,enablePayment:O=!1,paymentAmountPaise:$,onPaymentComplete:F,enablePrepaidNudge:R=!1,prepaidNudgeCopy:j,prepaidNudgeCtaUrl:W,registerController:H,orderConfirmationUrl:G})=>{var K
|
|
270
|
+
const Y=b?"phone":P?"email":"none",Q="phone"===Y?"phone":"email"===Y?"email":"map",Z=Boolean(O&&$&&_),[X,ee]=n.useState(Q),[re,te]=n.useState(null),[oe,le]=n.useState(null),[se,de]=n.useState(null),[ce,ue]=n.useState(""),[ye,ve]=n.useState(!1),[ge,we]=n.useState(!1),[Ce,xe]=n.useState(null),[Ee,Se]=n.useState(null),[Le,Te]=n.useState(null),[Pe,Ie]=n.useState("form"),Be=n.useRef(X),Ae=n.useMemo(()=>B??Ne(),[B]),Oe=n.useMemo(()=>qe(),[]),$e=n.useMemo(()=>({utm_source:Ae.utm_source,utm_medium:Ae.utm_medium,utm_campaign:Ae.utm_campaign,device_type:Oe.deviceType,platform:Oe.platform,user_agent:Oe.userAgent,experiment_variant:I}),[Ae,Oe,I]),Me={functionBaseUrl:_,merchantId:v},De=(null==se?void 0:se.sessionToken)||T
|
|
271
|
+
n.useEffect(()=>{Be.current=X},[X])
|
|
272
|
+
const Ue=n.useCallback(e=>{const r={...e,sessionId:e.sessionId??(null==se?void 0:se.sessionId),buyerId:e.buyerId??(null==se?void 0:se.buyerId),authChannel:e.authChannel??("phone"===Y?"phone":"email"===Y?"email":"none"),deviceType:e.deviceType??Oe.deviceType,platform:e.platform??Oe.platform,userAgent:e.userAgent??Oe.userAgent,experimentVariant:e.experimentVariant??I,timestamp:(new Date).toISOString()}
|
|
273
|
+
if(N)try{N(r)}catch{}v&&_&&z(Me,{event_type:r.type,step:r.step,buyer_id:r.buyerId,auth_channel:r.authChannel,device_type:r.deviceType,platform:r.platform,user_agent:r.userAgent,payment_method:r.paymentMethod,experiment_variant:r.experimentVariant},null==se?void 0:se.sessionToken).catch(()=>{})},[se,Y,Oe,I,N,v,_,Me])
|
|
274
|
+
n.useEffect(()=>{if(!v||!_)return
|
|
275
|
+
const e=()=>{"done"!==Be.current&&(null==se?void 0:se.sessionToken)&&(V(Me,se.sessionToken,Be.current).catch(()=>{}),Ue({type:"session_abandoned",step:Be.current}))}
|
|
276
|
+
return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==se?void 0:se.sessionToken,v,_,Me,Ue]),n.useEffect(()=>{(null==se?void 0:se.sessionToken)&&v&&_&&J(Me,se.sessionToken).then(xe).catch(()=>xe(null))},[null==se?void 0:se.sessionToken,v,_,Me])
|
|
277
|
+
const Fe=n.useMemo(()=>function(e,r){const n=null==r?void 0:r.trim()
|
|
278
278
|
if(!n)return e
|
|
279
279
|
const a={"--qr-primary":n,"--qr-primary-dark":n,"--qr-border-focus":n,"--qr-primary-light":`color-mix(in srgb, ${n} 18%, white)`}
|
|
280
|
-
return e?{...e,...a}:a}(c,
|
|
281
|
-
if(
|
|
282
|
-
else{if(
|
|
283
|
-
|
|
284
|
-
n.useEffect(()=>{
|
|
285
|
-
return"form"===e?(
|
|
286
|
-
e&&
|
|
287
|
-
const
|
|
280
|
+
return e?{...e,...a}:a}(c,g),[c,g]),Re=()=>{Ue({type:"auth_skipped",step:"map"}),ee("map")},je=(e,r,n)=>{te({lat:e,lng:r,digipin:n}),Ue({type:"location_confirmed",step:"form",digipin:n,buyerId:null==se?void 0:se.buyerId}),ee("form")},We=async(e,r)=>{var n
|
|
281
|
+
if(le(e),Ie((null==r?void 0:r.paymentBackStep)??"form"),Ue({type:"address_completed",step:Z?"payment":"done",digipin:e.digipin,buyerId:null==se?void 0:se.buyerId}),(null==se?void 0:se.sessionToken)&&(U(Me,se.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),!(null==r?void 0:r.skipCreate)&&!e.addressId))try{await A(Me,se.sessionToken,{digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,locality:e.locality,pincode:e.pincode,delivery_status:e.delivery,flat_number:e.flatNumber,floor_number:e.floorNumber,building_name:e.buildingName,street_name:e.streetName,full_address_json:e,label:e.label??"home",label_text:"other"===e.label&&(null==(n=e.labelText)?void 0:n.trim())||null,is_default:!1})}catch{}if(Z&&De)ee("payment")
|
|
282
|
+
else{if(Z&&!De)return null==i||i(new Error("enablePayment requires phone/email auth or a codSessionToken prop.")),ee("done"),void t(e)
|
|
283
|
+
ee("done"),t(e)}},ze=()=>"form"===X?(ee(Le?"verify-address":"map"),!0):"verify-address"===X?(Te(null),te(null),ee("saved"),!0):"map"===X&&(null==se?void 0:se.sessionToken)?(ee("saved"),!0):"email-otp"===X?(ee("email"),!0):"otp"===X?(ee("phone"),!0):"payment"===X&&(ee(Pe),!0)
|
|
284
|
+
n.useEffect(()=>{H&&H({goBack:()=>{const e=Be.current
|
|
285
|
+
return"form"===e?(ee(Le?"verify-address":"map"),!0):"verify-address"===e?(Te(null),te(null),ee("saved"),!0):"map"===e&&(null==se?void 0:se.sessionToken)?(ee("saved"),!0):"email-otp"===e?(ee("email"),!0):"otp"===e?(ee("phone"),!0):"payment"===e&&(ee(Pe),!0)},getStep:()=>Be.current})},[H,null==se?void 0:se.sessionToken,Le,Pe]),n.useEffect(()=>{const e={phone:"phone_step_viewed",email:"email_step_viewed",saved:"saved_addresses_viewed","verify-address":"verify_address_step_viewed",map:"map_step_viewed",form:"form_step_viewed",payment:"payment_step_viewed"}[X]
|
|
286
|
+
e&&Ue({type:e,step:X,buyerId:null==se?void 0:se.buyerId})},[X]),n.useEffect(()=>{P&&"email"===Y&&(v&&_||null==i||i(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[P,Y,v,_,i])
|
|
287
|
+
const Ve=function(e,r,n){const a="verify-address"===e?"map":e
|
|
288
288
|
if("none"===r){if(n){const e=["map","form","payment","done"].indexOf(a)
|
|
289
289
|
return-1===e?0:e}return"map"===a?0:"form"===a?1:2}const t=("email"===r?n?["email","email-otp","saved","map","form","payment","done"]:["email","email-otp","saved","map","form","done"]:n?["phone","otp","saved","map","form","payment","done"]:["phone","otp","saved","map","form","done"]).indexOf(a)
|
|
290
|
-
return-1===t?0:t}(
|
|
291
|
-
return r.jsxs("div",{className:`qr-checkout qr-checkout--${s} ${d}`,style:
|
|
292
|
-
return r.jsx("div",{className:"qr-progress",role:"progressbar","aria-valuenow":
|
|
293
|
-
|
|
294
|
-
return{digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,division:"",locality:e.locality,pincode:e.pincode,delivery:e.delivery_status,country:"India",flatNumber:e.flat_number,floorNumber:e.floor_number,buildingName:e.building_name,streetName:e.street_name,formattedAddress:[e.flat_number,e.building_name,e.street_name,e.locality,e.district,e.state,e.pincode].filter(Boolean).join(", "),label:"work"===e.label||"other"===e.label?e.label:"home",labelText:(null==(r=e.label_text)?void 0:r.trim())||void 0,addressId:e.id}}(e),{skipCreate:!0,paymentBackStep:"saved"})}},onAddNew:()=>{
|
|
295
|
-
const r={...e,addressId:
|
|
296
|
-
|
|
297
|
-
e.AddressForm=ne,e.CheckoutWidget=Ce,e.CodAvailabilityBanner=pe,e.DIGIPIN_BOUNDS=i,e.EmailOtpStep=_e,e.EmailStep=be,e.MapPinSelector=L,e.OtpStep=ie,e.PaymentStep=
|
|
298
|
-
return n.ok&&a.success?{prepaid_nudge_copy:a.data.prepaid_nudge_copy,prepaid_nudge_cta_url:a.data.prepaid_nudge_cta_url}:null},e.fetchSessionOffer=J,e.formatDigiPin=h,e.getDigiPin=m,e.getLatLngFromDigiPin=
|
|
290
|
+
return-1===t?0:t}(X,Y,Z),Je=function(e,r){return"none"===e?r?3:2:r?6:5}(Y,Z),He="payment"===X?"payment":"phone"===X||"otp"===X||"email"===X||"email-otp"===X?"auth":"address",Ge=(null==m?void 0:m.auth)??("email"===Y?"Email":"Mobile"),Ke=[..."none"===Y?[]:[{id:"auth",label:Ge,status:"auth"===He?"active":"complete"}],{id:"address",label:(null==m?void 0:m.address)??"Address",status:"address"===He?"active":"payment"===He?"complete":"pending"},...Z?[{id:"payment",label:(null==m?void 0:m.payment)??"Pay",status:"payment"===He?"active":"pending"}]:[]]
|
|
291
|
+
return r.jsxs("div",{className:`qr-checkout qr-checkout--${s} qr-checkout--mobile-${p} ${d}`,style:Fe,"data-testid":"quantaroute-checkout",children:["done"!==X&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"qr-header",children:[r.jsxs("div",{className:"qr-header__brand",children:[q?r.jsx("img",{src:q,alt:"",className:"qr-header__logo-img",width:28,height:28,decoding:"async"}):r.jsxs("svg",{className:"qr-header__logo","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r.jsx("circle",{cx:"12",cy:"10",r:"3"})]}),r.jsx("span",{className:"qr-header__title",children:h})]}),r.jsx("div",{className:"qr-header__progress-desktop",children:(()=>{const e=Array.from({length:Je+1},(e,r)=>r)
|
|
292
|
+
return r.jsx("div",{className:"qr-progress",role:"progressbar","aria-valuenow":Ve+1,"aria-valuemin":1,"aria-valuemax":Je+1,"aria-label":`Step ${Ve+1} of ${Je+1}`,children:e.map(e=>r.jsxs(n.Fragment,{children:[r.jsx("div",{className:"qr-progress__dot"+(Ve>=e?" qr-progress__dot--active":"")}),e<Je&&r.jsx("div",{className:"qr-progress__line"+(Ve>e?" qr-progress__line--active":"")})]},e))})})()})]}),r.jsx("div",{className:"qr-header__progress-mobile",children:r.jsx("div",{className:"qr-mobile-stepper",role:"list","aria-label":"Checkout progress",children:Ke.map((e,a)=>r.jsxs(n.Fragment,{children:[r.jsxs("div",{className:`qr-mobile-stepper__item qr-mobile-stepper__item--${e.status}`,role:"listitem","aria-current":"active"===e.status?"step":void 0,children:[r.jsx("span",{className:"qr-mobile-stepper__mark","aria-hidden":"true",children:"complete"===e.status?"✓":a+1}),r.jsx("span",{className:"qr-mobile-stepper__label",children:e.label})]}),a<Ke.length-1?r.jsx("span",{className:"qr-mobile-stepper__rail","aria-hidden":"true"}):null]},e.id))})}),w?r.jsx("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:w}):null,Ce?r.jsxs("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[Ce.banner_copy,Ce.banner_cta_url?r.jsxs(r.Fragment,{children:[" ",r.jsx("a",{href:Ce.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===X&&P&&r.jsx(be,{onOtpSent:(e,r)=>{ue(e),ve(Boolean(null==r?void 0:r.reused)),Ue({type:"email_otp_sent",step:"email-otp",mobile:e}),ee("email-otp")},onSkip:Re,functionBaseUrl:_,merchantId:v}),"email-otp"===X&&P&&ce&&r.jsx(_e,{email:ce,codeReused:ye,onVerified:(e,r,n)=>{de({mobile:ce,sessionToken:e,sessionId:n??"",buyerId:r}),Ue({type:"email_verified",step:"saved",buyerId:r,sessionId:n}),ee("saved")},onBack:ze,functionBaseUrl:_,merchantId:v,sessionContext:$e}),"phone"===X&&b&&r.jsx(ae,{onOtpSent:e=>{de(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),Ue({type:"otp_sent",step:"otp",mobile:e}),ee("otp")},onSkip:Re,functionBaseUrl:_,merchantId:v}),"otp"===X&&se&&r.jsx(ie,{mobile:se.mobile,onVerified:(e,r,n)=>{de({mobile:(null==se?void 0:se.mobile)??"",sessionToken:e,sessionId:n??"",buyerId:r}),Ue({type:"phone_verified",step:"saved",buyerId:r,sessionId:n}),ee("saved")},onBack:ze,functionBaseUrl:_,merchantId:v,sessionContext:$e}),"saved"===X&&(null==se?void 0:se.sessionToken)&&r.jsx(he,{sessionToken:se.sessionToken,functionBaseUrl:_,merchantId:v,onSelectAddress:async e=>{if(null==se?void 0:se.sessionToken){try{await M(Me,se.sessionToken,e.id)}catch(e){return void(null==i||i(e instanceof Error?e:new Error("Failed to select address.")))}if(!e.digipin)return Te(e),Ue({type:"saved_address_selected",step:"verify-address",buyerId:se.buyerId}),void ee("verify-address")
|
|
293
|
+
Ue({type:"saved_address_selected",step:Z?"payment":"done",buyerId:se.buyerId,digipin:e.digipin}),U(Me,se.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),await We(function(e){var r
|
|
294
|
+
return{digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,division:"",locality:e.locality,pincode:e.pincode,delivery:e.delivery_status,country:"India",flatNumber:e.flat_number,floorNumber:e.floor_number,buildingName:e.building_name,streetName:e.street_name,formattedAddress:[e.flat_number,e.building_name,e.street_name,e.locality,e.district,e.state,e.pincode].filter(Boolean).join(", "),label:"work"===e.label||"other"===e.label?e.label:"home",labelText:(null==(r=e.label_text)?void 0:r.trim())||void 0,addressId:e.id}}(e),{skipCreate:!0,paymentBackStep:"saved"})}},onAddNew:()=>{Te(null),te(null),ee("map")}}),"verify-address"===X&&Le&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"qr-order-lock-banner",role:"status",children:"Confirm your delivery pin to complete this order"}),r.jsx(L,{onLocationConfirm:je,defaultLat:Le.lat??o,defaultLng:Le.lng??l,mapHeight:u,theme:s,indiaBoundaryUrl:y,enableSearch:f,apiKey:e,apiBaseUrl:a,brandColor:g})]}),"map"===X&&r.jsx(L,{onLocationConfirm:je,defaultLat:o,defaultLng:l,mapHeight:u,theme:s,indiaBoundaryUrl:y,enableSearch:f,apiKey:e,apiBaseUrl:a,brandColor:g}),"form"===X&&re&&r.jsx(ne,{digipin:re.digipin,lat:re.lat,lng:re.lng,apiKey:e,apiBaseUrl:a,onAddressComplete:async e=>{if(Le&&(null==se?void 0:se.sessionToken))try{await D(Me,se.sessionToken,Le.id,{digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,locality:e.locality,pincode:e.pincode,delivery_status:e.delivery,flat_number:e.flatNumber,floor_number:e.floorNumber,building_name:e.buildingName,street_name:e.streetName})
|
|
295
|
+
const r={...e,addressId:Le.id}
|
|
296
|
+
Te(null),await We(r,{skipCreate:!0})}catch(e){null==i||i(e instanceof Error?e:new Error("Failed to verify delivery pin."))}else await We(e)},onBack:ze,onError:i,theme:s,checkoutConfig:Me,serviceabilitySessionToken:De,enableServiceabilityCheck:C,showIndiaPostDeliveryWarning:x,serviceabilityBlockCheckout:E,initialValues:Le?{flatNumber:Le.flat_number,floorNumber:Le.floor_number,buildingName:Le.building_name,streetName:Le.street_name,locality:Le.locality,label:"work"===Le.label||"other"===Le.label?Le.label:"home",labelText:(null==(K=Le.label_text)?void 0:K.trim())||void 0}:void 0,submitLabel:Le?"Confirm delivery pin":void 0}),"payment"===X&&Z&&De&&$&&r.jsx(fe,{checkoutConfig:Me,sessionToken:De,sessionId:null==se?void 0:se.sessionId,amountPaise:$,enableCod:k,codAllowed:ge,theme:s,onComplete:({paymentMethod:e,razorpayOrderId:r,razorpayPaymentId:n})=>{Se(e),Ue({type:"payment_method_selected",step:"done",paymentMethod:e}),ee("done"),oe&&t(oe),null==F||F({paymentMethod:e,sessionId:null==se?void 0:se.sessionId,razorpayOrderId:r,razorpayPaymentId:n})},onBack:ze,onEvent:(e,r)=>Ue({type:e,step:"payment",paymentMethod:r,buyerId:null==se?void 0:se.buyerId}),orderConfirmationUrl:G}),"done"===X&&oe&&r.jsxs(r.Fragment,{children:[r.jsx(ke,{address:oe,onEditAddress:()=>{Ue({type:"widget_reset",step:Q}),ee(Q),te(null),le(null),Te(null)}}),Ee?r.jsxs("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===Ee?"Cash on Delivery":"online payment"]}):null,k&&v&&_&&De?r.jsxs(r.Fragment,{children:[r.jsx(pe,{checkoutConfig:Me,sessionToken:De,pincode:oe.pincode,cartTotalPaise:S??$,theme:s,onCodAllowedChange:we}),R&&ge?r.jsx(me,{copy:j??"Save more when you pay online — faster delivery & exclusive offers.",ctaUrl:W,theme:s}):null]}):null]}),r.jsxs("div",{className:"qr-footer",children:[r.jsx("span",{children:"Powered by"}),r.jsx("a",{href:"https://quantaroute.com",target:"_blank",rel:"noopener noreferrer",className:"qr-footer__link",children:"QuantaRoute"}),r.jsx("span",{className:"qr-footer__flag","aria-label":"Made in India",children:"🇮🇳"})]})]})}
|
|
297
|
+
e.AddressForm=ne,e.CheckoutWidget=Ce,e.CodAvailabilityBanner=pe,e.DIGIPIN_BOUNDS=i,e.EmailOtpStep=_e,e.EmailStep=be,e.MapPinSelector=L,e.OtpStep=ie,e.PaymentStep=fe,e.PhoneStep=ae,e.PrepaidNudge=me,e.SavedAddressStep=he,e.autocompleteAddress=k,e.captureUtmFromUrl=Ne,e.checkCodEligibility=j,e.checkServiceability=W,e.couldBeDigiPinInput=N,e.createAddress=A,e.createPaymentOrder=H,e.default=Ce,e.deleteAddress=O,e.detectDeviceType=ge,e.detectPlatform=function(){return"web"},e.fetchPrepaidNudgeConfig=async function(e,r){const n=await fetch(`${e}/checkout-admin?action=cod_config`,{headers:{"x-api-key":r}}),a=await n.json().catch(()=>({}))
|
|
298
|
+
return n.ok&&a.success?{prepaid_nudge_copy:a.data.prepaid_nudge_copy,prepaid_nudge_cta_url:a.data.prepaid_nudge_cta_url}:null},e.fetchSessionOffer=J,e.formatDigiPin=h,e.getDigiPin=m,e.getLatLngFromDigiPin=y,e.getWebDeviceContext=qe,e.hasUtmParams=function(e){return Boolean(e.utm_source||e.utm_medium||e.utm_campaign)},e.isCompleteDigiPinInput=p,e.isPotentialDigiPinInput=u,e.isValidDigiPin=function(e){if(!e||"string"!=typeof e)return!1
|
|
299
299
|
if(!p(e))return!1
|
|
300
|
-
try{return
|
|
301
|
-
try{return m(e,r)}catch{return null}},[e,r])},e.useGeolocation=x,e.validatePincode=g,e.verifyDigipin=D,e.verifyEmailOtp=R,e.verifyOtp=
|
|
300
|
+
try{return y(e),!0}catch{return!1}},e.isWithinIndia=f,e.listAddresses=B,e.logFunnelEvent=z,e.looksLikeDigiPin=w,e.lookupLocation=_,e.normalizeDigiPinInput=c,e.notifyAddressCompleted=U,e.notifySessionAbandoned=V,e.pincodeHasDeliveryOffice=q,e.recordCodPayment=K,e.reverseGeocode=C,e.selectAddress=M,e.sendEmailOtp=F,e.sendOtp=T,e.setDefaultAddress=$,e.useDigiPin=function(e,r){return n.useMemo(()=>{if(!f(e,r))return null
|
|
301
|
+
try{return m(e,r)}catch{return null}},[e,r])},e.useGeolocation=x,e.validatePincode=g,e.verifyDigipin=D,e.verifyEmailOtp=R,e.verifyOtp=P,e.verifyPayment=G,Object.defineProperties(e,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})
|