function ProductModel(e){this.ProductCode=e.ProductCode,this.ProductName=e.ProductName,this.ProductDiscount=e.ProductDiscount,this.ProductPrice=e.ProductPrice,this.ProductShip=e.ProductShip,this.Qty=e.Qty||1,this.images=e.images,this.videos=e.videos,this.Colour=this.extractColourFromName(this.ProductName),this.Size=this.extractDimensionFromName(this.ProductName),this.Frame=this.extractFrameFromName(this.ProductName)}ProductModel.prototype.extractColourFromName=function(e){for(var o=["Red","Blue","Green","Yellow","Black","White","Purple","Orange","Pink","Grey","Taupe","Leaftree","LeafTree"],t=0;t"Gazebos"==e.name)).products.find((o=>(o.Frame.replace(" ","")||"").toUpperCase()==Gazebo.Frame.Type().toUpperCase()&&(o.Colour||"").toUpperCase()==e.toUpperCase()&&(o.Size||"")==Gazebo.Frame.Size()));return!!o&&1==Number(o.ProductShip)}},this.Sidewalls={Option:ko.observable(),Colour:ko.observable(t),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Sidewalls.Option("None"===Gazebo.Sidewalls.Option()?"Yes":"None")}),0)},previewOption:function(){return transformedData.find((e=>"Sidewalls"==e.name)).products.find((e=>(e.Colour||"").toUpperCase()==Gazebo.Sidewalls.Colour()&&(e.Size||"")==Gazebo.Frame.Size()))||transformedData.find((e=>"Sidewalls"==e.name)).products[0]},checkStock:function(e){var o=transformedData.find((e=>"Sidewalls"==e.name)).products.find((o=>(o.Colour||"").toUpperCase()==e.toUpperCase()&&(o.Size||"")==Gazebo.Frame.Size()));return!!o&&1==Number(o.ProductShip)},buyitwith:ko.observable(!0),buyitwithToggle:function(){setTimeout((function(){Gazebo.Sidewalls.buyitwith(!Gazebo.Sidewalls.buyitwith())}),0)}},this.Groundbars={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Groundbars.Option("None"===Gazebo.Groundbars.Option()?"Yes":"None")}),0)},previewOption:function(){var e=null;return"DX"!=Gazebo.Frame.Type()&&"MX"!=Gazebo.Frame.Type()&&"COMPACT"!=Gazebo.Frame.Type()&&"40"!=Gazebo.Frame.Type()&&"50"!=Gazebo.Frame.Type()||("3m x 3m"==Gazebo.Frame.Size()?e="07296":"3m x 4.5m"==Gazebo.Frame.Size()?e="07297":"3m x 6m"==Gazebo.Frame.Size()?e="07298":"4m x 6m"==Gazebo.Frame.Size()?e="10686":"4m x 8m"==Gazebo.Frame.Size()&&(e="10687")),e?transformedData.find((e=>"Groundbars"==e.name)).products.find((o=>o.ProductCode==e)):null}},this.Storagebag={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Storagebag.Option("None"===Gazebo.Storagebag.Option()?"Yes":"None")}),0)},previewOption:function(){var e=null;return"DX"!=Gazebo.Frame.Type()&&"MX"!=Gazebo.Frame.Type()||("3m x 3m"==Gazebo.Frame.Size()?e="12047":"3m x 4.5m"==Gazebo.Frame.Size()?e="12048":"3m x 6m"==Gazebo.Frame.Size()&&(e="12049")),"40"==Gazebo.Frame.Type()&&("3m x 3m"==Gazebo.Frame.Size()?e="07439":"3m x 4.5m"==Gazebo.Frame.Size()?e="07647":"3m x 6m"==Gazebo.Frame.Size()&&(e="07648")),"50"==Gazebo.Frame.Type()&&("3m x 3m"==Gazebo.Frame.Size()?e="09755":"3m x 4.5m"==Gazebo.Frame.Size()?e="09756":"3m x 6m"==Gazebo.Frame.Size()?e="09757":"4m x 6m"==Gazebo.Frame.Size()?e="11085":"4m x 8m"==Gazebo.Frame.Size()&&(e="11086")),e?transformedData.find((e=>"Bags"==e.name)).products.find((o=>o.ProductCode==e)):null},buyitwith:ko.observable(!0),buyitwithToggle:function(){setTimeout((function(){Gazebo.Storagebag.buyitwith(!Gazebo.Storagebag.buyitwith())}),0)}},this.Anchors={Empty:new ProductModel({ProductCode:"None",ProductName:"None"}),Option:ko.observable(),Product:ko.observable(),Options:ko.observableArray(),toggle:function(){setTimeout((function(){Gazebo.Anchors.Option(Gazebo.Anchors.Option()===Gazebo.Anchors.Empty?Gazebo.Anchors.tiedownkit():Gazebo.Anchors.Empty)}),0)},generateOptions:function(){var e=function(e,o){var t=new ProductModel(e=transformedData.find((e=>"Anchorage"==e.name)).products.find((o=>o.ProductCode==e)));return o>1&&(t.Qty=o,t.ProductName="(x"+t.Qty+") "+t.ProductName+" +"+localizeCost(t.ProductPrice*t.Qty)),t},o=[];o.push(this.Empty),"DX"==Gazebo.Frame.Type()||"MX"==Gazebo.Frame.Type()?o.push(e("09914",1)):"40"!=Gazebo.Frame.Type()&&"50"!=Gazebo.Frame.Type()||o.push(e("09913",1)),o.push(e("07608",4)),o.push(e("11087",4)),o.push(e("07290",4)),o.push(e("12595",4)),this.Options(o);var t=this.Options().find((e=>-1!==e.ProductName.toLowerCase().indexOf("tie down kit")));t&&(t.ProductName=t.ProductName+" +"+localizeCost(t.ProductPrice*t.Qty),this.tiedownkit(t))},tiedownkit:tiedownkit=ko.observable()},this.Printing={Option:ko.observable()},this.Extras={Option:ko.observable()},this.calculateGazeboProducts=function(){try{var e=transformedData.find((e=>"Gazebos"==e.name)).products.find((e=>(e.Frame.replace(" ","")||"").toUpperCase()==this.Frame.Type().toUpperCase()&&(e.Colour||"").toUpperCase()==this.Canopy.Colour()&&(e.Size||"")==this.Frame.Size()));if(this.Canopy.Product(e),"Yes"==this.Sidewalls.Option()){var o=transformedData.find((e=>"Sidewalls"==e.name)).products.find((e=>(e.Colour||"").toUpperCase()==this.Sidewalls.Colour()&&(e.Size||"")==this.Frame.Size()));o||showAlert("fa-check","Error","Not all products from your combination are available!","#FFFFFF",!1),this.Sidewalls.Product(o)}else this.Sidewalls.Product(void 0);try{var t=this.Groundbars.previewOption();"Yes"==this.Groundbars.Option()?this.Groundbars.Product(t):this.Groundbars.Product(void 0)}catch(e){console.log(e)}var r=this.Storagebag.previewOption();"Yes"==this.Storagebag.Option()?this.Storagebag.Product(r):this.Storagebag.Product(void 0)}catch(e){console.log(e)}},this.calcCosts=()=>{let e=0,o=0;return[this.Frame,this.Canopy,this.Sidewalls,this.Groundbars,this.Storagebag,this.Anchors].forEach((function(t){if(t.Product()&&t.Product().ProductPrice){var r=t.Product().ProductPrice,a=t.Product().Qty,i=t.Product().ProductDiscount,n=getFinalPrice(r,i)*a;e+=n,o+=r*a-n}})),o=Number(parseFloat(o).toFixed(2)),{totalCost:e,totalSaving:o}},this.calcBundleCosts=()=>{let e=0,o=0;[this.Frame,this.Canopy].forEach((function(t){if(t.Product()&&t.Product().ProductPrice){var r=t.Product().ProductPrice,a=t.Product().Qty,i=t.Product().ProductDiscount,n=getFinalPrice(r,i)*a;e+=n,o+=r*a-n}}));return[this.Sidewalls,this.Storagebag].forEach((function(t){if(t.buyitwith()&&t.previewOption()&&t.previewOption().ProductPrice){var r=t.previewOption().ProductPrice,a=t.previewOption().Qty,i=t.previewOption().ProductDiscount,n=getFinalPrice(r,i)*a;e+=n,o+=r*a-n}})),o=Number(parseFloat(o).toFixed(2)),{totalCost:e,totalSaving:o}},this.calculateGazeboCost=function(){const{totalCost:e}=this.calcCosts();return e},this.getSaving=function(){const{totalSaving:e}=this.calcCosts();return e},this.getBundleProducts=()=>{const e=[];var o=1;[this.Frame,this.Canopy].forEach((function(t){if(t.Product()&&t.Product().ProductPrice){let r={sku:t.Product().ProductCode,qty:t.Product().Qty};t==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(r.Artwork="Yes"),t.Product().ProductShip>o&&(o=t.Product().ProductShip),e.push(r)}}));return[this.Sidewalls,this.Storagebag].forEach((function(t){if(t.buyitwith()&&t.previewOption()&&t.previewOption().ProductPrice){let r={sku:t.previewOption().ProductCode,qty:t.previewOption().Qty};t==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(r.Artwork="Yes"),t.previewOption().ProductShip>o&&(o=t.previewOption().ProductShip),e.push(r)}})),{skusToAdd:e,productShipping:o}},this.click_addbuilderproducts_bundle=function(){const e=this.getBundleProducts();this.add(e)},this.getBuilderProducts=()=>{const e=[];var o=1;return[this.Frame,this.Canopy,this.Sidewalls,this.Groundbars,this.Storagebag,this.Anchors].forEach((function(t){if(t.Product()&&t.Product().ProductPrice){let r={sku:t.Product().ProductCode,qty:t.Product().Qty};t==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(r.Artwork="Yes"),t.Product().ProductShip>o&&(o=t.Product().ProductShip),e.push(r)}})),{skusToAdd:e,productShipping:o}},this.click_addbuilderproducts=function(){const e=this.getBuilderProducts();this.add(e)},this.add=e=>{const{skusToAdd:o,productShipping:t}=e;t>1&&modalOpen(document.getElementById("help-oos")),fetch("/basket/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:o})}).then((e=>e.json())).then((e=>{setBasket({Qty:e.totalQty,Cost:e.totalPrice}),showAlert("icon-ok-circled",CONST_PRODUCT_ADD_TITLE,CONST_PRODUCT_ADDED+" "+CONST_PRODUCT_ADDED_APPEND,"#FFFFFF",!1)})).catch((e=>{console.error("Error:",e)}))},this.displaySnippet=function(){try{switch(this.Frame.Type()){case"DX":return CONST_DX_SNIPPET;case"MX":return CONST_MX_SNIPPET;case"40":return CONST_40_SNIPPET;case"COMPACT":return CONST_40C_SNIPPET;case"50":return CONST_50_SNIPPET;case"60":return CONST_60_SNIPPET;default:return""}}catch(e){return""}},this.Frame.Size.subscribe((function(e){Gazebo.calculateGazeboProducts(),Gazebo.Anchors.generateOptions(),Gazebo.updateTabs(),updateUrlAndReload("frame="+Gazebo.Frame.Type().toLowerCase()+"&size="+Gazebo.Frame.Size())})),this.Frame.Frame.subscribe((function(e){Gazebo.calculateGazeboProducts(),Gazebo.Anchors.generateOptions()})),this.Frame.Type.subscribe((function(e){Gazebo.calculateGazeboProducts(),Gazebo.Anchors.generateOptions(),reloadSizeOptions(),-1!==["60"].indexOf(e.toUpperCase())&&(Gazebo.Storagebag.Option("None"),Gazebo.Groundbars.Option("None")),Gazebo.updateTabs(),updateUrlAndReload("frame="+Gazebo.Frame.Type().toLowerCase()+"&size="+Gazebo.Frame.Size())})),this.Canopy.Colour.subscribe((function(e){Gazebo.calculateGazeboProducts(),"None"==Gazebo.Sidewalls.Option()&&Gazebo.Sidewalls.Colour(e)})),this.Canopy.Product.subscribe((function(e){e&&e.images&&setTimeout((function(){var o=[],t=e.images;for(var r in t)o.push(new galleryModel(t[r]));var a=e.videos;for(var r in a)o.push(new galleryModel(a[r]));gallery=o,"undefined"!=typeof createGallery&&createGallery()}),0)})),this.Sidewalls.Option.subscribe((function(e){Gazebo.calculateGazeboProducts()})),this.Sidewalls.Colour.subscribe((function(e){Gazebo.calculateGazeboProducts()})),this.Groundbars.Option.subscribe((function(e){Gazebo.calculateGazeboProducts()})),this.Storagebag.Option.subscribe((function(e){Gazebo.calculateGazeboProducts()})),this.Anchors.Option.subscribe((function(e){Gazebo.Anchors.Product(e),Gazebo.calculateGazeboProducts()})),this.updateTabs=function(){Gazebo.Canopy.Product()&&fetch("/gala-shade-pro-gazebo/fragment?code="+Gazebo.Canopy.Product().ProductCode).then((e=>{if(!e.ok)throw new Error("Network response was not ok "+e.statusText);return e.json()})).then((e=>{document.querySelector("#gazebo-builder-description").innerHTML=e.ProductDesc,document.querySelector(".specs").innerHTML=e.ProductSpec})).catch((e=>{console.error("Fetch error:",e)}))}};function reloadSizeOptions(){setTimeout((function(){try{for(var e=document.getElementsByTagName("label"),o=null,t=0;t