var u=Object.defineProperty;var l=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var h=(t,r,e)=>r in t?u(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,d=(t,r)=>{for(var e in r||(r={}))F.call(r,e)&&h(t,e,r[e]);if(l)for(var e of l(r))g.call(r,e)&&h(t,e,r[e]);return t};import{b as m,_ as f}from"./main.2.8.10.js";const b=(t,r,e)=>{const{name:o,value:s}=t.target,i=d({},r);i[o]=s,e(i)},q=(t,r,e,o,s)=>{e(!0),m({},"user_registration_authorize").then(i=>{i!=null&&i.success?(t(!0),r(!0),o({show:!0,msg:f("Connected Successfully","bit-integrations")}),s(2)):o({show:!0,msg:f((i==null?void 0:i.data)||"Connection failed. Please make sure User Registration and Membership plugin is installed and activated.","bit-integrations")}),e(!1)}).catch(i=>{o({show:!0,msg:f("Connection failed","bit-integrations")}),e(!1)})},v=(t,r,e,o)=>{e(!0),m({},"refresh_user_registration_forms").then(s=>{if(s!=null&&s.success&&(s!=null&&s.data)){const i=d({},t);i.default||(i.default={}),i.default.forms=s.data.forms||[],r(i),o({show:!0,msg:f("Forms refreshed successfully","bit-integrations")})}else o({show:!0,msg:f("Failed to refresh forms","bit-integrations")});e(!1)}).catch(()=>{o({show:!0,msg:f("Failed to refresh forms","bit-integrations")}),e(!1)})},y=(t,r,e,o,s)=>{t&&(o(!0),m({form_id:t},"refresh_user_registration_form_fields").then(i=>{if(i!=null&&i.success&&(i!=null&&i.data)){const a=d({},r);a.default||(a.default={}),a.default.formFields=i.data.fields||[],a.field_map=_(a.default.formFields),e(a),s({show:!0,msg:f("Form fields refreshed successfully","bit-integrations")})}else s({show:!0,msg:f("Failed to refresh form fields","bit-integrations")});o(!1)}).catch(()=>{s({show:!0,msg:f("Failed to refresh form fields","bit-integrations")}),o(!1)}))},_=t=>{const r=t.filter(e=>e.required===!0);return r.length>0?r.map(e=>({formField:"",userRegistrationField:e.value||e.key})):[{formField:"",userRegistrationField:""}]},M=t=>{var c;const{mainAction:r,field_map:e,selectedForm:o}=t;if(!r||r!=="create_user"||!o)return!1;const i=(((c=t==null?void 0:t.default)==null?void 0:c.formFields)||[]).filter(n=>n.required===!0||n.required==="true");if(i.length===0)return e.length>0;const a=e.map(n=>n.userRegistrationField).filter(n=>n);return i.every(n=>a.includes(n.value))};export{y as a,M as c,b as h,v as r,q as u};
