function EntityCtrl(n,t,i,r,u,f,e,o,s){var h=this;h.CorpId="";f.Modal="dialogCorrespondence";h.Error=f;h.Loading=!0;h.Corp={};h.Filings=[];h.Mortgages=[];h.Addresses=[];h.Officers=[];h.Officer={};h.Members=[];h.Member={};h.CommitteeMembers=[];h.CommitteeMember={};h.Authorities=[];h.Shares=[];h.Correspondences=[];h.Correspondence={};h.Documents=[];h.Activities=[];h.IsAuthorized=!1;h.IsAuthorizedToViewHistory=!1;h.NewFiles=[];h.NewFile=null;h.ChosenFileName=o;h.ShowFullHistory=!1;h.ControllerInit=function(n){h.CorpId=n;h.GetProfile()};h.ToggleFullHistory=function(){h.ShowFullHistory=!h.ShowFullHistory;h.GetProfile()};h.GetProfile=function(){h.Loading=!0;var n="";n=h.ShowFullHistory?"/Api/Corp/GetHistoricalCorpProfile?id="+h.CorpId:"/Api/Corp/GetCorpProfile?id="+h.CorpId;i.get(n).then(function(n){var f,i,r,u,t;h.Error.Errors=n.data.ValidationResults;h.Error.Errors.length>0?h.Error.DisplayError():(h.IsAuthorized=n.data.IsAuthorized,h.ShowFilingLinkColumn=n.data.ShowFilingLinkColumn,h.IsAuthorizedToViewHistory=n.data.IsAuthorizedToViewHistory,h.Corp=n.data.Corp,h.Filings=n.data.CorpFilings,h.Addresses=n.data.Addresses,h.Officers=n.data.Officers,h.CommitteeMembers=n.data.CommitteeMembers,h.OfficersHistory=n.data.OfficersHistory,h.CommitteeMembersHistory=n.data.CommitteeMembersHistory,h.Mortgages=n.data.Mortgages,h.Activities=n.data.Activities,(!h.Mortgages||h.Mortgages&&h.Mortgages.length<=0)&&(f=document.getElementById("tabCompanyProfileTabMortgagesAndCharges"),i=document.getElementById("CompanyProfileTabMortgagesAndCharges"),i&&(i.style.display="none")),h.IsAuthorizedToViewHistory||(r=document.getElementById("CompanyProfileTabHistory"),r&&(r.style.display="none")),h.IsAuthorized?(h.Authorities=n.data.Authorities,h.Shares=n.data.Shares,h.Correspondences=n.data.Correspondence,h.Members=n.data.Members,h.MembersHistory=n.data.MembersHistory,h.Documents=n.data.Documents):(u=document.getElementById("tabCompanyProfileTabMembers"),u&&(u.style.display="none")),h.Corp.CorpTypeId==3&&h.Members.length==0&&(t=document.getElementById("NoSubscribersNotice"),t&&(t.style.display="block",t.style.visibility="visible")),h.Loading=!1)},function(){h.Error.DisplayError("error_corpprofile_load");h.Loading=!1})};h.printcertificate=function(){var n=$("#certtoken").val(),r=$("#certmessage").val(),i;n==""?u({title:"Certificate Unavailable",content:r,scope:t,buttons:{Ok:{text:"Ok",btnClass:"btn-blue"}}}):(i="/Api/UploadFile/GetFileContent?id="+n,window.open(i))};h.RenderHtml=function(n){return r.trustAsHtml(n)};h.ViewPDFFiling=function(n){n&&n.IsFileUploaded&&n.UploadFileId.length>0?e.Download(n.UploadFileId):h.Error.DisplayError("error_filenotfound")};h.AddNewCorrespondence=function(){t.aspnetForm.$submitted=!1;h.Error.ClearError();angular.element("#toggleCorrespondenceModal").trigger("click");h.Correspondence={};h.Correspondence.IsNew=!0;h.ChosenFileName=o;h.NewFiles=[];h.NewFile=null};h.ViewCorrespondence=function(n){h.Error.ClearError();h.Correspondence=null;angular.forEach(h.Correspondences,function(t){if(t.CorrespondenceId==n)return h.Correspondence={},h.Correspondence.CorrespondenceId=t.CorrespondenceId,h.Correspondence.Note=t.Note,h.Correspondence.DateFormatted=t.DateFormatted,h.Correspondence.CreatedBy=t.CreatedBy,h.Correspondence.Attachments=t.Attachments,!1});h.Correspondence!=null&&h.Correspondence.CorrespondenceId==n?angular.element("#toggleCorrespondenceModal").trigger("click"):h.Error.DisplayError("error_company_correspondence_load")};h.DeleteCorrespondence=function(n){if(confirm(s)){var t="/Api/Corp/DeleteCorrespondence?id="+n;i.delete(t).then(function(t){if(t.data){var i=!1;angular.forEach(h.Correspondences,function(t){t.CorrespondenceId==n&&(h.Correspondences.splice(h.Correspondences.indexOf(t),1),i=!0)});i?h.Error.DisplayError("success_company_correspondence_delete",2):h.Error.DisplayError("error_company_correspondence_delete")}else h.Error.DisplayError("error_company_correspondence_delete")},function(){h.Error.DisplayError("error_company_correspondence_delete")})}};h.SaveCorrespondence=function(){var r,n,t,u;h.Error.ClearError();r="/Api/Corp/SaveCorrespondence";n={};n.Note=h.Correspondence.Note;n.CorrespondenceId=h.Correspondence.CorrespondenceId;n.CorpId=h.CorpId;t=new FormData;u=1;angular.forEach(h.NewFiles,function(n){t.append("file"+(u++).toString(),n)});t.append("model",angular.toJson(n));i.post(r,t,{transformRequest:angular.identity,headers:{"Content-Type":undefined}}).then(function(n){var r=n.data.ValidationResults,t,i;r.length>0?(h.Error.Errors=r,h.Error.DisplayError()):(h.Error.ClearError(),t=!1,i=n.data,h.Correspondence.IsNew?(h.Correspondences.push(i),t=!0):angular.forEach(h.Correspondences,function(n){if(n.CorrespondenceId==h.Correspondence.CorrespondenceId){var r=h.Correspondences.indexOf(n);h.Correspondences[r]=i;t=!0}}),t?(h.Correspondence={},h.NewFiles=[],h.NewFile=null,$("#dialogCorrespondence .close").click(),h.Error.DisplayError("success_company_correspondence_save",2)):h.Error.DisplayError("error_company_correspondence_save"))},function(){h.Error.DisplayError("error_company_correspondence_save")})};h.CloseCorrespondence=function(){h.Correspondence={};h.NewFiles=[];h.NewFile=null};h.DeleteCorrespondenceAttachment=function(n){if(confirm(s)){var t="/Api/Corp/DeleteCorrespondenceAttachment?id="+n;i.delete(t).then(function(t){if(t.data){var i=!1;angular.forEach(h.Correspondence.Attachments,function(t){t.AttachmentId==n&&(h.Correspondence.Attachments.splice(h.Correspondence.Attachments.indexOf(t),1),i=!0)});i?h.Error.DisplayError("success_company_correspondenceattachment_delete",2):h.Error.DisplayError("error_company_correspondenceattachment_delete")}else h.Error.DisplayError("error_company_correspondenceattachment_delete")},function(){h.Error.DisplayError("error_company_correspondenceattachment_delete")})}};h.AddCorrespondenceAttachment=function(){h.NewFile!=undefined&&h.NewFiles!=undefined&&h.NewFiles.indexOf(h.NewFile)<0&&h.NewFiles.push(h.NewFile);h.NewFile=null;h.ChosenFileName=o};t.setFile=function(n){t.$apply(function(){n.files[0]!=undefined&&(h.NewFile=n.files[0],h.ChosenFileName=n.files[0].name)})};h.DeleteNewFile=function(n){var t=h.NewFiles.indexOf(n);h.NewFiles.splice(t,1)};h.DownloadCorrespondenceAttachment=function(n){n!=null&&n!=undefined&&n.UploadFileId.length>0&&e.Download(n.UploadFileId)};h.ViewOfficer=function(n){h.Error.ClearError();h.Officer=null;var t=h.Officers;h.ShowFullHistory&&(t=h.OfficersHistory);angular.forEach(t,function(t){if(t.CorpOfficerId==n||t.CorpOfficerHistoryId==n)return h.Officer=t,!1});h.Officer!=null&&h.Officer.CorpOfficerId==n||h.Officer.CorpOfficerHistoryId==n?angular.element("#toggleOfficerModal").trigger("click"):h.Error.DisplayError("error_company_officer_load")};h.CloseOfficer=function(){h.Officer={}};h.ViewCommitteeMember=function(n){h.Error.ClearError();h.CommitteeMember=null;var t=h.CommitteeMembers;h.ShowFullHistory&&(t=h.CommitteeMembersHistory);angular.forEach(t,function(t){if(t.CorpOfficerId==n||t.CorpOfficerHistoryId==n)return h.CommitteeMember=t,!1});h.CommitteeMember!=null&&h.CommitteeMember.CorpOfficerId==n||h.CommitteeMember.CorpOfficerHistoryId==n?angular.element("#toggleCommitteeMemberModal").trigger("click"):h.Error.DisplayError("error_company_CommitteeMember_load")};h.CloseCommitteeMember=function(){h.CommitteeMember={}};h.ViewMember=function(n){h.Error.ClearError();h.Member=null;var t=h.Members;h.ShowFullHistory&&(t=h.MembersHistory);angular.forEach(t,function(t){if(t.CorpOfficerId==n||t.CorpOfficerHistoryId==n)return h.Member=t,!1});h.Member!=null&&h.Member.CorpOfficerId==n||h.Member.CorpOfficerHistoryId==n?angular.element("#toggleMemberModal").trigger("click"):h.Error.DisplayError("error_company_member_load")};h.CloseMember=function(){h.Member={}};h.revokeAuthority=function(r){h.Error.ClearError();var f="companyprofile_authority_revoke_modal_title",e="companyprofile_authority_revoke_modal_content",s="/Api/Corp/RevokeAuthority?authorityId="+r,o=u({title:'<span data-localresourcekey="'+f+'">'+angular.element("#"+f).val()+"<\/span>",icon:"fa fa-warning",content:'<strong data-localresourcekey="'+e+'">'+angular.element("#"+e).val()+"<\/strong>",scope:t,columnClass:"col-md-6 col-md-offset-3",buttons:{confirm:{btnClass:"btn-danger",action:function(){i.get(s).then(function(n){var t=n.data.ValidationResults;t.length>0?(h.Error.Errors=t,h.Error.DisplayError()):(angular.forEach(h.Authorities,function(t){if(t.CorpAuthorityId==n.data.CorpAuthorityId){var i=h.Authorities.indexOf(t);h.Authorities[i]=n.data}}),h.Error.DisplayError("companyprofile_authority_revoke_success",1))},function(){h.Error.DisplayError("companyprofile_authority_revoke_error")})}},cancel:{btnClass:"btn-default",action:function(){}}},onOpen:function(){n.$broadcast("dynamic_element_loaded")}});o.buttons.confirm.setText(angular.element("#companyprofile_authority_revoke_confirm").val());o.buttons.cancel.setText(angular.element("#companyprofile_authority_revoke_cancel").val())};h.corporateMemberFilter=function(n){return n.IsCorporateMember||n.IsOtherMember?!0:!1};h.getOfficers=function(){return h.ShowFullHistory?h.OfficersHistory:h.Officers};h.getMembers=function(){return h.ShowFullHistory?h.MembersHistory:h.Members};h.getCommitteeMembers=function(){return h.ShowFullHistory?h.CommitteeMembersHistory:h.CommitteeMembers};h.GetRegistrationNumber=function(){return h.Corp.RegistrationNumber||h.Corp.PriorRegistrationNumber};h.reregisterFiling=function(){var n=getURLParam("id");n!=null&&$.get("/Api/CorpFiling/GetReregistrationPageForCorp?corpId="+n).then(function(n){window.location=n}).fail(function(n){var t=n.responseJSON;h.Error.DisplayError(t.Message)})}}function NewFiling(){var n=getURLParam("id");n!=null&&(addtoquery="?id="+n,location.href="./NewFiling.aspx?id="+n)}function OrderDocuments(){var n=getURLParam("id");n!=null&&(addtoquery="?id="+n,location.href="./DocumentOrder.aspx?id="+n)}var chooseFile,deleteRecordConfirm,app=angular.module("app",["HelpService","HelpDirective","cp.ngConfirm","auditLogMod"]).filter("replaceBrake",function(){return function(n){return n.replace(/\n/g,"<br />")}}).controller("EntityCtrl",["$rootScope","$scope","$http","$sce","$ngConfirm","ErrorHandler","FileHandler",EntityCtrl]),entityProfileInit=function(n,t){deleteRecordConfirm=t;chooseFile=n}