(()=>{let e="",t="",n="";!async function(){if(window.location.href.includes("?tigsaw-preview=true")){const o=new URLSearchParams(window.location.search).get("userTemplateId"),i="1DVZLQZA";await async function(o,i){try{const r=await fetch(`https://tigsaw.com/api/delivery/${i}?tigsaw-preview=true`);if(!r.ok)throw new Error("Iframe: Network response was not ok");const a=await r.json(),s=a.userObjectData?.listOfActiveWidgets,d=a.userObjectData?.listOfInactiveWidgets,c=s[o]||d[o];c?(e=c.html,t=c.css,n=c.js):console.error("Iframe: Template not found in either active or inactive list")}catch(e){console.error("Iframe: Error fetching template:",e)}}(o,i),(e=>{const t=document.createElement("style");t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),document.head.appendChild(t)})("\n          div#tigsaw-hover-drawer {\n            background: #FFF;\n            box-shadow: 1px 1px 12px 0px #00000057;\n            padding: 3px;\n            display: flex;\n            flex-direction: column;\n            gap: 5px;\n            z-index: 9999;\n          }\n          div#tigsaw-bottom-drawer-header > button {\n              color: black;\n          }\n    \n          div#tigsaw-hover-drawer button {\n            background: var(--Bg-2, linear-gradient(90deg, #EA0188 0%, #E18700 61.12%));\n            border: 0;\n            padding: 8px 15px;\n            color: #FFF;\n            font-family: sans-serif;\n            font-size: 15px;\n            font-style: normal;\n            font-weight: 400;\n            line-height: normal;\n            width: 100%;\n            cursor: pointer;\n          }\n    \n          .tigsaw-hover-highlight {\n            outline: 2px dashed #EA0188;\n          }\n    \n          #tigsaw-bottom-drawer {\n            position: fixed;\n            bottom: 0;\n            left: 0;\n            width: -webkit-fill-available;\n            min-height: 70px;\n            background: var(--Bg-2, linear-gradient(90deg, #EA0188 0%, #E18700 61.12%));\n            z-index: 9999999999999;\n            padding: 20px;\n          }\n    \n          div#tigsaw-bottom-drawer-header {\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n          }\n    \n          div#tigsaw-bottom-drawer-header > button {\n            border: 0;\n            background: white;\n            padding: 5px 10px;\n            cursor: pointer;\n            font-family: sans-serif;\n            height: 30px;\n          }\n    \n          div#tigsaw-bottom-drawer.minimized {\n            overflow: hidden;\n            right: 7px;\n            left: unset;\n            background: unset;\n            width: max-content;\n            padding: 0;\n            bottom: 7px;\n            min-height: unset;\n          }\n    \n          div#tigsaw-bottom-drawer-header div {\n            color: white;\n            font-size: 21px;\n            font-family: sans-serif;\n          }\n    \n          div#tigsaw-bottom-drawer.minimized ul {\n            display: none !important;\n          }\n    \n          div#tigsaw-bottom-drawer.minimized div#tigsaw-bottom-drawer-header > div {\n            display: none;\n          }\n    \n          div#tigsaw-bottom-drawer.minimized div#tigsaw-bottom-drawer-header > button {\n            background: var(--Bg-2, linear-gradient(90deg, #EA0188 0%, #E18700 61.12%));\n            height: 50px;\n            width: 50px;\n            border-radius: 8px;\n          }\n    \n          div#tigsaw-bottom-drawer.minimized div#tigsaw-bottom-drawer-header > button svg {\n            max-height: 30px;\n          }\n    \n          div#tigsaw-bottom-drawer > ul {\n            margin: 0;\n            padding: 0;\n            display: flex;\n            flex-direction: column;\n            row-gap: 7px;\n            margin-top: 5px;\n            border-top: 1px solid #ffffff14;\n            padding-top: 10px;\n          }\n    \n          div#tigsaw-bottom-drawer > ul li {\n            display: flex;\n            justify-content: space-between;\n            font-size: small;\n            color: white;\n          }\n    \n          div#tigsaw-bottom-drawer > ul li button {\n            border: 0;\n            font-size: 10px;\n            cursor: pointer;\n            padding: 3px 10px;\n          }\n    \n          div#tigsaw-bottom-drawer > ul li button:hover {\n            opacity: 0.9;\n          }\n    \n          div#tigsaw-bottom-drawer-header > button:hover {\n            opacity: 0.9;\n          }\n          #tigsaw-bottom-drawer * {\n              font-family: sans-serif;\n          }\n\n          div#tigsaw-bottom-drawer-publish {\n            position: absolute;\n            right: 20px;\n            font-size: 14px !important;\n            background: #4CAF50;\n            display: flex;\n            align-items: center;\n            font-weight: bold;\n            color: #ffffff !important;\n            cursor: pointer;\n            height: 30px;\n            padding: 0 20px;\n            font-family: sans-serif;\n          }\n    \n          div#tigsaw-bottom-drawer-header > button {\n            margin-right: 180px;\n          }\n    \n          div#tigsaw-bottom-drawer.minimized button {\n            margin: 0;\n          }\n        "),window.tigsawActionList=[];const r=()=>{let e=document.getElementById("tigsaw-bottom-drawer");e||(e=document.createElement("div"),e.id="tigsaw-bottom-drawer",document.body.appendChild(e)),e.innerHTML="";const t=document.createElement("div");t.id="tigsaw-bottom-drawer-header";const n=document.createElement("div");n.id="tigsaw-bottom-drawer-publish",n.textContent="Save and Continue";const o=document.createElement("div");o.textContent="Tigsaw Action Panel";const i=document.createElement("button");i.textContent="Minimize",e.classList.contains("minimized")&&e.classList.remove("minimized"),i.addEventListener("click",(()=>{e.classList.contains("minimized")?(e.classList.remove("minimized"),i.textContent="Minimize"):(e.classList.add("minimized"),i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="21" height="39" viewBox="0 0 21 39" fill="none">\n                <path d="M4.34993 19.775H0.169922V13.895C0.369922 13.885 0.589927 13.855 0.799927 13.855C6.99993 13.855 13.1899 13.855 19.3899 13.845C19.8899 13.845 20.0699 13.965 20.0599 14.495C20.0299 16.055 20.0499 17.615 20.0499 19.175C20.0499 19.355 20.0299 19.535 20.0099 19.765H12.6899C12.6899 20.005 12.6899 20.195 12.6899 20.395C12.6899 23.495 12.6899 26.595 12.6899 29.695C12.6899 30.105 12.7299 30.515 12.8199 30.915C13.0699 32.035 13.7999 32.705 14.9099 32.905C16.3699 33.165 17.7699 32.995 19.0699 32.245C19.2099 32.165 19.3499 32.095 19.5399 31.985C19.8099 33.595 20.0599 35.145 20.3299 36.695C20.3999 37.065 20.1899 37.205 19.9299 37.355C17.8699 38.505 15.6399 38.945 13.3099 38.925C11.6799 38.905 10.0799 38.745 8.54993 38.135C6.07993 37.145 4.76992 35.255 4.47992 32.665C4.32992 31.345 4.34992 30.005 4.33992 28.675C4.31992 25.965 4.33992 23.255 4.33992 20.545C4.33992 20.325 4.33992 20.095 4.33992 19.785L4.34993 19.775Z" fill="white"/>\n                <path d="M4.47986 8.09503C4.47986 7.39503 4.46986 6.69503 4.47986 6.00503C4.52986 3.42503 6.48987 1.17503 8.92987 0.895027C11.6599 0.575027 14.0999 2.18503 14.7899 4.77503C15.6799 8.06503 13.1499 11.355 9.73987 11.365C8.23987 11.365 6.73986 11.345 5.24986 11.375C4.66986 11.385 4.43986 11.235 4.46986 10.625C4.50986 9.78503 4.47986 8.94503 4.47986 8.10503V8.09503Z" fill="white"/>\n                </svg>')})),t.appendChild(o),t.appendChild(i),t.appendChild(n),e.appendChild(t);const a=document.createElement("ul");a.style.listStyleType="none",window.tigsawActionList.forEach(((e,t)=>{const n=document.createElement("li"),o=document.createElement("span");o.textContent=`${e.actionType.toUpperCase()} - ${e.selector}`;const i=document.createElement("button");i.textContent="Remove",i.addEventListener("click",(()=>{const e=window.tigsawActionList[t];if("hide"===e.actionType){const t=document.querySelector(e.selector);t&&t.style.removeProperty("display")}else e.insertedElement&&e.insertedElement.parentNode&&e.insertedElement.parentNode.removeChild(e.insertedElement);window.tigsawActionList.splice(t,1),r()})),n.appendChild(o),n.appendChild(i),a.appendChild(n)})),e.appendChild(a)},a=e=>{const t=window.getComputedStyle(e);e.dataset.originalDisplay=t.display};window.addTigsawAction=(e,t,n)=>{e&&t?(window.tigsawActionList.push({selector:e,actionType:t,insertedElement:n}),r()):console.error("Both selector and actionType are required.")},r();const s=(e,t,n,o,i)=>{const r=document.querySelector(e);if(!r)return void console.error("Element not found for the given selector:",e);const a=t?(()=>{const e=document.createElement("div");let n;if(e.innerHTML=t.trim(),"before"===i)n=e,r.parentNode.insertBefore(n,r);else{if("after"!==i)return console.error("Invalid action. Use 'before' or 'after'."),null;n=e,r.parentNode.insertBefore(n,r.nextSibling)}return n})():null;if(n){const e=document.createElement("style");e.type="text/css",e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n)),document.head.appendChild(e)}if(o){const e=document.createElement("script");e.type="text/javascript",e.textContent=o,document.body.appendChild(e)}return a},d=e=>{if(!e)return null;const t=e=>Array.from(e.parentNode.children).filter((t=>t.tagName===e.tagName)).indexOf(e)+1;return(e=>{let n=[];for(;e&&e.nodeType===Node.ELEMENT_NODE;){const o=e.tagName.toLowerCase(),i=e.parentNode?`:nth-of-type(${t(e)})`:"";n.unshift(`${o}${i}`),e=e.parentNode}return n.join(" > ")})(e)};(()=>{let o=!1;const i=()=>{const e=document.getElementById("tigsaw-hover-drawer");e&&e.remove(),o=!1};return{init:()=>{document.body.addEventListener("mouseover",(e=>{const t=e.target;t.id?.includes("tigsaw-hover-drawer")||t.closest("#tigsaw-hover-drawer")||t.id?.includes("tigsaw-bottom-drawer")||t.closest("#tigsaw-bottom-drawer")||t.classList.add("tigsaw-hover-highlight")})),document.body.addEventListener("mouseout",(e=>{e.target.classList.remove("tigsaw-hover-highlight")})),document.body.addEventListener("click",(r=>{const c=r.target.closest("a");c&&c.hasAttribute("href")&&(r.preventDefault(),console.log("Redirection prevented:",target.href));const l=r.target,{clientX:m,clientY:p}=r;l.id?.includes("tigsaw-hover-drawer")||l.closest("#tigsaw-hover-drawer")||(i(),((r,c,l)=>{const m=document.getElementById("tigsaw-hover-drawer");if(o&&m?.contains(r))return;i();const p=document.createElement("div");p.id="tigsaw-hover-drawer",p.style.position="fixed",p.style.left=`${c}px`,p.style.top=`${l}px`;const w=window.innerWidth,g=window.innerHeight;c+200>w&&(p.style.left=w-200-10+"px"),l+120>g&&(p.style.top=g-120-10+"px");const h=document.createElement("button");h.textContent="Insert Before",h.style.marginRight="10px";const u=document.createElement("button");u.textContent="Insert After";const f=document.createElement("button");f.textContent="Hide",h.addEventListener("click",(()=>{const o=d(r),a=s(o,e,t,n,"before");addTigsawAction(o,"before",a),i()})),u.addEventListener("click",(()=>{const o=d(r),a=s(o,e,t,n,"after");addTigsawAction(o,"after",a),i()})),f.addEventListener("click",(()=>{const e=d(r);a(r),r.style.setProperty("display","none","important"),addTigsawAction(e,"hide",null),i()})),p.appendChild(h),p.appendChild(u),p.appendChild(f),document.body.appendChild(p),o=!0})(l,m,p))}))}}})().init(),document.addEventListener("click",(e=>{if(e.target.matches("div#tigsaw-bottom-drawer-publish")){const t=e.target,n=t.textContent;t.textContent="Saving...",t.style.opacity="0.7",t.style.cursor="not-allowed";const i=JSON.stringify(window.tigsawActionList);if(window.tigsawActionList.length>0){const r=`https://tigsaw.com/editor/${o}`;if(window.opener&&!window.opener.closed)try{window.opener.postMessage(i,r),console.log("Data sent to parent window:",i),setTimeout((()=>{t.textContent="Saved!",t.style.background="linear-gradient(90deg, #4CAF50 0%, #45a049 100%)",setTimeout((()=>{window.close(),window.opener.focus()}),500)}),500)}catch(e){console.error("Error saving:",e),t.textContent="Error!",t.style.background="linear-gradient(90deg, #f44336 0%, #d32f2f 100%)",setTimeout((()=>{t.textContent=n,t.style.removeProperty("background"),t.style.opacity="1",t.style.cursor="pointer"}),2e3)}else console.error("Parent window is not available."),t.textContent="Error!",t.style.background="linear-gradient(90deg, #f44336 0%, #d32f2f 100%)",alert("Parent window is not available. Changes may not be saved."),setTimeout((()=>{t.textContent=n,t.style.removeProperty("background"),t.style.opacity="1",t.style.cursor="pointer"}),2e3)}else console.error("No data to send."),t.textContent="No Changes",t.style.background="linear-gradient(90deg, #FFC107 0%, #FFA000 100%)",setTimeout((()=>{t.textContent=n,t.style.removeProperty("background"),t.style.opacity="1",t.style.cursor="pointer"}),2e3)}}))}}(),fetch("https://tigsaw.com/api/delivery/1DVZLQZA?tigsaw-live=true").then((e=>{if(!e.ok)throw new Error("Network response was not ok "+e.statusText);return e.json()})).then((e=>{const t=e.userObjectData.listOfActiveWidgets;Object.keys(t).forEach((e=>{const n=t[e];console.log("Widget:",e);const o=e,i=n.html,r=n.css,a=n.js,s=n.actions,d=n.deviceType,c=(n.liveUrl,n.containsText),l=n.location,m=/Mobi|Android/i.test(navigator.userAgent),p=/Tablet|iPad/i.test(navigator.userAgent),w=!/Mobi|Android|Tablet|iPad/i.test(navigator.userAgent);("Mobile"===d&&m||"Tablet"===d&&p||"Desktop"===d&&w||"All"===d)&&("Exactly matches"===l&&(window.location.href===c||window.location.href===c+"/")||"Contains"===l&&window.location.href.includes(c)||"Starts with"===l&&window.location.href.startsWith(c))&&(function(e){const t=`lastTrackingTime_${e}`,n=localStorage.getItem(t),o=Date.now();!n||o-parseInt(n,10)>=144e5?fetch(`https://tigsaw.com/api/tracking/visitors/${e}`,{method:"POST"}).then((e=>e.json())).then((()=>{console.log(`Visitor tracked for userTemplateID: ${e}`),localStorage.setItem(t,o.toString())})).catch((e=>console.error("Error:",e))):console.log(`Visitor tracking delayed until 4 hours have passed for userTemplateID: ${e}`)}(o),s.forEach((e=>{const t=e.action,n=e.selector,s="wantToTrack"===e.action?e.title:"";!function(e,t,n,o,i,r,a){const s=e=>{const t=document.createElement("script");t.innerHTML=e,document.body.appendChild(t)};!function(e,...t){const n=t.map((e=>new Promise((t=>{const n=setInterval((()=>{e()&&(clearInterval(n),t(!0))}),100)}))));Promise.all(n).then((()=>{e()}))}((()=>{"before"!==o&&"after"!==o||(((e,t,n)=>{if("before"===n){e.insertAdjacentHTML("beforebegin",t);const n=document.createElement("div");n.innerHTML=t;const o=n.querySelector("script"),i=o?o.textContent:"";i&&s(i)}else if("after"===n){e.insertAdjacentHTML("afterend",t);const n=document.createElement("div");n.innerHTML=t;const o=n.querySelector("script"),i=o?o.textContent:"";i&&s(i)}else console.error("Invalid action: "+n)})(document.querySelector(i),e,o),(e=>{const t=document.createElement("style");t.innerHTML=e,document.head.appendChild(t)})(t),s(n)),"hide"===o&&document.querySelector(i).style.setProperty("display","none","important"),"wantToTrack"===o&&document.addEventListener("click",(function(e){const t=document.querySelector(i);t&&t.contains(e.target)&&fetch(`https://tigsaw.com/api/tracking/actionList?userTemplateId=${r}&title=${a}`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors"})}))}),(()=>document.querySelectorAll(i).length>0))}(i,r,a,t,n,o,s)})))}))})).catch((e=>{console.error("There was a problem with the fetch operation:",e)}))})();