PageSourceSearch

https://p1.prosperna.com/assets/ViewComment-1e7FD0cR.js

js prosperna.com collected 2026-09-26 09:23:24 UTC 14,605 bytes, 1 lines download raw bytes

1import{ax as le,j as e,O as j,R as oe,I as T,dl as me,cs as de,r as x,F as N,a as v,X as ce,S as ue,Q as g,cq as xe,f as S,c as $,T as H}from"./index-CSsSX63M.js";import{S as y}from"./utilities-CoYgNjuY.js";import{u as fe}from"./storeUtil-hNht0EjO.js";import{B as b}from"./index-CDbO1Jay.js";import{T as w,R as he,D as pe}from"./DeleteCommentDialog-9k-FoJgR.js";import{f as E}from"./formatDate-Bj_J6jZV.js";import{I as ge}from"./Image-BRC7Tz3c.js";import{B as je}from"./BrokenImageOutlined-RGLHn_iq.js";import{B as A}from"./Badge-s5mfaXBU.js";import{O as be,P as I}from"./OverlayTrigger-DxqfTLm5.js";import{H as _e}from"./HelpOutlined-CNQRJ5wk.js";import{A as ve}from"./ArrowBack-C2ef7Myz.js";import"./usePaginatedQuery-BTZTmgET.js";import"./Dropdown-COFT23os.js";import"./SSRProvider-Bmat4lxH.js";import"./NavContext-DA5l1Ihg.js";import"./mergeOptionsWithPopperConfig-Kl50-gi5.js";import"./useIsomorphicEffect-DOgrT-SO.js";import"./InputGroupContext-Dv2-VhGw.js";import"./NavbarContext-QfppLQS8.js";import"./MoreHoriz-qyBI47S_.js";import"./warning-Bu5snHln.js";import"./useTimeout-DMefeYIR.js";const Ne=le(e.jsx("path",{d:"M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11"}),"Reply"),Ce=({blogData:s,menuItems:t})=>s?e.jsx(j,{className:"mb-4",children:e.jsx(j.Body,{children:e.jsxs(oe,{className:"d-flex flex-row",children:[e.jsxs(T,{xs:10,className:"mb-2 d-flex flex-column flex-md-row align-items-start",children:[e.jsx("div",{className:"d-flex flex-row align-items-start pb-2 pb-md-0 pe-md-2",children:s.share_image?e.jsx(ge,{src:s.share_image,alt:s.title,className:"me-2 object-cover border border-1 border-gray-300 rounded",height:100,width:150,style:{objectPosition:"center"}}):e.jsx("div",{className:"d-flex align-items-center justify-content-center rounded bg-light",style:{width:"100px",height:"100px",minWidth:"100px",minHeight:"100px"},children:e.jsx(je,{className:"text-muted",sx:{fontSize:"50px"}})})}),e.jsxs("div",{className:"d-flex flex-column align-items-start",children:[e.jsxs("h6",{className:"mb-1",children:["Blog Post",e.jsx("span",{className:`ms-2 badge ${s.is_published?"tag-bg-success tag-text-success":"tag-bg-failed tag-text-failed"}`,children:s.is_published?"Published":"Drafts"})]}),e.jsxs("p",{className:"mb-0 d-flex flex-column align-items-start",children:[e.jsx("strong",{children:s.title}),e.jsx("span",{className:"text-muted small",children:E(s.created_at)}),e.jsx("p",{className:"mb-0 text-muted",children:me(de(s.meta_description,300)).replace(/<[^>]*>?/g,"")})]})]})]}),e.jsx(T,{xs:2,className:"d-flex align-items-start justify-content-end",children:e.jsx("div",{className:"d-flex align-items-center",children:e.jsx(w,{row:{index:0,original:s},idPrefix:"blog",menuItems:t,align:"start"})})})]})})}):e.jsx(j,{className:"mb-4",children:e.jsx(j.Body,{children:e.jsx("p",{className:"mb-0 text-muted",children:"The article is deleted."})})}),D=({initialValue:s,onSubmit:t,onCancel:r})=>{const[n,o]=x.useState(s||""),[l,m]=x.useState("");x.useEffect(()=>{o(s||"")},[s]);const d=c=>{if(c.preventDefault(),m(""),!n.trim()){m("Comment cannot be empty");return}if(n.length>5e3){m("Comment cannot exceed 5000 characters");return}t({comment:n})};return e.jsxs(N,{onSubmit:d,children:[e.jsxs(N.Group,{className:"mb-2",children:[e.jsx(N.Control,{as:"textarea",rows:3,value:n,onChange:c=>o(c.target.value),maxLength:5e3,required:!0}),e.jsxs(N.Text,{className:"text-muted",children:[n.length,"/5000 characters"]}),l&&e.jsx("div",{className:"text-danger small",children:l})]}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(v,{type:"submit",variant:"primary",size:"sm",children:"Save"}),e.jsx(v,{type:"button",variant:"cancel",size:"sm",onClick:r,children:"Cancel"})]})]})},Se=({comment:s,isOwner:t,isEditing:r,editFormData:n,onEditClick:o,onDeleteClick:l,onReplyClick:m,onEditSubmit:d,onEditCancel:c,onToggleComment:u,toggleComment:a,disableReply:f=!1})=>{const i=s.show_comment,p=x.useMemo(()=>[{id:"edit",label:"Edit",onClick:()=>{o()}},{id:i?"unpublish":"publish",label:i?"Unpublish":"Publish",onClick:()=>{u()},disabled:a==null?void 0:a.isLoading,isLoading:a==null?void 0:a.isLoading,loadingLabel:i?"Unpublishing...":"Publishing..."},{id:"delete",label:"Delete",onClick:()=>{l()}}],[o,l,u,i,a]);return e.jsx(j,{className:"mb-4",children:e.jsxs(j.Body,{children:[e.jsxs("div",{className:"d-flex justify-content-between align-items-start mb-3",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[s.author.first_name," ",s.author.last_name]}),e.jsxs("span",{className:"text-muted",children:[s.is_edited&&e.jsx(A,{bg:"primary",className:"ms-2",children:"edited"}),!s.show_comment&&e.jsx("span",{className:`ms-2 badge ${ce("badge",{"tag-text-success":i,"tag-bg-success":i,"tag-bg-failed":!i,"tag-text-failed":!i})}`,children:s.show_comment?"Published":"Unpublished"})]}),e.jsxs("div",{className:"text-muted small mt-1",children:[s.author.email," | ",E(s.created_at)," "]})]}),t&&e.jsx("div",{className:"d-flex gap-2",children:e.jsx(w,{row:{index:0,original:s},idPrefix:"comment",menuItems:p,align:"start"})})]}),r?e.jsx(D,{initialValue:n.comment,onSubmit:d,onCancel:c}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-3",children:s.comment}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(v,{variant:"primary",size:"sm",onClick:m,disabled:!i||f,children:[e.jsx(Ne,{fontSize:"small",className:"me-1"}),"Reply"]}),(!i||f)&&e.jsx(be,{trigger:["hover","focus"],placement:"top",overlay:e.jsx(I,{className:"section-popover",children:e.jsx(I.Body,{className:"text-white",children:f?"Cannot reply; the article is deleted.":"This comment is unpublished, please publish it first before replying."})}),children:e.jsx(_e,{className:"text-black ms-2",fontSize:"small"})})]})]})]})})},ye=({onBack:s})=>e.jsx("div",{className:"d-flex align-items-center justify-content-between mb-3",children:e.jsxs("div",{className:"d-flex align-items-center gap-3",children:[e.jsx(v,{variant:"link",onClick:s,children:e.jsx(ve,{})}),e.jsx("h4",{className:"mb-0",children:"View Comment"})]})}),we=()=>e.jsx(y,{className:"mt-4",children:e.jsx("div",{className:"d-flex justify-content-center align-items-center min-height-400",children:e.jsx(ue,{animation:"border"})})}),Ee=({onBack:s})=>e.jsx(y,{className:"mt-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h4",{children:"Comment not found"}),e.jsx(v,{variant:"primary",onClick:s,children:"Back to Comments"})]})}),U=({reply:s,depth:t=0,blogPostId:r,userEmail:n,editingId:o,editFormData:l,onEditClick:m,onDeleteClick:d,onEditSubmit:c,onEditCancel:u})=>{const f=o===s.id,i=x.useMemo(()=>[{id:"edit",label:"Edit",onClick:()=>{m()}},{id:"delete",label:"Delete",onClick:()=>{d()}}],[m,d]);return e.jsxs("div",{className:"reply-item mb-3",style:{marginLeft:`${t*30}
1px`,borderLeft:"2px solid #dee2e6"},children:[e.jsx(j,{className:"border-0 shadow-sm",children:e.jsxs(j.Body,{children:[e.jsxs("div",{className:"d-flex justify-content-between align-items-start mb-2",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[s.author.first_name," ",s.author.last_name]}),e.jsx("span",{className:"text-muted",children:s.is_edited&&e.jsx(A,{bg:"primary",className:"ms-2",children:"edited"})}),e.jsxs("div",{className:"text-muted small mt-1",children:[s.author.email," | ",E(s.created_at)," "]})]}),e.jsx("div",{className:"d-flex gap-2",children:e.jsx(w,{row:{index:0,original:s},idPrefix:"reply",menuItems:i,align:"start"})})]}),f?e.jsx(D,{initialValue:l.comment,onSubmit:c,onCancel:u}):e.jsx("p",{className:"mb-2",children:s.comment})]})}),s.replies&&s.replies.length>0&&e.jsx("div",{className:"mt-2",children:s.replies.map(p=>e.jsx(U,{reply:p,depth:t+1,blogPostId:r,userEmail:n,editingId:o,editFormData:l,onEditClick:m,onDeleteClick:d,onEditSubmit:c,onEditCancel:u},p.id))})]})},Re=({replies:s,blogPostId:t,userEmail:r,editingId:n,editFormData:o,setEditingId:l,setCommentToDelete:m,setDeleteWarning:d,onEditSubmit:c})=>{if(!s||s.length===0)return null;const u=i=>{l(i.id)},a=i=>{m({id:i.id,blog_post_id:t}),d(!0)},f=(i,p)=>{c(i.id,p)};return e.jsxs("div",{className:"mb-4",children:[e.jsxs("h5",{className:"mb-3",children:["Replies (",s.length,")"]}),s.map(i=>e.jsx(U,{reply:i,depth:0,blogPostId:t,userEmail:r,editingId:n,editFormData:o,onEditClick:()=>u(i),onDeleteClick:()=>a(i),onEditSubmit:p=>f(i,p),onEditCancel:()=>l(null)},i.id))]})},q=(s,t)=>{if(!s||!t)return null;for(const r of s){if(r.id===t)return r;if(r.replies&&r.replies.length>0){const n=q(r.replies,t);if(n)return n}}return null},z=(s,t)=>{if(!s||!t)return null;for(const r of s){if(r.id===t)return r;if(r.replies&&r.replies.length>0){const n=z(r.replies,t);if(n)return n}}return null},ke=s=>{var n,o,l,m;if(!((n=s.first_name)!=null&&n.trim()))return{isValid:!1,errorMessage:"First name is required"};if(!((o=s.last_name)!=null&&o.trim()))return{isValid:!1,errorMessage:"Last name is required"};if(!((l=s.email)!=null&&l.trim()))return{isValid:!1,errorMessage:"Email is required. Please check your profile settings."};const t=s.email.trim();return t.length>254?{isValid:!1,errorMessage:"Invalid email format in profile"}:/^[^\s@]{1,64}@[^\s@]+\.[^\s@]{1,63}$/.test(t)?(m=s.comment)!=null&&m.trim()?s.comment.length>5e3?{isValid:!1,errorMessage:"Reply cannot exceed 5000 characters"}:{isValid:!0,errorMessage:null}:{isValid:!1,errorMessage:"Reply text is required"}:{isValid:!1,errorMessage:"Invalid email format in profile"}},Be=s=>{const t=ke(s);return t.isValid?!0:(g(!1,"",t.errorMessage),!1)},Me=()=>{const{comment_id:s}=xe(),{data:t,isFetching:r}=b.useAllComments(),{data:n}=b.useGetBlogs({}),{data:o}=b.useGetDraftBlogs({}),l=x.useMemo(()=>!t||!s?null:q(t,s),[t,s]),{blogData:m,blogStatus:d}=x.useMemo(()=>{if(!l)return{blogData:null,blogStatus:"unknown"};const c=(n==null?void 0:n.blogs)??[],u=(o==null?void 0:o.blogs)??[],a=c.find(i=>String(i==null?void 0:i.id)===String(l.blog_post_id));if(a)return{blogData:a,blogStatus:a!=null&&a.is_drafted?"draft":"published"};const f=u.find(i=>String(i==null?void 0:i.id)===String(l.blog_post_id));return f?{blogData:f,blogStatus:"draft"}:{blogData:null,blogStatus:"unknown"}},[n,o,l]);return{comment:l,blogData:m,blogStatus:d,isFetching:r}},Fe=(s,t)=>x.useMemo(()=>{if(!s)return[];const r=[];return s.is_published&&r.push({id:"view",label:"View",eventKey:"1",onClick:n=>{n.preventDefault(),s.slug&&t&&window.open(`${t}/blogs/${s.slug}`,"_blank","noopener,noreferrer")}}),s.slug&&r.push({id:"edit",label:"Edit",eventKey:"2",to:`${S.blogs.linkToRoute}/${s.slug}`}),r},[s,t]),Le=({comment:s,commentToDelete:t,setReplyingTo:r,setReplyFormData:n,setDeleteWarning:o,setCommentToDelete:l,setEditingId:m,setEditFormData:d})=>{const c=$(),u=b.useCreateReply({onSuccess:i=>{g(!0,"",i.message),r(null),n({first_name:"",last_name:"",email:"",comment:""})},onError:i=>{g(!1,"",i)}}),a=b.useDeleteSingleBlogComment({onSuccess:i=>{g(!0,"",i.message),o(!1),(t==null?void 0:t.id)===(s==null?void 0:s.id)&&c(`${S.blogs.linkToRoute}?tab=comments`),l(null)},onError:i=>{g(!1,"",i),o(!1),l(null)}}),f=b.useUpdateBlogComment({onSuccess:i=>{g(!0,"",i.message),m(null),d({comment:""})},onError:i=>{g(!1,"",i)}});return{createReply:u,deleteSingleComment:a,updateComment:f}},Ve=s=>{const{data:t}=H.useGetUserProfile(),[r,n]=x.useState({first_name:"",last_name:"",email:"",comment:""});return x.useEffect(()=>{if(s&&(t!=null&&t.user_profile)){const m=t.user_profile;n({first_name:m.first_name||"",last_name:m.last_name||"",email:m.email||"",comment:""})}
1else s&&n({first_name:"",last_name:"",email:"",comment:""})},[s,t]),{replyFormData:r,setReplyFormData:n,validate:()=>Be(r),reset:()=>{n({first_name:"",last_name:"",email:"",comment:""})}}},Pe=(s,t)=>{const[r,n]=x.useState({comment:""});return x.useEffect(()=>{if(!t||!s)return;if(t===s.id){n({comment:s.comment||""});return}const l=s.replies?z(s.replies,t):null;l&&n({comment:l.comment||""})},[t,s]),{editFormData:r,setEditFormData:n,reset:()=>{n({comment:""})}}},rs=()=>{var P;const s=$(),t=fe(),[r,n]=x.useState(null),[o,l]=x.useState(null),[m,d]=x.useState(!1),[c,u]=x.useState(null),{comment:a,blogData:f,blogStatus:i,isFetching:p}=Me(),{data:G=[],isFetching:O,isError:K}=b.useGetReplies(a==null?void 0:a.blog_post_id,a==null?void 0:a.id),W=Fe(f,t),{replyFormData:_,setReplyFormData:R,validate:Q}=Ve(r),{editFormData:k,setEditFormData:X}=Pe(a,o),{createReply:B,deleteSingleComment:M,updateComment:F}=Le({comment:a,commentToDelete:c,setReplyingTo:n,setReplyFormData:R,setDeleteWarning:d,setCommentToDelete:u,setEditingId:l,setEditFormData:X}),L=b.useShowBlogComment({onSuccess:h=>{g(!0,"",h.message)},onError:h=>{g(!1,"",h)}}),{data:C}=H.useGetUserProfile(),J=(P=C==null?void 0:C.user_profile)==null?void 0:P.email,V=()=>{s(`${S.blogs.linkToRoute}?tab=comments`)},Y=()=>{if(!r||!a||!Q())return;const h={blog_post_id:a.blog_post_id,comment_id:r.id,payload:{first_name:_.first_name,last_name:_.last_name,email:_.email,comment:_.comment}};B.mutate(h)},Z=()=>{l(a.id)},ee=()=>{u({id:a.id,blog_post_id:a.blog_post_id}),d(!0)},se=()=>{n({id:a.id,blog_post_id:a.blog_post_id})},te=h=>{F.mutate({comment_id:a.id,payload:h})},ie=(h,re)=>{F.mutate({comment_id:h,payload:re})},ne=()=>{if(!a)return;const h={comment_id:a.id};L.mutate(h)};if(p)return e.jsx(we,{});if(!a)return e.jsx(Ee,{onBack:V});const ae=o===a.id;return e.jsxs(y,{className:"mt-4",children:[e.jsx(ye,{onBack:V}),e.jsx(Ce,{blogData:f,host:t,menuItems:W}),e.jsx(Se,{comment:a,isOwner:!0,isEditing:ae,editFormData:k,onEditClick:Z,onDeleteClick:ee,onReplyClick:se,onEditSubmit:te,onEditCancel:()=>l(null),onToggleComment:ne,toggleComment:L,disableReply:i==="unknown"}),i==="unknown"?e.jsx("div",{className:"text-center py-3",children:e.jsx("span",{className:"text-muted",children:"Replies unavailable. The blog may have been deleted or unpublished."})}):O?e.jsx("div",{className:"text-center py-3",children:e.jsx("span",{className:"text-muted",children:"Loading replies..."})}):K?e.jsx("div",{className:"text-center py-3",children:e.jsx("span",{className:"text-muted",children:i==="draft"?"Replies unavailable. This blog is unpublished (draft).":"Replies unavailable."})}):e.jsx(Re,{replies:G,blogPostId:a.blog_post_id,userEmail:J,editingId:o,editFormData:k,setEditingId:l,setCommentToDelete:u,setDeleteWarning:d,onEditSubmit:ie}),e.jsx(he,{show:!!r,onHide:()=>n(null),replyFormData:_,setReplyFormData:R,onSubmit:Y,isLoading:B.isLoading}),e.jsx(pe,{showConfirmation:m,handleHideConfirmation:()=>{d(!1),u(null)},handleConfirm:()=>{if(c){const h={comment_id:c.id};M.mutate(h)}},isLoading:M.isLoading,confirmButtonId:"comment-view-delete-confirm-button",cancelButtonId:"comment-view-delete-cancel-button"})]})};export{rs as default};

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.