var z=Object.defineProperty;var w=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var v=(a,s,e)=>s in a?z(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e,S=(a,s)=>{for(var e in s||(s={}))C.call(s,e)&&v(a,e,s[e]);if(w)for(var e of w(s))F.call(s,e)&&v(a,e,s[e]);return a};import{r as i,j as t,_ as x,bs as L,c as P,D as _,g as E,a as M,S as B,W as T,h as $}from"./main-634.js";import{m as D}from"./bf-25-81.js";import{S as H}from"./bf-54-258.js";import{a5 as R,a6 as q,a7 as W}from"./bf-746-82.js";import{I as G}from"./bf-942-184.js";import{t as k}from"./bf-275-83.js";import{N as J}from"./bf-123-109.js";import{A as K,g as O,c as Q}from"./bf-774-219.js";import"./bf-822-108.js";import"./bf-438-114.js";function U({autonamiConf:a,setAutonamiConf:s,step:e,nextPage:j,setSnackbar:A,isInfo:f}){const[l,b]=i.useState(!1),[u,o]=i.useState(!1),[d,g]=i.useState(!1),[r,n]=i.useState(!0),[h,p]=i.useState({integrationName:""});i.useEffect(()=>()=>{n(!1)},[]);const m=()=>{g("auth"),P({},"bitforms_autonami_authorize").then(c=>{r&&(c!=null&&c.success&&(b(!0),A({show:!0,msg:x("Connect Successfully")})),o(!0),g(!1))})},y=c=>{const I=S({},a),N=S({},h);N[c.target.name]="",I[c.target.name]=c.target.value,p(N),s(I)};return t.jsx(t.Fragment,{children:t.jsxs("div",{className:"btcd-stp-page",style:{width:e===1&&900,height:e===1&&"100%"},children:[t.jsx(R,{title:k.autonami.title,youTubeLink:k.autonami.link}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:x("Integration Name:")})}),t.jsx("input",{className:"btcd-paper-inp w-5 mt-1",onChange:y,name:"name",value:a.name,type:"text",placeholder:x("Integration Name..."),disabled:f}),u&&!l&&!d&&t.jsxs("div",{className:"flx mt-4",style:{color:"red"},children:[t.jsx(L,{size:"30"}),"Please! First Install or Active Autonami Pro Plugin"]}),t.jsx("br",{}),t.jsx(q,{isAuthorized:l,isLoading:d,handleAuthorize:()=>m()}),t.jsx("br",{}),t.jsx(J,{nextPageHandler:()=>j(2),disabled:!l})]})})}function rt({formFields:a,setIntegration:s,integrations:e,allIntegURL:j}){const A=_(),{formID:f}=E(),{css:l}=M(),[b,u]=i.useState(!1),[o,d]=i.useState(1),[g,r]=i.useState({show:!1}),[n,h]=i.useState({name:"Autonami API",type:"Autonami",field_map:[{formField:"",autonamiField:""}],actions:{}}),p=m=>{if(m===2&&n.name!=="")O(n,h,u,r),d(m);else if(m===3){if(!Q(n)){r({show:!0,msg:"Please map all required fields to continue."});return}n.field_map.length>0&&d(m)}document.getElementById("btcd-settings-wrp").scrollTop=0};return t.jsxs("div",{children:[t.jsx(B,{snack:g,setSnackbar:r}),t.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:t.jsx(H,{step:3,active:o})}),t.jsx(U,{formID:f,autonamiConf:n,setAutonamiConf:h,step:o,nextPage:p,isLoading:b,setIsLoading:u,setSnackbar:r}),t.jsxs("div",{className:"btcd-stp-page",style:{width:o===2&&900,height:o===2&&"100%",minHeight:o===2&&"200px"},children:[t.jsx(K,{formID:f,formFields:a,autonamiConf:n,setAutonamiConf:h,setIsLoading:u,setSnackbar:r}),t.jsx("br",{}),t.jsx("br",{}),t.jsx("br",{}),t.jsxs(T,{onClick:()=>p(3),disabled:n.field_map.length<1,className:l($.ftRight),children:[x("Next"),t.jsx(D,{className:"ml-1 rev-icn"})]})]}),t.jsx(G,{step:o,saveConfig:()=>W(e,s,j,n,A)})]})}export{rt as default};
