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.ProductCanPreOrder=e.ProductCanPreOrder,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)}}function promptLoginOrRegister(){try{"function"==typeof showAlert&&showAlert("icon-cancel-circled","Please sign in to add to your wishlist",'',"#FFFFFF",!1)}catch{}}function followToLogin(){const e=encodeURIComponent(window.location.pathname+window.location.search+window.location.hash);window.location.href="/login?url="+e}ProductModel.prototype.extractColourFromName=function(e){for(var t=["Red","Blue","Green","Yellow","Black","White","Purple","Orange","Pink","Grey","Taupe","Leaftree","LeafTree"],r=0;r{try{if(e&&e.gazebo_details_fragmentHTML){const t=document.getElementById("gazebo_details_fragmentHTML");if(t){t.innerHTML=e.gazebo_details_fragmentHTML,observeAnimations();try{pjslider_init()}catch(e){}}else console.error('Element with ID "gazebo_details_fragmentHTML" not found.');const r=document.querySelector("h1");if(r&&(r.innerHTML=e.ProductName),e.featuredVideo){const t=document.getElementById("featuredVideo");if(t&&"IFRAME"===t.tagName){const r=`https://www.youtube.com/embed/${e.featuredVideo}`;t.src!==r&&(t.src=r)}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.")}catch(e){}};var Gazebo,GazeboModel=function(){this.formattedProductShip=ko.observable(),this.Qty=ko.observable(1);var e=window.__builder.stickerSKU||"10536";this.Artwork=ko.observableArray(),this.getShipping=function(){const e=Gazebo.getBuilderProducts(),{productShipping:t}=e;return parseInt(t)},this.Sticker={Type:ko.observable(e),Product:ko.observable()},this.calculateGazeboProducts=function(){try{const e=transformedData.find((e=>"Stickers"==e.name)).products.find((e=>e.ProductCode===this.Sticker.Type()));this.Sticker.Product(e)}catch(e){console.log(e)}},this.calcCosts=()=>{let e=0,t=0;return[this.Sticker].forEach((function(r){if(r.Product()&&r.Product().ProductPrice){var o=r.Product().ProductPrice,i=r.Product().Qty,n=r.Product().ProductDiscount,c=getFinalPrice(o,n)*i;e+=c,t+=o*i-c}})),t=Number(parseFloat(t).toFixed(2)),e*=this.Qty(),t*=this.Qty(),{totalCost:e,totalSaving:t}},this.calcBundleCosts=()=>{let e=0,t=0;return[this.Sticker].forEach((function(r){if(r.Product()&&r.Product().ProductPrice){var o=r.Product().ProductPrice,i=r.Product().Qty,n=r.Product().ProductDiscount,c=getFinalPrice(o,n)*i;e+=c,t+=o*i-c}})),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;return[this.Sticker].forEach((function(r){if(r.Product()&&r.Product().ProductPrice){let o={sku:r.Product().ProductCode,qty:r.Product().Qty};r==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(o.Artwork="Yes"),r.Product().ProductShip>t&&(t=r.Product().ProductShip),e.push(o)}})),{skusToAdd:e,productShipping:t}},this.click_addbuilderproducts_bundle=function(){const e=this.getBundleProducts();this.add(e)},this.getBreakDown=function(){let e=[];return[this.Sticker].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.Sticker].forEach((function(r){if(r.Product()&&r.Product().ProductPrice){let o={sku:r.Product().ProductCode,qty:r.Product().Qty*Gazebo.Qty()};r==Gazebo.Canopy&&"Yes"==Gazebo.Printing.Option()&&(o.Artwork="Yes"),r.Product().ProductShip>t&&(t=r.Product().ProductShip),e.push(o)}})),{skusToAdd:e,productShipping:t}},this.click_addbuilderproducts=function(){const e=this.getBuilderProducts(),{productShipping:t}=e;if(t>1){const e=parseInt(t,10)+1;if(!isNaN(e)){const t=new Date,r=new Date(t);r.setDate(r.getDate()+e);const o=r.toLocaleDateString("en-GB"),i=document.getElementById("modalExpectDelDate");i&&(i.innerHTML=o)}modalOpen(document.getElementById("help-oos"))}else this.add(e)},this.click_addbuilderproducts_wishlist=function(){const e=this.getBuilderProducts();this.addToWishlist(e)},this.click_addDispiteOutOfStock=function(){const e=this.getBuilderProducts();this.add(e)},this.add=async e=>{const{skusToAdd:t,productShipping:r}=e;r>1&&modalOpen(document.getElementById("help-oos"));let o=[];try{o=await uploadLocalArtworkForBasket()}catch(e){return void showAlert("icon-alert","Upload Error","We couldn't upload your artwork. Please try again.","#FFFFFF",!1)}o.length&&t.forEach((e=>{e.artworkFiles=o}));try{console.log("SKUs to add",t);const e=await fetch("/basket/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:t})}),r=await e.json();setBasket({Qty:r.totalQty,Cost:r.totalPrice}),r.mysteryGifts?showOverlay({URL:"/popups/mystery-gift"}):showAlert("icon-ok-circled",CONST_PRODUCT_ADD_TITLE,CONST_PRODUCT_ADDED+" "+CONST_PRODUCT_ADDED_APPEND,"#FFFFFF",!1),"function"==typeof window.track_add_basket&&window.track_add_basket(),clearLocalArtworkAfterBasket()}catch(e){console.error("Error:",e)}},this.addToWishlist=e=>{const t=e&&e.skusToAdd?e.skusToAdd:[];t.length?fetch("/wishlist/add-multiple",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({items:t})}).then((async e=>{if(401===e.status)return promptLoginOrRegister(),Promise.reject(new Error("Not logged in"));let t={};try{t=await e.json()}catch{t={}}if(!e.ok||t&&!1===t.success){const e=t&&(t.error||t.message)||CONST_PRODUCT_WISHLIST_ERROR_MSG;throw new Error(e)}return t})).then((()=>{showAlert("icon-star",CONST_PRODUCT_WISHLIST_TITLE,CONST_PRODUCT_WISHLIST_ADDED+" "+CONST_PRODUCT_WISHLIST_APPEND,"#FFFFFF",!1),"function"==typeof customtrackEvent&&customtrackEvent("wishlist_add","gazebo_builder")})).catch((e=>{if(e&&"Not logged in"===e.message)return;console.error("Wishlist error:",e);const t=e&&e.message?e.message:CONST_PRODUCT_WISHLIST_ERROR_MSG;showAlert("icon-cancel-circled",CONST_PRODUCT_WISHLIST_ERROR_TITLE,t,"#FFFFFF",!1)})):showAlert("icon-info-circled",CONST_PRODUCT_WISHLIST_TITLE,CONST_PRODUCT_WISHLIST_EMPTY,"#FFFFFF",!1)},this.Sticker.Type.subscribe((function(e){resetStickerArtworkOnProductChange(),Gazebo.calculateGazeboProducts(),Gazebo.updateTabs()})),this.Sticker.Product.subscribe((function(e){e&&e.images&&setTimeout((function(){var t=[],r=e.images;for(var o in r)t.push(new galleryModel(r[o]));var i=e.videos;for(var o in i)t.push(new galleryModel(i[o]));gallery=t,"undefined"!=typeof createGallery&&createGallery()}),0),stickerPreviewUpdateSizeFromProduct()})),this.updateTabs=function(){Gazebo.Sticker.Product()&&fetch("/printing/floor-stickers/fragment?code="+Gazebo.Sticker.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(e.URL)})).catch((e=>{console.error("Fetch error:",e)}))}};function updateUrlAndReload(e){try{"string"==typeof e&&e.startsWith("/")&&(e=e.substring(1));const t=window.location.origin,r=new URL(e,t),o=window.location.origin+window.location.pathname+window.location.search,i=r.origin+r.pathname+r.search;if(o===i)return;window.history.pushState({path:i},"",i);const n=document.querySelector('link[rel="canonical"]');n&&(n.href=i);const c=document.querySelector(".breadcrumb .current-page");if(c){const e=r.pathname.split("/").filter(Boolean),t=e[e.length-1]||"",o=decodeURIComponent(t.replace(/-/g," "));c.textContent=o}else console.warn(".breadcrumb .current-page element not found.")}catch(e){console.error("Error updating URL:",e)}}function updateStickerType(){const e=document.getElementById("sticker-select").value;Gazebo.Sticker.Type(e)}function initStickerPreview(){const e=document.querySelector('input[name="multfile"]');e&&(e.addEventListener("change",(function(){})),stickerPreviewInit())}document.addEventListener("DOMContentLoaded",(function(){(Gazebo=new GazeboModel).calculateGazeboProducts(),setTimeout((function(){Gazebo.updateTabs()}),0);try{ko.applyBindings(Gazebo)}catch(e){}document.querySelectorAll(".hiddenUntilKO").forEach((function(e){e.classList.remove("hiddenUntilKO")}));try{initStickerPreview()}catch(e){}})),window.addEventListener("popstate",(function(e){window.location.reload(!1)}));const stickerPreviewState={canvas:null,ctx:null,img:null,scale:1,offsetX:0,offsetY:0,baseScale:1,canvasSize:700,baseSquareSize:480,sizeScale:1,sizeLabel:"1m x 1m",shape:"square",currentKey:null,currentArtworkId:null,dragging:!1,lastX:0,lastY:0},stickerLocalArtwork=[];function stickerPreviewInit(){const e=document.getElementById("stickerPreviewCanvas");if(!e)return;stickerPreviewState.canvas=e,stickerPreviewState.ctx=e.getContext("2d");const t=document.getElementById("stickerPreviewScale"),r=document.getElementById("stickerPreviewShape"),o=document.getElementById("stickerPreviewFit"),i=document.getElementById("stickerPreviewReset"),n=document.getElementById("stickerPreviewSave");t&&t.addEventListener("input",(function(){stickerPreviewState.scale=parseFloat(t.value),stickerPreviewRender()})),r&&r.addEventListener("change",(function(){stickerPreviewState.shape=r.value||"square",stickerPreviewRender()})),o&&o.addEventListener("click",(function(){stickerPreviewFit()})),i&&i.addEventListener("click",(function(){stickerPreviewResetPosition()})),n&&n.addEventListener("click",(function(){stickerPreviewSaveCurrent()})),e.addEventListener("mousedown",stickerPreviewStartDrag),window.addEventListener("mousemove",stickerPreviewDrag),window.addEventListener("mouseup",stickerPreviewEndDrag),e.addEventListener("touchstart",stickerPreviewStartDrag,{passive:!0}),window.addEventListener("touchmove",stickerPreviewDrag,{passive:!0}),window.addEventListener("touchend",stickerPreviewEndDrag,{passive:!0}),window.addEventListener("resize",(function(){stickerPreviewResize(),stickerPreviewRender()})),stickerPreviewResize(),stickerPreviewRender()}function stickerPreviewResize(){const e=stickerPreviewState;if(!e.canvas)return;const t=e.canvas.parentElement,r=Math.min(700,t&&t.clientWidth?t.clientWidth:700),o=window.devicePixelRatio||1;e.canvas.width=Math.round(r*o),e.canvas.height=Math.round(r*o),e.canvas.style.width=r+"px",e.canvas.style.height=r+"px",e.ctx.setTransform(o,0,0,o,0,0),e.canvasSize=r,e.baseSquareSize=Math.round(.7*r)}function stickerPreviewOpenUrl(e){if(!e)return;stickerPreviewState.currentKey=stickerPreviewBuildKey(e),stickerPreviewState.currentArtworkId=null;const t=new Image;t.crossOrigin="anonymous",t.onload=function(){stickerPreviewState.img=t,stickerPreviewUpdateSizeFromProduct(),stickerPreviewLoadConfig(),stickerPreviewApplyLoadedConfig()||stickerPreviewFit(),stickerPreviewOpenModal()};const r=e.includes("?")?"&":"?";t.src=e+r+"cb="+Date.now()}function stickerPreviewOpenLocalFile(e){if(!e||!e.file)return;const t=stickerPreviewBuildLocalKey(e.id);stickerPreviewState.currentKey=t,stickerPreviewState.currentArtworkId=e.id;const r=new FileReader;r.onload=function(e){const t=new Image;t.onload=function(){stickerPreviewState.img=t,stickerPreviewUpdateSizeFromProduct(),stickerPreviewLoadConfig(),stickerPreviewApplyLoadedConfig()||stickerPreviewFit(),stickerPreviewOpenModal()},t.src=e.target.result},r.readAsDataURL(e.file)}function stickerPreviewFit(){const e=stickerPreviewState;if(!e.img)return;const t=e.baseSquareSize||480;e.baseScale=Math.min(t/e.img.width,t/e.img.height),e.scale=1,e.offsetX=0,e.offsetY=0;const r=document.getElementById("stickerPreviewScale");r&&(r.value=e.scale),stickerPreviewRender()}function stickerPreviewResetPosition(){stickerPreviewState.offsetX=0,stickerPreviewState.offsetY=0,stickerPreviewRender()}function stickerPreviewOpenModal(){const e=document.getElementById("sticker-preview");e&&("function"==typeof modalOpen?modalOpen(e):window.jQuery&&window.jQuery(e).modal("show"))}function stickerPreviewStartDrag(e){const t=stickerPreviewState;if(!t.img)return;const r=stickerPreviewGetPoint(e);t.dragging=!0,t.lastX=r.x,t.lastY=r.y}function stickerPreviewDrag(e){const t=stickerPreviewState;if(!t.dragging)return;const r=stickerPreviewGetPoint(e),o=r.x-t.lastX,i=r.y-t.lastY;t.offsetX+=o,t.offsetY+=i,t.lastX=r.x,t.lastY=r.y,stickerPreviewRender()}function stickerPreviewEndDrag(){stickerPreviewState.dragging=!1}function stickerPreviewGetPoint(e){const t=stickerPreviewState.canvas.getBoundingClientRect(),r=e.touches&&e.touches[0],o=r?r.clientX:e.clientX,i=r?r.clientY:e.clientY;return{x:o-t.left,y:i-t.top}}function stickerPreviewRender(){const e=stickerPreviewState;if(!e.canvas||!e.ctx)return;const t=e.ctx,r=e.canvasSize||700,o=e.baseSquareSize||480;t.clearRect(0,0,r,r),t.fillStyle="#ffffff",t.fillRect(0,0,r,r);const i=(r-o)/2,n=(r-o)/2,c=o/2,a=r/2,s=r/2;if(!e.img)return t.save(),t.setLineDash([6,6]),t.strokeStyle="#E10198",t.lineWidth=1,"circle"===e.shape?(t.beginPath(),t.arc(a,s,c,0,2*Math.PI),t.stroke()):t.strokeRect(i,n,o,o),stickerPreviewDrawDimensions(t,e,i,n,o,a,s,c),void t.restore();const d=e.baseScale*e.scale,l=e.img.width*d,u=e.img.height*d,f=r/2+e.offsetX,w=r/2+e.offsetY;t.drawImage(e.img,f-l/2,w-u/2,l,u),t.save(),t.fillStyle="rgba(0, 0, 0, 0.60)",t.beginPath(),t.rect(0,0,r,r),"circle"===e.shape?t.arc(a,s,c,0,2*Math.PI,!0):t.rect(i,n,o,o),t.fill("evenodd"),t.restore(),t.save(),t.setLineDash([6,6]),t.strokeStyle="#E10198",t.lineWidth=1.5,"circle"===e.shape?(t.beginPath(),t.arc(a,s,c,0,2*Math.PI),t.stroke()):t.strokeRect(i,n,o,o),stickerPreviewDrawDimensions(t,e,i,n,o,a,s,c),t.restore()}function stickerPreviewDrawDimensions(e,t,r,o,i,n,c,a){const s=t.sizeLabel||"1m x 1m";e.setLineDash([]),e.fillStyle="#ececec",e.font="16px Arial",e.textBaseline="middle","circle"===t.shape?(e.textAlign="center",e.fillText(s,n,c-a-12),e.textAlign="left",e.fillText(s,n+a+8,c)):(e.textAlign="center",e.fillText(s,r+i/2,o-12),e.textAlign="left",e.fillText(s,r+i+8,o+i/2))}function stickerPreviewUpdateSizeFromProduct(){const e=stickerPreviewState;let t="1m x 1m",r=1;try{const e=Gazebo&&Gazebo.Sticker&&Gazebo.Sticker.Product?Gazebo.Sticker.Product():null,o=e&&e.Size?String(e.Size):"";if(o){t=o;const e=o.match(/(\d+(\.\d+)?)/);if(e){const t=parseFloat(e[1]);!isNaN(t)&&t>0&&(r=t)}}}catch(e){}e.sizeLabel=t,e.sizeScale=r,e.img?stickerPreviewFit():stickerPreviewRender()}const builderUploadArtwork=()=>{const e=document.querySelector('input[name="multfile"]'),t=Gazebo.Sticker.Product().ProductCode,r=Array.from(e.files||[]);if(!r.length)return void showAlert("icon-alert","Error!","Please select a file to upload!","#FFFFFF",!1);const o=r.filter((e=>e&&e.type&&e.type.startsWith("image/")));o.length?(addLocalArtwork(o,t),e.value=""):showAlert("icon-alert","Error!","Please upload an image file (JPG, PNG, GIF, BMP, TIFF).","#FFFFFF",!1)};function deleteLocalArtwork(e,t){confirm("Delete artwork "+t)&&(removeLocalArtwork(e),showAlert("icon-trash","Deleted!","","#FFFFFF",!1))}function addLocalArtwork(e,t){const r=Gazebo&&Gazebo.Sticker&&Gazebo.Sticker.Product?Gazebo.Sticker.Product():null,o=r?r.ProductName:"";e.forEach((e=>{const r="art_"+Date.now()+"_"+Math.random().toString(16).slice(2);stickerLocalArtwork.push({id:r,file:e,name:e.name,shortname:e.name,productcode:t,productname:o,configImageData:null})})),syncLocalArtworkView()}function removeLocalArtwork(e){const t=stickerLocalArtwork.findIndex((t=>t.id===e));-1!==t&&(stickerLocalArtwork.splice(t,1),stickerPreviewClearConfigByKey(stickerPreviewBuildLocalKey(e)),syncLocalArtworkView())}function syncLocalArtworkView(){if(!Gazebo||!Gazebo.Artwork)return;const e={};stickerLocalArtwork.forEach((t=>{e[t.productcode]||(e[t.productcode]={productcode:t.productcode,productname:t.productname,files:[]}),e[t.productcode].files.push({id:t.id,name:t.name,shortname:t.shortname})})),Gazebo.Artwork(Object.values(e))}async function uploadLocalArtworkForBasket(){if(!stickerLocalArtwork.length)return[];showAlert("icon-spin5 fa-spin ","Uploading","Uploading artwork...","#FFFFFF",!0);const e=[];for(const t of stickerLocalArtwork){const r=buildUniqueDropboxFilename(t.productcode,t.name,t.id);await uploadSingleArtwork(t);const o=t.configImageData||getStoredConfigImageData(t.id);let i=null;o&&(await uploadArtworkConfigImage(t.productcode,t.name,t.id,o),i=`${r}--config.png`),e.push({type:"original",uploadId:t.id,filename:r,path:`/session/artwork/${r}`}),i&&e.push({type:"config",uploadId:t.id,filename:i,path:`/session/artwork/${i}`})}try{document.body.classList.remove("noexit"),"function"==typeof clicked&&clicked({target:document.body})}catch(e){}return e}function uploadSingleArtwork(e){const t=new FormData;return t.append("multfile",e.file),t.append("ProductCode",e.productcode),t.append("UploadId",e.id),fetch("/session/artwork",{method:"PUT",body:t}).then((e=>{if(!e.ok)throw new Error("Upload failed");return e.json()}))}function uploadArtworkConfigImage(e,t,r,o){return fetch("/session/artwork-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ProductCode:e,OriginalName:t,UploadId:r,imageData:o})}).then((e=>{if(!e.ok)throw new Error("Config upload failed");return e.json()}))}function clearLocalArtworkAfterBasket(){stickerLocalArtwork.length=0,stickerPreviewClearAllConfigs(),Gazebo&&Gazebo.Artwork&&Gazebo.Artwork([]);const e=document.getElementById("stickerUploadInput");e&&(e.value="")}function getStoredConfigImageData(e){const t=stickerPreviewBuildLocalKey(e),r=stickerPreviewGetStore();return r&&r[t]&&r[t].configImageData?r[t].configImageData:null}function buildUniqueDropboxFilename(e,t,r){const o=String(r||"").replace(/[^a-zA-Z0-9_-]/g,"").slice(0,24),i=t.lastIndexOf(".");return`SKU${e}--${-1===i?t:t.slice(0,i)}${o?`--${o}`:""}${-1===i?"":t.slice(i)}`}const deleteArtworkBtn=e=>{const t=e.getAttribute("data-art-name");deleteLocalArtwork(e.getAttribute("data-art-id"),t)};function resetStickerArtworkOnProductChange(){stickerPreviewState.currentKey=null,stickerPreviewState.currentArtworkId=null,stickerPreviewClearAllConfigs(),stickerLocalArtwork.length=0,Gazebo&&Gazebo.Artwork&&Gazebo.Artwork([]);const e=document.getElementById("stickerUploadInput");e&&(e.value="")}function stickerPreviewBuildKey(e){return e?"sticker-preview::"+e:null}function stickerPreviewBuildLocalKey(e){return e?"sticker-preview::local::"+e:null}function stickerPreviewGetStore(){try{const e=window.localStorage.getItem("stickerPreviewConfigs");return e?JSON.parse(e):{}}catch(e){return{}}}function stickerPreviewSetStore(e){try{window.localStorage.setItem("stickerPreviewConfigs",JSON.stringify(e||{}))}catch(e){}}function stickerPreviewClearConfigByKey(e){if(!e)return;const t=stickerPreviewGetStore();t&&t[e]&&(delete t[e],stickerPreviewSetStore(t))}function stickerPreviewClearAllConfigs(){try{window.localStorage.removeItem("stickerPreviewConfigs")}catch(e){}}function stickerPreviewSaveCurrent(){const e=stickerPreviewState;if(!e.img||!e.currentKey)return void showAlert("icon-alert","Error!","Please open the artwork to save its configuration.","#FFFFFF",!1);const t=stickerPreviewGetStore();t[e.currentKey]={offsetX:e.offsetX,offsetY:e.offsetY,scale:e.scale,shape:e.shape,sizeScale:e.sizeScale,sizeLabel:e.sizeLabel},stickerPreviewSetStore(t);stickerPreviewSaveCanvasImage()&&(showAlert("icon-ok-circled","Saved","Artwork configuration saved.","#FFFFFF",!1),"function"==typeof modalClose?modalClose():window.jQuery&&window.jQuery("#sticker-preview").modal("hide"))}function stickerPreviewSaveCanvasImage(){const e=stickerPreviewState;if(!e.canvas||!e.currentArtworkId)return!1;let t="";try{t=e.canvas.toDataURL("image/png")}catch(e){return!1}const r=stickerLocalArtwork.find((t=>t.id===e.currentArtworkId));if(!r)return!1;r.configImageData=t;const o=stickerPreviewGetStore();return o&&e.currentKey&&o[e.currentKey]&&(o[e.currentKey].configImageData=t,stickerPreviewSetStore(o)),!0}function stickerPreviewLoadConfig(){const e=stickerPreviewState;if(!e.currentKey)return;const t=stickerPreviewGetStore();e._loadedConfig=t[e.currentKey]||null}function stickerPreviewApplyLoadedConfig(){const e=stickerPreviewState,t=e._loadedConfig;if(!t)return!1;"number"==typeof t.offsetX&&(e.offsetX=t.offsetX),"number"==typeof t.offsetY&&(e.offsetY=t.offsetY),"number"==typeof t.scale&&(e.scale=t.scale),"string"==typeof t.shape&&(e.shape=t.shape),"number"==typeof t.sizeScale&&(e.sizeScale=t.sizeScale),"string"==typeof t.sizeLabel&&(e.sizeLabel=t.sizeLabel);const r=document.getElementById("stickerPreviewShape");r&&(r.value=e.shape||"square");const o=document.getElementById("stickerPreviewScale");return o&&(o.value=e.scale||1),stickerPreviewRender(),e._loadedConfig=null,!0}function isStickerImageFile(e){if(!e)return!1;const t=String(e).toLowerCase();return t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".png")||t.endsWith(".gif")||t.endsWith(".bmp")||t.endsWith(".tiff")}function configureStickerArtworkBtn(e){if(!e)return;const t=e.getAttribute("data-art-id"),r=stickerLocalArtwork.find((e=>e.id===t));r&&isStickerImageFile(r.name)&&stickerPreviewOpenLocalFile(r)}function transformInputToProductModels(){var e=[];return window.__input.forEach((function(t){var r={};r.name=t.name,r.products=t.data.map((function(e){return new ProductModel(e)})),e.push(r)})),e}var transformedData=transformInputToProductModels();