text: "use strict";function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o};return _setPrototypeOf(o,p)}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget)}else{result=Super.apply(this,arguments)}return _possibleConstructorReturn(this,result)}}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call}return _assertThisInitialized(self)}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],(function(){})));return true}catch(e){return false}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _getPrototypeOf(o)}var editor_layout=function(_CrowdinComponent){_inherits(editor_layout,_CrowdinComponent);var _super=_createSuper(editor_layout);function editor_layout(){var _this;_classCallCheck(this,editor_layout);_this=_super.call(this);_this.panes={};_this.elements={};_this.storage_key=null;_this.mainMenuOpened=false;_this.options={center:[],left:[],right:[]};_this.state={left:{splitview:true,open:true},right:{splitview:true,open:true}};_this.timeouts={tint:null,animation:null,proofread:null};_this.evt={};_this.vars={window:0};_this.defaults={translate:{left:[300,.25,900],center:[480],right:[320,.25,600]},translateHTML:{left:[360,.4,900],center:[480],right:[320,.2,450]},assets:{left:[360,.4,900],center:[480],right:[320,.2,450]},proofread:{left:[0,0,0],center:[IS_MOBILE?650:800],right:[460,.35,600]},review:{left:[0,0,0],center:[IS_MOBILE?450:700],right:[460,.45,900]}};var self=_assertThisInitialized(_this);self.evt.mousedown=is_mobile_device.any()?"touchstart.panes":"mousedown.panes";self.panes={left:$("#left_panel"),center:$("#editor-center-layout"),right:$("#right_panel")};self.elements={translation:$("#translation_container"),suggestions:$("#suggestions-wrapper"),header:$("#editor-header"),masks:$(".editor-pane-mask"),content:$("#content")};self.resizePanes();self.bindPanesResize();self.updatePanes();self.elements.content.addClass("ready");$(window).resize((function(){var pwa=isPwa();self.updatePanes();crowdin.helpers.users.closeUserPopover();if(crowdin.editor.view.state.isPwa!==pwa){crowdin.editor.view.setState({isPwa:pwa})}}));self.bindModalMenu();return _this}_createClass(editor_layout,[{key:"getDocumentWidth",value:function getDocumentWidth(){return document.body.clientWidth||window.innerWidth}},{key:"resizePanes",value:function resizePanes(){var editorMode=crowdin.editor.mode;if(editorMode==="translate"){if(crowdin.phrases&&crowdin.phrases.version==="html"){editorMode="translateHTML"}}this.setStorageKey(editorMode);this.options=Object.assign(this.options,this.defaults[editorMode]);this.getPanesState();var left=this.options.left[1]*100+"%";var right=this.options.right[1]*100+"%";var left_m={"min-width":this.options.left[0],"max-width":this.options.left[2]};var right_m={"min-width":this.options.right[0],"max-width":this.options.right[2]};this.panes.left.css({width:left}).css(left_m);this.panes.center.css({left:this.panes.left.length?left:"-1px",right:this.panes.right.length?right:"-1px"});this.panes.right.css({width:right}).css(right_m)}},{key:"setStorageKey",value:function setStorageKey(editor_mode){this.storage_key="crowdin_editor_"+crowdin.user.id+"_"+editor_mode}},{key:"updateState",value:function updateState(pane){var window=this.getDocumentWidth();var ls=false;var rs=false;var lo=this.panes.left.length&&this.state.left.open;var ro=this.panes.right.length&&this.state.right.open;var cw=this.options.center[0];var lw=this.options.left;var rw=this.options.right;var left=lo?Math.round(Math.min(Math.max(window*lw[1],lw[0]),lw[2])):0;var right=ro?Math.round(Math.min(Math.max(window*rw[1],rw[0]),rw[2])):0;if(window>=cw+left){ls=true}if(window>=cw+right){rs=true}if(window<cw+left+right){if(!pane){rs=false}else{pane==="left"?ls=false:rs=false}}this.state.left.splitview=ls;this.state.right.splitview=rs}},{key:"handleRoom",value:function handleRoom(){var self=this;self.toggleAnimation(false);self.updateState();var left_css={};var right_css={};var center_css={};var l=self.options.left;var r=self.options.right;var lo=this.panes.left.length&&this.state.left.splitview&&this.state.left.open;var ro=this.panes.right.length&&this.state.right.splitview&&this.state.right.open;var lw=self.getDocumentWidth()*l[1];var rw=self.getDocumentWidth()*r[1];left_css={width:l[1]*100+"%","-webkit-transform":"translateX(0)",transform:"translateX(0)"};right_css={width:r[1]*100+"%","-webkit-transform":"translateX(0)",transform:"translateX(0)"};center_css={left:lo?lw<l[2]&&lw>l[0]?l[1]*100+"%":lw<l[2]?l[0]:l[2]:"-1px",right:ro?rw<r[2]&&rw>r[0]?r[1]*100+"%":rw<r[2]?r[0]:r[2]:"-1px","-webkit-transform":"translateX(0)",transform:"translateX(0)"};this.panes.left.css(left_css);this.panes.right.css(right_css);this.panes.center.css(center_css);this.panes.left[lo?"addClass":"removeClass"]("visible");this.panes.right[ro?"addClass":"removeClass"]("visible");this.elements.masks.removeClass("tinted").addClass("mask-hidden");$(".pane-toggler-left")[lo?"addClass":"removeClass"]("active").removeClass("disabled");$(".pane-toggler-right")[ro?"addClass":"removeClass"]("active").removeClass("disabled");$(".editor-pane-resizer.left")[!lo?"addClass":"removeClass"]("hidden");$(".editor-pane-resizer.right")[!ro?"addClass":"removeClass"]("hidden");self.elements.content.find("textarea, input[type=text]").prop("disabled",false);document.activeElement.blur()}},{key:"toggleAnimation",value:function toggleAnimation(yes){$(document.body)[yes!==false?"addClass":"removeClass"]("animated")}},{key:"bindPanesResize",value:function bindPanesResize(){var resizers=$(".editor-pane-resizer",this.panes.center);var active=false;var dragging=false;var startX=0;var startY=0;var startWidth=0;var pane={};var self=this;var minWidth=0;var maxValue=0;var pane_name="";$(document).on("click",".editor-pane-mask",(function(){if(!$(this).hasClass("mask-hidden")){self.isOpened("left")&&self.state.left.open&&!self.state.left.splitview&&self.toggle("left");self.isOpened("right")&&self.state.right.open&&!self.state.right.splitview&&self.toggle("right")}}));$(".pane-toggler").click((function(){var pane=$(this).hasClass("pane-toggler-left")?"left":"right";self.toggle(pane)}));if(!resizers.length){return}var dragStart=function dragStart(x,y){$(document.body).addClass("cursor-ew-resize")};var dragMove=function dragMove(x,y){if(pane_name==="right"){x=-x}var newWidth=startWidth+x;var classes=["cursor-w-resize","cursor-e-resize"];if(pane_name==="right"){classes.reverse()}$(document.body).removeClass(classes.join(" "));if(newWidth<minWidth||x>maxValue){$(document.body).addClass(x>maxValue?classes[0]:classes[1]);if(newWidth<minWidth){newWidth=minWidth}else{newWidth=startWidth+maxValue}}pane.width(newWidth);if(!self.state[pane_name].splitview){self.panes[pane_name==="right"?"left":"right"].add(self.panes.center).css({"-webkit-transform":"translateX("+(pane_name==="right"?-newWidth:newWidth)+"px)",transform:"translateX("+(pane_name==="right"?-newWidth:newWidth)+"px)"})}else{self.panes.center.css(pane_name==="right"?"right":"left",newWidth)}$(document).trigger("resize_pane_"+pane_name)};var dragEnd=function dragEnd(x,y){var width=pane.width()/self.getDocumentWidth();if(self.state[pane_name].splitview||width<self.options[pane_name][1]){self.options[pane_name][1]=width}$(document.body).removeClass("cursor-ew-resize cursor-e-resize cursor-w-resize");self.resizeSuggestions();self.savePanesState()};resizers.on(this.evt.mousedown,(function(e){e.preventDefault();pane_name=$(this).hasClass("right")?"right":"left";pane=self.panes[pane_name];if(!self.isOpened(pane_name)){return}active=true;startX=e.originalEvent.pageX;startY=e.originalEvent.pageY;minWidth=parseInt(pane.css("min-width"));startWidth=pane.width();pane.find(".editor-pane-mask").removeClass("mask-hidden");var cssMax=parseInt(pane.css("max-width"))-startWidth;maxValue=self.state[pane_name].splitview?Math.min(self.panes.center.outerWidth()-self.options.center[0],cssMax):Math.min(cssMax,self.getDocumentWidth()*.9-startWidth);maxValue--})).on("mouseup.panes touchend.panes",(function(){active&&pane.length&&pane.find(".editor-pane-mask:not(.tinted)").addClass("mask-hidden")}));$(document).on("mousemove.panes touchmove.panes",(function(e){if(active){e.preventDefault();var x_val=e.originalEvent.pageX-startX;var y_val=e.originalEvent.pageY-startY;if(Math.abs(x_val)<5&&Math.abs(y_val)<5){return}if(!dragging){dragStart(startX,startY);dragging=true}dragMove(x_val,y_val)}})).on("mouseup.panes touchend.panes",(function(e){if(dragging){var x_val=e.originalEvent.pageX-startX;var y_val=e.originalEvent.pageY-startY;dragEnd(x_val,y_val);pane.length&&pane.find(".editor-pane-mask:not(.tinted)").addClass("mask-hidden")}active=false;dragging=false}))}},{key:"toggle",value:function toggle(pane){$(document).trigger("mousedown");document.activeElement.blur();if(!this.panes[pane].length){return}var self=this;var p=this.panes[pane];var opane=pane==="left"?"right":"left";var op=this.panes[opane];var is_opened=this.isOpened(pane)&&this.state[pane].open;var slide_width=Math.min(Math.max(this.getDocumentWidth()*this.options[pane][1],this.options[pane][0]),this.options[pane][2]);var mask=op.add(this.panes.center).find(".editor-pane-mask");if(!this.state[opane].splitview&&this.isOpened(opane)){return}this.toggleAnimation();clearTimeout(this.timeouts.animation);clearTimeout(this.timeouts.tint);this.state[pane].open=!is_opened;this.updateState(pane);this.savePanesState();$(".editor-pane-resizer."+pane,this.panes.center)[is_opened?"addClass":"removeClass"]("hidden");$(".pane-toggler-"+pane)[!is_opened?"addClass":"removeClass"]("active");$(".pane-toggler-"+opane).removeClass("disabled");if(!is_opened&&!this.state[pane].splitview){mask.removeClass("mask-hidden");mask.addClass("tinted");if(IS_MOBILE){slide_width=Math.min(this.getDocumentWidth()*.85,slide_width)}p.css({width:slide_width,"min-width":Math.min(slide_width,this.options[pane][0])});p.addClass("visible sliding");op.add(this.panes.center).css({"-webkit-transform":"translateX("+(pane==="left"?slide_width:-slide_width)+"px)",transform:"translateX("+(pane==="left"?slide_width:-slide_width)+"px)"});op.add(this.panes.center).find("textarea, input[type=text]").prop("disabled",true);if(!IS_MOBILE){$(".editor-pane-resizer."+opane,this.panes.center).addClass("hidden")}$(".pane-toggler-"+opane).addClass("disabled");this.timeouts.animation=setTimeout((function(){self.toggleAnimation(false)}),400)}else{if(!is_opened){var pane_css={width:this.options[pane][1]*100+"%","-webkit-transform":"translateX(0)",transform:"translateX(0)"};p.css(pane_css).addClass("visible")}p.removeClass("sliding");var center_css={};if(pane==="left"){center_css["left"]=!is_opened&&this.state.left.splitview?slide_width:"-1px"}else{center_css["right"]=!is_opened&&this.state.right.splitview?slide_width:"-1px"}this.panes.center.css(center_css);op.add(this.panes.center).css({"-webkit-transform":"translateX(0)",transform:"translateX(0)"});mask.removeClass("tinted");self.elements.content.find("textarea, input[type=text]").prop("disabled",false);if(!IS_MOBILE){$(".editor-pane-resizer."+opane,this.panes.center).removeClass("hidden")}this.timeouts.tint=setTimeout((function(){is_opened&&p.removeClass("visible");mask.addClass("mask-hidden");self.toggleAnimation(false);self.updatePanes()}),400)}!is_opened&&$(document).trigger("open_pane_"+pane)}},{key:"isOpened",value:function isOpened(pane){return this.panes[pane].hasClass("visible")}},{key:"updatePanes",value:function updatePanes(){this.resizeSuggestions();if(this.getDocumentWidth()!==this.vars.window){this.handleRoom();this.vars.window=this.getDocumentWidth()}}},{key:"reloadLeftPanel",value:function reloadLeftPanel(){if(!crowdin.phrases){return}this.resizePanes();this.handleRoom();this.updatePanes()}},{key:"resizeSuggestions",value:function resizeSuggestions(){if(crowdin.editor.modeReviewProofread()){clearTimeout(this.timeouts.proofread);this.timeouts.proofread=setTimeout((function(){crowdin.editor.view.setState({updatePhrases:false});$("#phrases textarea").each((function(){var evt=document.createEvent("Event");evt.initEvent("autosize:update",true,false);this.dispatchEvent(evt)}))}),100)}else{if(crowdin.editor.modeTranslate()){var textarea=crowdin.translation&&crowdin.translation.area.container;if(textarea){$(textarea).trigger("highlight.handleLineBreaks")}}var center=this.panes.center;if(IS_MOBILE){center.addClass("small-height");return}var translation_container=this.elements.translation;var suggestions_height=center.height()-translation_container.height();this.elements.suggestions.height(suggestions_height-20);center[suggestions_height<290?"addClass":"removeClass"]("small-height")}}},{key:"getPanesState",value:function getPanesState(){try{if(typeof localStorage[this.storage_key]==="string"){var saved=JSON.parse(localStorage[this.storage_key]);this.options.left[1]=saved[0].left[1];this.options.right[1]=saved[0].right[1];this.state.left.open=saved[1].left.open;this.state.right.open=saved[1].right.open}}catch(e){}}},{key:"savePanesState",value:function savePanesState(){try{localStorage[this.storage_key]=JSON.stringify([this.options,this.state])}catch(e){}}},{key:"showModalMenu",value:function showModalMenu(selector){var menu=$(selector);menu.show();menu.css("display");menu.addClass("open");$("body .modal-menu-mask").addClass("active");this.elements.content.find("textarea, input[type=text]").prop("disabled",true);if(!is_mobile_device.iOS()){setHistory({modal_menu:true},"","push")}}},{key:"hideModalMenu",value:function hideModalMenu(){$("body .modal-menu.open").removeClass("open").hide();$("body .modal-menu-mask").removeClass("active");$(".tap").removeClass("tap");this.elements.content.find("textarea, input[type=text]").prop("disabled",false);if(window.history&&window.history.state&&window.history.state.modal_menu){window.history.back()}}},{key:"bindModalMenu",value:function bindModalMenu(){var self=this;$("body .modal-menu-mask").on("click",(function(){self.hideModalMenu()}))}},{key:"showMenu",value:function showMenu(tab){this.mainMenuOpened=true;$("#main_menu").show();if(tab){tab===crowdin.helpers.main_menu.LANGUAGE_MENU?$("#main_menu .tab-content #menu-filter-languages").focus():$("#main_menu .tab-content .content").focus()}else{$("#main_menu .tab-content .content").focus()}$("#main_menu_mask").show()}},{key:"hideMenu",value:function hideMenu(){if(this.mainMenuOpened){this.mainMenuOpened=false;var editor=crowdin.editor;if(editor.file&&editor.target_language&&editor.isValidWorkflowStep()){$("#main_menu").hide();$("#main_menu_mask").hide();$(document).off(".main-menu")}}}}]);return editor_layout}(CrowdinComponent);
  