1"use strict";(self.webpackChunkug_react_i18n_es6=self.webpackChunkug_react_i18n_es6||[]).push([[3270],{95838:(e,t,s)=>{s.r(t),s.d(t,{default:()=>h});var i,n=s(31349),r=s(37489),o=s(17727),l=s(90575),a=s(5246);let h=(0,r.Z)(i=class extends l.Z{constructor(e,t){super(e),this.params=t,this.el_btn_cancel=(0,n.qs)(".js-cancel",e),this.$$container=(0,n.qs)(".form--body",e),this.props={},this.onInit().then((()=>{this.addEventListeners(),this.validate(this.rules)}))}addEventListeners(){super.addEventListeners(),this.el_btn_cancel.addEventListener("click",this.onCancel.bind(this)),this.on("startSubmit",this.onSubmit.bind(this))}onInit(){const e=this.params.content;return(0,a.$)((({renderForumEditor:t,bbCodeToHTML:s})=>{e&&(this.props.content=s(e)),this.editor=t(this.$$container,this.props)})).then((e=>{this.editorBundle=e}))}onCancel(){this.trigger("cancel")}onSubmit(e){e.preventDefault();const t=this.editorBundle.HTMLtoBbCode(this.editorBundle.covertEditorStateToHTML(this.editor.content,this.editorBundle.forumExportOptions)),s=this.removeFileIfEmpty(new FormData(this.el_form));s.append("text",t);const i=this.params.post_id;o.v("edit_post",s,{post_id:i}).then((e=>{this.trigger("successSubmit",e)})).catch((t=>{this.updateErrors([{message:t}],e)}))}get rules(){return[{name:"editor_size",rules:"required",display:"reply"}]}})||i},90575:(e,t,s)=>{s.d(t,{Z:()=>b});var i=s(31349),n=s(86155),r=s(56936),o=s(10444),l=s(81176),a=s(91218),h=s(19305),c=s(40416),d=s(13736),u=s(99514);const m=new DOMParser;function p(e){return function(e){let t=e.getElementsByTagName("cursor")[0];const s=[];for(;t&&"BODY"!==t.nodeName;)"CURSOR"!==t.nodeName&&s.unshift({name:t.nodeName,prop:t.getAttribute("data-prop")}),t=t.parentNode;return s}(function(e){const t=e.replaceAll("[","<").replaceAll("[","<").replaceAll("]",">");return m.parseFromString(t,"text/html")}(e))}var g,v=s(17727);let b=(0,u.Z)(g=class e extends n.Z{constructor(e){super(e),this.mention=null,this.needMention=!0,this.PREVIEW_CLASS="has_preview",this.el_container=e,this.el_editor=(0,i.qs)(".js-editor",e),this.el_content=(0,i.qs)(".js-content",e),this.el_preview=(0,i.qs)(".js-preview-container",e),this.el_btn_preview=(0,i.qs)(".js-preview",e),this.el_btn_edit=(0,i.qs)(".js-edit",e),this.el_more_smiles=(0,i.qs)(".js-more-smiles",e),this.el_more_smiles_toggle=(0,i.qs)(".js-more-smiles-toggle",e),this.el_toggle=(0,i.BI)(".js-toggle",e),this.el_actions=(0,i.BI)("[data-action]",e),this.el_selects=(0,i.BI)("[data-select]",e),this.el_btn_mention=(0,i.qs)(".b-editor--mention",e),this.init()}init(){new a.Z(this.el_more_smiles_toggle),this.initMention()}initMention(){if(this.needMention){this.el_btn_mention.classList.remove("hidden");const e=window.UGAPP.store.thread,t=new c.Z({type:"thread",id:null==e?void 0:e.id});this.mention=new o.Z(this.el_content,this.el_editor,t)}}requireMentions(){const e=this;Promise.resolve().then((()=>
1{if(!e.mention&&e.needMention){const t=s(10444).Z;e.mention=new t(e.el_content,e.el_editor)}}).bind(null,s)).catch(s.oe)}addEventListeners(){["focus","click","keyup"].map((e=>this.el_content.addEventListener(e,this.highlightControls.bind(this)))),this.el_content.addEventListener("blur",this.clearHighlightControls.bind(this)),this.el_content.addEventListener("keydown",this.onKeyDown.bind(this)),this.el_preview.addEventListener("click",e.onSpoilerContainerClick),this.el_actions.map((e=>e.addEventListener("click",(e=>this.onBbCode(e,"action"))))),this.el_selects.map((e=>e.addEventListener("change",(e=>this.onBbCode(e,"select"))))),this.el_toggle.map((e=>e.addEventListener("click",this.toggleControlsState.bind(this)))),this.el_btn_edit.addEventListener("click",this.hidePreview.bind(this)),this.el_btn_preview.addEventListener("click",this.onPreview.bind(this)),this.el_btn_mention.addEventListener("click",this.forceMention.bind(this))}forceMention(){let e="@";this.el_content!==document.activeElement&&this.el_content.focus();const t=this.el_content.value,s=this.el_content.selectionStart,i=t.charAt(s-1);" "!==i&&""!==i&&(e=" @"),(0,l.Z)(this.el_content,e),setTimeout((()=>{const e=new CustomEvent("keyup");e.keyCode=72;const t=new CustomEvent("keydown");t.keyCode=72,this.el_content.dispatchEvent(t),this.el_content.dispatchEvent(e)}),16)}onPreview(){v.v("post_html",{text:this.content}).then(this.showPreview.bind(this))}showPreview(e){const t=(0,r.Qk)(e.textHtml||"");this.el_preview.innerHTML=t,this.el_editor.classList.add(this.PREVIEW_CLASS),(0,d.H)(h.Ly)}hidePreview(){this.el_editor.classList.remove(this.PREVIEW_CLASS)}toggleControlsState(){this.el_editor.classList.contains("collapsed")&&(0,d.H)(h.qK),this.el_editor.classList.toggle("collapsed")}bbCodeStart(e,t){return"["+e.toUpperCase()+("string"==typeof t?"="+t:"")+"]"}bbCodeEnd(e){return"[/"+e.toUpperCase()+"]"}createListBody(e){return e.split("\n").reduce(((e,t)=>e+"[*]"+t+"\n"),"\n")}onBbCode(e,t){const s=e.currentTarget,i=s.getAttribute("data-"+t);let n=s.getAttribute("data-option");e.preventDefault(),e.stopPropagation(),"select"===t&&(n=s.options[s.selectedIndex].value),"smile"===i?this.insertSmile(s.getAttribute("data-smile")):this.insertBbCode(i,n),this.focus()}onKeyDown(e){const t=this.insertBbCodeFromKeyboard.bind(this,e);if(-1===navigator.appVersion.indexOf("Mac")?e.ctrlKey:e.metaKey){switch(e.keyCode){case 66:t("b");break;case 73:t("i");break;case 85:t("u");break;case 76:t("left");break;case 82:t("right");break;case 69:t("center");break;case 190:t("list");break;case 75:t("url");break;case 77:t("img")}e.shiftKey&&75===e.keyCode&&t("email")}}insertBbCodeFromKeyboard(e,t){e.preventDefault(),this.insertBbCode(t)}insertSmile(e){const t=this.el_content,s=this.content,i=s.substring(0,t.selectionStart)+e;this.content=i+s.substring(t.selectionEnd),this.setCursor(i.length)}insertBbCode(e,t,s=null,i=!1){const n=this.el_content,r=this.content;let o=s||this.activeText;("list"===e||"olist"===e)&&(o=this.createListBody(o));const l=r.substring(0,n.selectionStart)+this.bbCodeStart(e,t)+o;this.content=l+this.bbCodeEnd(e)+r.substring(n.selectionEnd),this.setCursor(i?this.content.length:l.length)}setCursor(e,t=e){this.el_content.setSelectionRange(e,t)}focus(){this.el_content.focus()}get activeText(){const e=this.el_content;return this.content.substring(e.selectionStart,e.selectionEnd)}get content(){return this.el_content.value}set content(e){this.el_content.value=e}get highlightedTags(){const e=this.el_content,t=this.content;return p(t.substring(0,e.selectionStart)+"<cursor>cursor</cursor>"+t.substring(e.selectionStart))}clearHighlightControls(){this.el_actions.forEach((e=>e.classList.remove("active"))),this.el_selects.forEach((e=>{e.querySelectorAll("option")[0].selected=!0}))}highlightControl(e){e.name=e.name.toLowerCase();const t=this.el_container.querySelector('[data-action="'+e.name+'"]');if(t&&t.classList.add("active"),e.prop){e.prop=e.prop.toLowerCase();(0,i.BI)('[data-select="'+e.name+'"] option',this.el_container).some((t=>t.value.toLowerCase().replaceAll(" ","")===e.prop&&(t.selected=!0,!0)))}}highlightControls(){setTimeout((()=>
1{this.clearHighlightControls(),this.highlightedTags.forEach(this.highlightControl.bind(this))}),0)}})||g},28296:(e,t,s)=>{s.r(t),s.d(t,{default:()=>c});var i,n=s(31349),r=s(86155),o=s(55026),l=s(17727),a=s(37489),h=s(5246);let c=(0,a.Z)(i=class extends r.Z{constructor(e,t){super(e),this.el_container=e,this.$$container=(0,n.qs)(".form--body",e),this.loadEditor(t).then((()=>{this.validate(this.rules),this.addEventListeners()}))}loadEditor(e){return(0,h.$)((({renderForumEditor:t})=>{this.editor=t(this.$$container,e)})).then((e=>{this.editorBundle=e}))}addEventListeners(){super.addEventListeners(),this.on("startSubmit",this.onSubmit.bind(this)),this.on("focus",this.onFocus.bind(this))}onFocus(e,t){if(t){const s=this.editorBundle.bbCodeToHTML(t);this.editor.insertQuote({name:e,text:'<blockquote class="RichEditor-blockquote"><b>Quote by '+e+"</b><br><div>"+s+"</div></blockquote>"})}else if(e){const t={name:e,link:(0,o.Z)(e)};this.editor.insertReply(t)}this.scrollToForm()}scrollToForm(){window.scrollTo(0,this.el_container.offsetTop)}onSubmit(e){e.preventDefault();const t=this.editorBundle.covertEditorStateToHTML(this.editor.content,this.editorBundle.forumExportOptions),s=this.editorBundle.HTMLtoBbCode(t),i=this.removeFileIfEmpty(new FormData(this.el_form));i.append("text",s),l.v("reply_post",i,{thread_id:UGAPP.store.thread.id}).then(this.onSubmitSuccess.bind(this)).catch((t=>this.updateErrors([{message:t}],e)))}onSubmitSuccess(e){setTimeout((()=>{location.href=e.link}),100)}get rules(){return[{name:"editor_size",rules:"required",display:"reply"}]}})||i},37489:(e,t,s)=>{s.d(t,{Z:()=>n});var i=s(31349);const n=e=>{e.prototype.fileEls=function(){return{clear:(0,i.qs)(".js-file-clear",this.el_form),file:(0,i.qs)(".js-file",this.el_form)}},e.prototype.fileClearToggle=function(){const e=this.fileEls().file.value;this.fileEls().clear.hidden=""===e},e.prototype.clearFile=function(){this.fileEls().file.value="",this.fileClearToggle()},e.prototype.addFileEventListeners=function(){this.fileEls().clear.addEventListener("click",this.clearFile.bind(this)),this.fileEls().file.addEventListener("change",this.fileClearToggle.bind(this)),this.fileClearToggle()},e.prototype.removeFileIfEmpty=function(e){const t=this.fileEls().file;if(t&&t.name){const s=t.name;e.get&&e.get(s)&&!e.get(s).size&&e.delete(s)}return e}}},5246:(e,t,s)=>{s.d(t,{$:()=>o});var i=s(98652),n=s(44895),r=s(40070);const o=async e=>{try{return await(0,n.Z)(i.Z.jsBundle["forum_editor.js"],{once:!0}),e(window.editor),window.editor}catch(e){return r.Z.error("Can't load draft editors bundle"),void r.Z.error(e)}}},86155:(e,t,s)=>{s.d(t,{Z:()=>o});var i=s(53665),n=s.n(i),r=s(31349);class o{constructor(e){this.ERROR_CLASS="has_error",this.SUCCESS_CLASS="success",n()(this),this.el_form=e,this.el_submit=(0,r.qs)('[type="submit"]',e),this.el_errors=(0,r.qs)(".js-validation",e),this.el_groups=(0,r.BI)(".form-group",e),this.el_inputs=(0,r.BI)("input,textarea,select",e),this.name=e.name,this.validator=null}addEventListeners(){this.el_inputs.map((e=>e.addEventListener("focus",this.clearErrors.bind(this))))}get customMessages(){return{required:"Please, fill in the %s field.",not_empty:"Please, fill in the %s field.",matches:"%ss fields does not match.",valid_email:"Seems like you entered an incorrect email.",alpha_dash:"Your %s must include at least one number, one capital letter, one lowercase letter, plus either an underscore ('_') or a dash ('-')",check_multivariant:"Please add more then 1 variant in %s field",check_http_images:'Only "https" links are allowed for pictures, otherwise they won\'t appear'}}disableSubmit(){this.el_submit.setAttribute("disabled","disabled")}enableSubmit(){this.el_submit.removeAttribute("disabled")}validate(e){s.e(1665).then(s.t.bind(s,44025,23)).then((t=>{const s=t.default||t;this.validator=new s(this.name,e,this.updateErrors.bind(this)),this.setCustomValidationCallbacks(),Object.keys(this.customMessages).map((e=>{this.validator.setMessage(e,this.customMessages[e])}))}))}setCustomValidationCallbacks(){this.validator.registerCallback("check_multivariant",(e=>1<e.split("\n").filter((e=>!!e.trim())).length)),this.validator.registerCallback("not_empty",(e=>0<e.trim().length)),this.validator.registerCallback("check_http_images",(e=>!(e.match(/(.*?)[^w{3}.]([a-zA-Z0-9]([a-zA-Z0-9-]{0,65}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}/gim)&&e.match(/\.(jpg|gif|jpeg|png|bmp)$/gi)&&e.match(/^http:\/\//gi))))}updateErrors(e,t){return this.clearErrors(),this.disableSubmit(),e.length?(t.preventDefault(),e.forEach(this.highlightError.bind(this)),this.enableSubmit(),!1):void this.trigger("startSubmit",t)}static covertErrorData(e){if("string"==typeof e)return[{message:e}];const t=Object.keys(e);return t.length?t.map((t=>({name:t,message:e[t].join("/n")}))):[{name:"server",message:"Server internal error"}]}clearErrors(){this.el_groups.map((e=>e.classList.remove(this.ERROR_CLASS))),this.el_errors.innerHTML=""}addMessage(e){const t=document.createElement("li");t.innerHTML=e,this.el_errors.appendChild(t)}highlightError(e){const t=e.name,s=e.message;if(t)try{this.el_form[t].parentNode.classList.add(this.ERROR_CLASS)}catch(e){}this.el_errors.classList.contains(this.SUCCESS_CLASS)&&this.el_errors.classList.remove(this.SUCCESS_CLASS),this.addMessage(s)}highlightSuccess(e){this.addMessage(e),this.el_errors.classList.add(this.SUCCESS_CLASS)}}},81176:(e,t,s)=>{function i(e,t){if(e){var s=e.scrollTop,i=0,n=e.selectionStart||"0"==e.selectionStart?"ff":!!document.selection&&"ie";if("ie"==n){e.focus();var r=document.selection.createRange();r.moveStart("character",-e.value.length),i=r.text.length}else"ff"==n&&(i=e.selectionStart);var o=e.value.substring(0,i),l=e.value.substring(i,e.value.length);if(e.value=o+t+l,i+=t.length,"ie"==n){e.focus();var a=document.selection.createRange();a.moveStart("character",-e.value.length),a.moveStart("character",i),a.moveEnd("character",0),a.select()}else"ff"==n&&(e.selectionStart=i,e.selectionEnd=i,e.focus());e.scrollTop=s}}s.d(t,{Z:()=>i})},10444:(e,t,s)=>{s.d(t,{Z:()=>i});class i{constructor(e,t,s){this.noResults=!1,this.isActive=!1,this.autocomplete={},this.$$input=e,this.$$slot=t,this.mentionService=s,this.init(),this.addEventListeners()}init(){s.e(5366).then(s.bind(s,56175)).then((e=>
1{this.autocomplete=new e.default({menuContainer:this.$$slot,selectTemplate:e=>this.onInsertUserBBCode(e.original.value),values:this.onSearch.bind(this),lookup:"value",allowSpaces:!0}),this.autocomplete.attach(this.$$input)})).catch((e=>{}))}addEventListeners(){this.$$input.addEventListener("keydown",this.onKeyDown.bind(this))}onKeyDown(){this.isActive=this.autocomplete.isActive}onInsertUserBBCode(e){return this.mentionService.saveOne(e),"[USER]"+e+"[/USER]"}onSearch(e,t){const s=this.mentionService.findByUsername(e),i=s.results,n=s.promise,r=e=>e.map((e=>({value:e})));e||t(r(i)),n.then((e=>r(e))).then(t),this.isActive||!this.autocomplete.isActive||this.noResults||e||(this.noResults=!0,this.isActive=!0)}}},40416:(e,t,s)=>{s.d(t,{Z:()=>a});var i=s(40311),n=s(98652),r=s(49685);const o=(e,t)=>e.filter((e=>!e.toLowerCase().indexOf(t.toLowerCase()))),l={maxStoreLength:1e3,get localKey(){return"ug_mention_ver2_"+n.Z.user.id},get data(){return r.Z.get(this.localKey)||[]},set data(e){r.Z.set(this.localKey,e)},saveOne(e){const t=this.data.filter((t=>t!==e));this.data=[...t,e].splice(-this.maxStoreLength)}};class a{constructor({type:e,id:t,maxViewableResults:s=5,store:i=l,endpoint:n="/user/autocomplete/get/"}){this.hasUsersAndFriends=!1,this.type=e,this.id=t,this.maxViewableResults=s,this.store=i,this.endpoint=n,this.results=i.data}saveOne(e){this.store.saveOne(e)}getFirstResults(e){return(t=e,t.filter(((e,t,s)=>s.findIndex((t=>e===t))===t))).filter(((e,t)=>t<this.maxViewableResults));var t}getUsersByText(e){return i.Z.get({url:this.endpoint,payload:{q:e}}).then((({all:t})=>(this.results=[...this.results,...t||[]],o(this.results,e))))}getNodeUsersAndFriends(){if(this.hasUsersAndFriends)return Promise.resolve(this.hasUsersAndFriends);const e=this.id?{o:this.type+":"+this.id}:{};return i.Z.get({url:this.endpoint,payload:e}).then((({node:e,friends:t})=>(this.results=[...this.results,...e,...t],this.hasUsersAndFriends=!0,this.results)))}findByUsername(e){const t=e?o(this.results,e):this.results;return{results:this.getFirstResults(t),promise:(e?this.getUsersByText(e):this.getNodeUsersAndFriends()).then((e=>this.getFirstResults(e)))}}}}}]); 2//# sourceMappingURL=/static/public/build/ug_react_i18n_es6/../../sourcemap/ug_react_i18n_es6/202609/3270.d2bd6fea61b7679ef7009dc268b0c868.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.