1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6530],{17313:(e,t,r)=>{"use strict";r.d(t,{Xi:()=>d,av:()=>c,j7:()=>i,tU:()=>l});var a=r(95155),s=r(12115),o=r(69607),n=r(59434);let l=o.bL,i=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)(o.B8,{ref:t,className:(0,n.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",r),...s})});i.displayName=o.B8.displayName;let d=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)(o.l9,{ref:t,className:(0,n.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",r),...s})});d.displayName=o.l9.displayName;let c=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)(o.UC,{ref:t,className:(0,n.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",r),...s})});c.displayName=o.UC.displayName},17759:(e,t,r)=>{"use strict";r.d(t,{C5:()=>p,MJ:()=>f,Rr:()=>b,eI:()=>h,lR:()=>u,lV:()=>d,zB:()=>m});var a=r(95155),s=r(12115),o=r(99708),n=r(62177),l=r(59434),i=r(85057);let d=n.Op,c=s.createContext({}),m=e=>{let{...t}=e;return(0,a.jsx)(c.Provider,{value:{name:t.name},children:(0,a.jsx)(n.xI,{...t})})},g=()=>{let e=s.useContext(c),t=s.useContext(x),{getFieldState:r,formState:a}=(0,n.xW)(),o=r(e.name,a);if(!e)throw Error("useFormField should be used within <FormField>");let{id:l}=t;return{id:l,name:e.name,formItemId:"".concat(l,"-form-item"),formDescriptionId:"".concat(l,"-form-item-description"),formMessageId:"".concat(l,"-form-item-message"),...o}},x=s.createContext({}),h=s.forwardRef((e,t)=>{let{className:r,...o}=e,n=s.useId();return(0,a.jsx)(x.Provider,{value:{id:n},children:(0,a.jsx)("div",{ref:t,className:(0,l.cn)("space-y-2",r),...o})})});h.displayName="FormItem";let u=s.forwardRef((e,t)=>{let{className:r,...s}=e,{error:o,formItemId:n}=g();return(0,a.jsx)(i.J,{ref:t,className:(0,l.cn)(o&&"text-destructive",r),htmlFor:n,...s})});u.displayName="FormLabel";let f=s.forwardRef((e,t)=>{let{...r}=e,{error:s,formItemId:n,formDescriptionId:l,formMessageId:i}=g();return(0,a.jsx)(o.DX,{ref:t,id:n,"aria-describedby":s?"".concat(l," ").concat(i):"".concat(l),"aria-invalid":!!s,...r})});f.displayName="FormControl";let b=s.forwardRef((e,t)=>{let{className:r,...s}=e,{formDescriptionId:o}=g();return(0,a.jsx)("p",{ref:t,id:o,className:(0,l.cn)("text-[0.8rem] text-muted-foreground",r),...s})});b.displayName="FormDescription";let p=s.forwardRef((e,t)=>{var r;let{className:s,children:o,...n}=e,{error:i,formMessageId:d}=g(),c=i?String(null!==(r=null==i?void 0:i.message)&&void 0!==r?r:""):o;return c?(0,a.jsx)("p",{ref:t,id:d,className:(0,l.cn)("text-[0.8rem] font-medium text-destructive",s),...n,children:c}):null});p.displayName="FormMessage"},34464:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,6874,23)),Promise.resolve().then(r.bind(r,69098)),Promise.resolve().then(r.bind(r,23118)),Promise.resolve().then(r.bind(r,21371)),Promise.resolve().then(r.bind(r,4275))},69098:(e,t,r)=>{"use strict";r.d(t,{CommunityFeed:()=>C});var a=r(95155),s=r(12115),o=r(35695),n=r(62177),l=r(90221),i=r(55594),d=r(25318),c=r(79311),m=r(50172),g=r(13568),x=r(30285),h=r(66151),u=r(17759),f=r(52956),b=r(66766);let p=i.Ik({content:i.Yj().min(1,"Post content cannot be empty").max(5e3,"Post content is too long")});function y(e){let{token:t,onPostCreated:r}=e,[o,i]=(0,s.useState)(!1),[y,v]=(0,s.useState)([]),[j,w]=(0,s.useState)([]),k=(0,n.mN)({resolver:(0,l.u)(p),defaultValues:{content:""}}),N=e=>{v(t=>t.filter((t,r)=>r!==e)),w(t=>{let r=t.filter((t,r)=>r!==e);return URL.revokeObjectURL(t[e]),r})};async function C(e){i(!0);try{let a=[];y.length>0&&(a=await (0,f.yH)(y,t)),await (0,f.E3)({content:e.content,images:a},t),g.oR.success("Post created successfully!"),k.reset(),v([]),w([]),r()}catch(e){g.oR.error(e.message||"Failed to create post")}finally{i(!1)}}return(0,a.jsx)("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700 p-5 mb-6 hover:shadow-md transition-shadow",children:(0,a.jsx)(u.lV,{...k,children:(0,a.jsxs)("form",{onSubmit:k.handleSubmit(C),className:"space-y-4",children:[(0,a.jsx)(u.zB,{control:k.control,name:"content",render:e=>{let{field:r}=e;return(0,a.jsxs)(u.eI,{children:[(0,a.jsx)(u.MJ,{children:(0,a.jsx)(h.s,{value:r.value,onChange:r.onChange,placeholder:"What's on your mind?",className:"min-h-[100px]",token:t})}),(0,a.jsx)(u.C5,{})]})}}),j.length>0&&(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3 mb-4",children:j.map((e,t)=>(0,a.jsxs)("div",{className:"relative aspect-video rounded-xl overflow-hidden group border border-gray-200 dark:border-gray-700",children:[(0,a.jsx)(b.default,{src:e,alt:"Preview ".concat(t+1),fill:!0,className:"object-cover"}),(0,a.jsx)("button",{type:"button",onClick:()=>N(t),className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white p-1.5 rounded-full opacity-0 group-hover:opacity-100 transition-all shadow-lg",children:(0,a.jsx)(d.A,{size:16})})]},t))}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-3 mt-1 border-t border-gray-100 dark:border-gray-700",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{type:"file",id:"image-upload",multiple:!0,accept:"image/*",className:"hidden",onChange:e=>{if(e.target.files){let t=Array.from(e.target.files);if(y.length+t.length>4){g.oR.error("You can only upload up to 4 images");return}v(e=>[...e,...t]);let r=t.map(e=>URL.createObjectURL(e));w(e=>[...e,...r])}},disabled:o||y.length>=4}),(0,a.jsx)("label",{htmlFor:"image-upload",className:"p-2.5 rounded-full hover:bg-orange-50 dark:hover:bg-orange-900/20 cursor-pointer text-gray-500 hover:text-orange-600 transition-all ".concat(y.length>=4?"opacity-50 cursor-not-allowed":""),children:(0,a.jsx)(c.A,{size:20})})]}),(0,a.jsx)(x.$,{type:"submit",disabled:o||!k.getValues("content")&&0===y.length,className:"bg-gradient-to-r from-orange-500 to-orange-600 hover:from-orange-600 hover:to-orange-700 text-white rounded-full px-6 shadow-md hover:shadow-lg transition-all",children:o?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Posting..."]}):"Post"})]})]})})})}var v=r(66903),j=r(17313),w=r(12543),k=r(59576),N=r(36629);function C(){let{user:e,token:t,isLoading:r}=(0,k.A)(),n=(0,o.useRouter)(),l=(0,o.useSearchParams)(),i=l.get("feed")||"latest",d=l.get("postId"),[c,h]=(0,s.use
1State)([]),[u,b]=(0,s.useState)(null),[p,C]=(0,s.useState)(!0),[R,F]=(0,s.useState)(!1),[P,L]=(0,s.useState)(!1),[S,_]=(0,s.useState)(!1),[I,M]=(0,s.useState)(1),[U,A]=(0,s.useState)(!0),E=(0,s.useRef)(null);(0,s.useEffect)(()=>{d&&(window.scrollTo({top:0,behavior:"smooth"}),h([]),M(1),A(!0),r||z(d))},[d,r,t]),(0,s.useEffect)(()=>{if(u){let e=window.location.hash;e&&e.startsWith("#comment-")&&setTimeout(()=>{let t=document.querySelector(e);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("highlight-comment"),setTimeout(()=>{t.classList.remove("highlight-comment")},2e3))},500)}},[u]),(0,s.useEffect)(()=>{r||d||(window.scrollTo({top:0,behavior:"smooth"}),b(null),h([]),M(1),A(!0),B(1,!0))},[i,r,t,d]),(0,s.useEffect)(()=>{I>1&&!d&&B(I,!1)},[I,d]);let B=async function(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!p&&!R||r){if("following"===i&&!t){C(!1);return}r?C(!0):F(!0);try{let a=await (0,f.pl)(i,e,t||void 0,10);if(a){r?h(a):h(e=>[...e,...a]);let e=10===a.length;A(e)}}catch(e){"following"!==i||t?g.oR.error("Failed to load feed"):g.oR.error("Please log in to view your following feed")}finally{C(!1),F(!1)}}},V=(0,s.useCallback)(()=>{R||!U||d||M(e=>e+1)},[R,U,I,d]);(0,s.useEffect)(()=>{if(0===c.length||d)return;let e=new IntersectionObserver(e=>{e[0].isIntersecting&&U&&!R&&V()},{threshold:.1}),t=E.current;return t&&e.observe(t),()=>{t&&e.unobserve(t)}},[U,R,V,c.length,d]);let z=async e=>{L(!0),_(!1);try{let r=await (0,f.GN)(e,t||void 0);r?(b(r),_(!1)):_(!0)}catch(e){console.error("Failed to load post:",e),g.oR.error("Failed to load post")}finally{L(!1)}},O=e=>{u&&u._id===e&&n.push("/posts"),h(t=>t.filter(t=>t._id!==e))},T=e=>{u&&u._id===e._id&&b(e),h(t=>t.map(t=>t._id===e._id?e:t))},W=()=>{n.push("/posts"),b(null)};return(0,a.jsx)("div",{className:"w-full lg:flex-1 min-w-0",children:d&&u?(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsxs)(x.$,{variant:"ghost",onClick:W,className:"gap-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors -ml-2",children:[(0,a.jsx)(w.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"font-medium",children:"Back to Posts"})]})}),(0,a.jsx)("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden shadow-sm",children:(0,a.jsx)(v.R,{post:u,token:t||void 0,currentUserId:null==e?void 0:e._id,onPostDeleted:()=>O(u._id),onPostUpdated:T,defaultShowComments:!0})})]}):d&&S?(0,a.jsx)("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-12 text-center shadow-sm",children:(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-gradient-to-br from-gray-100 to-gray-50 dark:from-gray-800 dark:to-gray-900 mb-5 shadow-sm",children:(0,a.jsx)("svg",{className:"w-10 h-10 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:"Post Not Found"}),(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"This post may have been deleted or doesn't exist."}),(0,a.jsxs)(x.$,{onClick:W,className:"gap-2 bg-orange-600 hover:bg-orange-700",children:[(0,a.jsx)(w.A,{className:"h-4 w-4"}),"Back to Feed"]})]})}):d&&P?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-16",children:[(0,a.jsx)(m.A,{className:"h-10 w-10 animate-spin text-orange-500 mb-4"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-medium",children:"Loading post..."})]}):(0,a.jsxs)(a.Fragment,{children:[e&&t?(0,a.jsx)(y,{token:t,onPostCreated:()=>{h([]),M(1),A(!0),B(1,!0)}}):(0,a.jsx)("div",{className:"mb-6",children:(0,a.jsx)(N.i,{type:"post"})}),(0,a.jsx)(j.tU,{defaultValue:i,onValueChange:e=>{if("following"===e&&!t){g.oR.error("Please log in to view your following feed");return}n.push("/posts?feed=".concat(e))},className:"mb-6",children:(0,a.jsxs)(j.j7,{className:"inline-flex h-11 items-center justify-start rounded-none bg-transparent p-0 border-b border-gray-200 dark:border-gray-700 w-full gap-6",children:[(0,a.jsx)(j.Xi,{value:"latest",className:"inline-flex items-center justify-center whitespace-nowrap rounded-none border-b-2 border-transparent px-0 pb-3 pt-0 text-sm font-semibold text-gray-600 dark:text-gray-400 transition-all hover:text-gray-900 dark:hover:text-gray-100 data-[state=active]:border-orange-600 data-[state=active]:text-orange-600 dar
1k:data-[state=active]:text-orange-500 data-[state=active]:shadow-none",children:"Latest"}),(0,a.jsx)(j.Xi,{value:"trending",className:"inline-flex items-center justify-center whitespace-nowrap rounded-none border-b-2 border-transparent px-0 pb-3 pt-0 text-sm font-semibold text-gray-600 dark:text-gray-400 transition-all hover:text-gray-900 dark:hover:text-gray-100 data-[state=active]:border-orange-600 data-[state=active]:text-orange-600 dark:data-[state=active]:text-orange-500 data-[state=active]:shadow-none",children:"Trending"}),(0,a.jsxs)(j.Xi,{value:"following",disabled:!t,className:"inline-flex items-center justify-center whitespace-nowrap rounded-none border-b-2 border-transparent px-0 pb-3 pt-0 text-sm font-semibold text-gray-600 dark:text-gray-400 transition-all hover:text-gray-900 dark:hover:text-gray-100 data-[state=active]:border-orange-600 data-[state=active]:text-orange-600 dark:data-[state=active]:text-orange-500 data-[state=active]:shadow-none disabled:opacity-50 disabled:cursor-not-allowed",children:["Following ",!t&&"\uD83D\uDD12"]})]})}),(0,a.jsx)("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden shadow-sm",children:p?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-16",children:[(0,a.jsx)(m.A,{className:"h-10 w-10 animate-spin text-orange-500 mb-4"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-medium",children:"Loading posts..."})]}):c.length>0?(0,a.jsxs)(a.Fragment,{children:[c.map(r=>(0,a.jsx)(v.R,{post:r,token:t||void 0,currentUserId:null==e?void 0:e._id,onPostDeleted:()=>O(r._id),onPostUpdated:T},r._id)),(0,a.jsx)("div",{ref:E,className:"h-4"}),R&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 border-t border-gray-100 dark:border-gray-700/50",children:[(0,a.jsx)(m.A,{className:"h-8 w-8 animate-spin text-orange-500 mb-3"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-medium",children:"Loading more posts..."})]}),!U&&!R&&(0,a.jsxs)("div",{className:"text-center py-10 border-t border-gray-100 dark:border-gray-700/50 bg-gradient-to-b from-transparent to-gray-50/50 dark:to-gray-800/50",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-gradient-to-br from-orange-100 to-orange-50 dark:from-orange-900/30 dark:to-orange-800/20 rounded-full mb-4 shadow-sm",children:(0,a.jsx)("svg",{className:"w-8 h-8 text-orange-500 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,a.jsx)("p",{className:"text-gray-700 dark:text-gray-300 font-semibold text-base mb-1",children:"You've reached the end"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Check back later for more posts!"})]})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-20 h-20 bg-gradient-to-br from-gray-100 to-gray-50 dark:from-gray-800 dark:to-gray-900 rounded-full mb-5 shadow-sm",children:(0,a.jsx)("svg",{className:"w-10 h-10 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),(0,a.jsx)("p",{className:"text-gray-800 dark:text-gray-200 text-lg font-semibold mb-2",children:"No posts found"}),"following"===i&&(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Follow some makers to see their posts here!"})]})})]})})}},85057:(e,t,r)=>{"use strict";r.d(t,{J:()=>d});var a=r(95155),s=r(12115),o=r(40968),n=r(74466),l=r(59434);let i=(0,n.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=s.forwardRef((e,t)=>{let{className:r,...s}=e;return(0,a.jsx)(o.b,{ref:t,className:(0,l.cn)(i(),r),...s})});d.displayName=o.b.displayName}},e=>{var t=t=>e(e.s=t);e.O(0,[9013,5004,277,6874,4277,1098,3063,3568,7031,1476,2090,1020,5521,3148,9607,705,2202,6903,8441,1684,7358],()=>t(34464)),_N_E=e.O()}]);
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.