PageSourceSearch

https://deliverimates-production.up.railway.app/assets/Assistant-CcAAsysT.js

js deliverimates-production.up.railway.app collected 2026-10-03 12:13:07 UTC 76,884 bytes, 14 lines download raw bytes

vendor: 4,097 bytes, line 1
1import{c as Sr,r as u,bj as Ge,c6 as Ar,j as i,L as de,a as we,g as Nr,i as Tt,T as ue,a7 as Ir,cL as Pr,ab as Ct,E as _t,o as Bt,p as Dt,aa as kr,ay as Er,a8 as Or,aK as be,z as Tr,cM as Cr,bI as _r,J as Br,an as Dr,M as $r,N as Lr,cN as Mr,m as Rr,B as te,X as Fr,aJ as zr,ac as Kr,F as Wr,bg as Hr,cI as Ur,bi as qr}from"./index-Db4qfLtJ.js";import{z as Vr,A as xe,i as Gr,B as ce,E as $t,r as Ye,F as Qe,S as Yr,e as re,G as Qr,H as Y,I as Jr,J as Xr,K as Zr,M as Lt,N as ea,O as ta,P as Mt,Q as ra,U as aa,V as na,W as ia,_ as sa,u as me,$ as oa,a0 as it,a1 as la,a2 as ca,a3 as da,a4 as ua,a5 as ma,a6 as Pe,a7 as Me,k as Re,a8 as fa,a9 as Rt,aa as pa,ab as ha,ac as va,ad as ya,ae as se,af as xa,ag as ae,ah as ne,ai as Ft,aj as zt,ak as Kt,al as ga,am as ba,an as st,ao as wa,ap as ot,aq as ja,L as je,D as Je,ar as Sa,c as Wt,as as Aa,at as Na,au as Ia,Z as Xe,av as q,aw as Ht,ax as Pa,ay as ka,az as Ea,aA as Oa,aB as Ta,aC as Ca,aD as Ut,aE as _a,aF as Ba,aG as Da,aH as lt,aI as qt,aJ as $a,aK as La,aL as Ma,aM as Ra,aN as Fa,aO as za,aP as Ka,aQ as Wa,aR as ct,aS as Ha,aT as Ua,q as qa,R as Va,t as Ga,X as Ya,Y as Qa,T as Ja,v as Xa}from"./LineChart-CQf0FcUS.js";import{E as Vt}from"./external-link-BdKUXdmw.js";import{U as Za}from"./user-round-C53Gbq0i.js";import{I as en}from"./info-BUQseFxi.js";import{Q as Gt}from"./QueryErrorPanel-B1gDa5_u.js";import{A as tn}from"./auto-growing-textarea-CJATNMnZ.js";import{S as Fe}from"./skeleton-8NjDJt9K.js";import{P as Yt}from"./plus-MaSTFP3I.js";import{A as rn}from"./arrow-down-4OA5f-oV.js";import{S as an}from"./square-C86blp80.js";import{S as nn}from"./send-BKG_37I8.js";const sn=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],on=Sr("history",sn),Qt=Math.cos,Se=Math.sin,V=Math.sqrt,Ae=Math.PI,ke=2*Ae,Ze={draw(e,t){const r=V(t/Ae);e.moveTo(r,0),e.arc(0,0,r,0,ke)}},ln={draw(e,t){const r=V(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},Jt=V(1/3),cn=Jt*2,dn={draw(e,t){const r=V(t/cn),a=r*Jt;e.moveTo(0,-r),e.lineTo(a,0),e.lineTo(0,r),e.lineTo(-a,0),e.closePath()}},un={draw(e,t){const r=V(t),a=-r/2;e.rect(a,a,r,r)}},mn=.8908130915292852,Xt=Se(Ae/10)/Se(7*Ae/10),fn=Se(ke/10)*Xt,pn=-Qt(ke/10)*Xt,hn={draw(e,t){const r=V(t*mn),a=fn*r,n=pn*r;e.moveTo(0,-r),e.lineTo(a,n);for(let s=1;s<5;++s){const o=ke*s/5,d=Qt(o),c=Se(o);e.lineTo(c*r,-d*r),e.lineTo(d*a-c*n,c*a+d*n)}e.closePath()}},De=V(3),vn={draw(e,t){const r=-V(t/(De*3));e.moveTo(0,r*2),e.lineTo(-De*r,-r),e.lineTo(De*r,-r),e.closePath()}},z=-.5,K=V(3)/2,ze=1/V(12),yn=(ze/2+1)*3,xn={draw(e,t){const r=V(t/yn),a=r/2,n=r*ze,s=a,o=r*ze+r,d=-s,c=o;e.moveTo(a,n),e.lineTo(s,o),e.lineTo(d,c),e.lineTo(z*a-K*n,K*a+z*n),e.lineTo(z*s-K*o,K*s+z*o),e.lineTo(z*d-K*c,K*d+z*c),e.lineTo(z*a+K*n,z*n-K*a),e.lineTo(z*s+K*o,z*o-K*s),e.lineTo(z*d+K*c,z*c-K*d),e.closePath()}};function gn(e,t){let r=null,a=Vr(n);e=typeof e=="function"?e:xe(e||Ze),t=typeof t=="function"?t:xe(t===void 0?64:+t);function n(){let s;if(r||(r=s=a()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),s)return r=null,s+""||null}return n.type=function(s){return arguments.length?(e=typeof s=="function"?s:xe(s),n):e},n.size=function(s){return arguments.length?(t=typeof s=="function"?s:xe(+s),n):t},n.context=function(s){return arguments.length?(r=s??null,n):r},n}var bn=["type","size","sizeType"];function Ke(){return Ke=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},Ke.apply(null,arguments)}function dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function ut(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};
1t%2?dt(Object(r),!0).forEach(function(a){wn(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function wn(e,t,r){return(t=jn(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jn(e){var t=Sn(e,"string");return typeof t=="symbol"?t:t+""}function Sn(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function An(e,t){if(e==null)return{};var r,a,n=Nn(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Nn(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}var Zt={symbolCircle:Ze,symbolCross:ln,symbolDiamond:dn,symbolSquare:un,symbolStar:hn,symbolTriangle:vn,symbolWye:xn},In=Math.PI/180,Pn=e=>{var t="symbol".concat($t(e));return Zt[t]||Ze},kn=(e,t,r)=>{if(t==="area")return e;switch(r){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var a=18*In;return 1.25*e*e*(Math.tan(a)-Math.tan(a*2)*Math.tan(a)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},En=(e,t)=>{Zt["symbol".concat($t(e))]=t},er=e=>{var t=e.type,r=t===void 0?"circle":t,a=e.size,n=a===void 0?64:a,s=e.sizeType,o=s===void 0?"area":s,d=An(e,bn),c=ut(ut({},d),{},{type:r,size:n,sizeType:o}),l="circle";typeof r=="string"&&(l=r);var m=()=>{var j=Pn(l),x=gn().type(j).size(kn(n,o,l)),v=x();if(v!==null)return v},f=c.className,h=c.cx,y=c.cy,p=Gr(c);return ce(h)&&ce(y)&&ce(n)?u.createElement("path",Ke({}
1,p,{className:Ge("recharts-symbols",f),transform:"translate(".concat(h,", ").concat(y,")"),d:m()})):null};er.registerSymbol=En;function Ne(){return Ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},Ne.apply(null,arguments)}function mt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function tr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?mt(Object(r),!0).forEach(function(a){On(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mt(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function On(e,t,r){return(t=Tn(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Tn(e){var t=Cn(e,"string");return typeof t=="symbol"?t:t+""}function Cn(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var W=32,_n={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle",labelStyle:{}};function Bn(e){if(typeof e=="object"&&e!==null&&"strokeDasharray"in e)return String(e.strokeDasharray)}function Dn(e){var t=e.data,r=e.iconType,a=e.inactiveColor,n=W/2,s=W/6,o=W/3,d=t.inactive?a:t.color,c=r??t.type;if(c==="none")return null;if(c==="plainline")return u.createElement("line",{strokeWidth:4,fill:"none",stroke:d,strokeDasharray:Bn(t.payload),x1:0,y1:n,x2:W,y2:n,className:"recharts-legend-icon"});if(c==="line")return u.createElement("path",{strokeWidth:4,fill:"none",stroke:d,d:"M0,".concat(n,"h").concat(o,`
2            A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(n,`
3            H`).concat(W,"M").concat(2*o,",").concat(n,`
4            A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(n),className:"recharts-legend-icon"});if(c==="rect")return u.createElement("path",{stroke:"none",fill:d,d:"M0,".concat(W/8,"h").concat(W,"v").concat(W*3/4,"h").concat(-W,"z"),className:"recharts-legend-icon"});if(u.isValidElement(t.legendIcon)){var l=tr({},t);return delete l.legendIcon,u.cloneElement(t.legendIcon,l)}return u.createElement(er,{fill:d,cx:n,cy:n,size:W,sizeType:"diameter",type:c})}function $n(e){var t=e.payload,r=e.iconSize,a=e.layout,n=e.formatter,s=e.inactiveColor,o=e.iconType,d=e.labelStyle,c={x:0,y:0,width:W,height:W},l={display:a==="horizontal"?"inline-block":"block",marginRight:10,whiteSpace:"nowrap"},m={display:"inline-block",verticalAlign:"middle",marginRight:4};return t.map((f,h)=>{var y,p,j=f.formatter||n,x=Ge({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:f.inactive});if(f.type==="none")return null;var v=typeof d=="object"?tr({},d):{};v.color=f.inactive?s:v.color||f.color,(y=v.whiteSpace)!==null&&y!==void 0||(v.whiteSpace="normal"),(p=v.overflowWrap)!==null&&p!==void 0||(v.overflowWrap="break-word");var g=j?j(f.value,f,h):f.value;return u.createElement("li",Ne({className:x,style:l,key:"legend-item-".concat(h)},Qe(e,f,h)),u.createElement(Yr,{width:r,height:r,viewBox:c,style:m,"aria-label":f.value==null?"legend icon":"".concat(f.value," legend icon")},u.createElement(Dn,{data:f,iconType:o,inactiveColor:s})),u.createElement("span",{className:"recharts-legend-item-text",style:v},g))})}var Ln=e=>{var t=Ye(e,_n),r=t.payload,a=t.layout,n=t.align;if(!r||!r.length)return null;var s={padding:0,margin:0,textAlign:a==="horizontal"?n:"left"};return u.createElement("ul",{className:"recharts-default-legend",style:s},u.createElement($n,Ne({},t,{payload:r})))};function Mn(){return re(Qr)}var Rn=Y([Jr,Xr,Zr],(e,t,r)=>({x:r.left||0,y:r.top||0,width:Math.max(e-(r.left||0)-(r.right||0),0),height:Math.max(t-(r.top||0)-(r.bottom||0),0)}));function Fn(e,t){var r;if(e==="start"&&t==="start")return"";var a={start:"0",middle:"-50%",end:"-100%"},n={start:"0",middle:"-50%",end:"-100%"},s=e==="inherit"?"0":a[e],o=(r=n[t])!==null&&r!==void 0?r:"0";return"translate(".concat(s,", ").concat(o,")")}var zn=["contextPayload"];function We(){return We=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},We.apply(null,arguments)}function Kn(e,t){return qn(e)||Un(e,t)||Hn(e,t)||Wn()}
4function Wn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
5In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hn(e,t){if(e){if(typeof e=="string")return ft(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ft(e,t):void 0}}function ft(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function Un(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,n,s,o,d=[],c=!0,l=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(c=(a=s.call(r)).done)&&(d.push(a.value),d.length!==t);c=!0);}catch(m){l=!0,n=m}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(l)throw n}}return d}}function qn(e){if(Array.isArray(e))return e}function pt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function ie(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pt(Object(r),!0).forEach(function(a){Vn(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function Vn(e,t,r){return(t=Gn(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Gn(e){var t=Yn(e,"string");return typeof t=="symbol"?t:t+""}function Yn(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Qn(e,t){if(e==null)return{};var r,a,n=Jn(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Jn(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}function Xn(e){return e.value}function Zn(e){var t=e.contextPayload,r=Qn(e,zn),a=la(t,e.payloadUniqBy,Xn),n=ie(ie({},r),{},{payload:a});return u.isValidElement(e.content)?u.cloneElement(e.content,n):typeof e.content=="function"?u.createElement(e.content,n):u.createElement(Ln,n)}function ei(e){return e==="left"||e==="right"||e==="insideLeft"||e==="insideRight"?"vertical":"horizontal"}function ti(e,t){return t==null?null:Mt(t)?Rn(e):sa(e)}function ri(e,t,r){return e==="top"?{top:r.height+t}:e==="bottom"?{top:-r.height-t}:e==="left"?{left:r.width+t}:e==="right"?{left:-r.width-t}:{}}function ai(e,t,r,a,n,s){var o=t.layout,d=t.align,c=t.verticalAlign,l,m;return(!e||(e.left===void 0||e.left===null)&&(e.right===void 0||e.right===null))&&(d==="center"&&o==="vertical"?l={left:((a||0)-s.width)/2}:l=d==="right"?{right:r&&r.right||0}:{left:r&&r.left||0}),(!e||(e.top===void 0||e.top===null)&&(e.bottom===void 0||e.bottom===null))&&(c==="middle"?m={top:((n||0)-s.height)/2}:m=c==="bottom"?{bottom:r&&r.bottom||0}:{top:r&&r.top||0}),ie(ie({},l),m)}function ni(e){var t=e.align,r=e.layout,a=e.verticalAlign,n=e.itemSorter,s=e.position,o=e.offset,d=me();return u.useLayoutEffect(()=>{d(oa({align:t,layout:r,verticalAlign:a,itemSorter:n,position:s,offset:o}))},[d,t,r,a,n,s,o]),null}function ii(e){var t=e.width,r=e.height,a=me();return u.useLayoutEffect(()=>{a(it({width:t,height:r}))},[a,t,r]),u.useLayoutEffect(()=>()=>{a(it({width:0,height:0}))},[a]),null}function si(e,t,r,a){return e==="vertical"&&t!=null?{height:t}:e==="horizontal"?{width:r||a}:null}var oi={align:"center",iconSize:14,inactiveColor:"#ccc",itemSorter:"value",labelStyle:{},layout:"auto",verticalAlign:"bottom",offset:0};function li(e){var t,r,a,n,s,o,d,c,l=Ye(e,oi),m=e.layout&&e.layout!=="auto"?e.layout:ei(l.position),f=Mn(),h=ea(),y=ta(),p=re(F=>ti(F,l.position)),j=l.width,x=l.height,v=l.wrapperStyle,g=l.portal,P=g==null&&(l.position==null||Mt(l.position)),b=ra([f]),I=Kn(b,2),A=I[0],D=I[1],N=aa(),C=na();if(N==null||C==null||l.position!=null&&p==null)return null;var $=N-(y?.left||0)-(y?.right||0),O=si(m,x,j,$),k=l.position==null?null:ia({viewBox:p??{x:0,y:0,width:N,height:C},position:l.position,offset:(t=l.offset)!==null&&t!==void 0?t:0}),_=ri(l.position,(r=l.offset)!==null&&r!==void 0?r:0,A),E=m==="vertical"?((a=p?.width)!==null&&a!==void 0?a:0)/2:(n=p?.width)!==null&&n!==void 0?n:0,w=m==="horizontal"?((s=p?.height)!==null&&s!==void 0?s:0)/2:(o=p?.height)!==null&&o!==void 0?o:0,T=k?{width:"max-content",height:"max-content",maxWidth:E,maxHeight:w,overflowY:"auto",top:k.y+((d=_.top)!==null&&d!==void 0?d:0),left:k.x+((c=_.left)!==null&&c!==void 0?c:0),transform:Fn(k.horizontalAnchor,k.verticalAnchor)}:ai(v,l,y,N,C,A),M=g?v:ie(ie({position:"absolute",width:O?.width||j||"auto",height:O?.height||x||"auto"},T),v),L=g??h;if(L==null||f==null)return null;var R=u.createElement("div",{className:"recharts-legend-wrapper",style:M,ref:D},u.createElement(ni,{layout:m,align:l.align,verticalAlign:l.verticalAlign,itemSorter:l.itemSorter,position:l.position,offset:l.offset}),P&&u.createElement(ii,A),u.createElement(Zn,We({},l,{layout:m}
5,O,{margin:y,chartWidth:N,chartHeight:C,contextPayload:f})));return Ar.createPortal(R,L)}var rr=u.memo(li,Lt);rr.displayName="Legend";var ar=e=>null;ar.displayName="Cell";var nr=(e,t,r)=>{var a=me();return(n,s)=>o=>{e?.(n,s,o),a(ca({activeIndex:String(s),activeDataKey:t,activeCoordinate:n.tooltipPosition,activeGraphicalItemId:r}))}},ir=e=>{var t=me();return(r,a)=>n=>{e?.(r,a,n),t(da())}},sr=(e,t,r)=>{var a=me();return(n,s)=>o=>{e?.(n,s,o),a(ua({activeIndex:String(s),activeDataKey:t,activeCoordinate:n.tooltipPosition,activeGraphicalItemId:r}))}};function ci(e,t){return fi(e)||mi(e,t)||ui(e,t)||di()}function di(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
6In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ui(e,t){if(e){if(typeof e=="string")return ht(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ht(e,t):void 0}}function ht(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function mi(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,n,s,o,d=[],c=!0,l=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(c=(a=s.call(r)).done)&&(d.push(a.value),d.length!==t);c=!0);}catch(m){l=!0,n=m}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(l)throw n}}return d}}function fi(e){if(Array.isArray(e))return e}var vt=(e,t,r)=>{var a=r??e;if(!Pe(a))return Me(a,t,0)},pi=(e,t,r)=>{var a={},n=e.filter(ma),s=e.filter(l=>l.stackId==null),o=n.reduce((l,m)=>{var f=l[m.stackId];return f==null&&(f=[]),f.push(m),l[m.stackId]=f,l},a),d=Object.entries(o).map(l=>{var m,f=ci(l,2),h=f[0],y=f[1],p=y.map(x=>x.dataKey),j=vt(t,r,(m=y[0])===null||m===void 0?void 0:m.barSize);return{stackId:h,dataKeys:p,barSize:j}}),c=s.map(l=>{var m=[l.dataKey].filter(h=>h!=null),f=vt(t,r,l.barSize);return{stackId:void 0,dataKeys:m,barSize:f}});return[...d,...c]};function yt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function ge(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?yt(Object(r),!0).forEach(function(a){hi(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):yt(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function hi(e,t,r){return(t=vi(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vi(e){var t=yi(e,"string");return typeof t=="symbol"?t:t+""}function yi(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xi(e,t,r,a,n){var s,o=a.length;if(!(o<1)){var d=Me(e,r,0,!0),c,l=[];if(Re((s=a[0])===null||s===void 0?void 0:s.barSize)){var m=!1,f=r/o,h=a.reduce((g,P)=>g+(P.barSize||0),0);h+=(o-1)*d,h>=r&&(h-=(o-1)*d,d=0),h>=r&&f>0&&(m=!0,f*=.9,h=o*f);var y=Math.round((r-h)/2),p={offset:y-d,size:0};c=a.reduce((g,P)=>{var b,I={stackId:P.stackId,dataKeys:P.dataKeys,position:{offset:p.offset+p.size+d,size:m?f:(b=P.barSize)!==null&&b!==void 0?b:0}},A=[...g,I];return p=I.position,A},l)}else{var j=Me(t,r,0,!0);r-2*j-(o-1)*d<=0&&(d=0);var x=(r-2*j-(o-1)*d)/o;x>1&&(x=Math.round(x));var v=Re(n)?Math.min(x,n):x;c=a.reduce((g,P,b)=>[...g,{stackId:P.stackId,dataKeys:P.dataKeys,position:{offset:j+o*(x-v)/2+(v+d)*b,size:v}}],l)}return c}}var gi=(e,t,r,a,n,s,o)=>{var d=Pe(o)?t:o,c=xi(r,a,n!==s?n:s,e,d);return n!==s&&c!=null&&(c=c.map(l=>ge(ge({},l),{},{position:ge(ge({},l.position),{},{offset:l.position.offset-n/2})}))),c},bi=(e,t)=>{var r=fa(t);if(!(!e||r==null||t==null)){var a=t.stackId;if(a!=null){var n=e[a];if(n){var s=n.stackedData;if(s)return s.find(o=>o.key===r)}}}},wi=(e,t)=>{if(!(e==null||t==null)){var r=e.find(a=>a.stackId===t.stackId&&t.dataKey!=null&&a.dataKeys.includes(t.dataKey));if(r!=null)return r.position}};function ji(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&Re(e.zIndex)?e.zIndex:t}function X(e,t){var r,a;return(r=(a=e.graphicalItems.cartesianItems.find(n=>n.id===t))===null||a===void 0?void 0:a.xAxisId)!==null&&r!==void 0?r:Rt}function Z(e,t){var r,a;return(r=(a=e.graphicalItems.cartesianItems.find(n=>n.id===t))===null||a===void 0?void 0:a.yAxisId)!==null&&r!==void 0?r:Rt}var Si="Invariant failed";function Ai(e,t){throw new Error(Si)}var Ni=["option"];function Ii(e,t){if(e==null)return{};var r,a,n=Pi(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Pi(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}var et=pa;function tt(e){var t=e.option,r=Ii(e,Ni);return u.createElement(ha,{option:t,DefaultShape:et,shapeProps:r,activeClassName:"recharts-active-bar",inActiveClassName:"recharts-inactive-bar"})}var ki=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(a,n)=>{if(ce(t))return t;var s=ce(a)||Pe(a);return s?t(a,n):(s||Ai(),r)}},Ei=(e,t,r)=>r,Oi=(e,t)=>t,fe=Y([zt,Oi],(e,t)=>e.filter(r=>r.type==="bar").find(r=>r.id===t)),Ti=Y([fe],e=>e?.maxBarSize),Ci=(e,t,r,a)=>a,_i=Y([se,zt,X,Z,Ei],(e,t,r,a,n)=>t.filter(s=>e==="horizontal"?s.xAxisId===r:s.yAxisId===a).filter(s=>s.isPanorama===n).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),Bi=(e,t,r)=>{var a=se(e),n=X(e,t),s=Z(e,t);if(!(n==null||s==null))return a==="horizontal"?st(e,"yAxis",s,r):st(e,"xAxis",n,r)},Di=(e,t)=>{var r=se(e),a=X(e,t),n=Z(e,t);if(!(a==null||n==null))return r==="horizontal"?ot(e,"xAxis",a):ot(e,"yAxis",n)},$i=Y([_i,wa,Di],pi),Li=(e,t,r)=>{var a,n,s=fe(e,t);if(s==null)return 0;var o=X(e,t),d=Z(e,t);if(o==null||d==null)return 0;var c=se(e),l=Kt(e),m=s.maxBarSize,f=Pe(m)?l:m,h,y;return c==="horizontal"?(h=ae(e,"xAxis",o,r),y=ne(e,"xAxis",o,r)):(h=ae(e,"yAxis",d,r),y=ne(e,"yAxis",d,r)),(a=(n=Ft(h,y,!0))!==null&&n!==void 0?n:f)!==null&&a!==void 0?a:0},or=(e,t,r)=>{var a=se(e),n=X(e,t),s=Z(e,t);if(!(n==null||s==null)){var o,d;return a==="horizontal"?(o=ae(e,"xAxis",n,r),d=ne(e,"xAxis",n,r)):(o=ae(e,"yAxis",s,r),d=ne(e,"yAxis",s,r)),Ft(o,d)}},Mi=Y([$i,Kt,ga,ba,Li,or,Ti],gi),Ri=(e,t,r)=>{var a=X(e,t);if(a!=null)return ae(e,"xAxis",a,r)},Fi=(e,t,r)=>{var a=Z(e,t);if(a!=null)return ae(e,"yAxis",a,r)},zi=(e,t,r)=>{var a=X(e,t);if(a!=null)return ne(e,"xAxis",a,r)},Ki=(e,t,r)=>{var a=Z(e,t);if(a!=null)return ne(e,"yAxis",a,r)},Wi=Y([Mi,fe],wi),Hi=Y([Bi,fe],bi),Ui=Y([va,ya,Ri,Fi,zi,Ki,Wi,se,xa,or,Hi,fe,Ci],(e,t,r,a,n,s,o,d,c,l,m,f,h)=>{var y=c.chartData,p=c.dataStartIndex,j=c.dataEndIndex;if(!(f==null||o==null||t==null||d!=="horizontal"&&d!=="vertical"||r==null||a==null||n==null||s==null||l==null)){var x=f.data,v;if(x!=null&&x.length>0?v=x:v=y?.slice(p,j+1),v!=null)return As({layout:d,barSettings:f,pos:o,parentViewBox:t,bandSize:l,xAxis:r,yAxis:a,xAxisTicks:n,yAxisTicks:s,stackedData:m,dis
6playedData:v,offset:e,cells:h,dataStartIndex:p})}}),qi=["index"];function He(){return He=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},He.apply(null,arguments)}function Vi(e,t){if(e==null)return{};var r,a,n=Gi(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Gi(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}var lr=u.createContext(void 0),Yi=e=>{var t=u.useContext(lr);if(t!=null)return t.stackId;if(e!=null)return ja(e)},Qi=(e,t)=>"recharts-bar-stack-clip-path-".concat(e,"-").concat(t),Ji=e=>{var t=u.useContext(lr);if(t!=null){var r=t.stackId;return"url(#".concat(Qi(r,e),")")}},cr=e=>{var t=e.index,r=Vi(e,qi),a=Ji(t);return u.createElement(je,He({className:"recharts-bar-stack-layer",clipPath:a},r))},Xi=["onMouseEnter","onMouseLeave","onClick"],Zi=["value","background","tooltipPosition"],es=["id"],ts=["onMouseEnter","onClick","onMouseLeave"];function xt(e,t){return is(e)||ns(e,t)||as(e,t)||rs()}function rs(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
7In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function as(e,t){if(e){if(typeof e=="string")return gt(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?gt(e,t):void 0}}function gt(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function ns(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,n,s,o,d=[],c=!0,l=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(c=(a=s.call(r)).done)&&(d.push(a.value),d.length!==t);c=!0);}catch(m){l=!0,n=m}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(l)throw n}}return d}}function is(e){if(Array.isArray(e))return e}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},J.apply(null,arguments)}function bt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bt(Object(r),!0).forEach(function(a){ss(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bt(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ss(e,t,r){return(t=os(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function os(e){var t=ls(e,"string");return typeof t=="symbol"?t:t+""}function ls(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ie(e,t){if(e==null)return{};var r,a,n=cs(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function cs(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}var ds=e=>{var t=e.dataKey,r=e.name,a=e.fill,n=e.legendType,s=e.hide;return[{inactive:s,dataKey:t,type:n,color:a,value:Ht(r,t),payload:e}]},us=u.memo(e=>{var t=e.dataKey,r=e.stroke,a=e.strokeWidth,n=e.fill,s=e.name,o=e.hide,d=e.unit,c=e.formatter,l=e.tooltipType,m=e.id,f={dataDefinedOnItem:void 0,getPosition:ka,settings:{stroke:r,strokeWidth:a,fill:n,dataKey:t,nameKey:void 0,name:Ht
7(s,t),hide:o,type:l,color:n,unit:d,formatter:c,graphicalItemId:m}};return u.createElement(Pa,{tooltipEntrySettings:f})});function ms(e){var t=re(qt),r=e.data,a=e.dataKey,n=e.background,s=e.allOtherBarProps,o=s.onMouseEnter,d=s.onMouseLeave,c=s.onClick,l=Ie(s,Xi),m=nr(o,a,s.id),f=ir(d),h=sr(c,a,s.id);if(!n||r==null)return null;var y=$a(n);return u.createElement(Xe,{zIndex:ji(n,Je.barBackground)},r.map((p,j)=>{p.value;var x=p.background;p.tooltipPosition;var v=Ie(p,Zi);if(!x)return null;var g=m(p,p.originalDataIndex),P=f(p,p.originalDataIndex),b=h(p,p.originalDataIndex),I=B(B(B(B(B({option:n,isActive:String(p.originalDataIndex)===t},v),{},{fill:"#eee"},x),y),Qe(l,p,j)),{},{onMouseEnter:g,onMouseLeave:P,onClick:b,dataKey:a,index:j,className:"recharts-bar-background-rectangle"});return u.createElement(tt,J({key:"background-bar-".concat(j)},I))}))}function fs(e){var t=e.showLabels,r=e.children,a=e.rects,n=a?.map(s=>{var o={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return B(B({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return u.createElement(Fa,{value:t?n:void 0},r)}function ps(e){var t=e.shape,r=e.activeBar,a=e.baseProps,n=e.entry,s=e.index,o=e.dataKey,d=re(qt),c=re(Ka),l=r&&String(n.originalDataIndex)===d&&(c==null||o===c),m=d!=null&&(String(n.originalDataIndex)!==d||c!=null&&o!==c),f=u.useState(!1),h=xt(f,2),y=h[0],p=h[1],j=u.useState(!1),x=xt(j,2),v=x[0],g=x[1];u.useEffect(()=>{var N;return l?(p(!0),N=requestAnimationFrame(()=>{g(!0)})):(g(!1),m&&p(!1)),()=>{cancelAnimationFrame(N)}},[l,m]);var P=u.useCallback(()=>{l||p(!1)},[l]),b=l&&v,I=l||y,A;l?r===!0?A=t:A=r:A=t;var D=u.createElement(tt,J({},a,{name:String(a.name)},n,{isActive:b,option:A,index:s,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:P}));return I?u.createElement(Xe,{zIndex:Je.activeBar},u.createElement(cr,{index:n.originalDataIndex},D)):D}function hs(e){var t=e.shape,r=e.baseProps,a=e.entry,n=e.index,s=e.dataKey;return u.createElement(tt,J({},r,{name:String(r.name)},a,{isActive:!1,option:t,index:n,dataKey:s,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function vs(e){var t,r=e.data,a=e.props,n=e.animationElapsedTime,s=e.isAnimating,o=e.isEntrance,d=(t=za(a))!==null&&t!==void 0?t:{},c=d.id,l=Ie(d,es),m=a.shape,f=a.dataKey,h=a.activeBar,y=a.onMouseEnter,p=a.onClick,j=a.onMouseLeave,x=Ie(a,ts),v=nr(y,f,c),g=ir(j),P=sr(p,f,c);return r?u.createElement(u.Fragment,null,r.map((b,I)=>u.createElement(cr,J({index:b.originalDataIndex,key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(I),className:"recharts-bar-rectangle"},Qe(x,b,I),{onMouseEnter:v(b,b.originalDataIndex),onMouseLeave:g(b,b.originalDataIndex),onClick:P(b,b.originalDataIndex)}),h?u.createElement(ps,{shape:m,activeBar:h,baseProps:l,entry:b,index:I,dataKey:f,animationElapsedTime:n,isAnimating:s,isEntrance:o}):u.createElement(hs,{shape:m,baseProps:l,entry:b,index:I,dataKey:f,animationElapsedTime:n,isAnimating:s,isEntrance:o})))):null}var ys=(e,t,r)=>e==null?[]:t===1?e.flatMap(a=>a.status==="removed"?[]:[a.next]):e.flatMap(a=>{if(a.status==="removed")return r==="horizontal"?[B(B({},a.prev),{},{height:q(a.prev.height,0,t),y:q(a.prev.y,a.prev.y+a.prev.height,t)})]:[B(B({},a.prev),{},{width:q(a.prev.width,0,t)})];if(a.status==="matched")return[B(B({},a.next),{},{x:q(a.prev.x,a.next.x,t),y:q(a.prev.y,a.next.y,t),width:q(a.prev.width,a.next.width,t),height:q(a.prev.height,a.next.height,t)})];var n=a.next;return r==="horizontal"?[B(B({},n),{},{height:q(0,n.height,t),y:q(n.stackedBarStart,n.y,t)})]:[B(B({},n),{},{width:q(0,n.width,t),x:q(n.stackedBarStart,n.x,t)})]});function xs(e){var t=e.props,r=e.previousRectanglesRef,a=t.data,n=t.isAnimationActive,s=t.animationBegin,o=t.animationDuration,d=t.animationEasing,c=t.animationInterpolateFn,l=t.layout,m=La(t.onAnimationStart,t.onAnimationEnd),f=m.isAnimating,h=m.handleAnimationStart,y=m.handleAnimationEnd;return u.createElement(fs,{showLabels:!f,rects:a},u.createElement(Ma,{animationInput:a,animationIdPrefix:"recharts-bar-",items:a,previousItemsRef:r,isAnimationActive:n,animationBegin:s,animationDuration:o,animationEasing:d,onAnimationStart:h,onAnimationEnd:y,animationInterpolateFn:c,animationMatchBy:t.animationMatchBy,layout:l},(p,j,x)=>u.createElement(je,null,u.createElement(vs,{props:t,data:p,animationElapsedTime:j,isAnimating:f||j<1,isEntrance:x}))),u.createElement(Ra,{label:t.label}),t.children)}function gs(e){var t=u.useRef(null);return u.createElement(xs,{previousRectanglesRef:t,props:e})}var dr=0,bs=(e,t)=>{var r=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:r,errorVal:Ut(e,t)}};class ws extends u.PureComponent{render(){var t=this.props,r=t.hide,a=t.data,n=t.dataKey,s=t.className,o=t.xAxisId,d=t.yAxisId,c=t.needClip,l=t.background,m=t.id;if(r||a==null)return null;var f=Ge("recharts-bar",s),h=m;return u.createElement(je,{className:f,id:m},c&&u.createElement("defs",null,u.createElement(_a,{clipPathId:h,xAxisId:o,yAxisId:d})),u.createElement(je,{className:"recharts-bar-rectangles",clipPath:c?"url(#clipPath-".concat(h,")"):void 0},u.createElement(ms,{data:a,dataKey:n,background:l,allOtherBarProps:this.props}),u.createElement(gs,this.props)))}}var js={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",animationInterpolateFn:ys,animationMatchBy:Sa,background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendT
7ype:"rect",minPointSize:dr,shape:et,xAxisId:0,yAxisId:0,zIndex:Je.bar};function Ss(e){var t=e.xAxisId,r=e.yAxisId,a=e.hide,n=e.legendType,s=e.minPointSize,o=e.activeBar,d=e.animationBegin,c=e.animationDuration,l=e.animationEasing,m=e.isAnimationActive,f=Ea(t,r),h=f.needClip,y=Oa(),p=Wt(),j=Ta(e.children,ar),x=re(P=>Ui(P,e.id,p,j));if(y!=="vertical"&&y!=="horizontal")return null;var v,g=x?.[0];return g==null||g.height==null||g.width==null?v=0:v=y==="vertical"?g.height/2:g.width/2,u.createElement(Ca,{xAxisId:t,yAxisId:r,data:x,dataPointFormatter:bs,errorBarOffset:v},u.createElement(ws,J({},e,{layout:y,needClip:h,data:x,xAxisId:t,yAxisId:r,hide:a,legendType:n,minPointSize:s,activeBar:o,animationBegin:d,animationDuration:c,animationEasing:l,isAnimationActive:m})))}function As(e){var t=e.layout,r=e.barSettings,a=r.dataKey,n=r.minPointSize,s=r.hasCustomShape,o=e.pos,d=e.bandSize,c=e.xAxis,l=e.yAxis,m=e.xAxisTicks,f=e.yAxisTicks,h=e.stackedData,y=e.displayedData,p=e.offset,j=e.cells,x=e.parentViewBox,v=e.dataStartIndex,g=t==="horizontal"?l:c,P=h?g.scale.domain():null,b=Ba({numericAxis:g}),I=g.scale.map(b);return y.map((A,D)=>{var N,C,$,O,k,_;if(h){var E=h[D+v];if(E==null)return null;N=Da(E,P)}else N=Ut(A,a),Array.isArray(N)||(N=[b,N]);var w=ki(n,dr)(N[1],D);if(t==="horizontal"){var T,M=l.scale.map(N[0]),L=l.scale.map(N[1]);if(M==null||L==null)return null;C=lt({axis:c,ticks:m,bandSize:d,offset:o.offset,entry:A,index:D}),$=(T=L??M)!==null&&T!==void 0?T:void 0,O=o.size;var R=M-L;if(k=Wa(R)?0:R,_={x:C,y:p.top,width:O,height:p.height},Math.abs(w)>0&&Math.abs(k)<Math.abs(w)){var F=ct(k||w)*(Math.abs(w)-Math.abs(k));$-=F,k+=F}}else{var oe=c.scale.map(N[0]),Q=c.scale.map(N[1]);if(oe==null||Q==null)return null;if(C=oe,$=lt({axis:l,ticks:f,bandSize:d,offset:o.offset,entry:A,index:D}),O=Q-oe,k=o.size,_={x:p.left,y:$,width:p.width,height:k},Math.abs(w)>0&&Math.abs(O)<Math.abs(w)){var pe=ct(O||w)*(Math.abs(w)-Math.abs(O));O+=pe}}if(C==null||$==null||O==null||k==null||!s&&(O===0||k===0))return null;var Oe=B(B({},A),{},{stackedBarStart:I,x:C,y:$,width:O,height:k,value:h?N:N[1],payload:A,background:_,tooltipPosition:{x:C+O/2,y:$+k/2},parentViewBox:x,originalDataIndex:D},j&&j[D]&&j[D].props);return Oe}).filter(Boolean)}function Ns(e){var t=Ye(e,js),r=Yi(t.stackId),a=Wt();return u.createElement(Aa,{id:t.id,type:"bar"},n=>u.createElement(u.Fragment,null,u.createElement(Na,{legendPayload:ds(t)}),u.createElement(us,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:n}),u.createElement(Ia,{type:"bar",id:n,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:r,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:a,hasCustomShape:t.shape!=null&&t.shape!==et}),u.createElement(Xe,{zIndex:t.zIndex},u.createElement(Ss,J({},t,{id:n})))))}var ur=u.memo(Ns,Lt);ur.displayName="Bar";var Is=["axis","item"],Ps=u.forwardRef((e,t)=>u.createElement(Ha,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Is,tooltipPayloadSearcher:Ua,categoricalChartProps:e,ref:t}));const le=new Intl.NumberFormat("en-US",{maximumFractionDigits:2}),ks=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2});function Ue(e,t){if(typeof e!="string"||!e)return"—";const r=new Date(e.length===10?`${e}T00:00:00`:e);return Number.isNaN(r.getTime())?e:new Intl.DateTimeFormat("en-US",t?{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}:{month:"short",day:"numeric",year:"numeric"}).format(r)}function H(e,t){return e==null||e===""?"—":t==="boolean"?e?"Yes":"No":t==="date"?Ue(e,!1):t==="datetime"?Ue(e,!0):t==="currency"&&Number.isFinite(Number(e))?ks.format(Number(e)):t==="percent"&&Number.isFinite(Number(e))?`${le.format(Number(e))}%`:t==="estimate"&&Number.isFinite(Number(e))?`~${le.format(Number(e))}`:t==="speed_mph"&&Number.isFinite(Number(e))?`${le.format(Number(e))} mph`:t==="overspeed_mph"&&Number.isFinite(Number(e))?`${le.format(Number(e))} mph over`:(t==="number"||typeof e=="number")&&Number.isFinite(Number(e))?le.format(Number(e)):typeof e=="boolean"?e?"Yes":"No":typeof e=="object"?JSON.stringify(e):String(e)}function wt(e,t){return Ue(e,t)}function Es(e){if(!e.payload.series.filter(n=>n.group_key).length)return{rows:e.payload.rows,series:e.payload.series};const r=new Map,a=new Map;for(const n of e.payload.rows){const s=n[e.payload.x_key],o=String(s??"—"),d=r.get(o)||{[e.payload.x_key]:s??"—"};for(const c of e.payload.series){if(!c.group_key){d[c.key]=n[c.key]??null,a.set(c.key,c);continue}const l=String(n[c.group_key]??"Company"),m=`${c.key}::${l}`;
7d[m]=n[c.key]??null,a.set(m,{key:m,label:`${c.label} · ${l}`,format:c.format})}r.set(o,d)}return{rows:[...r.values()],series:[...a.values()]}}function $e(e){return e.replace(/^#{1,6}\s+/,"").replace(/^\*\*(.*)\*\*$/,"$1").trim()}function Os(e){const t=e.trim();if(!t)return{verdict:"",interpretation:""};const r=t.search(/\n\s*\n/);if(r>=0)return{verdict:$e(t.slice(0,r)),interpretation:t.slice(r).trim()};const a=t.indexOf(`
8`);return a>=0?{verdict:$e(t.slice(0,a)),interpretation:t.slice(a+1).trim()}:{verdict:$e(t),interpretation:""}}function Ts(){const e=Ir();return[Pr().ink,e.info.solid,e.success.solid,e.warning.solid,e.danger.solid]}function Cs(e){return!!(e&&typeof e=="object"&&"value"in e&&"entity"in e)}function rt(e){return!e||!e.startsWith("/dashboard/")||e.startsWith("//")?null:e}function mr(e,t="status"){const r=String(e??"").toLowerCase();return t==="tier"?r==="poor"?"danger":r==="fair"?"warning":r==="fantastic"||r==="fantastic plus"?"success":"neutral":t==="severity"?["critical","severe","fatal","violation","danger"].includes(r)?"danger":["warning","watch","moderate","medium","minor"].includes(r)?"warning":"neutral":["failed","lost","blocked","poor","danger","at risk"].includes(r)||/\b(late|failed|blocked|at risk)\b/.test(r)?"danger":["warning","watch","moderate","pending","open","needs verification","fair","overdue","unknown","telemetry unavailable"].includes(r)?"warning":["success","won","complete","completed","active","current","on track","clean","approved"].includes(r)?"success":["info","submitted","claimed","scheduled","ready","good"].includes(r)?"info":"neutral"}const fr={success:"bg-success-tint text-success-deep",warning:"bg-warning-tint text-warning-deep",danger:"bg-danger-tint text-danger-deep",info:"bg-info-tint text-info-deep",neutral:"bg-slate-100 text-slate-700"},_s={success:"bg-success-solid",warning:"bg-warning-solid",danger:"bg-danger-solid",info:"bg-info-solid",neutral:"bg-slate-400"};function pr({value:e,format:t="status"}){const r=mr(e,t),a=t==="severity",n=a&&r==="danger"?ue:a&&r==="warning"?en:null;return i.jsxs("span",{className:we("inline-flex min-h-6 items-center gap-1.5 rounded-full px-2 py-0.5 text-caption font-semibold",fr[r]),children:[n?i.jsx(n,{className:"h-3 w-3","aria-hidden":"true"}):i.jsx("span",{className:we("h-1.5 w-1.5 rounded-full",_s[r]),"aria-hidden":"true"}),H(e)]})}function jt({value:e,format:t}){if(Cs(e)){const r=H(e.value,t),a=rt(e.entity?.href);return a?i.jsxs(de,{className:"inline-flex min-h-11 items-center gap-1 font-medium text-slate-900 underline decoration-slate-300 underline-offset-2 hover:
8decoration-slate-900 md:min-h-0",to:a,children:[r,i.jsx(Vt,{className:"h-3 w-3","aria-hidden":"true"})]}):i.jsx("span",{children:r})}return t==="status"||t==="tier"||t==="severity"?t==="severity"&&typeof e=="number"?i.jsx("span",{className:"font-mono tabular-nums",children:H(e,"number")}):i.jsx(pr,{value:e,format:t}):i.jsx("span",{className:we((t==="mono"||["number","percent","currency","estimate","speed_mph","overspeed_mph"].includes(t||""))&&"font-mono tabular-nums"),children:H(e,t)})}function St({block:e}){const{title:t,description:r,columns:a,rows:n,empty:s}=e.payload;return i.jsxs("section",{className:"overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm","aria-labelledby":`${e.block_id}-title`,children:[i.jsxs("div",{className:"border-b border-slate-200 px-4 py-3",children:[i.jsx("h3",{id:`${e.block_id}-title`,className:"text-[17px] font-semibold text-slate-950",children:t}),r&&i.jsx("p",{className:"mt-1 text-caption text-slate-500",children:r})]}),n.length===0?i.jsx("p",{className:"px-4 py-6 text-[15px] text-slate-500",children:s||"No matching data."}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"hidden overflow-x-auto md:block",children:i.jsxs("table",{className:"w-full border-collapse text-left text-[15px]",children:[i.jsx("thead",{className:"bg-slate-50 text-caption font-semibold uppercase tracking-wide text-slate-500",children:i.jsx("tr",{children:a.map(o=>i.jsx("th",{className:"whitespace-nowrap px-4 py-2.5",children:o.label},o.key))})}),i.jsx("tbody",{className:"divide-y divide-slate-100",children:n.map((o,d)=>i.jsx("tr",{className:"align-top hover:bg-slate-50/70",children:a.map(c=>i.jsx("td",{className:"max-w-[24rem] px-4 py-3 text-slate-700",children:i.jsx(jt,{value:o[c.key]??null,format:c.format})},c.key))},`${e.block_id}-${d}`))})]})}),i.jsx("div",{className:"divide-y divide-slate-200 md:hidden",children:n.map((o,d)=>i.jsx("dl",{className:"space-y-2.5 px-4 py-4",children:a.map(c=>i.jsxs("div",{className:"grid grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)] gap-3",children:[i.jsx("dt",{className:"text-caption font-medium text-slate-500",children:c.label}),i.jsx("dd",{className:"min-w-0 break-words text-right text-[15px] text-slate-800",children:i.jsx(jt,{value:o[c.key]??null,format:c.format})})]},c.key))},`${e.block_id}-card-${d}`))})]})]})}function At({block:e}){const t=Ts(),r=Es(e),a=e.payload.chart==="bar"?Ps:qa,n=[...new Set(r.series.map(l=>l.format||"number"))],s=new Map(r.series.flatMap(l=>[[l.key,l.format],[l.label,l.format]])),o=l=>({percent:"Percent",currency:"Currency",estimate:"Estimated value",number:"Value"})[l]||"Value",d=[void 0,"7 4","2 3","10 3 2 3"],c=rt(e.payload.title_entity?.href);return i.jsxs("section",{className:"rounded-xl border border-slate-200 bg-white p-4 shadow-sm","aria-labelledby":`${e.block_id}-title`,children:[i.jsx("h3",{id:`${e.block_id}-title`,className:"text-[17px] font-semibold text-slate-950",children:c?i.jsxs(de,{className:"inline-flex min-h-11 items-center gap-1 underline decoration-slate-300 underline-offset-2 hover:
8decoration-slate-900 md:min-h-0",to:c,children:[e.payload.title,i.jsx(Vt,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}):e.payload.title}),e.payload.description&&i.jsx("p",{className:"mt-1 text-caption text-slate-500",children:e.payload.description}),r.rows.length===0?i.jsx("p",{className:"py-6 text-[15px] text-slate-500",children:"No chart data is available."}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-4 h-72 min-w-0","data-testid":"assistant-chart","aria-hidden":"true",children:i.jsx(Va,{width:"100%",height:"100%",children:i.jsxs(a,{data:r.rows,margin:{top:8,right:8,left:0,bottom:8},children:[i.jsx(Ga,{stroke:"hsl(var(--border))",strokeDasharray:"3 3",vertical:!1}),i.jsx(Ya,{dataKey:e.payload.x_key,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickLine:!1,axisLine:{stroke:"hsl(var(--border))"}}),n.map((l,m)=>i.jsx(Qa,{yAxisId:l,orientation:m===1?"right":"left",hide:m>1,tickFormatter:f=>H(f,l),tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickLine:!1,axisLine:!1,width:64,label:m<2?{value:o(l),angle:-90,position:m===1?"insideRight":"insideLeft",fontSize:11}:void 0},l)),i.jsx(Ja,{formatter:(l,m)=>[H(l,s.get(String(m))),String(m)],contentStyle:{borderRadius:8,borderColor:"hsl(var(--border))",backgroundColor:"hsl(var(--popover))",color:"hsl(var(--popover-foreground))",fontSize:12}}),i.jsx(rr,{wrapperStyle:{fontSize:12,paddingTop:12}}),r.series.map((l,m)=>e.payload.chart==="bar"?i.jsx(ur,{dataKey:l.key,name:l.label,yAxisId:l.format||"number",fill:t[m%t.length],fillOpacity:Math.max(.55,1-m%3*.2),radius:[4,4,0,0]},l.key):i.jsx(Xa,{dataKey:l.key,name:l.label,yAxisId:l.format||"number",type:"monotone",stroke:t[m%t.length],strokeDasharray:d[m%d.length],strokeWidth:2,dot:{r:3},activeDot:{r:5},connectNulls:!0},l.key))]})})}),i.jsxs("table",{className:"sr-only",children:[i.jsxs("caption",{children:[e.payload.title," exact chart values"]}),i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:e.payload.x_key}),r.series.map(l=>i.jsx("th",{children:l.label},l.key))]})}),i.jsx("tbody",{children:r.rows.map((l,m)=>i.jsxs("tr",{children:[i.jsx("th",{children:H(l[e.payload.x_key])}),r.series.map(f=>i.jsx("td",{children:H(l[f.key],f.format)},f.key))]},`${e.block_id}-accessible-${m}`))})]})]})]})}function Bs({block:e}){const t=mr(e.payload.state||e.payload.verdict,"status");return i.jsxs("section",{className:"rounded-xl border border-slate-200 bg-white p-5 shadow-sm","aria-labelledby":`${e.block_id}-title`,children:[i.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[i.jsxs("div",{children:[i.jsx("h3",{id:`${e.block_id}-title`,className:"text-[17px] font-semibold text-slate-950",children:e.payload.title}),i.jsx("p",{className:"mt-2 font-mono text-3xl font-semibold tabular-nums text-slate-950",children:H(e.payload.value,e.payload.format)})]}),e.payload.verdict&&i.jsx(pr,{value:e.payload.verdict,format:"status"})]}),e.payload.delta!==null&&e.payload.delta!==void 0&&i.jsxs("p",{className:we("mt-2 text-[15px] font-medium",fr[t].split(" ")[1]),children:[H(e.payload.delta,e.payload.format)," change"]}),e.payload.details&&e.payload.details.length>0&&i.jsx("dl",{className:"mt-4 grid grid-cols-2 gap-3 border-t border-slate-100 pt-4 sm:grid-cols-4",children:e.payload.details.map(r=>i.jsxs("div",{children:[i.jsx("dt",{className:"text-caption text-slate-500",children:r.label}),i.jsx("dd",{className:"mt-1 font-mono text-[15px] font-semibold tabular-nums text-slate-900",children:H(r.value)})]},r.label))})]})}function Ee(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function qe(e){return{scorecard_offenders:"Scorecard Analysis",scorecard_summary:"Scorecard Summary",signin_status:"Attendance and Route Coverage",safety_events:"Safety Events",customer_feedback:"Customer Feedback",disputes_status:"Disputes",payroll_violations:"Payroll Exceptions",compare_stations:"Station Comparison"}[e]||Ee(e)}function Ve(e){return e==null||e===""?i.jsx("span",{className:"text-slate-500",children:"—"}):Array.isArray(e)?e.length?i.jsx("ul",{className:"space-y-1.5",children:e.slice(0,10).map((t,r)=>i.jsx("li",{className:"rounded-md bg-slate-50 px-2.5 py-2",children:Ve(t)},r))}):i.jsx("span",{className:"text-slate-500",children:"No records"}):typeof e=="object"?i.jsx("dl",{className:"grid gap-1.5",children:Object.entries(e).map(([t,r])=>i.jsxs("div",{className:"grid grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)
8] gap-3",children:[i.jsx("dt",{className:"text-xs text-slate-500",children:Ee(t)}),i.jsx("dd",{className:"break-words text-right text-xs font-medium text-slate-800",children:Ve(r)})]},t))}):i.jsx("span",{children:H(e)})}function Ds({block:e}){const t=rt(e.payload.driver.href),r=e.payload.driver.name||"Driver";return i.jsxs("section",{className:"rounded-xl border border-slate-200 bg-white p-5 shadow-sm","aria-labelledby":`${e.block_id}-title`,children:[i.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 pb-4",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-slate-100 text-slate-700",children:i.jsx(Za,{className:"h-5 w-5","aria-hidden":"true"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{id:`${e.block_id}-title`,className:"font-semibold text-slate-950",children:t?i.jsx(de,{to:t,className:"inline-flex min-h-11 items-center underline decoration-slate-300 underline-offset-2 hover:decoration-slate-900 md:min-h-0",children:r}):r}),i.jsx("p",{className:"text-caption text-slate-500",children:[e.payload.driver.station_code,e.payload.driver.status].filter(Boolean).join(" · ")})]})]}),i.jsx("div",{className:"mt-4 grid gap-4 lg:grid-cols-2",children:Object.entries(e.payload.sections).map(([a,n])=>i.jsxs("div",{className:"rounded-lg border border-slate-100 p-3",children:[i.jsx("h4",{className:"mb-2 text-caption font-semibold uppercase tracking-wide text-slate-500",children:Ee(a)}),Ve(n)]},a))})]})}function $s(e){const t=e.payload.details||[];return t.length?t.map(r=>r.status==="failed"?`${qe(r.tool)} failed`:qe(r.tool)).join(" · "):e.payload.sources.join(" + ")||e.payload.tools.join(" · ")||"No data sources used"}function Ls({block:e}){const t=e.payload.details||[],r=t.filter(s=>s.status==="failed"),a=[...new Set(t.filter(s=>s.status==="complete").map(s=>s.scope||"Company-wide scope"))],n=e.payload.as_of?`as of ${wt(e.payload.as_of,e.payload.as_of.length!==10)}`:"freshness unavailable";return i.jsxs("footer",{className:"border-t border-slate-200 pt-3 font-mono text-caption leading-5 text-slate-500","data-testid":"assistant-provenance",children:[r.map((s,o)=>i.jsxs("div",{className:"mb-2 rounded-md border border-danger-solid/25 bg-danger-tint px-3 py-2 font-sans text-[15px] text-danger-deep",role:"alert",children:[i.jsxs("span",{className:"font-semibold",children:["Couldn’t check ",Ee(s.tool),"."]})," The answer may be incomplete."]},`${s.tool}-failure-${o}`)),e.payload.freshness_status==="stale"&&i.jsx("div",{className:"mb-2 rounded-md border border-warning-solid/25 bg-warning-tint px-3 py-2 font-sans text-[15px] text-warning-deep",role:"alert",children:"Some evidence is older than its source freshness limit. Verify or refresh it before acting."}),i.jsxs("p",{children:[$s(e)," · ",a.join(" + ")||"No data scope"," · ",n,e.payload.contains_estimates?" · ~ = estimate":""]}),i.jsxs("details",{className:"group mt-1",children:[i.jsxs("summary",{className:"flex min-h-11 cursor-pointer list-none items-center gap-1 font-sans text-caption font-medium text-slate-600 hover:text-slate-950",children:[i.jsx(Nr,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-180","aria-hidden":"true"}),"How I got this"]}),i.jsxs("ol",{className:"mt-1 space-y-1.5 pl-1",children:[t.map((s,o)=>i.jsxs("li",{className:"flex items-start gap-2",children:[s.status==="complete"?i.jsx(Tt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-success-solid","aria-hidden":"true"}):i.jsx(ue,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-danger-solid","aria-hidden":"true"}),i.jsxs("span",{children:[qe(s.tool)," · ",s.status==="failed"?`failed${s.reason?`: ${s.reason}`:""}`:s.row_count===null?"row count unavailable":`${s.row_count} displayed row${s.row_count===1?"":"s"}`,s.scope?` · ${s.scope}`:"",s.as_of?` · as of ${wt(s.as_of,s.as_of.length!==10)}`:" · freshness unavailable",typeof s.duration_ms=="number"?` · ${s.duration_ms}ms`:"",s.params&&Object.keys(s.params).length>0?` · params ${JSON.stringify(s.params)}`:""]})]},`${s.tool}-${o}`)),!t.length&&e.payload.tools.map(s=>i.jsx("li",{children:s},s))]})]})]})}const Ms={table:640,chart:640};function Rs({minWidth:e,children:t,sessionId:r,onOpenFullPage:a}){const n=u.useRef(null),[s,o]=u.useState(!1);return u.useLayoutEffect(()=>{const d=n.current,c=d?.closest("[data-sortd-ai-panel]");if(!d||!c)return;const l=()=>o(c.getBoundingClientRect().width>=e);if(l(),typeof ResizeObserver>"u")return;const m=new ResizeObserver(l);return m.observe(c),()=>m.disconnect()},[e]),i.jsx("div",{ref:n,"data-min-width":e,children:s?t:i.jsxs("div",{className:"rounded-lg border border-hairline bg-surface px-4 py-4 text-s3 text-subtle","data-testid":"assistant-block-width-refusal",children:[i.jsx("p",{className:"font-medium text-ink",children:"This result is too wide for the side panel."}),i.jsx("p",{className:"mt-1",children:"Open the full Sortd AI page to view the complete result."}),i.jsx(de,{className:"mt-3 inline-flex min-h-11 items-center font-medium underline underline-offset-2",to:r?`/dashboard/assistant?session=${encodeURIComponent(r)}`:"/dashboard/assistant",onClick:a,children:"Open full Sortd AI"})]})})}function hr({block:e,surface:t="page",sessionId:r,onOpenFullPage:a}){const n=Ms[e.type];return t==="panel"&&n?i.jsx(Rs,{minWidth:n,sessionId:r,onOpenFullPage:a,children:e.type==="table"?i.jsx(St,{block:e}):e.type==="chart"?i.jsx(At,{block:e}):null}):e.type==="table"?i.jsx(St,{block:e}):e.type==="chart"?i.jsx(At,{block:e}):e.type==="metric"?i.jsx(Bs,{block:e}):e.type==="driver_card"?i.jsx(Ds,{block:e}):e.type==="provenance"?i.jsx(Ls,{block:e}):i.jsx("div",{className:"rounded-lg border border-warning-solid/25 bg-warning-tint px-4 py-3 text-[15px] text-warning-deep",role:"status",children:"This response includes a newer evidence block that this dashboard cannot display yet."})}function Fs({blocks:e,surface:t="page",sessionId:r,onOpenFullPage:a}){return i.jsx(u.Fragment,{children:e.filter(n=>n.type!=="provenance").map(n=>i.jsx(hr,{block:n,surface:t,sessionId:r,onOpenFullPage:a},n.block_id))})}function Nt(e){const t=[],r=/\[([^\]]+)\]\((\/dashboard\/[^)\s]+)\)|\*\*([^*]+)\*\*/g;let a=0,n;for(;(n=r.exec(e))!==null;)n.index>
8a&&t.push(e.slice(a,n.index)),n[1]&&n[2]?t.push(i.jsx(de,{to:n[2],className:"font-medium underline decoration-slate-300 underline-offset-2 hover:decoration-slate-900",children:n[1]},`${n.index}-link`)):n[3]&&t.push(i.jsx("strong",{className:"font-semibold text-slate-950",children:n[3]},`${n.index}-strong`)),a=r.lastIndex;return a<e.length&&t.push(e.slice(a)),t}function zs({text:e}){const t=e.split(/\n\s*\n/).filter(r=>r.trim());return i.jsx("div",{className:"space-y-3 text-[15px] leading-6 text-slate-700",children:t.map((r,a)=>{const n=r.split(`
9`).map(o=>o.trim()).filter(Boolean);return n.every(o=>/^[-*]\s+/.test(o))?i.jsx("ul",{className:"list-disc space-y-1 pl-5",children:n.map((o,d)=>i.jsx("li",{children:Nt(o.replace(/^[-*]\s+/,""))},d))},a):i.jsx("p",{children:n.map((o,d)=>i.jsxs(u.Fragment,{children:[d>0&&i.jsx("br",{}),Nt(o)]},d))},a)})})}function It({text:e,blocks:t,followups:r=[],streaming:a=!1,failed:n=!1,onFollowup:s,surface:o="page",sessionId:d,onOpenFullPage:c}){const{verdict:l,interpretation:m}=Os(e),f=t.filter(v=>v.type!=="provenance"),h=f.filter(v=>"verdict"in v.payload||"interpretation"in v.payload),y=f.length===1&&h.length===1?h[0]:void 0,p=y&&"verdict"in y.payload&&y.payload.verdict||l,j=y&&"interpretation"in y.payload?y.payload.interpretation??m:m,x=t.find(v=>v.type==="provenance");return n?i.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-danger-solid/25 bg-danger-tint px-4 py-3 text-[15px] text-danger-deep",role:"alert",children:[i.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),i.jsx("p",{children:e})]}):i.jsxs("article",{className:"space-y-4",children:[p?i.jsx("p",{className:"text-[15px] font-semibold leading-6 text-slate-950",children:p}):a?i.jsxs("div",{className:"flex items-center gap-2 text-[15px] text-slate-500",role:"status",children:[i.jsx(Ct,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),"Reviewing your operation…"]}):null,i.jsx(Fs,{blocks:t,surface:o,sessionId:d,onOpenFullPage:c}),j&&i.jsx(zs,{text:j}),r.length>0&&i.jsx("div",{className:"flex flex-wrap gap-2","aria-label":"Suggested follow-up questions",children:r.slice(0,3).map(v=>i.jsx("button",{type:"button",className:"min-h-11 rounded-full border border-slate-300 bg-white px-3 py-1.5 text-left text-caption font-medium text-slate-700 transition-colors hover:border-slate-500 hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>s?.(v),disabled:!s||a,children:v},v))}),x&&i.jsx(hr,{block:x,surface:o,sessionId:d,onOpenFullPage:c})]})}function Pt(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function Ks({activities:e}){return e.length?i.jsx("div",{className:"flex flex-wrap gap-2","aria-label":"Sortd AI tool activity","aria-live":"polite","aria-atomic":"false",children:e.map(t=>i.jsxs("span",{className:"inline-flex min-h-7 items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-medium text-slate-600",children:[t.status==="running"&&i.jsx(Ct,{className:"h-3.5 w-3.5 animate-spin text-info-solid","aria-hidden":"true"}),t.status==="complete"&&i.jsx(Tt,{className:"h-3.5 w-3.5 text-success-solid","aria-hidden":"true"}),t.status==="failed"&&i.jsx(ue,{className:"h-3.5 w-3.5 text-danger-solid","aria-hidden":"true"}),t.status==="running"?`Checking ${Pt(t.tool)}…`:`${Pt(t.tool)} ${t.status}`]},t.tool_use_id))}):null}const at={root:["assistant"],sessions:(e,t="")=>t?["assistant",e,"sessions","search",t]:["assistant",e,"sessions"],history:(e,t)=>["assistant",e,"sessions",t,"history"]};function Ws(e,t=""){const{data:r}=_t(),a=r?`${r.id}:${r.companyId||"no-company"}`:"pending",n=t.trim();return Bt({queryKey:at.sessions(a,n),queryFn:()=>{const s=new URLSearchParams({limit:"50"});return n&&s.set("search",n),Dt(`/api/assistant/sessions?${s.toString()}`)},enabled:e&&!!r,staleTime:15e3})}function Hs(e,t){const{data:r}=_t(),a=r?`${r.id}:${r.companyId||"no-company"}`:"pending";return Bt({queryKey:at.history(a,e||"none"),queryFn:()=>Dt(`/api/assistant/sessions/${encodeURIComponent(e||"")}/history`),enabled:!!r&&!!e,staleTime:15e3})}const Le={status:"idle",sessionId:null,accepted:!1,text:"",blocks:[],activities:[],followups:[],error:null,errorCode:null};function Us(e){const t=e.split(`
10`);let r="message";const a=[];for(const n of t)n.startsWith("event:")&&(r=n.slice(6).trim()),n.startsWith("data:")&&a.push(n.slice(5).trimStart());if(!a.length)return null;try{return{event:r,data:JSON.parse(a.join(`
11`))}}
11catch(n){throw new Error(`Sortd AI returned an invalid ${r} event`,{cause:n})}}function vr(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function kt(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}async function qs(e){let t={};try{t=vr(await e.json())}catch(r){console.error("[sortd-ai] non-JSON error response",r)}return new be(typeof t.error=="string"?t.error:`Sortd AI request failed (${e.status})`,e.status,typeof t.code=="string"?t.code:null)}function Vs({surface:e="web",pageContext:t}={}){const r=kr(),a=u.useRef(null),n=u.useRef(0),[s,o]=u.useState(Le);u.useEffect(()=>()=>a.current?.abort(),[]);const d=u.useCallback(()=>{n.current+=1,a.current?.abort(),a.current=null,o(Le)},[]),c=u.useCallback(()=>{n.current+=1,a.current?.abort(),a.current=null,o(m=>({...m,status:"idle"}))},[]),l=u.useCallback(async(m,f)=>{a.current?.abort();const h=n.current+1;n.current=h;const y=new AbortController;a.current=y;let p={...Le,status:"streaming",sessionId:f},j=!1;o(p);const x=v=>{p=v(p),n.current===h&&o(p)};try{const v=await Er();j=!0;const g=await fetch(`${Or}/api/assistant/ask`,{method:"POST",headers:v,body:JSON.stringify({question:m,session_id:f||void 0,surface:e,page_context:t?.trim()||void 0}),signal:y.signal});if(!g.ok)throw await qs(g);if(!(g.headers.get("content-type")||"").toLowerCase().includes("text/event-stream"))throw new be("Sortd AI returned an unexpected response instead of a live stream.",g.status,"ASSISTANT_STREAM_UNAVAILABLE");if(!g.body)throw new Error("Sortd AI streaming is unavailable in this browser.");const b=g.body.getReader(),I=new TextDecoder;let A="",D=!1,N="",C=null;const $=()=>{if(C&&clearTimeout(C),C=null,!N)return;const _=N;N="",x(E=>({...E,text:E.text+_}))},O=_=>{N+=_,C||(C=setTimeout($,32))},k=_=>{const E=Us(_);if(!E)return;const w=vr(E.data);if(E.event!=="text_delta"&&$(),E.event==="meta"&&typeof w.session_id=="string")x(T=>({...T,sessionId:w.session_id,accepted:!0}));else if(E.event==="text_delta"&&typeof w.text=="string")O(w.text);else if(E.event==="block"&&typeof w.type=="string"&&typeof w.block_id=="string")x(T=>({...T,blocks:[...T.blocks,w]}));else if(E.event==="tool_activity"&&typeof w.tool=="string"){const T=typeof w.tool_use_id=="string"?w.tool_use_id:w.tool,M={tool:w.tool,tool_use_id:T,status:w.status==="complete"||w.status==="failed"?w.status:"running",...typeof w.block_id=="string"?{block_id:w.block_id}:{}};x(L=>({...L,activities:[...L.activities.filter(R=>R.tool_use_id!==M.tool_use_id),M]}))}else if(E.event==="followups")x(T=>({...T,followups:kt(w.prompts)}));else if(E.event==="error")D=!0,x(T=>({...T,status:"error",error:typeof w.message=="string"?w.message:"Sortd AI could not finish that response.",errorCode:typeof w.code=="string"?w.code:null}));else if(E.event==="done"){D=!0;const T=kt(w.follow_ups);x(M=>({...M,status:"done",followups:T.length?T:M.followups}))}};try{for(;;){const{value:_,done:E}=await b.read();A+=I.decode(_||new Uint8Array,{stream:!E}),A=A.replace(/\r\n/g,`
12`);const w=A.split(`
13
14`);A=w.pop()||"";for(const T of w)k(T);if(E)break}A.trim()&&k(A),$()}finally{C&&clearTimeout(C),b.releaseLock()}if(!D)throw new be("The Sortd AI connection ended before the response completed. Start a new chat to try again.",0,"ASSISTANT_STREAM_INTERRUPTED");return n.current===h&&o(p),p}catch(v){if(y.signal.aborted)return p;console.error("[sortd-ai] stream failed",v);const g=v instanceof Error?v.message:"Sortd AI could not start the response.";return p={...p,status:"error",error:g,errorCode:v instanceof be?v.code:null},n.current===h&&o(p),p}finally{j&&await r.invalidateQueries({queryKey:at.root}),a.current===y&&(a.current=null)}},[t,r,e]);return{...s,ask:l,cancel:c,reset:d}}const Gs=["Which drivers have the most CDF complaints this week?","What tier are we on and what is dragging it down?","Who's at risk of finishing late right now?","Show the in-zone gap trend for my worst driver","List drivers in the coaching queue","Any safety events this week I should know about?"];function Ys(e,t=new Date){const r=new Date(e);if(Number.isNaN(r.getTime()))return"Earlier";const a=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),n=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),s=Math.round((a-n)/864e5);return s<=0?"Today":s===1?"Yesterday":"Earlier"}function Qs(e,t,r=new Date){const a=t.trim().toLowerCase(),n=new Map([["Today",[]],["Yesterday",[]],["
14Earlier",[]]]);for(const s of e)a&&!s.title.toLowerCase().includes(a)||n.get(Ys(s.last_message_at,r))?.push(s);return[...n.entries()].map(([s,o])=>({label:s,sessions:o})).filter(s=>s.sessions.length>0)}function Js(e){const t=new Date(e);return Number.isNaN(t.getTime())?"Unknown time":Wr(t,{addSuffix:!0})}function Xs(e,t,r,a){const n=e.at(-1),s=e.at(-2);return!!(n&&s&&n.role==="assistant"&&s.role==="user"&&(a?n.usage?.failed===!0:n.text.trim()===r.trim())&&s.text.trim()===t.trim())}function Et({sessions:e,selectedSessionId:t,search:r,onSearch:a,onSelect:n,onNew:s,loading:o,error:d,onRetry:c,mobile:l=!1}){const m=Qs(e,r);return i.jsxs("aside",{className:`${l?"flex h-full w-full":"hidden w-72 lg:flex"} min-h-0 shrink-0 flex-col border-r border-slate-200 bg-white`,"aria-label":"Sortd AI conversation history",children:[i.jsxs("div",{className:"border-b border-slate-200 p-4",children:[i.jsx("div",{className:l?"flex h-11 items-center pr-12":"",children:i.jsx("p",{className:"text-[15px] font-semibold text-slate-950",children:"Conversations"})}),i.jsxs(te,{className:"mt-3 min-h-11 w-full",size:"sm",onClick:s,children:[i.jsx(Yt,{className:"h-4 w-4","aria-hidden":"true"})," New chat"]}),i.jsxs("label",{className:"relative mt-3 block",children:[i.jsx("span",{className:"sr-only",children:"Search conversations"}),i.jsx(zr,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400","aria-hidden":"true"}),i.jsx(Kr,{value:r,onChange:f=>a(f.target.value),placeholder:"Search history",className:l?"h-[52px] pl-9":"pl-9"})]})]}),i.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:[o&&!e.length&&i.jsx("div",{className:"space-y-3 p-1","aria-label":"Loading conversation history",children:[0,1,2,3].map(f=>i.jsx(Fe,{className:"h-14 w-full"},f))}),d&&!e.length&&i.jsxs("div",{className:"rounded-lg border border-danger-solid/25 bg-danger-tint p-3 text-sm text-danger-deep",role:"alert",children:[i.jsx("p",{className:"font-semibold",children:"History could not be loaded."}),i.jsx("button",{type:"button",className:"mt-2 min-h-11 font-medium underline",onClick:()=>{c()},children:"Retry"})]}),!o&&!d&&!e.length&&i.jsxs("div",{className:"px-3 py-8 text-center text-sm text-slate-500",children:[i.jsx(on,{className:"mx-auto mb-2 h-5 w-5","aria-hidden":"true"}),"Your conversations will appear here."]}),!o&&e.length>0&&m.length===0&&i.jsxs("p",{className:"px-3 py-8 text-center text-sm text-slate-500",children:["No conversations match “",r,"”."]}),i.jsx("div",{className:"space-y-4",children:m.map(f=>i.jsxs("section",{children:[i.jsx("h2",{className:"px-2 pb-1 text-caption font-semibold uppercase tracking-wide text-slate-500",children:f.label}),i.jsx("div",{className:"space-y-1",children:f.sessions.map(h=>i.jsxs("button",{type:"button",className:`min-h-11 w-full rounded-lg px-3 py-2.5 text-left transition-colors ${t===h.id?"bg-slate-100 text-slate-950":"text-slate-700 hover:bg-slate-50"}`,onClick:()=>n(h.id),children:[i.jsx("span",{className:"block truncate text-[15px] font-medium",children:h.title}),i.jsx("span",{className:`mt-0.5 block text-caption ${t===h.id?"text-slate-600":"text-slate-500"}`,children:Js(h.last_message_at)})]},h.id))})]},f.label))})]})]})}function Ot({text:e,onReask:t,disabled:r}){return i.jsxs("div",{className:"ml-auto max-w-2xl",children:[i.jsx("div",{className:"rounded-2xl rounded-br-md bg-slate-900 px-4 py-3 text-[15px] leading-6 text-white",children:e}),t&&i.jsx("button",{type:"button",onClick:t,disabled:r,className:"mt-1 min-h-11 px-1 text-xs font-medium text-slate-500 hover:text-slate-950 disabled:opacity-50",children:"Re-ask with fresh data"})]})}function Zs({surface:e="page",contextLabel:t="this page",onClose:r,onBudgetStateChange:a}){const n=e==="panel",[s]=Tr(),o=Cr(),d=a??o,[c,l]=u.useState(""),m=u.useDeferredValue(c.trim()),f=Ws(!n,m),[h,y]=u.useState(()=>n?null:s.get("session")),[p,j]=u.useState(!1),[x,v]=u.useState(""),[g,P]=u.useState(null),b=Hs(h),{status:I,sessionId:A,accepted:D,text:N,blocks:C,activities:$,followups:O,error:k,errorCode:_,ask:E,reset:w,cancel:T}
14=Vs({surface:n?"panel":"web",pageContext:n?t:void 0}),M=u.useRef(null),L=u.useRef(null),R=u.useRef(!0),F=u.useRef(0),[oe,Q]=u.useState(!1),pe=f.isError?[]:f.data?.sessions||[],Oe=_r(b.error)==="ASSISTANT_HISTORY_ACCESS_CHANGED",he=b.isError?[]:b.data?.messages||[],U=I==="streaming",ve=I==="error"&&_==="ASSISTANT_RATE_LIMITED",Te=I==="error"&&_==="ASSISTANT_DAILY_BUDGET_EXCEEDED",Ce=!!(g&&D&&A&&b.data?.session.id===A&&Xs(he,g,N,I==="error"));u.useEffect(()=>{!Te&&I!=="done"||d(Te)},[Te,d,I]),u.useEffect(()=>{R.current&&L.current?.scrollIntoView?.({behavior:U?"auto":"smooth",block:"end"})},[U,he.length,$,C.length,N]),u.useEffect(()=>{if(!Ce)return;const S=window.setTimeout(()=>{P(null),w()},0);return()=>window.clearTimeout(S)},[Ce,w]);const ye=u.useCallback(()=>{F.current+=1,w(),y(null),P(null),v(""),j(!1),R.current=!0,Q(!1)},[w]),nt=u.useCallback(S=>{F.current+=1,w(),P(null),y(S),j(!1),R.current=!0,Q(!1)},[w]),ee=u.useCallback(async S=>{const G=S.trim();if(!G||U||g&&!ve&&I!=="done")return;const _e=F.current+1;F.current=_e,R.current=!0,Q(!1),v(""),P(G);const Be=await E(G,h||A);Be.errorCode==="ASSISTANT_RATE_LIMITED"&&F.current===_e&&v(G),Be.sessionId&&F.current===_e&&y(Be.sessionId)},[E,U,g,h,A,I,ve]),yr=S=>{S.preventDefault(),ee(x)},xr=S=>{S.key==="Enter"&&!S.shiftKey&&!S.nativeEvent.isComposing&&S.nativeEvent.keyCode!==229&&(S.preventDefault(),ee(x))},gr=()=>{const S=M.current;if(!S)return;const G=S.scrollHeight-S.scrollTop-S.clientHeight<120;R.current=G,Q(!G)},br=()=>{R.current=!0,Q(!1),L.current?.scrollIntoView?.({behavior:"smooth",block:"end"})},wr=!h&&he.length===0&&!g&&!b.isLoading,jr=!!(g&&!Ce);return i.jsxs("div",{className:`relative flex min-h-0 flex-1 overflow-hidden bg-white ${n?"h-full":"rounded-xl border border-slate-200 shadow-sm"}`,children:[!n&&i.jsx(Et,{sessions:pe,selectedSessionId:h,search:c,onSearch:l,onSelect:nt,onNew:ye,loading:f.isLoading,error:f.isError,onRetry:f.refetch}),!n&&i.jsx(Br,{open:p,onOpenChange:j,children:i.jsxs(Dr,{className:"inset-0 left-0 top-0 h-[100dvh] max-w-none translate-x-0 translate-y-0 gap-0 rounded-none p-0 lg:hidden",children:[i.jsx($r,{className:"sr-only",children:"Sortd AI conversation history"}),i.jsx(Lr,{className:"sr-only",children:"Search, open, or start a Sortd AI conversation."}),i.jsx(Et,{mobile:!0,sessions:pe,selectedSessionId:h,search:c,onSearch:l,onSelect:nt,onNew:ye,loading:f.isLoading,error:f.isError,onRetry:f.refetch})]})}),i.jsxs("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-slate-50/50","aria-label":"Sortd AI chat",children:[i.jsx("p",{className:"sr-only","aria-live":"polite",children:U?"Sortd AI is checking your operation.":I==="done"?"Sortd AI response complete.":k||""}),i.jsxs("header",{className:"flex h-16 shrink-0 items-center justify-between gap-3 border-b border-slate-200 bg-white px-4 sm:px-6",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[!n&&i.jsx("button",{type:"button",className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-md border border-slate-200 hover:bg-slate-50 lg:hidden",onClick:()=>j(!0),"aria-label":"Open conversation history",children:i.jsx(Mr,{className:"h-4 w-4","aria-hidden":"true"})}),i.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-slate-900 text-white",children:i.jsx(Rr,{className:"h-4 w-4","aria-hidden":"true"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h1",{className:"truncate text-base font-semibold text-slate-950",children:"Sortd AI"}),i.jsx("p",{className:"truncate text-xs text-slate-500",children:n?`Reading ${t}`:"Answers grounded in your Sortd data"})]})]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsxs(te,{variant:"outline",size:"sm",onClick:ye,className:`${n?"inline-flex":"hidden sm:inline-flex"} min-h-11`,children:[i.jsx(Yt,{className:"h-4 w-4","aria-hidden":"true"})," New chat"]}),n&&r&&i.jsx("button",{type:"button",onClick:r,className:"flex h-11 w-11 items-center justify-center rounded-md text-slate-500 hover:bg-slate-100 hover:text-slate-950","aria-label":"Close Sortd AI panel",children:i.jsx(Fr,{className:"h-4 w-4","aria-hidden":!0})})]})]}),i.jsx("div",{ref:M,className:"min-h-0 flex-1 overflow-y-auto","data-testid":"assistant-transcript",onScroll:gr,children:i.jsxs("div",{className:"mx-auto w-full max-w-5xl space-y-8 px-4 py-6 sm:px-6 sm:py-8",children:[b.isLoading&&h&&i.jsxs("div",{className:"space-y-5","aria-label":"Loading conversation",children:[i.jsx(Fe,{className:"ml-auto h-16 w-2/3"}),i.jsx(Fe,{className:"h-40 w-full"})]}),b.isError&&h&&(Oe?i.jsxs("div",{className:"rounded-lg border border-warning-solid/25 bg-warning-tint px-4 py-3 text-sm text-warning-deep",role:"alert",children:[i.jsx("p",{className:"font-semibold",children:"This conversation is no longer available"}),i.jsx("p",{className:"mt-1",children:"Your permissions or station access changed after its evidence was created. Start a new chat for a current, correctly scoped answer."})]}):i.jsx(Gt,{title:"This conversation could not be loaded",onRetry:b.refetch,retrying:b.isFetching})),wr&&i.jsxs("div",{className:"py-4 sm:py-10",children:[i.jsxs("div",{className:"max-w-2xl",children:[i.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Ask your operation"}),i.jsx("h2",{className:"mt-2 text-2xl font-semibold tracking-tight text-slate-950",children:"What needs your attention?"}),i.jsx("p",{className:"mt-2 max-w-xl text-sm leading-6 text-slate-600",children:"Sortd AI checks the data you already have access to, shows the exact evidence, and explains what it means."})]}),i.jsx("div",{className:"mt-6 grid gap-2 sm:grid-cols-2","aria-label":"Starter questions",children:Gs.map(S=>
14i.jsx("button",{type:"button",className:"min-h-14 rounded-lg border border-slate-200 bg-white px-4 py-3 text-left text-sm font-medium leading-5 text-slate-800 shadow-sm transition-colors hover:border-slate-400 hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>{ee(S)},children:S},S))})]}),!b.isLoading&&he.map(S=>S.role==="user"?i.jsx(Ot,{text:S.text,onReask:()=>{ee(S.text)},disabled:U||!!g},S.id):i.jsx(It,{text:S.text,blocks:Array.isArray(S.blocks)?S.blocks:[],surface:e,followups:S.usage?.followups||[],failed:S.usage?.failed===!0,onFollowup:U||g?void 0:G=>{ee(G)},sessionId:h,onOpenFullPage:n?r:void 0},S.id)),jr&&g&&i.jsxs(i.Fragment,{children:[i.jsx(Ot,{text:g}),i.jsxs("div",{className:"space-y-4",children:[i.jsx(Ks,{activities:$}),i.jsx(It,{text:N,blocks:C,surface:e,followups:O,streaming:U,onFollowup:U?void 0:S=>{ee(S)},sessionId:A,onOpenFullPage:n?r:void 0}),k&&i.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-danger-solid/25 bg-danger-tint px-4 py-3 text-sm text-danger-deep sm:flex-row sm:items-center sm:justify-between",role:"alert",children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(ue,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),i.jsxs("div",{children:[_==="ASSISTANT_DAILY_BUDGET_EXCEEDED"&&i.jsx("p",{className:"font-semibold",children:"Daily limit reached"}),i.jsx("p",{children:k}),_==="ASSISTANT_DAILY_BUDGET_EXCEEDED"&&i.jsx("p",{className:"mt-1 text-xs",children:"Sortd AI resets at your company’s local midnight. Superadmins can review company usage."})]})]}),!["ASSISTANT_DAILY_BUDGET_EXCEEDED","ASSISTANT_RATE_LIMITED"].includes(_||"")&&i.jsx(te,{variant:"outline",size:"sm",className:"min-h-11 shrink-0 bg-white",onClick:()=>{const S=g;ye(),v(S)},children:"Start new chat"})]})]})]}),i.jsx("div",{ref:L})]})}),oe&&i.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"absolute bottom-24 right-4 z-20 min-h-11 bg-white shadow-md sm:right-6",onClick:br,children:[i.jsx(rn,{className:"h-4 w-4","aria-hidden":"true"})," Jump to latest"]}),i.jsxs("div",{className:"shrink-0 border-t border-slate-200 bg-white p-3 sm:p-4",children:[i.jsxs("form",{onSubmit:yr,className:"mx-auto flex w-full max-w-5xl items-end gap-2 rounded-xl border border-slate-300 bg-white p-2 shadow-sm focus-within:ring-2 focus-within:ring-slate-900/20",children:[i.jsx(tn,{value:x,onChange:S=>v(S.target.value),onKeyDown:xr,maxRows:6,mobileMaxRows:4,minHeight:52,maxLength:4e3,placeholder:"Ask about scorecards, drivers, safety, sign-ins, disputes…","aria-label":"Ask Sortd AI",className:"min-w-0 flex-1 border-0 px-2 shadow-none focus:ring-0",disabled:U||!!g&&!ve}),U?i.jsx(te,{type:"button",size:"icon",variant:"outline",onClick:()=>{const S=A;F.current+=1,T(),P(null),S&&y(S),b.refetch()},className:"h-11 w-11","aria-label":"Stop response",children:i.jsx(an,{className:"h-3.5 w-3.5 fill-current","aria-hidden":"true"})}):i.jsx(te,{type:"submit",size:"icon",className:"h-11 w-11",disabled:!x.trim()||!!g&&!ve,"aria-label":"Send question",children:i.jsx(nn,{className:"h-4 w-4","aria-hidden":"true"})})]}),i.jsx("p",{className:"mx-auto mt-2 max-w-5xl text-center font-mono text-caption text-slate-500",children:"Sortd AI can make mistakes in interpretation. Evidence blocks are rendered directly from Sortd data."})]})]})]})}function fo(){const{enabled:e,isLoading:t,isError:r,error:a,refetch:n}=Hr("sortd_ai_v1");return u.useEffect(()=>{r&&console.error("[sortd-ai] access flag lookup failed",a)},[a,r]),t?i.jsx(Ur,{label:"Loading Sortd AI…"}):r?i.jsx(Gt,{title:"Sortd AI access could not be loaded",description:"Check your connection and try again.",onRetry:n}):e?i.jsx(Zs,{}):i.jsx(qr,{to:"/dashboard",replace:!0})}export{Zs as AssistantWorkspace,fo as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.