var P=Object.defineProperty;var k=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var S=(a,t,s)=>t in a?P(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,v=(a,t)=>{for(var s in t||(t={}))q.call(t,s)&&S(a,s,t[s]);if(k)for(var s of k(t))C.call(t,s)&&S(a,s,t[s]);return a};import{_ as n,j as i,z as o}from"./main.2.9.0.js";import{u as F,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as z}from"./SnackMsg.DYSD96P4.js";import{S as D}from"./Steps.BYe8zHkm.js";import{I as E,g as L}from"./Integrations.DL8wqGct.js";import T from"./AsanaAuthorization.DDuyLh_4.js";import{h as M,c as N}from"./AsanaCommonFunc.CeZgRdAM.js";import{A as B}from"./AsanaIntegLayout.z2R4YaPL.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function ae({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const g=F(),[y,f]=r.useState(!1),[b,h]=r.useState({}),[c,x]=r.useState(1),[A,p]=r.useState({show:!1}),_=[{key:"name",label:n("Name","bit-integrations"),required:!0},{key:"due_at",label:n("Due At","bit-integrations"),required:!1},{key:"due_on",label:n("Due On","bit-integrations"),required:!1},{key:"notes",label:n("Notes","bit-integrations"),required:!1}],[e,l]=r.useState({name:"Asana",type:"Asana",api_key:"",field_map:[{formField:"",asanaFormField:""}],actionName:"",taskFields:_,actions:{}}),I=()=>{f(!0),L(s,t,u,e,g,"","",f).then(d=>{var j;d.success?(o.success((j=d.data)==null?void 0:j.msg),g(u)):o.error(d.data||d)})},w=m=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!N(e)){o.error(n("Please map mandatory fields","bit-integrations"));return}if(e.actionName==="task"){if(!e.selectedProject){o.error(n("Please select a project","bit-integrations"));return}if(!e.selectedSections&&e.actionName==="task"){o.error(n("Please select a Section","bit-integrations"));return}}e.field_map.length>0&&x(m)};return i.jsxs("div",{children:[i.jsx(z,{snack:A,setSnackbar:p}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(D,{step:3,active:c})}),i.jsx(T,{asanaConf:e,setAsanaConf:l,step:c,setStep:x,loading:b,setLoading:h,setSnackbar:p}),i.jsxs("div",{className:"btcd-stp-page",style:v({},c===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,handleInput:m=>M(m,e,l),asanaConf:e,setAsanaConf:l,loading:b,setLoading:h,setSnackbar:p}),(e==null?void 0:e.actionName)&&i.jsxs("button",{onClick:()=>w(3),disabled:!N(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[n("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&i.jsx(E,{step:c,saveConfig:()=>I(),isLoading:y,dataConf:e,setDataConf:l,formFields:a})]})}export{ae as default};
