larkup 0.4.43 → 0.4.45

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.
Files changed (78) hide show
  1. package/.next/standalone/apps/web/.next/BUILD_ID +1 -1
  2. package/.next/standalone/apps/web/.next/app-path-routes-manifest.json +27 -27
  3. package/.next/standalone/apps/web/.next/build-manifest.json +2 -2
  4. package/.next/standalone/apps/web/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/apps/web/.next/required-server-files.json +1 -1
  6. package/.next/standalone/apps/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/apps/web/.next/server/app/_global-error.html +1 -1
  8. package/.next/standalone/apps/web/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/standalone/apps/web/.next/server/app/_not-found.html +1 -1
  14. package/.next/standalone/apps/web/.next/server/app/_not-found.rsc +3 -3
  15. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  16. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  17. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  18. package/.next/standalone/apps/web/.next/server/app/add/page_client-reference-manifest.js +1 -1
  19. package/.next/standalone/apps/web/.next/server/app/add.html +1 -1
  20. package/.next/standalone/apps/web/.next/server/app/add.rsc +3 -3
  21. package/.next/standalone/apps/web/.next/server/app/add.segments/_full.segment.rsc +3 -3
  22. package/.next/standalone/apps/web/.next/server/app/add.segments/_tree.segment.rsc +2 -2
  23. package/.next/standalone/apps/web/.next/server/app/add.segments/add/__PAGE__.segment.rsc +3 -3
  24. package/.next/standalone/apps/web/.next/server/app/api/chat/route.js +10 -8
  25. package/.next/standalone/apps/web/.next/server/app/chat/[id]/page_client-reference-manifest.js +1 -1
  26. package/.next/standalone/apps/web/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  27. package/.next/standalone/apps/web/.next/server/app/chat.html +1 -1
  28. package/.next/standalone/apps/web/.next/server/app/chat.rsc +4 -4
  29. package/.next/standalone/apps/web/.next/server/app/chat.segments/_full.segment.rsc +4 -4
  30. package/.next/standalone/apps/web/.next/server/app/chat.segments/_tree.segment.rsc +2 -2
  31. package/.next/standalone/apps/web/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +4 -4
  32. package/.next/standalone/apps/web/.next/server/app/data/page_client-reference-manifest.js +1 -1
  33. package/.next/standalone/apps/web/.next/server/app/data.html +1 -1
  34. package/.next/standalone/apps/web/.next/server/app/data.rsc +3 -3
  35. package/.next/standalone/apps/web/.next/server/app/data.segments/_full.segment.rsc +3 -3
  36. package/.next/standalone/apps/web/.next/server/app/data.segments/_tree.segment.rsc +2 -2
  37. package/.next/standalone/apps/web/.next/server/app/data.segments/data/__PAGE__.segment.rsc +3 -3
  38. package/.next/standalone/apps/web/.next/server/app/index.html +1 -1
  39. package/.next/standalone/apps/web/.next/server/app/index.rsc +3 -3
  40. package/.next/standalone/apps/web/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  41. package/.next/standalone/apps/web/.next/server/app/index.segments/_full.segment.rsc +3 -3
  42. package/.next/standalone/apps/web/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  43. package/.next/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  44. package/.next/standalone/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  45. package/.next/standalone/apps/web/.next/server/app/settings.html +1 -1
  46. package/.next/standalone/apps/web/.next/server/app/settings.rsc +3 -3
  47. package/.next/standalone/apps/web/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  48. package/.next/standalone/apps/web/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  49. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +3 -3
  50. package/.next/standalone/apps/web/.next/server/app/widget-demo/page_client-reference-manifest.js +1 -1
  51. package/.next/standalone/apps/web/.next/server/app/widget-demo.html +1 -1
  52. package/.next/standalone/apps/web/.next/server/app/widget-demo.rsc +3 -3
  53. package/.next/standalone/apps/web/.next/server/app/widget-demo.segments/_full.segment.rsc +3 -3
  54. package/.next/standalone/apps/web/.next/server/app/widget-demo.segments/_tree.segment.rsc +2 -2
  55. package/.next/standalone/apps/web/.next/server/app/widget-demo.segments/widget-demo/__PAGE__.segment.rsc +3 -3
  56. package/.next/standalone/apps/web/.next/server/app-paths-manifest.json +27 -27
  57. package/.next/standalone/apps/web/.next/server/chunks/309.js +1 -1
  58. package/.next/standalone/apps/web/.next/server/chunks/5345.js +2 -2
  59. package/.next/standalone/apps/web/.next/server/middleware-build-manifest.js +1 -1
  60. package/.next/standalone/apps/web/.next/server/pages/404.html +1 -1
  61. package/.next/standalone/apps/web/.next/server/pages/500.html +1 -1
  62. package/.next/standalone/apps/web/.next/server/preview-props.json +3 -3
  63. package/.next/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  64. package/.next/standalone/apps/web/.next/static/chunks/7363-29e460bb5f13e54c.js +2 -0
  65. package/.next/standalone/apps/web/.next/static/chunks/app/{layout-82a744f2d2a31744.js → layout-75a13b9806a8382c.js} +1 -1
  66. package/.next/standalone/apps/web/.next/static/css/295d51125aa849b7.css +1 -0
  67. package/.next/standalone/apps/web/lib/chat/analysis-completeness.test.ts +35 -1
  68. package/.next/standalone/apps/web/lib/chat/matching-analysis-fallback.test.ts +46 -0
  69. package/.next/standalone/apps/web/lib/chat/tabular-routing.test.ts +43 -0
  70. package/.next/standalone/apps/web/lib/chat/tabular-sandbox-files.test.ts +11 -0
  71. package/.next/standalone/apps/web/lib/chat/tool-context.test.ts +18 -0
  72. package/.next/standalone/apps/web/package.json +11 -11
  73. package/.next/standalone/apps/web/server.js +1 -1
  74. package/package.json +13 -13
  75. package/.next/standalone/apps/web/.next/static/chunks/7363-46b08ee0bbb06aa2.js +0 -2
  76. package/.next/standalone/apps/web/.next/static/css/3d6a741cc52c5cb2.css +0 -1
  77. /package/.next/standalone/apps/web/.next/static/{g7clZdtou90PRiuXHff7- → sK-yq_GyR8nI_Rn0QeXB7}/_buildManifest.js +0 -0
  78. /package/.next/standalone/apps/web/.next/static/{g7clZdtou90PRiuXHff7- → sK-yq_GyR8nI_Rn0QeXB7}/_ssgManifest.js +0 -0
@@ -0,0 +1,2 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7363],{12578:(e,t,s)=>{"use strict";s.r(t),s.d(t,{ChatWorkspace:()=>sA});var r=s(58395),a=s(43012),n=s(27915),i=s(37624),l=s(58511);function o(e){if(!e||"object"!=typeof e)return e;if("json"===e.type&&"value"in e)return{...e,value:o(e.value)};let t={...e};return Array.isArray(t.rows)&&(t.rows=t.rows.slice(0,50)),Array.isArray(t.data)&&(t.data=t.data.slice(0,100)),"string"==typeof t.stdout&&(t.stdout=t.stdout.slice(0,4e3)),"string"==typeof t.stderr&&(t.stderr=t.stderr.slice(0,1e3)),"string"==typeof t.fileBase64&&delete t.fileBase64,Array.isArray(t.pages)&&(t.pages=t.pages.slice(0,3).flatMap(e=>e&&"object"==typeof e&&Number.isInteger(e.pageNumber)?[{pageNumber:e.pageNumber,..."string"==typeof e.previewUrl?{previewUrl:e.previewUrl}:{}}]:[])),t}var d=s(85755),c=s(10335),u=s(99845),m=s(35911),x=s(36445),p=s(11229),h=s(42328),f=s(98557),g=s(27857),b=s(92254),j=s(10464),v=s(86163),y=s(52252),N=s(88986),w=s(99384),k=s(87222),S=s(71550),C=s(31337),A=s(19466);s(36169);var $=s(20203),z=s(67452),I=s(81720),T=s(22299),L=s(31813),F=s(9129),D=s(53655);function M({text:e,liked:t,disliked:s,onLike:a,onDislike:i,onRegenerate:l,regenerateLabel:o="Regenerate",className:d}){let{copied:c,copy:u}=function(e=2e3){let[t,s]=(0,n.useState)(!1),r=(0,n.useRef)(null);return{copied:t,copy:(0,n.useCallback)(async t=>{if(t)try{await navigator.clipboard.writeText(t),s(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>s(!1),e)}catch(e){console.error("Copy to clipboard failed",e)}},[e])}}();return(0,r.jsx)(F.Bc,{delay:200,children:(0,r.jsxs)("div",{className:(0,D.cn)("flex items-center gap-0.5",d),children:[(0,r.jsx)(R,{label:c?"Copied":"Copy",onClick:()=>u(e),children:c?(0,r.jsx)($.A,{className:"size-3.5 text-emerald-500"}):(0,r.jsx)(z.A,{className:"size-3.5"})}),a&&i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(R,{label:t?"Liked — saved with this chat":"Like",onClick:a,pressed:t,children:(0,r.jsx)(I.A,{className:(0,D.cn)("size-3.5",t&&"fill-current text-emerald-500")})}),(0,r.jsx)(R,{label:s?"Disliked — cached answer removed":"Dislike",onClick:i,pressed:s,children:(0,r.jsx)(T.A,{className:(0,D.cn)("size-3.5",s&&"fill-current text-destructive")})})]}):null,l?(0,r.jsx)(R,{label:o,onClick:l,children:(0,r.jsx)(j.A,{className:"size-3.5"})}):null]})})}function R({label:e,onClick:t,children:s,pressed:a}){return(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)(L.$,{type:"button",variant:"ghost",size:"icon-xs",onClick:t,"aria-label":e,"aria-pressed":a,className:"text-muted-foreground hover:text-foreground"}),children:s}),(0,r.jsx)(F.ZI,{children:e})]})}var E=s(73788),P=s(47805),O=s(35970),_=s(46797),U=s(27059),B=s(79693),W=s(62533),K=s(13894),V=s(31120),q=s(90815),J=s(9987),Z=s(68253),H=s(32549),G=s(14550),X=s(77233),Y=s(1201),Q=s(44131),ee=s(27402),et=s(38697),es=s(39841),er=s(77163),ea=s(90902),en=s(85251);let ei=new Set(["bar","area","line","pie","scatter","radar"]),el=/^(?:\s|_)*(?:empty|null|undefined|n\/?a|unknown)(?:\s*[_-]?\s*\d+)?(?:\s|_)*$/i;function eo(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ed(e){return"string"==typeof e&&e.trim().length>0&&!el.test(e.trim())}function ec(e){return e.toLocaleLowerCase().replace(/[^\p{L}\p{N}]/gu,"")}function eu(e,t){if(!ed(e))return;if(t.includes(e))return e;let s=ec(e);return t.find(e=>ec(e)===s)}function em(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"!=typeof e)return;let t=e.trim();if(!t)return;let s=t.replace(/[\s,]/g,"").replace(/[€£$¥%]/g,"");if(!/^-?(?:\d+(?:\.\d+)?|\.\d+)$/.test(s))return;let r=Number(s);return Number.isFinite(r)?r:void 0}function ex(e,t){return e.some(e=>{let s=e[t];return null!=s&&String(s).trim().length>0&&!("string"==typeof s&&el.test(s.trim()))})}function ep(e,t){return e.some(e=>void 0!==em(e[t]))}function eh(e){return e.replace(/^(sum|avg|count|min|max|median)_/i,"$1 ").replace(/[_-]+/g," ").replace(/\s+/g," ").trim()}function ef(e){return ed(e)?e.trim():void 0}let eg=["#10b981","#f97316","#3b82f6","#22c55e","#f59e0b","#0ea5e9","#84cc16","#ea580c","#2563eb"];function eb({series:e}){return(0,r.jsx)("defs",{children:e.map((e,t)=>{let s=e.color||eg[t%eg.length];return(0,r.jsxs)("linearGradient",{id:`gradient-${e.dataKey}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,r.jsx)("stop",{offset:"5%",stopColor:s,stopOpacity:.25}),(0,r.jsx)("stop",{offset:"95%",stopColor:s,stopOpacity:.02})]},e.dataKey)})})}function ej({active:e,payload:t,label:s}){return e&&t&&0!==t.length?(0,r.jsxs)("div",{className:"rounded-lg border border-border/40 bg-card px-3 py-2.5 backdrop-blur-sm",children:[(0,r.jsx)("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:s}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:t.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:e.color}}),(0,r.jsxs)("span",{className:"text-muted-foreground",children:[e.name||e.dataKey,":"]}),(0,r.jsx)("span",{className:"font-medium tabular-nums text-foreground",children:"number"==typeof e.value?e.value.toLocaleString(void 0,{maximumFractionDigits:2}):e.value})]},t))})]}):null}let ev={fontSize:11,fill:"var(--muted-foreground)",fontFamily:"inherit"},ey={stroke:"var(--border)"},eN={fontSize:11,paddingTop:12},ew={fontSize:11},ek={stroke:"var(--muted-foreground)",strokeWidth:1},eS={strokeDasharray:"3 3"},eC={fontSize:11,fill:"var(--muted-foreground)"},eA={fontSize:10,fill:"var(--muted-foreground)"},e$={r:4,strokeWidth:2,stroke:"var(--card)"},ez=[4,4,0,0],eI={top:6,right:12,bottom:8,left:12},eT=({name:e,percent:t})=>`${e} ${(100*t).toFixed(0)}%`;function eL(e,t){let s=(0,n.useRef)(null),r=JSON.stringify(t);return(null===s.current||JSON.stringify(s.current.deps)!==r)&&(s.current={deps:JSON.parse(r),value:e()}),s.current.value}function eF({config:e}){let t=(0,n.useRef)(null),[s,a]=(0,n.useState)(!1),i=(0,n.useMemo)(()=>(function(e){let t=eo(e)?e:{},s=Array.isArray(t.data)?t.data.filter(eo):[],r=[...new Set(s.flatMap(e=>Object.keys(e)))].filter(ed),a=ei.has(t.chartType)?t.chartType:"bar",n=r.filter(e=>ep(s,e)),i=eu(t.xAxisKey,r);"scatter"===a?i&&ep(s,i)||(i=n[0]):i&&ex(s,i)||(i=r.find(e=>!ep(s,e)&&ex(s,e))??r.find(e=>ex(s,e))),"scatter"!==a&&i&&ep(s,i)&&!n.some(e=>e!==i)&&r.some(e=>e!==i&&!ep(s,e)&&ex(s,e))&&(i=r.find(e=>e!==i&&!ep(s,e)&&ex(s,e)));let l=Array.isArray(t.series)?t.series.filter(eo):[],o=[],d=new Set;for(let e of l){let t=eu(e.dataKey,n);if(!t||t===i||d.has(t))continue;let s=ef(e.label);d.add(t),o.push({dataKey:t,label:s??eh(t),...ef(e.color)?{color:ef(e.color)}:{}})}if(0===o.length)for(let e of n)e!==i&&(d.add(e),o.push({dataKey:e,label:eh(e)}));"pie"===a&&o.length>1&&o.splice(1);let c=s.map(e=>{let t={};for(let s of(i&&void 0!==e[i]&&null!==e[i]&&(t[i]=e[i]),o)){let r=em(e[s.dataKey]);void 0!==r&&(t[s.dataKey]=r)}return t}).filter(e=>!!(i&&ex([e],i))&&o.some(t=>void 0!==em(e[t.dataKey]))),u=ef(t.title)??(i&&o[0]?`${o[0].label??eh(o[0].dataKey)} by ${eh(i)}`:"Data chart"),m=0===s.length?"No data was provided for this chart.":i?0===o.length?"No numeric data series was provided for this chart.":0===c.length?"The supplied rows do not contain plottable values.":void 0:"No usable category or X-axis field was provided.",x=ef(t.xAxisLabel)??(i?eh(i):void 0),p=ef(t.yAxisLabel)??function(e){let t=e.map(e=>e.label??eh(e.dataKey));if(0===t.length)return;if(1===t.length)return t[0];let s=t.map(e=>e.split(/\s+/).filter(Boolean)),r=[];for(let e=1;e<=Math.min(...s.map(e=>e.length));e+=1){let t=s[0][s[0].length-e];if(!s.every(s=>s[s.length-e]?.toLowerCase()===t.toLowerCase()))break;r.unshift(t)}if(r.length>0)return r.join(" ");let a=t.join(" / ");return a.length<=40?a:"Value"}(o);return{chartType:a,title:u,...ef(t.subtitle)?{subtitle:ef(t.subtitle)}:{},data:c,xAxisKey:i??"",series:o,...Array.isArray(t.colors)?{colors:t.colors.filter(e=>ed(e))}:{},..."boolean"==typeof t.stacked?{stacked:t.stacked}:{},showLegend:"boolean"==typeof t.showLegend?t.showLegend:o.length>1,...x?{xAxisLabel:x}:{},...p?{yAxisLabel:p}:{},...m?{error:m}:{}}})(e),[e]),{chartType:l,title:o,subtitle:d,data:c,xAxisKey:u,series:m,colors:x,stacked:p,showLegend:h=!0,xAxisLabel:f,yAxisLabel:g}=i,b=eL(()=>{let e=x&&x.length>0?x:eg;return m.map((t,s)=>t.color||e[s%e.length])},[m,x]),j=eL(()=>x&&x.length>0?x:eg,[x]),v=eL(()=>b.map(e=>({r:3,fill:e})),[b]),y=(0,n.useCallback)(()=>{!function(e){if(0===e.length)return;let t=Object.keys(e[0]),s=[t.join(" "),...e.map(e=>t.map(t=>String(e[t]??"")).join(" "))].join("\n");navigator.clipboard.writeText(s)}(c),a(!0),setTimeout(()=>a(!1),2e3)},[c]),N=(0,n.useCallback)(()=>(function(e,t){if(0===e.length)return;let s=Object.keys(e[0]),r=new Blob([[s.join(","),...e.map(e=>s.map(t=>{let s=String(e[t]??"");return s.includes(",")?`"${s}"`:s}).join(","))].join("\n")],{type:"text/csv"}),a=URL.createObjectURL(r),n=document.createElement("a");n.href=a,n.download=`${t.replace(/\s+/g,"_").toLowerCase()}.csv`,n.click(),URL.revokeObjectURL(a)})(c,o),[c,o]),w=eL(()=>f?{value:f,position:"insideBottom",offset:-4,style:{fontSize:11,fill:"var(--muted-foreground)"}}:void 0,[f]),k=eL(()=>g?{value:g,angle:-90,position:"insideLeft",offset:-8,style:{fontSize:11,fill:"var(--muted-foreground)"}}:void 0,[g]);return i.error?(0,r.jsxs)("div",{className:"my-3 flex flex-col items-center justify-center rounded-lg border border-border/70 bg-transparent p-6 text-center text-muted-foreground",children:[(0,r.jsx)("p",{className:"text-sm",children:"This chart could not be prepared"}),(0,r.jsx)("p",{className:"text-xs opacity-70 mt-1",children:i.error})]}):(0,r.jsxs)("div",{ref:t,"data-testid":"chat-chart",className:"my-3 overflow-hidden rounded-lg border border-border/70 bg-muted/25 animate-in fade-in duration-300 [&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none [&_*:focus]:outline-none [&_*:focus-visible]:outline-none [&_*:focus-visible]:ring-0",children:[(0,r.jsx)("div",{className:"flex flex-row items-center justify-between gap-4 border-b border-border/30 px-3.5 py-2.5",children:(0,r.jsxs)("div",{className:"flex flex-col justify-center min-w-0",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground truncate",children:o}),d&&(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground truncate",children:d})]})}),(0,r.jsx)("div",{className:"px-1 pt-2.5 pb-0",children:(0,r.jsx)("div",{className:"h-68 min-h-68 w-full sm:h-72 sm:min-h-72",children:(0,r.jsx)(ea.u,{width:"100%",height:"100%",debounce:50,children:(()=>{switch(l){case"bar":return(0,r.jsxs)(E.E,{data:c,barGap:4,barCategoryGap:"20%",margin:eI,children:[(0,r.jsx)(P.d,{strokeDasharray:"3 3",stroke:"var(--border)",opacity:.4,vertical:!1}),(0,r.jsx)(O.W,{dataKey:u,tick:ev,axisLine:ey,tickLine:!1,tickMargin:8,minTickGap:24,height:52,label:w}),(0,r.jsx)(_.h,{tick:ev,axisLine:!1,tickLine:!1,tickMargin:8,width:62,label:k}),(0,r.jsx)(U.m,{content:ej,cursor:!1}),h&&(0,r.jsx)(B.s,{iconType:"circle",iconSize:7,wrapperStyle:eN}),m.map((e,t)=>(0,r.jsx)(W.yP,{dataKey:e.dataKey,name:e.label||e.dataKey,fill:b[t],stackId:p?"stack":void 0,radius:ez,maxBarSize:40,animationDuration:700,animationEasing:"ease-in-out"},e.dataKey))]});case"area":return(0,r.jsxs)(K.Q,{data:c,margin:eI,children:[(0,r.jsx)(eb,{series:m}),(0,r.jsx)(P.d,{strokeDasharray:"3 3",stroke:"var(--border)",opacity:.4,vertical:!1}),(0,r.jsx)(O.W,{dataKey:u,tick:ev,axisLine:ey,tickLine:!1,tickMargin:8,minTickGap:24,height:52,label:w}),(0,r.jsx)(_.h,{tick:ev,axisLine:!1,tickLine:!1,tickMargin:8,width:62,label:k}),(0,r.jsx)(U.m,{content:ej}),h&&(0,r.jsx)(B.s,{iconType:"circle",iconSize:7,wrapperStyle:eN}),m.map((e,t)=>(0,r.jsx)(V.Gk,{type:"monotone",dataKey:e.dataKey,name:e.label||e.dataKey,stroke:b[t],strokeWidth:2,fill:`url(#gradient-${e.dataKey})`,stackId:p?"stack":void 0,animationDuration:800,animationEasing:"ease-in-out"},e.dataKey))]});case"line":return(0,r.jsxs)(q.b,{data:c,margin:eI,children:[(0,r.jsx)(P.d,{strokeDasharray:"3 3",stroke:"var(--border)",opacity:.4,vertical:!1}),(0,r.jsx)(O.W,{dataKey:u,tick:ev,axisLine:ey,tickLine:!1,tickMargin:8,minTickGap:24,height:52,label:w}),(0,r.jsx)(_.h,{tick:ev,axisLine:!1,tickLine:!1,tickMargin:8,width:62,label:k}),(0,r.jsx)(U.m,{content:ej}),h&&(0,r.jsx)(B.s,{iconType:"circle",iconSize:7,wrapperStyle:eN}),m.map((e,t)=>(0,r.jsx)(J.N1,{type:"monotone",dataKey:e.dataKey,name:e.label||e.dataKey,stroke:b[t],strokeWidth:2,dot:v[t],activeDot:e$,animationDuration:800,animationEasing:"ease-in-out"},e.dataKey))]});case"pie":{let e=m[0]?.dataKey||"value";return(0,r.jsxs)(Z.r,{children:[(0,r.jsx)(U.m,{content:ej}),(0,r.jsx)(H.Fq,{data:c,dataKey:e,nameKey:u,cx:"50%",cy:"50%",outerRadius:"75%",innerRadius:"48%",paddingAngle:2,animationDuration:700,animationEasing:"ease-in-out",label:eT,labelLine:ek,children:c.map((e,t)=>(0,r.jsx)(G.f,{fill:j[t%j.length],stroke:"var(--card)",strokeWidth:2},`cell-${t}`))}),h&&(0,r.jsx)(B.s,{iconType:"circle",iconSize:7,wrapperStyle:ew})]})}case"scatter":return(0,r.jsxs)(X.t,{margin:eI,children:[(0,r.jsx)(P.d,{strokeDasharray:"3 3",stroke:"var(--border)",opacity:.4,vertical:!1}),(0,r.jsx)(O.W,{dataKey:u,type:"number",tick:ev,axisLine:ey,tickLine:!1,tickMargin:8,minTickGap:24,height:52,name:f||u,label:w}),(0,r.jsx)(_.h,{dataKey:m[0]?.dataKey,type:"number",tick:ev,axisLine:!1,tickLine:!1,tickMargin:8,width:62,name:g||m[0]?.label||m[0]?.dataKey,label:k}),(0,r.jsx)(U.m,{content:ej,cursor:eS}),(0,r.jsx)(Y.Xl,{name:m[0]?.label||m[0]?.dataKey,data:c,fill:b[0],animationDuration:700,animationEasing:"ease-in-out"})]});case"radar":return(0,r.jsxs)(Q.V,{data:c,outerRadius:"75%",children:[(0,r.jsx)(ee.z,{stroke:"var(--border)",opacity:.5}),(0,r.jsx)(et.r,{dataKey:u,tick:eC}),(0,r.jsx)(es.E,{tick:eA}),(0,r.jsx)(U.m,{content:ej}),m.map((e,t)=>(0,r.jsx)(er.Vd,{dataKey:e.dataKey,name:e.label||e.dataKey,stroke:b[t],fill:b[t],fillOpacity:.12,strokeWidth:2,animationDuration:700,animationEasing:"ease-in-out"},e.dataKey)),h&&(0,r.jsx)(B.s,{iconType:"circle",iconSize:7,wrapperStyle:ew})]});default:return null}})()})})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-start gap-1.5 border-t border-border/30 px-3 py-2",children:[(0,r.jsxs)(L.$,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[11px] text-muted-foreground hover:text-foreground focus:ring-0 focus-visible:ring-0",onClick:y,children:[s?(0,r.jsx)($.A,{className:"h-3 w-3 text-emerald-500"}):(0,r.jsx)(z.A,{className:"h-3 w-3"}),s?"Copied":"Copy Data"]}),(0,r.jsxs)(L.$,{variant:"ghost",size:"sm",className:"h-7 gap-1.5 text-[11px] text-muted-foreground hover:text-foreground focus:ring-0 focus-visible:ring-0",onClick:N,children:[(0,r.jsx)(en.A,{className:"h-3 w-3"}),"CSV"]})]})]})}var eD=s(52091),eM=s(59331),eR=s(31257),eE=s(45170),eP=s(20795),eO=s(55651),e_=s(92118),eU=s(82843),eB=s(44852),eW=s(22836),eK=s(95829);let eV=/!?(?:\[([^\]]+)\])\([^)]*\)/g,eq=[10,25,50,100];function eJ({config:e,compact:t=!1}){let{columns:s,rows:a}=(0,n.useMemo)(()=>{var t,s;let r,a;return t=e.columns,s=e.rows,r=new Map,{columns:(a=t.map((e,t)=>{let s=String(e??"").replace(eV,"$1").replace(/<[^>]*>/g,"").replace(/\\([\\`*_{}\[\]()#+.!|>-])/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/__([^_]+)__/g,"$1").replace(/~~([^~]+)~~/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^\s*[*_]+|[*_]+\s*$/g,"").replace(/\s+/g," ").trim()||`Column ${t+1}`,a=(r.get(s)??0)+1;return r.set(s,a),{source:e,target:1===a?s:`${s} (${a})`}})).map(({target:e})=>e),rows:s.map(e=>Object.fromEntries(a.map(({source:t,target:s})=>[s,e[t]])))}},[e.columns,e.rows]),{totalRows:i,aggregationResults:l}=e,o=!0===e.truncated||i>a.length,[c,u]=(0,n.useState)(null),[x,p]=(0,n.useState)("asc"),[h,f]=(0,n.useState)(0),[g,b]=(0,n.useState)(10),[j,v]=(0,n.useState)(""),[y,N]=(0,n.useState)(!1),[k,S]=(0,n.useState)(!t),C=(0,n.useMemo)(()=>{if(!j.trim())return a;let e=j.toLowerCase();return a.filter(t=>s.some(s=>String(t[s]??"").toLowerCase().includes(e)))},[a,s,j]),A=(0,n.useMemo)(()=>c?[...C].sort((e,t)=>{let s=e[c],r=t[c];if(null==s&&null==r)return 0;if(null==s)return 1;if(null==r)return -1;let a=Number(s),n=Number(r);return isNaN(a)||isNaN(n)?"asc"===x?String(s).localeCompare(String(r)):String(r).localeCompare(String(s)):"asc"===x?a-n:n-a}):C,[C,c,x]),I=Math.max(1,Math.ceil(A.length/g)),T=A.slice(h*g,(h+1)*g),F=(0,n.useCallback)(e=>{c===e?p(e=>"asc"===e?"desc":"asc"):(u(e),p("asc")),f(0)},[c]),M=(0,n.useCallback)(()=>{let e;e=[s.join(" "),...a.map(e=>s.map(t=>String(e[t]??"")).join(" "))].join("\n"),navigator.clipboard.writeText(e),N(!0),setTimeout(()=>N(!1),2e3)},[s,a]),R=(0,n.useCallback)(()=>(function(e,t,s="data"){let r=new Blob([[e.join(","),...t.map(t=>e.map(e=>{let s=String(t[e]??"");return/[,"\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}).join(","))].join("\n")],{type:"text/csv"}),a=URL.createObjectURL(r),n=document.createElement("a");n.href=a;let i=s.replace(/\.[^.]+$/,"").replace(/[^\p{L}\p{N}._-]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,100);n.download=`${i||"data"}.csv`,n.click(),URL.revokeObjectURL(a)})(s,a,e.fileName),[s,a,e.fileName]);if(0===s.length||0===a.length)return(0,r.jsx)("div",{className:"py-4 text-center text-sm text-muted-foreground",children:"No data returned"});if(t&&!k){let e=a.length;return(0,r.jsxs)("button",{type:"button",onClick:()=>S(!0),className:"my-1 inline-flex items-center gap-2 rounded-md border border-border/50 bg-muted/30 px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[(0,r.jsx)(eE.A,{className:"size-3.5"}),(0,r.jsx)("span",{children:"Data checked"}),(0,r.jsxs)("span",{className:"rounded-full bg-secondary px-1.5 py-0.5 text-[10px] tabular-nums text-foreground",children:[e.toLocaleString(),o?` of ${i.toLocaleString()}`:""," ",1===i?"row":"rows"]})]})}return(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border/90 bg-muted my-4 animate-in fade-in slide-in-from-bottom-2 duration-500 [&_*:focus]:outline-none [&_*:focus-visible]:ring-0",children:[l&&Object.keys(l).length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-3 border-b border-border/30 px-4 py-3",children:Object.entries(l).map(([e,t])=>{let[s,...a]=e.split("_"),n=a.join("_");return(0,r.jsxs)("div",{className:"flex flex-col rounded-lg bg-transparent px-2 py-1",children:[(0,r.jsxs)("span",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:[s," of ",n]}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:"number"==typeof t?t.toLocaleString(void 0,{maximumFractionDigits:4}):t})]},e)})}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border/30 px-3 py-2",children:[(0,r.jsxs)("div",{className:"relative flex-1 max-w-60",children:[(0,r.jsx)(m.A,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground"}),(0,r.jsx)(eW.p,{value:j,onChange:e=>{v(e.target.value),f(0)},placeholder:"Search rows…",className:"h-7 pl-8 pr-8 text-xs border-border/40 focus-visible:ring-0 focus-visible:border-border/60"}),j&&(0,r.jsx)("button",{type:"button",onClick:()=>v(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,r.jsx)(d.A,{className:"size-3"})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)(L.$,{variant:"ghost",size:"sm",onClick:M,className:"h-7 gap-1.5 text-[11px] text-muted-foreground focus:ring-0 focus-visible:ring-0",children:[y?(0,r.jsx)($.A,{className:"size-3 text-emerald-500"}):(0,r.jsx)(z.A,{className:"size-3"}),y?"Copied":"Copy"]}),(0,r.jsxs)(L.$,{variant:"ghost",size:"sm",onClick:R,className:"h-7 gap-1.5 text-[11px] text-muted-foreground focus:ring-0 focus-visible:ring-0",children:[(0,r.jsx)(en.A,{className:"size-3"}),"CSV"]})]})]}),(0,r.jsx)("div",{className:"overflow-x-auto [&::-webkit-scrollbar]:hidden",children:(0,r.jsxs)(eB.XI,{children:[(0,r.jsx)(eB.A0,{children:(0,r.jsx)(eB.Hj,{className:"bg-background hover:bg-background border-b border-border/30",children:s.map(e=>{let t,{icon:s}=0===(t=a.slice(0,10).map(t=>t[e]).filter(e=>null!=e&&""!==e)).length?{icon:(0,r.jsx)(eD.A,{className:"size-3 text-blue-500"}),label:"text"}:t.every(e=>!isNaN(Number(e)))?{icon:(0,r.jsx)(eM.A,{className:"size-3 text-emerald-500"}),label:"number"}:t.every(e=>!isNaN(Date.parse(String(e))))?{icon:(0,r.jsx)(eR.A,{className:"size-3 text-orange-500"}),label:"date"}:{icon:(0,r.jsx)(eD.A,{className:"size-3 text-blue-500"}),label:"text"};return(0,r.jsx)(eB.nd,{className:"cursor-pointer select-none px-3 py-2.5 text-xs font-medium transition hover:text-foreground",onClick:()=>F(e),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"flex items-center justify-center size-5 bg-background border border-border/50 rounded-sm",children:s}),(0,r.jsx)("span",{children:e}),c===e?"asc"===x?(0,r.jsx)(w.A,{className:"size-3 text-primary"}):(0,r.jsx)(eP.A,{className:"size-3 text-primary"}):(0,r.jsx)(eO.A,{className:"size-3 opacity-20"})]})},e)})})}),(0,r.jsx)(eB.BF,{children:T.map((e,t)=>(0,r.jsx)(eB.Hj,{className:(0,D.cn)("transition border-border/25",t%2==1&&"bg-muted/8"),children:s.map(t=>{var s;return(0,r.jsx)(eB.nA,{className:(0,D.cn)("px-3 py-2 text-xs tabular-nums",/reason|explanation|summary|description/i.test(t)?"min-w-72 max-w-xl whitespace-pre-wrap align-top leading-relaxed":"max-w-55 truncate"),title:String(e[t]??""),children:null==(s=e[t])?"—":"number"==typeof s?s.toLocaleString(void 0,{maximumFractionDigits:4}):String(s)},t)})},t))})]})}),(0,r.jsxs)("div",{className:"flex items-center justify-between border-t border-border/30 px-3 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:C.length!==a.length?`${C.length.toLocaleString()} matched in ${a.length.toLocaleString()} returned rows`:o?`${a.length.toLocaleString()} shown of ${i.toLocaleString()} matching rows`:`${a.length.toLocaleString()} rows`}),(0,r.jsx)("div",{className:"h-3 w-px bg-border/40"}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"Show"}),(0,r.jsxs)(eK.l6,{value:String(g),onValueChange:e=>{b(Number(e)),f(0)},children:[(0,r.jsx)(eK.bq,{className:"h-6 w-13 text-[11px] px-2 focus:ring-0 focus-visible:ring-0",children:g}),(0,r.jsx)(eK.gC,{children:eq.map(e=>(0,r.jsx)(eK.eb,{value:String(e),className:"text-xs",children:e},e))})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground mr-1",children:[h+1," / ",I]}),(0,r.jsx)(L.$,{variant:"ghost",size:"icon","aria-label":"Previous table page",className:"h-7 w-7 focus:ring-0 focus-visible:ring-0",disabled:0===h,onClick:()=>f(e=>e-1),children:(0,r.jsx)(e_.A,{className:"size-3.5"})}),(0,r.jsx)(L.$,{variant:"ghost",size:"icon","aria-label":"Next table page",className:"h-7 w-7 focus:ring-0 focus-visible:ring-0",disabled:h>=I-1,onClick:()=>f(e=>e+1),children:(0,r.jsx)(eU.A,{className:"size-3.5"})})]})]})]})}var eZ=s(39092),eH=s(16069);function eG({artifact:e}){let[t,s]=(0,n.useState)(!1),a=(0,n.useCallback)(()=>{let t=new Blob([function(e){let t=window.atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)s[e]=t.charCodeAt(e);return s}(e.fileBase64)],{type:e.mimeType}),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=e.fileName,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(r),1e3),s(!0)},[e]),i="xlsx"===e.format||"csv"===e.format?eZ.A:eH.A;return(0,r.jsxs)("div",{className:"my-3 flex items-center gap-3 rounded-xl border border-border/70 bg-card px-3.5 py-3",children:[(0,r.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:(0,r.jsx)(i,{className:"size-4.5"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"truncate text-sm font-medium text-foreground",children:e.fileName}),(0,r.jsxs)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[e.rowCount.toLocaleString()," ",1===e.rowCount?"row":"rows"," \xb7"," ",e.format.toUpperCase()]})]}),(0,r.jsxs)(L.$,{size:"sm",onClick:a,className:"h-8 shrink-0 gap-1.5 px-3 text-xs",children:[t?(0,r.jsx)($.A,{className:"size-3.5"}):(0,r.jsx)(en.A,{className:"size-3.5"}),t?"Downloaded":"Download"]})]})}var eX=s(30069),eY=s(28209),eQ=s(65916),e0=s(96828),e1=s(26355);function e5({presentation:e}){let t=e.requestedItems,s="table"===e.kind?e.rows.length:e.pages.length,a=void 0===t?`${s.toLocaleString()} prepared`:s===t?`${s.toLocaleString()} of ${t.toLocaleString()} prepared`:e.complete?`${t.toLocaleString()} of ${t.toLocaleString()} prepared \xb7 ${s.toLocaleString()} rows`:`${Math.min(s,t).toLocaleString()} of ${t.toLocaleString()} prepared \xb7 ${s.toLocaleString()} rows`;return(0,r.jsxs)("span",{className:(0,D.cn)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium tabular-nums",e.complete?"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400":"bg-amber-500/10 text-amber-700 dark:text-amber-400"),children:[e.complete&&(0,r.jsx)(e0.A,{className:"size-3"}),a]})}function e2({presentation:e}){let[t,s]=(0,n.useState)(0),[a,i]=(0,n.useState)(""),l=(0,n.useMemo)(()=>{let t=a.trim().toLocaleLowerCase();return t?e.pages.flatMap((e,s)=>`${e.title??""}
2
+ ${e.content}`.toLocaleLowerCase().includes(t)?[s]:[]):e.pages.map((e,t)=>t)},[e.pages,a]),o=l.includes(t)?t:l[0]??0,d=Math.max(0,l.indexOf(o)),c=e.pages[o],u=(0,n.useCallback)(e=>{let t=Math.min(Math.max(d+e,0),Math.max(l.length-1,0));s(l[t]??0)},[l,d]);return(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border/80 bg-card",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3 border-b border-border/50 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"relative min-w-0 flex-1 sm:max-w-72",children:[(0,r.jsx)(m.A,{className:"absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,r.jsx)(eW.p,{"aria-label":"Search prepared pages",value:a,onChange:e=>{i(e.target.value),s(0)},placeholder:"Search all pages…",className:"h-8 pl-8 text-xs"})]}),(0,r.jsxs)(L.$,{variant:"ghost",size:"sm",onClick:()=>{var t,s;let r,a,n,i;return r=new Blob([e.pages.map((e,t)=>[e.title||`Page ${t+1}`,e.content].filter(Boolean).join("\n\n")).join("\n\n---\n\n")],{type:"text/plain;charset=utf-8"}),a=URL.createObjectURL(r),(n=document.createElement("a")).href=a,void(t=e.fileName,s=e.title,i=(t||s).replace(/\.[^.]+$/,"").replace(/[^\p{L}\p{N}._-]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,100),n.download=`${i||s}.txt`,n.click(),URL.revokeObjectURL(a))},className:"h-8 gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(en.A,{className:"size-3.5"}),"TXT"]})]}),0===l.length?(0,r.jsxs)("div",{className:"px-4 py-14 text-center text-sm text-muted-foreground",children:["No prepared pages match “",a,"”."]}):(0,r.jsx)("article",{className:"min-h-72 bg-background/50 px-5 py-6 sm:px-8 sm:py-8",children:(0,r.jsxs)("div",{className:"mx-auto max-w-3xl",children:[(0,r.jsxs)("div",{className:"mb-5 flex items-center justify-between gap-3 text-[11px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"uppercase tracking-[0.16em]",children:["Prepared page ",o+1]}),(0,r.jsxs)("span",{className:"tabular-nums",children:[d+1," / ",l.length,a?" matches":""]})]}),c?.title&&(0,r.jsx)("h4",{className:"mb-4 text-lg font-semibold tracking-tight text-foreground",children:c.title}),(0,r.jsx)("div",{className:"whitespace-pre-wrap text-sm leading-7 text-foreground/90",children:c?.content})]})}),(0,r.jsxs)("div",{className:"flex items-center justify-between border-t border-border/50 px-3 py-2",children:[(0,r.jsxs)(L.$,{variant:"ghost",size:"sm","aria-label":"Previous prepared page",disabled:d<=0||0===l.length,onClick:()=>u(-1),className:"h-8 gap-1.5 text-xs",children:[(0,r.jsx)(e_.A,{className:"size-3.5"})," Previous"]}),(0,r.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:["Page ",o+1," of ",e.pages.length]}),(0,r.jsxs)(L.$,{variant:"ghost",size:"sm","aria-label":"Next prepared page",disabled:0===l.length||d>=l.length-1,onClick:()=>u(1),className:"h-8 gap-1.5 text-xs",children:["Next ",(0,r.jsx)(eU.A,{className:"size-3.5"})]})]})]})}function e3({presentation:e}){let t="table"===e.kind?eE.A:e1.A;return(0,r.jsxs)("section",{className:"my-2 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[(0,r.jsxs)("div",{className:"mb-1.5 flex items-start justify-between gap-3 px-0.5",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-start gap-2.5",children:[(0,r.jsx)("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,r.jsx)(t,{className:"size-3.5"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"truncate text-sm font-semibold text-foreground",children:e.title}),e.summary&&(0,r.jsx)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:e.summary})]})]}),(0,r.jsx)(e5,{presentation:e})]}),"table"===e.kind?(0,r.jsx)(eJ,{config:{columns:e.columns,rows:e.rows,totalRows:e.totalItems,truncated:e.totalItems>e.rows.length,fileName:e.fileName||e.title}}):(0,r.jsx)(e2,{presentation:e})]})}var e4=s(27722);function e6({config:e}){let t="string"==typeof e?.stdout?e.stdout:"",s="string"==typeof e?.stderr?e.stderr:"",a="number"==typeof e?.exitCode?e.exitCode:1,i=Array.isArray(e?.artifacts)?e.artifacts:[],l="number"==typeof e?.executionTimeMs?e.executionTimeMs:0,o=e?.presentation,d=(0,n.useMemo)(()=>i.filter(e=>e.mimeType.startsWith("image/")),[i]),c=(0,n.useMemo)(()=>null,[t]),m=0===a,x=m&&!t.trim()&&0===i.length&&void 0===o,p=/docker\.sock|docker (?:isn't|is not) running|code execution is unavailable|needs python 3/i.test(s);return(0,r.jsxs)(e4.Zp,{className:"overflow-hidden rounded-none border-0 bg-transparent p-0 shadow-none animate-in fade-in slide-in-from-bottom-2 duration-500",children:[!m&&(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border/40 px-4 py-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-red-100 text-red-600 dark:bg-red-900/30 dark:text-red-400",children:(0,r.jsx)(eX.A,{className:"size-3"})}),(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Analysis failed"})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1 text-[10px] tabular-nums text-muted-foreground",children:[(0,r.jsx)(eY.A,{className:"size-3"}),l<1e3?`${l}ms`:`${(l/1e3).toFixed(1)}s`]})]}),d.length>0&&(0,r.jsx)("div",{className:"space-y-3 p-4",children:d.map((e,t)=>(0,r.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border/40",children:[(0,r.jsx)("img",{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:"w-full"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 border-t border-border/40 px-3 py-1.5",children:[(0,r.jsx)(eQ.A,{className:"size-3 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.name})]})]},t))}),m&&o&&(0,r.jsx)(e3,{presentation:o}),c&&(0,r.jsxs)(e4.Wu,{className:"p-3 pt-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 text-xs text-muted-foreground",children:[(0,r.jsx)(eE.A,{className:"size-3"}),(0,r.jsx)("span",{className:"font-medium",children:"Analysis Results"})]}),(0,r.jsx)(eJ,{config:c})]}),t&&!c&&!o&&(0,r.jsx)("div",{className:"border-b border-border/40 px-4 py-3",children:(0,r.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap text-xs leading-relaxed text-foreground [&::-webkit-scrollbar]:hidden",children:t})}),x&&(0,r.jsxs)("div",{className:"border border-amber-500/20 bg-amber-500/5 px-4 py-3",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-amber-800 dark:text-amber-300",children:"Analysis completed without a usable result"}),(0,r.jsx)("div",{className:"mt-1 text-xs text-amber-700/80 dark:text-amber-300/80",children:"No table, document, chart, or diagnostic output was returned. Please retry the request."})]}),!m&&(0,r.jsx)("div",{className:"border-t border-border/40 bg-red-50/50 p-4 dark:bg-red-900/10",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-red-800 dark:text-red-400",children:p?"Analysis is unavailable":"Analysis encountered an issue"}),(0,r.jsx)("span",{className:"text-xs text-red-600/80 dark:text-red-400/80",children:p?"This workspace does not have a code-analysis runtime configured.":"This calculation could not be completed."}),s&&!p&&(0,r.jsxs)("details",{className:"mt-2 group",children:[(0,r.jsxs)("summary",{className:"cursor-pointer text-xs font-medium text-red-600/70 hover:text-red-600 dark:text-red-400/70 dark:hover:text-red-400 transition-colors list-none flex items-center gap-1",children:[(0,r.jsx)(u.A,{className:"size-3 transition-transform group-open:rotate-180"}),"Technical Details"]}),(0,r.jsx)("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap rounded bg-red-100/50 p-3 text-[11px] leading-relaxed text-red-900/70 dark:bg-red-900/20 dark:text-red-200/70 [&::-webkit-scrollbar]:hidden",children:s})]})]})})]})}function e8({config:e}){let{tabs:t,defaultIndex:s=0}=e,[a,i]=(0,n.useState)(s);return t&&0!==t.length?1===t.length?(0,r.jsx)(r.Fragment,{children:t[0].content}):(0,r.jsxs)("div",{className:"w-full my-4 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[(0,r.jsx)("div",{className:"flex items-center gap-0.5 border-b border-border/30 px-1",children:t.map((e,t)=>(0,r.jsxs)("button",{type:"button",onClick:()=>i(t),className:(0,D.cn)("relative flex items-center gap-1.5 px-3 py-2.5 text-xs font-medium transition-colors","focus:outline-none focus-visible:outline-none",a===t?"text-foreground":"text-muted-foreground hover:text-foreground/70"),children:[e.icon&&(0,r.jsx)("span",{className:"shrink-0 [&_svg]:size-3.5",children:e.icon}),(0,r.jsx)("span",{children:e.label}),a===t&&(0,r.jsx)("span",{className:"absolute bottom-0 left-2 right-2 h-0.5 rounded-full bg-foreground animate-in fade-in zoom-in-75 duration-300"})]},t))}),(0,r.jsx)("div",{className:"pt-3 animate-in fade-in slide-in-from-bottom-1 duration-400",children:t[a]?.content},a)]}):null}var e7=s(25448),e9=s(15724);let te={paste:(0,r.jsx)(eH.A,{className:"size-3"}),upload:(0,r.jsx)(e7.A,{className:"size-3"}),scrape:(0,r.jsx)(y.A,{className:"size-3"}),tabular:(0,r.jsx)(eE.A,{className:"size-3"}),media:(0,r.jsx)(eQ.A,{className:"size-3"})},tt={paste:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",upload:"bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400",scrape:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400",tabular:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",media:"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400"};function ts({config:e}){var t;let[s,a]=(0,n.useState)(!1),{documents:i,total:l,summary:o,error:d}=e;if(d)return(0,r.jsx)(e4.Zp,{className:"overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-500",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-red-600 dark:text-red-400",children:[(0,r.jsx)(e9.A,{className:"size-4"}),(0,r.jsxs)("span",{children:["Failed to fetch corpus data: ",d]})]})});if(0===o.totalDocuments)return(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 text-xs text-muted-foreground animate-in fade-in slide-in-from-bottom-2 duration-500",children:[(0,r.jsx)(e9.A,{className:"size-3"}),(0,r.jsx)("span",{children:"No documents found in the corpus."})]});let c=Object.entries(o.bySource).sort((e,t)=>t[1]-e[1]),m=Object.entries(o.byStatus).sort((e,t)=>t[1]-e[1]),x=i.length>0?{columns:["title","source","status","charCount","createdAt"],rows:i.map(e=>({title:e.title,source:e.source,status:e.status??"unindexed",charCount:e.charCount,createdAt:e.createdAt.split("T")[0],...e.url?{url:e.url}:{}})),totalRows:l}:null;return(0,r.jsxs)(e4.Zp,{className:"overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-500",children:[(0,r.jsxs)("div",{className:"border-b border-border/40 px-4 py-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,r.jsx)(e9.A,{className:"size-3"})}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Corpus Overview"}),(0,r.jsxs)("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[11px] tabular-nums text-muted-foreground",children:[l.toLocaleString()," ",1===l?"document":"documents"]})]}),(0,r.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[(t=o.totalCharacters)>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)," chars"]})]}),(0,r.jsxs)("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:[c.map(([e,t])=>(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium ${tt[e]??"bg-secondary text-muted-foreground"}`,children:[te[e],e,(0,r.jsx)("span",{className:"tabular-nums font-normal opacity-70",children:t})]},e)),m.map(([e,t])=>(0,r.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium ${"indexed"===e?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400":"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400"}`,children:[e,(0,r.jsx)("span",{className:"tabular-nums font-normal opacity-70",children:t})]},e))]}),o.topMetadataKeys.length>0&&(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1",children:[(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground/60 self-center mr-0.5",children:"metadata:"}),o.topMetadataKeys.slice(0,8).map(({key:e,count:t})=>(0,r.jsxs)("span",{className:"rounded bg-secondary/60 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:[e," ",(0,r.jsxs)("span",{className:"tabular-nums opacity-60",children:["(",t,")"]})]},e))]})]}),x&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"flex w-full items-center justify-between px-4 py-2 text-xs text-muted-foreground hover:bg-secondary/30 transition-colors",children:[(0,r.jsxs)("span",{children:[s?"Hide":"Show"," documents (",i.length,l>i.length?` of ${l}`:"",")"]}),(0,r.jsx)(u.A,{className:`size-3.5 transition-transform ${s?"rotate-180":""}`})]}),s&&(0,r.jsx)("div",{className:"border-t border-border/40 px-3 py-3",children:(0,r.jsx)(eJ,{config:x})})]})]})}let tr=(0,n.createContext)(null);function ta(){let e=(0,n.useContext)(tr);if(!e)throw Error("useDocEditor must be used within a DocEditorProvider");return e}function tn({children:e}){let[t,s]=(0,n.useState)({isCanvasOpen:!1,sessionId:null,parsedDocument:null,activeFileName:null,activeFileType:null,fileBase64:null,fileMimeType:null,isLoading:!1,error:null,fillingFields:new Set,updatedFields:new Set,updateVersion:0}),i=(0,n.useCallback)(async(e,t)=>{s(s=>({...s,isLoading:!0,error:null,activeFileName:e.name,isCanvasOpen:!t?.background||s.isCanvasOpen}));try{let t=new FormData;t.append("file",e);let r=await (0,a.St)((0,a.fO)("/api/doc-editor/parse"),{method:"POST",body:t});if(!r.ok){let e=await r.json();throw Error(e.error||"Failed to parse file")}let n=await r.json(),i=await new Promise(t=>{let s=new FileReader;s.onload=()=>{let e=s.result;t(e.split(",")[1]||e)},s.readAsDataURL(e)});s(e=>({...e,isLoading:!1,sessionId:n.sessionId,parsedDocument:{sessionId:n.sessionId,fileName:n.fileName,type:n.type,mimeType:n.mimeType,fileSize:n.fileSize,pages:n.pages,fields:n.fields,rawText:n.rawText,metadata:n.metadata,totalPages:n.totalPages},activeFileType:n.type,fileMimeType:n.mimeType,fileBase64:i,updateVersion:e.updateVersion+1}))}catch(e){s(t=>({...t,isLoading:!1,error:e.message||"Failed to parse file"}))}},[]),l=(0,n.useCallback)(()=>{s(e=>({...e,isCanvasOpen:!1}))},[]),o=(0,n.useCallback)(()=>{s(e=>({...e,isCanvasOpen:!e.isCanvasOpen}))},[]),d=(0,n.useCallback)(async e=>{if(t.sessionId){s(t=>({...t,fillingFields:new Set(e.map(e=>e.fieldId))}));try{let r=await (0,a.St)((0,a.fO)("/api/doc-editor/edit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:t.sessionId,fieldEdits:e})});if(!r.ok){let e=await r.json();throw Error(e.error||"Edit failed")}let n=await r.json();s(e=>({...e,fillingFields:new Set,updatedFields:new Set(n.updatedFields||[]),parsedDocument:e.parsedDocument?{...e.parsedDocument,fields:n.fields||e.parsedDocument.fields,pages:n.pages||e.parsedDocument.pages,totalPages:n.totalPages||e.parsedDocument.totalPages}:null,fileBase64:n.fileBase64||e.fileBase64,updateVersion:e.updateVersion+1})),setTimeout(()=>{s(e=>({...e,updatedFields:new Set}))},2e3)}catch(e){s(t=>({...t,fillingFields:new Set,error:e.message||"Edit failed"}))}}},[t.sessionId]),c=(0,n.useCallback)(e=>{s(t=>({...t,fillingFields:new Set(e)}))},[]),u=(0,n.useCallback)(()=>{s(e=>({...e,fillingFields:new Set}))},[]),m=(0,n.useCallback)(()=>{if(!t.sessionId)return;let e=(0,a.fO)(`/api/doc-editor/export?sessionId=${encodeURIComponent(t.sessionId)}`),s=document.createElement("a");s.href=e,s.download=t.activeFileName||"document",s.click()},[t.sessionId,t.activeFileName]),x=(0,n.useCallback)(e=>{s(t=>(t.isCanvasOpen&&(t.sessionId,e.sessionId),{...t,sessionId:e.sessionId,isCanvasOpen:!0,parsedDocument:t.parsedDocument?{...t.parsedDocument,fields:e.fields,pages:e.pages||t.parsedDocument.pages,totalPages:e.totalPages||t.parsedDocument.totalPages}:{sessionId:e.sessionId,fileName:t.activeFileName||"Document",type:"pdf",mimeType:"application/pdf",fileSize:0,pages:e.pages||[],fields:e.fields||[],rawText:"",metadata:{},totalPages:e.totalPages||1},fileBase64:e.fileBase64||t.fileBase64,updatedFields:new Set(e.updatedFields),fillingFields:new Set,updateVersion:t.updateVersion+1})),e.fileBase64&&e.sessionId&&!(0,a.Av)().durableDocumentSessions&&(0,a.St)((0,a.fO)("/api/doc-editor/restore"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e.sessionId,fileBase64:e.fileBase64,fileName:"Document",mimeType:"application/pdf",activeFileType:"pdf"})}).catch(console.error),setTimeout(()=>{s(e=>({...e,updatedFields:new Set}))},2e3)},[]),p={...t,openCanvas:i,closeCanvas:l,toggleCanvas:o,applyEdits:d,setFillingFields:c,clearFillingFields:u,exportFile:m,updateFromToolResult:x};return(0,r.jsx)(tr.Provider,{value:p,children:e})}var ti=s(80845),tl=s(52379),to=s(99156),td=s(57535),tc=s(9357),tu=s(33139),tm=s(94091),tx=s(40896),tp=s(35229),th=s(33800),tf=s(66352),tg=s(38515);function tb({className:e,defaultValue:t,value:s,min:a=0,max:n=100,...i}){let l=Array.isArray(s)?s:Array.isArray(t)?t:[a,n];return(0,r.jsx)(tx.g,{className:(0,D.cn)("data-horizontal:w-full data-vertical:h-full",e),"data-slot":"slider",defaultValue:t,value:s,min:a,max:n,thumbAlignment:"edge",...i,children:(0,r.jsxs)(tp.X,{className:"relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col",children:[(0,r.jsx)(th.h,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1",children:(0,r.jsx)(tf.X,{"data-slot":"slider-range",className:"bg-primary select-none data-horizontal:h-full data-vertical:w-full"})}),Array.from({length:l.length},(e,t)=>(0,r.jsx)(tg.O,{"data-slot":"slider-thumb",className:"relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50"},t))]})})}var tj=s(87932),tv=s(19384),ty=s(80732);function tN({open:e,onOpenChange:t,fileBase64:a,totalPages:i,placements:l,onSave:o,mode:d,imagePayload:c,text:u,font:m,color:x,scale:p}){let[h,g]=(0,n.useState)(0),[b,j]=(0,n.useState)(!0),[v,y]=(0,n.useState)(null),N=(0,n.useRef)(null),w=(0,n.useRef)(null),[k,S]=(0,n.useState)([]),[C,A]=(0,n.useState)(1);(0,n.useEffect)(()=>{e&&S([...l])},[e,l]),(0,n.useEffect)(()=>{if(!e||!a)return;let t=!0;return(async()=>{try{j(!0);let e=await Promise.all([s.e(308),s.e(3360)]).then(s.bind(s,81305));e.GlobalWorkerOptions.workerSrc=`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${e.version}/pdf.worker.mjs`;let r=atob(a),n=new Uint8Array(r.length);for(let e=0;e<r.length;e++)n[e]=r.charCodeAt(e);let i=e.getDocument({data:n}),l=await i.promise;t&&y(l)}catch(e){tc.oR.error("Failed to load PDF for visual placement"),console.error(e)}})(),()=>{t=!1}},[e,a]),(0,n.useEffect)(()=>{if(!v||!N.current)return;let e=!0;return(async()=>{try{j(!0);let e=await v.getPage(h+1),t=e.getViewport({scale:1}),s=Math.min(.95*window.innerWidth-64,1136)/t.width,r=Math.min(s,1.5);A(r);let a=e.getViewport({scale:r}),n=N.current;if(!n)return;let i=n.getContext("2d");if(!i)return;n.height=a.height,n.width=a.width,await e.render({canvasContext:i,viewport:a}).promise}catch(e){console.error("Error rendering page:",e)}finally{e&&j(!1)}})(),()=>{e=!1}},[v,h]);let $=k.find(e=>e.pageIndex===h),[z,I]=(0,n.useState)({x:150,y:150});return(0,n.useEffect)(()=>{if($&&w.current){let{width:e,height:t}=w.current.getBoundingClientRect();I({x:$.x/100*e,y:$.y/100*t})}else if(w.current){let{width:e,height:t}=w.current.getBoundingClientRect();I({x:e/2-50,y:t/2-25})}},[$,h,b]),(0,r.jsx)(tv.lG,{open:e,onOpenChange:t,children:(0,r.jsxs)(tv.Cf,{className:"w-[95vw] max-w-250 sm:max-w-250 h-[95vh] max-h-[95vh] bg-white/80 backdrop-blur-md overflow-hidden flex flex-col p-4",children:[(0,r.jsxs)(tv.c7,{className:"mb-2 shrink-0",children:[(0,r.jsx)(tv.L3,{children:"Visual Signature Placement"}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(L.$,{variant:"outline",size:"icon",onClick:()=>g(e=>Math.max(0,e-1)),disabled:0===h||b,children:(0,r.jsx)(e_.A,{className:"h-4 w-4"})}),(0,r.jsxs)("span",{className:"text-sm font-medium",children:["Page ",h+1," of ",i]}),(0,r.jsx)(L.$,{variant:"outline",size:"icon",onClick:()=>g(e=>Math.min(i-1,e+1)),disabled:h===i-1||b,children:(0,r.jsx)(eU.A,{className:"h-4 w-4"})})]}),$&&(0,r.jsx)(L.$,{variant:"ghost",size:"sm",onClick:()=>{S(e=>e.filter(e=>e.pageIndex!==h))},className:"text-muted-foreground",children:"Remove from this page"})]})]}),(0,r.jsxs)("div",{className:"relative flex-1 overflow-auto flex items-center justify-center bg-muted/40 border rounded-lg",children:[b&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10 backdrop-blur-md",children:(0,r.jsx)(f.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),(0,r.jsxs)("div",{ref:w,className:"relative 35 bg-white overflow-hidden shrink-0",children:[(0,r.jsx)("canvas",{ref:N,className:"block w-full h-auto"}),!b&&(0,r.jsx)(tl.P.div,{drag:!0,dragMomentum:!1,dragConstraints:w,onDrag:(e,t)=>{I({x:z.x+t.delta.x,y:z.y+t.delta.y})},onDragEnd:(e,t)=>{if(!w.current)return;let{width:s,height:r}=w.current.getBoundingClientRect(),a=Math.max(0,Math.min(100,z.x/s*100)),n=Math.max(0,Math.min(100,z.y/r*100)),i=k.findIndex(e=>e.pageIndex===h),l={pageIndex:h,x:a,y:n,scale:p};if(i>=0){let e=[...k];e[i]=l,S(e)}else S([...k,l])},style:{x:z.x,y:z.y,scale:p/100*C,transformOrigin:"top left"},className:"absolute top-0 left-0 cursor-move border border-primary/50 border-dashed hover:border-primary transition-colors w-max",children:"type"===d?(0,r.jsx)("span",{style:{fontFamily:"Cursive"===m?"cursive":"sans-serif",color:"black"===x?"#000":"blue"===x?"#0000ff":"#ff0000",fontSize:"24px",lineHeight:1,display:"block"},children:u||"Your Signature"}):c?(0,r.jsx)("img",{src:c,alt:"Signature",className:"max-h-15 pointer-events-none"}):(0,r.jsx)("span",{className:"text-muted-foreground text-sm",children:"No signature"})})]})]}),(0,r.jsxs)(tv.Es,{className:"mt-4 shrink-0 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[k.length," placement(s) set."]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(L.$,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),(0,r.jsxs)(L.$,{onClick:()=>{o(k),t(!1)},children:[(0,r.jsx)(ty.A,{className:"h-4 w-4 mr-2"}),"Save Placements"]})]})]})]})})}function tw({detectedLocations:e,fileName:t,mimeType:s,toolCallId:i,addToolResult:l}){let{sessionId:o,parsedDocument:d,updateFromToolResult:c,activeFileName:m,fileMimeType:x,fileBase64:h}=ta(),[g,b]=(0,n.useState)(!1),[j,v]=(0,n.useState)(!1),[y,N]=(0,n.useState)("type"),[w,k]=(0,n.useState)(e&&e.length>0&&void 0!==e[0].pageIndex?(e[0].pageIndex+1).toString():"1"),[S,C]=(0,n.useState)([]),[A,$]=(0,n.useState)(!1),[z,I]=(0,n.useState)([]),[T,F]=(0,n.useState)(!1),[M,R]=(0,n.useState)(!1),[E,P]=(0,n.useState)(null),[O,_]=(0,n.useState)({});(0,n.useEffect)(()=>{(0,tu.Jt)("saved_signatures").then(e=>{e&&I(e)})},[]);let U=async e=>{let t=[e,...z];I(t),await (0,tu.hZ)("saved_signatures",t)},B=async(e,t)=>{t.stopPropagation();let s=z.filter(t=>t.id!==e);I(s),await (0,tu.hZ)("saved_signatures",s)},[W,K]=(0,n.useState)(""),[V,q]=(0,n.useState)("Helvetica"),[J,Z]=(0,n.useState)("black"),[H,G]=(0,n.useState)(100),[X,Y]=(0,n.useState)(20),[Q,ee]=(0,n.useState)(85),[et,es]=(0,n.useState)(""),[er,ea]=(0,n.useState)(""),[en,ei]=(0,n.useState)(null),el=(0,n.useRef)(null),[eo,ed]=(0,n.useState)(!1),[ec,eu]=(0,n.useState)(null),em=e=>{ed(!0),ep(e)},ex=()=>{if(ed(!1),el.current){let e=el.current.getContext("2d");e?.beginPath()}},ep=e=>{let t,s;if(!eo||!el.current)return;let r=el.current,a=r.getContext("2d");if(!a)return;"touches"in e?(t=e.touches[0].clientX,s=e.touches[0].clientY):(t=e.clientX,s=e.clientY);let n=r.getBoundingClientRect(),i=r.width/n.width,l=r.height/n.height,o=(t-n.left)*i,d=(s-n.top)*l;a.lineWidth=2,a.lineCap="round",a.strokeStyle="black"===J?"#000000":"blue"===J?"#0000ff":"#ff0000",a.lineTo(o,d),a.stroke(),a.beginPath(),a.moveTo(o,d)},eh=async t=>{if(!o)return void tc.oR.error("No active document session");b(!0);try{let s;if("draw"===y&&el.current?s=el.current.toDataURL("image/png"):"upload"===y&&ec&&(s=ec),"type"===y&&!W.trim()){tc.oR.error("Please type a signature"),b(!1);return}if(("draw"===y||"upload"===y)&&!s){tc.oR.error("Please provide a signature image"),b(!1);return}T&&("draw"===y||"upload"===y)&&s&&await U({id:crypto.randomUUID(),imagePayload:s,mode:y});let r=new Set;w.split(",").forEach(e=>{let t=e.trim();if(t.includes("-")){let[e,s]=t.split("-").map(Number);if(!isNaN(e)&&!isNaN(s))for(let t=e;t<=s;t++)r.add(t-1)}else{let e=Number(t);isNaN(e)||r.add(e-1)}});let n=t||[...S];0===n.length&&(0===r.size&&r.add(0),Array.from(r).forEach(e=>{n.push({pageIndex:e,x:X,y:Q,scale:H})}));let i=en;!i&&h&&(i=h,ei(h));let l=null;for(let t of n){let r=await (0,a.St)((0,a.fO)("/api/document/sign"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:o,signatureData:{mode:y,imagePayload:s,text:W,font:V,color:J,date:et,extraText:er,pageIndex:t.pageIndex,placementNote:O[t.pageIndex]||"",detectedContext:e?.find(e=>e.pageIndex===t.pageIndex)?.context,x:t.x,y:t.y,scale:t.scale/100,base64Override:i}})});if(!r.ok){let e=await r.json();throw Error(e.error||`Failed to sign document on page ${t.pageIndex+1}`)}l=await r.json(),l?.document?.fileBase64&&(i=l.document.fileBase64)}l&&(eg(l.document),c({sessionId:o,fields:l.document.parsed.fields,updatedFields:l.document.updatedFields,fileBase64:l.document.fileBase64,pages:l.document.parsed.pages,totalPages:l.document.parsed.totalPages})),v(!0),tc.oR.success("Signature applied for preview. Please confirm or adjust.")}catch(e){tc.oR.error(e.message)}finally{b(!1)}},[ef,eg]=(0,n.useState)(null),eb=t||m||"Document",ej=s||x||"",ev=eb.split(".").pop()?.toLowerCase()||"",ey="/icons/image.png";return["csv","xls","xlsx"].includes(ev)||ej.includes("excel")||ej.includes("spreadsheet")?ey="/icons/excel.png":["doc","docx"].includes(ev)||ej.includes("word")?ey="/icons/word.png":["md","markdown"].includes(ev)?ey="/icons/markdown.png":["pdf"].includes(ev)||"application/pdf"===ej?ey="/icons/pdf.png":ev||(ey="/icons/word.png"),(0,r.jsxs)(e4.Zp,{className:"my-4 shadow-none! bg-transparent w-full max-w-3xl border-border",children:[(0,r.jsxs)(e4.aR,{className:"flex flex-row items-center gap-3 space-y-0",children:[(0,r.jsx)("div",{className:"size-10 shrink-0 rounded-md overflow-hidden bg-white border border-border flex items-center justify-center p-1.5 35",children:(0,r.jsx)("img",{src:ey,alt:eb,className:"w-full h-full object-contain"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(e4.ZB,{className:"text-lg",children:"Signature Request"}),(0,r.jsxs)(e4.BT,{children:["Sign ",(0,r.jsx)("span",{className:"font-semibold text-foreground/80",children:eb})," to continue."]})]})]}),(0,r.jsxs)(e4.Wu,{className:"space-y-4 pt-2",children:[!o&&(0,r.jsxs)("div",{className:"bg-amber-50 text-amber-900 border border-amber-200 rounded-md p-3 text-xs mb-4",children:[(0,r.jsx)("strong",{children:"Action Required:"})," Please click on your document in the chat to open it in the Canvas first. The document must be open before you can sign it."]}),e&&e.length>0&&(0,r.jsxs)("div",{className:"bg-muted p-3 rounded-md text-sm mb-4",children:[(0,r.jsx)("span",{className:"font-semibold block mb-1",children:"Detected Placement:"}),e.map((e,t)=>(0,r.jsxs)("div",{className:"group mb-2 last:mb-0",children:[(0,r.jsxs)("div",{className:"text-muted-foreground flex justify-between items-center",children:[(0,r.jsxs)("span",{children:["Page ",e.pageIndex+1]}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("span",{className:"italic truncate max-w-50",children:e.context}),(0,r.jsx)(L.$,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>P(E===t?null:t),children:(0,r.jsx)(to.A,{className:"h-3 w-3"})})]})]}),E===t&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(eW.p,{placeholder:"Add notes for placement (e.g. bottom right corner)",className:"h-8 text-xs bg-white",value:O[t]||"",onChange:e=>_({...O,[t]:e.target.value})})})]},t))]}),(0,r.jsxs)(tj.Nt,{open:M,onOpenChange:R,children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 items-end mb-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Pages (e.g. 1, 3-5)"}),(0,r.jsx)(eW.p,{value:w,onChange:e=>k(e.target.value),placeholder:"1",className:"h-10 text-xs bg-white"})]}),(0,r.jsx)("div",{className:"flex flex-col justify-end w-full",children:(0,r.jsx)(tj.R6,{className:"mb-px",render:(0,r.jsxs)(L.$,{variant:"outline",size:"sm",className:"h-10 w-full justify-between bg-white text-xs px-3",children:[(0,r.jsx)("span",{children:"Advanced Settings"}),(0,r.jsx)(u.A,{className:`h-4 w-4 transition-transform duration-200 ${M?"rotate-180":""}`})]})})})]}),(0,r.jsxs)(tj.Ke,{className:"space-y-4 mb-4 rounded-md p-3 bg-white/50 animate-in fade-in duration-200",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Font Style"}),(0,r.jsxs)(eK.l6,{value:V,onValueChange:e=>e&&q(e),disabled:"type"!==y,children:[(0,r.jsx)(eK.bq,{className:"bg-white h-8 text-xs",children:(0,r.jsx)(eK.yv,{placeholder:"Select font"})}),(0,r.jsxs)(eK.gC,{children:[(0,r.jsx)(eK.eb,{value:"Helvetica",children:"Standard"}),(0,r.jsx)(eK.eb,{value:"Cursive",children:"Cursive"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ti.J,{className:"text-xs block mb-1",children:"Signature Color"}),(0,r.jsx)("div",{className:"flex gap-2 h-8 items-center",children:["black","blue","red"].map(e=>(0,r.jsx)("button",{onClick:()=>Z(e),className:`size-5 rounded-full border ${J===e?"ring-2 ring-primary ring-offset-1":""}`,style:{backgroundColor:e},title:e},e))})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)(ti.J,{className:"text-xs block mb-1",children:["Size: ",H,"%"]}),(0,r.jsx)(tb,{value:[H],onValueChange:e=>G(Array.isArray(e)?e[0]:e),min:50,max:200,step:10,className:"mt-2"})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Date (Optional)"}),(0,r.jsx)(eW.p,{type:"date",value:et,onChange:e=>es(e.target.value),className:"h-8 text-xs bg-white"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Position X (%)"}),(0,r.jsx)(eW.p,{type:"number",min:0,max:100,value:X,onChange:e=>Y(Number(e.target.value)),className:"h-8 text-xs bg-white"})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Position Y (%)"}),(0,r.jsx)(eW.p,{type:"number",min:0,max:100,value:Q,onChange:e=>ee(Number(e.target.value)),className:"h-8 text-xs bg-white"})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Extra Text (Optional)"}),(0,r.jsx)(eW.p,{value:er,onChange:e=>ea(e.target.value),placeholder:"Title, Company, etc.",className:"h-8 text-xs bg-white"})]})]})]}),z.length>0&&(0,r.jsxs)("div",{className:"space-y-2 mb-4",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Saved Signatures"}),(0,r.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-2",children:z.map(e=>(0,r.jsxs)("div",{className:"relative shrink-0 w-25 h-12.5 border rounded bg-white flex items-center justify-center cursor-pointer hover:border-primary group overflow-hidden",onClick:()=>{N(e.mode),"upload"===e.mode?eu(e.imagePayload):"draw"===e.mode&&(N("upload"),eu(e.imagePayload))},children:[(0,r.jsx)("img",{src:e.imagePayload,alt:"Saved Signature",className:"max-h-full max-w-full object-contain"}),(0,r.jsx)("button",{onClick:t=>B(e.id,t),className:"absolute top-1 right-1 bg-destructive text-white rounded p-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(p.A,{className:"size-3"})})]},e.id))})]}),(0,r.jsxs)("div",{className:"w-full mt-4",children:[(0,r.jsx)("div",{className:"border-b border-border mb-6",children:(0,r.jsx)("div",{className:"flex items-center gap-1 -mb-px",children:[{id:"type",label:"Type",icon:eD.A},{id:"draw",label:"Draw",icon:td.A},{id:"upload",label:"Upload",icon:e7.A}].map(e=>{let t=y===e.id,s=e.icon;return(0,r.jsxs)("button",{onClick:()=>N(e.id),className:(0,D.cn)("relative flex items-center gap-2 px-4 py-2.5 text-sm font-medium transition-colors outline-none",t?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,r.jsx)(s,{className:"size-4"}),e.label,t&&(0,r.jsx)(tl.P.div,{layoutId:"signature-tab-indicator",className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary rounded-full",initial:!1,transition:{type:"spring",stiffness:500,damping:35}})]},e.id)})})}),(0,r.jsxs)("div",{className:"relative",children:["type"===y&&(0,r.jsxs)("div",{className:"space-y-1.5 animate-in fade-in duration-200",children:[(0,r.jsx)(ti.J,{className:"text-xs",children:"Your Name"}),(0,r.jsx)(eW.p,{value:W,onChange:e=>K(e.target.value),placeholder:"John Doe"})]}),"draw"===y&&(0,r.jsxs)("div",{className:"border rounded-md bg-white overflow-hidden touch-none relative animate-in fade-in duration-200",children:[(0,r.jsx)("canvas",{ref:el,width:380,height:150,onMouseDown:em,onMouseUp:ex,onMouseOut:ex,onMouseMove:ep,onTouchStart:em,onTouchEnd:ex,onTouchMove:ep,className:"w-full h-37.5 cursor-crosshair block"}),(0,r.jsx)(L.$,{variant:"outline",size:"sm",className:"absolute bottom-2 right-2 h-7 text-xs",onClick:()=>{if(!el.current)return;let e=el.current,t=e.getContext("2d");t&&t.clearRect(0,0,e.width,e.height)},children:"Clear"})]}),"upload"===y&&(0,r.jsxs)("div",{className:"border-2 border-dashed rounded-md p-6 flex flex-col items-center justify-center text-center relative overflow-hidden animate-in fade-in duration-200",children:[(0,r.jsx)("input",{type:"file",accept:"image/png, image/jpeg",onChange:e=>{let t=e.target.files?.[0];if(!t)return;let s=new FileReader;s.onload=e=>{eu(e.target?.result)},s.readAsDataURL(t)},className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer",id:"signature-upload"}),ec?(0,r.jsx)("div",{className:"mt-2 max-h-25 overflow-hidden rounded bg-white w-full flex justify-center pointer-events-none",children:(0,r.jsx)("img",{src:ec,alt:"Signature Preview",className:"max-h-full object-contain"})}):(0,r.jsxs)("div",{className:"flex flex-col items-center space-y-2 pointer-events-none",children:[(0,r.jsx)(e7.A,{className:"size-8 text-muted-foreground mb-2"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Click or drag to upload signature"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"PNG or JPG with transparent background"})]})]})]})]}),("draw"===y||"upload"===y)&&(0,r.jsxs)("div",{className:"flex items-center space-x-2 mt-4",children:[(0,r.jsx)(tm.S,{id:"save-signature",checked:T,onCheckedChange:e=>F(!!e)}),(0,r.jsx)(ti.J,{htmlFor:"save-signature",className:"text-sm font-medium leading-none",children:"Save signature for future use"})]})]}),(0,r.jsxs)(e4.wL,{className:"flex flex-col items-end pt-4 border-t gap-2",children:[!o&&(0,r.jsx)("span",{className:"text-xs text-amber-600 bg-amber-50 px-2 py-1 rounded-md border border-amber-200",children:"Click the document in the chat to open it in the canvas before signing."}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:j?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.$,{variant:"outline",onClick:()=>void(en&&o&&c({sessionId:o,fileBase64:en,fields:d?.fields||[],updatedFields:[],pages:d?.pages||[],totalPages:d?.totalPages||1}),v(!1)),disabled:g,className:"w-full sm:w-auto",children:"Undo & Adjust"}),(0,r.jsx)(L.$,{onClick:()=>void(i&&l&&l({toolCallId:i,result:{success:!0,action:"request_signature",message:"User has successfully signed the document.",fileBase64:ef?.fileBase64,fields:ef?.parsed?.fields,updatedFields:ef?.updatedFields,pages:ef?.parsed?.pages,totalPages:ef?.parsed?.totalPages},output:{success:!0,action:"request_signature",message:"User has successfully signed the document.",fileBase64:ef?.fileBase64,fields:ef?.parsed?.fields,updatedFields:ef?.updatedFields,pages:ef?.parsed?.pages,totalPages:ef?.parsed?.totalPages}})),className:"bg-emerald-600 hover:bg-emerald-700 text-white w-full sm:w-auto",children:"Confirm Signature"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(L.$,{variant:"outline",size:"sm",className:"h-10 text-xs px-3 text-primary",onClick:()=>$(!0),children:"Place Visually"}),(0,r.jsxs)(L.$,{onClick:()=>eh(),disabled:g||!o,className:"w-full sm:w-auto",children:[g?(0,r.jsx)(f.A,{className:"mr-2 size-4 animate-spin"}):null,"Preview Signature"]})]})})]}),(0,r.jsx)(tN,{open:A,onOpenChange:$,fileBase64:en||h||"",totalPages:d?.totalPages||1,placements:S,onSave:e=>{C(e),eh(e)},mode:y,imagePayload:"draw"===y&&el.current?el.current.toDataURL("image/png"):"upload"===y?ec:null,text:W,font:V,color:J,scale:H})]})}var tk=s(9439),tS=s(38458),tC=s(33380),tA=s(16169),t$=s(51991);function tz({assetId:e,mediaType:t,fileName:s,mediaUrl:i,sourceUrl:l,startSecs:o,endSecs:c}){let[u,m]=(0,n.useState)(!1),[x,p]=(0,n.useState)(!1),[h,f]=(0,n.useState)(!1),g=(0,n.useRef)(null),b=i?(0,a.fO)(i):void 0,j=b&&void 0!==o?`${b.split("#")[0]}#t=${o}${void 0!==c?`,${c}`:""}`:b,v="video"===t&&Number.isFinite(o)&&Number.isFinite(c)&&c>o;return((0,n.useEffect)(()=>{let e=g.current;if(!e||!Number.isFinite(o))return;let t=()=>{e.currentTime=Math.max(0,o)};return e.readyState>=HTMLMediaElement.HAVE_METADATA?t():e.addEventListener("loadedmetadata",t,{once:!0}),()=>e.removeEventListener("loadedmetadata",t)},[j,o]),b)?"image"===t?x?(0,r.jsxs)("div",{className:"my-2 w-full max-w-2xl rounded-lg border border-border bg-card p-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"This source image is no longer available."}),(0,r.jsx)(tT,{icon:(0,r.jsx)(eQ.A,{className:"size-3 text-muted-foreground"}),fileName:s,sourceUrl:l})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"my-2 w-full max-w-2xl overflow-hidden rounded-lg border border-border bg-card",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(!0),className:"group relative block w-full overflow-hidden",children:[(0,r.jsx)("img",{src:b,alt:s??"Image",className:"max-h-105 w-full object-contain",loading:"lazy",onError:()=>p(!0)}),(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black/0 opacity-0 transition-all group-hover:bg-black/20 group-hover:opacity-100",children:(0,r.jsx)(tC.A,{className:"size-5 text-white"})})]}),(0,r.jsx)(tT,{icon:(0,r.jsx)(eQ.A,{className:"size-3 text-muted-foreground"}),fileName:s,sourceUrl:l})]}),u&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-8",onClick:()=>m(!1),children:[(0,r.jsx)("button",{type:"button","aria-label":"Close image preview",className:"absolute right-4 top-4 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",onClick:()=>m(!1),children:(0,r.jsx)(d.A,{className:"size-5"})}),(0,r.jsx)("img",{src:b,alt:s??"Image",className:"max-h-[80vh] max-w-[90vw] rounded-lg object-contain",onClick:e=>e.stopPropagation(),onError:()=>p(!0)})]})]}):"video"===t?h?(0,r.jsxs)("div",{className:"my-2 w-full max-w-2xl overflow-hidden rounded-lg border border-border bg-card",children:[(0,r.jsx)("div",{className:"flex aspect-video items-center justify-center bg-muted/30 px-6 text-center",children:(0,r.jsxs)("div",{children:[(0,r.jsx)(tA.A,{className:"mx-auto mb-2 size-6 text-muted-foreground"}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Preview unavailable"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Open the original source to watch this cited moment."})]})}),(0,r.jsx)(tT,{icon:(0,r.jsx)(tA.A,{className:"size-3 text-muted-foreground"}),fileName:s,sourceUrl:tI(l,o,c),timestamp:void 0!==o?`${tL(o)}${void 0!==c?` – ${tL(c)}`:""}`:void 0})]}):(0,r.jsxs)("div",{className:"my-2 w-full max-w-2xl overflow-hidden rounded-lg border border-border bg-card",children:[(0,r.jsx)("video",{ref:g,src:j,controls:!0,playsInline:!0,preload:"metadata",className:"max-h-90 w-full bg-black object-contain",onError:()=>f(!0),onTimeUpdate:e=>{v&&e.currentTarget.currentTime>=c&&(e.currentTarget.pause(),e.currentTarget.currentTime=c)}}),(0,r.jsx)(tT,{icon:(0,r.jsx)(tA.A,{className:"size-3 text-muted-foreground"}),fileName:s,sourceUrl:tI(l,o,c),timestamp:void 0!==o?`${tL(o)}${void 0!==c?` – ${tL(c)}`:""}`:void 0})]}):"audio"===t?(0,r.jsxs)("div",{className:"my-2 w-full max-w-xl overflow-hidden rounded-lg border border-border bg-card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border px-3 py-2",children:[(0,r.jsx)("div",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,r.jsx)(t$.A,{className:"size-3.5"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"truncate text-[11px] font-medium text-foreground",children:s??"Audio recording"}),void 0!==o?(0,r.jsxs)("p",{className:"mt-0.5 text-[10px] tabular-nums text-muted-foreground",children:[tL(o),void 0!==c?` – ${tL(c)}`:""]}):(0,r.jsx)("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:"Audio reference"})]})]}),(0,r.jsx)("div",{className:"px-3 py-2",children:(0,r.jsx)("audio",{src:j,controls:!0,preload:"metadata",className:"h-8 w-full"})}),l?(0,r.jsx)("div",{className:"flex justify-end border-t border-border px-3 py-1.5",children:(0,r.jsx)("a",{href:tI(l,o,c),target:"_blank",rel:"noreferrer",className:"text-[11px] font-medium text-primary hover:text-primary/80",children:"Open source"})}):null]}):"frame-preview"===t?x?(0,r.jsxs)("div",{className:"my-2 w-full max-w-xl rounded-lg border border-border bg-card p-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"This frame could not be extracted."}),(0,r.jsx)(tT,{icon:(0,r.jsx)(tA.A,{className:"size-3 text-muted-foreground"}),fileName:s,sourceUrl:tI(l,o),timestamp:void 0!==o?tL(o):void 0})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"my-2 w-full max-w-xl overflow-hidden rounded-lg border border-border bg-card",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(!0),className:"group relative block w-full overflow-hidden",children:[(0,r.jsx)("img",{src:b,alt:`Frame at ${void 0!==o?tL(o):"unknown"}`,className:"max-h-105 w-full object-contain",loading:"lazy",onError:()=>p(!0)}),void 0!==o&&(0,r.jsx)("div",{className:"absolute bottom-2 left-2 rounded-md bg-black/70 px-2 py-0.5",children:(0,r.jsx)("span",{className:"text-[11px] font-medium tabular-nums text-white",children:tL(o)})}),(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black/0 opacity-0 transition-all group-hover:bg-black/20 group-hover:opacity-100",children:(0,r.jsx)(tC.A,{className:"size-5 text-white"})})]}),(0,r.jsx)(tT,{icon:(0,r.jsx)(tA.A,{className:"size-3 text-muted-foreground"}),fileName:s?`${s} — Frame`:"Video Frame",sourceUrl:tI(l,o),timestamp:void 0!==o?tL(o):void 0})]}),u&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-8",onClick:()=>m(!1),children:[(0,r.jsx)("button",{type:"button","aria-label":"Close frame preview",className:"absolute right-4 top-4 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",onClick:()=>m(!1),children:(0,r.jsx)(d.A,{className:"size-5"})}),(0,r.jsx)("img",{src:b,alt:`Frame at ${void 0!==o?tL(o):"unknown"}`,className:"max-h-[80vh] max-w-[90vw] rounded-lg object-contain",onClick:e=>e.stopPropagation(),onError:()=>p(!0)})]})]}):null:null}function tI(e,t,s){if(!e||!Number.isFinite(t))return e;let r=Math.max(0,Math.floor(t)),a=Number.isFinite(s)&&s>r?Math.floor(s):null;try{let t=new URL(e,"http://larkup.local"),s=t.hostname.toLowerCase().replace(/^www\./,"");if("youtube.com"===s||s.endsWith(".youtube.com")||"youtu.be"===s)return t.searchParams.set("t",`${r}s`),"http://larkup.local"===t.origin?`${t.pathname}${t.search}${t.hash}`:t.toString();return t.hash=`t=${r}${null!==a?`,${a}`:""}`,"http://larkup.local"===t.origin?`${t.pathname}${t.search}${t.hash}`:t.toString()}catch{return`${e.split("#")[0]}#t=${r}${null!==a?`,${a}`:""}`}}function tT({icon:e,fileName:t,sourceUrl:s,timestamp:a}){return t||s||a?(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-border px-3 py-1.5",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[e,(0,r.jsxs)("span",{className:"truncate text-[11px] text-muted-foreground",children:[t??"Media citation",a?` \xb7 ${a}`:""]})]}),s?(0,r.jsx)("a",{href:s,target:"_blank",rel:"noreferrer",className:"shrink-0 text-[11px] font-medium text-primary hover:text-primary/80",children:"Open source"}):null]}):null}function tL(e){let t=Math.floor(e/60),s=Math.floor(e%60);return`${t}:${String(s).padStart(2,"0")}`}var tF=s(34006),tD=s(1713);function tM(e){let t=Math.max(0,Math.floor(e)),s=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return s>0?`${s}:${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${r}:${String(a).padStart(2,"0")}`}function tR({ui:e,assetId:t,autoOpenSupportingClip:s=!1}){let[a,i]=(0,n.useState)(!1),[l,o]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{i(!!(s&&e.mediaUrl))},[s,e.mediaUrl]),e.items?.length||e.mediaUrl)?(0,r.jsxs)("div",{className:"mb-1 w-full max-w-2xl","data-testid":"chat-citations",children:[e.mediaUrl?(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>i(e=>!e),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[(0,r.jsx)(eX.A,{className:"size-3"}),(0,r.jsxs)("span",{className:"font-medium",children:[a?"Hide":"Watch"," supporting clip"]}),"number"==typeof e.primaryTimestampSecs?(0,r.jsxs)("span",{children:["\xb7 starts at ",tM(e.primaryTimestampSecs)]}):null]}),a?(0,r.jsx)("div",{className:"mt-1.5",children:(0,r.jsx)(tz,{assetId:t??"chat-citation",mediaType:e.mediaType??"video",fileName:e.fileName,mediaUrl:e.mediaUrl,sourceUrl:e.sourceUrl??e.mediaUrl,startSecs:e.primaryTimestampSecs,endSecs:e.primaryEndSecs})}):null]}):null,e.items?.length?(0,r.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border/70 bg-card/60",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-xs transition-colors hover:bg-muted/40","aria-expanded":l,children:[(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2 text-muted-foreground",children:[(0,r.jsx)(eH.A,{className:"size-3.5 shrink-0"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:e.title??"Sources"})]}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",children:[e.items.length," citation",1===e.items.length?"":"s",l?(0,r.jsx)(tF.A,{className:"size-3"}):(0,r.jsx)(u.A,{className:"size-3"})]})]}),l?(0,r.jsx)("div",{className:"border-t border-border/60 px-2 py-1.5",children:e.items.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-start gap-2 rounded-md px-1.5 py-2 hover:bg-muted/40",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:["number"==typeof e.timestampSecs?(0,r.jsx)("span",{className:"text-[11px] font-semibold tabular-nums text-foreground",children:tM(e.timestampSecs)}):null,(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.label}),e.conflicted?(0,r.jsx)(b.A,{className:"size-3 shrink-0 text-amber-600 dark:text-amber-400","aria-label":"Conflicting evidence"}):null]})}),e.seekUrl?(0,r.jsx)("a",{href:e.seekUrl,target:"_blank",rel:"noreferrer","aria-label":`Open source: ${e.label}`,className:"mt-0.5 shrink-0 p-1 text-muted-foreground transition-colors hover:text-foreground",children:(0,r.jsx)(tD.A,{className:"size-3.5"})}):null]},t))}):null]}):null]}):null}function tE(e,t=Date.now()){let s=Math.max(0,Math.min(97,e.percent)),r=Date.parse(e.updatedAt??e.startedAt??"");if(!Number.isFinite(r))return s;let a=Math.max(0,t-r),n="waking-up"===e.phase?28:97;if(s>=n)return s;let i=s+(n-s)*(1-Math.exp(-a/75e3));return Math.round(Math.max(s,Math.min(n,i)))}function tP(e,t){return Math.min(97,Math.max(e??0,t))}function tO({text:e,animate:t}){let[s,a]=(0,n.useState)(t?0:e.length);return(0,n.useEffect)(()=>{if(!t)return void a(e.length);a(t=>Math.min(t,e.length));let s=setInterval(()=>{a(t=>t>=e.length?(clearInterval(s),t):t+1)},20);return()=>clearInterval(s)},[e,t]),(0,r.jsx)(r.Fragment,{children:e.substring(0,s)})}function t_({parts:e,isShimmering:t,activity:s}){let[a,i]=(0,n.useState)(!1),l=e.some(e=>{if("tool-invocation"===e.type){let t=e.toolInvocation?.state;return"partial-call"===t||"call"===t}return"input-streaming"===e.state||"input-available"===e.state}),[o]=(0,n.useState)(l),d=(0,n.useMemo)(()=>{for(let t of e){let e="tool-invocation"===t.type?t.toolInvocation?.args:t.input??t.args;if(e?.query)return e.query}return""},[e]),c=(0,n.useMemo)(()=>e.flatMap(e=>{let t=function e(t){if("string"==typeof t)try{return e(JSON.parse(t))}catch{return null}return"object"==typeof t&&null!==t?t:null}("tool-invocation"===e.type?e.toolInvocation?.result:e.output??e.result);return Array.isArray(t?.hits)?t.hits:[]}),[e]);return(0,n.useEffect)(()=>{i(l)},[l]),(0,r.jsxs)("div",{className:"mb-0 w-full p","data-testid":"chat-citations",children:[(0,r.jsxs)("div",{className:"relative inline-flex items-center",children:[t&&(0,r.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 animate-pulse bg-linear-to-r from-transparent via-foreground/5 to-transparent"}),(0,r.jsxs)("button",{type:"button",onClick:()=>c.length>0&&i(e=>!e),className:`flex items-center gap-2 pr-2 py-1.5 text-xs transition-colors duration-500 rounded-md ${c.length>0?"hover:bg-muted/50 cursor-pointer":"cursor-default"} ${l?"text-foreground":"text-muted-foreground"}`,children:[l?(0,r.jsx)(f.A,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):(0,r.jsx)(e9.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate max-w-62.5 sm:max-w-100",children:d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"mr-1",children:l?"Searching":"Searched"}),(0,r.jsxs)("span",{className:"font-medium",children:["“",(0,r.jsx)(tO,{text:d,animate:o}),"”"]})]}):l?"Finding relevant sources…":c.length>0?"Sources":"No matching sources"}),!l&&c.length>0?(0,r.jsxs)("span",{className:"shrink-0 text-[10px] bg-secondary text-foreground px-1.5 py-0.5 rounded-full font-medium ml-1",children:[c.length," source",1===c.length?"":"s"]}):null,!l&&c.length>0?(0,r.jsx)(u.A,{className:`h-3 w-3 shrink-0 transition-transform ${a?"rotate-180":""}`}):null]})]}),l&&s?(0,r.jsxs)("div",{className:"mt-2.5 max-w-2xl rounded-xl border border-emerald-500/70 bg-background px-3 py-2.5","aria-live":"polite","data-testid":"video-analysis-progress",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,r.jsx)("span",{className:"larkup-shimmer-text font-medium",children:s.message}),s.percent>=90?null:(0,r.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[Math.max(1,Math.round(s.percent)),"%"]})]}),(0,r.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-emerald-950/10 dark:bg-emerald-100/10",role:"progressbar","aria-label":s.message,"aria-valuemin":0,"aria-valuemax":100,...s.percent>=90?{}:{"aria-valuenow":Math.max(1,Math.round(s.percent))},children:s.percent>=90?(0,r.jsx)("div",{className:"larkup-progress-shuttle h-full rounded-full bg-emerald-500"}):(0,r.jsx)("div",{className:"h-full rounded-full bg-emerald-500 transition-[width] duration-700 ease-out",style:{width:`${Math.max(6,Math.min(100,s.percent))}%`}})})]}):null,a&&c.length>0?(0,r.jsxs)("div",{className:"mt-2 overflow-hidden rounded-xl border border-border bg-card","data-testid":"citation-list",children:[l&&0===c.length?(0,r.jsx)("div",{className:"flex items-center gap-2 px-3.5 py-2.5",children:(0,r.jsx)(f.A,{className:"size-3 animate-spin text-muted-foreground"})}):null,c.slice(0,4).map((e,t)=>(0,r.jsxs)("div",{className:"flex gap-3 border-b border-border/60 px-3.5 py-3 last:border-0","data-testid":"citation-source",children:[(0,r.jsx)(tV,{hit:e}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsx)(tK,{hit:e}),tW(e.url)?(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer","aria-label":`Open ${e.title}`,className:"mt-0.5 shrink-0 text-muted-foreground transition-colors hover:text-foreground",children:(0,r.jsx)(tD.A,{className:"size-3.5"})}):null]}),e.metadata?.mediaType?(0,r.jsxs)("div",{className:"mt-1.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,r.jsxs)("span",{className:"capitalize",children:[e.metadata.mediaType," source"]}),Number.isFinite(e.metadata.startSecs)?(0,r.jsxs)("span",{className:"rounded-md bg-muted px-1.5 py-0.5 font-mono tabular-nums",children:[tB(e.metadata.startSecs),Number.isFinite(e.metadata.endSecs)?`–${tB(e.metadata.endSecs)}`:""]}):null]}):null,tU(e)?(0,r.jsxs)("div",{className:"mt-2 rounded-lg bg-muted/55 px-2.5 py-2",children:[(0,r.jsx)("div",{className:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Indexed context"}),(0,r.jsx)("p",{className:"line-clamp-4 text-xs leading-relaxed text-foreground/80",dir:"auto",children:tU(e)})]}):null]})]},`${e.title}-${t}`))]}):null]})}function tU(e){let t=e.context?.trim();if(t)return t;let s=e.timelineContext?.find(e=>"matched"===e.role)?.text?.trim();if(s)return s;let r=e.text?.trim();return r&&!r.startsWith("Verified media evidence is available")?r:""}function tB(e){let t=Math.max(0,Math.floor(e)),s=Math.floor(t/3600),r=Math.floor(t%3600/60),a=t%60;return s>0?`${s}:${String(r).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${r}:${String(a).padStart(2,"0")}`}function tW(e){return!!(e&&(e.startsWith("/")||/^https?:\/\//i.test(e)))}function tK({hit:e}){let t=e.title||"Untitled source";return tW(e.url)?(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"line-clamp-1 text-xs font-medium text-foreground transition-colors hover:text-primary hover:underline",children:t}):(0,r.jsx)("span",{className:"line-clamp-1 text-xs font-medium text-foreground",children:t})}function tV({hit:e}){let[t,s]=(0,n.useState)(!1),a=(e.images??e.metadata?.images)?.find(e=>tW(e.imageUrl));return a&&!t?(0,r.jsx)("img",{src:a.imageUrl,alt:"",className:"size-11 shrink-0 rounded-md border border-border object-cover",loading:"lazy",onError:()=>s(!0)}):(0,r.jsx)("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-md border border-border bg-muted/40 text-muted-foreground",children:e.metadata?.mediaType==="image"?(0,r.jsx)(eQ.A,{className:"size-4"}):(0,r.jsx)(eH.A,{className:"size-4"})})}var tq=s(43047);function tJ(e){if("string"==typeof e)try{return tJ(JSON.parse(e))}catch{return}return e&&"object"==typeof e&&"json"===e.type?tJ(e.value):e&&"object"==typeof e?e:void 0}function tZ(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function tH(e){let t=tZ(e.metadata).answerFeedback;return"liked"===t||"disliked"===t?t:void 0}function tG(e,t,s){return e.map(e=>e.id===t?function(e,t){let{answerFeedback:s,...r}=tZ(e.metadata),a=t?{...r,answerFeedback:t}:r;return{...e,...Object.keys(a).length>0?{metadata:a}:{metadata:void 0}}}(e,s):e)}function tX(e){return Array.isArray(e.parts)?e.parts.filter(e=>!!e&&"object"==typeof e&&"text"===e.type&&"string"==typeof e.text).map(e=>e.text).join("\n\n").trim():""}function tY({message:e,isLast:t,isStreaming:s,addToolResult:i,serverId:l,autoOpenSupportingClip:o=!1,regenerate:d,isBusy:c,onFeedback:u}){let m,x,p="user"===e.role,[h,f]=(0,n.useState)(()=>Date.now()),g=(0,n.useRef)({}),[b,j]=(0,n.useState)(null),[v,y]=(0,n.useState)({});(0,n.useEffect)(()=>{if(!t||!s)return;f(Date.now());let e=window.setInterval(()=>f(Date.now()),500);return()=>window.clearInterval(e)},[t,s]);let{data:N}=(0,k.u)(t&&s?(0,a.fO)(`/api/gpu-activity${l?`?projectId=${encodeURIComponent(l)}`:""}`):null,e=>(0,a.St)(e).then(e=>e.json()),{refreshInterval:800,dedupingInterval:0,keepPreviousData:!0}),w=N?.activity?.toolCallId&&N.activity.phase?N.activity:b,S=w?tE(w,h):0,$=tP(w?.toolCallId?v[w.toolCallId]:void 0,S);(0,n.useEffect)(()=>{if(!N?.activity?.toolCallId)return;j(N.activity);let e=N.activity.toolCallId,t=tE(N.activity,h);y(s=>{let r=tP(s[e],t);return s[e]===r?s:{...s,[e]:r}})},[N?.activity,h]);let z=w?.toolCallId?{toolCallId:w.toolCallId,percent:$,label:w.label,message:w.message||w.label,phase:w.phase}:null;try{let e=ta();m=e.updateFromToolResult,x=e.openCanvas}catch{}let I=(0,n.useMemo)(()=>{let t=e.parts?[...e.parts]:[];return e.toolInvocations&&Array.isArray(e.toolInvocations)&&e.toolInvocations.forEach(e=>{t.some(t=>"tool-invocation"===t.type&&t.toolInvocation?.toolCallId===e.toolCallId)||t.push({type:"tool-invocation",toolInvocation:e})}),t},[e.parts,e.toolInvocations]),T=(0,n.useRef)(new Set),L=(0,n.useMemo)(()=>t?I.filter(e=>{let t=t0(e);return t.isCompleted&&t.output?.success&&("fillDocumentForm"===t.toolName||"editDocument"===t.toolName||"requestDocumentSignature"===t.toolName)}).map(e=>{let t=e.toolInvocation??e;return t.toolCallId||t.id||""}).join(","):"",[I,t]);if((0,n.useEffect)(()=>{if(!m||!t||!L)return;let e=I.filter(e=>{let t=t0(e);return t.isCompleted&&t.output?.success&&("fillDocumentForm"===t.toolName||"editDocument"===t.toolName||"requestDocumentSignature"===t.toolName)});e.length>0&&e.forEach(e=>{let t=e.toolInvocation??e,s=t.toolCallId||t.id||"";if(s&&T.current.has(s))return;let r=t0(e).output;r&&r.fileBase64&&(s&&T.current.add(s),m(r))})},[L,m,t]),(0,n.useEffect)(()=>{if(!t||!i)return;let e=I.filter(e=>"requestDocumentSignature"===t0(e).toolName);if(e.length>1){for(let t=1;t<e.length;t++)if(t0(e[t]).isExecuting){let s=e[t].toolInvocation??e[t],r=s.toolCallId||s.id;r&&!T.current.has(r)&&(T.current.add(r),i({toolCallId:r,result:{success:!0,message:"Duplicate signature request auto-resolved."}}))}}},[I,t,i]),p){let t=I.filter(e=>"text"===e.type).map(e=>e.text).join(""),s=e.experimental_attachments||[],n=I.filter(e=>"image"===e.type||"file"===e.type).map(e=>{let t=e.name,s=e.mimeType||e.contentType||("image"===e.type?"image/png":"");if(!s&&e.url&&"string"==typeof e.url&&e.url.startsWith("data:")){let t=e.url.match(/^data:([^;]+);/);t&&(s=t[1])}return s||(s="application/octet-stream"),!t&&(e.url&&"string"==typeof e.url&&!e.url.startsWith("data:")?t=e.url.split("/").pop()?.split("?")[0]:(t="image"===e.type?"image.png":"Document","application/pdf"===s?t="Document.pdf":"text/plain"===s?t="Text.txt":s.includes("word")?t="Document.docx":(s.includes("excel")||s.includes("spreadsheet"))&&(t="Data.xlsx"))),{url:e.image||e.data||e.url,contentType:s,name:t}}),i=s.length>0?s:n;return(0,r.jsx)("div",{className:"message user-message group flex justify-end","data-role":"user",children:(0,r.jsxs)("div",{className:"max-w-[85%] flex flex-col gap-2 items-end",children:[i.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap justify-end gap-2",children:i.map((e,t)=>{let s=e.contentType||e.type||"",n=s.startsWith("image/"),i=s.startsWith("video/"),l=s.startsWith("audio/"),o=e.name;if(!s&&e.url&&"string"==typeof e.url&&e.url.startsWith("data:")){let t=e.url.match(/^data:([^;]+);/);t&&(s=t[1])}(!s||"application/octet-stream"===s)&&e.url&&"string"==typeof e.url&&e.url.includes("JVBERi0")&&(s="application/pdf"),o&&"Attachment"!==o?"application/pdf"!==s||o.toLowerCase().endsWith(".pdf")||(o+=".pdf"):(o=n?"image.png":"Document","application/pdf"===s?o="Document.pdf":"text/plain"===s?o="Text.txt":s.includes("word")?o="Document.docx":(s.includes("excel")||s.includes("spreadsheet"))&&(o="Data.xlsx"));let d=o.split(".").pop()?.toLowerCase()||"",c="/icons/image.png";return["csv","xls","xlsx"].includes(d)||s.includes("excel")||s.includes("spreadsheet")?c="/icons/excel.png":["doc","docx"].includes(d)||s.includes("word")?c="/icons/word.png":["md","markdown"].includes(d)?c="/icons/markdown.png":["pdf"].includes(d)||"application/pdf"===s?c="/icons/pdf.png":i?c="/icons/video.png":l?c="/icons/audio.png":n||d||(c="/icons/word.png"),(0,r.jsxs)("div",{onClick:()=>{if(x){if(e instanceof File||e.name&&e.size&&!e.url)x(e,{background:!1});else if(e.url){let t=e.url;t.startsWith("http")||t.startsWith("data:")||(t=`data:${s||"application/octet-stream"};base64,${t}`),(0,a.St)(t).then(e=>e.blob()).then(e=>{let t=new File([e],o,{type:s});x(t,{background:!1})}).catch(e=>{console.error("Failed to open attachment in canvas",e)})}}},className:`flex items-center gap-2 bg-muted/80 border border-border/60 rounded-xl h-12 px-3 p-1 shrink-0 ${x&&(e.url||e instanceof File||e.size)?"cursor-pointer hover:bg-muted":""}`,children:[(0,r.jsx)("div",{className:"size-7 shrink-0 rounded-md overflow-hidden bg-background border border-border/90 flex items-center justify-center p-1",children:(0,r.jsx)("img",{src:c,alt:o,className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"flex flex-col justify-center max-w-37.5",children:(0,r.jsx)("span",{className:"text-xs font-medium truncate text-foreground",children:o})})]},t)})}),t&&(0,r.jsx)(C.Ew,{children:t}),t&&(0,r.jsx)(M,{text:t,className:"opacity-0 transition group-hover:opacity-100 focus-within:opacity-100",regenerateLabel:"Resend from here",onRegenerate:!c&&d?()=>d({messageId:e.id}):void 0})]})})}let F=I.filter(e=>{let{toolName:t}=t0(e);return"source"===(0,tq.zf)(t).placement}),D=F.flatMap(e=>{let t=tJ(t0(e).output);return t?.videoEvidence?.success&&t.videoEvidence.ui?.kind==="citations"?[t.videoEvidence.ui]:[]}),R=F.some(e=>t0(e).isExecuting),E=z&&F.some(e=>{let t=e.toolInvocation??e;return(t.toolCallId||t.id||"")===z.toolCallId})?z:null,P=!1,O=I.filter(e=>{let{toolName:t}=t0(e);if("source"===(0,tq.zf)(t).placement)return!1;if("requestDocumentSignature"===t){if(P)return!1;P=!0}return!0}),_=I.filter(e=>"text"===e.type),{allCleanTexts:U,hasThinkTags:B}=(0,n.useMemo)(()=>{let e=!1,t=[];for(let s of _){let{cleanText:r,reasoningText:a}=function(e){let t,s;if(!e)return{cleanText:"",reasoningText:""};let r=[],a=function(e){let t=new Set(Object.keys(tq.Ag)),s=e.split("\n"),r=[],a=0;for(let e of s){if(a>0){(a+=tQ(e))<=0&&(a=0);continue}let s=e.match(/^\s*([A-Za-z_$][\w$]*)\s*\(/)?.[1];if(s&&t.has(s)){(a=tQ(e))<=0&&(a=0);continue}r.push(e)}return r.join("\n")}(e),n=/<(?:think|thought)>([\s\S]*?)<\/(?:think|thought)>/gi;for(;null!==(t=n.exec(a));)r.push(t[1].trim());a=a.replace(n,"");let i=/<(?:think|thought)>([\s\S]*)$/i,l=a.match(i);l&&(r.push(l[1].trim()),a=a.replace(i,""));let o=/<result>([\s\S]*?)<\/result>/gi,d=!1,c="",u=a;for(;null!==(s=o.exec(a));)d=!0,c+=(c?"\n\n":"")+s[1].trim(),u=u.replace(s[0],"");let m=/<result>([\s\S]*)$/i,x=u.match(m);return(x&&(d=!0,c+=(c?"\n\n":"")+x[1].trim(),u=u.replace(m,"")),d)?(u.trim()&&r.push(u.trim()),{cleanText:c.trim(),reasoningText:r.filter(Boolean).join("\n\n")}):{cleanText:a.trim(),reasoningText:r.filter(Boolean).join("\n\n")}}(s.text||"");t.push(r),a&&(e=!0)}return{allCleanTexts:t,hasThinkTags:e}},[_]),W=(0,n.useMemo)(()=>U.filter(Boolean).join("\n\n").trim(),[U]),K=tH(e),V="liked"===K,q="disliked"===K,J=_.every(e=>!e.text||0===e.text.trim().length)&&t&&s,Z=e=>{let{toolName:t,isCompleted:s}=t0(e);return"visualization"===(0,tq.zf)(t).placement&&s},H=O.filter(Z),G=O.filter(e=>"media"===(0,tq.zf)(t0(e).toolName).placement),X=O.filter(e=>"web-search"===(0,tq.zf)(t0(e).toolName).placement),Y=O.filter(e=>{let t=(0,tq.zf)(t0(e).toolName).placement;return!Z(e)&&"inline"===t}),Q=O.findIndex(e=>t0(e).output?.ui?.kind==="citations"),ee=H.length>1?H.map((e,t)=>{let{output:s}=t0(e);return{label:s?.title||`Chart ${t+1}`,content:t1(e,t)}}):null,et=(0,n.useMemo)(()=>O.filter(e=>{let{isExecuting:t,toolName:s}=t0(e);return t&&"source"!==(0,tq.zf)(s).placement}),[O]);return(0,r.jsxs)("div",{className:"message assistant-message flex flex-col gap-2","data-role":"assistant",children:[F.length>0&&(0,r.jsx)(t_,{parts:F,isShimmering:J,activity:E}),D.map((e,t)=>(0,r.jsx)(tR,{ui:e,autoOpenSupportingClip:o&&0===t},`nested-citations-${t}`)),X.length>0&&(0,r.jsx)(t5,{parts:X}),Y.filter(e=>{let t=t0(e);return t.isCompleted||t.isFailed}).map((e,t)=>{let s=O.indexOf(e);return t1(e,t,i,m,void 0,o&&0===D.length&&s===Q)}),ee?(0,r.jsx)(e8,{config:{tabs:ee}}):H.map((e,t)=>t1(e,t,i,m)),et.map((e,t)=>t1(e,t,i,m,(e=>{let t=e.toolInvocation??e,s=t.toolCallId||t.id||"";if(z?.toolCallId===s)return z;g.current[s]??=h;let r=(0,tq.zf)(t0(e).toolName);return{toolCallId:s,percent:function(e,t=Date.now()){return Math.max(4,Math.min(82,4+78*(1-Math.exp(-Math.max(0,t-e)/55e3))))}(g.current[s],h),indeterminate:!0,label:r.pendingLabel||"Working…",message:r.pendingLabel||"Working…"}})(e))),t&&s&&0===et.length&&!R&&!B&&_.every(e=>!e.text||0===e.text.trim().length)&&(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)("div",{className:"size-6.5 bg-white border border-border rounded-full flex items-center justify-center p-1 animate-pulse",children:(0,r.jsx)("img",{src:"/logo.png",alt:"logo",className:"size-4 animate-spin"})})}),_.map((e,t)=>{let s=e.text||"";if(!s.trim())return null;let a=(U[t]??s).replace(/\[(?:IMAGE_REF|VIDEO_REF|AUDIO_REF):[^\]]+\]/g,"");if(!a.trim())return null;let n=function(e){if(!e)return[];let t=e.split("\n"),s=[],r=[],a=[],n=!1,i=e=>{let t=e.trim();return t.startsWith("|")&&t.endsWith("|")&&t.length>2},l=e=>/^\|[\s\-:|]+\|$/.test(e.trim()),o=()=>{if(r.length>0){let e=r.join("\n").trim();e&&s.push({type:"text",content:e}),r=[]}},d=()=>{if(a.length<2){r.push(...a),a=[];return}let e=a[0].split("|").map(e=>e.trim()).filter(Boolean),t=1;a.length>1&&l(a[1])&&(t=2);let n=[];for(let s=t;s<a.length;s++){let t=a[s].split("|").slice(1,-1).map(e=>e.trim()),r={};e.forEach((e,s)=>{let a=t[s]??"",n=Number(a);r[e]=isNaN(n)||""===a?a:n}),n.push(r)}e.length>0&&n.length>0&&s.push({type:"table",table:{columns:e,rows:n}}),a=[]};for(let e of t)i(e)?(n||(o(),n=!0),l(e)&&1!==a.length?l(e)&&a.push(e):a.push(e)):(n&&(d(),n=!1),r.push(e));return n&&d(),o(),s}(a);return(0,r.jsx)("div",{className:"flex flex-col gap-4",children:n.map((e,t)=>{if("table"===e.type){let s={columns:e.table.columns,rows:e.table.rows,totalRows:e.table.rows.length};return(0,r.jsx)(eJ,{config:s},`table-${t}`)}return(0,r.jsx)("div",{className:"assistant-text-content",dangerouslySetInnerHTML:{__html:function(e){if(!e)return"";let t=(function(e){let t=e.split("\n"),s=null,r=2;for(let e=0;e<t.length;e+=1){let a=t[e].match(/^(\s*)1\.\s+(.+)$/);if(!a){/^\s*\d+\.\s+/.test(t[e])&&(s=null,r=2);continue}null!==s&&t.slice(s+1,e).every(e=>!e.trim()||/^\s*[-*+]\s+/.test(e))?(t[e]=`${a[1]}${r}. ${a[2]}`,r+=1):r=2,s=e}return t.join("\n")})(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\\\[([\s\S]+?)\\\]|\$\$([\s\S]+?)\$\$/g,(e,t,s)=>{try{return A.Ay.renderToString(t||s,{displayMode:!0,throwOnError:!1})}catch{return e}})).replace(/\\\(([\s\S]+?)\\\)|\$([^$\n]+?)\$/g,(e,t,s)=>{try{return A.Ay.renderToString(t||s,{displayMode:!1,throwOnError:!1})}catch{return e}})).replace(/!\[([^\]]*)\]\([^)]*\)/g,(e,t)=>`<span class="text-muted-foreground italic">[Image unavailable${t?`: ${t}`:""}]</span>`)).replace(/```(\w*)\n([\s\S]*?)```/g,'<pre class="msg-code-block"><code>$2</code></pre>')).replace(/`([^`]+)`/g,'<code class="msg-inline-code">$1</code>')).replace(/\*\*(.+?)\*\*/g,'<strong class="msg-bold">$1</strong>')).replace(/\*(.+?)\*/g,"<em>$1</em>")).replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,s)=>{let r=s.toLowerCase();return r.match(/\.(mp4|webm|ogg)$/)||r.includes("video")?`<video src="${s}" controls preload="metadata" class="max-w-90 w-full rounded-lg my-2 border border-border bg-card"></video>`:r.match(/\.(mp3|wav|m4a|oga)$/)||r.includes("audio")?`<audio src="${s}" controls preload="metadata" class="max-w-80 w-full my-2"></audio>`:`<a href="${s}" target="_blank" rel="noreferrer" class="msg-link">${t}</a>`})).replace(/^### (.+)$/gm,'<h3 class="msg-h3">$1</h3>')).replace(/^## (.+)$/gm,'<h2 class="msg-h2">$1</h2>')).replace(/^# (.+)$/gm,'<h1 class="msg-h1">$1</h1>')).replace(/^- (.+)$/gm,'<li class="msg-li">$1</li>')).replace(/(<li class="msg-li">.*?<\/li>\n?)+/g,e=>`<ul class="msg-ul">${e}</ul>`)).replace(/(^\d+\. .+$)(\n\n)((?=\d+\. ))/gm,"$1\n$3")).replace(/^(\d+)\. (.+)$/gm,'<li class="msg-li-ordered" data-order="$1">$2</li>')).replace(/(<li class="msg-li-ordered" data-order="\d+">.*?<\/li>\n?)+/g,e=>{let t=e.match(/data-order="(\d+)"/)?.[1]??"1";return`<ol class="msg-ol" start="${t}">${e.replace(/ data-order="\d+"/g,"")}</ol>`})).replace(/\n\n/g,'</p><p class="msg-p">')).replace(/(<?\/?(?:ul|ol|li|h1|h2|h3|pre)[^>]*>)\n+/g,"$1")).replace(/\n+(<\/?(?:ul|ol|li|h1|h2|h3|pre)[^>]*>)/g,"$1")).replace(/\n/g,"<br/>")}(e.content)}},`text-${t}`)})},t)}),G.filter(e=>t0(e).isCompleted).map((e,t)=>t1(e,t,i,m)),W&&!(t&&s)&&(0,r.jsx)(M,{text:W,liked:V,disliked:q,onLike:u?()=>{u?.(e.id,V?void 0:"liked")}:void 0,onDislike:u?()=>{u?.(e.id,q?void 0:"disliked")}:void 0,onRegenerate:d?()=>d({messageId:e.id}):void 0})]})}function tQ(e){let t=0;for(let s of e)"("===s&&(t+=1),")"===s&&(t-=1);return t}function t0(e){if("tool-invocation"===e.type){let t=e.toolInvocation,s=t.state;return{toolName:t.toolName,isExecuting:"partial-call"===s||"call"===s,isCompleted:("result"===s||"output"===s||"output-available"===s)&&void 0!==t.result,isFailed:"output-error"===s||"error"===s,errorText:"string"==typeof t.errorText?t.errorText:void 0,output:tJ(t.result)??t.result,input:t.args}}if(e.type?.startsWith("tool-")&&"tool-invocation"!==e.type){let t=e.type.replace("tool-",""),s=e.state;return{toolName:t,isExecuting:"input-streaming"===s||"input-available"===s,isCompleted:("output"===s||"output-available"===s)&&void 0!==e.output,isFailed:"output-error"===s||"error"===s,errorText:"string"==typeof e.errorText?e.errorText:void 0,output:tJ(e.output)??e.output,input:e.input}}return{toolName:"",isExecuting:!1,isCompleted:!1,isFailed:!1,output:void 0,input:void 0}}function t1(e,t,s,a,n,i=!1){let{toolName:l,isExecuting:o,isCompleted:d,isFailed:c,output:u,input:m}=t0(e),x=(0,tq.zf)(l),p=e.toolInvocation?.toolCallId||e.toolCallId||e.id||"";if(o){if("source"===x.placement)return null;if("signature"===x.resultView)return(0,r.jsx)(tw,{detectedLocations:m?.detectedLocations,toolCallId:p,addToolResult:s},t);let e=n&&n.toolCallId===p?n:null,a=!!e&&(!0===e.indeterminate||e.percent>=90);return(0,r.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5 py-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)("div",{className:"size-6.5 bg-white dark:bg-card border border-border rounded-full flex items-center justify-center p-1",children:(0,r.jsx)("img",{src:"/logo.png",alt:"",className:"size-4 animate-spin"})}),(0,r.jsx)("span",{className:"larkup-shimmer-text min-w-0 wrap-break-word text-[13px] font-medium leading-5","aria-live":"polite","aria-atomic":"true",children:e?.message||e?.label||x.pendingLabel||"Working"})]}),e&&!1!==x.showProgressBar?(0,r.jsxs)("div",{className:"ml-9 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-1.5 w-48 overflow-hidden rounded-full bg-muted",children:a?(0,r.jsx)("div",{className:"larkup-progress-shuttle h-full rounded-full bg-emerald-500"}):(0,r.jsx)("div",{className:"h-full rounded-full bg-emerald-500 transition-[width] duration-700 ease-out",style:{width:`${Math.max(6,Math.min(100,e.percent))}%`}})}),a?null:(0,r.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[Math.round(e.percent),"%"]})]}):null]},t)}if(c)return"sandbox"===x.resultView?(0,r.jsx)(e6,{config:{stdout:"",stderr:"",exitCode:1,artifacts:[],executionTimeMs:0}},t):(0,r.jsx)("div",{role:"alert",className:"rounded-md border border-red-500/20 bg-red-500/5 px-3 py-2 text-sm text-red-700 dark:text-red-300",children:"This action could not be completed. Please retry."},t);if(d){let e=u?.ui;if(e?.kind==="notice")return(0,r.jsxs)("div",{className:"rounded-xl border border-primary/20 bg-primary/5 px-4 py-3 text-sm",children:[(0,r.jsx)("div",{className:"font-medium",children:e.title}),(0,r.jsx)("div",{className:"mt-1 text-muted-foreground",children:e.body})]},t);if(e?.kind==="card")return(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card px-4 py-3 text-sm",children:[(0,r.jsx)("div",{className:"font-medium",children:e.title}),(0,r.jsx)("dl",{className:"mt-3 grid gap-2",children:(e.facts??[]).map(e=>(0,r.jsxs)("div",{className:"flex items-start justify-between gap-5",children:[(0,r.jsx)("dt",{className:"text-muted-foreground",children:e.label}),(0,r.jsx)("dd",{className:"text-right",children:e.value})]},e.label))})]},t);if(e?.kind==="table")return(0,r.jsxs)("div",{className:"overflow-x-auto rounded-xl border border-border bg-card p-3 text-sm",children:[(0,r.jsx)("div",{className:"mb-3 font-medium",children:e.title}),(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:"text-muted-foreground",children:(0,r.jsx)("tr",{children:(e.columns??[]).map(e=>(0,r.jsx)("th",{className:"px-2 py-1",children:e},e))})}),(0,r.jsx)("tbody",{children:(e.rows??[]).map((t,s)=>(0,r.jsx)("tr",{className:"border-t border-border/60",children:(e.columns??[]).map(e=>(0,r.jsx)("td",{className:"px-2 py-2",children:t[e]},e))},s))})]})]},t);if(e?.kind==="citations")return(0,r.jsx)(tR,{ui:e,assetId:u?.mediaAssetId,autoOpenSupportingClip:i},t);switch(x.resultView){case"data-table":{if(u.error)return null;let e={columns:u.columns??[],rows:u.rows??[],totalRows:u.totalRows??0,truncated:u.truncated,aggregationResults:u.aggregationResults};if(0===e.rows.length&&!e.aggregationResults)return null;let s=u.visualization;return(0,r.jsxs)("div",{children:[(0,r.jsx)(eJ,{config:e,compact:x.compactResult}),s?.data?.length?(0,r.jsx)(eF,{config:s}):null]},t)}case"file-export":if(!u?.success||!u?.fileBase64)break;return(0,r.jsx)(eG,{artifact:u},t);case"none":if("visualization"!==x.placement||!u)break;return(0,r.jsx)(eF,{config:u},t);case"sandbox":return(0,r.jsx)(e6,{config:u},t);case"corpus":if(!u)break;return(0,r.jsx)(ts,{config:u},t);case"document-edit":{if(!u.success)return null;let e=u.fileName||"Document",s=u.mimeType||"",n=e.split(".").pop()?.toLowerCase()||"",i="/icons/image.png";return["csv","xls","xlsx"].includes(n)||s.includes("excel")||s.includes("spreadsheet")?i="/icons/excel.png":["doc","docx"].includes(n)||s.includes("word")?i="/icons/word.png":["md","markdown"].includes(n)?i="/icons/markdown.png":["pdf"].includes(n)||"application/pdf"===s?i="/icons/pdf.png":n||(i="/icons/word.png"),(0,r.jsxs)("div",{onClick:()=>{a&&u.fileBase64&&a(u)},className:"group flex items-center gap-3 rounded-xl border border-border/60 bg-emerald-50/50 dark:bg-emerald-900/10 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-400 cursor-pointer hover:bg-emerald-100/50 dark:hover:bg-emerald-900/20 transition",children:[(0,r.jsx)("div",{className:"size-8 shrink-0 rounded-md overflow-hidden bg-white border border-emerald-200/50 flex items-center justify-center p-1.5 35",children:(0,r.jsx)("img",{src:i,alt:e,className:"w-full h-full object-contain"})}),(0,r.jsxs)("div",{className:"flex flex-col flex-1",children:[(0,r.jsxs)("span",{className:"font-medium text-emerald-800 dark:text-emerald-300",children:["fillDocumentForm"===l?"Form fields updated in ":"Edited ",(0,r.jsx)("span",{className:"font-bold",children:e})]}),(0,r.jsxs)("span",{className:"text-xs opacity-80 mt-0.5",children:[u.updatedFields?.length||0," ",u.updatedFields?.length===1?"change":"changes"," applied. Preview updated in Canvas."]})]}),u.fileBase64&&(0,r.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 text-xs font-medium text-emerald-600 dark:text-emerald-400 flex items-center gap-1 transition",children:[(0,r.jsx)(tk.A,{className:"size-3"}),"View this version"]})]},t)}case"signature":if(!u?.success)break;return(0,r.jsxs)("div",{onClick:()=>{a&&u.fileBase64&&a(u)},className:"group flex items-center gap-3 rounded-xl border border-border/60 bg-emerald-50/50 dark:bg-emerald-900/10 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-400 mt-2 cursor-pointer hover:bg-emerald-100/50 dark:hover:bg-emerald-900/20 transition",children:[(0,r.jsx)(e0.A,{className:"size-5 shrink-0 text-emerald-500"}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-medium text-emerald-800 dark:text-emerald-300",children:"Document signed successfully."}),u.fileBase64&&(0,r.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 text-xs font-medium text-emerald-600 dark:text-emerald-400 flex items-center gap-1 transition",children:[(0,r.jsx)(tk.A,{className:"size-3"}),"View this version"]})]})]},t);case"image-analysis":if(u.error)break;return(0,r.jsx)("div",{className:"mb-2 w-full",children:(0,r.jsxs)("div",{className:"inline-flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground bg-muted/30 rounded-md border border-border/50",children:[(0,r.jsx)(tS.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsx)("span",{className:"truncate max-w-62.5 sm:max-w-100",children:"Analyzed indexed image"})]})},t);case"media":if(!u?.success||!u.assetId||!["image","video","audio","frame-preview"].includes(u.mediaType))break;return(0,r.jsx)(tz,{assetId:u.assetId,mediaType:u.mediaType,fileName:u.fileName,mediaUrl:u.mediaUrl,sourceUrl:u.sourceUrl,startSecs:u.startSecs,endSecs:u.endSecs},t)}}return null}function t5({parts:e}){let[t,s]=(0,n.useState)(!1),a=e.map(e=>{let t=t0(e),s=Array.isArray(t.output?.results)?t.output.results:[];return{query:t.input?.query,results:s,running:t.isExecuting}}),i=a.reduce((e,t)=>e+t.results.length,0),l=a.some(e=>e.running);return(0,r.jsxs)("div",{className:"mb-2 w-full",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>(i>0||a.length>1)&&s(e=>!e),className:"inline-flex items-center gap-2 rounded-md border border-border/50 bg-muted/30 px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/50",children:[(0,r.jsx)(y.A,{className:"size-3.5 shrink-0"}),(0,r.jsx)("span",{children:l?"Searching the web…":"Searched the web"}),!l&&i>0?(0,r.jsxs)("span",{className:"rounded-full bg-secondary px-1.5 py-0.5 text-[10px] font-medium text-foreground",children:[i," result",1===i?"":"s"]}):null,!l&&(i>0||a.length>1)?(0,r.jsx)(u.A,{className:`size-3 transition-transform ${t?"rotate-180":""}`}):null]}),t?(0,r.jsx)("div",{className:"mt-2 max-w-xl overflow-hidden rounded-lg border border-border/60 bg-background text-xs",children:a.flatMap(e=>e.results).slice(0,5).map((e,t)=>(0,r.jsxs)("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"block border-b border-border/50 px-3 py-2.5 last:border-0 hover:bg-muted/40",children:[(0,r.jsx)("span",{className:"block truncate font-medium text-foreground",children:e.title||e.url}),e.snippet?(0,r.jsx)("span",{className:"mt-0.5 block line-clamp-2 text-muted-foreground",children:e.snippet}):null]},`${e.url??e.title??t}-${t}`))}):null]})}function t2({items:e,onRemove:t,onMoveUp:s,onMoveDown:a,onEdit:n}){return 0===e.length?null:(0,r.jsxs)("div",{className:"mx-auto mb-2 w-full max-w-3xl overflow-hidden rounded-2xl border border-border bg-card",children:[(0,r.jsx)("div",{className:"border-b border-border/60 px-3 py-1.5",children:(0,r.jsxs)("span",{className:"text-xs font-medium text-muted-foreground",children:[e.length," queued message",e.length>1?"s":""]})}),(0,r.jsx)("ul",{className:"max-h-40 overflow-y-auto scrollbar-none [&::-webkit-scrollbar]:hidden",children:e.map((i,l)=>(0,r.jsxs)("li",{className:"group flex items-start gap-2 border-border/40 px-3 py-2 text-sm transition-colors last:border-b-0 hover:bg-secondary",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>n(i.id),className:"min-w-0 flex-1 cursor-pointer text-left",title:"Click to edit",children:[(0,r.jsx)("p",{className:"line-clamp-2 break-words text-foreground",children:i.text||"(attachment only)"}),i.files&&i.files.length>0&&(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-1 text-muted-foreground",children:[(0,r.jsx)(c.A,{className:"size-3 shrink-0"}),(0,r.jsx)("span",{className:"truncate text-xs",children:i.files.map(e=>e.name).join(", ")})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[(0,r.jsx)("button",{type:"button",onClick:()=>s(i.id),disabled:0===l,className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition hover:bg-muted-foreground/10 hover:text-foreground disabled:pointer-events-none disabled:opacity-30","aria-label":"Move up in queue",children:(0,r.jsx)(tF.A,{className:"size-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>a(i.id),disabled:l===e.length-1,className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition hover:bg-muted-foreground/10 hover:text-foreground disabled:pointer-events-none disabled:opacity-30","aria-label":"Move down in queue",children:(0,r.jsx)(u.A,{className:"size-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:()=>t(i.id),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive","aria-label":"Remove from queue",children:(0,r.jsx)(p.A,{className:"size-3.5"})})]})]},i.id))})]})}var t3=s(51470),t4=s(34956),t6=s(73515),t8=s(25903),t7=s(60557),t9=s(96517),se=s(86326);let st=async e=>{let t=await (0,a.St)(e);if(!t.ok)throw Error("Could not load job progress.");return t.json()};function ss(){let[e,t]=(0,n.useState)(!1),[s,i]=(0,n.useState)("running"),{activeProject:l}=(0,t6.By)(),o=l?.id,{data:d,error:c,mutate:u}=(0,k.u)((0,a.fO)("/api/jobs"),se.A,{refreshInterval:e=>4e3*!!e?.jobs?.some(e=>"running"===e.status||"queued"===e.status),revalidateOnFocus:!0}),{data:m,error:x,mutate:p}=(0,k.u)((0,a.fO)("/api/index"),st,{refreshInterval:e=>2e3*!!e?.running,revalidateOnFocus:!0}),h=(0,a.fO)(`/api/media?type=all${o?`&serverId=${encodeURIComponent(o)}`:""}`),{data:g,error:j,mutate:v}=(0,k.u)(h,st,{refreshInterval:e=>2e3*!!e?.assets?.some(t7.t),revalidateOnFocus:!0}),y=d?.jobs??[],N=y.filter(e=>"running"===e.status||"queued"===e.status),w=(g?.assets??[]).filter(t7.t),S=m?.running??!1,C=N.length+w.length+ +!!S,A=C>0,$=y.length>0||w.length>0||S,z="running"===s?N:y,I=(0,n.useCallback)(()=>{Promise.all([u(),p(),v()])},[p,u,v]);return(0,r.jsxs)(t9.cj,{open:e,onOpenChange:e=>{t(e),e&&I()},children:[(0,r.jsx)(F.Bc,{delay:50,children:(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)(t9.CG,{render:(0,r.jsxs)("button",{type:"button","aria-label":A?`Jobs tracking, ${C} active`:"Jobs tracking",className:(0,D.cn)("relative flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground",A&&"bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/15 hover:text-emerald-700 dark:text-emerald-400"),children:[(0,r.jsx)(t3.A,{className:"size-4"}),A&&(0,r.jsx)("span",{"aria-hidden":"true",className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[9px] font-semibold leading-none text-white ring-2 ring-background motion-safe:animate-pulse",children:C>9?"9+":C})]})})}),(0,r.jsx)(F.ZI,{children:A?"Active jobs":"Jobs"})]})}),(0,r.jsxs)(t9.h,{side:"right",className:"w-[calc(100vw-1rem)]! max-w-2xl! gap-0 p-0 sm:w-2xl!",children:[(0,r.jsx)(t9.Fm,{className:"border-b border-border px-5 py-4 pr-14",children:(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("div",{className:(0,D.cn)("flex size-8 items-center justify-center rounded-lg bg-muted text-muted-foreground",A&&"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"),children:(0,r.jsx)(t3.A,{className:"size-4"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)(t9.qp,{className:"text-sm font-semibold",children:"Jobs"}),(0,r.jsx)(t9.Qs,{className:"text-xs",children:A?`${C} background ${1===C?"job":"jobs"} active`:"Track indexing and website jobs"})]})]})}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:[(c||x||j)&&(0,r.jsxs)("div",{className:"mb-4 flex items-start gap-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2.5 text-xs text-amber-800 dark:text-amber-300",children:[(0,r.jsx)(b.A,{className:"mt-0.5 size-3.5 shrink-0"}),"Some job progress could not be refreshed. The available results are shown below."]}),$?(0,r.jsxs)("div",{className:"space-y-5",children:[(0,r.jsx)(t7.v,{assets:w}),S&&(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5",children:[(0,r.jsx)(f.A,{className:"size-4 shrink-0 animate-spin text-emerald-600"}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:"Indexing files"}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Running in the background — new files will join the queue."})]})]}),y.length>0&&(0,r.jsxs)("section",{className:(0,D.cn)((w.length>0||S)&&"border-t border-border pt-4"),children:[(0,r.jsx)("div",{className:"mb-3 flex items-center gap-2",children:[{id:"running",label:"Running"},{id:"all",label:"All jobs"}].map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s===e.id,onClick:()=>i(e.id),className:(0,D.cn)("rounded-full px-3 py-1 text-xs font-medium transition-colors",s===e.id?"bg-muted text-foreground":"border border-border text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:e.label},e.id))}),(0,r.jsx)(t8.n,{jobs:z,onChanged:I})]})]}):(0,r.jsxs)("div",{className:"flex min-h-64 flex-col items-center justify-center text-center",children:[(0,r.jsx)("div",{className:"mb-3 flex size-10 items-center justify-center rounded-xl border border-border bg-muted/40 text-muted-foreground",children:(0,r.jsx)(t4.A,{className:"size-4.5"})}),(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No jobs yet"}),(0,r.jsx)("p",{className:"mt-1 max-w-xs text-xs leading-relaxed text-muted-foreground",children:"File indexing, media processing, and website jobs will appear here while they run."})]})]})]})]})}var sr=s(22194);let sa=e=>(0,a.fj)()?`${(0,a.fj)()}:${String(e)}`:e,sn=e=>tu.Jt(sa(e)),si=(e,t)=>tu.hZ(sa(e),t),sl=e=>tu.yH(sa(e));async function so(){let e=await tu.HP(),t=(0,a.fj)();return t?e.filter(e=>"string"==typeof e&&e.startsWith(t+":")).map(e=>String(e).slice(t.length+1)):e}var sd=s(46441),sc=s(97508),su=s(59175);let sm=(0,sc.v)()((0,su.Zr)(e=>({selectedModel:"",setSelectedModel:t=>e({selectedModel:t})}),{name:"larkup-chat-store"}));var sx=s(10663),sp=s(47136),sh=s(73361),sf=s(49484),sg=s(22942);function sb({field:e,isFilling:t,isUpdated:s,onEdit:a}){let[i,l]=(0,n.useState)(e.value),[o,d]=(0,n.useState)(!1),c=(0,n.useRef)(null);(0,n.useEffect)(()=>{l(e.value)},[e.value]);let u=()=>{d(!1),i!==e.value&&a(i)};return(0,r.jsxs)(tl.P.div,{"data-field-id":e.id,layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},className:(0,D.cn)("group relative rounded-lg border px-3 py-2 transition-all duration-300",t&&"border-primary/40 bg-primary/5",s&&!t&&"border-emerald-400/60 bg-emerald-50/50 dark:bg-emerald-900/10",!t&&!s&&"border-border/60 bg-card hover:border-border"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsxs)("label",{className:"text-[11px] font-medium text-muted-foreground",children:[e.name,e.required&&(0,r.jsx)("span",{className:"text-destructive ml-0.5",children:"*"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[t&&(0,r.jsxs)(tl.P.div,{initial:{scale:0},animate:{scale:1},className:"flex items-center gap-1",children:[(0,r.jsx)(f.A,{className:"size-3 animate-spin text-primary"}),(0,r.jsx)("span",{className:"text-[9px] text-primary font-medium",children:"Filling…"})]}),s&&!t&&(0,r.jsxs)(tl.P.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:500,damping:25},className:"flex items-center gap-1",children:[(0,r.jsx)("div",{className:"flex h-4 w-4 items-center justify-center rounded-full bg-emerald-500",children:(0,r.jsx)($.A,{className:"size-2.5 text-white"})}),(0,r.jsx)("span",{className:"text-[9px] text-emerald-600 dark:text-emerald-400 font-medium",children:"Updated"})]})]})]}),"checkbox"===e.type?(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:"true"===i,onChange:e=>{let t=e.target.checked?"true":"false";l(t),a(t)},className:"h-4 w-4 rounded border-border text-primary focus:ring-primary"}),(0,r.jsx)("span",{className:"text-xs text-foreground",children:e.name})]}):"select"===e.type&&e.options?(0,r.jsxs)("select",{value:i,onChange:e=>{l(e.target.value),a(e.target.value)},className:"w-full rounded-md border border-border/60 bg-transparent px-2 py-1 text-xs text-foreground outline-none focus:border-primary",children:[(0,r.jsx)("option",{value:"",children:"Select…"}),e.options.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}):"textarea"===e.type?(0,r.jsx)("textarea",{ref:c,value:i,onChange:e=>l(e.target.value),onFocus:()=>d(!0),onBlur:u,placeholder:e.placeholder||`Enter ${e.name.toLowerCase()}`,rows:2,className:(0,D.cn)("w-full rounded-md border bg-transparent px-2 py-1 text-xs text-foreground outline-none resize-none transition","border-border/60 focus:border-primary placeholder:text-muted-foreground/50",t&&"animate-pulse")}):(0,r.jsx)("input",{ref:c,type:"date"===e.type?"date":"number"===e.type?"number":"text",value:i,onChange:e=>l(e.target.value),onFocus:()=>d(!0),onBlur:u,onKeyDown:e=>{"Enter"===e.key&&e.target.blur()},placeholder:e.placeholder||`Enter ${e.name.toLowerCase()}`,className:(0,D.cn)("w-full rounded-md border bg-transparent px-2 py-1 text-xs text-foreground outline-none transition","border-border/60 focus:border-primary placeholder:text-muted-foreground/50",t&&"animate-pulse")}),t&&(0,r.jsx)(tl.P.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 rounded-lg overflow-hidden pointer-events-none",children:(0,r.jsx)("div",{className:"absolute inset-0 bg-linear-to-r from-transparent via-primary/5 to-transparent animate-shimmer"})})]})}function sj(){let{parsedDocument:e,activeFileName:t,activeFileType:s,fileBase64:a,fileMimeType:i,isLoading:l,error:o,fillingFields:c,updatedFields:u,updateVersion:m,closeCanvas:x,exportFile:p,applyEdits:h}=ta(),[g,b]=(0,n.useState)(0),[j,v]=(0,n.useState)(100),[y,N]=(0,n.useState)(!1),w=(0,n.useRef)(null),k=e?.totalPages??0,S=e?.pages?.[g];(0,n.useEffect)(()=>{if(c.size>0&&w.current){let e=Array.from(c)[0],t=w.current.querySelector(`[data-field-id="${e}"]`);t&&t.scrollIntoView({behavior:"smooth",block:"center"})}},[c]);let C=()=>{let t=S?.text||e?.rawText||"No content to display";return(0,r.jsx)("div",{className:"flex-1 overflow-auto p-6 bg-card",children:(0,r.jsx)("div",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground",children:t})})};return(0,r.jsxs)(tl.P.div,{initial:{width:0,opacity:0},animate:{width:"100%",opacity:1},exit:{width:0,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:(0,D.cn)("flex h-full flex-col border-l border-border bg-card overflow-hidden",y&&"fixed inset-0 z-50 border-none"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-border/40 px-3 py-2 bg-card",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(eH.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate text-xs font-medium text-foreground",children:t||"Document"}),e?.fields&&e.fields.length>0&&(0,r.jsxs)("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-semibold text-primary",children:[e.fields.length," fields"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[k>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",onClick:()=>b(e=>Math.max(0,e-1)),disabled:0===g,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted disabled:opacity-30",children:(0,r.jsx)(e_.A,{className:"size-3.5"})}),(0,r.jsxs)("span",{className:"text-[10px] tabular-nums text-muted-foreground px-1",children:[g+1,"/",k]}),(0,r.jsx)("button",{type:"button",onClick:()=>b(e=>Math.min(k-1,e+1)),disabled:g>=k-1,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted disabled:opacity-30",children:(0,r.jsx)(eU.A,{className:"size-3.5"})}),(0,r.jsx)("div",{className:"mx-1 h-4 w-px bg-border"})]}),(0,r.jsx)("button",{type:"button",onClick:()=>v(e=>Math.max(50,e-10)),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted",children:(0,r.jsx)(sh.A,{className:"size-3.5"})}),(0,r.jsxs)("span",{className:"text-[10px] tabular-nums text-muted-foreground w-8 text-center",children:[j,"%"]}),(0,r.jsx)("button",{type:"button",onClick:()=>v(e=>Math.min(200,e+10)),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted",children:(0,r.jsx)(sf.A,{className:"size-3.5"})}),(0,r.jsx)("div",{className:"mx-1 h-4 w-px bg-border"}),(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)("button",{type:"button",onClick:()=>N(e=>!e),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted",children:y?(0,r.jsx)(sg.A,{className:"size-3.5"}):(0,r.jsx)(tC.A,{className:"size-3.5"})})}),(0,r.jsx)(F.ZI,{children:y?"Exit fullscreen":"Fullscreen"})]}),(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)("button",{type:"button",onClick:p,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted",children:(0,r.jsx)(en.A,{className:"size-3.5"})})}),(0,r.jsx)(F.ZI,{children:"Download"})]}),(0,r.jsx)("button",{type:"button",onClick:x,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground",children:(0,r.jsx)(d.A,{className:"size-3.5"})})]})]}),(0,r.jsx)("div",{ref:w,className:"flex flex-1 flex-col min-h-0 overflow-hidden",children:(()=>{if(l)return(0,r.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(f.A,{className:"size-6 animate-spin text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:"Parsing document…"})]})});if(o)return(0,r.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center",children:[(0,r.jsx)(eH.A,{className:"size-8 text-muted-foreground/40"}),(0,r.jsx)("p",{className:"text-sm text-destructive",children:o})]})});if(!e)return null;switch(s){case"pdf":return a&&i?(0,r.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"flex-1 overflow-auto bg-muted/30 p-4",children:(0,r.jsx)("div",{style:{transform:`scale(${j/100})`,transformOrigin:"top center"},className:"transition-transform duration-200",children:(0,r.jsx)("object",{data:`data:${i};base64,${a}#page=${g+1}`,type:"application/pdf",className:"mx-auto w-full rounded-lg border border-border/40",style:{height:"80vh",minHeight:"500px"},children:C()},`pdf-view-${m}`)})}),e?.fields&&e.fields.length>0&&(0,r.jsxs)("div",{className:"border-t border-border/40 bg-card",children:[(0,r.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,r.jsx)(eH.A,{className:"size-3"}),"Form Fields (",e.fields.length,")"]}),(0,r.jsx)("div",{className:"max-h-50 overflow-y-auto px-4 pb-3 space-y-2 [&::-webkit-scrollbar]:hidden",children:e.fields.map(e=>(0,r.jsx)(sb,{field:e,isFilling:c.has(e.id),isUpdated:u.has(e.id),onEdit:t=>{h([{fieldId:e.id,value:t,type:"fill"}])}},e.id))})]})]}):C();case"docx":let t=S?.html;return(0,r.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,r.jsx)("div",{ref:w,className:"flex-1 overflow-auto p-6 bg-white dark:bg-card",style:{transform:`scale(${j/100})`,transformOrigin:"top left"},children:t?(0,r.jsx)("div",{className:"docx-content prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:t.replace(/<script[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style[^>]*>[\s\S]*?<\/style>/gi,"").replace(/on\w+="[^"]*"/gi,"").replace(/on\w+='[^']*'/gi,"")}}):C()}),e?.fields&&e.fields.length>0&&(0,r.jsxs)("div",{className:"border-t border-border/40 bg-card",children:[(0,r.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,r.jsx)(eH.A,{className:"size-3"}),"Detected Fields (",e.fields.length,")"]}),(0,r.jsx)("div",{className:"max-h-50 overflow-y-auto px-4 pb-3 space-y-2 [&::-webkit-scrollbar]:hidden",children:e.fields.map(e=>(0,r.jsx)(sb,{field:e,isFilling:c.has(e.id),isUpdated:u.has(e.id),onEdit:t=>{h([{fieldId:e.id,value:t,type:"fill"}])}},e.id))})]})]});case"pptx":return e?.pages?.length?(0,r.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"flex-1 overflow-auto p-6 bg-muted/30",children:(0,r.jsx)(sp.N,{mode:"wait",children:(0,r.jsxs)(tl.P.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:"mx-auto max-w-2xl rounded-xl border border-border bg-white dark:bg-card p-8 35",style:{aspectRatio:"16/9",transform:`scale(${j/100})`,transformOrigin:"top center"},children:[(0,r.jsxs)("div",{className:"text-sm text-muted-foreground mb-2",children:["Slide ",g+1," of ",k]}),(0,r.jsx)("div",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground",children:S?.text||"Empty slide"})]},g)})}),k>1&&(0,r.jsx)("div",{className:"border-t border-border/40 bg-card px-4 py-2",children:(0,r.jsx)("div",{className:"flex gap-2 overflow-x-auto [&::-webkit-scrollbar]:hidden",children:e.pages.map((e,t)=>(0,r.jsxs)("button",{type:"button",onClick:()=>b(t),className:(0,D.cn)("shrink-0 rounded-lg border px-3 py-1.5 text-[10px] transition",t===g?"border-primary bg-primary/5 text-primary font-medium":"border-border text-muted-foreground hover:bg-muted"),children:["Slide ",t+1]},t))})})]}):C();case"txt":let n;return n=S?.text||e?.rawText||"",(0,r.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4 bg-card",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap text-sm leading-relaxed text-foreground font-mono",style:{transform:`scale(${j/100})`,transformOrigin:"top left"},children:n})}),e?.fields&&e.fields.length>0&&(0,r.jsxs)("div",{className:"border-t border-border/40 bg-card",children:[(0,r.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,r.jsx)(eH.A,{className:"size-3"}),"Detected Fields (",e.fields.length,")"]}),(0,r.jsx)("div",{className:"max-h-50 overflow-y-auto px-4 pb-3 space-y-2 [&::-webkit-scrollbar]:hidden",children:e.fields.map(e=>(0,r.jsx)(sb,{field:e,isFilling:c.has(e.id),isUpdated:u.has(e.id),onEdit:t=>{h([{fieldId:e.id,value:t,type:"fill"}])}},e.id))})]})]});default:return C()}})()})]})}function sv({children:e}){let{isCanvasOpen:t,parsedDocument:s}=ta(),[a,i]=(0,n.useState)(50),l=(0,n.useRef)(null),o=(0,n.useRef)(!1),d=(0,n.useCallback)(e=>{e.preventDefault(),o.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let t=e=>{if(!o.current||!l.current)return;let t=l.current.getBoundingClientRect();i(Math.max(25,Math.min(75,(e.clientX-t.left)/t.width*100)))},s=()=>{o.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",s)},[]);return(0,r.jsxs)("div",{ref:l,className:"flex h-full w-full overflow-hidden",children:[(0,r.jsx)(tl.P.div,{initial:{width:"100%"},animate:{width:t?`${a}%`:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"flex h-full min-w-0 flex-col overflow-hidden",children:e}),t&&(0,r.jsx)("div",{role:"separator","aria-orientation":"vertical",onMouseDown:d,className:(0,D.cn)("relative z-10 flex w-0.75 shrink-0 cursor-col-resize items-center justify-center","bg-border/40 transition-colors hover:bg-primary/30 active:bg-primary/50","group"),children:(0,r.jsx)("div",{className:"absolute h-8 w-1 rounded-full bg-border group-hover:bg-primary/40 transition-colors"})}),(0,r.jsx)(sp.N,{mode:"wait",children:t&&(0,r.jsx)(tl.P.div,{initial:{width:0,opacity:0,scale:.95},animate:{width:`${100-a}%`,opacity:1,scale:1},exit:{width:0,opacity:0,scale:.95},transition:{type:"spring",stiffness:300,damping:30},className:"flex h-full min-w-0 flex-col overflow-hidden origin-top-left",children:(0,r.jsx)(sj,{})},"canvas-panel")})]})}let sy=["application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain"];function sN({onFileSelected:e,className:t,id:s}){let a=(0,n.useRef)(null),{openCanvas:i,isLoading:l}=ta(),o=(0,n.useCallback)(async t=>{let s=t.target.files?.[0];if(!s)return;let r=s.name.substring(s.name.lastIndexOf(".")).toLowerCase();(sy.includes(s.type)||[".pdf",".docx",".pptx",".txt"].includes(r))&&(await i(s),e?.(s),a.current&&(a.current.value=""))},[i,e]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{id:s,ref:a,type:"file",accept:".pdf,.docx,.pptx,.txt",onChange:o,className:"hidden","aria-label":"Attach document"}),(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)("button",{type:"button",onClick:()=>a.current?.click(),disabled:l,className:(0,D.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition","hover:bg-secondary hover:text-foreground","disabled:opacity-40 disabled:cursor-not-allowed",t),children:(0,r.jsx)(c.A,{className:"size-4.5"})})}),(0,r.jsx)(F.ZI,{children:"Attach document (PDF, Word, PPT, TXT)"})]})]})}var sw=s(83093),sk=s(88784);let sS=async e=>{let t=await (0,a.St)(e),s=await t.json().catch(()=>null);if(!t.ok)throw Error(s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:"Could not load chat configuration.");return s};function sC({file:e,onClick:t,onRemove:s}){let a,n,i=(a=e.name.split(".").pop()?.toLowerCase(),n=e.type,["csv","xls","xlsx"].includes(a||"")?"/icons/excel.png":["doc","docx"].includes(a||"")?"/icons/word.png":["md","markdown"].includes(a||"")?"/icons/markdown.png":["pdf"].includes(a||"")?"/icons/pdf.png":n.startsWith("video/")?"/icons/video.png":n.startsWith("audio/")?"/icons/audio.png":(n.startsWith("image/"),"/icons/image.png"));return(0,r.jsxs)("div",{className:"relative mt-2 group flex items-center gap-2 bg-muted/50 border border-border/60 rounded-xl h-12 px-3 p-1 shrink-0 cursor-pointer hover:bg-muted/80 transition-colors",onClick:t,children:[(0,r.jsx)("div",{className:"size-7 shrink-0 rounded-md overflow-hidden bg-background border border-border/90 flex items-center justify-center p-1",children:(0,r.jsx)("img",{src:i,alt:e.name,className:"w-full h-full object-contain"})}),(0,r.jsxs)("div",{className:"flex flex-col justify-center max-w-30",children:[(0,r.jsx)("span",{className:"text-xs font-medium truncate text-foreground",children:e.name}),(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[(e.size/1024).toFixed(0)," KB"]})]}),(0,r.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),s()},className:"absolute cursor-pointer -top-3 -right-2 flex h-5 w-5 items-center justify-center rounded-full bg-background border border-border text-muted-foreground hover:bg-destructive hover:border-destructive hover:text-white transition opacity-0 group-hover:opacity-100",children:(0,r.jsx)(d.A,{className:"size-3"})})]})}function sA({chatId:e}={}){return(0,r.jsx)(tn,{children:(0,r.jsx)(sv,{children:(0,r.jsx)(s$,{chatId:e})})})}function s$({chatId:e}){let t,s,{activeProject:A}=(0,t6.By)(),{sessionId:$,parsedDocument:z,openCanvas:I,isLoading:T}=ta(),L={sessionId:$,fields:z?.fields||[]},M=A?.id??null,R=(0,n.useRef)(0),[E,P]=(0,n.useState)(!1),O=M?(0,a.fO)(`/api/chat/status?projectId=${encodeURIComponent(M)}`):(0,a.fO)("/api/chat/status"),{data:_,error:U,isLoading:B}=(0,k.u)(O,sS,{refreshInterval:1e4}),{data:W,mutate:K}=(0,k.u)((0,a.fO)("/api/config"),sS),V=(0,sd.useRouter)(),{selectedModel:q,setSelectedModel:J}=sm(),[Z,H]=(0,n.useState)(!1),[G,X]=(0,n.useState)(""),[Y,Q]=(0,n.useState)(""),[ee,et]=(0,n.useState)([]),[es,er]=(0,n.useState)(null),[ea,en]=(0,n.useState)([]),ei=(0,n.useRef)(null),el=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=el.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)},[Y]);let[eo,ed]=(0,n.useState)(e||""),[ec,eu]=(0,n.useState)([]),[em,ex]=(0,n.useState)(!1),[ep,eh]=(0,n.useState)(""),[ef,eg]=(0,n.useState)(!!e);(0,n.useEffect)(()=>{sn("chat_sessions").then(e=>{e&&eu(e)})},[]),(0,n.useEffect)(()=>{if(!_?.chatModelId)return;let e=_.availableModels?.some(e=>e.id===q);q&&e||J(_.chatModelId)},[_?.chatModelId,_?.availableModels,q,J]),(0,n.useEffect)(()=>{Z?requestAnimationFrame(()=>ei.current?.focus()):X("")},[Z]);let eb=(0,n.useMemo)(()=>({projectId:M,chatModelId:q||void 0,docSessionId:L.sessionId,docFields:L.fields}),[M,q,L.sessionId,JSON.stringify(L.fields)]),ej=(0,n.useRef)(eb);(0,n.useEffect)(()=>{ej.current=eb},[eb]);let ev=(0,n.useMemo)(()=>new l.rLN({api:(0,a.fO)("/api/chat"),headers:{"Content-Type":"application/json"},prepareSendMessagesRequest:({messages:e,id:t,body:s})=>({body:{messages:e.map((t,s)=>{if(s===e.length-1)return t;let{toolInvocations:r,experimental_attachments:a,parts:n,...i}=t,l=Array.isArray(r)?r.map(e=>"result"===e.state&&e.result?{...e,result:o(e.result)}:e):r,d=Array.isArray(n)?n.map(e=>{if("tool-invocation"===e.type){let t=e.toolInvocation;if(t?.state==="result"&&t.result)return{...e,toolInvocation:{...t,result:o(t.result)}}}return e.type?.startsWith("tool-")?{...e,...void 0!==e.output?{output:o(e.output)}:{},...void 0!==e.result?{result:o(e.result)}:{}}:e}):n,c=Array.isArray(a)?a.map(e=>({name:e?.name,contentType:e?.contentType,size:e?.size})):a;return{...i,...d?{parts:d}:{},...l?{toolInvocations:l}:{},...c?{experimental_attachments:c}:{}}}),id:t,...ej.current,...s}})}),[]),{messages:ey,sendMessage:eN,status:ew,setMessages:ek,error:eS,regenerate:eC,addToolResult:eA}=(0,i.Y_)({transport:ev});(0,n.useEffect)(()=>{en([]),e?(eg(!0),sn(`chat_messages_${e}`).then(t=>{t&&(ek(t),ed(e)),eg(!1)})):eg(!1)},[e,ek]),(0,n.useEffect)(()=>{es&&L.sessionId&&!T&&(eN(es),er(null))},[es,L.sessionId,T,eN]),(0,n.useEffect)(()=>{if(!L.sessionId&&I&&ey.length>0&&!T){let e=ey[ey.length-1];if("assistant"===e.role&&e.toolInvocations&&e.toolInvocations.some(e=>["requestDocumentSignature","fillDocumentForm","editDocument"].includes(e.toolName))){let e=null;for(let t=ey.length-1;t>=0;t--){let s=ey[t];if(s.experimental_attachments){let t=s.experimental_attachments.filter(e=>e.contentType?.includes("pdf")||e.name?.toLowerCase().endsWith(".pdf"));if(t.length>0){e=t[t.length-1];break}}}if(e&&e.url){let t=e.url;t.startsWith("http")||t.startsWith("data:")||(t=`data:${e.contentType||"application/pdf"};base64,${t}`),(0,a.St)(t).then(e=>e.blob()).then(t=>{I(new File([t],e.name||"document.pdf",{type:e.contentType||"application/pdf"}),{background:!1})}).catch(e=>console.error("Auto-open failed",e))}}}},[ey,L.sessionId,I,T]),(0,n.useEffect)(()=>{ek([]),ed(""),en([])},[M,ek]);let e$=(0,n.useRef)(null),ez=(0,n.useRef)(!0),eI="submitted"===ew||"streaming"===ew;(0,n.useEffect)(()=>{if(0===ea.length||eI||T||es)return;let[e,...t]=ea;en(t),ez.current=!0;let s=new DataTransfer;(e.files??[]).forEach(e=>s.items.add(e)),eN({text:e.text,files:s.files.length>0?s.files:void 0})},[ea,eI,T,es,eN]);let eT=(0,n.useCallback)(()=>{let e=e$.current;e&&(ez.current=e.scrollHeight-e.scrollTop-e.clientHeight<80)},[]);(0,n.useEffect)(()=>{let e=e$.current;if(!e||!ez.current)return;let t=requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight,behavior:"streaming"===ew?"auto":"smooth"})});return()=>cancelAnimationFrame(t)},[ey,ew]);let eL=(0,n.useRef)(null),eF=(0,n.useRef)(ey);eF.current=ey;let eD=(0,n.useRef)({}),eM=(0,n.useCallback)((e,t)=>{let s=eF.current,r=s.find(t=>t.id===e),n=r?tH(r):void 0,i=function(e,t){let s=e.findIndex(e=>e.id===t&&"assistant"===e.role);if(s<0)return;let r=e[s],a=tX(r);if(!a)return;let n=s-1;for(;n>=0&&"user"!==e[n].role;)n-=1;if(n<0)return;let i=tX(e[n]);if(!i)return;let l=function(e){let t=tZ(e.metadata).groundedAnswerCache;if(!t||"object"!=typeof t||Array.isArray(t))return;let s=t.sourceScopeFingerprint;return"string"==typeof s&&s?s:void 0}(r),o=[...(Array.isArray(r.parts)?r.parts:[]).flatMap(e=>e?.type==="tool-invocation"?[{name:e.toolInvocation?.toolName,output:e.toolInvocation?.result}]:"string"==typeof e?.type&&e.type.startsWith("tool-")?[{name:e.type.slice(5),output:e.output??e.result}]:e?.type==="dynamic-tool"?[{name:e.toolName,output:e.output??e.result}]:[]),...(Array.isArray(r.toolInvocations)?r.toolInvocations:[]).map(e=>({name:e?.toolName,output:e?.result}))];if(o.some(e=>e.name&&"searchKnowledgeBase"!==e.name))return;if(l&&0===o.length)return{question:i,answer:a,sourceScopeFingerprint:l};let d=o.filter(e=>"searchKnowledgeBase"===e.name).map(e=>(function e(t){if("string"==typeof t)try{return e(JSON.parse(t))}catch{return t}return t&&"object"==typeof t&&"json"===t.type&&"value"in t?e(t.value):t})(e.output)).find(e=>Array.isArray(e?.hits)&&e.hits.length>0);if(d&&!d.videoEvidence&&!d.hits.some(e=>e?.mediaAssetId||e?.metadata?.mediaAssetId))return{question:i,answer:a,..."string"==typeof d.sourceScopeFingerprint?{sourceScopeFingerprint:d.sourceScopeFingerprint}:{}}}(s,e),l=tG(s,e,t);eF.current=l,ek(l);let o=eo||crypto.randomUUID();if(eo||(ed(o),"/chat"===window.location.pathname&&window.history.replaceState(null,"",`/chat/${o}`)),si(`chat_messages_${o}`,l).catch(e=>{console.error("Failed to save answer feedback",e),tc.oR.error("Could not save this feedback. Please try again.")}),!i){"liked"===t&&tc.oR.success("Feedback saved. This answer type will use fresh tool results when repeated.");return}let d=(eD.current[e]??0)+1;eD.current[e]=d,(0,a.St)((0,a.fO)("/api/chat/feedback"),{method:"POST",headers:{"Content-Type":"application/json"},keepalive:!0,body:JSON.stringify({projectId:M,feedback:t,...i})}).then(async e=>{let s=await e.json().catch(()=>null);if(!e.ok)throw Error(s?.error||"Could not update the answer cache.");"liked"===t&&s?.cached?tc.oR.success("Answer saved to Larkup cache"):"disliked"===t&&s?.removed&&tc.oR.success("Cached answer removed"),(0,S.k)((0,a.fO)("/api/system/cache"))}).catch(t=>{if(eD.current[e]!==d)return;let s=tG(eF.current,e,n);eF.current=s,ek(s),si(`chat_messages_${o}`,s),tc.oR.error(t instanceof Error?t.message:"Could not update the answer cache.")})},[eo,M,ek]);(0,n.useEffect)(()=>{if(0!==ey.length&&"streaming"!==ew&&"submitted"!==ew)return eL.current&&clearTimeout(eL.current),eL.current=setTimeout(()=>{let e=eF.current;if(0===e.length)return;let t=eo;t||ed(t=crypto.randomUUID()),si(`chat_messages_${t}`,e),"/chat"===window.location.pathname&&window.history.replaceState(null,"",`/chat/${t}`),eu(s=>{let r,a=s.find(e=>e.id===t),n=e[0],i=n?.parts?.filter(e=>"text"===e.type)?.map(e=>e.text)?.join("")||n?.content||n?.text,l=i?i.substring(0,40):"New Chat";return a&&a.title===l?s:(si("chat_sessions",r=a?s.map(e=>e.id===t?{...e,title:l,updatedAt:Date.now()}:e):[{id:t,title:l,updatedAt:Date.now()},...s]),r)})},500),()=>{eL.current&&clearTimeout(eL.current)}},[ey,eo,ew]);let eR=(0,n.useMemo)(()=>{let e=_?.availableModels??[],t=G.toLowerCase().trim(),s=t?e.filter(e=>e.label.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)):e,r=new Map;for(let e of s){let t=r.get(e.provider)??[];t.push(e),r.set(e.provider,t)}return r},[_?.availableModels,G]),eE=(0,n.useMemo)(()=>{let e=[...ec].sort((e,t)=>t.updatedAt-e.updatedAt),t=ep.toLowerCase().trim();return t?e.filter(e=>e.title.toLowerCase().includes(t)):e},[ec,ep]);function eP(e,t){en(s=>{let r=s.findIndex(t=>t.id===e),a=r+t;if(-1===r||a<0||a>=s.length)return s;let n=[...s];return[n[r],n[a]]=[n[a],n[r]],n})}function eO(e){e&&e.preventDefault();let t=Y.trim();if(!t&&0===ee.length)return;if(eI||T){en(e=>[...e,{id:crypto.randomUUID(),text:t,files:ee.length>0?ee:void 0}]),Q(""),et([]);return}ez.current=!0;let s=new DataTransfer;ee.forEach(e=>s.items.add(e));let r=s.files.length>0?s.files:void 0;if(r){let e=Array.from(r).find(e=>"application/pdf"===e.type||e.name.toLowerCase().endsWith(".pdf")||e.name.toLowerCase().endsWith(".doc")||e.name.toLowerCase().endsWith(".docx"));if(e&&!L.sessionId){tc.oR.info("Preparing document..."),er({text:t,files:r}),I(e,{background:!1}).catch(e=>{tc.oR.error(e.message||"Failed to open document"),er(null),eN({text:t,files:r})}),Q(""),et([]);return}eN({text:t,files:r})}else{let e=null;if(!L.sessionId)for(let t=ey.length-1;t>=0;t--){let s=ey[t];if(s.experimental_attachments){let t=s.experimental_attachments.filter(e=>e.contentType?.includes("pdf")||e.name?.toLowerCase().endsWith(".pdf")||e.name?.toLowerCase().endsWith(".doc")||e.name?.toLowerCase().endsWith(".docx"));if(t.length>0){e=t[t.length-1];break}}}if(e){tc.oR.info("Preparing document...");let s=e.url;s.startsWith("http")||s.startsWith("data:")||(s=`data:${e.contentType||"application/pdf"};base64,${s}`),er({text:t}),(0,a.St)(s).then(e=>e.blob()).then(s=>{I(new File([s],e.name||"document.pdf",{type:e.contentType||"application/pdf"}),{background:!1}).catch(e=>{tc.oR.error(e.message||"Failed to open document"),er(null),eN({text:t})})}).catch(e=>{console.error("Auto-open failed",e),er(null),eN({text:t})}),Q(""),et([]);return}eN({text:t})}Q(""),et([])}function e_(){ek([]),Q(""),en([]),ed(crypto.randomUUID()),window.history.pushState(null,"","/chat")}async function eU(){let e=W?.config;if(!e)return;let t=e.webSearchProvider||"tavily",s={tavily:e.tavilyApiKey,serper:e.serperApiKey,google:e.serperApiKey,brave:e.braveApiKey,bing:e.bingApiKey,exa:e.exaApiKey};if("local"!==t&&!s[t]){tc.oR.error("Web Search API key is missing. Please configure it in Settings."),V.push("/settings?section=search-web");return}let r=!e.webSearchEnabled;try{await (0,a.St)((0,a.fO)("/api/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,webSearchEnabled:r})}),await K(),tc.oR.success(`Web Search ${r?"enabled":"disabled"}`)}catch(e){tc.oR.error(e.message||"Failed to update web search setting")}}async function eB(e){let t=await sn(`chat_messages_${e}`);t&&(ek(t),ed(e),ex(!1),window.history.pushState(null,"",`/chat/${e}`))}async function eW(e){await sl(`chat_messages_${e}`),eu(t=>{let s=t.filter(t=>t.id!==e);return si("chat_sessions",s),s}),eo===e&&(ek([]),Q(""),ed(""),window.history.pushState(null,"","/chat"))}async function eK(){try{let e=(await so()).filter(e=>"string"==typeof e&&("chat_sessions"===e||e.startsWith("chat_messages_")));await Promise.all(e.map(e=>sl(e))),eu([]),eh(""),ek([]),en([]),ed(""),window.history.pushState(null,"","/chat"),tc.oR.success("Chat history cleared")}catch(e){console.error("Failed to clear chat history",e),tc.oR.error("Could not clear chat history. Please try again.")}}(0,n.useEffect)(()=>{let e=()=>e_();return window.addEventListener("new-chat",e),()=>window.removeEventListener("new-chat",e)},[]);let eV=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R.current++,e.dataTransfer.items&&e.dataTransfer.items.length>0&&Array.from(e.dataTransfer.items).some(e=>"file"===e.kind)&&P(!0)},[]),eq=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R.current--,0===R.current&&P(!1)},[]),eJ=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),eZ=(0,n.useCallback)(async e=>{e.preventDefault(),e.stopPropagation(),P(!1),R.current=0;let t=e.dataTransfer.files;if(!t||0===t.length)return;let s=Array.from(t);if(0===s.length)return void tc.oR.error("No valid files dropped.");et(e=>[...e,...s]);let r=s.find(e=>"application/pdf"===e.type||e.name.toLowerCase().endsWith(".pdf"));r&&I(r,{background:!1}).catch(e=>{tc.oR.error(e.message||"Failed to auto-open document")})},[I]),eH=0===ey.length&&!ef,eG=_?.ready??!1,eX=_?.availableModels?.find(e=>e.id===q);return(0,r.jsxs)("div",{className:(0,D.cn)("flex h-full w-full flex-1 flex-col overflow-hidden relative",E&&"bg-primary/5"),onDragEnter:eV,onDragLeave:eq,onDragOver:eJ,onDrop:eZ,children:[E&&(0,r.jsxs)("div",{className:"absolute inset-0 z-100 flex flex-col items-center justify-center bg-background/80 backdrop-blur-sm border-2 border-dashed border-primary/50 m-4 rounded-3xl pointer-events-none",children:[(0,r.jsx)("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-primary/10 text-primary mb-4",children:(0,r.jsx)(c.A,{className:"size-10"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold tracking-tight text-foreground",children:"Drop document to attach"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"PDF, Word, PPT, TXT"})]}),(0,r.jsxs)("div",{className:"relative z-40 flex items-center justify-between px-4 py-2",children:[(0,r.jsx)("div",{className:"flex items-center gap-3"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[_?.availableModels&&_.availableModels.length>0&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>H(e=>!e),className:"flex w-75 justify-between items-center gap-1.5 rounded-lg border border-border bg-white dark:bg-card px-3 py-1.5 text-xs text-foreground transition hover:bg-muted",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 truncate",children:[eX&&(0,r.jsx)(sr.rb,{src:(0,sr.D_)(eX.provider).iconSrc,alt:eX.provider,pillBg:(0,sr.D_)(eX.provider).pillBg,size:16}),(0,r.jsx)("span",{className:"truncate",children:eX?.label||q||"Select model"})]}),(0,r.jsx)(u.A,{className:(0,D.cn)("size-3 shrink-0 text-muted-foreground transition-transform",Z&&"rotate-180")})]}),Z&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>H(!1)}),(0,r.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1 w-75 rounded-lg border border-border bg-card ",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[(0,r.jsx)(m.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("input",{ref:ei,type:"text",value:G,onChange:e=>X(e.target.value),placeholder:"Search models...",className:"flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground"}),G&&(0,r.jsx)("button",{type:"button",onClick:()=>X(""),className:"text-muted-foreground hover:text-foreground",children:(0,r.jsx)(d.A,{className:"size-3"})})]}),(0,r.jsx)("div",{className:"max-h-72 overflow-y-auto p-1 [&::-webkit-scrollbar]:hidden",children:0===eR.size?(0,r.jsx)("div",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:"No models found"}):Array.from(eR.entries()).map(([e,t])=>{let s=(0,sr.D_)(e);return(0,r.jsxs)("div",{className:"mb-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs font-semibold uppercase tracking-wider text-foreground/70",children:[s.label,(0,r.jsxs)("span",{className:"text-[10px] text-muted-foreground/50",children:["(",t.length,")"]})]}),t.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>{J(e.id),H(!1)},className:(0,D.cn)("flex w-full items-center justify-between rounded-md px-3 py-1.5 text-left text-xs transition",e.id===q?"bg-primary/10 text-primary font-medium":"text-foreground hover:bg-muted"),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 truncate",children:[(0,r.jsx)(sr.rb,{src:s.iconSrc,alt:s.label,pillBg:s.pillBg,size:14}),(0,r.jsx)("span",{className:"truncate",children:e.label})]}),(0,r.jsx)("span",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:e.context_window&&(0,r.jsx)("span",{className:"text-[9px] font-mono text-muted-foreground/60",children:e.context_window>=1e6?`${(e.context_window/1e6).toFixed(0)}M`:`${(e.context_window/1e3).toFixed(0)}K`})})]},e.id))]},e)})})]})]})]}),(0,r.jsx)("div",{className:"h-4 w-px bg-border mx-1"}),(0,r.jsxs)(F.Bc,{delay:50,children:[(0,r.jsxs)(t9.cj,{open:em,onOpenChange:e=>{ex(e),e||eh("")},children:[(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)(t9.CG,{render:(0,r.jsx)("button",{type:"button","aria-label":"Chat history",className:"flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-secondary hover:text-foreground",children:(0,r.jsx)(x.A,{className:"h-4 w-4"})})})}),(0,r.jsx)(F.ZI,{children:"Chat History"})]}),(0,r.jsxs)(t9.h,{side:"left",showCloseButton:!1,className:"w-75 sm:w-87.5 p-0 flex flex-col",children:[(0,r.jsxs)(t9.Fm,{className:"p-4 pb-3 border-b",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)(t9.qp,{className:"text-sm font-semibold",children:"Chat History"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)(sx.Lt,{children:[(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)(sx.tv,{render:(0,r.jsx)("button",{type:"button","aria-label":"Clear chat history",disabled:0===ec.length,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive disabled:pointer-events-none disabled:opacity-40",children:(0,r.jsx)(p.A,{className:"size-3.5"})})})}),(0,r.jsx)(F.ZI,{children:"Clear all chat history"})]}),(0,r.jsxs)(sx.EO,{children:[(0,r.jsxs)(sx.wd,{children:[(0,r.jsx)(sx.r7,{children:"Delete all chat history?"}),(0,r.jsx)(sx.$v,{children:"This will permanently delete all saved chats on this device. This action cannot be undone."})]}),(0,r.jsxs)(sx.ck,{children:[(0,r.jsx)(sx.Zr,{children:"Cancel"}),(0,r.jsx)(sx.Rx,{onClick:()=>void eK(),className:"bg-destructive text-white hover:bg-destructive/90",children:"Delete all"})]})]})]}),(0,r.jsx)(t9.kN,{render:(0,r.jsx)("button",{type:"button","aria-label":"Close chat history",className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-secondary hover:text-foreground",children:(0,r.jsx)(d.A,{className:"size-3.5"})})})]})]}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-2 rounded-lg border border-border bg-muted/50 px-2.5 py-1.5",children:[(0,r.jsx)(m.A,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("input",{type:"text",value:ep,onChange:e=>eh(e.target.value),placeholder:"Search chats...",className:"flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground"}),ep&&(0,r.jsx)("button",{type:"button",onClick:()=>eh(""),className:"text-muted-foreground hover:text-foreground",children:(0,r.jsx)(d.A,{className:"size-3"})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-2",children:0===ec.length?(0,r.jsx)("div",{className:"p-4 text-center text-xs text-muted-foreground",children:"No chat history"}):0===eE.length?(0,r.jsxs)("div",{className:"p-4 text-center text-xs text-muted-foreground",children:['No chats match "',ep,'"']}):eE.map(e=>(0,r.jsxs)("div",{onClick:()=>eB(e.id),className:(0,D.cn)("group flex items-center justify-between rounded-md px-3 py-2 text-sm cursor-pointer transition hover:bg-muted mb-1",eo===e.id&&"bg-muted font-medium"),children:[(0,r.jsx)("div",{className:"truncate pr-4 flex-1 text-xs",children:e.title}),(0,r.jsxs)(sx.Lt,{children:[(0,r.jsx)(sx.tv,{render:(0,r.jsx)("button",{onClick:e=>e.stopPropagation(),className:"text-muted-foreground opacity-0 transition group-hover:opacity-100 hover:text-destructive",children:(0,r.jsx)(p.A,{className:"size-3.5"})})}),(0,r.jsxs)(sx.EO,{onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)(sx.wd,{children:[(0,r.jsx)(sx.r7,{children:"Delete Chat"}),(0,r.jsx)(sx.$v,{children:"Are you sure you want to delete this chat? This action cannot be undone."})]}),(0,r.jsxs)(sx.ck,{children:[(0,r.jsx)(sx.Zr,{children:"Cancel"}),(0,r.jsx)(sx.Rx,{onClick:()=>eW(e.id),className:"bg-destructive text-white hover:bg-destructive/90",children:"Delete"})]})]})]})]},e.id))})]})]}),(0,r.jsxs)(F.m_,{children:[(0,r.jsx)(F.k$,{render:(0,r.jsx)("button",{type:"button",onClick:e_,className:"flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-secondary hover:text-foreground",children:(0,r.jsx)(h.A,{className:"h-4 w-4"})})}),(0,r.jsx)(F.ZI,{children:"New Chat"})]}),(0,r.jsx)(ss,{})]})]})]}),(0,r.jsx)(C.P3,{viewportRef:e$,onScroll:eT,children:eG?eH?(0,r.jsx)(C.Vu,{mark:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("img",{src:"/logo.png",alt:"Logo",className:"size-9 dark:hidden"}),(0,r.jsx)("img",{src:"/logo-light.png",alt:"Logo",className:"size-9 dark:block hidden"})]})}):(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[ey.map((e,t)=>(0,r.jsx)(tY,{message:e,isLast:t===ey.length-1,isStreaming:"streaming"===ew,addToolResult:eA,serverId:M,autoOpenSupportingClip:ey[t]?.role==="assistant"&&t===ey.findIndex(e=>"assistant"===e.role),regenerate:eC,isBusy:eI,onFeedback:eM},e.id)),"submitted"===ew||ef?(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)("div",{className:"size-7 bg-white border border-border rounded-full flex items-center justify-center p-1 animate-pulse",children:(0,r.jsx)("img",{src:"/logo.png",alt:"logo",className:"size-4 animate-spin"})})}):null,eS?(s=t=eS.message||"Something went wrong while generating a response.",t.includes("rate-limited")||t.includes("rate_limit")||t.includes("429")?s="Vercel AI Gateway could not serve this model because it is rate-limited. We tried compatible backups. Try again shortly, choose another model, or add AI Gateway credits / a provider key in Settings.":t.includes("unavailable tool")||t.includes("NoSuchTool")?s="The model tried an unavailable action. Please try your question again.":(t.length>200||t.includes("http://")||t.includes("https://"))&&(s="Something went wrong while generating a response. Please try again."),(0,r.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-destructive/30 bg-destructive/5 px-4 py-3",children:[(0,r.jsx)(b.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:s}),(0,r.jsxs)("button",{type:"button",onClick:()=>eC(),className:"mt-2 inline-flex items-center gap-1.5 rounded-lg border border-border bg-card px-2.5 py-1.5 text-xs font-medium text-foreground transition hover:bg-secondary",children:[(0,r.jsx)(j.A,{className:"h-3.5 w-3.5"}),"Try again"]})]})]})):null]}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 pt-[18vh] text-center",children:[(0,r.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl bg-white border text-muted-foreground",children:B?(0,r.jsx)(f.A,{className:"size-6 animate-spin"}):(0,r.jsx)(g.A,{className:"size-7"})}),(0,r.jsx)("h1",{className:"text-xl font-semibold tracking-tight text-foreground",children:B?"Preparing your workspace":U?"Chat temporarily unavailable":"Setup Required"}),(0,r.jsx)("p",{className:"max-w-md text-sm leading-relaxed text-muted-foreground mb-2",children:B?"Loading your chat configuration and available models…":U?"Chat services are temporarily unavailable. Larkup will retry automatically.":_?.blockers?.join(" ")||"Connect a chat model in Settings to start chatting."}),!B&&!U&&(0,r.jsx)("a",{href:_?.blockers?.some(e=>e.includes("API Key")||e.includes("Settings"))?"/settings/models":"/settings",className:"inline-flex h-9 items-center justify-center rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",children:"Go to Settings"})]})}),eG&&(0,r.jsxs)("div",{className:"relative z-10 mt-auto px-4 pb-5 pt-3 sm:px-6",children:[ea.length>0&&(0,r.jsx)(t2,{items:ea,onRemove:function(e){en(t=>t.filter(t=>t.id!==e))},onMoveUp:e=>eP(e,-1),onMoveDown:e=>eP(e,1),onEdit:function(e){let t=ea.find(t=>t.id===e);t&&(en(t=>t.filter(t=>t.id!==e)),Q(t.text),et(t.files??[]),requestAnimationFrame(()=>el.current?.focus()))}}),(0,r.jsx)("form",{onSubmit:eO,className:"mx-auto w-full max-w-3xl",children:(0,r.jsxs)(C.sZ,{children:[(0,r.jsxs)(sw.rI,{children:[(0,r.jsx)(sw.ty,{render:(0,r.jsx)("button",{type:"button",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition hover:bg-secondary hover:text-foreground mt-1",children:(0,r.jsx)(v.A,{className:"h-4.5 w-4.5"})})}),(0,r.jsxs)(sw.SQ,{side:"top",align:"start",className:"w-56 gap-1 flex flex-col",sideOffset:8,children:[(0,r.jsxs)(sw._2,{onClick:e=>{e.preventDefault();let t=document.createElement("input");t.type="file",t.multiple=!0,t.accept="*/*",t.onchange=async e=>{let t=e.target.files;if(!t||0===t.length)return;let s=Array.from(t);et(e=>[...e,...s]);let r=s.find(e=>"application/pdf"===e.type||e.name.toLowerCase().endsWith(".pdf"));r&&I(r,{background:!1}).catch(e=>{tc.oR.error(e.message||"Failed to auto-open document")})},t.click()},className:"gap-2 cursor-pointer",children:[(0,r.jsx)(c.A,{className:"size-4"}),(0,r.jsx)("span",{children:"Attach Document"})]}),(0,r.jsxs)(sw._2,{onClick:e=>{e.preventDefault(),eU()},className:"gap-2 justify-between cursor-pointer",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(y.A,{className:"size-4"}),(0,r.jsx)("span",{children:"Web Search"})]}),(0,r.jsx)(sk.d,{checked:W?.config?.webSearchEnabled||!1,className:"pointer-events-none"})]})]})]}),(0,r.jsx)("div",{className:"hidden",children:(0,r.jsx)(sN,{id:"chat-file-attachment"})}),(0,r.jsxs)("div",{className:"flex flex-col flex-1 gap-2",children:[ee.length>0&&(0,r.jsx)("div",{className:"flex w-full overflow-x-auto items-center gap-2 px-1 pt-1 pb-2 [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-border/60",children:ee.map((e,t)=>(0,r.jsx)(sC,{file:e,onClick:()=>{I(e,{background:!1}).catch(e=>{tc.oR.error(e.message||"Failed to open document")})},onRemove:()=>{et(e=>e.filter((e,s)=>s!==t))}},`${e.name}-${t}`))}),(0,r.jsx)("textarea",{ref:el,value:Y,onChange:e=>Q(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eO(e))},onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let s=[];for(let e=0;e<t.length;e++)if("file"===t[e].kind){let r=t[e].getAsFile();r&&s.push(r)}if(s.length>0){et(e=>[...e,...s]);let e=s.find(e=>"application/pdf"===e.type||e.name.toLowerCase().endsWith(".pdf"));e&&I(e,{background:!1}).catch(e=>{tc.oR.error(e.message||"Failed to auto-open pasted document")})}},rows:1,disabled:!eG,placeholder:"How can I help you…",className:"max-h-48 min-h-11 w-full resize-none overflow-y-auto bg-transparent px-2 py-2.5 text-[15px] leading-relaxed text-foreground outline-none placeholder:text-muted-foreground scrollbar-none [&::-webkit-scrollbar]:hidden disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"submit",disabled:!Y.trim()&&0===ee.length,title:eI||T?"Add to queue":"Send",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary text-primary-foreground transition hover:opacity-90 disabled:opacity-40",children:eI||T?(0,r.jsx)(N.A,{className:"h-4.5 w-4.5"}):(0,r.jsx)(w.A,{className:"h-4.5 w-4.5"})})]})})]})]})}},27722:(e,t,s)=>{"use strict";s.d(t,{BT:()=>r.BT,Wu:()=>r.Wu,ZB:()=>r.ZB,Zp:()=>r.Zp,aR:()=>r.aR,wL:()=>r.wL});var r=s(31337)},43047:(e,t,s)=>{"use strict";s.d(t,{Ag:()=>c,d3:()=>x,zf:()=>m});var r=s(35911),a=s(49711),n=s(47900),i=s(72232),l=s(37e3),o=s(52542),d=s(9439);let c={searchKnowledgeBase:{placement:"source",resultView:"none"},queryVideoKnowledge:{placement:"inline",pendingLabel:"Reviewing the video…",resultView:"none"},queryVideoEvidence:{placement:"inline",pendingLabel:"Reviewing indexed video context…",resultView:"data-table",compactResult:!1},inspectVideoKnowledge:{placement:"inline",pendingLabel:"Checking the relevant moment…",resultView:"none"},webSearch:{placement:"web-search",resultView:"none"},presentMedia:{placement:"media",resultView:"media"},queryTabularData:{placement:"inline",pendingLabel:"Checking data…",resultView:"data-table",compactResult:!0,showProgressBar:!1},generateVisualization:{placement:"visualization",pendingLabel:"Preparing chart…",resultView:"none"},createDataExport:{placement:"inline",pendingLabel:"Preparing file…",resultView:"file-export",showProgressBar:!1},executeAnalysis:{placement:"inline",pendingLabel:"Running analysis…",resultView:"sandbox"},analyzeCorpusWithCode:{placement:"inline",pendingLabel:"Analyzing documents…",resultView:"sandbox"},getIndexedData:{placement:"inline",pendingLabel:"Checking documents…",resultView:"corpus"},analyzeImageDeeply:{placement:"inline",pendingLabel:"Analyzing image…",resultView:"image-analysis"},fillDocumentForm:{placement:"inline",pendingLabel:"Updating document…",resultView:"document-edit"},editDocument:{placement:"inline",pendingLabel:"Updating document…",resultView:"document-edit"},requestDocumentSignature:{placement:"inline",pendingLabel:"Preparing signature…",resultView:"signature"}},u={placement:"inline",pendingLabel:"Working…",resultView:"none"};function m(e){return c[e]??u}let x=[{id:"searchKnowledgeBase",name:"Semantic Search",description:"Search the RAG knowledge base for text.",icon:r.A},{id:"queryTabularData",name:"Tabular Data Query",description:"Filter, group, and aggregate tabular data.",icon:a.A},{id:"generateVisualization",name:"Generate Charts",description:"Create interactive charts from Assistant results.",icon:n.A},{id:"createDataExport",name:"Export Answer",description:"Create a downloadable Excel, CSV, or PDF file from an Assistant result.",icon:i.A},{id:"executeAnalysis",name:"Python Sandbox",description:"Execute Python code for complex analysis.",icon:l.A},{id:"getIndexedData",name:"Indexed Data",description:"List and filter source documents.",icon:o.A},{id:"analyzeCorpusWithCode",name:"Corpus Analysis",description:"Run code against the full indexed corpus.",icon:l.A},{id:"fillDocumentForm",name:"Form Filler",description:"Fill forms in the active document.",icon:d.A}]},57363:(e,t,s)=>{Promise.resolve().then(s.bind(s,12578))},87932:(e,t,s)=>{"use strict";s.d(t,{Ke:()=>d,Nt:()=>l,R6:()=>o});var r=s(58395),a=s(80846),n=s(11610),i=s(94226);function l({...e}){return(0,r.jsx)(a.N,{"data-slot":"collapsible",...e})}function o({...e}){return(0,r.jsx)(n.R,{"data-slot":"collapsible-trigger",...e})}function d({...e}){return(0,r.jsx)(i.j,{"data-slot":"collapsible-content",...e})}},96517:(e,t,s)=>{"use strict";s.d(t,{CG:()=>f,Fm:()=>y,Qs:()=>k,XW:()=>N,cj:()=>h,h:()=>v,kN:()=>g,qp:()=>w});var r=s(58395);s(27915);var a=s(12960),n=s(46282),i=s(89730),l=s(89860),o=s(89384),d=s(30403),c=s(22550),u=s(58118),m=s(53655),x=s(31813),p=s(85755);function h({...e}){return(0,r.jsx)(a.D,{"data-slot":"sheet",...e})}function f({...e}){return(0,r.jsx)(n.z,{"data-slot":"sheet-trigger",...e})}function g({...e}){return(0,r.jsx)(i.H,{"data-slot":"sheet-close",...e})}function b({...e}){return(0,r.jsx)(l.Z,{"data-slot":"sheet-portal",...e})}function j({className:e,...t}){return(0,r.jsx)(o.X,{"data-slot":"sheet-overlay",className:(0,m.cn)("fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",e),...t})}function v({className:e,children:t,side:s="right",showCloseButton:a=!0,...n}){return(0,r.jsxs)(b,{children:[(0,r.jsx)(j,{}),(0,r.jsxs)(d.h,{"data-slot":"sheet-content","data-side":s,className:(0,m.cn)("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-10 data-[side=bottom]:data-starting-style:translate-y-10 data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:-translate-x-10 data-[side=left]:data-starting-style:-translate-x-10 data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-10 data-[side=right]:data-starting-style:translate-x-10 data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:-translate-y-10 data-[side=top]:data-starting-style:-translate-y-10 data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",e),...n,children:[t,a&&(0,r.jsxs)(i.H,{"data-slot":"sheet-close",render:(0,r.jsx)(x.$,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm"}),children:[(0,r.jsx)(p.A,{}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function y({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"sheet-header",className:(0,m.cn)("flex flex-col gap-0.5 p-4",e),...t})}function N({className:e,...t}){return(0,r.jsx)("div",{"data-slot":"sheet-footer",className:(0,m.cn)("mt-auto flex flex-col gap-2 p-4",e),...t})}function w({className:e,...t}){return(0,r.jsx)(c.L,{"data-slot":"sheet-title",className:(0,m.cn)("font-heading text-base font-medium text-foreground",e),...t})}function k({className:e,...t}){return(0,r.jsx)(u.r,{"data-slot":"sheet-description",className:(0,m.cn)("text-sm text-muted-foreground",e),...t})}}}]);