orbcafe-ui 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -195,5 +195,5 @@ ${W}`,ue=encodeURI(G),oe=document.createElement("a");oe.setAttribute("href",ue),
195
195
  `,o?`${t}: ${a(p.primaryValue)}`:`${t}: ${a(p.primaryValue)}`,o?`
196
196
  ${o}: ${(r??a)(p.secondaryValue??0)}`:""]})}),jsxRuntime.jsx("text",{x:p.x,y:Math.max(p.y-12,d.top+8),textAnchor:"middle",fontSize:"10",fill:n.palette.text.secondary,children:p.name})]},p.name)),jsxRuntime.jsx("text",{x:i/2,y:c-10,textAnchor:"middle",fontSize:"11",fill:n.palette.text.secondary,children:o?t:"Index"}),jsxRuntime.jsx("text",{x:16,y:c/2,textAnchor:"middle",transform:`rotate(-90 16 ${c/2})`,fontSize:"11",fill:n.palette.text.secondary,children:o??t}),jsxRuntime.jsx("text",{x:d.left,y:d.top-4,fontSize:"10",fill:n.palette.text.secondary,children:Hu(f)}),jsxRuntime.jsx("text",{x:i-d.right,y:c-d.bottom+16,textAnchor:"end",fontSize:"10",fill:n.palette.text.secondary,children:Hu(g)})]})}),jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))",lg:"repeat(3, minmax(0, 1fr))"},gap:1},children:e.map(p=>jsxRuntime.jsxs(material.Box,{sx:C=>({borderRadius:2,px:1.25,py:1,border:`1px solid ${styles.alpha(C.palette.divider,.7)}`,bgcolor:styles.alpha(C.palette.background.default,.35)}),children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.78rem",fontWeight:700},noWrap:true,title:p.name,children:p.name}),jsxRuntime.jsxs(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:[t,": ",a(p.primaryValue)]}),o&&jsxRuntime.jsxs(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:[o,": ",(r??a)(p.secondaryValue??0)]})]},p.name))})]})};var Rc=e=>Math.max(...e,1),Ku=({data:e,chartType:t,primaryLabel:o,secondaryLabel:a,formatPrimaryValue:r,formatSecondaryValue:n})=>{let i=styles.useTheme(),c=i.palette.primary.main,d=i.palette.warning.main;if(e.length===0)return null;if(t==="bar-horizontal"){let m=Rc(e.flatMap(y=>[y.primaryValue,y.secondaryValue??0]));return jsxRuntime.jsx(material.Stack,{spacing:1.1,children:e.map(y=>jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"160px 1fr 128px"},gap:1.25,alignItems:"center"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.78rem",fontWeight:700},noWrap:true,title:y.name,children:y.name}),jsxRuntime.jsxs(material.Stack,{spacing:.65,children:[jsxRuntime.jsx(material.Box,{sx:{height:10,borderRadius:999,overflow:"hidden",bgcolor:styles.alpha(i.palette.action.active,.08)},children:jsxRuntime.jsx(material.Box,{sx:{width:`${y.primaryValue/m*100}%`,height:"100%",bgcolor:c}})}),a&&jsxRuntime.jsx(material.Box,{sx:{height:8,borderRadius:999,overflow:"hidden",bgcolor:styles.alpha(i.palette.action.active,.08)},children:jsxRuntime.jsx(material.Box,{sx:{width:`${(y.secondaryValue??0)/m*100}%`,height:"100%",bgcolor:d}})})]}),jsxRuntime.jsxs(material.Box,{sx:{minWidth:0},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",textAlign:{xs:"left",md:"right"},fontWeight:700},children:r(y.primaryValue)}),a&&jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",textAlign:{xs:"left",md:"right"},color:"text.secondary"},children:(n??r)(y.secondaryValue??0)})]})]},y.name))})}if(t==="bar-vertical"){let m=Rc(e.flatMap(x=>[x.primaryValue,x.secondaryValue??0])),y=a?92:76;return jsxRuntime.jsx(material.Box,{sx:{overflowX:"auto",pb:.5},children:jsxRuntime.jsx(material.Box,{sx:{minWidth:Math.max(620,e.length*y),display:"grid",gridTemplateColumns:`repeat(${e.length}, minmax(56px, 1fr))`,gap:1,alignItems:"end"},children:e.map(x=>jsxRuntime.jsxs(material.Box,{sx:{minWidth:0},children:[jsxRuntime.jsxs(material.Box,{sx:{height:210,display:"flex",alignItems:"flex-end",justifyContent:"center",gap:.8},children:[jsxRuntime.jsx(material.Box,{sx:{width:a?16:26,minHeight:8,height:`${Math.max(x.primaryValue/m*188,8)}px`,borderRadius:"10px 10px 2px 2px",bgcolor:c},title:`${o}: ${r(x.primaryValue)}`}),a&&jsxRuntime.jsx(material.Box,{sx:{width:16,minHeight:8,height:`${Math.max((x.secondaryValue??0)/m*188,8)}px`,borderRadius:"10px 10px 2px 2px",bgcolor:d},title:`${a}: ${(n??r)(x.secondaryValue??0)}`})]}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.76rem",fontWeight:700},noWrap:true,title:x.name,children:x.name}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.7rem",color:"text.secondary"},noWrap:true,title:r(x.primaryValue),children:r(x.primaryValue)}),a&&jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.7rem",color:"text.secondary"},noWrap:true,title:(n??r)(x.secondaryValue??0),children:(n??r)(x.secondaryValue??0)})]},x.name))})})}let l=Math.max(680,e.length*74),s=240,g={top:20,right:18,bottom:36,left:18},f=Rc(e.flatMap(m=>[m.primaryValue,m.secondaryValue??0])),u=l-g.left-g.right,h=s-g.top-g.bottom,v=m=>e.map((y,x)=>{let S=g.left+x*u/Math.max(e.length-1,1),B=s-g.bottom-m(y)/f*h;return {x:S,y:B,item:y}}),p=v(m=>m.primaryValue),C=a?v(m=>m.secondaryValue??0):[];return jsxRuntime.jsxs(material.Box,{sx:{display:"flex",flexDirection:"column",gap:1.1},children:[jsxRuntime.jsx(material.Box,{sx:{overflowX:"auto"},children:jsxRuntime.jsxs(material.Box,{component:"svg",viewBox:`0 0 ${l} ${s}`,sx:{width:"100%",minWidth:l,height:s},children:[jsxRuntime.jsx("line",{x1:g.left,y1:s-g.bottom,x2:l-g.right,y2:s-g.bottom,stroke:styles.alpha(i.palette.text.secondary,.35)}),jsxRuntime.jsx("polyline",{fill:"none",stroke:c,strokeWidth:3,points:p.map(m=>`${m.x},${m.y}`).join(" ")}),p.map(m=>jsxRuntime.jsx("circle",{cx:m.x,cy:m.y,r:4,fill:c,children:jsxRuntime.jsxs("title",{children:[m.item.name,`
197
197
  `,o,": ",r(m.item.primaryValue)]})},`primary-${m.item.name}`)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("polyline",{fill:"none",stroke:d,strokeWidth:2.5,strokeDasharray:"5 5",points:C.map(m=>`${m.x},${m.y}`).join(" ")}),C.map(m=>jsxRuntime.jsx("circle",{cx:m.x,cy:m.y,r:3.5,fill:d,children:jsxRuntime.jsxs("title",{children:[m.item.name,`
198
- `,a,": ",(n??r)(m.item.secondaryValue??0)]})},`secondary-${m.item.name}`))]})]})}),jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))",xl:"repeat(4, minmax(0, 1fr))"},gap:1},children:e.map(m=>jsxRuntime.jsxs(material.Box,{sx:y=>({borderRadius:2,px:1.1,py:.9,border:`1px solid ${styles.alpha(y.palette.divider,.7)}`,bgcolor:styles.alpha(y.palette.background.default,.35)}),children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.76rem",fontWeight:700},noWrap:true,title:m.name,children:m.name}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.71rem",color:"text.secondary"},children:r(m.primaryValue)}),a&&jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.71rem",color:"text.secondary"},children:(n??r)(m.secondaryValue??0)})]},m.name))})]})};var qu=(e,t,o)=>{let a=new Set,r=[];return e.forEach(n=>{a.has(n)||(a.add(n),r.push({fieldId:n,label:o.get(n)?.label??n,zone:"rows"}));}),t.forEach(n=>{a.has(n)||(a.add(n),r.push({fieldId:n,label:o.get(n)?.label??n,zone:"columns"}));}),r},_u=(e,t,o)=>e.map(a=>{let r=t.get(a.fieldId),n=r?.label??a.fieldId;return {fieldId:a.fieldId,label:`${o(a.aggregation)} \xB7 ${n}`,item:a,field:r}}),ju=({rows:e,dimensionFieldId:t,primaryValue:o,secondaryValue:a})=>{if(!t)return [];let r=new Map;return e.forEach(n=>{let i=ga(n[t]),c=r.get(i);if(c){c.push(n);return}r.set(i,[n]);}),Array.from(r.entries()).sort((n,i)=>n[0].localeCompare(i[0],void 0,{sensitivity:"base"})).map(([n,i])=>({name:n,primaryValue:on(i,o.fieldId,o.aggregation),secondaryValue:a?on(i,a.fieldId,a.aggregation):void 0}))};var Zu=({rows:e,fieldMap:t,rowFields:o,columnFields:a,valueFields:r,chartDimensionFieldId:n,chartPrimaryValueFieldId:i,chartSecondaryValueFieldId:c,chartType:d,isCollapsed:l,onChartDimensionFieldIdChange:s,onChartPrimaryValueFieldIdChange:g,onChartSecondaryValueFieldIdChange:f,onChartTypeChange:u,onToggleCollapse:h,getAggregationLabel:v})=>{let{t:p}=Q(),C=ht.useMemo(()=>qu(o,a,t),[a,t,o]),m=ht.useMemo(()=>_u(r,t,v),[t,v,r]),y=m.find(k=>k.fieldId===i)??m[0],x=m.find(k=>k.fieldId===c&&k.fieldId!==y?.fieldId)??null,S=C.find(k=>k.fieldId===n)??C[0],B=S&&y?p("pivot.chart.subtitleReady",{dimension:S.label,measure:x?`${y.label} / ${x.label}`:y.label}):p("pivot.chart.subtitle"),R=ht.useMemo(()=>!S||!y?[]:ju({rows:e,dimensionFieldId:S.fieldId,primaryValue:y.item,secondaryValue:x?.item}),[y,e,x,S]),w=k=>y?ai(k,y.item,t):k.toLocaleString(),A=k=>x?ai(k,x.item,t):k.toLocaleString(),P=C.length>1||m.length>1;return jsxRuntime.jsxs(ln,{title:p("pivot.chart.title"),subtitle:B,collapsed:l,onToggleCollapse:h,expandAriaLabel:p("pivot.chart.collapse.ariaExpand"),collapseAriaLabel:p("pivot.chart.collapse.ariaCollapse"),bodySx:{display:"flex",flexDirection:"column",gap:1.1},children:[P&&jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))",xl:"repeat(4, minmax(0, 1fr))"},gap:1,alignItems:"start"},children:[jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.dimension")}),jsxRuntime.jsx(material.Select,{value:S?.fieldId??"",onChange:k=>s(String(k.target.value)),sx:{fontSize:"0.75rem",height:32},children:C.map(k=>jsxRuntime.jsx(material.MenuItem,{value:k.fieldId,sx:{fontSize:"0.75rem"},children:k.label},k.fieldId))})]}),jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.primaryMeasure")}),jsxRuntime.jsx(material.Select,{value:y?.fieldId??"",onChange:k=>g(String(k.target.value)),sx:{fontSize:"0.75rem",height:32},children:m.map(k=>jsxRuntime.jsx(material.MenuItem,{value:k.fieldId,sx:{fontSize:"0.75rem"},children:k.label},k.fieldId))})]}),jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.secondaryMeasure")}),jsxRuntime.jsxs(material.Select,{value:x?.fieldId??"",onChange:k=>f(String(k.target.value)),sx:{fontSize:"0.75rem",height:32},children:[jsxRuntime.jsx(material.MenuItem,{value:"",sx:{fontSize:"0.75rem",color:"text.secondary"},children:p("common.none")}),m.filter(k=>k.fieldId!==y?.fieldId).map(k=>jsxRuntime.jsx(material.MenuItem,{value:k.fieldId,sx:{fontSize:"0.75rem"},children:k.label},k.fieldId))]})]}),jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.chartType")}),jsxRuntime.jsxs(material.Select,{value:d,onChange:k=>u(k.target.value),sx:{fontSize:"0.75rem",height:32},children:[jsxRuntime.jsx(material.MenuItem,{value:"bar-vertical",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.barVertical")}),jsxRuntime.jsx(material.MenuItem,{value:"bar-horizontal",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.barHorizontal")}),jsxRuntime.jsx(material.MenuItem,{value:"line",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.line")}),jsxRuntime.jsx(material.MenuItem,{value:"scatter",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.scatter")})]})]})]}),jsxRuntime.jsx(material.Box,{children:S?y?R.length===0?jsxRuntime.jsx(material.Box,{sx:{py:5,textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:p("pivot.chart.emptyNoData")})}):d==="scatter"?jsxRuntime.jsx(Gu,{data:R,primaryLabel:y.label,secondaryLabel:x?.label,formatPrimaryValue:w,formatSecondaryValue:A}):jsxRuntime.jsx(Ku,{data:R,chartType:d,primaryLabel:y.label,secondaryLabel:x?.label,formatPrimaryValue:w,formatSecondaryValue:A}):jsxRuntime.jsx(material.Box,{sx:{py:5,textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:p("pivot.chart.emptyNoValue")})}):jsxRuntime.jsx(material.Box,{sx:{py:5,textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:p("pivot.chart.emptyNoDimension")})})})]})};var Os=({node:e,dataColumns:t,fieldMap:o,level:a,expandedKeys:r,onToggle:n,getValue:i})=>{let c=r.has(e.key),d=e.children.length>0,l=e.isGrandTotal;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(material.TableRow,{sx:s=>({bgcolor:l?s.palette.mode==="dark"?"rgba(25, 118, 210, 0.22)":"rgba(47, 91, 255, 0.08)":s.palette.mode==="dark"?"#111111":"background.paper","&:hover":{bgcolor:l?s.palette.mode==="dark"?"rgba(25, 118, 210, 0.28)":"rgba(47, 91, 255, 0.12)":s.palette.mode==="dark"?"#181818":"rgba(0, 0, 0, 0.02)"}}),children:[jsxRuntime.jsxs(material.TableCell,{sx:s=>({fontSize:"0.76rem",fontWeight:l?800:600,borderBottom:`1px solid ${s.palette.divider}`,whiteSpace:"nowrap",pl:a*2+1,display:"flex",alignItems:"center",height:40}),children:[d&&!l&&jsxRuntime.jsx(material.IconButton,{size:"small",onClick:()=>n(e.key),sx:{p:.2,mr:.5,ml:-1},children:c?jsxRuntime.jsx(ch__default.default,{sx:{fontSize:16}}):jsxRuntime.jsx(qf__default.default,{sx:{fontSize:16}})}),!d&&!l&&a>0&&jsxRuntime.jsx(material.Box,{sx:{width:20}}),e.value]}),t.map(s=>jsxRuntime.jsx(material.TableCell,{align:"right",sx:{fontSize:"0.76rem",fontWeight:l?800:500,borderBottom:g=>`1px solid ${g.palette.divider}`,whiteSpace:"nowrap"},children:ai(i?i(e,s.id):e.aggregatedValues[s.id]??0,s.valueItem,o)},`${e.key}-${s.id}`))]}),c&&e.children.map(s=>jsxRuntime.jsx(Os,{node:s,dataColumns:t,fieldMap:o,level:a+1,expandedKeys:r,onToggle:n,getValue:i},s.key))]})};var Ec=(e,t,o)=>{let a=[...e,...t];return o&&a.includes(o)?o:a[0]??""},Hs=(e,t)=>t&&e.some(o=>o.fieldId===t)?t:e[0]?.fieldId??"",Fc=(e,t,o)=>o===""?"":o&&o!==t&&e.some(a=>a.fieldId===o)?o:e.find(a=>a.fieldId!==t)?.fieldId??"",om=e=>{let t=new Set,o=a=>{a.forEach(r=>{r.children.length>0&&(t.add(r.key),o(r.children));});};return o(e),t},rm=(e,t,o=0)=>e.length===0?o:e.reduce((a,r)=>r.children.length===0||!t.has(r.key)?Math.max(a,o+1):Math.max(a,rm(r.children,t,o+1)),o),oC=(e,t)=>{let o=[],a=r=>{r.forEach(n=>{if(n.children.length>0&&t.has(n.key)){a(n.children);return}o.push(n);});};return a(e),o},y5=({title:e,rows:t,fields:o,initialLayout:a,initialChart:r,emptyText:n,maxPreviewHeight:i=520,initialChartCollapsed:c=false,initialTableCollapsed:d=false,model:l,enablePresetManagement:s=false,presets:g,defaultPresets:f,onPresetsChange:u,initialPresetId:h,onPresetApplied:v})=>{let{t:p}=Q(),C=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:8}})),m=ht.useRef(0),y=ht.useRef(false),x=e??p("pivot.title.default"),S=n??p("pivot.empty"),B=ht.useMemo(()=>({sum:p("pivot.agg.sum"),count:p("pivot.agg.count"),avg:p("pivot.agg.avg"),min:p("pivot.agg.min"),max:p("pivot.agg.max")}),[p]),R=ht.useCallback(b=>B[b]??wu[b],[B]),w=ht.useMemo(()=>new Set(o.map(b=>b.id)),[o]),A=ht.useMemo(()=>new Map(o.map(b=>[b.id,b])),[o]),[P,k]=ht.useState(()=>St(a?.rows,w)),[D,T]=ht.useState(()=>St(a?.columns,w)),[I,M]=ht.useState(()=>St(a?.filters,w)),[H,V]=ht.useState(()=>{let b=a?.values??[],E=new Set,F=[];return b.forEach(U=>{if(!w.has(U.fieldId)||E.has(U.fieldId))return;E.add(U.fieldId),m.current+=1;let re=A.get(U.fieldId);F.push({tokenId:`v${m.current}`,fieldId:U.fieldId,aggregation:qt(U.aggregation,re)});}),F}),[J,ce]=ht.useState({}),[te,ne]=ht.useState(true),[ee,Y]=ht.useState(false),[Ze,Ue]=ht.useState(()=>Ec(St(a?.rows,w),St(a?.columns,w),r?.dimensionFieldId)),[ie,Ie]=ht.useState(()=>{let b=(a?.values??[]).filter((E,F,U)=>w.has(E.fieldId)&&U.findIndex(re=>re.fieldId===E.fieldId)===F).map(E=>({tokenId:E.fieldId,fieldId:E.fieldId,aggregation:qt(E.aggregation,A.get(E.fieldId))}));return Hs(b,r?.primaryValueFieldId)}),[Fe,Oe]=ht.useState(()=>{let b=(a?.values??[]).filter((F,U,re)=>w.has(F.fieldId)&&re.findIndex(ve=>ve.fieldId===F.fieldId)===U).map(F=>({tokenId:F.fieldId,fieldId:F.fieldId,aggregation:qt(F.aggregation,A.get(F.fieldId))})),E=Hs(b,r?.primaryValueFieldId);return Fc(b,E,r?.secondaryValueFieldId)}),[nt,Le]=ht.useState(r?.chartType??"bar-vertical"),[Xe,Zt]=ht.useState(c),[zt,Qe]=ht.useState(d),[lt,mt]=ht.useState(()=>f??[]),[_e,K]=ht.useState(""),[Ce,fe]=ht.useState(false),[be,Ne]=ht.useState(""),[Ve,Ht]=ht.useState(null),[Nt,Xt]=ht.useState(new Set(["__grand_total__"])),[Qt,Yt]=ht.useState(new Set),L=l?.rowFields??P,$=l?.columnFields??D,j=l?.filterFields??I,_=l?.valueFields??H,ke=l?.filterSelections??J,Ee=l?.showGrandTotal??te,Ye=l?.isConfiguratorCollapsed??ee,z=l?.chartDimensionFieldId??Ze,W=l?.chartPrimaryValueFieldId??ie,G=l?.chartSecondaryValueFieldId??Fe,ue=l?.chartType??nt,oe=l?.isChartCollapsed??Xe,Se=l?.isTableCollapsed??zt,ge=g??lt,Pe=s||ge.length>0||!!u,he=ht.useCallback(b=>{if(l?.setRowFields){l.setRowFields(b);return}k(b);},[l]),ze=ht.useCallback(b=>{if(l?.setColumnFields){l.setColumnFields(b);return}T(b);},[l]),Be=ht.useCallback(b=>{if(l?.setFilterFields){l.setFilterFields(b);return}M(b);},[l]),we=ht.useCallback(b=>{if(l?.setValueFields){l.setValueFields(b);return}V(b);},[l]),Me=ht.useCallback(b=>{if(l?.setFilterSelections){l.setFilterSelections(b);return}ce(b);},[l]),Tt=ht.useCallback(b=>{if(l?.setShowGrandTotal){l.setShowGrandTotal(b);return}ne(b);},[l]),Io=ht.useCallback(b=>{if(l?.setIsConfiguratorCollapsed){l.setIsConfiguratorCollapsed(b);return}Y(b);},[l]),Ct=ht.useCallback(b=>{if(l?.setChartDimensionFieldId){l.setChartDimensionFieldId(b);return}Ue(b);},[l]),It=ht.useCallback(b=>{if(l?.setChartPrimaryValueFieldId){l.setChartPrimaryValueFieldId(b);return}Ie(b);},[l]),bo=ht.useCallback(b=>{if(l?.setChartSecondaryValueFieldId){l.setChartSecondaryValueFieldId(b);return}Oe(b);},[l]),ka=ht.useCallback(b=>{if(l?.setChartType){l.setChartType(b);return}Le(b);},[l]),Rr=ht.useCallback(b=>{if(l?.setIsChartCollapsed){l.setIsChartCollapsed(b);return}Zt(b);},[l]),Po=ht.useCallback(b=>{if(l?.setIsTableCollapsed){l.setIsTableCollapsed(b);return}Qe(b);},[l]),ro=ht.useCallback(b=>{let E=typeof b=="function"?b(ge):b;g||mt(E),u?.(E);},[u,ge,g]),Za=ht.useMemo(()=>new Set([...L,...$,...j]),[L,$,j]),Yo=ht.useMemo(()=>o.filter(b=>!Za.has(b.id)),[o,Za]),Gt=ht.useMemo(()=>{let b=[...L,...$,...j],E=new Set,F=[];return b.forEach(U=>{E.has(U)||(E.add(U),F.push(U));}),F},[$,j,L]);ht.useEffect(()=>{he(b=>{let E=b.filter(F=>w.has(F));return fa(b,E)?b:E}),ze(b=>{let E=b.filter(F=>w.has(F));return fa(b,E)?b:E}),Be(b=>{let E=b.filter(F=>w.has(F));return fa(b,E)?b:E}),we(b=>{let E=b.filter(F=>w.has(F.fieldId)).map(F=>({...F,aggregation:qt(F.aggregation,A.get(F.fieldId))}));return Rs(b,E)?b:E});},[A,w]);let no=ht.useMemo(()=>{let b={};return Gt.forEach(E=>{let F=new Set;t.forEach(U=>{F.add(ga(U[E]));}),b[E]=Array.from(F).sort((U,re)=>U.localeCompare(re));}),b},[Gt,t]);ht.useEffect(()=>{Me(b=>{let E={};return Gt.forEach(F=>{let U=no[F]??[],ve=(b[F]??[]).filter(X=>U.includes(X)),N=Object.prototype.hasOwnProperty.call(b,F);E[F]=N?ve:U;}),Mu(b,E)?b:E});},[Gt,no]),ht.useEffect(()=>{Ct(b=>Ec(L,$,b));},[$,L,Ct]),ht.useEffect(()=>{It(b=>Hs(_,b));},[It,_]),ht.useEffect(()=>{bo(b=>Fc(_,W,b));},[W,bo,_]);let Vt=ht.useMemo(()=>t.filter(b=>Gt.every(E=>{let F=ke[E]??[],U=no[E]??[];if(F.length===U.length)return true;if(F.length===0)return false;let re=ga(b[E]);return F.includes(re)})),[Gt,no,ke,t]),We=ht.useMemo(()=>{if(_.length===0)return null;let b=new Map;if(Vt.forEach(N=>{let X=$.length>0?$.map(Je=>ga(N[Je])):[p("pivot.valueLabel")],Z=hr(X);b.set(Z,X);}),b.size===0){let N=$.length>0?$.map(()=>Is):[p("pivot.valueLabel")];b.set(hr(N),N);}let E=Array.from(b.entries()).sort((N,X)=>Du(N[1],X[1])),F=E.flatMap(([N,X])=>_.map(Z=>{let Je=A.get(Z.fieldId),O=`${R(Z.aggregation)} ${Je?.label??Z.fieldId}`,ae=$.length===0||_.length>1?`${X.join(" / ")} \u2022 ${O}`:X.join(" / ");return {id:`${N}::${Z.tokenId}`,colKey:N,valueItem:Z,label:ae}})),U=[];$.length>0&&E.forEach(([N,X])=>{let Z=F.filter(ae=>ae.colKey===N),Je=U,O=[];X.forEach((ae,q)=>{O.push(`d${q}:${ae}`);let de=`col::${hr(O)}`,$e=Je.find(Ko=>Ko.key===de);$e||($e={key:de,label:ae,children:[],leafColumnIds:[],path:X.slice(0,q+1),depth:q},Je.push($e)),Z.forEach(Ko=>{$e.leafColumnIds.includes(Ko.id)||$e.leafColumnIds.push(Ko.id);}),Je=$e.children;});});let re=N=>{let X={};return F.forEach(Z=>{let Je=N.filter(O=>{let ae=$.length>0?$.map(q=>ga(O[q])):[p("pivot.valueLabel")];return hr(ae)===Z.colKey});X[Z.id]=on(Je,Z.valueItem.fieldId,Z.valueItem.aggregation);}),X},ve=[];if(L.length===0)ve.push({key:"root",value:p("pivot.resultLabel")||ku,children:[],isLeaf:true,aggregatedValues:re(Vt),path:[],depth:0});else {let N=(X,Z,Je)=>{if(Z>=L.length)return [];let O=L[Z],ae=new Map;return X.forEach(q=>{let de=ga(q[O]);ae.has(de)||ae.set(de,[]),ae.get(de).push(q);}),Array.from(ae.keys()).sort().map(q=>{let de=ae.get(q),$e=[...Je,q];return {key:hr($e),value:q,fieldId:O,aggregatedValues:re(de),children:N(de,Z+1,$e),isLeaf:Z===L.length-1,path:$e,depth:Z}})};ve.push(...N(Vt,0,[]));}return {dataColumns:F,columnTree:U,rowTree:ve}},[$,A,Vt,R,L,p,_]),Jo=ht.useCallback((b,E)=>(m.current+=1,{tokenId:`v${m.current}`,fieldId:b,aggregation:qt(E,A.get(b))}),[A]),$o=ht.useCallback(b=>{if(b==="rows")return he([]);if(b==="columns")return ze([]);if(b==="filters")return Be([]);we([]);},[]),ea=ht.useCallback((b,E)=>{if(b==="rows")return he(F=>F.filter(U=>U!==E));if(b==="columns")return ze(F=>F.filter(U=>U!==E));if(b==="filters")return Be(F=>F.filter(U=>U!==E));we(F=>F.filter(U=>U.tokenId!==E));},[]),Xa=ht.useCallback((b,E)=>{we(F=>F.map(U=>U.tokenId===b?{...U,aggregation:qt(E,A.get(U.fieldId))}:U));},[A]),Ho=ht.useCallback(b=>{Ht(String(b.active.id));},[]),Qa=ht.useCallback(b=>{if(Ht(null),!b.over)return;let E=Ps(String(b.active.id)),F=Ps(String(b.over.id));if(!E||!F||E.kind!=="item"||!E.key)return;if(E.zone===F.zone&&F.kind==="item"){if(E.zone==="rows"){let q=L.indexOf(E.key),de=L.indexOf(F.key??"");q!==-1&&de!==-1&&q!==de&&he($e=>sortable.arrayMove($e,q,de));return}if(E.zone==="columns"){let q=$.indexOf(E.key),de=$.indexOf(F.key??"");q!==-1&&de!==-1&&q!==de&&ze($e=>sortable.arrayMove($e,q,de));return}if(E.zone==="filters"){let q=j.indexOf(E.key),de=j.indexOf(F.key??"");q!==-1&&de!==-1&&q!==de&&Be($e=>sortable.arrayMove($e,q,de));return}if(E.zone==="values"){let q=_.findIndex($e=>$e.tokenId===E.key),de=_.findIndex($e=>$e.tokenId===(F.key??""));q!==-1&&de!==-1&&q!==de&&we($e=>sortable.arrayMove($e,q,de));}return}let U=F.zone,re=[...L],ve=[...$],N=[...j],X=[..._],Z="",Je=null;if(E.zone==="palette")Z=E.key;else if(E.zone==="values"){let q=X.find(de=>de.tokenId===E.key);if(!q)return;Z=q.fieldId,Je=q,X=X.filter(de=>de.tokenId!==E.key);}else E.zone==="rows"?(Z=E.key,re=re.filter(q=>q!==Z)):E.zone==="columns"?(Z=E.key,ve=ve.filter(q=>q!==Z)):E.zone==="filters"&&(Z=E.key,N=N.filter(q=>q!==Z));if(!Z)return;let O=()=>{re=re.filter(q=>q!==Z),ve=ve.filter(q=>q!==Z),N=N.filter(q=>q!==Z);},ae=q=>{if(F.kind!=="item"||!F.key)return q==="rows"?re.length:q==="columns"?ve.length:q==="filters"?N.length:q==="values"?X.length:0;if(q==="rows"){let de=re.indexOf(F.key);return de>=0?de:re.length}if(q==="columns"){let de=ve.indexOf(F.key);return de>=0?de:ve.length}if(q==="filters"){let de=N.indexOf(F.key);return de>=0?de:N.length}if(q==="values"){let de=X.findIndex($e=>$e.tokenId===F.key);return de>=0?de:X.length}return 0};if(U==="palette"){he(re),ze(ve),Be(N),we(X);return}if(U==="values"){let q=ae("values"),de=Je??Jo(Z);X.splice(q,0,de),he(re),ze(ve),Be(N),we(X);return}if(Ru(U)){O();let q=ae(U);U==="rows"?re.splice(q,0,Z):U==="columns"?ve.splice(q,0,Z):N.splice(q,0,Z),he(re),ze(ve),Be(N),we(X);}},[$,Jo,j,L,_]),Ya=ht.useCallback((b,E)=>{Me(F=>({...F,[b]:E}));},[]),Go=ht.useCallback(b=>{Xt(E=>{let F=new Set(E);return F.has(b)?F.delete(b):F.add(b),F});},[]),ta=ht.useCallback(b=>{Yt(E=>{let F=new Set(E);return F.has(b)?F.delete(b):F.add(b),F});},[]),Sa=ht.useCallback(b=>{let E=A.get(b.fieldId),F=vc(E);return jsxRuntime.jsx(material.FormControl,{size:"small",sx:{minWidth:98},children:jsxRuntime.jsx(material.Select,{value:b.aggregation,onChange:U=>Xa(b.tokenId,U.target.value),onClick:U=>U.stopPropagation(),onMouseDown:U=>U.stopPropagation(),sx:{fontSize:"0.72rem",height:26,"& .MuiSelect-select":{py:.35}},children:F.map(U=>jsxRuntime.jsx(material.MenuItem,{value:U,sx:{fontSize:"0.75rem"},children:R(U)},U))})})},[A,R,Xa]),Ut=ht.useCallback(b=>{let E=no[b]??[],F=ke[b]??E;return E.length===0?p("pivot.filter.noValues"):F.length===0?p("pivot.filter.noneSelected"):F.length===E.length?p("pivot.filter.allValues"):p("pivot.filter.selectedCount",{selected:F.length,total:E.length})},[no,ke,p]),Ro=ht.useCallback(b=>{let E=no[b]??[],F=ke[b]??E;return jsxRuntime.jsx(Eu,{options:E,selectedValues:F,onChange:U=>Ya(b,U)})},[no,ke,Ya]),oa=ht.useCallback(()=>`pivot-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,[]),xo=ht.useCallback(()=>{let b={};return new Set([...Gt,...Object.keys(ke)]).forEach(F=>{if(!w.has(F))return;let U=ke[F]??[];b[F]=[...U];}),{layout:{rows:[...L],columns:[...$],filters:[...j],values:_.map(F=>({fieldId:F.fieldId,aggregation:F.aggregation}))},filterSelections:b,showGrandTotal:Ee,chart:{dimensionFieldId:z,primaryValueFieldId:W,secondaryValueFieldId:G,chartType:ue}}},[Gt,z,W,G,ue,$,j,ke,L,Ee,w,_]),Uo=ht.useCallback(b=>{let E=St(b.layout.rows,w),F=St(b.layout.columns,w),U=St(b.layout.filters,w),re=new Set,ve=(b.layout.values??[]).filter(Z=>!w.has(Z.fieldId)||re.has(Z.fieldId)?false:(re.add(Z.fieldId),true)).map(Z=>Jo(Z.fieldId,Z.aggregation)),N={};Object.entries(b.filterSelections??{}).forEach(([Z,Je])=>{!w.has(Z)||!Array.isArray(Je)||(N[Z]=Array.from(new Set(Je.map(O=>String(O)))));}),he(E),ze(F),Be(U),we(ve),Me(N),typeof b.showGrandTotal=="boolean"&&Tt(b.showGrandTotal),Ct(Ec(E,F,b.chart?.dimensionFieldId));let X=Hs(ve,b.chart?.primaryValueFieldId);It(X),bo(Fc(ve,X,b.chart?.secondaryValueFieldId)),ka(b.chart?.chartType??"bar-vertical"),K(b.id),v?.(b);},[Jo,v,Ct,It,bo,ka,ze,Be,Me,he,Tt,we,w]),Ja=ht.useCallback(b=>{if(!b){K("");return}let E=ge.find(F=>F.id===b);if(!E){K("");return}Uo(E);},[Uo,ge]),Dr=ht.useCallback(()=>{let b=p("pivot.preset.defaultName",{index:ge.length+1});Ne(b),fe(true);},[ge.length,p]),wa=ht.useCallback(()=>{let b=be.trim();if(!b)return;let E={id:oa(),name:b,...xo()};ro(F=>[...F,E]),K(E.id),fe(false);},[xo,oa,be,ro]),er=ht.useCallback(()=>{_e&&(ro(b=>b.filter(E=>E.id!==_e)),K(""));},[_e,ro]);ht.useEffect(()=>{if(!h||y.current)return;let b=ge.find(E=>E.id===h);b&&(y.current=true,Uo(b));},[Uo,h,ge]),ht.useEffect(()=>{_e&&(ge.some(b=>b.id===_e)||K(""));},[_e,ge]);let aa=ht.useMemo(()=>{if(!Ee||!We||!L.length)return null;let b={};return We.dataColumns.forEach(E=>{let F=Vt.filter(U=>{let re=$.length>0?$.map(ve=>ga(U[ve])):[p("pivot.valueLabel")];return hr(re)===E.colKey});b[E.id]=on(F,E.valueItem.fieldId,E.valueItem.aggregation);}),{key:"__grand_total__",value:p("pivot.grandTotal")||Su,children:[],isLeaf:false,isGrandTotal:true,aggregatedValues:b,path:[],depth:-1}},[Ee,We,Vt,$,L.length,p]),Jt=ht.useMemo(()=>om(We?.rowTree??[]),[We]),Do=ht.useMemo(()=>om(We?.columnTree??[]),[We]);ht.useEffect(()=>{Xt(b=>{let E=new Set;return b.has("__grand_total__")&&E.add("__grand_total__"),Jt.forEach(F=>{b.has(F)&&E.add(F);}),E});},[Jt]),ht.useEffect(()=>{Yt(b=>{let E=new Set;return Do.forEach(F=>{b.has(F)&&E.add(F);}),E});},[Do]);let Mr=ht.useCallback(()=>{Xt(b=>{let E=new Set(b);return Jt.forEach(F=>E.add(F)),E});},[Jt]),tr=ht.useCallback(()=>{Xt(b=>{let E=new Set;return b.has("__grand_total__")&&E.add("__grand_total__"),E});},[]),Ar=ht.useCallback(()=>{Yt(new Set(Do));},[Do]),Br=ht.useCallback(()=>{Yt(new Set);},[]),Er=ht.useMemo(()=>!We||$.length===0?[]:oC(We.columnTree,Qt),[$.length,Qt,We]),io=ht.useMemo(()=>{if(!We)return [];if($.length===0)return We.dataColumns.map(E=>({id:E.id,label:E.label,leafColumnIds:[E.id],valueItem:E.valueItem}));let b=new Map(We.dataColumns.map(E=>[E.id,E]));return Er.flatMap(E=>{let F=new Map;return E.leafColumnIds.forEach(U=>{let re=b.get(U);if(!re)return;let ve=re.valueItem.tokenId,N=`${R(re.valueItem.aggregation)} ${A.get(re.valueItem.fieldId)?.label??re.valueItem.fieldId}`,X=F.get(ve);if(X){X.leafColumnIds.push(U);return}F.set(ve,{id:`${E.key}::${ve}`,label:_.length>1?N:E.label,leafColumnIds:[U],valueItem:re.valueItem});}),Array.from(F.values())})},[$.length,A,R,We,_.length,Er]),Fr=ht.useMemo(()=>new Map(io.map(b=>[b.id,b])),[io]),Lr=ht.useMemo(()=>io.map(b=>({id:b.id,colKey:b.id,valueItem:b.valueItem,label:b.label})),[io]),or=ht.useMemo(()=>{if(!We||$.length===0)return [];let b=[],E=rm(We.columnTree,Qt),F=E+(_.length>1?1:0),U=(re,ve)=>{b[ve]??(b[ve]=[]),re.forEach(N=>{let X=N.children.length>0&&Qt.has(N.key),Z=io.filter(O=>N.leafColumnIds.some(ae=>O.leafColumnIds.includes(ae))).length,Je=X||_.length>1?1:F-ve;b[ve].push({key:N.key,label:N.label,colSpan:Z,rowSpan:Je,expandable:N.children.length>0,expanded:X}),X&&U(N.children,ve+1);});};return U(We.columnTree,0),_.length>1&&(b[E]=io.map(re=>({key:re.id,label:re.label,colSpan:1,rowSpan:1,expandable:false,expanded:false}))),b},[$.length,Qt,We,_.length,io]),ra=ht.useCallback((b,E)=>E.leafColumnIds.reduce((F,U)=>F+(b.aggregatedValues[U]??0),0),[]),Ta=ht.useMemo(()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:Mr,disabled:Jt.size===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.expandRowsAll")}),jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:tr,disabled:Jt.size===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.collapseRowsAll")}),jsxRuntime.jsx(material.Divider,{orientation:"vertical",flexItem:true}),jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:Ar,disabled:Do.size===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.expandColumnsAll")}),jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:Br,disabled:$.length===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.collapseColumnsAll")})]}),[$.length,Do.size,Jt.size,Br,tr,Ar,Mr,p]),Ia=()=>{if(!Ve)return null;let b=Ps(Ve);if(!b||b.kind!=="item"||!b.key)return null;if(b.zone==="palette"){let re=A.get(b.key);return re?jsxRuntime.jsx(kc,{label:re.label,subtitle:re.type}):null}if(b.zone==="values"){let re=_.find(Z=>Z.tokenId===b.key);if(!re)return null;let N=A.get(re.fieldId)?.label??re.fieldId,X=`${R(re.aggregation)}(${N})`;return jsxRuntime.jsx(Es,{label:N,caption:X})}let F=A.get(b.key)?.label??b.key,U=Ut(b.key);return jsxRuntime.jsx(Es,{label:F,caption:U})};return jsxRuntime.jsxs(material.Paper,{sx:b=>({p:{xs:1.2,md:2},borderRadius:4,border:`1px solid ${b.palette.divider}`,bgcolor:"background.paper",boxShadow:b.palette.mode==="dark"?"none":"0 12px 28px rgba(15, 23, 42, 0.08)",display:"flex",flexDirection:"column",gap:2}),children:[jsxRuntime.jsxs(material.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexWrap:"wrap"},children:[jsxRuntime.jsxs(material.Box,{children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1.05rem",fontWeight:800},children:x}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.78rem",color:"text.secondary"},children:p("pivot.subtitle.default")})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[Pe&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.FormControl,{size:"small",sx:{minWidth:200},children:jsxRuntime.jsxs(material.Select,{value:_e,displayEmpty:true,onChange:b=>Ja(String(b.target.value)),sx:{fontSize:"0.75rem",height:32},children:[jsxRuntime.jsx(material.MenuItem,{value:"",sx:{fontSize:"0.75rem",color:"text.secondary"},children:p("pivot.preset.selectPlaceholder")}),ge.map(b=>jsxRuntime.jsx(material.MenuItem,{value:b.id,sx:{fontSize:"0.75rem"},children:b.name},b.id))]})}),jsxRuntime.jsx(material.Tooltip,{title:p("pivot.preset.save"),children:jsxRuntime.jsx(material.IconButton,{size:"small",onClick:Dr,"aria-label":p("pivot.preset.save"),children:jsxRuntime.jsx(Rp__default.default,{sx:{fontSize:18}})})}),jsxRuntime.jsx(material.Tooltip,{title:p("pivot.preset.delete"),children:jsxRuntime.jsx("span",{children:jsxRuntime.jsx(material.IconButton,{size:"small",onClick:er,disabled:!_e,"aria-label":p("pivot.preset.delete"),children:jsxRuntime.jsx(_v__default.default,{sx:{fontSize:18}})})})}),jsxRuntime.jsx(material.Divider,{flexItem:true,orientation:"vertical"})]}),jsxRuntime.jsxs(material.Typography,{sx:{fontSize:"0.74rem",color:"text.secondary"},children:[p("pivot.records"),": ",jsxRuntime.jsx("strong",{children:t.length.toLocaleString()})," / ",p("pivot.afterFilter"),":"," ",jsxRuntime.jsx("strong",{children:Vt.length.toLocaleString()})]}),jsxRuntime.jsx(material.Divider,{flexItem:true,orientation:"vertical"}),jsxRuntime.jsxs(material.Box,{sx:{display:"flex",alignItems:"center",gap:.6},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.74rem"},children:p("pivot.grandTotal")}),jsxRuntime.jsx(material.Switch,{size:"small",checked:Ee,onChange:b=>Tt(b.target.checked)})]})]})]}),jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsxs(core.DndContext,{sensors:C,collisionDetection:core.closestCenter,onDragStart:Ho,onDragEnd:Qa,children:[jsxRuntime.jsx($u,{isConfiguratorCollapsed:Ye,onToggleCollapse:()=>Io(b=>!b),availableFields:Yo,fieldMap:A,filterFields:j,columnFields:$,rowFields:L,valueFields:_,clearZone:$o,removeFieldFromZone:ea,getFilterSelectionSummary:Ut,renderDimensionFilterSelect:Ro,renderAggregationSelect:Sa,getAggregationLabel:R}),jsxRuntime.jsx(material.Portal,{children:jsxRuntime.jsx(core.DragOverlay,{dropAnimation:{duration:250,easing:"cubic-bezier(0.18, 0.67, 0.6, 1.22)"},children:Ia()})})]}),jsxRuntime.jsx(Zu,{rows:Vt,fieldMap:A,rowFields:L,columnFields:$,valueFields:_,chartDimensionFieldId:z,chartPrimaryValueFieldId:W,chartSecondaryValueFieldId:G,chartType:ue,isCollapsed:oe,onChartDimensionFieldIdChange:b=>Ct(b),onChartPrimaryValueFieldIdChange:b=>It(b),onChartSecondaryValueFieldIdChange:b=>bo(b),onChartTypeChange:b=>ka(b),onToggleCollapse:()=>Rr(b=>!b),getAggregationLabel:R}),jsxRuntime.jsx(ln,{title:p("pivot.table.sectionTitle"),subtitle:L.length>0?L.map(b=>A.get(b)?.label??b).join(" > "):p("pivot.table.dimensions"),collapsed:Se,onToggleCollapse:()=>Po(b=>!b),expandAriaLabel:p("pivot.table.collapse.ariaExpand"),collapseAriaLabel:p("pivot.table.collapse.ariaCollapse"),bodySx:{p:0},headerActions:Ta,children:We===null?jsxRuntime.jsx(material.Box,{sx:{py:5,px:{xs:1.2,md:1.6},textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:S})}):jsxRuntime.jsx(material.TableContainer,{sx:{maxHeight:i},children:jsxRuntime.jsxs(material.Table,{size:"small",stickyHeader:true,children:[jsxRuntime.jsx(material.TableHead,{children:(or.length>0?or:[[]]).map((b,E)=>jsxRuntime.jsxs(material.TableRow,{children:[E===0&&jsxRuntime.jsx(material.TableCell,{rowSpan:Math.max(or.length,1),sx:F=>({fontWeight:800,fontSize:"0.76rem",color:"text.primary",bgcolor:F.palette.mode==="dark"?"#000000":"#f5f5f5",borderBottom:`1px solid ${F.palette.divider}`,pl:2,minWidth:220,verticalAlign:"middle"}),children:L.length>0?L.map(F=>A.get(F)?.label).join(" > "):p("pivot.table.dimensions")}),(b.length>0?b:io.map(F=>({key:F.id,label:F.label,colSpan:1,rowSpan:1,expandable:false,expanded:false}))).map(F=>jsxRuntime.jsx(material.TableCell,{align:"center",colSpan:F.colSpan,rowSpan:F.rowSpan,sx:U=>({fontWeight:800,fontSize:"0.75rem",color:"text.primary",bgcolor:U.palette.mode==="dark"?"#000000":"#f5f5f5",borderBottom:`1px solid ${U.palette.divider}`,minWidth:148,verticalAlign:"middle"}),children:jsxRuntime.jsxs(material.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:.4},children:[F.expandable&&jsxRuntime.jsx(material.IconButton,{size:"small",onClick:()=>ta(F.key),sx:{p:.1,ml:-0.3},children:F.expanded?jsxRuntime.jsx(ch__default.default,{sx:{fontSize:16}}):jsxRuntime.jsx(qf__default.default,{sx:{fontSize:16}})}),jsxRuntime.jsx(material.Box,{component:"span",children:F.label})]})},F.key))]},`pivot-header-row-${E}`))}),jsxRuntime.jsxs(material.TableBody,{children:[We.rowTree.map(b=>jsxRuntime.jsx(Os,{node:b,dataColumns:Lr,fieldMap:A,level:0,expandedKeys:Nt,onToggle:Go,getValue:(E,F)=>{let U=Fr.get(F);return U?ra(E,U):0}},b.key)),aa&&jsxRuntime.jsx(Os,{node:aa,dataColumns:Lr,fieldMap:A,level:0,expandedKeys:Nt,onToggle:Go,getValue:(b,E)=>{let F=Fr.get(E);return F?ra(b,F):0}})]})]})})}),jsxRuntime.jsxs(material.Dialog,{open:Ce,onClose:()=>fe(false),maxWidth:"xs",fullWidth:true,children:[jsxRuntime.jsx(material.DialogTitle,{children:p("pivot.preset.saveDialogTitle")}),jsxRuntime.jsx(material.DialogContent,{children:jsxRuntime.jsx(material.TextField,{autoFocus:true,fullWidth:true,margin:"dense",label:p("pivot.preset.nameLabel"),value:be,onChange:b=>Ne(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),wa());}})}),jsxRuntime.jsxs(material.DialogActions,{children:[jsxRuntime.jsx(material.Button,{onClick:()=>fe(false),children:p("common.cancel")}),jsxRuntime.jsx(material.Button,{variant:"contained",onClick:wa,disabled:!be.trim(),children:p("common.save")})]})]})]})};var nm=(e,t,o)=>{let a=[...e,...t];return o&&a.includes(o)?o:a[0]??""},zc=(e,t)=>t&&e.some(o=>o.fieldId===t)?t:e[0]?.fieldId??"",im=(e,t,o)=>o===""?"":o&&o!==t&&e.some(a=>a.fieldId===o)?o:e.find(a=>a.fieldId!==t)?.fieldId??"",k5=({fields:e,initialLayout:t,initialFilterSelections:o={},initialShowGrandTotal:a=true,initialConfiguratorCollapsed:r=false,initialChart:n,initialChartCollapsed:i=false,initialTableCollapsed:c=false})=>{let d=ht.useRef(0),l=ht.useMemo(()=>new Set(e.map(K=>K.id)),[e]),s=ht.useMemo(()=>new Map(e.map(K=>[K.id,K])),[e]),[g,f]=ht.useState(()=>St(t?.rows,l)),[u,h]=ht.useState(()=>St(t?.columns,l)),[v,p]=ht.useState(()=>St(t?.filters,l)),[C,m]=ht.useState(()=>{let K=t?.values??[],Ce=new Set,fe=[];return K.forEach(be=>{!l.has(be.fieldId)||Ce.has(be.fieldId)||(Ce.add(be.fieldId),d.current+=1,fe.push({tokenId:`v${d.current}`,fieldId:be.fieldId,aggregation:qt(be.aggregation,s.get(be.fieldId))}));}),fe}),[y,x]=ht.useState(o),[S,B]=ht.useState(a),[R,w]=ht.useState(r),[A,P]=ht.useState(()=>nm(St(t?.rows,l),St(t?.columns,l),n?.dimensionFieldId)),[k,D]=ht.useState(()=>{let K=(()=>{let Ce=t?.values??[],fe=new Set,be=[];return Ce.forEach(Ne=>{!l.has(Ne.fieldId)||fe.has(Ne.fieldId)||(fe.add(Ne.fieldId),be.push({tokenId:Ne.fieldId,fieldId:Ne.fieldId,aggregation:qt(Ne.aggregation,s.get(Ne.fieldId))}));}),be})();return zc(K,n?.primaryValueFieldId)}),[T,I]=ht.useState(()=>{let K=(()=>{let fe=t?.values??[],be=new Set,Ne=[];return fe.forEach(Ve=>{!l.has(Ve.fieldId)||be.has(Ve.fieldId)||(be.add(Ve.fieldId),Ne.push({tokenId:Ve.fieldId,fieldId:Ve.fieldId,aggregation:qt(Ve.aggregation,s.get(Ve.fieldId))}));}),Ne})(),Ce=zc(K,n?.primaryValueFieldId);return im(K,Ce,n?.secondaryValueFieldId)}),[M,H]=ht.useState(n?.chartType??"bar-vertical"),[V,J]=ht.useState(i),[ce,te]=ht.useState(c);ht.useEffect(()=>{f(K=>{let Ce=K.filter(fe=>l.has(fe));return fa(K,Ce)?K:Ce}),h(K=>{let Ce=K.filter(fe=>l.has(fe));return fa(K,Ce)?K:Ce}),p(K=>{let Ce=K.filter(fe=>l.has(fe));return fa(K,Ce)?K:Ce}),m(K=>{let Ce=K.filter(fe=>l.has(fe.fieldId)).map(fe=>({...fe,aggregation:qt(fe.aggregation,s.get(fe.fieldId))}));return Rs(K,Ce)?K:Ce});},[s,l]),ht.useEffect(()=>{P(K=>nm(g,u,K));},[u,g]),ht.useEffect(()=>{D(K=>zc(C,K));},[C]),ht.useEffect(()=>{I(K=>im(C,k,K));},[k,C]);let ne=ht.useCallback(K=>{f(St(K,l));},[l]),ee=ht.useCallback(K=>{h(St(K,l));},[l]),Y=ht.useCallback(K=>{p(St(K,l));},[l]),Ze=ht.useCallback(K=>{m(Ce=>{let fe=K??[],be=new Set,Ne=[];return fe.forEach(Ve=>{if(!l.has(Ve.fieldId)||be.has(Ve.fieldId))return;be.add(Ve.fieldId);let Ht=Ce.find(Nt=>Nt.fieldId===Ve.fieldId);if(Ht){Ne.push({...Ht,aggregation:qt(Ve.aggregation??Ht.aggregation,s.get(Ve.fieldId))});return}d.current+=1,Ne.push({tokenId:`v${d.current}`,fieldId:Ve.fieldId,aggregation:qt(Ve.aggregation,s.get(Ve.fieldId))});}),Ne});},[s,l]),Ue=ht.useCallback(K=>{ne(K.rows??[]),ee(K.columns??[]),Y(K.filters??[]),Ze(K.values??[]);},[ee,Y,ne,Ze]),ie=ht.useCallback(K=>{if(K==="rows")return f([]);if(K==="columns")return h([]);if(K==="filters")return p([]);m([]);},[]),Ie=ht.useCallback((K,Ce)=>{if(K==="rows")return f(fe=>fe.filter(be=>be!==Ce));if(K==="columns")return h(fe=>fe.filter(be=>be!==Ce));if(K==="filters")return p(fe=>fe.filter(be=>be!==Ce));m(fe=>fe.filter(be=>be.tokenId!==Ce));},[]),Fe=ht.useCallback((K,Ce)=>{m(fe=>fe.map(be=>be.tokenId===K?{...be,aggregation:qt(Ce,s.get(be.fieldId))}:be));},[s]),Oe=ht.useCallback((K,Ce)=>{x(fe=>({...fe,[K]:Ce}));},[]),nt=ht.useCallback(()=>{x({});},[]),Le=ht.useCallback(()=>{B(K=>!K);},[]),Xe=ht.useCallback(()=>{w(K=>!K);},[]),Zt=ht.useCallback(K=>{P(K);},[]),zt=ht.useCallback(K=>{D(K);},[]),Qe=ht.useCallback(K=>{I(K);},[]),lt=ht.useCallback(()=>{J(K=>!K);},[]),mt=ht.useCallback(()=>{te(K=>!K);},[]);return {model:ht.useMemo(()=>({rowFields:g,setRowFields:f,columnFields:u,setColumnFields:h,filterFields:v,setFilterFields:p,valueFields:C,setValueFields:m,filterSelections:y,setFilterSelections:x,showGrandTotal:S,setShowGrandTotal:B,isConfiguratorCollapsed:R,setIsConfiguratorCollapsed:w,chartDimensionFieldId:A,setChartDimensionFieldId:P,chartPrimaryValueFieldId:k,setChartPrimaryValueFieldId:D,chartSecondaryValueFieldId:T,setChartSecondaryValueFieldId:I,chartType:M,setChartType:H,isChartCollapsed:V,setIsChartCollapsed:J,isTableCollapsed:ce,setIsTableCollapsed:te}),[A,k,T,M,u,v,y,V,R,ce,g,S,C]),actions:{setRows:ne,setColumns:ee,setFilters:Y,setValues:Ze,setLayout:Ue,clearZone:ie,removeFieldFromZone:Ie,setAggregationForValue:Fe,setFilterSelection:Oe,resetFilterSelections:nt,toggleGrandTotal:Le,toggleConfigurator:Xe,setChartDimension:Zt,setChartPrimaryValue:zt,setChartSecondaryValue:Qe,setChartType:H,toggleChart:lt,toggleTable:mt}}};var P5=({orientation:e="auto",defaultNavigationOpen:t,onNavOpenChange:o}={})=>{let a=styles.useTheme(),r=material.useMediaQuery("(orientation: portrait)",{noSsr:true}),n=material.useMediaQuery(a.breakpoints.down("md"),{noSsr:true}),i=ht.useMemo(()=>e==="auto"?r||n?"portrait":"landscape":e,[n,r,e]),[c,d]=ht.useState(t??i==="landscape");ht.useEffect(()=>{d(t??i==="landscape");},[t,i]);let l=g=>{d(g),o?.(g);};return {resolvedOrientation:i,isPortraitViewport:r,isCompactViewport:n,navigationOpen:c,setNavigationOpen:l,toggleNavigationOpen:()=>l(!c)}};var cC=e=>{let t=Number(e||0);return Number.isFinite(t)?t:0},M5=({rows:e,rowKey:t="id",numericField:o,defaultSelectedId:a})=>{let n=e[0]?.[t],[i,c]=ht.useState(a??n),d=ht.useMemo(()=>e.find(u=>u[t]===i)||e[0],[t,e,i]),[l,s]=ht.useState(()=>{let u=d?.[o];return u==null?"0":String(u)});return {selectedId:i,selectedRecord:d,editorValue:l,setEditorValue:s,selectRecord:u=>{let h=u[t];c(h);let v=u[o];s(v==null?"0":String(v));},applyEditorValue:u=>{if(i===void 0)return;let h=cC(l),v=e.map(p=>p[t]===i?{...p,[o]:h}:p);u(v);}}};var vC=["code_128","ean_13","ean_8","qr_code","upc_a","upc_e"],um=(e,t,o,a)=>{t?.(e),a&&o?.();},z5=({open:e,onClose:t,title:o="Scan barcode",subtitle:a="Use the rear camera on the device. If scanning is unavailable, enter the code manually.",formats:r=vC,facingMode:n="environment",manualEntry:i=true,autoCloseOnDetect:c=true,scanIntervalMs:d=600,confirmLabel:l="Use code",cancelLabel:s="Close",manualPlaceholder:g="Enter barcode manually",onDetected:f,onError:u,sx:h})=>{let v=ht__namespace.default.useRef(null),p=ht__namespace.default.useRef(null),C=ht__namespace.default.useRef(null),m=ht__namespace.default.useRef(null),[y,x]=ht__namespace.default.useState("idle"),[S,B]=ht__namespace.default.useState(""),[R,w]=ht__namespace.default.useState(null),[A,P]=ht__namespace.default.useState(null),k=ht__namespace.default.useCallback(()=>{C.current!==null&&(window.clearInterval(C.current),C.current=null),p.current&&(p.current.getTracks().forEach(I=>I.stop()),p.current=null),v.current&&(v.current.srcObject=null);},[]),D=ht__namespace.default.useCallback(I=>{P(I),x("error"),u?.(I);},[u]);ht__namespace.default.useEffect(()=>{if(!e){k(),x("idle"),P(null),B("");return}let I=false;return (async()=>{if(!(typeof window>"u"||typeof navigator>"u")){if(!navigator.mediaDevices?.getUserMedia){x("unsupported"),P("Camera access is not supported in this browser.");return}x("starting"),P(null);try{let H=await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:{ideal:n}}});if(I){H.getTracks().forEach(V=>V.stop());return}if(p.current=H,v.current&&(v.current.srcObject=H,await v.current.play()),!window.BarcodeDetector){x("unsupported"),P("BarcodeDetector is not available. Camera preview is ready and manual entry is enabled.");return}m.current=new window.BarcodeDetector({formats:r}),x("ready"),C.current=window.setInterval(async()=>{if(!(!v.current||!m.current)&&!(v.current.readyState<HTMLMediaElement.HAVE_CURRENT_DATA))try{let J=(await m.current.detect(v.current)).find(te=>te.rawValue);if(!J?.rawValue)return;let ce={rawValue:J.rawValue,format:J.format};w(ce),k(),um(ce,f,t,c);}catch(V){D(V instanceof Error?V.message:"Failed to detect barcode.");}},d);}catch(H){D(H instanceof Error?H.message:"Unable to start camera.");}}})(),()=>{I=true,k();}},[c,n,r,t,f,e,D,d,k]);let T=()=>{let I=S.trim();if(!I)return;let M={rawValue:I,format:"manual"};w(M),um(M,f,t,c);};return jsxRuntime.jsxs(material.Dialog,{open:e,onClose:t,fullWidth:true,maxWidth:"sm",children:[jsxRuntime.jsx(material.DialogTitle,{sx:{fontSize:"1rem",fontWeight:900},children:o}),jsxRuntime.jsx(material.DialogContent,{sx:{pt:"8px !important"},children:jsxRuntime.jsxs(material.Stack,{spacing:2,sx:h,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.88rem",color:"text.secondary",lineHeight:1.55},children:a}),jsxRuntime.jsxs(material.Paper,{elevation:0,sx:I=>({position:"relative",overflow:"hidden",borderRadius:4,border:"1px solid",borderColor:"divider",minHeight:280,background:I.palette.mode==="dark"?"linear-gradient(180deg, rgba(15,23,42,0.92), rgba(2,6,23,0.96))":"linear-gradient(180deg, rgba(241,245,249,1), rgba(226,232,240,0.92))"}),children:[jsxRuntime.jsx("video",{ref:v,muted:true,playsInline:true,autoPlay:true,style:{width:"100%",height:280,objectFit:"cover",display:"block"}}),jsxRuntime.jsx(material.Box,{sx:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(material.Box,{sx:{width:"72%",maxWidth:320,aspectRatio:"1.7 / 1",borderRadius:3,border:"2px solid rgba(255,255,255,0.95)",boxShadow:"0 0 0 999px rgba(15,23,42,0.24)",position:"relative"},children:jsxRuntime.jsx(material.Box,{sx:{position:"absolute",top:"50%",left:0,right:0,height:2,bgcolor:"#38bdf8",boxShadow:"0 0 18px rgba(56,189,248,0.85)"}})})}),jsxRuntime.jsxs(material.Box,{sx:{position:"absolute",top:12,left:12,display:"flex",gap:1,flexWrap:"wrap"},children:[jsxRuntime.jsx(material.Chip,{icon:jsxRuntime.jsx(bC__default.default,{}),label:y==="ready"?"Camera ready":y==="starting"?"Starting camera":y==="unsupported"?"Preview only":y==="error"?"Scanner error":"Idle",size:"small",color:y==="error"?"error":"primary",variant:"filled"}),R?jsxRuntime.jsx(material.Chip,{icon:jsxRuntime.jsx(xC__default.default,{}),label:`${R.format||"barcode"}: ${R.rawValue}`,size:"small",color:"success",variant:"filled"}):null]})]}),A?jsxRuntime.jsx(material.Alert,{severity:y==="unsupported"?"info":"warning",children:A}):null,i?jsxRuntime.jsxs(material.Stack,{direction:{xs:"column",sm:"row"},spacing:1.25,children:[jsxRuntime.jsx(material.TextField,{fullWidth:true,label:"Barcode",placeholder:g,value:S,onChange:I=>B(I.target.value)}),jsxRuntime.jsx(material.Button,{variant:"contained",onClick:T,sx:{minHeight:56,px:2.5},children:l})]}):null]})}),jsxRuntime.jsx(material.DialogActions,{sx:{px:3,pb:2},children:jsxRuntime.jsx(material.Button,{onClick:t,children:s})})]})};var wC={default:"#475569",primary:"#1d4ed8",success:"#047857",warning:"#b45309",error:"#b91c1c",info:"#0369a1"},H5=({title:e,description:t,kicker:o,icon:a,badges:r=[],metrics:n=[],footer:i,children:c,selected:d=false,draggable:l=false,isDragging:s=false,swipeThreshold:g=88,startAction:f,endAction:u,dragHandleProps:h,onClick:v,onSwipe:p,sx:C})=>{let[m,y]=ht.useState(0),[x,S]=ht.useState(false),B=ht.useRef(null),R=ht.useRef(0),w=ht.useRef(0),A=!!(f||u),P=132,k=()=>{y(0),S(false),B.current=null,R.current=0,w.current=0;},D=V=>{(V==="start"?f:u)?.onTrigger?.(),p?.(V),k();},T=V=>{!A||V.target.closest('button, a, input, textarea, [data-no-swipe="true"]')||(B.current=V.pointerId,R.current=V.clientX,w.current=V.clientX,S(true),V.currentTarget.setPointerCapture(V.pointerId));},I=V=>{if(!x||B.current!==V.pointerId)return;w.current=V.clientX;let J=w.current-R.current,ce=Math.max(-P,Math.min(P,J));y(ce);},M=V=>{if(!x||B.current!==V.pointerId)return;let J=w.current-R.current;if(J>=g&&f){D("start");return}if(J<=-g&&u){D("end");return}Math.abs(J)<12&&v?.(),k();},H=(V,J)=>{if(!V)return null;let ce=V.backgroundColor||wC[V.tone||"default"];return jsxRuntime.jsx(material.Box,{sx:{position:"absolute",top:0,bottom:0,[J]:0,width:P,px:2,display:"flex",alignItems:"center",justifyContent:J==="left"?"flex-start":"flex-end",color:"#fff",background:`linear-gradient(135deg, ${ce}, rgba(15,23,42,0.92))`},children:jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[V.icon,jsxRuntime.jsx(material.Typography,{sx:{fontWeight:700,fontSize:"0.95rem"},children:V.label})]})})};return jsxRuntime.jsxs(material.Box,{sx:{position:"relative",overflow:"hidden",borderRadius:4,...C},children:[H(f,"left"),H(u,"right"),jsxRuntime.jsx(material.Paper,{elevation:0,onPointerDown:T,onPointerMove:I,onPointerUp:M,onPointerCancel:k,sx:V=>({position:"relative",zIndex:1,p:2,borderRadius:4,border:"1px solid",borderColor:d?"primary.main":"divider",background:V.palette.mode==="dark"?"linear-gradient(180deg, rgba(30,41,59,0.96), rgba(15,23,42,0.92))":"linear-gradient(180deg, #ffffff, #f8fafc)",color:"text.primary",boxShadow:d?"0 18px 42px rgba(37, 99, 235, 0.18)":"0 12px 28px rgba(15, 23, 42, 0.08)",transform:`translate3d(${m}px, 0, 0) scale(${s?.985:1})`,transition:x?"none":"transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease",touchAction:"pan-y",cursor:v?"pointer":"default",opacity:s?.9:1}),children:jsxRuntime.jsxs(material.Stack,{spacing:1.5,children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[a?jsxRuntime.jsx(material.Box,{sx:{mt:.25},children:a}):null,jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[o?jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",fontWeight:700,letterSpacing:"0.08em",color:"text.secondary"},children:o}):null,jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1.05rem",fontWeight:800,lineHeight:1.25},children:e}),t?jsxRuntime.jsx(material.Typography,{sx:{mt:.5,fontSize:"0.9rem",color:"text.secondary",lineHeight:1.45},children:t}):null]}),l?jsxRuntime.jsx(material.Box,{"data-no-swipe":"true",...h,sx:{alignSelf:"center",display:"inline-flex",touchAction:"none"},children:jsxRuntime.jsx(material.IconButton,{size:"small",children:jsxRuntime.jsx(SC__default.default,{})})}):null]}),r.length>0?jsxRuntime.jsx(material.Stack,{direction:"row",spacing:1,useFlexGap:true,flexWrap:"wrap",children:r.map((V,J)=>jsxRuntime.jsx(material.Chip,{label:V,size:"small",sx:{borderRadius:999,fontWeight:700,bgcolor:"action.hover",color:"text.primary"}},J))}):null,n.length>0?jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(110px, 1fr))",gap:1},children:n.map(V=>jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{p:1.25,borderRadius:3,bgcolor:"action.hover",border:"1px solid",borderColor:"divider",color:"text.primary"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:V.label}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:800,lineHeight:1.2},children:V.value})]},V.id))}):null,c,i]})})]})};var mi=({label:e,onPress:t,emphasis:o="default"})=>jsxRuntime.jsx(material.Box,{component:"button",type:"button",onClick:t,sx:a=>({minHeight:72,borderRadius:3,border:"1px solid",borderColor:o==="primary"?"primary.main":"divider",background:o==="primary"?a.palette.primary.main:o==="danger"?a.palette.mode==="dark"?"rgba(239,68,68,0.18)":"rgba(239,68,68,0.10)":a.palette.mode==="dark"?"rgba(255,255,255,0.04)":"#fff",color:o==="primary"?"#fff":"text.primary",fontSize:"1.25rem",fontWeight:800,transition:"transform 120ms ease, box-shadow 160ms ease, background-color 160ms ease",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent","&:active":{transform:"scale(0.98)"}}),children:e}),Q5=({value:e,defaultValue:t="",title:o,subtitle:a,placeholder:r="0",allowDecimal:n=false,allowNegative:i=false,maxLength:c,confirmLabel:d,clearLabel:l,backspaceLabel:s,onChange:g,onSubmit:f,onClose:u,sx:h})=>{let{t:v}=Q(),[p,C]=ht.useState(t),m=e??p,y=k=>{e===void 0&&C(k),g?.(k);},x=k=>{c&&m.length>=c||y(`${m}${k}`);},S=k=>{if(k==="00"){if(!m){y("0");return}x("00");return}x(k);},B=()=>{!n||m.includes(".")||y(m?`${m}.`:"0.");},R=()=>{if(i){if(m.startsWith("-")){y(m.slice(1));return}y(m?`-${m}`:"-");}},w=()=>{y(m.slice(0,-1));},A=()=>{y("");},P=()=>{f?.(m);};return jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:2,borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",...h},children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsxs(material.Stack,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[jsxRuntime.jsxs(material.Box,{sx:{minWidth:0},children:[o?jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:800},children:o}):null,a?jsxRuntime.jsx(material.Typography,{sx:{mt:.5,fontSize:"0.86rem",color:"text.secondary"},children:a}):null]}),u?jsxRuntime.jsx(material.IconButton,{onClick:u,size:"small",children:jsxRuntime.jsx(RC__default.default,{})}):null]}),jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:2,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"action.hover"},children:jsxRuntime.jsx(material.Typography,{sx:{minHeight:38,fontSize:m?"1.9rem":"1.25rem",fontWeight:900,letterSpacing:"0.06em",color:m?"text.primary":"text.disabled"},children:m||r})}),jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:1.25},children:[["1","2","3","4","5","6","7","8","9"].map(k=>jsxRuntime.jsx(mi,{label:k,onPress:()=>S(k)},k)),jsxRuntime.jsx(mi,{label:i?"+/-":"00",onPress:i?R:()=>S("00")}),jsxRuntime.jsx(mi,{label:"0",onPress:()=>S("0")}),jsxRuntime.jsx(mi,{label:n?".":s?String(s):"DEL",onPress:n?B:w})]}),jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:1.25},children:[jsxRuntime.jsx(material.Box,{component:"button",type:"button",onClick:w,sx:{minHeight:64,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent"},children:jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,justifyContent:"center",alignItems:"center",children:[jsxRuntime.jsx(PC__default.default,{}),jsxRuntime.jsx(material.Typography,{sx:{fontWeight:700},children:s||"DEL"})]})}),jsxRuntime.jsx(mi,{label:String(l||"CLR"),onPress:A,emphasis:"danger"}),jsxRuntime.jsx(material.Box,{component:"button",type:"button",onClick:P,sx:k=>({minHeight:64,borderRadius:3,border:"1px solid",borderColor:"primary.main",background:k.palette.primary.main,color:"#fff",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent"}),children:jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,justifyContent:"center",alignItems:"center",children:[jsxRuntime.jsx(DC__default.default,{}),jsxRuntime.jsx(material.Typography,{sx:{fontWeight:800},children:d||v("common.ok")})]})})]})]})})};var ym=({touchMode:e="comfortable",sx:t,...o})=>{let a=e==="expanded";return jsxRuntime.jsx(material.Box,{sx:{"& .MuiPaper-root":{borderRadius:4},"& .MuiAutocomplete-root":{minWidth:{xs:"100%",md:260}},"& .MuiAutocomplete-root .MuiInputBase-root":{backgroundColor:"transparent !important"},"& .MuiInputBase-root":{minHeight:a?56:50,borderRadius:3,fontSize:a?"0.98rem":"0.92rem"},"& .MuiInputBase-input":{py:a?1.6:1.25,fontSize:a?"0.98rem":"0.92rem"},"& .MuiInputLabel-root":{fontSize:a?"0.95rem":"0.88rem"},"& .MuiButton-root":{minHeight:a?48:44,px:a?2.25:1.75,borderRadius:3,fontSize:a?"0.95rem":"0.88rem",fontWeight:700},"& .MuiIconButton-root":{width:a?40:36,height:a?40:36},"& .MuiMenuItem-root":{minHeight:a?44:38,fontSize:a?"0.95rem":"0.88rem"},"& .MuiListSubheader-root":{py:1},"& .MuiCheckbox-root":{p:a?1:.75},"& .MuiFormControlLabel-label":{fontSize:a?"0.95rem":"0.88rem"},"& .MuiDialog-paper":{borderRadius:4},"& .MuiDialogTitle-root":{fontSize:a?"1.05rem":"0.98rem",fontWeight:800},"& .MuiDialogContent-root .MuiInputBase-root":{minHeight:52},'& .MuiGrid-root > .MuiGrid-item, & .MuiGrid-root > .MuiGrid-sizeXs-1, & .MuiGrid-root > [class*="MuiGrid-grid-"]':{minWidth:0},...t},children:jsxRuntime.jsx(ca,{...o})})};var zC=(e,t,o)=>{if(o?.(t),!!t.href){if(t.href.startsWith("http://")||t.href.startsWith("https://")){window.open(t.href,"_blank");return}e.push(t.href);}},vm=({items:e,selectedId:t,orientation:o="auto",onItemSelect:a,sx:r})=>{let n=styles.useTheme(),[i,c]=ht.useState(false);ht.useEffect(()=>{c(true);},[]);let d=material.useMediaQuery("(orientation: portrait)",{noSsr:true}),l=material.useMediaQuery(n.breakpoints.down("md"),{noSsr:true}),s=o==="auto"?d||l?"portrait":"landscape":o,g=navigation.useRouter();return jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:!i||s==="portrait"?"repeat(2, minmax(0, 1fr))":"repeat(auto-fit, minmax(180px, 1fr))",gap:1.5,...r},children:e.map(f=>{let u=f.id===t,h=f.color||(u?n.palette.primary.main:n.palette.divider);return jsxRuntime.jsx(material.Paper,{elevation:0,sx:{overflow:"hidden",borderRadius:4,border:"1px solid",borderColor:u?"primary.main":"divider",boxShadow:u?"0 18px 40px rgba(37, 99, 235, 0.16)":"none",bgcolor:n.palette.mode==="dark"?"rgba(30,41,59,0.6)":"background.paper"},children:jsxRuntime.jsx(material.Box,{component:"button",type:"button",disabled:f.disabled,onClick:()=>zC(g,f,a),sx:{width:"100%",p:2,minHeight:s==="portrait"?156:148,display:"block",border:0,background:"transparent",textAlign:"left",cursor:f.disabled?"not-allowed":"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent",color:"text.primary"},children:jsxRuntime.jsxs(material.Stack,{spacing:1.5,sx:{height:"100%"},children:[jsxRuntime.jsxs(material.Stack,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[jsxRuntime.jsx(material.Box,{sx:{width:44,height:44,borderRadius:3,display:"grid",placeItems:"center",color:u?"#fff":"text.primary",background:u?h:"action.hover"},children:f.icon||jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:900},children:f.title.slice(0,1).toUpperCase()})}),f.badge!==void 0?jsxRuntime.jsx(material.Box,{sx:{minWidth:34,px:1,py:.4,borderRadius:999,bgcolor:u?"primary.main":"action.hover",color:u?"#fff":"text.secondary",textAlign:"center",fontWeight:800,fontSize:"0.8rem"},children:f.badge}):null]}),jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:800,lineHeight:1.25},children:f.title}),f.caption?jsxRuntime.jsx(material.Typography,{sx:{mt:.5,fontSize:"0.74rem",fontWeight:700,color:"text.secondary"},children:f.caption}):null,f.description?jsxRuntime.jsx(material.Typography,{sx:{mt:.75,fontSize:"0.84rem",lineHeight:1.45,color:"text.secondary"},children:f.description}):null]})]})})},f.id)})})};var wm=(e,t)=>t.trim()?e.reduce((o,a)=>{let r=a.title?.toLowerCase().includes(t.toLowerCase())||a.label?.toLowerCase().includes(t.toLowerCase())||a.description?.toLowerCase().includes(t.toLowerCase()),n=a.children?wm(a.children,t):[];return (r||n.length>0)&&o.push({...a,children:n.length>0?n:a.children}),o},[]):e,ZC=e=>{let t=new Set,o=a=>{a.forEach(r=>{r.children?.length&&(t.add(r.id),o(r.children));});};return o(e),t},Tm=({collapsed:e=false,onToggle:t,className:o="",maxHeight:a,menuData:r=[],colorMode:n="light",orientation:i="auto",headerSlot:c,footerSlot:d,activeHref:l,onItemSelect:s})=>{let{t:g}=Q(),f=styles.useTheme(),u=material.useMediaQuery("(orientation: portrait)"),h=material.useMediaQuery(f.breakpoints.down("md")),v=i==="auto"?u||h?"portrait":"landscape":i,p=n==="dark",C=navigation.useRouter(),m=navigation.usePathname(),[y,x]=ht.useState(""),[S,B]=ht.useState(new Set),R=ht.useMemo(()=>wm(r,y),[r,y]),w=ht.useMemo(()=>y.trim()?ZC(R):S,[S,R,y]);ht.useEffect(()=>{e&&B(new Set);},[e]);let A=I=>I.appurl||I.href||"",P=I=>{s?.(I);let M=A(I);if(M){if(M.startsWith("http://")||M.startsWith("https://")){window.open(M,"_blank");return}C.push(M);}},k=I=>{let M=!!I.children?.length;if(e&&M){t?.();return}if(M){B(H=>{let V=new Set(H);return V.has(I.id)?V.delete(I.id):V.add(I.id),V});return}P(I);},D=I=>{let M=l||m,H=A(I);return !!(H&&M===H)},T=(I,M=0)=>{let H=!!I.children?.length,V=w.has(I.id),J=D(I);return jsxRuntime.jsx(material.Box,{sx:{pl:M===0?0:1.5},children:jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{mb:1,overflow:"hidden",borderRadius:3,border:"1px solid",borderColor:J?"primary.main":"divider",bgcolor:J?"action.selected":"background.paper"},children:[jsxRuntime.jsxs(material.Box,{component:"button",type:"button",onClick:()=>k(I),sx:{width:"100%",px:1.5,py:1.4,display:"flex",alignItems:"center",gap:1.25,border:0,background:"transparent",textAlign:"left",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent"},children:[jsxRuntime.jsx(material.Avatar,{variant:"rounded",sx:{width:40,height:40,bgcolor:J?"primary.main":"action.hover",color:J?"#fff":"text.primary"},children:I.icon||(I.title||I.label||"?").slice(0,1).toUpperCase()}),jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.95rem",fontWeight:800,lineHeight:1.2},children:I.title||I.label}),I.description?jsxRuntime.jsx(material.Typography,{sx:{mt:.4,fontSize:"0.78rem",color:"text.secondary",lineHeight:1.35},children:I.description}):null]}),H?jsxRuntime.jsx(_C__default.default,{sx:{transform:V?"rotate(180deg)":"rotate(0deg)",transition:"transform 180ms ease"}}):jsxRuntime.jsx(jC__default.default,{color:"action"})]}),H?jsxRuntime.jsx(material.Collapse,{in:V,children:jsxRuntime.jsx(material.Box,{sx:{px:1.25,pb:1.25},children:I.children?.map(ce=>T(ce,M+1))})}):null]})},I.id)};return e?jsxRuntime.jsx(material.Paper,{elevation:0,className:o,sx:{width:v==="portrait"?"100%":88,p:1,borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:p?"#101828":"rgba(255,255,255,0.88)",maxHeight:a?`${a}px`:void 0,overflowY:"auto"},children:jsxRuntime.jsxs(material.Stack,{spacing:1,children:[jsxRuntime.jsx(material.IconButton,{onClick:t,sx:{width:48,height:48,alignSelf:"center",bgcolor:"action.hover"},title:g("navigation.expand"),children:jsxRuntime.jsx(qC__default.default,{})}),r.map(I=>jsxRuntime.jsx(material.IconButton,{onClick:()=>k(I),sx:{width:56,height:56,alignSelf:"center",borderRadius:3,bgcolor:D(I)?"primary.main":"action.hover",color:D(I)?"#fff":"text.primary"},children:I.icon||(I.title||I.label||"?").slice(0,1).toUpperCase()},I.id))]})}):jsxRuntime.jsx(material.Paper,{elevation:0,className:o,sx:{width:v==="portrait"?"100%":320,p:1.25,borderRadius:5,border:"1px solid",borderColor:"divider",bgcolor:p?"#101828":"rgba(255,255,255,0.88)",maxHeight:a?`${a}px`:void 0,overflow:"hidden",display:"flex",flexDirection:"column"},children:jsxRuntime.jsxs(material.Stack,{spacing:1.25,sx:{flex:1,minHeight:0},children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[jsxRuntime.jsx(material.TextField,{value:y,onChange:I=>x(I.target.value),placeholder:g("navigation.searchPlaceholder"),size:"small",fullWidth:true,InputProps:{startAdornment:jsxRuntime.jsx(UC__default.default,{fontSize:"small",color:"action"})}}),v==="landscape"&&!e?jsxRuntime.jsx(material.IconButton,{onClick:t,sx:{bgcolor:"action.hover"},children:jsxRuntime.jsx(KC__default.default,{})}):null]}),c,jsxRuntime.jsx(material.Box,{sx:{flex:1,minHeight:0,overflowY:"auto",pr:.25},children:R.length>0?R.map(I=>T(I)):jsxRuntime.jsx(material.Typography,{sx:{p:2,fontSize:"0.88rem",color:"text.secondary",textAlign:"center"},children:g("navigation.noMatch")})}),d]})})};var Em=(e,t)=>{let o=t[e.id];if(e.render)return e.render(o,t);if(o==null||o==="")return "--";if(e.numeric){if(typeof o=="number")return o.toLocaleString();if(typeof o=="string"&&o.trim()!==""&&!Number.isNaN(Number(o)))return Number(o).toLocaleString()}return String(o)},tk=e=>ht__namespace.default.isValidElement(e)?jsxRuntime.jsx(material.Box,{sx:{display:"inline-flex",alignItems:"center"},children:e}):jsxRuntime.jsx(material.Typography,{sx:{mt:.2,fontSize:"0.88rem",fontWeight:800},children:e}),ok=(e,t)=>{let o=t[e.id];if(o==null||o==="")return "--";if(e.numeric){if(typeof o=="number")return o.toLocaleString();if(typeof o=="string"&&o.trim()!==""&&!Number.isNaN(Number(o)))return Number(o).toLocaleString()}return String(o)},ak=({summaryRow:e,visibleColumns:t,columns:o})=>{let a=o.filter(r=>t.includes(r.id)&&e[r.id]!=="");return a.length===0?null:jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:1.5,borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:"action.hover"},children:jsxRuntime.jsxs(material.Stack,{spacing:1,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.82rem",fontWeight:800,color:"text.secondary"},children:"Summary"}),jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(132px, 1fr))",gap:1},children:a.map(r=>jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{p:1.1,borderRadius:3,border:"1px solid",borderColor:"divider"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:r.label}),jsxRuntime.jsx(material.Typography,{sx:{mt:.25,fontSize:"0.96rem",fontWeight:800},children:e[r.id]})]},`summary-${r.id}`))})]})})},rk=e=>{let{t}=Q(),o=styles.useTheme(),{title:a,showToolbar:r=true,selectionMode:n,selected:i=[],onSelectionChange:c,actions:d,extraTools:l,fitContainer:s=false,fullWidth:g=false,maxHeight:f,loading:u=false,rowsPerPageOptions:h=[20,50,100,-1],onLayoutSave:v,filterConfig:p,rowKey:C,tableKey:m="default",graphReport:y,quickCreate:x,quickEdit:S,quickDelete:B,serviceUrl:R,orientation:w="auto",cardTitleField:A,cardSubtitleFields:P,toolbarSlot:k,emptyState:D,rowHeight:T="comfortable",cardActionSlot:I,renderCardFooter:M,onRowClick:H}=e,V=a||t("table.title.default"),J=material.useMediaQuery("(orientation: portrait)"),ce=material.useMediaQuery(o.breakpoints.down("md")),te=w==="auto"?J||ce?"portrait":"landscape":w,{columns:ne,filterText:ee,setFilterText:Y,visibleColumns:Ze,showSummary:Ue,setShowSummary:ie,summaryColumns:Ie,grouping:Fe,setGrouping:Oe,expandedGroups:nt,groupAnchorEl:Le,setGroupAnchorEl:Xe,summaryAnchorEl:Zt,setSummaryAnchorEl:zt,anchorEl:Qe,setAnchorEl:lt,contextMenu:mt,sortedAndFilteredRows:_e,summaryRow:K,visibleRows:Ce,page:fe,setPage:be,rowsPerPage:Ne,setRowsPerPage:Ve,totalDisplayCount:Ht,setSelected:Nt,handleClick:Xt,toggleSummaryColumn:Qt,handleExport:Yt,handleCloseContextMenu:L,toggleColumnVisibility:$,toggleGroupExpand:j,toggleGroupField:_,handleExpandGroupRecursively:ke,handleCollapseGroupRecursively:Ee,handleLayoutLoad:Ye,handleVariantLoad:z,handleLayoutSave:W,effectiveAppId:G,currentLayoutData:ue,currentLayoutId:oe,layoutIdToLoad:Se,graphReportOpen:ge,handleOpenGraphReport:Pe,handleCloseGraphReport:he}=Yr(e),ze=y?.enabled??false,Be=ze&&(y?.interaction?.enabled??true),we=ji(),Me=C||"id",Tt=ht__namespace.default.useMemo(()=>({borderRadius:999,fontWeight:700,borderColor:styles.alpha(o.palette.divider,o.palette.mode==="dark"?.55:.3),bgcolor:o.palette.mode==="dark"?styles.alpha(o.palette.common.white,.06):styles.alpha(o.palette.background.paper,.92),color:o.palette.text.primary,"& .MuiChip-label":{px:1.05}}),[o]),Io=ht__namespace.default.useMemo(()=>({...Tt,borderColor:styles.alpha(o.palette.primary.main,o.palette.mode==="dark"?.42:.24),bgcolor:o.palette.mode==="dark"?styles.alpha(o.palette.primary.main,.16):styles.alpha(o.palette.primary.main,.08)}),[Tt,o]),Ct=ht__namespace.default.useMemo(()=>{let O=new Set(i);return _e.filter(ae=>O.has(ae?.[Me]))},[Me,i,_e]),It=Ct.length===1?Ct[0]:null,bo=!!x?.enabled,ka=!!S?.enabled,Rr=!!B?.enabled,Po=x?.fields,ro=x?.excludeFields||[],Za=x?.initialValues||{},Yo=S?.fields,Gt=S?.excludeFields||[],no=S?.editableFields||[],Vt=S?.nonEditableFields||[],We=S?.primaryKeys?.length?S.primaryKeys:[Me],[Jo,$o]=ht__namespace.default.useState(false),[ea,Xa]=ht__namespace.default.useState(false),[Ho,Qa]=ht__namespace.default.useState({}),[Ya,Go]=ht__namespace.default.useState(false),[ta,Sa]=ht__namespace.default.useState(false),[Ut,Ro]=ht__namespace.default.useState({}),[oa,xo]=ht__namespace.default.useState(false),[Uo,Ja]=ht__namespace.default.useState(false),Dr=u||ea||ta||Uo,wa=ht__namespace.default.useMemo(()=>{let O=[...ne];if(Array.isArray(Po)&&Po.length>0){let ae=new Set(Po);O=O.filter(q=>ae.has(q.id));}if(ro.length>0){let ae=new Set(ro);O=O.filter(q=>!ae.has(q.id));}return O.filter(ae=>!!ae?.id)},[ne,ro,Po]),er=ht__namespace.default.useMemo(()=>{let O=[...ne];if(Array.isArray(Yo)&&Yo.length>0){let ae=new Set(Yo);O=O.filter(q=>ae.has(q.id));}if(Gt.length>0){let ae=new Set(Gt);O=O.filter(q=>!ae.has(q.id));}return O.filter(ae=>!!ae?.id)},[ne,Gt,Yo]),aa=ht__namespace.default.useMemo(()=>new Set(We),[We]),Jt=ht__namespace.default.useMemo(()=>new Set(no),[no]),Do=ht__namespace.default.useMemo(()=>new Set(Vt),[Vt]),Mr=ht__namespace.default.useCallback(O=>Jt.size>0?Jt.has(O):!(Do.has(O)||aa.has(O)),[Jt,Do,aa]);ht__namespace.default.useEffect(()=>{!ge&&we.hasActiveFilters&&we.clearAll();},[we,ge]);let tr=()=>{let O={};wa.forEach(ae=>{O[ae.id]=Za[ae.id]??"";}),Qa(O),$o(true);},Ar=(O,ae)=>{Qa(q=>({...q,[O]:ae}));},Br=async()=>{if(!x?.onSubmit){$o(false);return}try{Xa(!0),await x.onSubmit(Ho),$o(!1);}finally{Xa(false);}},Er=()=>{if(!It)return;let O={};er.forEach(q=>{O[q.id]=It[q.id]??"";});let ae=S?.getInitialValues?{...O,...S.getInitialValues(It)}:O;Ro(ae),Go(true);},io=(O,ae)=>{Ro(q=>({...q,[O]:ae}));},Fr=async()=>{if(It){if(!S?.onSubmit){Go(false);return}try{Sa(!0),await S.onSubmit(Ut,It),Go(!1);}finally{Sa(false);}}},Lr=()=>{Ct.length!==0&&xo(true);},or=async()=>{if(Ct.length===0){xo(false);return}if(!B?.onConfirm){xo(false),Nt([]),c?.([]);return}try{Ja(!0),await B.onConfirm(Ct),xo(!1),Nt([]),c?.([]);}finally{Ja(false);}},ra=_e,{fieldMapping:Ta}=jr({rows:ra,config:{...y,title:y?.title||`${V} ${t("graph.reportTitle")}`}}),Ia=ht__namespace.default.useMemo(()=>Be?we.applyRows(ra,Ta):ra,[Ta,we,Be,ra]),{model:b}=jr({rows:Ia,config:{...y,title:y?.title||`${V} ${t("graph.reportTitle")}`,fieldMapping:Ta}}),E=b.table.columns.map(O=>({id:O.id,label:O.label,align:O.align||"left",minWidth:120,numeric:O.align==="right"})),F=G?jsxRuntime.jsx(rs,{appId:G,tableKey:m,currentLayoutData:ue,onLayoutLoad:Ye,targetLayoutId:Se,activeLayoutId:oe,serviceUrl:R??p?.serviceUrl}):null,U=ne.filter(O=>Ze.includes(O.id)),re=U.find(O=>O.id===A)||U[0],ve=P?.map(O=>U.find(ae=>ae.id===O)).filter(Boolean)||U.filter(O=>O.id!==re?.id).slice(0,te==="portrait"?2:3),N=U.filter(O=>O.id!==re?.id&&!ve.some(ae=>ae.id===O.id)),X=[k,l].filter(Boolean),Z=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Nr,{groupAnchorEl:Le,setGroupAnchorEl:Xe,grouping:Fe,setGrouping:Oe,columns:ne,toggleGroupField:_}),jsxRuntime.jsx(Vr,{anchorEl:Qe,setAnchorEl:lt,columns:ne,visibleColumns:Ze,toggleColumnVisibility:$}),jsxRuntime.jsx(Di,{anchorEl:Zt,setAnchorEl:zt,showSummary:Ue,setShowSummary:ie,columns:ne,summaryColumns:Ie,toggleSummaryColumn:Qt}),jsxRuntime.jsx(Mi,{contextMenu:mt,handleCloseContextMenu:L,columns:ne,visibleColumns:Ze,toggleColumnVisibility:$})]}),Je=(O,ae,q)=>{let de=i.includes(ae),$e=te==="portrait"?"repeat(2, minmax(0, 1fr))":"repeat(auto-fit, minmax(140px, 1fr))",Ko=q%2===0?styles.alpha(o.palette.primary.main,o.palette.mode==="dark"?.09:.04):styles.alpha(o.palette.primary.main,o.palette.mode==="dark"?.05:.022),Ng=styles.alpha(o.palette.divider,.22);return jsxRuntime.jsx(material.Paper,{elevation:0,onClick:()=>{Xt({},O),H?.(O);},sx:{p:T==="compact"?1.25:1.5,borderRadius:4,border:"0.5px solid",borderColor:de?styles.alpha(o.palette.primary.main,.38):Ng,background:de?`linear-gradient(135deg, ${styles.alpha(o.palette.primary.main,.13)}, ${styles.alpha(o.palette.primary.main,.06)})`:`linear-gradient(135deg, ${Ko}, ${styles.alpha(o.palette.primary.main,.015)})`,boxShadow:de?`0 12px 30px ${styles.alpha(o.palette.primary.main,.2)}`:`0 3px 10px ${styles.alpha(o.palette.common.black,.045)}`,cursor:"pointer",position:"relative",overflow:"hidden",transition:"border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease, background 160ms ease","&::before":{content:'""',position:"absolute",left:0,top:0,bottom:0,width:4,background:de?o.palette.primary.main:q%2===0?styles.alpha(o.palette.primary.main,.26):styles.alpha(o.palette.text.primary,.16)},"&:hover":{boxShadow:`0 10px 20px ${styles.alpha(o.palette.primary.main,.12)}`,transform:"translateY(-1px)"},"&:active":{transform:"scale(0.995)"}},children:jsxRuntime.jsxs(material.Stack,{spacing:1.25,children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.25,alignItems:"flex-start",children:[n?jsxRuntime.jsx(material.Checkbox,{checked:de,onClick:so=>so.stopPropagation(),onChange:()=>Xt({},O),sx:{mt:-0.6,ml:-0.6}}):null,jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[re?jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:900,lineHeight:1.25},children:Em(re,O)}):null,ve.length>0?jsxRuntime.jsx(material.Stack,{direction:"row",spacing:.75,useFlexGap:true,flexWrap:"wrap",sx:{mt:.75},children:ve.map(so=>jsxRuntime.jsx(material.Chip,{label:`${so.label}: ${ok(so,O)}`,size:"small",variant:"outlined",sx:Tt},`${ae}-${so.id}`))}):null]}),I?jsxRuntime.jsx(material.Box,{onClick:so=>so.stopPropagation(),children:I(O)}):null]}),N.length>0?jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:$e,gap:1},children:N.map(so=>jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{p:1,borderRadius:3,bgcolor:o.palette.mode==="dark"?styles.alpha(o.palette.background.default,.7):styles.alpha(o.palette.background.paper,.92),border:"0.1px solid",borderColor:styles.alpha(o.palette.divider,.24)},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:so.label}),tk(Em(so,O))]},`${ae}-${so.id}-detail`))}):null,M?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsx(material.Box,{onClick:so=>so.stopPropagation(),children:M(O)})]}):null]})},ae)};return jsxRuntime.jsxs(material.Box,{sx:{width:g?"100%":"auto",mb:s?0:2,...s?{flex:1,display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"hidden"}:{}},children:[p?jsxRuntime.jsx(material.Box,{sx:{mb:2},children:jsxRuntime.jsx(ym,{...p,onVariantLoad:O=>{z(O),p.onVariantLoad?.(O);},appId:p.appId,tableKey:m,currentLayout:[{tableKey:m,layoutData:ue}],currentLayoutId:oe,layoutRefs:[{tableKey:m,layoutId:oe}],variantService:p.variantService,serviceUrl:R??p.serviceUrl,touchMode:te==="portrait"?"expanded":"comfortable"})}):null,jsxRuntime.jsxs(material.Paper,{sx:{width:g?"100%":"auto",mb:s?0:2,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative",bgcolor:"transparent",backgroundImage:"none",boxShadow:"none","&::before":Dr?{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"3px",background:"linear-gradient(90deg, rgba(25, 118, 210, 0) 0%, rgba(25, 118, 210, 0.25) 25%, rgba(25, 118, 210, 1) 50%, rgba(25, 118, 210, 0.25) 75%, rgba(25, 118, 210, 0) 100%)",backgroundSize:"220% 100%",animation:"cTableTopMarquee 1.2s linear infinite",zIndex:6,pointerEvents:"none"}:{},"@keyframes cTableTopMarquee":{"0%":{backgroundPosition:"220% 0"},"100%":{backgroundPosition:"-120% 0"}},...f?{height:f}:s?{flex:1,minHeight:0,height:"100%"}:{}},children:[r?jsxRuntime.jsx(material.Box,{sx:{"& .MuiToolbar-root":{minHeight:60,alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",rowGap:1,columnGap:1},"& .MuiToolbar-root > :nth-of-type(1)":{width:{xs:"100%",md:"auto"},"& .MuiTextField-root":{width:{xs:"100%",md:300}}},"& .MuiToolbar-root > :nth-of-type(2)":{flexShrink:0},"& .MuiToolbar-root > :nth-of-type(3)":{display:{xs:"none",md:"block"}},"& .MuiToolbar-root > :nth-of-type(4)":{ml:"auto",justifyContent:"flex-end",flexWrap:"wrap"},"& .MuiInputBase-root":{minHeight:46},"& .MuiIconButton-root":{width:40,height:40},"& .MuiTypography-root":{fontSize:"0.9rem"},"& .MuiButtonBase-root":{borderRadius:2.5}},children:jsxRuntime.jsx(wi,{filterText:ee,setFilterText:Y,onRowsPerPageChange:Ve,rowsPerPage:Ne,rowsPerPageOptions:h,page:fe,count:Ht,onPageChange:be,actions:d,extraTools:X,grouping:Fe,setGroupAnchorEl:Xe,showSummary:Ue,setShowSummary:ie,setAnchorEl:lt,setSummaryAnchorEl:zt,handleExport:Yt,showCreateButton:bo,onOpenCreateDialog:tr,showEditButton:ka,onOpenEditDialog:Er,editDisabled:Ct.length!==1,showDeleteButton:Rr,onOpenDeleteConfirm:Lr,deleteDisabled:Ct.length===0,onLayoutSave:v||p?.variantService&&p?.appId?W:void 0,loading:u,layoutManager:F,onOpenGraphReport:ze?Pe:void 0})}):null,jsxRuntime.jsx(material.Box,{sx:{flex:1,minHeight:0,overflow:"auto",p:1.5},children:jsxRuntime.jsxs(material.Stack,{spacing:1.25,children:[Ce.length===0&&!u?D||jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:4,borderRadius:4,border:"1px dashed",borderColor:"divider",textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.92rem",color:"text.secondary"},children:t("common.noData")})}):null,Ce.map((O,ae)=>{if(O.type==="group"){let $e=nt.has(O.id);return jsxRuntime.jsx(material.Paper,{elevation:0,sx:{borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:"action.hover"},children:jsxRuntime.jsxs(material.Box,{component:"button",type:"button",onClick:()=>j(O.id),sx:{width:"100%",px:1.5,py:1.3,border:0,background:"transparent",display:"flex",alignItems:"center",gap:1,textAlign:"left",cursor:"pointer",appearance:"none",WebkitAppearance:"none",color:"text.primary"},children:[$e?jsxRuntime.jsx(_C__default.default,{}):jsxRuntime.jsx(jC__default.default,{}),jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[jsxRuntime.jsxs(material.Typography,{sx:{fontSize:"0.94rem",fontWeight:800},children:[O.field,": ",O.value]}),jsxRuntime.jsxs(material.Typography,{sx:{mt:.2,fontSize:"0.76rem",color:"text.secondary"},children:[O.count," records"]})]}),Fe.length>1&&O.level<Fe.length-1?jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:.5,children:[jsxRuntime.jsx(material.Chip,{size:"small",label:t("table.group.expandAll"),onClick:Ko=>{Ko.stopPropagation(),ke(O.id);},sx:Io}),jsxRuntime.jsx(material.Chip,{size:"small",label:t("table.group.collapseAll"),onClick:Ko=>{Ko.stopPropagation(),Ee(O.id);},sx:Io})]}):null]})},O.id)}let q=O.data||O,de=O.id||q[Me]||ae;return Je(q,de,ae)}),Ue?jsxRuntime.jsx(ak,{summaryRow:K,visibleColumns:Ze,columns:ne}):null,u?jsxRuntime.jsx(material.Typography,{sx:{py:1,fontSize:"0.84rem",color:"text.secondary",textAlign:"center"},children:t("common.loading")}):null]})})]}),bo?jsxRuntime.jsxs(material.Dialog,{open:Jo,onClose:()=>!ea&&$o(false),fullWidth:true,maxWidth:"sm",children:[jsxRuntime.jsx(material.DialogTitle,{sx:{fontSize:"1rem",fontWeight:800},children:x?.title||t("quickCreate.createWithTitle",{title:V})}),jsxRuntime.jsx(material.DialogContent,{sx:{pt:"8px !important"},children:jsxRuntime.jsxs(material.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[wa.map(O=>{let ae=O.type==="number"||O.numeric?"number":O.type==="date"?"date":"text";return jsxRuntime.jsx(material.TextField,{label:O.label||O.id,value:Ho[O.id]??"",onChange:q=>Ar(O.id,q.target.value),type:ae,fullWidth:true,InputLabelProps:{shrink:ae==="date"?true:void 0}},`quick-create-${O.id}`)}),x?.description?jsxRuntime.jsx(material.Alert,{severity:"info",children:x.description}):null]})}),jsxRuntime.jsxs(material.DialogActions,{sx:{px:3,pb:2},children:[jsxRuntime.jsx(material.Button,{onClick:()=>$o(false),disabled:ea,children:x?.cancelLabel||t("common.cancel")}),jsxRuntime.jsx(material.Button,{onClick:Br,variant:"contained",disabled:ea,children:x?.submitLabel||t("common.save")})]})]}):null,ka?jsxRuntime.jsxs(material.Dialog,{open:Ya,onClose:()=>!ta&&Go(false),fullWidth:true,maxWidth:"sm",children:[jsxRuntime.jsx(material.DialogTitle,{sx:{fontSize:"1rem",fontWeight:800},children:S?.title||t("quickEdit.editWithTitle",{title:V})}),jsxRuntime.jsx(material.DialogContent,{sx:{pt:"8px !important"},children:jsxRuntime.jsxs(material.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[er.map(O=>{let ae=O.type==="number"||O.numeric?"number":O.type==="date"?"date":"text";return jsxRuntime.jsx(material.TextField,{label:O.label||O.id,value:Ut[O.id]??"",onChange:q=>io(O.id,q.target.value),type:ae,disabled:!Mr(O.id),fullWidth:true,InputLabelProps:{shrink:ae==="date"?true:void 0}},`quick-edit-${O.id}`)}),S?.description?jsxRuntime.jsx(material.Alert,{severity:"info",children:S.description}):null]})}),jsxRuntime.jsxs(material.DialogActions,{sx:{px:3,pb:2},children:[jsxRuntime.jsx(material.Button,{onClick:()=>Go(false),disabled:ta,children:S?.cancelLabel||t("common.cancel")}),jsxRuntime.jsx(material.Button,{onClick:Fr,variant:"contained",disabled:ta||!It,children:S?.submitLabel||t("common.save")})]})]}):null,Rr?jsxRuntime.jsx(Rn,{open:oa,type:"warning",title:B?.title||t("quickDelete.confirmTitle"),message:B?.message||(Ct.length>1?t("quickDelete.confirmMessageMultiple",{count:Ct.length}):t("quickDelete.confirmMessageSingle")),confirmText:B?.confirmText||t("common.delete"),cancelText:B?.cancelText||t("common.cancel"),onClose:()=>!Uo&&xo(false),onConfirm:or}):null,Z,ze?jsxRuntime.jsx(qi,{open:ge,onClose:he,model:b,aiAssistant:y?.aiAssistant,interaction:Be?{enabled:true,filters:we.filters,fieldMapping:Ta,onPrimaryDimensionClick:O=>we.setFilter("primaryDimension",O),onSecondaryDimensionClick:O=>we.setFilter("secondaryDimension",O),onStatusClick:O=>we.setFilter("status",O),onClearFilter:we.clearFilter,onClearAll:we.clearAll}:void 0,tableContent:jsxRuntime.jsx(rk,{appId:G||"graph-report-internal",title:t("graph.dataBody"),columns:E,rows:b.table.rows,rowKey:"id",fullWidth:true,maxHeight:"420px",rowsPerPage:20,rowsPerPageOptions:[20,50,100],graphReport:{enabled:false},showSummary:false})}):null]})};var _E=({appTitle:e,children:t,menuData:o=[],workloadItems:a=[],workloadSelectedId:r,showNavigation:n=true,showWorkloadNav:i=true,orientation:c="auto",logo:d,headerSlot:l,actionSlot:s,portraitBottomSlot:g,contentSx:f,containerSx:u,user:h,onSearch:v,defaultNavigationOpen:p,navOpen:C,onNavOpenChange:m,onWorkloadSelect:y,locale:x="en",localeLabel:S,localeOptions:B,onLocaleChange:R,onUserSetting:w,onUserLogout:A,userMenuItems:P,leftHeaderSlot:k,rightHeaderSlot:D})=>{let T="orbcafe:page-layout-mode",[I,M]=ht.useState("system"),[H,V]=ht.useState("light"),[J,ce]=ht.useState(false),[te,ne]=ht.useState(false),ee=I==="system"?te?H:"light":I;ht.useEffect(()=>{ce(true);},[]),ht.useEffect(()=>{try{let mt=window.localStorage.getItem(T);(mt==="light"||mt==="dark"||mt==="system")&&M(mt);}catch{}ne(true);let Qe=window.matchMedia("(prefers-color-scheme: dark)"),lt=()=>{V(Qe.matches?"dark":"light");};return lt(),Qe.addEventListener("change",lt),()=>Qe.removeEventListener("change",lt)},[]),ht.useEffect(()=>{if(te)try{window.localStorage.setItem(T,I);}catch{}},[te,I]),ht.useEffect(()=>{ee==="dark"?(document.documentElement.classList.add("dark"),document.documentElement.style.colorScheme="dark"):(document.documentElement.classList.remove("dark"),document.documentElement.style.colorScheme="light");},[ee]);let Y=ht.useMemo(()=>styles.createTheme({palette:ee==="dark"?{mode:"dark",primary:{main:"#93c5fd"},background:{default:"#060913",paper:"#101826"},text:{primary:"#f8fafc",secondary:"rgba(226,232,240,0.74)"},divider:"rgba(148,163,184,0.18)",action:{hover:"rgba(148,163,184,0.10)",selected:"rgba(59,130,246,0.18)"}}:{mode:"light",background:{default:"#eef3f8",paper:"#ffffff"}},components:{MuiCssBaseline:{styleOverrides:{body:{backgroundColor:ee==="dark"?"#060913":"#eef3f8"}}},MuiPaper:{styleOverrides:{root:{backgroundImage:"none"}}}}}),[ee]),Ze=material.useMediaQuery("(orientation: portrait)"),Ue=material.useMediaQuery(Y.breakpoints.down("md")),ie=c==="auto"?!J||Ze||Ue?"portrait":"landscape":c,[Ie,Fe]=ht.useState({landscape:p??true,portrait:false}),Oe=Ie[ie],nt=C??Oe,Le=Qe=>{C===void 0&&Fe(lt=>({...lt,[ie]:Qe})),m?.(Qe);},Xe=jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[!J||n&&ie==="portrait"?jsxRuntime.jsx(material.IconButton,{onClick:()=>Le(!nt),sx:{bgcolor:"action.hover"},children:jsxRuntime.jsx(qC__default.default,{})}):null,k]}),Zt=jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[s,D]}),zt=jsxRuntime.jsx(Tm,{collapsed:ie==="landscape"?!nt:false,onToggle:()=>Le(!nt),menuData:o,orientation:ie,colorMode:ee,maxHeight:ie==="landscape"?900:void 0});return jsxRuntime.jsx(styles.ThemeProvider,{theme:Y,children:jsxRuntime.jsx(Si,{locale:x,children:jsxRuntime.jsxs(material.Box,{sx:[Qe=>({minHeight:"100vh",display:"flex",flexDirection:"column",background:Qe.palette.mode==="dark"?"linear-gradient(180deg, #0A0A0A 0%, #141414 55%, #1A1A1A 100%)":Qe.palette.background.default}),...Array.isArray(u)?u:[u]],children:[jsxRuntime.jsx(ws,{appTitle:e,logo:d===void 0?null:d,mode:I,onToggleMode:()=>M(Qe=>Qe==="system"?"dark":Qe==="dark"?"light":"system"),locale:x,localeLabel:S,localeOptions:B,onLocaleChange:R,user:h,onUserSetting:w,onUserLogout:A,userMenuItems:P,onSearch:v,leftSlot:Xe,rightSlot:Zt}),l?jsxRuntime.jsx(material.Box,{sx:{px:{xs:2,md:3},py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:l}):null,jsxRuntime.jsxs(material.Box,{sx:{flex:1,minHeight:0,display:"flex",position:"relative"},children:[J&&n&&ie==="landscape"?jsxRuntime.jsx(material.Box,{sx:{p:1.5,pr:0,flexShrink:0},children:zt}):null,!J||n&&ie==="portrait"?jsxRuntime.jsx(material.Drawer,{open:nt,onClose:()=>Le(false),PaperProps:{sx:{width:"min(88vw, 360px)",p:1.25,bgcolor:"transparent",boxShadow:"none"}},children:zt}):null,jsxRuntime.jsx(material.Box,{sx:{flex:1,minWidth:0,minHeight:0,overflow:"auto",p:1.5,...f},children:jsxRuntime.jsxs(material.Stack,{spacing:1.5,children:[i&&a.length>0?jsxRuntime.jsx(vm,{items:a,selectedId:r,orientation:ie,onItemSelect:y}):null,jsxRuntime.jsx(material.Paper,{elevation:0,sx:{flex:1,minHeight:ie==="portrait"?420:560,p:{xs:1.25,md:1.5},borderRadius:5,border:"1px solid",borderColor:"divider",bgcolor:Y.palette.mode==="dark"?"rgba(15,23,42,0.72)":"rgba(255,255,255,0.72)",backdropFilter:"blur(12px)",color:"text.primary"},children:t})]})})]}),ie==="portrait"&&g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsx(material.Box,{sx:{p:1.5},children:g})]}):null]})})})};var Om=Sk__default.default(()=>Promise.resolve().then(()=>(Vm(),Nm)).then(e=>e.COrbCanvas),{ssr:false,loading:()=>jsxRuntime.jsx("div",{className:"h-full w-full bg-transparent"})});function Kc({isRecording:e}){return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"pointer-events-none absolute inset-0 z-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"relative flex h-full w-full items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0",children:jsxRuntime.jsx(Om,{hue:0,hoverIntensity:.5,rotateOnHover:true,forceHoverState:true,backgroundColor:"transparent"})}),jsxRuntime.jsx("div",{className:"relative z-10 h-full w-1/3 mix-blend-overlay opacity-80",children:jsxRuntime.jsx(Om,{hue:10,hoverIntensity:.8,rotateOnHover:true,forceHoverState:true,backgroundColor:"transparent"})})]})})})}var tF=Kc;function Xs({onTextUpdate:e,onComplete:t,onError:o,wsUrl:a="ws://localhost:8765",silenceThresholdMs:r=2e3,minVolumeRms:n=.015}){let[i,c]=ht.useState(false),d=ht.useRef(null),l=ht.useRef(null),s=ht.useRef(null),g=ht.useRef(null),f=ht.useRef(null),u=ht.useRef(0),h=ht.useRef(false),v=ht.useRef(false),p=ht.useCallback(()=>{d.current&&(d.current.close(),d.current=null),g.current&&(g.current.disconnect(),g.current=null),f.current&&(f.current.disconnect(),f.current=null),l.current&&(l.current.getTracks().forEach(y=>y.stop()),l.current=null),s.current&&(s.current.close(),s.current=null),v.current=false,c(false);},[]),C=ht.useCallback(()=>{h.current||(h.current=true,d.current?.readyState===WebSocket.OPEN&&d.current.send(JSON.stringify({type:"stop"})),setTimeout(p,500));},[p]),m=ht.useCallback(async()=>{if(!(i||v.current)){v.current=true,h.current=false,u.current=Date.now();try{let y=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:16e3,echoCancellation:!0,noiseSuppression:!0}});l.current=y;let x=new WebSocket(a);d.current=x,x.onopen=()=>{c(!0),v.current=!1;},x.onmessage=A=>{try{let P=JSON.parse(A.data);if(P.type==="recognition")P.is_final?t(P.text):e?.(P.text);else if(P.type==="error"){let k=P.message||"Voice recognition error";o?.(k),C();}}catch{o?.("Failed to parse voice message");}},x.onerror=()=>{o?.("Voice service connection failed"),p();},x.onclose=()=>{p();};let S=window.AudioContext||window.webkitAudioContext;if(!S)throw new Error("AudioContext is not supported in this browser");let B=new S({sampleRate:16e3});s.current=B;let R=B.createMediaStreamSource(y);f.current=R;let w=B.createScriptProcessor(4096,1,1);g.current=w,w.onaudioprocess=A=>{if(d.current?.readyState!==WebSocket.OPEN)return;let P=A.inputBuffer.getChannelData(0),k=0;for(let I=0;I<P.length;I+=1)k+=P[I]*P[I];if(Math.sqrt(k/P.length)>n)u.current=Date.now();else if(Date.now()-u.current>r&&!h.current){C();return}let T=new Int16Array(P.length);for(let I=0;I<P.length;I+=1){let M=Math.max(-1,Math.min(1,P[I]));T[I]=M<0?M*32768:M*32767;}d.current.send(T.buffer);},R.connect(w),w.connect(B.destination);}catch{o?.("Cannot access microphone"),p();}}},[p,i,n,t,o,e,r,C,a]);return ht.useEffect(()=>p,[p]),{isRecording:i,startRecording:m,stopRecording:C}}var $m=ht.createContext(null);function Ek(e){if(!e||!(e instanceof HTMLElement))return false;let t=e.tagName;return !!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[data-voice-hotkey-ignore="true"]'))}function Fk({children:e,onVoiceSubmit:t,onVoicePartial:o,onVoiceError:a,longPressMs:r=200,disableSpaceTrigger:n=false,ignoreWhenFocusedInput:i=true,renderOverlay:c=true,wsUrl:d,silenceThresholdMs:l,minVolumeRms:s}){let[g,f]=ht.useState(false),[u,h]=ht.useState(false),v=ht.useRef(null),p=ht.useRef(false),C=ht.useRef(false),m=ht.useCallback(()=>{C.current=false,f(false);},[]),{isRecording:y,startRecording:x,stopRecording:S}=Xs({wsUrl:d,silenceThresholdMs:l,minVolumeRms:s,onTextUpdate:A=>{o?.(A);},onComplete:async A=>{try{A.trim()&&(h(!0),await t(A.trim()));}catch(P){let k=P instanceof Error?P.message:"Failed to process voice command";a?.(k);}finally{h(!1),m();}},onError:A=>{a?.(A),h(!1),p.current||m();}}),B=ht.useCallback(async()=>{C.current=false,await x();},[x]),R=ht.useCallback(()=>{S();},[S]);ht.useEffect(()=>{if(n)return;let A=k=>{k.isComposing||(k.code==="Space"||k.key===" ")&&(p.current||k.repeat||i&&Ek(document.activeElement)||(p.current=true,k.preventDefault(),v.current=setTimeout(()=>{C.current=true,f(true),x();},r)));},P=k=>{(k.code==="Space"||k.key===" ")&&(v.current&&(clearTimeout(v.current),v.current=null),p.current=false,C.current&&(k.preventDefault(),f(false),S()));};return window.addEventListener("keydown",A),window.addEventListener("keyup",P),()=>{window.removeEventListener("keydown",A),window.removeEventListener("keyup",P),v.current&&(clearTimeout(v.current),v.current=null);}},[n,i,r,x,S]);let w=ht.useMemo(()=>({isRecording:y,isHotkeyRecording:g,isSubmitting:u,startRecording:B,stopRecording:R}),[g,y,u,B,R]);return jsxRuntime.jsxs($m.Provider,{value:w,children:[c?jsxRuntime.jsx(Kc,{isRecording:g}):null,e]})}function Lk(){let e=ht.useContext($m);if(!e)throw new Error("useAINav must be used within CAINavProvider");return e}var cF=Fk,dF=Lk;function De(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var Hk=({content:e,theme:t="light",size:o="base",defaultExpanded:a=false})=>{let[r,n]=ht.useState(a),i=ht.useMemo(()=>`${(o==="sm"?14:o==="lg"?18:16)-2}px`,[o]);return jsxRuntime.jsxs("div",{className:`my-6 rounded-lg overflow-hidden transition-all duration-200 ${t==="dark"?"bg-gray-800":"bg-white"}`,style:{border:`0.5px solid ${t==="dark"?"#4b5563":"#d1d5db"}`},children:[jsxRuntime.jsxs("div",{className:`px-4 py-3 cursor-pointer flex items-center justify-between transition-colors duration-200 ${t==="dark"?"bg-gray-700 hover:bg-gray-650":"bg-gray-50 hover:bg-gray-100"}`,style:{borderBottom:`0.5px solid ${t==="dark"?"#4b5563":"#e5e7eb"}`},onClick:()=>n(!r),children:[jsxRuntime.jsxs("span",{className:"flex items-center",children:[jsxRuntime.jsx("span",{className:"mr-2",children:"\u{1F914}"}),jsxRuntime.jsx("span",{className:`font-medium ${t==="dark"?"text-gray-300":"text-gray-700"}`,style:{fontSize:o==="sm"?"14px":o==="lg"?"18px":"16px"},children:"\u601D\u8003\u8FC7\u7A0B"})]}),jsxRuntime.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${r?"rotate-180":""} ${t==="dark"?"text-gray-400":"text-gray-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxRuntime.jsx("div",{className:`p-4 whitespace-pre-wrap italic font-light ${t==="dark"?"text-gray-400":"text-gray-600"}`,style:{fontSize:i,lineHeight:"1.3 !important"},children:e})]})},Hm=Hk;var Xk=({content:e,language:t="text",isStreaming:o=false,className:a=""})=>{let{theme:r}=nextThemes.useTheme(),[n,i]=ht.useState(false),c=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3);}catch(l){console.error("\u590D\u5236\u5931\u8D25:",l);}},d=r==="dark"?prism.oneDark:prism.oneLight;return jsxRuntime.jsxs("div",{className:De("rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 my-4",a),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 uppercase",children:t}),jsxRuntime.jsx("button",{onClick:c,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",disabled:o,title:n?"Copied":"Copy code",children:n?jsxRuntime.jsx(lucideReact.Check,{size:14,className:"text-green-500"}):jsxRuntime.jsx(lucideReact.Clipboard,{size:14,className:"text-gray-500 dark:text-gray-400"})})]}),jsxRuntime.jsx("div",{className:"text-sm",children:jsxRuntime.jsx(reactSyntaxHighlighter.Prism,{language:t,style:d,customStyle:{margin:0,padding:"16px",fontSize:"14px",lineHeight:"1.5",backgroundColor:r==="dark"?"#1f2937":"#ffffff"},wrapLongLines:true,children:e})})]})},Um=Xk;var eS=({content:e,isLoading:t,className:o="",style:a})=>{let r=ht.useRef(null),[n,i]=ht.useState(false),[c,d]=ht.useState(null),{theme:l}=nextThemes.useTheme();return ht.useEffect(()=>{let s=async()=>{if(!(!e.trim()||!r.current)){i(true),d(null);try{qm__default.default.initialize({startOnLoad:!1,theme:l==="dark"?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});let f=`mermaid-${Math.random().toString(36).substr(2,9)}`,u=e.replace(/```mermaid\n?|\n?```/g,"").trim(),{svg:h}=await qm__default.default.render(f,u);r.current&&(r.current.innerHTML=h);}catch(f){console.error("Mermaid render failed:",f),d(f instanceof Error?f.message:"Render failed"),r.current&&(r.current.innerText=e);}finally{i(false);}}},g=setTimeout(()=>{s();},100);return ()=>clearTimeout(g)},[e,l]),t||n?jsxRuntime.jsx("div",{className:`mermaid-block loading ${o}`,style:a,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 bg-gray-50 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500 mr-2"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:"Generating Diagram..."})]})}):c?jsxRuntime.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-red-600 dark:text-red-400 text-sm overflow-auto",children:[jsxRuntime.jsx("p",{className:"font-semibold mb-2",children:"Mermaid Error:"}),jsxRuntime.jsx("pre",{children:c}),jsxRuntime.jsx("pre",{className:"mt-4 text-xs text-gray-500",children:e})]}):jsxRuntime.jsx("div",{className:`mermaid-block overflow-x-auto ${o}`,style:a,ref:r})},jm=eS;var iS=({title:e="\u53D1\u751F\u9519\u8BEF",content:t,errorCode:o,stack:a,icon:r,closable:n=true,onClose:i,onRetry:c,className:d="",...l})=>{let[s,g]=ht.useState(false),[f,u]=ht.useState(false),h=async()=>{if(c){u(true);try{await c();}catch(v){console.error("\u91CD\u8BD5\u5931\u8D25:",v);}finally{u(false);}}};return jsxRuntime.jsxs("div",{className:`relative w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${d}`,...l,children:[jsxRuntime.jsxs("div",{className:"flex p-4 border-l-4 border-l-red-500 bg-red-50 dark:bg-red-900/10",children:[jsxRuntime.jsx("div",{className:"flex-shrink-0 mr-3 text-red-500 mt-0.5",children:r||jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[jsxRuntime.jsx("h4",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:e}),o&&jsxRuntime.jsx("span",{className:"text-xs font-mono px-1.5 py-0.5 rounded bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300",children:o})]}),t&&jsxRuntime.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 mb-3 leading-relaxed",children:typeof t=="string"?jsxRuntime.jsx("p",{className:"whitespace-pre-wrap",children:t}):t}),(c||a)&&jsxRuntime.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[c&&jsxRuntime.jsxs("button",{onClick:h,disabled:f,className:"flex items-center text-xs font-medium text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors disabled:opacity-50",children:[jsxRuntime.jsx(lucideReact.RotateCw,{className:`w-3.5 h-3.5 mr-1.5 ${f?"animate-spin":""}`}),f?"\u91CD\u8BD5\u4E2D...":"\u91CD\u8BD5"]}),a&&jsxRuntime.jsxs("button",{onClick:()=>g(!s),className:"flex items-center text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 transition-colors",children:[s?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3.5 h-3.5 mr-1"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3.5 h-3.5 mr-1"}),s?"\u9690\u85CF\u8BE6\u60C5":"\u67E5\u770B\u8BE6\u60C5"]})]})]}),n&&i&&jsxRuntime.jsx("button",{onClick:i,className:"flex-shrink-0 ml-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors self-start",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),a&&s&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 p-3 border-t border-gray-100 dark:border-gray-800",children:jsxRuntime.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 overflow-x-auto whitespace-pre-wrap p-2 bg-white dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-800",children:a})})]})},Qs=iS;var uS=({title:e="\u8B66\u544A",content:t,warningType:o,severity:a="warning",warnings:r=[],icon:n,closable:i=true,onClose:c,onConfirm:d,actionText:l,className:s="",...g})=>{let f=()=>{switch(a){case "info":return {borderLeftColor:"border-l-blue-500",iconColor:"text-blue-500",bgColor:"bg-blue-50 dark:bg-blue-900/10"};case "error":return {borderLeftColor:"border-l-red-500",iconColor:"text-red-500",bgColor:"bg-red-50 dark:bg-red-900/10"};case "success":return {borderLeftColor:"border-l-green-500",iconColor:"text-green-500",bgColor:"bg-green-50 dark:bg-green-900/10"};default:return {borderLeftColor:"border-l-yellow-500",iconColor:"text-yellow-500",bgColor:"bg-yellow-50 dark:bg-yellow-900/10"}}},u=()=>{switch(a){case "info":return jsxRuntime.jsx(lucideReact.Info,{className:"w-5 h-5"});case "error":return jsxRuntime.jsx(lucideReact.XCircle,{className:"w-5 h-5"});case "success":return jsxRuntime.jsx(lucideReact.CheckCircle,{className:"w-5 h-5"});default:return jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5"})}},h=f();return jsxRuntime.jsxs("div",{className:`relative w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${s}`,...g,children:[jsxRuntime.jsxs("div",{className:`flex p-4 border-l-4 ${h.borderLeftColor} ${h.bgColor}`,children:[jsxRuntime.jsx("div",{className:`flex-shrink-0 mr-3 ${h.iconColor}`,children:n||u()}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("h4",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:e}),o&&jsxRuntime.jsx("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400",children:o})]}),t&&jsxRuntime.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 mb-2",children:t}),r&&r.length>0&&jsxRuntime.jsx("ul",{className:"mt-2 space-y-1",children:r.map((v,p)=>jsxRuntime.jsxs("li",{className:"flex items-start text-sm text-gray-600 dark:text-gray-300",children:[jsxRuntime.jsx("span",{className:"mr-2 mt-1.5 w-1 h-1 rounded-full bg-gray-400 dark:bg-gray-500 flex-shrink-0"}),jsxRuntime.jsx("span",{children:v})]},p))})]}),i&&c&&jsxRuntime.jsx("button",{onClick:c,className:"flex-shrink-0 ml-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),d&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-800/50 px-4 py-3 flex justify-end border-t border-gray-100 dark:border-gray-800",children:jsxRuntime.jsx("button",{onClick:d,className:"px-4 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",children:l||"\u786E\u8BA4"})})]})},Ys=uS;var hS=({title:e="\u76F8\u5173\u63A8\u8350",content:t,suggestions:o,onSuggestionClick:a,maxDisplay:r=5,icon:n,closable:i=false,onClose:c,className:d="",...l})=>{let[s,g]=ht.useState(false),[f,u]=ht.useState(""),[h,v]=ht.useState(false),p=ht.useMemo(()=>f.trim()?o.filter(y=>y.toLowerCase().includes(f.toLowerCase())):o,[o,f]),C=ht.useMemo(()=>s?p:p.slice(0,r),[p,s,r]),m=y=>{a?.(y);};return !o||o.length===0?null:jsxRuntime.jsxs("div",{className:`w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${d}`,...l,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-blue-50/30 dark:bg-blue-900/10",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2.5",children:[jsxRuntime.jsx("div",{className:"text-blue-500 flex-shrink-0",children:n||jsxRuntime.jsx(lucideReact.Lightbulb,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 leading-tight",children:e}),t&&jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:t})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[o.length>3&&jsxRuntime.jsx("button",{onClick:()=>v(!h),className:`p-1.5 rounded-md transition-colors ${h?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:h?"\u5173\u95ED\u641C\u7D22":"\u641C\u7D22\u95EE\u9898",children:jsxRuntime.jsx(lucideReact.Search,{className:"w-4 h-4"})}),i&&c&&jsxRuntime.jsx("button",{onClick:c,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",title:"\u5173\u95ED",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})]}),h&&jsxRuntime.jsx("div",{className:"px-4 py-2 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/50",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"text",placeholder:"\u641C\u7D22\u76F8\u5173\u95EE\u9898...",value:f,onChange:y=>u(y.target.value),className:"w-full text-sm px-3 py-1.5 pl-8 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-1 focus:ring-blue-500 focus:border-blue-500 outline-none transition-shadow",autoFocus:true}),jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-2.5 top-2 w-3.5 h-3.5 text-gray-400"})]})}),jsxRuntime.jsxs("div",{className:"p-2",children:[jsxRuntime.jsx("ul",{className:"space-y-1",children:C.map((y,x)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{onClick:()=>m(y),className:"w-full text-left px-3 py-2 rounded-md text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-blue-600 dark:hover:text-blue-400 transition-colors group flex items-start justify-between",children:[jsxRuntime.jsx("span",{children:y}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4 text-gray-300 group-hover:text-blue-400 opacity-0 group-hover:opacity-100 transition-all transform group-hover:translate-x-0.5"})]})},x))}),p.length>r&&jsxRuntime.jsx("button",{onClick:()=>g(!s),className:"w-full text-center py-2 text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors border-t border-gray-50 dark:border-gray-800/50 mt-1",children:s?"\u6536\u8D77":`\u67E5\u770B\u5168\u90E8 (${p.length})`}),p.length===0&&f&&jsxRuntime.jsx("div",{className:"text-center py-4 text-sm text-gray-500 dark:text-gray-400",children:"\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u5EFA\u8BAE"})]})]})},Js=hS;var SS=({title:e,content:t,toolName:o,parameters:a,result:r,status:n,duration:i,icon:c,closable:d=false,onClose:l,onAction:s,actionText:g,className:f="",...u})=>{let[h,v]=ht.useState(false),[p,C]=ht.useState(true),m=()=>{switch(n){case "pending":return {iconColor:"text-blue-500",badgeBg:"bg-blue-50 dark:bg-blue-900/30",badgeText:"text-blue-600 dark:text-blue-400",label:"\u6267\u884C\u4E2D"};case "error":return {iconColor:"text-red-500",badgeBg:"bg-red-50 dark:bg-red-900/30",badgeText:"text-red-600 dark:text-red-400",label:"\u5931\u8D25"};default:return {iconColor:"text-green-500",badgeBg:"bg-green-50 dark:bg-green-900/30",badgeText:"text-green-600 dark:text-green-400",label:"\u6210\u529F"}}},y=()=>{switch(n){case "pending":return jsxRuntime.jsx(lucideReact.Loader2,{className:"w-5 h-5 animate-spin"});case "error":return jsxRuntime.jsx(lucideReact.XCircle,{className:"w-5 h-5"});default:return jsxRuntime.jsx(lucideReact.CheckCircle,{className:"w-5 h-5"})}},x=R=>R?R<1e3?`${R}ms`:`${(R/1e3).toFixed(2)}s`:"",S=m(),B=e||o||"\u5DE5\u5177\u8C03\u7528";return jsxRuntime.jsxs("div",{className:`w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${f}`,...u,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-3",children:[jsxRuntime.jsx("div",{className:`flex-shrink-0 ${S.iconColor}`,children:c||y()}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:B}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${S.badgeBg} ${S.badgeText}`,children:S.label})]}),o&&e&&jsxRuntime.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 flex items-center mt-0.5",children:[jsxRuntime.jsx(lucideReact.Terminal,{className:"w-3 h-3 mr-1"}),o]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400",children:[i&&jsxRuntime.jsxs("div",{className:"flex items-center bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3 mr-1"}),x(i)]}),d&&l&&jsxRuntime.jsx("button",{onClick:l,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1 rounded",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"p-4",children:[t&&jsxRuntime.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 mb-4 leading-relaxed",children:t}),a&&jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsxs("button",{onClick:()=>v(!h),className:"flex items-center text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 mb-2",children:[h?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3.5 h-3.5 mr-1"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3.5 h-3.5 mr-1"}),jsxRuntime.jsx(lucideReact.Box,{className:"w-3.5 h-3.5 mr-1.5"}),"\u8F93\u5165\u53C2\u6570"]}),h&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 rounded border border-gray-100 dark:border-gray-800 overflow-hidden",children:jsxRuntime.jsx("pre",{className:"p-3 text-xs font-mono text-gray-600 dark:text-gray-400 overflow-x-auto",children:JSON.stringify(a,null,2)})})]}),r&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{onClick:()=>C(!p),className:"flex items-center text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 mb-2",children:[p?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3.5 h-3.5 mr-1"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3.5 h-3.5 mr-1"}),jsxRuntime.jsx(lucideReact.Terminal,{className:"w-3.5 h-3.5 mr-1.5"}),"\u6267\u884C\u7ED3\u679C"]}),p&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 rounded border border-gray-100 dark:border-gray-800 overflow-hidden",children:jsxRuntime.jsx("pre",{className:"p-3 text-xs font-mono text-gray-600 dark:text-gray-400 overflow-x-auto",children:typeof r=="string"?r:JSON.stringify(r,null,2)})})]}),s&&jsxRuntime.jsx("div",{className:"mt-3 pt-3 border-t border-gray-100 dark:border-gray-800 flex justify-end",children:jsxRuntime.jsx("button",{onClick:s,className:"px-4 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",children:g||"\u6267\u884C\u64CD\u4F5C"})})]})]})},el=SS;var TS=({data:e})=>{if(!e)return null;let t=ht.useMemo(()=>{let o=[],a=[],r="\u6570\u636E\u8868\u683C";return Array.isArray(e)?(o=e,o.length>0&&(a=Object.keys(o[0]).map(n=>({id:n,label:n.charAt(0).toUpperCase()+n.slice(1),numeric:typeof o[0][n]=="number"})))):typeof e=="object"&&(r=e.title||r,o=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[],Array.isArray(e.columns)?a=e.columns.map(i=>({id:i.key||i.id,label:i.title||i.label,numeric:i.dataType==="number"||i.numeric})):o.length>0&&(a=Object.keys(o[0]).map(i=>({id:i,label:i,numeric:typeof o[0][i]=="number"})))),o=o.map((n,i)=>({...n,id:n.id||`row_${i}`})),{title:r,columns:a,rows:o}},[e]);return t.rows.length===0?jsxRuntime.jsx("div",{className:"w-full my-4 p-4 border border-dashed border-gray-300 rounded text-center text-gray-500",children:"\u6682\u65E0\u8868\u683C\u6570\u636E"}):jsxRuntime.jsx("div",{className:"w-full my-4",children:jsxRuntime.jsx(La,{appId:"agent-ui-table-card",title:t.title,columns:t.columns,rows:t.rows,count:t.rows.length,rowKey:"id",fitContainer:false,maxHeight:"500px",rowsPerPage:10,rowsPerPageOptions:[5,10,20,50]})})},tl=TS;var FS=({title:e,subtitle:t,data:o,type:a,config:r={}})=>{let n=()=>{switch(a){case "bar-chart-card":return jsxRuntime.jsx(lucideReact.BarChart,{className:"w-4 h-4 text-blue-500"});case "line-chart-card":return jsxRuntime.jsx(lucideReact.LineChart,{className:"w-4 h-4 text-green-500"});case "pie-chart-card":return jsxRuntime.jsx(lucideReact.PieChart,{className:"w-4 h-4 text-purple-500"});case "combo-chart-card":return jsxRuntime.jsx(lucideReact.Activity,{className:"w-4 h-4 text-orange-500"});case "heatmap-chart-card":return jsxRuntime.jsx(lucideReact.Grid,{className:"w-4 h-4 text-red-500"});case "fishbone-chart-card":return jsxRuntime.jsx(lucideReact.GitBranch,{className:"w-4 h-4 text-indigo-500"});case "waterfall-chart-card":return jsxRuntime.jsx(lucideReact.TrendingDown,{className:"w-4 h-4 text-teal-500"});case "google-map-card":return jsxRuntime.jsx(lucideReact.Globe,{className:"w-4 h-4 text-blue-600"});case "amap-card":return jsxRuntime.jsx(lucideReact.MapPin,{className:"w-4 h-4 text-blue-600"});default:return jsxRuntime.jsx(lucideReact.BarChart,{className:"w-4 h-4"})}},i=()=>{if(!o&&a!=="google-map-card"&&a!=="amap-card")return jsxRuntime.jsx("div",{className:"text-gray-500 text-sm p-4 text-center",children:"No data available"});try{switch(a){case "bar-chart-card":return jsxRuntime.jsx(En,{data:o,orientation:r.orientation||"horizontal",valueSuffix:r.valueSuffix||"",minHeight:r.minHeight});case "line-chart-card":return jsxRuntime.jsx($d,{data:o,color:r.color,valueSuffix:r.valueSuffix||"",height:r.height});case "pie-chart-card":let c=o.reduce((l,s)=>l+(Number(s.value)||0),0),d=o.map(l=>({name:l.name,value:Number(l.value)||0,percent:typeof l.percent=="number"?l.percent:c>0?(Number(l.value)||0)/c*100:0}));return jsxRuntime.jsx(Vi,{data:d,variant:r.variant||"donut",size:r.size,colors:r.colors});case "combo-chart-card":return jsxRuntime.jsx(Hd,{data:o,barColor:r.barColor,lineColor:r.lineColor});case "heatmap-chart-card":return jsxRuntime.jsx(Ud,{data:o});case "fishbone-chart-card":return jsxRuntime.jsx(qd,{branches:o,effect:r.effect||e||"Problem"});case "waterfall-chart-card":return jsxRuntime.jsx(jd,{data:o,height:r.height});case "google-map-card":return jsxRuntime.jsx(Qd,{embedUrl:r.embedUrl||o&&o[0]?.embedUrl,apiKey:r.apiKey,query:r.query||o&&o[0]?.query||e,height:r.height});case "amap-card":return jsxRuntime.jsx(tp,{embedUrl:r.embedUrl||o&&o[0]?.embedUrl,keyword:r.keyword||o&&o[0]?.keyword||e,height:r.height});default:return jsxRuntime.jsxs("div",{className:"text-gray-500 text-sm p-4 text-center",children:["Unsupported chart type: ",a]})}}catch(c){return console.error("Error rendering chart:",c),jsxRuntime.jsx("div",{className:"text-red-500 text-sm p-4 text-center",children:"Error rendering chart"})}};return jsxRuntime.jsxs("div",{className:"w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50",children:[jsxRuntime.jsx("div",{className:"mr-2 flex-shrink-0",children:n()}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:e}),t&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 truncate",children:t})]})]}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("div",{className:"overflow-x-auto",children:i()}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsxs("details",{className:"text-xs text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("summary",{className:"cursor-pointer hover:text-gray-700 dark:hover:text-gray-300 transition-colors select-none font-medium opacity-60 hover:opacity-100",children:"View Raw Data"}),jsxRuntime.jsx("pre",{className:"mt-2 p-2 bg-gray-50 dark:bg-gray-950 rounded border border-gray-100 dark:border-gray-800 overflow-x-auto max-h-40",children:JSON.stringify(o,null,2)})]})})]})]})},ol=FS;var zS=({type:e,manifest:t})=>jsxRuntime.jsxs("div",{className:"w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-blue-50/50 dark:bg-blue-900/10",children:[jsxRuntime.jsx(lucideReact.Box,{className:"w-4 h-4 mr-2 text-blue-600 dark:text-blue-400"}),jsxRuntime.jsxs("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:["SAP Card: ",e]})]}),jsxRuntime.jsx("div",{className:"p-4",children:jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 p-3 rounded border border-gray-100 dark:border-gray-800 overflow-x-auto",children:jsxRuntime.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:JSON.stringify(t,null,2)})})})]}),rl=zS;var nl=e=>{let t;try{t=JSON.parse(e);}catch{return null}return t&&typeof t=="object"&&((t.type==="bar-chart-card"||t.type==="line-chart-card"||t.type==="pie-chart-card"||t.type==="combo-chart-card"||t.type==="heatmap-chart-card"||t.type==="fishbone-chart-card"||t.type==="waterfall-chart-card"||t.type==="google-map-card"||t.type==="amap-card")&&t.title||(t.type==="sap-analytical-card"||t.type==="sap-list-card"||t.type==="sap-object-card"||t.type==="sap-component-card")&&t.manifest||t.type==="error-card"||t.type==="warning-card"||t.type==="suggestions-card"||t.type==="tool-result-card"||t.type==="table"&&t.data)?t:null};var HS=({content:e,theme:t,size:o="base",className:a,enableCodeHighlight:r=true,enableMermaid:n=true,messageId:i,cardHooks:c})=>{let d=ht.useMemo(()=>e?e.replace(/<think>([\s\S]*?)<\/think>/g,(f,u)=>`<div data-component="thinkbox" data-think-content="${encodeURIComponent(u.trim())}"></div>`):"",[e]),l=(f,u,h,v,p)=>{c?.onCardEvent?.({messageId:i,cardType:f,action:u,title:h,payload:v,rawData:p});},s=(f,u,h,v,p,C)=>{if(!(!p&&!c?.onCardEvent))return (...m)=>{let y=p?.(...m),x=C?C(...m):void 0;return l(f,u,h,x,v),y}},g=ht.useMemo(()=>({div(f){let{"data-component":u,"data-think-content":h,...v}=f;return u==="thinkbox"&&h?jsxRuntime.jsx(Hm,{content:decodeURIComponent(h),theme:t,size:o,defaultExpanded:false}):jsxRuntime.jsx("div",{...v})},table({children:f}){return jsxRuntime.jsx("div",{className:"my-4 w-full overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:jsxRuntime.jsx("table",{className:"w-full min-w-[520px] border-collapse text-sm",children:f})})},thead({children:f}){return jsxRuntime.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/60",children:f})},tbody({children:f}){return jsxRuntime.jsx("tbody",{className:"bg-white dark:bg-gray-950",children:f})},tr({children:f}){return jsxRuntime.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-800 last:border-b-0",children:f})},th({children:f,align:u}){return jsxRuntime.jsx("th",{className:`px-3 py-2 font-semibold text-gray-800 dark:text-gray-100 ${u==="center"?"text-center":u==="right"?"text-right":"text-left"}`,children:f})},td({children:f,align:u}){return jsxRuntime.jsx("td",{className:`px-3 py-2 text-gray-700 dark:text-gray-200 align-top ${u==="center"?"text-center":u==="right"?"text-right":"text-left"}`,children:f})},code({inline:f,className:u,children:h,...v}){let p=/language-([\w-]+)/.exec(u||""),C=p?p[1]:"";if(f)return jsxRuntime.jsx("code",{className:"font-mono text-sm bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded text-red-600 dark:text-red-400",...v,children:h});let m=String(h).replace(/\n$/,"");if(n&&C==="mermaid")return jsxRuntime.jsx(jm,{content:m});if(C==="json"){let y=nl(m);if(y)switch(y.type){case "table":return jsxRuntime.jsx(tl,{data:y.data});case "bar-chart-card":case "line-chart-card":case "pie-chart-card":case "combo-chart-card":case "heatmap-chart-card":case "fishbone-chart-card":case "waterfall-chart-card":case "google-map-card":case "amap-card":return jsxRuntime.jsx(ol,{...y});case "sap-analytical-card":case "sap-list-card":case "sap-object-card":case "sap-component-card":return jsxRuntime.jsx(rl,{...y});case "error-card":{let x=y;return jsxRuntime.jsx(Qs,{...x,onClose:s("error-card","close",x.title,x,x.onClose),onRetry:s("error-card","retry",x.title,x,x.onRetry)})}case "warning-card":{let x=y,S=x.onConfirm?s("warning-card","confirm",x.title,x,x.onConfirm):x.actionText&&c?.onCardEvent?s("warning-card","confirm",x.title,x):void 0;return jsxRuntime.jsx(Ys,{...x,onClose:s("warning-card","close",x.title,x,x.onClose),onConfirm:S})}case "suggestions-card":{let x=y;return jsxRuntime.jsx(Js,{...x,onClose:s("suggestions-card","close",x.title,x,x.onClose),onSuggestionClick:s("suggestions-card","suggestion-click",x.title,x,x.onSuggestionClick,S=>({suggestion:S}))})}case "tool-result-card":{let x=y;return jsxRuntime.jsx(el,{...x,onClose:s("tool-result-card","close",x.title,x,x.onClose),onAction:s("tool-result-card","action",x.title,x,x.onAction)})}}}return r?jsxRuntime.jsx(Um,{content:m,language:C,className:"not-prose"}):jsxRuntime.jsx("code",{className:u,...v,children:h})}}),[t,o,n,r,c,i]);return jsxRuntime.jsx("div",{className:De("markdown-body prose dark:prose-invert max-w-none",a),children:jsxRuntime.jsx(NS__default.default,{remarkPlugins:[VS__default.default,OS__default.default],rehypePlugins:[WS__default.default,$S__default.default],components:g,children:d})})},il=HS;var GS=({content:e,messageId:t,cardHooks:o})=>{let a=(i,c,d,l,s)=>{o?.onCardEvent?.({messageId:t,cardType:i,action:c,title:d,payload:l,rawData:s});},r=(i,c,d,l,s,g)=>{if(!(!s&&!o?.onCardEvent))return (...f)=>{let u=s?.(...f),h=g?g(...f):void 0;return a(i,c,d,h,l),u}},n=nl(e);if(n)switch(n.type){case "table":return jsxRuntime.jsx(tl,{data:n.data});case "bar-chart-card":case "line-chart-card":case "pie-chart-card":case "combo-chart-card":case "heatmap-chart-card":case "fishbone-chart-card":case "waterfall-chart-card":case "google-map-card":case "amap-card":return jsxRuntime.jsx(ol,{...n});case "sap-analytical-card":case "sap-list-card":case "sap-object-card":case "sap-component-card":return jsxRuntime.jsx(rl,{...n});case "error-card":{let i=n;return jsxRuntime.jsx(Qs,{...i,onClose:r("error-card","close",i.title,i,i.onClose),onRetry:r("error-card","retry",i.title,i,i.onRetry)})}case "warning-card":{let i=n,c=i.onConfirm?r("warning-card","confirm",i.title,i,i.onConfirm):i.actionText&&o?.onCardEvent?r("warning-card","confirm",i.title,i):void 0;return jsxRuntime.jsx(Ys,{...i,onClose:r("warning-card","close",i.title,i,i.onClose),onConfirm:c})}case "suggestions-card":{let i=n;return jsxRuntime.jsx(Js,{...i,onClose:r("suggestions-card","close",i.title,i,i.onClose),onSuggestionClick:r("suggestions-card","suggestion-click",i.title,i,i.onSuggestionClick,c=>({suggestion:c}))})}case "tool-result-card":{let i=n;return jsxRuntime.jsx(el,{...i,onClose:r("tool-result-card","close",i.title,i,i.onClose),onAction:r("tool-result-card","action",i.title,i,i.onAction)})}}return jsxRuntime.jsx("div",{className:"dynamic-card-fallback",children:jsxRuntime.jsx(il,{content:e,enableCodeHighlight:true,enableMath:true,enableMermaid:true,messageId:t,cardHooks:o})})},rg=GS;var ed=class{static analyze(t){if(!t.trim())return {blocks:[],hasComplexContent:false,overallType:"simple"};let a=/```json\s*\{\s*"type":\s*"[^"]+"/g.test(t),r=/<[^>]+>[\s\S]*?<\/[^>]+>/.test(t),n=t.includes("NQ#")||t.includes("data-component");return a||r||n?{blocks:[{type:"mixed",content:t,startIndex:0,endIndex:t.length}],hasComplexContent:true,overallType:"complex"}:{blocks:[{type:"markdown",content:t,startIndex:0,endIndex:t.length}],hasComplexContent:false,overallType:"simple"}}},KS=({content:e,className:t="",messageId:o,cardHooks:a})=>{let r=ht__namespace.default.useMemo(()=>ed.analyze(e),[e]);return jsxRuntime.jsx("div",{className:`universal-content-renderer ${t}`,children:r.blocks.map((n,i)=>n.type==="mixed"||n.type==="json-card"?jsxRuntime.jsx(rg,{content:n.content,messageId:o,cardHooks:a},`block-${i}`):jsxRuntime.jsx(il,{content:n.content,enableCodeHighlight:true,enableMath:true,enableMermaid:true,messageId:o,cardHooks:a},`block-${i}`))})},ng=KS;var qS=({content:e,isStreaming:t=true,onComplete:o,className:a="",streamIntervalMs:r=24,streamChunkSize:n=3,messageId:i,cardHooks:c})=>{let[d,l]=ht.useState(t?0:e.length),[s,g]=ht.useState(!t);ht.useEffect(()=>{if(t){l(0),g(false);return}l(e.length),g(true);},[e,t]),ht.useEffect(()=>{if(!t||s)return;if(d>=e.length){g(true),o?.();return}let p=window.setTimeout(()=>{l(C=>Math.min(C+n,e.length));},r);return ()=>{window.clearTimeout(p);}},[e.length,s,t,o,n,r,d]);let f=()=>{t&&!s&&(l(e.length),g(true),o?.());},u=t?e.slice(0,d):e,h=t&&!s,v=t&&!s;return jsxRuntime.jsxs("div",{className:`streaming-markdown ${a}`,onClick:f,style:{cursor:t?"pointer":"default"},children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(ng,{content:u,messageId:i,cardHooks:c}),h&&jsxRuntime.jsx("span",{className:"inline-block w-0.5 h-5 bg-blue-500 ml-1 animate-pulse",style:{verticalAlign:"text-bottom"}})]}),v&&jsxRuntime.jsx("div",{className:"streaming-hint",style:{fontSize:"9px",color:"#999",marginTop:"8px",fontStyle:"italic",opacity:.7},children:"\u70B9\u51FB\u6B64\u5904\u663E\u793A\u5B8C\u6574\u5185\u5BB9"})]})},cg=qS;var dg=({buttons:e,className:t})=>{let o=a=>{switch(a){case "copy":return jsxRuntime.jsx(lucideReact.Copy,{size:14});case "refresh":return jsxRuntime.jsx(lucideReact.RefreshCw,{size:14});case "volume":return jsxRuntime.jsx(lucideReact.Volume2,{size:14});case "like":return jsxRuntime.jsx(lucideReact.ThumbsUp,{size:14});case "dislike":return jsxRuntime.jsx(lucideReact.ThumbsDown,{size:14});default:return null}};return jsxRuntime.jsx("div",{className:De("flex items-center gap-1",t),children:e.map((a,r)=>jsxRuntime.jsx("button",{onClick:a.onClick,disabled:a.disabled,className:De("p-1.5 rounded-md transition-colors","text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-800","disabled:opacity-50 disabled:cursor-not-allowed",a.active&&"text-blue-600 bg-blue-50 dark:text-blue-400 dark:bg-blue-900/20",a.type==="refresh"&&a.disabled&&"animate-spin"),title:a.type,type:"button",children:o(a.type)},`${a.type}-${r}`))})};var sl=({message:e,onStreamingComplete:t,assistantActions:o,streamIntervalMs:a,streamChunkSize:r,cardHooks:n})=>e.type==="assistant"?jsxRuntime.jsx("div",{className:"flex justify-start mb-4",children:jsxRuntime.jsxs("div",{className:"w-full bg-transparent text-black dark:text-gray-100 rounded-2xl px-4 py-3 mr-auto",style:{lineHeight:"1.5",fontSize:"16px",fontWeight:"280",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[jsxRuntime.jsx(cg,{content:e.content,isStreaming:e.isStreaming??false,onComplete:t,streamIntervalMs:a,streamChunkSize:r,messageId:e.id,cardHooks:n}),e.content&&o?.isLatestAssistant&&jsxRuntime.jsx("div",{className:"flex flex-row justify-start gap-2 mt-3 pt-2 border-t border-gray-100 dark:border-gray-700",children:jsxRuntime.jsx(dg,{buttons:[{type:"refresh",onClick:()=>o?.onRegenerate?.(),disabled:!o?.onRegenerate},{type:"copy",onClick:()=>navigator.clipboard.writeText(e.content),disabled:false},{type:"volume",onClick:()=>console.log("\u8BED\u97F3\u64AD\u653E"),disabled:false},{type:"like",onClick:()=>console.log("\u70B9\u8D5E"),disabled:false},{type:"dislike",onClick:()=>console.log("\u70B9\u8E29"),disabled:false}],size:"sm",variant:"default"})}),jsxRuntime.jsx("div",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:e.timestamp.toLocaleTimeString()})]})}):jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsxs("div",{className:"max-w-[80%] bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-2xl px-4 py-3 ml-auto",style:{lineHeight:"1.5",fontSize:"16px",fontWeight:"280",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[jsxRuntime.jsx("div",{className:"whitespace-pre-wrap",style:{lineHeight:"1.5",fontSize:"16px",fontWeight:"280",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:e.content}),jsxRuntime.jsx("div",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:e.timestamp.toLocaleTimeString()})]})});var ug=({onTextUpdate:e,onComplete:t,onCancel:o,disabled:a,className:r})=>{let{isRecording:n,startRecording:i,stopRecording:c}=Xs({onTextUpdate:e,onComplete:l=>{t?.(l);},onError:l=>{console.error("Voice input error:",l),o?.();}});return jsxRuntime.jsx("button",{onClick:async()=>{n?c():await i();},disabled:a,className:De("transition-all duration-200 flex items-center justify-center rounded-full",n?"bg-red-100 text-red-600 hover:bg-red-200 animate-pulse":"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 active:scale-95",a&&"opacity-50 cursor-not-allowed",r),title:n?"Stop recording":"Start recording",type:"button",children:n?jsxRuntime.jsx(JS__default.default,{sx:{fontSize:24}}):jsxRuntime.jsx(YS__default.default,{sx:{fontSize:24}})})};var yt={container:"w-full max-w-4xl mx-auto",inputContainer:De("w-full border backdrop-blur-xl transition-all duration-300 shadow-2xl flex flex-col","bg-white/80 dark:bg-gray-900/80","border-gray-200/60 dark:border-gray-600/40","shadow-gray-900/5","hover:border-blue-300/80 hover:shadow-blue-500/10 hover:shadow-2xl","focus-within:border-blue-400/90 focus-within:shadow-blue-500/20 focus-within:shadow-3xl focus-within:scale-[1.005] transform-gpu"),dragActive:"border-blue-500 bg-blue-50/50 dark:bg-blue-900/20",textareaWrapper:"flex-1 relative flex items-center",textarea:De("w-full outline-none appearance-none resize-none bg-transparent border-none text-sm font-normal py-3 px-2","placeholder:text-gray-400/70 dark:placeholder:text-gray-500/60 placeholder:font-normal","text-gray-800 dark:text-gray-100 selection:bg-blue-200/50 dark:selection:bg-blue-500/30","focus:ring-0 focus:outline-none focus:border-none focus:shadow-none","min-h-[44px] max-h-[12em] overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600"),filePreviewArea:"px-6 pt-3 pb-1 flex flex-wrap gap-2",fileTag:De("flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-medium","bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300","border border-gray-200 dark:border-gray-700","transition-all hover:bg-gray-200 dark:hover:bg-gray-700"),buttonBase:"flex items-center justify-center transition-all duration-200 rounded-full",buttonSmall:"w-10 h-10",buttonNormal:De("bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400","cursor-pointer active:scale-95"),sendButton:De("cursor-pointer bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 shadow-none active:scale-95"),sendButtonDisabled:De("cursor-not-allowed opacity-40 bg-transparent text-gray-400"),stopButton:De("cursor-pointer bg-red-500 hover:bg-red-600 text-white shadow-sm active:scale-95")},sw={padding:0,lineHeight:"1.5",border:"none !important",boxShadow:"none !important",backgroundColor:"transparent",height:"auto",fontFeatureSettings:'"liga" 1, "kern" 1',WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"},lw=({enabled:e,onClick:t})=>jsxRuntime.jsx("button",{className:De(yt.buttonBase,yt.buttonSmall,yt.buttonNormal),onClick:t,disabled:!e,"aria-label":"Upload file",type:"button",children:jsxRuntime.jsx(nw__default.default,{sx:{fontSize:24}})}),cw=()=>jsxRuntime.jsxs("button",{className:De(yt.buttonBase,"h-10 px-3 py-2 gap-1.5 rounded-full",yt.buttonNormal),"aria-label":"Tools",type:"button",children:[jsxRuntime.jsx(iw__default.default,{sx:{fontSize:20}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Tools"})]}),dw=({canSend:e,isResponding:t,onSend:o,onStop:a})=>t?jsxRuntime.jsx("button",{className:De(yt.buttonBase,yt.buttonSmall,yt.stopButton),onClick:a,"aria-label":"Stop generating",type:"button",children:jsxRuntime.jsx(iconsMaterial.Stop,{sx:{fontSize:20}})}):jsxRuntime.jsx("button",{className:De(yt.buttonBase,yt.buttonSmall,e?yt.sendButton:yt.sendButtonDisabled),onClick:o,disabled:!e,"aria-label":"Send message",type:"button",children:jsxRuntime.jsx(rw__default.default,{sx:{fontSize:24},className:e?"text-gray-500 dark:text-gray-400":"text-gray-300 dark:text-gray-600"})}),mg=({onSend:e,onStop:t,isResponding:o=false,placeholder:a,getText:r})=>{let[n,i]=ht.useState(""),[c,d]=ht.useState([]),[l,s]=ht.useState(false),[g,f]=ht.useState(false),u=ht.useRef(null),h=a||(r?r("00019","Type a message..."):"Type a message..."),v=(n.trim().length>0||c.length>0)&&!o,p={enabled:true},C=ht.useCallback(M=>{i(M.target.value),M.target.style.height="auto",M.target.style.height=`${Math.min(M.target.scrollHeight,200)}px`;},[]),m=ht.useCallback(M=>{if(M.target.files&&M.target.files.length>0){let H=Array.from(M.target.files);d(V=>{let J=H.filter(te=>V.some(ne=>ne.name===te.name&&ne.size===te.size));J.length>0&&console.warn("Duplicate files ignored:",J.map(te=>te.name));let ce=H.filter(te=>!V.some(ne=>ne.name===te.name&&ne.size===te.size));return [...V,...ce]}),u.current&&(u.current.value="");}},[]),y=ht.useCallback(M=>{d(H=>H.filter((V,J)=>J!==M));},[]),x=ht.useCallback(()=>{u.current?.click();},[]),S=ht.useCallback(async()=>{if(!v)return;let M=n,H=[...c];i(""),d([]),u.current&&(u.current.value="");try{await e(M,H);}catch(V){console.error("Failed to send message:",V),i(M),d(H);}},[n,v,e,c]),B=ht.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&!l&&(M.preventDefault(),S());},[S,l]),R=ht.useCallback(()=>{s(true);},[]),w=ht.useCallback(()=>{s(false);},[]),A=ht.useCallback(M=>{i(M);},[]),P=ht.useCallback(M=>{i(M);},[]),k=ht.useCallback(()=>{},[]),D=ht.useCallback(M=>{M.preventDefault(),f(true);},[]),T=ht.useCallback(M=>{M.preventDefault(),f(false);},[]),I=ht.useCallback(M=>{if(M.preventDefault(),f(false),M.dataTransfer.files&&M.dataTransfer.files.length>0){let H=Array.from(M.dataTransfer.files);d(V=>[...V,...H]);}},[]);return jsxRuntime.jsx("div",{className:yt.container,children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"file",multiple:true,className:"hidden",ref:u,onChange:m}),jsxRuntime.jsxs("div",{className:De(yt.inputContainer,g&&yt.dragActive),style:{borderRadius:"32px"},onDragOver:D,onDragLeave:T,onDrop:I,children:[c.length>0&&jsxRuntime.jsx("div",{className:yt.filePreviewArea,children:c.map((M,H)=>jsxRuntime.jsxs("div",{className:yt.fileTag,children:[jsxRuntime.jsx(iconsMaterial.InsertDriveFile,{sx:{fontSize:16},className:"text-blue-500"}),jsxRuntime.jsx("span",{className:"truncate max-w-[150px]",children:M.name}),jsxRuntime.jsx("button",{onClick:()=>y(H),className:"ml-1 hover:text-red-500 focus:outline-none",type:"button",children:jsxRuntime.jsx(iconsMaterial.Close,{sx:{fontSize:16}})})]},`${M.name}-${H}`))}),jsxRuntime.jsxs("div",{className:"flex flex-col w-full p-2",children:[jsxRuntime.jsx("div",{className:De(yt.textareaWrapper,"px-3 pt-2 pb-3 min-h-[60px]"),children:jsxRuntime.jsx("textarea",{className:De(yt.textarea,"min-h-[24px] py-0 px-0"),placeholder:h,value:n,onChange:C,onKeyDown:B,onCompositionStart:R,onCompositionEnd:w,style:sw,"aria-label":"Message input",spellCheck:false,rows:1})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-1 pb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",role:"toolbar","aria-label":"Input tools",children:[jsxRuntime.jsx(lw,{enabled:p.enabled,onClick:x}),jsxRuntime.jsx(cw,{})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ug,{onTextUpdate:A,onComplete:P,onCancel:k,disabled:o,className:yt.buttonSmall}),jsxRuntime.jsx(dw,{canSend:v,isResponding:o,onSend:S,onStop:t})]})]})]})]})]})})};var hg=({messages:e,onSend:t,onStop:o,onRegenerate:a,isResponding:r=false,className:n,placeholder:i,streamIntervalMs:c,streamChunkSize:d,onMessageStreamingComplete:l,cardHooks:s,showInput:g=true})=>{let f=ht.useRef(null),u=ht.useRef(e.length);return ht.useEffect(()=>{e.length>u.current&&f.current?.scrollIntoView({behavior:"smooth"}),u.current=e.length;},[e]),jsxRuntime.jsxs("div",{className:De("flex flex-col h-full w-full relative",n),children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600",children:[e.map((h,v)=>{let p=h.type==="assistant"&&v===e.length-1,C=h.type==="assistant"?{isLatestAssistant:p,onRegenerate:a?()=>a(h.id):void 0}:void 0;return jsxRuntime.jsx(sl,{message:h,assistantActions:C,onStreamingComplete:()=>l?.(h.id),streamIntervalMs:c,streamChunkSize:d,cardHooks:s},h.id)}),jsxRuntime.jsx("div",{ref:f})]}),g&&jsxRuntime.jsx("div",{className:"p-4 bg-gradient-to-t from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 pb-8 z-10",children:jsxRuntime.jsx(mg,{onSend:t||(async()=>{}),onStop:o||(()=>{}),isResponding:r,placeholder:i})})]})};var ho={};var mw={idle:"Idle",running:"Running",success:"Success",error:"Error",pending:"Pending"},Lz=({title:e="AI Agent",description:t,headerActions:o,className:a,agentStatus:r,showInput:n=false,...i})=>{let c=r??(i.isResponding?"running":"idle");return jsxRuntime.jsxs("div",{className:De("relative flex h-full w-full",ho.agentPanel,a),"data-status":c,children:[jsxRuntime.jsx("div",{className:ho.colorHalo,"data-status":c,"aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:ho.marqueeBorder,"data-status":c,"aria-hidden":"true",children:[jsxRuntime.jsx("span",{className:De(ho.edge,ho.top)}),jsxRuntime.jsx("span",{className:De(ho.edge,ho.right)}),jsxRuntime.jsx("span",{className:De(ho.edge,ho.bottom)}),jsxRuntime.jsx("span",{className:De(ho.edge,ho.left)})]}),jsxRuntime.jsxs("div",{className:"relative z-10 flex h-full w-full flex-col rounded-xl border border-slate-200/70 bg-white shadow-sm overflow-hidden dark:border-slate-800 dark:bg-gray-950",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-gray-800 bg-white/50 dark:bg-gray-900/50 backdrop-blur-sm z-20",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:e}),t&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:t})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-full bg-gray-100/80 dark:bg-gray-800/70",children:[jsxRuntime.jsx("span",{className:ho.statusDot,"data-status":c}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-gray-600 dark:text-gray-300",children:mw[c]})]}),o]})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 relative z-10",children:jsxRuntime.jsx(hg,{...i,showInput:n})})]})]})};var bw={"top-left":"bottom-right","top-right":"bottom-left","bottom-left":"top-right","bottom-right":"top-left"},Gz=({messages:e,onSend:t,onRegenerate:o,isResponding:a=false,className:r,placeholder:n,title:i="Copilot",corner:c="bottom-right",onCollapse:d,onHeaderPointerDown:l,onPlusClick:s,onMicClick:g,streamIntervalMs:f,streamChunkSize:u,onMessageStreamingComplete:h,cardHooks:v})=>{let[p,C]=ht.useState(""),[m,y]=ht.useState(false),x=ht.useRef(null),S=bw[c];ht.useEffect(()=>{x.current?.scrollIntoView({behavior:"smooth"});},[e,a]);let B=ht.useCallback(async()=>{let w=p.trim();!w||a||(C(""),await t(w));},[a,t,p]),R=ht.useCallback(async w=>{w.key==="Enter"&&!m&&(w.preventDefault(),await B());},[B,m]);return jsxRuntime.jsxs("div",{className:De("relative flex h-full w-full min-h-[460px] min-w-[340px] flex-col overflow-hidden rounded-3xl border border-gray-200 bg-white shadow-none dark:border-gray-800 dark:bg-gray-900",r),children:[d&&jsxRuntime.jsx("button",{onClick:d,className:De("absolute z-20 flex h-10 w-10 items-center justify-center rounded-full transition-colors hover:bg-transparent dark:hover:bg-transparent",S==="top-left"&&"-left-2 -top-2",S==="top-right"&&"-right-2 -top-2",S==="bottom-left"&&"-bottom-2 -left-2",S==="bottom-right"&&"-bottom-2 -right-2"),type:"button","aria-label":"Collapse Copilot",children:jsxRuntime.jsx("span",{className:De("block h-4 w-4 border-[#21BCFF]",S==="top-left"&&"rounded-tl-full border-l-[3px] border-t-[3px]",S==="top-right"&&"rounded-tr-full border-r-[3px] border-t-[3px]",S==="bottom-left"&&"rounded-bl-full border-b-[3px] border-l-[3px]",S==="bottom-right"&&"rounded-br-full border-b-[3px] border-r-[3px]")})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 dark:border-gray-800",onPointerDown:l,children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx("h3",{className:"text-base font-semibold tracking-tight text-gray-900 dark:text-gray-100",children:i})}),jsxRuntime.jsx("div",{})]}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-5 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600",children:[e.map((w,A)=>{let P=w.type==="assistant"&&A===e.length-1,k=w.type==="assistant"?{isLatestAssistant:P,onRegenerate:o?()=>o(w.id):void 0}:void 0;return jsxRuntime.jsx(sl,{message:w,assistantActions:k,onStreamingComplete:()=>h?.(w.id),streamIntervalMs:f,streamChunkSize:u,cardHooks:v},w.id)}),jsxRuntime.jsx("div",{ref:x})]}),jsxRuntime.jsx("div",{className:"border-t border-gray-100 px-3 py-3 dark:border-gray-800",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-blue-300/80 bg-white px-2 py-1.5 dark:bg-gray-900",children:[jsxRuntime.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-full text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:s,type:"button","aria-label":"Add",children:jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})}),jsxRuntime.jsx("input",{className:"h-7 flex-1 border-none bg-transparent text-sm text-gray-800 outline-none placeholder:text-gray-400 dark:text-gray-100 dark:placeholder:text-gray-500",placeholder:n||"Ask Copilot...",value:p,onChange:w=>C(w.target.value),onCompositionStart:()=>y(true),onCompositionEnd:()=>y(false),onKeyDown:R,"aria-label":"Copilot input",spellCheck:false}),jsxRuntime.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-full text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:g,type:"button","aria-label":"Microphone",children:jsxRuntime.jsx(lucideReact.Mic,{className:"h-4 w-4"})})]})})]})};var _z=({defaultMode:e="login",onLogin:t,onRegister:o,onForgotPassword:a}={})=>{let[r,n]=ht.useState(e),[i,c]=ht.useState(false),d=ht.useCallback(async u=>{c(true);try{await u?.();}finally{c(false);}},[]),l=ht.useCallback(u=>d(()=>t?.(u)),[t,d]),s=ht.useCallback(u=>d(()=>o?.(u)),[o,d]),g=ht.useCallback(u=>d(()=>a?.(u)),[a,d]),f=ht.useMemo(()=>({mode:r,loading:i,onModeChange:n,onLogin:l,onRegister:s,onForgotPassword:g}),[g,l,s,i,r]);return {mode:r,loading:i,setMode:n,authPageProps:f}};var ad=({label:e,...t})=>jsxRuntime.jsx(material.FormControlLabel,{control:jsxRuntime.jsx(material.Checkbox,{...t}),label:e});var xi=ht.forwardRef((e,t)=>jsxRuntime.jsx(material.Paper,{ref:t,...e,elevation:e.elevation||1,sx:{p:2,mb:2,...e.sx}}));xi.displayName="CPaper";var Aw={productName:"ORBCAFE",headline:"Operational workbench",subheadline:"A focused entry point for reports, planning, agent workflows, and enterprise operations.",loginTitle:"Sign in",loginSubtitle:"Use your workspace account to continue.",registerTitle:"Create account",registerSubtitle:"Request a demo workspace user for evaluation.",forgotTitle:"Reset password",forgotSubtitle:"Send a password reset request to your email address."},mN=({mode:e,defaultMode:t="login",onModeChange:o,onLogin:a,onRegister:r,onForgotPassword:n,loading:i=false,logo:c,copy:d,sx:l})=>{let s=material.useTheme(),g=e!==void 0,[f,u]=ht.useState(t),h=e??f,v=ht.useMemo(()=>({...Aw,...d}),[d]),[p,C]=ht.useState({username:"demo@orbcafe.local",password:"orbcafe-demo",remember:true}),[m,y]=ht.useState({name:"",email:"",password:"",confirmPassword:"",acceptedTerms:false}),[x,S]=ht.useState({email:""}),[B,R]=ht.useState(""),w=I=>{g||u(I),R(""),o?.(I);},A=async I=>{I.preventDefault(),await a?.(p),R("Demo login accepted. No real authentication request was sent.");},P=async I=>{I.preventDefault(),await r?.(m),R("Demo registration saved locally for this screen.");},k=async I=>{I.preventDefault(),await n?.(x),R("Demo reset link request created. No email was sent.");},D=h==="login"?v.loginTitle:h==="register"?v.registerTitle:v.forgotTitle,T=h==="login"?v.loginSubtitle:h==="register"?v.registerSubtitle:v.forgotSubtitle;return jsxRuntime.jsxs(material.Box,{sx:{minHeight:"100vh",display:"grid",gridTemplateColumns:{xs:"1fr",md:"minmax(320px, 0.9fr) minmax(420px, 1.1fr)"},background:s.palette.mode==="dark"?"linear-gradient(135deg, #071018 0%, #151515 48%, #101827 100%)":"linear-gradient(135deg, #eef3f8 0%, #ffffff 52%, #e8f2f0 100%)",...l},children:[jsxRuntime.jsxs(material.Box,{sx:{display:{xs:"none",md:"flex"},flexDirection:"column",justifyContent:"space-between",p:{md:6,lg:8},borderRight:`1px solid ${s.palette.divider}`},children:[jsxRuntime.jsxs(material.Stack,{spacing:4,children:[jsxRuntime.jsx(material.Box,{children:c}),jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:14,fontWeight:700,color:"primary.main",textTransform:"uppercase"},children:v.productName}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:{md:34,lg:42},lineHeight:1.06,fontWeight:800},children:v.headline}),jsxRuntime.jsx(material.Typography,{sx:{maxWidth:460,color:"text.secondary",fontSize:16,lineHeight:1.7},children:v.subheadline})]})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:2,sx:{color:"text.secondary",fontSize:13},children:[jsxRuntime.jsx(material.Typography,{variant:"caption",children:"Reports"}),jsxRuntime.jsx(material.Typography,{variant:"caption",children:"Planning"}),jsxRuntime.jsx(material.Typography,{variant:"caption",children:"Agent UI"})]})]}),jsxRuntime.jsx(material.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:{xs:2,sm:4,md:6}},children:jsxRuntime.jsx(xi,{elevation:0,sx:{width:"100%",maxWidth:460,m:0,p:{xs:2.5,sm:4},borderRadius:3,border:`1px solid ${s.palette.divider}`,backgroundColor:s.palette.mode==="dark"?"rgba(15, 23, 42, 0.86)":"rgba(255, 255, 255, 0.88)",backdropFilter:"blur(18px)",boxShadow:s.palette.mode==="dark"?"0 24px 80px rgba(0,0,0,0.34)":"0 24px 80px rgba(15,23,42,0.10)"},children:jsxRuntime.jsxs(material.Stack,{spacing:3,children:[jsxRuntime.jsxs(material.Stack,{spacing:1,children:[jsxRuntime.jsx(material.Box,{sx:{display:{xs:"block",md:"none"},mb:1},children:c}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:28,fontWeight:800},children:D}),jsxRuntime.jsx(material.Typography,{sx:{color:"text.secondary"},children:T})]}),B&&jsxRuntime.jsx(material.Alert,{severity:"success",children:B}),h==="login"&&jsxRuntime.jsx(material.Box,{component:"form",onSubmit:A,children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(Kt,{label:"Email or user ID",value:p.username,onChange:I=>C(M=>({...M,username:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(kg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Password",type:"password",value:p.password,onChange:I=>C(M=>({...M,password:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Dw__default.default,{fontSize:"small"})})}}),jsxRuntime.jsxs(material.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2},children:[jsxRuntime.jsx(ad,{label:"Remember me",checked:p.remember,onChange:I=>C(M=>({...M,remember:I.target.checked}))}),jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("forgot"),children:"Forgot?"})]}),jsxRuntime.jsx(Mo,{type:"submit",size:"large",disabled:i,children:"Sign in"}),jsxRuntime.jsxs(material.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"center"},children:["New user?"," ",jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("register"),sx:{minWidth:0,p:0},children:"Register"})]})]})}),h==="register"&&jsxRuntime.jsx(material.Box,{component:"form",onSubmit:P,children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(Kt,{label:"Full name",value:m.name,onChange:I=>y(M=>({...M,name:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(kg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Work email",type:"email",value:m.email,onChange:I=>y(M=>({...M,email:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Cg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Password",type:"password",value:m.password,onChange:I=>y(M=>({...M,password:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Mw__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Confirm password",type:"password",value:m.confirmPassword,onChange:I=>y(M=>({...M,confirmPassword:I.target.value}))}),jsxRuntime.jsx(ad,{label:"I accept the demo workspace terms",checked:m.acceptedTerms,onChange:I=>y(M=>({...M,acceptedTerms:I.target.checked}))}),jsxRuntime.jsx(Mo,{type:"submit",size:"large",disabled:i,children:"Create demo account"}),jsxRuntime.jsxs(material.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"center"},children:["Already have an account?"," ",jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("login"),sx:{minWidth:0,p:0},children:"Sign in"})]})]})}),h==="forgot"&&jsxRuntime.jsx(material.Box,{component:"form",onSubmit:k,children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(Kt,{label:"Work email",type:"email",value:x.email,onChange:I=>S({email:I.target.value}),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Cg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Mo,{type:"submit",size:"large",disabled:i,children:"Send reset request"}),jsxRuntime.jsxs(material.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"center"},children:["Remember your password?"," ",jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("login"),sx:{minWidth:0,p:0},children:"Back to sign in"})]})]})}),jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsx(material.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Demo credentials: demo@orbcafe.local / orbcafe-demo"})]})})})]})};var Fw={keyword:{value:"",operator:"contains"},status:{value:"",operator:"equals"},owner:{value:"",operator:"contains"},workCenter:{value:"",operator:"contains"}},Lw=[{id:"keyword",label:"Keyword",type:"text",placeholder:"Task/ID/Project",hasSearchIcon:true},{id:"status",label:"Status",type:"select",options:[{label:"In progress",value:"in-progress"},{label:"Blocked",value:"blocked"},{label:"Planned",value:"planned"},{label:"Not started",value:"not-started"}]},{id:"owner",label:"Owner",type:"text",placeholder:"Owner name"},{id:"workCenter",label:"Work Center",type:"text",placeholder:"CNC-02 / WH-A / ..."},{id:"dateRange",label:"Date Range",type:"date"}],Sg=({tasks:e,defaultScale:t="week",defaultSelectedTaskId:o,initialFilters:a,filterFields:r,filterAppId:n="planning-gantt-filter",filterTableKey:i="planning",onFilterSearch:c,onFilterVariantLoad:d,enableRowReorder:l,onTaskReorder:s})=>{let[g,f]=ht.useState(t),[u,h]=ht.useState(o??e[0]?.id??""),[v,p]=ht.useState({...Fw,...a}),C=ht.useMemo(()=>{let S=String(v.keyword?.value??"").trim().toLowerCase(),B=String(v.status?.value??"").trim(),R=String(v.owner?.value??"").trim().toLowerCase(),w=String(v.workCenter?.value??"").trim().toLowerCase(),A=v.dateRange?.value,P=A?.[0]?_a__default.default(A[0]):null,k=A?.[1]?_a__default.default(A[1]):null;return e.filter(D=>{if(S&&![D.id,D.code,D.title,D.project,D.workCenter,D.owner?.name].join(" ").toLowerCase().includes(S)||B&&D.status!==B||R&&!String(D.owner?.name??"").toLowerCase().includes(R)||w&&!String(D.workCenter??"").toLowerCase().includes(w))return false;if(P||k){let T=_a__default.default(D.startDate),I=_a__default.default(D.endDate),M=P?I.isAfter(P)||I.isSame(P,"day"):true,H=k?T.isBefore(k)||T.isSame(k,"day"):true;if(!M||!H)return false}return true})},[v,e]);ht.useEffect(()=>{C.length!==0&&(C.some(S=>S.id===u)||h(C[0].id));},[C,u]);let m=ht.useCallback(S=>{h(S.id);},[]),y=ht.useMemo(()=>({appId:n,tableKey:i,fields:r??Lw,filters:v,onFilterChange:p,onVariantLoad:d??(()=>{}),onSearch:c??(()=>{})}),[n,r,i,v,c,d]),x=ht.useMemo(()=>({tasks:C,scale:g,onScaleChange:f,selectedTaskId:u,onTaskSelect:m,enableRowReorder:l,onTaskReorder:s}),[l,C,s,m,g,u]);return {scale:g,setScale:f,selectedTaskId:u,setSelectedTaskId:h,filters:v,setFilters:p,filteredTasks:C,smartFilterProps:y,planningGanttProps:x}};var CN=e=>{let t=Sg(e),o=ht.useMemo(()=>({filterProps:t.smartFilterProps,ganttProps:t.planningGanttProps}),[t.planningGanttProps,t.smartFilterProps]);return {...t,layoutProps:o}};var wg=e=>jsxRuntime.jsx(material.Chip,{...e,size:e.size||"small",variant:e.variant||"outlined"});var Ka=ht.forwardRef(({tooltip:e,...t},o)=>{let a=jsxRuntime.jsx(material.IconButton,{ref:o,...t,size:t.size||"small"});return e?jsxRuntime.jsx(material.Tooltip,{title:e,children:a}):a});Ka.displayName="CIconButton";var Ig=({label:e,options:t,minWidth:o=120,...a})=>jsxRuntime.jsxs(material.FormControl,{fullWidth:true,size:"small",sx:{minWidth:o},children:[e&&jsxRuntime.jsx(material.InputLabel,{children:e}),jsxRuntime.jsx(material.Select,{label:e,...a,children:t.map(r=>jsxRuntime.jsx(material.MenuItem,{value:r.value,children:r.label},r.value))})]});var sd=[{value:"hour",label:"Hour",width:56},{value:"day",label:"Day",width:46},{value:"week",label:"Week",width:78},{value:"month",label:"Month",width:104}],ld=56,Pr=58,cd=8,dd=260,d1=320,ja="220ms cubic-bezier(0.2, 0, 0, 1)",Mg={"not-started":{label:"Not started",color:"default"},planned:{label:"Planned",color:"info"},"in-progress":{label:"In progress",color:"primary"},blocked:{label:"Blocked",color:"error"},done:{label:"Done",color:"success"}},p1=e=>e?Mg[e]?.label??e:"Planned",u1=e=>e?Mg[e]?.color??"default":"info",Ag=e=>Math.min(100,Math.max(0,e??0)),Bg=(e,t=0)=>e.flatMap(o=>[{...o,level:t},...Bg(o.children??[],t+1)]),m1=e=>({id:e.id,code:e.code??e.id,title:e.title,titleSub:e.project??e.workCenter??"General",owner:e.owner?.name??"Unassigned",status:p1(e.status),statusTone:e.status??"planned",progress:Ag(e.progress),startDate:e.startDate,endDate:e.endDate,color:e.color,reorderable:e.reorderable!==false}),Eg=(e,t)=>t==="month"?e.startOf("month"):t==="week"?e.startOf("week"):t==="day"?e.startOf("day"):e.startOf("hour"),Fg=(e,t)=>t==="month"?e.endOf("month"):t==="week"?e.endOf("week"):t==="day"?e.endOf("day"):e.endOf("hour"),g1=(e,t,o)=>{let a=[],r=Eg(e,o),n=Fg(t,o);for(;r.isBefore(n)||r.isSame(n);){let i=o==="month"?r.add(1,"month"):o==="week"?r.add(1,"week"):o==="day"?r.add(1,"day"):r.add(1,"hour");a.push({key:`${o}-${r.valueOf()}`,label:o==="month"?r.format("MMM YYYY"):o==="week"?r.format("MMM D"):o==="day"?r.format("D"):r.format("HH:mm"),start:r,end:i}),r=i;}return a},Dg=(e,t,o)=>{let a=0;for(let r of t){if(e.isBefore(r.start))return a;if(e.isBefore(r.end)){let n=Math.max(1,r.end.valueOf()-r.start.valueOf()),i=Math.max(0,e.valueOf()-r.start.valueOf());return a+i/n*o}a+=o;}return a},Lg=({title:e="Project Plan",subtitle:t="Task table and timeline view",extraTools:o,bodyHeight:a=560,tasks:r,scale:n="week",onScaleChange:i,timelineStart:c,timelineEnd:d,selectedTaskId:l,onTaskSelect:s,enableRowReorder:g=true,onTaskReorder:f,emptyLabel:u="No planning tasks available.",sx:h})=>{let v=material.useTheme(),p=ht.useRef(null),C=ht.useRef(null),m=ht.useRef(null),y=ht.useRef(false),[x,S]=ht.useState(null),[B,R]=ht.useState(null),[w,A]=ht.useState({}),[P,k]=ht.useState(ld),[D,T]=ht.useState([]),[I,M]=ht.useState({activeId:null,overId:null}),H=ht.useRef(null),V=ht.useMemo(()=>Bg(r),[r]),J=ht.useMemo(()=>{if(D.length===0)return V;let L=new Map(V.map(_=>[_.id,_])),$=D.map(_=>L.get(_)).filter(_=>!!_),j=new Set($.map(_=>_.id));return [...$,...V.filter(_=>!j.has(_.id))]},[V,D]),ce=ht.useMemo(()=>new Map(J.map(L=>[L.id,L])),[J]),te=ht.useMemo(()=>J.map(L=>m1(L)),[J]),ne=ht.useMemo(()=>new Map(te.map(L=>[L.id,L])),[te]),ee=ht.useMemo(()=>[{id:"code",label:"ID",minWidth:90},{id:"title",label:"Task",minWidth:260,render:(L,$)=>jsxRuntime.jsxs(material.Stack,{spacing:.2,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:15,fontWeight:700,lineHeight:1.2},children:$.title}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:13,color:"text.secondary"},children:$.titleSub})]})},{id:"owner",label:"Owner",minWidth:170},{id:"status",label:"Status",minWidth:130,render:(L,$)=>jsxRuntime.jsx(wg,{label:$.status,color:u1($.statusTone),size:"small"})},{id:"progress",label:"Progress",minWidth:140,numeric:true,render:L=>jsxRuntime.jsxs(material.Stack,{spacing:.6,children:[jsxRuntime.jsxs(material.Typography,{variant:"caption",sx:{color:"text.secondary"},children:[L,"%"]}),jsxRuntime.jsx(material.LinearProgress,{variant:"determinate",value:L,sx:{height:6,borderRadius:999}})]})},{id:"startDate",label:"Start",minWidth:120},{id:"endDate",label:"End",minWidth:120}],[]),Y=Yr({appId:"planning-gantt",title:e,columns:ee,rows:te,rowKey:"id",rowsPerPage:-1,rowsPerPageOptions:[-1],count:te.length,showSummary:false}),Ze=Y.visibleRows;ht.useEffect(()=>{let L=V.map($=>$.id);T($=>{let j=new Set(L),_=$.filter(z=>j.has(z)),ke=new Set(_),Ee=L.filter(z=>!ke.has(z)),Ye=[..._,...Ee];return Ye.length===$.length&&Ye.every((z,W)=>z===$[W])?$:Ye});},[V]);let Ue=L=>L.type==="group"?`group-${L.id}`:`row-${(L.data||L)?.id}`,ie=ht.useMemo(()=>{let L=te.map(W=>_a__default.default(W.startDate)),$=te.map(W=>_a__default.default(W.endDate)),j=c?_a__default.default(c):L.reduce((W,G)=>G.isBefore(W)?G:W,L[0]??_a__default.default()),_=d?_a__default.default(d):$.reduce((W,G)=>G.isAfter(W)?G:W,$[0]??_a__default.default().add(30,"day")),ke=n==="month"?"month":n==="week"?"week":n==="day"?"day":"hour",Ee=n==="month"?"month":n==="week"?"week":n==="day"?"day":"hour",Ye=n==="hour"?12:1,z=n==="hour"?12:1;return {start:Eg(j.subtract(Ye,ke),n),end:Fg(_.add(z,Ee),n)}},[te,n,d,c]),Ie=sd.find(L=>L.value===n)??sd[1],Fe=Array.isArray(o)?o:o?[o]:[],Oe=ht.useMemo(()=>g1(ie.start,ie.end,n),[ie.end,ie.start,n]),nt=Oe.length*Ie.width,Le=(Y.columns||[]).filter(L=>Y.visibleColumns.includes(L.id)).reduce((L,$)=>L+(Y.columnWidths?.[$.id]||$.minWidth||100),0),Xe=x??Le,Zt=B==="table",zt=B==="timeline",Qe=zt?0:Zt?"100%":Xe,lt=B==="timeline",mt=B==="table",_e=!lt&&!mt,K=Zt?"minmax(0, 1fr) 0px 0px":zt?"0px 0px minmax(0, 1fr)":`${Xe}px ${cd}px minmax(0, 1fr)`;ht.useEffect(()=>{S(L=>L===null?null:Math.min(Math.max(L,dd),Le));},[Le]);let Ce=L=>{L.preventDefault(),L.currentTarget.setPointerCapture(L.pointerId),R(null),H.current={startX:L.clientX,startWidth:Xe};let $=_=>{let ke=H.current;if(!ke)return;let Ee=p.current?.clientWidth??0,Ye=Ee>0?Math.max(dd,Ee-cd-d1):Le,z=Math.min(Math.max(ke.startWidth+_.clientX-ke.startX,dd),Ye);S(z);},j=()=>{H.current=null,window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",j),document.body.style.cursor="",document.body.style.userSelect="";};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",$),window.addEventListener("pointerup",j);},fe=()=>{R(null),S(null);},be=L=>!g||!L?false:ne.get(L)?.reorderable!==false,Ne=(L,$)=>{if(!L||!$||L===$||!be(L)||!be($))return false;if(Y.grouping.length===0)return true;let j=ne.get(L),_=ne.get($);return !j||!_?false:Y.grouping.every(ke=>j[ke]===_[ke])},Ve=(L,$)=>{if(!Ne(L,$))return;let j=Ze.filter(oe=>oe.type!=="group").map(oe=>String((oe.data||oe)?.id)),_=j.indexOf(L),ke=j.indexOf($);if(_<0||ke<0)return;let Ee=[...j];[Ee[_],Ee[ke]]=[Ee[ke],Ee[_]];let Ye=new Set(j),z=J.map(oe=>oe.id),W=[...Ee,...z.filter(oe=>!Ye.has(oe))],G=ce.get(L),ue=ce.get($);if(Y.setOrder("asc"),Y.setOrderBy(""),T(W),G&&ue){let{level:oe,...Se}=G,{level:ge,...Pe}=ue,he=W.reduce((ze,Be)=>{let we=ce.get(Be);if(we){let{level:Me,...Tt}=we;ze.push(Tt);}return ze},[]);f?.(he,{activeTask:Se,targetTask:Pe});}},Ht=(L,$)=>{if(!be($.id)){L.preventDefault();return}L.stopPropagation(),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",$.id),M({activeId:$.id,overId:null}),s?.(ce.get($.id)||$);},Nt=(L,$)=>{if(!Ne(I.activeId,$)){M(j=>j.overId===null?j:{...j,overId:null});return}L.preventDefault(),L.stopPropagation(),L.dataTransfer.dropEffect="move",M(j=>j.overId===$?j:{...j,overId:$});},Xt=(L,$)=>{let j=I.activeId||L.dataTransfer.getData("text/plain");if(!Ne(j,$)){M({activeId:null,overId:null});return}L.preventDefault(),L.stopPropagation(),Ve(j,$),M({activeId:null,overId:null});},Qt=()=>{M({activeId:null,overId:null});},Yt=L=>{if(y.current)return;let $=L==="table"?C.current:m.current,j=L==="table"?m.current:C.current;!$||!j||(y.current=true,j.scrollTop=$.scrollTop,window.requestAnimationFrame(()=>{y.current=false;}));};return ht.useLayoutEffect(()=>{let L=C.current;if(!L)return;let $=0,j=()=>{let z=L.querySelector("thead"),W=Array.from(L.querySelectorAll("tbody tr[data-planning-row-key]"));if(W.length===0)return;let G=z?.getBoundingClientRect().height||ld,ue={};W.forEach(oe=>{let Se=oe.dataset.planningRowKey;Se&&(ue[Se]=oe.getBoundingClientRect().height);}),k(oe=>Math.abs(oe-G)<.01?oe:G),A(oe=>{let Se=Object.keys(oe),ge=Object.keys(ue);return Se.length===ge.length&&ge.every(Pe=>Math.abs((oe[Pe]??0)-ue[Pe])<.01)?oe:ue});},_=()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(j);};if(j(),typeof ResizeObserver>"u")return window.addEventListener("resize",_),()=>{window.cancelAnimationFrame($),window.removeEventListener("resize",_);};let ke=new ResizeObserver(_),Ee=L.querySelector("table"),Ye=L.querySelector("thead");return Ee&&ke.observe(Ee),Ye&&ke.observe(Ye),L.querySelectorAll("tbody tr[data-planning-row-key]").forEach(z=>ke.observe(z)),window.addEventListener("resize",_),()=>{window.cancelAnimationFrame($),ke.disconnect(),window.removeEventListener("resize",_);}},[Ze,Y.visibleColumns,Y.grouping,Y.columnWidths]),jsxRuntime.jsxs(xi,{elevation:0,sx:{m:0,p:0,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",borderRadius:3,border:`1px solid ${v.palette.divider}`,backgroundColor:v.palette.background.paper,...h},children:[jsxRuntime.jsxs(material.Stack,{direction:{xs:"column",md:"row"},justifyContent:"space-between",alignItems:{xs:"stretch",md:"center"},spacing:2,sx:{px:2,py:1.75,borderBottom:`1px solid ${v.palette.divider}`},children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[jsxRuntime.jsx(material.Box,{sx:{width:38,height:38,borderRadius:2,display:"grid",placeItems:"center",backgroundColor:"primary.main",color:"primary.contrastText"},children:jsxRuntime.jsx(t1__default.default,{fontSize:"small"})}),jsxRuntime.jsxs(material.Box,{children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:18,fontWeight:800},children:e}),jsxRuntime.jsx(material.Typography,{variant:"body2",sx:{color:"text.secondary"},children:t})]})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{flexWrap:"wrap"},children:[Fe.length>0&&jsxRuntime.jsx(material.Stack,{direction:"row",spacing:.75,alignItems:"center",children:Fe.map((L,$)=>jsxRuntime.jsx(material.Box,{sx:{display:"flex",alignItems:"center"},children:L},`planning-extra-tool-${$}`))}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:.25,sx:{p:.5,borderRadius:2,backgroundColor:"action.hover"},children:[jsxRuntime.jsx(Ka,{tooltip:"Column visibility",onClick:L=>Y.setAnchorEl(L.currentTarget),color:"default",children:jsxRuntime.jsx(zf__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Group by",onClick:L=>Y.setGroupAnchorEl(L.currentTarget),color:"default",children:jsxRuntime.jsx(Of__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Sort by first visible column",onClick:()=>{let L=(Y.columns||[]).find($=>Y.visibleColumns.includes($.id));L&&Y.handleRequestSort(L.id);},color:Y.orderBy?"primary":"default",children:jsxRuntime.jsx(l1__default.default,{fontSize:"small"})})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:.25,sx:{p:.5,borderRadius:2,backgroundColor:"action.hover"},children:[jsxRuntime.jsx(Ka,{tooltip:"Expand task table",onClick:()=>R("table"),color:B==="table"?"primary":"default",children:jsxRuntime.jsx(i1__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Reset split",onClick:fe,color:B===null?"primary":"default",children:jsxRuntime.jsx(s1__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Expand timeline",onClick:()=>R("timeline"),color:B==="timeline"?"primary":"default",children:jsxRuntime.jsx(n1__default.default,{fontSize:"small"})})]}),jsxRuntime.jsx(material.Box,{sx:{minWidth:120},children:jsxRuntime.jsx(Ig,{label:"",value:n,options:sd.map(L=>({value:L.value,label:L.label})),onChange:L=>i?.(L.target.value),sx:{"& .MuiSelect-select":{fontSize:"0.92rem",py:.65},"& .MuiSvgIcon-root":{fontSize:20}}})})]})]}),te.length===0?jsxRuntime.jsx(material.Box,{sx:{minHeight:240,display:"grid",placeItems:"center",color:"text.secondary"},children:u}):jsxRuntime.jsx(material.Box,{sx:{overflow:"hidden",flex:1,minHeight:0},children:jsxRuntime.jsxs(material.Box,{ref:p,sx:{height:"100%",display:"grid",gridTemplateColumns:K,transition:`grid-template-columns ${ja}`},children:[jsxRuntime.jsx(material.TableContainer,{"data-planning-scroll-pane":"table",ref:C,onScroll:()=>Yt("table"),sx:{width:Qe,height:a,overflowX:"auto",overflowY:"auto",opacity:lt?0:1,transform:lt?"translateX(-10px)":"translateX(0)",pointerEvents:lt?"none":"auto",transition:`opacity ${ja}, transform ${ja}, width ${ja}`},children:jsxRuntime.jsxs(material.Table,{size:"small",stickyHeader:true,sx:{tableLayout:"fixed",width:Le,"& thead .MuiTableCell-root":{height:ld,py:0,lineHeight:1.15,boxSizing:"border-box"}},children:[jsxRuntime.jsx(Ti,{columns:Y.columns,visibleColumns:Y.visibleColumns,order:Y.order,orderBy:Y.orderBy,onRequestSort:Y.handleRequestSort,grouping:Y.grouping,isAllExpanded:Y.isAllExpanded,handleToggleAll:Y.handleToggleAll,columnWidths:Y.columnWidths,onColumnResize:Y.handleColumnResize}),jsxRuntime.jsx(material.TableBody,{children:Ze.map(L=>{let $=Ue(L);if(L.type==="group")return jsxRuntime.jsxs(material.TableRow,{"data-planning-row-key":$,sx:{height:Pr,backgroundColor:v.palette.action.hover},children:[Y.grouping.length>0&&jsxRuntime.jsx(material.TableCell,{sx:{width:44,height:Pr,py:0,borderBottom:`1px solid ${v.palette.divider}`},children:jsxRuntime.jsx(material.IconButton,{size:"small",onClick:()=>Y.toggleGroupExpand(L.id),children:L.isExpanded?jsxRuntime.jsx(ch__default.default,{fontSize:"small"}):jsxRuntime.jsx(qf__default.default,{fontSize:"small"})})}),jsxRuntime.jsx(material.TableCell,{colSpan:Y.visibleColumns.length,sx:{height:Pr,py:0,borderBottom:`1px solid ${v.palette.divider}`},children:jsxRuntime.jsxs(material.Typography,{sx:{fontSize:13,fontWeight:700},children:[L.field,": ",L.value," (",L.count,")"]})})]},L.id);let j=L.data||L,_=j.id===l,ke=be(j.id),Ee=I.activeId===j.id,Ye=I.overId===j.id&&Ne(I.activeId,j.id);return jsxRuntime.jsxs(material.TableRow,{"data-planning-row-key":$,draggable:ke,hover:true,selected:_,onDragStart:z=>Ht(z,j),onDragOver:z=>Nt(z,j.id),onDragEnter:z=>Nt(z,j.id),onDrop:z=>Xt(z,j.id),onDragEnd:Qt,onClick:()=>s?.(ce.get(j.id)||j),sx:{cursor:Ee?"grabbing":ke?"grab":s?"pointer":"default",height:Pr,opacity:Ee?.56:1,boxShadow:Ye?`inset 0 0 0 2px ${v.palette.primary.main}`:"none",transition:"background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease"},children:[Y.grouping.length>0&&jsxRuntime.jsx(material.TableCell,{sx:{width:44,height:Pr,py:0,borderBottom:`1px solid ${v.palette.divider}`}}),(Y.columns||[]).filter(z=>Y.visibleColumns.includes(z.id)).map(z=>jsxRuntime.jsx(material.TableCell,{sx:{width:Y.columnWidths?.[z.id]||z.minWidth||100,height:Pr,py:0,overflow:"hidden",borderBottom:`1px solid ${v.palette.divider}`},children:z.render?z.render(j[z.id],j):String(j[z.id]??"-")},`${j.id}-${z.id}`))]},j.id)})})]})}),jsxRuntime.jsx(material.Box,{onPointerDown:_e?Ce:void 0,role:"separator","aria-orientation":"vertical",sx:{width:_e?cd:0,cursor:_e?"col-resize":"default",opacity:_e?1:0,pointerEvents:_e?"auto":"none",borderLeft:_e?`1px solid ${v.palette.divider}`:"0 solid transparent",borderRight:_e?`1px solid ${v.palette.divider}`:"0 solid transparent",backgroundColor:v.palette.mode==="dark"?"rgba(148,163,184,0.10)":"rgba(15,23,42,0.04)",transition:`width ${ja}, opacity ${ja}, background-color 120ms ease`,position:"relative","&:hover":{backgroundColor:v.palette.action.selected},"&::before":{content:'""',position:"absolute",top:0,bottom:0,left:-6,right:-6,cursor:_e?"col-resize":"default"}}}),jsxRuntime.jsx(material.Box,{sx:{minWidth:0,overflow:"hidden",opacity:mt?0:1,transform:mt?"translateX(10px)":"translateX(0)",pointerEvents:mt?"none":"auto",transition:`opacity ${ja}, transform ${ja}`},children:jsxRuntime.jsx(material.Box,{"data-planning-scroll-pane":"timeline",ref:m,onScroll:()=>Yt("timeline"),sx:{width:"100%",height:a,overflowX:"auto",overflowY:"auto"},children:jsxRuntime.jsxs(material.Box,{sx:{width:nt},children:[jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:`repeat(${Oe.length}, ${Ie.width}px)`,height:P,boxSizing:"border-box",borderBottom:`1px solid ${v.palette.divider}`,position:"sticky",top:0,zIndex:2,backgroundColor:v.palette.background.paper},children:Oe.map(L=>jsxRuntime.jsx(material.Box,{sx:{px:.75,display:"flex",alignItems:"center",borderRight:`1px solid ${v.palette.divider}`,color:"text.secondary",fontSize:12,fontWeight:700},children:L.label},L.key))}),jsxRuntime.jsx(material.Stack,{sx:{position:"relative"},children:Ze.map(L=>{let $=Ue(L),j=w[$]??Pr;if(L.type==="group")return jsxRuntime.jsx(material.Box,{"data-planning-timeline-row-key":$,sx:{position:"relative",height:j,boxSizing:"border-box",borderBottom:`1px solid ${v.palette.divider}`,backgroundColor:v.palette.action.hover}},L.id);let _=L.data||L,ke=_a__default.default(_.startDate),Ee=_a__default.default(_.endDate),Ye=Dg(ke,Oe,Ie.width),z=Dg(Ee,Oe,Ie.width),W=Math.max(18,z-Ye),G=Ag(_.progress),ue=_.id===l,oe=be(_.id),Se=I.activeId===_.id,ge=I.overId===_.id&&Ne(I.activeId,_.id),Pe=_.color??(_.statusTone==="blocked"?v.palette.error.main:v.palette.primary.main);return jsxRuntime.jsx(material.Box,{"data-planning-timeline-row-key":$,draggable:oe,onDragStart:he=>Ht(he,_),onDragOver:he=>Nt(he,_.id),onDragEnter:he=>Nt(he,_.id),onDrop:he=>Xt(he,_.id),onDragEnd:Qt,onClick:()=>s?.(ce.get(_.id)||_),sx:{position:"relative",height:j,boxSizing:"border-box",borderBottom:`1px solid ${v.palette.divider}`,opacity:Se?.56:1,boxShadow:ge?`inset 0 0 0 2px ${v.palette.primary.main}`:"none",backgroundImage:v.palette.mode==="dark"?"linear-gradient(90deg, rgba(148,163,184,0.08) 1px, transparent 1px)":"linear-gradient(90deg, rgba(15,23,42,0.06) 1px, transparent 1px)",backgroundSize:`${Ie.width}px 100%`,cursor:Se?"grabbing":oe?"grab":s?"pointer":"default",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:jsxRuntime.jsx(material.Tooltip,{title:`${_.title}: ${ke.format("MMM D HH:mm")} - ${Ee.format("MMM D HH:mm")}`,children:jsxRuntime.jsxs(material.Box,{sx:{position:"absolute",left:Ye,top:Math.max(8,(j-24)/2),width:W,height:24,borderRadius:999,overflow:"hidden",backgroundColor:v.palette.mode==="dark"?"rgba(148,163,184,0.18)":"rgba(15,23,42,0.10)",outline:ue?`2px solid ${v.palette.warning.main}`:"none",outlineOffset:2},children:[jsxRuntime.jsx(material.Box,{sx:{height:"100%",width:`${G}%`,backgroundColor:Pe}}),jsxRuntime.jsx(material.Typography,{sx:{position:"absolute",inset:0,px:1,display:"flex",alignItems:"center",color:"#fff",fontSize:11,fontWeight:800,textShadow:"0 1px 4px rgba(0,0,0,0.45)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.code})]})})},_.id)})})]})})})]})}),jsxRuntime.jsx(Nr,{groupAnchorEl:Y.groupAnchorEl,setGroupAnchorEl:Y.setGroupAnchorEl,grouping:Y.grouping,setGrouping:Y.setGrouping,columns:Y.columns,toggleGroupField:Y.toggleGroupField}),jsxRuntime.jsx(Vr,{anchorEl:Y.anchorEl,setAnchorEl:Y.setAnchorEl,columns:Y.columns,visibleColumns:Y.visibleColumns,toggleColumnVisibility:Y.toggleColumnVisibility})]})};var rV=({filterProps:e,ganttProps:t,spacing:o=2,sx:a,children:r})=>{let n=a?[{height:"100%",overflow:"hidden"},a]:{height:"100%",overflow:"hidden"},i=t.sx?[{height:"100%"},t.sx]:{height:"100%"};return jsxRuntime.jsxs(material.Stack,{spacing:o,sx:n,children:[jsxRuntime.jsx(material.Box,{sx:{flexShrink:0},children:jsxRuntime.jsx(ca,{...e})}),jsxRuntime.jsx(material.Box,{sx:{flex:1,minHeight:0,overflow:"hidden"},children:jsxRuntime.jsx(Lg,{...t,bodyHeight:t.bodyHeight??"100%",sx:i})}),r]})};var k1={none:{from:{},to:{}},fade:{from:{opacity:0},to:{opacity:1}},"slide-up":{from:{opacity:0,transform:"translate3d(0, 12px, 0)"},to:{opacity:1,transform:"translate3d(0, 0, 0)"}},"slide-left":{from:{opacity:0,transform:"translate3d(12px, 0, 0)"},to:{opacity:1,transform:"translate3d(0, 0, 0)"}},scale:{from:{opacity:0,transform:"scale(0.985)"},to:{opacity:1,transform:"scale(1)"}}},cV=({children:e,transitionKey:t,variant:o="fade",durationMs:a=220,delayMs:r=0,easing:n="cubic-bezier(0.22, 1, 0.36, 1)",disabled:i=false,sx:c})=>{let d=material.useMediaQuery("(prefers-reduced-motion: reduce)"),[l,s]=ht.useState("to"),g=!i&&!d&&o!=="none";ht.useEffect(()=>{if(!g){s("to");return}s("from");let h=requestAnimationFrame(()=>{h=requestAnimationFrame(()=>{s("to");});});return ()=>cancelAnimationFrame(h)},[t,g]);let f=k1[o],u=ht.useMemo(()=>g?l==="from"?f.from:f.to:{opacity:1,transform:"none"},[g,l,f.from,f.to]);return jsxRuntime.jsx(material.Box,{sx:{willChange:g?"opacity, transform":"auto",transition:g?`opacity ${a}ms ${n} ${r}ms, transform ${a}ms ${n} ${r}ms`:"none",backfaceVisibility:"hidden",...u,...c},children:e})},dV={subtle:{variant:"fade",durationMs:180},smooth:{variant:"slide-up",durationMs:220},snappy:{variant:"scale",durationMs:160}};
198
+ `,a,": ",(n??r)(m.item.secondaryValue??0)]})},`secondary-${m.item.name}`))]})]})}),jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))",xl:"repeat(4, minmax(0, 1fr))"},gap:1},children:e.map(m=>jsxRuntime.jsxs(material.Box,{sx:y=>({borderRadius:2,px:1.1,py:.9,border:`1px solid ${styles.alpha(y.palette.divider,.7)}`,bgcolor:styles.alpha(y.palette.background.default,.35)}),children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.76rem",fontWeight:700},noWrap:true,title:m.name,children:m.name}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.71rem",color:"text.secondary"},children:r(m.primaryValue)}),a&&jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.71rem",color:"text.secondary"},children:(n??r)(m.secondaryValue??0)})]},m.name))})]})};var qu=(e,t,o)=>{let a=new Set,r=[];return e.forEach(n=>{a.has(n)||(a.add(n),r.push({fieldId:n,label:o.get(n)?.label??n,zone:"rows"}));}),t.forEach(n=>{a.has(n)||(a.add(n),r.push({fieldId:n,label:o.get(n)?.label??n,zone:"columns"}));}),r},_u=(e,t,o)=>e.map(a=>{let r=t.get(a.fieldId),n=r?.label??a.fieldId;return {fieldId:a.fieldId,label:`${o(a.aggregation)} \xB7 ${n}`,item:a,field:r}}),ju=({rows:e,dimensionFieldId:t,primaryValue:o,secondaryValue:a})=>{if(!t)return [];let r=new Map;return e.forEach(n=>{let i=ga(n[t]),c=r.get(i);if(c){c.push(n);return}r.set(i,[n]);}),Array.from(r.entries()).sort((n,i)=>n[0].localeCompare(i[0],void 0,{sensitivity:"base"})).map(([n,i])=>({name:n,primaryValue:on(i,o.fieldId,o.aggregation),secondaryValue:a?on(i,a.fieldId,a.aggregation):void 0}))};var Zu=({rows:e,fieldMap:t,rowFields:o,columnFields:a,valueFields:r,chartDimensionFieldId:n,chartPrimaryValueFieldId:i,chartSecondaryValueFieldId:c,chartType:d,isCollapsed:l,onChartDimensionFieldIdChange:s,onChartPrimaryValueFieldIdChange:g,onChartSecondaryValueFieldIdChange:f,onChartTypeChange:u,onToggleCollapse:h,getAggregationLabel:v})=>{let{t:p}=Q(),C=ht.useMemo(()=>qu(o,a,t),[a,t,o]),m=ht.useMemo(()=>_u(r,t,v),[t,v,r]),y=m.find(k=>k.fieldId===i)??m[0],x=m.find(k=>k.fieldId===c&&k.fieldId!==y?.fieldId)??null,S=C.find(k=>k.fieldId===n)??C[0],B=S&&y?p("pivot.chart.subtitleReady",{dimension:S.label,measure:x?`${y.label} / ${x.label}`:y.label}):p("pivot.chart.subtitle"),R=ht.useMemo(()=>!S||!y?[]:ju({rows:e,dimensionFieldId:S.fieldId,primaryValue:y.item,secondaryValue:x?.item}),[y,e,x,S]),w=k=>y?ai(k,y.item,t):k.toLocaleString(),A=k=>x?ai(k,x.item,t):k.toLocaleString(),P=C.length>1||m.length>1;return jsxRuntime.jsxs(ln,{title:p("pivot.chart.title"),subtitle:B,collapsed:l,onToggleCollapse:h,expandAriaLabel:p("pivot.chart.collapse.ariaExpand"),collapseAriaLabel:p("pivot.chart.collapse.ariaCollapse"),bodySx:{display:"flex",flexDirection:"column",gap:1.1},children:[P&&jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))",xl:"repeat(4, minmax(0, 1fr))"},gap:1,alignItems:"start"},children:[jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.dimension")}),jsxRuntime.jsx(material.Select,{value:S?.fieldId??"",onChange:k=>s(String(k.target.value)),sx:{fontSize:"0.75rem",height:32},children:C.map(k=>jsxRuntime.jsx(material.MenuItem,{value:k.fieldId,sx:{fontSize:"0.75rem"},children:k.label},k.fieldId))})]}),jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.primaryMeasure")}),jsxRuntime.jsx(material.Select,{value:y?.fieldId??"",onChange:k=>g(String(k.target.value)),sx:{fontSize:"0.75rem",height:32},children:m.map(k=>jsxRuntime.jsx(material.MenuItem,{value:k.fieldId,sx:{fontSize:"0.75rem"},children:k.label},k.fieldId))})]}),jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.secondaryMeasure")}),jsxRuntime.jsxs(material.Select,{value:x?.fieldId??"",onChange:k=>f(String(k.target.value)),sx:{fontSize:"0.75rem",height:32},children:[jsxRuntime.jsx(material.MenuItem,{value:"",sx:{fontSize:"0.75rem",color:"text.secondary"},children:p("common.none")}),m.filter(k=>k.fieldId!==y?.fieldId).map(k=>jsxRuntime.jsx(material.MenuItem,{value:k.fieldId,sx:{fontSize:"0.75rem"},children:k.label},k.fieldId))]})]}),jsxRuntime.jsxs(material.FormControl,{size:"small",sx:{minWidth:0,width:"100%"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.68rem",color:"text.secondary",mb:.45},children:p("pivot.chart.chartType")}),jsxRuntime.jsxs(material.Select,{value:d,onChange:k=>u(k.target.value),sx:{fontSize:"0.75rem",height:32},children:[jsxRuntime.jsx(material.MenuItem,{value:"bar-vertical",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.barVertical")}),jsxRuntime.jsx(material.MenuItem,{value:"bar-horizontal",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.barHorizontal")}),jsxRuntime.jsx(material.MenuItem,{value:"line",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.line")}),jsxRuntime.jsx(material.MenuItem,{value:"scatter",sx:{fontSize:"0.75rem"},children:p("pivot.chart.style.scatter")})]})]})]}),jsxRuntime.jsx(material.Box,{children:S?y?R.length===0?jsxRuntime.jsx(material.Box,{sx:{py:5,textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:p("pivot.chart.emptyNoData")})}):d==="scatter"?jsxRuntime.jsx(Gu,{data:R,primaryLabel:y.label,secondaryLabel:x?.label,formatPrimaryValue:w,formatSecondaryValue:A}):jsxRuntime.jsx(Ku,{data:R,chartType:d,primaryLabel:y.label,secondaryLabel:x?.label,formatPrimaryValue:w,formatSecondaryValue:A}):jsxRuntime.jsx(material.Box,{sx:{py:5,textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:p("pivot.chart.emptyNoValue")})}):jsxRuntime.jsx(material.Box,{sx:{py:5,textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:p("pivot.chart.emptyNoDimension")})})})]})};var Os=({node:e,dataColumns:t,fieldMap:o,level:a,expandedKeys:r,onToggle:n,getValue:i})=>{let c=r.has(e.key),d=e.children.length>0,l=e.isGrandTotal;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(material.TableRow,{sx:s=>({bgcolor:l?s.palette.mode==="dark"?"rgba(25, 118, 210, 0.22)":"rgba(47, 91, 255, 0.08)":s.palette.mode==="dark"?"#111111":"background.paper","&:hover":{bgcolor:l?s.palette.mode==="dark"?"rgba(25, 118, 210, 0.28)":"rgba(47, 91, 255, 0.12)":s.palette.mode==="dark"?"#181818":"rgba(0, 0, 0, 0.02)"}}),children:[jsxRuntime.jsxs(material.TableCell,{sx:s=>({fontSize:"0.76rem",fontWeight:l?800:600,borderBottom:`1px solid ${s.palette.divider}`,whiteSpace:"nowrap",pl:a*2+1,display:"flex",alignItems:"center",height:40}),children:[d&&!l&&jsxRuntime.jsx(material.IconButton,{size:"small",onClick:()=>n(e.key),sx:{p:.2,mr:.5,ml:-1},children:c?jsxRuntime.jsx(ch__default.default,{sx:{fontSize:16}}):jsxRuntime.jsx(qf__default.default,{sx:{fontSize:16}})}),!d&&!l&&a>0&&jsxRuntime.jsx(material.Box,{sx:{width:20}}),e.value]}),t.map(s=>jsxRuntime.jsx(material.TableCell,{align:"right",sx:{fontSize:"0.76rem",fontWeight:l?800:500,borderBottom:g=>`1px solid ${g.palette.divider}`,whiteSpace:"nowrap"},children:ai(i?i(e,s.id):e.aggregatedValues[s.id]??0,s.valueItem,o)},`${e.key}-${s.id}`))]}),c&&e.children.map(s=>jsxRuntime.jsx(Os,{node:s,dataColumns:t,fieldMap:o,level:a+1,expandedKeys:r,onToggle:n,getValue:i},s.key))]})};var Ec=(e,t,o)=>{let a=[...e,...t];return o&&a.includes(o)?o:a[0]??""},Hs=(e,t)=>t&&e.some(o=>o.fieldId===t)?t:e[0]?.fieldId??"",Fc=(e,t,o)=>o===""?"":o&&o!==t&&e.some(a=>a.fieldId===o)?o:e.find(a=>a.fieldId!==t)?.fieldId??"",om=e=>{let t=new Set,o=a=>{a.forEach(r=>{r.children.length>0&&(t.add(r.key),o(r.children));});};return o(e),t},rm=(e,t,o=0)=>e.length===0?o:e.reduce((a,r)=>r.children.length===0||!t.has(r.key)?Math.max(a,o+1):Math.max(a,rm(r.children,t,o+1)),o),oC=(e,t)=>{let o=[],a=r=>{r.forEach(n=>{if(n.children.length>0&&t.has(n.key)){a(n.children);return}o.push(n);});};return a(e),o},y5=({title:e,rows:t,fields:o,initialLayout:a,initialChart:r,emptyText:n,maxPreviewHeight:i=520,initialChartCollapsed:c=false,initialTableCollapsed:d=false,model:l,enablePresetManagement:s=false,presets:g,defaultPresets:f,onPresetsChange:u,initialPresetId:h,onPresetApplied:v})=>{let{t:p}=Q(),C=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:8}})),m=ht.useRef(0),y=ht.useRef(false),x=e??p("pivot.title.default"),S=n??p("pivot.empty"),B=ht.useMemo(()=>({sum:p("pivot.agg.sum"),count:p("pivot.agg.count"),avg:p("pivot.agg.avg"),min:p("pivot.agg.min"),max:p("pivot.agg.max")}),[p]),R=ht.useCallback(b=>B[b]??wu[b],[B]),w=ht.useMemo(()=>new Set(o.map(b=>b.id)),[o]),A=ht.useMemo(()=>new Map(o.map(b=>[b.id,b])),[o]),[P,k]=ht.useState(()=>St(a?.rows,w)),[D,T]=ht.useState(()=>St(a?.columns,w)),[I,M]=ht.useState(()=>St(a?.filters,w)),[H,V]=ht.useState(()=>{let b=a?.values??[],E=new Set,F=[];return b.forEach(U=>{if(!w.has(U.fieldId)||E.has(U.fieldId))return;E.add(U.fieldId),m.current+=1;let re=A.get(U.fieldId);F.push({tokenId:`v${m.current}`,fieldId:U.fieldId,aggregation:qt(U.aggregation,re)});}),F}),[J,ce]=ht.useState({}),[te,ne]=ht.useState(true),[ee,Y]=ht.useState(false),[Ze,Ue]=ht.useState(()=>Ec(St(a?.rows,w),St(a?.columns,w),r?.dimensionFieldId)),[ie,Ie]=ht.useState(()=>{let b=(a?.values??[]).filter((E,F,U)=>w.has(E.fieldId)&&U.findIndex(re=>re.fieldId===E.fieldId)===F).map(E=>({tokenId:E.fieldId,fieldId:E.fieldId,aggregation:qt(E.aggregation,A.get(E.fieldId))}));return Hs(b,r?.primaryValueFieldId)}),[Fe,Oe]=ht.useState(()=>{let b=(a?.values??[]).filter((F,U,re)=>w.has(F.fieldId)&&re.findIndex(ve=>ve.fieldId===F.fieldId)===U).map(F=>({tokenId:F.fieldId,fieldId:F.fieldId,aggregation:qt(F.aggregation,A.get(F.fieldId))})),E=Hs(b,r?.primaryValueFieldId);return Fc(b,E,r?.secondaryValueFieldId)}),[nt,Le]=ht.useState(r?.chartType??"bar-vertical"),[Xe,Zt]=ht.useState(c),[zt,Qe]=ht.useState(d),[lt,mt]=ht.useState(()=>f??[]),[_e,K]=ht.useState(""),[Ce,fe]=ht.useState(false),[be,Ne]=ht.useState(""),[Ve,Ht]=ht.useState(null),[Nt,Xt]=ht.useState(new Set(["__grand_total__"])),[Qt,Yt]=ht.useState(new Set),L=l?.rowFields??P,$=l?.columnFields??D,j=l?.filterFields??I,_=l?.valueFields??H,ke=l?.filterSelections??J,Ee=l?.showGrandTotal??te,Ye=l?.isConfiguratorCollapsed??ee,z=l?.chartDimensionFieldId??Ze,W=l?.chartPrimaryValueFieldId??ie,G=l?.chartSecondaryValueFieldId??Fe,ue=l?.chartType??nt,oe=l?.isChartCollapsed??Xe,Se=l?.isTableCollapsed??zt,ge=g??lt,Pe=s||ge.length>0||!!u,he=ht.useCallback(b=>{if(l?.setRowFields){l.setRowFields(b);return}k(b);},[l]),ze=ht.useCallback(b=>{if(l?.setColumnFields){l.setColumnFields(b);return}T(b);},[l]),Be=ht.useCallback(b=>{if(l?.setFilterFields){l.setFilterFields(b);return}M(b);},[l]),we=ht.useCallback(b=>{if(l?.setValueFields){l.setValueFields(b);return}V(b);},[l]),Me=ht.useCallback(b=>{if(l?.setFilterSelections){l.setFilterSelections(b);return}ce(b);},[l]),Tt=ht.useCallback(b=>{if(l?.setShowGrandTotal){l.setShowGrandTotal(b);return}ne(b);},[l]),Io=ht.useCallback(b=>{if(l?.setIsConfiguratorCollapsed){l.setIsConfiguratorCollapsed(b);return}Y(b);},[l]),Ct=ht.useCallback(b=>{if(l?.setChartDimensionFieldId){l.setChartDimensionFieldId(b);return}Ue(b);},[l]),It=ht.useCallback(b=>{if(l?.setChartPrimaryValueFieldId){l.setChartPrimaryValueFieldId(b);return}Ie(b);},[l]),bo=ht.useCallback(b=>{if(l?.setChartSecondaryValueFieldId){l.setChartSecondaryValueFieldId(b);return}Oe(b);},[l]),ka=ht.useCallback(b=>{if(l?.setChartType){l.setChartType(b);return}Le(b);},[l]),Rr=ht.useCallback(b=>{if(l?.setIsChartCollapsed){l.setIsChartCollapsed(b);return}Zt(b);},[l]),Po=ht.useCallback(b=>{if(l?.setIsTableCollapsed){l.setIsTableCollapsed(b);return}Qe(b);},[l]),ro=ht.useCallback(b=>{let E=typeof b=="function"?b(ge):b;g||mt(E),u?.(E);},[u,ge,g]),Za=ht.useMemo(()=>new Set([...L,...$,...j]),[L,$,j]),Yo=ht.useMemo(()=>o.filter(b=>!Za.has(b.id)),[o,Za]),Gt=ht.useMemo(()=>{let b=[...L,...$,...j],E=new Set,F=[];return b.forEach(U=>{E.has(U)||(E.add(U),F.push(U));}),F},[$,j,L]);ht.useEffect(()=>{he(b=>{let E=b.filter(F=>w.has(F));return fa(b,E)?b:E}),ze(b=>{let E=b.filter(F=>w.has(F));return fa(b,E)?b:E}),Be(b=>{let E=b.filter(F=>w.has(F));return fa(b,E)?b:E}),we(b=>{let E=b.filter(F=>w.has(F.fieldId)).map(F=>({...F,aggregation:qt(F.aggregation,A.get(F.fieldId))}));return Rs(b,E)?b:E});},[A,w]);let no=ht.useMemo(()=>{let b={};return Gt.forEach(E=>{let F=new Set;t.forEach(U=>{F.add(ga(U[E]));}),b[E]=Array.from(F).sort((U,re)=>U.localeCompare(re));}),b},[Gt,t]);ht.useEffect(()=>{Me(b=>{let E={};return Gt.forEach(F=>{let U=no[F]??[],ve=(b[F]??[]).filter(X=>U.includes(X)),N=Object.prototype.hasOwnProperty.call(b,F);E[F]=N?ve:U;}),Mu(b,E)?b:E});},[Gt,no]),ht.useEffect(()=>{Ct(b=>Ec(L,$,b));},[$,L,Ct]),ht.useEffect(()=>{It(b=>Hs(_,b));},[It,_]),ht.useEffect(()=>{bo(b=>Fc(_,W,b));},[W,bo,_]);let Vt=ht.useMemo(()=>t.filter(b=>Gt.every(E=>{let F=ke[E]??[],U=no[E]??[];if(F.length===U.length)return true;if(F.length===0)return false;let re=ga(b[E]);return F.includes(re)})),[Gt,no,ke,t]),We=ht.useMemo(()=>{if(_.length===0)return null;let b=new Map;if(Vt.forEach(N=>{let X=$.length>0?$.map(Je=>ga(N[Je])):[p("pivot.valueLabel")],Z=hr(X);b.set(Z,X);}),b.size===0){let N=$.length>0?$.map(()=>Is):[p("pivot.valueLabel")];b.set(hr(N),N);}let E=Array.from(b.entries()).sort((N,X)=>Du(N[1],X[1])),F=E.flatMap(([N,X])=>_.map(Z=>{let Je=A.get(Z.fieldId),O=`${R(Z.aggregation)} ${Je?.label??Z.fieldId}`,ae=$.length===0||_.length>1?`${X.join(" / ")} \u2022 ${O}`:X.join(" / ");return {id:`${N}::${Z.tokenId}`,colKey:N,valueItem:Z,label:ae}})),U=[];$.length>0&&E.forEach(([N,X])=>{let Z=F.filter(ae=>ae.colKey===N),Je=U,O=[];X.forEach((ae,q)=>{O.push(`d${q}:${ae}`);let de=`col::${hr(O)}`,$e=Je.find(Ko=>Ko.key===de);$e||($e={key:de,label:ae,children:[],leafColumnIds:[],path:X.slice(0,q+1),depth:q},Je.push($e)),Z.forEach(Ko=>{$e.leafColumnIds.includes(Ko.id)||$e.leafColumnIds.push(Ko.id);}),Je=$e.children;});});let re=N=>{let X={};return F.forEach(Z=>{let Je=N.filter(O=>{let ae=$.length>0?$.map(q=>ga(O[q])):[p("pivot.valueLabel")];return hr(ae)===Z.colKey});X[Z.id]=on(Je,Z.valueItem.fieldId,Z.valueItem.aggregation);}),X},ve=[];if(L.length===0)ve.push({key:"root",value:p("pivot.resultLabel")||ku,children:[],isLeaf:true,aggregatedValues:re(Vt),path:[],depth:0});else {let N=(X,Z,Je)=>{if(Z>=L.length)return [];let O=L[Z],ae=new Map;return X.forEach(q=>{let de=ga(q[O]);ae.has(de)||ae.set(de,[]),ae.get(de).push(q);}),Array.from(ae.keys()).sort().map(q=>{let de=ae.get(q),$e=[...Je,q];return {key:hr($e),value:q,fieldId:O,aggregatedValues:re(de),children:N(de,Z+1,$e),isLeaf:Z===L.length-1,path:$e,depth:Z}})};ve.push(...N(Vt,0,[]));}return {dataColumns:F,columnTree:U,rowTree:ve}},[$,A,Vt,R,L,p,_]),Jo=ht.useCallback((b,E)=>(m.current+=1,{tokenId:`v${m.current}`,fieldId:b,aggregation:qt(E,A.get(b))}),[A]),$o=ht.useCallback(b=>{if(b==="rows")return he([]);if(b==="columns")return ze([]);if(b==="filters")return Be([]);we([]);},[]),ea=ht.useCallback((b,E)=>{if(b==="rows")return he(F=>F.filter(U=>U!==E));if(b==="columns")return ze(F=>F.filter(U=>U!==E));if(b==="filters")return Be(F=>F.filter(U=>U!==E));we(F=>F.filter(U=>U.tokenId!==E));},[]),Xa=ht.useCallback((b,E)=>{we(F=>F.map(U=>U.tokenId===b?{...U,aggregation:qt(E,A.get(U.fieldId))}:U));},[A]),Ho=ht.useCallback(b=>{Ht(String(b.active.id));},[]),Qa=ht.useCallback(b=>{if(Ht(null),!b.over)return;let E=Ps(String(b.active.id)),F=Ps(String(b.over.id));if(!E||!F||E.kind!=="item"||!E.key)return;if(E.zone===F.zone&&F.kind==="item"){if(E.zone==="rows"){let q=L.indexOf(E.key),de=L.indexOf(F.key??"");q!==-1&&de!==-1&&q!==de&&he($e=>sortable.arrayMove($e,q,de));return}if(E.zone==="columns"){let q=$.indexOf(E.key),de=$.indexOf(F.key??"");q!==-1&&de!==-1&&q!==de&&ze($e=>sortable.arrayMove($e,q,de));return}if(E.zone==="filters"){let q=j.indexOf(E.key),de=j.indexOf(F.key??"");q!==-1&&de!==-1&&q!==de&&Be($e=>sortable.arrayMove($e,q,de));return}if(E.zone==="values"){let q=_.findIndex($e=>$e.tokenId===E.key),de=_.findIndex($e=>$e.tokenId===(F.key??""));q!==-1&&de!==-1&&q!==de&&we($e=>sortable.arrayMove($e,q,de));}return}let U=F.zone,re=[...L],ve=[...$],N=[...j],X=[..._],Z="",Je=null;if(E.zone==="palette")Z=E.key;else if(E.zone==="values"){let q=X.find(de=>de.tokenId===E.key);if(!q)return;Z=q.fieldId,Je=q,X=X.filter(de=>de.tokenId!==E.key);}else E.zone==="rows"?(Z=E.key,re=re.filter(q=>q!==Z)):E.zone==="columns"?(Z=E.key,ve=ve.filter(q=>q!==Z)):E.zone==="filters"&&(Z=E.key,N=N.filter(q=>q!==Z));if(!Z)return;let O=()=>{re=re.filter(q=>q!==Z),ve=ve.filter(q=>q!==Z),N=N.filter(q=>q!==Z);},ae=q=>{if(F.kind!=="item"||!F.key)return q==="rows"?re.length:q==="columns"?ve.length:q==="filters"?N.length:q==="values"?X.length:0;if(q==="rows"){let de=re.indexOf(F.key);return de>=0?de:re.length}if(q==="columns"){let de=ve.indexOf(F.key);return de>=0?de:ve.length}if(q==="filters"){let de=N.indexOf(F.key);return de>=0?de:N.length}if(q==="values"){let de=X.findIndex($e=>$e.tokenId===F.key);return de>=0?de:X.length}return 0};if(U==="palette"){he(re),ze(ve),Be(N),we(X);return}if(U==="values"){let q=ae("values"),de=Je??Jo(Z);X.splice(q,0,de),he(re),ze(ve),Be(N),we(X);return}if(Ru(U)){O();let q=ae(U);U==="rows"?re.splice(q,0,Z):U==="columns"?ve.splice(q,0,Z):N.splice(q,0,Z),he(re),ze(ve),Be(N),we(X);}},[$,Jo,j,L,_]),Ya=ht.useCallback((b,E)=>{Me(F=>({...F,[b]:E}));},[]),Go=ht.useCallback(b=>{Xt(E=>{let F=new Set(E);return F.has(b)?F.delete(b):F.add(b),F});},[]),ta=ht.useCallback(b=>{Yt(E=>{let F=new Set(E);return F.has(b)?F.delete(b):F.add(b),F});},[]),Sa=ht.useCallback(b=>{let E=A.get(b.fieldId),F=vc(E);return jsxRuntime.jsx(material.FormControl,{size:"small",sx:{minWidth:98},children:jsxRuntime.jsx(material.Select,{value:b.aggregation,onChange:U=>Xa(b.tokenId,U.target.value),onClick:U=>U.stopPropagation(),onMouseDown:U=>U.stopPropagation(),sx:{fontSize:"0.72rem",height:26,"& .MuiSelect-select":{py:.35}},children:F.map(U=>jsxRuntime.jsx(material.MenuItem,{value:U,sx:{fontSize:"0.75rem"},children:R(U)},U))})})},[A,R,Xa]),Ut=ht.useCallback(b=>{let E=no[b]??[],F=ke[b]??E;return E.length===0?p("pivot.filter.noValues"):F.length===0?p("pivot.filter.noneSelected"):F.length===E.length?p("pivot.filter.allValues"):p("pivot.filter.selectedCount",{selected:F.length,total:E.length})},[no,ke,p]),Ro=ht.useCallback(b=>{let E=no[b]??[],F=ke[b]??E;return jsxRuntime.jsx(Eu,{options:E,selectedValues:F,onChange:U=>Ya(b,U)})},[no,ke,Ya]),oa=ht.useCallback(()=>`pivot-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,[]),xo=ht.useCallback(()=>{let b={};return new Set([...Gt,...Object.keys(ke)]).forEach(F=>{if(!w.has(F))return;let U=ke[F]??[];b[F]=[...U];}),{layout:{rows:[...L],columns:[...$],filters:[...j],values:_.map(F=>({fieldId:F.fieldId,aggregation:F.aggregation}))},filterSelections:b,showGrandTotal:Ee,chart:{dimensionFieldId:z,primaryValueFieldId:W,secondaryValueFieldId:G,chartType:ue}}},[Gt,z,W,G,ue,$,j,ke,L,Ee,w,_]),Uo=ht.useCallback(b=>{let E=St(b.layout.rows,w),F=St(b.layout.columns,w),U=St(b.layout.filters,w),re=new Set,ve=(b.layout.values??[]).filter(Z=>!w.has(Z.fieldId)||re.has(Z.fieldId)?false:(re.add(Z.fieldId),true)).map(Z=>Jo(Z.fieldId,Z.aggregation)),N={};Object.entries(b.filterSelections??{}).forEach(([Z,Je])=>{!w.has(Z)||!Array.isArray(Je)||(N[Z]=Array.from(new Set(Je.map(O=>String(O)))));}),he(E),ze(F),Be(U),we(ve),Me(N),typeof b.showGrandTotal=="boolean"&&Tt(b.showGrandTotal),Ct(Ec(E,F,b.chart?.dimensionFieldId));let X=Hs(ve,b.chart?.primaryValueFieldId);It(X),bo(Fc(ve,X,b.chart?.secondaryValueFieldId)),ka(b.chart?.chartType??"bar-vertical"),K(b.id),v?.(b);},[Jo,v,Ct,It,bo,ka,ze,Be,Me,he,Tt,we,w]),Ja=ht.useCallback(b=>{if(!b){K("");return}let E=ge.find(F=>F.id===b);if(!E){K("");return}Uo(E);},[Uo,ge]),Dr=ht.useCallback(()=>{let b=p("pivot.preset.defaultName",{index:ge.length+1});Ne(b),fe(true);},[ge.length,p]),wa=ht.useCallback(()=>{let b=be.trim();if(!b)return;let E={id:oa(),name:b,...xo()};ro(F=>[...F,E]),K(E.id),fe(false);},[xo,oa,be,ro]),er=ht.useCallback(()=>{_e&&(ro(b=>b.filter(E=>E.id!==_e)),K(""));},[_e,ro]);ht.useEffect(()=>{if(!h||y.current)return;let b=ge.find(E=>E.id===h);b&&(y.current=true,Uo(b));},[Uo,h,ge]),ht.useEffect(()=>{_e&&(ge.some(b=>b.id===_e)||K(""));},[_e,ge]);let aa=ht.useMemo(()=>{if(!Ee||!We||!L.length)return null;let b={};return We.dataColumns.forEach(E=>{let F=Vt.filter(U=>{let re=$.length>0?$.map(ve=>ga(U[ve])):[p("pivot.valueLabel")];return hr(re)===E.colKey});b[E.id]=on(F,E.valueItem.fieldId,E.valueItem.aggregation);}),{key:"__grand_total__",value:p("pivot.grandTotal")||Su,children:[],isLeaf:false,isGrandTotal:true,aggregatedValues:b,path:[],depth:-1}},[Ee,We,Vt,$,L.length,p]),Jt=ht.useMemo(()=>om(We?.rowTree??[]),[We]),Do=ht.useMemo(()=>om(We?.columnTree??[]),[We]);ht.useEffect(()=>{Xt(b=>{let E=new Set;return b.has("__grand_total__")&&E.add("__grand_total__"),Jt.forEach(F=>{b.has(F)&&E.add(F);}),E});},[Jt]),ht.useEffect(()=>{Yt(b=>{let E=new Set;return Do.forEach(F=>{b.has(F)&&E.add(F);}),E});},[Do]);let Mr=ht.useCallback(()=>{Xt(b=>{let E=new Set(b);return Jt.forEach(F=>E.add(F)),E});},[Jt]),tr=ht.useCallback(()=>{Xt(b=>{let E=new Set;return b.has("__grand_total__")&&E.add("__grand_total__"),E});},[]),Ar=ht.useCallback(()=>{Yt(new Set(Do));},[Do]),Br=ht.useCallback(()=>{Yt(new Set);},[]),Er=ht.useMemo(()=>!We||$.length===0?[]:oC(We.columnTree,Qt),[$.length,Qt,We]),io=ht.useMemo(()=>{if(!We)return [];if($.length===0)return We.dataColumns.map(E=>({id:E.id,label:E.label,leafColumnIds:[E.id],valueItem:E.valueItem}));let b=new Map(We.dataColumns.map(E=>[E.id,E]));return Er.flatMap(E=>{let F=new Map;return E.leafColumnIds.forEach(U=>{let re=b.get(U);if(!re)return;let ve=re.valueItem.tokenId,N=`${R(re.valueItem.aggregation)} ${A.get(re.valueItem.fieldId)?.label??re.valueItem.fieldId}`,X=F.get(ve);if(X){X.leafColumnIds.push(U);return}F.set(ve,{id:`${E.key}::${ve}`,label:_.length>1?N:E.label,leafColumnIds:[U],valueItem:re.valueItem});}),Array.from(F.values())})},[$.length,A,R,We,_.length,Er]),Fr=ht.useMemo(()=>new Map(io.map(b=>[b.id,b])),[io]),Lr=ht.useMemo(()=>io.map(b=>({id:b.id,colKey:b.id,valueItem:b.valueItem,label:b.label})),[io]),or=ht.useMemo(()=>{if(!We||$.length===0)return [];let b=[],E=rm(We.columnTree,Qt),F=E+(_.length>1?1:0),U=(re,ve)=>{b[ve]??(b[ve]=[]),re.forEach(N=>{let X=N.children.length>0&&Qt.has(N.key),Z=io.filter(O=>N.leafColumnIds.some(ae=>O.leafColumnIds.includes(ae))).length,Je=X||_.length>1?1:F-ve;b[ve].push({key:N.key,label:N.label,colSpan:Z,rowSpan:Je,expandable:N.children.length>0,expanded:X}),X&&U(N.children,ve+1);});};return U(We.columnTree,0),_.length>1&&(b[E]=io.map(re=>({key:re.id,label:re.label,colSpan:1,rowSpan:1,expandable:false,expanded:false}))),b},[$.length,Qt,We,_.length,io]),ra=ht.useCallback((b,E)=>E.leafColumnIds.reduce((F,U)=>F+(b.aggregatedValues[U]??0),0),[]),Ta=ht.useMemo(()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:Mr,disabled:Jt.size===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.expandRowsAll")}),jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:tr,disabled:Jt.size===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.collapseRowsAll")}),jsxRuntime.jsx(material.Divider,{orientation:"vertical",flexItem:true}),jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:Ar,disabled:Do.size===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.expandColumnsAll")}),jsxRuntime.jsx(material.Button,{size:"small",variant:"text",onClick:Br,disabled:$.length===0,sx:{minWidth:"auto",px:.8,fontSize:"0.72rem"},children:p("pivot.table.collapseColumnsAll")})]}),[$.length,Do.size,Jt.size,Br,tr,Ar,Mr,p]),Ia=()=>{if(!Ve)return null;let b=Ps(Ve);if(!b||b.kind!=="item"||!b.key)return null;if(b.zone==="palette"){let re=A.get(b.key);return re?jsxRuntime.jsx(kc,{label:re.label,subtitle:re.type}):null}if(b.zone==="values"){let re=_.find(Z=>Z.tokenId===b.key);if(!re)return null;let N=A.get(re.fieldId)?.label??re.fieldId,X=`${R(re.aggregation)}(${N})`;return jsxRuntime.jsx(Es,{label:N,caption:X})}let F=A.get(b.key)?.label??b.key,U=Ut(b.key);return jsxRuntime.jsx(Es,{label:F,caption:U})};return jsxRuntime.jsxs(material.Paper,{sx:b=>({p:{xs:1.2,md:2},borderRadius:4,border:`1px solid ${b.palette.divider}`,bgcolor:"background.paper",boxShadow:b.palette.mode==="dark"?"none":"0 12px 28px rgba(15, 23, 42, 0.08)",display:"flex",flexDirection:"column",gap:2}),children:[jsxRuntime.jsxs(material.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexWrap:"wrap"},children:[jsxRuntime.jsxs(material.Box,{children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1.05rem",fontWeight:800},children:x}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.78rem",color:"text.secondary"},children:p("pivot.subtitle.default")})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[Pe&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.FormControl,{size:"small",sx:{minWidth:200},children:jsxRuntime.jsxs(material.Select,{value:_e,displayEmpty:true,onChange:b=>Ja(String(b.target.value)),sx:{fontSize:"0.75rem",height:32},children:[jsxRuntime.jsx(material.MenuItem,{value:"",sx:{fontSize:"0.75rem",color:"text.secondary"},children:p("pivot.preset.selectPlaceholder")}),ge.map(b=>jsxRuntime.jsx(material.MenuItem,{value:b.id,sx:{fontSize:"0.75rem"},children:b.name},b.id))]})}),jsxRuntime.jsx(material.Tooltip,{title:p("pivot.preset.save"),children:jsxRuntime.jsx(material.IconButton,{size:"small",onClick:Dr,"aria-label":p("pivot.preset.save"),children:jsxRuntime.jsx(Rp__default.default,{sx:{fontSize:18}})})}),jsxRuntime.jsx(material.Tooltip,{title:p("pivot.preset.delete"),children:jsxRuntime.jsx("span",{children:jsxRuntime.jsx(material.IconButton,{size:"small",onClick:er,disabled:!_e,"aria-label":p("pivot.preset.delete"),children:jsxRuntime.jsx(_v__default.default,{sx:{fontSize:18}})})})}),jsxRuntime.jsx(material.Divider,{flexItem:true,orientation:"vertical"})]}),jsxRuntime.jsxs(material.Typography,{sx:{fontSize:"0.74rem",color:"text.secondary"},children:[p("pivot.records"),": ",jsxRuntime.jsx("strong",{children:t.length.toLocaleString()})," / ",p("pivot.afterFilter"),":"," ",jsxRuntime.jsx("strong",{children:Vt.length.toLocaleString()})]}),jsxRuntime.jsx(material.Divider,{flexItem:true,orientation:"vertical"}),jsxRuntime.jsxs(material.Box,{sx:{display:"flex",alignItems:"center",gap:.6},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.74rem"},children:p("pivot.grandTotal")}),jsxRuntime.jsx(material.Switch,{size:"small",checked:Ee,onChange:b=>Tt(b.target.checked)})]})]})]}),jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsxs(core.DndContext,{sensors:C,collisionDetection:core.closestCenter,onDragStart:Ho,onDragEnd:Qa,children:[jsxRuntime.jsx($u,{isConfiguratorCollapsed:Ye,onToggleCollapse:()=>Io(b=>!b),availableFields:Yo,fieldMap:A,filterFields:j,columnFields:$,rowFields:L,valueFields:_,clearZone:$o,removeFieldFromZone:ea,getFilterSelectionSummary:Ut,renderDimensionFilterSelect:Ro,renderAggregationSelect:Sa,getAggregationLabel:R}),jsxRuntime.jsx(material.Portal,{children:jsxRuntime.jsx(core.DragOverlay,{dropAnimation:{duration:250,easing:"cubic-bezier(0.18, 0.67, 0.6, 1.22)"},children:Ia()})})]}),jsxRuntime.jsx(Zu,{rows:Vt,fieldMap:A,rowFields:L,columnFields:$,valueFields:_,chartDimensionFieldId:z,chartPrimaryValueFieldId:W,chartSecondaryValueFieldId:G,chartType:ue,isCollapsed:oe,onChartDimensionFieldIdChange:b=>Ct(b),onChartPrimaryValueFieldIdChange:b=>It(b),onChartSecondaryValueFieldIdChange:b=>bo(b),onChartTypeChange:b=>ka(b),onToggleCollapse:()=>Rr(b=>!b),getAggregationLabel:R}),jsxRuntime.jsx(ln,{title:p("pivot.table.sectionTitle"),subtitle:L.length>0?L.map(b=>A.get(b)?.label??b).join(" > "):p("pivot.table.dimensions"),collapsed:Se,onToggleCollapse:()=>Po(b=>!b),expandAriaLabel:p("pivot.table.collapse.ariaExpand"),collapseAriaLabel:p("pivot.table.collapse.ariaCollapse"),bodySx:{p:0},headerActions:Ta,children:We===null?jsxRuntime.jsx(material.Box,{sx:{py:5,px:{xs:1.2,md:1.6},textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.86rem",color:"text.secondary"},children:S})}):jsxRuntime.jsx(material.TableContainer,{sx:{maxHeight:i},children:jsxRuntime.jsxs(material.Table,{size:"small",stickyHeader:true,children:[jsxRuntime.jsx(material.TableHead,{children:(or.length>0?or:[[]]).map((b,E)=>jsxRuntime.jsxs(material.TableRow,{children:[E===0&&jsxRuntime.jsx(material.TableCell,{rowSpan:Math.max(or.length,1),sx:F=>({fontWeight:800,fontSize:"0.76rem",color:"text.primary",bgcolor:F.palette.mode==="dark"?"#000000":"#f5f5f5",borderBottom:`1px solid ${F.palette.divider}`,pl:2,minWidth:220,verticalAlign:"middle"}),children:L.length>0?L.map(F=>A.get(F)?.label).join(" > "):p("pivot.table.dimensions")}),(b.length>0?b:io.map(F=>({key:F.id,label:F.label,colSpan:1,rowSpan:1,expandable:false,expanded:false}))).map(F=>jsxRuntime.jsx(material.TableCell,{align:"center",colSpan:F.colSpan,rowSpan:F.rowSpan,sx:U=>({fontWeight:800,fontSize:"0.75rem",color:"text.primary",bgcolor:U.palette.mode==="dark"?"#000000":"#f5f5f5",borderBottom:`1px solid ${U.palette.divider}`,minWidth:148,verticalAlign:"middle"}),children:jsxRuntime.jsxs(material.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:.4},children:[F.expandable&&jsxRuntime.jsx(material.IconButton,{size:"small",onClick:()=>ta(F.key),sx:{p:.1,ml:-0.3},children:F.expanded?jsxRuntime.jsx(ch__default.default,{sx:{fontSize:16}}):jsxRuntime.jsx(qf__default.default,{sx:{fontSize:16}})}),jsxRuntime.jsx(material.Box,{component:"span",children:F.label})]})},F.key))]},`pivot-header-row-${E}`))}),jsxRuntime.jsxs(material.TableBody,{children:[We.rowTree.map(b=>jsxRuntime.jsx(Os,{node:b,dataColumns:Lr,fieldMap:A,level:0,expandedKeys:Nt,onToggle:Go,getValue:(E,F)=>{let U=Fr.get(F);return U?ra(E,U):0}},b.key)),aa&&jsxRuntime.jsx(Os,{node:aa,dataColumns:Lr,fieldMap:A,level:0,expandedKeys:Nt,onToggle:Go,getValue:(b,E)=>{let F=Fr.get(E);return F?ra(b,F):0}})]})]})})}),jsxRuntime.jsxs(material.Dialog,{open:Ce,onClose:()=>fe(false),maxWidth:"xs",fullWidth:true,children:[jsxRuntime.jsx(material.DialogTitle,{children:p("pivot.preset.saveDialogTitle")}),jsxRuntime.jsx(material.DialogContent,{children:jsxRuntime.jsx(material.TextField,{autoFocus:true,fullWidth:true,margin:"dense",label:p("pivot.preset.nameLabel"),value:be,onChange:b=>Ne(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),wa());}})}),jsxRuntime.jsxs(material.DialogActions,{children:[jsxRuntime.jsx(material.Button,{onClick:()=>fe(false),children:p("common.cancel")}),jsxRuntime.jsx(material.Button,{variant:"contained",onClick:wa,disabled:!be.trim(),children:p("common.save")})]})]})]})};var nm=(e,t,o)=>{let a=[...e,...t];return o&&a.includes(o)?o:a[0]??""},zc=(e,t)=>t&&e.some(o=>o.fieldId===t)?t:e[0]?.fieldId??"",im=(e,t,o)=>o===""?"":o&&o!==t&&e.some(a=>a.fieldId===o)?o:e.find(a=>a.fieldId!==t)?.fieldId??"",k5=({fields:e,initialLayout:t,initialFilterSelections:o={},initialShowGrandTotal:a=true,initialConfiguratorCollapsed:r=false,initialChart:n,initialChartCollapsed:i=false,initialTableCollapsed:c=false})=>{let d=ht.useRef(0),l=ht.useMemo(()=>new Set(e.map(K=>K.id)),[e]),s=ht.useMemo(()=>new Map(e.map(K=>[K.id,K])),[e]),[g,f]=ht.useState(()=>St(t?.rows,l)),[u,h]=ht.useState(()=>St(t?.columns,l)),[v,p]=ht.useState(()=>St(t?.filters,l)),[C,m]=ht.useState(()=>{let K=t?.values??[],Ce=new Set,fe=[];return K.forEach(be=>{!l.has(be.fieldId)||Ce.has(be.fieldId)||(Ce.add(be.fieldId),d.current+=1,fe.push({tokenId:`v${d.current}`,fieldId:be.fieldId,aggregation:qt(be.aggregation,s.get(be.fieldId))}));}),fe}),[y,x]=ht.useState(o),[S,B]=ht.useState(a),[R,w]=ht.useState(r),[A,P]=ht.useState(()=>nm(St(t?.rows,l),St(t?.columns,l),n?.dimensionFieldId)),[k,D]=ht.useState(()=>{let K=(()=>{let Ce=t?.values??[],fe=new Set,be=[];return Ce.forEach(Ne=>{!l.has(Ne.fieldId)||fe.has(Ne.fieldId)||(fe.add(Ne.fieldId),be.push({tokenId:Ne.fieldId,fieldId:Ne.fieldId,aggregation:qt(Ne.aggregation,s.get(Ne.fieldId))}));}),be})();return zc(K,n?.primaryValueFieldId)}),[T,I]=ht.useState(()=>{let K=(()=>{let fe=t?.values??[],be=new Set,Ne=[];return fe.forEach(Ve=>{!l.has(Ve.fieldId)||be.has(Ve.fieldId)||(be.add(Ve.fieldId),Ne.push({tokenId:Ve.fieldId,fieldId:Ve.fieldId,aggregation:qt(Ve.aggregation,s.get(Ve.fieldId))}));}),Ne})(),Ce=zc(K,n?.primaryValueFieldId);return im(K,Ce,n?.secondaryValueFieldId)}),[M,H]=ht.useState(n?.chartType??"bar-vertical"),[V,J]=ht.useState(i),[ce,te]=ht.useState(c);ht.useEffect(()=>{f(K=>{let Ce=K.filter(fe=>l.has(fe));return fa(K,Ce)?K:Ce}),h(K=>{let Ce=K.filter(fe=>l.has(fe));return fa(K,Ce)?K:Ce}),p(K=>{let Ce=K.filter(fe=>l.has(fe));return fa(K,Ce)?K:Ce}),m(K=>{let Ce=K.filter(fe=>l.has(fe.fieldId)).map(fe=>({...fe,aggregation:qt(fe.aggregation,s.get(fe.fieldId))}));return Rs(K,Ce)?K:Ce});},[s,l]),ht.useEffect(()=>{P(K=>nm(g,u,K));},[u,g]),ht.useEffect(()=>{D(K=>zc(C,K));},[C]),ht.useEffect(()=>{I(K=>im(C,k,K));},[k,C]);let ne=ht.useCallback(K=>{f(St(K,l));},[l]),ee=ht.useCallback(K=>{h(St(K,l));},[l]),Y=ht.useCallback(K=>{p(St(K,l));},[l]),Ze=ht.useCallback(K=>{m(Ce=>{let fe=K??[],be=new Set,Ne=[];return fe.forEach(Ve=>{if(!l.has(Ve.fieldId)||be.has(Ve.fieldId))return;be.add(Ve.fieldId);let Ht=Ce.find(Nt=>Nt.fieldId===Ve.fieldId);if(Ht){Ne.push({...Ht,aggregation:qt(Ve.aggregation??Ht.aggregation,s.get(Ve.fieldId))});return}d.current+=1,Ne.push({tokenId:`v${d.current}`,fieldId:Ve.fieldId,aggregation:qt(Ve.aggregation,s.get(Ve.fieldId))});}),Ne});},[s,l]),Ue=ht.useCallback(K=>{ne(K.rows??[]),ee(K.columns??[]),Y(K.filters??[]),Ze(K.values??[]);},[ee,Y,ne,Ze]),ie=ht.useCallback(K=>{if(K==="rows")return f([]);if(K==="columns")return h([]);if(K==="filters")return p([]);m([]);},[]),Ie=ht.useCallback((K,Ce)=>{if(K==="rows")return f(fe=>fe.filter(be=>be!==Ce));if(K==="columns")return h(fe=>fe.filter(be=>be!==Ce));if(K==="filters")return p(fe=>fe.filter(be=>be!==Ce));m(fe=>fe.filter(be=>be.tokenId!==Ce));},[]),Fe=ht.useCallback((K,Ce)=>{m(fe=>fe.map(be=>be.tokenId===K?{...be,aggregation:qt(Ce,s.get(be.fieldId))}:be));},[s]),Oe=ht.useCallback((K,Ce)=>{x(fe=>({...fe,[K]:Ce}));},[]),nt=ht.useCallback(()=>{x({});},[]),Le=ht.useCallback(()=>{B(K=>!K);},[]),Xe=ht.useCallback(()=>{w(K=>!K);},[]),Zt=ht.useCallback(K=>{P(K);},[]),zt=ht.useCallback(K=>{D(K);},[]),Qe=ht.useCallback(K=>{I(K);},[]),lt=ht.useCallback(()=>{J(K=>!K);},[]),mt=ht.useCallback(()=>{te(K=>!K);},[]);return {model:ht.useMemo(()=>({rowFields:g,setRowFields:f,columnFields:u,setColumnFields:h,filterFields:v,setFilterFields:p,valueFields:C,setValueFields:m,filterSelections:y,setFilterSelections:x,showGrandTotal:S,setShowGrandTotal:B,isConfiguratorCollapsed:R,setIsConfiguratorCollapsed:w,chartDimensionFieldId:A,setChartDimensionFieldId:P,chartPrimaryValueFieldId:k,setChartPrimaryValueFieldId:D,chartSecondaryValueFieldId:T,setChartSecondaryValueFieldId:I,chartType:M,setChartType:H,isChartCollapsed:V,setIsChartCollapsed:J,isTableCollapsed:ce,setIsTableCollapsed:te}),[A,k,T,M,u,v,y,V,R,ce,g,S,C]),actions:{setRows:ne,setColumns:ee,setFilters:Y,setValues:Ze,setLayout:Ue,clearZone:ie,removeFieldFromZone:Ie,setAggregationForValue:Fe,setFilterSelection:Oe,resetFilterSelections:nt,toggleGrandTotal:Le,toggleConfigurator:Xe,setChartDimension:Zt,setChartPrimaryValue:zt,setChartSecondaryValue:Qe,setChartType:H,toggleChart:lt,toggleTable:mt}}};var P5=({orientation:e="auto",defaultNavigationOpen:t,onNavOpenChange:o}={})=>{let a=styles.useTheme(),r=material.useMediaQuery("(orientation: portrait)",{noSsr:true}),n=material.useMediaQuery(a.breakpoints.down("md"),{noSsr:true}),i=ht.useMemo(()=>e==="auto"?r||n?"portrait":"landscape":e,[n,r,e]),[c,d]=ht.useState(t??i==="landscape");ht.useEffect(()=>{d(t??i==="landscape");},[t,i]);let l=g=>{d(g),o?.(g);};return {resolvedOrientation:i,isPortraitViewport:r,isCompactViewport:n,navigationOpen:c,setNavigationOpen:l,toggleNavigationOpen:()=>l(!c)}};var cC=e=>{let t=Number(e||0);return Number.isFinite(t)?t:0},M5=({rows:e,rowKey:t="id",numericField:o,defaultSelectedId:a})=>{let n=e[0]?.[t],[i,c]=ht.useState(a??n),d=ht.useMemo(()=>e.find(u=>u[t]===i)||e[0],[t,e,i]),[l,s]=ht.useState(()=>{let u=d?.[o];return u==null?"0":String(u)});return {selectedId:i,selectedRecord:d,editorValue:l,setEditorValue:s,selectRecord:u=>{let h=u[t];c(h);let v=u[o];s(v==null?"0":String(v));},applyEditorValue:u=>{if(i===void 0)return;let h=cC(l),v=e.map(p=>p[t]===i?{...p,[o]:h}:p);u(v);}}};var vC=["code_128","ean_13","ean_8","qr_code","upc_a","upc_e"],um=(e,t,o,a)=>{t?.(e),a&&o?.();},z5=({open:e,onClose:t,title:o="Scan barcode",subtitle:a="Use the rear camera on the device. If scanning is unavailable, enter the code manually.",formats:r=vC,facingMode:n="environment",manualEntry:i=true,autoCloseOnDetect:c=true,scanIntervalMs:d=600,confirmLabel:l="Use code",cancelLabel:s="Close",manualPlaceholder:g="Enter barcode manually",onDetected:f,onError:u,sx:h})=>{let v=ht__namespace.default.useRef(null),p=ht__namespace.default.useRef(null),C=ht__namespace.default.useRef(null),m=ht__namespace.default.useRef(null),[y,x]=ht__namespace.default.useState("idle"),[S,B]=ht__namespace.default.useState(""),[R,w]=ht__namespace.default.useState(null),[A,P]=ht__namespace.default.useState(null),k=ht__namespace.default.useCallback(()=>{C.current!==null&&(window.clearInterval(C.current),C.current=null),p.current&&(p.current.getTracks().forEach(I=>I.stop()),p.current=null),v.current&&(v.current.srcObject=null);},[]),D=ht__namespace.default.useCallback(I=>{P(I),x("error"),u?.(I);},[u]);ht__namespace.default.useEffect(()=>{if(!e){k(),x("idle"),P(null),B("");return}let I=false;return (async()=>{if(!(typeof window>"u"||typeof navigator>"u")){if(!navigator.mediaDevices?.getUserMedia){x("unsupported"),P("Camera access is not supported in this browser.");return}x("starting"),P(null);try{let H=await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:{ideal:n}}});if(I){H.getTracks().forEach(V=>V.stop());return}if(p.current=H,v.current&&(v.current.srcObject=H,await v.current.play()),!window.BarcodeDetector){x("unsupported"),P("BarcodeDetector is not available. Camera preview is ready and manual entry is enabled.");return}m.current=new window.BarcodeDetector({formats:r}),x("ready"),C.current=window.setInterval(async()=>{if(!(!v.current||!m.current)&&!(v.current.readyState<HTMLMediaElement.HAVE_CURRENT_DATA))try{let J=(await m.current.detect(v.current)).find(te=>te.rawValue);if(!J?.rawValue)return;let ce={rawValue:J.rawValue,format:J.format};w(ce),k(),um(ce,f,t,c);}catch(V){D(V instanceof Error?V.message:"Failed to detect barcode.");}},d);}catch(H){D(H instanceof Error?H.message:"Unable to start camera.");}}})(),()=>{I=true,k();}},[c,n,r,t,f,e,D,d,k]);let T=()=>{let I=S.trim();if(!I)return;let M={rawValue:I,format:"manual"};w(M),um(M,f,t,c);};return jsxRuntime.jsxs(material.Dialog,{open:e,onClose:t,fullWidth:true,maxWidth:"sm",children:[jsxRuntime.jsx(material.DialogTitle,{sx:{fontSize:"1rem",fontWeight:900},children:o}),jsxRuntime.jsx(material.DialogContent,{sx:{pt:"8px !important"},children:jsxRuntime.jsxs(material.Stack,{spacing:2,sx:h,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.88rem",color:"text.secondary",lineHeight:1.55},children:a}),jsxRuntime.jsxs(material.Paper,{elevation:0,sx:I=>({position:"relative",overflow:"hidden",borderRadius:4,border:"1px solid",borderColor:"divider",minHeight:280,background:I.palette.mode==="dark"?"linear-gradient(180deg, rgba(15,23,42,0.92), rgba(2,6,23,0.96))":"linear-gradient(180deg, rgba(241,245,249,1), rgba(226,232,240,0.92))"}),children:[jsxRuntime.jsx("video",{ref:v,muted:true,playsInline:true,autoPlay:true,style:{width:"100%",height:280,objectFit:"cover",display:"block"}}),jsxRuntime.jsx(material.Box,{sx:{pointerEvents:"none",position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:jsxRuntime.jsx(material.Box,{sx:{width:"72%",maxWidth:320,aspectRatio:"1.7 / 1",borderRadius:3,border:"2px solid rgba(255,255,255,0.95)",boxShadow:"0 0 0 999px rgba(15,23,42,0.24)",position:"relative"},children:jsxRuntime.jsx(material.Box,{sx:{position:"absolute",top:"50%",left:0,right:0,height:2,bgcolor:"#38bdf8",boxShadow:"0 0 18px rgba(56,189,248,0.85)"}})})}),jsxRuntime.jsxs(material.Box,{sx:{position:"absolute",top:12,left:12,display:"flex",gap:1,flexWrap:"wrap"},children:[jsxRuntime.jsx(material.Chip,{icon:jsxRuntime.jsx(bC__default.default,{}),label:y==="ready"?"Camera ready":y==="starting"?"Starting camera":y==="unsupported"?"Preview only":y==="error"?"Scanner error":"Idle",size:"small",color:y==="error"?"error":"primary",variant:"filled"}),R?jsxRuntime.jsx(material.Chip,{icon:jsxRuntime.jsx(xC__default.default,{}),label:`${R.format||"barcode"}: ${R.rawValue}`,size:"small",color:"success",variant:"filled"}):null]})]}),A?jsxRuntime.jsx(material.Alert,{severity:y==="unsupported"?"info":"warning",children:A}):null,i?jsxRuntime.jsxs(material.Stack,{direction:{xs:"column",sm:"row"},spacing:1.25,children:[jsxRuntime.jsx(material.TextField,{fullWidth:true,label:"Barcode",placeholder:g,value:S,onChange:I=>B(I.target.value)}),jsxRuntime.jsx(material.Button,{variant:"contained",onClick:T,sx:{minHeight:56,px:2.5},children:l})]}):null]})}),jsxRuntime.jsx(material.DialogActions,{sx:{px:3,pb:2},children:jsxRuntime.jsx(material.Button,{onClick:t,children:s})})]})};var wC={default:"#475569",primary:"#1d4ed8",success:"#047857",warning:"#b45309",error:"#b91c1c",info:"#0369a1"},H5=({title:e,description:t,kicker:o,icon:a,badges:r=[],metrics:n=[],footer:i,children:c,selected:d=false,draggable:l=false,isDragging:s=false,swipeThreshold:g=88,startAction:f,endAction:u,dragHandleProps:h,onClick:v,onSwipe:p,sx:C})=>{let[m,y]=ht.useState(0),[x,S]=ht.useState(false),B=ht.useRef(null),R=ht.useRef(0),w=ht.useRef(0),A=!!(f||u),P=132,k=()=>{y(0),S(false),B.current=null,R.current=0,w.current=0;},D=V=>{(V==="start"?f:u)?.onTrigger?.(),p?.(V),k();},T=V=>{!A||V.target.closest('button, a, input, textarea, [data-no-swipe="true"]')||(B.current=V.pointerId,R.current=V.clientX,w.current=V.clientX,S(true),V.currentTarget.setPointerCapture(V.pointerId));},I=V=>{if(!x||B.current!==V.pointerId)return;w.current=V.clientX;let J=w.current-R.current,ce=Math.max(-P,Math.min(P,J));y(ce);},M=V=>{if(!x||B.current!==V.pointerId)return;let J=w.current-R.current;if(J>=g&&f){D("start");return}if(J<=-g&&u){D("end");return}Math.abs(J)<12&&v?.(),k();},H=(V,J)=>{if(!V)return null;let ce=V.backgroundColor||wC[V.tone||"default"];return jsxRuntime.jsx(material.Box,{sx:{position:"absolute",top:0,bottom:0,[J]:0,width:P,px:2,display:"flex",alignItems:"center",justifyContent:J==="left"?"flex-start":"flex-end",color:"#fff",background:`linear-gradient(135deg, ${ce}, rgba(15,23,42,0.92))`},children:jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[V.icon,jsxRuntime.jsx(material.Typography,{sx:{fontWeight:700,fontSize:"0.95rem"},children:V.label})]})})};return jsxRuntime.jsxs(material.Box,{sx:{position:"relative",overflow:"hidden",borderRadius:4,...C},children:[H(f,"left"),H(u,"right"),jsxRuntime.jsx(material.Paper,{elevation:0,onPointerDown:T,onPointerMove:I,onPointerUp:M,onPointerCancel:k,sx:V=>({position:"relative",zIndex:1,p:2,borderRadius:4,border:"1px solid",borderColor:d?"primary.main":"divider",background:V.palette.mode==="dark"?"linear-gradient(180deg, rgba(30,41,59,0.96), rgba(15,23,42,0.92))":"linear-gradient(180deg, #ffffff, #f8fafc)",color:"text.primary",boxShadow:d?"0 18px 42px rgba(37, 99, 235, 0.18)":"0 12px 28px rgba(15, 23, 42, 0.08)",transform:`translate3d(${m}px, 0, 0) scale(${s?.985:1})`,transition:x?"none":"transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease",touchAction:"pan-y",cursor:v?"pointer":"default",opacity:s?.9:1}),children:jsxRuntime.jsxs(material.Stack,{spacing:1.5,children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[a?jsxRuntime.jsx(material.Box,{sx:{mt:.25},children:a}):null,jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[o?jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",fontWeight:700,letterSpacing:"0.08em",color:"text.secondary"},children:o}):null,jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1.05rem",fontWeight:800,lineHeight:1.25},children:e}),t?jsxRuntime.jsx(material.Typography,{sx:{mt:.5,fontSize:"0.9rem",color:"text.secondary",lineHeight:1.45},children:t}):null]}),l?jsxRuntime.jsx(material.Box,{"data-no-swipe":"true",...h,sx:{alignSelf:"center",display:"inline-flex",touchAction:"none"},children:jsxRuntime.jsx(material.IconButton,{size:"small",children:jsxRuntime.jsx(SC__default.default,{})})}):null]}),r.length>0?jsxRuntime.jsx(material.Stack,{direction:"row",spacing:1,useFlexGap:true,flexWrap:"wrap",children:r.map((V,J)=>jsxRuntime.jsx(material.Chip,{label:V,size:"small",sx:{borderRadius:999,fontWeight:700,bgcolor:"action.hover",color:"text.primary"}},J))}):null,n.length>0?jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(110px, 1fr))",gap:1},children:n.map(V=>jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{p:1.25,borderRadius:3,bgcolor:"action.hover",border:"1px solid",borderColor:"divider",color:"text.primary"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:V.label}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:800,lineHeight:1.2},children:V.value})]},V.id))}):null,c,i]})})]})};var mi=({label:e,onPress:t,emphasis:o="default"})=>jsxRuntime.jsx(material.Box,{component:"button",type:"button",onClick:t,sx:a=>({minHeight:72,borderRadius:3,border:"1px solid",borderColor:o==="primary"?"primary.main":"divider",background:o==="primary"?a.palette.primary.main:o==="danger"?a.palette.mode==="dark"?"rgba(239,68,68,0.18)":"rgba(239,68,68,0.10)":a.palette.mode==="dark"?"rgba(255,255,255,0.04)":"#fff",color:o==="primary"?"#fff":"text.primary",fontSize:"1.25rem",fontWeight:800,transition:"transform 120ms ease, box-shadow 160ms ease, background-color 160ms ease",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent","&:active":{transform:"scale(0.98)"}}),children:e}),Q5=({value:e,defaultValue:t="",title:o,subtitle:a,placeholder:r="0",allowDecimal:n=false,allowNegative:i=false,maxLength:c,confirmLabel:d,clearLabel:l,backspaceLabel:s,onChange:g,onSubmit:f,onClose:u,sx:h})=>{let{t:v}=Q(),[p,C]=ht.useState(t),m=e??p,y=k=>{e===void 0&&C(k),g?.(k);},x=k=>{c&&m.length>=c||y(`${m}${k}`);},S=k=>{if(k==="00"){if(!m){y("0");return}x("00");return}x(k);},B=()=>{!n||m.includes(".")||y(m?`${m}.`:"0.");},R=()=>{if(i){if(m.startsWith("-")){y(m.slice(1));return}y(m?`-${m}`:"-");}},w=()=>{y(m.slice(0,-1));},A=()=>{y("");},P=()=>{f?.(m);};return jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:2,borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",...h},children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsxs(material.Stack,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[jsxRuntime.jsxs(material.Box,{sx:{minWidth:0},children:[o?jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:800},children:o}):null,a?jsxRuntime.jsx(material.Typography,{sx:{mt:.5,fontSize:"0.86rem",color:"text.secondary"},children:a}):null]}),u?jsxRuntime.jsx(material.IconButton,{onClick:u,size:"small",children:jsxRuntime.jsx(RC__default.default,{})}):null]}),jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:2,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"action.hover"},children:jsxRuntime.jsx(material.Typography,{sx:{minHeight:38,fontSize:m?"1.9rem":"1.25rem",fontWeight:900,letterSpacing:"0.06em",color:m?"text.primary":"text.disabled"},children:m||r})}),jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:1.25},children:[["1","2","3","4","5","6","7","8","9"].map(k=>jsxRuntime.jsx(mi,{label:k,onPress:()=>S(k)},k)),jsxRuntime.jsx(mi,{label:i?"+/-":"00",onPress:i?R:()=>S("00")}),jsxRuntime.jsx(mi,{label:"0",onPress:()=>S("0")}),jsxRuntime.jsx(mi,{label:n?".":s?String(s):"DEL",onPress:n?B:w})]}),jsxRuntime.jsxs(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:1.25},children:[jsxRuntime.jsx(material.Box,{component:"button",type:"button",onClick:w,sx:{minHeight:64,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent"},children:jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,justifyContent:"center",alignItems:"center",children:[jsxRuntime.jsx(PC__default.default,{}),jsxRuntime.jsx(material.Typography,{sx:{fontWeight:700},children:s||"DEL"})]})}),jsxRuntime.jsx(mi,{label:String(l||"CLR"),onPress:A,emphasis:"danger"}),jsxRuntime.jsx(material.Box,{component:"button",type:"button",onClick:P,sx:k=>({minHeight:64,borderRadius:3,border:"1px solid",borderColor:"primary.main",background:k.palette.primary.main,color:"#fff",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent"}),children:jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,justifyContent:"center",alignItems:"center",children:[jsxRuntime.jsx(DC__default.default,{}),jsxRuntime.jsx(material.Typography,{sx:{fontWeight:800},children:d||v("common.ok")})]})})]})]})})};var ym=({touchMode:e="comfortable",sx:t,...o})=>{let a=e==="expanded";return jsxRuntime.jsx(material.Box,{sx:{"& .MuiPaper-root":{borderRadius:4},"& .MuiAutocomplete-root":{minWidth:{xs:"100%",md:260}},"& .MuiAutocomplete-root .MuiInputBase-root":{backgroundColor:"transparent !important"},"& .MuiInputBase-root":{minHeight:a?56:50,borderRadius:3,fontSize:a?"0.98rem":"0.92rem"},"& .MuiInputBase-input":{py:a?1.6:1.25,fontSize:a?"0.98rem":"0.92rem"},"& .MuiInputLabel-root":{fontSize:a?"0.95rem":"0.88rem"},"& .MuiButton-root":{minHeight:a?48:44,px:a?2.25:1.75,borderRadius:3,fontSize:a?"0.95rem":"0.88rem",fontWeight:700},"& .MuiIconButton-root":{width:a?40:36,height:a?40:36},"& .MuiMenuItem-root":{minHeight:a?44:38,fontSize:a?"0.95rem":"0.88rem"},"& .MuiListSubheader-root":{py:1},"& .MuiCheckbox-root":{p:a?1:.75},"& .MuiFormControlLabel-label":{fontSize:a?"0.95rem":"0.88rem"},"& .MuiDialog-paper":{borderRadius:4},"& .MuiDialogTitle-root":{fontSize:a?"1.05rem":"0.98rem",fontWeight:800},"& .MuiDialogContent-root .MuiInputBase-root":{minHeight:52},'& .MuiGrid-root > .MuiGrid-item, & .MuiGrid-root > .MuiGrid-sizeXs-1, & .MuiGrid-root > [class*="MuiGrid-grid-"]':{minWidth:0},...t},children:jsxRuntime.jsx(ca,{...o})})};var zC=(e,t,o)=>{if(o?.(t),!!t.href){if(t.href.startsWith("http://")||t.href.startsWith("https://")){window.open(t.href,"_blank");return}e.push(t.href);}},vm=({items:e,selectedId:t,orientation:o="auto",onItemSelect:a,sx:r})=>{let n=styles.useTheme(),[i,c]=ht.useState(false);ht.useEffect(()=>{c(true);},[]);let d=material.useMediaQuery("(orientation: portrait)",{noSsr:true}),l=material.useMediaQuery(n.breakpoints.down("md"),{noSsr:true}),s=o==="auto"?d||l?"portrait":"landscape":o,g=navigation.useRouter();return jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:!i||s==="portrait"?"repeat(2, minmax(0, 1fr))":"repeat(auto-fit, minmax(180px, 1fr))",gap:1.5,...r},children:e.map(f=>{let u=f.id===t,h=f.color||(u?n.palette.primary.main:n.palette.divider);return jsxRuntime.jsx(material.Paper,{elevation:0,sx:{overflow:"hidden",borderRadius:4,border:"1px solid",borderColor:u?"primary.main":"divider",boxShadow:u?"0 18px 40px rgba(37, 99, 235, 0.16)":"none",bgcolor:n.palette.mode==="dark"?"rgba(30,41,59,0.6)":"background.paper"},children:jsxRuntime.jsx(material.Box,{component:"button",type:"button",disabled:f.disabled,onClick:()=>zC(g,f,a),sx:{width:"100%",p:2,minHeight:s==="portrait"?156:148,display:"block",border:0,background:"transparent",textAlign:"left",cursor:f.disabled?"not-allowed":"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent",color:"text.primary"},children:jsxRuntime.jsxs(material.Stack,{spacing:1.5,sx:{height:"100%"},children:[jsxRuntime.jsxs(material.Stack,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",children:[jsxRuntime.jsx(material.Box,{sx:{width:44,height:44,borderRadius:3,display:"grid",placeItems:"center",color:u?"#fff":"text.primary",background:u?h:"action.hover"},children:f.icon||jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:900},children:f.title.slice(0,1).toUpperCase()})}),f.badge!==void 0?jsxRuntime.jsx(material.Box,{sx:{minWidth:34,px:1,py:.4,borderRadius:999,bgcolor:u?"primary.main":"action.hover",color:u?"#fff":"text.secondary",textAlign:"center",fontWeight:800,fontSize:"0.8rem"},children:f.badge}):null]}),jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:800,lineHeight:1.25},children:f.title}),f.caption?jsxRuntime.jsx(material.Typography,{sx:{mt:.5,fontSize:"0.74rem",fontWeight:700,color:"text.secondary"},children:f.caption}):null,f.description?jsxRuntime.jsx(material.Typography,{sx:{mt:.75,fontSize:"0.84rem",lineHeight:1.45,color:"text.secondary"},children:f.description}):null]})]})})},f.id)})})};var wm=(e,t)=>t.trim()?e.reduce((o,a)=>{let r=a.title?.toLowerCase().includes(t.toLowerCase())||a.label?.toLowerCase().includes(t.toLowerCase())||a.description?.toLowerCase().includes(t.toLowerCase()),n=a.children?wm(a.children,t):[];return (r||n.length>0)&&o.push({...a,children:n.length>0?n:a.children}),o},[]):e,ZC=e=>{let t=new Set,o=a=>{a.forEach(r=>{r.children?.length&&(t.add(r.id),o(r.children));});};return o(e),t},Tm=({collapsed:e=false,onToggle:t,className:o="",maxHeight:a,menuData:r=[],colorMode:n="light",orientation:i="auto",headerSlot:c,footerSlot:d,activeHref:l,onItemSelect:s})=>{let{t:g}=Q(),f=styles.useTheme(),u=material.useMediaQuery("(orientation: portrait)"),h=material.useMediaQuery(f.breakpoints.down("md")),v=i==="auto"?u||h?"portrait":"landscape":i,p=n==="dark",C=navigation.useRouter(),m=navigation.usePathname(),[y,x]=ht.useState(""),[S,B]=ht.useState(new Set),R=ht.useMemo(()=>wm(r,y),[r,y]),w=ht.useMemo(()=>y.trim()?ZC(R):S,[S,R,y]);ht.useEffect(()=>{e&&B(new Set);},[e]);let A=I=>I.appurl||I.href||"",P=I=>{s?.(I);let M=A(I);if(M){if(M.startsWith("http://")||M.startsWith("https://")){window.open(M,"_blank");return}C.push(M);}},k=I=>{let M=!!I.children?.length;if(e&&M){t?.();return}if(M){B(H=>{let V=new Set(H);return V.has(I.id)?V.delete(I.id):V.add(I.id),V});return}P(I);},D=I=>{let M=l||m,H=A(I);return !!(H&&M===H)},T=(I,M=0)=>{let H=!!I.children?.length,V=w.has(I.id),J=D(I);return jsxRuntime.jsx(material.Box,{sx:{pl:M===0?0:1.5},children:jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{mb:1,overflow:"hidden",borderRadius:3,border:"1px solid",borderColor:J?"primary.main":"divider",bgcolor:J?"action.selected":"background.paper"},children:[jsxRuntime.jsxs(material.Box,{component:"button",type:"button",onClick:()=>k(I),sx:{width:"100%",px:1.5,py:1.4,display:"flex",alignItems:"center",gap:1.25,border:0,background:"transparent",textAlign:"left",cursor:"pointer",appearance:"none",WebkitAppearance:"none",WebkitTapHighlightColor:"transparent"},children:[jsxRuntime.jsx(material.Avatar,{variant:"rounded",sx:{width:40,height:40,bgcolor:J?"primary.main":"action.hover",color:J?"#fff":"text.primary"},children:I.icon||(I.title||I.label||"?").slice(0,1).toUpperCase()}),jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.95rem",fontWeight:800,lineHeight:1.2},children:I.title||I.label}),I.description?jsxRuntime.jsx(material.Typography,{sx:{mt:.4,fontSize:"0.78rem",color:"text.secondary",lineHeight:1.35},children:I.description}):null]}),H?jsxRuntime.jsx(_C__default.default,{sx:{transform:V?"rotate(180deg)":"rotate(0deg)",transition:"transform 180ms ease"}}):jsxRuntime.jsx(jC__default.default,{color:"action"})]}),H?jsxRuntime.jsx(material.Collapse,{in:V,children:jsxRuntime.jsx(material.Box,{sx:{px:1.25,pb:1.25},children:I.children?.map(ce=>T(ce,M+1))})}):null]})},I.id)};return e?jsxRuntime.jsx(material.Paper,{elevation:0,className:o,sx:{width:v==="portrait"?"100%":88,p:1,borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:p?"#101828":"rgba(255,255,255,0.88)",maxHeight:a?`${a}px`:void 0,overflowY:"auto"},children:jsxRuntime.jsxs(material.Stack,{spacing:1,children:[jsxRuntime.jsx(material.IconButton,{onClick:t,sx:{width:48,height:48,alignSelf:"center",bgcolor:"action.hover"},title:g("navigation.expand"),children:jsxRuntime.jsx(qC__default.default,{})}),r.map(I=>jsxRuntime.jsx(material.IconButton,{onClick:()=>k(I),sx:{width:56,height:56,alignSelf:"center",borderRadius:3,bgcolor:D(I)?"primary.main":"action.hover",color:D(I)?"#fff":"text.primary"},children:I.icon||(I.title||I.label||"?").slice(0,1).toUpperCase()},I.id))]})}):jsxRuntime.jsx(material.Paper,{elevation:0,className:o,sx:{width:v==="portrait"?"100%":320,p:1.25,borderRadius:5,border:"1px solid",borderColor:"divider",bgcolor:p?"#101828":"rgba(255,255,255,0.88)",maxHeight:a?`${a}px`:void 0,overflow:"hidden",display:"flex",flexDirection:"column"},children:jsxRuntime.jsxs(material.Stack,{spacing:1.25,sx:{flex:1,minHeight:0},children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[jsxRuntime.jsx(material.TextField,{value:y,onChange:I=>x(I.target.value),placeholder:g("navigation.searchPlaceholder"),size:"small",fullWidth:true,InputProps:{startAdornment:jsxRuntime.jsx(UC__default.default,{fontSize:"small",color:"action"})}}),v==="landscape"&&!e?jsxRuntime.jsx(material.IconButton,{onClick:t,sx:{bgcolor:"action.hover"},children:jsxRuntime.jsx(KC__default.default,{})}):null]}),c,jsxRuntime.jsx(material.Box,{sx:{flex:1,minHeight:0,overflowY:"auto",pr:.25},children:R.length>0?R.map(I=>T(I)):jsxRuntime.jsx(material.Typography,{sx:{p:2,fontSize:"0.88rem",color:"text.secondary",textAlign:"center"},children:g("navigation.noMatch")})}),d]})})};var Em=(e,t)=>{let o=t[e.id];if(e.render)return e.render(o,t);if(o==null||o==="")return "--";if(e.numeric){if(typeof o=="number")return o.toLocaleString();if(typeof o=="string"&&o.trim()!==""&&!Number.isNaN(Number(o)))return Number(o).toLocaleString()}return String(o)},tk=e=>ht__namespace.default.isValidElement(e)?jsxRuntime.jsx(material.Box,{sx:{display:"inline-flex",alignItems:"center"},children:e}):jsxRuntime.jsx(material.Typography,{sx:{mt:.2,fontSize:"0.88rem",fontWeight:800},children:e}),ok=(e,t)=>{let o=t[e.id];if(o==null||o==="")return "--";if(e.numeric){if(typeof o=="number")return o.toLocaleString();if(typeof o=="string"&&o.trim()!==""&&!Number.isNaN(Number(o)))return Number(o).toLocaleString()}return String(o)},ak=({summaryRow:e,visibleColumns:t,columns:o})=>{let a=o.filter(r=>t.includes(r.id)&&e[r.id]!=="");return a.length===0?null:jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:1.5,borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:"action.hover"},children:jsxRuntime.jsxs(material.Stack,{spacing:1,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.82rem",fontWeight:800,color:"text.secondary"},children:"Summary"}),jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(132px, 1fr))",gap:1},children:a.map(r=>jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{p:1.1,borderRadius:3,border:"1px solid",borderColor:"divider"},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:r.label}),jsxRuntime.jsx(material.Typography,{sx:{mt:.25,fontSize:"0.96rem",fontWeight:800},children:e[r.id]})]},`summary-${r.id}`))})]})})},rk=e=>{let{t}=Q(),o=styles.useTheme(),{title:a,showToolbar:r=true,selectionMode:n,selected:i=[],onSelectionChange:c,actions:d,extraTools:l,fitContainer:s=false,fullWidth:g=false,maxHeight:f,loading:u=false,rowsPerPageOptions:h=[20,50,100,-1],onLayoutSave:v,filterConfig:p,rowKey:C,tableKey:m="default",graphReport:y,quickCreate:x,quickEdit:S,quickDelete:B,serviceUrl:R,orientation:w="auto",cardTitleField:A,cardSubtitleFields:P,toolbarSlot:k,emptyState:D,rowHeight:T="comfortable",cardActionSlot:I,renderCardFooter:M,onRowClick:H}=e,V=a||t("table.title.default"),J=material.useMediaQuery("(orientation: portrait)"),ce=material.useMediaQuery(o.breakpoints.down("md")),te=w==="auto"?J||ce?"portrait":"landscape":w,{columns:ne,filterText:ee,setFilterText:Y,visibleColumns:Ze,showSummary:Ue,setShowSummary:ie,summaryColumns:Ie,grouping:Fe,setGrouping:Oe,expandedGroups:nt,groupAnchorEl:Le,setGroupAnchorEl:Xe,summaryAnchorEl:Zt,setSummaryAnchorEl:zt,anchorEl:Qe,setAnchorEl:lt,contextMenu:mt,sortedAndFilteredRows:_e,summaryRow:K,visibleRows:Ce,page:fe,setPage:be,rowsPerPage:Ne,setRowsPerPage:Ve,totalDisplayCount:Ht,setSelected:Nt,handleClick:Xt,toggleSummaryColumn:Qt,handleExport:Yt,handleCloseContextMenu:L,toggleColumnVisibility:$,toggleGroupExpand:j,toggleGroupField:_,handleExpandGroupRecursively:ke,handleCollapseGroupRecursively:Ee,handleLayoutLoad:Ye,handleVariantLoad:z,handleLayoutSave:W,effectiveAppId:G,currentLayoutData:ue,currentLayoutId:oe,layoutIdToLoad:Se,graphReportOpen:ge,handleOpenGraphReport:Pe,handleCloseGraphReport:he}=Yr(e),ze=y?.enabled??false,Be=ze&&(y?.interaction?.enabled??true),we=ji(),Me=C||"id",Tt=ht__namespace.default.useMemo(()=>({borderRadius:999,fontWeight:700,borderColor:styles.alpha(o.palette.divider,o.palette.mode==="dark"?.55:.3),bgcolor:o.palette.mode==="dark"?styles.alpha(o.palette.common.white,.06):styles.alpha(o.palette.background.paper,.92),color:o.palette.text.primary,"& .MuiChip-label":{px:1.05}}),[o]),Io=ht__namespace.default.useMemo(()=>({...Tt,borderColor:styles.alpha(o.palette.primary.main,o.palette.mode==="dark"?.42:.24),bgcolor:o.palette.mode==="dark"?styles.alpha(o.palette.primary.main,.16):styles.alpha(o.palette.primary.main,.08)}),[Tt,o]),Ct=ht__namespace.default.useMemo(()=>{let O=new Set(i);return _e.filter(ae=>O.has(ae?.[Me]))},[Me,i,_e]),It=Ct.length===1?Ct[0]:null,bo=!!x?.enabled,ka=!!S?.enabled,Rr=!!B?.enabled,Po=x?.fields,ro=x?.excludeFields||[],Za=x?.initialValues||{},Yo=S?.fields,Gt=S?.excludeFields||[],no=S?.editableFields||[],Vt=S?.nonEditableFields||[],We=S?.primaryKeys?.length?S.primaryKeys:[Me],[Jo,$o]=ht__namespace.default.useState(false),[ea,Xa]=ht__namespace.default.useState(false),[Ho,Qa]=ht__namespace.default.useState({}),[Ya,Go]=ht__namespace.default.useState(false),[ta,Sa]=ht__namespace.default.useState(false),[Ut,Ro]=ht__namespace.default.useState({}),[oa,xo]=ht__namespace.default.useState(false),[Uo,Ja]=ht__namespace.default.useState(false),Dr=u||ea||ta||Uo,wa=ht__namespace.default.useMemo(()=>{let O=[...ne];if(Array.isArray(Po)&&Po.length>0){let ae=new Set(Po);O=O.filter(q=>ae.has(q.id));}if(ro.length>0){let ae=new Set(ro);O=O.filter(q=>!ae.has(q.id));}return O.filter(ae=>!!ae?.id)},[ne,ro,Po]),er=ht__namespace.default.useMemo(()=>{let O=[...ne];if(Array.isArray(Yo)&&Yo.length>0){let ae=new Set(Yo);O=O.filter(q=>ae.has(q.id));}if(Gt.length>0){let ae=new Set(Gt);O=O.filter(q=>!ae.has(q.id));}return O.filter(ae=>!!ae?.id)},[ne,Gt,Yo]),aa=ht__namespace.default.useMemo(()=>new Set(We),[We]),Jt=ht__namespace.default.useMemo(()=>new Set(no),[no]),Do=ht__namespace.default.useMemo(()=>new Set(Vt),[Vt]),Mr=ht__namespace.default.useCallback(O=>Jt.size>0?Jt.has(O):!(Do.has(O)||aa.has(O)),[Jt,Do,aa]);ht__namespace.default.useEffect(()=>{!ge&&we.hasActiveFilters&&we.clearAll();},[we,ge]);let tr=()=>{let O={};wa.forEach(ae=>{O[ae.id]=Za[ae.id]??"";}),Qa(O),$o(true);},Ar=(O,ae)=>{Qa(q=>({...q,[O]:ae}));},Br=async()=>{if(!x?.onSubmit){$o(false);return}try{Xa(!0),await x.onSubmit(Ho),$o(!1);}finally{Xa(false);}},Er=()=>{if(!It)return;let O={};er.forEach(q=>{O[q.id]=It[q.id]??"";});let ae=S?.getInitialValues?{...O,...S.getInitialValues(It)}:O;Ro(ae),Go(true);},io=(O,ae)=>{Ro(q=>({...q,[O]:ae}));},Fr=async()=>{if(It){if(!S?.onSubmit){Go(false);return}try{Sa(!0),await S.onSubmit(Ut,It),Go(!1);}finally{Sa(false);}}},Lr=()=>{Ct.length!==0&&xo(true);},or=async()=>{if(Ct.length===0){xo(false);return}if(!B?.onConfirm){xo(false),Nt([]),c?.([]);return}try{Ja(!0),await B.onConfirm(Ct),xo(!1),Nt([]),c?.([]);}finally{Ja(false);}},ra=_e,{fieldMapping:Ta}=jr({rows:ra,config:{...y,title:y?.title||`${V} ${t("graph.reportTitle")}`}}),Ia=ht__namespace.default.useMemo(()=>Be?we.applyRows(ra,Ta):ra,[Ta,we,Be,ra]),{model:b}=jr({rows:Ia,config:{...y,title:y?.title||`${V} ${t("graph.reportTitle")}`,fieldMapping:Ta}}),E=b.table.columns.map(O=>({id:O.id,label:O.label,align:O.align||"left",minWidth:120,numeric:O.align==="right"})),F=G?jsxRuntime.jsx(rs,{appId:G,tableKey:m,currentLayoutData:ue,onLayoutLoad:Ye,targetLayoutId:Se,activeLayoutId:oe,serviceUrl:R??p?.serviceUrl}):null,U=ne.filter(O=>Ze.includes(O.id)),re=U.find(O=>O.id===A)||U[0],ve=P?.map(O=>U.find(ae=>ae.id===O)).filter(Boolean)||U.filter(O=>O.id!==re?.id).slice(0,te==="portrait"?2:3),N=U.filter(O=>O.id!==re?.id&&!ve.some(ae=>ae.id===O.id)),X=[k,l].filter(Boolean),Z=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Nr,{groupAnchorEl:Le,setGroupAnchorEl:Xe,grouping:Fe,setGrouping:Oe,columns:ne,toggleGroupField:_}),jsxRuntime.jsx(Vr,{anchorEl:Qe,setAnchorEl:lt,columns:ne,visibleColumns:Ze,toggleColumnVisibility:$}),jsxRuntime.jsx(Di,{anchorEl:Zt,setAnchorEl:zt,showSummary:Ue,setShowSummary:ie,columns:ne,summaryColumns:Ie,toggleSummaryColumn:Qt}),jsxRuntime.jsx(Mi,{contextMenu:mt,handleCloseContextMenu:L,columns:ne,visibleColumns:Ze,toggleColumnVisibility:$})]}),Je=(O,ae,q)=>{let de=i.includes(ae),$e=te==="portrait"?"repeat(2, minmax(0, 1fr))":"repeat(auto-fit, minmax(140px, 1fr))",Ko=q%2===0?styles.alpha(o.palette.primary.main,o.palette.mode==="dark"?.09:.04):styles.alpha(o.palette.primary.main,o.palette.mode==="dark"?.05:.022),Ng=styles.alpha(o.palette.divider,.22);return jsxRuntime.jsx(material.Paper,{elevation:0,onClick:()=>{Xt({},O),H?.(O);},sx:{p:T==="compact"?1.25:1.5,borderRadius:4,border:"0.5px solid",borderColor:de?styles.alpha(o.palette.primary.main,.38):Ng,background:de?`linear-gradient(135deg, ${styles.alpha(o.palette.primary.main,.13)}, ${styles.alpha(o.palette.primary.main,.06)})`:`linear-gradient(135deg, ${Ko}, ${styles.alpha(o.palette.primary.main,.015)})`,boxShadow:de?`0 12px 30px ${styles.alpha(o.palette.primary.main,.2)}`:`0 3px 10px ${styles.alpha(o.palette.common.black,.045)}`,cursor:"pointer",position:"relative",overflow:"hidden",transition:"border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease, background 160ms ease","&::before":{content:'""',position:"absolute",left:0,top:0,bottom:0,width:4,background:de?o.palette.primary.main:q%2===0?styles.alpha(o.palette.primary.main,.26):styles.alpha(o.palette.text.primary,.16)},"&:hover":{boxShadow:`0 10px 20px ${styles.alpha(o.palette.primary.main,.12)}`,transform:"translateY(-1px)"},"&:active":{transform:"scale(0.995)"}},children:jsxRuntime.jsxs(material.Stack,{spacing:1.25,children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.25,alignItems:"flex-start",children:[n?jsxRuntime.jsx(material.Checkbox,{checked:de,onClick:so=>so.stopPropagation(),onChange:()=>Xt({},O),sx:{mt:-0.6,ml:-0.6}}):null,jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[re?jsxRuntime.jsx(material.Typography,{sx:{fontSize:"1rem",fontWeight:900,lineHeight:1.25},children:Em(re,O)}):null,ve.length>0?jsxRuntime.jsx(material.Stack,{direction:"row",spacing:.75,useFlexGap:true,flexWrap:"wrap",sx:{mt:.75},children:ve.map(so=>jsxRuntime.jsx(material.Chip,{label:`${so.label}: ${ok(so,O)}`,size:"small",variant:"outlined",sx:Tt},`${ae}-${so.id}`))}):null]}),I?jsxRuntime.jsx(material.Box,{onClick:so=>so.stopPropagation(),children:I(O)}):null]}),N.length>0?jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:$e,gap:1},children:N.map(so=>jsxRuntime.jsxs(material.Paper,{elevation:0,sx:{p:1,borderRadius:3,bgcolor:o.palette.mode==="dark"?styles.alpha(o.palette.background.default,.7):styles.alpha(o.palette.background.paper,.92),border:"0.1px solid",borderColor:styles.alpha(o.palette.divider,.24)},children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:so.label}),tk(Em(so,O))]},`${ae}-${so.id}-detail`))}):null,M?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsx(material.Box,{onClick:so=>so.stopPropagation(),children:M(O)})]}):null]})},ae)};return jsxRuntime.jsxs(material.Box,{sx:{width:g?"100%":"auto",mb:s?0:2,...s?{flex:1,display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"hidden"}:{}},children:[p?jsxRuntime.jsx(material.Box,{sx:{mb:2},children:jsxRuntime.jsx(ym,{...p,onVariantLoad:O=>{z(O),p.onVariantLoad?.(O);},appId:p.appId,tableKey:m,currentLayout:[{tableKey:m,layoutData:ue}],currentLayoutId:oe,layoutRefs:[{tableKey:m,layoutId:oe}],variantService:p.variantService,serviceUrl:R??p.serviceUrl,touchMode:te==="portrait"?"expanded":"comfortable"})}):null,jsxRuntime.jsxs(material.Paper,{sx:{width:g?"100%":"auto",mb:s?0:2,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative",bgcolor:"transparent",backgroundImage:"none",boxShadow:"none","&::before":Dr?{content:'""',position:"absolute",top:0,left:0,width:"100%",height:"3px",background:"linear-gradient(90deg, rgba(25, 118, 210, 0) 0%, rgba(25, 118, 210, 0.25) 25%, rgba(25, 118, 210, 1) 50%, rgba(25, 118, 210, 0.25) 75%, rgba(25, 118, 210, 0) 100%)",backgroundSize:"220% 100%",animation:"cTableTopMarquee 1.2s linear infinite",zIndex:6,pointerEvents:"none"}:{},"@keyframes cTableTopMarquee":{"0%":{backgroundPosition:"220% 0"},"100%":{backgroundPosition:"-120% 0"}},...f?{height:f}:s?{flex:1,minHeight:0,height:"100%"}:{}},children:[r?jsxRuntime.jsx(material.Box,{sx:{"& .MuiToolbar-root":{minHeight:60,alignItems:{xs:"flex-start",md:"center"},flexWrap:"wrap",rowGap:1,columnGap:1},"& .MuiToolbar-root > :nth-of-type(1)":{width:{xs:"100%",md:"auto"},"& .MuiTextField-root":{width:{xs:"100%",md:300}}},"& .MuiToolbar-root > :nth-of-type(2)":{flexShrink:0},"& .MuiToolbar-root > :nth-of-type(3)":{display:{xs:"none",md:"block"}},"& .MuiToolbar-root > :nth-of-type(4)":{ml:"auto",justifyContent:"flex-end",flexWrap:"wrap"},"& .MuiInputBase-root":{minHeight:46},"& .MuiIconButton-root":{width:40,height:40},"& .MuiTypography-root":{fontSize:"0.9rem"},"& .MuiButtonBase-root":{borderRadius:2.5}},children:jsxRuntime.jsx(wi,{filterText:ee,setFilterText:Y,onRowsPerPageChange:Ve,rowsPerPage:Ne,rowsPerPageOptions:h,page:fe,count:Ht,onPageChange:be,actions:d,extraTools:X,grouping:Fe,setGroupAnchorEl:Xe,showSummary:Ue,setShowSummary:ie,setAnchorEl:lt,setSummaryAnchorEl:zt,handleExport:Yt,showCreateButton:bo,onOpenCreateDialog:tr,showEditButton:ka,onOpenEditDialog:Er,editDisabled:Ct.length!==1,showDeleteButton:Rr,onOpenDeleteConfirm:Lr,deleteDisabled:Ct.length===0,onLayoutSave:v||p?.variantService&&p?.appId?W:void 0,loading:u,layoutManager:F,onOpenGraphReport:ze?Pe:void 0})}):null,jsxRuntime.jsx(material.Box,{sx:{flex:1,minHeight:0,overflow:"auto",p:1.5},children:jsxRuntime.jsxs(material.Stack,{spacing:1.25,children:[Ce.length===0&&!u?D||jsxRuntime.jsx(material.Paper,{elevation:0,sx:{p:4,borderRadius:4,border:"1px dashed",borderColor:"divider",textAlign:"center"},children:jsxRuntime.jsx(material.Typography,{sx:{fontSize:"0.92rem",color:"text.secondary"},children:t("common.noData")})}):null,Ce.map((O,ae)=>{if(O.type==="group"){let $e=nt.has(O.id);return jsxRuntime.jsx(material.Paper,{elevation:0,sx:{borderRadius:4,border:"1px solid",borderColor:"divider",bgcolor:"action.hover"},children:jsxRuntime.jsxs(material.Box,{component:"button",type:"button",onClick:()=>j(O.id),sx:{width:"100%",px:1.5,py:1.3,border:0,background:"transparent",display:"flex",alignItems:"center",gap:1,textAlign:"left",cursor:"pointer",appearance:"none",WebkitAppearance:"none",color:"text.primary"},children:[$e?jsxRuntime.jsx(_C__default.default,{}):jsxRuntime.jsx(jC__default.default,{}),jsxRuntime.jsxs(material.Box,{sx:{flex:1,minWidth:0},children:[jsxRuntime.jsxs(material.Typography,{sx:{fontSize:"0.94rem",fontWeight:800},children:[O.field,": ",O.value]}),jsxRuntime.jsxs(material.Typography,{sx:{mt:.2,fontSize:"0.76rem",color:"text.secondary"},children:[O.count," records"]})]}),Fe.length>1&&O.level<Fe.length-1?jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:.5,children:[jsxRuntime.jsx(material.Chip,{size:"small",label:t("table.group.expandAll"),onClick:Ko=>{Ko.stopPropagation(),ke(O.id);},sx:Io}),jsxRuntime.jsx(material.Chip,{size:"small",label:t("table.group.collapseAll"),onClick:Ko=>{Ko.stopPropagation(),Ee(O.id);},sx:Io})]}):null]})},O.id)}let q=O.data||O,de=O.id||q[Me]||ae;return Je(q,de,ae)}),Ue?jsxRuntime.jsx(ak,{summaryRow:K,visibleColumns:Ze,columns:ne}):null,u?jsxRuntime.jsx(material.Typography,{sx:{py:1,fontSize:"0.84rem",color:"text.secondary",textAlign:"center"},children:t("common.loading")}):null]})})]}),bo?jsxRuntime.jsxs(material.Dialog,{open:Jo,onClose:()=>!ea&&$o(false),fullWidth:true,maxWidth:"sm",children:[jsxRuntime.jsx(material.DialogTitle,{sx:{fontSize:"1rem",fontWeight:800},children:x?.title||t("quickCreate.createWithTitle",{title:V})}),jsxRuntime.jsx(material.DialogContent,{sx:{pt:"8px !important"},children:jsxRuntime.jsxs(material.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[wa.map(O=>{let ae=O.type==="number"||O.numeric?"number":O.type==="date"?"date":"text";return jsxRuntime.jsx(material.TextField,{label:O.label||O.id,value:Ho[O.id]??"",onChange:q=>Ar(O.id,q.target.value),type:ae,fullWidth:true,InputLabelProps:{shrink:ae==="date"?true:void 0}},`quick-create-${O.id}`)}),x?.description?jsxRuntime.jsx(material.Alert,{severity:"info",children:x.description}):null]})}),jsxRuntime.jsxs(material.DialogActions,{sx:{px:3,pb:2},children:[jsxRuntime.jsx(material.Button,{onClick:()=>$o(false),disabled:ea,children:x?.cancelLabel||t("common.cancel")}),jsxRuntime.jsx(material.Button,{onClick:Br,variant:"contained",disabled:ea,children:x?.submitLabel||t("common.save")})]})]}):null,ka?jsxRuntime.jsxs(material.Dialog,{open:Ya,onClose:()=>!ta&&Go(false),fullWidth:true,maxWidth:"sm",children:[jsxRuntime.jsx(material.DialogTitle,{sx:{fontSize:"1rem",fontWeight:800},children:S?.title||t("quickEdit.editWithTitle",{title:V})}),jsxRuntime.jsx(material.DialogContent,{sx:{pt:"8px !important"},children:jsxRuntime.jsxs(material.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[er.map(O=>{let ae=O.type==="number"||O.numeric?"number":O.type==="date"?"date":"text";return jsxRuntime.jsx(material.TextField,{label:O.label||O.id,value:Ut[O.id]??"",onChange:q=>io(O.id,q.target.value),type:ae,disabled:!Mr(O.id),fullWidth:true,InputLabelProps:{shrink:ae==="date"?true:void 0}},`quick-edit-${O.id}`)}),S?.description?jsxRuntime.jsx(material.Alert,{severity:"info",children:S.description}):null]})}),jsxRuntime.jsxs(material.DialogActions,{sx:{px:3,pb:2},children:[jsxRuntime.jsx(material.Button,{onClick:()=>Go(false),disabled:ta,children:S?.cancelLabel||t("common.cancel")}),jsxRuntime.jsx(material.Button,{onClick:Fr,variant:"contained",disabled:ta||!It,children:S?.submitLabel||t("common.save")})]})]}):null,Rr?jsxRuntime.jsx(Rn,{open:oa,type:"warning",title:B?.title||t("quickDelete.confirmTitle"),message:B?.message||(Ct.length>1?t("quickDelete.confirmMessageMultiple",{count:Ct.length}):t("quickDelete.confirmMessageSingle")),confirmText:B?.confirmText||t("common.delete"),cancelText:B?.cancelText||t("common.cancel"),onClose:()=>!Uo&&xo(false),onConfirm:or}):null,Z,ze?jsxRuntime.jsx(qi,{open:ge,onClose:he,model:b,aiAssistant:y?.aiAssistant,interaction:Be?{enabled:true,filters:we.filters,fieldMapping:Ta,onPrimaryDimensionClick:O=>we.setFilter("primaryDimension",O),onSecondaryDimensionClick:O=>we.setFilter("secondaryDimension",O),onStatusClick:O=>we.setFilter("status",O),onClearFilter:we.clearFilter,onClearAll:we.clearAll}:void 0,tableContent:jsxRuntime.jsx(rk,{appId:G||"graph-report-internal",title:t("graph.dataBody"),columns:E,rows:b.table.rows,rowKey:"id",fullWidth:true,maxHeight:"420px",rowsPerPage:20,rowsPerPageOptions:[20,50,100],graphReport:{enabled:false},showSummary:false})}):null]})};var _E=({appTitle:e,children:t,menuData:o=[],workloadItems:a=[],workloadSelectedId:r,showNavigation:n=true,showWorkloadNav:i=true,orientation:c="auto",logo:d,headerSlot:l,actionSlot:s,portraitBottomSlot:g,contentSx:f,containerSx:u,user:h,onSearch:v,defaultNavigationOpen:p,navOpen:C,onNavOpenChange:m,onWorkloadSelect:y,locale:x="en",localeLabel:S,localeOptions:B,onLocaleChange:R,onUserSetting:w,onUserLogout:A,userMenuItems:P,leftHeaderSlot:k,rightHeaderSlot:D})=>{let T="orbcafe:page-layout-mode",[I,M]=ht.useState("system"),[H,V]=ht.useState("light"),[J,ce]=ht.useState(false),[te,ne]=ht.useState(false),ee=I==="system"?te?H:"light":I;ht.useEffect(()=>{ce(true);},[]),ht.useEffect(()=>{try{let mt=window.localStorage.getItem(T);(mt==="light"||mt==="dark"||mt==="system")&&M(mt);}catch{}ne(true);let Qe=window.matchMedia("(prefers-color-scheme: dark)"),lt=()=>{V(Qe.matches?"dark":"light");};return lt(),Qe.addEventListener("change",lt),()=>Qe.removeEventListener("change",lt)},[]),ht.useEffect(()=>{if(te)try{window.localStorage.setItem(T,I);}catch{}},[te,I]),ht.useEffect(()=>{ee==="dark"?(document.documentElement.classList.add("dark"),document.documentElement.style.colorScheme="dark"):(document.documentElement.classList.remove("dark"),document.documentElement.style.colorScheme="light");},[ee]);let Y=ht.useMemo(()=>styles.createTheme({palette:ee==="dark"?{mode:"dark",primary:{main:"#93c5fd"},background:{default:"#060913",paper:"#101826"},text:{primary:"#f8fafc",secondary:"rgba(226,232,240,0.74)"},divider:"rgba(148,163,184,0.18)",action:{hover:"rgba(148,163,184,0.10)",selected:"rgba(59,130,246,0.18)"}}:{mode:"light",background:{default:"#eef3f8",paper:"#ffffff"}},components:{MuiCssBaseline:{styleOverrides:{body:{backgroundColor:ee==="dark"?"#060913":"#eef3f8"}}},MuiPaper:{styleOverrides:{root:{backgroundImage:"none"}}}}}),[ee]),Ze=material.useMediaQuery("(orientation: portrait)"),Ue=material.useMediaQuery(Y.breakpoints.down("md")),ie=c==="auto"?!J||Ze||Ue?"portrait":"landscape":c,[Ie,Fe]=ht.useState({landscape:p??true,portrait:false}),Oe=Ie[ie],nt=C??Oe,Le=Qe=>{C===void 0&&Fe(lt=>({...lt,[ie]:Qe})),m?.(Qe);},Xe=jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[!J||n&&ie==="portrait"?jsxRuntime.jsx(material.IconButton,{onClick:()=>Le(!nt),sx:{bgcolor:"action.hover"},children:jsxRuntime.jsx(qC__default.default,{})}):null,k]}),Zt=jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[s,D]}),zt=jsxRuntime.jsx(Tm,{collapsed:ie==="landscape"?!nt:false,onToggle:()=>Le(!nt),menuData:o,orientation:ie,colorMode:ee,maxHeight:ie==="landscape"?900:void 0});return jsxRuntime.jsx(styles.ThemeProvider,{theme:Y,children:jsxRuntime.jsx(Si,{locale:x,children:jsxRuntime.jsxs(material.Box,{sx:[Qe=>({minHeight:"100vh",display:"flex",flexDirection:"column",background:Qe.palette.mode==="dark"?"linear-gradient(180deg, #0A0A0A 0%, #141414 55%, #1A1A1A 100%)":Qe.palette.background.default}),...Array.isArray(u)?u:[u]],children:[jsxRuntime.jsx(ws,{appTitle:e,logo:d===void 0?null:d,mode:I,onToggleMode:()=>M(Qe=>Qe==="system"?"dark":Qe==="dark"?"light":"system"),locale:x,localeLabel:S,localeOptions:B,onLocaleChange:R,user:h,onUserSetting:w,onUserLogout:A,userMenuItems:P,onSearch:v,leftSlot:Xe,rightSlot:Zt}),l?jsxRuntime.jsx(material.Box,{sx:{px:{xs:2,md:3},py:1.5,borderBottom:"1px solid",borderColor:"divider"},children:l}):null,jsxRuntime.jsxs(material.Box,{sx:{flex:1,minHeight:0,display:"flex",position:"relative"},children:[J&&n&&ie==="landscape"?jsxRuntime.jsx(material.Box,{sx:{p:1.5,pr:0,flexShrink:0},children:zt}):null,!J||n&&ie==="portrait"?jsxRuntime.jsx(material.Drawer,{open:nt,onClose:()=>Le(false),PaperProps:{sx:{width:"min(88vw, 360px)",p:1.25,bgcolor:"transparent",boxShadow:"none"}},children:zt}):null,jsxRuntime.jsx(material.Box,{sx:{flex:1,minWidth:0,minHeight:0,overflow:"auto",p:1.5,...f},children:jsxRuntime.jsxs(material.Stack,{spacing:1.5,children:[i&&a.length>0?jsxRuntime.jsx(vm,{items:a,selectedId:r,orientation:ie,onItemSelect:y}):null,jsxRuntime.jsx(material.Paper,{elevation:0,sx:{flex:1,minHeight:ie==="portrait"?420:560,p:{xs:1.25,md:1.5},borderRadius:5,border:"1px solid",borderColor:"divider",bgcolor:Y.palette.mode==="dark"?"rgba(15,23,42,0.72)":"rgba(255,255,255,0.72)",backdropFilter:"blur(12px)",color:"text.primary"},children:t})]})})]}),ie==="portrait"&&g?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsx(material.Box,{sx:{p:1.5},children:g})]}):null]})})})};var Om=Sk__default.default(()=>Promise.resolve().then(()=>(Vm(),Nm)).then(e=>e.COrbCanvas),{ssr:false,loading:()=>jsxRuntime.jsx("div",{className:"h-full w-full bg-transparent"})});function Kc({isRecording:e}){return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"pointer-events-none absolute inset-0 z-0 overflow-hidden",children:jsxRuntime.jsxs("div",{className:"relative flex h-full w-full items-center justify-center",children:[jsxRuntime.jsx("div",{className:"absolute inset-0",children:jsxRuntime.jsx(Om,{hue:0,hoverIntensity:.5,rotateOnHover:true,forceHoverState:true,backgroundColor:"transparent"})}),jsxRuntime.jsx("div",{className:"relative z-10 h-full w-1/3 mix-blend-overlay opacity-80",children:jsxRuntime.jsx(Om,{hue:10,hoverIntensity:.8,rotateOnHover:true,forceHoverState:true,backgroundColor:"transparent"})})]})})})}var tF=Kc;function Xs({onTextUpdate:e,onComplete:t,onError:o,wsUrl:a="ws://localhost:8765",silenceThresholdMs:r=2e3,minVolumeRms:n=.015}){let[i,c]=ht.useState(false),d=ht.useRef(null),l=ht.useRef(null),s=ht.useRef(null),g=ht.useRef(null),f=ht.useRef(null),u=ht.useRef(0),h=ht.useRef(false),v=ht.useRef(false),p=ht.useCallback(()=>{d.current&&(d.current.close(),d.current=null),g.current&&(g.current.disconnect(),g.current=null),f.current&&(f.current.disconnect(),f.current=null),l.current&&(l.current.getTracks().forEach(y=>y.stop()),l.current=null),s.current&&(s.current.close(),s.current=null),v.current=false,c(false);},[]),C=ht.useCallback(()=>{h.current||(h.current=true,d.current?.readyState===WebSocket.OPEN&&d.current.send(JSON.stringify({type:"stop"})),setTimeout(p,500));},[p]),m=ht.useCallback(async()=>{if(!(i||v.current)){v.current=true,h.current=false,u.current=Date.now();try{let y=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:16e3,echoCancellation:!0,noiseSuppression:!0}});l.current=y;let x=new WebSocket(a);d.current=x,x.onopen=()=>{c(!0),v.current=!1;},x.onmessage=A=>{try{let P=JSON.parse(A.data);if(P.type==="recognition")P.is_final?t(P.text):e?.(P.text);else if(P.type==="error"){let k=P.message||"Voice recognition error";o?.(k),C();}}catch{o?.("Failed to parse voice message");}},x.onerror=()=>{o?.("Voice service connection failed"),p();},x.onclose=()=>{p();};let S=window.AudioContext||window.webkitAudioContext;if(!S)throw new Error("AudioContext is not supported in this browser");let B=new S({sampleRate:16e3});s.current=B;let R=B.createMediaStreamSource(y);f.current=R;let w=B.createScriptProcessor(4096,1,1);g.current=w,w.onaudioprocess=A=>{if(d.current?.readyState!==WebSocket.OPEN)return;let P=A.inputBuffer.getChannelData(0),k=0;for(let I=0;I<P.length;I+=1)k+=P[I]*P[I];if(Math.sqrt(k/P.length)>n)u.current=Date.now();else if(Date.now()-u.current>r&&!h.current){C();return}let T=new Int16Array(P.length);for(let I=0;I<P.length;I+=1){let M=Math.max(-1,Math.min(1,P[I]));T[I]=M<0?M*32768:M*32767;}d.current.send(T.buffer);},R.connect(w),w.connect(B.destination);}catch{o?.("Cannot access microphone"),p();}}},[p,i,n,t,o,e,r,C,a]);return ht.useEffect(()=>p,[p]),{isRecording:i,startRecording:m,stopRecording:C}}var $m=ht.createContext(null);function Ek(e){if(!e||!(e instanceof HTMLElement))return false;let t=e.tagName;return !!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[data-voice-hotkey-ignore="true"]'))}function Fk({children:e,onVoiceSubmit:t,onVoicePartial:o,onVoiceError:a,longPressMs:r=200,disableSpaceTrigger:n=false,ignoreWhenFocusedInput:i=true,renderOverlay:c=true,wsUrl:d,silenceThresholdMs:l,minVolumeRms:s}){let[g,f]=ht.useState(false),[u,h]=ht.useState(false),v=ht.useRef(null),p=ht.useRef(false),C=ht.useRef(false),m=ht.useCallback(()=>{C.current=false,f(false);},[]),{isRecording:y,startRecording:x,stopRecording:S}=Xs({wsUrl:d,silenceThresholdMs:l,minVolumeRms:s,onTextUpdate:A=>{o?.(A);},onComplete:async A=>{try{A.trim()&&(h(!0),await t(A.trim()));}catch(P){let k=P instanceof Error?P.message:"Failed to process voice command";a?.(k);}finally{h(!1),m();}},onError:A=>{a?.(A),h(!1),p.current||m();}}),B=ht.useCallback(async()=>{C.current=false,await x();},[x]),R=ht.useCallback(()=>{S();},[S]);ht.useEffect(()=>{if(n)return;let A=k=>{k.isComposing||(k.code==="Space"||k.key===" ")&&(p.current||k.repeat||i&&Ek(document.activeElement)||(p.current=true,k.preventDefault(),v.current=setTimeout(()=>{C.current=true,f(true),x();},r)));},P=k=>{(k.code==="Space"||k.key===" ")&&(v.current&&(clearTimeout(v.current),v.current=null),p.current=false,C.current&&(k.preventDefault(),f(false),S()));};return window.addEventListener("keydown",A),window.addEventListener("keyup",P),()=>{window.removeEventListener("keydown",A),window.removeEventListener("keyup",P),v.current&&(clearTimeout(v.current),v.current=null);}},[n,i,r,x,S]);let w=ht.useMemo(()=>({isRecording:y,isHotkeyRecording:g,isSubmitting:u,startRecording:B,stopRecording:R}),[g,y,u,B,R]);return jsxRuntime.jsxs($m.Provider,{value:w,children:[c?jsxRuntime.jsx(Kc,{isRecording:g}):null,e]})}function Lk(){let e=ht.useContext($m);if(!e)throw new Error("useAINav must be used within CAINavProvider");return e}var cF=Fk,dF=Lk;function De(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var Hk=({content:e,theme:t="light",size:o="base",defaultExpanded:a=false})=>{let[r,n]=ht.useState(a),i=ht.useMemo(()=>`${(o==="sm"?14:o==="lg"?18:16)-2}px`,[o]);return jsxRuntime.jsxs("div",{className:`my-6 rounded-lg overflow-hidden transition-all duration-200 ${t==="dark"?"bg-gray-800":"bg-white"}`,style:{border:`0.5px solid ${t==="dark"?"#4b5563":"#d1d5db"}`},children:[jsxRuntime.jsxs("div",{className:`px-4 py-3 cursor-pointer flex items-center justify-between transition-colors duration-200 ${t==="dark"?"bg-gray-700 hover:bg-gray-650":"bg-gray-50 hover:bg-gray-100"}`,style:{borderBottom:`0.5px solid ${t==="dark"?"#4b5563":"#e5e7eb"}`},onClick:()=>n(!r),children:[jsxRuntime.jsxs("span",{className:"flex items-center",children:[jsxRuntime.jsx("span",{className:"mr-2",children:"\u{1F914}"}),jsxRuntime.jsx("span",{className:`font-medium ${t==="dark"?"text-gray-300":"text-gray-700"}`,style:{fontSize:o==="sm"?"14px":o==="lg"?"18px":"16px"},children:"\u601D\u8003\u8FC7\u7A0B"})]}),jsxRuntime.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${r?"rotate-180":""} ${t==="dark"?"text-gray-400":"text-gray-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),r&&jsxRuntime.jsx("div",{className:`p-4 whitespace-pre-wrap italic font-light ${t==="dark"?"text-gray-400":"text-gray-600"}`,style:{fontSize:i,lineHeight:"1.3 !important"},children:e})]})},Hm=Hk;var Xk=({content:e,language:t="text",isStreaming:o=false,className:a=""})=>{let{theme:r}=nextThemes.useTheme(),[n,i]=ht.useState(false),c=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3);}catch(l){console.error("\u590D\u5236\u5931\u8D25:",l);}},d=r==="dark"?prism.oneDark:prism.oneLight;return jsxRuntime.jsxs("div",{className:De("rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 my-4",a),children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 uppercase",children:t}),jsxRuntime.jsx("button",{onClick:c,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",disabled:o,title:n?"Copied":"Copy code",children:n?jsxRuntime.jsx(lucideReact.Check,{size:14,className:"text-green-500"}):jsxRuntime.jsx(lucideReact.Clipboard,{size:14,className:"text-gray-500 dark:text-gray-400"})})]}),jsxRuntime.jsx("div",{className:"text-sm",children:jsxRuntime.jsx(reactSyntaxHighlighter.Prism,{language:t,style:d,customStyle:{margin:0,padding:"16px",fontSize:"14px",lineHeight:"1.5",backgroundColor:r==="dark"?"#1f2937":"#ffffff"},wrapLongLines:true,children:e})})]})},Um=Xk;var eS=({content:e,isLoading:t,className:o="",style:a})=>{let r=ht.useRef(null),[n,i]=ht.useState(false),[c,d]=ht.useState(null),{theme:l}=nextThemes.useTheme();return ht.useEffect(()=>{let s=async()=>{if(!(!e.trim()||!r.current)){i(true),d(null);try{qm__default.default.initialize({startOnLoad:!1,theme:l==="dark"?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});let f=`mermaid-${Math.random().toString(36).substr(2,9)}`,u=e.replace(/```mermaid\n?|\n?```/g,"").trim(),{svg:h}=await qm__default.default.render(f,u);r.current&&(r.current.innerHTML=h);}catch(f){console.error("Mermaid render failed:",f),d(f instanceof Error?f.message:"Render failed"),r.current&&(r.current.innerText=e);}finally{i(false);}}},g=setTimeout(()=>{s();},100);return ()=>clearTimeout(g)},[e,l]),t||n?jsxRuntime.jsx("div",{className:`mermaid-block loading ${o}`,style:a,children:jsxRuntime.jsxs("div",{className:"flex items-center justify-center p-4 bg-gray-50 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500 mr-2"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:"Generating Diagram..."})]})}):c?jsxRuntime.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-red-600 dark:text-red-400 text-sm overflow-auto",children:[jsxRuntime.jsx("p",{className:"font-semibold mb-2",children:"Mermaid Error:"}),jsxRuntime.jsx("pre",{children:c}),jsxRuntime.jsx("pre",{className:"mt-4 text-xs text-gray-500",children:e})]}):jsxRuntime.jsx("div",{className:`mermaid-block overflow-x-auto ${o}`,style:a,ref:r})},jm=eS;var iS=({title:e="\u53D1\u751F\u9519\u8BEF",content:t,errorCode:o,stack:a,icon:r,closable:n=true,onClose:i,onRetry:c,className:d="",...l})=>{let[s,g]=ht.useState(false),[f,u]=ht.useState(false),h=async()=>{if(c){u(true);try{await c();}catch(v){console.error("\u91CD\u8BD5\u5931\u8D25:",v);}finally{u(false);}}};return jsxRuntime.jsxs("div",{className:`relative w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${d}`,...l,children:[jsxRuntime.jsxs("div",{className:"flex p-4 border-l-4 border-l-red-500 bg-red-50 dark:bg-red-900/10",children:[jsxRuntime.jsx("div",{className:"flex-shrink-0 mr-3 text-red-500 mt-0.5",children:r||jsxRuntime.jsx(lucideReact.AlertCircle,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[jsxRuntime.jsx("h4",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:e}),o&&jsxRuntime.jsx("span",{className:"text-xs font-mono px-1.5 py-0.5 rounded bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300",children:o})]}),t&&jsxRuntime.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 mb-3 leading-relaxed",children:typeof t=="string"?jsxRuntime.jsx("p",{className:"whitespace-pre-wrap",children:t}):t}),(c||a)&&jsxRuntime.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[c&&jsxRuntime.jsxs("button",{onClick:h,disabled:f,className:"flex items-center text-xs font-medium text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors disabled:opacity-50",children:[jsxRuntime.jsx(lucideReact.RotateCw,{className:`w-3.5 h-3.5 mr-1.5 ${f?"animate-spin":""}`}),f?"\u91CD\u8BD5\u4E2D...":"\u91CD\u8BD5"]}),a&&jsxRuntime.jsxs("button",{onClick:()=>g(!s),className:"flex items-center text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 transition-colors",children:[s?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3.5 h-3.5 mr-1"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3.5 h-3.5 mr-1"}),s?"\u9690\u85CF\u8BE6\u60C5":"\u67E5\u770B\u8BE6\u60C5"]})]})]}),n&&i&&jsxRuntime.jsx("button",{onClick:i,className:"flex-shrink-0 ml-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors self-start",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),a&&s&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 p-3 border-t border-gray-100 dark:border-gray-800",children:jsxRuntime.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 overflow-x-auto whitespace-pre-wrap p-2 bg-white dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-800",children:a})})]})},Qs=iS;var uS=({title:e="\u8B66\u544A",content:t,warningType:o,severity:a="warning",warnings:r=[],icon:n,closable:i=true,onClose:c,onConfirm:d,actionText:l,className:s="",...g})=>{let f=()=>{switch(a){case "info":return {borderLeftColor:"border-l-blue-500",iconColor:"text-blue-500",bgColor:"bg-blue-50 dark:bg-blue-900/10"};case "error":return {borderLeftColor:"border-l-red-500",iconColor:"text-red-500",bgColor:"bg-red-50 dark:bg-red-900/10"};case "success":return {borderLeftColor:"border-l-green-500",iconColor:"text-green-500",bgColor:"bg-green-50 dark:bg-green-900/10"};default:return {borderLeftColor:"border-l-yellow-500",iconColor:"text-yellow-500",bgColor:"bg-yellow-50 dark:bg-yellow-900/10"}}},u=()=>{switch(a){case "info":return jsxRuntime.jsx(lucideReact.Info,{className:"w-5 h-5"});case "error":return jsxRuntime.jsx(lucideReact.XCircle,{className:"w-5 h-5"});case "success":return jsxRuntime.jsx(lucideReact.CheckCircle,{className:"w-5 h-5"});default:return jsxRuntime.jsx(lucideReact.AlertTriangle,{className:"w-5 h-5"})}},h=f();return jsxRuntime.jsxs("div",{className:`relative w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${s}`,...g,children:[jsxRuntime.jsxs("div",{className:`flex p-4 border-l-4 ${h.borderLeftColor} ${h.bgColor}`,children:[jsxRuntime.jsx("div",{className:`flex-shrink-0 mr-3 ${h.iconColor}`,children:n||u()}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-1",children:[jsxRuntime.jsx("h4",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:e}),o&&jsxRuntime.jsx("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400",children:o})]}),t&&jsxRuntime.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 mb-2",children:t}),r&&r.length>0&&jsxRuntime.jsx("ul",{className:"mt-2 space-y-1",children:r.map((v,p)=>jsxRuntime.jsxs("li",{className:"flex items-start text-sm text-gray-600 dark:text-gray-300",children:[jsxRuntime.jsx("span",{className:"mr-2 mt-1.5 w-1 h-1 rounded-full bg-gray-400 dark:bg-gray-500 flex-shrink-0"}),jsxRuntime.jsx("span",{children:v})]},p))})]}),i&&c&&jsxRuntime.jsx("button",{onClick:c,className:"flex-shrink-0 ml-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]}),d&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-800/50 px-4 py-3 flex justify-end border-t border-gray-100 dark:border-gray-800",children:jsxRuntime.jsx("button",{onClick:d,className:"px-4 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",children:l||"\u786E\u8BA4"})})]})},Ys=uS;var hS=({title:e="\u76F8\u5173\u63A8\u8350",content:t,suggestions:o,onSuggestionClick:a,maxDisplay:r=5,icon:n,closable:i=false,onClose:c,className:d="",...l})=>{let[s,g]=ht.useState(false),[f,u]=ht.useState(""),[h,v]=ht.useState(false),p=ht.useMemo(()=>f.trim()?o.filter(y=>y.toLowerCase().includes(f.toLowerCase())):o,[o,f]),C=ht.useMemo(()=>s?p:p.slice(0,r),[p,s,r]),m=y=>{a?.(y);};return !o||o.length===0?null:jsxRuntime.jsxs("div",{className:`w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${d}`,...l,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-blue-50/30 dark:bg-blue-900/10",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2.5",children:[jsxRuntime.jsx("div",{className:"text-blue-500 flex-shrink-0",children:n||jsxRuntime.jsx(lucideReact.Lightbulb,{className:"w-5 h-5"})}),jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 leading-tight",children:e}),t&&jsxRuntime.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:t})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-1",children:[o.length>3&&jsxRuntime.jsx("button",{onClick:()=>v(!h),className:`p-1.5 rounded-md transition-colors ${h?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:h?"\u5173\u95ED\u641C\u7D22":"\u641C\u7D22\u95EE\u9898",children:jsxRuntime.jsx(lucideReact.Search,{className:"w-4 h-4"})}),i&&c&&jsxRuntime.jsx("button",{onClick:c,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",title:"\u5173\u95ED",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})]}),h&&jsxRuntime.jsx("div",{className:"px-4 py-2 border-b border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/50",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"text",placeholder:"\u641C\u7D22\u76F8\u5173\u95EE\u9898...",value:f,onChange:y=>u(y.target.value),className:"w-full text-sm px-3 py-1.5 pl-8 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-1 focus:ring-blue-500 focus:border-blue-500 outline-none transition-shadow",autoFocus:true}),jsxRuntime.jsx(lucideReact.Search,{className:"absolute left-2.5 top-2 w-3.5 h-3.5 text-gray-400"})]})}),jsxRuntime.jsxs("div",{className:"p-2",children:[jsxRuntime.jsx("ul",{className:"space-y-1",children:C.map((y,x)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsxs("button",{onClick:()=>m(y),className:"w-full text-left px-3 py-2 rounded-md text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-blue-600 dark:hover:text-blue-400 transition-colors group flex items-start justify-between",children:[jsxRuntime.jsx("span",{children:y}),jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-4 h-4 text-gray-300 group-hover:text-blue-400 opacity-0 group-hover:opacity-100 transition-all transform group-hover:translate-x-0.5"})]})},x))}),p.length>r&&jsxRuntime.jsx("button",{onClick:()=>g(!s),className:"w-full text-center py-2 text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors border-t border-gray-50 dark:border-gray-800/50 mt-1",children:s?"\u6536\u8D77":`\u67E5\u770B\u5168\u90E8 (${p.length})`}),p.length===0&&f&&jsxRuntime.jsx("div",{className:"text-center py-4 text-sm text-gray-500 dark:text-gray-400",children:"\u6CA1\u6709\u627E\u5230\u5339\u914D\u7684\u5EFA\u8BAE"})]})]})},Js=hS;var SS=({title:e,content:t,toolName:o,parameters:a,result:r,status:n,duration:i,icon:c,closable:d=false,onClose:l,onAction:s,actionText:g,className:f="",...u})=>{let[h,v]=ht.useState(false),[p,C]=ht.useState(true),m=()=>{switch(n){case "pending":return {iconColor:"text-blue-500",badgeBg:"bg-blue-50 dark:bg-blue-900/30",badgeText:"text-blue-600 dark:text-blue-400",label:"\u6267\u884C\u4E2D"};case "error":return {iconColor:"text-red-500",badgeBg:"bg-red-50 dark:bg-red-900/30",badgeText:"text-red-600 dark:text-red-400",label:"\u5931\u8D25"};default:return {iconColor:"text-green-500",badgeBg:"bg-green-50 dark:bg-green-900/30",badgeText:"text-green-600 dark:text-green-400",label:"\u6210\u529F"}}},y=()=>{switch(n){case "pending":return jsxRuntime.jsx(lucideReact.Loader2,{className:"w-5 h-5 animate-spin"});case "error":return jsxRuntime.jsx(lucideReact.XCircle,{className:"w-5 h-5"});default:return jsxRuntime.jsx(lucideReact.CheckCircle,{className:"w-5 h-5"})}},x=R=>R?R<1e3?`${R}ms`:`${(R/1e3).toFixed(2)}s`:"",S=m(),B=e||o||"\u5DE5\u5177\u8C03\u7528";return jsxRuntime.jsxs("div",{className:`w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md ${f}`,...u,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-3",children:[jsxRuntime.jsx("div",{className:`flex-shrink-0 ${S.iconColor}`,children:c||y()}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:B}),jsxRuntime.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${S.badgeBg} ${S.badgeText}`,children:S.label})]}),o&&e&&jsxRuntime.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 flex items-center mt-0.5",children:[jsxRuntime.jsx(lucideReact.Terminal,{className:"w-3 h-3 mr-1"}),o]})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400",children:[i&&jsxRuntime.jsxs("div",{className:"flex items-center bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:[jsxRuntime.jsx(lucideReact.Clock,{className:"w-3 h-3 mr-1"}),x(i)]}),d&&l&&jsxRuntime.jsx("button",{onClick:l,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1 rounded",children:jsxRuntime.jsx(lucideReact.X,{className:"w-4 h-4"})})]})]}),jsxRuntime.jsxs("div",{className:"p-4",children:[t&&jsxRuntime.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 mb-4 leading-relaxed",children:t}),a&&jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsxs("button",{onClick:()=>v(!h),className:"flex items-center text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 mb-2",children:[h?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3.5 h-3.5 mr-1"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3.5 h-3.5 mr-1"}),jsxRuntime.jsx(lucideReact.Box,{className:"w-3.5 h-3.5 mr-1.5"}),"\u8F93\u5165\u53C2\u6570"]}),h&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 rounded border border-gray-100 dark:border-gray-800 overflow-hidden",children:jsxRuntime.jsx("pre",{className:"p-3 text-xs font-mono text-gray-600 dark:text-gray-400 overflow-x-auto",children:JSON.stringify(a,null,2)})})]}),r&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{onClick:()=>C(!p),className:"flex items-center text-xs font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 mb-2",children:[p?jsxRuntime.jsx(lucideReact.ChevronDown,{className:"w-3.5 h-3.5 mr-1"}):jsxRuntime.jsx(lucideReact.ChevronRight,{className:"w-3.5 h-3.5 mr-1"}),jsxRuntime.jsx(lucideReact.Terminal,{className:"w-3.5 h-3.5 mr-1.5"}),"\u6267\u884C\u7ED3\u679C"]}),p&&jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 rounded border border-gray-100 dark:border-gray-800 overflow-hidden",children:jsxRuntime.jsx("pre",{className:"p-3 text-xs font-mono text-gray-600 dark:text-gray-400 overflow-x-auto",children:typeof r=="string"?r:JSON.stringify(r,null,2)})})]}),s&&jsxRuntime.jsx("div",{className:"mt-3 pt-3 border-t border-gray-100 dark:border-gray-800 flex justify-end",children:jsxRuntime.jsx("button",{onClick:s,className:"px-4 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",children:g||"\u6267\u884C\u64CD\u4F5C"})})]})]})},el=SS;var TS=({data:e})=>{if(!e)return null;let t=ht.useMemo(()=>{let o=[],a=[],r="\u6570\u636E\u8868\u683C";return Array.isArray(e)?(o=e,o.length>0&&(a=Object.keys(o[0]).map(n=>({id:n,label:n.charAt(0).toUpperCase()+n.slice(1),numeric:typeof o[0][n]=="number"})))):typeof e=="object"&&(r=e.title||r,o=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[],Array.isArray(e.columns)?a=e.columns.map(i=>({id:i.key||i.id,label:i.title||i.label,numeric:i.dataType==="number"||i.numeric})):o.length>0&&(a=Object.keys(o[0]).map(i=>({id:i,label:i,numeric:typeof o[0][i]=="number"})))),o=o.map((n,i)=>({...n,id:n.id||`row_${i}`})),{title:r,columns:a,rows:o}},[e]);return t.rows.length===0?jsxRuntime.jsx("div",{className:"w-full my-4 p-4 border border-dashed border-gray-300 rounded text-center text-gray-500",children:"\u6682\u65E0\u8868\u683C\u6570\u636E"}):jsxRuntime.jsx("div",{className:"w-full my-4",children:jsxRuntime.jsx(La,{appId:"agent-ui-table-card",title:t.title,columns:t.columns,rows:t.rows,count:t.rows.length,rowKey:"id",fitContainer:false,maxHeight:"500px",rowsPerPage:10,rowsPerPageOptions:[5,10,20,50]})})},tl=TS;var FS=({title:e,subtitle:t,data:o,type:a,config:r={}})=>{let n=()=>{switch(a){case "bar-chart-card":return jsxRuntime.jsx(lucideReact.BarChart,{className:"w-4 h-4 text-blue-500"});case "line-chart-card":return jsxRuntime.jsx(lucideReact.LineChart,{className:"w-4 h-4 text-green-500"});case "pie-chart-card":return jsxRuntime.jsx(lucideReact.PieChart,{className:"w-4 h-4 text-purple-500"});case "combo-chart-card":return jsxRuntime.jsx(lucideReact.Activity,{className:"w-4 h-4 text-orange-500"});case "heatmap-chart-card":return jsxRuntime.jsx(lucideReact.Grid,{className:"w-4 h-4 text-red-500"});case "fishbone-chart-card":return jsxRuntime.jsx(lucideReact.GitBranch,{className:"w-4 h-4 text-indigo-500"});case "waterfall-chart-card":return jsxRuntime.jsx(lucideReact.TrendingDown,{className:"w-4 h-4 text-teal-500"});case "google-map-card":return jsxRuntime.jsx(lucideReact.Globe,{className:"w-4 h-4 text-blue-600"});case "amap-card":return jsxRuntime.jsx(lucideReact.MapPin,{className:"w-4 h-4 text-blue-600"});default:return jsxRuntime.jsx(lucideReact.BarChart,{className:"w-4 h-4"})}},i=()=>{if(!o&&a!=="google-map-card"&&a!=="amap-card")return jsxRuntime.jsx("div",{className:"text-gray-500 text-sm p-4 text-center",children:"No data available"});try{switch(a){case "bar-chart-card":return jsxRuntime.jsx(En,{data:o,orientation:r.orientation||"horizontal",valueSuffix:r.valueSuffix||"",minHeight:r.minHeight});case "line-chart-card":return jsxRuntime.jsx($d,{data:o,color:r.color,valueSuffix:r.valueSuffix||"",height:r.height});case "pie-chart-card":let c=o.reduce((l,s)=>l+(Number(s.value)||0),0),d=o.map(l=>({name:l.name,value:Number(l.value)||0,percent:typeof l.percent=="number"?l.percent:c>0?(Number(l.value)||0)/c*100:0}));return jsxRuntime.jsx(Vi,{data:d,variant:r.variant||"donut",size:r.size,colors:r.colors});case "combo-chart-card":return jsxRuntime.jsx(Hd,{data:o,barColor:r.barColor,lineColor:r.lineColor});case "heatmap-chart-card":return jsxRuntime.jsx(Ud,{data:o});case "fishbone-chart-card":return jsxRuntime.jsx(qd,{branches:o,effect:r.effect||e||"Problem"});case "waterfall-chart-card":return jsxRuntime.jsx(jd,{data:o,height:r.height});case "google-map-card":return jsxRuntime.jsx(Qd,{embedUrl:r.embedUrl||o&&o[0]?.embedUrl,apiKey:r.apiKey,query:r.query||o&&o[0]?.query||e,height:r.height});case "amap-card":return jsxRuntime.jsx(tp,{embedUrl:r.embedUrl||o&&o[0]?.embedUrl,keyword:r.keyword||o&&o[0]?.keyword||e,height:r.height});default:return jsxRuntime.jsxs("div",{className:"text-gray-500 text-sm p-4 text-center",children:["Unsupported chart type: ",a]})}}catch(c){return console.error("Error rendering chart:",c),jsxRuntime.jsx("div",{className:"text-red-500 text-sm p-4 text-center",children:"Error rendering chart"})}};return jsxRuntime.jsxs("div",{className:"w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/50",children:[jsxRuntime.jsx("div",{className:"mr-2 flex-shrink-0",children:n()}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:e}),t&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 truncate",children:t})]})]}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("div",{className:"overflow-x-auto",children:i()}),jsxRuntime.jsx("div",{className:"mt-3",children:jsxRuntime.jsxs("details",{className:"text-xs text-gray-500 dark:text-gray-400",children:[jsxRuntime.jsx("summary",{className:"cursor-pointer hover:text-gray-700 dark:hover:text-gray-300 transition-colors select-none font-medium opacity-60 hover:opacity-100",children:"View Raw Data"}),jsxRuntime.jsx("pre",{className:"mt-2 p-2 bg-gray-50 dark:bg-gray-950 rounded border border-gray-100 dark:border-gray-800 overflow-x-auto max-h-40",children:JSON.stringify(o,null,2)})]})})]})]})},ol=FS;var zS=({type:e,manifest:t})=>jsxRuntime.jsxs("div",{className:"w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shadow-sm transition-all hover:shadow-md",children:[jsxRuntime.jsxs("div",{className:"flex items-center px-4 py-3 border-b border-gray-100 dark:border-gray-800 bg-blue-50/50 dark:bg-blue-900/10",children:[jsxRuntime.jsx(lucideReact.Box,{className:"w-4 h-4 mr-2 text-blue-600 dark:text-blue-400"}),jsxRuntime.jsxs("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:["SAP Card: ",e]})]}),jsxRuntime.jsx("div",{className:"p-4",children:jsxRuntime.jsx("div",{className:"bg-gray-50 dark:bg-gray-950 p-3 rounded border border-gray-100 dark:border-gray-800 overflow-x-auto",children:jsxRuntime.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:JSON.stringify(t,null,2)})})})]}),rl=zS;var nl=e=>{let t;try{t=JSON.parse(e);}catch{return null}return t&&typeof t=="object"&&((t.type==="bar-chart-card"||t.type==="line-chart-card"||t.type==="pie-chart-card"||t.type==="combo-chart-card"||t.type==="heatmap-chart-card"||t.type==="fishbone-chart-card"||t.type==="waterfall-chart-card"||t.type==="google-map-card"||t.type==="amap-card")&&t.title||(t.type==="sap-analytical-card"||t.type==="sap-list-card"||t.type==="sap-object-card"||t.type==="sap-component-card")&&t.manifest||t.type==="error-card"||t.type==="warning-card"||t.type==="suggestions-card"||t.type==="tool-result-card"||t.type==="table"&&t.data)?t:null};var HS=({content:e,theme:t,size:o="base",className:a,enableCodeHighlight:r=true,enableMermaid:n=true,messageId:i,cardHooks:c})=>{let d=ht.useMemo(()=>e?e.replace(/<think>([\s\S]*?)<\/think>/g,(f,u)=>`<div data-component="thinkbox" data-think-content="${encodeURIComponent(u.trim())}"></div>`):"",[e]),l=(f,u,h,v,p)=>{c?.onCardEvent?.({messageId:i,cardType:f,action:u,title:h,payload:v,rawData:p});},s=(f,u,h,v,p,C)=>{if(!(!p&&!c?.onCardEvent))return (...m)=>{let y=p?.(...m),x=C?C(...m):void 0;return l(f,u,h,x,v),y}},g=ht.useMemo(()=>({div(f){let{"data-component":u,"data-think-content":h,...v}=f;return u==="thinkbox"&&h?jsxRuntime.jsx(Hm,{content:decodeURIComponent(h),theme:t,size:o,defaultExpanded:false}):jsxRuntime.jsx("div",{...v})},table({children:f}){return jsxRuntime.jsx("div",{className:"my-4 w-full overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:jsxRuntime.jsx("table",{className:"w-full min-w-[520px] border-collapse text-sm",children:f})})},thead({children:f}){return jsxRuntime.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/60",children:f})},tbody({children:f}){return jsxRuntime.jsx("tbody",{className:"bg-white dark:bg-gray-950",children:f})},tr({children:f}){return jsxRuntime.jsx("tr",{className:"border-b border-gray-200 dark:border-gray-800 last:border-b-0",children:f})},th({children:f,align:u}){return jsxRuntime.jsx("th",{className:`px-3 py-2 font-semibold text-gray-800 dark:text-gray-100 ${u==="center"?"text-center":u==="right"?"text-right":"text-left"}`,children:f})},td({children:f,align:u}){return jsxRuntime.jsx("td",{className:`px-3 py-2 text-gray-700 dark:text-gray-200 align-top ${u==="center"?"text-center":u==="right"?"text-right":"text-left"}`,children:f})},code({inline:f,className:u,children:h,...v}){let p=/language-([\w-]+)/.exec(u||""),C=p?p[1]:"";if(f)return jsxRuntime.jsx("code",{className:"font-mono text-sm bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded text-red-600 dark:text-red-400",...v,children:h});let m=String(h).replace(/\n$/,"");if(n&&C==="mermaid")return jsxRuntime.jsx(jm,{content:m});if(C==="json"){let y=nl(m);if(y)switch(y.type){case "table":return jsxRuntime.jsx(tl,{data:y.data});case "bar-chart-card":case "line-chart-card":case "pie-chart-card":case "combo-chart-card":case "heatmap-chart-card":case "fishbone-chart-card":case "waterfall-chart-card":case "google-map-card":case "amap-card":return jsxRuntime.jsx(ol,{...y});case "sap-analytical-card":case "sap-list-card":case "sap-object-card":case "sap-component-card":return jsxRuntime.jsx(rl,{...y});case "error-card":{let x=y;return jsxRuntime.jsx(Qs,{...x,onClose:s("error-card","close",x.title,x,x.onClose),onRetry:s("error-card","retry",x.title,x,x.onRetry)})}case "warning-card":{let x=y,S=x.onConfirm?s("warning-card","confirm",x.title,x,x.onConfirm):x.actionText&&c?.onCardEvent?s("warning-card","confirm",x.title,x):void 0;return jsxRuntime.jsx(Ys,{...x,onClose:s("warning-card","close",x.title,x,x.onClose),onConfirm:S})}case "suggestions-card":{let x=y;return jsxRuntime.jsx(Js,{...x,onClose:s("suggestions-card","close",x.title,x,x.onClose),onSuggestionClick:s("suggestions-card","suggestion-click",x.title,x,x.onSuggestionClick,S=>({suggestion:S}))})}case "tool-result-card":{let x=y;return jsxRuntime.jsx(el,{...x,onClose:s("tool-result-card","close",x.title,x,x.onClose),onAction:s("tool-result-card","action",x.title,x,x.onAction)})}}}return r?jsxRuntime.jsx(Um,{content:m,language:C,className:"not-prose"}):jsxRuntime.jsx("code",{className:u,...v,children:h})}}),[t,o,n,r,c,i]);return jsxRuntime.jsx("div",{className:De("markdown-body prose dark:prose-invert max-w-none",a),children:jsxRuntime.jsx(NS__default.default,{remarkPlugins:[VS__default.default,OS__default.default],rehypePlugins:[WS__default.default,$S__default.default],components:g,children:d})})},il=HS;var GS=({content:e,messageId:t,cardHooks:o})=>{let a=(i,c,d,l,s)=>{o?.onCardEvent?.({messageId:t,cardType:i,action:c,title:d,payload:l,rawData:s});},r=(i,c,d,l,s,g)=>{if(!(!s&&!o?.onCardEvent))return (...f)=>{let u=s?.(...f),h=g?g(...f):void 0;return a(i,c,d,h,l),u}},n=nl(e);if(n)switch(n.type){case "table":return jsxRuntime.jsx(tl,{data:n.data});case "bar-chart-card":case "line-chart-card":case "pie-chart-card":case "combo-chart-card":case "heatmap-chart-card":case "fishbone-chart-card":case "waterfall-chart-card":case "google-map-card":case "amap-card":return jsxRuntime.jsx(ol,{...n});case "sap-analytical-card":case "sap-list-card":case "sap-object-card":case "sap-component-card":return jsxRuntime.jsx(rl,{...n});case "error-card":{let i=n;return jsxRuntime.jsx(Qs,{...i,onClose:r("error-card","close",i.title,i,i.onClose),onRetry:r("error-card","retry",i.title,i,i.onRetry)})}case "warning-card":{let i=n,c=i.onConfirm?r("warning-card","confirm",i.title,i,i.onConfirm):i.actionText&&o?.onCardEvent?r("warning-card","confirm",i.title,i):void 0;return jsxRuntime.jsx(Ys,{...i,onClose:r("warning-card","close",i.title,i,i.onClose),onConfirm:c})}case "suggestions-card":{let i=n;return jsxRuntime.jsx(Js,{...i,onClose:r("suggestions-card","close",i.title,i,i.onClose),onSuggestionClick:r("suggestions-card","suggestion-click",i.title,i,i.onSuggestionClick,c=>({suggestion:c}))})}case "tool-result-card":{let i=n;return jsxRuntime.jsx(el,{...i,onClose:r("tool-result-card","close",i.title,i,i.onClose),onAction:r("tool-result-card","action",i.title,i,i.onAction)})}}return jsxRuntime.jsx("div",{className:"dynamic-card-fallback",children:jsxRuntime.jsx(il,{content:e,enableCodeHighlight:true,enableMath:true,enableMermaid:true,messageId:t,cardHooks:o})})},rg=GS;var ed=class{static analyze(t){if(!t.trim())return {blocks:[],hasComplexContent:false,overallType:"simple"};let a=/```json\s*\{\s*"type":\s*"[^"]+"/g.test(t),r=/<[^>]+>[\s\S]*?<\/[^>]+>/.test(t),n=t.includes("NQ#")||t.includes("data-component");return a||r||n?{blocks:[{type:"mixed",content:t,startIndex:0,endIndex:t.length}],hasComplexContent:true,overallType:"complex"}:{blocks:[{type:"markdown",content:t,startIndex:0,endIndex:t.length}],hasComplexContent:false,overallType:"simple"}}},KS=({content:e,className:t="",messageId:o,cardHooks:a})=>{let r=ht__namespace.default.useMemo(()=>ed.analyze(e),[e]);return jsxRuntime.jsx("div",{className:`universal-content-renderer ${t}`,children:r.blocks.map((n,i)=>n.type==="mixed"||n.type==="json-card"?jsxRuntime.jsx(rg,{content:n.content,messageId:o,cardHooks:a},`block-${i}`):jsxRuntime.jsx(il,{content:n.content,enableCodeHighlight:true,enableMath:true,enableMermaid:true,messageId:o,cardHooks:a},`block-${i}`))})},ng=KS;var qS=({content:e,isStreaming:t=true,onComplete:o,className:a="",streamIntervalMs:r=24,streamChunkSize:n=3,messageId:i,cardHooks:c})=>{let[d,l]=ht.useState(t?0:e.length),[s,g]=ht.useState(!t);ht.useEffect(()=>{if(t){l(0),g(false);return}l(e.length),g(true);},[e,t]),ht.useEffect(()=>{if(!t||s)return;if(d>=e.length){g(true),o?.();return}let p=window.setTimeout(()=>{l(C=>Math.min(C+n,e.length));},r);return ()=>{window.clearTimeout(p);}},[e.length,s,t,o,n,r,d]);let f=()=>{t&&!s&&(l(e.length),g(true),o?.());},u=t?e.slice(0,d):e,h=t&&!s,v=t&&!s;return jsxRuntime.jsxs("div",{className:`streaming-markdown ${a}`,onClick:f,style:{cursor:t?"pointer":"default"},children:[jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(ng,{content:u,messageId:i,cardHooks:c}),h&&jsxRuntime.jsx("span",{className:"inline-block w-0.5 h-5 bg-blue-500 ml-1 animate-pulse",style:{verticalAlign:"text-bottom"}})]}),v&&jsxRuntime.jsx("div",{className:"streaming-hint",style:{fontSize:"9px",color:"#999",marginTop:"8px",fontStyle:"italic",opacity:.7},children:"\u70B9\u51FB\u6B64\u5904\u663E\u793A\u5B8C\u6574\u5185\u5BB9"})]})},cg=qS;var dg=({buttons:e,className:t})=>{let o=a=>{switch(a){case "copy":return jsxRuntime.jsx(lucideReact.Copy,{size:14});case "refresh":return jsxRuntime.jsx(lucideReact.RefreshCw,{size:14});case "volume":return jsxRuntime.jsx(lucideReact.Volume2,{size:14});case "like":return jsxRuntime.jsx(lucideReact.ThumbsUp,{size:14});case "dislike":return jsxRuntime.jsx(lucideReact.ThumbsDown,{size:14});default:return null}};return jsxRuntime.jsx("div",{className:De("flex items-center gap-1",t),children:e.map((a,r)=>jsxRuntime.jsx("button",{onClick:a.onClick,disabled:a.disabled,className:De("p-1.5 rounded-md transition-colors","text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-800","disabled:opacity-50 disabled:cursor-not-allowed",a.active&&"text-blue-600 bg-blue-50 dark:text-blue-400 dark:bg-blue-900/20",a.type==="refresh"&&a.disabled&&"animate-spin"),title:a.type,type:"button",children:o(a.type)},`${a.type}-${r}`))})};var sl=({message:e,onStreamingComplete:t,assistantActions:o,streamIntervalMs:a,streamChunkSize:r,cardHooks:n})=>e.type==="assistant"?jsxRuntime.jsx("div",{className:"flex justify-start mb-4",children:jsxRuntime.jsxs("div",{className:"w-full bg-transparent text-black dark:text-gray-100 rounded-2xl px-4 py-3 mr-auto",style:{lineHeight:"1.5",fontSize:"16px",fontWeight:"280",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[jsxRuntime.jsx(cg,{content:e.content,isStreaming:e.isStreaming??false,onComplete:t,streamIntervalMs:a,streamChunkSize:r,messageId:e.id,cardHooks:n}),e.content&&o?.isLatestAssistant&&jsxRuntime.jsx("div",{className:"flex flex-row justify-start gap-2 mt-3 pt-2 border-t border-gray-100 dark:border-gray-700",children:jsxRuntime.jsx(dg,{buttons:[{type:"refresh",onClick:()=>o?.onRegenerate?.(),disabled:!o?.onRegenerate},{type:"copy",onClick:()=>navigator.clipboard.writeText(e.content),disabled:false},{type:"volume",onClick:()=>console.log("\u8BED\u97F3\u64AD\u653E"),disabled:false},{type:"like",onClick:()=>console.log("\u70B9\u8D5E"),disabled:false},{type:"dislike",onClick:()=>console.log("\u70B9\u8E29"),disabled:false}],size:"sm",variant:"default"})}),jsxRuntime.jsx("div",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:e.timestamp.toLocaleTimeString()})]})}):jsxRuntime.jsx("div",{className:"flex justify-end",children:jsxRuntime.jsxs("div",{className:"max-w-[80%] bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-2xl px-4 py-3 ml-auto",style:{lineHeight:"1.5",fontSize:"16px",fontWeight:"280",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[jsxRuntime.jsx("div",{className:"whitespace-pre-wrap",style:{lineHeight:"1.5",fontSize:"16px",fontWeight:"280",fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:e.content}),jsxRuntime.jsx("div",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:e.timestamp.toLocaleTimeString()})]})});var ug=({onTextUpdate:e,onComplete:t,onCancel:o,disabled:a,className:r})=>{let{isRecording:n,startRecording:i,stopRecording:c}=Xs({onTextUpdate:e,onComplete:l=>{t?.(l);},onError:l=>{console.error("Voice input error:",l),o?.();}});return jsxRuntime.jsx("button",{onClick:async()=>{n?c():await i();},disabled:a,className:De("transition-all duration-200 flex items-center justify-center rounded-full",n?"bg-red-100 text-red-600 hover:bg-red-200 animate-pulse":"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 active:scale-95",a&&"opacity-50 cursor-not-allowed",r),title:n?"Stop recording":"Start recording",type:"button",children:n?jsxRuntime.jsx(JS__default.default,{sx:{fontSize:24}}):jsxRuntime.jsx(YS__default.default,{sx:{fontSize:24}})})};var yt={container:"w-full max-w-4xl mx-auto",inputContainer:De("w-full border backdrop-blur-xl transition-all duration-300 shadow-2xl flex flex-col","bg-white/80 dark:bg-gray-900/80","border-gray-200/60 dark:border-gray-600/40","shadow-gray-900/5","hover:border-blue-300/80 hover:shadow-blue-500/10 hover:shadow-2xl","focus-within:border-blue-400/90 focus-within:shadow-blue-500/20 focus-within:shadow-3xl focus-within:scale-[1.005] transform-gpu"),dragActive:"border-blue-500 bg-blue-50/50 dark:bg-blue-900/20",textareaWrapper:"flex-1 relative flex items-center",textarea:De("w-full outline-none appearance-none resize-none bg-transparent border-none text-sm font-normal py-3 px-2","placeholder:text-gray-400/70 dark:placeholder:text-gray-500/60 placeholder:font-normal","text-gray-800 dark:text-gray-100 selection:bg-blue-200/50 dark:selection:bg-blue-500/30","focus:ring-0 focus:outline-none focus:border-none focus:shadow-none","min-h-[44px] max-h-[12em] overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600"),filePreviewArea:"px-6 pt-3 pb-1 flex flex-wrap gap-2",fileTag:De("flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-medium","bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300","border border-gray-200 dark:border-gray-700","transition-all hover:bg-gray-200 dark:hover:bg-gray-700"),buttonBase:"flex items-center justify-center transition-all duration-200 rounded-full",buttonSmall:"w-10 h-10",buttonNormal:De("bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400","cursor-pointer active:scale-95"),sendButton:De("cursor-pointer bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-500 dark:text-gray-400 shadow-none active:scale-95"),sendButtonDisabled:De("cursor-not-allowed opacity-40 bg-transparent text-gray-400"),stopButton:De("cursor-pointer bg-red-500 hover:bg-red-600 text-white shadow-sm active:scale-95")},sw={padding:0,lineHeight:"1.5",border:"none !important",boxShadow:"none !important",backgroundColor:"transparent",height:"auto",fontFeatureSettings:'"liga" 1, "kern" 1',WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"},lw=({enabled:e,onClick:t})=>jsxRuntime.jsx("button",{className:De(yt.buttonBase,yt.buttonSmall,yt.buttonNormal),onClick:t,disabled:!e,"aria-label":"Upload file",type:"button",children:jsxRuntime.jsx(nw__default.default,{sx:{fontSize:24}})}),cw=()=>jsxRuntime.jsxs("button",{className:De(yt.buttonBase,"h-10 px-3 py-2 gap-1.5 rounded-full",yt.buttonNormal),"aria-label":"Tools",type:"button",children:[jsxRuntime.jsx(iw__default.default,{sx:{fontSize:20}}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:"Tools"})]}),dw=({canSend:e,isResponding:t,onSend:o,onStop:a})=>t?jsxRuntime.jsx("button",{className:De(yt.buttonBase,yt.buttonSmall,yt.stopButton),onClick:a,"aria-label":"Stop generating",type:"button",children:jsxRuntime.jsx(iconsMaterial.Stop,{sx:{fontSize:20}})}):jsxRuntime.jsx("button",{className:De(yt.buttonBase,yt.buttonSmall,e?yt.sendButton:yt.sendButtonDisabled),onClick:o,disabled:!e,"aria-label":"Send message",type:"button",children:jsxRuntime.jsx(rw__default.default,{sx:{fontSize:24},className:e?"text-gray-500 dark:text-gray-400":"text-gray-300 dark:text-gray-600"})}),mg=({onSend:e,onStop:t,isResponding:o=false,placeholder:a,getText:r})=>{let[n,i]=ht.useState(""),[c,d]=ht.useState([]),[l,s]=ht.useState(false),[g,f]=ht.useState(false),u=ht.useRef(null),h=a||(r?r("00019","Type a message..."):"Type a message..."),v=(n.trim().length>0||c.length>0)&&!o,p={enabled:true},C=ht.useCallback(M=>{i(M.target.value),M.target.style.height="auto",M.target.style.height=`${Math.min(M.target.scrollHeight,200)}px`;},[]),m=ht.useCallback(M=>{if(M.target.files&&M.target.files.length>0){let H=Array.from(M.target.files);d(V=>{let J=H.filter(te=>V.some(ne=>ne.name===te.name&&ne.size===te.size));J.length>0&&console.warn("Duplicate files ignored:",J.map(te=>te.name));let ce=H.filter(te=>!V.some(ne=>ne.name===te.name&&ne.size===te.size));return [...V,...ce]}),u.current&&(u.current.value="");}},[]),y=ht.useCallback(M=>{d(H=>H.filter((V,J)=>J!==M));},[]),x=ht.useCallback(()=>{u.current?.click();},[]),S=ht.useCallback(async()=>{if(!v)return;let M=n,H=[...c];i(""),d([]),u.current&&(u.current.value="");try{await e(M,H);}catch(V){console.error("Failed to send message:",V),i(M),d(H);}},[n,v,e,c]),B=ht.useCallback(M=>{M.key==="Enter"&&!M.shiftKey&&!l&&(M.preventDefault(),S());},[S,l]),R=ht.useCallback(()=>{s(true);},[]),w=ht.useCallback(()=>{s(false);},[]),A=ht.useCallback(M=>{i(M);},[]),P=ht.useCallback(M=>{i(M);},[]),k=ht.useCallback(()=>{},[]),D=ht.useCallback(M=>{M.preventDefault(),f(true);},[]),T=ht.useCallback(M=>{M.preventDefault(),f(false);},[]),I=ht.useCallback(M=>{if(M.preventDefault(),f(false),M.dataTransfer.files&&M.dataTransfer.files.length>0){let H=Array.from(M.dataTransfer.files);d(V=>[...V,...H]);}},[]);return jsxRuntime.jsx("div",{className:yt.container,children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("input",{type:"file",multiple:true,className:"hidden",ref:u,onChange:m}),jsxRuntime.jsxs("div",{className:De(yt.inputContainer,g&&yt.dragActive),style:{borderRadius:"32px"},onDragOver:D,onDragLeave:T,onDrop:I,children:[c.length>0&&jsxRuntime.jsx("div",{className:yt.filePreviewArea,children:c.map((M,H)=>jsxRuntime.jsxs("div",{className:yt.fileTag,children:[jsxRuntime.jsx(iconsMaterial.InsertDriveFile,{sx:{fontSize:16},className:"text-blue-500"}),jsxRuntime.jsx("span",{className:"truncate max-w-[150px]",children:M.name}),jsxRuntime.jsx("button",{onClick:()=>y(H),className:"ml-1 hover:text-red-500 focus:outline-none",type:"button",children:jsxRuntime.jsx(iconsMaterial.Close,{sx:{fontSize:16}})})]},`${M.name}-${H}`))}),jsxRuntime.jsxs("div",{className:"flex flex-col w-full p-2",children:[jsxRuntime.jsx("div",{className:De(yt.textareaWrapper,"px-3 pt-2 pb-3 min-h-[60px]"),children:jsxRuntime.jsx("textarea",{className:De(yt.textarea,"min-h-[24px] py-0 px-0"),placeholder:h,value:n,onChange:C,onKeyDown:B,onCompositionStart:R,onCompositionEnd:w,style:sw,"aria-label":"Message input",spellCheck:false,rows:1})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-1 pb-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",role:"toolbar","aria-label":"Input tools",children:[jsxRuntime.jsx(lw,{enabled:p.enabled,onClick:x}),jsxRuntime.jsx(cw,{})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(ug,{onTextUpdate:A,onComplete:P,onCancel:k,disabled:o,className:yt.buttonSmall}),jsxRuntime.jsx(dw,{canSend:v,isResponding:o,onSend:S,onStop:t})]})]})]})]})]})})};var hg=({messages:e,onSend:t,onStop:o,onRegenerate:a,isResponding:r=false,className:n,placeholder:i,streamIntervalMs:c,streamChunkSize:d,onMessageStreamingComplete:l,cardHooks:s,showInput:g=true})=>{let f=ht.useRef(null),u=ht.useRef(e.length);return ht.useEffect(()=>{e.length>u.current&&f.current?.scrollIntoView({behavior:"smooth"}),u.current=e.length;},[e]),jsxRuntime.jsxs("div",{className:De("flex flex-col h-full w-full relative",n),children:[jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-6 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600",children:[e.map((h,v)=>{let p=h.type==="assistant"&&v===e.length-1,C=h.type==="assistant"?{isLatestAssistant:p,onRegenerate:a?()=>a(h.id):void 0}:void 0;return jsxRuntime.jsx(sl,{message:h,assistantActions:C,onStreamingComplete:()=>l?.(h.id),streamIntervalMs:c,streamChunkSize:d,cardHooks:s},h.id)}),jsxRuntime.jsx("div",{ref:f})]}),g&&jsxRuntime.jsx("div",{className:"p-4 bg-gradient-to-t from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 pb-8 z-10",children:jsxRuntime.jsx(mg,{onSend:t||(async()=>{}),onStop:o||(()=>{}),isResponding:r,placeholder:i})})]})};var ho={};var mw={idle:"Idle",running:"Running",success:"Success",error:"Error",pending:"Pending"},Lz=({title:e="AI Agent",description:t,headerActions:o,className:a,agentStatus:r,showInput:n=false,...i})=>{let c=r??(i.isResponding?"running":"idle");return jsxRuntime.jsxs("div",{className:De("relative flex h-full w-full",ho.agentPanel,a),"data-status":c,children:[jsxRuntime.jsx("div",{className:ho.colorHalo,"data-status":c,"aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:ho.marqueeBorder,"data-status":c,"aria-hidden":"true",children:[jsxRuntime.jsx("span",{className:De(ho.edge,ho.top)}),jsxRuntime.jsx("span",{className:De(ho.edge,ho.right)}),jsxRuntime.jsx("span",{className:De(ho.edge,ho.bottom)}),jsxRuntime.jsx("span",{className:De(ho.edge,ho.left)})]}),jsxRuntime.jsxs("div",{className:"relative z-10 flex h-full w-full flex-col rounded-xl border border-slate-200/70 bg-white shadow-sm overflow-hidden dark:border-slate-800 dark:bg-gray-950",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-gray-800 bg-white/50 dark:bg-gray-900/50 backdrop-blur-sm z-20",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:e}),t&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:t})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-full bg-gray-100/80 dark:bg-gray-800/70",children:[jsxRuntime.jsx("span",{className:ho.statusDot,"data-status":c}),jsxRuntime.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-gray-600 dark:text-gray-300",children:mw[c]})]}),o]})]}),jsxRuntime.jsx("div",{className:"flex-1 min-h-0 relative z-10",children:jsxRuntime.jsx(hg,{...i,showInput:n})})]})]})};var bw={"top-left":"bottom-right","top-right":"bottom-left","bottom-left":"top-right","bottom-right":"top-left"},Gz=({messages:e,onSend:t,onRegenerate:o,isResponding:a=false,className:r,placeholder:n,title:i="Copilot",corner:c="bottom-right",onCollapse:d,onHeaderPointerDown:l,onPlusClick:s,onMicClick:g,streamIntervalMs:f,streamChunkSize:u,onMessageStreamingComplete:h,cardHooks:v})=>{let[p,C]=ht.useState(""),[m,y]=ht.useState(false),x=ht.useRef(null),S=bw[c];ht.useEffect(()=>{x.current?.scrollIntoView({behavior:"smooth"});},[e,a]);let B=ht.useCallback(async()=>{let w=p.trim();!w||a||(C(""),await t(w));},[a,t,p]),R=ht.useCallback(async w=>{w.key==="Enter"&&!m&&(w.preventDefault(),await B());},[B,m]);return jsxRuntime.jsxs("div",{className:De("relative flex h-full w-full min-h-[460px] min-w-[340px] flex-col overflow-hidden rounded-3xl border border-gray-200 bg-white shadow-none dark:border-gray-800 dark:bg-gray-900",r),children:[d&&jsxRuntime.jsx("button",{onClick:d,className:De("absolute z-20 flex h-10 w-10 items-center justify-center rounded-full transition-colors hover:bg-transparent dark:hover:bg-transparent",S==="top-left"&&"-left-2 -top-2",S==="top-right"&&"-right-2 -top-2",S==="bottom-left"&&"-bottom-2 -left-2",S==="bottom-right"&&"-bottom-2 -right-2"),type:"button","aria-label":"Collapse Copilot",children:jsxRuntime.jsx("span",{className:De("block h-4 w-4 border-[#21BCFF]",S==="top-left"&&"rounded-tl-full border-l-[3px] border-t-[3px]",S==="top-right"&&"rounded-tr-full border-r-[3px] border-t-[3px]",S==="bottom-left"&&"rounded-bl-full border-b-[3px] border-l-[3px]",S==="bottom-right"&&"rounded-br-full border-b-[3px] border-r-[3px]")})}),jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-4 py-3 dark:border-gray-800",onPointerDown:l,children:[jsxRuntime.jsx("div",{className:"flex items-center",children:jsxRuntime.jsx("h3",{className:"text-base font-semibold tracking-tight text-gray-900 dark:text-gray-100",children:i})}),jsxRuntime.jsx("div",{})]}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-5 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600",children:[e.map((w,A)=>{let P=w.type==="assistant"&&A===e.length-1,k=w.type==="assistant"?{isLatestAssistant:P,onRegenerate:o?()=>o(w.id):void 0}:void 0;return jsxRuntime.jsx(sl,{message:w,assistantActions:k,onStreamingComplete:()=>h?.(w.id),streamIntervalMs:f,streamChunkSize:u,cardHooks:v},w.id)}),jsxRuntime.jsx("div",{ref:x})]}),jsxRuntime.jsx("div",{className:"border-t border-gray-100 px-3 py-3 dark:border-gray-800",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-blue-300/80 bg-white px-2 py-1.5 dark:bg-gray-900",children:[jsxRuntime.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-full text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:s,type:"button","aria-label":"Add",children:jsxRuntime.jsx(lucideReact.Plus,{className:"h-4 w-4"})}),jsxRuntime.jsx("input",{className:"h-7 flex-1 border-none bg-transparent text-sm text-gray-800 outline-none placeholder:text-gray-400 dark:text-gray-100 dark:placeholder:text-gray-500",placeholder:n||"Ask Copilot...",value:p,onChange:w=>C(w.target.value),onCompositionStart:()=>y(true),onCompositionEnd:()=>y(false),onKeyDown:R,"aria-label":"Copilot input",spellCheck:false}),jsxRuntime.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-full text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:g,type:"button","aria-label":"Microphone",children:jsxRuntime.jsx(lucideReact.Mic,{className:"h-4 w-4"})})]})})]})};var _z=({defaultMode:e="login",onLogin:t,onRegister:o,onForgotPassword:a}={})=>{let[r,n]=ht.useState(e),[i,c]=ht.useState(false),d=ht.useCallback(async u=>{c(true);try{await u?.();}finally{c(false);}},[]),l=ht.useCallback(u=>d(()=>t?.(u)),[t,d]),s=ht.useCallback(u=>d(()=>o?.(u)),[o,d]),g=ht.useCallback(u=>d(()=>a?.(u)),[a,d]),f=ht.useMemo(()=>({mode:r,loading:i,onModeChange:n,onLogin:l,onRegister:s,onForgotPassword:g}),[g,l,s,i,r]);return {mode:r,loading:i,setMode:n,authPageProps:f}};var ad=({label:e,...t})=>jsxRuntime.jsx(material.FormControlLabel,{control:jsxRuntime.jsx(material.Checkbox,{...t}),label:e});var xi=ht.forwardRef((e,t)=>jsxRuntime.jsx(material.Paper,{ref:t,...e,elevation:e.elevation||1,sx:{p:2,mb:2,...e.sx}}));xi.displayName="CPaper";var Aw={productName:"ORBCAFE",headline:"Operational workbench",subheadline:"A focused entry point for reports, planning, agent workflows, and enterprise operations.",loginTitle:"Sign in",loginSubtitle:"Use your workspace account to continue.",registerTitle:"Create account",registerSubtitle:"Request a demo workspace user for evaluation.",forgotTitle:"Reset password",forgotSubtitle:"Send a password reset request to your email address."},mN=({mode:e,defaultMode:t="login",onModeChange:o,onLogin:a,onRegister:r,onForgotPassword:n,loading:i=false,logo:c,copy:d,sx:l})=>{let s=material.useTheme(),g=e!==void 0,[f,u]=ht.useState(t),h=e??f,v=ht.useMemo(()=>({...Aw,...d}),[d]),[p,C]=ht.useState({username:"demo@orbcafe.local",password:"orbcafe-demo",remember:true}),[m,y]=ht.useState({name:"",email:"",password:"",confirmPassword:"",acceptedTerms:false}),[x,S]=ht.useState({email:""}),[B,R]=ht.useState(""),w=I=>{g||u(I),R(""),o?.(I);},A=async I=>{I.preventDefault(),await a?.(p),R("Demo login accepted. No real authentication request was sent.");},P=async I=>{I.preventDefault(),await r?.(m),R("Demo registration saved locally for this screen.");},k=async I=>{I.preventDefault(),await n?.(x),R("Demo reset link request created. No email was sent.");},D=h==="login"?v.loginTitle:h==="register"?v.registerTitle:v.forgotTitle,T=h==="login"?v.loginSubtitle:h==="register"?v.registerSubtitle:v.forgotSubtitle;return jsxRuntime.jsxs(material.Box,{sx:{minHeight:"100vh",display:"grid",gridTemplateColumns:{xs:"1fr",md:"minmax(320px, 0.9fr) minmax(420px, 1.1fr)"},background:s.palette.mode==="dark"?"linear-gradient(135deg, #071018 0%, #151515 48%, #101827 100%)":"linear-gradient(135deg, #eef3f8 0%, #ffffff 52%, #e8f2f0 100%)",...l},children:[jsxRuntime.jsxs(material.Box,{sx:{display:{xs:"none",md:"flex"},flexDirection:"column",justifyContent:"space-between",p:{md:6,lg:8},borderRight:`1px solid ${s.palette.divider}`},children:[jsxRuntime.jsxs(material.Stack,{spacing:4,children:[jsxRuntime.jsx(material.Box,{children:c}),jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:14,fontWeight:700,color:"primary.main",textTransform:"uppercase"},children:v.productName}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:{md:34,lg:42},lineHeight:1.06,fontWeight:800},children:v.headline}),jsxRuntime.jsx(material.Typography,{sx:{maxWidth:460,color:"text.secondary",fontSize:16,lineHeight:1.7},children:v.subheadline})]})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:2,sx:{color:"text.secondary",fontSize:13},children:[jsxRuntime.jsx(material.Typography,{variant:"caption",children:"Reports"}),jsxRuntime.jsx(material.Typography,{variant:"caption",children:"Planning"}),jsxRuntime.jsx(material.Typography,{variant:"caption",children:"Agent UI"})]})]}),jsxRuntime.jsx(material.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:{xs:2,sm:4,md:6}},children:jsxRuntime.jsx(xi,{elevation:0,sx:{width:"100%",maxWidth:460,m:0,p:{xs:2.5,sm:4},borderRadius:3,border:`1px solid ${s.palette.divider}`,backgroundColor:s.palette.mode==="dark"?"rgba(15, 23, 42, 0.86)":"rgba(255, 255, 255, 0.88)",backdropFilter:"blur(18px)",boxShadow:s.palette.mode==="dark"?"0 24px 80px rgba(0,0,0,0.34)":"0 24px 80px rgba(15,23,42,0.10)"},children:jsxRuntime.jsxs(material.Stack,{spacing:3,children:[jsxRuntime.jsxs(material.Stack,{spacing:1,children:[jsxRuntime.jsx(material.Box,{sx:{display:{xs:"block",md:"none"},mb:1},children:c}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:28,fontWeight:800},children:D}),jsxRuntime.jsx(material.Typography,{sx:{color:"text.secondary"},children:T})]}),B&&jsxRuntime.jsx(material.Alert,{severity:"success",children:B}),h==="login"&&jsxRuntime.jsx(material.Box,{component:"form",onSubmit:A,children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(Kt,{label:"Email or user ID",value:p.username,onChange:I=>C(M=>({...M,username:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(kg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Password",type:"password",value:p.password,onChange:I=>C(M=>({...M,password:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Dw__default.default,{fontSize:"small"})})}}),jsxRuntime.jsxs(material.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2},children:[jsxRuntime.jsx(ad,{label:"Remember me",checked:p.remember,onChange:I=>C(M=>({...M,remember:I.target.checked}))}),jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("forgot"),children:"Forgot?"})]}),jsxRuntime.jsx(Mo,{type:"submit",size:"large",disabled:i,children:"Sign in"}),jsxRuntime.jsxs(material.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"center"},children:["New user?"," ",jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("register"),sx:{minWidth:0,p:0},children:"Register"})]})]})}),h==="register"&&jsxRuntime.jsx(material.Box,{component:"form",onSubmit:P,children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(Kt,{label:"Full name",value:m.name,onChange:I=>y(M=>({...M,name:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(kg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Work email",type:"email",value:m.email,onChange:I=>y(M=>({...M,email:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Cg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Password",type:"password",value:m.password,onChange:I=>y(M=>({...M,password:I.target.value})),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Mw__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Kt,{label:"Confirm password",type:"password",value:m.confirmPassword,onChange:I=>y(M=>({...M,confirmPassword:I.target.value}))}),jsxRuntime.jsx(ad,{label:"I accept the demo workspace terms",checked:m.acceptedTerms,onChange:I=>y(M=>({...M,acceptedTerms:I.target.checked}))}),jsxRuntime.jsx(Mo,{type:"submit",size:"large",disabled:i,children:"Create demo account"}),jsxRuntime.jsxs(material.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"center"},children:["Already have an account?"," ",jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("login"),sx:{minWidth:0,p:0},children:"Sign in"})]})]})}),h==="forgot"&&jsxRuntime.jsx(material.Box,{component:"form",onSubmit:k,children:jsxRuntime.jsxs(material.Stack,{spacing:2,children:[jsxRuntime.jsx(Kt,{label:"Work email",type:"email",value:x.email,onChange:I=>S({email:I.target.value}),InputProps:{startAdornment:jsxRuntime.jsx(material.InputAdornment,{position:"start",children:jsxRuntime.jsx(Cg__default.default,{fontSize:"small"})})}}),jsxRuntime.jsx(Mo,{type:"submit",size:"large",disabled:i,children:"Send reset request"}),jsxRuntime.jsxs(material.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"center"},children:["Remember your password?"," ",jsxRuntime.jsx(Mo,{type:"button",variant:"text",size:"small",onClick:()=>w("login"),sx:{minWidth:0,p:0},children:"Back to sign in"})]})]})}),jsxRuntime.jsx(material.Divider,{}),jsxRuntime.jsx(material.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Demo credentials: demo@orbcafe.local / orbcafe-demo"})]})})})]})};var Fw={keyword:{value:"",operator:"contains"},status:{value:"",operator:"equals"},owner:{value:"",operator:"contains"},workCenter:{value:"",operator:"contains"}},Lw=[{id:"keyword",label:"Keyword",type:"text",placeholder:"Task/ID/Project",hasSearchIcon:true},{id:"status",label:"Status",type:"select",options:[{label:"In progress",value:"in-progress"},{label:"Blocked",value:"blocked"},{label:"Planned",value:"planned"},{label:"Not started",value:"not-started"}]},{id:"owner",label:"Owner",type:"text",placeholder:"Owner name"},{id:"workCenter",label:"Work Center",type:"text",placeholder:"CNC-02 / WH-A / ..."},{id:"dateRange",label:"Date Range",type:"date"}],Sg=({tasks:e,defaultScale:t="week",defaultSelectedTaskId:o,initialFilters:a,filterFields:r,filterAppId:n="planning-gantt-filter",filterTableKey:i="planning",onFilterSearch:c,onFilterVariantLoad:d,enableRowReorder:l,onTaskReorder:s})=>{let[g,f]=ht.useState(t),[u,h]=ht.useState(o??e[0]?.id??""),[v,p]=ht.useState({...Fw,...a}),C=ht.useMemo(()=>{let S=String(v.keyword?.value??"").trim().toLowerCase(),B=String(v.status?.value??"").trim(),R=String(v.owner?.value??"").trim().toLowerCase(),w=String(v.workCenter?.value??"").trim().toLowerCase(),A=v.dateRange?.value,P=A?.[0]?_a__default.default(A[0]):null,k=A?.[1]?_a__default.default(A[1]):null;return e.filter(D=>{if(S&&![D.id,D.code,D.title,D.project,D.workCenter,D.owner?.name].join(" ").toLowerCase().includes(S)||B&&D.status!==B||R&&!String(D.owner?.name??"").toLowerCase().includes(R)||w&&!String(D.workCenter??"").toLowerCase().includes(w))return false;if(P||k){let T=_a__default.default(D.startDate),I=_a__default.default(D.endDate),M=P?I.isAfter(P)||I.isSame(P,"day"):true,H=k?T.isBefore(k)||T.isSame(k,"day"):true;if(!M||!H)return false}return true})},[v,e]);ht.useEffect(()=>{C.length!==0&&(C.some(S=>S.id===u)||h(C[0].id));},[C,u]);let m=ht.useCallback(S=>{h(S.id);},[]),y=ht.useMemo(()=>({appId:n,tableKey:i,fields:r??Lw,filters:v,onFilterChange:p,onVariantLoad:d??(()=>{}),onSearch:c??(()=>{})}),[n,r,i,v,c,d]),x=ht.useMemo(()=>({tasks:C,scale:g,onScaleChange:f,selectedTaskId:u,onTaskSelect:m,enableRowReorder:l,onTaskReorder:s}),[l,C,s,m,g,u]);return {scale:g,setScale:f,selectedTaskId:u,setSelectedTaskId:h,filters:v,setFilters:p,filteredTasks:C,smartFilterProps:y,planningGanttProps:x}};var CN=e=>{let t=Sg(e),o=ht.useMemo(()=>({filterProps:t.smartFilterProps,ganttProps:t.planningGanttProps}),[t.planningGanttProps,t.smartFilterProps]);return {...t,layoutProps:o}};var wg=e=>jsxRuntime.jsx(material.Chip,{...e,size:e.size||"small",variant:e.variant||"outlined"});var Ka=ht.forwardRef(({tooltip:e,...t},o)=>{let a=jsxRuntime.jsx(material.IconButton,{ref:o,...t,size:t.size||"small"});return e?jsxRuntime.jsx(material.Tooltip,{title:e,children:a}):a});Ka.displayName="CIconButton";var Ig=({label:e,options:t,minWidth:o=120,...a})=>jsxRuntime.jsxs(material.FormControl,{fullWidth:true,size:"small",sx:{minWidth:o},children:[e&&jsxRuntime.jsx(material.InputLabel,{children:e}),jsxRuntime.jsx(material.Select,{label:e,...a,children:t.map(r=>jsxRuntime.jsx(material.MenuItem,{value:r.value,children:r.label},r.value))})]});var sd=[{value:"hour",label:"Hour",width:56},{value:"day",label:"Day",width:46},{value:"week",label:"Week",width:78},{value:"month",label:"Month",width:104}],ld=56,Pr=58,cd=8,dd=260,d1=320,ja="220ms cubic-bezier(0.2, 0, 0, 1)",Mg={"not-started":{label:"Not started",color:"default"},planned:{label:"Planned",color:"info"},"in-progress":{label:"In progress",color:"primary"},blocked:{label:"Blocked",color:"error"},done:{label:"Done",color:"success"}},p1=e=>e?Mg[e]?.label??e:"Planned",u1=e=>e?Mg[e]?.color??"default":"info",Ag=e=>Math.min(100,Math.max(0,e??0)),Bg=(e,t=0)=>e.flatMap(o=>[{...o,level:t},...Bg(o.children??[],t+1)]),m1=e=>({id:e.id,code:e.code??e.id,title:e.title,titleSub:e.project??e.workCenter??"General",owner:e.owner?.name??"Unassigned",status:p1(e.status),statusTone:e.status??"planned",progress:Ag(e.progress),startDate:e.startDate,endDate:e.endDate,color:e.color,reorderable:e.reorderable!==false}),Eg=(e,t)=>t==="month"?e.startOf("month"):t==="week"?e.startOf("week"):t==="day"?e.startOf("day"):e.startOf("hour"),Fg=(e,t)=>t==="month"?e.endOf("month"):t==="week"?e.endOf("week"):t==="day"?e.endOf("day"):e.endOf("hour"),g1=(e,t,o)=>{let a=[],r=Eg(e,o),n=Fg(t,o);for(;r.isBefore(n)||r.isSame(n);){let i=o==="month"?r.add(1,"month"):o==="week"?r.add(1,"week"):o==="day"?r.add(1,"day"):r.add(1,"hour");a.push({key:`${o}-${r.valueOf()}`,label:o==="month"?r.format("MMM YYYY"):o==="week"?r.format("MMM D"):o==="day"?r.format("D"):r.format("HH:mm"),start:r,end:i}),r=i;}return a},Dg=(e,t,o)=>{let a=0;for(let r of t){if(e.isBefore(r.start))return a;if(e.isBefore(r.end)){let n=Math.max(1,r.end.valueOf()-r.start.valueOf()),i=Math.max(0,e.valueOf()-r.start.valueOf());return a+i/n*o}a+=o;}return a},Lg=({title:e="Project Plan",subtitle:t="Task table and timeline view",extraTools:o,bodyHeight:a=560,tasks:r,scale:n="week",onScaleChange:i,timelineStart:c,timelineEnd:d,selectedTaskId:l,onTaskSelect:s,enableRowReorder:g=true,onTaskReorder:f,emptyLabel:u="No planning tasks available.",sx:h})=>{let v=material.useTheme(),p=ht.useRef(null),C=ht.useRef(null),m=ht.useRef(null),y=ht.useRef(false),[x,S]=ht.useState(null),[B,R]=ht.useState(null),[w,A]=ht.useState({}),[P,k]=ht.useState(ld),[D,T]=ht.useState([]),[I,M]=ht.useState({activeId:null,overId:null}),H=ht.useRef(null),V=ht.useMemo(()=>Bg(r),[r]),J=ht.useMemo(()=>{if(D.length===0)return V;let L=new Map(V.map(_=>[_.id,_])),$=D.map(_=>L.get(_)).filter(_=>!!_),j=new Set($.map(_=>_.id));return [...$,...V.filter(_=>!j.has(_.id))]},[V,D]),ce=ht.useMemo(()=>new Map(J.map(L=>[L.id,L])),[J]),te=ht.useMemo(()=>J.map(L=>m1(L)),[J]),ne=ht.useMemo(()=>new Map(te.map(L=>[L.id,L])),[te]),ee=ht.useMemo(()=>[{id:"code",label:"ID",minWidth:90},{id:"title",label:"Task",minWidth:260,render:(L,$)=>jsxRuntime.jsxs(material.Stack,{spacing:.2,children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:15,fontWeight:700,lineHeight:1.2},children:$.title}),jsxRuntime.jsx(material.Typography,{sx:{fontSize:13,color:"text.secondary"},children:$.titleSub})]})},{id:"owner",label:"Owner",minWidth:170},{id:"status",label:"Status",minWidth:130,render:(L,$)=>jsxRuntime.jsx(wg,{label:$.status,color:u1($.statusTone),size:"small"})},{id:"progress",label:"Progress",minWidth:140,numeric:true,render:L=>jsxRuntime.jsxs(material.Stack,{spacing:.6,children:[jsxRuntime.jsxs(material.Typography,{variant:"caption",sx:{color:"text.secondary"},children:[L,"%"]}),jsxRuntime.jsx(material.LinearProgress,{variant:"determinate",value:L,sx:{height:6,borderRadius:999}})]})},{id:"startDate",label:"Start",minWidth:120},{id:"endDate",label:"End",minWidth:120}],[]),Y=Yr({appId:"planning-gantt",title:e,columns:ee,rows:te,rowKey:"id",rowsPerPage:-1,rowsPerPageOptions:[-1],count:te.length,showSummary:false}),Ze=Y.visibleRows;ht.useEffect(()=>{let L=V.map($=>$.id);T($=>{let j=new Set(L),_=$.filter(z=>j.has(z)),ke=new Set(_),Ee=L.filter(z=>!ke.has(z)),Ye=[..._,...Ee];return Ye.length===$.length&&Ye.every((z,W)=>z===$[W])?$:Ye});},[V]);let Ue=L=>L.type==="group"?`group-${L.id}`:`row-${(L.data||L)?.id}`,ie=ht.useMemo(()=>{let L=te.map(W=>_a__default.default(W.startDate)),$=te.map(W=>_a__default.default(W.endDate)),j=c?_a__default.default(c):L.reduce((W,G)=>G.isBefore(W)?G:W,L[0]??_a__default.default()),_=d?_a__default.default(d):$.reduce((W,G)=>G.isAfter(W)?G:W,$[0]??_a__default.default().add(30,"day")),ke=n==="month"?"month":n==="week"?"week":n==="day"?"day":"hour",Ee=n==="month"?"month":n==="week"?"week":n==="day"?"day":"hour",Ye=n==="hour"?12:1,z=n==="hour"?12:1;return {start:Eg(j.subtract(Ye,ke),n),end:Fg(_.add(z,Ee),n)}},[te,n,d,c]),Ie=sd.find(L=>L.value===n)??sd[1],Fe=Array.isArray(o)?o:o?[o]:[],Oe=ht.useMemo(()=>g1(ie.start,ie.end,n),[ie.end,ie.start,n]),nt=Oe.length*Ie.width,Le=(Y.columns||[]).filter(L=>Y.visibleColumns.includes(L.id)).reduce((L,$)=>L+(Y.columnWidths?.[$.id]||$.minWidth||100),0),Xe=x??Le,Zt=B==="table",zt=B==="timeline",Qe=zt?0:Zt?"100%":Xe,lt=B==="timeline",mt=B==="table",_e=!lt&&!mt,K=Zt?"minmax(0, 1fr) 0px 0px":zt?"0px 0px minmax(0, 1fr)":`${Xe}px ${cd}px minmax(0, 1fr)`;ht.useEffect(()=>{S(L=>L===null?null:Math.min(Math.max(L,dd),Le));},[Le]);let Ce=L=>{L.preventDefault(),L.currentTarget.setPointerCapture(L.pointerId),R(null),H.current={startX:L.clientX,startWidth:Xe};let $=_=>{let ke=H.current;if(!ke)return;let Ee=p.current?.clientWidth??0,Ye=Ee>0?Math.max(dd,Ee-cd-d1):Le,z=Math.min(Math.max(ke.startWidth+_.clientX-ke.startX,dd),Ye);S(z);},j=()=>{H.current=null,window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",j),document.body.style.cursor="",document.body.style.userSelect="";};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",$),window.addEventListener("pointerup",j);},fe=()=>{R(null),S(null);},be=L=>!g||!L?false:ne.get(L)?.reorderable!==false,Ne=(L,$)=>{if(!L||!$||L===$||!be(L)||!be($))return false;if(Y.grouping.length===0)return true;let j=ne.get(L),_=ne.get($);return !j||!_?false:Y.grouping.every(ke=>j[ke]===_[ke])},Ve=(L,$)=>{if(!Ne(L,$))return;let j=Ze.filter(oe=>oe.type!=="group").map(oe=>String((oe.data||oe)?.id)),_=j.indexOf(L),ke=j.indexOf($);if(_<0||ke<0)return;let Ee=[...j];[Ee[_],Ee[ke]]=[Ee[ke],Ee[_]];let Ye=new Set(j),z=J.map(oe=>oe.id),W=[...Ee,...z.filter(oe=>!Ye.has(oe))],G=ce.get(L),ue=ce.get($);if(Y.setOrder("asc"),Y.setOrderBy(""),T(W),G&&ue){let{level:oe,...Se}=G,{level:ge,...Pe}=ue,he=W.reduce((ze,Be)=>{let we=ce.get(Be);if(we){let{level:Me,...Tt}=we;ze.push(Tt);}return ze},[]);f?.(he,{activeTask:Se,targetTask:Pe});}},Ht=(L,$)=>{if(!be($.id)){L.preventDefault();return}L.stopPropagation(),L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",$.id),M({activeId:$.id,overId:null}),s?.(ce.get($.id)||$);},Nt=(L,$)=>{if(!Ne(I.activeId,$)){M(j=>j.overId===null?j:{...j,overId:null});return}L.preventDefault(),L.stopPropagation(),L.dataTransfer.dropEffect="move",M(j=>j.overId===$?j:{...j,overId:$});},Xt=(L,$)=>{let j=I.activeId||L.dataTransfer.getData("text/plain");if(!Ne(j,$)){M({activeId:null,overId:null});return}L.preventDefault(),L.stopPropagation(),Ve(j,$),M({activeId:null,overId:null});},Qt=()=>{M({activeId:null,overId:null});},Yt=L=>{if(y.current)return;let $=L==="table"?C.current:m.current,j=L==="table"?m.current:C.current;!$||!j||(y.current=true,j.scrollTop=$.scrollTop,window.requestAnimationFrame(()=>{y.current=false;}));};return ht.useLayoutEffect(()=>{let L=C.current;if(!L)return;let $=0,j=()=>{let z=L.querySelector("thead"),W=Array.from(L.querySelectorAll("tbody tr[data-planning-row-key]"));if(W.length===0)return;let G=z?.getBoundingClientRect().height||ld,ue={};W.forEach(oe=>{let Se=oe.dataset.planningRowKey;Se&&(ue[Se]=oe.getBoundingClientRect().height);}),k(oe=>Math.abs(oe-G)<.01?oe:G),A(oe=>{let Se=Object.keys(oe),ge=Object.keys(ue);return Se.length===ge.length&&ge.every(Pe=>Math.abs((oe[Pe]??0)-ue[Pe])<.01)?oe:ue});},_=()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(j);};if(j(),typeof ResizeObserver>"u")return window.addEventListener("resize",_),()=>{window.cancelAnimationFrame($),window.removeEventListener("resize",_);};let ke=new ResizeObserver(_),Ee=L.querySelector("table"),Ye=L.querySelector("thead");return Ee&&ke.observe(Ee),Ye&&ke.observe(Ye),L.querySelectorAll("tbody tr[data-planning-row-key]").forEach(z=>ke.observe(z)),window.addEventListener("resize",_),()=>{window.cancelAnimationFrame($),ke.disconnect(),window.removeEventListener("resize",_);}},[Ze,Y.visibleColumns,Y.grouping,Y.columnWidths]),jsxRuntime.jsxs(xi,{elevation:0,sx:{m:0,p:0,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",borderRadius:3,border:`1px solid ${v.palette.divider}`,backgroundColor:v.palette.background.paper,...h},children:[jsxRuntime.jsxs(material.Stack,{direction:{xs:"column",md:"row"},justifyContent:"space-between",alignItems:{xs:"stretch",md:"center"},spacing:2,sx:{px:2,py:1.75,borderBottom:`1px solid ${v.palette.divider}`},children:[jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[jsxRuntime.jsx(material.Box,{sx:{width:38,height:38,borderRadius:2,display:"grid",placeItems:"center",backgroundColor:"primary.main",color:"primary.contrastText"},children:jsxRuntime.jsx(t1__default.default,{fontSize:"small"})}),jsxRuntime.jsxs(material.Box,{children:[jsxRuntime.jsx(material.Typography,{sx:{fontSize:18,fontWeight:800},children:e}),jsxRuntime.jsx(material.Typography,{variant:"body2",sx:{color:"text.secondary"},children:t})]})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{flexWrap:"wrap"},children:[Fe.length>0&&jsxRuntime.jsx(material.Stack,{direction:"row",spacing:.75,alignItems:"center",children:Fe.map((L,$)=>jsxRuntime.jsx(material.Box,{sx:{display:"flex",alignItems:"center"},children:L},`planning-extra-tool-${$}`))}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:.25,sx:{p:.5,borderRadius:2,backgroundColor:"action.hover"},children:[jsxRuntime.jsx(Ka,{tooltip:"Column visibility",onClick:L=>Y.setAnchorEl(L.currentTarget),color:"default",children:jsxRuntime.jsx(zf__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Group by",onClick:L=>Y.setGroupAnchorEl(L.currentTarget),color:"default",children:jsxRuntime.jsx(Of__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Sort by first visible column",onClick:()=>{let L=(Y.columns||[]).find($=>Y.visibleColumns.includes($.id));L&&Y.handleRequestSort(L.id);},color:Y.orderBy?"primary":"default",children:jsxRuntime.jsx(l1__default.default,{fontSize:"small"})})]}),jsxRuntime.jsxs(material.Stack,{direction:"row",spacing:.25,sx:{p:.5,borderRadius:2,backgroundColor:"action.hover"},children:[jsxRuntime.jsx(Ka,{tooltip:"Expand task table",onClick:()=>R("table"),color:B==="table"?"primary":"default",children:jsxRuntime.jsx(i1__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Reset split",onClick:fe,color:B===null?"primary":"default",children:jsxRuntime.jsx(s1__default.default,{fontSize:"small"})}),jsxRuntime.jsx(Ka,{tooltip:"Expand timeline",onClick:()=>R("timeline"),color:B==="timeline"?"primary":"default",children:jsxRuntime.jsx(n1__default.default,{fontSize:"small"})})]}),jsxRuntime.jsx(material.Box,{sx:{minWidth:120},children:jsxRuntime.jsx(Ig,{label:"",value:n,options:sd.map(L=>({value:L.value,label:L.label})),onChange:L=>i?.(L.target.value),sx:{"& .MuiSelect-select":{fontSize:"0.92rem",py:.65},"& .MuiSvgIcon-root":{fontSize:20}}})})]})]}),te.length===0?jsxRuntime.jsx(material.Box,{sx:{minHeight:240,display:"grid",placeItems:"center",color:"text.secondary"},children:u}):jsxRuntime.jsx(material.Box,{sx:{overflow:"hidden",flex:1,minHeight:0},children:jsxRuntime.jsxs(material.Box,{ref:p,sx:{height:"100%",display:"grid",gridTemplateColumns:K,transition:`grid-template-columns ${ja}`},children:[jsxRuntime.jsx(material.TableContainer,{"data-planning-scroll-pane":"table",ref:C,onScroll:()=>Yt("table"),sx:{width:Qe,height:a,overflowX:"auto",overflowY:"auto",opacity:lt?0:1,transform:lt?"translateX(-10px)":"translateX(0)",pointerEvents:lt?"none":"auto",transition:`opacity ${ja}, transform ${ja}, width ${ja}`},children:jsxRuntime.jsxs(material.Table,{size:"small",stickyHeader:true,sx:{tableLayout:"fixed",width:Le,"& thead .MuiTableCell-root":{height:ld,py:0,lineHeight:1.15,boxSizing:"border-box"}},children:[jsxRuntime.jsx(Ti,{columns:Y.columns,visibleColumns:Y.visibleColumns,order:Y.order,orderBy:Y.orderBy,onRequestSort:Y.handleRequestSort,grouping:Y.grouping,isAllExpanded:Y.isAllExpanded,handleToggleAll:Y.handleToggleAll,columnWidths:Y.columnWidths,onColumnResize:Y.handleColumnResize}),jsxRuntime.jsx(material.TableBody,{children:Ze.map(L=>{let $=Ue(L);if(L.type==="group")return jsxRuntime.jsxs(material.TableRow,{"data-planning-row-key":$,sx:{height:Pr,backgroundColor:v.palette.action.hover},children:[Y.grouping.length>0&&jsxRuntime.jsx(material.TableCell,{sx:{width:44,height:Pr,py:0,borderBottom:`1px solid ${v.palette.divider}`},children:jsxRuntime.jsx(material.IconButton,{size:"small",onClick:()=>Y.toggleGroupExpand(L.id),children:L.isExpanded?jsxRuntime.jsx(ch__default.default,{fontSize:"small"}):jsxRuntime.jsx(qf__default.default,{fontSize:"small"})})}),jsxRuntime.jsx(material.TableCell,{colSpan:Y.visibleColumns.length,sx:{height:Pr,py:0,borderBottom:`1px solid ${v.palette.divider}`},children:jsxRuntime.jsxs(material.Typography,{sx:{fontSize:13,fontWeight:700},children:[L.field,": ",L.value," (",L.count,")"]})})]},L.id);let j=L.data||L,_=j.id===l,ke=be(j.id),Ee=I.activeId===j.id,Ye=I.overId===j.id&&Ne(I.activeId,j.id);return jsxRuntime.jsxs(material.TableRow,{"data-planning-row-key":$,draggable:ke,hover:true,selected:_,onDragStart:z=>Ht(z,j),onDragOver:z=>Nt(z,j.id),onDragEnter:z=>Nt(z,j.id),onDrop:z=>Xt(z,j.id),onDragEnd:Qt,onClick:()=>s?.(ce.get(j.id)||j),sx:{cursor:Ee?"grabbing":ke?"grab":s?"pointer":"default",height:Pr,opacity:Ee?.56:1,"& .MuiTableCell-root":Ye?{borderTop:`2px solid ${v.palette.primary.main}`}:void 0,transition:"background-color 120ms ease, opacity 120ms ease"},children:[Y.grouping.length>0&&jsxRuntime.jsx(material.TableCell,{sx:{width:44,height:Pr,py:0,borderBottom:`1px solid ${v.palette.divider}`}}),(Y.columns||[]).filter(z=>Y.visibleColumns.includes(z.id)).map(z=>jsxRuntime.jsx(material.TableCell,{sx:{width:Y.columnWidths?.[z.id]||z.minWidth||100,height:Pr,py:0,overflow:"hidden",borderBottom:`1px solid ${v.palette.divider}`},children:z.render?z.render(j[z.id],j):String(j[z.id]??"-")},`${j.id}-${z.id}`))]},j.id)})})]})}),jsxRuntime.jsx(material.Box,{onPointerDown:_e?Ce:void 0,role:"separator","aria-orientation":"vertical",sx:{width:_e?cd:0,cursor:_e?"col-resize":"default",opacity:_e?1:0,pointerEvents:_e?"auto":"none",borderLeft:_e?`1px solid ${v.palette.divider}`:"0 solid transparent",borderRight:_e?`1px solid ${v.palette.divider}`:"0 solid transparent",backgroundColor:v.palette.mode==="dark"?"rgba(148,163,184,0.10)":"rgba(15,23,42,0.04)",transition:`width ${ja}, opacity ${ja}, background-color 120ms ease`,position:"relative","&:hover":{backgroundColor:v.palette.action.selected},"&::before":{content:'""',position:"absolute",top:0,bottom:0,left:-6,right:-6,cursor:_e?"col-resize":"default"}}}),jsxRuntime.jsx(material.Box,{sx:{minWidth:0,overflow:"hidden",opacity:mt?0:1,transform:mt?"translateX(10px)":"translateX(0)",pointerEvents:mt?"none":"auto",transition:`opacity ${ja}, transform ${ja}`},children:jsxRuntime.jsx(material.Box,{"data-planning-scroll-pane":"timeline",ref:m,onScroll:()=>Yt("timeline"),sx:{width:"100%",height:a,overflowX:"auto",overflowY:"auto"},children:jsxRuntime.jsxs(material.Box,{sx:{width:nt},children:[jsxRuntime.jsx(material.Box,{sx:{display:"grid",gridTemplateColumns:`repeat(${Oe.length}, ${Ie.width}px)`,height:P,boxSizing:"border-box",borderBottom:`1px solid ${v.palette.divider}`,position:"sticky",top:0,zIndex:2,backgroundColor:v.palette.background.paper},children:Oe.map(L=>jsxRuntime.jsx(material.Box,{sx:{px:.75,display:"flex",alignItems:"center",borderRight:`1px solid ${v.palette.divider}`,color:"text.secondary",fontSize:12,fontWeight:700},children:L.label},L.key))}),jsxRuntime.jsx(material.Stack,{sx:{position:"relative"},children:Ze.map(L=>{let $=Ue(L),j=w[$]??Pr;if(L.type==="group")return jsxRuntime.jsx(material.Box,{"data-planning-timeline-row-key":$,sx:{position:"relative",height:j,boxSizing:"border-box",borderBottom:`1px solid ${v.palette.divider}`,backgroundColor:v.palette.action.hover}},L.id);let _=L.data||L,ke=_a__default.default(_.startDate),Ee=_a__default.default(_.endDate),Ye=Dg(ke,Oe,Ie.width),z=Dg(Ee,Oe,Ie.width),W=Math.max(18,z-Ye),G=Ag(_.progress),ue=_.id===l,oe=be(_.id),Se=I.activeId===_.id,ge=I.overId===_.id&&Ne(I.activeId,_.id),Pe=_.color??(_.statusTone==="blocked"?v.palette.error.main:v.palette.primary.main);return jsxRuntime.jsx(material.Box,{"data-planning-timeline-row-key":$,draggable:oe,onDragStart:he=>Ht(he,_),onDragOver:he=>Nt(he,_.id),onDragEnter:he=>Nt(he,_.id),onDrop:he=>Xt(he,_.id),onDragEnd:Qt,onClick:()=>s?.(ce.get(_.id)||_),sx:{position:"relative",height:j,boxSizing:"border-box",borderBottom:`1px solid ${v.palette.divider}`,opacity:Se?.56:1,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,height:2,backgroundColor:v.palette.primary.main,opacity:ge?1:0,transition:"opacity 120ms ease",pointerEvents:"none",zIndex:3},backgroundImage:v.palette.mode==="dark"?"linear-gradient(90deg, rgba(148,163,184,0.08) 1px, transparent 1px)":"linear-gradient(90deg, rgba(15,23,42,0.06) 1px, transparent 1px)",backgroundSize:`${Ie.width}px 100%`,cursor:Se?"grabbing":oe?"grab":s?"pointer":"default",transition:"opacity 120ms ease"},children:jsxRuntime.jsx(material.Tooltip,{title:`${_.title}: ${ke.format("MMM D HH:mm")} - ${Ee.format("MMM D HH:mm")}`,children:jsxRuntime.jsxs(material.Box,{sx:{position:"absolute",left:Ye,top:Math.max(8,(j-24)/2),width:W,height:24,borderRadius:999,overflow:"hidden",backgroundColor:v.palette.mode==="dark"?"rgba(148,163,184,0.18)":"rgba(15,23,42,0.10)",outline:ue?`2px solid ${v.palette.warning.main}`:"none",outlineOffset:2},children:[jsxRuntime.jsx(material.Box,{sx:{height:"100%",width:`${G}%`,backgroundColor:Pe}}),jsxRuntime.jsx(material.Typography,{sx:{position:"absolute",inset:0,px:1,display:"flex",alignItems:"center",color:"#fff",fontSize:11,fontWeight:800,textShadow:"0 1px 4px rgba(0,0,0,0.45)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.code})]})})},_.id)})})]})})})]})}),jsxRuntime.jsx(Nr,{groupAnchorEl:Y.groupAnchorEl,setGroupAnchorEl:Y.setGroupAnchorEl,grouping:Y.grouping,setGrouping:Y.setGrouping,columns:Y.columns,toggleGroupField:Y.toggleGroupField}),jsxRuntime.jsx(Vr,{anchorEl:Y.anchorEl,setAnchorEl:Y.setAnchorEl,columns:Y.columns,visibleColumns:Y.visibleColumns,toggleColumnVisibility:Y.toggleColumnVisibility})]})};var rV=({filterProps:e,ganttProps:t,spacing:o=2,sx:a,children:r})=>{let n=a?[{height:"100%",overflow:"hidden"},a]:{height:"100%",overflow:"hidden"},i=t.sx?[{height:"100%"},t.sx]:{height:"100%"};return jsxRuntime.jsxs(material.Stack,{spacing:o,sx:n,children:[jsxRuntime.jsx(material.Box,{sx:{flexShrink:0},children:jsxRuntime.jsx(ca,{...e})}),jsxRuntime.jsx(material.Box,{sx:{flex:1,minHeight:0,overflow:"hidden"},children:jsxRuntime.jsx(Lg,{...t,bodyHeight:t.bodyHeight??"100%",sx:i})}),r]})};var k1={none:{from:{},to:{}},fade:{from:{opacity:0},to:{opacity:1}},"slide-up":{from:{opacity:0,transform:"translate3d(0, 12px, 0)"},to:{opacity:1,transform:"translate3d(0, 0, 0)"}},"slide-left":{from:{opacity:0,transform:"translate3d(12px, 0, 0)"},to:{opacity:1,transform:"translate3d(0, 0, 0)"}},scale:{from:{opacity:0,transform:"scale(0.985)"},to:{opacity:1,transform:"scale(1)"}}},cV=({children:e,transitionKey:t,variant:o="fade",durationMs:a=220,delayMs:r=0,easing:n="cubic-bezier(0.22, 1, 0.36, 1)",disabled:i=false,sx:c})=>{let d=material.useMediaQuery("(prefers-reduced-motion: reduce)"),[l,s]=ht.useState("to"),g=!i&&!d&&o!=="none";ht.useEffect(()=>{if(!g){s("to");return}s("from");let h=requestAnimationFrame(()=>{h=requestAnimationFrame(()=>{s("to");});});return ()=>cancelAnimationFrame(h)},[t,g]);let f=k1[o],u=ht.useMemo(()=>g?l==="from"?f.from:f.to:{opacity:1,transform:"none"},[g,l,f.from,f.to]);return jsxRuntime.jsx(material.Box,{sx:{willChange:g?"opacity, transform":"auto",transition:g?`opacity ${a}ms ${n} ${r}ms, transform ${a}ms ${n} ${r}ms`:"none",backfaceVisibility:"hidden",...u,...c},children:e})},dV={subtle:{variant:"fade",durationMs:180},smooth:{variant:"slide-up",durationMs:220},snappy:{variant:"scale",durationMs:160}};
199
199
  exports.AgentPanel=Lz;exports.Button=hl;exports.CAINavProvider=Fk;exports.CAmapChart=tp;exports.CAppHeader=ws;exports.CAppPageLayout=DA;exports.CAuthPage=mN;exports.CBarChart=En;exports.CChartCard=Ai;exports.CComboChart=Hd;exports.CCustomizeAgent=np;exports.CDetailInfoPage=E2;exports.CDetailSearchAiBar=tu;exports.CDetailSectionCard=gs;exports.CFishboneChart=qd;exports.CGoogleMapChart=Qd;exports.CGraphCharts=op;exports.CGraphKpiCards=Vd;exports.CGraphReport=qi;exports.CHeatmapChart=Ud;exports.CKanbanBoard=eA;exports.CKanbanBucket=su;exports.CKanbanCard=mc;exports.CLayoutManagement=Dp;exports.CLayoutManager=rs;exports.CLineChart=$d;exports.CMessageBox=Rn;exports.COrbCanvas=vk;exports.CPageLayout=Id;exports.CPageTransition=cV;exports.CPieChart=Vi;exports.CPivotTable=y5;exports.CPlanningGantt=Lg;exports.CPlanningLayout=rV;exports.CSmartFilter=ca;exports.CSmartTable=YD;exports.CStandardPage=nM;exports.CTable=La;exports.CTableBody=_D;exports.CTableCell=jD;exports.CTableContainer=ZD;exports.CTableHead=XD;exports.CTableRow=QD;exports.CVariantManagement=Xi;exports.CVariantManager=fp;exports.CVoiceWaveOverlay=Kc;exports.CWaterfallChart=jd;exports.CodeBlock=Kn;exports.CopilotChat=Gz;exports.GlobalMessage=PT;exports.MarkdownRenderer=Xn;exports.MathBlock=qn;exports.MermaidBlock=Jl;exports.NavigationIsland=kd;exports.ORBCAFE_I18N_MESSAGES=Pn;exports.OrbcafeI18nProvider=Si;exports.PAGE_TRANSITION_PRESETS=dV;exports.PAppPageLayout=_E;exports.PBarcodeScanner=z5;exports.PNavIsland=Tm;exports.PNumericKeypad=Q5;exports.PSmartFilter=ym;exports.PTable=rk;exports.PTouchCard=H5;exports.PWorkloadNav=vm;exports.PivotChartPanel=Zu;exports.StdChat=hg;exports.TableBlock=tc;exports.ThinkBlock=us;exports.TreeMenu=bl;exports.VoiceNavigatorProvider=cF;exports.VoiceWaveOverlay=tF;exports.buildAmapEmbedUrl=$i;exports.buildGoogleMapEmbedUrl=zn;exports.buildGoogleMapIframe=iP;exports.buttonVariants=Kg;exports.createKanbanBoardModel=du;exports.findKanbanCard=No;exports.message=dT;exports.messageManager=na;exports.moveKanbanCard=xs;exports.parseMarkdownTable=ds;exports.renderMarkdown=o2;exports.resolveVariantFilters=Ap;exports.resolveVariantLayout=ns;exports.useAINav=Lk;exports.useAmapEmbedUrl=vM;exports.useAuthPage=_z;exports.useDetailInfo=au;exports.useGoogleMapEmbedUrl=xM;exports.useGraphChartData=gM;exports.useGraphInteraction=ji;exports.useGraphReport=jr;exports.useKanbanBoard=nA;exports.useNavigationIsland=wd;exports.useOrbcafeI18n=Q;exports.usePadLayout=P5;exports.usePadRecordEditor=M5;exports.usePageLayout=vu;exports.usePivotTable=k5;exports.usePlanningGantt=Sg;exports.usePlanningLayout=CN;exports.useStandardReport=pM;exports.useVoiceInput=Xs;exports.useVoiceNavigator=dF;