1 line
147 KiB
JavaScript
1 line
147 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[2764],{24873:function(e,n,s){s.r(n),s.d(n,{default:function(){return Fe}});var r=s(45987),t=s(93433),a=s(74165),i=s(15861),c=s(4942),l=s(29439),d=s(37762),o=s(1413),u=s(47313),m=s(84536),p=s(39062),h=s(98817),v=s(74580),f=s(88153),x=s(73999),j=s(93854),g=s(45158),N=s(87248),b=s.n(N);s(63331);b().PolylineOffset={translatePoint:function(e,n,s){return b().point(e.x+n*Math.cos(s),e.y+n*Math.sin(s))},offsetPointLine:function(e,n){var s=e.length;if(s<2)throw new Error("Line should be defined by at least 2 points");for(var r,t=e[0],a=Math.PI/2,i=[],c=1;c<s;c++){r=e[c];var l=Math.atan2(r.y-t.y,r.x-t.x);i.push({offsetAngle:l-a,original:[t,r],offset:[this.translatePoint(t,n,l-a),this.translatePoint(r,n,l-a)]}),t=r}return i},intersection:function(e,n,s,r){var t=this.segmentAsVector(e,n),a=this.segmentAsVector(s,r),i=-a.x*t.y+t.x*a.y;if(0===i)return null;var c=(-t.y*(e.x-s.x)+t.x*(e.y-s.y))/i,l=(a.x*(e.y-s.y)-a.y*(e.x-s.x))/i;return c>=0&&c<=1&&l>=0&&l<=1?b().point(e.x+l*t.x,e.y+l*t.y):null},segmentAsVector:function(e,n){return b().point(n.x-e.x,n.y-e.y)},joinLineSegments:function(e){var n=[],s=e[0].offset;n.push(s[0]);for(var r=1;r<e.length;r++){var t=e[r].offset,a=this.intersection(s[0],s[1],t[0],t[1]);a?n.push(a):n.push(s[1]),s=t}return n.push(s[1]),n},offsetPoints:function(e,n){if(!e||e.length<2)return e;var s=this.offsetPointLine(e,n);return this.joinLineSegments(s)},offsetLatLngs:function(e,n,s){var r=n.map((function(n){return e.latLngToLayerPoint(n)}));return this.offsetPoints(r,s).map((function(n){return e.layerPointToLatLng(n)}))}};var y=b().Polyline.prototype._projectLatlngs;b().Polyline.prototype._projectLatlngs=function(e,n,s){var r=this,t=this.options.offset;if(!t||"number"!==typeof t)return y.call(this,e,n,s);if(e[0]instanceof b().LatLng){for(var a=e.map((function(e){return r._map.latLngToLayerPoint(e)})),i=b().PolylineOffset.offsetPoints(a,t),c=0;c<i.length;c++)s.extend(i[c]);n.push(i)}else for(var l=0;l<e.length;l++)this._projectLatlngs(e[l],n,s)};var k=s(10658),S=s.n(k),_=s(50581),w=s(41962),F=s(25963),A=s(71559),C=s(56573),E=s(22539),M=s(71049),z=s(29127),P=s(46417);var R=function(e){var n=e.focusedRider,s=e.compareDeltas,r=e.compareSummary,t=e.actualOrdered,a=e.focusedCompareStep,i=e.setFocusedCompareStep,c=e.sequenceOpen,d=e.setSequenceOpen,o=e.expandedSeqGroups,m=e.setExpandedSeqGroups,p=e.onClose,h=(0,u.useMemo)((function(){var e=r,a=e.onTime+e.late,i=s.filter((function(e){return e.anomaly})),c=s.filter((function(e){return z.Q6.has(String(e.orderstatus||"").toLowerCase())})).length,d=s.filter((function(e){return z.us.has(String(e.orderstatus||"").toLowerCase())})).length,o=null==e.kmDeltaPct?"":e.kmDeltaPct>25?"is-over":e.kmDeltaPct<-5?"is-under":"",u=s.length||1,m=e.onTime+e.late||1,p=Math.round(c/u*60+e.onTime/m*25+(u-e.anomalies)/u*15),h=p>=85?"#16a34a":p>=65?"#f59e0b":"#dc2626",v=p>=85?"Excellent":p>=65?"Acceptable":"Needs review",f=s.filter((function(e){return e.actualTs})),x=f.reduce((function(e,n){return!e||n.actualTs.isBefore(e)?n.actualTs:e}),null),j=f.reduce((function(e,n){return!e||n.actualTs.isAfter(e)?n.actualTs:e}),null),g=x&&j?Math.max(0,j.diff(x,"minute")):0,N=s.length>1?Math.round(g/(s.length-1)):0,b=g>0?(e.actualKm/(g/60)).toFixed(1):null,y=s.filter((function(e){return!e.isLoading&&e.coordsCount>0})),k=y.filter((function(e){return null!=e.timeDeltaMin&&!e.anomaly})).sort((function(e,n){return e.timeDeltaMin-n.timeDeltaMin}))[0]||null,S=y.filter((function(e){return e.anomaly})).sort((function(e,n){var s=Math.abs(e.kmDeltaPct||0)+(e.timeDeltaMin>0?e.timeDeltaMin:0);return Math.abs(n.kmDeltaPct||0)+(n.timeDeltaMin>0?n.timeDeltaMin:0)-s}))[0]||null,_=t.filter((function(e,n){var s,r=null===(s=e.order)||void 0===s?void 0:s.step;return null!=r&&r!==n+1})),w=[];_.forEach((function(e){var n,s=null===(n=e.order)||void 0===n?void 0:n.step,r=t.findIndex((function(n){return n.sequenceStep===e.sequenceStep}))+1,a=r-s,i=w[w.length-1];i&&i.delta===a&&i.lastActualPos+1===r?(i.items.push({d:e,planned:s,actualPos:r,delta:a}),i.lastActualPos=r):w.push({delta:a,items:[{d:e,planned:s,actualPos:r,delta:a}],lastActualPos:r})}));var F={};n.orders.forEach((function(e){var n=e.trip_number||1;F[n]||(F[n]=[]),F[n].push(e)}));var A=Object.entries(F).sort((function(e,n){var s=(0,l.Z)(e,1)[0],r=(0,l.Z)(n,1)[0];return Number(s)-Number(r)})).map((function(e){var n=(0,l.Z)(e,2),s=n[0],r=n[1];return{tNum:s,count:r.length,actualKm:r.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),delivered:r.filter((function(e){return z.Q6.has(String(e.orderstatus||"").toLowerCase())})).length}}));return{sum:e,totalSteps:a,deviations:i,delivered:c,skipped:d,stepDeltaPct:o,score:p,scoreColor:h,scoreLabel:v,firstDelivery:x,lastDelivery:j,activeMin:g,avgPerStop:N,avgSpeed:b,bestStep:k,worstStep:S,outOfOrderSteps:_,seqRuns:w,tripList:A}}),[n,s,r,t]),v=null!=a?s.find((function(e){return e.sequenceStep===a})):null,f=function(e){i((function(n){return n===e?null:e}))},x=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=e.d,r=e.planned,t=e.actualPos,i=e.delta;return(0,P.jsxs)("li",{className:"cdp-seq-diff".concat(a===s.sequenceStep?" is-focused":"").concat(n?"":" is-nested"),onClick:function(){return f(s.sequenceStep)},children:[(0,P.jsx)("span",{className:"cdp-seq-diff-num",style:{background:(0,z.di)((r||s.sequenceStep)-1)},children:r||s.sequenceStep}),(0,P.jsxs)("div",{className:"cdp-seq-diff-body",children:[(0,P.jsx)("div",{className:"cdp-seq-diff-title",children:s.deliverycustomer||"Step ".concat(r||s.sequenceStep)}),(0,P.jsxs)("div",{className:"cdp-seq-diff-sub",children:["Visited ",(0,P.jsx)("strong",{children:(0,z.xw)(t)})," ","\xb7 planned ",(0,P.jsx)("strong",{children:(0,z.xw)(r)})]})]}),(0,P.jsx)("span",{className:"cdp-seq-diff-tag",children:i>0?"+".concat(i):"".concat(i)})]},"diff-".concat(s.sequenceStep))},j=h.sum,g=h.totalSteps,N=h.deviations,b=h.delivered,y=h.skipped,k=h.stepDeltaPct,S=h.score,_=h.scoreColor,w=h.scoreLabel,F=h.firstDelivery,A=h.lastDelivery,C=h.activeMin,M=h.avgPerStop,R=h.avgSpeed,D=h.bestStep,L=h.worstStep,Z=h.outOfOrderSteps,q=h.seqRuns,O=h.tripList;return(0,P.jsxs)("aside",{id:"compare-data-panel",className:"compare-data-panel",children:[(0,P.jsxs)("div",{className:"cdp-head",children:[(0,P.jsxs)("div",{className:"cdp-head-title",children:[(0,P.jsx)("span",{className:"cdp-rider-dot",style:{background:n.color}}),(0,P.jsxs)("div",{className:"cdp-head-text",children:[(0,P.jsx)("div",{className:"cdp-rider-name",children:n.riderName}),(0,P.jsx)("div",{className:"cdp-head-badge",children:"PLANNED vs ACTUAL"})]})]}),(0,P.jsx)("button",{type:"button",className:"cdp-close",onClick:p,title:"Exit compare","aria-label":"Exit compare",children:(0,P.jsx)(E.FU5,{})})]}),(0,P.jsxs)("div",{className:"cdp-scroll",children:[(0,P.jsx)("section",{className:"cdp-section cdp-score-section",children:(0,P.jsxs)("div",{className:"cdp-score-wrap",children:[(0,P.jsx)("div",{className:"cdp-score-ring",style:{background:"conic-gradient(".concat(_," ").concat(3.6*S,"deg, rgba(15,23,42,0.08) 0deg)")},children:(0,P.jsxs)("div",{className:"cdp-score-inner",children:[(0,P.jsx)("div",{className:"cdp-score-value",style:{color:_},children:S}),(0,P.jsx)("div",{className:"cdp-score-unit",children:"/100"})]})}),(0,P.jsxs)("div",{className:"cdp-score-body",children:[(0,P.jsx)("div",{className:"cdp-score-label",style:{color:_},children:w}),(0,P.jsx)("div",{className:"cdp-score-title",children:"Compliance score"}),(0,P.jsxs)("div",{className:"cdp-score-sub",children:[b,"/",s.length," delivered",j.anomalies>0?" \xb7 ".concat(j.anomalies," deviation").concat(j.anomalies>1?"s":""):"",j.late>0?" \xb7 ".concat(j.late," late"):"",y>0?" \xb7 ".concat(y," skipped"):""]})]})]})}),(0,P.jsxs)("section",{className:"cdp-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.zNX,{})}),(0,P.jsx)("span",{className:"cdp-section-title",children:"Day overview"})]}),(0,P.jsxs)("div",{className:"cdp-tiles",children:[(0,P.jsxs)("div",{className:"cdp-tile",children:[(0,P.jsxs)("div",{className:"cdp-tile-label",children:[(0,P.jsx)(E.v93,{})," Distance"]}),(0,P.jsxs)("div",{className:"cdp-tile-value",children:[j.actualKm.toFixed(1),(0,P.jsx)("span",{className:"cdp-tile-unit",children:"km"})]}),(0,P.jsx)("div",{className:"cdp-tile-sub",children:"actual"})]}),(0,P.jsxs)("div",{className:"cdp-tile".concat(j.anomalies>0?" is-warn":""),children:[(0,P.jsxs)("div",{className:"cdp-tile-label",children:[(0,P.jsx)(E.YTL,{})," Deviation"]}),(0,P.jsx)("div",{className:"cdp-tile-value ".concat(k),children:null!=j.kmDeltaPct?"".concat(j.kmDeltaPct>0?"+":"").concat(j.kmDeltaPct.toFixed(0),"%"):"\u2014"}),(0,P.jsx)("div",{className:"cdp-tile-sub",children:j.anomalies>0?"".concat(j.anomalies," flagged"):"within plan"})]}),(0,P.jsxs)("div",{className:"cdp-tile".concat(j.late>0?" is-warn":""),children:[(0,P.jsxs)("div",{className:"cdp-tile-label",children:[(0,P.jsx)(E.dKE,{})," On-time"]}),(0,P.jsxs)("div",{className:"cdp-tile-value",children:[j.onTime,g>0&&(0,P.jsxs)("span",{className:"cdp-tile-unit",children:["/",g]})]}),(0,P.jsx)("div",{className:"cdp-tile-sub",children:j.late>0?"".concat(j.late," late"):"all on schedule"})]})]})]}),s.length>0&&(0,P.jsxs)("section",{className:"cdp-section cdp-seq-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head cdp-section-head-clickable",onClick:function(){return d((function(e){return!e}))},role:"button","aria-expanded":c,title:c?"Collapse route sequence":"Expand route sequence",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.x82,{})}),(0,P.jsx)("span",{className:"cdp-section-title",children:"Route sequence"}),(0,P.jsx)("span",{className:"cdp-seq-status".concat(Z.length>0?" is-warn":" is-good"),children:Z.length>0?"".concat(Z.length," out of order"):"In order"}),(0,P.jsx)("span",{className:"cdp-seq-toggle".concat(c?" is-open":""),children:(0,P.jsx)(E.Yc6,{})})]}),c&&(0,P.jsx)("div",{className:"cdp-seq",children:Z.length>0?(0,P.jsx)("ul",{className:"cdp-seq-diffs",children:q.map((function(e,n){if(1===e.items.length)return x(e.items[0]);var s=e.items[0],r=e.items[e.items.length-1],t=o.has(n),i=e.delta>0?"+".concat(e.delta):"".concat(e.delta),c=e.items.some((function(e){return e.d.sequenceStep===a}));return(0,P.jsxs)(u.Fragment,{children:[(0,P.jsxs)("li",{className:"cdp-seq-diff is-group".concat(t?" is-expanded":"").concat(c?" is-focused":""),onClick:function(){return e=n,void m((function(n){var s=new Set(n);return s.has(e)?s.delete(e):s.add(e),s}));var e},"aria-expanded":t,children:[(0,P.jsxs)("span",{className:"cdp-seq-group-num",children:[(0,P.jsx)("span",{className:"cdp-seq-group-num-bg",style:{background:"linear-gradient(135deg, ".concat((0,z.di)((s.planned||1)-1),", ").concat((0,z.di)((r.planned||1)-1),")")}}),(0,P.jsxs)("span",{className:"cdp-seq-group-num-label",children:[e.items.length,"\xd7"]})]}),(0,P.jsxs)("div",{className:"cdp-seq-diff-body",children:[(0,P.jsxs)("div",{className:"cdp-seq-diff-title",children:[e.items.length," consecutive steps shifted"," ",(0,P.jsx)("span",{className:"cdp-seq-group-delta",children:i})]}),(0,P.jsxs)("div",{className:"cdp-seq-diff-sub",children:["Planned ",(0,z.xw)(s.planned),"\u2013",(0,z.xw)(r.planned)," ","visited"," ",(0,P.jsxs)("strong",{children:[(0,z.xw)(s.actualPos),"\u2013",(0,z.xw)(r.actualPos)]})]})]}),(0,P.jsx)("span",{className:"cdp-seq-diff-tag",children:i}),(0,P.jsx)("span",{className:"cdp-seq-group-toggle".concat(t?" is-open":""),"aria-hidden":"true",children:(0,P.jsx)(E.Yc6,{})})]}),t&&(0,P.jsx)("li",{className:"cdp-seq-group-children-wrap",children:(0,P.jsx)("ul",{className:"cdp-seq-group-children",children:e.items.map((function(e){return x(e,!1)}))})})]},"run-".concat(n,"-").concat(s.d.sequenceStep))}))}):(0,P.jsxs)("div",{className:"cdp-seq-good",children:[(0,P.jsx)(E.ZSR,{})," Rider followed the planned route in order."]})})]}),(F||A)&&(0,P.jsxs)("section",{className:"cdp-section cdp-timing-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.Vqd,{})}),(0,P.jsx)("span",{className:"cdp-section-title",children:"Timing"}),C>0&&(0,P.jsxs)("span",{className:"cdp-timing-active-tag",children:[(0,P.jsx)("span",{className:"cdp-timing-active-pulse"}),"Day window"]})]}),(0,P.jsxs)("div",{className:"cdp-timing-clock",children:[(0,P.jsxs)("div",{className:"cdp-clock-card is-start",children:[(0,P.jsxs)("div",{className:"cdp-clock-label",children:[(0,P.jsx)(E.KGF,{})," First delivery"]}),(0,P.jsxs)("div",{className:"cdp-clock-face",children:[(0,P.jsx)("span",{className:"cdp-clock-time",children:F?F.format("hh:mm"):"\u2014"}),(0,P.jsx)("span",{className:"cdp-clock-period",children:F?F.format("A"):""})]}),(0,P.jsx)("div",{className:"cdp-clock-caption",children:"Started"})]}),(0,P.jsxs)("div",{className:"cdp-clock-track","aria-hidden":"true",children:[(0,P.jsx)("span",{className:"cdp-clock-track-line"}),(0,P.jsx)("span",{className:"cdp-clock-track-dot is-start"}),(0,P.jsx)("span",{className:"cdp-clock-track-dot is-end"}),(0,P.jsxs)("div",{className:"cdp-clock-duration",children:[(0,P.jsx)("span",{className:"cdp-clock-duration-icon",children:(0,P.jsx)(E.TSC,{})}),(0,P.jsx)("span",{className:"cdp-clock-duration-val",children:C>0?C>=60?"".concat(Math.floor(C/60),"h ").concat(C%60,"m"):"".concat(C,"m"):"\u2014"}),(0,P.jsx)("span",{className:"cdp-clock-duration-sub",children:"active"})]})]}),(0,P.jsxs)("div",{className:"cdp-clock-card is-end",children:[(0,P.jsxs)("div",{className:"cdp-clock-label",children:[(0,P.jsx)(E.ZSR,{})," Last delivery"]}),(0,P.jsxs)("div",{className:"cdp-clock-face",children:[(0,P.jsx)("span",{className:"cdp-clock-time",children:A?A.format("hh:mm"):"\u2014"}),(0,P.jsx)("span",{className:"cdp-clock-period",children:A?A.format("A"):""})]}),(0,P.jsx)("div",{className:"cdp-clock-caption",children:"Finished"})]})]}),(0,P.jsxs)("div",{className:"cdp-timing-stats",children:[(0,P.jsxs)("div",{className:"cdp-timing-stat",children:[(0,P.jsxs)("div",{className:"cdp-timing-stat-head",children:[(0,P.jsx)("div",{className:"cdp-timing-stat-icon",children:(0,P.jsx)(E.dKE,{})}),(0,P.jsxs)("div",{className:"cdp-timing-stat-body",children:[(0,P.jsxs)("div",{className:"cdp-timing-stat-value",children:[M>0?"".concat(M):"\u2014",M>0&&(0,P.jsx)("span",{className:"cdp-timing-stat-unit",children:"min"})]}),(0,P.jsx)("div",{className:"cdp-timing-stat-label",children:"Avg / stop"})]})]}),s.length>0&&(0,P.jsxs)("div",{className:"cdp-timing-stat-viz cdp-stops-dots","aria-hidden":"true",children:[Array.from({length:Math.min(s.length,12)}).map((function(e,n){return(0,P.jsx)("span",{className:"cdp-stop-dot"},"dot-".concat(n))})),(0,P.jsxs)("span",{className:"cdp-timing-stat-viz-label",children:[s.length," stop",1===s.length?"":"s"]})]})]}),null!=R&&(0,P.jsxs)("div",{className:"cdp-timing-stat",children:[(0,P.jsxs)("div",{className:"cdp-timing-stat-head",children:[(0,P.jsx)("div",{className:"cdp-timing-stat-icon",children:(0,P.jsx)(E.JKp,{})}),(0,P.jsxs)("div",{className:"cdp-timing-stat-body",children:[(0,P.jsxs)("div",{className:"cdp-timing-stat-value",children:[R,(0,P.jsx)("span",{className:"cdp-timing-stat-unit",children:"km/h"})]}),(0,P.jsx)("div",{className:"cdp-timing-stat-label",children:"Avg speed"})]})]}),(0,P.jsxs)("div",{className:"cdp-timing-stat-viz cdp-speed-gauge","aria-hidden":"true",children:[(0,P.jsx)("div",{className:"cdp-speed-gauge-track",children:(0,P.jsx)("div",{className:"cdp-speed-gauge-fill",style:{width:"".concat(Math.min(100,parseFloat(R)/60*100),"%")}})}),(0,P.jsxs)("div",{className:"cdp-speed-gauge-scale",children:[(0,P.jsx)("span",{children:"0"}),(0,P.jsx)("span",{children:"30"}),(0,P.jsx)("span",{children:"60 km/h"})]})]})]})]})]}),(D||L)&&(0,P.jsxs)("section",{className:"cdp-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.MVI,{})}),(0,P.jsx)("span",{className:"cdp-section-title",children:"Highlights"})]}),(0,P.jsxs)("div",{className:"cdp-highlights",children:[D&&(0,P.jsxs)("div",{className:"cdp-highlight is-best",onClick:function(){return f(D.sequenceStep)},role:"button",title:"Focus this step",children:[(0,P.jsx)("span",{className:"cdp-highlight-rail","aria-hidden":"true"}),(0,P.jsxs)("div",{className:"cdp-highlight-content",children:[(0,P.jsxs)("div",{className:"cdp-highlight-top",children:[(0,P.jsxs)("span",{className:"cdp-highlight-label",children:[(0,P.jsx)("span",{className:"cdp-highlight-chip",children:(0,P.jsx)(E.ZSR,{})}),"Fastest stop"]}),(0,P.jsxs)("span",{className:"cdp-highlight-step-chip",style:{background:(0,z.di)(D.sequenceStep-1)},children:["Step ",D.sequenceStep]})]}),(0,P.jsx)("div",{className:"cdp-highlight-title",children:D.deliverycustomer||"Step ".concat(D.sequenceStep)}),(0,P.jsx)("div",{className:"cdp-highlight-meta",children:(0,P.jsx)("span",{className:"cdp-highlight-pill is-good",children:null!=D.timeDeltaMin?0===D.timeDeltaMin?"On schedule":"".concat(D.timeDeltaMin>0?"+":"").concat(D.timeDeltaMin," min vs plan"):"On schedule"})})]})]}),L&&(0,P.jsxs)("div",{className:"cdp-highlight is-worst",onClick:function(){return f(L.sequenceStep)},role:"button",title:"Focus this step",children:[(0,P.jsx)("span",{className:"cdp-highlight-rail","aria-hidden":"true"}),(0,P.jsxs)("div",{className:"cdp-highlight-content",children:[(0,P.jsxs)("div",{className:"cdp-highlight-top",children:[(0,P.jsxs)("span",{className:"cdp-highlight-label",children:[(0,P.jsx)("span",{className:"cdp-highlight-chip",children:(0,P.jsx)(E.YTL,{})}),"Biggest deviation"]}),(0,P.jsxs)("span",{className:"cdp-highlight-step-chip",style:{background:(0,z.di)(L.sequenceStep-1)},children:["Step ",L.sequenceStep]})]}),(0,P.jsx)("div",{className:"cdp-highlight-title",children:L.deliverycustomer||"Step ".concat(L.sequenceStep)}),(0,P.jsxs)("div",{className:"cdp-highlight-meta",children:[null!=L.kmDeltaPct&&(0,P.jsxs)("span",{className:"cdp-highlight-pill is-bad",children:[L.kmDeltaPct>0?"+":"",L.kmDeltaPct.toFixed(0),"% route"]}),null!=L.timeDeltaMin&&L.timeDeltaMin>0&&(0,P.jsxs)("span",{className:"cdp-highlight-pill is-bad",children:["+",L.timeDeltaMin,"m late"]})]})]})]})]})]}),O.length>1&&(0,P.jsxs)("section",{className:"cdp-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.x82,{})}),(0,P.jsxs)("span",{className:"cdp-section-title",children:["Trips (",O.length,")"]})]}),(0,P.jsx)("div",{className:"cdp-trips",children:O.map((function(e){return(0,P.jsxs)("div",{className:"cdp-trip",children:[(0,P.jsxs)("div",{className:"cdp-trip-head",children:[(0,P.jsxs)("span",{className:"cdp-trip-badge",children:["Trip ",e.tNum]}),(0,P.jsxs)("span",{className:"cdp-trip-meta",children:[e.delivered,"/",e.count," delivered"]})]}),(0,P.jsx)("div",{className:"cdp-trip-stats",children:(0,P.jsxs)("span",{title:"Distance",children:[(0,P.jsx)(E.v93,{}),e.actualKm.toFixed(1),"km"]})})]},"trip-".concat(e.tNum))}))})]}),v&&function(){var e=(0,z.di)(v.sequenceStep-1),n=null!=v.timeDeltaMin?v.timeDeltaMin>10?"is-over":v.timeDeltaMin<-2?"is-under":"":"",s=(0,z.Cl)(v.orderstatus);return(0,P.jsxs)("section",{className:"cdp-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.x82,{})}),(0,P.jsxs)("span",{className:"cdp-section-title",children:["Step ",v.sequenceStep," details"]}),(0,P.jsx)("button",{type:"button",className:"cdp-section-clear",onClick:function(){return i(null)},title:"Clear step focus",children:"Show all"})]}),(0,P.jsxs)("div",{className:"compare-delta".concat(v.anomaly?" is-anomaly":""),children:[(0,P.jsxs)("div",{className:"compare-delta-title",children:[(0,P.jsx)("span",{className:"compare-delta-step-badge",style:{background:e},children:v.sequenceStep}),(0,P.jsxs)("div",{className:"compare-delta-title-text",children:[(0,P.jsx)("div",{className:"compare-delta-title-main",children:v.deliverycustomer||"Step ".concat(v.sequenceStep)}),(0,P.jsxs)("div",{className:"compare-delta-title-sub",children:[v.pickupcustomer?"from ".concat(v.pickupcustomer," \xb7 "):"","Order #",v.orderid]})]}),v.orderstatus&&(0,P.jsx)("span",{className:"compare-delta-status",style:{background:s.bg,color:s.fg},children:s.label})]}),(0,P.jsxs)("div",{className:"compare-delta-grid",children:[(0,P.jsxs)("div",{className:"compare-delta-cell".concat(v.anomaly?" is-anomaly":""),children:[(0,P.jsx)("span",{className:"compare-delta-cell-label",children:"Distance"}),(0,P.jsxs)("span",{className:"compare-delta-cell-val",children:[v.actualKm.toFixed(2)," ",(0,P.jsx)("span",{className:"compare-delta-cell-unit",children:"km"})]}),(0,P.jsx)("span",{className:"compare-delta-cell-sub",children:"actual"})]}),(0,P.jsxs)("div",{className:"compare-delta-cell",children:[(0,P.jsx)("span",{className:"compare-delta-cell-label",children:"Time"}),(0,P.jsx)("span",{className:"compare-delta-cell-val ".concat(n),children:null!=v.timeDeltaMin?"".concat(v.timeDeltaMin>0?"+":"").concat(v.timeDeltaMin," min"):"\u2014"}),(0,P.jsx)("span",{className:"compare-delta-cell-sub",children:v.actualTs&&v.expectedTs?"".concat(v.actualTs.format("HH:mm")," vs ").concat(v.expectedTs.format("HH:mm")):v.actualTs?"delivered ".concat(v.actualTs.format("HH:mm")):"in flight"})]})]})]})]})}(),N.length>0&&(0,P.jsxs)("section",{className:"cdp-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon cdp-icon-warn",children:(0,P.jsx)(E.wr$,{})}),(0,P.jsxs)("span",{className:"cdp-section-title",children:["Deviations (",N.length,")"]})]}),(0,P.jsx)("ul",{className:"cdp-dev-list",children:N.map((function(e){var n=(0,z.di)(e.sequenceStep-1),s=e.kmDelta>=0?"+":"";return(0,P.jsxs)("li",{className:"cdp-dev-item".concat(a===e.sequenceStep?" is-focused":""),onClick:function(){return f(e.sequenceStep)},children:[(0,P.jsx)("span",{className:"cdp-dev-num",style:{background:n},children:e.sequenceStep}),(0,P.jsxs)("div",{className:"cdp-dev-body",children:[(0,P.jsx)("div",{className:"cdp-dev-title",children:e.deliverycustomer||"Step ".concat(e.sequenceStep)}),(0,P.jsxs)("div",{className:"cdp-dev-meta",children:[null!=e.kmDeltaPct&&(0,P.jsxs)("span",{className:"cdp-dev-chip is-over",children:[s,e.kmDeltaPct.toFixed(0),"% route"]}),null!=e.timeDeltaMin&&e.timeDeltaMin>10&&(0,P.jsxs)("span",{className:"cdp-dev-chip is-over",children:["+",e.timeDeltaMin,"m late"]})]})]})]},"dev-".concat(e.sequenceStep))}))})]}),(0,P.jsxs)("section",{className:"cdp-section",children:[(0,P.jsxs)("div",{className:"cdp-section-head",children:[(0,P.jsx)("span",{className:"cdp-section-icon",children:(0,P.jsx)(E.f_H,{})}),(0,P.jsxs)("span",{className:"cdp-section-title",children:["Steps (",s.length,")"]}),(0,P.jsxs)("span",{className:"cdp-section-sub",children:[b,"/",s.length," delivered"]})]}),(0,P.jsx)("ul",{className:"cdp-step-list",children:s.map((function(e){var n=(0,z.di)(e.sequenceStep-1),s=String(e.orderstatus||"").toLowerCase(),r=z.Q6.has(s),t=z.us.has(s),i=r&&!e.anomaly,c=a===e.sequenceStep,l=(0,z.Cl)(e.orderstatus),d=null!=e.timeDeltaMin?e.timeDeltaMin>10?"is-over":e.timeDeltaMin<-2?"is-under":"":"",o=["cdp-step",c?"is-focused":"",e.anomaly?"is-anomaly":"",i?"is-correct":"",t?"is-skipped":"",e.isLoading?"is-loading":""].filter(Boolean).join(" ");return(0,P.jsxs)("li",{className:o,onClick:function(){return f(e.sequenceStep)},children:[(0,P.jsxs)("span",{className:"cdp-step-num",style:{background:n},children:[e.sequenceStep,i&&(0,P.jsx)("span",{className:"cdp-step-check",children:(0,P.jsx)(E.ZSR,{})}),e.anomaly&&(0,P.jsx)("span",{className:"cdp-step-flag",children:(0,P.jsx)(E.wr$,{})})]}),(0,P.jsxs)("div",{className:"cdp-step-body",children:[(0,P.jsxs)("div",{className:"cdp-step-title-row",children:[(0,P.jsx)("span",{className:"cdp-step-title",children:e.deliverycustomer||"Step ".concat(e.sequenceStep)}),e.orderstatus&&(0,P.jsx)("span",{className:"cdp-step-status",style:{background:l.bg,color:l.fg},children:l.label})]}),(0,P.jsxs)("div",{className:"cdp-step-sub",children:[e.pickupcustomer?"from ".concat(e.pickupcustomer," \xb7 "):"","Order #",e.orderid]}),(0,P.jsxs)("div",{className:"cdp-step-deltas",children:[(0,P.jsxs)("span",{className:"cdp-step-delta",title:"Distance",children:[(0,P.jsx)(E.v93,{}),e.actualKm.toFixed(1),"km"]}),(0,P.jsxs)("span",{className:"cdp-step-delta ".concat(d),title:"Delivery time",children:[(0,P.jsx)(E.dKE,{}),e.actualTs?e.actualTs.format("HH:mm"):"\u2014",null!=e.timeDeltaMin&&(0,P.jsxs)("small",{children:[" ",e.timeDeltaMin>0?"+":"",e.timeDeltaMin,"m"]})]})]})]})]},"step-".concat(e.sequenceStep))}))})]})]})]})},D=s(84506),L={DEBUG:0,INFO:1,WARN:2,ERROR:3},Z=L.WARN,q=function(e,n){return"background: ".concat(e,"; color: ").concat(n,"; padding: 2px 5px; border-radius: 4px; font-weight: bold;")},O=q("#2563eb","#ffffff"),T=console.log,I=console.warn||console.log,H=console.error||console.log,K=function(e,n,s){if(!(L[e]<Z)){var r=(0,D.Z)(n),a=r[0],i=r.slice(1),c="string"===typeof a,l="".concat("%c[NearlExpress]","%c ").concat(e),d=[O,s],o="ERROR"===e?H:"WARN"===e?I:T;c?o.apply(void 0,["".concat(l,"%c ").concat(a)].concat(d,["color: inherit;"],(0,t.Z)(i))):o.apply(void 0,["".concat(l)].concat(d,[a],(0,t.Z)(i)))}},B={debug:function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return K("DEBUG",n,q("#64748b","#ffffff"))},info:function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return K("INFO",n,q("#10b981","#ffffff"))},warn:function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return K("WARN",n,q("#f59e0b","#ffffff"))},error:function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];K("ERROR",n,q("#ef4444","#ffffff"))}},Y=B,G=["_ts"],U="#6366f1",V="#10b981",W=function(e){var n=parseFloat(e);return Number.isFinite(n)?n:NaN},J=function(e){if(!e)return"";var n=String(e).trim();if(!n)return"";if(n.includes(",")){var s=n.split(",").map((function(e){return e.trim()})).filter(Boolean);return 0===s.length?n:s.length<=2?s.join(", "):s.slice(-2).join(", ")}var r=n.split(/\s+/).filter(Boolean),t=r.length>6?r.slice(-6).join(" "):n;return t.length>40?"".concat(t.slice(0,40).trim(),"\u2026"):t},Q=function(e){return Number.isFinite(W(e.droplat||e.deliverylat))&&Number.isFinite(W(e.droplon||e.deliverylong))},X=function(e){return e.pickuplat||e.pickuplatitude||e.pickup_lat},$=function(e){return e.pickuplong||e.pickuplongitude||e.picklongitude||e.pickup_lon},ee=function(e){return Number.isFinite(W(X(e)))&&Number.isFinite(W($(e)))},ne=[{id:"morning",name:"Morning Batch",startHour:0,endHour:8},{id:"afternoon",name:"Afternoon Batch",startHour:9,endHour:12.5},{id:"evening",name:"Evening Batch",startHour:16,endHour:19}],se="dispatch.slots.v8",re=["dispatch.slots.v1","dispatch.slots.v2","dispatch.slots.v3","dispatch.slots.v4","dispatch.slots.v5","dispatch.slots.v6","dispatch.slots.v7"],te=function(e,n){return"Slot ".concat(e+1," \xb7 ").concat(ae(n))},ae=function(e){var n=Math.floor(e),s=Math.round(60*(e-n)),r=(n+11)%12+1,t=n>=12&&n<24?"PM":"AM";if(0===s)return"".concat(r," ").concat(t);var a=String(s).padStart(2,"0");return"".concat(r,":").concat(a," ").concat(t)},ie=function(e,n){return n>=24?"After ".concat(ae(e)):"".concat(ae(e),"\u2013").concat(ae(n))},ce=ne.map((function(e,n){return(0,o.Z)((0,o.Z)({},e),{},{label:e.name||te(n,e.startHour),range:ie(e.startHour,e.endHour)})})),le=function(e,n){var s,r=(0,d.Z)(n);try{for(r.s();!(s=r.n()).done;){var t=s.value;if(e>=t.startHour&&e<t.endHour)return t.id}}catch(a){r.e(a)}finally{r.f()}return null},de=[{id:"delivered",label:"Delivered",keys:["deliverytime"]},{id:"pending",label:"Pending",keys:["expecteddeliverytime"]},{id:"assigned",label:"Assigned",keys:["assigntime"]},{id:"accepted",label:"Accepted",keys:["acceptedtime"]},{id:"started",label:"Started",keys:["starttime"]},{id:"arrived",label:"Arrived",keys:["arrivaltime"]},{id:"pickup",label:"Pickup",keys:["pickuptime"]},{id:"all",label:"All",keys:["deliverytime","expecteddeliverytime","assigntime","acceptedtime","arrivaltime","pickuptime","starttime"]}],oe=function(e,n){var s,r=de.find((function(e){return e.id===n}))||de[0],t=(0,d.Z)(r.keys);try{for(t.s();!(s=t.n()).done;){var a=s.value;if(null!==e&&void 0!==e&&e[a])return e[a]}}catch(i){t.e(i)}finally{t.f()}return null},ue=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ce,r=oe(e,n);if(!r)return null;var t=String(r).trim();if(/^\d{4}-\d{2}-\d{2}$/.test(t))return null;var a=S()(r);return a.isValid()?le(a.hour()+a.minute()/60,s):null};function me(e){var n=e.targetRef,s=(0,m.Sx)();return(0,u.useEffect)((function(){return n.current=s,function(){n.current=null}}),[s]),null}function pe(e,n){var s=function(e){return e*Math.PI/180},r=s(e[0]),t=s(n[0]),a=s(n[0]-e[0]),i=s(n[1]-e[1]),c=Math.pow(Math.sin(a/2),2)+Math.cos(r)*Math.cos(t)*Math.pow(Math.sin(i/2),2);return 12742*Math.asin(Math.min(1,Math.sqrt(c)))}function he(e){if(!Array.isArray(e)||e.length<2)return 0;for(var n=0,s=1;s<e.length;s++)n+=pe(e[s-1],e[s]);return n}function ve(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Array.isArray(e)||0===e.length)return[];if(1===e.length)return[{lat:e[0].lat,lng:e[0].lng,logdate:e[0].logdate}];var s=null!=n.processNoise?n.processNoise:1e-9,r=null!=n.measurementNoise?n.measurementNoise:1e-7,t=function(e){return e._ts||(e.logdate?new Date(e.logdate).getTime():0)},a=function(n){for(var a=e[0][n],i=0,c=1,l=0,d=0,o=1,u=[a],m=t(e[0]),p=1;p<e.length;p++){var h=t(e[p])||m+1e3,v=Math.max(.1,(h-m)/1e3);m=h;var f=a+i*v,x=i,j=v*v,g=j*v,N=c+v*(l+d)+j*o+g*v/4*s,b=l+v*o+g/2*s,y=d+v*o+g/2*s,k=o+j*s,S=e[p][n]-f,_=N+r,w=N/_,F=y/_;a=f+w*S,i=x+F*S,c=(1-w)*N,l=(1-w)*b,d=y-F*N,o=k-F*b,u.push(a)}return u},i=a("lat"),c=a("lng");return e.map((function(e,n){return{lat:i[n],lng:c[n],logdate:e.logdate,_ts:e._ts}}))}function fe(e,n){if(!Array.isArray(e)||e.length<2||!n||!n.length)return[];for(var s=n.map((function(n){for(var s=0,r=1/0,t=0;t<e.length;t++){var a=e[t][0]-n[0],i=e[t][1]-n[1],c=a*a+i*i;c<r&&(r=c,s=t)}return s})),r=1;r<s.length;r++)s[r]<s[r-1]&&(s[r]=s[r-1]);var t=[],a=0;return s.forEach((function(n){var s=Math.max(n,a);t.push(e.slice(a,s+1)),a=s})),t}var xe=function(e){if(!e)return null;var n=S()(e);return n.isValid()?n.format("HH:mm:ss"):String(e)},je=[{key:"assigntime",label:"Assigned"},{key:"acceptedtime",label:"Accepted"},{key:"arrivaltime",label:"Arrived"},{key:"pickuptime",label:"Pickup"},{key:"starttime",label:"Started"},{key:"deliverytime",label:"Delivered",final:!0}],ge=function(e){var n=e.filter(Q);if(!n.length)return[];var s=e.find(ee),r=[];return s&&r.push([W(X(s)),W($(s))]),n.forEach((function(e){return r.push([W(e.droplat||e.deliverylat),W(e.droplon||e.deliverylong)])})),r};delete b().Icon.Default.prototype._getIconUrl,b().Icon.Default.mergeOptions({iconRetinaUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon-2x.png",iconUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png"});var Ne=["#0055FF","#00D82C","#FF6B00","#9D00FF","#FF00A8","#00C2B2","#FF9900","#FF0000"],be=function(e){var n=String(null!==e&&void 0!==e?e:"");if(!n)return Ne[0];for(var s=0,r=0;r<n.length;r++)s=31*s+n.charCodeAt(r)>>>0;return Ne[s%Ne.length]},ye=function(e){var n=e.focusedItem,s=e.viewMode,r=e.orders,t=e.kitchens,a=e.locationKey,i=e.extraPoints,c=(0,m.Sx)(),l=(0,u.useRef)(""),o=(0,u.useMemo)((function(){var e=null!=a?"loc:".concat(a,"|"):"",c=function(e){var n,s=0,r=0,t=0,a=(0,d.Z)(e);try{for(a.s();!(n=a.n()).done;){var i=n.value;Number.isFinite(i[0])&&Number.isFinite(i[1])&&(s+=i[0],r+=i[1],t+=1)}}catch(c){a.e(c)}finally{a.f()}return 0===t?"0":"".concat((s/t).toFixed(1),",").concat((r/t).toFixed(1))};if(n){var l,o,u,m=null!==(l=null!==(o=null!==(u=n.id)&&void 0!==u?u:n.kitchenName)&&void 0!==o?o:n.name)&&void 0!==l?l:null!=n.lat?"".concat(n.lat,",").concat(n.lon):"item",p=n.orders?n.orders.length:0;return"".concat(e,"f|").concat(m,"|").concat(p)}var h=(t||[]).map((function(e){return[e.lat,e.lon]})),v=c(h);if("kitchens"===s){var f=h.filter((function(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])})).length;return"".concat(e,"k|").concat(f,"|").concat(v)}if("all"===s){var x=(r||[]).map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]})),j=i||[],g=x.concat(j);return"".concat(e,"a|").concat(g.length,"|").concat(c(g))}return"".concat(e,"m|").concat(s||"","|").concat(h.length,"|").concat(v)}),[n,s,r,t,a]);return(0,u.useEffect)((function(){if(l.current!==o){var e=[];n?n.orders&&n.orders.length?(e=n.orders.map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]})),n.orders.forEach((function(n){return e.push([W(X(n)),W($(n))])}))):e=[[n.lat,n.lon]]:"kitchens"===s?0===(e=(t||[]).filter((function(e){return Number.isFinite(e.lat)&&Number.isFinite(e.lon)})).map((function(e){return[e.lat,e.lon]}))).length&&(e=(r||[]).map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]}))):"all"===s?e=(e=(r||[]).map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]}))).concat(i||[]):0===(e=(t||[]).filter((function(e){return Number.isFinite(e.lat)&&Number.isFinite(e.lon)})).map((function(e){return[e.lat,e.lon]}))).length&&(e=(r||[]).map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]})));var a=e.filter((function(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])}));if(a.length>0){var d=b().latLngBounds(a);d.isValid()&&(1===a.length||d.getNorthEast().equals(d.getSouthWest())?c.setView(a[0],15,{animate:!0,duration:.6}):c.flyToBounds(d,{padding:[60,60],duration:.6,maxZoom:16}),l.current=o)}else;}}),[o,n,s,r,t,i,c]),null},ke=function(e){var n=e.target,s=e.icon,r=e.duration,t=void 0===r?950:r,a=e.zIndexOffset,i=e.eventHandlers,c=e.children,l=e.markerRef,d=(0,u.useRef)(null),o=(0,u.useRef)(null),m=(0,u.useRef)(n),h=(0,u.useRef)(null),v=Array.isArray(n)?Number(n[0]):NaN,f=Array.isArray(n)?Number(n[1]):NaN;return(0,u.useEffect)((function(){var e=d.current;if(e&&Number.isFinite(v)&&Number.isFinite(f)){var n=b().latLng(v,f),s=e.getLatLng();if(s){var r=n.lat-s.lat,a=n.lng-s.lng;if(!(Math.abs(r)<1e-6&&Math.abs(a)<1e-6)){var i=!1;try{i=s.distanceTo(n)>2e3}catch(x){i=!1}if(i)return e.setLatLng(n),void(h.current=performance.now());o.current&&cancelAnimationFrame(o.current);var c=performance.now(),l=null==h.current?t:c-h.current,u=Math.max(800,Math.min(32e3,l));h.current=c;var m=s.lat,p=s.lng;return o.current=requestAnimationFrame((function n(s){var t=Math.min(1,(s-c)/u);e.setLatLng([m+r*t,p+a*t]),t<1&&(o.current=requestAnimationFrame(n))})),function(){o.current&&cancelAnimationFrame(o.current)}}e.setLatLng(n)}else e.setLatLng(n)}}),[v,f,t]),(0,u.useEffect)((function(){return function(){o.current&&cancelAnimationFrame(o.current)}}),[]),(0,P.jsx)(p.J,{ref:function(e){d.current=e,"function"===typeof l?l(e):l&&(l.current=e)},position:m.current,icon:s,zIndexOffset:a,eventHandlers:i,children:c})},Se=function(e){var n=e.children;return(0,P.jsx)("span",{className:"ico-inline",style:{display:"inline-flex",alignItems:"center",verticalAlign:"-2px",marginRight:4},children:n})},_e=[{key:"morning",label:"Morning",timeRange:"12:00 AM \u2013 8:00 AM",sub:"Early shift orders",color:"#f59e0b",bg:"#fffbeb",border:"#fde68a"},{key:"afternoon",label:"Noon",timeRange:"9:00 AM \u2013 12:30 PM",sub:"Lunch rush window",color:"#10b981",bg:"#ecfdf5",border:"#a7f3d0"},{key:"evening",label:"Evening",timeRange:"4:00 PM \u2013 7:00 PM",sub:"Dinner & end-of-day",color:"#6366f1",bg:"#eef2ff",border:"#c7d2fe"}],we=function(e){if(null==e)return"\u2014";if("number"===typeof e)return e.toLocaleString("en-IN");var n=parseFloat(e);return Number.isFinite(n)?n.toLocaleString("en-IN"):String(e)},Fe=function(e){var n=e.data,s=e.embedded,m=void 0!==s&&s,N=e.selectedRiderId,y=e.onRiderSelect,k=e.pulseOrderId,D=e.onChangeRider,L=null!==n&&void 0!==n&&n.zones&&n.zones.length>0?"zones":"riders",Z=(0,u.useState)(L),q=(0,l.Z)(Z,2),O=q[0],T=q[1],I=(0,u.useState)("live"),H=(0,l.Z)(I,2),K=H[0],B=(H[1],(0,u.useState)({})),ae=(0,l.Z)(B,2),de=ae[0],oe=ae[1],Fe=(0,u.useState)(null),Ae=(0,l.Z)(Fe,2),Ce=Ae[0],Ee=Ae[1],Me=(0,u.useState)(null),ze=(0,l.Z)(Me,2),Pe=ze[0],Re=ze[1],De=(0,_.D)({mutationFn:M.UV,onMutate:function(e){return Ee(e.batch)},onSuccess:function(e,n){oe((function(s){return(0,o.Z)((0,o.Z)({},s),{},(0,c.Z)({},n.batch,{data:e,fetchedAt:S()().format("HH:mm:ss")}))}))},onSettled:function(){return Ee(null)}}),Le=function(e){Re(e);var n=de[e];n&&n.data&&!1!==n.data.success||De.mutate({batch:e,tenantId:916})},Ze=(0,u.useState)(new Set),qe=(0,l.Z)(Ze,2),Oe=qe[0],Te=qe[1],Ie=(0,u.useState)(null),He=(0,l.Z)(Ie,2),Ke=He[0],Be=He[1],Ye=(0,u.useState)(null),Ge=(0,l.Z)(Ye,2),Ue=Ge[0],Ve=Ge[1],We=(0,u.useState)(null),Je=(0,l.Z)(We,2),Qe=Je[0],Xe=Je[1],$e=(0,u.useState)(null),en=(0,l.Z)($e,2),nn=en[0],sn=en[1],rn=(0,u.useState)("planned"),tn=(0,l.Z)(rn,2),an=tn[0],cn=tn[1],ln=(0,u.useRef)({}),dn=(0,u.useRef)(new Set),on=(0,u.useRef)(new Set),un=(0,u.useRef)(new Map),mn=((0,u.useRef)(null),(0,u.useRef)(null)),pn=(0,u.useState)(null),hn=(0,l.Z)(pn,2),vn=hn[0],fn=hn[1],xn=void 0!==N,jn=(0,u.useState)(""),gn=(0,l.Z)(jn,2),Nn=gn[0],bn=gn[1],yn=(0,w.a)({queryKey:["appLocations"],queryFn:M.gO,staleTime:3e5}).data,kn="undefined"!==typeof window?localStorage.getItem("applocationid"):null,Sn=(0,u.useState)(null!=kn?Number(kn):0),_n=(0,l.Z)(Sn,2),wn=_n[0],Fn=(_n[1],(0,u.useState)(!1)),An=(0,l.Z)(Fn,2),Cn=An[0],En=An[1],Mn=(0,u.useRef)(null),zn=(0,u.useState)("assigned"),Pn=(0,l.Z)(zn,2),Rn=Pn[0],Dn=(Pn[1],(0,u.useState)(!1)),Ln=(0,l.Z)(Dn,2),Zn=Ln[0],qn=Ln[1],On=(0,u.useRef)(null),Tn=(0,u.useState)((function(){if("undefined"===typeof window)return ce;try{var e=window.localStorage.getItem(se);if(!e)return ce;var n=JSON.parse(e);return Array.isArray(n)&&n.length===ne.length?n.map((function(e,n){var s=e.id||"slot-".concat(n+1),r=Number(e.startHour)||0,t=Number(e.endHour)||24,a=ce.find((function(e){return e.id===s}));return{id:s,startHour:r,endHour:t,label:(null===a||void 0===a?void 0:a.name)||te(n,r),range:ie(r,t)}})):ce}catch(s){return ce}})),In=(0,l.Z)(Tn,2),Hn=In[0],Kn=(In[1],Hn),Bn=(0,u.useState)(!1),Yn=(0,l.Z)(Bn,2),Gn=Yn[0],Un=Yn[1],Vn=(0,u.useRef)(null);(0,u.useEffect)((function(){if("undefined"!==typeof window)try{re.forEach((function(e){return window.localStorage.removeItem(e)}))}catch(e){}}),[]);var Wn=(0,u.useRef)(!1);(0,u.useEffect)((function(){if(Wn.current){if("undefined"!==typeof window)try{window.localStorage.setItem(se,JSON.stringify(Hn.map((function(e){return{id:e.id,startHour:e.startHour,endHour:e.endHour}}))))}catch(e){}}else Wn.current=!0}),[Hn]),(0,u.useEffect)((function(){if(Cn){var e=function(e){Mn.current&&!Mn.current.contains(e.target)&&En(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}}),[Cn]),(0,u.useEffect)((function(){if(Zn){var e=function(e){On.current&&!On.current.contains(e.target)&&qn(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}}),[Zn]),(0,u.useEffect)((function(){if(Gn){var e=function(e){Vn.current&&!Vn.current.contains(e.target)&&Un(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}}),[Gn]);var Jn=(0,u.useState)(null),Qn=(0,l.Z)(Jn,2),Xn=Qn[0],$n=Qn[1],es=(0,u.useState)(""),ns=(0,l.Z)(es,2),ss=ns[0],rs=ns[1],ts=(0,w.a)({queryKey:["riderPeriodicLog",Xn],queryFn:function(){return(0,M.hG)(Xn)},enabled:"rider-info"===O&&null!=Xn,refetchInterval:"rider-info"===O&&null!=Xn&&15e3,refetchIntervalInBackground:!1,staleTime:5e3,refetchOnWindowFocus:!1}),as=ts.data,is=ts.isFetching,cs=ts.isError,ls=ts.error,ds=(0,u.useMemo)((function(){var e=parseFloat(null===as||void 0===as?void 0:as.latitude),n=parseFloat(null===as||void 0===as?void 0:as.longitude);return Number.isFinite(e)&&Number.isFinite(n)?{lat:e.toFixed(4),lon:n.toFixed(4)}:null}),[null===as||void 0===as?void 0:as.latitude,null===as||void 0===as?void 0:as.longitude]),os=(0,w.a)({queryKey:["reverseGeocode",null===ds||void 0===ds?void 0:ds.lat,null===ds||void 0===ds?void 0:ds.lon],queryFn:function(){var e=(0,i.Z)((0,a.Z)().mark((function e(){var n,s,r,t;return(0,a.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://nominatim.openstreetmap.org/reverse?lat=".concat(ds.lat,"&lon=").concat(ds.lon,"&format=json&zoom=16&addressdetails=1"),{headers:{Accept:"application/json"}});case 2:if((n=e.sent).ok){e.next=5;break}return e.abrupt("return",null);case 5:return e.next=7,n.json();case 7:return s=e.sent,r=(null===s||void 0===s?void 0:s.address)||{},t=r.suburb||r.neighbourhood||r.village||r.hamlet||r.city_district||r.town||r.city||r.county||r.state||"",e.abrupt("return",{area:t,display:(null===s||void 0===s?void 0:s.display_name)||""});case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),enabled:"rider-info"===O&&!!ds,staleTime:3e5,refetchOnWindowFocus:!1,retry:1}),us=os.data,ms=(0,u.useMemo)((function(){if(!yn)return null;var e=yn.find((function(e){return String(e.applocationid)===String(wn)}));return(null===e||void 0===e?void 0:e.locationname)||null}),[yn,wn]),ps=(0,u.useState)({}),hs=(0,l.Z)(ps,2),vs=hs[0],fs=hs[1],xs=(0,u.useRef)({}),js=(0,u.useState)({}),gs=(0,l.Z)(js,2),Ns=gs[0],bs=gs[1],ys=(0,u.useRef)({}),ks=(0,u.useState)(!1),Ss=(0,l.Z)(ks,2),_s=Ss[0],ws=Ss[1],Fs=(0,u.useState)([]),As=(0,l.Z)(Fs,2),Cs=As[0],Es=As[1],Ms=(0,u.useState)({}),zs=(0,l.Z)(Ms,2),Ps=zs[0],Rs=zs[1],Ds=(0,u.useRef)(!1),Ls=(0,u.useState)(S()().format("YYYY-MM-DD")),Zs=(0,l.Z)(Ls,2),qs=Zs[0],Os=Zs[1],Ts=(0,u.useState)(!1),Is=(0,l.Z)(Ts,2),Hs=Is[0],Ks=Is[1],Bs=(0,u.useState)((function(){return S()(qs).isValid()?S()(qs).startOf("month"):S()().startOf("month")})),Ys=(0,l.Z)(Bs,2),Gs=Ys[0],Us=Ys[1],Vs=(0,u.useRef)(null);(0,u.useEffect)((function(){if(Hs){var e=function(e){Vs.current&&(Vs.current.contains(e.target)||Ks(!1))},n=function(e){"Escape"===e.key&&Ks(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",n),function(){document.removeEventListener("mousedown",e),document.removeEventListener("keydown",n)}}}),[Hs]),(0,u.useEffect)((function(){if(Hs){var e=S()(qs);e.isValid()&&Us(e.startOf("month"))}}),[Hs,qs]);var Ws=(0,u.useState)(!1),Js=(0,l.Z)(Ws,2),Qs=Js[0],Xs=Js[1],$s=(0,u.useState)("combined"),er=(0,l.Z)($s,2),nr=er[0],sr=er[1],rr=(0,u.useState)(!0),tr=(0,l.Z)(rr,2),ar=tr[0],ir=tr[1],cr=(0,u.useState)(!0),lr=(0,l.Z)(cr,2),dr=lr[0],or=lr[1],ur=(0,u.useState)((function(){return new Set})),mr=(0,l.Z)(ur,2),pr=mr[0],hr=mr[1],vr=(0,u.useRef)(!1),fr=(0,u.useState)(!1),xr=(0,l.Z)(fr,2),jr=xr[0],gr=xr[1],Nr=(0,u.useRef)(!1),br=(0,u.useRef)(!1),yr=(0,u.useState)(!1),kr=(0,l.Z)(yr,2),Sr=kr[0],_r=kr[1],wr=(0,u.useState)(null),Fr=(0,l.Z)(wr,2),Ar=Fr[0],Cr=Fr[1],Er=(0,u.useRef)(null),Mr=(0,u.useRef)(null);Mr.current||(Mr.current=b().canvas({padding:1.5,tolerance:5}));var zr="all"===O?1e3:15e3,Pr=(0,w.a)({queryKey:[wn,qs,""],queryFn:M.N4,refetchInterval:zr,refetchIntervalInBackground:!1,staleTime:1e3,refetchOnWindowFocus:!1}).data,Rr=(0,u.useMemo)((function(){return(Pr||[]).map((function(e){var n,s=parseFloat(null===e||void 0===e?void 0:e.latitude),r=parseFloat(null===e||void 0===e?void 0:e.longitude);return Number.isFinite(s)&&Number.isFinite(r)?{id:String(null!==(n=e.userid)&&void 0!==n?n:""),userid:e.userid,username:e.username||"Rider #".concat(e.userid),status:String(e.status||"").toLowerCase(),contactno:e.contactno,orderid:e.orderid,logdate:e.logdate,lat:s,lon:r}:null})).filter(Boolean)}),[Pr]),Dr=(0,u.useMemo)((function(){return new Set(Rr.filter((function(e){return"active"===e.status})).map((function(e){return String(e.id)})))}),[Rr]),Lr=(0,u.useState)((function(){var e=S()();return le(e.hour()+e.minute()/60,ce)||ce[0].id})),Zr=(0,l.Z)(Lr,2),qr=Zr[0],Or=Zr[1];(0,u.useEffect)((function(){var e;"all"!==qr&&(Kn.some((function(e){return e.id===qr}))||Or((null===(e=Kn[0])||void 0===e?void 0:e.id)||"all"))}),[Kn,qr]);var Tr=(0,u.useRef)(null),Ir=!n,Hr="undefined"!==typeof window&&localStorage.getItem("userid")||0,Kr=(0,F.N)({queryKey:["dispatchDeliveries",wn,Hr,"all",qs,qs,50,"",0,0,0],queryFn:M.p7,getNextPageParam:function(e){var n;return null!==(n=e.nextPage)&&void 0!==n?n:void 0},enabled:Ir}),Br=Kr.data,Yr=Kr.isFetching,Gr=Kr.isError,Ur=Kr.fetchNextPage,Vr=Kr.hasNextPage,Wr=Kr.isFetchingNextPage;(0,u.useEffect)((function(){Ir&&Vr&&!Wr&&Ur()}),[Ir,Vr,Wr,Ur]);var Jr=(0,u.useMemo)((function(){var e,n=((null===Br||void 0===Br?void 0:Br.pages)||[]).flatMap((function(e){return e.rows||[]})),s=new Set,r=[],t=(0,d.Z)(n);try{for(t.s();!(e=t.n()).done;){var a=e.value,i=null!=a.orderid?String(a.orderid):null;i&&s.has(i)||(i&&s.add(i),r.push(a))}}catch(c){t.e(c)}finally{t.f()}return r}),[Br]),Qr=(0,u.useMemo)((function(){var e=new Map;return Jr.forEach((function(n){var s=String(n.userid||n.rider_id||"");s&&"unassigned"!==s&&"0"!==s&&(e.has(s)||e.set(s,{id:s,riderName:n.ridername||n.rider_name||n.username||"Rider ".concat(s)}))})),Array.from(e.values()).sort((function(e,n){return String(e.riderName).localeCompare(String(n.riderName))}))}),[Jr]),Xr=(0,u.useMemo)((function(){var e={all:Jr.length};return Kn.forEach((function(n){e[n.id]=0})),Jr.forEach((function(n){var s=ue(n,Rn,Kn);s&&(e[s]=(e[s]||0)+1)})),e}),[Jr,Rn,Kn]),$r=(0,u.useMemo)((function(){return"all"===qr?Jr:Jr.filter((function(e){return ue(e,Rn,Kn)===qr}))}),[Jr,qr,Rn,Kn]),et=(0,u.useMemo)((function(){if(!Ir)return null;if(!$r.length)return{code:200,zone_summary:[],zones:[]};var e=function(e){return String(e||"").trim()},n={};$r.forEach((function(s){var r=e(s.deliverysuburb)||e(s.locationsuburb)||e(s.zone_name)||"Unzoned",t=r.toLowerCase(),a=String(s.userid||s.rider_id||"unassigned"),i=s.ridername||s.rider_name||s.username||("unassigned"===a?"Unassigned":"Rider ".concat(a));n[t]||(n[t]={zone_name:r,riders:{}}),n[t].riders[a]||(n[t].riders[a]={rider_id:a,rider_name:i,orders:[]}),n[t].riders[a].orders.push(s)}));var s=Object.values(n).map((function(e){var n=Object.values(e.riders).map((function(e){var n=(0,t.Z)(e.orders).sort((function(e,n){return S()(e.deliverydate||e.assigntime||0).valueOf()-S()(n.deliverydate||n.assigntime||0).valueOf()}));return(0,o.Z)((0,o.Z)({},e),{},{orders:n.map((function(e,n){return(0,o.Z)((0,o.Z)({},e),{},{trip_number:e.trip_number||1,step:e.step||n+1})}))})}));return{zone_name:e.zone_name,riders:n}}));return{code:200,zone_summary:s.map((function(e){var n=e.riders.flatMap((function(e){return e.orders})),s=n.filter((function(e){return e.userid||e.rider_id})).length;return{zone_name:e.zone_name,total_orders:n.length,assigned_orders:s,unassigned_orders_count:n.length-s,active_riders_count:e.riders.filter((function(e){return"unassigned"!==e.rider_id})).length,total_delivery_kms:n.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),total_profit:n.reduce((function(e,n){return e+parseFloat(n.profit||0)}),0)}})),zones:s}}),[Ir,$r]),nt=(0,u.useMemo)((function(){var e=n||et||{zones:[],zone_summary:[]},s=e.zones||[],r={};(e.zone_summary||[]).forEach((function(e){r[e.zone_name]=e}));var t=function(e,n){var s={};return e.forEach((function(e){var r=n(e);r&&(s[r]=(s[r]||0)+1)})),Object.entries(s).map((function(e){var n=(0,l.Z)(e,2);return{name:n[0],count:n[1]}})).sort((function(e,n){return n.count-e.count}))};return s.map((function(e){var n,s,a,i,c=r[e.zone_name]||{},l=(e.riders||[]).flatMap((function(e){return e.orders||[]})),d=(e.riders||[]).filter((function(e){return e.rider_id&&"unassigned"!==e.rider_id})).length,o=t(l,(function(e){return e.deliverysuburb||e.locationsuburb})),u=t(l,(function(e){return e.pickupcustomer||e.kitchen_key})),m={};return l.forEach((function(e){var n=String(e.orderstatus||"unknown").toLowerCase();m[n]=(m[n]||0)+1})),{id:e.zone_name,name:e.zone_name,riders:e.riders||[],orders:l,totalOrders:null!==(n=c.total_orders)&&void 0!==n?n:l.length,activeRidersCount:null!==(s=c.active_riders_count)&&void 0!==s?s:d,totalKms:null!==(a=c.total_delivery_kms)&&void 0!==a?a:l.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),totalProfit:null!==(i=c.total_profit)&&void 0!==i?i:l.reduce((function(e,n){return e+parseFloat(n.profit||0)}),0),suburbs:o,kitchens:u,statusCounts:m}}))}),[n,et]),st=(0,u.useMemo)((function(){var e=[];((n||et||{zones:[],zone_summary:[]}).zones||[]).forEach((function(n){(n.riders||[]).forEach((function(s){s.orders.forEach((function(r){e.push((0,o.Z)((0,o.Z)({},r),{},{zone_name:n.zone_name,rider_name:s.rider_name,rider_id:s.rider_id}))}))}))}));var s={};e.forEach((function(e){var n=e.rider_id||e.userid||"unknown";s[n]||(s[n]={id:n,riderName:e.rider_name||e.username||e.rider||n,orders:[],color:Ne[Object.keys(s).length%Ne.length]}),s[n].orders.push(e)}));var r={};e.forEach((function(e){var n=e.pickupcustomer||e.kitchen_key||"Unknown",s=n.toLowerCase().trim();r[s]?!Number.isFinite(r[s].lat)&&ee(e)&&(r[s].lat=W(X(e)),r[s].lon=W($(e))):r[s]={id:s,kitchenName:n,lat:W(X(e)),lon:W($(e)),orders:[],riders:new Set},r[s].orders.push(e),e.rider_id&&r[s].riders.add(e.rider_id)}));var a=e.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),i=e.reduce((function(e,n){return e+parseFloat(n.profit||0)}),0);return{riders:Object.values(s).map((function(e){return(0,o.Z)((0,o.Z)({},e),{},{orders:(0,t.Z)(e.orders).sort((function(e,n){var s=e.trip_number||1,r=n.trip_number||1;return s!==r?s-r:(e.step||0)-(n.step||0)}))})})).sort((function(e,n){return n.orders.length-e.orders.length})),kitchens:Object.values(r).sort((function(e,n){return n.orders.length-e.orders.length})),allOrders:e,stats:{totalOrders:e.length,totalKms:a,totalProfit:i,totalRiders:Object.keys(s).length}}}),[n,et]),rt=st.riders,tt=st.kitchens,at=st.allOrders,it=st.stats,ct=xn?N&&rt.find((function(e){return e.id===N}))||null:Ke,lt="all"===O,dt=(0,u.useMemo)((function(){if(!lt)return[];var e=new Set(rt.map((function(e){return String(e.id)})));return Rr.filter((function(n){return"active"===n.status&&!e.has(String(n.id))})).map((function(e){return{id:e.id,riderName:e.username||"Rider #".concat(e.id),orders:[],color:be(e.id),gpsOnly:!0,lat:e.lat,lon:e.lon}}))}),[lt,Rr,rt]),ot=(0,u.useMemo)((function(){return lt?[].concat((0,t.Z)(rt.filter((function(e){return Dr.has(String(e.id))}))),(0,t.Z)(dt)):rt}),[lt,rt,Dr,dt]),ut=(0,u.useMemo)((function(){return lt?at.filter((function(e){return Dr.has(String(e.rider_id))})):at}),[lt,at,Dr]),mt=(0,u.useMemo)((function(){return lt?Rr.filter((function(e){return"active"===e.status})).map((function(e){return[e.lat,e.lon]})):[]}),[lt,Rr]),pt=(0,u.useCallback)((function(e){y&&y(e?e.id:null),xn||Be(e),sn(null)}),[xn,y]),ht=(0,u.useRef)(null);(0,u.useEffect)((function(){var e=ct?ct.id:null;e!==ht.current&&(ct?Y.info("Focused rider changed to: ".concat(ct.riderName," (").concat(ct.orders.length," orders)")):Y.info("Focused rider reset to: None"),ht.current=e)}),[ct]),(0,u.useEffect)((function(){nn?Y.info("Focused order updated: ID ".concat(nn.orderid)):Y.debug("Focused order selection cleared")}),[nn]);var vt=(0,u.useRef)(0);(0,u.useEffect)((function(){at&&at.length!==vt.current&&(Y.info("Orders database updated: ".concat(at.length," orders actively tracked")),vt.current=at.length)}),[at]);var ft=(0,u.useRef)(0);(0,u.useEffect)((function(){Rr&&Rr.length!==ft.current&&(Y.info("Live riders list updated: ".concat(Rr.length," active riders mapped")),ft.current=Rr.length)}),[Rr]);var xt=(0,u.useMemo)((function(){return ct?{orders:ct.orders.length,riders:1,km:ct.orders.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),profit:ct.orders.reduce((function(e,n){return e+parseFloat(n.profit||0)}),0),label:"Focused Rider"}:Ue?{orders:Ue.orders.length,riders:Ue.riders.size,km:Ue.orders.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),profit:Ue.orders.reduce((function(e,n){return e+parseFloat(n.profit||0)}),0),label:"Focused Kitchen"}:lt?{orders:ut.length,riders:ot.length,km:ut.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0),profit:ut.reduce((function(e,n){return e+parseFloat(n.profit||0)}),0),label:"Active Fleet"}:{orders:it.totalOrders,riders:it.totalRiders,km:it.totalKms,profit:it.totalProfit,label:"Total Fleet"}}),[ct,Ue,lt,ut,ot,it]),jt=(0,u.useMemo)((function(){return lt?ut.filter(z.Y_).length:0}),[lt,ut]),gt=(0,u.useMemo)((function(){var e;e=ct?ct.orders:Ue?Ue.orders:Qe?Qe.orders:at;var n=new Set;return(e||[]).forEach((function(e){null!=e.deliveryid&&""!==e.deliveryid&&0!==e.deliveryid&&n.add(String(e.deliveryid))})),Array.from(n)}),[at,ct,Ue,Qe]),Nt=(0,A.h)({queries:gt.map((function(e){return{queryKey:["deliveryLogs",e],queryFn:function(){var n=(0,i.Z)((0,a.Z)().mark((function n(){var s,t,i,c,l,d,o;return(0,a.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,C.Z.get("".concat({NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_API_URL:"https://mock-data-api-nextjs.vercel.app/",REACT_APP_AUTH0_CLIENT_ID:"",REACT_APP_AUTH0_DOMAIN:"",REACT_APP_AWS_APP_CLIENT_ID:"",REACT_APP_AWS_POOL_ID:"",REACT_APP_FIREBASE_API_KEY:"",REACT_APP_FIREBASE_APP_ID:"",REACT_APP_FIREBASE_AUTH_DOMAIN:"",REACT_APP_FIREBASE_MEASUREMENT_ID:"",REACT_APP_FIREBASE_MESSAGING_SENDER_ID:"",REACT_APP_FIREBASE_PROJECT_ID:"",REACT_APP_FIREBASE_STORAGE_BUCKET:"",REACT_APP_GOOGLE_MAPS_API_KEY:"AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8",REACT_APP_RIDER_ACCESS_ID:"AAAAILMpCEU:APA91bEavuOllBI6sFgYtxXAgNmAVwNA-MnCMHLGlR4_t7UqpLajAkdn3T0CZr_zaLBknLyim9ytFLMZgbeXmKqTad_PKCbqlYjHpaizVrLXtecxqyEy4UktIacK2UvHVUATHL-7VQQk",REACT_APP_STAFF_TOKEN:"",REACT_APP_URL:"https://jupiter.nearle.app/live/api/v1",REACT_APP_URL2:"https://jupiter.nearle.app/live/api/v2",REACT_APP_VERSION:"v2.1.0"}.REACT_APP_URL3,"/deliveries/getdeliverylogs/?deliveryid=").concat(e));case 2:return i=n.sent,c=[null===i||void 0===i||null===(s=i.data)||void 0===s?void 0:s.details,null===i||void 0===i||null===(t=i.data)||void 0===t?void 0:t.data,null===i||void 0===i?void 0:i.data,i],l=c.find((function(e){return Array.isArray(e)}))||[],d=l.map((function(e){var n,s,r,t=null!==e&&void 0!==e&&e.logdate?S()(e.logdate):null;return{lat:parseFloat(null!==(n=null===e||void 0===e?void 0:e.latitude)&&void 0!==n?n:null===e||void 0===e?void 0:e.lat),lng:parseFloat(null!==(s=null!==(r=null===e||void 0===e?void 0:e.longitude)&&void 0!==r?r:null===e||void 0===e?void 0:e.lng)&&void 0!==s?s:null===e||void 0===e?void 0:e.lon),logdate:null===e||void 0===e?void 0:e.logdate,_ts:t&&t.isValid()?t.valueOf():Number.MAX_SAFE_INTEGER}})).filter((function(e){return Number.isFinite(e.lat)&&Number.isFinite(e.lng)})).sort((function(e,n){return e._ts-n._ts})),o=ve(d),n.abrupt("return",o.map((function(e){e._ts;return(0,r.Z)(e,G)})));case 8:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}(),enabled:!0,staleTime:3e5,refetchOnWindowFocus:!1,retry:1}}))}),bt=(0,u.useMemo)((function(){var e=new Map;return gt.forEach((function(n,s){var r=Nt[s];e.set(n,{coords:(null===r||void 0===r?void 0:r.data)||[],isLoading:!!(null!==r&&void 0!==r&&r.isLoading||null!==r&&void 0!==r&&r.isFetching),isError:!(null===r||void 0===r||!r.isError)})})),e}),[gt,Nt]),yt=(0,u.useMemo)((function(){if(!ct)return[];var e=function(e){var n=e.deliverytime||e.expecteddeliverytime;if(!n)return Number.MAX_SAFE_INTEGER;var s=S()(n);return s.isValid()?s.valueOf():Number.MAX_SAFE_INTEGER};return ct.orders.filter((function(e){return null!=e.deliveryid&&""!==e.deliveryid&&0!==e.deliveryid})).sort((function(n,s){var r=e(n)-e(s);return 0!==r?r:(n.step||0)-(s.step||0)})).map((function(e,n){var s=bt.get(String(e.deliveryid));return{sequenceStep:n+1,orderid:e.orderid,deliveryid:e.deliveryid,deliverycustomer:e.deliverycustomer,pickupcustomer:e.pickupcustomer,step:e.step,tripNumber:e.trip_number||1,deliverytime:e.deliverytime||e.expecteddeliverytime,kms:parseFloat(e.actualkms||e.kms||0)||0,profit:parseFloat(e.profit||0)||0,orderstatus:e.orderstatus,isLoading:!(null===s||void 0===s||!s.isLoading),isError:!(null===s||void 0===s||!s.isError),coords:(null===s||void 0===s?void 0:s.coords)||[]}}))}),[ct,bt]),kt=(0,u.useMemo)((function(){return ct?yt.map((function(e){var n=ct.orders.find((function(n){return String(n.deliveryid)===String(e.deliveryid)})),s=parseFloat((null===n||void 0===n?void 0:n.kms)||0)||0,r=Ns[e.deliveryid],t=0;Array.isArray(r)&&r.length>=2?t=he(r):null!=(null===n||void 0===n?void 0:n.actualkms)&&""!==n.actualkms?t=parseFloat(n.actualkms)||0:e.coords.length>=2&&(t=he(e.coords.map((function(e){return[e.lat,e.lng]}))));var a=t-s,i=s>0?a/s*100:null,c=null!==n&&void 0!==n&&n.expecteddeliverytime?S()(n.expecteddeliverytime):null,l=null!==n&&void 0!==n&&n.deliverytime?S()(n.deliverytime):null,d=null!==c&&void 0!==c&&c.isValid()&&null!==l&&void 0!==l&&l.isValid()?l.diff(c,"minute"):null,o=s>0&&t>1.25*s||null!=d&&d>15;return{sequenceStep:e.sequenceStep,deliveryid:e.deliveryid,orderid:e.orderid,order:n,plannedKm:s,actualKm:t,kmDelta:a,kmDeltaPct:i,expectedTs:null!==c&&void 0!==c&&c.isValid()?c:null,actualTs:null!==l&&void 0!==l&&l.isValid()?l:null,timeDeltaMin:d,anomaly:o,orderstatus:e.orderstatus,deliverycustomer:e.deliverycustomer,pickupcustomer:null===n||void 0===n?void 0:n.pickupcustomer,isLoading:e.isLoading,coordsCount:e.coords.length}})):[]}),[yt,ct,Ns]),St=(0,u.useMemo)((function(){if(0===kt.length)return{plannedKm:0,actualKm:0,kmDeltaPct:null,anomalies:0,late:0,onTime:0};var e=kt.filter((function(e){return!e.isLoading&&e.coordsCount>0})),n=e.reduce((function(e,n){return e+n.plannedKm}),0),s=e.reduce((function(e,n){return e+n.actualKm}),0);return{plannedKm:n,actualKm:s,kmDeltaPct:n>0?(s-n)/n*100:null,anomalies:e.filter((function(e){return e.anomaly})).length,late:e.filter((function(e){return null!=e.timeDeltaMin&&e.timeDeltaMin>5})).length,onTime:e.filter((function(e){return null!=e.timeDeltaMin&&e.timeDeltaMin<=5})).length}}),[kt]),_t=(0,u.useMemo)((function(){return(0,t.Z)(kt).sort((function(e,n){var s,r;return((null===(s=e.order)||void 0===s?void 0:s.step)||e.sequenceStep)-((null===(r=n.order)||void 0===r?void 0:r.step)||n.sequenceStep)}))}),[kt]),wt=(0,u.useMemo)((function(){return(0,t.Z)(kt).sort((function(e,n){return e.sequenceStep-n.sequenceStep}))}),[kt]),Ft=(0,u.useMemo)((function(){if(!Qs||!Ar||!ct)return null;var e=yt.find((function(e){return e.sequenceStep===Ar}));if(!e)return null;var n=ct.orders.find((function(n){return String(n.deliveryid)===String(e.deliveryid)}));return n?{orders:[n],id:"cmp-step-".concat(Ar,"-").concat(n.orderid)}:null}),[Qs,Ar,ct,yt]);(0,u.useEffect)((function(){Cr(null),hr(new Set),sr("combined")}),[Qs,null===ct||void 0===ct?void 0:ct.id]),(0,u.useEffect)((function(){!ct&&Qs&&Xs(!1)}),[ct,Qs]),(0,u.useEffect)((function(){vr.current&&ct&&(vr.current=!1,Xs(!0))}),[ct]),(0,u.useEffect)((function(){Qs&&!br.current?(Nr.current=jr,gr(!0),_r(!1)):!Qs&&br.current&&gr(Nr.current),br.current=Qs}),[Qs]);var At=(0,u.useCallback)(function(){var e=(0,i.Z)((0,a.Z)().mark((function e(n,s,r){var t,i,l,d,u,m;return(0,a.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t="".concat(n,"-").concat(s),void 0===xs.current[t]){e.next=3;break}return e.abrupt("return");case 3:if(!(r.length<2)){e.next=5;break}return e.abrupt("return");case 5:return xs.current[t]=null,fs((function(e){return(0,o.Z)((0,o.Z)({},e),{},(0,c.Z)({},t,null))})),i=r.map((function(e){return"".concat(e[1],",").concat(e[0])})).join(";"),l="https://router.project-osrm.org/route/v1/driving/".concat(i,"?overview=full&geometries=geojson"),e.prev=9,e.next=12,fetch(l);case 12:return d=e.sent,e.next=15,d.json();case 15:(u=e.sent).routes&&u.routes[0]?(m=u.routes[0].geometry.coordinates.map((function(e){return[e[1],e[0]]})),xs.current[t]=m,fs((function(e){return(0,o.Z)((0,o.Z)({},e),{},(0,c.Z)({},t,m))}))):(xs.current[t]=!1,fs((function(e){return(0,o.Z)((0,o.Z)({},e),{},(0,c.Z)({},t,!1))}))),e.next=24;break;case 19:e.prev=19,e.t0=e.catch(9),console.error("OSRM Fetch error:",e.t0),xs.current[t]=!1,fs((function(e){return(0,o.Z)((0,o.Z)({},e),{},(0,c.Z)({},t,!1))}));case 24:case"end":return e.stop()}}),e,null,[[9,19]])})));return function(n,s,r){return e.apply(this,arguments)}}(),[]);(0,u.useEffect)((function(){xs.current={},fs({}),ys.current={},bs({})}),[qs,qr]);var Ct=(0,u.useCallback)(function(){var e=(0,i.Z)((0,a.Z)().mark((function e(n,s){var r,t,i,l,d,u,m,p,h,v,f,x,j,g,N;return(0,a.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===ys.current[n]){e.next=2;break}return e.abrupt("return");case 2:if(Array.isArray(s)&&!(s.length<2)){e.next=4;break}return e.abrupt("return");case 4:return ys.current[n]=null,bs((function(e){return(0,o.Z)((0,o.Z)({},e),{},(0,c.Z)({},n,null))})),r=function(e){ys.current[n]=e,bs((function(s){return(0,o.Z)((0,o.Z)({},s),{},(0,c.Z)({},n,e))}))},t=function(){ys.current[n]=!1,bs((function(e){return(0,o.Z)((0,o.Z)({},e),{},(0,c.Z)({},n,!1))}))},i=function(e,n){if(e.length<=n)return e;var s=Math.ceil(e.length/n),r=e.filter((function(e,n){return n%s===0})),t=e[e.length-1];return r[r.length-1]!==t&&r.push(t),r},e.prev=9,l=i(s,90),d=l.map((function(e){return"".concat(e[1],",").concat(e[0])})).join(";"),u="https://router.project-osrm.org/match/v1/driving/".concat(d,"?overview=full&geometries=geojson&gaps=ignore&tidy=true"),e.next=15,fetch(u);case 15:return m=e.sent,e.next=18,m.json();case 18:if(!((p=e.sent).matchings&&p.matchings.length>0)){e.next=24;break}if(!((h=p.matchings.flatMap((function(e){var n;return((null===(n=e.geometry)||void 0===n?void 0:n.coordinates)||[]).map((function(e){return[e[1],e[0]]}))}))).length>=2)){e.next=24;break}return r(h),e.abrupt("return");case 24:e.next=29;break;case 26:e.prev=26,e.t0=e.catch(9),console.warn("OSRM Match error, trying route fallback:",e.t0);case 29:return e.prev=29,v=i(s,25),f=v.map((function(e){return"".concat(e[1],",").concat(e[0])})).join(";"),x="https://router.project-osrm.org/route/v1/driving/".concat(f,"?overview=full&geometries=geojson"),e.next=35,fetch(x);case 35:return j=e.sent,e.next=38,j.json();case 38:if(!(g=e.sent).routes||!g.routes[0]){e.next=44;break}if(!((N=g.routes[0].geometry.coordinates.map((function(e){return[e[1],e[0]]}))).length>=2)){e.next=44;break}return r(N),e.abrupt("return");case 44:t(),e.next=51;break;case 47:e.prev=47,e.t1=e.catch(29),console.error("OSRM Route fallback error:",e.t1),t();case 51:case"end":return e.stop()}}),e,null,[[9,26],[29,47]])})));return function(n,s){return e.apply(this,arguments)}}(),[]);(0,u.useEffect)((function(){bt.forEach((function(e,n){if(n&&e&&!(e.coords.length<2)){var s=e.coords.map((function(e){return[e.lat,e.lng]}));Ct(n,s)}}))}),[bt,Ct]),(0,u.useEffect)((function(){Ds.current=_s}),[_s]),(0,u.useEffect)((function(){if(!m){var e=function(){var e=new Date;bn([e.getHours(),e.getMinutes(),e.getSeconds()].map((function(e){return String(e).padStart(2,"0")})).join(":"))},n=setInterval(e,1e3);return e(),function(){return clearInterval(n)}}}),[m]),(0,u.useEffect)((function(){Te(new Set(rt.map((function(e){return e.id}))))}),[rt]),(0,u.useEffect)((function(){rt.forEach((function(e){if(Oe.has(e.id)&&(!ct||ct.id===e.id)){var n={};e.orders.forEach((function(e){var s=e.trip_number||1;n[s]||(n[s]=[]),n[s].push(e)})),Object.entries(n).forEach((function(n){var s=(0,l.Z)(n,2),r=s[0],a=s[1],i=(0,t.Z)(a).sort((function(e,n){return(e.step||0)-(n.step||0)})),c=ge(i);c.length>=2&&At(e.id,r,c)}))}}))}),[rt,Oe,ct,At]);var Et=(0,u.useRef)(null);(0,u.useEffect)((function(){if(Ir){var e=function(){var e=S()();return e.hour()+e.minute()/60};null===Et.current&&(Et.current=e());var n=setInterval((function(){var n=e(),s=le(Et.current,Kn),r=le(n,Kn);Et.current=n,r&&r!==s&&Or((function(e){return e===s?r:e}))}),3e4);return function(){return clearInterval(n)}}}),[Ir,Kn]),(0,u.useEffect)((function(){sn(null)}),[null===Ue||void 0===Ue?void 0:Ue.id]),(0,u.useEffect)((function(){var e=Tr.current;e&&"function"===typeof e.scrollIntoView&&e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})}),[qr]),(0,u.useEffect)((function(){if(nn){var e=setTimeout((function(){var e,n=null===at||void 0===at||null===(e=at.find)||void 0===e?void 0:e.call(at,(function(e){return String(e.orderid)===String(nn.orderid)}));n&&fn(n)}),350);return function(){return clearTimeout(e)}}}),[nn,at]);var Mt=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return b().divIcon({className:"",iconSize:n?[56,56]:[46,46],iconAnchor:n?[28,28]:[23,23],popupAnchor:[0,n?-30:-24],html:'<div class="kitchen-mark'.concat(n?" is-focused":"",'">').concat((e||"K").charAt(0).toUpperCase(),"</div>")})},zt=function(e){var n;return(null===(n=rt.find((function(n){return n.id===e})))||void 0===n?void 0:n.color)||"#475569"},Pt=function(e,n){if(!e||!n||!Q(n))return null;var s=Rr.find((function(n){return String(n.id)===String(e)}));if(!s)return null;var r=W(n.droplat||n.deliverylat),t=W(n.droplon||n.deliverylong);if(!Number.isFinite(r)||!Number.isFinite(t))return null;var a=pe([s.lat,s.lon],[r,t]);return Math.round(1e3*a)},Rt=function(e){return null===e||void 0===e?"":e>=1e3?"".concat((e/1e3).toFixed(1)," km"):"".concat(e," m")},Dt=function(e,n){var s=e.rider_id,r=rt.find((function(e){return String(e.id)===String(s)})),t=zt(s),a=(0,z.Cl)(e.orderstatus),i=parseFloat(e.droplat||e.deliverylat),c=parseFloat(e.droplon||e.deliverylong),l=Number.isFinite(i)&&Number.isFinite(c),d=Pt(s,e),o=e.deliverycustomer||e.customername||"Order #".concat(e.orderid),u=e.deliverysuburb||e.deliveryaddress||e.zone_name||"";return(0,P.jsxs)("div",{className:"rcard active-delivery-card",onClick:function(){r&&pt(r),l&&sn({orderid:e.orderid,lat:i,lon:c})},style:{animationDelay:"".concat(.05*n,"s")},children:[(0,P.jsxs)("div",{className:"rcard-top",children:[(0,P.jsx)("div",{className:"rcard-emo",style:{background:"".concat(t,"18"),borderColor:"".concat(t,"50"),color:t},children:(0,P.jsx)(E.$0r,{})}),(0,P.jsxs)("div",{className:"rcard-info",children:[(0,P.jsx)("div",{className:"rcard-name",title:o,children:o}),(0,P.jsxs)("div",{className:"rcard-zone",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.pbk,{})}),e.rider_name||e.ridername||"Unassigned",u?" \xb7 ".concat(u):""]})]}),(0,P.jsx)("div",{className:"rcard-badge",style:{background:a.bg,color:a.fg},title:a.label,children:a.label})]}),(0,P.jsxs)("div",{className:"rcard-meta",children:[e.pickupcustomer&&(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.TkG,{})}),e.pickupcustomer]}),(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),parseFloat(e.actualkms||e.kms||0).toFixed(1)," km"]}),null!==d&&(0,P.jsxs)("span",{className:"rcard-est-meters",title:"Estimated distance to drop location",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.x$F,{})}),Rt(d)," to drop"]})]})]},e.orderid)};return(0,P.jsxs)("div",{className:"dispatch-container".concat(m?" embedded":"").concat(Qs?" compare-open":""),children:[!m&&(0,P.jsxs)("div",{id:"hdr",children:[(0,P.jsxs)("div",{className:"logo",children:[(0,P.jsx)("div",{className:"logo-badge",children:"D"}),(0,P.jsx)("div",{className:"logo-name",children:"Dispatch"})]}),(0,P.jsx)("div",{className:"hdr-stats",children:Ir&&(0,P.jsxs)(P.Fragment,{children:[Yr&&(0,P.jsxs)("span",{className:"live-status",children:[(0,P.jsx)("span",{className:"live-dot"})," Loading ",Jr.length?"\xb7 ".concat(Jr.length," loaded"):""]}),!Yr&&!Gr&&(0,P.jsxs)("span",{className:"live-status live-status-ready",children:[(0,P.jsx)("span",{className:"live-dot ready"})," ",$r.length," orders",(0,P.jsxs)("span",{className:"live-status-sub",children:[" / ",Jr.length," total"]})]}),Gr&&(0,P.jsxs)("span",{className:"live-status live-status-error",children:[(0,P.jsx)("span",{className:"live-dot error"})," Failed to load"]}),function(){var e=S()().startOf("day"),n=e.format("YYYY-MM-DD"),s=S()(qs),r=qs===n,t=s.isAfter(e,"day"),a=function(n){if(n){var s=n.format("YYYY-MM-DD");s!==qs?n.isAfter(e,"day")||(Os(s),pt(null),Ve(null),Xe(null),Ks(!1)):Ks(!1)}},i=Gs.startOf("month"),c=i.subtract(i.day(),"day"),l=Array.from({length:42},(function(e,n){return c.add(n,"day")})),d=!Gs.add(1,"month").startOf("month").isAfter(e,"month");return(0,P.jsxs)("div",{className:"date-chip".concat(r?" is-today":"").concat(Hs?" is-open":""),ref:Vs,children:[(0,P.jsx)("button",{type:"button",className:"date-chip-nav",onClick:function(){return a(s.subtract(1,"day"))},"aria-label":"Previous day",title:"Previous day",children:(0,P.jsx)(E.G1X,{})}),(0,P.jsxs)("button",{type:"button",className:"date-chip-main",onClick:function(){return Ks((function(e){return!e}))},"aria-haspopup":"dialog","aria-expanded":Hs,children:[(0,P.jsx)("span",{className:"date-chip-icon","aria-hidden":"true",children:(0,P.jsx)(E.kVv,{})}),(0,P.jsxs)("span",{className:"date-chip-text",children:[(0,P.jsxs)("span",{className:"date-chip-label",children:["Date",r&&(0,P.jsx)("span",{className:"date-chip-today-pill",children:"Today"})]}),(0,P.jsx)("span",{className:"date-chip-value",children:s.isValid()?s.format("ddd, MMM D, YYYY"):"\u2014"})]}),(0,P.jsx)("span",{className:"date-chip-chevron".concat(Hs?" is-open":""),"aria-hidden":"true",children:(0,P.jsx)(E.Yc6,{})})]}),(0,P.jsx)("button",{type:"button",className:"date-chip-nav",onClick:function(){r||t||a(s.add(1,"day"))},disabled:r||t,"aria-label":"Next day",title:r?"You're viewing today":"Next day",children:(0,P.jsx)(E.FNi,{})}),Hs&&(0,P.jsxs)("div",{className:"date-cal-popover",role:"dialog","aria-label":"Pick a date",children:[(0,P.jsxs)("div",{className:"date-cal-header",children:[(0,P.jsx)("button",{type:"button",className:"date-cal-nav",onClick:function(){return Us((function(e){return e.subtract(1,"month")}))},"aria-label":"Previous month",children:(0,P.jsx)(E.G1X,{})}),(0,P.jsx)("div",{className:"date-cal-title",children:Gs.format("MMMM YYYY")}),(0,P.jsx)("button",{type:"button",className:"date-cal-nav",onClick:function(){var n=Gs.add(1,"month");n.startOf("month").isAfter(e,"month")||Us(n)},disabled:!d,"aria-label":"Next month",children:(0,P.jsx)(E.FNi,{})})]}),(0,P.jsx)("div",{className:"date-cal-weekdays",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map((function(e){return(0,P.jsx)("div",{className:"date-cal-weekday",children:e},e)}))}),(0,P.jsx)("div",{className:"date-cal-grid",children:l.map((function(s){var r=s.month()===Gs.month(),t=s.format("YYYY-MM-DD")===qs,i=s.format("YYYY-MM-DD")===n,c=s.isAfter(e,"day"),l=["date-cal-day",!r&&"is-other-month",t&&"is-selected",i&&"is-today",c&&"is-disabled"].filter(Boolean).join(" ");return(0,P.jsx)("button",{type:"button",className:l,disabled:c,onClick:function(){return a(s)},"aria-current":i?"date":void 0,"aria-pressed":t,children:s.date()},s.format("YYYY-MM-DD"))}))}),(0,P.jsxs)("div",{className:"date-cal-presets",children:[(0,P.jsx)("button",{type:"button",className:"date-cal-preset",onClick:function(){return a(e)},children:"Today"}),(0,P.jsx)("button",{type:"button",className:"date-cal-preset",onClick:function(){return a(e.subtract(1,"day"))},children:"Yesterday"}),(0,P.jsx)("button",{type:"button",className:"date-cal-preset",onClick:function(){return a(e.subtract(7,"day"))},children:"\u22127 days"})]})]})]})}()]})}),(0,P.jsx)("div",{id:"clock",children:Nn})]}),(m||"live"===K)&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{id:"strat-row",children:[(0,P.jsxs)("button",{className:"sbt ".concat("kitchens"===O?"active":""),onClick:function(){Y.info("View mode changed: By Location"),T("kitchens"),pt(null),Ve(null),Xe(null)},children:[(0,P.jsx)("span",{className:"sbt-icon",children:(0,P.jsx)(E.c7Z,{})})," By Location"]}),(0,P.jsxs)("button",{className:"sbt ".concat("zones"===O?"active":""),onClick:function(){Y.info("View mode changed: By Zone"),T("zones"),pt(null),Ve(null),Xe(null)},children:[(0,P.jsx)("span",{className:"sbt-icon",children:(0,P.jsx)(E.PKO,{})})," By Zone"]}),(0,P.jsxs)("button",{className:"sbt ".concat("riders"===O?"active":""),onClick:function(){Y.info("View mode changed: By Rider"),T("riders"),pt(null),Ve(null),Xe(null)},children:[(0,P.jsx)("span",{className:"sbt-icon",children:(0,P.jsx)(E.MCF,{})})," By Rider"]}),(0,P.jsxs)("button",{className:"sbt ".concat("all"===O?"active":""),onClick:function(){Y.info("View mode changed: All Active Routes"),T("all"),pt(null),Ve(null),Xe(null)},children:[(0,P.jsx)("span",{className:"sbt-icon",children:(0,P.jsx)(E.zNX,{})}),"Active"]}),(0,P.jsxs)("button",{type:"button",className:"sbt sbt-rider-info ".concat("rider-info"===O?"active":""),onClick:function(){T("rider-info"),pt(null),Ve(null),Xe(null)},title:"Live GPS / battery / status snapshot for a rider",children:[(0,P.jsx)("span",{className:"sbt-icon",children:(0,P.jsx)(E.eJU,{})})," Rider Info"]})]}),Ir&&"rider-info"!==O&&(0,P.jsxs)("div",{id:"batch-row",children:[(0,P.jsx)("span",{className:"batch-label",children:"Batch"}),(0,P.jsx)("div",{className:"batch-scroll",children:Kn.map((function(e){var n,s=qr===e.id;return(0,P.jsxs)("button",{ref:s?Tr:null,className:"batch-btn batch-slot ".concat(s?"active":""),onClick:function(){Or(e.id),pt(null),Ve(null),Xe(null)},title:"".concat(e.label," (").concat(e.range,")"),children:[(0,P.jsx)("span",{className:"batch-btn-label",children:e.label}),(0,P.jsx)("span",{className:"batch-btn-count",children:null!==(n=Xr[e.id])&&void 0!==n?n:0})]},e.id)}))})]}),"rider-info"===O?(0,P.jsxs)("div",{className:"rider-info-mode",children:[(0,P.jsxs)("div",{className:"ri-sidebar",children:[(0,P.jsxs)("div",{className:"ri-sb-head",children:[(0,P.jsx)("div",{className:"ri-sb-title",children:"Riders"}),(0,P.jsxs)("div",{className:"ri-sb-sub",children:[Qr.length," ",1===Qr.length?"rider":"riders"," today"]})]}),(0,P.jsxs)("div",{className:"ri-search",children:[(0,P.jsx)(E.vU7,{className:"ri-search-icon"}),(0,P.jsx)("input",{type:"text",className:"ri-search-input",placeholder:"Search by name or ID",value:ss,onChange:function(e){return rs(e.target.value)}})]}),function(){var e=ss.trim().toLowerCase(),n=Qr.filter((function(n){return!e||(String(n.riderName||"").toLowerCase().includes(e)||String(n.id).includes(e))}));return 0===n.length?(0,P.jsx)("div",{className:"ri-empty",children:ss?'No riders match "'.concat(ss,'"'):"No riders have orders today"}):(0,P.jsx)("div",{className:"ri-rider-list",children:n.map((function(e){var n=String(Xn)===String(e.id);return(0,P.jsxs)("button",{type:"button",className:"ri-rider-item ".concat(n?"active":""),onClick:function(){return $n(e.id)},children:[(0,P.jsx)("span",{className:"ri-rider-dot",style:{background:be(e.id)}}),(0,P.jsxs)("span",{className:"ri-rider-info-block",children:[(0,P.jsx)("span",{className:"ri-rider-name",children:e.riderName}),(0,P.jsxs)("span",{className:"ri-rider-meta",children:["#",e.id]})]}),(0,P.jsx)("span",{className:"ri-rider-arrow",children:"\u2192"})]},e.id)}))})}()]}),(0,P.jsx)("div",{className:"ri-main",children:null==Xn?(0,P.jsxs)("div",{className:"ri-placeholder",children:[(0,P.jsx)("div",{className:"ri-placeholder-icon",children:(0,P.jsx)(E.eJU,{})}),(0,P.jsx)("div",{className:"ri-placeholder-title",children:"Pick a rider"}),(0,P.jsx)("div",{className:"ri-placeholder-sub",children:"Select a rider from the list on the left to see their live GPS, battery, connection, and current order snapshot."})]}):(0,P.jsxs)(P.Fragment,{children:[is&&!as&&(0,P.jsx)("div",{className:"ri-loading",children:"Loading rider snapshot\u2026"}),cs&&(0,P.jsxs)("div",{className:"ri-error",children:["Couldn't load this rider's log. ",(null===ls||void 0===ls?void 0:ls.message)||""]}),as&&function(){var e=as,n=parseFloat(e.latitude),s=parseFloat(e.longitude),r=Number.isFinite(n)&&Number.isFinite(s),t=parseInt(String(e.battery||"").replace("%",""),10),a=Number.isFinite(t)&&t<=20,i=parseFloat(e.speed),c=String(e.status||"").toLowerCase();return(0,P.jsxs)("div",{className:"ri-snapshot",children:[(0,P.jsxs)("div",{className:"ri-snap-head",children:[(0,P.jsx)("div",{className:"ri-snap-name",children:e.username||"Rider #".concat(e.userid)}),(0,P.jsxs)("div",{className:"ri-snap-meta",children:[(0,P.jsxs)("span",{children:["#",e.userid]}),e.status&&(0,P.jsx)("span",{className:"ri-status ri-status-".concat(c),children:e.status}),(0,P.jsxs)("span",{className:"ri-live ".concat(is?"is-refetching":""),children:[(0,P.jsx)("span",{className:"ri-live-dot"}),is?"Updating\u2026":"Live"]})]}),e.logdate&&(0,P.jsxs)("div",{className:"ri-snap-time",children:[(0,P.jsx)(E.dKE,{})," Last seen ",e.logdate]})]}),(0,P.jsxs)("div",{className:"ri-snap-grid",children:[(0,P.jsxs)("div",{className:"ri-stat ".concat(a?"ri-stat-warn":""),children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.f9F,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"Battery"}),(0,P.jsxs)("div",{className:"ri-stat-value",children:[e.battery||"\u2014",e.is_charging&&(0,P.jsx)("span",{className:"ri-stat-tag",children:"Charging"})]})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.YPA,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"Connection"}),(0,P.jsx)("div",{className:"ri-stat-value",children:e.connection||"\u2014"})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.x$F,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"GPS Accuracy"}),(0,P.jsx)("div",{className:"ri-stat-value",children:e.accuracy?"".concat(e.accuracy," m"):"\u2014"})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.A_X,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"Location Service"}),(0,P.jsx)("div",{className:"ri-stat-value",children:e.location_service||"\u2014"})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.JKp,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"Speed"}),(0,P.jsx)("div",{className:"ri-stat-value",children:Number.isFinite(i)?"".concat(i.toFixed(2)," km/h"):"\u2014"})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.DTb,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"Heading"}),(0,P.jsx)("div",{className:"ri-stat-value",children:null!=e.heading?"".concat(e.heading,"\xb0"):"\u2014"})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.NUu,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"App State"}),(0,P.jsx)("div",{className:"ri-stat-value",children:e.is_background?"Background":"Foreground"})]})]}),(0,P.jsxs)("div",{className:"ri-stat",children:[(0,P.jsx)("div",{className:"ri-stat-icon",children:(0,P.jsx)(E.ByW,{})}),(0,P.jsxs)("div",{className:"ri-stat-body",children:[(0,P.jsx)("div",{className:"ri-stat-label",children:"Current Order"}),(0,P.jsx)("div",{className:"ri-stat-value",children:e.orderid||"\u2014"})]})]})]}),r&&(0,P.jsxs)("div",{className:"ri-map-section",children:[(0,P.jsxs)("div",{className:"ri-coords-label",children:[(0,P.jsx)(E.$0r,{})," ",n.toFixed(6),", ",s.toFixed(6)]}),(0,P.jsx)("div",{className:"ri-map",children:(0,P.jsxs)(v.h,{center:[n,s],zoom:13,scrollWheelZoom:!1,style:{height:"100%",width:"100%"},children:[(0,P.jsx)(f.I,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\xa9 OpenStreetMap contributors"}),(0,P.jsxs)(p.J,{position:[n,s],children:[(0,P.jsx)(x.u,{direction:"top",offset:[0,-10],permanent:!0,className:"ri-area-banner",children:(null===us||void 0===us?void 0:us.area)||"Locating area\u2026"}),(0,P.jsxs)(j.G,{children:[(0,P.jsx)("div",{style:{fontWeight:700,marginBottom:2},children:e.username||"Rider #".concat(e.userid)}),(null===us||void 0===us?void 0:us.area)&&(0,P.jsx)("div",{style:{fontSize:12,color:"#0f172a",marginBottom:4},children:us.area}),(0,P.jsx)("div",{style:{fontSize:11,color:"#64748b"},children:e.logdate?"Last seen ".concat(e.logdate):"".concat(n.toFixed(6),", ").concat(s.toFixed(6))})]})]})]},"".concat(e.userid,"-").concat(n,"-").concat(s))})]})]})}()]})})]}):(0,P.jsxs)("div",{id:"body",className:"".concat(jr?"sidebar-collapsed":""," ").concat(Qs?"compare-mode":""," ").concat(Qs&&Sr?"compare-data-collapsed":"").trim(),children:[(0,P.jsx)("button",{type:"button",className:"sidebar-toggle-tab".concat(jr?" is-collapsed":""),onClick:function(){return gr((function(e){return!e}))},title:jr?"Show sidebar":"Hide sidebar","aria-label":jr?"Show sidebar":"Hide sidebar",children:jr?(0,P.jsx)(E.FNi,{}):(0,P.jsx)(E.G1X,{})}),Qs&&ct&&(0,P.jsx)("button",{type:"button",className:"compare-data-toggle-tab".concat(Sr?" is-collapsed":""),onClick:function(){return _r((function(e){return!e}))},title:Sr?"Show details panel":"Hide details panel","aria-label":Sr?"Show details panel":"Hide details panel",children:Sr?(0,P.jsx)(E.G1X,{}):(0,P.jsx)(E.FNi,{})}),(0,P.jsxs)("div",{id:"sidebar",children:[!ct&&!(lt&&0===jt)&&(0,P.jsxs)("div",{className:"sb-header",children:[(0,P.jsxs)("div",{className:"sb-header-top",children:[(0,P.jsxs)("div",{className:"sb-header-title",children:[(0,P.jsx)("span",{className:"sb-title-bar","aria-hidden":"true"}),(0,P.jsx)("span",{className:"sb-title-text",children:"RIDER DISPATCH"})]}),(0,P.jsxs)("span",{className:"sb-header-scope",title:xt.label,children:[(0,P.jsx)("span",{className:"sb-scope-dot"}),xt.label]})]}),(0,P.jsxs)("div",{className:"sb-header-tiles",children:[(0,P.jsxs)("div",{className:"sb-tile sb-tile-orders",children:[(0,P.jsx)("span",{className:"sb-tile-icon",children:(0,P.jsx)(E.ByW,{})}),(0,P.jsxs)("div",{className:"sb-tile-body",children:[(0,P.jsx)("div",{className:"sb-tile-value",children:xt.orders}),(0,P.jsx)("div",{className:"sb-tile-label",children:1===xt.orders?"Order":"Orders"})]})]}),(0,P.jsxs)("div",{className:"sb-tile sb-tile-riders",children:[(0,P.jsx)("span",{className:"sb-tile-icon",children:(0,P.jsx)(E.pbk,{})}),(0,P.jsxs)("div",{className:"sb-tile-body",children:[(0,P.jsx)("div",{className:"sb-tile-value",children:xt.riders}),(0,P.jsx)("div",{className:"sb-tile-label",children:1===xt.riders?"Rider":"Riders"})]})]})]})]}),ct||Ue?(0,P.jsxs)("div",{id:"route-detail",children:[(0,P.jsxs)("button",{className:"rd-back",onClick:function(){pt(null),Ve(null)},children:["\u2190 Back to ",Qe?Qe.name:"list"]}),ct?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("div",{className:"rd-rider-name",style:{color:ct.color},children:ct.riderName}),function(){var e=lt?(0,z.P0)(ct.orders):null,n=lt?e?[e]:[]:ct.orders,s=n.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0);return(0,P.jsxs)("div",{className:"rd-stats-grid",children:[(0,P.jsxs)("div",{className:"rd-stat rd-stat-orders",children:[(0,P.jsx)("div",{className:"rd-stat-icon",children:(0,P.jsx)(E.ByW,{})}),(0,P.jsx)("div",{className:"rd-stat-value",children:n.length}),(0,P.jsx)("div",{className:"rd-stat-label",children:"Orders"})]}),(0,P.jsxs)("div",{className:"rd-stat rd-stat-distance",children:[(0,P.jsx)("div",{className:"rd-stat-icon",children:(0,P.jsx)(E.v93,{})}),(0,P.jsxs)("div",{className:"rd-stat-value",children:[s.toFixed(1),(0,P.jsx)("span",{className:"rd-stat-unit",children:"km"})]}),(0,P.jsx)("div",{className:"rd-stat-label",children:"Distance"})]})]})}(),function(){var e=lt?(0,z.P0)(ct.orders):null,n=lt?e?[e]:[]:ct.orders;if(lt&&0===n.length)return(0,P.jsx)("div",{className:"trip-empty-note",style:{padding:"14px 4px",color:"#94a3b8",fontSize:13},children:"No active delivery right now."});var s={};n.forEach((function(e){var n=e.trip_number||1;s[n]||(s[n]=[]),s[n].push(e)}));var r=(0,t.Z)(ct.orders).sort((function(e,n){var s=e.trip_number||1,r=n.trip_number||1;return s!==r?s-r:(e.step||0)-(n.step||0)})).find((function(e){var n=String(e.orderstatus||"").toLowerCase();return!z.Q6.has(n)&&!z.us.has(n)})),a=r?r.orderid:null,i=function(e){var n=e.deliverytime||e.expecteddeliverytime;if(!n)return Number.MAX_SAFE_INTEGER;var s=S()(n);return s.isValid()?s.valueOf():Number.MAX_SAFE_INTEGER},c="time"===an,d=null;return Object.entries(s).sort((function(e,n){var s=(0,l.Z)(e,1)[0],r=(0,l.Z)(n,1)[0];return Number(s)-Number(r)})).map((function(e){var n=(0,l.Z)(e,2),s=n[0],r=n[1],o=c?(0,t.Z)(r).sort((function(e,n){var s=i(e)-i(n);return 0!==s?s:(e.step||0)-(n.step||0)})):r;return(0,P.jsxs)("div",{className:"trip-block",children:[(0,P.jsxs)("div",{className:"trip-header",style:{background:"".concat(ct.color,"12"),borderColor:"".concat(ct.color,"30")},children:[(0,P.jsxs)("span",{className:"th-badge",style:{background:ct.color},children:["Trip ",s]}),(0,P.jsxs)("span",{className:"trip-stats",children:[(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.$0r,{})}),r.length," stops"]}),(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),r.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0).toFixed(1)," km"]})]}),(0,P.jsxs)("div",{className:"trip-sort-toggle",role:"group","aria-label":"Sort stops by","data-mode":c?"time":"planned",children:[(0,P.jsxs)("button",{type:"button",className:"trip-sort-pill ".concat(c?"":"is-active"),"aria-pressed":!c,onClick:function(){return cn("planned")},title:"Sort stops by planned step (dispatched order)",children:[(0,P.jsx)(E.f_H,{"aria-hidden":"true"}),(0,P.jsx)("span",{children:"Planned"})]}),(0,P.jsxs)("button",{type:"button",className:"trip-sort-pill ".concat(c?"is-active":""),"aria-pressed":c,onClick:function(){return cn("time")},title:"Sort stops by completion time (which delivery was done first)",children:[(0,P.jsx)(E.dKE,{"aria-hidden":"true"}),(0,P.jsx)("span",{children:"By time"})]})]})]}),(0,P.jsx)("div",{className:"zone-order-grid",children:o.map((function(e,n){var r=(e.kitchen_key||e.pickupcustomer||"Unknown").toLowerCase().trim(),t=null!==d&&r!==d;d=r;var i=nn&&nn.orderid===e.orderid,l=a&&e.orderid===a,o=parseFloat(e.droplat||e.deliverylat),m=parseFloat(e.droplon||e.deliverylong),p=Number.isFinite(o)&&Number.isFinite(m),h=(0,z.Cl)(e.orderstatus),v=Pt(ct.id,e),f=c&&!e.deliverytime;return(0,P.jsxs)(u.Fragment,{children:[t&&(0,P.jsxs)("div",{className:"kitchen-transition",children:[(0,P.jsx)("span",{className:"kt-ico",children:(0,P.jsx)(E.x82,{})})," Switch to ",(0,P.jsx)("strong",{children:e.pickupcustomer})]}),(0,P.jsxs)("div",{className:"zone-order-card ".concat(p?"clickable":""," ").concat(i?"active":""," ").concat(l?"going-on":""," ").concat(f?"is-pending-time":""),role:p?"button":void 0,tabIndex:p?0:void 0,onClick:p?function(){return sn(i?null:{orderid:e.orderid,lat:o,lon:m})}:void 0,onKeyDown:p?function(n){"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),sn(i?null:{orderid:e.orderid,lat:o,lon:m}))}:void 0,title:p?i?"Click to show full trip":"Show ".concat(e.deliverycustomer||"order #".concat(e.orderid)," on map"):void 0,children:[(0,P.jsxs)("div",{className:"zone-order-card-head",children:[(0,P.jsx)("div",{className:"zone-order-num",children:e.step||n+1}),(0,P.jsx)("div",{className:"zone-order-id-block",children:(0,P.jsxs)("div",{className:"zone-order-id",children:["Order #",e.orderid]})}),function(){var n=xe(e.deliverytime),s=xe(e.expecteddeliverytime),r=!z.Q6.has(String(e.orderstatus||"").toLowerCase())&&null!==v;return e.orderstatus||n||s||r?(0,P.jsxs)("div",{className:"zone-order-status-stack",children:[e.orderstatus&&(0,P.jsx)("span",{className:"zone-order-status",style:{background:h.bg,color:h.fg},children:h.label}),(n||s)&&(0,P.jsxs)("span",{className:"zone-order-time ".concat(n?"":"is-expected"),title:n?"Delivered at ".concat(n):"Expected at ".concat(s),children:[(0,P.jsx)(E.dKE,{}),n||s]}),r&&(0,P.jsxs)("span",{className:"zone-order-est-drop",title:"Estimated distance to drop location",children:[(0,P.jsx)(E.x$F,{}),Rt(v)]})]}):null}(),D&&(0,P.jsx)("button",{type:"button",className:"zone-order-change-rider",title:"Change rider",onClick:function(n){n.stopPropagation(),D(e,ct)},children:(0,P.jsx)(E.x82,{})})]}),(0,P.jsxs)("div",{className:"zone-order-customer",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.gNp,{})}),e.deliverycustomer||"\u2014"]}),e.pickupcustomer&&(0,P.jsxs)("div",{className:"zone-order-line",title:"Kitchen: ".concat(e.pickupcustomer),children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.TkG,{})}),e.pickupcustomer]}),(e.deliverysuburb||e.deliveryaddress)&&(0,P.jsxs)("div",{className:"zone-order-line",title:e.deliveryaddress||e.deliverysuburb,children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.$0r,{})}),e.deliverysuburb||J(e.deliveryaddress)]}),e.ordernotes&&(0,P.jsxs)("div",{className:"zone-order-line zone-order-notes",title:e.ordernotes,children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.hKf,{})}),e.ordernotes]}),(0,P.jsxs)("div",{className:"zone-order-stats",children:[(0,P.jsxs)("span",{className:"zone-order-chip",title:"Distance",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),e.actualkms||e.kms||0," km"]}),e.ordertype&&(0,P.jsx)("span",{className:"zone-order-chip zone-order-type type-".concat(String(e.ordertype).toLowerCase()),children:e.ordertype}),(0,P.jsxs)("span",{className:"zone-order-chip zone-order-trip",children:["T",e.trip_number||s," \xb7 S",e.step||n+1]})]})]})]},e.orderid)}))})]},s)}))}()]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("div",{className:"rd-rider-name",style:{color:"#f59e0b"},children:Ue.kitchenName}),(0,P.jsxs)("div",{className:"rd-rider-sub",children:[(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.ByW,{})}),Ue.orders.length," orders"]}),(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.pbk,{})}),Ue.riders.size," riders"]})]}),(0,P.jsxs)("div",{className:"zone-detail-section",children:[(0,P.jsxs)("div",{className:"zone-section-label",children:["Orders ",(0,P.jsxs)("span",{className:"section-count",children:["(",Ue.orders.length,")"]})]}),0===Ue.orders.length?(0,P.jsx)("div",{className:"zone-suburb-panel-empty",children:"No orders for this kitchen."}):(0,P.jsx)("div",{className:"zone-order-grid",children:Ue.orders.map((function(e,n){var s=parseFloat(e.droplat||e.deliverylat),r=parseFloat(e.droplon||e.deliverylong),a=Number.isFinite(s)&&Number.isFinite(r),i=nn&&nn.orderid===e.orderid,c=(0,z.Cl)(e.orderstatus),l=e.rider_id||e.userid,d=l?rt.find((function(e){return String(e.id)===String(l)})):null,o=function(){if(!d)return null;var e=(0,t.Z)(d.orders).sort((function(e,n){var s=e.trip_number||1,r=n.trip_number||1;return s!==r?s-r:(e.step||0)-(n.step||0)})).find((function(e){var n=String(e.orderstatus||"").toLowerCase();return!z.Q6.has(n)&&!z.us.has(n)}));return e?e.orderid:null}(),u=o&&e.orderid===o,m=l?Pt(l,e):null;return(0,P.jsxs)("div",{className:"zone-order-card ".concat(a?"clickable":""," ").concat(i?"active":""," ").concat(u?"going-on":""),role:a?"button":void 0,tabIndex:a?0:void 0,onClick:a?function(){return sn(i?null:{orderid:e.orderid,lat:s,lon:r})}:void 0,children:[(0,P.jsxs)("div",{className:"zone-order-card-head",children:[(0,P.jsx)("div",{className:"zone-order-num",children:e.step||n+1}),(0,P.jsxs)("div",{className:"zone-order-id-block",children:[(0,P.jsxs)("div",{className:"zone-order-id",children:["Order #",e.orderid]}),(0,P.jsxs)("div",{className:"zone-order-rider",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.pbk,{})}),e.rider_name||e.ridername||"Unassigned"]})]}),function(){var n=xe(e.deliverytime),s=xe(e.expecteddeliverytime),r=!z.Q6.has(String(e.orderstatus||"").toLowerCase())&&null!==m;return e.orderstatus||n||s||r?(0,P.jsxs)("div",{className:"zone-order-status-stack",children:[e.orderstatus&&(0,P.jsx)("span",{className:"zone-order-status",style:{background:c.bg,color:c.fg},children:c.label}),(n||s)&&(0,P.jsxs)("span",{className:"zone-order-time ".concat(n?"":"is-expected"),title:n?"Delivered at ".concat(n):"Expected at ".concat(s),children:[(0,P.jsx)(E.dKE,{}),n||s]}),r&&(0,P.jsxs)("span",{className:"zone-order-est-drop",title:"Estimated distance to drop location",children:[(0,P.jsx)(E.x$F,{}),Rt(m)]})]}):null}()]}),(0,P.jsxs)("div",{className:"zone-order-customer",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.gNp,{})}),e.deliverycustomer||"\u2014"]}),e.pickupcustomer&&(0,P.jsxs)("div",{className:"zone-order-line",title:"Kitchen: ".concat(e.pickupcustomer),children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.TkG,{})}),e.pickupcustomer]}),(e.deliverysuburb||e.deliveryaddress)&&(0,P.jsxs)("div",{className:"zone-order-line",title:e.deliveryaddress||e.deliverysuburb,children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.$0r,{})}),e.deliverysuburb||J(e.deliveryaddress)]}),e.ordernotes&&(0,P.jsxs)("div",{className:"zone-order-line zone-order-notes",title:e.ordernotes,children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.hKf,{})}),e.ordernotes]}),(0,P.jsxs)("div",{className:"zone-order-stats",children:[(0,P.jsxs)("span",{className:"zone-order-chip",title:"Distance",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),e.actualkms||e.kms||0," km"]}),e.ordertype&&(0,P.jsx)("span",{className:"zone-order-chip zone-order-type type-".concat(String(e.ordertype).toLowerCase()),children:e.ordertype}),(0,P.jsxs)("span",{className:"zone-order-chip zone-order-trip",children:["T",e.trip_number||"-"," \xb7 S",e.step||n+1]})]})]},e.orderid)}))})]})]})]}):Qe?(0,P.jsxs)("div",{id:"route-detail",children:[(0,P.jsx)("button",{className:"rd-back",onClick:function(){return Xe(null)},children:"\u2190 Back to zones"}),(0,P.jsx)("div",{className:"rd-rider-name",style:{color:"#3b82f6"},children:Qe.name}),(0,P.jsx)("div",{className:"rd-rider-sub",children:(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.ByW,{})}),Qe.totalOrders," ",1===Qe.totalOrders?"order":"orders"]})}),(0,P.jsxs)("div",{className:"zone-detail-section",children:[(0,P.jsxs)("div",{className:"zone-section-label",children:["Orders ",(0,P.jsxs)("span",{className:"section-count",children:["(",Qe.orders.length,")"]})]}),0===Qe.orders.length?(0,P.jsx)("div",{className:"zone-suburb-panel-empty",children:"No orders in this zone."}):(0,P.jsx)("div",{className:"zone-order-grid",children:Qe.orders.map((function(e,n){var s=parseFloat(e.droplat||e.deliverylat),r=parseFloat(e.droplon||e.deliverylong),a=Number.isFinite(s)&&Number.isFinite(r),i=nn&&nn.orderid===e.orderid,c=(0,z.Cl)(e.orderstatus),l=e.rider_id||e.userid,d=l?rt.find((function(e){return String(e.id)===String(l)})):null,o=function(){if(!d)return null;var e=(0,t.Z)(d.orders).sort((function(e,n){var s=e.trip_number||1,r=n.trip_number||1;return s!==r?s-r:(e.step||0)-(n.step||0)})).find((function(e){var n=String(e.orderstatus||"").toLowerCase();return!z.Q6.has(n)&&!z.us.has(n)}));return e?e.orderid:null}(),u=o&&e.orderid===o,m=l?Pt(l,e):null;return(0,P.jsxs)("div",{className:"zone-order-card ".concat(a?"clickable":""," ").concat(i?"active":""," ").concat(u?"going-on":""),role:a?"button":void 0,tabIndex:a?0:void 0,onClick:a?function(){return sn(i?null:{orderid:e.orderid,lat:s,lon:r})}:void 0,children:[(0,P.jsxs)("div",{className:"zone-order-card-head",children:[(0,P.jsx)("div",{className:"zone-order-num",children:e.step||n+1}),(0,P.jsxs)("div",{className:"zone-order-id-block",children:[(0,P.jsxs)("div",{className:"zone-order-id",children:["Order #",e.orderid]}),(0,P.jsxs)("div",{className:"zone-order-rider",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.pbk,{})}),e.rider_name||e.ridername||"Unassigned"]})]}),function(){var n=xe(e.deliverytime),s=xe(e.expecteddeliverytime),r=!z.Q6.has(String(e.orderstatus||"").toLowerCase())&&null!==m;return e.orderstatus||n||s||r?(0,P.jsxs)("div",{className:"zone-order-status-stack",children:[e.orderstatus&&(0,P.jsx)("span",{className:"zone-order-status",style:{background:c.bg,color:c.fg},children:c.label}),(n||s)&&(0,P.jsxs)("span",{className:"zone-order-time ".concat(n?"":"is-expected"),title:n?"Delivered at ".concat(n):"Expected at ".concat(s),children:[(0,P.jsx)(E.dKE,{}),n||s]}),r&&(0,P.jsxs)("span",{className:"zone-order-est-drop",title:"Estimated distance to drop location",children:[(0,P.jsx)(E.x$F,{}),Rt(m)]})]}):null}()]}),(0,P.jsxs)("div",{className:"zone-order-customer",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.gNp,{})}),e.deliverycustomer||"\u2014"]}),e.pickupcustomer&&(0,P.jsxs)("div",{className:"zone-order-line",title:"Kitchen: ".concat(e.pickupcustomer),children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.TkG,{})}),e.pickupcustomer]}),(e.deliverysuburb||e.deliveryaddress)&&(0,P.jsxs)("div",{className:"zone-order-line",title:e.deliveryaddress||e.deliverysuburb,children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.$0r,{})}),e.deliverysuburb||J(e.deliveryaddress)]}),e.ordernotes&&(0,P.jsxs)("div",{className:"zone-order-line zone-order-notes",title:e.ordernotes,children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.hKf,{})}),e.ordernotes]}),(0,P.jsxs)("div",{className:"zone-order-stats",children:[(0,P.jsxs)("span",{className:"zone-order-chip",title:"Distance",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),e.actualkms||e.kms||0," km"]}),e.ordertype&&(0,P.jsx)("span",{className:"zone-order-chip zone-order-type type-".concat(String(e.ordertype).toLowerCase()),children:e.ordertype}),(0,P.jsxs)("span",{className:"zone-order-chip zone-order-trip",children:["T",e.trip_number||"-"," \xb7 S",e.step||n+1]})]})]},e.orderid)}))})]})]}):(0,P.jsxs)("div",{id:"riders-panel",children:[!(lt&&0===jt)&&(0,P.jsx)("div",{className:"ph",children:"zones"===O?"Zone dispatch":"kitchens"===O?"Kitchen dispatch":"all"===O?"Active rider dispatch":"Rider dispatch"}),(0,P.jsx)("div",{id:"rider-cards",children:0!==at.length||Yr?"zones"===O?nt.map((function(e,n){var s=e.statusCounts.delivered||0;return(0,P.jsxs)("div",{className:"rcard zone-card",onClick:function(){return Xe(e)},style:{animationDelay:"".concat(.05*n,"s")},children:[(0,P.jsxs)("div",{className:"zone-card-header",children:[(0,P.jsx)("div",{className:"zone-card-emoji",children:(0,P.jsx)(E.PKO,{})}),(0,P.jsxs)("div",{className:"zone-card-titles",children:[(0,P.jsx)("div",{className:"zone-card-name",children:e.name}),(0,P.jsxs)("div",{className:"zone-card-sub",children:[e.activeRidersCount," ",1===e.activeRidersCount?"rider":"riders"," \xb7 ",e.totalOrders," ",1===e.totalOrders?"order":"orders"]})]}),(0,P.jsx)("span",{className:"zone-card-arrow","aria-hidden":"true",children:"\u2192"})]}),e.totalOrders>0&&(0,P.jsxs)("div",{className:"zone-progress-row",children:[(0,P.jsx)("div",{className:"zone-status-bar",title:Object.entries(e.statusCounts).map((function(e){var n=(0,l.Z)(e,2),s=n[0],r=n[1];return"".concat((0,z.Cl)(s).label,": ").concat(r)})).join(" \xb7 "),children:Object.entries(e.statusCounts).map((function(n){var s=(0,l.Z)(n,2),r=s[0],t=s[1],a=(0,z.Cl)(r),i=t/e.totalOrders*100;return(0,P.jsx)("div",{className:"zone-status-seg",style:{width:"".concat(i,"%"),background:a.bg}},r)}))}),(0,P.jsxs)("div",{className:"zone-progress-label",children:[s,"/",e.totalOrders]})]}),(0,P.jsxs)("div",{className:"zone-stat-pills",children:[(0,P.jsxs)("span",{className:"zone-stat-pill",title:"Areas covered",children:[(0,P.jsx)("span",{className:"zone-stat-icon",children:(0,P.jsx)(E.$0r,{})}),(0,P.jsx)("span",{className:"zone-stat-value",children:e.suburbs.length}),(0,P.jsx)("span",{className:"zone-stat-label",children:1===e.suburbs.length?"area":"areas"})]}),(0,P.jsxs)("span",{className:"zone-stat-pill",title:"Total distance",children:[(0,P.jsx)("span",{className:"zone-stat-icon",children:(0,P.jsx)(E.v93,{})}),(0,P.jsx)("span",{className:"zone-stat-value",children:e.totalKms.toFixed(1)}),(0,P.jsx)("span",{className:"zone-stat-label",children:"km"})]}),(0,P.jsxs)("span",{className:"zone-stat-pill",title:"Kitchens",children:[(0,P.jsx)("span",{className:"zone-stat-icon",children:(0,P.jsx)(E.TkG,{})}),(0,P.jsx)("span",{className:"zone-stat-value",children:e.kitchens.length}),(0,P.jsx)("span",{className:"zone-stat-label",children:1===e.kitchens.length?"kitchen":"kitchens"})]})]}),e.suburbs.length>0&&(0,P.jsxs)("div",{className:"zone-card-suburbs",children:[(0,P.jsx)("span",{className:"zone-card-suburbs-text",children:e.suburbs.slice(0,3).map((function(e){return e.name})).join(" \xb7 ")}),e.suburbs.length>3&&(0,P.jsxs)("span",{className:"zone-card-suburbs-more",children:["+",e.suburbs.length-3]})]})]},e.id)})):"kitchens"===O?tt.map((function(e,n){return(0,P.jsxs)("div",{className:"rcard",onClick:function(){return Ve(e)},style:{animationDelay:"".concat(.05*n,"s")},children:[(0,P.jsxs)("div",{className:"rcard-top",children:[(0,P.jsx)("div",{className:"rcard-emo",style:{background:"#f59e0b18",borderColor:"#f59e0b50",color:"#f59e0b"},children:(0,P.jsx)(E.TkG,{})}),(0,P.jsxs)("div",{className:"rcard-info",children:[(0,P.jsx)("div",{className:"rcard-name",children:e.kitchenName}),(0,P.jsxs)("div",{className:"rcard-zone",children:[e.riders.size," ",1===e.riders.size?"rider":"riders"]})]}),(0,P.jsx)("div",{className:"rcard-badge",style:{background:"#f59e0b18",color:"#f59e0b"},children:e.orders.length})]}),(0,P.jsx)("div",{className:"bar-bg",children:(0,P.jsx)("div",{className:"bar-fg",style:{width:"".concat(Math.min(100,e.orders.length/20*100),"%"),background:"#f59e0b"}})}),(0,P.jsxs)("div",{className:"rcard-meta",children:[(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),e.orders.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0).toFixed(1)," km"]}),(0,P.jsxs)("span",{children:[e.riders.size," riders"]})]}),(0,P.jsx)("div",{className:"step-ids",children:Array.from(e.riders).slice(0,10).map((function(e){var n;return(0,P.jsx)("span",{className:"step-id",style:{color:zt(e)},children:null===(n=rt.find((function(n){return n.id===e})))||void 0===n?void 0:n.riderName.split(" ")[0]},e)}))})]},e.id)})):lt?function(){var e=ut.filter(z.Y_).slice().sort((function(e,n){var s=String(e.rider_name||e.ridername||"").localeCompare(String(n.rider_name||n.ridername||""));if(0!==s)return s;var r=e.trip_number||1,t=n.trip_number||1;return r!==t?r-t:(e.step||0)-(n.step||0)}));return 0===e.length?(0,P.jsxs)("div",{className:"empty-slot",children:[(0,P.jsx)("div",{className:"empty-slot-icon",children:(0,P.jsx)(E.ByW,{})}),(0,P.jsx)("div",{className:"empty-slot-title",children:"No active deliveries"}),(0,P.jsx)("div",{className:"empty-slot-sub",children:"No deliveries are currently in progress for this slot"})]}):e.map(Dt)}():ot.map((function(e,n){var s,r=e.orders.length,t=e.orders.filter((function(e){return z.Q6.has(String(e.orderstatus||"").toLowerCase())})).length,a=r>0&&t>=r,i=e.orders.find((function(e){var n=String(e.orderstatus||"").toLowerCase();return!z.Q6.has(n)&&!z.us.has(n)})),c=i?Pt(e.id,i):null,l=e.gpsOnly||0===r;return(0,P.jsxs)("div",{className:"rcard".concat(l?" is-gps-only":""),onClick:l?void 0:function(){return pt(e)},style:{animationDelay:"".concat(.05*n,"s")},children:[(0,P.jsxs)("div",{className:"rcard-top",children:[(0,P.jsx)("div",{className:"rcard-emo",style:{background:"".concat(e.color,"18"),borderColor:"".concat(e.color,"50"),color:e.color},children:(0,P.jsx)(E.pbk,{})}),(0,P.jsxs)("div",{className:"rcard-info",children:[(0,P.jsx)("div",{className:"rcard-name",children:e.riderName}),(0,P.jsx)("div",{className:"rcard-zone",children:l?"Live GPS \xb7 no active delivery":"".concat((null===(s=e.orders[0])||void 0===s?void 0:s.zone_name)||ms||"Local"," \xb7 ").concat(new Set(e.orders.map((function(e){return e.trip_number||1}))).size," trips")})]}),l?(0,P.jsxs)("div",{className:"rcard-badge rcard-badge-live",title:"Rider is live on GPS with no active delivery",children:[(0,P.jsx)("span",{className:"rcard-live-dot"})," LIVE"]}):(0,P.jsxs)("div",{className:"rcard-badge ".concat(a?"is-done":""),style:a?void 0:{background:"".concat(e.color,"18"),color:e.color},title:"".concat(t," delivered of ").concat(r," total"),children:[t,"/",r]})]}),!l&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)("div",{className:"bar-bg",children:(0,P.jsx)("div",{className:"bar-fg",style:{width:"".concat(Math.min(100,r/15*100),"%"),background:e.color}})}),(0,P.jsxs)("div",{className:"rcard-meta",children:[(0,P.jsxs)("span",{children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.v93,{})}),e.orders.reduce((function(e,n){return e+parseFloat(n.actualkms||n.kms||0)}),0).toFixed(1)," km"]}),null!==c&&(0,P.jsxs)("span",{className:"rcard-est-meters",title:"Estimated distance to next drop location",children:[(0,P.jsx)(Se,{children:(0,P.jsx)(E.x$F,{})}),Rt(c)," to drop"]})]}),(0,P.jsx)("div",{className:"step-ids",children:e.orders.slice(0,15).map((function(e){return(0,P.jsxs)("span",{className:"step-id",children:["S",e.step]},e.orderid)}))})]})]},e.id)})):function(){var e,n=null===(e=Kn.find((function(e){return e.id===qr})))||void 0===e?void 0:e.label,s=Ir&&Jr.length>0;return(0,P.jsxs)("div",{className:"empty-slot",children:[(0,P.jsx)("div",{className:"empty-slot-icon",children:(0,P.jsx)(E.ByW,{})}),(0,P.jsx)("div",{className:"empty-slot-title",children:n?"No orders in ".concat(n):"No orders"}),(0,P.jsx)("div",{className:"empty-slot-sub",children:s?"".concat(Jr.length," order").concat(1===Jr.length?"":"s"," exist in other slots today"):"No deliveries found for this date"})]})}()})]})]}),(0,P.jsxs)("div",{id:"map-wrap",className:"".concat("kitchens"===O?"view-mode-kitchens":""," ").concat(Qs?"compare-split":"").trim(),children:[(0,P.jsxs)(v.h,{center:[11.022,76.982],zoom:12,scrollWheelZoom:!0,style:{height:"100%",width:"100%"},zoomControl:!1,renderer:Mr.current,inertia:!0,inertiaDeceleration:2400,inertiaMaxSpeed:2e3,wheelDebounceTime:20,wheelPxPerZoomLevel:80,zoomSnap:.25,children:[(0,P.jsx)(f.I,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\xa9 OpenStreetMap contributors"}),(0,P.jsx)(g.L,{position:"bottomright"}),Qs&&(0,P.jsx)(me,{targetRef:Er}),(0,P.jsx)(ye,{focusedItem:Ft||(ct||Ue)&&nn||ct||Ue||Qe,viewMode:O,orders:ut,kitchens:tt,locationKey:wn,extraPoints:mt}),tt.filter((function(e){return Number.isFinite(e.lat)&&Number.isFinite(e.lon)})).filter((function(e){return!ct||e.riders.has(ct.id)})).map((function(e,n){return(0,P.jsx)(p.J,{position:[e.lat,e.lon],icon:Mt(e.kitchenName,(null===Ue||void 0===Ue?void 0:Ue.id)===e.id),zIndexOffset:(null===Ue||void 0===Ue?void 0:Ue.id)===e.id?4e3:2e3,eventHandlers:{click:function(){return Ve(e)},mouseover:function(e){return e.target.openPopup()},mouseout:function(e){return e.target.closePopup()}},children:(0,P.jsxs)(j.G,{className:"kitchen-popup",maxWidth:220,minWidth:200,autoPan:!0,autoPanPadding:[20,20],children:[(0,P.jsx)("div",{className:"kp-header",children:"KITCHEN"}),(0,P.jsx)("div",{className:"kp-name",children:e.kitchenName}),(0,P.jsxs)("div",{className:"kp-stat",children:[(0,P.jsx)("span",{className:"kp-stat-lbl",children:"Orders"}),(0,P.jsx)("span",{className:"kp-stat-val",children:e.orders.length})]})]})},"k-".concat(n))})),function(){if(Qs&&ct&&"actual"===nr)return null;var e=ut;if(Qe&&(e=Qe.orders),Ue&&(e=Ue.orders),ct&&(e=ct.orders),e=e.filter(Q),lt)if(ct){var n=(0,z.P0)(ct.orders),s=n?String(n.orderid):null;e=s?e.filter((function(e){return String(e.orderid)===s})):[]}else e=e.filter(z.Y_);var r=Qs&&ct?new Map(yt.map((function(e){return[String(e.deliveryid),e.sequenceStep]}))):null;return e.map((function(n,s){var t,a=n.rider_id,i=!a||Oe.has(a),c=zt(a);if(r&&a===ct.id&&null!=n.deliveryid){var l=r.get(String(n.deliveryid));l&&(c=(0,z.di)(l-1),t=l)}var d=!!ct||!!Ue,o=(0,z.Cl)(n.orderstatus),u="delivered"===String(n.orderstatus||"").toLowerCase(),m=k&&String(k)===String(n.orderid),h=n.orderstatus?'<svg class="cmark-flag" viewBox="0 0 18 22" xmlns="http://www.w3.org/2000/svg">\n <line x1="1.5" y1="0" x2="1.5" y2="22" stroke="#0f172a" stroke-width="1.6" stroke-linecap="round"/>\n <polygon points="2,1 17,1 13.5,5.5 17,10 2,10" fill="'.concat(o.bg,'" stroke="#0f172a" stroke-width="0.6" stroke-linejoin="round"/>\n ').concat(u?'<polyline points="5,5.5 7,7.5 11,3.5" fill="none" stroke="#fff" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>':"","\n </svg>"):"",v=d?function(){var s=t||n.step||e.indexOf(n)+1,r=32;return b().divIcon({className:"",iconSize:[r,r],iconAnchor:[16,16],popupAnchor:[0,-28],html:'<div class="cmark is-rider-focused'.concat(m?" pulse":"",'" style="background:').concat(c,";width:").concat(r,"px;height:").concat(r,"px;font-size:").concat(s>9?12:14,"px;opacity:").concat(i?1:.75,'">').concat(s>0?s:"").concat(h,"</div>")})}():b().divIcon({className:"",iconSize:[24,30],iconAnchor:[2,30],popupAnchor:[10,-25],html:'<div class="cmark'.concat(m?" pulse":"",'" style="width:24px;height:30px;opacity:').concat(i?1:.75,'">').concat(h,"</div>")});return(0,P.jsx)(p.J,{position:[parseFloat(n.droplat||n.deliverylat),parseFloat(n.droplon||n.deliverylong)],icon:v,zIndexOffset:a?100:0,ref:function(e){e?ln.current[String(n.orderid)]=e:delete ln.current[String(n.orderid)]},eventHandlers:{click:function(){var e=String(n.orderid);dn.current.has(e)?(dn.current.delete(e),fn(null)):(dn.current.add(e),fn(n))}}},"".concat(n.orderid,"-").concat(d?"num":"flag"))}))}(),function(){var e=Qs&&ct&&"actual"===nr;if(_s)return e?[]:Cs.map((function(e,n){return(0,P.jsx)(h.a,{positions:[e.from,e.to],pathOptions:{color:e.color,weight:6,opacity:.9,lineJoin:"round",lineCap:"round"}},n)}));var n=[],s=Qe?new Set(Qe.riders.map((function(e){return String(e.rider_id)}))):null;return e||ot.forEach((function(e){var r=Oe.has(e.id);if((!ct||ct.id===e.id)&&(!Ue||Ue.riders.has(e.id))&&(!s||s.has(String(e.id)))){var a=lt?(0,z.P0)(e.orders):null,i=lt?a?[a]:[]:e.orders;if(!lt||0!==i.length){var c={};i.forEach((function(e){var n=e.trip_number||1;c[n]||(c[n]=[]),c[n].push(e)})),Object.entries(c).forEach((function(s){var a=(0,l.Z)(s,2),i=a[0],c=a[1],d=Ue?c.filter((function(e){return(e.pickupcustomer||e.kitchen_key||"Unknown").toLowerCase().trim()===Ue.id})):c;if(0!==d.length){var o="".concat(e.id,"-").concat(i),m=vs[o],p=(0,t.Z)(d).sort((function(e,n){return(e.step||0)-(n.step||0)})),v=r?1:.1,f="kitchens"===O||Ue?7:6,x=Qs&&ct&&e.id===ct.id;if(!x){var j=[],g=!1;if(p.forEach((function(e){if(null!=e.deliveryid&&""!==e.deliveryid&&0!==e.deliveryid){var n=String(e.deliveryid),s=Ns[n],r=bt.get(n),a=null;if(Array.isArray(s)&&s.length>=2?a=s:r&&r.coords.length>=2&&(a=r.coords.map((function(e){return[e.lat,e.lng]}))),a)if(g=!0,0===j.length)j.push.apply(j,(0,t.Z)(a));else{var i=j[j.length-1],c=a[0],l=Math.abs(i[0]-c[0])<1e-5&&Math.abs(i[1]-c[1])<1e-5;j.push.apply(j,(0,t.Z)(l?a.slice(1):a))}}})),g&&j.length>=2)return void n.push((0,P.jsxs)(u.Fragment,{children:[(0,P.jsx)(h.a,{positions:j,pathOptions:{color:"#ffffff",weight:f+4,opacity:.5*v,lineJoin:"round",lineCap:"round"}}),(0,P.jsx)(h.a,{positions:j,pathOptions:{color:e.color,weight:f,opacity:v,lineJoin:"round",lineCap:"round"}})]},"".concat(e.id,"-").concat(i,"-actual")))}var N=!lt&&Array.isArray(m)&&m.length>=2,b=!!lt||!1===m;if(N||b){var y=N?m:ge(p);if(y&&!(y.length<2)){var k=Qs&&ct&&e.id===ct.id,S=b?"8 6":k&&"combined"===nr?"6 5":void 0;if(x){var _,w=new Map(yt.map((function(e){return[String(e.deliveryid),e.sequenceStep]}))),F=p.filter(Q),A=F.map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]}));if(N)_=fe(y,A);else{var C=y.length>A.length;_=[];for(var E=0;E<A.length;E++){var M=C?E:E-1,R=C?E+1:E;M<0||M>=y.length||R>=y.length?_.push([]):_.push([y[M],y[R]])}}var D="combined"===nr?5:0;return n.push((0,P.jsx)(h.a,{positions:y,pathOptions:{color:"#ffffff",weight:f+4,opacity:.5*v,lineJoin:"round",lineCap:"round",offset:D}},"".concat(e.id,"-").concat(i,"-halo"))),void _.forEach((function(s,r){if(s&&!(s.length<2)){var t=F[r],a=t?w.get(String(t.deliveryid)):null,c="combined"===nr?U:a?(0,z.di)(a-1):e.color,l=null!=Ar&&Ar===a,d=l?f+1.5:f,o=l?1:Ar?.5*v:v;n.push((0,P.jsx)(h.a,{positions:s,pathOptions:{color:c,weight:d,opacity:o,lineJoin:"round",lineCap:"round",dashArray:S,offset:D}},"".concat(e.id,"-").concat(i,"-step-").concat(r,"-").concat((null===t||void 0===t?void 0:t.deliveryid)||r)))}}))}n.push((0,P.jsxs)(u.Fragment,{children:[(0,P.jsx)(h.a,{positions:y,pathOptions:{color:"#ffffff",weight:f+4,opacity:.5*v,lineJoin:"round",lineCap:"round"}}),(0,P.jsx)(h.a,{positions:y,pathOptions:{color:e.color,weight:f,opacity:v,lineJoin:"round",lineCap:"round",dashArray:S}})]},"".concat(e.id,"-").concat(i)))}}}}))}}})),n}(),Rr.filter((function(e){return lt?"active"===e.status:rt.some((function(n){return String(n.id)===String(e.id)}))})).filter((function(e){return!ct||String(ct.id)===String(e.id)})).map((function(e){var n,s="active"===e.status,r=s?"#16a34a":"#dc2626",t=rt.find((function(n){return String(n.id)===String(e.id)})),a=null===t||void 0===t||null===(n=t.orders)||void 0===n?void 0:n.slice().sort((function(e,n){var s=e.trip_number||1,r=n.trip_number||1;return s!==r?s-r:(e.step||0)-(n.step||0)})).find((function(e){var n=String(e.orderstatus||"").toLowerCase();return!z.Q6.has(n)&&!z.us.has(n)})),i=a?a.deliverysuburb||J(a.deliveryaddress):null,c=(e.username||"").replace(/[<>&"']/g,""),l=e.orderid?String(e.orderid).replace(/[<>&"']/g,""):"",d="".concat(lt?"bike":"pin","|").concat(r,"|").concat(c,"|").concat(l,"|").concat(s?1:0),u=un.current.get(e.id);u&&u.sig===d||(u={sig:d,icon:lt?b().divIcon({className:"",iconSize:[160,44],iconAnchor:[22,22],popupAnchor:[0,-22],html:'<div class="live-rider-bike '.concat(s?"is-active":"is-idle",'" style="--pin-color:').concat(r,'">\n <span class="live-rider-bike-pulse"></span>\n <span class="live-rider-bike-badge">\n <svg viewBox="0 0 24 24" width="20" height="20" fill="#fff" aria-hidden="true"><path d="M19.44 9.03 15.41 5H11v2h3.59l2 2H5c-2.8 0-5 2.2-5 5s2.2 5 5 5c2.46 0 4.45-1.69 4.9-4h1.65l2.77-2.77c-.21.54-.32 1.14-.32 1.77 0 2.76 2.24 5 5 5s5-2.24 5-5c0-2.65-2.06-4.77-4.66-4.97ZM7.82 15C7.4 16.15 6.28 17 5 17c-1.63 0-3-1.37-3-3s1.37-3 3-3c1.28 0 2.4.85 2.82 2H5v2h2.82ZM19 17c-1.63 0-3-1.37-3-3s1.37-3 3-3 3 1.37 3 3-1.37 3-3 3Z"/></svg>\n </span>\n <span class="live-rider-bike-label">').concat(c).concat(l?" <span>#".concat(l,"</span>"):"","</span>\n </div>")}):b().divIcon({className:"",iconSize:[140,56],iconAnchor:[12,41],popupAnchor:[58,-40],html:'<div class="live-rider-pin" style="--pin-color:'.concat(r,'">\n <div class="live-rider-pin-marker"></div>\n <div class="live-rider-pin-label">').concat(c).concat(l?" <span>#".concat(l,"</span>"):"","</div>\n </div>")})},un.current.set(e.id,u));var m=u.icon,h={click:function(n){var s=String(e.id);on.current.has(s)?(on.current.delete(s),n.target.closePopup()):(on.current.add(s),n.target.openPopup());var r=rt.find((function(e){return String(e.id)===s}));r&&pt(r)},popupclose:function(){on.current.delete(String(e.id))}},v=lt?ke:p.J,f=lt?{target:[e.lat,e.lon],duration:1200}:{position:[e.lat,e.lon]};return(0,P.jsx)(v,(0,o.Z)((0,o.Z)({},f),{},{icon:m,zIndexOffset:2500,eventHandlers:h,children:(0,P.jsxs)(j.G,{maxWidth:260,autoPan:!0,autoPanPadding:[20,20],className:"dispatch-popup live-rider-popup",children:[(0,P.jsx)("div",{className:"pu-hdr-live",children:(0,P.jsxs)("div",{className:"pu-hdr-left",children:[(0,P.jsx)("span",{className:"pu-live-indicator",style:{"--pulse-color":r},children:(0,P.jsx)("span",{className:"pu-live-dot"})}),(0,P.jsx)("span",{className:"pu-hdr-title",children:"LIVE GPS"})]})}),(0,P.jsxs)("div",{className:"pu-rider-profile",children:[(0,P.jsx)("div",{className:"pu-avatar",style:{backgroundColor:"".concat(r,"12"),color:r},children:(0,P.jsx)(E.MCF,{})}),(0,P.jsxs)("div",{className:"pu-rider-info-text",children:[(0,P.jsxs)("div",{className:"pu-rider-name-row",children:[(0,P.jsx)("span",{className:"pu-rider-name",children:e.username||"Rider #".concat(e.id)}),e.status&&(0,P.jsx)("span",{className:"pu-status-badge ".concat("active"===e.status.toLowerCase()?"active":"idle"),children:e.status})]}),(0,P.jsxs)("div",{className:"pu-rider-meta",children:["Rider ID: #",e.id]})]})]}),(0,P.jsxs)("div",{className:"pu-body-content",children:[e.orderid&&(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Active Order"}),(0,P.jsxs)("span",{className:"pu-info-value pu-order-badge",children:["#",e.orderid]})]}),a&&(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Next Stop"}),(0,P.jsxs)("span",{className:"pu-info-value",style:{color:"#4f46e5"},children:["#",a.step||"?"," \xb7 ",a.deliverycustomer||"\u2014"]})]}),i&&(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Next Location"}),(0,P.jsx)("span",{className:"pu-info-value",title:a.deliveryaddress||i,children:i})]}),(null===a||void 0===a?void 0:a.pickupcustomer)&&(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Pickup"}),(0,P.jsx)("span",{className:"pu-info-value",title:a.pickupcustomer,children:a.pickupcustomer})]}),e.contactno&&(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Phone"}),(0,P.jsx)("a",{href:"tel:".concat(e.contactno),className:"pu-info-value pu-phone-link",children:e.contactno})]}),e.logdate&&(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Last Seen"}),(0,P.jsxs)("span",{className:"pu-info-value pu-time-stamp",children:[(0,P.jsx)(E.dKE,{className:"inline-icon"})," ",S()(e.logdate).isValid()?S()(e.logdate).format("hh:mm:ss A"):e.logdate]})]}),(0,P.jsxs)("div",{className:"pu-info-row",children:[(0,P.jsx)("span",{className:"pu-info-label",children:"Position"}),(0,P.jsxs)("span",{className:"pu-info-value pu-coordinates",children:[e.lat.toFixed(5),", ",e.lon.toFixed(5)]})]})]})]})}),"live-".concat(e.id))})),Qs&&ct&&"planned"!==nr&&yt.map((function(e,n){var s,r;if(0===e.coords.length)return null;var t=(0,z.di)(n),a="combined"===nr?V:t,i=[e.coords[0].lat,e.coords[0].lng],c=[e.coords[e.coords.length-1].lat,e.coords[e.coords.length-1].lng],l=Ns[e.deliveryid],d=Array.isArray(l)&&l.length>=2?l:e.coords.map((function(e){return[e.lat,e.lng]})),o=d,m=!0;if(_s){var v=Ps[e.sequenceStep]||0;v<2?m=!1:o=d.slice(0,Math.min(v,d.length))}var f=Ar===e.sequenceStep,j=String(e.orderstatus||"").toLowerCase(),g=z.Q6.has(j),N=z.us.has(j),y=kt.find((function(n){return n.sequenceStep===e.sequenceStep})),k=!(null===y||void 0===y||!y.anomaly),_=null===ct||void 0===ct||null===(s=ct.orders)||void 0===s?void 0:s.find((function(n){return null!=n.deliveryid&&String(n.deliveryid)===String(e.deliveryid)})),w=(0,z.Cl)(e.orderstatus),F=(e.orderstatus&&'<svg class="cmark-flag" viewBox="0 0 18 22" xmlns="http://www.w3.org/2000/svg">\n <line x1="1.5" y1="0" x2="1.5" y2="22" stroke="#0f172a" stroke-width="1.6" stroke-linecap="round"/>\n <polygon points="2,1 17,1 13.5,5.5 17,10 2,10" fill="'.concat(w.bg,'" stroke="#0f172a" stroke-width="0.6" stroke-linejoin="round"/>\n ').concat(g?'<polyline points="5,5.5 7,7.5 11,3.5" fill="none" stroke="#fff" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>':"","\n </svg>"),["compare-step-pin"]);f&&F.push("is-focused"),g&&F.push("is-delivered"),N&&F.push("is-skipped"),k&&F.push("is-anomaly");var A='<div class="'.concat(F.join(" "),'" style="--pin-color:').concat(t,'">')+'<span class="compare-step-pin-num">'.concat(e.sequenceStep,"</span>")+(g?'<svg class="compare-step-pin-check" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M2.5 6.5 L5 9 L9.5 3.5" stroke="white" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>':"")+"</div>",C=b().divIcon({className:"",iconSize:[36,36],iconAnchor:[18,18],popupAnchor:[0,-22],html:A}),M=1===e.sequenceStep,R=M?b().divIcon({className:"",iconSize:[40,40],iconAnchor:[20,20],html:'<div class="compare-start-pin" style="--pin-color:'.concat(t,'">')+'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M19 6h-2c0-2.76-2.24-5-5-5S7 3.24 7 6H5c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-7-3c1.66 0 3 1.34 3 3H9c0-1.66 1.34-3 3-3zm0 10c-2.76 0-5-2.24-5-5h2c0 1.66 1.34 3 3 3s3-1.34 3-3h2c0 2.76-2.24 5-5 5z" fill="currentColor"/></svg></div>'}):null,D=function(n){n.originalEvent&&n.originalEvent.stopPropagation(),Cr((function(n){return n===e.sequenceStep?null:e.sequenceStep})),_&&n.target&&"function"===typeof n.target.openPopup&&n.target.openPopup()},L="combined"===nr?-5:0;return(0,P.jsxs)(u.Fragment,{children:[m&&(0,P.jsx)(h.a,{positions:o,pathOptions:{color:"#ffffff",weight:f?11:9,opacity:f?.75:.55,lineJoin:"round",lineCap:"round",offset:L}}),m&&(0,P.jsx)(h.a,{positions:o,pathOptions:{color:a,weight:f?6.5:5,opacity:f?1:Ar?.55:.95,lineJoin:"round",lineCap:"round",offset:L}}),M&&(0,P.jsx)(p.J,{position:i,icon:R,zIndexOffset:f?900:100,eventHandlers:{click:function(n){n.originalEvent&&n.originalEvent.stopPropagation(),Cr((function(n){return n===e.sequenceStep?null:e.sequenceStep}))}},children:(0,P.jsx)(x.u,{direction:"top",offset:[0,-12],opacity:1,className:"compare-tooltip",children:(0,P.jsxs)("div",{className:"cmp-tip",children:[(0,P.jsxs)("div",{className:"cmp-tip-header",children:[(0,P.jsx)("span",{className:"cmp-tip-step",style:{background:t},children:(0,P.jsx)(E.YD2,{})}),(0,P.jsxs)("div",{className:"cmp-tip-title-stack",children:[(0,P.jsx)("div",{className:"cmp-tip-title",children:e.pickupcustomer||"Pickup"}),(0,P.jsx)("div",{className:"cmp-tip-sub",children:null!==(r=e.coords[0])&&void 0!==r&&r.logdate?"Picked up \xb7 ".concat(S()(e.coords[0].logdate).format("hh:mm A")):"Rider trip origin"})]})]}),(0,P.jsx)("div",{className:"cmp-tip-action",children:"Click for step 1 details"})]})})}),(0,P.jsx)(p.J,{position:c,icon:C,zIndexOffset:f?1e3:200,eventHandlers:_?{mouseover:function(){mn.current&&(clearTimeout(mn.current),mn.current=null),fn(_)},mouseout:function(){Ar!==e.sequenceStep&&(mn.current&&clearTimeout(mn.current),mn.current=setTimeout((function(){fn((function(e){return e&&String(e.orderid)===String(_.orderid)?null:e})),mn.current=null}),200))},click:D}:{click:D},children:!_&&(0,P.jsx)(x.u,{direction:"top",offset:[0,-20],opacity:1,className:"compare-tooltip",children:function(){var n=(0,z.Cl)(e.orderstatus);return(0,P.jsxs)("div",{className:"cmp-tip",children:[(0,P.jsxs)("div",{className:"cmp-tip-header",children:[(0,P.jsx)("span",{className:"cmp-tip-step",style:{background:t},children:e.sequenceStep}),(0,P.jsxs)("div",{className:"cmp-tip-title-stack",children:[(0,P.jsx)("div",{className:"cmp-tip-title",children:e.deliverycustomer||"Step ".concat(e.sequenceStep)}),(0,P.jsx)("div",{className:"cmp-tip-sub",children:e.deliverytime?"Delivered ".concat(S()(e.deliverytime).format("hh:mm A")):"".concat(e.coords.length," GPS pings")})]}),e.orderstatus&&(0,P.jsx)("span",{className:"cmp-tip-tag",style:{background:n.bg,color:n.fg},children:n.label})]}),k&&(0,P.jsx)("div",{className:"cmp-tip-anomaly",children:"Deviation flagged \u2014 see details below"}),(0,P.jsx)("div",{className:"cmp-tip-action",children:f?"Click to deselect":"Click for details"})]})}()})})]},"actual-".concat(e.deliveryid))}))]}),Qs&&ct&&(0,P.jsxs)("div",{className:"compare-view-switcher",role:"group","aria-label":"Compare view layer",children:[(0,P.jsx)("button",{type:"button",className:"actual"===nr?"is-active":"",onClick:function(){return sr("actual")},title:"Show only the rider's actual GPS trail",children:"Actual"}),(0,P.jsx)("button",{type:"button",className:"planned"===nr?"is-active":"",onClick:function(){return sr("planned")},title:"Show only the dispatched planned route",children:"Planned"}),(0,P.jsx)("button",{type:"button",className:"combined"===nr?"is-active":"",onClick:function(){return sr("combined")},title:"Overlay planned (dashed) and actual (solid) on one map",children:"Combined"})]}),(0,P.jsx)("div",{id:"ov-tl"}),(0,P.jsx)("div",{id:"ov-br",children:(0,P.jsxs)("button",{className:"sbt ".concat(_s?"active":""),onClick:function(){if(_s)return ws(!1),Es([]),void Rs({});ws(!0),Es([]),Rs({});var e=Qs&&ct,n=e?new Map(yt.map((function(e){return[String(e.deliveryid),e.sequenceStep]}))):null,s=[];if(rt.forEach((function(r){if(Oe.has(r.id)&&(!ct||ct.id===r.id)&&(!Ue||Ue.riders.has(r.id))){var a={};r.orders.forEach((function(e){var n=e.trip_number||1;a[n]||(a[n]=[]),a[n].push(e)})),Object.entries(a).forEach((function(a){var i=(0,l.Z)(a,2),c=i[0],d=i[1],o=Ue?d.filter((function(e){return(e.pickupcustomer||e.kitchen_key||"Unknown").toLowerCase().trim()===Ue.id})):d;if(0!==o.length){var u="".concat(r.id,"-").concat(c),m=vs[u],p=(0,t.Z)(o).sort((function(e,n){return(e.step||0)-(n.step||0)})),h=ge(p),v="kitchens"===O||Ue,f=m||h;if(!(f.length<2)){var x=function(){return r.color};if(e&&r.id===ct.id){var j=p.filter(Q).map((function(e){return[parseFloat(e.droplat||e.deliverylat),parseFloat(e.droplon||e.deliverylong)]})),g=m?fe(m,j):function(){for(var e=h.length>j.length,n=[],s=0;s<j.length;s++){var r=e?s:s-1,t=e?s+1:s;r<0||r>=h.length||t>=h.length?n.push([]):n.push([h[r],h[t]])}return n}(),N=[],b=0;g.forEach((function(e,n){for(var s=Math.max(0,((null===e||void 0===e?void 0:e.length)||0)-1),r=0;r<s;r++)N[b+r]=n;b+=s})),x=function(e){var s=N[e];if(null==s)return r.color;var t=p.filter(Q)[s],a=t?n.get(String(t.deliveryid)):null;return a?(0,z.di)(a-1):r.color}}for(var y=0;y<f.length-1;y++)s.push({from:f[y],to:f[y+1],color:x(y),delay:.05*(parseInt(r.id.slice(-3))||0)+40*parseInt(c)+y*(v?40:8)})}}}))}})),s.sort((function(e,n){return e.delay-n.delay})),s.forEach((function(e,n){setTimeout((function(){Es((function(n){return[].concat((0,t.Z)(n),[e])})),n===s.length-1&&setTimeout((function(){ws(!1),Rs({})}),1e3)}),e.delay)})),e&&yt.length>0){var r=(0,t.Z)(yt),a=r.map((function(e){var n=Ns[e.deliveryid];return Array.isArray(n)&&n.length>=2?n:e.coords.map((function(e){return[e.lat,e.lng]}))})),i=s.length>0?s[s.length-1].delay:800*r.length,c=Math.max(i,600*r.length),d=c/Math.max(1,r.length),o=Date.now();requestAnimationFrame((function e(){if(Ds.current){var n=Date.now()-o,s={};r.forEach((function(e,r){var t=a[r];if(t&&!(t.length<2)){var i=r*d;if(n>=i+d)s[e.sequenceStep]=t.length;else if(n>=i){var c=(n-i)/d;s[e.sequenceStep]=Math.max(2,Math.ceil(c*t.length))}}})),Rs(s),n<c+200&&requestAnimationFrame(e)}}))}},style:{boxShadow:"var(--shadow-lg)",background:_s?"var(--accent)":"#fff"},children:[(0,P.jsx)("span",{children:_s?"\u23f9":"\u25b6"})," ",_s?"Stop":"Animate Routes"]})})]}),Qs&&ct&&(0,P.jsx)("div",{id:"compare-map-wrap",children:function(){var e=yt.length,n=yt.filter((function(e){return e.coords.length>0})).length,s=yt.filter((function(e){return e.isLoading})).length,r=e>0?Math.round(n/e*100):0,t=e>0&&n===e&&0===s,a=null!=Ar?kt.find((function(e){return e.sequenceStep===Ar})):null;return(0,P.jsxs)("div",{className:"compare-header-v2",children:[(0,P.jsxs)("div",{className:"compare-header-row",children:[(0,P.jsxs)("div",{className:"compare-title",children:[(0,P.jsx)("span",{className:"compare-title-dot",style:{background:ct.color}}),(0,P.jsx)("span",{className:"compare-title-name",children:ct.riderName}),(0,P.jsx)("span",{className:"compare-title-badge",children:"ACTUAL vs PLANNED"})]}),(0,P.jsxs)("div",{className:"compare-header-tools",children:[null!=Ar&&(0,P.jsxs)("button",{type:"button",className:"compare-overall-btn",onClick:function(){return Cr(null)},title:"Zoom out to the whole day",children:[(0,P.jsx)(E.zNX,{})," Overall"]}),(0,P.jsx)("button",{type:"button",className:"compare-timeline-toggle".concat(dr?" is-open":""),onClick:function(){return or((function(e){return!e}))},title:dr?"Hide planned/actual timeline":"Show planned/actual timeline","aria-expanded":dr,children:(0,P.jsx)(E.Yc6,{})})]})]}),dr&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:"compare-timeline-wrap",children:[(0,P.jsxs)("div",{className:"compare-timeline-container",children:[(0,P.jsxs)("div",{className:"compare-timeline-labels",children:[(0,P.jsx)("div",{className:"compare-timeline-label",children:"Planned"}),(0,P.jsx)("div",{className:"compare-timeline-label",children:"Actual"})]}),(0,P.jsxs)("div",{className:"compare-timeline-scrollable",children:[(0,P.jsx)("div",{className:"compare-timeline-track is-planned",children:_t.map((function(e,n){var s,r=String(e.orderstatus||"").toLowerCase(),t=z.Q6.has(r),a=z.us.has(r),i=Ar===e.sequenceStep,c=e.isLoading&&0===e.coordsCount,l=!e.isLoading&&0===e.coordsCount,d=(null===(s=e.order)||void 0===s?void 0:s.step)||e.sequenceStep,o=(0,z.di)(d-1),m=["compare-step",i&&"is-focused",t&&"is-delivered",a&&"is-skipped",!t&&!a&&"is-pending",c&&"is-loading",l&&"is-no-data",e.anomaly&&"is-anomaly"].filter(Boolean).join(" ");return(0,P.jsxs)(u.Fragment,{children:[n>0&&(0,P.jsx)("span",{className:"compare-step-spacer"}),(0,P.jsxs)("button",{type:"button",className:m,style:{"--step-color":o},onClick:function(){return Cr((function(n){return n===e.sequenceStep?null:e.sequenceStep}))},title:"Planned Step ".concat(d)+(e.deliverycustomer?" \xb7 ".concat(e.deliverycustomer):"")+(e.expectedTs?" \xb7 ".concat(e.expectedTs.format("hh:mm A")):"")+(e.anomaly?" \xb7 deviation flagged":""),children:[(0,P.jsx)("span",{className:"compare-step-circle",children:c?(0,P.jsx)("span",{className:"compare-step-spin"}):d}),e.expectedTs&&(0,P.jsx)("span",{className:"compare-step-tick",children:e.expectedTs.format("HH:mm")})]})]},"step-p-".concat(e.deliveryid))}))}),(0,P.jsx)("div",{className:"compare-timeline-track is-actual",children:wt.map((function(e,n){var s,r=String(e.orderstatus||"").toLowerCase(),t=z.Q6.has(r),a=z.us.has(r),i=Ar===e.sequenceStep,c=e.isLoading&&0===e.coordsCount,l=!e.isLoading&&0===e.coordsCount,d=(null===(s=e.order)||void 0===s?void 0:s.step)||e.sequenceStep,o=(0,z.di)(d-1),m=["compare-step",i&&"is-focused",t&&"is-delivered",a&&"is-skipped",!t&&!a&&"is-pending",c&&"is-loading",l&&"is-no-data",e.anomaly&&"is-anomaly"].filter(Boolean).join(" ");return(0,P.jsxs)(u.Fragment,{children:[n>0&&(0,P.jsx)("span",{className:"compare-step-spacer"}),(0,P.jsxs)("button",{type:"button",className:m,style:{"--step-color":o},onClick:function(){return Cr((function(n){return n===e.sequenceStep?null:e.sequenceStep}))},title:"Actual Visit ".concat(n+1," (Planned Step ").concat(d,")")+(e.deliverycustomer?" \xb7 ".concat(e.deliverycustomer):"")+(e.actualTs?" \xb7 ".concat(e.actualTs.format("hh:mm A")):"")+(e.anomaly?" \xb7 deviation flagged":""),children:[(0,P.jsx)("span",{className:"compare-step-circle",children:c?(0,P.jsx)("span",{className:"compare-step-spin"}):d}),e.actualTs&&(0,P.jsx)("span",{className:"compare-step-tick",children:e.actualTs.format("HH:mm")}),e.anomaly&&(0,P.jsx)("span",{className:"compare-step-flag",title:"Deviation flagged"})]})]},"step-a-".concat(e.deliveryid))}))})]})]}),(0,P.jsxs)("div",{className:"compare-progress-strip",children:[(0,P.jsx)("div",{className:"compare-progress-bar-wrap",children:(0,P.jsx)("div",{className:"compare-progress-bar-fill".concat(t?" is-done":""),style:{width:"".concat(r,"%")}})}),(0,P.jsx)("span",{className:"compare-progress-text",children:s>0?"Loading GPS\u2026 ".concat(n,"/").concat(e):"".concat(n,"/").concat(e," tracks")})]})]}),function(){var e="combined"===nr,n=a?(0,z.di)(a.sequenceStep-1):"linear-gradient(90deg, ".concat(z.XZ.slice(0,6).join(", "),")"),s=e?U:n,r=e?V:n;return(0,P.jsxs)("div",{className:"compare-legend",children:[(0,P.jsxs)("span",{className:"compare-legend-item",children:[(0,P.jsx)("span",{className:"compare-legend-swatch is-step-color is-dashed",style:{background:s}}),"Planned (dashed)"]}),(0,P.jsxs)("span",{className:"compare-legend-item",children:[(0,P.jsx)("span",{className:"compare-legend-swatch is-step-color",style:{background:r}}),"Actual GPS (solid)"]}),(0,P.jsx)("span",{className:"compare-legend-note",children:"Kalman-smoothed GPS \xb7 OSRM road-snapped"})]})}()]})]})}()}),Qs&&ct&&(0,P.jsx)(R,{focusedRider:ct,compareDeltas:kt,compareSummary:St,actualOrdered:wt,focusedCompareStep:Ar,setFocusedCompareStep:Cr,sequenceOpen:ar,setSequenceOpen:ir,expandedSeqGroups:pr,setExpandedSeqGroups:hr,onClose:function(){return Xs(!1)}})]}),vn&&(0,P.jsx)("div",{className:"dispatch-popup-center",role:"dialog","aria-label":"Order ".concat(vn.orderid," details"),onMouseEnter:function(){mn.current&&(clearTimeout(mn.current),mn.current=null)},onMouseLeave:function(){(function(e){if(!e)return!1;if(dn.current.has(String(e.orderid)))return!0;if(Qs&&ct&&null!=e.deliveryid){var n=yt.find((function(n){return String(n.deliveryid)===String(e.deliveryid)}));if(n&&Ar===n.sequenceStep)return!0}return!1})(vn)||(mn.current&&clearTimeout(mn.current),mn.current=setTimeout((function(){fn(null),mn.current=null}),200))},children:(0,P.jsxs)("div",{className:"dispatch-popup-card dispatch-popup",children:[(0,P.jsx)("button",{type:"button",className:"dispatch-popup-center-close","aria-label":"Close order details",onClick:function(){dn.current.delete(String(vn.orderid)),fn(null)},children:"\xd7"}),function(e){var n=(0,z.Cl)(e.orderstatus),s=e.rider_id||e.userid,r=z.Q6.has(String(e.orderstatus||"").toLowerCase()),t=r?null:Pt(s,e);return(0,P.jsxs)("div",{style:{height:"100%",width:"100%"},children:[(0,P.jsxs)("div",{className:"pu-header",children:[(0,P.jsxs)("div",{className:"pu-header-top",children:[(0,P.jsxs)("div",{className:"pu-id",children:["ORDER #",e.orderid]}),e.orderstatus&&(0,P.jsx)("span",{className:"pu-status-chip",style:{background:n.bg,color:n.fg},children:n.label})]}),(0,P.jsxs)("div",{className:"pu-rider",children:[(0,P.jsx)(E.pbk,{})," ",(0,P.jsx)("span",{children:e.rider_name||e.ridername||"Unassigned"})]}),(e.deliverycustomer||e.customername)&&(0,P.jsxs)("div",{className:"pu-customer",title:e.deliverycustomer||e.customername,children:[(0,P.jsx)(E.Vyx,{})," ",(0,P.jsx)("span",{children:e.deliverycustomer||e.customername})]}),null!=e.deliveryid&&(0,P.jsxs)("div",{className:"pu-delivery-id",children:["Delivery #",e.deliveryid]})]}),(0,P.jsxs)("div",{className:"pu-body",children:[je.some((function(n){return e[n.key]}))&&(0,P.jsxs)("div",{className:"pu-section",children:[(0,P.jsx)("div",{className:"pu-section-label",children:"Timeline"}),(0,P.jsx)("div",{className:"pu-timeline",children:je.map((function(n){var s=xe(e[n.key]);return s?(0,P.jsxs)("div",{className:"pu-tl-row ".concat(n.final?"delivered":""),children:[(0,P.jsx)("span",{className:"pu-tl-dot"}),(0,P.jsx)("span",{className:"pu-tl-label",children:n.label}),(0,P.jsx)("span",{className:"pu-tl-time",children:s})]},n.key):null}))})]}),(0,P.jsxs)("div",{className:"pu-section",children:[(0,P.jsx)("div",{className:"pu-section-label",children:"Details"}),(0,P.jsxs)("div",{className:"pu-details-grid",children:[(e.pickupcustomer||e.locationname||e.pickuplocation)&&(0,P.jsxs)("div",{className:"pu-detail",children:[(0,P.jsx)("div",{className:"pu-detail-icon",children:(0,P.jsx)(E.TkG,{})}),(0,P.jsxs)("div",{className:"pu-detail-body",children:[(0,P.jsx)("div",{className:"pu-detail-label",children:"Pickup"}),(0,P.jsx)("div",{className:"pu-detail-value",title:e.pickupcustomer||e.locationname||e.pickuplocation,children:e.pickupcustomer||e.locationname||e.pickuplocation})]})]}),(e.deliverysuburb||e.deliveryaddress)&&(0,P.jsxs)("div",{className:"pu-detail",children:[(0,P.jsx)("div",{className:"pu-detail-icon",children:(0,P.jsx)(E.c7Z,{})}),(0,P.jsxs)("div",{className:"pu-detail-body",children:[(0,P.jsx)("div",{className:"pu-detail-label",children:"Drop"}),(0,P.jsx)("div",{className:"pu-detail-value",title:e.deliveryaddress||e.deliverysuburb,children:e.deliverysuburb||J(e.deliveryaddress)})]})]}),e.zone_name&&(0,P.jsxs)("div",{className:"pu-detail",children:[(0,P.jsx)("div",{className:"pu-detail-icon",children:(0,P.jsx)(E.PKO,{})}),(0,P.jsxs)("div",{className:"pu-detail-body",children:[(0,P.jsx)("div",{className:"pu-detail-label",children:"Zone"}),(0,P.jsx)("div",{className:"pu-detail-value",title:e.zone_name,children:e.zone_name})]})]}),(e.rider_id||e.userid)&&(0,P.jsxs)("div",{className:"pu-detail",children:[(0,P.jsx)("div",{className:"pu-detail-icon",children:(0,P.jsx)(E.pbk,{})}),(0,P.jsxs)("div",{className:"pu-detail-body",children:[(0,P.jsx)("div",{className:"pu-detail-label",children:"Rider ID"}),(0,P.jsxs)("div",{className:"pu-detail-value",children:["#",e.rider_id||e.userid]})]})]})]}),(null!=e.actualkms||!r&&null!=e.riderkms||null!==t)&&(0,P.jsxs)("div",{className:"pu-distance-row",children:[null!=e.actualkms&&""!==e.actualkms&&(0,P.jsxs)("div",{className:"pu-distance-chip",children:[(0,P.jsx)("span",{className:"pu-distance-icon",children:(0,P.jsx)(E.v93,{})}),(0,P.jsx)("span",{className:"pu-distance-label",children:"Actual"}),(0,P.jsxs)("span",{className:"pu-distance-value",children:[e.actualkms," km"]})]}),!r&&null!=e.riderkms&&""!==e.riderkms&&(0,P.jsxs)("div",{className:"pu-distance-chip",children:[(0,P.jsx)("span",{className:"pu-distance-icon",children:(0,P.jsx)(E.MCF,{})}),(0,P.jsx)("span",{className:"pu-distance-label",children:"Rider"}),(0,P.jsxs)("span",{className:"pu-distance-value",children:[parseFloat(e.riderkms).toFixed(2)," km"]})]}),null!==t&&(0,P.jsxs)("div",{className:"pu-distance-chip pu-est-meters",title:"Estimated distance to drop location",children:[(0,P.jsx)("span",{className:"pu-distance-icon",children:(0,P.jsx)(E.x$F,{})}),(0,P.jsx)("span",{className:"pu-distance-label",children:"Est. to Drop"}),(0,P.jsx)("span",{className:"pu-distance-value",children:Rt(t)})]})]})]})]})]})}(vn)]})})]}),!m&&"analysis"===K&&(0,P.jsxs)("div",{id:"dispatch-analysis",children:[(0,P.jsx)("div",{className:"da-picker-row",children:_e.map((function(e){var n,s=de[e.key],r=Ce===e.key,t=!1===(null===s||void 0===s||null===(n=s.data)||void 0===n?void 0:n.success),a=t?"#fee2e2":s?"".concat(e.color,"22"):"#f1f5f9",i=t?"#dc2626":s?e.color:"#64748b",c=r?"Loading\u2026":t?"! Failed":s?"\u2713 ".concat(s.fetchedAt):"Fetch",l=Pe===e.key;return(0,P.jsxs)("button",{type:"button",className:"da-picker ".concat(s?"has-data":""," ").concat(r?"is-loading":""," ").concat(l?"is-active":""),onClick:function(){return!r&&Le(e.key)},style:{borderColor:l?e.color:t?"#fecaca":s?e.border:"#e2e8f0",background:t?"#fef2f2":s?e.bg:"#ffffff",boxShadow:l?"0 0 0 2px ".concat(e.color,"33"):void 0},disabled:r,children:[(0,P.jsxs)("div",{className:"da-picker-head",children:[(0,P.jsx)("div",{className:"da-picker-badge",style:{background:"".concat(e.color,"22"),color:e.color},children:e.label[0]}),(0,P.jsxs)("div",{className:"da-picker-meta",children:[(0,P.jsx)("div",{className:"da-picker-name",children:e.label}),(0,P.jsx)("div",{className:"da-picker-range",children:e.timeRange})]}),(0,P.jsx)("span",{className:"da-picker-status",style:{background:a,color:i},children:c})]}),(0,P.jsx)("div",{className:"da-picker-sub",children:e.sub})]},e.key)}))}),function(){var e,n,s,r;if(!Pe)return(0,P.jsx)("div",{className:"da-empty",children:"Pick a batch above to view its efficiency analysis."});var t=_e.find((function(e){return e.key===Pe})),a=de[Pe],i=Ce===Pe;if(i&&!a)return(0,P.jsxs)("div",{className:"da-empty",children:["Loading ",t.label," batch\u2026"]});if(!a)return null;var c,l,d=a.data||{};if(!1===d.success)return(0,P.jsxs)("div",{className:"da-result-card da-result-card-error",style:{borderColor:"#fecaca",borderTopColor:"#ef4444"},children:[(0,P.jsxs)("div",{className:"da-result-head",children:[(0,P.jsxs)("div",{children:[(0,P.jsxs)("div",{className:"da-result-title",children:[t.label," Batch"]}),(0,P.jsxs)("div",{className:"da-result-sub",children:[t.timeRange," \xb7 Fetched at ",a.fetchedAt]})]}),(0,P.jsx)("button",{type:"button",className:"da-result-refresh",title:"Retry",onClick:function(){return Le(Pe)},disabled:i,style:{background:"#fee2e2",color:"#dc2626"},children:(0,P.jsx)(E.la_,{})})]}),(0,P.jsxs)("div",{className:"da-error",children:[(0,P.jsxs)("div",{className:"da-error-title",children:[(0,P.jsx)(E.wr$,{}),(0,P.jsx)("span",{children:(null===d||void 0===d||null===(c=d.error)||void 0===c?void 0:c.code)||"Request failed"})]}),(0,P.jsx)("div",{className:"da-error-msg",children:(null===d||void 0===d||null===(l=d.error)||void 0===l?void 0:l.message)||"The server returned an error."}),(null===d||void 0===d?void 0:d.request_id)&&(0,P.jsxs)("div",{className:"da-error-meta",children:["request_id: ",d.request_id]})]})]});var u=d.fleet_summary||{},m=Array.isArray(d.rider_timelines)?d.rider_timelines:[],p=Array.isArray(d.substitution_opportunities)?d.substitution_opportunities:[],h=d.top_recommendation,v=!(!h||!h.idle_rider_name&&!h.idle_rider_id),f=!!(h&&h.action&&"none"!==h.action&&v),x=d.window||{},j=[{label:"Total Orders",value:we(u.total_orders)},{label:"Total Riders",value:we(u.total_riders)},{label:"Avg Orders/Rider",value:null!==(e=u.orders_per_rider_avg)&&void 0!==e?e:"\u2014"},{label:"Fleet Start",value:u.fleet_start||"\u2014"},{label:"Fleet Done",value:u.fleet_done||"\u2014"},{label:"Duration",value:null!=u.total_duration_minutes?"".concat(u.total_duration_minutes," min"):"\u2014"}];return(0,P.jsxs)("div",{className:"da-detail",children:[(0,P.jsxs)("div",{className:"da-detail-head",style:{borderTopColor:t.color,background:t.bg},children:[(0,P.jsxs)("div",{children:[(0,P.jsxs)("div",{className:"da-detail-title",children:[t.label," Batch",(0,P.jsxs)("span",{className:"da-detail-sub-inline",children:[d.date?" \xb7 ".concat(d.date):"",x.from&&x.to?" \xb7 ".concat(x.from," \u2013 ").concat(x.to):""]})]}),(0,P.jsxs)("div",{className:"da-detail-sub",children:["Fetched at ",a.fetchedAt," \xb7 Input deliveries: ",null!==(n=d.input_delivery_count)&&void 0!==n?n:"\u2014"]})]}),(0,P.jsx)("button",{type:"button",className:"da-result-refresh",title:"Refresh",onClick:function(){oe((function(e){var n=(0,o.Z)({},e);return delete n[Pe],n})),De.mutate({batch:Pe,tenantId:916})},disabled:i,style:{background:"".concat(t.color,"22"),color:t.color},children:(0,P.jsx)(E.la_,{})})]}),(0,P.jsxs)("div",{className:"da-section",children:[(0,P.jsx)("div",{className:"da-section-label",children:"Fleet Summary"}),(0,P.jsx)("div",{className:"da-metric-grid da-metric-grid-3",children:j.map((function(e){return(0,P.jsxs)("div",{className:"da-metric",children:[(0,P.jsx)("div",{className:"da-metric-label",children:e.label}),(0,P.jsx)("div",{className:"da-metric-value",children:e.value})]},e.label)}))})]}),f?(0,P.jsxs)("div",{className:"da-section",children:[(0,P.jsx)("div",{className:"da-section-label",children:"Top Recommendation"}),(0,P.jsxs)("div",{className:"da-rec",children:[(0,P.jsxs)("div",{className:"da-rec-head",children:[(0,P.jsxs)("div",{className:"da-rec-action",children:[(0,P.jsx)(E.YgO,{}),(0,P.jsx)("span",{children:(h.action||"recommendation").replaceAll("_"," ")})]}),null!=h.fleet_improvement_minutes&&(0,P.jsxs)("span",{className:"da-rec-improve",style:h.fleet_improvement_minutes>0?{background:"#dcfce7",color:"#166534"}:{background:"#f1f5f9",color:"#475569"},children:[h.fleet_improvement_minutes>0?"\u2191":"\u2022"," Fleet improves by ",h.fleet_improvement_minutes," min"]})]}),(0,P.jsxs)("div",{className:"da-rec-line",children:[(0,P.jsx)("strong",{children:h.idle_rider_name||"Rider ".concat(h.idle_rider_id)}),h.primary_kitchen&&(0,P.jsxs)(P.Fragment,{children:[" \xb7 primary kitchen ",(0,P.jsx)("strong",{children:h.primary_kitchen})]}),h.second_kitchen&&(0,P.jsxs)(P.Fragment,{children:[" \u2192 also serve ",(0,P.jsx)("strong",{children:h.second_kitchen})," after ",h.second_kitchen_dispatch_after||"\u2014"]})]}),h.description&&(0,P.jsx)("div",{className:"da-rec-desc",children:h.description}),(null===(s=h.activate_when)||void 0===s||null===(r=s.rules)||void 0===r?void 0:r.length)>0&&(0,P.jsxs)("div",{className:"da-rec-rules",children:[(0,P.jsxs)("div",{className:"da-rec-rules-head",children:["Activate when (",h.activate_when.condition||"AND","):"]}),h.activate_when.rules.map((function(e,n){return(0,P.jsxs)("div",{className:"da-rec-rule",children:[(0,P.jsxs)("code",{children:[e.field," ",e.operator," ",e.value]}),e.reason&&(0,P.jsxs)("span",{className:"da-rec-rule-why",children:[" \u2014 ",e.reason]})]},n)}))]})]})]}):(0,P.jsxs)("div",{className:"da-section",children:[(0,P.jsx)("div",{className:"da-section-label",children:"Top Recommendation"}),(0,P.jsx)("div",{className:"da-rec da-rec-empty",children:(0,P.jsxs)("div",{className:"da-rec-action",children:[(0,P.jsx)(E.YgO,{}),(0,P.jsx)("span",{children:"Fleet is balanced, no reassignment needed right now."})]})})]}),m.length>0&&(0,P.jsxs)("div",{className:"da-section",children:[(0,P.jsxs)("div",{className:"da-section-label",children:["Rider Timelines ",(0,P.jsxs)("span",{className:"da-section-count",children:["(",m.length,")"]})]}),(0,P.jsx)("div",{className:"da-timeline-list",children:m.map((function(e){var n="active"===String(e.status||"").toLowerCase();return(0,P.jsxs)("div",{className:"da-timeline-card",children:[(0,P.jsxs)("div",{className:"da-timeline-top",children:[(0,P.jsxs)("div",{className:"da-timeline-name",children:[(0,P.jsx)(E.pbk,{style:{color:t.color}}),(0,P.jsx)("span",{children:e.name}),(0,P.jsxs)("span",{className:"da-timeline-id",children:["#",e.userid]})]}),(0,P.jsx)("span",{className:"da-pill ".concat(n?"is-active":"is-idle"),children:e.status})]}),(0,P.jsxs)("div",{className:"da-timeline-mid",children:[e.kitchen&&(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.TkG,{})," ",e.kitchen]}),(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.ByW,{})," ",e.order_count," orders"]}),(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.dKE,{})," ",e.started_at," \u2192 ",e.finished_at]}),(0,P.jsxs)("span",{className:"da-chip",style:e.idle_minutes>30?{background:"#fef3c7",color:"#92400e"}:void 0,children:[(0,P.jsx)(E.Vqd,{})," ",e.idle_minutes," min idle"]})]})]},e.userid)}))})]}),p.length>0&&(0,P.jsxs)("div",{className:"da-section",children:[(0,P.jsxs)("div",{className:"da-section-label",children:["Substitution Opportunities ",(0,P.jsxs)("span",{className:"da-section-count",children:["(",p.length,")"]})]}),(0,P.jsx)("div",{className:"da-sub-list",children:p.map((function(e,n){var s,r=e.idle_rider||{},t=e.most_relieved_rider||{},a=null!==(s=e.fleet_improvement_minutes)&&void 0!==s?s:0;return(0,P.jsxs)("div",{className:"da-sub-card",children:[(0,P.jsxs)("div",{className:"da-sub-head",children:[(0,P.jsxs)("div",{className:"da-sub-title",children:[(0,P.jsx)("strong",{children:r.name||"Rider ".concat(r.userid)})," ","covers ",(0,P.jsx)("strong",{children:e.target_kitchen})]}),(0,P.jsxs)("span",{className:"da-sub-improve",style:a>0?{background:"#dcfce7",color:"#166534"}:{background:"#f1f5f9",color:"#475569"},children:["Fleet ",a>0?"\u2191":"\u2022"," ",a," min"]})]}),(0,P.jsxs)("div",{className:"da-sub-meta",children:[(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.v93,{})," ",e.travel_to_kitchen_km," km"]}),(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.Vqd,{})," ",e.travel_to_kitchen_minutes," min travel"]}),(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.dKE,{})," arrives ",e.arrive_at_kitchen]}),(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.ByW,{})," ",e.total_orders_transferred," orders"]}),(0,P.jsxs)("span",{className:"da-chip",children:[(0,P.jsx)(E.v93,{})," +",e.extra_km_for_idle_rider," km for idle rider"]})]}),t.name&&(0,P.jsxs)("div",{className:"da-sub-relieved",children:[(0,P.jsx)(E.gSd,{}),"Most relieved: ",(0,P.jsx)("strong",{children:t.name})," ","(",t.original_finish," \u2192 ",t.new_finish,", saves"," ",t.time_saved_minutes," min)"]}),Array.isArray(e.orders_to_transfer)&&e.orders_to_transfer.length>0&&(0,P.jsxs)("div",{className:"da-sub-transfers",children:[(0,P.jsx)("div",{className:"da-sub-transfers-head",children:"Orders transferred"}),e.orders_to_transfer.map((function(e){var n,s=null!==(n=e.improvement_minutes)&&void 0!==n?n:0;return(0,P.jsxs)("div",{className:"da-transfer-row",children:[(0,P.jsxs)("span",{className:"da-transfer-id",children:["#",e.deliveryid]}),(0,P.jsxs)("span",{className:"da-transfer-from",children:["from ",e.from_rider_name]}),(0,P.jsxs)("span",{className:"da-transfer-time",children:[e.original_delivery_time," \u2192 ",e.estimated_delivery_time]}),(0,P.jsxs)("span",{className:"da-transfer-imp",style:s>0?{background:"#dcfce7",color:"#166534"}:s<0?{background:"#fee2e2",color:"#991b1b"}:{background:"#f1f5f9",color:"#475569"},children:[s>0?"+":"",s," min"]})]},e.deliveryid)}))]})]},n)}))})]})]})}()]})]})}},29127:function(e,n,s){s.d(n,{Cl:function(){return a},P0:function(){return d},Q6:function(){return i},XZ:function(){return o},Y_:function(){return l},di:function(){return u},us:function(){return c},xw:function(){return m}});var r=s(93433),t={created:{label:"Created",bg:"#3b82f6",fg:"#fff"},pending:{label:"Pending",bg:"#f59e0b",fg:"#fff"},accepted:{label:"Accepted",bg:"#8b5cf6",fg:"#fff"},arrived:{label:"Arrived",bg:"#ea580c",fg:"#fff"},picked:{label:"Picked",bg:"#0ea5e9",fg:"#fff"},active:{label:"Active",bg:"#0ea5e9",fg:"#fff"},delivered:{label:"Delivered",bg:"#22c55e",fg:"#fff"},skipped:{label:"Skipped",bg:"#94a3b8",fg:"#fff"},cancelled:{label:"Cancelled",bg:"#ef4444",fg:"#fff"}},a=function(e){return t[String(e||"").toLowerCase()]||{label:e||"Unknown",bg:"#64748b",fg:"#fff"}},i=new Set(["delivered"]),c=new Set(["cancelled","skipped"]),l=function(e){var n=String((null===e||void 0===e?void 0:e.orderstatus)||"").toLowerCase();return!i.has(n)&&!c.has(n)},d=function(e){return Array.isArray(e)&&e.length&&(0,r.Z)(e).sort((function(e,n){var s=e.trip_number||1,r=n.trip_number||1;return s!==r?s-r:(e.step||0)-(n.step||0)})).find(l)||null},o=["#2563eb","#dc2626","#16a34a","#ea580c","#9333ea","#0891b2","#ca8a04","#db2777","#0f766e","#7c3aed","#65a30d","#0284c7","#b91c1c","#15803d","#a16207","#86198f"],u=function(e){return o[(e%o.length+o.length)%o.length]},m=function(e){if(null==e)return"";var n=["th","st","nd","rd"],s=e%100;return e+(n[(s-20)%10]||n[s]||n[0])}}}]); |