"use strict";(globalThis.blocksyNewsletterSubscribeExtJsonp=globalThis.blocksyNewsletterSubscribeExtJsonp||[]).push([[564],{564:function(e,t,n){n.r(t);var a=n(462),c=n(861),r=n(152),s=n(687),i=n.n(s),o=n(381),l=n(343),u=n(652),d=n(184),p=n.n(d),m=null;t.default=function(e){var t=e.value,n=e.onChange,s=(0,o.useState)(m||[]),d=(0,r.Z)(s,2),b=d[0],f=d[1],h=(0,o.useState)(!m),_=(0,r.Z)(h,2),v=_[0],g=_[1],k=function(){var e=(0,c.Z)(i().mark((function e(){var t,n,a,c=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(!(c.length>0&&void 0!==c[0])||c[0])&&g(!0),(t=new FormData).append("action","blocksy_ext_newsletter_subscribe_get_actual_lists"),t.append("nonce",(window.ctDashboardLocalizations||window.ct_localizations||window.ct_customizer_localizations).dashboard_actions_nonce),e.prev=5,e.next=8,fetch(ajaxurl,{method:"POST",body:t});case 8:if(200!==(n=e.sent).status){e.next=19;break}return e.next=12,n.json();case 12:if(!(a=e.sent).success){e.next=19;break}if("api_key_invalid"===a.data.result){e.next=19;break}return g(!1),f(a.data.result),m=a.data.result,e.abrupt("return");case 19:e.next=23;break;case 21:e.prev=21,e.t0=e.catch(5);case 23:g(!1);case 24:case"end":return e.stop()}}),e,null,[[5,21]])})));return function(){return e.apply(this,arguments)}}();return(0,o.useEffect)((function(){k(!m)}),[]),0===b.length?(0,o.createElement)("div",{className:"ct-select-input"},(0,o.createElement)("input",{disabled:!0,placeholder:v?(0,u.__)("Loading...","blocksy-companion"):(0,u.__)("Invalid API Key...","blocksy-companion")})):(0,o.createElement)(l.ZP,{selectedItem:t||b[0].id,onChange:function(e){return n(e)},itemToString:function(e){return e?(b.find((function(t){return t.id===e}))||{}).name:""}},(function(e){var t=e.getInputProps,n=e.getItemProps,c=(e.getLabelProps,e.getMenuProps),r=e.isOpen,s=(e.inputValue,e.highlightedIndex),i=e.selectedItem,l=e.openMenu;return(0,o.createElement)("div",{className:"ct-select-input"},(0,o.createElement)("input",(0,a.Z)({},t({onFocus:function(){return l()},onClick:function(){return l()}}),{placeholder:(0,u.__)("Select list...","blocksy-companion"),readOnly:!0})),r&&(0,o.createElement)("div",c({className:"ct-select-dropdown"}),b.map((function(e,t){return(0,o.createElement)("div",n({key:e.id,index:t,item:e.id,className:p()("ct-select-dropdown-item",{active:s===t,selected:i===e.id})}),e.name)}))))}))}}}]);