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)}function customtrackEvent(e,t){try{gtag("event",e,{event_category:"engagement",event_label:t,value:1}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e})}catch(e){console.log(e)}}ProductModel.prototype.extractColourFromName=function(e){for(var t=["Red","Blue","Green","Yellow","Black","White","Purple","Orange","Pink","Grey","Taupe","Leaftree","LeafTree"],o=0;o{if(e&&e.gazebo_details_fragmentHTML){const t=document.getElementById("gazebo_details_fragmentHTML");t?(t.innerHTML=e.gazebo_details_fragmentHTML,observeAnimations()):console.error('Element with ID "gazebo_details_fragmentHTML" not found.');const o=document.querySelector("h1");if(o&&(o.innerHTML=`${e.size} ${e.colour} Pop Up Gazebo Pro ${e.frame}`),e.featuredVideo){const t=document.getElementById("featuredVideo");if(t&&"IFRAME"===t.tagName){const o=`https://www.youtube.com/embed/${e.featuredVideo}`;t.src!==o&&(t.src=o)}else console.error('Element with ID "featuredVideo" not found or is not an iframe.')}e.meta&&(document.title=e.meta.title||document.title,document.querySelector('meta[name="description"]').content=e.meta.description||"",document.querySelector('meta[name="keywords"]').content=e.meta.keywords||"")}else console.error("Invalid data or gazebo_details_fragmentHTML not found.")};var Gazebo,GazeboModel=function(){this.formattedProductShip=ko.observable(),this.Qty=ko.observable(1),this.Packages={lastPackage:ko.observable("Select"),toggleExtra:function(){"Extra"==Gazebo.Packages.lastPackage()?(Gazebo.Anchors.Option(Gazebo.Anchors.Empty),Gazebo.Storagebag.Option("Select"),Gazebo.Sidewalls.Option("Select"),Gazebo.Groundbars.Option("Select"),Gazebo.Packages.lastPackage("Select")):(Gazebo.Anchors.Option(Gazebo.Anchors.tiedownkit()),Gazebo.Storagebag.Option("Yes"),Gazebo.Sidewalls.Option("Yes"),Gazebo.Packages.lastPackage("Extra"))},togglePlusExtra:function(){"PlusExtra"==Gazebo.Packages.lastPackage()?(Gazebo.Anchors.Option(Gazebo.Anchors.Empty),Gazebo.Storagebag.Option("Select"),Gazebo.Sidewalls.Option("Select"),Gazebo.Groundbars.Option("Select"),Gazebo.Packages.lastPackage("Select")):(Gazebo.Anchors.Option(Gazebo.Anchors.tiedownkit()),Gazebo.Storagebag.Option("Yes"),Gazebo.Sidewalls.Option("Yes"),Gazebo.Groundbars.Option("Yes"),Gazebo.Packages.lastPackage("PlusExtra"))}};var e=window.__gazebo.frame,t=window.__gazebo.size,o=window.__gazebo.colour;this.getShipping=function(){const e=Gazebo.getBuilderProducts(),{productShipping:t}=e;return parseInt(t)},this.H1=function(){switch(Gazebo.Frame.Type()){case"DX":return"Gala Shade Pro Gazebo DX - Durable Event Shelter";case"MX":return"Gala Shade Pro Gazebo MX - Heavy Duty Gazebo";case"COMPACT":return"Gala Shade Pro Compact Gazebo - Easy Setup Shelter";case"40":return"Gala Shade Pro Gazebo 40 - Robust and Reliable";case"50":return"Gala Shade Pro Gazebo 50 - Enhanced Durability";case"60":return"Gala Shade Pro Gazebo 60 - Ultimate Strength and Protection";default:return"Gala Shade Pro Gazebo"}},this.Frame={Size:ko.observable(t),Type:ko.observable(e),Frame:ko.observable(),Product:ko.observable()},this.Canopy={Colour:ko.observable(o),Product:ko.observable(),checkStock:function(e){var t=transformedData.find((e=>"Gazebos"==e.name)).products.find((t=>(t.Frame.replace(" ","")||"").toUpperCase()==Gazebo.Frame.Type().toUpperCase()&&(t.Colour||"").toUpperCase()==e.toUpperCase()&&(t.Size||"")==Gazebo.Frame.Size()));return!!t&&1==Number(t.ProductShip)}},this.Sidewalls={Option:ko.observable(),Colour:ko.observable(o),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Sidewalls.Option("Select"===Gazebo.Sidewalls.Option()?"Yes":"Select")}),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 t=transformedData.find((e=>"Sidewalls"==e.name)).products.find((t=>(t.Colour||"").toUpperCase()==e.toUpperCase()&&(t.Size||"")==Gazebo.Frame.Size()));return!!t&&1==Number(t.ProductShip)},buyitwith:ko.observable(!0),buyitwithToggle:function(){setTimeout((function(){Gazebo.Sidewalls.buyitwith(!Gazebo.Sidewalls.buyitwith())}),0)}},this.Sidewallgroundpegs={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Sidewallgroundpegs.Option("Select"===Gazebo.Sidewallgroundpegs.Option()?"Yes":"Select")}),0)},generateOptions:function(){var e=transformedData.find((e=>"Sidewallgroundpegs"==e.name)).products[0],t=0;return Gazebo.Sidewalls.Product()&&void 0!==Gazebo.Sidewalls.Product().ProductCode&&""!==Gazebo.Sidewalls.Product().ProductCode&&(t=window.__input.find((e=>"Sidewallgroundpegs"==e.name)).relatedProd.find((e=>e.ProdMaster==Gazebo.Sidewalls.Product().ProductCode)).recQty),e.Qty=t,e},previewOption:function(){return transformedData.find((e=>"Sidewallgroundpegs"==e.name)).products[0]}},this.Groundbars={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Groundbars.Option("Select"===Gazebo.Groundbars.Option()?"Yes":"Select")}),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((t=>t.ProductCode==e)):null}},this.Storagebag={Option:ko.observable(),Product:ko.observable(),toggle:function(){setTimeout((function(){Gazebo.Storagebag.Option("Select"===Gazebo.Storagebag.Option()?"Yes":"Select")}),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((t=>t.ProductCode==e)):null},buyitwith:ko.observable(!0),buyitwithToggle:function(){setTimeout((function(){Gazebo.Storagebag.buyitwith(!Gazebo.Storagebag.buyitwith())}),0)}},this.Anchors={Empty:new ProductModel({ProductCode:"Select",ProductName:"Select"}),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,t){var o=new ProductModel(e=transformedData.find((e=>"Anchorage"==e.name)).products.find((t=>t.ProductCode==e)));return t>1&&(o.Qty=t,o.ProductName="(x"+o.Qty+") "+o.ProductName+" +"+localizeCost(o.ProductPrice*o.Qty)),o},t=[];t.push(this.Empty),"DX"==Gazebo.Frame.Type()||"MX"==Gazebo.Frame.Type()?t.push(e("09914",1)):"40"!=Gazebo.Frame.Type()&&"50"!=Gazebo.Frame.Type()||t.push(e("09913",1)),t.push(e("07608",2)),t.push(e("11087",4)),t.push(e("07290",2)),t.push(e("12595",1)),this.Options(t);var o=this.Options().find((e=>-1!==e.ProductName.toLowerCase().indexOf("tie down kit")));o&&(o.ProductName=o.ProductName+" +"+localizeCost(o.ProductPrice*o.Qty),this.tiedownkit(o))},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 t=transformedData.find((e=>"Sidewalls"==e.name)).products.find((e=>(e.Colour||"").toUpperCase()==this.Sidewalls.Colour()&&(e.Size||"")==this.Frame.Size()));t||showAlert("fa-check","Error","Not all products from your combination are available!","#FFFFFF",!1),this.Sidewalls.Product(t)}else this.Sidewalls.Product(void 0);var o=this.Sidewallgroundpegs.previewOption();"Yes"==this.Sidewallgroundpegs.Option()?this.Sidewallgroundpegs.Product(o):this.Sidewallgroundpegs.Product(void 0);try{var a=this.Groundbars.previewOption();"Yes"==this.Groundbars.Option()?this.Groundbars.Product(a):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,t=0;return[this.Frame,this.Canopy,this.Sidewalls,this.Groundbars,this.Sidewallgroundpegs,this.Storagebag,this.Anchors].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){var a=o.Product().ProductPrice,r=o.Product().Qty,i=o.Product().ProductDiscount,n=getFinalPrice(a,i)*r;e+=n,t+=a*r-n}})),t=Number(parseFloat(t).toFixed(2)),e*=this.Qty(),t*=this.Qty(),{totalCost:e,totalSaving:t}},this.calcBundleCosts=()=>{let e=0,t=0;[this.Frame,this.Canopy].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){var a=o.Product().ProductPrice,r=o.Product().Qty,i=o.Product().ProductDiscount,n=getFinalPrice(a,i)*r;e+=n,t+=a*r-n}}));return[this.Sidewalls,this.Storagebag].forEach((function(o){if(o.buyitwith()&&o.previewOption()&&o.previewOption().ProductPrice){var a=o.previewOption().ProductPrice,r=o.previewOption().Qty,i=o.previewOption().ProductDiscount,n=getFinalPrice(a,i)*r;e+=n,t+=a*r-n}})),t=Number(parseFloat(t).toFixed(2)),e*=this.Qty(),t*=this.Qty(),{totalCost:e,totalSaving:t}},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 t=1;[this.Frame,this.Canopy].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){let a={sku:o.Product().ProductCode,qty:o.Product().Qty};o==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(a.Artwork="Yes"),o.Product().ProductShip>t&&(t=o.Product().ProductShip),e.push(a)}}));return[this.Sidewalls,this.Storagebag].forEach((function(o){if(o.buyitwith()&&o.previewOption()&&o.previewOption().ProductPrice){let a={sku:o.previewOption().ProductCode,qty:o.previewOption().Qty};o==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(a.Artwork="Yes"),o.previewOption().ProductShip>t&&(t=o.previewOption().ProductShip),e.push(a)}})),{skusToAdd:e,productShipping:t}},this.click_addbuilderproducts_bundle=function(){const e=this.getBundleProducts();this.add(e)},this.getBreakDown=function(){let e=[];return[this.Frame,this.Canopy,this.Sidewalls,this.Groundbars,this.Sidewallgroundpegs,this.Storagebag,this.Anchors].forEach((function(t){t.Product()&&t.Product().ProductPrice&&t.Product().Qty>0&&e.push(t.Product())})),e},this.getBuilderProducts=()=>{const e=[];var t=1;return[this.Frame,this.Canopy,this.Sidewalls,this.Groundbars,this.Sidewallgroundpegs,this.Storagebag,this.Anchors].forEach((function(o){if(o.Product()&&o.Product().ProductPrice){let a={sku:o.Product().ProductCode,qty:o.Product().Qty*Gazebo.Qty()};o==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(a.Artwork="Yes"),o.Product().ProductShip>t&&(t=o.Product().ProductShip),e.push(a)}})),{skusToAdd:e,productShipping:t}},this.click_addbuilderproducts=function(){const e=this.getBuilderProducts();this.add(e)},this.add=e=>{const{skusToAdd:t,productShipping:o}=e;o>1&&modalOpen(document.getElementById("help-oos")),fetch("/basket/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:t})}).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.Sidewallgroundpegs.generateOptions(),Gazebo.updateTabs()})),this.Frame.Frame.subscribe((function(e){Gazebo.calculateGazeboProducts(),Gazebo.Anchors.generateOptions(),Gazebo.Sidewallgroundpegs.generateOptions()})),this.Frame.Type.subscribe((function(e){Gazebo.calculateGazeboProducts(),Gazebo.Anchors.generateOptions(),Gazebo.Sidewallgroundpegs.generateOptions(),reloadSizeOptions(),-1==["MX","40","COMPACT","50"].indexOf(e)&&Gazebo.Groundbars.Option("Select"),-1!==["60"].indexOf(e.toUpperCase())&&(Gazebo.Storagebag.Option("Select"),Gazebo.Groundbars.Option("Select")),Gazebo.updateTabs()})),this.Canopy.Colour.subscribe((function(e){Gazebo.calculateGazeboProducts(),"Select"==Gazebo.Sidewalls.Option()&&Gazebo.Sidewalls.Colour(e),Gazebo.updateTabs()})),this.Canopy.Product.subscribe((function(e){e&&e.images&&setTimeout((function(){var t=[],o=e.images;for(var a in o)t.push(new galleryModel(o[a]));var r=e.videos;for(var a in r)t.push(new galleryModel(r[a]));gallery=t,"undefined"!=typeof createGallery&&createGallery()}),0)})),this.Sidewalls.Option.subscribe((function(e){Gazebo.calculateGazeboProducts()})),this.Sidewalls.Colour.subscribe((function(e){Gazebo.calculateGazeboProducts()})),this.Sidewallgroundpegs.Option.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=>{Gazebo.formattedProductShip(e.formattedProductShip),setGazeboDetailsFragmentHTML(e),updateUrlAndReload(`/pop-up-gazebos${e.URL}`)})).catch((e=>{console.error("Fetch error:",e)}))}};function reloadSizeOptions(){setTimeout((function(){try{for(var e=document.getElementsByTagName("label"),t=null,o=0;o