2 lines
82 KiB
JavaScript
2 lines
82 KiB
JavaScript
!function(){"use strict";function c(e){"function"!=typeof e.then&&(angular.extend(this,e),_.forEach(this.identities,function(e){if(e.fullName&&e.email?e.full=e.fullName+" <"+e.email+">":e.email?e.full="<"+e.email+">":e.full="",e.signature){var t=angular.element("<div>"+e.signature+"</div>");e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()}}),c.$log.debug("Account: "+JSON.stringify(e,void 0,2)))}c.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(e,t,n,s,i,o,a,r){return angular.extend(c,{$q:e,$timeout:t,$log:n,$$resource:new i(s.activeUser("folderURL")+"Mail",s.activeUser()),$Preferences:o,$Mailbox:a,$Message:r}),c}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",c.$factory),c.$findAll=function(e){return e?c.$unwrapCollection(e):c.$accounts?c.$q.when(c.$accounts):c.$$resource.fetch("","mailAccounts").then(function(e){return c.$unwrapCollection(e)})},c.$unwrapCollection=function(e){var n=[];return angular.forEach(e,function(e,t){e.id=t,n[t]=new c(e)}),c.$accounts=n},c.prototype.getLength=function(){return this.$expanded?this.$flattenMailboxes().length:0},c.prototype.getItemAtIndex=function(e){var t;return t=this.$flattenMailboxes(),0<=e&&e<t.length?t[e]:null},c.prototype.$getMailboxes=function(e){var o=this,t=e&&e.reload;return this.$mailboxes&&!t?c.$q.when(this.$mailboxes):(!t&&this.$futureMailboxesData||(this.$futureMailboxesData=c.$Mailbox.$find(this,e).then(function(e){var n=o.$flattenMailboxes({all:!0});o.$mailboxes=e,o.$expanded=!1;var s=function(e){_.forEach(e,function(e){var t=_.find(n,["id",e.id]);t&&(e.unseenCount=t.unseenCount),e.children&&0<e.children.length&&s(e.children)})};s(o.$mailboxes);var t,i=function(e){_.forEach(e,function(e){e.$expanded=0<=t.indexOf("/"+e.id),e.children&&0<e.children.length&&i(e.children)})};if(c.$Preferences.settings.Mail.ExpandedFolders){if(angular.isString(c.$Preferences.settings.Mail.ExpandedFolders))try{t=angular.fromJson(c.$Preferences.settings.Mail.ExpandedFolders)}catch(e){c.$log.warn("Can't parse list of expanded folders. String was: "+c.$Preferences.settings.Mail.ExpandedFolders),t=[]}else t=c.$Preferences.settings.Mail.ExpandedFolders;o.$expanded=0<=t.indexOf("/"+o.id),0<t.length&&i(o.$mailboxes)}return c.$accounts&&(o.$expanded|=1==c.$accounts.length),o.$flattenMailboxes({reload:!0}),o.$mailboxes})),this.$futureMailboxesData)},c.prototype.$flattenMailboxes=function(t){var n=[],s=[],i=function(e){_.forEach(e,function(e){n.push(e),(t&&t.all||e.$expanded)&&e.children&&0<e.children.length&&i(e.children)})};return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(i(this.$mailboxes),t&&t.all||(this.$$flattenMailboxes=n,t&&t.saveState&&(_.forEach(c.$accounts,function(e){e.$expanded&&s.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},s)}),c.$$resource.post(null,"saveFoldersState",s)))):n=this.$$flattenMailboxes,n},c.prototype.$getMailboxByType=function(n){var s=function(e){var t=_.find(e,function(e){return e.type==n});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=s(e.children))}),t};return s(this.$mailboxes)},c.prototype.$getMailboxByPath=function(n){var s=function(e){var t=_.find(e,function(e){return e.path==n});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=s(e.children))}),t};return s(this.$mailboxes)},c.prototype.$newMailbox=function(e,t){var n=this;return c.$$resource.post(e.toString(),"createFolder",{name:t}).then(function(){n.$getMailboxes({reload:!0})})},c.prototype.getTextSignature=function(e){if(e.signature){var t=angular.element("<div>"+e.signature+"</div>");e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()}else e.textSignature="";return e.textSignature},c.prototype.$certificate=function(){var t=this;return this.security&&this.security.hasCertificate?this.$$certificate?c.$q.when(this.$$certificate):c.$$resource.fetch(this.id.toString(),"certificate").then(function(e){return t.$$certificate=e}):c.$q.reject()},c.prototype.$removeCertificate=function(){var e=this;return c.$$resource.fetch(this.id.toString(),"removeCertificate").then(function(){e.security.hasCertificate=!1})},c.prototype.updateQuota=function(e){var t,n;t=Math.round(1e4*e.usedSpace/e.maxQuota)/100,n=l("quotasFormat").formatted(t,Math.round(e.maxQuota/10.24)/100),this.$quota={percent:t,description:n}},c.prototype.$newMessage=function(s){var i=this;return c.$$resource.fetch(this.id.toString(),"compose").then(function(e){return c.$log.debug("New message (compose): "+JSON.stringify(e,void 0,2)),new c.$Message(e.accountId,i.$getMailboxByPath(e.mailboxPath),e)}).then(function(n){return c.$$resource.fetch(n.$absolutePath({asDraft:!0}),"edit").then(function(e){var t=c.$Preferences.defaults.AuxiliaryMailAccounts[i.id];return t.security&&(t.security.alwaysSign&&(e.sign=!0),t.security.alwaysEncrypt&&(e.encrypt=!0)),c.$log.debug("New message (edit): "+JSON.stringify(e,void 0,2)),angular.extend(n.editable,e),n.isNew=!0,s&&s.mailto&&(angular.isObject(s.mailto)?angular.extend(n.editable,s.mailto):n.$parseMailto(s.mailto)),n})})},c.prototype.$addDelegate=function(e){var t=this,n=c.$q.defer(),s={uid:e.uid};return!e.uid||-1<_.indexOf(_.map(this.delegates,"uid"),e.uid)?n.resolve():c.$$resource.fetch(this.id.toString(),"addDelegate",s).then(function(){t.delegates.push(e),n.resolve(t.users)},function(e,t){n.reject(l("An error occured, please try again."))}),n.promise},c.prototype.$removeDelegate=function(t){var n=this,e={uid:t};return c.$$resource.fetch(this.id.toString(),"removeDelegate",e).then(function(){var e=_.indexOf(_.map(n.delegates,"uid"),t);0<=e&&n.delegates.splice(e,1)})},c.prototype.$omit=function(){var n={},t=[],s=!1;return angular.forEach(this,function(e,t){"constructor"!=t&&"identities"!=t&&"$"!=t[0]&&(n[t]=angular.copy(e))}),_.forEach(this.identities,function(e){e.isReadOnly||t.push(_.pick(e,["email","fullName","replyTo","signature","isDefault"])),e.isDefault&&(s=e)}),n.identities=t,s&&n.forceDefaultIdentity||delete n.forceDefaultIdentity,n}}(),function(){"use strict";function d(e,t){if(this.$account=e,"function"!=typeof t.then){if(this.init(t),this.name&&!this.path){var n=d.$$resource.create("createFolder",this.name);this.$unwrap(n)}}else this.$unwrap(t)}d.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Acl","Preferences","sgMailbox_PRELOAD","sgMailbox_BATCH_DELETE_LIMIT",function(e,t,n,s,i,o,a,r,l,c){return angular.extend(d,{$q:e,$timeout:t,$log:n,$$resource:new i(s.activeUser("folderURL")+"Mail",s.activeUser()),$Message:o,$$Acl:a,$Preferences:r,$query:{sort:"arrival",asc:0},selectedFolder:null,$refreshTimeout:null,$virtualMode:!1,$virtualPath:!1,PRELOAD:l,BATCH_DELETE_LIMIT:c}),r.settings.Mail.SortingState&&(d.$query.sort=r.settings.Mail.SortingState[0],d.$query.asc=parseInt(r.settings.Mail.SortingState[1])),d}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMailbox_PRELOAD",{LOOKAHEAD:50,SIZE:100}).constant("sgMailbox_BATCH_DELETE_LIMIT",1e3).factory("Mailbox",d.$factory),d.$find=function(e,t){var n;return n=t&&t.all?this.$$resource.fetch(e.id.toString(),"viewAll"):this.$$resource.fetch(e.id.toString(),"view"),d.$unwrapCollection(e,n)},d.$unwrapCollection=function(s,e){var i=[],o=function(e,t){t.isSentFolder=t.isSentFolder||"sent"==t.type;for(var n=0;n<t.children.length;n++)t.children[n].level=e,t.children[n]=new d(s,t.children[n]),t.isSentFolder&&(t.children[n].isSentFolder=!0),o(e+1,t.children[n])};return e.then(function(e){return d.$timeout(function(){return angular.forEach(e.mailboxes,function(e,t){e.level=0;var n=new d(s,e);o(1,n),i.push(n)}),e.quotas&&s.updateQuota(e.quotas),i})})},d.$absolutePath=function(e,t){var n=[];return t&&(n=_.map(t.split("/"),function(e){return"folder"+e.asCSSIdentifier()})),n.splice(0,0,e),n.join("/")},d.prototype.init=function(e){(angular.isUndefined(this.uidsMap)||e.headers)&&(this.$isLoading=!0,this.$messages=[],this.uidsMap={}),angular.extend(this,e),this.path&&(this.id=this.$id(),this.$acl=new d.$$Acl("Mail/"+this.id),this.threaded&&(this.$collapsedThreads=[],d.$Preferences.settings.Mail.threadsCollapsed&&d.$Preferences.settings.Mail.threadsCollapsed["/"+this.id]&&(this.$collapsedThreads=d.$Preferences.settings.Mail.threadsCollapsed["/"+this.id]))),this.$displayName=this.name,this.type&&(this.$isEditable=this.isEditable(),this.$isSpecial=!0,"inbox"==this.type?(this.$displayName=l("InboxFolderName"),this.$icon="inbox"):"draft"==this.type?(this.$displayName=l("DraftsFolderName"),this.$icon="drafts"):"sent"==this.type?(this.$displayName=l("SentFolderName"),this.$icon="send"):"trash"==this.type?(this.$displayName=l("TrashFolderName"),this.$icon="delete"):"junk"==this.type?(this.$displayName=l("JunkFolderName"),this.$icon="thumb_down"):"additional"==this.type?this.$icon="folder_shared":(this.$isSpecial=!1,this.$icon="folder")),this.$isNoInferiors=this.isNoInferiors(),angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},d.prototype.selectFolder=function(){d.$virtualMode||(d.selectedFolder=this)},d.prototype.getLength=function(){var n=!1;return _.filter(this.$messages,function(e,t){return e.first?n=e.collapsed:e.level<0&&(n=!1),e.first||!1===n}).length},d.prototype.getItemAtIndex=function(e){var t,n=!1,s=_.filter(this.$messages,function(e,t){return e.first?n=e.collapsed:e.level<0&&(n=!1),e.first||!1===n});return 0<=e&&e<s.length&&(t=s[e],this.$lastVisibleIndex=Math.max(0,e-3),this.$loadMessage(t.uid))?t:null},d.prototype.$id=function(){return d.$absolutePath(this.$account.id,this.path)},d.prototype.$selectedMessages=function(){return _.filter(this.$messages,function(e){return e.selected})},d.prototype.$selectedCount=function(){return this.$selectedMessages().length},d.prototype.isSelectedMessage=function(e){return this.selectedMessage==e},d.prototype.$selectedMessage=function(){var t=this;return _.find(this.$messages,function(e){return e.uid==t.selectedMessage})},d.prototype.$selectedMessageIndex=function(){return this.uidsMap[this.selectedMessage]},d.prototype.hasSelectedMessage=function(){return angular.isDefined(this.selectedMessage)},d.prototype.$filter=function(e,t){var n=this,s={};if(angular.isDefined(this.unseenCount)||(this.unseenCount=0),d.$timeout(function(){n.$isLoading=!0}),d.$refreshTimeout&&d.$timeout.cancel(d.$refreshTimeout),e&&angular.extend(d.$query,e),angular.extend(s,{sortingAttributes:d.$query}),angular.isDefined(t)&&(s.filters=_.reject(angular.copy(t),function(e){return!e.searchInput||0===e.searchInput.length}),_.forEach(s.filters,function(e){var t,n=e.searchBy.match(/(\w+)_or_(\w+)/);n&&(s.sortingAttributes.match="OR",e.searchBy=n[1],(t=angular.copy(e)).searchBy=n[2],s.filters.push(t))})),!d.$virtualMode){var i=d.$Preferences.defaults.SOGoRefreshViewCheck;if(i&&"manually"!=i){var o=angular.bind(this,d.prototype.$filter,null,t);d.$refreshTimeout=d.$timeout(o,1e3*i.timeInterval())}}var a=d.$$resource.post(this.id,"view",s);return this.$unwrap(a)},d.prototype.$loadMessage=function(e){var t,n,s,i,o=this.uidsMap[e],a=this.$messages.length,r=!1;if(angular.isDefined(this.uidsMap[e])&&o<this.$messages.length&&(angular.isDefined(this.$messages[o].subject)&&(r=!0),t=Math.min(o+d.PRELOAD.LOOKAHEAD,a-1),angular.isDefined(this.$messages[t].subject)||angular.isDefined(this.$messages[t].loading)?(n=Math.max(o-d.PRELOAD.LOOKAHEAD,0),angular.isDefined(this.$messages[n].subject)||angular.isDefined(this.$messages[n].loading)||(t=o,o=Math.max(o-d.PRELOAD.SIZE,0))):t=Math.min(o+d.PRELOAD.SIZE,a-1),!angular.isDefined(this.$messages[o].subject)&&!angular.isDefined(this.$messages[o].loading)||!angular.isDefined(this.$messages[t].subject)&&!angular.isDefined(this.$messages[t].loading))){for(s=[];o<t&&o<a;o++)angular.isDefined(this.$messages[o].subject)||this.$messages[o].loading?t++:(s.push(this.$messages[o].uid),this.$messages[o].loading=!0);s.length&&(d.$log.debug("Loading UIDs "+s.join(" ")),i=d.$$resource.post(this.id,"headers",{uids:s}),this.$unwrapHeaders(i))}return r},d.prototype.isEditable=function(){return"folder"==this.type},d.prototype.isNoInferiors=function(){return 0<=this.flags.indexOf("noinferiors")},d.prototype.isNoSelect=function(){return 0<=this.flags.indexOf("noselect")},d.prototype.getClassName=function(e){return!1},d.prototype.$rename=function(){var s,e,o,a,r=this;return this.name==this.$shadowData.name?d.$q.when():(e=(s=function(e,t){var n=null;return _.find(t,function(e){return e.path==r.path})?n=e:angular.forEach(t,function(e){!n&&e.children&&0<e.children.length&&(n=s(e,e.children))}),n})(null,this.$account.$mailboxes),o=null===e?this.$account.$mailboxes:e.children,a=_.indexOf(_.map(o,"id"),this.id),this.$save().then(function(e){var t,n=r.path;r.init(e),o.splice(a,1),t=_.find(o,function(e){return"folder"==e.type&&0<e.name.localeCompare(r.name)}),a=t?_.indexOf(_.map(o,"id"),t.id):o.length,o.splice(a,0,r);var s=new RegExp("^"+n),i=function(e){_.forEach(e.children,function(e){e.path=e.path.replace(s,r.path),e.id=e.$id(),i(e)})};i(r)}))},d.prototype.$compact=function(){var t=this;return d.$$resource.post(this.id,"expunge").then(function(e){return e.quotas&&t.$account.updateQuota(e.quotas),!0})},d.prototype.$canFolderAs=function(){return"folder"==this.type},d.prototype.$setFolderAs=function(e){return d.$$resource.post(this.id,"setAs"+e+"Folder")},d.prototype.$emptyTrash=function(){var t=this;return d.$$resource.post(this.id,"emptyTrash").then(function(e){t.$messages=[],t.uidsMap={},t.unseenCount=0,angular.isDefined(t.children)&&t.children.length&&t.$account.$getMailboxes({reload:!0}),e.quotas&&t.$account.updateQuota(e.quotas)})},d.prototype.$markAsRead=function(){var e=this;return d.$$resource.post(this.id,"markRead").then(function(){e.unseenCount=0,_.forEach(e.$messages,function(e){e.isread=!0})})},d.prototype.$flagMessages=function(e,t,n){var s={msgUIDs:_.map(e,"uid"),flags:t,operation:n};return d.$$resource.post(this.id,"addOrRemoveLabel",s).then(function(){return e})},d.prototype.saveSelectedMessages=function(){var e,t;return e=_.filter(this.$messages,function(e){return e.selected}),{uids:t=_.map(e,"uid")},{filename:l("Saved Messages.zip")},d.$$resource.download(this.id,"saveMessages",{uids:t})},d.prototype.exportFolder=function(){var e;return e={filename:this.name+".zip"},d.$$resource.open(this.id,"exportFolder",null,e)},d.prototype.$delete=function(e){var t=this;return d.$$resource.post(this.id,"delete",e).then(function(){return t.$account.$getMailboxes({reload:!0}),!0})},d.prototype.$_deleteMessages=function(s,e){var t,i=this,o=this.$messages.length;return t=_.filter(e,function(e,t){return!e.isread}),this.unseenCount-=t.length,_.forEachRight(this.$messages,function(t,e){var n=_.findIndex(s,function(e){return t.uid==e});-1<n?(s.splice(n,1),delete i.uidsMap[t.uid],t.uid==i.selectedMessage&&delete i.selectedMessage,i.$messages.splice(e,1),e<o&&(o=e)):i.uidsMap[t.uid]-=s.length}),o},d.prototype.$deleteMessages=function(a,r){var l,c=this,u=d.BATCH_DELETE_LIMIT;return l=_.map(a,"uid"),function t(e,n){var s=l.slice(e,n),i=a.slice(e,n),o={uids:s};return r&&angular.extend(o,r),d.$$resource.post(c.id,"batchDelete",o).then(function(e){return n<l.length?(c.$_deleteMessages(s,i),t(n,Math.min(n+u,l.length))):(e.quotas&&c.$account.updateQuota(e.quotas),c.$_deleteMessages(s,i))})}(0,Math.min(u,l.length))},d.prototype.$markOrUnMarkMessagesAsJunk=function(e){var t=_.map(e,"uid"),n="junk"==this.type?"markMessagesAsNotJunk":"markMessagesAsJunk";return d.$$resource.post(this.id,n,{uids:t})},d.prototype.$copyMessages=function(e,t){var n=this,s=_.map(e,"uid");return d.$$resource.post(this.id,"copyMessages",{uids:s,folder:t}).then(function(e){e.quotas&&n.$account.updateQuota(e.quotas)})},d.prototype.$moveMessages=function(e,t){var n,s=this;return n=_.map(e,"uid"),d.$$resource.post(this.id,"moveMessages",{uids:n,folder:t}).then(function(){return s.$_deleteMessages(n,e)})},d.prototype.$reset=function(){var n=this;angular.forEach(this.$shadowData,function(e,t){delete n[t]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},d.prototype.$move=function(e){var t=this;return d.$$resource.post(this.id,"move",{parent:e}).finally(function(){return t.$account.$getMailboxes({reload:!0}),!0})},d.prototype.$save=function(){var t=this;return d.$$resource.save(this.id,this.$omit()).then(function(e){return t.$shadowData=t.$omit(),d.$log.debug(JSON.stringify(e,void 0,2)),e},function(e){return d.$log.error(JSON.stringify(e.data,void 0,2)),t.$reset(),e.data})},d.prototype.$newMailbox=function(e,t){return this.$account.$newMailbox(e,t)},d.prototype.$omit=function(){var n={};return angular.forEach(this,function(e,t){"constructor"!=t&&"children"!=t&&"headers"!=t&&"uids"!=t&&"uidsMap"!=t&&"$"!=t[0]&&(n[t]=e)}),n},d.prototype.$unwrap=function(e){var l=this,t=d.$q.defer();return this.$futureMailboxData=e,this.$futureMailboxData.then(function(e){var r=_.map(l.$selectedMessages(),"uid");d.$timeout(function(){var a,s;(!e.uids||l.$topIndex>e.uids.length-1)&&(l.$topIndex=0),l.init(e),l.uids&&(d.$log.debug("unwrapping "+l.uids.length+" messages"),s=_.invokeMap(l.headers[0],"toLowerCase"),l.headers.splice(0,1),l.threaded&&(a=l.uids[0],l.uids.splice(0,1)),_.reduce(l.uids,function(e,t,n){var s,i;if(l.threaded){if(1===(s=_.zipObject(a,t)).first){for(var o=1;l.uids[n+o]&&0<=l.uids[n+o][1]&&1!==l.uids[n+o][2];)o++;s.count=o,s.collapsed=!1,0<=l.$collapsedThreads.indexOf(s.uid.toString())&&(s.collapsed=!0)}}else s={uid:t.toString()};return l.uidsMap[s.uid]=n,(i=new d.$Message(l.$account.id,l,s,!0)).selected=-1<r.indexOf(i.uid),e.push(i),e},l.$messages),_.forEach(l.headers,function(e){var t=_.zipObject(s,e),n=l.uidsMap[t.uid.toString()];l.$messages[n].init(t)})),d.$log.debug("mailbox "+l.id+" ready"),l.$isLoading=!1,t.resolve(l.$messages)})},function(e){angular.extend(l,e),l.isError=!0,l.$isLoading=!1,t.reject()}),t.promise},d.prototype.$unwrapHeaders=function(e){var s=this;e.then(function(e){d.$timeout(function(){var t,n;0<e.length&&(t=_.invokeMap(e[0],"toLowerCase"),e.splice(0,1),_.forEach(e,function(e){e=_.zipObject(t,e),n=s.uidsMap[e.uid.toString()],angular.isDefined(n)&&s.$messages[n].init(e)}))})})},d.prototype.$updateSubscribe=function(){var e=this.subscribed?"subscribe":"unsubscribe";d.$$resource.post(this.id,e)}}(),function(){"use strict";function r(e,t,n,s){this.accountId=e,this.$mailbox=t,this.$hasUnsafeContent=!1,this.$loadUnsafeContent=!1,this.editable={to:[],cc:[],bcc:[]},this.selected=!1,"function"!=typeof n.then?(!angular.isUndefined(s)&&s||this.init(n),this.uid=parseInt(n.uid),this.level=parseInt(n.level),this.first=1===parseInt(n.first),this.first?(this.threadCount=parseInt(n.count),this.collapsed=!0===n.collapsed):!isNaN(this.level)&&0<=this.level&&(this.threadMember=!0)):this.$unwrap(n)}r.$factory=["$q","$timeout","$log","sgSettings","sgMessage_STATUS","Resource","Preferences",function(e,t,n,s,i,o,a){return angular.extend(r,{STATUS:i,$q:e,$timeout:t,$log:n,$$resource:new o(s.activeUser("folderURL")+"Mail",s.activeUser()),$Preferences:a,$avatar:angular.bind(a,a.avatar)}),a.defaults.SOGoMailLabelsColors&&(r.$tags=a.defaults.SOGoMailLabelsColors),a.defaults.SOGoMailDisplayRemoteInlineImages&&"always"==a.defaults.SOGoMailDisplayRemoteInlineImages&&(r.$displayRemoteInlineImages=!0),r}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMessage_STATUS",{NOT_LOADED:0,DELAYED_LOADING:1,LOADING:2,LOADED:3,DELAYED_MS:300}).factory("Message",r.$factory),r.filterTags=function(e,n){var s=new RegExp(e,"i"),i=[];return _.forEach(_.keys(r.$tags),function(e){var t=r.$tags[e];-1!=t[0].search(s)&&(_.includes(n,e)||i.push({name:e,description:t[0],color:t[1]}))}),i},r.prototype.init=function(e){var n=this;angular.extend(this,e),this.$formatFullAddresses(),this.$loadUnsafeContent=!1,_.forEach(this.flags,function(e,t){"$"==e.charAt(0)&&n.flags.splice(t,1,"_"+e)})},r.prototype.$absolutePath=function(e){var t=this,n=this.id;function s(){var e;return(e=_.map(t.$mailbox.path.split("/"),function(e){return"folder"+e.asCSSIdentifier()})).splice(0,0,t.accountId),e.join("/")}return(angular.isUndefined(this.id)||e&&e.nocache)&&(this.id=s()+"/"+this.uid,n=this.id),e&&e.asDraft&&this.draftId&&(n=s()+"/"+this.draftId),e&&e.withResourcePath&&(n=r.$$resource.path(n)),n},r.prototype.$setUID=function(e){var t,n=this.uid||-1,s=this;n!=parseInt(e)&&(this.uid=parseInt(e),this.$absolutePath({nocache:!0}),-1<n?(n=n.toString(),angular.isDefined(this.$mailbox.uidsMap[n])&&(t=this.$mailbox.uidsMap[n],this.$mailbox.uidsMap[e]=t,delete this.$mailbox.uidsMap[n],this.$mailbox.$messages[t].uid=this.uid,_.forEach(["from","to","subject"],function(e){s.$mailbox.$messages[t][e]=s.editable[e]}))):this.$mailbox.constructor.selectedFolder&&"draft"==this.$mailbox.constructor.selectedFolder.type&&this.$mailbox.constructor.selectedFolder.$filter())},r.prototype.$formatFullAddresses=function(){var t=this,n=_.map(t.$mailbox.$account.identities,"email");_.forEach(["from","to","cc","bcc","reply-to"],function(e){_.forEach(t[e],function(e){e.name&&e.name!=e.email?(e.full=e.name+" <"+e.email+">",e.name.length<10?e.shortname=e.name:e.name.split(" ").length&&(e.shortname=_.first(_.last(e.name.split(/, */)).split(/ +/)).replace("'",""))):e.email&&(e.full="<"+e.email+">",e.shortname=e.email.split("@")[0]),e.image=r.$avatar(e.email,32),0<=_.indexOf(n,e.email)&&(e.shortname=l("me"))})})},r.prototype.$shortRecipients=function(n){var t=this,s=[],i=0,o=0;return _.forEach(["to","cc","bcc"],function(e){o+=t[e]?t[e].length:0,_.forEach(t[e],function(e,t){i<n&&s.push(e.shortname),i++})}),n<o&&s.push(l("and %{0} more...",o-n)),s.join(", ")},r.prototype.$shortAddress=function(e){var t="";return this[e]&&0<this[e].length&&(t=this[e][0].name||this[e][0].email||""),t},r.prototype.allowReplyAll=function(){var s=_.map(this.$mailbox.$account.identities,"email"),e=0;return e=_.reduce(["to","cc","bcc","reply-to"],_.bind(function(e,t){var n=0;return this[t]?(n=this[t].length,_.forEach(this[t],function(e){0<=_.indexOf(s,e.email)&&n--}),e+n):e},this),e),!this.isDraft&&1<e},r.prototype.loadUnsafeContent=function(){this.$loadUnsafeContent=!0,delete this.$parts},r.prototype.$content=function(){var e=this,t=[],n=function(o){o.msgclass="msg-attachment-other","UIxMailPartAlternativeViewer"==o.type?n(_.find(o.content,function(e){return o.preferredPart==e.contentType})):angular.isArray(o.content)?("UIxMailPartSignedViewer"==o.type&&1===o["supports-smime"]?e.signed={valid:o.valid,certificate:o.certificates[o.certificates.length-1],message:o.message}:"UIxMailPartEncryptedViewer"==o.type&&(o.encrypted&&(e.encrypted={valid:o.decrypted},o.decrypted?e.encrypted.message=l("This message is encrypted"):e.encrypted.message=l("This message can't be decrypted. Please make sure you have uploaded your S/MIME certificate from the mail preferences module.")),o.opaqueSigned&&(e.signed={valid:o.valid,certificate:o.certificates[o.certificates.length-1],message:o.message})),_.forEach(o.content,function(e){n(e)})):(angular.isUndefined(o.safeContent)&&(o.safeContent=o.content,e.$hasUnsafeContent|=-1<o.safeContent.indexOf(" unsafe-")),"UIxMailPartHTMLViewer"==o.type?(o.html=!0,e.$loadUnsafeContent||r.$displayRemoteInlineImages?(angular.isUndefined(o.unsafeContent)&&(o.unsafeContent=document.createElement("div"),o.unsafeContent.innerHTML=o.safeContent,angular.forEach(["src","data","classid","background","style"],function(e){var t,n,s,i=o.unsafeContent.querySelectorAll("[unsafe-"+e+"]");for(s=0;s<i.length;s++)n=(t=angular.element(i[s])).attr("unsafe-"+e),t.attr(e,n),t.removeAttr("unsafe-"+e)}),e.$hasUnsafeContent=!1),o.content=o.unsafeContent.innerHTML):o.content=o.safeContent):"UIxMailPartICalViewer"==o.type||"UIxMailPartImageViewer"==o.type||"UIxMailPartLinkViewer"==o.type?("UIxMailPartImageViewer"==o.type?o.msgclass="msg-attachment-image":"UIxMailPartLinkViewer"==o.type&&(o.msgclass="msg-attachment-link"),o.compile=!0):(o.html=!0,o.content=o.safeContent),t.push(o))};return this.$parts?this.$parts:(this.parts&&n(this.parts),this.$parts=t)},r.prototype.$editableContent=function(){var s=this;return r.$$resource.fetch(this.$absolutePath(),"edit").then(function(e){return angular.extend(s,e),r.$$resource.fetch(s.$absolutePath({asDraft:!0}),"edit").then(function(t){var e=_.find(s.$mailbox.$account.identities,function(e){return t.from&&-1!==t.from.toLowerCase().indexOf(e.email)});e&&(t.from=e.full);var n=r.$Preferences.defaults.AuxiliaryMailAccounts[s.$mailbox.$account.id];return n.security&&(n.security.alwaysSign&&(t.sign=!0),n.security.alwaysEncrypt&&(t.encrypt=!0)),r.$log.debug("editable = "+JSON.stringify(t,void 0,2)),angular.extend(s.editable,t),t.text})})},r.prototype.$plainContent=function(){return r.$$resource.fetch(this.$absolutePath(),"viewplain")},r.prototype.addTag=function(e){return this.$addOrRemoveTag("add",e)},r.prototype.removeTag=function(e){return this.$addOrRemoveTag("remove",e)},r.prototype.$addOrRemoveTag=function(e,t){var n={operation:e,msgUIDs:[this.uid],flags:t.replace(/^_\$/,"$")};if(t)return r.$$resource.post(this.$mailbox.$id(),"addOrRemoveLabel",n)},r.prototype.$imipAction=function(e,t,n){var s=this;r.$$resource.post([this.$absolutePath(),e].join("/"),t,n).then(function(e){r.$timeout(function(){s.$reload()})})},r.prototype.$sendMDN=function(){return this.shouldAskReceipt=0,r.$$resource.post(this.$absolutePath(),"sendMDN")},r.prototype.$deleteAttachment=function(t){var e={filename:t},n=this;r.$$resource.fetch(this.$absolutePath({asDraft:!0}),"deleteAttachment",e).then(function(e){r.$timeout(function(){n.editable.attachmentAttrs=_.filter(n.editable.attachmentAttrs,function(e){return e.filename!=t})})})},r.prototype.toggleFlag=function(){var t=this,e="markMessageFlagged";return this.isflagged&&(e="markMessageUnflagged"),r.$$resource.post(this.$absolutePath(),e).then(function(e){r.$timeout(function(){t.isflagged=!t.isflagged})})},r.prototype.toggleThread=function(){var e="markMessageCollapse";return this.collapsed&&(e="markMessageUncollapse"),this.collapsed=!this.collapsed,r.$$resource.post(this.$absolutePath(),e)},r.prototype.$isLoading=function(){return this.$loaded==r.STATUS.LOADING},r.prototype.$reload=function(e){var t,n=this;return e&&e.useCache&&this.$futureMessageData?(this.isread||r.$$resource.fetch(this.$absolutePath(),"markMessageRead").then(function(){r.$timeout(function(){n.isread=!0,n.$mailbox.unseenCount--})}),this):(t=r.$$resource.fetch(this.$absolutePath(e),"view"),this.$unwrap(t))},r.prototype.$parseMailto=function(n){var e,s,i=/^mailto:([^\?]+)/.exec(n);i&&(e=_.map(decodeURIComponent(i[1]).split(","),function(e){return"<"+e.trim()+">"}),s={to:e},_.forEach(["subject","body"],function(e){var t=new RegExp(e+"=([^&]+)");e="body"==e?"text":e,(i=t.exec(n))&&(s[e]=decodeURIComponent(i[1]))}),_.forEach(["cc","bcc"],function(e){var t=new RegExp(e+"=([^&]+)");(i=t.exec(n))&&(s[e]=_.map(decodeURIComponent(i[1]).split(","),function(e){return"<"+e.trim()+">"}))}),angular.extend(this.editable,s))},r.prototype.$reply=function(){return this.$newDraft("reply")},r.prototype.$replyAll=function(){return this.$newDraft("replyall")},r.prototype.$forward=function(){return this.$newDraft("forward")},r.prototype.$newDraft=function(i){var o=this;return r.$$resource.fetch(this.$absolutePath(),i).then(function(e){var t,s;return r.$log.debug("New "+i+": "+JSON.stringify(e,void 0,2)),t=o.$mailbox.$account.$getMailboxByPath(e.mailboxPath),s=new r(e.accountId,t,e),r.$$resource.fetch(s.$absolutePath({asDraft:!0}),"edit").then(function(e){r.$log.debug("New "+i+": "+JSON.stringify(e,void 0,2)+" original UID: "+o.uid);var t=r.$Preferences.defaults.AuxiliaryMailAccounts[o.$mailbox.$account.id];if(t.security&&(t.security.alwaysSign&&(e.sign=!0),t.security.alwaysEncrypt&&(e.encrypt=!0)),e.isHTML){var n=angular.element("<div>"+e.text+"</div>");n.find("meta").remove(),n.find("link").remove(),n.find("base").remove(),n.find("title").remove(),e.text=n.html()}return angular.extend(s.editable,e),s.origin={message:o,action:i},s})})},r.prototype.$save=function(){var t=this,e=this.$omit();return r.$log.debug("save = "+JSON.stringify(e,void 0,2)),r.$$resource.save(this.$absolutePath({asDraft:!0}),e).then(function(e){r.$log.debug("save = "+JSON.stringify(e,void 0,2)),t.$setUID(e.uid),t.$reload(),t.isNew=!1})},r.prototype.$send=function(){var t=this,e=this.$omit();return r.$log.debug("send = "+JSON.stringify(e,void 0,2)),r.$$resource.post(this.$absolutePath({asDraft:!0}),"send",e).then(function(e){return"success"==e.status?(angular.isDefined(t.origin)&&(t.origin.action.startsWith("reply")?t.origin.message.isanswered=!0:"forward"==t.origin.action&&(t.origin.message.isforwarded=!0)),e):r.$q.reject(e.data)})},r.prototype.$unwrap=function(e){var t=this;return this.$loaded=r.STATUS.DELAYED_LOADING,r.$timeout(function(){t.$loaded!=r.STATUS.LOADED&&(t.$loaded=r.STATUS.LOADING)},r.STATUS.DELAYED_MS),this.$futureMessageData=e.then(function(e){return 0===t.isread&&(t.isread=!0,t.$mailbox.unseenCount--),r.$timeout(function(){return delete t.$parts,t.$loaded=r.STATUS.LOADED,t.init(e),t})}),this.$futureMessageData},r.prototype.$omit=function(e){var n={},s=e&&e.privateAttributes,t=s?this:this.editable;return angular.forEach(t,function(e,t){_.includes(["to","cc","bcc"],t)&&!s?n[t]=_.map(e,function(e){return e.toString()}):("constructor"!=t&&"$"!=t[0]||s)&&(n[t]=e)}),n},r.prototype.download=function(){var e,t;return e={uids:[this.uid]},t={filename:this.subject+".zip"},r.$$resource.download(this.$mailbox.id,"saveMessages",e,t)},r.prototype.downloadAttachments=function(){var e;return e={filename:l("attachments")+"-"+this.uid+".zip"},r.$$resource.download(this.$absolutePath(),"archiveAttachments",null,e)}}(),function(){"use strict";function h(){this.show=!1,this.message=null,this.elements=[]}h.$factory=["$document","$timeout","$mdPanel","sgHotkeys",function(e,t,n,s){return angular.extend(h,{$document:e,$timeout:t,$mdPanel:n,sgHotkeys:s}),new h}],h.prototype.setMessage=function(e){this.message=e},h.prototype.registerImage=function(e){this.elements.push(e)},h.prototype.registerHotkeys=function(e){this.keys=[h.sgHotkeys.createHotkey({key:"left",description:l("View previous item"),callback:angular.bind(e,e.previousImage)}),h.sgHotkeys.createHotkey({key:"right",description:l("View next item"),callback:angular.bind(e,e.nextImage)})],_.forEach(this.keys,function(e){h.sgHotkeys.registerHotkey(e)})},h.prototype.showGallery=function(e,t){var n=this,s=h.$mdPanel,i=angular.element(this.message.$content()[t].content).find("img")[0].src,o=_.filter(this.message.attachmentAttrs,function(e){return 0===e.mimetype.indexOf("image/")}),a=_.findIndex(o,function(e){return 0<=e.url.indexOf(i)});angular.element(h.$document[0].body).addClass("sg-image-gallery-backdrop");var r=s.newPanelPosition().absolute(),c=s.newPanelAnimation().openFrom(e.target).duration(100).withAnimation(s.animation.FADE),u={attachTo:angular.element(document.body),locals:{lastIndex:o.length-1,images:o,selectedIndex:a,selectedImage:o[a]},bindToController:!0,controller:d,controllerAs:"$panelCtrl",position:r,animation:c,targetEvent:e,fullscreen:!0,hasBackdrop:!0,template:['<sg-image-gallery layout="column">',' <div class="md-toolbar-tools" layout="row" layout-align="space-between center">',' <md-button class="md-icon-button"',' aria-label="'+l("Close")+'"',' ng-click="$panelCtrl.close()">'," <md-icon>arrow_back</md-icon>"," </md-button>",' <md-icon class="md-primary">image</md-icon>',' <div md-truncate class="md-flex" ng-bind="$panelCtrl.selectedImage.filename"></div>',' <md-button class="md-icon-button"',' aria-label="'+l("Save Attachment")+'"',' ng-href="{{$panelCtrl.selectedImage.urlAsAttachment}}">'," <md-icon>file_download</md-icon>"," </md-button>"," </div>",' <div class="md-flex" layout="row" layout-align="space-between center">',' <md-button class="md-icon-button" ng-click="$panelCtrl.previousImage()"',' ng-disabled="$panelCtrl.selectedIndex == 0">'," <md-icon>navigate_before</md-icon>"," </md-button>",' <img class="sg-image" ng-src="{{$panelCtrl.selectedImage.url}}">',' <md-button class="md-icon-button" ng-click="$panelCtrl.nextImage()"',' ng-disabled="$panelCtrl.selectedIndex == $panelCtrl.lastIndex">'," <md-icon>navigate_next</md-icon>"," </md-button>"," </div>",' <div class="sg-image-thumbnails">',' <div class="sg-image-thumbnail" ng-repeat="image in ::$panelCtrl.images">',' <img class="sg-hide" ng-src="{{::image.url}}" ng-click="$panelCtrl.selectImage($index)">'," </div>"," </div>","</sg-image-gallery>"].join(""),trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0,onOpenComplete:function(){n.show=!0,_.forEach(h.$document.find("sg-image-gallery")[0].getElementsByClassName("sg-image-thumbnail"),function(e){var t=e.children[0];angular.element(t).one("load",function(){t.naturalWidth<t.naturalHeight&&t.classList.add("portrait")}),h.$timeout(function(){t.classList.remove("sg-hide")},1e3)})},onDomRemoved:function(){angular.element(h.$document[0].body).removeClass("sg-image-gallery-backdrop"),n.show=!1,_.forEach(n.hotkeys,function(e){h.sgHotkeys.deregisterHotkey(e)})}};function d(e){(e.$ctrl=this).close=function(){e.close()},this.selectImage=function(e){this.selectedIndex=e,this.selectedImage=this.images[e]},this.nextImage=function(){this.selectedIndex!=this.lastIndex&&this.selectImage(this.selectedIndex+1)},this.previousImage=function(){0<this.selectedIndex&&this.selectImage(this.selectedIndex-1)}}s.open(u).then(function(e){n.registerHotkeys(e.$ctrl)}),d.$inject=["mdPanelRef"]},angular.module("SOGo.MailerUI").factory("ImageGallery",h.$factory)}(),function(){"use strict";function l(e){this.$account=e}l.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Mailbox","sgMailbox_PRELOAD",function(e,t,n,s,i,o,a,r){return angular.extend(l,{$q:e,$timeout:t,$log:n,$$resource:new i(s.activeUser("folderURL")+"Mail",s.activeUser()),$Message:a,selectedFolder:null,PRELOAD:r}),l}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMailbox_PRELOAD",{LOOKAHEAD:50,SIZE:100}).factory("VirtualMailbox",l.$factory),l.$absolutePath=function(e){return[e,"virtual"].join("/")},l.prototype.init=function(e){this.$isLoading=!1,this.$mailboxes=[],this.uidsMap={},angular.extend(this,e),this.id=this.$id()},l.prototype.setMailboxes=function(e){this.$mailboxes=e,_.forEach(this.$mailboxes,function(e){e.$messages=[],e.uidsMap={}})},l.prototype.startSearch=function(t,n){var s=this,i=l.$q.when();this.$isLoading=!0,_.forEach(this.$mailboxes,function(e){i=i.then(function(){if(s.$isLoading)return l.$log.debug("searching mailbox "+e.path),e.$filter({sort:"date",asc:!1,match:t},n)})}),i.finally(function(){s.$isLoading=!1})},l.prototype.stopSearch=function(){l.$log.debug("stopping search..."),this.$isLoading=!1},l.prototype.selectFolder=function(){},l.prototype.resetSelectedMessage=function(){_.forEach(this.$mailboxes,function(e){delete e.selectedMessage})},l.prototype.hasSelectedMessage=function(){return angular.isDefined(_.find(this.$mailboxes,function(e){return angular.isDefined(e.selectedMessage)}))},l.prototype.isSelectedMessage=function(t,n){return angular.isDefined(_.find(this.$mailboxes,function(e){return e.path==n&&e.selectedMessage==t}))},l.prototype.getLength=function(){var t=0;return angular.isDefined(this.$mailboxes)&&_.forEach(this.$mailboxes,function(e){t+=e.$messages.length}),t},l.prototype.getItemAtIndex=function(e){var t,n,s,i,o;if(angular.isDefined(this.$mailboxes)&&0<=e)for(n=t=0;n<this.$mailboxes.length;n++)for(i=this.$mailboxes[n],s=0;s<i.$messages.length;t++,s++)if(t==e&&(o=i.$messages[s],i.$loadMessage(o.uid)))return o;return null},l.prototype.$id=function(){return l.$absolutePath(this.$account.id)},l.prototype.$selectedMessageIndex=function(){var t=0,e=_.find(this.$mailboxes,function(e){return!!angular.isDefined(e.selectedMessage)||(t+=e.getLength(),!1)});return t+e.uidsMap[e.selectedMessage]},l.prototype.$selectedMessages=function(){return _.filter(_.transform(this.$mailboxes,function(e,t){e[t.id]=t.$selectedMessages()},{}),function(e){return 0<_.size(e)})},l.prototype.$selectedCount=function(){return _.sum(_.invokeMap(this.$mailboxes,"$selectedCount"))},l.prototype.$flagMessages=function(e,t,n){var i={flags:t,operation:n},o=[],a=[];return _.forEach(e,function(e,t){if(0<e.length){var n=_.map(e,"uid");o.push(e);var s=l.$$resource.post(t,"addOrRemoveLabel",_.assign(i,{msgUIDs:n}));a.push(s)}}),l.$q.all(a).then(function(){return _.flatten(o)})},l.prototype.$deleteMessages=function(e){var n=this,s=[];if(_.isArray(e)&&1===e.length){var t=e[0],i=t.$mailbox;return i.$deleteMessages([t]).then(function(e){var t=0;return _.find(n.$mailboxes,function(e){return e.id===i.id||(t+=e.getLength(),!1)}),t+e})}return _.forEach(e,function(e,t){if(0<e.length){var n=e[0].$mailbox.$deleteMessages(e);s.push(n)}}),l.$q.all(s)},l.prototype.$markOrUnMarkMessagesAsJunk=function(e){var s=[];return _.forEach(e,function(e,t){if(0<e.length){var n=e[0].$mailbox.$markOrUnMarkMessagesAsJunk(e);s.push(n)}}),l.$q.all(s)},l.prototype.$copyMessages=function(e,s){var i=[];return _.forEach(e,function(e,t){if(0<e.length){var n=e[0].$mailbox.$copyMessages(e,s);i.push(n)}}),l.$q.all(i)},l.prototype.$moveMessages=function(e,s){var i=[];return _.forEach(e,function(e,t){if(0<e.length){var n=e[0].$mailbox.$moveMessages(e,s);i.push(n)}}),l.$q.all(i)},l.prototype.$comact=function(){return!0}}(),function(){"use strict";function e(i,o,a,r,c,u,d,e,t,n,s,h,f,g,m,p,$,b){var v,y=this,M=angular.element(i.document).find("title").attr("sg-default")||"SOGo",x=[];function C(e){return!!b.$virtualMode||y.selectedFolder.$compact()}function w(e){var t=y.selectedFolder.$selectedMessageIndex();return angular.isDefined(t)?(t--,0<y.selectedFolder.$topIndex&&y.selectedFolder.$topIndex--):(t=y.selectedFolder.getLength()-1,y.selectedFolder.$topIndex=y.selectedFolder.getLength()),-1<t&&y.selectMessage(y.selectedFolder.getItemAtIndex(t)),e.preventDefault(),t}function I(e){var t=y.selectedFolder.$selectedMessageIndex();return angular.isDefined(t)?(t++,y.selectedFolder.$topIndex<y.selectedFolder.getLength()&&y.selectedFolder.$topIndex++):t=0,t<y.selectedFolder.getLength()?y.selectMessage(y.selectedFolder.getItemAtIndex(t)):t=-1,e.preventDefault(),t}function S(e){var t;y.selectedFolder.hasSelectedMessage()&&0<=(t=w(e))&&y.toggleMessageSelection(e,y.selectedFolder.$messages[t])}function E(e){var t;y.selectedFolder.hasSelectedMessage()&&0<=(t=I(e))&&y.toggleMessageSelection(e,y.selectedFolder.$messages[t])}function A(){return b.$virtualMode?y.selectedFolder.$mailboxes:[y.selectedFolder]}function F(e,t){var n,s,i=t;y.mode.multiple=y.selectedFolder.$selectedCount(),e?(0<t&&(i-=1,n=y.selectedFolder.$messages[i]),t<y.selectedFolder.$messages.length&&(s=y.selectedFolder.$messages[t]),n?n.isread&&s&&!s.isread&&(i=t,n=s):s&&(i=t,n=s),n?(y.selectedFolder.$topIndex=i,c.go("mail.account.mailbox.message",{messageId:n.uid})):c.go("mail.account.mailbox")):a(function(){console.warn("go to mailbox"),c.go("mail.account.mailbox")})}v={subject:"Subject",from:"From",date:"Date",size:"Size",arrival:"Order Received"},this.$onInit=function(){i.$mailboxController=y,this.service=b,this.accounts=e,this.account=t,this.selectedFolder=n,this.messageDialog=null,this.mode={search:!1,multiple:0},function(t){t.push(s.createHotkey({key:l("hotkey_search"),description:l("Search"),callback:y.searchMode})),t.push(s.createHotkey({key:l("hotkey_compose"),description:l("Write a new message"),callback:function(e){null===y.messageDialog&&y.newMessage(e)}})),t.push(s.createHotkey({key:l("hotkey_junk"),description:l("Mark the selected messages as junk"),callback:y.markOrUnMarkMessagesAsJunk})),t.push(s.createHotkey({key:"space",description:l("Toggle item"),callback:y.toggleMessageSelection})),t.push(s.createHotkey({key:"shift+space",description:l("Toggle range of items"),callback:y.toggleMessageSelection})),t.push(s.createHotkey({key:"up",description:l("View next item"),callback:w,preventInClass:["sg-mail-part"]})),t.push(s.createHotkey({key:"down",description:l("View previous item"),callback:I,preventInClass:["sg-mail-part"]})),t.push(s.createHotkey({key:"shift+up",description:l("Add next item to selection"),callback:S,preventInClass:["sg-mail-part"]})),t.push(s.createHotkey({key:"shift+down",description:l("Add previous item to selection"),callback:E,preventInClass:["sg-mail-part"]})),_.forEach(["backspace","delete"],function(e){t.push(s.createHotkey({key:e,description:l("Delete selected message or folder"),callback:y.confirmDeleteSelectedMessages}))}),_.forEach(t,function(e){s.registerHotkey(e)})}(x),angular.element(i).on("beforeunload",C),o.$on("$destroy",function(){angular.element(i).off("beforeunload",C),_.forEach(x,function(e){s.deregisterHotkey(e)})}),o.$watch(function(){return y.selectedFolder.unseenCount},function(e){var t="";e&&(t+="("+e+") "),t+=y.selectedFolder.$displayName,t+=" | "+M,i.document.title=t})},this.centerIsClose=function(e){return this.selectedFolder.hasSelectedMessage()&&!!e},this.sort=function(e){if(!e)return v[y.service.$query.sort];y.selectedFolder.$filter({sort:e})},this.sortedBy=function(e){return b.$query.sort==e},this.ascending=function(){return b.$query.asc},this.refresh=function(){p.pollInbox(),this.selectedFolder.$filter()},this.searchMode=function(e){y.mode.search=!0,g("search"),e&&e.preventDefault()},this.cancelSearch=function(){y.mode.search=!1,y.selectedFolder.$filter().then(function(){y.selectedFolder.selectedMessage&&a(function(){y.selectedFolder.$topIndex=y.selectedFolder.uidsMap[y.selectedFolder.selectedMessage]})})},this.composeWindowEnabled=function(){return p.defaults.SOGoMailComposeWindowEnabled},this.newMessage=function(e,t){var n,s=r.defer();null===y.messageDialog&&(t||"popup"==p.defaults.SOGoMailComposeWindow?function(){var e=[f.baseURL(),"UIxMailPopupView#!/Mail",y.account.id,h(h(y.selectedFolder.path)),"new"].join("/"),t=y.selectedFolder.$id()+"/"+Math.random(0,1e3);i.open(e,t,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))}():(n=y.account.$newMessage(),y.messageDialog=u.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",onComplete:function(e,t){return s.resolve(t)},locals:{stateParent:o,stateAccount:y.account,stateMessage:n,onCompletePromise:function(){return s.promise}}}).catch(_.noop).finally(function(){y.messageDialog=null})))},this.selectMessage=function(e){b.$virtualMode?c.go("mail.account.virtualMailbox.message",{mailboxId:h(e.$mailbox.path),messageId:e.uid}):c.go("mail.account.mailbox.message",{messageId:e.uid})},this.toggleMessageSelection=function(e,t){var n,s,i,o=y.selectedFolder;if(!(t=t||o.$selectedMessage()))return!0;if(t.selected=!t.selected,y.mode.multiple+=t.selected?1:-1,e.shiftKey&&1<o.$selectedCount()){for(s=(n=o.uidsMap[t.uid])-2;0<=s&&!o.$messages[s].selected;)s--;if(s<0)for(s=n+2;s<o.getLength()&&!o.$messages[s].selected;)s++;if(0<=s&&s<o.getLength())for(i=Math.min(n,s);i<=Math.max(n,s);i++)o.$messages[i].selected=!0}e.preventDefault(),e.stopPropagation()},this.confirmDeleteSelectedMessages=function(e){var n=y.selectedFolder.$selectedMessages();null===y.messageDialog&&0<_.size(n)&&(y.messageDialog=m.confirm(l("Confirmation"),l("Are you sure you want to delete the selected messages?"),{ok:l("Delete")}).then(function(){var t=y.selectedFolder.hasSelectedMessage();y.selectedFolder.$deleteMessages(n).then(function(e){b.$virtualMode?t&&c.go("mail.account.virtualMailbox"):F(t,e)},function(e){y.messageDialog=m.confirm(l("Warning"),l("The messages could not be moved to the trash folder. Would you like to delete them immediately?"),{ok:l("Delete")}).then(function(){y.selectedFolder.$deleteMessages(n,{withoutTrash:!0}).then(function(e){b.$virtualMode?t&&c.go("mail.account.virtualMailbox"):F(t,e)}).finally(function(){y.messageDialog=null})})})}).finally(function(){y.messageDialog=null})),e.preventDefault()},this.markOrUnMarkMessagesAsJunk=function(){var t=y.selectedFolder.hasSelectedMessage(),n=y.selectedFolder.$selectedMessages();0===_.size(n)&&t&&(n=[y.selectedFolder.$selectedMessage()]),0<_.size(n)&&y.selectedFolder.$markOrUnMarkMessagesAsJunk(n).then(function(){var e="/"+y.account.id+"/folderINBOX";"junk"!=y.selectedFolder.type&&(e="/"+y.account.$getMailboxByType("junk").id),y.selectedFolder.$moveMessages(n,e).then(function(e){b.$virtualMode?t&&c.go("mail.account.virtualMailbox"):F(t,e)})})},this.copySelectedMessages=function(e){var t=y.selectedFolder.$selectedMessages();0<_.size(t)&&y.selectedFolder.$copyMessages(t,"/"+e).then(function(){d.show(d.simple().textContent(l("%{0} message(s) copied",y.selectedFolder.$selectedCount())).position("top right").hideDelay(2e3))})},this.moveSelectedMessages=function(e){var t=y.selectedFolder.hasSelectedMessage(),n=y.selectedFolder.$selectedMessages(),s=y.selectedFolder.$selectedCount();0<_.size(n)&&y.selectedFolder.$moveMessages(n,"/"+e).then(function(e){d.show(d.simple().textContent(l("%{0} message(s) moved",s)).position("top right").hideDelay(2e3)),b.$virtualMode?t&&c.go("mail.account.virtualMailbox"):F(t,e)})},this.selectAll=function(){var s=0;_.forEach(A(),function(e){for(var t=0,n=e.$messages.length;t<n;t++)e.$messages[t].selected=!0;s+=n}),y.mode.multiple=s},this.unselectMessages=function(){_.forEach(A(),function(e){_.forEach(e.$messages,function(e){e.selected=!1})}),y.mode.multiple=0},this.markSelectedMessagesAsFlagged=function(){var e=y.selectedFolder.$selectedMessages();0<_.size(e)&&y.selectedFolder.$flagMessages(e,"\\Flagged","add").then(function(e){_.forEach(e,function(e){e.isflagged=!0})})},this.markSelectedMessagesAsUnread=function(){var e=y.selectedFolder.$selectedMessages();0<_.size(e)&&y.selectedFolder.$flagMessages(e,"seen","remove").then(function(e){_.forEach(e,function(e){e.isread&&e.$mailbox.unseenCount++,e.isread=!1})})},this.markSelectedMessagesAsRead=function(){var e=y.selectedFolder.$selectedMessages();0<_.size(e)&&y.selectedFolder.$flagMessages(e,"seen","add").then(function(e){_.forEach(e,function(e){e.isread||e.$mailbox.unseenCount--,e.isread=!0})})}}function t(e){return e[0].controller.prototype.resetScroll=function(){"messagesList"==this.$element.parent().attr("id")?this.updateSize():this.scrollTo(0)},e}e.$inject=["$window","$scope","$timeout","$q","$state","$mdDialog","$mdToast","stateAccounts","stateAccount","stateMailbox","sgHotkeys","encodeUriFilter","sgSettings","sgFocus","Dialog","Preferences","Account","Mailbox"],angular.module("SOGo.MailerUI").controller("MailboxController",e),t.$inject=["$delegate"],angular.module("material.components.virtualRepeat").decorator("mdVirtualRepeatContainerDirective",t)}(),function(){"use strict";function e(e,u,t,n,s,i,o,a,r,d,c,h,f,g,m,p,$,b,v,y,M,x){var C,w,I=this,S=[];this.$onInit=function(){this.service=b,this.accounts=x,this.currentSearchParam="",this.search={options:{"":"",subject:l("Enter Subject"),from:l("Enter From"),to:l("Enter To"),cc:l("Enter Cc"),body:l("Enter Body")},subfolders:1,match:"AND",params:[]},this.showSubscribedOnly=M.defaults.SOGoMailShowSubscribedFoldersOnly,this.refreshUnseenCount(),function(t){_.forEach(["backspace","delete"],function(e){t.push(p.createHotkey({key:e,description:l("Delete selected message or folder"),callback:function(){b.selectedFolderController&&b.selectedFolder&&b.selectedFolder.$isEditable&&!b.selectedFolder.hasSelectedMessage()&&0===b.selectedFolder.$selectedCount()&&b.selectedFolderController.confirmDelete(b.selectedFolder)}}))}),_.forEach(t,function(e){p.registerHotkey(e)})}(S),e.$on("$destroy",function(){_.forEach(S,function(e){p.deregisterHotkey(e)})})},this.hideAdvancedSearch=function(){I.service.$virtualPath=!1,I.service.$virtualMode=!1,C=I.accounts[0],w=I.searchPreviousMailbox,u.go("mail.account.mailbox",{accountId:C.id,mailboxId:f(w.path)})},this.toggleAdvancedSearch=function(){if(b.selectedFolder.$isLoading)I.virtualMailbox.stopSearch();else{var e,t=[],n=function(e){_.forEach(e,function(e){e.isNoSelect()||t.push(e),e.children&&0<e.children.length&&n(e.children)})};I.virtualMailbox=new v(I.accounts[0]),b.$virtualMode||(I.searchPreviousMailbox=b.selectedFolder),b.selectedFolder=I.virtualMailbox,b.$virtualMode=!0,b.$virtualPath.length?(e=I.accounts[0].$getMailboxByPath(b.$virtualPath),t.push(e),I.search.subfolders&&e.children.length&&n(e.children)):t=_.filter(I.accounts[0].$flattenMailboxes({all:!0}),function(e){return!e.isNoSelect()}),I.virtualMailbox.setMailboxes(t),I.virtualMailbox.startSearch(I.search.match,I.search.params),"mail.account.virtualMailbox"!=u.$current.name&&u.go("mail.account.virtualMailbox",{accountId:I.accounts[0].id})}},this.addSearchParam=function(e){return this.currentSearchParam=e,h("advancedSearch"),!1},this.newSearchParam=function(e){if(e.length&&this.currentSearchParam.length){var t=0,n=this.currentSearchParam;return e.startsWith("!")&&(t=1,e=e.substring(1).trim()),this.currentSearchParam="",{searchBy:n,searchInput:e,negative:t}}},this.toggleAccountState=function(e){e.$expanded=!e.$expanded,this.debounceSaveState||(this.debounceSaveState=i.debounce(function(){e.$flattenMailboxes({reload:!0,saveState:!0})},1e3)),this.debounceSaveState()},this.subscribe=function(e){function t(e,t,n){var s=this;s.loading=!0,s.filter={name:""},s.account=new $({id:n.id,name:n.name}),s.close=function(){t.hide()},s.account.$getMailboxes({reload:!0,all:!0}).then(function(){s.loading=!1})}r.show({templateUrl:e.id+"/subscribe",controller:t,controllerAs:"subscriptions",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAccount:e}}).finally(function(){e.$getMailboxes({reload:!0})}),t.$inject=["$scope","$mdDialog","srcAccount"]},this.showAdvancedSearch=function(){b.$virtualPath="",o(c["gt-md"])||a("left").close()},this.newFolder=function(e){g.prompt(l("New Folder..."),l("Enter the new name of your folder")).then(function(n){e.$newMailbox(e.id,n).then(function(){},function(e,t){g.alert(l('An error occured while creating the mailbox "%{0}".',n),l(e.error))})})},this.delegate=function(e){function t(e,t,n,s){var i=this;i.users=s.delegates,i.account=s,i.userToAdd="",i.searchText="",i.userFilter=function(e){return n.$filter(e,s.delegates)},i.closeModal=function(){t.hide()},i.removeUser=function(e){s.$removeDelegate(e.uid).catch(function(e,t){g.alert(l("Warning"),l("An error occured, please try again."))})},i.addUser=function(e){e&&s.$addDelegate(e).then(function(){i.userToAdd="",i.searchText=""},function(e){g.alert(l("Warning"),e)})}}r.show({templateUrl:e.id+"/delegation",controller:t,controllerAs:"delegate",clickOutsideToClose:!0,escapeToClose:!0,locals:{User:y,account:e}}),t.$inject=["$scope","$mdDialog","User","account"]},this.refreshUnseenCount=function(){var t,e;t=1===M.defaults.SOGoMailFetchAllUnseenCountFolders?[]:s.unseenCountFolders,_.forEach(I.accounts,function(e){1===M.defaults.SOGoMailFetchAllUnseenCountFolders?_.forEach(e.$$flattenMailboxes,function(e){t.push(e.id)}):(_.includes(t,e.id+"/folderINBOX")||t.push(e.id+"/folderINBOX"),_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(e.unseenCount)&&!_.includes(t,e.id)&&t.push(e.id)}))}),$.$$resource.post("","unseenCount",{mailboxes:t}).then(function(t){_.forEach(I.accounts,function(e){_.forEach(e.$$flattenMailboxes,function(e){t[e.id]&&(e.unseenCount=t[e.id])})})}),(e=M.defaults.SOGoRefreshViewCheck)&&"manually"!=e&&n(I.refreshUnseenCount,1e3*e.timeInterval())},this.isDroppableFolder=function(e,t){return t.id!=e.id&&!t.isNoSelect()},this.dragSelectedMessages=function(e,t,n){var s,i,o,a,r,c;s="/"+t.id,0===(i=e.$selectedMessages()).length&&(i=[e.$selectedMessage()]),o=_.map(i,"uid"),a=e.selectedMessage&&0<=o.indexOf(e.selectedMessage),c="copy"==n?(r=e.$copyMessages(i,s),l("%{0} message(s) copied",i.length)):(r=e.$moveMessages(i,s),l("%{0} message(s) moved",i.length)),r.then(function(){a&&u.go("mail.account.mailbox"),d.show(d.simple().textContent(c).position("top right").hideDelay(2e3))})}}e.$inject=["$scope","$state","$transitions","$timeout","$window","$mdUtil","$mdMedia","$mdSidenav","$mdDialog","$mdToast","sgConstant","sgFocus","encodeUriFilter","Dialog","sgSettings","sgHotkeys","Account","Mailbox","VirtualMailbox","User","Preferences","stateAccounts"],angular.module("SOGo.MailerUI").controller("MailboxesController",e)}(),function(){"use strict";function e(s,i,o,c,u,a,r,d,t,n,h,f,g,m,p,$,b,v,y,M,x,e,C,w,I,S){var E=this,A=[];function F(e){return i.mailbox?(0<arguments.length&&(i.mailbox.messageDialog=e),i.mailbox.messageDialog):null}function D(e){return function(){if(null===F())return e.apply(E,arguments)}}function k(){var e,t,n={};return s.opener&&"$mailboxController"in s.opener&&"selectedFolder"in s.opener.$mailboxController&&s.opener.$mailboxController.selectedFolder.$id()==h.$id()&&(t=s.opener.$mailboxController,n.mailboxCtrl=t,"$messageController"in s.opener&&s.opener.$messageController.message.uid==f.uid&&(e=s.opener.$messageController,n.messageCtrl=e)),n}function O(e,t){if(null===F()){var n=o.defer();F(a.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",onComplete:function(e,t){return n.resolve(t)},locals:{stateParent:i,stateAccount:E.account,stateMessage:t,onCompletePromise:function(){return n.promise}}}).catch(_.noop).finally(function(){F(null),E.closePopup()}))}}function P(i,o){E.message.$plainContent().then(function(e){var t={pid:M.$defaultCalendar(),type:o,summary:e.subject,comment:e.content},n=new x(t),s=[p.activeUser("folderURL"),"Calendar","UIx"+o.capitalize()+"EditorTemplate"].join("/");return a.show({parent:angular.element(document.body),targetEvent:i,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:s,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:n}})})}this.$onInit=function(){var e=!1;s.$messageController=E,$.setMessage(f),this.$state=c,this.accounts=t,this.account=n,this.mailbox=h,this.message=f,this.service=w,this.tags={searchText:"",selected:""},this.showFlags=f.flags&&0<f.flags.length,this.$alwaysShowDetailedRecipients=(!f.to||f.to.length<5)&&(!f.cc||f.cc.length<5),this.$showDetailedRecipients=this.$alwaysShowDetailedRecipients,this.showRawSource=!1,function(t){t.push(g.createHotkey({key:l("hotkey_reply"),description:l("Reply to the message"),callback:D(angular.bind(E,E.reply))})),t.push(g.createHotkey({key:l("hotkey_replyall"),description:l("Reply to sender and all recipients"),callback:D(angular.bind(E,E.replyAll))})),t.push(g.createHotkey({key:l("hotkey_forward"),description:l("Forward selected message"),callback:D(angular.bind(E,E.forward))})),t.push(g.createHotkey({key:l("hotkey_flag"),description:l("Flagged"),callback:D(angular.bind(f,f.toggleFlag))})),_.forEach(["backspace","delete"],function(e){t.push(g.createHotkey({key:e,callback:D(function(e){0===E.mailbox.$selectedCount()&&E.deleteMessage(),e.preventDefault()})}))}),_.forEach(t,function(e){g.registerHotkey(e)})}(A);try{e=s.opener&&"$mailboxController"in s.opener}catch(e){}e?(i.$watchCollection(function(){return E.message.flags},function(e,t){var n;(e||t)&&(n=k()).messageCtrl&&n.messageCtrl.service.$timeout(function(){n.messageCtrl.showFlags=!0,n.messageCtrl.message.flags=e})}),i.$watch(function(){return E.message.isflagged},function(e,t){var n=k();n.mailboxCtrl&&n.mailboxCtrl.service.$timeout(function(){_.find(n.mailboxCtrl.selectedFolder.$messages,{uid:E.message.uid}).isflagged=e})})):i.$watchCollection(function(){return E.message.flags},function(e,t){var n,s,i;(e||t)&&(n=e||[],s=t||[],_.forEach(n,function(e,t){angular.isObject(e)&&(n[t]=e.name)}),n.length>s.length?(i=_.difference(n,s),_.forEach(i,function(e){E.message.addTag(e)})):n.length<s.length&&(i=_.difference(s,n),_.forEach(i,function(e){E.message.removeTag(e)})))}),i.$on("$destroy",function(){_.forEach(A,function(e){g.deregisterHotkey(e)})})},this.addFlags=function(e){e.stopPropagation(),e.preventDefault(),this.showFlags=!0,b("flags")},this.toggleDetailedRecipients=function(e){this.$showDetailedRecipients=!this.$showDetailedRecipients,e.stopPropagation(),e.preventDefault()},this.focusChip=function(e){for(var t=e.target;"MD-CHIP"!==t.tagName;)t=t.parentNode;t.classList.add("md-focused")},this.blurChip=function(e){for(var t=e.target;"MD-CHIP"!==t.tagName;)t=t.parentNode;t.classList.remove("md-focused"),e.relatedTarget&&"MD-CHIP-TEMPLATE"===e.relatedTarget.tagName&&E.panel.close()},this.selectRecipient=function(e,t){I.$findAll([]);var n=t.target,s=r.newPanelPosition().relativeTo(n).addPanelPosition(r.xPosition.ALIGN_START,r.yPosition.ALIGN_TOPS),i=r.newPanelAnimation().openFrom(n).duration(100).withAnimation(r.animation.FADE),o={attachTo:angular.element(document.body),locals:{recipient:e,addressbooks:I.$addressbooks,subscriptions:I.$subscriptions,newMessage:angular.bind(this,this.newMessage)},bindToController:!0,controller:a,controllerAs:"$menuCtrl",position:s,animation:i,targetEvent:t,templateUrl:"UIxMailViewRecipientMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!1};function a(s,e,i){this.onKeyDown=function(e){9===e.which&&s.close()},this.newCard=function(e,t){var n=new S({pid:t,c_cn:e.name,emails:[{value:e.email}]});n.$id().then(function(e){n.$save().then(function(){i.show(i.simple().textContent(l("Successfully created card")).position("top right").hideDelay(2e3))})}),s.close()}}r.open(o).then(function(e){(E.panel=e).panelEl.one("click",function(){e.close()})}),a.$inject=["mdPanelRef","$state","$mdToast"],"A"===n.tagName&&(t.stopPropagation(),t.preventDefault())},this.filterMailtoLinks=function(e){var t;"A"==e.target.tagName&&"href"in e.target.attributes&&(t=e.target.attributes.href.value,/^mailto:([^\?]+)/.exec(t)&&(delete e.target.attributes.target,this.newMessage(e,t)))},this.deleteMessage=function(){var n,s,i,o,a,e=k(),r=this.service.$timeout;function t(e){var t=e;if(s=null,angular.isDefined(i)){0<e&&(t-=1,o=n.getItemAtIndex(t)),e<n.getLength()&&(a=n.getItemAtIndex(e)),o?o.isread&&a&&!a.isread&&(t=e,o=a):a&&(t=e,o=a);try{o&&u(d["gt-md"])?(C.$virtualMode?i.go("mail.account.virtualMailbox.message",{mailboxId:m(o.$mailbox.path),messageId:o.uid}):i.go("mail.account.mailbox.message",{messageId:o.uid}),r(function(){t<n.$topIndex?n.$topIndex=t:t>n.$lastVisibleIndex&&(n.$topIndex=t-(n.$lastVisibleIndex-n.$topIndex))})):i.go("mail.account.mailbox").then(function(){s=null,delete n.selectedMessage})}catch(e){}}E.closePopup()}i=e.messageCtrl?(n=e.mailboxCtrl.selectedFolder,s=e.messageCtrl.message,e.messageCtrl.$state):(n=h,s=f,c),C.$virtualMode&&(n=C.selectedFolder),n.$deleteMessages([s]).then(t,function(e){F(v.confirm(l("Warning"),l("The message could not be moved to the trash folder. Would you like to delete it immediately?"),{ok:l("Delete")}).then(function(){n.$deleteMessages([s],{withoutTrash:!0}).then(t).finally(function(){F(null)})}).finally(function(){F(null)}))})},this._showMailEditorInPopup=function(e){return!p.isPopup&&"popup"==y.defaults.SOGoMailComposeWindow&&(this.openInPopup(e),!0)},this.close=function(){var e=C.$virtualMode?"mail.account.virtualMailbox":"mail.account.mailbox";c.go(e).then(function(){E.message=null,delete h.selectedMessage})},this.reply=function(e){this._showMailEditorInPopup("reply")||O(e,this.message.$reply())},this.replyAll=function(e){this._showMailEditorInPopup("replyall")||O(e,this.message.$replyAll())},this.forward=function(e){this._showMailEditorInPopup("forward")||O(e,this.message.$forward())},this.edit=function(e){this._showMailEditorInPopup("edit")||this.message.$editableContent().then(function(){O(e,E.message)})},this.openInPopup=function(e){var t=[p.baseURL(),"UIxMailPopupView#!/Mail",this.message.accountId,m(m(this.message.$mailbox.path)),this.message.uid].join("/"),n=this.message.$absolutePath();e&&(t+="/"+e),s.open(t,n,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))},this.closePopup=function(){s.document.body.classList.contains("popup")&&s.close()},this.newMessage=function(t,e){"A"===t.target.tagName&&(t.stopPropagation(),t.preventDefault()),this.account.$newMessage({mailto:e}).then(function(e){O(t,e)})},this.toggleRawSource=function(e){this.showRawSource||this.message.$rawSource?this.showRawSource=!this.showRawSource:w.$$resource.post(this.message.id,"viewsource").then(function(e){E.message.$rawSource=e,E.showRawSource=!0})},this.print=function(e){s.print()},this.convertToEvent=function(e){return P(e,"appointment")},this.convertToTask=function(e){return P(e,"task")}}e.$inject=["$window","$scope","$q","$state","$mdMedia","$mdDialog","$mdPanel","sgConstant","stateAccounts","stateAccount","stateMailbox","stateMessage","sgHotkeys","encodeUriFilter","sgSettings","ImageGallery","sgFocus","Dialog","Preferences","Calendar","Component","Account","Mailbox","Message","AddressBook","Card"],angular.module("SOGo.MailerUI").controller("MessageController",e)}(),function(){"use strict";function e(e,s,t,n,i,o,a,r,c,u,d,h,f,g,m,p,$,b,v){var y=this;function M(){var e,t={};try{s.opener&&"$mailboxController"in s.opener&&"selectedFolder"in s.opener.$mailboxController&&("draft"==s.opener.$mailboxController.selectedFolder.type?(t.draftMailboxCtrl=s.opener.$mailboxController,"$messageController"in s.opener&&s.opener.$messageController.message.uid==d.uid&&(t.draftMessageCtrl=s.opener.$messageController)):d.origin&&(e=d.origin.message,s.opener.$mailboxController.selectedFolder.$id()==e.$mailbox.$id()&&(t.originMailboxCtrl=s.opener.$mailboxController)))}catch(e){}return t}function x(){y.uploader.url=y.message.$absolutePath({asDraft:!0,withResourcePath:!0})+"/save"}function C(){var e,t,n,s=y.message.editable.attachmentAttrs;if(s)for(e=0;e<s.length;e++)t={name:s[e].filename,type:s[e].mimetype,size:parseInt(s[e].size)},(n=new r.FileItem(y.uploader,t)).progress=100,n.isUploaded=!0,n.isSuccess=!0,n.inlineUrl=s[e].url,y.uploader.queue.push(n)}function w(e,t){e.isUploading?y.uploader.cancelItem(e):(y.message.$deleteAttachment(e.file.name),e.remove());var n=s.document.getElementById(t);n&&angular.element(n).prop("value",null)}function I(){y.autosave&&g.cancel(y.autosave),y.message.isNew&&y.message.attachmentAttrs&&y.message.$mailbox.$deleteMessages([y.message]),o.cancel()}function S(){y.isFullscreen=!y.isFullscreen}function E(e){return $.$filterAll(e).then(function(e){var t=[];return _.forEach(_.invokeMap(e,"explode"),function(e){_.forEach(e,function(e){t.push(e)})}),_.uniqBy(t,function(e){return e.$$fullname+" "+e.$$email})})}function A(){y.message.$save(),v.defaults.SOGoMailAutoSave&&(y.autosave=g(y.autosaveDrafts,1e3*v.defaults.SOGoMailAutoSave*60))}this.$onInit=function(){e.isPopup=c.isPopup,this.account=u,this.autocomplete={to:{},cc:{},bcc:{}},this.autosave=null,this.autosaveDrafts=A,this.cancel=I,this.contactFilter=E,this.isFullscreen=!1,this.hideBcc=0===d.editable.bcc.length,this.hideCc=0===d.editable.cc.length,this.identities=u.identities,this.fromIdentity=d.editable.from,this.identitySearchText="",this.message=d,this.recipientSeparatorKeys=[n.KEY_CODE.ENTER,n.KEY_CODE.TAB,n.KEY_CODE.COMMA,n.KEY_CODE.SEMICOLON],this.removeAttachment=w,this.sendState=!1,this.toggleFullscreen=S,this.firstFocus=!0,y.uploader=new r({url:y.message.$absolutePath({asDraft:!0,withResourcePath:!0})+"/save",autoUpload:!0,alias:"attachments",removeAfterUpload:!1,onSuccessItem:function(e,t,n,s){y.message.$setUID(t.uid),y.message.$reload(),e.inlineUrl=t.lastAttachmentAttrs[0].url,e.file.name=t.lastAttachmentAttrs[0].filename},onCancelItem:function(e,t,n,s){y.message.$deleteAttachment(e.file.name),this.removeFromQueue(e)},onErrorItem:function(e,t,n,s){a.show(a.simple().textContent(l('Error while uploading the file "%{0}":',e.file.name)+" "+(t.message?l(t.message):"")).position("top right").action(l("OK")).hideDelay(!1)),this.removeFromQueue(e)}}),v.defaults.SOGoMailAutoSave&&(this.autosave=g(this.autosaveDrafts,1e3*v.defaults.SOGoMailAutoSave*60)),this.localeCode=v.defaults.LocaleCode,this.ckConfig={language:v.defaults.LocaleCode},this.composeType=v.defaults.SOGoMailComposeMessageType,this.signaturePlacement=v.defaults.SOGoMailSignaturePlacement,this.replyPlacement=v.defaults.SOGoMailReplyPlacement,this.message.origin&&"forward"==this.message.origin.action&&(this.replyPlacement="above"),e.$on("$destroy",function(){y.uploader.destroy()}),"reply"==t.actionName?d.$reply().then(function(e){y.message=e,y.fromIdentity=e.editable.from,y.hideCc=!e.editable.cc||0===e.editable.cc.length,y.hideBcc=!e.editable.bcc||0===e.editable.bcc.length,x()}):"replyall"==t.actionName?d.$replyAll().then(function(e){y.message=e,y.fromIdentity=e.editable.from,y.hideCc=!e.editable.cc||0===e.editable.cc.length,y.hideBcc=!e.editable.bcc||0===e.editable.bcc.length,x()}):"forward"==t.actionName?d.$forward().then(function(e){y.message=e,y.fromIdentity=e.editable.from,x(),C()}):angular.isDefined(d)&&(this.message=d,x(),C())},this.save=function(){var t=M();this.message.$save().then(function(e){y.message.$rawSource=null,t.draftMailboxCtrl&&t.draftMailboxCtrl.selectedFolder.$filter().then(function(){t.draftMessageCtrl&&t.draftMessageCtrl.$state.go("mail.account.mailbox.message",{messageId:y.message.uid})}),a.show(a.simple().textContent(l("Your email has been saved")).position("top right").hideDelay(3e3))})},this.send=function(){this.sendState="sending",this.autosave&&g.cancel(this.autosave),this.message.$send().then(function(e){var t=M();y.sendState="sent",t.draftMailboxCtrl&&t.draftMailboxCtrl.selectedFolder.$filter().then(function(){t.draftMessageCtrl&&t.draftMessageCtrl.close()}),t.originMailboxCtrl&&t.originMailboxCtrl.selectedFolder.$filter(),a.show(a.simple().textContent(l("Your email has been sent")).position("top right").hideDelay(3e3)),g(o.hide,1e3)},function(e){g(function(){y.sendState="error",y.errorMessage=e.data?e.data.message:e.statusText})})},this.addRecipient=function(e,t){var n,s,i,o,a,r=/([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i;if(n=this.message.editable[t],angular.isString(e)){for(a="",o=0;o<e.length;o++)(9==e.charCodeAt(o)||32==e.charCodeAt(o)||44==e.charCodeAt(o)||59==e.charCodeAt(o))&&r.test(a)&&n.indexOf(a)<0?(n.push(a),a=""):a+=e.charAt(o);return a&&n.indexOf(a)<0&&n.push(a),null}return e.$isList({expandable:!0})?angular.isDefined(e.refs)&&e.refs.length?_.forEach(e.refs,function(e){e.email.length&&n.indexOf(e.$shortFormat())<0&&n.push(e.$shortFormat())}):(i=b.$find(e.container,e.c_name)).$id().then(function(e){_.forEach(i.refs,function(e){e.email.length&&n.indexOf(e.$shortFormat())<0&&n.push(e.$shortFormat())})}):e.$isGroup({expandable:!0})?(s={toString:function(){return e.$shortFormat()},isExpandable:!0,members:[]},e.$members().then(function(e){s.members=e})):s=e.$shortFormat(),s||null},this.setFromIdentity=function(e){var t,s,i,o;if(e&&e.full)this.message.editable.from=e.full;else if(e&&e.length)return;if(i="html"==this.composeType?(t="<br />",s="<br ?/>[ \n]?"," "):(s=t="\n"," "),o=e&&e.signature?t+t+"--"+i+t+e.signature:"",!_.find(this.identities,function(e,t){if(e.signature){var n=new RegExp(s+s+"--"+i+s+e.signature.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&"));if(0<=y.message.editable.text.search(n))return y.message.editable.text=y.message.editable.text.replace(n,o),!0}return!1})&&0<o.length)if(this.isNew()||"above"!=this.signaturePlacement)this.message.editable.text+=o;else{var n=this.message.editable.text.search(new RegExp(s+".+?:( ?"+s+'){2}(> |<blockquote type="cite")'));this.message.editable.text=0<=n?this.message.editable.text.slice(0,n)+o+this.message.editable.text.slice(n):o+this.message.editable.text}},this.identitySearch=function(e){var t=e||"";return _.filter(u.identities,function(e){return 0<=e.full.toLowerCase().indexOf(t.toLowerCase())})},this.expandGroup=function(e,t){var n,s,i;for(s=(n=this.message.editable[t]).indexOf(e),n.splice(s,1),i=0;i<e.members.length;i++){var o=e.members[i].$shortFormat();n.indexOf(o)<0&&n.splice(s+i,0,e.members[i].$shortFormat())}},this.isNew=function(){return void 0===this.message.origin},this.onTextFocus=function(e){var a=e.target;this.firstFocus&&(h().then(function(e){var t,n,s=angular.element(a).val(),i=/\n-- \n/.test(s),o=0;"above"==y.replyPlacement?(a.setCaretTo(0),e.find("md-dialog-content")[0].scrollTop=0):(i&&-1<(t=s.lastIndexOf("-- "))&&(o=s.length-t),n=function(e,t){var n,s=t;return-1<e.indexOf("\r\n")&&(s-=(n=e.replace(/\r\n/g,"\n").slice(0,t).match(/\n/g))?n.length-1:0),s}(s,n=s.length-o),i&&(n-=2),a.setCaretTo(n))}),this.firstFocus=!1)},this.onHTMLReady=function(e){this.isNew()||h().then(function(){e.focus()})},this.onHTMLFocus=function(r){this.firstFocus&&(h().then(function(e){var t,n="above"==y.replyPlacement,s=r.getSelection(),i=s.getRanges(),o=r.document.getBody().getChildren();if(n)t=o.getItem(0);else for(t=o.getItem(o.count()-1);;){var a=t.getPrevious();if(null===a)break;if(/--(%20|%A0|%C2%A0)/.test(encodeURI(a.getText()))){t=a.getPrevious().getPrevious();break}t=a}s.selectElement(t),n&&s.scrollIntoView(),(i=s.getRanges())[0].collapse(!0),s.selectRanges(i),n||s.scrollIntoView()}),this.firstFocus=!1)}}function t(e,t){e.closeToast=function(){t.hide()}}e.$inject=["$scope","$window","$stateParams","$mdConstant","$mdUtil","$mdDialog","$mdToast","FileUploader","stateParent","stateAccount","stateMessage","onCompletePromise","encodeUriFilter","$timeout","sgFocus","Dialog","AddressBook","Card","Preferences"],t.$inject=["$scope","$mdToast"],angular.module("SOGo.MailerUI").controller("SendMessageToastController",t).controller("MessageEditorController",e)}(),function(){function e(e,t,n,s,i,o,a,r){var l=[];this.$postLink=function(){this.quotaElement=_.find(e.find("div"),function(e){return e.classList.contains("sg-quota")})},this.addMailboxController=function(e){l.push(e)},this.selectFolder=function(e){if(a.selectedFolderController=e,null!==a.selectedFolder){var t=_.find(l,function(e){return e.mailbox.id==a.selectedFolder.id});t&&t.unselectFolder()}s(o["gt-md"])||i("left").close()}}e.$inject=["$element","$transitions","$state","$mdMedia","$mdSidenav","sgConstant","Mailbox","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgAccountController",e).directive("sgAccountSection",function(){return{restrict:"C",scope:{},controller:"sgAccountController"}})}(),function(){"use strict";function e(n,t){var s=this;n.delegateInvitation=!1,n.delegatedTo="",n.searchText="",n.userFilter=function(e){return t.$filter(e)},n.iCalendarAction=function(e){var t;"delegate"==e&&(t={receiveUpdates:!1,delegatedTo:n.delegatedTo.c_email}),n.viewer.message.$imipAction(s.pathToAttachment,e,t)}}e.$inject=["$scope","User"],angular.module("SOGo.MailerUI").controller("sgImipController",e).directive("sgImip",function(){return{restrict:"A",link:function(e,t,n,s){s.pathToAttachment=n.sgImipPath},controller:"sgImipController"}})}(),function(){function e(e,t,n,s,o,a,r,c,u,d,h,i){var f=this;this.$onInit=function(){this.$element=t,this.editMode=!1,this.accountController.addMailboxController(this)},this.$postLink=function(){this.selectableElement=t.find("div")[0],this.clickableElement=t.find("p")[0],this.inputContainer=t.find("md-input-container")[0],this.inputElement=t.find("input")[0],this.moreOptionsButton=_.last(t.find("md-icon")),null!==h.selectedFolder&&h.selectedFolder.id==this.mailbox.id&&this.accountController.selectFolder(this)},this.childLevel=function(){return"sg-child-level-"+this.mailbox.level},this.selectFolder=function(e){this.editMode||this.mailbox==h.selectedFolder||this.mailbox.isNoSelect()||(h.$virtualPath=!1,h.$virtualMode=!1,this.accountController.selectFolder(this),e&&(n.go("mail.account.mailbox",{accountId:this.mailbox.$account.id,mailboxId:i(i(this.mailbox.path))}),e.stopPropagation(),e.preventDefault()))},this.unselectFolder=function(){t[0].classList.remove("md-bg")},this.editFolder=function(e){e.stopPropagation(),e.preventDefault(),this.editMode=!0,this.inputElement.value=this.mailbox.name,this.clickableElement.classList.add("ng-hide"),this.inputContainer.classList.remove("ng-hide"),e.srcEvent&&"touchend"==e.srcEvent.type?s(function(){f.inputElement.select(),f.inputElement.focus()},200):(this.inputElement.select(),this.inputElement.focus()),this.panel&&this.panel.close()},this.saveFolder=function(e){this.inputElement.disabled||(this.mailbox.name=this.inputElement.value,this.inputElement.disabled=!0,this.mailbox.$rename().then(function(e){f.editMode=!1,f.inputContainer.classList.add("ng-hide"),f.clickableElement.classList.remove("ng-hide")}).finally(function(){f.inputElement.disabled=!1}))},this.revertEditing=function(){this.editMode=!1,this.clickableElement.classList.remove("ng-hide"),this.inputContainer.classList.add("ng-hide"),this.inputElement.value=this.mailbox.name},this.confirmDelete=function(){d.confirm(l("Warning"),l("Do you really want to move this folder into the trash ?"),{ok:l("Delete")}).then(function(){f.mailbox.$delete().then(function(){n.go("mail.account.inbox")},function(e){d.confirm(l("Warning"),l("The mailbox could not be moved to the trash folder. Would you like to delete it immediately?"),{ok:l("Delete")}).then(function(){f.mailbox.$delete({withoutTrash:!0}).then(function(){n.go("mail.account.inbox")},function(e){d.alert(l('An error occured while deleting the mailbox "%{0}".',f.mailbox.name),l(e.error))})})})})},this.showMenu=function(e){var t=a.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(a.xPosition.ALIGN_START,a.yPosition.ALIGN_TOPS),n=a.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(a.animation.FADE),s={attachTo:angular.element(document.body),locals:{itemCtrl:this,folder:this.mailbox,editFolder:angular.bind(this,this.editFolder),confirmDelete:angular.bind(this,this.confirmDelete)},bindToController:!0,controller:i,controllerAs:"$menuCtrl",position:t,animation:n,targetEvent:e,templateUrl:"UIxMailFolderMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};function i(t,e,n,s){var i=this;this.markFolderRead=function(){this.folder.$markAsRead()},this.newFolder=function(){d.prompt(l("New Folder..."),l("Enter the new name of your folder")).then(function(n){i.folder.$newMailbox(i.folder.id,n).then(function(){},function(e,t){d.alert(l('An error occured while creating the mailbox "%{0}".',n),l(e.error))})})},this.compactFolder=function(){this.folder.$compact().then(function(){o.show(o.simple().textContent(l("Folder compacted")).position("top right").hideDelay(3e3))})},this.emptyTrashFolder=function(){this.folder.$emptyTrash().then(function(){o.show(o.simple().textContent(l("Trash emptied")).position("top right").hideDelay(3e3))})},this.showAdvancedSearch=function(){h.$virtualPath=this.folder.path,r(u["gt-md"])||c("left").close()},this.share=function(){this.folder.$acl.$users().then(function(){n.show({templateUrl:i.folder.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:i.folder.$acl.users,User:s,folder:i.folder}})})},this.setFolderAs=function(e){this.folder.$setFolderAs(e).then(function(){i.folder.$account.$getMailboxes({reload:!0})})},this.isParentOf=function(s){var i;return(i=function(e){if(!(e.children&&0<e.children.length))return e.path==s;for(var t=0;t<e.children.length;t++){var n=e.children[t];if(n.children&&0<n.children.length){if(i(n))return!0}else if(n.path==s)return!0}})(this.folder)},this.moveFolder=function(e){this.folder.$move(e),t.close()}}a.open(s).then(function(e){(f.panel=e).panelEl.one("click",function(){e.close()})}),i.$inject=["mdPanelRef","$state","$mdDialog","User"]}}e.$inject=["$scope","$element","$state","$timeout","$mdToast","$mdPanel","$mdMedia","$mdSidenav","sgConstant","Dialog","Mailbox","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgMailboxListItemController",e).directive("sgMailboxListItem",function(){return{restrict:"C",require:{accountController:"^^sgAccountSection"},scope:{},bindToController:{mailbox:"=sgMailbox"},template:[' <div class="sg-child-level-0"',' ng-class="$ctrl.childLevel()">',' <md-checkbox class="sg-folder"',' ng-class="$ctrl.mailbox.$icon"',' aria-label="'+l("Expanded")+'"',' ng-model="$ctrl.mailbox.$expanded"',' ng-disabled="$ctrl.mailbox.children.length == 0"',' ng-change="$ctrl.mailbox.$account.$flattenMailboxes({ reload: true, saveState: true })">'," </md-checkbox>"," </div>",' <p class="sg-item-name"',' ng-click="$ctrl.selectFolder($event)"',' ng-dblclick="$ctrl.editFolder($event)">'," <md-icon ng-class=\"{ 'sg-opacity-70': $ctrl.mailbox.isNoSelect() }\">{{$ctrl.mailbox.$icon}}</md-icon>",' <span ng-bind="$ctrl.mailbox.$displayName"></span>',' <span class="sg-counter-badge ng-hide"',' ng-show="$ctrl.mailbox.unseenCount"',' ng-bind="$ctrl.mailbox.unseenCount"></span>'," </p>",' <md-input-container class="md-flex ng-hide">',' <input class="sg-item-name" type="text"',' aria-label="'+l("Enter the new name of your folder")+'"',' ng-blur="$ctrl.saveFolder($event)"',' sg-enter="$ctrl.saveFolder($event)"',' sg-escape="$ctrl.revertEditing()" />'," </md-input-container>",' <md-icon class="md-menu md-secondary-container" ng-click="$ctrl.showMenu($event)" aria-label="'+l("Options")+'">more_vert</md-icon>'].join(""),controller:"sgMailboxListItemController",controllerAs:"$ctrl"}})}(),function(){function e(t,e,n){var s=this;this.$onInit=function(){var e=["uid","isread","isflagged","flags","subject"];"draft"==(this.MailboxService=n).selectedFolder.type&&e.push("subject"),t.$watch(function(){return s.message?[_.pick(s.message,e)]:null},function(e,t){s.message&&s.onUpdate()},!0)},this.onUpdate=function(){this.message.isread?e.removeClass("unread"):e.addClass("unread"),n.selectedFolder.isSelectedMessage(this.message.uid,this.message.$mailbox.path)?e.addClass("md-default-theme md-accent md-bg md-hue-2"):e.removeClass("md-default-theme md-accent md-bg md-hue-2")},this.setVisibility=function(e,t){t?e.classList.remove("ng-hide"):e.classList.add("ng-hide")}}e.$inject=["$scope","$element","Mailbox"],angular.module("SOGo.MailerUI").controller("sgMessageListItemController",e).directive("sgMessageListItem",function(){return{restrict:"C",scope:{},bindToController:{message:"=sgMessage"},controller:"sgMessageListItemController"}})}(),function(){function e(s,a,e,t,r,n,l,c,i){var u=this;this.$postLink=function(){var t,e,n,i,o;this.parentController=s.parentController,i=this.parentController.onUpdate,o=this.parentController.setVisibility,_.forEach(a.find("div"),function(e){e.classList.contains("sg-tile-content")?t=angular.element(e):e.classList.contains("sg-tile-icons")&&(n=angular.element(e))}),e=t.find("button")[0],this.threadButton=e,e=angular.element(e),this.threadIconElement=e.find("md-icon")[0],this.threadCountElement=e.find("span")[0],this.priorityIconElement=t.find("md-icon")[0],l.$virtualMode&&(this.mailboxNameElement=t.find("span")[0],this.mailboxNameElement.classList.remove("ng-hide")),this.senderElement=t.find("span")[1],_.forEach(t.find("div"),function(e){e.classList.contains("sg-tile-subject")?u.subjectElement=e:e.classList.contains("sg-tile-size")?u.sizeElement=e:e.classList.contains("sg-tile-date")&&(u.dateElement=e)}),_.forEach(n.find("md-icon"),function(e){"star"==e.textContent?u.flagIconElement=e:"reply"==e.textContent?u.answerIconElement=e:"forward"==e.textContent?u.forwardIconElement=e:"attach_file"==e.textContent&&(u.attachmentIconElement=e)}),this.parentController.onUpdate=function(){var e;u.message=u.parentController.message;var t=r.nodesToArray(a[0].querySelectorAll(".sg-category"));for(_.forEach(t,function(e){a[0].removeChild(e)}),e=0;e<u.message.flags.length&&e<5;e++){var n=u.message.flags[e];if(u.service.$tags[n]){var s=angular.element('<div class="sg-category"></div>');s.css("left",3*e+"px"),s.css("background-color",u.service.$tags[n][1]),a.prepend(s)}}u.mailboxNameElement&&(u.mailboxNameElement.innerHTML=u.message.$mailbox.$displayName),u.MailboxService.selectedFolder.isSentFolder?u.senderElement.innerHTML=u.message.$shortAddress("to").encodeEntities():u.senderElement.innerHTML=u.message.$shortAddress("from").encodeEntities(),u.message.priority&&u.message.priority.level<3?(u.priorityIconElement.classList.remove("ng-hide"),u.message.priority.level<2?u.priorityIconElement.classList.add("md-warn"):u.priorityIconElement.classList.remove("md-warn")):u.priorityIconElement.classList.add("ng-hide"),u.message.first?(u.threadButton.classList.remove("ng-hide"),u.threadCountElement.innerHTML=u.message.threadCount,u.message.collapsed&&u.threadIconElement.classList.remove("md-rotate-180-ccw")):u.threadButton.classList.add("ng-hide"),u.subjectElement.innerHTML=u.message.subject.encodeEntities(),u.sizeElement.innerHTML=u.message.size,u.dateElement.innerHTML=u.message.relativedate,o(u.flagIconElement,u.message.isflagged),o(u.answerIconElement,u.message.isanswered),o(u.forwardIconElement,u.message.isforwarded),o(u.attachmentIconElement,u.message.hasattachment),angular.bind(u.parentController,i)()},this.service=c,this.MailboxService=l},this.toggleThread=function(){this.message.collapsed?this.threadIconElement.classList.add("md-rotate-180-ccw"):this.threadIconElement.classList.remove("md-rotate-180-ccw"),this.message.toggleThread()}}e.$inject=["$scope","$element","$parse","$state","$mdUtil","$mdToast","Mailbox","Message","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgMessageListItemMainController",e).directive("sgMessageListItemMain",function(){return{restrict:"C",require:"^^sgMessageListItem",scope:{},template:['<div class="sg-tile-content">',' <div class="sg-md-subhead">'," <div>",' <span class="sg-label-outline ng-hide">\x3c!-- mailbox --\x3e</span>',' <md-icon class="ng-hide">error</md-icon>'," <span>\x3c!-- sender or recipient --\x3e</span>"," </div>",' <div class="sg-tile-date">\x3c!-- date --\x3e</div>'," </div>",' <div class="sg-md-body">',' <div class="sg-tile-subject">\x3c!-- subject --\x3e</div>',' <div class="sg-tile-size">\x3c!-- size --\x3e</div>',' <md-button class="sg-tile-btn md-secondary ng-hide" md-colors="::{ color: \'accent-600\'}" ng-click="$ctrl.toggleThread()">',' <md-icon class="md-rotate-180-ccw" md-colors="::{ color: \'accent-600\'}">expand_more</md-icon><span></span>'," </md-button>"," </div>","</div>",'<div class="sg-tile-icons">',' <md-icon class="ng-hide sg-icon-star">star</md-icon>',' <md-icon class="ng-hide">reply</md-icon>',' <md-icon class="ng-hide">forward</md-icon>',' <md-icon class="ng-hide">attach_file</md-icon>',"</div>",'<div class="sg-progress-linear-bottom">',' <md-progress-linear class="md-accent"',' md-mode="indeterminate"',' ng-disabled="!$ctrl.message.$isLoading()">\x3c!-- message loading progress --\x3e</md-progress-linear>',"</div>"].join(""),link:function(e,t,n,s){e.parentController=s},controller:"sgMessageListItemMainController",controllerAs:"$ctrl"}})}(),function(){"use strict";function e(e,t){var n=this;this.$postLink=function(){t.registerImage(e),e.on("click",this.showImage)},this.showImage=function(e){"IMG"==e.target.tagName&&t.showGallery(e,n.partIndex)}}e.$inject=["$element","ImageGallery"],angular.module("SOGo.MailerUI").directive("sgZoomableImage",function(){return{restrict:"A",bindToController:{partIndex:"=sgZoomableImage"},controller:e}})}();
|
|
//# sourceMappingURL=Mailer.services.js.map
|