(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,961572,(e,t,s)=>{var a=e.r(758629),i=e.r(268829),o=e.r(713266),n=e.r(448684),r=e.r(379858),h=e.r(613272),c=e.r(734274),d=e.r(75299),l=Object.prototype.hasOwnProperty;t.exports=function(e){if(null==e)return!0;if(r(e)&&(n(e)||"string"==typeof e||"function"==typeof e.splice||h(e)||d(e)||o(e)))return!e.length;var t=i(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(c(e))return!a(e).length;for(var s in e)if(l.call(e,s))return!1;return!0}},193432,943029,805513,e=>{"use strict";let t,s=Object.freeze({TAG:"tag",TAG_SEARCH:"tag-search",FEED:"feed",GRAPHFEED:"graph-feed",PROFILE:"profile",FORUM:"forum",COMMUNITY:"community",FACT:"fact",FACT_USER:"fact_user"});e.s(["f",0,s],193432);var a,i=e.i(391398),o=e.i(145246),n=e.i(191788);e.i(966278);var r=e.i(318398),h=e.i(455404),c=e.i(961572),d=e.i(949125),l=e.i(131254),f=e.i(705004);let m=new String(".end-of-page.jsx-cf87d0f085393ae9{text-align:center;color:var(--text-light-2);margin-top:20px}");m.__hash="cf87d0f085393ae9";let x=e=>{let{text:t="--- Hết nội dung ---"}=e;return(0,i.jsxs)("div",{className:"jsx-".concat(m.__hash)+" end-of-page",children:[(0,i.jsx)("span",{className:"jsx-".concat(m.__hash),children:t}),(0,i.jsx)(o.default,{id:m.__hash,children:m})]})};e.s(["f",0,x],943029);var p=e.i(318892),u=e.i(395659),g=e.i(174659),j=e.i(910474),b=e.i(58026);let _=new String(".recommended-channels.jsx-fd5ea811fd11fa8f .channels.jsx-fd5ea811fd11fa8f{flex-wrap:wrap;justify-content:space-between;display:flex}.item.jsx-fd5ea811fd11fa8f{width:100%;margin:8px 0;display:flex}@media (min-width:576px){.item.jsx-fd5ea811fd11fa8f{width:48%}}.item.jsx-fd5ea811fd11fa8f:last-child{margin-bottom:0}.item.jsx-fd5ea811fd11fa8f .title.jsx-fd5ea811fd11fa8f{font-size:14px;font-weight:700}.item.jsx-fd5ea811fd11fa8f .title.jsx-fd5ea811fd11fa8f:hover{color:var(--color-accent-dark)}.item.jsx-fd5ea811fd11fa8f .sub-title.jsx-fd5ea811fd11fa8f{margin:6px 0;font-weight:700}.item.jsx-fd5ea811fd11fa8f .description.jsx-fd5ea811fd11fa8f{color:var(--color-light-action-box-text)}.thumbnail.jsx-fd5ea811fd11fa8f{width:85px;margin-right:15px}.text.jsx-fd5ea811fd11fa8f{flex:1 1 0}");_.__hash="fd5ea811fd11fa8f";let v=[{id:1,title:"Video Tinh tế",description:"Các video review sản phẩm, hướng dẫn, kinh nghiệm",thumbnail:b.default,link:"https://youtube.com/tinhte"},{id:2,title:"Xe Tinh tế",description:"Thông tin, thủ thuật, mẹo mặt về xe máy, xe hơi",thumbnail:j.default,link:"https://tinhte.vn/xe"},{id:3,title:"Camera Tinh tế",description:"Camera và camera phone, vào đây hết nhé anh em",thumbnail:g.default,link:"https://tinhte.vn/camera"},{id:4,title:"Audio Tinh tế",description:"Âm nhạc, tai nghe, loa và mọi thứ về âm thanh",thumbnail:u.default,link:"https://tinhte.vn/audio"}],y=r.f.ApiConsumer(e=>{let{channels:t=v}=e;return(0,i.jsxs)("div",{className:"jsx-".concat(_.__hash)+" recommended-channels",children:[(0,i.jsx)("h2",{className:"jsx-".concat(_.__hash)+" section-heading",children:"Các kênh thú vị khác"}),(0,i.jsx)("div",{className:"jsx-".concat(_.__hash)+" channels",children:t.map(e=>(0,i.jsxs)("a",{href:e.link,className:"jsx-".concat(_.__hash)+" item",children:[(0,i.jsx)("div",{className:"jsx-".concat(_.__hash)+" thumbnail",children:(0,i.jsx)("img",{src:e.thumbnail,alt:e.title,className:"jsx-".concat(_.__hash)})}),(0,i.jsxs)("div",{className:"jsx-".concat(_.__hash)+" text",children:[(0,i.jsx)("div",{className:"jsx-".concat(_.__hash)+" title",children:e.title}),(0,i.jsx)("div",{className:"jsx-".concat(_.__hash)+" sub-title",children:e.subTitle}),(0,i.jsx)("div",{className:"jsx-".concat(_.__hash)+" description",children:e.description})]})]},e.id))}),(0,i.jsx)(o.default,{id:_.__hash,children:_})]})});var k=e.i(724383),w=e.i(377330),T=e.i(962525),N=e.i(565715),S=e.i(913083),P=n,C=e.i(730943),I=e.i(827808),F=e.i(661655),R=e.i(199184),A=e.i(769907);function M(){return(M=Object.assign.bind()).apply(null,arguments)}let D=e=>n.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:19,height:18,viewBox:"0 0 19 18"},e),a||(a=n.createElement("path",{fill:"#4B4F56",fillRule:"evenodd",d:"M9.03 0C4.033 0 0 4.02 0 9s4.033 9 9.03 9 9.03-4.02 9.03-9-4.033-9-9.03-9m2.974 5a1 1 0 1 1 0 2A1 1 0 0 1 11 6c-.017-.553.448-1 1.004-1m1.688 8h-9.34c-.27 0-.434-.254-.31-.487l3.347-6.338c.124-.233.496-.233.62 0L9.993 9.92c.124.233.496.233.62 0l.682-1.287c.124-.234.496-.234.62 0l2.087 3.88a.343.343 0 0 1-.31.488"}))),U=new String('.thread-form.jsx-2df470b33f5b5e8a{border:1px solid var(--color-light-1);border-radius:3px;overflow:hidden}.thread-form-actions.jsx-2df470b33f5b5e8a{background-color:var(--color-fill-1)}.thread-form-action.jsx-2df470b33f5b5e8a{color:var(--color-accent-dark);cursor:pointer;vertical-align:middle;padding:12px;font-weight:700}.thread-form-action.jsx-2df470b33f5b5e8a>span.jsx-2df470b33f5b5e8a{vertical-align:middle;display:inline-block}.thread-form-action.jsx-2df470b33f5b5e8a .action-label.jsx-2df470b33f5b5e8a{color:var(--color-dark-0);margin-right:5px}.thread-form-body.jsx-2df470b33f5b5e8a{box-sizing:border-box;background-color:#fff;border-top:1px solid #e2e2e2;padding:11px;position:relative}.thread-form-body.jsx-2df470b33f5b5e8a:before{content:"";border-bottom:8px solid #e2e2e2;border-left:6px solid #0000;border-right:6px solid #0000;width:0;height:0;position:absolute;top:-8px;left:55px;overflow:visible}.thread-form-body.jsx-2df470b33f5b5e8a:after{content:"";border-bottom:7px solid #fff;border-left:5px solid #0000;border-right:5px solid #0000;width:0;height:0;position:absolute;top:-7px;left:56px;overflow:visible}@media only screen and (max-width:63.99em){.thread-form-body.jsx-2df470b33f5b5e8a:before{left:28.5px}.thread-form-body.jsx-2df470b33f5b5e8a:after{left:29.5px}}.thread-form-content-container.jsx-2df470b33f5b5e8a{flex:1}.thread-form-content-container.jsx-2df470b33f5b5e8a textarea{box-sizing:border-box;resize:none;width:100%;min-height:40px;box-shadow:none;background:0 0;border:none;outline:none;padding:12px 0;font-size:16px;line-height:1.5;transition:min-height .3s ease-in-out;overflow:hidden}.thread-form-content-container.jsx-2df470b33f5b5e8a input[type=checkbox]{-webkit-appearance:checkbox;-moz-appearance:checkbox;appearance:checkbox}.thread-form-avatar.jsx-2df470b33f5b5e8a{width:40px;margin-right:13px}.thread-form-avatar.jsx-2df470b33f5b5e8a img.jsx-2df470b33f5b5e8a{background-color:#aaa;border-radius:50%;width:100%;display:block;overflow:hidden}.thread-form-author.jsx-2df470b33f5b5e8a{display:none}.thread-form-footer.jsx-2df470b33f5b5e8a{box-sizing:border-box;background-color:#fff;border-top:1px solid #e2e2e2;width:100%;padding:9px 11px 11px;display:none}.thread-form-submit.jsx-2df470b33f5b5e8a{color:var(--color-light-0);cursor:pointer;text-transform:uppercase;background-color:var(--color-accent-dark);border-radius:4px;margin-left:12px;padding:7px 15px;font-size:14px;font-weight:700}.thread-form-error.jsx-2df470b33f5b5e8a{color:red;font-size:12px}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-author.jsx-2df470b33f5b5e8a{font-size:14px;font-weight:700;display:block}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-content.jsx-2df470b33f5b5e8a{min-height:80px;padding-top:5px}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-footer.jsx-2df470b33f5b5e8a{align-items:center;display:flex}.thread-form-cancel.jsx-2df470b33f5b5e8a{color:#757575;cursor:pointer;font-size:14px}.post-to-forum.jsx-2df470b33f5b5e8a{margin-left:5px}.post-to-forum.jsx-2df470b33f5b5e8a:hover{cursor:pointer}@media only screen and (min-width:64em){.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-actions.jsx-2df470b33f5b5e8a,.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-body.jsx-2df470b33f5b5e8a,.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-footer.jsx-2df470b33f5b5e8a{z-index:9999}.thread-form-bg.jsx-2df470b33f5b5e8a{content:"";opacity:0;z-index:200;pointer-events:none;background-color:#000;transition:all .3s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-bg.jsx-2df470b33f5b5e8a{opacity:.5;pointer-events:all}.thread-form-cancel.jsx-2df470b33f5b5e8a{display:none}}.thread-form-pic.jsx-2df470b33f5b5e8a{display:none}@media only screen and (max-width:63.99em){.thread-form.jsx-2df470b33f5b5e8a{margin-top:-1px}.thread-form.jsx-2df470b33f5b5e8a:not(.focused){border:none}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-actions.jsx-2df470b33f5b5e8a{display:none}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-body.jsx-2df470b33f5b5e8a{border-radius:3px;margin-top:8px;padding:5px 11px}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-pic.jsx-2df470b33f5b5e8a{color:#757575;align-items:center;padding:0 5px;display:flex}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-pic.jsx-2df470b33f5b5e8a i.jsx-2df470b33f5b5e8a{margin-bottom:4px}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-avatar.jsx-2df470b33f5b5e8a{align-items:center;padding-bottom:5px;display:flex}}');U.__hash="2df470b33f5b5e8a";class E extends P.Component{componentDidMount(){let{id:e,edittingThread:t}=this.props;if(this.setState({forum_id:e}),t){let e=[];t.firstPost.attachments&&(e=t.firstPost.attachments.map(e=>({image:e.links.thumbnail||e.links.permalink,attachment_id:e.attachment_id}))),this.setState({focused:!0,content:t.firstPost.postBody,post_id:t.firstPostId,files:e},()=>{C.default.findDOMNode(this.contentTextarea).value=this.state.content})}}componentDidUpdate(e){let{subForums:t}=this.props;t!==e.subForums&&t.length>0&&this.setState({forum_id:t[0].id})}onBackgroundClick(){this.state.post_id||this.blur()}onSizeTypeChanged(e){this.setState({fullsizeImage:e})}onNewImages(e){this.setState({files:this.state.files.concat(e)})}removeFile(e){let{files:t}=this.state;t[e].shouldUpload?t[e].shouldUpload=!1:t[e].shoudDelete=!0,this.setState({})}showFilePicker(){this.focus(),this.imagePicker.show()}blur(){this.setState({focused:!1}),this.props.onBlur&&this.props.onBlur()}focus(){this.setState({focused:!0}),C.default.findDOMNode(this.contentTextarea).focus()}changeForumToPost(e){let{subForums:t}=this.props,{target:{value:s}}=e,a=t.find(e=>e.id===parseInt(s,10));this.setState({forum_id:parseInt(s,10),forum_title:a.title})}submitPromise(e){return this.state.post_id?this.submitEditPost():this.submitThread(e,this.state.content,this.state.thread_id,this.state.post_id,this.state.files,this.state.fullsizeImage)}prepareThreadToSubmit(){if(this.state.loading)return;if(this.setState({loading:!0,error:""}),!this.state.content)return void this.setState({loading:!1,error:"Vui lòng không để nội dung trống"});let e=this.state.content.split("\n")[0];if(e.length>100){for((e=e.slice(0,100).split(/ /)).pop();e.join(" ").length>97;)e.pop();e="".concat(e.join(" "),"...")}this.submitPromise(e).then(e=>{if(this.state.post_id){let t={...this.props.edittingThread};this.props.edittingThread.firstPost=(0,F.U)(e,t)}this.resetForm()}).catch(e=>{this.setState({error:e,loading:!1})})}async submitThread(e,t,s,a,i,o){let n=new A.f(this.props.api),r=this.state.forum_id,h=null;try{return h=await n.uploadAttachments(i,s,a,r,o),this.props.api.post({uri:"threads",params:{forum_id:r,thread_title:e,post_body:t}}).catch(e=>{console.log(e),h&&n.deleteAttachments(h,r),this.setState({error:e.toString()})}).then(e=>{if(e.errors)h&&n.deleteAttachments(h,r),this.setState({error:e.errors.toString()});else{let{forum_title:t}=this.state,s={...e.thread,forum:{forum_title:t,forum_id:e.thread.forum_id}};this.props.newThread(s)}})}catch(e){h&&n.deleteAttachments(h,r),this.setState({error:e.toString()})}return!1}submitEditPost(){let e={thread_id:this.state.thread_id,post_body:this.state.content};return this.props.api.put({uri:"posts/".concat(this.state.post_id),params:e}).then(e=>{let{post:t,errors:s}=e;if(s)throw Error(s.toString());return t}).catch(e=>{throw console.log(e),Error(e.toString())})}resetForm(){this.setState({focused:!1,loading:!1,content:"",files:[]}),C.default.findDOMNode(this.contentTextarea).value="",this.blur()}render(){let{user:e,subForums:t}=this.props,{focused:s,post_id:a,content:n,files:r,error:h}=this.state;return(0,i.jsxs)("div",{ref:e=>{this.threadForm=e},onFocus:()=>{this.setState({focused:!0})},className:"jsx-".concat(U.__hash)+" "+"thread-form ".concat(s?" focused":""),children:[(0,i.jsx)("div",{onClick:this.onBackgroundClick,onKeyDown:this.onBackgroundClick,className:"jsx-".concat(U.__hash)+" thread-form-bg"}),(0,i.jsxs)("div",{className:"jsx-".concat(U.__hash)+" thread-form-actions box",children:[(0,i.jsx)("div",{onClick:this.focus,onKeyDown:this.focus,className:"jsx-".concat(U.__hash)+" thread-form-action",children:(0,i.jsx)("span",{className:"jsx-".concat(U.__hash),children:a?"Sửa bài viết":"Tạo câu hỏi/ bài viết"})}),(0,i.jsxs)("div",{onClick:this.showFilePicker,onKeyDown:this.showFilePicker,className:"jsx-".concat(U.__hash)+" thread-form-action",children:[(0,i.jsx)("span",{className:"jsx-".concat(U.__hash)+" action-label",children:(0,i.jsx)(D,{})}),(0,i.jsx)("span",{className:"jsx-".concat(U.__hash),children:"Thêm ảnh"})]}),t.length>0&&(0,i.jsxs)("div",{className:"jsx-".concat(U.__hash)+" thread-form-action",children:[(0,i.jsx)("span",{className:"jsx-".concat(U.__hash)+" action-label",children:"Trong:"}),(0,i.jsx)("select",{onChange:this.changeForumToPost,className:"jsx-".concat(U.__hash)+" post-to-forum",children:t.map(e=>(0,i.jsx)("option",{value:e.id,className:"jsx-".concat(U.__hash),children:e.title},e.id))})]})]}),(0,i.jsxs)("div",{className:"jsx-".concat(U.__hash)+" thread-form-body box",children:[e?(0,i.jsx)("div",{className:"jsx-".concat(U.__hash)+" thread-form-avatar",children:(0,i.jsx)("img",{alt:e.name,src:e.avatar,className:"jsx-".concat(U.__hash)})}):(0,i.jsx)("div",{className:"jsx-".concat(U.__hash)}),(0,i.jsxs)("div",{className:"jsx-".concat(U.__hash)+" thread-form-content-container",children:[(0,i.jsx)("div",{className:"jsx-".concat(U.__hash)+" thread-form-author",children:e?e.name:""}),(0,i.jsx)(I.f,{placeholder:"Bạn có muốn hỏi hay chia sẻ gì không"+(e?", ".concat(e.name,"?"):"?"),ref:e=>{this.contentTextarea=e},defaultValue:n,onChange:e=>{this.setState({content:e.target.value})}}),(0,i.jsx)(R.f,{files:r,ref:e=>{this.imagePicker=e},onSizeTypeChanged:this.onSizeTypeChanged,onNewImages:this.onNewImages,removeFile:this.removeFile})]}),(0,i.jsx)("div",{onClick:this.showFilePicker,onKeyDown:this.showFilePicker,className:"jsx-".concat(U.__hash)+" thread-form-pic",children:(0,i.jsx)("i",{"aria-hidden":"true",className:"jsx-".concat(U.__hash)+" fa fa-picture-o"})})]}),(0,i.jsxs)("div",{className:"jsx-".concat(U.__hash)+" thread-form-footer box middle-xs",children:[(0,i.jsx)("div",{style:a?{display:"block"}:{},onClick:this.blur,onKeyDown:this.blur,className:"jsx-".concat(U.__hash)+" thread-form-cancel",children:"Huỷ"}),(0,i.jsx)("div",{style:{flex:1},className:"jsx-".concat(U.__hash)}),(0,i.jsx)("div",{className:"jsx-".concat(U.__hash)+" thread-form-error",children:h}),(0,i.jsx)("div",{onClick:this.prepareThreadToSubmit,onKeyDown:this.prepareThreadToSubmit,className:"jsx-".concat(U.__hash)+" thread-form-submit",children:a?"Lưu":"Đăng"})]}),(0,i.jsx)(o.default,{id:U.__hash,children:U})]})}constructor(e){super(e),this.state={files:[],content:"",focused:!1,loading:!1,thread_id:null,post_id:null,error:"",fullsizeImage:!1,forum_id:null,forum_title:""},this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.showFilePicker=this.showFilePicker.bind(this),this.onNewImages=this.onNewImages.bind(this),this.onSizeTypeChanged=this.onSizeTypeChanged.bind(this),this.prepareThreadToSubmit=this.prepareThreadToSubmit.bind(this),this.resetForm=this.resetForm.bind(this),this.onBackgroundClick=this.onBackgroundClick.bind(this),this.changeForumToPost=this.changeForumToPost.bind(this),this.removeFile=this.removeFile.bind(this)}}E.defaultProps={subForums:[]},E.apiFetchesWithAuth={user:{uri:"users/me",success:e=>(0,N.U)(e.user||{}),error:()=>{}}};let z=r.f.ApiConsumer(E);var B=e.i(363872),L=e.i(203828),O=n,H=e.i(886328),V=e.i(770267),K=e.i(437994),X=e.i(612683),q=e.i(693084),G=e.i(241427),W=e.i(310717),Y=e.i(490839),$=e.i(535044),J=e.i(867507),Q=e.i(618488),Z=e.i(723661),ee=e.i(501584),et=e.i(634529),es=e.i(566573),ea=e.i(6788),ei=e.i(298299),eo=e.i(532123),en=e.i(588076),er=e.i(574186),eh=e.i(659497),ec=e.i(456310),ed=e.i(94432);let el=n.default.createContext("thread_self_session"),ef=async(e,t)=>{let{stats:s}=t,a=!t.isLiked;return await e[a?"post":"del"]({uri:"/posts/".concat(t.id,"/likes")}),{...t,isLiked:a,stats:{...s,like:s.like+(a?1:-1)}}};var em=n,ex=e.i(659967),ep=e.i(34026);let eu=e=>new Promise(t=>{let s=new window.Image;s.onload=()=>{t(s)},s.src=e});var eg=n;let ej=new String(".loading-spinner.jsx-a969af87b94bc3ad{color:var(--color-accent-dark);opacity:.7;justify-content:center;align-items:center;font-size:50px;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}");ej.__hash="a969af87b94bc3ad";class eb extends eg.default.Component{UNSAFE_componentWillMount(){this.loadAttachmentImage()}async loadAttachmentImage(){let{attachment:e,onImageLoaded:t}=this.props,s=await eu(e.links.permalink);t&&t(s),this.setState({loaded:!0})}render(){let{attachment:e}=this.props,{loaded:t}=this.state,s=e.links.thumbnail?e.links.permalink:"";return(0,i.jsxs)("div",{style:{backgroundImage:"url(".concat(s||ep.default,")")},className:"jsx-".concat(ej.__hash)+" image",children:[!t&&(0,i.jsx)("span",{className:"jsx-".concat(ej.__hash)+" loading-spinner",children:(0,i.jsx)("i",{className:"jsx-".concat(ej.__hash)+" fas fa-circle-notch fa-spin"})}),!s&&(0,i.jsx)("span",{className:"jsx-".concat(ej.__hash)+" no-thumb-hint",children:"Nhấn để xem ảnh gốc"}),(0,i.jsx)(o.default,{id:ej.__hash,children:ej})]})}constructor(e){super(e),this.state={loaded:!1}}}let e_=new String(".image-masonry.jsx-c7a5230df8c34e05{flex-wrap:wrap;margin-left:-2.5px;margin-right:-2.5px;display:flex}.image-masonry.jsx-c7a5230df8c34e05 .image{cursor:pointer;background-position:50%;background-repeat:no-repeat;background-size:cover;padding-top:100%;position:relative}.image-masonry.jsx-c7a5230df8c34e05 .no-thumb-hint{text-align:center;justify-content:center;align-items:flex-end;padding:3px;font-size:12px;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.image-masonry.jsx-c7a5230df8c34e05 .image-wrapper.jsx-c7a5230df8c34e05{width:100%}.image-masonry.jsx-c7a5230df8c34e05 .single-tile.jsx-c7a5230df8c34e05{cursor:pointer;padding:2.5px;position:relative}.image-masonry.jsx-c7a5230df8c34e05 .single-tile.jsx-c7a5230df8c34e05 .image{border-top:1px solid var(--border-light);border-bottom:1px solid var(--border-light);padding-top:56.25%}.image-masonry.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05{box-sizing:border-box;width:33.3%;padding:2.5px;position:relative}.image-masonry.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05 .more.jsx-c7a5230df8c34e05{color:#fff;pointer-events:none;background:#00000073;justify-content:center;align-items:center;font-size:36px;font-weight:700;display:flex;position:absolute;top:2.5px;bottom:2.5px;left:2.5px;right:2.5px}.image-masonry.big-top.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05:first-child,.image-masonry.big-top.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05:nth-child(2){width:50%}.image-masonry.single-row.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05{flex:1;width:auto}img.single-img{border-top:1px solid var(--border-light);border-bottom:1px solid var(--border-light)}");e_.__hash="c7a5230df8c34e05";class ev extends em.default.Component{componentDidMount(){this.preprocessAttachments(this.props.attachments)}onAttachmentClick(e){return()=>{this.props.onAttachmentClick(e)}}onImageLoaded(e){this.setState({loadedImageHash:{...this.state.loadedImageHash,[e.attachment_id]:!0}},this.checkAllImagesLoaded)}checkAllImagesLoaded(){let{onAllImagesLoaded:e}=this.props;if(!e)return;let{loadedImageHash:t,imageAttachments:s}=this.state;s.every(e=>t[e.attachment_id])&&e()}preprocessAttachments(e){if(!e)return;let t=/\.(jpg|gif|png|jpeg|bmp|tiff)$/i,s=[],a=[];e.forEach(e=>{t.test(e.filename)?s.push(e):a.push(e)}),this.checkSingleTile(s),this.setState({imageAttachments:s,nonImageAttachments:a,loadedImageHash:{}})}checkSingleTile(e){let t=null,s=null;if(!e)return;let a=e.filter(e=>!e.attachment_is_inserted);1===a.length&&([t]=a,s=e.findIndex(e=>e===t),this.loadSingleImageAttachment(t)),this.setState({singleTile:t,singleTileIndex:s})}async loadSingleImageAttachment(e){let t=await eu(e.links.permalink),s=t.height/t.width>=1;this.setState({shouldCropSingleTile:s}),this.onImageLoaded(e)}renderTile(e){return(0,i.jsx)(eb,{attachment:e,onImageLoaded:()=>{this.onImageLoaded(e)}})}renderSingleTile(e,t){let{loadedImageHash:s}=this.state,a=s[e.attachment_id],n=null;return n=e.links.thumbnail?a?this.state.shouldCropSingleTile?this.renderTile(e):(0,i.jsx)("img",{className:"full-width single-img",src:e.links.permalink,alt:e.filename,title:e.filename,onLoad:()=>this.onImageLoaded(e)}):(0,i.jsxs)("div",{children:["Đang tải ảnh...",(0,i.jsx)(ex.f,{busy:!0,color:"var(--color-accent-dark)"})]}):(0,i.jsxs)("div",{children:[(0,i.jsx)("img",{className:"full-width single-img",src:ep.default,alt:e.filename}),(0,i.jsx)("span",{className:"no-thumb-hint",children:"Nhấn để xem ảnh gốc"})]}),(0,i.jsxs)("button",{onClick:this.onAttachmentClick(t),className:"jsx-".concat(e_.__hash)+" single-tile image-wrapper",children:[n,(0,i.jsx)(o.default,{id:e_.__hash,children:e_})]})}renderTiles(e,t){let s=0;return e.map((a,n)=>a.attachment_is_inserted||s>=t?null:(s+=1,(0,i.jsxs)("button",{onClick:this.onAttachmentClick(n),className:"jsx-".concat(e_.__hash)+" image-tile",children:[this.renderTile(a),s===t&&e.length>t&&(0,i.jsxs)("span",{className:"jsx-".concat(e_.__hash)+" more",children:["+",e.length-t]}),(0,i.jsx)(o.default,{id:e_.__hash,children:e_})]},a.attachment_id)))}render(){let{singleRow:e}=this.props,{imageAttachments:t,nonImageAttachments:s,singleTile:a,singleTileIndex:n}=this.state,r=this.props.maxSize||5,h="";return e?h="single-row":(2===t.length||t.length>3)&&(h="big-top"),(0,i.jsxs)(em.Fragment,{children:[s.length>0&&(0,i.jsx)("div",{style:{padding:12},className:"jsx-".concat(e_.__hash),children:s.map(e=>(0,i.jsx)("div",{className:"jsx-".concat(e_.__hash),children:(0,i.jsxs)("a",{href:e.links.permalink,style:{color:"var(--color-link)"},className:"jsx-".concat(e_.__hash),children:[(0,i.jsx)("i",{style:{marginRight:4},className:"jsx-".concat(e_.__hash)+" far fa-file"}),e.filename]})},e.attachment_id))}),(0,i.jsx)("div",{className:"jsx-".concat(e_.__hash)+" "+"image-masonry ".concat(h),children:a?this.renderSingleTile(a,n):this.renderTiles(t,r)}),(0,i.jsx)(o.default,{id:e_.__hash,children:e_})]})}constructor(e){super(e),this.state={shouldCropSingleTile:null,imageAttachments:[],nonImageAttachments:[],loadedImageHash:{}}}}var ey=e.i(281312),ek=e.i(158586);e.i(189500);let ew="/feature-pages/threads/sticky",eT=(0,H.default)(e=>{let{innerRef:t}=e;return(0,i.jsx)("div",{className:"mark-read-marker",ref:t})}),eN={content:{border:"none",backgroundColor:"var(--post-background)",maxWidth:"600px",width:"95%",top:"20%",left:"50%",right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"}};class eS extends O.default.Component{componentDidMount(){if(this.threadBody){let{clientHeight:e}=this.threadBody;this.setState({threadHeight:e})}}onReact(e,t,s){let{totalReaction:a}=this.state,i={...this.state.thread};e===ed.U.Up&&(a=this.state.totalReaction+1,i.firstPost.reaction.postReactions[t]=i.firstPost.reaction.postReactions[t]+1,i.firstPost.reaction.userReactionId=t),e===ed.U.Down&&(a=this.state.totalReaction-1,i.firstPost.reaction.postReactions[s]=i.firstPost.reaction.postReactions[s]-1,i.firstPost.reaction.userReactionId=null),e===ed.U.Neutral&&(i.firstPost.reaction.postReactions[s]=i.firstPost.reaction.postReactions[s]-1,i.firstPost.reaction.postReactions[t]=i.firstPost.reaction.postReactions[t]+1,i.firstPost.reaction.userReactionId=t),this.setState({totalReaction:a,thread:{...i,firstPost:{...i.firstPost}}})}async toggleLikeThread(){let{api:e}=this.props,{thread:t}=this.state;try{let s=await ef(e,t.firstPost);t={...t,firstPost:s},this.setState({thread:t})}catch(t){let{message:e}=(0,es.f)(t);h.c.error(e)}}focusPostReply(){this.postReply&&this.postReply.focus()}addPost(e){let t=this.state.thread;t.posts.unshift(e),this.props.session.updateThreadInSession(t),this.setState({thread:t})}viewAttachment(e){let{thread:t}=this.state;this.props.threadSelfUtils.viewAttachment(t.firstPost.attachments,e)}showFullContent(){this.setState({readMore:!0})}startTimer(e){this.timer=setTimeout(()=>{this.markThreadAsRead(e)},1500)}resetTimer(){this.timer&&clearTimeout(this.timer)}trackThreadRead(e){let{api:t,requestType:a,community:i,pageNumber:o}=this.props,n=new er.U(t),r="foru";a===s.FEED||a===s.GRAPHFEED?r="foru":a===s.COMMUNITY?r="community":a===s.PROFILE&&(r="profile");let h=[{key:"thread_id",value:e},{key:"source_feature",value:r},{key:"foru_page_number",value:o||1}];i&&a===s.COMMUNITY&&h.push({key:"community_id",value:i.fpId}),t.onAuthenticated(()=>{n.trackEvent(ec.f.ForU_Thread_Read,t.getUserId(),h),n.trackPageView(eh.f.ThreadView_Detail,t.getUserId(),h)})}markThreadAsRead(e){let{api:t}=this.props;t.post({uri:"/tinhte/threads/thread-reads",params:{thread_id:e}}).catch(e=>console.log("Failed to mark thread as read. "+e)),ga("send","pageview"),this.trackThreadRead(e)}toggleCommunityStickyThread(){let{api:e,community:t}=this.props,{thread:s}=this.state,a="post";s.isSticky&&(a="del"),e[a]({uri:ew,params:{fp_id:t.fpId,thread_id:s.id}}).then(()=>{this.setState({thread:{...s,isSticky:!s.isSticky}})}).catch(e=>console.log("Failed to stick thread: "+e))}removeCommunityThread(){let{api:e,community:t}=this.props,{thread:s}=this.state;e.del({uri:ew,params:{fp_id:t.fpId,thread_id:s.id}}).then(()=>{this.setState({thread:{...s,isDeleted:!0}})}).catch(e=>console.log("Failed to remove thread from community: "+e))}deleteThread(){let{api:e}=this.props,{thread:t}=this.state;e.del({uri:"/threads/".concat(t.id)}).then(()=>{this.setState({thread:{...t,isDeleted:!0},showDeleteConfirmationModal:!1})}).catch(e=>console.log("Failed to delete thread"+e))}toogleDeleteConfirmationModal(){let{showDeleteConfirmationModal:e}=this.state;this.setState({showDeleteConfirmationModal:!e})}loadMorePosts(e){let{postLink:t}=e,{api:s}=this.props;s.get({uri:t,headers:{"Api-Post-Tree":1},params:{limit:5,order:"natural_reverse"}}).then(t=>{let{posts:s,links:a=null}=t,{next:i=""}=a||{},o=(0,F.e)(e,s.map(t=>(0,F.U)(t,e)));this.showMorePost(o,i)}).catch(e=>console.log("Failed to load more posts. "+e))}showMorePost(e,t){let{thread:s}=this.state,{latestPosts:a}=s,i=(0,K.default)([...a,...e],"id"),o=i.reduce((e,t)=>e+t.postRepliesDetail.length,0)+i.length;this.setState({thread:{...s,postLink:t,latestPosts:i},loadMore:o{"tinhtefact"===e.tag&&(d=!0,c=!1)}),e.firstPost.isThreadBackground&&(c=!1),e)?e.userIsIgnored?(0,i.jsx)("div",{}):(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" thread",children:[(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" main-thread",children:[(0,i.jsxs)("div",{id:e.id,className:"jsx-".concat(ey.f.__hash)+" header",children:[(0,i.jsx)(Y.f,{user:e.author,thread:e,userRank:e.firstPost.posterRank.rankName,postedSince:e.since}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" thread-controls",children:[e.isSticky&&(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)+" sticky-icon",children:(0,i.jsx)("button",{onClick:()=>this.toggleCommunityStickyThread(),className:"jsx-".concat(ey.f.__hash)+" sticky-icon-button",children:(0,i.jsx)(en.f,{})})}),(0,i.jsx)(et.f,{position:"right",menuItems:(0,i.jsxs)(O.Fragment,{children:[(0,i.jsx)("a",{href:e.link,className:"jsx-".concat(ey.f.__hash),children:"Xem chi tiết"}),e&&e.permissions.edit&&(0,i.jsx)("button",{onClick:()=>{this.props.editThread(e)},className:"jsx-".concat(ey.f.__hash),children:"Sửa"}),e&&e.permissions.delete&&(0,i.jsx)("button",{onClick:()=>this.toogleDeleteConfirmationModal(),className:"jsx-".concat(ey.f.__hash),children:"Xóa"}),n&&n.isVisitor&&(0,i.jsx)("button",{onClick:()=>this.onStickProfileThread(e.id),className:"jsx-".concat(ey.f.__hash),children:"Ghim bài"}),r&&(0,i.jsxs)(O.Fragment,{children:[e.fpPermissions.delete&&(0,i.jsx)("button",{onClick:()=>this.removeCommunityThread(),className:"jsx-".concat(ey.f.__hash),children:"Xóa khỏi cộng đồng"}),(e.fpPermissions.stick||e.fpPermissions.unstick)&&(0,i.jsx)("button",{onClick:()=>this.toggleCommunityStickyThread(),className:"jsx-".concat(ey.f.__hash),children:"Ghim bài"})]})]})}),e.isDeleted&&(0,i.jsx)(eo.f,{className:"deleted-marker"})]})]}),(0,i.jsx)(eT,{onEnterViewport:()=>this.startTimer(e.id),onLeaveViewport:()=>this.resetTimer()}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" body visible-xs",children:[(0,i.jsx)("a",{href:e.link.replace("https://tinhte.vn",""),className:"jsx-".concat(ey.f.__hash)+" content-mobile",children:e.firstPost.isThreadBackground?(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)+" thread-with-background-container",children:(0,i.jsx)(W.f,{firstPost:e.firstPost})}):(0,i.jsx)(q.f,{body:e.firstPost.bodyHtml,author:e.firstPost.author.name})}),(0,i.jsx)(ek.f,{thread:e,post:e.firstPost}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" thread-react",children:[ed.q.map(e=>{let t=h&&h.reaction&&h.reaction.userReactionId===e,s=h&&h.reaction&&h.reaction.postReactions[e]||0;return(0,i.jsx)(O.Fragment,{children:(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" react-item",children:[(0,i.jsx)(Q.f,{commentMode:!1,post:h,onReact:this.onReact,reactionButtonId:e}),(0,i.jsx)("span",{className:"jsx-".concat(ey.f.__hash)+" "+"".concat(t?"reacted-text":""),children:s})]})},"".concat(e))}),(0,i.jsxs)("a",{href:e.link,className:"jsx-".concat(ey.f.__hash)+" react-item",children:[(0,i.jsx)(ea.f,{}),(0,i.jsx)("span",{className:"jsx-".concat(ey.f.__hash),children:e.stats.comment})]}),(0,i.jsx)("a",{href:"https://www.facebook.com/sharer/sharer.php?u=".concat(e.link),rel:"noopener noreferrer",target:"_blank",className:"jsx-".concat(ey.f.__hash)+" react-item",children:(0,i.jsx)(ei.f,{})})]})]}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" body hidden-xs",children:[c&&(0,i.jsx)("h4",{className:"jsx-".concat(ey.f.__hash)+" thread-title",children:(0,i.jsx)("a",{href:e.link,className:"jsx-".concat(ey.f.__hash),children:e.title})}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" "+("thread-content ".concat(d?"tinhtefact":"")+(this.state.readMore?" open":"")||""),children:[!e.firstPost.isThreadBackground&&(0,i.jsx)(O.Fragment,{children:d?(0,i.jsx)(G.f,{thread:e}):(0,i.jsx)("div",{ref:e=>{this.threadBody=e},className:"jsx-".concat(ey.f.__hash),children:(0,i.jsx)(q.f,{body:e.firstPost.bodyHtml,author:e.firstPost.author.name})})}),e.firstPost.isThreadBackground&&(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)+" thread-with-background-container",children:(0,i.jsx)(W.f,{firstPost:e.firstPost})})]}),this.state.threadHeight>400&&(0,i.jsx)("div",{onClick:this.showFullContent,onKeyDown:this.showFullContent,className:"jsx-".concat(ey.f.__hash)+" read-more",children:"...Xem thêm"})]}),!d&&!e.firstPost.isThreadBackground&&e.firstPost.attachments&&e.firstPost.attachments.length>0&&(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)+" image-masonry-wrapper hidden-xs",children:(0,i.jsx)(ev,{attachments:e.firstPost.attachments,onAttachmentClick:this.viewAttachment})}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" statistic hidden-xs",children:[(0,i.jsx)(Z.f,{commentMode:!1,totalReaction:this.state.totalReaction,post:e.firstPost}),e.stats.comment>0&&(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash),children:[(0,i.jsx)("span",{className:"jsx-".concat(ey.f.__hash),children:(0,i.jsx)(X.f,{value:e.stats.comment})})," bình luận"]})]}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" action-bar no-user-select hidden-xs",children:[ed.q.map(e=>(0,i.jsx)(Q.f,{commentMode:!1,post:h,onReact:this.onReact,reactionButtonId:e},"".concat(e))),(0,i.jsx)("a",{href:e.link,className:"jsx-".concat(ey.f.__hash)+" action no-user-select",children:(0,i.jsx)("span",{className:"jsx-".concat(ey.f.__hash)+" icon",children:(0,i.jsx)(ea.f,{})})}),(0,i.jsx)("a",{href:"https://www.facebook.com/sharer/sharer.php?u=".concat(e.link),rel:"noopener noreferrer",target:"_blank",className:"jsx-".concat(ey.f.__hash)+" action no-user-select",children:(0,i.jsx)("span",{className:"jsx-".concat(ey.f.__hash)+" icon",children:(0,i.jsx)(ei.f,{})})})]}),a?(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)+" comment-box hidden-xs",children:(0,i.jsx)(J.f,{ref:e=>{this.postReply=e},api:this.props.api,postToReply:h,user:a,addPost:this.addPost})}):(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)})]}),e.latestPosts&&e.latestPosts.length>0&&(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" comments hidden-xs",children:[(0,i.jsx)($.f,{user:a,posts:e.latestPosts}),s&&(0,i.jsx)("div",{className:"jsx-".concat(ey.f.__hash)+" more-comments",children:(0,i.jsx)("button",{onClick:()=>this.loadMorePosts(e),className:"jsx-".concat(ey.f.__hash),children:"Xem thêm bình luận..."})})]}),t&&(0,i.jsxs)(V.default,{isOpen:t,ariaHideApp:!1,style:eN,children:[(0,i.jsx)("h2",{className:"jsx-".concat(ey.f.__hash)+" modal-title",children:"Bạn có chắc chắn muốn xóa bài này không? Xóa là mất luôn đó nha!"}),(0,i.jsxs)("div",{className:"jsx-".concat(ey.f.__hash)+" modal-controls",children:[(0,i.jsx)("button",{onClick:()=>this.deleteThread(),className:"jsx-".concat(ey.f.__hash)+" modal-button yes",children:"Xóa"}),(0,i.jsx)("button",{onClick:()=>this.setState({showDeleteConfirmationModal:!1}),className:"jsx-".concat(ey.f.__hash)+" modal-button",children:"Không"})]})]}),(0,i.jsx)(o.default,{id:ey.f.__hash,children:ey.f})]}):(0,i.jsx)("div",{})}constructor(e){super(e),this.addPost=this.addPost.bind(this);let{thread:t}=this.props;this.state={thread:t,readMore:!1,loadMore:t.latestPosts.length(0,i.jsx)(el.Consumer,{children:t=>{let{session:s,user:a,utils:o}=t;return(0,i.jsx)(eS,{...e,session:s,user:a,threadSelfUtils:o})}})).displayName=t.name,t)),{errorMsg:"Lỗi social thread stream"});var eC=n;let eI=new String(".image-overlay.jsx-32e3f23e7b0f919a{opacity:1;z-index:2;justify-content:center;align-items:center;transition:opacity .3s ease-in-out;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}@media (min-width:1001px){.image-overlay.jsx-32e3f23e7b0f919a{padding-left:15%}}.image-overlay.hidden.jsx-32e3f23e7b0f919a,.image-overlay.hidden.jsx-32e3f23e7b0f919a .jsx-32e3f23e7b0f919a{pointer-events:none;opacity:0}.image-overlay.jsx-32e3f23e7b0f919a .bg.jsx-32e3f23e7b0f919a{background:#000c;position:absolute;top:0;bottom:0;left:0;right:0}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a{position:relative}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image.jsx-32e3f23e7b0f919a{background:#fff}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image.jsx-32e3f23e7b0f919a img.jsx-32e3f23e7b0f919a{max-width:80vw;max-height:80vh;display:block}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a{opacity:0;pointer-events:none;justify-content:space-between;align-items:center;transition:opacity .3s ease-in-out;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a{color:#fff;text-shadow:2px 2px 2px #000;cursor:pointer;padding:10px;font-size:24px;position:absolute;top:0;right:0}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a{color:#fff;text-shadow:2px 2px 2px #000;cursor:pointer;padding:10px;font-size:24px}@media (min-width:48em){.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a,.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a{padding:20px}}.image-overlay.focused.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a{opacity:1}.image-overlay.focused.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a,.image-overlay.focused.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a{pointer-events:all}@media (min-width:48em){.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a:hover .image-overlay-navs.jsx-32e3f23e7b0f919a{opacity:1}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a:hover .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a,.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a:hover .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a{pointer-events:all}}");eI.__hash="32e3f23e7b0f919a";class eF extends eC.default.Component{componentDidMount(){window.$(window.document).on("keyup",this.keyHandler)}componentWillUnmount(){window.$(window.document).off("keyup",this.keyHandler)}onImageSwitch(e){return()=>{let t=this.props.viewingIndex+e;t=Math.min(t=Math.max(t,0),this.props.attachments?this.props.attachments.length-1:0),this.props.onImageSwitch(t)}}toggleImageFocused(){this.setState({imageFocused:!this.state.imageFocused})}render(){let{viewingIndex:e,attachments:t}=this.props,s=t?t[e]:null,a=t&&e0&&(0,i.jsx)("button",{onClick:this.onImageSwitch(-1),className:"jsx-".concat(eI.__hash)+" image-nav",children:(0,i.jsx)("i",{"aria-hidden":"true",className:"jsx-".concat(eI.__hash)+" fa fa-chevron-left"})}),(0,i.jsx)("div",{className:"jsx-".concat(eI.__hash)}),a&&(0,i.jsx)("button",{onClick:this.onImageSwitch(1),className:"jsx-".concat(eI.__hash)+" image-nav",children:(0,i.jsx)("i",{"aria-hidden":"true",className:"jsx-".concat(eI.__hash)+" fa fa-chevron-right"})})]})]}),(0,i.jsx)(o.default,{id:eI.__hash,children:eI})]})}constructor(e){super(e),this.state={imageFocused:!0},this.toggleImageFocused=this.toggleImageFocused.bind(this),this.keyHandler=(e=>{let{esc:t,left:s,right:a}=e;return e=>{switch(e.keyCode){case 27:t();break;case 37:s();break;case 39:a()}}})({left:this.onImageSwitch(-1),right:this.onImageSwitch(1),esc:this.props.onClose})}}var eR=e.i(758568);let eA=e=>{let t=(e.data||e.threads).map(S.U),s=(0,eR.default)(e,"sticky_threads",[]).map(S.U),a=[];s.length>0&&s.forEach(e=>{a.push({...e,isSticky:!0})});let i=(0,eR.default)(e,"links",null);return{newThreads:[...a,...t],nextPage:(0,eR.default)(i,"next",null)}},eM=e=>{let t=(e.data||e.facts).map(S.U),s=(0,eR.default)(e,"links",null);return{newThreads:t,nextPage:(0,eR.default)(s,"next",null)}},eD=e=>({newThreads:[],error:e&&e.message?e.message:"Có lỗi khi tải bài viết"}),eU=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,n=arguments.length>5?arguments[5]:void 0,r=null,h="",c=!1,d=(0,S.X)("content.");if(t)r=t;else{let t={limit:a,page:1,non_mod_only:1,order:"thread_create_date_reverse",fields_include:d};switch(i){case s.FACT_USER:h="/tinhte-facts/users",t={page:1,limit:a||5,user_id:n,_bdImageApiThreadThumbnailWidth:"200",_bdImageApiThreadThumbnailHeight:"sw",fields_include:d};break;case s.FACT:h="/tinhte-facts";break;case s.FEED:e.getUserId(),h="users/me/neo-feeds";break;case s.FORUM:h="tinhte/node-new-threads?node_id=".concat(o);break;case s.PROFILE:let l,f;l=o.userProfile.id,f=o.forumId,h="users/".concat(l,"/threads?forum_id=").concat(f);break;case s.TAG:h="search/tagged?tag=".concat(o),c=!0;break;case s.COMMUNITY:h="feature-pages/threads?fp_id=".concat(o),d=(0,S.X)("content.",["fp_permissions"]);break;case s.TAG_SEARCH:h="search/?tag=".concat(o&&o.tagText||"","&q=").concat(o&&o.term||""),d=(0,S.Y)("content."),c=!0;break;default:return Promise.reject(Error("Missing component's request type and parameter's value"))}r={uri:h,params:t,headers:{"Api-Post-Tree":1}}}return c?t?e.get(r).then(eA,eD):e.post(r).then(eA,eD):e.get(r).then(i===s.FACT||i===s.FACT_USER?eM:eA,eD)},eE=new String(".main.jsx-79523f40e962430c{margin-bottom:0}@media (min-width:768px){.main.jsx-79523f40e962430c{margin-bottom:12px}}.interfered-block.jsx-79523f40e962430c{margin:12px 0;padding:12px 10px}@media (min-width:576px){.interfered-block.jsx-79523f40e962430c{padding-left:20px;padding-right:20px}}@media (min-width:768px){.interfered-block.jsx-79523f40e962430c{padding-left:0;padding-right:0}}.loading-container.jsx-79523f40e962430c{justify-content:center;margin:20px 0;display:flex}.loading-container.jsx-79523f40e962430c svg{fill:inherit}.threads.jsx-79523f40e962430c .primaryContent a,.threads.jsx-79523f40e962430c .primaryContent a *{color:var(--color-accent-dark)}.threads.jsx-79523f40e962430c .LinkExpander.expanded{display:block}");eE.__hash="79523f40e962430c";var ez=e.i(566709);let eB=new String(".facts-container.jsx-9f8ccfc7430bdcb9{-webkit-scroll-snap-type:y mandatory;-ms-scroll-snap-type:y mandatory;scroll-snap-type:y mandatory;scroll-behavior:smooth;touch-action:pan-y;overscroll-behavior-y:contain;scrollbar-width:none;height:100vh;scroll-padding-top:1px;overflow-x:hidden;overflow-y:auto}.facts-container.jsx-9f8ccfc7430bdcb9::-webkit-scrollbar{display:none}");eB.__hash="9f8ccfc7430bdcb9";let eL=e=>{let{threads:t,onMoreThread:s,onNewThread:a}=e,r=(0,n.useRef)(null),[h,c]=(0,n.useState)(t?t[0]:null),d=(0,n.useCallback)(()=>{h&&window.history.replaceState({},"","#".concat(h.id))},[h]);return(0,n.useEffect)(()=>{d()},[d]),(0,n.useEffect)(()=>{h&&t.findIndex(e=>e.id===h.id)===t.length-2&&s()},[h,t]),(0,i.jsxs)("div",{ref:r,className:"jsx-".concat(eB.__hash)+" facts-container",children:[t.map((e,t)=>(0,i.jsx)(ez.U,{thread:e,observerOptions:{root:r.current},onInView:c,showHeader:0===t,onNewThread:a},e.id)),(0,i.jsx)(o.default,{id:eB.__hash,children:eB})]})};class eO extends n.default.Component{componentDidMount(){let{api:e}=this.props;e.onAuthenticated(()=>{this.loadMore()}),B.isMobile||window.addEventListener("scroll",(0,l.default)(()=>{this.handleInfinityScroll()},1e3))}componentDidUpdate(e){let{id:t,api:s,newThread:a,paramVal:i,tinhteFact:o}=this.props;if((0,c.default)(a)||a===e.newThread)t!==e.id&&s&&s.onAuthenticated(()=>{this.setState({threads:[],nextPage:null}),this.loadMore()});else{let{threads:e}=this.state,t=[{...(0,S.U)(a),posts:[]},...e];this.setState({threads:t})}let n=window.location.hash?window.location.hash.replace("#",""):null;n&&setTimeout(()=>{let e=document.getElementById(n);e&&(o&&B.isMobile?e.scrollIntoView({behavior:"instant",block:"start"}):(e.scrollIntoView({block:"center"}),window.history.replaceState("",document.title,window.location.pathname+window.location.search)))},0);let r=i.userProfile?i.userProfile.id:null,h=e.paramVal.userProfile?e.paramVal.userProfile.id:null,{forumId:l}=i,f=e.paramVal?e.paramVal.forumId:null;(h&&r&&!(0,d.default)(r,h)||!(0,d.default)(l,f))&&this.resetComponentState()}onImageSwitch(e){this.viewAttachment(this.state.attachmentViewer.attachments,e)}onImageClose(){this.viewAttachment(null,null)}onStickProfileThread(e){this.props.stickProfileThread(e)}resetComponentState(){this.setState({threads:[],pageNumber:0,nextPage:null,loading:!0,attachmentViewer:{viewingIndex:null,attachments:null},edittingThread:null,endResult:!1},()=>this.loadMore())}stickThread(e){this.props.stickThread&&this.props.stickThread(e)}editThread(e){this.setState({edittingThread:e})}loadMore(){let{api:e,requestType:t,paramVal:a,router:i}=this.props,o=i.query&&i.query.user_id,{threads:n,nextPage:r,pageNumber:c}=this.state;if(console.log("ThreadStream loadMore: ",c,o),!e)return;this.setState({loading:!0});let d=t;d===s.FACT&&o&&(d=s.FACT_USER),eU(e,r,15,d,a,o).then(e=>{let{newThreads:t,error:s,nextPage:a}=e;if(s)this.setState({loading:!1,endResult:!0}),h.c.error(s);else{let e=t.filter(e=>!n.some(t=>t.id===e.id)),s=[...n,...e];this.setState({threads:s,loading:!1,nextPage:a,endResult:!a,pageNumber:c+1},()=>{})}}).catch(e=>{this.setState({loading:!1,endResult:!0}),h.c.error("Có lỗi khi tải bài viết"),console.log(e)})}saveThreadsToSession(){let{threads:e,nextPage:t,loading:s}=this.state,a={state:{threads:e,nextPage:t,loading:s},last_load_time:parseInt(new Date().getTime()/1e3,10)};window.sessionStorage.setItem("threadSelf",JSON.stringify(a))}updateThreadInSession(e){if(!window.sessionStorage.getItem("threadSelf"))return;let t=this.state.threads.find(t=>t.id===e.id);t&&(Object.assign(t,e),this.saveThreadsToSession())}updatePostInSession(e){if(!window.sessionStorage.getItem("threadSelf"))return;let t=this.state.threads.find(t=>t.id===e.thread.id);if(!t)return;let s=null;if(e.postReplyTo&&e.postReplyTo!==t.firstPostId){let a=t.posts.find(t=>t.id===e.postReplyTo);a.postRepliesDetail&&(s=a.postRepliesDetail.find(t=>t.id===e.id))}else s=t.posts.find(t=>t.id===e.id);s&&Object.assign(s,e),this.saveThreadsToSession()}viewAttachment(e,t){this.setState({attachmentViewer:{attachments:e,viewingIndex:t}})}handleInfinityScroll(){let{threads:e,endResult:t}=this.state;if(!t){let t=document.querySelector(".load-more-marker");if(t&&e.length>0){let e=t.offsetTop+t.clientHeight;window.pageYOffset+window.innerHeight>e&&this.loadMore()}}}render(){let{user:e,community:t,requestType:s,paramVal:a,tinhteFact:r,onNewThread:h}=this.props,{attachmentViewer:c,loading:d,threads:l,edittingThread:m,endResult:u,pageNumber:g}=this.state,{attachments:j,viewingIndex:b}=c;return r&&B.isMobile?(0,i.jsxs)(n.Fragment,{children:[0===l.length&&!d&&(0,i.jsx)(p.f,{children:(0,i.jsx)("a",{href:"/following-community",target:"_blank",className:"jsx-".concat(eE.__hash)+" btn",children:"Tìm hiểu tag"})}),d&&(0,i.jsx)("div",{className:"jsx-".concat(eE.__hash)+" loading-container",children:(0,i.jsx)(f.default,{type:"cylon",color:"#00bad6",width:100})}),(0,i.jsx)(eL,{threads:l,onMoreThread:this.loadMore,onNewThread:h}),(0,i.jsx)(o.default,{id:eE.__hash,children:eE})]}):(0,i.jsxs)("div",{className:"jsx-".concat(eE.__hash),children:[0===l.length&&!d&&(0,i.jsx)(p.f,{children:(0,i.jsx)("a",{href:"/following-community",target:"_blank",className:"jsx-".concat(eE.__hash)+" btn",children:"Tìm hiểu tag"})}),(0,i.jsxs)(el.Provider,{value:{session:this.session,user:e,utils:this.utils},children:[(0,i.jsxs)("div",{className:"jsx-".concat(eE.__hash)+" threads items",children:[l.length>0&&l.map((e,o)=>(0,i.jsxs)(n.Fragment,{children:[m&&m.id===e.id?(0,i.jsx)(z,{edittingThread:e,onBlur:()=>{this.editThread(null)}}):(0,i.jsx)(eP,{thread:e,userProfile:a&&a.userProfile,editThread:this.editThread,community:t,requestType:s,pageNumber:g,stickProfileThread:this.onStickProfileThread}),2===o&&(0,i.jsxs)("div",{className:"jsx-".concat(eE.__hash)+" interfered-block visible-md",children:[" ",(0,i.jsx)(k.f,{})]}),(2===o||o>10&&o%5==0)&&(0,i.jsx)("div",{className:"jsx-".concat(eE.__hash)+" interfered-block",children:(0,i.jsx)(w.f,{adLayoutKey:"-6c+du+k-3x+d5",adSlot:"3460318925"})}),6===o&&(0,i.jsxs)("div",{className:"jsx-".concat(eE.__hash)+" interfered-block",children:[" ",(0,i.jsx)(T.f,{})]}),10===o&&(0,i.jsxs)("div",{className:"jsx-".concat(eE.__hash)+" interfered-block",children:[" ",(0,i.jsx)(y,{})]})]},e.id)),u?(0,i.jsx)(x,{}):(0,i.jsx)("div",{className:"jsx-".concat(eE.__hash)+" load-more-marker"})]}),(0,i.jsx)("div",{className:"jsx-".concat(eE.__hash)+" main",children:(0,i.jsx)(eF,{onImageSwitch:this.onImageSwitch,onClose:this.onImageClose,attachments:j,viewingIndex:b})})]}),d&&(0,i.jsx)("div",{className:"jsx-".concat(eE.__hash)+" loading-container",children:(0,i.jsx)(f.default,{type:"cylon",color:"#00bad6",width:100})}),(0,i.jsx)(o.default,{id:eE.__hash,children:eE})]})}constructor(e){super(e),this.state={threads:[],pageNumber:0,nextPage:null,loading:!0,attachmentViewer:{viewingIndex:null,attachments:null},edittingThread:null,endResult:!1},this.onImageSwitch=this.onImageSwitch.bind(this),this.onImageClose=this.onImageClose.bind(this),this.loadMore=this.loadMore.bind(this),this.session={updateThreadInSession:this.updateThreadInSession.bind(this),updatePostInSession:this.updatePostInSession.bind(this)},this.utils={viewAttachment:this.viewAttachment.bind(this)},this.editThread=this.editThread.bind(this),this.stickThread=this.stickThread.bind(this),this.handleInfinityScroll=this.handleInfinityScroll.bind(this),this.onStickProfileThread=this.onStickProfileThread.bind(this)}}eO.apiFetchesWithAuth={user:{uri:"users/me",success:e=>(0,N.U)(e.user||{})}};let eH=r.f.ApiConsumer((0,L.withRouter)(eO));e.s(["f",0,eH],805513)}]);