PageSourceSearch

https://www.goodamerican.com/cdn/shopifycloud/checkout-web/assets/c1/d22d2b80.CrBDr4H-.js

js goodamerican.com collected 2026-10-02 02:50:09 UTC 11,872 bytes, 1 lines download raw bytes

1import{q as M,T as w,l as D,A as K,h as G}from"./2c1ab0fe.BqEHHmaW.js";import{O as ve,dk as Ee,b2 as x,dl as Me,dm as ee,ab as _e,bZ as De,dn as me,G as Q,dp as he,dq as Oe}from"./4c290a1e.FJVsH4yi.js";import{s as Ue}from"./74835653.BtNhMTqJ.js";import{u as Le}from"./3ca8ef7e.D9Nch_50.js";import{ci as $e,e0 as Ge,e1 as ke,p as te,cS as Ne}from"./164ad2e3.BA-GikTU.js";import{A as Be}from"./60a453ce.BClq-svk.js";function Ve(e){const{observability:t}=ve(),{geolocation:s}=$e();return M(async(n,u,d)=>{const o=await e(n,u,d);return t.histogram({name:"prediction_duration",value:o.duration.end-o.duration.start,attributes:{buyerCountry:s.country.code}}),o.data},[e,t,s.country.code])}function we(e){return new Promise((t,s)=>{Ge(e.approvalScopes,Be.CustomerPersonalData)||s(new Ee(`Extension ${e.id} at target \`${e.extensionPoint.target}\` is missing required access to read customer personal data.`)),t()})}function xe(e,t,s){switch(!0){case e instanceof Ee:Ae(e,t);break;case e instanceof x:if(t.type==="persisted")Ae(e,t);else{const{extensionPoint:{target:n}}=t;s(new x(`[${n}] ${e.message}`))}break;default:s(e)}}function Ae(e,t){const s=`[${t.extensionPoint.target}] ${e.name}: ${e.message}`;console.error(s)}function Qe(e){if(typeof e!="object")throw new x(`formattedAddress must be an object: received type ${typeof e}`);const t=Pe(e);if(t.length)throw new x(t.join("; "));return e}function je(e){const t=[];if(!Array.isArray(e))throw new x("An array of address suggestions must be defined");const s=e.slice(0,5);for(const[n,{id:u,label:d,matchedSubstrings:o,formattedAddress:r}]of s.entries()){if(q(d)||t.push(`label is required and must be a non-empty string: received ${typeof d} in suggestions[${n}]`),u&&!q(u)&&t.push(`id must be a non-empty string: received ${typeof u} in suggestions[${n}]`),o)if(Array.isArray(o))for(const[p,{offset:a,length:c}]of o.entries())typeof a!="number"&&t.push(`offset must be a number: received type ${typeof a} in matchedSubstrings[${p}] for suggestions[${n}]`),typeof c!="number"&&t.push(`length must be a number: received type ${typeof c} in matchedSubstrings[${p}] for suggestions[${n}]`);else t.push(`matchedSubstrings must be an array: received type ${typeof o} in suggestions[${n}]`);if(r)if(typeof r=="object"){const p=Pe(r);for(const a of p)t.push(`${a} for suggestions[${n}]`)}else t.push(`formattedAddress must be an object: received type ${typeof r} in suggestions[${n}]`);if(t.length)throw new x(t.join("; "))}return s}function Pe(e){const t=[],{address1:s,address2:n,city:u,company:d,provinceCode:o,zip:r,countryCode:p,latitude:a,longitude:c}=e;return s&&!q(s)&&t.push(`address1 must be a non-empty string: received type ${typeof s} in formattedAddress`),n&&!q(n)&&t.push(`address2 must be a non-empty string: received type ${typeof n} in formattedAddress`),u&&!q(u)&&t.push(`city must be a non-empty string: received type ${typeof u} in formattedAddress`),d&&!q(d)&&t.push(`company must be a non-empty string: received type ${typeof d} in formattedAddress`),o&&!q(o)&&t.push(`provinceCode must be a non-empty string: received type ${typeof o} in formattedAddress`),r&&!q(r)&&t.push(`zip must be a non-empty string: received type ${typeof r} in formattedAddress`),p&&!Me(p)&&t.push(`countryCode must be a valid alpha-2 country code: received "${p}" in formattedAddress`),a&&(typeof a!="number"?t.push(`latitude must be a number: received type ${typeof a} in formattedAddress`):(a<-90||a>90)&&t.push(`latitude must be between -90 and 90: received ${a} in formattedAddress`)),c&&(typeof c!="number"?t.push(`longitude must be a number: received type ${typeof c} in formattedAddress`):(c<-180||c>180)&&t.push(`longitude must be between -180 and 180: received ${c} in formattedAddress`)),t}function q(e){return typeof e=="string"||e instanceof String?e.trim().length>0:!1}function Xe(e){const t=ke(e),s=w(()=>e[0],[e]),n=te("purchase.address-autocomplete.suggest"),u=w(()=>n.length>0,[n]);return M(d=>s?new Promise((o,r)=>{We(u).then(()=>we(s)).then(()=>{const{internalId:p,...a}=d;return t({target:{selectedSuggestion:a}})}).then(p=>{const a=p?.formattedAddress||{};o({formattedAddress:Qe(a)})}).catch(p=>{xe(p,s,r),o({formattedAddress:{}})})}):Promise.resolve({formattedAddress:{}}),[t,s,u])}function We(e){return new Promise((t,s)=>{if(e)t();else{const n="A purchase.address-autocomplete.suggest extension is required for a purchase.address-autocomplete.format-suggestion extension";s(new x(n))}})}function Ye(e){return e.map((t,s)=>{const{id:n,label:u,matchedSubstrings:d,formattedAddress:o}=t;return{internalId:`extension-suggestion-${s}`,matchedSubstrings:Ze(d),label:u,...n&&{id:n},...o&&{formattedAddress:o}}})}function Ze(e){return e?.length?e.sort(He):[{offset:0,length:0}]}function He(e,t){return e.offset-t.offset}function Je(e){const t=ke(e),s=w(()=>e[0],[e]);return M((n,u)=>s?new Promise((d,o)=>{u.aborted&&o(new ee(u.reason)),we(s).then(()=>t({signal:u,target:{...n}})).then(r=>r?.suggestions||[]).then(r=>je(r)).then(r=>Ye(r)).then(r=>d(r)).catch(r=>{xe(r,s,o),d([])}),u.addEventListener("abort",()=>{o(new ee(u.reason))})}):Promise.resolve([]),[t,s])}const Ke=300,ye="address_clobber",be=20;function $(e){try{return e()}catch{return}}function et({addressType:e,field:t,log:s,now:n=Date.now}){let u=0,d=0,o=0,r=0,p,a,c=!1,N=be,E=be;const C=(h,A)=>s(ye,`${ye}: ${h}`,{kind:h,addressType:e??"unknown",field:t??"unknown",...A});return{recordQuery(h){h!==p&&(p=h,r+=1)},resetPredictionContext(){a=void 0,c=!1},startPredictionRequest(){return[r,++u,n()]},recordPredictionResponse([h,A,_],O){const T=A<d,P=d;d=Math.max(d,A),a=h,c=T,!(!T||N===0)&&(N-=1,C("prediction-race",{latestAppliedPredictionGeneration:P,predictionCount:O,queryChangedSinceRequest:h!==r,requestGeneration:A,responseAgeMs:Math.max(0,n()-_)}))},startAddressRequest(){const h=c||a!==void 0&&a!==r;return[r,++o,h,n()]},recordAddressResponse([h,A,_,O]){const T=A!==o,P=h!==r;!T&&!P&&!_||E===0||(E-=1,C("address-race",{latestRequestGeneration:o,newerSelectionStarted:T,queryChangedSinceSelection:P,requestGeneration:A,responseAgeMs:Math.max(0,n()-O),selectedFromStalePredictionResponse:_}))}}}function ut({addressType:e,countryCode:t,field:s,initialAddressQuery:n="",provider:u="autocomplete-service",allowAllCountries:d}){const{i18n:{locale:o},observability:r,userEvents:p,shop:a,source:c,checkout:{address:N}}=ve(),{id:E}=a,[C,h]=D(n),[A,_]=D(C),[O,T]=D(!1),[P,F]=D([]),[se,X]=D([]),W=K(!1),[z,Re]=D(Se(c.sourceId)
1),{geolocation:y}=$e(),{search:Ie,fetchAddress:ne}=Le(),R=Ne(),{details:oe}=_e(t),B=De(),re=N.extendedAddressMode.get(t)!==null,ie=e==="pickup"?"google":void 0,ce=K(void 0);ce.current??=et({addressType:e,field:s,log:(l,g,k)=>r.log(l,g,k)});const b=ce.current,ue=te("purchase.address-autocomplete.suggest"),V=w(()=>ue.map(me),[ue]),qe=Je(V),de=w(()=>V.length>0,[V]),ae=te("purchase.address-autocomplete.format-suggestion"),Y=w(()=>ae.map(me),[ae]),pe=Xe(Y),le=w(()=>Y.length>0,[Y]),fe=M((l,g,k,m)=>{const S=B.value.defaultAttributes?.uniqToken||"";p.monorailEvent({schemaId:"checkout_autocomplete_suggestion/5.1",payload:{shopId:parseInt(Q(E),10),checkoutToken:c.checkoutSessionIdentifier||"",uniqueToken:S,provider:g[0]?.completionService??"",context:l==="shipping"?"Shipping address":"Billing address",territoryCode:t??y.country.code,locale:o,query:k,sessionToken:z,requestProvider:m,requestLatitude:y.coordinates?.latitude,requestLongitude:y.coordinates?.longitude,addressIds:g.map(v=>v.addressId)}})},[t,y.country.code,o,z,E,c.checkoutSessionIdentifier,B.value.defaultAttributes?.uniqToken,p,y.coordinates]),Z=w(()=>de&&s&&j(e),[s,e,de]),H=w(()=>Z||d||Ue(t||y.country.code),[d,t,y.country.code,Z]);G(()=>{const l=setTimeout(()=>{R&&_(C)},Ke);return()=>{clearTimeout(l)}},[R,C]),G(()=>{$(()=>b.recordQuery(n)),h(n)},[n,b]),G(()=>{H||F([])},[H]);const J=K(t);G(()=>{J.current!==t&&J.current!==void 0&&(F([]),X([]),W.current=!1),J.current=t},[t]);const Ce=Ve(Ie);G(()=>{let l=!1;async function g(m){try{if(!m||typeof m!="string"||m.length<=1){$(()=>b.resetPredictionContext()),F([]);return}const S=$(()=>b.startPredictionRequest()),v=await Ce(m,{locale:o,countryCode:t??y.country.code,location:y.coordinates,requestToken:z,shopId:Q(E),sourceId:c.sourceId||"",checkoutSessionIdentifier:c.checkoutSessionIdentifier||""},ie);R.current&&!l&&(S&&$(()=>b.recordPredictionResponse(S,v.length)),F(v),!W.current&&j(e)&&(fe(e,v,m,ie),W.current=!0))}catch(S){console.warn(`Unable to fetch predictions: ${S}`),R.current&&!l&&F([])}}async function k({query:m,field:S,signal:v}){function U(i){return i.map(({label:f,matchedSubstrings:I,internalId:ze})=>({addressId:ze,completionService:"AUTOCOMPLETE_EXTENSION",description:f,matchedSubstrings:I}))}function L(i){switch(i){case"address1":case"streetName":return"address1";case"postalCode":return"zip";default:{const f=i;throw new he(`Unknown Address Autocomplete field: ${f}`)}}}if(!m||typeof m!="string"||m.length<=1){$(()=>b.resetPredictionContext()),X([]),F([]);return}try{const i=$(()=>b.startPredictionRequest()),f=await qe({value:m,field:L(S),selectedCountryCode:t},v);R.current&&!l&&(i&&$(()=>b.recordPredictionResponse(i,f.length)),X(f),F(U(f)))}catch(i){if(i instanceof he&&r.error(i),V[0].type==="local")if(i instanceof ee)console.warn("AddressAutocompleteSignalAbortedError: ",i.message);else throw i}}if(H&&O)if(Z&&j(e)){const m=new AbortController;return k({query:A,field:s,signal:m.signal}),()=>{l=!0,m.abort("The query was debounced")}}else g(A);return()=>{l=!0}},[t,A,o,z,fe]);const ge=M((l,g,k,m,S)=>{const v=oe?.zones.find(i=>i.code===g.zoneCode)?.name||void 0,U=B.value.defaultAttributes?.uniqToken,L=k.findIndex(i=>i.addressId===l)+1;p.monorailEvent({schemaId:"checkout_autocomplete_selection/6.2",payload:{shopId:parseInt(Q(E),10),checkoutToken:c.checkoutSessionIdentifier||"",uniqueToken:U,address1:g.address1,address2:g.address2,city:g.city,zone:v,latitude:g.coordinates?.latitude,longitude:g.coordinates?.longitude,zip:g.postalCode,territoryCode:t??y.country.code,position:L,query:A,context:m==="shipping"?"Shipping address":"Billing address",locale:o,sessionToken:S,requestLatitude:y.coordinates?.latitude,requestLongitude:y.coordinates?.longitude}})},[oe,B.value.defaultAttributes?.uniqToken,E,c.checkoutSessionIdentifier,t,y.country.code,y.coordinates,A,o,p]),Te=M(async(l,g,k,m)=>{const S=$(()=>b.startAddressRequest());function v(i){const f=se.find(I=>I.internalId===i);return f||r.error(new Oe("Could not find selected suggestion in extension suggestions.")),f}async function U(i){if(le&&i)return(await pe(i)).formattedAddress;const f=new x("The address fields could not be auto-populated. Please provide a `formattedAddress` for the selected suggestion or implement the `purchase.address-autocomplete.format-suggestion` extension.");console.error(`${f.name}: ${f.message}`)}async function L(i){const f=v(i),I=f?.formattedAddress||await U(f);return tt(I)}try{let i,f;if(g==="AUTOCOMPLETE_EXTENSION")i=await L(l);else{const I=z;i=await ne(l,{locale:o,requestToken:z,completionService:g,shopId:Q(E),sourceId:c.sourceId||"",checkoutSessionIdentifier:c.checkoutSessionIdentifier||"",extendedFields:!k&&re}
1),f=I,R.current&&(Re(Se(c.sourceId)),j(e)&&ge(l,i,P,e,I))}R.current&&(S&&$(()=>b.recordAddressResponse(S)),m(i,f))}catch(i){if(i instanceof x)throw i;console.warn(`Unable to select prediction: ${i}`)}},[o,z,E,c.sourceId,c.checkoutSessionIdentifier,ne,R,e,ge,P,le,se,pe,r,re,b]),Fe=M((l,g=!0)=>{$(()=>b.recordQuery(l)),h(l),T(g)},[b]);return{value:C,debouncedValue:A,setValue:Fe,predictions:P,selectPrediction:Te,provider:u}}function Se(e){return`${e}-${Date.now()}`}function tt(e){return{address1:e?.address1,address2:e?.address2,city:e?.city,company:e?.company,zoneCode:e?.provinceCode,postalCode:e?.zip,coordinates:e?.latitude&&e?.longitude?{latitude:e.latitude,longitude:e.longitude}:void 0}}function j(e){return e==="billing"||e==="shipping"}export{ut as u};

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.