function ProductModel(t){this.ProductCode=t.ProductCode,this.ProductName=t.ProductName,this.ProductDiscount=t.ProductDiscount,this.ProductPrice=t.ProductPrice,this.ProductShip=t.ProductShip,this.Qty=t.Qty||1,this.images=t.images,this.videos=t.videos,this.Material=this.extractMaterialFromName(this.ProductName),this.Size=this.extractDimensionFromName(this.ProductName)}function transformInputToProductModels(){var t=[];return window.__input.forEach((function(e){var o={};o.name=e.name,o.products=e.data.map((function(t){return new ProductModel(t)})),t.push(o)})),t}ProductModel.prototype.extractMaterialFromName=function(t){for(var e=["PE","PVC"],o=0;o"Groundbars"==t.name)).products.find((t=>-1!==t.ProductName.indexOf(Marquee.Frame.Size())))},buyitwith:ko.observable(!0),buyitwithToggle:function(){setTimeout((function(){Marquee.Groundbars.buyitwith(!Marquee.Groundbars.buyitwith())}),0)}},this.Anchors={Empty:new ProductModel({ProductCode:"None",ProductName:"None"}),Option:ko.observable(),Product:ko.observable(),Options:ko.observableArray(),toggle:function(){setTimeout((function(){Marquee.Anchors.Option(Marquee.Anchors.Option()===Marquee.Anchors.Empty?Marquee.Anchors.tiedownkit():Marquee.Anchors.Empty)}),0)},generateOptions:function(){var t=function(t,e){var o=new ProductModel(t=transformedData.find((t=>"Anchorage"==t.name)).products.find((e=>e.ProductCode==t)));return e>1&&(o.Qty=e,o.ProductName="(x"+o.Qty+") "+o.ProductName+" +"+localizeCost(o.ProductPrice*o.Qty)),o},e=[];e.push(this.Empty);const o=extractDimensions(Marquee.Frame.Size());o?6==o.width?e.push(t("01003",o.height)):4==o.width?12==o.height?e.push(t("01003",8)):10==o.height?e.push(t("01003",6)):8==o.height||6==o.height?e.push(t("01003",4)):e.push(t("01003",3)):3==o.width&&(12==o.height?e.push(t("01003",8)):10==o.height?e.push(t("01003",5)):8==o.height?e.push(t("01003",4)):6==o.height?e.push(t("01003",3)):e.push(t("01003",2))):e.push(t("01003",2)),this.Options(e)},previewOption:function(){return transformedData.find((t=>"Anchorage"==t.name)).products.find((t=>"01003"===t.ProductCode))}},this.Extras={Option:ko.observable()},this.Heaters={Product:ko.observable(),Qty:ko.observable(0),qty_increase:function(){qty_increase(Marquee.Heaters.Qty)},qty_decrease:function(){qty_decrease(Marquee.Heaters.Qty)},generateOptions:function(){var t=transformedData.find((t=>"Heaters"==t.name)).products[0];t.Qty=0,this.Product(t)}},this.Lighting={Product:ko.observable(),Qty:ko.observable(0),qty_increase:function(){qty_increase(Marquee.Lighting.Qty)},qty_decrease:function(){qty_decrease(Marquee.Lighting.Qty)},generateOptions:function(){var t=transformedData.find((t=>"Lighting"==t.name)).products[0];t.Qty=0,this.Product(t)}},this.Lining={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Marquee.Lining.Option("None"===Marquee.Lining.Option()?"Yes":"None")}),0)},previewOption:function(){return transformedData.find((t=>"Lining"==t.name)).products.find((t=>-1!==t.ProductName.indexOf(Marquee.Frame.Size())))}},this.Polebag={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Marquee.Polebag.Option("None"===Marquee.Polebag.Option()?"Yes":"None")}),0)},generateOptions:function(){var t=transformedData.find((t=>"Polebag"==t.name)).products[0],e=window.__input.find((t=>"Polebag"==t.name)).relatedProd.find((t=>t.ProdMaster==Marquee.Canopy.Product().ProductCode)).recQty;return t.Qty=e,t},previewOption:function(){return transformedData.find((t=>"Polebag"==t.name)).products[0]}},this.Canopybag={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Marquee.Canopybag.Option("None"===Marquee.Canopybag.Option()?"Yes":"None")}),0)},generateOptions:function(){var t=transformedData.find((t=>"Canopybag"==t.name)).products[0],e=window.__input.find((t=>"Canopybag"==t.name)).relatedProd.find((t=>t.ProdMaster==Marquee.Canopy.Product().ProductCode)).recQty;return t.Qty=e,t},previewOption:function(){return transformedData.find((t=>"Canopybag"==t.name)).products[0]}},this.calculateMarquee=function(){var t=transformedData.find((t=>"Marquees"==t.name)).products.find((t=>(t.Material||"").toUpperCase()==this.Canopy.Material()&&(t.Size||"")==this.Frame.Size()));this.Canopy.Product(t)},this.calculateMarqueeProducts=function(){try{if("Yes"==this.Groundbars.Option()?this.Groundbars.Product(Marquee.Groundbars.previewOption()):this.Groundbars.Product(void 0),"Yes"==this.Lining.Option()){var t=transformedData.find((t=>"Lining"==t.name)).products.find((t=>-1!==t.ProductName.indexOf(this.Frame.Size())));t?this.Lining.Product(t):(showAlert("icon-cancel-circled","Error","Lining option not available for this size!","#FFFFFF",!1),this.Lining.Option("None"))}else this.Lining.Product(void 0);"Yes"==this.Polebag.Option()?this.Polebag.Product(Marquee.Polebag.previewOption()):this.Polebag.Product(void 0),"Yes"==this.Canopybag.Option()?this.Canopybag.Product(Marquee.Canopybag.previewOption()):this.Canopybag.Product(void 0)}catch(t){console.log(t)}},this.calcCosts=()=>{let t=0,e=0;return[this.Frame,this.Canopy,this.Groundbars,this.Anchors,this.Heaters,this.Lighting,this.Lining,this.Polebag,this.Canopybag].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){var r=o.Product().ProductPrice,n=o.Product().Qty,i=o.Product().ProductDiscount,a=getFinalPrice(r,i)*n;t+=a,e+=r*n-a}})),e=Number(parseFloat(e).toFixed(2)),{totalCost:t,totalSaving:e}},this.calcBundleCosts=()=>{let t=0,e=0;[this.Frame,this.Canopy].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){var r=o.Product().ProductPrice,n=o.Product().Qty,i=o.Product().ProductDiscount,a=getFinalPrice(r,i)*n;t+=a,e+=r*n-a}}));return[this.Groundbars].forEach((function(o){if(o.buyitwith()&&o.previewOption()&&o.previewOption().ProductPrice){var r=o.previewOption().ProductPrice,n=o.previewOption().Qty,i=o.previewOption().ProductDiscount,a=getFinalPrice(r,i)*n;t+=a,e+=r*n-a}})),e=Number(parseFloat(e).toFixed(2)),{totalCost:t,totalSaving:e}},this.calculateGazeboCost=function(){const{totalCost:t}=this.calcCosts();return t},this.getSaving=function(){const{totalSaving:t}=this.calcCosts();return t},this.getBundleProducts=()=>{const t=[];var e=1;[this.Frame,this.Canopy].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){let r={sku:o.Product().ProductCode,qty:o.Product().Qty};o.Product().ProductShip>e&&(e=o.Product().ProductShip),r.qty>0&&t.push(r)}}));return[this.Groundbars].forEach((function(o){if(o.buyitwith()&&o.previewOption()&&o.previewOption().ProductPrice){let r={sku:o.previewOption().ProductCode,qty:o.previewOption().Qty};o.previewOption().ProductShip>e&&(e=o.previewOption().ProductShip),r.qty>0&&t.push(r)}})),{skusToAdd:t,productShipping:e}},this.click_addbuilderproducts_bundle=function(){const t=this.getBundleProducts();this.add(t)},this.getShipping=function(){const t=Marquee.getBuilderProducts(),{productShipping:e}=t;return parseInt(e)},this.getBuilderProducts=function(){const t=[];var e=1;return[this.Frame,this.Canopy,this.Groundbars,this.Anchors,this.Heaters,this.Lighting,this.Lining,this.Polebag,this.Canopybag].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){let r={sku:o.Product().ProductCode,qty:o.Product().Qty};o.Product().ProductShip>e&&(e=o.Product().ProductShip),r.qty>0&&t.push(r)}})),{skusToAdd:t,productShipping:e}},this.click_addbuilderproducts=function(){const t=this.getBuilderProducts();this.add(t)},this.add=t=>{const{skusToAdd:e,productShipping:o}=t;o>1&&modalOpen(document.getElementById("help-oos")),fetch(`${window.location.pathname}/add`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:e})}).then((t=>t.json())).then((t=>{setBasket({Qty:t.totalQty,Cost:t.totalPrice}),showAlert("icon-ok-circled",CONST_PRODUCT_ADD_TITLE,CONST_PRODUCT_ADDED+" "+CONST_PRODUCT_ADDED_APPEND,"#FFFFFF",!1)})).catch((t=>{console.error("Error:",t)}))},this.click_includeall=function(){Marquee.Groundbars.Option("Yes"),showAlert("icon-ok-circled",CONST_PRODUCT_INCLUDE_ALL_TITLE,CONST_PRODUCT_INCLUDE_ALL_MSG,"#FFFFFF",!1)},this.displaySnippet=function(){try{switch(this.Canopy.Material()){case"PE":return"Low cost and functional";case"PVC":return"Commercial Quality Marquee";default:return""}}catch(t){return""}},this.Frame.Size.subscribe((function(t){Marquee.calculateMarquee(),Marquee.calculateMarqueeProducts(),Marquee.Anchors.generateOptions(),Marquee.Polebag.generateOptions(),Marquee.Canopybag.generateOptions(),updateUrlAndReload("material="+Marquee.Canopy.Material().toLowerCase()+"&size="+Marquee.Frame.Size())})),this.Canopy.Material.subscribe((function(t){Marquee.calculateMarquee(),updateUrlAndReload("material="+Marquee.Canopy.Material().toLowerCase()+"&size="+Marquee.Frame.Size())})),this.Canopy.Product.subscribe((function(t){t&&t.images&&setTimeout((function(){var e=[],o=t.images;for(var r in o)e.push(new galleryModel(o[r]));var n=t.videos;for(var r in n)e.push(new galleryModel(n[r]));gallery=e,"undefined"!=typeof createGallery&&createGallery()}),0),fetch("/gala-tent-marquee/fragment?code="+Marquee.Canopy.Product().ProductCode).then((t=>{if(!t.ok)throw new Error("Network response was not ok "+t.statusText);return t.json()})).then((t=>{document.querySelector("#marquee-builder-description").innerHTML=t.ProductDesc,document.querySelector(".specs").innerHTML=t.ProductSpec})).catch((t=>{console.error("Fetch error:",t)}))})),this.Groundbars.Option.subscribe((function(t){Marquee.calculateMarqueeProducts()})),this.Anchors.Option.subscribe((function(t){Marquee.Anchors.Product(t),Marquee.calculateMarqueeProducts()})),this.Heaters.Qty.subscribe((function(t){Marquee.Heaters.Product({...Marquee.Heaters.Product(),Qty:t})})),this.Lighting.Qty.subscribe((function(t){Marquee.Lighting.Product({...Marquee.Lighting.Product(),Qty:t})})),this.Lining.Option.subscribe((function(t){Marquee.calculateMarqueeProducts()})),this.Polebag.Option.subscribe((function(t){Marquee.calculateMarqueeProducts()})),this.Canopybag.Option.subscribe((function(t){Marquee.calculateMarqueeProducts()}))};function qty_increase(t){var e=t();e=isNaN(e)?0:e,t(qty_check(++e))}function qty_decrease(t){var e=t();e=isNaN(e)?0:e,t(qty_check(--e))}function qty_check(t){var e=isNaN(t)?0:t;return e>999?e=999:e<0&&(e=0),e}function extractDimensions(t){const e=t.match(/(\d+)m\s*x\s*(\d+)m/);if(e&&e.length>=3){return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}return null}function updateUrlAndReload(t){let e=window.location.href.split("?")[0]+"?"+t;window.history.pushState({path:e},"",e)}document.addEventListener("DOMContentLoaded",(function(){(Marquee=new MarqueeModel).calculateMarquee(),Marquee.Anchors.generateOptions(),Marquee.Heaters.generateOptions(),Marquee.Lighting.generateOptions(),Marquee.Polebag.generateOptions(),Marquee.Canopybag.generateOptions(),ko.applyBindings(Marquee,document.getElementById("content"))})),window.addEventListener("popstate",(function(t){window.location.reload(!1)}));