var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var f=(i,l,o)=>l in i?I(i,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[l]=o,r=(i,l)=>{for(var o in l||(l={}))L.call(l,o)&&f(i,o,l[o]);if(j)for(var o of j(l))z.call(l,o)&&f(i,o,l[o]);return i};import{i as F,r as M,a as O,q as S,_ as a,j as e,a1 as T,ao as R,E as H,W as P,d as B,s as V,b as q,bg as W,h as E,aO as Y,f as G,c as J,A as y,z as K,u as Q,B as U,D as X,F as u,bs as N,H as w,O as Z}from"./main-343.js";import{L as ee}from"./bf-241-329.js";import{S as se}from"./bf-175-330.js";import{t as _}from"./bf-974-82.js";import{g as C}from"./bf-649-79.js";import{F as D}from"./bf-90-70.js";import"./bf-594-113.js";function te({formID:i}){const[l,o]=F(Y),[s,m]=M.useState({show:!1}),{css:x}=O(),{pathname:d}=S(),g=t=>{const c=G(l,n=>{n.splice(t+1,0,{title:n[t].title,sub:n[t].sub,body:n[t].body}),n.push({updateTem:1})});o(c)},k=(t,c)=>{if(c.original.id){const n=J({formID:i,id:c.original.id},"bitforms_delete_mailtemplate").then(h=>{if(h!==void 0&&h.success){const b=y(l);b.splice(t,1),o(b)}});K.promise(n,{loading:"Deleting",success:"Successfully Deleted",error:"Error Occurred"})}else{const n=y(l);n.splice(t,1),o(n)}},p=()=>{s.show=!1,m(r({},s))},$=(t,c)=>{s.btnTxt=a("Delete"),s.body=a("Are you sure to delete this template"),s.btnClass="",s.action=()=>{k(t,c),p()},s.show=!0,m(r({},s))},v=t=>{s.btnTxt=a("Duplicate"),s.body=a("Are you sure to duplicate this template?"),s.btnClass="blue",s.action=()=>{g(t),p()},s.show=!0,m(r({},s))},A=[{Header:a("Template Name"),accessor:"title",Cell:t=>e.jsx(T,{to:`${d}/${t.row.index}`,children:e.jsx("b",{children:t.cell.value})})},{Header:a("Action"),accessor:"action",Cell:t=>e.jsxs(e.Fragment,{children:[e.jsx(C,{onClick:()=>v(t.row.index),className:"icn-btn mr-2 tooltip pos-rel",style:{"--tooltip-txt":`'${a("Duplicate")}'`},children:e.jsx(R,{size:"22"})}),e.jsx(T,{to:`${d}/${t.row.index}`,className:"icn-btn mr-2 flx flx-center tooltip pos-rel",style:{"--tooltip-txt":`'${a("Edit")}'`},children:e.jsx(H,{size:"22"})}),e.jsx(C,{onClick:()=>$(t.row.index,t.row),className:"icn-btn tooltip pos-rel",style:{"--tooltip-txt":`'${a("Delete")}'`},children:e.jsx(P,{size:"21"})})]})}];return e.jsxs("div",{className:"w-7",children:[e.jsx(B,{show:s.show,close:p,btnTxt:s.btnTxt,btnClass:s.btnClass,body:s.body,action:s.action}),e.jsx("h2",{children:a("Email Templates")}),e.jsxs("h5",{children:[a("How to setup Email Templates & Send Email Notification:")," ",e.jsx("a",{href:_.emailTemplates.link,target:"_blank",rel:"noreferrer",className:"yt-txt ml-1 mr-1",children:a("YouTube")}),e.jsx("a",{href:_.emailTemplatesDoc.link,target:"_blank",rel:"noreferrer",className:"doc-txt",children:a("Documentation")})]}),e.jsxs("div",{className:"",children:[e.jsxs(V,{to:`${d}/new`,className:`${x(q.btn)} blue`,children:[e.jsx(ee,{size:"20"})," ",a("Add New Template")]}),l.length>0?e.jsx(W,{height:"60vh",className:"btcd-neu-table mr-1",columns:A,data:l}):e.jsxs("div",{className:x(E.btcdEmpty,E.txCenter),children:[e.jsx(se,{size:"50"}),a("Empty")]})]})]})}const le=N(()=>w(()=>import("./bf-97-327.js"),["./bf-97-327.js","./main-343.js","./main-343.css","./bf-649-79.js","./bf-899-409.css"],import.meta.url),{fallback:e.jsx(D,{})}),ae=N(()=>w(()=>import("./bf-644-328.js"),["./bf-644-328.js","./main-343.js","./main-343.css","./bf-649-79.js","./bf-899-409.css"],import.meta.url),{fallback:e.jsx(D,{})});function ue(){const i=Q(Z);return e.jsx(U,{children:e.jsxs(X,{children:[e.jsx(u,{index:!0,element:e.jsx(te,{formID:i})}),e.jsx(u,{path:"/new",element:e.jsx(le,{})}),e.jsx(u,{path:"/:id",element:e.jsx(ae,{})})]})})}export{ue as default};
