var Q=Object.defineProperty,U=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var Y=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var j=(n,s,o)=>s in n?Q(n,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[s]=o,c=(n,s)=>{for(var o in s||(s={}))Y.call(s,o)&&j(n,o,s[o]);if(b)for(var o of b(s))G.call(s,o)&&j(n,o,s[o]);return n},T=(n,s)=>U(n,W(s));import{i as J,r as K,a as X,D as Z,g as ee,ap as te,u as $,q as se,_ as l,j as e,a1 as y,am as ae,E as oe,Q as le,d as ne,I as _,W as ie,bm as re,h as w,cd as ce,f as P,aR as de,cc as me,$ as pe,c as ue,H as g,V as fe,A as xe,B as x,bx as v,F as D,N as he}from"./main-634.js";import{F as k}from"./bf-400-72.js";import{L as be}from"./bf-29-403.js";import{S as je}from"./bf-504-404.js";import{t as C}from"./bf-275-83.js";import{B as N,P as Te}from"./bf-25-81.js";import"./bf-438-114.js";function ye({formID:n}){const[s,o]=J(de),[a,p]=K.useState({show:!1}),{css:E}=X(),F=Z(),{formType:A}=ee(),I=te(me),S=$(pe);let{pdf:u}=S.allFormSettings;u===void 0&&(u={direction:"ltr",font:{name:"DejaVuSansCondensed",fontFamily:"dejavusanscondensed"},fontColor:"#000000",fontFamily:"dejavusanscondensed",fontSize:10,orientation:"p",paperSize:"a4",pdfFileName:"",watermark:{}});const{pathname:h}=se(),z=t=>{const r=P(s,i=>{const{title:d,body:m,setting:B}=i[t],q=`${d} - Copy`;i.splice(t+1,0,{title:q,body:m,setting:B}),i.push({updateTem:1})});o(r)},L=(t,r)=>{if(r.original.id){const i=ue({formID:n,id:r.original.id},"bitforms_delete_pdf_template").then(d=>{if(d!==void 0&&d.success){const m=g(s);m.splice(t,1),o(m)}});fe.promise(i,{loading:"Deleting",success:"Successfully Deleted",error:"Error Occurred"})}else{const i=g(s);i.splice(t,1),o(i)}},f=()=>{a.show=!1,p(c({},a))},R=(t,r)=>{a.btnTxt=l("Delete"),a.body=l("Are you sure to delete this template"),a.btnClass="",a.action=()=>{L(t,r),f()},a.show=!0,p(c({},a))},M=t=>{a.btnTxt=l("Duplicate"),a.body=l("Are you sure to duplicate this template?"),a.btnClass="blue",a.action=()=>{z(t),f()},a.show=!0,p(c({},a))},O={title:"Untitled PDF Template",setting:T(c({},u),{password:{static:!0,pass:""}}),body:"${bf_all_data}"},V=()=>{if(!_){I(c({show:!0},ce.pdfProInstalledAlert));return}const t=s.length,r=P(s,i=>{i.push(O),i.push({updateTem:1})});o(r),F(`/form/settings/${A}/${n}/pdf-templates/${t}`)},H=[{Header:l("Template Name"),accessor:"title",Cell:t=>e.jsx(y,{to:`${h}/${t.row.index}`,children:e.jsx("b",{children:t.cell.value})})},{Header:l("Action"),accessor:"action",Cell:t=>e.jsxs(e.Fragment,{children:[e.jsx(N,{onClick:()=>M(t.row.index),className:"icn-btn mr-2 tooltip pos-rel",style:{"--tooltip-txt":`'${l("Duplicate")}'`},children:e.jsx(ae,{size:"22"})}),e.jsx(y,{to:`${h}/${t.row.index}`,className:"icn-btn mr-2 flx flx-center tooltip pos-rel",style:{"--tooltip-txt":`'${l("Edit")}'`},children:e.jsx(oe,{size:"22"})}),e.jsx(N,{onClick:()=>R(t.row.index,t.row),className:"icn-btn tooltip pos-rel",style:{"--tooltip-txt":`'${l("Delete")}'`},children:e.jsx(le,{size:"21"})})]})}];return e.jsxs("div",{className:"w-7 pos-rel",children:[e.jsx(ne,{show:a.show,close:f,btnTxt:a.btnTxt,btnClass:a.btnClass,body:a.body,action:a.action}),!_&&e.jsx(Te,{style:{height:"110%",left:-53,width:"110%"}}),e.jsx("h2",{children:l("PDF Templates")}),e.jsxs("h5",{className:"mt-3",children:[l("How to setup PDF Templates:"),e.jsx("a",{href:C.pdfTemplate.link,target:"_blank",rel:"noreferrer",className:"yt-txt ml-1 mr-1",children:l("YouTube")}),e.jsx("a",{href:C.pdfTemplateDoc.link,target:"_blank",rel:"noreferrer",className:"doc-txt",children:l("Documentation")})]}),e.jsxs("div",{className:"",children:[e.jsxs(ie,{size:"sm",onClick:V,variant:"tertiary",children:[e.jsx(be,{size:"20"})," ",l("Add New Template")]}),s.length>0?e.jsx(re,{height:"60vh",className:"btcd-neu-table mr-1",columns:H,data:s.sort((t,r)=>r.id-t.id)}):e.jsxs("div",{className:E(w.btcdEmpty,w.txCenter),children:[e.jsx(je,{size:"50"}),l("Empty")]})]})]})}const _e=v(()=>D(()=>import("./bf-270-405.js"),["./bf-270-405.js","./main-634.js","./main-634.css","./bf-25-81.js","./bf-831-476.css","./bf-297-103.js"],import.meta.url),{fallback:e.jsx(k,{})}),we=v(()=>D(()=>import("./bf-175-406.js"),["./bf-175-406.js","./main-634.js","./main-634.css","./bf-25-81.js","./bf-831-476.css","./bf-297-103.js","./bf-400-72.js","./bf-438-114.js","./bf-542-475.css"],import.meta.url),{fallback:e.jsx(k,{})});function Ee(){const n=$(he);return e.jsxs(xe,{children:[e.jsx(x,{index:!0,element:e.jsx(ye,{formID:n})}),e.jsx(x,{path:"/new",element:e.jsx(_e,{})}),e.jsx(x,{path:"/:id",element:e.jsx(we,{})})]})}export{Ee as default};
