var T=Object.defineProperty;var f=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var b=(a,s,e)=>s in a?T(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e,u=(a,s)=>{for(var e in s||(s={}))V.call(s,e)&&b(a,e,s[e]);if(f)for(var e of f(s))F.call(s,e)&&b(a,e,s[e]);return a};import{j as t,_ as d}from"./main.2.9.0.js";import{g as I,u as A,b as r}from"./react-router.DMwpH23k.js";import{S as L}from"./SnackMsg.DYSD96P4.js";import{S as _}from"./Steps.BYe8zHkm.js";import{g as M}from"./Integrations.DL8wqGct.js";import{c as $,C as q}from"./CustomFunctionHelper.CtoiCI7A.js";import B from"./CustomFuncEditor.DzEqv_Ss.js";import{T as K}from"./TutorialLink.CFG7bS5c.js";import{y as P}from"./Note.NSUdvR3c.js";import"./react-vendor.P7K3d6op.js";import"./CopyIcn.CEA_lFLo.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";var p,h;function R(){if(h)return p;h=1;function a(){const s=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let n=0;n<36;n++)n===8||n===13||n===18||n===23?e[n]="-":e[n]=s[Math.ceil(Math.random()*s.length-1)];return e.join("")}return p=a,p}var U=R(),z=I(U);const at=({formFields:a,setFlow:s,flow:e,allIntegURL:n})=>{const x=A(),[c,v]=r.useState(1),[j,N]=r.useState(!1),[o,y]=r.useState({}),[S,C]=r.useState({show:!1}),w=z(),[i,m]=r.useState({name:"Custom Action",type:"CustomAction",randomFileName:w,defaultValue:`<?php if (!defined('ABSPATH')) {exit;} 
    
  function yourFunctionName($trigger){
    $trigger['yourKey'];
    //write here your custom function
  }  
  yourFunctionName($trigger);`,value:""});r.useEffect(()=>{const l=u({},i);delete l.isValid,m(u({},l))},[i==null?void 0:i.value]);const k=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),v(2)},E=l=>{const g=u({},i);g[l.target.name]=l.target.value,m(g)};return t.jsxs("div",{children:[t.jsx(L,{snack:S,setSnackbar:C}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(_,{step:2,active:c})}),t.jsxs("div",{className:"btcd-stp-page",style:u({},c===1&&{width:"70%",height:"auto",overflow:"visible"}),children:[t.jsx(K,{linkKey:"customAction"}),t.jsxs("div",{className:"d-flx my-3",children:[t.jsx("div",{className:"wdt-200 d-in-b mt-3",children:t.jsx("b",{children:d("Integration Name:","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp mt-1",onChange:E,name:"name",value:i.name,type:"text",placeholder:d("Integration Name...","bit-integrations")})]}),t.jsx(B,{customActionConf:i,setCustomActionConf:m,formFields:a}),t.jsxs("button",{onClick:()=>$(i,m,o,y),disabled:!i.value||(o==null?void 0:o.validate),className:"btn f-left btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:[i!=null&&i.isValid?d("Validated ✔","bit-integrations"):d("Validated","bit-integrations"),(o==null?void 0:o.validate)&&t.jsx(P,{size:"20",clr:"#022217",className:"ml-2"})]}),t.jsxs("button",{onClick:()=>k(),disabled:!i.isValid,className:"btn f-right btcd-btn-lg purple sh-sm flx mt-5",type:"button",children:[d("Next","bit-integrations"),"  ",t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsx("div",{className:"btcd-stp-page",style:{width:c===2&&"100%",height:c===2&&"auto"},children:t.jsx(q,{step:c,saveConfig:()=>M(e,s,n,i,x,"","",N),isLoading:j})})]})};export{at as default};
