@quantaroute/checkout 1.7.3 → 1.7.4

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.
@@ -74,96 +74,102 @@ 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
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}))},[])}}const E="https://maps.quantaroute.com/styles/quantaroute.json",S="https://maps.quantaroute.com/styles/quantaroute-pro-light.json",L="https://maps.quantaroute.com/styles/quantaroute-pro-dark.json",T={pro:E,light:S,dark:L}
77
- function P(e,r){return e||(r?T[r]:E)}const I=E
78
- function B(){if("undefined"==typeof window)return null
77
+ function P(e,r){return e||(r?T[r]:E)}const I="https://maps.quantaroute.com"
78
+ function B(e,r){if(!r||!e.startsWith(I))return e
79
+ try{const n=new URL(e)
80
+ return n.searchParams.set("key",r),n.toString()}catch{return e}}function A(e){if(e)return r=>r.startsWith(I)?{url:B(r,e)}:{url:r}}const O=E
81
+ function M(){if("undefined"==typeof window)return null
79
82
  const e=window.maplibregl
80
- return e&&"function"==typeof e.Map&&"function"==typeof e.Marker?e:null}function A(e,r,n=8e3,a=100){const t=Date.now()
83
+ return e&&"function"==typeof e.Map&&"function"==typeof e.Marker?e:null}function $(e,r,n=8e3,a=100){const t=Date.now()
81
84
  let i=null,o=!1
82
85
  const l=()=>{if(o)return
83
- const s=B()
86
+ const s=M()
84
87
  s?e(s):Date.now()-t>=n?r():i=window.setTimeout(l,a)}
85
- return l(),()=>{o=!0,null!==i&&window.clearTimeout(i)}}function O(e,r){if(!f(e,r))return null
86
- try{return m(e,r)}catch{return null}}const M="#0ea5e9"
87
- function $(e=M){const r=document.createElement("div")
88
- 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}function D(e){const r=null==e?void 0:e.querySelector(".maplibregl-ctrl-attrib")
89
- r instanceof HTMLElement&&(r.classList.add("maplibregl-compact"),r.classList.remove("maplibregl-compact-show"),r.removeAttribute("open"))}const U=({onLocationConfirm:e,defaultLat:t,defaultLng:i,mapHeight:o="380px",theme:l="light",indiaBoundaryUrl:s,enableSearch:d=!0,apiKey:c,apiBaseUrl:u,brandColor:p=M,mapStyle:m,mapTheme:f,embedMode:b="bundled"})=>{const v=P(m,f),_=n.useRef(null),g=n.useRef(null),q=n.useRef(null),C=t??13.00427,E=i??77.589291,S=void 0!==t&&void 0!==i,[L,T]=n.useState(C),[I,B]=n.useState(E),[U,R]=n.useState(()=>O(C,E)),[F,j]=n.useState(!1),[W,z]=n.useState("loading"),[V,J]=n.useState(null),[H,G]=n.useState(""),[K,Q]=n.useState([]),[Z,Y]=n.useState(!1),[X,ee]=n.useState(null),[re,ne]=n.useState(!1),ae=n.useRef(null),te=n.useRef(null),ie=n.useId(),{loading:oe,error:le,locate:se,clearError:de}=x(),ce=n.useCallback((e,r)=>{T(e),B(r),R(O(e,r))},[]),ue=n.useCallback((e,r)=>{var n,a
90
- ce(e,r),null==(n=g.current)||n.flyTo({center:[r,e],zoom:18,duration:900,essential:!0}),null==(a=q.current)||a.setLngLat([r,e])},[ce]),he=n.useCallback(e=>{const r=e.target.value
91
- G(r),ee(null),ae.current&&clearTimeout(ae.current)
92
- const n=r.trim()
93
- if(!n)return Q([]),ne(!1),void Y(!1)
94
- if(w(n))try{const e=y(n),r=parseFloat(e.latitude),a=parseFloat(e.longitude)
95
- ue(r,a),Q([]),ne(!1),G(h(n))}catch{ee("Invalid DigiPin code")}else{if(N(n))return Q([]),ne(!1),void Y(!1)
96
- if(n.length<3)return Q([]),void ne(!1)
97
- Y(!0),ae.current=setTimeout(async()=>{try{const e=c??"",r=await k(n,e,u,5,L,I)
98
- Q(r),ne(r.length>0)}catch(e){ee(e instanceof Error?e.message:"Search failed"),Q([]),ne(!1)}finally{Y(!1)}},400)}},[c,u,ue,L,I]),pe=n.useCallback(e=>{var r
99
- ue(e.coordinates.latitude,e.coordinates.longitude),G(""),Q([]),ne(!1),null==(r=te.current)||r.blur()},[ue]),me=n.useCallback(e=>{"Escape"===e.key&&(Q([]),ne(!1),G(""))},[])
100
- n.useEffect(()=>{if(!_.current)return
88
+ return l(),()=>{o=!0,null!==i&&window.clearTimeout(i)}}function D(e,r){if(!f(e,r))return null
89
+ try{return m(e,r)}catch{return null}}const R="#0ea5e9"
90
+ function U(e=R){const r=document.createElement("div")
91
+ 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}function F(e){const r=null==e?void 0:e.querySelector(".maplibregl-ctrl-attrib")
92
+ r instanceof HTMLElement&&(r.classList.add("maplibregl-compact"),r.classList.remove("maplibregl-compact-show"),r.removeAttribute("open"))}const j=({onLocationConfirm:e,defaultLat:t,defaultLng:i,mapHeight:o="380px",theme:l="light",indiaBoundaryUrl:s,enableSearch:d=!0,apiKey:c,apiBaseUrl:u,brandColor:p=R,mapStyle:m,mapTheme:f,embedMode:b="bundled",mapsKey:v})=>{const _=P(m,f),g=n.useRef(null),q=n.useRef(null),C=n.useRef(null),E=t??13.00427,S=i??77.589291,L=void 0!==t&&void 0!==i,[T,I]=n.useState(E),[O,M]=n.useState(S),[j,W]=n.useState(()=>D(E,S)),[z,V]=n.useState(!1),[J,H]=n.useState("loading"),[K,G]=n.useState(null),[Q,Z]=n.useState(""),[Y,X]=n.useState([]),[ee,re]=n.useState(!1),[ne,ae]=n.useState(null),[te,ie]=n.useState(!1),oe=n.useRef(null),le=n.useRef(0),se=n.useRef(null),de=n.useId(),{loading:ce,error:ue,locate:he,clearError:pe}=x(),me=n.useCallback((e,r)=>{I(e),M(r),W(D(e,r))},[]),ye=n.useCallback((e,r)=>{var n,a
93
+ me(e,r),null==(n=q.current)||n.flyTo({center:[r,e],zoom:18,duration:900,essential:!0}),null==(a=C.current)||a.setLngLat([r,e])},[me]),fe=n.useCallback(e=>{const r=e.target.value
94
+ Z(r),ae(null),oe.current&&clearTimeout(oe.current)
95
+ const n=++le.current,a=r.trim()
96
+ if(!a)return X([]),ie(!1),void re(!1)
97
+ if(w(a)){re(!1)
98
+ try{const e=y(a),r=parseFloat(e.latitude),n=parseFloat(e.longitude)
99
+ ye(r,n),X([]),ie(!1),Z(h(a))}catch{ae("Invalid DigiPin code")}}else{if(N(a))return X([]),ie(!1),void re(!1)
100
+ if(a.length<3)return X([]),ie(!1),void re(!1)
101
+ re(!0),oe.current=setTimeout(async()=>{try{const e=c??"",r=await k(a,e,u,5,T,O)
102
+ if(n!==le.current)return
103
+ X(r),ie(r.length>0)}catch(e){if(n!==le.current)return
104
+ ae(e instanceof Error?e.message:"Search failed"),X([]),ie(!1)}finally{n===le.current&&re(!1)}},400)}},[c,u,ye,T,O]),be=n.useCallback(e=>{var r
105
+ ye(e.coordinates.latitude,e.coordinates.longitude),oe.current&&clearTimeout(oe.current),le.current+=1,re(!1),Z(""),X([]),ie(!1),null==(r=se.current)||r.blur()},[ye]),ve=n.useCallback(e=>{"Escape"===e.key&&(oe.current&&clearTimeout(oe.current),le.current+=1,re(!1),X([]),ie(!1),Z(""))},[])
106
+ n.useEffect(()=>{if(!g.current)return
101
107
  let e=!1,r=null,n=null
102
- const t=S?18:9,i=_.current,o=r=>{if(!e&&_.current)try{const{map:a,cleanup:o}=function(e,r,n,a){const{styleUrl:t,initLat:i,initLng:o,initZoom:l,brandColor:s,indiaBoundaryUrl:d,refreshDigipin:c,onReady:u,onError:h}=a,p=d?fetch(d).then(e=>e.ok?e.json():null).catch(()=>null):Promise.resolve(null),m=new e.Map({container:r,style:t,center:[o,i],zoom:l,minZoom:6,attributionControl:!1,maplibreLogo:!1,touchZoomRotate:!0})
103
- "function"==typeof e.AttributionControl&&m.addControl(new e.AttributionControl({compact:!0}),"bottom-right"),function(e,r="https://maps.quantaroute.com/brand/quantaroute-mark.png"){let n
108
+ const t=L?18:9,i=g.current,o=r=>{if(!e&&g.current)try{const{map:a,cleanup:o}=function(e,r,n,a){const{styleUrl:t,initLat:i,initLng:o,initZoom:l,brandColor:s,indiaBoundaryUrl:d,mapsKey:c,refreshDigipin:u,onReady:h,onError:p}=a,m=d?fetch(d).then(e=>e.ok?e.json():null).catch(()=>null):Promise.resolve(null),y=new e.Map({container:r,style:B(t,c),transformRequest:A(c),center:[o,i],zoom:l,minZoom:6,attributionControl:!1,maplibreLogo:!1,touchZoomRotate:!0})
109
+ "function"==typeof e.AttributionControl&&y.addControl(new e.AttributionControl({compact:!0}),"bottom-right"),function(e,r="https://maps.quantaroute.com/brand/quantaroute-mark.png"){let n
104
110
  e.addControl({onAdd(){const e=document.createElement("a")
105
111
  e.className="maplibregl-ctrl qr-map-watermark",e.href="https://quantaroute.com",e.target="_blank",e.rel="noopener noreferrer",e.title="QuantaRoute",e.setAttribute("aria-label","QuantaRoute")
106
112
  const a=document.createElement("img")
107
- return a.src=r,a.alt="QuantaRoute",a.width=28,a.height=28,e.appendChild(a),n=e,e},onRemove(){null==n||n.remove()}},"bottom-left")}(m),"function"==typeof e.NavigationControl&&m.addControl(new e.NavigationControl({showCompass:!1}),"top-right")
108
- let y=null
109
- return m.on("style.load",()=>{D(r)}),m.on("load",()=>{D(r),u(),p.then(e=>{if(!t.includes("maps.quantaroute.com")&&e&&m.isStyleLoaded())try{m.addSource("india-boundary",{type:"geojson",data:e}),m.addLayer({id:"india-boundary-line",type:"line",source:"india-boundary",paint:{"line-color":"#94a3b8","line-width":1.5,"line-opacity":.65}})}catch{}}),y=new e.Marker({element:$(s),draggable:!0,anchor:"bottom"}).setLngLat([o,i]).addTo(m),n.current=y,y.on("drag",()=>{const e=y.getLngLat()
110
- c(e.lat,e.lng)}),y.on("dragend",()=>{const e=y.getLngLat()
111
- m.easeTo({center:[e.lng,e.lat],duration:250})})}),m.on("error",()=>{h("Map tiles could not load. Please try again.")}),m.on("click",e=>{const r=e.lngLat
112
- null==y||y.setLngLat([r.lng,r.lat]),c(r.lat,r.lng),m.easeTo({center:[r.lng,r.lat],duration:200})}),{map:m,cleanup:()=>{n.current=null,y=null,m.remove()}}}(r,i,q,{styleUrl:v,initLat:C,initLng:E,initZoom:t,brandColor:p,indiaBoundaryUrl:s,refreshDigipin:ce,onReady:()=>{e||(j(!0),z("ready"),J(null))},onError:r=>{e||(z(e=>"ready"===e?e:"error"),J(r))}})
113
- g.current=a,n=o}catch(e){z("error"),J(e instanceof Error?e.message:"Map failed to initialize.")}}
114
- return"external"===b?r=A(o,()=>{e||(z("unavailable"),J("Map could not load. Check your connection and try again."))}):o(a),()=>{e=!0,null==r||r(),ae.current&&clearTimeout(ae.current),q.current=null,g.current=null,null==n||n()}},[p,b,S,s,C,E,v,ce])
115
- const ye=n.useCallback(()=>{de(),se((e,r)=>{var n,a
116
- ce(e,r),null==(n=g.current)||n.flyTo({center:[r,e],zoom:18,duration:1400,essential:!0}),null==(a=q.current)||a.setLngLat([r,e])})},[se,de,ce]),fe=n.useCallback(()=>{U&&e(L,I,U)},[L,I,U,e]),be=null!==U,ve=be&&F&&"ready"===W,_e="ready"!==W
117
- 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:te,type:"search",className:"qr-search-bar__input",placeholder:"Search address, 'pharmacy near me', or DigiPin…",value:H,onChange:he,onKeyDown:me,autoComplete:"off",autoCorrect:"off",autoCapitalize:"characters",spellCheck:!1,"aria-label":"Search address or DigiPin","aria-autocomplete":"list","aria-controls":re?ie:void 0,"aria-expanded":re}),Z&&r.jsx("span",{className:"qr-search-bar__spinner qr-spinner qr-spinner--sm","aria-hidden":"true"}),H&&!Z&&r.jsx("button",{type:"button",className:"qr-search-bar__clear",onClick:()=>{G(""),Q([]),ne(!1),ee(null)},"aria-label":"Clear search",tabIndex:-1,children:"×"})]}),X&&r.jsx("p",{className:"qr-search-bar__error",role:"alert",children:X}),re&&K.length>0&&r.jsx("ul",{id:ie,className:"qr-search-bar__dropdown",role:"listbox","aria-label":"Address suggestions",children:K.map((e,n)=>r.jsxs("li",{className:"qr-search-bar__suggestion",role:"option","aria-selected":"false",onMouseDown:r=>{r.preventDefault(),pe(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:_,className:"qr-map-canvas"}),_e&&r.jsx("div",{className:"qr-map-notice",role:"loading"===W?"status":"alert",children:"loading"===W?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),r.jsx("span",{children:"Loading map…"})]}):V??"Map is unavailable. Please try again."}),U&&r.jsxs("div",{className:"qr-digipin-badge","aria-live":"polite","aria-label":`DigiPin: ${U}`,children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:U})]}),!be&&F&&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"+(oe?" qr-locate-btn--loading":""),onClick:ye,disabled:oe||"ready"!==W,title:"Use my current location","aria-label":"Use my current location",type:"button",children:oe?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"})]})}),le&&r.jsxs("div",{className:"qr-geo-error",role:"alert",children:[r.jsx("span",{children:le}),r.jsx("button",{type:"button",className:"qr-geo-error__dismiss",onClick:de,"aria-label":"Dismiss error",children:"×"})]})]}),F&&r.jsxs("div",{className:"qr-coords-strip","aria-label":"Current pin coordinates",children:[r.jsxs("span",{children:[L.toFixed(5),"° N"]}),r.jsx("span",{className:"qr-coords-sep",children:"·"}),r.jsxs("span",{children:[I.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:fe,disabled:!ve,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"})})]}),!be&&F&&r.jsx("p",{className:"qr-map-hint",children:"Move the pin to a location in India to continue"}),"ready"!==W&&r.jsx("p",{className:"qr-map-hint",children:"loading"===W?"Loading the map before location confirmation.":"Map is unavailable, so location confirmation is paused."})]})]})}
118
- async function R(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(()=>({}))
119
- if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")}async function F(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(()=>({}))
113
+ return a.src=r,a.alt="QuantaRoute",a.width=28,a.height=28,e.appendChild(a),n=e,e},onRemove(){null==n||n.remove()}},"bottom-left")}(y),"function"==typeof e.NavigationControl&&y.addControl(new e.NavigationControl({showCompass:!1}),"top-right")
114
+ let f=null
115
+ return y.on("style.load",()=>{F(r)}),y.on("load",()=>{F(r),h(),m.then(e=>{if(!t.includes("maps.quantaroute.com")&&e&&y.isStyleLoaded())try{y.addSource("india-boundary",{type:"geojson",data:e}),y.addLayer({id:"india-boundary-line",type:"line",source:"india-boundary",paint:{"line-color":"#94a3b8","line-width":1.5,"line-opacity":.65}})}catch{}}),f=new e.Marker({element:U(s),draggable:!0,anchor:"bottom"}).setLngLat([o,i]).addTo(y),n.current=f,f.on("drag",()=>{const e=f.getLngLat()
116
+ u(e.lat,e.lng)}),f.on("dragend",()=>{const e=f.getLngLat()
117
+ y.easeTo({center:[e.lng,e.lat],duration:250})})}),y.on("error",()=>{p("Map tiles could not load. Please try again.")}),y.on("click",e=>{const r=e.lngLat
118
+ null==f||f.setLngLat([r.lng,r.lat]),u(r.lat,r.lng),y.easeTo({center:[r.lng,r.lat],duration:200})}),{map:y,cleanup:()=>{n.current=null,f=null,y.remove()}}}(r,i,C,{styleUrl:_,initLat:E,initLng:S,initZoom:t,brandColor:p,indiaBoundaryUrl:s,mapsKey:v,refreshDigipin:me,onReady:()=>{e||(V(!0),H("ready"),G(null))},onError:r=>{e||(H(e=>"ready"===e?e:"error"),G(r))}})
119
+ q.current=a,n=o}catch(e){H("error"),G(e instanceof Error?e.message:"Map failed to initialize.")}}
120
+ return"external"===b?r=$(o,()=>{e||(H("unavailable"),G("Map could not load. Check your connection and try again."))}):o(a),()=>{e=!0,null==r||r(),oe.current&&clearTimeout(oe.current),C.current=null,q.current=null,null==n||n()}},[p,b,L,s,E,S,v,_,me])
121
+ const _e=n.useCallback(()=>{pe(),he((e,r)=>{var n,a
122
+ me(e,r),null==(n=q.current)||n.flyTo({center:[r,e],zoom:18,duration:1400,essential:!0}),null==(a=C.current)||a.setLngLat([r,e])})},[he,pe,me]),ge=n.useCallback(()=>{j&&e(T,O,j)},[T,O,j,e]),qe=null!==j,we=qe&&z&&"ready"===J,Ne="ready"!==J
123
+ 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:se,type:"search",className:"qr-search-bar__input",placeholder:"Search address, 'pharmacy near me', or DigiPin…",value:Q,onChange:fe,onKeyDown:ve,autoComplete:"off",autoCorrect:"off",autoCapitalize:"characters",spellCheck:!1,"aria-label":"Search address or DigiPin","aria-autocomplete":"list","aria-controls":te?de:void 0,"aria-expanded":te}),ee&&r.jsx("span",{className:"qr-search-bar__spinner qr-spinner qr-spinner--sm","aria-hidden":"true"}),Q&&!ee&&r.jsx("button",{type:"button",className:"qr-search-bar__clear",onClick:()=>{Z(""),X([]),ie(!1),ae(null)},"aria-label":"Clear search",tabIndex:-1,children:"×"})]}),ne&&r.jsx("p",{className:"qr-search-bar__error",role:"alert",children:ne}),te&&Y.length>0&&r.jsx("ul",{id:de,className:"qr-search-bar__dropdown",role:"listbox","aria-label":"Address suggestions",children:Y.map((e,n)=>r.jsxs("li",{className:"qr-search-bar__suggestion",role:"option","aria-selected":"false",onMouseDown:r=>{r.preventDefault(),be(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:g,className:"qr-map-canvas"}),Ne&&r.jsx("div",{className:"qr-map-notice",role:"loading"===J?"status":"alert",children:"loading"===J?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),r.jsx("span",{children:"Loading map…"})]}):K??"Map is unavailable. Please try again."}),j&&r.jsxs("div",{className:"qr-digipin-badge","aria-live":"polite","aria-label":`DigiPin: ${j}`,children:[r.jsx("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r.jsx("span",{className:"qr-digipin-badge__code",children:j})]}),!qe&&z&&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"+(ce?" qr-locate-btn--loading":""),onClick:_e,disabled:ce||"ready"!==J,title:"Use my current location","aria-label":"Use my current location",type:"button",children:ce?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"})]})}),ue&&r.jsxs("div",{className:"qr-geo-error",role:"alert",children:[r.jsx("span",{children:ue}),r.jsx("button",{type:"button",className:"qr-geo-error__dismiss",onClick:pe,"aria-label":"Dismiss error",children:"×"})]})]}),z&&r.jsxs("div",{className:"qr-coords-strip","aria-label":"Current pin coordinates",children:[r.jsxs("span",{children:[T.toFixed(5),"° N"]}),r.jsx("span",{className:"qr-coords-sep",children:"·"}),r.jsxs("span",{children:[O.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:ge,disabled:!we,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"})})]}),!qe&&z&&r.jsx("p",{className:"qr-map-hint",children:"Move the pin to a location in India to continue"}),"ready"!==J&&r.jsx("p",{className:"qr-map-hint",children:"loading"===J?"Loading the map before location confirmation.":"Map is unavailable, so location confirmation is paused."})]})]})}
124
+ async function W(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(()=>({}))
125
+ if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")}async function z(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(()=>({}))
120
126
  if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired OTP.")
121
- return i}function j(e){return{"Content-Type":"application/json","x-session-token":e}}async function W(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"list"})}),a=await n.json().catch(()=>({}))
127
+ return i}function V(e){return{"Content-Type":"application/json","x-session-token":e}}async function J(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"list"})}),a=await n.json().catch(()=>({}))
122
128
  if(!n.ok||!a.success)throw new Error(a.error??"Failed to load saved addresses.")
123
- return a.data??[]}async function z(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"create",address:n})}),t=await a.json().catch(()=>({}))
129
+ return a.data??[]}async function H(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"create",address:n})}),t=await a.json().catch(()=>({}))
124
130
  if(!a.ok||!t.success)throw new Error(t.error??"Failed to save address.")
125
- return t.data}async function V(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"delete",address_id:n})}),t=await a.json().catch(()=>({}))
126
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to delete address.")}async function J(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"set_default",address_id:n})}),t=await a.json().catch(()=>({}))
127
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to set default address.")}async function H(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"select_address",address_id:n})}),t=await a.json().catch(()=>({}))
128
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to select address.")}async function G(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"verify_digipin",address_id:n,...a})}),i=await t.json().catch(()=>({}))
131
+ return t.data}async function K(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"delete",address_id:n})}),t=await a.json().catch(()=>({}))
132
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to delete address.")}async function G(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"set_default",address_id:n})}),t=await a.json().catch(()=>({}))
133
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to set default address.")}async function Q(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"select_address",address_id:n})}),t=await a.json().catch(()=>({}))
134
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to select address.")}async function Z(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"verify_digipin",address_id:n,...a})}),i=await t.json().catch(()=>({}))
129
135
  if(!t.ok||!i.success)throw new Error(i.error??"Failed to verify delivery pin.")
130
- return i.data}async function K(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"address_completed",data:n})}),t=await a.json().catch(()=>({}))
131
- !a.ok||t.success}async function Q(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(()=>({}))
136
+ return i.data}async function Y(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"address_completed",data:n})}),t=await a.json().catch(()=>({}))
137
+ !a.ok||t.success}async function X(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(()=>({}))
132
138
  if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")
133
- return{reused:Boolean(a.reused)}}async function Z(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(()=>({}))
139
+ return{reused:Boolean(a.reused)}}async function ee(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(()=>({}))
134
140
  if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired code.")
135
- return i}async function Y(e,r,n,a){const t={action:"cod_eligibility",pincode:n}
141
+ return i}async function re(e,r,n,a){const t={action:"cod_eligibility",pincode:n}
136
142
  void 0!==a&&(t.cart_total_paise=a)
137
- const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify(t)}),o=await i.json().catch(()=>({}))
143
+ const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify(t)}),o=await i.json().catch(()=>({}))
138
144
  if(!i.ok||!o.success)throw new Error(o.error??"Failed to check COD eligibility.")
139
- return o.data}async function X(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"address_risk",data:n})}),t=await a.json().catch(()=>({}))
145
+ return o.data}async function ne(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"address_risk",data:n})}),t=await a.json().catch(()=>({}))
140
146
  if(!a.ok||!t.success)throw new Error(t.error??"Failed to score address risk.")
141
- return t.data}async function ee(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(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(()=>({}))
147
+ return t.data}async function ae(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(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(()=>({}))
142
148
  if(!t.ok||!i.success)throw new Error(i.error??"Failed to check delivery serviceability.")
143
- return i.data}async function re(e,r,n){try{const a={"Content-Type":"application/json"}
144
- 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 ne(e,r,n){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:j(r),body:JSON.stringify({action:"abandon",last_step:n})})}catch{}}async function ae(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:j(r)}),a=await n.json().catch(()=>({}))
145
- return n.ok&&a.success?a.data??null:null}async function te(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:j(r),body:JSON.stringify({action:"create_order",amount_paise:n})}),t=await a.json().catch(()=>({}))
149
+ return i.data}async function te(e,r,n){try{const a={"Content-Type":"application/json"}
150
+ 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 ie(e,r,n){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:V(r),body:JSON.stringify({action:"abandon",last_step:n})})}catch{}}async function oe(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:V(r)}),a=await n.json().catch(()=>({}))
151
+ return n.ok&&a.success?a.data??null:null}async function le(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:V(r),body:JSON.stringify({action:"create_order",amount_paise:n})}),t=await a.json().catch(()=>({}))
146
152
  if(!a.ok||!t.success)throw new Error(t.error??"Failed to create payment order.")
147
- return t.data}async function ie(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:j(r),body:JSON.stringify({action:"verify",...n})}),t=await a.json().catch(()=>({}))
153
+ return t.data}async function se(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:V(r),body:JSON.stringify({action:"verify",...n})}),t=await a.json().catch(()=>({}))
148
154
  if(!a.ok||!t.success)throw new Error(t.error??"Payment verification failed.")
149
- return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function oe(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:j(r),body:JSON.stringify({action:"record_cod"})}),a=await n.json().catch(()=>({}))
155
+ return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function de(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:V(r),body:JSON.stringify({action:"record_cod"})}),a=await n.json().catch(()=>({}))
150
156
  if(!n.ok||!a.success)throw new Error(a.error??"Failed to record COD selection.")
151
- return{payment_method:a.payment_method}}const le=/\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
152
- function se(e){return e.replace(le,"").replace(/\s+/g," ").trim()}function de(e){return se(e).toLowerCase()}function ce({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"}
157
+ return{payment_method:a.payment_method}}const ce=/\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
158
+ function ue(e){return e.replace(ce,"").replace(/\s+/g," ").trim()}function he(e){return ue(e).toLowerCase()}function pe({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"}
153
159
  switch(e){case"home":return r.jsxs("svg",{...a,children:[r.jsx("path",{d:"M3 9.5L12 3l9 6.5V20a1 1 0 01-1 1H5a1 1 0 01-1-1V9.5z"}),r.jsx("path",{d:"M9 21V12h6v9"})]})
154
160
  case"work":return r.jsxs("svg",{...a,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"})]})
155
- case"other":return r.jsxs("svg",{...a,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"})]})}}const ue={flatNumber:"",floorNumber:"",buildingName:"",streetName:""}
156
- function he(e,r){var n
161
+ case"other":return r.jsxs("svg",{...a,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"})]})}}const me={flatNumber:"",floorNumber:"",buildingName:"",streetName:""}
162
+ function ye(e,r){var n
157
163
  switch(r.type){case"LOAD_START":return{status:"loading"}
158
164
  case"LOAD_SUCCESS":{const e=function(e){const r={}
159
165
  e.name?r.buildingName=e.name:e.building_name?r.buildingName=e.building_name:e.addr_housename&&(r.buildingName=e.addr_housename)
160
166
  const n=[]
161
- return e.road&&n.push(e.road),e.suburb&&n.push(e.suburb),n.length>0&&(r.streetName=n.join(", ")),r}(r.addressComponents),a=r.initialValues,t={...ue,...e,...void 0!==(null==a?void 0:a.flatNumber)?{flatNumber:a.flatNumber}:{},...void 0!==(null==a?void 0:a.floorNumber)?{floorNumber:a.floorNumber}:{},...void 0!==(null==a?void 0:a.buildingName)?{buildingName:a.buildingName}:{},...void 0!==(null==a?void 0:a.streetName)?{streetName:a.streetName}:{}},i=function(e,r=[]){const n=new Set,a=[],t=e=>{const r=de(e)
162
- r&&!n.has(r)&&(n.add(r),a.push(se(e)))}
167
+ return e.road&&n.push(e.road),e.suburb&&n.push(e.suburb),n.length>0&&(r.streetName=n.join(", ")),r}(r.addressComponents),a=r.initialValues,t={...me,...e,...void 0!==(null==a?void 0:a.flatNumber)?{flatNumber:a.flatNumber}:{},...void 0!==(null==a?void 0:a.floorNumber)?{floorNumber:a.floorNumber}:{},...void 0!==(null==a?void 0:a.buildingName)?{buildingName:a.buildingName}:{},...void 0!==(null==a?void 0:a.streetName)?{streetName:a.streetName}:{}},i=function(e,r=[]){const n=new Set,a=[],t=e=>{const r=he(e)
168
+ r&&!n.has(r)&&(n.add(r),a.push(ue(e)))}
163
169
  t(e.locality)
164
170
  for(const e of r)t(e.name)
165
- const i=se(e.locality),o=de(e.locality),l=r.map(e=>({...e,name:se(e.name)})).filter(e=>{const r=de(e.name)
166
- return r&&r!==o}).filter((e,r,n)=>n.findIndex(r=>de(r.name)===de(e.name))===r)
171
+ const i=ue(e.locality),o=he(e.locality),l=r.map(e=>({...e,name:ue(e.name)})).filter(e=>{const r=he(e.name)
172
+ return r&&r!==o}).filter((e,r,n)=>n.findIndex(r=>he(r.name)===he(e.name))===r)
167
173
  return{adminInfo:{...e,locality:i},alternatives:l,localityOptions:a,selectedLocality:i}}(r.adminInfo,r.alternatives||[])
168
174
  let o=i.localityOptions,l=i.selectedLocality
169
175
  if(null==(n=null==a?void 0:a.locality)?void 0:n.trim()){const e=a.locality.trim()
@@ -175,8 +181,8 @@ case"SET_LABEL":return"ready"!==e.status?e:{...e,selectedLabel:r.label,labelText
175
181
  case"SET_LABEL_TEXT":return"ready"!==e.status?e:{...e,labelText:r.value.slice(0,64)}
176
182
  case"SUBMIT_START":return"ready"!==e.status?e:{...e,submitting:!0}
177
183
  case"SUBMIT_END":return"ready"!==e.status?e:{...e,submitting:!1}
178
- default:return e}}const pe=({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
179
- const[x,E]=n.useReducer(he,{status:"loading"}),S=n.useCallback(async()=>{var r
184
+ default:return e}}const fe=({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
185
+ const[x,E]=n.useReducer(ye,{status:"loading"}),S=n.useCallback(async()=>{var r
180
186
  E({type:"LOAD_START"})
181
187
  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))??""
182
188
  if(6!==s.length)return E({type:"LOAD_ERROR",message:"Could not determine a valid 6-digit pincode for this location. Please adjust the map pin."}),void(null==d||d(new Error("Missing or invalid pincode")))
@@ -184,24 +190,24 @@ const p=await g(s,i,o)
184
190
  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")))
185
191
  const m=q(p.offices)
186
192
  let b=null
187
- if(h&&(null==c?void 0:c.functionBaseUrl)&&c.merchantId&&u)try{b=await ee(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."
193
+ if(h&&(null==c?void 0:c.functionBaseUrl)&&c.merchantId&&u)try{b=await ae(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."
188
194
  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])
189
195
  n.useEffect(()=>{S()},[S])
190
- const L=n.useCallback(r=>{var n
191
- if(r.preventDefault(),"ready"!==x.status)return
196
+ const L=n.useCallback(async r=>{var n
197
+ if(r.preventDefault(),"ready"!==x.status||x.submitting)return
192
198
  const{adminInfo:i,selectedLocality:o,selectedLabel:s,labelText:d,fields:c}=x
193
199
  if("other"===s&&!d.trim())return
194
200
  if((null==(n=x.serviceabilityResult)?void 0:n.checked)&&!1===x.serviceabilityResult.serviceable&&(m??x.serviceabilityResult.block_checkout))return
195
201
  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()}:{}}
196
202
  E({type:"SUBMIT_START"})
197
- 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)
198
- 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(ce,{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"})})]})})]})]})]})},me=({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
203
+ try{await 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)
204
+ 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(pe,{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"})})]})})]})]})]})},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.replace(/\D/g,"").slice(0,10)),u(null)},[]),m=n.useCallback(async r=>{var n
199
205
  if(r.preventDefault(),10!==o.length)return u("Enter a valid 10-digit mobile number."),void(null==(n=h.current)||n.focus())
200
206
  d(!0),u(null)
201
- try{await R({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])
207
+ try{await W({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])
202
208
  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"})]})}
203
- function ye(e){const r=e.replace(/\D/g,"")
204
- return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const fe=({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)
209
+ function ve(e){const r=e.replace(/\D/g,"")
210
+ return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const _e=({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)
205
211
  n.useEffect(()=>(_.current=setInterval(()=>{y(e=>e<=1?(clearInterval(_.current),0):e-1)},1e3),()=>{_.current&&clearInterval(_.current)}),[])
206
212
  const g=e=>{var r
207
213
  null==(r=v.current[e])||r.focus()},q=n.useCallback((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
@@ -213,26 +219,26 @@ const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6)
213
219
  if(!r)return
214
220
  const n=Array(6).fill("")
215
221
  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)
216
- try{const r=await F({functionBaseUrl:i,merchantId:o},e,k,l)
222
+ try{const r=await z({functionBaseUrl:i,merchantId:o},e,k,l)
217
223
  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])
218
224
  n.useEffect(()=>{C&&!c&&x()},[C])
219
225
  const E=n.useCallback(async()=>{if(!(m>0||f)){b(!0),p(null),d(Array(6).fill(""))
220
- try{await R({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])
221
- 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:ye(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"})})]})},be=()=>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"})]}),ve=()=>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"})]}),_e=()=>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"})]})
222
- function ge({label:e}){return"home"===e?r.jsx(be,{}):"work"===e?r.jsx(ve,{}):r.jsx(_e,{})}function qe(e){var r
226
+ try{await W({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])
227
+ 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:ve(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"})})]})},ge=()=>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"})]}),qe=()=>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"})]}),we=()=>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"})]})
228
+ function Ne({label:e}){return"home"===e?r.jsx(ge,{}):"work"===e?r.jsx(qe,{}):r.jsx(we,{})}function ke(e){var r
223
229
  const n=null==(r=e.label_text)?void 0:r.trim()
224
- return"other"===e.label&&n?n:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function we({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
225
- 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(ge,{label:e.label})}),r.jsx("span",{className:"qr-addr-card__label",children:qe(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 Ne=({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)
226
- try{const r=await W(y,e)
230
+ return"other"===e.label&&n?n:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function Ce({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
231
+ 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(Ne,{label:e.label})}),r.jsx("span",{className:"qr-addr-card__label",children:ke(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 xe=({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)
232
+ try{const r=await J(y,e)
227
233
  if(0===r.length)return void o()
228
234
  s(r)}catch(e){h(e instanceof Error?e.message:"Failed to load addresses.")}finally{c(!1)}},[e])
229
235
  n.useEffect(()=>{f()},[f])
230
236
  const b=n.useCallback(async r=>{m(r)
231
- try{await V(y,e,r),s(e=>{const n=e.filter(e=>e.id!==r)
232
- 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 J(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])
233
- 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(we,{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"]})]})},ke=({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()
237
+ try{await K(y,e,r),s(e=>{const n=e.filter(e=>e.id!==r)
238
+ 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 G(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])
239
+ 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(Ce,{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"]})]})},Ee=({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()
234
240
  n.useEffect(()=>{let r=!1
235
- return d("loading"),(async()=>{try{const n=await Y(e,a,t,i)
241
+ return d("loading"),(async()=>{try{const n=await re(e,a,t,i)
236
242
  if(r)return
237
243
  u(n.cod_allowed),null==l||l(n.cod_allowed),p(n.cod_allowed?void 0:n.reason?function(e){switch(e){case"cod_disabled":return"Cash on Delivery is not enabled for this store."
238
244
  case"pincode_blocked":return"COD is not available for this pincode."
@@ -240,28 +246,32 @@ case"cart_value_exceeded":return"COD is not available for this order value."
240
246
  case"invalid_pincode":return"Enter a valid pincode to check COD."
241
247
  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])
242
248
  const m="dark"===o
243
- 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})]})},Ce=({copy:e,ctaUrl:n,theme:a="light"})=>{const t="dark"===a
244
- 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]})},xe="https://checkout.razorpay.com/v1/checkout.js",Ee=({checkoutConfig:e,sessionToken:a,sessionId:t,amountPaise:i,enableCod:o=!1,codAllowed:l=!1,addressRisk:s,theme:d="light",onComplete:c,onBack:u,onEvent:h,orderConfirmationUrl:p})=>{const[m,y]=n.useState(!1),[f,b]=n.useState(null),v="dark"===d
249
+ 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})]})},Se=({copy:e,ctaUrl:n,theme:a="light"})=>{const t="dark"===a
250
+ 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]})},Le="https://checkout.razorpay.com/v1/checkout.js"
251
+ let Te=null
252
+ const Pe=({checkoutConfig:e,sessionToken:a,sessionId:t,amountPaise:i,enableCod:o=!1,codAllowed:l=!1,addressRisk:s,theme:d="light",onComplete:c,onBack:u,onEvent:h,orderConfirmationUrl:p})=>{const[m,y]=n.useState(!1),[f,b]=n.useState(null),v="dark"===d
245
253
  n.useEffect(()=>{null==h||h("payment_step_viewed")},[h])
246
254
  const _=`₹${(i/100).toLocaleString("en-IN")}`,g=(null==s?void 0:s.interventions.includes("hide_cod"))??!1,q="high"===(null==s?void 0:s.level)?"high":"medium"===(null==s?void 0:s.level)?"medium":"low"
247
255
  return r.jsxs("div",{className:"qr-payment-step"+(v?" qr-payment-step--dark":""),children:[u?r.jsx("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:u,disabled:m,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:_})]}),f?r.jsx("p",{className:"qr-auth-step__error",role:"alert",children:f}):null,s&&"low"!==s.level?r.jsxs("div",{className:`qr-risk-banner qr-risk-banner--${q}`,role:"status",children:[r.jsx("strong",{children:"high"===s.level?"Address needs extra confirmation":"Address confidence check"}),r.jsx("span",{children:s.reasons[0]}),g?r.jsx("span",{children:"Cash on Delivery is disabled for this order. Online payment is still available."}):null]}):null,r.jsxs("button",{type:"button",className:"qr-payment-option qr-payment-option--primary",onClick:async()=>{y(!0),b(null)
248
- try{await(window.Razorpay?Promise.resolve():new Promise((e,r)=>{const n=document.querySelector(`script[src="${xe}"]`)
249
- if(n)return void n.addEventListener("load",()=>e())
256
+ try{await(window.Razorpay?Promise.resolve():Te||(Te=new Promise((e,r)=>{var n
257
+ null==(n=document.querySelector(`script[src="${Le}"]`))||n.remove()
250
258
  const a=document.createElement("script")
251
- a.src=xe,a.async=!0,a.onload=()=>e(),a.onerror=()=>r(new Error("Failed to load Razorpay")),document.body.appendChild(a)}))
252
- const r=await te(e,a,i)
253
- 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 ie(e,a,{razorpay_order_id:r.razorpay_order_id,razorpay_payment_id:r.razorpay_payment_id,razorpay_signature:r.razorpay_signature,payment_method:"prepaid"})
259
+ a.src=Le,a.async=!0
260
+ const t=e=>{window.clearTimeout(i),a.remove(),Te=null,r(new Error(e))},i=window.setTimeout(()=>t("Razorpay took too long to load"),15e3)
261
+ a.onload=()=>{window.clearTimeout(i),window.Razorpay?e():t("Razorpay unavailable")},a.onerror=()=>t("Failed to load Razorpay"),document.body.appendChild(a)}),Te))
262
+ const r=await le(e,a,i)
263
+ 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 se(e,a,{razorpay_order_id:r.razorpay_order_id,razorpay_payment_id:r.razorpay_payment_id,razorpay_signature:r.razorpay_signature,payment_method:"prepaid"})
254
264
  if(null==h||h("payment_method_selected",i.payment_method),c({paymentMethod:i.payment_method,razorpayOrderId:i.razorpay_order_id,razorpayPaymentId:i.razorpay_payment_id}),p){const e=p.replace("{{sessionId}}",t??"")
255
265
  window.location.href=e}n()}catch(e){i(e)}},modal:{ondismiss:()=>i(new Error("Payment cancelled"))}}).open():i(new Error("Razorpay unavailable"))})}catch(e){b(e instanceof Error?e.message:"Payment failed")}finally{y(!1)}},disabled:m,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:m?"Processing...":"Pay online"}),r.jsx("span",{className:"qr-payment-option__sub",children:"UPI, cards, wallets"})]}),r.jsx("strong",{className:"qr-payment-option__amount",children:_})]}),o&&l&&!g?r.jsxs("button",{type:"button",className:"qr-payment-option qr-payment-option--secondary",onClick:async()=>{y(!0),b(null)
256
- try{const r=await oe(e,a)
257
- null==h||h("payment_method_selected",r.payment_method),c({paymentMethod:r.payment_method})}catch(e){b(e instanceof Error?e.message:"Failed to select COD")}finally{y(!1)}},disabled:m,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]})},Se=({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
266
+ try{const r=await de(e,a)
267
+ null==h||h("payment_method_selected",r.payment_method),c({paymentMethod:r.payment_method})}catch(e){b(e instanceof Error?e.message:"Failed to select COD")}finally{y(!1)}},disabled:m,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]})},Ie=({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
258
268
  if(r.preventDefault(),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return u("Enter a valid email address."),void(null==(n=h.current)||n.focus())
259
269
  d(!0),u(null)
260
- try{const{reused:r}=await Q({functionBaseUrl:t,merchantId:i},o)
270
+ try{const{reused:r}=await X({functionBaseUrl:t,merchantId:i},o)
261
271
  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])
262
272
  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"})]})}
263
- function Le(e){const[r,n]=e.split("@")
264
- return!n||r.length<=1?e:`${r[0]}***@${n}`}const Te=({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)
273
+ function Be(e){const[r,n]=e.split("@")
274
+ return!n||r.length<=1?e:`${r[0]}***@${n}`}const Ae=({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)
265
275
  n.useEffect(()=>(g.current=setInterval(()=>{f(e=>e<=1?(clearInterval(g.current),0):e-1)},1e3),()=>{g.current&&clearInterval(g.current)}),[])
266
276
  const q=e=>{var r
267
277
  return null==(r=_.current[e])?void 0:r.focus()},w=n.useCallback((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
@@ -273,52 +283,57 @@ const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6)
273
283
  if(!r)return
274
284
  const n=Array(6).fill("")
275
285
  r.split("").forEach((e,r)=>{n[r]=e}),c(n),m(null),q(Math.min(r.length,5))},[]),C=d.join(""),x=6===C.length&&!d.includes(""),E=n.useCallback(async()=>{if(x){h(!0),m(null)
276
- try{const r=await Z({functionBaseUrl:o,merchantId:l},e,C,s)
286
+ try{const r=await ee({functionBaseUrl:o,merchantId:l},e,C,s)
277
287
  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])
278
288
  n.useEffect(()=>{x&&!u&&E()},[x])
279
289
  const S=n.useCallback(async()=>{if(!(y>0||b)){v(!0),m(null),c(Array(6).fill(""))
280
- try{await Q({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])
281
- 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:Le(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"})})]})}
282
- function Pe(e){if("undefined"!=typeof window){const e=window.innerWidth
290
+ try{await X({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])
291
+ 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:Be(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"})})]})}
292
+ function Oe(e){if("undefined"!=typeof window){const e=window.innerWidth
283
293
  return e<768?"mobile":e<1024?"tablet":"desktop"}const r=(e??"").toLowerCase()
284
- return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function Ie(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
285
- return{deviceType:Pe(e),platform:"web",userAgent:e}}const Be=["utm_source","utm_medium","utm_campaign"]
286
- function Ae(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),n={}
287
- for(const e of Be){const a=r.searchParams.get(e)
288
- a&&(n[e]=a.slice(0,256))}return n}catch{return{}}}const Oe=({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"})]}),Me=({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,mapStyle:b,mapTheme:v,embedMode:_,enablePhoneAuth:g=!1,merchantId:q="",supabaseFunctionBaseUrl:w="",brandColor:N,logoUrl:k,headerBanner:C,onCheckoutEvent:x,enableCod:E=!1,enableServiceabilityCheck:S=!1,enableAddressIntelligence:L=!1,showIndiaPostDeliveryWarning:T=!1,serviceabilityBlockCheckout:P,codCartTotalPaise:I,codSessionToken:B="",enableEmailAuth:A=!1,variant:O,utmParams:M,enablePayment:$=!1,paymentAmountPaise:D,onPaymentComplete:R,enablePrepaidNudge:F=!1,prepaidNudgeCopy:j,prepaidNudgeCtaUrl:W,registerController:V,orderConfirmationUrl:J})=>{var Q
289
- const Z=g?"phone":A?"email":"none",Y="phone"===Z?"phone":"email"===Z?"email":"map",ee=Boolean($&&D&&w),[te,ie]=n.useState(Y),[oe,le]=n.useState(null),[se,de]=n.useState(null),[ce,ue]=n.useState(null),[he,ye]=n.useState(""),[be,ve]=n.useState(!1),[_e,ge]=n.useState(!1),[qe,we]=n.useState(null),[xe,Le]=n.useState(null),[Pe,Be]=n.useState(null),[Me,$e]=n.useState(null),[De,Ue]=n.useState("form"),Re=n.useRef(te),Fe=n.useMemo(()=>M??Ae(),[M]),je=n.useMemo(()=>Ie(),[]),We=n.useMemo(()=>({utm_source:Fe.utm_source,utm_medium:Fe.utm_medium,utm_campaign:Fe.utm_campaign,device_type:je.deviceType,platform:je.platform,user_agent:je.userAgent,experiment_variant:O}),[Fe,je,O]),ze={functionBaseUrl:w,merchantId:q},Ve=(null==ce?void 0:ce.sessionToken)||B
290
- n.useEffect(()=>{Re.current=te},[te])
291
- const Je=n.useCallback(e=>{const r={...e,sessionId:e.sessionId??(null==ce?void 0:ce.sessionId),buyerId:e.buyerId??(null==ce?void 0:ce.buyerId),authChannel:e.authChannel??("phone"===Z?"phone":"email"===Z?"email":"none"),deviceType:e.deviceType??je.deviceType,platform:e.platform??je.platform,userAgent:e.userAgent??je.userAgent,experimentVariant:e.experimentVariant??O,timestamp:(new Date).toISOString()}
292
- if(x)try{x(r)}catch{}q&&w&&re(ze,{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==ce?void 0:ce.sessionToken).catch(()=>{})},[ce,Z,je,O,x,q,w,ze])
293
- n.useEffect(()=>{if(!q||!w)return
294
- const e=()=>{"done"!==Re.current&&(null==ce?void 0:ce.sessionToken)&&(ne(ze,ce.sessionToken,Re.current).catch(()=>{}),Je({type:"session_abandoned",step:Re.current}))}
295
- return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==ce?void 0:ce.sessionToken,q,w,ze,Je]),n.useEffect(()=>{(null==ce?void 0:ce.sessionToken)&&q&&w&&ae(ze,ce.sessionToken).then(we).catch(()=>we(null))},[null==ce?void 0:ce.sessionToken,q,w,ze])
296
- const He=n.useMemo(()=>function(e,r){const n=null==r?void 0:r.trim()
294
+ return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function Me(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
295
+ return{deviceType:Oe(e),platform:"web",userAgent:e}}const $e=["utm_source","utm_medium","utm_campaign"]
296
+ function De(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),n={}
297
+ for(const e of $e){const a=r.searchParams.get(e)
298
+ a&&(n[e]=a.slice(0,256))}return n}catch{return{}}}const Re=({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"})]}),Ue=({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,mapStyle:b,mapTheme:v,embedMode:_,mapsKey:g,enablePhoneAuth:q=!1,merchantId:w="",supabaseFunctionBaseUrl:N="",brandColor:k,logoUrl:C,headerBanner:x,onCheckoutEvent:E,enableCod:S=!1,enableServiceabilityCheck:L=!1,enableAddressIntelligence:T=!1,showIndiaPostDeliveryWarning:P=!1,serviceabilityBlockCheckout:I,codCartTotalPaise:B,codSessionToken:A="",enableEmailAuth:O=!1,variant:M,utmParams:$,enablePayment:D=!1,paymentAmountPaise:R,onPaymentComplete:U,enablePrepaidNudge:F=!1,prepaidNudgeCopy:W,prepaidNudgeCtaUrl:z,registerController:V,orderConfirmationUrl:J})=>{var K
299
+ const G=q?"phone":O?"email":"none",X="phone"===G?"phone":"email"===G?"email":"map",ee=Boolean(D&&R&&N),[ae,le]=n.useState(X),[se,de]=n.useState(null),[ce,ue]=n.useState(null),[he,pe]=n.useState(null),[me,ye]=n.useState(""),[ve,ge]=n.useState(!1),[qe,we]=n.useState(!1),[Ne,ke]=n.useState(null),[Ce,Le]=n.useState(null),[Te,Be]=n.useState(null),[Oe,$e]=n.useState(null),[Ue,Fe]=n.useState("form"),je=n.useRef(ae),We=n.useMemo(()=>$??De(),[$]),ze=n.useMemo(()=>Me(),[]),Ve=n.useMemo(()=>({utm_source:We.utm_source,utm_medium:We.utm_medium,utm_campaign:We.utm_campaign,device_type:ze.deviceType,platform:ze.platform,user_agent:ze.userAgent,experiment_variant:M}),[We,ze,M]),Je=n.useMemo(()=>({functionBaseUrl:N,merchantId:w}),[N,w]),He=(null==he?void 0:he.sessionToken)||A
300
+ n.useEffect(()=>{je.current=ae},[ae])
301
+ const Ke=n.useCallback(e=>{const r={...e,sessionId:e.sessionId??(null==he?void 0:he.sessionId),buyerId:e.buyerId??(null==he?void 0:he.buyerId),authChannel:e.authChannel??("phone"===G?"phone":"email"===G?"email":"none"),deviceType:e.deviceType??ze.deviceType,platform:e.platform??ze.platform,userAgent:e.userAgent??ze.userAgent,experimentVariant:e.experimentVariant??M,timestamp:(new Date).toISOString()}
302
+ if(E)try{E(r)}catch{}w&&N&&te(Je,{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==he?void 0:he.sessionToken).catch(()=>{})},[he,G,ze,M,E,w,N,Je])
303
+ n.useEffect(()=>{if(!w||!N)return
304
+ const e=()=>{"done"!==je.current&&(null==he?void 0:he.sessionToken)&&(ie(Je,he.sessionToken,je.current).catch(()=>{}),Ke({type:"session_abandoned",step:je.current}))}
305
+ return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==he?void 0:he.sessionToken,w,N,Je,Ke]),n.useEffect(()=>{(null==he?void 0:he.sessionToken)&&w&&N&&oe(Je,he.sessionToken).then(ke).catch(()=>ke(null))},[null==he?void 0:he.sessionToken,w,N,Je])
306
+ const Ge=null==ce?void 0:ce.pincode,Qe=B??R
307
+ n.useEffect(()=>{if(we(!1),!(ee&&S&&w&&He&&Ge))return
308
+ let e=!1
309
+ return re(Je,He,Ge,Qe).then(r=>{e||we(r.cod_allowed)}).catch(()=>{}),()=>{e=!0}},[ee,S,w,He,Ge,Qe,Je])
310
+ const Ze=n.useMemo(()=>function(e,r){const n=null==r?void 0:r.trim()
297
311
  if(!n)return e
298
312
  const a={"--qr-primary":n,"--qr-primary-dark":n,"--qr-border-focus":n,"--qr-primary-light":`color-mix(in srgb, ${n} 18%, white)`}
299
- return e?{...e,...a}:a}(c,N),[c,N]),Ge=()=>{Je({type:"auth_skipped",step:"map"}),ie("map")},Ke=(e,r,n)=>{le({lat:e,lng:r,digipin:n}),Je({type:"location_confirmed",step:"form",digipin:n,buyerId:null==ce?void 0:ce.buyerId}),ie("form")},Qe=async(e,r)=>{var n
313
+ return e?{...e,...a}:a}(c,k),[c,k]),Ye=()=>{Ke({type:"auth_skipped",step:"map"}),le("map")},Xe=(e,r,n)=>{de({lat:e,lng:r,digipin:n}),Ke({type:"location_confirmed",step:"form",digipin:n,buyerId:null==he?void 0:he.buyerId}),le("form")},er=async(e,r)=>{var n
300
314
  let a=e
301
- if(de(a),Ue((null==r?void 0:r.paymentBackStep)??"form"),(null==ce?void 0:ce.sessionToken)&&(K(ze,ce.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{const r=await z(ze,ce.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})
302
- a={...a,addressId:r.id},de(a)}catch{}if(L&&q&&w&&Ve)try{const e=await X(ze,Ve,{address_id:a.addressId,digipin:a.digipin,lat:a.lat,lng:a.lng,state:a.state,district:a.district,locality:a.locality,pincode:a.pincode,delivery_status:a.delivery,flat_number:a.flatNumber,floor_number:a.floorNumber,building_name:a.buildingName,street_name:a.streetName})
303
- Le(e),a={...a,addressRisk:e},de(a),Je({type:"address_risk_scored",step:ee?"payment":"done",digipin:a.digipin,buyerId:null==ce?void 0:ce.buyerId,addressRiskLevel:e.level,addressRiskScore:e.score})}catch{Le(null)}else Le(null)
304
- if(Je({type:"address_completed",step:ee?"payment":"done",digipin:a.digipin,buyerId:null==ce?void 0:ce.buyerId}),ee&&Ve)ie("payment")
305
- else{if(ee&&!Ve)return null==i||i(new Error("enablePayment requires phone/email auth or a codSessionToken prop.")),ie("done"),void t(a)
306
- ie("done"),t(a)}},Ze=()=>"form"===te?(ie(Me?"verify-address":"map"),!0):"verify-address"===te?($e(null),le(null),ie("saved"),!0):"map"===te&&(null==ce?void 0:ce.sessionToken)?(ie("saved"),!0):"email-otp"===te?(ie("email"),!0):"otp"===te?(ie("phone"),!0):"payment"===te&&(ie(De),!0)
307
- n.useEffect(()=>{V&&V({goBack:()=>{const e=Re.current
308
- return"form"===e?(ie(Me?"verify-address":"map"),!0):"verify-address"===e?($e(null),le(null),ie("saved"),!0):"map"===e&&(null==ce?void 0:ce.sessionToken)?(ie("saved"),!0):"email-otp"===e?(ie("email"),!0):"otp"===e?(ie("phone"),!0):"payment"===e&&(ie(De),!0)},getStep:()=>Re.current})},[V,null==ce?void 0:ce.sessionToken,Me,De]),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"}[te]
309
- e&&Je({type:e,step:te,buyerId:null==ce?void 0:ce.buyerId})},[te]),n.useEffect(()=>{A&&"email"===Z&&(q&&w||null==i||i(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[A,Z,q,w,i])
310
- const Ye=function(e,r,n){const a="verify-address"===e?"map":e
315
+ if(ue(a),Fe((null==r?void 0:r.paymentBackStep)??"form"),(null==he?void 0:he.sessionToken)&&(Y(Je,he.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{const r=await H(Je,he.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})
316
+ a={...a,addressId:r.id},ue(a)}catch{}if(T&&w&&N&&He)try{const e=await ne(Je,He,{address_id:a.addressId,digipin:a.digipin,lat:a.lat,lng:a.lng,state:a.state,district:a.district,locality:a.locality,pincode:a.pincode,delivery_status:a.delivery,flat_number:a.flatNumber,floor_number:a.floorNumber,building_name:a.buildingName,street_name:a.streetName})
317
+ Le(e),a={...a,addressRisk:e},ue(a),Ke({type:"address_risk_scored",step:ee?"payment":"done",digipin:a.digipin,buyerId:null==he?void 0:he.buyerId,addressRiskLevel:e.level,addressRiskScore:e.score})}catch{Le(null)}else Le(null)
318
+ if(Ke({type:"address_completed",step:ee?"payment":"done",digipin:a.digipin,buyerId:null==he?void 0:he.buyerId}),ee&&He)le("payment")
319
+ else{if(ee&&!He)return null==i||i(new Error("enablePayment requires phone/email auth or a codSessionToken prop.")),le("done"),void t(a)
320
+ le("done"),t(a)}},rr=()=>"form"===ae?(le(Oe?"verify-address":"map"),!0):"verify-address"===ae?($e(null),de(null),le("saved"),!0):"map"===ae&&(null==he?void 0:he.sessionToken)?(le("saved"),!0):"email-otp"===ae?(le("email"),!0):"otp"===ae?(le("phone"),!0):"payment"===ae&&(le(Ue),!0)
321
+ n.useEffect(()=>{V&&V({goBack:()=>{const e=je.current
322
+ return"form"===e?(le(Oe?"verify-address":"map"),!0):"verify-address"===e?($e(null),de(null),le("saved"),!0):"map"===e&&(null==he?void 0:he.sessionToken)?(le("saved"),!0):"email-otp"===e?(le("email"),!0):"otp"===e?(le("phone"),!0):"payment"===e&&(le(Ue),!0)},getStep:()=>je.current})},[V,null==he?void 0:he.sessionToken,Oe,Ue]),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"}[ae]
323
+ e&&Ke({type:e,step:ae,buyerId:null==he?void 0:he.buyerId})},[ae]),n.useEffect(()=>{O&&"email"===G&&(w&&N||null==i||i(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[O,G,w,N,i])
324
+ const nr=function(e,r,n){const a="verify-address"===e?"map":e
311
325
  if("none"===r){if(n){const e=["map","form","payment","done"].indexOf(a)
312
326
  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)
313
- return-1===t?0:t}(te,Z,ee),Xe=function(e,r){return"none"===e?r?3:2:r?6:5}(Z,ee),er="payment"===te?"payment":"phone"===te||"otp"===te||"email"===te||"email-otp"===te?"auth":"address",rr=(null==m?void 0:m.auth)??("email"===Z?"Email":"Mobile"),nr=[..."none"===Z?[]:[{id:"auth",label:rr,status:"auth"===er?"active":"complete"}],{id:"address",label:(null==m?void 0:m.address)??"Address",status:"address"===er?"active":"payment"===er?"complete":"pending"},...ee?[{id:"payment",label:(null==m?void 0:m.payment)??"Pay",status:"payment"===er?"active":"pending"}]:[]]
314
- return r.jsxs("div",{className:`qr-checkout qr-checkout--${s} qr-checkout--mobile-${p} ${d}`,style:He,"data-testid":"quantaroute-checkout",children:["done"!==te&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"qr-header",children:[r.jsxs("div",{className:"qr-header__brand",children:[k?r.jsx("img",{src:k,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:Xe+1},(e,r)=>r)
315
- return r.jsx("div",{className:"qr-progress",role:"progressbar","aria-valuenow":Ye+1,"aria-valuemin":1,"aria-valuemax":Xe+1,"aria-label":`Step ${Ye+1} of ${Xe+1}`,children:e.map(e=>r.jsxs(n.Fragment,{children:[r.jsx("div",{className:"qr-progress__dot"+(Ye>=e?" qr-progress__dot--active":"")}),e<Xe&&r.jsx("div",{className:"qr-progress__line"+(Ye>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:nr.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<nr.length-1?r.jsx("span",{className:"qr-mobile-stepper__rail","aria-hidden":"true"}):null]},e.id))})}),C?r.jsx("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:C}):null,qe?r.jsxs("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[qe.banner_copy,qe.banner_cta_url?r.jsxs(r.Fragment,{children:[" ",r.jsx("a",{href:qe.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===te&&A&&r.jsx(Se,{onOtpSent:(e,r)=>{ye(e),ve(Boolean(null==r?void 0:r.reused)),Je({type:"email_otp_sent",step:"email-otp",mobile:e}),ie("email-otp")},onSkip:Ge,functionBaseUrl:w,merchantId:q}),"email-otp"===te&&A&&he&&r.jsx(Te,{email:he,codeReused:be,onVerified:(e,r,n)=>{ue({mobile:he,sessionToken:e,sessionId:n??"",buyerId:r}),Je({type:"email_verified",step:"saved",buyerId:r,sessionId:n}),ie("saved")},onBack:Ze,functionBaseUrl:w,merchantId:q,sessionContext:We}),"phone"===te&&g&&r.jsx(me,{onOtpSent:e=>{ue(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),Je({type:"otp_sent",step:"otp",mobile:e}),ie("otp")},onSkip:Ge,functionBaseUrl:w,merchantId:q}),"otp"===te&&ce&&r.jsx(fe,{mobile:ce.mobile,onVerified:(e,r,n)=>{ue({mobile:(null==ce?void 0:ce.mobile)??"",sessionToken:e,sessionId:n??"",buyerId:r}),Je({type:"phone_verified",step:"saved",buyerId:r,sessionId:n}),ie("saved")},onBack:Ze,functionBaseUrl:w,merchantId:q,sessionContext:We}),"saved"===te&&(null==ce?void 0:ce.sessionToken)&&r.jsx(Ne,{sessionToken:ce.sessionToken,functionBaseUrl:w,merchantId:q,onSelectAddress:async e=>{if(null==ce?void 0:ce.sessionToken){try{await H(ze,ce.sessionToken,e.id)}catch(e){return void(null==i||i(e instanceof Error?e:new Error("Failed to select address.")))}if(!e.digipin)return $e(e),Je({type:"saved_address_selected",step:"verify-address",buyerId:ce.buyerId}),void ie("verify-address")
316
- Je({type:"saved_address_selected",step:ee?"payment":"done",buyerId:ce.buyerId,digipin:e.digipin}),K(ze,ce.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),await Qe(function(e){var r
317
- 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:()=>{$e(null),le(null),ie("map")}}),"verify-address"===te&&Me&&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(U,{onLocationConfirm:Ke,defaultLat:Me.lat??o,defaultLng:Me.lng??l,mapHeight:u,theme:s,indiaBoundaryUrl:y,enableSearch:f,apiKey:e,apiBaseUrl:a,brandColor:N,mapStyle:b,mapTheme:v,embedMode:_})]}),"map"===te&&r.jsx(U,{onLocationConfirm:Ke,defaultLat:o,defaultLng:l,mapHeight:u,theme:s,indiaBoundaryUrl:y,enableSearch:f,apiKey:e,apiBaseUrl:a,brandColor:N,mapStyle:b,mapTheme:v,embedMode:_}),"form"===te&&oe&&r.jsx(pe,{digipin:oe.digipin,lat:oe.lat,lng:oe.lng,apiKey:e,apiBaseUrl:a,onAddressComplete:async e=>{if(Me&&(null==ce?void 0:ce.sessionToken))try{await G(ze,ce.sessionToken,Me.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})
318
- const r={...e,addressId:Me.id}
319
- $e(null),await Qe(r,{skipCreate:!0})}catch(e){null==i||i(e instanceof Error?e:new Error("Failed to verify delivery pin."))}else await Qe(e)},onBack:Ze,onError:i,theme:s,checkoutConfig:ze,serviceabilitySessionToken:Ve,enableServiceabilityCheck:S,showIndiaPostDeliveryWarning:T,serviceabilityBlockCheckout:P,initialValues:Me?{flatNumber:Me.flat_number,floorNumber:Me.floor_number,buildingName:Me.building_name,streetName:Me.street_name,locality:Me.locality,label:"work"===Me.label||"other"===Me.label?Me.label:"home",labelText:(null==(Q=Me.label_text)?void 0:Q.trim())||void 0}:void 0,submitLabel:Me?"Confirm delivery pin":void 0}),"payment"===te&&ee&&Ve&&D&&r.jsx(Ee,{checkoutConfig:ze,sessionToken:Ve,sessionId:null==ce?void 0:ce.sessionId,amountPaise:D,enableCod:E,codAllowed:_e&&!(null==xe?void 0:xe.interventions.includes("hide_cod")),addressRisk:xe,theme:s,onComplete:({paymentMethod:e,razorpayOrderId:r,razorpayPaymentId:n})=>{Be(e),Je({type:"payment_method_selected",step:"done",paymentMethod:e}),ie("done"),se&&t(se),null==R||R({paymentMethod:e,sessionId:null==ce?void 0:ce.sessionId,razorpayOrderId:r,razorpayPaymentId:n})},onBack:Ze,onEvent:(e,r)=>Je({type:e,step:"payment",paymentMethod:r,buyerId:null==ce?void 0:ce.buyerId}),orderConfirmationUrl:J}),"done"===te&&se&&r.jsxs(r.Fragment,{children:[r.jsx(Oe,{address:se,onEditAddress:()=>{Je({type:"widget_reset",step:Y}),ie(Y),le(null),de(null),Le(null),$e(null)}}),Pe?r.jsxs("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===Pe?"Cash on Delivery":"online payment"]}):null,E&&q&&w&&Ve?r.jsxs(r.Fragment,{children:[r.jsx(ke,{checkoutConfig:ze,sessionToken:Ve,pincode:se.pincode,cartTotalPaise:I??D,theme:s,onCodAllowedChange:ge}),F&&_e?r.jsx(Ce,{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:"🇮🇳"})]})]})}
320
- e.AddressForm=pe,e.CARTO_POSITRON_STYLE_URL="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",e.CheckoutWidget=Me,e.CodAvailabilityBanner=ke,e.DEFAULT_MAP_STYLE_URL=I,e.DIGIPIN_BOUNDS=i,e.EmailOtpStep=Te,e.EmailStep=Se,e.MapPinSelector=U,e.OPENFREEMAP_POSITRON_STYLE_URL="https://tiles.openfreemap.org/styles/positron",e.OtpStep=fe,e.PaymentStep=Ee,e.PhoneStep=me,e.PrepaidNudge=Ce,e.QUANTAROUTE_INDIA_BOUNDARY_URL="https://maps.quantaroute.com/geojson/india.geojson",e.QUANTAROUTE_MAP_STYLES=T,e.QUANTAROUTE_MAP_STYLES_CATALOG_URL="https://maps.quantaroute.com/styles.json",e.QUANTAROUTE_MAP_STYLE_DARK_URL=L,e.QUANTAROUTE_MAP_STYLE_LIGHT_URL=S,e.QUANTAROUTE_MAP_STYLE_URL=E,e.SavedAddressStep=Ne,e.autocompleteAddress=k,e.captureUtmFromUrl=Ae,e.checkCodEligibility=Y,e.checkServiceability=ee,e.couldBeDigiPinInput=N,e.createAddress=z,e.createPaymentOrder=te,e.default=Me,e.deleteAddress=V,e.detectDeviceType=Pe,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(()=>({}))
321
- 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=ae,e.formatDigiPin=h,e.getDigiPin=m,e.getExternalMapRuntime=B,e.getLatLngFromDigiPin=y,e.getWebDeviceContext=Ie,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
327
+ return-1===t?0:t}(ae,G,ee),ar=function(e,r){return"none"===e?r?3:2:r?6:5}(G,ee),tr="payment"===ae?"payment":"phone"===ae||"otp"===ae||"email"===ae||"email-otp"===ae?"auth":"address",ir=(null==m?void 0:m.auth)??("email"===G?"Email":"Mobile"),or=[..."none"===G?[]:[{id:"auth",label:ir,status:"auth"===tr?"active":"complete"}],{id:"address",label:(null==m?void 0:m.address)??"Address",status:"address"===tr?"active":"payment"===tr?"complete":"pending"},...ee?[{id:"payment",label:(null==m?void 0:m.payment)??"Pay",status:"payment"===tr?"active":"pending"}]:[]]
328
+ return r.jsxs("div",{className:`qr-checkout qr-checkout--${s} qr-checkout--mobile-${p} ${d}`,style:Ze,"data-testid":"quantaroute-checkout",children:["done"!==ae&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"qr-header",children:[r.jsxs("div",{className:"qr-header__brand",children:[C?r.jsx("img",{src:C,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:ar+1},(e,r)=>r)
329
+ return r.jsx("div",{className:"qr-progress",role:"progressbar","aria-valuenow":nr+1,"aria-valuemin":1,"aria-valuemax":ar+1,"aria-label":`Step ${nr+1} of ${ar+1}`,children:e.map(e=>r.jsxs(n.Fragment,{children:[r.jsx("div",{className:"qr-progress__dot"+(nr>=e?" qr-progress__dot--active":"")}),e<ar&&r.jsx("div",{className:"qr-progress__line"+(nr>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:or.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<or.length-1?r.jsx("span",{className:"qr-mobile-stepper__rail","aria-hidden":"true"}):null]},e.id))})}),x?r.jsx("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:x}):null,Ne?r.jsxs("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[Ne.banner_copy,Ne.banner_cta_url?r.jsxs(r.Fragment,{children:[" ",r.jsx("a",{href:Ne.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===ae&&O&&r.jsx(Ie,{onOtpSent:(e,r)=>{ye(e),ge(Boolean(null==r?void 0:r.reused)),Ke({type:"email_otp_sent",step:"email-otp",mobile:e}),le("email-otp")},onSkip:Ye,functionBaseUrl:N,merchantId:w}),"email-otp"===ae&&O&&me&&r.jsx(Ae,{email:me,codeReused:ve,onVerified:(e,r,n)=>{pe({mobile:me,sessionToken:e,sessionId:n??"",buyerId:r}),Ke({type:"email_verified",step:"saved",buyerId:r,sessionId:n}),le("saved")},onBack:rr,functionBaseUrl:N,merchantId:w,sessionContext:Ve}),"phone"===ae&&q&&r.jsx(be,{onOtpSent:e=>{pe(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),Ke({type:"otp_sent",step:"otp",mobile:e}),le("otp")},onSkip:Ye,functionBaseUrl:N,merchantId:w}),"otp"===ae&&he&&r.jsx(_e,{mobile:he.mobile,onVerified:(e,r,n)=>{pe({mobile:(null==he?void 0:he.mobile)??"",sessionToken:e,sessionId:n??"",buyerId:r}),Ke({type:"phone_verified",step:"saved",buyerId:r,sessionId:n}),le("saved")},onBack:rr,functionBaseUrl:N,merchantId:w,sessionContext:Ve}),"saved"===ae&&(null==he?void 0:he.sessionToken)&&r.jsx(xe,{sessionToken:he.sessionToken,functionBaseUrl:N,merchantId:w,onSelectAddress:async e=>{if(null==he?void 0:he.sessionToken){try{await Q(Je,he.sessionToken,e.id)}catch(e){return void(null==i||i(e instanceof Error?e:new Error("Failed to select address.")))}if(!e.digipin)return $e(e),Ke({type:"saved_address_selected",step:"verify-address",buyerId:he.buyerId}),void le("verify-address")
330
+ Ke({type:"saved_address_selected",step:ee?"payment":"done",buyerId:he.buyerId,digipin:e.digipin}),await er(function(e){var r
331
+ 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:()=>{$e(null),de(null),le("map")}}),"verify-address"===ae&&Oe&&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(j,{onLocationConfirm:Xe,defaultLat:Oe.lat??o,defaultLng:Oe.lng??l,mapHeight:u,theme:s,indiaBoundaryUrl:y,enableSearch:f,apiKey:e,apiBaseUrl:a,brandColor:k,mapStyle:b,mapTheme:v,embedMode:_,mapsKey:g})]}),"map"===ae&&r.jsx(j,{onLocationConfirm:Xe,defaultLat:o,defaultLng:l,mapHeight:u,theme:s,indiaBoundaryUrl:y,enableSearch:f,apiKey:e,apiBaseUrl:a,brandColor:k,mapStyle:b,mapTheme:v,embedMode:_,mapsKey:g}),"form"===ae&&se&&r.jsx(fe,{digipin:se.digipin,lat:se.lat,lng:se.lng,apiKey:e,apiBaseUrl:a,onAddressComplete:async e=>{if(Oe&&(null==he?void 0:he.sessionToken))try{await Z(Je,he.sessionToken,Oe.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})
332
+ const r={...e,addressId:Oe.id}
333
+ $e(null),await er(r,{skipCreate:!0})}catch(e){null==i||i(e instanceof Error?e:new Error("Failed to verify delivery pin."))}else await er(e)},onBack:rr,onError:i,theme:s,checkoutConfig:Je,serviceabilitySessionToken:He,enableServiceabilityCheck:L,showIndiaPostDeliveryWarning:P,serviceabilityBlockCheckout:I,initialValues:Oe?{flatNumber:Oe.flat_number,floorNumber:Oe.floor_number,buildingName:Oe.building_name,streetName:Oe.street_name,locality:Oe.locality,label:"work"===Oe.label||"other"===Oe.label?Oe.label:"home",labelText:(null==(K=Oe.label_text)?void 0:K.trim())||void 0}:void 0,submitLabel:Oe?"Confirm delivery pin":void 0}),"payment"===ae&&ee&&He&&R&&r.jsx(Pe,{checkoutConfig:Je,sessionToken:He,sessionId:null==he?void 0:he.sessionId,amountPaise:R,enableCod:S,codAllowed:qe&&!(null==Ce?void 0:Ce.interventions.includes("hide_cod")),addressRisk:Ce,theme:s,onComplete:({paymentMethod:e,razorpayOrderId:r,razorpayPaymentId:n})=>{Be(e),Ke({type:"payment_method_selected",step:"done",paymentMethod:e}),le("done"),ce&&t(ce),null==U||U({paymentMethod:e,sessionId:null==he?void 0:he.sessionId,razorpayOrderId:r,razorpayPaymentId:n})},onBack:rr,onEvent:(e,r)=>Ke({type:e,step:"payment",paymentMethod:r,buyerId:null==he?void 0:he.buyerId}),orderConfirmationUrl:J}),"done"===ae&&ce&&r.jsxs(r.Fragment,{children:[r.jsx(Re,{address:ce,onEditAddress:()=>{const e=null!==Te,r=!e&&(null==he?void 0:he.sessionToken)?"saved":X
334
+ Ke({type:"widget_reset",step:r}),e&&(pe(null),ke(null)),le(r),de(null),ue(null),Le(null),$e(null),Be(null)}}),Te?r.jsxs("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===Te?"Cash on Delivery":"online payment"]}):null,S&&w&&N&&He?r.jsxs(r.Fragment,{children:[r.jsx(Ee,{checkoutConfig:Je,sessionToken:He,pincode:ce.pincode,cartTotalPaise:B??R,theme:s,onCodAllowedChange:we}),F&&qe?r.jsx(Se,{copy:W??"Save more when you pay online — faster delivery & exclusive offers.",ctaUrl:z,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:"🇮🇳"})]})]})}
335
+ e.AddressForm=fe,e.CARTO_POSITRON_STYLE_URL="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",e.CheckoutWidget=Ue,e.CodAvailabilityBanner=Ee,e.DEFAULT_MAP_STYLE_URL=O,e.DIGIPIN_BOUNDS=i,e.EmailOtpStep=Ae,e.EmailStep=Ie,e.MapPinSelector=j,e.OPENFREEMAP_POSITRON_STYLE_URL="https://tiles.openfreemap.org/styles/positron",e.OtpStep=_e,e.PaymentStep=Pe,e.PhoneStep=be,e.PrepaidNudge=Se,e.QUANTAROUTE_INDIA_BOUNDARY_URL="https://maps.quantaroute.com/geojson/india.geojson",e.QUANTAROUTE_MAP_STYLES=T,e.QUANTAROUTE_MAP_STYLES_CATALOG_URL="https://maps.quantaroute.com/styles.json",e.QUANTAROUTE_MAP_STYLE_DARK_URL=L,e.QUANTAROUTE_MAP_STYLE_LIGHT_URL=S,e.QUANTAROUTE_MAP_STYLE_URL=E,e.SavedAddressStep=xe,e.autocompleteAddress=k,e.captureUtmFromUrl=De,e.checkCodEligibility=re,e.checkServiceability=ae,e.couldBeDigiPinInput=N,e.createAddress=H,e.createPaymentOrder=le,e.default=Ue,e.deleteAddress=K,e.detectDeviceType=Oe,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(()=>({}))
336
+ 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=oe,e.formatDigiPin=h,e.getDigiPin=m,e.getExternalMapRuntime=M,e.getLatLngFromDigiPin=y,e.getWebDeviceContext=Me,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
322
337
  if(!p(e))return!1
323
- try{return y(e),!0}catch{return!1}},e.isWithinIndia=f,e.listAddresses=W,e.logFunnelEvent=re,e.looksLikeDigiPin=w,e.lookupLocation=_,e.normalizeDigiPinInput=c,e.notifyAddressCompleted=K,e.notifySessionAbandoned=ne,e.pincodeHasDeliveryOffice=q,e.recordCodPayment=oe,e.resolveQuantaRouteMapStyle=P,e.reverseGeocode=C,e.scoreAddressRisk=X,e.selectAddress=H,e.sendEmailOtp=Q,e.sendOtp=R,e.setDefaultAddress=J,e.useDigiPin=function(e,r){return n.useMemo(()=>{if(!f(e,r))return null
324
- try{return m(e,r)}catch{return null}},[e,r])},e.useGeolocation=x,e.validatePincode=g,e.verifyDigipin=G,e.verifyEmailOtp=Z,e.verifyOtp=F,e.verifyPayment=ie,e.waitForExternalMapRuntime=A,Object.defineProperties(e,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})
338
+ try{return y(e),!0}catch{return!1}},e.isWithinIndia=f,e.listAddresses=J,e.logFunnelEvent=te,e.looksLikeDigiPin=w,e.lookupLocation=_,e.mapsTransformRequest=A,e.normalizeDigiPinInput=c,e.notifyAddressCompleted=Y,e.notifySessionAbandoned=ie,e.pincodeHasDeliveryOffice=q,e.recordCodPayment=de,e.resolveQuantaRouteMapStyle=P,e.reverseGeocode=C,e.scoreAddressRisk=ne,e.selectAddress=Q,e.sendEmailOtp=X,e.sendOtp=W,e.setDefaultAddress=G,e.useDigiPin=function(e,r){return n.useMemo(()=>{if(!f(e,r))return null
339
+ try{return m(e,r)}catch{return null}},[e,r])},e.useGeolocation=x,e.validatePincode=g,e.verifyDigipin=Z,e.verifyEmailOtp=ee,e.verifyOtp=z,e.verifyPayment=se,e.waitForExternalMapRuntime=$,e.withMapsKey=B,Object.defineProperties(e,{t:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})