Changeset 3382403
- Timestamp:
- 10/22/2025 08:34:11 AM (5 months ago)
- Location:
- personalizewp
- Files:
-
- 52 edited
- 1 copied
-
tags/3.2.2 (copied) (copied from personalizewp/trunk)
-
tags/3.2.2/README.txt (modified) (3 diffs)
-
tags/3.2.2/admin/js/admin.asset.php (modified) (1 diff)
-
tags/3.2.2/admin/js/admin.js (modified) (1 diff)
-
tags/3.2.2/admin/partials/scoring-rules/_form.php (modified) (1 diff)
-
tags/3.2.2/admin/partials/segments/_form.php (modified) (2 diffs)
-
tags/3.2.2/build/blocks/product-collection/block.json (modified) (1 diff)
-
tags/3.2.2/build/blocks/product-collection/index.asset.php (modified) (1 diff)
-
tags/3.2.2/build/blocks/product-collection/index.js (modified) (1 diff)
-
tags/3.2.2/build/blocks/variation-fallback/block.json (modified) (1 diff)
-
tags/3.2.2/build/blocks/variation/block.json (modified) (1 diff)
-
tags/3.2.2/build/blocks/variations-block/block.json (modified) (1 diff)
-
tags/3.2.2/build/blocks/variations-block/index.asset.php (modified) (1 diff)
-
tags/3.2.2/build/blocks/variations-block/index.js (modified) (1 diff)
-
tags/3.2.2/includes/class-api.php (modified) (7 diffs)
-
tags/3.2.2/includes/class-personalizewp.php (modified) (2 diffs)
-
tags/3.2.2/includes/rule-conditions/woocommerce/class-category-quantity-in-cart.php (modified) (1 diff)
-
tags/3.2.2/package.json (modified) (1 diff)
-
tags/3.2.2/personalizewp.php (modified) (2 diffs)
-
tags/3.2.2/src/admin/js/components/auto-complete.js (modified) (11 diffs)
-
tags/3.2.2/src/blocks/product-collection/block.json (modified) (1 diff)
-
tags/3.2.2/src/blocks/product-collection/index.js (modified) (1 diff)
-
tags/3.2.2/src/blocks/variation-fallback/block.json (modified) (1 diff)
-
tags/3.2.2/src/blocks/variation/block.json (modified) (1 diff)
-
tags/3.2.2/src/blocks/variations-block/block.json (modified) (1 diff)
-
tags/3.2.2/src/blocks/variations-block/index.js (modified) (1 diff)
-
tags/3.2.2/uninstall.php (modified) (1 diff)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/admin/js/admin.asset.php (modified) (1 diff)
-
trunk/admin/js/admin.js (modified) (1 diff)
-
trunk/admin/partials/scoring-rules/_form.php (modified) (1 diff)
-
trunk/admin/partials/segments/_form.php (modified) (2 diffs)
-
trunk/build/blocks/product-collection/block.json (modified) (1 diff)
-
trunk/build/blocks/product-collection/index.asset.php (modified) (1 diff)
-
trunk/build/blocks/product-collection/index.js (modified) (1 diff)
-
trunk/build/blocks/variation-fallback/block.json (modified) (1 diff)
-
trunk/build/blocks/variation/block.json (modified) (1 diff)
-
trunk/build/blocks/variations-block/block.json (modified) (1 diff)
-
trunk/build/blocks/variations-block/index.asset.php (modified) (1 diff)
-
trunk/build/blocks/variations-block/index.js (modified) (1 diff)
-
trunk/includes/class-api.php (modified) (7 diffs)
-
trunk/includes/class-personalizewp.php (modified) (2 diffs)
-
trunk/includes/rule-conditions/woocommerce/class-category-quantity-in-cart.php (modified) (1 diff)
-
trunk/package.json (modified) (1 diff)
-
trunk/personalizewp.php (modified) (2 diffs)
-
trunk/src/admin/js/components/auto-complete.js (modified) (11 diffs)
-
trunk/src/blocks/product-collection/block.json (modified) (1 diff)
-
trunk/src/blocks/product-collection/index.js (modified) (1 diff)
-
trunk/src/blocks/variation-fallback/block.json (modified) (1 diff)
-
trunk/src/blocks/variation/block.json (modified) (1 diff)
-
trunk/src/blocks/variations-block/block.json (modified) (1 diff)
-
trunk/src/blocks/variations-block/index.js (modified) (1 diff)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
personalizewp/tags/3.2.2/README.txt
r3381436 r3382403 4 4 Requires at least: 6.2.0 5 5 Tested up to: 6.8 6 Stable tag: 3.2. 16 Stable tag: 3.2.2 7 7 Requires PHP: 7.4 8 8 License: GPL v3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html 10 10 11 Add powerful personalization features to your WordPress site. Show different content to differentvisitors based on their behavior, profile, location, and more.11 Add powerful personalization features to your WordPress site. Show different content to visitors based on their behavior, profile, location, and more. 12 12 13 13 == Description == … … 178 178 == Changelog == 179 179 180 = 3.2.2 = 181 182 * Enhancement: Group our custom blocks within a PersonalizeWP block category. 183 * Tweak: Update the logo on our custom blocks to match the new branding. 184 * Enhancement: Add better sanitizing of URLs when using them for API authentication tokens. 185 * Bug fix: Fix JS error that occurred on some of our forms that used auto complete fields, causing those fields to be incorrectly disabled. 186 * Bug fix: Fix loading error that occurred with the WooCommerce Category Quantity in Cart condition, causing it to not appear. 187 * Bug fix: Fix fatal error that occurred when attempting to uninstall/delete PersonalizeWP. 188 180 189 = 3.2.1 = 181 190 182 * Bug Fix: Fix database migration of Pro addon which wouldn't automatically run if you didn't visit your admin.191 * Bug fix: Fix database migration of Pro addon which wouldn't automatically run if you didn't visit your admin. 183 192 184 193 = 3.2.0 = … … 389 398 390 399 == Upgrade Notice == 400 401 = 3.2.1 = 391 402 IMPORTANT: Users of PersonalizeWP 3.1 or earlier should immediately upgrade to 3.2.1 or later. 3.2.0+ merges all the features of PersonalizeWP Pro, giving you much more powerful personalization features. -
personalizewp/tags/3.2.2/admin/js/admin.asset.php
r3380017 r3382403 1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-dom-ready', 'wp-html-entities', 'wp-i18n', 'wp-url'), 'version' => ' 8292ed898169b6442251');1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-dom-ready', 'wp-html-entities', 'wp-i18n', 'wp-url'), 'version' => '525ecc764eae56bb5e3c'); -
personalizewp/tags/3.2.2/admin/js/admin.js
r3380017 r3382403 1 (()=>{var e={51:function(e,t,r){var s,i;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),i=void 0!==r.g?r.g:"undefined"!=typeof window?window:this,s=function(){return function(e){"use strict";var t={idPrefix:"tabby-toggle_",default:"[data-tabby-default]"},r=function(t){if(t&&"true"!=t.getAttribute("aria-selected")){var r=document.querySelector(t.hash);if(r){var s=function(e){var t=e.closest('[role="tablist"]');if(!t)return{};var r=t.querySelector('[role="tab"][aria-selected="true"]');if(!r)return{};var s=document.querySelector(r.hash);return r.setAttribute("aria-selected","false"),r.setAttribute("tabindex","-1"),s?(s.setAttribute("hidden","hidden"),{previousTab:r,previousContent:s}):{previousTab:r}}(t);!function(e,t){e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0"),t.removeAttribute("hidden"),e.focus()}(t,r),s.tab=t,s.content=r,function(t,r){var s;"function"==typeof e.CustomEvent?s=new CustomEvent("tabby",{bubbles:!0,cancelable:!0,detail:r}):(s=document.createEvent("CustomEvent")).initCustomEvent("tabby",!0,!0,r),t.dispatchEvent(s)}(t,s)}}};return function(s,i){var a,o,n={destroy:function(){var e=o.querySelectorAll("a");Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id.slice(0,r.idPrefix.length)===r.idPrefix&&(e.id=""),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex"),e.closest("li").removeAttribute("role"),t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("hidden")}(e,t,a)}),o.removeAttribute("role"),document.documentElement.removeEventListener("click",l,!0),o.removeEventListener("keydown",c,!0),a=null,o=null},setup:function(){if(o=document.querySelector(s)){var e=o.querySelectorAll("a");o.setAttribute("role","tablist"),Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id||(e.id=r.idPrefix+t.id),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.id),e.closest("li").setAttribute("role","presentation"),t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),e.matches(r.default)?e.setAttribute("aria-selected","true"):(e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),t.setAttribute("hidden","hidden"))}(e,t,a)})}},toggle:function(e){var t=e;"string"==typeof e&&(t=document.querySelector(s+' [role="tab"][href*="'+e+'"]')),r(t)}},l=function(e){var t=e.target.closest(s+' [role="tab"]');t&&(e.preventDefault(),r(t))},c=function(e){var t=document.activeElement;t.matches(s+' [role="tab"]')&&(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Up","Down","Left","Right","Home","End"].indexOf(e.key)<0||function(e,t){var s=function(e){var t=e.closest('[role="tablist"]'),r=t?t.querySelectorAll('[role="tab"]'):null;if(r)return{tabs:r,index:Array.prototype.indexOf.call(r,e)}}(e);if(s){var i,a=s.tabs.length-1;["ArrowUp","ArrowLeft","Up","Left"].indexOf(t)>-1?i=s.index<1?a:s.index-1:["ArrowDown","ArrowRight","Down","Right"].indexOf(t)>-1?i=s.index===a?0:s.index+1:"Home"===t?i=0:"End"===t&&(i=a),r(s.tabs[i])}}(t,e.key))};return a=function(){var e={};return Array.prototype.forEach.call(arguments,function(t){for(var r in t){if(!t.hasOwnProperty(r))return;e[r]=t[r]}}),e}(t,i||{}),n.setup(),function(t){if(!(e.location.hash.length<1)){var s=document.querySelector(t+' [role="tab"][href*="'+e.location.hash+'"]');r(s)}}(s),document.documentElement.addEventListener("click",l,!0),o.addEventListener("keydown",c,!0),n}}(i)}.apply(t,[]),void 0===s||(e.exports=s)}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.i18n,t=window.wp.domReady;var s=r.n(t),i=r(51),a=r.n(i);function o(e,t,r,s=null,i=!1){const a=new CustomEvent(`pwp-${t}:${r}`,{bubbles:!0,cancelable:i,detail:s});return e.dispatchEvent(a)}function n(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{e.readyInit()},{once:!0}):e.readyInit()}customElements.define("ajax-form",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){var e;this.hasAttribute("is-ready")||(this.announce=this.querySelector('[role="status"]')||document.createElement("div"),this.announce.setAttribute("role","status"),this.form=this.querySelector("form"),this.form&&(this.form.append(this.announce),this.msgSubmitting=null!==(e=this.getAttribute("msg-submitting"))&&void 0!==e?e:"Submitting...",this.msgDisappear=this.hasAttribute("msg-disappear"),this.keepFields=this.hasAttribute("keep-fields"),this.updateURL=this.getAttribute("update-url"),this.removeElem=this.getAttribute("remove"),this.closeDialog=this.hasAttribute("close-dialog"),this.delay=this.hasAttribute("delay")?6e3:0,this.form.addEventListener("submit",this),o(this,"ajax-form","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`on${e.type}`](e)}async onsubmit(e){if(e.preventDefault(),!this.isDisabled()){this.disable(),this.showStatus(this.msgSubmitting,!0);try{const e=this.serialize(),t=this.form.getAttribute("action"),r=this.form.getAttribute("method");if(!o(this,"ajax-form","submit-before",{action:t,formData:e},!0))return;const s=await fetch(t,{method:r,body:this.serialize(),headers:{Accept:"application/json, */*;q=0.1","Content-type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"}});let i=await s.json();if(!s.ok)throw i;if(Object.hasOwn(i,"success")&&!i.success)throw Object.hasOwn(i,"data")&&(i=i.data),o(this,"ajax-form","error",i),i;Object.hasOwn(i,"data")&&(i=i.data),i.message&&this.showStatus(i.message,!0,!0),this.updateURL&&history.replaceState(history.state,null,this.updateURL),i.url&&(window.location.href=i.url),this.keepFields||this.reset(),o(this,"ajax-form","success",i),this.removeElem&&(this.closest(this.removeElem)||this).remove()}catch(e){console.warn(e),this.showStatus(e.message)}finally{setTimeout(()=>{this.enable()},this.delay)}}}disable(){this.setAttribute("form-submitting","")}enable(){this.removeAttribute("form-submitting")}isDisabled(){return this.hasAttribute("form-submitting")}showStatus(e,t,r){this.announce.hidden=!1,this.announce.innerHTML=e,this.announce.className=t?"notice-message success-message":"notice-message error-message",t&&r&&this.removeElem&&this.toast(),t&&this.msgDisappear&&setTimeout(()=>{this.announce.hidden=!0,this.announce.innerHTML="",this.announce.className=""},6e3),t&&r&&this.closeDialog&&setTimeout(()=>{const e=this.closest("dialog");e&&e.close("close")},6e3)}toast(){const e=document.querySelector(".toast-wrapper");e||(e=document.createElement("div"),e.className="toast-wrapper",document.body.append(e)),this.announce.className="toast",e.prepend(this.announce),setTimeout(()=>{this.announce.remove()},6e3)}serialize(){const e=new FormData(this.form),t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);return t.toString()}reset(){this.form.reset()}}),customElements.define("ajax-html",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("event-name")?.split(",")||[];if(this.eventUID=this.getAttribute("event-uid")?.split(",")||[],e.length&&this.id){for(let t of e)document.addEventListener(t,e=>{this.updateHTML(e,this)});o(this,"ajax-html","ready"),this.setAttribute("is-ready","")}}async updateHTML(e,t){if(!this.eventUID.length||this.eventUID.includes(e.detail?.uid))try{let e=await fetch(location.href);if(!e.ok)throw e;let r=await e.text(),s=(new DOMParser).parseFromString(r,"text/html").querySelector(`#${t.id}`);if(!s)return;t.replaceWith(s)}catch(e){console.warn("Unable to update HTML")}}});const l=window.wp.apiFetch;var c=r.n(l);const u=window.wp.url,d=window.wp.htmlEntities;customElements.define("auto-complete",class extends HTMLElement{static observedAttributes=["mode","content-types","taxonomy","disabled","placeholder"];connectedCallback(){n(this)}readyInit(){this.hasAttribute("is-ready")||(this.isDomSetup=!1,this.searchQueries={},this.contentTypes=[],this.taxonomy=null,this.restBase=null,this.selectedItems=[],this.currentSearch="",this.currentPage=1,this.totalPages=1,this.perPage=10,this.minChars=2,this.itemTemplate=null,this.searchInput=null,this.clearSearch=null,this.searchResults=null,this.displaySelected=null,this.disabled=this.getAttribute("disabled")||!1,this.itemTemplate=this.querySelector("template")?.content,this.itemTemplate&&(this.isDomSetup||this.setupDOM(),this.renderSelection(),this.searchInput.addEventListener("keyup",this),this.clearSearch.addEventListener("click",this),this.searchResults.addEventListener("click",this),this.displaySelected.addEventListener("click",this),this.isDomSetup=!0,o(this,"auto-complete","ready",{items:this.selectedItems}),this.setAttribute("is-ready","")))}setupDOM(){if(!this.searchInput&&!this.clearSearch){let t=document.createElement("div");t.classList.add("search"),this.searchInput=document.createElement("input"),this.searchInput.setAttribute("type","text"),this.searchInput.setAttribute("autocomplete","off"),this.disabled&&this.searchInput.setAttribute("disabled",""),this.searchInput.classList.add("auto-complete","search-icon"),this.searchInput.id=this.getAttribute("label-id")||"auto-complete-"+Math.floor(100*Math.random()),this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`),t.append(this.searchInput),this.clearSearch=document.createElement("button"),this.clearSearch.setAttribute("type","button"),this.clearSearch.setAttribute("data-type","reset"),this.clearSearch.setAttribute("aria-label",`${(0,e.__)("Reset search","personalizewp")}`),this.clearSearch.innerHTML='<svg width="24" height="24"><use xlink:href="#pwp-icon-cross"></use></svg>',this.hideClearSearch(),t.append(this.clearSearch),this.append(t)}this.searchResults||(this.searchResults=document.createElement("ul"),this.searchResults.classList.add("search-results"),this.append(this.searchResults)),this.displaySelected||(this.displaySelected=document.createElement("ul"),this.displaySelected.classList.add("tag-list","cluster"),this.append(this.displaySelected))}initialiseMode(){this.mode=this.getAttribute("mode")||"post","term"===this.mode&&(this.restBase=null,this.taxonomy=this.getAttribute("taxonomy"),window.PWPTaxonomyRestBases&&(this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null),this.restBase||c()({path:"wp/v2/taxonomies"}).then(e=>{const t={};for(const r in e)t[`${r}`]=e[`${r}`].rest_base;window.PWPTaxonomyRestBases=t,this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null,this.restBase||this.setAttribute("disabled","")}).catch(e=>{console.log("catching error...",e),this.setAttribute("disabled","")}));const e=this.getAttribute("content")||[];0!==e.length&&(this.selectedItems=JSON.parse(e))}handleEvent(e){this[`handle${e.type}`](e)}attributeChangedCallback(e,t,r){this[`handleChange${e=e.replace(/[^a-zA-Z0-9]/i,"")}`](t,r)}handleChangeplaceholder(t){this.searchInput&&this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`)}handlekeyup(e){clearTimeout(this.debouce),""===this.searchInput.value?this.hideClearSearch():this.showClearSearch(),this.debouce=setTimeout(()=>{this.handleSearchStringChange(this.searchInput.value,this.currentPage)},250)}handleclick(e){e.preventDefault();let t=e.target.closest("button");if(!t)return;let r=t.getAttribute("data-type");if(r)switch(r){case"reset":this.currentPage=1,this.currentSearch="",this.searchInput.value="",this.resetSearchResults(),this.searchInput.focus(),this.hideClearSearch();break;case"load-more":this.currentPage++,this.handleSearchStringChange(this.searchInput.value,this.currentPage),t.closest("li").remove();break;case"selected":t.closest("li").remove(),this.removeSelectedItem(t.value);break;case"search":this.addSelectedItem(t.value,t.querySelector(".header").textContent)}}handleChangemode(e,t){this.initialiseMode()}handleChangecontenttypes(e,t){t&&0!==t.length?this.contentTypes=t.split(",").map(e=>e.replace(/[^a-z0-9_\-]/,"")):this.contentTypes=[]}handleChangetaxonomy(e,t){if(null===t||""===t)return this.taxonomy=null,void this.setAttribute("disabled","");if(this.taxonomy=t,this.resetSearchResults(),this.initialiseMode(),!this.itemTemplate)return;null!==e&&""!==e||(e="%TAXONOMY%");const r=this.itemTemplate.querySelector('input[type="hidden"][name^="pwp_form"]');r&&r.setAttribute("name",r.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`)),this.displaySelected.querySelectorAll('input[type="hidden"][name^="pwp_form"]').forEach(t=>{t.setAttribute("name",t.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`))}),this.removeAttribute("disabled")}handleChangedisabled(e,t){null!==t?(this.disabled=!0,this.searchInput&&this.searchInput.setAttribute("disabled",""),this.resetSearchResults()):(this.disabled=!1,this.searchInput&&this.searchInput.removeAttribute("disabled"))}removeSelectedItem(e){let t=this.selectedItems.findIndex(t=>t.value===e);-1!==t&&(this.selectedItems.splice(t,1),this.renderSelection(),o(this,"auto-complete","remove-item",{item:e,items:this.selectedItems}))}addSelectedItem(e,t){-1===this.selectedItems.findIndex(t=>t.value===e)&&(this.selectedItems.unshift({value:e,text:t}),this.renderSelection(),o(this,"auto-complete","add-item",{newItem:e,items:this.selectedItems}))}renderSelection(){this.displaySelected&&this.displaySelected.replaceChildren(...Array.from(this.selectedItems).map(e=>{let t=document.createElement("li");return t.append(this.itemTemplate.cloneNode(!0)),t.querySelector("span").textContent=e.text,t.querySelector("input").value=e.value,t.querySelector("button").value=e.value,t.querySelector("button").setAttribute("data-type","selected"),t}))}showLoading(){if(this.searchResults.querySelector(".loading"))return;let e=document.createElement("li");e.classList.add("loading"),e.innerHTML='<svg class="components-spinner" viewBox="0 0 100 100" width="20" height="20" xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false"><circle cx="50" cy="50" r="50" vector-effect="non-scaling-stroke" fill="transparent" stroke="#ddd" stroke-width="2"></circle><path d="m 50 0 a 50 50 0 0 1 50 50" vector-effect="non-scaling-stroke" fill="transparent" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>',this.searchResults.append(e)}hideLoading(){const e=this.searchResults.querySelector(".loading");e&&e.remove()}showNothingFound(){if(this.searchResults.querySelector(".nothing"))return;let t=document.createElement("li");t.classList.add("nothing"),t.textContent=`${(0,e.__)("Nothing found.","personalizewp")}`,this.searchResults.replaceChildren(t)}hideClearSearch(){this.clearSearch.style.display="none"}showClearSearch(){this.clearSearch.style.display=""}showLoadMore(){if(this.searchResults.querySelector(".load-more"))return;let t=document.createElement("li");t.classList.add("load-more"),t.innerHTML=`<button type="button" data-type="load-more">${(0,e.__)("Load more","personalizewp")}</button>`,this.searchResults.append(t)}resetSearchResults(){this.searchResults&&this.searchResults.replaceChildren()}resetAll(){this.selectedItems=[],this.renderSelection(),this.currentSearch="",this.currentPage=1,this.resetSearchResults(),this.searchInput&&(this.searchInput.value=""),o(this,"auto-complete","reset-all")}renderResults(e){this.hideLoading(),0!==e.length?(1===this.currentPage&&this.resetSearchResults(),this.searchResults.append(...Array.from(e).map(e=>{let t=document.createElement("span");t.classList.add("header"),t.textContent=e.text;let r=document.createElement("button");if(r.value=e.value,r.setAttribute("type","button"),r.setAttribute("data-type","search"),r.append(t),e.info){let t=document.createElement("span");t.classList.add("info"),t.setAttribute("aria-hidden","true"),t.textContent=e.info,r.append(t)}let s=document.createElement("li");return s.append(r),s})),this.totalPages>this.currentPage&&this.showLoadMore()):this.showNothingFound()}normalizeResults(e){let t=[];switch(this.mode){case"form":case"product":e.forEach(e=>{let r={value:e.value,text:(0,d.decodeEntities)(e.title)};e.url&&(r.info=(0,u.filterURLForDisplay)((0,u.safeDecodeURI)(e.url),30)),t.push(r)});break;case"term":e.forEach(e=>{t.push({value:e.id,text:(0,d.decodeEntities)(e.name),info:(0,u.filterURLForDisplay)((0,u.safeDecodeURI)(e.link),30)})});break;case"post":e.forEach(e=>{t.push({value:e.id,text:(0,d.decodeEntities)(e.title),info:(0,u.filterURLForDisplay)((0,u.safeDecodeURI)(e.url),30)})})}return t}handleSearchStringChange(e,t){if(""===(e=e.trim()))return this.currentSearch="",this.currentPage=1,void this.resetSearchResults();if(e!==this.currentSearch&&(this.currentPage=1,this.currentSearch=e),e.length<this.minChars)return;this.showLoading();let r=this.prepareSearchQuery(e,t);this.contentSearch(r)}prepareSearchQuery(e,t){let r,s;switch(this.mode){case"product":s={search:e,_embed:!0,per_page:this.perPage,page:t},0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,u.addQueryArgs)("personalizewp/v1/products-search",s);break;case"form":s={search:e,_embed:!0,per_page:this.perPage,page:t},r=(0,u.addQueryArgs)("personalizewp/v1/forms-search",s);break;case"term":s={search:e,per_page:this.perPage,page:t},r=(0,u.addQueryArgs)(`wp/v2/${this.restBase}`,s);break;default:s={search:e,type:this.mode,_embed:!0,per_page:this.perPage,page:t},0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,u.addQueryArgs)("wp/v2/search",s)}return r}contentSearch(e){c()({path:e,parse:!1}).then(e=>{this.totalPages=parseInt(e.headers&&e.headers.get("X-WP-TotalPages"),10),e.json().then(e=>{const t=this.normalizeResults(e);this.renderResults(t)})}).catch(e=>{console.log("catching error..."),this.hideLoading()})}}),customElements.define("custom-tag-list",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("input")||!1,t=this.getAttribute("submit")||!1,r=this.getAttribute("list")||!1;e&&t&&r&&(this.itemInput=this.querySelector(`#${e}`),this.itemSubmit=this.querySelector(`#${t}`),this.itemList=this.querySelector(`#${r}`),this.itemTemplate=this.querySelector("template")?.content,this.itemInput&&this.itemSubmit&&this.itemList&&this.itemTemplate&&(this.itemSubmit.removeAttribute("hidden"),this.itemSubmit.addEventListener("click",this),o(this,"custom-tag-list","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`handle${e.type}`](e)}handleclick(e){e.preventDefault();const t=this.itemInput.value.trim();if(""===t)return;const r=this.itemTemplate.cloneNode(!0);r.querySelector("span").textContent=t,r.querySelector("input").value=t,this.itemList.appendChild(r),this.itemInput.value=""}}),customElements.define("custom-tag",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;if(this.itemInput=this.querySelector("input"),this.itemButton=this.querySelector("button"),!this.itemInput||!this.itemButton)return;this.itemLabel=this.querySelector("label")||null;const e=this.itemButton.getAttribute("data-confirm-modal"),t=e?document.querySelector(e):null;this.dialog=e&&void 0!==window.HTMLDialogElement&&t?t:null,this.itemInput.setAttribute("type","hidden"),this.itemLabel&&(this.itemLabel.style.pointerEvents="none"),this.itemButton.removeAttribute("hidden"),this.itemButton.addEventListener("click",this),this.setAttribute("is-ready","")}handleEvent(e){this[`handle${e.type}`](e)}handleclose(e){this.dialog.removeEventListener("close",this),"delete"===this.dialog.returnValue&&this.remove()}handleclick(e){e.preventDefault(),this.dialog?(this.dialog.addEventListener("close",this),this.dialog.showModal()):this.remove()}});s()(()=>{window.pwpSettings&&""!==window.pwpSettings?.kb&&document.querySelector(`ul#adminmenu a[href='${window.pwpSettings.kb}']`)?.setAttribute("target","_blank");const t=document.querySelector("form[data-pwp]");t&&(e=>{const t=e.querySelector("#pwp_form_type"),r=e.querySelectorAll("[data-condition-type]");if(!t||0===r.length)return;const s=e.querySelector("#condition-addition"),i=e.querySelector("#condition-operator"),a=function(e){r.forEach(t=>{const r=t.getAttribute("data-condition-type")===e;if(t.hidden=!r,r){const e=null===t.querySelector(":scope > template");if(s.hidden=e,i){const r=null===t.querySelector(":scope auto-complete");i.hidden=r&&e}o(t,!0)}r||o(t)})},o=function(e,t=!1){t?e.querySelectorAll("[data-required]").forEach(e=>{e.removeAttribute("data-required"),e.required=!0}):e.querySelectorAll("[required]").forEach(e=>{e.setAttribute("data-required","required"),e.required=!1})};t.addEventListener("change",function(){a(t.options[t.selectedIndex].value)});var n=t.selectedIndex?t.options[t.selectedIndex].value:"";a(n);const l=e=>{const t=e.querySelectorAll('[data-type="taxonomy"]');t.length&&t.forEach(e=>{e.addEventListener("change",function(){const t=e.selectedIndex?e.options[e.selectedIndex].value:"",r=e.closest('[data-condition="row"]');if(r){const e=r.querySelector("auto-complete");e&&e.setAttribute("taxonomy",t)}})})};l(e),e.addEventListener("click",function(t){let r=t.target.closest("button");if(r){var s,i,a,o=!1;switch(r.value){case"add":a=(i=e.querySelector("[data-condition-type]:not([hidden])")).querySelector(":scope > template").content.cloneNode(!0),i.appendChild(a),l(e),o=!0;break;case"remove":(i=(s=r.closest('[data-condition="row"]')).closest("[data-condition-type]")).removeChild(s),o=!0}if(o){var n=i.querySelectorAll('[data-condition="row"]').length;i.setAttribute("data-condition-count",n)}}})})(t);var r=document.querySelectorAll("dialog.dialog");0!==r.length&&r.forEach(e=>{e.addEventListener("click",function(t){if(t.target.matches("dialog"))return e.close("close"),void t.stopPropagation();const r=t.target.closest("button");return r&&r.matches("button[value=close]")?(e.close("close"),void t.stopPropagation()):void 0})}),document.addEventListener("click",function(e){var t=e.target.closest("[data-show-modal]");if(!t)return;const r=t.getAttribute("data-show-modal"),s=document.querySelector(r);if(void 0!==window.HTMLDialogElement&&s){if(s.hasAttribute("data-url-action")){let e;t.hasAttribute("href")&&(e=t.getAttribute("href")),t.hasAttribute("data-form-action")&&(e=t.getAttribute("data-form-action")),e&&s.querySelector("form").setAttribute("action",e)}if("#editCategoryModal"===r){const e=t.getAttribute("href"),r=t.getAttribute("data-id"),i=t.getAttribute("data-name");s.querySelector("form").setAttribute("action",e),s.querySelector('[name="personalizewp_form[id]"]').value=r,s.querySelector('[name="personalizewp_form[name]"]').value=i}e.preventDefault(),s.showModal()}});const s=document.querySelector("ajax-form#newsletter-signup");s&&(s.addEventListener("pwp-ajax-form:submit-before",e=>{s.querySelectorAll(".field-error").forEach(e=>{e.classList.remove("field-error"),e.querySelector(".input-error").hidden=!0})}),s.addEventListener("pwp-ajax-form:error",e=>{var t;const r=null!==(t=e.detail?.errors)&&void 0!==t?t:[];r.length&&r.forEach(e=>{const t=s.querySelector(`input[name="${e}"]`).closest(".field"),r=t.querySelector(".input-error");t.classList.add("field-error"),r.hidden=!1})}),s.addEventListener("pwp-ajax-form:success",e=>{s.querySelectorAll(".actions button").forEach(e=>{e.hidden=!e.hidden})}));const i=document.querySelectorAll(".notice[data-dismiss-type]");0!==i.length&&i.forEach(e=>{e.addEventListener("click",function(t){if(!t.target.matches("button"))return;t.stopPropagation();const r=e.getAttribute("data-dismiss-type"),s=new FormData;s.append("action",`pwp_dismiss_${r}_message`),s.append("_ajax_nonce",pwpSettings.nonce),async function(e){let t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);const r=await fetch(pwpSettings.url,{method:"POST",headers:{Accept:"application/json, */*;q=0.1","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"},body:t.toString()});await r.json();r.ok}(s)})}),document.querySelector(".pwp-page [data-tabs]")&&(new(a())(".pwp-page [data-tabs]",{idPrefix:"pwp_"}),document.addEventListener("tabby",function(e){e.detail.tab.classList.add("is-active"),e.detail.previousTab.classList.remove("is-active")},!1)),(()=>{window.pwpSaveAlert=!1;const e=document.querySelectorAll("[data-save-alert]");if(0!==e.length){let t=[];e.forEach(e=>{var r;e.addEventListener("click",function(){window.pwpSaveAlert=!0});const s=null!==(r=e.getAttribute("form"))&&void 0!==r&&r;s?t.push(document.getElementById(s)):t.push(e.closest("form"))}),t.forEach(e=>{e.addEventListener("submit",function(){window.pwpSaveAlert=!1})})}const t=document.querySelectorAll("[data-clear-save-alert]");0!==t.length&&t.forEach(e=>{e.addEventListener("click",function(){window.pwpSaveAlert=!1})}),window.addEventListener("beforeunload",e=>{window.pwpSaveAlert&&(e.preventDefault(),e.returnValue=!0)})})();const o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;"woocommerce_time_since_last_order"===s&&(a=(0,e.__)("Enter number of days","personalizewp")),a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)},n=document.querySelector("#pwp-form");n&&((t=>{if(!t)return;if(!(t.querySelector(".conditions-measure")||document.body.classList.contains("post-type-personalizewp_rule")||t.classList.contains("personalizewp-rules-form")))return;const r=window.pwpRuleFormEx?.autocomplete_conditions||["woocommerce_product_stock_level","woocommerce_product_quantity_in_cart","woocommerce_category_quantity_in_cart"],s=e=>r.includes(e),i=e=>{const t=e.closest(".condition"),r=t?.querySelector(".rule-condition-values");if(!r)return;const s=(e.selectedItems||[]).map(e=>(e=>{if(!e)return"";if(/^\d+$/.test(e))return e;const t=e.match(/:(\d+)$/);return t?t[1]:e})(e.value||e.id)).filter(Boolean).join(",");r.value!==s&&(r.value=s)},a=(e,t)=>{const r=e.querySelector(".autocomplete-field-wrapper");t?(r&&(r.style.display="block"),e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{e.style.display="none";const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!0,t.value="")})):r&&(r.style.display="none",e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!1)}))},o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;switch(s){case"woocommerce_product_quantity_in_cart":a=(0,e.__)("No. of product","personalizewp");break;case"woocommerce_category_quantity_in_cart":a=(0,e.__)("No. of category","personalizewp");break;default:const t=i.getAttribute("data-initial-placeholder");t&&(a=t)}a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)};t.addEventListener("change",t=>{if(!t.target.classList.contains("conditions-measure"))return;const r=t.target.closest(".condition"),i=t.target.value;if(s(i)){const t=r.querySelector(".autocomplete-field-wrapper"),s=r.querySelector("auto-complete.rule-condition-autocomplete");t?(s&&((t,r)=>{const s={woocommerce_product_stock_level:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_product_quantity_in_cart:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_category_quantity_in_cart:{mode:"product","content-types":"categories",placeholder:(0,e.__)("Search for a category","personalizewp")}}[r];s&&t&&(t.setAttribute("mode",s.mode),t.setAttribute("placeholder",s.placeholder),t.removeAttribute("taxonomy"),t.setAttribute("content-types",s["content-types"]),setTimeout(()=>{t.removeAttribute("disabled"),"function"==typeof t.resetAll&&t.resetAll()},10))})(s,i),a(r,!0)):((e,t)=>{const r=document.getElementById(`pwp-autocomplete-template-${t}`);if(!r)return;const s=r.content.cloneNode(!0).querySelector(".autocomplete-field-wrapper");if(s){const t=e.querySelector(".conditions-comparator");t&&t.before(s),o(e),a(e,!0)}})(r,i)}else{const e=r.querySelector("auto-complete.rule-condition-autocomplete");e&&"function"==typeof e.resetAll&&e.resetAll(),a(r,!1)}o(r)});const n=e=>{t.querySelectorAll("auto-complete.rule-condition-autocomplete").forEach(i)};t.addEventListener("submit",n);const l=(e,r)=>{const s=t.querySelector("#form-actions");(r?.detail?.items?.length&&s||s)&&jQuery(s).show(),n()};t.addEventListener("pwp-auto-complete:remove-item",l),t.addEventListener("pwp-auto-complete:add-item",l),t.querySelectorAll(".condition").forEach(e=>{const t=e.querySelector(".conditions-measure"),r=t?.value;if(r&&s(r)){const t=e.querySelector(".autocomplete-field-wrapper"),r=e.querySelector(".conditions-comparator");r&&r.before(t),o(e),a(e,!0)}})})(n),n.querySelectorAll(".condition").forEach(o),n.addEventListener("change",e=>{if(!e.target.classList.contains("conditions-measure"))return;const t=e.target.closest(".condition");t&&o(t)}))})})()})();1 (()=>{var e={51:function(e,t,r){var s,i;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),i=void 0!==r.g?r.g:"undefined"!=typeof window?window:this,s=function(){return function(e){"use strict";var t={idPrefix:"tabby-toggle_",default:"[data-tabby-default]"},r=function(t){if(t&&"true"!=t.getAttribute("aria-selected")){var r=document.querySelector(t.hash);if(r){var s=function(e){var t=e.closest('[role="tablist"]');if(!t)return{};var r=t.querySelector('[role="tab"][aria-selected="true"]');if(!r)return{};var s=document.querySelector(r.hash);return r.setAttribute("aria-selected","false"),r.setAttribute("tabindex","-1"),s?(s.setAttribute("hidden","hidden"),{previousTab:r,previousContent:s}):{previousTab:r}}(t);!function(e,t){e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0"),t.removeAttribute("hidden"),e.focus()}(t,r),s.tab=t,s.content=r,function(t,r){var s;"function"==typeof e.CustomEvent?s=new CustomEvent("tabby",{bubbles:!0,cancelable:!0,detail:r}):(s=document.createEvent("CustomEvent")).initCustomEvent("tabby",!0,!0,r),t.dispatchEvent(s)}(t,s)}}};return function(s,i){var a,o,n={destroy:function(){var e=o.querySelectorAll("a");Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id.slice(0,r.idPrefix.length)===r.idPrefix&&(e.id=""),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex"),e.closest("li").removeAttribute("role"),t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("hidden")}(e,t,a)}),o.removeAttribute("role"),document.documentElement.removeEventListener("click",l,!0),o.removeEventListener("keydown",c,!0),a=null,o=null},setup:function(){if(o=document.querySelector(s)){var e=o.querySelectorAll("a");o.setAttribute("role","tablist"),Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id||(e.id=r.idPrefix+t.id),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.id),e.closest("li").setAttribute("role","presentation"),t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),e.matches(r.default)?e.setAttribute("aria-selected","true"):(e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),t.setAttribute("hidden","hidden"))}(e,t,a)})}},toggle:function(e){var t=e;"string"==typeof e&&(t=document.querySelector(s+' [role="tab"][href*="'+e+'"]')),r(t)}},l=function(e){var t=e.target.closest(s+' [role="tab"]');t&&(e.preventDefault(),r(t))},c=function(e){var t=document.activeElement;t.matches(s+' [role="tab"]')&&(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Up","Down","Left","Right","Home","End"].indexOf(e.key)<0||function(e,t){var s=function(e){var t=e.closest('[role="tablist"]'),r=t?t.querySelectorAll('[role="tab"]'):null;if(r)return{tabs:r,index:Array.prototype.indexOf.call(r,e)}}(e);if(s){var i,a=s.tabs.length-1;["ArrowUp","ArrowLeft","Up","Left"].indexOf(t)>-1?i=s.index<1?a:s.index-1:["ArrowDown","ArrowRight","Down","Right"].indexOf(t)>-1?i=s.index===a?0:s.index+1:"Home"===t?i=0:"End"===t&&(i=a),r(s.tabs[i])}}(t,e.key))};return a=function(){var e={};return Array.prototype.forEach.call(arguments,function(t){for(var r in t){if(!t.hasOwnProperty(r))return;e[r]=t[r]}}),e}(t,i||{}),n.setup(),function(t){if(!(e.location.hash.length<1)){var s=document.querySelector(t+' [role="tab"][href*="'+e.location.hash+'"]');r(s)}}(s),document.documentElement.addEventListener("click",l,!0),o.addEventListener("keydown",c,!0),n}}(i)}.apply(t,[]),void 0===s||(e.exports=s)}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.i18n,t=window.wp.domReady;var s=r.n(t),i=r(51),a=r.n(i);function o(e,t,r,s=null,i=!1){const a=new CustomEvent(`pwp-${t}:${r}`,{bubbles:!0,cancelable:i,detail:s});return e.dispatchEvent(a)}function n(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{e.readyInit()},{once:!0}):e.readyInit()}customElements.define("ajax-form",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){var e;this.hasAttribute("is-ready")||(this.announce=this.querySelector('[role="status"]')||document.createElement("div"),this.announce.setAttribute("role","status"),this.form=this.querySelector("form"),this.form&&(this.form.append(this.announce),this.msgSubmitting=null!==(e=this.getAttribute("msg-submitting"))&&void 0!==e?e:"Submitting...",this.msgDisappear=this.hasAttribute("msg-disappear"),this.keepFields=this.hasAttribute("keep-fields"),this.updateURL=this.getAttribute("update-url"),this.removeElem=this.getAttribute("remove"),this.closeDialog=this.hasAttribute("close-dialog"),this.delay=this.hasAttribute("delay")?6e3:0,this.form.addEventListener("submit",this),o(this,"ajax-form","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`on${e.type}`](e)}async onsubmit(e){if(e.preventDefault(),!this.isDisabled()){this.disable(),this.showStatus(this.msgSubmitting,!0);try{const e=this.serialize(),t=this.form.getAttribute("action"),r=this.form.getAttribute("method");if(!o(this,"ajax-form","submit-before",{action:t,formData:e},!0))return;const s=await fetch(t,{method:r,body:this.serialize(),headers:{Accept:"application/json, */*;q=0.1","Content-type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"}});let i=await s.json();if(!s.ok)throw i;if(Object.hasOwn(i,"success")&&!i.success)throw Object.hasOwn(i,"data")&&(i=i.data),o(this,"ajax-form","error",i),i;Object.hasOwn(i,"data")&&(i=i.data),i.message&&this.showStatus(i.message,!0,!0),this.updateURL&&history.replaceState(history.state,null,this.updateURL),i.url&&(window.location.href=i.url),this.keepFields||this.reset(),o(this,"ajax-form","success",i),this.removeElem&&(this.closest(this.removeElem)||this).remove()}catch(e){console.warn(e),this.showStatus(e.message)}finally{setTimeout(()=>{this.enable()},this.delay)}}}disable(){this.setAttribute("form-submitting","")}enable(){this.removeAttribute("form-submitting")}isDisabled(){return this.hasAttribute("form-submitting")}showStatus(e,t,r){this.announce.hidden=!1,this.announce.innerHTML=e,this.announce.className=t?"notice-message success-message":"notice-message error-message",t&&r&&this.removeElem&&this.toast(),t&&this.msgDisappear&&setTimeout(()=>{this.announce.hidden=!0,this.announce.innerHTML="",this.announce.className=""},6e3),t&&r&&this.closeDialog&&setTimeout(()=>{const e=this.closest("dialog");e&&e.close("close")},6e3)}toast(){const e=document.querySelector(".toast-wrapper");e||(e=document.createElement("div"),e.className="toast-wrapper",document.body.append(e)),this.announce.className="toast",e.prepend(this.announce),setTimeout(()=>{this.announce.remove()},6e3)}serialize(){const e=new FormData(this.form),t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);return t.toString()}reset(){this.form.reset()}}),customElements.define("ajax-html",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("event-name")?.split(",")||[];if(this.eventUID=this.getAttribute("event-uid")?.split(",")||[],e.length&&this.id){for(let t of e)document.addEventListener(t,e=>{this.updateHTML(e,this)});o(this,"ajax-html","ready"),this.setAttribute("is-ready","")}}async updateHTML(e,t){if(!this.eventUID.length||this.eventUID.includes(e.detail?.uid))try{let e=await fetch(location.href);if(!e.ok)throw e;let r=await e.text(),s=(new DOMParser).parseFromString(r,"text/html").querySelector(`#${t.id}`);if(!s)return;t.replaceWith(s)}catch(e){console.warn("Unable to update HTML")}}});const l=window.wp.apiFetch;var c=r.n(l);const d=window.wp.url,u=window.wp.htmlEntities;customElements.define("auto-complete",class extends HTMLElement{static observedAttributes=["mode","content-types","taxonomy","disabled","placeholder"];connectedCallback(){n(this)}readyInit(){this.hasAttribute("is-ready")||(this.itemTemplate=this.querySelector("template")?.content,this.itemTemplate&&(this.currentSearch="",this.currentPage=1,this.totalPages=1,this.perPage=10,this.minChars=2,this.initialiseMode(),this.searchInput=null,this.clearSearch=null,this.searchResults=null,this.displaySelected=null,this.setupDOM(),this.renderSelection(),this.searchInput.addEventListener("keyup",this),this.clearSearch.addEventListener("click",this),this.searchResults.addEventListener("click",this),this.displaySelected.addEventListener("click",this),o(this,"auto-complete","ready",{items:this.selectedItems}),this.setAttribute("is-ready","")))}setupDOM(){if(!this.searchInput&&!this.clearSearch){let t=document.createElement("div");t.classList.add("search"),this.searchInput=document.createElement("input"),this.searchInput.setAttribute("type","text"),this.searchInput.setAttribute("autocomplete","off"),this.disabled&&this.searchInput.setAttribute("disabled",""),this.searchInput.classList.add("auto-complete","search-icon"),this.searchInput.id=this.getAttribute("label-id")||"auto-complete-"+Math.floor(100*Math.random()),this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`),t.append(this.searchInput),this.clearSearch=document.createElement("button"),this.clearSearch.setAttribute("type","button"),this.clearSearch.setAttribute("data-type","reset"),this.clearSearch.setAttribute("aria-label",`${(0,e.__)("Reset search","personalizewp")}`),this.clearSearch.innerHTML='<svg width="24" height="24"><use xlink:href="#pwp-icon-cross"></use></svg>',this.hideClearSearch(),t.append(this.clearSearch),this.append(t)}this.searchResults||(this.searchResults=document.createElement("ul"),this.searchResults.classList.add("search-results"),this.append(this.searchResults)),this.displaySelected||(this.displaySelected=document.createElement("ul"),this.displaySelected.classList.add("tag-list","cluster"),this.append(this.displaySelected))}initialiseMode(){this.mode=this.getAttribute("mode")||"post",this.disabled=this.getAttribute("disabled")||!1,this.taxonomy=this.getAttribute("taxonomy")||null,this.contentTypes=this.getAttribute("content-types")||[],0!==this.contentTypes.length&&(this.contentTypes=this.contentTypes.split(",").map(e=>e.replace(/[^a-z0-9_\-]/,""))),this.selectedItems=this.getAttribute("content")||[],0!==this.selectedItems.length&&(this.selectedItems=JSON.parse(this.selectedItems)),this.restBase=null,"term"===this.mode&&(window.PWPTaxonomyRestBases&&(this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null),this.restBase||c()({path:"wp/v2/taxonomies"}).then(e=>{const t={};for(const r in e)t[`${r}`]=e[`${r}`].rest_base;window.PWPTaxonomyRestBases=t,this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null,this.restBase||this.setAttribute("disabled","")}).catch(e=>{console.log("catching error...",e),this.setAttribute("disabled","")}))}handleEvent(e){this[`handle${e.type}`](e)}handlekeyup(e){clearTimeout(this.debouce),""===this.searchInput.value?this.hideClearSearch():this.showClearSearch(),this.debouce=setTimeout(()=>{this.handleSearchStringChange(this.searchInput.value,this.currentPage)},250)}handleclick(e){e.preventDefault();let t=e.target.closest("button");if(!t)return;let r=t.getAttribute("data-type");if(r)switch(r){case"reset":this.currentPage=1,this.currentSearch="",this.searchInput.value="",this.resetSearchResults(),this.searchInput.focus(),this.hideClearSearch();break;case"load-more":this.currentPage++,this.handleSearchStringChange(this.searchInput.value,this.currentPage),t.closest("li").remove();break;case"selected":t.closest("li").remove(),this.removeSelectedItem(t.value);break;case"search":this.addSelectedItem(t.value,t.querySelector(".header").textContent)}}attributeChangedCallback(e,t,r){this.hasAttribute("is-ready")&&this[`handleChange${e=e.replace(/[^a-zA-Z0-9]/i,"")}`](t,r)}handleChangeplaceholder(t){this.searchInput&&this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`)}handleChangemode(e,t){this.initialiseMode()}handleChangecontenttypes(e,t){t&&0!==t.length?this.contentTypes=t.split(",").map(e=>e.replace(/[^a-z0-9_\-]/,"")):this.contentTypes=[]}handleChangetaxonomy(e,t){if(null===t||""===t)return this.taxonomy=null,void this.setAttribute("disabled","");this.taxonomy=t,this.resetSearchResults(),this.initialiseMode(),null!==e&&""!==e||(e="%TAXONOMY%");const r=this.itemTemplate.querySelector('input[type="hidden"][name^="pwp_form"]');r&&r.setAttribute("name",r.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`)),this.displaySelected.querySelectorAll('input[type="hidden"][name^="pwp_form"]').forEach(t=>{t.setAttribute("name",t.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`))}),this.removeAttribute("disabled")}handleChangedisabled(e,t){null!==t?(this.disabled=!0,this.searchInput&&this.searchInput.setAttribute("disabled",""),this.resetSearchResults()):(this.disabled=!1,this.searchInput&&this.searchInput.removeAttribute("disabled"))}removeSelectedItem(e){let t=this.selectedItems.findIndex(t=>t.value===e);-1!==t&&(this.selectedItems.splice(t,1),this.renderSelection(),o(this,"auto-complete","remove-item",{item:e,items:this.selectedItems}))}addSelectedItem(e,t){-1===this.selectedItems.findIndex(t=>t.value===e)&&(this.selectedItems.unshift({value:e,text:t}),this.renderSelection(),o(this,"auto-complete","add-item",{newItem:e,items:this.selectedItems}))}renderSelection(){this.displaySelected&&this.displaySelected.replaceChildren(...Array.from(this.selectedItems).map(e=>{let t=document.createElement("li");return t.append(this.itemTemplate.cloneNode(!0)),t.querySelector("span").textContent=e.text,t.querySelector("input").value=e.value,t.querySelector("button").value=e.value,t.querySelector("button").setAttribute("data-type","selected"),t}))}showLoading(){if(this.searchResults.querySelector(".loading"))return;let e=document.createElement("li");e.classList.add("loading"),e.innerHTML='<svg class="components-spinner" viewBox="0 0 100 100" width="20" height="20" xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false"><circle cx="50" cy="50" r="50" vector-effect="non-scaling-stroke" fill="transparent" stroke="#ddd" stroke-width="2"></circle><path d="m 50 0 a 50 50 0 0 1 50 50" vector-effect="non-scaling-stroke" fill="transparent" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>',this.searchResults.append(e)}hideLoading(){const e=this.searchResults.querySelector(".loading");e&&e.remove()}showNothingFound(){if(this.searchResults.querySelector(".nothing"))return;let t=document.createElement("li");t.classList.add("nothing"),t.textContent=`${(0,e.__)("Nothing found.","personalizewp")}`,this.searchResults.replaceChildren(t)}hideClearSearch(){this.clearSearch.style.display="none"}showClearSearch(){this.clearSearch.style.display=""}showLoadMore(){if(this.searchResults.querySelector(".load-more"))return;let t=document.createElement("li");t.classList.add("load-more"),t.innerHTML=`<button type="button" data-type="load-more">${(0,e.__)("Load more","personalizewp")}</button>`,this.searchResults.append(t)}resetSearchResults(){this.searchResults&&this.searchResults.replaceChildren()}resetAll(){this.selectedItems=[],this.renderSelection(),this.currentSearch="",this.currentPage=1,this.resetSearchResults(),this.searchInput&&(this.searchInput.value=""),o(this,"auto-complete","reset-all")}renderResults(e){this.hideLoading(),0!==e.length?(1===this.currentPage&&this.resetSearchResults(),this.searchResults.append(...Array.from(e).map(e=>{let t=document.createElement("span");t.classList.add("header"),t.textContent=e.text;let r=document.createElement("button");if(r.value=e.value,r.setAttribute("type","button"),r.setAttribute("data-type","search"),r.append(t),e.info){let t=document.createElement("span");t.classList.add("info"),t.setAttribute("aria-hidden","true"),t.textContent=e.info,r.append(t)}let s=document.createElement("li");return s.append(r),s})),this.totalPages>this.currentPage&&this.showLoadMore()):this.showNothingFound()}normalizeResults(e){let t=[];switch(this.mode){case"form":case"product":e.forEach(e=>{let r={value:e.value,text:(0,u.decodeEntities)(e.title)};e.url&&(r.info=(0,d.filterURLForDisplay)((0,d.safeDecodeURI)(e.url),30)),t.push(r)});break;case"term":e.forEach(e=>{t.push({value:e.id,text:(0,u.decodeEntities)(e.name),info:(0,d.filterURLForDisplay)((0,d.safeDecodeURI)(e.link),30)})});break;case"post":e.forEach(e=>{t.push({value:e.id,text:(0,u.decodeEntities)(e.title),info:(0,d.filterURLForDisplay)((0,d.safeDecodeURI)(e.url),30)})})}return t}handleSearchStringChange(e,t){if(""===(e=e.trim()))return this.currentSearch="",this.currentPage=1,void this.resetSearchResults();if(e!==this.currentSearch&&(this.currentPage=1,this.currentSearch=e),e.length<this.minChars)return;this.showLoading();let r=this.prepareSearchQuery(e,t);this.contentSearch(r)}prepareSearchQuery(e,t){let r,s;switch(this.mode){case"product":s={search:e,_embed:!0,per_page:this.perPage,page:t},this.contentTypes&&0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,d.addQueryArgs)("personalizewp/v1/products-search",s);break;case"form":s={search:e,_embed:!0,per_page:this.perPage,page:t},r=(0,d.addQueryArgs)("personalizewp/v1/forms-search",s);break;case"term":s={search:e,per_page:this.perPage,page:t},r=(0,d.addQueryArgs)(`wp/v2/${this.restBase}`,s);break;default:s={search:e,type:this.mode,_embed:!0,per_page:this.perPage,page:t},0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,d.addQueryArgs)("wp/v2/search",s)}return r}contentSearch(e){c()({path:e,parse:!1}).then(e=>{this.totalPages=parseInt(e.headers&&e.headers.get("X-WP-TotalPages"),10),e.json().then(e=>{const t=this.normalizeResults(e);this.renderResults(t)})}).catch(e=>{console.log("catching error..."),this.hideLoading()})}}),customElements.define("custom-tag-list",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("input")||!1,t=this.getAttribute("submit")||!1,r=this.getAttribute("list")||!1;e&&t&&r&&(this.itemInput=this.querySelector(`#${e}`),this.itemSubmit=this.querySelector(`#${t}`),this.itemList=this.querySelector(`#${r}`),this.itemTemplate=this.querySelector("template")?.content,this.itemInput&&this.itemSubmit&&this.itemList&&this.itemTemplate&&(this.itemSubmit.removeAttribute("hidden"),this.itemSubmit.addEventListener("click",this),o(this,"custom-tag-list","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`handle${e.type}`](e)}handleclick(e){e.preventDefault();const t=this.itemInput.value.trim();if(""===t)return;const r=this.itemTemplate.cloneNode(!0);r.querySelector("span").textContent=t,r.querySelector("input").value=t,this.itemList.appendChild(r),this.itemInput.value=""}}),customElements.define("custom-tag",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;if(this.itemInput=this.querySelector("input"),this.itemButton=this.querySelector("button"),!this.itemInput||!this.itemButton)return;this.itemLabel=this.querySelector("label")||null;const e=this.itemButton.getAttribute("data-confirm-modal"),t=e?document.querySelector(e):null;this.dialog=e&&void 0!==window.HTMLDialogElement&&t?t:null,this.itemInput.setAttribute("type","hidden"),this.itemLabel&&(this.itemLabel.style.pointerEvents="none"),this.itemButton.removeAttribute("hidden"),this.itemButton.addEventListener("click",this),this.setAttribute("is-ready","")}handleEvent(e){this[`handle${e.type}`](e)}handleclose(e){this.dialog.removeEventListener("close",this),"delete"===this.dialog.returnValue&&this.remove()}handleclick(e){e.preventDefault(),this.dialog?(this.dialog.addEventListener("close",this),this.dialog.showModal()):this.remove()}});s()(()=>{window.pwpSettings&&""!==window.pwpSettings?.kb&&document.querySelector(`ul#adminmenu a[href='${window.pwpSettings.kb}']`)?.setAttribute("target","_blank");const t=document.querySelector("form[data-pwp]");t&&(e=>{const t=e.querySelector("#pwp_form_type"),r=e.querySelectorAll("[data-condition-type]");if(!t||0===r.length)return;const s=e.querySelector("#condition-addition"),i=e.querySelector("#condition-operator"),a=function(e){r.forEach(t=>{const r=t.getAttribute("data-condition-type")===e;if(t.hidden=!r,r){const e=null===t.querySelector(":scope > template");if(s.hidden=e,i){const r=null===t.querySelector(":scope auto-complete");i.hidden=r&&e}o(t,!0)}r||o(t)})},o=function(e,t=!1){t?e.querySelectorAll("[data-required]").forEach(e=>{e.removeAttribute("data-required"),e.required=!0}):e.querySelectorAll("[required]").forEach(e=>{e.setAttribute("data-required","required"),e.required=!1})};t.addEventListener("change",function(){a(t.options[t.selectedIndex].value)});var n=t.selectedIndex?t.options[t.selectedIndex].value:"";a(n);const l=e=>{const t=e.querySelectorAll('[data-type="taxonomy"]');t.length&&t.forEach(e=>{e.addEventListener("change",function(){const t=e.selectedIndex?e.options[e.selectedIndex].value:"",r=e.closest('[data-condition="row"]');if(r){const e=r.querySelector("auto-complete");e&&e.setAttribute("taxonomy",t)}})})};l(e),e.addEventListener("click",function(t){let r=t.target.closest("button");if(r){var s,i,a,o=!1;switch(r.value){case"add":a=(i=e.querySelector("[data-condition-type]:not([hidden])")).querySelector(":scope > template").content.cloneNode(!0),i.appendChild(a),l(e),o=!0;break;case"remove":(i=(s=r.closest('[data-condition="row"]')).closest("[data-condition-type]")).removeChild(s),o=!0}if(o){var n=i.querySelectorAll('[data-condition="row"]').length;i.setAttribute("data-condition-count",n)}}})})(t);var r=document.querySelectorAll("dialog.dialog");0!==r.length&&r.forEach(e=>{e.addEventListener("click",function(t){if(t.target.matches("dialog"))return e.close("close"),void t.stopPropagation();const r=t.target.closest("button");return r&&r.matches("button[value=close]")?(e.close("close"),void t.stopPropagation()):void 0})}),document.addEventListener("click",function(e){var t=e.target.closest("[data-show-modal]");if(!t)return;const r=t.getAttribute("data-show-modal"),s=document.querySelector(r);if(void 0!==window.HTMLDialogElement&&s){if(s.hasAttribute("data-url-action")){let e;t.hasAttribute("href")&&(e=t.getAttribute("href")),t.hasAttribute("data-form-action")&&(e=t.getAttribute("data-form-action")),e&&s.querySelector("form").setAttribute("action",e)}if("#editCategoryModal"===r){const e=t.getAttribute("href"),r=t.getAttribute("data-id"),i=t.getAttribute("data-name");s.querySelector("form").setAttribute("action",e),s.querySelector('[name="personalizewp_form[id]"]').value=r,s.querySelector('[name="personalizewp_form[name]"]').value=i}e.preventDefault(),s.showModal()}});const s=document.querySelector("ajax-form#newsletter-signup");s&&(s.addEventListener("pwp-ajax-form:submit-before",e=>{s.querySelectorAll(".field-error").forEach(e=>{e.classList.remove("field-error"),e.querySelector(".input-error").hidden=!0})}),s.addEventListener("pwp-ajax-form:error",e=>{var t;const r=null!==(t=e.detail?.errors)&&void 0!==t?t:[];r.length&&r.forEach(e=>{const t=s.querySelector(`input[name="${e}"]`).closest(".field"),r=t.querySelector(".input-error");t.classList.add("field-error"),r.hidden=!1})}),s.addEventListener("pwp-ajax-form:success",e=>{s.querySelectorAll(".actions button").forEach(e=>{e.hidden=!e.hidden})}));const i=document.querySelectorAll(".notice[data-dismiss-type]");0!==i.length&&i.forEach(e=>{e.addEventListener("click",function(t){if(!t.target.matches("button"))return;t.stopPropagation();const r=e.getAttribute("data-dismiss-type"),s=new FormData;s.append("action",`pwp_dismiss_${r}_message`),s.append("_ajax_nonce",pwpSettings.nonce),async function(e){let t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);const r=await fetch(pwpSettings.url,{method:"POST",headers:{Accept:"application/json, */*;q=0.1","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"},body:t.toString()});await r.json();r.ok}(s)})}),document.querySelector(".pwp-page [data-tabs]")&&(new(a())(".pwp-page [data-tabs]",{idPrefix:"pwp_"}),document.addEventListener("tabby",function(e){e.detail.tab.classList.add("is-active"),e.detail.previousTab.classList.remove("is-active")},!1)),(()=>{window.pwpSaveAlert=!1;const e=document.querySelectorAll("[data-save-alert]");if(0!==e.length){let t=[];e.forEach(e=>{var r;e.addEventListener("click",function(){window.pwpSaveAlert=!0});const s=null!==(r=e.getAttribute("form"))&&void 0!==r&&r;s?t.push(document.getElementById(s)):t.push(e.closest("form"))}),t.forEach(e=>{e.addEventListener("submit",function(){window.pwpSaveAlert=!1})})}const t=document.querySelectorAll("[data-clear-save-alert]");0!==t.length&&t.forEach(e=>{e.addEventListener("click",function(){window.pwpSaveAlert=!1})}),window.addEventListener("beforeunload",e=>{window.pwpSaveAlert&&(e.preventDefault(),e.returnValue=!0)})})();const o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;"woocommerce_time_since_last_order"===s&&(a=(0,e.__)("Enter number of days","personalizewp")),a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)},n=document.querySelector("#pwp-form");n&&((t=>{if(!t)return;if(!(t.querySelector(".conditions-measure")||document.body.classList.contains("post-type-personalizewp_rule")||t.classList.contains("personalizewp-rules-form")))return;const r=window.pwpRuleFormEx?.autocomplete_conditions||["woocommerce_product_stock_level","woocommerce_product_quantity_in_cart","woocommerce_category_quantity_in_cart"],s=e=>r.includes(e),i=e=>{const t=e.closest(".condition"),r=t?.querySelector(".rule-condition-values");if(!r)return;const s=(e.selectedItems||[]).map(e=>(e=>{if(!e)return"";if(/^\d+$/.test(e))return e;const t=e.match(/:(\d+)$/);return t?t[1]:e})(e.value||e.id)).filter(Boolean).join(",");r.value!==s&&(r.value=s)},a=(e,t)=>{const r=e.querySelector(".autocomplete-field-wrapper");t?(r&&(r.style.display="block"),e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{e.style.display="none";const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!0,t.value="")})):r&&(r.style.display="none",e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!1)}))},o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;switch(s){case"woocommerce_product_quantity_in_cart":a=(0,e.__)("No. of product","personalizewp");break;case"woocommerce_category_quantity_in_cart":a=(0,e.__)("No. of category","personalizewp");break;default:const t=i.getAttribute("data-initial-placeholder");t&&(a=t)}a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)};t.addEventListener("change",t=>{if(!t.target.classList.contains("conditions-measure"))return;const r=t.target.closest(".condition"),i=t.target.value;if(s(i)){const t=r.querySelector(".autocomplete-field-wrapper"),s=r.querySelector("auto-complete.rule-condition-autocomplete");t?(s&&((t,r)=>{const s={woocommerce_product_stock_level:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_product_quantity_in_cart:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_category_quantity_in_cart:{mode:"product","content-types":"categories",placeholder:(0,e.__)("Search for a category","personalizewp")}}[r];s&&t&&(t.setAttribute("mode",s.mode),t.setAttribute("placeholder",s.placeholder),t.removeAttribute("taxonomy"),t.setAttribute("content-types",s["content-types"]),setTimeout(()=>{t.removeAttribute("disabled"),"function"==typeof t.resetAll&&t.resetAll()},10))})(s,i),a(r,!0)):((e,t)=>{const r=document.getElementById(`pwp-autocomplete-template-${t}`);if(!r)return;const s=r.content.cloneNode(!0).querySelector(".autocomplete-field-wrapper");if(s){const t=e.querySelector(".conditions-comparator");t&&t.before(s),o(e),a(e,!0)}})(r,i)}else{const e=r.querySelector("auto-complete.rule-condition-autocomplete");e&&"function"==typeof e.resetAll&&e.resetAll(),a(r,!1)}o(r)});const n=e=>{t.querySelectorAll("auto-complete.rule-condition-autocomplete").forEach(i)};t.addEventListener("submit",n);const l=(e,r)=>{const s=t.querySelector("#form-actions");(r?.detail?.items?.length&&s||s)&&jQuery(s).show(),n()};t.addEventListener("pwp-auto-complete:remove-item",l),t.addEventListener("pwp-auto-complete:add-item",l),t.querySelectorAll(".condition").forEach(e=>{const t=e.querySelector(".conditions-measure"),r=t?.value;if(r&&s(r)){const t=e.querySelector(".autocomplete-field-wrapper"),r=e.querySelector(".conditions-comparator");r&&r.before(t),o(e),a(e,!0)}})})(n),n.querySelectorAll(".condition").forEach(o),n.addEventListener("change",e=>{if(!e.target.classList.contains("conditions-measure"))return;const t=e.target.closest(".condition");t&&o(t)}))})})()})(); -
personalizewp/tags/3.2.2/admin/partials/scoring-rules/_form.php
r3380017 r3382403 221 221 if ( is_numeric( $cpt_page ) ) : 222 222 $page_ids[] = array( 223 'value' => ( int) $cpt_page,223 'value' => (string) $cpt_page, // Web component standardises on strings 224 224 'text' => get_the_title( $cpt_page ), 225 225 ); -
personalizewp/tags/3.2.2/admin/partials/segments/_form.php
r3380017 r3382403 293 293 if ( is_a( $term_cond, '\WP_Term' ) ) : 294 294 $taxonomies[ $tax_cond ][] = array( 295 'value' => $term_cond->term_id,295 'value' => (string) $term_cond->term_id, // Web component standardises on strings 296 296 'text' => esc_html( $term_cond->name ), 297 297 ); … … 590 590 if ( is_numeric( $cpt_page ) ) : 591 591 $page_ids[] = array( 592 'value' => ( int) $cpt_page,592 'value' => (string) $cpt_page, // Web component standardises on strings 593 593 'text' => get_the_title( $cpt_page ), 594 594 ); -
personalizewp/tags/3.2.2/build/blocks/product-collection/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/product-collection", 5 "version": "1.0. 0",6 "title": "P ersonalizeWP Product Collection",5 "version": "1.0.1", 6 "title": "Product Collection", 7 7 "description": "Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.", 8 "category": " woocommerce",8 "category": "personalizewp", 9 9 "keywords": [ 10 10 "PersonalizeWP", 11 "pwp", 11 12 "WooCommerce", 12 13 "personalization", -
personalizewp/tags/3.2.2/build/blocks/product-collection/index.asset.php
r3380017 r3382403 1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => ' f3b4f67fee01300afd98');1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'b07c136b179f020339de'); -
personalizewp/tags/3.2.2/build/blocks/product-collection/index.js
r3380017 r3382403 1 (()=>{"use strict";var e,t={20:(e,t,o)=>{var l=o(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,o){var l,i={},s=null,p=null;for(l in void 0!==o&&(s=""+o),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(p=t.ref),t)n.call(t,l)&&!r.hasOwnProperty(l)&&(i[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===i[l]&&(i[l]=t[l]);return{$$typeof:a,type:e,key:s,ref:p,props:i,_owner:c.current}}},539:(e,t,o)=>{var l=o(609);const a=window.wp.blocks,n=window.wp.i18n,c=window.wp.blockEditor,r=window.wp.components,i=window.wp.element,s=window.wp.primitives;var p=o(848);const d=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})}),u=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})}),m=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{fillRule:"evenodd",d:"M19.75 11H21V8.667L19.875 4H4.125L3 8.667V11h1.25v8.75h15.5V11zm-1.5 0H5.75v7.25H10V13h4v5.25h4.25V11zm-5.5-5.5h2.067l.486 3.24.028.76H12.75v-4zm-3.567 0h2.067v4H8.669l.028-.76.486-3.24zm7.615 3.1l-.464-3.1h2.36l.806 3.345V9.5h-2.668l-.034-.9zM7.666 5.5h-2.36L4.5 8.845V9.5h2.668l.034-.9.464-3.1z",clipRule:"evenodd"})}),w=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"m3 5c0-1.10457.89543-2 2-2h13.5c1.1046 0 2 .89543 2 2v13.5c0 1.1046-.8954 2-2 2h-13.5c-1.10457 0-2-.8954-2-2zm2-.5h6v6.5h-6.5v-6c0-.27614.22386-.5.5-.5zm-.5 8v6c0 .2761.22386.5.5.5h6v-6.5zm8 0v6.5h6c.2761 0 .5-.2239.5-.5v-6zm0-8v6.5h6.5v-6c0-.27614-.2239-.5-.5-.5z",fillRule:"evenodd",clipRule:"evenodd"})}),_=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})}),g=window.wp.apiFetch;var h=o.n(g);const b=[{name:"previously-viewed",title:(0,n.__)("Previously Viewed Products","personalizewp"),icon:d,description:(0,n.__)("Display products that visitors have recently browsed on your store","personalizewp"),details:(0,n.__)('Creates a "Recently Viewed" section showing products the current visitor has looked at before. Perfect for helping customers continue their shopping journey.',"personalizewp"),keywords:["viewed","history","recent"],color:"#7c3aed",gradient:"linear-gradient(135deg, #7c3aed 0%, #a855f7 100%)"},{name:"products-for-you",title:(0,n.__)("Products For You","personalizewp"),icon:u,description:(0,n.__)("Personalized product recommendations based on visitor segments and behavior","personalizewp"),details:(0,n.__)("Shows tailored product recommendations using PersonalizeWP's visitor segments and behavioral data. Displays products from relevant categories and frequently bought together items.","personalizewp"),keywords:["recommended","personalized","segments"],color:"#059669",gradient:"linear-gradient(135deg, #059669 0%, #10b981 100%)"}];function v({collection:e,onSelect:t,isSelected:o=!1}){const a=(0,i.useCallback)(()=>{t(e.name)},[e.name,t]),n=(0,i.useMemo)(()=>({"--collection-color":e.color,"--collection-gradient":e.gradient}),[e.color,e.gradient]);return(0,l.createElement)(r.Tooltip,{text:e.details,placement:"top"},(0,l.createElement)("button",{type:"button",className:"components-button wc-blocks-product-collection__collection-button "+(o?"is-selected":""),onClick:a,style:n,"aria-pressed":o,"aria-describedby":`collection-${e.name}-description`},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collection-button-icon"},(0,l.createElement)(r.Icon,{icon:e.icon,size:24})),(0,l.createElement)("p",{className:"wc-blocks-product-collection__collection-button-title",id:`collection-${e.name}-description`},e.title)))}function y({isOpen:e,onClose:t,onSelect:o,currentCollection:a}){const[c,s]=(0,i.useState)(a),p=(0,i.useCallback)(()=>{c&&(o(c),t())},[c,o,t]),d=(0,i.useCallback)(e=>{s(e)},[]),u=Boolean(c);return(0,l.createElement)(r.Modal,{className:"wc-blocks-product-collection__modal pwp-collection-picker-modal",onRequestClose:t,size:"large",shouldCloseOnClickOutside:!1,title:(0,n.__)("What products do you want to show?","personalizewp")},(0,l.createElement)("div",{className:"wc-blocks-product-collection__content"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-grid"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-section"},b.map(e=>(0,l.createElement)(v,{key:e.name,collection:e,onSelect:d,isSelected:c===e.name})))),(0,l.createElement)(r.Flex,{className:"wc-blocks-product-collection__footer",justify:"flex-end",gap:3},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",onClick:t},(0,n.__)("Cancel","personalizewp"))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"primary",onClick:p,disabled:!u},(0,n.__)("Continue","personalizewp"))))))}function C({onOpenModal:e}){return(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder"},(0,l.createElement)(r.Card,null,(0,l.createElement)(r.CardBody,null,(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder__content"},(0,l.createElement)("h3",{className:"pwp-collection-picker-placeholder__title"},(0,n.__)("PersonalizeWP Product Collection","personalizewp")),(0,l.createElement)("p",{className:"pwp-collection-picker-placeholder__description"},(0,n.__)("Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.","personalizewp")),(0,l.createElement)(r.Button,{variant:"primary",onClick:e,className:"pwp-collection-picker-placeholder__button"},(0,n.__)("Choose Recipe","personalizewp"))))))}function E({collection:e,onChangeCollection:t}){const o=(0,i.useMemo)(()=>b.find(t=>t.name===e),[e]);return o?(0,l.createElement)(r.Card,{className:"pwp-selected-collection"},(0,l.createElement)(r.CardBody,null,(0,l.createElement)(r.Flex,{direction:"column",gap:2},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Flex,{justify:"space-between",align:"center"},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("h4",{className:"pwp-selected-collection__title"},o.title)),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",size:"small",onClick:t,className:"pwp-selected-collection__change-button"},(0,n.__)("Change","personalizewp"))))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("p",{className:"pwp-selected-collection__description"},o.description))))):null}function f({currentCollection:e,onCollectionChange:t}){const[o,a]=(0,i.useState)(!1),n=(0,i.useCallback)(()=>{a(!0)},[]),c=(0,i.useCallback)(()=>{a(!1)},[]),r=(0,i.useCallback)(e=>{t(e),c()},[t,c]);return(0,l.createElement)(l.Fragment,null,e?(0,l.createElement)(E,{collection:e,onChangeCollection:n}):(0,l.createElement)(C,{onOpenModal:n}),o&&(0,l.createElement)(y,{isOpen:o,onClose:c,onSelect:r,currentCollection:e}))}const k=[{title:(0,n.__)("Previously Viewed Products","personalizewp"),value:"previously-viewed",icon:d,info:(0,n.__)("Display products that the current visitor has recently browsed on your store.","personalizewp")},{title:(0,n.__)("Products For You","personalizewp"),value:"products-for-you",icon:u,info:(0,n.__)("Show personalized product recommendations based on visitor segments, categories, and related products.","personalizewp")}],x=[{label:(0,n.__)("Show All Products","personalizewp"),value:"show_all"},{label:(0,n.__)("Hide Block","personalizewp"),value:"hide_block"},{label:(0,n.__)("Show Custom Message","personalizewp"),value:"show_message"}],z=[{id:1,name:"Sample Product",price_html:"$19.99",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"simple",average_rating:4.5,permalink:"#"},{id:2,name:"Variable Product",price_html:"$20.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"variable",average_rating:4,permalink:"#"},{id:3,name:"External Product",price_html:"$15.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"external",button_text:"Buy on external store!",average_rating:5,external_url:"#",permalink:"#"}],P=(e,t)=>{switch(t.type){case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_PRODUCTS":return{...e,products:t.payload,isLoading:!1,error:null};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"RESET":return{products:[],isLoading:!1,error:null};default:return e}},N=({product:e,layoutType:t,index:o,totalProducts:a,onButtonClick:c})=>{const r=function(e){return(0,i.useMemo)(()=>{let t=(0,n.__)("Add to cart","personalizewp"),o="add_to_cart_button ajax_add_to_cart",l="product-type-simple",a=!1;return"external"===e.type?(t=e.button_text||(0,n.__)("Buy product","personalizewp"),o="product_type_external",l="product-type-external",a=!0):"variable"===e.type&&(t=(0,n.__)("Select options","personalizewp"),o="product_type_variable",l="product-type-variable"),{text:t,className:o,typeClass:l,isExternal:a}},[e.type,e.button_text])}(e),s=e.price_html&&e.price_html.includes("<del"),p=function(e,t,o,l,a){return(0,i.useMemo)(()=>["wc-block-product",`post-${e.id}`,"product","type-product","status-publish",e.image_url?"has-post-thumbnail":"","instock","shipping-taxable","purchasable",t.typeClass,"list"===o?"pwp-list-item":"",0===l?"first":"",l===a-1?"last":""].filter(Boolean).join(" "),[e,t.typeClass,o,l,a])}(e,r,t,o,a),d=e.image_url||"/wp-content/uploads/woocommerce-placeholder-300x300.png";return(0,l.createElement)("li",{className:p},(0,l.createElement)("div",{className:"wc-block-components-product-image wc-block-grid__product-image wp-block-woocommerce-product-image"},(0,l.createElement)("a",{href:"#",onClick:c},s&&(0,l.createElement)("div",{className:"wc-block-components-product-sale-badge wc-block-components-product-sale-badge--align-right wc-block-grid__product-onsale"},(0,l.createElement)("span",{"aria-hidden":"true"},(0,n.__)("Sale","personalizewp")),(0,l.createElement)("span",{className:"screen-reader-text"},(0,n.__)("Product on sale","personalizewp"))),(0,l.createElement)("img",{decoding:"async",width:"300",height:"300",src:d,alt:e.name,className:"attachment-woocommerce_thumbnail size-woocommerce_thumbnail",style:{maxWidth:"none",objectFit:"cover"}}))),(0,l.createElement)("h3",{style:{marginBottom:"0.75rem",marginTop:0},className:"has-text-align-center wp-block-post-title has-medium-font-size"},(0,l.createElement)("a",{href:"#",onClick:c,target:"_self"},e.name)),e.average_rating>0&&(0,l.createElement)("div",{className:"wc-block-components-product-rating"},(0,l.createElement)("div",{className:"wc-block-components-product-rating__stars","aria-label":`${e.average_rating} out of 5 stars`},"★".repeat(Math.floor(e.average_rating)),"☆".repeat(5-Math.floor(e.average_rating)))),(0,l.createElement)("div",{className:"wp-block-woocommerce-product-price"},(0,l.createElement)("div",{className:"wc-block-components-product-price wc-block-grid__product-price has-text-align-center has-font-size has-small-font-size"},(0,l.createElement)("span",{dangerouslySetInnerHTML:{__html:e.price_html}}))),(0,l.createElement)("div",{className:"wp-block-button wc-block-components-product-button align-center wp-block-woocommerce-product-button has-small-font-size"},r.isExternal?(0,l.createElement)("a",{href:"#",className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow noopener",target:"_blank"},(0,l.createElement)("span",null,r.text)):(0,l.createElement)("button",{className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow"},(0,l.createElement)("span",null,r.text))))};function T({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("div",{className:"pwp-loading-spinner",style:{display:"inline-block",width:"20px",height:"20px",border:"2px solid #ddd",borderTop:"2px solid #874FB9",borderRadius:"50%",animation:"spin 1s linear infinite",marginRight:"8px"}}),(0,n.__)("Loading personalized products...","personalizewp")))}function B({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("Unable to load products. Using fallback display.","personalizewp"))))}function S({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("No products found for this personalization recipe.","personalizewp")),(0,l.createElement)("p",null,(0,l.createElement)("small",null,(0,n.__)("Try viewing some products on your site first.","personalizewp")))))}function M({products:e,layoutType:t,gridColumns:o,onButtonClick:a}){const n="list"===t?"pwp-layout-list":"pwp-layout-grid",c="grid"===t?`columns-${o}`:"columns-1";return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${n}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("ul",{className:`${c} wc-block-product-template__responsive wc-block-product-template wp-block-woocommerce-product-template`},e.map((o,n)=>(0,l.createElement)(N,{key:o.id,product:o,layoutType:t,index:n,totalProducts:e.length,onButtonClick:a}))))}const R=JSON.parse('{"UU":"personalizewp-pro/product-collection"}'),L={src:(0,l.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)("path",{fill:"url(#paint0_linear_311_20854)",d:"M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"}),(0,l.createElement)("defs",null,(0,l.createElement)("linearGradient",{id:"paint0_linear_311_20854"},(0,l.createElement)("stop",{offset:".16",stopColor:"#C127A0"}),(0,l.createElement)("stop",{offset:".28",stopColor:"#CD20A1"}),(0,l.createElement)("stop",{offset:".59",stopColor:"#E813A4"}),(0,l.createElement)("stop",{offset:".76",stopColor:"#F20FA6"}))))};(0,a.registerBlockType)(R.UU,{icon:L,edit:function(e){const{attributes:t,setAttributes:o,clientId:a}=e,{queryId:s,query:p={},displayLayout:d={type:"flex",columns:3},layoutType:u="grid",gridColumns:g=3,pwpRecipe:b,pwpFallbackBehavior:v="show_all",pwpMaxProducts:y=8,pwpFallbackMessage:C="",pwpCollectionTitle:E=""}=t,[N,R]=(0,i.useReducer)(P,{products:[],isLoading:!1,error:null}),L=(0,i.useMemo)(()=>k.find(e=>e.value===b),[b]),O=(0,i.useCallback)(e=>{e.preventDefault()},[]),F=(0,i.useCallback)(async()=>{try{h()({path:`/wc/store/v1/products?per_page=${y||6}&orderby=date&order=desc`}).then(e=>{const t=e.map(e=>({id:e.id,name:e.name,permalink:e.permalink,excerpt:e.short_description||e.description,image_url:e.images&&e.images.length>0?e.images[0].src:null,price_html:e.price_html||`$${e.prices.price}`,average_rating:parseFloat(e.average_rating)||0,rating_count:e.rating_count||0,type:e.type||"simple",external_url:e.external_url||"",button_text:e.button_text||"",sku:e.sku||""}));R({type:"SET_PRODUCTS",payload:t})})}catch(e){R({type:"SET_PRODUCTS",payload:[]})}},[y]),V=(0,i.useCallback)(async()=>{if(b){R({type:"SET_LOADING",payload:!0});try{if(window.PersonalizeWP&&window.PersonalizeWP.getVisitorUID){const e=window.PersonalizeWP.getVisitorUID();if(e){let t=[];switch(b){case"previously-viewed":const o=await window.PersonalizeWP.fetchVisitorActivities(e,{activity_type:"post",object_type:"product"});t=window.PersonalizeWP.getPreviouslyViewedProducts(o,y);break;case"products-for-you":const l=await window.PersonalizeWP.fetchVisitorActivities(e),a=await window.PersonalizeWP.fetchVisitorSegments(e);t=window.PersonalizeWP.getRecommendedProducts(l,a,y)}if(t.length>0){const e=await window.PersonalizeWP.fetchProductDetails(t,b);R({type:"SET_PRODUCTS",payload:e})}else await F()}else await F()}else await F()}catch(e){R({type:"SET_ERROR",payload:e.message}),await F()}}},[b,y,F]),D=(0,i.useMemo)(()=>N.isLoading?[]:N.error||0===N.products.length?z.slice(0,y||6):N.products.slice(0,y||6),[N,y]),$=(0,i.useCallback)(()=>{const e="list"===u?"pwp-layout-list":"pwp-layout-grid";return N.isLoading?(0,l.createElement)(T,{layoutClass:e}):N.error&&0===D.length?(0,l.createElement)(B,{layoutClass:e}):0===D.length?(0,l.createElement)(S,{layoutClass:e}):(0,l.createElement)(M,{products:D,layoutType:u,gridColumns:g,onButtonClick:O})},[u,N,D,g,O]),j=(0,i.useCallback)(e=>{const t=k.find(t=>t.value===e);o({pwpRecipe:e,pwpCollectionTitle:t?t.title:""})},[o]);(0,i.useEffect)(()=>{if(!s){const e=`block-${Date.now()}`;o({queryId:e})}},[s,o]),(0,i.useEffect)(()=>{const e={...p,isProductCollectionBlock:!0,pwpRecipe:b||"default",pwpMaxProducts:y,pwpFallbackBehavior:v,pwpFallbackMessage:C,lastUpdated:Date.now(),perPage:y,inherit:!1,postType:"product"},t=b?`personalizewp-${b}`:"personalizewp-default";o({query:{...e,productCollectionQueryContext:{collection:t,pwpRecipe:b,pwpMaxProducts:y,pwpFallbackBehavior:v}},collection:t})},[b,y,v,C,o]),(0,i.useEffect)(()=>{b&&!E&&L&&o({pwpCollectionTitle:L.title})},[b,E,L,o]),(0,i.useEffect)(()=>{b&&V()},[b,y,V]);const A=(0,c.useBlockProps)({className:`wp-block-personalizewp-pro-product-collection pwp-layout-${u} pwp-columns-${g}`,"data-pwp-recipe":b,"data-layout-type":u,"data-grid-columns":g});return b?(0,l.createElement)("div",{...A},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:L?.icon||m,label:(0,n.__)("Choose Collection","personalizewp"),text:L?.title||(0,n.__)("Choose Collection","personalizewp"),controls:k.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:b===e.value}))})),(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarButton,{icon:w,label:(0,n.__)("Grid View","personalizewp"),onClick:()=>o({layoutType:"grid"}),isActive:"grid"===u}),(0,l.createElement)(r.ToolbarButton,{icon:_,label:(0,n.__)("List View","personalizewp"),onClick:()=>o({layoutType:"list"}),isActive:"list"===u}))),(0,l.createElement)(c.InspectorControls,null,(0,l.createElement)(r.PanelBody,{title:(0,n.__)("Settings","personalizewp"),initialOpen:!0},(0,l.createElement)(f,{currentCollection:b,onCollectionChange:j}),(0,l.createElement)(r.SelectControl,{label:(0,n.__)("Fallback Behavior","personalizewp"),value:v,options:x,onChange:e=>o({pwpFallbackBehavior:e}),help:(0,n.__)("What to show when personalization data is not available","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"show_message"===v&&(0,l.createElement)(r.TextControl,{label:(0,n.__)("Fallback Message","personalizewp"),value:C,onChange:e=>o({pwpFallbackMessage:e}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Max Products","personalizewp"),value:y,min:1,max:20,onChange:e=>o({pwpMaxProducts:e}),help:(0,n.__)("Maximum number of products to display","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)("div",{style:{marginBottom:"16px",marginTop:"24px"}},(0,l.createElement)("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500"}},(0,n.__)("Layout","personalizewp")),(0,l.createElement)(r.ButtonGroup,null,(0,l.createElement)(r.Button,{icon:w,onClick:()=>o({layoutType:"grid"}),isPressed:"grid"===u,variant:"grid"===u?"primary":"secondary"},(0,n.__)("Grid","personalizewp")),(0,l.createElement)(r.Button,{icon:_,onClick:()=>o({layoutType:"list"}),isPressed:"list"===u,variant:"list"===u?"primary":"secondary"},(0,n.__)("List","personalizewp")))),"grid"===u&&(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Columns","personalizewp"),value:g,min:1,max:6,onChange:e=>{o({gridColumns:e,displayLayout:{...d,columns:e}})},help:(0,n.__)("Number of columns in grid layout","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"list"===u&&(0,l.createElement)("div",{style:{marginTop:"16px"}},(0,l.createElement)("p",{style:{margin:0,fontSize:"13px",color:"#757575"}},(0,n.__)("Products will be displayed in a single column list format.","personalizewp"))))),L&&(0,l.createElement)("div",{className:"pwp-collection-title"},(0,l.createElement)(c.RichText,{tagName:"h2",className:"pwp-collection-title__heading",value:E,onChange:e=>o({pwpCollectionTitle:e}),placeholder:L.title,allowedFormats:["core/bold","core/italic"]})),$()):(0,l.createElement)("div",{...A},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:m,label:(0,n.__)("Choose Collection","personalizewp"),text:(0,n.__)("Choose Collection","personalizewp"),controls:k.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:!1}))}))),(0,l.createElement)(f,{currentCollection:null,onCollectionChange:j}))},save:function(e){const{attributes:t}=e,{queryId:o,pwpRecipe:a,pwpMaxProducts:r=8,pwpFallbackBehavior:i="show_all",pwpFallbackMessage:s="Discover our featured products",pwpCollectionTitle:p,layoutType:d="grid",gridColumns:u=3}=t;if(!a)return null;const m=Math.max(1,Math.min(20,parseInt(r,10)||8)),w=o,_=s||(0,n.__)("Discover our featured products","personalizewp"),g=c.useBlockProps.save({className:"pwp-product-collection-block","data-recipe":a,"data-max-products":m,"data-fallback-behavior":i,"data-fallback-message":_,"data-block-id":w});return(0,l.createElement)("div",{...g},(0,l.createElement)("pwp-product-collection",{recipe:a,"max-products":m,"fallback-behavior":i,"fallback-message":_,"layout-type":d,"grid-columns":u,"block-id":w,"collection-title":p||""},(0,l.createElement)("div",{className:"woocommerce"},(0,l.createElement)("div",{className:"woocommerce-info"},(0,l.createElement)("span",{className:"pwp-loading-spinner"}),(0,n.__)("Loading personalized products...","personalizewp")))))}})},609:e=>{e.exports=window.React},848:(e,t,o)=>{e.exports=o(20)}},o={};function l(e){var a=o[e];if(void 0!==a)return a.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,l),n.exports}l.m=t,e=[],l.O=(t,o,a,n)=>{if(!o){var c=1/0;for(p=0;p<e.length;p++){for(var[o,a,n]=e[p],r=!0,i=0;i<o.length;i++)(!1&n||c>=n)&&Object.keys(l.O).every(e=>l.O[e](o[i]))?o.splice(i--,1):(r=!1,n<c&&(c=n));if(r){e.splice(p--,1);var s=a();void 0!==s&&(t=s)}}return t}n=n||0;for(var p=e.length;p>0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[o,a,n]},l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var o in t)l.o(t,o)&&!l.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={488:0,272:0};l.O.j=t=>0===e[t];var t=(t,o)=>{var a,n,[c,r,i]=o,s=0;if(c.some(t=>0!==e[t])){for(a in r)l.o(r,a)&&(l.m[a]=r[a]);if(i)var p=i(l)}for(t&&t(o);s<c.length;s++)n=c[s],l.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return l.O(p)},o=globalThis.webpackChunkpersonalizewp=globalThis.webpackChunkpersonalizewp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var a=l.O(void 0,[272],()=>l(539));a=l.O(a)})();1 (()=>{"use strict";var e,t={20:(e,t,o)=>{var l=o(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,o){var l,i={},s=null,p=null;for(l in void 0!==o&&(s=""+o),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(p=t.ref),t)n.call(t,l)&&!r.hasOwnProperty(l)&&(i[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===i[l]&&(i[l]=t[l]);return{$$typeof:a,type:e,key:s,ref:p,props:i,_owner:c.current}}},539:(e,t,o)=>{var l=o(609);const a=window.wp.blocks,n=window.wp.i18n,c=window.wp.blockEditor,r=window.wp.components,i=window.wp.element,s=window.wp.primitives;var p=o(848);const d=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})}),u=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})}),m=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{fillRule:"evenodd",d:"M19.75 11H21V8.667L19.875 4H4.125L3 8.667V11h1.25v8.75h15.5V11zm-1.5 0H5.75v7.25H10V13h4v5.25h4.25V11zm-5.5-5.5h2.067l.486 3.24.028.76H12.75v-4zm-3.567 0h2.067v4H8.669l.028-.76.486-3.24zm7.615 3.1l-.464-3.1h2.36l.806 3.345V9.5h-2.668l-.034-.9zM7.666 5.5h-2.36L4.5 8.845V9.5h2.668l.034-.9.464-3.1z",clipRule:"evenodd"})}),w=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"m3 5c0-1.10457.89543-2 2-2h13.5c1.1046 0 2 .89543 2 2v13.5c0 1.1046-.8954 2-2 2h-13.5c-1.10457 0-2-.8954-2-2zm2-.5h6v6.5h-6.5v-6c0-.27614.22386-.5.5-.5zm-.5 8v6c0 .2761.22386.5.5.5h6v-6.5zm8 0v6.5h6c.2761 0 .5-.2239.5-.5v-6zm0-8v6.5h6.5v-6c0-.27614-.2239-.5-.5-.5z",fillRule:"evenodd",clipRule:"evenodd"})}),_=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})}),g=window.wp.apiFetch;var h=o.n(g);const b=[{name:"previously-viewed",title:(0,n.__)("Previously Viewed Products","personalizewp"),icon:d,description:(0,n.__)("Display products that visitors have recently browsed on your store","personalizewp"),details:(0,n.__)('Creates a "Recently Viewed" section showing products the current visitor has looked at before. Perfect for helping customers continue their shopping journey.',"personalizewp"),keywords:["viewed","history","recent"],color:"#7c3aed",gradient:"linear-gradient(135deg, #7c3aed 0%, #a855f7 100%)"},{name:"products-for-you",title:(0,n.__)("Products For You","personalizewp"),icon:u,description:(0,n.__)("Personalized product recommendations based on visitor segments and behavior","personalizewp"),details:(0,n.__)("Shows tailored product recommendations using PersonalizeWP's visitor segments and behavioral data. Displays products from relevant categories and frequently bought together items.","personalizewp"),keywords:["recommended","personalized","segments"],color:"#059669",gradient:"linear-gradient(135deg, #059669 0%, #10b981 100%)"}];function v({collection:e,onSelect:t,isSelected:o=!1}){const a=(0,i.useCallback)(()=>{t(e.name)},[e.name,t]),n=(0,i.useMemo)(()=>({"--collection-color":e.color,"--collection-gradient":e.gradient}),[e.color,e.gradient]);return(0,l.createElement)(r.Tooltip,{text:e.details,placement:"top"},(0,l.createElement)("button",{type:"button",className:"components-button wc-blocks-product-collection__collection-button "+(o?"is-selected":""),onClick:a,style:n,"aria-pressed":o,"aria-describedby":`collection-${e.name}-description`},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collection-button-icon"},(0,l.createElement)(r.Icon,{icon:e.icon,size:24})),(0,l.createElement)("p",{className:"wc-blocks-product-collection__collection-button-title",id:`collection-${e.name}-description`},e.title)))}function y({isOpen:e,onClose:t,onSelect:o,currentCollection:a}){const[c,s]=(0,i.useState)(a),p=(0,i.useCallback)(()=>{c&&(o(c),t())},[c,o,t]),d=(0,i.useCallback)(e=>{s(e)},[]),u=Boolean(c);return(0,l.createElement)(r.Modal,{className:"wc-blocks-product-collection__modal pwp-collection-picker-modal",onRequestClose:t,size:"large",shouldCloseOnClickOutside:!1,title:(0,n.__)("What products do you want to show?","personalizewp")},(0,l.createElement)("div",{className:"wc-blocks-product-collection__content"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-grid"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-section"},b.map(e=>(0,l.createElement)(v,{key:e.name,collection:e,onSelect:d,isSelected:c===e.name})))),(0,l.createElement)(r.Flex,{className:"wc-blocks-product-collection__footer",justify:"flex-end",gap:3},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",onClick:t},(0,n.__)("Cancel","personalizewp"))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"primary",onClick:p,disabled:!u},(0,n.__)("Continue","personalizewp"))))))}function C({onOpenModal:e}){return(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder"},(0,l.createElement)(r.Card,null,(0,l.createElement)(r.CardBody,null,(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder__content"},(0,l.createElement)("h3",{className:"pwp-collection-picker-placeholder__title"},(0,n.__)("PersonalizeWP Product Collection","personalizewp")),(0,l.createElement)("p",{className:"pwp-collection-picker-placeholder__description"},(0,n.__)("Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.","personalizewp")),(0,l.createElement)(r.Button,{variant:"primary",onClick:e,className:"pwp-collection-picker-placeholder__button"},(0,n.__)("Choose Recipe","personalizewp"))))))}function E({collection:e,onChangeCollection:t}){const o=(0,i.useMemo)(()=>b.find(t=>t.name===e),[e]);return o?(0,l.createElement)(r.Card,{className:"pwp-selected-collection"},(0,l.createElement)(r.CardBody,null,(0,l.createElement)(r.Flex,{direction:"column",gap:2},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Flex,{justify:"space-between",align:"center"},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("h4",{className:"pwp-selected-collection__title"},o.title)),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",size:"small",onClick:t,className:"pwp-selected-collection__change-button"},(0,n.__)("Change","personalizewp"))))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("p",{className:"pwp-selected-collection__description"},o.description))))):null}function k({currentCollection:e,onCollectionChange:t}){const[o,a]=(0,i.useState)(!1),n=(0,i.useCallback)(()=>{a(!0)},[]),c=(0,i.useCallback)(()=>{a(!1)},[]),r=(0,i.useCallback)(e=>{t(e),c()},[t,c]);return(0,l.createElement)(l.Fragment,null,e?(0,l.createElement)(E,{collection:e,onChangeCollection:n}):(0,l.createElement)(C,{onOpenModal:n}),o&&(0,l.createElement)(y,{isOpen:o,onClose:c,onSelect:r,currentCollection:e}))}const f=[{title:(0,n.__)("Previously Viewed Products","personalizewp"),value:"previously-viewed",icon:d,info:(0,n.__)("Display products that the current visitor has recently browsed on your store.","personalizewp")},{title:(0,n.__)("Products For You","personalizewp"),value:"products-for-you",icon:u,info:(0,n.__)("Show personalized product recommendations based on visitor segments, categories, and related products.","personalizewp")}],x=[{label:(0,n.__)("Show All Products","personalizewp"),value:"show_all"},{label:(0,n.__)("Hide Block","personalizewp"),value:"hide_block"},{label:(0,n.__)("Show Custom Message","personalizewp"),value:"show_message"}],z=[{id:1,name:"Sample Product",price_html:"$19.99",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"simple",average_rating:4.5,permalink:"#"},{id:2,name:"Variable Product",price_html:"$20.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"variable",average_rating:4,permalink:"#"},{id:3,name:"External Product",price_html:"$15.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"external",button_text:"Buy on external store!",average_rating:5,external_url:"#",permalink:"#"}],P=(e,t)=>{switch(t.type){case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_PRODUCTS":return{...e,products:t.payload,isLoading:!1,error:null};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"RESET":return{products:[],isLoading:!1,error:null};default:return e}},N=({product:e,layoutType:t,index:o,totalProducts:a,onButtonClick:c})=>{const r=function(e){return(0,i.useMemo)(()=>{let t=(0,n.__)("Add to cart","personalizewp"),o="add_to_cart_button ajax_add_to_cart",l="product-type-simple",a=!1;return"external"===e.type?(t=e.button_text||(0,n.__)("Buy product","personalizewp"),o="product_type_external",l="product-type-external",a=!0):"variable"===e.type&&(t=(0,n.__)("Select options","personalizewp"),o="product_type_variable",l="product-type-variable"),{text:t,className:o,typeClass:l,isExternal:a}},[e.type,e.button_text])}(e),s=e.price_html&&e.price_html.includes("<del"),p=function(e,t,o,l,a){return(0,i.useMemo)(()=>["wc-block-product",`post-${e.id}`,"product","type-product","status-publish",e.image_url?"has-post-thumbnail":"","instock","shipping-taxable","purchasable",t.typeClass,"list"===o?"pwp-list-item":"",0===l?"first":"",l===a-1?"last":""].filter(Boolean).join(" "),[e,t.typeClass,o,l,a])}(e,r,t,o,a),d=e.image_url||"/wp-content/uploads/woocommerce-placeholder-300x300.png";return(0,l.createElement)("li",{className:p},(0,l.createElement)("div",{className:"wc-block-components-product-image wc-block-grid__product-image wp-block-woocommerce-product-image"},(0,l.createElement)("a",{href:"#",onClick:c},s&&(0,l.createElement)("div",{className:"wc-block-components-product-sale-badge wc-block-components-product-sale-badge--align-right wc-block-grid__product-onsale"},(0,l.createElement)("span",{"aria-hidden":"true"},(0,n.__)("Sale","personalizewp")),(0,l.createElement)("span",{className:"screen-reader-text"},(0,n.__)("Product on sale","personalizewp"))),(0,l.createElement)("img",{decoding:"async",width:"300",height:"300",src:d,alt:e.name,className:"attachment-woocommerce_thumbnail size-woocommerce_thumbnail",style:{maxWidth:"none",objectFit:"cover"}}))),(0,l.createElement)("h3",{style:{marginBottom:"0.75rem",marginTop:0},className:"has-text-align-center wp-block-post-title has-medium-font-size"},(0,l.createElement)("a",{href:"#",onClick:c,target:"_self"},e.name)),e.average_rating>0&&(0,l.createElement)("div",{className:"wc-block-components-product-rating"},(0,l.createElement)("div",{className:"wc-block-components-product-rating__stars","aria-label":`${e.average_rating} out of 5 stars`},"★".repeat(Math.floor(e.average_rating)),"☆".repeat(5-Math.floor(e.average_rating)))),(0,l.createElement)("div",{className:"wp-block-woocommerce-product-price"},(0,l.createElement)("div",{className:"wc-block-components-product-price wc-block-grid__product-price has-text-align-center has-font-size has-small-font-size"},(0,l.createElement)("span",{dangerouslySetInnerHTML:{__html:e.price_html}}))),(0,l.createElement)("div",{className:"wp-block-button wc-block-components-product-button align-center wp-block-woocommerce-product-button has-small-font-size"},r.isExternal?(0,l.createElement)("a",{href:"#",className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow noopener",target:"_blank"},(0,l.createElement)("span",null,r.text)):(0,l.createElement)("button",{className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow"},(0,l.createElement)("span",null,r.text))))};function T({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("div",{className:"pwp-loading-spinner",style:{display:"inline-block",width:"20px",height:"20px",border:"2px solid #ddd",borderTop:"2px solid #874FB9",borderRadius:"50%",animation:"spin 1s linear infinite",marginRight:"8px"}}),(0,n.__)("Loading personalized products...","personalizewp")))}function B({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("Unable to load products. Using fallback display.","personalizewp"))))}function S({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("No products found for this personalization recipe.","personalizewp")),(0,l.createElement)("p",null,(0,l.createElement)("small",null,(0,n.__)("Try viewing some products on your site first.","personalizewp")))))}function M({products:e,layoutType:t,gridColumns:o,onButtonClick:a}){const n="list"===t?"pwp-layout-list":"pwp-layout-grid",c="grid"===t?`columns-${o}`:"columns-1";return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${n}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("ul",{className:`${c} wc-block-product-template__responsive wc-block-product-template wp-block-woocommerce-product-template`},e.map((o,n)=>(0,l.createElement)(N,{key:o.id,product:o,layoutType:t,index:n,totalProducts:e.length,onButtonClick:a}))))}const R=JSON.parse('{"UU":"personalizewp-pro/product-collection"}'),L={src:(0,l.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)("path",{fill:"#e1236c",d:"M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z"}))};(0,a.registerBlockType)(R.UU,{icon:L,edit:function(e){const{attributes:t,setAttributes:o,clientId:a}=e,{queryId:s,query:p={},displayLayout:d={type:"flex",columns:3},layoutType:u="grid",gridColumns:g=3,pwpRecipe:b,pwpFallbackBehavior:v="show_all",pwpMaxProducts:y=8,pwpFallbackMessage:C="",pwpCollectionTitle:E=""}=t,[N,R]=(0,i.useReducer)(P,{products:[],isLoading:!1,error:null}),L=(0,i.useMemo)(()=>f.find(e=>e.value===b),[b]),O=(0,i.useCallback)(e=>{e.preventDefault()},[]),F=(0,i.useCallback)(async()=>{try{h()({path:`/wc/store/v1/products?per_page=${y||6}&orderby=date&order=desc`}).then(e=>{const t=e.map(e=>({id:e.id,name:e.name,permalink:e.permalink,excerpt:e.short_description||e.description,image_url:e.images&&e.images.length>0?e.images[0].src:null,price_html:e.price_html||`$${e.prices.price}`,average_rating:parseFloat(e.average_rating)||0,rating_count:e.rating_count||0,type:e.type||"simple",external_url:e.external_url||"",button_text:e.button_text||"",sku:e.sku||""}));R({type:"SET_PRODUCTS",payload:t})})}catch(e){R({type:"SET_PRODUCTS",payload:[]})}},[y]),V=(0,i.useCallback)(async()=>{if(b){R({type:"SET_LOADING",payload:!0});try{if(window.PersonalizeWP&&window.PersonalizeWP.getVisitorUID){const e=window.PersonalizeWP.getVisitorUID();if(e){let t=[];switch(b){case"previously-viewed":const o=await window.PersonalizeWP.fetchVisitorActivities(e,{activity_type:"post",object_type:"product"});t=window.PersonalizeWP.getPreviouslyViewedProducts(o,y);break;case"products-for-you":const l=await window.PersonalizeWP.fetchVisitorActivities(e),a=await window.PersonalizeWP.fetchVisitorSegments(e);t=window.PersonalizeWP.getRecommendedProducts(l,a,y)}if(t.length>0){const e=await window.PersonalizeWP.fetchProductDetails(t,b);R({type:"SET_PRODUCTS",payload:e})}else await F()}else await F()}else await F()}catch(e){R({type:"SET_ERROR",payload:e.message}),await F()}}},[b,y,F]),$=(0,i.useMemo)(()=>N.isLoading?[]:N.error||0===N.products.length?z.slice(0,y||6):N.products.slice(0,y||6),[N,y]),D=(0,i.useCallback)(()=>{const e="list"===u?"pwp-layout-list":"pwp-layout-grid";return N.isLoading?(0,l.createElement)(T,{layoutClass:e}):N.error&&0===$.length?(0,l.createElement)(B,{layoutClass:e}):0===$.length?(0,l.createElement)(S,{layoutClass:e}):(0,l.createElement)(M,{products:$,layoutType:u,gridColumns:g,onButtonClick:O})},[u,N,$,g,O]),j=(0,i.useCallback)(e=>{const t=f.find(t=>t.value===e);o({pwpRecipe:e,pwpCollectionTitle:t?t.title:""})},[o]);(0,i.useEffect)(()=>{if(!s){const e=`block-${Date.now()}`;o({queryId:e})}},[s,o]),(0,i.useEffect)(()=>{const e={...p,isProductCollectionBlock:!0,pwpRecipe:b||"default",pwpMaxProducts:y,pwpFallbackBehavior:v,pwpFallbackMessage:C,lastUpdated:Date.now(),perPage:y,inherit:!1,postType:"product"},t=b?`personalizewp-${b}`:"personalizewp-default";o({query:{...e,productCollectionQueryContext:{collection:t,pwpRecipe:b,pwpMaxProducts:y,pwpFallbackBehavior:v}},collection:t})},[b,y,v,C,o]),(0,i.useEffect)(()=>{b&&!E&&L&&o({pwpCollectionTitle:L.title})},[b,E,L,o]),(0,i.useEffect)(()=>{b&&V()},[b,y,V]);const I=(0,c.useBlockProps)({className:`wp-block-personalizewp-pro-product-collection pwp-layout-${u} pwp-columns-${g}`,"data-pwp-recipe":b,"data-layout-type":u,"data-grid-columns":g});return b?(0,l.createElement)("div",{...I},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:L?.icon||m,label:(0,n.__)("Choose Collection","personalizewp"),text:L?.title||(0,n.__)("Choose Collection","personalizewp"),controls:f.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:b===e.value}))})),(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarButton,{icon:w,label:(0,n.__)("Grid View","personalizewp"),onClick:()=>o({layoutType:"grid"}),isActive:"grid"===u}),(0,l.createElement)(r.ToolbarButton,{icon:_,label:(0,n.__)("List View","personalizewp"),onClick:()=>o({layoutType:"list"}),isActive:"list"===u}))),(0,l.createElement)(c.InspectorControls,null,(0,l.createElement)(r.PanelBody,{title:(0,n.__)("Settings","personalizewp"),initialOpen:!0},(0,l.createElement)(k,{currentCollection:b,onCollectionChange:j}),(0,l.createElement)(r.SelectControl,{label:(0,n.__)("Fallback Behavior","personalizewp"),value:v,options:x,onChange:e=>o({pwpFallbackBehavior:e}),help:(0,n.__)("What to show when personalization data is not available","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"show_message"===v&&(0,l.createElement)(r.TextControl,{label:(0,n.__)("Fallback Message","personalizewp"),value:C,onChange:e=>o({pwpFallbackMessage:e}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Max Products","personalizewp"),value:y,min:1,max:20,onChange:e=>o({pwpMaxProducts:e}),help:(0,n.__)("Maximum number of products to display","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)("div",{style:{marginBottom:"16px",marginTop:"24px"}},(0,l.createElement)("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500"}},(0,n.__)("Layout","personalizewp")),(0,l.createElement)(r.ButtonGroup,null,(0,l.createElement)(r.Button,{icon:w,onClick:()=>o({layoutType:"grid"}),isPressed:"grid"===u,variant:"grid"===u?"primary":"secondary"},(0,n.__)("Grid","personalizewp")),(0,l.createElement)(r.Button,{icon:_,onClick:()=>o({layoutType:"list"}),isPressed:"list"===u,variant:"list"===u?"primary":"secondary"},(0,n.__)("List","personalizewp")))),"grid"===u&&(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Columns","personalizewp"),value:g,min:1,max:6,onChange:e=>{o({gridColumns:e,displayLayout:{...d,columns:e}})},help:(0,n.__)("Number of columns in grid layout","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"list"===u&&(0,l.createElement)("div",{style:{marginTop:"16px"}},(0,l.createElement)("p",{style:{margin:0,fontSize:"13px",color:"#757575"}},(0,n.__)("Products will be displayed in a single column list format.","personalizewp"))))),L&&(0,l.createElement)("div",{className:"pwp-collection-title"},(0,l.createElement)(c.RichText,{tagName:"h2",className:"pwp-collection-title__heading",value:E,onChange:e=>o({pwpCollectionTitle:e}),placeholder:L.title,allowedFormats:["core/bold","core/italic"]})),D()):(0,l.createElement)("div",{...I},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:m,label:(0,n.__)("Choose Collection","personalizewp"),text:(0,n.__)("Choose Collection","personalizewp"),controls:f.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:!1}))}))),(0,l.createElement)(k,{currentCollection:null,onCollectionChange:j}))},save:function(e){const{attributes:t}=e,{queryId:o,pwpRecipe:a,pwpMaxProducts:r=8,pwpFallbackBehavior:i="show_all",pwpFallbackMessage:s="Discover our featured products",pwpCollectionTitle:p,layoutType:d="grid",gridColumns:u=3}=t;if(!a)return null;const m=Math.max(1,Math.min(20,parseInt(r,10)||8)),w=o,_=s||(0,n.__)("Discover our featured products","personalizewp"),g=c.useBlockProps.save({className:"pwp-product-collection-block","data-recipe":a,"data-max-products":m,"data-fallback-behavior":i,"data-fallback-message":_,"data-block-id":w});return(0,l.createElement)("div",{...g},(0,l.createElement)("pwp-product-collection",{recipe:a,"max-products":m,"fallback-behavior":i,"fallback-message":_,"layout-type":d,"grid-columns":u,"block-id":w,"collection-title":p||""},(0,l.createElement)("div",{className:"woocommerce"},(0,l.createElement)("div",{className:"woocommerce-info"},(0,l.createElement)("span",{className:"pwp-loading-spinner"}),(0,n.__)("Loading personalized products...","personalizewp")))))}})},609:e=>{e.exports=window.React},848:(e,t,o)=>{e.exports=o(20)}},o={};function l(e){var a=o[e];if(void 0!==a)return a.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,l),n.exports}l.m=t,e=[],l.O=(t,o,a,n)=>{if(!o){var c=1/0;for(p=0;p<e.length;p++){for(var[o,a,n]=e[p],r=!0,i=0;i<o.length;i++)(!1&n||c>=n)&&Object.keys(l.O).every(e=>l.O[e](o[i]))?o.splice(i--,1):(r=!1,n<c&&(c=n));if(r){e.splice(p--,1);var s=a();void 0!==s&&(t=s)}}return t}n=n||0;for(var p=e.length;p>0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[o,a,n]},l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var o in t)l.o(t,o)&&!l.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={488:0,272:0};l.O.j=t=>0===e[t];var t=(t,o)=>{var a,n,[c,r,i]=o,s=0;if(c.some(t=>0!==e[t])){for(a in r)l.o(r,a)&&(l.m[a]=r[a]);if(i)var p=i(l)}for(t&&t(o);s<c.length;s++)n=c[s],l.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return l.O(p)},o=globalThis.webpackChunkpersonalizewp=globalThis.webpackChunkpersonalizewp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var a=l.O(void 0,[272],()=>l(539));a=l.O(a)})(); -
personalizewp/tags/3.2.2/build/blocks/variation-fallback/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation-fallback", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Default Content", 7 "category": " design",7 "category": "personalizewp", 8 8 "description": "The fallback content that is displayed when no variation conditions are matched.", 9 9 "parent": [ -
personalizewp/tags/3.2.2/build/blocks/variation/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variation", 7 "category": " design",7 "category": "personalizewp", 8 8 "icon": "block-default", 9 9 "description": "A group of one or more blocks that displays different content to the fallback.", -
personalizewp/tags/3.2.2/build/blocks/variations-block/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variations-block", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variations", 7 "category": "design", 7 "category": "personalizewp", 8 "keywords": [ 9 "PersonalizeWP", 10 "pwp", 11 "personalization", 12 "variation" 13 ], 8 14 "icon": "block-default", 9 15 "description": "Show different variations of your content to specific users depending on which conditions they match, with a fallback for everyone else.", -
personalizewp/tags/3.2.2/build/blocks/variations-block/index.asset.php
r3380017 r3382403 1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => ' 0cf06715dca7eef73b4b');1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '66383005d3040fbb23a6'); -
personalizewp/tags/3.2.2/build/blocks/variations-block/index.js
r3380017 r3382403 1 (()=>{"use strict";const e=window.React,t=window.wp.blocks,n=window.wp.i18n,o=window.wp.hooks,a=["personalizewp-pro/variations-block","personalizewp-pro/variation-fallback","personalizewp-pro/variation"];(0,o.addFilter)("personalizewp.hasPersonalizeControls","personalizewp/indicate-variation-blocks",function(e,t){return"personalizewp-pro/variations-block"===t.name||e}),(0,o.addFilter)("personalizeWP.globallyRestrictedBlockTypes","personalizewp/restrict-variation-blocks",function(e){return[...e,...a]}),(0,o.addFilter)("blocks.registerBlockType","personalizewp/register-variations-context",function(e,t){return a.includes(t)||(e={...e,usesContext:[...e.usesContext,"personalizewp/isVariationContent"]}),e},100),(0,o.addFilter)("personalizeWP.preRenderControls","personalizewp/restrict-personalize-controls-showing",function(e,t){return!t.context["personalizewp/isVariationContent"]&&e});const r=window.wp.blockEditor, l=window.wp.components,i=window.wp.data,s=window.wp.element,c=[["personalizewp-pro/variation",{metadata:{name:(0,n.__)("Variation 1","personalizewp")}},[["core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")}]]],["personalizewp-pro/variation-fallback",{metadata:{name:(0,n.__)("Fallback","personalizewp")},supports:{lock:!1},lock:{move:!0,remove:!0},inserter:!1,multiple:!0,html:!1,renaming:!1},[["core/paragraph",{placeholder:(0,n.__)("Add fallback content here","personalizewp")}]]]],p=JSON.parse('{"UU":"personalizewp-pro/variations-block"}'),d={src:(0,e.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("path",{fill:"url(#paint0_linear_311_20854)",d:"M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"}),(0,e.createElement)("defs",null,(0,e.createElement)("linearGradient",{id:"paint0_linear_311_20854"},(0,e.createElement)("stop",{offset:".16",stopColor:"#C127A0"}),(0,e.createElement)("stop",{offset:".28",stopColor:"#CD20A1"}),(0,e.createElement)("stop",{offset:".59",stopColor:"#E813A4"}),(0,e.createElement)("stop",{offset:".76",stopColor:"#F20FA6"}))))};(0,t.registerBlockType)(p.UU,{icon:d,edit:function(o){const{attributes:a,setAttributes:p,clientId:d,isSelected:w}=o,{variationsBlockId:u}=a,{innerVariationBlocks:k,selectedVariationClientId:m}=(0,i.useSelect)(e=>{const{getBlocks:t,getSelectedBlockClientId:n,hasSelectedInnerBlock:o}=e(r.store),a=t(d),l=n();let i=null;for(const e of a)if(e.clientId===l||o(e.clientId,!0)){i=e.clientId;break}return{innerVariationBlocks:a,selectedVariationClientId:i}},[d]),{__unstableMarkNextChangeAsNotPersistent:f,updateBlockAttributes:v,insertBlock:b,selectBlock:h}=(0,i.useDispatch)(r.store),z=(0,s.useCallback)(e=>{k.forEach(t=>{f(),v(t.clientId,{isActive:t.clientId===e})})},[k,v,f]);(0,s.useEffect)(()=>{u&&""!==u||p({variationsBlockId:d}),k?.length&&z(k[k.length-1].clientId)},[]),(0,s.useEffect)(()=>{const e=k&&k.some(e=>e.attributes.isActive);m?z(m):!e&&k?.length&&z(k[k.length-1].clientId)},[k,m,z]),(0,s.useEffect)(()=>{null!==u&&""!==u||p({variationsBlockId:d})},[d,w]);const g=(0,r.useBlockProps)(),B=(0,r.useInnerBlocksProps)(g,{template:c,renderAppender:!1});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.BlockControls,{group:"block"},(0,e.createElement)(l.Toolbar,{label:(0,n.__)("Variations","personalizewp")},(0,e.createElement)(l.ToolbarGroup,null,k.map(({clientId:t,attributes:n})=>{const{metadata:o,isActive:a}=n;return(0,e.createElement)(l.ToolbarButton,{key:t,label:o.name,isActive:a,onClick:()=>z(t)},o.name)}),(0,e.createElement)(l.ToolbarButton,{icon:"plus",label:(0,n.__)("New Variation","personalizewp"),onClick:()=>(()=>{const e=k.length,o=(0,t.createBlock)("personalizewp-pro/variation",{metadata:{name:(0,n.sprintf)(1 (()=>{"use strict";const e=window.React,t=window.wp.blocks,n=window.wp.i18n,o=window.wp.hooks,a=["personalizewp-pro/variations-block","personalizewp-pro/variation-fallback","personalizewp-pro/variation"];(0,o.addFilter)("personalizewp.hasPersonalizeControls","personalizewp/indicate-variation-blocks",function(e,t){return"personalizewp-pro/variations-block"===t.name||e}),(0,o.addFilter)("personalizeWP.globallyRestrictedBlockTypes","personalizewp/restrict-variation-blocks",function(e){return[...e,...a]}),(0,o.addFilter)("blocks.registerBlockType","personalizewp/register-variations-context",function(e,t){return a.includes(t)||(e={...e,usesContext:[...e.usesContext,"personalizewp/isVariationContent"]}),e},100),(0,o.addFilter)("personalizeWP.preRenderControls","personalizewp/restrict-personalize-controls-showing",function(e,t){return!t.context["personalizewp/isVariationContent"]&&e});const r=window.wp.blockEditor,i=window.wp.components,l=window.wp.data,s=window.wp.element,c=[["personalizewp-pro/variation",{metadata:{name:(0,n.__)("Variation 1","personalizewp")}},[["core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")}]]],["personalizewp-pro/variation-fallback",{metadata:{name:(0,n.__)("Fallback","personalizewp")},supports:{lock:!1},lock:{move:!0,remove:!0},inserter:!1,multiple:!0,html:!1,renaming:!1},[["core/paragraph",{placeholder:(0,n.__)("Add fallback content here","personalizewp")}]]]],p=JSON.parse('{"UU":"personalizewp-pro/variations-block"}'),d={src:(0,e.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("path",{fill:"#e1236c",d:"M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z"}))};(0,t.registerBlockType)(p.UU,{icon:d,edit:function(o){const{attributes:a,setAttributes:p,clientId:d,isSelected:w}=o,{variationsBlockId:u}=a,{innerVariationBlocks:k,selectedVariationClientId:m}=(0,l.useSelect)(e=>{const{getBlocks:t,getSelectedBlockClientId:n,hasSelectedInnerBlock:o}=e(r.store),a=t(d),i=n();let l=null;for(const e of a)if(e.clientId===i||o(e.clientId,!0)){l=e.clientId;break}return{innerVariationBlocks:a,selectedVariationClientId:l}},[d]),{__unstableMarkNextChangeAsNotPersistent:v,updateBlockAttributes:b,insertBlock:h,selectBlock:z}=(0,l.useDispatch)(r.store),g=(0,s.useCallback)(e=>{k.forEach(t=>{v(),b(t.clientId,{isActive:t.clientId===e})})},[k,b,v]);(0,s.useEffect)(()=>{u&&""!==u||p({variationsBlockId:d}),k?.length&&g(k[k.length-1].clientId)},[]),(0,s.useEffect)(()=>{const e=k&&k.some(e=>e.attributes.isActive);m?g(m):!e&&k?.length&&g(k[k.length-1].clientId)},[k,m,g]),(0,s.useEffect)(()=>{null!==u&&""!==u||p({variationsBlockId:d})},[d,w]);const B=(0,r.useBlockProps)(),f=(0,r.useInnerBlocksProps)(B,{template:c,renderAppender:!1});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.BlockControls,{group:"block"},(0,e.createElement)(i.Toolbar,{label:(0,n.__)("Variations","personalizewp")},(0,e.createElement)(i.ToolbarGroup,null,k.map(({clientId:t,attributes:n})=>{const{metadata:o,isActive:a}=n;return(0,e.createElement)(i.ToolbarButton,{key:t,label:o.name,isActive:a,onClick:()=>g(t)},o.name)}),(0,e.createElement)(i.ToolbarButton,{icon:"plus",label:(0,n.__)("New Variation","personalizewp"),onClick:()=>(()=>{const e=k.length,o=(0,t.createBlock)("personalizewp-pro/variation",{metadata:{name:(0,n.sprintf)( 2 2 // Translators: %d: Variation number being added. 3 3 // Translators: %d: Variation number being added. 4 (0,n.__)("Variation %d","personalizewp"),e)}},[(0,t.createBlock)("core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")})]); b(o,k.length-1,d),h(o.clientId)})()})))),(0,e.createElement)("div",{...B}))},save:function(t){const n=r.useBlockProps.save(),{className:o,...a}=r.useInnerBlocksProps.save(n);return(0,e.createElement)("pwp-content-variations",{...a})}})})();4 (0,n.__)("Variation %d","personalizewp"),e)}},[(0,t.createBlock)("core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")})]);h(o,k.length-1,d),z(o.clientId)})()})))),(0,e.createElement)("div",{...f}))},save:function(t){const n=r.useBlockProps.save(),{className:o,...a}=r.useInnerBlocksProps.save(n);return(0,e.createElement)("pwp-content-variations",{...a})}})})(); -
personalizewp/tags/3.2.2/includes/class-api.php
r3380017 r3382403 122 122 // Requests from file:// and data: URLs send "Origin: null". 123 123 if ( 'null' !== $origin ) { 124 $origin = sanitize_url( $origin );124 $origin = $this->sanitize_origin_url( $origin ); 125 125 } 126 126 … … 212 212 protected function is_allowed_origin( $origin ): bool { 213 213 214 $home_url = set_url_scheme( home_url(), 'https' ); // Always assume https215 $allowed_origins = [ $home_url ]; 214 $home_url = set_url_scheme( $this->sanitize_origin_url( home_url() ), 'https' ); // Always assume https 215 $allowed_origins = [ $home_url ]; // Ensures ssl is there, in case the default is non-ssl. 216 216 217 217 // Automatically filter the origins to add any URLs from auth tokens UI. 218 $url_tokens = get_option( $this->auth_tokens, []);218 $url_tokens = $this->get_all_api_auth_tokens(); 219 219 if ( ! empty( $url_tokens ) ) { 220 220 $allowed_origins = array_merge( array_keys( $url_tokens ) ); … … 296 296 */ 297 297 public function populate_default_auth_token(): void { 298 $all_tokens = get_option( $this->auth_tokens, [] ); 299 300 if ( empty( $all_tokens ) ) { 298 $all_tokens = $this->get_all_api_auth_tokens(); 299 300 $force_gen = false; 301 $home_url = untrailingslashit( home_url() ); 302 $root_url = $this->sanitize_origin_url( $home_url ); 303 304 // Check for sub-directory created URL token that won't match an origin. 305 if ( $home_url !== $root_url && isset( $all_tokens[ $home_url ] ) ) { 306 // Migrate default root URL by clearing the existing token. 307 $this->delete_api_auth_token( $home_url ); 308 // Force a regen of the home url. 309 $force_gen = true; 310 } 311 312 if ( empty( $all_tokens ) || $force_gen ) { 301 313 // Use home URL, but upgrade to https to ensure single entry to check 302 314 $root_url = set_url_scheme( home_url(), 'https' ); … … 340 352 public function generate_api_auth_token( $url, $store = false ): string { 341 353 342 // Remove any potential trailing slash to match incoming browser origin. 343 $url = untrailingslashit( $url ); 344 354 $url = $this->sanitize_origin_url( $url ); 345 355 $token = base64_encode( hash_hmac( 'sha384', $url, $this->get_auth_secret(), true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- Token creation 346 356 347 357 if ( $store ) { 348 $all_tokens = get_option( $this->auth_tokens, [] ); 349 358 $all_tokens = $this->get_all_api_auth_tokens(); 350 359 // Only set if it doesn't already exist. 351 360 if ( ! isset( $all_tokens[ $url ] ) ) { … … 387 396 public function get_api_auth_token( $url ): string { 388 397 389 // Remove any potential trailing slash to match incoming browser origin. 390 $url = untrailingslashit( $url ); 391 392 $all_tokens = get_option( $this->auth_tokens, [] ); 393 398 // Strip URL back to simple URL scheme and host matching browser origin format. 399 $url = $this->sanitize_origin_url( $url ); 400 401 $all_tokens = $this->get_all_api_auth_tokens(); 394 402 if ( isset( $all_tokens[ $url ] ) && ! empty( $all_tokens[ $url ] ) ) { 395 403 return $all_tokens[ $url ]; … … 411 419 public function delete_api_auth_token( $url ): bool { 412 420 413 // Remove any potential trailing slash to match incoming browser origin. 421 // Lightly sanitise by just removing any potential trailing slash. 422 // Don't fully sanitise as then would not be possible to remove incorrect URLs. 414 423 $url = untrailingslashit( $url ); 415 424 416 $all_tokens = get_option( $this->auth_tokens, [] ); 417 425 $all_tokens = $this->get_all_api_auth_tokens(); 418 426 if ( isset( $all_tokens[ $url ] ) ) { 419 427 unset( $all_tokens[ $url ] ); … … 535 543 return true; 536 544 } 545 546 /** 547 * Sanitise a URL to match the format that browsers send within their `origin` header 548 * 549 * Ensures that sub-directories, trailing slashes etc are removed. 550 * 551 * @since 3.2.2 552 * 553 * @param string $url URL to sanitise to match browser origin format 554 * 555 * @return string Sanitised URL 556 */ 557 public function sanitize_origin_url( $url ) { 558 559 $_parts = wp_parse_url( $url ); 560 $url = untrailingslashit( sprintf( '%s://%s', $_parts['scheme'], $_parts['host'] ) ); 561 562 return $url; 563 } 537 564 } -
personalizewp/tags/3.2.2/includes/class-personalizewp.php
r3380017 r3382403 423 423 424 424 /** 425 * Add block category for PersonalizeWP Blocks. 426 * 427 * @since 3.2.2 428 * 429 * @param array[] $categories All categories 430 * 431 * @return array[] Returns an array containing array of categories for block types including our custom ones. 432 */ 433 function register_block_category( $categories ) { 434 return array_merge( 435 $categories, 436 array( 437 array( 438 'slug' => 'personalizewp', 439 'title' => esc_html__( 'PersonalizeWP', 'personalizewp' ), 440 ), 441 ) 442 ); 443 } 444 445 /** 425 446 * Register custom block types. 426 447 * … … 428 449 */ 429 450 public function register_blocks() { 451 452 add_filter( 'block_categories_all', [ $this, 'register_block_category' ], 10 ); 430 453 431 454 $custom_blocks = array( -
personalizewp/tags/3.2.2/includes/rule-conditions/woocommerce/class-category-quantity-in-cart.php
r3380017 r3382403 21 21 * Checks if the total quantity of products from a specific category in the cart meets the specified condition 22 22 */ 23 class WooCommerce_Category_Quantity_In_Cart extends RuleCondition {23 class Category_Quantity_In_Cart extends RuleCondition { 24 24 25 25 /** -
personalizewp/tags/3.2.2/package.json
r3380017 r3382403 24 24 "repository": { 25 25 "type": "git", 26 "url": "https:// bitbucket.org/filter-digital/personalizewp.git"26 "url": "https://github.com/filter-agency/personalizewp.git" 27 27 }, 28 28 "files": [ -
personalizewp/tags/3.2.2/personalizewp.php
r3381432 r3382403 11 11 * Plugin URI: https://personalizewp.com/ 12 12 * Description: Add powerful personalization features to your WordPress site. Show different content to different visitors based on their behavior, profile, location, and more. 13 * Version: 3.2. 113 * Version: 3.2.2 14 14 * Author: Filter 15 15 * Author URI: https://filter.agency/ … … 40 40 * Current plugin version. 41 41 */ 42 define( 'PERSONALIZEWP_VERSION', '3.2. 1' );42 define( 'PERSONALIZEWP_VERSION', '3.2.2' ); 43 43 44 44 // Load autoloader. -
personalizewp/tags/3.2.2/src/admin/js/components/auto-complete.js
r3380017 r3382403 16 16 17 17 /** 18 * Run when the element is added to the DOM 19 * Often run after each of the observedAttributes. 18 * Runs only once the complete element has been parsed and added to the DOM. 20 19 */ 21 20 connectedCallback() { … … 29 28 if (this.hasAttribute('is-ready')) return; 30 29 31 // Internal data 32 this.isDomSetup = false; 33 this.searchQueries = {}; 34 this.contentTypes = []; 35 this.taxonomy = null; 36 this.restBase = null; 37 this.selectedItems = []; 30 // Get the required template for working. Used to format searched items. 31 this.itemTemplate = this.querySelector('template')?.content; 32 if ( ! this.itemTemplate ) return; 33 34 // Internal variables, not configured via attributes 38 35 this.currentSearch = ''; 39 36 this.currentPage = 1; … … 41 38 this.perPage = 10; 42 39 this.minChars = 2; 43 44 // Dom references 45 this.itemTemplate = null;40 this.initialiseMode(); 41 42 // DOM references 46 43 this.searchInput = null; 47 44 this.clearSearch = null; 48 45 this.searchResults = null; 49 46 this.displaySelected = null; 50 51 // Can start disabled.52 this.disabled = this.getAttribute('disabled') || false;53 54 // Get the elements55 this.itemTemplate = this.querySelector('template')?.content;56 if ( ! this.itemTemplate ) return;57 58 // Initialise mode is automatic due to observedAttributes.59 60 47 // Setup default UI 61 if ( ! this.isDomSetup )this.setupDOM();48 this.setupDOM(); 62 49 63 50 // Populate initial list based on already set items … … 69 56 this.searchResults.addEventListener('click', this); // On the search results 70 57 this.displaySelected.addEventListener('click', this); // On the buttons to remove items 71 72 this.isDomSetup = true;73 58 74 59 // Emit ready event. … … 126 111 127 112 /** 128 * Initialise/update mode. Some modes have additional setup. 113 * Initialise/update mode, and base required properties via attributes. 114 * Some modes have additional setup, such as terms to confirm valid taxonomy. 129 115 */ 130 116 initialiseMode() { 131 // Define properties 117 118 // Define base dynamic properties 132 119 this.mode = this.getAttribute('mode') || 'post'; 133 120 this.disabled = this.getAttribute('disabled') || false; // Field can start disabled 121 this.taxonomy = this.getAttribute('taxonomy') || null; 122 this.contentTypes = this.getAttribute('content-types') || []; 123 if ( 0 !== this.contentTypes.length ) { 124 // Convert string to sanitised array 125 this.contentTypes = this.contentTypes.split(',').map( (v) => v.replace( /[^a-z0-9_\-]/, '' ) ); 126 } 127 // Keep a list of internal chosen IDs/titles 128 this.selectedItems = this.getAttribute('content') || []; 129 if ( 0 !== this.selectedItems.length ) { 130 this.selectedItems = JSON.parse(this.selectedItems); 131 } 132 133 this.restBase = null; 134 134 // Additional defaults depend on specific mode 135 135 switch( this.mode ) { 136 136 case 'term': 137 this.restBase = null;138 this.taxonomy = this.getAttribute('taxonomy');139 137 if ( window.PWPTaxonomyRestBases ) { 140 138 this.restBase = window.PWPTaxonomyRestBases?.[`${this.taxonomy}`] || null; … … 173 171 } 174 172 175 // Keep a list of internal chosen IDs/titles176 const _selectedItems = this.getAttribute('content') || [];177 if ( 0 !== _selectedItems.length ) {178 this.selectedItems = JSON.parse(_selectedItems);179 }180 173 } 181 174 … … 186 179 handleEvent(event) { 187 180 this[`handle${event.type}`](event); 188 }189 190 /**191 * Runs when the value of an attribute is changed on the component.192 * Also runs when the component is first seen, before connectedCallback() is run.193 * @param {String} name The attribute name194 * @param {String} oldValue The old attribute value195 * @param {String} newValue The new attribute value196 */197 attributeChangedCallback(name, oldValue, newValue) {198 // Rationalise the attribute name for function name support199 name = name.replace( /[^a-zA-Z0-9]/i, '' );200 this[`handleChange${name}`](oldValue, newValue);201 }202 203 /**204 * Updating placeholder on search input205 * @param {Event} event206 */207 handleChangeplaceholder(event) {208 if ( this.searchInput ) {209 this.searchInput.setAttribute('placeholder', this.getAttribute('placeholder') || `${ __('Search', 'personalizewp') }`);210 }211 181 } 212 182 … … 272 242 273 243 /** 244 * Runs when the value of an attribute is changed on the component. 245 * Also runs when a components' attribute is first seen, before connectedCallback() is run. 246 * @param {String} name The attribute name 247 * @param {String} oldValue The old attribute value 248 * @param {String} newValue The new attribute value 249 */ 250 attributeChangedCallback(name, oldValue, newValue) { 251 // Don't run if not initialized, ensures data integrity. 252 if (! this.hasAttribute('is-ready')) return; 253 254 // Rationalise the attribute name for function name support 255 name = name.replace( /[^a-zA-Z0-9]/i, '' ); 256 this[`handleChange${name}`](oldValue, newValue); 257 } 258 259 /** 260 * Updating placeholder on search input 261 * @param {Event} event 262 */ 263 handleChangeplaceholder(event) { 264 if ( this.searchInput ) { 265 this.searchInput.setAttribute('placeholder', this.getAttribute('placeholder') || `${ __('Search', 'personalizewp') }`); 266 } 267 } 268 269 /** 274 270 * Handle [mode] attribute changes 275 271 * @param {String} oldValue The old attribute value … … 310 306 // Has a category, so (re)initialise. 311 307 this.initialiseMode(); 312 313 // Only update template inputs if the component is fully initialized314 if ( ! this.itemTemplate ) {315 return;316 }317 308 318 309 // Use placeholder value for initial search/replace. … … 496 487 emit( this, 'auto-complete', 'reset-all' ); 497 488 } 498 499 // /**500 // * Emit a custom event501 // * @param {String} type The event type502 // * @param {Object} detail Any details to pass along with the event503 // */504 // emit(type, detail = {}) {505 506 // // Create a new event507 // let event = new CustomEvent(`auto-complete:${type}`, {508 // bubbles: true,509 // cancelable: true,510 // detail: detail511 // });512 513 // // Dispatch the event514 // return this.dispatchEvent(event);515 // }516 489 517 490 /** … … 657 630 }; 658 631 // Use content-types attribute and pass as subtype (consistent with post case) 659 if ( 0 !== this.contentTypes.length ) {632 if ( this.contentTypes && 0 !== this.contentTypes.length ) { 660 633 _searchArgs.subtype = this.contentTypes.join(','); 661 634 } -
personalizewp/tags/3.2.2/src/blocks/product-collection/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/product-collection", 5 "version": "1.0. 0",6 "title": "P ersonalizeWP Product Collection",5 "version": "1.0.1", 6 "title": "Product Collection", 7 7 "description": "Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.", 8 "category": " woocommerce",8 "category": "personalizewp", 9 9 "keywords": [ 10 10 "PersonalizeWP", 11 "pwp", 11 12 "WooCommerce", 12 13 "personalization", -
personalizewp/tags/3.2.2/src/blocks/product-collection/index.js
r3380017 r3382403 33 33 > 34 34 <path 35 fill=" url(#paint0_linear_311_20854)"36 d="M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"35 fill="#e1236c" 36 d="M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z" 37 37 /> 38 <defs>39 <linearGradient id="paint0_linear_311_20854">40 <stop offset=".16" stopColor="#C127A0"/>41 <stop offset=".28" stopColor="#CD20A1"/>42 <stop offset=".59" stopColor="#E813A4"/>43 <stop offset=".76" stopColor="#F20FA6"/>44 </linearGradient>45 </defs>46 38 </svg> 47 39 }; -
personalizewp/tags/3.2.2/src/blocks/variation-fallback/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation-fallback", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Default Content", 7 "category": " design",7 "category": "personalizewp", 8 8 "description": "The fallback content that is displayed when no variation conditions are matched.", 9 9 "parent": [ "personalizewp-pro/variations-block" ], -
personalizewp/tags/3.2.2/src/blocks/variation/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variation", 7 "category": " design",7 "category": "personalizewp", 8 8 "icon": "block-default", 9 9 "description": "A group of one or more blocks that displays different content to the fallback.", -
personalizewp/tags/3.2.2/src/blocks/variations-block/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variations-block", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variations", 7 "category": "design", 7 "category": "personalizewp", 8 "keywords": [ 9 "PersonalizeWP", 10 "pwp", 11 "personalization", 12 "variation" 13 ], 8 14 "icon": "block-default", 9 15 "description": "Show different variations of your content to specific users depending on which conditions they match, with a fallback for everyone else.", -
personalizewp/tags/3.2.2/src/blocks/variations-block/index.js
r3380017 r3382403 22 22 > 23 23 <path 24 fill=" url(#paint0_linear_311_20854)"25 d="M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"24 fill="#e1236c" 25 d="M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z" 26 26 /> 27 <defs>28 <linearGradient id="paint0_linear_311_20854">29 <stop offset=".16" stopColor="#C127A0"/>30 <stop offset=".28" stopColor="#CD20A1"/>31 <stop offset=".59" stopColor="#E813A4"/>32 <stop offset=".76" stopColor="#F20FA6"/>33 </linearGradient>34 </defs>35 27 </svg> 36 28 }; -
personalizewp/tags/3.2.2/uninstall.php
r3380017 r3382403 14 14 defined( 'WP_UNINSTALL_PLUGIN' ) || exit; 15 15 16 // To ensure that all variables and constants are available. 17 require __DIR__ . '/includes/personalizewp-constants.php'; 16 // Skip the autoloader, manually include what is needed for the DB Manager 18 17 require __DIR__ . '/includes/traits/class-singletontrait.php'; 19 18 require __DIR__ . '/includes/class-db-manager.php'; -
personalizewp/trunk/README.txt
r3381436 r3382403 4 4 Requires at least: 6.2.0 5 5 Tested up to: 6.8 6 Stable tag: 3.2. 16 Stable tag: 3.2.2 7 7 Requires PHP: 7.4 8 8 License: GPL v3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html 10 10 11 Add powerful personalization features to your WordPress site. Show different content to differentvisitors based on their behavior, profile, location, and more.11 Add powerful personalization features to your WordPress site. Show different content to visitors based on their behavior, profile, location, and more. 12 12 13 13 == Description == … … 178 178 == Changelog == 179 179 180 = 3.2.2 = 181 182 * Enhancement: Group our custom blocks within a PersonalizeWP block category. 183 * Tweak: Update the logo on our custom blocks to match the new branding. 184 * Enhancement: Add better sanitizing of URLs when using them for API authentication tokens. 185 * Bug fix: Fix JS error that occurred on some of our forms that used auto complete fields, causing those fields to be incorrectly disabled. 186 * Bug fix: Fix loading error that occurred with the WooCommerce Category Quantity in Cart condition, causing it to not appear. 187 * Bug fix: Fix fatal error that occurred when attempting to uninstall/delete PersonalizeWP. 188 180 189 = 3.2.1 = 181 190 182 * Bug Fix: Fix database migration of Pro addon which wouldn't automatically run if you didn't visit your admin.191 * Bug fix: Fix database migration of Pro addon which wouldn't automatically run if you didn't visit your admin. 183 192 184 193 = 3.2.0 = … … 389 398 390 399 == Upgrade Notice == 400 401 = 3.2.1 = 391 402 IMPORTANT: Users of PersonalizeWP 3.1 or earlier should immediately upgrade to 3.2.1 or later. 3.2.0+ merges all the features of PersonalizeWP Pro, giving you much more powerful personalization features. -
personalizewp/trunk/admin/js/admin.asset.php
r3380017 r3382403 1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-dom-ready', 'wp-html-entities', 'wp-i18n', 'wp-url'), 'version' => ' 8292ed898169b6442251');1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-dom-ready', 'wp-html-entities', 'wp-i18n', 'wp-url'), 'version' => '525ecc764eae56bb5e3c'); -
personalizewp/trunk/admin/js/admin.js
r3380017 r3382403 1 (()=>{var e={51:function(e,t,r){var s,i;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),i=void 0!==r.g?r.g:"undefined"!=typeof window?window:this,s=function(){return function(e){"use strict";var t={idPrefix:"tabby-toggle_",default:"[data-tabby-default]"},r=function(t){if(t&&"true"!=t.getAttribute("aria-selected")){var r=document.querySelector(t.hash);if(r){var s=function(e){var t=e.closest('[role="tablist"]');if(!t)return{};var r=t.querySelector('[role="tab"][aria-selected="true"]');if(!r)return{};var s=document.querySelector(r.hash);return r.setAttribute("aria-selected","false"),r.setAttribute("tabindex","-1"),s?(s.setAttribute("hidden","hidden"),{previousTab:r,previousContent:s}):{previousTab:r}}(t);!function(e,t){e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0"),t.removeAttribute("hidden"),e.focus()}(t,r),s.tab=t,s.content=r,function(t,r){var s;"function"==typeof e.CustomEvent?s=new CustomEvent("tabby",{bubbles:!0,cancelable:!0,detail:r}):(s=document.createEvent("CustomEvent")).initCustomEvent("tabby",!0,!0,r),t.dispatchEvent(s)}(t,s)}}};return function(s,i){var a,o,n={destroy:function(){var e=o.querySelectorAll("a");Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id.slice(0,r.idPrefix.length)===r.idPrefix&&(e.id=""),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex"),e.closest("li").removeAttribute("role"),t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("hidden")}(e,t,a)}),o.removeAttribute("role"),document.documentElement.removeEventListener("click",l,!0),o.removeEventListener("keydown",c,!0),a=null,o=null},setup:function(){if(o=document.querySelector(s)){var e=o.querySelectorAll("a");o.setAttribute("role","tablist"),Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id||(e.id=r.idPrefix+t.id),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.id),e.closest("li").setAttribute("role","presentation"),t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),e.matches(r.default)?e.setAttribute("aria-selected","true"):(e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),t.setAttribute("hidden","hidden"))}(e,t,a)})}},toggle:function(e){var t=e;"string"==typeof e&&(t=document.querySelector(s+' [role="tab"][href*="'+e+'"]')),r(t)}},l=function(e){var t=e.target.closest(s+' [role="tab"]');t&&(e.preventDefault(),r(t))},c=function(e){var t=document.activeElement;t.matches(s+' [role="tab"]')&&(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Up","Down","Left","Right","Home","End"].indexOf(e.key)<0||function(e,t){var s=function(e){var t=e.closest('[role="tablist"]'),r=t?t.querySelectorAll('[role="tab"]'):null;if(r)return{tabs:r,index:Array.prototype.indexOf.call(r,e)}}(e);if(s){var i,a=s.tabs.length-1;["ArrowUp","ArrowLeft","Up","Left"].indexOf(t)>-1?i=s.index<1?a:s.index-1:["ArrowDown","ArrowRight","Down","Right"].indexOf(t)>-1?i=s.index===a?0:s.index+1:"Home"===t?i=0:"End"===t&&(i=a),r(s.tabs[i])}}(t,e.key))};return a=function(){var e={};return Array.prototype.forEach.call(arguments,function(t){for(var r in t){if(!t.hasOwnProperty(r))return;e[r]=t[r]}}),e}(t,i||{}),n.setup(),function(t){if(!(e.location.hash.length<1)){var s=document.querySelector(t+' [role="tab"][href*="'+e.location.hash+'"]');r(s)}}(s),document.documentElement.addEventListener("click",l,!0),o.addEventListener("keydown",c,!0),n}}(i)}.apply(t,[]),void 0===s||(e.exports=s)}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.i18n,t=window.wp.domReady;var s=r.n(t),i=r(51),a=r.n(i);function o(e,t,r,s=null,i=!1){const a=new CustomEvent(`pwp-${t}:${r}`,{bubbles:!0,cancelable:i,detail:s});return e.dispatchEvent(a)}function n(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{e.readyInit()},{once:!0}):e.readyInit()}customElements.define("ajax-form",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){var e;this.hasAttribute("is-ready")||(this.announce=this.querySelector('[role="status"]')||document.createElement("div"),this.announce.setAttribute("role","status"),this.form=this.querySelector("form"),this.form&&(this.form.append(this.announce),this.msgSubmitting=null!==(e=this.getAttribute("msg-submitting"))&&void 0!==e?e:"Submitting...",this.msgDisappear=this.hasAttribute("msg-disappear"),this.keepFields=this.hasAttribute("keep-fields"),this.updateURL=this.getAttribute("update-url"),this.removeElem=this.getAttribute("remove"),this.closeDialog=this.hasAttribute("close-dialog"),this.delay=this.hasAttribute("delay")?6e3:0,this.form.addEventListener("submit",this),o(this,"ajax-form","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`on${e.type}`](e)}async onsubmit(e){if(e.preventDefault(),!this.isDisabled()){this.disable(),this.showStatus(this.msgSubmitting,!0);try{const e=this.serialize(),t=this.form.getAttribute("action"),r=this.form.getAttribute("method");if(!o(this,"ajax-form","submit-before",{action:t,formData:e},!0))return;const s=await fetch(t,{method:r,body:this.serialize(),headers:{Accept:"application/json, */*;q=0.1","Content-type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"}});let i=await s.json();if(!s.ok)throw i;if(Object.hasOwn(i,"success")&&!i.success)throw Object.hasOwn(i,"data")&&(i=i.data),o(this,"ajax-form","error",i),i;Object.hasOwn(i,"data")&&(i=i.data),i.message&&this.showStatus(i.message,!0,!0),this.updateURL&&history.replaceState(history.state,null,this.updateURL),i.url&&(window.location.href=i.url),this.keepFields||this.reset(),o(this,"ajax-form","success",i),this.removeElem&&(this.closest(this.removeElem)||this).remove()}catch(e){console.warn(e),this.showStatus(e.message)}finally{setTimeout(()=>{this.enable()},this.delay)}}}disable(){this.setAttribute("form-submitting","")}enable(){this.removeAttribute("form-submitting")}isDisabled(){return this.hasAttribute("form-submitting")}showStatus(e,t,r){this.announce.hidden=!1,this.announce.innerHTML=e,this.announce.className=t?"notice-message success-message":"notice-message error-message",t&&r&&this.removeElem&&this.toast(),t&&this.msgDisappear&&setTimeout(()=>{this.announce.hidden=!0,this.announce.innerHTML="",this.announce.className=""},6e3),t&&r&&this.closeDialog&&setTimeout(()=>{const e=this.closest("dialog");e&&e.close("close")},6e3)}toast(){const e=document.querySelector(".toast-wrapper");e||(e=document.createElement("div"),e.className="toast-wrapper",document.body.append(e)),this.announce.className="toast",e.prepend(this.announce),setTimeout(()=>{this.announce.remove()},6e3)}serialize(){const e=new FormData(this.form),t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);return t.toString()}reset(){this.form.reset()}}),customElements.define("ajax-html",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("event-name")?.split(",")||[];if(this.eventUID=this.getAttribute("event-uid")?.split(",")||[],e.length&&this.id){for(let t of e)document.addEventListener(t,e=>{this.updateHTML(e,this)});o(this,"ajax-html","ready"),this.setAttribute("is-ready","")}}async updateHTML(e,t){if(!this.eventUID.length||this.eventUID.includes(e.detail?.uid))try{let e=await fetch(location.href);if(!e.ok)throw e;let r=await e.text(),s=(new DOMParser).parseFromString(r,"text/html").querySelector(`#${t.id}`);if(!s)return;t.replaceWith(s)}catch(e){console.warn("Unable to update HTML")}}});const l=window.wp.apiFetch;var c=r.n(l);const u=window.wp.url,d=window.wp.htmlEntities;customElements.define("auto-complete",class extends HTMLElement{static observedAttributes=["mode","content-types","taxonomy","disabled","placeholder"];connectedCallback(){n(this)}readyInit(){this.hasAttribute("is-ready")||(this.isDomSetup=!1,this.searchQueries={},this.contentTypes=[],this.taxonomy=null,this.restBase=null,this.selectedItems=[],this.currentSearch="",this.currentPage=1,this.totalPages=1,this.perPage=10,this.minChars=2,this.itemTemplate=null,this.searchInput=null,this.clearSearch=null,this.searchResults=null,this.displaySelected=null,this.disabled=this.getAttribute("disabled")||!1,this.itemTemplate=this.querySelector("template")?.content,this.itemTemplate&&(this.isDomSetup||this.setupDOM(),this.renderSelection(),this.searchInput.addEventListener("keyup",this),this.clearSearch.addEventListener("click",this),this.searchResults.addEventListener("click",this),this.displaySelected.addEventListener("click",this),this.isDomSetup=!0,o(this,"auto-complete","ready",{items:this.selectedItems}),this.setAttribute("is-ready","")))}setupDOM(){if(!this.searchInput&&!this.clearSearch){let t=document.createElement("div");t.classList.add("search"),this.searchInput=document.createElement("input"),this.searchInput.setAttribute("type","text"),this.searchInput.setAttribute("autocomplete","off"),this.disabled&&this.searchInput.setAttribute("disabled",""),this.searchInput.classList.add("auto-complete","search-icon"),this.searchInput.id=this.getAttribute("label-id")||"auto-complete-"+Math.floor(100*Math.random()),this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`),t.append(this.searchInput),this.clearSearch=document.createElement("button"),this.clearSearch.setAttribute("type","button"),this.clearSearch.setAttribute("data-type","reset"),this.clearSearch.setAttribute("aria-label",`${(0,e.__)("Reset search","personalizewp")}`),this.clearSearch.innerHTML='<svg width="24" height="24"><use xlink:href="#pwp-icon-cross"></use></svg>',this.hideClearSearch(),t.append(this.clearSearch),this.append(t)}this.searchResults||(this.searchResults=document.createElement("ul"),this.searchResults.classList.add("search-results"),this.append(this.searchResults)),this.displaySelected||(this.displaySelected=document.createElement("ul"),this.displaySelected.classList.add("tag-list","cluster"),this.append(this.displaySelected))}initialiseMode(){this.mode=this.getAttribute("mode")||"post","term"===this.mode&&(this.restBase=null,this.taxonomy=this.getAttribute("taxonomy"),window.PWPTaxonomyRestBases&&(this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null),this.restBase||c()({path:"wp/v2/taxonomies"}).then(e=>{const t={};for(const r in e)t[`${r}`]=e[`${r}`].rest_base;window.PWPTaxonomyRestBases=t,this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null,this.restBase||this.setAttribute("disabled","")}).catch(e=>{console.log("catching error...",e),this.setAttribute("disabled","")}));const e=this.getAttribute("content")||[];0!==e.length&&(this.selectedItems=JSON.parse(e))}handleEvent(e){this[`handle${e.type}`](e)}attributeChangedCallback(e,t,r){this[`handleChange${e=e.replace(/[^a-zA-Z0-9]/i,"")}`](t,r)}handleChangeplaceholder(t){this.searchInput&&this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`)}handlekeyup(e){clearTimeout(this.debouce),""===this.searchInput.value?this.hideClearSearch():this.showClearSearch(),this.debouce=setTimeout(()=>{this.handleSearchStringChange(this.searchInput.value,this.currentPage)},250)}handleclick(e){e.preventDefault();let t=e.target.closest("button");if(!t)return;let r=t.getAttribute("data-type");if(r)switch(r){case"reset":this.currentPage=1,this.currentSearch="",this.searchInput.value="",this.resetSearchResults(),this.searchInput.focus(),this.hideClearSearch();break;case"load-more":this.currentPage++,this.handleSearchStringChange(this.searchInput.value,this.currentPage),t.closest("li").remove();break;case"selected":t.closest("li").remove(),this.removeSelectedItem(t.value);break;case"search":this.addSelectedItem(t.value,t.querySelector(".header").textContent)}}handleChangemode(e,t){this.initialiseMode()}handleChangecontenttypes(e,t){t&&0!==t.length?this.contentTypes=t.split(",").map(e=>e.replace(/[^a-z0-9_\-]/,"")):this.contentTypes=[]}handleChangetaxonomy(e,t){if(null===t||""===t)return this.taxonomy=null,void this.setAttribute("disabled","");if(this.taxonomy=t,this.resetSearchResults(),this.initialiseMode(),!this.itemTemplate)return;null!==e&&""!==e||(e="%TAXONOMY%");const r=this.itemTemplate.querySelector('input[type="hidden"][name^="pwp_form"]');r&&r.setAttribute("name",r.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`)),this.displaySelected.querySelectorAll('input[type="hidden"][name^="pwp_form"]').forEach(t=>{t.setAttribute("name",t.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`))}),this.removeAttribute("disabled")}handleChangedisabled(e,t){null!==t?(this.disabled=!0,this.searchInput&&this.searchInput.setAttribute("disabled",""),this.resetSearchResults()):(this.disabled=!1,this.searchInput&&this.searchInput.removeAttribute("disabled"))}removeSelectedItem(e){let t=this.selectedItems.findIndex(t=>t.value===e);-1!==t&&(this.selectedItems.splice(t,1),this.renderSelection(),o(this,"auto-complete","remove-item",{item:e,items:this.selectedItems}))}addSelectedItem(e,t){-1===this.selectedItems.findIndex(t=>t.value===e)&&(this.selectedItems.unshift({value:e,text:t}),this.renderSelection(),o(this,"auto-complete","add-item",{newItem:e,items:this.selectedItems}))}renderSelection(){this.displaySelected&&this.displaySelected.replaceChildren(...Array.from(this.selectedItems).map(e=>{let t=document.createElement("li");return t.append(this.itemTemplate.cloneNode(!0)),t.querySelector("span").textContent=e.text,t.querySelector("input").value=e.value,t.querySelector("button").value=e.value,t.querySelector("button").setAttribute("data-type","selected"),t}))}showLoading(){if(this.searchResults.querySelector(".loading"))return;let e=document.createElement("li");e.classList.add("loading"),e.innerHTML='<svg class="components-spinner" viewBox="0 0 100 100" width="20" height="20" xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false"><circle cx="50" cy="50" r="50" vector-effect="non-scaling-stroke" fill="transparent" stroke="#ddd" stroke-width="2"></circle><path d="m 50 0 a 50 50 0 0 1 50 50" vector-effect="non-scaling-stroke" fill="transparent" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>',this.searchResults.append(e)}hideLoading(){const e=this.searchResults.querySelector(".loading");e&&e.remove()}showNothingFound(){if(this.searchResults.querySelector(".nothing"))return;let t=document.createElement("li");t.classList.add("nothing"),t.textContent=`${(0,e.__)("Nothing found.","personalizewp")}`,this.searchResults.replaceChildren(t)}hideClearSearch(){this.clearSearch.style.display="none"}showClearSearch(){this.clearSearch.style.display=""}showLoadMore(){if(this.searchResults.querySelector(".load-more"))return;let t=document.createElement("li");t.classList.add("load-more"),t.innerHTML=`<button type="button" data-type="load-more">${(0,e.__)("Load more","personalizewp")}</button>`,this.searchResults.append(t)}resetSearchResults(){this.searchResults&&this.searchResults.replaceChildren()}resetAll(){this.selectedItems=[],this.renderSelection(),this.currentSearch="",this.currentPage=1,this.resetSearchResults(),this.searchInput&&(this.searchInput.value=""),o(this,"auto-complete","reset-all")}renderResults(e){this.hideLoading(),0!==e.length?(1===this.currentPage&&this.resetSearchResults(),this.searchResults.append(...Array.from(e).map(e=>{let t=document.createElement("span");t.classList.add("header"),t.textContent=e.text;let r=document.createElement("button");if(r.value=e.value,r.setAttribute("type","button"),r.setAttribute("data-type","search"),r.append(t),e.info){let t=document.createElement("span");t.classList.add("info"),t.setAttribute("aria-hidden","true"),t.textContent=e.info,r.append(t)}let s=document.createElement("li");return s.append(r),s})),this.totalPages>this.currentPage&&this.showLoadMore()):this.showNothingFound()}normalizeResults(e){let t=[];switch(this.mode){case"form":case"product":e.forEach(e=>{let r={value:e.value,text:(0,d.decodeEntities)(e.title)};e.url&&(r.info=(0,u.filterURLForDisplay)((0,u.safeDecodeURI)(e.url),30)),t.push(r)});break;case"term":e.forEach(e=>{t.push({value:e.id,text:(0,d.decodeEntities)(e.name),info:(0,u.filterURLForDisplay)((0,u.safeDecodeURI)(e.link),30)})});break;case"post":e.forEach(e=>{t.push({value:e.id,text:(0,d.decodeEntities)(e.title),info:(0,u.filterURLForDisplay)((0,u.safeDecodeURI)(e.url),30)})})}return t}handleSearchStringChange(e,t){if(""===(e=e.trim()))return this.currentSearch="",this.currentPage=1,void this.resetSearchResults();if(e!==this.currentSearch&&(this.currentPage=1,this.currentSearch=e),e.length<this.minChars)return;this.showLoading();let r=this.prepareSearchQuery(e,t);this.contentSearch(r)}prepareSearchQuery(e,t){let r,s;switch(this.mode){case"product":s={search:e,_embed:!0,per_page:this.perPage,page:t},0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,u.addQueryArgs)("personalizewp/v1/products-search",s);break;case"form":s={search:e,_embed:!0,per_page:this.perPage,page:t},r=(0,u.addQueryArgs)("personalizewp/v1/forms-search",s);break;case"term":s={search:e,per_page:this.perPage,page:t},r=(0,u.addQueryArgs)(`wp/v2/${this.restBase}`,s);break;default:s={search:e,type:this.mode,_embed:!0,per_page:this.perPage,page:t},0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,u.addQueryArgs)("wp/v2/search",s)}return r}contentSearch(e){c()({path:e,parse:!1}).then(e=>{this.totalPages=parseInt(e.headers&&e.headers.get("X-WP-TotalPages"),10),e.json().then(e=>{const t=this.normalizeResults(e);this.renderResults(t)})}).catch(e=>{console.log("catching error..."),this.hideLoading()})}}),customElements.define("custom-tag-list",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("input")||!1,t=this.getAttribute("submit")||!1,r=this.getAttribute("list")||!1;e&&t&&r&&(this.itemInput=this.querySelector(`#${e}`),this.itemSubmit=this.querySelector(`#${t}`),this.itemList=this.querySelector(`#${r}`),this.itemTemplate=this.querySelector("template")?.content,this.itemInput&&this.itemSubmit&&this.itemList&&this.itemTemplate&&(this.itemSubmit.removeAttribute("hidden"),this.itemSubmit.addEventListener("click",this),o(this,"custom-tag-list","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`handle${e.type}`](e)}handleclick(e){e.preventDefault();const t=this.itemInput.value.trim();if(""===t)return;const r=this.itemTemplate.cloneNode(!0);r.querySelector("span").textContent=t,r.querySelector("input").value=t,this.itemList.appendChild(r),this.itemInput.value=""}}),customElements.define("custom-tag",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;if(this.itemInput=this.querySelector("input"),this.itemButton=this.querySelector("button"),!this.itemInput||!this.itemButton)return;this.itemLabel=this.querySelector("label")||null;const e=this.itemButton.getAttribute("data-confirm-modal"),t=e?document.querySelector(e):null;this.dialog=e&&void 0!==window.HTMLDialogElement&&t?t:null,this.itemInput.setAttribute("type","hidden"),this.itemLabel&&(this.itemLabel.style.pointerEvents="none"),this.itemButton.removeAttribute("hidden"),this.itemButton.addEventListener("click",this),this.setAttribute("is-ready","")}handleEvent(e){this[`handle${e.type}`](e)}handleclose(e){this.dialog.removeEventListener("close",this),"delete"===this.dialog.returnValue&&this.remove()}handleclick(e){e.preventDefault(),this.dialog?(this.dialog.addEventListener("close",this),this.dialog.showModal()):this.remove()}});s()(()=>{window.pwpSettings&&""!==window.pwpSettings?.kb&&document.querySelector(`ul#adminmenu a[href='${window.pwpSettings.kb}']`)?.setAttribute("target","_blank");const t=document.querySelector("form[data-pwp]");t&&(e=>{const t=e.querySelector("#pwp_form_type"),r=e.querySelectorAll("[data-condition-type]");if(!t||0===r.length)return;const s=e.querySelector("#condition-addition"),i=e.querySelector("#condition-operator"),a=function(e){r.forEach(t=>{const r=t.getAttribute("data-condition-type")===e;if(t.hidden=!r,r){const e=null===t.querySelector(":scope > template");if(s.hidden=e,i){const r=null===t.querySelector(":scope auto-complete");i.hidden=r&&e}o(t,!0)}r||o(t)})},o=function(e,t=!1){t?e.querySelectorAll("[data-required]").forEach(e=>{e.removeAttribute("data-required"),e.required=!0}):e.querySelectorAll("[required]").forEach(e=>{e.setAttribute("data-required","required"),e.required=!1})};t.addEventListener("change",function(){a(t.options[t.selectedIndex].value)});var n=t.selectedIndex?t.options[t.selectedIndex].value:"";a(n);const l=e=>{const t=e.querySelectorAll('[data-type="taxonomy"]');t.length&&t.forEach(e=>{e.addEventListener("change",function(){const t=e.selectedIndex?e.options[e.selectedIndex].value:"",r=e.closest('[data-condition="row"]');if(r){const e=r.querySelector("auto-complete");e&&e.setAttribute("taxonomy",t)}})})};l(e),e.addEventListener("click",function(t){let r=t.target.closest("button");if(r){var s,i,a,o=!1;switch(r.value){case"add":a=(i=e.querySelector("[data-condition-type]:not([hidden])")).querySelector(":scope > template").content.cloneNode(!0),i.appendChild(a),l(e),o=!0;break;case"remove":(i=(s=r.closest('[data-condition="row"]')).closest("[data-condition-type]")).removeChild(s),o=!0}if(o){var n=i.querySelectorAll('[data-condition="row"]').length;i.setAttribute("data-condition-count",n)}}})})(t);var r=document.querySelectorAll("dialog.dialog");0!==r.length&&r.forEach(e=>{e.addEventListener("click",function(t){if(t.target.matches("dialog"))return e.close("close"),void t.stopPropagation();const r=t.target.closest("button");return r&&r.matches("button[value=close]")?(e.close("close"),void t.stopPropagation()):void 0})}),document.addEventListener("click",function(e){var t=e.target.closest("[data-show-modal]");if(!t)return;const r=t.getAttribute("data-show-modal"),s=document.querySelector(r);if(void 0!==window.HTMLDialogElement&&s){if(s.hasAttribute("data-url-action")){let e;t.hasAttribute("href")&&(e=t.getAttribute("href")),t.hasAttribute("data-form-action")&&(e=t.getAttribute("data-form-action")),e&&s.querySelector("form").setAttribute("action",e)}if("#editCategoryModal"===r){const e=t.getAttribute("href"),r=t.getAttribute("data-id"),i=t.getAttribute("data-name");s.querySelector("form").setAttribute("action",e),s.querySelector('[name="personalizewp_form[id]"]').value=r,s.querySelector('[name="personalizewp_form[name]"]').value=i}e.preventDefault(),s.showModal()}});const s=document.querySelector("ajax-form#newsletter-signup");s&&(s.addEventListener("pwp-ajax-form:submit-before",e=>{s.querySelectorAll(".field-error").forEach(e=>{e.classList.remove("field-error"),e.querySelector(".input-error").hidden=!0})}),s.addEventListener("pwp-ajax-form:error",e=>{var t;const r=null!==(t=e.detail?.errors)&&void 0!==t?t:[];r.length&&r.forEach(e=>{const t=s.querySelector(`input[name="${e}"]`).closest(".field"),r=t.querySelector(".input-error");t.classList.add("field-error"),r.hidden=!1})}),s.addEventListener("pwp-ajax-form:success",e=>{s.querySelectorAll(".actions button").forEach(e=>{e.hidden=!e.hidden})}));const i=document.querySelectorAll(".notice[data-dismiss-type]");0!==i.length&&i.forEach(e=>{e.addEventListener("click",function(t){if(!t.target.matches("button"))return;t.stopPropagation();const r=e.getAttribute("data-dismiss-type"),s=new FormData;s.append("action",`pwp_dismiss_${r}_message`),s.append("_ajax_nonce",pwpSettings.nonce),async function(e){let t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);const r=await fetch(pwpSettings.url,{method:"POST",headers:{Accept:"application/json, */*;q=0.1","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"},body:t.toString()});await r.json();r.ok}(s)})}),document.querySelector(".pwp-page [data-tabs]")&&(new(a())(".pwp-page [data-tabs]",{idPrefix:"pwp_"}),document.addEventListener("tabby",function(e){e.detail.tab.classList.add("is-active"),e.detail.previousTab.classList.remove("is-active")},!1)),(()=>{window.pwpSaveAlert=!1;const e=document.querySelectorAll("[data-save-alert]");if(0!==e.length){let t=[];e.forEach(e=>{var r;e.addEventListener("click",function(){window.pwpSaveAlert=!0});const s=null!==(r=e.getAttribute("form"))&&void 0!==r&&r;s?t.push(document.getElementById(s)):t.push(e.closest("form"))}),t.forEach(e=>{e.addEventListener("submit",function(){window.pwpSaveAlert=!1})})}const t=document.querySelectorAll("[data-clear-save-alert]");0!==t.length&&t.forEach(e=>{e.addEventListener("click",function(){window.pwpSaveAlert=!1})}),window.addEventListener("beforeunload",e=>{window.pwpSaveAlert&&(e.preventDefault(),e.returnValue=!0)})})();const o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;"woocommerce_time_since_last_order"===s&&(a=(0,e.__)("Enter number of days","personalizewp")),a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)},n=document.querySelector("#pwp-form");n&&((t=>{if(!t)return;if(!(t.querySelector(".conditions-measure")||document.body.classList.contains("post-type-personalizewp_rule")||t.classList.contains("personalizewp-rules-form")))return;const r=window.pwpRuleFormEx?.autocomplete_conditions||["woocommerce_product_stock_level","woocommerce_product_quantity_in_cart","woocommerce_category_quantity_in_cart"],s=e=>r.includes(e),i=e=>{const t=e.closest(".condition"),r=t?.querySelector(".rule-condition-values");if(!r)return;const s=(e.selectedItems||[]).map(e=>(e=>{if(!e)return"";if(/^\d+$/.test(e))return e;const t=e.match(/:(\d+)$/);return t?t[1]:e})(e.value||e.id)).filter(Boolean).join(",");r.value!==s&&(r.value=s)},a=(e,t)=>{const r=e.querySelector(".autocomplete-field-wrapper");t?(r&&(r.style.display="block"),e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{e.style.display="none";const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!0,t.value="")})):r&&(r.style.display="none",e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!1)}))},o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;switch(s){case"woocommerce_product_quantity_in_cart":a=(0,e.__)("No. of product","personalizewp");break;case"woocommerce_category_quantity_in_cart":a=(0,e.__)("No. of category","personalizewp");break;default:const t=i.getAttribute("data-initial-placeholder");t&&(a=t)}a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)};t.addEventListener("change",t=>{if(!t.target.classList.contains("conditions-measure"))return;const r=t.target.closest(".condition"),i=t.target.value;if(s(i)){const t=r.querySelector(".autocomplete-field-wrapper"),s=r.querySelector("auto-complete.rule-condition-autocomplete");t?(s&&((t,r)=>{const s={woocommerce_product_stock_level:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_product_quantity_in_cart:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_category_quantity_in_cart:{mode:"product","content-types":"categories",placeholder:(0,e.__)("Search for a category","personalizewp")}}[r];s&&t&&(t.setAttribute("mode",s.mode),t.setAttribute("placeholder",s.placeholder),t.removeAttribute("taxonomy"),t.setAttribute("content-types",s["content-types"]),setTimeout(()=>{t.removeAttribute("disabled"),"function"==typeof t.resetAll&&t.resetAll()},10))})(s,i),a(r,!0)):((e,t)=>{const r=document.getElementById(`pwp-autocomplete-template-${t}`);if(!r)return;const s=r.content.cloneNode(!0).querySelector(".autocomplete-field-wrapper");if(s){const t=e.querySelector(".conditions-comparator");t&&t.before(s),o(e),a(e,!0)}})(r,i)}else{const e=r.querySelector("auto-complete.rule-condition-autocomplete");e&&"function"==typeof e.resetAll&&e.resetAll(),a(r,!1)}o(r)});const n=e=>{t.querySelectorAll("auto-complete.rule-condition-autocomplete").forEach(i)};t.addEventListener("submit",n);const l=(e,r)=>{const s=t.querySelector("#form-actions");(r?.detail?.items?.length&&s||s)&&jQuery(s).show(),n()};t.addEventListener("pwp-auto-complete:remove-item",l),t.addEventListener("pwp-auto-complete:add-item",l),t.querySelectorAll(".condition").forEach(e=>{const t=e.querySelector(".conditions-measure"),r=t?.value;if(r&&s(r)){const t=e.querySelector(".autocomplete-field-wrapper"),r=e.querySelector(".conditions-comparator");r&&r.before(t),o(e),a(e,!0)}})})(n),n.querySelectorAll(".condition").forEach(o),n.addEventListener("change",e=>{if(!e.target.classList.contains("conditions-measure"))return;const t=e.target.closest(".condition");t&&o(t)}))})})()})();1 (()=>{var e={51:function(e,t,r){var s,i;Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),i=void 0!==r.g?r.g:"undefined"!=typeof window?window:this,s=function(){return function(e){"use strict";var t={idPrefix:"tabby-toggle_",default:"[data-tabby-default]"},r=function(t){if(t&&"true"!=t.getAttribute("aria-selected")){var r=document.querySelector(t.hash);if(r){var s=function(e){var t=e.closest('[role="tablist"]');if(!t)return{};var r=t.querySelector('[role="tab"][aria-selected="true"]');if(!r)return{};var s=document.querySelector(r.hash);return r.setAttribute("aria-selected","false"),r.setAttribute("tabindex","-1"),s?(s.setAttribute("hidden","hidden"),{previousTab:r,previousContent:s}):{previousTab:r}}(t);!function(e,t){e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0"),t.removeAttribute("hidden"),e.focus()}(t,r),s.tab=t,s.content=r,function(t,r){var s;"function"==typeof e.CustomEvent?s=new CustomEvent("tabby",{bubbles:!0,cancelable:!0,detail:r}):(s=document.createEvent("CustomEvent")).initCustomEvent("tabby",!0,!0,r),t.dispatchEvent(s)}(t,s)}}};return function(s,i){var a,o,n={destroy:function(){var e=o.querySelectorAll("a");Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id.slice(0,r.idPrefix.length)===r.idPrefix&&(e.id=""),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex"),e.closest("li").removeAttribute("role"),t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("hidden")}(e,t,a)}),o.removeAttribute("role"),document.documentElement.removeEventListener("click",l,!0),o.removeEventListener("keydown",c,!0),a=null,o=null},setup:function(){if(o=document.querySelector(s)){var e=o.querySelectorAll("a");o.setAttribute("role","tablist"),Array.prototype.forEach.call(e,function(e){var t=document.querySelector(e.hash);t&&function(e,t,r){e.id||(e.id=r.idPrefix+t.id),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.id),e.closest("li").setAttribute("role","presentation"),t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),e.matches(r.default)?e.setAttribute("aria-selected","true"):(e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),t.setAttribute("hidden","hidden"))}(e,t,a)})}},toggle:function(e){var t=e;"string"==typeof e&&(t=document.querySelector(s+' [role="tab"][href*="'+e+'"]')),r(t)}},l=function(e){var t=e.target.closest(s+' [role="tab"]');t&&(e.preventDefault(),r(t))},c=function(e){var t=document.activeElement;t.matches(s+' [role="tab"]')&&(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Up","Down","Left","Right","Home","End"].indexOf(e.key)<0||function(e,t){var s=function(e){var t=e.closest('[role="tablist"]'),r=t?t.querySelectorAll('[role="tab"]'):null;if(r)return{tabs:r,index:Array.prototype.indexOf.call(r,e)}}(e);if(s){var i,a=s.tabs.length-1;["ArrowUp","ArrowLeft","Up","Left"].indexOf(t)>-1?i=s.index<1?a:s.index-1:["ArrowDown","ArrowRight","Down","Right"].indexOf(t)>-1?i=s.index===a?0:s.index+1:"Home"===t?i=0:"End"===t&&(i=a),r(s.tabs[i])}}(t,e.key))};return a=function(){var e={};return Array.prototype.forEach.call(arguments,function(t){for(var r in t){if(!t.hasOwnProperty(r))return;e[r]=t[r]}}),e}(t,i||{}),n.setup(),function(t){if(!(e.location.hash.length<1)){var s=document.querySelector(t+' [role="tab"][href*="'+e.location.hash+'"]');r(s)}}(s),document.documentElement.addEventListener("click",l,!0),o.addEventListener("keydown",c,!0),n}}(i)}.apply(t,[]),void 0===s||(e.exports=s)}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.i18n,t=window.wp.domReady;var s=r.n(t),i=r(51),a=r.n(i);function o(e,t,r,s=null,i=!1){const a=new CustomEvent(`pwp-${t}:${r}`,{bubbles:!0,cancelable:i,detail:s});return e.dispatchEvent(a)}function n(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{e.readyInit()},{once:!0}):e.readyInit()}customElements.define("ajax-form",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){var e;this.hasAttribute("is-ready")||(this.announce=this.querySelector('[role="status"]')||document.createElement("div"),this.announce.setAttribute("role","status"),this.form=this.querySelector("form"),this.form&&(this.form.append(this.announce),this.msgSubmitting=null!==(e=this.getAttribute("msg-submitting"))&&void 0!==e?e:"Submitting...",this.msgDisappear=this.hasAttribute("msg-disappear"),this.keepFields=this.hasAttribute("keep-fields"),this.updateURL=this.getAttribute("update-url"),this.removeElem=this.getAttribute("remove"),this.closeDialog=this.hasAttribute("close-dialog"),this.delay=this.hasAttribute("delay")?6e3:0,this.form.addEventListener("submit",this),o(this,"ajax-form","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`on${e.type}`](e)}async onsubmit(e){if(e.preventDefault(),!this.isDisabled()){this.disable(),this.showStatus(this.msgSubmitting,!0);try{const e=this.serialize(),t=this.form.getAttribute("action"),r=this.form.getAttribute("method");if(!o(this,"ajax-form","submit-before",{action:t,formData:e},!0))return;const s=await fetch(t,{method:r,body:this.serialize(),headers:{Accept:"application/json, */*;q=0.1","Content-type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"}});let i=await s.json();if(!s.ok)throw i;if(Object.hasOwn(i,"success")&&!i.success)throw Object.hasOwn(i,"data")&&(i=i.data),o(this,"ajax-form","error",i),i;Object.hasOwn(i,"data")&&(i=i.data),i.message&&this.showStatus(i.message,!0,!0),this.updateURL&&history.replaceState(history.state,null,this.updateURL),i.url&&(window.location.href=i.url),this.keepFields||this.reset(),o(this,"ajax-form","success",i),this.removeElem&&(this.closest(this.removeElem)||this).remove()}catch(e){console.warn(e),this.showStatus(e.message)}finally{setTimeout(()=>{this.enable()},this.delay)}}}disable(){this.setAttribute("form-submitting","")}enable(){this.removeAttribute("form-submitting")}isDisabled(){return this.hasAttribute("form-submitting")}showStatus(e,t,r){this.announce.hidden=!1,this.announce.innerHTML=e,this.announce.className=t?"notice-message success-message":"notice-message error-message",t&&r&&this.removeElem&&this.toast(),t&&this.msgDisappear&&setTimeout(()=>{this.announce.hidden=!0,this.announce.innerHTML="",this.announce.className=""},6e3),t&&r&&this.closeDialog&&setTimeout(()=>{const e=this.closest("dialog");e&&e.close("close")},6e3)}toast(){const e=document.querySelector(".toast-wrapper");e||(e=document.createElement("div"),e.className="toast-wrapper",document.body.append(e)),this.announce.className="toast",e.prepend(this.announce),setTimeout(()=>{this.announce.remove()},6e3)}serialize(){const e=new FormData(this.form),t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);return t.toString()}reset(){this.form.reset()}}),customElements.define("ajax-html",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("event-name")?.split(",")||[];if(this.eventUID=this.getAttribute("event-uid")?.split(",")||[],e.length&&this.id){for(let t of e)document.addEventListener(t,e=>{this.updateHTML(e,this)});o(this,"ajax-html","ready"),this.setAttribute("is-ready","")}}async updateHTML(e,t){if(!this.eventUID.length||this.eventUID.includes(e.detail?.uid))try{let e=await fetch(location.href);if(!e.ok)throw e;let r=await e.text(),s=(new DOMParser).parseFromString(r,"text/html").querySelector(`#${t.id}`);if(!s)return;t.replaceWith(s)}catch(e){console.warn("Unable to update HTML")}}});const l=window.wp.apiFetch;var c=r.n(l);const d=window.wp.url,u=window.wp.htmlEntities;customElements.define("auto-complete",class extends HTMLElement{static observedAttributes=["mode","content-types","taxonomy","disabled","placeholder"];connectedCallback(){n(this)}readyInit(){this.hasAttribute("is-ready")||(this.itemTemplate=this.querySelector("template")?.content,this.itemTemplate&&(this.currentSearch="",this.currentPage=1,this.totalPages=1,this.perPage=10,this.minChars=2,this.initialiseMode(),this.searchInput=null,this.clearSearch=null,this.searchResults=null,this.displaySelected=null,this.setupDOM(),this.renderSelection(),this.searchInput.addEventListener("keyup",this),this.clearSearch.addEventListener("click",this),this.searchResults.addEventListener("click",this),this.displaySelected.addEventListener("click",this),o(this,"auto-complete","ready",{items:this.selectedItems}),this.setAttribute("is-ready","")))}setupDOM(){if(!this.searchInput&&!this.clearSearch){let t=document.createElement("div");t.classList.add("search"),this.searchInput=document.createElement("input"),this.searchInput.setAttribute("type","text"),this.searchInput.setAttribute("autocomplete","off"),this.disabled&&this.searchInput.setAttribute("disabled",""),this.searchInput.classList.add("auto-complete","search-icon"),this.searchInput.id=this.getAttribute("label-id")||"auto-complete-"+Math.floor(100*Math.random()),this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`),t.append(this.searchInput),this.clearSearch=document.createElement("button"),this.clearSearch.setAttribute("type","button"),this.clearSearch.setAttribute("data-type","reset"),this.clearSearch.setAttribute("aria-label",`${(0,e.__)("Reset search","personalizewp")}`),this.clearSearch.innerHTML='<svg width="24" height="24"><use xlink:href="#pwp-icon-cross"></use></svg>',this.hideClearSearch(),t.append(this.clearSearch),this.append(t)}this.searchResults||(this.searchResults=document.createElement("ul"),this.searchResults.classList.add("search-results"),this.append(this.searchResults)),this.displaySelected||(this.displaySelected=document.createElement("ul"),this.displaySelected.classList.add("tag-list","cluster"),this.append(this.displaySelected))}initialiseMode(){this.mode=this.getAttribute("mode")||"post",this.disabled=this.getAttribute("disabled")||!1,this.taxonomy=this.getAttribute("taxonomy")||null,this.contentTypes=this.getAttribute("content-types")||[],0!==this.contentTypes.length&&(this.contentTypes=this.contentTypes.split(",").map(e=>e.replace(/[^a-z0-9_\-]/,""))),this.selectedItems=this.getAttribute("content")||[],0!==this.selectedItems.length&&(this.selectedItems=JSON.parse(this.selectedItems)),this.restBase=null,"term"===this.mode&&(window.PWPTaxonomyRestBases&&(this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null),this.restBase||c()({path:"wp/v2/taxonomies"}).then(e=>{const t={};for(const r in e)t[`${r}`]=e[`${r}`].rest_base;window.PWPTaxonomyRestBases=t,this.restBase=window.PWPTaxonomyRestBases?.[`${this.taxonomy}`]||null,this.restBase||this.setAttribute("disabled","")}).catch(e=>{console.log("catching error...",e),this.setAttribute("disabled","")}))}handleEvent(e){this[`handle${e.type}`](e)}handlekeyup(e){clearTimeout(this.debouce),""===this.searchInput.value?this.hideClearSearch():this.showClearSearch(),this.debouce=setTimeout(()=>{this.handleSearchStringChange(this.searchInput.value,this.currentPage)},250)}handleclick(e){e.preventDefault();let t=e.target.closest("button");if(!t)return;let r=t.getAttribute("data-type");if(r)switch(r){case"reset":this.currentPage=1,this.currentSearch="",this.searchInput.value="",this.resetSearchResults(),this.searchInput.focus(),this.hideClearSearch();break;case"load-more":this.currentPage++,this.handleSearchStringChange(this.searchInput.value,this.currentPage),t.closest("li").remove();break;case"selected":t.closest("li").remove(),this.removeSelectedItem(t.value);break;case"search":this.addSelectedItem(t.value,t.querySelector(".header").textContent)}}attributeChangedCallback(e,t,r){this.hasAttribute("is-ready")&&this[`handleChange${e=e.replace(/[^a-zA-Z0-9]/i,"")}`](t,r)}handleChangeplaceholder(t){this.searchInput&&this.searchInput.setAttribute("placeholder",this.getAttribute("placeholder")||`${(0,e.__)("Search","personalizewp")}`)}handleChangemode(e,t){this.initialiseMode()}handleChangecontenttypes(e,t){t&&0!==t.length?this.contentTypes=t.split(",").map(e=>e.replace(/[^a-z0-9_\-]/,"")):this.contentTypes=[]}handleChangetaxonomy(e,t){if(null===t||""===t)return this.taxonomy=null,void this.setAttribute("disabled","");this.taxonomy=t,this.resetSearchResults(),this.initialiseMode(),null!==e&&""!==e||(e="%TAXONOMY%");const r=this.itemTemplate.querySelector('input[type="hidden"][name^="pwp_form"]');r&&r.setAttribute("name",r.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`)),this.displaySelected.querySelectorAll('input[type="hidden"][name^="pwp_form"]').forEach(t=>{t.setAttribute("name",t.getAttribute("name").replace(`[${e}]`,`[${this.taxonomy}]`))}),this.removeAttribute("disabled")}handleChangedisabled(e,t){null!==t?(this.disabled=!0,this.searchInput&&this.searchInput.setAttribute("disabled",""),this.resetSearchResults()):(this.disabled=!1,this.searchInput&&this.searchInput.removeAttribute("disabled"))}removeSelectedItem(e){let t=this.selectedItems.findIndex(t=>t.value===e);-1!==t&&(this.selectedItems.splice(t,1),this.renderSelection(),o(this,"auto-complete","remove-item",{item:e,items:this.selectedItems}))}addSelectedItem(e,t){-1===this.selectedItems.findIndex(t=>t.value===e)&&(this.selectedItems.unshift({value:e,text:t}),this.renderSelection(),o(this,"auto-complete","add-item",{newItem:e,items:this.selectedItems}))}renderSelection(){this.displaySelected&&this.displaySelected.replaceChildren(...Array.from(this.selectedItems).map(e=>{let t=document.createElement("li");return t.append(this.itemTemplate.cloneNode(!0)),t.querySelector("span").textContent=e.text,t.querySelector("input").value=e.value,t.querySelector("button").value=e.value,t.querySelector("button").setAttribute("data-type","selected"),t}))}showLoading(){if(this.searchResults.querySelector(".loading"))return;let e=document.createElement("li");e.classList.add("loading"),e.innerHTML='<svg class="components-spinner" viewBox="0 0 100 100" width="20" height="20" xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false"><circle cx="50" cy="50" r="50" vector-effect="non-scaling-stroke" fill="transparent" stroke="#ddd" stroke-width="2"></circle><path d="m 50 0 a 50 50 0 0 1 50 50" vector-effect="non-scaling-stroke" fill="transparent" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>',this.searchResults.append(e)}hideLoading(){const e=this.searchResults.querySelector(".loading");e&&e.remove()}showNothingFound(){if(this.searchResults.querySelector(".nothing"))return;let t=document.createElement("li");t.classList.add("nothing"),t.textContent=`${(0,e.__)("Nothing found.","personalizewp")}`,this.searchResults.replaceChildren(t)}hideClearSearch(){this.clearSearch.style.display="none"}showClearSearch(){this.clearSearch.style.display=""}showLoadMore(){if(this.searchResults.querySelector(".load-more"))return;let t=document.createElement("li");t.classList.add("load-more"),t.innerHTML=`<button type="button" data-type="load-more">${(0,e.__)("Load more","personalizewp")}</button>`,this.searchResults.append(t)}resetSearchResults(){this.searchResults&&this.searchResults.replaceChildren()}resetAll(){this.selectedItems=[],this.renderSelection(),this.currentSearch="",this.currentPage=1,this.resetSearchResults(),this.searchInput&&(this.searchInput.value=""),o(this,"auto-complete","reset-all")}renderResults(e){this.hideLoading(),0!==e.length?(1===this.currentPage&&this.resetSearchResults(),this.searchResults.append(...Array.from(e).map(e=>{let t=document.createElement("span");t.classList.add("header"),t.textContent=e.text;let r=document.createElement("button");if(r.value=e.value,r.setAttribute("type","button"),r.setAttribute("data-type","search"),r.append(t),e.info){let t=document.createElement("span");t.classList.add("info"),t.setAttribute("aria-hidden","true"),t.textContent=e.info,r.append(t)}let s=document.createElement("li");return s.append(r),s})),this.totalPages>this.currentPage&&this.showLoadMore()):this.showNothingFound()}normalizeResults(e){let t=[];switch(this.mode){case"form":case"product":e.forEach(e=>{let r={value:e.value,text:(0,u.decodeEntities)(e.title)};e.url&&(r.info=(0,d.filterURLForDisplay)((0,d.safeDecodeURI)(e.url),30)),t.push(r)});break;case"term":e.forEach(e=>{t.push({value:e.id,text:(0,u.decodeEntities)(e.name),info:(0,d.filterURLForDisplay)((0,d.safeDecodeURI)(e.link),30)})});break;case"post":e.forEach(e=>{t.push({value:e.id,text:(0,u.decodeEntities)(e.title),info:(0,d.filterURLForDisplay)((0,d.safeDecodeURI)(e.url),30)})})}return t}handleSearchStringChange(e,t){if(""===(e=e.trim()))return this.currentSearch="",this.currentPage=1,void this.resetSearchResults();if(e!==this.currentSearch&&(this.currentPage=1,this.currentSearch=e),e.length<this.minChars)return;this.showLoading();let r=this.prepareSearchQuery(e,t);this.contentSearch(r)}prepareSearchQuery(e,t){let r,s;switch(this.mode){case"product":s={search:e,_embed:!0,per_page:this.perPage,page:t},this.contentTypes&&0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,d.addQueryArgs)("personalizewp/v1/products-search",s);break;case"form":s={search:e,_embed:!0,per_page:this.perPage,page:t},r=(0,d.addQueryArgs)("personalizewp/v1/forms-search",s);break;case"term":s={search:e,per_page:this.perPage,page:t},r=(0,d.addQueryArgs)(`wp/v2/${this.restBase}`,s);break;default:s={search:e,type:this.mode,_embed:!0,per_page:this.perPage,page:t},0!==this.contentTypes.length&&(s.subtype=this.contentTypes.join(",")),r=(0,d.addQueryArgs)("wp/v2/search",s)}return r}contentSearch(e){c()({path:e,parse:!1}).then(e=>{this.totalPages=parseInt(e.headers&&e.headers.get("X-WP-TotalPages"),10),e.json().then(e=>{const t=this.normalizeResults(e);this.renderResults(t)})}).catch(e=>{console.log("catching error..."),this.hideLoading()})}}),customElements.define("custom-tag-list",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;const e=this.getAttribute("input")||!1,t=this.getAttribute("submit")||!1,r=this.getAttribute("list")||!1;e&&t&&r&&(this.itemInput=this.querySelector(`#${e}`),this.itemSubmit=this.querySelector(`#${t}`),this.itemList=this.querySelector(`#${r}`),this.itemTemplate=this.querySelector("template")?.content,this.itemInput&&this.itemSubmit&&this.itemList&&this.itemTemplate&&(this.itemSubmit.removeAttribute("hidden"),this.itemSubmit.addEventListener("click",this),o(this,"custom-tag-list","ready"),this.setAttribute("is-ready","")))}handleEvent(e){this[`handle${e.type}`](e)}handleclick(e){e.preventDefault();const t=this.itemInput.value.trim();if(""===t)return;const r=this.itemTemplate.cloneNode(!0);r.querySelector("span").textContent=t,r.querySelector("input").value=t,this.itemList.appendChild(r),this.itemInput.value=""}}),customElements.define("custom-tag",class extends HTMLElement{connectedCallback(){n(this)}readyInit(){if(this.hasAttribute("is-ready"))return;if(this.itemInput=this.querySelector("input"),this.itemButton=this.querySelector("button"),!this.itemInput||!this.itemButton)return;this.itemLabel=this.querySelector("label")||null;const e=this.itemButton.getAttribute("data-confirm-modal"),t=e?document.querySelector(e):null;this.dialog=e&&void 0!==window.HTMLDialogElement&&t?t:null,this.itemInput.setAttribute("type","hidden"),this.itemLabel&&(this.itemLabel.style.pointerEvents="none"),this.itemButton.removeAttribute("hidden"),this.itemButton.addEventListener("click",this),this.setAttribute("is-ready","")}handleEvent(e){this[`handle${e.type}`](e)}handleclose(e){this.dialog.removeEventListener("close",this),"delete"===this.dialog.returnValue&&this.remove()}handleclick(e){e.preventDefault(),this.dialog?(this.dialog.addEventListener("close",this),this.dialog.showModal()):this.remove()}});s()(()=>{window.pwpSettings&&""!==window.pwpSettings?.kb&&document.querySelector(`ul#adminmenu a[href='${window.pwpSettings.kb}']`)?.setAttribute("target","_blank");const t=document.querySelector("form[data-pwp]");t&&(e=>{const t=e.querySelector("#pwp_form_type"),r=e.querySelectorAll("[data-condition-type]");if(!t||0===r.length)return;const s=e.querySelector("#condition-addition"),i=e.querySelector("#condition-operator"),a=function(e){r.forEach(t=>{const r=t.getAttribute("data-condition-type")===e;if(t.hidden=!r,r){const e=null===t.querySelector(":scope > template");if(s.hidden=e,i){const r=null===t.querySelector(":scope auto-complete");i.hidden=r&&e}o(t,!0)}r||o(t)})},o=function(e,t=!1){t?e.querySelectorAll("[data-required]").forEach(e=>{e.removeAttribute("data-required"),e.required=!0}):e.querySelectorAll("[required]").forEach(e=>{e.setAttribute("data-required","required"),e.required=!1})};t.addEventListener("change",function(){a(t.options[t.selectedIndex].value)});var n=t.selectedIndex?t.options[t.selectedIndex].value:"";a(n);const l=e=>{const t=e.querySelectorAll('[data-type="taxonomy"]');t.length&&t.forEach(e=>{e.addEventListener("change",function(){const t=e.selectedIndex?e.options[e.selectedIndex].value:"",r=e.closest('[data-condition="row"]');if(r){const e=r.querySelector("auto-complete");e&&e.setAttribute("taxonomy",t)}})})};l(e),e.addEventListener("click",function(t){let r=t.target.closest("button");if(r){var s,i,a,o=!1;switch(r.value){case"add":a=(i=e.querySelector("[data-condition-type]:not([hidden])")).querySelector(":scope > template").content.cloneNode(!0),i.appendChild(a),l(e),o=!0;break;case"remove":(i=(s=r.closest('[data-condition="row"]')).closest("[data-condition-type]")).removeChild(s),o=!0}if(o){var n=i.querySelectorAll('[data-condition="row"]').length;i.setAttribute("data-condition-count",n)}}})})(t);var r=document.querySelectorAll("dialog.dialog");0!==r.length&&r.forEach(e=>{e.addEventListener("click",function(t){if(t.target.matches("dialog"))return e.close("close"),void t.stopPropagation();const r=t.target.closest("button");return r&&r.matches("button[value=close]")?(e.close("close"),void t.stopPropagation()):void 0})}),document.addEventListener("click",function(e){var t=e.target.closest("[data-show-modal]");if(!t)return;const r=t.getAttribute("data-show-modal"),s=document.querySelector(r);if(void 0!==window.HTMLDialogElement&&s){if(s.hasAttribute("data-url-action")){let e;t.hasAttribute("href")&&(e=t.getAttribute("href")),t.hasAttribute("data-form-action")&&(e=t.getAttribute("data-form-action")),e&&s.querySelector("form").setAttribute("action",e)}if("#editCategoryModal"===r){const e=t.getAttribute("href"),r=t.getAttribute("data-id"),i=t.getAttribute("data-name");s.querySelector("form").setAttribute("action",e),s.querySelector('[name="personalizewp_form[id]"]').value=r,s.querySelector('[name="personalizewp_form[name]"]').value=i}e.preventDefault(),s.showModal()}});const s=document.querySelector("ajax-form#newsletter-signup");s&&(s.addEventListener("pwp-ajax-form:submit-before",e=>{s.querySelectorAll(".field-error").forEach(e=>{e.classList.remove("field-error"),e.querySelector(".input-error").hidden=!0})}),s.addEventListener("pwp-ajax-form:error",e=>{var t;const r=null!==(t=e.detail?.errors)&&void 0!==t?t:[];r.length&&r.forEach(e=>{const t=s.querySelector(`input[name="${e}"]`).closest(".field"),r=t.querySelector(".input-error");t.classList.add("field-error"),r.hidden=!1})}),s.addEventListener("pwp-ajax-form:success",e=>{s.querySelectorAll(".actions button").forEach(e=>{e.hidden=!e.hidden})}));const i=document.querySelectorAll(".notice[data-dismiss-type]");0!==i.length&&i.forEach(e=>{e.addEventListener("click",function(t){if(!t.target.matches("button"))return;t.stopPropagation();const r=e.getAttribute("data-dismiss-type"),s=new FormData;s.append("action",`pwp_dismiss_${r}_message`),s.append("_ajax_nonce",pwpSettings.nonce),async function(e){let t=new URLSearchParams;for(let[r,s]of e)t.append(r,s);const r=await fetch(pwpSettings.url,{method:"POST",headers:{Accept:"application/json, */*;q=0.1","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8","X-Requested-With":"XMLHttpRequest"},body:t.toString()});await r.json();r.ok}(s)})}),document.querySelector(".pwp-page [data-tabs]")&&(new(a())(".pwp-page [data-tabs]",{idPrefix:"pwp_"}),document.addEventListener("tabby",function(e){e.detail.tab.classList.add("is-active"),e.detail.previousTab.classList.remove("is-active")},!1)),(()=>{window.pwpSaveAlert=!1;const e=document.querySelectorAll("[data-save-alert]");if(0!==e.length){let t=[];e.forEach(e=>{var r;e.addEventListener("click",function(){window.pwpSaveAlert=!0});const s=null!==(r=e.getAttribute("form"))&&void 0!==r&&r;s?t.push(document.getElementById(s)):t.push(e.closest("form"))}),t.forEach(e=>{e.addEventListener("submit",function(){window.pwpSaveAlert=!1})})}const t=document.querySelectorAll("[data-clear-save-alert]");0!==t.length&&t.forEach(e=>{e.addEventListener("click",function(){window.pwpSaveAlert=!1})}),window.addEventListener("beforeunload",e=>{window.pwpSaveAlert&&(e.preventDefault(),e.returnValue=!0)})})();const o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;"woocommerce_time_since_last_order"===s&&(a=(0,e.__)("Enter number of days","personalizewp")),a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)},n=document.querySelector("#pwp-form");n&&((t=>{if(!t)return;if(!(t.querySelector(".conditions-measure")||document.body.classList.contains("post-type-personalizewp_rule")||t.classList.contains("personalizewp-rules-form")))return;const r=window.pwpRuleFormEx?.autocomplete_conditions||["woocommerce_product_stock_level","woocommerce_product_quantity_in_cart","woocommerce_category_quantity_in_cart"],s=e=>r.includes(e),i=e=>{const t=e.closest(".condition"),r=t?.querySelector(".rule-condition-values");if(!r)return;const s=(e.selectedItems||[]).map(e=>(e=>{if(!e)return"";if(/^\d+$/.test(e))return e;const t=e.match(/:(\d+)$/);return t?t[1]:e})(e.value||e.id)).filter(Boolean).join(",");r.value!==s&&(r.value=s)},a=(e,t)=>{const r=e.querySelector(".autocomplete-field-wrapper");t?(r&&(r.style.display="block"),e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{e.style.display="none";const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!0,t.value="")})):r&&(r.style.display="none",e.querySelectorAll(".meta-text-field-wrapper, .meta-value-wrapper").forEach(e=>{const t=e.querySelector('input[name*="[meta_value]"]');t&&(t.disabled=!1)}))},o=t=>{const r=t.querySelector(".conditions-measure"),s=r?.value,i=t.querySelector(".text-field-wrapper .field-value-text");let a=null;switch(s){case"woocommerce_product_quantity_in_cart":a=(0,e.__)("No. of product","personalizewp");break;case"woocommerce_category_quantity_in_cart":a=(0,e.__)("No. of category","personalizewp");break;default:const t=i.getAttribute("data-initial-placeholder");t&&(a=t)}a&&i&&(i.getAttribute("data-initial-placeholder")||i.setAttribute("data-initial-placeholder",i.placeholder),i.placeholder=a)};t.addEventListener("change",t=>{if(!t.target.classList.contains("conditions-measure"))return;const r=t.target.closest(".condition"),i=t.target.value;if(s(i)){const t=r.querySelector(".autocomplete-field-wrapper"),s=r.querySelector("auto-complete.rule-condition-autocomplete");t?(s&&((t,r)=>{const s={woocommerce_product_stock_level:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_product_quantity_in_cart:{mode:"product","content-types":"products",placeholder:(0,e.__)("Search for a product","personalizewp")},woocommerce_category_quantity_in_cart:{mode:"product","content-types":"categories",placeholder:(0,e.__)("Search for a category","personalizewp")}}[r];s&&t&&(t.setAttribute("mode",s.mode),t.setAttribute("placeholder",s.placeholder),t.removeAttribute("taxonomy"),t.setAttribute("content-types",s["content-types"]),setTimeout(()=>{t.removeAttribute("disabled"),"function"==typeof t.resetAll&&t.resetAll()},10))})(s,i),a(r,!0)):((e,t)=>{const r=document.getElementById(`pwp-autocomplete-template-${t}`);if(!r)return;const s=r.content.cloneNode(!0).querySelector(".autocomplete-field-wrapper");if(s){const t=e.querySelector(".conditions-comparator");t&&t.before(s),o(e),a(e,!0)}})(r,i)}else{const e=r.querySelector("auto-complete.rule-condition-autocomplete");e&&"function"==typeof e.resetAll&&e.resetAll(),a(r,!1)}o(r)});const n=e=>{t.querySelectorAll("auto-complete.rule-condition-autocomplete").forEach(i)};t.addEventListener("submit",n);const l=(e,r)=>{const s=t.querySelector("#form-actions");(r?.detail?.items?.length&&s||s)&&jQuery(s).show(),n()};t.addEventListener("pwp-auto-complete:remove-item",l),t.addEventListener("pwp-auto-complete:add-item",l),t.querySelectorAll(".condition").forEach(e=>{const t=e.querySelector(".conditions-measure"),r=t?.value;if(r&&s(r)){const t=e.querySelector(".autocomplete-field-wrapper"),r=e.querySelector(".conditions-comparator");r&&r.before(t),o(e),a(e,!0)}})})(n),n.querySelectorAll(".condition").forEach(o),n.addEventListener("change",e=>{if(!e.target.classList.contains("conditions-measure"))return;const t=e.target.closest(".condition");t&&o(t)}))})})()})(); -
personalizewp/trunk/admin/partials/scoring-rules/_form.php
r3380017 r3382403 221 221 if ( is_numeric( $cpt_page ) ) : 222 222 $page_ids[] = array( 223 'value' => ( int) $cpt_page,223 'value' => (string) $cpt_page, // Web component standardises on strings 224 224 'text' => get_the_title( $cpt_page ), 225 225 ); -
personalizewp/trunk/admin/partials/segments/_form.php
r3380017 r3382403 293 293 if ( is_a( $term_cond, '\WP_Term' ) ) : 294 294 $taxonomies[ $tax_cond ][] = array( 295 'value' => $term_cond->term_id,295 'value' => (string) $term_cond->term_id, // Web component standardises on strings 296 296 'text' => esc_html( $term_cond->name ), 297 297 ); … … 590 590 if ( is_numeric( $cpt_page ) ) : 591 591 $page_ids[] = array( 592 'value' => ( int) $cpt_page,592 'value' => (string) $cpt_page, // Web component standardises on strings 593 593 'text' => get_the_title( $cpt_page ), 594 594 ); -
personalizewp/trunk/build/blocks/product-collection/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/product-collection", 5 "version": "1.0. 0",6 "title": "P ersonalizeWP Product Collection",5 "version": "1.0.1", 6 "title": "Product Collection", 7 7 "description": "Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.", 8 "category": " woocommerce",8 "category": "personalizewp", 9 9 "keywords": [ 10 10 "PersonalizeWP", 11 "pwp", 11 12 "WooCommerce", 12 13 "personalization", -
personalizewp/trunk/build/blocks/product-collection/index.asset.php
r3380017 r3382403 1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => ' f3b4f67fee01300afd98');1 <?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'b07c136b179f020339de'); -
personalizewp/trunk/build/blocks/product-collection/index.js
r3380017 r3382403 1 (()=>{"use strict";var e,t={20:(e,t,o)=>{var l=o(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,o){var l,i={},s=null,p=null;for(l in void 0!==o&&(s=""+o),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(p=t.ref),t)n.call(t,l)&&!r.hasOwnProperty(l)&&(i[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===i[l]&&(i[l]=t[l]);return{$$typeof:a,type:e,key:s,ref:p,props:i,_owner:c.current}}},539:(e,t,o)=>{var l=o(609);const a=window.wp.blocks,n=window.wp.i18n,c=window.wp.blockEditor,r=window.wp.components,i=window.wp.element,s=window.wp.primitives;var p=o(848);const d=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})}),u=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})}),m=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{fillRule:"evenodd",d:"M19.75 11H21V8.667L19.875 4H4.125L3 8.667V11h1.25v8.75h15.5V11zm-1.5 0H5.75v7.25H10V13h4v5.25h4.25V11zm-5.5-5.5h2.067l.486 3.24.028.76H12.75v-4zm-3.567 0h2.067v4H8.669l.028-.76.486-3.24zm7.615 3.1l-.464-3.1h2.36l.806 3.345V9.5h-2.668l-.034-.9zM7.666 5.5h-2.36L4.5 8.845V9.5h2.668l.034-.9.464-3.1z",clipRule:"evenodd"})}),w=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"m3 5c0-1.10457.89543-2 2-2h13.5c1.1046 0 2 .89543 2 2v13.5c0 1.1046-.8954 2-2 2h-13.5c-1.10457 0-2-.8954-2-2zm2-.5h6v6.5h-6.5v-6c0-.27614.22386-.5.5-.5zm-.5 8v6c0 .2761.22386.5.5.5h6v-6.5zm8 0v6.5h6c.2761 0 .5-.2239.5-.5v-6zm0-8v6.5h6.5v-6c0-.27614-.2239-.5-.5-.5z",fillRule:"evenodd",clipRule:"evenodd"})}),_=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})}),g=window.wp.apiFetch;var h=o.n(g);const b=[{name:"previously-viewed",title:(0,n.__)("Previously Viewed Products","personalizewp"),icon:d,description:(0,n.__)("Display products that visitors have recently browsed on your store","personalizewp"),details:(0,n.__)('Creates a "Recently Viewed" section showing products the current visitor has looked at before. Perfect for helping customers continue their shopping journey.',"personalizewp"),keywords:["viewed","history","recent"],color:"#7c3aed",gradient:"linear-gradient(135deg, #7c3aed 0%, #a855f7 100%)"},{name:"products-for-you",title:(0,n.__)("Products For You","personalizewp"),icon:u,description:(0,n.__)("Personalized product recommendations based on visitor segments and behavior","personalizewp"),details:(0,n.__)("Shows tailored product recommendations using PersonalizeWP's visitor segments and behavioral data. Displays products from relevant categories and frequently bought together items.","personalizewp"),keywords:["recommended","personalized","segments"],color:"#059669",gradient:"linear-gradient(135deg, #059669 0%, #10b981 100%)"}];function v({collection:e,onSelect:t,isSelected:o=!1}){const a=(0,i.useCallback)(()=>{t(e.name)},[e.name,t]),n=(0,i.useMemo)(()=>({"--collection-color":e.color,"--collection-gradient":e.gradient}),[e.color,e.gradient]);return(0,l.createElement)(r.Tooltip,{text:e.details,placement:"top"},(0,l.createElement)("button",{type:"button",className:"components-button wc-blocks-product-collection__collection-button "+(o?"is-selected":""),onClick:a,style:n,"aria-pressed":o,"aria-describedby":`collection-${e.name}-description`},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collection-button-icon"},(0,l.createElement)(r.Icon,{icon:e.icon,size:24})),(0,l.createElement)("p",{className:"wc-blocks-product-collection__collection-button-title",id:`collection-${e.name}-description`},e.title)))}function y({isOpen:e,onClose:t,onSelect:o,currentCollection:a}){const[c,s]=(0,i.useState)(a),p=(0,i.useCallback)(()=>{c&&(o(c),t())},[c,o,t]),d=(0,i.useCallback)(e=>{s(e)},[]),u=Boolean(c);return(0,l.createElement)(r.Modal,{className:"wc-blocks-product-collection__modal pwp-collection-picker-modal",onRequestClose:t,size:"large",shouldCloseOnClickOutside:!1,title:(0,n.__)("What products do you want to show?","personalizewp")},(0,l.createElement)("div",{className:"wc-blocks-product-collection__content"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-grid"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-section"},b.map(e=>(0,l.createElement)(v,{key:e.name,collection:e,onSelect:d,isSelected:c===e.name})))),(0,l.createElement)(r.Flex,{className:"wc-blocks-product-collection__footer",justify:"flex-end",gap:3},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",onClick:t},(0,n.__)("Cancel","personalizewp"))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"primary",onClick:p,disabled:!u},(0,n.__)("Continue","personalizewp"))))))}function C({onOpenModal:e}){return(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder"},(0,l.createElement)(r.Card,null,(0,l.createElement)(r.CardBody,null,(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder__content"},(0,l.createElement)("h3",{className:"pwp-collection-picker-placeholder__title"},(0,n.__)("PersonalizeWP Product Collection","personalizewp")),(0,l.createElement)("p",{className:"pwp-collection-picker-placeholder__description"},(0,n.__)("Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.","personalizewp")),(0,l.createElement)(r.Button,{variant:"primary",onClick:e,className:"pwp-collection-picker-placeholder__button"},(0,n.__)("Choose Recipe","personalizewp"))))))}function E({collection:e,onChangeCollection:t}){const o=(0,i.useMemo)(()=>b.find(t=>t.name===e),[e]);return o?(0,l.createElement)(r.Card,{className:"pwp-selected-collection"},(0,l.createElement)(r.CardBody,null,(0,l.createElement)(r.Flex,{direction:"column",gap:2},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Flex,{justify:"space-between",align:"center"},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("h4",{className:"pwp-selected-collection__title"},o.title)),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",size:"small",onClick:t,className:"pwp-selected-collection__change-button"},(0,n.__)("Change","personalizewp"))))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("p",{className:"pwp-selected-collection__description"},o.description))))):null}function f({currentCollection:e,onCollectionChange:t}){const[o,a]=(0,i.useState)(!1),n=(0,i.useCallback)(()=>{a(!0)},[]),c=(0,i.useCallback)(()=>{a(!1)},[]),r=(0,i.useCallback)(e=>{t(e),c()},[t,c]);return(0,l.createElement)(l.Fragment,null,e?(0,l.createElement)(E,{collection:e,onChangeCollection:n}):(0,l.createElement)(C,{onOpenModal:n}),o&&(0,l.createElement)(y,{isOpen:o,onClose:c,onSelect:r,currentCollection:e}))}const k=[{title:(0,n.__)("Previously Viewed Products","personalizewp"),value:"previously-viewed",icon:d,info:(0,n.__)("Display products that the current visitor has recently browsed on your store.","personalizewp")},{title:(0,n.__)("Products For You","personalizewp"),value:"products-for-you",icon:u,info:(0,n.__)("Show personalized product recommendations based on visitor segments, categories, and related products.","personalizewp")}],x=[{label:(0,n.__)("Show All Products","personalizewp"),value:"show_all"},{label:(0,n.__)("Hide Block","personalizewp"),value:"hide_block"},{label:(0,n.__)("Show Custom Message","personalizewp"),value:"show_message"}],z=[{id:1,name:"Sample Product",price_html:"$19.99",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"simple",average_rating:4.5,permalink:"#"},{id:2,name:"Variable Product",price_html:"$20.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"variable",average_rating:4,permalink:"#"},{id:3,name:"External Product",price_html:"$15.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"external",button_text:"Buy on external store!",average_rating:5,external_url:"#",permalink:"#"}],P=(e,t)=>{switch(t.type){case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_PRODUCTS":return{...e,products:t.payload,isLoading:!1,error:null};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"RESET":return{products:[],isLoading:!1,error:null};default:return e}},N=({product:e,layoutType:t,index:o,totalProducts:a,onButtonClick:c})=>{const r=function(e){return(0,i.useMemo)(()=>{let t=(0,n.__)("Add to cart","personalizewp"),o="add_to_cart_button ajax_add_to_cart",l="product-type-simple",a=!1;return"external"===e.type?(t=e.button_text||(0,n.__)("Buy product","personalizewp"),o="product_type_external",l="product-type-external",a=!0):"variable"===e.type&&(t=(0,n.__)("Select options","personalizewp"),o="product_type_variable",l="product-type-variable"),{text:t,className:o,typeClass:l,isExternal:a}},[e.type,e.button_text])}(e),s=e.price_html&&e.price_html.includes("<del"),p=function(e,t,o,l,a){return(0,i.useMemo)(()=>["wc-block-product",`post-${e.id}`,"product","type-product","status-publish",e.image_url?"has-post-thumbnail":"","instock","shipping-taxable","purchasable",t.typeClass,"list"===o?"pwp-list-item":"",0===l?"first":"",l===a-1?"last":""].filter(Boolean).join(" "),[e,t.typeClass,o,l,a])}(e,r,t,o,a),d=e.image_url||"/wp-content/uploads/woocommerce-placeholder-300x300.png";return(0,l.createElement)("li",{className:p},(0,l.createElement)("div",{className:"wc-block-components-product-image wc-block-grid__product-image wp-block-woocommerce-product-image"},(0,l.createElement)("a",{href:"#",onClick:c},s&&(0,l.createElement)("div",{className:"wc-block-components-product-sale-badge wc-block-components-product-sale-badge--align-right wc-block-grid__product-onsale"},(0,l.createElement)("span",{"aria-hidden":"true"},(0,n.__)("Sale","personalizewp")),(0,l.createElement)("span",{className:"screen-reader-text"},(0,n.__)("Product on sale","personalizewp"))),(0,l.createElement)("img",{decoding:"async",width:"300",height:"300",src:d,alt:e.name,className:"attachment-woocommerce_thumbnail size-woocommerce_thumbnail",style:{maxWidth:"none",objectFit:"cover"}}))),(0,l.createElement)("h3",{style:{marginBottom:"0.75rem",marginTop:0},className:"has-text-align-center wp-block-post-title has-medium-font-size"},(0,l.createElement)("a",{href:"#",onClick:c,target:"_self"},e.name)),e.average_rating>0&&(0,l.createElement)("div",{className:"wc-block-components-product-rating"},(0,l.createElement)("div",{className:"wc-block-components-product-rating__stars","aria-label":`${e.average_rating} out of 5 stars`},"★".repeat(Math.floor(e.average_rating)),"☆".repeat(5-Math.floor(e.average_rating)))),(0,l.createElement)("div",{className:"wp-block-woocommerce-product-price"},(0,l.createElement)("div",{className:"wc-block-components-product-price wc-block-grid__product-price has-text-align-center has-font-size has-small-font-size"},(0,l.createElement)("span",{dangerouslySetInnerHTML:{__html:e.price_html}}))),(0,l.createElement)("div",{className:"wp-block-button wc-block-components-product-button align-center wp-block-woocommerce-product-button has-small-font-size"},r.isExternal?(0,l.createElement)("a",{href:"#",className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow noopener",target:"_blank"},(0,l.createElement)("span",null,r.text)):(0,l.createElement)("button",{className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow"},(0,l.createElement)("span",null,r.text))))};function T({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("div",{className:"pwp-loading-spinner",style:{display:"inline-block",width:"20px",height:"20px",border:"2px solid #ddd",borderTop:"2px solid #874FB9",borderRadius:"50%",animation:"spin 1s linear infinite",marginRight:"8px"}}),(0,n.__)("Loading personalized products...","personalizewp")))}function B({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("Unable to load products. Using fallback display.","personalizewp"))))}function S({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("No products found for this personalization recipe.","personalizewp")),(0,l.createElement)("p",null,(0,l.createElement)("small",null,(0,n.__)("Try viewing some products on your site first.","personalizewp")))))}function M({products:e,layoutType:t,gridColumns:o,onButtonClick:a}){const n="list"===t?"pwp-layout-list":"pwp-layout-grid",c="grid"===t?`columns-${o}`:"columns-1";return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${n}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("ul",{className:`${c} wc-block-product-template__responsive wc-block-product-template wp-block-woocommerce-product-template`},e.map((o,n)=>(0,l.createElement)(N,{key:o.id,product:o,layoutType:t,index:n,totalProducts:e.length,onButtonClick:a}))))}const R=JSON.parse('{"UU":"personalizewp-pro/product-collection"}'),L={src:(0,l.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)("path",{fill:"url(#paint0_linear_311_20854)",d:"M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"}),(0,l.createElement)("defs",null,(0,l.createElement)("linearGradient",{id:"paint0_linear_311_20854"},(0,l.createElement)("stop",{offset:".16",stopColor:"#C127A0"}),(0,l.createElement)("stop",{offset:".28",stopColor:"#CD20A1"}),(0,l.createElement)("stop",{offset:".59",stopColor:"#E813A4"}),(0,l.createElement)("stop",{offset:".76",stopColor:"#F20FA6"}))))};(0,a.registerBlockType)(R.UU,{icon:L,edit:function(e){const{attributes:t,setAttributes:o,clientId:a}=e,{queryId:s,query:p={},displayLayout:d={type:"flex",columns:3},layoutType:u="grid",gridColumns:g=3,pwpRecipe:b,pwpFallbackBehavior:v="show_all",pwpMaxProducts:y=8,pwpFallbackMessage:C="",pwpCollectionTitle:E=""}=t,[N,R]=(0,i.useReducer)(P,{products:[],isLoading:!1,error:null}),L=(0,i.useMemo)(()=>k.find(e=>e.value===b),[b]),O=(0,i.useCallback)(e=>{e.preventDefault()},[]),F=(0,i.useCallback)(async()=>{try{h()({path:`/wc/store/v1/products?per_page=${y||6}&orderby=date&order=desc`}).then(e=>{const t=e.map(e=>({id:e.id,name:e.name,permalink:e.permalink,excerpt:e.short_description||e.description,image_url:e.images&&e.images.length>0?e.images[0].src:null,price_html:e.price_html||`$${e.prices.price}`,average_rating:parseFloat(e.average_rating)||0,rating_count:e.rating_count||0,type:e.type||"simple",external_url:e.external_url||"",button_text:e.button_text||"",sku:e.sku||""}));R({type:"SET_PRODUCTS",payload:t})})}catch(e){R({type:"SET_PRODUCTS",payload:[]})}},[y]),V=(0,i.useCallback)(async()=>{if(b){R({type:"SET_LOADING",payload:!0});try{if(window.PersonalizeWP&&window.PersonalizeWP.getVisitorUID){const e=window.PersonalizeWP.getVisitorUID();if(e){let t=[];switch(b){case"previously-viewed":const o=await window.PersonalizeWP.fetchVisitorActivities(e,{activity_type:"post",object_type:"product"});t=window.PersonalizeWP.getPreviouslyViewedProducts(o,y);break;case"products-for-you":const l=await window.PersonalizeWP.fetchVisitorActivities(e),a=await window.PersonalizeWP.fetchVisitorSegments(e);t=window.PersonalizeWP.getRecommendedProducts(l,a,y)}if(t.length>0){const e=await window.PersonalizeWP.fetchProductDetails(t,b);R({type:"SET_PRODUCTS",payload:e})}else await F()}else await F()}else await F()}catch(e){R({type:"SET_ERROR",payload:e.message}),await F()}}},[b,y,F]),D=(0,i.useMemo)(()=>N.isLoading?[]:N.error||0===N.products.length?z.slice(0,y||6):N.products.slice(0,y||6),[N,y]),$=(0,i.useCallback)(()=>{const e="list"===u?"pwp-layout-list":"pwp-layout-grid";return N.isLoading?(0,l.createElement)(T,{layoutClass:e}):N.error&&0===D.length?(0,l.createElement)(B,{layoutClass:e}):0===D.length?(0,l.createElement)(S,{layoutClass:e}):(0,l.createElement)(M,{products:D,layoutType:u,gridColumns:g,onButtonClick:O})},[u,N,D,g,O]),j=(0,i.useCallback)(e=>{const t=k.find(t=>t.value===e);o({pwpRecipe:e,pwpCollectionTitle:t?t.title:""})},[o]);(0,i.useEffect)(()=>{if(!s){const e=`block-${Date.now()}`;o({queryId:e})}},[s,o]),(0,i.useEffect)(()=>{const e={...p,isProductCollectionBlock:!0,pwpRecipe:b||"default",pwpMaxProducts:y,pwpFallbackBehavior:v,pwpFallbackMessage:C,lastUpdated:Date.now(),perPage:y,inherit:!1,postType:"product"},t=b?`personalizewp-${b}`:"personalizewp-default";o({query:{...e,productCollectionQueryContext:{collection:t,pwpRecipe:b,pwpMaxProducts:y,pwpFallbackBehavior:v}},collection:t})},[b,y,v,C,o]),(0,i.useEffect)(()=>{b&&!E&&L&&o({pwpCollectionTitle:L.title})},[b,E,L,o]),(0,i.useEffect)(()=>{b&&V()},[b,y,V]);const A=(0,c.useBlockProps)({className:`wp-block-personalizewp-pro-product-collection pwp-layout-${u} pwp-columns-${g}`,"data-pwp-recipe":b,"data-layout-type":u,"data-grid-columns":g});return b?(0,l.createElement)("div",{...A},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:L?.icon||m,label:(0,n.__)("Choose Collection","personalizewp"),text:L?.title||(0,n.__)("Choose Collection","personalizewp"),controls:k.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:b===e.value}))})),(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarButton,{icon:w,label:(0,n.__)("Grid View","personalizewp"),onClick:()=>o({layoutType:"grid"}),isActive:"grid"===u}),(0,l.createElement)(r.ToolbarButton,{icon:_,label:(0,n.__)("List View","personalizewp"),onClick:()=>o({layoutType:"list"}),isActive:"list"===u}))),(0,l.createElement)(c.InspectorControls,null,(0,l.createElement)(r.PanelBody,{title:(0,n.__)("Settings","personalizewp"),initialOpen:!0},(0,l.createElement)(f,{currentCollection:b,onCollectionChange:j}),(0,l.createElement)(r.SelectControl,{label:(0,n.__)("Fallback Behavior","personalizewp"),value:v,options:x,onChange:e=>o({pwpFallbackBehavior:e}),help:(0,n.__)("What to show when personalization data is not available","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"show_message"===v&&(0,l.createElement)(r.TextControl,{label:(0,n.__)("Fallback Message","personalizewp"),value:C,onChange:e=>o({pwpFallbackMessage:e}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Max Products","personalizewp"),value:y,min:1,max:20,onChange:e=>o({pwpMaxProducts:e}),help:(0,n.__)("Maximum number of products to display","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)("div",{style:{marginBottom:"16px",marginTop:"24px"}},(0,l.createElement)("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500"}},(0,n.__)("Layout","personalizewp")),(0,l.createElement)(r.ButtonGroup,null,(0,l.createElement)(r.Button,{icon:w,onClick:()=>o({layoutType:"grid"}),isPressed:"grid"===u,variant:"grid"===u?"primary":"secondary"},(0,n.__)("Grid","personalizewp")),(0,l.createElement)(r.Button,{icon:_,onClick:()=>o({layoutType:"list"}),isPressed:"list"===u,variant:"list"===u?"primary":"secondary"},(0,n.__)("List","personalizewp")))),"grid"===u&&(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Columns","personalizewp"),value:g,min:1,max:6,onChange:e=>{o({gridColumns:e,displayLayout:{...d,columns:e}})},help:(0,n.__)("Number of columns in grid layout","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"list"===u&&(0,l.createElement)("div",{style:{marginTop:"16px"}},(0,l.createElement)("p",{style:{margin:0,fontSize:"13px",color:"#757575"}},(0,n.__)("Products will be displayed in a single column list format.","personalizewp"))))),L&&(0,l.createElement)("div",{className:"pwp-collection-title"},(0,l.createElement)(c.RichText,{tagName:"h2",className:"pwp-collection-title__heading",value:E,onChange:e=>o({pwpCollectionTitle:e}),placeholder:L.title,allowedFormats:["core/bold","core/italic"]})),$()):(0,l.createElement)("div",{...A},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:m,label:(0,n.__)("Choose Collection","personalizewp"),text:(0,n.__)("Choose Collection","personalizewp"),controls:k.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:!1}))}))),(0,l.createElement)(f,{currentCollection:null,onCollectionChange:j}))},save:function(e){const{attributes:t}=e,{queryId:o,pwpRecipe:a,pwpMaxProducts:r=8,pwpFallbackBehavior:i="show_all",pwpFallbackMessage:s="Discover our featured products",pwpCollectionTitle:p,layoutType:d="grid",gridColumns:u=3}=t;if(!a)return null;const m=Math.max(1,Math.min(20,parseInt(r,10)||8)),w=o,_=s||(0,n.__)("Discover our featured products","personalizewp"),g=c.useBlockProps.save({className:"pwp-product-collection-block","data-recipe":a,"data-max-products":m,"data-fallback-behavior":i,"data-fallback-message":_,"data-block-id":w});return(0,l.createElement)("div",{...g},(0,l.createElement)("pwp-product-collection",{recipe:a,"max-products":m,"fallback-behavior":i,"fallback-message":_,"layout-type":d,"grid-columns":u,"block-id":w,"collection-title":p||""},(0,l.createElement)("div",{className:"woocommerce"},(0,l.createElement)("div",{className:"woocommerce-info"},(0,l.createElement)("span",{className:"pwp-loading-spinner"}),(0,n.__)("Loading personalized products...","personalizewp")))))}})},609:e=>{e.exports=window.React},848:(e,t,o)=>{e.exports=o(20)}},o={};function l(e){var a=o[e];if(void 0!==a)return a.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,l),n.exports}l.m=t,e=[],l.O=(t,o,a,n)=>{if(!o){var c=1/0;for(p=0;p<e.length;p++){for(var[o,a,n]=e[p],r=!0,i=0;i<o.length;i++)(!1&n||c>=n)&&Object.keys(l.O).every(e=>l.O[e](o[i]))?o.splice(i--,1):(r=!1,n<c&&(c=n));if(r){e.splice(p--,1);var s=a();void 0!==s&&(t=s)}}return t}n=n||0;for(var p=e.length;p>0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[o,a,n]},l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var o in t)l.o(t,o)&&!l.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={488:0,272:0};l.O.j=t=>0===e[t];var t=(t,o)=>{var a,n,[c,r,i]=o,s=0;if(c.some(t=>0!==e[t])){for(a in r)l.o(r,a)&&(l.m[a]=r[a]);if(i)var p=i(l)}for(t&&t(o);s<c.length;s++)n=c[s],l.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return l.O(p)},o=globalThis.webpackChunkpersonalizewp=globalThis.webpackChunkpersonalizewp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var a=l.O(void 0,[272],()=>l(539));a=l.O(a)})();1 (()=>{"use strict";var e,t={20:(e,t,o)=>{var l=o(609),a=Symbol.for("react.element"),n=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,o){var l,i={},s=null,p=null;for(l in void 0!==o&&(s=""+o),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(p=t.ref),t)n.call(t,l)&&!r.hasOwnProperty(l)&&(i[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===i[l]&&(i[l]=t[l]);return{$$typeof:a,type:e,key:s,ref:p,props:i,_owner:c.current}}},539:(e,t,o)=>{var l=o(609);const a=window.wp.blocks,n=window.wp.i18n,c=window.wp.blockEditor,r=window.wp.components,i=window.wp.element,s=window.wp.primitives;var p=o(848);const d=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})}),u=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})}),m=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{fillRule:"evenodd",d:"M19.75 11H21V8.667L19.875 4H4.125L3 8.667V11h1.25v8.75h15.5V11zm-1.5 0H5.75v7.25H10V13h4v5.25h4.25V11zm-5.5-5.5h2.067l.486 3.24.028.76H12.75v-4zm-3.567 0h2.067v4H8.669l.028-.76.486-3.24zm7.615 3.1l-.464-3.1h2.36l.806 3.345V9.5h-2.668l-.034-.9zM7.666 5.5h-2.36L4.5 8.845V9.5h2.668l.034-.9.464-3.1z",clipRule:"evenodd"})}),w=(0,p.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,p.jsx)(s.Path,{d:"m3 5c0-1.10457.89543-2 2-2h13.5c1.1046 0 2 .89543 2 2v13.5c0 1.1046-.8954 2-2 2h-13.5c-1.10457 0-2-.8954-2-2zm2-.5h6v6.5h-6.5v-6c0-.27614.22386-.5.5-.5zm-.5 8v6c0 .2761.22386.5.5.5h6v-6.5zm8 0v6.5h6c.2761 0 .5-.2239.5-.5v-6zm0-8v6.5h6.5v-6c0-.27614-.2239-.5-.5-.5z",fillRule:"evenodd",clipRule:"evenodd"})}),_=(0,p.jsx)(s.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,p.jsx)(s.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})}),g=window.wp.apiFetch;var h=o.n(g);const b=[{name:"previously-viewed",title:(0,n.__)("Previously Viewed Products","personalizewp"),icon:d,description:(0,n.__)("Display products that visitors have recently browsed on your store","personalizewp"),details:(0,n.__)('Creates a "Recently Viewed" section showing products the current visitor has looked at before. Perfect for helping customers continue their shopping journey.',"personalizewp"),keywords:["viewed","history","recent"],color:"#7c3aed",gradient:"linear-gradient(135deg, #7c3aed 0%, #a855f7 100%)"},{name:"products-for-you",title:(0,n.__)("Products For You","personalizewp"),icon:u,description:(0,n.__)("Personalized product recommendations based on visitor segments and behavior","personalizewp"),details:(0,n.__)("Shows tailored product recommendations using PersonalizeWP's visitor segments and behavioral data. Displays products from relevant categories and frequently bought together items.","personalizewp"),keywords:["recommended","personalized","segments"],color:"#059669",gradient:"linear-gradient(135deg, #059669 0%, #10b981 100%)"}];function v({collection:e,onSelect:t,isSelected:o=!1}){const a=(0,i.useCallback)(()=>{t(e.name)},[e.name,t]),n=(0,i.useMemo)(()=>({"--collection-color":e.color,"--collection-gradient":e.gradient}),[e.color,e.gradient]);return(0,l.createElement)(r.Tooltip,{text:e.details,placement:"top"},(0,l.createElement)("button",{type:"button",className:"components-button wc-blocks-product-collection__collection-button "+(o?"is-selected":""),onClick:a,style:n,"aria-pressed":o,"aria-describedby":`collection-${e.name}-description`},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collection-button-icon"},(0,l.createElement)(r.Icon,{icon:e.icon,size:24})),(0,l.createElement)("p",{className:"wc-blocks-product-collection__collection-button-title",id:`collection-${e.name}-description`},e.title)))}function y({isOpen:e,onClose:t,onSelect:o,currentCollection:a}){const[c,s]=(0,i.useState)(a),p=(0,i.useCallback)(()=>{c&&(o(c),t())},[c,o,t]),d=(0,i.useCallback)(e=>{s(e)},[]),u=Boolean(c);return(0,l.createElement)(r.Modal,{className:"wc-blocks-product-collection__modal pwp-collection-picker-modal",onRequestClose:t,size:"large",shouldCloseOnClickOutside:!1,title:(0,n.__)("What products do you want to show?","personalizewp")},(0,l.createElement)("div",{className:"wc-blocks-product-collection__content"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-grid"},(0,l.createElement)("div",{className:"wc-blocks-product-collection__collections-section"},b.map(e=>(0,l.createElement)(v,{key:e.name,collection:e,onSelect:d,isSelected:c===e.name})))),(0,l.createElement)(r.Flex,{className:"wc-blocks-product-collection__footer",justify:"flex-end",gap:3},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",onClick:t},(0,n.__)("Cancel","personalizewp"))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"primary",onClick:p,disabled:!u},(0,n.__)("Continue","personalizewp"))))))}function C({onOpenModal:e}){return(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder"},(0,l.createElement)(r.Card,null,(0,l.createElement)(r.CardBody,null,(0,l.createElement)("div",{className:"pwp-collection-picker-placeholder__content"},(0,l.createElement)("h3",{className:"pwp-collection-picker-placeholder__title"},(0,n.__)("PersonalizeWP Product Collection","personalizewp")),(0,l.createElement)("p",{className:"pwp-collection-picker-placeholder__description"},(0,n.__)("Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.","personalizewp")),(0,l.createElement)(r.Button,{variant:"primary",onClick:e,className:"pwp-collection-picker-placeholder__button"},(0,n.__)("Choose Recipe","personalizewp"))))))}function E({collection:e,onChangeCollection:t}){const o=(0,i.useMemo)(()=>b.find(t=>t.name===e),[e]);return o?(0,l.createElement)(r.Card,{className:"pwp-selected-collection"},(0,l.createElement)(r.CardBody,null,(0,l.createElement)(r.Flex,{direction:"column",gap:2},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Flex,{justify:"space-between",align:"center"},(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("h4",{className:"pwp-selected-collection__title"},o.title)),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)(r.Button,{variant:"tertiary",size:"small",onClick:t,className:"pwp-selected-collection__change-button"},(0,n.__)("Change","personalizewp"))))),(0,l.createElement)(r.FlexItem,null,(0,l.createElement)("p",{className:"pwp-selected-collection__description"},o.description))))):null}function k({currentCollection:e,onCollectionChange:t}){const[o,a]=(0,i.useState)(!1),n=(0,i.useCallback)(()=>{a(!0)},[]),c=(0,i.useCallback)(()=>{a(!1)},[]),r=(0,i.useCallback)(e=>{t(e),c()},[t,c]);return(0,l.createElement)(l.Fragment,null,e?(0,l.createElement)(E,{collection:e,onChangeCollection:n}):(0,l.createElement)(C,{onOpenModal:n}),o&&(0,l.createElement)(y,{isOpen:o,onClose:c,onSelect:r,currentCollection:e}))}const f=[{title:(0,n.__)("Previously Viewed Products","personalizewp"),value:"previously-viewed",icon:d,info:(0,n.__)("Display products that the current visitor has recently browsed on your store.","personalizewp")},{title:(0,n.__)("Products For You","personalizewp"),value:"products-for-you",icon:u,info:(0,n.__)("Show personalized product recommendations based on visitor segments, categories, and related products.","personalizewp")}],x=[{label:(0,n.__)("Show All Products","personalizewp"),value:"show_all"},{label:(0,n.__)("Hide Block","personalizewp"),value:"hide_block"},{label:(0,n.__)("Show Custom Message","personalizewp"),value:"show_message"}],z=[{id:1,name:"Sample Product",price_html:"$19.99",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"simple",average_rating:4.5,permalink:"#"},{id:2,name:"Variable Product",price_html:"$20.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"variable",average_rating:4,permalink:"#"},{id:3,name:"External Product",price_html:"$15.00",image_url:"/wp-content/uploads/woocommerce-placeholder-300x300.png",type:"external",button_text:"Buy on external store!",average_rating:5,external_url:"#",permalink:"#"}],P=(e,t)=>{switch(t.type){case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_PRODUCTS":return{...e,products:t.payload,isLoading:!1,error:null};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"RESET":return{products:[],isLoading:!1,error:null};default:return e}},N=({product:e,layoutType:t,index:o,totalProducts:a,onButtonClick:c})=>{const r=function(e){return(0,i.useMemo)(()=>{let t=(0,n.__)("Add to cart","personalizewp"),o="add_to_cart_button ajax_add_to_cart",l="product-type-simple",a=!1;return"external"===e.type?(t=e.button_text||(0,n.__)("Buy product","personalizewp"),o="product_type_external",l="product-type-external",a=!0):"variable"===e.type&&(t=(0,n.__)("Select options","personalizewp"),o="product_type_variable",l="product-type-variable"),{text:t,className:o,typeClass:l,isExternal:a}},[e.type,e.button_text])}(e),s=e.price_html&&e.price_html.includes("<del"),p=function(e,t,o,l,a){return(0,i.useMemo)(()=>["wc-block-product",`post-${e.id}`,"product","type-product","status-publish",e.image_url?"has-post-thumbnail":"","instock","shipping-taxable","purchasable",t.typeClass,"list"===o?"pwp-list-item":"",0===l?"first":"",l===a-1?"last":""].filter(Boolean).join(" "),[e,t.typeClass,o,l,a])}(e,r,t,o,a),d=e.image_url||"/wp-content/uploads/woocommerce-placeholder-300x300.png";return(0,l.createElement)("li",{className:p},(0,l.createElement)("div",{className:"wc-block-components-product-image wc-block-grid__product-image wp-block-woocommerce-product-image"},(0,l.createElement)("a",{href:"#",onClick:c},s&&(0,l.createElement)("div",{className:"wc-block-components-product-sale-badge wc-block-components-product-sale-badge--align-right wc-block-grid__product-onsale"},(0,l.createElement)("span",{"aria-hidden":"true"},(0,n.__)("Sale","personalizewp")),(0,l.createElement)("span",{className:"screen-reader-text"},(0,n.__)("Product on sale","personalizewp"))),(0,l.createElement)("img",{decoding:"async",width:"300",height:"300",src:d,alt:e.name,className:"attachment-woocommerce_thumbnail size-woocommerce_thumbnail",style:{maxWidth:"none",objectFit:"cover"}}))),(0,l.createElement)("h3",{style:{marginBottom:"0.75rem",marginTop:0},className:"has-text-align-center wp-block-post-title has-medium-font-size"},(0,l.createElement)("a",{href:"#",onClick:c,target:"_self"},e.name)),e.average_rating>0&&(0,l.createElement)("div",{className:"wc-block-components-product-rating"},(0,l.createElement)("div",{className:"wc-block-components-product-rating__stars","aria-label":`${e.average_rating} out of 5 stars`},"★".repeat(Math.floor(e.average_rating)),"☆".repeat(5-Math.floor(e.average_rating)))),(0,l.createElement)("div",{className:"wp-block-woocommerce-product-price"},(0,l.createElement)("div",{className:"wc-block-components-product-price wc-block-grid__product-price has-text-align-center has-font-size has-small-font-size"},(0,l.createElement)("span",{dangerouslySetInnerHTML:{__html:e.price_html}}))),(0,l.createElement)("div",{className:"wp-block-button wc-block-components-product-button align-center wp-block-woocommerce-product-button has-small-font-size"},r.isExternal?(0,l.createElement)("a",{href:"#",className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow noopener",target:"_blank"},(0,l.createElement)("span",null,r.text)):(0,l.createElement)("button",{className:`wp-block-button__link wp-element-button wc-block-components-product-button__button ${r.className} ${r.typeClass.replace("-","_")} has-font-size has-small-font-size has-text-align-center wc-interactive`,onClick:c,rel:"nofollow"},(0,l.createElement)("span",null,r.text))))};function T({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("div",{className:"pwp-loading-spinner",style:{display:"inline-block",width:"20px",height:"20px",border:"2px solid #ddd",borderTop:"2px solid #874FB9",borderRadius:"50%",animation:"spin 1s linear infinite",marginRight:"8px"}}),(0,n.__)("Loading personalized products...","personalizewp")))}function B({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("Unable to load products. Using fallback display.","personalizewp"))))}function S({layoutClass:e}){return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${e}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("div",{style:{textAlign:"center",padding:"2rem",color:"#666"}},(0,l.createElement)("p",null,(0,n.__)("No products found for this personalization recipe.","personalizewp")),(0,l.createElement)("p",null,(0,l.createElement)("small",null,(0,n.__)("Try viewing some products on your site first.","personalizewp")))))}function M({products:e,layoutType:t,gridColumns:o,onButtonClick:a}){const n="list"===t?"pwp-layout-list":"pwp-layout-grid",c="grid"===t?`columns-${o}`:"columns-1";return(0,l.createElement)("div",{className:`wp-block-woocommerce-product-collection is-layout-flow wp-block-product-collection-is-layout-flow ${n}`},(0,l.createElement)("div",{className:"wc-block-components-notices alignwide"}),(0,l.createElement)("ul",{className:`${c} wc-block-product-template__responsive wc-block-product-template wp-block-woocommerce-product-template`},e.map((o,n)=>(0,l.createElement)(N,{key:o.id,product:o,layoutType:t,index:n,totalProducts:e.length,onButtonClick:a}))))}const R=JSON.parse('{"UU":"personalizewp-pro/product-collection"}'),L={src:(0,l.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,l.createElement)("path",{fill:"#e1236c",d:"M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z"}))};(0,a.registerBlockType)(R.UU,{icon:L,edit:function(e){const{attributes:t,setAttributes:o,clientId:a}=e,{queryId:s,query:p={},displayLayout:d={type:"flex",columns:3},layoutType:u="grid",gridColumns:g=3,pwpRecipe:b,pwpFallbackBehavior:v="show_all",pwpMaxProducts:y=8,pwpFallbackMessage:C="",pwpCollectionTitle:E=""}=t,[N,R]=(0,i.useReducer)(P,{products:[],isLoading:!1,error:null}),L=(0,i.useMemo)(()=>f.find(e=>e.value===b),[b]),O=(0,i.useCallback)(e=>{e.preventDefault()},[]),F=(0,i.useCallback)(async()=>{try{h()({path:`/wc/store/v1/products?per_page=${y||6}&orderby=date&order=desc`}).then(e=>{const t=e.map(e=>({id:e.id,name:e.name,permalink:e.permalink,excerpt:e.short_description||e.description,image_url:e.images&&e.images.length>0?e.images[0].src:null,price_html:e.price_html||`$${e.prices.price}`,average_rating:parseFloat(e.average_rating)||0,rating_count:e.rating_count||0,type:e.type||"simple",external_url:e.external_url||"",button_text:e.button_text||"",sku:e.sku||""}));R({type:"SET_PRODUCTS",payload:t})})}catch(e){R({type:"SET_PRODUCTS",payload:[]})}},[y]),V=(0,i.useCallback)(async()=>{if(b){R({type:"SET_LOADING",payload:!0});try{if(window.PersonalizeWP&&window.PersonalizeWP.getVisitorUID){const e=window.PersonalizeWP.getVisitorUID();if(e){let t=[];switch(b){case"previously-viewed":const o=await window.PersonalizeWP.fetchVisitorActivities(e,{activity_type:"post",object_type:"product"});t=window.PersonalizeWP.getPreviouslyViewedProducts(o,y);break;case"products-for-you":const l=await window.PersonalizeWP.fetchVisitorActivities(e),a=await window.PersonalizeWP.fetchVisitorSegments(e);t=window.PersonalizeWP.getRecommendedProducts(l,a,y)}if(t.length>0){const e=await window.PersonalizeWP.fetchProductDetails(t,b);R({type:"SET_PRODUCTS",payload:e})}else await F()}else await F()}else await F()}catch(e){R({type:"SET_ERROR",payload:e.message}),await F()}}},[b,y,F]),$=(0,i.useMemo)(()=>N.isLoading?[]:N.error||0===N.products.length?z.slice(0,y||6):N.products.slice(0,y||6),[N,y]),D=(0,i.useCallback)(()=>{const e="list"===u?"pwp-layout-list":"pwp-layout-grid";return N.isLoading?(0,l.createElement)(T,{layoutClass:e}):N.error&&0===$.length?(0,l.createElement)(B,{layoutClass:e}):0===$.length?(0,l.createElement)(S,{layoutClass:e}):(0,l.createElement)(M,{products:$,layoutType:u,gridColumns:g,onButtonClick:O})},[u,N,$,g,O]),j=(0,i.useCallback)(e=>{const t=f.find(t=>t.value===e);o({pwpRecipe:e,pwpCollectionTitle:t?t.title:""})},[o]);(0,i.useEffect)(()=>{if(!s){const e=`block-${Date.now()}`;o({queryId:e})}},[s,o]),(0,i.useEffect)(()=>{const e={...p,isProductCollectionBlock:!0,pwpRecipe:b||"default",pwpMaxProducts:y,pwpFallbackBehavior:v,pwpFallbackMessage:C,lastUpdated:Date.now(),perPage:y,inherit:!1,postType:"product"},t=b?`personalizewp-${b}`:"personalizewp-default";o({query:{...e,productCollectionQueryContext:{collection:t,pwpRecipe:b,pwpMaxProducts:y,pwpFallbackBehavior:v}},collection:t})},[b,y,v,C,o]),(0,i.useEffect)(()=>{b&&!E&&L&&o({pwpCollectionTitle:L.title})},[b,E,L,o]),(0,i.useEffect)(()=>{b&&V()},[b,y,V]);const I=(0,c.useBlockProps)({className:`wp-block-personalizewp-pro-product-collection pwp-layout-${u} pwp-columns-${g}`,"data-pwp-recipe":b,"data-layout-type":u,"data-grid-columns":g});return b?(0,l.createElement)("div",{...I},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:L?.icon||m,label:(0,n.__)("Choose Collection","personalizewp"),text:L?.title||(0,n.__)("Choose Collection","personalizewp"),controls:f.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:b===e.value}))})),(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarButton,{icon:w,label:(0,n.__)("Grid View","personalizewp"),onClick:()=>o({layoutType:"grid"}),isActive:"grid"===u}),(0,l.createElement)(r.ToolbarButton,{icon:_,label:(0,n.__)("List View","personalizewp"),onClick:()=>o({layoutType:"list"}),isActive:"list"===u}))),(0,l.createElement)(c.InspectorControls,null,(0,l.createElement)(r.PanelBody,{title:(0,n.__)("Settings","personalizewp"),initialOpen:!0},(0,l.createElement)(k,{currentCollection:b,onCollectionChange:j}),(0,l.createElement)(r.SelectControl,{label:(0,n.__)("Fallback Behavior","personalizewp"),value:v,options:x,onChange:e=>o({pwpFallbackBehavior:e}),help:(0,n.__)("What to show when personalization data is not available","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"show_message"===v&&(0,l.createElement)(r.TextControl,{label:(0,n.__)("Fallback Message","personalizewp"),value:C,onChange:e=>o({pwpFallbackMessage:e}),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Max Products","personalizewp"),value:y,min:1,max:20,onChange:e=>o({pwpMaxProducts:e}),help:(0,n.__)("Maximum number of products to display","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,l.createElement)("div",{style:{marginBottom:"16px",marginTop:"24px"}},(0,l.createElement)("label",{style:{display:"block",marginBottom:"8px",fontWeight:"500"}},(0,n.__)("Layout","personalizewp")),(0,l.createElement)(r.ButtonGroup,null,(0,l.createElement)(r.Button,{icon:w,onClick:()=>o({layoutType:"grid"}),isPressed:"grid"===u,variant:"grid"===u?"primary":"secondary"},(0,n.__)("Grid","personalizewp")),(0,l.createElement)(r.Button,{icon:_,onClick:()=>o({layoutType:"list"}),isPressed:"list"===u,variant:"list"===u?"primary":"secondary"},(0,n.__)("List","personalizewp")))),"grid"===u&&(0,l.createElement)(r.RangeControl,{label:(0,n.__)("Columns","personalizewp"),value:g,min:1,max:6,onChange:e=>{o({gridColumns:e,displayLayout:{...d,columns:e}})},help:(0,n.__)("Number of columns in grid layout","personalizewp"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),"list"===u&&(0,l.createElement)("div",{style:{marginTop:"16px"}},(0,l.createElement)("p",{style:{margin:0,fontSize:"13px",color:"#757575"}},(0,n.__)("Products will be displayed in a single column list format.","personalizewp"))))),L&&(0,l.createElement)("div",{className:"pwp-collection-title"},(0,l.createElement)(c.RichText,{tagName:"h2",className:"pwp-collection-title__heading",value:E,onChange:e=>o({pwpCollectionTitle:e}),placeholder:L.title,allowedFormats:["core/bold","core/italic"]})),D()):(0,l.createElement)("div",{...I},(0,l.createElement)(c.BlockControls,null,(0,l.createElement)(r.ToolbarGroup,null,(0,l.createElement)(r.ToolbarDropdownMenu,{icon:m,label:(0,n.__)("Choose Collection","personalizewp"),text:(0,n.__)("Choose Collection","personalizewp"),controls:f.map(e=>({title:e.title,icon:e.icon,onClick:()=>j(e.value),isActive:!1}))}))),(0,l.createElement)(k,{currentCollection:null,onCollectionChange:j}))},save:function(e){const{attributes:t}=e,{queryId:o,pwpRecipe:a,pwpMaxProducts:r=8,pwpFallbackBehavior:i="show_all",pwpFallbackMessage:s="Discover our featured products",pwpCollectionTitle:p,layoutType:d="grid",gridColumns:u=3}=t;if(!a)return null;const m=Math.max(1,Math.min(20,parseInt(r,10)||8)),w=o,_=s||(0,n.__)("Discover our featured products","personalizewp"),g=c.useBlockProps.save({className:"pwp-product-collection-block","data-recipe":a,"data-max-products":m,"data-fallback-behavior":i,"data-fallback-message":_,"data-block-id":w});return(0,l.createElement)("div",{...g},(0,l.createElement)("pwp-product-collection",{recipe:a,"max-products":m,"fallback-behavior":i,"fallback-message":_,"layout-type":d,"grid-columns":u,"block-id":w,"collection-title":p||""},(0,l.createElement)("div",{className:"woocommerce"},(0,l.createElement)("div",{className:"woocommerce-info"},(0,l.createElement)("span",{className:"pwp-loading-spinner"}),(0,n.__)("Loading personalized products...","personalizewp")))))}})},609:e=>{e.exports=window.React},848:(e,t,o)=>{e.exports=o(20)}},o={};function l(e){var a=o[e];if(void 0!==a)return a.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,l),n.exports}l.m=t,e=[],l.O=(t,o,a,n)=>{if(!o){var c=1/0;for(p=0;p<e.length;p++){for(var[o,a,n]=e[p],r=!0,i=0;i<o.length;i++)(!1&n||c>=n)&&Object.keys(l.O).every(e=>l.O[e](o[i]))?o.splice(i--,1):(r=!1,n<c&&(c=n));if(r){e.splice(p--,1);var s=a();void 0!==s&&(t=s)}}return t}n=n||0;for(var p=e.length;p>0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[o,a,n]},l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var o in t)l.o(t,o)&&!l.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={488:0,272:0};l.O.j=t=>0===e[t];var t=(t,o)=>{var a,n,[c,r,i]=o,s=0;if(c.some(t=>0!==e[t])){for(a in r)l.o(r,a)&&(l.m[a]=r[a]);if(i)var p=i(l)}for(t&&t(o);s<c.length;s++)n=c[s],l.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return l.O(p)},o=globalThis.webpackChunkpersonalizewp=globalThis.webpackChunkpersonalizewp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var a=l.O(void 0,[272],()=>l(539));a=l.O(a)})(); -
personalizewp/trunk/build/blocks/variation-fallback/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation-fallback", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Default Content", 7 "category": " design",7 "category": "personalizewp", 8 8 "description": "The fallback content that is displayed when no variation conditions are matched.", 9 9 "parent": [ -
personalizewp/trunk/build/blocks/variation/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variation", 7 "category": " design",7 "category": "personalizewp", 8 8 "icon": "block-default", 9 9 "description": "A group of one or more blocks that displays different content to the fallback.", -
personalizewp/trunk/build/blocks/variations-block/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variations-block", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variations", 7 "category": "design", 7 "category": "personalizewp", 8 "keywords": [ 9 "PersonalizeWP", 10 "pwp", 11 "personalization", 12 "variation" 13 ], 8 14 "icon": "block-default", 9 15 "description": "Show different variations of your content to specific users depending on which conditions they match, with a fallback for everyone else.", -
personalizewp/trunk/build/blocks/variations-block/index.asset.php
r3380017 r3382403 1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => ' 0cf06715dca7eef73b4b');1 <?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '66383005d3040fbb23a6'); -
personalizewp/trunk/build/blocks/variations-block/index.js
r3380017 r3382403 1 (()=>{"use strict";const e=window.React,t=window.wp.blocks,n=window.wp.i18n,o=window.wp.hooks,a=["personalizewp-pro/variations-block","personalizewp-pro/variation-fallback","personalizewp-pro/variation"];(0,o.addFilter)("personalizewp.hasPersonalizeControls","personalizewp/indicate-variation-blocks",function(e,t){return"personalizewp-pro/variations-block"===t.name||e}),(0,o.addFilter)("personalizeWP.globallyRestrictedBlockTypes","personalizewp/restrict-variation-blocks",function(e){return[...e,...a]}),(0,o.addFilter)("blocks.registerBlockType","personalizewp/register-variations-context",function(e,t){return a.includes(t)||(e={...e,usesContext:[...e.usesContext,"personalizewp/isVariationContent"]}),e},100),(0,o.addFilter)("personalizeWP.preRenderControls","personalizewp/restrict-personalize-controls-showing",function(e,t){return!t.context["personalizewp/isVariationContent"]&&e});const r=window.wp.blockEditor, l=window.wp.components,i=window.wp.data,s=window.wp.element,c=[["personalizewp-pro/variation",{metadata:{name:(0,n.__)("Variation 1","personalizewp")}},[["core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")}]]],["personalizewp-pro/variation-fallback",{metadata:{name:(0,n.__)("Fallback","personalizewp")},supports:{lock:!1},lock:{move:!0,remove:!0},inserter:!1,multiple:!0,html:!1,renaming:!1},[["core/paragraph",{placeholder:(0,n.__)("Add fallback content here","personalizewp")}]]]],p=JSON.parse('{"UU":"personalizewp-pro/variations-block"}'),d={src:(0,e.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("path",{fill:"url(#paint0_linear_311_20854)",d:"M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"}),(0,e.createElement)("defs",null,(0,e.createElement)("linearGradient",{id:"paint0_linear_311_20854"},(0,e.createElement)("stop",{offset:".16",stopColor:"#C127A0"}),(0,e.createElement)("stop",{offset:".28",stopColor:"#CD20A1"}),(0,e.createElement)("stop",{offset:".59",stopColor:"#E813A4"}),(0,e.createElement)("stop",{offset:".76",stopColor:"#F20FA6"}))))};(0,t.registerBlockType)(p.UU,{icon:d,edit:function(o){const{attributes:a,setAttributes:p,clientId:d,isSelected:w}=o,{variationsBlockId:u}=a,{innerVariationBlocks:k,selectedVariationClientId:m}=(0,i.useSelect)(e=>{const{getBlocks:t,getSelectedBlockClientId:n,hasSelectedInnerBlock:o}=e(r.store),a=t(d),l=n();let i=null;for(const e of a)if(e.clientId===l||o(e.clientId,!0)){i=e.clientId;break}return{innerVariationBlocks:a,selectedVariationClientId:i}},[d]),{__unstableMarkNextChangeAsNotPersistent:f,updateBlockAttributes:v,insertBlock:b,selectBlock:h}=(0,i.useDispatch)(r.store),z=(0,s.useCallback)(e=>{k.forEach(t=>{f(),v(t.clientId,{isActive:t.clientId===e})})},[k,v,f]);(0,s.useEffect)(()=>{u&&""!==u||p({variationsBlockId:d}),k?.length&&z(k[k.length-1].clientId)},[]),(0,s.useEffect)(()=>{const e=k&&k.some(e=>e.attributes.isActive);m?z(m):!e&&k?.length&&z(k[k.length-1].clientId)},[k,m,z]),(0,s.useEffect)(()=>{null!==u&&""!==u||p({variationsBlockId:d})},[d,w]);const g=(0,r.useBlockProps)(),B=(0,r.useInnerBlocksProps)(g,{template:c,renderAppender:!1});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.BlockControls,{group:"block"},(0,e.createElement)(l.Toolbar,{label:(0,n.__)("Variations","personalizewp")},(0,e.createElement)(l.ToolbarGroup,null,k.map(({clientId:t,attributes:n})=>{const{metadata:o,isActive:a}=n;return(0,e.createElement)(l.ToolbarButton,{key:t,label:o.name,isActive:a,onClick:()=>z(t)},o.name)}),(0,e.createElement)(l.ToolbarButton,{icon:"plus",label:(0,n.__)("New Variation","personalizewp"),onClick:()=>(()=>{const e=k.length,o=(0,t.createBlock)("personalizewp-pro/variation",{metadata:{name:(0,n.sprintf)(1 (()=>{"use strict";const e=window.React,t=window.wp.blocks,n=window.wp.i18n,o=window.wp.hooks,a=["personalizewp-pro/variations-block","personalizewp-pro/variation-fallback","personalizewp-pro/variation"];(0,o.addFilter)("personalizewp.hasPersonalizeControls","personalizewp/indicate-variation-blocks",function(e,t){return"personalizewp-pro/variations-block"===t.name||e}),(0,o.addFilter)("personalizeWP.globallyRestrictedBlockTypes","personalizewp/restrict-variation-blocks",function(e){return[...e,...a]}),(0,o.addFilter)("blocks.registerBlockType","personalizewp/register-variations-context",function(e,t){return a.includes(t)||(e={...e,usesContext:[...e.usesContext,"personalizewp/isVariationContent"]}),e},100),(0,o.addFilter)("personalizeWP.preRenderControls","personalizewp/restrict-personalize-controls-showing",function(e,t){return!t.context["personalizewp/isVariationContent"]&&e});const r=window.wp.blockEditor,i=window.wp.components,l=window.wp.data,s=window.wp.element,c=[["personalizewp-pro/variation",{metadata:{name:(0,n.__)("Variation 1","personalizewp")}},[["core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")}]]],["personalizewp-pro/variation-fallback",{metadata:{name:(0,n.__)("Fallback","personalizewp")},supports:{lock:!1},lock:{move:!0,remove:!0},inserter:!1,multiple:!0,html:!1,renaming:!1},[["core/paragraph",{placeholder:(0,n.__)("Add fallback content here","personalizewp")}]]]],p=JSON.parse('{"UU":"personalizewp-pro/variations-block"}'),d={src:(0,e.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,e.createElement)("path",{fill:"#e1236c",d:"M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z"}))};(0,t.registerBlockType)(p.UU,{icon:d,edit:function(o){const{attributes:a,setAttributes:p,clientId:d,isSelected:w}=o,{variationsBlockId:u}=a,{innerVariationBlocks:k,selectedVariationClientId:m}=(0,l.useSelect)(e=>{const{getBlocks:t,getSelectedBlockClientId:n,hasSelectedInnerBlock:o}=e(r.store),a=t(d),i=n();let l=null;for(const e of a)if(e.clientId===i||o(e.clientId,!0)){l=e.clientId;break}return{innerVariationBlocks:a,selectedVariationClientId:l}},[d]),{__unstableMarkNextChangeAsNotPersistent:v,updateBlockAttributes:b,insertBlock:h,selectBlock:z}=(0,l.useDispatch)(r.store),g=(0,s.useCallback)(e=>{k.forEach(t=>{v(),b(t.clientId,{isActive:t.clientId===e})})},[k,b,v]);(0,s.useEffect)(()=>{u&&""!==u||p({variationsBlockId:d}),k?.length&&g(k[k.length-1].clientId)},[]),(0,s.useEffect)(()=>{const e=k&&k.some(e=>e.attributes.isActive);m?g(m):!e&&k?.length&&g(k[k.length-1].clientId)},[k,m,g]),(0,s.useEffect)(()=>{null!==u&&""!==u||p({variationsBlockId:d})},[d,w]);const B=(0,r.useBlockProps)(),f=(0,r.useInnerBlocksProps)(B,{template:c,renderAppender:!1});return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(r.BlockControls,{group:"block"},(0,e.createElement)(i.Toolbar,{label:(0,n.__)("Variations","personalizewp")},(0,e.createElement)(i.ToolbarGroup,null,k.map(({clientId:t,attributes:n})=>{const{metadata:o,isActive:a}=n;return(0,e.createElement)(i.ToolbarButton,{key:t,label:o.name,isActive:a,onClick:()=>g(t)},o.name)}),(0,e.createElement)(i.ToolbarButton,{icon:"plus",label:(0,n.__)("New Variation","personalizewp"),onClick:()=>(()=>{const e=k.length,o=(0,t.createBlock)("personalizewp-pro/variation",{metadata:{name:(0,n.sprintf)( 2 2 // Translators: %d: Variation number being added. 3 3 // Translators: %d: Variation number being added. 4 (0,n.__)("Variation %d","personalizewp"),e)}},[(0,t.createBlock)("core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")})]); b(o,k.length-1,d),h(o.clientId)})()})))),(0,e.createElement)("div",{...B}))},save:function(t){const n=r.useBlockProps.save(),{className:o,...a}=r.useInnerBlocksProps.save(n);return(0,e.createElement)("pwp-content-variations",{...a})}})})();4 (0,n.__)("Variation %d","personalizewp"),e)}},[(0,t.createBlock)("core/paragraph",{placeholder:(0,n.__)("Add variation content here","personalizewp")})]);h(o,k.length-1,d),z(o.clientId)})()})))),(0,e.createElement)("div",{...f}))},save:function(t){const n=r.useBlockProps.save(),{className:o,...a}=r.useInnerBlocksProps.save(n);return(0,e.createElement)("pwp-content-variations",{...a})}})})(); -
personalizewp/trunk/includes/class-api.php
r3380017 r3382403 122 122 // Requests from file:// and data: URLs send "Origin: null". 123 123 if ( 'null' !== $origin ) { 124 $origin = sanitize_url( $origin );124 $origin = $this->sanitize_origin_url( $origin ); 125 125 } 126 126 … … 212 212 protected function is_allowed_origin( $origin ): bool { 213 213 214 $home_url = set_url_scheme( home_url(), 'https' ); // Always assume https215 $allowed_origins = [ $home_url ]; 214 $home_url = set_url_scheme( $this->sanitize_origin_url( home_url() ), 'https' ); // Always assume https 215 $allowed_origins = [ $home_url ]; // Ensures ssl is there, in case the default is non-ssl. 216 216 217 217 // Automatically filter the origins to add any URLs from auth tokens UI. 218 $url_tokens = get_option( $this->auth_tokens, []);218 $url_tokens = $this->get_all_api_auth_tokens(); 219 219 if ( ! empty( $url_tokens ) ) { 220 220 $allowed_origins = array_merge( array_keys( $url_tokens ) ); … … 296 296 */ 297 297 public function populate_default_auth_token(): void { 298 $all_tokens = get_option( $this->auth_tokens, [] ); 299 300 if ( empty( $all_tokens ) ) { 298 $all_tokens = $this->get_all_api_auth_tokens(); 299 300 $force_gen = false; 301 $home_url = untrailingslashit( home_url() ); 302 $root_url = $this->sanitize_origin_url( $home_url ); 303 304 // Check for sub-directory created URL token that won't match an origin. 305 if ( $home_url !== $root_url && isset( $all_tokens[ $home_url ] ) ) { 306 // Migrate default root URL by clearing the existing token. 307 $this->delete_api_auth_token( $home_url ); 308 // Force a regen of the home url. 309 $force_gen = true; 310 } 311 312 if ( empty( $all_tokens ) || $force_gen ) { 301 313 // Use home URL, but upgrade to https to ensure single entry to check 302 314 $root_url = set_url_scheme( home_url(), 'https' ); … … 340 352 public function generate_api_auth_token( $url, $store = false ): string { 341 353 342 // Remove any potential trailing slash to match incoming browser origin. 343 $url = untrailingslashit( $url ); 344 354 $url = $this->sanitize_origin_url( $url ); 345 355 $token = base64_encode( hash_hmac( 'sha384', $url, $this->get_auth_secret(), true ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- Token creation 346 356 347 357 if ( $store ) { 348 $all_tokens = get_option( $this->auth_tokens, [] ); 349 358 $all_tokens = $this->get_all_api_auth_tokens(); 350 359 // Only set if it doesn't already exist. 351 360 if ( ! isset( $all_tokens[ $url ] ) ) { … … 387 396 public function get_api_auth_token( $url ): string { 388 397 389 // Remove any potential trailing slash to match incoming browser origin. 390 $url = untrailingslashit( $url ); 391 392 $all_tokens = get_option( $this->auth_tokens, [] ); 393 398 // Strip URL back to simple URL scheme and host matching browser origin format. 399 $url = $this->sanitize_origin_url( $url ); 400 401 $all_tokens = $this->get_all_api_auth_tokens(); 394 402 if ( isset( $all_tokens[ $url ] ) && ! empty( $all_tokens[ $url ] ) ) { 395 403 return $all_tokens[ $url ]; … … 411 419 public function delete_api_auth_token( $url ): bool { 412 420 413 // Remove any potential trailing slash to match incoming browser origin. 421 // Lightly sanitise by just removing any potential trailing slash. 422 // Don't fully sanitise as then would not be possible to remove incorrect URLs. 414 423 $url = untrailingslashit( $url ); 415 424 416 $all_tokens = get_option( $this->auth_tokens, [] ); 417 425 $all_tokens = $this->get_all_api_auth_tokens(); 418 426 if ( isset( $all_tokens[ $url ] ) ) { 419 427 unset( $all_tokens[ $url ] ); … … 535 543 return true; 536 544 } 545 546 /** 547 * Sanitise a URL to match the format that browsers send within their `origin` header 548 * 549 * Ensures that sub-directories, trailing slashes etc are removed. 550 * 551 * @since 3.2.2 552 * 553 * @param string $url URL to sanitise to match browser origin format 554 * 555 * @return string Sanitised URL 556 */ 557 public function sanitize_origin_url( $url ) { 558 559 $_parts = wp_parse_url( $url ); 560 $url = untrailingslashit( sprintf( '%s://%s', $_parts['scheme'], $_parts['host'] ) ); 561 562 return $url; 563 } 537 564 } -
personalizewp/trunk/includes/class-personalizewp.php
r3380017 r3382403 423 423 424 424 /** 425 * Add block category for PersonalizeWP Blocks. 426 * 427 * @since 3.2.2 428 * 429 * @param array[] $categories All categories 430 * 431 * @return array[] Returns an array containing array of categories for block types including our custom ones. 432 */ 433 function register_block_category( $categories ) { 434 return array_merge( 435 $categories, 436 array( 437 array( 438 'slug' => 'personalizewp', 439 'title' => esc_html__( 'PersonalizeWP', 'personalizewp' ), 440 ), 441 ) 442 ); 443 } 444 445 /** 425 446 * Register custom block types. 426 447 * … … 428 449 */ 429 450 public function register_blocks() { 451 452 add_filter( 'block_categories_all', [ $this, 'register_block_category' ], 10 ); 430 453 431 454 $custom_blocks = array( -
personalizewp/trunk/includes/rule-conditions/woocommerce/class-category-quantity-in-cart.php
r3380017 r3382403 21 21 * Checks if the total quantity of products from a specific category in the cart meets the specified condition 22 22 */ 23 class WooCommerce_Category_Quantity_In_Cart extends RuleCondition {23 class Category_Quantity_In_Cart extends RuleCondition { 24 24 25 25 /** -
personalizewp/trunk/package.json
r3380017 r3382403 24 24 "repository": { 25 25 "type": "git", 26 "url": "https:// bitbucket.org/filter-digital/personalizewp.git"26 "url": "https://github.com/filter-agency/personalizewp.git" 27 27 }, 28 28 "files": [ -
personalizewp/trunk/personalizewp.php
r3381432 r3382403 11 11 * Plugin URI: https://personalizewp.com/ 12 12 * Description: Add powerful personalization features to your WordPress site. Show different content to different visitors based on their behavior, profile, location, and more. 13 * Version: 3.2. 113 * Version: 3.2.2 14 14 * Author: Filter 15 15 * Author URI: https://filter.agency/ … … 40 40 * Current plugin version. 41 41 */ 42 define( 'PERSONALIZEWP_VERSION', '3.2. 1' );42 define( 'PERSONALIZEWP_VERSION', '3.2.2' ); 43 43 44 44 // Load autoloader. -
personalizewp/trunk/src/admin/js/components/auto-complete.js
r3380017 r3382403 16 16 17 17 /** 18 * Run when the element is added to the DOM 19 * Often run after each of the observedAttributes. 18 * Runs only once the complete element has been parsed and added to the DOM. 20 19 */ 21 20 connectedCallback() { … … 29 28 if (this.hasAttribute('is-ready')) return; 30 29 31 // Internal data 32 this.isDomSetup = false; 33 this.searchQueries = {}; 34 this.contentTypes = []; 35 this.taxonomy = null; 36 this.restBase = null; 37 this.selectedItems = []; 30 // Get the required template for working. Used to format searched items. 31 this.itemTemplate = this.querySelector('template')?.content; 32 if ( ! this.itemTemplate ) return; 33 34 // Internal variables, not configured via attributes 38 35 this.currentSearch = ''; 39 36 this.currentPage = 1; … … 41 38 this.perPage = 10; 42 39 this.minChars = 2; 43 44 // Dom references 45 this.itemTemplate = null;40 this.initialiseMode(); 41 42 // DOM references 46 43 this.searchInput = null; 47 44 this.clearSearch = null; 48 45 this.searchResults = null; 49 46 this.displaySelected = null; 50 51 // Can start disabled.52 this.disabled = this.getAttribute('disabled') || false;53 54 // Get the elements55 this.itemTemplate = this.querySelector('template')?.content;56 if ( ! this.itemTemplate ) return;57 58 // Initialise mode is automatic due to observedAttributes.59 60 47 // Setup default UI 61 if ( ! this.isDomSetup )this.setupDOM();48 this.setupDOM(); 62 49 63 50 // Populate initial list based on already set items … … 69 56 this.searchResults.addEventListener('click', this); // On the search results 70 57 this.displaySelected.addEventListener('click', this); // On the buttons to remove items 71 72 this.isDomSetup = true;73 58 74 59 // Emit ready event. … … 126 111 127 112 /** 128 * Initialise/update mode. Some modes have additional setup. 113 * Initialise/update mode, and base required properties via attributes. 114 * Some modes have additional setup, such as terms to confirm valid taxonomy. 129 115 */ 130 116 initialiseMode() { 131 // Define properties 117 118 // Define base dynamic properties 132 119 this.mode = this.getAttribute('mode') || 'post'; 133 120 this.disabled = this.getAttribute('disabled') || false; // Field can start disabled 121 this.taxonomy = this.getAttribute('taxonomy') || null; 122 this.contentTypes = this.getAttribute('content-types') || []; 123 if ( 0 !== this.contentTypes.length ) { 124 // Convert string to sanitised array 125 this.contentTypes = this.contentTypes.split(',').map( (v) => v.replace( /[^a-z0-9_\-]/, '' ) ); 126 } 127 // Keep a list of internal chosen IDs/titles 128 this.selectedItems = this.getAttribute('content') || []; 129 if ( 0 !== this.selectedItems.length ) { 130 this.selectedItems = JSON.parse(this.selectedItems); 131 } 132 133 this.restBase = null; 134 134 // Additional defaults depend on specific mode 135 135 switch( this.mode ) { 136 136 case 'term': 137 this.restBase = null;138 this.taxonomy = this.getAttribute('taxonomy');139 137 if ( window.PWPTaxonomyRestBases ) { 140 138 this.restBase = window.PWPTaxonomyRestBases?.[`${this.taxonomy}`] || null; … … 173 171 } 174 172 175 // Keep a list of internal chosen IDs/titles176 const _selectedItems = this.getAttribute('content') || [];177 if ( 0 !== _selectedItems.length ) {178 this.selectedItems = JSON.parse(_selectedItems);179 }180 173 } 181 174 … … 186 179 handleEvent(event) { 187 180 this[`handle${event.type}`](event); 188 }189 190 /**191 * Runs when the value of an attribute is changed on the component.192 * Also runs when the component is first seen, before connectedCallback() is run.193 * @param {String} name The attribute name194 * @param {String} oldValue The old attribute value195 * @param {String} newValue The new attribute value196 */197 attributeChangedCallback(name, oldValue, newValue) {198 // Rationalise the attribute name for function name support199 name = name.replace( /[^a-zA-Z0-9]/i, '' );200 this[`handleChange${name}`](oldValue, newValue);201 }202 203 /**204 * Updating placeholder on search input205 * @param {Event} event206 */207 handleChangeplaceholder(event) {208 if ( this.searchInput ) {209 this.searchInput.setAttribute('placeholder', this.getAttribute('placeholder') || `${ __('Search', 'personalizewp') }`);210 }211 181 } 212 182 … … 272 242 273 243 /** 244 * Runs when the value of an attribute is changed on the component. 245 * Also runs when a components' attribute is first seen, before connectedCallback() is run. 246 * @param {String} name The attribute name 247 * @param {String} oldValue The old attribute value 248 * @param {String} newValue The new attribute value 249 */ 250 attributeChangedCallback(name, oldValue, newValue) { 251 // Don't run if not initialized, ensures data integrity. 252 if (! this.hasAttribute('is-ready')) return; 253 254 // Rationalise the attribute name for function name support 255 name = name.replace( /[^a-zA-Z0-9]/i, '' ); 256 this[`handleChange${name}`](oldValue, newValue); 257 } 258 259 /** 260 * Updating placeholder on search input 261 * @param {Event} event 262 */ 263 handleChangeplaceholder(event) { 264 if ( this.searchInput ) { 265 this.searchInput.setAttribute('placeholder', this.getAttribute('placeholder') || `${ __('Search', 'personalizewp') }`); 266 } 267 } 268 269 /** 274 270 * Handle [mode] attribute changes 275 271 * @param {String} oldValue The old attribute value … … 310 306 // Has a category, so (re)initialise. 311 307 this.initialiseMode(); 312 313 // Only update template inputs if the component is fully initialized314 if ( ! this.itemTemplate ) {315 return;316 }317 308 318 309 // Use placeholder value for initial search/replace. … … 496 487 emit( this, 'auto-complete', 'reset-all' ); 497 488 } 498 499 // /**500 // * Emit a custom event501 // * @param {String} type The event type502 // * @param {Object} detail Any details to pass along with the event503 // */504 // emit(type, detail = {}) {505 506 // // Create a new event507 // let event = new CustomEvent(`auto-complete:${type}`, {508 // bubbles: true,509 // cancelable: true,510 // detail: detail511 // });512 513 // // Dispatch the event514 // return this.dispatchEvent(event);515 // }516 489 517 490 /** … … 657 630 }; 658 631 // Use content-types attribute and pass as subtype (consistent with post case) 659 if ( 0 !== this.contentTypes.length ) {632 if ( this.contentTypes && 0 !== this.contentTypes.length ) { 660 633 _searchArgs.subtype = this.contentTypes.join(','); 661 634 } -
personalizewp/trunk/src/blocks/product-collection/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/product-collection", 5 "version": "1.0. 0",6 "title": "P ersonalizeWP Product Collection",5 "version": "1.0.1", 6 "title": "Product Collection", 7 7 "description": "Create personalized product collections that adapt to each visitor. Choose between showing recently viewed products or segment-based recommendations.", 8 "category": " woocommerce",8 "category": "personalizewp", 9 9 "keywords": [ 10 10 "PersonalizeWP", 11 "pwp", 11 12 "WooCommerce", 12 13 "personalization", -
personalizewp/trunk/src/blocks/product-collection/index.js
r3380017 r3382403 33 33 > 34 34 <path 35 fill=" url(#paint0_linear_311_20854)"36 d="M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"35 fill="#e1236c" 36 d="M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z" 37 37 /> 38 <defs>39 <linearGradient id="paint0_linear_311_20854">40 <stop offset=".16" stopColor="#C127A0"/>41 <stop offset=".28" stopColor="#CD20A1"/>42 <stop offset=".59" stopColor="#E813A4"/>43 <stop offset=".76" stopColor="#F20FA6"/>44 </linearGradient>45 </defs>46 38 </svg> 47 39 }; -
personalizewp/trunk/src/blocks/variation-fallback/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation-fallback", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Default Content", 7 "category": " design",7 "category": "personalizewp", 8 8 "description": "The fallback content that is displayed when no variation conditions are matched.", 9 9 "parent": [ "personalizewp-pro/variations-block" ], -
personalizewp/trunk/src/blocks/variation/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variation", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variation", 7 "category": " design",7 "category": "personalizewp", 8 8 "icon": "block-default", 9 9 "description": "A group of one or more blocks that displays different content to the fallback.", -
personalizewp/trunk/src/blocks/variations-block/block.json
r3380017 r3382403 3 3 "apiVersion": 3, 4 4 "name": "personalizewp-pro/variations-block", 5 "version": "1.0. 0",5 "version": "1.0.1", 6 6 "title": "Content Variations", 7 "category": "design", 7 "category": "personalizewp", 8 "keywords": [ 9 "PersonalizeWP", 10 "pwp", 11 "personalization", 12 "variation" 13 ], 8 14 "icon": "block-default", 9 15 "description": "Show different variations of your content to specific users depending on which conditions they match, with a fallback for everyone else.", -
personalizewp/trunk/src/blocks/variations-block/index.js
r3380017 r3382403 22 22 > 23 23 <path 24 fill=" url(#paint0_linear_311_20854)"25 d="M22.98 9.12a3.04 3.04 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4.28 4.28 0 0 0-.91-.43 3.78 3.78 0 0 0-1.34-.13 3.92 3.92 0 0 0-1.28.39 4.3 4.3 0 0 0-.57.37 3.14 3.14 0 0 0-.67.75 3.77 3.77 0 0 0-.43.92 2.9 2.9 0 0 0-.14.66 3.1 3.1 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.48 3.48 0 0 0 2.58.52 3.8 3.8 0 0 0 .95-.34A3.48 3.48 0 0 0 23 9.45c0-.1 0-.22-.02-.33z"24 fill="#e1236c" 25 d="M22.98 9.12a3 3 0 0 0-.25-.98 3.4 3.4 0 0 0-1.26-1.55 4 4 0 0 0-.91-.43 4 4 0 0 0-1.34-.13 4 4 0 0 0-1.28.39 4 4 0 0 0-.57.37 3 3 0 0 0-.67.75 4 4 0 0 0-.43.92 3 3 0 0 0-.14.66 3 3 0 0 0 0 .63l-1.15-2.01A3.44 3.44 0 0 0 8.56 9.7L7.42 7.73a3.44 3.44 0 1 0-5.96 3.43l2.48 4.32a3.44 3.44 0 0 0 6.41-1.97l1.15 1.98a3.44 3.44 0 0 0 6.06-3.24l.09.06a3.5 3.5 0 0 0 2.58.52 4 4 0 0 0 .95-.34A3.5 3.5 0 0 0 23 9.45z" 26 26 /> 27 <defs>28 <linearGradient id="paint0_linear_311_20854">29 <stop offset=".16" stopColor="#C127A0"/>30 <stop offset=".28" stopColor="#CD20A1"/>31 <stop offset=".59" stopColor="#E813A4"/>32 <stop offset=".76" stopColor="#F20FA6"/>33 </linearGradient>34 </defs>35 27 </svg> 36 28 }; -
personalizewp/trunk/uninstall.php
r3380017 r3382403 14 14 defined( 'WP_UNINSTALL_PLUGIN' ) || exit; 15 15 16 // To ensure that all variables and constants are available. 17 require __DIR__ . '/includes/personalizewp-constants.php'; 16 // Skip the autoloader, manually include what is needed for the DB Manager 18 17 require __DIR__ . '/includes/traits/class-singletontrait.php'; 19 18 require __DIR__ . '/includes/class-db-manager.php';
Note: See TracChangeset
for help on using the changeset viewer.