import{j as C}from"./main.2.8.1.js";import{d as v}from"./react-router-dom.9mCuUg3q.js";/* empty css                */function _({id:m,value:u,formFields:o,SmartTagField:a,onChangeHandler:s,toolbarMnu:g,menubar:p,height:y,width:f,disabled:w,plugins:h,show:c=!0}){const n=`${m}-settings`;v.useEffect(()=>{var e;!c&&((e=window==null?void 0:window.tinymce)!=null&&e.get(n))?window.tinymce.get(n).remove():typeof tinymce!="undefined"?x():console.warn("TinyMCE is not loaded yet")},[c]);const b=e=>e.type==="signature"?`<img width="250" src="\${${e.name}}" alt="${e.name}" />`:`\${${e.name}}`,x=()=>{window&&window.tinymce&&window.tinymce.init({selector:`textarea#${n}`,charset:"UTF-8",entity_encoding:"raw",menubar:p,height:y||150,width:f||"100%",branding:!1,resize:"verticle",convert_urls:!1,theme:"modern",plugins:h||"directionality fullscreen image link media charmap hr lists textcolor colorpicker wordpress",toolbar:g||"formatselect | fontsizeselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify  | numlist bullist outdent indent  | removeformat toogleCode wp_code | addFormField | addSmartField",image_advtab:!0,default_link_target:"_blank",setup(e){e.on("Paste Change input Undo Redo",()=>{s(e.getContent())}),o&&e.addButton("addFormField",{text:"Form Fields ",tooltip:"Add Form Field Value in Message",type:"menubutton",icon:!1,menu:o==null?void 0:o.map(t=>{var i;return!((i=t==null?void 0:t.type)!=null&&i.match(/^(file-up|recaptcha|section|divider|image|advanced-file-up|)$/))&&{text:t.name,onClick(){e.insertContent(b(t))}}})}),a&&e.addButton("addSmartField",{text:"Smart Tag Fields",tooltip:"Add Smart Tag Field Value in Message",type:"menubutton",icon:!1,menu:a==null?void 0:a.map(t=>({text:t.label,onClick(){e.insertContent(`\${${t.name}}`)}}))}),e.addButton("toogleCode",{text:"</>",tooltip:"Toggle preview",icon:!1,onclick(t){const{$:i}=t.control,l=i(`#${n}`),r=i(e.iframeElement);if(l.value=e.getContent({source_view:!0}),r.toggleClass("btcd-mce-tinymce-hidden"),l.toggleClass("btcd-mce-tinymce-visible"),console.log("clicked",l,r),i("iframe.btcd-mce-tinymce-hidden").length>0)l.prependTo(".mce-edit-area");else{const d=document.getElementById(n);d instanceof HTMLTextAreaElement&&e.setContent(d.value)}}})}})};return c&&C.jsx("textarea",{id:n,className:"btcd-paper-inp mt-1 w-10",rows:5,value:u,onChange:e=>s(e.target.value),style:{width:"95.5%",height:"auto"},disabled:w})}export{_ as T};
