var C=Object.defineProperty;var v=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var y=(a,e,s)=>e in a?C(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,N=(a,e)=>{for(var s in e||(e={}))I.call(e,s)&&y(a,s,e[s]);if(v)for(var s of v(e))A.call(e,s)&&y(a,s,e[s]);return a};import{j as t,_ as i,s as W,b as _}from"./main.2.9.0.js";import{b as m,u as z,e as T}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as F}from"./SnackMsg.DYSD96P4.js";import{S as B}from"./Steps.BYe8zHkm.js";import{I as M,s as q}from"./Integrations.DL8wqGct.js";import{S as D,h as E,c as P}from"./SliceWpIntegLayout.D8E9OxDF.js";import{B as L}from"./BackIcn._8Wofmn2.js";import{y as H,x as K}from"./Note.NSUdvR3c.js";import{T as R}from"./TutorialLink.CFG7bS5c.js";import"./react-vendor.P7K3d6op.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function G({formID:a,sliceWpConf:e,setSliceWpConf:s,step:p,setStep:x,isLoading:u,setIsLoading:f,setSnackbar:S}){const[n,d]=m.useState(!1),[l,h]=m.useState(!1),j=()=>{f("auth"),_({},"slicewp_authorize").then(r=>{r!=null&&r.success&&(d(!0),S({show:!0,msg:i("Connected with SliceWp affiliate Successfully","bit-integrations")})),f(!1),h(!0)})},c=r=>{const b=K(e);b[r.target.name]=r.target.value,s(b)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:p===1&&900,height:p===1&&"auto"},children:[t.jsx(R,{linkKey:"sliceWp"}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:i("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:c,name:"name",value:e.name,type:"text",placeholder:i("Integration Name...","bit-integrations")}),u==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(H,{size:25,clr:"#022217",className:"mr-2"}),"Checking if SliceWp affiliate is active!!!"]}),l&&!n&&!u&&t.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[t.jsx("span",{className:"btcd-icn mr-2",style:{fontSize:30,marginTop:-5},children:"×"}),W(i("%s plugin must be activated to integrate with Bit Integrations","bit-integrations"),"SliceWp affiliate")]}),!n&&t.jsx("button",{onClick:j,className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:i("Connect","bit-integrations")}),n&&t.jsxs("button",{onClick:()=>x(2),className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",disabled:!n,children:[i("Next","bit-integrations"),t.jsx(L,{className:"ml-1 rev-icn"})]})]})}function rt({formFields:a,setFlow:e,flow:s,allIntegURL:p,isInfo:x,edit:u}){const f=z(),{formID:S}=T(),[n,d]=m.useState(!1),[l,h]=m.useState(1),[j,c]=m.useState({show:!1}),r=[{key:"1",label:i("Add commission to user's affiliate","bit-integrations")}],b=[{key:"commission_date",label:i("commission_date","bit-integrations"),required:!0},{key:"reference",label:i("Reference","bit-integrations"),required:!1},{key:"amount",label:i("Amount","bit-integrations"),required:!1}],[o,g]=m.useState({name:"SliceWp",type:"SliceWp",mainAction:"",field_map:[{formField:"",slicewpFormField:""}],allActions:r,sliceWpFields:b,actions:{}}),k=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!P(o)){c({show:!0,msg:i("Please map mandatory fields","bit-integrations")});return}o.mainAction!==""&&h(3)};return t.jsxs("div",{children:[t.jsx(F,{snack:j,setSnackbar:c}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(B,{step:3,active:l})}),t.jsx(G,{formID:S,sliceWpConf:o,setSliceWpConf:g,step:l,setStep:h,isLoading:n,setIsLoading:d,setSnackbar:c}),t.jsxs("div",{className:"btcd-stp-page",style:N({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[t.jsx(D,{formFields:a,handleInput:w=>E(w,o,g),sliceWpConf:o,setSliceWpConf:g,isLoading:n,setIsLoading:d,setSnackbar:c,allIntegURL:p,isInfo:x,edit:u}),t.jsxs("button",{onClick:()=>k(),disabled:!o.mainAction||n||o.statusId===void 0,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations")," ",t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsx(M,{step:l,saveConfig:()=>q({flow:s,setFlow:e,allIntegURL:p,navigate:f,conf:o,setIsLoading:d,setSnackbar:c}),isLoading:n,dataConf:o,setDataConf:g,formFields:a})]})}export{rt as default};
