!function(){const e=["White","Black","Blue","Green","Grey","Taupe","Orange","Red","Purple","Yellow","Pink","Leaftree"],t={White:"white",Black:"black",Blue:"blue",Green:"green",Grey:"grey",Taupe:"taupe",Orange:"orange",Red:"red",Purple:"purple",Yellow:"yellow",Pink:"pink",Leaftree:"leaftree"},o={"Pro Compact":{sizes:["3m x 3m"],colours:e},"Pro 40":{sizes:["3m x 3m","3m x 4.5m","3m x 6m"],colours:e},"Pro 50":{sizes:["3m x 3m","3m x 4.5m","3m x 6m","4m x 6m","4m x 8m"],colours:e},"Pro 60":{sizes:["3m x 3m","3m x 6m","4m x 8m"],colours:e},"Pro 60 (4m x 10m)":{sizes:["4m x 10m"],colours:["White","Taupe","Black"]},"Pro 60 Vantage":{sizes:["6m x 6m"],colours:["White","Taupe"]}},r={"3m x 3m":["Pro Compact","Pro 40","Pro 50","Pro 60"],"3m x 4.5m":["Pro 40","Pro 50"],"3m x 6m":["Pro 40","Pro 50","Pro 60"],"4m x 6m":["Pro 50"],"4m x 8m":["Pro 50","Pro 60"],"4m x 10m":["Pro 60 (4m x 10m)"],"6m x 6m":["Pro 60 Vantage"]};function s(s){const a=this;a.progressLabels=["Using your gazebo","Anchoring and stability","Cosmetics and accessories","Recommendation"],a.sizeOptions=["3m x 3m","3m x 4.5m","3m x 6m","4m x 6m","4m x 8m","4m x 10m","6m x 6m"],a.smallVehicleOptions=["Yes","No","Sometimes"],a.useTypeOptions=["Business","Personal"],a.frequencyOptions=["Rarely","Sometimes","Quite often","Very often"],a.groundOptions=["Hard ground","Soft ground","Both"],a.waterOptions=["Yes","No","Sometimes"],a.stabilityOptions=["Yes","No","Not sure"],a.sidewallsOptions=["Yes","No","Not sure"],a.sidewallsTypeOptions=["Full set","Individual walls","Not sure"],a.printingOptions=["Yes","No","Not sure"],a.bagOptions=["Yes","No","Not sure"],a.lightingOptions=["Yes","No","Not sure"],a.currentStep=ko.observable(1),a.size=ko.observable(""),a.smallVehicle=ko.observable(""),a.useType=ko.observable(""),a.frequency=ko.observable(""),a.ground=ko.observable(""),a.water=ko.observable(""),a.stability=ko.observable(""),a.colour=ko.observable(""),a.sidewalls=ko.observable(""),a.sidewallsType=ko.observable(""),a.printing=ko.observable(""),a.bag=ko.observable(""),a.lighting=ko.observable(""),a.alternativeLinks=ko.observableArray([]),a.isSmallVehicleSize=ko.pureComputed((()=>"3m x 3m"===a.size())),a.showSmallVehicle=ko.pureComputed((()=>a.isSmallVehicleSize())),a.isBusiness=ko.pureComputed((()=>"Business"===a.useType())),a.currentModel=ko.pureComputed((()=>function(e){const t=e.size();if("4m x 6m"===t)return"Pro 50";if("4m x 10m"===t)return"Pro 60 (4m x 10m)";if("6m x 6m"===t)return"Pro 60 Vantage";if("3m x 3m"===t&&"Yes"===e.smallVehicle())return"Pro Compact";const o=r[t]||[];if(1===o.length)return o[0];const s=e.frequency();if("Very often"===s){if(o.includes("Pro 60"))return"Pro 60";if(o.includes("Pro 50"))return"Pro 50"}if("Quite often"===s){if(o.includes("Pro 50"))return"Pro 50";if(o.includes("Pro 60"))return"Pro 60";if(o.includes("Pro 40"))return"Pro 40"}return o.includes("Pro 40")?"Pro 40":o.includes("Pro 50")?"Pro 50":o.includes("Pro 60")?"Pro 60":o.includes("Pro Compact")?"Pro Compact":"No match"}(a))),a.isPro60Family=ko.pureComputed((()=>a.currentModel().startsWith("Pro 60"))),a.isVantage=ko.pureComputed((()=>"Pro 60 Vantage"===a.currentModel())),a.showStability=ko.pureComputed((()=>!a.isVantage())),a.showSidewallsWrap=ko.pureComputed((()=>!a.isVantage())),a.showSidewallsNote=ko.pureComputed((()=>a.isVantage())),a.showSidewallsType=ko.pureComputed((()=>"Yes"===a.sidewalls()&&!a.isVantage())),a.showPrinting=ko.pureComputed((()=>a.isBusiness())),a.showBagWrap=ko.pureComputed((()=>!a.isPro60Family())),a.showBagNote=ko.pureComputed((()=>a.isPro60Family())),a.groundbarsAvailable=ko.observable(!0),a.showStabilityHelp=ko.pureComputed((()=>a.showStability()&&a.groundbarsAvailable())),a.sidewallsNoteText="Sidewalls: included as standard with the 6m x 6m package.",a.bagNoteText="Storage bag: included as standard with this frame.",a.effectiveSidewalls=ko.pureComputed((()=>a.isVantage()?"Included as standard":a.sidewalls())),a.effectiveSidewallsType=ko.pureComputed((()=>a.isVantage()?"Full set":a.sidewallsType())),a.effectiveBag=ko.pureComputed((()=>a.isPro60Family()?"Included as standard":a.bag())),a.effectiveStability=ko.pureComputed((()=>a.isVantage()?"Included as standard":a.stability())),a.availableColours=ko.pureComputed((()=>{const t=a.currentModel();if(!t||t.startsWith("No match"))return[];const r=o[t];return r?r.colours:e})),a.colourNote=ko.pureComputed((()=>{const e=a.currentModel();return e.startsWith("No match")?"No colour selection shown because the vehicle constraint prevents a valid model recommendation.":"Pro 60 (4m x 10m)"===e?"Note: 4m x 10m Pro 60 is available in White, Taupe, and Black only.":"Pro 60 Vantage"===e?"Note: Pro 60 Vantage 6m x 6m is available in White and Taupe only.":"Colours shown are available for the recommended model."})),a.availableColours.subscribe((e=>{a.colour()&&-1===e.indexOf(a.colour())&&a.colour("")})),a.updateGroundbarsAvailability=e=>{if(!e)return void a.groundbarsAvailable(!0);const t=`/choosing-the-right-gazebo/groundbars?size=${encodeURIComponent(e)}`;fetch(t).then((e=>e.json())).then((e=>{a.groundbarsAvailable(!(!e||!e.available))})).catch((()=>{a.groundbarsAvailable(!0)}))},a.size.subscribe((e=>{"3m x 3m"!==e&&a.smallVehicle(""),a.updateGroundbarsAvailability(e)})),a.smallVehicle.subscribe((e=>{})),a.canGoStep2=ko.pureComputed((()=>!!(a.size()&&a.useType()&&a.frequency())&&!("3m x 3m"===a.size()&&!a.smallVehicle()))),a.canGoStep3=ko.pureComputed((()=>!!(a.ground()&&a.water()&&a.effectiveStability()))),a.canGoStep4=ko.pureComputed((()=>!(!a.colour()||!a.lighting())&&(!!a.effectiveSidewalls()&&(!!a.effectiveBag()&&(!("Yes"===a.sidewalls()&&!a.isVantage()&&!a.sidewallsType())&&!(a.isBusiness()&&!a.printing())))))),a.selectColour=e=>{a.colour(e)},a.colourClass=e=>{const o=t[e]||"";return["dot","gtf-colour-choice",o?`prod-dot-${o}`:"","Leaftree"===e?"img-wrapper":"",e===a.colour()?"gtf-dot-selected":""].filter(Boolean).join(" ")},a.progressLabelClass=e=>{const t=a.currentStep();return e+1===t?"is-active":e+1{a.currentStep(e),4===e&&a.loadProductRecommendation(),window.scrollTo({top:0,behavior:"instant"})},a.reset=()=>{a.size(""),a.smallVehicle(""),a.useType(""),a.frequency(""),a.ground(""),a.water(""),a.stability(""),a.colour(""),a.sidewalls(""),a.sidewallsType(""),a.printing(""),a.bag(""),a.lighting(""),a.alternativeLinks([]),a.productCardHtml("Finding the closest match..."),a.latestRecommendation=null,a.currentStep(1),window.scrollTo({top:0,behavior:"instant"})},a.buildProductPayload=()=>({colour:a.colour()||"ANY COLOUR",usageType:a.useType(),smallCar:"Yes"===a.smallVehicle()?"Yes":"No",size:a.size(),usageQty:a.frequency(),ground:a.ground(),water:a.water(),sidewalls:"Yes"===a.effectiveSidewalls()||"Included as standard"===a.effectiveSidewalls()?"Yes":"No",extraStability:"Yes"===a.effectiveStability()?"Yes":"No",storageBag:"Yes"===a.effectiveBag()||"Included as standard"===a.effectiveBag()?"Yes":"No",lighting:a.lighting()}),a.formatPrice=(e,t)=>{const o=Number(e.ProductPrice);if(!Number.isFinite(o))return"";const r=Number(t||1),s=Number.isFinite(r)&&r>0?r:1,a=Number(e.ProductDiscount||0);if(a>0){const e=o*s;return`£${(o*(1-a/100)*s).toFixed(2)} (was £${e.toFixed(2)})`}return`£${(o*s).toFixed(2)}`},a.formatPriceValue=e=>Number.isFinite(e)?`£${e.toFixed(2)}`:"",a.getEffectivePrice=e=>{const t=Number(e.ProductPrice);if(!Number.isFinite(t))return 0;const o=Number(e.ProductDiscount||0);return o>0?t*(1-o/100):t},a.calculateTotal=(e,t)=>{let o=0;return e&&(o+=a.getEffectivePrice(e)),(t||[]).forEach((e=>{const t=Number(e.Qty||1);o+=a.getEffectivePrice(e)*(Number.isFinite(t)?t:1)})),o},a.getProductUrl=e=>e.URL||(e.ProductCode?`/product/${e.ProductCode}`:"#"),a.isInStock=e=>{const t=e.ProductInStock;if("number"==typeof t)return t>0;const o=Number(e.TotalAvailable||0);return!!(Number.isFinite(o)&&o>0)||("string"==typeof t&&"YES"===t.trim().toUpperCase()||"string"==typeof e.ProductAvailable&&"YES"===e.ProductAvailable.trim().toUpperCase())},a.renderProductLine=(e,t)=>{if(!e)return"";const o=e.ProductName||"Recommended gazebo",r=a.getProductUrl(e),s=Number(t||1),i=a.formatPrice(e,s),n=s>1,l=a.isInStock(e),d=l?"gtf-stock-yes":"gtf-stock-no",u=l?"✓":"×",c=l?"In stock":"Out of stock",m=e.ProductCode||"";return`\n
\n
\n ${u}\n ${o}\n ${n?`x${t}`:""}\n
\n
\n ${i?`${i}`:""}\n ${c}\n ${m?``:""}\n
\n
\n `},a.renderProductCard=e=>{if(!e||!e.structure)return"We could not find a matching product for these answers.";const t=e.structure,o=t.imagesSchema&&t.imagesSchema[0]||"",r=(e.extras||[]).filter((e=>e&&e.ProductName)),s=a.renderProductLine(t,1),i=r.map((e=>a.renderProductLine(e,e.Qty||1))).join(""),n=a.calculateTotal(t,r),l=a.formatPriceValue(n);return`\n
\n ${o?`${t.ProductName||`:""}\n
\n
\n
\n
Structure
\n ${s}\n
\n
\n
Add-ons
\n ${i||'
No add-ons selected.
'}\n
\n
\n
\n Total\n ${l}\n
\n \n
\n
\n
\n
\n `},a.productCardHtml=ko.observable("Finding the closest match..."),a.latestRecommendation=null,a.getBasketItemsFromRecommendation=e=>{if(!e||!e.structure)return[];const t=[{sku:e.structure.ProductCode,qty:1}];return(e.extras||[]).forEach((e=>{e&&e.ProductCode&&t.push({sku:e.ProductCode,qty:e.Qty||1})})),t},a.addItemsToBasket=e=>{e&&e.length&&fetch("/basket/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:e})}).then((e=>e.json())).then((e=>{if("function"==typeof setBasket&&setBasket({Qty:e.totalQty,Cost:e.totalPrice}),"function"==typeof showAlert){const e="undefined"!=typeof CONST_PRODUCT_ADD_TITLE?CONST_PRODUCT_ADD_TITLE:"Added!",t="undefined"!=typeof CONST_PRODUCT_ADDED?CONST_PRODUCT_ADDED:"Added",o="undefined"!=typeof CONST_PRODUCT_ADDED_APPEND?CONST_PRODUCT_ADDED_APPEND:"to your basket.";showAlert("icon-ok-circled",e,`${t} ${o}`,"#FFFFFF",!1)}})).catch((e=>{console.error("Error:",e),"function"==typeof showAlert&&showAlert("icon-cancel-circled","Error","Unable to add to basket.","#FFFFFF",!1)}))},a.handleProductAction=e=>{if(!e)return;const t=e.getAttribute("data-gtf-action");if("add"!==t){if("add-all"===t){const e=a.getBasketItemsFromRecommendation(a.latestRecommendation);a.addItemsToBasket(e)}}else{const t=e.getAttribute("data-code"),o=Number(e.getAttribute("data-qty")||1);if(!t)return;a.addItemsToBasket([{sku:t,qty:o||1}])}},a.loadProductRecommendation=()=>{a.productCardHtml("Finding the closest match..."),fetch("/choosing-the-right-gazebo/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.buildProductPayload())}).then((e=>e.json())).then((e=>{a.latestRecommendation=e,a.alternativeLinks(e&&e.alternatives||[]),a.productCardHtml(a.renderProductCard(e))})).catch((()=>{a.alternativeLinks([]),a.productCardHtml("We could not find a matching product for these answers.")}))},a.anchoringPlan=ko.pureComputed((()=>{const e=a.ground(),t=a.water(),o=a.effectiveStability();let r="";"Soft ground"===e&&(r="Stakes and storm kit"),"Hard ground"===e&&(r="Cast iron weights and storm kit"),"Both"===e&&(r="Mixed anchoring (weights for hard ground, stakes for soft ground) plus storm kit");let s="";"Yes"===t&&(s="Water weights can be useful if you have reliable water access on site."),"No"===t&&(s="Water weights are not recommended here because you do not have regular water access."),"Sometimes"===t&&(s="Water weights may work, but only if you can reliably fill them on site.");let i="";return"Pro 60 Vantage"===(a.currentModel()||"")?i="Ground bars are included as standard with the 6m x 6m package for a stiffer frame and reduced sway.":"Yes"===o&&(i="Add ground bars for increased rigidity, reduced sway, and a stiffer frame at ground level."),"No"===o&&(i="Standard anchoring should be fine if you follow the anchoring guidance above."),"Not sure"===o&&(i="If you are using it commercially or in exposed locations, ground bars are a sensible upgrade."),{primary:r,waterNote:s,bars:i}})),a.buildWhyNarrative=ko.pureComputed((()=>{a.currentModel();const e=[];return a.size()&&e.push(`You asked for ${a.size()} cover, so we have limited the recommendation to the models that are actually available in that footprint.`),"3m x 3m"===a.size()&&"Yes"===a.smallVehicle()&&e.push("Because you need to transport it in a small vehicle, the Pro Compact is the realistic choice for car transport in this size."),a.useType()&&a.frequency()&&("Very often"===a.frequency()?e.push("You will be using it very often, so we have biased toward the most heavy-duty frame available in your chosen size."):"Quite often"===a.frequency()?e.push("You will be using it quite often, so we have biased toward a stronger commercial frame rather than a lighter occasional-use option."):"Sometimes"===a.frequency()?e.push("You will be using it sometimes, so the recommendation balances strength with practicality."):"Rarely"===a.frequency()&&e.push("You will be using it rarely, so there is no need to over-spec the frame unless you expect challenging conditions."),"Business"===a.useType()?e.push("Because it is for business use, we have leaned toward a frame that will cope better with repeat setups and longer days on site."):e.push("Because it is for personal use, the recommendation focuses on sensible durability without pushing you into commercial overkill.")),a.ground()&&("Hard ground"===a.ground()&&e.push("You will be using it on hard ground, so weights become the primary anchoring method."),"Soft ground"===a.ground()&&e.push("You will be using it on soft ground, so stakes become the primary anchoring method."),"Both"===a.ground()&&e.push("You will be using it on mixed ground, so the safest approach is a combination of weights and stakes.")),"Yes"===a.stability()?e.push("You asked for increased stability, so ground bars are included to stiffen the frame at ground level and reduce sway."):"Not sure"===a.stability()&&e.push("If you are ever in exposed spots or running it commercially, ground bars are a sensible upgrade for extra rigidity."),`

${e.join(" ")}

`})),a.buildAccessoriesNarrative=ko.pureComputed((()=>{const e=[];a.colour()&&e.push(`Colour: ${a.colour()}.`);const t=a.effectiveSidewalls(),o=a.effectiveSidewallsType();t&&("Included as standard"===t?e.push("Sidewalls: included as standard."):"Yes"===t?e.push(`Sidewalls: Yes${o?` (${o})`:""}.`):"No"===t?e.push("Sidewalls: No."):e.push("Sidewalls: Not sure yet.")),a.isBusiness()&&a.printing()&&e.push(`Printing: ${a.printing()}.`);const r=a.effectiveBag();return r&&e.push(`Storage bag: ${r}.`),a.lighting()&&e.push(`Lighting: ${a.lighting()}.`),`

${e.join(" ")}

`})),a.resultBlocks=ko.pureComputed((()=>{const e=a.currentModel(),t=r[a.size()]||[],o=t.filter((t=>t!==e)),s=(a.anchoringPlan(),a.alternativeLinks()),i=s.length?s.map((e=>`${e.label}`)).join(", "):(o.length?o:t).join(", ");let n="",l="gtf-good";return"No match (vehicle constraint)"===e?(l="gtf-warn",n="You have selected a small vehicle and also said 3m x 3m is not enough cover. In practice, larger sizes usually require a larger vehicle for transport."):n="Based on your answers, this is the best fit model within the available sizes and transport constraints.",[{title:"Recommended model",body:`${e}
${n}
${a.buildWhyNarrative()}
`},{title:"Recommended product",body:`
${a.productCardHtml()}
`},{title:"Want to assess your options?",body:t.length?`These gazebos are also available in ${a.size()}: ${i}.`:"No other models found for this size."}]}))}function a(){const e=document.getElementById("gazebo-finder");if(!e||"undefined"==typeof ko)return;const t=new s(e);ko.applyBindings(t,e),e.addEventListener("click",(o=>{const r=o.target.closest("[data-gtf-action]");r&&e.contains(r)&&(o.preventDefault(),t.handleProductAction(r))}))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()}();