PageSourceSearch

https://homefoodsapp.com/_next/static/chunks/0b9dde2c43658304.js

js homefoodsapp.com collected 2026-10-02 00:51:42 UTC 33,237 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,853165,662593,e=>{"use strict";var t=e.i(247167),s=e.i(843476),l=e.i(271645),a=e.i(346897),r=e.i(531278),n=e.i(37727);let o=(0,e.i(475254).default)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),i="true"===t.default.env.NEXT_PUBLIC_SKIP_GEOCODING,d={lat:37.7749,lng:-122.4194},c=[{value:"CA",label:"California"}],u=null;async function m(){return i?Promise.resolve():u||("u">typeof google&&google.maps?.places?Promise.resolve():u=new Promise((e,t)=>{let s=document.querySelector('script[src*="maps.googleapis.com"]');if(s){s.addEventListener("load",()=>e()),window.google?.maps?.places&&e();return}let l="__googleMapsCallback_"+Date.now(),a=document.createElement("script");a.src=`https://maps.googleapis.com/maps/api/js?key=AIzaSyBViaXTeSLVNrTV8WeyCL56WhypnWKcbSk&libraries=places&loading=async&callback=${l}`,a.async=!0,a.defer=!0,window[l]=()=>{delete window[l],e()},a.onerror=()=>{t(Error("Failed to load Google Maps script"))},document.head.appendChild(a)}))}function x({onPlaceSelected:e,placeholder:t="Enter your delivery address",defaultValue:u="",className:x="",size:h="default",allowClear:p=!0,showManualEntry:f=!0,mode:g}){let[b,y]=(0,l.useState)(u),[j,v]=(0,l.useState)([]),[N,w]=(0,l.useState)(!1),[k,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[P,_]=(0,l.useState)(-1),[$,L]=(0,l.useState)(null),[E,z]=(0,l.useState)(!1),[M,T]=(0,l.useState)({street:"",apt:"",city:"",state:"",zip:""}),[I,D]=(0,l.useState)(!1),F=void 0!==g,G=F?"manual"===g:E,U=(0,l.useRef)(null),q=(0,l.useRef)(null),B=(0,l.useRef)(null),K=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(i)return;let e=!0;return m().then(()=>{e&&(A(!0),U.current=new google.maps.places.AutocompleteSessionToken)}).catch(t=>{console.error("Failed to load Google Maps:",t),e&&L("Failed to load address search. Please refresh the page.")}),()=>{e=!1}},[]),(0,l.useEffect)(()=>{function e(e){K.current&&!K.current.contains(e.target)&&w(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let O=(0,l.useCallback)(async e=>{if(!e.trim())return void v([]);if(i){if(e.trim().length<3){v([]),w(!1);return}v([{placeId:"dev-fallback",description:e.trim(),mainText:e.trim(),secondaryText:"Dev mode — using fallback coordinates"}]),w(!0);return}if(!S)return void v([]);C(!0);try{let{suggestions:t}=await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:e,sessionToken:U.current||void 0,includedPrimaryTypes:["street_address","subpremise","premise","route"],includedRegionCodes:["us"]});if(t&&t.length>0){let e=t.filter(e=>e.placePrediction).map(e=>{let t=e.placePrediction;return{placeId:t.placeId,description:t.text.text,mainText:t.mainText?.text||t.text.text,secondaryText:t.secondaryText?.text||""}});v(e),w(!0)}else v([])}catch(e){console.error("Error fetching predictions:",e),v([])}finally{C(!1)}},[S]),R=(0,l.useCallback)(e=>{let t=e.target.value;if(y(t),_(-1),q.current&&clearTimeout(q.current),t.length<3){v([]),w(!1);return}q.current=setTimeout(()=>{O(t)},300)},[O]),H=(0,l.useCallback)(async t=>{if(y(t.description),w(!1),v([]),i||"dev-fallback"===t.placeId)return void e({address:t.description,...d});try{let s=new google.maps.places.Place({id:t.placeId});await s.fetchFields({fields:["formattedAddress","location"]}),U.current=new google.maps.places.AutocompleteSessionToken,s.location&&e({address:s.formattedAddress||t.description,lat:s.location.lat(),lng:s.location.lng()})}catch(e){console.error("Error fetching place details:",e),L("Could not get location details. Please try again.")}},[e]),V=(0,l.useCallback)(async()=>{let{street:t,apt:s,city:l,state:a,zip:r}=M;if(!t||!l||!a||!r)return void L("Please fill in all required fields");let n=s?`${t}, ${s}, ${l}, ${a} ${r}`:`${t}, ${l}, ${a} ${r}`;if(D(!0),L(null),i){e({address:n,...d}),D(!1),F||z(!1),y(n);return}try{await m(),new google.maps.Geocoder().geocode({address:n},(t,s)=>{if(D(!1),"OK"===s&&t?.[0]?.geometry?.location){let s=t[0].geometry.location;e({address:t[0].formatted_address||n,lat:s.lat(),lng:s.lng()}),F||z(!1),y(t[0].formatted_address||n)}})}catch{D(!1)}},[M,e,F]),X=(0,l.useCallback)(t=>{if("Enter"===t.key&&i&&b.trim().length>=3){t.preventDefault(),e({address:b.trim(),...d});return}if(N&&0!==j.length)switch(t.key){case"ArrowDown":t.preventDefault(),_(e=>e<j.length-1?e+1:0);break;case"ArrowUp":t.preventDefault(),_(e=>e>0?e-1:j.length-1);break;case"Enter":t.preventDefault(),P>=0&&j[P]&&H(j[P]);break;case"Escape":w(!1)}},[N,j,P,H,b,e]),W=(0,l.useCallback)(()=>{y(""),v([]),w(!1),L(null),B.current?.focus()},[]),Z={default:"h-12 text-base",large:"h-14 text-lg"};return G?(0,s.jsxs)("div",{className:`space-y-3 ${x}`,children:[(0,s.jsx)("input",{type:"text",value:M.street,onChange:e=>T({...M,street:e.target.value}),placeholder:"Street address *",className:"w-full h-12 px-4 roun
1ded-xl border border-neutral-200 bg-white outline-none focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100"}),(0,s.jsx)("input",{type:"text",value:M.apt,onChange:e=>T({...M,apt:e.target.value}),placeholder:"Apt, suite, unit (optional)",className:"w-full h-12 px-4 rounded-xl border border-neutral-200 bg-white outline-none focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100"}),(0,s.jsx)("input",{type:"text",value:M.city,onChange:e=>T({...M,city:e.target.value}),placeholder:"City *",className:"w-full h-12 px-4 rounded-xl border border-neutral-200 bg-white outline-none focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100"}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsxs)("select",{value:M.state,onChange:e=>T({...M,state:e.target.value}),className:"flex-1 h-12 px-4 rounded-xl border border-neutral-200 bg-white outline-none focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100",children:[(0,s.jsx)("option",{value:"",children:"State *"}),c.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}),(0,s.jsx)("input",{type:"text",value:M.zip,onChange:e=>T({...M,zip:e.target.value}),placeholder:"ZIP *",maxLength:10,className:"w-32 h-12 px-4 rounded-xl border border-neutral-200 bg-white outline-none focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100"})]}),$&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:$}),(0,s.jsx)("button",{type:"button",onClick:V,disabled:I,className:"w-full h-12 rounded-xl bg-neutral-900 text-white font-medium hover:bg-neutral-800 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:I?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Loader2,{className:"h-4 w-4 animate-spin"}),"Verifying..."]}):"Confirm address"})]}):S||$||i?$&&!G?(0,s.jsxs)("div",{className:`space-y-2 ${x}`,children:[(0,s.jsx)("div",{className:`flex items-center gap-3 rounded-full border border-red-200 bg-red-50 px-4 ${Z[h]}`,children:(0,s.jsx)("span",{className:"text-sm text-red-500",children:$})}),f&&!F&&(0,s.jsx)("button",{type:"button",onClick:()=>{L(null),z(!0)},className:"text-sm text-neutral-500 hover:text-neutral-700",children:"Enter address manually"})]}):(0,s.jsxs)("div",{ref:K,className:`relative ${x}`,children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(a.MapPin,{className:"absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-neutral-400 pointer-events-none"}),(0,s.jsx)("input",{ref:B,type:"text",value:b,onChange:R,onKeyDown:X,onFocus:()=>j.length>0&&w(!0),placeholder:t,className:`w-full rounded-full border border-neutral-200 bg-white pl-12 pr-10 outline-none transition-all duration-200 placeholder:text-neutral-400 focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100 ${Z[h]}`,autoComplete:"off"}),k&&(0,s.jsx)(r.Loader2,{className:"absolute right-4 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin text-neutral-400"}),!k&&b&&p&&(0,s.jsx)("button",{type:"button",onClick:W,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full p-1 text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",children:(0,s.jsx)(n.X,{className:"h-4 w-4"})}),!k&&b&&!p&&(0,s.jsx)(o,{className:"absolute right-4 top-1/2 h-4 w-4 -translate-y-1/2 text-neutral-400"})]}),f&&!F&&!b&&(0,s.jsx)("button",{type:"button",onClick:()=>z(!0),className:"mt-2 text-sm text-neutral-500 hover:text-neutral-700",children:"Enter address manually"}),N&&j.length>0&&(0,s.jsx)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white rounded-2xl border border-neutral-200 shadow-xl z-100 max-h-[300px] overflow-y-auto",children:(0,s.jsx)("ul",{className:"py-2",children:j.map((e,t)=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",onClick:()=>H(e),onMouseEnter:()=>_(t),className:`w-full px-4 py-3 text-left flex items-start gap-3 transition-colors ${t===P?"bg-neutral-50":"hover:bg-neutral-50"}`,children:[(0,s.jsx)(a.MapPin,{className:"h-5 w-5 text-neutral-400 shrink-0 mt-0.5"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"font-medium text-neutral-900 truncate",children:e.mainText}),e.secondaryText&&(0,s.jsx)("div",{className:"text-sm text-neutral-500 truncate",children:e.secondaryText})]})]})},e.placeId))})})]}):(0,s.jsxs)("div",{className:`flex items-center gap-3 rounded-full border border-neutral-200 bg-white px-4 ${Z[h]} ${x}
1`,children:[(0,s.jsx)(r.Loader2,{className:"h-5 w-5 animate-spin text-neutral-400"}),(0,s.jsx)("span",{className:"text-neutral-400",children:"Loading..."})]})}function h(){let[e,t]=(0,l.useState)(!1),[s,a]=(0,l.useState)(null);return{getCurrentLocation:(0,l.useCallback)(()=>new Promise((e,s)=>{navigator.geolocation?(t(!0),a(null),navigator.geolocation.getCurrentPosition(s=>{t(!1),e({lat:s.coords.latitude,lng:s.coords.longitude})},e=>{t(!1);let l=1===e.code?"Location access denied. Please enable location permissions.":"Unable to get your location. Please try again.";a(l),s(Error(l))},{enableHighAccuracy:!0,timeout:1e4,maximumAge:3e5})):s(Error("Geolocation is not supported by your browser"))}),[]),isLoading:e,error:s}}async function p(e,t){if(i)return`Location (${e.toFixed(4)}, ${t.toFixed(4)})`;await m();let s=new google.maps.Geocoder;return new Promise((l,a)=>{s.geocode({location:{lat:e,lng:t}},(e,t)=>{"OK"===t&&e?.[0]?l(e[0].formatted_address):a(Error("Unable to get address from coordinates"))})})}function f(e){let t=[];e.street&&t.push(e.street),e.street2&&t.push(e.street2);let s=[];return e.city&&s.push(e.city),e.state&&s.push(e.state),e.zip&&s.push(e.zip),s.length>0&&t.push(s.join(", ")),t.join(", ")}function g(e){let t,s;return e.full_name?e.full_name:(t=e.street||"",s=e.city||"",t&&s?`${t}, ${s}`:t||s||"No address")}async function b(e){if(i)return d;let t=f(e);return await m(),new Promise((e,s)=>{new google.maps.Geocoder().geocode({address:t},(t,l)=>{if("OK"===l&&t?.[0]?.geometry?.location){let s=t[0].geometry.location;e({lat:s.lat(),lng:s.lng()})}else s(Error(`Geocoding failed: ${l}`))})})}e.s(["AddressAutocomplete",()=>x,"loadGoogleMaps",()=>m,"reverseGeocode",()=>p,"useCurrentLocation",()=>h],662593),e.s(["formatAddress",()=>f,"getAddressCoordinates",()=>b,"getAddressDisplayName",()=>g],853165)},242639,e=>{"use strict";var t=e.i(843476),s=e.i(346897),l=e.i(643531),a=e.i(870273),r=e.i(323585),n=e.i(788699),o=e.i(727612),i=e.i(271645),d=e.i(853165);e.i(320305);var c=e.i(386556);function u({address:e,isSelected:u=!1,onSelect:m,onEdit:x,onDelete:h,onSetPrimary:p,showActions:f=!1,variant:g="default"}){let[b,y]=(0,i.useState)(!1),j=(0,i.useRef)(null);(0,i.useEffect)(()=>{function e(e){j.current&&!j.current.contains(e.target)&&y(!1)}if(b)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[b]);let v=()=>{m&&m(e)},N=!!m;return"compact"===g?(0,t.jsxs)("button",{type:"button",onClick:v,disabled:!N,className:`w-full flex items-center gap-3 p-3 rounded-xl text-left transition-colors ${u?"bg-neutral-100 border-2 border-neutral-900":N?"hover:bg-neutral-50 border border-neutral-200":"border border-neutral-200"}`,children:[(0,t.jsx)(s.MapPin,{className:"h-5 w-5 text-neutral-400 shrink-0"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium text-neutral-900 truncate",children:(0,d.getAddressDisplayName)(e)}),e.is_default&&(0,t.jsx)("span",{className:"shrink-0 px-1.5 py-0.5 text-xs font-medium bg-yellow-100 text-yellow-800 rounded",children:"Primary"})]}),(0,t.jsx)("p",{className:"text-sm text-neutral-500 truncate",children:(0,d.formatAddress)(e)})]}),u&&(0,t.jsx)(l.Check,{className:"h-5 w-5 text-neutral-900 shrink-0"})]}):(0,t.jsxs)("div",{onClick:v,className:`relative flex items-start gap-4 p-4 rounded-2xl transition-colors ${u?"bg-neutral-100 border-2 border-neutral-900":N?"hover:bg-neutral-50 border border-neutral-200 cursor-pointer":"border border-neutral-200"}`,children:[(0,t.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-full bg-neutral-100 flex items-center justify-center",children:(0,t.jsx)(s.MapPin,{className:"h-5 w-5 text-neutral-600"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,t.jsx)("h3",{className:"font-semibold text-neutral-900 truncate",children:(0,d.getAddressDisplayName)(e)}),e.is_default&&(0,t.jsxs)("span",{className:"shrink-0 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-yellow-100 text-yellow-800 rounded-full",children:[(0,t.jsx)(a.Star,{className:"h-3 w-3"}),"Primary"]})]}),(0,t.jsx)("p",{className:"text-sm text-neutral-600",children:e.street}),e.street2&&(0,t.jsx)("p",{className:"text-sm text-neutral-500",children:e.street2}),(0,t.jsxs)("p",{className:"text-sm text-neutral-500",children:[e.city,", ",e.state," ",e.zip]})]}),u&&(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(l.Check,{className:"h-5 w-5 text-neutral-900"})}),f&&(0,t.jsxs)("div",{ref:j,className:"relative shrink-0",children:[(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),y(!b)},className:"p-2 rounded-full hover:bg-neutral-200 transition-colors",children:(0,t.jsx)(r.MoreVertical,{className:"h-5 w-5 text-neutral-500"})}),b&&(0,t.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white rounded-xl border border-neutral-200 shadow-lg overflow-hidden z-50",children:[x&&(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),y(!1),x?.(e)},className:"w-full flex items-center gap-3 px-4 py-3 text-left text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[(0,t.jsx)(n.Pencil,{className:"h-4 w-4"}),"Edit address"]}),p&&!e.is_default&&(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),y(!1),p?.(e)},className:"w-full flex items-center gap-3 px-4 py-3 text-left text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[(0,t.jsx)(a.Star,{className:"h-4 w-4"}),"Set as primary"]}),h&&(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),y(!1),c.posthog.capture("account:delete_address_button_click",{address_id:e.id}),h?.(e)},className:"w-full flex items-center gap-3 px-4 py-3 text-left text-sm text-red-600 hover:bg-red-50 transition-colors",children:[(0,t.jsx)(o.Trash2,{className:"h-4 w-4"}),"Delete"]})]})]})]})}e.s(["AddressCard",()=>u])},734858,e=>{"use strict";let t=(0,e.i(475254).default)("navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);e.s(["Navigation",()=>t],734858)},501082,896730,916766,774539,e=>{"use strict";var t=e.i(242639),s=e.i(843476),l=e.i(271645),a=e.i(912598),r=e.i(37727),n=e.i(107233),o=e.i(531278),i=e.i(727612),d=e.i(734858);e.i(28856);var c=e.i(767507),u=e.i(291121);e.i(468695);var m=e.i(107248),x=e.i(346897);let h=(0,e.i(475254).default)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);var p=e.i(871689),f=e.i(662593);let g=[{value:"CA",label:"California"}];function b({isOpen:e,onClose:t,onSaved:a,addressToEdit:n=null,initialData:i,showBackButton:d=!1,isOnlyAddress:c=!1}){let u=!!n,[b,y]=(0,l.useState)(u?"manual":"autocomplete"),[j,v]=(0,l.useState)(u),[N,w]=(0,l.useState)({full_name:"",street:"",street2:"",city:"",state:"",zip:"",is_default:!1}),[k,C]=(0,l.useState)({}),S=(0,m.useCreateAddress)(),A=(0,m.useUpdateAddress)(),P=S.isPending||A.isPending;(0,l.useEffect)(()=>{n?(w({full_name:n.full_name||"",street:n.street||"",street2:n.street2||"",city:n.city||"",state:n.state||"",zip:n.zip||"",is_default:n.is_default||!1}),v(!0),y("manual")):i?(w(e=>({...e,...i})),i.street&&(v(!0),y("manual"))):(w({full_name:"",street:"",street2:"",city:"",state:"",zip:"",is_default:!1}),v(!1),y("autocomplete"),C({}))},[n,i]);let _=(0,l.useCallback)(e=>{let t=e.split(",").map(e=>e.trim());if(t.length>
1=3){let e=t[0],s=t[1],l=t[2].split(" ").filter(Boolean),a="",r="";if(l.length>=2){let e=l[l.length-1];/^\d{5}(-\d{4})?$/.test(e)?(r=e,a=l.slice(0,-1).join(" ")):a=l.join(" ")}else 1===l.length&&(a=l[0]);return{street:e,city:s,state:a,zip:r}}return{street:e}},[]),$=(0,l.useCallback)(e=>{let t=_(e.address);w(e=>({...e,...t})),v(!0),y("manual")},[_]),L=(0,l.useCallback)(()=>{let e={};return N.full_name.trim()||(e.full_name="Address label is required"),N.street.trim()||(e.street="Street address is required"),N.city.trim()||(e.city="City is required"),N.state||(e.state="State is required"),N.zip.trim()?/^\d{5}(-\d{4})?$/.test(N.zip)||(e.zip="Invalid ZIP code"):e.zip="ZIP code is required",C(e),0===Object.keys(e).length},[N]),E=(0,l.useCallback)(async()=>{if(!L())return;let e=!!n?.is_default||N.is_default,s={full_name:N.full_name.trim(),street:N.street.trim(),street2:N.street2.trim()||void 0,city:N.city.trim(),state:N.state,zip:N.zip.trim(),country:"US",is_default:e};try{let e;e=u&&n?await A.mutateAsync({id:n.id,payload:s}):await S.mutateAsync(s),a?.(e),t()}catch(e){C({full_name:e?.response?.data?.non_field_errors?.[0]||e?.message||"Failed to save address. Please try again."})}},[L,N,u,n,A,S,a,t]),z=(0,l.useCallback)((e,t)=>{w(s=>({...s,[e]:t})),k[e]&&C(t=>({...t,[e]:void 0}))},[k]);if(!e)return null;let M="manual"===b||j;return(0,s.jsxs)("div",{className:"fixed inset-0 z-60 flex items-start justify-center pt-12 sm:pt-16 px-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:t}),(0,s.jsxs)("div",{className:`relative w-full max-w-lg bg-white rounded-2xl shadow-xl flex flex-col ${M?"max-h-[90vh] overflow-hidden":"max-h-[80vh]"}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-neutral-100",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[d&&(0,s.jsx)("button",{onClick:t,className:"p-2 -ml-2 rounded-full hover:bg-neutral-100 transition-colors",children:(0,s.jsx)(p.ArrowLeft,{className:"h-5 w-5 text-neutral-500"})}),(0,s.jsx)("h2",{className:"text-lg font-semibold text-neutral-900",children:u?"Edit address":"Add new address"})]}),!d&&(0,s.jsx)("button",{onClick:t,className:"p-2 rounded-full hover:bg-neutral-100 transition-colors",children:(0,s.jsx)(r.X,{className:"h-5 w-5 text-neutral-500"})})]}),(0,s.jsxs)("div",{className:`flex-1 p-4 space-y-4 ${M?"overflow-y-auto":"overflow-visible"}`,children:[!u&&!j&&(0,s.jsxs)("div",{className:"flex gap-2 p-1 bg-neutral-100 rounded-xl",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>y("autocomplete"),className:`flex-1 flex items-center justify-center gap-2 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${"autocomplete"===b?"bg-white text-neutral-900 shadow-sm":"text-neutral-600 hover:text-neutral-900"}`,children:[(0,s.jsx)(x.MapPin,{className:"h-4 w-4"}),"Search"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>y("manual"),className:`flex-1 flex items-center justify-center gap-2 py-2 px-4 rounded-lg text-sm font-medium transition-colors ${"manual"===b?"bg-white text-neutral-900 shadow-sm":"text-neutral-600 hover:text-neutral-900"}`,children:[(0,s.jsx)(h,{className:"h-4 w-4"}),"Manual"]})]}),"autocomplete"===b&&!j&&(0,s.jsxs)("div",{className:"space-y-3 min-h-[300px]",children:[(0,s.jsx)(f.AddressAutocomplete,{onPlaceSelected:$,placeholder:"Search for your address",allowClear:!0,showManualEntry:!1}),(0,s.jsx)("p",{className:"text-sm text-neutral-500 text-center",children:"Search for your address, then confirm the details"})]}),("manual"===b||j)&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-neutral-700 mb-1",children:"Address label *"}),(0,s.jsx)("input",{type:"text",value:N.full_name,onChange:e=>z("full_name",e.target.value),placeholder:"e.g., Home, Work, Mom's House",className:`w-full h-12 px-4 rounded-xl border bg-white outline-none focus:ring-2 focus:ring-neutral-100 ${k.full_name?"border-red-300 focus:border-red-400":"border-neutral-200 focus:border-neutral-400"}`}),k.full_name&&(0,s.jsx)("p",{className:"mt-1 text-sm text-red-500",children:k.full_name})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-neutral-700 mb-1",children:"Street address *"}),(0,s.jsx)("input",{type:"text",value:N.street,onChange:e=>z("street",e.target.value),placeholder:"123 Main St",className:`w-full h-12 px-4 roun
1ded-xl border bg-white outline-none focus:ring-2 focus:ring-neutral-100 ${k.street?"border-red-300 focus:border-red-400":"border-neutral-200 focus:border-neutral-400"}`}),k.street&&(0,s.jsx)("p",{className:"mt-1 text-sm text-red-500",children:k.street})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-neutral-700 mb-1",children:"Apt, suite, unit (optional)"}),(0,s.jsx)("input",{type:"text",value:N.street2,onChange:e=>z("street2",e.target.value),placeholder:"Apt 4B",className:"w-full h-12 px-4 rounded-xl border border-neutral-200 bg-white outline-none focus:border-neutral-400 focus:ring-2 focus:ring-neutral-100"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-neutral-700 mb-1",children:"City *"}),(0,s.jsx)("input",{type:"text",value:N.city,onChange:e=>z("city",e.target.value),placeholder:"San Francisco",className:`w-full h-12 px-4 rounded-xl border bg-white outline-none focus:ring-2 focus:ring-neutral-100 ${k.city?"border-red-300 focus:border-red-400":"border-neutral-200 focus:border-neutral-400"}`}),k.city&&(0,s.jsx)("p",{className:"mt-1 text-sm text-red-500",children:k.city})]}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-neutral-700 mb-1",children:"State *"}),(0,s.jsxs)("select",{value:N.state,onChange:e=>z("state",e.target.value),className:`w-full h-12 px-4 rounded-xl border bg-white outline-none focus:ring-2 focus:ring-neutral-100 ${k.state?"border-red-300 focus:border-red-400":"border-neutral-200 focus:border-neutral-400"}`,children:[(0,s.jsx)("option",{value:"",children:"Select state"}),g.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}),k.state&&(0,s.jsx)("p",{className:"mt-1 text-sm text-red-500",children:k.state})]}),(0,s.jsxs)("div",{className:"w-32",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-neutral-700 mb-1",children:"ZIP *"}),(0,s.jsx)("input",{type:"text",value:N.zip,onChange:e=>z("zip",e.target.value),placeholder:"94105",maxLength:10,className:`w-full h-12 px-4 rounded-xl border bg-white outline-none focus:ring-2 focus:ring-neutral-100 ${k.zip?"border-red-300 focus:border-red-400":"border-neutral-200 focus:border-neutral-400"}`}),k.zip&&(0,s.jsx)("p",{className:"mt-1 text-sm text-red-500",children:k.zip})]})]}),!n?.is_default&&(0,s.jsxs)("label",{className:`flex items-center gap-3 ${c?"cursor-not-allowed opacity-70":"cursor-pointer"}`,children:[(0,s.jsx)("input",{type:"checkbox",checked:N.is_default,onChange:e=>!c&&z("is_default",e.target.checked),disabled:!!c,className:"w-5 h-5 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-500"}),(0,s.jsxs)("span",{className:"text-sm text-neutral-700",children:["Set as default address",c&&(0,s.jsx)("span",{className:"block text-xs text-neutral-500 mt-0.5",children:"You must have at least one default address"})]})]})]})]}),("manual"===b||j)&&(0,s.jsx)("div",{className:"p-4 border-t border-neutral-100",children:(0,s.jsx)("button",{type:"button",onClick:E,disabled:P,className:"w-full h-12 rounded-xl bg-neutral-900 text-white font-medium hover:bg-neutral-800 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Loader2,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):u?"Save changes":"Save address"})})]})]})}function y({onPlaceSelected:e,onCurrentLocationSelected:t,placeholder:a="Enter your delivery address",size:r="default",className:n=""}){let[i,d]=(0,l.useState)("autocomplete"),[c,u]=(0,l.useState)(null),{getCurrentLocation:m,isLoading:p}=(0,f.useCurrentLocation)(),g=(0,l.useCallback)(e=>{d(e),u(null)},[]),b=(0,l.useCallback)(async()=>{try{u(null);let s=await m(),l={address:await (0,f.reverseGeocode)(s.lat,s.lng),lat:s.lat,lng:s.lng};t?t(l):e(l)}catch(e){u(e instanceof Error?e.message:"Unable to get location")}},[m,t,e]);return(0,s.jsxs)("div",{className:`space-y-4 ${n}`,children:[(0,s.jsxs)("div",{className:"flex gap-2 p-1 bg-neutral-100 rounded-full",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>g("autocomplete"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 px-4 roun
1ded-full text-sm font-medium transition-colors ${"autocomplete"===i?"bg-white text-neutral-900 shadow-sm":"text-neutral-600 hover:text-neutral-900"}`,children:[(0,s.jsx)(x.MapPin,{className:"h-4 w-4"}),"Search"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>g("manual"),className:`flex-1 flex items-center justify-center gap-2 py-2.5 px-4 rounded-full text-sm font-medium transition-colors ${"manual"===i?"bg-white text-neutral-900 shadow-sm":"text-neutral-600 hover:text-neutral-900"}`,children:[(0,s.jsx)(h,{className:"h-4 w-4"}),"Manual"]})]}),(0,s.jsx)(f.AddressAutocomplete,{mode:i,onPlaceSelected:e,placeholder:a,size:r,className:"w-full",showManualEntry:!1}),"autocomplete"===i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-4 px-4",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-neutral-200"}),(0,s.jsx)("span",{className:"text-sm text-neutral-400",children:"or"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-neutral-200"})]}),(0,s.jsx)("button",{type:"button",onClick:b,disabled:p,className:"w-full flex items-center justify-center gap-2 h-14 rounded-full border border-neutral-200 bg-white text-neutral-700 font-medium transition-all hover:bg-neutral-50 hover:border-neutral-300 disabled:opacity-50 disabled:cursor-not-allowed",children:p?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Loader2,{className:"h-5 w-5 animate-spin"}),(0,s.jsx)("span",{children:"Getting your location..."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.MapPin,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:"Use my current location"})]})})]}),c&&(0,s.jsx)("p",{className:"text-sm text-red-500 text-center",children:c})]})}e.s(["AddAddressModal",()=>b],896730),e.s(["AddressEntry",()=>y],916766);var j=e.i(853165);function v({isOpen:e,onClose:x}){let h=(0,a.useQueryClient)(),p=(0,c.useAuthStore)(e=>e.isAuthenticated),f=(0,c.useAuthStore)(e=>e.isHydrated),g=(0,u.useLocationHydrated)(),v=(0,u.useSelectedAddressId)(),N=(0,u.useAddress)(),w=(0,u.useIsLocationSet)(),k=(0,u.useLocationStore)(e=>e.setGuestLocation),C=(0,u.useLocationStore)(e=>e.setSavedAddress),S=(0,u.useLocationStore)(e=>e.setCurrentLocation),A=(0,u.useLocationStore)(e=>e.clearLocation),P=(0,l.useCallback)((e,t)=>{h.invalidateQueries({predicate:s=>{let l=s.queryKey;if("listings"===l[0]&&"list"===l[1]){let s=l[2];return s?.lat===e&&s?.long===t}if("explore"===l[0]&&"unit"===l[1]&&"listings"===l[3]){let s=l[4];return s?.lat===e&&s?.long===t}if("feed"===l[0]&&"list"===l[1]||"listings"===l[0]&&"by-ids"===l[1]){let s=l[2];return s?.lat===e&&s?.long===t}if("listings"===l[0]&&"detail"===l[1]&&"number"==typeof l[2]){let s=l[3];return s?.lat===e&&s?.long===t}return!1}})},[h]),[_,$]=(0,l.useState)("select"),[L,E]=(0,l.useState)(null),[z,M]=(0,l.useState)(null),[T,I]=(0,l.useState)(!1),[D,F]=(0,l.useState)(null),{data:G,isLoading:U}=(0,m.useAddresses)(),q=(0,l.useCallback)(async e=>{I(!0),F(null);try{let t=await (0,j.getAddressCoordinates)(e);C(e.id,{address:(0,j.formatAddress)(e),lat:t.lat,lng:t.lng}),P(t.lat,t.lng),x()}catch(e){console.error("Failed to geocode address:",e),F("Could not verify address location. Please try again.")}finally{I(!1)}},[C,P,x]),B=(0,l.useCallback)(e=>{let t=e.split(",").map(e=>e.trim()),s="",l="",a="",r="";if(t.length>=3){s=t[0],l=t[1];let e=t[2].split(" ").filter(Boolean);if(e.length>=2){let t=e[e.length-1];/^\d{5}
1(-\d{4})?$/.test(t)?(r=t,a=e.slice(0,-1).join(" ")):a=e.join(" ")}else 1===e.length&&(a=e[0])}else 2===t.length?(s=t[0],l=t[1]):s=e;return{street:s,city:l,state:a,zip:r}},[]),K=(0,l.useCallback)(e=>{p&&f?(M(B(e.address)),E(null),$("add")):(k(e),P(e.lat,e.lng),x())},[p,f,B,k,P,x]),O=(0,l.useCallback)(e=>{S(e),P(e.lat,e.lng),x()},[S,P,x]),R=(0,l.useCallback)(()=>{A()},[A]),H=(0,l.useCallback)(()=>{E(null),M(null),$("add")},[]),V=(0,l.useCallback)(()=>{$("select"),E(null),M(null)},[]),X=(0,l.useCallback)(async e=>{await q(e)},[q]),W=(0,l.useCallback)(()=>{$("select"),E(null),M(null),x()},[x]);if(!e)return null;let Z=p&&f&&G&&G.length>0,Q=p&&f&&U,Y=g&&w&&N;return"add"===_?(0,s.jsx)(b,{isOpen:!0,onClose:V,onSaved:X,addressToEdit:L,initialData:z||void 0,showBackButton:!0}):(0,s.jsxs)("div",{className:"fixed inset-0 z-100 flex items-start justify-center px-4 pt-12 sm:pt-20",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:W}),(0,s.jsxs)("div",{className:"relative flex w-full max-w-lg flex-col overflow-hidden rounded-2xl bg-white shadow-xl",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-neutral-100 p-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-neutral-900",children:"Delivery address"}),(0,s.jsx)("button",{onClick:W,className:"rounded-full p-2 transition-colors hover:bg-neutral-100",children:(0,s.jsx)(r.X,{className:"h-5 w-5 text-neutral-500"})})]}),(0,s.jsx)("div",{className:"relative z-10 border-b border-neutral-100 bg-white p-4",children:(0,s.jsx)(y,{onPlaceSelected:K,onCurrentLocationSelected:O,placeholder:"Search for address"})}),(0,s.jsxs)("div",{className:"space-y-4 overflow-y-auto p-4",children:[D&&(0,s.jsx)("p",{className:"text-center text-sm text-red-500",children:D}),Y&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-neutral-500",children:"Current location"}),(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-xl border-2 border-primary bg-primary/5",children:[(0,s.jsx)("div",{className:"p-2 rounded-full bg-primary/10",children:(0,s.jsx)(d.Navigation,{className:"h-4 w-4 text-primary"})}),(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)("p",{className:"text-sm font-medium text-neutral-900 truncate",children:N})}),(0,s.jsx)("button",{type:"button",onClick:R,className:"p-2 rounded-full hover:bg-red-50 text-neutral-400 hover:text-red-500 transition-colors",title:"Clear location",children:(0,s.jsx)(i.Trash2,{className:"h-4 w-4"})})]})]}),Q&&(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)(o.Loader2,{className:"h-6 w-6 animate-spin text-neutral-400"})}),Z&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-neutral-500",children:"Saved addresses"}),(0,s.jsxs)("button",{type:"button",onClick:H,className:"text-sm font-medium text-neutral-700 hover:text-neutral-900 flex items-center gap-1",children:[(0,s.jsx)(n.Plus,{className:"h-4 w-4"}),"Add new"]})]}),T&&(0,s.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,s.jsx)(o.Loader2,{className:"h-5 w-5 animate-spin text-neutral-400 mr-2"}),(0,s.jsx)("span",{className:"text-sm text-neutral-500",children:"Setting location..."})]}),(0,s.jsx)("div",{className:"space-y-2",children:G.map(e=>(0,s.jsx)(t.AddressCard,{address:e,isSelected:v===e.id,onSelect:q,variant:"compact"},e.id))})]}),p&&f&&!Q&&G?.length===0&&(0,s.jsxs)("button",{type:"button",onClick:H,className:"w-full flex items-center justify-center gap-2 p-3 rounded-xl border border-dashed border-neutral-300 text-neutral-600 hover:bg-neutral-50 hover:border-neutral-400 transition-colors",children:[(0,s.jsx)(n.Plus,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:"Save this address to your account"})]})]})]})]})}e.s(["AddressSelectModal",()=>v],774539),e.s([],501082)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.