File: /var/www/html/wordpress/wp-content/plugins/bit-integrations/assets/bi.181.332.js
var K=Object.defineProperty;var C=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var q=(m,o,c)=>o in m?K(m,o,{enumerable:!0,configurable:!0,writable:!0,value:c}):m[o]=c,g=(m,o)=>{for(var c in o||(o={}))Q.call(o,c)&&q(m,c,o[c]);if(C)for(var c of C(o))V.call(o,c)&&q(m,c,o[c]);return m};import{r as u,u as X,o as Y,f as Z,j as t}from"./main-685.js";import{d as tt,c as N,_ as s}from"./bi.878.0.js";import{aj as j}from"./bi.451.455.js";import{S as et}from"./bi.674.13.js";import{S as st}from"./bi.347.1012.js";import{r as it,F as at,a as nt,C as rt,c as lt,b as ot,d as ct,e as dt}from"./bi.902.809.js";import{p as I}from"./bi.55.779.js";import{I as mt,g as pt}from"./bi.776.3.js";import{T as M,t as ut}from"./bi.703.796.js";import{P as bt}from"./bi.463.750.js";import"./bi.327.9.js";import"./bi.601.11.js";import"./bi.825.14.js";import"./bi.768.751.js";import"./bi.666.752.js";function It({formFields:m,setFlow:o,flow:c,allIntegURL:P}){var k;const[_,L]=u.useState([]),[x,y]=u.useState([]),S=X(),{formID:T}=Y(),[w,v]=u.useState(!1),[f,A]=u.useState(1),[D,p]=u.useState({show:!1}),[E,W]=u.useState({fields:[],files:[]}),[$,z]=u.useState({fields:[],files:[]}),[J,O]=u.useState({fields:[],files:[]}),{postCreation:d}=ut,R=Z(tt),{isPro:U}=R,[a,b]=u.useState({name:"WP Post Creation",type:"WP Post Creation",post_map:[{post_author:"logged_in_user"}],acf_map:[{}],acf_file_map:[{}],metabox_map:[{}],metabox_file_map:[{}],je_cpt_meta_map:[{}],je_cpt_file_map:[{}]}),h=(e,i)=>{const n=g({},a);n[e]=i,b(n)};u.useEffect(()=>{N({},"user/list").then(i=>{const{data:n}=i;L(n)}),N({},"post-types/list").then(i=>{const{data:n}=i;y(n)});const e=g({},a);e.post_map=I.filter(i=>i.required).map(i=>({formField:"",postField:i.key,required:i.required})),b(e)},[]);const B=(e,i)=>{const n=g({},a);n[e]=i,N({post_type:i},"customfield/list").then(H=>{const{data:r}=H;W({fields:r.acf_fields,files:r.acf_files}),z({fields:r.mb_fields,files:r.mb_files}),O({fields:r.je_cpt_fields,files:r.je_cpt_files}),r!=null&&r.acf_fields&&(n.acf_map=r.acf_fields.filter(l=>l.required).map(l=>({formField:"",acfField:l.key,required:l.required})),n.acf_map.length<1&&(n.acf_map=[{}])),r!=null&&r.mb_fields&&(n.metabox_map=r.mb_fields.filter(l=>l.required).map(l=>({formField:"",metaboxField:l.key,required:l.required})),n.metabox_map.length<1&&(n.metabox_map=[{}])),r!=null&&r.je_cpt_fields&&(n.je_cpt_meta_map=r.je_cpt_fields.filter(l=>l.required).map(l=>({formField:"",jeCPTField:l.key,required:l.required}))),n.je_cpt_meta_map.length<1&&(n.je_cpt_meta_map=[{}])}),b(n)},F=e=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!lt(a)){p({show:!0,msg:s("Please map mandatory fields","bit-integrations")});return}if(!a.post_type){p({show:!0,msg:s("Post Type can't be empty","bit-integrations")});return}if(!a.post_status){p({show:!0,msg:s("Post Status can't be empty","bit-integrations")});return}if(e===3){if(!ot(a)){p({show:!0,msg:s("Please map mandatory fields","bit-integrations")});return}if(!ct(a)){p({show:!0,msg:s("Please map mandatory fields","bit-integrations")});return}if(!dt(a)){p({show:!0,msg:s("Please map mandatory fields","bit-integrations")});return}}A(e)},G=()=>{v(!0),pt(c,o,P,a,S,"","",v).then(i=>{var n;i.success?(p({show:!0,msg:(n=i.data)==null?void 0:n.msg}),S(P)):p({show:!0,msg:i.data||i})})};return t.jsxs("div",{children:[t.jsx(et,{snack:D,setSnackbar:p}),(d==null?void 0:d.youTubeLink)&&t.jsx(M,{title:"WP Post Creation",youTubeLink:d==null?void 0:d.youTubeLink}),(d==null?void 0:d.docLink)&&t.jsx(M,{title:"WP Post Creation",docLink:d==null?void 0:d.docLink}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(st,{step:3,active:f})}),t.jsxs("div",{className:"btcd-stp-page",style:{width:f===1&&900,height:f===1&&"auto"},children:[t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:s("Integration Name","bit-integrations")})}),t.jsx("input",{className:"btcd-paper-inp w-5 mt-1",onChange:e=>h(e.target.name,e.target.value),name:"name",value:a.name,type:"text",placeholder:s("Integration Name...","bit-integrations")}),t.jsxs("div",{className:"mt-3 flx",children:[t.jsx("b",{children:s("Post Type","bit-integrations")}),t.jsx(j,{width:250,icnSize:17,className:"ml-2",children:t.jsxs("div",{className:"txt-body",children:[s("Select one of the defined WordPress post types Or custom post types for the post","bit-integrations"),t.jsx("br",{})]})})]}),t.jsxs("div",{children:[t.jsxs("select",{name:"post_type",onChange:e=>B(e.target.name,e.target.value),className:"btcd-paper-inp w-5 mt-1",children:[t.jsx("option",{disabled:!0,selected:!0,children:"bit-integrations"}),x==null?void 0:x.map((e,i)=>t.jsx("option",{value:e==null?void 0:e.id,children:e==null?void 0:e.title},`acf-${i*2}`))]}),t.jsx("button",{onClick:()=>it(x,y),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${s("Refresh Post Types","bit-integrations")}'`},type:"button",children:"↻"})]}),t.jsxs("div",{className:"mt-3",children:[t.jsx("b",{children:s("Post Status","bit-integrations")}),t.jsx(j,{width:250,icnSize:17,className:"ml-2",children:t.jsxs("div",{className:"txt-body",children:[s("Select the status for the post. If published status is selected and the post date is in the future, it will automatically be changed to scheduled","bit-integrations"),t.jsx("br",{})]})})]}),t.jsxs("select",{name:"post_status",onChange:e=>h(e.target.name,e.target.value),className:"btcd-paper-inp w-5 mt-2",children:[t.jsx("option",{disabled:!0,selected:!0,children:s("Select Status","bit-integrations")}),t.jsx("option",{value:"publish",children:s("Publish","bit-integrations")}),t.jsx("option",{value:"draft",children:s("Draft","bit-integrations")}),t.jsx("option",{value:"auto-draft",children:s("Auto-Draft","bit-integrations")}),t.jsx("option",{value:"private",children:s("Private","bit-integrations")}),t.jsx("option",{value:"pending",children:s("Pending","bit-integrations")})]}),t.jsxs("div",{className:"mt-3 flx",children:[t.jsx("b",{children:s("Author","bit-integrations")}),t.jsx(j,{width:250,icnSize:17,className:"ml-2",children:t.jsxs("div",{className:"txt-body",children:["bit-integrations",t.jsx("br",{})]})})]}),t.jsx("div",{children:t.jsxs("select",{name:"post_author",onChange:e=>h(e.target.name,e.target.value),className:"btcd-paper-inp w-5 mt-2",children:[t.jsx("option",{disabled:!0,selected:!0,children:s("Select Author","bit-integrations")}),t.jsx("option",{value:"logged_in_user",children:s("Logged In User","bit-integrations")}),_==null?void 0:_.map((e,i)=>t.jsx("option",{value:e.ID,children:e.display_name},`acf-${i*2}`))]})}),t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:s("Comment Status","bit-integrations")})}),t.jsxs("select",{name:"comment_status",onChange:e=>h(e.target.name,e.target.value),className:"btcd-paper-inp w-5 mt-2",children:[t.jsx("option",{disabled:!0,selected:!0,children:s("Select Status","bit-integrations")}),t.jsx("option",{value:"open",children:s("Open","bit-integrations")}),t.jsx("option",{value:"closed",children:s("Closed","bit-integrations")})]}),t.jsxs("div",{className:"mt-3",children:[t.jsx("b",{children:t.jsx(bt,{title:s("Add Post Tags","bit-integrations")})}),t.jsx(j,{width:250,icnSize:17,className:"ml-2",children:t.jsxs("div",{className:"txt-body",children:[s("Use commas to separate multiple tags. Example: tag1, tag2, tag3","bit-integrations"),t.jsx("br",{})]})})]}),t.jsx("input",{className:"btcd-paper-inp w-5 mt-2 ",onChange:e=>h(e.target.name,e.target.value),name:"post_tags",value:a.post_tags,type:"text",placeholder:s("Add Post Tags...","bit-integrations"),disabled:!U}),t.jsxs("div",{children:[t.jsx("div",{className:"mt-3 mb-1",children:t.jsx("b",{children:s("Post Field Mapping","bit-integrations")})}),t.jsx("div",{className:"btcd-hr"}),t.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[t.jsx("div",{className:"txt-dp",children:t.jsx("b",{children:s("Form Fields","bit-integrations")})}),t.jsx("div",{className:"txt-dp",children:t.jsx("b",{children:s("Post Fields","bit-integrations")})})]})]}),(k=a==null?void 0:a.post_map)==null?void 0:k.map((e,i)=>t.jsx(at,{i,type:"post",field:e,formFields:m,postConf:a,setPostConf:b,customFields:I},`analytics-m-${i+9}`)),t.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:t.jsx("button",{onClick:()=>nt("post_map",a.post_map.length,a,b),className:"icn-btn sh-sm",type:"button",children:"+"})}),t.jsxs("button",{onClick:()=>F(2),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[s("Next","bit-integrations"),t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsxs("div",{className:"btcd-stp-page",style:g({},f===2&&{width:900,height:"auto",overflow:"visible"}),children:[t.jsx(rt,{formID:T,formFields:m,handleInput:e=>h(e,a),postConf:a,setPostConf:b,isLoading:w,setIsLoading:v,setSnackbar:p,acfFields:E,mbFields:$,jeCPTFields:J}),t.jsxs("button",{onClick:()=>F(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[s("Next","bit-integrations"),t.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),t.jsx(mt,{step:f,saveConfig:()=>G(),isLoading:w,dataConf:a,setDataConf:b,formFields:m})]})}export{It as default};