import{a as J}from"./chunk-IG534TUB.mjs";import{a as q}from"./chunk-EV4I2B7B.mjs";import{a as z}from"./chunk-FSFL2CDH.mjs";import{a as G}from"./chunk-K35JDPQ6.mjs";import{a as Y}from"./chunk-3FC6O56G.mjs";import{a as V,b as X}from"./chunk-JCTDF5UL.mjs";import{a as Q}from"./chunk-ZVTL5GCC.mjs";import{a as H}from"./chunk-X332F2ZY.mjs";import{b as K}from"./chunk-EXHBXGDG.mjs";import{a as g}from"./chunk-66PCFZQY.mjs";import{a as F}from"./chunk-VAFUPSD5.mjs";import{a as W}from"./chunk-DUTRTT6Y.mjs";import{useRef as qe,useState as te,useTransition as ze}from"react";import{ClickableAvatar as Ge}from"@baseapp-frontend/design-system/components/web/avatars";import{Typography as ne}from"@mui/material";import Je from"next/link";import{useRouter as Ve}from"next/navigation";import{useRefetchableFragment as Xe}from"react-relay";import{jsx as m,jsxs as u}from"react/jsx-runtime";function v(e){"@babel/helpers - typeof";return v=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(e)}var ke=["actions"];function Z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Z(Object(n),!0).forEach(function(r){Ne(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ne(e,t,n){return(t=Ue(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ue(e){var t=Le(e,"string");return v(t)=="symbol"?t:t+""}function Le(e,t){if(v(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(v(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Me(e,t){if(e==null)return{};var n,r,a=We(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function y(e,t){return Qe(e)||He(e,t)||Ke(e,t)||Fe()}function Fe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ke(e,t){if(e){if(typeof e=="string")return ee(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ee(e,t):void 0}}function ee(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function He(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,a,i,l,p=[],s=!0,b=!1;try{if(i=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(p.push(r.value),p.length!==t);s=!0);}catch(c){b=!0,a=c}finally{try{if(!s&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(b)throw a}}return p}}function Qe(e){if(Array.isArray(e))return e}var re=function(t){var n,r,a,i,l,p=t.comment,s=t.currentThreadDepth,b=t.subscriptionsEnabled,c=t.onReplyClick,oe=t.CommentUpdateProps,ie=t.CommentsRepliesProps,h=t.ActionOverlayProps,R=t.enableDelete,me=R===void 0?!1:R,P=t.Timestamp,ae=P===void 0?F:P,O=t.CommentUpdate,le=O===void 0?Q:O,_=t.CommentReplyButton,se=_===void 0?G:_,j=t.CommentPinnedBadge,ue=j===void 0?q:j,w=t.CommentReactionButton,ce=w===void 0?z:w,D=t.profilePath,pe=D===void 0?"/profile":D,de=Xe(H,p),S=y(de,2),o=S[0],fe=S[1],ye=g(),ve=ye.setCommentReply,be=Ve(),T=qe(null),Ce=te(!1),I=y(Ce,2),he=I[0],x=I[1],ge=te(!1),$=y(ge,2),A=$[0],Re=$[1],Pe=Y({comment:o,onEdit:function(){return x(!0)}}),E=h??{},B=E.actions,Oe=B===void 0?Pe:B,_e=Me(E,ke),je=ze(),k=y(je,2),N=k[0],we=k[1],De=g(),Se=De.resetCommentReply,Te=K(),U=y(Te,2),Ie=U[0],xe=U[1],L="".concat(pe,"/").concat(o==null||(n=o.user)===null||n===void 0?void 0:n.pk),$e=function(){A||we(function(){fe({isRepliesExpanded:!0},{fetchPolicy:"store-or-network",onComplete:function(M){M?console.error(M):Re(!0)}})})},Ae=function(){var f;c?.(),ve({commentItemRef:T,inReplyToId:o.id,name:(f=o.user)===null||f===void 0?void 0:f.fullName}),$e()},Ee=function(){return he?m(le,C({comment:o,onCancel:function(){return x(!1)}},oe)):m(ne,{variant:"body2",sx:{whiteSpace:"pre-wrap",wordBreak:"normal",overflowWrap:"anywhere"},children:o.body})};if(!o)return null;var Be=function(){Ie({variables:{id:o.id}}),Se()};return u("div",{children:[m(V,{currentThreadDepth:s,children:m(W,C(C({actions:Oe,showDeleteButton:me&&o.canDelete,handleDeleteItem:Be,isDeletingItem:xe,title:"Comment"},_e),{},{ref:T,children:u(X,{children:[m(Ge,{width:40,height:40,alt:(r=(a=o.user)===null||a===void 0?void 0:a.fullName)!==null&&r!==void 0?r:"Comment's user avatar",src:(i=o.user)===null||i===void 0||(i=i.avatar)===null||i===void 0?void 0:i.url,onClick:function(){return be.push(L)}}),u("div",{className:"grid gap-3",children:[u("div",{className:"grid grid-cols-1 justify-start",children:[u("div",{className:"grid grid-cols-[repeat(2,max-content)] items-center gap-2",children:[m(Je,{href:L,children:m(ne,{variant:"subtitle2",children:(l=o.user)===null||l===void 0?void 0:l.fullName})}),m(ue,{isPinned:o.isPinned})]}),Ee()]}),u("div",{className:"flex justify-between",children:[u("div",{className:"grid grid-cols-[repeat(2,max-content)] gap-4",children:[m(ce,{target:o}),m(se,{onReply:Ae,isLoadingReplies:N,commentId:o.id,totalCommentsCount:o.commentsCount.total})]}),m(ae,{date:o.created})]})]})]})}))}),A&&!N&&m(J,C({target:o,currentThreadDepth:s+1,subscriptionsEnabled:b,onReplyClick:c,CommentItem:re},ie),"replies-of-".concat(o.id))]})},ft=re;export{ft as a};
//# sourceMappingURL=chunk-4X2GOTSI.mjs.map