File: /var/www/html/wordpress/wp-content/plugins/bit-integrations/assets/bi.751.45.js
var B=Object.defineProperty;var C=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var I=(c,r,o)=>r in c?B(c,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):c[r]=o,b=(c,r)=>{for(var o in r||(r={}))G.call(r,o)&&I(c,o,r[o]);if(C)for(var o of C(r))H.call(r,o)&&I(c,o,r[o]);return c};import{r as p,u as K,o as Q,e as k,f as M,j as e}from"./main-685.js";import{e as V,f as X,$ as Y,d as Z,c as x,_ as i}from"./bi.878.0.js";import{y as ee,aj as g}from"./bi.451.455.js";import{p as te}from"./bi.55.779.js";import{S as se}from"./bi.674.13.js";import{S as ie,I as ae,g as ne}from"./bi.776.3.js";import{r as le,F as re,a as de,C as oe,c as ce,b as me,d as pe,e as he}from"./bi.902.809.js";import{P as ue}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 Ie({allIntegURL:c}){var w;const[r,o]=p.useState([]),[f,v]=p.useState([]),q=K(),{formID:$,id:D}=Q(),[s,h]=k(V),j=M(X),[N,A]=k(Y),[F,_]=p.useState(!1),[E,m]=p.useState({show:!1}),[z,P]=p.useState({fields:[],files:[]}),[R,y]=p.useState({fields:[],files:[]}),[L,S]=p.useState({fields:[],files:[]}),T=M(Z),{isPro:U}=T,u=(t,n)=>{const a=b({},s);a[t]=n,h(a)};p.useEffect(()=>{const t=ee(b({},s));x({},"user/list").then(n=>{const{data:a}=n;o(a)}),x({},"post-types/list").then(n=>{const{data:a}=n;v(a)}),x({post_type:s==null?void 0:s.post_type},"customfield/list").then(n=>{const{data:a}=n;P({fields:a.acf_fields,files:a.acf_files}),y({fields:a.mb_fields,files:a.mb_files}),S({fields:a.je_cpt_fields,files:a.je_cpt_files})}),h(t)},[]);const J=(t,n)=>{const a=b({},s);a[t]=n,x({post_type:n},"customfield/list").then(W=>{const{data:l}=W;P({fields:l.acf_fields,files:l.acf_files}),y({fields:l.mb_fields,files:l.mb_files}),S({fields:l.je_cpt_fields,files:l.je_cpt_files}),l!=null&&l.acf_fields&&(a.acf_map=l.acf_fields.filter(d=>d.required).map(d=>({formField:"",acfField:d.key,required:d.required})),a.acf_map.length<1&&(a.acf_map=[{}])),l!=null&&l.mb_fields&&(a.metabox_map=l.mb_fields.filter(d=>d.required).map(d=>({formField:"",metaboxField:d.key,required:d.required})),a.metabox_map.length<1&&(a.metabox_map=[{}])),l!=null&&l.je_cpt_fields&&(a.je_cpt_meta_map=l.je_cpt_fields.filter(d=>d.required).map(d=>({formField:"",jeCPTField:d.key,required:d.required}))),a.je_cpt_meta_map.length<1&&(a.je_cpt_meta_map=[{}])}),h(a)},O=()=>{if(!ce(s)){m({show:!0,msg:i("Please map mandatory fields","bit-integrations")});return}if(!me(s)){m({show:!0,msg:i("Please map mandatory fields","bit-integrations")});return}if(!pe(s)){m({show:!0,msg:i("Please map mandatory fields","bit-integrations")});return}if(!he(s)){m({show:!0,msg:i("Please map mandatory fields","bit-integrations")});return}_(!0),ne(N,A,c,s,q,D,1,_).then(n=>{n.success?m({show:!0,msg:n.data}):m({show:!0,msg:n.data||n})})};return e.jsxs("div",{children:[e.jsx(se,{snack:E,setSnackbar:m}),e.jsxs("div",{style:{width:900},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:i("Integration Name","bit-integrations")})}),e.jsx("input",{className:"btcd-paper-inp w-5 mt-1",onChange:t=>u(t.target.name,t.target.value),name:"name",value:s.name,type:"text",placeholder:i("Integration Name...","bit-integrations")}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(ie,{entity:N.triggered_entity,setSnackbar:m}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{children:i("Post Type","bit-integrations")}),e.jsx(g,{width:250,icnSize:17,className:"ml-2",children:e.jsxs("div",{className:"txt-body",children:[i("Select one of the defined WordPress post types Or custom post types for the post","bit-integrations"),e.jsx("br",{})]})})]}),e.jsxs("div",{children:[e.jsxs("select",{name:"post_type",value:s==null?void 0:s.post_type,onChange:t=>J(t.target.name,t.target.value),className:"btcd-paper-inp w-5 mt-1",children:[e.jsx("option",{disabled:!0,selected:!0,children:i("Select Post Type","bit-integrations")}),f==null?void 0:f.map((t,n)=>e.jsx("option",{value:t==null?void 0:t.id,children:t==null?void 0:t.title},`acf-${n*2}`))]}),e.jsx("button",{onClick:()=>le(f,v),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${i("Refresh Post Types","bit-integrations")}'`},type:"button",children:"↻"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("b",{children:i("Post Status","bit-integrations")}),e.jsx(g,{width:250,icnSize:17,className:"ml-2",children:e.jsxs("div",{className:"txt-body",children:[i("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"),e.jsx("br",{})]})})]}),e.jsxs("select",{name:"post_status",value:s==null?void 0:s.post_status,onChange:t=>u(t.target.name,t.target.value),className:"btcd-paper-inp w-5 mt-2",children:[e.jsx("option",{disabled:!0,selected:!0,children:i("Select Status","bit-integrations")}),e.jsx("option",{value:"publish",children:i("Publish","bit-integrations")}),e.jsx("option",{value:"draft",children:i("Draft","bit-integrations")}),e.jsx("option",{value:"auto-draft",children:i("Auto-Draft","bit-integrations")}),e.jsx("option",{value:"private",children:i("Private","bit-integrations")}),e.jsx("option",{value:"pending",children:i("Pending","bit-integrations")})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{children:i("Author","bit-integrations")}),e.jsx(g,{width:250,icnSize:17,className:"ml-2",children:e.jsxs("div",{className:"txt-body",children:[i("Select the user to be assigned to the post","bit-integrations"),e.jsx("br",{})]})})]}),e.jsx("div",{children:e.jsxs("select",{name:"post_author",value:s==null?void 0:s.post_author,onChange:t=>u(t.target.name,t.target.value),className:"btcd-paper-inp w-5 mt-2",children:[e.jsx("option",{disabled:!0,selected:!0,children:i("Select Author","bit-integrations")}),e.jsx("option",{value:"logged_in_user",children:i("Logged In User","bit-integrations")}),r==null?void 0:r.map((t,n)=>e.jsx("option",{value:t.ID,children:t.display_name},`acf-${n*2}`))]})}),e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:i("Comment Status","bit-integrations")})}),e.jsxs("select",{name:"comment_status",value:s==null?void 0:s.comment_status,onChange:t=>u(t.target.name,t.target.value),className:"btcd-paper-inp w-5 mt-2",children:[e.jsx("option",{disabled:!0,selected:!0,children:i("Select Status","bit-integrations")}),e.jsx("option",{value:"open",children:i("Open","bit-integrations")}),e.jsx("option",{value:"closed",children:i("Closed","bit-integrations")})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("b",{children:e.jsx(ue,{title:i("Add Post Tags","bit-integrations")})}),e.jsx(g,{width:250,icnSize:17,className:"ml-2",children:e.jsxs("div",{className:"txt-body",children:[i("Use commas to separate multiple tags. Example: tag1, tag2, tag3","bit-integrations"),e.jsx("br",{})]})})]}),e.jsx("input",{className:"btcd-paper-inp w-5 mt-2 ",onChange:t=>u(t.target.name,t.target.value),name:"post_tags",value:s.post_tags,type:"text",placeholder:i("Add Post Tags...","bit-integrations"),disabled:!U}),e.jsxs("div",{children:[e.jsx("div",{className:"mt-3 mb-1",children:e.jsx("b",{children:i("Post Field Mapping","bit-integrations")})}),e.jsx("div",{className:"btcd-hr"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:i("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:i("Post Fields","bit-integrations")})})]})]}),(w=s==null?void 0:s.post_map)==null?void 0:w.map((t,n)=>e.jsx(re,{i:n,type:"post",field:t,formFields:j,postConf:s,setPostConf:h,customFields:te},`analytics-m-${n+9}`)),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>de("post_map",s.post_map.length,s,h),className:"icn-btn sh-sm",type:"button",children:"+"})})]}),e.jsx("div",{children:e.jsx(oe,{formID:$,formFields:j,handleInput:t=>u(t,s),postConf:s,setPostConf:h,isLoading:F,setIsLoading:_,setSnackbar:m,acfFields:z,mbFields:R,jeCPTFields:L})}),e.jsx(ae,{edit:!0,saveConfig:O,isLoading:F,dataConf:s,setDataConf:h,formFields:j})]})}export{Ie as default};