var P=Object.defineProperty;var j=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var k=(c,n,o)=>n in c?P(c,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):c[n]=o,h=(c,n)=>{for(var o in n||(n={}))q.call(n,o)&&k(c,o,n[o]);if(j)for(var o of j(n))B.call(n,o)&&k(c,o,n[o]);return c};import{k as D,r as m,u as G,j as t}from"./main-406.js";import{b as z,d as A,_ as d,n as H,F as O,N as y,L as J,G as K}from"./bi.394.85.js";import{u as w,U as Q,C as V,c as W}from"./bi.442.761.js";import{C as L}from"./bi.492.719.js";import{T as U,t as X}from"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function ne({formFields:c,setFlow:n,flow:o,allIntegURL:C}){var _,v;const{formID:b}=D(),[N,p]=m.useState({show:!1}),[T,F]=m.useState([]),S=G(),[f,g]=m.useState(!1),{registration:a}=X,[e,u]=m.useState({name:"User Registration",type:"Registration",user_map:[{}],meta_map:[{}],condition:{action_behavior:"",actions:[{field:"",action:"value"}],logics:[{field:"",logic:"",val:""},"or",{field:"",logic:"",val:""}]}});m.useEffect(()=>{var r,l;const s=h({},e);z({},"role/list",null,"GET").then(i=>{i!=null&&i.success&&i!==void 0&&F(Object.values(i==null?void 0:i.data))}),(l=(r=s==null?void 0:s.user_map)==null?void 0:r[0])!=null&&l.userField||(s.user_map=w.filter(i=>i.required).map(i=>({formField:"",userField:i.key,required:i.required}))),u(s)},[]);const I=()=>{if(!e.action_type){p({show:!0,msg:d("Please select action type","bit-integrations")});return}if(!e.user_role&&e.action_type!=="updated_user"){p({show:!0,msg:d("User Role cann't be empty","bit-integrations")});return}if(!W(e)&&e.action_type!=="updated_user"){p({show:!0,msg:d("Please map mandatory fields","bit-integrations")});return}g(!0),K(o,n,C,e,S,"","",g)},R=(s,r)=>{const l=h({},e);r?l.condition.action_behavior=s:l.condition.action_behavior="",u(l)},x=s=>{const r=h({},e),{name:l,value:i}=s.target;s.target.checked&&(r[l]=i),u(h({},r))},E=`
  <ul>
  <li>The user must be logged in when updating profile</li>
  <li>The user cannot change the value of the username field when updating the user profile.</li>
     
  </ul>`,M=`
  <ul>
  <li>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.</li>
     
  </ul>`;return t.jsxs("div",{style:{width:900},children:[t.jsx(A,{snack:N,setSnackbar:p}),(a==null?void 0:a.youTubeLink)&&t.jsx(U,{title:a==null?void 0:a.title,youTubeLink:a==null?void 0:a.youTubeLink}),(a==null?void 0:a.docLink)&&t.jsx(U,{title:a==null?void 0:a.title,docLink:a==null?void 0:a.docLink}),t.jsx("div",{className:"font-w-m mt-3",children:d("Action type","bit-integrations")}),t.jsxs("div",{children:[t.jsx(L,{radio:!0,name:"action_type",onChange:x,checked:(e==null?void 0:e.action_type)==="new_user",value:"new_user",title:d("New User Create","bit-integrations")}),t.jsx(L,{radio:!0,name:"action_type",onChange:x,checked:(e==null?void 0:e.action_type)==="updated_user",value:"updated_user",title:d("Updated User","bit-integrations")})]}),t.jsx("div",{children:t.jsx(Q,{formFields:c,formID:b,userConf:e,setUserConf:u,roles:T,userFields:w})}),t.jsxs("div",{children:[t.jsx(V,{formFields:c,formID:b,userConf:e,setUserConf:u}),t.jsx("br",{})]}),(e==null?void 0:e.condition)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flx",children:t.jsx(H,{onChange:s=>R(s.target.value,s.target.checked),checked:((_=e==null?void 0:e.condition)==null?void 0:_.action_behavior)==="cond",className:"wdt-200 mt-4 mr-2",value:"cond",title:d("Conditional Logics","bit_integration")})}),t.jsx("br",{}),((v=e==null?void 0:e.condition)==null?void 0:v.action_behavior)==="cond"&&t.jsx(O,{formFields:c,dataConf:e,setDataConf:u})]}),(e==null?void 0:e.action_type)==="updated_user"?t.jsx(y,{note:E}):t.jsx(y,{note:M}),t.jsxs("button",{className:"btn f-left btcd-btn-lg purple sh-sm flx",type:"button",onClick:()=>I(),disabled:f,children:[d("Save","bit-integrations"),f&&t.jsx(J,{size:20,clr:"#022217",className:"ml-2"})]})]})}export{ne as default};
