PageSourceSearch

https://bonnegueule.fr/cdn/shop/t/9/assets/__vite-product-html-element.56f77478.js

js bonnegueule.fr collected 2026-10-02 10:04:56 UTC 3,965 bytes, 1 lines download raw bytes

1var V=Object.defineProperty;var D=(a,r,t)=>r in a?V(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t;var i=(a,r,t)=>(D(a,typeof r!="symbol"?r+"":r,t),t);import{C as S}from"./__vite-custom-html-element.bdb17794.js";import{a as _,s as E,b as C,g as T,c as j,d as y,e as k}from"./__vite-products.9c26dcf5.js";import{_ as $,S as A}from"./__vite-section-loader.cfabd402.js";let p=new Map;const w=class{static load(a,r={}){return a?this.loadedProducts[a]?this.loadedProducts[a]:(this.loadedProducts[a]=new Promise((t,e)=>{this.addUrl(a,r).then(s=>{s.error?(delete this.loadedProducts[a],e(new Error(`Failed to load product ${a}`))):t(s)})}),this.loadedProducts[a]):Promise.reject(new Error("No product handle provided"))}static addUrl(a,r={}){let t;const e=new Promise(d=>t=d);let s=p.get(a);return s||(s=[],p.set(a,s)),s.push(t),this.launch(r),e}static launch(a={}){this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.process(a),0)}static async process(a={}){const r=new Map(p);p=new Map;const t=r.keys();let e=t.next();const s=[],d=[];for(;!e.done;){const c=r.get(e.value).flat().map(n=>n),o=e.value;d.push(o);const l=fetch(`${window.themeVariables.routes.rootUrlWithoutSlash}/products/${o}.js`).then(async n=>{if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const m=await n.json();return{handle:o,responseAsJson:m,resolvers:c}}).catch(n=>(console.error(`Error fetching product ${o}:`,n),{handle:o,responseAsJson:{handle:o,variants:[],error:!0},resolvers:c}));s.push(l),e=t.next()}s.push(A.load({resource:`products/${d[0]}`,params:{variantId:new Date().getTime(),view:new Date().getTime(),product_handles:d.join(",")},sections:"product-complement-json",options:{removeSectionWrapper:!0,returnNodes:!1,cache:!1,saveToStorage:!1}}).then(u=>{try{const{product_complements:c}=JSON.parse(u);return c}catch(c){return console.error(c),{product_complements:{}}}})),Promise.all(s).then(u=>{const c=u.pop();u.forEach(o=>{if(o.responseAsJson.error){o.resolvers.forEach(h=>h(o.responseAsJson));return}let{collection_names:l,...n}=c[o.handle]||{};l=(l==null?void 0:l.split(","))||[];const{variants_complement:m=[],...v}=n,f=o.responseAsJson,{variants:P=[]}=f;P.forEach((h,g)=>{Object.assign(h,m[g])});const b={...f,collection_names:l,variants:P,...v,...a};_(o.handle,b),o.resolvers.forEach(h=>h(b))}),r.clear()})}};$(w,"loadedProducts",{});class O extends S{constructor(){super(...arguments);i(this,"watchVariant",!1);i(this,"watchProductData",!1);i(this,"loadProductData",!1);i(this,"noDefaultVariantSelected",!1);i(this,"selectedVariantId");i(this,"variant");i(this,"product")}async connectedCallback(){const t=this.productHandle;if(!t){console.warn(`${this.constructor.name}::Product custom element must have a "handle" attribute or have an ancestor with "data-product-handle"`);return}if(t!=="null"){if(this.loadProductData)try{this.product=await w.load(t,this.customData)}catch(e){this.onLoadProductDataFailed(e);return}this.watchVariant&&(this._unsubscribeSelectedVariant=E(t,e=>{this.variant=e,this.onVariantChanged({variant:e})})),this.watchProductData&&(this._unsubscribeProduct=C(t,e=>{this.product=e;const s=T(this.productHandle);if(s)this.variant=j(t,s);else{const d=y(this.productHandle);(!this.noDefaultVariantSelected||d)&&(this.variant=k(this.productHandle))}this.onProductDataChanged({product:e,variant:this.variant})}))}}get productHandle(){var e,s;let t;return this.getAttribute("handle")||((e=this.dataset)==null?void 0:e.productHandle)||((t=this.closest("[data-product-handle]"))?(s=t.dataset)==null?void 0:s.productHandle:null)}get customData(){const t=Object.entries(this.dataset||{}).filter(([e,s])=>/^custom/.test(e));return Object.fromEntries(t)}onVariantChanged(){}onProductDataChanged(){}onLoadProductDataFailed(){}disconnectedCallback(){var t,e;super.disconnectedCallback(),(t=this._unsubscribeSelectedVariant)==null||t.call(this),(e=this._unsubscribeProduct)==null||e.call(this)}}export{O as P,w as a};

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.