1import{c as $s,b as De,g as lt,s as Q,A as xs,t as Ks,O as Qt,Q as Bs,u as Jt,X as Vt,S as gs,q as bs,r as ys,v as vs,e as Hs,_ as Vs,z as Zt}from"./index-BkVb42KZ.js";import{a as h,j as e,u as ws,e as Ne}from"./vendor-query-CRhh6spR.js";import{S as Tt,a as Rt,b as Ft,c as zt,d as Dt}from"./select-B5KGv1Do.js";import{u as Us}from"./use-shortlist-CvqefUst.js";import{u as qs}from"./use-connections-YgycEy9k.js";import{u as js}from"./use-subscription-Q7kB2EwX.js";import{citiesMatch as es,haversineMiles as Pt,geocodeCity as Ys}from"./geocode-CX448-fu.js";import{n as $e,u as Js,S as ts,W as Xs,I as Gs,p as Qs,a as Zs}from"./search-normalize-B5CdTFrv.js";import{H as er}from"./Head-B4hXUiBE.js";import{c as tr}from"./profile-completion-CCj5IUp0.js";import{Q as sr}from"./QuickJobDialog-ZZpSNq89.js";import{g as ss,a as rr}from"./MarketRateWarning-CGmSGXXM.js";import nr from"./WorkersMap-DOqaKB9j.js";import{e as Wt,E as ir}from"./entity-icons-BRGQ7M58.js";import{I as or}from"./info-CsexF6vj.js";import{C as _s}from"./chevron-down-CXoJibNt.js";import{L as lr}from"./lock-BhoZ9g-C.js";import{C as dt}from"./check-BtcgJ1Z4.js";import{E as $t}from"./EntityIcon-D-YBmt-d.js";import{m as rs,a as ar,h as Kt,e as ns}from"./viewed-entities-BBR1nlgw.js";import{K as is,i as os,p as Ss,b as ks,c as cr}from"./map-pins-C2PZr5Kz.js";import{l as dr,n as ur,f as mr}from"./lead-headline-CDpCWieG.js";import{u as hr,A as fr}from"./use-contractor-attention-items-DSgW7lRT.js";import{t as pr,a as xr,n as gr}from"./notification-link-CENdaziQ.js";import{u as He,a as br,d as yr}from"./vendor-react-BAmwgVqg.js";import{B as J}from"./briefcase-D-vMkZXu.js";import{M as Qe}from"./message-square-BwPXUwfW.js";import{U as G}from"./users-CLblnKO6.js";import{B as vr}from"./bell-CGtP-THa.js";import{P as wr}from"./ProBadge-CeeKgQ59.js";import{u as jr}from"./use-crew-signals-DvnqqlJQ.js";import{t as _r}from"./image-url-_sEuZELz.js";import{e as Sr,b as ls,m as Te,A as Ns}from"./vendor-motion-BcLIBd36.js";import{S as Xt}from"./search-BNuSVdRk.js";import{L as kr}from"./list-BX8ff7zP.js";import{M as ut}
1from"./map-pin-BnyER353.js";import{C as mt}from"./chevron-right-DSioQ7mT.js";import{B as Nr}from"./building-2-C8te0Xoz.js";import{H as Cr}from"./house-0Xv-8BDy.js";import{P as Er}from"./package-BlcShqlZ.js";import{R as Mr}from"./repeat-msnld17P.js";import{S as Ir}from"./star-BpldOkBP.js";import{u as Ar}from"./use-pending-review-count-CQb0BGms.js";import{C as Lr}from"./clipboard-list-DxTA222t.js";import{S as Ke}from"./skeleton-CRf0VGJi.js";import{u as Or}from"./use-worker-recommendations-BIjZsPXJ.js";import{I as Tr}from"./InviteToJobDialog-C27zAl8P.js";import{S as Cs}from"./sparkles-BuBBRAeM.js";import{U as Rr}from"./undo-2-BMAwPfs4.js";import{Z as Fr}from"./zap-lWgtODcO.js";import{A as Es}from"./arrow-right-B52b088t.js";import{u as zr}from"./CrewList-Bos37ikn.js";import{N as Dr}from"./NeedsReviewSection-Dhhtw3D3.js";import{R as Pr}from"./ReferralsCard-ZCuUR9qH.js";import{P as Wr}from"./PaymentDisclaimer-DkCiTvJU.js";import{u as $r}from"./use-feature-gate-CQ1xTF7b.js";import{F as Kr,a as as}from"./seed-visibility-BxpEBmgQ.js";import{P as Br}from"./PersonPreviewSheet-Vyrd9cie.js";import{L as Hr}from"./locate-fixed-BvHUYlGL.js";import{A as Vr}from"./arrow-up-down-BaWw1Y0Q.js";import"./vendor-charts-BVeOEGzI.js";import"./vendor-stripe-2y4Jo9_W.js";import"./vendor-supabase-Csx7YFID.js";import"./index-D17hSi50.js";import"./index-Bmtd1gWP.js";import"./index-fVqgy0Om.js";import"./chevron-up-DcqJwcAx.js";import"./flash-prefill-CtQFfO_E.js";import"./post-job-sheet-BxL-Oe-u.js";import"./calendar-BOzI1TJy.js";import"./parse-local-date-Cyj0xjkK.js";import"./parseISO-3q6JebNo.js";import"./skill-tiers-B5nM_Fe9.js";import"./switch-rgNxObl6.js";import"./LocationAutocomplete-DhEGcuTZ.js";import"./clock-B5A68DmX.js";import"./MiniMapPreview-5ibW19p3.js";import"./dollar-sign-CoQE7qNd.js";import"./file-text-DfpMrF0r.js";import"./car-Bi5bG36r.js";import"./send-5x2Iukow.js";import"./use-geolocation-CHbY3Amh.js";import"./trending-up-WeSkWL9_.js";import"./MapUnavailable-B5MbGmNr.js";import"./vendor-leaflet-hfhF5hzr.js";import"./external-link-ibDNud24.js";import"./hard-hat-DFuF37sz.js";import"./globe-BUYI8zey.js";import"./phase-status-BY6RT0LZ.js";import"./flag-CJw6Dv0L.js";import"./circle-check-BibDl6sq.js";import"./user-plus-C-YQzt8j.js";import"./popover-D6r7zknv.js";import"./review-window-bRPqN3sJ.js";import"./use-primary-query-LdYs10m3.js";import"./LoadErrorCard-B2FnJgy6.js";import"./use-profile-summary-CvkL6Ay4.js";import"./ContactActions-BppkLExC.js";import"./use-call-worker-3r5ezR1Y.js";import"./use-message-worker-action-DwTPFeve.js";import"./use-messaging-permission-Dax1aQua.js";import"./haptics-C4kiRWSa.js";import"./MessagingGate-DMz-Yzwh.js";import"./message-circle-BTvelDNo.js";import"./badge-DfIFDYyU.js";import"./application-status-E6n3bMhj.js";import"./applicant-match-C-uzOpYD.js";import"./use-referral-status-BFounFqz.js";import"./use-toast-BcDh8CQ0.js";
1import"./referral-share-Ckq6Dnto.js";import"./copy-BEFhSt3P.js";import"./share-2-qYpHQYhX.js";import"./coffee-Ci0O5SGe.js";import"./use-availability-calendar-B6tu-gBc.js";import"./AvailabilityCalendarCard-Bykbk6KH.js";import"./calendar-days-BR8_50Bs.js";import"./chevron-left-D_T4_riH.js";import"./ChatView-ukaCOHC8.js";import"./dropdown-menu-CR6TaDw3.js";import"./index-D5IzgxZK.js";import"./circle-Sm8JI_tc.js";import"./alert-dialog-whTlFcP7.js";import"./ellipsis-vertical-4BGDn3no.js";import"./ban-DV16IFya.js";import"./navigation-Z4x6zh4R.js";import"./arrow-left-B9mh4lKG.js";import"./circle-alert-0D7rBznR.js";import"./BusinessShowcase-BdcVtRfI.js";import"./truck-CtbXv7e4.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ur=$s("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),cs="knuckl.map_legend_expanded",qr={"top-left":"left-3 top-[calc(env(safe-area-inset-top,0px)+6rem)]","top-right":"right-3 top-[calc(env(safe-area-inset-top,0px)+6rem)]","bottom-left":"left-3 bottom-[calc(var(--app-bottom-nav-h,64px)+5rem)] md:bottom-[calc(var(--app-bottom-nav-h,64px)+5.25rem)]","bottom-right":"right-3 bottom-[calc(var(--app-bottom-nav-h,64px)+1rem)] md:bottom-[calc(var(--app-bottom-nav-h,64px)+8.5rem)]"};function Yr({entities:n,entries:c,position:t="top-left"}){const{t:s}=De(),r=h.useRef(null),o=t.startsWith("bottom"),[a,d]=h.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(cs)==="1");h.useEffect(()=>{try{window.localStorage.setItem(cs,a?"1":"0")}catch{}},[a]),h.useEffect(()=>{if(!a)return;const x=T=>{var _;(_=r.current)!=null&&_.contains(T.target)||d(!1)},N=T=>{T.key==="Escape"&&d(!1)};return window.addEventListener("pointerdown",x),window.addEventListener("keydown",N),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",N)}},[a]);const u=x=>{const N=Wt(x),[T,_]=N.label.split("."),L=s[T];return(L==null?void 0:L[_])??_},b=c??(n??[]).map(x=>({kind:"entity",type:x,label:u(x),description:""})),w=x=>{const N=Wt(x);return N.pinUrl?e.jsx("img",{src:N.pinUrl,alt:"",width:22,height:26,className:"object-contain shrink-0",draggable:!1,"aria-hidden":!0}):e.jsx("span",{className:"inline-block w-3 h-3 rounded-full shrink-0",style:{background:N.pinHexDark}})},m=Wt("worker").pinUrl,p=x=>x==="locked"?e.jsxs("span",{className:"relative inline-flex items-center justify-center shrink-0",style:{width:22,height:26},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block rounded-full",style:{width:18,height:18,background:"#1E2A38",border:"1.5px dashed #FBF5E9"}}),e.jsx(lr,{className:"absolute -top-0.5 -right-1 w-3 h-3 text-[#FBF5E9]","aria-hidden":!0})]}):x==="full"?e.jsxs("span",{className:"relative inline-flex items-center justify-center shrink-0",style:{width:22,height:26},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block rounded-full",style:{width:18,height:18,background:"#5A6774",border:"1.5px solid #FBF5E9"}}),e.jsx(dt,{className:"absolute -top-0.5 -right-1 w-3 h-3 text-[#FBF5E9]",strokeWidth:3,"aria-hidden":!0})]}):x==="cluster"?e.jsx("span",{className:"inline-flex items-center justify-center shrink-0 rounded-full text-micro font-bold text-[#1F1F1F]",style:{width:22,height:22,background:"#E85D24",border:"2px solid #FBF5E9",boxShadow:"0 0 0 3px rgba(232,93,36,0.35)"},children:"3"}):x==="focused"?e.jsxs("span",{className:"relative inline-flex items-center justify-center shrink-0",style:{width:26,height:30},children:[e.jsx("span",{"aria-hidden":!0,className:"absolute inset-0 rounded-full",style:{boxShadow:"0 0 0 2px #E85D24, 0 0 0 4px rgba(232,93,36,0.35)"}}),m&&e.jsx("img",{src:m,alt:"",width:22,height:26,className:"object-contain relative",draggable:!1,"aria-hidden":!0})]}):m?e.jsx("img",{src:m,alt:"",width:22,height:26,className:"object-contain shrink-0",style:{opacity:.55,filter:"grayscale(1)"},draggable:!1,"aria-hidden":!0}):null;return e.jsxs("div",{ref:r,className:lt("absolute z-[500] pointer-events-auto flex",o?"flex-col-reverse items-start":"flex-col items-start",qr[t]),children:[e.jsxs("button",{type:"button",onClick:()=>d(x=>!x),"aria-expanded":a,className:lt("inline-flex items-center gap-1.5 h-8 pl-2 pr-2.5 rounded-full text-caption font-semibold text-white","backdrop-blur-md transition-all duration-200 ease-out","hover:bg-[rgba(31,31,31,0.98)] active:scale-95",a&&"shadow-[0_0_0_2px_rgba(232,93,36,0.35)]"),style:{background:"rgba(31,31,31,0.85)",border:"1px solid rgba(251,245,233,0.5)",boxShadow:a?"0 4px 14px rgba(0,0,0,0.5), 0 0 0 2px rgba(232,93,36,0.35)":"0 2px 8px rgba(0,0,0,0.4)"},children:[e.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded-full shrink-0",style:{background:"rgba(232,93,36,0.9)"},children:e.jsx(or,{className:"w-2.5 h-2.5 text-[#FBF5E9]"})}),e.jsx("span",{className:"tracking-wide",children:s.mapLegend.title}),e.jsx(_s,{className:lt("w-3 h-3 opacity-70 transition-transform duration-200",a&&"rotate-180")}
6)]}),a&&e.jsx("div",{className:lt(o?"mb-2":"mt-2","p-3 rounded-card text-caption text-white min-w-[220px]","max-w-[calc(100vw-1.5rem)] sm:max-w-[272px] overflow-y-auto overscroll-contain","backdrop-blur-md animate-in fade-in duration-200",o?"slide-in-from-bottom-1":"slide-in-from-top-1"),style:{maxHeight:"min(60vh, calc(100dvh - var(--app-content-top, 64px) - var(--app-bottom-nav-h, 64px) - 11rem))",background:"rgba(23,23,23,0.92)",border:"1px solid rgba(251,245,233,0.35)",boxShadow:"0 8px 24px rgba(0,0,0,0.55), inset 0 1px 0 rgba(251,245,233,0.08)"},children:e.jsx("ul",{className:"flex flex-col",children:b.map((x,N)=>{const T=b[N-1],_=!!T&&T.kind!==x.kind;return e.jsxs("li",{className:lt("flex items-start gap-3 py-1.5 px-1 rounded-lg","transition-colors hover:bg-white/[0.04]",_&&"mt-1.5 pt-2.5 border-t border-white/10"),children:[e.jsx("span",{className:"flex items-center justify-center w-7 shrink-0 pt-0.5",children:x.kind==="entity"?w(x.type):p(x.visual)}),e.jsxs("span",{className:"flex flex-col leading-tight min-w-0",children:[e.jsx("span",{className:"font-semibold tracking-wide",children:x.label}),x.description&&e.jsx("span",{className:"text-micro text-white/55 mt-0.5 leading-snug",children:x.description})]})]},x.kind==="entity"?`e:${x.type}`:`s:${x.visual}:${N}`)})})})]})}function Jr({userId:n}){var a,d,u,b;const c=He(),t=ws(),{t:s}=De(),{data:r=[],isLoading:o}=Ne({queryKey:["sheet-feed",n],enabled:!!n,queryFn:async()=>{const{data:w,error:m}=await Q.from("notifications").select("id, type, title, body, link, created_at, read, job_id, data").eq("user_id",n).order("created_at",{ascending:!1}).limit(25);if(m)throw m;return w??[]}});return h.useEffect(()=>{if(!n)return;const w=Q.channel(`sheet-feed-${n}-${Math.random().toString(36).slice(2,8)}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"notifications",filter:`user_id=eq.${n}`},()=>t.invalidateQueries({queryKey:["sheet-feed",n]})).subscribe();return()=>{Q.removeChannel(w)}},[n,t]),o?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:((d=(a=s==null?void 0:s.talentSheet)==null?void 0:a.feed)==null?void 0:d.loading)??"Loadingâ¦"}):r.length===0?e.jsx("div",{className:"px-4 py-10 text-center text-sm text-muted-foreground",children:((b=(u=s==null?void 0:s.talentSheet)==null?void 0:u.feed)==null?void 0:b.empty)??"No recent activity."}):e.jsx("ul",{className:"divide-y divide-border/40",children:r.map(w=>{const m=Gr(w.type);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>{const p=gr(w);p&&c(p)},className:`w-full flex items-start gap-3 px-3 py-3 text-left hover:bg-secondary/30 transition-colors ${w.read?"opacity-60":""}`,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary shrink-0 mt-0.5",children:e.jsx(m,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:pr(w.title,s)}),w.body&&e.jsx("p",{className:"text-caption text-muted-foreground line-clamp-2 mt-0.5",children:xr(w.body,s)}),e.jsx("p",{className:"text-micro text-muted-foreground/70 mt-1",children:xs(w.created_at)})]})]})},w.id)})})}const Xr={new_applicant:G,new_applicants_multi:G,application_accepted:G,application_withdrawn:G,worker_confirmed:G,worker_declined:G,worker_cancelled:G,worker_removed:G,worker_removed_late:G,worker_no_show:G,worker_completed:G,worker_paid:G,contractor_worker_withdrew:G,contractor_worker_withdrew_late:G,crew_invite:G,crew_preferred:G,new_message:Qe,cold_message:Qe,connection_made:Qe,support_dm:Qe,whatsapp_opened:Qe,job_update:J,job_closed:J,positions_filled:J,job_needs_closeout:J,job_expiring:J,job_cancelled:J,phase_understaffed:J,job_match:J,urgent_match:J,job_alert:J,spot_reopened:J,sub_package_match:J,job_invitation:J,bid_invitation:J,job_reminder:J,day_before_reminder:J,shift_reminder_1h:J};function Gr(n){const c=(n??"").toLowerCase(),t=Xr[c];return t||(c.includes("application")||c.includes("hire")||c.includes("match")?G:c.includes("message")||c.includes("chat")?Qe:c.includes("job")||c.includes("phase")?J:vr)}function Xe(n){return n.entityKind?n.entityKind:ks(n.id)??"worker"}const Ms="knuckl.talent_sheet_sort";function Qr(){if(typeof window>"u")return"distance";try{const n=window.localStorage.getItem(Ms);if(n==="distance"||n==="rate"||n==="rating")return n}catch{}return"distance"}function ds(n){if(!n)return null;const c=n.match(/\$(\d+(?:\.\d+)?)/);return c?Number(c[1]):null}const Nt=84,Is=.45,Ut=.9,Zr=520,en=760;function _t(n){if(typeof window>"u")return Nt;const c=window.innerHeight;return n==="peek"?Nt:n==="half"?Math.min(Math.round(c*Is),Zr):Math.min(Math.round(c*Ut),en)}function tn({workers:n,snap:c,onSnapChange:t,onSelect:s,entityFilter:r,onEntityFilterChange:o,clusterSubsetIds:a,onClearSubset:d,nearProjectsEnabled:u,onNearProjectsToggle:b,nearProjectsRadius:w,onNearProjectsRadiusChange:m,projectCount:p,availableKinds:x,selectedKinds:N,onKindToggle:T,kindCounts:_,userId:L,onProjectSelect:E,onJobSelect:R,onSubPackageSelect:$,onSubSelect:K,mode:Z,onModeChange:Y,initialMode:ge="list",viewM
6ode:ue,onViewModeChange:ee,leadContent:me,listHeader:X,sections:B,sectionRenderedCount:be=0,onQueryChange:le,quickFilters:ft}){var ce,ie,ke;const{t:C}=De(),ye=C.matching??{},[Re,Ze]=h.useState(Qr),[ve,et]=h.useState(""),tt=l=>{et(l),le==null||le(l)},[Ct,Et]=h.useState(ge),we=Z??Ct,Mt=l=>{Z===void 0&&Et(l),Y==null||Y(l)},Pe=!!L,{items:It}=hr(Pe&&we==="attention"?L:void 0);h.useEffect(()=>{try{window.localStorage.setItem(Ms,Re)}catch{}},[Re]);const te=Sr(_t(c)),Ce=h.useRef(!1),Ve=h.useRef(!1),je=h.useRef(null);h.useEffect(()=>{if(Ce.current)return;const l=_t(c),I=ls(te,l,{type:"spring",stiffness:320,damping:34,mass:.6});return()=>I.stop()},[c]),h.useEffect(()=>{let l=typeof window>"u"?0:window.innerWidth,I=typeof window>"u"?0:window.innerHeight;const S=()=>{const z=window.innerWidth,U=window.innerHeight,P=z!==l,V=Math.abs(U-I)>200;l=z,I=U,!Ce.current&&(!P&&!V||te.set(_t(c)))};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[c]);const ne=8,st=l=>{const I=te.get(),S=window.innerHeight;let z;if(l<-600)z=c==="peek"?"half":"full";else if(l>600)z=c==="full"?"half":"peek";else{const U=Math.abs(I-Nt),P=Math.abs(I-S*Is),V=Math.abs(I-S*Ut),H=Math.min(U,P,V);z=H===U?"peek":H===P?"half":"full"}ls(te,_t(z),{type:"spring",stiffness:320,damping:34,mass:.6}),z!==c&&t(z)},At=(l={})=>({onPointerDown:I=>{if(I.button!==void 0&&I.button!==0)return;Ve.current=!1;const S={id:I.pointerId,startY:I.clientY,startH:te.get(),lastY:I.clientY,lastT:performance.now(),velocity:0,active:!1,downOnly:!!l.downOnly};je.current=S;const z=H=>{var Ae;if(je.current!==S||H.pointerId!==S.id)return;const se=H.clientY-S.startY;if(!S.active){if(Math.abs(se)<ne)return;if(S.downOnly&&(se<0||((Ae=l.canStart)==null?void 0:Ae.call(l))===!1)){V(),je.current=null;return}S.active=!0,Ce.current=!0,Ve.current=!0}const de=performance.now(),Ie=Math.max(1,de-S.lastT);S.velocity=(H.clientY-S.lastY)/Ie*1e3,S.lastY=H.clientY,S.lastT=de;const j=S.startH-se;te.set(Math.max(Nt,Math.min(window.innerHeight*Ut,j))),H.cancelable&&H.preventDefault()},U=H=>{if(H.pointerId!==S.id||(V(),je.current!==S)||(je.current=null,!S.active))return;Ce.current=!1,st(S.velocity);const se=de=>{de.preventDefault(),de.stopPropagation()};document.addEventListener("click",se,!0),window.setTimeout(()=>{document.removeEventListener("click",se,!0),Ve.current=!1},0)},P=H=>{H.pointerId===S.id&&(V(),je.current===S&&(je.current=null,S.active&&(Ce.current=!1,st(0))))};function V(){document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",U),document.removeEventListener("pointercancel",P)}document.addEventListener("pointermove",z,{passive:!1}),document.addEventListener("pointerup",U),document.addEventListener("pointercancel",P)}}),pt=h.useRef(null),_e=At({downOnly:!0,canStart:()=>{var l;return(((l=pt.current)==null?void 0:l.scrollTop)??0)<=0}}),Ue=At(),W=C.talentCluster,qe=jr(),he=h.useMemo(()=>N?n.filter(l=>N.has(Xe(l))):r==="workers"?n.filter(l=>Xe(l)!=="sub"):r==="subs"?n.filter(l=>Xe(l)==="sub"):n,[n,r,N]),rt=h.useMemo(()=>{if(!a||a.length===0)return he;const l=new Set(a);return he.filter(S=>l.has(S.id))},[he,a]),ae=h.useMemo(()=>{const l=$e(ve);return(l?(l?n:rt).filter(z=>{if($e(z.name).includes(l)||(z.skills??[]).some(H=>$e(H).includes(l)))return!0;const P=z.meta;if(P!=null&&P.title&&$e(String(P.title)).includes(l)||P!=null&&P.city&&$e(String(P.city)).includes(l)||P!=null&&P.address&&$e(String(P.address)).includes(l))return!0;const V=z.primarySkill;return!!(V&&$e(V).includes(l))}):rt.slice()).sort((z,U)=>{if(Re==="rate"){const H=ds(z.rateLine)??-1/0;return(ds(U.rateLine)??-1/0)-H}if(Re==="rating")return(U.matchScore??0)-(z.matchScore??0);const P=z.distanceMi??1/0,V=U.distanceMi??1/0;return P-V})},[rt,n,ve,Re]),Fe=!!B&&we==="list",Ee=h.useMemo(()=>Fe?ae.filter(l=>{const I=Xe(l);return!(I==="worker"&&(B!=null&&B.workers)||I==="sub"&&(B!=null&&B.subs))}):ae,[ae,Fe,B]),Ye=Fe?be+Ee.length:ae.length,fe=!!a&&a.length>0,nt=h.useRef(null);h.useEffect(()=>{if(!fe){nt.current=null;return}const l=(a??[]).join(",");nt.current!==l&&(nt.current=l,Ks("contractor.cluster.applied",{kinds:N?[...N]:[r],rendered_count:Ye}))},[fe,a]);const xt=l=>{const I=Xe(l);return I==="sub"?Kt(l.id):os(I)?Kt(ns(I,l.id)):Kt(ns("worker",l.id))},Se=()=>{t(c==="peek"?"half":"peek")},pe=h.useRef(null);h.useEffect(()=>{pe.current&&(pe.current.scrollLeft=0)},[x]);const Me=l=>{var I,S,z,U,P,V,H,se;return l==="worker"?W.chipWorkers:l==="sub"?W.chipSubs:l==="project"?((I=C==null?void 0:C.home)==null?void 0:I.projects)??"Projects":l==="job"?((S=C==null?void 0:C.home)==null?void 0:S.jobs)??"Jobs":l==="homeowner"?((z=C==null?void 0:C.entityLabels)==null?void 0:z.homeowner)??"Homeowner":l==="permit_owner"?((U=C==null?void 0:C.entityLabels)==null?void 0:U.permit_owner)??"Owner permits":l==="permit"?((P=C==null?void 0:C.entityLabels)==null?void 0:P.permit)??"Permits":l==="violation"?((V=C==null?void 0:C.entityLabels)==null?void 0:V.violation)??"Violations":l==="lead_post"?((H=C==null?void 0:C.entityLabels)==null?void 0:H.lead_post)??"Requests":l==="sub_package"?((se=C==null?void 0:C.home)==null?void 0:se.subPackages)??"Sub packages":l};return e.jsxs(Te.div,{role:"dialog","aria-label":W.viewportTitle,className:"fixed left-0 right-0 mx-auto w-full max-w-6xl z-[1100] pointer-events-auto rounded-t-2xl border border-b-0 border-border/60 shadow-[0_-8px_24px_rgba(0,0,0,0.35)] bg-background flex flex-col overflow-hidden",style:{bottom:"var(--contractor-bottom-nav-h, 5rem)",height:te,touchAction:"none"},children:[e.jsx("div",{...Ue,className:"shrink-0 cursor-grab active:cursor-grabbing select-none",children:e.jsxs("div",{className:"flex flex-col items-stretch pt-1",children:[e.jsx("button",{type:"button",onClick:()=>{Ve.current||Se()},"aria-label":W.viewportTitle,className:"mx-auto w-24 py-2 flex items-center justify-center",children:e.jsx("span",{className:"block w-10 h-1.5 rounded-full bg-muted-foreground
6/40"})}),ft&&e.jsx("div",{className:"mt-2 px-3 flex items-center gap-1.5 overflow-x-auto md:overflow-x-visible md:flex-wrap no-scrollbar snap-x scroll-pl-3",style:{touchAction:"pan-x"},children:ft}),N&&x&&x.length>0?e.jsx("div",{ref:pe,className:"mt-2 px-3 pb-2 flex items-center gap-1.5 overflow-x-auto md:overflow-x-visible md:flex-wrap no-scrollbar snap-x scroll-pl-3",role:"group","aria-label":W.viewportTitle,style:{touchAction:"pan-x"},children:x.filter(l=>!_||(_[l]??0)>0).map(l=>{const I=N.has(l),S=(_==null?void 0:_[l])??0,z=S===0;return e.jsxs("button",{type:"button",onClick:()=>{Ve.current||T==null||T(l)},"aria-pressed":I,className:`inline-flex shrink-0 snap-start items-center gap-1 h-8 px-3 rounded-full text-caption font-semibold border transition-colors whitespace-nowrap ${I&&!z?"bg-primary text-primary-foreground border-primary":I&&z?"bg-transparent text-muted-foreground/70 border-primary/50":!I&&!z?"bg-card text-foreground border-border/60 hover:bg-secondary/40":"bg-card text-muted-foreground/50 border-border/60"}`,children:[e.jsx("span",{"aria-hidden":!0,className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:is[l],outline:I?"1.5px solid rgba(255,255,255,0.7)":"none"}}),e.jsx("span",{children:Me(l)}),e.jsx("span",{className:`text-caption tabular-nums ${I&&!z?"opacity-90":"opacity-70"}`,children:`(${S})`})]},l)})}):e.jsx("div",{className:"pb-2"})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[me&&e.jsx("div",{className:"shrink-0 px-3 pb-2 border-b border-border/60",children:me}),e.jsxs("div",{className:"px-4 pb-2 space-y-2",children:[X&&we==="list"&&e.jsx("div",{className:"pt-1",children:X}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Xt,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"search",value:ve,onChange:l=>tt(l.target.value),placeholder:W.searchPlaceholder,onFocus:()=>{c==="peek"&&t("half")},className:"w-full h-9 pl-8 pr-3 rounded-lg bg-secondary/40 border border-border/60 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})]}),B!=null&&B.workers&&we==="list"?e.jsx("div",{className:"h-9 px-2.5 rounded-lg bg-secondary/40 border border-border/60 text-xs font-medium flex items-center text-muted-foreground",children:W.sortDistance}):e.jsxs("select",{value:Re,onChange:l=>Ze(l.target.value),className:"h-9 px-2 rounded-lg bg-secondary/40 border border-border/60 text-xs font-medium","aria-label":W.sortAria,children:[e.jsx("option",{value:"distance",children:W.sortDistance}),e.jsx("option",{value:"rate",children:W.sortRate}),e.jsx("option",{value:"rating",children:W.sortRating})]})]}),ve.trim().length>0&&(a&&a.length>0||N&&x&&N.size<x.length)&&e.jsx("div",{className:"text-micro text-muted-foreground px-0.5",children:"Searching all in view â filters ignored while typing."}),ue&&ee&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-secondary/40 p-0.5 border border-border/60",role:"group","aria-label":ye.bestMatches??"Best matches",children:["best","all"].map(l=>{const I=ue===l,S=l==="best"?ye.bestMatches??"Best matches":ye.allWorkers??"All workers";return e.jsx("button",{type:"button",onClick:()=>ee(l),"aria-pressed":I,className:`flex-1 h-7 rounded-md text-caption font-semibold transition-colors ${I?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:S},l)})}),e.jsx("p",{className:"text-micro text-muted-foreground px-0.5",children:ue==="best"?ye.bestMatchesHint??"Filtered by your active jobs and skills":ye.allWorkersHint??"Everyone in your area"})]}),N&&x&&x.length>1?null:e.jsx("div",{className:"flex items-center gap-1.5",role:"group","aria-label":W.viewportTitle,children:["all","workers","subs"].map(l=>{const I=r===l,S=l==="all"?W.chipAll:l==="workers"?W.chipWorkers:W.chipSubs;return e.jsxs("button",{type:"button",onClick:()=>o(l),"aria-pressed":I,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-caption font-semibold border transition-colors ${I?"bg-primary text-primary-foreground border-primary":"bg-card text-muted-foreground border-border/60 hover:text-foreground"}`,children:[l==="workers"&&e.jsx(G,{className:"w-3 h-3"}),l==="subs"&&e.jsx($t,{type:"sub",size:10}),S]},l)})}),Pe&&e.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-secondary/40 p-0.5 border border-border/60",children:["list","attention","feed"].map(l=>{var z,U,P,V,H,se;const I=we===l,S=l==="list"?((U=(z=C==null?void 0:C.talentSheet)==null?void 0:z.mode)==null?void 0:U.list)??"List":l==="attention"?((V=(P=C==null?void 0:C.talentSheet)==null?void 0:P.mode)==null?void 0:V.attention)??"Attention":((se=(H=C==null?void 0:C.talentSheet)==null?void 0:H.mode)==null?void 0:se.feed)??"Feed";return e.jsx("button",{type:"button",onClick:()=>Mt(l),"aria-pressed":I,className:`flex-1 h-7 rounded-md text-caption font-semibold transition-colors ${I?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:S},l)})}),p>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>b(!u),"aria-pressed":u,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-caption font-semibold border transition-colors ${u?"bg-primary text-primary-foreground border-primary":"bg-card text-muted-foreground border-border/60 hover:text-foreground"}`,children:[e.jsx($t,{type:"project",size:10}),W.proximityFilter.label]}),u&&e.jsx("div",{className:"inline-flex items-center rounded-full border border-border/60 bg-card overflow-hidden",role:"group","aria-label":W.proximityFilter.label,children:[5,15,25].map(l=>{const I=w===l;return e.jsxs("button",{type:"button",onClick:()=>m(l),"aria-pressed":I,className:`h-7 px-2 text-caption font-semibold transition-colors ${I?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:[l," ",W.proximityFilter.radiusUnit]},l)})})]}),fe&&e.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1.5 rounded-lg bg-secondary/60 border border-border/60 text-caption",children:[e.jsx("span",{className:"truncate text-foreground
6/85",children:Ye===0?W.clusterEmpty:W.showingCluster.replace("{count}",String(Ye))}),e.jsxs("button",{type:"button",onClick:d,className:"shrink-0 inline-flex items-center gap-1 px-2 h-6 rounded-md bg-background border border-border/60 text-micro font-semibold text-foreground hover:bg-secondary/40",children:[e.jsx(kr,{className:"w-3 h-3"})," ",W.showAllInView]})]})]}),e.jsx("div",{ref:pt,..._e,className:"flex-1 overflow-y-auto px-2 pb-6",style:{touchAction:"pan-y"},children:we==="attention"&&Pe?e.jsx("div",{className:"px-2 pt-2",children:e.jsx(fr,{userId:L,items:It,a:((ce=C==null?void 0:C.contractorJobs)==null?void 0:ce.attention)??{}})}):we==="feed"&&Pe?e.jsx(Jr,{userId:L}):e.jsxs("div",{className:"pt-1 space-y-4",children:[Fe&&((ie=B==null?void 0:B.workers)==null?void 0:ie.call(B,{query:ve})),Fe&&((ke=B==null?void 0:B.subs)==null?void 0:ke.call(B,{query:ve})),Ee.length===0?(!Fe||Ye===0)&&e.jsxs("div",{className:"text-center text-sm text-muted-foreground py-10 px-4 space-y-3",children:[e.jsx("p",{children:n.length===0?W.emptyViewport:W.emptySearch}),ue==="best"&&ee&&e.jsx("button",{type:"button",onClick:()=>ee("all"),className:"inline-flex items-center gap-1 h-8 px-3 rounded-full bg-primary text-primary-foreground text-caption font-semibold",children:ye.switchToAllCta??"Show all"})]}):e.jsx("ul",{className:"divide-y divide-border/40",children:Ee.map(l=>{var Ae,it,gt,Le,ot,bt,yt;const I=xt(l),S=Xe(l),z=S==="sub",U=S==="project",P=S==="job",V=S==="sub_package",H=S==="worker",se=S==="homeowner",de=(l.name??"?").split(" ").map(re=>re[0]).filter(Boolean).join("").slice(0,2).toUpperCase(),Ie=H?l.primarySkill??(l.skills??[])[0]??"":(l.skills??[]).slice(0,3).join(" · "),j=l.meta;if(os(S)){const re=j!=null&&j.headline?{headline:j.headline,reference:j.reference??null,hasAddress:!0}:dr(j),Oe=(C==null?void 0:C.external)??{},ze=ur(j==null?void 0:j.lead_kind),xe=((Ae=Oe.kind)==null?void 0:Ae[ze])??ze,Je=is[S],Lt=((it=ir[S])==null?void 0:it.Icon)??J,We=(j==null?void 0:j.my_status)??"new",vt=(gt=Oe.notes)==null?void 0:gt[`status${We.charAt(0).toUpperCase()}${We.slice(1)}`],wt=mr(j==null?void 0:j.acts_by),jt=[xe,re.hasAddress?(j==null?void 0:j.trade)??l.name:j==null?void 0:j.trade,[j==null?void 0:j.city,j==null?void 0:j.state].filter(Boolean).join(", "),j!=null&&j.posted_at?xs(j.posted_at):null].filter(Boolean).join(" · ");return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>{rs(S,l.id),t("peek"),s(l)},className:`w-full flex items-start gap-3 px-2 py-3 text-left hover:bg-secondary/30 rounded-lg transition-colors ${I?"opacity-60":""}`,children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg grid place-items-center",style:{backgroundColor:`${Je}26`,color:Je},children:e.jsx(Lt,{className:"w-5 h-5"})}),I&&e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-4 h-4 rounded-full bg-success text-white flex items-center justify-center border border-background",children:e.jsx(dt,{className:"w-2.5 h-2.5",strokeWidth:3})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:re.headline}),(j==null?void 0:j.matches_trades)&&e.jsx("span",{className:"shrink-0 inline-flex items-center px-1.5 py-0.5 rounded-full bg-primary/15 text-primary text-micro font-bold uppercase tracking-wider",children:((Le=Oe.feed)==null?void 0:Le.matchesTrades)??"Match"})]}),e.jsx("div",{className:"text-caption text-muted-foreground truncate",children:jt}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-micro text-muted-foreground",children:[re.reference&&re.hasAddress&&e.jsx("span",{className:"font-mono truncate",children:re.reference}),(j==null?void 0:j.source_label)&&e.jsx("span",{className:"uppercase tracking-wider truncate",children:j.source_label}),wt&&e.jsx("span",{className:"text-destructive shrink-0",children:wt}),We!=="new"&&vt&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-full bg-secondary text-foreground/80",children:vt}),((j==null?void 0:j.note_count)??0)>0&&e.jsx("span",{className:"shrink-0",children:`ð ${j==null?void 0:j.note_count}`})]})]}),l.distanceMi!=null&&e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 text-caption text-muted-foreground",children:[e.jsx(ut,{className:"w-2.5 h-2.5"}),l.distanceMi.toFixed(1)," mi"]}),e.jsx(mt,{className:"w-4 h-4 text-muted-foreground shrink-0"})]})},l.id)}return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>
6{if(z?ar(l.id):S==="worker"&&rs("worker",l.id),t("peek"),U&&E)E(l.id);else if(P&&R)R(l.id);else if(V&&$)$(l.id);else if(z&&K){const re=Ss(l.id);K(re)}else s(l)},className:`w-full flex items-center gap-3 px-2 py-3 text-left hover:bg-secondary/30 rounded-lg transition-colors ${I?"opacity-60":""}`,children:[e.jsxs("div",{className:"relative shrink-0",children:[U?e.jsx("div",{className:"w-10 h-10 rounded-lg bg-[hsl(var(--entity-project))]/20 flex items-center justify-center text-[hsl(var(--entity-project-ink))]",children:e.jsx(Nr,{className:"w-5 h-5"})}):P?e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/15 flex items-center justify-center text-primary",children:e.jsx(J,{className:"w-5 h-5"})}):se?e.jsx("div",{className:"w-10 h-10 rounded-lg bg-[hsl(var(--entity-homeowner))]/15 flex items-center justify-center text-[hsl(var(--entity-homeowner))]",children:e.jsx(Cr,{className:"w-5 h-5"})}):V?e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-500",children:e.jsx(Er,{className:"w-5 h-5"})}):l.avatarUrl?e.jsx("img",{loading:"lazy",decoding:"async",src:_r(l.avatarUrl,96),alt:"",className:"w-10 h-10 rounded-full object-cover border border-border/60"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-secondary flex items-center justify-center text-xs font-semibold text-muted-foreground",children:de}),I&&e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-4 h-4 rounded-full bg-success text-white flex items-center justify-center border border-background",children:e.jsx(dt,{className:"w-2.5 h-2.5",strokeWidth:3})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:l.name}),se&&e.jsx("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-[hsl(var(--entity-homeowner))]/15 text-[hsl(var(--entity-homeowner))] border border-[hsl(var(--entity-homeowner))]/40 text-micro font-bold uppercase tracking-wider",children:((ot=C==null?void 0:C.entityLabels)==null?void 0:ot.homeowner)??"Homeowner"}),z&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-[hsl(var(--entity-sub))]/25 text-[hsl(var(--entity-sub-ink))] border border-[hsl(var(--entity-sub))]/40 text-micro font-bold uppercase tracking-wider",children:[e.jsx($t,{type:"sub",size:9,className:"text-[hsl(var(--entity-sub-ink))]"}),W.subPill]}),z&&l.isPaid&&e.jsx(wr,{visible:!0,size:"xs"}),H&&(((bt=qe.get(l.id))==null?void 0:bt.jobsTogether)??0)>0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-primary/10 text-primary border border-primary/30 text-micro font-semibold shrink-0",children:[e.jsx(Mr,{className:"w-2.5 h-2.5"}),(yt=C.crew)!=null&&yt.workedWithYou?C.crew.workedWithYou(qe.get(l.id).jobsTogether):`Worked with you (${qe.get(l.id).jobsTogether})`]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-caption text-muted-foreground truncate",children:[U?e.jsx("span",{className:"truncate",children:[j==null?void 0:j.address,j==null?void 0:j.status].filter(Boolean).join(" · ")||l.status||"â"}):P?e.jsx("span",{className:"truncate",children:(j==null?void 0:j.slots)!=null?`${(j==null?void 0:j.filledSlots)??0}/${j==null?void 0:j.slots} filled`:l.status??"â"}):V?e.jsx("span",{className:"truncate",children:(()=>{var Oe,ze;const re=l.bidCount;if(re!=null&&re>0){const xe=(Oe=C==null?void 0:C.talentSheet)==null?void 0:Oe.bidsCount;return typeof xe=="function"?xe(re):`${re} bid${re===1?"":"s"}`}return re===0?((ze=C==null?void 0:C.talentSheet)==null?void 0:ze.noBidsYet)??"No bids yet":l.status??"Open for bids"})()}):Ie&&e.jsx("span",{className:"truncate",children:Ie}),l.distanceMi!=null&&e.jsxs("span",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx(ut,{className:"w-2.5 h-2.5"}),l.distanceMi.toFixed(1)," mi"]})]})]}),(P||V)&&l.budget!=null?e.jsxs("div",{className:"shrink-0 text-right text-xs font-semibold text-foreground",children:["$",Number(l.budget).toLocaleStr
6ing()]}):l.rateLine&&e.jsx("div",{className:"shrink-0 text-right text-xs font-semibold text-foreground",children:l.rateLine}),l.matchScore!=null&&e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 text-caption text-warning font-semibold ml-1",children:[e.jsx(Ir,{className:"w-3 h-3 fill-warning"}),Math.round(l.matchScore)]}),(U||P||V)&&e.jsx(mt,{className:"w-4 h-4 text-muted-foreground shrink-0"})]})},l.id)})})]})})]})]})}const at="#E85D24",sn="#FFF3EE",rn="#3A2418",nn="#F4F4F5",on="#52525B",ln="#18181B",us="#71717A",an="#1F1F1F",cn="#3A3A3A",dn="#262626",un="#A0A0A0",mn="#FFFFFF",ms="#999999",St='"DM Sans", system-ui, -apple-system, sans-serif';function kt({icon:n,value:c,label:t,context:s,priority:r=!1,showDot:o=!1,onPress:a,ariaLabel:d,className:u}){const b=typeof a=="function",w=b?Te.button:Te.div,[m,p]=h.useState(()=>Qt()==="dark");h.useEffect(()=>(p(Qt()==="dark"),Bs((K,Z)=>p(Z==="dark"))),[]);const x=m?an:"#FFFFFF",N=m?cn:"transparent",T=r?m?rn:sn:m?dn:nn,_=r?at:m?un:on,L=r?at:m?mn:ln,E=r?at:m?ms:us,R=m?ms:us,$=b?{type:"button",onClick:a,whileTap:{scale:.98},"aria-label":d}:{};return e.jsxs(w,{...$,style:{backgroundColor:x,borderRadius:16,boxShadow:m?"0 1px 4px rgba(0,0,0,0.4)":"0 1px 4px rgba(0,0,0,0.08)",minHeight:48,height:"auto",minWidth:48,borderColor:r?at:N,borderWidth:r?1.5:1,borderStyle:"solid",fontFamily:St},className:["relative flex flex-col items-start justify-start text-left py-2.5 px-3 transition-transform self-start",b?"active:scale-[0.98] cursor-pointer":"",u??""].join(" "),children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center mb-1.5 shrink-0",style:{backgroundColor:T,color:_},children:n}),o&&e.jsx("span",{"aria-hidden":"true",className:"absolute top-2.5 right-2.5 inline-flex h-2 w-2 rounded-full",style:{backgroundColor:at}}),e.jsx("p",{className:"text-2xl font-bold leading-none tracking-tight",style:{color:L,fontFamily:St},children:c}),t&&e.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold mt-0.5 leading-tight",style:{color:R,fontFamily:St},children:t}),s&&e.jsxs("p",{className:"text-[11px] leading-tight flex items-center gap-0.5 min-w-0 w-full mt-1",style:{color:E,fontFamily:St},children:[e.jsx("span",{className:"truncate",children:s}),e.jsx(mt,{className:"w-3 h-3 shrink-0"})]})]})}function hn({activeCount:n,pendingReviewCount:c,jobsNeedingWorkers:t,recommendedWorkersCount:s}){const r=He(),{t:o}=De();return e.jsxs(Te.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"grid grid-cols-3 gap-2.5",children:[e.jsx(kt,{icon:e.jsx(Lr,{className:"w-4 h-4"}),value:c,context:o.b6.stats.leaveReview,priority:c>0,onPress:()=>r("/contractor/pending-reviews"),ariaLabel:`${c} pending review${c===1?"":"s"}`}),t>0?e.jsx(kt,{icon:e.jsx(J,{className:"w-4 h-4"}),value:t,context:o.b6.stats.jobsNeedWorkers,onPress:()=>r("/contractor/jobs?filter=active"),ariaLabel:`${t} job${t===1?"":"s"} need workers`}):e.jsx(kt,{icon:e.jsx(G,{className:"w-4 h-4"}),value:s,context:o.b6.stats.viewRecommended,onPress:()=>r("/home"),ariaLabel:`${s} recommended workers`}),e.jsx(kt,{icon:e.jsx(Xt,{className:"w-4 h-4"}),value:o.b6.stats.browse,context:o.b6.stats.searchWorkers,onPress:()=>r("/home"),ariaLabel:o.b6.stats.searchWorkers})]})}const fn=3,hs=3;function pn(n){return n>=80?{dot:"bg-success",text:"text-success",bg:"bg-success/15",border:"border-success/30"}:n>=60?{dot:"bg-primary",text:"text-primary",bg:"bg-primary/15",border:"border-primary/30"}:{dot:"bg-warning",text:"text-warning",bg:"bg-warning/15",border:"border-warning/30"}}const Be="knuckl_skipped_workers";function xn(){try{const n=localStorage.getItem(Be);if(!n)return new Set;const c=JSON.parse(n),t=Date.now(),s=Object.entries(c).filter(([,r])=>t-r<864e5);return s.length!==Object.keys(c).length&&localStorage.setItem(Be,JSON.stringify(Object.fromEntries(s))),new Set(s.map(([r])=>r))}catch{return new Set}}function gn(n){try{const c=localStorage.getItem(Be),t=c?JSON.parse(c):{};t[n]=Date.now(),localStorage.setItem(Be,JSON.stringify(t))}catch{}}function bn({worker:n,jobId:c,onSkip:t}){var w,m;const s=He(),[r,o]=h.useState(!1),a=n.name.split(" ").map(p=>p[0]).join("").slice(0,2),d=pn(n.score),u=(w=n.skills)==null?void 0:w[0],b=p=>p.stopPropagation();return e.jsxs(Te.div,{initial:{opacity:0,x:8}
6,animate:{opacity:1,x:0},exit:{opacity:0,x:-8,height:0},layout:!0,onClick:()=>s(`/profile/${n.userId}`),role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s(`/profile/${n.userId}`))},className:"rounded-xl bg-secondary/30 border border-border/60 hover:border-primary/30 hover:bg-secondary/50 transition-all group overflow-hidden cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary flex items-center justify-center text-xs font-bold text-primary-foreground ring-1 ring-primary/30 shrink-0",children:a}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate group-hover:text-primary transition-colors",children:n.name}),e.jsxs("span",{className:`shrink-0 text-micro font-bold px-1.5 py-0.5 rounded-md ${d.bg} ${d.text} border ${d.border}`,children:[n.score,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[u&&e.jsx("span",{className:"text-micro font-medium px-1.5 py-0.5 rounded-md bg-primary/10 text-primary border border-primary/20 truncate max-w-[120px]",children:u}),n.location&&e.jsxs("span",{className:"flex items-center gap-0.5 text-micro text-muted-foreground truncate max-w-[120px]",children:[e.jsx(ut,{className:"w-2.5 h-2.5 shrink-0"})," ",n.location]})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",onClick:b,children:[e.jsxs("button",{onClick:p=>{b(p),o(!0)},className:"inline-flex items-center gap-1 px-3 py-1.5 rounded-full bg-primary text-primary-foreground text-caption font-semibold hover:bg-primary/90 active:scale-95 transition-all shadow-sm","aria-label":`Invite ${n.name} to a job`,children:["Invite to Job ",e.jsx(Es,{className:"w-3 h-3"})]}),e.jsx("button",{onClick:p=>{b(p),t(n.userId,c,n.name)},className:"text-micro text-muted-foreground hover:text-destructive transition-colors px-1",children:"â Skip"})]})]}),r&&e.jsx(Tr,{open:r,onClose:()=>o(!1),workerId:n.userId,workerName:n.name,defaultSkill:((m=n.skills)==null?void 0:m[0])??""})]})}function yn({rec:n,skippedIds:c,onSkip:t,index:s}){const r=He(),o=n.workers.filter(w=>!c.has(`${w.userId}-${n.jobId}`)),a=o.slice(0,hs),d=o.length>hs,u=!!n.boostedUntil&&new Date(n.boostedUntil).getTime()>Date.now(),b=u?Math.max(1,Math.round((new Date(n.boostedUntil).getTime()-Date.now())/36e5)):0;return e.jsxs(Te.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:s*.08,duration:.4,ease:[.16,1,.3,1]},className:`rounded-card bg-card/90 backdrop-blur-md border overflow-hidden group/card transition-all relative ${u?"border-primary/50 ring-1 ring-inset ring-primary/30 shadow-[0_8px_30px_-10px_hsl(var(--primary)/0.45)]":"border-border/60 hover:border-primary/30"}`,children:[u&&e.jsx("div",{className:"h-1 w-full bg-gradient-to-r from-primary via-primary/70 to-transparent"}),e.jsxs("div",{className:"flex items-start gap-3 p-4 pb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0",children:e.jsx(J,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"text-sm font-display font-semibold text-foreground truncate",children:n.jobTitle}),u&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 shrink-0 text-micro font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-md bg-primary text-primary-foreground border border-primary shadow-sm",title:`Boosted · ${b}h left`,children:[e.jsx(Fr,{className:"w-2.5 h-2.5"})," Boosted · ",b,"h"]}),typeof n.slots=="number"&&e.jsx("span",{className:`shrink-0 text-micro font-bold px-1.5 py-0.5 rounded-md border ${(n.filledSlots??0)>=n.slots?"bg-success/15 text-success border-success/30":"bg-primary/10 text-primary border-primary/25"}`,children:(n.filledSlots??0)>=n.slots?"Filled":`${n.filledSlots??0}/${n.slots} filled`})]}),e.jsxs("p",{className:"text-micro text-muted-foreground mt-0.5",children:[o.length," recommended worker",o.length!==1?"s":"",n.jobSkills&&n.jobSkills.length>
60&&e.jsxs("span",{className:"ml-1.5 text-muted-foreground/60",children:["· ",n.jobSkills.length," skills needed"]})]}),n.jobSkills&&n.jobSkills.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:n.jobSkills.map(w=>{const m=(n.filledSkills??[]).some(p=>p.toLowerCase()===w.toLowerCase());return e.jsxs("span",{className:`inline-flex items-center gap-0.5 text-micro px-1.5 py-0.5 rounded-md border font-medium ${m?"bg-success/10 text-success border-success/25":"bg-warning/10 text-warning border-warning/25"}`,title:m?"Position filled":"Still needs to be filled",children:[m?e.jsx(dt,{className:"w-2.5 h-2.5"}):e.jsx(Vt,{className:"w-2.5 h-2.5"}),w]},w)})})]}),e.jsxs("button",{onClick:()=>r(`/contractor/jobs/${n.jobId}/find-workers`),className:"flex items-center gap-1 text-micro text-primary font-medium hover:text-primary/80 transition-colors shrink-0 mt-0.5",children:["All ",e.jsx(mt,{className:"w-3 h-3"})]})]}),a.length>0?e.jsxs("div",{className:"px-3 pb-3 space-y-1.5",children:[e.jsx(Ns,{mode:"popLayout",children:a.map(w=>e.jsx(bn,{worker:w,jobId:n.jobId,onSkip:t},w.userId))}),d&&e.jsxs("button",{onClick:()=>r(`/contractor/jobs/${n.jobId}/find-workers`),className:"w-full text-center text-micro text-muted-foreground hover:text-primary font-medium transition-colors py-1.5 flex items-center justify-center gap-1",children:["See all ",o.length," matches ",e.jsx(Es,{className:"w-3 h-3"})]})]}):e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded-xl bg-secondary/30 border border-border/60 p-3 text-center",children:e.jsx("p",{className:"text-caption text-muted-foreground",children:"All workers reviewed"})})})]})}function vn(){const{user:n}=Jt(),{t:c}=De(),t=ws(),{data:s=[],isLoading:r}=Or(),[o,a]=h.useState(xn),[d,u]=h.useState(null),[b,w]=h.useState(null);h.useEffect(()=>{if(!n)return;const L=Q.channel(`contractor-recs-${n.id}-${Math.random().toString(36).slice(2,10)}`).on("postgres_changes",{event:"*",schema:"public",table:"applications"},()=>{t.invalidateQueries({queryKey:["worker-recommendations"]})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"jobs",filter:`contractor_id=eq.${n.id}`},()=>{t.invalidateQueries({queryKey:["worker-recommendations"]})}).subscribe();return()=>{Q.removeChannel(L)}},[n,t]);const m=h.useCallback(L=>{gn(L),a(E=>new Set(E).add(L))},[]),p=h.useCallback((L,E,R)=>{const $=`${L}-${E}`;m($),b&&clearTimeout(b),u({id:$,name:R});const K=setTimeout(()=>u(null),4e3);w(K)},[m,b]),x=h.useCallback(()=>{if(d){try{const L=localStorage.getItem(Be);if(L){const E=JSON.parse(L);delete E[d.id],localStorage.setItem(Be,JSON.stringify(E))}}catch{}a(L=>{const E=new Set(L);return E.delete(d.id),E}),u(null),b&&clearTimeout(b)}},[d,b]),N=h.useCallback(()=>{localStorage.removeItem(Be),a(new Set)},[]);if(r)return e.jsx("div",{className:"space-y-3",children:[0,1].map(L=>e.jsxs("div",{className:"rounded-card bg-card/90 border border-border/60 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ke,{className:"h-8 w-8 rounded-xl"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx(Ke,{className:"h-4 w-32"}),e.jsx(Ke,{className:"h-2.5 w-20"})]})]}),[0,1,2].map(E=>e.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl bg-secondary/30 p-2.5",children:[e.jsx(Ke,{className:"h-9 w-9 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(Ke,{className:"h-3 w-24"}),e.jsx(Ke,{className:"h-2.5 w-32"})]}),e.jsx(Ke,{className:"h-7 w-20 rounded-lg"})]},E))]},L))});const _=s.filter(L=>typeof L.slots!="number"||(L.filledSlots??0)<L.slots).slice(0,fn);return _.length===0?e.jsxs(Te.div,{initial:{opacity:0,scale:.97},animate:{opacity:1,scale:1},className:"rounded-card bg-card/90 backdrop-blur-md border border-border/60 p-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-card bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(Cs,{className:"w-6 h-6 text-primary"})}),e.jsx("p",{className:"font-display text-base text-foreground mb-1",children:c.b6.recommended.noneTitle}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-[220px] mx-auto",children:c.contractorDashboard.noRecommendations||"Match workers to see worker recommendations"}),o.size>0&&e.jsx("button",{onClick:N,className:"mt-3 px-4 py-2 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium hover:bg-secondary/80 transition-colors",children:c.b6.recommended.reviewSkipped})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ns,{children:d&&e.jsx(Te.div,{initial:{opacity:0,y:-8,height:0}
6,animate:{opacity:1,y:0,height:"auto"},exit:{opacity:0,y:-8,height:0},className:"overflow-hidden",children:e.jsxs("div",{className:"flex items-center justify-between bg-secondary/80 backdrop-blur-sm border border-border rounded-xl px-3 py-2",children:[e.jsxs("span",{className:"text-caption text-muted-foreground truncate mr-2",children:['Skipped "',e.jsx("span",{className:"text-foreground font-medium",children:d.name}),'"']}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-primary text-primary-foreground text-caption font-semibold hover:bg-primary/90 transition-colors shrink-0",children:[e.jsx(Rr,{className:"w-3 h-3"})," Undo"]})]})})}),_.map((L,E)=>e.jsx(yn,{rec:L,skippedIds:o,onSkip:p,index:E},L.jobId)),o.size>0&&e.jsx(Te.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.3},children:e.jsx("button",{onClick:N,className:"w-full text-center text-micro text-muted-foreground hover:text-primary transition-colors py-1.5",children:"Reset skipped workers"})})]})}function wn({onNavigate:n}){const c=He(),{t}=De(),{data:s}=zr(),r=(s==null?void 0:s.length)??0;return e.jsxs("button",{type:"button",onClick:()=>{n==null||n(),c("/contractor/crew")},className:"w-full min-h-[64px] flex items-center gap-3 rounded-card border border-border/60 bg-card p-5 shadow-sm text-left active:scale-[0.99] transition-transform",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(G,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-base font-semibold text-foreground",children:t.crew.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r>0?t.crew.entryCount(r):t.crew.entryTeaser})]}),e.jsx(mt,{className:"w-5 h-5 text-muted-foreground shrink-0"})]})}function jn({open:n,onClose:c}){var N,T;const t=He(),{user:s}=Jt(),{t:r}=De(),{isFoundingMember:o}=js(),{data:a}=Ne({queryKey:["user-profile",s==null?void 0:s.id],enabled:!!s&&n,queryFn:async()=>{const{data:_}=await Q.from("profiles").select("full_name").eq("user_id",s.id).maybeSingle();return _}}),{data:d=[]}=Ne({queryKey:["contractor-jobs-summary",s==null?void 0:s.id],enabled:!!s&&n,queryFn:async()=>{const{data:_}=await Q.from("jobs").select("id, status, slots, filled_slots").eq("contractor_id",s.id).is("deleted_at",null);return _??[]}}),{data:u=0}=Ar(),{data:b=0}=Ne({queryKey:["recommended-workers-count",s==null?void 0:s.id],enabled:!!s&&n,staleTime:5*60*1e3,queryFn:async()=>{const{count:_}=await Q.from("worker_profiles").select("user_id",{count:"exact",head:!0});return _??0}}),w=((T=(N=a==null?void 0:a.full_name)==null?void 0:N.split(" ")[0])==null?void 0:T.toUpperCase())||"CONTRACTOR",m=d.filter(_=>_.status==="active"),p=m.length,x=m.filter(_=>Math.max(0,(_.slots??1)-(_.filled_slots??0))>0).length;return e.jsx(gs,{open:n,onOpenChange:_=>!_&&c(),children:e.jsxs(bs,{side:"bottom",className:"rounded-t-2xl max-h-[85dvh] overflow-y-auto pb-safe",children:[e.jsx(ys,{className:"pb-2",children:e.jsx(vs,{className:"text-[18px] font-bold text-left",children:r.contractorOverview.title})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("h2",{className:"font-display text-xl tracking-tight",children:w}),o&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/20 text-amber-600 dark:text-amber-300 border border-amber-500/30 px-2 py-0.5 text-micro font-semibold uppercase tracking-wide",children:[e.jsx(Cs,{className:"w-3 h-3"}),r.b6.founding.badge]})]}),e.jsx(hn,{activeCount:p,pendingReviewCount:u,jobsNeedingWorkers:x,recommendedWorkersCount:b}),e.jsx(wn,{onNavigate:c}),e.jsx(Dr,{}),e.jsx(vn,{}),e.jsx(Pr,{voice:"contractor"}),e.jsx(Wr,{}),e.jsx("button",{onClick:()=>{c(),t("/home")},className:"w-full mt-4 text-small text-muted-foreground underline text-center",children:r.contractorOverview.viewFullDashboard})]})]})})}function _n(n){return typeof n=="object"?n.key:n}function Sn(n,c){const t=n.length;return new Proxy(n,{get(s,r,o){if(typeof r=="string"){const a=r.charCodeAt(0);if(a>=48&&a<=57){const d=+r;if(Number.isInteger(d)&&d>=0&&d<t){let u=s[d];if(typeof u!="object"){const b=c[d*2];u=s[d]={index:d,key:u,start:b,size:c[d*2+1],end:b+c[d*2+1],lane:0}}return u}}if(r==="length")return t}return Reflect.get(s,r,o)}})}function Ge(n,c,t){let s=t.initialDeps??[],r,o=!0;function a(){const d=n();return(d.length!==s.length||d.some((b,w)=>s[w]!==b))&&(s=d,r=c(...d),t!=null&&t.onChange&&!(o&&t.skipInitialOnChange)&&t.onChange(r),o=!1),r}return a.updateDeps=d=>{s=d},a}function fs(n,c){if(n===void 0)throw new Error("Unexpected undefined");return n}const ps=(n,c)=>Math.abs(n-c)<1.01,kn=(n,c,t)=>{let s;return Object.assign(function(...r){n.clearTimeout(s),s=n.setTimeout(()=>c.apply(this,r),t)},{cancel:()=>{n.clearTimeout(s)}})};let ct;const Bt=()=>{if(ct!==void 0)return ct;if(typeof navigator>"u")return ct=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return ct=!0;const n=navigator.maxTouchPoints;return ct=navigator.platform==="MacIntel"&&n!==void 0&&n>0},Nn=n=>n,Cn=n=>
6{const c=Math.max(n.startIndex-n.overscan,0),s=Math.min(n.endIndex+n.overscan,n.count-1)-c+1,r=new Array(s);for(let o=0;o<s;o++)r[o]=c+o;return r},ht={passive:!0},En=(n,c)=>{const t=n.scrollElement;if(!t)return;const s=()=>{c({width:t.innerWidth,height:t.innerHeight})};return s(),t.addEventListener("resize",s,ht),()=>{t.removeEventListener("resize",s)}},Mn=typeof window>"u"?!0:"onscrollend"in window,In=(n,c,t)=>{const s=n.scrollElement;if(!s)return;const r=n.targetWindow;if(!r)return;const o=n.options.useScrollendEvent&&Mn;let a=0;const d=o?null:kn(r,()=>c(t(s),!1),n.options.isScrollingResetDelay),u=m=>()=>{a=t(s),d==null||d(),c(a,m)},b=u(!0),w=u(!1);return s.addEventListener("scroll",b,ht),o&&s.addEventListener("scrollend",w,ht),()=>{s.removeEventListener("scroll",b),o&&s.removeEventListener("scrollend",w),d==null||d.cancel()}},An=(n,c)=>In(n,c,t=>n.options.horizontal?t.scrollX:t.scrollY),Ln=(n,c,t)=>{if(t.options.useCachedMeasurements){const s=t.indexFromElement(n),r=t.options.getItemKey(s);return t.itemSizeCache.get(r)??t.options.estimateSize(s)}if(c!=null&&c.borderBoxSize){const s=c.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}if(!c){const s=t.indexFromElement(n),r=t.options.getItemKey(s),o=t.itemSizeCache.get(r);if(o!==void 0)return o}return n[t.options.horizontal?"offsetWidth":"offsetHeight"]},On=(n,{adjustments:c=0,behavior:t},s)=>{var r,o;(o=(r=s.scrollElement)==null?void 0:r.scrollTo)==null||o.call(r,{[s.options.horizontal?"left":"top"]:n+c,behavior:t})},Tn=On;function Rn(n,c,t,s){if(c===0)return!1;const r=s(0),o=new Set;let a=0;for(;a<n;){const u=t(a);if(u===r)break;o.add(u),a++}const d=n-a;if(d===0||d>=c)return!1;for(let u=0;u<d;u++)if(s(u)!==t(a+u))return!1;for(let u=d;u<c;u++)if(o.has(s(u)))return!1;return!0}class Fn{constructor(c){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var t,s,r;return((r=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:r.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const a=()=>{const d=o.target,u=this.indexFromElement(d);if(!d.isConnected){this.observer.unobserve(d);for(const[b,w]of this.elementsCache)if(w===d){this.elementsCache.delete(b);break}return}this.isIndexInRange(u)&&this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(d,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=s())==null||r.disconnect(),t=null},observe:r=>{var o;return(o=s())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=s())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{var s;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Nn,rangeExtractor:Cn,onChange:()=>{},measureElement:Ln,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in t){const p=t[m];p!==void 0&&(r[m]=p)}const o=this.options;let a=null,d=null,u=!1;if(o!==void 0&&o.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const m=o.count,p=r.count,x=this.getMeasurements(),N=((s=this._singleLaneMeasurements)==null?void 0:s.items)??x,T=$=>_n(N[$]),_=m>0?T(0):null,L=m>0?T(m-1):null;if(p!==m||m>0&&p>
60&&(r.getItemKey(0)!==_||r.getItemKey(p-1)!==L)){u=!0;const $=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??x[0]:null;$&&(a=[$.key,this.getScrollOffset()-$.start]);const K=r.followOnAppend===!0?"auto":r.followOnAppend||null;K&&p>0&&this.isAtEnd(o.scrollEndThreshold)&&(m===0||r.getItemKey(p-1)!==L)&&(p>m||Rn(m,p,T,r.getItemKey))&&(d=K)}}this.options=r,u&&(this.pendingMin=0,this.itemSizeCacheVersion++);let b=!1,w=0;if(a&&this.scrollOffset!==null){const[m,p]=a,x=this.getMeasurements(),{count:N,getItemKey:T}=this.options;let _=0;for(;_<N&&T(_)!==m;)_++;if(_<N){const L=x[_];if(L){const E=Math.max(0,L.start+p);!d&&E!==this.scrollOffset&&(w=E-this.scrollOffset,this.scrollOffset=E,b=!0)}}}(b||d)&&(this.pendingScrollAnchor=[b?a[0]:null,b?a[1]:0,d,w])},this.notify=t=>{var s,r;(r=(s=this.options).onChange)==null||r.call(s,this,t)},this.maybeNotify=Ge(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t,s;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,d)=>{if(d&&this._intendedScrollOffset===null&&a===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(a-this._intendedScrollOffset)<1.5&&(a=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(a-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const u=this.getScrollOffset();this.scrollDirection=d?u===a?this.scrollDirection:u<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=d,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const a=this.scrollElement,d=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!Bt()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",d,ht),a.addEventListener("touchend",u,ht),this.unsubs.push(()=>{a.removeEventListener("touchstart",d),a.removeEventListener("touchend",u),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[a,d,u,b]=o;a!==null&&!u&&(Bt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?b!==0&&(this._iosDeferredAdjustment+=b):((s=this.scrollState)==null?void 0:s.behavior)==="smooth"&&!ps(this.getScrollOffset()-b,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),u&&this.scrollToEnd({behavior:u})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;const{target:t,maxAtWrite:s}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>s+.5&&(this._clampedAdjustment=t>r+.5?{target:t,maxAtWrite:r}:null,this._scrollToOffset(t,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>
6{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const t=this.getScrollOffset(),s=this.getMaxScrollOffset();if(t<0||t>s)return;if(this._iosDeferredAdjustment<0&&t>=s-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Ge(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(t,s,r,o,a,d,u,b)=>(this.prevLanes!==void 0&&this.prevLanes!==d&&(this.lanesChangedFlag=!0),this.prevLanes=d,this.pendingMin=null,{count:t,paddingStart:s,scrollMargin:r,getItemKey:o,enabled:a,lanes:d,laneAssignmentMode:u,gap:b}),{key:!1}),this.isIndexInRange=t=>t>=0&&t<this.options.count,this.getMeasurements=Ge(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:s,scrollMargin:r,getItemKey:o,enabled:a,lanes:d,laneAssignmentMode:u,gap:b},w)=>{var m;const p=this.itemSizeCache;if(!a)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const E of this.laneAssignments.keys())E>=t&&this.laneAssignments.delete(E);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(E=>{this.itemSizeCache.set(E.key,E.size)}));const x=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),d===1){const E=t*2;let R=(m=this._singleLaneMeasurements)==null?void 0:m.flat;if(!R||R.length<E){const Y=new Float64Array(E);R&&x>0&&Y.set(R.subarray(0,x*2)),R=Y}const $=x===0?new Array(t):this._singleLaneMeasurements.items.slice();let K;if(x===0)K=s+r;else{const Y=x-1;K=R[Y*2]+R[Y*2+1]+b}for(let Y=x;Y<t;Y++){const ge=o(Y);$[Y]=ge;const ue=p.get(ge),ee=typeof ue=="number"?ue:this.options.estimateSize(Y);R[Y*2]=K,R[Y*2+1]=ee,K+=ee+b}this._singleLaneMeasurements={flat:R,items:$};const Z=Sn($,R);return this.measurementsCache=Z,Z}const N=this.measurementsCache.slice(0,x),T=new Array(d).fill(void 0),_=new Float64Array(d);let L=0;for(let E=0;E<x;E++){const R=N[E];R&&(T[R.lane]===void 0&&L++,T[R.lane]=E,_[R.lane]=R.end)}for(let E=x;E<t;E++){const R=o(E),$=this.laneAssignments.get(E);let K,Z;const Y=u==="estimate"||p.has(R);if($!==void 0&&this.options.lanes>1){K=$;const me=T[K],X=me!==void 0?N[me]:void 0;Z=X?X.end+b:s+r}else if(L===d){let me=0,X=_[0],B=T[0];for(let be=1;be<d;be++){const le=_[be];(le<X||le===X&&T[be]<B)&&(me=be,X=le,B=T[be])}K=me,Z=X+b,Y&&this.laneAssignments.set(E,K)}else K=E%this.options.lanes,Z=s+r,Y&&this.laneAssignments.set(E,K);const ge=p.get(R),ue=typeof ge=="number"?ge:this.options.estimateSize(E),ee=Z+ue;N[E]={index:E,start:Z,size:ue,end:ee,key:R,lane:K},T[K]===void 0&&L++,T[K]=E,_[K]=ee}return this.measurementsCache=N,N},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ge(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,r,o)=>t.length===0||s===0?(this.range=null,null):(this.range=Dn(t,s,r,o,o===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}
6),this.getVirtualIndexes=Ge(()=>{let t=null,s=null;const r=this.calculateRange();return r&&(t=r.startIndex,s=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,r,o,a)=>o===null||a===null?[]:t({startIndex:o,endIndex:a,overscan:s,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,r=t.getAttribute(s);return r?parseInt(r,10):-1},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(r!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,r-o),d=Math.min(this.options.count-1,r+o);return t>=a&&t<=d}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,d)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(d))});return}const s=this.indexFromElement(t);if(!this.isIndexInRange(s))return;const r=this.options.getItemKey(s),o=this.elementsCache.get(r);o!==t&&(o&&this.observer.unobserve(o),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var r,o,a;if(!this.isIndexInRange(t))return;let d,u,b;const w=(r=this._singleLaneMeasurements)==null?void 0:r.flat;if(this.options.lanes===1&&w!=null)b=this.options.getItemKey(t),u=w[t*2],d=w[t*2+1];else{const x=this.measurementsCache[t];if(!x)return;b=x.key,u=x.start,d=x.size}const m=this.itemSizeCache.get(b)??d,p=s-m;if(p!==0){const x=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,N=x?this.getTotalSize():0,T=this.getScrollOffset()+this.scrollAdjustments,L=!this.itemSizeCache.has(b)?u<T:u+m<=T&&this.scrollDirection!=="backward",E=((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:b,start:u,size:d,end:u+d,lane:0},p,this):L);(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(b,s),this.itemSizeCacheVersion++;let R=!1;x?R=this.applyScrollAdjustment(this.getTotalSize()-N):E&&(R=this.applyScrollAdjustment(p)),this.notify(R),this._retryClampedAdjustment()}},this.getVirtualItems=Ge(()=>
6[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const r=[];for(let o=0,a=t.length;o<a;o++){const d=t[o],u=s[d];r.push(u)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{var s;const r=this.getMeasurements();if(r.length===0)return;const o=(s=this._singleLaneMeasurements)==null?void 0:s.flat,a=this.options.lanes===1&&o!=null,d=As(0,r.length-1,a?u=>o[u*2]:u=>fs(r[u]).start,t);return fs(r[d])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,s,r=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),a=this.getScrollOffset();s==="auto"&&(s=t>=a+o?"end":"start"),s==="center"?t+=(r-o)/2:s==="end"&&(t-=o);const d=this.getMaxScrollOffset();return Math.max(Math.min(d,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const r=this.getSize(),o=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(s==="auto")if(a.end>=o+r-this.options.scrollPaddingEnd)s="end";else if(a.start<=o+this.options.scrollPaddingStart)s="start";else return[o,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const d=s==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(d,s,a.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(t,s),a=this.now();this.scrollState={index:null,align:s,behavior:r,startedAt:a,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getOffsetForIndex(t,s);if(!o)return;const[a,d]=o,u=this.now();this.scrollState={index:t,align:d,behavior:r,startedAt:u,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const r=this.getScrollOffset()+t,o=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:o,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t,s;const r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const a=r.length-1,d=(t=this._singleLaneMeasurements)==null?void 0:t.flat;d!=null?o=d[a*2]+d[a*2+1]:o=((s=r[a])==null?void 0:s.end)??0}else{const a=Array(this.options.lanes).fill(null);let d=r.length-1;for(;d>=0&&a.some(u=>u===null);){const u=r[d];a[u.lane]===null&&(a[u.lane]=u.end),d--}o=Math.max(...a.filter(u=>u!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const t=[];if(this.itemSizeCache.size===0)return t;const s=this.getMeasurements();
6for(const r of s)r&&this.itemSizeCache.has(r.key)&&t.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return t},this._scrollToOffset=(t,{adjustments:s,behavior:r})=>{this._intendedScrollOffset=t+(s??0),this.options.scrollToFn(t,{behavior:r,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(c)}applyScrollAdjustment(c,t){if(c===0)return!1;if(Bt()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=c,!1;{const s=this.getScrollOffset()+this.scrollAdjustments+c,r=this.scrollElement,o=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=o!==null&&s>o+.5?{target:s,maxAtWrite:o}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=s?s[0]:this.scrollState.lastTargetOffset,o=1,a=r!==this.scrollState.lastTargetOffset;if(!a&&ps(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const d=this.getSize()||600,u=Math.abs(r-this.getScrollOffset()),b=this.scrollState.behavior==="smooth"&&u>d;this.scrollState.lastTargetOffset=r,b||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:b?"smooth":"auto"})}this.scheduleScrollReconcile()}}const As=(n,c,t,s)=>{for(;n<=c;){const r=(n+c)/2|0,o=t(r);if(o<s)n=r+1;else if(o>s)c=r-1;else return r}return n>0?n-1:0};function zn(n,c,t){let s=0;for(;s<=c;){const r=(s+c)/2|0,o=n[r*2];if(o<t)s=r+1;else if(o>t)c=r-1;else return r}return s>0?s-1:0}function Dn(n,c,t,s,r){const o=n.length-1;if(n.length<=s)return{startIndex:0,endIndex:o};if(s===1&&r!==null){const b=zn(r,o,t);let w=b;const m=t+c;for(;w<o&&r[w*2]+r[w*2+1]<m;)w++;return{startIndex:b,endIndex:w}}let d=As(0,o,b=>n[b].start,t),u=d;if(s===1)for(;u<o&&n[u].end<t+c;)u++;else if(s>1){const b=Array(s).fill(0);for(;u<o&&b.some(m=>m<t+c);){const m=n[u];b[m.lane]=m.end,u++}const w=Array(s).fill(t+c);for(;d>=0&&w.some(m=>m>=t);){const m=n[d];w[m.lane]=m.start,d--}d=Math.max(0,d-d%s),u=Math.min(o,u+(s-1-u%s))}return{startIndex:d,endIndex:u}}const Ht=typeof document<"u"?h.useLayoutEffect:h.useEffect;function Pn({useFlushSync:n=!0,directDomUpdates:c=!1,directDomUpdatesMode:t="transform",...s}){const r=h.useReducer(m=>m+1,0)[1],o=h.useRef({enabled:c,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=c,o.current.mode=t;const a=h.useRef(!1),d=m=>{const p=o.current;if(!p.enabled||!p.container)return;const x=m.getTotalSize();if(x!==p.lastSize){p.lastSize=x;const N=m.options.horizontal?"width":"height";p.container.style[N]=`${x}px`}},u=m=>{const p=o.current;if(!p.enabled||!p.container)return;d(m);const x=!!m.options.horizontal,N=p.mode==="transform",T=x?"left":"top",_=m.options.scrollMargin,L=m.getVirtualItems();for(const E of L){const R=E.start-_,$=m.elementsCache.get(E.key);$&&p.lastPositions.get($)!==R&&(p.lastPositions.set($,R),N?$.style.transform=x?`translate3d(${R}px, 0, 0)`:`translate3d(0, ${R}px, 0)`:$.style[T]=`${R}px`)}},b={...s,onChange:(m,p)=>{var x;const N=o.current;let T=!0;if(N.enabled){u(m);const _=m.range,L=N.prevRange;T=!L||L.isScrolling!==m.isScrolling||L.startIndex!==(_==null?void 0:_.startIndex)||L.endIndex!==(_==null?void 0:_.endIndex),T&&(N.prevRange=_?{startIndex:_.startIndex,endIndex:_.endIndex,isScrolling:m.isScrolling}:null)}
6T&&(n&&p&&!a.current?br.flushSync(r):r()),(x=s.onChange)==null||x.call(s,m,p)}},[w]=h.useState(()=>{const m=new Fn(b),p=m.measureElement;return m.measureElement=x=>{a.current=!0;try{p(x)}finally{a.current=!1}},Object.assign(m,{containerRef:x=>{const N=o.current;if(N.container=x,N.lastSize=null,x&&N.enabled){const T=m.getTotalSize();N.lastSize=T;const _=m.options.horizontal?"width":"height";x.style[_]=`${T}px`}}})});return w.setOptions(b),Ht(()=>w._didMount(),[]),Ht(()=>(d(w),w._willUpdate())),Ht(()=>{u(w)}),w}function Wn(n){return Pn({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:En,observeElementOffset:An,scrollToFn:Tn,initialOffset:()=>typeof document<"u"?window.scrollY:0,...n})}const Ls="knuckl.browse_talent_entity_filter";function $n(){if(typeof window>"u")return"all";try{const n=window.localStorage.getItem(Ls);if(n==="workers"||n==="subs"||n==="all")return n}catch{}return"all"}const qt="knuckl.browseWorkers.sortBy.v1",Yt="knuckl.browseWorkers.restrictToCity.v1",Os="knuckl.browseWorkers.radius.v1",Ts="knuckl.talent.near_projects",Rs="knuckl.talent.near_projects_radius",Fs="knuckl.contractor.workerBrowseMode";function Kn(){if(typeof window>"u")return"best";try{return window.localStorage.getItem(Fs)==="all"?"all":"best"}catch{return"best"}}function Bn(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ts)==="true"}catch{return!1}}function Hn(){if(typeof window>"u")return 15;try{const n=window.localStorage.getItem(Rs),c=Number(n);if(c===5||c===15||c===25)return c}catch{}return 15}const Vn=new Set(["match","skills","nearest","relevance","jobs","rating","name","price_high","price_low","completeness","newest"]);function Un(){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(qt);return n&&Vn.has(n)?n:null}catch{return null}}function qn(){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(Yt);return n==="true"?!0:n==="false"?!1:null}catch{return null}}const Yn=[{value:5,labelKey:"within5mi"},{value:10,labelKey:"within10mi"},{value:25,labelKey:"within25mi"},{value:50,labelKey:"within50mi"},{value:null,labelKey:"anyDistance"}],Jn=new Set([5,10,25,50]),Xn=[{value:null,labelKey:"expAny"},{value:0,labelKey:"exp0_1"},{value:1,labelKey:"exp1_3"},{value:3,labelKey:"exp3_5"},{value:5,labelKey:"exp5_10"},{value:10,labelKey:"exp10plus"}];function Gn(n){if(!n)return null;const c=n.trim();if(c==="0-1")return 0;if(c==="1-3")return 1;if(c==="3-5")return 3;if(c==="5-10")return 5;if(c==="10+")return 10;const t=Number(c);return Number.isFinite(t)?t:null}function Qn(){if(!(typeof window>"u"))try{const n=window.localStorage.getItem(Os);if(n===null)return;if(n==="any")return null;const c=Number(n);return Jn.has(c)?c:void 0}catch{return}}const Zn=[{value:"completeness",labelKey:"sortMostComplete"},{value:"nearest",labelKey:"sortNearest"},{value:"rating",labelKey:"sortHighestRated"},{value:"jobs",labelKey:"sortMostJobs"},{value:"newest",labelKey:"sortNewest"}],ei=["Framing","Drywall","General Labor","Concrete","HVAC","Electrical","Plumbing","Scaffolding"];function _l(){var Gt;const n=He(),[c]=yr(),{user:t}=Jt(),{t:s,lang:r}=De(),{shortlistedWorkerIds:o}=Us();qs();const{canPostPrivateJob:a}=js(),d=!0,{open:u}=Hs(),[b,w]=h.useState(""),m=h.useDeferredValue(b),[p,x]=h.useState([]),[N,T]=h.useState(!1),[_,L]=h.useState(null),[E,R]=h.useState(!1),[$,K]=h.useState(!1),[Z,Y]=h.useState(()=>Un()??"completeness"),[ge,ue]=h.useState(c.get("tab")==="saved"?"saved":"all"),[ee,me]=h.useState(!1),[X,B]=h.useState(null),[be,le]=h.useState(null),[ft,C]=h.useState(null),[ye,Re]=h.useState(null),[Ze,ve]=h.useState(null),[et,tt]=h.useState("peek"),[Ct,Et]=h.useState(null),we=h.useRef(null);h.useRef(null);const[Mt,Pe]=h.useState(!1),{data:It=[]}=Ne({queryKey:["contractor-noted-workers",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:6e4,queryFn:async()=>{const{data:i}=await Q.from("saved_workers").select("worker_id, notes").eq("contractor_id",t.id).not("notes","is",null);return(i??[]).filter(g=>typeof g.notes=="string"&&g.notes.trim().length>0).map(g=>g.worker_id)}});new Set(It);const[te,Ce]=h.useState(null),[Ve,je]=h.useState(""),[ne,st]=h.useState(null),[At,pt]=h.useState(()=>ss()),[_e,Ue]=h.useState(()=>qn()??!0),[W,qe]=h.useState(()=>{const i=Qn();return i===void 0?null:i}),[he,rt]=h.useState(()=>$n());h.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ls,he)}catch{}},[he]);const[ae,Fe]=h.useState(()=>Bn()),[Ee,Ye]=h.useState(()=>Hn()),[fe,nt]=h.useState(()=>Kn());h.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Fs,fe)}catch{}},[fe]),h.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ts,String(ae))}catch{}},[ae]),h.useEffect(()=>{if(!(typeof window>
6"u"))try{window.localStorage.setItem(Rs,String(Ee))}catch{}},[Ee]);const{data:xt}=Js(t==null?void 0:t.id),Se=h.useMemo(()=>xt??[],[xt]);h.useEffect(()=>{if(!ae||Se.length===0)return;const i=we.current;i&&i.fitBounds(Se,{padding:[60,60]})},[ae,Se]),h.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Os,W==null?"any":String(W))}catch{}},[W]);const pe=h.useRef(null),Me=h.useRef(null);h.useEffect(()=>{if(typeof window>"u")return;pe.current&&clearTimeout(pe.current);const i=Z;return pe.current=setTimeout(()=>{try{window.localStorage.setItem(qt,i)}catch{}pe.current=null},300),()=>{if(pe.current){clearTimeout(pe.current),pe.current=null;try{window.localStorage.setItem(qt,i)}catch{}}}},[Z]),h.useEffect(()=>{if(typeof window>"u")return;Me.current&&clearTimeout(Me.current);const i=String(_e);return Me.current=setTimeout(()=>{try{window.localStorage.setItem(Yt,i)}catch{}Me.current=null},300),()=>{if(Me.current){clearTimeout(Me.current),Me.current=null;try{window.localStorage.setItem(Yt,i)}catch{}}}},[_e]),$r();const{data:ce}=Ne({queryKey:["contractor-origin",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:i}=await Q.from("contractor_profiles").select("lat, lng, city, location, specialties").eq("user_id",t.id).maybeSingle();let g=(i==null?void 0:i.lat)??null,k=(i==null?void 0:i.lng)??null;const M=(i==null?void 0:i.city)||(i==null?void 0:i.location);if((g==null||k==null)&&M&&M.trim())try{const F=await Ys(M);F&&(g=F.lat,k=F.lng,await Q.from("contractor_profiles").update({lat:g,lng:k,city:F.city||((i==null?void 0:i.city)??null)}).eq("user_id",t.id))}catch{}return{lat:g,lng:k,label:(i==null?void 0:i.city)||(i==null?void 0:i.location)||"your location",specialties:(i==null?void 0:i.specialties)??[]}}}),ie=ne||(ce&&ce.lat!=null&&ce.lng!=null?{lat:ce.lat,lng:ce.lng,label:ce.label}:null),{data:ke=[]}=Ne({queryKey:["contractor-recent-job-skills",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:i}=await Q.from("jobs").select("skills, created_at").eq("contractor_id",t.id).order("created_at",{ascending:!1}).limit(5),g=new Set;return(i??[]).forEach(k=>(k.skills??[]).forEach(M=>g.add(M.toLowerCase()))),Array.from(g)}}),{data:l}=Ne({queryKey:["browse-workers-credentials"],queryFn:async()=>{const{data:i,error:g}=await Q.from("worker_credential_summary").select("worker_id, has_any_credential, has_verified_credential");if(g)throw g;const k={};for(const M of i??[])M.worker_id&&(k[M.worker_id]={hasAny:!!M.has_any_credential,hasVerified:!!M.has_verified_credential});return k}}),I=l??{},{data:S=[],isLoading:z,isError:U}=Ne({queryKey:["browse-all-workers",as],queryFn:async()=>{const i=Q.from("worker_profiles_public").select("user_id, skills, location, city, total_jobs, reliability_score, hourly_rate, approx_lat, approx_lng, availability, created_at, bio, available_days, is_seed, years_experience, has_own_tools, has_transportation, travel_radius_miles");as||i.eq("is_seed",!1);const[g,k,M,F,v]=await Promise.all([Q.from("profiles_public").select("user_id, full_name, avatar_url").eq("role","worker"),i,Q.from("worker_skill_rates_public").select("worker_id, skill, rate"),Q.from("worker_skills_public").select("user_id, skill_name"),Q.rpc("get_worker_review_ratings",{_worker_ids:null})]),A=Object.fromEntries((k.data??[]).map(O=>[O.user_id,O])),y={};(F.data??[]).forEach(O=>{y[O.user_id]||(y[O.user_id]=[]),y[O.user_id].includes(O.skill_name)||y[O.user_id].push(O.skill_name)});const D={};(M.data??[]).forEach(O=>{D[O.worker_id]||(D[O.worker_id]={}),D[O.worker_id][O.skill.trim().toLowerCase()]=O.rate});const q={};return(v.data??[]).forEach(O=>{q[O.worker_id]||(q[O.worker_id]={sum:0,count:0}),q[O.worker_id].sum+=O.rating,q[O.worker_id].count+=1}),(g.data??[]).filter(O=>A[O.user_id]).filter(O=>{const f=A[O.user_id],oe=!!(O.full_name&&O.full_name.trim()),Ot=Array.isArray(f==null?void 0:f.skills)&&f.skills.length>0;return oe||Ot}).map(O=>{const f=A[O.user_id],oe=q[O.user_id],Ot=(f==null?void 0:f.years_experience)??null,zs=(f==null?void 0:f.has_own_tools)??null,Ds=Object.values(D[O.user_id]??{}).map(Ws=>({rate:Ws??null})),Ps=tr({bio:(f==null?void 0:f.bio)??null,skills:(f==null?void 0:f.skills)??[],years_experience:Ot,has_own_tools:zs,has_transportation:(f==null?void 0:f.has_transportation)??null,travel_radius_miles:(f==null?void 0:f.travel_radius_miles)??null,hourly_rate:(f==null?void 0:f.hourly_rate)??null},O.avatar_url??null,Ds);return{user_id:O.user_id,full_name:O.full_name||"Unknown Worker",avatar_url:O.avatar_url,skills:(f==null?void 0:f.skills)??y[O.user_id]??[],skillRates:D[O.user_id]??{},location:(f==null?void 0:f.city)??(f==null?void 0:f.location)??null,city:(f==null?void 0:f.city)??null,lat:(f==null?void 0:f.a
6pprox_lat)??null,lng:(f==null?void 0:f.approx_lng)??null,total_jobs:(f==null?void 0:f.total_jobs)??0,reliability_score:(f==null?void 0:f.reliability_score)??null,hourly_rate:(f==null?void 0:f.hourly_rate)??null,avg_rating:oe?Math.round(oe.sum/oe.count*10)/10:null,review_count:(oe==null?void 0:oe.count)??0,availability:(f==null?void 0:f.availability)??null,created_at:(f==null?void 0:f.created_at)??null,bio:(f==null?void 0:f.bio)??null,available_days:(f==null?void 0:f.available_days)??[],years_experience:(f==null?void 0:f.years_experience)??null,has_own_tools:(f==null?void 0:f.has_own_tools)??null,has_transportation:(f==null?void 0:f.has_transportation)??null,travel_radius_miles:(f==null?void 0:f.travel_radius_miles)??null,profile_strength:Ps.score}})},enabled:!!t,staleTime:5*60*1e3}),{data:P=[]}=Ne({queryKey:["browse-all-subs",t==null?void 0:t.id],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>{const{data:i}=await Q.from("contractor_profiles_public").select("user_id, company_name, bio, specialties, avg_rating, total_hires, approx_lat, approx_lng, city, location, logo_url, badges, company_size, website").neq("user_id",t.id),g=i??[];if(!g.length)return[];const k=g.map(v=>v.user_id),{data:M}=await Q.from("profiles_public").select("user_id, full_name, avatar_url").in("user_id",k),F=new Map((M??[]).map(v=>[v.user_id,v]));return g.map(v=>{var A,y;return{entityType:"sub",user_id:v.user_id,full_name:((A=F.get(v.user_id))==null?void 0:A.full_name)??v.company_name??null,avatar_url:((y=F.get(v.user_id))==null?void 0:y.avatar_url)??null,company_name:v.company_name??null,bio:v.bio??null,specialties:v.specialties??null,avg_rating:v.avg_rating??null,total_hires:v.total_hires??null,approx_lat:v.approx_lat??null,approx_lng:v.approx_lng??null,city:v.city??null,location:v.location??null,logo_url:v.logo_url??null,badges:v.badges??null,company_size:v.company_size??null,website:v.website??null}})}}),V=h.useMemo(()=>{if(he==="workers")return[];const i=m.trim().toLowerCase(),g=p.map(k=>k.toLowerCase());return P.filter(k=>{if(ne&&_e&&!es(ne.label,k.city??k.location))return!1;if(i){const M=(k.full_name??"").toLowerCase().includes(i),F=(k.company_name??"").toLowerCase().includes(i),v=(k.location??"").toLowerCase().includes(i),A=(k.specialties??[]).some(y=>y.toLowerCase().includes(i));if(!M&&!F&&!v&&!A)return!1}if(g.length>0){const M=(k.specialties??[]).map(F=>F.toLowerCase());if(!g.some(F=>M.includes(F)))return!1}return!0})},[P,he,m,p,ne,_e]),H=h.useMemo(()=>{const i=new Set;return S.forEach(g=>g.skills.forEach(k=>i.add(k))),Array.from(i).sort()},[S]);h.useMemo(()=>{const i=m.trim().toLowerCase();if(!i)return new Set;const g=new Set;return S.forEach(k=>{k.skills.forEach(M=>{M.toLowerCase().includes(i)&&g.add(M.toLowerCase())})}),g},[m,S]);const se=i=>{x(g=>g.includes(i)?g.filter(k=>k!==i):[...g,i])},de=h.useMemo(()=>{if(he==="subs")return[];const i=fe==="best"&&p.length===0?ke.map(M=>M.toLowerCase()):[],g=fe==="best",k=fe==="best"||p.length>0;return S.filter(M=>{var v;if(M.user_id===(t==null?void 0:t.id)||ge==="saved"&&!o.has(M.user_id)||ne&&_e&&!es(ne.label,M.city??M.location)||g&&W!=null&&ie&&M.lat!=null&&M.lng!=null&&Pt(ie.lat,ie.lng,M.lat,M.lng)>W)return!1;const F=m.trim().toLowerCase();if(F){const A=M.full_name.toLowerCase().includes(F),y=(v=M.location)==null?void 0:v.toLowerCase().includes(F),D=M.skills.some(q=>q.toLowerCase().includes(F));if(!A&&!y&&!D)return!1}if(k){const A=p.length>0?p.map(y=>y.toLowerCase()):i;if(A.length>0){const y=M.skills.map(q=>q.toLowerCase());if(!A.some(q=>y.includes(q)))return!1}}if(_!=null){const A=Gn(M.years_experience);if(A==null||A<_)return!1}return!0})},[S,m,p,t==null?void 0:t.id,ge,o,ne,_e,W,ie,_,he,fe,ke]),Ie=i=>!ie||i.lat==null||i.lng==null?null:Pt(ie.lat,ie.lng,i.lat,i.lng),j=i=>{var q;const g=(i.skills??[]).map(O=>O.toLowerCase()),k=ke.length?ke.filter(O=>g.includes(O)).length:0,M=ke.length?k/ke.length*40:g.length>0?20:0,F=10,v=Qs(Ie(i)??null),A=!!i.avatar_url,y=(i.hourly_rate??0)>0||Object.values(i.skillRates??{}).some(O=>O!=null&&O>0),D=(((q=i.available_days)==null?void 0:q.length)??0)>0;return Zs({skillScore:M,ratingScore:F,proximityScore:v,hasPhoto:A,hasPayRate:y,hasAvailability:D})},Ae=h.useMemo(()=>{const i=v=>{const A=Object.values(v.skillRates).filter(y=>y!=null&&y>0);return A.length>0?A.reduce((y,D)=>y+D,0)/A.length:v.hourly_rate??0},g=v=>{var D,q;let A=0;return v.avatar_url&&(A+=15),(((D=v.skills)==null?void 0:D.length)??0)>0&&(A+=15),(((q=v.skills)==null?void 0:q.length)??0)>=3&&(A+=5),v.location&&(A+=10),v.lat!=null&&v.lng!=null&&(A+=5),(Object.values(v.skillRates??{}).some(O=>O!=null&&O>0)||(v.hourly_rate??0)>0)&&(A+=15),v.availability&&(A+=5),(v.total_jobs??0)>0&&(A+=10),(v.review_count??0)>0&&(A+=10),A},k=m.trim().toLowerCase(),M=p.map(v=>v.toLowerCase()),F=v=>{const A=v.skills.map(f=>f.toLowerCase()),y=M.length?M.filter(f=>A.some(oe=>oe===f)).length:0,D=k?A.filter(f=>f.includes(k)).length+(v.full_name.toLowerCase().includes(k)?1:0):0,q=y*10+D*4,O=(v.total_jobs??0)/1e3;return q+O};return[...de].sort((v,A)=>{var q,O;const y=g(A)-g(v),D=(((q=A.skills)==null?void 0:q.length)??0)-(((O=v.skills)==null?void 0:O.length)??0)||y;switch(Z){case"completeness":return y||(A.total_jobs??0)-(v.total_jobs??0);case"match":return j(A)-j(v)||D;case"skills":return D;case"nearest":{const f=Ie(v),oe=Ie(A);return f==null&&oe==null?0:f==null?1:oe==null?-1:f-oe||D}case"relevance":return F(A)-F(v)||D;case"jobs":return(A.total_jobs??0)-(v.total_jobs??0)||D;case"rating":return(A.avg_rating??0)-(v.avg_rating??0)||D;case"price_high":return i(A)-i(v)||D;case"price_low":return i(v)-i(A)||D;case"name":return v.full_name.localeCompare(A.full_name)||D;case"newest":{const f=v.created_at?new Date(v.created_at).getTime():0;return(A.created_at?new Date(A.created_at).getTime():0)-f||D}default:return D}})},[de,Z,ie,m,p,ke]),it=i=>{const g=i.display;st({lat:i.lat,lng:i.lng,label:g}),je(g),Y("nearest"),Ue(!0),rr({display:g,lat:i.lat,lng:i.lng}),pt(ss())},gt=()=>{st(null),je(""),Ue(!0)},Le=p.length+(W!=null?1:0)+(_!=null?1:0)+(ee?1:0),ot=h.useMemo(()=>Ae.filter(i=>{var g;return ee?((g=I[i.user_id])==null?void 0:g.hasVerified)===!0:!0}),[Ae,ee,I]),bt=h.useRef(null);Wn({count:ot.length,estimateSize:()=>180,overscan:4,scrollMargin:((Gt=bt.current)==null?void 0:Gt.offsetTop)??0,measureElement:i=>(i==null?void 0:i.getBoundingClientRect().height)??180});const yt=p.map(i=>i.toLowerCase()),re=i=>{var k;if(yt.length>0){for(const M of p){const F=(k=i.skillRates)==null?void 0:k[M.trim().toLowerCase()];if(F!=null&&F>0)return`${M} · $${Math.round(F)}${s.browseMap.perHour}`}return null}const g=Object.values(i.skillRates??{}).filter(M=>M!=null&&M>0);if(g.length>0){const M=g.reduce((F,v)=>F+v,0)/g.length;return`$${Math.round(M)}${s.browseMap.perHour}`}return(i.hourly_rate??0)>0?`$${Math.round(i.hourly_rate)}${s.browseMap.perHour}`:null},Oe=h.useMemo(()=>de.filter(i=>i.lat!=null&&i.lng!=null).map(i=>{var g;return{id:i.user_id,name:i.full_name,primarySkill:((g=i.skills)==null?void 0:g[0])??null,lat:i.lat,lng:i.lng,distanceMi:Ie(i),rateLine:re(i),skills:i.skills??[],matchScore:j(i),user_id:i.user_id,full_name:i.full_name,avatarUrl:i.avatar_url}}
6),[de,p]),ze=h.useMemo(()=>V.filter(i=>i.approx_lat!=null&&i.approx_lng!=null).map(i=>{var g;return{id:cr("sub",i.user_id),name:i.company_name??i.full_name??"Sub",primarySkill:((g=i.specialties)==null?void 0:g[0])??null,lat:i.approx_lat,lng:i.approx_lng,distanceMi:null,rateLine:null,skills:i.specialties??[],user_id:i.user_id,full_name:i.company_name??i.full_name??"Sub",avatarUrl:i.logo_url??i.avatar_url??null}}),[V]),xe=h.useMemo(()=>[...Oe,...ze],[Oe,ze]),Je=h.useMemo(()=>{if(!ae)return xe;if(Se.length===0)return[];const i=Ee;return xe.filter(g=>Se.some(k=>Pt(g.lat,g.lng,k.lat,k.lng)<=i))},[xe,ae,Se,Ee]),Lt=h.useMemo(()=>{if(!ye)return Je;const{south:i,west:g,north:k,east:M}=ye;return Je.filter(F=>F.lat>=i&&F.lat<=k&&F.lng>=g&&F.lng<=M)},[Je,ye]),We=i=>{if(i.entityKind==="sub"||ks(i.id)==="sub"){C(Ss(i.id));return}le(i)},vt=()=>{navigator.geolocation&&(K(!0),navigator.geolocation.getCurrentPosition(async i=>{const{latitude:g,longitude:k}=i.coords;try{const{reverseGeocodeCity:M}=await Vs(async()=>{const{reverseGeocodeCity:v}=await import("./geocode-CX448-fu.js");return{reverseGeocodeCity:v}},[]),F=await M(g,k)||"Current Location";it({display:F,lat:g,lng:k})}catch{it({display:"Current Location",lat:g,lng:k})}finally{K(!1)}},()=>K(!1),{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e5}))},wt=()=>{const i=new Set,g=[];[...((ce==null?void 0:ce.specialties)??[]).filter(y=>typeof y=="string"&&y.trim().length>
60),...ei].forEach(y=>{const D=y.toLowerCase();i.has(D)||(i.add(D),g.push(y))});const M=p.filter(y=>!g.some(D=>D.toLowerCase()===y.toLowerCase())),F=[...g,...M],v=H.filter(y=>!F.some(D=>D.toLowerCase()===y.toLowerCase())),A=N?[...F,...v]:F;return e.jsxs("div",{className:"space-y-5 pt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-caption font-semibold uppercase tracking-wider text-muted-foreground",children:s.browseMap.sort}),e.jsxs(Tt,{value:Z,onValueChange:y=>Y(y),children:[e.jsxs(Rt,{className:"h-11 text-xs rounded-xl","aria-label":s.browseMap.sort,children:[e.jsx(Vr,{className:"w-3.5 h-3.5 text-muted-foreground mr-1"}),e.jsx(Ft,{placeholder:"Sort"})]}),e.jsx(zt,{children:Zn.map(y=>e.jsx(Dt,{value:y.value,className:"text-xs",children:s.browseMap[y.labelKey]},y.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-caption font-semibold uppercase tracking-wider text-muted-foreground",children:s.browseMap.distance}),e.jsxs(Tt,{value:W==null?"any":String(W),onValueChange:y=>qe(y==="any"?null:Number(y)),children:[e.jsxs(Rt,{className:"h-11 text-xs rounded-xl","aria-label":s.browseMap.distance,children:[e.jsx(ut,{className:"w-3.5 h-3.5 text-muted-foreground mr-1"}),e.jsx(Ft,{})]}),e.jsx(zt,{children:Yn.map(y=>e.jsx(Dt,{value:y.value==null?"any":String(y.value),className:"text-xs",children:s.browseMap[y.labelKey]},String(y.value)))})]})]})]}),W!=null&&!ie&&e.jsx("p",{className:"text-caption text-destructive font-medium",children:"Set a location to use distance"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-caption font-semibold uppercase tracking-wider text-muted-foreground",children:s.browseMap.experience}),e.jsxs(Tt,{value:_==null?"any":String(_),onValueChange:y=>L(y==="any"?null:Number(y)),children:[e.jsxs(Rt,{className:"h-11 text-xs rounded-xl","aria-label":s.browseMap.experience,children:[e.jsx(ts,{className:"w-3.5 h-3.5 text-muted-foreground mr-1"}),e.jsx(Ft,{})]}),e.jsx(zt,{children:Xn.map(y=>e.jsx(Dt,{value:y.value==null?"any":String(y.value),className:"text-xs",children:s.browseMap[y.labelKey]},String(y.value)))})]})]}),ne&&e.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:_e,onChange:y=>Ue(y.target.checked),className:"w-4 h-4 rounded border-border accent-primary cursor-pointer"}),e.jsxs("span",{children:["Only show workers in"," ",e.jsx("span",{className:"text-foreground font-medium",children:ne.label})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"text-caption font-semibold uppercase tracking-wider text-muted-foreground inline-flex items-center gap-1.5",children:[e.jsx(Zt,{className:"w-3 h-3"})," ",s.browseMap.verifiedFilterLabel]}),e.jsx("p",{className:"text-caption text-muted-foreground/80 leading-snug",children:s.browseMap.verifiedFilterSubtitle}),e.jsxs("button",{type:"button",onClick:()=>{me(y=>!y)},"aria-pressed":ee,className:`w-full h-11 px-3 rounded-xl border text-xs font-semibold inline-flex items-center justify-between transition-colors touch-manipulation ${ee&&d?"bg-primary/10 border-primary/40 text-foreground":"bg-card border-border/60 text-muted-foreground hover:border-primary/30 hover:text-foreground"}`,children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(Zt,{className:"w-3.5 h-3.5 text-primary"}),s.browseMap.verifiedFilterOnly]}),e.jsx("span",{className:`w-9 h-5 rounded-full flex items-center transition-colors ${ee?"bg-primary":"bg-muted"}`,children:e.jsx("span",{className:`w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${ee?"translate-x-[18px]":"translate-x-[2px]"}`})})]}),ee&&d&&(()=>{const y=Ae.length-ot.length;return y<=0?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 rounded-lg bg-muted/40 border border-border/60 text-caption",children:[e.jsx("span",{className:"text-muted-foreground",children:s.browseMap.verifiedFilterHidden(y)}),e.jsx("button",{type:"button",onClick:()=>me(!1),className:"font-semibold text-primary hover:underline",children:s.browseMap.verifiedFilterShowAll})]})})()]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-caption font-semibold uppercase tracking-wider text-muted-foreground inline-flex items-center gap-1.5",children:[e.jsx(Kr,{className:"w-3 h-3"})," ",s.browseMap.skills,p.length>0&&e.jsxs("span",{className:"ml-1 text-primary normal-case",children:["(",p.length,")"]})]}),p.length>0&&e.jsxs("button",{onClick:()=>x([]),className:"inline-flex items-center gap-1 text-caption font-medium text-destructive hover:text-destructive/80",children:[e.jsx(Vt,{className:"w-3 h-3"})," ",s.browseMap.reset]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[A.map(y=>{const D=p.some(q=>q.toLowerCase()===y.toLowerCase());return e.jsxs("button",{onClick:()=>se(y),className:`inline-flex items-center gap-1 px-3 py-1.5 rounded-full text-caption font-semibold border transition-colors min-h-[36px] touch-manipulation ${D?"bg-primary text-primary-foreground border-primary shadow-sm shadow-primary/20":"bg-card text-muted-foreground border-border/60 hover:border-primary/40 hover:text-foreground"}`,children:[D&&e.jsx(dt,{className:"w-3 h-3"}),y]},y)}),v.length>0&&e.jsx("button",{onClick:()=>T(y=>!y),className:"inline-flex items-center gap-1 px-3 py-1.5 rounded-full text-caption font-semibold border border-dashed border-border/60 text-muted-foreground hover:text-foreground hover:border-primary/40",children:N?e.jsxs(e.Fragment,{children:[e.jsx(_s,{className:"w-3 h-3 rotate-180"})," Less"]}):e.jsx(e.Fragment,{children:"More filters +"})})]})]})]})},jt=Le>0?s.browseMap.filtersWithCount.replace("{count}",String(Le)):s.browseMap.filters;return e.jsxs(e.Fragment,{children:[e.jsx(er,{title:"Browse Workers",description:"Browse all workers on the platform."}),e.jsxs("div",{className:"relative w-full z-10",style:{height:"calc(100dvh - var(--contractor-content-top, 4.5rem) - var(--contractor-bottom-nav-h, 5rem) - var(--contractor-reminder-h, 0px))"},children:[z?e.jsx("div",{className:"h-full w-full flex items-center justify-center",style:{background:"#0F0F0F"},children:e.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-primary/20 border-t-primary animate-spin"})}):e.jsx(nr,{ref:we,fillParent:!0,workers:xe,projects:ae?Se:[],origin:ie?{lat:ie.lat,lng:ie.lng}:null,onSelect:i=>{const g=xe.find(k=>k.id===i||k.user_id===i);g?We(g):C(i)},onWorkerSelect:We,viewProfileLabel:s.browseMap.viewProfile,awayLabel:s.browseMap.miAway,focusedWorkerId:Ct,onClusterOpen:i=>{ve(i.map(g=>g.id)),et==="peek"&&tt("half")},onBoundsChange:Re,onMapTap:()=>{et!=="peek"&&tt("peek"),Ze&&Ze.length>0&&ve(null)}}),!z&&e.jsx(Yr,{position:"top-left",entries:[{kind:"entity",type:"worker",label:s.mapLegend.entries.worker.label,description:s.mapLegend.entries.worker.description},{kind:"entity",type:"sub",label:s.mapLegend.entries.sub.label,description:s.mapLegend.entries.sub.description},{kind:"state",visual:"viewed",label:s.mapLegend.entries.viewed.label,description:s.mapLegend.entries.viewed.description},{kind:"state",visual:"focused",label:s.mapLegend.entries.focused.label,description:s.mapLegend.entries.focused.description},{kind:"state",visual:"cluster",label:s.mapLegend.entries.cluster.label,description:s.mapLegend.entries.cluster.description}]}),!z&&xe.length===0&&S.length>0&&e.jsx("div",{className:"absolute top-20 left-3 right-3 z-[1000] pointer-events-none",children:e.jsxs("div",{className:"pointer-events-auto rounded-xl border p-3 text-sm",style:{background:"rgba(26,26,26,0.95)",borderColor:"#3A3A3A",color:"white",backdropFilter:"blur(8px)"},children:[e.jsx("div",{className:"font-medium mb-1",children:"No workers on the map right now"}),e.jsxs("div",{className:"text-white/70 text-xs mb-2",children:[S.length," ",S.length===1?"worker matches":"workers match",", but filters or your location are hiding them."]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[ne&&_e&&e.jsx("button",{type:"button",onClick:()=>Ue(!1),className:"px-2.5 py-1 rounded-md text-xs bg-primary text-primary-foreground",children:"Show all cities"}),W!=null&&e.jsx("button",{type:"button",onClick:()=>qe(null),className:"px-2.5 py-1 rounded-md text-xs bg-white/10 text-white border border-white/20",children:"Clear distance"}),p.length>0&&e.jsx("button",{type:"button",onClick:()=>x([]),className:"px-2.5 py-1 rounded-md text-xs bg-white/10 text-white border border-white/20",children:"Clear skills"}),(b||m)&&e.jsx("button",{type:"button",onClick:()=>w(""),className:"px-2.5 py-1 rounded-md text-xs bg-white/10 text-white border border-white/20",children:"Clear search"})]})]})}),e.jsxs("div",{className:"absolute top-3 left-3 right-3 z-[1000] pointer-events-none",children:[e.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 p-1.5 rounded-card border",style:{background:"rgba(26,26,26,0.92)",borderColor:"#2A2A2A",boxShadow:"0 1px 4px rgba(0,0,0,0.4)",backdropFilter:"blur(8px)"},children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(Xt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-white/50 pointer-events-none"}),e.jsx("input",{value:b,onChange:i=>w(i.target.value),placeholder:s.browseMap.searchPlaceholder,type:"search",inputMode:"search",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,enterKeyHint:"search","aria-label":s.browseMap.searchPlaceholder,className:"w-full h-12 pl-10 pr-10 rounded-xl bg-transparent text-sm text-white placeholder:text-white/50 border-0 focus:outline-none focus:ring-0"}),e.jsx("button",{type:"button",onClick:vt,disabled:$,"aria-label":s.aria.useCurrentLocation,className:"absolute right-1 top-1/2 -translate-y-1/2 w-9 h-9 inline-flex items-center justify-center rounded-lg text-white/60 hover:text-primary hover:bg-white/5 transition-colors disabled:opacity-50",children:$?e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white/30 border-t-white animate-spin"}):e.jsx(Hr,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>R(!0),"aria-label":jt,className:`shrink-0 h-12 min-w-[48px] px-3 inline-flex items-center gap-1.5 rounded-xl text-xs font-semibold transition-colors ${Le>0?"bg-primary text-primary-foreground":"text-white/85 hover:bg-white/5 border border-white/10"}`,children:[e.jsx(ts,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:jt}),Le>0&&e.jsx("span",{className:`sm:hidden inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full text-micro font-bold ${Le>
60?"bg-primary-foreground/20 text-primary-foreground":""}`,children:Le})]})]}),ne&&e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1.5 h-8 px-2.5 rounded-full text-caption font-medium text-white pointer-events-auto",style:{background:"rgba(31,31,31,0.9)",border:"1px solid #2A2A2A"},children:[e.jsx(ut,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:"truncate max-w-[180px]",children:ne.label}),e.jsx("button",{onClick:gt,"aria-label":s.aria.clearCity,className:"w-5 h-5 inline-flex items-center justify-center rounded-md hover:bg-white/10",children:e.jsx(Vt,{className:"w-3 h-3"})})]})]}),e.jsxs("button",{onClick:()=>Pe(!0),className:"absolute bottom-24 left-4 z-[1000] flex items-center gap-2 px-4 py-2.5 rounded-full bg-background/95 backdrop-blur-sm border border-border shadow-md text-small font-semibold text-foreground active:scale-95 transition-transform",children:[e.jsx(Ur,{size:15,className:"text-muted-foreground"}),s.contractorOverview.title]}),e.jsxs("button",{onClick:()=>n("/contractor/crew"),className:"absolute bottom-24 right-4 z-[1000] flex items-center gap-2 px-4 py-2.5 rounded-full bg-background/95 backdrop-blur-sm border border-border shadow-md text-small font-semibold text-foreground active:scale-95 transition-transform",children:[e.jsx(G,{size:15,className:"text-muted-foreground"}),s.crew.title]})]}),e.jsx(gs,{open:E,onOpenChange:R,children:e.jsxs(bs,{side:"bottom",className:"max-h-[85dvh] overflow-y-auto rounded-t-2xl z-[1250]",children:[e.jsx(ys,{children:e.jsx(vs,{children:s.browseMap.filters})}),e.jsx(wt,{}),e.jsx("div",{className:"sticky bottom-0 bg-background pt-3 mt-4 -mx-6 px-6 pb-2 border-t border-border/60",children:e.jsx("button",{onClick:()=>R(!1),className:"w-full h-12 rounded-xl bg-primary text-primary-foreground text-sm font-semibold",children:s.browseMap.apply})})]})}),e.jsx(sr,{open:!!X,onClose:()=>B(null),skill:(X==null?void 0:X.skill)??"",workerId:(X==null?void 0:X.workerId)??"",workerName:(X==null?void 0:X.workerName)??""}),e.jsx(Br,{userId:ft,onClose:()=>C(null),messageBasePath:"/contractor/messages",canPostPrivateJob:a,onInviteToJob:(i,g,k)=>{C(null),B({skill:i,workerId:g,workerName:k})},onInvitePrivate:(i,g,k)=>{C(null),Ce({workerId:i,workerName:g,skills:k})}}),e.jsx(Xs,{worker:be,onClose:()=>le(null),onInviteToJob:(i,g,k)=>{le(null),B({skill:i,workerId:g,workerName:k})},onViewProfile:i=>{n(`/profile/${i}`)},onInvitePrivate:(i,g,k)=>{le(null),Ce({workerId:i,workerName:g,skills:k})},onMessage:i=>{le(null),n(`/contractor/messages?to=${i}`)},canPostPrivateJob:a,lang:r}),e.jsx(Gs,{open:!!te,onClose:()=>Ce(null),workerId:(te==null?void 0:te.workerId)??"",workerName:(te==null?void 0:te.workerName)??"",workerSkills:(te==null?void 0:te.skills)??[]}),e.jsx(jn,{open:Mt,onClose:()=>Pe(!1)}),e.jsx(tn,{workers:Lt,snap:et,onSnapChange:tt,entityFilter:he,onEntityFilterChange:rt,clusterSubsetIds:Ze,onClearSubset:()=>ve(null),nearProjectsEnabled:ae,onNearProjectsToggle:Fe,nearProjectsRadius:Ee,onNearProjectsRadiusChange:Ye,projectCount:Se.length,viewMode:fe,onViewModeChange:nt,onSelect:i=>{Et(i.id),We(i)}})]})}export{_l 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.