1import{r as e}from"./rolldown-runtime-NMqb_1LM.js";import{m as t}from"./vendor-html-parser-CiVdoA1N.js";import{rt as a}from"./vendor-react-BMWHUqYo.js";import{n as r,o as s,t as n}from"./vendor-mui-Bbd-Dt7Y.js";import{f as i,m as o,v as l}from"./vendor-router-g9effIMP.js";import{t as d}from"./index.esm-BCGGggxg.js";import{t as c}from"./roles-Dzfup356.js";import{n as m}from"./UserContext-B9zIxwNG.js";import{x as h}from"./seoCopy-Ch7c6mde.js";import{i as u,p as x,r as p,s as g}from"./seoJsonLd-Bvjrc0Qn.js";import{h as y,m as j,s as f,y as b}from"./md-3ENEeIc9.js";import{S as v,T as N,y as w}from"./fa-DA0D16hb.js";import{p as k}from"./fa6-OClIAD7S.js";import{t as C}from"./RoleProtectedComponent-CYhXxX-_.js";import{n as S}from"./Notification-D-1G36S5.js";import{t as T}from"./seoMeta-aMWHeaSn.js";import{t as I}from"./Button-Dva0dGoZ.js";import{t as E}from"./ProfileLink-B05QhP_E.js";import{o as R}from"./newsRendererShared-CQrosQxU.js";import{t as A}from"./NewsRenderer-CXnaCtYg.js";import{r as M,t as D}from"./htmlToPlainText-DPGSeqqV.js";import{C as F,S as B,_ as H,a as $,b as P,c as L,d as z,f as J,g as V,h as W,l as Y,m as _,o as O,p as q,r as G,s as K,t as Q,u as U,v as X,x as Z,y as ee}from"./ContentCommentsChrome-CrY8__p1.js";import{n as te,t as ae}from"./EmojiPicker-BHtnFLJX.js";import{t as re}from"./HomeSidebar-DrSTDTMg.js";import{t as se}from"./ContentWithSidebar-JxtdEv-g.js";import{t as ne}from"./article-BPGeFQcq.js";import{n as ie,t as oe}from"./leadingNumericId-BFZHu3T2.js";import{t as le}from"./scrollToCommentHash-D4-qVugo.js";var de=e(t(),1),ce=s(),me=()=>(0,ce.jsxs)("div",{className:"flow w-full overflow-hidden bg-white dark:bg-gray-800 relative rounded-lg border border-gray-200 dark:border-gray-700",children:[(0,ce.jsxs)("div",{className:"px-4 pt-4 pb-3 border-b border-gray-100 dark:border-gray-700",children:[(0,ce.jsx)("div",{className:"h-5 w-3/4 max-w-md bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),(0,ce.jsxs)("div",{className:"flex gap-3 mt-3",children:[(0,ce.jsx)("div",{className:"h-3.5 w-24 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),(0,ce.jsx)("div",{className:"h-3.5 w-28 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})]})]}),(0,ce.jsx)("div",{className:"px-4 py-4",children:(0,ce.jsxs)("div",{className:"space-y-2",children:[(0,ce.jsx)("div",{className:"h-4 w-full bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),(0,ce.jsx)("div",{className:"h-4 w-4/5 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"}),(0,ce.jsx)("div",{className:"h-4 w-1/2 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})]})})]}),he=e=>{const[t,s]=(0,de.useState)([{id:-1,message:"",author:"",authorId:-1,commentDate:"",country:"",parentId:-1,icons:[]}]),{notifySuccess:i,notifyError:o}=S(),[l,d]=(0,de.useState)(""),[h,u]=(0,de.useState)({state:!1,commentId:-1}),[x,p]=(0,de.useState)(""),[g,T]=(0,de.useState)("-1"),[M,D]=(0,de.useState)(!0),{user:F,adminEdit:Z}=m(),[re,se]=(0,de.useState)({id:"",title:"",htmlContent:"",author:"",authorId:"",authorCountry:"",articleDate:"",isNew:!1,commentsNumber:"",icons:{isMapper:!1,isRecordHolder:!1,isLjRecordHolder:!1,isMovieMaker:!1,isAdmin:!1,isManagement:!1,isTournamentRank1:!1,isTournamentRank2:!1,isTournamentRank3:!1,isVip:!1,hasBirthday:!1,isBanned:!1,isCommentBanned:!1,isSubmitBanned:!1}}),[ie,oe]=(0,de.useState)(e.initExpanded),he=(0,de.useRef)(null),ue=(0,de.useRef)(null),xe=(0,de.useRef)(null),pe=()=>{oe(!ie),ie&&T("-1")},ge=Boolean(F?.roles?.some(e=>[c.Admin,c.HeadAdmin,c.HeadManagement,c.TechnicalManagement,c.Ceo,c.Coo,c.Cto].includes(e))),ye=async(e,a=!1)=>{F&&e&&ne.deleteArticleComment(e.toString(),a).then(()=>{if(a)s(t=>t.filter(t=>t.id!==e)),i("Comment hidden from everyone");else{const a=t.find(t=>t.id===e);a&&(a.message="<deleted>",i("Comment deleted"))}}).catch(e=>{o(e)})},je=(e,t)=>{u(a=>a.commentId===t?{state:!a.state,commentId:t,commentMessage:e}:{state:!0,commentId:t,commentMessage:""})},fe=e=>{p(e.target.value)},be=e=>{const{newValue:t,newStart:a,newEnd:r}=te(ue.current,e,x);p(t),ue.current&&(ue.current.focus(),ue.current.setSelectionRange(a,r))},ve=async(e,t,a,r)=>{r.preventDefault(),""!==t&&e&&ne.postArticleComment(e,t,a).then(()=>{ne.getArticleComments(e).then(e=>{const t=e.data;s(t),d(""),p(""),je("",-1),i("Comment written")})}).catch(e=>{o(e)})},Ne=e=>{e&&(String(g)===String(e)?T("-1"):(T(String(e)),(async e=>{try{s((await ne.getArticleComments(e)).data)}catch(t){o(t)}})(e)))}
1,we=null!=e.article?.id&&""!==e.article.id&&-1!==e.article.id?String(e.article.id):"";(0,de.useEffect)(()=>{null!=e.article&&(se(t=>({...t,...e.article,isNew:e.article?.isNew??t.isNew,icons:e.article?.icons??t.icons})),D(!we))},[we,e.article]),(0,de.useEffect)(()=>{if(!e.initExpanded||!we)return;T(we);let t=!1;return ne.getArticleComments(we).then(e=>{t||s(e.data)}).catch(e=>{t||o(e)}),()=>{t=!0}},[e.initExpanded,we,o]),(0,de.useEffect)(()=>{if(1===t.length&&-1===t[0].id)return;const e=void 0===globalThis.location?"":globalThis.location.hash;e.startsWith("#comment-")&&xe.current!==e&&le(100)&&(xe.current=e)},[t]);const ke=de.useCallback(()=>{const e=`${globalThis.location.origin}/blog/${re.id}`;navigator.clipboard.writeText(e).then(()=>{i("Link copied to clipboard",3500)}).catch(()=>{})},[re.id,i]),Ce=de.useCallback((e,r,s=0)=>(0,ce.jsx)(ee,{level:s,children:t?.filter(e=>e.parentId===r).map(t=>(0,ce.jsx)(a,{as:"div",appear:!0,enter:"transition-all duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"transition-opacity duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,ce.jsxs)("div",{className:"mt-2 first:mt-0",children:[(0,ce.jsxs)("div",{id:`comment-${t.id}`,className:`${K} ${L}`,children:[(0,ce.jsxs)("div",{className:G,children:[(0,ce.jsx)("div",{className:"min-w-0 text-xs",children:(0,ce.jsx)(E,{id:t.authorId,name:t.author,country:t.country,roleIcons:t.icons})}),(0,ce.jsx)("span",{className:J,children:t.commentDate})]}),(0,ce.jsxs)("div",{className:$,children:[(0,ce.jsx)("p",{className:O,children:t.message.replaceAll("\\\\r\\\\n","\n").replaceAll("\\r\\n","\n")}),(0,ce.jsxs)("div",{className:Q,children:[F&&(0,ce.jsx)("button",{type:"button",onClick:()=>je(x,t.id),className:"inline-flex h-6 min-w-[1.5rem] items-center justify-center rounded px-0.5 text-[10px] font-medium leading-none text-gray-600 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-orange-400/80 dark:text-gray-400 dark:focus-visible:ring-orange-500/60","aria-label":"Reply to this comment",children:(0,ce.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,ce.jsx)(y,{className:"h-3 w-3"}),"Reply"]})}),(0,ce.jsxs)(C,{requiredRoles:[c.Admin,c.Moderator,c.HeadAdmin,c.Ceo,c.Coo,c.Cto,c.HeadManagement,c.Management,c.TechnicalManagement],matchAll:!1,override:t.authorId===F?.userId,children:[ge&&Z&&(0,ce.jsx)(n,{title:"Delete and hide from everyone",children:(0,ce.jsx)("button",{type:"button",onClick:()=>ye(t.id,!0),"aria-label":"Hide comment from everyone",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-500 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-orange-400/80 dark:text-gray-400 dark:focus-visible:ring-orange-500/60",children:(0,ce.jsx)(b,{className:"h-3 w-3"})})}),(0,ce.jsx)(n,{title:"Delete (shows as deleted)",children:(0,ce.jsx)("button",{type:"button",onClick:()=>ye(t.id),"aria-label":"Delete comment",className:B,children:(0,ce.jsx)(f,{className:"h-3 w-3"})})})]})]})]})]}),(0,ce.jsx)(a,{as:"div",show:h.state&&h.commentId===t.id,enter:"transition-all duration-500",enterFrom:"opacity-0 max-h-0",enterTo:"opacity-100 max-h-[1000px]",leave:"transition-all duration-500",leaveFrom:"opacity-100 max-h-[1000px]",leaveTo:"opacity-0 max-h-0",children:(0,ce.jsx)("div",{className:W,children:(0,ce.jsx)("div",{className:q,children:(0,ce.jsxs)("div",{className:_,children:[(0,ce.jsx)("textarea",{ref:ue,rows:2,className:X,placeholder:`Reply to ${t.author}'s comment`,onChange:fe,value:x}),(0,ce.jsxs)("div",{className:"flex shrink-0 items-center justify-end gap-2 self-end",children:[(0,ce.jsx)(ae,{onEmojiSelect:be,ariaLabel:"Insert emoji"}),(0,ce.jsx)("button",{type:"button",disabled:""===x,onClick:()=>ve(e,x,t.id,event),className:V,children:"Reply"})]})]})})})}),Ce(e,t.id,s+1)]},t.id)},t.id))}),[t,F,x,h]);return M?(0,ce.jsx)(me,{}):(0,ce.jsxs)("div",{className:"flow w-full overflow-hidden bg-white dark:bg-gray-800 relative rounded-lg border border-gray-200 dark:border-gray-700",children:[(0,ce.jsxs)("header",{className:"px-4 pt-4 pb-3 border-b border-gray-100 dark:border-gray-700",children:[(0,ce.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,ce.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2",children:[(0,ce.jsx)("span",{className:"mt-0.5 inline-flex shrink-0 items-center rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-600 dark:bg-gray-700/80 dark:text-gray-300",children:"Short news"}),(0,ce.jsx)("h2",{dangerouslySetInnerHTML:{__html:R(re.title)},className:"min-w-0 flex-1 text-gray-900 dark:text-white font-semibold text-base leading-snug"})]}),!e.standalone&&(0,ce.jsx)(n,{title:ie?"Collapse":"Expand",TransitionComponent:r,children:(0,ce.jsx)("button",{type:"button",onClick:pe,className:"p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-orange-500 dark:hover:text-orange-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shrink-0","aria-label":ie?"Collapse":"Expand",children:(0,ce.jsx)(k,{className:"w-4 h-4"})})})]}),(0,ce.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-xs text-gray-500 dark:text-gray-400",children:[null!=re.authorId&&""!==re.authorId?(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)("span",{children:"By"}),(0,ce.jsx)(E,{id:re.authorId,name:re.author??"",country:re.authorCountry??null,roleIcons:re.icons})]}):(0,ce.jsx)("span",{children:"By \u2014"}),(0,ce.jsx)("time",{className:"tabular-nums",children:re.articleDate})]})]}),!e.standalone&&(0,ce.jsx)(a,{as:"div",show:!ie,enter:"transition-all duration-500",enterFrom:"opacity-0 max-h-0",enterTo:"opacity-100 max-h-[1000px]",leave:"transition-all duration-500",leaveFrom:"opacity-100 max-h-[1000px]",leaveTo:"opacity-0 max-h-0",children:(0,ce.jsx)(n,{title:"Expand article",TransitionComponent:r,children:(0,ce.jsx)("button",{type:"button",className:"w-full text-left cursor-pointer",onClick:pe,children:(0,ce.jsx)("div",{className:"px-4 py-3 max-h-[130px] overflow-hidden bg-gray-50/50 dark:bg-gray-800/50",children:(0,ce.jsx)(A,{isExpanded:!1,newsContent:re.htmlContent})})})})}),(0,ce.jsx)(a,{as:"div",show:ie||!0===e.standalone,enter:"transition-all duration-500",enterFrom:"opacity-0 max-h-0",enterTo:"opacity-100 max-h-[1000px]",leave:"transition-all duration-500",leaveFrom:"opacity-100 max-h-[1000px]",leaveTo:"opacity-0 max-h-0",children:(0,ce.jsx)("div",{className:"px-4 py-3 overflow-y-auto text-gray-700 dark:text-gray-300",children:(0,ce.jsx)(A,{isExpanded:!0,newsContent:re.htmlContent})})}),(0,ce.jsxs)("footer",{className:"px-4 py-3 border-t border-gray-100 dark:border-gray-700 transition-opacity duration-500 ease-in-out",children:[(0,ce.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[!e.standalone&&(0,ce.jsx)(n,{title:ie?"Collapse article":"Expand article",TransitionComponent:r,children:(0,ce.jsx)("button",{type:"button",onClick:pe,className:"p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-orange-500 dark:hover:text-orange-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors","aria-label":ie?"Collapse":"Expand",children:ie?(0,ce.jsx)(v,{className:"h-4 w-4"}):(0,ce.jsx)(w,{className:"h-4 w-4"})})}),(0,ce.jsxs)("div",{className:"flex items-center gap-2 "+(e.standalone?"w-full justify-end":""),children:[(0,ce.jsxs)("button",{type:"button",className:"flex items-center px-3 py-1.5 rounded-md text-sm text-white bg-orange-500 hover:bg-orange-600 dar
1k:bg-orange-600 dark:hover:bg-orange-700 transition-colors",onClick:()=>Ne(re.id),children:[(0,ce.jsx)(N,{className:"mr-1.5 h-4 w-4"}),re.commentsNumber]}),(0,ce.jsx)(n,{title:(0,ce.jsx)("span",{children:"Copy link to clipboard"}),TransitionComponent:r,children:(0,ce.jsx)("button",{type:"button",onClick:e=>(e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),ke(),!1),className:"p-1.5 rounded-md text-gray-500 dark:text-gray-400 hover:text-orange-500 dark:hover:text-orange-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors","aria-label":"Copy link",children:(0,ce.jsx)(j,{className:"w-5 h-5"})})})]})]}),(0,ce.jsx)(a,{as:"div",show:g===re.id,enter:"transition-all duration-500",enterFrom:"opacity-0 max-h-0",enterTo:"opacity-100 max-h-[1000px]",leave:"transition-all duration-500",leaveFrom:"opacity-100 max-h-[1000px]",leaveTo:"opacity-0 max-h-0",children:(0,ce.jsx)("div",{className:"mt-3 overflow-y-auto border-t border-gray-200 pt-3 opacity-100 transition-opacity duration-500 ease-in-out dark:border-gray-700",children:(0,ce.jsxs)("div",{className:H,children:[(0,ce.jsx)(P,{}),F?(0,ce.jsx)("form",{onSubmit:()=>ve(re.id,l,null,event),children:(0,ce.jsx)("div",{className:Y,children:(0,ce.jsxs)("div",{className:U,children:[(0,ce.jsx)("textarea",{ref:he,rows:2,className:X,placeholder:"Write a comment\u2026",onChange:e=>{d(e.target.value)},value:l}),(0,ce.jsxs)("div",{className:"flex shrink-0 items-center gap-2 self-end",children:[(0,ce.jsx)(ae,{onEmojiSelect:e=>{const{newValue:t,newStart:a,newEnd:r}=te(he.current,e,l);d(t),he.current&&(he.current.focus(),he.current.setSelectionRange(a,r))},ariaLabel:"Insert emoji"}),(0,ce.jsx)(I,{className:"!px-2.5 !py-1 !text-[11px] !font-medium min-w-0",text:"Submit"})]})]})})}):(0,ce.jsx)("p",{className:z,children:"You need to be logged in to post a comment."}),(0,ce.jsx)("div",{className:"mt-6",children:Ce(re.id,null)})]})})})]})]})};function ue(e){return e?{id:ie(e.id),title:ie(e.title),htmlContent:ie(e.htmlContent),author:ie(e.author),authorId:ie(e.authorId),authorCountry:ie(e.authorCountry),articleDate:ie(e.articleDate),commentsNumber:ie(e.commentsNumber),isNew:!0===e.isNew||"true"===e.isNew,icons:e.icons}:null}var xe={id:"",title:"",htmlContent:"",author:"",authorId:"",authorCountry:"",articleDate:"",commentsNumber:""};function pe({loaderData:e,params:t}){const a=D(e?.article?.title||""),r=D(e?.article?.htmlContent||""),s=g(e?.article?.htmlContent);return T({title:h(a||"Blog"),description:M(r||"Kreedz blog post."),url:`https://kreedz.com/blog/${t.id??""}`,type:"article",image:s})}var ge=i(()=>{const{id:e}=l(),t=o(),[a,r]=(0,de.useState)(()=>ue(t?.article)??xe),{notifyError:s}=S(),n=(0,de.useRef)(s);(0,de.useEffect)(()=>{n.current=s},[s]),(0,de.useEffect)(()=>{const a=ue(t?.article);if(a?.id)return void r(a);(async()=>{try{const t=oe(e);null!=t&&r(ue((await ne.getArticle(String(t))).data)??xe)}catch(t){n.current(t)}})()},[e,t]);const i=D(a.title),c=D(a.htmlContent),m=c.length>160?`${c.slice(0,157)}...`:c,h=`https://kreedz.com/blog/${e??""}`,y=x(g(a.htmlContent));return(0,ce.jsxs)(ce.Fragment,{children:[a.id&&(0,ce.jsxs)(d,{children:[(0,ce.jsx)("script",{type:"application/ld+json",children:JSON.stringify(p({headline:i,url:h,description:m,datePublished:a.articleDate,authorName:a.author,image:y}))}),(0,ce.jsx)("script",{type:"application/ld+json",children:JSON.stringify(u([{name:"Home",url:"https://kreedz.com/"},{name:i||"Blog",url:h}]))})]}),(0,ce.jsx)("div",{className:"space-y-8 pb-5",children:(0,ce.jsx)(se,{sidebar:(0,ce.jsx)(re,{}),children:(0,ce.jsx)(he,{initExpanded:!0,article:a,standalone:!0})})})]})});export{ge as default,pe as meta};
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.