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