PageSourceSearch

https://www.sunspel.com/cdn/shop/t/532/assets/bao-cart.js?v=108983647315143965771789479774

js sunspel.com collected 2026-09-24 17:56:49 UTC 6,006 bytes, 2 lines download raw bytes

1const{fetchJSON,getDefaultRequestConfig,getElement}=window.BAO.Utils,defaultSectionsUrl=()=>["/apps/","/a/","/tools/","/community/"].some(url=>window.location.pathname.includes(url))?"/":window.location.pathname,DEFAULT_SECTIONS_URL=defaultSectionsUrl();class BaoCart{async addItemFromForm(form,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={},silent=!1){const formData=new FormData(form);formData.append("sections",sections),formData.append("sections_url",sectionsUrl);const config=getDefaultRequestConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"],config.body=formData,silent===!1&&window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD_FROM_FORM,{form,formData});try{const state=await fetchJSON(`${window.routes.cartAddUrl}`,config);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_ADD_FROM_FORM,{form,formData,state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state,form}),state}catch(err){this.handleAddToCartError(err,form);try{await this.refreshCartSections(sections,sectionsUrl)}catch(fetchErr){console.error(fetchErr)}}}async addItem(items,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL,attributes={},form}={}){Array.isArray(items)||(items=[items]),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD,{items,attributes,form});const body={items,attributes};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartAdd(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_ADD,{items,state,form}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){this.handleAddToCartError(err,form);try{await this.refreshCartSections(sections,sectionsUrl)}catch(fetchErr){console.error(fetchErr)}}}async updateQuantity(key,quantity,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_ITEM_QUANTITY,{key,quantity});const body={id:key,quantity};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartChange(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_ITEM_QUANTITY,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){this.handleAddToCartError(err);try{await this.refreshCartSections(sections,sectionsUrl)}catch(fetchErr){console.error(fetchErr)}}}async removeItem(key,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_REMOVE_ITEM,{key});const body={id:key,quantity:0};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartChange(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_REMOVE_ITEM,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){console.error(err)}}async removeItems(keys,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){for(window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_REMOVE_ITEM,{keys});keys.length>0;){const key=keys.shift(),isLastKey=keys.length===0,body={id:key,quantity:0};isLastKey&&sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartChange(body);if(isLastKey)return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_REMOVE_ITEM,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){console.error(err)}}}async updateItemProperties(key,properties,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){const body={id:key,properties};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{return this.cartChange(body)}catch(e){console.error(e)}}async updateCartAttributes(attributes,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_CART_ATTRIBUTES,{attributes});const body={attributes};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartUpdate(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_CART_ATTRIBUTES,{attributes}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(e){console.error(e)}}async updateNote(note){window.BAO.dispatchEvent(window.BAO.EVENTS.CART_NOTE.BEFORE_CHANGE,{note});try{const state=await this.cartUpdate({note});return window.BAO.dispatchEvent(window.BAO.EVENTS.CART_NOTE.AFTER_CHANGE,{state,note}),state}catch(e){console.error(e)}}async refreshCartSections(sections,sectionsUrl=DEFAULT_SECTIONS_URL){const stateSections=await window.BAO.sectionRenderer.fetch(sections,sectionsUrl);window.BAO.sectionRenderer.renderMultiple(window.BAO.sectionRenderer.pushCartSections.filter(s=>s.section in stateSections).map(s=>({...s,html:stateSections[s.section]})))}handleAddToCartError(res,form){const pushCart=getElement("push-cart");pushCart&&(pushCart.handleError(res),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.ERROR,{form}))}cartAdd(body){return fetchJSON(`${window.routes.cartAddUrl}`,{...getDefaultRequestConfig(),body:JSON.stringify(body)})}cartChange(body){return fetchJSON(`${window.routes.cartChangeUrl}`,{...getDefaultRequestConfig(),body:JSON.stringify(body)})}
1cartUpdate(body){return fetchJSON(`${window.routes.cartUpdateUrl}`,{...getDefaultRequestConfig(),body:JSON.stringify(body)})}}window.BAO.Cart=new BaoCart;
2//# sourceMappingURL=/cdn/shop/t/532/assets/bao-cart.js.map?v=108983647315143965771789479774

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.