!function(){"use strict";tinymce.PluginManager.add("jdragndrop",(function(t){var e=function(e){if(e.dataTransfer.types.includes("Files"))return e.stopPropagation(),e.preventDefault(),t.contentAreaContainer.style.borderWidth="0",!1};function a(e){var a=new FileReader;a.onload=function(a){var n=a.target.result,r=n.indexOf("base64")+7,o=n.slice(r,n.length);!function(e,a){var n,r=t.settings.uploadUri+"&path="+t.settings.comMediaAdapter+t.settings.parentUploadFolder,o=((n={})[t.settings.csrfToken]="1",n.name=e,n.content=a,n.parent=t.settings.parentUploadFolder,n);Joomla.request({url:r,method:"POST",data:JSON.stringify(o),headers:{"Content-Type":"application/json"},onSuccess:function(e){var a;try{a=JSON.parse(e)}catch(e){t.windowManager.alert(Joomla.Text._("ERROR")+": {e}")}if(a.data&&a.data.path){var n,r=a.data,o=Joomla.getOptions("system.paths").rootFull,i=a.data.url.split(o);i.length>1?n=""+i[1]:r.url&&(n=r.url);var l=function(e){var a=e.getData(),o=a.altEmpty?' alt=""':"",i=a.altText?' alt="'+a.altText+'"':o,l=a.isLazy?' loading="lazy"':"",s=a.isLazy?' width="'+r.width+'"':"",d=a.isLazy?' height="'+r.height+'"':"";t.execCommand("mceInsertContent",!1,'<img src="'+n+'"'+i+l+s+d+"/>")};t.windowManager.open({title:Joomla.Text._("PLG_TINY_DND_ADDITIONALDATA"),body:{type:"panel",items:[{type:"input",name:"altText",label:Joomla.Text._("PLG_TINY_DND_ALTTEXT")},{type:"checkbox",name:"altEmpty",label:Joomla.Text._("PLG_TINY_DND_EMPTY_ALT")},{type:"checkbox",name:"isLazy",label:Joomla.Text._("PLG_TINY_DND_LAZYLOADED")}]},buttons:[{type:"cancel",text:"Cancel"},{type:"submit",name:"submitButton",text:"Save",primary:!0}],initialData:{altText:"",isLazy:!0,altEmpty:!1},onSubmit:function(t){l(t),t.close()},onCancel:function(t){l(t)}})}},onError:function(e){t.windowManager.alert("Error: "+e.statusText)}})}(e.name,o)},a.readAsDataURL(e)}tinyMCE.DOM.bind(document,"dragleave",e),t.on("remove",(function(){tinyMCE.DOM.unbind(document,"dragleave",e)})),t.on("dragenter",(function(t){if(t.dataTransfer.types.includes("Files"))return t.stopPropagation(),!1})),t.on("dragover",(function(e){if(e.dataTransfer.types.includes("Files"))return e.preventDefault(),t.contentAreaContainer.style.borderStyle="dashed",t.contentAreaContainer.style.borderWidth="5px",!1})),t.on("drop",(function(e){if(e.dataTransfer.types.includes("Files")){if(e.preventDefault(),e.dataTransfer.files.length>0)[].slice.call(e.dataTransfer.files).forEach((function(t){t.name.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/)&&a(t)}));t.contentAreaContainer.style.borderWidth="0"}}))}))}();