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}={}){const formData=new FormData(form);formData.append("sections",sections),formData.append("sections_url",sectionsUrl),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD_FROM_FORM,{form,formData});const config=getDefaultRequestConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"],config.body=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}),state}catch(err){this.handleAddToCartError(err);const pushCartSections=window.BAO.sectionRenderer.pushCartSections;if(!pushCartSections||!pushCartSections.length)return;window.BAO.sectionRenderer.fetch(pushCartSections.map(s=>s.section)).then(htmlSections=>{const updatedSections=pushCartSections.map(section=>({...section,html:htmlSections[section.section]}));window.BAO.sectionRenderer.renderMultiple(updatedSections);const cartCountHTML=htmlSections["push-cart-count"];cartCountHTML&&window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state:{sections:{"push-cart-count":cartCountHTML}}})}).catch(err2=>{console.error("Failed to fetch cart sections:",err2)})}}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)}}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)}}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}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_REMOVE_ITEM,{keys});const body={updates:Object.fromEntries(keys.map(k=>[k,0]))};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_REMOVE_ITEM,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){console.error(err)}}async updateItemProperties(key,quantity,properties,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){const body={id:key,properties,quantity};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)}}handleAddToCartError(res){const pushCart=getElement("push-cart");pushCart&&pushCart.handleError(res)}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/727/assets/bao-cart.js.map?v=33832023603683773611790328888
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.