PageSourceSearch

https://www.goodness.ro/_next/static/chunks/31404-7edf37809eeee9fd.js?dpl=dpl_BgESgPTRQhW6jbz36AWJAZwfp5yY

js goodness.ro collected 2026-10-09 22:37:02 UTC 35,317 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[31404],{31404:(e,t,s)=>{s.d(t,{default:()=>D});var a=s(95155),n=s(12115),r=s(89715),i=s(65229),l=s(14285),o=s(5937),c=s(1375),d=s(35626),m=s(5917),f=s(75426),u=s(45345),h=s(52056),g=s(18085),p=s(8803),x=s(20063),b=s(71104),w=s(54109),y=s(15239),v=s(32394);function j(e,t){return!(null==e?void 0:e.shipped)||e.freeThresholdCents&&t>=e.freeThresholdCents?0:e.baseCents}var N=s(27507),k=s(70143),C=s(74719);function T(){return(0,a.jsxs)("div",{className:"flex h-full bg-base-100",children:[(0,a.jsxs)("div",{className:"w-full md:w-80 border-r border-base-300 flex flex-col",children:[(0,a.jsx)("div",{className:"p-4 border-b border-base-300",children:(0,a.jsx)("div",{className:"h-6 w-28 bg-base-300 rounded animate-pulse"})}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:[1,2,3,4,5].map(e=>(0,a.jsxs)("div",{className:"p-3.5 border-b border-base-300 flex gap-3",children:[(0,a.jsx)("div",{className:"w-16 h-16 rounded-lg bg-base-300 animate-pulse flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 space-y-2 py-1",children:[(0,a.jsx)("div",{className:"h-4 w-3/4 bg-base-300 rounded animate-pulse"}),(0,a.jsx)("div",{className:"h-3 w-1/3 bg-base-300 rounded animate-pulse"}),(0,a.jsx)("div",{className:"h-3 w-2/3 bg-base-300 rounded animate-pulse"})]})]},e))})]}),(0,a.jsxs)("div",{className:"hidden md:flex flex-1 flex-col",children:[(0,a.jsxs)("div",{className:"p-4 border-b border-base-300 space-y-2",children:[(0,a.jsx)("div",{className:"h-5 w-48 bg-base-300 rounded animate-pulse"}),(0,a.jsx)("div",{className:"h-3 w-24 bg-base-300 rounded animate-pulse"})]}),(0,a.jsx)("div",{className:"flex-1 p-4 space-y-3",children:[{me:!1,w:"w-40"},{me:!0,w:"w-52"},{me:!1,w:"w-32"},{me:!0,w:"w-44"},{me:!1,w:"w-48"}].map((e,t)=>(0,a.jsx)("div",{className:"flex ".concat(e.me?"justify-end":"justify-start"),children:(0,a.jsx)("div",{className:"h-9 ".concat(e.w," rounded-2xl bg-base-300 animate-pulse")})},t))}),(0,a.jsx)("div",{className:"p-4 border-t border-base-300",children:(0,a.jsx)("div",{className:"h-10 w-full bg-base-300 rounded-lg animate-pulse"})})]})]})}let S={"image/jpeg":["jpg","jpeg"],"image/png":["png"],"image/webp":["webp"],"image/gif":["gif"],"application/pdf":["pdf"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"]},E=[...Object.keys(S),".docx"].join(",");function _(e,t){var s;let a=(t||"").trim().toLowerCase();if(a&&"application/octet-stream"!==a&&S[a])return a;let n=null==(s=e.split(".").pop())?void 0:s.toLowerCase();if(n){for(let[e,t]of Object.entries(S))if(t.includes(n))return e}return a}function I(e){return e>=1048576?"".concat((e/1048576).toFixed(1)," MB"):e>=1024?"".concat(Math.round(e/1024)," KB"):"".concat(e," B")}function D(e){var t,s,D,A,P,F;let{storeId:L,isPreviewMode:O,userRoles:M,language:U="en",primaryColor:z="#3b82f6",attachmentsEnabled:R=!1,buyerSingularOverride:H,sellerSingularOverride:K}=e,{t:J}=(0,k.Bd)(U),$=J("common.free"),B=(0,x.useSearchParams)(),W=(0,b.xV)(z),Y="#ffffff"===W?"rgba(255,255,255,0.18)":"rgba(31,41,55,0.10)",q=(0,b.Pl)(z,.88),V=(0,x.useRouter)(),Q=(0,x.usePathname)(),[G,X]=(0,n.useState)([]),Z=!Q.startsWith("/s/"),ee=e=>Z?"/listings/".concat(e):"/s/".concat(L,"/listings/").concat(e),[et,es]=(0,n.useState)(null),[ea,en]=(0,n.useState)([]),[er,ei]=(0,n.useState)(!1),[el,eo]=(0,n.useState)(""),[ec,ed]=(0,n.useState)(!0),[em,ef]=(0,n.useState)(!1),[eu,eh]=(0,n.useState)(!1),[eg,ep]=(0,n.useState)([]),ex=(0,n.useRef)(null),[eb,ew]=(0,n.useState)(!1),[ey,ev]=(0,n.use
1State)(!0),[ej,eN]=(0,n.useState)(null),ek=(0,n.useRef)(null),eC=(0,n.useRef)(null),eT=e=>{e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,120),"px"),e.style.overflowY=e.scrollHeight>120?"auto":"hidden"},eS=()=>{eC.current&&eT(eC.current)},eE=(0,n.useCallback)(e=>{eC.current=e,e&&eT(e)},[]),[e_,eI]=(0,n.useState)(!1),[eD,eA]=(0,n.useState)(""),[eP,eF]=(0,n.useState)(""),[eL,eO]=(0,n.useState)(!1),[eM,eU]=(0,n.useState)(null),[ez,eR]=(0,n.useState)(null),[eH,eK]=(0,n.useState)(null),[eJ,e$]=(0,n.useState)(null),[eB,eW]=(0,n.useState)(null),[eY,eq]=(0,n.useState)(null),eV=B.get("listing"),eQ=B.get("seller"),eG=B.get("buyer"),eX=B.get("title"),eZ=B.get("price"),e0=B.get("currency"),e1=B.get("image"),e3=!!(eV&&(eQ||eG)),e5=B.get("conversation");(0,n.useEffect)(()=>{let e=()=>{ew(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,n.useEffect)(()=>{e3&&eb&&ev(!1)},[e3,eb]),(0,n.useEffect)(()=>{var e;null==(e=ek.current)||e.scrollIntoView({behavior:"smooth"})},[ea]),(0,n.useEffect)(()=>{""===el&&eC.current&&(eC.current.style.height="auto")},[el]),(0,n.useEffect)(()=>{eo(""),ep([])},[et]),(0,n.useLayoutEffect)(()=>{let e=eC.current;e&&(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,120),"px"),e.style.overflowY=e.scrollHeight>120?"auto":"hidden")},[et,e3,O]);let e2=(e,t)=>{let s=new Date(e),a=new Date(t);return s.getFullYear()===a.getFullYear()&&s.getMonth()===a.getMonth()&&s.getDate()===a.getDate()};(0,n.useEffect)(()=>{(async()=>{if(O){X([{conversationId:"preview-1",listingId:"preview-listing",listingTitle:"Sample Listing",listingImage:void 0,listingPrice:void 0,lastMessage:"This is a preview of the messaging system",lastMessageAt:new Date,unreadCount:0,otherPartyName:"Preview User",otherPartyType:M.includes("seller")?"buyer":"seller"}]),ed(!1);return}try{let e=await fetch("/api/marketplace/".concat(L,"/messages/conversations"));if(!e.ok)throw Error("Failed to fetch conversations");let t=await e.json();X(t.conversations||[])}catch(e){console.error("Error fetching conversations:",e),X([])}finally{ed(!1)}})()},[O,M,L]);let e4=(0,n.useRef)(null);(0,n.useEffect)(()=>{e4.current=et},[et]);let e6=(0,n.useRef)([]);(0,n.useEffect)(()=>{e6.current=ea},[ea]);let e8=(0,n.useCallback)(async()=>{if(O||"visible"!==document.visibilityState)return;let e=e4.current;try{let t="/api/marketplace/".concat(L,"/messages/poll").concat(e?"?conversation=".concat(encodeURIComponent(e)):""),s=await fetch(t,{cache:"no-store"});if(!s.ok)return;let a=await s.json();if(e4.current!==e)return;if(X(a.conversations||[]),e&&Array.isArray(a.messages)&&"offerCart"in a){let e=a.offerCart;eK(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)}if(e&&Array.isArray(a.messages)){let e=a.messages,t=e6.current,s=t.filter(e=>String(e._id).startsWith("temp-")),n=t.filter(e=>!String(e._id).startsWith("temp-"));if(e.length!==n.length||e.some((e,t)=>{var s;return e._id!==(null==(s=n[t])?void 0:s._id)})){en([...e,...s]);let t=new Set(n.map(e=>e._id));e.some(e=>
1!t.has(e._id))&&window.dispatchEvent(new Event(w.D))}}}catch(e){}},[O,L]);(0,n.useEffect)(()=>{if(O)return;let e=()=>{"visible"===document.visibilityState&&e8()};window.addEventListener("focus",e),document.addEventListener("visibilitychange",e);let t=window.setInterval(e8,15e3);return()=>{window.removeEventListener("focus",e),document.removeEventListener("visibilitychange",e),window.clearInterval(t)}},[e8,O]),(0,n.useEffect)(()=>{e5&&G.length>0&&!et&&G.some(e=>e.conversationId===e5)&&(es(e5),X(e=>e.map(e=>e.conversationId===e5?{...e,unreadCount:0}:e)),eb&&ev(!1))},[e5,G,et,eb]),(0,n.useEffect)(()=>{(async()=>{if(et){if(O)return en([{_id:"msg-1",content:"Hi, I'm interested in this listing!",senderType:M.includes("seller")?"buyer":"seller",createdAt:new Date(Date.now()-36e5),read:!0},{_id:"msg-2",content:"Thanks for your interest! How can I help you?",senderType:M.includes("seller")?"seller":"buyer",createdAt:new Date(Date.now()-18e5),read:!0}]);ei(!0),eU(null),eR(null),eK(null);try{var e,t,s;let a=await fetch("/api/marketplace/".concat(L,"/messages/").concat(et));if(!a.ok)throw Error("Failed to fetch messages");let n=await a.json();en(n.messages||[]),eU(null!=(e=n.offerDelivery)?e:null),eR(null!=(t=n.offerBuyerFee)?t:null),eK(null!=(s=n.offerCart)?s:null),window.dispatchEvent(new Event(w.D))}catch(e){console.error("Error fetching messages:",e),en([])}finally{ei(!1)}}})()},[et,O,M,L]);let e7=async e=>{let t=[];for(let s of e){let e=await fetch("/api/marketplace/".concat(L,"/messages/attachments/presigned-url"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:s.name,fileType:_(s.name,s.type),fileSize:s.size})});if(!e.ok)throw Error((await e.json().catch(()=>({}))).error||J("messages.attachments.uploadFailed"));let{presignedUrl:a,key:n,mimeType:r}=await e.json();if(!(await fetch(a,{method:"PUT",headers:{"Content-Type":r},body:s})).ok)throw Error(J("messages.attachments.uploadFailed"));t.push({key:n,fileName:s.name,size:s.size,mimeType:r})}return t},e9=async()=>{if((el.trim()||0!==eg.length)&&(et||e3)){ef(!0),eh(!1);try{if(O){let e={_id:"msg-".concat(Date.now()),content:el,senderType:M.includes("seller")?"seller":"buyer",createdAt:new Date,read:!0};en([...ea,e]),eo(""),ef(!1);return}if(e3&&eV&&(eQ||eG)){let a=eG||eQ,n=eG?"buyer":"seller",r=eg.length>0?await e7(eg):void 0,i=await fetch("/api/marketplace/".concat(L,"/messages/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:eV,content:el,recipientUserId:a,recipientType:n,...r&&{attachments:r}})});if(!i.ok){let e=await i.json().catch(()=>({error:"Unknown error"}));throw Error(e.error||"Failed to send message")}let l=await i.json();eh(!0===l.flagged);let o=l.conversationId;eo(""),ep([]);let c=await fetch("/api/marketplace/".concat(L,"/messages/conversations"));if(c.ok){let e=await c.json();X(e.conversations||[])}es(o);let d=await fetch("/api/marketplace/".concat(L,"/messages/").concat(o));if(d.ok){var e,t,s;let a=await d.json();en(a.messages||[]),eU(null!=(e=a.offerDelivery)?e:null),eR(null!=(t=a.offerBuyerFee)?t:null),eK(null!=(s=a.offerCart)?s:null)}V.replace(window.location.pathname)}else if(et){let e=G.find(e=>e.conversationId===et);if(!e)throw Error("Conversation not found");let t="seller"===e.otherPartyType,s=t?"seller":"buyer",a=et.split("-"),n="seller"===s?a[a.length-1]:a[a.length-3];if(eg.length>0){let t=await e7(eg),a=await fetch("/api/marketplace/".concat(L,"/messages/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e.listingId,content:el,recipientUserId:n,recipientType:s,attachments:t})});if(!a.ok){let e=await a.json().catch(()=>({error:"Failed to send message"}));throw Error(e.error||"Failed to send message")}let r=await a.json();eh(!0===r.flagged);let i={_id:r.message._id,content:r.message.content,senderType:r.message.senderType,createdAt:new Date(r.message.createdAt),read:r.message.read,type:r.message.type||"text",attachments:r.message.attachments};en(e=>e.some(e=>e._id===i._id)?e:[...e,i]),eo(""),ep([]);return}let r="temp-".concat(Date.now()),i={_id:r,content:el,senderType:t?"buyer":"seller",createdAt:new Date,read:!1,type:"text"};en(e=>[...e,i]),eo("");try{let t=await fetch("/api/marketplace/".concat(L,"/messages/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e.listingId,content:el,recipientUserId:n,recipientType:s})});if(!t.ok)throw Error("Failed to send message");let a=await t.json();eh(!0===a.flagged),en(e=>e.map(e=>e._id===r?{_id:a.message._id,content:a.message.content,senderType:a.message.senderType,createdAt:new Date(a.message.createdAt),read:a.message.read,type:a.message.type||"text"}:e))}catch(e){throw en(e=>e.filter(e=>e._id!==r)),eo(el),e}}}catch(e){console.error("Failed to send message:",e),alert(e instanceof Error?e.message:"Failed to send message. Please try again.")}finally{ef(!1)}}},te=e=>{es(e),X(t=>t.map(t=>t.conversationId===e&&t.unreadCount>0?{...t,unreadCount:0}:t)),eb&&ev(!1)},tt=()=>{ev(!0),es(null)},ts=async e=>{try{await navigator.clipboard.writeText(e),eN(e),setTimeout(()=>eN(null),2e3)}catch(e){console.error("Failed to copy to clipboard:",e)}},ta=async(e,t)=>{if(t.stopPropagation(),confirm(J("messages.archiveConversation")+"?"))try{if(!(await fetch("/api/marketplace/".concat(L,"/messages/").concat(e,"/archive"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({archived:!0})})).ok)throw Error("Failed to archive");X(t=>t.filter(t=>t.conversationId!==e)),et===e&&(es(null),eb&&ev(!0))}catch(e){console.error("Failed to archive conversation:",e)}},tn=async()=>
1{if(!et||O)return;let e=G.find(e=>e.conversationId===et);if(!e)return;let t=eD.trim(),s=Math.round(100*parseFloat(eP));if(!t||!Number.isFinite(s)||s<=0)return void alert(J("messages.offer.invalid"));eO(!0);try{let a=et.split("-"),n=a[a.length-3],r=await fetch("/api/marketplace/".concat(L,"/messages/send"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingId:e.listingId,recipientUserId:n,recipientType:"buyer",offer:{title:t,amount:s}})});if(!r.ok){let e=await r.json().catch(()=>({error:"Unknown error"}));throw Error(e.error||"Failed to send offer")}let i=await r.json(),l={_id:i.message._id,content:i.message.content,senderType:i.message.senderType,createdAt:new Date(i.message.createdAt),read:i.message.read,type:i.message.type,offer:i.message.offer};en(e=>e.some(e=>e._id===l._id)?e:[...e,l]),eA(""),eF(""),eI(!1)}catch(e){alert(e instanceof Error?e.message:"Failed to send offer")}finally{eO(!1)}},tr=async e=>{if(!O){eW(e._id);try{let t=await fetch("/api/checkout/accept-offer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:L,offerMessageId:e._id,language:U,customDomain:Z?window.location.host:void 0})});if(!t.ok){let e=await t.json().catch(()=>({error:"Unknown error"}));throw Error(e.error||"Failed to start checkout")}let s=await t.json();if(s.url)window.location.href=s.url;else throw Error("No checkout URL returned")}catch(e){alert(e instanceof Error?e.message:"Failed to start checkout"),eW(null)}}},ti=async e=>{if(!O){e$(e._id);try{let t=await fetch("/api/marketplace/".concat(L,"/messages/offer/").concat(e._id,"/cart"),{method:"POST"});if(!t.ok){let e=await t.json().catch(()=>({error:"Unknown error"}));throw Error(e.error||"Failed to add the offer to the cart")}eK(t=>t&&{...t,inCart:t.inCart.includes(e._id)?t.inCart:[...t.inCart,e._id]}),window.dispatchEvent(new CustomEvent("cart-updated"))}catch(e){alert(e instanceof Error?e.message:"Failed to add the offer to the cart")}finally{e$(null)}}},tl=async()=>{if(eY&&!O){eW(eY._id);try{let e=await fetch("/api/marketplace/".concat(L,"/messages/offer/").concat(eY._id,"/withdraw"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!e.ok){let t=await e.json().catch(()=>({error:"Unknown error"}));throw Error(t.error||"Failed to withdraw offer")}en(e=>e.map(e=>e._id===eY._id&&e.offer?{...e,offer:{...e.offer,status:"withdrawn"}}:e)),eq(null)}catch(e){alert(e instanceof Error?e.message:"Failed to withdraw offer")}finally{eW(null)}}},to=()=>0===eg.length?null:(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:eg.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 rounded-lg border border-base-300 bg-base-200 pl-2 pr-1 py-1",children:[(0,a.jsx)(r.A,{className:"w-3.5 h-3.5 flex-shrink-0 text-base-content/60"}),(0,a.jsx)("span",{className:"text-xs text-base-content truncate max-w-[140px]",children:e.name}),(0,a.jsx)("span",{className:"text-[10px] text-base-content/50",children:I(e.size)}),(0,a.jsx)("button",{onClick:()=>ep(e=>e.filter((e,s)=>s!==t)),disabled:em,className:"btn btn-ghost btn-xs btn-circle",title:J("messages.attachments.remove"),children:(0,a.jsx)(i.A,{className:"w-3 h-3"})})]},"".concat(e.name,"-").concat(t)))}),tc=()=>R?(0,a.jsx)("button",{onClick:()=>{var e;return null==(e=ex.current)?void 0:e.click()},disabled:em||O,className:"btn btn-ghost btn-square",title:J("messages.attachments.attachFile"),children:(0,a.jsx)(l.A,{className:"w-5 h-5"})}):null;if(ec)return(0,a.jsx)(T,{});let td=G.find(e=>e.conversationId===et),tm=(null==td?void 0:td.otherPartyType)==="buyer";return(0,a.jsxs)("div",{className:"flex h-full bg-base-100",children:[R&&(0,a.jsx)("input",{ref:ex,type:"file",multiple:!0,accept:E,className:"hidden",onChange:e=>{let t=Array.from(e.target.files||[]);if(e.target.value="",0===t.length)return;let s=[],a=[...eg];for(let e of t){if(a.length>=5){s.push(J("messages.attachments.tooMany",{max:5}));break}if(!function(e,t){var s;let a=S[t];if(!a)return!1;let n=null==(s=e.split(".").pop())?void 0:s.toLowerCase();return!!n&&a.includes(n)}(e.name,_(e.name,e.type))){s.push(J("messages.attachments.invalidType",{fileName:e.name}));continue}if(e.size>0xa00000){s.push(J("messages.attachments.tooLarge",{fileName:e.name}));continue}a.push(e)}ep(a),s.length>0&&alert(s.join("\n"))}}),(!eb||ey)&&(0,a.jsxs)("div",{className:"".concat(eb?"w-full":"w-80"," border-r border-base-300 flex flex-col"),children:[(0,a.jsx)("div",{className:"p-4 border-b border-base-300",children:(0,a.jsx)("h2",{className:"text-xl font-bold text-base-content",children:J("messages.title")})}),0===G.length?(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(o.A,{className:"w-16 h-16 mx-auto mb-4 text-base-content/30"}),(0,a.jsx)("p",{className:"text-base-content/70 text-sm",children:J("messages.noMessagesYet")}),(0,a.jsx)("p",{className:"text-base-content/50 text-xs mt-2",children:M.includes("buyer")?J("messages.buyerEmptyState"):J("messages.sellerEmptyState")})]})}):(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:G.map(e=>(0,a.jsx)("div",{role:"button",tabIndex:0,"aria-current":et===e.conversationId?"true":void 0,onClick:()=>te(e.conversationId),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),te(e.conversationId))},className:"group/conv relative w-full p-3 rounded-xl transition-colors text-left cursor-pointer ".concat(et===e.conversationId?"":"hover:bg-base-200/60"),style:et===e.conversationId?{backgroundColor:q}:void 0,children:(0,a.jsxs)("div",{className:"flex gap-3",children:[e.listingImage?(0,a.jsx)("a",{href:ee(e.listingId),target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"w-16 h-16 flex-shrink-0 rounded-lg overflow-hidden bg-base-300 hover:ring-2 transition-all",style:{"--tw-ring-color":z},title:J("messages.viewListing"),children:(0,a.jsx)(y.default,{src:e.listingImage,alt:e.listingTitle,width:64,height:64,className:"w-full h-full object-cover"})}):(0,a.jsx)("a",{href:ee(e.listingId),target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"w-16 h-16 flex-shrink-0 rounded-lg bg-base-300 flex items-center justify-center hover:ring-2 transition-all",style:{"--tw-ring-color":z},title:J("messages.viewListing"),children:(0,a.jsx)("span",{className:"text-2xl",children:"\uD83D\uDCE6"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex justify-between items-start mb-1",children:[(0,a.jsx)("a",{href:ee(e.listingId),target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"font-semibold text-base-content truncate flex-1 hover:text-[var(--theme-primary)] hover:underline transition-colors",title:J("messages.viewListing"),children:e.listingTitle}),e.unreadCount>0&&(0,a.jsx)("span",{className:"text-xs font-semibold rounded-full px-2 py-0.5 ml-2 flex-shrink-0",style:{backgroundColor:z,color:(0,b.xV)(z)},children:e.unreadCount})]}),void 0!==e.listingPrice&&(0,a.jsx)("p",{className:"text-xs font-medium text-base-content/80 mb-0.5",children:e.listingHasOptions?J("messages.fromPrice",{price:(0,v.$g)(e.listingPrice,{freeLabel:$,currency:e.listingCurrency})}):(0,v.$g)(e.listingPrice,{freeLabel:$,currency:e.listingCurrency})}),(0,a.jsxs)("p",{className:"text-xs text-base-content/60 mb-0.5",children:["buyer"===e.otherPartyType?H||J("messages.buyer"):K||J("messages.seller"),": ",e.otherPartyName]}),(0,a.jsx)("p",{className:"text-[13px] truncate ".concat(e.unreadCount>0?"font-medium text-base-content/80":"text-base-content/50"),children:e.lastMessage}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-1",children:[(0,a.jsx)("p",{className:"text-xs text-base-content/40",children:new Date(e.lastMessageAt).toLocaleDateString("da"===U?"da-DK":"en-US")}),(0,a.jsx)("button",{onClick:t=>ta(e.conversationId,t),className:"opacity-0 group-hover/conv:opacity-100 transition-opacity p-1 rounded hover:bg-base-300",title:J("messages.archiveConversation"),children:(0,a.jsx)(c.A,{className:"w-3.5 h-3.5 text-base-content/50"})})]})]})]})},e.conversationId))})]}),(!eb||!ey)&&(0,a.jsx)("div",{className:"flex-1 flex flex-col",children:et?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"p-4 border-b border-base-300 flex items-center gap-2",children:[eb&&(0,a.jsx)("button",{onClick:tt,className:"btn btn-ghost btn-sm btn-circle",children:(0,a.jsx)(d.A,{className:"w-5 h-5"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:ee((null==(t=G.find(e=>e.conversationId===et))?void 0:t.listingId)||""),target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-base-content hover:text-[var(--theme-primary)] hover:underline transition-colors",title:J("messages.viewListing"),children:null==(s=G.find(e=>e.conversationId===et))?void 0:s.listingTitle}),M.includes("seller")&&(null==(D=G.find(e=>e.conversationId===et))?void 0:D.uniqueIdentifier)&&(0,a.jsxs)("button",{onClick:()=>ts(G.find(e=>e.conversationId===et).uniqueIdentifier),className:"flex items-center gap-1 text-xs text-base-content/60 font-medium mt
1-1 hover:text-[var(--theme-primary)] transition-colors group",children:[(0,a.jsxs)("span",{children:[J("messages.internalRef"),": ",null==(A=G.find(e=>e.conversationId===et))?void 0:A.uniqueIdentifier]}),ej===(null==(P=G.find(e=>e.conversationId===et))?void 0:P.uniqueIdentifier)?(0,a.jsx)(m.A,{className:"w-3 h-3 text-success"}):(0,a.jsx)(f.A,{className:"w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity"})]}),(0,a.jsx)("p",{className:"text-sm text-base-content/70",children:null==(F=G.find(e=>e.conversationId===et))?void 0:F.otherPartyName})]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:er?(0,a.jsx)("div",{className:"space-y-3 pt-1",children:[{me:!1,w:"w-40"},{me:!0,w:"w-52"},{me:!1,w:"w-28"},{me:!1,w:"w-44"},{me:!0,w:"w-36"},{me:!0,w:"w-48"}].map((e,t)=>(0,a.jsx)("div",{className:"flex ".concat(e.me?"justify-end":"justify-start"),children:(0,a.jsx)("div",{className:"h-9 ".concat(e.w," rounded-2xl bg-base-300 animate-pulse")})},t))}):(0,a.jsxs)(a.Fragment,{children:[ea.map((e,t)=>{let s=t>0?ea[t-1]:void 0,n=t<ea.length-1?ea[t+1]:void 0,i=!s||!e2(e.createdAt,s.createdAt),l=tm?"seller"===e.senderType:"buyer"===e.senderType,o="offer"===e.type&&!!e.offer,c=(null==s?void 0:s.type)==="offer",d=(null==n?void 0:n.type)==="offer",f=o||i||!s||c||s.senderType!==e.senderType,u=o||!n||d||n.senderType!==e.senderType||!e2(e.createdAt,n.createdAt),h=new Date(e.createdAt).toLocaleTimeString("da"===U?"da-DK":"en-US",{hour:"2-digit",minute:"2-digit",hour12:"da"!==U});return(0,a.jsxs)("div",{children:[i&&(0,a.jsx)("div",{className:"flex justify-center my-3",children:(0,a.jsx)("span",{className:"px-2.5 py-0.5 rounded-full bg-base-200 text-base-content/50 text-[11px] font-medium",children:(e=>{let t=new Date(e),s=new Date,a=new Date;return(a.setDate(s.getDate()-1),e2(t,s))?J("messages.today"):e2(t,a)?J("messages.yesterday"):t.toLocaleDateString("da"===U?"da-DK":"en-US",{day:"numeric",month:"short",year:"numeric"})})(e.createdAt)})}),o?(0,a.jsx)("div",{className:"flex ".concat(f?"mt-3":"mt-0.5"," ").concat(l?"justify-end":"justify-start"),children:(0,a.jsxs)("div",{className:"max-w-[80%] md:max-w-sm w-full border rounded-2xl p-3.5 bg-base-100 shadow-sm",style:{borderColor:z},children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:z},children:J("messages.offer.label")}),(0,a.jsx)("p",{className:"text-[13px] font-medium text-base-content mt-1 leading-snug",children:e.offer.title}),(0,a.jsx)("p",{className:"text-xl font-bold text-base-content mt-0.5",children:(0,v.$g)(e.offer.amount,{freeLabel:$,currency:e.offer.currency})}),"pending"===e.offer.status&&(null==eM?void 0:eM.shipped)&&(()=>{let t=j(eM,e.offer.amount);return(0,a.jsx)("p",{className:"text-[12px] text-base-content/70",children:t>0?J("messages.offer.plusDelivery",{amount:(0,v.$g)(t,{freeLabel:null,currency:e.offer.currency})}):J("messages.offer.freeDelivery")})})(),"pending"===e.offer.status&&!tm&&(()=>{let t=(0,N.sQ)(ez,e.offer.amount);return t<=0?null:(0,a.jsx)("p",{className:"text-[12px] text-base-content/70",children:J("messages.offer.plusFee",{amount:(0,v.$g)(t,{freeLabel:null,currency:e.offer.currency}),label:(null==ez?void 0:ez.label)||J("checkout.buyerFee")})})})(),(null==td?void 0:td.listingPrice)?(0,a.jsxs)("p",{className:"text-[11px] text-base-content/50 mt-0.5",children:[J("messages.offer.listingPriceRef"),": ",(0,v.$g)(td.listingPrice,{freeLabel:$,currency:td.listingCurrency||e.offer.currency})]}):null,"pending"===e.offer.status&&!tm&&(0,a.jsx)("button",{onClick:()=>tr(e),disabled:eB===e._id||O,className:"btn btn-primary btn-sm w-full mt-3",children:eB===e._id?(0,a.jsx)("span",{className:"loading loading-spinner loading-sm"}):J("messages.offer.acceptAndPay")}),"pending"===e.offer.status&&!tm&&(null==eH?void 0:eH.eligible.includes(e._id))&&(eH.inCart.includes(e._id)?(0,a.jsxs)("a",{href:Z?"/cart":"/s/".concat(L,"/cart"),className:"mt-2 flex items-center justify-center gap-1 text-[13px] font-medium underline",style:{color:z},children:[(0,a.jsx)(m.A,{className:"w-4 h-4"})," ",J("messages.offer.inCart")]}):(0,a.jsx)("button",{onClick:()=>ti(e),disabled:eJ===e._id||eB===e._id||O,className:"btn btn-outline btn-sm w-full mt-2",children:eJ===e._id?(0,a.jsx)("span",{className:"loading loading-spinner loading-sm"}):J("messages.offer.addToCart")})),"pending"===e.offer.status&&tm&&(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-[11px] text-base-content/60",children:J("messages.offer.awaitingPayment")}),(0,a.jsx)("button",{onClick:()=>eq(e),disabled:eB===e._id||O,className:"btn btn-ghost btn-xs text-error",children:eB===e._id?(0,a.jsx)("span",{className:"loading loading-spinner loading-xs"}):J("messages.offer.withdraw")})]}),"paid"===e.offer.status&&(0,a.jsxs)("div",{className:"mt-3 flex items-center gap-1 text-success text-[13px] font-medium",children:[(0,a.jsx)(m.A,{className:"w-4 h-4"})," ",J("messages.offer.paid")]}),"withdrawn"===e.offer.status&&(0,a.jsx)("p",{className:"mt-3 text-[13px] text-base-content/50",children:J("messages.offer.withdrawn")}),"expired"===e.offer.status&&(0,a.jsx)("p",{className:"mt-3 text-[13px] text-base-content/50",children:J("messages.offer.expired")}),(0,a.jsx)("p",{className:"text-[10px] text-base-content/40 mt-2",children:h})]})}):(0,a.jsx)("div",{className:"flex ".concat(f?"mt-3":"mt-0.5"," ").concat(l?"justify-end":"justify-start"),children:(0,a.jsxs)("div",{className:"max-w-[75%] md:max-w-[60%] px-3 py-1.5 rounded-2xl ".concat(l?u?"rounded-br-sm":"":"bg-base-200 text-base-content ".concat(u?"rounded-bl-sm":"")),style:l?{backgroundColor:z,color:W}:void 0,children:[e.attachments&&e.attachments.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-1.5 pt-1 ".concat(e.content?"pb-1.5":"pb-0.5"),children:e.attachments.map((e,t)=>e.mimeType.startsWith("image/")&&e.url?(0,a.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"block",children:(0,a.jsx)("img",{src:e.url,alt:e.fileName,className:"rounded-lg max-h-48 max-w-full object-contain"})},t):(0,a.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 rounded-lg px-2.5 py-2 ".concat(l?"hover:opacity-80":"bg-base-100 border border-base-300 hover:bg-base-100/60"," transition-colors"),style:l?{backgroundColor:Y}:void 0,children:[(0,a.jsx)(r.A,{className:"w-4 h-4 flex-shrink-0"}),(0,a.jsx)("span",{className:"text-[12px] font-medium truncate max-w-[180px]",children:e.fileName}),(0,a.jsx)("span",{className:"text-[10px] flex-shrink-0 ".concat(l?"opacity-70":"text-base-content/50"),children:I(e.size)})]},t))}),e.content?(0,a.jsx)("p",{className:"text-[13px] leading-snug whitespace-pre-wrap break-words",children:e.content}):null,u&&(0,a.jsx)("p",{className:"text-[10px] mt-0.5 text-right ".concat(l?"opacity-70":"text-base-content/40"),children:h})]})})]},e._id)}),(0,a.jsx)("div",{ref:ek})]})}),(0,a.jsxs)("div",{className:"p-4 border-t border-base-300",children:[(()=>{let e=G.find(e=>e.conversationId===et);return!O&&(null==e?void 0:e.offerEligible)&&(null==e?void 0:e.otherPartyType)==="buyer"?e_?(0,a.jsxs)("div",{className:"mb-3 border border-base-300 rounded-lg p-3 space-y-2 bg-base-200/50",children:[(0,a.jsx)("p",{className:"text-sm font-semibold text-base-content",children:J("messages.offer.composeTitle")}),(0,a.jsx)("input",{type:"text",value:eD,onChange:e=>eA(e.target.value),placeholder:J("messages.offer.titlePlaceholder"),className:"input input-bordered input-sm w-full",disabled:eL}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"number",min:"0",step:"0.01",value:eP,onChange:e=>eF(e.target.value),placeholder:J("messages.offer.pricePlaceholder"),className:"input input-bordered input-sm flex-1",disabled:eL}),(0,a.jsx)("button",{onClick:tn,disabled:eL||!eD.trim()||!eP,className:"btn btn-primary btn-sm",children:eL?(0,a.jsx)("span",{className:"loading loading-spinner loading-sm"}):J("messages.offer.send")}),(0,a.jsx)("button",{onClick:()=>{eI(!1),eA(""),eF("")},disabled:eL,className:"btn btn-ghost btn-sm",children:J("messages.offer.cancel")})]}),(null==e?void 0:e.listingPrice)?(0,a.jsxs)("p",{className:"text-xs text-base-content/50",children:[J("messages.offer.listingPriceRef"),": ",(0,v.$g)(e.listingPrice,{freeLabel:$,currency:e.listingCurrency||void 0})]}):null,(null==eM?void 0:eM.shipped)&&(()=>{let t=Math.round(100*parseFloat(eP)),s=j(eM,Number.isFinite(t)?t:0),n=(0,v.$g)(s,{freeLabel:null,currency:(null==e?void 0:e.listingCurrency)||void 0});return(0,a.jsx)("p",{className:"text-xs text-base-content/60",children:[s>0?J(eM.storeKeepsShipping?"messages.offer.deliveryToStore":"messages.offer.deliveryToSeller",{amount:n}
1):null,J("messages.offer.payoutHeldUntilShipped")].filter(Boolean).join(" ")})})()]}):(0,a.jsxs)("button",{onClick:()=>eI(!0),className:"btn btn-outline btn-sm mb-3 gap-1",style:{borderColor:z,color:z},children:[(0,a.jsx)(u.A,{className:"w-4 h-4"})," ",J("messages.offer.sendCustomOffer")]}):null})(),eu&&(0,a.jsxs)("div",{className:"mb-2 flex items-start gap-2 rounded-lg bg-warning/10 border border-warning/30 p-3 text-sm text-warning-content",children:[(0,a.jsx)(h.A,{className:"w-4 h-4 flex-shrink-0 mt-0.5 text-warning"}),(0,a.jsx)("span",{children:J("messages.flaggedWarning")})]}),to(),(0,a.jsxs)("div",{className:"flex gap-2 items-end",children:[tc(),(0,a.jsx)("textarea",{ref:eE,rows:1,value:el,onChange:e=>{eo(e.target.value),eS()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e9())},placeholder:J("messages.typeMessage"),className:"textarea textarea-bordered flex-1 resize-none leading-snug min-h-0 py-2 overflow-hidden",disabled:em||O}),(0,a.jsx)("button",{onClick:e9,disabled:!el.trim()&&0===eg.length||em||O,className:"btn btn-primary",children:em?(0,a.jsx)("span",{className:"loading loading-spinner loading-sm"}):(0,a.jsx)(g.A,{className:"w-5 h-5"})})]}),O&&(0,a.jsx)("p",{className:"text-xs text-base-content/50 mt-2",children:J("messages.previewDisabled")})]})]}):e3?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"p-4 border-b border-base-300 flex items-center gap-3",children:[eb&&(0,a.jsx)("button",{onClick:tt,className:"btn btn-ghost btn-sm btn-circle",children:(0,a.jsx)(d.A,{className:"w-5 h-5"})}),(0,a.jsxs)("div",{className:"flex gap-3 items-center flex-1",children:[e1?(0,a.jsx)("a",{href:ee(eV||""),target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex-shrink-0 rounded-lg overflow-hidden bg-base-300 hover:ring-2 transition-all",style:{"--tw-ring-color":z},title:J("messages.viewListing"),children:(0,a.jsx)(y.default,{src:e1,alt:eX||"Listing",width:48,height:48,className:"w-full h-full object-cover"})}):(0,a.jsx)("a",{href:ee(eV||""),target:"_blank",rel:"noopener noreferrer",className:"w-12 h-12 flex-shrink-0 rounded-lg bg-base-300 flex items-center justify-center hover:ring-2 transition-all",style:{"--tw-ring-color":z},title:J("messages.viewListing"),children:(0,a.jsx)("span",{className:"text-xl",children:"\uD83D\uDCE6"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:ee(eV||""),target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-base-content hover:text-[var(--theme-primary)] hover:underline transition-colors",title:J("messages.viewListing"),children:eX||J("messages.newMessage")}),eZ&&(0,a.jsx)("p",{className:"text-sm text-base-content font-medium",children:(0,v.$g)(parseInt(eZ),{freeLabel:$,currency:e0||void 0})})]})]})]}),(0,a.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center p-4",children:(0,a.jsxs)("div",{className:"text-center text-base-content/50 max-w-xs",children:[(0,a.jsx)(o.A,{className:"w-14 h-14 mx-auto mb-3"}),(0,a.jsx)("p",{className:"font-medium text-base-content/70 mb-1",children:J("messages.startConversation")}),(0,a.jsx)("p",{className:"text-sm",children:J("messages.sendFirstMessage")}),(0,a.jsx)(p.A,{className:"w-5 h-5 mx-auto mt-5 animate-bounce",style:{color:z}})]})}),(0,a.jsxs)("div",{className:"p-4 border-t border-base-300",children:[eu&&(0,a.jsxs)("div",{className:"mb-2 flex items-start gap-2 rounded-lg bg-warning/10 border border-warning/30 p-3 text-sm text-warning-content",children:[(0,a.jsx)(h.A,{className:"w-4 h-4 flex-shrink-0 mt-0.5 text-warning"}),(0,a.jsx)("span",{children:J("messages.flaggedWarning")})]}),to(),(0,a.jsxs)("div",{className:"flex gap-2 items-end",children:[tc(),(0,a.jsx)("textarea",{ref:eE,autoFocus:!0,rows:1,value:el,onChange:e=>{eo(e.target.value),eS()},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e9())},placeholder:J("messages.typeYourMessage"),className:"textarea textarea-bordered flex-1 resize-none leading-snug min-h-0 py-2 overflow-hidden",disabled:em||O}),(0,a.jsx)("button",{onClick:e9,disabled:!el.trim()&&0===eg.length||em||O,className:"btn btn-primary",children:em?(0,a.jsx)("span",{className:"loading loading-spinner loading-sm"}):(0,a.jsx)(g.A,{className:"w-5 h-5"})})]}),O&&(0,a.jsx)("p",{className:"text-xs text-base-content/50 mt-2",children:J("messages.previewDisabled")})]})]}):(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center text-base-content/50",children:[(0,a.jsx)(o.A,{className:"w-16 h-16 mx-auto mb-4"}),(0,a.jsx)("p",{children:J("messages.selectConversation")})]})})}),eY&&(0,a.jsx)(C.T,{title:J("messages.offer.withdrawTitle"),message:J("messages.offer.withdrawConfirm"),confirmLabel:J("messages.offer.withdraw"),cancelLabel:J("messages.offer.cancel"),danger:!0,loading:eB===eY._id,onConfirm:tl,onCancel:()=>eq(null)})]})}},54109:(e,t,s)=>{s.d(t,{D:()=>n,N:()=>r});var a=s(74077);let n="prometora:messages-read";function r(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return(0,a.H6)({url:"/api/marketplace/".concat(e,"/messages/unread-count"),field:"unreadCount",enabled:t,initial:s,refreshEvent:n})}}}]);

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.