import{c as e,b as s,F as t}from"../types/nile-file-preview.enums.esm.js";const n=s=>new Promise(((t,n)=>{const o=new FileReader;s?o.readAsDataURL(s):n(e.NO_FILE_SELECTED),o.onload=()=>{const e=o.result;t(e)},o.onerror=s=>{n(e.UNABLE_TO_GENEARTE_URL)}})),o=(e,t,n)=>{t.target&&t.target.dispatchEvent(new CustomEvent(s.NILE_REMOVE,{detail:{value:e,url:n},bubbles:!0,composed:!0}))},a=(n,o,a)=>{o.target&&(o.target.dispatchEvent(new CustomEvent(s.NILE_CANCEL_UPLOAD,{detail:{file:n},bubbles:!0,composed:!0})),a.state=t.ERROR,a.errorMessage=e.UPLOAD_CANCEL,a.requestUpdate())},r=e=>{const s=e/1e3,t=e/1e6,n=e/1e9;return n>=1?n.toFixed(2)+" GB":t>=1?t.toFixed(2)+" MB":s>=1?s.toFixed(2)+" KB":e+" B"},i=(e,s)=>{if(s)return e.name.split(".").pop()||"";return((e.type||"").split("/")[1]||"").toUpperCase()},l=e=>{("vertical"===e.variant&&e.errorMessage.length>34||"horizontal"===e.variant&&e.errorMessage.length>96)&&(e.isStringTruncated=!0,e.requestUpdate())},m=e=>new Promise((s=>{const t=new Blob([e],{type:e.type}),n=URL.createObjectURL(t),o=new Image;o.onload=()=>{URL.revokeObjectURL(n),s(!0)},o.onerror=()=>{URL.revokeObjectURL(n),s(!1)},o.src=n}));export{n as a,a as c,r as f,i as g,m as i,o as r,l as t};
