import{G as u,_ as b,c as d,l as f,r as l,s as p,u as m}from"./chunk-LU6Q5ONP.js";import{k as c}from"./chunk-5VMFMKJR.js";b();var y=class a{static{this.mimeTypes={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xls:"application/vnd.ms-excel",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 isXls(t){return t?t===this.mimeTypes.xls:!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 a.isPDF(t)?"pdf":a.isImage(t)?"image":a.isDocument(t)?"docx":a.isSheet(t)?"xlsx":a.isXls(t)?"xls":a.isCSV(t)?"csv":a.isText(t)?"text":"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=a.createBlobUrl(t,e);i&&this.downloadFileFromUrl(i,e)}static createBlobUrl(t,e){var i=a.getMimeType(e);return URL.createObjectURL(new Blob([t],{type:i}))}static getFileByteArray(t){return new d(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 a.getFileByteArray(t).pipe(p(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 f(Array.from(t)).pipe(m(e=>a.getBase64File(e)),u())}static fileToByteArray(t){return c(this,null,function*(){return new Uint8Array(yield t.arrayBuffer())})}static fileToBase64(t){return c(this,null,function*(){let e=yield this.fileToByteArray(t),i="",r=32768;for(let s=0;s<e.length;s+=r){let n=e.subarray(s,s+r);i+=String.fromCharCode(...n)}return btoa(i)})}static arrayBufferToBase64(t){let e="",i=new Uint8Array(t),r=i.byteLength;for(let s=0;s<r;s++)e+=String.fromCharCode(i[s]);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,s]of Object.entries(i))if(t.startsWith(r))return s;return e}static base64ToDataUrl(t,e=a.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}),s=window.URL.createObjectURL(r),n=document.createElement("a");n.href=s,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(s)}static openPdfInNewWindowWithLoading(s){return c(this,arguments,function*(t,e=this.mimeTypes.pdf,i="document.pdf",r=!1){let n=window.open("","_blank");if(n){let g="/Content/Animations/Trademark/Printing.gif";n.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+g}"><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 o=yield l(t instanceof Promise?yield t:t);if(o===null)return n?.close(),!1;if(r)return n?.close(),this.DirectDownload(o,e,i),!0;let h=new Blob([o],{type:e}),w=URL.createObjectURL(h);n.document.close(),n.focus(),n.location.href=w}else{var o=yield l(t instanceof Promise?yield t:t);if(o===null)return!1;this.DirectDownload(o,e,i)}return!0})}static base64ToUint8Array(t){let e=atob(t),i=new Uint8Array(e.length);for(let r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return i}static DirectDownload(t,e,i){let r=new Blob([t],{type:e}),s=URL.createObjectURL(r),n=document.createElement("a");n.href=s,n.download=i,n.click(),window.URL.revokeObjectURL(s)}static getFileExtension(t){let e=t.lastIndexOf(".");return e===-1?null:t.substring(e+1).toLowerCase()}static base64ToBlobUrl(t,e,i){let r=e&&e.trim().length>0?e:i?a.getMimeType(i):a.tryDetectMimeType(t,a.mimeTypes.other),s=a.base64ToUint8Array(t);return URL.createObjectURL(new Blob([s],{type:r}))}};export{y as a};
