1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8e932f3d-7eb4-47eb-b46a-9f6d3de9f828",e._sentryDebugIdIdentifier="sentry-dbid-8e932f3d-7eb4-47eb-b46a-9f6d3de9f828")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6220],{46749:function(e,t,i){(window.__NEXT_P=window.__NEXT_P||[]).push(["/mesh/notifications",function(){return i(56563)}])},56563:function(e,t,i){"use strict";i.r(t),i.d(t,{default:function(){return ed}});var n,r,s,o,a,d,l,c,u=i(85893),p=i(67294),E=i(45007),h=i(11163),f=i(31529),x=i(6459),g=i(88329),b=i(48899),T=i(68029),I=i(90092),_=i(8186),y=i(73636),S=i(12553),R=i(38491),A=i(96254),j=i(90608),m=i(12095),v=i(12519),D=i(34302),O=i(63162),w=i(95478),N=i(59342),C=i(90573),P=i(33229),L=i(8387),k=i(3347),U=i(42449),q=i(14968),M=i(96887),Z=i(31318),z=i(18382),W=i(52587),F=i(22768),G=i(30983),B=i(56489),V=i(86507),Q=i(86903),J=i(94441),Y=i(23171),X=i(80791),H=i(90077);let K={assignment:e=>"/mesh/job-board/requests/".concat(e.parentId||e.id),request:e=>"/mesh/job-board/requests/".concat(e.id),quotation:e=>e.id?"/mesh/job-board/quotations/".concat(e.id):"/mesh/job-board/quotations",payment:e=>"/mesh/meshpay",bid:e=>e.parentId?"/mesh/job-board/requests/".concat(e.parentId):"/mesh/job-board/bids",proof:e=>{var t;let i=(null===(t=e.metadata)||void 0===t?void 0:t.meshId)||e.parentId;return"/mesh/".concat(i,"/proof-of-work/").concat(e.id)},candidate:e=>"/mesh/job-board/requests/".concat(e.id)};function $(e){var t,i,n;let r=null===(t=e.data)||void 0===t?void 0:t.action,s=null;if(r&&"object"==typeof r&&"type"in r)s=r;else{let t=function(e){var t,i,n,r,s,o;let{data:a}=e;if(!a)return null;let d="string"==typeof e.type?e.type.toLowerCase():"",l=()=>{var e,t,i,n;return null!==(n=null!==(i=a.requestId)&&void 0!==i?i:null===(t=a.context)||void 0===t?void 0:null===(e=t.request)||void 0===e?void 0:e.id)&&void 0!==n?n:void 0};if(d.startsWith("quotation.")){let e=null!==(r=null!==(n=a.quotationId)&&void 0!==n?n:null===(i=a.context)||void 0===i?void 0:null===(t=i.quotation)||void 0===t?void 0:t.id)&&void 0!==r?r:void 0;if(e)return{type:"quotation",id:e,parentId:l()}}if(d.startsWith("bid.")&&a.bidId)return{type:"bid",id:a.bidId,parentId:l()};if(a.assignmentId)return{type:"assignment",id:a.assignmentId,parentId:a.requestId};if(a.quotationId)return{type:"quotation",id:a.quotationId,parentId:a.requestId};if(a.requestId)return{type:"request",id:a.requestId};if(a.paymentId)return{type:"payment",id:a.paymentId};if(a.bidId)return{type:"bid",id:a.bidId,parentId:l()};if(a.proofOfWorkId||a.proofId){let e=a.proofOfWorkId||a.proofId,t=(null===(o=a.context)||void 0===o?void 0:null===(s=o.artisan)||void 0===s?void 0:s.id)||a.artisanId;return{type:"proof",id:e,parentId:a.requestId,metadata:t?{meshId:t}:void 0}}return(d.includes("candidate")||d.includes("selection"))&&a.requestId?{type:"candidate",id:a.requestId}:null}(e);t&&(s={type:"VIEW_RESOURCE",resource:t})}return((null==s?void 0:s.resource)&&(null===(i=e.data)||void 0===i?void 0:i.businessId)!==void 0&&(s.resource.businessId=e.data.businessId,s.resource.isBusinessIdentity=!!e.data.isBusinessIdentity),s)?s:(null===(n=e.data)||void 0===n?void 0:n.deepLink)?{type:"NAVIGATE_EXTERNAL",url:e.data.deepLink}:null}async function ee(e,t){var i,n,r;let s=null===(i=e.data)||void 0===i?void 0:i.targetRole,o="artisan"===s?"provider":s;o&&(null==t?void 0:t.switchRole)&&t.activeRole!==o&&(null===(n=t.userRoles)||void 0===n?void 0:n.includes(o))&&await t.switchRole(o);let a=null===(r=e.data)||void 0===r?void 0:r.businessId;void 0!==a&&(null==t?void 0:t.switchBusiness)&&t.currentBusinessId!==a&&await t.switchBusiness(a)}async function et(e,t,i){let n=$(e);if(!n)return!1;try{switch(n.type){case"VIEW_RESOURCE":if(n.resource)return await ee(e,i),function(e,t){let i=function(e){let t=K[e.type];return t?t(e):(console.warn("[ResourceRouter] Unknown resource type: ".concat(e.type)),"/mesh/job-board")}(e);t.push(i)}
1(n.resource,t),!0;break;case"NAVIGATE_EXTERNAL":if(n.url)return window.open(n.url,"_blank","noopener,noreferrer"),!0;break;case"CUSTOM_ACTION":break;default:console.warn("[NotificationAction] Unknown action type:",n.type)}}catch(e){console.error("[NotificationAction] Failed to execute action:",e)}return!1}(n=a||(a={})).EMAIL="email",n.SMS="sms",n.PUSH="push",n.IN_APP="in_app",(r=d||(d={})).LOW="low",r.NORMAL="normal",r.HIGH="high",r.URGENT="urgent",(s=l||(l={})).PENDING="pending",s.QUEUED="queued",s.SENT="sent",s.DELIVERED="delivered",s.FAILED="failed",s.ACKNOWLEDGED="acknowledged",s.EXPIRED="expired",(o=c||(c={})).ASSIGNMENT_CREATED="assignment.created",o.ASSIGNMENT_ACCEPTED="assignment.accepted",o.ASSIGNMENT_EXPIRED="assignment.expired",o.ASSIGNMENT_CANCELLED="assignment.cancelled",o.ASSIGNMENT_COMPLETED="assignment.completed",o.ASSIGNMENT_URGENT="assignment.urgent",o.ASSIGNMENT_UPDATED="assignment.updated",o.CANDIDATES_READY="selection.candidates_ready",o.SELECTION_EXPIRED="selection.expired",o.REQUEST_CREATED="request.created",o.REQUEST_ACCEPTED="request.accepted",o.REQUEST_IN_PROGRESS="request.in_progress",o.REQUEST_COMPLETED="request.completed",o.REQUEST_CANCELLED="request.cancelled",o.JOB_STARTED="job.started",o.JOB_PAUSED="job.paused",o.JOB_RESUMED="job.resumed",o.JOB_COMPLETED="job.completed",o.PROOF_SUBMITTED="proof.submitted",o.PROOF_APPROVED="proof.approved",o.PROOF_REJECTED="proof.rejected",o.PROOF_AUTO_APPROVED="proof.auto_approved",o.PROOF_REVISION_REQUESTED="proof.revision_requested",o.PAYMENT_PENDING="payment.pending",o.PAYMENT_COMPLETED="payment.completed",o.PAYMENT_FAILED="payment.failed",o.WALLET_TOPUP_COMPLETED="wallet.topup.completed",o.WALLET_TOPUP_FAILED="wallet.topup.failed",o.WALLET_ESCROW_RELEASED="wallet.escrow.released",o.TRANSFER_COMPLETED="transfer.completed",o.TRANSFER_FAILED="transfer.failed",o.QUOTATION_CREATED="quotation.created",o.QUOTATION_SUBMITTED="quotation.submitted",o.QUOTATION_APPROVED="quotation.approved",o.QUOTATION_REJECTED="quotation.rejected",o.QUOTATION_COUNTER_OFFERED="quotation.counter_offered",o.BID_RECEIVED="bid.received",o.BID_ACCEPTED="bid.accepted",o.BID_REJECTED="bid.rejected",o.KYC_SUBMITTED="kyc.submitted",o.KYC_APPROVED="kyc.approved",o.KYC_REJECTED="kyc.rejected",o.KYC_REVISION_REQUESTED="kyc.revision_requested",o.SYSTEM_ALERT="system.alert",o.SUPPORT_ALERT="support.alert",o.REMINDER="system.reminder",o.AD_HOC="system.ad_hoc";var ei=i(37987),en=i(61656),er=i(68730),es=i(18471);let eo=e=>{let t={[c.ASSIGNMENT_CREATED]:k.Z,[c.ASSIGNMENT_ACCEPTED]:U.Z,[c.ASSIGNMENT_COMPLETED]:q.Z,[c.ASSIGNMENT_CANCELLED]:M.Z,[c.ASSIGNMENT_URGENT]:Z.Z,[c.REQUEST_CREATED]:z.Z,[c.REQUEST_COMPLETED]:U.Z,[c.PAYMENT_COMPLETED]:W.Z,[c.PAYMENT_PENDING]:Z.Z,[c.PAYMENT_FAILED]:M.Z,[c.QUOTATION_SUBMITTED]:F.Z,[c.QUOTATION_APPROVED]:U.Z,[c.PROOF_SUBMITTED]:F.Z,[c.PROOF_APPROVED]:U.Z,[c.PROOF_REJECTED]:M.Z,[c.CANDIDATES_READY]:G.Z,[c.JOB_STARTED]:z.Z,[c.JOB_COMPLETED]:q.Z,[c.WALLET_TOPUP_COMPLETED]:W.Z,[c.WALLET_TOPUP_FAILED]:M.Z,[c.WALLET_ESCROW_RELEASED]:W.Z,[c.TRANSFER_COMPLETED]:B.Z,[c.TRANSFER_FAILED]:M.Z};return"string"==typeof e&&e.toLowerCase().includes("candidates")?G.Z:t[e]||V.Z},ea=e=>{let t="string"==typeof e?e:"";return t.includes("urgent")||t.includes("cancelled")||t.includes("rejected")||t.includes("failed")?"amber":t.includes("completed")||t.includes("approved")||t.includes("accepted")?"green":t.includes("payment")||t.includes("quotation")||t.includes("wallet")||t.includes("transfer")?"blue":"purple"};var ed=()=>{let e=(0,E.I0)(),t=(0,h.useRouter)(),i=(0,x.p)(),{businessId:n}=(0,en.O)(),{activeRole:r,roles:s,switchRole:o,switchBusiness:a}=(0,er.q)(),d=(0,es.$V)(),l=(0,E.v9)(e=>(0,H._6)(e)),c=(0,E.v9)(e=>(0,H.NH)(e)),[k,q]=(0,p.useState)(0),[M,Z]=(0,p.useState)("all"),[z,W]=(0,p.useState)(new Set);(0,p.useEffect)(()=>{e((0,H.nZ)({limit:50,businessId:n}))},[e,n]);let F=async l=>{var c;if(!l.read)try{await e((0,H.Ix)({id:l.id,businessId:n})).unwrap()}catch(e){i({title:"Error",description:"Failed to mark notification as read",status:"error",duration:3e3})}await et(l,t,{activeRole:r,userRoles:s,switchRole:o,currentBusinessId:null!==(c=null==d?void 0:d.activeBusinessId)&&void 0!==c?c:null,switchBusiness:a})},G=async t=>{try{await e((0,H.vL)({id:t,businessId:n})).unwrap()}catch(e){i({title:"Error",description:"Failed to mark notification as unread",status:"error",duration:3e3})}},K=async()=>{try{await e((0,H.Go)(n)).unwrap(),i({title:"Success",description:"All notifications marked as read",status:"success",duration:2e3})}catch(e){i({title:"Error",description:"Failed to mark all as read",status:"error",duration:3e3})}},ee=e=>{W(t=>new Set(t).add(e)),i({title:"Archived",description:"Notification archived",status:"success",duration:2e3})},ed=e=>{W(t=>{let i=new Set(t);return i.delete(e),i}),i({title:"Restored",description:"Notification unarchived",status:"success",duration:2e3})},el=e=>{try{return(0,ei.Q)(new Date(e),{addSuffix:!0})}catch(e){return"Recently"}},ec=e=>"unread"===M?e.filter(e=>!e.read&&!z.has(e.id)):"archived"===M?e.filter(e=>z.has(e.id)):e.filter(e=>!z.has(e.id)),eu=ec(l.filter(e=>{let t=e.type.toLowerCase();return t.includes("request")||t.includes("assignment")||t.includes("quotation")||t.includes("proof")||t.includes("bid")||t.includes("candidates")})),ep=ec(l.filter(e=>{let t=e.type.toLowerCase();return t.includes("payment")||t.includes("wallet")||t.includes("transfer")})),eE=ec(l),eh=e=>c&&0===e.length?(0,u.jsx)(g.k,{justify:"center",align:"center",h:"300px",children:(0,u.jsx)(b.$,{size:"lg",color:"green.500"})}):0===e.length?(0,u.jsxs)(T.x,{p:8,borderRadius:"12px",bg:"gray.50",border:"1px solid",borderColor:"gray.200",textAlign:"center",children:[(0,u.jsx)(T.x,{display:"inline-block",mb:2,children:(0,u.jsx)(I.x,{fontSize:"48px",children:"\uD83D\uDCCB"})}),(0,u.jsx)(I.x,{color:"gray.500",fontSize:"16px",fontWeight:"500",mt:2,children:"No notifications yet"}),(0,u.jsx)(I.x,{color:"gray.400",fontSize:"14px",mt:1,children:"You're all caught up!"})]}):(0,u.jsx)(_.g,{spacing:3,align:"stretch",children:e.map(e=>{let t=eo(e.type),i=ea(e.type),n=$(e),r=null!==$(e);return(0,u.jsx)(T.x,{p:4,borderRadius:"12px",border:"1px solid",borderColor:e.read?"gray.200":"green.200",bg
1:e.read?"white":"green.50",cursor:r?"pointer":"default",transition:"all 0.2s",_hover:r?{shadow:"md",borderColor:"green.300",transform:"translateY(-2px)"}:{},onClick:()=>F(e),children:(0,u.jsxs)(y.U,{spacing:4,align:"start",children:[(0,u.jsx)(g.k,{w:"48px",h:"48px",borderRadius:"full",bg:"amber"===i?"orange.100":"green"===i?"green.100":"blue"===i?"blue.100":"purple.100",align:"center",justify:"center",flexShrink:0,children:(0,u.jsx)(S.J,{as:t,boxSize:6,color:"amber"===i?"orange.600":"green"===i?"green.600":"blue"===i?"blue.600":"purple.600"})}),(0,u.jsxs)(_.g,{align:"start",spacing:2,flex:1,children:[(0,u.jsxs)(y.U,{justify:"space-between",w:"full",children:[(0,u.jsx)(I.x,{fontSize:"md",fontWeight:e.read?"500":"700",color:"gray.800",children:e.title}),!e.read&&(0,u.jsx)(T.x,{w:2.5,h:2.5,borderRadius:"full",bg:"green.500",flexShrink:0})]}),(0,u.jsx)(I.x,{fontSize:"sm",color:"gray.600",lineHeight:"1.5",children:e.body}),(0,u.jsxs)(y.U,{justify:"space-between",w:"full",mt:1,children:[(0,u.jsxs)(y.U,{spacing:2,children:[(0,u.jsx)(I.x,{fontSize:"xs",color:"gray.400",fontWeight:"500",children:el(e.createdAt)}),r&&n&&(0,u.jsxs)(y.U,{spacing:1,color:"green.600",children:[(0,u.jsx)(S.J,{as:B.Z,boxSize:3}),(0,u.jsx)(I.x,{fontSize:"xs",fontWeight:"600",children:function(e){let t=$(e);return t&&t.resource?({assignment:"View Job",request:"View Request",quotation:"View Quotation",payment:"View Payment",bid:"View Bid",proof:"Review Proof",candidate:"View Candidates"})[t.resource.type]||"View Details":"View"}(e)})]})]}),(0,u.jsx)(y.U,{spacing:1,children:z.has(e.id)?(0,u.jsx)(R.z,{size:"xs",variant:"ghost",colorScheme:"green",leftIcon:(0,u.jsx)(Q.Z,{size:"14"}),onClick:t=>{t.stopPropagation(),ed(e.id)},children:"Unarchive"}):(0,u.jsxs)(u.Fragment,{children:[e.read?(0,u.jsx)(R.z,{size:"xs",variant:"ghost",colorScheme:"purple",onClick:t=>{t.stopPropagation(),G(e.id)},children:"Mark as unread"}):null,(0,u.jsx)(R.z,{size:"xs",variant:"ghost",colorScheme:"blue",leftIcon:(0,u.jsx)(J.Z,{size:"14"}),onClick:t=>{t.stopPropagation(),ee(e.id)},children:"Archive"})]})})]})]})]})},e.id)})});return(0,u.jsx)(f.Z,{children:(0,u.jsx)(A.W,{maxW:"container.xl",py:6,children:(0,u.jsxs)(_.g,{spacing:6,align:"stretch",children:[(0,u.jsxs)(g.k,{justify:"space-between",align:"center",gap:4,w:"full",position:"sticky",top:0,bg:"white",zIndex:10,py:3,children:[(0,u.jsxs)(T.x,{children:[(0,u.jsxs)(y.U,{children:[(0,u.jsx)(V.Z,{size:"26"}),(0,u.jsx)(I.x,{fontSize:"20px",fontWeight:"bold",color:"gray.800",children:"Notifications"})]}),"all"!==M?(0,u.jsx)(y.U,{mt:1,spacing:2,children:(0,u.jsx)(T.x,{px:2,py:1,bg:"blue.100",borderRadius:"md",display:"inline-block",children:(0,u.jsxs)(I.x,{fontSize:"13px",color:"blue.700",fontWeight:"600",children:["Showing: ","unread"===M?"Unread Only":"Archived Only"]})})}):null]}),(0,u.jsxs)(y.U,{spacing:2,children:[(0,u.jsxs)(j.v,{children:[(0,u.jsx)(m.j,{as:v.h,icon:(0,u.jsx)(Y.Z,{size:"20"}),variant:"outline",size:"sm","aria-label":"Filter notifications"}),(0,u.jsxs)(D.q,{children:[(0,u.jsx)(O.s,{onClick:()=>Z("all"),bg:"all"===M?"green.50":"transparent",children:"Read and Unread"}),(0,u.jsx)(O.s,{onClick:()=>Z("unread"),bg:"unread"===M?"green.50":"transparent",children:"Unread Only"}),(0,u.jsx)(O.s,{onClick:()=>Z("archived"),bg:"archived"===M?"green.50":"transparent",children:"Archived Only"})]})]}),(0,u.jsxs)(j.v,{children:[(0,u.jsx)(m.j,{as:v.h,icon:(0,u.jsx)(X.Z,{size:"20"}),variant:"outline",size:"sm","aria-label":"More options"}),(0,u.jsxs)(D.q,{children:[(0,u.jsx)(O.s,{icon:(0,u.jsx)(S.J,{as:U.Z,boxSize:4}),onClick:K,children:"Mark all as read"}),(0,u.jsx)(O.s,{icon:(0,u.jsx)(S.J,{as:J.Z,boxSize:4}),onClick:()=>{W(new Set(l.map(e=>e.id))),i({title:"Success",description:"All notifications archived",status:"success",duration:2e3})},children:"Archive all"})]})]})]})]}),(0,u.jsxs)(w.m,{index:k,onChange:q,colorScheme:"green",variant:"soft-rounded",isLazy:!0,children:[(0,u.jsx)(T.x,{position:"relative",sx:{"&::after":{content:'""',position:"absolute",top:0,right:0,bottom:0,width:"40px",background:"linear-gradient(to right, transparent, white)",pointerEvents:"none"}}
1,children:(0,u.jsxs)(N.t,{overflowX:"auto",overflowY:"hidden",whiteSpace:"nowrap",pb:2,mb:3,sx:{"&::-webkit-scrollbar":{height:"4px"},"&::-webkit-scrollbar-track":{background:"gray.100",borderRadius:"full"},"&::-webkit-scrollbar-thumb":{background:"gray.300",borderRadius:"full"},"&::-webkit-scrollbar-thumb:hover":{background:"gray.400"},scrollbarWidth:"thin",scrollbarColor:"gray.300 gray.100"},gap:2,children:[(0,u.jsxs)(C.O,{fontWeight:"500",flexShrink:0,children:["All",l.filter(e=>!e.read).length>0&&(0,u.jsx)(T.x,{as:"span",ml:2,px:2,py:.5,bg:"orange.500",color:"white",borderRadius:"full",fontSize:"11px",fontWeight:"600",children:l.filter(e=>!e.read).length})]}),(0,u.jsxs)(C.O,{fontWeight:"500",flexShrink:0,children:["Requests",eu.filter(e=>!e.read).length>0&&(0,u.jsx)(T.x,{as:"span",ml:2,px:2,py:.5,bg:"orange.500",color:"white",borderRadius:"full",fontSize:"11px",fontWeight:"600",children:eu.filter(e=>!e.read).length})]}),(0,u.jsxs)(C.O,{fontWeight:"500",flexShrink:0,children:["Payments",ep.filter(e=>!e.read).length>0&&(0,u.jsx)(T.x,{as:"span",ml:2,px:2,py:.5,bg:"orange.500",color:"white",borderRadius:"full",fontSize:"11px",fontWeight:"600",children:ep.filter(e=>!e.read).length})]})]})}),(0,u.jsxs)(P.n,{children:[(0,u.jsx)(L.x,{px:0,children:eh(eE)}),(0,u.jsx)(L.x,{px:0,children:eh(eu)}),(0,u.jsx)(L.x,{px:0,children:eh(ep)})]})]})]})})})}}},function(e){e.O(0,[5443,4838,1664,1657,2775,6714,4699,5551,9203,1529,2888,9774,179],function(){return e(e.s=46749)}),_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.