1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BulkSmsDrawer-C1EGDkxu.js","assets/index-lDgJwfvj.js","assets/index-CNvpvgYw.css","assets/SmsSuccessOverlay-aPyi2_YP.js","assets/sms-segments-BY9ukeHt.js","assets/sms-time-format-CZ8-28JG.js","assets/format-DXUGC_R2.js","assets/sms-variables-D4kfmLom.js","assets/use-scheduled-sms-DWyF1E7s.js","assets/clipboard-list-g0Aqb5k9.js","assets/send-B8L0S-hD.js","assets/chevron-right-DnpOQBUQ.js","assets/external-link-DE-D-8-x.js"])))=>i.map(i=>d[i]); 2import{r,u as E,l as M,I as L,j as t,aJ as P,a6 as A,ai as D,b6 as R}from"./index-lDgJwfvj.js";import{a as $}from"./use-dispatch-map-PRGqted8.js";import{u as I}from"./use-click-to-call-tC8nWVMA.js";import{u as O}from"./use-voice-settings-DQrHfi94.js";import{P as T}from"./phone-C_MPOIGo.js";import{E as q}from"./external-link-DE-D-8-x.js";import"./use-station-scoped-query-BjZXI3SB.js";import"./use-search-source-access-BbQCvrdC.js";const z=r.lazy(()=>R(()=>import("./BulkSmsDrawer-C1EGDkxu.js").then(l=>l.a),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(l=>({default:l.BulkSmsDrawer}))),B="https://logistics.amazon.com/business-performance/";function K({open:l,onClose:n}){const{data:v,isLoading:j}=$({enabled:l}),i=r.useMemo(()=>v?.routes??[],[v?.routes]),[x,w]=r.useState(""),[N,u]=r.useState(0),[d,p]=r.useState(null),g=r.useRef(null),_=E(),{toast:c}=M(),h=I(),{settings:b}=O(),o=r.useMemo(()=>{const e=x.trim().toLowerCase();return e?i.filter(a=>{const s=a.route_code?.toLowerCase()??"",C=a.da_name?.toLowerCase()??"";return s.includes(e)||C.includes(e)}):i},[i,x]);r.useEffect(()=>{requestAnimationFrame(()=>g.current?.focus())},[]);const m=o.length===0?0:Math.min(N,o.length-1),f=r.useCallback(e=>{if(!e.da_id||!e.da_phone){c({title:"No phone number on file for this driver",variant:"destructive"});return}if(!b?.voice_forward_to_number){c({title:"Configure your forwarding number in Settings â Voice first",variant:"destructive"});return}h.mutate({da_id:e.da_id,da_name:e.da_name??e.route_code,da_phone:e.da_phone,dispatcher_phone:b.voice_forward_to_number},{onSuccess:()=>{c({title:`Calling your phone â answer to connect to ${e.da_name??e.route_code}`}),n()},onError:a=>c({title:L(a),variant:"destructive"})})},[h,b,c,n]),k=r.useCallback(e=>{p(e)},[]),y=r.useCallback(e=>{_(`/dashboard/dispatch-map?route=${e.route_state_id}`),n()},[_,n]),S=r.useCallback(()=>{window.open(B,"_blank","noopener,noreferrer"),n()},[n]);return r.useEffect(()=>{if(!l)return;const e=a=>{if(a.key==="Escape"){a.preventDefault(),n();return}if(a.key==="ArrowDown"){a.preventDefault(),u(s=>Math.min(s+1,Math.max(0,o.length-1)));return}if(a.key==="ArrowUp"){a.preventDefault(),u(s=>Math.max(s-1,0));return}if(a.key==="Enter"){const s=o[m];s&&(a.preventDefault(),f(s))}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,o,m,f,n]),l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Command palette â call, SMS, rescue, or open Cortex",className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",children:[t.jsx("button",{type:"button","aria-label":"Close command palette",onClick:n,className:"absolute inset-0 bg-slate-900/40 backdrop-blur-sm"}),t.jsxs("div",{className:"relative w-full max-w-xl mx-4 rounded-xl border border-slate-200 bg-white shadow-2xl",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 px-4 py-3",children:[t.jsx(P,{className:"h-4 w-4 text-slate-400","aria-hidden":"true"}),t.jsx("input",{ref:g,type:"text",value:x,onChange:e=>{w(e.target.value),u(0)},placeholder:"Search route code or driver nameâ¦",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-slate-400","aria-label":"Search routes",autoComplete:"off"}),t.jsx("kbd",{className:"text-xs font-medium text-slate-400 border border-slate-200 rounded px-1.5 py-0.5",children:"Esc"})]}),t.jsx("ul",{role:"listbox",className:"max-h-[50vh] overflow-y-auto p-1",children:j&&i.length===0?t.jsx("li",{className:"px-3 py-6 text-center text-sm text-slate-500",children:"Loading routesâ¦"}):o.length===0?t.jsx("li",{className:"px-3 py-6 text-center text-sm text-slate-500",children:i.length===0?"N
2o active routes right now.":"No routes match."}):o.map((e,a)=>t.jsxs("li",{role:"option","aria-selected":a===m,className:`flex items-center justify-between gap-2 rounded-lg px-3 py-2 ${a===m?"bg-slate-100":"hover:bg-slate-50"}`,onMouseEnter:()=>u(a),children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-mono text-sm font-semibold text-slate-900",children:e.route_code}),e.risk_level==="behind"&&t.jsx("span",{className:"text-xs font-medium text-rose-700 bg-rose-50 border border-rose-200 rounded px-1.5 py-0.5",children:"Behind"}),e.risk_level==="at_risk"&&t.jsx("span",{className:"text-xs font-medium text-amber-700 bg-amber-50 border border-amber-200 rounded px-1.5 py-0.5",children:"At risk"})]}),t.jsxs("div",{className:"truncate text-xs text-slate-500",children:[e.da_name??"No driver assigned",e.completion_pct!=null&&` · ${e.completion_pct}% done`]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),f(e)},disabled:h.isPending||!e.da_phone,className:"rounded p-1.5 text-slate-600 hover:bg-slate-200 hover:text-slate-900 disabled:opacity-30 disabled:cursor-not-allowed","aria-label":`Call ${e.da_name??e.route_code}`,title:"Call driver",children:t.jsx(T,{className:"h-4 w-4","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),k(e)},disabled:!e.da_phone,className:"rounded p-1.5 text-slate-600 hover:bg-slate-200 hover:text-slate-900 disabled:opacity-30 disabled:cursor-not-allowed","aria-label":`SMS ${e.da_name??e.route_code}`,title:"Send SMS",children:t.jsx(A,{className:"h-4 w-4","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),y(e)},className:"rounded p-1.5 text-slate-600 hover:bg-slate-200 hover:text-slate-900","aria-label":`Start rescue for ${e.route_code}`,title:"Start rescue",children:t.jsx(D,{className:"h-4 w-4","aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),S()},className:"rounded p-1.5 text-slate-600 hover:bg-slate-200 hover:text-slate-900","aria-label":"Open Cortex",title:"Open Cortex (Amazon Logistics)",children:t.jsx(q,{className:"h-4 w-4","aria-hidden":"true"})})]})]},e.route_state_id))}),t.jsxs("div",{className:"flex items-center justify-between border-t border-slate-100 px-4 py-2 text-xs text-slate-500",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"font-medium border border-slate-200 rounded px-1",children:"ââ"})," navigate ·"," ",t.jsx("kbd",{className:"font-medium border border-slate-200 rounded px-1",children:"âµ"})," call"]}),t.jsxs("span",{children:[o.length," active"]})]})]})]}),t.jsx(r.Suspense,{fallback:null,children:d&&t.jsx(z,{open:!0,onClose:()=>p(null),onSendComplete:()=>{p(null),n()},recipients:[{daId:d.da_id,fullName:d.da_name??d.route_code,phone:d.da_phone}],sourcePage:"manual",mode:"single"})})]}):null}export{K as CommandPalette};
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.