import{d,e as U,f as k,m as M}from"./chunk-ZHB7Y3RV.js";import{P as V,fa as E}from"./chunk-Q232IBQN.js";import{b as C}from"./chunk-LGT7QKWT.js";import{e as y,h as B,m as b}from"./chunk-K3AFQ46O.js";import{H as O,K as F,c as T,e as I,ha as L,ja as x,q as w,sa as P,v as c,xa as f}from"./chunk-O7RN3KYY.js";import{a as h}from"./chunk-ZE2KCNEA.js";import{f as H,h as X}from"./chunk-CEWFFWI2.js";var D=H((A,S)=>{h();(function(u,m){typeof define=="function"&&define.amd?define([],m):typeof A<"u"?m():(m(),u.FileSaver={})})(A,function(){"use strict";function u(n,r){return typeof r>"u"?r={autoBom:!1}:typeof r!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),r={autoBom:!r}),r.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type)?new Blob(["\uFEFF",n],{type:n.type}):n}function m(n,r,p){var a=new XMLHttpRequest;a.open("GET",n),a.responseType="blob",a.onload=function(){i(a.response,r,p)},a.onerror=function(){console.error("could not download file")},a.send()}function t(n){var r=new XMLHttpRequest;r.open("HEAD",n,!1);try{r.send()}catch(p){}return 200<=r.status&&299>=r.status}function o(n){try{n.dispatchEvent(new MouseEvent("click"))}catch(p){var r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),n.dispatchEvent(r)}}var e=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof global=="object"&&global.global===global?global:void 0,s=e.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),i=e.saveAs||(typeof window!="object"||window!==e?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(n,r,p){var a=e.URL||e.webkitURL,l=document.createElement("a");r=r||n.name||"download",l.download=r,l.rel="noopener",typeof n=="string"?(l.href=n,l.origin===location.origin?o(l):t(l.href)?m(n,r,p):o(l,l.target="_blank")):(l.href=a.createObjectURL(n),setTimeout(function(){a.revokeObjectURL(l.href)},4e4),setTimeout(function(){o(l)},0))}:"msSaveOrOpenBlob"in navigator?function(n,r,p){if(r=r||n.name||"download",typeof n!="string")navigator.msSaveOrOpenBlob(u(n,p),r);else if(t(n))m(n,r,p);else{var a=document.createElement("a");a.href=n,a.target="_blank",setTimeout(function(){o(a)})}}:function(n,r,p,a){if(a=a||open("","_blank"),a&&(a.document.title=a.document.body.innerText="downloading..."),typeof n=="string")return m(n,r,p);var l=n.type==="application/octet-stream",$=/constructor/i.test(e.HTMLElement)||e.safari,R=/CriOS\/[\d]+/.test(navigator.userAgent);if((R||l&&$||s)&&typeof FileReader<"u"){var v=new FileReader;v.onloadend=function(){var g=v.result;g=R?g:g.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=g:location=g,a=null},v.readAsDataURL(n)}else{var j=e.URL||e.webkitURL,_=j.createObjectURL(n);a?a.location=_:location.href=_,a=null,setTimeout(function(){j.revokeObjectURL(_)},4e4)}});e.saveAs=i.saveAs=i,typeof S<"u"&&(S.exports=i)})});h();var N=X(D());var re=(()=>{class u{constructor(){this.http=f(B),this.helper=f(C),this.deviceService=f(V),this.filesValidation=f(k),this.imageService=f(M)}upload(t,o,e){let s=new FormData;s.append(o,t,t.name);let i=new I;return e&&e.then(()=>{i.next(),i.complete()}),this.http.post(`${b.API_ENDPOINT_V1}/core/upload`,s,{context:E}).pipe(L(i))}genericUpload(t,o,e=()=>{}){let s=new FormData;s.append(o,t,t.name);let i=this.filesValidation.isValid([t]);return i.result?this.http.post(`${b.API_ENDPOINT_V1}/core/upload`,s,{reportProgress:!0,observe:"events",context:E}).pipe(x(n=>{n.type===y.UploadProgress&&e(n)}),O(n=>n.type===y.Response),F(()=>w($localize`There was a problem uploading the file`))):w(()=>i.error_message)}uploadTransactionAttachment(t,o){return this.genericUpload(t,"transaction_attachments",o).pipe(c(e=>e.body?.results?.successful_transaction_attachment[0]))}uploadPostVideo(t,o){return this.genericUpload(t,"post_videos",o).pipe(c(e=>e.body?.results?.successful_post_video[0]))}uploadCommentImage(t,o){return this.genericUpload(t,"comment_images",o).pipe(c(e=>e.body?.results?.successful_comment_image[0]))}uploadCommentAttachment(t,o){return this.genericUpload(t,"comment_attachments",o).pipe(c(e=>e.body?.results?.successful_comment_attachment[0]))}uploadCommentVideo(t,o){return this.genericUpload(t,"comment_videos",o).pipe(c(e=>e.body?.results?.successful_comment_video[0]))}uploadMessageAttachment(t,o){return this.genericUpload(t,"message_attachments",o).pipe(c(e=>e.body?.results?.successful_message_attachment[0]))}uploadMessageImage(t,o){return this.genericUpload(t,"message_images",o).pipe(c(e=>e.body?.results?.successful_message_image[0]))}uploadPageAttachment(t,o){return this.genericUpload(t,"page_attachments",o).pipe(c(e=>e.body?.results?.successful_page_attachment[0]))}uploadPageImage(t,o){return this.genericUpload(t,"page_images",o).pipe(c(e=>e.body?.results?.successful_page_image[0]))}uploadGroupPageAttachment(t,o){return this.genericUpload(t,"group_page_attachments",o).pipe(c(e=>e.body?.results?.successful_group_page_attachment[0]))}uploadGroupPageImage(t,o){return this.genericUpload(t,"group_page_images",o).pipe(c(e=>e.body?.results?.successful_group_page_image[0]))}uploadBuildingPhoto(t,o){return this.genericUpload(t,"building_photos",o).pipe(c(e=>e.body?.results?.successful_building_photos[0]))}uploadBuildingVideo(t,o){return this.genericUpload(t,"building_videos",o).pipe(c(e=>e.body?.results?.successful_building_videos[0]))}uploadRoomPhoto(t,o){return this.genericUpload(t,"room_photos",o).pipe(c(e=>e.body?.results?.successful_room_photos[0]))}uploadRoomVideo(t,o){return this.genericUpload(t,"room_videos",o).pipe(c(e=>e.body?.results?.successful_room_videos[0]))}uploadFormSubmissionFile(t,o){return this.genericUpload(t,"form_submission_file",o).pipe(c(e=>e.body?.results?.successful_form_submission_files[0]))}uploadCctActivityCompletionFile(t,o){return this.genericUpload(t,"cct_activity_completion_files",o).pipe(c(e=>e.body?.results?.successful_cct_activity_completion_files[0]))}getIcon(t,o){let e={"application/vnd.google-apps.document":"doc","application/vnd.google-apps.spreadsheet":"csv","text/uri-list":"link",folder:"folder"},s="/static/frontend/static/images/file-images/",i;return o&&(i=e[o]),i||(i=String(t).split(".").pop().toLowerCase()),`${s}${U.large[i]||U.large.default}`}downloadFile(t,o){let e=o?`${t}?${this.helper.toHttpParams(o).toString()}`:t;this.deviceService.isMobileApp()?this.deviceService.downloadUrl(e):window.location.href=e}saveBlob(t,o){let e=window.URL.createObjectURL(t),s=document.createElement("a");s.href=e,s.download=o,s.click(),window.URL.revokeObjectURL(e)}stringToBlob(t,o){return new Blob([t],{type:o})}blobToString(t){return new Promise((o,e)=>{let s=new FileReader;s.onload=i=>{o(i.target.result)},s.readAsText(t)})}saveAsCsv(t,o,e){let s=o.map(r=>`"${r.join('","')}"`),i=[`"${t.join('","')}"`,...s].join(` `),n=new File([i],e,{type:"text/csv;charset=utf-8"});N.default.saveAs(n)}isImageFile(t){let o=new RegExp("("+d.image.join("|")+")$","i");return!!t.match(o)}generateAcceptedExtensionsString(){return[d.video.join(","),d.document.join(","),d.audio.join(","),d.image.join(","),d.other.join(",")].join(",")}processImages(t,o=d.image){return new T(e=>{if(!t||!t.length)return;let s=this.filesValidation.isValid(t,o),i=t[0];s.result?this.filesValidation.isValidImage(i).then(()=>this.imageService.detectOrientation(i)).then(n=>this.imageService.resetOrientation(n.data,n.orientation)).then(n=>{e.next([i,n]),e.complete()}).catch(n=>{e.error(n),e.complete()}):e.error(s.error_message)})}fileToBase64(t){return new Promise((o,e)=>{let s=new FileReader;s.onloadend=()=>{let i=s.result,n="data:"+t.type+";base64,"+this.arrayBufferToBase64(i);o(n)},s.onerror=e,s.readAsArrayBuffer(t)})}arrayBufferToBase64(t){let o="",e=new Uint8Array(t),s=e.byteLength;for(let i=0;i