File: /home/ohirex/web/ohirex.com/public_html/wp-content/plugins/mailster/build/forms/lists/index.js
(()=>{var e={6942:(e,t)=>{var s;!function(){"use strict";var r={}.hasOwnProperty;function l(){for(var e="",t=0;t<arguments.length;t++){var s=arguments[t];s&&(e=n(e,i(s)))}return e}function i(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return l.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var s in e)r.call(e,s)&&e[s]&&(t=n(t,s));return t}function n(e,t){return t?e?e+" "+t:e+t:e}e.exports?(l.default=l,e.exports=l):void 0===(s=function(){return l}.apply(t,[]))||(e.exports=s)}()}},t={};function s(r){var l=t[r];if(void 0!==l)return l.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,s),i.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks;var t=s(6942),r=s.n(t);const l=window.wp.i18n,i=window.wp.blockEditor,n=window.wp.element,a=window.wp.coreData,o=window.wp.data,c=window.wp.components,d=window.wp.primitives,u=window.ReactJSXRuntime,h=(0,u.jsx)(d.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,u.jsx)(d.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})}),p=(0,u.jsx)(d.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,u.jsx)(d.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})});function m(e){const{meta:t,setMeta:s,attributes:r={},setAttributes:i}=e,{userschoice:n,lists:a}=t,{showLabel:d=!1,label:m=""}=r,x=(0,o.useSelect)((e=>e("mailster/form").getLists()));function b(e,t){var r=[...a];t?r.push(e):r=r.filter((t=>t!=e)),s({lists:r})}function w(e,t){var r=[...a],l=r[e];r.splice(e,1),r.splice(e+t,0,l),s({lists:r})}const f=x?x.filter((e=>!a.includes(e.ID))):[];return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.PanelRow,{children:(0,u.jsx)(c.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,l.__)("Users Choice","mailster"),checked:!!t.userschoice,onChange:()=>s({userschoice:!t.userschoice}),help:(0,l.__)("Users decide which list they subscribe to","mailster")})}),!x&&(0,u.jsx)(c.Spinner,{}),x&&a.length>0&&(0,u.jsx)(c.PanelRow,{children:(0,u.jsx)(c.BaseControl,{__nextHasNoMarginBottom:!0,id:"mailster-values",className:"widefat",label:n?(0,l.__)("Users can subscribe to","mailster"):(0,l.__)("Subscribe new users to","mailster"),children:(0,u.jsx)(c.Flex,{className:"mailster-value-options",justify:"flex-end",id:"mailster-values",style:{flexWrap:"wrap"},children:a.map(((e,t)=>{const s=(e=>{const t=x.filter((t=>t.ID==e));return t.length?t[0]:null})(e);return s&&((e,t)=>(0,u.jsxs)(c.Flex,{style:{flexShrink:0},children:[(0,u.jsx)(c.FlexItem,{children:(0,u.jsx)(c.CheckboxControl,{__nextHasNoMarginBottom:!0,checked:!0,value:e.ID,onChange:t=>{b(e.ID,t)},label:e.name})}),a.length>1&&(0,u.jsxs)(c.FlexItem,{children:[(0,u.jsx)(c.Button,{disabled:!t,icon:h,isSmall:!0,label:(0,l.__)("move up","mailster"),onClick:()=>{w(t,-1)}}),(0,u.jsx)(c.Button,{disabled:t+1==a.length,icon:p,isSmall:!0,label:(0,l.__)("move down","mailster"),onClick:()=>{w(t,1)}})]})]},t))(s,t)}))})})}),f.length>0&&(0,u.jsx)(c.PanelRow,{children:(0,u.jsx)(c.BaseControl,{__nextHasNoMarginBottom:!0,id:"mailster-values",className:"widefat",label:(0,l.__)("Available Lists","mailster"),children:(0,u.jsx)(c.Flex,{className:"mailster-value-options",justify:"flex-end",id:"mailster-values",style:{flexWrap:"wrap"},children:f.map(((e,t)=>(0,u.jsx)(c.Flex,{style:{flexShrink:0},children:(0,u.jsx)(c.FlexItem,{children:(0,u.jsx)(c.CheckboxControl,{__nextHasNoMarginBottom:!0,checked:a.includes(e.ID),value:e.ID,onChange:t=>{b(e.ID,t)},label:e.name})})},t)))})})}),t.userschoice&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c.PanelRow,{children:(0,u.jsx)(c.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,l.__)("Show Label","mailster"),checked:d,onChange:()=>i({showLabel:!d})})}),(0,u.jsx)(c.PanelRow,{children:(0,u.jsx)(c.TextControl,{__nextHasNoMarginBottom:!0,className:"widefat",value:m,onChange:e=>i({label:e}),help:(0,l.__)("If the label is hidden it will be used for screen readers.","mailster")})})]}),t.userschoice&&a.length>0&&(0,u.jsx)(c.PanelRow,{children:(0,u.jsx)(c.Tip,{children:(0,l.__)("You can update the list names and the precheck status in the editor.","mailster")})})]})}function x(e){return(0,u.jsx)(i.InspectorControls,{children:(0,u.jsx)(c.Panel,{children:(0,u.jsx)(c.PanelBody,{title:(0,l.__)("List Settings","mailster"),children:(0,u.jsx)(m,{...e})})})})}const b=(0,u.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,u.jsx)(d.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})}),w=(0,u.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,u.jsx)(d.Path,{d:"m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z"})});function f(e){const{attributes:t,setAttributes:s}=e,{vertical:r}=t;return(0,u.jsx)(i.BlockControls,{group:"block",children:(0,u.jsx)(c.ToolbarButton,{icon:r?b:w,onClick:()=>s({vertical:!r}),label:(0,l.__)("Orientation","mailster")})})}const j=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"mailster/lists","title":"Lists Field","category":"mailster-form-fields","keywords":["container","wrapper","row","section"],"parent":["mailster/form-wrapper","core/column","core/group"],"description":"Adds a List block to your Mailster Block Form","example":{},"supports":{"html":false,"reusable":false,"multiple":false,"inserter":false,"spacing":{"margin":true,"padding":true},"color":true},"attributes":{"lock":{"type":"object","default":{"remove":true}},"vertical":{"type":"boolean","default":false},"id":{"type":"string","source":"attribute","selector":"input","attribute":"id"},"showLabel":{"type":"boolean","default":false},"label":{"type":"string","source":"html","selector":"legend"},"lists":{"type":"array","source":"query","selector":"input","default":[],"query":{"id":{"type":"integer","source":"attribute","attribute":"value"},"name":{"type":"string","source":"attribute","attribute":"aria-label"},"checked":{"type":"boolean","source":"attribute","attribute":"checked"}}}},"textdomain":"mailster","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css"}'),g=(0,u.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,u.jsx)("path",{d:"M0,0H24V24H0Z",fill:"none"}),(0,u.jsx)("path",{d:"M12,12h8",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),(0,u.jsx)("path",{d:"M12,19h8",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),(0,u.jsx)("path",{d:"M12,5h8",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),(0,u.jsx)("line",{x1:"4.5",y1:"3.5",x2:"7.5",y2:"6.5",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),(0,u.jsx)("line",{x1:"7.5",y1:"3.5",x2:"4.5",y2:"6.5",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),(0,u.jsx)("path",{d:"M6.5,12.00063A.5.5,0,1,1,5.99937,11.5.5.5,0,0,1,6.5,12.00063",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"}),(0,u.jsx)("path",{d:"M6.5,19.00063A.5.5,0,1,1,5.99937,18.5.5.5,0,0,1,6.5,19.00063",fill:"none",stroke:"#323232",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})]}),{name:k,...v}=j;(0,e.registerBlockType)(k,{...v,icon:g,edit:function(e){const{attributes:t,setAttributes:s,isSelected:c,clientId:d}=e,{lists:h,vertical:p,showLabel:m,label:b}=t,w=["mailster-wrapper mailster-wrapper-_lists"],[j,g]=(0,a.useEntityProp)("postType","mailster-form","meta");p&&w.push("mailster-wrapper-is-vertical"),m&&w.push("mailster-show-label");const k=(0,i.useBlockProps)({className:r()({},w)}),v=(0,o.useSelect)((e=>e("mailster/form").getLists()),[]),_=(e,t)=>{(t||JSON.stringify(h)!==JSON.stringify(e))&&s({lists:e})};(0,n.useEffect)((()=>{if(j.lists&&v){var e=j.lists.map((e=>({id:e.toString(),name:y(e).name,checked:!!y(e).checked})));_(e)}}),[j.lists]),(0,n.useEffect)((()=>{t.id||s({id:"mailster-id-"+d.substring(30)})}));const y=e=>{const t=h.find((t=>t.id==e));return t||v.find((t=>t.ID==e))};return(0,u.jsxs)("div",{...k,children:[(0,u.jsxs)("fieldset",{children:[(0,u.jsx)(i.RichText,{tagName:"legend",value:b||(0,l.__)("Lists","mailster"),onChange:e=>s({label:e}),placeholder:(0,l.__)("Enter Label","mailster")}),h.map(((e,t)=>(0,u.jsxs)("div",{className:"mailster-group mailster-group-checkbox",children:[(0,u.jsx)("input",{type:"checkbox",value:e.id,checked:e.checked||!1,"aria-label":e.name,onChange:()=>((e,t)=>{var s=[...h];s[t].checked=e,_(s,!0)})(!e.checked,t)}),(0,u.jsx)(i.RichText,{tagName:"label",value:e.name,onChange:e=>((e,t)=>{var s=[...h];s[t].name=e,_(s,!0)})(e,t),allowedFormats:[],className:"mailster-label",placeholder:(0,l.__)("Enter Label","mailster")})]},t))),!h.length&&(0,u.jsx)("i",{children:(0,l.__)("Please select at least one list or disable user choice.","mailster")})]}),(0,u.jsx)(f,{...e}),(0,u.jsx)(x,{meta:j,setMeta:g,attributes:t,setAttributes:s})]})},save:function(e){const{attributes:t,setAttributes:s,isSelected:n}=e,{lists:a,vertical:o,showLabel:c,label:d}=t,h=["mailster-wrapper mailster-wrapper-_lists"];o&&h.push("mailster-wrapper-is-vertical"),c&&h.push("mailster-show-label");const p=i.useBlockProps.save({className:r()({},h)});return(0,u.jsx)("div",{...p,children:(0,u.jsxs)("fieldset",{children:[(0,u.jsx)(i.RichText.Content,{tagName:"legend",value:d||(0,l.__)("Lists","mailster")}),a.map(((e,s)=>{const r=t.id+(s?"-"+s:"");return(0,u.jsxs)("div",{className:"mailster-group mailster-group-checkbox",children:[(0,u.jsx)("input",{type:"checkbox",name:"_lists[]",id:r,value:e.id,checked:e.checked,"aria-label":e.name}),(0,u.jsx)(i.RichText.Content,{tagName:"label",htmlFor:r,value:e.name,className:"mailster-label"})]},s)}))]})})}})})()})();