import{F as c,G as d,I as m,U as f,k as s,la as g,q as l,z as p}from"./chunk-PGS4AHIT.js";g();var u=class o{static{this.mimeTypes={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",odt:"application/vnd.oasis.opendocument.text",txt:"text/plain",csv:"text/csv",other:"application/octet-stream"}}static{this.imgMimeTypes=[this.mimeTypes.jpg,this.mimeTypes.jpeg,this.mimeTypes.png]}static{this.documentMimeTypes=[this.mimeTypes.docx,this.mimeTypes.odt]}static getMimeType(t){let e=t.split(".").pop()?.toLowerCase();return e&&this.mimeTypes[e]?this.mimeTypes[e]:"application/octet-stream"}static isImage(t){return t?this.imgMimeTypes.indexOf(t)>-1:!1}static isPDF(t){return t?t===this.mimeTypes.pdf:!1}static isDocument(t){return t?this.documentMimeTypes.indexOf(t)>-1:!1}static isSheet(t){return t?t===this.mimeTypes.xlsx:!1}static isCSV(t){return t?t===this.mimeTypes.csv:!1}static isText(t){return t?t===this.mimeTypes.txt:!1}static isOther(t){return t?t===this.mimeTypes.other:!1}static getFileType(t){return o.isPDF(t)?"pdf":o.isImage(t)?"image":o.isDocument(t)?"docx":o.isSheet(t)?"xlsx":o.isCSV(t)?"csv":"other"}static downloadFileFromUrl(t,e){if(!t)return;let i=document.createElement("a");i.href=t,i.download=e??"",i.click()}static downloadFileFromData(t,e){let i=o.createBlobUrl(t,e);i&&this.downloadFileFromUrl(i,e)}static createBlobUrl(t,e){var i=o.getMimeType(e);return URL.createObjectURL(new Blob([t],{type:i}))}static getFileByteArray(t){return new l(e=>{let i=new FileReader;i.readAsArrayBuffer(t),i.onload=()=>{let r=i.result;e.next(new Uint8Array(r)),e.complete()},i.onerror=r=>{console.error("Error reading file",r)}})}static getBase64File(t){return o.getFileByteArray(t).pipe(d(e=>{let i="";for(let r=0;r<e.length;r++)i+=String.fromCharCode(e[r]);return{name:t.name,byteArray:btoa(i)}}))}static getBase64Files(t){return p(Array.from(t)).pipe(m(e=>o.getBase64File(e)),f())}static fileToByteArray(t){return s(this,null,function*(){return new Uint8Array(yield t.arrayBuffer())})}static fileToBase64(t){return s(this,null,function*(){let e=yield this.fileToByteArray(t),i="",r=32768;for(let n=0;n<e.length;n+=r){let a=e.subarray(n,n+r);i+=String.fromCharCode(...a)}return btoa(i)})}static arrayBufferToBase64(t){let e="",i=new Uint8Array(t),r=i.byteLength;for(let n=0;n<r;n++)e+=String.fromCharCode(i[n]);return btoa(e)}static tryDetectMimeType(t,e="application/octet-stream"){let i={"/9j/":"image/jpeg",iVBORw0KGgo:"image/png",R0lGOD:"image/gif",JVBERi0:"application/pdf"};for(let[r,n]of Object.entries(i))if(t.startsWith(r))return n;return e}static base64ToDataUrl(t,e=o.mimeTypes.other){return`data:${this.tryDetectMimeType(t,e)};base64,${t}`}static downloadContent(t,e,i=this.mimeTypes.txt){if(!e)return;let r=new Blob([e],{type:i}),n=window.URL.createObjectURL(r),a=document.createElement("a");a.href=n,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),window.URL.revokeObjectURL(n)}static openPdfInNewWindowWithLoading(t){return s(this,null,function*(){let e=window.open("","_blank");if(e){let r="/Content/Animations/Trademark/Printing.gif";e.document.documentElement.innerHTML=`
                <html><body>
                <div style="width:100%;height:100%;position:relative;margin:0;padding:0;background-color:white"><div style="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);"><div style="position: relative;"><img style="min-width: 300px;" src="${window.location.origin+r}"><span style="position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 0%); display:inline-block; width:100%; text-align: center; font-family: sans-serif; color:#636363;"></span></div></div></div>
                </body></html>
            `;var i=yield c(t instanceof Promise?yield t:t);if(i===null)return e?.close(),!1;let a=new Blob([i],{type:"application/pdf"}),y=URL.createObjectURL(a);e.document.close(),e.focus(),e.location.href=y}else{var i=yield c(t instanceof Promise?yield t:t);if(i===null)return!1;let r=new Blob([i],{type:"application/pdf"}),n=URL.createObjectURL(r),a=document.createElement("a");a.href=n,a.download="document.pdf",a.click(),window.URL.revokeObjectURL(n)}return!0})}};export{u as a};
