1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mapbox-gl-DiYTSXjO.js","assets/entry-Do74TiKF.js","assets/index-BiQ39brC.css","assets/mapbox-gl--KYsKQ2R.css"])))=>i.map(i=>d[i]); 2import{n as Ae,r as f,aA as Te,j as e,Z as De,aB as Pe,aC as Q,a2 as J,a as k,f as Oe,m as je,ad as le,aD as Re,C as Be,k as Fe}from"./entry-Do74TiKF.js";import"./chat-session-context-B4L4YnRG.js";import{u as He}from"./use-page-context-BGXeyuTT.js";import{d as L,u as C,M as w,F as Ue}from"./index-DJijX_33.js";import{h as qe,i as ze,L as Ke,B as re,f as $e}from"./use-locations-D6saFpb6.js";import{l as G,f as ie,w as Ge,g as Ye,s as Ve,E as We,h as Xe,j as Ze,k as ve,t as Qe,m as Je,n as et,o as tt,p as st}from"./geocode-flow-CMskhOon.js";import{u as at}from"./use-hash-overlay-CuhiRPgg.js";import{L as ot,e as ke,f as nt,d as lt,a as ce,E as ee}from"./PageHeaderSlot-Br21m3sy.js";import{u as rt}from"./use-permission-CYx1Cdct.js";import{u as it}from"./use-track-list-filter-D_Kt03fn.js";import{u as ct}from"./use-filterable-list-6j9BvnYF.js";import{U as Ne,i as dt,I as ut}from"./ImportRosterDialog-DA-qk7IV.js";import{u as mt}from"./use-mobile-D7b4MNm1.js";import{S as R}from"./skeleton-DGzORg1U.js";import{B as D}from"./index-BZII-Bkc.js";import{l as se,L as we,a as pt,m as ht}from"./LocationFormDialog-DT3KWXCz.js";import{L as de}from"./loader-circle-0uo0RU0M.js";import{u as ft,t as gt,r as xt,C as bt,F as yt}from"./ColumnResizeHandle-DIf0Xzf4.js";import{C as Y}from"./checkbox-DojxLk7z.js";import{a as jt,A as vt}from"./arrow-up-BsC8jbpx.js";import{C as kt}from"./chevron-down-QLMw16wt.js";import{C as Nt}from"./chevron-up-a0DHjTiH.js";import{M as ue}from"./map-pin-C3cRBqU3.js";import{C as wt}from"./circle-alert-CTUQKP2n.js";import"./ChatMessageItem-1FyHwZ-1.js";import"./check-CuBV3tGh.js";import"./copy-BXCSOQ4Q.js";import"./chevron-right-DO02ttya.js";import"./mock-members-Bfilma6e.js";import"./parseISO-BJ8NA1Tw.js";import"./with-selector-BECvcOMO.js";import"./dumbbell-DqI5xzH3.js";import"./clock-C8UNSBRI.js";import"./chart-column-DxCyIWMA.js";import"./map-pinned-BP5Dk_Pr.js";import"./popover-B819a5UE.js";import"./zap-BImvJgYE.js";import"./employee-query-keys-DgjZRCij.js";import"./useForm-Ce-jLSnp.js";import"./FilterSearch-DgcyUoUk.js";import"./LocalizedMultiSelect-DYSvO4Wj.js";import"./MetaRow-ItyptvWB.js";import"./truncate-middle-BmviLiZg.js";import"./plus-D9_t5hfT.js";import"./eye-CFF0i2TW.js";import"./use-debounced-value-CtTX4qbY.js";import"./table-k2hrzkX1.js";import"./circle-check-yzMXjH7f.js";import"./pencil-BzrEZ12i.js";import"./minus-3hw6tVOj.js";const Ct="__ungrouped__";function Mt(t,a){const l=new Map;for(const r of t){const o=G(r),n=o.length===0?Ct:o.join(" / "),s=l.get(n);if(s)s.locations.push(r);else{const i=a?G(r,a):o;l.set(n,{key:n,parts:i,locations:[r]})}}return Array.from(l.values())}const me=L({noFilterMatch:{id:"portal.locations.list.empty",defaultMessage:"No locations match your filters.",description:"Shown when the locations list has no results for the current filters."},noQueryMatch:{id:"portal.locations.list.emptyForQuery",defaultMessage:"No locations match â{query}â.",description:"Shown when the locations list has no results for the typed search query."}});function Ce(t){const a=t.trim();return a===""?{descriptor:me.noFilterMatch}:{descriptor:me.noQueryMatch,values:{query:a}}}const Lt=t=>[t.name,t.address,t.city,t.region,t.country,t.externalId];function St(t,a){const l=a.trim().toLowerCase();return l===""?!0:Lt(t).some(r=>r!=null&&r.toLowerCase().includes(l))}const It=25,Et=(t,a)=>t[a],pe=t=>({countries:t.country,regions:t.region,cities:t.city}),_t=t=>{const a=new Set(t.statuses);return l=>(a.size===0||a.has(l.status))&&St(l,t.query)},At={query:"search",statuses:"status",sort:"sort",country:"facet",region:"facet",city:"facet"};function Tt(t,a=It){const[l,r]=Ae(),o=f.useMemo(()=>ie(l),[l]),n=f.useCallback(h=>{r(b=>{const v=ie(b);return Ge(b,{...v,...h(v)})},{replace:!0})},[r]),s=ct({items:t,pageSize:a,fields:Ye,getFieldValue:Et,buildExtraMatcher:_t,sortItems:Ve,defaultDirectionFor:Xe,emptyLocation:We,state:o,update:n}),i=f.useCallback(h=>n(()=>({query:h,page:1})),[n]),p=f.useCallback(h=>n(()=>({statuses:h,page:1})),[n]),g=f.useMemo(()=>JSON.stringify({query:o.query,statuses:[...o.statuses].sort(),location:{country:[...o.location.country].sort(),region:[...o.location.region].sort(),city:[...o.location.city].sort()}}),[o.query,o.statuses,o.location]),u=f.useMemo(()=>({query:o.query,statuses:o.statuses,sort:s.sort,...o.location}),[o.query,o.statuses,o.location,s.sort]);return it("locations",u,s.total,At),{query:o.query,setQuery:i,statuses:o.statuses,setStatuses:p,location:s.location,setLocation:s.setLocation,toggleLocation:s.toggleLocation,resetLocation:s.resetLocation,options:pe(s.options),allOptions:pe(s.allOptions),sort:s.sort,setSort:s.setSort,page:s.page,pageCount:s.pageCount,nextPage:s.nextPage,prevPage:s.prevPage,canPrev:s.canPrev,canNext:s.canNext,pageItems:s.pageItems,items:s.items,total:s.total,rangeStart:s.rangeStart,rangeEnd:s.rangeEnd,filterKey:g}}const H=new Set,U=new Map;function Me(t){const[a,l]=f.useState({filterKey:t,active:!1,selectedIds:H,blocked:U}),r=a.filterKey===t?a:{filterKey:t,active:a.active,selectedIds:H,blocked:U};r!==a&&l(r);const o=()=>l({filterKey:t,active:!0,selectedIds:H,blocked:U}),n=()=>l({filterKey:t,active:!1,selectedIds:H,blocked:U}),s=g=>l(u=>{const h=new Set(u.selectedIds),b=new Map(u.blocked);return h.has(g)?(h.delete(g),b.delete(g)):h.add(g),{...u,selectedIds:h,blocked:b}}),i=(g,u)=>l(h=>{const b=new Set(h.selectedIds),v=new Map(h.blocked);for(const y of g)u?b.add(y):(b.delete(y),v.delete(y));return{...h,selectedIds:b,blocked:v}}),p=g=>l(u=>({...u,blocked:new Map(g.map(h=>[h.locationId,h]))}));return{active:r.active,selectedIds:r.selectedIds,blocked:r.blocked,enter:o,exit:n,toggle:s,setPage:i,markBlocked:p}}const he=L({deletedToast:{id:"portal.locations.bulkDelete.deletedToast",defaultMessage:"{count, plural, one {# location} other {# locations}} deleted",description:"Toast title shown after a bulk delete succeeds."},deleteErrorToast:{id:"portal.locations.bulkDelete.deleteErrorToast",defaultMessage:"Could not delete the selected locations",description:"Toast title shown when a bulk delete fails for a reason other than being in use."}});function Le({onBlocked:t,onDeleted:a}){const l=C(),{toast:r}=Te(),[o,n]=f.useState(!1),[s,i]=f.useState([]),[p,g]=f.useState(null),[u,h]=f.useState("done"),b=qe(),v=ze(
2),y=f.useRef(0),c=d=>{const j=++y.current;g(null),h("checking"),b.mutate(d,{onSuccess:E=>{y.current===j&&(h("done"),t(E.blocked),E.blocked.length>0&&g(E.blocked))},onError:()=>{y.current===j&&h("error")}})},m=d=>{i(d),n(!0),c(d.map(j=>j.id))},N=u==="checking"?"checking":u==="error"?"error":p!==null?"blocked":"confirm",x=()=>{if(N!=="confirm")return;const d=s.map(j=>j.id);v.mutate({locationIds:d},{onSuccess:()=>{r({title:l.formatMessage(he.deletedToast,{count:d.length})}),n(!1),a()},onError:j=>{if(j instanceof Ke){g(j.blocked),t(j.blocked);return}r({title:l.formatMessage(he.deleteErrorToast),variant:"destructive"})}})};return{start:m,dialogProps:{open:o,onOpenChange:n,status:N,count:s.length,blocked:p??[],pending:v.isPending,onRetry:()=>c(s.map(d=>d.id)),onConfirm:x}}}const M=L({checkingAria:{id:"portal.locations.bulkDelete.checkingAria",defaultMessage:"Checking whether these locations can be deletedâ¦",description:"Accessible status announced while the bulk-delete dialog runs its check."},errorTitle:{id:"portal.locations.bulkDelete.errorTitle",defaultMessage:"Could not check these locations",description:"Title shown when the bulk-delete dialog fails to run its check."},errorBody:{id:"portal.locations.bulkDelete.errorBody",defaultMessage:"Try again.",description:"Body shown when the bulk-delete dialog fails to run its check."},retry:{id:"portal.locations.bulkDelete.retry",defaultMessage:"Retry",description:"Button that retries the bulk-delete check."},close:{id:"portal.locations.bulkDelete.close",defaultMessage:"Close",description:"Button that closes the bulk-delete dialog without deleting anything."},blockedTitle:{id:"portal.locations.bulkDelete.blockedTitle",defaultMessage:"Some locations can't be deleted",description:"Title shown when part of the selection blocks a bulk delete."},blockedIntro:{id:"portal.locations.bulkDelete.blockedIntro",defaultMessage:"Nothing will be deleted until these are deselected. Remove what's still attached to them, or deactivate them instead.",description:"Explanation shown above the list of locations blocking a bulk delete."},confirmTitle:{id:"portal.locations.bulkDelete.confirmTitle",defaultMessage:"Delete {count, plural, one {# location} other {# locations}}?",description:"Title of the bulk-delete confirmation dialog."},confirmBody:{id:"portal.locations.bulkDelete.confirmBody",defaultMessage:"This can't be undone.",description:"Body of the bulk-delete confirmation dialog."},confirm:{id:"portal.locations.bulkDelete.confirm",defaultMessage:"Delete {count, plural, one {# location} other {# locations}}",description:"Button that confirms a bulk delete."}});function Se({open:t,onOpenChange:a,status:l,count:r,blocked:o,pending:n,onRetry:s,onConfirm:i}){const p=C();return e.jsx(De,{open:t,onOpenChange:a,children:e.jsx(Pe,{className:"max-h-[90vh] overflow-y-auto sm:max-w-md",children:l==="checking"?e.jsx("div",{role:"status","aria-label":p.formatMessage(M.checkingAria),className:"flex justify-center py-6",children:e.jsx(de,{className:"size-5 animate-spin text-on-surface-muted motion-reduce:animate-none","aria-hidden":"true"})}):l==="error"?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:e.jsx(J,{children:p.formatMessage(M.errorTitle)})}),e.jsx("p",{className:"text-body-md text-on-surface-muted",children:p.formatMessage(M.errorBody)}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(D,{type:"button",variant:"secondary",onClick:()=>a(!1),children:p.formatMessage(M.close)}),e.jsx(D,{type:"button",variant:"primary",onClick:s,children:p.formatMessage(M.retry)})]})]}):l==="blocked"?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:e.jsx(J,{children:p.formatMessage(M.blockedTitle)})}),e.jsx("p",{className:"text-body-md text-on-surface-muted",children:p.formatMessage(M.blockedIntro)}),e.jsx("ul",{className:"flex flex-col gap-3 text-body-sm text-on-surface",children:o.map(g=>e.jsxs("li",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"text-body-sm-medium",children:g.name}),e.jsx("ul",{className:"flex flex-col gap-0.5 pl-4 text-on-surface-muted",children:se(p,g).map(u=>e.jsx("li",{children:u.text},u.id))})]},g.locationId))})]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:e.jsx(J,{children:p.formatMessage(M.confirmTitle,{count:r})})}),e.jsx("p",{className:"text-body-md text-on-surface-muted",children:p.formatMessage(M.confirmBody)}),e.jsx(D,{type:"button",variant:"secondary",size:"lg",disabled:n,className:"w-full text-danger",onClick:i,leftIcon:n?e.jsx(de,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}):void 0,children:e.jsx(w,{...M.confirm,values:{count:r}})})]})})})}const B=L({count:{id:"portal.locations.selection.count",defaultMessage:"{count, plural, one {# selected} other {# selected}}",description:"Number of locations currently selected in Select mode."},delete:{id:"portal.locations.selection.delete",defaultMessage:"Delete",description:"Button in the selection bar that opens the bulk-delete confirmation dialog."}
2,clear:{id:"portal.locations.selection.clear",defaultMessage:"Clear",description:"Button in the selection bar that deselects every location."},selectAll:{id:"portal.locations.selection.selectAll",defaultMessage:"{total, plural, one {Select # location} other {Select all # locations}}",description:"Button in the selection bar that extends the selection to every location matching the current filters."},overCapHint:{id:"portal.locations.selection.overCapHint",defaultMessage:"You can delete up to {max, number} locations at once.",description:"Hint shown in the selection bar when more locations are selected than a bulk delete can process at once."}});function Ie({count:t,onDelete:a,onClear:l,selectAll:r,className:o}){const n=C(),s=t>re;return e.jsxs("div",{className:k("flex flex-col gap-2 rounded-2xl bg-surface-base px-4 py-3",o),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-body-sm-medium text-on-surface",children:e.jsx(w,{...B.count,values:{count:t}})}),r&&t<r.total&&e.jsx(D,{type:"button",variant:"ghost",onClick:r.onSelectAll,children:n.formatMessage(B.selectAll,{total:r.total})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{type:"button",variant:"ghost",className:"text-danger border-danger",disabled:t===0||s,onClick:a,children:n.formatMessage(B.delete)}),l&&e.jsx(D,{type:"button",variant:"secondary",onClick:l,children:n.formatMessage(B.clear)})]})]}),s&&e.jsx("p",{className:"text-body-caption text-danger",children:e.jsx(w,{...B.overCapHint,values:{max:re}})})]})}const V=L({placeholder:{id:"portal.locations.list.searchPlaceholder",defaultMessage:"Search locations",description:"Placeholder for the search input above the locations list."},ariaLabel:{id:"portal.locations.list.searchAriaLabel",defaultMessage:"Search locations",description:"Accessible name for the search input above the locations list."}});function Ee({filters:t}){return e.jsx(ot,{summary:e.jsx(w,{id:"portal.locations.pagination.summary",defaultMessage:"Showing {rangeStart}â{rangeEnd} of {total, plural, one {# location} other {# locations}}",description:"Range and total shown above the locations list.",values:{rangeStart:t.rangeStart,rangeEnd:t.rangeEnd,total:t.total}}),page:t.page,pageCount:t.pageCount,canPrev:t.canPrev,canNext:t.canNext,onPrev:t.prevPage,onNext:t.nextPage})}const Dt={address:200,externalId:140,employees:110,status:110},Pt="portal.locations.table.columnWidths",Ot=240,I=L({region:{id:"portal.locations.table.regionAria",defaultMessage:"Locations",description:"Accessible name for the scrollable region wrapping the locations table."},address:{id:"portal.locations.table.address",defaultMessage:"Address",description:"Column header for the location's address in the locations table."},name:{id:"portal.locations.table.name",defaultMessage:"Name",description:"Column header for the location's name in the locations table."},externalId:{id:"portal.locations.table.externalId",defaultMessage:"External ID",description:"Column header for the location's external id in the locations table."},employees:{id:"portal.locations.table.employees",defaultMessage:"Staff",description:"Column header for the location's employee count in the locations table."},status:{id:"portal.locations.table.status",defaultMessage:"Status",description:"Column header for the location's status in the locations table."},viewDetails:{id:"portal.locations.table.viewDetails",defaultMessage:"View {name} details",description:"Accessible name for the button that opens a location's details."},selectAllAria:{id:"portal.locations.table.selectAllAria",defaultMessage:"Select all locations on this page",description:"Accessible name for the header checkbox that selects every row on the page."},selectRowAria:{id:"portal.locations.table.selectRowAria",defaultMessage:"Select {name}",description:"Accessible name for a row's selection checkbox."}});function Rt({location:t}){const a=C(),l=G(t),r=G(t,o=>ve(o,a.locale));return l.length===0?e.jsx("span",{className:"text-on-surface-muted",children:"â"}):e.jsx("span",{className:"block truncate text-body-sm",title:r.join(" / "),children:l.map((o,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{className:"text-on-surface-muted",children:" / "}),e.jsx("span",{className:"text-on-surface-muted",children:o})]},`${o}-${n}`))})}function Bt({externalId:t}){return t===null?null:e.jsx("span",{className:"block truncate text-body-sm text-on-surface-muted",title:t,children:Qe(t)})}const T="px-2 py-[13px] align-baseline",fe="pl-4 py-[13px] align-middle",ge="block border-bg-300 hover:border-fg-400 data-[state=checked]:border-fg-100 data-[state=checked]:bg-fg-100 data-[state=indeterminate]:border-fg-100 data-[state=indeterminate]:bg-fg-100",xe=t=>t!=="name",K=[{key:"address",label:I.address,className:"pl-4",sortable:!0},{key:"name",label:I.name,sortable:!0},{key:"externalId",label:I.externalId,sortable:!1},{key:"employees",label:I.employees,sortable:!0},{key:"status",label:I.status,className:"pr-4",sortable:!0}],Ft=K.map(t=>t.key);function Ht({id:t,column:a,sort:l,onSort:r}){const o=C(),n=l.key===a.key,s=n&&l.direction==="asc"?jt:vt;return e.jsxs("button",{id:t,type:"button",onClick:()=>r(a.key),className:k("inline-flex items-center gap-1 rounded-sm transition-colors hover:text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring",n?"text-on-surface":"text-on-surface-muted"),children:[o.formatMessage(
2a.label),e.jsx(s,{className:k("size-3 shrink-0",!n&&"opacity-0"),"aria-hidden":"true"})]})}function Ut({column:t,sort:a,onSort:l,resize:r}){const o=C(),n=f.useId(),s=o.formatMessage(t.label),i=t.sortable&&a.key===t.key;return e.jsxs("th",{scope:"col","aria-sort":t.sortable?i?a.direction==="asc"?"ascending":"descending":"none":void 0,"aria-labelledby":n,className:k(T,"relative overflow-hidden text-ellipsis whitespace-nowrap text-left font-normal",!t.sortable&&"text-on-surface-muted",t.className),children:[t.sortable?e.jsx(Ht,{id:n,column:t,sort:a,onSort:l}):e.jsx("span",{id:n,children:s}),r&&e.jsx(bt,{column:s,...r})]})}const qt=f.memo(function({locations:a,onSelect:l,sort:r,onSort:o,query:n,selection:s}){const i=C(),p=Ce(n),{widths:g,handleProps:u}=ft({storageKey:Pt,defaults:Dt}),h=K.length+(s?1:0),b=a.map(c=>c.id),v=s!=null&&b.length>0&&b.every(c=>s.selectedIds.has(c)),y=s!=null&&b.some(c=>s.selectedIds.has(c));return e.jsx("div",{role:"region","aria-label":i.formatMessage(I.region),tabIndex:0,className:"overflow-x-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-ring",children:e.jsxs("table",{className:"w-full table-fixed border-collapse",style:{minWidth:gt(Object.values(g),Ot)},children:[e.jsxs("colgroup",{children:[s&&e.jsx("col",{className:"w-8"}),K.map(c=>e.jsx("col",{style:xe(c.key)?{width:g[c.key]}:void 0},c.key))]}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border-subtle text-body-sm",children:[s&&e.jsx("th",{scope:"col",className:k(fe,"text-left font-normal"),children:e.jsx(Y,{className:ge,checked:v?!0:y?"indeterminate":!1,onCheckedChange:c=>s.onTogglePage(b,c===!0),"aria-label":i.formatMessage(I.selectAllAria)})}),K.map(c=>e.jsx(Ut,{column:c,sort:r,onSort:o,resize:xe(c.key)?{...u(c.key),edge:xt(Ft,"name",c.key)}:void 0},c.key))]})}),e.jsx("tbody",{children:a.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:h,className:"px-4 py-12 text-center text-body-md text-on-surface-muted",children:e.jsx(w,{...p.descriptor,values:p.values})})}):a.map(c=>{const m=s==null?void 0:s.blocked.get(c.id),N=(s==null?void 0:s.selectedIds.has(c.id))??!1,x=m?se(i,m):[];return e.jsxs("tr",{onClick:()=>l(c.id),className:k("cursor-pointer border-b border-border-subtle transition-colors last:border-b-0 hover:bg-surface-sunken/20 focus-within:bg-accent-secondary/10",N&&"bg-accent-secondary/10 hover:bg-accent-secondary/15",m&&"bg-danger-soft hover:bg-danger-soft"),children:[s&&e.jsx("td",{className:fe,onClick:d=>d.stopPropagation(),children:e.jsx(Y,{className:ge,checked:N,onCheckedChange:()=>s.onToggle(c.id),"aria-label":i.formatMessage(I.selectRowAria,{name:c.name})})}),e.jsx("td",{className:k(T,"pl-4"),children:e.jsx(Rt,{location:c})}),e.jsxs("td",{className:k(T,"text-body-sm-medium text-on-surface"),children:[e.jsx("button",{type:"button","aria-label":i.formatMessage(I.viewDetails,{name:c.name}),onClick:d=>{d.stopPropagation(),l(c.id)},title:c.name,className:"block w-full truncate rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring",children:c.name}),m&&e.jsx("p",{className:"truncate text-body-caption text-danger",title:x.map(d=>d.text).join(` 3`),children:x.flatMap((d,j)=>[j>0&&e.jsx("span",{"aria-hidden":"true",children:" · "},`${d.id}-sep`),e.jsx("span",{children:d.text},d.id)])})]}),e.jsx("td",{className:T,children:e.jsx(Bt,{externalId:c.externalId})}),e.jsx("td",{className:k(T,"overflow-hidden text-ellipsis whitespace-nowrap text-body-sm tabular-nums text-on-surface"),children:c.employeeCount===null?e.jsx("span",{className:"text-on-surface-muted",children:"â"}):e.jsx(Ue,{value:c.employeeCount})}),e.jsx("td",{className:k(T,"overflow-hidden text-ellipsis whitespace-nowrap pr-4"),children:e.jsx(Ze,{status:c.status})})]},c.id)})})]})})}),zt=L({importLocations:{id:"portal.locations.list.importLocations",defaultMessage:"Import",description:"Button that opens the location-import dialog from the Locations list."}});function Kt({filters:t,onSelect:a,canManage:l,onImportLocations:r}){const o=C(),n=Me(t.filterKey),s=Le({onBlocked:n.markBlocked,onDeleted:n.exit}),i=f.useMemo(()=>t.items.filter(p=>n.selectedIds.has(p.id)).map(p=>({id:p.id,name:p.name})),[t.items,n.selectedIds]);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsx("h1",{className:"font-brand text-heading-h2 text-on-surface-heading",children:e.jsx(w,{id:"portal.locations.list.title",defaultMessage:"Locations",description:"Heading of the locations list page."})}),l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Oe,{variant:"secondary",className:"h-12 gap-1 rounded-cta pl-3 pr-4",onClick:r,children:[e.jsx(Ne,{className:"size-4","aria-hidden":"true"}),o.formatMessage(zt.importLocations)]}),e.jsx(we,{mode:"create"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 lg:flex-row lg:flex-wrap lg:items-center lg:justify-between",children:[e.jsx(ke,{value:t.query,onValueChange:t.setQuery,placeholder:o.formatMessage(V.placeholder),"aria-label":o.formatMessage(V.ariaLabel),enterKeyHint:"search",className:"w-full max-w-[320px]"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(Je,{location:t.location,options:t.options,onChange:t.setLocation}),e.jsx(et,{value:t.statuses,onChange:t.setStatuses})]})]}),e.jsx("div",{className:"overflow-hidden rounded-[16px] border border-bg-300 bg-surface-base",children:e.jsx(qt,{locations:t.pageItems,onSelect:a,sort:t.sort,onSort:t.setSort,query:t.query,selection:l?{selectedIds:n.selectedIds,blocked:n.blocked,onToggle:n.toggle,onTogglePage:n.setPage}:void 0})}),e.jsx(Ee,{filters:t}),i.length>0&&e.jsx(Ie,{className:"sticky bottom-6 z-10 mx-auto w-full max-w-xl shadow-lg",count:i.length,onClear:n.exit,selectAll:{total:t.items.length,onSelectAll:()=>n.setPage(t.items.map(p=>p.id),!0)},onDelete:()=>s.start(i)}),e.jsx(Se,{...s.dialogProps})]})}const _=L({otherGroup:{id:"portal.locations.list.otherGroup",defaultMessage:"Other",description:"Fallback group header for locations with
3no country/region/city."},filterAria:{id:"portal.locations.list.filterAria",defaultMessage:"Filter locations",description:"Accessible name for the button that opens the locations filters drawer."},importLocations:{id:"portal.locations.list.importLocationsMobile",defaultMessage:"Import locations",description:"Accessible name for the mobile button that opens the location-import dialog."},select:{id:"portal.locations.list.selectMobile",defaultMessage:"Select",description:"Button that turns on Select mode on the mobile locations list."},cancelSelect:{id:"portal.locations.list.cancelSelectMobile",defaultMessage:"Cancel",description:"Button that turns off Select mode on the mobile locations list."},selectAll:{id:"portal.locations.list.selectAllMobile",defaultMessage:"Select all on this page",description:"Checkbox that selects every location on the current page of the mobile list."},selectRowAria:{id:"portal.locations.list.selectRowAriaMobile",defaultMessage:"Select {name}",description:"Accessible name for a location card's selection checkbox."}});function $t({parts:t,collapsed:a,onToggle:l}){const r=C(),o=a?kt:Nt,n=t.length>0?t:[r.formatMessage(_.otherGroup)];return e.jsxs("button",{type:"button",onClick:l,"aria-expanded":!a,className:"flex w-full items-center gap-2 rounded-sm text-body-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring",children:[e.jsx(o,{className:"size-4 shrink-0 text-on-surface-muted","aria-hidden":"true"}),e.jsx("span",{className:"flex items-center gap-1",children:n.map((s,i)=>e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx("span",{className:"text-on-surface-muted",children:"/"}),e.jsx("span",{className:"text-on-surface-muted",children:s})]},s))}),e.jsx("span",{className:"h-px flex-1 bg-border-subtle","aria-hidden":"true"})]})}const Gt="divide-y divide-border-subtle overflow-hidden rounded-3xl bg-surface-base";function Yt({location:t,blockedLocation:a,selected:l,selecting:r,onToggle:o,onSelect:n}){const s=C();return e.jsxs("div",{className:k("flex items-start gap-2 px-2",a&&"bg-danger-soft"),children:[r&&e.jsx(Y,{className:"mt-4 shrink-0",checked:l,onCheckedChange:()=>o(t.id),"aria-label":s.formatMessage(_.selectRowAria,{name:t.name})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(st,{location:t,onSelect:r?o:n,className:a?"bg-danger-soft hover:bg-danger-soft":void 0}),a&&se(s,a).map(i=>e.jsx("p",{className:"px-4 pb-2 text-body-caption text-danger",children:i.text},i.id))]})]})}function Vt({filters:t,onSelect:a,canManage:l,onImportLocations:r}){const o=C(),n=Ce(t.query),[s,i]=f.useState(!1),[p,g]=f.useState(()=>new Set),u=Me(t.filterKey),h=Le({onBlocked:u.markBlocked,onDeleted:u.exit}),b=m=>g(N=>{const x=new Set(N);return x.has(m)?x.delete(m):x.add(m),x}),v=t.pageItems.map(m=>m.id),y=v.length>0&&v.every(m=>u.selectedIds.has(m)),c=t.items.filter(m=>u.selectedIds.has(m.id)).map(m=>({id:m.id,name:m.name}));return e.jsxs("div",{className:"flex flex-col gap-4 pb-20",children:[e.jsx(nt,{children:e.jsx("h1",{className:"truncate font-brand text-heading-h4-semi text-on-surface-heading",children:e.jsx(w,{id:"portal.locations.list.title",defaultMessage:"Locations",description:"Heading of the locations list page."})})}),e.jsx(lt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[l&&!u.active&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:r,"aria-label":o.formatMessage(_.importLocations),className:k(ce,"text-on-surface"),children:e.jsx(Ne,{className:"size-4","aria-hidden":"true"})}),e.jsx(we,{mode:"create",triggerVariant:"icon"})]}),e.jsx("button",{type:"button",onClick:()=>i(!0),"aria-label":o.formatMessage(_.filterAria),className:k(ce,"text-on-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring"),children:e.jsx(yt,{className:"size-4","aria-hidden":"true"})}),l&&e.jsx("button",{type:"button",onClick:u.active?u.exit:u.enter,className:"text-body-sm-medium text-on-surface",children:o.formatMessage(u.active?_.cancelSelect:_.select)})]})}),e.jsx(ke,{value:t.query,onValueChange:t.setQuery,placeholder:o.formatMessage(V.placeholder),"aria-label":o.formatMessage(V.ariaLabel),enterKeyHint:"search"}),u.active&&e.jsxs("label",{className:"flex items-center gap-2 text-body-sm-medium text-on-surface",children:[e.jsx(Y,{checked:y,onCheckedChange:m=>u.setPage(v,m===!0)}),o.formatMessage(_.selectAll)]}),t.total===0?e.jsx("p",{className:"py-12 text-center text-body-md text-on-surface-muted",children:e.jsx(w,{...n.descriptor,values:n.values})}):e.jsxs("div",{className:"flex flex-col gap-4",children:[Mt(t.pageItems,m=>ve(m,o.locale)).map(m=>
3{const N=p.has(m.key);return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsx($t,{parts:m.parts,collapsed:N,onToggle:()=>b(m.key)}),!N&&e.jsx("div",{className:k(Gt),children:m.locations.map(x=>e.jsx(Yt,{location:x,blockedLocation:u.blocked.get(x.id),selected:u.selectedIds.has(x.id),selecting:u.active,onToggle:u.toggle,onSelect:a},x.id))})]},m.key)}),e.jsx(Ee,{filters:t})]}),e.jsx(tt,{open:s,onOpenChange:i,location:t.location,options:t.options,allOptions:t.allOptions,onToggle:t.toggleLocation,onReset:t.resetLocation}),u.active&&e.jsx(Ie,{count:c.length,onDelete:()=>c.length>0&&h.start(c),className:"fixed inset-x-4 bottom-4 z-10 shadow-lg"}),e.jsx(Se,{...h.dialogProps})]})}const $=L({unavailable:{id:"portal.locations.list.map.unavailable",defaultMessage:"Map is unavailable without a Mapbox token.",description:"Shown in place of the locations overview map when no Mapbox token is configured."},empty:{id:"portal.locations.list.map.empty",defaultMessage:"No locations have a map pin yet.",description:"Empty state shown over the locations overview map when nothing has coordinates to plot."},viewProfile:{id:"portal.locations.list.map.viewProfile",defaultMessage:"View profile",description:"Link text in a map pin popup that opens the location's profile."},hiddenCount:{id:"portal.locations.list.map.hiddenCount",defaultMessage:"{count, plural, one {# location isn't shown because it has no map pin} other {# locations aren't shown because they have no map pin}}",description:"Count of locations excluded from the overview map because they have no coordinates."}}),W=ht,Wt=W["orchid-300"],be=W["orchid-500"],Xt=W["orchid-700"],te=W["white-100"],ye="pk.eyJ1IjoiemluZ2NvYWNoIiwiYSI6ImNtYnBkenJ5azAzMG8ybHNjdWZrM3VudXYifQ.dAcSmyheacAxk_yqEFMFFg",Zt=[-.1276,51.5072],A="locations-overview",q="locations-overview-clusters",Qt="locations-overview-cluster-count",z="locations-overview-point",Jt=50,es=14,ts=48,ss=14,as=15,os={type:"FeatureCollection",features:[]};function ns(t){return t.flatMap(a=>a.latitude!==null&&a.longitude!==null?[{id:a.id,name:a.name,latitude:a.latitude,longitude:a.longitude}]:[])}function ls(t){return{type:"FeatureCollection",features:t.map(a=>({type:"Feature",geometry:{type:"Point",coordinates:[a.longitude,a.latitude]},properties:{id:a.id,name:a.name}}))}}function rs(t,a,l){if(l.length===0)return;const r=new t.LngLatBounds;l.forEach(({latitude:o,longitude:n})=>r.extend([n,o])),a.fitBounds(r,{padding:ts,maxZoom:l.length===1?ss:as,duration:0})}function is(t,a,l){const r=document.createElement("div");r.className="flex flex-col gap-1.5 py-1";const o=document.createElement("p");o.className="text-body-sm-semi text-on-surface",o.textContent=t.name;const n=`/dashboard/locations/${t.id}`,s=document.createElement("a");return s.href=n,s.textContent=a.formatMessage($.viewProfile),s.className="text-body-sm text-brand underline underline-offset-2",s.addEventListener("click",i=>{i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),l(n))}),r.append(o,s),r}function cs({locations:t,className:a}){const l=C(),r=je(),o=f.useRef(null),n=f.useRef(null),s=f.useRef(null),i=f.useRef(null),p=f.useRef(l),g=f.useRef(r),[u,h]=f.useState(!ye),[b,v]=f.useState(!1);p.current=l,g.current=r;const y=f.useMemo(()=>ns(t),[t]),c=t.length-y.length;return f.useEffect(()=>{if(!o.current)return;let m=!1;return(async()=>{const x=(await le(async()=>{const{default:j}=await import("./mapbox-gl-DiYTSXjO.js").then(E=>E.m);return{default:j}},__vite__mapDeps([0,1,2]))).default;if(await le(()=>Promise.resolve({}),__vite__mapDeps([3])),m||!o.current)return;x.accessToken=ye,s.current=x;const d=new x.Map({container:o.current,style:"mapbox://styles/mapbox/light-v11",center:Zt,zoom:1,attributionControl:!0});n.current=d,d.addControl(new x.NavigationControl({showCompass:!1}),"top-right"),d.on("style.load",()=>pt(d)),d.on("load",()=>{if(m)return;d.addSource(A,{type:"geojson",data:os,cluster:!0,clusterRadius:Jt,clusterMa
3xZoom:es}),d.addLayer({id:q,type:"circle",source:A,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],Wt,10,be,50,Xt],"circle-radius":["step",["get","point_count"],16,10,20,50,26],"circle-stroke-width":2,"circle-stroke-color":te}}),d.addLayer({id:Qt,type:"symbol",source:A,filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-size":12},paint:{"text-color":te}}),d.addLayer({id:z,type:"circle",source:A,filter:["!",["has","point_count"]],paint:{"circle-color":be,"circle-radius":8,"circle-stroke-width":2,"circle-stroke-color":te}}),d.on("click",q,X=>{var O,oe;const S=(O=X.features)==null?void 0:O[0];if(!S||S.geometry.type!=="Point")return;const P=(oe=S.properties)==null?void 0:oe.cluster_id;if(P===void 0)return;const Z=d.getSource(A),F=S.geometry.coordinates;Z.getClusterExpansionZoom(P,(_e,ne)=>{_e||ne==null||d.easeTo({center:F,zoom:ne})})}),d.on("click",z,X=>{var F,O;const S=(F=X.features)==null?void 0:F[0];if(!S||S.geometry.type!=="Point")return;const P=S.properties;if(!P)return;(O=i.current)==null||O.remove();const Z=new x.Popup({closeButton:!0,offset:12}).setLngLat(S.geometry.coordinates).setDOMContent(is(P,p.current,g.current)).addTo(d);i.current=Z});const j=d.getCanvas(),E=()=>{j.style.cursor="pointer"},ae=()=>{j.style.cursor=""};d.on("mouseenter",q,E),d.on("mouseleave",q,ae),d.on("mouseenter",z,E),d.on("mouseleave",z,ae),v(!0)})})().catch(()=>{m||h(!0)}),()=>{var x,d;m=!0,(x=i.current)==null||x.remove(),i.current=null,(d=n.current)==null||d.remove(),n.current=null,s.current=null}},[]),f.useEffect(()=>{const m=n.current,N=s.current;if(!m||!N||!b)return;const x=m.getSource(A);x&&(x.setData(ls(y)),rs(N,m,y))},[y,b]),u?e.jsxs("div",{className:k("relative flex h-96 w-full flex-col items-center justify-center gap-2 overflow-hidden bg-surface-sunken text-on-surface-muted",a),children:[e.jsx(ue,{className:"size-5","aria-hidden":"true"}),e.jsx(ee,{variant:"inline",children:e.jsx(w,{...$.unavailable})})]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:k("relative h-96 w-full overflow-hidden bg-surface-sunken",a),children:[e.jsx("div",{ref:o,className:"h-full w-full"}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-surface-raised to-transparent"}),y.length===0&&e.jsxs("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 bg-surface-sunken text-on-surface-muted",children:[e.jsx(ue,{className:"size-5","aria-hidden":"true"}),e.jsx(ee,{variant:"inline",children:e.jsx(w,{...$.empty})})]})]}),c>0&&e.jsx(ee,{variant:"inline",children:e.jsx(w,{...$.hiddenCount,values:{count:c}})})]})}const ds=L({loadingAria:{id:"portal.locations.list.loadingAria",defaultMessage:"Loading locations...",description:"Accessible name for the locations list loading skeleton."}});function us(){const t=C();return e.jsxs("div",{className:"flex flex-col gap-6",role:"status","aria-label":t.formatMessage(ds.loadingAria),children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsx(R,{className:"h-10 w-56"}),e.jsx(R,{className:"h-12 w-40 rounded-2xl"})]}),e.jsx(R,{className:"h-12 w-full max-w-[456px] rounded-2xl"}),e.jsx(R,{className:"h-64 w-full rounded-[16px]"}),e.jsx(R,{className:"h-8 w-48"})]})}function ms(){return e.jsx(Be,{className:"border-none bg-surface-base shadow-none",role:"alert",children:e.jsxs(Fe,{className:"flex flex-col items-center gap-2 py-12 text-center",children:[e.jsx(wt,{className:"size-8 text-on-surface-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body-lg-semi text-on-surface",children:e.jsx(w,{id:"portal.locations.list.errorTitle",defaultMessage:"Could not load locations",description:"Title shown when the locations list fails to load."})}),e.jsx("p",{className:"text-body-md text-on-surface-muted",children:e.jsx(w,{id:"portal.locations.list.errorBody",defaultMessage:"Try refreshing the page.",description:"Body text shown when the locations list fails to load."})})]})})}function ps(){const t=je(),a=mt(),l=rt("locations.manage"),r=Re(),{setOpen:o}=at(dt("location")),{data:n,isLoading:s,isError:i}=$e(),p=Tt(n??[]),g=f.useCallback(b=>t(`/dashboard/locations/${b}`),[t]),u=f.useCallback(()=>o(!0),[o]),h=l&&r?e.jsx(ut,{partnerId:r,entity:"location"}):null;return e.jsxs(e.Fragment,{children:[s?e.jsx(us,{}):i?e.jsx(ms,{}):e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(cs,{locations:p.items,className:a?"-mx-4 -mt-1 w-auto":"-mx-6 -mt-6 w-auto"}),a?e.jsx(Vt,{filters:p,onSelect:g,canManage:l,onImportLocations:u}):e.jsx(Kt,{filters:p,onSelect:g,canManage:l,onImportLocations:u})]}),h]})}function da(){return He({type:"locations",label:"Locations"}),e.jsx(ps,{})}export{da as LocationsPage};
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.