1import{j as e}from"./vendor-query-BHcDM7rw.js";import{r as v}from"./vendor-react-DHPG0S42.js";import{C as b,a as I,b as X,d as R}from"./card-txxsFi8B.js";import{B as y}from"./button-DRDlISWS.js";import{T as J}from"./textarea-DLk_SQy4.js";import{A as Y,b as z,a as L}from"./avatar-BtX-O-RE.js";import{B as O}from"./badge-CeptlhxZ.js";import{J as p}from"./vendor-ui-BEbuZsVX.js";import{u as G,s as _}from"./index-B6gMI8qg.js";import{g as k}from"./imageUtils-Df--LVGr.js";import{S as K}from"./shield-DPbGT-eM.js";import{T as A}from"./Navbar-Bq020x-r.js";import{M as Q}from"./message-square-CGFl2opP.js";import{L as U}from"./loader-circle-Cge3CHC4.js";import{S as V}from"./send-D6VaOBN6.js";import{t as m,c as W,d as Z,e as ee,a as B,f as q,h as D,g as se}from"./en-US-B4N5_QyQ.js";import{S as te}from"./star-D8oMQa2e.js";import"./vendor-supabase-CseCC2Es.js";import"./supabase-E19SSUmj.js";import"./check-1S43UZIh.js";import"./user-DVf5dCms.js";import"./briefcase-BZz3Ngt4.js";import"./mail-CcV2vjvx.js";function C(t,r){const n=m(t),o=m(r),a=n.getTime()-o.getTime();return a<0?-1:a>0?1:a}function re(t){return W(t,Date.now())}function ae(t,r){const n=m(t),o=m(r),a=n.getFullYear()-o.getFullYear(),u=n.getMonth()-o.getMonth();return a*12+u}function ne(t){return r=>{const o=(t?Math[t]:Math.trunc)(r);return o===0?0:o}}function ie(t,r){return+m(t)-+m(r)}function oe(t){const r=m(t),n=r.getMonth();return r.setFullYear(r.getFullYear(),n+1,0),r.setHours(23,59,59,999),r}function ce(t){const r=m(t);return+Z(r)==+oe(r)}function le(t,r){const n=m(t),o=m(r),a=C(n,o),u=Math.abs(ae(n,o));let f;if(u<1)f=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-a*u);let i=C(n,o)===-a;ce(m(t))&&u===1&&C(t,o)===1&&(i=!1),f=a*(u-Number(i))}return f===0?0:f}function me(t,r,n){const o=ie(t,r)/1e3;return ne(n?.roundingMethod)(o)}function de(t,r,n){const o=se(),a=n?.locale??o.locale??ee,u=2520,f=C(t,r);if(isNaN(f))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:f});let j,d;f>0?(j=m(r),d=m(t)):(j=m(t),d=m(r));const g=me(d,j),M=(B(d)-B(j))/1e3,l=Math.round((g-M)/60);let h;if(l<2)return n?.includeSeconds?g<5?a.formatDistance("lessThanXSeconds",5,i):g<10?a.formatDistance("lessThanXSeconds",10,i):g<20?a.formatDistance("lessThanXSeconds",20,i):g<40?a.formatDistance("halfAMinute",0,i):g<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):l===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",l,i);if(l<45)return a.formatDistance("xMinutes",l,i);if(l<90)return a.formatDistance("aboutXHours",1,i);if(l<q){const x=Math.round(l/60);return a.formatDistance("aboutXHours",x,i)}else{if(l<u)return a.formatDistance("xDays",1,i);if(l<D){const x=Math.round(l/q);return a.formatDistance("xDays",x,i)}else if(l<D*2)return h=Math.round(l/D),a.formatDistance("aboutXMonths",h,i)}if(h=le(d,j),h<12){const x=Math.round(l/D);return a.formatDistance("xMonths",x,i)}else{const x=h%12,N=Math.trunc(h/12);return x<3?a.formatDistance("aboutXYears",N,i):x<9?a.formatDistance("overXYears",N,i):a.formatDistance("almostXYears",N+1,i)}}function ue(t,r){return de(t,re(t),r)}const ze=({isAdmin:t=!1})=>{const{user:r,profile:n}=G(),[o,a]=v.useState([]),[u,f]=v.useState(!0),[i,j]=v.useState(!1),[d,g]=v.useState(""),[M,l]=v.useState(5),[h,x]=v.useState([]);v.useEffect(()=>{N(),t&&S()},[t]);const N=async()=>{try{const{data:s,error:c}=await _.from("resume_builder_comments").select("*").eq("is_approved",!0).order("is_featured",{ascending:!1}).order("created_at",{ascending:!1}).limit(20);if(c)throw c;a(s||[])}catch(s){console.error("Error fetching comments:",s)}finally{f(!1)}},S=async()=>{try{const{data:s,error:c}=await _.from("resume_builder_comments").select("*").eq("is_approved",!1).order("created_at",{ascending:!1});if(c)throw c;x(s||[])}catch(s){console.error("Error fetching pending comments:",s)}},P=async()=>{if(!r){p.error("Please login to leave a review");return}if(!d.trim()){p.error("Please write a comment");return}j(!0);try{const{error:s}=await _.from("resume_builder_comments").insert({user_id:r.id,user_name:n?.name||r.email?.split("@")[0]||"Anonymous",user_avatar:n?.avatar_url,comment:d.trim(),rating:M,is_approved:!1});if(s)throw s;
1p.success("Thank you! Your review will appear after moderation."),g(""),l(5)}catch(s){console.error("Error submitting comment:",s),p.error(s.message||"Failed to submit review")}finally{j(!1)}},H=async s=>{try{const{error:c}=await _.from("resume_builder_comments").update({is_approved:!0}).eq("id",s);if(c)throw c;p.success("Comment approved"),N(),S()}catch(c){console.error("Error approving comment:",c),p.error("Failed to approve comment")}},E=async s=>{try{const{error:c}=await _.from("resume_builder_comments").delete().eq("id",s);if(c)throw c;p.success("Comment deleted"),N(),t&&S()}catch(c){console.error("Error deleting comment:",c),p.error("Failed to delete comment")}},$=async(s,c)=>{try{const{error:w}=await _.from("resume_builder_comments").update({is_featured:c}).eq("id",s);if(w)throw w;p.success(c?"Comment featured":"Comment unfeatured"),N()}catch(w){console.error("Error featuring comment:",w),p.error("Failed to update comment")}},T=(s,c=!1,w="h-4 w-4")=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(F=>e.jsx(te,{className:`${w} ${F<=s?"fill-yellow-400 text-yellow-400":"text-muted-foreground/30"} ${c?"cursor-pointer hover:scale-110 transition-transform":""}`,onClick:()=>c&&l(F)},F))});return e.jsxs("div",{className:"space-y-6",children:[t&&h.length>0&&e.jsxs(b,{className:"border-yellow-500/50 bg-yellow-500/5",children:[e.jsx(I,{className:"pb-3",children:e.jsxs(X,{className:"text-lg flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5 text-yellow-500"}),"Pending Reviews (",h.length,")"]})}),e.jsx(R,{className:"space-y-3",children:h.map(s=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsxs(Y,{className:"h-8 w-8",children:[e.jsx(z,{className:"text-xs bg-primary/10 text-primary",children:s.user_name.charAt(0).toUpperCase()}),s.user_avatar&&e.jsx(L,{src:k(s.user_avatar,32),alt:s.user_name||"User avatar",loading:"lazy",decoding:"async"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-sm",children:s.user_name}),T(s.rating)]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.comment}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(y,{size:"sm",variant:"default",onClick:()=>H(s.id),children:"Approve"}),e.jsxs(y,{size:"sm",variant:"destructive",onClick:()=>E(s.id),children:[e.jsx(A,{className:"h-3 w-3 mr-1"}),"Delete"]})]})]})]},s.id))})]}),e.jsxs(b,{children:[e.jsx(I,{className:"pb-3",children:e.jsxs(X,{className:"text-lg flex items-center gap-2",children:[e.jsx(Q,{className:"h-5 w-5 text-primary"}),"Share Your Experience"]})}),e.jsx(R,{className:"space-y-4",children:r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rating:"}),T(M,!0,"h-5 w-5")]}),e.jsx(J,{placeholder:"Tell us about your experience with the Resume Builder...",value:d,onChange:s=>g(s.target.value),className:"min-h-[100px] resize-none",maxLength:500}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[d.length,"/500 characters"]}),e.jsxs(y,{onClick:P,disabled:i||!d.trim(),className:"gap-2",children:[i?e.jsx(U,{className:"h-4 w-4 animate-spin"}):e.jsx(V,{className:"h-4 w-4"}),"Submit Review"]})]})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-muted-foreground mb-2",children:"Login to share your experience"}),e.jsx(y,{variant:"outline",onClick:()=>window.location.href="/auth",children:"Login to Review"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:["User Reviews",o.length>0&&e.jsx(O,{variant:"secondary",children:o.length})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(U,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):o.length===0?e.jsx(b,{className:"p-6 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No reviews yet. Be the first to share your experience!"})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:o.map(s=>e.jsx(b,{className:s.is_featured?"ring-2 ring-primary/50":"",children:e.jsxs(R,{className:"pt-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(Y,{className:"h-10 w-10",children:[e.jsx(z,{className:"bg-primary/10 text-primary font-medium",children:s.user_name.charAt(0).toUpperCase()}),s.user_avatar&&e.jsx(L,{src:k(s.user_avatar,40),alt:s.user_name||"User avatar",loading:"lazy",decoding:"async"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:s.user_name}),s.is_featured&&e.jsx(O,{className:"bg-primary/10 text-primary text-xs",children:"Featured"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[T(s.rating),e.jsx("span",{className:"text-xs text-muted-foreground",children:ue(new Date(s.created_at),{addSuffix:!0})})]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3 leading-relaxed",children:s.comment}),t&&e.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>$(s.id,!s.is_featured),children:s.is_featured?"Unfeature":"Feature"}),e.jsxs(y,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>E(s.id),children:[e.jsx(A,{className:"h-3 w-3 mr-1"}),"Delete"]})]})]})},s.id))})]})]})};export{ze 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.