PageSourceSearch

https://knuckl.com/assets/WorkerDashboard-B1VTNVsM.js

js knuckl.com collected 2026-09-24 14:46:33 UTC 58,341 bytes, 1 lines download raw bytes

1import{u as be,a as j,j as e,c as P,i as st}from"./vendor-query-BxlSJxfF.js";import{C as at,a as de,c as re,b as Me,s as rt}from"./submit-review-DKPhkcxU.js";import{B as me}from"./badge-4jZnSn2H.js";import{P as ot}from"./PullToRefresh-BHB5o2lO.js";import{Z as it,a as B,u as G,T as ye,I as nt,B as oe,L as xe,X as ge,e as U,s as k,j as lt,f as ae,m as ue,d as Re,r as ct,$ as dt,a0 as mt,a1 as ut,a2 as pt,a3 as ht}from"./index-DO0aGFYL.js";import{a as xt}from"./use-profile-summary-pcsmjbRV.js";import{u as ft}from"./appReview-CW1-s-M2.js";import{S as bt,a as yt,b as gt,c as jt}from"./sheet-KxRpZ2qz.js";import{T as wt}from"./textarea-CY9O0h4D.js";import{H as vt}from"./Head-CFjoxvyt.js";import{P as _t}from"./PaymentDisclaimer-j5dyffP4.js";import{u as H,d as kt,b as Nt}from"./vendor-react-DdNhUK9-.js";import{m as W,A as ze}from"./vendor-motion-CdL2ySym.js";import{M as Le}from"./mail-jw7BVI6D.js";import{s as Ct,c as St,S as Dt}from"./ShareAppDialog-Cxgpe6xU.js";import{M as It}from"./MomentSharePrompt-D_sKPhPX.js";import{e as fe}from"./jobOccurrences-DBTKhznG.js";import{h as z}from"./haptics-C4kiRWSa.js";import{K as At}from"./KnucklLogo-DmAzyuOm.js";import{b as qt}from"./schedule-utils-D9oAnoFZ.js";import{D as Tt,a as Et,b as Mt,c as Pe,d as Rt}from"./dropdown-menu-CWX03-u_.js";import{u as Lt,W as Pt}from"./WithdrawJobSheet-Cc67P2K1.js";import{E as $t}from"./ellipsis-vertical-hz3e7lEk.js";import{M as Ue}from"./message-square-CLxZQpIa.js";import{L as Ft}from"./log-out-D2Yq8Kil.js";import{T as Ot}from"./TransportOptions-BbKaIp8X.js";import{P as Ye}from"./ProBadge-XhoH1wyr.js";import{C as je}from"./clock-TDYRjmmL.js";import{M as V}from"./map-pin-Clc12hBl.js";import{F as Jt}from"./file-text-CHUqxuo4.js";import{C as $e}from"./car-DO0yWu1G.js";import{W as Kt,t as Fe,i as Wt}from"./profile-strength-i18n-DiF-vRSb.js";import{C as Bt}from"./chevron-left-Bpy2VrDY.js";import{C as Ve}from"./chevron-right-n5eCbV2c.js";import{u as Ge}from"./use-job-recommendations-MNwuX0Y_.js";import{C as Ht}from"./circle-check-big-S3OQIQmC.js";import{S as ie}from"./star-B2GJQJHh.js";import{N as Qt,a as zt,b as Ut,A as Yt}from"./AddLocationBanner-CCCqkWuX.js";import{s as Vt,g as Gt}from"./dismissedJobs-BOWSxrmn.js";import{a as Oe}from"./addDays-CBy3L5y7.js";import{i as Xe}from"./isSameDay-CF4KglHU.js";import{R as Xt}from"./ReferralsCard-CVmJ3YdU.js";import{B as ne}from"./briefcase-DprwYuVO.js";import{C as Zt}from"./camera-vAyeR-gp.js";import{C as Ze}from"./calendar-bL1Vkweo.js";import{L as es}from"./lock-CWPApfun.js";import{A as we}from"./arrow-right-Cxpw4wQL.js";import{g as Je,s as ts,m as ss,r as Ke}from"./pending-shared-jobs-ByGeH9Qv.js";import{S as as}from"./share-2-0UyL2gfq.js";import{c as et,a as rs}from"./profile-completion-CCj5IUp0.js";import{F as os}from"./FirstTimeHint-DY83n2XR.js";import{p as is}from"./parseISO-B5tfR1s8.js";import{L as ns}from"./layers-CKDVPOd0.js";import{L as ls}from"./list-BzmR_WE3.js";import"./check-BTT3mgzE.js";import"./vendor-supabase-Csx7YFID.js";import"./info-CrnkT6_5.js";
1import"./referral-share-DSEBK8Kr.js";import"./gtm-BvBzX99D.js";import"./award-BPuchHpr.js";import"./copy-0DH5VK1i.js";import"./message-circle-BO3xv6Rs.js";import"./sparkles-B9Io74C_.js";import"./moment-share-CYblPAFV.js";import"./party-popper-CcTxkyfz.js";import"./index-Ce1IEqmK.js";import"./index-Bidgsva9.js";import"./index-B9yCq0Ag.js";import"./circle-qEn4UVIP.js";import"./label-Lh_RHPfV.js";import"./application-status-OYVIyYV9.js";import"./popover-wk50W3qJ.js";import"./PushPrePrompt-CM-0ATu6.js";import"./bell-D4WR-0m3.js";import"./use-home-mode-vjQLewqa.js";import"./zap-3WSssjod.js";import"./use-pending-review-count-DlV_gBvd.js";import"./review-window-bRPqN3sJ.js";import"./use-toast-DIh7BwqI.js";import"./coffee-CzwT2awH.js";function cs(i){return+it(i)<Date.now()}const ds="@knuckl.phone";function ms(i){return!!i&&i.toLowerCase().endsWith(ds)}function us(i){return!!i&&!ms(i)}const ps="knuckl_add_email_banner_dismissed";function hs({hasEmail:i,onAdded:x,title:t,body:s,defaultExpanded:b,noDismiss:y,dismissKey:w=ps}){const{t:r}=B(),{user:h}=G(),p=H(),[N,C]=kt(),S=be(),[D,d]=j.useState(()=>y?!1:sessionStorage.getItem(w)==="1"),[m,o]=j.useState(!!b),[l,E]=j.useState(""),[n,M]=j.useState(!1);if(j.useEffect(()=>{if(N.get("addEmail")==="1"){o(!0),d(!1),requestAnimationFrame(()=>{var F;(F=document.getElementById("add-email-banner"))==null||F.scrollIntoView({behavior:"smooth",block:"center"})});const R=new URLSearchParams(N);R.delete("addEmail"),C(R,{replace:!0})}},[]),(i??us(h==null?void 0:h.email))||D||!h)return null;const O=()=>{y||sessionStorage.setItem(w,"1"),d(!0)},v=async()=>{const R=l.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(R)){U.error("Please enter a valid email address");return}M(!0);try{const{data:F,error:Y}=await k.functions.invoke("phone-auth",{body:{action:"attach_email_to_phone_user",userId:h.id,email:R}});if(Y)throw Y;const J=F;if(J!=null&&J.error)throw new Error(J.error);await S.invalidateQueries(),x==null||x(),y||sessionStorage.setItem(w,"1"),d(!0),J!=null&&J.requires_verification?(await k.auth.refreshSession(),U.success("We sent a 6-digit code — verify to finish."),p("/verify-email")):U.success("Email added — you'll now receive notifications")}catch(F){const Y=F instanceof Error?F.message:"Failed to add email";U.error(Y)}finally{M(!1)}};return e.jsx(W.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},id:"add-email-banner",className:"rounded-card border border-primary/30 bg-primary/5 backdrop-blur-sm p-4 mb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 rounded-full bg-primary/15 p-2",children:e.jsx(ye,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t??"Add an email to your account"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s??"You're signed up with phone only. Add an email so you don't miss messages, application updates, or job alerts."}),e.jsx(ze,{initial:!1,children:m?e.jsx(W.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mt-3",children:[e.jsx(nt,{type:"email",inputMode:"email",autoComplete:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,enterKeyHint:"go",placeholder:"[email protected]",value:l,onChange:R=>E(R.target.value),disabled:n,className:"h-9"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(oe,{size:"sm",onClick:v,disabled:n,className:"flex-1 sm:flex-none",children:n?e.jsx(xe,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{className:"h-4 w-4"}),"Save"]})}),e.jsx(oe,{size:"sm",variant:"ghost",onClick:()=>o(!1),disabled:n,children:"Cancel"})]})]})},"form"):e.jsx(W.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"mt-3",children:e.jsxs(oe,{size:"sm",onClick:()=>o(!0),className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),"Add email"]})},"cta")})]}),e.jsx("button",{type:"button",onClick:O,"aria-label":r.aria.dismiss,className:"flex-shrink-0 rounded-full p-1 hover:bg-foreground/5 transition-colors text-muted-foreground",children:e.jsx(ge,{className:"h-4 w-4"})})]})})}function xs({greeting:i,firstName:x,hasLocation:t,hasMatches:s}){const{t:b}=B(),y=H(),w=h=>{z(),window.dispatchEvent(new CustomEvent("knuckl:open-discovery",{detail:h==="today"?{filterDate:new Date}:{filterWeek:!0}}))},r=t?s?b.b7.state.subFindNearby:b.b7.state.subFinding:b.b7.state.subSetLocation;return e.jsxs(W.section,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"flex flex-col items-center text-center pt-6 pb-2","aria-label":b.aria.findWorkToday,children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i,", ",x]}),e.jsx("div",{className:"mt-8 mb-4 flex items-center justify-center",children:e.jsx(At,{size:"lg"})}),e.jsx("h1",{className:"font-display text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:b.b7.state.noWorkBookedToday}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground max-w-xs",children:r}),e.jsxs("div",{className:"w-full max-w-sm mt-6 flex flex-col items-center gap-3",children:[e.jsx("button",{onClick:()=>
1w("today"),className:"w-full min-h-[48px] rounded-full bg-primary text-primary-foreground font-semibold text-base hover:bg-primary/90 transition-colors shadow-[0_4px_18px_-6px_hsl(var(--primary)/0.6)]",children:b.b7.state.findWorkToday}),e.jsxs("button",{onClick:()=>w("week"),className:"text-xs font-medium text-primary hover:underline min-h-[32px]",children:[b.b7.state.browseThisWeek," →"]}),!t&&e.jsxs("button",{onClick:()=>y("/profile"),className:"text-caption text-muted-foreground hover:text-primary transition-colors",children:[b.b7.state.updateLocation," →"]})]})]})}function fs({applicationId:i,jobId:x,jobTitle:t,contractorId:s}){const b=H(),{tr:y}=B(),{data:w}=Lt(x),[r,h]=j.useState(!1),p=!!(w!=null&&w.within24h),N=!!(w!=null&&w.jobDayOrPast),C=()=>{b(s?`/messages?to=${s}`:"/messages")};return e.jsxs(e.Fragment,{children:[e.jsxs(Tt,{children:[e.jsx(Et,{asChild:!0,children:e.jsx(oe,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0 rounded-lg","aria-label":y("workerJobActions.jobOptions"),children:e.jsx($t,{className:"w-4 h-4"})})}),e.jsxs(Mt,{align:"end",className:"w-56",children:[e.jsxs(Pe,{onClick:C,children:[e.jsx(Ue,{className:"w-4 h-4 mr-2"})," ",y("workerJobActions.messageContractor")]}),!N&&e.jsxs(e.Fragment,{children:[e.jsx(Rt,{}),e.jsxs(Pe,{onClick:()=>h(!0),className:p?"text-warning focus:text-warning":"text-destructive focus:text-destructive",children:[p?e.jsx(ye,{className:"w-4 h-4 mr-2"}):e.jsx(Ft,{className:"w-4 h-4 mr-2"}),y("workerJobActions.withdrawFromJob")]})]})]})]}),e.jsx(Pt,{open:r,onOpenChange:h,applicationId:i,jobId:x,jobTitle:t})]})}function bs({greeting:i,firstName:x,jobs:t}){const{t:s}=B(),b=H(),[y,w]=j.useState(0),r=t[y],h=j.useMemo(()=>{if(!(r!=null&&r.shiftStart))return null;const[S,D]=r.shiftStart.split(":").map(Number),d=new Date;d.setHours(S||0,D||0,0,0);const m=d.getTime()-Date.now();if(m<=0)return s.b7.state.startingNow;const o=m/1e3/60/60;return o>3?null:o<1?s.b7.state.startsInMin(Math.max(1,Math.round(m/6e4))):s.b7.state.startsInHr(Math.round(o*10)/10)},[r==null?void 0:r.shiftStart,s]);if(!r)return null;const p=Math.round((r.rideReimbursementAmount??0)/100),N=r.rideClaimStatus??null,C=S=>{z(),window.dispatchEvent(new CustomEvent("knuckl:open-discovery",{detail:S==="today"?{filterDate:new Date}:{filterWeek:!0}}))};return e.jsxs(W.section,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"space-y-4","aria-label":s.aria.todaysJob,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i,", ",x]}),t.length>1&&e.jsx("span",{className:"text-caption font-semibold text-primary bg-primary/10 px-2 py-0.5 rounded-full",children:s.b7.state.youHaveJobsToday(t.length)})]}),e.jsxs("div",{className:"relative bg-card border border-border rounded-card shadow-sm overflow-hidden",children:[e.jsx("div",{className:"h-1.5 w-full bg-primary"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"font-display text-xl sm:text-2xl font-bold text-foreground leading-tight",children:r.title}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-0.5 inline-flex items-center gap-1.5",children:[e.jsx("span",{children:r.contractorName}),e.jsx(Ye,{size:"xs",visible:!!r.contractorIsPaid})]})]}),e.jsx(fs,{applicationId:r.applicationId,jobId:r.jobId,jobTitle:r.title,contractorId:r.contractorId})]}),(r.shiftStart||r.shiftEnd)&&e.jsxs("p",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx(je,{className:"w-4 h-4 text-muted-foreground"}),qt(r.shiftStart,r.shiftEnd)??s.b7.schedule.today]}),r.location&&e.jsxs("p",{className:"flex items-center gap-2 text-sm text-foreground",children:[e.jsx(V,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:r.location})]}),e.jsxs("div",{className:"flex items-end justify-between pt-1",children:[e.jsxs("span",{className:"font-display text-2xl text-primary font-bold",children:["$",r.pay,e.jsxs("span",{className:"text-xs text-muted-foreground ml-1 font-normal",children:["/ ",r.payType||"hr"]})]}),h&&e.jsx("span",{className:"text-xs font-semibold text-primary bg-primary/10 px-2.5 py-1 rounded-full",children:h})]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2.5",children:[e.jsxs("button",{onClick:()=>{z(),b(`/jobs/${r.jobId}`)},className:"min-h-[48px] flex items-center justify-center gap-1.5 rounded-card bg-card border border-border text-sm font-semibold text-foreground hover:border-primary/40 transition-colors",children:[e.jsx(V,{className:"w-4 h-4"})," ",s.b7.state.getThere]}),e.jsxs("button",{onClick:()=>{z(),b(r.contractorId?`/messages?to=${r.contractorId}`:"/messages")},className:"min-h-[48px] flex items-center justify-center gap-1.5 rounded-card bg-card border border-border text-sm font-semibold text-foreground hover:border-primary/40 transition-colors",children:[e.jsx(Ue,{className:"w-4 h-4"})," ",s.b7.state.message]}),e.jsxs("button",{onClick:()=>{z(),b(`/jobs/${r.jobId}`)},className:"min-h-[48px] flex items-center justify-center gap-1.5 rounded-card bg-card border border-border text-sm font-semibold text-foreground hover:border-primary/40 transition-colors",children:[e.jsx(Jt,{className:"w-4 h-4"})," ",s.b7.state.details]})]}),r.needsPickup&&r.pickupConfirmed&&e.jsxs("div",{className:"flex items-start gap-2.5 rounded-card bg-[#E8F5EC] dark:bg-success/10 border border-success/30 px-4 py-3 text-sm text-foreground",children:[e.jsx($e,{className:"w-4 h-4 text-success mt-0.5 shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:["🚗 ",s.b7.state.pickupConfirmed]}),r.pickupTime?` — ${r.pickupTime}`:"",r.pickupLocation?` at ${r.pickupLocation}`:""]})]}),r.needsPickup&&!r.pickupConfirmed&&e.jsxs("div",{className:"flex items-start gap-2.5 rounded-card bg-[#FFF3EE] dark:bg-primary/10 border border-primary/30 px-4 py-3 text-sm text-foreground",children:[e.jsx($e,{className:"w-4 h-4 text-primary mt-0.5 shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:["🚗 ",s.b7.state.pickupRequested]})," — ",s.b7.state.awaitingConfirmation]})]}),r.rideReimbursementOffered&&e.jsxs("div",{className:"flex items-start gap-2.5 rounded-card bg-success/5 border border-success/30 px-4 py-3 text-sm text-foreground",children:[e.jsx(Kt,{className:"w-4 h-4 text-success mt-0.5 shrink-0"}),e.jsxs("span",{children:[!N&&e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["💵 ",s.b7.state.rideAvailable]}),p>0?` — ${s.b7.state.rideUpTo} $${p}`:""]}),N==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["🚗 ",s.b7.state.ridePending]})," — ",s.b7.state.awaitingContractor]}),N==="confirmed"&&e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:["✅ ",s.b7.state.rideConfirmed]})," — ",s.b7.state.getYourRide]}),N==="paid"&&e.jsx(e.Fragment,{children:e.jsxs("strong",{children:["💵 ",s.b7.state.ridePaid]})}),N==="declined"&&e.jsx(e.Fragment,{children:e.jsxs("strong",{children:["❌ ",s.b7.state.rideDeclined]})})]})]}),e.jsx(Ot,{location:r.location??"",lat:r.lat,lng:r.lng,jobTitle:r.title,reimbursement:r.rideReimbursementOffered?{coversUber:!0,coversLyft:!0,maxAmount:p}:null}),t.length>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("button",{onClick:()=>w(S=>Math.max(0,S-1)),disabled:y===0,className:"p-2 rounded-full border border-border disabled:opacity-30","aria-label":s.aria.previousJob,children:e.jsx(Bt,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[y+1," / ",t.length]}),e.jsx("button",{onClick:()=>w(S=>Math.min(t.length-1,S+1)),disabled:y===t.length-1,className:"p-2 rounded-full border border-border disabled:opacity-30","aria-label":s.aria.nextJob,children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"w-full max-w-sm mx-auto pt-2 flex flex-col items-center gap-3",children:[e.jsx("button",{onClick:()=>
1C("today"),className:"w-full min-h-[48px] rounded-full bg-primary text-primary-foreground font-semibold text-base hover:bg-primary/90 transition-colors shadow-[0_4px_18px_-6px_hsl(var(--primary)/0.6)]",children:s.b7.state.findWorkToday}),e.jsxs("button",{onClick:()=>C("week"),className:"text-xs font-medium text-primary hover:underline min-h-[32px]",children:[s.b7.state.browseThisWeek," →"]})]})]})}function ys({greeting:i,firstName:x,jobs:t,reviewable:s,onStartReview:b}){const{t:y}=B(),w=H(),{data:r}=Ge(),h=((r==null?void 0:r.recommendations)??[]).slice(0,3),p=t[0],N=(()=>{if(!(p!=null&&p.pay))return null;if(p.payType==="hourly"&&p.shiftStart&&p.shiftEnd){const[D,d]=p.shiftStart.split(":").map(Number),[m,o]=p.shiftEnd.split(":").map(Number),l=(m??0)+(o??0)/60-((D??0)+(d??0)/60);if(l>0)return Math.round(p.pay*l)}return p.pay})(),C=p?s.find(D=>D.jobId===p.jobId):null,S=D=>{z(),window.dispatchEvent(new CustomEvent("knuckl:open-discovery",{detail:D==="today"?{filterDate:new Date}:{filterWeek:!0}}))};return e.jsxs(W.section,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"space-y-5","aria-label":y.aria.todaysWorkComplete,children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:y.b7.state.goodWorkToday(x)}),p&&e.jsx("div",{className:"bg-card border border-border rounded-card p-5 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-success/15 flex items-center justify-center shrink-0",children:e.jsx(Ht,{className:"w-5 h-5 text-success"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-display text-lg font-bold text-foreground leading-tight",children:[p.title," — ",y.b7.state.completeSuffix]}),p.contractorName&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 inline-flex items-center gap-1.5",children:[e.jsx("span",{children:p.contractorName}),e.jsx(Ye,{size:"xs",visible:!!p.contractorIsPaid})]}),N!=null&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[y.b7.state.earnedApprox," ",e.jsxs("span",{className:"text-primary font-bold",children:["$",N]})," ",y.b7.state.todaySuffix]}),C&&e.jsxs("button",{onClick:()=>{z(),b(C.jobId,C.contractorId)},className:"mt-3 inline-flex items-center gap-1.5 text-sm font-semibold text-primary hover:underline",children:[e.jsx(ie,{className:"w-3.5 h-3.5"})," ",y.b7.state.leaveReviewFor," ",p.contractorName," →"]})]})]})}),h.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground px-1",children:y.b7.state.findMoreThisWeek}),h.map(D=>e.jsx("button",{onClick:()=>w(`/jobs/${D.id}`),className:"w-full text-left bg-card border border-border rounded-card px-4 py-3 hover:border-primary/40 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:D.title}),D.location&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:D.location})]}),e.jsxs("span",{className:"font-display text-base text-primary font-bold shrink-0",children:["$",D.pay]})]})},D.id))]}),e.jsxs("div",{className:"w-full max-w-sm mx-auto pt-2 flex flex-col items-center gap-3",children:[e.jsx("button",{onClick:()=>
1S("today"),className:"w-full min-h-[48px] rounded-full bg-primary text-primary-foreground font-semibold text-base hover:bg-primary/90 transition-colors shadow-[0_4px_18px_-6px_hsl(var(--primary)/0.6)]",children:y.b7.state.findWorkToday}),e.jsxs("button",{onClick:()=>S("week"),className:"text-xs font-medium text-primary hover:underline min-h-[32px]",children:[y.b7.state.browseThisWeek," →"]})]})]})}const We=i=>Array.isArray(i)?i.filter(x=>typeof x=="string"&&x.length>0):[];function gs({inline:i=!1}){const{tr:x}=B(),{user:t}=G(),s=j.useMemo(()=>lt(new Date),[]),b=j.useMemo(()=>Array.from({length:7},(o,l)=>Oe(s,l)),[s]),y=j.useMemo(()=>Oe(s,7),[s]),{data:w}=P({queryKey:["worker-schedule-strip-booked",t==null?void 0:t.id,ae(s,"yyyy-MM-dd")],enabled:!!t,staleTime:6e4,meta:{persist:!1},queryFn:async()=>{const{data:o}=await k.from("applications").select("jobs(start_date, recurrence_end_date, recurrence_pattern, status)").eq("worker_id",t.id).eq("status","accepted"),l=new Set;for(const E of o??[]){const n=E.jobs;if(!(!n||n.status==="closed"))for(const M of fe({start_date:n.start_date,recurrence_end_date:n.recurrence_end_date,recurrence_pattern:n.recurrence_pattern}))l.add(M)}return[...l]}}),{data:r}=P({queryKey:["worker-schedule-strip-blocked",t==null?void 0:t.id],enabled:!!t,staleTime:6e4,meta:{persist:!1},queryFn:async()=>{const{data:o}=await k.from("availability_slots").select("available_date").eq("user_id",t.id).eq("is_blocked",!0).gte("available_date",ae(s,"yyyy-MM-dd")).lte("available_date",ae(y,"yyyy-MM-dd"));return(o??[]).map(l=>l.available_date)}}),h=j.useMemo(()=>new Set(We(w)),[w]),p=j.useMemo(()=>new Set(We(r)),[r]),{data:N}=Ge(),[C,S]=j.useState(0);j.useEffect(()=>Vt(()=>S(o=>o+1)),[]);const D=j.useMemo(()=>{const o=Gt(),l=new Set;for(const E of(N==null?void 0:N.recommendations)??[])if(!o.has(E.id))for(const n of fe({start_date:E.startDate??null,recurrence_end_date:E.endDate??null,recurrence_pattern:E.recurrencePattern??null}))l.add(n);return l},[N,C]),d=o=>{const l=ae(o,"yyyy-MM-dd");return h!=null&&h.has(l)?"booked":p!=null&&p.has(l)?"unavailable":D.has(l)?"available":"empty"},m=o=>{z(),window.dispatchEvent(new CustomEvent("knuckl:open-discovery",{detail:{filterDate:o}}))};return e.jsx("div",{className:Re(i?"relative z-0":"fixed left-0 right-0 z-40 pointer-events-none"),style:i?void 0:{bottom:"calc(64px + env(safe-area-inset-bottom))"},"aria-label":x("scheduleStrip.aria"),children:e.jsx("div",{className:"mx-auto max-w-lg px-3 pointer-events-auto",children:e.jsx("div",{className:"bg-card/95 backdrop-blur-md border border-border rounded-card shadow-[0_4px_20px_-6px_rgba(0,0,0,0.18)] px-2 py-2",children:e.jsx("div",{className:"flex items-center justify-between gap-1.5 overflow-x-auto scrollbar-hide",style:{WebkitOverflowScrolling:"touch"},children:b.map(o=>{const l=d(o),E=Xe(o,s),n="shrink-0 flex flex-col items-center justify-center min-w-[44px] min-h-[48px] rounded-xl border text-micro font-semibold transition-colors relative",M=l==="booked"?"bg-success/15 border-success/40 text-success":l==="unavailable"?"bg-muted/60 border-border text-muted-foreground":"bg-background border-border text-foreground hover:border-primary/40";return e.jsxs("button",{type:"button",onClick:()=>m(o),className:Re(n,M,E&&"ring-1 ring-primary/40"),"aria-label":`${ue(o,"EEEE MMMM d")} — ${l}`,children:[e.jsx("span",{className:"uppercase tracking-wide opacity-70",children:ue(o,"EEE")}),e.jsx("span",{className:"text-sm font-bold leading-none mt-0.5",children:ue(o,"d")}),l==="available"&&e.jsx("span",{"aria-hidden":!0,className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-primary"})]},o.toISOString())})})})})})}const pe=3,he={lat:28.5383,lng:-81.3792,city:"Orlando"},Be={en:{headlineNear:(i,x,t)=>`There are ${i} jobs near ${t} right now`,construction:"construction",matched24h:"Workers who finish setup get matched within 24 hours of jobs going live.",unlock:"unlock",sections:{location:{cta:"Add location"},skills:{cta:"Add work types"},experience:{cta:"Add experience"},photo:{cta:"Add photo"},payAvailability:{cta:"Set pay & days"}}},es:{headlineNear:(i,x,t)=>`Hay ${i} trabajos cerca de ${t} ahora mismo`,construction:"construcción",matched24h:"Los trabajadores que completan su perfil reciben coincidencias dentro de 24 horas.",unlock:"desbloquear",sections:{location:{cta:"Agregar ubicación"},skills:{cta:"Agregar tipo de trabajo"},experience:{cta:"Agregar experiencia"},photo:{cta:"Agregar foto"},payAvailability:{cta:"Configurar pago"}}},pt:{headlineNear:(i,x,t)=>`Há ${i} vagas perto de ${t} agora`,construction:"construção",matched24h:"Operários que completam o cadastro são combinados em até 24 horas.",unlock:"desbloquear",sections:{location:{cta:"Adicionar localização"},skills:{cta:"Adicionar tipos de trabalho"},experience:{cta:"Adicionar experiência"},photo:{cta:"Adicionar foto"},payAvailability:{cta:"Definir pagamento"}}},ht:{headlineNear:(i,x,t)=>`Gen ${i} travay tou pre ${t}
1 kounye a`,construction:"konstriksyon",matched24h:"Travayè ki fini enskripsyon jwenn matche nan 24 èdtan aprè travay yo poste.",unlock:"debloke",sections:{location:{cta:"Ajoute kote"},skills:{cta:"Ajoute kalite travay"},experience:{cta:"Ajoute eksperyans"},photo:{cta:"Ajoute foto"},payAvailability:{cta:"Mete peman"}}},fr:{headlineNear:(i,x,t)=>`Il y a ${i} emplois près de ${t} en ce moment`,construction:"construction",matched24h:"Les ouvriers qui terminent leur profil sont mis en relation en moins de 24h.",unlock:"débloquer",sections:{location:{cta:"Ajouter la localisation"},skills:{cta:"Ajouter les types de travail"},experience:{cta:"Ajouter l'expérience"},photo:{cta:"Ajouter une photo"},payAvailability:{cta:"Définir la paie"}}}};function js(i){return Be[i]??Be.en}const ws=[{key:"location",anchor:"section-location",Icon:V},{key:"skills",anchor:"section-skills",Icon:ne},{key:"experience",anchor:"section-track-record",Icon:je},{key:"photo",anchor:"section-photo",Icon:Zt},{key:"payAvailability",anchor:"section-pay",Icon:Ze}];function vs({lang:i,lat:x,lng:t,city:s,skills:b,missing:y}){const{t:w}=B(),r=H(),h=js(i),p=x??he.lat,N=t??he.lng,C=s??he.city,S=b.length>0,D=S?b[0]:h.construction,{data:d}=P({queryKey:["jobs-for-worker-nudge",p,N,b.join(",")],staleTime:5*6e4,queryFn:async()=>{const{data:n,error:M}=await k.rpc("jobs_for_worker_nudge",{p_lat:p,p_lng:N,p_radius_miles:50,p_skills:S?b:null});if(M)throw M;const q=n??{};return{count_total:Number(q.count_total??0),count_trade:q.count_trade==null?null:Number(q.count_trade),preview:Array.isArray(q.preview)?q.preview:[]}}}),m=ws.filter(n=>y[n.key]),o=((d==null?void 0:d.preview)??[]).slice(0,5),l=S&&(d==null?void 0:d.count_trade)!=null&&d.count_trade>=pe?d.count_trade:(d==null?void 0:d.count_total)??0,E=S&&(d==null?void 0:d.count_trade)!=null&&d.count_trade>=pe?D:h.construction;return l<pe||o.length===0?null:e.jsxs(W.section,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:"mt-5 rounded-card border border-border bg-card p-4 space-y-3 shadow-sm","aria-label":w.aria.jobsWaiting,children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"font-display text-lg font-bold text-foreground leading-snug",children:h.headlineNear(l,E,C)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h.matched24h})]}),e.jsx("ul",{className:"space-y-2",children:o.map((n,M)=>{const q=m.length>0?m[M%m.length]:null,O=q?h.sections[q.key].cta:null,v=(q==null?void 0:q.anchor)??"section-skills",R=(q==null?void 0:q.Icon)??ne;return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>r(`/profile#${v}`),className:"w-full block text-left rounded-xl border border-border bg-background hover:border-primary/40 transition-colors min-h-[48px] overflow-hidden","aria-label":O?`${O} — ${h.unlock}`:h.unlock,children:e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 bg-secondary/40 select-none pointer-events-none",style:{filter:"blur(4px)"},children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-primary/15 flex items-center justify-center shrink-0",children:e.jsx(ne,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate capitalize",children:n.trade??"construction"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[n.area??"—"," · ",ct(n.posted_at)]})]}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"$ ••"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-end pr-3 pl-3 bg-background/30",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-card border border-primary/30 px-3 py-1.5 shadow-sm text-xs font-semibold",style:{color:"#E85D24"},children:[e.jsx(es,{className:"w-3 h-3"}),O?e.jsxs(e.Fragment,{children:[O," ",e.jsx(we,{className:"w-3 h-3"})," ",h.unlock]}):h.unlock,e.jsx(R,{className:"sr-only"})]})})]})})},n.id)})})]})}const He={en:{sharedBy:i=>`Shared with you by ${i}`,sharedAnon:"A contractor shared this job with you",viewJob:"View job",unavailable:"This 
1job is no longer available",dismiss:"Dismiss",section:"Shared with you"},es:{sharedBy:i=>`Compartido contigo por ${i}`,sharedAnon:"Un contratista compartió este trabajo contigo",viewJob:"Ver trabajo",unavailable:"Este trabajo ya no está disponible",dismiss:"Descartar",section:"Compartido contigo"},pt:{sharedBy:i=>`Compartilhado com você por ${i}`,sharedAnon:"Um empreiteiro compartilhou esta vaga com você",viewJob:"Ver vaga",unavailable:"Esta vaga não está mais disponível",dismiss:"Descartar",section:"Compartilhado com você"},ht:{sharedBy:i=>`Pataje avè w pa ${i}`,sharedAnon:"Yon kontraktè pataje travay sa a avè w",viewJob:"Wè travay",unavailable:"Travay sa a pa disponib ankò",dismiss:"Anile",section:"Pataje avè w"},fr:{sharedBy:i=>`Partagé avec vous par ${i}`,sharedAnon:"Un entrepreneur a partagé cet emploi avec vous",viewJob:"Voir l'emploi",unavailable:"Cet emploi n'est plus disponible",dismiss:"Ignorer",section:"Partagés avec vous"}},_s=i=>He[i]??He.en;function ks({lang:i}){const x=H(),t=be(),{user:s}=G(),b=_s(i),[y,w]=j.useState(()=>Je());j.useEffect(()=>ts(()=>w(Je())),[]),j.useEffect(()=>{s!=null&&s.id&&ss(s.id).then(()=>{t.invalidateQueries({queryKey:["shared-jobs-server",s.id]})})},[s==null?void 0:s.id,t]);const{data:r}=P({enabled:!!(s!=null&&s.id),queryKey:["shared-jobs-server",s==null?void 0:s.id],staleTime:3e4,queryFn:async()=>{const{data:m,error:o}=await k.from("pending_shared_jobs").select("id, job_id, contractor_id, contractor_name, created_at").order("created_at",{ascending:!1});if(o)throw o;return m??[]}}),{data:h}=P({enabled:!!(s!=null&&s.id),queryKey:["worker-applied-job-ids",s==null?void 0:s.id],staleTime:3e4,queryFn:async()=>{const{data:m,error:o}=await k.from("applications").select("job_id").eq("worker_id",s.id);if(o)throw o;return new Set((m??[]).map(l=>l.job_id))}}),p=j.useMemo(()=>{const m=[],o=new Set;for(const l of r??[])o.add(l.job_id),m.push({jobId:l.job_id,sharedAt:l.created_at,contractorId:l.contractor_id??void 0,contractorName:l.contractor_name??void 0,origin:"server",serverId:l.id});for(const l of y)o.has(l.jobId)||m.push({...l,origin:"local"});return m.sort((l,E)=>new Date(E.sharedAt).getTime()-new Date(l.sharedAt).getTime())},[r,y]),N=j.useMemo(()=>p.map(m=>m.jobId),[p]),{data:C}=P({enabled:N.length>0,queryKey:["shared-jobs-module",N.slice().sort().join(",")],staleTime:3e4,queryFn:async()=>{const{data:m,error:o}=await k.from("jobs").select("id, title, location, pay, pay_type, status, slots, filled_slots, deleted_at, contractor_id").in("id",N);if(o)throw o;return m??[]}});j.useEffect(()=>{if(!(s!=null&&s.id)||!h||p.length===0)return;const m=p.filter(l=>l.origin==="server"&&h.has(l.jobId)).map(l=>l.serverId).filter(Boolean),o=p.filter(l=>l.origin==="local"&&h.has(l.jobId)).map(l=>l.jobId);m.length>0&&k.from("pending_shared_jobs").delete().in("id",m).then(()=>t.invalidateQueries({queryKey:["shared-jobs-server",s.id]})),o.forEach(Ke)},[h,p,s==null?void 0:s.id,t]);const S=j.useMemo(()=>p.filter(m=>!h||!h.has(m.jobId)),[p,h]);if(S.length===0)return null;const D=new Map((C??[]).map(m=>[m.id,m])),d=async m=>{if(m.origin==="local"){Ke(m.jobId);return}m.serverId&&(await k.from("pending_shared_jobs").delete().eq("id",m.serverId),t.invalidateQueries({queryKey:["shared-jobs-server",s==null?void 0:s.id]}))};return e.jsxs("section",{className:"mt-4 space-y-2","aria-label":b.section,children:[e.jsxs("header",{className:"flex items-center gap-2 px-1",children:[e.jsx(as,{className:"w-4 h-4",style:{color:"#E85D24"}}),e.jsx("h2",{className:"text-sm font-bold text-foreground",children:b.section})]}),e.jsx(ze,{initial:!1,children:S.map(m=>{const o=D.get(m.jobId),l=o?Math.max((o.slots??0)-(o.filled_slots??0),0):0,E=!!o&&o.deleted_at==null&&o.status==="active"&&l>0,n=m.contractorName?b.sharedBy(m.contractorName):b.sharedAnon,M=(o==null?void 0:o.pay)!=null?`$${o.pay}${o.pay_type==="daily"?"/day":o.pay_type==="fixed"?" fixed":"/hr"}`:null;return e.jsx(W.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,height:0,marginTop:0},className:"rounded-card bg-white dark:bg-card border border-[#FFE2D2] dark:border-border shadow-sm overflow-hidden",style:{backgroundColor:"var(--shared-tint, #FFF3EE)"},children:e.jsx("div",{className:"p-3 flex items-start gap-3",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-caption uppercase tracking-wider font-semibold mb-1",style:{color:"#E85D24"},children:n}),E&&o?e.jsxs("button",{type:"button",onClick:()=>{d(m),x(`/jobs/${m.jobId}`)},className:"w-full text-left min-h-[48px] flex items-center gap-3 rounded-xl","aria-label":`${b.viewJob}: ${o.title}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-[#1A1A1A] dark:text-foreground truncate",children:o.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[o.location&&e.jsxs("span",{className:"inline-flex items-center gap-1 truncate",children:[e.jsx(V,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:o.location})]}),M&&e.jsx("span",{className:"font-semibold text-foreground",children:M})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 h-12 px-4 roun
1ded-full text-white text-sm font-semibold shrink-0",style:{backgroundColor:"#E85D24"},children:[b.viewJob," ",e.jsx(we,{className:"w-4 h-4"})]})]}):C===void 0?e.jsx("div",{className:"h-12 flex items-center text-xs text-muted-foreground",children:"…"}):e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-[48px]",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:b.unavailable}),e.jsx("button",{type:"button",onClick:()=>void d(m),className:"h-12 w-12 inline-flex items-center justify-center rounded-full text-muted-foreground active:opacity-70","aria-label":b.dismiss,children:e.jsx(ge,{className:"w-5 h-5"})})]})]})})},m.jobId)})})]})}const Qe="knuckl.profile_nudge_dismissed";function Ns(){const i=H(),{user:x}=G(),{t}=B(),[s,b]=j.useState(()=>{try{return sessionStorage.getItem(Qe)==="1"}catch{return!1}}),{data:y}=P({queryKey:["profile-nudge-strength",x==null?void 0:x.id],enabled:!!x,staleTime:6e4,queryFn:async()=>{var m,o;const[C,S,D]=await Promise.all([k.from("profiles").select("avatar_url, bio").eq("user_id",x.id).single(),k.from("worker_profiles").select("skills, hourly_rate, years_experience, has_own_tools, has_transportation, travel_radius_miles").eq("user_id",x.id).single(),k.from("worker_skill_rates").select("rate").eq("worker_id",x.id)]),d=S.data;return et({bio:((m=C.data)==null?void 0:m.bio)??null,skills:(d==null?void 0:d.skills)??[],years_experience:(d==null?void 0:d.years_experience)??null,has_own_tools:(d==null?void 0:d.has_own_tools)??null,has_transportation:(d==null?void 0:d.has_transportation)??null,travel_radius_miles:(d==null?void 0:d.travel_radius_miles)??null,hourly_rate:(d==null?void 0:d.hourly_rate)??null},((o=C.data)==null?void 0:o.avatar_url)??null,(D.data??[]).map(l=>({rate:(l==null?void 0:l.rate)??null})))}});if(!y||y.score>=86||s)return null;const w=y.nextItem;if(!w)return null;const r=Fe(t,w.labelKey),h=Fe(t,w.benefitKey),p=()=>{try{sessionStorage.setItem(Qe,"1")}
1catch{}b(!0)},N=()=>{w.anchor.startsWith("/")?i(w.anchor):i(`/worker/profile${w.anchor}`)};return e.jsxs("div",{className:"mt-3 rounded-card border border-primary/20 bg-primary/5 px-4 py-3 flex items-center gap-3",children:[e.jsxs("span",{className:"shrink-0 min-w-[40px] text-center text-caption font-bold text-primary bg-primary/15 rounded-full px-2 py-0.5",children:["+",w.points]}),e.jsxs("button",{onClick:N,className:"flex-1 min-w-0 text-left","aria-label":t.profileStrength.nudge.ariaLabel(r,h),children:[e.jsx("span",{className:"block text-sm font-semibold text-foreground",children:r}),e.jsx("span",{className:"block text-caption text-muted-foreground leading-snug",children:h})]}),e.jsx(we,{className:"w-4 h-4 text-primary shrink-0"}),e.jsx("button",{onClick:p,"aria-label":t.profileStrength.nudge.dismiss,className:"text-muted-foreground hover:text-foreground shrink-0 p-1",children:e.jsx(ge,{className:"w-3.5 h-3.5"})})]})}function Cs(){const{user:i}=G(),{data:x}=P({queryKey:["worker-push-nudge-signals",i==null?void 0:i.id],enabled:!!(i!=null&&i.id),staleTime:6e4,queryFn:async()=>{const[b,y]=await Promise.all([k.from("job_invitations").select("id",{count:"exact",head:!0}).eq("worker_id",i.id).eq("status","pending"),k.from("applications").select("id",{count:"exact",head:!0}).eq("worker_id",i.id).eq("status","pending")]);return{invites:b.count??0,applications:y.count??0}}}),t=(x==null?void 0:x.invites)??0,s=(x==null?void 0:x.applications)??0;return e.jsx(Qt,{variant:t>0?"worker-invite":"worker-match",show:t>0||s>0})}function Za(){var ke;const i=H(),x=Nt(),{user:t}=G(),s=be(),b=ft(),[y,w]=j.useState(!1),[r,h]=j.useState(null),[p,N]=j.useState(""),[C,S]=j.useState({}),[D,d]=j.useState(!1),[m,o]=j.useState(!1),[l,E]=j.useState(()=>{try{return sessionStorage.getItem("referralsCardDismissed")==="true"}catch{return!1}}),{t:n,lang:M}=B();j.useEffect(()=>{dt("worker")},[]);const{data:q}=P({queryKey:["profile-nudge-strength",t==null?void 0:t.id],enabled:!!t,staleTime:6e4,queryFn:async()=>{var A,c;const[a,f,_]=await Promise.all([k.from("profiles").select("avatar_url, bio").eq("user_id",t.id).single(),k.from("worker_profiles").select("skills, hourly_rate, years_experience, has_own_tools, has_transportation, travel_radius_miles").eq("user_id",t.id).single(),k.from("worker_skill_rates").select("rate").eq("worker_id",t.id)]),u=f.data;return et({bio:((A=a.data)==null?void 0:A.bio)??null,skills:(u==null?void 0:u.skills)??[],years_experience:(u==null?void 0:u.years_experience)??null,has_own_tools:(u==null?void 0:u.has_own_tools)??null,has_transportation:(u==null?void 0:u.has_transportation)??null,travel_radius_miles:(u==null?void 0:u.travel_radius_miles)??null,hourly_rate:(u==null?void 0:u.hourly_rate)??null},((c=a.data)==null?void 0:c.avatar_url)??null,(_.data??[]).map(I=>({rate:(I==null?void 0:I.rate)??null})))}});j.useEffect(()=>{if(!t||!q||q.score>=61)return;const a=q.nextItem;if(!a)return;const f=`knuckl.weekly_profile_prompt:${t.id}`;let _=0;try{_=Number(localStorage.getItem(f)??0)}catch{}const u=7*24*60*60*1e3;if(Date.now()-_<u)return;const A=setTimeout(()=>{U(n.profileStrength.weekly.title(a.points),{description:Wt(n,a),action:{label:n.profileStrength.weekly.fix,onClick:()=>i(a.anchor.startsWith("/")?a.anchor:`/worker/profile${a.anchor}`)},duration:8e3});try{localStorage.setItem(f,String(Date.now()))}catch{}},1500);return()=>clearTimeout(A)},[t,q,i,n]),j.useEffect(()=>{if(Ct()){const a=setTimeout(()=>{d(!0),St()},800);return()=>clearTimeout(a)}},[]),j.useEffect(()=>{new URLSearchParams(x.search).get("history")==="1"&&w(!0)},[x.search]),j.useEffect(()=>{if(!t)return;const a=k.channel(`worker-applications-${t.id}-${Math.random().toString(36).slice(2,10)}`).on("postgres_changes",{event:"*",schema:"public",table:"applications",filter:`worker_id=eq.${t.id}`},()=>{s.invalidateQueries({queryKey:["worker-today-jobs"]}),s.invalidateQueries({queryKey:["worker-profile-min"]}),s.invalidateQueries({queryKey:["worker-schedule-strip-booked"]}),s.invalidateQueries({queryKey:["work-history"]}),s.invalidateQueries({queryKey:["reviewable-jobs"]}),s.invalidateQueries({queryKey:["worker-applied-job-ids"]}),s.invalidateQueries({queryKey:["worker-today-no-shows"]})}).on("postgres_changes",{event:"INSERT",schema:"public",table:"jobs"},()=>{s.invalidateQueries({queryKey:["job-recommendations",t.id]})}).subscribe();return()=>{k.removeChannel(a)}},[t,s]);const O=st({mutationFn:async()=>{const a=re(C);if(!t||!r||!Me(de,C))throw new Error("Invalid");const f=await rt({jobId:r.jobId,jobType:r.jobType??"day_labor",reviewerId:t.id,revieweeId:r.contractorId,reviewerIsJobPoster:!1,rating:a,comment:p,categories:C});if(f.ok===!1)throw new Error(f.error)},onSuccess:()=>{U.success(n.workerReviews.reviewSubmitted),b(),o(!0),h(null),S({}),N(""),s.invalidateQueries({queryKey:["work-history"]}),s.invalidateQueries({queryKey:["reviewable-jobs"]})},onError:a=>U.error(a.message||"Failed to submit review")}),{data:v}=P({queryKey:["worker-profile-min",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{var A,c,I,L,$,Q,T,g,K,Z,ee,te,se,Ne,Ce,Se,De,Ie,Ae,qe,Te,Ee;const[a,f]=await Promise.all([k.from("profiles").select("full_name, avatar_url, phone, bio").eq("user_id",t.id).single(),k.from("worker_profiles").select("skills, city, location, lat, lng, hourly_rate, availability, badges, available_days, total_jobs, profile_completed_at").eq("user_id",t.id).single()]),[{count:_},{count:u}]=await Promise.all([k.from("work_experience").select("id",{count:"exact",head:!0}).eq("user_id",t.id),k.from("reviews").select("id",{count:"exact",head:!0}).eq("worker_id",t.id)]);return{firstName:((c=(A=a.data)==null?void 0:A.full_name)==null?void 0:c.split(" ")[0])||n.common.worker,fullName:((I=a.data)==null?void 0:I.full_name)||n.common.worker,avatarUrl:((L=a.data)==null?void 0:L.avatar_url)??null,phone:(($=a.data)==null?void 0:$.phone)??null,city:((Q=f.data)==null?void 0:Q.city)??null,location:((T=f.data)==null?void 0:T.location)??null,hasLocation:!!((g=f.data)!=null&&g.city)||((K=f.data)==null?void 0:K.lat)!=null&&((Z=f.data)==null?void 0:Z.lng)!=null,hasCoords:((ee=f.data)==null?void 0:ee.lat)!=null&&((te=f.data)==null?void 0:te.lng)!=null,lat:((se=f.data)==null?void 0:se.lat)??null,lng:((Ne=f.data)==null?void 0:Ne.lng)??null,skills:((Ce=f.data)==null?void 0:Ce.skills)??[],hourlyRate:((Se=f.data)==null?void 0:Se.hourly_rate)??null,availability:((De=f.data)==null?void 0:De.availability)??null,badges:((Ie=f.data)==null?void 0:Ie.badges)??[],bio:((Ae=a.data)==null?void 0:Ae.bio)??"",availableDays:((qe=f.data)==null?void 0:qe.available_days)??[],totalJobs:((Te=f.data)==null?void 0:Te.total_jobs)??0,experienceCount:_??0,reviewsCount:u??0,profileCompletedAt:((Ee=f.data)==null?void 0:Ee.profile_completed_at)??null}}}),{data:R}=P({queryKey:["worker-today-jobs",t==null?void 0:t.id],enabled:!!t,staleTime:6e4,queryFn:async()=>{var $,Q;const a=ae(new Date,"yyyy-MM-dd"),{data:f}=await k.from("applications").select("id, needs_pickup, pickup_confirmed, jobs(id, title, contractor_id, location, lat, lng, pay, pay_type, start_date, recurrence_end_date, recurrence_pattern, shift_start_time, shift_end_time, status, pickup_offered, pickup_location, pickup_time, ride_reimbursement_offered, ride_reimbursement_amount)").eq("worker_id",t.id).eq("status","accepted");if(!f)return[];const _=f.filter(T=>{const g=T.jobs;return!g||g.status==="closed"?!1:fe({start_date:g.start_date,recurrence_end_date:g.re
1currence_end_date,recurrence_pattern:g.recurrence_pattern}).includes(a)}),u=Array.from(new Set(_.map(T=>T.jobs.contractor_id).filter(Boolean))),A=new Map,c=new Map;if(u.length>0){const T=await xt(u);for(const[g,K]of T)A.set(g,(($=K.sub)==null?void 0:$.companyName)||K.displayName||"Contractor"),c.set(g,!!((Q=K.sub)!=null&&Q.isPaid))}const I=_.map(T=>T.jobs.id).filter(Boolean),L=new Map;if(I.length>0){const{data:T}=await k.from("ride_reimbursements").select("job_id, status").eq("worker_id",t.id).in("job_id",I);for(const g of T??[])L.set(g.job_id,g.status)}return _.map(T=>{const g=T.jobs;return{applicationId:T.id,jobId:g.id,title:g.title,contractorId:g.contractor_id,contractorName:g.contractor_id&&A.get(g.contractor_id)||"Contractor",contractorIsPaid:g.contractor_id?c.get(g.contractor_id)??!1:!1,location:g.location,lat:g.lat,lng:g.lng,startDate:g.start_date,shiftStart:g.shift_start_time,shiftEnd:g.shift_end_time,pay:g.pay,payType:g.pay_type,pickupOffered:g.pickup_offered===!0,pickupLocation:g.pickup_location??null,pickupTime:g.pickup_time??null,needsPickup:T.needs_pickup===!0,pickupConfirmed:T.pickup_confirmed===!0,rideReimbursementOffered:g.ride_reimbursement_offered===!0,rideReimbursementAmount:Number(g.ride_reimbursement_amount??0),rideClaimStatus:L.get(g.id)??null}})}}),{data:F,isLoading:Y}=P({queryKey:["work-history",t==null?void 0:t.id],enabled:!!t&&y,queryFn:async()=>{const[a,f,_]=await Promise.all([k.from("applications").select("id, created_at, job_id, jobs(id, title, pay, pay_type, location, start_date, duration, skills, status, closed_at, contractor_id)").eq("worker_id",t.id).eq("status","accepted").order("created_at",{ascending:!1}),k.from("reviews").select("job_id, rating, comment, created_at").eq("worker_id",t.id),k.from("contractor_reviews").select("job_id, rating").eq("worker_id",t.id)]),u=new Map;for(const c of f.data??[])u.set(c.job_id,{rating:c.rating,comment:c.comment,date:c.created_at});const A=new Set((_.data??[]).map(c=>c.job_id));return(a.data??[]).map(c=>{var I,L,$,Q,T,g,K,Z,ee,te,se;return{id:c.id,appliedAt:c.created_at,jobId:((I=c.jobs)==null?void 0:I.id)??c.job_id,title:((L=c.jobs)==null?void 0:L.title)||n.common.jobTitleUnavailable,pay:($=c.jobs)!=null&&$.pay?`$${c.jobs.pay}`:"—",payType:((Q=c.jobs)==null?void 0:Q.pay_type)??"",location:((T=c.jobs)==null?void 0:T.location)??"",startDate:(g=c.jobs)==null?void 0:g.start_date,duration:(K=c.jobs)==null?void 0:K.duration,skills:((Z=c.jobs)==null?void 0:Z.skills)??[],review:u.get(c.job_id)??null,jobStatus:((ee=c.jobs)==null?void 0:ee.status)??"active",closedAt:((te=c.jobs)==null?void 0:te.closed_at)??null,contractorId:((se=c.jobs)==null?void 0:se.contractor_id)??null,hasReviewedContractor:A.has(c.job_id)}})}}),{data:J=[]}=P({queryKey:["reviewable-jobs",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:a}=await k.from("applications").select("job_id, jobs(id, title, contractor_id, closed_at, status, job_type)").eq("worker_id",t.id).eq("status","accepted");if(!a||a.length===0)return[];const{data:f}=await k.from("contractor_reviews").select("job_id").eq("worker_id",t.id),_=new Set((f??[]).map(c=>c.job_id)),u=new Date,A=14*24*60*60*1e3;return a.filter(c=>{const I=c.jobs;if(!I||I.status!=="closed"||!I.closed_at||I.job_type==="sub_package")return!1;const L=new Date(I.closed_at);return u.getTime()-L.getTime()>A?!1:!_.has(c.job_id)}).map(c=>({jobId:c.jobs.id,title:c.jobs.title,contractorId:c.jobs.contractor_id,jobType:c.jobs.job_type,closedAt:c.jobs.closed_at,daysLeft:Math.max(0,Math.ceil((new Date(c.jobs.closed_at).getTime()+A-u.getTime())/(24*60*60*1e3)))}))}}),{data:ve=[]}=P({queryKey:["worker-today-no-shows",t==null?void 0:t.id],enabled:!!t,staleTime:6e4,queryFn:async()=>{const a=new Date().toISOString().slice(0,10),{data:f}=await k.from("applications").select("id, status, jobs(id, title, start_date, recurrence_end_date)").eq("worker_id",t.id).eq("status","no_show");return(f??[]).filter(_=>{const u=_.jobs;return u!=null&&u.start_date?u.start_date===a?!0:u.recurrence_end_date?u.start_date<=a&&a<=u.recurrence_end_date:!1:!1}).map(_=>({id:_.id,jobId:_.jobs.id,title:_.jobs.title}))}}),_e=new Date().getHours(),le=(_e<12?n.workerDashboard.goodMorning:_e<18?n.workerDashboard.goodAfternoon:n.workerDashboard.goodEvening).replace(/,\s*$/,""),ce=(v==null?void 0:v.firstName)||"there",X=j.useMemo(()=>{const a=R??[],f=new Date,_=f.toISOString().slice(0,10),u=a.filter(c=>{if(!c.startDate)return!1;if(c.startDate===_)return!0;try{return Xe(is(c.startDate),f)}catch{return!1}});return u.length===0?"no_job":u.every(c=>{if(!c.shiftStart||!c.shiftEnd)return!1;const[I,L]=c.shiftEnd.split(":").map(Number),$=new Date;return $.setHours(I||0,L||0,0,0),cs($)})?"completed":"job_booked"},[R]);j.useMemo(()=>v?rs({hasPhone:!!v.phone,hasLocation:!!v.hasLocation,hasAvatar:!!v.avatarUrl,skillsCount:(v.skills??[]).length,hasExperience:(v.experienceCount??0)>0,bioLength:(v.bio??"").length,hasRate:!!v.hourlyRate,availableDaysCount:(v.availableDays??[]).length,completedJobs:v.totalJobs??0,reviewsCount:v.reviewsCount??0}):null,[v]);const tt=j.useMemo(()=>J.map(a=>({jobId:a.jobId,title:a.title,contractorId:a.contractorId})),[J]);return e.jsxs(ot,{onRefresh:async()=>{await s.invalidateQueries({queryKey:["worker-today-jobs"]}),await s.invalidateQueries({queryKey:["worker-profile-min"]}),await s.invalidateQueries({queryKey:["reviewable-jobs"]}),await s.invalidateQueries({queryKey:["job-recommendations"]}),await s.invalidateQueries({queryKey:["worker-schedule-strip-booked"]})},children:[e.jsxs("div",{className:"px-4 pt-3 pb-6 max-w-2xl mx-auto",role:"main",children:[e.jsx(vt,{title:"Worker Dashboard",description:"Your work today, at a glance."}),e.jsx(hs,{}),e.jsx(Cs,{}),e.jsx(ks,{lang:M}),e.jsx(zt,{}),e.jsxs("div",{className:"mt-4 mb-2",children:[e.jsx("p",{className:"text-caption font-semibold text-muted-foreground uppercase tracking-widest mb-2 px-1",children:n.workerDashboard.findWork}),e.jsx(os,{storageKey:"knuckl_hint_view_selector_seen",message:((ke=n.hints)==null?void 0:ke.viewSelector)??"Choose how you want to see jobs — swipe, list, or map.",emoji:"👇",position:"top"}),e.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:[{mode:"swipe",Icon:ns,title:n.workerDashboard.swipeMode,desc:n.workerDashboard.swipeModeDesc},{mode:"list",Icon:ls,title:n.workerDashboard.listMode,desc:n.workerDashboard.listModeDesc},{mode:"map",Icon:V,title:n.workerDashboard.mapMode,desc:n.workerDashboard.mapModeDesc}].map(({mode:a,Icon:f,title:_,desc:u})=>e.jsxs("button",{"aria-label":_,onClick:()=>{a==="swipe"?window.dispatchEvent(new CustomEvent("knuckl:open-discovery")):i("/jobs",{state:{defaultView:a}})},className:"flex flex-col items-center gap-1.5 rounded-card border border-border bg-card px-2 py-3 active:scale-95 transition-transform active:bg-primary/5 text-center",children:[e.jsx(f,{size:22,className:"text-primary"}),e.jsx("p",{className:"text-small font-semibold text-foreground leading-none",children:_}),e.jsx("p",{className:"text-micro text-muted-foreground leading-snug",children:u})]},a))})]}),X==="no_job"&&e.jsx(xs,{greeting:le,firstName:ce,hasLocation:!!(v!=null&&v.hasLocation),hasMatches:!0}),X==="job_booked"&&e.jsx(bs,{greeting:le,firstName:ce,jobs:R??[]}),X==="completed"&&e.jsx(ys,{greeting:le,firstName:ce,jobs:R??[],reviewable:tt,onStartReview:(a,f)=>h({jobId:a,contractorId:f||""})}),e.jsx(Ut,{}),v&&v.profileCompletedAt==null&&X!=="completed"&&e.jsx("div",{className:"px-0",children:e.jsx(vs,{lang:M,lat:v.lat,lng:v.lng,city:v.city,skills:v.skills??[],missing:{location:!v.hasLocation,skills:(v.skills??[]).length===0,experience:(v.experienceCount??0)===0,photo:!v.avatarUrl,payAvailability:!v.hourlyRate||(v.availableDays??[]).length===0}})}),e.jsx(Ns,{}),ve.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:ve.map(a=>e.jsxs("div",{className:"rounded-card border border-destructive/30 bg-destructive/10 px-4 py-3 flex items-start gap-2.5",children:[e.jsx(ye,{className:"w-4 h-4 mt-0.5 shrink-0 text-destructive"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-foreground",children:n.workerDashboard.noShowAlert}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:a.title})]})]},a.id))}),v&&!v.hasCoords&&e.jsx(Yt,{}),e.jsx(It,{event:"worker_first_review",active:m,title:n.workerDashboard.firstReviewCelebration,body:n.pass3.momentWorkerBody,shareLabel:n.pass3.momentWorkerShare}),e.jsx(bt,{open:y,onOpenChange:w,children:e.jsxs(yt,{side:"bottom",className:"h-[85dvh] rounded-t-2xl",children:[e.jsx(gt,{className:"pb-4",children:e.jsx(jt,{className:"font-display text-2xl",children:n.workerDashboard.workHistory})}),e.jsx("div",{className:"overflow-y-auto space-y-3 pb-8 pr-1",style:{maxHeight:"calc(85vh - 80px)"},children:Y?e.jsxs("div",{className:"flex justify-center py-12",role:"status","aria-live":"polite",children:[e.jsx(xe,{className:"w-5 h-5 animate-spin text-primary","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:n.common.loading})]}):!F||F.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ne,{className:"w-10 h-10 text-muted-foreground
1/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.workerDashboard.noCompletedJobs}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:n.workerDashboard.completedJobsDesc})]}):F.map((a,f)=>e.jsxs(W.button,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:f*.03},onClick:()=>{w(!1),i(`/jobs/${a.jobId}`)},className:"w-full text-left bg-card/80 backdrop-blur-md rounded-card p-4 border border-border/60 hover:border-primary/30 hover:shadow-sm transition-all",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:a.title}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[a.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3"}),a.location]}),a.startDate&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ze,{className:"w-3 h-3"}),a.startDate]}),a.duration&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"w-3 h-3"}),a.duration]})]}),a.skills.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:a.skills.map(_=>e.jsx(me,{variant:"secondary",className:"text-micro py-0 px-1.5 font-normal",children:_},_))})]}),e.jsxs("div",{className:"text-right shrink-0 flex items-center gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-display text-xl text-primary",children:a.pay}),e.jsx("p",{className:"text-micro text-muted-foreground uppercase",children:a.payType})]}),e.jsx(Ve,{className:"w-4 h-4 text-muted-foreground"})]})]}),a.review?e.jsxs("div",{className:"mt-3 pt-3 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"flex items-center gap-0.5",children:Array.from({length:5},(_,u)=>e.jsx(ie,{className:`w-3.5 h-3.5 ${u<a.review.rating?"text-warning fill-warning":"text-muted-foreground/30"}`},u))}),e.jsxs("span",{className:"text-xs font-medium text-foreground",children:[a.review.rating,"/5"]})]}),a.review.comment&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 italic line-clamp-2",children:['"',a.review.comment,'"']})]}):e.jsx("div",{className:"mt-3 pt-3 border-t border-border flex items-center justify-between",children:e.jsx("p",{className:"text-caption text-muted-foreground/60 italic",children:n.workerDashboard.noReviewYet})}),(()=>{const _=a.jobStatus==="closed",u=a.closedAt?new Date(a.closedAt):null,A=u?new Date(u.getTime()+14*24*60*60*1e3):null,c=new Date,I=A?c<A:!1,L=A?Math.max(0,Math.ceil((A.getTime()-c.getTime())/(24*60*60*1e3))):0;return a.hasReviewedContractor?e.jsx("div",{className:"mt-2",children:e.jsxs(me,{className:"bg-warning/20 text-warning border-warning/30 text-micro",children:["✓ ",n.workerReviews.rateContractor]})}):_&&I?e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),h({jobId:a.jobId,contractorId:a.contractorId})},className:"px-3 py-1.5 rounded-lg bg-primary text-primary-foreground text-xs font-medium hover:bg-primary/90 transition-colors flex items-center gap-1",children:[e.jsx(ie,{className:"w-3 h-3"})," ",n.workerReviews.rateContractor]}),e.jsx("span",{className:"text-micro text-muted-foreground",children:n.workerReviews.daysLeftToReview(L)})]}):_&&!I?e.jsx("div",{className:"mt-2",children:e.jsx(me,{className:"bg-muted text-muted-foreground border-border text-micro",children:n.workerReviews.reviewWindowExpired})}):null})()]},a.id))})]})}),e.jsx(mt,{open:!!r,onOpenChange:a=>{a||(h(null),S({}),N(""))},children:e.jsxs(ut,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsx(pt,{children:e.jsx(ht,{className:"font-display text-xl",children:n.workerReviews.rateContractor})}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:n.workerReviews.howWasExperience}),e.jsx(at,{categories:de,values:C,onChange:(a,f)=>S(_=>({..._,[a]:f}))}),re(C)>0&&e.jsxs("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-border/60",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Overall:"}),e.jsx("span",{className:"text-sm font-bold text-foreground",children:re(C)}),e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(a=>e.jsx(ie,{className:`w-3.5 h-3.5 ${a<=Math.round(re(C))?"text-warning fill-warning":"text-muted-foreground
1/20"}`},a))})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n.workerReviews.rateComment}),e.jsx(wt,{value:p,onChange:a=>N(a.target.value),placeholder:n.workerReviews.rateCommentPlaceholder,className:"bg-secondary border-border",rows:3})]}),e.jsxs("button",{disabled:!Me(de,C)||O.isPending,onClick:()=>O.mutate(),className:"w-full py-2.5 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[O.isPending?e.jsx(xe,{className:"w-4 h-4 animate-spin"}):null,n.workerReviews.submitReview]})]})]})})]}),e.jsx("div",{className:"px-4 pb-3 max-w-2xl mx-auto w-full",children:e.jsx(gs,{inline:!0})}),X!=="completed"&&!l&&e.jsx("div",{className:"px-4 pb-3 max-w-2xl mx-auto w-full",children:e.jsx(Xt,{onDismiss:()=>{try{sessionStorage.setItem("referralsCardDismissed","true")}catch{}E(!0)}})}),e.jsx("div",{className:"px-4 pb-2 max-w-2xl mx-auto w-full",children:e.jsx(_t,{})}),e.jsx("div",{"aria-hidden":!0,className:"h-24"}),e.jsx(Dt,{open:D,onOpenChange:d})]})}export{Za 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.