(()=>{"use strict";const e=window.wp.element,t=window.wp.i18n,l=window.wp.components,s=window.wp.blockEditor;wp.hooks.addFilter("blocks.registerBlockType","pmpro/content-visibility",(function(e,t){return void 0!==e.attributes&&t.startsWith("core/")&&(e.attributes=Object.assign(e.attributes,{visibilityBlockEnabled:{type:"boolean",default:!1},invert_restrictions:{type:"string",default:"0"},segment:{type:"string",default:"all"},levels:{type:"array",default:[]},show_noaccess:{type:"string",default:"0"}})),e}));const i=wp.compose.createHigherOrderComponent((i=>n=>{const{Fragment:o}=wp.element,{isSelected:r}=n;return(0,e.createElement)(o,null,(0,e.createElement)(i,n),r&&n.name.startsWith("core/")&&function(i){const{attributes:{visibilityBlockEnabled:n,invert_restrictions:o,segment:r,levels:a,show_noaccess:p},setAttributes:c}=i,m=e=>{const t=pmpro.all_level_values_and_labels.map((e=>e.value+""));c({levels:e?t:[]})},b=pmpro.all_level_values_and_labels.map((t=>[(0,e.createElement)(l.CheckboxControl,{label:t.label,checked:a.some((e=>e==t.value)),onChange:function(e){if(e&&!a.some((e=>e==t.value))){const e=a.slice();e.push(t.value+""),c({levels:e})}else if(!e&&a.some((e=>e==t.value))){const e=a.filter((e=>e!=t.value));c({levels:e})}}})]));return(0,e.createElement)(s.InspectorControls,null,(0,e.createElement)(l.PanelBody,{title:(0,t.__)("Content Visibility","paid-memberships-pro"),initialOpen:!0},"pmpro/membership"!==i.name&&(0,e.createElement)(l.ToggleControl,{label:n?(0,t.__)("Disable content visibility for this block","paid-memberships-pro"):(0,t.__)("Enable content visibility for this block","paid-memberships-pro"),onChange:e=>{c({visibilityBlockEnabled:!!e})},checked:n}),(0,e.createElement)("div",{style:{display:n?"block":"none"}},(0,e.createElement)(l.__experimentalHStack,null,(0,e.createElement)(l.Button,{className:"pmpro-block-require-membership-element__set-show-button",icon:"visibility",variant:"0"===o?"primary":"secondary",style:{flexGrow:"1",justifyContent:"center"},onClick:()=>c({invert_restrictions:"0"})},(0,t.__)("Show","paid-memberships-pro")),(0,e.createElement)(l.Button,{className:"pmpro-block-require-membership-element__set-hide-button",icon:"hidden",variant:"1"===o?"primary":"secondary",style:{flexGrow:"1",justifyContent:"center"},onClick:()=>c({invert_restrictions:"1"})},(0,t.__)("Hide","paid-memberships-pro"))),(0,e.createElement)("br",null),(0,e.createElement)(l.SelectControl,{value:r,label:"1"===o?(0,t.__)("Hide content from:","paid-memberships-pro"):(0,t.__)("Show content to:","paid-memberships-pro"),options:[{label:(0,t.__)("All Members","paid-memberships-pro"),value:"all"},{label:(0,t.__)("Specific Membership Levels","paid-memberships-pro"),value:"specific"},{label:(0,t.__)("Logged-In Users","paid-memberships-pro"),value:"logged_in"}],onChange:e=>{c({segment:e,levels:[]})}}),"specific"==r&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",null,(0,e.createElement)("strong",null,(0,t.__)("Membership Levels","paid-memberships-pro"))),(0,e.createElement)("p",null,(0,t.__)("Select","paid-memberships-pro")," ",(0,e.createElement)("a",{href:"#",onClick:e=>{e.preventDefault(),m(!0)}},(0,t.__)("All","paid-memberships-pro"))," | ",(0,e.createElement)("a",{href:"#",onClick:e=>{e.preventDefault(),m(!1)}},(0,t.__)("None","paid-memberships-pro"))),(0,e.createElement)("div",{class:"pmpro-block-inspector-scrollable"},b)),"0"==o&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.SelectControl,{value:p,label:(0,t.__)("Show No Access Message?","paid-memberships-pro"),help:(0,t.__)("Modify the 'no access' message on the Memberships > Advanced Settings page.","paid-memberships-pro"),options:[{label:(0,t.__)("No - Hide this block if the user does not have access","paid-memberships-pro"),value:"0"},{label:(0,t.__)("Yes - Show the 'no access' message if the user does not have access","paid-memberships-pro"),value:"1"}],onChange:e=>c({show_noaccess:e})})))))}(n))}),"contentVisibilityComponent");wp.hooks.addFilter("editor.BlockEdit","pmpro/content-visibility",i)})();