var P=Object.defineProperty;var k=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var v=(o,a,s)=>a in o?P(o,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[a]=s,p=(o,a)=>{for(var s in a||(a={}))E.call(a,s)&&v(o,s,a[s]);if(k)for(var s of k(a))M.call(a,s)&&v(o,s,a[s]);return o};import{b as w,$ as q,k as A,i as z,h as B,_ as n,j as e}from"./main.2.8.1.js";import{u as D,h as W,d as h}from"./react-router-dom.9mCuUg3q.js";import{a9 as H,z as G}from"./Note.BeM7sN-p.js";import{S as J}from"./SnackMsg.S8DrwLlT.js";import{S as K,C as O,s as Q}from"./Integrations.D2bgBas2.js";import{u as y,U as V,C as X,R as Y,c as Z}from"./RegistrationActions.D8rEUqfJ.js";import{b as ee}from"./Table.DAL7rcPQ.js";import{C as U}from"./CheckBox.Dg5Lw38s.js";import{t as te}from"./tutorialLinks.kMkIDzcD.js";import{T as C}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function fe({allIntegURL:o}){var j,_;const a=D(),{formID:s}=W(),[F,l]=h.useState({show:!1}),[N,se]=h.useState([]),[x,L]=h.useState(!1),[g,R]=w(q),b=A(z),[t,c]=w(B),{registration:m}=te;h.useEffect(()=>{var d,r;const i=p({},t);(r=(d=i==null?void 0:i.user_map)==null?void 0:d[0])!=null&&r.userField||(i.user_map=y.filter(u=>u.required).map(u=>({formField:"",userField:u.key,required:u.required}))),c(i)},[]);const S=()=>{if(!t.action_type){l({show:!0,msg:n("Please select action type","bit-integrations")});return}if(!t.user_role&&t.action_type!=="updated_user"){l({show:!0,msg:n("User Role can't be empty","bit-integrations")});return}if(!Z(t)&&t.action_type!=="updated_user"){l({show:!0,msg:n("Please map mandatory fields","bit-integrations")});return}Q({flow:g,setFlow:R,allIntegURL:o,conf:t,navigate:a,edit:1,setIsLoading:L,setSnackbar:l})},T=(i,d)=>{const r=p({},t);d?r.condition.action_behavior=i:r.condition.action_behavior="",c(r)},f=i=>{const d=p({},t),{name:r,value:u}=i.target;i.target.checked&&(d[r]=u),c(p({},d))},$=`
  <ul>
  <li>${n("The user must be logged in when updating profile","bit-integrations")}</li>
  <li>${n("The user cannot change the value of the username field when updating the user profile.","bit-integrations")}</li>
     
  </ul>`,I=`
  <ul>
  <li>${n("If the Username and Password fields are blank then the user will take the value of the email field as the field and the password will be auto-generated.","bit-integrations")}</li>  
  </ul>`;return e.jsxs("div",{style:{width:900},children:[e.jsx(J,{snack:F,setSnackbar:l}),e.jsx(C,{title:"WP User Registration",youTubeLink:m==null?void 0:m.youTubeLink}),e.jsx(C,{title:"WP User Registration",docLink:m==null?void 0:m.docLink}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(K,{entity:g.triggered_entity,setSnackbar:l}),e.jsxs("div",{className:"flx mt-3",children:[e.jsx("div",{className:"wdt-200 d-in-b",children:n("Action type","bit-integrations")}),e.jsx(U,{radio:!0,name:"action_type",onChange:f,checked:(t==null?void 0:t.action_type)==="new_user",value:"new_user",title:n("New User Create","bit-integrations")}),e.jsx(U,{radio:!0,name:"action_type",onChange:f,checked:(t==null?void 0:t.action_type)==="updated_user",value:"updated_user",title:n("Updated User","bit-integrations")})]}),e.jsx("br",{}),e.jsx("br",{}),e.jsxs("div",{children:[e.jsx(V,{formFields:b,formID:s,userConf:t,setUserConf:c,roles:N,userFields:y}),e.jsx("br",{})]}),e.jsxs("div",{children:[e.jsx(X,{formFields:b,formID:s,userConf:t,setUserConf:c}),e.jsx("br",{})]}),e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:n("Utilities","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx(Y,{userConf:t,setUserConf:c}),e.jsx("br",{}),e.jsx(H,{note:(t==null?void 0:t.action_type)==="updated_user"?$:I}),(t==null?void 0:t.condition)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flx",children:e.jsx(ee,{onChange:i=>T(i.target.value,i.target.checked),checked:((j=t==null?void 0:t.condition)==null?void 0:j.action_behavior)==="cond",className:"wdt-200 mt-4 mr-2",value:"cond",title:n("Conditional Logics","bit_integration")})}),e.jsx("br",{}),((_=t==null?void 0:t.condition)==null?void 0:_.action_behavior)==="cond"&&e.jsx(O,{formFields:b,dataConf:t,setDataConf:c})]}),e.jsxs("button",{className:"btn f-left btcd-btn-lg purple sh-sm flx",type:"button",onClick:S,disabled:x,children:[n("Update","bit-integrations"),x&&e.jsx(G,{size:20,clr:"#022217",className:"ml-2"})]})]})}export{fe as default};
