text: "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FilePondPluginFileEncode=t()}(void 0,function(){var e=function(){self.onmessage=function(t){e(t.data.message,function(e){self.postMessage({id:t.data.id,message:e})})};var e=function(e,t){var n=e.file,i=new FileReader;i.onloadend=function(){t(i.result.replace("data:","").replace(/^.+,/,""))},i.readAsDataURL(n)}},t=function(t){var n=t.addFilter,i=t.utils,a=i.Type,o=i.createWorker,r=i.createRoute,d=i.isFile,f=function(t){var n=t.name,i=t.file;return new Promise(function(t){var a=o(e);a.post({file:i},function(e){t({name:n,data:e}),a.terminate()})})},u=[];return n("DID_CREATE_ITEM",function(e,t){(0,t.query)("GET_ALLOW_FILE_ENCODE")&&(e.extend("getFileEncodeBase64String",function(){return u[e.id]&&u[e.id].data}),e.extend("getFileEncodeDataURL",function(){return"data:".concat(e.fileType,";base64,").concat(u[e.id].data)}))}),n("SHOULD_PREPARE_OUTPUT",function(e,t){var n=t.query;return new Promise(function(e){e(n("GET_ALLOW_FILE_ENCODE"))})}),n("COMPLETE_PREPARE_OUTPUT",function(e,t){var n=t.item,i=t.query;return new Promise(function(t){if(!i("GET_ALLOW_FILE_ENCODE")||!d(e)&&!Array.isArray(e))return t(e);u[n.id]={metadata:n.getMetadata(),data:null},Promise.all((e instanceof Blob?[{name:null,file:e}]:e).map(f)).then(function(i){u[n.id].data=e instanceof Blob?i[0].data:i,t(e)})})}),n("CREATE_VIEW",function(e){var t=e.is,n=e.view,i=e.query;t("file-wrapper")&&i("GET_ALLOW_FILE_ENCODE")&&n.registerWriter(r({DID_PREPARE_OUTPUT:function(e){var t=e.root,n=e.action;if(!i("IS_ASYNC")){var a=i("GET_ITEM",n.id);if(a){var o=u[a.id],r=o.metadata,d=o.data,f=JSON.stringify({id:a.id,name:a.file.name,type:a.file.type,size:a.file.size,metadata:r,data:d});t.ref.data?t.ref.data.value=f:t.dispatch("DID_DEFINE_VALUE",{id:a.id,value:f})}}},DID_REMOVE_ITEM:function(e){var t=e.action,n=i("GET_ITEM",t.id);n&&delete u[n.id]}}))}),{options:{allowFileEncode:[!0,a.BOOLEAN]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t})),t});