Your IP : 18.191.192.250


Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/timeline/dist/
Upload File :
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/timeline/dist/timeline.bundle.min.js

this.BX=this.BX||{};(function(t,e,i,s,n,r){"use strict";let o=t=>t,a,h,d,l,c,m,u,g,p,f;class y{constructor(t){this.isProgress=false;n.EventEmitter.makeObservable(this,"UI.Timeline.Item");this.id=t.id;this.createdTimestamp=null;this.action="";this.title="";this.description="";this.htmlDescription="";this.textDescription="";this.userId=t.userId;this.isFixed=t.isFixed===true;this.data={};this.eventIds=new Set;if(r.Type.isPlainObject(t)){if(r.Type.isSet(t.eventIds)){this.eventIds=t.eventIds}if(r.Type.isString(t.action)){this.action=t.action}if(r.Type.isString(t.title)){this.title=t.title}if(r.Type.isString(t.description)){this.description=t.description}if(r.Type.isString(t.htmlDescription)){this.htmlDescription=t.htmlDescription}if(r.Type.isString(t.textDescription)){this.textDescription=t.textDescription}if(r.Type.isNumber(t.createdTimestamp)){this.createdTimestamp=t.createdTimestamp}if(r.Type.isPlainObject(t.data)){this.data=t.data}}this.layout={};this.timeFormat="H:M";this.nameFormat="";this.users=new Map;this.isLast=false;this.events=t.events;this.isPinned=false}afterRender(){r.Event.bind(this.renderPin(),"click",this.onPinClick.bind(this));this.bindActionsButtonClick()}bindActionsButtonClick(){const t=this.getActionsButton();if(t){r.Event.bind(t,"click",this.onActionsButtonClick.bind(this))}}setIsLast(t){this.isLast=t;if(this.isRendered()){if(this.isLast){this.getContainer().classList.add("ui-item-detail-stream-section-last")}else{this.getContainer().classList.remove("ui-item-detail-stream-section-last")}}}setUserData(t){if(t){this.users=t}return this}setTimeFormat(t){if(r.Type.isString(t)){this.timeFormat=t}return this}setNameFormat(t){if(r.Type.isString(t)){this.nameFormat=t}return this}getContainer(){return this.layout.container}isRendered(){return r.Type.isDomNode(this.getContainer())}getCreatedTime(){if(this.createdTimestamp>0){this.createdTimestamp=r.Text.toInteger(this.createdTimestamp);return new Date(this.createdTimestamp)}return null}formatTime(t){return BX.date.format(this.timeFormat,t)}getId(){return this.id}getTitle(){return this.title}getUserId(){return r.Text.toInteger(this.userId)}getScope(){if(r.Type.isString(this.data.scope)){return this.data.scope}return null}isScopeManual(){const t=this.getScope();return!t||t==="manual"}isScopeAutomation(){return this.getScope()==="automation"}isScopeTask(){return this.getScope()==="task"}isScopeRest(){return this.getScope()==="rest"}render(){this.layout.container=this.renderContainer();this.updateLayout();return this.layout.container}updateLayout(){this.clearLayout(true);this.layout.container.appendChild(this.renderIcon());if(this.hasMenu()){this.layout.container.appendChild(this.renderActionsButton())}this.layout.container.appendChild(this.renderPin());let t=this.getContent();if(!t){t=this.renderContent()}this.layout.container.appendChild(t);this.afterRender()}renderContainer(){return r.Tag.render(a||(a=o`<div class="ui-item-detail-stream-section ${0}"></div>`),this.isLast?"ui-item-detail-stream-section-last":"")}renderPin(){if(!this.layout.pin){this.layout.pin=r.Tag.render(h||(h=o`<span class="ui-item-detail-stream-section-top-fixed-btn"></span>`))}if(this.isFixed){this.layout.pin.classList.add("ui-item-detail-stream-section-top-fixed-btn-active")}else{this.layout.pin.classList.remove("ui-item-detail-stream-section-top-fixed-btn-active")}return this.layout.pin}renderContent(){this.layout.content=r.Tag.render(d||(d=o`<div class="ui-item-detail-stream-section-content">${0}</div>`),this.renderDescription());return this.getContent()}getContent(){return this.layout.content}renderDescription(){this.layout.description=r.Tag.render(l||(l=o`<div class="ui-item-detail-stream-content-event"></div>`));let t=this.renderHeader();if(t){this.layout.description.appendChild(t)}this.layout.description.appendChild(this.renderMain());return this.layout.description}renderHeader(){return null}renderHeaderUser(t,e=21){t=r.Text.toInteger(t);let i={link:"javascript: void(0)",fullName:"",photo:null};if(t>0){i=this.users.get(t)}if(!i){return r.Tag.render(c||(c=o`<a></a>`))}const s=r.Tag.safe(m||(m=o`${0}`),i.fullName);return r.Tag.render(u||(u=o`<a class="ui-item-detail-stream-content-employee" href="${0}" target="_blank" title="${0}" ${0}></a>`),i.link,s,i.photo?"style=\"background-image: url('"+i.photo+"'); background-size: 100%;\"":"")}renderMain(){this.layout.main=r.Tag.render(g||(g=o`<div class="ui-item-detail-stream-content-detail">${0}</div>`),this.description);return this.getMain()}getMain(){return this.layout.main}renderIcon(){this.layout.icon=r.Tag.render(p||(p=o`<div class="ui-item-detail-stream-section-icon"></div>`));return this.layout.icon}getItem(){if(r.Type.isPlainObject(this.data.item)){return this.data.item}return null}onPinClick(){this.isFixed=!this.isFixed;this.renderPin();if(r.Type.isFunction(this.events.onPinClick)){this.events.onPinClick(this)}this.emit("onPinClick")}clearLayout(t=false){const e=this.getContainer();Object.keys(this.layout).forEach((i=>{const s=this.layout[i];if(!t||e!==s){r.Dom.remove(s);delete this.layout[i]}}));return this}getDataForUpdate(){return{description:this.description,htmlDescription:this.htmlDescription,data:this.data,userId:this.userId}}updateData(t){if(r.Type.isPlainObject(t)){if(r.Type.isString(t.description)){this.description=t.description}if(r.Type.isString(t.htmlDescription)){this.htmlDescription=t.htmlDescription}if(r.Type.isPlainObject(t.data)){this.data=t.data}if(t.userId>0){this.userId=t.userId}}return this}update(t){this.updateData(t).updateLayout();return this}onError(t){if(r.Type.isFunction(this.events.onError)){this.events.onError(t)}this.emit("error",t)}onDelete(){if(r.Type.isFunction(this.events.onDelete)){this.events.onDelete(this)}this.emit("onDeleteComplete")}hasMenu(){return this.hasActions()}hasActions(){return this.getActions().length>0}getActions(){return[]}renderActionsButton(){this.layout.contextMenuButton=r.Tag.render(f||(f=o`<div class="ui-timeline-item-context-menu"></div>`));return this.getActionsButton()}getActionsButton(){return this.layout.contextMenuButton}getActionsMenuId(){return"ui-timeline-item-context-menu-"+this.getId()}onActionsButtonClick(){this.getActionsMenu().toggle()}getActionsMenu(){return s.MenuManager.create({id:this.getActionsMenuId(),bindElement:this.getActionsButton(),items:this.getActions(),offsetTop:0,offsetLeft:16,angle:{position:"top",offset:0},events:{onPopupShow:this.onContextMenuShow.bind(this),onPopupClose:this.onContextMenuClose.bind(this)}})}onContextMenuShow(){this.getActionsButton().classList.add("active")}onContextMenuClose(){this.getActionsButton().classList.remove("active");this.getActionsMenu().destroy()}startProgress(){this.isProgress=true;this.getLoader().show()}stopProgress(){this.isProgress=false;if(this.getLoader().isShown()){this.getLoader().hide()}}getLoader(){if(!this.loader){this.loader=new e.Loader({target:this.getContainer()})}return this.loader}}let T=t=>t,C,I,E,v,D,P;class x extends y{renderContainer(){const t=super.renderContainer();if(this.isScopeAutomation()){t.classList.add("ui-item-detail-stream-section-icon-robot")}else{t.classList.add("ui-item-detail-stream-section-info")}return t}renderHeader(){return r.Tag.render(C||(C=T`<div class="ui-item-detail-stream-content-header">
			<div class="ui-item-detail-stream-content-title">
				<span class="ui-item-detail-stream-content-title-text">${0}</span>
				<span class="ui-item-detail-stream-content-title-time">${0}</span>
			</div>
			${0}
		</div>`),r.Text.encode(this.getTitle()),this.formatTime(this.getCreatedTime()),this.renderHeaderUser(this.getUserId()))}renderStageChangeTitle(){return r.Tag.render(I||(I=T`<div class="ui-item-detail-stream-content-title">
			<span class="ui-item-detail-stream-content-title-text">${0}</span>
		</div>`),r.Loc.getMessage("UI_TIMELINE_STAGE_CHANGE_SUBTITLE"))}renderStageChange(){const t=this.getStageFrom();const e=this.getStageTo();if(t&&e&&t.id!==e.id){return r.Tag.render(E||(E=T`<div class="ui-item-detail-stream-content-detail-info">
				<span class="ui-item-detail-stream-content-detail-info-status">${0}</span>
				<span class="ui-item-detail-stream-content-detail-info-separator"></span>
				<span class="ui-item-detail-stream-content-detail-info-status">${0}</span>
			</div>`),r.Text.encode(t.name),r.Text.encode(e.name))}return null}getStageFrom(){if(r.Type.isPlainObject(this.data.stageFrom)){return this.data.stageFrom}return null}getStageTo(){if(r.Type.isPlainObject(this.data.stageTo)){return this.data.stageTo}return null}getFields(){if(r.Type.isArray(this.data.fields)){return this.data.fields}return null}renderFieldsChange(){const t=this.getFields();if(t){const e=[];t.forEach((t=>{e.push(r.Tag.render(v||(v=T`<div class="ui-item-detail-stream-content-detail-field">${0}</div>`),r.Text.encode(t.title)))}));return r.Tag.render(D||(D=T`<div class="ui-item-detail-stream-content-detail-info ui-item-detail-stream-content-detail-info-break">
				${0}
			</div>`),e)}return null}renderFieldsChangeTitle(){return r.Tag.render(P||(P=T`<div class="ui-item-detail-stream-content-title">
			<span class="ui-item-detail-stream-content-title-text">${0}</span>
		</div>`),r.Loc.getMessage("UI_TIMELINE_FIELDS_CHANGE_SUBTITLE"))}}let F=t=>t,b;class B extends x{renderMain(){let t=this.renderStageChange();if(!t){t=""}let e=this.renderFieldsChange();if(!e){e=""}return r.Tag.render(b||(b=F`<div class="ui-item-detail-stream-content-detail">
			${0}
			${0}
		</div>`),t,e)}}let L=t=>t,A;class M extends x{renderMain(){let t=this.renderFieldsChange();if(!t){t=""}return r.Tag.render(A||(A=L`<div class="ui-item-detail-stream-content-detail">
			${0}
		</div>`),t)}}class k{constructor(t){this.isProgress=false;if(r.Type.isString(t.id)&&t.id.length>0){this.id=t.id}else{this.id=r.Text.getRandom()}this.layout={};n.EventEmitter.makeObservable(this,"BX.UI.Timeline.Editor")}getId(){return this.id}getTitle(){}getContainer(){return this.layout.container}render(){throw new Error("This method should be overridden")}clearLayout(t=false){const e=this.getContainer();Object.keys(this.layout).forEach((i=>{const s=this.layout[i];if(!t||e!==s){r.Dom.clean(s);delete this.layout[i]}}));return this}startProgress(){this.isProgress=true;this.getLoader().show()}stopProgress(){this.isProgress=false;if(this.getLoader().isShown()){this.getLoader().hide()}}getLoader(){if(!this.loader){this.loader=new e.Loader({target:this.getContainer()})}return this.loader}isRendered(){return r.Type.isDomNode(this.getContainer())}}let S=t=>t,w,N,O,_,U,R,X;class $ extends k{constructor(t){super(t);this.commentId=0;this.editorContent=null;if(r.Type.isNumber(t.commentId)){this.commentId=t.commentId}this.setEventNamespace("BX.UI.Timeline.CommentEditor")}getTitle(){return r.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT")}getVisualEditorName(){return"UiTimelineCommentVisualEditor"+this.getId().replace("- ","")}getTextarea(){return this.layout.textarea}renderTextarea(){this.layout.textarea=r.Tag.render(w||(w=S`<textarea onfocus="${0}" rows="1" class="ui-item-detail-stream-section-new-comment-textarea" placeholder="${0}"></textarea>`),this.onFocus.bind(this),r.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT_TEXTAREA"));return this.getTextarea()}getVisualEditorContainer(){return this.layout.visualEditorContainer}renderVisualEditorContainer(){this.layout.visualEditorContainer=r.Tag.render(N||(N=S`<div class="ui-timeline-comment-visual-editor"></div>`));return this.getVisualEditorContainer()}getButtonsContainer(){return this.layout.buttonsContainer}renderButtons(){this.layout.buttonsContainer=r.Tag.render(O||(O=S`<div class="ui-item-detail-stream-section-new-comment-btn-container">
			${0}
			${0}
		</div>`),this.renderSaveButton(),this.renderCancelButton());return this.getButtonsContainer()}getSaveButton(){return this.layout.saveButton}renderSaveButton(){this.layout.saveButton=r.Tag.render(_||(_=S`<button onclick="${0}" class="ui-btn ui-btn-xs ui-btn-primary">${0}</button>`),this.save.bind(this),r.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT_SEND"));return this.getSaveButton()}getCancelButton(){return this.layout.cancelButton}renderCancelButton(){this.layout.cancelButton=r.Tag.render(U||(U=S`<span onclick="${0}" class="ui-btn ui-btn-xs ui-btn-link">${0}</span>`),this.cancel.bind(this),r.Loc.getMessage("UI_TIMELINE_EDITOR_COMMENT_CANCEL"));return this.getCancelButton()}render(){this.layout.container=r.Tag.render(R||(R=S`<div class="ui-timeline-comment-editor">
				${0}
				${0}
				${0}
			</div>`),this.renderTextarea(),this.renderButtons(),this.renderVisualEditorContainer());return this.getContainer()}onFocus(){const t=this.getContainer();if(t){t.classList.add("focus")}this.showVisualEditor()}showVisualEditor(){if(!this.getVisualEditorContainer()){return}if(this.postForm&&this.visualEditor){this.postForm.eventNode.style.display="block";this.visualEditor.Focus()}else if(!this.isProgress){this.loadVisualEditor().then((()=>{n.EventEmitter.emit(this.postForm.eventNode,"OnShowLHE",[true]);setTimeout((()=>{this.editorContent=this.postForm.oEditor.GetContent()}),300)})).catch((()=>{this.cancel();this.emit("error",{message:"Could not load visual editor. Please try again later"})}))}}loadVisualEditor(){return new Promise(((t,e)=>{if(this.isProgress){e()}this.showEditorLoader();const i=new n.BaseEvent({data:{name:this.getVisualEditorName(),commentId:this.commentId}});this.emitAsync("onLoadVisualEditor",i).then((()=>{const s=i.getData().html;if(r.Type.isString(s)){r.Runtime.html(this.getVisualEditorContainer(),s).then((()=>{this.hideEditorLoader();if(LHEPostForm&&BXHtmlEditor){this.postForm=LHEPostForm.getHandler(this.getVisualEditorName());this.visualEditor=BXHtmlEditor.Get(this.getVisualEditorName());t()}else{e()}}))}else{e()}})).catch((()=>{e()}))}))}showEditorLoader(){this.editorLoader=r.Tag.render(X||(X=S`<div class="ui-timeline-wait"></div>`));r.Dom.append(this.editorLoader,this.getContainer())}hideEditorLoader(){r.Dom.remove(this.editorLoader)}hideVisualEditor(){if(this.postForm){this.postForm.eventNode.style.display="none"}}save(){if(this.isProgress||!this.postForm){return}let t=false;const e=this.postForm.oEditor.GetContent();this.editorContent=e;const i=this.getAttachments();this.emit("beforeSave",{description:e,isCancel:t,files:i});if(e===""){this.getEmptyMessageNotification().show();return}this.startProgress();const s=new n.BaseEvent({data:{description:e,files:i,commentId:this.commentId}});this.emitAsync("onSave",s).then((()=>{this.postForm.reinit();this.stopProgress();this.emit("afterSave",{data:s.getData()});this.cancel()})).catch((()=>{this.stopProgress();this.cancel();const t=s.getData().message;if(t){this.emit("error",{message:t})}}))}cancel(){this.hideVisualEditor();const t=this.getContainer();if(t){t.classList.remove("focus")}this.stopProgress();this.emit("cancel")}getEmptyMessageNotification(){if(!this.emptyMessagePopup){this.emptyMessagePopup=new s.Popup({id:this.getId()+"-empty-message-popup",bindElement:this.getSaveButton(),content:BX.message("UI_TIMELINE_EMPTY_COMMENT_NOTIFICATION"),darkMode:true,autoHide:true,zIndex:990,angle:{position:"top",offset:77},closeByEsc:true,bindOptions:{forceBindPosition:true}})}return this.emptyMessagePopup}refresh(){if(this.postForm&&this.postForm.oEditor){if(this.editorContent){this.postForm.oEditor.SetContent(this.editorContent)}}if(this.visualEditor){this.visualEditor.ReInitIframe()}}getAttachments(){const t=[];if(!this.postForm||!r.Type.isPlainObject(this.postForm.arFiles)||!r.Type.isPlainObject(this.postForm.controllers)){return t}const e=[];Object.values(this.postForm.arFiles).forEach((t=>{if(!e.includes(t)){e.push(t)}}));e.forEach((e=>{if(this.postForm.controllers[e]&&r.Type.isPlainObject(this.postForm.controllers[e].values)){Object.keys(this.postForm.controllers[e].values).forEach((e=>{if(!t.includes(e)){t.push(e)}}))}}));return t}}let H=t=>t,j,V,z,G,q,Y;const K=128;class W extends x{constructor(t){super(t);this.isCollapsed=null;this.isContentLoaded=null;this.setEventNamespace("BX.UI.Timeline.Comment")}afterRender(){super.afterRender();if(this.isCollapsed===null){this.isCollapsed=this.isAddExpandBlock()}if(this.isContentLoaded===null){this.isContentLoaded=!this.hasFiles()}if(this.isCollapsed){this.getMain().classList.add("ui-timeline-content-description-collapsed");this.getMain().classList.remove("ui-timeline-content-description-expand")}else{this.getMain().classList.remove("ui-timeline-content-description-collapsed");this.getMain().classList.add("ui-timeline-content-description-expand")}if(this.isAddExpandBlock()){this.getMainDescription().appendChild(this.renderExpandBlock())}if(this.hasFiles()){this.getContent().appendChild(r.Tag.render(j||(j=H`<div class="ui-timeline-section-files">${0}</div>`),this.renderFilesContainer()));r.Event.ready((()=>{setTimeout((()=>{this.loadFilesContent()}),100)}))}}getFiles(){if(r.Type.isArray(this.data.files)){return this.data.files}return[]}hasFiles(){return this.getFiles().length>0}isAddExpandBlock(){return this.textDescription.length>K||this.hasFiles()}renderContainer(){const t=super.renderContainer();t.classList.add("ui-item-detail-stream-section-comment");t.classList.remove("ui-item-detail-stream-section-info");return t}renderMain(){this.layout.main=r.Tag.render(V||(V=H`<div class="ui-item-detail-stream-content-detail">
			${0}
		</div>`),this.renderMainDescription());return this.getMain()}getMain(){return this.layout.main}renderMainDescription(){this.layout.mainDescription=r.Tag.render(z||(z=H`<div class="ui-item-detail-stream-content-description" onclick="${0}">${0}</div>`),this.onMainClick.bind(this),this.htmlDescription);return this.getMainDescription()}getMainDescription(){return this.layout.mainDescription}renderExpandBlock(){this.layout.expandBlock=r.Tag.render(G||(G=H`<div class="ui-timeline-content-description-expand-container">${0}</div>`),this.renderExpandButton());return this.getExpandBlock()}getExpandBlock(){return this.layout.expandBlock}renderExpandButton(){this.layout.expandButton=r.Tag.render(q||(q=H`<a class="ui-timeline-content-description-expand-btn" onclick="${0}">
			${0}
		</a>`),this.onExpandButtonClick.bind(this),r.Loc.getMessage(this.isCollapsed?"UI_TIMELINE_EXPAND_SM":"UI_TIMELINE_COLLAPSE_SM"));return this.getExpandButton()}getExpandButton(){return this.layout.expandButton}getCommendEditor(){if(!this.commentEditor){this.commentEditor=new $({commentId:this.getId(),id:"UICommentEditor"+this.getId()+(this.isPinned?"pinned":"")+r.Text.getRandom()});this.commentEditor.layout.container=this.getContainer();this.commentEditor.subscribe("cancel",this.switchToViewMode.bind(this));this.commentEditor.subscribe("afterSave",this.onSaveComment.bind(this))}return this.commentEditor}getEditorContainer(){return this.layout.editorContainer}renderEditorContainer(){const t=this.getCommendEditor().getVisualEditorContainer();if(t){this.layout.editorContainer=t}else{this.layout.editorContainer=this.getCommendEditor().renderVisualEditorContainer()}return this.getEditorContainer()}getEditorButtons(){return this.layout.editorButtons}renderEditorButtons(){this.layout.editorButtons=this.getCommendEditor().renderButtons();return this.getEditorButtons()}renderFilesContainer(){this.layout.filesContainer=r.Tag.render(Y||(Y=H`<div class="ui-timeline-section-files-inner"></div>`));return this.getFilesContainer()}getFilesContainer(){return this.layout.filesContainer}switchToEditMode(){if(!this.isRendered()){return}if(!this.getEditorContainer()){this.getMain().appendChild(this.renderEditorContainer());this.getMain().appendChild(this.renderEditorButtons())}else{this.getCommendEditor().refresh()}this.getContent().classList.add("ui-item-detail-comment-edit");this.getCommendEditor().showVisualEditor()}switchToViewMode(){this.getContent().classList.remove("ui-item-detail-comment-edit");this.getCommendEditor().hideVisualEditor()}getActions(){return[{text:r.Loc.getMessage("UI_TIMELINE_ACTION_MODIFY"),onclick:this.actionEdit.bind(this)},{text:r.Loc.getMessage("UI_TIMELINE_ACTION_DELETE"),onclick:this.actionDelete.bind(this)}]}actionEdit(){this.getActionsMenu().close();this.switchToEditMode()}actionDelete(){this.getActionsMenu().close();i.MessageBox.confirm(r.Loc.getMessage("UI_TIMELINE_COMMENT_DELETE_CONFIRM"),(()=>new Promise((t=>{if(this.isProgress){return}this.startProgress();const e=new n.BaseEvent({data:{commentId:this.getId()}});this.emitAsync("onDelete",e).then((()=>{this.stopProgress();this.onDelete();t()})).catch((()=>{this.stopProgress();const i=e.getData().message;if(i){this.emit("error",{message:i})}t()}))}))))}clearLayout(t=false){this.commentEditor=null;return super.clearLayout(t)}onSaveComment(t){const e=t.getData();if(e.data&&e.data.comment){this.update(e.data.comment)}}onMainClick({target:t}){if(r.Type.isDomNode(t)){const e=t.tagName.toLowerCase();if(e==="a"||e==="img"||r.Dom.hasClass(t,"feed-con-file-changes-link-more")||r.Dom.hasClass(t,"feed-com-file-inline")||document.getSelection().toString().length>0){return}}this.switchToEditMode()}onExpandButtonClick(t){t.preventDefault();t.stopPropagation();if(!this.isRendered()){return}if(this.isCollapsed===true){this.getExpandBlock().style.maxHeight=this.getExpandBlock().scrollHeight+130+"px";this.getMain().classList.remove("ui-timeline-content-description-collapsed");this.getMain().classList.add("ui-timeline-content-description-expand");setTimeout((()=>{this.getExpandBlock().style.maxHeight=""}),300);this.getExpandButton().innerText=r.Loc.getMessage("UI_TIMELINE_COLLAPSE_SM");if(!this.isContentLoaded){this.isContentLoaded=true;this.loadContent()}this.isCollapsed=false}else if(this.isCollapsed===false){this.getExpandBlock().style.maxHeight=this.getExpandBlock().scrollHeight+"px";this.getMain().classList.add("ui-timeline-content-description-collapsed");this.getMain().classList.remove("ui-timeline-content-description-expand");setTimeout((()=>{this.getExpandBlock().style.maxHeight=""}),0);this.getExpandButton().innerText=r.Loc.getMessage("UI_TIMELINE_EXPAND_SM");this.isCollapsed=true}}loadFilesContent(){if(this.isProgress){return}this.startProgress();const t=new n.BaseEvent({data:{commentId:this.getId()}});this.emitAsync("onLoadFilesContent",t).then((()=>{this.stopProgress();const e=t.getData().html;if(r.Type.isString(e)){r.Runtime.html(this.getFilesContainer(),e)}})).catch((()=>{this.stopProgress();const e=t.getData().message;if(e){this.emit("error",{message:e})}}))}loadContent(){if(this.isProgress){return}this.startProgress();const t=new n.BaseEvent({data:{commentId:this.getId()}});this.emitAsync("onLoadContent",t).then((()=>{this.stopProgress();const e=t.getData().comment;if(e&&r.Type.isString(e.htmlDescription)){r.Runtime.html(this.getMainDescription(),e.htmlDescription);if(this.isAddExpandBlock()){this.getMainDescription().appendChild(this.getExpandBlock())}this.updateData(e)}})).catch((()=>{this.stopProgress();const e=t.getData().message;if(e){this.emit("error",{message:e})}}))}}class J{start(){}finish(t,e){}}let Q=t=>t,Z;class tt extends J{constructor(t){super(t);if(r.Type.isPlainObject(t)){if(t.item instanceof y&&r.Type.isDomNode(t.container)){this.item=t.item;this.container=t.container;this.insertAfter=t.insertAfter}}}start(){const t=tt.DEFAULT_TIMEOUT;return new Promise((e=>{if(!this.item||!this.container){e()}setTimeout((()=>{this.createGhost(this.item.render(),e)}),t)}))}createGhost(t,e){t.style.position="absolute";t.style.width=this.container.offsetWidth+"px";t.style.top=r.Dom.getPosition(this.container).top+"px";t.style.left=r.Dom.getPosition(this.container).left+"px";document.body.appendChild(t);this.anchor=r.Tag.render(Z||(Z=Q`<div class="ui-item-detail-stream-section ui-item-detail-stream-section-shadow"></div>`));r.Dom.prepend(this.anchor,this.container);if(r.Type.isDomNode(this.insertAfter)){r.Dom.insertAfter(this.anchor,this.insertAfter)}this.moveGhost(t,e)}moveGhost(t,e){const i=r.Dom.getPosition(this.anchor);const s=r.Dom.getPosition(this.container);const n=new BX.easing({duration:tt.DURATION,start:{top:s.top,height:0},finish:{top:i.top-5,height:r.Dom.getPosition(t).height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:e=>{t.style.top=e.top+"px";this.anchor.style.height=e.height+"px"},complete:()=>{this.finish(t,e)}});n.animate()}finish(t,e){t.style.position="";t.style.width="";t.style.height="";t.style.top="";t.style.left="";t.style.opacity="";r.Dom.insertAfter(t,this.anchor);r.Dom.remove(this.anchor);this.anchor=null;if(r.Type.isFunction(e)){e()}}}tt.DEFAULT_TIMEOUT=150;tt.DURATION=1200;class et extends J{constructor(t){super(t);if(r.Type.isPlainObject(t)){if(t.item instanceof y&&r.Type.isDomNode(t.anchor)){this.item=t.item;this.anchor=t.anchor;this.startPosition=t.startPosition}}}start(){return new Promise((t=>{if(!this.item||!this.anchor){t()}this.node=this.item.render();r.Dom.addClass(this.node,"ui-item-detail-stream-section-top-fixed");this.node.style.position="absolute";this.node.style.width=this.startPosition.width+"px";let e=this.startPosition.height;const i=65;const s=18;if(e<s+i)e=s+i;this.node.style.height=e+"px";this.node.style.top=this.startPosition.top+"px";this.node.style.left=this.startPosition.left+"px";this.node.style.zIndex=960;document.body.appendChild(this.node);this._anchorPosition=r.Dom.getPosition(this.anchor);const n={top:this._anchorPosition.top,height:e+15,opacity:1};const o=this.startPosition.top-this._anchorPosition.bottom;const a=2*(document.body.clientHeight+this.startPosition.height);if(o>a){n.top=this.startPosition.top-a;n.opacity=0}let h=Math.abs(n.top-this.startPosition.top)*2;h=h<et.DURATION?et.DURATION:h;const d=new BX.easing({duration:h,start:{top:this.startPosition.top,height:0,opacity:1},finish:n,transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:t=>{this.node.style.top=t.top+"px";this.node.style.opacity=t.opacity;this.anchor.style.height=t.height+"px"},complete:()=>{this.finish(this.node,t)}});d.animate()}))}finish(t,e){t.style.position="";t.style.width="";t.style.height="";t.style.top="";t.style.left="";t.style.zIndex="";this.anchor.style.height=0;r.Dom.insertAfter(t,this.anchor);if(r.Type.isFunction(e)){e()}}}et.DURATION=1500;class it extends J{constructor(t){super(t);if(r.Type.isPlainObject(t)){if(t.item instanceof y&&r.Type.isDomNode(t.container)&&r.Type.isDomNode(t.insertAfter)){this.item=t.item;this.container=t.container;this.insertAfter=t.insertAfter}}}start(){return new Promise((t=>{if(!this.item||!this.container||!this.insertAfter){t()}r.Dom.insertAfter(this.item.render(),this.insertAfter);this.expand().then((()=>{this.fadeIn().then((()=>{this.finish(this.item.getContainer(),t)}))}))}))}expand(){return new Promise((t=>{const e=this.item.getContainer();const i=r.Dom.getPosition(e);e.style.height=0;e.style.opacity=0;e.style.overflow="hidden";const s=new BX.easing({duration:it.EXPAND_DURATION,start:{height:0},finish:{height:i.height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:t=>{e.style.height=t.height+"px"},complete:t});s.animate()}))}fadeIn(){return new Promise((t=>{this.item.getContainer().style.overflow="";const e=new BX.easing({duration:it.FADE_IN_DURATION,start:{opacity:0},finish:{opacity:100},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:t=>{this.item.getContainer().style.opacity=t.opacity/100},complete:t});e.animate()}))}finish(t,e){this.item.getContainer().style.height="";this.item.getContainer().style.opacity="";if(r.Type.isFunction(e)){e()}}}it.EXPAND_DURATION=150;it.FADE_IN_DURATION=150;let st=t=>t,nt;class rt extends J{constructor(t){super(t);if(r.Type.isPlainObject(t)){if(t.item instanceof y&&t.task instanceof y&&r.Type.isDomNode(t.insertAfter)){this.item=t.item;this.task=t.task;this.insertAfter=t.insertAfter}}}start(){return new Promise((t=>{if(!this.item||!this.task||!this.container||!this.insertAfter){t()}const e=this.item.render();const i=this.task.getContainer();const s=r.Dom.getPosition(i);e.style.position="absolute";e.style.width=i.offsetWidth+"px";e.style.top=s.top+"px";e.style.left=s.left+"px";e.style.zIndex="999";r.Dom.addClass(e,"ui-item-detail-stream-section-show");document.body.appendChild(e);this.anchor=r.Tag.render(nt||(nt=st`<div class="ui-item-detail-stream-section ui-item-detail-stream-section-shadow"></div>`));r.Dom.prepend(this.anchor,this.container);if(r.Type.isDomNode(this.insertAfter)){r.Dom.insertAfter(this.anchor,this.insertAfter)}i.style.height=i.offsetHeight+"px";r.Dom.addClass(i,"ui-item-detail-stream-section-hide");setTimeout(function(){const s=i.offsetHeight;this.anchor.style.height=s+"px";r.Dom.remove(i);r.Dom.removeClass(e,"ui-item-detail-stream-section-show");const n=new BX.easing({duration:800,start:{top:r.Dom.getPosition(e).top,height:s},finish:{top:r.Dom.getPosition(this.anchor).top,height:r.Dom.getPosition(e).height},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:t=>{e.style.top=t.top+"px";this.anchor.style.height=t.height+"px"},complete:()=>{this.finish(e,t)}});n.animate()}.bind(this),200)}))}finish(t,e){t.style.position="";t.style.width="";t.style.top="";t.style.left="";t.style.zIndex="";r.Dom.insertAfter(t,this.anchor);r.Dom.remove(this.anchor);this.anchor=null;if(r.Type.isFunction(e)){e()}}}rt.DURATION=1200;class ot extends J{constructor(t){super(t);if(r.Type.isPlainObject(t)){if(r.Type.isDomNode(t.node)){this.node=t.node}}}start(){return new Promise((t=>{if(!this.node){t()}const e=this.node;const i=r.Dom.getPosition(e);const s=new BX.easing({duration:ot.DURATION,start:{height:i.height,opacity:1,marginBottom:15},finish:{height:0,opacity:0,marginBottom:0},transition:BX.easing.makeEaseOut(BX.easing.transitions.quart),step:t=>{if(e){e.style.height=t.height+"px";e.style.opacity=t.opacity;e.style.marginBottom=t.marginBottom}},complete:()=>{this.finish(e,t)}});s.animate()}))}finish(t,e){r.Dom.remove(t);if(r.Type.isFunction(e)){e()}}}ot.DURATION=1e3;var at=babelHelpers.classPrivateFieldLooseKey("items");var ht=babelHelpers.classPrivateFieldLooseKey("isRunning");class dt{static add(t){babelHelpers.classPrivateFieldLooseBase(dt,at)[at].push(t);return dt}static run(){if(babelHelpers.classPrivateFieldLooseBase(dt,ht)[ht]){return}let t=babelHelpers.classPrivateFieldLooseBase(dt,at)[at].shift();if(!t){return}if(!r.Type.isArray(t)){t=[t]}babelHelpers.classPrivateFieldLooseBase(dt,ht)[ht]=true;const e=[];t.forEach((t=>{if(t instanceof J){e.push(t.start())}}));Promise.all(e).then((()=>{babelHelpers.classPrivateFieldLooseBase(dt,ht)[ht]=false;dt.run()}))}}Object.defineProperty(dt,at,{writable:true,value:[]});Object.defineProperty(dt,ht,{writable:true,value:false});let lt=t=>t,ct,mt,ut,gt,pt,ft,yt,Tt,Ct,It,Et,vt;class Dt{constructor(t){this.users=new Map;this.eventIds=new Set;this.pinnedItems=[];this.tasks=[];this.items=[];this.editors=new Map;this.layout={};this.dateSeparators=new Map;this.nameFormat=t.nameFormat;n.EventEmitter.makeObservable(this,"BX.UI.Timeline.Stream");this.initItemClasses(t.itemClasses);this.currentPage=1;if(r.Type.isPlainObject(t)){if(r.Type.isNumber(t.pageSize)){this.pageSize=t.pageSize}if(!this.pageSize||this.pageSize<=0){this.pageSize=20}this.addUsers(t.users);if(r.Type.isArray(t.items)){t.items.forEach((t=>{const e=this.createItem(t);if(e){this.addItem(e)}}))}if(r.Type.isArray(t.tasks)){this.initTasks(t.tasks)}if(r.Type.isArray(t.editors)){t.editors.forEach((t=>{if(t instanceof k){this.editors.set(t.getId(),t)}}))}}this.bindEvents();this.progress=false;this.emit("onAfterInit",{stream:this})}initTasks(t){this.tasks=[];t.forEach((t=>{const e=this.createItem(t);if(e){this.tasks.push(e)}}))}bindEvents(){this.onScrollHandler=r.Runtime.throttle(this.onScroll.bind(this),100).bind(this);r.Event.ready((()=>{if(this.getItems().length>=this.pageSize){this.enableLoadOnScroll()}}));Array.from(this.editors.values()).forEach((t=>{t.subscribe("error",(t=>{this.onError(t.getData())}))}))}initItemClasses(t){if(t){this.itemClasses=new Map(t)}else{this.itemClasses=new Map}this.itemClasses.set("item_create",x);this.itemClasses.set("stage_change",B);this.itemClasses.set("fields_change",M);this.itemClasses.set("comment",W)}createItem(t,e){if(!r.Type.isPlainObject(t.events)){t.events={}}t.eventIds=this.eventIds;t.events.onPinClick=this.onItemPinClick.bind(this);t.events.onDelete=this.onItemDelete.bind(this);t.events.onError=this.onError.bind(this);if(!r.Type.isFunction(e)){e=this.getItemClassName(t)}const i=new e(t);if(i instanceof y){return i.setUserData(this.users).setTimeFormat(this.getTimeFormat()).setNameFormat(this.nameFormat)}return null}addItem(t){if(t instanceof y){this.items.push(t);if(t.isFixed){this.pinnedItems.push(this.getPinnedItemFromItem(t))}}return this}static getItemFromArray(t,e){let i=null;let s=0;while(true){if(!t[s]){break}const n=t[s];if(n.getId()===e){i=n;break}s++}return i}static getItemIndexFromArray(t,e){let i=null;let s=0;while(true){if(!t[s]){break}const n=t[s];if(n.getId()===e){i=s;break}s++}return i}getItems(){return this.items}getItem(t){return Dt.getItemFromArray(this.getItems(),t)}getPinnedItems(){return this.pinnedItems}getPinnedItem(t){return Dt.getItemFromArray(this.getPinnedItems(),t)}getTasks(){return this.tasks}getTask(t){return Dt.getItemFromArray(this.getTasks(),t)}render(){if(!this.layout.container){this.layout.container=r.Tag.render(ct||(ct=lt`<div class="ui-item-detail-stream-container"></div>`))}if(this.editors.size>0){this.renderEditors()}if(!this.layout.content){this.layout.content=r.Tag.render(mt||(mt=lt`<div class="ui-item-detail-stream-content"></div>`));this.layout.container.appendChild(this.layout.content)}if(!this.layout.pinnedItemsContainer){this.layout.pinnedItemsContainer=r.Tag.render(ut||(ut=lt`<div class="ui-item-detail-stream-container-list ui-item-detail-stream-container-list-fixed"></div>`));this.layout.content.appendChild(this.layout.pinnedItemsContainer)}this.renderPinnedItems();if(!this.layout.tasksContainer){this.layout.tasksContainer=r.Tag.render(gt||(gt=lt`<div class="ui-item-detail-stream-container-list"></div>`));this.layout.content.appendChild(this.layout.tasksContainer)}this.renderTasks();if(!this.layout.itemsContainer){this.layout.itemsContainer=r.Tag.render(pt||(pt=lt`<div class="ui-item-detail-stream-container-list"></div>`));this.layout.content.appendChild(this.layout.itemsContainer)}this.renderItems();this.emit("onAfterRender");return this.layout.container}getContainer(){return this.layout.container}renderEditors(){if(!this.layout.container){return}if(!this.layout.editors){this.layout.editorsTitle=r.Tag.render(ft||(ft=lt`<div class="ui-item-detail-stream-section-new-header"></div>`));this.layout.editorsContent=r.Tag.render(yt||(yt=lt`<div class="ui-item-detail-stream-section-new-detail"></div>`));this.layout.editors=r.Tag.render(Tt||(Tt=lt`<div class="ui-item-detail-stream-section ui-item-detail-stream-section-new">
				<div class="ui-item-detail-stream-section-icon"></div>
				<div class="ui-item-detail-stream-section-content">
					${0}
				</div>
				${0}
			</div>`),this.layout.editorsTitle,this.layout.editorsContent);let t=true;Array.from(this.editors.values()).forEach((e=>{this.layout.editorsTitle.appendChild(r.Tag.render(Ct||(Ct=lt`<a class="ui-item-detail-stream-section-new-action ${0}">${0}</a>`),t?"ui-item-detail-stream-section-new-action-active":"",e.getTitle()));this.layout.editorsContent.appendChild(e.render());t=false}));this.layout.container.appendChild(this.layout.editors)}}renderPinnedItems(){r.Dom.clean(this.layout.pinnedItemsContainer);this.createFixedAnchor();this.getPinnedItems().forEach((t=>{if(!t.isRendered()){t.render()}r.Dom.append(t.getContainer(),this.layout.pinnedItemsContainer)}))}createFixedAnchor(){this.fixedAnchor=r.Tag.render(It||(It=lt`<div class="ui-item-detail-stream-section-fixed-anchor"></div>`));r.Dom.prepend(this.fixedAnchor,this.layout.pinnedItemsContainer)}updateTasks(t){if(!this.tasks){this.tasks=[]}const e=[];t.forEach((t=>{const i=this.createItem(t);if(i){e.push(i);this.addUsers(t.users)}}));const i=[];this.tasks.forEach((t=>{if(!Dt.getItemFromArray(e,t.getId())){i.push(t)}}));i.forEach((t=>{this.deleteItem(t)}));let s=this.getTasksTitle();if(e.length>0){if(!s){s=this.renderTasksTitle();this.layout.tasksContainer.appendChild(s)}e.forEach((t=>{if(!this.getTask(t.getId())){this.tasks.push(t);dt.add(new it({item:t,container:this.layout.tasksContainer,insertAfter:s}))}else{const e=this.getTask(t.getId());e.setUserData(this.users);e.update(t.getDataForUpdate())}}))}else{const t=this.getTasksTitle();if(t){r.Dom.remove(t);this.layout.tasksTitle=null}}dt.run()}renderTasks(){if(this.getTasks().length>0){this.layout.tasksContainer.appendChild(this.renderTasksTitle());this.getTasks().forEach((t=>{if(!t.isRendered()){r.Dom.append(t.render(),this.layout.tasksContainer)}}))}else{const t=this.getTasksTitle();if(t){t.parentElement.removeChild(t)}}}getTasksTitle(){return this.layout.tasksTitle}renderTasksTitle(){if(!this.layout.tasksTitle){this.layout.tasksTitle=r.Tag.render(Et||(Et=lt`<div class="ui-item-detail-stream-section ui-item-detail-stream-section-planned-label">
				<div class="ui-item-detail-stream-section-content">
					<div class="ui-item-detail-stream-planned-text">${0}</div>
				</div>
			</div>`),r.Loc.getMessage("UI_TIMELINE_TASKS_TITLE"))}return this.layout.tasksTitle}renderItems(){const t=this.items[this.items.length-1];this.items.forEach((e=>{e.setIsLast(e===t);if(!e.isRendered()){const t=this.constructor.getDayFromDate(e.getCreatedTime());if(!this.getDateSeparator(t)){const e=this.createDateSeparator(t);r.Dom.append(e,this.layout.itemsContainer)}r.Dom.append(e.render(),this.layout.itemsContainer)}}))}getDateSeparator(t){return this.dateSeparators.get(t)}createDateSeparator(t){const e=this.renderDateSeparator(t);this.dateSeparators.set(t,e);return e}static getDayFromDate(t){if(t instanceof Date){if(Dt.isToday(t)){return BX.date.format("today")}return BX.date.format("d F Y",t)}return null}static isToday(t){return BX.date.format("d F Y",t)===BX.date.format("d F Y")}renderDateSeparator(t){return r.Tag.render(vt||(vt=lt`<div class="ui-item-detail-stream-section ui-item-detail-stream-section-history-label">
			<div class="ui-item-detail-stream-section-content">
				<div class="ui-item-detail-stream-history-text">${0}</div>
			</div>
		</div>`),t)}getItemClassName(t){let e=null;if(r.Type.isPlainObject(t)&&r.Type.isString(t.itemClassName)){e=t.itemClassName}if(e){e=r.Reflection.getClass(e)}if(!r.Type.isFunction(e)){if(r.Type.isPlainObject(t)&&r.Type.isString(t.action)){e=this.itemClasses.get(t.action)}if(!e){e=x}}return e}insertItem(t){if(!(t instanceof y)){return this}if(this.getItem(t.getId())){return this}this.items.unshift(t);const e=this.constructor.getDayFromDate(t.getCreatedTime());if(!e){return this}if(!this.getDateSeparator(e)){const t=this.createDateSeparator(e);r.Dom.prepend(t,this.layout.itemsContainer)}dt.add(new tt({item:t,insertAfter:this.getDateSeparator(e),container:this.layout.editorsContent})).run();return this}getTimeFormat(){if(!this.timeFormat){const t=r.Loc.getMessage("FORMAT_DATETIME").replace(/:SS/,"");const e=r.Loc.getMessage("FORMAT_DATE");this.timeFormat=BX.date.convertBitrixFormat(t.trim().replace(e,""))}return this.timeFormat}getDateTimeFormat(){if(!this.dateTimeFormat){const t=r.Loc.getMessage("FORMAT_DATETIME").replace(/:SS/,"");this.dateTimeFormat=BX.date.convertBitrixFormat(t)}return this.dateTimeFormat}startProgress(){this.progress=true;if(!this.getLoader().isShown()){const t=this.items[this.items.length-1];if(t&&t.isRendered()){this.getLoader().show(t.getContainer())}else{this.getLoader().show(this.layout.container)}}}stopProgress(){this.progress=false;this.getLoader().hide()}isProgress(){return this.progress===true}getLoader(){if(!this.loader){this.loader=new e.Loader({size:150})}return this.loader}enableLoadOnScroll(){r.Event.bind(window,"scroll",this.onScrollHandler)}disableLoadOnScroll(){r.Event.unbind(window,"scroll",this.onScrollHandler)}onScroll(){if(this.isProgress()){return}const t=this.items[this.items.length-1];if(!t){this.disableLoadOnScroll();return}if(!t.isRendered()){return}const e=t.getContainer().getBoundingClientRect();if(e.top<=document.documentElement.clientHeight){this.emit("onScrollToTheBottom")}}getPinnedItemFromItem(t){const e=r.Runtime.clone(t);if(t.isRendered()){e.clearLayout()}e.setTimeFormat(this.getDateTimeFormat());e.isPinned=true;return e}onItemPinClick(t){if(t.isFixed){this.pinItem(t)}else{this.unPinItem(t)}this.emit("onPinClick",{item:t})}pinItem(t){const e=this.getPinnedItem(t.getId());if(!e){this.getPinnedItems().push(this.getPinnedItemFromItem(t))}dt.add(new et({item:this.getPinnedItem(t.getId()),anchor:this.fixedAnchor,startPosition:r.Dom.getPosition(t.getContainer())})).run();return this}unPinItem(t){const e=this.getPinnedItem(t.getId());if(e===t){const t=this.getItem(e.getId());if(t){t.isFixed=false;t.renderPin()}}if(e&&e.isRendered()){dt.add(new ot({node:e.getContainer()})).run()}this.pinnedItems=this.pinnedItems.filter((e=>e.getId()!==t.getId()))}onItemDelete(t){this.deleteItem(t)}deleteItem(t){let e=Dt.getItemIndexFromArray(this.items,t.getId());const i=[];if(e!==null){if(t.isRendered()){const e=new ot({node:this.getItem(t.getId()).getContainer()});i.push(e)}this.items.splice(e,1)}e=Dt.getItemIndexFromArray(this.pinnedItems,t.getId());if(e!==null){if(t.isRendered()){const e=new ot({node:this.getPinnedItem(t.getId()).getContainer()});i.push(e)}this.pinnedItems.splice(e,1)}e=Dt.getItemIndexFromArray(this.tasks,t.getId());if(e!==null){let s=true;if(t.completedData){const e=this.createItem(t.completedData);if(e){if(!this.getItem(e.getId())){this.items.unshift(e);const i=this.constructor.getDayFromDate(e.getCreatedTime());if(i){if(!this.getDateSeparator(i)){const t=this.createDateSeparator(i);r.Dom.prepend(t,this.layout.itemsContainer)}dt.add(new rt({item:e,task:t,insertAfter:this.getDateSeparator(i)})).run();s=false}}}}if(s){i.push(new ot({node:this.getTask(t.getId()).getContainer()}))}this.tasks.splice(e,1)}dt.add(i).run()}onError({message:t}){this.showError(t)}showError(t){console.error(t)}addUsers(t){if(r.Type.isPlainObject(t)){if(!this.users){this.users=new Map}Object.keys(t).forEach((e=>{e=r.Text.toInteger(e);if(e>0){this.users.set(e,t[e])}}))}}addAnimation(t){dt.add(t).run()}}const Pt={Stream:Dt,Item:y,History:x,StageChange:B,Editor:k,CommentEditor:$,FieldsChange:M};t.Timeline=Pt})(this.BX.UI=this.BX.UI||{},BX,BX.UI.Dialogs,BX.Main,BX.Event,BX);
//# sourceMappingURL=timeline.bundle.map.js