var z=Object.defineProperty;var j=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var v=(s,i,a)=>i in s?z(s,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[i]=a,A=(s,i)=>{for(var a in i||(i={}))T.call(i,a)&&v(s,a,i[a]);if(j)for(var a of j(i))D.call(i,a)&&v(s,a,i[a]);return s};import{j as t,_ as e,s as F,b as L,k as P,f as R}from"./main.2.9.0.js";import{b as m,u as q,e as B}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as M}from"./SnackMsg.DYSD96P4.js";import{S as E}from"./Steps.BYe8zHkm.js";import{I as H,s as K}from"./Integrations.DL8wqGct.js";import{A as O,h as U,c as $}from"./AffiliateIntegLayout.BcAMoy1H.js";import{B as G}from"./BackIcn._8Wofmn2.js";import{y as J,x as Q}from"./Note.NSUdvR3c.js";import{T as V}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 W({formID:s,affiliateConf:i,setAffiliateConf:a,step:d,setStep:x,isLoading:p,setIsLoading:u,setSnackbar:y}){const[l,k]=m.useState(!1),[c,b]=m.useState(!1),f=()=>{u("auth"),L({},"affiliate_authorize").then(r=>{r!=null&&r.success&&(k(!0),y({show:!0,msg:e("Connected with Affiliate Successfully","bit-integrations")})),u(!1),b(!0)})},g=r=>{const o=Q(i);o[r.target.name]=r.target.value,a(o)};return t.jsxs("div",{className:"btcd-stp-page",style:{width:d===1&&900,height:d===1&&"auto"},children:[t.jsx(V,{linkKey:"affiliate"}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:e("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:g,name:"name",value:i.name,type:"text",placeholder:e("Integration Name...","bit-integrations")}),p==="auth"&&t.jsxs("div",{className:"flx mt-5",children:[t.jsx(J,{size:25,clr:"#022217",className:"mr-2"}),"Checking if LearnDash is active!!!"]}),c&&!l&&!p&&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:"×"}),F(e("%s plugin must be activated to integrate with Bit Integrations","bit-integrations"),"Affiliate plugin")]}),!l&&t.jsx("button",{onClick:f,className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:e("Connect","bit-integrations")}),l&&t.jsxs("button",{onClick:()=>x(2),className:"btn btcd-btn-lg purple sh-sm flx mt-5",type:"button",disabled:!l,children:[e("Next","bit-integrations"),t.jsx(G,{className:"ml-1 rev-icn"})]})]})}function bt({formFields:s,setFlow:i,flow:a,allIntegURL:d,isInfo:x,edit:p}){const u=q(),{formID:y}=B(),l=P(R),{siteURL:k}=l,[c,b]=m.useState(!1),[f,g]=m.useState(1),[r,o]=m.useState({show:!1}),S=[{key:"1",label:e("Create a referral for specific affiliate Id","bit-integrations")},{key:"2",label:e("Create a referral for the user","bit-integrations")}],N=[{key:"1",label:e("Paid","bit-integrations")},{key:"2",label:e("Unpaid","bit-integrations")},{key:"3",label:e("Pending","bit-integrations")},{key:"4",label:e("Reject","bit-integrations")}],C=[{key:"1",label:e("Sale","bit-integrations")},{key:"2",label:e("Opt-in","bit-integrations")},{key:"3",label:e("Lead","bit-integrations")}],I=[{key:"amount",label:e("Amount","bit-integrations"),required:!0},{key:"description",label:e("Description","bit-integrations"),required:!0},{key:"reference",label:e("Reference","bit-integrations"),required:!1},{key:"context",label:e("Context","bit-integrations"),required:!1}],[n,h]=m.useState({name:"Affiliate",type:"Affiliate",mainAction:"",affiliate_id:"",referralId:"",statusId:"",field_map:[{formField:"",affiliateFormField:""}],allReferralType:C,allStatus:N,allActions:S,createAffiliateFields:I,actions:{}}),w=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!$(n)){o({show:!0,msg:e("Please map fields to continue.","bit-integrations")});return}n.mainAction!==""&&g(3)};return t.jsxs("div",{children:[t.jsx(M,{snack:r,setSnackbar:o}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(E,{step:3,active:f})}),t.jsx(W,{formID:y,affiliateConf:n,setAffiliateConf:h,step:f,setStep:g,isLoading:c,setIsLoading:b,setSnackbar:o}),t.jsxs("div",{className:"btcd-stp-page",style:A({},f===2&&{width:900,height:"auto",overflow:"visible"}),children:[t.jsx(O,{formFields:s,handleInput:_=>U(_,n,h),affiliateConf:n,setAffiliateConf:h,isLoading:c,setIsLoading:b,setSnackbar:o,allIntegURL:d,isInfo:x,edit:p}),t.jsxs("button",{onClick:()=>w(),disabled:!n.statusId||!n.referralId||c,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[e("Next","bit-integrations")," ",t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsx(H,{step:f,saveConfig:()=>K({flow:a,setFlow:i,allIntegURL:d,navigate:u,conf:n,setIsLoading:b,setSnackbar:o}),isLoading:c,dataConf:n,setDataConf:h,formFields:s})]})}export{bt as default};
