(()=>{"use strict";const e=window.wp.domReady,t=window.webStoriesData||{},n=function(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const o=e.value,i=e.closest(".widget"),d=t.fields[o];for(const[e,t]of Object.entries(d)){const o=i.querySelector(`.${e}.stories-widget-field`),d=i.querySelector(`.${e}_wrapper`);if(o&&d){"checkbox"===o.getAttribute("type")?(n&&(o.checked=!1),t.hidden&&(o.checked=t.show),d.style.display=t.hidden?"none":"block"):d.style.display=t.show?"block":"none"}}},o=()=>document.getElementsByClassName("view_type stories-widget-field"),i=function(){const e=o();if(e.length)for(let t=0;t<e.length;t++)e[t].addEventListener("change",(e=>{n(e.target,!1)}))};e((()=>{i(),function(){const e=o(),t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0);for(let n=0;n<e.length;n++)e[n].dispatchEvent(t)}()}));const d=(e,t)=>{if(!t[0])return;const o=t[0].querySelectorAll(".stories-widget-field.view_type");o.length&&(n(o[0],!1),i())},c=window.jQuery;c(document).on("widget-updated",d),c(document).on("widget-added",d)})();