PageSourceSearch

https://static2.ntv.ru/assets/js/comments-form.type_style-B9BHbDdP.js

js ntv.ru collected 2026-10-02 02:30:59 UTC 14,096 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["https://static2.ntv.ru/assets/js/email-confirm-CPUqTqXJ.js","https://static2.ntv.ru/assets/main-sKWLCJQt.js","https://static2.ntv.ru/assets/css/main-DzjLpoR4.css","https://static2.ntv.ru/assets/js/validate-q49PAmOY.js","https://static2.ntv.ru/assets/js/form-item.type_style-DkUeUWlw.js","https://static2.ntv.ru/assets/css/form-item-BFQJaogK.css","https://static2.ntv.ru/assets/js/form-input.type_style-DCjz2UJl.js","https://static2.ntv.ru/assets/css/form-input-GL37qnZn.css","https://static2.ntv.ru/assets/js/form-label.type_style-CRImqC13.js","https://static2.ntv.ru/assets/css/form-label-BencbZUt.css","https://static2.ntv.ru/assets/js/form-error.type_style-De7XrReq.js","https://static2.ntv.ru/assets/css/form-error-CI4LxaJm.css","https://static2.ntv.ru/assets/css/email-confirm-C1LxdqEk.css","https://static2.ntv.ru/assets/js/emoji-picker-async-BBoDmc05.js","https://static2.ntv.ru/assets/css/emoji-picker-async-DtxjZLQM.css"])))=>i.map(i=>d[i]);
2import{aA as _export_sfc,o as openBlock,v as createBlock,f as withCtx,s as createTextVNode,q as hUi,c as createElementBlock,e as createVNode,H as _sfc_main$5,d as defineComponent,t as toDisplayString,g as createBaseVNode,m as mergeProps,a as unref,j as computed,av as use,w as watch,bo as _sfc_main$6,i as isRef,h as createCommentVNode,bN as defineAsyncComponent,bO as __vitePreload,y as ref,am as apiBase,ao as NTV_API_CONFIG,b3 as isAxiosError,a4 as useQueryClient,bP as useElementSize,n as nextTick,bu as onClickOutside,l as normalizeClass,aN as _sfc_main$8,U as Transition,R as withKeys,b as withModifiers,az as normalizeStyle,T as _sfc_main$b,bQ as _sfc_main$c,r as reactive}from"../main-sKWLCJQt.js";import{_ as _sfc_main$7}from"./guest-badge.type_style-Dsy4thQX.js";import{c as confirmEmailRequest}from"./confirm-email-CxiifsCT.js";import{u as useValidate,_ as _sfc_main$9,r as required}from"./validate-q49PAmOY.js";import"./form-item.type_style-DkUeUWlw.js";import{_ as _sfc_main$a}from"./form-area.type_style-Dcty5qfv.js";var ORDER=(e=>(e.desc="desc",e.asc="asc",e))(ORDER||{});const CommentError=_export_sfc({},[["render",function(e,t){const a=hUi;return openBlock(),createBlock(a,null,{default:withCtx(()=>[...t[0]||(t[0]=[createTextVNode(" Не удалось загрузить комментарии. Пожалуйста, попробуйте позже ",-1)])]),_:1})}]]),_hoisted_1$3={class:"comments-loader"};const CommentLoader=_export_sfc({},[["render",function(e,t){const a=_sfc_main$5;return openBlock(),createElementBlock("div",_hoisted_1$3,[createVNode(a,{"is-loading":"",type:"block"})])}]]),_hoisted_1$2={class:"email-confirm-badge"},_sfc_main$2=defineComponent({__name:"EmailConfirmBadge",props:{size:{default:"s"},text:{default:"Чтобы оставлять комментарии"},withAttr:{type:Boolean,default:!1}},emits:["confirm"],setup(e,{emit:t}){const a=e,o=t,r=computed(()=>a.withAttr?{"data-email-confirm-show":1}:{});return(t,a)=>{const s=hUi;return openBlock(),createElementBlock("div",_hoisted_1$2,[createVNode(s,{class:"email-confirm-badge__text",size:e.size},{default:withCtx(()=>[createTextVNode(toDisplayString(e.text)+", ",1),createBaseVNode("span",mergeProps({class:"hov-pr"},unref(r),{onClick:a[0]||(a[0]=e=>o("confirm"))}),"подтвердите свой email",16)]),_:1},8,["size"])])}}}),_hoisted_1$1={class:"comments-confirm"},_sfc_main$1=defineComponent({__name:"CommentsConfirm",props:{modelValue:{type:Boolean},size:{default:"s"},text:{default:"Чтобы оставлять комментарии"}},emits:["update:modelValue"],setup(e,{emit:t}){const a=e,o=t,r=computed({get:()=>a.modelValue,set:e=>o("update:modelValue",e)}),s=defineAsyncComponent({loader:()=>__vitePreload(()=>import("./email-confirm-CPUqTqXJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url)}),n=use();function i(){r.value=!1}function l(){confirmEmailRequest()}function m(){r.value=!0}return watch(r,()=>{r.value&&confirmEmailRequest()}),(t,a)=>{var o,c,u,d;const _=_sfc_main$6,f=_sfc_main$7,p=_sfc_main$2;return openBlock(),createElementBlock("div",_hoisted_1$1,[unref(n).isGuest||(null==(c=null==(o=unref(n).token)?void 0:o.sub)?void 0:c.is_email_confirmed)?createCommentVNode("",!0):(openBlock(),createBlock(_,{key:0,modelValue:unref(r),"onUpdate:modelValue":a[0]||(a[0]=e=>isRef(r)?r.value=e:null),type:"white"},{default:withCtx(()=>{var e,t;return[createVNode(unref(s),{email:null==(t=null==(e=unref(n).token)?void 0:e.sub)?void 0:t.email,onTryAgain:l,onSuccess:i},null,8,["email"])]}),_:1},8,["modelValue"])),unref(n).isGuest?(openBlock(),createBlock(f,{key:1,text:e.text,size:e.size},null,8,["text","size"])):(null==(d=null==(u=unref(n).token)?void 0:u.sub)?void 0:d.is_email_confirmed)?createCommentVNode("",!0):(openBlock(),createBlock(p,{key:2,onConfirm:m}))])}}}),COMMENTS_URL="/comments/v1/comment";function getLocalOrder(e){const t=localStorage.getItem("".concat(e,"-order"));return t&&t in ORDER?t:ORDER.desc}function setLocalOrder(e,t){window.localStorage.setItem("".concat(e,"-order"),t)}function isAsc(e){return e===ORDER.asc}const COMMENT_ORDER_PFX="ntv-comment";function getSubThreadUrl(e,t){return"".concat("/comments/v1/comment","/").concat(unref(e),"/parent_by_time/").concat(unref(t),"/children")}function getTimeCursor(e,t){return t?{direction:e,cursor:t}:null}function getDateForCursor(e,t){if(e){const{items:a,pagination:o}=e;if((null==o?void 0:o["is_has_".concat(t,"_page")])&&a&&a.length>0)return a["prev"===t?0:a.length-1].display_date}return null}function setData(e,t,a,o){const r=computed(()=>
2getSubThreadUrl(t,a.id)),{children:s}=a;if(!e.getQueryData(["subthread",r,ORDER.asc])&&s){const t=getDateForCursor(s,"next"),a=getDateForCursor(s,"prev");e.setQueryData(["subthread",r,ORDER.asc],{pages:[{data:{items:null==s?void 0:s.items,pagination:null==s?void 0:s.pagination},nextCursor:getTimeCursor("forward",t),prevCursor:getTimeCursor("backward",a)}],pageParams:[getTimeCursor("forward",o)]})}}function setThreadQueryData(e,t,a,o){var r;const{items:s,pagination:n}=a.comments,{is_has_next_page:i,is_has_prev_page:l,total_items:m}=n,c=getDateForCursor(a.comments,"next"),u=getDateForCursor(a.comments,"prev"),d=getLocalOrder("ntv-comment");e.setQueryData(["thread",t,d],{pages:[{data:a,nextCursor:getTimeCursor("forward",c),prevCursor:getTimeCursor("backward",u)}],pageParams:[getTimeCursor("forward",a.initial_cursor)]});const _=isAsc(d)?ORDER.desc:ORDER.asc,f={is_has_next_page:l,is_has_prev_page:i,total_items:m};e.setQueryData(["thread",t,_],{pages:[{data:{...a,comments:{items:s.slice().reverse(),pagination:f}},nextCursor:getTimeCursor("forward",u),prevCursor:getTimeCursor("backward",c)}],pageParams:[getTimeCursor("backward",a.initial_cursor)]});const p=getSubThreadUrl(t,o.id);e.removeQueries({queryKey:["subthread",p,ORDER.asc]}),setData(e,ref(t),o,a.initial_children_cursor);return{cursors:{[d]:"forward",[_]:"backward"},replyToComment:o.id!==(null==(r=a.reply_to_comment)?void 0:r.id)?a.reply_to_comment:void 0}}const DEFAULT_ERR="Извините, что-то пошло не так. Попробуйте, пожалуйста, позже";const _hoisted_1={class:"comments-form__aria"},_hoisted_2={key:0,class:"comments-form__btns"},_hoisted_3=["onKeydown"],_sfc_main=defineComponent({__name:"CommentsForm",props:{threadKey:{},parendId:{},replyToId:{},nameTo:{},name:{},avatar:{},mini:{type:Boolean},placeholder:{},maxlength:{},minlength:{},showmax:{type:Boolean},emojiOn:{type:Boolean}},emits:["sended","cancel"],setup(e,{emit:t}){const a=e,o=t,r=()=>__vitePreload(()=>import("./emoji-picker-async-BBoDmc05.js"),__vite__mapDeps([13,1,2,14]),import.meta.url),s=useQueryClient(),n=ref(null),i=ref(null),l=ref(null),m=ref(!1),c=ref(!1),u=ref(!1),d=ref(!1),_=ref(!a.mini),f=reactive({message:""}),p=ref(null),h=computed(()=>_.value?"s":"xs"),g=computed(()=>a.threadKey.startsWith("live-")),{width:y}=useElementSize(n),v=computed(()=>y.value?"".concat(y.value+3,"px"):"0");const{errors:C,isValid:k,reset:b,onSubmit:x}=useValidate(f,{message:[e=>required(e,{message:"Нельзя отправить пустой комментарий"}),function(e){return{isValid:(null==e?void 0:e.replace(/^\s*[\r\n]/gm,"").trim().length)>=(a.minlength||2),message:"Слишком короткий комментарий"}}]},{beforeSubmit:()=>{c.value=!0},submit:async e=>{m.value=!0;try{const t=await async function({message:e,thread_key:t,parent_id:a,reply_to_id:o}){const{data:r}=await apiBase.post("/comments/v1/comment",{message:e,thread_key:t,parent_id:a,reply_to_id:o},NTV_API_CONFIG);return r.data.comment}({...e,thread_key:a.threadKey,parent_id:a.parendId,reply_to_id:a.replyToId});if(N(),g.value)s.invalidateQueries({queryKey:["thread_live",a.threadKey]});else if(a.parendId){const e=getSubThreadUrl(a.threadKey,a.parendId);nextTick(()=>{s.invalidateQueries({queryKey:["subthread",e,ORDER.asc]})})}else s.invalidateQueries({queryKey:["thread",a.threadKey]});o("sended",t),a.mini&&(_.value=!1)}catch(t){const{errors:e}=function(e){var t;if(isAxiosError(e)&&e.response){const{error:a=[]}=e.response.data,o={};if(404===e.response.status)o.body="Отправка комментариев временно недоступна";else if(429===e.response.status)o.body="Вы отправили слишком много комментариев за короткое время. Пожалуйста, попробуйте позже";else for(const e of a)"value_error"===e.type&&(null==(t=e.loc)?void 0:t.includes("message"))&&("Value error, message too long"===e.msg&&(o.body="Длина комментария не может превышать 2000 символов"),"Value error, message need more than 2 character"===e.msg&&(o.body="Слишком короткий комментарий"));return Object.keys(o).length||(o.body=DEFAULT_ERR),{success:!1,errors:o}}return{success:!1,errors:{body:DEFAULT_ERR}}}(t);p.value=e,u.value=!0}m.value=!1},isDisabledSubmit:m});onClickOutside(i,()=>{d.value=!1});const w=computed(()=>c.value?C.value.message:"");function T(){a.mini&&(_.value=!0),a.emojiOn&&d.value&&(d.value=!1)}function V(e){g.value&&e.preventDefault()}function E(e){var t;O(e),null==(t=l.value)||t.el.blur()}function R(){var e;a.replyToId&&(null==(e=l.value)||e.el.focus())}function B(){d.value=!d.value}function D({type:e,value:t}){"add-emoji"===e&&(!a.maxlength||f.message.length+1<a.maxlength)&&(f.message=f.message+t)}function N(){p.value=null,b(),c.value=!1}function O(e){e.preventDefault(),N(),a.mini&&(_.value=!1),o("cancel")}return watch(()=>a.replyToId,()=>{a.replyToId&&R()}),watch(_,()=>{d.value=!1,_.value?document.body.setAttribute("data-show-form","1"):document.body.removeAttribute("data-show-form")}),watch(()=>f.message,()=>{var e;p.value=null,f.message=null==(e=f.message)?void 0:e.replace(/^\s*[\r\n]/gm,""),a.maxlength&&f.message.length>a.maxlength&&(f.message=f.message.slice(0,a.maxlength)),!_.value&&f.message.length>0&&(_.value=!0)}),(t,a)=>{var o;const s=_sfc_main$8,u=hUi,g=_sfc_main$a,y=_sfc_main$b,C=_sfc_main$c,b=_sfc_main$9,N=_sfc_main$5;return openBlock(),createElementBlock("form",{ref_key:"container",ref:i,class:normalizeClass(["comments-form",{full:unref(_)}]),onSubmit:a[1]||(a[1]=(...e)=>unref(x)&&unref(x)(...e))},[e.name?(openBlock(),createBlock(s,{key:0,img:e.avatar,name:e.name,class:"comments-form__photo","
2show-name":!1},null,8,["img","name"])):createCommentVNode("",!0),createVNode(b,{error:unref(w)||(null==(o=unref(p))?void 0:o.body),class:"comments-form__comment"},{default:withCtx(()=>[createBaseVNode("div",_hoisted_1,[createVNode(Transition,{name:"name-fade",appear:"",onAfterEnter:R},{default:withCtx(()=>[e.nameTo?(openBlock(),createBlock(u,{key:0,ref_key:"recipient",ref:n,class:"comments-form__to",type:"bodyBold",size:"s"},{default:withCtx(()=>[createTextVNode(toDisplayString(e.nameTo)+", ",1)]),_:1},512)):createCommentVNode("",!0)]),_:1}),createVNode(g,{ref_key:"aria",ref:l,modelValue:unref(f).message,"onUpdate:modelValue":a[0]||(a[0]=e=>unref(f).message=e),name:"message",placeholder:e.nameTo?"":e.placeholder||"Написать комментарий",size:unref(h),style:normalizeStyle({textIndent:e.nameTo?unref(v):"0"}),maxlength:e.maxlength||2e3,onFocus:T,onKeydown:[withKeys(withModifiers(unref(x),["exact","prevent"]),["enter"]),withKeys(withModifiers(E,["exact","prevent"]),["escape"]),withKeys(withModifiers(V,["shift"]),["enter"]),withKeys(withModifiers(V,["alt"]),["enter"])]},null,8,["modelValue","placeholder","size","style","maxlength","onKeydown"]),unref(_)?(openBlock(),createElementBlock("div",_hoisted_2,[createVNode(u,{type:"control",size:"s",class:"comments-form__cancel",tag:"button",onClick:O},{default:withCtx(()=>[...a[2]||(a[2]=[createTextVNode("Отмена",-1)])]),_:1}),createVNode(y,{"native-type":"submit",disabled:!unref(k)&&unref(c)||unref(m),size:"s"},{default:withCtx(()=>[...a[3]||(a[3]=[createTextVNode(" Отправить ",-1)])]),_:1},8,["disabled"]),e.emojiOn?(openBlock(),createElementBlock("button",{key:0,type:"button",class:"comments-from__emoji-btn",onClick:B,onKeydown:withKeys(withModifiers(E,["exact","prevent"]),["escape"])}," 🙂 ",40,_hoisted_3)):createCommentVNode("",!0),unref(d)?(openBlock(),createBlock(C,{key:1,component:r,"client-only":"",class:"comments-from__emoji-picker",onCustomEvent:D})):createCommentVNode("",!0)])):createCommentVNode("",!0),e.showmax&&unref(f).message.length>(e.maxlength||2e3)-20&&unref(_)?(openBlock(),createBlock(u,{key:1,type:"control",size:"s",class:"comments-from__max"},{default:withCtx(()=>[createTextVNode(toDisplayString(unref(f).message.length)+" / "+toDisplayString(e.maxlength||2e3),1)]),_:1})):createCommentVNode("",!0)])]),_:1},8,["error"]),createVNode(N,{"is-loading":unref(m),type:"block",class:"comments-from__loader"},null,8,["is-loading"])],34)}}});export{COMMENTS_URL as C,ORDER as O,_sfc_main$1 as _,CommentLoader as a,CommentError as b,_sfc_main as c,COMMENT_ORDER_PFX as d,getDateForCursor as e,setLocalOrder as f,getLocalOrder as g,_sfc_main$2 as h,isAsc as i,getSubThreadUrl as j,setData as k,setThreadQueryData as s};

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.